Revert "prepare 1.6.5"

This reverts commit c31136032b.
This commit is contained in:
Robin Malfait
2022-06-20 18:00:31 +02:00
parent f4d1acb5d7
commit bc0b64a8c9
14 changed files with 98 additions and 45 deletions
@@ -172,7 +172,7 @@ describe('Rendering', () => {
})
)
describe.skip('Equality', () => {
describe('Equality', () => {
let options = [
{ id: 1, name: 'Alice' },
{ id: 2, name: 'Bob' },
@@ -311,10 +311,11 @@ let ComboboxRoot = forwardRefWithAs(function Combobox<
props: Props<
TTag,
ComboboxRenderPropArg<TType>,
'value' | 'onChange' | 'disabled' | 'name' | 'nullable' | 'multiple'
'value' | 'onChange' | 'disabled' | 'name' | 'nullable' | 'multiple' | 'by'
> & {
value: TType
onChange(value: TType): void
by?: (keyof TType & string) | ((a: TType, z: TType) => boolean)
disabled?: boolean
__demoMode?: boolean
name?: string
@@ -327,6 +328,7 @@ let ComboboxRoot = forwardRefWithAs(function Combobox<
name,
value,
onChange: theirOnChange,
by = (a, z) => a === z,
disabled = false,
__demoMode = false,
nullable = false,
@@ -352,7 +354,14 @@ let ComboboxRoot = forwardRefWithAs(function Combobox<
let buttonRef = useRef<_Data['buttonRef']['current']>(null)
let optionsRef = useRef<_Data['optionsRef']['current']>(null)
let compare = useEvent((a, z) => a === z)
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 isSelected: (value: TType) => boolean = useCallback(
(compareValue) =>
@@ -163,7 +163,7 @@ describe('Rendering', () => {
})
)
describe.skip('Equality', () => {
describe('Equality', () => {
let options = [
{ id: 1, name: 'Alice' },
{ id: 2, name: 'Bob' },
@@ -311,10 +311,11 @@ let ListboxRoot = forwardRefWithAs(function Listbox<
props: Props<
TTag,
ListboxRenderPropArg,
'value' | 'onChange' | 'disabled' | 'horizontal' | 'name' | 'multiple'
'value' | 'onChange' | 'disabled' | 'horizontal' | 'name' | 'multiple' | 'by'
> & {
value: TType
onChange(value: TType): void
by?: (keyof TType & string) | ((a: TType, z: TType) => boolean)
disabled?: boolean
horizontal?: boolean
name?: string
@@ -326,6 +327,7 @@ let ListboxRoot = forwardRefWithAs(function Listbox<
value,
name,
onChange,
by = (a, z) => a === z,
disabled = false,
horizontal = false,
multiple = false,
@@ -341,7 +343,14 @@ let ListboxRoot = forwardRefWithAs(function Listbox<
value,
onChange,
mode: multiple ? ValueMode.Multi : ValueMode.Single,
compare: useEvent((a, z) => a === z),
compare: useEvent(
typeof by === 'string'
? (a: TType, z: TType) => {
let property = by as unknown as keyof TType
return a[property] === z[property]
}
: by
),
},
},
labelRef: createRef(),
@@ -322,7 +322,7 @@ describe('Rendering', () => {
})
)
it.skip(
it(
'should expose internal data as a render prop',
suppressConsoleLogs(async () => {
function Example() {
@@ -372,7 +372,7 @@ describe('Rendering', () => {
})
)
describe.skip('Equality', () => {
describe('Equality', () => {
let options = [
{ id: 1, name: 'Alice' },
{ id: 2, name: 'Bob' },
@@ -113,17 +113,25 @@ let RadioGroupRoot = forwardRefWithAs(function RadioGroup<
props: Props<
TTag,
RadioGroupRenderPropArg,
RadioGroupPropsWeControl | 'value' | 'onChange' | 'disabled' | 'name'
RadioGroupPropsWeControl | 'value' | 'onChange' | 'disabled' | 'name' | 'by'
> & {
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, disabled = false, ...theirProps } = props
let compare = useEvent((a, z) => a === z)
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 [state, dispatch] = useReducer(stateReducer, { options: [] } as StateDefinition<TType>)
let options = state.options as unknown as Option<TType>[]
let [labelledby, LabelProvider] = useLabels()
+14 -14
View File
@@ -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) {
@@ -203,7 +203,7 @@ describe('Rendering', () => {
})
)
describe.skip('Equality', () => {
describe('Equality', () => {
let options = [
{ id: 1, name: 'Alice' },
{ id: 2, name: 'Bob' },
@@ -35,6 +35,10 @@ 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,
@@ -112,6 +116,7 @@ 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 },
@@ -175,7 +180,11 @@ export let Combobox = defineComponent({
value,
mode,
compare(a: any, z: any) {
return a === z
if (typeof props.by === 'string') {
let property = props.by as unknown as any
return a[property] === z[property]
}
return props.by(a, z)
},
nullable,
inputRef,
@@ -183,7 +183,7 @@ describe('Rendering', () => {
})
)
describe.skip('Equality', () => {
describe('Equality', () => {
let options = [
{ id: 1, name: 'Alice' },
{ id: 2, name: 'Bob' },
@@ -33,6 +33,10 @@ 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,
@@ -112,6 +116,7 @@ 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 },
@@ -167,7 +172,11 @@ export let Listbox = defineComponent({
value,
mode,
compare(a: any, z: any) {
return a === z
if (typeof props.by === 'string') {
let property = props.by as unknown as any
return a[property] === z[property]
}
return props.by(a, z)
},
orientation: computed(() => (props.horizontal ? 'horizontal' : 'vertical')),
labelRef,
@@ -496,7 +496,7 @@ describe('Rendering', () => {
assertActiveElement(getByText('Option 3'))
})
describe.skip('Equality', () => {
describe('Equality', () => {
let options = [
{ id: 1, name: 'Alice' },
{ id: 2, name: 'Bob' },
@@ -27,6 +27,10 @@ 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>
@@ -71,6 +75,7 @@ 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 },
},
@@ -102,7 +107,11 @@ export let RadioGroup = defineComponent({
)
),
compare(a: any, z: any) {
return a === z
if (typeof props.by === 'string') {
let property = props.by as unknown as any
return a[property] === z[property]
}
return props.by(a, z)
},
change(nextValue: unknown) {
if (props.disabled) return false
+14 -14
View File
@@ -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') {
children = flattenFragments(children as VNode[])