Skip to content

Commit

Permalink
prepare 1.6.4
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinMalfait committed May 29, 2022
1 parent 912af7e commit 842d071
Show file tree
Hide file tree
Showing 14 changed files with 45 additions and 98 deletions.
Expand Up @@ -171,7 +171,7 @@ describe('Rendering', () => {
})
)

describe('Equality', () => {
describe.skip('Equality', () => {
let options = [
{ id: 1, name: 'Alice' },
{ id: 2, name: 'Bob' },
Expand Down
13 changes: 2 additions & 11 deletions packages/@headlessui-react/src/components/combobox/combobox.tsx
Expand Up @@ -311,11 +311,10 @@ let ComboboxRoot = forwardRefWithAs(function Combobox<
props: Props<
TTag,
ComboboxRenderPropArg<TType>,
'value' | 'onChange' | 'disabled' | 'name' | 'nullable' | 'multiple' | 'by'
'value' | 'onChange' | 'disabled' | 'name' | 'nullable' | 'multiple'
> & {
value: TType
onChange(value: TType): void
by?: (keyof TType & string) | ((a: TType, z: TType) => boolean)
disabled?: boolean
__demoMode?: boolean
name?: string
Expand All @@ -328,7 +327,6 @@ let ComboboxRoot = forwardRefWithAs(function Combobox<
name,
value,
onChange: theirOnChange,
by = (a, z) => a === z,
disabled = false,
__demoMode = false,
nullable = false,
Expand All @@ -354,14 +352,7 @@ let ComboboxRoot = forwardRefWithAs(function Combobox<
let buttonRef = useRef<_Data['buttonRef']['current']>(null)
let optionsRef = useRef<_Data['optionsRef']['current']>(null)

let compare = useEvent(
typeof by === 'string'
? (a: TType, z: TType) => {
let property = by as unknown as keyof TType
return a[property] === z[property]
}
: by
)
let compare = useEvent((a, z) => a === z)

let isSelected: (value: TType) => boolean = useCallback(
(compareValue) =>
Expand Down
Expand Up @@ -163,7 +163,7 @@ describe('Rendering', () => {
})
)

describe('Equality', () => {
describe.skip('Equality', () => {
let options = [
{ id: 1, name: 'Alice' },
{ id: 2, name: 'Bob' },
Expand Down
13 changes: 2 additions & 11 deletions packages/@headlessui-react/src/components/listbox/listbox.tsx
Expand Up @@ -311,11 +311,10 @@ let ListboxRoot = forwardRefWithAs(function Listbox<
props: Props<
TTag,
ListboxRenderPropArg,
'value' | 'onChange' | 'disabled' | 'horizontal' | 'name' | 'multiple' | 'by'
'value' | 'onChange' | 'disabled' | 'horizontal' | 'name' | 'multiple'
> & {
value: TType
onChange(value: TType): void
by?: (keyof TType & string) | ((a: TType, z: TType) => boolean)
disabled?: boolean
horizontal?: boolean
name?: string
Expand All @@ -327,7 +326,6 @@ let ListboxRoot = forwardRefWithAs(function Listbox<
value,
name,
onChange,
by = (a, z) => a === z,
disabled = false,
horizontal = false,
multiple = false,
Expand All @@ -343,14 +341,7 @@ let ListboxRoot = forwardRefWithAs(function Listbox<
value,
onChange,
mode: multiple ? ValueMode.Multi : ValueMode.Single,
compare: useEvent(
typeof by === 'string'
? (a: TType, z: TType) => {
let property = by as unknown as keyof TType
return a[property] === z[property]
}
: by
),
compare: useEvent((a, z) => a === z),
},
},
labelRef: createRef(),
Expand Down
Expand Up @@ -322,7 +322,7 @@ describe('Rendering', () => {
})
)

it(
it.skip(
'should expose internal data as a render prop',
suppressConsoleLogs(async () => {
function Example() {
Expand Down Expand Up @@ -372,7 +372,7 @@ describe('Rendering', () => {
})
)

describe('Equality', () => {
describe.skip('Equality', () => {
let options = [
{ id: 1, name: 'Alice' },
{ id: 2, name: 'Bob' },
Expand Down
Expand Up @@ -113,25 +113,17 @@ let RadioGroupRoot = forwardRefWithAs(function RadioGroup<
props: Props<
TTag,
RadioGroupRenderPropArg,
RadioGroupPropsWeControl | 'value' | 'onChange' | 'disabled' | 'name' | 'by'
RadioGroupPropsWeControl | 'value' | 'onChange' | 'disabled' | 'name'
> & {
value: TType
onChange(value: TType): void
by?: (keyof TType & string) | ((a: TType, z: TType) => boolean)
disabled?: boolean
name?: string
},
ref: Ref<HTMLElement>
) {
let { value, name, onChange, by = (a, z) => a === z, disabled = false, ...theirProps } = props
let compare = useEvent(
typeof by === 'string'
? (a: TType, z: TType) => {
let property = by as unknown as keyof TType
return a[property] === z[property]
}
: by
)
let { value, name, onChange, disabled = false, ...theirProps } = props
let compare = useEvent((a, z) => a === z)
let [state, dispatch] = useReducer(stateReducer, { options: [] } as StateDefinition<TType>)
let options = state.options as unknown as Option<TType>[]
let [labelledby, LabelProvider] = useLabels()
Expand Down
28 changes: 14 additions & 14 deletions packages/@headlessui-react/src/utils/render.ts
Expand Up @@ -126,20 +126,20 @@ function _render<TTag extends ElementType, TSlot>(
}

let dataAttributes: Record<string, string> = {}
if (slot) {
let exposeState = false
let states = []
for (let [k, v] of Object.entries(slot)) {
if (typeof v === 'boolean') {
exposeState = true
}
if (v === true) {
states.push(k)
}
}

if (exposeState) dataAttributes[`data-headlessui-state`] = states.join(' ')
}
// if (slot) {
// let exposeState = false
// let states = []
// for (let [k, v] of Object.entries(slot)) {
// if (typeof v === 'boolean') {
// exposeState = true
// }
// if (v === true) {
// states.push(k)
// }
// }
//
// if (exposeState) dataAttributes[`data-headlessui-state`] = states.join(' ')
// }

if (Component === Fragment) {
if (Object.keys(compact(rest)).length > 0) {
Expand Down
Expand Up @@ -226,7 +226,7 @@ describe('Rendering', () => {
})
)

describe('Equality', () => {
describe.skip('Equality', () => {
let options = [
{ id: 1, name: 'Alice' },
{ id: 2, name: 'Bob' },
Expand Down
11 changes: 1 addition & 10 deletions packages/@headlessui-vue/src/components/combobox/combobox.ts
Expand Up @@ -35,10 +35,6 @@ import { useOutsideClick } from '../../hooks/use-outside-click'
import { Hidden, Features as HiddenFeatures } from '../../internal/hidden'
import { objectToFormEntries } from '../../utils/form'

function defaultComparator<T>(a: T, z: T): boolean {
return a === z
}

enum ComboboxStates {
Open,
Closed,
Expand Down Expand Up @@ -116,7 +112,6 @@ export let Combobox = defineComponent({
props: {
as: { type: [Object, String], default: 'template' },
disabled: { type: [Boolean], default: false },
by: { type: [String, Function], default: () => defaultComparator },
modelValue: { type: [Object, String, Number, Boolean] },
name: { type: String },
nullable: { type: Boolean, default: false },
Expand Down Expand Up @@ -180,11 +175,7 @@ export let Combobox = defineComponent({
value,
mode,
compare(a: any, z: any) {
if (typeof props.by === 'string') {
let property = props.by as unknown as any
return a[property] === z[property]
}
return props.by(a, z)
return a === z
},
nullable,
inputRef,
Expand Down
Expand Up @@ -199,7 +199,7 @@ describe('Rendering', () => {
})
)

describe('Equality', () => {
describe.skip('Equality', () => {
let options = [
{ id: 1, name: 'Alice' },
{ id: 2, name: 'Bob' },
Expand Down
11 changes: 1 addition & 10 deletions packages/@headlessui-vue/src/components/listbox/listbox.ts
Expand Up @@ -33,10 +33,6 @@ import { useOutsideClick } from '../../hooks/use-outside-click'
import { Hidden, Features as HiddenFeatures } from '../../internal/hidden'
import { objectToFormEntries } from '../../utils/form'

function defaultComparator<T>(a: T, z: T): boolean {
return a === z
}

enum ListboxStates {
Open,
Closed,
Expand Down Expand Up @@ -116,7 +112,6 @@ export let Listbox = defineComponent({
props: {
as: { type: [Object, String], default: 'template' },
disabled: { type: [Boolean], default: false },
by: { type: [String, Function], default: () => defaultComparator },
horizontal: { type: [Boolean], default: false },
modelValue: { type: [Object, String, Number, Boolean] },
name: { type: String, optional: true },
Expand Down Expand Up @@ -172,11 +167,7 @@ export let Listbox = defineComponent({
value,
mode,
compare(a: any, z: any) {
if (typeof props.by === 'string') {
let property = props.by as unknown as any
return a[property] === z[property]
}
return props.by(a, z)
return a === z
},
orientation: computed(() => (props.horizontal ? 'horizontal' : 'vertical')),
labelRef,
Expand Down
Expand Up @@ -505,7 +505,7 @@ describe('Rendering', () => {
assertActiveElement(getByText('Option 3'))
})

describe('Equality', () => {
describe.skip('Equality', () => {
let options = [
{ id: 1, name: 'Alice' },
{ id: 2, name: 'Bob' },
Expand Down
Expand Up @@ -27,10 +27,6 @@ import { Hidden, Features as HiddenFeatures } from '../../internal/hidden'
import { attemptSubmit, objectToFormEntries } from '../../utils/form'
import { getOwnerDocument } from '../../utils/owner'

function defaultComparator<T>(a: T, z: T): boolean {
return a === z
}

interface Option {
id: string
element: Ref<HTMLElement | null>
Expand Down Expand Up @@ -75,7 +71,6 @@ export let RadioGroup = defineComponent({
props: {
as: { type: [Object, String], default: 'div' },
disabled: { type: [Boolean], default: false },
by: { type: [String, Function], default: () => defaultComparator },
modelValue: { type: [Object, String, Number, Boolean] },
name: { type: String, optional: true },
},
Expand Down Expand Up @@ -106,11 +101,7 @@ export let RadioGroup = defineComponent({
)
),
compare(a: any, z: any) {
if (typeof props.by === 'string') {
let property = props.by as unknown as any
return a[property] === z[property]
}
return props.by(a, z)
return a === z
},
change(nextValue: unknown) {
if (props.disabled) return false
Expand Down
28 changes: 14 additions & 14 deletions packages/@headlessui-vue/src/utils/render.ts
Expand Up @@ -86,20 +86,20 @@ function _render({
let children = slots.default?.(slot)

let dataAttributes: Record<string, string> = {}
if (slot) {
let exposeState = false
let states = []
for (let [k, v] of Object.entries(slot)) {
if (typeof v === 'boolean') {
exposeState = true
}
if (v === true) {
states.push(k)
}
}

if (exposeState) dataAttributes[`data-headlessui-state`] = states.join(' ')
}
// if (slot) {
// let exposeState = false
// let states = []
// for (let [k, v] of Object.entries(slot)) {
// if (typeof v === 'boolean') {
// exposeState = true
// }
// if (v === true) {
// states.push(k)
// }
// }
//
// if (exposeState) dataAttributes[`data-headlessui-state`] = states.join(' ')
// }

if (as === 'template') {
if (Object.keys(incomingProps).length > 0 || Object.keys(attrs).length > 0) {
Expand Down

0 comments on commit 842d071

Please sign in to comment.