@yamada-ui/react 2.3.0-next-20260516220903 → 2.3.0-next-20260517014349
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/pin-input/use-pin-input.cjs +10 -9
- package/dist/cjs/components/pin-input/use-pin-input.cjs.map +1 -1
- package/dist/esm/components/pin-input/use-pin-input.js +10 -9
- package/dist/esm/components/pin-input/use-pin-input.js.map +1 -1
- package/dist/types/components/accordion/accordion.style.d.ts +1 -1
- package/dist/types/components/alert/alert.style.d.ts +1 -1
- package/dist/types/components/autocomplete/autocomplete.style.d.ts +1 -1
- package/dist/types/components/breadcrumb/breadcrumb.style.d.ts +1 -1
- package/dist/types/components/calendar/calendar.style.d.ts +2 -2
- package/dist/types/components/carousel/carousel.style.d.ts +2 -2
- package/dist/types/components/color-picker/color-picker.style.d.ts +1 -1
- package/dist/types/components/date-picker/date-picker.style.d.ts +1 -1
- package/dist/types/components/dropzone/dropzone.d.ts +1 -1
- package/dist/types/components/dropzone/dropzone.style.d.ts +1 -1
- package/dist/types/components/field/use-field-props.d.ts +1 -1
- package/dist/types/components/file-button/use-file-button.d.ts +2 -2
- package/dist/types/components/file-input/use-file-input.d.ts +2 -2
- package/dist/types/components/menu/menu.style.d.ts +2 -2
- package/dist/types/components/native-accordion/native-accordion.style.d.ts +2 -2
- package/dist/types/components/progress/use-progress.d.ts +6 -6
- package/dist/types/components/rating/rating.style.d.ts +2 -2
- package/dist/types/components/select/select.style.d.ts +1 -1
- package/dist/types/components/stat/stat.style.d.ts +2 -2
- package/dist/types/components/steps/steps.style.d.ts +1 -1
- package/dist/types/components/tabs/tabs.style.d.ts +1 -1
- package/dist/types/components/tree/tree.style.d.ts +1 -1
- package/dist/types/components/tree/use-tree.d.ts +4 -4
- package/dist/types/hooks/use-clickable/index.d.ts +2 -2
- package/dist/types/providers/i18n-provider/i18n-provider.d.ts +1 -1
- package/package.json +1 -1
|
@@ -134,24 +134,25 @@ const usePinInput = (props = {}) => {
|
|
|
134
134
|
return {
|
|
135
135
|
descendants,
|
|
136
136
|
items,
|
|
137
|
-
getInputProps: (0, react.useCallback)(({
|
|
137
|
+
getInputProps: (0, react.useCallback)(({ index, ...props }) => require_props.mergeProps({
|
|
138
138
|
...ariaProps,
|
|
139
139
|
...dataProps,
|
|
140
|
+
...eventProps,
|
|
140
141
|
type: mask ? "password" : type === "number" ? "tel" : "text",
|
|
141
|
-
"aria-labelledby":
|
|
142
|
+
"aria-labelledby": labelId,
|
|
142
143
|
autoComplete: otp ? "one-time-code" : "off",
|
|
143
144
|
disabled,
|
|
144
145
|
inputMode: type === "number" ? "numeric" : "text",
|
|
145
146
|
placeholder: focusedIndex === index && !readOnly && !props.readOnly ? "" : placeholder,
|
|
146
147
|
readOnly,
|
|
147
|
-
value: values[index] || ""
|
|
148
|
-
|
|
148
|
+
value: values[index] || ""
|
|
149
|
+
}, (0, require_utils_index.utils_exports.filterUndefined)(props), {
|
|
149
150
|
id: `${id}${index ? `-${index}` : ""}`,
|
|
150
|
-
onBlur
|
|
151
|
-
onChange:
|
|
152
|
-
onFocus:
|
|
153
|
-
onKeyDown:
|
|
154
|
-
}), [
|
|
151
|
+
onBlur,
|
|
152
|
+
onChange: onChange(index),
|
|
153
|
+
onFocus: onFocus(index),
|
|
154
|
+
onKeyDown: onKeyDown(index)
|
|
155
|
+
})(), [
|
|
155
156
|
ariaProps,
|
|
156
157
|
dataProps,
|
|
157
158
|
eventProps,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-pin-input.cjs","names":["createDescendants","useFieldProps","useControllableState","mergeProps"],"sources":["../../../../src/components/pin-input/use-pin-input.ts"],"sourcesContent":["\"use client\"\n\nimport type { ChangeEvent, KeyboardEvent } from \"react\"\nimport type { HTMLProps, PropGetter, RequiredPropGetter } from \"../../core\"\nimport type { FieldProps } from \"../field\"\nimport { useCallback, useEffect, useId, useState } from \"react\"\nimport { mergeProps } from \"../../core\"\nimport { useControllableState } from \"../../hooks/use-controllable-state\"\nimport { createDescendants } from \"../../hooks/use-descendants\"\nimport { cx, filterUndefined, handlerAll, runKeyAction } from \"../../utils\"\nimport { useFieldProps } from \"../field\"\n\nconst {\n DescendantsContext: PinInputDescendantsContext,\n useDescendant: usePinInputDescendant,\n useDescendants: usePinInputDescendants,\n} = createDescendants<HTMLInputElement>()\n\nexport {\n PinInputDescendantsContext,\n usePinInputDescendant,\n usePinInputDescendants,\n}\n\nconst toArray = (value?: string) => value?.split(\"\")\n\nconst validate = (value: string, type: UsePinInputProps[\"type\"]) => {\n const NUMERIC_REGEX = /^[0-9]+$/\n const ALPHA_NUMERIC_REGEX = /^[a-zA-Z0-9]+$/i\n\n const regex = type === \"alphanumeric\" ? ALPHA_NUMERIC_REGEX : NUMERIC_REGEX\n\n return regex.test(value)\n}\n\nexport interface UsePinInputProps\n extends\n Omit<HTMLProps, \"defaultValue\" | \"mask\" | \"onChange\" | \"value\">,\n FieldProps {\n /**\n * If `true`, the pin input receives focus on mount.\n *\n * @default false\n */\n autoFocus?: boolean\n /**\n * The initial value of the pin input.\n */\n defaultValue?: string\n /**\n * The top-level id string that will be applied to the input fields.\n * The index of the input will be appended to this top-level id.\n */\n id?: string\n /**\n * The number of inputs to display.\n *\n * @default 4\n */\n items?: number\n /**\n * If `true`, focus will move automatically to the next input once filled.\n *\n * @default true\n */\n manageFocus?: boolean\n /**\n * If `true`, the input's value will be masked just like `type=password`.\n */\n mask?: boolean\n /**\n * If `true`, the pin input component signals to its fields that they should.\n */\n otp?: boolean\n /**\n * The placeholder for the pin input.\n *\n * @default '◯'\n */\n placeholder?: string\n /**\n * The type of values the pin-input should allow.\n *\n * @default 'number'\n */\n type?: \"alphanumeric\" | \"number\"\n /**\n * The value of the pin input.\n */\n value?: string\n /**\n * Function called on input change.\n */\n onChange?: (value: string) => void\n /**\n * Function called when all inputs have valid values.\n */\n onComplete?: (value: string) => void\n}\n\nexport const usePinInput = (props: UsePinInputProps = {}) => {\n const uuid = useId()\n const {\n context: { labelId } = {},\n props: {\n id = uuid,\n type = \"number\",\n autoFocus,\n defaultValue,\n disabled,\n items = 4,\n manageFocus = true,\n mask,\n otp = false,\n placeholder = \"◯\",\n readOnly,\n value,\n onChange: onChangeProp,\n onComplete,\n ...rest\n },\n ariaProps,\n dataProps,\n eventProps,\n } = useFieldProps(props)\n const descendants = usePinInputDescendants()\n const [moveFocus, setMoveFocus] = useState<boolean>(true)\n const [focusedIndex, setFocusedIndex] = useState<number>(-1)\n const [values, setValues] = useControllableState<string[]>({\n defaultValue: toArray(defaultValue) || [],\n value: toArray(value),\n onChange: (values) => onChangeProp?.(values.join(\"\")),\n })\n\n const focusNext = useCallback(\n (index: number) => {\n if (!moveFocus || !manageFocus) return\n\n const next = descendants.nextValue(index, false)\n\n if (!next) return\n\n requestAnimationFrame(() => next.node.focus())\n },\n [descendants, moveFocus, manageFocus],\n )\n\n const focusInputField = useCallback(\n (direction: \"next\" | \"prev\", index: number) => {\n const input =\n direction === \"next\"\n ? descendants.nextValue(index, false)\n : descendants.prevValue(index, false)\n\n if (!input) return\n\n const valueLength = input.node.value.length\n\n requestAnimationFrame(() => {\n input.node.focus()\n input.node.setSelectionRange(0, valueLength)\n })\n },\n [descendants],\n )\n\n const setValue = useCallback(\n (value: string, index: number, focus = true) => {\n let nextValues = [...values]\n\n nextValues[index] = value\n\n setValues(nextValues)\n\n nextValues = nextValues.filter(Boolean)\n\n const complete = value !== \"\" && nextValues.length === descendants.count()\n\n if (complete) {\n onComplete?.(nextValues.join(\"\"))\n descendants.value(index)?.node.blur()\n } else if (focus) {\n focusNext(index)\n }\n },\n [values, setValues, descendants, onComplete, focusNext],\n )\n\n const getNextValue = useCallback(\n (value: string | undefined, eventValue: string) => {\n let nextValue = eventValue\n\n if (!value?.length) return nextValue\n\n if (value.startsWith(eventValue.charAt(0))) {\n nextValue = eventValue.charAt(1)\n } else if (value.startsWith(eventValue.charAt(1))) {\n nextValue = eventValue.charAt(0)\n }\n\n return nextValue\n },\n [],\n )\n\n const onChange = useCallback(\n (index: number) =>\n ({ target }: ChangeEvent<HTMLInputElement>) => {\n const eventValue = target.value\n const currentValue = values[index]\n const nextValue = getNextValue(currentValue, eventValue)\n\n if (nextValue === \"\") {\n setValue(\"\", index)\n\n return\n }\n\n if (eventValue.length > 2) {\n if (!validate(eventValue, type)) return\n\n const nextValue = eventValue\n .split(\"\")\n .filter((_, index) => index < descendants.count())\n\n setValues(nextValue)\n\n if (nextValue.length === descendants.count()) {\n onComplete?.(nextValue.join(\"\"))\n descendants.value(index)?.node.blur()\n }\n } else {\n if (validate(nextValue, type)) setValue(nextValue, index)\n\n setMoveFocus(true)\n }\n },\n [descendants, getNextValue, onComplete, setValue, setValues, type, values],\n )\n\n const onKeyDown = useCallback(\n (index: number) => (ev: KeyboardEvent<HTMLInputElement>) => {\n if (!manageFocus) return\n\n runKeyAction(\n ev,\n {\n ArrowLeft: (ev) => {\n ev.preventDefault()\n focusInputField(\"prev\", index)\n },\n ArrowRight: (ev) => {\n ev.preventDefault()\n focusInputField(\"next\", index)\n },\n Backspace: (ev) => {\n if ((ev.target as HTMLInputElement).value === \"\") {\n const prevInput = descendants.prevValue(index, false)\n\n if (!prevInput) return\n\n setValue(\"\", index - 1, false)\n prevInput.node.focus()\n setMoveFocus(true)\n } else {\n setMoveFocus(false)\n }\n },\n },\n { preventDefault: false },\n )\n },\n [descendants, focusInputField, manageFocus, setValue],\n )\n\n const onFocus = useCallback(\n (index: number) => () => setFocusedIndex(index),\n [],\n )\n\n const onBlur = useCallback(() => setFocusedIndex(-1), [])\n\n useEffect(() => {\n if (!autoFocus) return\n\n const firstValue = descendants.firstValue()\n\n if (!firstValue) return\n\n requestAnimationFrame(() => firstValue.node.focus())\n }, [autoFocus, descendants])\n\n const getRootProps: PropGetter = useCallback(\n (props) => mergeProps({ role: \"group\" }, rest, props)(),\n [rest],\n )\n\n const getInputProps: RequiredPropGetter<\"input\", { index: number }> =\n useCallback(\n ({ \"aria-labelledby\": ariaLabelledby, index, ...props }) => ({\n ...ariaProps,\n ...dataProps,\n type: mask ? \"password\" : type === \"number\" ? \"tel\" : \"text\",\n \"aria-labelledby\": cx(ariaLabelledby, labelId),\n autoComplete: otp ? \"one-time-code\" : \"off\",\n disabled,\n inputMode: type === \"number\" ? \"numeric\" : \"text\",\n placeholder:\n focusedIndex === index && !readOnly && !props.readOnly\n ? \"\"\n : placeholder,\n readOnly,\n value: values[index] || \"\",\n ...filterUndefined(props),\n id: `${id}${index ? `-${index}` : \"\"}`,\n onBlur: handlerAll(eventProps.onBlur, props.onBlur, onBlur),\n onChange: handlerAll(props.onChange, onChange(index)),\n onFocus: handlerAll(eventProps.onFocus, props.onFocus, onFocus(index)),\n onKeyDown: handlerAll(props.onKeyDown, onKeyDown(index)),\n }),\n [\n ariaProps,\n dataProps,\n eventProps,\n mask,\n type,\n labelId,\n otp,\n disabled,\n focusedIndex,\n readOnly,\n placeholder,\n values,\n id,\n onBlur,\n onChange,\n onFocus,\n onKeyDown,\n ],\n )\n\n return {\n descendants,\n items,\n getInputProps,\n getRootProps,\n }\n}\n\nexport type UsePinInputReturn = ReturnType<typeof usePinInput>\n"],"mappings":";;;;;;;;;;AAYA,MAAM,EACJ,oBAAoB,4BACpB,eAAe,uBACf,gBAAgB,2BACdA,oCAAAA,mBAAqC;AAQzC,MAAM,WAAW,UAAmB,OAAO,MAAM,GAAG;AAEpD,MAAM,YAAY,OAAe,SAAmC;CAMlE,QAFc,SAAS,iBAAiB,oBAAsB,YAEjD,KAAK,MAAM;;AAoE1B,MAAa,eAAe,QAA0B,EAAE,KAAK;CAC3D,MAAM,QAAA,GAAA,MAAA,QAAc;CACpB,MAAM,EACJ,SAAS,EAAE,YAAY,EAAE,EACzB,OAAO,EACL,KAAK,MACL,OAAO,UACP,WACA,cACA,UACA,QAAQ,GACR,cAAc,MACd,MACA,MAAM,OACN,cAAc,KACd,UACA,OACA,UAAU,cACV,YACA,GAAG,QAEL,WACA,WACA,eACEC,wBAAAA,c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,GAAA,oBAAA,cAAA,YAAqB,MAAM,UAAU,SAAS,MAAM,CAAC;GACrD,UAAA,GAAA,oBAAA,cAAA,YAAoB,WAAW,SAAS,MAAM,SAAS,QAAQ,MAAM,CAAC;GACtE,YAAA,GAAA,oBAAA,cAAA,YAAsB,MAAM,WAAW,UAAU,MAAM,CAAC;GACzD,GACD;GACE;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACD,CAMU;EACb;EACD"}
|
|
1
|
+
{"version":3,"file":"use-pin-input.cjs","names":["createDescendants","useFieldProps","useControllableState","mergeProps"],"sources":["../../../../src/components/pin-input/use-pin-input.ts"],"sourcesContent":["\"use client\"\n\nimport type { ChangeEvent, KeyboardEvent } from \"react\"\nimport type { HTMLProps, PropGetter, RequiredPropGetter } from \"../../core\"\nimport type { FieldProps } from \"../field\"\nimport { useCallback, useEffect, useId, useState } from \"react\"\nimport { mergeProps } from \"../../core\"\nimport { useControllableState } from \"../../hooks/use-controllable-state\"\nimport { createDescendants } from \"../../hooks/use-descendants\"\nimport { filterUndefined, runKeyAction } from \"../../utils\"\nimport { useFieldProps } from \"../field\"\n\nconst {\n DescendantsContext: PinInputDescendantsContext,\n useDescendant: usePinInputDescendant,\n useDescendants: usePinInputDescendants,\n} = createDescendants<HTMLInputElement>()\n\nexport {\n PinInputDescendantsContext,\n usePinInputDescendant,\n usePinInputDescendants,\n}\n\nconst toArray = (value?: string) => value?.split(\"\")\n\nconst validate = (value: string, type: UsePinInputProps[\"type\"]) => {\n const NUMERIC_REGEX = /^[0-9]+$/\n const ALPHA_NUMERIC_REGEX = /^[a-zA-Z0-9]+$/i\n\n const regex = type === \"alphanumeric\" ? ALPHA_NUMERIC_REGEX : NUMERIC_REGEX\n\n return regex.test(value)\n}\n\nexport interface UsePinInputProps\n extends\n Omit<HTMLProps, \"defaultValue\" | \"mask\" | \"onChange\" | \"value\">,\n FieldProps {\n /**\n * If `true`, the pin input receives focus on mount.\n *\n * @default false\n */\n autoFocus?: boolean\n /**\n * The initial value of the pin input.\n */\n defaultValue?: string\n /**\n * The top-level id string that will be applied to the input fields.\n * The index of the input will be appended to this top-level id.\n */\n id?: string\n /**\n * The number of inputs to display.\n *\n * @default 4\n */\n items?: number\n /**\n * If `true`, focus will move automatically to the next input once filled.\n *\n * @default true\n */\n manageFocus?: boolean\n /**\n * If `true`, the input's value will be masked just like `type=password`.\n */\n mask?: boolean\n /**\n * If `true`, the pin input component signals to its fields that they should.\n */\n otp?: boolean\n /**\n * The placeholder for the pin input.\n *\n * @default '◯'\n */\n placeholder?: string\n /**\n * The type of values the pin-input should allow.\n *\n * @default 'number'\n */\n type?: \"alphanumeric\" | \"number\"\n /**\n * The value of the pin input.\n */\n value?: string\n /**\n * Function called on input change.\n */\n onChange?: (value: string) => void\n /**\n * Function called when all inputs have valid values.\n */\n onComplete?: (value: string) => void\n}\n\nexport const usePinInput = (props: UsePinInputProps = {}) => {\n const uuid = useId()\n const {\n context: { labelId } = {},\n props: {\n id = uuid,\n type = \"number\",\n autoFocus,\n defaultValue,\n disabled,\n items = 4,\n manageFocus = true,\n mask,\n otp = false,\n placeholder = \"◯\",\n readOnly,\n value,\n onChange: onChangeProp,\n onComplete,\n ...rest\n },\n ariaProps,\n dataProps,\n eventProps,\n } = useFieldProps(props)\n const descendants = usePinInputDescendants()\n const [moveFocus, setMoveFocus] = useState<boolean>(true)\n const [focusedIndex, setFocusedIndex] = useState<number>(-1)\n const [values, setValues] = useControllableState<string[]>({\n defaultValue: toArray(defaultValue) || [],\n value: toArray(value),\n onChange: (values) => onChangeProp?.(values.join(\"\")),\n })\n\n const focusNext = useCallback(\n (index: number) => {\n if (!moveFocus || !manageFocus) return\n\n const next = descendants.nextValue(index, false)\n\n if (!next) return\n\n requestAnimationFrame(() => next.node.focus())\n },\n [descendants, moveFocus, manageFocus],\n )\n\n const focusInputField = useCallback(\n (direction: \"next\" | \"prev\", index: number) => {\n const input =\n direction === \"next\"\n ? descendants.nextValue(index, false)\n : descendants.prevValue(index, false)\n\n if (!input) return\n\n const valueLength = input.node.value.length\n\n requestAnimationFrame(() => {\n input.node.focus()\n input.node.setSelectionRange(0, valueLength)\n })\n },\n [descendants],\n )\n\n const setValue = useCallback(\n (value: string, index: number, focus = true) => {\n let nextValues = [...values]\n\n nextValues[index] = value\n\n setValues(nextValues)\n\n nextValues = nextValues.filter(Boolean)\n\n const complete = value !== \"\" && nextValues.length === descendants.count()\n\n if (complete) {\n onComplete?.(nextValues.join(\"\"))\n descendants.value(index)?.node.blur()\n } else if (focus) {\n focusNext(index)\n }\n },\n [values, setValues, descendants, onComplete, focusNext],\n )\n\n const getNextValue = useCallback(\n (value: string | undefined, eventValue: string) => {\n let nextValue = eventValue\n\n if (!value?.length) return nextValue\n\n if (value.startsWith(eventValue.charAt(0))) {\n nextValue = eventValue.charAt(1)\n } else if (value.startsWith(eventValue.charAt(1))) {\n nextValue = eventValue.charAt(0)\n }\n\n return nextValue\n },\n [],\n )\n\n const onChange = useCallback(\n (index: number) =>\n ({ target }: ChangeEvent<HTMLInputElement>) => {\n const eventValue = target.value\n const currentValue = values[index]\n const nextValue = getNextValue(currentValue, eventValue)\n\n if (nextValue === \"\") {\n setValue(\"\", index)\n\n return\n }\n\n if (eventValue.length > 2) {\n if (!validate(eventValue, type)) return\n\n const nextValue = eventValue\n .split(\"\")\n .filter((_, index) => index < descendants.count())\n\n setValues(nextValue)\n\n if (nextValue.length === descendants.count()) {\n onComplete?.(nextValue.join(\"\"))\n descendants.value(index)?.node.blur()\n }\n } else {\n if (validate(nextValue, type)) setValue(nextValue, index)\n\n setMoveFocus(true)\n }\n },\n [descendants, getNextValue, onComplete, setValue, setValues, type, values],\n )\n\n const onKeyDown = useCallback(\n (index: number) => (ev: KeyboardEvent<HTMLInputElement>) => {\n if (!manageFocus) return\n\n runKeyAction(\n ev,\n {\n ArrowLeft: (ev) => {\n ev.preventDefault()\n focusInputField(\"prev\", index)\n },\n ArrowRight: (ev) => {\n ev.preventDefault()\n focusInputField(\"next\", index)\n },\n Backspace: (ev) => {\n if ((ev.target as HTMLInputElement).value === \"\") {\n const prevInput = descendants.prevValue(index, false)\n\n if (!prevInput) return\n\n setValue(\"\", index - 1, false)\n prevInput.node.focus()\n setMoveFocus(true)\n } else {\n setMoveFocus(false)\n }\n },\n },\n { preventDefault: false },\n )\n },\n [descendants, focusInputField, manageFocus, setValue],\n )\n\n const onFocus = useCallback(\n (index: number) => () => setFocusedIndex(index),\n [],\n )\n\n const onBlur = useCallback(() => setFocusedIndex(-1), [])\n\n useEffect(() => {\n if (!autoFocus) return\n\n const firstValue = descendants.firstValue()\n\n if (!firstValue) return\n\n requestAnimationFrame(() => firstValue.node.focus())\n }, [autoFocus, descendants])\n\n const getRootProps: PropGetter = useCallback(\n (props) => mergeProps({ role: \"group\" }, rest, props)(),\n [rest],\n )\n\n const getInputProps: RequiredPropGetter<\"input\", { index: number }> =\n useCallback(\n ({ index, ...props }) =>\n mergeProps(\n {\n ...ariaProps,\n ...dataProps,\n ...eventProps,\n type: mask ? \"password\" : type === \"number\" ? \"tel\" : \"text\",\n \"aria-labelledby\": labelId,\n autoComplete: otp ? \"one-time-code\" : \"off\",\n disabled,\n inputMode: type === \"number\" ? \"numeric\" : \"text\",\n placeholder:\n focusedIndex === index && !readOnly && !props.readOnly\n ? \"\"\n : placeholder,\n readOnly,\n value: values[index] || \"\",\n },\n filterUndefined(props),\n {\n id: `${id}${index ? `-${index}` : \"\"}`,\n onBlur,\n onChange: onChange(index),\n onFocus: onFocus(index),\n onKeyDown: onKeyDown(index),\n },\n )(),\n [\n ariaProps,\n dataProps,\n eventProps,\n mask,\n type,\n labelId,\n otp,\n disabled,\n focusedIndex,\n readOnly,\n placeholder,\n values,\n id,\n onBlur,\n onChange,\n onFocus,\n onKeyDown,\n ],\n )\n\n return {\n descendants,\n items,\n getInputProps,\n getRootProps,\n }\n}\n\nexport type UsePinInputReturn = ReturnType<typeof usePinInput>\n"],"mappings":";;;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AA,MAAA,cAnDG,EAAE,OAAO,GAAG,YACXA,cAAAA,WACE;GACE,GAAG;GACH,GAAG;GACH,GAAG;GACH,MAAM,OAAO,aAAa,SAAS,WAAW,QAAQ;GACtD,mBAAmB;GACnB,cAAc,MAAM,kBAAkB;GACtC;GACA,WAAW,SAAS,WAAW,YAAY;GAC3C,aACE,iBAAiB,SAAS,CAAC,YAAY,CAAC,MAAM,WAC1C,KACA;GACN;GACA,OAAO,OAAO,UAAU;GACzB,GAAA,GAAA,oBAAA,cAAA,iBACe,MAAM,EACtB;GACE,IAAI,GAAG,KAAK,QAAQ,IAAI,UAAU;GAClC;GACA,UAAU,SAAS,MAAM;GACzB,SAAS,QAAQ,MAAM;GACvB,WAAW,UAAU,MAAM;GAC5B,CACF,EAAE,EACL;GACE;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACD,CAMU;EACb;EACD"}
|
|
@@ -133,24 +133,25 @@ const usePinInput = (props = {}) => {
|
|
|
133
133
|
return {
|
|
134
134
|
descendants,
|
|
135
135
|
items,
|
|
136
|
-
getInputProps: useCallback(({
|
|
136
|
+
getInputProps: useCallback(({ index, ...props }) => mergeProps({
|
|
137
137
|
...ariaProps,
|
|
138
138
|
...dataProps,
|
|
139
|
+
...eventProps,
|
|
139
140
|
type: mask ? "password" : type === "number" ? "tel" : "text",
|
|
140
|
-
"aria-labelledby":
|
|
141
|
+
"aria-labelledby": labelId,
|
|
141
142
|
autoComplete: otp ? "one-time-code" : "off",
|
|
142
143
|
disabled,
|
|
143
144
|
inputMode: type === "number" ? "numeric" : "text",
|
|
144
145
|
placeholder: focusedIndex === index && !readOnly && !props.readOnly ? "" : placeholder,
|
|
145
146
|
readOnly,
|
|
146
|
-
value: values[index] || ""
|
|
147
|
-
|
|
147
|
+
value: values[index] || ""
|
|
148
|
+
}, (0, utils_exports.filterUndefined)(props), {
|
|
148
149
|
id: `${id}${index ? `-${index}` : ""}`,
|
|
149
|
-
onBlur
|
|
150
|
-
onChange:
|
|
151
|
-
onFocus:
|
|
152
|
-
onKeyDown:
|
|
153
|
-
}), [
|
|
150
|
+
onBlur,
|
|
151
|
+
onChange: onChange(index),
|
|
152
|
+
onFocus: onFocus(index),
|
|
153
|
+
onKeyDown: onKeyDown(index)
|
|
154
|
+
})(), [
|
|
154
155
|
ariaProps,
|
|
155
156
|
dataProps,
|
|
156
157
|
eventProps,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-pin-input.js","names":[],"sources":["../../../../src/components/pin-input/use-pin-input.ts"],"sourcesContent":["\"use client\"\n\nimport type { ChangeEvent, KeyboardEvent } from \"react\"\nimport type { HTMLProps, PropGetter, RequiredPropGetter } from \"../../core\"\nimport type { FieldProps } from \"../field\"\nimport { useCallback, useEffect, useId, useState } from \"react\"\nimport { mergeProps } from \"../../core\"\nimport { useControllableState } from \"../../hooks/use-controllable-state\"\nimport { createDescendants } from \"../../hooks/use-descendants\"\nimport { cx, filterUndefined, handlerAll, runKeyAction } from \"../../utils\"\nimport { useFieldProps } from \"../field\"\n\nconst {\n DescendantsContext: PinInputDescendantsContext,\n useDescendant: usePinInputDescendant,\n useDescendants: usePinInputDescendants,\n} = createDescendants<HTMLInputElement>()\n\nexport {\n PinInputDescendantsContext,\n usePinInputDescendant,\n usePinInputDescendants,\n}\n\nconst toArray = (value?: string) => value?.split(\"\")\n\nconst validate = (value: string, type: UsePinInputProps[\"type\"]) => {\n const NUMERIC_REGEX = /^[0-9]+$/\n const ALPHA_NUMERIC_REGEX = /^[a-zA-Z0-9]+$/i\n\n const regex = type === \"alphanumeric\" ? ALPHA_NUMERIC_REGEX : NUMERIC_REGEX\n\n return regex.test(value)\n}\n\nexport interface UsePinInputProps\n extends\n Omit<HTMLProps, \"defaultValue\" | \"mask\" | \"onChange\" | \"value\">,\n FieldProps {\n /**\n * If `true`, the pin input receives focus on mount.\n *\n * @default false\n */\n autoFocus?: boolean\n /**\n * The initial value of the pin input.\n */\n defaultValue?: string\n /**\n * The top-level id string that will be applied to the input fields.\n * The index of the input will be appended to this top-level id.\n */\n id?: string\n /**\n * The number of inputs to display.\n *\n * @default 4\n */\n items?: number\n /**\n * If `true`, focus will move automatically to the next input once filled.\n *\n * @default true\n */\n manageFocus?: boolean\n /**\n * If `true`, the input's value will be masked just like `type=password`.\n */\n mask?: boolean\n /**\n * If `true`, the pin input component signals to its fields that they should.\n */\n otp?: boolean\n /**\n * The placeholder for the pin input.\n *\n * @default '◯'\n */\n placeholder?: string\n /**\n * The type of values the pin-input should allow.\n *\n * @default 'number'\n */\n type?: \"alphanumeric\" | \"number\"\n /**\n * The value of the pin input.\n */\n value?: string\n /**\n * Function called on input change.\n */\n onChange?: (value: string) => void\n /**\n * Function called when all inputs have valid values.\n */\n onComplete?: (value: string) => void\n}\n\nexport const usePinInput = (props: UsePinInputProps = {}) => {\n const uuid = useId()\n const {\n context: { labelId } = {},\n props: {\n id = uuid,\n type = \"number\",\n autoFocus,\n defaultValue,\n disabled,\n items = 4,\n manageFocus = true,\n mask,\n otp = false,\n placeholder = \"◯\",\n readOnly,\n value,\n onChange: onChangeProp,\n onComplete,\n ...rest\n },\n ariaProps,\n dataProps,\n eventProps,\n } = useFieldProps(props)\n const descendants = usePinInputDescendants()\n const [moveFocus, setMoveFocus] = useState<boolean>(true)\n const [focusedIndex, setFocusedIndex] = useState<number>(-1)\n const [values, setValues] = useControllableState<string[]>({\n defaultValue: toArray(defaultValue) || [],\n value: toArray(value),\n onChange: (values) => onChangeProp?.(values.join(\"\")),\n })\n\n const focusNext = useCallback(\n (index: number) => {\n if (!moveFocus || !manageFocus) return\n\n const next = descendants.nextValue(index, false)\n\n if (!next) return\n\n requestAnimationFrame(() => next.node.focus())\n },\n [descendants, moveFocus, manageFocus],\n )\n\n const focusInputField = useCallback(\n (direction: \"next\" | \"prev\", index: number) => {\n const input =\n direction === \"next\"\n ? descendants.nextValue(index, false)\n : descendants.prevValue(index, false)\n\n if (!input) return\n\n const valueLength = input.node.value.length\n\n requestAnimationFrame(() => {\n input.node.focus()\n input.node.setSelectionRange(0, valueLength)\n })\n },\n [descendants],\n )\n\n const setValue = useCallback(\n (value: string, index: number, focus = true) => {\n let nextValues = [...values]\n\n nextValues[index] = value\n\n setValues(nextValues)\n\n nextValues = nextValues.filter(Boolean)\n\n const complete = value !== \"\" && nextValues.length === descendants.count()\n\n if (complete) {\n onComplete?.(nextValues.join(\"\"))\n descendants.value(index)?.node.blur()\n } else if (focus) {\n focusNext(index)\n }\n },\n [values, setValues, descendants, onComplete, focusNext],\n )\n\n const getNextValue = useCallback(\n (value: string | undefined, eventValue: string) => {\n let nextValue = eventValue\n\n if (!value?.length) return nextValue\n\n if (value.startsWith(eventValue.charAt(0))) {\n nextValue = eventValue.charAt(1)\n } else if (value.startsWith(eventValue.charAt(1))) {\n nextValue = eventValue.charAt(0)\n }\n\n return nextValue\n },\n [],\n )\n\n const onChange = useCallback(\n (index: number) =>\n ({ target }: ChangeEvent<HTMLInputElement>) => {\n const eventValue = target.value\n const currentValue = values[index]\n const nextValue = getNextValue(currentValue, eventValue)\n\n if (nextValue === \"\") {\n setValue(\"\", index)\n\n return\n }\n\n if (eventValue.length > 2) {\n if (!validate(eventValue, type)) return\n\n const nextValue = eventValue\n .split(\"\")\n .filter((_, index) => index < descendants.count())\n\n setValues(nextValue)\n\n if (nextValue.length === descendants.count()) {\n onComplete?.(nextValue.join(\"\"))\n descendants.value(index)?.node.blur()\n }\n } else {\n if (validate(nextValue, type)) setValue(nextValue, index)\n\n setMoveFocus(true)\n }\n },\n [descendants, getNextValue, onComplete, setValue, setValues, type, values],\n )\n\n const onKeyDown = useCallback(\n (index: number) => (ev: KeyboardEvent<HTMLInputElement>) => {\n if (!manageFocus) return\n\n runKeyAction(\n ev,\n {\n ArrowLeft: (ev) => {\n ev.preventDefault()\n focusInputField(\"prev\", index)\n },\n ArrowRight: (ev) => {\n ev.preventDefault()\n focusInputField(\"next\", index)\n },\n Backspace: (ev) => {\n if ((ev.target as HTMLInputElement).value === \"\") {\n const prevInput = descendants.prevValue(index, false)\n\n if (!prevInput) return\n\n setValue(\"\", index - 1, false)\n prevInput.node.focus()\n setMoveFocus(true)\n } else {\n setMoveFocus(false)\n }\n },\n },\n { preventDefault: false },\n )\n },\n [descendants, focusInputField, manageFocus, setValue],\n )\n\n const onFocus = useCallback(\n (index: number) => () => setFocusedIndex(index),\n [],\n )\n\n const onBlur = useCallback(() => setFocusedIndex(-1), [])\n\n useEffect(() => {\n if (!autoFocus) return\n\n const firstValue = descendants.firstValue()\n\n if (!firstValue) return\n\n requestAnimationFrame(() => firstValue.node.focus())\n }, [autoFocus, descendants])\n\n const getRootProps: PropGetter = useCallback(\n (props) => mergeProps({ role: \"group\" }, rest, props)(),\n [rest],\n )\n\n const getInputProps: RequiredPropGetter<\"input\", { index: number }> =\n useCallback(\n ({ \"aria-labelledby\": ariaLabelledby, index, ...props }) => ({\n ...ariaProps,\n ...dataProps,\n type: mask ? \"password\" : type === \"number\" ? \"tel\" : \"text\",\n \"aria-labelledby\": cx(ariaLabelledby, labelId),\n autoComplete: otp ? \"one-time-code\" : \"off\",\n disabled,\n inputMode: type === \"number\" ? \"numeric\" : \"text\",\n placeholder:\n focusedIndex === index && !readOnly && !props.readOnly\n ? \"\"\n : placeholder,\n readOnly,\n value: values[index] || \"\",\n ...filterUndefined(props),\n id: `${id}${index ? `-${index}` : \"\"}`,\n onBlur: handlerAll(eventProps.onBlur, props.onBlur, onBlur),\n onChange: handlerAll(props.onChange, onChange(index)),\n onFocus: handlerAll(eventProps.onFocus, props.onFocus, onFocus(index)),\n onKeyDown: handlerAll(props.onKeyDown, onKeyDown(index)),\n }),\n [\n ariaProps,\n dataProps,\n eventProps,\n mask,\n type,\n labelId,\n otp,\n disabled,\n focusedIndex,\n readOnly,\n placeholder,\n values,\n id,\n onBlur,\n onChange,\n onFocus,\n onKeyDown,\n ],\n )\n\n return {\n descendants,\n items,\n getInputProps,\n getRootProps,\n }\n}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gB,QAAQ;GAC9C,cAAc,MAAM,kBAAkB;GACtC;GACA,WAAW,SAAS,WAAW,YAAY;GAC3C,aACE,iBAAiB,SAAS,CAAC,YAAY,CAAC,MAAM,WAC1C,KACA;GACN;GACA,OAAO,OAAO,UAAU;GACxB,IAAA,GAAA,cAAA,iBAAmB,MAAM;GACzB,IAAI,GAAG,KAAK,QAAQ,IAAI,UAAU;GAClC,SAAA,GAAA,cAAA,YAAmB,WAAW,QAAQ,MAAM,QAAQ,OAAO;GAC3D,WAAA,GAAA,cAAA,YAAqB,MAAM,UAAU,SAAS,MAAM,CAAC;GACrD,UAAA,GAAA,cAAA,YAAoB,WAAW,SAAS,MAAM,SAAS,QAAQ,MAAM,CAAC;GACtE,YAAA,GAAA,cAAA,YAAsB,MAAM,WAAW,UAAU,MAAM,CAAC;GACzD,GACD;GACE;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACD,CAMU;EACb;EACD"}
|
|
1
|
+
{"version":3,"file":"use-pin-input.js","names":[],"sources":["../../../../src/components/pin-input/use-pin-input.ts"],"sourcesContent":["\"use client\"\n\nimport type { ChangeEvent, KeyboardEvent } from \"react\"\nimport type { HTMLProps, PropGetter, RequiredPropGetter } from \"../../core\"\nimport type { FieldProps } from \"../field\"\nimport { useCallback, useEffect, useId, useState } from \"react\"\nimport { mergeProps } from \"../../core\"\nimport { useControllableState } from \"../../hooks/use-controllable-state\"\nimport { createDescendants } from \"../../hooks/use-descendants\"\nimport { filterUndefined, runKeyAction } from \"../../utils\"\nimport { useFieldProps } from \"../field\"\n\nconst {\n DescendantsContext: PinInputDescendantsContext,\n useDescendant: usePinInputDescendant,\n useDescendants: usePinInputDescendants,\n} = createDescendants<HTMLInputElement>()\n\nexport {\n PinInputDescendantsContext,\n usePinInputDescendant,\n usePinInputDescendants,\n}\n\nconst toArray = (value?: string) => value?.split(\"\")\n\nconst validate = (value: string, type: UsePinInputProps[\"type\"]) => {\n const NUMERIC_REGEX = /^[0-9]+$/\n const ALPHA_NUMERIC_REGEX = /^[a-zA-Z0-9]+$/i\n\n const regex = type === \"alphanumeric\" ? ALPHA_NUMERIC_REGEX : NUMERIC_REGEX\n\n return regex.test(value)\n}\n\nexport interface UsePinInputProps\n extends\n Omit<HTMLProps, \"defaultValue\" | \"mask\" | \"onChange\" | \"value\">,\n FieldProps {\n /**\n * If `true`, the pin input receives focus on mount.\n *\n * @default false\n */\n autoFocus?: boolean\n /**\n * The initial value of the pin input.\n */\n defaultValue?: string\n /**\n * The top-level id string that will be applied to the input fields.\n * The index of the input will be appended to this top-level id.\n */\n id?: string\n /**\n * The number of inputs to display.\n *\n * @default 4\n */\n items?: number\n /**\n * If `true`, focus will move automatically to the next input once filled.\n *\n * @default true\n */\n manageFocus?: boolean\n /**\n * If `true`, the input's value will be masked just like `type=password`.\n */\n mask?: boolean\n /**\n * If `true`, the pin input component signals to its fields that they should.\n */\n otp?: boolean\n /**\n * The placeholder for the pin input.\n *\n * @default '◯'\n */\n placeholder?: string\n /**\n * The type of values the pin-input should allow.\n *\n * @default 'number'\n */\n type?: \"alphanumeric\" | \"number\"\n /**\n * The value of the pin input.\n */\n value?: string\n /**\n * Function called on input change.\n */\n onChange?: (value: string) => void\n /**\n * Function called when all inputs have valid values.\n */\n onComplete?: (value: string) => void\n}\n\nexport const usePinInput = (props: UsePinInputProps = {}) => {\n const uuid = useId()\n const {\n context: { labelId } = {},\n props: {\n id = uuid,\n type = \"number\",\n autoFocus,\n defaultValue,\n disabled,\n items = 4,\n manageFocus = true,\n mask,\n otp = false,\n placeholder = \"◯\",\n readOnly,\n value,\n onChange: onChangeProp,\n onComplete,\n ...rest\n },\n ariaProps,\n dataProps,\n eventProps,\n } = useFieldProps(props)\n const descendants = usePinInputDescendants()\n const [moveFocus, setMoveFocus] = useState<boolean>(true)\n const [focusedIndex, setFocusedIndex] = useState<number>(-1)\n const [values, setValues] = useControllableState<string[]>({\n defaultValue: toArray(defaultValue) || [],\n value: toArray(value),\n onChange: (values) => onChangeProp?.(values.join(\"\")),\n })\n\n const focusNext = useCallback(\n (index: number) => {\n if (!moveFocus || !manageFocus) return\n\n const next = descendants.nextValue(index, false)\n\n if (!next) return\n\n requestAnimationFrame(() => next.node.focus())\n },\n [descendants, moveFocus, manageFocus],\n )\n\n const focusInputField = useCallback(\n (direction: \"next\" | \"prev\", index: number) => {\n const input =\n direction === \"next\"\n ? descendants.nextValue(index, false)\n : descendants.prevValue(index, false)\n\n if (!input) return\n\n const valueLength = input.node.value.length\n\n requestAnimationFrame(() => {\n input.node.focus()\n input.node.setSelectionRange(0, valueLength)\n })\n },\n [descendants],\n )\n\n const setValue = useCallback(\n (value: string, index: number, focus = true) => {\n let nextValues = [...values]\n\n nextValues[index] = value\n\n setValues(nextValues)\n\n nextValues = nextValues.filter(Boolean)\n\n const complete = value !== \"\" && nextValues.length === descendants.count()\n\n if (complete) {\n onComplete?.(nextValues.join(\"\"))\n descendants.value(index)?.node.blur()\n } else if (focus) {\n focusNext(index)\n }\n },\n [values, setValues, descendants, onComplete, focusNext],\n )\n\n const getNextValue = useCallback(\n (value: string | undefined, eventValue: string) => {\n let nextValue = eventValue\n\n if (!value?.length) return nextValue\n\n if (value.startsWith(eventValue.charAt(0))) {\n nextValue = eventValue.charAt(1)\n } else if (value.startsWith(eventValue.charAt(1))) {\n nextValue = eventValue.charAt(0)\n }\n\n return nextValue\n },\n [],\n )\n\n const onChange = useCallback(\n (index: number) =>\n ({ target }: ChangeEvent<HTMLInputElement>) => {\n const eventValue = target.value\n const currentValue = values[index]\n const nextValue = getNextValue(currentValue, eventValue)\n\n if (nextValue === \"\") {\n setValue(\"\", index)\n\n return\n }\n\n if (eventValue.length > 2) {\n if (!validate(eventValue, type)) return\n\n const nextValue = eventValue\n .split(\"\")\n .filter((_, index) => index < descendants.count())\n\n setValues(nextValue)\n\n if (nextValue.length === descendants.count()) {\n onComplete?.(nextValue.join(\"\"))\n descendants.value(index)?.node.blur()\n }\n } else {\n if (validate(nextValue, type)) setValue(nextValue, index)\n\n setMoveFocus(true)\n }\n },\n [descendants, getNextValue, onComplete, setValue, setValues, type, values],\n )\n\n const onKeyDown = useCallback(\n (index: number) => (ev: KeyboardEvent<HTMLInputElement>) => {\n if (!manageFocus) return\n\n runKeyAction(\n ev,\n {\n ArrowLeft: (ev) => {\n ev.preventDefault()\n focusInputField(\"prev\", index)\n },\n ArrowRight: (ev) => {\n ev.preventDefault()\n focusInputField(\"next\", index)\n },\n Backspace: (ev) => {\n if ((ev.target as HTMLInputElement).value === \"\") {\n const prevInput = descendants.prevValue(index, false)\n\n if (!prevInput) return\n\n setValue(\"\", index - 1, false)\n prevInput.node.focus()\n setMoveFocus(true)\n } else {\n setMoveFocus(false)\n }\n },\n },\n { preventDefault: false },\n )\n },\n [descendants, focusInputField, manageFocus, setValue],\n )\n\n const onFocus = useCallback(\n (index: number) => () => setFocusedIndex(index),\n [],\n )\n\n const onBlur = useCallback(() => setFocusedIndex(-1), [])\n\n useEffect(() => {\n if (!autoFocus) return\n\n const firstValue = descendants.firstValue()\n\n if (!firstValue) return\n\n requestAnimationFrame(() => firstValue.node.focus())\n }, [autoFocus, descendants])\n\n const getRootProps: PropGetter = useCallback(\n (props) => mergeProps({ role: \"group\" }, rest, props)(),\n [rest],\n )\n\n const getInputProps: RequiredPropGetter<\"input\", { index: number }> =\n useCallback(\n ({ index, ...props }) =>\n mergeProps(\n {\n ...ariaProps,\n ...dataProps,\n ...eventProps,\n type: mask ? \"password\" : type === \"number\" ? \"tel\" : \"text\",\n \"aria-labelledby\": labelId,\n autoComplete: otp ? \"one-time-code\" : \"off\",\n disabled,\n inputMode: type === \"number\" ? \"numeric\" : \"text\",\n placeholder:\n focusedIndex === index && !readOnly && !props.readOnly\n ? \"\"\n : placeholder,\n readOnly,\n value: values[index] || \"\",\n },\n filterUndefined(props),\n {\n id: `${id}${index ? `-${index}` : \"\"}`,\n onBlur,\n onChange: onChange(index),\n onFocus: onFocus(index),\n onKeyDown: onKeyDown(index),\n },\n )(),\n [\n ariaProps,\n dataProps,\n eventProps,\n mask,\n type,\n labelId,\n otp,\n disabled,\n focusedIndex,\n readOnly,\n placeholder,\n values,\n id,\n onBlur,\n onChange,\n onFocus,\n onKeyDown,\n ],\n )\n\n return {\n descendants,\n items,\n getInputProps,\n getRootProps,\n }\n}\n\nexport type UsePinInputReturn = ReturnType<typeof usePinInput>\n"],"mappings":";;;;;;;;;AAYA,MAAM,EACJ,oBAAoB,4BACpB,eAAe,uBACf,gBAAgB,2BACd,mBAAqC;AAQzC,MAAM,WAAW,UAAmB,OAAO,MAAM,GAAG;AAEpD,MAAM,YAAY,OAAe,SAAmC;CAMlE,QAFc,SAAS,iBAAiB,oBAAsB,YAEjD,KAAK,MAAM;;AAoE1B,MAAa,eAAe,QAA0B,EAAE,KAAK;CAC3D,MAAM,OAAO,OAAO;CACpB,MAAM,EACJ,SAAS,EAAE,YAAY,EAAE,EACzB,OAAO,EACL,KAAK,MACL,OAAO,UACP,WACA,cACA,UACA,QAAQ,GACR,cAAc,MACd,MACA,MAAM,OACN,cAAc,KACd,UACA,OACA,UAAU,cACV,YACA,GAAG,QAEL,WACA,WACA,eACE,cAAc,MAAM;CACxB,MAAM,cAAc,wBAAwB;CAC5C,MAAM,CAAC,WAAW,gBAAgB,SAAkB,KAAK;CACzD,MAAM,CAAC,cAAc,mBAAmB,SAAiB,GAAG;CAC5D,MAAM,CAAC,QAAQ,aAAa,qBAA+B;EACzD,cAAc,QAAQ,aAAa,IAAI,EAAE;EACzC,OAAO,QAAQ,MAAM;EACrB,WAAW,WAAW,eAAe,OAAO,KAAK,GAAG,CAAC;EACtD,CAAC;CAEF,MAAM,YAAY,aACf,UAAkB;EACjB,IAAI,CAAC,aAAa,CAAC,aAAa;EAEhC,MAAM,OAAO,YAAY,UAAU,OAAO,MAAM;EAEhD,IAAI,CAAC,MAAM;EAEX,4BAA4B,KAAK,KAAK,OAAO,CAAC;IAEhD;EAAC;EAAa;EAAW;E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,EAAE,EACvD,CAAC,KAAK,CACP;CAoDD,OAAO;EACL;EACA;EACA,eApDA,aACG,EAAE,OAAO,GAAG,YACX,WACE;GACE,GAAG;GACH,GAAG;GACH,GAAG;GACH,MAAM,OAAO,aAAa,SAAS,WAAW,QAAQ;GACtD,mBAAmB;GACnB,cAAc,MAAM,kBAAkB;GACtC;GACA,WAAW,SAAS,WAAW,YAAY;GAC3C,aACE,iBAAiB,SAAS,CAAC,YAAY,CAAC,MAAM,WAC1C,KACA;GACN;GACA,OAAO,OAAO,UAAU;GACzB,GAAA,GAAA,cAAA,iBACe,MAAM,EACtB;GACE,IAAI,GAAG,KAAK,QAAQ,IAAI,UAAU;GAClC;GACA,UAAU,SAAS,MAAM;GACzB,SAAS,QAAQ,MAAM;GACvB,WAAW,UAAU,MAAM;GAC5B,CACF,EAAE,EACL;GACE;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACD,CAMU;EACb;EACD"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ComponentSlotStyle } from "../../core/system/index.types.js";
|
|
2
2
|
import { CSSModifierObject, CSSPropObject, CSSSlotObject } from "../../core/css/index.types.js";
|
|
3
3
|
//#region src/components/accordion/accordion.style.d.ts
|
|
4
|
-
declare const accordionStyle: ComponentSlotStyle<"button" | "
|
|
4
|
+
declare const accordionStyle: ComponentSlotStyle<"button" | "panel" | "icon" | "item" | "root", CSSPropObject<CSSSlotObject<"button" | "panel" | "icon" | "item" | "root">>, CSSModifierObject<CSSSlotObject<"button" | "panel" | "icon" | "item" | "root">>, {
|
|
5
5
|
panel: {
|
|
6
6
|
button: {
|
|
7
7
|
rounded: "l2";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ComponentSlotStyle } from "../../core/system/index.types.js";
|
|
2
2
|
import { CSSModifierObject, CSSPropObject, CSSSlotObject } from "../../core/css/index.types.js";
|
|
3
3
|
//#region src/components/alert/alert.style.d.ts
|
|
4
|
-
declare const alertStyle: ComponentSlotStyle<"
|
|
4
|
+
declare const alertStyle: ComponentSlotStyle<"title" | "loading" | "icon" | "root" | "description", CSSPropObject<CSSSlotObject<"title" | "loading" | "icon" | "root" | "description">>, CSSModifierObject<CSSSlotObject<"title" | "loading" | "icon" | "root" | "description">>, {
|
|
5
5
|
island: {
|
|
6
6
|
description: {
|
|
7
7
|
color: "fg.muted";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ComponentSlotStyle } from "../../core/system/index.types.js";
|
|
2
2
|
import { CSSPropObject, CSSSlotObject } from "../../core/css/index.types.js";
|
|
3
3
|
//#region src/components/autocomplete/autocomplete.style.d.ts
|
|
4
|
-
declare const autocompleteStyle: ComponentSlotStyle<"input" | "label" | "option" | "content" | "
|
|
4
|
+
declare const autocompleteStyle: ComponentSlotStyle<"input" | "label" | "option" | "content" | "group" | "separator" | "icon" | "root" | "indicator" | "field" | "valueText" | "empty", CSSPropObject<CSSSlotObject<"input" | "label" | "option" | "content" | "group" | "separator" | "icon" | "root" | "indicator" | "field" | "valueText" | "empty">>, {
|
|
5
5
|
xs: {
|
|
6
6
|
empty: {
|
|
7
7
|
gap: "1.5";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ComponentSlotStyle } from "../../core/system/index.types.js";
|
|
2
2
|
import { CSSPropObject, CSSSlotObject } from "../../core/css/index.types.js";
|
|
3
3
|
//#region src/components/breadcrumb/breadcrumb.style.d.ts
|
|
4
|
-
declare const breadcrumbStyle: ComponentSlotStyle<"link" | "
|
|
4
|
+
declare const breadcrumbStyle: ComponentSlotStyle<"link" | "list" | "separator" | "ellipsis" | "item" | "root", CSSPropObject<CSSSlotObject<"link" | "list" | "separator" | "ellipsis" | "item" | "root">>, {
|
|
5
5
|
sm: {
|
|
6
6
|
list: {
|
|
7
7
|
fontSize: "sm";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ComponentSlotStyle } from "../../core/system/index.types.js";
|
|
2
2
|
import { CSSModifierObject, CSSSlotObject } from "../../core/css/index.types.js";
|
|
3
3
|
//#region src/components/calendar/calendar.style.d.ts
|
|
4
|
-
declare const calendarStyle: ComponentSlotStyle<"button" | "select" | "cell" | "
|
|
4
|
+
declare const calendarStyle: ComponentSlotStyle<"button" | "select" | "cell" | "navigation" | "row" | "separator" | "next" | "root" | "month" | "week" | "weekday" | "day" | "control" | "months" | "years" | "weeks" | "prev", {
|
|
5
5
|
/**
|
|
6
6
|
* If `true`, the calendar will be fixed rows.
|
|
7
7
|
*
|
|
@@ -73,7 +73,7 @@ declare const calendarStyle: ComponentSlotStyle<"button" | "select" | "cell" | "
|
|
|
73
73
|
"--font-size": "fontSizes.xl";
|
|
74
74
|
};
|
|
75
75
|
};
|
|
76
|
-
}, CSSModifierObject<CSSSlotObject<"button" | "select" | "cell" | "
|
|
76
|
+
}, CSSModifierObject<CSSSlotObject<"button" | "select" | "cell" | "navigation" | "row" | "separator" | "next" | "root" | "month" | "week" | "weekday" | "day" | "control" | "months" | "years" | "weeks" | "prev">>>;
|
|
77
77
|
type CalendarStyle = typeof calendarStyle;
|
|
78
78
|
//#endregion
|
|
79
79
|
export { CalendarStyle, calendarStyle };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ComponentSlotStyle } from "../../core/system/index.types.js";
|
|
2
2
|
import { CSSModifierObject, CSSPropObject, CSSSlotObject } from "../../core/css/index.types.js";
|
|
3
3
|
//#region src/components/carousel/carousel.style.d.ts
|
|
4
|
-
declare const carouselStyle: ComponentSlotStyle<"
|
|
4
|
+
declare const carouselStyle: ComponentSlotStyle<"list" | "next" | "item" | "root" | "trigger" | "indicator" | "indicators" | "prev", CSSPropObject<CSSSlotObject<"list" | "next" | "item" | "root" | "trigger" | "indicator" | "indicators" | "prev">>, {
|
|
5
5
|
sm: {
|
|
6
6
|
root: {
|
|
7
7
|
h: "sm";
|
|
@@ -17,7 +17,7 @@ declare const carouselStyle: ComponentSlotStyle<"next" | "list" | "item" | "root
|
|
|
17
17
|
h: "lg";
|
|
18
18
|
};
|
|
19
19
|
};
|
|
20
|
-
}, CSSModifierObject<CSSSlotObject<"
|
|
20
|
+
}, CSSModifierObject<CSSSlotObject<"list" | "next" | "item" | "root" | "trigger" | "indicator" | "indicators" | "prev">>>;
|
|
21
21
|
type CarouselStyle = typeof carouselStyle;
|
|
22
22
|
//#endregion
|
|
23
23
|
export { CarouselStyle, carouselStyle };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ComponentSlotStyle } from "../../core/system/index.types.js";
|
|
2
2
|
import { CSSPropObject, CSSSlotObject } from "../../core/css/index.types.js";
|
|
3
3
|
//#region src/components/color-picker/color-picker.style.d.ts
|
|
4
|
-
declare const colorPickerStyle: ComponentSlotStyle<"input" | "content" | "icon" | "root" | "
|
|
4
|
+
declare const colorPickerStyle: ComponentSlotStyle<"input" | "content" | "icon" | "root" | "field" | "colorSwatch" | "eyeDropper", CSSPropObject<CSSSlotObject<"input" | "content" | "icon" | "root" | "field" | "colorSwatch" | "eyeDropper">>, {
|
|
5
5
|
xs: {
|
|
6
6
|
field: {
|
|
7
7
|
fontSize: "1em";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ComponentSlotStyle } from "../../core/system/index.types.js";
|
|
2
2
|
import { CSSPropObject, CSSSlotObject } from "../../core/css/index.types.js";
|
|
3
3
|
//#region src/components/date-picker/date-picker.style.d.ts
|
|
4
|
-
declare const datePickerStyle: ComponentSlotStyle<"input" | "content" | "
|
|
4
|
+
declare const datePickerStyle: ComponentSlotStyle<"input" | "content" | "separator" | "icon" | "root" | "field" | "adjust", CSSPropObject<CSSSlotObject<"input" | "content" | "separator" | "icon" | "root" | "field" | "adjust">>, {
|
|
5
5
|
xs: {
|
|
6
6
|
field: {
|
|
7
7
|
fontSize: "1em";
|
|
@@ -41,7 +41,7 @@ declare const DropzoneRoot: Component<({
|
|
|
41
41
|
loadingProps,
|
|
42
42
|
overlayProps,
|
|
43
43
|
...rest
|
|
44
|
-
}: WithoutThemeProps<DropzoneRootProps, ComponentSlotStyle<"
|
|
44
|
+
}: WithoutThemeProps<DropzoneRootProps, ComponentSlotStyle<"title" | "overlay" | "loading" | "icon" | "root" | "description", CSSPropObject<CSSSlotObject<"title" | "overlay" | "loading" | "icon" | "root" | "description">>, {
|
|
45
45
|
xs: {
|
|
46
46
|
root: {
|
|
47
47
|
minH: "xs";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ComponentSlotStyle } from "../../core/system/index.types.js";
|
|
2
2
|
import { CSSPropObject, CSSSlotObject } from "../../core/css/index.types.js";
|
|
3
3
|
//#region src/components/dropzone/dropzone.style.d.ts
|
|
4
|
-
declare const dropzoneStyle: ComponentSlotStyle<"
|
|
4
|
+
declare const dropzoneStyle: ComponentSlotStyle<"title" | "overlay" | "loading" | "icon" | "root" | "description", CSSPropObject<CSSSlotObject<"title" | "overlay" | "loading" | "icon" | "root" | "description">>, {
|
|
5
5
|
xs: {
|
|
6
6
|
root: {
|
|
7
7
|
minH: "xs";
|
|
@@ -31,7 +31,7 @@ declare const useFieldProps: <Y extends HTMLElement, M extends Dict>({
|
|
|
31
31
|
disabled: boolean | undefined;
|
|
32
32
|
readOnly: boolean | undefined;
|
|
33
33
|
required: boolean | undefined;
|
|
34
|
-
} & Omit<M & UseFieldProps<Y>, "
|
|
34
|
+
} & Omit<M & UseFieldProps<Y>, "disabled" | "readOnly" | "id" | "aria-describedby" | "onFocus" | "onBlur" | "invalid" | "name" | "required" | "notSupportReadOnly">;
|
|
35
35
|
ariaProps: {
|
|
36
36
|
"aria-describedby": any;
|
|
37
37
|
"aria-disabled": (boolean | "true" | "false") | undefined;
|
|
@@ -8,7 +8,7 @@ import * as _$_yamada_ui_utils0 from "@yamada-ui/utils";
|
|
|
8
8
|
//#region src/components/file-button/use-file-button.d.ts
|
|
9
9
|
interface UseFileButtonProps extends UseFileInputProps<"button">, FieldProps {}
|
|
10
10
|
declare const useFileButton: (props?: UseFileButtonProps) => {
|
|
11
|
-
clickableProps: (Omit<UseClickableProps<HTMLElement, _$_yamada_ui_utils0.Dict<any>>, "disabled" | "ref" | "tabIndex" | "onKeyDown" | "onKeyUp" | "onClick" | "onMouseDown" | "onMouseLeave" | "onMouseOver" | "onMouseUp" | "
|
|
11
|
+
clickableProps: (Omit<UseClickableProps<HTMLElement, _$_yamada_ui_utils0.Dict<any>>, "disabled" | "ref" | "tabIndex" | "onKeyDown" | "onKeyUp" | "onClick" | "onMouseDown" | "onMouseLeave" | "onMouseOver" | "onMouseUp" | "clickOnEnter" | "clickOnSpace" | "disableTouchBehavior" | "focusable" | "focusOnClick"> & {
|
|
12
12
|
ref: (node: any) => void;
|
|
13
13
|
type: "button";
|
|
14
14
|
"aria-disabled": boolean | undefined;
|
|
@@ -20,7 +20,7 @@ declare const useFileButton: (props?: UseFileButtonProps) => {
|
|
|
20
20
|
onMouseLeave: _$react.MouseEventHandler<HTMLElement> | undefined;
|
|
21
21
|
onMouseOver: _$react.MouseEventHandler<HTMLElement> | undefined;
|
|
22
22
|
onMouseUp: _$react.MouseEventHandler<HTMLElement> | undefined;
|
|
23
|
-
}) | (Omit<UseClickableProps<HTMLElement, _$_yamada_ui_utils0.Dict<any>>, "disabled" | "ref" | "tabIndex" | "onKeyDown" | "onKeyUp" | "onClick" | "onMouseDown" | "onMouseLeave" | "onMouseOver" | "onMouseUp" | "
|
|
23
|
+
}) | (Omit<UseClickableProps<HTMLElement, _$_yamada_ui_utils0.Dict<any>>, "disabled" | "ref" | "tabIndex" | "onKeyDown" | "onKeyUp" | "onClick" | "onMouseDown" | "onMouseLeave" | "onMouseOver" | "onMouseUp" | "clickOnEnter" | "clickOnSpace" | "disableTouchBehavior" | "focusable" | "focusOnClick"> & {
|
|
24
24
|
ref: (node: any) => void;
|
|
25
25
|
"aria-disabled": "true" | undefined;
|
|
26
26
|
"data-active": string | undefined;
|
|
@@ -30,7 +30,7 @@ declare const useFileInput: <Y extends "button" | "input" = "input">(props: UseF
|
|
|
30
30
|
readOnly: boolean | undefined;
|
|
31
31
|
required: boolean | undefined;
|
|
32
32
|
values: File[] | undefined;
|
|
33
|
-
clickableProps: (Omit<UseClickableProps<HTMLElement, Dict<any>>, "disabled" | "ref" | "tabIndex" | "onKeyDown" | "onKeyUp" | "onClick" | "onMouseDown" | "onMouseLeave" | "onMouseOver" | "onMouseUp" | "
|
|
33
|
+
clickableProps: (Omit<UseClickableProps<HTMLElement, Dict<any>>, "disabled" | "ref" | "tabIndex" | "onKeyDown" | "onKeyUp" | "onClick" | "onMouseDown" | "onMouseLeave" | "onMouseOver" | "onMouseUp" | "clickOnEnter" | "clickOnSpace" | "disableTouchBehavior" | "focusable" | "focusOnClick"> & {
|
|
34
34
|
ref: (node: any) => void;
|
|
35
35
|
type: "button";
|
|
36
36
|
"aria-disabled": boolean | undefined;
|
|
@@ -42,7 +42,7 @@ declare const useFileInput: <Y extends "button" | "input" = "input">(props: UseF
|
|
|
42
42
|
onMouseLeave: _$react.MouseEventHandler<HTMLElement> | undefined;
|
|
43
43
|
onMouseOver: _$react.MouseEventHandler<HTMLElement> | undefined;
|
|
44
44
|
onMouseUp: _$react.MouseEventHandler<HTMLElement> | undefined;
|
|
45
|
-
}) | (Omit<UseClickableProps<HTMLElement, Dict<any>>, "disabled" | "ref" | "tabIndex" | "onKeyDown" | "onKeyUp" | "onClick" | "onMouseDown" | "onMouseLeave" | "onMouseOver" | "onMouseUp" | "
|
|
45
|
+
}) | (Omit<UseClickableProps<HTMLElement, Dict<any>>, "disabled" | "ref" | "tabIndex" | "onKeyDown" | "onKeyUp" | "onClick" | "onMouseDown" | "onMouseLeave" | "onMouseOver" | "onMouseUp" | "clickOnEnter" | "clickOnSpace" | "disableTouchBehavior" | "focusable" | "focusOnClick"> & {
|
|
46
46
|
ref: (node: any) => void;
|
|
47
47
|
"aria-disabled": "true" | undefined;
|
|
48
48
|
"data-active": string | undefined;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ComponentSlotStyle } from "../../core/system/index.types.js";
|
|
2
2
|
import { CSSModifierObject, CSSPropObject, CSSSlotObject } from "../../core/css/index.types.js";
|
|
3
3
|
//#region src/components/menu/menu.style.d.ts
|
|
4
|
-
declare const menuStyle: ComponentSlotStyle<"footer" | "header" | "label" | "content" | "command" | "
|
|
4
|
+
declare const menuStyle: ComponentSlotStyle<"footer" | "header" | "label" | "content" | "command" | "group" | "separator" | "item" | "indicator", CSSPropObject<CSSSlotObject<"footer" | "header" | "label" | "content" | "command" | "group" | "separator" | "item" | "indicator">>, {
|
|
5
5
|
sm: {
|
|
6
6
|
command: {
|
|
7
7
|
fontSize: "2xs";
|
|
@@ -86,7 +86,7 @@ declare const menuStyle: ComponentSlotStyle<"footer" | "header" | "label" | "con
|
|
|
86
86
|
px: "2";
|
|
87
87
|
};
|
|
88
88
|
};
|
|
89
|
-
}, CSSModifierObject<CSSSlotObject<"footer" | "header" | "label" | "content" | "command" | "
|
|
89
|
+
}, CSSModifierObject<CSSSlotObject<"footer" | "header" | "label" | "content" | "command" | "group" | "separator" | "item" | "indicator">>>;
|
|
90
90
|
type MenuStyle = typeof menuStyle;
|
|
91
91
|
//#endregion
|
|
92
92
|
export { MenuStyle, menuStyle };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ComponentSlotStyle } from "../../core/system/index.types.js";
|
|
2
2
|
import { CSSModifierObject, CSSSlotObject } from "../../core/css/index.types.js";
|
|
3
3
|
//#region src/components/native-accordion/native-accordion.style.d.ts
|
|
4
|
-
declare const nativeAccordionStyle: ComponentSlotStyle<"button" | "
|
|
4
|
+
declare const nativeAccordionStyle: ComponentSlotStyle<"button" | "panel" | "icon" | "item" | "root", {
|
|
5
5
|
/**
|
|
6
6
|
* If `true`, animate the accordion items when they are expanded or collapsed.
|
|
7
7
|
*
|
|
@@ -31,7 +31,7 @@ declare const nativeAccordionStyle: ComponentSlotStyle<"button" | "icon" | "pane
|
|
|
31
31
|
};
|
|
32
32
|
};
|
|
33
33
|
};
|
|
34
|
-
}, CSSModifierObject<CSSSlotObject<"button" | "
|
|
34
|
+
}, CSSModifierObject<CSSSlotObject<"button" | "panel" | "icon" | "item" | "root">>, {
|
|
35
35
|
panel: {
|
|
36
36
|
button: {
|
|
37
37
|
rounded: "l2";
|
|
@@ -29,13 +29,12 @@ declare const useProgress: <Y extends "div" | "svg" = "div">({
|
|
|
29
29
|
}?: UseProgressProps) => {
|
|
30
30
|
percent: number;
|
|
31
31
|
getRangeProps: (props?: HTMLProps<Y extends "svg" ? "circle" : "div">) => {
|
|
32
|
-
id?: _$react.JSX.IntrinsicElements[Y extends "svg" ? "circle" : "div"]["id"] | undefined;
|
|
33
|
-
key?: _$react.JSX.IntrinsicElements[Y extends "svg" ? "circle" : "div"]["key"] | undefined;
|
|
34
32
|
slot?: _$react.JSX.IntrinsicElements[Y extends "svg" ? "circle" : "div"]["slot"] | undefined;
|
|
35
33
|
style?: _$react.JSX.IntrinsicElements[Y extends "svg" ? "circle" : "div"]["style"] | undefined;
|
|
36
34
|
ref?: _$react.JSX.IntrinsicElements[Y extends "svg" ? "circle" : "div"]["ref"] | undefined;
|
|
37
35
|
suppressHydrationWarning?: _$react.JSX.IntrinsicElements[Y extends "svg" ? "circle" : "div"]["suppressHydrationWarning"] | undefined;
|
|
38
36
|
className?: _$react.JSX.IntrinsicElements[Y extends "svg" ? "circle" : "div"]["className"] | undefined;
|
|
37
|
+
id?: _$react.JSX.IntrinsicElements[Y extends "svg" ? "circle" : "div"]["id"] | undefined;
|
|
39
38
|
lang?: _$react.JSX.IntrinsicElements[Y extends "svg" ? "circle" : "div"]["lang"] | undefined;
|
|
40
39
|
nonce?: _$react.JSX.IntrinsicElements[Y extends "svg" ? "circle" : "div"]["nonce"] | undefined;
|
|
41
40
|
tabIndex?: _$react.JSX.IntrinsicElements[Y extends "svg" ? "circle" : "div"]["tabIndex"] | undefined;
|
|
@@ -264,16 +263,16 @@ declare const useProgress: <Y extends "div" | "svg" = "div">({
|
|
|
264
263
|
onTransitionRunCapture?: _$react.JSX.IntrinsicElements[Y extends "svg" ? "circle" : "div"]["onTransitionRunCapture"] | undefined;
|
|
265
264
|
onTransitionStart?: _$react.JSX.IntrinsicElements[Y extends "svg" ? "circle" : "div"]["onTransitionStart"] | undefined;
|
|
266
265
|
onTransitionStartCapture?: _$react.JSX.IntrinsicElements[Y extends "svg" ? "circle" : "div"]["onTransitionStartCapture"] | undefined;
|
|
266
|
+
key?: _$react.JSX.IntrinsicElements[Y extends "svg" ? "circle" : "div"]["key"] | undefined;
|
|
267
267
|
"data-indeterminate": string | undefined;
|
|
268
268
|
};
|
|
269
269
|
getRootProps: (props?: HTMLProps<Y>) => {
|
|
270
|
-
id?: _$react.JSX.IntrinsicElements[Y]["id"] | undefined;
|
|
271
|
-
key?: _$react.JSX.IntrinsicElements[Y]["key"] | undefined;
|
|
272
270
|
slot?: _$react.JSX.IntrinsicElements[Y]["slot"] | undefined;
|
|
273
271
|
style?: _$react.JSX.IntrinsicElements[Y]["style"] | undefined;
|
|
274
272
|
ref?: _$react.JSX.IntrinsicElements[Y]["ref"] | undefined;
|
|
275
273
|
suppressHydrationWarning?: _$react.JSX.IntrinsicElements[Y]["suppressHydrationWarning"] | undefined;
|
|
276
274
|
className?: _$react.JSX.IntrinsicElements[Y]["className"] | undefined;
|
|
275
|
+
id?: _$react.JSX.IntrinsicElements[Y]["id"] | undefined;
|
|
277
276
|
lang?: _$react.JSX.IntrinsicElements[Y]["lang"] | undefined;
|
|
278
277
|
nonce?: _$react.JSX.IntrinsicElements[Y]["nonce"] | undefined;
|
|
279
278
|
tabIndex?: _$react.JSX.IntrinsicElements[Y]["tabIndex"] | undefined;
|
|
@@ -502,16 +501,16 @@ declare const useProgress: <Y extends "div" | "svg" = "div">({
|
|
|
502
501
|
onTransitionRunCapture?: _$react.JSX.IntrinsicElements[Y]["onTransitionRunCapture"] | undefined;
|
|
503
502
|
onTransitionStart?: _$react.JSX.IntrinsicElements[Y]["onTransitionStart"] | undefined;
|
|
504
503
|
onTransitionStartCapture?: _$react.JSX.IntrinsicElements[Y]["onTransitionStartCapture"] | undefined;
|
|
504
|
+
key?: _$react.JSX.IntrinsicElements[Y]["key"] | undefined;
|
|
505
505
|
"data-indeterminate": string | undefined;
|
|
506
506
|
};
|
|
507
507
|
getTrackProps: (props?: HTMLProps<Y extends "svg" ? "circle" : "div">) => {
|
|
508
|
-
id?: _$react.JSX.IntrinsicElements[Y extends "svg" ? "circle" : "div"]["id"] | undefined;
|
|
509
|
-
key?: _$react.JSX.IntrinsicElements[Y extends "svg" ? "circle" : "div"]["key"] | undefined;
|
|
510
508
|
slot?: _$react.JSX.IntrinsicElements[Y extends "svg" ? "circle" : "div"]["slot"] | undefined;
|
|
511
509
|
style?: _$react.JSX.IntrinsicElements[Y extends "svg" ? "circle" : "div"]["style"] | undefined;
|
|
512
510
|
ref?: _$react.JSX.IntrinsicElements[Y extends "svg" ? "circle" : "div"]["ref"] | undefined;
|
|
513
511
|
suppressHydrationWarning?: _$react.JSX.IntrinsicElements[Y extends "svg" ? "circle" : "div"]["suppressHydrationWarning"] | undefined;
|
|
514
512
|
className?: _$react.JSX.IntrinsicElements[Y extends "svg" ? "circle" : "div"]["className"] | undefined;
|
|
513
|
+
id?: _$react.JSX.IntrinsicElements[Y extends "svg" ? "circle" : "div"]["id"] | undefined;
|
|
515
514
|
lang?: _$react.JSX.IntrinsicElements[Y extends "svg" ? "circle" : "div"]["lang"] | undefined;
|
|
516
515
|
nonce?: _$react.JSX.IntrinsicElements[Y extends "svg" ? "circle" : "div"]["nonce"] | undefined;
|
|
517
516
|
tabIndex?: _$react.JSX.IntrinsicElements[Y extends "svg" ? "circle" : "div"]["tabIndex"] | undefined;
|
|
@@ -740,6 +739,7 @@ declare const useProgress: <Y extends "div" | "svg" = "div">({
|
|
|
740
739
|
onTransitionRunCapture?: _$react.JSX.IntrinsicElements[Y extends "svg" ? "circle" : "div"]["onTransitionRunCapture"] | undefined;
|
|
741
740
|
onTransitionStart?: _$react.JSX.IntrinsicElements[Y extends "svg" ? "circle" : "div"]["onTransitionStart"] | undefined;
|
|
742
741
|
onTransitionStartCapture?: _$react.JSX.IntrinsicElements[Y extends "svg" ? "circle" : "div"]["onTransitionStartCapture"] | undefined;
|
|
742
|
+
key?: _$react.JSX.IntrinsicElements[Y extends "svg" ? "circle" : "div"]["key"] | undefined;
|
|
743
743
|
"data-indeterminate": string | undefined;
|
|
744
744
|
};
|
|
745
745
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ComponentSlotStyle } from "../../core/system/index.types.js";
|
|
2
2
|
import { CSSModifierObject, CSSPropObject, CSSSlotObject } from "../../core/css/index.types.js";
|
|
3
3
|
//#region src/components/rating/rating.style.d.ts
|
|
4
|
-
declare const ratingStyle: ComponentSlotStyle<"
|
|
4
|
+
declare const ratingStyle: ComponentSlotStyle<"group" | "icon" | "item" | "root", CSSPropObject<CSSSlotObject<"group" | "icon" | "item" | "root">>, {
|
|
5
5
|
xs: {
|
|
6
6
|
icon: {
|
|
7
7
|
fontSize: "md";
|
|
@@ -27,7 +27,7 @@ declare const ratingStyle: ComponentSlotStyle<"icon" | "group" | "item" | "root"
|
|
|
27
27
|
fontSize: "3xl";
|
|
28
28
|
};
|
|
29
29
|
};
|
|
30
|
-
}, CSSModifierObject<CSSSlotObject<"
|
|
30
|
+
}, CSSModifierObject<CSSSlotObject<"group" | "icon" | "item" | "root">>>;
|
|
31
31
|
type RatingStyle = typeof ratingStyle;
|
|
32
32
|
//#endregion
|
|
33
33
|
export { RatingStyle, ratingStyle };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ComponentSlotStyle } from "../../core/system/index.types.js";
|
|
2
2
|
//#region src/components/select/select.style.d.ts
|
|
3
|
-
declare const selectStyle: ComponentSlotStyle<"label" | "option" | "content" | "
|
|
3
|
+
declare const selectStyle: ComponentSlotStyle<"label" | "option" | "content" | "group" | "separator" | "icon" | "root" | "indicator" | "field" | "valueText", {
|
|
4
4
|
/**
|
|
5
5
|
* If `true`, wrap the value text.
|
|
6
6
|
*
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ComponentSlotStyle } from "../../core/system/index.types.js";
|
|
2
2
|
import { CSSModifierObject, CSSSlotObject } from "../../core/css/index.types.js";
|
|
3
3
|
//#region src/components/stat/stat.style.d.ts
|
|
4
|
-
declare const statStyle: ComponentSlotStyle<"
|
|
4
|
+
declare const statStyle: ComponentSlotStyle<"label" | "value" | "icon" | "root" | "helperMessage" | "unit", {
|
|
5
5
|
/**
|
|
6
6
|
* If `true`, container will center its children regardless of their width.
|
|
7
7
|
*
|
|
@@ -92,7 +92,7 @@ declare const statStyle: ComponentSlotStyle<"value" | "label" | "icon" | "root"
|
|
|
92
92
|
gap: "2";
|
|
93
93
|
};
|
|
94
94
|
};
|
|
95
|
-
}, CSSModifierObject<CSSSlotObject<"
|
|
95
|
+
}, CSSModifierObject<CSSSlotObject<"label" | "value" | "icon" | "root" | "helperMessage" | "unit">>>;
|
|
96
96
|
type StatStyle = typeof statStyle;
|
|
97
97
|
//#endregion
|
|
98
98
|
export { StatStyle, statStyle };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ComponentSlotStyle } from "../../core/system/index.types.js";
|
|
2
2
|
//#region src/components/steps/steps.style.d.ts
|
|
3
|
-
declare const stepsStyle: ComponentSlotStyle<"title" | "
|
|
3
|
+
declare const stepsStyle: ComponentSlotStyle<"title" | "list" | "separator" | "item" | "root" | "indicator" | "description", {
|
|
4
4
|
/**
|
|
5
5
|
* The orientation of the steps.
|
|
6
6
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ComponentSlotStyle } from "../../core/system/index.types.js";
|
|
2
2
|
//#region src/components/tabs/tabs.style.d.ts
|
|
3
|
-
declare const tabsStyle: ComponentSlotStyle<"
|
|
3
|
+
declare const tabsStyle: ComponentSlotStyle<"panel" | "list" | "tab" | "root", {
|
|
4
4
|
/**
|
|
5
5
|
* The alignment of the tabs.
|
|
6
6
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ComponentSlotStyle } from "../../core/system/index.types.js";
|
|
2
2
|
//#region src/components/tree/tree.style.d.ts
|
|
3
|
-
declare const treeStyle: ComponentSlotStyle<"label" | "
|
|
3
|
+
declare const treeStyle: ComponentSlotStyle<"label" | "checkbox" | "group" | "end" | "start" | "element" | "item" | "root" | "indicator", {
|
|
4
4
|
/**
|
|
5
5
|
* The shape of the component
|
|
6
6
|
*
|
|
@@ -239,12 +239,11 @@ declare const useTreeItem: ({
|
|
|
239
239
|
level: number;
|
|
240
240
|
props: {
|
|
241
241
|
[key: `data-${string}`]: string | undefined;
|
|
242
|
-
id?: string | undefined | undefined;
|
|
243
|
-
key?: _$react.Key | null | undefined;
|
|
244
242
|
slot?: string | undefined | undefined;
|
|
245
243
|
style?: _$react.CSSProperties | undefined;
|
|
246
244
|
title?: string | undefined | undefined;
|
|
247
245
|
translate?: "yes" | "no" | undefined | undefined;
|
|
246
|
+
hidden?: boolean | undefined | undefined;
|
|
248
247
|
ref?: _$react.Ref<HTMLDivElement> | undefined;
|
|
249
248
|
defaultChecked?: boolean | undefined | undefined;
|
|
250
249
|
defaultValue?: string | number | readonly string[] | undefined;
|
|
@@ -254,12 +253,12 @@ declare const useTreeItem: ({
|
|
|
254
253
|
autoCapitalize?: "off" | "none" | "on" | "sentences" | "words" | "characters" | undefined | (string & {}) | undefined;
|
|
255
254
|
autoFocus?: boolean | undefined | undefined;
|
|
256
255
|
className?: string | undefined | undefined;
|
|
257
|
-
contentEditable?: (boolean | "true" | "false") | "
|
|
256
|
+
contentEditable?: "inherit" | (boolean | "true" | "false") | "plaintext-only" | undefined;
|
|
258
257
|
contextMenu?: string | undefined | undefined;
|
|
259
258
|
dir?: string | undefined | undefined;
|
|
260
259
|
draggable?: (boolean | "true" | "false") | undefined;
|
|
261
260
|
enterKeyHint?: "enter" | "done" | "go" | "next" | "previous" | "search" | "send" | undefined | undefined;
|
|
262
|
-
|
|
261
|
+
id?: string | undefined | undefined;
|
|
263
262
|
lang?: string | undefined | undefined;
|
|
264
263
|
nonce?: string | undefined | undefined;
|
|
265
264
|
spellCheck?: (boolean | "true" | "false") | undefined;
|
|
@@ -518,6 +517,7 @@ declare const useTreeItem: ({
|
|
|
518
517
|
onTransitionRunCapture?: _$react.TransitionEventHandler<HTMLDivElement> | undefined;
|
|
519
518
|
onTransitionStart?: _$react.TransitionEventHandler<HTMLDivElement> | undefined;
|
|
520
519
|
onTransitionStartCapture?: _$react.TransitionEventHandler<HTMLDivElement> | undefined;
|
|
520
|
+
key?: _$react.Key | null | undefined;
|
|
521
521
|
};
|
|
522
522
|
selected: boolean;
|
|
523
523
|
value: string;
|
|
@@ -64,7 +64,7 @@ declare const useClickable: <Y extends HTMLElement = HTMLElement, M extends Prop
|
|
|
64
64
|
onMouseOver: onMouseOverProp,
|
|
65
65
|
onMouseUp: onMouseUpProp,
|
|
66
66
|
...props
|
|
67
|
-
}?: UseClickableProps<Y, M>) => (Omit<UseClickableProps<Y, M>, "disabled" | "ref" | "tabIndex" | "onKeyDown" | "onKeyUp" | "onClick" | "onMouseDown" | "onMouseLeave" | "onMouseOver" | "onMouseUp" | "
|
|
67
|
+
}?: UseClickableProps<Y, M>) => (Omit<UseClickableProps<Y, M>, "disabled" | "ref" | "tabIndex" | "onKeyDown" | "onKeyUp" | "onClick" | "onMouseDown" | "onMouseLeave" | "onMouseOver" | "onMouseUp" | "clickOnEnter" | "clickOnSpace" | "disableTouchBehavior" | "focusable" | "focusOnClick"> & {
|
|
68
68
|
ref: (node: any) => void;
|
|
69
69
|
type: "button";
|
|
70
70
|
"aria-disabled": boolean | undefined;
|
|
@@ -76,7 +76,7 @@ declare const useClickable: <Y extends HTMLElement = HTMLElement, M extends Prop
|
|
|
76
76
|
onMouseLeave: _$react.MouseEventHandler<Y> | undefined;
|
|
77
77
|
onMouseOver: _$react.MouseEventHandler<Y> | undefined;
|
|
78
78
|
onMouseUp: _$react.MouseEventHandler<Y> | undefined;
|
|
79
|
-
}) | (Omit<UseClickableProps<Y, M>, "disabled" | "ref" | "tabIndex" | "onKeyDown" | "onKeyUp" | "onClick" | "onMouseDown" | "onMouseLeave" | "onMouseOver" | "onMouseUp" | "
|
|
79
|
+
}) | (Omit<UseClickableProps<Y, M>, "disabled" | "ref" | "tabIndex" | "onKeyDown" | "onKeyUp" | "onClick" | "onMouseDown" | "onMouseLeave" | "onMouseOver" | "onMouseUp" | "clickOnEnter" | "clickOnSpace" | "disableTouchBehavior" | "focusable" | "focusOnClick"> & {
|
|
80
80
|
ref: (node: any) => void;
|
|
81
81
|
"aria-disabled": "true" | undefined;
|
|
82
82
|
"data-active": string | undefined;
|
|
@@ -134,7 +134,7 @@ declare const I18nContext: _$react.Context<I18nContext<{
|
|
|
134
134
|
readonly toggle: {
|
|
135
135
|
readonly "Toggle button": "Toggle button";
|
|
136
136
|
};
|
|
137
|
-
}, "progress.Loading..." | "progress.{value} percent" | "select.Clear value" | "table.Clear sorting" | "table.Page size" | "table.Select all rows" | "table.Select row" | "table.Sort ascending" | "table.Sort descending" | "
|
|
137
|
+
}, "progress.Loading..." | "progress.{value} percent" | "select.Clear value" | "table.Clear sorting" | "table.Page size" | "table.Select all rows" | "table.Select row" | "table.Sort ascending" | "table.Sort descending" | "toggle.Toggle button" | "slider.Slider thumb" | "modal.Close modal" | "modal.Open modal" | "sidebar.Close sidebar" | "sidebar.Open sidebar" | "closeButton.Close" | "actionBar.Close action bar" | "actionBar.Open action bar" | "autocomplete.Clear value" | "autocomplete.No results found" | "avatar.Avatar Icon" | "breadcrumb.Breadcrumb" | "breadcrumb.Ellipsis" | "calendar.Choose the month" | "calendar.Choose the year" | "calendar.Go to the next month" | "calendar.Go to the previous month" | "calendar.Today" | "carousel.Go to next slide" | "carousel.Go to previous slide" | "carousel.Go to {page} slide" | "carousel.Slides" | "carousel.{page} of {total}" | "colorPicker.Pick a color" | "colorSelector.Pick a color" | "colorSwatch.Color swatch group" | "datePicker.Clear value" | "hueSlider.Blue" | "hueSlider.Cyan" | "hueSlider.Green" | "hueSlider.Magenta" | "hueSlider.Red" | "hueSlider.Yellow" | "numberInput.Decrease" | "numberInput.Increase" | "pagination.Go to first page" | "pagination.Go to last page" | "pagination.Go to next page" | "pagination.Go to page {value}" | "pagination.Go to previous page" | "pagination.Pagination" | "pagination.{value} / {total}" | "pagination.{value} of {total}" | "passwordInput.Password strength meter" | "passwordInput.Toggle password visibility" | "saturationSlider.Saturation and brightness thumb" | "saturationSlider.Saturation {saturation}%, Brightness {brightness}%" | "stat.Decreased by" | "stat.Increased by" | "tag.Close tag">>;
|
|
138
138
|
interface I18nProviderProps {
|
|
139
139
|
children?: ReactNode;
|
|
140
140
|
/**
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yamada-ui/react",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.3.0-next-
|
|
4
|
+
"version": "2.3.0-next-20260517014349",
|
|
5
5
|
"description": "React UI components of the Yamada, by the Yamada, for the Yamada built with React and Emotion",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"yamada",
|