@plexui/ui 0.30.0 → 0.32.0

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 (102) hide show
  1. package/dist/es/components/ButtonGroup/ButtonGroup.js +1 -1
  2. package/dist/es/components/ButtonGroup/ButtonGroup.js.map +1 -1
  3. package/dist/es/components/ButtonGroup/index.js.map +1 -1
  4. package/dist/es/components/ContextMenu/shared.js +3 -2
  5. package/dist/es/components/ContextMenu/shared.js.map +1 -1
  6. package/dist/es/components/Dialog/Dialog.js +42 -29
  7. package/dist/es/components/Dialog/Dialog.js.map +1 -1
  8. package/dist/es/components/Dialog/dialogSteps.js +85 -0
  9. package/dist/es/components/Dialog/dialogSteps.js.map +1 -0
  10. package/dist/es/components/Dialog/dialogViewport.js +74 -0
  11. package/dist/es/components/Dialog/dialogViewport.js.map +1 -0
  12. package/dist/es/components/Dialog/index.js +1 -1
  13. package/dist/es/components/Dialog/index.js.map +1 -1
  14. package/dist/es/components/Dialog/sheetDrag.js +2 -1
  15. package/dist/es/components/Dialog/sheetDrag.js.map +1 -1
  16. package/dist/es/components/IndexBar/IndexBar.js +164 -0
  17. package/dist/es/components/IndexBar/IndexBar.js.map +1 -0
  18. package/dist/es/components/IndexBar/index.js +2 -0
  19. package/dist/es/components/IndexBar/index.js.map +1 -0
  20. package/dist/es/components/MarkdownEditor/MarkdownEditor.js +142 -1
  21. package/dist/es/components/MarkdownEditor/MarkdownEditor.js.map +1 -1
  22. package/dist/es/components/Menu/Menu.js +57 -35
  23. package/dist/es/components/Menu/Menu.js.map +1 -1
  24. package/dist/es/components/Page/Page.js +1 -1
  25. package/dist/es/components/Page/Page.js.map +1 -1
  26. package/dist/es/components/PhoneLayout/PhoneLayout.js +41 -0
  27. package/dist/es/components/PhoneLayout/PhoneLayout.js.map +1 -0
  28. package/dist/es/components/PhoneLayout/index.js +2 -0
  29. package/dist/es/components/PhoneLayout/index.js.map +1 -0
  30. package/dist/es/components/Slider/Slider.js +33 -3
  31. package/dist/es/components/Slider/Slider.js.map +1 -1
  32. package/dist/es/components/SwipeActions/SwipeActions.js +321 -0
  33. package/dist/es/components/SwipeActions/SwipeActions.js.map +1 -0
  34. package/dist/es/components/SwipeActions/index.js +2 -0
  35. package/dist/es/components/SwipeActions/index.js.map +1 -0
  36. package/dist/es/components/TabBar/TabBar.js +4 -4
  37. package/dist/es/components/TabBar/TabBar.js.map +1 -1
  38. package/dist/es/components/TabBar/index.js.map +1 -1
  39. package/dist/es/components/Tabs/Tabs.js +1 -1
  40. package/dist/es/components/Tabs/Tabs.js.map +1 -1
  41. package/dist/es/components/TagInput/TagInput.js +5 -65
  42. package/dist/es/components/TagInput/TagInput.js.map +1 -1
  43. package/dist/es/components/Textarea/Textarea.js +1 -1
  44. package/dist/es/components/Textarea/Textarea.js.map +1 -1
  45. package/dist/es/components/Tip/Tip.js +106 -0
  46. package/dist/es/components/Tip/Tip.js.map +1 -0
  47. package/dist/es/components/Tip/index.js +2 -0
  48. package/dist/es/components/Tip/index.js.map +1 -0
  49. package/dist/es/components/Toast/ToastRenderer.js +22 -9
  50. package/dist/es/components/Toast/ToastRenderer.js.map +1 -1
  51. package/dist/es/components/Toast/Toaster.js +17 -6
  52. package/dist/es/components/Toast/Toaster.js.map +1 -1
  53. package/dist/es/components/Toast/toastLifecycle.js +113 -1
  54. package/dist/es/components/Toast/toastLifecycle.js.map +1 -1
  55. package/dist/es/components/Toolbar/Toolbar.js +1 -1
  56. package/dist/es/components/Toolbar/Toolbar.js.map +1 -1
  57. package/dist/es/hooks/useEscCloseStack.js +10 -3
  58. package/dist/es/hooks/useEscCloseStack.js.map +1 -1
  59. package/dist/es/hooks/usePhoneSubmenu.js +6 -3
  60. package/dist/es/hooks/usePhoneSubmenu.js.map +1 -1
  61. package/dist/es/lib/floatingBoundary.js +3 -1
  62. package/dist/es/lib/floatingBoundary.js.map +1 -1
  63. package/dist/es/lib/helpers.js +21 -0
  64. package/dist/es/lib/helpers.js.map +1 -1
  65. package/dist/es/lib/menuInitialFocus.js +5 -3
  66. package/dist/es/lib/menuInitialFocus.js.map +1 -1
  67. package/dist/es/lib/menuSubmenuPlacement.js +129 -5
  68. package/dist/es/lib/menuSubmenuPlacement.js.map +1 -1
  69. package/dist/es/lib/menuTriggerCover.js +10 -4
  70. package/dist/es/lib/menuTriggerCover.js.map +1 -1
  71. package/dist/es/lib/phoneLayout.js +16 -0
  72. package/dist/es/lib/phoneLayout.js.map +1 -0
  73. package/dist/es/lib/toastRegion.js +6 -0
  74. package/dist/es/lib/toastRegion.js.map +1 -0
  75. package/dist/types/components/ButtonGroup/ButtonGroup.d.ts +8 -1
  76. package/dist/types/components/ButtonGroup/index.d.ts +1 -1
  77. package/dist/types/components/ContextMenu/shared.d.ts +3 -2
  78. package/dist/types/components/Dialog/Dialog.d.ts +48 -3
  79. package/dist/types/components/Dialog/dialogSteps.d.ts +10 -0
  80. package/dist/types/components/Dialog/dialogViewport.d.ts +1 -0
  81. package/dist/types/components/Dialog/index.d.ts +1 -1
  82. package/dist/types/components/IndexBar/IndexBar.d.ts +35 -0
  83. package/dist/types/components/IndexBar/index.d.ts +1 -0
  84. package/dist/types/components/Menu/Menu.d.ts +6 -2
  85. package/dist/types/components/Page/Page.d.ts +1 -1
  86. package/dist/types/components/PhoneLayout/PhoneLayout.d.ts +18 -0
  87. package/dist/types/components/PhoneLayout/index.d.ts +1 -0
  88. package/dist/types/components/SwipeActions/SwipeActions.d.ts +46 -0
  89. package/dist/types/components/SwipeActions/index.d.ts +1 -0
  90. package/dist/types/components/TabBar/TabBar.d.ts +18 -4
  91. package/dist/types/components/TabBar/index.d.ts +1 -1
  92. package/dist/types/components/Tip/Tip.d.ts +57 -0
  93. package/dist/types/components/Tip/index.d.ts +1 -0
  94. package/dist/types/components/Toast/toastLifecycle.d.ts +34 -0
  95. package/dist/types/components/Toolbar/Toolbar.d.ts +5 -3
  96. package/dist/types/hooks/useEscCloseStack.d.ts +5 -1
  97. package/dist/types/hooks/usePhoneSubmenu.d.ts +2 -1
  98. package/dist/types/lib/helpers.d.ts +6 -0
  99. package/dist/types/lib/menuSubmenuPlacement.d.ts +9 -2
  100. package/dist/types/lib/phoneLayout.d.ts +11 -0
  101. package/dist/types/lib/toastRegion.d.ts +5 -0
  102. package/package.json +2 -2
@@ -5,7 +5,7 @@ import { Slot } from "radix-ui";
5
5
  import {} from "react";
6
6
  import { Separator } from "../Separator/index.js";
7
7
  import s from "@plexui/styles/components/ButtonGroup/ButtonGroup.module.css";
8
- const ButtonGroupRoot = ({ orientation = "horizontal", className, ref, ...restProps }) => (_jsx("div", { ref: ref, role: "group", "data-slot": "button-group", "data-orientation": orientation, className: clsx(s.Root, className), ...restProps }));
8
+ const ButtonGroupRoot = ({ orientation = "horizontal", mobileMaterial, className, ref, ...restProps }) => (_jsx("div", { ref: ref, role: "group", "data-slot": "button-group", "data-orientation": orientation, "data-mobile-material": mobileMaterial, className: clsx(s.Root, className), ...restProps }));
9
9
  const ButtonGroupSeparator = ({ className, orientation, ...restProps }) => (_jsx(Separator, { "data-slot": "button-group-separator", orientation: orientation ?? "vertical", className: clsx(s.Separator, className), ...restProps }));
10
10
  const ButtonGroupText = ({ asChild = false, className, ref, ...restProps }) => {
11
11
  const Comp = asChild ? Slot.Root : "div";
@@ -1 +1 @@
1
- {"version":3,"file":"ButtonGroup.js","sourceRoot":"","sources":["../../../../src/components/ButtonGroup/ButtonGroup.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AAC/B,OAAO,EAAsD,MAAM,OAAO,CAAA;AAC1E,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,CAAC,MAAM,8DAA8D,CAAA;AAkB5E,MAAM,eAAe,GAAG,CAAC,EACvB,WAAW,GAAG,YAAY,EAC1B,SAAS,EACT,GAAG,EACH,GAAG,SAAS,EACK,EAAE,EAAE,CAAC,CACtB,cACE,GAAG,EAAE,GAAG,EACR,IAAI,EAAC,OAAO,eACF,cAAc,sBACN,WAAW,EAC7B,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,SAAS,CAAC,KAC9B,SAAS,GACb,CACH,CAAA;AAkBD,MAAM,oBAAoB,GAAG,CAAC,EAC5B,SAAS,EACT,WAAW,EACX,GAAG,SAAS,EACc,EAAE,EAAE,CAAC,CAC/B,KAAC,SAAS,iBACE,wBAAwB,EAClC,WAAW,EAAE,WAAW,IAAI,UAAU,EACtC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,SAAS,EAAE,SAAS,CAAC,KACnC,SAAS,GACb,CACH,CAAA;AAiBD,MAAM,eAAe,GAAG,CAAC,EACvB,OAAO,GAAG,KAAK,EACf,SAAS,EACT,GAAG,EACH,GAAG,SAAS,EACS,EAAE,EAAE;IACzB,MAAM,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAA;IACxC,OAAO,CACL,KAAC,IAAI,IACH,GAAG,EAAE,GAAG,eACE,mBAAmB,EAC7B,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,SAAS,CAAC,KAC9B,SAAS,GACb,CACH,CAAA;AACH,CAAC,CAAA;AAWD,MAAM,CAAC,MAAM,WAAW,GAAG,eAAuC,CAAA;AAClE,WAAW,CAAC,SAAS,GAAG,oBAAoB,CAAA;AAC5C,WAAW,CAAC,IAAI,GAAG,eAAe,CAAA","sourcesContent":["\"use client\"\n\nimport clsx from \"clsx\"\nimport { Slot } from \"radix-ui\"\nimport { type ComponentProps, type HTMLAttributes, type Ref } from \"react\"\nimport { Separator } from \"../Separator\"\nimport s from \"@plexui/styles/components/ButtonGroup/ButtonGroup.module.css\"\n\n/* ------------------------------------------------------------------ */\n/* Root */\n/* ------------------------------------------------------------------ */\n\nexport type ButtonGroupOrientation = \"horizontal\" | \"vertical\"\n\nexport type ButtonGroupProps = HTMLAttributes<HTMLDivElement> & {\n /**\n * Direction of the joined buttons.\n * @default \"horizontal\"\n */\n orientation?: ButtonGroupOrientation\n className?: string\n ref?: Ref<HTMLDivElement>\n}\n\nconst ButtonGroupRoot = ({\n orientation = \"horizontal\",\n className,\n ref,\n ...restProps\n}: ButtonGroupProps) => (\n <div\n ref={ref}\n role=\"group\"\n data-slot=\"button-group\"\n data-orientation={orientation}\n className={clsx(s.Root, className)}\n {...restProps}\n />\n)\n\n/* ------------------------------------------------------------------ */\n/* Separator — thin divider between items */\n/* ------------------------------------------------------------------ */\n\nexport type ButtonGroupSeparatorProps = Omit<\n ComponentProps<typeof Separator>,\n \"orientation\"\n> & {\n /**\n * When omitted, uses `\"vertical\"`, the axis that looks right between\n * horizontal items. Pass explicitly inside a vertical group.\n * @default \"vertical\"\n */\n orientation?: ButtonGroupOrientation\n}\n\nconst ButtonGroupSeparator = ({\n className,\n orientation,\n ...restProps\n}: ButtonGroupSeparatorProps) => (\n <Separator\n data-slot=\"button-group-separator\"\n orientation={orientation ?? \"vertical\"}\n className={clsx(s.Separator, className)}\n {...restProps}\n />\n)\n\n/* ------------------------------------------------------------------ */\n/* Text — muted label/pill sharing the group's joined geometry */\n/* ------------------------------------------------------------------ */\n\nexport type ButtonGroupTextProps = HTMLAttributes<HTMLDivElement> & {\n /**\n * Swap the rendered element for a child (label, span, etc.) while\n * keeping the group's visual treatment.\n * @default false\n */\n asChild?: boolean\n className?: string\n ref?: Ref<HTMLDivElement>\n}\n\nconst ButtonGroupText = ({\n asChild = false,\n className,\n ref,\n ...restProps\n}: ButtonGroupTextProps) => {\n const Comp = asChild ? Slot.Root : \"div\"\n return (\n <Comp\n ref={ref}\n data-slot=\"button-group-text\"\n className={clsx(s.Text, className)}\n {...restProps}\n />\n )\n}\n\n/* ------------------------------------------------------------------ */\n/* Export — compound API */\n/* ------------------------------------------------------------------ */\n\ntype ButtonGroupComponent = typeof ButtonGroupRoot & {\n Separator: typeof ButtonGroupSeparator\n Text: typeof ButtonGroupText\n}\n\nexport const ButtonGroup = ButtonGroupRoot as ButtonGroupComponent\nButtonGroup.Separator = ButtonGroupSeparator\nButtonGroup.Text = ButtonGroupText\n"]}
1
+ {"version":3,"file":"ButtonGroup.js","sourceRoot":"","sources":["../../../../src/components/ButtonGroup/ButtonGroup.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AAC/B,OAAO,EAAsD,MAAM,OAAO,CAAA;AAC1E,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,CAAC,MAAM,8DAA8D,CAAA;AA0B5E,MAAM,eAAe,GAAG,CAAC,EACvB,WAAW,GAAG,YAAY,EAC1B,cAAc,EACd,SAAS,EACT,GAAG,EACH,GAAG,SAAS,EACK,EAAE,EAAE,CAAC,CACtB,cACE,GAAG,EAAE,GAAG,EACR,IAAI,EAAC,OAAO,eACF,cAAc,sBACN,WAAW,0BACP,cAAc,EACpC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,SAAS,CAAC,KAC9B,SAAS,GACb,CACH,CAAA;AAkBD,MAAM,oBAAoB,GAAG,CAAC,EAC5B,SAAS,EACT,WAAW,EACX,GAAG,SAAS,EACc,EAAE,EAAE,CAAC,CAC/B,KAAC,SAAS,iBACE,wBAAwB,EAClC,WAAW,EAAE,WAAW,IAAI,UAAU,EACtC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,SAAS,EAAE,SAAS,CAAC,KACnC,SAAS,GACb,CACH,CAAA;AAiBD,MAAM,eAAe,GAAG,CAAC,EACvB,OAAO,GAAG,KAAK,EACf,SAAS,EACT,GAAG,EACH,GAAG,SAAS,EACS,EAAE,EAAE;IACzB,MAAM,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAA;IACxC,OAAO,CACL,KAAC,IAAI,IACH,GAAG,EAAE,GAAG,eACE,mBAAmB,EAC7B,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,SAAS,CAAC,KAC9B,SAAS,GACb,CACH,CAAA;AACH,CAAC,CAAA;AAWD,MAAM,CAAC,MAAM,WAAW,GAAG,eAAuC,CAAA;AAClE,WAAW,CAAC,SAAS,GAAG,oBAAoB,CAAA;AAC5C,WAAW,CAAC,IAAI,GAAG,eAAe,CAAA","sourcesContent":["\"use client\"\n\nimport clsx from \"clsx\"\nimport { Slot } from \"radix-ui\"\nimport { type ComponentProps, type HTMLAttributes, type Ref } from \"react\"\nimport { Separator } from \"../Separator\"\nimport s from \"@plexui/styles/components/ButtonGroup/ButtonGroup.module.css\"\n\n/* ------------------------------------------------------------------ */\n/* Root */\n/* ------------------------------------------------------------------ */\n\nexport type ButtonGroupOrientation = \"horizontal\" | \"vertical\"\n\nexport type ButtonGroupMobileMaterial = \"glass\" | \"flat\"\n\nexport type ButtonGroupProps = HTMLAttributes<HTMLDivElement> & {\n /**\n * Direction of the joined buttons.\n * @default \"horizontal\"\n */\n orientation?: ButtonGroupOrientation\n /**\n * Phone surface (below 768px, with touch.css). `\"glass\"` makes the group one glass capsule, the Button Group\n * of the iOS 27 kit, for controls over the content; a group in a Toolbar is one already. `\"flat\"` keeps the\n * joined buttons in a Toolbar.\n */\n mobileMaterial?: ButtonGroupMobileMaterial\n className?: string\n ref?: Ref<HTMLDivElement>\n}\n\nconst ButtonGroupRoot = ({\n orientation = \"horizontal\",\n mobileMaterial,\n className,\n ref,\n ...restProps\n}: ButtonGroupProps) => (\n <div\n ref={ref}\n role=\"group\"\n data-slot=\"button-group\"\n data-orientation={orientation}\n data-mobile-material={mobileMaterial}\n className={clsx(s.Root, className)}\n {...restProps}\n />\n)\n\n/* ------------------------------------------------------------------ */\n/* Separator — thin divider between items */\n/* ------------------------------------------------------------------ */\n\nexport type ButtonGroupSeparatorProps = Omit<\n ComponentProps<typeof Separator>,\n \"orientation\"\n> & {\n /**\n * When omitted, uses `\"vertical\"`, the axis that looks right between\n * horizontal items. Pass explicitly inside a vertical group.\n * @default \"vertical\"\n */\n orientation?: ButtonGroupOrientation\n}\n\nconst ButtonGroupSeparator = ({\n className,\n orientation,\n ...restProps\n}: ButtonGroupSeparatorProps) => (\n <Separator\n data-slot=\"button-group-separator\"\n orientation={orientation ?? \"vertical\"}\n className={clsx(s.Separator, className)}\n {...restProps}\n />\n)\n\n/* ------------------------------------------------------------------ */\n/* Text — muted label/pill sharing the group's joined geometry */\n/* ------------------------------------------------------------------ */\n\nexport type ButtonGroupTextProps = HTMLAttributes<HTMLDivElement> & {\n /**\n * Swap the rendered element for a child (label, span, etc.) while\n * keeping the group's visual treatment.\n * @default false\n */\n asChild?: boolean\n className?: string\n ref?: Ref<HTMLDivElement>\n}\n\nconst ButtonGroupText = ({\n asChild = false,\n className,\n ref,\n ...restProps\n}: ButtonGroupTextProps) => {\n const Comp = asChild ? Slot.Root : \"div\"\n return (\n <Comp\n ref={ref}\n data-slot=\"button-group-text\"\n className={clsx(s.Text, className)}\n {...restProps}\n />\n )\n}\n\n/* ------------------------------------------------------------------ */\n/* Export — compound API */\n/* ------------------------------------------------------------------ */\n\ntype ButtonGroupComponent = typeof ButtonGroupRoot & {\n Separator: typeof ButtonGroupSeparator\n Text: typeof ButtonGroupText\n}\n\nexport const ButtonGroup = ButtonGroupRoot as ButtonGroupComponent\nButtonGroup.Separator = ButtonGroupSeparator\nButtonGroup.Text = ButtonGroupText\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/ButtonGroup/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,GAIZ,MAAM,eAAe,CAAA","sourcesContent":["export {\n ButtonGroup,\n type ButtonGroupProps,\n type ButtonGroupOrientation,\n type ButtonGroupSeparatorProps,\n} from \"./ButtonGroup\"\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/ButtonGroup/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,GAKZ,MAAM,eAAe,CAAA","sourcesContent":["export {\n ButtonGroup,\n type ButtonGroupProps,\n type ButtonGroupMobileMaterial,\n type ButtonGroupOrientation,\n type ButtonGroupSeparatorProps,\n} from \"./ButtonGroup\"\n"]}
@@ -2,8 +2,9 @@
2
2
  export const CONTEXT_MENU_LONG_PRESS = 500;
3
3
  /** A touch that moves farther than this before then scrolls or drags instead. */
4
4
  export const CONTEXT_MENU_LONG_PRESS_SLOP = 10;
5
- /** The kit's gap between the preview and the menu (Context Menu, Alignment=Vertical: 160 + 18 = 178). */
6
- export const CONTEXT_MENU_PREVIEW_GAP = 18;
5
+ /** The kit's gap between the preview and the menu: iOS 27 Context Menu 125:58750, Alignment=Vertical, the menu at
6
+ * 176.5 under a content area that ends at 160.5 (the iOS 26 kit had 18). */
7
+ export const CONTEXT_MENU_PREVIEW_GAP = 16;
7
8
  /** The kit's preview corner (Content Area, radius 30), for an element without corners of its own. */
8
9
  const PREVIEW_RADIUS = 30;
9
10
  const px = (value, base) => {
@@ -1 +1 @@
1
- {"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../../src/components/ContextMenu/shared.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CAAA;AAC1C,iFAAiF;AACjF,MAAM,CAAC,MAAM,4BAA4B,GAAG,EAAE,CAAA;AAC9C,yGAAyG;AACzG,MAAM,CAAC,MAAM,wBAAwB,GAAG,EAAE,CAAA;AAC1C,qGAAqG;AACrG,MAAM,cAAc,GAAG,EAAE,CAAA;AAUzB,MAAM,EAAE,GAAG,CAAC,KAAa,EAAE,IAAY,EAAE,EAAE;IACzC,MAAM,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;IACvC,IAAI,CAAC,MAAM,CAAC,QAAQ,C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C,KAAK,CAAC,CAAA;IACnC,MAAM,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IACpC,MAAM,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;IAC/B,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,KAAK,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,KAAK,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAA;IACjR,MAAM,GAAG,GAAG,kDAAkD,KAAK,aAAa,MAAM,kBAAkB,KAAK,IAAI,MAAM,uCAAuC,KAAK,IAAI,MAAM,MAAM,IAAI,WAAW,CAAA;IAClM,OAAO,EAAE,qBAAqB,EAAE,2BAA2B,kBAAkB,CAAC,GAAG,CAAC,IAAI,EAAE,CAAA;AAC1F,CAAC","sourcesContent":["/** A touch held this long opens the menu, as a UIKit long press (0.5 s). */\nexport const CONTEXT_MENU_LONG_PRESS = 500\n/** A touch that moves farther than this before then scrolls or drags instead. */\nexport const CONTEXT_MENU_LONG_PRESS_SLOP = 10\n/** The kit's gap between the preview and the menu (Context Menu, Alignment=Vertical: 160 + 18 = 178). */\nexport const CONTEXT_MENU_PREVIEW_GAP = 18\n/** The kit's preview corner (Content Area, radius 30), for an element without corners of its own. */\nconst PREVIEW_RADIUS = 30\n\ntype Rect = { x: number; y: number; width: number; height: number }\n\n/** Where the menu opens: at the pointer, under the element for the keyboard, or beside a touch-and-hold preview. */\nexport type ContextMenuPresentation =\n | { kind: \"pointer\"; rect: Rect }\n | { kind: \"keyboard\"; rect: Rect }\n | { kind: \"preview\"; rect: Rect; radius: number; align: \"start\" | \"end\" }\n\nconst px = (value: string, base: number) => {\n const number = Number.parseFloat(value)\n if (!Number.isFinite(number)) return 0\n return value.trim().endsWith(\"%\") ? (number / 100) * base : number\n}\n\n/**\n * The preview of a touch and hold: the element's box and corner (its own, or `--context-menu-preview-radius`), and\n * the edge the menu keeps to, the one on the side of the touch, as the kit's Side=Leading and Side=Trailing.\n */\nexport function contextMenuPreview(element: HTMLElement, touchX: number): ContextMenuPresentation {\n const box = element.getBoundingClientRect()\n const rect = { x: box.left, y: box.top, width: box.width, height: box.height }\n const style = getComputedStyle(element)\n const short = Math.min(rect.width, rect.height)\n const own = px(style.borderTopLeftRadius, short)\n const fallback = px(style.getPropertyValue(\"--context-menu-preview-radius\"), short) || PREVIEW_RADIUS\n const radius = Math.min(own > 0 ? own : fallback, short / 2)\n const width = element.ownerDocument.defaultView?.innerWidth ?? rect.x + rect.width\n return { kind: \"preview\", rect, radius, align: touchX < width / 2 ? \"start\" : \"end\" }\n}\n\n/** The menu's side, alignment and offsets for a presentation. */\nexport function contextMenuPlacement(presentation: ContextMenuPresentation | null) {\n if (presentation?.kind === \"preview\")\n return { side: \"bottom\" as const, align: presentation.align, sideOffset: CONTEXT_MENU_PREVIEW_GAP, alignOffset: 0 }\n if (presentation?.kind === \"keyboard\") return { side: \"bottom\" as const, align: \"start\" as const, sideOffset: 5, alignOffset: 0 }\n // As a desktop context menu, its corner at the pointer.\n return { side: \"bottom\" as const, align: \"start\" as const, sideOffset: 2, alignOffset: 0 }\n}\n\nconst round = (value: number) => Math.round(value * 100) / 100\n\n/**\n * The dimming covers the page but the element: an SVG mask with the element's rounded box cut out, written to\n * `--context-menu-hole`, so the element stays clear above the dimmed, blurred page.\n */\nexport function contextMenuHoleMask(preview: Extract<ContextMenuPresentation, { kind: \"preview\" }>, viewport?: { width: number; height: number }) {\n const width = round(viewport?.width ?? window.innerWidth)\n const height = round(viewport?.height ?? window.innerHeight)\n const x = round(preview.rect.x)\n const y = round(preview.rect.y)\n const w = round(preview.rect.width)\n const h = round(preview.rect.height)\n const r = round(preview.radius)\n const hole = `M${x + r} ${y}H${round(x + w - r)}A${r} ${r} 0 0 1 ${x + w} ${round(y + r)}V${round(y + h - r)}A${r} ${r} 0 0 1 ${round(x + w - r)} ${round(y + h)}H${round(x + r)}A${r} ${r} 0 0 1 ${x} ${round(y + h - r)}V${round(y + r)}A${r} ${r} 0 0 1 ${round(x + r)} ${y}Z`\n const svg = `<svg xmlns='http://www.w3.org/2000/svg' width='${width}' height='${height}' viewBox='0 0 ${width} ${height}'><path fill-rule='evenodd' d='M0 0H${width}V${height}H0Z${hole}'/></svg>`\n return { \"--context-menu-hole\": `url(\"data:image/svg+xml,${encodeURIComponent(svg)}\")` }\n}\n"]}
1
+ {"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../../src/components/ContextMenu/shared.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CAAA;AAC1C,iFAAiF;AACjF,MAAM,CAAC,MAAM,4BAA4B,GAAG,EAAE,CAAA;AAC9C;4EAC4E;AAC5E,MAAM,CAAC,MAAM,wBAAwB,GAAG,EAAE,CAAA;AAC1C,qGAAqG;AACrG,MAAM,cAAc,GAAG,EAAE,CAAA;AAUzB,MAAM,EAAE,GAAG,CAAC,KAAa,EAAE,IAAY,EAAE,EAAE;IACzC,MAAM,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;IACvC,IAAI,CAAC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OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACnC,MAAM,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IACpC,MAAM,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;IAC/B,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,KAAK,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,KAAK,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAA;IACjR,MAAM,GAAG,GAAG,kDAAkD,KAAK,aAAa,MAAM,kBAAkB,KAAK,IAAI,MAAM,uCAAuC,KAAK,IAAI,MAAM,MAAM,IAAI,WAAW,CAAA;IAClM,OAAO,EAAE,qBAAqB,EAAE,2BAA2B,kBAAkB,CAAC,GAAG,CAAC,IAAI,EAAE,CAAA;AAC1F,CAAC","sourcesContent":["/** A touch held this long opens the menu, as a UIKit long press (0.5 s). */\nexport const CONTEXT_MENU_LONG_PRESS = 500\n/** A touch that moves farther than this before then scrolls or drags instead. */\nexport const CONTEXT_MENU_LONG_PRESS_SLOP = 10\n/** The kit's gap between the preview and the menu: iOS 27 Context Menu 125:58750, Alignment=Vertical, the menu at\n * 176.5 under a content area that ends at 160.5 (the iOS 26 kit had 18). */\nexport const CONTEXT_MENU_PREVIEW_GAP = 16\n/** The kit's preview corner (Content Area, radius 30), for an element without corners of its own. */\nconst PREVIEW_RADIUS = 30\n\ntype Rect = { x: number; y: number; width: number; height: number }\n\n/** Where the menu opens: at the pointer, under the element for the keyboard, or beside a touch-and-hold preview. */\nexport type ContextMenuPresentation =\n | { kind: \"pointer\"; rect: Rect }\n | { kind: \"keyboard\"; rect: Rect }\n | { kind: \"preview\"; rect: Rect; radius: number; align: \"start\" | \"end\" }\n\nconst px = (value: string, base: number) => {\n const number = Number.parseFloat(value)\n if (!Number.isFinite(number)) return 0\n return value.trim().endsWith(\"%\") ? (number / 100) * base : number\n}\n\n/**\n * The preview of a touch and hold: the element's box and corner (its own, or `--context-menu-preview-radius`), and\n * the edge the menu keeps to, the one on the side of the touch, as the kit's Side=Leading and Side=Trailing.\n */\nexport function contextMenuPreview(element: HTMLElement, touchX: number): ContextMenuPresentation {\n const box = element.getBoundingClientRect()\n const rect = { x: box.left, y: box.top, width: box.width, height: box.height }\n const style = getComputedStyle(element)\n const short = Math.min(rect.width, rect.height)\n const own = px(style.borderTopLeftRadius, short)\n const fallback = px(style.getPropertyValue(\"--context-menu-preview-radius\"), short) || PREVIEW_RADIUS\n const radius = Math.min(own > 0 ? own : fallback, short / 2)\n const width = element.ownerDocument.defaultView?.innerWidth ?? rect.x + rect.width\n return { kind: \"preview\", rect, radius, align: touchX < width / 2 ? \"start\" : \"end\" }\n}\n\n/** The menu's side, alignment and offsets for a presentation. */\nexport function contextMenuPlacement(presentation: ContextMenuPresentation | null) {\n if (presentation?.kind === \"preview\")\n return { side: \"bottom\" as const, align: presentation.align, sideOffset: CONTEXT_MENU_PREVIEW_GAP, alignOffset: 0 }\n if (presentation?.kind === \"keyboard\") return { side: \"bottom\" as const, align: \"start\" as const, sideOffset: 5, alignOffset: 0 }\n // As a desktop context menu, its corner at the pointer.\n return { side: \"bottom\" as const, align: \"start\" as const, sideOffset: 2, alignOffset: 0 }\n}\n\nconst round = (value: number) => Math.round(value * 100) / 100\n\n/**\n * The dimming covers the page but the element: an SVG mask with the element's rounded box cut out, written to\n * `--context-menu-hole`, so the element stays clear above the dimmed, blurred page.\n */\nexport function contextMenuHoleMask(preview: Extract<ContextMenuPresentation, { kind: \"preview\" }>, viewport?: { width: number; height: number }) {\n const width = round(viewport?.width ?? window.innerWidth)\n const height = round(viewport?.height ?? window.innerHeight)\n const x = round(preview.rect.x)\n const y = round(preview.rect.y)\n const w = round(preview.rect.width)\n const h = round(preview.rect.height)\n const r = round(preview.radius)\n const hole = `M${x + r} ${y}H${round(x + w - r)}A${r} ${r} 0 0 1 ${x + w} ${round(y + r)}V${round(y + h - r)}A${r} ${r} 0 0 1 ${round(x + w - r)} ${round(y + h)}H${round(x + r)}A${r} ${r} 0 0 1 ${x} ${round(y + h - r)}V${round(y + r)}A${r} ${r} 0 0 1 ${round(x + r)} ${y}Z`\n const svg = `<svg xmlns='http://www.w3.org/2000/svg' width='${width}' height='${height}' viewBox='0 0 ${width} ${height}'><path fill-rule='evenodd' d='M0 0H${width}V${height}H0Z${hole}'/></svg>`\n return { \"--context-menu-hole\": `url(\"data:image/svg+xml,${encodeURIComponent(svg)}\")` }\n}\n"]}
@@ -2,10 +2,11 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import clsx from "clsx";
4
4
  import { Dialog as RadixDialog } from "radix-ui";
5
- import { Children, cloneElement, createContext, Fragment, isValidElement, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore, } from "react";
5
+ import { Children, cloneElement, createContext, Fragment, isValidElement, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState, } from "react";
6
6
  import { FloatingBoundaryProvider, useFloatingBoundaryRegistration, useFloatingBoundaryScope } from "../../hooks/useFloatingBoundary.js";
7
7
  import { useEscCloseStack } from "../../hooks/useEscCloseStack.js";
8
- import { keepMovedFocus, preventDefaultHandler, toCssVariables } from "../../lib/helpers.js";
8
+ import { inToastRegion } from "../../lib/toastRegion.js";
9
+ import { cancelableKeyCopy, dataAttributes, keepMovedFocus, preventDefaultHandler, toCssVariables } from "../../lib/helpers.js";
9
10
  import { useStableCallback } from "../../hooks/useStableCallback.js";
10
11
  import { NavigationButton } from "../Button/NavigationButton.js";
11
12
  import { Toolbar, ToolbarHostContext } from "../Toolbar/Toolbar.js";
@@ -13,6 +14,9 @@ import { NO_SCROLL_EDGES, observeScrollEdges, sameScrollEdges } from "../../lib/
13
14
  import { TransitionGroup } from "../Transition/index.js";
14
15
  import { createExitGuard, overlayTiming, overlayTimingLarge } from "../Transition/shared.js";
15
16
  import { attachSheetDrag } from "./sheetDrag.js";
17
+ import { watchDialogViewport } from "./dialogViewport.js";
18
+ import { enterStep, leaveStep, releaseStepHeight, settleStepHeight, STEP_TIMING } from "./dialogSteps.js";
19
+ import { PhoneLayoutContext, usePhoneLayout } from "../PhoneLayout/PhoneLayout.js";
16
20
  import { usePopoverDismissableSurface } from "../Popover/deferredOutsidePress.js";
17
21
  import s from "@plexui/styles/components/Dialog/Dialog.module.css";
18
22
  import t from "@plexui/styles/components/Toolbar/Toolbar.module.css";
@@ -41,8 +45,14 @@ export const Dialog = ({ open: controlledOpen, onOpenChange: controlledOnOpenCha
41
45
  const Trigger = ({ children }) => {
42
46
  return _jsx(RadixDialog.Trigger, { asChild: true, children: children });
43
47
  };
44
- const Content = ({ children, width = 480, showClose = true, pill = false, className, placement = "center", mobilePlacement: requestedMobilePlacement, mobileVariant, surface = "plain", onOpenAutoFocus, onCloseAutoFocus, }) => {
48
+ const Content = ({ children, width = 480, showClose = true, pill = false, className, placement = "center", mobilePlacement: requestedMobilePlacement, mobileVariant, surface = "plain", onOpenAutoFocus, onCloseAutoFocus, onEscapeKeyDown, onInteractOutside, zIndex, rootProps, overlayProps, layout = "auto", ...rest }) => {
45
49
  const { open, setOpen } = useDialogContext();
50
+ const outerPhoneLayout = useContext(PhoneLayoutContext);
51
+ // A dialog laid out as on a phone by its own prop, outside a PhoneLayout, keeps the window: what it holds and
52
+ // the dialogs it opens are phone ones too.
53
+ const phoneLayout = useMemo(() => outerPhoneLayout ?? (layout === "phone" ? { container: null } : null), [outerPhoneLayout, layout]);
54
+ const [content, setContent] = useState(null);
55
+ useDialogViewport(content, outerPhoneLayout?.container ?? null);
46
56
  const overlaySurfaceRef = usePopoverDismissableSurface();
47
57
  const mobilePlacement = mobileVariant === "alert"
48
58
  ? "center"
@@ -66,7 +76,13 @@ const Content = ({ children, width = 480, showClose = true, pill = false, classN
66
76
  onCloseAutoFocus?.(event);
67
77
  keepMovedFocus(event);
68
78
  });
69
- useEscCloseStack(open, () => {
79
+ useEscCloseStack(open, (event) => {
80
+ if (onEscapeKeyDown) {
81
+ const request = cancelableKeyCopy(event);
82
+ onEscapeKeyDown(request);
83
+ if (request.defaultPrevented)
84
+ return;
85
+ }
70
86
  setOpen(false);
71
87
  });
72
88
  useEffect(() => {
@@ -104,36 +120,30 @@ const Content = ({ children, width = 480, showClose = true, pill = false, classN
104
120
  children.observe(panel, { childList: true });
105
121
  return () => { observer?.disconnect(); children.disconnect(); };
106
122
  }, [panel]);
107
- return (_jsx(FloatingBoundaryProvider, { value: boundary, children: _jsx(RadixDialog.Portal, { forceMount: true, children: _jsx(TransitionGroup, { ...(crossesScreen ? overlayTimingLarge : overlayTiming), ...exitGuard.transition, className: s.Transition, overlay: true, preventInitialTransition: false, children: open && (_jsxs("div", { children: [_jsx(RadixDialog.Overlay, { ref: overlaySurfaceRef, className: s.Overlay }), _jsx(RadixDialog.Content, { forceMount: true, className: s.Content, "data-plex-dialog": "", style: toCssVariables({ "dialog-width": width }), "data-placement": placement === "center" ? undefined : placement, "data-mobile-placement": mobilePlacement, "data-mobile-variant": mobileVariant, "data-surface": surface, "data-pill": pill ? "" : undefined, onEscapeKeyDown: preventDefaultHandler, onInteractOutside: (event) => {
108
- // The second click of a double click lands on the overlay: it must not undo the first
109
- if (performance.now() - openedAt.current < DOUBLE_CLICK)
110
- event.preventDefault();
111
- else
112
- exitGuard.onInteractOutside(event);
113
- }, onOpenAutoFocus: onOpenAutoFocus, onCloseAutoFocus: handleCloseAutoFocus, children: _jsxs("div", { ref: setPanelRef, className: clsx(s.Panel, className), children: [showClose && (_jsx(RadixDialog.Close, { asChild: true, children: _jsx(NavigationButton, { action: "close", variant: "ghost", className: s.CloseButton, "aria-label": "Close dialog" }) })), _jsx(DialogScrollContext.Provider, { value: scroll, children: _jsx(DialogSheetContext.Provider, { value: sheet, children: _jsx(DialogBarContext.Provider, { value: false, children: _jsx(ToolbarHostContext.Provider, { value: toolbarHost, children: children }) }) }) })] }) })] }, "dialog")) }) }) }));
123
+ const layerStyle = toCssVariables({ "dialog-z-index": zIndex === undefined ? undefined : String(zIndex) });
124
+ return (_jsx(FloatingBoundaryProvider, { value: boundary, children: _jsx(PhoneLayoutContext, { value: phoneLayout, children: _jsx(RadixDialog.Portal, { forceMount: true, container: outerPhoneLayout?.container ?? undefined, children: _jsx(PhoneScope, { enabled: phoneLayout !== null && !outerPhoneLayout?.container, children: _jsx(TransitionGroup, { ...(crossesScreen ? overlayTimingLarge : overlayTiming), ...exitGuard.transition, className: s.Transition, overlay: true, preventInitialTransition: false, children: open && (_jsxs("div", { children: [_jsx(RadixDialog.Overlay, { ...overlayProps, ref: overlaySurfaceRef, className: clsx(s.Overlay, overlayProps?.className), style: { ...layerStyle, ...overlayProps?.style } }), _jsx(RadixDialog.Content, { ...dataAttributes(rest), ...rootProps, ref: setContent, forceMount: true, className: clsx(s.Content, rootProps?.className), "data-plex-dialog": "", style: { ...toCssVariables({ "dialog-width": width }), ...layerStyle, ...rootProps?.style }, "data-placement": placement === "center" ? undefined : placement, "data-mobile-placement": mobilePlacement, "data-mobile-variant": mobileVariant, "data-surface": surface, "data-pill": pill ? "" : undefined, onEscapeKeyDown: preventDefaultHandler, onInteractOutside: (event) => {
125
+ // A press or focus in a toast is not outside: the toast region is a layer above the dialog. The
126
+ // Toaster stops these before Radix sees them; this holds when the Toaster mounted after the dialog.
127
+ if (inToastRegion(event.detail.originalEvent.target))
128
+ return event.preventDefault();
129
+ onInteractOutside?.(event);
130
+ if (event.defaultPrevented)
131
+ return;
132
+ // The second click of a double click lands on the overlay: it must not undo the first
133
+ if (performance.now() - openedAt.current < DOUBLE_CLICK)
134
+ event.preventDefault();
135
+ else
136
+ exitGuard.onInteractOutside(event);
137
+ }, onOpenAutoFocus: onOpenAutoFocus, onCloseAutoFocus: handleCloseAutoFocus, children: _jsxs("div", { ref: setPanelRef, className: clsx(s.Panel, className), children: [showClose && (_jsx(RadixDialog.Close, { asChild: true, children: _jsx(NavigationButton, { action: "close", variant: "ghost", className: s.CloseButton, "aria-label": "Close dialog" }) })), _jsx(DialogScrollContext.Provider, { value: scroll, children: _jsx(DialogSheetContext.Provider, { value: sheet, children: _jsx(DialogBarContext.Provider, { value: false, children: _jsx(ToolbarHostContext.Provider, { value: toolbarHost, children: children }) }) }) })] }) })] }, "dialog")) }) }) }) }) }));
114
138
  };
115
139
  const DialogScrollContext = createContext(null);
116
140
  const DialogSheetContext = createContext(null);
117
141
  // Inside that bar: the title, the description and the header actions take the Toolbar's parts
118
142
  const DialogBarContext = createContext(false);
119
- // The phone layout of the Dialog style sheet (its rules for the Sheet's bar use the same query). A dialog's content
120
- // mounts on the client only (its portal waits for the document), so its first render already knows the layout, with
121
- // nothing to swap after it.
122
- const PHONE_LAYOUT = "(width <= 767px)";
123
- const phoneLayout = () => (typeof window !== "undefined" && typeof window.matchMedia === "function" ? window.matchMedia(PHONE_LAYOUT) : null);
124
- const subscribePhoneLayout = (onChange) => {
125
- const query = phoneLayout();
126
- if (!query)
127
- return () => { };
128
- // Safari before 14 has only the older listener methods
129
- if (typeof query.addEventListener !== "function") {
130
- query.addListener(onChange);
131
- return () => query.removeListener(onChange);
132
- }
133
- query.addEventListener("change", onChange);
134
- return () => query.removeEventListener("change", onChange);
143
+ const PhoneScope = ({ enabled, children }) => enabled ? _jsx("div", { className: s.PhoneScope, "data-plex-layout": "phone", children: children }) : children;
144
+ const useDialogViewport = (content, container) => {
145
+ useLayoutEffect(() => (content ? watchDialogViewport(content, container) : undefined), [content, container]);
135
146
  };
136
- const usePhoneLayout = () => useSyncExternalStore(subscribePhoneLayout, () => phoneLayout()?.matches ?? false, () => false);
137
147
  const TOP_TOOLBAR = '[data-toolbar][data-placement="top"]';
138
148
  const BOTTOM_TOOLBAR = '[data-toolbar][data-placement="bottom"]';
139
149
  // The header's own parts, fragments opened up, so its actions can stand at the end of the bar. A part from a
@@ -146,7 +156,7 @@ const headerParts = (children, prefix = "") => Children.toArray(children).flatMa
146
156
  return [prefix ? cloneElement(part, { key: `${prefix}${String(part.key)}` }) : part];
147
157
  });
148
158
  const isHeaderAction = (part) => isValidElement(part) && part.type === HeaderAction;
149
- const Header = ({ children, className, background = "soft" }) => {
159
+ const Header = ({ children, className, background = "glass" }) => {
150
160
  const sheet = useContext(DialogSheetContext);
151
161
  const phone = usePhoneLayout();
152
162
  const scrolled = useContext(DialogScrollContext)?.edges.scrolled;
@@ -201,6 +211,8 @@ const Description = ({ children, className }) => {
201
211
  }, [bar, children, className]);
202
212
  return (_jsx(RadixDialog.Description, { ref: element, className: clsx(bar && shown ? t.Subtitle : s.Description, className), children: children }));
203
213
  };
214
+ /** The steps of a flow inside a dialog, such as a sign-in that asks for an email and then a code. */
215
+ const Steps = ({ step, direction = "forward", children, className }) => (_jsx("div", { className: clsx(s.Steps, className), "data-direction": direction, children: _jsx(TransitionGroup, { ...STEP_TIMING, as: "div", overlay: true, className: s.Step, onEnter: enterStep, onExit: leaveStep, onExitActive: settleStepHeight, onExitComplete: releaseStepHeight, children: _jsx("div", { "data-dialog-step": "", tabIndex: -1, children: children }, step) }) }));
204
216
  const Close = ({ children }) => {
205
217
  return _jsx(RadixDialog.Close, { asChild: true, children: children });
206
218
  };
@@ -213,4 +225,5 @@ Dialog.Footer = Footer;
213
225
  Dialog.Title = Title;
214
226
  Dialog.Description = Description;
215
227
  Dialog.Close = Close;
228
+ Dialog.Steps = Steps;
216
229
  //# sourceMappingURL=Dialog.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Dialog.js","sourceRoot":"","sources":["../../../../src/components/Dialog/Dialog.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,MAAM,IAAI,WAAW,EAAE,MAAM,UAAU,CAAA;AAChD,OAAO,EACL,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,QAAQ,EACR,cAAc,EACd,WAAW,EACX,UAAU,EACV,SAAS,EACT,eAAe,EACf,OAAO,EACP,MAAM,EACN,QAAQ,EACR,oBAAoB,GAGrB,MAAM,OAAO,CAAA;AACd,OAAO,EAAE,wBAAwB,EAAE,+BAA+B,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAA;AACrI,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAA;AAC/D,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACzF,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAA;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAC7D,OAAO,EAAE,OAAO,EAAE,kBAAkB,EAAwC,MAAM,oBAAoB,CAAA;AACtG,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,eAAe,EAAoB,MAAM,uBAAuB,CAAA;AAC9G,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAC/C,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AACzF,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,EAAE,4BAA4B,EAAE,MAAM,iCAAiC,CAAA;AAC9E,OAAO,CA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,EAAE,QAAQ,EAA2B,EAAE,EAAE;IACtD,OAAO,KAAC,WAAW,CAAC,KAAK,IAAC,OAAO,kBAAE,QAAQ,GAAqB,CAAA;AAClE,CAAC,CAAA;AAED,MAAM,CAAC,OAAO,GAAG,OAAO,CAAA;AACxB,MAAM,CAAC,OAAO,GAAG,OAAO,CAAA;AACxB,MAAM,CAAC,MAAM,GAAG,MAAM,CAAA;AACtB,MAAM,CAAC,YAAY,GAAG,YAAY,CAAA;AAClC,MAAM,CAAC,IAAI,GAAG,IAAI,CAAA;AAClB,MAAM,CAAC,MAAM,GAAG,MAAM,CAAA;AACtB,MAAM,CAAC,KAAK,GAAG,KAAK,CAAA;AACpB,MAAM,CAAC,WAAW,GAAG,WAAW,CAAA;AAChC,MAAM,CAAC,KAAK,GAAG,KAAK,CAAA","sourcesContent":["\"use client\"\n\nimport clsx from \"clsx\"\nimport { Dialog as RadixDialog } from \"radix-ui\"\nimport {\n Children,\n cloneElement,\n createContext,\n Fragment,\n isValidElement,\n useCallback,\n useContext,\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n useSyncExternalStore,\n type ReactElement,\n type ReactNode,\n} from \"react\"\nimport { FloatingBoundaryProvider, useFloatingBoundaryRegistration, useFloatingBoundaryScope } from \"../../hooks/useFloatingBoundary\"\nimport { useEscCloseStack } from \"../../hooks/useEscCloseStack\"\nimport { keepMovedFocus, preventDefaultHandler, toCssVariables } from \"../../lib/helpers\"\nimport { useStableCallback } from \"../../hooks/useStableCallback\"\nimport { NavigationButton } from \"../Button/NavigationButton\"\nimport { Toolbar, ToolbarHostContext, type BarBackground, type ToolbarHost } from \"../Toolbar/Toolbar\"\nimport { NO_SCROLL_EDGES, observeScrollEdges, sameScrollEdges, type ScrollEdges } from \"../../lib/scrollEdges\"\nimport { TransitionGroup } from \"../Transition\"\nimport { createExitGuard, overlayTiming, overlayTimingLarge } from \"../Transition/shared\"\nimport { attachSheetDrag } from \"./sheetDrag\"\nimport { usePopoverDismissableSurface } from \"../Popover/deferredOutsidePress\"\nimport s from \"@plexui/styles/components/Dialog/Dialog.module.css\"\nimport t from \"@plexui/styles/components/Toolbar/Toolbar.module.css\"\n\ntype DialogContextValue = {\n open: boolean\n setOpen: (nextState: boolean) => void\n}\n\nconst DOUBLE_CLICK = 300\n\nconst DialogContext = createContext<DialogContextValue | null>(null)\n\nconst useDialogContext = () => {\n const context = useContext(DialogContext)\n\n if (!context) {\n throw new Error(\"Dialog compound components must be used inside <Dialog>\")\n }\n\n return context\n}\n\nexport type DialogProps = {\n open?: boolean\n onOpenChange?: (open: boolean) => void\n children: ReactNode\n}\n\nexport const Dialog = ({\n open: controlledOpen,\n onOpenChange: controlledOnOpenChange,\n children,\n}: DialogProps) => {\n const [open, setOpen] = useState<boolean>(false)\n const isOpen = controlledOpen ?? open\n\n const handleOpenChange = useCallback(\n (nextState: boolean) => {\n controlledOnOpenChange?.(nextState)\n setOpen(nextState)\n },\n [controlledOnOpenChange],\n )\n\n const store = useMemo<DialogContextValue>(\n () => ({\n open: isOpen,\n setOpen: handleOpenChange,\n }),\n [isOpen, handleOpenChange],\n )\n\n return (\n <DialogContext value={store}>\n <RadixDialog.Root open={isOpen} onOpenChange={handleOpenChange}>\n {children}\n </RadixDialog.Root>\n </DialogContext>\n )\n}\n\nconst Trigger = ({ children }: { children: ReactNode }) => {\n return <RadixDialog.Trigger asChild>{children}</RadixDialog.Trigger>\n}\n\nexport type DialogPlacement = \"center\" | \"top\" | \"bottom\" | \"start\" | \"end\" | \"fullscreen\"\n\nexport type DialogContentProps = {\n children: ReactNode\n width?: number | string\n showClose?: boolean\n /**\n * Rounder panel and a round close button, for dialogs that sit beside pill controls.\n * @default false\n */\n pill?: boolean\n className?: string\n /**\n * Where the panel sits: centered, near the top (search, command lists),\n * a sheet along the bottom, a full-height panel on the start or end side,\n * or the whole screen.\n * @default center\n */\n placement?: DialogPlacement\n /** Placement at 767px and below, such as a bottom sheet on phones. @default placement */\n mobilePlacement?: Extract<DialogPlacement, \"center\" | \"bottom\" | \"fullscreen\">\n /** Mobile presentation at 767px and below. Sheets default to bottom placement. */\n mobileVariant?: \"alert\" | \"sheet\"\n /** Mobile panel palette; dark mode uses elevated surfaces. @default \"plain\" */\n surface?: \"plain\" | \"grouped\"\n /**\n * Called when focus moves into the dialog on open. Call\n * `event.preventDefault()` to focus something else yourself.\n */\n onOpenAutoFocus?: (event: Event) => void\n /** Called when focus returns on close. Call `event.preventDefault()` to keep it elsewhere. */\n onCloseAutoFocus?: (event: Event) => void\n}\n\nconst Content = ({\n children,\n width = 480,\n showClose = true,\n pill = false,\n className,\n placement = \"center\",\n mobilePlacement: requestedMobilePlacement,\n mobileVariant,\n surface = \"plain\",\n onOpenAutoFocus,\n onCloseAutoFocus,\n}: DialogContentProps) => {\n const { open, setOpen } = useDialogContext()\n const overlaySurfaceRef = usePopoverDismissableSurface()\n const mobilePlacement =\n mobileVariant === \"alert\"\n ? \"center\"\n : requestedMobilePlacement ?? (mobileVariant === \"sheet\" ? \"bottom\" : undefined)\n const [exitGuard] = useState(createExitGuard)\n const [panel, setPanel] = useState<HTMLDivElement | null>(null)\n // Dialog.Body reports where content lies under the bars: they show their lines with it.\n const [edges, setEdgesState] = useState(NO_SCROLL_EDGES)\n const setEdges = useCallback((next: ScrollEdges) => setEdgesState((current) => sameScrollEdges(current, next) ? current : next), [])\n const scroll = useMemo(() => ({ edges, setEdges }), [edges, setEdges])\n const toolbarHost = useMemo<ToolbarHost>(() => ({ kind: \"dialog\", scrolled: edges.scrolled, contentBelow: edges.contentBelow }), [edges])\n const sheet = useMemo<DialogSheetValue | null>(() => (mobileVariant === \"sheet\" ? { showClose } : null), [mobileVariant, showClose])\n const boundary = useFloatingBoundaryScope()\n const setRoot = boundary.setRoot\n const setPanelRef = useCallback((node: HTMLDivElement | null) => { setPanel(node); setRoot(node) }, [setRoot])\n const openedAt = useRef(0)\n const crossesScreen =\n placement === \"bottom\" || placement === \"start\" || placement === \"end\" || placement === \"fullscreen\" || mobilePlacement === \"bottom\" || mobilePlacement === \"fullscreen\"\n\n // The content of a closing dialog is frozen for its exit, so this reads the owner's latest\n // handler: state that changes together with the close decides where focus returns.\n const handleCloseAutoFocus = useStableCallback((event: Event) => {\n onCloseAutoFocus?.(event)\n keepMovedFocus(event)\n })\n\n useEscCloseStack(open, () => {\n setOpen(false)\n })\n\n useEffect(() => {\n if (open) openedAt.current = performance.now()\n }, [open])\n\n useEffect(() => {\n if (!panel || mobilePlacement !== \"bottom\") return undefined\n return attachSheetDrag(panel, () => setOpen(false))\n }, [panel, mobilePlacement, setOpen])\n\n useLayoutEffect(() => {\n if (!panel) return\n const update = () => {\n // A phone Toolbar takes the place of the header or footer bar on its side: one the dialog places itself\n // before the bar its header becomes.\n const header = panel.querySelector<HTMLElement>(`:scope > ${TOP_TOOLBAR}:not([data-dialog-bar])`)\n ?? panel.querySelector<HTMLElement>(`:scope > ${TOP_TOOLBAR}`)\n ?? panel.querySelector<HTMLElement>(`:scope > .${s.Header}`)\n const footer = panel.querySelector<HTMLElement>(`:scope > ${BOTTOM_TOOLBAR}`) ?? panel.querySelector<HTMLElement>(`:scope > .${s.Footer}`)\n panel.style.setProperty(\"--dialog-header-height\", `${header?.offsetHeight ?? 0}px`)\n panel.style.setProperty(\"--dialog-footer-height\", `${footer?.offsetHeight ?? 0}px`)\n }\n const observer = typeof ResizeObserver !== \"undefined\" ? new ResizeObserver(update) : undefined\n const observeBars = () => {\n observer?.disconnect()\n panel.querySelectorAll<HTMLElement>(`:scope > .${s.Header}, :scope > .${s.Footer}, :scope > [data-toolbar]`)\n .forEach((bar) => observer?.observe(bar, { box: \"border-box\" }))\n update()\n }\n observeBars()\n // A form can add or remove its action bar while the dialog stays open.\n const children = new MutationObserver(observeBars)\n children.observe(panel, { childList: true })\n return () => { observer?.disconnect(); children.disconnect() }\n }, [panel])\n\n return (\n <FloatingBoundaryProvider value={boundary}>\n <RadixDialog.Portal forceMount>\n {/* A dialog mounted open enters too, as `open` set with the mount does */}\n <TransitionGroup\n {...(crossesScreen ? overlayTimingLarge : overlayTiming)}\n {...exitGuard.transition}\n className={s.Transition}\n overlay\n preventInitialTransition={false}\n >\n {open && (\n <div key=\"dialog\">\n <RadixDialog.Overlay ref={overlaySurfaceRef} className={s.Overlay} />\n <RadixDialog.Content\n forceMount\n className={s.Content}\n data-plex-dialog=\"\"\n style={toCssVariables({ \"dialog-width\": width })}\n data-placement={placement === \"center\" ? undefined : placement}\n data-mobile-placement={mobilePlacement}\n data-mobile-variant={mobileVariant}\n data-surface={surface}\n data-pill={pill ? \"\" : undefined}\n onEscapeKeyDown={preventDefaultHandler}\n onInteractOutside={(event) => {\n // The second click of a double click lands on the overlay: it must not undo the first\n if (performance.now() - openedAt.current < DOUBLE_CLICK) event.preventDefault()\n else exitGuard.onInteractOutside(event)\n }}\n onOpenAutoFocus={onOpenAutoFocus}\n onCloseAutoFocus={handleCloseAutoFocus}\n >\n <div ref={setPanelRef} className={clsx(s.Panel, className)}>\n {showClose && (\n <RadixDialog.Close asChild>\n <NavigationButton action=\"close\" variant=\"ghost\" className={s.CloseButton} aria-label=\"Close dialog\" />\n </RadixDialog.Close>\n )}\n <DialogScrollContext.Provider value={scroll}>\n <DialogSheetContext.Provider value={sheet}>\n {/* A dialog opened from a header action is not inside that header's bar */}\n <DialogBarContext.Provider value={false}>\n <ToolbarHostContext.Provider value={toolbarHost}>{children}</ToolbarHostContext.Provider>\n </DialogBarContext.Provider>\n </DialogSheetContext.Provider>\n </DialogScrollContext.Provider>\n </div>\n </RadixDialog.Content>\n </div>\n )}\n </TransitionGroup>\n </RadixDialog.Portal>\n </FloatingBoundaryProvider>\n )\n}\n\ntype DialogScrollValue = { edges: ScrollEdges; setEdges: (edges: ScrollEdges) => void }\nconst DialogScrollContext = createContext<DialogScrollValue | null>(null)\n// What the header of a Sheet needs from its Content to become the Sheet's bar on a phone\ntype DialogSheetValue = { showClose: boolean }\nconst DialogSheetContext = createContext<DialogSheetValue | null>(null)\n// Inside that bar: the title, the description and the header actions take the Toolbar's parts\nconst DialogBarContext = createContext(false)\n\n// The phone layout of the Dialog style sheet (its rules for the Sheet's bar use the same query). A dialog's content\n// mounts on the client only (its portal waits for the document), so its first render already knows the layout, with\n// nothing to swap after it.\nconst PHONE_LAYOUT = \"(width <= 767px)\"\nconst phoneLayout = () => (typeof window !== \"undefined\" && typeof window.matchMedia === \"function\" ? window.matchMedia(PHONE_LAYOUT) : null)\nconst subscribePhoneLayout = (onChange: () => void) => {\n const query = phoneLayout()\n if (!query) return () => {}\n // Safari before 14 has only the older listener methods\n if (typeof query.addEventListener !== \"function\") {\n query.addListener(onChange)\n return () => query.removeListener(onChange)\n }\n query.addEventListener(\"change\", onChange)\n return () => query.removeEventListener(\"change\", onChange)\n}\nconst usePhoneLayout = () => useSyncExternalStore(subscribePhoneLayout, () => phoneLayout()?.matches ?? false, () => false)\nconst TOP_TOOLBAR = '[data-toolbar][data-placement=\"top\"]'\nconst BOTTOM_TOOLBAR = '[data-toolbar][data-placement=\"bottom\"]'\n\ntype DialogSlotProps = {\n children: ReactNode\n className?: string\n}\n\n/** How a Sheet's bar meets the content scrolled under it; see `BarBackground`. */\nexport type DialogBarBackground = BarBackground\nexport type DialogHeaderProps = DialogSlotProps & {\n /** How the bar meets the content scrolled under it in a phone Sheet. @default \"soft\" */\n background?: DialogBarBackground\n}\n\n// The header's own parts, fragments opened up, so its actions can stand at the end of the bar. A part from a\n// fragment keeps the fragment's key before its own, so two parts never share a key.\nconst headerParts = (children: ReactNode, prefix = \"\"): ReactNode[] =>\n Children.toArray(children).flatMap((part) => {\n if (!isValidElement<{ children?: ReactNode }>(part)) return [part]\n if (part.type === Fragment) return headerParts(part.props.children, `${prefix}${String(part.key)}/`)\n return [prefix ? cloneElement(part, { key: `${prefix}${String(part.key)}` }) : part]\n })\nconst isHeaderAction = (part: ReactNode): part is ReactElement => isValidElement(part) && part.type === HeaderAction\n\nconst Header = ({ children, className, background = \"soft\" }: DialogHeaderProps) => {\n const sheet = useContext(DialogSheetContext)\n const phone = usePhoneLayout()\n const scrolled = useContext(DialogScrollContext)?.edges.scrolled\n if (sheet && phone) {\n const parts = headerParts(children)\n // On a phone the header of a Sheet is its Toolbar (iOS 27 kit Sheets 507-24684, Toolbar - Top - iPhone\n // 1-54520): Close at the leading edge, the title centered on the row of controls, the header actions at the\n // trailing edge, all on one 44px row under the grabber.\n return (\n <Toolbar background={background} className={className} data-dialog-bar=\"\">\n <DialogBarContext.Provider value={true}>\n {sheet.showClose && (\n <Toolbar.Leading className={s.BarClose}>\n <RadixDialog.Close asChild>\n <NavigationButton action=\"close\" variant=\"ghost\" aria-label=\"Close dialog\" />\n </RadixDialog.Close>\n </Toolbar.Leading>\n )}\n <div className={clsx(t.Heading, s.BarHeading)}>{parts.filter((part) => !isHeaderAction(part))}</div>\n {parts.filter(isHeaderAction)}\n </DialogBarContext.Provider>\n </Toolbar>\n )\n }\n return <div className={clsx(s.Header, className)} data-background={background} data-scrolled={scrolled ? \"\" : undefined}>{children}</div>\n}\n\nconst HeaderAction = ({ children, className }: DialogSlotProps) => {\n const bar = useContext(DialogBarContext)\n if (bar) return <Toolbar.Trailing className={className}>{children}</Toolbar.Trailing>\n return <div className={clsx(s.HeaderAction, className)}>{children}</div>\n}\n\n/** The scrolling part between Header and Footer: with it, only the body scrolls */\nconst Body = ({ children, className }: DialogSlotProps) => {\n const setEdges = useContext(DialogScrollContext)?.setEdges\n const element = useRef<HTMLDivElement | null>(null)\n useLayoutEffect(() => {\n const body = element.current\n if (!body || !setEdges) return\n const stop = observeScrollEdges(body, setEdges)\n return () => { stop(); setEdges(NO_SCROLL_EDGES) }\n }, [setEdges])\n return <div ref={element} className={clsx(s.Body, className)}>{children}</div>\n}\n\nexport type DialogFooterProps = DialogSlotProps & {\n /** How the bar meets the content scrolled under it in a phone Sheet. @default \"soft\" */\n background?: DialogBarBackground\n /** Override the mobile action layout. Alerts default to inline; sheets to stacked. */\n mobileLayout?: \"inline\" | \"stacked\"\n}\n\nconst Footer = ({ children, className, mobileLayout, background = \"soft\" }: DialogFooterProps) => {\n const setFooter = useFloatingBoundaryRegistration()?.setFooter\n const contentBelow = useContext(DialogScrollContext)?.edges.contentBelow\n return (\n <div\n ref={setFooter}\n className={clsx(s.Footer, className)}\n data-mobile-layout={mobileLayout}\n data-background={background}\n data-content-below={contentBelow ? \"\" : undefined}\n >\n {children}\n </div>\n )\n}\n\nconst Title = ({ children, className }: DialogSlotProps) => {\n const bar = useContext(DialogBarContext)\n return <RadixDialog.Title className={clsx(bar ? t.Title : s.Title, className)}>{children}</RadixDialog.Title>\n}\n\nconst Description = ({ children, className }: DialogSlotProps) => {\n const bar = useContext(DialogBarContext)\n const element = useRef<HTMLParagraphElement | null>(null)\n const [shown, setShown] = useState(false)\n useLayoutEffect(() => {\n // In the bar a description the reader sees is the title's second line (Toolbar's subtitle); one that is only\n // read out, visually hidden, leaves the title on its one line.\n const node = element.current\n // A measurement of the laid-out description, which only an effect after layout can read\n // eslint-disable-next-line react-hooks/set-state-in-effect\n setShown(bar && !!node && node.offsetHeight > 1 && node.offsetWidth > 1)\n }, [bar, children, className])\n return (\n <RadixDialog.Description ref={element} className={clsx(bar && shown ? t.Subtitle : s.Description, className)}>\n {children}\n </RadixDialog.Description>\n )\n}\n\nconst Close = ({ children }: { children: ReactNode }) => {\n return <RadixDialog.Close asChild>{children}</RadixDialog.Close>\n}\n\nDialog.Trigger = Trigger\nDialog.Content = Content\nDialog.Header = Header\nDialog.HeaderAction = HeaderAction\nDialog.Body = Body\nDialog.Footer = Footer\nDialog.Title = Title\nDialog.Description = Description\nDialog.Close = Close\n"]}
1
+ {"version":3,"file":"Dialog.js","sourceRoot":"","sources":["../../../../src/components/Dialog/Dialog.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,MAAM,IAAI,WAAW,EAAE,MAAM,UAAU,CAAA;AAChD,OAAO,EACL,QAAQ,EACR,YAAY,EACZ,a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,OAAK,WAAW,EAAE,EAAE,EAAC,KAAK,EAAC,OAAO,QAAC,SAAS,EAAE,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,gBAAgB,EAAE,cAAc,EAAE,iBAAiB,YAC5K,kCAAiC,EAAE,EAAC,QAAQ,EAAE,CAAC,CAAC,YAAG,QAAQ,IAAjD,IAAI,CAAoD,GAClD,GACd,CACP,CAAA;AAED,MAAM,KAAK,GAAG,CAAC,EAAE,QAAQ,EAA2B,EAAE,EAAE;IACtD,OAAO,KAAC,WAAW,CAAC,KAAK,IAAC,OAAO,kBAAE,QAAQ,GAAqB,CAAA;AAClE,CAAC,CAAA;AAED,MAAM,CAAC,OAAO,GAAG,OAAO,CAAA;AACxB,MAAM,CAAC,OAAO,GAAG,OAAO,CAAA;AACxB,MAAM,CAAC,MAAM,GAAG,MAAM,CAAA;AACtB,MAAM,CAAC,YAAY,GAAG,YAAY,CAAA;AAClC,MAAM,CAAC,IAAI,GAAG,IAAI,CAAA;AAClB,MAAM,CAAC,MAAM,GAAG,MAAM,CAAA;AACtB,MAAM,CAAC,KAAK,GAAG,KAAK,CAAA;AACpB,MAAM,CAAC,WAAW,GAAG,WAAW,CAAA;AAChC,MAAM,CAAC,KAAK,GAAG,KAAK,CAAA;AACpB,MAAM,CAAC,KAAK,GAAG,KAAK,CAAA","sourcesContent":["\"use client\"\n\nimport clsx from \"clsx\"\nimport { Dialog as RadixDialog } from \"radix-ui\"\nimport {\n Children,\n cloneElement,\n createContext,\n Fragment,\n isValidElement,\n useCallback,\n useContext,\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n type CSSProperties,\n type ReactElement,\n type ReactNode,\n} from \"react\"\nimport { FloatingBoundaryProvider, useFloatingBoundaryRegistration, useFloatingBoundaryScope } from \"../../hooks/useFloatingBoundary\"\nimport { useEscCloseStack } from \"../../hooks/useEscCloseStack\"\nimport { inToastRegion } from \"../../lib/toastRegion\"\nimport { cancelableKeyCopy, dataAttributes, keepMovedFocus, preventDefaultHandler, toCssVariables } from \"../../lib/helpers\"\nimport { useStableCallback } from \"../../hooks/useStableCallback\"\nimport { NavigationButton } from \"../Button/NavigationButton\"\nimport { Toolbar, ToolbarHostContext, type BarBackground, type ToolbarHost } from \"../Toolbar/Toolbar\"\nimport { NO_SCROLL_EDGES, observeScrollEdges, sameScrollEdges, type ScrollEdges } from \"../../lib/scrollEdges\"\nimport { TransitionGroup } from \"../Transition\"\nimport { createExitGuard, overlayTiming, overlayTimingLarge } from \"../Transition/shared\"\nimport { attachSheetDrag } from \"./sheetDrag\"\nimport { watchDialogViewport } from \"./dialogViewport\"\nimport { enterStep, leaveStep, releaseStepHeight, settleStepHeight, STEP_TIMING } from \"./dialogSteps\"\nimport { PhoneLayoutContext, usePhoneLayout, type PhoneLayoutValue } from \"../PhoneLayout/PhoneLayout\"\nimport { usePopoverDismissableSurface } from \"../Popover/deferredOutsidePress\"\nimport s from \"@plexui/styles/components/Dialog/Dialog.module.css\"\nimport t from \"@plexui/styles/components/Toolbar/Toolbar.module.css\"\n\ntype DialogContextValue = {\n open: boolean\n setOpen: (nextState: boolean) => void\n}\n\nconst DOUBLE_CLICK = 300\n\nconst DialogContext = createContext<DialogContextValue | null>(null)\n\nconst useDialogContext = () => {\n const context = useContext(DialogContext)\n\n if (!context) {\n throw new Error(\"Dialog compound components must be used inside <Dialog>\")\n }\n\n return context\n}\n\nexport type DialogProps = {\n open?: boolean\n onOpenChange?: (open: boolean) => void\n children: ReactNode\n}\n\nexport const Dialog = ({\n open: controlledOpen,\n onOpenChange: controlledOnOpenChange,\n children,\n}: DialogProps) => {\n const [open, setOpen] = useState<boolean>(false)\n const isOpen = controlledOpen ?? open\n\n const handleOpenChange = useCallback(\n (nextState: boolean) => {\n controlledOnOpenChange?.(nextState)\n setOpen(nextState)\n },\n [controlledOnOpenChange],\n )\n\n const store = useMemo<DialogContextValue>(\n () => ({\n open: isOpen,\n setOpen: handleOpenChange,\n }),\n [isOpen, handleOpenChange],\n )\n\n return (\n <DialogContext value={store}>\n <RadixDialog.Root open={isOpen} onOpenChange={handleOpenChange}>\n {children}\n </RadixDialog.Root>\n </DialogContext>\n )\n}\n\nconst Trigger = ({ children }: { children: ReactNode }) => {\n return <RadixDialog.Trigger asChild>{children}</RadixDialog.Trigger>\n}\n\nexport type DialogPlacement = \"center\" | \"top\" | \"bottom\" | \"start\" | \"end\" | \"fullscreen\"\n\n/** A press or a focus outside the dialog; `event.detail.originalEvent` is the browser's event. */\nexport type DialogInteractOutsideEvent = CustomEvent<{ originalEvent: PointerEvent | FocusEvent }>\n\n/** Class, style and data attributes for one of the dialog's layers. */\nexport type DialogLayerProps = {\n className?: string\n style?: CSSProperties\n [dataAttribute: `data-${string}`]: string | number | boolean | undefined\n}\n\nexport type DialogContentProps = {\n children: ReactNode\n width?: number | string\n showClose?: boolean\n /**\n * Rounder panel and a round close button, for dialogs that sit beside pill controls.\n * @default false\n */\n pill?: boolean\n className?: string\n /**\n * Where the panel sits: centered, near the top (search, command lists),\n * a sheet along the bottom, a full-height panel on the start or end side,\n * or the whole screen.\n * @default center\n */\n placement?: DialogPlacement\n /** Placement at 767px and below, such as a bottom sheet on phones. @default placement */\n mobilePlacement?: Extract<DialogPlacement, \"center\" | \"bottom\" | \"fullscreen\">\n /** Mobile presentation at 767px and below. Sheets default to bottom placement. */\n mobileVariant?: \"alert\" | \"sheet\"\n /** Mobile panel palette; dark mode uses elevated surfaces. @default \"plain\" */\n surface?: \"plain\" | \"grouped\"\n /**\n * Called when focus moves into the dialog on open. Call\n * `event.preventDefault()` to focus something else yourself.\n */\n onOpenAutoFocus?: (event: Event) => void\n /** Called when focus returns on close. Call `event.preventDefault()` to keep it elsewhere. */\n onCloseAutoFocus?: (event: Event) => void\n /**\n * Called on Escape before the dialog closes. Call `event.preventDefault()` to keep it open, such as for a form\n * with unsaved changes.\n */\n onEscapeKeyDown?: (event: KeyboardEvent) => void\n /**\n * Called on a press or a focus outside the dialog before it closes. Call `event.preventDefault()` to keep it open,\n * such as for a press on a developer panel over the page.\n */\n onInteractOutside?: (event: DialogInteractOutsideEvent) => void\n /** Stack order of the overlay and the dialog. @default 50 */\n zIndex?: number\n /** Class, style and data attributes for the fixed layer that holds the panel. Data attributes of Content land here too. */\n rootProps?: DialogLayerProps\n /** Class, style and data attributes for the overlay. */\n overlayProps?: DialogLayerProps\n /**\n * `phone` lays the dialog out as on a phone at any window width. Inside a PhoneLayout it always is.\n * @default \"auto\"\n */\n layout?: \"auto\" | \"phone\"\n [dataAttribute: `data-${string}`]: string | number | boolean | undefined\n}\n\nconst Content = ({\n children,\n width = 480,\n showClose = true,\n pill = false,\n className,\n placement = \"center\",\n mobilePlacement: requestedMobilePlacement,\n mobileVariant,\n surface = \"plain\",\n onOpenAutoFocus,\n onCloseAutoFocus,\n onEscapeKeyDown,\n onInteractOutside,\n zIndex,\n rootProps,\n overlayProps,\n layout = \"auto\",\n ...rest\n}: DialogContentProps) => {\n const { open, setOpen } = useDialogContext()\n const outerPhoneLayout = useContext(PhoneLayoutContext)\n // A dialog laid out as on a phone by its own prop, outside a PhoneLayout, keeps the window: what it holds and\n // the dialogs it opens are phone ones too.\n const phoneLayout = useMemo<PhoneLayoutValue | null>(\n () => outerPhoneLayout ?? (layout === \"phone\" ? { container: null } : null),\n [outerPhoneLayout, layout],\n )\n const [content, setContent] = useState<HTMLDivElement | null>(null)\n useDialogViewport(content, outerPhoneLayout?.container ?? null)\n const overlaySurfaceRef = usePopoverDismissableSurface()\n const mobilePlacement =\n mobileVariant === \"alert\"\n ? \"center\"\n : requestedMobilePlacement ?? (mobileVariant === \"sheet\" ? \"bottom\" : undefined)\n const [exitGuard] = useState(createExitGuard)\n const [panel, setPanel] = useState<HTMLDivElement | null>(null)\n // Dialog.Body reports where content lies under the bars: they show their lines with it.\n const [edges, setEdgesState] = useState(NO_SCROLL_EDGES)\n const setEdges = useCallback((next: ScrollEdges) => setEdgesState((current) => sameScrollEdges(current, next) ? current : next), [])\n const scroll = useMemo(() => ({ edges, setEdges }), [edges, setEdges])\n const toolbarHost = useMemo<ToolbarHost>(() => ({ kind: \"dialog\", scrolled: edges.scrolled, contentBelow: edges.contentBelow }), [edges])\n const sheet = useMemo<DialogSheetValue | null>(() => (mobileVariant === \"sheet\" ? { showClose } : null), [mobileVariant, showClose])\n const boundary = useFloatingBoundaryScope()\n const setRoot = boundary.setRoot\n const setPanelRef = useCallback((node: HTMLDivElement | null) => { setPanel(node); setRoot(node) }, [setRoot])\n const openedAt = useRef(0)\n const crossesScreen =\n placement === \"bottom\" || placement === \"start\" || placement === \"end\" || placement === \"fullscreen\" || mobilePlacement === \"bottom\" || mobilePlacement === \"fullscreen\"\n\n // The content of a closing dialog is frozen for its exit, so this reads the owner's latest\n // handler: state that changes together with the close decides where focus returns.\n const handleCloseAutoFocus = useStableCallback((event: Event) => {\n onCloseAutoFocus?.(event)\n keepMovedFocus(event)\n })\n\n useEscCloseStack(open, (event) => {\n if (onEscapeKeyDown) {\n const request = cancelableKeyCopy(event)\n onEscapeKeyDown(request)\n if (request.defaultPrevented) return\n }\n setOpen(false)\n })\n\n useEffect(() => {\n if (open) openedAt.current = performance.now()\n }, [open])\n\n useEffect(() => {\n if (!panel || mobilePlacement !== \"bottom\") return undefined\n return attachSheetDrag(panel, () => setOpen(false))\n }, [panel, mobilePlacement, setOpen])\n\n useLayoutEffect(() => {\n if (!panel) return\n const update = () => {\n // A phone Toolbar takes the place of the header or footer bar on its side: one the dialog places itself\n // before the bar its header becomes.\n const header = panel.querySelector<HTMLElement>(`:scope > ${TOP_TOOLBAR}:not([data-dialog-bar])`)\n ?? panel.querySelector<HTMLElement>(`:scope > ${TOP_TOOLBAR}`)\n ?? panel.querySelector<HTMLElement>(`:scope > .${s.Header}`)\n const footer = panel.querySelector<HTMLElement>(`:scope > ${BOTTOM_TOOLBAR}`) ?? panel.querySelector<HTMLElement>(`:scope > .${s.Footer}`)\n panel.style.setProperty(\"--dialog-header-height\", `${header?.offsetHeight ?? 0}px`)\n panel.style.setProperty(\"--dialog-footer-height\", `${footer?.offsetHeight ?? 0}px`)\n }\n const observer = typeof ResizeObserver !== \"undefined\" ? new ResizeObserver(update) : undefined\n const observeBars = () => {\n observer?.disconnect()\n panel.querySelectorAll<HTMLElement>(`:scope > .${s.Header}, :scope > .${s.Footer}, :scope > [data-toolbar]`)\n .forEach((bar) => observer?.observe(bar, { box: \"border-box\" }))\n update()\n }\n observeBars()\n // A form can add or remove its action bar while the dialog stays open.\n const children = new MutationObserver(observeBars)\n children.observe(panel, { childList: true })\n return () => { observer?.disconnect(); children.disconnect() }\n }, [panel])\n\n const layerStyle = toCssVariables({ \"dialog-z-index\": zIndex === undefined ? undefined : String(zIndex) })\n\n return (\n <FloatingBoundaryProvider value={boundary}>\n <PhoneLayoutContext value={phoneLayout}>\n <RadixDialog.Portal forceMount container={outerPhoneLayout?.container ?? undefined}>\n {/* Portaled out of any phone layout, a phone dialog carries its own scope, above its transition: the phone\n rules of the style sheet start there. */}\n <PhoneScope enabled={phoneLayout !== null && !outerPhoneLayout?.container}>\n {/* A dialog mounted open enters too, as `open` set with the mount does */}\n <TransitionGroup\n {...(crossesScreen ? overlayTimingLarge : overlayTiming)}\n {...exitGuard.transition}\n className={s.Transition}\n overlay\n preventInitialTransition={false}\n >\n {open && (\n <div key=\"dialog\">\n <RadixDialog.Overlay\n {...overlayProps}\n ref={overlaySurfaceRef}\n className={clsx(s.Overlay, overlayProps?.className)}\n style={{ ...layerStyle, ...overlayProps?.style }}\n />\n <RadixDialog.Content\n {...dataAttributes(rest)}\n {...rootProps}\n ref={setContent}\n forceMount\n className={clsx(s.Content, rootProps?.className)}\n data-plex-dialog=\"\"\n style={{ ...toCssVariables({ \"dialog-width\": width }), ...layerStyle, ...rootProps?.style }}\n data-placement={placement === \"center\" ? undefined : placement}\n data-mobile-placement={mobilePlacement}\n data-mobile-variant={mobileVariant}\n data-surface={surface}\n data-pill={pill ? \"\" : undefined}\n onEscapeKeyDown={preventDefaultHandler}\n onInteractOutside={(event) => {\n // A press or focus in a toast is not outside: the toast region is a layer above the dialog. The\n // Toaster stops these before Radix sees them; this holds when the Toaster mounted after the dialog.\n if (inToastRegion(event.detail.originalEvent.target)) return event.preventDefault()\n onInteractOutside?.(event)\n if (event.defaultPrevented) return\n // The second click of a double click lands on the overlay: it must not undo the first\n if (performance.now() - openedAt.current < DOUBLE_CLICK) event.preventDefault()\n else exitGuard.onInteractOutside(event)\n }}\n onOpenAutoFocus={onOpenAutoFocus}\n onCloseAutoFocus={handleCloseAutoFocus}\n >\n <div ref={setPanelRef} className={clsx(s.Panel, className)}>\n {showClose && (\n <RadixDialog.Close asChild>\n <NavigationButton action=\"close\" variant=\"ghost\" className={s.CloseButton} aria-label=\"Close dialog\" />\n </RadixDialog.Close>\n )}\n <DialogScrollContext.Provider value={scroll}>\n <DialogSheetContext.Provider value={sheet}>\n {/* A dialog opened from a header action is not inside that header's bar */}\n <DialogBarContext.Provider value={false}>\n <ToolbarHostContext.Provider value={toolbarHost}>{children}</ToolbarHostContext.Provider>\n </DialogBarContext.Provider>\n </DialogSheetContext.Provider>\n </DialogScrollContext.Provider>\n </div>\n </RadixDialog.Content>\n </div>\n )}\n </TransitionGroup>\n </PhoneScope>\n </RadixDialog.Portal>\n </PhoneLayoutContext>\n </FloatingBoundaryProvider>\n )\n}\n\ntype DialogScrollValue = { edges: ScrollEdges; setEdges: (edges: ScrollEdges) => void }\nconst DialogScrollContext = createContext<DialogScrollValue | null>(null)\n// What the header of a Sheet needs from its Content to become the Sheet's bar on a phone\ntype DialogSheetValue = { showClose: boolean }\nconst DialogSheetContext = createContext<DialogSheetValue | null>(null)\n// Inside that bar: the title, the description and the header actions take the Toolbar's parts\nconst DialogBarContext = createContext(false)\n\nconst PhoneScope = ({ enabled, children }: { enabled: boolean; children: ReactNode }) =>\n enabled ? <div className={s.PhoneScope} data-plex-layout=\"phone\">{children}</div> : children\n\nconst useDialogViewport = (content: HTMLElement | null, container: HTMLElement | null) => {\n useLayoutEffect(() => (content ? watchDialogViewport(content, container) : undefined), [content, container])\n}\nconst TOP_TOOLBAR = '[data-toolbar][data-placement=\"top\"]'\nconst BOTTOM_TOOLBAR = '[data-toolbar][data-placement=\"bottom\"]'\n\ntype DialogSlotProps = {\n children: ReactNode\n className?: string\n}\n\n/** How a Sheet's bar meets the content scrolled under it; see `BarBackground`. */\nexport type DialogBarBackground = BarBackground\nexport type DialogHeaderProps = DialogSlotProps & {\n /** How the bar meets the content scrolled under it in a phone Sheet. @default \"glass\" */\n background?: DialogBarBackground\n}\n\n// The header's own parts, fragments opened up, so its actions can stand at the end of the bar. A part from a\n// fragment keeps the fragment's key before its own, so two parts never share a key.\nconst headerParts = (children: ReactNode, prefix = \"\"): ReactNode[] =>\n Children.toArray(children).flatMap((part) => {\n if (!isValidElement<{ children?: ReactNode }>(part)) return [part]\n if (part.type === Fragment) return headerParts(part.props.children, `${prefix}${String(part.key)}/`)\n return [prefix ? cloneElement(part, { key: `${prefix}${String(part.key)}` }) : part]\n })\nconst isHeaderAction = (part: ReactNode): part is ReactElement => isValidElement(part) && part.type === HeaderAction\n\nconst Header = ({ children, className, background = \"glass\" }: DialogHeaderProps) => {\n const sheet = useContext(DialogSheetContext)\n const phone = usePhoneLayout()\n const scrolled = useContext(DialogScrollContext)?.edges.scrolled\n if (sheet && phone) {\n const parts = headerParts(children)\n // On a phone the header of a Sheet is its Toolbar (iOS 27 kit Sheets 507-24684, Toolbar - Top - iPhone\n // 1-54520): Close at the leading edge, the title centered on the row of controls, the header actions at the\n // trailing edge, all on one 44px row under the grabber.\n return (\n <Toolbar background={background} className={className} data-dialog-bar=\"\">\n <DialogBarContext.Provider value={true}>\n {sheet.showClose && (\n <Toolbar.Leading className={s.BarClose}>\n <RadixDialog.Close asChild>\n <NavigationButton action=\"close\" variant=\"ghost\" aria-label=\"Close dialog\" />\n </RadixDialog.Close>\n </Toolbar.Leading>\n )}\n <div className={clsx(t.Heading, s.BarHeading)}>{parts.filter((part) => !isHeaderAction(part))}</div>\n {parts.filter(isHeaderAction)}\n </DialogBarContext.Provider>\n </Toolbar>\n )\n }\n return <div className={clsx(s.Header, className)} data-background={background} data-scrolled={scrolled ? \"\" : undefined}>{children}</div>\n}\n\nconst HeaderAction = ({ children, className }: DialogSlotProps) => {\n const bar = useContext(DialogBarContext)\n if (bar) return <Toolbar.Trailing className={className}>{children}</Toolbar.Trailing>\n return <div className={clsx(s.HeaderAction, className)}>{children}</div>\n}\n\n/** The scrolling part between Header and Footer: with it, only the body scrolls */\nconst Body = ({ children, className }: DialogSlotProps) => {\n const setEdges = useContext(DialogScrollContext)?.setEdges\n const element = useRef<HTMLDivElement | null>(null)\n useLayoutEffect(() => {\n const body = element.current\n if (!body || !setEdges) return\n const stop = observeScrollEdges(body, setEdges)\n return () => { stop(); setEdges(NO_SCROLL_EDGES) }\n }, [setEdges])\n return <div ref={element} className={clsx(s.Body, className)}>{children}</div>\n}\n\nexport type DialogFooterProps = DialogSlotProps & {\n /** How the bar meets the content scrolled under it in a phone Sheet. @default \"soft\" */\n background?: DialogBarBackground\n /** Override the mobile action layout. Alerts default to inline; sheets to stacked. */\n mobileLayout?: \"inline\" | \"stacked\"\n}\n\nconst Footer = ({ children, className, mobileLayout, background = \"soft\" }: DialogFooterProps) => {\n const setFooter = useFloatingBoundaryRegistration()?.setFooter\n const contentBelow = useContext(DialogScrollContext)?.edges.contentBelow\n return (\n <div\n ref={setFooter}\n className={clsx(s.Footer, className)}\n data-mobile-layout={mobileLayout}\n data-background={background}\n data-content-below={contentBelow ? \"\" : undefined}\n >\n {children}\n </div>\n )\n}\n\nconst Title = ({ children, className }: DialogSlotProps) => {\n const bar = useContext(DialogBarContext)\n return <RadixDialog.Title className={clsx(bar ? t.Title : s.Title, className)}>{children}</RadixDialog.Title>\n}\n\nconst Description = ({ children, className }: DialogSlotProps) => {\n const bar = useContext(DialogBarContext)\n const element = useRef<HTMLParagraphElement | null>(null)\n const [shown, setShown] = useState(false)\n useLayoutEffect(() => {\n // In the bar a description the reader sees is the title's second line (Toolbar's subtitle); one that is only\n // read out, visually hidden, leaves the title on its one line.\n const node = element.current\n // A measurement of the laid-out description, which only an effect after layout can read\n // eslint-disable-next-line react-hooks/set-state-in-effect\n setShown(bar && !!node && node.offsetHeight > 1 && node.offsetWidth > 1)\n }, [bar, children, className])\n return (\n <RadixDialog.Description ref={element} className={clsx(bar && shown ? t.Subtitle : s.Description, className)}>\n {children}\n </RadixDialog.Description>\n )\n}\n\nexport type DialogStepsProps = {\n /** The step on screen. A new value brings its content in. */\n step: string | number\n /**\n * `forward` brings the new step in from the trailing edge over the one before, as a push on iOS; `back` returns to\n * a step before it.\n * @default \"forward\"\n */\n direction?: \"forward\" | \"back\"\n children: ReactNode\n className?: string\n}\n\n/** The steps of a flow inside a dialog, such as a sign-in that asks for an email and then a code. */\nconst Steps = ({ step, direction = \"forward\", children, className }: DialogStepsProps) => (\n <div className={clsx(s.Steps, className)} data-direction={direction}>\n <TransitionGroup {...STEP_TIMING} as=\"div\" overlay className={s.Step} onEnter={enterStep} onExit={leaveStep} onExitActive={settleStepHeight} onExitComplete={releaseStepHeight}>\n <div key={step} data-dialog-step=\"\" tabIndex={-1}>{children}</div>\n </TransitionGroup>\n </div>\n)\n\nconst Close = ({ children }: { children: ReactNode }) => {\n return <RadixDialog.Close asChild>{children}</RadixDialog.Close>\n}\n\nDialog.Trigger = Trigger\nDialog.Content = Content\nDialog.Header = Header\nDialog.HeaderAction = HeaderAction\nDialog.Body = Body\nDialog.Footer = Footer\nDialog.Title = Title\nDialog.Description = Description\nDialog.Close = Close\nDialog.Steps = Steps\n"]}
@@ -0,0 +1,85 @@
1
+ // The motion of Dialog Steps (Dialog.module.css): the next step comes in over the one before, as a push on iOS.
2
+ import s from "@plexui/styles/components/Dialog/Dialog.module.css";
3
+ export const STEP_TIMING = { enterDuration: 300, exitDuration: 300 };
4
+ // Focus in the step that leaves moves to the one that comes in, so a press on Next does not drop it to the page. A
5
+ // step that comes back while it still leaves (Back right after Next) is inert for a moment and takes no focus, so
6
+ // the focus moves once it is not.
7
+ export const enterStep = (element) => {
8
+ if (!(element instanceof HTMLElement))
9
+ return;
10
+ delete element.dataset.exitDirection;
11
+ element.style.removeProperty("top");
12
+ const active = element.ownerDocument.activeElement;
13
+ const steps = element.parentElement;
14
+ if (!active || !steps?.contains(active) || element.contains(active))
15
+ return;
16
+ const view = element.ownerDocument.defaultView;
17
+ const focus = (frames) => {
18
+ if (!element.isConnected)
19
+ return;
20
+ if (element.inert && frames > 0 && view) {
21
+ view.requestAnimationFrame(() => focus(frames - 1));
22
+ return;
23
+ }
24
+ element.querySelector(":scope > [data-dialog-step]")?.focus({ preventScroll: true });
25
+ };
26
+ focus(3);
27
+ };
28
+ // The lowest edge of the steps still leaving, from the top of the steps: the step that comes in covers them to it
29
+ const exitExtent = (steps, except) => Math.max(0, ...Array.from(steps.children)
30
+ .filter((child) => child instanceof HTMLElement && child !== except && child.hasAttribute("data-exiting"))
31
+ .map((child) => (Number.parseFloat(child.style.top) || 0) + child.offsetHeight));
32
+ export const leaveStep = (element) => {
33
+ if (!(element instanceof HTMLElement))
34
+ return;
35
+ const steps = element.parentElement;
36
+ if (!steps)
37
+ return;
38
+ // A later step can change the direction while this one still leaves
39
+ element.dataset.exitDirection = steps.dataset.direction === "back" ? "back" : "forward";
40
+ // The new step starts at its top, as a pushed screen does; the one that leaves keeps its place on screen
41
+ const scroller = steps.closest(`.${s.Body}, .${s.Panel}`);
42
+ if (scroller) {
43
+ const padding = Number.parseFloat(getComputedStyle(scroller).scrollPaddingTop) || 0;
44
+ const stepsTop = steps.getBoundingClientRect().top - scroller.getBoundingClientRect().top + scroller.scrollTop;
45
+ const target = Math.max(0, Math.min(scroller.scrollTop, Math.round(stepsTop - padding)));
46
+ const offset = scroller.scrollTop - target;
47
+ if (offset > 0) {
48
+ element.style.top = `${-offset}px`;
49
+ scroller.scrollTop = target;
50
+ }
51
+ }
52
+ // The steps keep the height of the one that leaves, then take the new one's as it comes in. A step that still
53
+ // leaves from a step before stays covered too.
54
+ const height = element.offsetHeight;
55
+ const extent = Math.max(exitExtent(steps, element), (Number.parseFloat(element.style.top) || 0) + height);
56
+ steps.style.setProperty("--dialog-steps-exit-height", `${extent}px`);
57
+ steps.style.transition = "none";
58
+ steps.style.minHeight = `${height}px`;
59
+ };
60
+ export const settleStepHeight = (element) => {
61
+ if (!(element instanceof HTMLElement))
62
+ return;
63
+ const steps = element.parentElement;
64
+ const entering = steps?.querySelector(":scope > :not([data-exiting])");
65
+ if (!steps || !entering)
66
+ return;
67
+ steps.style.transition = "min-height var(--motion-enter-large) var(--cubic-enter)";
68
+ steps.style.minHeight = `${entering.offsetHeight}px`;
69
+ };
70
+ export const releaseStepHeight = (element) => {
71
+ if (!(element instanceof HTMLElement))
72
+ return;
73
+ const steps = element.parentElement;
74
+ if (!steps)
75
+ return;
76
+ // Another step still leaving keeps the height, and the cover reaches its edge
77
+ if (Array.from(steps.children).some((child) => child !== element && child.hasAttribute("data-exiting"))) {
78
+ steps.style.setProperty("--dialog-steps-exit-height", `${exitExtent(steps, element)}px`);
79
+ return;
80
+ }
81
+ steps.style.removeProperty("min-height");
82
+ steps.style.removeProperty("transition");
83
+ steps.style.removeProperty("--dialog-steps-exit-height");
84
+ };
85
+ //# sourceMappingURL=dialogSteps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dialogSteps.js","sourceRoot":"","sources":["../../../../src/components/Dialog/dialogSteps.ts"],"names":[],"mappings":"AAAA,gHAAgH;AAChH,OAAO,CAAC,MAAM,oDAAoD,CAAA;AAElE,MAAM,CAAC,MAAM,WAAW,GAAG,EAAE,aAAa,EAAE,GAAG,EAAE,YAAY,EAAE,GAAG,EAAE,CAAA;AAKpE,mHAAmH;AACnH,kHAAkH;AAClH,kCAAkC;AAClC,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,OAA0B,EAAE,EAAE;IACtD,IAAI,CAAC,CAAC,OAAO,YAAY,WAAW,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AC,aAAa,CAAA;IACnC,IAAI,CAAC,KAAK;QAAE,OAAM;IAClB,8EAA8E;IAC9E,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,OAAO,IAAI,KAAK,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC,EAAE,CAAC;QACxG,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,4BAA4B,EAAE,GAAG,UAAU,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,CAAA;QACxF,OAAM;IACR,CAAC;IACD,KAAK,CAAC,KAAK,CAAC,cAAc,CAAC,YAAY,CAAC,CAAA;IACxC,KAAK,CAAC,KAAK,CAAC,cAAc,CAAC,YAAY,CAAC,CAAA;IACxC,KAAK,CAAC,KAAK,CAAC,cAAc,CAAC,4BAA4B,CAAC,CAAA;AAC1D,CAAC,CAAA","sourcesContent":["// The motion of Dialog Steps (Dialog.module.css): the next step comes in over the one before, as a push on iOS.\nimport s from \"@plexui/styles/components/Dialog/Dialog.module.css\"\n\nexport const STEP_TIMING = { enterDuration: 300, exitDuration: 300 }\n\n// A transition can hand an SVG element; a step is always the HTML element Steps renders\ntype TransitionElement = HTMLElement | SVGElement\n\n// Focus in the step that leaves moves to the one that comes in, so a press on Next does not drop it to the page. A\n// step that comes back while it still leaves (Back right after Next) is inert for a moment and takes no focus, so\n// the focus moves once it is not.\nexport const enterStep = (element: TransitionElement) => {\n if (!(element instanceof HTMLElement)) return\n delete element.dataset.exitDirection\n element.style.removeProperty(\"top\")\n const active = element.ownerDocument.activeElement\n const steps = element.parentElement\n if (!active || !steps?.contains(active) || element.contains(active)) return\n const view = element.ownerDocument.defaultView\n const focus = (frames: number) => {\n if (!element.isConnected) return\n if (element.inert && frames > 0 && view) {\n view.requestAnimationFrame(() => focus(frames - 1))\n return\n }\n element.querySelector<HTMLElement>(\":scope > [data-dialog-step]\")?.focus({ preventScroll: true })\n }\n focus(3)\n}\n\n// The lowest edge of the steps still leaving, from the top of the steps: the step that comes in covers them to it\nconst exitExtent = (steps: HTMLElement, except?: Element) =>\n Math.max(\n 0,\n ...Array.from(steps.children)\n .filter((child): child is HTMLElement => child instanceof HTMLElement && child !== except && child.hasAttribute(\"data-exiting\"))\n .map((child) => (Number.parseFloat(child.style.top) || 0) + child.offsetHeight),\n )\n\nexport const leaveStep = (element: TransitionElement) => {\n if (!(element instanceof HTMLElement)) return\n const steps = element.parentElement\n if (!steps) return\n // A later step can change the direction while this one still leaves\n element.dataset.exitDirection = steps.dataset.direction === \"back\" ? \"back\" : \"forward\"\n // The new step starts at its top, as a pushed screen does; the one that leaves keeps its place on screen\n const scroller = steps.closest<HTMLElement>(`.${s.Body}, .${s.Panel}`)\n if (scroller) {\n const padding = Number.parseFloat(getComputedStyle(scroller).scrollPaddingTop) || 0\n const stepsTop = steps.getBoundingClientRect().top - scroller.getBoundingClientRect().top + scroller.scrollTop\n const target = Math.max(0, Math.min(scroller.scrollTop, Math.round(stepsTop - padding)))\n const offset = scroller.scrollTop - target\n if (offset > 0) {\n element.style.top = `${-offset}px`\n scroller.scrollTop = target\n }\n }\n // The steps keep the height of the one that leaves, then take the new one's as it comes in. A step that still\n // leaves from a step before stays covered too.\n const height = element.offsetHeight\n const extent = Math.max(exitExtent(steps, element), (Number.parseFloat(element.style.top) || 0) + height)\n steps.style.setProperty(\"--dialog-steps-exit-height\", `${extent}px`)\n steps.style.transition = \"none\"\n steps.style.minHeight = `${height}px`\n}\n\nexport const settleStepHeight = (element: TransitionElement) => {\n if (!(element instanceof HTMLElement)) return\n const steps = element.parentElement\n const entering = steps?.querySelector<HTMLElement>(\":scope > :not([data-exiting])\")\n if (!steps || !entering) return\n steps.style.transition = \"min-height var(--motion-enter-large) var(--cubic-enter)\"\n steps.style.minHeight = `${entering.offsetHeight}px`\n}\n\nexport const releaseStepHeight = (element: TransitionElement) => {\n if (!(element instanceof HTMLElement)) return\n const steps = element.parentElement\n if (!steps) return\n // Another step still leaving keeps the height, and the cover reaches its edge\n if (Array.from(steps.children).some((child) => child !== element && child.hasAttribute(\"data-exiting\"))) {\n steps.style.setProperty(\"--dialog-steps-exit-height\", `${exitExtent(steps, element)}px`)\n return\n }\n steps.style.removeProperty(\"min-height\")\n steps.style.removeProperty(\"transition\")\n steps.style.removeProperty(\"--dialog-steps-exit-height\")\n}\n"]}
@@ -0,0 +1,74 @@
1
+ // The height a dialog lays out in, where the window's is not it: the box of a PhoneLayout, or the part of the window
2
+ // a phone keyboard leaves visible (the visual viewport; the layout viewport keeps its height under the keyboard). The
3
+ // layer then covers that part, so a sheet sits on the keyboard and a panel stays in view. Inside a PhoneLayout the
4
+ // layer covers the part of the box the keyboard leaves visible. Returns the cleanup.
5
+ export const watchDialogViewport = (content, container) => {
6
+ const style = content.style;
7
+ const view = content.ownerDocument.defaultView;
8
+ const viewport = view?.visualViewport ?? null;
9
+ const clear = () => {
10
+ content.removeAttribute("data-visual-viewport");
11
+ style.removeProperty("--dialog-viewport-top");
12
+ style.removeProperty("--dialog-viewport-height");
13
+ };
14
+ // The part of the layout viewport a keyboard leaves visible, or null with no keyboard: a keyboard shortens the
15
+ // visual viewport at scale 1; a pinch zoom scales it instead
16
+ const visible = () => {
17
+ if (!viewport)
18
+ return null;
19
+ const layoutHeight = content.ownerDocument.documentElement.clientHeight;
20
+ if (Math.abs(viewport.scale - 1) > 0.01 || layoutHeight - viewport.height <= 1)
21
+ return null;
22
+ return { top: viewport.offsetTop, bottom: viewport.offsetTop + viewport.height };
23
+ };
24
+ const update = container
25
+ ? () => {
26
+ // A box with no height yet (not laid out) leaves the window's
27
+ const height = container.clientHeight;
28
+ if (height <= 0)
29
+ return clear();
30
+ const area = visible();
31
+ // The layer lays out in the box's padding box, in the box's own pixels: a scaled box (a phone drawn smaller)
32
+ // measures on screen at its scale
33
+ const box = container.getBoundingClientRect();
34
+ const scale = container.offsetHeight > 0 && box.height > 0 ? box.height / container.offsetHeight : 1;
35
+ const boxTop = box.top + container.clientTop * scale;
36
+ const top = area ? Math.max(0, (area.top - boxTop) / scale) : 0;
37
+ const bottom = area ? Math.min(height, (area.bottom - boxTop) / scale) : height;
38
+ if (!area || (top <= 0 && bottom >= height) || bottom <= top) {
39
+ content.removeAttribute("data-visual-viewport");
40
+ style.removeProperty("--dialog-viewport-top");
41
+ style.setProperty("--dialog-viewport-height", `${height}px`);
42
+ return;
43
+ }
44
+ content.setAttribute("data-visual-viewport", "");
45
+ style.setProperty("--dialog-viewport-top", `${top}px`);
46
+ style.setProperty("--dialog-viewport-height", `${bottom - top}px`);
47
+ }
48
+ : () => {
49
+ const area = visible();
50
+ if (!area)
51
+ return clear();
52
+ content.setAttribute("data-visual-viewport", "");
53
+ style.setProperty("--dialog-viewport-top", `${area.top}px`);
54
+ style.setProperty("--dialog-viewport-height", `${area.bottom - area.top}px`);
55
+ };
56
+ update();
57
+ viewport?.addEventListener("resize", update);
58
+ viewport?.addEventListener("scroll", update);
59
+ // The box moves with the page, and changes its own size
60
+ const observer = container && typeof ResizeObserver !== "undefined" ? new ResizeObserver(update) : undefined;
61
+ if (container) {
62
+ observer?.observe(container);
63
+ view?.addEventListener("scroll", update, { capture: true, passive: true });
64
+ }
65
+ return () => {
66
+ viewport?.removeEventListener("resize", update);
67
+ viewport?.removeEventListener("scroll", update);
68
+ observer?.disconnect();
69
+ if (container)
70
+ view?.removeEventListener("scroll", update, { capture: true });
71
+ clear();
72
+ };
73
+ };
74
+ //# sourceMappingURL=dialogViewport.js.map