@yamada-ui/react 2.2.6-dev-20260730064602 → 2.2.6-dev-20260730073118

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.
@@ -65,8 +65,8 @@ const useEditable = (props = {}) => {
65
65
  }, [onCancel]);
66
66
  const onBlur = (0, react.useCallback)((ev) => {
67
67
  if (!editing) return;
68
- const ownerDocument = ev.currentTarget.ownerDocument;
69
- const relatedTarget = ev.relatedTarget ?? ownerDocument.activeElement;
68
+ const rootNode = ev.currentTarget.getRootNode();
69
+ const relatedTarget = (0, require_utils_index.utils_exports.isShadowRoot)(rootNode) ? rootNode.activeElement ?? ev.relatedTarget : ev.relatedTarget ?? rootNode.activeElement;
70
70
  const targetIsCancel = (0, require_utils_index.utils_exports.contains)(cancelRef.current, relatedTarget);
71
71
  const targetIsSubmit = (0, require_utils_index.utils_exports.contains)(submitRef.current, relatedTarget);
72
72
  if (!(!targetIsCancel && !targetIsSubmit)) return;
@@ -102,9 +102,8 @@ const useEditable = (props = {}) => {
102
102
  selectAllOnFocus
103
103
  ]);
104
104
  (0, react.useEffect)(() => {
105
- if (editing) return;
106
- const el = inputRef.current;
107
- if (el?.ownerDocument.activeElement === el) el?.blur();
105
+ if (editing || !inputRef.current) return;
106
+ if ((0, require_utils_index.utils_exports.isActiveElement)(inputRef.current, inputRef.current.getRootNode())) inputRef.current.blur();
108
107
  }, [editing]);
109
108
  const getRootProps = (0, react.useCallback)((props) => ({
110
109
  ...rest,
@@ -1 +1 @@
1
- {"version":3,"file":"use-editable.cjs","names":["createContext","useFieldProps","useCallbackRef","useControllableState","mergeRefs"],"sources":["../../../../src/components/editable/use-editable.ts"],"sourcesContent":["\"use client\"\n\nimport type { ChangeEvent, FocusEvent, KeyboardEvent } from \"react\"\nimport type { PropGetter } from \"../../core\"\nimport type { FieldProps } from \"../field\"\nimport { useCallback, useEffect, useRef, useState } from \"react\"\nimport { useControllableState } from \"../../hooks/use-controllable-state\"\nimport { useFocusOnPointerDown } from \"../../hooks/use-focus\"\nimport {\n contains,\n createContext,\n handlerAll,\n mergeRefs,\n useCallbackRef,\n useSafeLayoutEffect,\n useUpdateEffect,\n} from \"../../utils\"\nimport { useFieldProps } from \"../field\"\n\ninterface EditableContext extends Omit<\n UseEditableReturn,\n \"getRootProps\" | \"onCancel\" | \"onEdit\" | \"onSubmit\" | \"value\"\n> {}\n\nconst [EditableContext, useEditableContext] = createContext<EditableContext>({\n name: \"EditableContext\",\n})\n\nexport { EditableContext, useEditableContext }\n\nexport interface UseEditableProps extends FieldProps {\n /**\n * The initial value of the Editable in both edit & preview mode.\n */\n defaultValue?: string\n /**\n * The placeholder text when the value is empty.\n */\n placeholder?: string\n /**\n * If `true`, the read only view, has a `tabIndex` set to `0`\n * so it can receive focus via the keyboard or click.\n *\n * @default true\n */\n previewFocusable?: boolean\n /**\n * If `true`, the input's text will be highlighted on focus.\n *\n * @default true\n */\n selectAllOnFocus?: boolean\n /**\n * If `true`, the Editable will start with edit mode by default.\n */\n startWithEditView?: boolean\n /**\n * If `true`, it'll update the value onBlur and turn off the edit mode.\n *\n * @default true\n */\n submitOnBlur?: boolean\n /**\n * The value of the Editable in both edit & preview mode.\n */\n value?: string\n /**\n * Callback invoked when user cancels input with the `Esc` key.\n * It provides the last confirmed value as argument.\n */\n onCancel?: (preValue: string) => void\n /**\n * A callback invoked when user changes input.\n */\n onChange?: (value: string) => void\n /**\n * A callback invoked once the user enters edit mode.\n */\n onEdit?: () => void\n /**\n * A callback invoked when user confirms value with `enter` key or by blurring input.\n */\n onSubmit?: (value: string) => void\n}\n\nexport const useEditable = (props: UseEditableProps = {}) => {\n const {\n props: {\n id,\n defaultValue,\n disabled,\n placeholder,\n previewFocusable = true,\n readOnly,\n required,\n selectAllOnFocus = true,\n startWithEditView,\n submitOnBlur = true,\n value: valueProp,\n onCancel: onCancelProp,\n onChange: onChangeProp,\n onEdit: onEditProp,\n onSubmit: onSubmitProp,\n ...rest\n },\n ariaProps,\n dataProps,\n eventProps,\n } = useFieldProps(props)\n const onEditRef = useCallbackRef(onEditProp)\n const [editing, setEditing] = useState<boolean>(\n !!startWithEditView && !disabled,\n )\n const [value, setValue] = useControllableState({\n defaultValue: defaultValue || \"\",\n value: valueProp,\n onChange: onChangeProp,\n })\n const interactive = !editing && !disabled\n const emptyValue = value.length === 0\n const [prevValue, setPrevValue] = useState(value)\n const inputRef = useRef<HTMLInputElement | HTMLTextAreaElement>(null)\n const previewRef = useRef<HTMLElement>(null)\n const editRef = useRef<HTMLButtonElement>(null)\n const cancelRef = useRef<HTMLButtonElement>(null)\n const submitRef = useRef<HTMLButtonElement>(null)\n\n const onChange = useCallback(\n (ev: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) =>\n setValue(ev.currentTarget.value),\n [setValue],\n )\n\n const onUpdatePrevValue = useCallback(() => setPrevValue(value), [value])\n\n const onEdit = useCallback(() => {\n if (interactive) setEditing(true)\n }, [interactive])\n\n const onCancel = useCallback(() => {\n setEditing(false)\n setValue(prevValue)\n onCancelProp?.(prevValue)\n }, [prevValue, onCancelProp, setValue])\n\n const onSubmit = useCallback(() => {\n setEditing(false)\n setPrevValue(value)\n onSubmitProp?.(value)\n }, [onSubmitProp, value])\n\n const onKeyDown = useCallback(\n (ev: KeyboardEvent) => {\n if (ev.key !== \"Escape\" && ev.key !== \"Enter\") return\n\n if (ev.key === \"Escape\") {\n ev.preventDefault()\n onCancel()\n } else {\n const { metaKey, shiftKey } = ev\n\n if (!shiftKey && !metaKey) {\n ev.preventDefault()\n onSubmit()\n }\n }\n },\n [onCancel, onSubmit],\n )\n\n const onKeyDownWithoutSubmit = useCallback(\n (ev: KeyboardEvent) => {\n if (ev.key !== \"Escape\") return\n\n ev.preventDefault()\n onCancel()\n },\n [onCancel],\n )\n\n const onBlur = useCallback(\n (ev: FocusEvent) => {\n if (!editing) return\n\n const ownerDocument = ev.currentTarget.ownerDocument\n const relatedTarget = (ev.relatedTarget ??\n ownerDocument.activeElement) as HTMLElement\n const targetIsCancel = contains(cancelRef.current, relatedTarget)\n const targetIsSubmit = contains(submitRef.current, relatedTarget)\n const validBlur = !targetIsCancel && !targetIsSubmit\n\n if (!validBlur) return\n\n if (submitOnBlur) onSubmit()\n else onCancel()\n },\n [editing, submitOnBlur, onSubmit, onCancel],\n )\n\n useFocusOnPointerDown({\n ref: inputRef,\n elements: [cancelRef, submitRef],\n enabled: editing,\n })\n\n useSafeLayoutEffect(() => {\n if (!editing) return\n\n inputRef.current?.focus()\n\n if (selectAllOnFocus) inputRef.current?.select()\n }, [])\n\n useUpdateEffect(() => {\n if (!editing) {\n editRef.current?.focus()\n\n return\n }\n\n inputRef.current?.focus()\n\n if (selectAllOnFocus) inputRef.current?.select()\n\n onEditRef()\n }, [editing, onEditRef, selectAllOnFocus])\n\n useEffect(() => {\n if (editing) return\n\n const el = inputRef.current\n const activeEl = el?.ownerDocument.activeElement\n\n if (activeEl === el) el?.blur()\n }, [editing])\n\n const getRootProps: PropGetter = useCallback(\n (props) => ({\n ...rest,\n ...dataProps,\n ...props,\n }),\n [rest, dataProps],\n )\n\n const getPreviewProps: PropGetter<\"span\"> = useCallback(\n ({ ref, ...props } = {}) => ({\n ...dataProps,\n ...props,\n ref: mergeRefs(previewRef, ref),\n children: emptyValue ? placeholder : value,\n hidden: editing,\n tabIndex: interactive && previewFocusable ? 0 : undefined,\n onFocus: handlerAll(props.onFocus, onEdit, onUpdatePrevValue),\n }),\n [\n dataProps,\n editing,\n interactive,\n previewFocusable,\n emptyValue,\n onEdit,\n onUpdatePrevValue,\n placeholder,\n value,\n ],\n )\n\n const getInputProps: PropGetter<\"input\"> = useCallback(\n ({ ref, ...props } = {}) => ({\n ...dataProps,\n ...ariaProps,\n ...props,\n id,\n ref: mergeRefs(inputRef, ref),\n disabled,\n hidden: !editing,\n placeholder,\n readOnly,\n required,\n value,\n onBlur: handlerAll(eventProps.onBlur, props.onBlur, onBlur),\n onChange: handlerAll(props.onChange, onChange),\n onFocus: handlerAll(eventProps.onFocus, props.onFocus, onUpdatePrevValue),\n onKeyDown: handlerAll(props.onKeyDown, onKeyDown),\n }),\n [\n dataProps,\n ariaProps,\n id,\n disabled,\n editing,\n placeholder,\n readOnly,\n required,\n value,\n eventProps.onBlur,\n eventProps.onFocus,\n onBlur,\n onChange,\n onUpdatePrevValue,\n onKeyDown,\n ],\n )\n\n const getTextareaProps: PropGetter<\"textarea\"> = useCallback(\n ({ ref, ...props } = {}) => ({\n ...dataProps,\n ...ariaProps,\n ...props,\n id,\n ref: mergeRefs(inputRef, ref),\n disabled,\n hidden: !editing,\n placeholder,\n readOnly,\n required,\n value,\n onBlur: handlerAll(eventProps.onBlur, props.onBlur, onBlur),\n onChange: handlerAll(props.onChange, onChange),\n onFocus: handlerAll(eventProps.onFocus, props.onFocus, onUpdatePrevValue),\n onKeyDown: handlerAll(props.onKeyDown, onKeyDownWithoutSubmit),\n }),\n [\n dataProps,\n ariaProps,\n id,\n disabled,\n editing,\n placeholder,\n readOnly,\n required,\n value,\n eventProps.onBlur,\n eventProps.onFocus,\n onBlur,\n onChange,\n onUpdatePrevValue,\n onKeyDownWithoutSubmit,\n ],\n )\n\n const getControlProps: PropGetter = useCallback(\n (props) => ({\n ...dataProps,\n role: \"group\",\n ...props,\n }),\n [dataProps],\n )\n\n const getEditProps: PropGetter<\"button\"> = useCallback(\n ({ ref, ...props } = {}) => ({\n ...dataProps,\n ...props,\n ref: mergeRefs(editRef, ref),\n disabled,\n hidden: editing,\n onClick: handlerAll(props.onClick, onEdit),\n }),\n [dataProps, disabled, editing, onEdit],\n )\n\n const getSubmitProps: PropGetter<\"button\"> = useCallback(\n ({ ref, ...props } = {}) => ({\n ...dataProps,\n ...props,\n ref: mergeRefs(submitRef, ref),\n disabled,\n hidden: !editing,\n onClick: handlerAll(props.onClick, onSubmit),\n }),\n [dataProps, disabled, editing, onSubmit],\n )\n\n const getCancelProps: PropGetter<\"button\"> = useCallback(\n ({ ref, ...props } = {}) => ({\n ...dataProps,\n ...props,\n ref: mergeRefs(cancelRef, ref),\n disabled,\n hidden: !editing,\n onClick: handlerAll(props.onClick, onCancel),\n }),\n [dataProps, disabled, editing, onCancel],\n )\n\n return {\n editing,\n value,\n getCancelProps,\n getControlProps,\n getEditProps,\n getInputProps,\n getPreviewProps,\n getRootProps,\n getSubmitProps,\n getTextareaProps,\n onCancel,\n onEdit,\n onSubmit,\n }\n}\n\nexport type UseEditableReturn = ReturnType<typeof useEditable>\n"],"mappings":";;;;;;;;;;AAwBA,MAAM,CAAC,iBAAiB,sBAAsBA,gBAAAA,cAA+B,EAC3E,MAAM,kBACR,CAAC;AA2DD,MAAa,eAAe,QAA0B,CAAC,MAAM;CAC3D,MAAM,EACJ,OAAO,EACL,IACA,cACA,UACA,aACA,mBAAmB,MACnB,UACA,UACA,mBAAmB,MACnB,mBACA,eAAe,MACf,OAAO,WACP,UAAU,cACV,UAAU,cACV,QAAQ,YACR,UAAU,cACV,GAAG,QAEL,WACA,WACA,eACEC,wBAAAA,cAAc,KAAK;CACvB,MAAM,YAAYC,YAAAA,eAAe,UAAU;CAC3C,MAAM,CAAC,SAAS,eAAA,GAAA,MAAA,SAAA,CACd,CAAC,CAAC,qBAAqB,CAAC,QAC1B;CACA,MAAM,CAAC,OAAO,YAAYC,2CAAAA,qBAAqB;EAC7C,cAAc,gBAAgB;EAC9B,OAAO;EACP,UAAU;CACZ,CAAC;CACD,MAAM,cAAc,CAAC,WAAW,CAAC;CACjC,MAAM,aAAa,MAAM,WAAW;CACpC,MAAM,CAAC,WAAW,iBAAA,GAAA,MAAA,SAAA,CAAyB,KAAK;CAChD,MAAM,YAAA,GAAA,MAAA,OAAA,CAA0D,IAAI;CACpE,MAAM,cAAA,GAAA,MAAA,OAAA,CAAiC,IAAI;CAC3C,MAAM,WAAA,GAAA,MAAA,OAAA,CAAoC,IAAI;CAC9C,MAAM,aAAA,GAAA,MAAA,OAAA,CAAsC,IAAI;CAChD,MAAM,aAAA,GAAA,MAAA,OAAA,CAAsC,IAAI;C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W;EACV,GAAG;EACH,MAAM;EACN,GAAG;CACL,IACA,CAAC,SAAS,CACZ;CAEA,MAAM,gBAAA,GAAA,MAAA,YAAA,EACH,EAAE,KAAK,GAAG,UAAU,CAAC,OAAO;EAC3B,GAAG;EACH,GAAG;EACH,KAAKA,YAAAA,UAAU,SAAS,GAAG;EAC3B;EACA,QAAQ;EACR,UAAA,GAAA,oBAAA,cAAA,WAAA,CAAoB,MAAM,SAAS,MAAM;CAC3C,IACA;EAAC;EAAW;EAAU;EAAS;CAAM,CACvC;CAEA,MAAM,kBAAA,GAAA,MAAA,YAAA,EACH,EAAE,KAAK,GAAG,UAAU,CAAC,OAAO;EAC3B,GAAG;EACH,GAAG;EACH,KAAKA,YAAAA,UAAU,WAAW,GAAG;EAC7B;EACA,QAAQ,CAAC;EACT,UAAA,GAAA,oBAAA,cAAA,WAAA,CAAoB,MAAM,SAAS,QAAQ;CAC7C,IACA;EAAC;EAAW;EAAU;EAAS;CAAQ,CACzC;CAcA,OAAO;EACL;EACA;EACA,iBAAA,GAAA,MAAA,YAAA,EAdC,EAAE,KAAK,GAAG,UAAU,CAAC,OAAO;GAC3B,GAAG;GACH,GAAG;GACH,KAAKA,YAAAA,UAAU,WAAW,GAAG;GAC7B;GACA,QAAQ,CAAC;GACT,UAAA,GAAA,oBAAA,cAAA,WAAA,CAAoB,MAAM,SAAS,QAAQ;EAC7C,IACA;GAAC;GAAW;GAAU;GAAS;EAAQ,CAM1B;EACb;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;AACF"}
1
+ {"version":3,"file":"use-editable.cjs","names":["createContext","useFieldProps","useCallbackRef","useControllableState","mergeRefs"],"sources":["../../../../src/components/editable/use-editable.ts"],"sourcesContent":["\"use client\"\n\nimport type { ChangeEvent, FocusEvent, KeyboardEvent } from \"react\"\nimport type { PropGetter } from \"../../core\"\nimport type { FieldProps } from \"../field\"\nimport { useCallback, useEffect, useRef, useState } from \"react\"\nimport { useControllableState } from \"../../hooks/use-controllable-state\"\nimport { useFocusOnPointerDown } from \"../../hooks/use-focus\"\nimport {\n contains,\n createContext,\n handlerAll,\n isActiveElement,\n isShadowRoot,\n mergeRefs,\n useCallbackRef,\n useSafeLayoutEffect,\n useUpdateEffect,\n} from \"../../utils\"\nimport { useFieldProps } from \"../field\"\n\ninterface EditableContext extends Omit<\n UseEditableReturn,\n \"getRootProps\" | \"onCancel\" | \"onEdit\" | \"onSubmit\" | \"value\"\n> {}\n\nconst [EditableContext, useEditableContext] = createContext<EditableContext>({\n name: \"EditableContext\",\n})\n\nexport { EditableContext, useEditableContext }\n\nexport interface UseEditableProps extends FieldProps {\n /**\n * The initial value of the Editable in both edit & preview mode.\n */\n defaultValue?: string\n /**\n * The placeholder text when the value is empty.\n */\n placeholder?: string\n /**\n * If `true`, the read only view, has a `tabIndex` set to `0`\n * so it can receive focus via the keyboard or click.\n *\n * @default true\n */\n previewFocusable?: boolean\n /**\n * If `true`, the input's text will be highlighted on focus.\n *\n * @default true\n */\n selectAllOnFocus?: boolean\n /**\n * If `true`, the Editable will start with edit mode by default.\n */\n startWithEditView?: boolean\n /**\n * If `true`, it'll update the value onBlur and turn off the edit mode.\n *\n * @default true\n */\n submitOnBlur?: boolean\n /**\n * The value of the Editable in both edit & preview mode.\n */\n value?: string\n /**\n * Callback invoked when user cancels input with the `Esc` key.\n * It provides the last confirmed value as argument.\n */\n onCancel?: (preValue: string) => void\n /**\n * A callback invoked when user changes input.\n */\n onChange?: (value: string) => void\n /**\n * A callback invoked once the user enters edit mode.\n */\n onEdit?: () => void\n /**\n * A callback invoked when user confirms value with `enter` key or by blurring input.\n */\n onSubmit?: (value: string) => void\n}\n\nexport const useEditable = (props: UseEditableProps = {}) => {\n const {\n props: {\n id,\n defaultValue,\n disabled,\n placeholder,\n previewFocusable = true,\n readOnly,\n required,\n selectAllOnFocus = true,\n startWithEditView,\n submitOnBlur = true,\n value: valueProp,\n onCancel: onCancelProp,\n onChange: onChangeProp,\n onEdit: onEditProp,\n onSubmit: onSubmitProp,\n ...rest\n },\n ariaProps,\n dataProps,\n eventProps,\n } = useFieldProps(props)\n const onEditRef = useCallbackRef(onEditProp)\n const [editing, setEditing] = useState<boolean>(\n !!startWithEditView && !disabled,\n )\n const [value, setValue] = useControllableState({\n defaultValue: defaultValue || \"\",\n value: valueProp,\n onChange: onChangeProp,\n })\n const interactive = !editing && !disabled\n const emptyValue = value.length === 0\n const [prevValue, setPrevValue] = useState(value)\n const inputRef = useRef<HTMLInputElement | HTMLTextAreaElement>(null)\n const previewRef = useRef<HTMLElement>(null)\n const editRef = useRef<HTMLButtonElement>(null)\n const cancelRef = useRef<HTMLButtonElement>(null)\n const submitRef = useRef<HTMLButtonElement>(null)\n\n const onChange = useCallback(\n (ev: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) =>\n setValue(ev.currentTarget.value),\n [setValue],\n )\n\n const onUpdatePrevValue = useCallback(() => setPrevValue(value), [value])\n\n const onEdit = useCallback(() => {\n if (interactive) setEditing(true)\n }, [interactive])\n\n const onCancel = useCallback(() => {\n setEditing(false)\n setValue(prevValue)\n onCancelProp?.(prevValue)\n }, [prevValue, onCancelProp, setValue])\n\n const onSubmit = useCallback(() => {\n setEditing(false)\n setPrevValue(value)\n onSubmitProp?.(value)\n }, [onSubmitProp, value])\n\n const onKeyDown = useCallback(\n (ev: KeyboardEvent) => {\n if (ev.key !== \"Escape\" && ev.key !== \"Enter\") return\n\n if (ev.key === \"Escape\") {\n ev.preventDefault()\n onCancel()\n } else {\n const { metaKey, shiftKey } = ev\n\n if (!shiftKey && !metaKey) {\n ev.preventDefault()\n onSubmit()\n }\n }\n },\n [onCancel, onSubmit],\n )\n\n const onKeyDownWithoutSubmit = useCallback(\n (ev: KeyboardEvent) => {\n if (ev.key !== \"Escape\") return\n\n ev.preventDefault()\n onCancel()\n },\n [onCancel],\n )\n\n const onBlur = useCallback(\n (ev: FocusEvent) => {\n if (!editing) return\n\n const rootNode = ev.currentTarget.getRootNode() as Document | ShadowRoot\n const relatedTarget = (\n isShadowRoot(rootNode)\n ? (rootNode.activeElement ?? ev.relatedTarget)\n : (ev.relatedTarget ?? rootNode.activeElement)\n ) as HTMLElement\n const targetIsCancel = contains(cancelRef.current, relatedTarget)\n const targetIsSubmit = contains(submitRef.current, relatedTarget)\n const validBlur = !targetIsCancel && !targetIsSubmit\n\n if (!validBlur) return\n\n if (submitOnBlur) onSubmit()\n else onCancel()\n },\n [editing, submitOnBlur, onSubmit, onCancel],\n )\n\n useFocusOnPointerDown({\n ref: inputRef,\n elements: [cancelRef, submitRef],\n enabled: editing,\n })\n\n useSafeLayoutEffect(() => {\n if (!editing) return\n\n inputRef.current?.focus()\n\n if (selectAllOnFocus) inputRef.current?.select()\n }, [])\n\n useUpdateEffect(() => {\n if (!editing) {\n editRef.current?.focus()\n\n return\n }\n\n inputRef.current?.focus()\n\n if (selectAllOnFocus) inputRef.current?.select()\n\n onEditRef()\n }, [editing, onEditRef, selectAllOnFocus])\n\n useEffect(() => {\n if (editing || !inputRef.current) return\n if (isActiveElement(inputRef.current, inputRef.current.getRootNode()))\n inputRef.current.blur()\n }, [editing])\n\n const getRootProps: PropGetter = useCallback(\n (props) => ({\n ...rest,\n ...dataProps,\n ...props,\n }),\n [rest, dataProps],\n )\n\n const getPreviewProps: PropGetter<\"span\"> = useCallback(\n ({ ref, ...props } = {}) => ({\n ...dataProps,\n ...props,\n ref: mergeRefs(previewRef, ref),\n children: emptyValue ? placeholder : value,\n hidden: editing,\n tabIndex: interactive && previewFocusable ? 0 : undefined,\n onFocus: handlerAll(props.onFocus, onEdit, onUpdatePrevValue),\n }),\n [\n dataProps,\n editing,\n interactive,\n previewFocusable,\n emptyValue,\n onEdit,\n onUpdatePrevValue,\n placeholder,\n value,\n ],\n )\n\n const getInputProps: PropGetter<\"input\"> = useCallback(\n ({ ref, ...props } = {}) => ({\n ...dataProps,\n ...ariaProps,\n ...props,\n id,\n ref: mergeRefs(inputRef, ref),\n disabled,\n hidden: !editing,\n placeholder,\n readOnly,\n required,\n value,\n onBlur: handlerAll(eventProps.onBlur, props.onBlur, onBlur),\n onChange: handlerAll(props.onChange, onChange),\n onFocus: handlerAll(eventProps.onFocus, props.onFocus, onUpdatePrevValue),\n onKeyDown: handlerAll(props.onKeyDown, onKeyDown),\n }),\n [\n dataProps,\n ariaProps,\n id,\n disabled,\n editing,\n placeholder,\n readOnly,\n required,\n value,\n eventProps.onBlur,\n eventProps.onFocus,\n onBlur,\n onChange,\n onUpdatePrevValue,\n onKeyDown,\n ],\n )\n\n const getTextareaProps: PropGetter<\"textarea\"> = useCallback(\n ({ ref, ...props } = {}) => ({\n ...dataProps,\n ...ariaProps,\n ...props,\n id,\n ref: mergeRefs(inputRef, ref),\n disabled,\n hidden: !editing,\n placeholder,\n readOnly,\n required,\n value,\n onBlur: handlerAll(eventProps.onBlur, props.onBlur, onBlur),\n onChange: handlerAll(props.onChange, onChange),\n onFocus: handlerAll(eventProps.onFocus, props.onFocus, onUpdatePrevValue),\n onKeyDown: handlerAll(props.onKeyDown, onKeyDownWithoutSubmit),\n }),\n [\n dataProps,\n ariaProps,\n id,\n disabled,\n editing,\n placeholder,\n readOnly,\n required,\n value,\n eventProps.onBlur,\n eventProps.onFocus,\n onBlur,\n onChange,\n onUpdatePrevValue,\n onKeyDownWithoutSubmit,\n ],\n )\n\n const getControlProps: PropGetter = useCallback(\n (props) => ({\n ...dataProps,\n role: \"group\",\n ...props,\n }),\n [dataProps],\n )\n\n const getEditProps: PropGetter<\"button\"> = useCallback(\n ({ ref, ...props } = {}) => ({\n ...dataProps,\n ...props,\n ref: mergeRefs(editRef, ref),\n disabled,\n hidden: editing,\n onClick: handlerAll(props.onClick, onEdit),\n }),\n [dataProps, disabled, editing, onEdit],\n )\n\n const getSubmitProps: PropGetter<\"button\"> = useCallback(\n ({ ref, ...props } = {}) => ({\n ...dataProps,\n ...props,\n ref: mergeRefs(submitRef, ref),\n disabled,\n hidden: !editing,\n onClick: handlerAll(props.onClick, onSubmit),\n }),\n [dataProps, disabled, editing, onSubmit],\n )\n\n const getCancelProps: PropGetter<\"button\"> = useCallback(\n ({ ref, ...props } = {}) => ({\n ...dataProps,\n ...props,\n ref: mergeRefs(cancelRef, ref),\n disabled,\n hidden: !editing,\n onClick: handlerAll(props.onClick, onCancel),\n }),\n [dataProps, disabled, editing, onCancel],\n )\n\n return {\n editing,\n value,\n getCancelProps,\n getControlProps,\n getEditProps,\n getInputProps,\n getPreviewProps,\n getRootProps,\n getSubmitProps,\n getTextareaProps,\n onCancel,\n onEdit,\n onSubmit,\n }\n}\n\nexport type UseEditableReturn = ReturnType<typeof useEditable>\n"],"mappings":";;;;;;;;;;AA0BA,MAAM,CAAC,iBAAiB,sBAAsBA,gBAAAA,cAA+B,EAC3E,MAAM,kBACR,CAAC;AA2DD,MAAa,eAAe,QAA0B,CAAC,MAAM;CAC3D,MAAM,EACJ,OAAO,EACL,IACA,cACA,UACA,aACA,mBAAmB,MACnB,UACA,UACA,mBAAmB,MACnB,mBACA,eAAe,MACf,OAAO,WACP,UAAU,cACV,UAAU,cACV,QAAQ,YACR,UAAU,cACV,GAAG,QAEL,WACA,WACA,eACEC,wBAAAA,cAAc,KAAK;CACvB,MAAM,YAAYC,YAAAA,eAAe,UAAU;CAC3C,MAAM,CAAC,SAAS,eAAA,GAAA,MAAA,SAAA,CACd,CAAC,CAAC,qBAAqB,CAAC,QAC1B;CACA,MAAM,CAAC,OAAO,YAAYC,2CAAAA,qBAAqB;EAC7C,cAAc,gBAAgB;EAC9B,OAAO;EACP,UAAU;CACZ,CAAC;CACD,MAAM,cAAc,CAAC,WAAW,CAAC;CACjC,MAAM,aAAa,MAAM,WAAW;CACpC,MAAM,CAAC,WAAW,iBAAA,GAAA,MAAA,SAAA,CAAyB,KAAK;CAChD,MAAM,YAAA,GAAA,MAAA,OAAA,CAA0D,IAAI;CACpE,MAAM,cAAA,GAAA,MAAA,OAAA,CAAiC,IAAI;CAC3C,MAAM,WAAA,GAAA,MAAA,OAAA,CAAoC,IA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utils/children.cjs");
3
3
  const require_utils_index = require("../../utils/index.cjs");
4
4
  const require_factory = require("../../core/system/factory.cjs");
5
+ const require_props = require("../../core/components/props.cjs");
5
6
  const require_create_component = require("../../core/components/create-component.cjs");
6
7
  const require_factory$1 = require("../motion/factory.cjs");
7
8
  const require_hooks_use_value_index = require("../../hooks/use-value/index.cjs");
@@ -24,7 +25,7 @@ const { ComponentContext, PropsContext: ModalPropsContext, useComponentContext,
24
25
  *
25
26
  * @see https://yamada-ui.com/docs/components/modal
26
27
  */
27
- const ModalRoot = withProvider(({ allowPinchZoom = false, animationScheme = "scale", autoFocus, blockScrollOnMount = true, body, cancel, children, duration, finalFocusRef, footer, header, initialFocusRef, lockFocusAcrossFrames = true, middle, restoreFocus, success, title, trigger, withCloseButton = true, withOverlay = true, portalProps, onCancel, onCloseComplete, onMiddle, onSuccess, ...props }) => {
28
+ const ModalRoot = withProvider(({ allowPinchZoom = false, animationScheme = "scale", autoFocus, blockScrollOnMount = true, body, cancel, children, duration, finalFocusRef, footer, header, initialFocusRef, lockFocusAcrossFrames = true, middle, restoreFocus, success, title, trigger, withCloseButton = true, withOverlay = true, bodyProps, closeButtonProps, closeTriggerProps, contentProps, footerProps, headerProps, openTriggerProps, overlayProps, portalProps, titleProps, onCancel, onCloseComplete, onMiddle, onSuccess, ...props }) => {
28
29
  const [omittedChildren, openTrigger, customOverlay] = require_children.useSplitChildren(children, ModalOpenTrigger, ModalOverlay);
29
30
  const hasChildren = (0, require_utils_index.utils_exports.isArray)(omittedChildren) && !!omittedChildren.length;
30
31
  const { open, getRootProps, ...rest } = require_use_modal.useModal(props);
@@ -34,12 +35,30 @@ const ModalRoot = withProvider(({ allowPinchZoom = false, animationScheme = "sca
34
35
  duration,
35
36
  open,
36
37
  withCloseButton,
38
+ bodyProps,
39
+ closeButtonProps,
40
+ closeTriggerProps,
41
+ contentProps,
42
+ footerProps,
43
+ headerProps,
44
+ openTriggerProps,
45
+ overlayProps,
46
+ titleProps,
37
47
  ...rest
38
48
  }), [
39
49
  animationScheme,
40
50
  duration,
41
51
  open,
42
52
  withCloseButton,
53
+ contentProps,
54
+ bodyProps,
55
+ footerProps,
56
+ headerProps,
57
+ titleProps,
58
+ openTriggerProps,
59
+ closeTriggerProps,
60
+ closeButtonProps,
61
+ overlayProps,
43
62
  rest
44
63
  ]);
45
64
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(ComponentContext, {
@@ -83,28 +102,28 @@ const ModalOpenTrigger = withContext("button", {
83
102
  name: "OpenTrigger",
84
103
  slot: ["trigger", "open"]
85
104
  })(void 0, (props) => {
86
- const { getOpenTriggerProps } = useComponentContext();
105
+ const { getOpenTriggerProps, openTriggerProps } = useComponentContext();
87
106
  return {
88
107
  asChild: true,
89
- ...getOpenTriggerProps(props)
108
+ ...getOpenTriggerProps(require_props.mergeProps(openTriggerProps, props)())
90
109
  };
91
110
  });
92
111
  const ModalCloseTrigger = withContext("button", {
93
112
  name: "CloseTrigger",
94
113
  slot: ["trigger", "close"]
95
114
  })(void 0, (props) => {
96
- const { getCloseTriggerProps } = useComponentContext();
115
+ const { closeTriggerProps, getCloseTriggerProps } = useComponentContext();
97
116
  return {
98
117
  asChild: true,
99
- ...getCloseTriggerProps(props)
118
+ ...getCloseTriggerProps(require_props.mergeProps(closeTriggerProps, props)())
100
119
  };
101
120
  });
102
121
  const ModalCloseButton = withContext(require_close_button.CloseButton, "closeButton")(void 0, (props) => {
103
- const { getCloseButtonProps } = useComponentContext();
104
- return { ...getCloseButtonProps(props) };
122
+ const { closeButtonProps, getCloseButtonProps } = useComponentContext();
123
+ return { ...getCloseButtonProps(require_props.mergeProps(closeButtonProps, props)()) };
105
124
  });
106
125
  const ModalOverlay = withContext((props) => {
107
- const { animationScheme, duration: durationProp, getOverlayProps } = useComponentContext();
126
+ const { animationScheme, duration: durationProp, getOverlayProps, overlayProps } = useComponentContext();
108
127
  const duration = require_hooks_use_value_index.useValue(durationProp);
109
128
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_factory$1.motion.div, {
110
129
  custom: { duration },
@@ -114,11 +133,11 @@ const ModalOverlay = withContext((props) => {
114
133
  initial: "exit",
115
134
  variants: require_fade.fadeVariants
116
135
  } : {},
117
- ...(0, require_utils_index.utils_exports.cast)(getOverlayProps((0, require_utils_index.utils_exports.cast)(props)))
136
+ ...(0, require_utils_index.utils_exports.cast)(getOverlayProps((0, require_utils_index.utils_exports.cast)(require_props.mergeProps(overlayProps, props)())))
118
137
  });
119
138
  }, "overlay")();
120
139
  const ModalContent = withContext(({ children, ...rest }) => {
121
- const { animationScheme, duration, withCloseButton, getContentProps } = useComponentContext();
140
+ const { animationScheme, duration, withCloseButton, contentProps, getContentProps } = useComponentContext();
122
141
  const [omittedChildren, customCloseButton] = require_children.useSplitChildren(children, ModalCloseButton);
123
142
  const popupAnimationProps = require_popover.usePopupAnimationProps({
124
143
  animationScheme,
@@ -126,7 +145,7 @@ const ModalContent = withContext(({ children, ...rest }) => {
126
145
  });
127
146
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_factory$1.motion.section, {
128
147
  ...popupAnimationProps,
129
- ...(0, require_utils_index.utils_exports.cast)(getContentProps((0, require_utils_index.utils_exports.cast)(rest))),
148
+ ...(0, require_utils_index.utils_exports.cast)(getContentProps((0, require_utils_index.utils_exports.cast)(require_props.mergeProps(contentProps, rest)()))),
130
149
  children: [customCloseButton ?? (withCloseButton ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ModalCloseButton, {}) : null), omittedChildren]
131
150
  });
132
151
  }, "content")();
@@ -160,20 +179,20 @@ const ShorthandModalContent = ({ body, cancel, footer, header, middle, success,
160
179
  ] });
161
180
  };
162
181
  const ModalHeader = withContext("header", "header")(void 0, (props) => {
163
- const { getHeaderProps } = useComponentContext();
164
- return { ...getHeaderProps(props) };
182
+ const { getHeaderProps, headerProps } = useComponentContext();
183
+ return { ...getHeaderProps(require_props.mergeProps(headerProps, props)()) };
165
184
  });
166
185
  const ModalTitle = withContext("h2", "title")(void 0, (props) => {
167
- const { getTitleProps } = useComponentContext();
168
- return { ...getTitleProps(props) };
186
+ const { getTitleProps, titleProps } = useComponentContext();
187
+ return { ...getTitleProps(require_props.mergeProps(titleProps, props)()) };
169
188
  });
170
189
  const ModalBody = withContext("div", "body")(void 0, (props) => {
171
- const { getBodyProps } = useComponentContext();
172
- return { ...getBodyProps(props) };
190
+ const { bodyProps, getBodyProps } = useComponentContext();
191
+ return { ...getBodyProps(require_props.mergeProps(bodyProps, props)()) };
173
192
  });
174
193
  const ModalFooter = withContext("footer", "footer")(void 0, (props) => {
175
- const { getFooterProps } = useComponentContext();
176
- return { ...getFooterProps(props) };
194
+ const { footerProps, getFooterProps } = useComponentContext();
195
+ return { ...getFooterProps(require_props.mergeProps(footerProps, props)()) };
177
196
  });
178
197
  //#endregion
179
198
  exports.ModalBody = ModalBody;
@@ -187,7 +206,6 @@ exports.ModalOverlay = ModalOverlay;
187
206
  exports.ModalPropsContext = ModalPropsContext;
188
207
  exports.ModalRoot = ModalRoot;
189
208
  exports.ModalTitle = ModalTitle;
190
- exports.ShorthandModalContent = ShorthandModalContent;
191
209
  exports.useModalPropsContext = useModalPropsContext;
192
210
 
193
211
  //# sourceMappingURL=modal.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"modal.cjs","names":["createSlotComponent","modalStyle","useSplitChildren","useModal","AnimatePresence","Portal","FocusLock","RemoveScroll","styled","CloseButton","useValue","motion","fadeVariants","usePopupAnimationProps","wrapOrPassProps","Button"],"sources":["../../../../src/components/modal/modal.tsx"],"sourcesContent":["\"use client\"\n\nimport type { FC, PropsWithChildren, ReactNode } from \"react\"\nimport type { HTMLProps, HTMLStyledProps, ThemeProps } from \"../../core\"\nimport type { ButtonProps } from \"../button\"\nimport type { CloseButtonProps } from \"../close-button\"\nimport type { FocusLockProps } from \"../focus-lock\"\nimport type { HTMLMotionProps, HTMLMotionPropsWithoutAs } from \"../motion\"\nimport type { UsePopupAnimationProps } from \"../popover\"\nimport type { PortalProps } from \"../portal\"\nimport type { ModalStyle } from \"./modal.style\"\nimport type { UseModalProps, UseModalReturn } from \"./use-modal\"\nimport { AnimatePresence } from \"motion/react\"\nimport { useMemo } from \"react\"\nimport { RemoveScroll } from \"react-remove-scroll\"\nimport { createSlotComponent, styled } from \"../../core\"\nimport { useValue } from \"../../hooks/use-value\"\nimport { cast, isArray, useSplitChildren, wrapOrPassProps } from \"../../utils\"\nimport { Button } from \"../button\"\nimport { CloseButton } from \"../close-button\"\nimport { fadeVariants } from \"../fade\"\nimport { FocusLock } from \"../focus-lock\"\nimport { motion } from \"../motion\"\nimport { usePopupAnimationProps } from \"../popover\"\nimport { Portal } from \"../portal\"\nimport { modalStyle } from \"./modal.style\"\nimport { useModal } from \"./use-modal\"\n\ninterface ComponentContext\n extends\n Omit<UseModalReturn, \"getRootProps\">,\n UsePopupAnimationProps,\n Pick<ModalRootProps, \"withCloseButton\"> {}\n\nexport interface ModalRootProps\n extends\n Omit<HTMLStyledProps<\"div\">, \"scrollBehavior\" | \"title\">,\n ThemeProps<ModalStyle>,\n Omit<UseModalProps, \"title\">,\n Pick<\n FocusLockProps,\n | \"autoFocus\"\n | \"finalFocusRef\"\n | \"initialFocusRef\"\n | \"lockFocusAcrossFrames\"\n | \"restoreFocus\"\n >,\n UsePopupAnimationProps,\n ShorthandModalContentProps {\n /**\n * Handle zoom or pinch gestures on iOS devices when scroll locking is enabled.\n *\n * @default false.\n */\n allowPinchZoom?: boolean\n /**\n * If `true`, scrolling will be disabled on the `body` when the modal opens.\n *\n * @default true\n */\n blockScrollOnMount?: boolean\n /**\n * The modal trigger to use.\n */\n trigger?: ReactNode\n /**\n * If `true`, display the modal close button.\n *\n * @default true\n */\n withCloseButton?: boolean\n /**\n * If `true`, display the modal overlay.\n *\n * @default true\n */\n withOverlay?: boolean\n /**\n * Props to be forwarded to the portal component.\n */\n portalProps?: Omit<PortalProps, \"children\">\n /**\n * Callback function to run side effects after the modal has closed.\n */\n onCloseComplete?: () => void\n}\n\nconst {\n ComponentContext,\n PropsContext: ModalPropsContext,\n useComponentContext,\n usePropsContext: useModalPropsContext,\n withContext,\n withProvider,\n} = createSlotComponent<ModalRootProps, ModalStyle, ComponentContext>(\n \"modal\",\n modalStyle,\n)\n\nexport { ModalPropsContext, useModalPropsContext }\n\n/**\n * `Modal` is a component that is displayed over the main content to focus the user's attention solely on the information.\n *\n * @see https://yamada-ui.com/docs/components/modal\n */\nexport const ModalRoot = withProvider<\"div\", ModalRootProps>(\n ({\n allowPinchZoom = false,\n animationScheme = \"scale\",\n autoFocus,\n blockScrollOnMount = true,\n body,\n cancel,\n children,\n duration,\n finalFocusRef,\n footer,\n header,\n initialFocusRef,\n lockFocusAcrossFrames = true,\n middle,\n restoreFocus,\n success,\n title,\n trigger,\n withCloseButton = true,\n withOverlay = true,\n portalProps,\n onCancel,\n onCloseComplete,\n onMiddle,\n onSuccess,\n ...props\n }) => {\n const [omittedChildren, openTrigger, customOverlay] = useSplitChildren(\n children,\n ModalOpenTrigger,\n ModalOverlay,\n )\n const hasChildren = isArray(omittedChildren) && !!omittedChildren.length\n const { open, getRootProps, ...rest } = useModal(props)\n const customOpenTrigger = trigger ? (\n <ModalOpenTrigger>{trigger}</ModalOpenTrigger>\n ) : null\n const context = useMemo(\n () => ({\n animationScheme,\n duration,\n open,\n withCloseButton,\n ...rest,\n }),\n [animationScheme, duration, open, withCloseButton, rest],\n )\n\n return (\n <ComponentContext value={context}>\n {openTrigger ?? customOpenTrigger}\n\n <AnimatePresence onExitComplete={onCloseComplete}>\n {open ? (\n <Portal {...portalProps}>\n <FocusLock\n autoFocus={autoFocus}\n finalFocusRef={finalFocusRef}\n initialFocusRef={initialFocusRef}\n lockFocusAcrossFrames={lockFocusAcrossFrames}\n restoreFocus={restoreFocus}\n >\n <RemoveScroll\n allowPinchZoom={allowPinchZoom}\n enabled={blockScrollOnMount}\n forwardProps\n >\n <styled.div {...getRootProps()}>\n {customOverlay ?? (withOverlay ? <ModalOverlay /> : null)}\n\n {hasChildren ? (\n omittedChildren\n ) : (\n <ShorthandModalContent\n body={body}\n cancel={cancel}\n footer={footer}\n header={header}\n middle={middle}\n success={success}\n title={title}\n onCancel={onCancel}\n onMiddle={onMiddle}\n onSuccess={onSuccess}\n />\n )}\n </styled.div>\n </RemoveScroll>\n </FocusLock>\n </Portal>\n ) : null}\n </AnimatePresence>\n </ComponentContext>\n )\n },\n \"root\",\n)()\n\nexport interface ModalOpenTriggerProps extends HTMLStyledProps<\"button\"> {}\n\nexport const ModalOpenTrigger = withContext<\"button\", ModalOpenTriggerProps>(\n \"button\",\n { name: \"OpenTrigger\", slot: [\"trigger\", \"open\"] },\n)(undefined, (props) => {\n const { getOpenTriggerProps } = useComponentContext()\n\n return { asChild: true, ...getOpenTriggerProps(props) }\n})\n\nexport interface ModalCloseTriggerProps extends HTMLStyledProps<\"button\"> {}\n\nexport const ModalCloseTrigger = withContext<\"button\", ModalCloseTriggerProps>(\n \"button\",\n { name: \"CloseTrigger\", slot: [\"trigger\", \"close\"] },\n)(undefined, (props) => {\n const { getCloseTriggerProps } = useComponentContext()\n\n return { asChild: true, ...getCloseTriggerProps(props) }\n})\n\nexport interface ModalCloseButtonProps extends CloseButtonProps {}\n\nexport const ModalCloseButton = withContext<\"button\", ModalCloseButtonProps>(\n CloseButton,\n \"closeButton\",\n)(undefined, (props) => {\n const { getCloseButtonProps } = useComponentContext()\n\n return { ...getCloseButtonProps(props) }\n})\n\nexport interface ModalOverlayProps extends HTMLMotionProps {}\n\nexport const ModalOverlay = withContext<\"div\", ModalOverlayProps>((props) => {\n const {\n animationScheme,\n duration: durationProp,\n getOverlayProps,\n } = useComponentContext()\n const duration = useValue(durationProp)\n\n return (\n <motion.div\n custom={{ duration }}\n {...(animationScheme !== \"none\"\n ? {\n animate: \"enter\",\n exit: \"exit\",\n initial: \"exit\",\n variants: fadeVariants,\n }\n : {})}\n {...cast<HTMLMotionProps>(getOverlayProps(cast<HTMLProps>(props)))}\n />\n )\n}, \"overlay\")()\n\nexport interface ModalContentProps\n extends Omit<HTMLMotionProps<\"section\">, \"children\">, PropsWithChildren {}\n\nexport const ModalContent = withContext<\"section\", ModalContentProps>(\n ({ children, ...rest }) => {\n const { animationScheme, duration, withCloseButton, getContentProps } =\n useComponentContext()\n const [omittedChildren, customCloseButton] = useSplitChildren(\n children,\n ModalCloseButton,\n )\n const popupAnimationProps = usePopupAnimationProps({\n animationScheme,\n duration,\n })\n\n return (\n <motion.section\n {...popupAnimationProps}\n {...cast<HTMLMotionPropsWithoutAs<\"section\">>(\n getContentProps(cast<HTMLProps<\"section\">>(rest)),\n )}\n >\n {customCloseButton ?? (withCloseButton ? <ModalCloseButton /> : null)}\n\n {omittedChildren}\n </motion.section>\n )\n },\n \"content\",\n)()\n\ninterface ShorthandModalContentProps {\n /**\n * The modal body to use.\n */\n body?: ModalBodyProps | ReactNode\n /**\n * The modal cancel button to use.\n */\n cancel?: ButtonProps | ReactNode\n /**\n * The modal footer to use.\n */\n footer?: ModalFooterProps | ReactNode\n /**\n * The modal header to use.\n */\n header?: ModalHeaderProps | ReactNode\n /**\n * The modal middle button to use.\n */\n middle?: ButtonProps | ReactNode\n /**\n * The modal success button to use.\n */\n success?: ButtonProps | ReactNode\n /**\n * The modal title to use.\n */\n title?: ModalTitleProps | ReactNode\n /**\n * The callback invoked when cancel button clicked.\n */\n onCancel?: (onClose: () => void) => void\n /**\n * The callback invoked when middle button clicked.\n */\n onMiddle?: (onClose: () => void) => void\n /**\n * The callback invoked when success button clicked.\n */\n onSuccess?: (onClose: () => void) => void\n}\n\nexport const ShorthandModalContent: FC<ShorthandModalContentProps> = ({\n body,\n cancel,\n footer,\n header,\n middle,\n success,\n title,\n onCancel,\n onMiddle,\n onSuccess,\n}) => {\n const { onClose } = useComponentContext()\n const customHeader = wrapOrPassProps(ModalHeader, header)\n const customTitle = wrapOrPassProps(ModalTitle, title)\n const customBody = wrapOrPassProps(ModalBody, body)\n const customFooter = wrapOrPassProps(ModalFooter, footer)\n const customCancel = wrapOrPassProps(Button, cancel, {\n colorScheme: \"mono\",\n variant: \"ghost\",\n onClick: () => (onCancel ? onCancel(onClose) : onClose()),\n })\n const customMiddle = wrapOrPassProps(Button, middle, {\n colorScheme: \"secondary\",\n onClick: () => (onMiddle ? onMiddle(onClose) : onClose()),\n })\n const customSuccess = wrapOrPassProps(Button, success, {\n colorScheme: \"primary\",\n onClick: () => (onSuccess ? onSuccess(onClose) : onClose()),\n })\n\n return (\n <ModalContent>\n {customHeader ??\n (customTitle ? <ModalHeader>{customTitle}</ModalHeader> : null)}\n {customBody}\n {customFooter ??\n (customCancel || customMiddle || customSuccess ? (\n <ModalFooter>\n {customCancel}\n {customMiddle}\n {customSuccess}\n </ModalFooter>\n ) : null)}\n </ModalContent>\n )\n}\n\nexport interface ModalHeaderProps extends HTMLStyledProps<\"header\"> {}\n\nexport const ModalHeader = withContext<\"header\", ModalHeaderProps>(\n \"header\",\n \"header\",\n)(undefined, (props) => {\n const { getHeaderProps } = useComponentContext()\n\n return { ...getHeaderProps(props) }\n})\n\nexport interface ModalTitleProps extends HTMLStyledProps<\"h2\"> {}\n\nexport const ModalTitle = withContext<\"h2\", ModalTitleProps>(\"h2\", \"title\")(\n undefined,\n (props) => {\n const { getTitleProps } = useComponentContext()\n\n return { ...getTitleProps(props) }\n },\n)\n\nexport interface ModalBodyProps extends HTMLStyledProps {}\n\nexport const ModalBody = withContext<\"div\", ModalBodyProps>(\"div\", \"body\")(\n undefined,\n (props) => {\n const { getBodyProps } = useComponentContext()\n\n return { ...getBodyProps(props) }\n },\n)\n\nexport interface ModalFooterProps extends HTMLStyledProps<\"footer\"> {}\n\nexport const ModalFooter = withContext<\"footer\", ModalFooterProps>(\n \"footer\",\n \"footer\",\n)(undefined, (props) => {\n const { getFooterProps } = useComponentContext()\n\n return { ...getFooterProps(props) }\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAuFA,MAAM,EACJ,kBACA,cAAc,mBACd,qBACA,iBAAiB,sBACjB,aACA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A,QAAQ,SAAS;EACrD,aAAa;EACb,eAAgB,YAAY,UAAU,OAAO,IAAI,QAAQ;CAC3D,CAAC;CAED,OACE,iBAAA,GAAA,kBAAA,KAAA,CAAC,cAAD,EAAA,UAAA;EACG,iBACE,cAAc,iBAAA,GAAA,kBAAA,IAAA,CAAC,aAAD,EAAA,UAAc,YAAyB,CAAA,IAAI;EAC3D;EACA,iBACE,gBAAgB,gBAAgB,gBAC/B,iBAAA,GAAA,kBAAA,KAAA,CAAC,aAAD,EAAA,UAAA;GACG;GACA;GACA;EACU,EAAA,CAAA,IACX;CACM,EAAA,CAAA;AAElB;AAIA,MAAa,cAAc,YACzB,UACA,QACF,CAAC,CAAC,KAAA,IAAY,UAAU;CACtB,MAAM,EAAE,mBAAmB,oBAAoB;CAE/C,OAAO,EAAE,GAAG,eAAe,KAAK,EAAE;AACpC,CAAC;AAID,MAAa,aAAa,YAAmC,MAAM,OAAO,CAAC,CACzE,KAAA,IACC,UAAU;CACT,MAAM,EAAE,kBAAkB,oBAAoB;CAE9C,OAAO,EAAE,GAAG,cAAc,KAAK,EAAE;AACnC,CACF;AAIA,MAAa,YAAY,YAAmC,OAAO,MAAM,CAAC,CACxE,KAAA,IACC,UAAU;CACT,MAAM,EAAE,iBAAiB,oBAAoB;CAE7C,OAAO,EAAE,GAAG,aAAa,KAAK,EAAE;AAClC,CACF;AAIA,MAAa,cAAc,YACzB,UACA,QACF,CAAC,CAAC,KAAA,IAAY,UAAU;CACtB,MAAM,EAAE,mBAAmB,oBAAoB;CAE/C,OAAO,EAAE,GAAG,eAAe,KAAK,EAAE;AACpC,CAAC"}
1
+ {"version":3,"file":"modal.cjs","names":["createSlotComponent","modalStyle","useSplitChildren","useModal","AnimatePresence","Portal","FocusLock","RemoveScroll","styled","mergeProps","CloseButton","useValue","motion","fadeVariants","usePopupAnimationProps","wrapOrPassProps","Button"],"sources":["../../../../src/components/modal/modal.tsx"],"sourcesContent":["\"use client\"\n\nimport type { FC, PropsWithChildren, ReactNode } from \"react\"\nimport type { HTMLProps, HTMLStyledProps, ThemeProps } from \"../../core\"\nimport type { ButtonProps } from \"../button\"\nimport type { CloseButtonProps } from \"../close-button\"\nimport type { FocusLockProps } from \"../focus-lock\"\nimport type { HTMLMotionProps, HTMLMotionPropsWithoutAs } from \"../motion\"\nimport type { UsePopupAnimationProps } from \"../popover\"\nimport type { PortalProps } from \"../portal\"\nimport type { ModalStyle } from \"./modal.style\"\nimport type { UseModalProps, UseModalReturn } from \"./use-modal\"\nimport { AnimatePresence } from \"motion/react\"\nimport { useMemo } from \"react\"\nimport { RemoveScroll } from \"react-remove-scroll\"\nimport { createSlotComponent, mergeProps, styled } from \"../../core\"\nimport { useValue } from \"../../hooks/use-value\"\nimport { cast, isArray, useSplitChildren, wrapOrPassProps } from \"../../utils\"\nimport { Button } from \"../button\"\nimport { CloseButton } from \"../close-button\"\nimport { fadeVariants } from \"../fade\"\nimport { FocusLock } from \"../focus-lock\"\nimport { motion } from \"../motion\"\nimport { usePopupAnimationProps } from \"../popover\"\nimport { Portal } from \"../portal\"\nimport { modalStyle } from \"./modal.style\"\nimport { useModal } from \"./use-modal\"\n\ninterface ComponentContext\n extends\n Omit<UseModalReturn, \"getRootProps\">,\n UsePopupAnimationProps,\n Pick<\n ModalRootProps,\n | \"bodyProps\"\n | \"closeButtonProps\"\n | \"closeTriggerProps\"\n | \"contentProps\"\n | \"footerProps\"\n | \"headerProps\"\n | \"openTriggerProps\"\n | \"overlayProps\"\n | \"titleProps\"\n | \"withCloseButton\"\n > {}\n\nexport interface ModalRootProps\n extends\n Omit<HTMLStyledProps<\"div\">, \"scrollBehavior\" | \"title\">,\n ThemeProps<ModalStyle>,\n Omit<UseModalProps, \"title\">,\n Pick<\n FocusLockProps,\n | \"autoFocus\"\n | \"finalFocusRef\"\n | \"initialFocusRef\"\n | \"lockFocusAcrossFrames\"\n | \"restoreFocus\"\n >,\n UsePopupAnimationProps,\n ShorthandModalContentProps {\n /**\n * Handle zoom or pinch gestures on iOS devices when scroll locking is enabled.\n *\n * @default false.\n */\n allowPinchZoom?: boolean\n /**\n * If `true`, scrolling will be disabled on the `body` when the modal opens.\n *\n * @default true\n */\n blockScrollOnMount?: boolean\n /**\n * The modal trigger to use.\n */\n trigger?: ReactNode\n /**\n * If `true`, display the modal close button.\n *\n * @default true\n */\n withCloseButton?: boolean\n /**\n * If `true`, display the modal overlay.\n *\n * @default true\n */\n withOverlay?: boolean\n /**\n * Props for body element.\n */\n bodyProps?: Omit<ModalBodyProps, \"children\">\n /**\n * Props for close button element.\n */\n closeButtonProps?: Omit<ModalCloseButtonProps, \"children\">\n /**\n * Props for close trigger element.\n */\n closeTriggerProps?: Omit<ModalCloseTriggerProps, \"asChild\" | \"children\">\n /**\n * Props for content element.\n */\n contentProps?: Omit<ModalContentProps, \"children\">\n /**\n * Props for footer element.\n */\n footerProps?: Omit<ModalFooterProps, \"children\">\n /**\n * Props for header element.\n */\n headerProps?: Omit<ModalHeaderProps, \"children\">\n /**\n * Props for open trigger element.\n */\n openTriggerProps?: Omit<ModalOpenTriggerProps, \"asChild\" | \"children\">\n /**\n * Props for overlay element.\n */\n overlayProps?: Omit<ModalOverlayProps, \"children\">\n /**\n * Props to be forwarded to the portal component.\n */\n portalProps?: Omit<PortalProps, \"children\">\n /**\n * Props for title element.\n */\n titleProps?: Omit<ModalTitleProps, \"children\">\n /**\n * Callback function to run side effects after the modal has closed.\n */\n onCloseComplete?: () => void\n}\n\nconst {\n ComponentContext,\n PropsContext: ModalPropsContext,\n useComponentContext,\n usePropsContext: useModalPropsContext,\n withContext,\n withProvider,\n} = createSlotComponent<ModalRootProps, ModalStyle, ComponentContext>(\n \"modal\",\n modalStyle,\n)\n\nexport { ModalPropsContext, useModalPropsContext }\n\n/**\n * `Modal` is a component that is displayed over the main content to focus the user's attention solely on the information.\n *\n * @see https://yamada-ui.com/docs/components/modal\n */\nexport const ModalRoot = withProvider<\"div\", ModalRootProps>(\n ({\n allowPinchZoom = false,\n animationScheme = \"scale\",\n autoFocus,\n blockScrollOnMount = true,\n body,\n cancel,\n children,\n duration,\n finalFocusRef,\n footer,\n header,\n initialFocusRef,\n lockFocusAcrossFrames = true,\n middle,\n restoreFocus,\n success,\n title,\n trigger,\n withCloseButton = true,\n withOverlay = true,\n bodyProps,\n closeButtonProps,\n closeTriggerProps,\n contentProps,\n footerProps,\n headerProps,\n openTriggerProps,\n overlayProps,\n portalProps,\n titleProps,\n onCancel,\n onCloseComplete,\n onMiddle,\n onSuccess,\n ...props\n }) => {\n const [omittedChildren, openTrigger, customOverlay] = useSplitChildren(\n children,\n ModalOpenTrigger,\n ModalOverlay,\n )\n const hasChildren = isArray(omittedChildren) && !!omittedChildren.length\n const { open, getRootProps, ...rest } = useModal(props)\n const customOpenTrigger = trigger ? (\n <ModalOpenTrigger>{trigger}</ModalOpenTrigger>\n ) : null\n const context = useMemo(\n () => ({\n animationScheme,\n duration,\n open,\n withCloseButton,\n bodyProps,\n closeButtonProps,\n closeTriggerProps,\n contentProps,\n footerProps,\n headerProps,\n openTriggerProps,\n overlayProps,\n titleProps,\n ...rest,\n }),\n [\n animationScheme,\n duration,\n open,\n withCloseButton,\n contentProps,\n bodyProps,\n footerProps,\n headerProps,\n titleProps,\n openTriggerProps,\n closeTriggerProps,\n closeButtonProps,\n overlayProps,\n rest,\n ],\n )\n\n return (\n <ComponentContext value={context}>\n {openTrigger ?? customOpenTrigger}\n\n <AnimatePresence onExitComplete={onCloseComplete}>\n {open ? (\n <Portal {...portalProps}>\n <FocusLock\n autoFocus={autoFocus}\n finalFocusRef={finalFocusRef}\n initialFocusRef={initialFocusRef}\n lockFocusAcrossFrames={lockFocusAcrossFrames}\n restoreFocus={restoreFocus}\n >\n <RemoveScroll\n allowPinchZoom={allowPinchZoom}\n enabled={blockScrollOnMount}\n forwardProps\n >\n <styled.div {...getRootProps()}>\n {customOverlay ?? (withOverlay ? <ModalOverlay /> : null)}\n\n {hasChildren ? (\n omittedChildren\n ) : (\n <ShorthandModalContent\n body={body}\n cancel={cancel}\n footer={footer}\n header={header}\n middle={middle}\n success={success}\n title={title}\n onCancel={onCancel}\n onMiddle={onMiddle}\n onSuccess={onSuccess}\n />\n )}\n </styled.div>\n </RemoveScroll>\n </FocusLock>\n </Portal>\n ) : null}\n </AnimatePresence>\n </ComponentContext>\n )\n },\n \"root\",\n)()\n\nexport interface ModalOpenTriggerProps extends HTMLStyledProps<\"button\"> {}\n\nexport const ModalOpenTrigger = withContext<\"button\", ModalOpenTriggerProps>(\n \"button\",\n { name: \"OpenTrigger\", slot: [\"trigger\", \"open\"] },\n)(undefined, (props) => {\n const { getOpenTriggerProps, openTriggerProps } = useComponentContext()\n\n return {\n asChild: true,\n ...getOpenTriggerProps(mergeProps(openTriggerProps, props)()),\n }\n})\n\nexport interface ModalCloseTriggerProps extends HTMLStyledProps<\"button\"> {}\n\nexport const ModalCloseTrigger = withContext<\"button\", ModalCloseTriggerProps>(\n \"button\",\n { name: \"CloseTrigger\", slot: [\"trigger\", \"close\"] },\n)(undefined, (props) => {\n const { closeTriggerProps, getCloseTriggerProps } = useComponentContext()\n\n return {\n asChild: true,\n ...getCloseTriggerProps(mergeProps(closeTriggerProps, props)()),\n }\n})\n\nexport interface ModalCloseButtonProps extends CloseButtonProps {}\n\nexport const ModalCloseButton = withContext<\"button\", ModalCloseButtonProps>(\n CloseButton,\n \"closeButton\",\n)(undefined, (props) => {\n const { closeButtonProps, getCloseButtonProps } = useComponentContext()\n\n return { ...getCloseButtonProps(mergeProps(closeButtonProps, props)()) }\n})\n\nexport interface ModalOverlayProps extends HTMLMotionProps {}\n\nexport const ModalOverlay = withContext<\"div\", ModalOverlayProps>((props) => {\n const {\n animationScheme,\n duration: durationProp,\n getOverlayProps,\n overlayProps,\n } = useComponentContext()\n const duration = useValue(durationProp)\n\n return (\n <motion.div\n custom={{ duration }}\n {...(animationScheme !== \"none\"\n ? {\n animate: \"enter\",\n exit: \"exit\",\n initial: \"exit\",\n variants: fadeVariants,\n }\n : {})}\n {...cast<HTMLMotionProps>(\n getOverlayProps(cast<HTMLProps>(mergeProps(overlayProps, props)())),\n )}\n />\n )\n}, \"overlay\")()\n\nexport interface ModalContentProps\n extends Omit<HTMLMotionProps<\"section\">, \"children\">, PropsWithChildren {}\n\nexport const ModalContent = withContext<\"section\", ModalContentProps>(\n ({ children, ...rest }) => {\n const {\n animationScheme,\n duration,\n withCloseButton,\n contentProps,\n getContentProps,\n } = useComponentContext()\n const [omittedChildren, customCloseButton] = useSplitChildren(\n children,\n ModalCloseButton,\n )\n const popupAnimationProps = usePopupAnimationProps({\n animationScheme,\n duration,\n })\n\n return (\n <motion.section\n {...popupAnimationProps}\n {...cast<HTMLMotionPropsWithoutAs<\"section\">>(\n getContentProps(\n cast<HTMLProps<\"section\">>(mergeProps(contentProps, rest)()),\n ),\n )}\n >\n {customCloseButton ?? (withCloseButton ? <ModalCloseButton /> : null)}\n\n {omittedChildren}\n </motion.section>\n )\n },\n \"content\",\n)()\n\ninterface ShorthandModalContentProps {\n /**\n * The modal body to use.\n */\n body?: ModalBodyProps | ReactNode\n /**\n * The modal cancel button to use.\n */\n cancel?: ButtonProps | ReactNode\n /**\n * The modal footer to use.\n */\n footer?: ModalFooterProps | ReactNode\n /**\n * The modal header to use.\n */\n header?: ModalHeaderProps | ReactNode\n /**\n * The modal middle button to use.\n */\n middle?: ButtonProps | ReactNode\n /**\n * The modal success button to use.\n */\n success?: ButtonProps | ReactNode\n /**\n * The modal title to use.\n */\n title?: ModalTitleProps | ReactNode\n /**\n * The callback invoked when cancel button clicked.\n */\n onCancel?: (onClose: () => void) => void\n /**\n * The callback invoked when middle button clicked.\n */\n onMiddle?: (onClose: () => void) => void\n /**\n * The callback invoked when success button clicked.\n */\n onSuccess?: (onClose: () => void) => void\n}\n\nconst ShorthandModalContent: FC<ShorthandModalContentProps> = ({\n body,\n cancel,\n footer,\n header,\n middle,\n success,\n title,\n onCancel,\n onMiddle,\n onSuccess,\n}) => {\n const { onClose } = useComponentContext()\n const customHeader = wrapOrPassProps(ModalHeader, header)\n const customTitle = wrapOrPassProps(ModalTitle, title)\n const customBody = wrapOrPassProps(ModalBody, body)\n const customFooter = wrapOrPassProps(ModalFooter, footer)\n const customCancel = wrapOrPassProps(Button, cancel, {\n colorScheme: \"mono\",\n variant: \"ghost\",\n onClick: () => (onCancel ? onCancel(onClose) : onClose()),\n })\n const customMiddle = wrapOrPassProps(Button, middle, {\n colorScheme: \"secondary\",\n onClick: () => (onMiddle ? onMiddle(onClose) : onClose()),\n })\n const customSuccess = wrapOrPassProps(Button, success, {\n colorScheme: \"primary\",\n onClick: () => (onSuccess ? onSuccess(onClose) : onClose()),\n })\n\n return (\n <ModalContent>\n {customHeader ??\n (customTitle ? <ModalHeader>{customTitle}</ModalHeader> : null)}\n {customBody}\n {customFooter ??\n (customCancel || customMiddle || customSuccess ? (\n <ModalFooter>\n {customCancel}\n {customMiddle}\n {customSuccess}\n </ModalFooter>\n ) : null)}\n </ModalContent>\n )\n}\n\nexport interface ModalHeaderProps extends HTMLStyledProps<\"header\"> {}\n\nexport const ModalHeader = withContext<\"header\", ModalHeaderProps>(\n \"header\",\n \"header\",\n)(undefined, (props) => {\n const { getHeaderProps, headerProps } = useComponentContext()\n\n return { ...getHeaderProps(mergeProps(headerProps, props)()) }\n})\n\nexport interface ModalTitleProps extends HTMLStyledProps<\"h2\"> {}\n\nexport const ModalTitle = withContext<\"h2\", ModalTitleProps>(\"h2\", \"title\")(\n undefined,\n (props) => {\n const { getTitleProps, titleProps } = useComponentContext()\n\n return { ...getTitleProps(mergeProps(titleProps, props)()) }\n },\n)\n\nexport interface ModalBodyProps extends HTMLStyledProps {}\n\nexport const ModalBody = withContext<\"div\", ModalBodyProps>(\"div\", \"body\")(\n undefined,\n (props) => {\n const { bodyProps, getBodyProps } = useComponentContext()\n\n return { ...getBodyProps(mergeProps(bodyProps, props)()) }\n },\n)\n\nexport interface ModalFooterProps extends HTMLStyledProps<\"footer\"> {}\n\nexport const ModalFooter = withContext<\"footer\", ModalFooterProps>(\n \"footer\",\n \"footer\",\n)(undefined, (props) => {\n const { footerProps, getFooterProps } = useComponentContext()\n\n return { ...getFooterProps(mergeProps(footerProps, props)()) }\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAuIA,MAAM,EACJ,kBACA,cAAc,mBACd,qBACA,iBAAiB,sBACjB,aACA,iBACEA,yBAAAA,oBACF,SACAC,oBAAAA,UACF;;;;;;AASA,MAAa,YAAY,cACtB,EACC,iBAAiB,OACjB,kBAAkB,SAClB,WACA,qBAAqB,MACrB,MACA,QACA,UACA,UACA,eACA,QACA,QACA,iBACA,wBAAwB,MACxB,QACA,cACA,SACA,OACA,SACA,kBAAkB,MAClB,cAAc,MACd,WACA,kBACA,mBACA,cACA,aACA,aACA,kBACA,cACA,aACA,YACA,UACA,iBACA,UACA,WACA,GAAG,YACC;CACJ,MAAM,CAAC,iBAAiB,aAAa,iBAAiBC,iBAAAA,iBACpD,UACA,kBACA,YACF;CACA,MAAM,eAAA,GAAA,oBAAA,cAAA,QAAA,CAAsB,eAAe,KAAK,CAAC,CAAC,gBAAgB;CAClE,MAAM,EAAE,MAAM,cAAc,GAAG,SAASC,kBAAAA,SAAS,KAAK;CACtD,MAAM,oBAAoB,UACxB,iBAAA,GAAA,kBAAA,IAAA,CAAC,kBAAD,EAAA,UAAmB,QAA0B,CAAA,IAC3C;CACJ,MAAM,WAAA,GAAA,MAAA,QAAA,QACG;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,GAAG;CACL,IACA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CACF;CAEA,OACE,iBAAA,GAAA,kBAAA,KAAA,CAAC,kBAAD;EAAkB,OAAO;EAAzB,UAAA,CACG,eAAe,mBAEhB,iBAAA,GAAA,kBAAA,IAAA,CAACC,aAAAA,iBAAD;GAAiB,gBAAgB;GAC9B,UAAA,OACC,iBAAA,GAAA,kB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,oBAAoB;CAE1D,OAAO,EAAE,GAAG,cAAcA,cAAAA,WAAW,YAAY,KAAK,CAAC,CAAC,CAAC,EAAE;AAC7D,CACF;AAIA,MAAa,YAAY,YAAmC,OAAO,MAAM,CAAC,CACxE,KAAA,IACC,UAAU;CACT,MAAM,EAAE,WAAW,iBAAiB,oBAAoB;CAExD,OAAO,EAAE,GAAG,aAAaA,cAAAA,WAAW,WAAW,KAAK,CAAC,CAAC,CAAC,EAAE;AAC3D,CACF;AAIA,MAAa,cAAc,YACzB,UACA,QACF,CAAC,CAAC,KAAA,IAAY,UAAU;CACtB,MAAM,EAAE,aAAa,mBAAmB,oBAAoB;CAE5D,OAAO,EAAE,GAAG,eAAeA,cAAAA,WAAW,aAAa,KAAK,CAAC,CAAC,CAAC,EAAE;AAC/D,CAAC"}
@@ -26,7 +26,8 @@ const useFocusOnShow = (refOrEl, { focusTarget: focusRefOrEl, preventScroll, sho
26
26
  const onFocus = (0, react.useCallback)(() => {
27
27
  const target = getTarget();
28
28
  if (!target || !trulyShouldFocus || focused.current) return;
29
- if (target.contains(document.activeElement)) return;
29
+ const rootNode = target.getRootNode();
30
+ if ((0, require_utils_index.utils_exports.contains)(target, (0, require_utils_index.utils_exports.getActiveElement)((0, require_utils_index.utils_exports.isShadowRoot)(rootNode) ? rootNode : (0, require_utils_index.utils_exports.getDocument)(target)))) return;
30
31
  const focusTarget = getFocusTarget();
31
32
  if (focusTarget) requestAnimationFrame(() => {
32
33
  focusTarget.focus({ preventScroll });
@@ -63,14 +64,17 @@ const useFocusOnShow = (refOrEl, { focusTarget: focusRefOrEl, preventScroll, sho
63
64
  * @see https://yamada-ui.com/docs/hooks/use-focus-on-pointer-down
64
65
  */
65
66
  const useFocusOnPointerDown = ({ ref, elements, enabled }) => {
66
- require_hooks_use_event_listener_index.useEventListener(() => (0, require_utils_index.utils_exports.getDocument)(ref.current), "pointerdown", (ev) => {
67
+ require_hooks_use_event_listener_index.useEventListener(() => ref.current?.getRootNode() ?? (0, require_utils_index.utils_exports.getDocument)(ref.current), "pointerdown", (ev) => {
67
68
  if (!(0, require_utils_index.utils_exports.isSafari)() || !enabled) return;
68
69
  const target = ev.target;
69
- const validTarget = (elements ?? [ref]).some((elOrRef) => {
70
+ const els = elements ?? [ref];
71
+ const rootNode = ref.current?.getRootNode();
72
+ const root = (0, require_utils_index.utils_exports.isShadowRoot)(rootNode) ? rootNode : (0, require_utils_index.utils_exports.getDocument)(ref.current);
73
+ const validTarget = els.some((elOrRef) => {
70
74
  const el = require_ref.isRefObject(elOrRef) ? elOrRef.current : elOrRef;
71
75
  return el?.contains(target) || el === target;
72
76
  });
73
- if ((0, require_utils_index.utils_exports.getActiveElement)((0, require_utils_index.utils_exports.getDocument)(ref.current)) !== target && validTarget) {
77
+ if ((0, require_utils_index.utils_exports.getActiveElement)(root) !== target && validTarget) {
74
78
  ev.preventDefault();
75
79
  target.focus();
76
80
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["isRefObject"],"sources":["../../../../src/hooks/use-focus/index.ts"],"sourcesContent":["\"use client\"\n\nimport type { RefObject } from \"react\"\nimport { useCallback, useRef } from \"react\"\nimport {\n getActiveElement,\n getDocument,\n getFirstFocusableElement,\n isRefObject,\n isSafari,\n useUpdateEffect,\n} from \"../../utils\"\nimport { useEventListener } from \"../use-event-listener\"\n\nexport interface UseFocusOnShowProps {\n focusTarget?: HTMLElement | null | RefObject<HTMLElement | null>\n preventScroll?: boolean\n shouldFocus?: boolean\n visible?: boolean\n}\n\n/**\n * `useFocusOnShow` is a custom hook that focuses on the target element when it is shown.\n *\n * @see https://yamada-ui.com/docs/hooks/use-focus-on-show\n */\nexport const useFocusOnShow = <Y extends HTMLElement>(\n refOrEl: RefObject<null | Y> | Y,\n {\n focusTarget: focusRefOrEl,\n preventScroll,\n shouldFocus,\n visible,\n }: UseFocusOnShowProps = {\n preventScroll: true,\n shouldFocus: false,\n },\n) => {\n const trulyShouldFocus = shouldFocus && visible\n const focused = useRef(false)\n\n const getTarget = useCallback(() => {\n return isRefObject(refOrEl) ? refOrEl.current : refOrEl\n }, [refOrEl])\n\n const getFocusTarget = useCallback(() => {\n return isRefObject(focusRefOrEl) ? focusRefOrEl.current : focusRefOrEl\n }, [focusRefOrEl])\n\n const onFocus = useCallback(() => {\n const target = getTarget()\n\n if (!target || !trulyShouldFocus || focused.current) return\n if (target.contains(document.activeElement)) return\n\n const focusTarget = getFocusTarget()\n\n if (focusTarget) {\n requestAnimationFrame(() => {\n focusTarget.focus({ preventScroll })\n\n focused.current = true\n })\n } else {\n const firstFocusable = getFirstFocusableElement(target)\n\n if (firstFocusable)\n requestAnimationFrame(() => {\n firstFocusable.focus({ preventScroll })\n\n focused.current = true\n })\n else\n requestAnimationFrame(() => {\n target.focus({ preventScroll })\n\n focused.current = true\n })\n }\n }, [getTarget, trulyShouldFocus, getFocusTarget, preventScroll])\n\n useUpdateEffect(() => {\n focused.current = !trulyShouldFocus\n }, [trulyShouldFocus])\n\n useUpdateEffect(() => {\n requestAnimationFrame(onFocus)\n }, [onFocus])\n\n useEventListener(getTarget, \"transitionend\", onFocus)\n}\n\nexport interface UseFocusOnMouseDownProps {\n ref: RefObject<HTMLElement | null>\n elements?: (HTMLElement | null | RefObject<HTMLElement | null>)[]\n enabled?: boolean\n}\n\n/**\n * `useFocusOnPointerDown` is a custom hook that focuses on the target element when it is clicked.\n *\n * @see https://yamada-ui.com/docs/hooks/use-focus-on-pointer-down\n */\nexport const useFocusOnPointerDown = ({\n ref,\n elements,\n enabled,\n}: UseFocusOnMouseDownProps) => {\n useEventListener(\n () => getDocument(ref.current),\n \"pointerdown\",\n (ev) => {\n if (!isSafari() || !enabled) return\n const target = ev.target as HTMLElement\n\n const els = elements ?? [ref]\n\n const validTarget = els.some((elOrRef) => {\n const el = isRefObject(elOrRef) ? elOrRef.current : elOrRef\n\n return el?.contains(target) || el === target\n })\n\n if (\n getActiveElement(getDocument(ref.current)) !== target &&\n validTarget\n ) {\n ev.preventDefault()\n\n target.foc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AAO;AACtD;;;;;;AAaA,MAAa,yBAAyB,EACpC,KACA,UACA,cAC8B;CAC9B,uCAAA,wBAAA,GAAA,oBAAA,cAAA,YAAA,CACoB,IAAI,OAAO,GAC7B,gBACC,OAAO;EACN,IAAI,EAAA,GAAA,oBAAA,cAAA,SAAA,CAAU,KAAK,CAAC,SAAS;EAC7B,MAAM,SAAS,GAAG;EAIlB,MAAM,eAFM,YAAY,CAAC,GAAG,EAAA,CAEJ,MAAM,YAAY;GACxC,MAAM,KAAKA,YAAAA,YAAY,OAAO,IAAI,QAAQ,UAAU;GAEpD,OAAO,IAAI,SAAS,MAAM,KAAK,OAAO;EACxC,CAAC;EAED,KAAA,GAAA,oBAAA,cAAA,iBAAA,EAAA,GAAA,oBAAA,cAAA,YAAA,CAC+B,IAAI,OAAO,CAAC,MAAM,UAC/C,aACA;GACA,GAAG,eAAe;GAElB,OAAO,MAAM;EACf;CACF,CACF;AACF"}
1
+ {"version":3,"file":"index.cjs","names":["isRefObject"],"sources":["../../../../src/hooks/use-focus/index.ts"],"sourcesContent":["\"use client\"\n\nimport type { RefObject } from \"react\"\nimport { useCallback, useRef } from \"react\"\nimport {\n contains,\n getActiveElement,\n getDocument,\n getFirstFocusableElement,\n isRefObject,\n isSafari,\n isShadowRoot,\n useUpdateEffect,\n} from \"../../utils\"\nimport { useEventListener } from \"../use-event-listener\"\n\nexport interface UseFocusOnShowProps {\n focusTarget?: HTMLElement | null | RefObject<HTMLElement | null>\n preventScroll?: boolean\n shouldFocus?: boolean\n visible?: boolean\n}\n\n/**\n * `useFocusOnShow` is a custom hook that focuses on the target element when it is shown.\n *\n * @see https://yamada-ui.com/docs/hooks/use-focus-on-show\n */\nexport const useFocusOnShow = <Y extends HTMLElement>(\n refOrEl: RefObject<null | Y> | Y,\n {\n focusTarget: focusRefOrEl,\n preventScroll,\n shouldFocus,\n visible,\n }: UseFocusOnShowProps = {\n preventScroll: true,\n shouldFocus: false,\n },\n) => {\n const trulyShouldFocus = shouldFocus && visible\n const focused = useRef(false)\n\n const getTarget = useCallback(() => {\n return isRefObject(refOrEl) ? refOrEl.current : refOrEl\n }, [refOrEl])\n\n const getFocusTarget = useCallback(() => {\n return isRefObject(focusRefOrEl) ? focusRefOrEl.current : focusRefOrEl\n }, [focusRefOrEl])\n\n const onFocus = useCallback(() => {\n const target = getTarget()\n\n if (!target || !trulyShouldFocus || focused.current) return\n const rootNode = target.getRootNode()\n const root = isShadowRoot(rootNode) ? rootNode : getDocument(target)\n if (contains(target, getActiveElement(root))) return\n\n const focusTarget = getFocusTarget()\n\n if (focusTarget) {\n requestAnimationFrame(() => {\n focusTarget.focus({ preventScroll })\n\n focused.current = true\n })\n } else {\n const firstFocusable = getFirstFocusableElement(target)\n\n if (firstFocusable)\n requestAnimationFrame(() => {\n firstFocusable.focus({ preventScroll })\n\n focused.current = true\n })\n else\n requestAnimationFrame(() => {\n target.focus({ preventScroll })\n\n focused.current = true\n })\n }\n }, [getTarget, trulyShouldFocus, getFocusTarget, preventScroll])\n\n useUpdateEffect(() => {\n focused.current = !trulyShouldFocus\n }, [trulyShouldFocus])\n\n useUpdateEffect(() => {\n requestAnimationFrame(onFocus)\n }, [onFocus])\n\n useEventListener(getTarget, \"transitionend\", onFocus)\n}\n\nexport interface UseFocusOnMouseDownProps {\n ref: RefObject<HTMLElement | null>\n elements?: (HTMLElement | null | RefObject<HTMLElement | null>)[]\n enabled?: boolean\n}\n\n/**\n * `useFocusOnPointerDown` is a custom hook that focuses on the target element when it is clicked.\n *\n * @see https://yamada-ui.com/docs/hooks/use-focus-on-pointer-down\n */\nexport const useFocusOnPointerDown = ({\n ref,\n elements,\n enabled,\n}: UseFocusOnMouseDownProps) => {\n useEventListener(\n () => ref.current?.getRootNode() ?? getDocument(ref.current),\n \"pointerdown\",\n (ev) => {\n if (!isSafari() || !enabled) return\n\n const target = ev.target as HTMLElement\n const els = elements ?? [ref]\n const rootNode = ref.current?.getRootNode()\n const root = isShadowRoot(rootNode) ? rootNode : getDocument(ref.current)\n const validTarget = els.some((elOrRef) => {\n const el = isRefObject(elOrRef) ? elOrRef.current : elOrRef\n\n return el?.contains(target) || el === target\n })\n\n if (getActiveElement(root) !== target && validTarget) {\n ev.preventDefault()\n\n target.focus()\n }\n },\n )\n}\n"],"mappings":";;;;;;;;;;;;;AA4BA,MAAa,kBACX,SACA,EACE,aAAa,cACb,eACA,aACA,YACuB;CACvB,eAAe;CACf,aAAa;AACf,MACG;CACH,MAAM,mBAAmB,eAAe;CACxC,MAAM,WAAA,GAAA,MAAA,OAAA,CAAiB,KAAK;CAE5B,MAAM,aAAA,GAAA,MAAA,YAAA,OAA8B;EAClC,OAAOA,YAAAA,YAAY,OAAO,IAAI,QAAQ,UAAU;CAClD,GAAG,CAAC,OAAO,CAAC;CAEZ,MAAM,kBAAA,GAAA,MAAA,YAAA,OAAmC;EACvC,OAAOA,YAAAA,YAAY,YAAY,IAAI,aAAa,UAAU;CAC5D,GAAG,CAAC,YAAY,CAAC;CAEjB,MAAM,WAAA,GAAA,MAAA,YAAA,OAA4B;EAChC,MAAM,SAAS,UAAU;EAEzB,IAAI,CAAC,UAAU,CAAC,oBAAoB,QAAQ,SAAS;EACrD,MAAM,WAAW,OAAO,YAAY;EAEpC,KAAA,GAAA,oBAAA,cAAA,SAAA,CAAa,SAAA,GAAA,oBAAA,cAAA,iBAAA,EAAA,GAAA,oBAAA,cAAA,aAAA,CADa,QAAQ,IAAI,YAAA,GAAA,oBAAA,cAAA,YAAA,CAAuB,MAAM,CACzB,CAAC,GAAG;EAE9C,MAAM,cAAc,eAAe;EAEnC,IAAI,aACF,4BAA4B;GAC1B,YAAY,MAAM,EAAE,cAAc,CAAC;GAEnC,QAAQ,UAAU;EACpB,CAAC;OACI;GACL,MAAM,kBAAA,GAAA,oBAAA,cAAA,yBAAA,CAA0C,MAAM;GAEtD,IAAI,gBACF,4BAA4B;IAC1B,eAAe,MAAM,EAAE,cAAc,CAAC;IAEtC,QAAQ,UAAU;GACpB,CAAC;QAED,4BAA4B;IAC1B,OAAO,MAAM,EAAE,cAAc,CAAC;IAE9B,QAAQ,UAAU;GACpB,CAAC;EACL;CACF,GAAG;EAAC;EAAW;EAAkB;EAAgB;CAAa,CAAC;CAE/D,eAAA,sBAAsB;EACpB,QAAQ,UAAU,CAAC;CACrB,GAAG,CAAC,gBAAgB,CAAC;CAErB,eAAA,sBAAsB;EACpB,sBAAsB,OAAO;CAC/B,GAAG,CAAC,OAAO,CAAC;CAEZ,uCAAA,iBAAiB,WAAW,iBAAiB,OAAO;AACtD;;;;;;AAaA,MAAa,yBAAyB,EACpC,KACA,UACA,cAC8B;CAC9B,uCAAA,uBACQ,IAAI,SAAS,YAAY,MAAA,GAAA,oBAAA,cAAA,YAAA,CAAiB,IAAI,OAAO,GAC3D,gBACC,OAAO;EACN,IAAI,EAAA,GAAA,oBAAA,cAAA,SAAA,CAAU,KAAK,CAAC,SAAS;EAE7B,MAAM,SAAS,GAAG;EAClB,MAAM,MAAM,YAAY,CAAC,GAAG;EAC5B,MAAM,WAAW,IAAI,SAAS,YAAY;EAC1C,MAAM,QAAA,GAAA,oBAAA,cAAA,aAAA,CAAoB,QAAQ,IAAI,YAAA,GAAA,oBAAA,cAAA,YAAA,CAAuB,IAAI,OAAO;EACxE,MAAM,cAAc,IAAI,MAAM,YAAY;GACxC,MAAM,KAAKA,YAAAA,YAAY,OAAO,IAAI,QAAQ,UAAU;GAEpD,OAAO,IAAI,SAAS,MAAM,KAAK,OAAO;EACxC,CAAC;EAED,KAAA,GAAA,oBAAA,cAAA,iBAAA,CAAqB,IAAI,MAAM,UAAU,aAAa;GACpD,GAAG,eAAe;GAElB,OAAO,MAAM;EACf;CACF,CACF;AACF"}
@@ -1,6 +1,7 @@
1
1
  const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
2
2
  let react = require("react");
3
3
  react = require_runtime.__toESM(react, 1);
4
+ let _yamada_ui_utils = require("@yamada-ui/utils");
4
5
  //#region src/utils/dom.ts
5
6
  function runKeyAction(ev, actions, { preventDefault = true } = {}) {
6
7
  if (ev.key === " ") ev.key = ev.code;
@@ -32,7 +33,9 @@ function useAttributeObserver(ref, attributeFilter, enabled, func) {
32
33
  });
33
34
  }
34
35
  function getEventRelatedTarget(ev) {
35
- return ev.relatedTarget ?? ev.currentTarget.ownerDocument.activeElement;
36
+ if (ev.relatedTarget) return ev.relatedTarget;
37
+ const root = ev.currentTarget.getRootNode?.call(ev.currentTarget);
38
+ return (root && (0, _yamada_ui_utils.getActiveElement)(root)) ?? ev.currentTarget.ownerDocument.activeElement;
36
39
  }
37
40
  const visuallyHiddenAttributes = {
38
41
  style: {
@@ -1 +1 @@
1
- {"version":3,"file":"dom.cjs","names":["React"],"sources":["../../../src/utils/dom.ts"],"sourcesContent":["import type { AnyString } from \"@yamada-ui/utils\"\nimport * as React from \"react\"\n\ntype KeyboardNavigationKey =\n | \"ArrowDown\"\n | \"ArrowLeft\"\n | \"ArrowRight\"\n | \"ArrowUp\"\n | \"End\"\n | \"Home\"\n | \"PageDown\"\n | \"PageUp\"\n\ntype KeyboardControlKey =\n | \"Alt\"\n | \"Backspace\"\n | \"CapsLock\"\n | \"Control\"\n | \"Delete\"\n | \"Enter\"\n | \"Escape\"\n | \"Insert\"\n | \"Meta\"\n | \"NumLock\"\n | \"Pause\"\n | \"PrintScreen\"\n | \"ScrollLock\"\n | \"Shift\"\n | \"Space\"\n | \"Tab\"\n\ntype KeyboardFunctionKey = \"Fn\" | \"FnLock\" | `F${number}`\n\ntype KeyboardKey =\n | AnyString\n | KeyboardControlKey\n | KeyboardFunctionKey\n | KeyboardNavigationKey\n\nexport function runKeyAction<Y>(\n ev: React.KeyboardEvent<Y>,\n actions: { [key in KeyboardKey]?: React.KeyboardEventHandler<Y> },\n { preventDefault = true }: { preventDefault?: boolean } = {},\n) {\n if (ev.key === \" \") ev.key = ev.code\n const action = actions[ev.key]\n\n if (!action) return\n\n if (preventDefault) ev.preventDefault()\n\n action(ev)\n}\n\nexport function isComposing(\n ev: React.ChangeEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>,\n): boolean {\n if (\"keyCode\" in ev) return ev.nativeEvent.isComposing || ev.keyCode === 229\n else if (ev.nativeEvent instanceof InputEvent)\n return ev.nativeEvent.isComposing\n else return false\n}\n\nexport function useAttributeObserver(\n ref: React.RefObject<HTMLElement | null>,\n attributeFilter: string[],\n enabled: boolean,\n func: () => void,\n) {\n React.useEffect(() => {\n if (!ref.current || !enabled) return\n\n const ownerDocument = ref.current.ownerDocument.defaultView ?? window\n\n const observer = new ownerDocument.MutationObserver((changes) => {\n for (const { type, attributeName } of changes) {\n if (type !== \"attributes\") continue\n if (!attributeName) continue\n\n if (attributeFilter.includes(attributeName)) func()\n }\n })\n\n observer.observe(ref.current, { attributeFilter, attributes: true })\n\n return () => observer.disconnect()\n })\n}\n\nexport function getEventRelatedTarget(ev: React.FocusEvent | React.MouseEvent) {\n return (ev.relatedTarget ??\n ev.currentTarget.ownerDocument.activeElement) as HTMLElement | null\n}\n\nconst visuallyHiddenStyle = {\n border: \"0px\",\n clipPath: \"rect(0px 0px 0px 0px)\",\n height: \"1px\",\n margin: \"-1px\",\n overflow: \"hidden\",\n padding: \"0px\",\n position: \"absolute\",\n whiteSpace: \"nowrap\",\n width: \"1px\",\n} satisfies React.CSSProperties\n\nexport const visuallyHiddenAttributes = {\n style: visuallyHiddenStyle,\n \"aria-hidden\": true,\n tabIndex: -1,\n} satisfies React.HTMLAttributes<HTMLElement>\n\nexport function* useIds() {\n const id = React.useId()\n\n for (let i = 0; ; i++) yield `${id}-${i}`\n}\n"],"mappings":";;;;AAuCA,SAAgB,aACd,IACA,SACA,EAAE,iBAAiB,SAAuC,CAAC,GAC3D;CACA,IAAI,GAAG,QAAQ,KAAK,GAAG,MAAM,GAAG;CAChC,MAAM,SAAS,QAAQ,GAAG;CAE1B,IAAI,CAAC,QAAQ;CAEb,IAAI,gBAAgB,GAAG,eAAe;CAEtC,OAAO,EAAE;AACX;AAEA,SAAgB,YACd,IACS;CACT,IAAI,aAAa,IAAI,OAAO,GAAG,YAAY,eAAe,GAAG,YAAY;MACpE,IAAI,GAAG,uBAAuB,YACjC,OAAO,GAAG,YAAY;MACnB,OAAO;AACd;AAEA,SAAgB,qBACd,KACA,iBACA,SACA,MACA;CACA,MAAM,gBAAgB;EACpB,IAAI,CAAC,IAAI,WAAW,CAAC,SAAS;EAI9B,MAAM,WAAW,KAFK,IAAI,QAAQ,cAAc,eAAe,OAAA,CAE5B,kBAAkB,YAAY;GAC/D,KAAK,MAAM,EAAE,MAAM,mBAAmB,SAAS;IAC7C,IAAI,SAAS,cAAc;IAC3B,IAAI,CAAC,eAAe;IAEpB,IAAI,gBAAgB,SAAS,aAAa,GAAG,KAAK;GACpD;EACF,CAAC;EAED,SAAS,QAAQ,IAAI,SAAS;GAAE;GAAiB,YAAY;EAAK,CAAC;EAEnE,aAAa,SAAS,WAAW;CACnC,CAAC;AACH;AAEA,SAAgB,sBAAsB,IAAyC;CAC7E,OAAQ,GAAG,iBACT,GAAG,cAAc,cAAc;AACnC;AAcA,MAAa,2BAA2B;CACtC,OAAO;EAZP,QAAQ;EACR,UAAU;EACV,QAAQ;EACR,QAAQ;EACR,UAAU;EACV,SAAS;EACT,UAAU;EACV,YAAY;EACZ,OAAO;CAIA;CACP,eAAe;CACf,UAAU;AACZ;AAEA,UAAiB,SAAS;CACxB,MAAM,KAAKA,MAAM,MAAM;CAEvB,KAAK,IAAI,IAAI,IAAK,KAAK,MAAM,GAAG,GAAG,GAAG;AACxC"}
1
+ {"version":3,"file":"dom.cjs","names":["React"],"sources":["../../../src/utils/dom.ts"],"sourcesContent":["import { type AnyString, getActiveElement } from \"@yamada-ui/utils\"\nimport * as React from \"react\"\n\ntype KeyboardNavigationKey =\n | \"ArrowDown\"\n | \"ArrowLeft\"\n | \"ArrowRight\"\n | \"ArrowUp\"\n | \"End\"\n | \"Home\"\n | \"PageDown\"\n | \"PageUp\"\n\ntype KeyboardControlKey =\n | \"Alt\"\n | \"Backspace\"\n | \"CapsLock\"\n | \"Control\"\n | \"Delete\"\n | \"Enter\"\n | \"Escape\"\n | \"Insert\"\n | \"Meta\"\n | \"NumLock\"\n | \"Pause\"\n | \"PrintScreen\"\n | \"ScrollLock\"\n | \"Shift\"\n | \"Space\"\n | \"Tab\"\n\ntype KeyboardFunctionKey = \"Fn\" | \"FnLock\" | `F${number}`\n\ntype KeyboardKey =\n | AnyString\n | KeyboardControlKey\n | KeyboardFunctionKey\n | KeyboardNavigationKey\n\nexport function runKeyAction<Y>(\n ev: React.KeyboardEvent<Y>,\n actions: { [key in KeyboardKey]?: React.KeyboardEventHandler<Y> },\n { preventDefault = true }: { preventDefault?: boolean } = {},\n) {\n if (ev.key === \" \") ev.key = ev.code\n const action = actions[ev.key]\n\n if (!action) return\n\n if (preventDefault) ev.preventDefault()\n\n action(ev)\n}\n\nexport function isComposing(\n ev: React.ChangeEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>,\n): boolean {\n if (\"keyCode\" in ev) return ev.nativeEvent.isComposing || ev.keyCode === 229\n else if (ev.nativeEvent instanceof InputEvent)\n return ev.nativeEvent.isComposing\n else return false\n}\n\nexport function useAttributeObserver(\n ref: React.RefObject<HTMLElement | null>,\n attributeFilter: string[],\n enabled: boolean,\n func: () => void,\n) {\n React.useEffect(() => {\n if (!ref.current || !enabled) return\n\n const ownerDocument = ref.current.ownerDocument.defaultView ?? window\n\n const observer = new ownerDocument.MutationObserver((changes) => {\n for (const { type, attributeName } of changes) {\n if (type !== \"attributes\") continue\n if (!attributeName) continue\n\n if (attributeFilter.includes(attributeName)) func()\n }\n })\n\n observer.observe(ref.current, { attributeFilter, attributes: true })\n\n return () => observer.disconnect()\n })\n}\n\nexport function getEventRelatedTarget(ev: React.FocusEvent | React.MouseEvent) {\n if (ev.relatedTarget) return ev.relatedTarget as HTMLElement\n\n const getRootNode = (\n ev.currentTarget as unknown as {\n getRootNode?: () => Document | ShadowRoot\n }\n ).getRootNode\n const root = getRootNode?.call(ev.currentTarget)\n\n return ((root && getActiveElement(root)) ??\n ev.currentTarget.ownerDocument.activeElement) as HTMLElement | null\n}\n\nconst visuallyHiddenStyle = {\n border: \"0px\",\n clipPath: \"rect(0px 0px 0px 0px)\",\n height: \"1px\",\n margin: \"-1px\",\n overflow: \"hidden\",\n padding: \"0px\",\n position: \"absolute\",\n whiteSpace: \"nowrap\",\n width: \"1px\",\n} satisfies React.CSSProperties\n\nexport const visuallyHiddenAttributes = {\n style: visuallyHiddenStyle,\n \"aria-hidden\": true,\n tabIndex: -1,\n} satisfies React.HTMLAttributes<HTMLElement>\n\nexport function* useIds() {\n const id = React.useId()\n\n for (let i = 0; ; i++) yield `${id}-${i}`\n}\n"],"mappings":";;;;;AAuCA,SAAgB,aACd,IACA,SACA,EAAE,iBAAiB,SAAuC,CAAC,GAC3D;CACA,IAAI,GAAG,QAAQ,KAAK,GAAG,MAAM,GAAG;CAChC,MAAM,SAAS,QAAQ,GAAG;CAE1B,IAAI,CAAC,QAAQ;CAEb,IAAI,gBAAgB,GAAG,eAAe;CAEtC,OAAO,EAAE;AACX;AAEA,SAAgB,YACd,IACS;CACT,IAAI,aAAa,IAAI,OAAO,GAAG,YAAY,eAAe,GAAG,YAAY;MACpE,IAAI,GAAG,uBAAuB,YACjC,OAAO,GAAG,YAAY;MACnB,OAAO;AACd;AAEA,SAAgB,qBACd,KACA,iBACA,SACA,MACA;CACA,MAAM,gBAAgB;EACpB,IAAI,CAAC,IAAI,WAAW,CAAC,SAAS;EAI9B,MAAM,WAAW,KAFK,IAAI,QAAQ,cAAc,eAAe,OAAA,CAE5B,kBAAkB,YAAY;GAC/D,KAAK,MAAM,EAAE,MAAM,mBAAmB,SAAS;IAC7C,IAAI,SAAS,cAAc;IAC3B,IAAI,CAAC,eAAe;IAEpB,IAAI,gBAAgB,SAAS,aAAa,GAAG,KAAK;GACpD;EACF,CAAC;EAED,SAAS,QAAQ,IAAI,SAAS;GAAE;GAAiB,YAAY;EAAK,CAAC;EAEnE,aAAa,SAAS,WAAW;CACnC,CAAC;AACH;AAEA,SAAgB,sBAAsB,IAAyC;CAC7E,IAAI,GAAG,eAAe,OAAO,GAAG;CAOhC,MAAM,OAJJ,GAAG,cAGH,aACwB,KAAK,GAAG,aAAa;CAE/C,QAAS,SAAA,GAAA,iBAAA,iBAAA,CAAyB,IAAI,MACpC,GAAG,cAAc,cAAc;AACnC;AAcA,MAAa,2BAA2B;CACtC,OAAO;EAZP,QAAQ;EACR,UAAU;EACV,QAAQ;EACR,QAAQ;EACR,UAAU;EACV,SAAS;EACT,UAAU;EACV,YAAY;EACZ,OAAO;CAIA;CACP,eAAe;CACf,UAAU;AACZ;AAEA,UAAiB,SAAS;CACxB,MAAM,KAAKA,MAAM,MAAM;CAEvB,KAAK,IAAI,IAAI,IAAK,KAAK,MAAM,GAAG,GAAG,GAAG;AACxC"}
@@ -65,8 +65,8 @@ const useEditable = (props = {}) => {
65
65
  }, [onCancel]);
66
66
  const onBlur = useCallback((ev) => {
67
67
  if (!editing) return;
68
- const ownerDocument = ev.currentTarget.ownerDocument;
69
- const relatedTarget = ev.relatedTarget ?? ownerDocument.activeElement;
68
+ const rootNode = ev.currentTarget.getRootNode();
69
+ const relatedTarget = (0, utils_exports.isShadowRoot)(rootNode) ? rootNode.activeElement ?? ev.relatedTarget : ev.relatedTarget ?? rootNode.activeElement;
70
70
  const targetIsCancel = (0, utils_exports.contains)(cancelRef.current, relatedTarget);
71
71
  const targetIsSubmit = (0, utils_exports.contains)(submitRef.current, relatedTarget);
72
72
  if (!(!targetIsCancel && !targetIsSubmit)) return;
@@ -102,9 +102,8 @@ const useEditable = (props = {}) => {
102
102
  selectAllOnFocus
103
103
  ]);
104
104
  useEffect(() => {
105
- if (editing) return;
106
- const el = inputRef.current;
107
- if (el?.ownerDocument.activeElement === el) el?.blur();
105
+ if (editing || !inputRef.current) return;
106
+ if ((0, utils_exports.isActiveElement)(inputRef.current, inputRef.current.getRootNode())) inputRef.current.blur();
108
107
  }, [editing]);
109
108
  const getRootProps = useCallback((props) => ({
110
109
  ...rest,
@@ -1 +1 @@
1
- {"version":3,"file":"use-editable.js","names":["createContext"],"sources":["../../../../src/components/editable/use-editable.ts"],"sourcesContent":["\"use client\"\n\nimport type { ChangeEvent, FocusEvent, KeyboardEvent } from \"react\"\nimport type { PropGetter } from \"../../core\"\nimport type { FieldProps } from \"../field\"\nimport { useCallback, useEffect, useRef, useState } from \"react\"\nimport { useControllableState } from \"../../hooks/use-controllable-state\"\nimport { useFocusOnPointerDown } from \"../../hooks/use-focus\"\nimport {\n contains,\n createContext,\n handlerAll,\n mergeRefs,\n useCallbackRef,\n useSafeLayoutEffect,\n useUpdateEffect,\n} from \"../../utils\"\nimport { useFieldProps } from \"../field\"\n\ninterface EditableContext extends Omit<\n UseEditableReturn,\n \"getRootProps\" | \"onCancel\" | \"onEdit\" | \"onSubmit\" | \"value\"\n> {}\n\nconst [EditableContext, useEditableContext] = createContext<EditableContext>({\n name: \"EditableContext\",\n})\n\nexport { EditableContext, useEditableContext }\n\nexport interface UseEditableProps extends FieldProps {\n /**\n * The initial value of the Editable in both edit & preview mode.\n */\n defaultValue?: string\n /**\n * The placeholder text when the value is empty.\n */\n placeholder?: string\n /**\n * If `true`, the read only view, has a `tabIndex` set to `0`\n * so it can receive focus via the keyboard or click.\n *\n * @default true\n */\n previewFocusable?: boolean\n /**\n * If `true`, the input's text will be highlighted on focus.\n *\n * @default true\n */\n selectAllOnFocus?: boolean\n /**\n * If `true`, the Editable will start with edit mode by default.\n */\n startWithEditView?: boolean\n /**\n * If `true`, it'll update the value onBlur and turn off the edit mode.\n *\n * @default true\n */\n submitOnBlur?: boolean\n /**\n * The value of the Editable in both edit & preview mode.\n */\n value?: string\n /**\n * Callback invoked when user cancels input with the `Esc` key.\n * It provides the last confirmed value as argument.\n */\n onCancel?: (preValue: string) => void\n /**\n * A callback invoked when user changes input.\n */\n onChange?: (value: string) => void\n /**\n * A callback invoked once the user enters edit mode.\n */\n onEdit?: () => void\n /**\n * A callback invoked when user confirms value with `enter` key or by blurring input.\n */\n onSubmit?: (value: string) => void\n}\n\nexport const useEditable = (props: UseEditableProps = {}) => {\n const {\n props: {\n id,\n defaultValue,\n disabled,\n placeholder,\n previewFocusable = true,\n readOnly,\n required,\n selectAllOnFocus = true,\n startWithEditView,\n submitOnBlur = true,\n value: valueProp,\n onCancel: onCancelProp,\n onChange: onChangeProp,\n onEdit: onEditProp,\n onSubmit: onSubmitProp,\n ...rest\n },\n ariaProps,\n dataProps,\n eventProps,\n } = useFieldProps(props)\n const onEditRef = useCallbackRef(onEditProp)\n const [editing, setEditing] = useState<boolean>(\n !!startWithEditView && !disabled,\n )\n const [value, setValue] = useControllableState({\n defaultValue: defaultValue || \"\",\n value: valueProp,\n onChange: onChangeProp,\n })\n const interactive = !editing && !disabled\n const emptyValue = value.length === 0\n const [prevValue, setPrevValue] = useState(value)\n const inputRef = useRef<HTMLInputElement | HTMLTextAreaElement>(null)\n const previewRef = useRef<HTMLElement>(null)\n const editRef = useRef<HTMLButtonElement>(null)\n const cancelRef = useRef<HTMLButtonElement>(null)\n const submitRef = useRef<HTMLButtonElement>(null)\n\n const onChange = useCallback(\n (ev: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) =>\n setValue(ev.currentTarget.value),\n [setValue],\n )\n\n const onUpdatePrevValue = useCallback(() => setPrevValue(value), [value])\n\n const onEdit = useCallback(() => {\n if (interactive) setEditing(true)\n }, [interactive])\n\n const onCancel = useCallback(() => {\n setEditing(false)\n setValue(prevValue)\n onCancelProp?.(prevValue)\n }, [prevValue, onCancelProp, setValue])\n\n const onSubmit = useCallback(() => {\n setEditing(false)\n setPrevValue(value)\n onSubmitProp?.(value)\n }, [onSubmitProp, value])\n\n const onKeyDown = useCallback(\n (ev: KeyboardEvent) => {\n if (ev.key !== \"Escape\" && ev.key !== \"Enter\") return\n\n if (ev.key === \"Escape\") {\n ev.preventDefault()\n onCancel()\n } else {\n const { metaKey, shiftKey } = ev\n\n if (!shiftKey && !metaKey) {\n ev.preventDefault()\n onSubmit()\n }\n }\n },\n [onCancel, onSubmit],\n )\n\n const onKeyDownWithoutSubmit = useCallback(\n (ev: KeyboardEvent) => {\n if (ev.key !== \"Escape\") return\n\n ev.preventDefault()\n onCancel()\n },\n [onCancel],\n )\n\n const onBlur = useCallback(\n (ev: FocusEvent) => {\n if (!editing) return\n\n const ownerDocument = ev.currentTarget.ownerDocument\n const relatedTarget = (ev.relatedTarget ??\n ownerDocument.activeElement) as HTMLElement\n const targetIsCancel = contains(cancelRef.current, relatedTarget)\n const targetIsSubmit = contains(submitRef.current, relatedTarget)\n const validBlur = !targetIsCancel && !targetIsSubmit\n\n if (!validBlur) return\n\n if (submitOnBlur) onSubmit()\n else onCancel()\n },\n [editing, submitOnBlur, onSubmit, onCancel],\n )\n\n useFocusOnPointerDown({\n ref: inputRef,\n elements: [cancelRef, submitRef],\n enabled: editing,\n })\n\n useSafeLayoutEffect(() => {\n if (!editing) return\n\n inputRef.current?.focus()\n\n if (selectAllOnFocus) inputRef.current?.select()\n }, [])\n\n useUpdateEffect(() => {\n if (!editing) {\n editRef.current?.focus()\n\n return\n }\n\n inputRef.current?.focus()\n\n if (selectAllOnFocus) inputRef.current?.select()\n\n onEditRef()\n }, [editing, onEditRef, selectAllOnFocus])\n\n useEffect(() => {\n if (editing) return\n\n const el = inputRef.current\n const activeEl = el?.ownerDocument.activeElement\n\n if (activeEl === el) el?.blur()\n }, [editing])\n\n const getRootProps: PropGetter = useCallback(\n (props) => ({\n ...rest,\n ...dataProps,\n ...props,\n }),\n [rest, dataProps],\n )\n\n const getPreviewProps: PropGetter<\"span\"> = useCallback(\n ({ ref, ...props } = {}) => ({\n ...dataProps,\n ...props,\n ref: mergeRefs(previewRef, ref),\n children: emptyValue ? placeholder : value,\n hidden: editing,\n tabIndex: interactive && previewFocusable ? 0 : undefined,\n onFocus: handlerAll(props.onFocus, onEdit, onUpdatePrevValue),\n }),\n [\n dataProps,\n editing,\n interactive,\n previewFocusable,\n emptyValue,\n onEdit,\n onUpdatePrevValue,\n placeholder,\n value,\n ],\n )\n\n const getInputProps: PropGetter<\"input\"> = useCallback(\n ({ ref, ...props } = {}) => ({\n ...dataProps,\n ...ariaProps,\n ...props,\n id,\n ref: mergeRefs(inputRef, ref),\n disabled,\n hidden: !editing,\n placeholder,\n readOnly,\n required,\n value,\n onBlur: handlerAll(eventProps.onBlur, props.onBlur, onBlur),\n onChange: handlerAll(props.onChange, onChange),\n onFocus: handlerAll(eventProps.onFocus, props.onFocus, onUpdatePrevValue),\n onKeyDown: handlerAll(props.onKeyDown, onKeyDown),\n }),\n [\n dataProps,\n ariaProps,\n id,\n disabled,\n editing,\n placeholder,\n readOnly,\n required,\n value,\n eventProps.onBlur,\n eventProps.onFocus,\n onBlur,\n onChange,\n onUpdatePrevValue,\n onKeyDown,\n ],\n )\n\n const getTextareaProps: PropGetter<\"textarea\"> = useCallback(\n ({ ref, ...props } = {}) => ({\n ...dataProps,\n ...ariaProps,\n ...props,\n id,\n ref: mergeRefs(inputRef, ref),\n disabled,\n hidden: !editing,\n placeholder,\n readOnly,\n required,\n value,\n onBlur: handlerAll(eventProps.onBlur, props.onBlur, onBlur),\n onChange: handlerAll(props.onChange, onChange),\n onFocus: handlerAll(eventProps.onFocus, props.onFocus, onUpdatePrevValue),\n onKeyDown: handlerAll(props.onKeyDown, onKeyDownWithoutSubmit),\n }),\n [\n dataProps,\n ariaProps,\n id,\n disabled,\n editing,\n placeholder,\n readOnly,\n required,\n value,\n eventProps.onBlur,\n eventProps.onFocus,\n onBlur,\n onChange,\n onUpdatePrevValue,\n onKeyDownWithoutSubmit,\n ],\n )\n\n const getControlProps: PropGetter = useCallback(\n (props) => ({\n ...dataProps,\n role: \"group\",\n ...props,\n }),\n [dataProps],\n )\n\n const getEditProps: PropGetter<\"button\"> = useCallback(\n ({ ref, ...props } = {}) => ({\n ...dataProps,\n ...props,\n ref: mergeRefs(editRef, ref),\n disabled,\n hidden: editing,\n onClick: handlerAll(props.onClick, onEdit),\n }),\n [dataProps, disabled, editing, onEdit],\n )\n\n const getSubmitProps: PropGetter<\"button\"> = useCallback(\n ({ ref, ...props } = {}) => ({\n ...dataProps,\n ...props,\n ref: mergeRefs(submitRef, ref),\n disabled,\n hidden: !editing,\n onClick: handlerAll(props.onClick, onSubmit),\n }),\n [dataProps, disabled, editing, onSubmit],\n )\n\n const getCancelProps: PropGetter<\"button\"> = useCallback(\n ({ ref, ...props } = {}) => ({\n ...dataProps,\n ...props,\n ref: mergeRefs(cancelRef, ref),\n disabled,\n hidden: !editing,\n onClick: handlerAll(props.onClick, onCancel),\n }),\n [dataProps, disabled, editing, onCancel],\n )\n\n return {\n editing,\n value,\n getCancelProps,\n getControlProps,\n getEditProps,\n getInputProps,\n getPreviewProps,\n getRootProps,\n getSubmitProps,\n getTextareaProps,\n onCancel,\n onEdit,\n onSubmit,\n }\n}\n\nexport type UseEditableReturn = ReturnType<typeof useEditable>\n"],"mappings":";;;;;;;;;;AAwBA,MAAM,CAAC,iBAAiB,sBAAsBA,gBAA+B,EAC3E,MAAM,kBACR,CAAC;AA2DD,MAAa,eAAe,QAA0B,CAAC,MAAM;CAC3D,MAAM,EACJ,OAAO,EACL,IACA,cACA,UACA,aACA,mBAAmB,MACnB,UACA,UACA,mBAAmB,MACnB,mBACA,eAAe,MACf,OAAO,WACP,UAAU,cACV,UAAU,cACV,QAAQ,YACR,UAAU,cACV,GAAG,QAEL,WACA,WACA,eACE,cAAc,KAAK;CACvB,MAAM,YAAY,eAAe,UAAU;CAC3C,MAAM,CAAC,SAAS,cAAc,SAC5B,CAAC,CAAC,qBAAqB,CAAC,QAC1B;CACA,MAAM,CAAC,OAAO,YAAY,qBAAqB;EAC7C,cAAc,gBAAgB;EAC9B,OAAO;EACP,UAAU;CACZ,CAAC;CACD,MAAM,cAAc,CAAC,WAAW,CAAC;CACjC,MAAM,aAAa,MAAM,WAAW;CACpC,MAAM,CAAC,WAAW,gBAAgB,SAAS,KAAK;CAChD,MAAM,WAAW,OAA+C,IAA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AAoB,MAAM,SAAS,MAAM;CAC3C,IACA;EAAC;EAAW;EAAU;EAAS;CAAM,CACvC;CAEA,MAAM,iBAAuC,aAC1C,EAAE,KAAK,GAAG,UAAU,CAAC,OAAO;EAC3B,GAAG;EACH,GAAG;EACH,KAAK,UAAU,WAAW,GAAG;EAC7B;EACA,QAAQ,CAAC;EACT,UAAA,GAAA,cAAA,WAAA,CAAoB,MAAM,SAAS,QAAQ;CAC7C,IACA;EAAC;EAAW;EAAU;EAAS;CAAQ,CACzC;CAcA,OAAO;EACL;EACA;EACA,gBAf2C,aAC1C,EAAE,KAAK,GAAG,UAAU,CAAC,OAAO;GAC3B,GAAG;GACH,GAAG;GACH,KAAK,UAAU,WAAW,GAAG;GAC7B;GACA,QAAQ,CAAC;GACT,UAAA,GAAA,cAAA,WAAA,CAAoB,MAAM,SAAS,QAAQ;EAC7C,IACA;GAAC;GAAW;GAAU;GAAS;EAAQ,CAM1B;EACb;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;AACF"}
1
+ {"version":3,"file":"use-editable.js","names":["createContext"],"sources":["../../../../src/components/editable/use-editable.ts"],"sourcesContent":["\"use client\"\n\nimport type { ChangeEvent, FocusEvent, KeyboardEvent } from \"react\"\nimport type { PropGetter } from \"../../core\"\nimport type { FieldProps } from \"../field\"\nimport { useCallback, useEffect, useRef, useState } from \"react\"\nimport { useControllableState } from \"../../hooks/use-controllable-state\"\nimport { useFocusOnPointerDown } from \"../../hooks/use-focus\"\nimport {\n contains,\n createContext,\n handlerAll,\n isActiveElement,\n isShadowRoot,\n mergeRefs,\n useCallbackRef,\n useSafeLayoutEffect,\n useUpdateEffect,\n} from \"../../utils\"\nimport { useFieldProps } from \"../field\"\n\ninterface EditableContext extends Omit<\n UseEditableReturn,\n \"getRootProps\" | \"onCancel\" | \"onEdit\" | \"onSubmit\" | \"value\"\n> {}\n\nconst [EditableContext, useEditableContext] = createContext<EditableContext>({\n name: \"EditableContext\",\n})\n\nexport { EditableContext, useEditableContext }\n\nexport interface UseEditableProps extends FieldProps {\n /**\n * The initial value of the Editable in both edit & preview mode.\n */\n defaultValue?: string\n /**\n * The placeholder text when the value is empty.\n */\n placeholder?: string\n /**\n * If `true`, the read only view, has a `tabIndex` set to `0`\n * so it can receive focus via the keyboard or click.\n *\n * @default true\n */\n previewFocusable?: boolean\n /**\n * If `true`, the input's text will be highlighted on focus.\n *\n * @default true\n */\n selectAllOnFocus?: boolean\n /**\n * If `true`, the Editable will start with edit mode by default.\n */\n startWithEditView?: boolean\n /**\n * If `true`, it'll update the value onBlur and turn off the edit mode.\n *\n * @default true\n */\n submitOnBlur?: boolean\n /**\n * The value of the Editable in both edit & preview mode.\n */\n value?: string\n /**\n * Callback invoked when user cancels input with the `Esc` key.\n * It provides the last confirmed value as argument.\n */\n onCancel?: (preValue: string) => void\n /**\n * A callback invoked when user changes input.\n */\n onChange?: (value: string) => void\n /**\n * A callback invoked once the user enters edit mode.\n */\n onEdit?: () => void\n /**\n * A callback invoked when user confirms value with `enter` key or by blurring input.\n */\n onSubmit?: (value: string) => void\n}\n\nexport const useEditable = (props: UseEditableProps = {}) => {\n const {\n props: {\n id,\n defaultValue,\n disabled,\n placeholder,\n previewFocusable = true,\n readOnly,\n required,\n selectAllOnFocus = true,\n startWithEditView,\n submitOnBlur = true,\n value: valueProp,\n onCancel: onCancelProp,\n onChange: onChangeProp,\n onEdit: onEditProp,\n onSubmit: onSubmitProp,\n ...rest\n },\n ariaProps,\n dataProps,\n eventProps,\n } = useFieldProps(props)\n const onEditRef = useCallbackRef(onEditProp)\n const [editing, setEditing] = useState<boolean>(\n !!startWithEditView && !disabled,\n )\n const [value, setValue] = useControllableState({\n defaultValue: defaultValue || \"\",\n value: valueProp,\n onChange: onChangeProp,\n })\n const interactive = !editing && !disabled\n const emptyValue = value.length === 0\n const [prevValue, setPrevValue] = useState(value)\n const inputRef = useRef<HTMLInputElement | HTMLTextAreaElement>(null)\n const previewRef = useRef<HTMLElement>(null)\n const editRef = useRef<HTMLButtonElement>(null)\n const cancelRef = useRef<HTMLButtonElement>(null)\n const submitRef = useRef<HTMLButtonElement>(null)\n\n const onChange = useCallback(\n (ev: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) =>\n setValue(ev.currentTarget.value),\n [setValue],\n )\n\n const onUpdatePrevValue = useCallback(() => setPrevValue(value), [value])\n\n const onEdit = useCallback(() => {\n if (interactive) setEditing(true)\n }, [interactive])\n\n const onCancel = useCallback(() => {\n setEditing(false)\n setValue(prevValue)\n onCancelProp?.(prevValue)\n }, [prevValue, onCancelProp, setValue])\n\n const onSubmit = useCallback(() => {\n setEditing(false)\n setPrevValue(value)\n onSubmitProp?.(value)\n }, [onSubmitProp, value])\n\n const onKeyDown = useCallback(\n (ev: KeyboardEvent) => {\n if (ev.key !== \"Escape\" && ev.key !== \"Enter\") return\n\n if (ev.key === \"Escape\") {\n ev.preventDefault()\n onCancel()\n } else {\n const { metaKey, shiftKey } = ev\n\n if (!shiftKey && !metaKey) {\n ev.preventDefault()\n onSubmit()\n }\n }\n },\n [onCancel, onSubmit],\n )\n\n const onKeyDownWithoutSubmit = useCallback(\n (ev: KeyboardEvent) => {\n if (ev.key !== \"Escape\") return\n\n ev.preventDefault()\n onCancel()\n },\n [onCancel],\n )\n\n const onBlur = useCallback(\n (ev: FocusEvent) => {\n if (!editing) return\n\n const rootNode = ev.currentTarget.getRootNode() as Document | ShadowRoot\n const relatedTarget = (\n isShadowRoot(rootNode)\n ? (rootNode.activeElement ?? ev.relatedTarget)\n : (ev.relatedTarget ?? rootNode.activeElement)\n ) as HTMLElement\n const targetIsCancel = contains(cancelRef.current, relatedTarget)\n const targetIsSubmit = contains(submitRef.current, relatedTarget)\n const validBlur = !targetIsCancel && !targetIsSubmit\n\n if (!validBlur) return\n\n if (submitOnBlur) onSubmit()\n else onCancel()\n },\n [editing, submitOnBlur, onSubmit, onCancel],\n )\n\n useFocusOnPointerDown({\n ref: inputRef,\n elements: [cancelRef, submitRef],\n enabled: editing,\n })\n\n useSafeLayoutEffect(() => {\n if (!editing) return\n\n inputRef.current?.focus()\n\n if (selectAllOnFocus) inputRef.current?.select()\n }, [])\n\n useUpdateEffect(() => {\n if (!editing) {\n editRef.current?.focus()\n\n return\n }\n\n inputRef.current?.focus()\n\n if (selectAllOnFocus) inputRef.current?.select()\n\n onEditRef()\n }, [editing, onEditRef, selectAllOnFocus])\n\n useEffect(() => {\n if (editing || !inputRef.current) return\n if (isActiveElement(inputRef.current, inputRef.current.getRootNode()))\n inputRef.current.blur()\n }, [editing])\n\n const getRootProps: PropGetter = useCallback(\n (props) => ({\n ...rest,\n ...dataProps,\n ...props,\n }),\n [rest, dataProps],\n )\n\n const getPreviewProps: PropGetter<\"span\"> = useCallback(\n ({ ref, ...props } = {}) => ({\n ...dataProps,\n ...props,\n ref: mergeRefs(previewRef, ref),\n children: emptyValue ? placeholder : value,\n hidden: editing,\n tabIndex: interactive && previewFocusable ? 0 : undefined,\n onFocus: handlerAll(props.onFocus, onEdit, onUpdatePrevValue),\n }),\n [\n dataProps,\n editing,\n interactive,\n previewFocusable,\n emptyValue,\n onEdit,\n onUpdatePrevValue,\n placeholder,\n value,\n ],\n )\n\n const getInputProps: PropGetter<\"input\"> = useCallback(\n ({ ref, ...props } = {}) => ({\n ...dataProps,\n ...ariaProps,\n ...props,\n id,\n ref: mergeRefs(inputRef, ref),\n disabled,\n hidden: !editing,\n placeholder,\n readOnly,\n required,\n value,\n onBlur: handlerAll(eventProps.onBlur, props.onBlur, onBlur),\n onChange: handlerAll(props.onChange, onChange),\n onFocus: handlerAll(eventProps.onFocus, props.onFocus, onUpdatePrevValue),\n onKeyDown: handlerAll(props.onKeyDown, onKeyDown),\n }),\n [\n dataProps,\n ariaProps,\n id,\n disabled,\n editing,\n placeholder,\n readOnly,\n required,\n value,\n eventProps.onBlur,\n eventProps.onFocus,\n onBlur,\n onChange,\n onUpdatePrevValue,\n onKeyDown,\n ],\n )\n\n const getTextareaProps: PropGetter<\"textarea\"> = useCallback(\n ({ ref, ...props } = {}) => ({\n ...dataProps,\n ...ariaProps,\n ...props,\n id,\n ref: mergeRefs(inputRef, ref),\n disabled,\n hidden: !editing,\n placeholder,\n readOnly,\n required,\n value,\n onBlur: handlerAll(eventProps.onBlur, props.onBlur, onBlur),\n onChange: handlerAll(props.onChange, onChange),\n onFocus: handlerAll(eventProps.onFocus, props.onFocus, onUpdatePrevValue),\n onKeyDown: handlerAll(props.onKeyDown, onKeyDownWithoutSubmit),\n }),\n [\n dataProps,\n ariaProps,\n id,\n disabled,\n editing,\n placeholder,\n readOnly,\n required,\n value,\n eventProps.onBlur,\n eventProps.onFocus,\n onBlur,\n onChange,\n onUpdatePrevValue,\n onKeyDownWithoutSubmit,\n ],\n )\n\n const getControlProps: PropGetter = useCallback(\n (props) => ({\n ...dataProps,\n role: \"group\",\n ...props,\n }),\n [dataProps],\n )\n\n const getEditProps: PropGetter<\"button\"> = useCallback(\n ({ ref, ...props } = {}) => ({\n ...dataProps,\n ...props,\n ref: mergeRefs(editRef, ref),\n disabled,\n hidden: editing,\n onClick: handlerAll(props.onClick, onEdit),\n }),\n [dataProps, disabled, editing, onEdit],\n )\n\n const getSubmitProps: PropGetter<\"button\"> = useCallback(\n ({ ref, ...props } = {}) => ({\n ...dataProps,\n ...props,\n ref: mergeRefs(submitRef, ref),\n disabled,\n hidden: !editing,\n onClick: handlerAll(props.onClick, onSubmit),\n }),\n [dataProps, disabled, editing, onSubmit],\n )\n\n const getCancelProps: PropGetter<\"button\"> = useCallback(\n ({ ref, ...props } = {}) => ({\n ...dataProps,\n ...props,\n ref: mergeRefs(cancelRef, ref),\n disabled,\n hidden: !editing,\n onClick: handlerAll(props.onClick, onCancel),\n }),\n [dataProps, disabled, editing, onCancel],\n )\n\n return {\n editing,\n value,\n getCancelProps,\n getControlProps,\n getEditProps,\n getInputProps,\n getPreviewProps,\n getRootProps,\n getSubmitProps,\n getTextareaProps,\n onCancel,\n onEdit,\n onSubmit,\n }\n}\n\nexport type UseE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KAAK,UAAU,WAAW,GAAG;GAC7B;GACA,QAAQ,CAAC;GACT,UAAA,GAAA,cAAA,WAAA,CAAoB,MAAM,SAAS,QAAQ;EAC7C,IACA;GAAC;GAAW;GAAU;GAAS;EAAQ,CAM1B;EACb;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;AACF"}
@@ -2,6 +2,7 @@
2
2
  import { useSplitChildren, wrapOrPassProps } from "../../utils/children.js";
3
3
  import { utils_exports } from "../../utils/index.js";
4
4
  import { styled } from "../../core/system/factory.js";
5
+ import { mergeProps } from "../../core/components/props.js";
5
6
  import { createSlotComponent } from "../../core/components/create-component.js";
6
7
  import { motion as motion$1 } from "../motion/factory.js";
7
8
  import { useValue } from "../../hooks/use-value/index.js";
@@ -24,7 +25,7 @@ const { ComponentContext, PropsContext: ModalPropsContext, useComponentContext,
24
25
  *
25
26
  * @see https://yamada-ui.com/docs/components/modal
26
27
  */
27
- const ModalRoot = withProvider(({ allowPinchZoom = false, animationScheme = "scale", autoFocus, blockScrollOnMount = true, body, cancel, children, duration, finalFocusRef, footer, header, initialFocusRef, lockFocusAcrossFrames = true, middle, restoreFocus, success, title, trigger, withCloseButton = true, withOverlay = true, portalProps, onCancel, onCloseComplete, onMiddle, onSuccess, ...props }) => {
28
+ const ModalRoot = withProvider(({ allowPinchZoom = false, animationScheme = "scale", autoFocus, blockScrollOnMount = true, body, cancel, children, duration, finalFocusRef, footer, header, initialFocusRef, lockFocusAcrossFrames = true, middle, restoreFocus, success, title, trigger, withCloseButton = true, withOverlay = true, bodyProps, closeButtonProps, closeTriggerProps, contentProps, footerProps, headerProps, openTriggerProps, overlayProps, portalProps, titleProps, onCancel, onCloseComplete, onMiddle, onSuccess, ...props }) => {
28
29
  const [omittedChildren, openTrigger, customOverlay] = useSplitChildren(children, ModalOpenTrigger, ModalOverlay);
29
30
  const hasChildren = (0, utils_exports.isArray)(omittedChildren) && !!omittedChildren.length;
30
31
  const { open, getRootProps, ...rest } = useModal(props);
@@ -34,12 +35,30 @@ const ModalRoot = withProvider(({ allowPinchZoom = false, animationScheme = "sca
34
35
  duration,
35
36
  open,
36
37
  withCloseButton,
38
+ bodyProps,
39
+ closeButtonProps,
40
+ closeTriggerProps,
41
+ contentProps,
42
+ footerProps,
43
+ headerProps,
44
+ openTriggerProps,
45
+ overlayProps,
46
+ titleProps,
37
47
  ...rest
38
48
  }), [
39
49
  animationScheme,
40
50
  duration,
41
51
  open,
42
52
  withCloseButton,
53
+ contentProps,
54
+ bodyProps,
55
+ footerProps,
56
+ headerProps,
57
+ titleProps,
58
+ openTriggerProps,
59
+ closeTriggerProps,
60
+ closeButtonProps,
61
+ overlayProps,
43
62
  rest
44
63
  ]);
45
64
  return /* @__PURE__ */ jsxs(ComponentContext, {
@@ -83,28 +102,28 @@ const ModalOpenTrigger = withContext("button", {
83
102
  name: "OpenTrigger",
84
103
  slot: ["trigger", "open"]
85
104
  })(void 0, (props) => {
86
- const { getOpenTriggerProps } = useComponentContext();
105
+ const { getOpenTriggerProps, openTriggerProps } = useComponentContext();
87
106
  return {
88
107
  asChild: true,
89
- ...getOpenTriggerProps(props)
108
+ ...getOpenTriggerProps(mergeProps(openTriggerProps, props)())
90
109
  };
91
110
  });
92
111
  const ModalCloseTrigger = withContext("button", {
93
112
  name: "CloseTrigger",
94
113
  slot: ["trigger", "close"]
95
114
  })(void 0, (props) => {
96
- const { getCloseTriggerProps } = useComponentContext();
115
+ const { closeTriggerProps, getCloseTriggerProps } = useComponentContext();
97
116
  return {
98
117
  asChild: true,
99
- ...getCloseTriggerProps(props)
118
+ ...getCloseTriggerProps(mergeProps(closeTriggerProps, props)())
100
119
  };
101
120
  });
102
121
  const ModalCloseButton = withContext(CloseButton, "closeButton")(void 0, (props) => {
103
- const { getCloseButtonProps } = useComponentContext();
104
- return { ...getCloseButtonProps(props) };
122
+ const { closeButtonProps, getCloseButtonProps } = useComponentContext();
123
+ return { ...getCloseButtonProps(mergeProps(closeButtonProps, props)()) };
105
124
  });
106
125
  const ModalOverlay = withContext((props) => {
107
- const { animationScheme, duration: durationProp, getOverlayProps } = useComponentContext();
126
+ const { animationScheme, duration: durationProp, getOverlayProps, overlayProps } = useComponentContext();
108
127
  const duration = useValue(durationProp);
109
128
  return /* @__PURE__ */ jsx(motion$1.div, {
110
129
  custom: { duration },
@@ -114,11 +133,11 @@ const ModalOverlay = withContext((props) => {
114
133
  initial: "exit",
115
134
  variants: fadeVariants
116
135
  } : {},
117
- ...(0, utils_exports.cast)(getOverlayProps((0, utils_exports.cast)(props)))
136
+ ...(0, utils_exports.cast)(getOverlayProps((0, utils_exports.cast)(mergeProps(overlayProps, props)())))
118
137
  });
119
138
  }, "overlay")();
120
139
  const ModalContent = withContext(({ children, ...rest }) => {
121
- const { animationScheme, duration, withCloseButton, getContentProps } = useComponentContext();
140
+ const { animationScheme, duration, withCloseButton, contentProps, getContentProps } = useComponentContext();
122
141
  const [omittedChildren, customCloseButton] = useSplitChildren(children, ModalCloseButton);
123
142
  const popupAnimationProps = usePopupAnimationProps({
124
143
  animationScheme,
@@ -126,7 +145,7 @@ const ModalContent = withContext(({ children, ...rest }) => {
126
145
  });
127
146
  return /* @__PURE__ */ jsxs(motion$1.section, {
128
147
  ...popupAnimationProps,
129
- ...(0, utils_exports.cast)(getContentProps((0, utils_exports.cast)(rest))),
148
+ ...(0, utils_exports.cast)(getContentProps((0, utils_exports.cast)(mergeProps(contentProps, rest)()))),
130
149
  children: [customCloseButton ?? (withCloseButton ? /* @__PURE__ */ jsx(ModalCloseButton, {}) : null), omittedChildren]
131
150
  });
132
151
  }, "content")();
@@ -160,22 +179,22 @@ const ShorthandModalContent = ({ body, cancel, footer, header, middle, success,
160
179
  ] });
161
180
  };
162
181
  const ModalHeader = withContext("header", "header")(void 0, (props) => {
163
- const { getHeaderProps } = useComponentContext();
164
- return { ...getHeaderProps(props) };
182
+ const { getHeaderProps, headerProps } = useComponentContext();
183
+ return { ...getHeaderProps(mergeProps(headerProps, props)()) };
165
184
  });
166
185
  const ModalTitle = withContext("h2", "title")(void 0, (props) => {
167
- const { getTitleProps } = useComponentContext();
168
- return { ...getTitleProps(props) };
186
+ const { getTitleProps, titleProps } = useComponentContext();
187
+ return { ...getTitleProps(mergeProps(titleProps, props)()) };
169
188
  });
170
189
  const ModalBody = withContext("div", "body")(void 0, (props) => {
171
- const { getBodyProps } = useComponentContext();
172
- return { ...getBodyProps(props) };
190
+ const { bodyProps, getBodyProps } = useComponentContext();
191
+ return { ...getBodyProps(mergeProps(bodyProps, props)()) };
173
192
  });
174
193
  const ModalFooter = withContext("footer", "footer")(void 0, (props) => {
175
- const { getFooterProps } = useComponentContext();
176
- return { ...getFooterProps(props) };
194
+ const { footerProps, getFooterProps } = useComponentContext();
195
+ return { ...getFooterProps(mergeProps(footerProps, props)()) };
177
196
  });
178
197
  //#endregion
179
- export { ModalBody, ModalCloseButton, ModalCloseTrigger, ModalContent, ModalFooter, ModalHeader, ModalOpenTrigger, ModalOverlay, ModalPropsContext, ModalRoot, ModalTitle, ShorthandModalContent, useModalPropsContext };
198
+ export { ModalBody, ModalCloseButton, ModalCloseTrigger, ModalContent, ModalFooter, ModalHeader, ModalOpenTrigger, ModalOverlay, ModalPropsContext, ModalRoot, ModalTitle, useModalPropsContext };
180
199
 
181
200
  //# sourceMappingURL=modal.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"modal.js","names":["motion"],"sources":["../../../../src/components/modal/modal.tsx"],"sourcesContent":["\"use client\"\n\nimport type { FC, PropsWithChildren, ReactNode } from \"react\"\nimport type { HTMLProps, HTMLStyledProps, ThemeProps } from \"../../core\"\nimport type { ButtonProps } from \"../button\"\nimport type { CloseButtonProps } from \"../close-button\"\nimport type { FocusLockProps } from \"../focus-lock\"\nimport type { HTMLMotionProps, HTMLMotionPropsWithoutAs } from \"../motion\"\nimport type { UsePopupAnimationProps } from \"../popover\"\nimport type { PortalProps } from \"../portal\"\nimport type { ModalStyle } from \"./modal.style\"\nimport type { UseModalProps, UseModalReturn } from \"./use-modal\"\nimport { AnimatePresence } from \"motion/react\"\nimport { useMemo } from \"react\"\nimport { RemoveScroll } from \"react-remove-scroll\"\nimport { createSlotComponent, styled } from \"../../core\"\nimport { useValue } from \"../../hooks/use-value\"\nimport { cast, isArray, useSplitChildren, wrapOrPassProps } from \"../../utils\"\nimport { Button } from \"../button\"\nimport { CloseButton } from \"../close-button\"\nimport { fadeVariants } from \"../fade\"\nimport { FocusLock } from \"../focus-lock\"\nimport { motion } from \"../motion\"\nimport { usePopupAnimationProps } from \"../popover\"\nimport { Portal } from \"../portal\"\nimport { modalStyle } from \"./modal.style\"\nimport { useModal } from \"./use-modal\"\n\ninterface ComponentContext\n extends\n Omit<UseModalReturn, \"getRootProps\">,\n UsePopupAnimationProps,\n Pick<ModalRootProps, \"withCloseButton\"> {}\n\nexport interface ModalRootProps\n extends\n Omit<HTMLStyledProps<\"div\">, \"scrollBehavior\" | \"title\">,\n ThemeProps<ModalStyle>,\n Omit<UseModalProps, \"title\">,\n Pick<\n FocusLockProps,\n | \"autoFocus\"\n | \"finalFocusRef\"\n | \"initialFocusRef\"\n | \"lockFocusAcrossFrames\"\n | \"restoreFocus\"\n >,\n UsePopupAnimationProps,\n ShorthandModalContentProps {\n /**\n * Handle zoom or pinch gestures on iOS devices when scroll locking is enabled.\n *\n * @default false.\n */\n allowPinchZoom?: boolean\n /**\n * If `true`, scrolling will be disabled on the `body` when the modal opens.\n *\n * @default true\n */\n blockScrollOnMount?: boolean\n /**\n * The modal trigger to use.\n */\n trigger?: ReactNode\n /**\n * If `true`, display the modal close button.\n *\n * @default true\n */\n withCloseButton?: boolean\n /**\n * If `true`, display the modal overlay.\n *\n * @default true\n */\n withOverlay?: boolean\n /**\n * Props to be forwarded to the portal component.\n */\n portalProps?: Omit<PortalProps, \"children\">\n /**\n * Callback function to run side effects after the modal has closed.\n */\n onCloseComplete?: () => void\n}\n\nconst {\n ComponentContext,\n PropsContext: ModalPropsContext,\n useComponentContext,\n usePropsContext: useModalPropsContext,\n withContext,\n withProvider,\n} = createSlotComponent<ModalRootProps, ModalStyle, ComponentContext>(\n \"modal\",\n modalStyle,\n)\n\nexport { ModalPropsContext, useModalPropsContext }\n\n/**\n * `Modal` is a component that is displayed over the main content to focus the user's attention solely on the information.\n *\n * @see https://yamada-ui.com/docs/components/modal\n */\nexport const ModalRoot = withProvider<\"div\", ModalRootProps>(\n ({\n allowPinchZoom = false,\n animationScheme = \"scale\",\n autoFocus,\n blockScrollOnMount = true,\n body,\n cancel,\n children,\n duration,\n finalFocusRef,\n footer,\n header,\n initialFocusRef,\n lockFocusAcrossFrames = true,\n middle,\n restoreFocus,\n success,\n title,\n trigger,\n withCloseButton = true,\n withOverlay = true,\n portalProps,\n onCancel,\n onCloseComplete,\n onMiddle,\n onSuccess,\n ...props\n }) => {\n const [omittedChildren, openTrigger, customOverlay] = useSplitChildren(\n children,\n ModalOpenTrigger,\n ModalOverlay,\n )\n const hasChildren = isArray(omittedChildren) && !!omittedChildren.length\n const { open, getRootProps, ...rest } = useModal(props)\n const customOpenTrigger = trigger ? (\n <ModalOpenTrigger>{trigger}</ModalOpenTrigger>\n ) : null\n const context = useMemo(\n () => ({\n animationScheme,\n duration,\n open,\n withCloseButton,\n ...rest,\n }),\n [animationScheme, duration, open, withCloseButton, rest],\n )\n\n return (\n <ComponentContext value={context}>\n {openTrigger ?? customOpenTrigger}\n\n <AnimatePresence onExitComplete={onCloseComplete}>\n {open ? (\n <Portal {...portalProps}>\n <FocusLock\n autoFocus={autoFocus}\n finalFocusRef={finalFocusRef}\n initialFocusRef={initialFocusRef}\n lockFocusAcrossFrames={lockFocusAcrossFrames}\n restoreFocus={restoreFocus}\n >\n <RemoveScroll\n allowPinchZoom={allowPinchZoom}\n enabled={blockScrollOnMount}\n forwardProps\n >\n <styled.div {...getRootProps()}>\n {customOverlay ?? (withOverlay ? <ModalOverlay /> : null)}\n\n {hasChildren ? (\n omittedChildren\n ) : (\n <ShorthandModalContent\n body={body}\n cancel={cancel}\n footer={footer}\n header={header}\n middle={middle}\n success={success}\n title={title}\n onCancel={onCancel}\n onMiddle={onMiddle}\n onSuccess={onSuccess}\n />\n )}\n </styled.div>\n </RemoveScroll>\n </FocusLock>\n </Portal>\n ) : null}\n </AnimatePresence>\n </ComponentContext>\n )\n },\n \"root\",\n)()\n\nexport interface ModalOpenTriggerProps extends HTMLStyledProps<\"button\"> {}\n\nexport const ModalOpenTrigger = withContext<\"button\", ModalOpenTriggerProps>(\n \"button\",\n { name: \"OpenTrigger\", slot: [\"trigger\", \"open\"] },\n)(undefined, (props) => {\n const { getOpenTriggerProps } = useComponentContext()\n\n return { asChild: true, ...getOpenTriggerProps(props) }\n})\n\nexport interface ModalCloseTriggerProps extends HTMLStyledProps<\"button\"> {}\n\nexport const ModalCloseTrigger = withContext<\"button\", ModalCloseTriggerProps>(\n \"button\",\n { name: \"CloseTrigger\", slot: [\"trigger\", \"close\"] },\n)(undefined, (props) => {\n const { getCloseTriggerProps } = useComponentContext()\n\n return { asChild: true, ...getCloseTriggerProps(props) }\n})\n\nexport interface ModalCloseButtonProps extends CloseButtonProps {}\n\nexport const ModalCloseButton = withContext<\"button\", ModalCloseButtonProps>(\n CloseButton,\n \"closeButton\",\n)(undefined, (props) => {\n const { getCloseButtonProps } = useComponentContext()\n\n return { ...getCloseButtonProps(props) }\n})\n\nexport interface ModalOverlayProps extends HTMLMotionProps {}\n\nexport const ModalOverlay = withContext<\"div\", ModalOverlayProps>((props) => {\n const {\n animationScheme,\n duration: durationProp,\n getOverlayProps,\n } = useComponentContext()\n const duration = useValue(durationProp)\n\n return (\n <motion.div\n custom={{ duration }}\n {...(animationScheme !== \"none\"\n ? {\n animate: \"enter\",\n exit: \"exit\",\n initial: \"exit\",\n variants: fadeVariants,\n }\n : {})}\n {...cast<HTMLMotionProps>(getOverlayProps(cast<HTMLProps>(props)))}\n />\n )\n}, \"overlay\")()\n\nexport interface ModalContentProps\n extends Omit<HTMLMotionProps<\"section\">, \"children\">, PropsWithChildren {}\n\nexport const ModalContent = withContext<\"section\", ModalContentProps>(\n ({ children, ...rest }) => {\n const { animationScheme, duration, withCloseButton, getContentProps } =\n useComponentContext()\n const [omittedChildren, customCloseButton] = useSplitChildren(\n children,\n ModalCloseButton,\n )\n const popupAnimationProps = usePopupAnimationProps({\n animationScheme,\n duration,\n })\n\n return (\n <motion.section\n {...popupAnimationProps}\n {...cast<HTMLMotionPropsWithoutAs<\"section\">>(\n getContentProps(cast<HTMLProps<\"section\">>(rest)),\n )}\n >\n {customCloseButton ?? (withCloseButton ? <ModalCloseButton /> : null)}\n\n {omittedChildren}\n </motion.section>\n )\n },\n \"content\",\n)()\n\ninterface ShorthandModalContentProps {\n /**\n * The modal body to use.\n */\n body?: ModalBodyProps | ReactNode\n /**\n * The modal cancel button to use.\n */\n cancel?: ButtonProps | ReactNode\n /**\n * The modal footer to use.\n */\n footer?: ModalFooterProps | ReactNode\n /**\n * The modal header to use.\n */\n header?: ModalHeaderProps | ReactNode\n /**\n * The modal middle button to use.\n */\n middle?: ButtonProps | ReactNode\n /**\n * The modal success button to use.\n */\n success?: ButtonProps | ReactNode\n /**\n * The modal title to use.\n */\n title?: ModalTitleProps | ReactNode\n /**\n * The callback invoked when cancel button clicked.\n */\n onCancel?: (onClose: () => void) => void\n /**\n * The callback invoked when middle button clicked.\n */\n onMiddle?: (onClose: () => void) => void\n /**\n * The callback invoked when success button clicked.\n */\n onSuccess?: (onClose: () => void) => void\n}\n\nexport const ShorthandModalContent: FC<ShorthandModalContentProps> = ({\n body,\n cancel,\n footer,\n header,\n middle,\n success,\n title,\n onCancel,\n onMiddle,\n onSuccess,\n}) => {\n const { onClose } = useComponentContext()\n const customHeader = wrapOrPassProps(ModalHeader, header)\n const customTitle = wrapOrPassProps(ModalTitle, title)\n const customBody = wrapOrPassProps(ModalBody, body)\n const customFooter = wrapOrPassProps(ModalFooter, footer)\n const customCancel = wrapOrPassProps(Button, cancel, {\n colorScheme: \"mono\",\n variant: \"ghost\",\n onClick: () => (onCancel ? onCancel(onClose) : onClose()),\n })\n const customMiddle = wrapOrPassProps(Button, middle, {\n colorScheme: \"secondary\",\n onClick: () => (onMiddle ? onMiddle(onClose) : onClose()),\n })\n const customSuccess = wrapOrPassProps(Button, success, {\n colorScheme: \"primary\",\n onClick: () => (onSuccess ? onSuccess(onClose) : onClose()),\n })\n\n return (\n <ModalContent>\n {customHeader ??\n (customTitle ? <ModalHeader>{customTitle}</ModalHeader> : null)}\n {customBody}\n {customFooter ??\n (customCancel || customMiddle || customSuccess ? (\n <ModalFooter>\n {customCancel}\n {customMiddle}\n {customSuccess}\n </ModalFooter>\n ) : null)}\n </ModalContent>\n )\n}\n\nexport interface ModalHeaderProps extends HTMLStyledProps<\"header\"> {}\n\nexport const ModalHeader = withContext<\"header\", ModalHeaderProps>(\n \"header\",\n \"header\",\n)(undefined, (props) => {\n const { getHeaderProps } = useComponentContext()\n\n return { ...getHeaderProps(props) }\n})\n\nexport interface ModalTitleProps extends HTMLStyledProps<\"h2\"> {}\n\nexport const ModalTitle = withContext<\"h2\", ModalTitleProps>(\"h2\", \"title\")(\n undefined,\n (props) => {\n const { getTitleProps } = useComponentContext()\n\n return { ...getTitleProps(props) }\n },\n)\n\nexport interface ModalBodyProps extends HTMLStyledProps {}\n\nexport const ModalBody = withContext<\"div\", ModalBodyProps>(\"div\", \"body\")(\n undefined,\n (props) => {\n const { getBodyProps } = useComponentContext()\n\n return { ...getBodyProps(props) }\n },\n)\n\nexport interface ModalFooterProps extends HTMLStyledProps<\"footer\"> {}\n\nexport const ModalFooter = withContext<\"footer\", ModalFooterProps>(\n \"footer\",\n \"footer\",\n)(undefined, (props) => {\n const { getFooterProps } = useComponentContext()\n\n return { ...getFooterProps(props) }\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAuFA,MAAM,EACJ,kBACA,cAAc,mBACd,qBACA,iBAAiB,sBACjB,aACA,iBACE,oBACF,SACA,UACF;;;;;;AASA,MAAa,YAAY,cACtB,EACC,iBAAiB,OACjB,kBAAkB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,IACC,UAAU;CACT,MAAM,EAAE,iBAAiB,oBAAoB;CAE7C,OAAO,EAAE,GAAG,aAAa,KAAK,EAAE;AAClC,CACF;AAIA,MAAa,cAAc,YACzB,UACA,QACF,CAAC,CAAC,KAAA,IAAY,UAAU;CACtB,MAAM,EAAE,mBAAmB,oBAAoB;CAE/C,OAAO,EAAE,GAAG,eAAe,KAAK,EAAE;AACpC,CAAC"}
1
+ {"version":3,"file":"modal.js","names":["motion"],"sources":["../../../../src/components/modal/modal.tsx"],"sourcesContent":["\"use client\"\n\nimport type { FC, PropsWithChildren, ReactNode } from \"react\"\nimport type { HTMLProps, HTMLStyledProps, ThemeProps } from \"../../core\"\nimport type { ButtonProps } from \"../button\"\nimport type { CloseButtonProps } from \"../close-button\"\nimport type { FocusLockProps } from \"../focus-lock\"\nimport type { HTMLMotionProps, HTMLMotionPropsWithoutAs } from \"../motion\"\nimport type { UsePopupAnimationProps } from \"../popover\"\nimport type { PortalProps } from \"../portal\"\nimport type { ModalStyle } from \"./modal.style\"\nimport type { UseModalProps, UseModalReturn } from \"./use-modal\"\nimport { AnimatePresence } from \"motion/react\"\nimport { useMemo } from \"react\"\nimport { RemoveScroll } from \"react-remove-scroll\"\nimport { createSlotComponent, mergeProps, styled } from \"../../core\"\nimport { useValue } from \"../../hooks/use-value\"\nimport { cast, isArray, useSplitChildren, wrapOrPassProps } from \"../../utils\"\nimport { Button } from \"../button\"\nimport { CloseButton } from \"../close-button\"\nimport { fadeVariants } from \"../fade\"\nimport { FocusLock } from \"../focus-lock\"\nimport { motion } from \"../motion\"\nimport { usePopupAnimationProps } from \"../popover\"\nimport { Portal } from \"../portal\"\nimport { modalStyle } from \"./modal.style\"\nimport { useModal } from \"./use-modal\"\n\ninterface ComponentContext\n extends\n Omit<UseModalReturn, \"getRootProps\">,\n UsePopupAnimationProps,\n Pick<\n ModalRootProps,\n | \"bodyProps\"\n | \"closeButtonProps\"\n | \"closeTriggerProps\"\n | \"contentProps\"\n | \"footerProps\"\n | \"headerProps\"\n | \"openTriggerProps\"\n | \"overlayProps\"\n | \"titleProps\"\n | \"withCloseButton\"\n > {}\n\nexport interface ModalRootProps\n extends\n Omit<HTMLStyledProps<\"div\">, \"scrollBehavior\" | \"title\">,\n ThemeProps<ModalStyle>,\n Omit<UseModalProps, \"title\">,\n Pick<\n FocusLockProps,\n | \"autoFocus\"\n | \"finalFocusRef\"\n | \"initialFocusRef\"\n | \"lockFocusAcrossFrames\"\n | \"restoreFocus\"\n >,\n UsePopupAnimationProps,\n ShorthandModalContentProps {\n /**\n * Handle zoom or pinch gestures on iOS devices when scroll locking is enabled.\n *\n * @default false.\n */\n allowPinchZoom?: boolean\n /**\n * If `true`, scrolling will be disabled on the `body` when the modal opens.\n *\n * @default true\n */\n blockScrollOnMount?: boolean\n /**\n * The modal trigger to use.\n */\n trigger?: ReactNode\n /**\n * If `true`, display the modal close button.\n *\n * @default true\n */\n withCloseButton?: boolean\n /**\n * If `true`, display the modal overlay.\n *\n * @default true\n */\n withOverlay?: boolean\n /**\n * Props for body element.\n */\n bodyProps?: Omit<ModalBodyProps, \"children\">\n /**\n * Props for close button element.\n */\n closeButtonProps?: Omit<ModalCloseButtonProps, \"children\">\n /**\n * Props for close trigger element.\n */\n closeTriggerProps?: Omit<ModalCloseTriggerProps, \"asChild\" | \"children\">\n /**\n * Props for content element.\n */\n contentProps?: Omit<ModalContentProps, \"children\">\n /**\n * Props for footer element.\n */\n footerProps?: Omit<ModalFooterProps, \"children\">\n /**\n * Props for header element.\n */\n headerProps?: Omit<ModalHeaderProps, \"children\">\n /**\n * Props for open trigger element.\n */\n openTriggerProps?: Omit<ModalOpenTriggerProps, \"asChild\" | \"children\">\n /**\n * Props for overlay element.\n */\n overlayProps?: Omit<ModalOverlayProps, \"children\">\n /**\n * Props to be forwarded to the portal component.\n */\n portalProps?: Omit<PortalProps, \"children\">\n /**\n * Props for title element.\n */\n titleProps?: Omit<ModalTitleProps, \"children\">\n /**\n * Callback function to run side effects after the modal has closed.\n */\n onCloseComplete?: () => void\n}\n\nconst {\n ComponentContext,\n PropsContext: ModalPropsContext,\n useComponentContext,\n usePropsContext: useModalPropsContext,\n withContext,\n withProvider,\n} = createSlotComponent<ModalRootProps, ModalStyle, ComponentContext>(\n \"modal\",\n modalStyle,\n)\n\nexport { ModalPropsContext, useModalPropsContext }\n\n/**\n * `Modal` is a component that is displayed over the main content to focus the user's attention solely on the information.\n *\n * @see https://yamada-ui.com/docs/components/modal\n */\nexport const ModalRoot = withProvider<\"div\", ModalRootProps>(\n ({\n allowPinchZoom = false,\n animationScheme = \"scale\",\n autoFocus,\n blockScrollOnMount = true,\n body,\n cancel,\n children,\n duration,\n finalFocusRef,\n footer,\n header,\n initialFocusRef,\n lockFocusAcrossFrames = true,\n middle,\n restoreFocus,\n success,\n title,\n trigger,\n withCloseButton = true,\n withOverlay = true,\n bodyProps,\n closeButtonProps,\n closeTriggerProps,\n contentProps,\n footerProps,\n headerProps,\n openTriggerProps,\n overlayProps,\n portalProps,\n titleProps,\n onCancel,\n onCloseComplete,\n onMiddle,\n onSuccess,\n ...props\n }) => {\n const [omittedChildren, openTrigger, customOverlay] = useSplitChildren(\n children,\n ModalOpenTrigger,\n ModalOverlay,\n )\n const hasChildren = isArray(omittedChildren) && !!omittedChildren.length\n const { open, getRootProps, ...rest } = useModal(props)\n const customOpenTrigger = trigger ? (\n <ModalOpenTrigger>{trigger}</ModalOpenTrigger>\n ) : null\n const context = useMemo(\n () => ({\n animationScheme,\n duration,\n open,\n withCloseButton,\n bodyProps,\n closeButtonProps,\n closeTriggerProps,\n contentProps,\n footerProps,\n headerProps,\n openTriggerProps,\n overlayProps,\n titleProps,\n ...rest,\n }),\n [\n animationScheme,\n duration,\n open,\n withCloseButton,\n contentProps,\n bodyProps,\n footerProps,\n headerProps,\n titleProps,\n openTriggerProps,\n closeTriggerProps,\n closeButtonProps,\n overlayProps,\n rest,\n ],\n )\n\n return (\n <ComponentContext value={context}>\n {openTrigger ?? customOpenTrigger}\n\n <AnimatePresence onExitComplete={onCloseComplete}>\n {open ? (\n <Portal {...portalProps}>\n <FocusLock\n autoFocus={autoFocus}\n finalFocusRef={finalFocusRef}\n initialFocusRef={initialFocusRef}\n lockFocusAcrossFrames={lockFocusAcrossFrames}\n restoreFocus={restoreFocus}\n >\n <RemoveScroll\n allowPinchZoom={allowPinchZoom}\n enabled={blockScrollOnMount}\n forwardProps\n >\n <styled.div {...getRootProps()}>\n {customOverlay ?? (withOverlay ? <ModalOverlay /> : null)}\n\n {hasChildren ? (\n omittedChildren\n ) : (\n <ShorthandModalContent\n body={body}\n cancel={cancel}\n footer={footer}\n header={header}\n middle={middle}\n success={success}\n title={title}\n onCancel={onCancel}\n onMiddle={onMiddle}\n onSuccess={onSuccess}\n />\n )}\n </styled.div>\n </RemoveScroll>\n </FocusLock>\n </Portal>\n ) : null}\n </AnimatePresence>\n </ComponentContext>\n )\n },\n \"root\",\n)()\n\nexport interface ModalOpenTriggerProps extends HTMLStyledProps<\"button\"> {}\n\nexport const ModalOpenTrigger = withContext<\"button\", ModalOpenTriggerProps>(\n \"button\",\n { name: \"OpenTrigger\", slot: [\"trigger\", \"open\"] },\n)(undefined, (props) => {\n const { getOpenTriggerProps, openTriggerProps } = useComponentContext()\n\n return {\n asChild: true,\n ...getOpenTriggerProps(mergeProps(openTriggerProps, props)()),\n }\n})\n\nexport interface ModalCloseTriggerProps extends HTMLStyledProps<\"button\"> {}\n\nexport const ModalCloseTrigger = withContext<\"button\", ModalCloseTriggerProps>(\n \"button\",\n { name: \"CloseTrigger\", slot: [\"trigger\", \"close\"] },\n)(undefined, (props) => {\n const { closeTriggerProps, getCloseTriggerProps } = useComponentContext()\n\n return {\n asChild: true,\n ...getCloseTriggerProps(mergeProps(closeTriggerProps, props)()),\n }\n})\n\nexport interface ModalCloseButtonProps extends CloseButtonProps {}\n\nexport const ModalCloseButton = withContext<\"button\", ModalCloseButtonProps>(\n CloseButton,\n \"closeButton\",\n)(undefined, (props) => {\n const { closeButtonProps, getCloseButtonProps } = useComponentContext()\n\n return { ...getCloseButtonProps(mergeProps(closeButtonProps, props)()) }\n})\n\nexport interface ModalOverlayProps extends HTMLMotionProps {}\n\nexport const ModalOverlay = withContext<\"div\", ModalOverlayProps>((props) => {\n const {\n animationScheme,\n duration: durationProp,\n getOverlayProps,\n overlayProps,\n } = useComponentContext()\n const duration = useValue(durationProp)\n\n return (\n <motion.div\n custom={{ duration }}\n {...(animationScheme !== \"none\"\n ? {\n animate: \"enter\",\n exit: \"exit\",\n initial: \"exit\",\n variants: fadeVariants,\n }\n : {})}\n {...cast<HTMLMotionProps>(\n getOverlayProps(cast<HTMLProps>(mergeProps(overlayProps, props)())),\n )}\n />\n )\n}, \"overlay\")()\n\nexport interface ModalContentProps\n extends Omit<HTMLMotionProps<\"section\">, \"children\">, PropsWithChildren {}\n\nexport const ModalContent = withContext<\"section\", ModalContentProps>(\n ({ children, ...rest }) => {\n const {\n animationScheme,\n duration,\n withCloseButton,\n contentProps,\n getContentProps,\n } = useComponentContext()\n const [omittedChildren, customCloseButton] = useSplitChildren(\n children,\n ModalCloseButton,\n )\n const popupAnimationProps = usePopupAnimationProps({\n animationScheme,\n duration,\n })\n\n return (\n <motion.section\n {...popupAnimationProps}\n {...cast<HTMLMotionPropsWithoutAs<\"section\">>(\n getContentProps(\n cast<HTMLProps<\"section\">>(mergeProps(contentProps, rest)()),\n ),\n )}\n >\n {customCloseButton ?? (withCloseButton ? <ModalCloseButton /> : null)}\n\n {omittedChildren}\n </motion.section>\n )\n },\n \"content\",\n)()\n\ninterface ShorthandModalContentProps {\n /**\n * The modal body to use.\n */\n body?: ModalBodyProps | ReactNode\n /**\n * The modal cancel button to use.\n */\n cancel?: ButtonProps | ReactNode\n /**\n * The modal footer to use.\n */\n footer?: ModalFooterProps | ReactNode\n /**\n * The modal header to use.\n */\n header?: ModalHeaderProps | ReactNode\n /**\n * The modal middle button to use.\n */\n middle?: ButtonProps | ReactNode\n /**\n * The modal success button to use.\n */\n success?: ButtonProps | ReactNode\n /**\n * The modal title to use.\n */\n title?: ModalTitleProps | ReactNode\n /**\n * The callback invoked when cancel button clicked.\n */\n onCancel?: (onClose: () => void) => void\n /**\n * The callback invoked when middle button clicked.\n */\n onMiddle?: (onClose: () => void) => void\n /**\n * The callback invoked when success button clicked.\n */\n onSuccess?: (onClose: () => void) => void\n}\n\nconst ShorthandModalContent: FC<ShorthandModalContentProps> = ({\n body,\n cancel,\n footer,\n header,\n middle,\n success,\n title,\n onCancel,\n onMiddle,\n onSuccess,\n}) => {\n const { onClose } = useComponentContext()\n const customHeader = wrapOrPassProps(ModalHeader, header)\n const customTitle = wrapOrPassProps(ModalTitle, title)\n const customBody = wrapOrPassProps(ModalBody, body)\n const customFooter = wrapOrPassProps(ModalFooter, footer)\n const customCancel = wrapOrPassProps(Button, cancel, {\n colorScheme: \"mono\",\n variant: \"ghost\",\n onClick: () => (onCancel ? onCancel(onClose) : onClose()),\n })\n const customMiddle = wrapOrPassProps(Button, middle, {\n colorScheme: \"secondary\",\n onClick: () => (onMiddle ? onMiddle(onClose) : onClose()),\n })\n const customSuccess = wrapOrPassProps(Button, success, {\n colorScheme: \"primary\",\n onClick: () => (onSuccess ? onSuccess(onClose) : onClose()),\n })\n\n return (\n <ModalContent>\n {customHeader ??\n (customTitle ? <ModalHeader>{customTitle}</ModalHeader> : null)}\n {customBody}\n {customFooter ??\n (customCancel || customMiddle || customSuccess ? (\n <ModalFooter>\n {customCancel}\n {customMiddle}\n {customSuccess}\n </ModalFooter>\n ) : null)}\n </ModalContent>\n )\n}\n\nexport interface ModalHeaderProps extends HTMLStyledProps<\"header\"> {}\n\nexport const ModalHeader = withContext<\"header\", ModalHeaderProps>(\n \"header\",\n \"header\",\n)(undefined, (props) => {\n const { getHeaderProps, headerProps } = useComponentContext()\n\n return { ...getHeaderProps(mergeProps(headerProps, props)()) }\n})\n\nexport interface ModalTitleProps extends HTMLStyledProps<\"h2\"> {}\n\nexport const ModalTitle = withContext<\"h2\", ModalTitleProps>(\"h2\", \"title\")(\n undefined,\n (props) => {\n const { getTitleProps, titleProps } = useComponentContext()\n\n return { ...getTitleProps(mergeProps(titleProps, props)()) }\n },\n)\n\nexport interface ModalBodyProps extends HTMLStyledProps {}\n\nexport const ModalBody = withContext<\"div\", ModalBodyProps>(\"div\", \"body\")(\n undefined,\n (props) => {\n const { bodyProps, getBodyProps } = useComponentContext()\n\n return { ...getBodyProps(mergeProps(bodyProps, props)()) }\n },\n)\n\nexport interface ModalFooterProps extends HTMLStyledProps<\"footer\"> {}\n\nexport const ModalFooter = withContext<\"footer\", ModalFooterProps>(\n \"footer\",\n \"footer\",\n)(undefined, (props) => {\n const { footerProps, getFooterProps } = useComponentContext()\n\n return { ...getFooterProps(mergeProps(footerProps, props)()) }\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAuIA,MAAM,EACJ,kBACA,cAAc,mBACd,qBACA,iBAAiB,sBACjB,aACA,iBACE,oBACF,SACA,UACF;;;;;;AASA,MAAa,YAAY,cACtB,EACC,iBAAiB,OACjB,kBAAkB,SAClB,WACA,qBAAqB,MACrB,MACA,QACA,UACA,UACA,eACA,QACA,QACA,iBACA,wBAAwB,MACxB,QACA,cACA,SACA,OACA,SACA,kBAAkB,MAClB,cAAc,MACd,WACA,kBACA,mBACA,cACA,aACA,aACA,kBACA,cACA,aACA,YACA,UACA,iBACA,UACA,WACA,GAAG,YACC;CACJ,MAAM,CAAC,iBAAiB,aAAa,iBAAiB,iBACpD,UACA,kBACA,YACF;CACA,MAAM,eAAA,GAAA,cAAA,QAAA,CAAsB,eAAe,KAAK,CAAC,CAAC,gBAAgB;CAClE,MAAM,EAAE,MAAM,cAAc,GAAG,SAAS,SAAS,KAAK;CACtD,MAAM,oBAAoB,UACxB,oBAAC,kBAAD,EAAA,UAAmB,QAA0B,CAAA,IAC3C;CACJ,MAAM,UAAU,eACP;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,GAAG;CACL,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AAM,EAAE,aAAa,mBAAmB,oBAAoB;CAE5D,OAAO,EAAE,GAAG,eAAe,WAAW,aAAa,KAAK,CAAC,CAAC,CAAC,EAAE;AAC/D,CAAC"}
@@ -25,7 +25,8 @@ const useFocusOnShow = (refOrEl, { focusTarget: focusRefOrEl, preventScroll, sho
25
25
  const onFocus = useCallback(() => {
26
26
  const target = getTarget();
27
27
  if (!target || !trulyShouldFocus || focused.current) return;
28
- if (target.contains(document.activeElement)) return;
28
+ const rootNode = target.getRootNode();
29
+ if ((0, utils_exports.contains)(target, (0, utils_exports.getActiveElement)((0, utils_exports.isShadowRoot)(rootNode) ? rootNode : (0, utils_exports.getDocument)(target)))) return;
29
30
  const focusTarget = getFocusTarget();
30
31
  if (focusTarget) requestAnimationFrame(() => {
31
32
  focusTarget.focus({ preventScroll });
@@ -62,14 +63,17 @@ const useFocusOnShow = (refOrEl, { focusTarget: focusRefOrEl, preventScroll, sho
62
63
  * @see https://yamada-ui.com/docs/hooks/use-focus-on-pointer-down
63
64
  */
64
65
  const useFocusOnPointerDown = ({ ref, elements, enabled }) => {
65
- useEventListener(() => (0, utils_exports.getDocument)(ref.current), "pointerdown", (ev) => {
66
+ useEventListener(() => ref.current?.getRootNode() ?? (0, utils_exports.getDocument)(ref.current), "pointerdown", (ev) => {
66
67
  if (!(0, utils_exports.isSafari)() || !enabled) return;
67
68
  const target = ev.target;
68
- const validTarget = (elements ?? [ref]).some((elOrRef) => {
69
+ const els = elements ?? [ref];
70
+ const rootNode = ref.current?.getRootNode();
71
+ const root = (0, utils_exports.isShadowRoot)(rootNode) ? rootNode : (0, utils_exports.getDocument)(ref.current);
72
+ const validTarget = els.some((elOrRef) => {
69
73
  const el = isRefObject(elOrRef) ? elOrRef.current : elOrRef;
70
74
  return el?.contains(target) || el === target;
71
75
  });
72
- if ((0, utils_exports.getActiveElement)((0, utils_exports.getDocument)(ref.current)) !== target && validTarget) {
76
+ if ((0, utils_exports.getActiveElement)(root) !== target && validTarget) {
73
77
  ev.preventDefault();
74
78
  target.focus();
75
79
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../../src/hooks/use-focus/index.ts"],"sourcesContent":["\"use client\"\n\nimport type { RefObject } from \"react\"\nimport { useCallback, useRef } from \"react\"\nimport {\n getActiveElement,\n getDocument,\n getFirstFocusableElement,\n isRefObject,\n isSafari,\n useUpdateEffect,\n} from \"../../utils\"\nimport { useEventListener } from \"../use-event-listener\"\n\nexport interface UseFocusOnShowProps {\n focusTarget?: HTMLElement | null | RefObject<HTMLElement | null>\n preventScroll?: boolean\n shouldFocus?: boolean\n visible?: boolean\n}\n\n/**\n * `useFocusOnShow` is a custom hook that focuses on the target element when it is shown.\n *\n * @see https://yamada-ui.com/docs/hooks/use-focus-on-show\n */\nexport const useFocusOnShow = <Y extends HTMLElement>(\n refOrEl: RefObject<null | Y> | Y,\n {\n focusTarget: focusRefOrEl,\n preventScroll,\n shouldFocus,\n visible,\n }: UseFocusOnShowProps = {\n preventScroll: true,\n shouldFocus: false,\n },\n) => {\n const trulyShouldFocus = shouldFocus && visible\n const focused = useRef(false)\n\n const getTarget = useCallback(() => {\n return isRefObject(refOrEl) ? refOrEl.current : refOrEl\n }, [refOrEl])\n\n const getFocusTarget = useCallback(() => {\n return isRefObject(focusRefOrEl) ? focusRefOrEl.current : focusRefOrEl\n }, [focusRefOrEl])\n\n const onFocus = useCallback(() => {\n const target = getTarget()\n\n if (!target || !trulyShouldFocus || focused.current) return\n if (target.contains(document.activeElement)) return\n\n const focusTarget = getFocusTarget()\n\n if (focusTarget) {\n requestAnimationFrame(() => {\n focusTarget.focus({ preventScroll })\n\n focused.current = true\n })\n } else {\n const firstFocusable = getFirstFocusableElement(target)\n\n if (firstFocusable)\n requestAnimationFrame(() => {\n firstFocusable.focus({ preventScroll })\n\n focused.current = true\n })\n else\n requestAnimationFrame(() => {\n target.focus({ preventScroll })\n\n focused.current = true\n })\n }\n }, [getTarget, trulyShouldFocus, getFocusTarget, preventScroll])\n\n useUpdateEffect(() => {\n focused.current = !trulyShouldFocus\n }, [trulyShouldFocus])\n\n useUpdateEffect(() => {\n requestAnimationFrame(onFocus)\n }, [onFocus])\n\n useEventListener(getTarget, \"transitionend\", onFocus)\n}\n\nexport interface UseFocusOnMouseDownProps {\n ref: RefObject<HTMLElement | null>\n elements?: (HTMLElement | null | RefObject<HTMLElement | null>)[]\n enabled?: boolean\n}\n\n/**\n * `useFocusOnPointerDown` is a custom hook that focuses on the target element when it is clicked.\n *\n * @see https://yamada-ui.com/docs/hooks/use-focus-on-pointer-down\n */\nexport const useFocusOnPointerDown = ({\n ref,\n elements,\n enabled,\n}: UseFocusOnMouseDownProps) => {\n useEventListener(\n () => getDocument(ref.current),\n \"pointerdown\",\n (ev) => {\n if (!isSafari() || !enabled) return\n const target = ev.target as HTMLElement\n\n const els = elements ?? [ref]\n\n const validTarget = els.some((elOrRef) => {\n const el = isRefObject(elOrRef) ? elOrRef.current : elOrRef\n\n return el?.contains(target) || el === target\n })\n\n if (\n getActiveElement(getDocument(ref.current)) !== target &&\n validTarget\n ) {\n ev.preventDefault()\n\n target.focus()\n }\n },\n )\n}\n"],"mappings":";;;;;;;;;;;;AA0BA,MAAa,kBACX,SACA,EACE,aAAa,cACb,eACA,aACA,YACuB;CACvB,eAAe;CACf,aAAa;AACf,MACG;CACH,MAAM,mBAAmB,eAAe;CACxC,MAAM,UAAU,OAAO,KAAK;CAE5B,MAAM,YAAY,kBAAkB;EAClC,OAAO,YAAY,OAAO,IAAI,QAAQ,UAAU;CAClD,GAAG,CAAC,OAAO,CAAC;CAEZ,MAAM,iBAAiB,kBAAkB;EACvC,OAAO,YAAY,YAAY,IAAI,aAAa,UAAU;CAC5D,GAAG,CAAC,YAAY,CAAC;CAEjB,MAAM,UAAU,kBAAkB;EAChC,MAAM,SAAS,UAAU;EAEzB,IAAI,CAAC,UAAU,CAAC,oBAAoB,QAAQ,SAAS;EACrD,IAAI,OAAO,SAAS,SAAS,aAAa,GAAG;EAE7C,MAAM,cAAc,eAAe;EAEnC,IAAI,aACF,4BAA4B;GAC1B,YAAY,MAAM,EAAE,cAAc,CAAC;GAEnC,QAAQ,UAAU;EACpB,CAAC;OACI;GACL,MAAM,kBAAA,GAAA,cAAA,yBAAA,CAA0C,MAAM;GAEtD,IAAI,gBACF,4BAA4B;IAC1B,eAAe,MAAM,EAAE,cAAc,CAAC;IAEtC,QAAQ,UAAU;GACpB,CAAC;QAED,4BAA4B;IAC1B,OAAO,MAAM,EAAE,cAAc,CAAC;IAE9B,QAAQ,UAAU;GACpB,CAAC;EACL;CACF,GAAG;EAAC;EAAW;EAAkB;EAAgB;CAAa,CAAC;CAE/D,sBAAsB;EACpB,QAAQ,UAAU,CAAC;CACrB,GAAG,CAAC,gBAAgB,CAAC;CAErB,sBAAsB;EACpB,sBAAsB,OAAO;CAC/B,GAAG,CAAC,OAAO,CAAC;CAEZ,iBAAiB,WAAW,iBAAiB,OAAO;AACtD;;;;;;AAaA,MAAa,yBAAyB,EACpC,KACA,UACA,cAC8B;CAC9B,wBAAA,GAAA,cAAA,YAAA,CACoB,IAAI,OAAO,GAC7B,gBACC,OAAO;EACN,IAAI,EAAA,GAAA,cAAA,SAAA,CAAU,KAAK,CAAC,SAAS;EAC7B,MAAM,SAAS,GAAG;EAIlB,MAAM,eAFM,YAAY,CAAC,GAAG,EAAA,CAEJ,MAAM,YAAY;GACxC,MAAM,KAAK,YAAY,OAAO,IAAI,QAAQ,UAAU;GAEpD,OAAO,IAAI,SAAS,MAAM,KAAK,OAAO;EACxC,CAAC;EAED,KAAA,GAAA,cAAA,iBAAA,EAAA,GAAA,cAAA,YAAA,CAC+B,IAAI,OAAO,CAAC,MAAM,UAC/C,aACA;GACA,GAAG,eAAe;GAElB,OAAO,MAAM;EACf;CACF,CACF;AACF"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../../src/hooks/use-focus/index.ts"],"sourcesContent":["\"use client\"\n\nimport type { RefObject } from \"react\"\nimport { useCallback, useRef } from \"react\"\nimport {\n contains,\n getActiveElement,\n getDocument,\n getFirstFocusableElement,\n isRefObject,\n isSafari,\n isShadowRoot,\n useUpdateEffect,\n} from \"../../utils\"\nimport { useEventListener } from \"../use-event-listener\"\n\nexport interface UseFocusOnShowProps {\n focusTarget?: HTMLElement | null | RefObject<HTMLElement | null>\n preventScroll?: boolean\n shouldFocus?: boolean\n visible?: boolean\n}\n\n/**\n * `useFocusOnShow` is a custom hook that focuses on the target element when it is shown.\n *\n * @see https://yamada-ui.com/docs/hooks/use-focus-on-show\n */\nexport const useFocusOnShow = <Y extends HTMLElement>(\n refOrEl: RefObject<null | Y> | Y,\n {\n focusTarget: focusRefOrEl,\n preventScroll,\n shouldFocus,\n visible,\n }: UseFocusOnShowProps = {\n preventScroll: true,\n shouldFocus: false,\n },\n) => {\n const trulyShouldFocus = shouldFocus && visible\n const focused = useRef(false)\n\n const getTarget = useCallback(() => {\n return isRefObject(refOrEl) ? refOrEl.current : refOrEl\n }, [refOrEl])\n\n const getFocusTarget = useCallback(() => {\n return isRefObject(focusRefOrEl) ? focusRefOrEl.current : focusRefOrEl\n }, [focusRefOrEl])\n\n const onFocus = useCallback(() => {\n const target = getTarget()\n\n if (!target || !trulyShouldFocus || focused.current) return\n const rootNode = target.getRootNode()\n const root = isShadowRoot(rootNode) ? rootNode : getDocument(target)\n if (contains(target, getActiveElement(root))) return\n\n const focusTarget = getFocusTarget()\n\n if (focusTarget) {\n requestAnimationFrame(() => {\n focusTarget.focus({ preventScroll })\n\n focused.current = true\n })\n } else {\n const firstFocusable = getFirstFocusableElement(target)\n\n if (firstFocusable)\n requestAnimationFrame(() => {\n firstFocusable.focus({ preventScroll })\n\n focused.current = true\n })\n else\n requestAnimationFrame(() => {\n target.focus({ preventScroll })\n\n focused.current = true\n })\n }\n }, [getTarget, trulyShouldFocus, getFocusTarget, preventScroll])\n\n useUpdateEffect(() => {\n focused.current = !trulyShouldFocus\n }, [trulyShouldFocus])\n\n useUpdateEffect(() => {\n requestAnimationFrame(onFocus)\n }, [onFocus])\n\n useEventListener(getTarget, \"transitionend\", onFocus)\n}\n\nexport interface UseFocusOnMouseDownProps {\n ref: RefObject<HTMLElement | null>\n elements?: (HTMLElement | null | RefObject<HTMLElement | null>)[]\n enabled?: boolean\n}\n\n/**\n * `useFocusOnPointerDown` is a custom hook that focuses on the target element when it is clicked.\n *\n * @see https://yamada-ui.com/docs/hooks/use-focus-on-pointer-down\n */\nexport const useFocusOnPointerDown = ({\n ref,\n elements,\n enabled,\n}: UseFocusOnMouseDownProps) => {\n useEventListener(\n () => ref.current?.getRootNode() ?? getDocument(ref.current),\n \"pointerdown\",\n (ev) => {\n if (!isSafari() || !enabled) return\n\n const target = ev.target as HTMLElement\n const els = elements ?? [ref]\n const rootNode = ref.current?.getRootNode()\n const root = isShadowRoot(rootNode) ? rootNode : getDocument(ref.current)\n const validTarget = els.some((elOrRef) => {\n const el = isRefObject(elOrRef) ? elOrRef.current : elOrRef\n\n return el?.contains(target) || el === target\n })\n\n if (getActiveElement(root) !== target && validTarget) {\n ev.preventDefault()\n\n target.focus()\n }\n },\n )\n}\n"],"mappings":";;;;;;;;;;;;AA4BA,MAAa,kBACX,SACA,EACE,aAAa,cACb,eACA,aACA,YACuB;CACvB,eAAe;CACf,aAAa;AACf,MACG;CACH,MAAM,mBAAmB,eAAe;CACxC,MAAM,UAAU,OAAO,KAAK;CAE5B,MAAM,YAAY,kBAAkB;EAClC,OAAO,YAAY,OAAO,IAAI,QAAQ,UAAU;CAClD,GAAG,CAAC,OAAO,CAAC;CAEZ,MAAM,iBAAiB,kBAAkB;EACvC,OAAO,YAAY,YAAY,IAAI,aAAa,UAAU;CAC5D,GAAG,CAAC,YAAY,CAAC;CAEjB,MAAM,UAAU,kBAAkB;EAChC,MAAM,SAAS,UAAU;EAEzB,IAAI,CAAC,UAAU,CAAC,oBAAoB,QAAQ,SAAS;EACrD,MAAM,WAAW,OAAO,YAAY;EAEpC,KAAA,GAAA,cAAA,SAAA,CAAa,SAAA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AAK,OAAO;EACxC,CAAC;EAED,KAAA,GAAA,cAAA,iBAAA,CAAqB,IAAI,MAAM,UAAU,aAAa;GACpD,GAAG,eAAe;GAElB,OAAO,MAAM;EACf;CACF,CACF;AACF"}
@@ -1,4 +1,5 @@
1
1
  import * as React from "react";
2
+ import { getActiveElement } from "@yamada-ui/utils";
2
3
  //#region src/utils/dom.ts
3
4
  function runKeyAction(ev, actions, { preventDefault = true } = {}) {
4
5
  if (ev.key === " ") ev.key = ev.code;
@@ -30,7 +31,9 @@ function useAttributeObserver(ref, attributeFilter, enabled, func) {
30
31
  });
31
32
  }
32
33
  function getEventRelatedTarget(ev) {
33
- return ev.relatedTarget ?? ev.currentTarget.ownerDocument.activeElement;
34
+ if (ev.relatedTarget) return ev.relatedTarget;
35
+ const root = ev.currentTarget.getRootNode?.call(ev.currentTarget);
36
+ return (root && getActiveElement(root)) ?? ev.currentTarget.ownerDocument.activeElement;
34
37
  }
35
38
  const visuallyHiddenAttributes = {
36
39
  style: {
@@ -1 +1 @@
1
- {"version":3,"file":"dom.js","names":[],"sources":["../../../src/utils/dom.ts"],"sourcesContent":["import type { AnyString } from \"@yamada-ui/utils\"\nimport * as React from \"react\"\n\ntype KeyboardNavigationKey =\n | \"ArrowDown\"\n | \"ArrowLeft\"\n | \"ArrowRight\"\n | \"ArrowUp\"\n | \"End\"\n | \"Home\"\n | \"PageDown\"\n | \"PageUp\"\n\ntype KeyboardControlKey =\n | \"Alt\"\n | \"Backspace\"\n | \"CapsLock\"\n | \"Control\"\n | \"Delete\"\n | \"Enter\"\n | \"Escape\"\n | \"Insert\"\n | \"Meta\"\n | \"NumLock\"\n | \"Pause\"\n | \"PrintScreen\"\n | \"ScrollLock\"\n | \"Shift\"\n | \"Space\"\n | \"Tab\"\n\ntype KeyboardFunctionKey = \"Fn\" | \"FnLock\" | `F${number}`\n\ntype KeyboardKey =\n | AnyString\n | KeyboardControlKey\n | KeyboardFunctionKey\n | KeyboardNavigationKey\n\nexport function runKeyAction<Y>(\n ev: React.KeyboardEvent<Y>,\n actions: { [key in KeyboardKey]?: React.KeyboardEventHandler<Y> },\n { preventDefault = true }: { preventDefault?: boolean } = {},\n) {\n if (ev.key === \" \") ev.key = ev.code\n const action = actions[ev.key]\n\n if (!action) return\n\n if (preventDefault) ev.preventDefault()\n\n action(ev)\n}\n\nexport function isComposing(\n ev: React.ChangeEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>,\n): boolean {\n if (\"keyCode\" in ev) return ev.nativeEvent.isComposing || ev.keyCode === 229\n else if (ev.nativeEvent instanceof InputEvent)\n return ev.nativeEvent.isComposing\n else return false\n}\n\nexport function useAttributeObserver(\n ref: React.RefObject<HTMLElement | null>,\n attributeFilter: string[],\n enabled: boolean,\n func: () => void,\n) {\n React.useEffect(() => {\n if (!ref.current || !enabled) return\n\n const ownerDocument = ref.current.ownerDocument.defaultView ?? window\n\n const observer = new ownerDocument.MutationObserver((changes) => {\n for (const { type, attributeName } of changes) {\n if (type !== \"attributes\") continue\n if (!attributeName) continue\n\n if (attributeFilter.includes(attributeName)) func()\n }\n })\n\n observer.observe(ref.current, { attributeFilter, attributes: true })\n\n return () => observer.disconnect()\n })\n}\n\nexport function getEventRelatedTarget(ev: React.FocusEvent | React.MouseEvent) {\n return (ev.relatedTarget ??\n ev.currentTarget.ownerDocument.activeElement) as HTMLElement | null\n}\n\nconst visuallyHiddenStyle = {\n border: \"0px\",\n clipPath: \"rect(0px 0px 0px 0px)\",\n height: \"1px\",\n margin: \"-1px\",\n overflow: \"hidden\",\n padding: \"0px\",\n position: \"absolute\",\n whiteSpace: \"nowrap\",\n width: \"1px\",\n} satisfies React.CSSProperties\n\nexport const visuallyHiddenAttributes = {\n style: visuallyHiddenStyle,\n \"aria-hidden\": true,\n tabIndex: -1,\n} satisfies React.HTMLAttributes<HTMLElement>\n\nexport function* useIds() {\n const id = React.useId()\n\n for (let i = 0; ; i++) yield `${id}-${i}`\n}\n"],"mappings":";;AAuCA,SAAgB,aACd,IACA,S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getActiveElement } from \"@yamada-ui/utils\"\nimport * as React from \"react\"\n\ntype KeyboardNavigationKey =\n | \"ArrowDown\"\n | \"ArrowLeft\"\n | \"ArrowRight\"\n | \"ArrowUp\"\n | \"End\"\n | \"Home\"\n | \"PageDown\"\n | \"PageUp\"\n\ntype KeyboardControlKey =\n | \"Alt\"\n | \"Backspace\"\n | \"CapsLock\"\n | \"Control\"\n | \"Delete\"\n | \"Enter\"\n | \"Escape\"\n | \"Insert\"\n | \"Meta\"\n | \"NumLock\"\n | \"Pause\"\n | \"PrintScreen\"\n | \"ScrollLock\"\n | \"Shift\"\n | \"Space\"\n | \"Tab\"\n\ntype KeyboardFunctionKey = \"Fn\" | \"FnLock\" | `F${number}`\n\ntype KeyboardKey =\n | AnyString\n | KeyboardControlKey\n | KeyboardFunctionKey\n | KeyboardNavigationKey\n\nexport function runKeyAction<Y>(\n ev: React.KeyboardEvent<Y>,\n actions: { [key in KeyboardKey]?: React.KeyboardEventHandler<Y> },\n { preventDefault = true }: { preventDefault?: boolean } = {},\n) {\n if (ev.key === \" \") ev.key = ev.code\n const action = actions[ev.key]\n\n if (!action) return\n\n if (preventDefault) ev.preventDefault()\n\n action(ev)\n}\n\nexport function isComposing(\n ev: React.ChangeEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>,\n): boolean {\n if (\"keyCode\" in ev) return ev.nativeEvent.isComposing || ev.keyCode === 229\n else if (ev.nativeEvent instanceof InputEvent)\n return ev.nativeEvent.isComposing\n else return false\n}\n\nexport function useAttributeObserver(\n ref: React.RefObject<HTMLElement | null>,\n attributeFilter: string[],\n enabled: boolean,\n func: () => void,\n) {\n React.useEffect(() => {\n if (!ref.current || !enabled) return\n\n const ownerDocument = ref.current.ownerDocument.defaultView ?? window\n\n const observer = new ownerDocument.MutationObserver((changes) => {\n for (const { type, attributeName } of changes) {\n if (type !== \"attributes\") continue\n if (!attributeName) continue\n\n if (attributeFilter.includes(attributeName)) func()\n }\n })\n\n observer.observe(ref.current, { attributeFilter, attributes: true })\n\n return () => observer.disconnect()\n })\n}\n\nexport function getEventRelatedTarget(ev: React.FocusEvent | React.MouseEvent) {\n if (ev.relatedTarget) return ev.relatedTarget as HTMLElement\n\n const getRootNode = (\n ev.currentTarget as unknown as {\n getRootNode?: () => Document | ShadowRoot\n }\n ).getRootNode\n const root = getRootNode?.call(ev.currentTarget)\n\n return ((root && getActiveElement(root)) ??\n ev.currentTarget.ownerDocument.activeElement) as HTMLElement | null\n}\n\nconst visuallyHiddenStyle = {\n border: \"0px\",\n clipPath: \"rect(0px 0px 0px 0px)\",\n height: \"1px\",\n margin: \"-1px\",\n overflow: \"hidden\",\n padding: \"0px\",\n position: \"absolute\",\n whiteSpace: \"nowrap\",\n width: \"1px\",\n} satisfies React.CSSProperties\n\nexport const visuallyHiddenAttributes = {\n style: visuallyHiddenStyle,\n \"aria-hidden\": true,\n tabIndex: -1,\n} satisfies React.HTMLAttributes<HTMLElement>\n\nexport function* useIds() {\n const id = React.useId()\n\n for (let i = 0; ; i++) yield `${id}-${i}`\n}\n"],"mappings":";;;AAuCA,SAAgB,aACd,IACA,SACA,EAAE,iBAAiB,SAAuC,CAAC,GAC3D;CACA,IAAI,GAAG,QAAQ,KAAK,GAAG,MAAM,GAAG;CAChC,MAAM,SAAS,QAAQ,GAAG;CAE1B,IAAI,CAAC,QAAQ;CAEb,IAAI,gBAAgB,GAAG,eAAe;CAEtC,OAAO,EAAE;AACX;AAEA,SAAgB,YACd,IACS;CACT,IAAI,aAAa,IAAI,OAAO,GAAG,YAAY,eAAe,GAAG,YAAY;MACpE,IAAI,GAAG,uBAAuB,YACjC,OAAO,GAAG,YAAY;MACnB,OAAO;AACd;AAEA,SAAgB,qBACd,KACA,iBACA,SACA,MACA;CACA,MAAM,gBAAgB;EACpB,IAAI,CAAC,IAAI,WAAW,CAAC,SAAS;EAI9B,MAAM,WAAW,KAFK,IAAI,QAAQ,cAAc,eAAe,OAAA,CAE5B,kBAAkB,YAAY;GAC/D,KAAK,MAAM,EAAE,MAAM,mBAAmB,SAAS;IAC7C,IAAI,SAAS,cAAc;IAC3B,IAAI,CAAC,eAAe;IAEpB,IAAI,gBAAgB,SAAS,aAAa,GAAG,KAAK;GACpD;EACF,CAAC;EAED,SAAS,QAAQ,IAAI,SAAS;GAAE;GAAiB,YAAY;EAAK,CAAC;EAEnE,aAAa,SAAS,WAAW;CACnC,CAAC;AACH;AAEA,SAAgB,sBAAsB,IAAyC;CAC7E,IAAI,GAAG,eAAe,OAAO,GAAG;CAOhC,MAAM,OAJJ,GAAG,cAGH,aACwB,KAAK,GAAG,aAAa;CAE/C,QAAS,QAAQ,iBAAiB,IAAI,MACpC,GAAG,cAAc,cAAc;AACnC;AAcA,MAAa,2BAA2B;CACtC,OAAO;EAZP,QAAQ;EACR,UAAU;EACV,QAAQ;EACR,QAAQ;EACR,UAAU;EACV,SAAS;EACT,UAAU;EACV,YAAY;EACZ,OAAO;CAIA;CACP,eAAe;CACf,UAAU;AACZ;AAEA,UAAiB,SAAS;CACxB,MAAM,KAAK,MAAM,MAAM;CAEvB,KAAK,IAAI,IAAI,IAAK,KAAK,MAAM,GAAG,GAAG,GAAG;AACxC"}
@@ -2,7 +2,7 @@ import { ComponentSlotStyle } from "../../core/system/index.types.js";
2
2
  import { CSSModifierObject, CSSPropObject, CSSSlotObject } from "../../core/css/index.types.js";
3
3
  import "../../index.js";
4
4
  //#region src/components/chart/cartesian-chart.style.d.ts
5
- declare const cartesianChartStyle: ComponentSlotStyle<"area" | "line" | "grid" | "bar" | "dot" | "root" | "labelList" | "activeDot" | "referenceLine" | "referenceLineLabel" | "xAxis" | "xAxisLabel" | "xAxisTick" | "xAxisTickLine" | "yAxis" | "yAxisLabel" | "yAxisTick" | "yAxisTickLine", CSSPropObject<CSSSlotObject<"area" | "line" | "grid" | "bar" | "dot" | "root" | "labelList" | "activeDot" | "referenceLine" | "referenceLineLabel" | "xAxis" | "xAxisLabel" | "xAxisTick" | "xAxisTickLine" | "yAxis" | "yAxisLabel" | "yAxisTick" | "yAxisTickLine">>, CSSModifierObject<CSSSlotObject<"area" | "line" | "grid" | "bar" | "dot" | "root" | "labelList" | "activeDot" | "referenceLine" | "referenceLineLabel" | "xAxis" | "xAxisLabel" | "xAxisTick" | "xAxisTickLine" | "yAxis" | "yAxisLabel" | "yAxisTick" | "yAxisTickLine">>, CSSModifierObject<CSSSlotObject<"area" | "line" | "grid" | "bar" | "dot" | "root" | "labelList" | "activeDot" | "referenceLine" | "referenceLineLabel" | "xAxis" | "xAxisLabel" | "xAxisTick" | "xAxisTickLine" | "yAxis" | "yAxisLabel" | "yAxisTick" | "yAxisTickLine">>>;
5
+ declare const cartesianChartStyle: ComponentSlotStyle<"area" | "line" | "grid" | "bar" | "dot" | "root" | "activeDot" | "labelList" | "referenceLine" | "referenceLineLabel" | "xAxis" | "xAxisLabel" | "xAxisTick" | "xAxisTickLine" | "yAxis" | "yAxisLabel" | "yAxisTick" | "yAxisTickLine", CSSPropObject<CSSSlotObject<"area" | "line" | "grid" | "bar" | "dot" | "root" | "activeDot" | "labelList" | "referenceLine" | "referenceLineLabel" | "xAxis" | "xAxisLabel" | "xAxisTick" | "xAxisTickLine" | "yAxis" | "yAxisLabel" | "yAxisTick" | "yAxisTickLine">>, CSSModifierObject<CSSSlotObject<"area" | "line" | "grid" | "bar" | "dot" | "root" | "activeDot" | "labelList" | "referenceLine" | "referenceLineLabel" | "xAxis" | "xAxisLabel" | "xAxisTick" | "xAxisTickLine" | "yAxis" | "yAxisLabel" | "yAxisTick" | "yAxisTickLine">>, CSSModifierObject<CSSSlotObject<"area" | "line" | "grid" | "bar" | "dot" | "root" | "activeDot" | "labelList" | "referenceLine" | "referenceLineLabel" | "xAxis" | "xAxisLabel" | "xAxisTick" | "xAxisTickLine" | "yAxis" | "yAxisLabel" | "yAxisTick" | "yAxisTickLine">>>;
6
6
  type CartesianChartStyle = typeof cartesianChartStyle;
7
7
  //#endregion
8
8
  export { CartesianChartStyle, cartesianChartStyle };
@@ -2,7 +2,7 @@ import { ComponentSlotStyle } from "../../core/system/index.types.js";
2
2
  import { CSSModifierObject, CSSPropObject, CSSSlotObject } from "../../core/css/index.types.js";
3
3
  import "../../index.js";
4
4
  //#region src/components/chart/polar-chart.style.d.ts
5
- declare const polarChartStyle: ComponentSlotStyle<"label" | "grid" | "dot" | "root" | "labelList" | "activeDot" | "radial" | "labelLine" | "angleAxis" | "angleAxisLabel" | "angleAxisLine" | "angleAxisTick" | "angleAxisTickLine" | "pie" | "radar" | "radialBackground" | "radiusAxis" | "radiusAxisLabel" | "radiusAxisLine" | "radiusAxisTick" | "radiusAxisTickLine" | "sector", CSSPropObject<CSSSlotObject<"label" | "grid" | "dot" | "root" | "labelList" | "activeDot" | "radial" | "labelLine" | "angleAxis" | "angleAxisLabel" | "angleAxisLine" | "angleAxisTick" | "angleAxisTickLine" | "pie" | "radar" | "radialBackground" | "radiusAxis" | "radiusAxisLabel" | "radiusAxisLine" | "radiusAxisTick" | "radiusAxisTickLine" | "sector">>, CSSModifierObject<CSSSlotObject<"label" | "grid" | "dot" | "root" | "labelList" | "activeDot" | "radial" | "labelLine" | "angleAxis" | "angleAxisLabel" | "angleAxisLine" | "angleAxisTick" | "angleAxisTickLine" | "pie" | "radar" | "radialBackground" | "radiusAxis" | "radiusAxisLabel" | "radiusAxisLine" | "radiusAxisTick" | "radiusAxisTickLine" | "sector">>, CSSModifierObject<CSSSlotObject<"label" | "grid" | "dot" | "root" | "labelList" | "activeDot" | "radial" | "labelLine" | "angleAxis" | "angleAxisLabel" | "angleAxisLine" | "angleAxisTick" | "angleAxisTickLine" | "pie" | "radar" | "radialBackground" | "radiusAxis" | "radiusAxisLabel" | "radiusAxisLine" | "radiusAxisTick" | "radiusAxisTickLine" | "sector">>>;
5
+ declare const polarChartStyle: ComponentSlotStyle<"label" | "grid" | "dot" | "root" | "activeDot" | "angleAxis" | "angleAxisLabel" | "angleAxisLine" | "angleAxisTick" | "angleAxisTickLine" | "labelLine" | "labelList" | "pie" | "radar" | "radial" | "radialBackground" | "radiusAxis" | "radiusAxisLabel" | "radiusAxisLine" | "radiusAxisTick" | "radiusAxisTickLine" | "sector", CSSPropObject<CSSSlotObject<"label" | "grid" | "dot" | "root" | "activeDot" | "angleAxis" | "angleAxisLabel" | "angleAxisLine" | "angleAxisTick" | "angleAxisTickLine" | "labelLine" | "labelList" | "pie" | "radar" | "radial" | "radialBackground" | "radiusAxis" | "radiusAxisLabel" | "radiusAxisLine" | "radiusAxisTick" | "radiusAxisTickLine" | "sector">>, CSSModifierObject<CSSSlotObject<"label" | "grid" | "dot" | "root" | "activeDot" | "angleAxis" | "angleAxisLabel" | "angleAxisLine" | "angleAxisTick" | "angleAxisTickLine" | "labelLine" | "labelList" | "pie" | "radar" | "radial" | "radialBackground" | "radiusAxis" | "radiusAxisLabel" | "radiusAxisLine" | "radiusAxisTick" | "radiusAxisTickLine" | "sector">>, CSSModifierObject<CSSSlotObject<"label" | "grid" | "dot" | "root" | "activeDot" | "angleAxis" | "angleAxisLabel" | "angleAxisLine" | "angleAxisTick" | "angleAxisTickLine" | "labelLine" | "labelList" | "pie" | "radar" | "radial" | "radialBackground" | "radiusAxis" | "radiusAxisLabel" | "radiusAxisLine" | "radiusAxisTick" | "radiusAxisTickLine" | "sector">>>;
6
6
  type PolarChartStyle = typeof polarChartStyle;
7
7
  //#endregion
8
8
  export { PolarChartStyle, polarChartStyle };
@@ -16,7 +16,7 @@ import "../focus-lock/index.js";
16
16
  import { ModalStyle } from "./modal.style.js";
17
17
  import { UseModalProps } from "./use-modal.js";
18
18
  import "../../index.js";
19
- import { FC, PropsWithChildren, ReactNode } from "react";
19
+ import { PropsWithChildren, ReactNode } from "react";
20
20
  //#region src/components/modal/modal.d.ts
21
21
  interface ModalRootProps extends Omit<HTMLStyledProps<"div">, "scrollBehavior" | "title">, ThemeProps<ModalStyle>, Omit<UseModalProps, "title">, Pick<FocusLockProps, "autoFocus" | "finalFocusRef" | "initialFocusRef" | "lockFocusAcrossFrames" | "restoreFocus">, UsePopupAnimationProps, ShorthandModalContentProps {
22
22
  /**
@@ -47,10 +47,46 @@ interface ModalRootProps extends Omit<HTMLStyledProps<"div">, "scrollBehavior" |
47
47
  * @default true
48
48
  */
49
49
  withOverlay?: boolean;
50
+ /**
51
+ * Props for body element.
52
+ */
53
+ bodyProps?: Omit<ModalBodyProps, "children">;
54
+ /**
55
+ * Props for close button element.
56
+ */
57
+ closeButtonProps?: Omit<ModalCloseButtonProps, "children">;
58
+ /**
59
+ * Props for close trigger element.
60
+ */
61
+ closeTriggerProps?: Omit<ModalCloseTriggerProps, "asChild" | "children">;
62
+ /**
63
+ * Props for content element.
64
+ */
65
+ contentProps?: Omit<ModalContentProps, "children">;
66
+ /**
67
+ * Props for footer element.
68
+ */
69
+ footerProps?: Omit<ModalFooterProps, "children">;
70
+ /**
71
+ * Props for header element.
72
+ */
73
+ headerProps?: Omit<ModalHeaderProps, "children">;
74
+ /**
75
+ * Props for open trigger element.
76
+ */
77
+ openTriggerProps?: Omit<ModalOpenTriggerProps, "asChild" | "children">;
78
+ /**
79
+ * Props for overlay element.
80
+ */
81
+ overlayProps?: Omit<ModalOverlayProps, "children">;
50
82
  /**
51
83
  * Props to be forwarded to the portal component.
52
84
  */
53
85
  portalProps?: Omit<PortalProps, "children">;
86
+ /**
87
+ * Props for title element.
88
+ */
89
+ titleProps?: Omit<ModalTitleProps, "children">;
54
90
  /**
55
91
  * Callback function to run side effects after the modal has closed.
56
92
  */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@yamada-ui/react",
3
3
  "type": "module",
4
- "version": "2.2.6-dev-20260730064602",
4
+ "version": "2.2.6-dev-20260730073118",
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",
@@ -147,7 +147,7 @@
147
147
  "scroll-into-view-if-needed": "^3.1.0",
148
148
  "sonner": "^2.0.7",
149
149
  "uqr": "^0.1.3",
150
- "@yamada-ui/utils": "2.1.6-dev-20260730064602"
150
+ "@yamada-ui/utils": "2.1.6-dev-20260730073118"
151
151
  },
152
152
  "devDependencies": {
153
153
  "@babel/parser": "^7.29.7",