@eightshift/ui-components 5.0.0 → 5.0.1

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 (144) hide show
  1. package/dist/Button-wERNNG0T.js +185 -0
  2. package/dist/Collection-CKsHTyhc.js +2363 -0
  3. package/dist/Color-BhgbJF5x.js +2452 -0
  4. package/dist/ColorSwatch-Bcn6oRSg.js +64 -0
  5. package/dist/ComboBox-D1LPUwWP.js +1906 -0
  6. package/dist/Dialog-D190gMbE.js +2298 -0
  7. package/dist/FieldError-DeUh5Wkw.js +42 -0
  8. package/dist/FocusScope-C-plSxbS.js +831 -0
  9. package/dist/Form-Cq3fu75_.js +5 -0
  10. package/dist/Group-C5iZpSAM.js +48 -0
  11. package/dist/Heading-D-Pboe4p.js +16 -0
  12. package/dist/Hidden-rE6uR-lr.js +41 -0
  13. package/dist/Input--mF4XVE1.js +133 -0
  14. package/dist/Label-Fp6AwSRn.js +17 -0
  15. package/dist/List-CZMUbkFU.js +593 -0
  16. package/dist/ListBox-4oW9kh3R.js +582 -0
  17. package/dist/NumberFormatter-DA8u1Ot7.js +140 -0
  18. package/dist/OverlayArrow-BpB9uB_I.js +637 -0
  19. package/dist/RSPContexts-2lR5GG9p.js +14 -0
  20. package/dist/Select-aab027f3.esm-BKIJGje-.js +2469 -0
  21. package/dist/Separator-B88tj5YD.js +323 -0
  22. package/dist/Slider-CyJzC1bp.js +853 -0
  23. package/dist/Text-DRpwWot2.js +16 -0
  24. package/dist/VisuallyHidden-DsKYcRQ_.js +48 -0
  25. package/dist/_commonjsHelpers-CUmg6egw.js +6 -0
  26. package/dist/assets/index.css +57 -0
  27. package/dist/assets/style-admin.css +5864 -0
  28. package/dist/assets/style-editor.css +5864 -0
  29. package/dist/assets/style.css +5870 -0
  30. package/dist/assets/wp-font-enhancements.css +8 -0
  31. package/dist/assets/wp-ui-enhancements.css +377 -0
  32. package/dist/components/animated-visibility/animated-visibility.js +105 -0
  33. package/dist/components/base-control/base-control.js +86 -0
  34. package/dist/components/breakpoint-preview/breakpoint-preview.js +161 -0
  35. package/dist/components/button/button.js +387 -0
  36. package/dist/components/checkbox/checkbox.js +320 -0
  37. package/dist/components/color-pickers/color-picker.js +272 -0
  38. package/dist/components/color-pickers/color-swatch.js +59 -0
  39. package/dist/components/color-pickers/gradient-editor.js +534 -0
  40. package/dist/components/color-pickers/solid-color-picker.js +1567 -0
  41. package/dist/components/component-toggle/component-toggle.js +161 -0
  42. package/dist/components/container-panel/container-panel.js +131 -0
  43. package/dist/components/draggable/draggable-context.js +5 -0
  44. package/dist/components/draggable/draggable-handle.js +46 -0
  45. package/dist/components/draggable/draggable.js +6979 -0
  46. package/dist/components/draggable-list/draggable-list-context.js +5 -0
  47. package/dist/components/draggable-list/draggable-list-item.js +77 -0
  48. package/dist/components/draggable-list/draggable-list.js +151 -0
  49. package/dist/components/expandable/expandable.js +342 -0
  50. package/dist/components/index.js +137 -0
  51. package/dist/components/input-field/input-field.js +231 -0
  52. package/dist/components/item-collection/item-collection.js +59 -0
  53. package/dist/components/layout/hstack.js +30 -0
  54. package/dist/components/layout/vstack.js +30 -0
  55. package/dist/components/link-input/link-input.js +291 -0
  56. package/dist/components/matrix-align/matrix-align.js +134 -0
  57. package/dist/components/menu/menu.js +285 -0
  58. package/dist/components/modal/modal.js +305 -0
  59. package/dist/components/notice/notice.js +123 -0
  60. package/dist/components/number-picker/number-picker.js +292 -0
  61. package/dist/components/option-select/option-select.js +264 -0
  62. package/dist/components/options-panel/options-panel.js +158 -0
  63. package/dist/components/placeholders/file-placeholder.js +42 -0
  64. package/dist/components/placeholders/image-placeholder.js +88 -0
  65. package/dist/components/placeholders/media-placeholder.js +63 -0
  66. package/dist/components/popover/popover.js +207 -0
  67. package/dist/components/radio/radio.js +579 -0
  68. package/dist/components/repeater/repeater-context.js +5 -0
  69. package/dist/components/repeater/repeater-item.js +119 -0
  70. package/dist/components/repeater/repeater.js +280 -0
  71. package/dist/components/responsive/mini-responsive.js +498 -0
  72. package/dist/components/responsive/responsive-legacy.js +343 -0
  73. package/dist/components/responsive/responsive.js +583 -0
  74. package/dist/components/responsive-preview/responsive-preview.js +123 -0
  75. package/dist/components/rich-label/rich-label.js +66 -0
  76. package/dist/components/select/async-multi-select.js +157 -0
  77. package/dist/components/select/async-single-select.js +137 -0
  78. package/dist/components/select/custom-select-default-components.js +38 -0
  79. package/dist/components/select/multi-select-components.js +8 -0
  80. package/dist/components/select/multi-select.js +151 -0
  81. package/dist/components/select/react-select-component-wrappers.js +90 -0
  82. package/dist/components/select/shared.js +26 -0
  83. package/dist/components/select/single-select.js +131 -0
  84. package/dist/components/select/styles.js +49 -0
  85. package/dist/components/select/v2/async-select.js +297 -0
  86. package/dist/components/select/v2/shared.js +24 -0
  87. package/dist/components/select/v2/single-select.js +991 -0
  88. package/dist/components/slider/column-config-slider.js +210 -0
  89. package/dist/components/slider/slider.js +345 -0
  90. package/dist/components/slider/utils.js +94 -0
  91. package/dist/components/spacer/spacer.js +97 -0
  92. package/dist/components/tabs/tabs.js +704 -0
  93. package/dist/components/toggle/switch.js +156 -0
  94. package/dist/components/toggle/toggle.js +64 -0
  95. package/dist/components/toggle-button/toggle-button.js +343 -0
  96. package/dist/components/tooltip/tooltip.js +527 -0
  97. package/dist/context-BYWrbm1z.js +92 -0
  98. package/dist/default-i18n-CT_oS1Fy.js +922 -0
  99. package/dist/filterDOMProps-EDDcM64A.js +28 -0
  100. package/dist/icons/block-icon.js +42 -0
  101. package/dist/icons/generic-color-swatch.js +113 -0
  102. package/dist/icons/icons.js +30371 -0
  103. package/dist/icons/index.js +11 -0
  104. package/dist/icons/jsx-svg.js +50 -0
  105. package/dist/index-641ee5b8.esm-BPU8rMZr.js +3137 -0
  106. package/dist/index-CFozsmNS.js +28321 -0
  107. package/dist/index-wl5606BX.js +44 -0
  108. package/dist/index.js +139 -0
  109. package/dist/lite-DVmmD_-j.js +7 -0
  110. package/dist/modifiers.esm-BuJQPI1X.js +31 -0
  111. package/dist/multi-select-components-Sp-JEFEX.js +3744 -0
  112. package/dist/number-GajL10e1.js +36 -0
  113. package/dist/react-jsx-parser.min-DZCiis5V.js +11753 -0
  114. package/dist/react-select-async.esm-D937XTWW.js +107 -0
  115. package/dist/react-select.esm-Ciai3aKf.js +15 -0
  116. package/dist/style-admin.js +1 -0
  117. package/dist/style-editor.js +1 -0
  118. package/dist/style.js +1 -0
  119. package/dist/textSelection-CCcyjiRP.js +46 -0
  120. package/dist/useButton-BOHxkGQF.js +50 -0
  121. package/dist/useEvent-D5o_CqDH.js +23 -0
  122. package/dist/useFocusRing-nMG2uzxS.js +107 -0
  123. package/dist/useFormReset-DlmRL87g.js +22 -0
  124. package/dist/useFormValidation-D0_aaK-e.js +224 -0
  125. package/dist/useHover-VO5tcIli.js +890 -0
  126. package/dist/useLabel-BKH4fVA4.js +27 -0
  127. package/dist/useLabels-ntF3rFY0.js +23 -0
  128. package/dist/useListState-Cq2Nvr-v.js +161 -0
  129. package/dist/useLocalizedStringFormatter-CGzwx1a0.js +121 -0
  130. package/dist/useNumberField-C9dmERhP.js +1207 -0
  131. package/dist/useNumberFormatter-MrRLgvhj.js +13 -0
  132. package/dist/usePress-DjNo5790.js +677 -0
  133. package/dist/useSingleSelectListState--r3AAhRj.js +38 -0
  134. package/dist/useToggle-CQaXLe-O.js +59 -0
  135. package/dist/useToggleState-C3DLdez5.js +19 -0
  136. package/dist/utilities/array-helpers.js +56 -0
  137. package/dist/utilities/debounce-throttle.js +123 -0
  138. package/dist/utilities/es-dash.js +382 -0
  139. package/dist/utilities/index.js +27 -0
  140. package/dist/utilities/text-helpers.js +136 -0
  141. package/dist/utils-B94NDG0v.js +370 -0
  142. package/dist/wp/wp-font-enhancements.js +1 -0
  143. package/dist/wp/wp-ui-enhancements.js +1 -0
  144. package/package.json +8 -8
@@ -0,0 +1,285 @@
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { $ as $72a5793c14baf454$export$8b251419efc915eb, a as $431f98aba6844401$export$1ff3c3f08ae963c0 } from "../../Separator-B88tj5YD.js";
3
+ import { a as $3674c52c6b3c5bce$export$27d2ad3c5815583e, b as $3674c52c6b3c5bce$export$d9b273488cd8ce6f, c as $3674c52c6b3c5bce$export$2ce376c2cc3355c8, d as $3674c52c6b3c5bce$export$4b1545b4f2016d26, e as $3674c52c6b3c5bce$export$ecabc99eeffab7ca } from "../../Dialog-D190gMbE.js";
4
+ import { icons } from "../../icons/icons.js";
5
+ import { Button } from "../button/button.js";
6
+ import { Popover } from "../popover/popover.js";
7
+ import { c as clsx } from "../../lite-DVmmD_-j.js";
8
+ import { cloneElement } from "react";
9
+ import { _ as __ } from "../../default-i18n-CT_oS1Fy.js";
10
+ /**
11
+ * A simple menu component.
12
+ *
13
+ * @component
14
+ * @param {Object} props - Component props.
15
+ * @param {string} [props.triggerLabel] - The label of the trigger button.
16
+ * @param {JSX.Element} [props.triggerIcon] - The icon of the trigger button.
17
+ * @param {Object} [props.triggerProps] - Props to pass to the trigger button.
18
+ * @param {string} [props.tooltip] - Tooltip text to display on the trigger button.
19
+ * @param {boolean} [props.keepOpen=false] - If `true`, the menu will not close when an item is selected.
20
+ * @param {boolean} [props.openOnLongPress=false] - If `true`, the menu will open on long press instead of click. If enabled, a regular `onPress` event can also be passed to the trigger button to enable dual behavior.
21
+ * @param {Object} [props.popoverProps] - Props to pass to the popover.
22
+ * @param {boolean} [props.hidden] - If `true`, the component is not rendered.
23
+ *
24
+ * @returns {JSX.Element} The Menu component.
25
+ *
26
+ * @example
27
+ * <Menu>
28
+ * <MenuSection label='Section 1'>
29
+ * <MenuItem>Item 1</MenuItem>
30
+ * <MenuItem>Item 2</MenuItem>
31
+ * </MenuSection>
32
+ * <MenuSection label='Section 2'>
33
+ * <MenuItem>Item 3</MenuItem>
34
+ * <MenuItem>Item 4</MenuItem>
35
+ * </MenuSection>
36
+ * </Menu>
37
+ *
38
+ * @example
39
+ * <Menu>
40
+ * <MenuItem>Item 1</MenuItem>
41
+ * <MenuItem>Item 2</MenuItem>
42
+ * <MenuSeparator />
43
+ * <MenuItem>Item 3</MenuItem>
44
+ * <MenuItem>Item 4</MenuItem>
45
+ * </Menu>
46
+ *
47
+ * @example
48
+ * <Menu>
49
+ * <MenuItem>Item 1</MenuItem>
50
+ * <MenuItem>Item 2</MenuItem>
51
+ * <SubMenuItem
52
+ * trigger={<MenuItem>Submenu</MenuItem>}
53
+ * >
54
+ * <MenuItem>Subitem 1</MenuItem>
55
+ * <MenuItem>Subitem 2</MenuItem>
56
+ * </SubMenuItem>
57
+ * </Menu>
58
+ *
59
+ *
60
+ * @preserve
61
+ */
62
+ const Menu = (props) => {
63
+ var _a;
64
+ const {
65
+ children,
66
+ triggerLabel,
67
+ triggerIcon = !triggerLabel && icons.hamburgerMenu,
68
+ triggerProps,
69
+ popoverProps,
70
+ tooltip,
71
+ keepOpen = false,
72
+ "aria-label": ariaLabel = triggerLabel ?? __("Menu", "eightshift-ui-components"),
73
+ openOnLongPress = false,
74
+ hidden
75
+ } = props;
76
+ if (hidden) {
77
+ return null;
78
+ }
79
+ let additionalProps = {};
80
+ if (keepOpen) {
81
+ additionalProps = {
82
+ ...additionalProps,
83
+ selectionMode: "multiple",
84
+ selectedKeys: [],
85
+ onSelectionChange: () => {
86
+ },
87
+ items: []
88
+ };
89
+ }
90
+ if (openOnLongPress) {
91
+ additionalProps.trigger = "longPress";
92
+ }
93
+ const hasSubmenuItems = Array.isArray(children) ? children.some((child) => {
94
+ var _a2;
95
+ return ((_a2 = child == null ? void 0 : child.type) == null ? void 0 : _a2.displayName) === "SubMenuItem";
96
+ }) : ((_a = children == null ? void 0 : children.type) == null ? void 0 : _a.displayName) === "SubMenuItem";
97
+ return /* @__PURE__ */ jsxs(
98
+ $3674c52c6b3c5bce$export$27d2ad3c5815583e,
99
+ {
100
+ ...props,
101
+ ...additionalProps,
102
+ children: [
103
+ /* @__PURE__ */ jsx(
104
+ Button,
105
+ {
106
+ icon: triggerIcon,
107
+ tooltip,
108
+ ...triggerProps,
109
+ children: triggerLabel
110
+ }
111
+ ),
112
+ /* @__PURE__ */ jsx(
113
+ Popover,
114
+ {
115
+ className: "es:p-0! es:any-focus:outline-hidden",
116
+ "aria-label": ariaLabel,
117
+ wrapperClassName: clsx(!hasSubmenuItems && "es:overflow-y-auto"),
118
+ ...popoverProps,
119
+ children: /* @__PURE__ */ jsx(
120
+ $3674c52c6b3c5bce$export$d9b273488cd8ce6f,
121
+ {
122
+ className: "es:outline-hidden",
123
+ ...props,
124
+ ...additionalProps,
125
+ children
126
+ }
127
+ )
128
+ }
129
+ )
130
+ ]
131
+ }
132
+ );
133
+ };
134
+ /**
135
+ * A wrapper for `MenuItem` components that visually groups them and ensures proper keyboard navigation.
136
+ *
137
+ * **Important**: <MenuSection> cannot be mixed with other <MenuItem> in the top-level of the same menu.
138
+ *
139
+ * @component
140
+ * @param {Object} props - Component props.
141
+ * @param {string} [props.label] - The label of the section.
142
+ *
143
+ * @returns {JSX.Element} The MenuSection component.
144
+ *
145
+ * @see {@link Menu} for usage example.
146
+ *
147
+ * @preserve
148
+ */
149
+ const MenuSection = (props) => {
150
+ const { children, label } = props;
151
+ return /* @__PURE__ */ jsxs(
152
+ $3674c52c6b3c5bce$export$4b1545b4f2016d26,
153
+ {
154
+ className: clsx(
155
+ "es:space-y-1 es:border-b es:border-b-secondary-200 es:last:border-b-0",
156
+ label && "es:pt-2 es:first:pt-1.5 es:last:pb-0",
157
+ !label && "es:has-[>_:only-child]:pb-0"
158
+ ),
159
+ children: [
160
+ label && /* @__PURE__ */ jsx($72a5793c14baf454$export$8b251419efc915eb, { className: "es:ml-1.5 es:text-xs es:font-medium es:text-secondary-400", children: label }),
161
+ children
162
+ ]
163
+ }
164
+ );
165
+ };
166
+ /**
167
+ * A menu separator.
168
+ *
169
+ * @returns {JSX.Element} The MenuSeparator component.
170
+ *
171
+ * @see {@link Menu} for usage example.
172
+ *
173
+ * @preserve
174
+ */
175
+ const MenuSeparator = () => {
176
+ return /* @__PURE__ */ jsx($431f98aba6844401$export$1ff3c3f08ae963c0, { className: "es:mb-1 es:border-b es:border-secondary-200/50" });
177
+ };
178
+ /**
179
+ * A menu item.
180
+ *
181
+ * @component
182
+ * @param {Object} props - Component props.
183
+ * @param {JSX.Element} [props.icon] - The icon of the item.
184
+ * @param {string} [props.shortcut] - A slot for text like the keyboard shortcut, displayed on the right side of the item.
185
+ * @param {boolean} [props.checked] - If `true`, the item is marked as checked. This is visually represented by a checkmark icon.
186
+ * @param {boolean} [props.selected] - If `true`, the item is marked as selected. This is visually represented by a circle.
187
+ * @param {boolean} [props.disabled] - If `true`, the item will be disabled.
188
+ * @param {JSX.Element} [props.endIcon] - The icon at the right side of the item.
189
+ * @param {Function} [props.onClick] - Function to run when the item is clicked.
190
+ * @param {string} [props.className] - Classes to pass to the menu item.
191
+ *
192
+ * @returns {JSX.Element} The MenuItem component.
193
+ *
194
+ * @see {@link Menu} for usage example.
195
+ *
196
+ * @preserve
197
+ */
198
+ const MenuItem = (props) => {
199
+ const {
200
+ icon,
201
+ children,
202
+ checked,
203
+ selected,
204
+ disabled,
205
+ endIcon,
206
+ onClick,
207
+ shortcut,
208
+ className,
209
+ "aria-label": ariaLabel = typeof children === "string" ? children : __("Menu item", "eightshift-ui-components")
210
+ } = props;
211
+ return /* @__PURE__ */ jsxs(
212
+ $3674c52c6b3c5bce$export$2ce376c2cc3355c8,
213
+ {
214
+ ...props,
215
+ "aria-label": ariaLabel,
216
+ isDisabled: disabled,
217
+ className: clsx(
218
+ "es:mx-1 es:mb-1 es:flex es:min-w-44 es:min-h-8 es:items-center es:gap-1.5",
219
+ "es:first:mt-1 es:icon:size-5 es:icon:text-secondary-500",
220
+ "es:select-none es:rounded-md es:p-1.5 es:text-sm es:transition",
221
+ "es:any-focus:outline-hidden",
222
+ !disabled && "es:hover:bg-secondary-100 es:focus-visible:inset-ring es:focus-visible:inset-ring-secondary-100/30 es:focus-visible:bg-secondary-100 es:contrast-more:focus-visible:bg-accent-500/15",
223
+ disabled ? "es:text-secondary-400" : "es:text-secondary-800",
224
+ className
225
+ ),
226
+ onAction: onClick,
227
+ children: [
228
+ checked === true && icons.menuItemCheck,
229
+ selected === true && icons.menuItemCircle,
230
+ (selected === false || checked === false) && icons.dummySpacer,
231
+ icon,
232
+ children,
233
+ shortcut && /* @__PURE__ */ jsx("div", { className: "es:ml-auto es:pl-2 es:text-[0.6875rem] es:tracking-tight es:text-secondary-400", children: shortcut }),
234
+ endIcon && /* @__PURE__ */ jsx("div", { className: clsx(!shortcut && "es:ml-auto es:pl-2"), children: endIcon })
235
+ ]
236
+ }
237
+ );
238
+ };
239
+ /**
240
+ * A supplementary menu item that triggers a submenu.
241
+ *
242
+ * @component
243
+ * @param {Object} props - Component props.
244
+ * @param {JSX.Element} props.trigger - The trigger button for the submenu. **This should be a `MenuItem`.**
245
+ * @param {Object} [props.popoverProps] - Props to pass to the popover.
246
+ *
247
+ * @returns {JSX.Element} The SubMenuItem component.
248
+ *
249
+ * @see {@link Menu} for usage example.
250
+ *
251
+ * @preserve
252
+ */
253
+ const SubMenuItem = (props) => {
254
+ const { children, trigger, popoverProps } = props;
255
+ return /* @__PURE__ */ jsxs($3674c52c6b3c5bce$export$ecabc99eeffab7ca, { children: [
256
+ cloneElement(trigger, {
257
+ endIcon: /* @__PURE__ */ jsx("span", { className: "es:text-secondary-400", children: icons.caretRightFill })
258
+ }),
259
+ /* @__PURE__ */ jsx(
260
+ Popover,
261
+ {
262
+ "aria-label": props["aria-label"] ?? __("Submenu", "eightshift-ui-components"),
263
+ className: "es:p-0! es:any-focus:outline-hidden",
264
+ offset: -1,
265
+ ...popoverProps,
266
+ children: /* @__PURE__ */ jsx(
267
+ $3674c52c6b3c5bce$export$d9b273488cd8ce6f,
268
+ {
269
+ "aria-label": props["aria-label"] ?? __("Submenu", "eightshift-ui-components"),
270
+ className: "es:any-focus:outline-hidden",
271
+ children
272
+ }
273
+ )
274
+ }
275
+ )
276
+ ] });
277
+ };
278
+ SubMenuItem.displayName = "SubMenuItem";
279
+ export {
280
+ Menu,
281
+ MenuItem,
282
+ MenuSection,
283
+ MenuSeparator,
284
+ SubMenuItem
285
+ };
@@ -0,0 +1,305 @@
1
+ import { jsxs, jsx, Fragment } from "react/jsx-runtime";
2
+ import { h as $a11501f3d1d39e6c$export$ea8f71083e90600f, i as $49c51c25361d4cd2$export$ee0f7cc6afcd1c18, j as $337b884510726a0d$export$14c98a7594375490, k as $5e3802645cc19319$export$1c3ebcada18427bf, l as $de32f1b87079253c$export$d2f961adcb0afbe, m as $86ea4cb521eb2e37$export$2317d149ed6f78c4, n as $337b884510726a0d$export$c6fdb837b070b4ff, g as $de32f1b87079253c$export$2e1e1122cf0cba88, f as $de32f1b87079253c$export$3ddf2d174ce01153 } from "../../Dialog-D190gMbE.js";
3
+ import { $ as $5cb03073d3f54797$export$a8a3e93435678ff9 } from "../../Heading-D-Pboe4p.js";
4
+ import { n as $b5e257d569688ac6$export$535bd6ca7f90a273, d as $3ef42575df84b30b$export$9d1611c77c2fe928, a as $64fa3d84918910a7$export$29f1550f4b0d4415, l as $df56164dff5785e2$export$4338b53315abf666, m as $5dc95899b306f630$export$c9058316764c140e, b as $64fa3d84918910a7$export$4d86445c2cf5e3, i as $64fa3d84918910a7$export$2881499e37b75b9a } from "../../utils-B94NDG0v.js";
5
+ import { $ as $65484d02dcb7eb3e$export$457c3d6518dd4c6f } from "../../filterDOMProps-EDDcM64A.js";
6
+ import React__default, { useState, useEffect, forwardRef, useContext, createContext, useRef, useMemo } from "react";
7
+ import { $ as $fc909762b330b746$export$61c6a8c84e605fb6, a as $d3f049242431219c$export$45fda7c47f93fd48, b as $d3f049242431219c$export$6d3443f2c48bfc20 } from "../../OverlayArrow-BpB9uB_I.js";
8
+ import { Button } from "../button/button.js";
9
+ import { _ as __ } from "../../default-i18n-CT_oS1Fy.js";
10
+ import { c as clsx } from "../../lite-DVmmD_-j.js";
11
+ import { icons } from "../../icons/icons.js";
12
+ import "../../react-jsx-parser.min-DZCiis5V.js";
13
+ import { HStack } from "../layout/hstack.js";
14
+ let $5df64b3807dc15ee$var$visualViewport = typeof document !== "undefined" && window.visualViewport;
15
+ function $5df64b3807dc15ee$export$d699905dd57c73ca() {
16
+ let isSSR = $b5e257d569688ac6$export$535bd6ca7f90a273();
17
+ let [size, setSize] = useState(() => isSSR ? {
18
+ width: 0,
19
+ height: 0
20
+ } : $5df64b3807dc15ee$var$getViewportSize());
21
+ useEffect(() => {
22
+ let onResize = () => {
23
+ setSize((size2) => {
24
+ let newSize = $5df64b3807dc15ee$var$getViewportSize();
25
+ if (newSize.width === size2.width && newSize.height === size2.height) return size2;
26
+ return newSize;
27
+ });
28
+ };
29
+ if (!$5df64b3807dc15ee$var$visualViewport) window.addEventListener("resize", onResize);
30
+ else $5df64b3807dc15ee$var$visualViewport.addEventListener("resize", onResize);
31
+ return () => {
32
+ if (!$5df64b3807dc15ee$var$visualViewport) window.removeEventListener("resize", onResize);
33
+ else $5df64b3807dc15ee$var$visualViewport.removeEventListener("resize", onResize);
34
+ };
35
+ }, []);
36
+ return size;
37
+ }
38
+ function $5df64b3807dc15ee$var$getViewportSize() {
39
+ return {
40
+ width: $5df64b3807dc15ee$var$visualViewport && ($5df64b3807dc15ee$var$visualViewport === null || $5df64b3807dc15ee$var$visualViewport === void 0 ? void 0 : $5df64b3807dc15ee$var$visualViewport.width) || window.innerWidth,
41
+ height: $5df64b3807dc15ee$var$visualViewport && ($5df64b3807dc15ee$var$visualViewport === null || $5df64b3807dc15ee$var$visualViewport === void 0 ? void 0 : $5df64b3807dc15ee$var$visualViewport.height) || window.innerHeight
42
+ };
43
+ }
44
+ function $8ac8429251c45e4b$export$dbc0f175b25fb0fb(props, state, ref) {
45
+ let { overlayProps, underlayProps } = $a11501f3d1d39e6c$export$ea8f71083e90600f({
46
+ ...props,
47
+ isOpen: state.isOpen,
48
+ onClose: state.close
49
+ }, ref);
50
+ $49c51c25361d4cd2$export$ee0f7cc6afcd1c18({
51
+ isDisabled: !state.isOpen
52
+ });
53
+ $337b884510726a0d$export$14c98a7594375490();
54
+ useEffect(() => {
55
+ if (state.isOpen && ref.current) return $5e3802645cc19319$export$1c3ebcada18427bf([
56
+ ref.current
57
+ ]);
58
+ }, [
59
+ state.isOpen,
60
+ ref
61
+ ]);
62
+ return {
63
+ modalProps: $3ef42575df84b30b$export$9d1611c77c2fe928(overlayProps),
64
+ underlayProps
65
+ };
66
+ }
67
+ const $f3f84453ead64de5$export$ab57792b9b6974a6 = /* @__PURE__ */ createContext(null);
68
+ const $f3f84453ead64de5$var$InternalModalContext = /* @__PURE__ */ createContext(null);
69
+ const $f3f84453ead64de5$export$2b77a92f1a5ad772 = /* @__PURE__ */ forwardRef(function Modal(props, ref) {
70
+ let ctx = useContext($f3f84453ead64de5$var$InternalModalContext);
71
+ if (ctx) return /* @__PURE__ */ React__default.createElement($f3f84453ead64de5$var$ModalContent, {
72
+ ...props,
73
+ modalRef: ref
74
+ }, props.children);
75
+ let { isDismissable, isKeyboardDismissDisabled, isOpen, defaultOpen, onOpenChange, children, isEntering, isExiting, UNSTABLE_portalContainer, shouldCloseOnInteractOutside, ...otherProps } = props;
76
+ return /* @__PURE__ */ React__default.createElement($f3f84453ead64de5$export$8948f78d83984c69, {
77
+ isDismissable,
78
+ isKeyboardDismissDisabled,
79
+ isOpen,
80
+ defaultOpen,
81
+ onOpenChange,
82
+ isEntering,
83
+ isExiting,
84
+ UNSTABLE_portalContainer,
85
+ shouldCloseOnInteractOutside
86
+ }, /* @__PURE__ */ React__default.createElement($f3f84453ead64de5$var$ModalContent, {
87
+ ...otherProps,
88
+ modalRef: ref
89
+ }, children));
90
+ });
91
+ function $f3f84453ead64de5$var$ModalOverlayWithForwardRef(props, ref) {
92
+ [props, ref] = $64fa3d84918910a7$export$29f1550f4b0d4415(props, ref, $f3f84453ead64de5$export$ab57792b9b6974a6);
93
+ let contextState = useContext($de32f1b87079253c$export$d2f961adcb0afbe);
94
+ let localState = $fc909762b330b746$export$61c6a8c84e605fb6(props);
95
+ let state = props.isOpen != null || props.defaultOpen != null || !contextState ? localState : contextState;
96
+ let objectRef = $df56164dff5785e2$export$4338b53315abf666(ref);
97
+ let modalRef = useRef(null);
98
+ let isOverlayExiting = $d3f049242431219c$export$45fda7c47f93fd48(objectRef, state.isOpen);
99
+ let isModalExiting = $d3f049242431219c$export$45fda7c47f93fd48(modalRef, state.isOpen);
100
+ let isExiting = isOverlayExiting || isModalExiting || props.isExiting || false;
101
+ let isSSR = $b5e257d569688ac6$export$535bd6ca7f90a273();
102
+ if (!state.isOpen && !isExiting || isSSR) return null;
103
+ return /* @__PURE__ */ React__default.createElement($f3f84453ead64de5$var$ModalOverlayInner, {
104
+ ...props,
105
+ state,
106
+ isExiting,
107
+ overlayRef: objectRef,
108
+ modalRef
109
+ });
110
+ }
111
+ const $f3f84453ead64de5$export$8948f78d83984c69 = /* @__PURE__ */ forwardRef($f3f84453ead64de5$var$ModalOverlayWithForwardRef);
112
+ function $f3f84453ead64de5$var$ModalOverlayInner({ UNSTABLE_portalContainer, ...props }) {
113
+ let modalRef = props.modalRef;
114
+ let { state } = props;
115
+ let { modalProps, underlayProps } = $8ac8429251c45e4b$export$dbc0f175b25fb0fb(props, state, modalRef);
116
+ let entering = $d3f049242431219c$export$6d3443f2c48bfc20(props.overlayRef) || props.isEntering || false;
117
+ let renderProps = $64fa3d84918910a7$export$4d86445c2cf5e3({
118
+ ...props,
119
+ defaultClassName: "react-aria-ModalOverlay",
120
+ values: {
121
+ isEntering: entering,
122
+ isExiting: props.isExiting,
123
+ state
124
+ }
125
+ });
126
+ let viewport = $5df64b3807dc15ee$export$d699905dd57c73ca();
127
+ let style = {
128
+ ...renderProps.style,
129
+ "--visual-viewport-height": viewport.height + "px"
130
+ };
131
+ return /* @__PURE__ */ React__default.createElement($337b884510726a0d$export$c6fdb837b070b4ff, {
132
+ isExiting: props.isExiting,
133
+ portalContainer: UNSTABLE_portalContainer
134
+ }, /* @__PURE__ */ React__default.createElement("div", {
135
+ ...$3ef42575df84b30b$export$9d1611c77c2fe928($65484d02dcb7eb3e$export$457c3d6518dd4c6f(props), underlayProps),
136
+ ...renderProps,
137
+ style,
138
+ ref: props.overlayRef,
139
+ "data-entering": entering || void 0,
140
+ "data-exiting": props.isExiting || void 0
141
+ }, /* @__PURE__ */ React__default.createElement($64fa3d84918910a7$export$2881499e37b75b9a, {
142
+ values: [
143
+ [
144
+ $f3f84453ead64de5$var$InternalModalContext,
145
+ {
146
+ modalProps,
147
+ modalRef,
148
+ isExiting: props.isExiting,
149
+ isDismissable: props.isDismissable
150
+ }
151
+ ],
152
+ [
153
+ $de32f1b87079253c$export$d2f961adcb0afbe,
154
+ state
155
+ ]
156
+ ]
157
+ }, renderProps.children)));
158
+ }
159
+ function $f3f84453ead64de5$var$ModalContent(props) {
160
+ let { modalProps, modalRef, isExiting, isDismissable } = useContext($f3f84453ead64de5$var$InternalModalContext);
161
+ let state = useContext($de32f1b87079253c$export$d2f961adcb0afbe);
162
+ let mergedRefs = useMemo(() => $5dc95899b306f630$export$c9058316764c140e(props.modalRef, modalRef), [
163
+ props.modalRef,
164
+ modalRef
165
+ ]);
166
+ let ref = $df56164dff5785e2$export$4338b53315abf666(mergedRefs);
167
+ let entering = $d3f049242431219c$export$6d3443f2c48bfc20(ref);
168
+ let renderProps = $64fa3d84918910a7$export$4d86445c2cf5e3({
169
+ ...props,
170
+ defaultClassName: "react-aria-Modal",
171
+ values: {
172
+ isEntering: entering,
173
+ isExiting,
174
+ state
175
+ }
176
+ });
177
+ return /* @__PURE__ */ React__default.createElement("div", {
178
+ ...$3ef42575df84b30b$export$9d1611c77c2fe928($65484d02dcb7eb3e$export$457c3d6518dd4c6f(props), modalProps),
179
+ ...renderProps,
180
+ ref,
181
+ "data-entering": entering || void 0,
182
+ "data-exiting": isExiting || void 0
183
+ }, isDismissable && /* @__PURE__ */ React__default.createElement($86ea4cb521eb2e37$export$2317d149ed6f78c4, {
184
+ onDismiss: state.close
185
+ }), renderProps.children);
186
+ }
187
+ /**
188
+ * Modal dialog.
189
+ *
190
+ * @component
191
+ * @param {Object} props - Component props.
192
+ * @param {boolean} [props.open] - **Controlled mode ** - whether the modal is open.
193
+ * @param {boolean} [props.defaultOpen] - **Uncontrolled mode ** - whether the modal is initially open.
194
+ * @param {string|JSX.Element} [props.triggerLabel] - Label for the trigger button.
195
+ * @param {JSX.Element} [props.triggerIcon] - Trigger button icon.
196
+ * @param {Object} [props.triggerProps] - Props to pass to the trigger button.
197
+ * @param {ReactNode} [props.customTrigger] - If provided, replaces the default trigger button. The passed component should be something button-related that can open the modal.
198
+ * @param {string|JSX.Element} [props.title] - Title of the modal.
199
+ * @param {boolean} [props.noCloseButton] - If `true`, the close button will not be displayed.
200
+ * @param {boolean} [props.noClickToDismiss] - If `true`, the modal will not close when clicking outside of it.
201
+ * @param {boolean} [props.noKeyboardDismiss] - If `true`, the modal will not close when pressing the `Esc` key.
202
+ * @param {string} [props.className] - Classes to pass to the modal container.
203
+ * @param {string} [props.overlayClassName] - Classes to pass to the modal backdrop.
204
+ * @param {Function} [props.shouldCloseOnInteractOutside=() => true] - Allows ignoring close events for certain elements. `(element: HTMLElement) => boolean`.
205
+ *
206
+ * @returns {JSX.Element} The Modal component.
207
+ *
208
+ * @example
209
+ * <Modal>
210
+ * <p>Modal content</p>
211
+ * </Modal>
212
+ *
213
+ * @preserve
214
+ */
215
+ const Modal2 = (props) => {
216
+ const {
217
+ children,
218
+ shouldCloseOnInteractOutside,
219
+ open,
220
+ defaultOpen,
221
+ triggerLabel,
222
+ triggerIcon,
223
+ triggerProps,
224
+ customTrigger,
225
+ title,
226
+ noCloseButton,
227
+ noClickToDismiss,
228
+ noKeyboardDismiss,
229
+ "aria-label": ariaLabel,
230
+ className,
231
+ overlayClassName
232
+ } = props;
233
+ return /* @__PURE__ */ jsxs($de32f1b87079253c$export$2e1e1122cf0cba88, { children: [
234
+ !customTrigger && /* @__PURE__ */ jsx(
235
+ Button,
236
+ {
237
+ icon: triggerIcon,
238
+ ...triggerProps,
239
+ children: triggerLabel ?? (!triggerIcon && __("Open", "eightshift-frontend-libs"))
240
+ }
241
+ ),
242
+ customTrigger,
243
+ /* @__PURE__ */ jsx(
244
+ $f3f84453ead64de5$export$8948f78d83984c69,
245
+ {
246
+ isDismissable: !noClickToDismiss,
247
+ defaultOpen,
248
+ isOpen: open,
249
+ shouldCloseOnInteractOutside,
250
+ isKeyboardDismissDisabled: noKeyboardDismiss,
251
+ className: ({ isEntering, isExiting }) => clsx(
252
+ "es:fixed es:inset-0 es:z-9999 es:flex es:min-h-full es:items-center es:justify-center es:overflow-y-auto es:bg-black/25 es:p-4 es:text-center es:backdrop-blur-xs",
253
+ isEntering && "es:motion-opacity-in es:motion-duration-150",
254
+ isExiting && "es:motion-opacity-out es:motion-duration-150",
255
+ overlayClassName
256
+ ),
257
+ children: /* @__PURE__ */ jsx(
258
+ $f3f84453ead64de5$export$2b77a92f1a5ad772,
259
+ {
260
+ className: ({ isEntering, isExiting }) => clsx(
261
+ "es:w-full es:max-w-lg es:overflow-hidden es:rounded-xl es:border es:border-secondary-100 es:bg-white es:p-5 es:text-left es:align-middle es:shadow-xl es:inset-ring es:inset-ring-secondary-100",
262
+ isEntering && "es:motion-safe:motion-scale-in-95 es:motion-fade-in es:motion-duration-300 es:motion-ease-spring-smooth/scale",
263
+ isExiting && "es:motion-safe:motion-scale-out-95 es:motion-fade-out es:motion-duration-250 es:motion-ease-spring-smooth/scale",
264
+ className
265
+ ),
266
+ children: /* @__PURE__ */ jsx(
267
+ $de32f1b87079253c$export$3ddf2d174ce01153,
268
+ {
269
+ className: "es:relative es:text-sm es:outline-hidden",
270
+ "aria-label": ariaLabel,
271
+ children: ({ close }) => /* @__PURE__ */ jsxs(Fragment, { children: [
272
+ /* @__PURE__ */ jsxs(HStack, { children: [
273
+ title && /* @__PURE__ */ jsx(
274
+ $5cb03073d3f54797$export$a8a3e93435678ff9,
275
+ {
276
+ className: "es:text-balance es:text-base",
277
+ slot: "title",
278
+ children: title
279
+ }
280
+ ),
281
+ !noCloseButton && /* @__PURE__ */ jsx(
282
+ Button,
283
+ {
284
+ className: "es:ml-auto",
285
+ onPress: close,
286
+ type: "ghost",
287
+ size: "small",
288
+ icon: icons.clear,
289
+ "aria-label": __("Close modal", "eightshift-frontend-libs")
290
+ }
291
+ )
292
+ ] }),
293
+ children
294
+ ] })
295
+ }
296
+ )
297
+ }
298
+ )
299
+ }
300
+ )
301
+ ] });
302
+ };
303
+ export {
304
+ Modal2 as Modal
305
+ };