@gild-ui/vue 0.0.0 → 0.1.0-alpha.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 (61) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +97 -2
  3. package/dist/Button.cjs +238 -0
  4. package/dist/Button.d.cts +17 -0
  5. package/dist/Button.d.mts +17 -0
  6. package/dist/Button.mjs +237 -0
  7. package/dist/Button.types-BnJ28ym9.d.mts +1113 -0
  8. package/dist/Flex.cjs +25 -0
  9. package/dist/Flex.d.cts +11 -0
  10. package/dist/Flex.d.mts +11 -0
  11. package/dist/Flex.mjs +24 -0
  12. package/dist/Modal.cjs +369 -0
  13. package/dist/Modal.d.cts +23 -0
  14. package/dist/Modal.d.mts +23 -0
  15. package/dist/Modal.mjs +368 -0
  16. package/dist/TextInput.cjs +299 -0
  17. package/dist/TextInput.d.cts +37 -0
  18. package/dist/TextInput.d.mts +37 -0
  19. package/dist/TextInput.mjs +298 -0
  20. package/dist/ThemeProvider-CareN7BO.mjs +58 -0
  21. package/dist/ThemeProvider-DIeSdYou.cjs +63 -0
  22. package/dist/ThemeProvider.cjs +3 -0
  23. package/dist/ThemeProvider.d.cts +25 -0
  24. package/dist/ThemeProvider.d.mts +25 -0
  25. package/dist/ThemeProvider.mjs +1 -0
  26. package/dist/Typography.cjs +72 -0
  27. package/dist/Typography.d.cts +15 -0
  28. package/dist/Typography.d.mts +15 -0
  29. package/dist/Typography.mjs +71 -0
  30. package/dist/View.cjs +12 -0
  31. package/dist/View.d.cts +11 -0
  32. package/dist/View.d.mts +11 -0
  33. package/dist/View.mjs +11 -0
  34. package/dist/ViewRoot-CsaIxrtD.mjs +40 -0
  35. package/dist/ViewRoot-X9F9RROv.cjs +45 -0
  36. package/dist/bridge-D-x2kK4r.d.mts +36 -0
  37. package/dist/bridge-t6zHXVt-.d.cts +36 -0
  38. package/dist/engine.cjs +82 -0
  39. package/dist/engine.d.cts +46 -0
  40. package/dist/engine.d.mts +46 -0
  41. package/dist/engine.mjs +26 -0
  42. package/dist/index.cjs +57 -0
  43. package/dist/index.d.cts +37 -0
  44. package/dist/index.d.mts +37 -0
  45. package/dist/index.mjs +6 -0
  46. package/dist/props-BRLGZVjJ.d.mts +21 -0
  47. package/dist/props-Bzm7Wbdv.d.cts +21 -0
  48. package/dist/props-DDBSpAkG.mjs +49 -0
  49. package/dist/props-DxoB9cT4.cjs +72 -0
  50. package/dist/styled-Cmxvlft5.mjs +34 -0
  51. package/dist/styled-JHkZtq_1.cjs +39 -0
  52. package/dist/themes-BqxOUMCB.cjs +12 -0
  53. package/dist/themes-CgFrk0_b.d.cts +1112 -0
  54. package/dist/themes-rGHVhV5e.mjs +8 -0
  55. package/dist/useDefaultProps--fOGOSGa.mjs +18 -0
  56. package/dist/useDefaultProps-qCDgeYFm.cjs +23 -0
  57. package/dist/useTheme.cjs +8 -0
  58. package/dist/useTheme.d.cts +3 -0
  59. package/dist/useTheme.d.mts +3 -0
  60. package/dist/useTheme.mjs +1 -0
  61. package/package.json +167 -4
package/dist/Flex.cjs ADDED
@@ -0,0 +1,25 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_styled = require("./styled-JHkZtq_1.cjs");
3
+ const require_props = require("./props-DxoB9cT4.cjs");
4
+ const require_ViewRoot = require("./ViewRoot-X9F9RROv.cjs");
5
+ let vue = require("vue");
6
+ let _soroush_tech_styled_system_should_forward_prop = require("@soroush.tech/styled-system/should-forward-prop");
7
+ let _soroush_tech_styled_system = require("@soroush.tech/styled-system");
8
+ // src/Flex/Flex.ts
9
+ const shouldForwardProp = (0, _soroush_tech_styled_system_should_forward_prop.createShouldForwardProp)([..._soroush_tech_styled_system_should_forward_prop.props, "layout"]);
10
+ const FlexRoot = require_styled.styled(require_ViewRoot.ViewRoot, {
11
+ name: "Flex",
12
+ label: "flex",
13
+ shouldForwardProp,
14
+ systemProps: [_soroush_tech_styled_system.flexbox, _soroush_tech_styled_system.space]
15
+ })({
16
+ display: "flex",
17
+ flexDirection: "column"
18
+ });
19
+ const Flex = (0, vue.defineComponent)((props, { attrs, slots }) => () => (0, vue.h)(FlexRoot, require_props.rootProps(props, attrs), slots), {
20
+ name: "Flex",
21
+ inheritAttrs: false,
22
+ props: require_props.declare("slotProps", "style"),
23
+ slots: {}
24
+ });
25
+ exports.Flex = Flex;
@@ -0,0 +1,11 @@
1
+ import { n as SharedProps, r as Slot, t as Listeners } from "./props-Bzm7Wbdv.cjs";
2
+ import { A as FlexProps$1, M as FlexThemeConfig, N as GapToken, j as FlexSlot, k as FlexOwnerState } from "./themes-CgFrk0_b.cjs";
3
+ import { HTMLAttributes, SlotsType } from "vue";
4
+ /** The props of `Flex`: the shared props of `@gild-ui/react`, and a listener for each DOM event of the element. */
5
+ export type FlexProps = SharedProps<FlexProps$1> & Listeners<HTMLAttributes>;
6
+ /** The slots of the `Flex` component: the content. */
7
+ export interface FlexSlots {
8
+ default?: Slot;
9
+ }
10
+ export declare const Flex: import("vue").DefineSetupFnComponent<FlexProps, Record<never, never>, SlotsType<FlexSlots>, SharedProps<FlexProps$1, never> & Pick<HTMLAttributes, "onAbort" | "onAnimationcancel" | "onAnimationend" | "onAnimationiteration" | "onAnimationstart" | "onAuxclick" | "onBeforeinput" | "onBeforetoggle" | "onBlur" | "onCanplay" | "onCanplaythrough" | "onChange" | "onClick" | "onCompositionend" | "onCompositionstart" | "onCompositionupdate" | "onContextmenu" | "onCopy" | "onCut" | "onDblclick" | "onDrag" | "onDragend" | "onDragenter" | "onDragexit" | "onDragleave" | "onDragover" | "onDragstart" | "onDrop" | "onDurationchange" | "onEmptied" | "onEncrypted" | "onEnded" | "onError" | "onFocus" | "onFocusin" | "onFocusout" | "onFormdata" | "onFullscreenchange" | "onFullscreenerror" | "onGotpointercapture" | "onInput" | "onInvalid" | "onKeydown" | "onKeypress" | "onKeyup" | "onLoad" | "onLoadeddata" | "onLoadedmetadata" | "onLoadstart" | "onLostpointercapture" | "onMousedown" | "onMouseenter" | "onMouseleave" | "onMousemove" | "onMouseout" | "onMouseover" | "onMouseup" | "onPaste" | "onPause" | "onPlay" | "onPlaying" | "onPointercancel" | "onPointerdown" | "onPointerenter" | "onPointerleave" | "onPointermove" | "onPointerout" | "onPointerover" | "onPointerup" | "onProgress" | "onRatechange" | "onReset" | "onScroll" | "onScrollend" | "onSecuritypolicyviolation" | "onSeeked" | "onSeeking" | "onSelect" | "onStalled" | "onSubmit" | "onSuspend" | "onTimeupdate" | "onToggle" | "onTouchcancel" | "onTouchend" | "onTouchmove" | "onTouchstart" | "onTransitioncancel" | "onTransitionend" | "onTransitionrun" | "onTransitionstart" | "onVolumechange" | "onWaiting" | "onWheel"> & Pick<HTMLAttributes, "class"> & {}, import("vue").PublicProps>;
11
+ export type { FlexOwnerState, FlexSlot, FlexThemeConfig, GapToken };
@@ -0,0 +1,11 @@
1
+ import { n as SharedProps, r as Slot, t as Listeners } from "./props-BRLGZVjJ.mjs";
2
+ import { B as FlexProps$1, H as FlexThemeConfig, U as GapToken, V as FlexSlot, z as FlexOwnerState } from "./Button.types-BnJ28ym9.mjs";
3
+ import { HTMLAttributes, SlotsType } from "vue";
4
+ /** The props of `Flex`: the shared props of `@gild-ui/react`, and a listener for each DOM event of the element. */
5
+ export type FlexProps = SharedProps<FlexProps$1> & Listeners<HTMLAttributes>;
6
+ /** The slots of the `Flex` component: the content. */
7
+ export interface FlexSlots {
8
+ default?: Slot;
9
+ }
10
+ export declare const Flex: import("vue").DefineSetupFnComponent<FlexProps, Record<never, never>, SlotsType<FlexSlots>, SharedProps<FlexProps$1, never> & Pick<HTMLAttributes, "onAbort" | "onAnimationcancel" | "onAnimationend" | "onAnimationiteration" | "onAnimationstart" | "onAuxclick" | "onBeforeinput" | "onBeforetoggle" | "onBlur" | "onCanplay" | "onCanplaythrough" | "onChange" | "onClick" | "onCompositionend" | "onCompositionstart" | "onCompositionupdate" | "onContextmenu" | "onCopy" | "onCut" | "onDblclick" | "onDrag" | "onDragend" | "onDragenter" | "onDragexit" | "onDragleave" | "onDragover" | "onDragstart" | "onDrop" | "onDurationchange" | "onEmptied" | "onEncrypted" | "onEnded" | "onError" | "onFocus" | "onFocusin" | "onFocusout" | "onFormdata" | "onFullscreenchange" | "onFullscreenerror" | "onGotpointercapture" | "onInput" | "onInvalid" | "onKeydown" | "onKeypress" | "onKeyup" | "onLoad" | "onLoadeddata" | "onLoadedmetadata" | "onLoadstart" | "onLostpointercapture" | "onMousedown" | "onMouseenter" | "onMouseleave" | "onMousemove" | "onMouseout" | "onMouseover" | "onMouseup" | "onPaste" | "onPause" | "onPlay" | "onPlaying" | "onPointercancel" | "onPointerdown" | "onPointerenter" | "onPointerleave" | "onPointermove" | "onPointerout" | "onPointerover" | "onPointerup" | "onProgress" | "onRatechange" | "onReset" | "onScroll" | "onScrollend" | "onSecuritypolicyviolation" | "onSeeked" | "onSeeking" | "onSelect" | "onStalled" | "onSubmit" | "onSuspend" | "onTimeupdate" | "onToggle" | "onTouchcancel" | "onTouchend" | "onTouchmove" | "onTouchstart" | "onTransitioncancel" | "onTransitionend" | "onTransitionrun" | "onTransitionstart" | "onVolumechange" | "onWaiting" | "onWheel"> & Pick<HTMLAttributes, "class"> & {}, import("vue").PublicProps>;
11
+ export type { FlexOwnerState, FlexSlot, FlexThemeConfig, GapToken };
package/dist/Flex.mjs ADDED
@@ -0,0 +1,24 @@
1
+ import { r as styled } from "./styled-Cmxvlft5.mjs";
2
+ import { r as rootProps, t as declare } from "./props-DDBSpAkG.mjs";
3
+ import { t as ViewRoot } from "./ViewRoot-CsaIxrtD.mjs";
4
+ import { defineComponent, h } from "vue";
5
+ import { createShouldForwardProp, props } from "@soroush.tech/styled-system/should-forward-prop";
6
+ import { flexbox, space } from "@soroush.tech/styled-system";
7
+ // src/Flex/Flex.ts
8
+ const shouldForwardProp = createShouldForwardProp([...props, "layout"]);
9
+ const FlexRoot = styled(ViewRoot, {
10
+ name: "Flex",
11
+ label: "flex",
12
+ shouldForwardProp,
13
+ systemProps: [flexbox, space]
14
+ })({
15
+ display: "flex",
16
+ flexDirection: "column"
17
+ });
18
+ const Flex = defineComponent((props, { attrs, slots }) => () => h(FlexRoot, rootProps(props, attrs), slots), {
19
+ name: "Flex",
20
+ inheritAttrs: false,
21
+ props: declare("slotProps", "style"),
22
+ slots: {}
23
+ });
24
+ export { Flex };
package/dist/Modal.cjs ADDED
@@ -0,0 +1,369 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_styled = require("./styled-JHkZtq_1.cjs");
3
+ const require_props = require("./props-DxoB9cT4.cjs");
4
+ const require_ViewRoot = require("./ViewRoot-X9F9RROv.cjs");
5
+ let vue = require("vue");
6
+ let _umber_style_vue = require("@umber-style/vue");
7
+ let _soroush_tech_styled_system_should_forward_prop = require("@soroush.tech/styled-system/should-forward-prop");
8
+ // src/Modal/FocusTrap.ts
9
+ const FOCUSABLE_SELECTOR = [
10
+ "a[href]",
11
+ "button:not([disabled])",
12
+ "textarea:not([disabled])",
13
+ "input:not([disabled])",
14
+ "select:not([disabled])",
15
+ "[tabindex]:not([tabindex=\"-1\"])"
16
+ ].join(",");
17
+ function getFocusable(node) {
18
+ return Array.from(node.querySelectorAll(FOCUSABLE_SELECTOR)).filter((element) => element.tabIndex >= 0);
19
+ }
20
+ /** Move focus to the first focusable descendant, or the node itself when there is none. */
21
+ function focusFirst(node) {
22
+ const [first] = getFocusable(node);
23
+ (first ?? node).focus();
24
+ }
25
+ /**
26
+ * Keeps keyboard focus within `node` until the returned function is called: moves focus in, cycles Tab
27
+ * and Shift+Tab at the boundaries, pulls focus back when it escapes, and gives focus back to the element
28
+ * that had it before. It is the behavior of `FocusTrap` of `@gild-ui/react`.
29
+ */
30
+ function trapFocus(node, options) {
31
+ const { shouldAutoFocus = true, shouldTrapFocus = true, shouldEnforceFocus = true, shouldRestoreFocus = true } = options;
32
+ const doc = node.ownerDocument;
33
+ const previouslyFocused = doc.activeElement;
34
+ if (shouldAutoFocus) focusFirst(node);
35
+ const handleFocusIn = (event) => {
36
+ if (!(event.target instanceof Node && node.contains(event.target))) focusFirst(node);
37
+ };
38
+ if (shouldEnforceFocus) doc.addEventListener("focusin", handleFocusIn);
39
+ const handleKeyDown = (event) => {
40
+ if (!shouldTrapFocus || event.key !== "Tab") return;
41
+ const focusable = getFocusable(node);
42
+ if (focusable.length === 0) {
43
+ event.preventDefault();
44
+ return;
45
+ }
46
+ const first = focusable[0];
47
+ const last = focusable.at(-1);
48
+ const active = doc.activeElement;
49
+ if (event.shiftKey && active === first) {
50
+ event.preventDefault();
51
+ last?.focus();
52
+ } else if (!event.shiftKey && active === last) {
53
+ event.preventDefault();
54
+ first?.focus();
55
+ }
56
+ };
57
+ node.addEventListener("keydown", handleKeyDown);
58
+ return () => {
59
+ doc.removeEventListener("focusin", handleFocusIn);
60
+ node.removeEventListener("keydown", handleKeyDown);
61
+ if (shouldRestoreFocus && previouslyFocused instanceof HTMLElement) previouslyFocused.focus();
62
+ };
63
+ }
64
+ // ../react/src/utils/ownerDocument.ts
65
+ /**
66
+ * Returns the `Document` that owns the given node, falling back to the global
67
+ * `document`. Lets the modal logic work across iframes / portaled containers.
68
+ */
69
+ function ownerDocument(node) {
70
+ return node?.ownerDocument ?? document;
71
+ }
72
+ // ../react/src/Modal/utils/ownerWindow.ts
73
+ /**
74
+ * Returns the `Window` that owns the given node, falling back to the global
75
+ * `window`. Used to read viewport metrics for scroll-lock calculations.
76
+ */
77
+ function ownerWindow(node) {
78
+ return ownerDocument(node).defaultView ?? window;
79
+ }
80
+ // ../react/src/Modal/utils/getScrollbarSize.ts
81
+ /**
82
+ * Width of the vertical scrollbar for the given window, in pixels. Equal to the
83
+ * gap between the inner window width and the document's client width. Used to
84
+ * pad the container when scroll-lock hides the scrollbar, preventing layout jump.
85
+ */
86
+ function getScrollbarSize(win) {
87
+ const documentWidth = win.document.documentElement.clientWidth;
88
+ return Math.abs(win.innerWidth - documentWidth);
89
+ }
90
+ // ../react/src/Modal/ModalManager.ts
91
+ const ARIA_HIDDEN_FORBIDDEN_TAGS = /* @__PURE__ */ new Set([
92
+ "TEMPLATE",
93
+ "SCRIPT",
94
+ "STYLE",
95
+ "LINK",
96
+ "MAP",
97
+ "META",
98
+ "NOSCRIPT",
99
+ "PICTURE",
100
+ "COL",
101
+ "COLGROUP",
102
+ "PARAM",
103
+ "SLOT",
104
+ "SOURCE",
105
+ "TRACK"
106
+ ]);
107
+ /** Hides an element from assistive tech. */
108
+ function hideFromAria(element) {
109
+ element.setAttribute("aria-hidden", "true");
110
+ }
111
+ /** Reveals an element to assistive tech again. */
112
+ function exposeToAria(element) {
113
+ element.removeAttribute("aria-hidden");
114
+ }
115
+ function isAriaHiddenForbidden(element) {
116
+ if (ARIA_HIDDEN_FORBIDDEN_TAGS.has(element.tagName)) return true;
117
+ return element.tagName === "INPUT" && element.getAttribute("type") === "hidden";
118
+ }
119
+ function ariaHiddenSiblings(container, mountElement, currentElement, hiddenSiblings, apply) {
120
+ const exclude = /* @__PURE__ */ new Set([
121
+ mountElement,
122
+ currentElement,
123
+ ...hiddenSiblings
124
+ ]);
125
+ Array.from(container.children).forEach((element) => {
126
+ if (!exclude.has(element) && !isAriaHiddenForbidden(element)) apply(element);
127
+ });
128
+ }
129
+ function getHiddenSiblings(container) {
130
+ return Array.from(container.children).filter((element) => element.getAttribute("aria-hidden") === "true");
131
+ }
132
+ function isOverflowing(container) {
133
+ const doc = ownerDocument(container);
134
+ if (container === doc.body) return ownerWindow(container).innerWidth > doc.documentElement.clientWidth;
135
+ return container.scrollHeight > container.clientHeight;
136
+ }
137
+ function getPaddingRight(element) {
138
+ return Number.parseFloat(ownerWindow(element).getComputedStyle(element).paddingRight) || 0;
139
+ }
140
+ /**
141
+ * Locks scrolling on the container, padding it by the scrollbar width so hiding
142
+ * the scrollbar causes no horizontal layout shift. Returns a function that
143
+ * restores the exact prior inline styles.
144
+ */
145
+ function lockScroll(container) {
146
+ const restores = [];
147
+ const setStyle = (property, value) => {
148
+ const previous = container.style.getPropertyValue(property);
149
+ restores.push(() => {
150
+ if (previous) container.style.setProperty(property, previous);
151
+ else container.style.removeProperty(property);
152
+ });
153
+ container.style.setProperty(property, value);
154
+ };
155
+ if (isOverflowing(container)) {
156
+ const scrollbarSize = container === ownerDocument(container).body ? getScrollbarSize(ownerWindow(container)) : container.offsetWidth - container.clientWidth;
157
+ setStyle("padding-right", `${getPaddingRight(container) + scrollbarSize}px`);
158
+ }
159
+ setStyle("overflow", "hidden");
160
+ return () => restores.forEach((restore) => restore());
161
+ }
162
+ /**
163
+ * Tracks every open modal and the containers they live in. A single shared
164
+ * instance coordinates stacking (`isTopModal`), scroll-lock, and `aria-hidden`
165
+ * on background siblings so assistive tech only sees the active modal.
166
+ */
167
+ var ModalManager = class {
168
+ modals = [];
169
+ containers = [];
170
+ add(modal, container, disableAriaHidden = false) {
171
+ const existingIndex = this.modals.indexOf(modal);
172
+ if (existingIndex !== -1) return existingIndex;
173
+ const modalIndex = this.modals.length;
174
+ this.modals.push(modal);
175
+ exposeToAria(modal.modalRef);
176
+ const hiddenSiblings = getHiddenSiblings(container);
177
+ if (!disableAriaHidden) ariaHiddenSiblings(container, modal.mount, modal.modalRef, hiddenSiblings, hideFromAria);
178
+ const containerState = this.containers.find((item) => item.container === container);
179
+ if (containerState) {
180
+ containerState.modals.push(modal);
181
+ if (!disableAriaHidden) containerState.ariaHiddenApplied = true;
182
+ return modalIndex;
183
+ }
184
+ this.containers.push({
185
+ container,
186
+ modals: [modal],
187
+ restore: null,
188
+ hiddenSiblings,
189
+ ariaHiddenApplied: !disableAriaHidden
190
+ });
191
+ return modalIndex;
192
+ }
193
+ mount(modal, props) {
194
+ const containerState = this.containers.find((item) => item.modals.includes(modal));
195
+ containerState.restore ??= props.disableScrollLock ? () => {} : lockScroll(containerState.container);
196
+ }
197
+ remove(modal, ariaHiddenState = true) {
198
+ const modalIndex = this.modals.indexOf(modal);
199
+ if (modalIndex === -1) return modalIndex;
200
+ const containerState = this.containers.find((item) => item.modals.includes(modal));
201
+ containerState.modals.splice(containerState.modals.indexOf(modal), 1);
202
+ this.modals.splice(modalIndex, 1);
203
+ if (containerState.modals.length === 0) {
204
+ if (containerState.restore) containerState.restore();
205
+ (ariaHiddenState ? hideFromAria : exposeToAria)(modal.modalRef);
206
+ if (containerState.ariaHiddenApplied) ariaHiddenSiblings(containerState.container, modal.mount, modal.modalRef, containerState.hiddenSiblings, exposeToAria);
207
+ this.containers.splice(this.containers.indexOf(containerState), 1);
208
+ } else {
209
+ const nextTop = containerState.modals.at(-1);
210
+ (ariaHiddenState ? hideFromAria : exposeToAria)(modal.modalRef);
211
+ exposeToAria(nextTop.modalRef);
212
+ }
213
+ return modalIndex;
214
+ }
215
+ isTopModal(modal) {
216
+ return this.modals.at(-1) === modal;
217
+ }
218
+ };
219
+ // src/Modal/Modal.ts
220
+ const shouldForwardProp = (0, _soroush_tech_styled_system_should_forward_prop.createShouldForwardProp)(["scroll", "layer"]);
221
+ const ModalRoot = require_styled.styled(require_ViewRoot.ViewRoot, {
222
+ name: "Modal",
223
+ label: "Modal",
224
+ shouldForwardProp
225
+ })(({ theme, scroll, layer }) => ({
226
+ position: "fixed",
227
+ inset: 0,
228
+ zIndex: theme.zOrder[layer],
229
+ display: "flex",
230
+ ...scroll === "paper" ? {
231
+ alignItems: "center",
232
+ justifyContent: "center"
233
+ } : {
234
+ flexDirection: "column",
235
+ overflowY: "auto",
236
+ "& > :not([aria-hidden=\"true\"])": { margin: "auto" }
237
+ }
238
+ }));
239
+ const BackdropRoot = require_styled.styled(require_ViewRoot.ViewRoot, {
240
+ name: "Backdrop",
241
+ label: "Backdrop"
242
+ })({
243
+ position: "fixed",
244
+ inset: 0,
245
+ zIndex: -1,
246
+ pointerEvents: "none"
247
+ });
248
+ const FocusTrapRoot = require_styled.styled("div", {
249
+ name: "FocusTrap",
250
+ label: "FocusTrap"
251
+ })({ outline: "none" });
252
+ const modalManager = new ModalManager();
253
+ const resolveContainer = (container) => (typeof container === "function" ? container() : container) ?? null;
254
+ /**
255
+ * @description Accessible overlay primitive: teleports its content, dims the page, traps focus, locks
256
+ * scroll, and closes on Escape or backdrop click. The content is the default slot.
257
+ */
258
+ const Modal = (0, vue.defineComponent)((props, { emit, slots }) => {
259
+ const root = (0, vue.ref)(null);
260
+ const trap = (0, vue.ref)(null);
261
+ let modal;
262
+ let release;
263
+ const isTopModal = () => modal !== void 0 && modalManager.isTopModal(modal);
264
+ const sync = () => {
265
+ release?.();
266
+ release = void 0;
267
+ const element = root.value;
268
+ const content = trap.value;
269
+ if (!props.isOpen || !element || !content) return;
270
+ const registered = {
271
+ mount: element,
272
+ modalRef: element
273
+ };
274
+ modal = registered;
275
+ const container = resolveContainer(props.portalContainer) ?? element.ownerDocument.body;
276
+ modalManager.add(registered, container, props.disableAriaHidden);
277
+ modalManager.mount(registered, { disableScrollLock: !props.shouldLockScroll });
278
+ const releaseFocus = trapFocus(content, props);
279
+ release = () => {
280
+ releaseFocus();
281
+ modalManager.remove(registered);
282
+ };
283
+ };
284
+ (0, vue.onMounted)(sync);
285
+ (0, vue.watch)(() => [
286
+ props.isOpen,
287
+ props.portalContainer,
288
+ props.shouldLockScroll,
289
+ props.disableAriaHidden,
290
+ props.shouldAutoFocus,
291
+ props.shouldTrapFocus,
292
+ props.shouldEnforceFocus,
293
+ props.shouldRestoreFocus
294
+ ], sync, { flush: "post" });
295
+ (0, vue.onBeforeUnmount)(() => release?.());
296
+ const close = (event, reason) => {
297
+ emit("close", event, reason);
298
+ emit("update:isOpen", false);
299
+ };
300
+ const handleClick = (event) => {
301
+ if (event.target === event.currentTarget) close(event, "backdropClick");
302
+ };
303
+ const handleKeydown = (event) => {
304
+ if (event.key !== "Escape" || event.isComposing || !isTopModal()) return;
305
+ event.stopPropagation();
306
+ close(event, "escapeKey");
307
+ };
308
+ return () => {
309
+ const { isOpen, scroll = "paper", layer = "modal", style, slotProps } = props;
310
+ if (!props.shouldKeepMounted && !isOpen) return null;
311
+ const content = (0, vue.h)(ModalRoot, {
312
+ scroll,
313
+ layer,
314
+ role: "presentation",
315
+ onKeydown: handleKeydown,
316
+ onClick: handleClick,
317
+ ref: root,
318
+ ...require_props.mergeOverrides(slotProps?.root, { style })
319
+ }, () => [props.hasBackdrop && (0, vue.h)(BackdropRoot, {
320
+ bg: "backdrop",
321
+ "aria-hidden": true
322
+ }), (0, vue.h)(FocusTrapRoot, {
323
+ ref: trap,
324
+ tabindex: -1
325
+ }, () => slots.default?.())].filter(Boolean));
326
+ if (!props.shouldUsePortal) return content;
327
+ return typeof document === "undefined" ? null : (0, vue.h)(vue.Teleport, { to: resolveContainer(props.portalContainer) ?? document.body }, (0, vue.h)(_umber_style_vue.ThemeScope, null, () => content));
328
+ };
329
+ }, {
330
+ name: "Modal",
331
+ inheritAttrs: false,
332
+ props: {
333
+ ...require_props.declare("portalContainer", "scroll", "layer", "style", "slotProps"),
334
+ isOpen: {
335
+ type: Boolean,
336
+ required: true
337
+ },
338
+ hasBackdrop: {
339
+ type: Boolean,
340
+ default: true
341
+ },
342
+ shouldKeepMounted: {
343
+ type: Boolean,
344
+ default: false
345
+ },
346
+ shouldUsePortal: {
347
+ type: Boolean,
348
+ default: true
349
+ },
350
+ shouldLockScroll: {
351
+ type: Boolean,
352
+ default: true
353
+ },
354
+ disableAriaHidden: {
355
+ type: Boolean,
356
+ default: false
357
+ },
358
+ shouldAutoFocus: require_props.flag,
359
+ shouldTrapFocus: require_props.flag,
360
+ shouldEnforceFocus: require_props.flag,
361
+ shouldRestoreFocus: require_props.flag
362
+ },
363
+ emits: {
364
+ close: () => true,
365
+ "update:isOpen": () => true
366
+ },
367
+ slots: {}
368
+ });
369
+ exports.Modal = Modal;
@@ -0,0 +1,23 @@
1
+ import { n as SharedProps, r as Slot } from "./props-Bzm7Wbdv.cjs";
2
+ import { C as ModalCloseReason, D as ModalSlot, E as ModalScroll, O as ModalThemeConfig, T as ModalProps$1, w as ModalOwnerState } from "./themes-CgFrk0_b.cjs";
3
+ import { SlotsType } from "vue";
4
+ /** The props of `Modal`: the shared props of `@gild-ui/react` without the content, which is the default slot. */
5
+ export type ModalProps = SharedProps<ModalProps$1>;
6
+ /** The slots of the `Modal` component: the content. */
7
+ export interface ModalSlots {
8
+ default?: Slot;
9
+ }
10
+ /** What a `Modal` emits: `close` on Escape (top modal only) or a backdrop click, and `update:isOpen` for `v-model:isOpen`, with `false`. */
11
+ export type ModalEmits = {
12
+ close: (event: Event, reason: ModalCloseReason) => true;
13
+ 'update:isOpen': (isOpen: boolean) => true;
14
+ };
15
+ /**
16
+ * @description Accessible overlay primitive: teleports its content, dims the page, traps focus, locks
17
+ * scroll, and closes on Escape or backdrop click. The content is the default slot.
18
+ */
19
+ export declare const Modal: import("vue").DefineSetupFnComponent<SharedProps<ModalProps$1, never>, ModalEmits, SlotsType<ModalSlots>, SharedProps<ModalProps$1, never> & {
20
+ onClose?: ((event: Event, reason: ModalCloseReason) => any) | undefined;
21
+ "onUpdate:isOpen"?: ((isOpen: boolean) => any) | undefined;
22
+ }, import("vue").PublicProps>;
23
+ export type { ModalCloseReason, ModalOwnerState, ModalScroll, ModalSlot, ModalThemeConfig };
@@ -0,0 +1,23 @@
1
+ import { n as SharedProps, r as Slot } from "./props-BRLGZVjJ.mjs";
2
+ import { F as ModalProps$1, I as ModalScroll, L as ModalSlot, N as ModalCloseReason, P as ModalOwnerState, R as ModalThemeConfig } from "./Button.types-BnJ28ym9.mjs";
3
+ import { SlotsType } from "vue";
4
+ /** The props of `Modal`: the shared props of `@gild-ui/react` without the content, which is the default slot. */
5
+ export type ModalProps = SharedProps<ModalProps$1>;
6
+ /** The slots of the `Modal` component: the content. */
7
+ export interface ModalSlots {
8
+ default?: Slot;
9
+ }
10
+ /** What a `Modal` emits: `close` on Escape (top modal only) or a backdrop click, and `update:isOpen` for `v-model:isOpen`, with `false`. */
11
+ export type ModalEmits = {
12
+ close: (event: Event, reason: ModalCloseReason) => true;
13
+ 'update:isOpen': (isOpen: boolean) => true;
14
+ };
15
+ /**
16
+ * @description Accessible overlay primitive: teleports its content, dims the page, traps focus, locks
17
+ * scroll, and closes on Escape or backdrop click. The content is the default slot.
18
+ */
19
+ export declare const Modal: import("vue").DefineSetupFnComponent<SharedProps<ModalProps$1, never>, ModalEmits, SlotsType<ModalSlots>, SharedProps<ModalProps$1, never> & {
20
+ onClose?: ((event: Event, reason: ModalCloseReason) => any) | undefined;
21
+ "onUpdate:isOpen"?: ((isOpen: boolean) => any) | undefined;
22
+ }, import("vue").PublicProps>;
23
+ export type { ModalCloseReason, ModalOwnerState, ModalScroll, ModalSlot, ModalThemeConfig };