ropav 0.0.10 → 0.0.12
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.
- package/README.md +9 -0
- package/dist/accordion.css +115 -111
- package/dist/accordion.js +60 -16
- package/dist/alert.css +110 -108
- package/dist/alert.js +48 -26
- package/dist/aspect-ratio.css +17 -15
- package/dist/aspect-ratio.js +20 -6
- package/dist/avatar.css +98 -96
- package/dist/avatar.js +27 -16
- package/dist/badge.css +95 -93
- package/dist/badge.js +29 -16
- package/dist/base.css +672 -671
- package/dist/button-group.css +39 -37
- package/dist/button-group.js +23 -12
- package/dist/button-link.css +160 -158
- package/dist/button-link.js +43 -24
- package/dist/button.css +160 -158
- package/dist/button.js +37 -19
- package/dist/card.css +109 -107
- package/dist/card.js +42 -17
- package/dist/checkbox.css +139 -137
- package/dist/checkbox.js +103 -33
- package/dist/collapse.css +29 -27
- package/dist/collapse.js +44 -10
- package/dist/color-input.css +137 -107
- package/dist/color-input.js +117 -30
- package/dist/color-picker.css +309 -303
- package/dist/color-picker.js +147 -54
- package/dist/color-picker2.js +9 -1
- package/dist/color-swatch.css +48 -46
- package/dist/color-swatch.js +15 -11
- package/dist/color-swatch2.js +4 -0
- package/dist/components/accordion/accordion-item.d.ts +13 -1
- package/dist/components/accordion/index.d.ts +2 -1
- package/dist/components/accordion/index.js +2 -2
- package/dist/components/accordion/types.d.ts +9 -4
- package/dist/components/alert/alert.d.ts +2 -2
- package/dist/components/alert/index.d.ts +2 -2
- package/dist/components/alert/index.js +2 -2
- package/dist/components/alert/types.d.ts +4 -1
- package/dist/components/aspect-ratio/index.d.ts +2 -1
- package/dist/components/aspect-ratio/index.js +2 -2
- package/dist/components/aspect-ratio/types.d.ts +4 -1
- package/dist/components/avatar/index.d.ts +2 -2
- package/dist/components/avatar/index.js +2 -2
- package/dist/components/avatar/types.d.ts +4 -1
- package/dist/components/badge/index.d.ts +2 -2
- package/dist/components/badge/index.js +2 -2
- package/dist/components/badge/types.d.ts +4 -1
- package/dist/components/button/index.d.ts +2 -1
- package/dist/components/button/index.js +2 -2
- package/dist/components/button/types.d.ts +4 -1
- package/dist/components/button-group/index.d.ts +2 -1
- package/dist/components/button-group/index.js +2 -2
- package/dist/components/button-group/types.d.ts +4 -1
- package/dist/components/button-link/index.d.ts +2 -1
- package/dist/components/button-link/index.js +2 -2
- package/dist/components/button-link/types.d.ts +4 -1
- package/dist/components/card/index.d.ts +2 -1
- package/dist/components/card/index.js +2 -2
- package/dist/components/card/types.d.ts +5 -1
- package/dist/components/checkbox/checkbox.d.ts +4 -1
- package/dist/components/checkbox/index.d.ts +2 -1
- package/dist/components/checkbox/index.js +2 -2
- package/dist/components/checkbox/types.d.ts +11 -2
- package/dist/components/checkbox/useCheckbox.d.ts +3 -1
- package/dist/components/collapse/collapse.d.ts +2 -2
- package/dist/components/collapse/index.d.ts +2 -1
- package/dist/components/collapse/index.js +2 -2
- package/dist/components/collapse/types.d.ts +9 -2
- package/dist/components/color-input/index.d.ts +2 -1
- package/dist/components/color-input/index.js +2 -2
- package/dist/components/color-input/types.d.ts +8 -2
- package/dist/components/color-input/useColorInput.d.ts +1 -1
- package/dist/components/color-input/useColorInputValue.d.ts +1 -1
- package/dist/components/color-picker/index.d.ts +2 -2
- package/dist/components/color-picker/index.js +2 -2
- package/dist/components/color-picker/types.d.ts +13 -1
- package/dist/components/color-swatch/index.d.ts +2 -1
- package/dist/components/color-swatch/index.js +2 -1
- package/dist/components/color-swatch/types.d.ts +4 -1
- package/dist/components/dialog/dialog-close.d.ts +21 -0
- package/dist/components/dialog/dialog-content.d.ts +32 -0
- package/dist/components/dialog/dialog-core.d.ts +27 -0
- package/dist/components/dialog/dialog-description.d.ts +21 -0
- package/dist/components/dialog/dialog-overlay.d.ts +21 -0
- package/dist/components/dialog/dialog-portal.d.ts +21 -0
- package/dist/components/dialog/dialog-root.d.ts +28 -0
- package/dist/components/dialog/dialog-title.d.ts +21 -0
- package/dist/components/dialog/dialog-trigger.d.ts +23 -0
- package/dist/components/dialog/index.d.ts +9 -0
- package/dist/components/dialog/index.js +2 -0
- package/dist/components/dialog/types.d.ts +61 -0
- package/dist/components/dropdown-menu/dropdown-menu-checkbox-item.d.ts +24 -0
- package/dist/components/dropdown-menu/dropdown-menu-content.d.ts +34 -0
- package/dist/components/dropdown-menu/dropdown-menu-context-trigger.d.ts +23 -0
- package/dist/components/dropdown-menu/dropdown-menu-item-indicator.d.ts +24 -0
- package/dist/components/dropdown-menu/dropdown-menu-item-row.d.ts +28 -0
- package/dist/components/dropdown-menu/dropdown-menu-item.d.ts +23 -0
- package/dist/components/dropdown-menu/dropdown-menu-items.d.ts +24 -22
- package/dist/components/dropdown-menu/dropdown-menu-label.d.ts +21 -0
- package/dist/components/dropdown-menu/dropdown-menu-outside.d.ts +3 -0
- package/dist/components/dropdown-menu/dropdown-menu-portal.d.ts +21 -0
- package/dist/components/dropdown-menu/dropdown-menu-primitive-core.d.ts +110 -0
- package/dist/components/dropdown-menu/dropdown-menu-primitives.d.ts +15 -0
- package/dist/components/dropdown-menu/dropdown-menu-radio-group.d.ts +25 -0
- package/dist/components/dropdown-menu/dropdown-menu-radio-item.d.ts +23 -0
- package/dist/components/dropdown-menu/dropdown-menu-root.d.ts +30 -0
- package/dist/components/dropdown-menu/dropdown-menu-separator.d.ts +19 -0
- package/dist/components/dropdown-menu/dropdown-menu-sub-content.d.ts +34 -0
- package/dist/components/dropdown-menu/dropdown-menu-sub-trigger.d.ts +28 -0
- package/dist/components/dropdown-menu/dropdown-menu-sub.d.ts +28 -0
- package/dist/components/dropdown-menu/dropdown-menu-trigger.d.ts +23 -0
- package/dist/components/dropdown-menu/dropdown-menu.d.ts +6 -3
- package/dist/components/dropdown-menu/index.d.ts +32 -1
- package/dist/components/dropdown-menu/index.js +2 -2
- package/dist/components/dropdown-menu/types.d.ts +145 -6
- package/dist/components/dropdown-menu/useDropdownMenu.d.ts +15 -3
- package/dist/components/dropdown-menu/useDropdownMenuDisclosure.d.ts +10 -3
- package/dist/components/dropdown-menu/useDropdownMenuDom.d.ts +2 -1
- package/dist/components/dropdown-menu/useDropdownMenuInteractions.d.ts +4 -4
- package/dist/components/dropdown-menu/useDropdownMenuPortalPosition.d.ts +19 -0
- package/dist/components/dropdown-menu/useDropdownMenuPrimitiveContent.d.ts +27 -0
- package/dist/components/dropdown-menu/useDropdownMenuRenderItems.d.ts +14 -2
- package/dist/components/field/index.d.ts +2 -1
- package/dist/components/field/index.js +2 -2
- package/dist/components/field/types.d.ts +4 -1
- package/dist/components/floating/index.d.ts +3 -0
- package/dist/components/floating/index.js +3 -0
- package/dist/components/floating/types.d.ts +105 -0
- package/dist/components/floating/useFloatingPosition.d.ts +15 -0
- package/dist/components/floating/useHoverDisclosure.d.ts +2 -0
- package/dist/components/focus-trap/focus-trap.d.ts +31 -0
- package/dist/components/focus-trap/index.d.ts +4 -0
- package/dist/components/focus-trap/index.js +3 -0
- package/dist/components/focus-trap/types.d.ts +41 -0
- package/dist/components/focus-trap/useFocusTrap.d.ts +2 -0
- package/dist/components/icon-button/index.d.ts +2 -1
- package/dist/components/icon-button/index.js +2 -1
- package/dist/components/icon-button/types.d.ts +4 -1
- package/dist/components/input/index.d.ts +2 -1
- package/dist/components/input/index.js +2 -1
- package/dist/components/input/input.d.ts +4 -1
- package/dist/components/input/types.d.ts +7 -2
- package/dist/components/modal/index.d.ts +2 -1
- package/dist/components/modal/index.js +2 -2
- package/dist/components/modal/modal.d.ts +3 -1
- package/dist/components/modal/types.d.ts +11 -1
- package/dist/components/modal/useModal.d.ts +7 -4
- package/dist/components/number-input/index.d.ts +2 -1
- package/dist/components/number-input/index.js +2 -2
- package/dist/components/number-input/types.d.ts +7 -2
- package/dist/components/number-input/useNumberInput.d.ts +2 -1
- package/dist/components/overlay/index.d.ts +2 -1
- package/dist/components/overlay/index.js +2 -1
- package/dist/components/overlay/types.d.ts +4 -1
- package/dist/components/popover/index.d.ts +2 -2
- package/dist/components/popover/index.js +2 -2
- package/dist/components/popover/popover.d.ts +2 -2
- package/dist/components/popover/types.d.ts +20 -11
- package/dist/components/popover/usePopover.d.ts +9 -1
- package/dist/components/progress/index.d.ts +2 -2
- package/dist/components/progress/index.js +2 -2
- package/dist/components/progress/types.d.ts +4 -1
- package/dist/components/radio/index.d.ts +2 -1
- package/dist/components/radio/index.js +2 -2
- package/dist/components/radio/radio.d.ts +8 -3
- package/dist/components/radio/types.d.ts +37 -4
- package/dist/components/radio/useRadio.d.ts +12 -4
- package/dist/components/select/index.d.ts +2 -1
- package/dist/components/select/index.js +2 -2
- package/dist/components/select/select.d.ts +4 -1
- package/dist/components/select/types.d.ts +10 -2
- package/dist/components/select/useSelect.d.ts +3 -1
- package/dist/components/slider/index.d.ts +2 -2
- package/dist/components/slider/index.js +2 -2
- package/dist/components/slider/range-slider-tooltip.d.ts +3 -0
- package/dist/components/slider/range-slider.d.ts +7 -4
- package/dist/components/slider/slider.d.ts +4 -1
- package/dist/components/slider/sliderCore.d.ts +4 -4
- package/dist/components/slider/types.d.ts +22 -4
- package/dist/components/slider/useRangeSlider.d.ts +2 -2
- package/dist/components/slider/useSlider.d.ts +2 -2
- package/dist/components/switch/index.d.ts +2 -1
- package/dist/components/switch/index.js +2 -2
- package/dist/components/switch/switch.d.ts +4 -1
- package/dist/components/switch/types.d.ts +11 -2
- package/dist/components/switch/useSwitch.d.ts +3 -1
- package/dist/components/tabs/index.d.ts +2 -1
- package/dist/components/tabs/index.js +2 -2
- package/dist/components/tabs/types.d.ts +13 -4
- package/dist/components/teleport-provider/index.d.ts +3 -0
- package/dist/components/teleport-provider/index.js +3 -0
- package/dist/components/teleport-provider/teleport-provider.d.ts +21 -0
- package/dist/components/teleport-provider/types.d.ts +4 -0
- package/dist/components/teleport-provider/useTeleportTarget.d.ts +6 -0
- package/dist/components/textarea/index.d.ts +2 -1
- package/dist/components/textarea/index.js +2 -2
- package/dist/components/textarea/textarea.d.ts +4 -1
- package/dist/components/textarea/types.d.ts +10 -2
- package/dist/components/textarea/useTextarea.d.ts +2 -1
- package/dist/components/toast/index.d.ts +3 -2
- package/dist/components/toast/index.js +2 -2
- package/dist/components/toast/toast-store.d.ts +2 -0
- package/dist/components/toast/toast.d.ts +2 -2
- package/dist/components/toast/types.d.ts +20 -10
- package/dist/components/toast/useToast.d.ts +2 -2
- package/dist/components/tooltip/index.d.ts +2 -1
- package/dist/components/tooltip/index.js +2 -1
- package/dist/components/tooltip/tooltip.d.ts +2 -2
- package/dist/components/tooltip/types.d.ts +13 -12
- package/dist/components/tooltip/useTooltip.d.ts +12 -2
- package/dist/composables/useOverlayLayer.d.ts +32 -0
- package/dist/dialog.js +510 -0
- package/dist/dropdown-menu.css +191 -108
- package/dist/dropdown-menu.js +1954 -198
- package/dist/field.css +41 -39
- package/dist/field.js +40 -16
- package/dist/floating.js +403 -0
- package/dist/focus-trap.js +80 -0
- package/dist/icon-button.css +193 -189
- package/dist/icon-button.js +23 -18
- package/dist/icon-button2.js +8 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +39 -32
- package/dist/input.css +122 -120
- package/dist/input.js +63 -40
- package/dist/input2.js +9 -0
- package/dist/legacy-unlayered.css +5382 -0
- package/dist/modal.css +129 -127
- package/dist/modal.js +182 -281
- package/dist/number-input.css +87 -85
- package/dist/number-input.js +98 -26
- package/dist/overlay.css +26 -24
- package/dist/overlay.js +17 -9
- package/dist/overlay2.js +4 -0
- package/dist/popover.css +140 -107
- package/dist/popover.js +276 -196
- package/dist/popover2.js +6 -1
- package/dist/progress.css +101 -99
- package/dist/progress.js +50 -28
- package/dist/radio.css +114 -105
- package/dist/radio.js +237 -61
- package/dist/select.css +255 -242
- package/dist/select.js +257 -94
- package/dist/slider.css +1090 -1031
- package/dist/slider.js +443 -175
- package/dist/styles-api.d.ts +22 -0
- package/dist/styles-api.js +49 -0
- package/dist/switch.css +120 -108
- package/dist/switch.js +112 -38
- package/dist/tabs.css +286 -278
- package/dist/tabs.js +60 -21
- package/dist/teleport-provider.js +15 -0
- package/dist/textarea.css +132 -130
- package/dist/textarea.js +83 -31
- package/dist/toast.css +229 -225
- package/dist/toast.js +189 -118
- package/dist/tooltip.css +61 -106
- package/dist/tooltip.js +184 -228
- package/dist/tooltip2.js +8 -0
- package/dist/useControlState.js +4 -0
- package/dist/useFloatingPosition.js +1317 -0
- package/dist/useFocusTrap.js +130 -0
- package/dist/useFormControl.js +107 -0
- package/dist/useOverlayLayer.js +262 -0
- package/dist/useTeleportTarget.js +40 -0
- package/docs/public-floating-api.md +148 -0
- package/docs/public-styles-api.md +134 -0
- package/docs/public-tokens.md +545 -0
- package/package.json +37 -9
- package/src/styles/_tokens.scss +33 -28
- package/src/styles/_utilities.scss +11 -9
- package/src/styles/styles-manifest.json +4125 -0
- package/dist/rafScheduler.js +0 -34
- package/dist/useClickOutside.js +0 -24
package/dist/modal.js
CHANGED
|
@@ -1,24 +1,15 @@
|
|
|
1
1
|
import './modal.css';
|
|
2
2
|
import { t as x_default } from "./x.js";
|
|
3
3
|
import { t as bem } from "./bem.js";
|
|
4
|
+
import { n as useStylesApi } from "./styles-api.js";
|
|
4
5
|
import { t as _plugin_vue_export_helper_default } from "./_plugin-vue_export-helper.js";
|
|
6
|
+
import { a as dialog_overlay_default, c as dialog_close_default, i as dialog_portal_default, l as resolveDialogCloseReason, n as dialog_title_default, o as dialog_description_default, r as dialog_root_default, s as dialog_content_default } from "./dialog.js";
|
|
5
7
|
import { t as icon_button_default } from "./icon-button.js";
|
|
6
8
|
import { t as overlay_default } from "./overlay.js";
|
|
7
|
-
import { VaporTransition, applyVShow,
|
|
9
|
+
import { VaporTransition, applyVShow, computed, createComponent, createIf, createSlot, defineVaporComponent, extend, mergeProps, ref, renderEffect, setDynamicProps, setInsertionState, setText, template, toDisplayString, unref, useId, useSlots } from "vue";
|
|
8
10
|
//#region src/components/modal/useModal.ts
|
|
9
|
-
var bodyScrollLockCount = 0;
|
|
10
|
-
var previousBodyOverflow = "";
|
|
11
|
-
var activeModalStack = [];
|
|
12
11
|
var DEFAULT_ROLE = "dialog";
|
|
13
12
|
var DEFAULT_SIZE = "md";
|
|
14
|
-
var FOCUSABLE_SELECTOR = [
|
|
15
|
-
"a[href]",
|
|
16
|
-
"button:not([disabled])",
|
|
17
|
-
"textarea:not([disabled])",
|
|
18
|
-
"input:not([disabled])",
|
|
19
|
-
"select:not([disabled])",
|
|
20
|
-
"[tabindex]:not([tabindex=\"-1\"])"
|
|
21
|
-
].join(",");
|
|
22
13
|
var MODAL_PRESET_SIZES = /* @__PURE__ */ new Set([
|
|
23
14
|
"sm",
|
|
24
15
|
"md",
|
|
@@ -26,63 +17,13 @@ var MODAL_PRESET_SIZES = /* @__PURE__ */ new Set([
|
|
|
26
17
|
"xl",
|
|
27
18
|
"full"
|
|
28
19
|
]);
|
|
29
|
-
function isHTMLElement(value) {
|
|
30
|
-
return typeof HTMLElement !== "undefined" && value instanceof HTMLElement;
|
|
31
|
-
}
|
|
32
20
|
function isModalPresetSize(size) {
|
|
33
21
|
return MODAL_PRESET_SIZES.has(size);
|
|
34
22
|
}
|
|
35
|
-
function
|
|
36
|
-
if (element.getAttribute("aria-hidden") === "true") return false;
|
|
37
|
-
if (element.hasAttribute("disabled")) return false;
|
|
38
|
-
return element.tabIndex >= 0;
|
|
39
|
-
}
|
|
40
|
-
function getFocusableElements(panel) {
|
|
41
|
-
if (!panel) return [];
|
|
42
|
-
return [...panel.querySelectorAll(FOCUSABLE_SELECTOR)].filter(isFocusable);
|
|
43
|
-
}
|
|
44
|
-
function focusElement(element) {
|
|
45
|
-
if (!element) return;
|
|
46
|
-
try {
|
|
47
|
-
element.focus({ preventScroll: true });
|
|
48
|
-
} catch {
|
|
49
|
-
element.focus();
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
function lockBodyScroll() {
|
|
53
|
-
if (typeof document === "undefined") return void 0;
|
|
54
|
-
if (bodyScrollLockCount === 0) {
|
|
55
|
-
previousBodyOverflow = document.body.style.overflow;
|
|
56
|
-
document.body.style.overflow = "hidden";
|
|
57
|
-
}
|
|
58
|
-
bodyScrollLockCount += 1;
|
|
59
|
-
return () => {
|
|
60
|
-
bodyScrollLockCount = Math.max(0, bodyScrollLockCount - 1);
|
|
61
|
-
if (bodyScrollLockCount === 0) document.body.style.overflow = previousBodyOverflow;
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
function readInitialFocus(initialFocus) {
|
|
65
|
-
return isRef(initialFocus) ? initialFocus.value : initialFocus;
|
|
66
|
-
}
|
|
67
|
-
function queryPanelElement(panel, selector) {
|
|
68
|
-
try {
|
|
69
|
-
const element = panel.querySelector(selector);
|
|
70
|
-
return isHTMLElement(element) ? element : null;
|
|
71
|
-
} catch {
|
|
72
|
-
return null;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
function useModal(props, emitOpenChange) {
|
|
23
|
+
function useModal(props, emit = {}) {
|
|
76
24
|
const slots = useSlots();
|
|
77
25
|
const generatedId = useId();
|
|
78
|
-
const panelRef = ref(null);
|
|
79
26
|
const uncontrolledOpen = ref(false);
|
|
80
|
-
const modalToken = Symbol("modal");
|
|
81
|
-
let isMounted = false;
|
|
82
|
-
let isActiveModal = false;
|
|
83
|
-
let previousActiveElement = null;
|
|
84
|
-
let removeDocumentListeners;
|
|
85
|
-
let unlockScroll;
|
|
86
27
|
const modalId = computed(() => props.id ?? `${generatedId}-modal`);
|
|
87
28
|
const titleId = computed(() => `${modalId.value}-title`);
|
|
88
29
|
const descriptionId = computed(() => `${modalId.value}-description`);
|
|
@@ -124,132 +65,21 @@ function useModal(props, emitOpenChange) {
|
|
|
124
65
|
function setOpen(nextOpen) {
|
|
125
66
|
if (nextOpen === isOpen.value) return;
|
|
126
67
|
if (props.open === void 0) uncontrolledOpen.value = nextOpen;
|
|
127
|
-
|
|
68
|
+
emit.openChange?.(nextOpen);
|
|
128
69
|
}
|
|
129
70
|
function openModal() {
|
|
130
71
|
setOpen(true);
|
|
131
72
|
}
|
|
132
|
-
function closeModal() {
|
|
73
|
+
function closeModal(reason = "programmatic") {
|
|
74
|
+
if (!isOpen.value) return;
|
|
133
75
|
setOpen(false);
|
|
76
|
+
emit.close?.(resolveDialogCloseReason(reason));
|
|
134
77
|
}
|
|
135
78
|
function toggleModal() {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
function resolveInitialFocus() {
|
|
139
|
-
const initialFocus = readInitialFocus(props.initialFocus);
|
|
140
|
-
const panel = panelRef.value;
|
|
141
|
-
if (!initialFocus || !panel) return null;
|
|
142
|
-
if (typeof initialFocus === "string") return queryPanelElement(panel, initialFocus);
|
|
143
|
-
return panel.contains(initialFocus) ? initialFocus : null;
|
|
144
|
-
}
|
|
145
|
-
function focusInitialElement() {
|
|
146
|
-
const firstFocusable = getFocusableElements(panelRef.value)[0];
|
|
147
|
-
focusElement(resolveInitialFocus() ?? firstFocusable ?? panelRef.value);
|
|
148
|
-
}
|
|
149
|
-
function addToStack() {
|
|
150
|
-
if (!activeModalStack.includes(modalToken)) activeModalStack.push(modalToken);
|
|
151
|
-
}
|
|
152
|
-
function removeFromStack() {
|
|
153
|
-
const index = activeModalStack.indexOf(modalToken);
|
|
154
|
-
if (index !== -1) activeModalStack.splice(index, 1);
|
|
155
|
-
}
|
|
156
|
-
function isTopModal() {
|
|
157
|
-
return activeModalStack[activeModalStack.length - 1] === modalToken;
|
|
158
|
-
}
|
|
159
|
-
function trapFocus(event) {
|
|
160
|
-
const panel = panelRef.value;
|
|
161
|
-
if (!panel) return;
|
|
162
|
-
const focusableElements = getFocusableElements(panel);
|
|
163
|
-
if (focusableElements.length === 0) {
|
|
164
|
-
event.preventDefault();
|
|
165
|
-
focusElement(panel);
|
|
166
|
-
return;
|
|
167
|
-
}
|
|
168
|
-
const firstElement = focusableElements[0];
|
|
169
|
-
const lastElement = focusableElements[focusableElements.length - 1];
|
|
170
|
-
const activeElement = document.activeElement;
|
|
171
|
-
if (!(activeElement instanceof Node && panel.contains(activeElement))) {
|
|
172
|
-
event.preventDefault();
|
|
173
|
-
focusElement(firstElement);
|
|
174
|
-
return;
|
|
175
|
-
}
|
|
176
|
-
if (event.shiftKey && activeElement === firstElement) {
|
|
177
|
-
event.preventDefault();
|
|
178
|
-
focusElement(lastElement);
|
|
179
|
-
return;
|
|
180
|
-
}
|
|
181
|
-
if (!event.shiftKey && activeElement === lastElement) {
|
|
182
|
-
event.preventDefault();
|
|
183
|
-
focusElement(firstElement);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
function onDocumentKeydown(event) {
|
|
187
|
-
if (!isOpen.value || !isTopModal()) return;
|
|
188
|
-
if (event.key === "Escape") {
|
|
189
|
-
if (props.closeOnEscape === false) return;
|
|
190
|
-
event.preventDefault();
|
|
191
|
-
closeModal();
|
|
192
|
-
return;
|
|
193
|
-
}
|
|
194
|
-
if (event.key === "Tab") trapFocus(event);
|
|
79
|
+
if (isOpen.value) closeModal("programmatic");
|
|
80
|
+
else openModal();
|
|
195
81
|
}
|
|
196
|
-
function bindDocumentListeners() {
|
|
197
|
-
if (typeof document === "undefined" || removeDocumentListeners) return;
|
|
198
|
-
document.addEventListener("keydown", onDocumentKeydown);
|
|
199
|
-
removeDocumentListeners = () => {
|
|
200
|
-
document.removeEventListener("keydown", onDocumentKeydown);
|
|
201
|
-
removeDocumentListeners = void 0;
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
|
-
function restoreFocus() {
|
|
205
|
-
if (props.returnFocus === false) {
|
|
206
|
-
previousActiveElement = null;
|
|
207
|
-
return;
|
|
208
|
-
}
|
|
209
|
-
if (previousActiveElement?.isConnected) focusElement(previousActiveElement);
|
|
210
|
-
previousActiveElement = null;
|
|
211
|
-
}
|
|
212
|
-
function activateModal() {
|
|
213
|
-
if (isActiveModal) return;
|
|
214
|
-
isActiveModal = true;
|
|
215
|
-
addToStack();
|
|
216
|
-
if (typeof document !== "undefined") {
|
|
217
|
-
const activeElement = document.activeElement;
|
|
218
|
-
previousActiveElement = isHTMLElement(activeElement) ? activeElement : null;
|
|
219
|
-
}
|
|
220
|
-
bindDocumentListeners();
|
|
221
|
-
if (props.preventScroll !== false) unlockScroll = lockBodyScroll();
|
|
222
|
-
nextTick(() => {
|
|
223
|
-
if (isActiveModal) focusInitialElement();
|
|
224
|
-
});
|
|
225
|
-
}
|
|
226
|
-
function deactivateModal() {
|
|
227
|
-
if (!isActiveModal) return;
|
|
228
|
-
isActiveModal = false;
|
|
229
|
-
removeFromStack();
|
|
230
|
-
removeDocumentListeners?.();
|
|
231
|
-
unlockScroll?.();
|
|
232
|
-
unlockScroll = void 0;
|
|
233
|
-
restoreFocus();
|
|
234
|
-
}
|
|
235
|
-
function onOverlayClick(event) {
|
|
236
|
-
if (props.closeOnOverlayClick === false || event.target !== event.currentTarget) return;
|
|
237
|
-
closeModal();
|
|
238
|
-
}
|
|
239
|
-
onMounted(() => {
|
|
240
|
-
isMounted = true;
|
|
241
|
-
if (isOpen.value) activateModal();
|
|
242
|
-
});
|
|
243
|
-
onBeforeUnmount(() => {
|
|
244
|
-
deactivateModal();
|
|
245
|
-
});
|
|
246
|
-
watch(isOpen, (nextOpen) => {
|
|
247
|
-
if (!isMounted) return;
|
|
248
|
-
if (nextOpen) activateModal();
|
|
249
|
-
else deactivateModal();
|
|
250
|
-
});
|
|
251
82
|
return {
|
|
252
|
-
panelRef,
|
|
253
83
|
modalId,
|
|
254
84
|
titleId,
|
|
255
85
|
descriptionId,
|
|
@@ -270,22 +100,19 @@ function useModal(props, emitOpenChange) {
|
|
|
270
100
|
openModal,
|
|
271
101
|
closeModal,
|
|
272
102
|
toggleModal,
|
|
273
|
-
|
|
103
|
+
setOpen
|
|
274
104
|
};
|
|
275
105
|
}
|
|
276
106
|
//#endregion
|
|
277
107
|
//#region src/components/modal/modal.vue?vue&type=script&setup=true&vapor=true&lang.ts
|
|
278
|
-
var t0 = template("
|
|
279
|
-
var t1 = template("<
|
|
280
|
-
var t2 = template("<div data-v-
|
|
281
|
-
var t3 = template("<div data-v-657f313d class=rp-modal__header>");
|
|
282
|
-
var t4 = template("<div data-v-657f313d class=rp-modal__body>");
|
|
283
|
-
var t5 = template("<div data-v-657f313d class=rp-modal__footer>");
|
|
284
|
-
var t6 = template("<div data-v-657f313d><section data-v-657f313d class=rp-modal__panel aria-modal=true tabindex=-1>");
|
|
108
|
+
var t0 = template(" ");
|
|
109
|
+
var t1 = template("<div data-v-1a627831 class=rp-modal__heading>");
|
|
110
|
+
var t2 = template("<div data-v-1a627831>");
|
|
285
111
|
//#endregion
|
|
286
112
|
//#region src/components/modal/modal.vue
|
|
287
113
|
var modal_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__ */ defineVaporComponent({
|
|
288
114
|
name: "RpModal",
|
|
115
|
+
inheritAttrs: false,
|
|
289
116
|
__name: "modal",
|
|
290
117
|
props: {
|
|
291
118
|
id: {},
|
|
@@ -324,104 +151,178 @@ var modal_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__
|
|
|
324
151
|
keepMounted: {
|
|
325
152
|
type: Boolean,
|
|
326
153
|
default: false
|
|
327
|
-
}
|
|
154
|
+
},
|
|
155
|
+
modal: {
|
|
156
|
+
type: Boolean,
|
|
157
|
+
default: true
|
|
158
|
+
},
|
|
159
|
+
focusTrapOptions: { default: () => ({}) },
|
|
160
|
+
teleport: {
|
|
161
|
+
type: Boolean,
|
|
162
|
+
default: true
|
|
163
|
+
},
|
|
164
|
+
teleportTo: {},
|
|
165
|
+
classNames: {},
|
|
166
|
+
styles: {}
|
|
328
167
|
},
|
|
329
|
-
emits: ["update:open"],
|
|
168
|
+
emits: ["update:open", "close"],
|
|
330
169
|
setup(__props, { emit: __emit, slots: $slots }) {
|
|
331
170
|
const props = __props;
|
|
332
171
|
const emit = __emit;
|
|
333
|
-
const {
|
|
334
|
-
emit("update:open", open)
|
|
172
|
+
const { modalId, titleId, descriptionId, role, isOpen, shouldRender, hasHeader, hasFooter, showCloseButton, headerId, ariaLabelledby, ariaDescribedby, ariaLabel, rootClass, rootStyle, stateClass, slotProps, setOpen } = useModal(props, {
|
|
173
|
+
openChange: (open) => emit("update:open", open),
|
|
174
|
+
close: (reason) => emit("close", reason)
|
|
335
175
|
});
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
176
|
+
function onDialogClose(reason) {
|
|
177
|
+
emit("close", reason);
|
|
178
|
+
}
|
|
179
|
+
const { getPartAttrs, getRootAttrs } = useStylesApi(props, "root");
|
|
180
|
+
const state = computed(() => isOpen.value ? "open" : "closed");
|
|
181
|
+
const rootAttrs = computed(() => getRootAttrs({
|
|
182
|
+
class: [rootClass.value, stateClass.value],
|
|
183
|
+
style: rootStyle.value,
|
|
184
|
+
"data-state": state.value
|
|
185
|
+
}));
|
|
186
|
+
function getLayeredRootAttrs(zIndex) {
|
|
187
|
+
return mergeProps(rootAttrs.value, { style: { zIndex } });
|
|
188
|
+
}
|
|
189
|
+
const overlayClassNames = computed(() => ({ root: ["rp-modal__overlay", props.classNames?.overlay] }));
|
|
190
|
+
const overlayStyles = computed(() => ({ root: props.styles?.overlay }));
|
|
191
|
+
const panelAttrs = computed(() => ({
|
|
192
|
+
...getPartAttrs("panel", { class: "rp-modal__panel" }),
|
|
193
|
+
"data-state": state.value
|
|
194
|
+
}));
|
|
195
|
+
const closeClassNames = computed(() => ({ root: ["rp-modal__close", props.classNames?.close] }));
|
|
196
|
+
const closeStyles = computed(() => ({ root: props.styles?.close }));
|
|
197
|
+
return createComponent(unref(dialog_root_default), {
|
|
198
|
+
open: () => unref(isOpen),
|
|
199
|
+
modal: () => __props.modal,
|
|
200
|
+
"close-on-escape": () => __props.closeOnEscape,
|
|
201
|
+
"close-on-outside-click": () => __props.closeOnOverlayClick,
|
|
202
|
+
"prevent-scroll": () => __props.preventScroll,
|
|
203
|
+
"return-focus": () => __props.returnFocus,
|
|
204
|
+
"onUpdate:open": () => unref(setOpen),
|
|
205
|
+
onClose: () => onDialogClose
|
|
206
|
+
}, (_slotProps0) => {
|
|
207
|
+
return createComponent(unref(dialog_portal_default), {
|
|
208
|
+
teleport: () => __props.teleport,
|
|
209
|
+
"teleport-to": () => __props.teleportTo
|
|
210
|
+
}, () => {
|
|
211
|
+
return createComponent(VaporTransition, {
|
|
212
|
+
name: "rp-modal",
|
|
213
|
+
persisted: ""
|
|
214
|
+
}, extend(() => {
|
|
215
|
+
return createIf(() => unref(shouldRender), () => {
|
|
216
|
+
const n30 = t2();
|
|
217
|
+
renderEffect(() => setDynamicProps(n30, [getLayeredRootAttrs(_slotProps0.zIndex)]));
|
|
218
|
+
setInsertionState(n30, null, 0);
|
|
219
|
+
createComponent(unref(dialog_overlay_default), {
|
|
220
|
+
as: () => overlay_default,
|
|
221
|
+
"force-mount": () => __props.keepMounted,
|
|
222
|
+
$: [() => __props.overlayProps, {
|
|
223
|
+
"class-names": () => overlayClassNames.value,
|
|
224
|
+
styles: () => overlayStyles.value,
|
|
225
|
+
"z-index": 0,
|
|
226
|
+
interactive: ""
|
|
227
|
+
}]
|
|
388
228
|
});
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
229
|
+
setInsertionState(n30, null, 1);
|
|
230
|
+
createComponent(unref(dialog_content_default), {
|
|
231
|
+
id: () => unref(modalId),
|
|
232
|
+
as: "section",
|
|
233
|
+
"force-mount": () => __props.keepMounted,
|
|
234
|
+
$: [() => panelAttrs.value, {
|
|
235
|
+
role: () => unref(role),
|
|
236
|
+
"aria-label": () => unref(ariaLabel),
|
|
237
|
+
"aria-labelledby": () => unref(ariaLabelledby),
|
|
238
|
+
"aria-describedby": () => unref(ariaDescribedby),
|
|
239
|
+
"initial-focus": () => __props.initialFocus,
|
|
240
|
+
"focus-trap-options": () => __props.focusTrapOptions
|
|
241
|
+
}]
|
|
242
|
+
}, extend(() => {
|
|
243
|
+
return [
|
|
244
|
+
createIf(() => unref(hasHeader), () => {
|
|
245
|
+
const n16 = t2();
|
|
246
|
+
renderEffect(() => setDynamicProps(n16, [{ id: unref(headerId) }, unref(getPartAttrs)("header", { class: "rp-modal__header" })]));
|
|
247
|
+
setInsertionState(n16, null, 0);
|
|
248
|
+
createSlot("header", { $: [() => unref(slotProps)] }, () => {
|
|
249
|
+
const n15 = t1();
|
|
250
|
+
setInsertionState(n15, null, 0);
|
|
251
|
+
createIf(() => __props.title, () => {
|
|
252
|
+
return createComponent(unref(dialog_title_default), {
|
|
253
|
+
id: () => unref(titleId),
|
|
254
|
+
as: "h2",
|
|
255
|
+
$: [() => unref(getPartAttrs)("title", { class: "rp-modal__title" })]
|
|
256
|
+
}, () => {
|
|
257
|
+
const n9 = t0();
|
|
258
|
+
renderEffect(() => setText(n9, toDisplayString(__props.title)));
|
|
259
|
+
return n9;
|
|
260
|
+
});
|
|
261
|
+
});
|
|
262
|
+
setInsertionState(n15, null, 1);
|
|
263
|
+
createIf(() => __props.description, () => {
|
|
264
|
+
return createComponent(unref(dialog_description_default), {
|
|
265
|
+
id: () => unref(descriptionId),
|
|
266
|
+
as: "p",
|
|
267
|
+
$: [() => unref(getPartAttrs)("description", { class: "rp-modal__description" })]
|
|
268
|
+
}, () => {
|
|
269
|
+
const n13 = t0();
|
|
270
|
+
renderEffect(() => setText(n13, toDisplayString(__props.description)));
|
|
271
|
+
return n13;
|
|
272
|
+
});
|
|
273
|
+
});
|
|
274
|
+
return n15;
|
|
275
|
+
}, 1);
|
|
276
|
+
return n16;
|
|
277
|
+
}, null, 129),
|
|
278
|
+
createIf(() => unref(showCloseButton), () => {
|
|
279
|
+
return createComponent(unref(dialog_close_default), {
|
|
280
|
+
as: () => icon_button_default,
|
|
281
|
+
"class-names": () => closeClassNames.value,
|
|
282
|
+
styles: () => closeStyles.value,
|
|
283
|
+
ariaLabel: () => __props.closeLabel,
|
|
284
|
+
variant: "ghost",
|
|
285
|
+
size: "sm"
|
|
286
|
+
}, () => {
|
|
287
|
+
return createComponent(unref(x_default));
|
|
288
|
+
});
|
|
289
|
+
}, null, 129),
|
|
290
|
+
createIf(() => $slots.default, () => {
|
|
291
|
+
const n24 = t2();
|
|
292
|
+
renderEffect(() => setDynamicProps(n24, [unref(getPartAttrs)("body", { class: "rp-modal__body" })]));
|
|
293
|
+
setInsertionState(n24, null, 0);
|
|
294
|
+
createSlot("default", { $: [() => unref(slotProps)] }, null, 1);
|
|
295
|
+
return n24;
|
|
296
|
+
}, null, 129),
|
|
297
|
+
createIf(() => unref(hasFooter), () => {
|
|
298
|
+
const n28 = t2();
|
|
299
|
+
renderEffect(() => setDynamicProps(n28, [unref(getPartAttrs)("footer", { class: "rp-modal__footer" })]));
|
|
300
|
+
setInsertionState(n28, null, 0);
|
|
301
|
+
createSlot("footer", { $: [() => unref(slotProps)] }, null, 1);
|
|
302
|
+
return n28;
|
|
303
|
+
}, null, 129)
|
|
304
|
+
];
|
|
305
|
+
}, { _: 8 }));
|
|
306
|
+
applyVShow(n30, () => unref(isOpen));
|
|
307
|
+
return n30;
|
|
308
|
+
}, null, 129);
|
|
309
|
+
}, { _: 8 }));
|
|
310
|
+
});
|
|
311
|
+
}, true);
|
|
424
312
|
}
|
|
425
|
-
}), [["__scopeId", "data-v-
|
|
313
|
+
}), [["__scopeId", "data-v-1a627831"]]);
|
|
314
|
+
//#endregion
|
|
315
|
+
//#region src/components/modal/types.ts
|
|
316
|
+
var modalParts = [
|
|
317
|
+
"root",
|
|
318
|
+
"overlay",
|
|
319
|
+
"panel",
|
|
320
|
+
"header",
|
|
321
|
+
"title",
|
|
322
|
+
"description",
|
|
323
|
+
"body",
|
|
324
|
+
"footer",
|
|
325
|
+
"close"
|
|
326
|
+
];
|
|
426
327
|
//#endregion
|
|
427
|
-
export { modal_default as t };
|
|
328
|
+
export { modal_default as n, modalParts as t };
|