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

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.
@@ -5,11 +5,11 @@ const require_factory = require("../../core/system/factory.cjs");
5
5
  const require_create_component = require("../../core/components/create-component.cjs");
6
6
  const require_factory$1 = require("../motion/factory.cjs");
7
7
  const require_hooks_use_value_index = require("../../hooks/use-value/index.cjs");
8
+ const require_focus_lock = require("../focus-lock/focus-lock.cjs");
8
9
  const require_portal = require("../portal/portal.cjs");
9
10
  const require_button = require("../button/button.cjs");
10
11
  const require_close_button = require("../close-button/close-button.cjs");
11
12
  const require_fade = require("../fade/fade.cjs");
12
- const require_focus_lock = require("../focus-lock/focus-lock.cjs");
13
13
  const require_drawer_style = require("./drawer.style.cjs");
14
14
  const require_slide = require("../slide/slide.cjs");
15
15
  const require_use_drawer = require("./use-drawer.cjs");
@@ -1,11 +1,16 @@
1
1
  "use client";
2
2
  const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
3
+ const require_context = require("../../utils/context.cjs");
3
4
  const require_utils_index = require("../../utils/index.cjs");
4
5
  let react = require("react");
5
6
  let react_jsx_runtime = require("react/jsx-runtime");
6
7
  let react_focus_lock = require("react-focus-lock");
7
8
  react_focus_lock = require_runtime.__toESM(react_focus_lock, 1);
8
9
  //#region src/components/focus-lock/focus-lock.tsx
10
+ const [FocusLockShardContext, useFocusLockShard] = require_context.createContext({
11
+ name: "FocusLockShardContext",
12
+ strict: false
13
+ });
9
14
  const InternalFocusLock = (0, require_utils_index.utils_exports.interopDefault)(react_focus_lock.default);
10
15
  /**
11
16
  * `FocusLock` is a component that improves accessibility by restricting focus within elements such as modals and dialogs, and locking the focus within that range.
@@ -13,7 +18,14 @@ const InternalFocusLock = (0, require_utils_index.utils_exports.interopDefault)(
13
18
  * @see https://yamada-ui.com/docs/components/focus-lock
14
19
  */
15
20
  const FocusLock = ({ autoFocus, children, contentRef, disabled, finalFocusRef, initialFocusRef, lockFocusAcrossFrames, persistentFocus, restoreFocus }) => {
21
+ const [shards, setShards] = (0, react.useState)([]);
16
22
  const returnFocus = restoreFocus && !finalFocusRef;
23
+ const registerShard = (0, react.useCallback)((shard) => {
24
+ setShards((prev) => prev.includes(shard) ? prev : [...prev, shard]);
25
+ return () => {
26
+ setShards((prev) => prev.filter((item) => item !== shard));
27
+ };
28
+ }, []);
17
29
  const onActivation = (0, react.useCallback)(() => {
18
30
  if (initialFocusRef?.current) initialFocusRef.current.focus();
19
31
  else if (contentRef?.current) {
@@ -25,18 +37,23 @@ const FocusLock = ({ autoFocus, children, contentRef, disabled, finalFocusRef, i
25
37
  const onDeactivation = (0, react.useCallback)(() => {
26
38
  finalFocusRef?.current?.focus();
27
39
  }, [finalFocusRef]);
28
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(InternalFocusLock, {
29
- autoFocus,
30
- crossFrame: lockFocusAcrossFrames,
31
- disabled,
32
- persistentFocus,
33
- returnFocus,
34
- onActivation,
35
- onDeactivation,
36
- children
40
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FocusLockShardContext, {
41
+ value: registerShard,
42
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(InternalFocusLock, {
43
+ autoFocus,
44
+ crossFrame: lockFocusAcrossFrames,
45
+ disabled,
46
+ persistentFocus,
47
+ returnFocus,
48
+ shards,
49
+ onActivation,
50
+ onDeactivation,
51
+ children
52
+ })
37
53
  });
38
54
  };
39
55
  //#endregion
40
56
  exports.FocusLock = FocusLock;
57
+ exports.useFocusLockShard = useFocusLockShard;
41
58
 
42
59
  //# sourceMappingURL=focus-lock.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"focus-lock.cjs","names":["ReactFocusLock"],"sources":["../../../../src/components/focus-lock/focus-lock.tsx"],"sourcesContent":["\"use client\"\n\nimport type { FC, PropsWithChildren, RefObject } from \"react\"\nimport { useCallback } from \"react\"\nimport ReactFocusLock from \"react-focus-lock\"\nimport { getFocusableElements, interopDefault } from \"../../utils\"\n\nconst InternalFocusLock = interopDefault(ReactFocusLock)\n\nexport interface FocusLockProps extends PropsWithChildren {\n /**\n * If `true`, the first focusable element within the `children` will auto-focused once `FocusLock` mounts.\n *\n * @default false\n */\n autoFocus?: boolean\n /**\n * The `ref` of the wrapper for which the focus-lock wraps.\n */\n contentRef?: RefObject<HTMLElement | null>\n /**\n * If `true`, focus trapping will be disabled.\n *\n * @default false\n */\n disabled?: boolean\n /**\n * `ref` of the element to return focus to when `FocusLock` unmounts.\n */\n finalFocusRef?: RefObject<HTMLElement | null>\n /**\n * `ref` of the element to receive focus initially.\n */\n initialFocusRef?: RefObject<HTMLElement | null>\n /**\n * Enables aggressive focus capturing within iframes.\n * - If `true`: keep focus in the lock, no matter where lock is active.\n * - If `false`: allows focus to move outside of iframe.\n *\n * @default false\n */\n lockFocusAcrossFrames?: boolean\n /**\n * If `true`, disables text selections inside, and outside focus lock.\n *\n * @default false\n */\n persistentFocus?: boolean\n /**\n * If `true`, focus will be restored to the element that triggered the `FocusLock` once it unmounts.\n *\n * @default false\n */\n restoreFocus?: boolean\n}\n\n/**\n * `FocusLock` is a component that improves accessibility by restricting focus within elements such as modals and dialogs, and locking the focus within that range.\n *\n * @see https://yamada-ui.com/docs/components/focus-lock\n */\nexport const FocusLock: FC<FocusLockProps> = ({\n autoFocus,\n children,\n contentRef,\n disabled,\n finalFocusRef,\n initialFocusRef,\n lockFocusAcrossFrames,\n persistentFocus,\n restoreFocus,\n}) => {\n const returnFocus = restoreFocus && !finalFocusRef\n\n const onActivation = useCallback(() => {\n if (initialFocusRef?.current) {\n initialFocusRef.current.focus()\n } else if (contentRef?.current) {\n const focusables = getFocusableElements(contentRef.current)\n\n if (focusables.length === 0)\n requestAnimationFrame(() => {\n contentRef.current?.focus()\n })\n }\n }, [initialFocusRef, contentRef])\n\n const onDeactivation = useCallback(() => {\n finalFocusRef?.current?.focus()\n }, [finalFocusRef])\n\n return (\n <InternalFocusLock\n autoFocus={autoFocus}\n crossFrame={lockFocusAcrossFrames}\n disabled={disabled}\n persistentFocus={persistentFocus}\n returnFocus={returnFocus}\n onActivation={onActivation}\n onDeactivation={onDeactivation}\n >\n {children}\n </InternalFocusLock>\n )\n}\n"],"mappings":";;;;;;;;AAOA,MAAM,qBAAA,GAAA,oBAAA,cAAA,eAAA,CAAmCA,iBAAAA,OAAc;;;;;;AAsDvD,MAAa,aAAiC,EAC5C,WACA,UACA,YACA,UACA,eACA,iBACA,uBACA,iBACA,mBACI;CACJ,MAAM,cAAc,gBAAgB,CAAC;CAErC,MAAM,gBAAA,GAAA,MAAA,YAAA,OAAiC;EACrC,IAAI,iBAAiB,SACnB,gBAAgB,QAAQ,MAAM;OACzB,IAAI,YAAY,SACmB;QAAA,GAAA,oBAAA,cAAA,qBAAA,CAAA,WAAW,OAEtC,CAAC,CAAC,WAAW,GACxB,4BAA4B;IAC1B,WAAW,SAAS,MAAM;GAC5B,CAAC;EAAA;CAEP,GAAG,CAAC,iBAAiB,UAAU,CAAC;CAEhC,MAAM,kBAAA,GAAA,MAAA,YAAA,OAAmC;EACvC,eAAe,SAAS,MAAM;CAChC,GAAG,CAAC,aAAa,CAAC;CAElB,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,mBAAD;EACa;EACX,YAAY;EACF;EACO;EACJ;EACC;EACE;EAEf;CACgB,CAAA;AAEvB"}
1
+ {"version":3,"file":"focus-lock.cjs","names":["createContext","ReactFocusLock"],"sources":["../../../../src/components/focus-lock/focus-lock.tsx"],"sourcesContent":["\"use client\"\n\nimport type { FC, PropsWithChildren, RefObject } from \"react\"\nimport { useCallback, useState } from \"react\"\nimport ReactFocusLock from \"react-focus-lock\"\nimport {\n createContext,\n getFocusableElements,\n interopDefault,\n} from \"../../utils\"\n\nconst [FocusLockShardContext, useFocusLockShard] = createContext<\n ((shard: HTMLElement) => () => void) | undefined\n>({ name: \"FocusLockShardContext\", strict: false })\n\nexport { useFocusLockShard }\n\nconst InternalFocusLock = interopDefault(ReactFocusLock)\n\nexport interface FocusLockProps extends PropsWithChildren {\n /**\n * If `true`, the first focusable element within the `children` will auto-focused once `FocusLock` mounts.\n *\n * @default false\n */\n autoFocus?: boolean\n /**\n * The `ref` of the wrapper for which the focus-lock wraps.\n */\n contentRef?: RefObject<HTMLElement | null>\n /**\n * If `true`, focus trapping will be disabled.\n *\n * @default false\n */\n disabled?: boolean\n /**\n * `ref` of the element to return focus to when `FocusLock` unmounts.\n */\n finalFocusRef?: RefObject<HTMLElement | null>\n /**\n * `ref` of the element to receive focus initially.\n */\n initialFocusRef?: RefObject<HTMLElement | null>\n /**\n * Enables aggressive focus capturing within iframes.\n * - If `true`: keep focus in the lock, no matter where lock is active.\n * - If `false`: allows focus to move outside of iframe.\n *\n * @default false\n */\n lockFocusAcrossFrames?: boolean\n /**\n * If `true`, disables text selections inside, and outside focus lock.\n *\n * @default false\n */\n persistentFocus?: boolean\n /**\n * If `true`, focus will be restored to the element that triggered the `FocusLock` once it unmounts.\n *\n * @default false\n */\n restoreFocus?: boolean\n}\n\n/**\n * `FocusLock` is a component that improves accessibility by restricting focus within elements such as modals and dialogs, and locking the focus within that range.\n *\n * @see https://yamada-ui.com/docs/components/focus-lock\n */\nexport const FocusLock: FC<FocusLockProps> = ({\n autoFocus,\n children,\n contentRef,\n disabled,\n finalFocusRef,\n initialFocusRef,\n lockFocusAcrossFrames,\n persistentFocus,\n restoreFocus,\n}) => {\n const [shards, setShards] = useState<HTMLElement[]>([])\n const returnFocus = restoreFocus && !finalFocusRef\n\n const registerShard = useCallback((shard: HTMLElement) => {\n setShards((prev) => (prev.includes(shard) ? prev : [...prev, shard]))\n\n return () => {\n setShards((prev) => prev.filter((item) => item !== shard))\n }\n }, [])\n\n const onActivation = useCallback(() => {\n if (initialFocusRef?.current) {\n initialFocusRef.current.focus()\n } else if (contentRef?.current) {\n const focusables = getFocusableElements(contentRef.current)\n\n if (focusables.length === 0)\n requestAnimationFrame(() => {\n contentRef.current?.focus()\n })\n }\n }, [initialFocusRef, contentRef])\n\n const onDeactivation = useCallback(() => {\n finalFocusRef?.current?.focus()\n }, [finalFocusRef])\n\n return (\n <FocusLockShardContext value={registerShard}>\n <InternalFocusLock\n autoFocus={autoFocus}\n crossFrame={lockFocusAcrossFrames}\n disabled={disabled}\n persistentFocus={persistentFocus}\n returnFocus={returnFocus}\n shards={shards}\n onActivation={onActivation}\n onDeactivation={onDeactivation}\n >\n {children}\n </InternalFocusLock>\n </FocusLockShardContext>\n )\n}\n"],"mappings":";;;;;;;;;AAWA,MAAM,CAAC,uBAAuB,qBAAqBA,gBAAAA,cAEjD;CAAE,MAAM;CAAyB,QAAQ;AAAM,CAAC;AAIlD,MAAM,qBAAA,GAAA,oBAAA,cAAA,eAAA,CAAmCC,iBAAAA,OAAc;;;;;;AAsDvD,MAAa,aAAiC,EAC5C,WACA,UACA,YACA,UACA,eACA,iBACA,uBACA,iBACA,mBACI;CACJ,MAAM,CAAC,QAAQ,cAAA,GAAA,MAAA,SAAA,CAAqC,CAAC,CAAC;CACtD,MAAM,cAAc,gBAAgB,CAAC;CAErC,MAAM,iBAAA,GAAA,MAAA,YAAA,EAA6B,UAAuB;EACxD,WAAW,SAAU,KAAK,SAAS,KAAK,IAAI,OAAO,CAAC,GAAG,MAAM,KAAK,CAAE;EAEpE,aAAa;GACX,WAAW,SAAS,KAAK,QAAQ,SAAS,SAAS,KAAK,CAAC;EAC3D;CACF,GAAG,CAAC,CAAC;CAEL,MAAM,gBAAA,GAAA,MAAA,YAAA,OAAiC;EACrC,IAAI,iBAAiB,SACnB,gBAAgB,QAAQ,MAAM;OACzB,IAAI,YAAY,SACmB;QAAA,GAAA,oBAAA,cAAA,qBAAA,CAAA,WAAW,OAEtC,CAAC,CAAC,WAAW,GACxB,4BAA4B;IAC1B,WAAW,SAAS,MAAM;GAC5B,CAAC;EAAA;CAEP,GAAG,CAAC,iBAAiB,UAAU,CAAC;CAEhC,MAAM,kBAAA,GAAA,MAAA,YAAA,OAAmC;EACvC,eAAe,SAAS,MAAM;CAChC,GAAG,CAAC,aAAa,CAAC;CAElB,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,uBAAD;EAAuB,OAAO;EAC5B,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAAC,mBAAD;GACa;GACX,YAAY;GACF;GACO;GACJ;GACL;GACM;GACE;GAEf;EACgB,CAAA;CACE,CAAA;AAE3B"}
@@ -1,3 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_focus_lock = require("./focus-lock.cjs");
3
3
  exports.FocusLock = require_focus_lock.FocusLock;
4
+ exports.useFocusLockShard = require_focus_lock.useFocusLockShard;
@@ -6,13 +6,13 @@ const require_props = require("../../core/components/props.cjs");
6
6
  const require_create_component = require("../../core/components/create-component.cjs");
7
7
  const require_factory$1 = require("../motion/factory.cjs");
8
8
  const require_hooks_use_value_index = require("../../hooks/use-value/index.cjs");
9
+ const require_focus_lock = require("../focus-lock/focus-lock.cjs");
9
10
  const require_portal = require("../portal/portal.cjs");
10
11
  const require_popover = require("../popover/popover.cjs");
11
12
  const require_button = require("../button/button.cjs");
12
13
  const require_close_button = require("../close-button/close-button.cjs");
13
14
  const require_modal_style = require("./modal.style.cjs");
14
15
  const require_fade = require("../fade/fade.cjs");
15
- const require_focus_lock = require("../focus-lock/focus-lock.cjs");
16
16
  const require_use_modal = require("./use-modal.cjs");
17
17
  let react = require("react");
18
18
  let react_jsx_runtime = require("react/jsx-runtime");
@@ -1,5 +1,7 @@
1
1
  "use client";
2
+ const require_children = require("../../utils/children.cjs");
2
3
  const require_utils_index = require("../../utils/index.cjs");
4
+ const require_props = require("../../core/components/props.cjs");
3
5
  const require_create_component = require("../../core/components/create-component.cjs");
4
6
  const require_factory = require("../motion/factory.cjs");
5
7
  const require_hooks_use_value_index = require("../../hooks/use-value/index.cjs");
@@ -97,15 +99,21 @@ const { ComponentContext, PropsContext: PopoverPropsContext, StyleContext, useCo
97
99
  */
98
100
  const PopoverRoot = (props) => {
99
101
  const styleProps = usePopoverStyleProps(props);
100
- const [styleContext, { animationScheme, children, duration, ...rest }] = useRootComponentProps({
102
+ const [styleContext, { anchor: anchorProp, animationScheme, body, children, duration, footer, header, trigger: triggerProp, anchorProps, bodyProps, closeTriggerProps, contentProps, footerProps, headerProps, triggerProps, ...rest }] = useRootComponentProps({
101
103
  ...props,
102
104
  ...styleProps
103
105
  });
106
+ const [omittedChildren, trigger, anchor, customContent] = require_children.useSplitChildren((0, require_utils_index.utils_exports.isFunction)(children) ? void 0 : children, PopoverTrigger, PopoverAnchor, PopoverContent);
104
107
  const { open, getAnchorProps, getBodyProps, getCloseTriggerProps, getContentProps, getFooterProps, getHeaderProps, getPositionerProps, getTriggerProps, onClose } = require_use_popover.usePopover(rest);
105
108
  const componentContext = (0, react.useMemo)(() => ({
106
109
  animationScheme,
107
110
  duration,
108
111
  open,
112
+ anchorProps,
113
+ bodyProps,
114
+ closeTriggerProps,
115
+ contentProps,
116
+ footerProps,
109
117
  getAnchorProps,
110
118
  getBodyProps,
111
119
  getCloseTriggerProps,
@@ -113,11 +121,19 @@ const PopoverRoot = (props) => {
113
121
  getFooterProps,
114
122
  getHeaderProps,
115
123
  getPositionerProps,
116
- getTriggerProps
124
+ getTriggerProps,
125
+ headerProps,
126
+ triggerProps
117
127
  }), [
118
128
  open,
119
129
  animationScheme,
130
+ anchorProps,
131
+ bodyProps,
132
+ closeTriggerProps,
133
+ contentProps,
120
134
  duration,
135
+ footerProps,
136
+ headerProps,
121
137
  getAnchorProps,
122
138
  getBodyProps,
123
139
  getCloseTriggerProps,
@@ -125,66 +141,89 @@ const PopoverRoot = (props) => {
125
141
  getFooterProps,
126
142
  getHeaderProps,
127
143
  getPositionerProps,
128
- getTriggerProps
144
+ getTriggerProps,
145
+ triggerProps
129
146
  ]);
147
+ const customAnchor = anchorProp ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PopoverAnchor, { children: anchorProp }) : null;
148
+ const customTrigger = triggerProp ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PopoverTrigger, { children: triggerProp }) : null;
149
+ const customContentProp = header !== void 0 || body !== void 0 || footer !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ShorthandPopoverContent, {
150
+ body,
151
+ footer,
152
+ header
153
+ }) : null;
130
154
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StyleContext, {
131
155
  value: styleContext,
132
156
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ComponentContext, {
133
157
  value: componentContext,
134
- children: (0, require_utils_index.utils_exports.runIfFn)(children, {
158
+ children: (0, require_utils_index.utils_exports.isFunction)(children) ? (0, require_utils_index.utils_exports.runIfFn)(children, {
135
159
  open,
136
160
  onClose
137
- })
161
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
162
+ anchor ?? customAnchor,
163
+ trigger ?? customTrigger,
164
+ omittedChildren,
165
+ customContent ?? customContentProp
166
+ ] })
138
167
  })
139
168
  });
140
169
  };
141
170
  const PopoverTrigger = withContext("button", "trigger")({ asChild: true }, (props) => {
142
- const { getTriggerProps } = useComponentContext();
143
- return getTriggerProps(props);
171
+ const { getTriggerProps, triggerProps } = useComponentContext();
172
+ return getTriggerProps(require_props.mergeProps(triggerProps, props)());
144
173
  });
145
174
  const PopoverCloseTrigger = withContext("button", {
146
175
  name: "CloseTrigger",
147
176
  slot: ["trigger", "close"]
148
177
  })({ asChild: true }, (props) => {
149
- const { getCloseTriggerProps } = useComponentContext();
150
- return getCloseTriggerProps(props);
178
+ const { closeTriggerProps, getCloseTriggerProps } = useComponentContext();
179
+ return getCloseTriggerProps(require_props.mergeProps(closeTriggerProps, props)());
151
180
  });
152
181
  const PopoverAnchor = withContext("div", "anchor")({ asChild: true }, (props) => {
153
- const { getAnchorProps } = useComponentContext();
154
- return getAnchorProps(props);
182
+ const { anchorProps, getAnchorProps } = useComponentContext();
183
+ return getAnchorProps(require_props.mergeProps(anchorProps, props)());
155
184
  });
156
185
  const PopoverPositioner = withContext("div", "positioner")(void 0, (props) => {
157
186
  const { getPositionerProps } = useComponentContext();
158
187
  return getPositionerProps(props);
159
188
  });
160
- const PopoverContent = withContext(({ portalProps, positionerProps, ...rest }) => {
161
- const { animationScheme, duration, open, getContentProps } = useComponentContext();
189
+ const PopoverContent = withContext(({ portalProps: portalPropsProp, positionerProps: positionerPropsProp, ...rest }) => {
190
+ const { animationScheme, duration, open, contentProps: { portalProps, positionerProps, ...contentProps } = {}, getContentProps } = useComponentContext();
162
191
  const popupAnimationProps = usePopupAnimationProps({
163
192
  animationScheme,
164
193
  duration
165
194
  });
166
195
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(motion_react.AnimatePresence, { children: open ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_portal.Portal, {
167
- ...portalProps,
196
+ ...require_props.mergeProps(portalProps, portalPropsProp)(),
168
197
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PopoverPositioner, {
169
- ...positionerProps,
198
+ ...require_props.mergeProps(positionerProps, positionerPropsProp)(),
170
199
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_factory.motion.div, {
171
200
  ...popupAnimationProps,
172
- ...(0, require_utils_index.utils_exports.cast)(getContentProps((0, require_utils_index.utils_exports.cast)(rest)))
201
+ ...(0, require_utils_index.utils_exports.cast)(getContentProps((0, require_utils_index.utils_exports.cast)(require_props.mergeProps(contentProps, rest)())))
173
202
  })
174
203
  })
175
204
  }) : null });
176
205
  }, "content")();
206
+ const ShorthandPopoverContent = ({ body, footer, header }) => {
207
+ const customHeader = require_children.wrapOrPassProps(PopoverHeader, header);
208
+ const customBody = require_children.wrapOrPassProps(PopoverBody, body);
209
+ const customFooter = require_children.wrapOrPassProps(PopoverFooter, footer);
210
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(PopoverContent, { children: [
211
+ customHeader,
212
+ customBody,
213
+ customFooter
214
+ ] });
215
+ };
177
216
  const PopoverHeader = withContext("div", "header")(void 0, (props) => {
178
- const { getHeaderProps } = useComponentContext();
179
- return getHeaderProps(props);
217
+ const { getHeaderProps, headerProps } = useComponentContext();
218
+ return getHeaderProps(require_props.mergeProps(headerProps, props)());
180
219
  });
181
220
  const PopoverBody = withContext("div", "body")(void 0, (props) => {
182
- const { getBodyProps } = useComponentContext();
183
- return getBodyProps(props);
221
+ const { bodyProps, getBodyProps } = useComponentContext();
222
+ return getBodyProps(require_props.mergeProps(bodyProps, props)());
184
223
  });
185
224
  const PopoverFooter = withContext("div", "footer")(void 0, (props) => {
186
- const { getFooterProps } = useComponentContext();
187
- return getFooterProps(props);
225
+ const { footerProps, getFooterProps } = useComponentContext();
226
+ return getFooterProps(require_props.mergeProps(footerProps, props)());
188
227
  });
189
228
  //#endregion
190
229
  exports.PopoverAnchor = PopoverAnchor;
@@ -1 +1 @@
1
- {"version":3,"file":"popover.cjs","names":["useValue","fadeScaleVariants","slideFadeVariants","createSlotComponent","popoverStyle","usePopover","AnimatePresence","Portal","motion"],"sources":["../../../../src/components/popover/popover.tsx"],"sourcesContent":["\"use client\"\n\nimport type { FC, PropsWithChildren } from \"react\"\nimport type {\n HTMLProps,\n HTMLStyledProps,\n SimplePlacement,\n StyleValue,\n ThemeProps,\n} from \"../../core\"\nimport type { Merge, ReactNodeOrFunction } from \"../../utils\"\nimport type { HTMLMotionProps, MotionTransitionProps } from \"../motion\"\nimport type { PortalProps } from \"../portal\"\nimport type { PopoverStyle } from \"./popover.style\"\nimport type { UsePopoverProps, UsePopoverReturn } from \"./use-popover\"\nimport { AnimatePresence } from \"motion/react\"\nimport { useMemo } from \"react\"\nimport { createSlotComponent } from \"../../core\"\nimport { useValue } from \"../../hooks/use-value\"\nimport { cast, filterUndefined, runIfFn } from \"../../utils\"\nimport { fadeScaleVariants } from \"../fade-scale\"\nimport { motion } from \"../motion\"\nimport { Portal } from \"../portal\"\nimport { slideFadeVariants } from \"../slide-fade\"\nimport { popoverStyle } from \"./popover.style\"\nimport { usePopover } from \"./use-popover\"\n\nexport interface UsePopupAnimationProps {\n /**\n * The animation of the element.\n *\n * @default 'scale'\n */\n animationScheme?: StyleValue<\"none\" | \"scale\" | SimplePlacement>\n /**\n * The animation duration.\n *\n * @default 0.1\n */\n duration?: StyleValue<MotionTransitionProps[\"duration\"]>\n}\n\nexport const usePopupAnimationProps = (props: UsePopupAnimationProps = {}) => {\n const animationScheme = useValue(props.animationScheme ?? \"scale\")\n const duration = useValue(props.duration ?? 0.1)\n const sharedProps = { animate: \"enter\", exit: \"exit\", initial: \"exit\" }\n\n switch (animationScheme) {\n case \"scale\":\n return {\n ...sharedProps,\n custom: { duration, reverse: true, scale: 0.95 },\n variants: fadeScaleVariants,\n }\n case \"block-start\":\n return {\n ...sharedProps,\n custom: { duration, offsetY: -16, reverse: true },\n variants: slideFadeVariants,\n }\n case \"inline-end\":\n return {\n ...sharedProps,\n custom: { duration, offsetX: 16, reverse: true },\n variants: slideFadeVariants,\n }\n case \"inline-start\":\n return {\n ...sharedProps,\n custom: { duration, offsetX: -16, reverse: true },\n variants: slideFadeVariants,\n }\n case \"block-end\":\n return {\n ...sharedProps,\n custom: { duration, offsetY: 16, reverse: true },\n variants: slideFadeVariants,\n }\n default:\n return {}\n }\n}\n\nexport interface UsePopoverStyleProps {\n /**\n * If `true`, the popper will change its placement and flip when it's about to overflow its boundary area.\n *\n * @default true\n */\n flip?: StyleValue<UsePopoverProps[\"flip\"]>\n /**\n * The distance or margin between the reference and popper.\n * It is used internally to create an `offset` modifier.\n *\n * @default 8\n */\n gutter?: StyleValue<UsePopoverProps[\"gutter\"]>\n /**\n * If `true`, the popper will match the width of the reference at all times.\n * It's useful for `autocomplete`, `date-picker` and `select` patterns.\n *\n * @default false\n */\n matchWidth?: StyleValue<UsePopoverProps[\"matchWidth\"]>\n /**\n * The placement of the popper relative to its reference.\n *\n * @default 'end'\n */\n placement?: StyleValue<UsePopoverProps[\"placement\"]>\n /**\n * The CSS positioning strategy to use.\n *\n * @default 'absolute'\n */\n strategy?: StyleValue<UsePopoverProps[\"strategy\"]>\n}\n\nexport const usePopoverStyleProps = (props: UsePopoverStyleProps = {}) => {\n const placement = useValue(props.placement)\n const gutter = useValue(props.gutter)\n const matchWidth = useValue(props.matchWidth)\n const strategy = useValue(props.strategy)\n const flip = useValue(props.flip)\n\n return useMemo(\n () => filterUndefined({ flip, gutter, matchWidth, placement, strategy }),\n [flip, gutter, matchWidth, placement, strategy],\n )\n}\n\ninterface ComponentContext\n extends\n Pick<\n UsePopoverReturn,\n | \"getAnchorProps\"\n | \"getBodyProps\"\n | \"getCloseTriggerProps\"\n | \"getContentProps\"\n | \"getFooterProps\"\n | \"getHeaderProps\"\n | \"getPositionerProps\"\n | \"getTriggerProps\"\n | \"open\"\n >,\n UsePopupAnimationProps {}\n\nexport interface PopoverRootProps\n extends\n Merge<UsePopoverProps, UsePopoverStyleProps>,\n UsePopupAnimationProps,\n ThemeProps<PopoverStyle> {\n /**\n * The children of the popover.\n */\n children?: ReactNodeOrFunction<{\n open: boolean\n onClose: () => void\n }>\n}\n\nconst {\n ComponentContext,\n PropsContext: PopoverPropsContext,\n StyleContext,\n useComponentContext,\n usePropsContext: usePopoverPropsContext,\n withContext,\n useRootComponentProps,\n} = createSlotComponent<PopoverRootProps, PopoverStyle, ComponentContext>(\n \"popover\",\n popoverStyle,\n)\n\nexport { PopoverPropsContext, usePopoverPropsContext }\n\n/**\n * `Popover` is a component that floats around an element to display information.\n *\n * @see https://yamada-ui.com/docs/components/popover\n */\nexport const PopoverRoot: FC<PopoverRootProps> = (props) => {\n const styleProps = usePopoverStyleProps(props)\n const [styleContext, { animationScheme, children, duration, ...rest }] =\n useRootComponentProps({ ...props, ...styleProps })\n const {\n open,\n getAnchorProps,\n getBodyProps,\n getCloseTriggerProps,\n getContentProps,\n getFooterProps,\n getHeaderProps,\n getPositionerProps,\n getTriggerProps,\n onClose,\n } = usePopover(rest)\n const componentContext = useMemo(\n () => ({\n animationScheme,\n duration,\n open,\n getAnchorProps,\n getBodyProps,\n getCloseTriggerProps,\n getContentProps,\n getFooterProps,\n getHeaderProps,\n getPositionerProps,\n getTriggerProps,\n }),\n [\n open,\n animationScheme,\n duration,\n getAnchorProps,\n getBodyProps,\n getCloseTriggerProps,\n getContentProps,\n getFooterProps,\n getHeaderProps,\n getPositionerProps,\n getTriggerProps,\n ],\n )\n\n return (\n <StyleContext value={styleContext}>\n <ComponentContext value={componentContext}>\n {runIfFn(children, { open, onClose })}\n </ComponentContext>\n </StyleContext>\n )\n}\n\nexport interface PopoverTriggerProps extends HTMLStyledProps<\"button\"> {}\n\nexport const PopoverTrigger = withContext<\"button\", PopoverTriggerProps>(\n \"button\",\n \"trigger\",\n)({ asChild: true }, (props) => {\n const { getTriggerProps } = useComponentContext()\n\n return getTriggerProps(props)\n})\n\nexport interface PopoverCloseTriggerProps extends HTMLStyledProps<\"button\"> {}\n\nexport const PopoverCloseTrigger = withContext<\n \"button\",\n PopoverCloseTriggerProps\n>(\"button\", { name: \"CloseTrigger\", slot: [\"trigger\", \"close\"] })(\n { asChild: true },\n (props) => {\n const { getCloseTriggerProps } = useComponentContext()\n\n return getCloseTriggerProps(props)\n },\n)\n\nexport interface PopoverAnchorProps extends HTMLStyledProps {}\n\nexport const PopoverAnchor = withContext<\"div\", PopoverAnchorProps>(\n \"div\",\n \"anchor\",\n)({ asChild: true }, (props) => {\n const { getAnchorProps } = useComponentContext()\n\n return getAnchorProps(props)\n})\n\ninterface PopoverPositionerProps extends HTMLStyledProps {}\n\nconst PopoverPositioner = withContext<\"div\", PopoverPositionerProps>(\n \"div\",\n \"positioner\",\n)(undefined, (props) => {\n const { getPositionerProps } = useComponentContext()\n\n return getPositionerProps(props)\n})\n\nexport interface PopoverContentProps\n extends Omit<HTMLMotionProps, \"children\">, PropsWithChildren {\n /**\n * Props for portal component.\n */\n portalProps?: Omit<PortalProps, \"children\">\n /**\n * Props for positioner component.\n */\n positionerProps?: Omit<PopoverPositionerProps, \"children\">\n}\n\nexport const PopoverContent = withContext<\"div\", PopoverContentProps>(\n ({ portalProps, positionerProps, ...rest }) => {\n const { animationScheme, duration, open, getContentProps } =\n useComponentContext()\n const popupAnimationProps = usePopupAnimationProps({\n animationScheme,\n duration,\n })\n\n return (\n <AnimatePresence>\n {open ? (\n <Portal {...portalProps}>\n <PopoverPositioner {...positionerProps}>\n <motion.div\n {...popupAnimationProps}\n {...cast<HTMLMotionProps>(\n getContentProps(cast<HTMLProps>(rest)),\n )}\n />\n </PopoverPositioner>\n </Portal>\n ) : null}\n </AnimatePresence>\n )\n },\n \"content\",\n)()\n\nexport interface PopoverHeaderProps extends HTMLStyledProps {}\n\nexport const PopoverHeader = withContext<\"div\", PopoverHeaderProps>(\n \"div\",\n \"header\",\n)(undefined, (props) => {\n const { getHeaderProps } = useComponentContext()\n\n return getHeaderProps(props)\n})\n\nexport interface PopoverBodyProps extends HTMLStyledProps {}\n\nexport const PopoverBody = withContext<\"div\", PopoverBodyProps>(\"div\", \"body\")(\n undefined,\n (props) => {\n const { getBodyProps } = useComponentContext()\n\n return getBodyProps(props)\n },\n)\n\nexport interface PopoverFooterProps extends HTMLStyledProps {}\n\nexport const PopoverFooter = withContext<\"div\", PopoverFooterProps>(\n \"div\",\n \"footer\",\n)(undefined, (props) => {\n const { getFooterProps } = useComponentContext()\n\n return getFooterProps(props)\n})\n"],"mappings":";;;;;;;;;;;;;;AA0CA,MAAa,0BAA0B,QAAgC,CAAC,MAAM;CAC5E,MAAM,kBAAkBA,8BAAAA,SAAS,MAAM,mBAAmB,OAAO;CACjE,MAAM,WAAWA,8BAAAA,SAAS,MAAM,YAAY,EAAG;CAC/C,MAAM,cAAc;EAAE,SAAS;EAAS,MAAM;EAAQ,SAAS;CAAO;CAEtE,QAAQ,iBAAR;EACE,KAAK,SACH,OAAO;GACL,GAAG;GACH,QAAQ;IAAE;IAAU,SAAS;IAAM,OAAO;GAAK;GAC/C,UAAUC,mBAAAA;EACZ;EACF,KAAK,eACH,OAA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D;EACA;CACF,CAAC;CAED,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACC,aAAAA,iBAAD,EAAA,UACG,OACC,iBAAA,GAAA,kBAAA,IAAA,CAACC,eAAAA,QAAD;EAAQ,GAAI;EACV,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAAC,mBAAD;GAAmB,GAAI;GACrB,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAACC,gBAAAA,OAAO,KAAR;IACE,GAAI;IACJ,IAAA,GAAA,oBAAA,cAAA,KAAA,CACE,iBAAA,GAAA,oBAAA,cAAA,KAAA,CAAgC,IAAI,CAAC,CACvC;GACD,CAAA;EACgB,CAAA;CACb,CAAA,IACN,KACW,CAAA;AAErB,GACA,SACF,CAAC,CAAC;AAIF,MAAa,gBAAgB,YAC3B,OACA,QACF,CAAC,CAAC,KAAA,IAAY,UAAU;CACtB,MAAM,EAAE,mBAAmB,oBAAoB;CAE/C,OAAO,eAAe,KAAK;AAC7B,CAAC;AAID,MAAa,cAAc,YAAqC,OAAO,MAAM,CAAC,CAC5E,KAAA,IACC,UAAU;CACT,MAAM,EAAE,iBAAiB,oBAAoB;CAE7C,OAAO,aAAa,KAAK;AAC3B,CACF;AAIA,MAAa,gBAAgB,YAC3B,OACA,QACF,CAAC,CAAC,KAAA,IAAY,UAAU;CACtB,MAAM,EAAE,mBAAmB,oBAAoB;CAE/C,OAAO,eAAe,KAAK;AAC7B,CAAC"}
1
+ {"version":3,"file":"popover.cjs","names":["useValue","fadeScaleVariants","slideFadeVariants","createSlotComponent","popoverStyle","useSplitChildren","usePopover","mergeProps","AnimatePresence","Portal","motion","wrapOrPassProps"],"sources":["../../../../src/components/popover/popover.tsx"],"sourcesContent":["\"use client\"\n\nimport type { FC, PropsWithChildren, ReactNode } from \"react\"\nimport type {\n HTMLProps,\n HTMLStyledProps,\n SimplePlacement,\n StyleValue,\n ThemeProps,\n} from \"../../core\"\nimport type { Merge, ReactNodeOrFunction } from \"../../utils\"\nimport type { HTMLMotionProps, MotionTransitionProps } from \"../motion\"\nimport type { PortalProps } from \"../portal\"\nimport type { PopoverStyle } from \"./popover.style\"\nimport type { UsePopoverProps, UsePopoverReturn } from \"./use-popover\"\nimport { AnimatePresence } from \"motion/react\"\nimport { useMemo } from \"react\"\nimport { createSlotComponent, mergeProps } from \"../../core\"\nimport { useValue } from \"../../hooks/use-value\"\nimport {\n cast,\n filterUndefined,\n isFunction,\n runIfFn,\n useSplitChildren,\n wrapOrPassProps,\n} from \"../../utils\"\nimport { fadeScaleVariants } from \"../fade-scale\"\nimport { motion } from \"../motion\"\nimport { Portal } from \"../portal\"\nimport { slideFadeVariants } from \"../slide-fade\"\nimport { popoverStyle } from \"./popover.style\"\nimport { usePopover } from \"./use-popover\"\n\nexport interface UsePopupAnimationProps {\n /**\n * The animation of the element.\n *\n * @default 'scale'\n */\n animationScheme?: StyleValue<\"none\" | \"scale\" | SimplePlacement>\n /**\n * The animation duration.\n *\n * @default 0.1\n */\n duration?: StyleValue<MotionTransitionProps[\"duration\"]>\n}\n\nexport const usePopupAnimationProps = (props: UsePopupAnimationProps = {}) => {\n const animationScheme = useValue(props.animationScheme ?? \"scale\")\n const duration = useValue(props.duration ?? 0.1)\n const sharedProps = { animate: \"enter\", exit: \"exit\", initial: \"exit\" }\n\n switch (animationScheme) {\n case \"scale\":\n return {\n ...sharedProps,\n custom: { duration, reverse: true, scale: 0.95 },\n variants: fadeScaleVariants,\n }\n case \"block-start\":\n return {\n ...sharedProps,\n custom: { duration, offsetY: -16, reverse: true },\n variants: slideFadeVariants,\n }\n case \"inline-end\":\n return {\n ...sharedProps,\n custom: { duration, offsetX: 16, reverse: true },\n variants: slideFadeVariants,\n }\n case \"inline-start\":\n return {\n ...sharedProps,\n custom: { duration, offsetX: -16, reverse: true },\n variants: slideFadeVariants,\n }\n case \"block-end\":\n return {\n ...sharedProps,\n custom: { duration, offsetY: 16, reverse: true },\n variants: slideFadeVariants,\n }\n default:\n return {}\n }\n}\n\nexport interface UsePopoverStyleProps {\n /**\n * If `true`, the popper will change its placement and flip when it's about to overflow its boundary area.\n *\n * @default true\n */\n flip?: StyleValue<UsePopoverProps[\"flip\"]>\n /**\n * The distance or margin between the reference and popper.\n * It is used internally to create an `offset` modifier.\n *\n * @default 8\n */\n gutter?: StyleValue<UsePopoverProps[\"gutter\"]>\n /**\n * If `true`, the popper will match the width of the reference at all times.\n * It's useful for `autocomplete`, `date-picker` and `select` patterns.\n *\n * @default false\n */\n matchWidth?: StyleValue<UsePopoverProps[\"matchWidth\"]>\n /**\n * The placement of the popper relative to its reference.\n *\n * @default 'end'\n */\n placement?: StyleValue<UsePopoverProps[\"placement\"]>\n /**\n * The CSS positioning strategy to use.\n *\n * @default 'absolute'\n */\n strategy?: StyleValue<UsePopoverProps[\"strategy\"]>\n}\n\nexport const usePopoverStyleProps = (props: UsePopoverStyleProps = {}) => {\n const placement = useValue(props.placement)\n const gutter = useValue(props.gutter)\n const matchWidth = useValue(props.matchWidth)\n const strategy = useValue(props.strategy)\n const flip = useValue(props.flip)\n\n return useMemo(\n () => filterUndefined({ flip, gutter, matchWidth, placement, strategy }),\n [flip, gutter, matchWidth, placement, strategy],\n )\n}\n\ninterface ComponentContext\n extends\n Pick<\n UsePopoverReturn,\n | \"getAnchorProps\"\n | \"getBodyProps\"\n | \"getCloseTriggerProps\"\n | \"getContentProps\"\n | \"getFooterProps\"\n | \"getHeaderProps\"\n | \"getPositionerProps\"\n | \"getTriggerProps\"\n | \"open\"\n >,\n UsePopupAnimationProps,\n Pick<\n PopoverRootProps,\n | \"anchorProps\"\n | \"bodyProps\"\n | \"closeTriggerProps\"\n | \"contentProps\"\n | \"footerProps\"\n | \"headerProps\"\n | \"triggerProps\"\n > {}\n\nexport interface PopoverRootProps\n extends\n Merge<UsePopoverProps, UsePopoverStyleProps>,\n UsePopupAnimationProps,\n ThemeProps<PopoverStyle>,\n ShorthandPopoverContentProps {\n /**\n * The popover anchor to use.\n */\n anchor?: ReactNode\n /**\n * The children of the popover.\n */\n children?: ReactNodeOrFunction<{\n open: boolean\n onClose: () => void\n }>\n /**\n * The popover trigger to use.\n */\n trigger?: ReactNode\n /**\n * Props for anchor element.\n */\n anchorProps?: Omit<PopoverAnchorProps, \"asChild\" | \"children\">\n /**\n * Props for body element.\n */\n bodyProps?: Omit<PopoverBodyProps, \"children\">\n /**\n * Props for close trigger element.\n */\n closeTriggerProps?: Omit<PopoverCloseTriggerProps, \"asChild\" | \"children\">\n /**\n * Props for content element.\n */\n contentProps?: Omit<PopoverContentProps, \"children\">\n /**\n * Props for footer element.\n */\n footerProps?: Omit<PopoverFooterProps, \"children\">\n /**\n * Props for header element.\n */\n headerProps?: Omit<PopoverHeaderProps, \"children\">\n /**\n * Props for trigger element.\n */\n triggerProps?: Omit<PopoverTriggerProps, \"asChild\" | \"children\">\n}\n\nconst {\n ComponentContext,\n PropsContext: PopoverPropsContext,\n StyleContext,\n useComponentContext,\n usePropsContext: usePopoverPropsContext,\n withContext,\n useRootComponentProps,\n} = createSlotComponent<PopoverRootProps, PopoverStyle, ComponentContext>(\n \"popover\",\n popoverStyle,\n)\n\nexport { PopoverPropsContext, usePopoverPropsContext }\n\n/**\n * `Popover` is a component that floats around an element to display information.\n *\n * @see https://yamada-ui.com/docs/components/popover\n */\nexport const PopoverRoot: FC<PopoverRootProps> = (props) => {\n const styleProps = usePopoverStyleProps(props)\n const [\n styleContext,\n {\n anchor: anchorProp,\n animationScheme,\n body,\n children,\n duration,\n footer,\n header,\n trigger: triggerProp,\n anchorProps,\n bodyProps,\n closeTriggerProps,\n contentProps,\n footerProps,\n headerProps,\n triggerProps,\n ...rest\n },\n ] = useRootComponentProps({ ...props, ...styleProps })\n const [omittedChildren, trigger, anchor, customContent] = useSplitChildren(\n isFunction(children) ? undefined : children,\n PopoverTrigger,\n PopoverAnchor,\n PopoverContent,\n )\n const {\n open,\n getAnchorProps,\n getBodyProps,\n getCloseTriggerProps,\n getContentProps,\n getFooterProps,\n getHeaderProps,\n getPositionerProps,\n getTriggerProps,\n onClose,\n } = usePopover(rest)\n const componentContext = useMemo(\n () => ({\n animationScheme,\n duration,\n open,\n anchorProps,\n bodyProps,\n closeTriggerProps,\n contentProps,\n footerProps,\n getAnchorProps,\n getBodyProps,\n getCloseTriggerProps,\n getContentProps,\n getFooterProps,\n getHeaderProps,\n getPositionerProps,\n getTriggerProps,\n headerProps,\n triggerProps,\n }),\n [\n open,\n animationScheme,\n anchorProps,\n bodyProps,\n closeTriggerProps,\n contentProps,\n duration,\n footerProps,\n headerProps,\n getAnchorProps,\n getBodyProps,\n getCloseTriggerProps,\n getContentProps,\n getFooterProps,\n getHeaderProps,\n getPositionerProps,\n getTriggerProps,\n triggerProps,\n ],\n )\n const customAnchor = anchorProp ? (\n <PopoverAnchor>{anchorProp}</PopoverAnchor>\n ) : null\n const customTrigger = triggerProp ? (\n <PopoverTrigger>{triggerProp}</PopoverTrigger>\n ) : null\n const customContentProp =\n header !== undefined || body !== undefined || footer !== undefined ? (\n <ShorthandPopoverContent body={body} footer={footer} header={header} />\n ) : null\n\n return (\n <StyleContext value={styleContext}>\n <ComponentContext value={componentContext}>\n {isFunction(children) ? (\n runIfFn(children, { open, onClose })\n ) : (\n <>\n {anchor ?? customAnchor}\n {trigger ?? customTrigger}\n {omittedChildren}\n {customContent ?? customContentProp}\n </>\n )}\n </ComponentContext>\n </StyleContext>\n )\n}\n\nexport interface PopoverTriggerProps extends HTMLStyledProps<\"button\"> {}\n\nexport const PopoverTrigger = withContext<\"button\", PopoverTriggerProps>(\n \"button\",\n \"trigger\",\n)({ asChild: true }, (props) => {\n const { getTriggerProps, triggerProps } = useComponentContext()\n\n return getTriggerProps(mergeProps(triggerProps, props)())\n})\n\nexport interface PopoverCloseTriggerProps extends HTMLStyledProps<\"button\"> {}\n\nexport const PopoverCloseTrigger = withContext<\n \"button\",\n PopoverCloseTriggerProps\n>(\"button\", { name: \"CloseTrigger\", slot: [\"trigger\", \"close\"] })(\n { asChild: true },\n (props) => {\n const { closeTriggerProps, getCloseTriggerProps } = useComponentContext()\n\n return getCloseTriggerProps(mergeProps(closeTriggerProps, props)())\n },\n)\n\nexport interface PopoverAnchorProps extends HTMLStyledProps {}\n\nexport const PopoverAnchor = withContext<\"div\", PopoverAnchorProps>(\n \"div\",\n \"anchor\",\n)({ asChild: true }, (props) => {\n const { anchorProps, getAnchorProps } = useComponentContext()\n\n return getAnchorProps(mergeProps(anchorProps, props)())\n})\n\ninterface PopoverPositionerProps extends HTMLStyledProps {}\n\nconst PopoverPositioner = withContext<\"div\", PopoverPositionerProps>(\n \"div\",\n \"positioner\",\n)(undefined, (props) => {\n const { getPositionerProps } = useComponentContext()\n\n return getPositionerProps(props)\n})\n\nexport interface PopoverContentProps\n extends Omit<HTMLMotionProps, \"children\">, PropsWithChildren {\n /**\n * Props for portal component.\n */\n portalProps?: Omit<PortalProps, \"children\">\n /**\n * Props for positioner component.\n */\n positionerProps?: Omit<PopoverPositionerProps, \"children\">\n}\n\nexport const PopoverContent = withContext<\"div\", PopoverContentProps>(\n ({\n portalProps: portalPropsProp,\n positionerProps: positionerPropsProp,\n ...rest\n }) => {\n const {\n animationScheme,\n duration,\n open,\n contentProps: { portalProps, positionerProps, ...contentProps } = {},\n getContentProps,\n } = useComponentContext()\n const popupAnimationProps = usePopupAnimationProps({\n animationScheme,\n duration,\n })\n\n return (\n <AnimatePresence>\n {open ? (\n <Portal {...mergeProps(portalProps, portalPropsProp)()}>\n <PopoverPositioner\n {...mergeProps(positionerProps, positionerPropsProp)()}\n >\n <motion.div\n {...popupAnimationProps}\n {...cast<HTMLMotionProps>(\n getContentProps(\n cast<HTMLProps>(mergeProps(contentProps, rest)()),\n ),\n )}\n />\n </PopoverPositioner>\n </Portal>\n ) : null}\n </AnimatePresence>\n )\n },\n \"content\",\n)()\n\ninterface ShorthandPopoverContentProps {\n /**\n * The popover body to use.\n */\n body?: PopoverBodyProps | ReactNode\n /**\n * The popover footer to use.\n */\n footer?: PopoverFooterProps | ReactNode\n /**\n * The popover header to use.\n */\n header?: PopoverHeaderProps | ReactNode\n}\n\nconst ShorthandPopoverContent: FC<ShorthandPopoverContentProps> = ({\n body,\n footer,\n header,\n}) => {\n const customHeader = wrapOrPassProps(PopoverHeader, header)\n const customBody = wrapOrPassProps(PopoverBody, body)\n const customFooter = wrapOrPassProps(PopoverFooter, footer)\n\n return (\n <PopoverContent>\n {customHeader}\n {customBody}\n {customFooter}\n </PopoverContent>\n )\n}\n\nexport interface PopoverHeaderProps extends HTMLStyledProps {}\n\nexport const PopoverHeader = withContext<\"div\", PopoverHeaderProps>(\n \"div\",\n \"header\",\n)(undefined, (props) => {\n const { getHeaderProps, headerProps } = useComponentContext()\n\n return getHeaderProps(mergeProps(headerProps, props)())\n})\n\nexport interface PopoverBodyProps extends HTMLStyledProps {}\n\nexport const PopoverBody = withContext<\"div\", PopoverBodyProps>(\"div\", \"body\")(\n undefined,\n (props) => {\n const { bodyProps, getBodyProps } = useComponentContext()\n\n return getBodyProps(mergeProps(bodyProps, props)())\n },\n)\n\nexport interface PopoverFooterProps extends HTMLStyledProps {}\n\nexport const PopoverFooter = withContext<\"div\", PopoverFooterProps>(\n \"div\",\n \"footer\",\n)(undefined, (props) => {\n const { footerProps, getFooterProps } = useComponentContext()\n\n return getFooterProps(mergeProps(footerProps, props)())\n})\n"],"mappings":";;;;;;;;;;;;;;;;AAiDA,MAAa,0BAA0B,QAAgC,CAAC,MAAM;CAC5E,MAAM,kBAAkBA,8BAAAA,SAAS,MAAM,mBAAmB,OAAO;CACjE,MAAM,WAAWA,8BAAAA,SAAS,MAAM,YAAY,EAAG;CAC/C,MAAM,cAAc;EAAE,SAAS;EAAS,MAAM;EAAQ,SAAS;CAAO;CAEtE,QAAQ,iBAAR;EACE,KAAK,SACH,OAAO;GACL,GAAG;GACH,QAAQ;IAAE;IAAU,SAAS;IAAM,OAAO;GAAK;GAC/C,UAAUC,mBAAAA;EACZ;EACF,KAAK,eACH,OAAO;GACL,GAAG;GACH,QAAQ;IAAE;IAAU,SAAS;I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AAC;GAErD,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAACG,gBAAAA,OAAO,KAAR;IACE,GAAI;IACJ,IAAA,GAAA,oBAAA,cAAA,KAAA,CACE,iBAAA,GAAA,oBAAA,cAAA,KAAA,CACkBH,cAAAA,WAAW,cAAc,IAAI,CAAC,CAAC,CAAC,CAClD,CACF;GACD,CAAA;EACgB,CAAA;CACb,CAAA,IACN,KACW,CAAA;AAErB,GACA,SACF,CAAC,CAAC;AAiBF,MAAM,2BAA6D,EACjE,MACA,QACA,aACI;CACJ,MAAM,eAAeI,iBAAAA,gBAAgB,eAAe,MAAM;CAC1D,MAAM,aAAaA,iBAAAA,gBAAgB,aAAa,IAAI;CACpD,MAAM,eAAeA,iBAAAA,gBAAgB,eAAe,MAAM;CAE1D,OACE,iBAAA,GAAA,kBAAA,KAAA,CAAC,gBAAD,EAAA,UAAA;EACG;EACA;EACA;CACa,EAAA,CAAA;AAEpB;AAIA,MAAa,gBAAgB,YAC3B,OACA,QACF,CAAC,CAAC,KAAA,IAAY,UAAU;CACtB,MAAM,EAAE,gBAAgB,gBAAgB,oBAAoB;CAE5D,OAAO,eAAeJ,cAAAA,WAAW,aAAa,KAAK,CAAC,CAAC,CAAC;AACxD,CAAC;AAID,MAAa,cAAc,YAAqC,OAAO,MAAM,CAAC,CAC5E,KAAA,IACC,UAAU;CACT,MAAM,EAAE,WAAW,iBAAiB,oBAAoB;CAExD,OAAO,aAAaA,cAAAA,WAAW,WAAW,KAAK,CAAC,CAAC,CAAC;AACpD,CACF;AAIA,MAAa,gBAAgB,YAC3B,OACA,QACF,CAAC,CAAC,KAAA,IAAY,UAAU;CACtB,MAAM,EAAE,aAAa,mBAAmB,oBAAoB;CAE5D,OAAO,eAAeA,cAAAA,WAAW,aAAa,KAAK,CAAC,CAAC,CAAC;AACxD,CAAC"}
@@ -2,6 +2,7 @@
2
2
  const require_ssr = require("../../utils/ssr.cjs");
3
3
  const require_utils_index = require("../../utils/index.cjs");
4
4
  const require_environment_provider = require("../../core/system/environment-provider.cjs");
5
+ const require_focus_lock = require("../focus-lock/focus-lock.cjs");
5
6
  let react = require("react");
6
7
  let react_jsx_runtime = require("react/jsx-runtime");
7
8
  let react_dom = require("react-dom");
@@ -17,14 +18,29 @@ const getPortalNode = (node) => {
17
18
  * @see https://yamada-ui.com/docs/components/portal
18
19
  */
19
20
  const Portal = ({ children, containerRef: ref, disabled }) => {
21
+ const shardRef = (0, react.useRef)(null);
20
22
  const [target, setTarget] = (0, react.useState)(ref?.current);
21
23
  const ssr = require_ssr.useSsr();
22
24
  const { getRootNode } = require_environment_provider.useEnvironment();
25
+ const registerShard = require_focus_lock.useFocusLockShard();
23
26
  (0, react.useEffect)(() => {
24
27
  setTarget(() => ref?.current);
25
28
  }, [ref]);
29
+ (0, react.useEffect)(() => {
30
+ const shard = shardRef.current;
31
+ if (disabled || ssr || !shard) return;
32
+ return registerShard?.(shard);
33
+ }, [
34
+ disabled,
35
+ registerShard,
36
+ ssr
37
+ ]);
26
38
  if (ssr || disabled) return children;
27
39
  const container = target ?? getPortalNode(getRootNode());
40
+ if (registerShard) return (0, react_dom.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
41
+ ref: shardRef,
42
+ children
43
+ }), container);
28
44
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: react.Children.map(children, (child) => (0, react_dom.createPortal)(child, container)) });
29
45
  };
30
46
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"portal.cjs","names":["useSsr","useEnvironment","Children"],"sources":["../../../../src/components/portal/portal.tsx"],"sourcesContent":["\"use client\"\n\nimport type { FC, PropsWithChildren, RefObject } from \"react\"\nimport type { RootNode } from \"../../core\"\nimport { Children, useEffect, useState } from \"react\"\nimport { createPortal } from \"react-dom\"\nimport { useEnvironment } from \"../../core\"\nimport { getDocument, isShadowRoot, useSsr } from \"../../utils\"\n\nconst getPortalNode = (node?: RootNode) => {\n const rootNode = node?.getRootNode()\n\n if (isShadowRoot(rootNode)) return rootNode\n\n return getDocument(node).body\n}\n\nexport interface PortalProps extends PropsWithChildren {\n /**\n * The `ref` to the component where the portal will be attached to.\n */\n containerRef?: RefObject<HTMLElement | null>\n /**\n * If `true`, the forwarding will be disabled.\n */\n disabled?: boolean\n}\n\n/**\n * `Portal` is a component that renders elements outside of the current `DOM` hierarchy.\n *\n * @see https://yamada-ui.com/docs/components/portal\n */\nexport const Portal: FC<PortalProps> = ({\n children,\n containerRef: ref,\n disabled,\n}) => {\n const [target, setTarget] = useState(ref?.current)\n const ssr = useSsr()\n const { getRootNode } = useEnvironment()\n\n useEffect(() => {\n setTarget(() => ref?.current)\n }, [ref])\n\n if (ssr || disabled) return children\n\n const container = target ?? getPortalNode(getRootNode())\n\n return (\n <>{Children.map(children, (child) => createPortal(child, container))}</>\n )\n}\n"],"mappings":";;;;;;;;AASA,MAAM,iBAAiB,SAAoB;CACzC,MAAM,WAAW,MAAM,YAAY;CAEnC,KAAA,GAAA,oBAAA,cAAA,aAAA,CAAiB,QAAQ,GAAG,OAAO;CAEnC,QAAA,GAAA,oBAAA,cAAA,YAAA,CAAmB,IAAI,CAAC,CAAC;AAC3B;;;;;;AAkBA,MAAa,UAA2B,EACtC,UACA,cAAc,KACd,eACI;CACJ,MAAM,CAAC,QAAQ,cAAA,GAAA,MAAA,SAAA,CAAsB,KAAK,OAAO;CACjD,MAAM,MAAMA,YAAAA,OAAO;CACnB,MAAM,EAAE,gBAAgBC,6BAAAA,eAAe;CAEvC,CAAA,GAAA,MAAA,UAAA,OAAgB;EACd,gBAAgB,KAAK,OAAO;CAC9B,GAAG,CAAC,GAAG,CAAC;CAER,IAAI,OAAO,UAAU,OAAO;CAE5B,MAAM,YAAY,UAAU,cAAc,YAAY,CAAC;CAEvD,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAA,kBAAA,UAAA,EAAA,UAAGC,MAAAA,SAAS,IAAI,WAAW,WAAA,GAAA,UAAA,aAAA,CAAuB,OAAO,SAAS,CAAC,EAAI,CAAA;AAE3E"}
1
+ {"version":3,"file":"portal.cjs","names":["useSsr","useEnvironment","useFocusLockShard","Children"],"sources":["../../../../src/components/portal/portal.tsx"],"sourcesContent":["\"use client\"\n\nimport type { FC, PropsWithChildren, RefObject } from \"react\"\nimport type { RootNode } from \"../../core\"\nimport { Children, useEffect, useRef, useState } from \"react\"\nimport { createPortal } from \"react-dom\"\nimport { useEnvironment } from \"../../core\"\nimport { getDocument, isShadowRoot, useSsr } from \"../../utils\"\nimport { useFocusLockShard } from \"../focus-lock\"\n\nconst getPortalNode = (node?: RootNode) => {\n const rootNode = node?.getRootNode()\n\n if (isShadowRoot(rootNode)) return rootNode\n\n return getDocument(node).body\n}\n\nexport interface PortalProps extends PropsWithChildren {\n /**\n * The `ref` to the component where the portal will be attached to.\n */\n containerRef?: RefObject<HTMLElement | null>\n /**\n * If `true`, the forwarding will be disabled.\n */\n disabled?: boolean\n}\n\n/**\n * `Portal` is a component that renders elements outside of the current `DOM` hierarchy.\n *\n * @see https://yamada-ui.com/docs/components/portal\n */\nexport const Portal: FC<PortalProps> = ({\n children,\n containerRef: ref,\n disabled,\n}) => {\n const shardRef = useRef<HTMLDivElement>(null)\n const [target, setTarget] = useState(ref?.current)\n const ssr = useSsr()\n const { getRootNode } = useEnvironment()\n const registerShard = useFocusLockShard()\n\n useEffect(() => {\n setTarget(() => ref?.current)\n }, [ref])\n\n useEffect(() => {\n const shard = shardRef.current\n\n if (disabled || ssr || !shard) return\n\n return registerShard?.(shard)\n }, [disabled, registerShard, ssr])\n\n if (ssr || disabled) return children\n\n const container = target ?? getPortalNode(getRootNode())\n\n if (registerShard)\n return createPortal(<div ref={shardRef}>{children}</div>, container)\n\n return (\n <>{Children.map(children, (child) => createPortal(child, container))}</>\n )\n}\n"],"mappings":";;;;;;;;;AAUA,MAAM,iBAAiB,SAAoB;CACzC,MAAM,WAAW,MAAM,YAAY;CAEnC,KAAA,GAAA,oBAAA,cAAA,aAAA,CAAiB,QAAQ,GAAG,OAAO;CAEnC,QAAA,GAAA,oBAAA,cAAA,YAAA,CAAmB,IAAI,CAAC,CAAC;AAC3B;;;;;;AAkBA,MAAa,UAA2B,EACtC,UACA,cAAc,KACd,eACI;CACJ,MAAM,YAAA,GAAA,MAAA,OAAA,CAAkC,IAAI;CAC5C,MAAM,CAAC,QAAQ,cAAA,GAAA,MAAA,SAAA,CAAsB,KAAK,OAAO;CACjD,MAAM,MAAMA,YAAAA,OAAO;CACnB,MAAM,EAAE,gBAAgBC,6BAAAA,eAAe;CACvC,MAAM,gBAAgBC,mBAAAA,kBAAkB;CAExC,CAAA,GAAA,MAAA,UAAA,OAAgB;EACd,gBAAgB,KAAK,OAAO;CAC9B,GAAG,CAAC,GAAG,CAAC;CAER,CAAA,GAAA,MAAA,UAAA,OAAgB;EACd,MAAM,QAAQ,SAAS;EAEvB,IAAI,YAAY,OAAO,CAAC,OAAO;EAE/B,OAAO,gBAAgB,KAAK;CAC9B,GAAG;EAAC;EAAU;EAAe;CAAG,CAAC;CAEjC,IAAI,OAAO,UAAU,OAAO;CAE5B,MAAM,YAAY,UAAU,cAAc,YAAY,CAAC;CAEvD,IAAI,eACF,QAAA,GAAA,UAAA,aAAA,CAAoB,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;EAAK,KAAK;EAAW;CAAc,CAAA,GAAG,SAAS;CAErE,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAA,kBAAA,UAAA,EAAA,UAAGC,MAAAA,SAAS,IAAI,WAAW,WAAA,GAAA,UAAA,aAAA,CAAuB,OAAO,SAAS,CAAC,EAAI,CAAA;AAE3E"}
@@ -1826,6 +1826,7 @@ const require_namespace$2 = require("./components/native-popover/namespace.cjs")
1826
1826
  const require_popover_style = require("./components/popover/popover.style.cjs");
1827
1827
  const require_fade_scale_style = require("./components/fade-scale/fade-scale.style.cjs");
1828
1828
  const require_fade_scale = require("./components/fade-scale/fade-scale.cjs");
1829
+ const require_focus_lock = require("./components/focus-lock/focus-lock.cjs");
1829
1830
  const require_portal = require("./components/portal/portal.cjs");
1830
1831
  const require_slide_fade_style = require("./components/slide-fade/slide-fade.style.cjs");
1831
1832
  const require_slide_fade = require("./components/slide-fade/slide-fade.cjs");
@@ -2043,7 +2044,6 @@ const require_namespace$31 = require("./components/data-list/namespace.cjs");
2043
2044
  const require_modal_style = require("./components/modal/modal.style.cjs");
2044
2045
  const require_fade_style = require("./components/fade/fade.style.cjs");
2045
2046
  const require_fade = require("./components/fade/fade.cjs");
2046
- const require_focus_lock = require("./components/focus-lock/focus-lock.cjs");
2047
2047
  const require_use_modal = require("./components/modal/use-modal.cjs");
2048
2048
  const require_modal = require("./components/modal/modal.cjs");
2049
2049
  const require_namespace$32 = require("./components/modal/namespace.cjs");
@@ -5086,6 +5086,7 @@ var src_exports = /* @__PURE__ */ require_runtime.__exportAll({
5086
5086
  useFlexPropsContext: () => require_flex.useFlexPropsContext,
5087
5087
  useFlipPropsContext: () => require_flip.useFlipPropsContext,
5088
5088
  useFloatPropsContext: () => require_float.useFloatPropsContext,
5089
+ useFocusLockShard: () => require_focus_lock.useFocusLockShard,
5089
5090
  useFocusOnPointerDown: () => require_hooks_use_focus_index.useFocusOnPointerDown,
5090
5091
  useFocusOnShow: () => require_hooks_use_focus_index.useFocusOnShow,
5091
5092
  useFormContext: () => require_form.useFormContext,
@@ -8502,6 +8503,7 @@ exports.useFindChildren = require_children.useFindChildren;
8502
8503
  exports.useFlexPropsContext = require_flex.useFlexPropsContext;
8503
8504
  exports.useFlipPropsContext = require_flip.useFlipPropsContext;
8504
8505
  exports.useFloatPropsContext = require_float.useFloatPropsContext;
8506
+ exports.useFocusLockShard = require_focus_lock.useFocusLockShard;
8505
8507
  exports.useFocusOnPointerDown = require_hooks_use_focus_index.useFocusOnPointerDown;
8506
8508
  exports.useFocusOnShow = require_hooks_use_focus_index.useFocusOnShow;
8507
8509
  exports.useFormContext = require_form.useFormContext;
@@ -5,11 +5,11 @@ import { styled } from "../../core/system/factory.js";
5
5
  import { createSlotComponent } from "../../core/components/create-component.js";
6
6
  import { motion as motion$1 } from "../motion/factory.js";
7
7
  import { useValue } from "../../hooks/use-value/index.js";
8
+ import { FocusLock } from "../focus-lock/focus-lock.js";
8
9
  import { Portal } from "../portal/portal.js";
9
10
  import { Button } from "../button/button.js";
10
11
  import { CloseButton } from "../close-button/close-button.js";
11
12
  import { fadeVariants } from "../fade/fade.js";
12
- import { FocusLock } from "../focus-lock/focus-lock.js";
13
13
  import { drawerStyle } from "./drawer.style.js";
14
14
  import { Slide } from "../slide/slide.js";
15
15
  import { useDrawer } from "./use-drawer.js";
@@ -1,9 +1,14 @@
1
1
  "use client";
2
+ import { createContext as createContext$1 } from "../../utils/context.js";
2
3
  import { utils_exports } from "../../utils/index.js";
3
- import { useCallback } from "react";
4
+ import { useCallback, useState } from "react";
4
5
  import { jsx } from "react/jsx-runtime";
5
6
  import ReactFocusLock from "react-focus-lock";
6
7
  //#region src/components/focus-lock/focus-lock.tsx
8
+ const [FocusLockShardContext, useFocusLockShard] = createContext$1({
9
+ name: "FocusLockShardContext",
10
+ strict: false
11
+ });
7
12
  const InternalFocusLock = (0, utils_exports.interopDefault)(ReactFocusLock);
8
13
  /**
9
14
  * `FocusLock` is a component that improves accessibility by restricting focus within elements such as modals and dialogs, and locking the focus within that range.
@@ -11,7 +16,14 @@ const InternalFocusLock = (0, utils_exports.interopDefault)(ReactFocusLock);
11
16
  * @see https://yamada-ui.com/docs/components/focus-lock
12
17
  */
13
18
  const FocusLock = ({ autoFocus, children, contentRef, disabled, finalFocusRef, initialFocusRef, lockFocusAcrossFrames, persistentFocus, restoreFocus }) => {
19
+ const [shards, setShards] = useState([]);
14
20
  const returnFocus = restoreFocus && !finalFocusRef;
21
+ const registerShard = useCallback((shard) => {
22
+ setShards((prev) => prev.includes(shard) ? prev : [...prev, shard]);
23
+ return () => {
24
+ setShards((prev) => prev.filter((item) => item !== shard));
25
+ };
26
+ }, []);
15
27
  const onActivation = useCallback(() => {
16
28
  if (initialFocusRef?.current) initialFocusRef.current.focus();
17
29
  else if (contentRef?.current) {
@@ -23,18 +35,22 @@ const FocusLock = ({ autoFocus, children, contentRef, disabled, finalFocusRef, i
23
35
  const onDeactivation = useCallback(() => {
24
36
  finalFocusRef?.current?.focus();
25
37
  }, [finalFocusRef]);
26
- return /* @__PURE__ */ jsx(InternalFocusLock, {
27
- autoFocus,
28
- crossFrame: lockFocusAcrossFrames,
29
- disabled,
30
- persistentFocus,
31
- returnFocus,
32
- onActivation,
33
- onDeactivation,
34
- children
38
+ return /* @__PURE__ */ jsx(FocusLockShardContext, {
39
+ value: registerShard,
40
+ children: /* @__PURE__ */ jsx(InternalFocusLock, {
41
+ autoFocus,
42
+ crossFrame: lockFocusAcrossFrames,
43
+ disabled,
44
+ persistentFocus,
45
+ returnFocus,
46
+ shards,
47
+ onActivation,
48
+ onDeactivation,
49
+ children
50
+ })
35
51
  });
36
52
  };
37
53
  //#endregion
38
- export { FocusLock };
54
+ export { FocusLock, useFocusLockShard };
39
55
 
40
56
  //# sourceMappingURL=focus-lock.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"focus-lock.js","names":[],"sources":["../../../../src/components/focus-lock/focus-lock.tsx"],"sourcesContent":["\"use client\"\n\nimport type { FC, PropsWithChildren, RefObject } from \"react\"\nimport { useCallback } from \"react\"\nimport ReactFocusLock from \"react-focus-lock\"\nimport { getFocusableElements, interopDefault } from \"../../utils\"\n\nconst InternalFocusLock = interopDefault(ReactFocusLock)\n\nexport interface FocusLockProps extends PropsWithChildren {\n /**\n * If `true`, the first focusable element within the `children` will auto-focused once `FocusLock` mounts.\n *\n * @default false\n */\n autoFocus?: boolean\n /**\n * The `ref` of the wrapper for which the focus-lock wraps.\n */\n contentRef?: RefObject<HTMLElement | null>\n /**\n * If `true`, focus trapping will be disabled.\n *\n * @default false\n */\n disabled?: boolean\n /**\n * `ref` of the element to return focus to when `FocusLock` unmounts.\n */\n finalFocusRef?: RefObject<HTMLElement | null>\n /**\n * `ref` of the element to receive focus initially.\n */\n initialFocusRef?: RefObject<HTMLElement | null>\n /**\n * Enables aggressive focus capturing within iframes.\n * - If `true`: keep focus in the lock, no matter where lock is active.\n * - If `false`: allows focus to move outside of iframe.\n *\n * @default false\n */\n lockFocusAcrossFrames?: boolean\n /**\n * If `true`, disables text selections inside, and outside focus lock.\n *\n * @default false\n */\n persistentFocus?: boolean\n /**\n * If `true`, focus will be restored to the element that triggered the `FocusLock` once it unmounts.\n *\n * @default false\n */\n restoreFocus?: boolean\n}\n\n/**\n * `FocusLock` is a component that improves accessibility by restricting focus within elements such as modals and dialogs, and locking the focus within that range.\n *\n * @see https://yamada-ui.com/docs/components/focus-lock\n */\nexport const FocusLock: FC<FocusLockProps> = ({\n autoFocus,\n children,\n contentRef,\n disabled,\n finalFocusRef,\n initialFocusRef,\n lockFocusAcrossFrames,\n persistentFocus,\n restoreFocus,\n}) => {\n const returnFocus = restoreFocus && !finalFocusRef\n\n const onActivation = useCallback(() => {\n if (initialFocusRef?.current) {\n initialFocusRef.current.focus()\n } else if (contentRef?.current) {\n const focusables = getFocusableElements(contentRef.current)\n\n if (focusables.length === 0)\n requestAnimationFrame(() => {\n contentRef.current?.focus()\n })\n }\n }, [initialFocusRef, contentRef])\n\n const onDeactivation = useCallback(() => {\n finalFocusRef?.current?.focus()\n }, [finalFocusRef])\n\n return (\n <InternalFocusLock\n autoFocus={autoFocus}\n crossFrame={lockFocusAcrossFrames}\n disabled={disabled}\n persistentFocus={persistentFocus}\n returnFocus={returnFocus}\n onActivation={onActivation}\n onDeactivation={onDeactivation}\n >\n {children}\n </InternalFocusLock>\n )\n}\n"],"mappings":";;;;;;AAOA,MAAM,qBAAA,GAAA,cAAA,eAAA,CAAmC,cAAc;;;;;;AAsDvD,MAAa,aAAiC,EAC5C,WACA,UACA,YACA,UACA,eACA,iBACA,uBACA,iBACA,mBACI;CACJ,MAAM,cAAc,gBAAgB,CAAC;CAErC,MAAM,eAAe,kBAAkB;EACrC,IAAI,iBAAiB,SACnB,gBAAgB,QAAQ,MAAM;OACzB,IAAI,YAAY,SACmB;QAAA,GAAA,cAAA,qBAAA,CAAA,WAAW,OAEtC,CAAC,CAAC,WAAW,GACxB,4BAA4B;IAC1B,WAAW,SAAS,MAAM;GAC5B,CAAC;EAAA;CAEP,GAAG,CAAC,iBAAiB,UAAU,CAAC;CAEhC,MAAM,iBAAiB,kBAAkB;EACvC,eAAe,SAAS,MAAM;CAChC,GAAG,CAAC,aAAa,CAAC;CAElB,OACE,oBAAC,mBAAD;EACa;EACX,YAAY;EACF;EACO;EACJ;EACC;EACE;EAEf;CACgB,CAAA;AAEvB"}
1
+ {"version":3,"file":"focus-lock.js","names":["createContext"],"sources":["../../../../src/components/focus-lock/focus-lock.tsx"],"sourcesContent":["\"use client\"\n\nimport type { FC, PropsWithChildren, RefObject } from \"react\"\nimport { useCallback, useState } from \"react\"\nimport ReactFocusLock from \"react-focus-lock\"\nimport {\n createContext,\n getFocusableElements,\n interopDefault,\n} from \"../../utils\"\n\nconst [FocusLockShardContext, useFocusLockShard] = createContext<\n ((shard: HTMLElement) => () => void) | undefined\n>({ name: \"FocusLockShardContext\", strict: false })\n\nexport { useFocusLockShard }\n\nconst InternalFocusLock = interopDefault(ReactFocusLock)\n\nexport interface FocusLockProps extends PropsWithChildren {\n /**\n * If `true`, the first focusable element within the `children` will auto-focused once `FocusLock` mounts.\n *\n * @default false\n */\n autoFocus?: boolean\n /**\n * The `ref` of the wrapper for which the focus-lock wraps.\n */\n contentRef?: RefObject<HTMLElement | null>\n /**\n * If `true`, focus trapping will be disabled.\n *\n * @default false\n */\n disabled?: boolean\n /**\n * `ref` of the element to return focus to when `FocusLock` unmounts.\n */\n finalFocusRef?: RefObject<HTMLElement | null>\n /**\n * `ref` of the element to receive focus initially.\n */\n initialFocusRef?: RefObject<HTMLElement | null>\n /**\n * Enables aggressive focus capturing within iframes.\n * - If `true`: keep focus in the lock, no matter where lock is active.\n * - If `false`: allows focus to move outside of iframe.\n *\n * @default false\n */\n lockFocusAcrossFrames?: boolean\n /**\n * If `true`, disables text selections inside, and outside focus lock.\n *\n * @default false\n */\n persistentFocus?: boolean\n /**\n * If `true`, focus will be restored to the element that triggered the `FocusLock` once it unmounts.\n *\n * @default false\n */\n restoreFocus?: boolean\n}\n\n/**\n * `FocusLock` is a component that improves accessibility by restricting focus within elements such as modals and dialogs, and locking the focus within that range.\n *\n * @see https://yamada-ui.com/docs/components/focus-lock\n */\nexport const FocusLock: FC<FocusLockProps> = ({\n autoFocus,\n children,\n contentRef,\n disabled,\n finalFocusRef,\n initialFocusRef,\n lockFocusAcrossFrames,\n persistentFocus,\n restoreFocus,\n}) => {\n const [shards, setShards] = useState<HTMLElement[]>([])\n const returnFocus = restoreFocus && !finalFocusRef\n\n const registerShard = useCallback((shard: HTMLElement) => {\n setShards((prev) => (prev.includes(shard) ? prev : [...prev, shard]))\n\n return () => {\n setShards((prev) => prev.filter((item) => item !== shard))\n }\n }, [])\n\n const onActivation = useCallback(() => {\n if (initialFocusRef?.current) {\n initialFocusRef.current.focus()\n } else if (contentRef?.current) {\n const focusables = getFocusableElements(contentRef.current)\n\n if (focusables.length === 0)\n requestAnimationFrame(() => {\n contentRef.current?.focus()\n })\n }\n }, [initialFocusRef, contentRef])\n\n const onDeactivation = useCallback(() => {\n finalFocusRef?.current?.focus()\n }, [finalFocusRef])\n\n return (\n <FocusLockShardContext value={registerShard}>\n <InternalFocusLock\n autoFocus={autoFocus}\n crossFrame={lockFocusAcrossFrames}\n disabled={disabled}\n persistentFocus={persistentFocus}\n returnFocus={returnFocus}\n shards={shards}\n onActivation={onActivation}\n onDeactivation={onDeactivation}\n >\n {children}\n </InternalFocusLock>\n </FocusLockShardContext>\n )\n}\n"],"mappings":";;;;;;;AAWA,MAAM,CAAC,uBAAuB,qBAAqBA,gBAEjD;CAAE,MAAM;CAAyB,QAAQ;AAAM,CAAC;AAIlD,MAAM,qBAAA,GAAA,cAAA,eAAA,CAAmC,cAAc;;;;;;AAsDvD,MAAa,aAAiC,EAC5C,WACA,UACA,YACA,UACA,eACA,iBACA,uBACA,iBACA,mBACI;CACJ,MAAM,CAAC,QAAQ,aAAa,SAAwB,CAAC,CAAC;CACtD,MAAM,cAAc,gBAAgB,CAAC;CAErC,MAAM,gBAAgB,aAAa,UAAuB;EACxD,WAAW,SAAU,KAAK,SAAS,KAAK,IAAI,OAAO,CAAC,GAAG,MAAM,KAAK,CAAE;EAEpE,aAAa;GACX,WAAW,SAAS,KAAK,QAAQ,SAAS,SAAS,KAAK,CAAC;EAC3D;CACF,GAAG,CAAC,CAAC;CAEL,MAAM,eAAe,kBAAkB;EACrC,IAAI,iBAAiB,SACnB,gBAAgB,QAAQ,MAAM;OACzB,IAAI,YAAY,SACmB;QAAA,GAAA,cAAA,qBAAA,CAAA,WAAW,OAEtC,CAAC,CAAC,WAAW,GACxB,4BAA4B;IAC1B,WAAW,SAAS,MAAM;GAC5B,CAAC;EAAA;CAEP,GAAG,CAAC,iBAAiB,UAAU,CAAC;CAEhC,MAAM,iBAAiB,kBAAkB;EACvC,eAAe,SAAS,MAAM;CAChC,GAAG,CAAC,aAAa,CAAC;CAElB,OACE,oBAAC,uBAAD;EAAuB,OAAO;EAC5B,UAAA,oBAAC,mBAAD;GACa;GACX,YAAY;GACF;GACO;GACJ;GACL;GACM;GACE;GAEf;EACgB,CAAA;CACE,CAAA;AAE3B"}
@@ -1,2 +1,2 @@
1
- import { FocusLock } from "./focus-lock.js";
2
- export { FocusLock };
1
+ import { FocusLock, useFocusLockShard } from "./focus-lock.js";
2
+ export { FocusLock, useFocusLockShard };
@@ -6,13 +6,13 @@ import { mergeProps } from "../../core/components/props.js";
6
6
  import { createSlotComponent } from "../../core/components/create-component.js";
7
7
  import { motion as motion$1 } from "../motion/factory.js";
8
8
  import { useValue } from "../../hooks/use-value/index.js";
9
+ import { FocusLock } from "../focus-lock/focus-lock.js";
9
10
  import { Portal } from "../portal/portal.js";
10
11
  import { usePopupAnimationProps } from "../popover/popover.js";
11
12
  import { Button } from "../button/button.js";
12
13
  import { CloseButton } from "../close-button/close-button.js";
13
14
  import { modalStyle } from "./modal.style.js";
14
15
  import { fadeVariants } from "../fade/fade.js";
15
- import { FocusLock } from "../focus-lock/focus-lock.js";
16
16
  import { useModal } from "./use-modal.js";
17
17
  import { useMemo } from "react";
18
18
  import { jsx, jsxs } from "react/jsx-runtime";