@yamada-ui/react 2.2.6-dev-20260730065117 → 2.2.6-dev-20260730091154

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.
Files changed (30) hide show
  1. package/dist/cjs/components/drawer/drawer.cjs +1 -1
  2. package/dist/cjs/components/focus-lock/focus-lock.cjs +26 -9
  3. package/dist/cjs/components/focus-lock/focus-lock.cjs.map +1 -1
  4. package/dist/cjs/components/focus-lock/index.cjs +1 -0
  5. package/dist/cjs/components/modal/modal.cjs +39 -21
  6. package/dist/cjs/components/modal/modal.cjs.map +1 -1
  7. package/dist/cjs/components/popover/popover.cjs +61 -22
  8. package/dist/cjs/components/popover/popover.cjs.map +1 -1
  9. package/dist/cjs/components/portal/portal.cjs +16 -0
  10. package/dist/cjs/components/portal/portal.cjs.map +1 -1
  11. package/dist/cjs/index.cjs +3 -1
  12. package/dist/esm/components/drawer/drawer.js +1 -1
  13. package/dist/esm/components/focus-lock/focus-lock.js +27 -11
  14. package/dist/esm/components/focus-lock/focus-lock.js.map +1 -1
  15. package/dist/esm/components/focus-lock/index.js +2 -2
  16. package/dist/esm/components/modal/modal.js +40 -21
  17. package/dist/esm/components/modal/modal.js.map +1 -1
  18. package/dist/esm/components/popover/popover.js +62 -23
  19. package/dist/esm/components/popover/popover.js.map +1 -1
  20. package/dist/esm/components/portal/portal.js +17 -1
  21. package/dist/esm/components/portal/portal.js.map +1 -1
  22. package/dist/esm/index.js +3 -2
  23. package/dist/types/components/chart/cartesian-chart.style.d.ts +1 -1
  24. package/dist/types/components/chart/polar-chart.style.d.ts +1 -1
  25. package/dist/types/components/focus-lock/focus-lock.d.ts +2 -1
  26. package/dist/types/components/focus-lock/index.d.ts +2 -2
  27. package/dist/types/components/modal/modal.d.ts +37 -1
  28. package/dist/types/components/popover/popover.d.ts +52 -2
  29. package/dist/types/index.d.ts +3 -3
  30. package/package.json +2 -2
@@ -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 };
@@ -2,16 +2,17 @@
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";
9
+ import { FocusLock } from "../focus-lock/focus-lock.js";
8
10
  import { Portal } from "../portal/portal.js";
9
11
  import { usePopupAnimationProps } from "../popover/popover.js";
10
12
  import { Button } from "../button/button.js";
11
13
  import { CloseButton } from "../close-button/close-button.js";
12
14
  import { modalStyle } from "./modal.style.js";
13
15
  import { fadeVariants } from "../fade/fade.js";
14
- import { FocusLock } from "../focus-lock/focus-lock.js";
15
16
  import { useModal } from "./use-modal.js";
16
17
  import { useMemo } from "react";
17
18
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -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,SAClB,WACA,qBAAqB,MACrB,MACA,QACA,UACA,UACA,eACA,QACA,QACA,iBACA,wBAAwB,MACxB,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K,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,IACA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CACF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K,CAAC,CAAC,CAAC,EAAE;AAC/D,CAAC"}
@@ -1,5 +1,7 @@
1
1
  "use client";
2
+ import { useSplitChildren, wrapOrPassProps } from "../../utils/children.js";
2
3
  import { utils_exports } from "../../utils/index.js";
4
+ import { mergeProps } from "../../core/components/props.js";
3
5
  import { createSlotComponent } from "../../core/components/create-component.js";
4
6
  import { motion as motion$1 } from "../motion/factory.js";
5
7
  import { useValue } from "../../hooks/use-value/index.js";
@@ -9,7 +11,7 @@ import { Portal } from "../portal/portal.js";
9
11
  import { slideFadeVariants } from "../slide-fade/slide-fade.js";
10
12
  import { usePopover } from "./use-popover.js";
11
13
  import { useMemo } from "react";
12
- import { jsx } from "react/jsx-runtime";
14
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
13
15
  import { AnimatePresence } from "motion/react";
14
16
  //#region src/components/popover/popover.tsx
15
17
  const usePopupAnimationProps = (props = {}) => {
@@ -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] = useSplitChildren((0, utils_exports.isFunction)(children) ? void 0 : children, PopoverTrigger, PopoverAnchor, PopoverContent);
104
107
  const { open, getAnchorProps, getBodyProps, getCloseTriggerProps, getContentProps, getFooterProps, getHeaderProps, getPositionerProps, getTriggerProps, onClose } = usePopover(rest);
105
108
  const componentContext = 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__ */ jsx(PopoverAnchor, { children: anchorProp }) : null;
148
+ const customTrigger = triggerProp ? /* @__PURE__ */ jsx(PopoverTrigger, { children: triggerProp }) : null;
149
+ const customContentProp = header !== void 0 || body !== void 0 || footer !== void 0 ? /* @__PURE__ */ jsx(ShorthandPopoverContent, {
150
+ body,
151
+ footer,
152
+ header
153
+ }) : null;
130
154
  return /* @__PURE__ */ jsx(StyleContext, {
131
155
  value: styleContext,
132
156
  children: /* @__PURE__ */ jsx(ComponentContext, {
133
157
  value: componentContext,
134
- children: (0, utils_exports.runIfFn)(children, {
158
+ children: (0, utils_exports.isFunction)(children) ? (0, utils_exports.runIfFn)(children, {
135
159
  open,
136
160
  onClose
137
- })
161
+ }) : /* @__PURE__ */ jsxs(Fragment$1, { 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(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(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(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__ */ jsx(AnimatePresence, { children: open ? /* @__PURE__ */ jsx(Portal, {
167
- ...portalProps,
196
+ ...mergeProps(portalProps, portalPropsProp)(),
168
197
  children: /* @__PURE__ */ jsx(PopoverPositioner, {
169
- ...positionerProps,
198
+ ...mergeProps(positionerProps, positionerPropsProp)(),
170
199
  children: /* @__PURE__ */ jsx(motion$1.div, {
171
200
  ...popupAnimationProps,
172
- ...(0, utils_exports.cast)(getContentProps((0, utils_exports.cast)(rest)))
201
+ ...(0, utils_exports.cast)(getContentProps((0, utils_exports.cast)(mergeProps(contentProps, rest)())))
173
202
  })
174
203
  })
175
204
  }) : null });
176
205
  }, "content")();
206
+ const ShorthandPopoverContent = ({ body, footer, header }) => {
207
+ const customHeader = wrapOrPassProps(PopoverHeader, header);
208
+ const customBody = wrapOrPassProps(PopoverBody, body);
209
+ const customFooter = wrapOrPassProps(PopoverFooter, footer);
210
+ return /* @__PURE__ */ 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(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(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(mergeProps(footerProps, props)());
188
227
  });
189
228
  //#endregion
190
229
  export { PopoverAnchor, PopoverBody, PopoverCloseTrigger, PopoverContent, PopoverFooter, PopoverHeader, PopoverPropsContext, PopoverRoot, PopoverTrigger, usePopoverPropsContext, usePopoverStyleProps, usePopupAnimationProps };