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/dialog.js
ADDED
|
@@ -0,0 +1,510 @@
|
|
|
1
|
+
import { t as useRequiredInject } from "./useRequiredInject.js";
|
|
2
|
+
import { n as useOverlayLayerBranch, t as useOverlayLayer } from "./useOverlayLayer.js";
|
|
3
|
+
import { t as useFocusTrap } from "./useFocusTrap.js";
|
|
4
|
+
import { t as provideTeleportTarget } from "./useTeleportTarget.js";
|
|
5
|
+
import { VaporTeleport, applyVShow, computed, createComponent, createDynamicComponent, createIf, createSlot, defineVaporComponent, extend, isRef, mergeProps, nextTick, onBeforeUnmount, provide, ref, setTemplateRefBinding, shallowRef, unref, useAttrs, useId, watch } from "vue";
|
|
6
|
+
//#region src/components/dialog/dialog-core.ts
|
|
7
|
+
var dialogRootKey = Symbol("dialog-root");
|
|
8
|
+
function resolveDialogCloseReason(reason) {
|
|
9
|
+
return reason === "escape" || reason === "outside" || reason === "programmatic" ? reason : "programmatic";
|
|
10
|
+
}
|
|
11
|
+
function toDialogHTMLElement(value) {
|
|
12
|
+
if (typeof HTMLElement !== "undefined" && value instanceof HTMLElement) return value;
|
|
13
|
+
if (value == null || typeof Element !== "undefined" && value instanceof Element) return null;
|
|
14
|
+
const element = value.$el;
|
|
15
|
+
return element instanceof HTMLElement ? element : null;
|
|
16
|
+
}
|
|
17
|
+
function createDialogEvent(type, detail, originalEvent) {
|
|
18
|
+
const target = originalEvent.target;
|
|
19
|
+
return new (((typeof Node !== "undefined" && target instanceof Node ? target.ownerDocument?.defaultView : null)?.CustomEvent) ?? CustomEvent)(type, {
|
|
20
|
+
bubbles: false,
|
|
21
|
+
cancelable: true,
|
|
22
|
+
detail
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region src/components/dialog/dialog-close.vue
|
|
27
|
+
var dialog_close_default = /* @__PURE__ */ defineVaporComponent({
|
|
28
|
+
name: "RpDialogClose",
|
|
29
|
+
inheritAttrs: false,
|
|
30
|
+
__name: "dialog-close",
|
|
31
|
+
props: {
|
|
32
|
+
as: { default: "button" },
|
|
33
|
+
disabled: {
|
|
34
|
+
type: Boolean,
|
|
35
|
+
default: false
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
setup(__props) {
|
|
39
|
+
const props = __props;
|
|
40
|
+
const attrs = useAttrs();
|
|
41
|
+
const root = useRequiredInject(dialogRootKey, "RpDialogClose");
|
|
42
|
+
function onClick(event) {
|
|
43
|
+
if (event.defaultPrevented || props.disabled) return;
|
|
44
|
+
root.close("programmatic");
|
|
45
|
+
}
|
|
46
|
+
const rootAttrs = computed(() => mergeProps(attrs, {
|
|
47
|
+
type: props.as === "button" ? "button" : void 0,
|
|
48
|
+
disabled: props.as === "button" ? props.disabled || void 0 : void 0,
|
|
49
|
+
"aria-disabled": props.as === "button" ? void 0 : props.disabled || void 0,
|
|
50
|
+
"data-disabled": props.disabled ? "" : void 0,
|
|
51
|
+
onClick
|
|
52
|
+
}));
|
|
53
|
+
return createDynamicComponent(() => __props.as, { $: [() => rootAttrs.value] }, extend(() => {
|
|
54
|
+
return createSlot();
|
|
55
|
+
}, { _: 8 }), 1);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
//#endregion
|
|
59
|
+
//#region src/components/dialog/dialog-content.vue
|
|
60
|
+
var dialog_content_default = /* @__PURE__ */ defineVaporComponent({
|
|
61
|
+
name: "RpDialogContent",
|
|
62
|
+
inheritAttrs: false,
|
|
63
|
+
__name: "dialog-content",
|
|
64
|
+
props: {
|
|
65
|
+
id: {},
|
|
66
|
+
as: { default: "div" },
|
|
67
|
+
role: { default: "dialog" },
|
|
68
|
+
forceMount: {
|
|
69
|
+
type: Boolean,
|
|
70
|
+
default: false
|
|
71
|
+
},
|
|
72
|
+
initialFocus: { default: null },
|
|
73
|
+
ariaLabel: {},
|
|
74
|
+
ariaLabelledby: {},
|
|
75
|
+
ariaDescribedby: {},
|
|
76
|
+
focusTrapOptions: { default: () => ({}) }
|
|
77
|
+
},
|
|
78
|
+
emits: [
|
|
79
|
+
"escapeKeyDown",
|
|
80
|
+
"pointerDownOutside",
|
|
81
|
+
"interactOutside"
|
|
82
|
+
],
|
|
83
|
+
setup(__props, { emit: __emit }) {
|
|
84
|
+
const props = __props;
|
|
85
|
+
const emit = __emit;
|
|
86
|
+
const attrs = useAttrs();
|
|
87
|
+
const root = useRequiredInject(dialogRootKey, "RpDialogContent");
|
|
88
|
+
const id = computed(() => props.id ?? root.contentId.value);
|
|
89
|
+
const shouldRender = computed(() => props.forceMount || root.isOpen.value);
|
|
90
|
+
const focusTrapContainers = computed(() => {
|
|
91
|
+
const content = root.contentRef.value;
|
|
92
|
+
if (!content) return null;
|
|
93
|
+
return [content, ...root.layer.focusBranches.value];
|
|
94
|
+
});
|
|
95
|
+
const ariaLabelledby = computed(() => {
|
|
96
|
+
if (props.ariaLabel) return void 0;
|
|
97
|
+
return props.ariaLabelledby ?? (root.titleIds.value.join(" ") || void 0);
|
|
98
|
+
});
|
|
99
|
+
const ariaDescribedby = computed(() => props.ariaDescribedby ?? (root.descriptionIds.value.join(" ") || void 0));
|
|
100
|
+
function resolveInitialFocus() {
|
|
101
|
+
const initialFocus = props.initialFocus;
|
|
102
|
+
const resolved = isRef(initialFocus) ? initialFocus.value : initialFocus;
|
|
103
|
+
if (typeof resolved !== "string") return resolved ?? void 0;
|
|
104
|
+
try {
|
|
105
|
+
return root.contentRef.value?.querySelector(resolved) ?? void 0;
|
|
106
|
+
} catch {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
const focusTrap = useFocusTrap(focusTrapContainers, {
|
|
111
|
+
...props.focusTrapOptions,
|
|
112
|
+
initialFocus: resolveInitialFocus,
|
|
113
|
+
fallbackFocus: () => root.contentRef.value,
|
|
114
|
+
returnFocusOnDeactivate: false,
|
|
115
|
+
escapeDeactivates: false,
|
|
116
|
+
allowOutsideClick: true,
|
|
117
|
+
preventScroll: true,
|
|
118
|
+
delayInitialFocus: props.focusTrapOptions.delayInitialFocus ?? false
|
|
119
|
+
});
|
|
120
|
+
function setElement(value) {
|
|
121
|
+
root.setContent(toDialogHTMLElement(value), id.value);
|
|
122
|
+
}
|
|
123
|
+
function onDocumentKeydown(event) {
|
|
124
|
+
if (event.key !== "Escape" || event.defaultPrevented || !root.closeOnEscape.value || !root.layer.isTopLayer()) return;
|
|
125
|
+
const customEvent = createDialogEvent("dialog-escape-key-down", { originalEvent: event }, event);
|
|
126
|
+
emit("escapeKeyDown", customEvent);
|
|
127
|
+
if (customEvent.defaultPrevented) return;
|
|
128
|
+
event.preventDefault();
|
|
129
|
+
root.close("escape");
|
|
130
|
+
}
|
|
131
|
+
function onDocumentPointerdown(event) {
|
|
132
|
+
if (event.defaultPrevented || !root.closeOnOutsideClick.value || !root.layer.isTopLayer() || root.layer.isInside(event)) return;
|
|
133
|
+
const customEvent = createDialogEvent("dialog-pointer-down-outside", { originalEvent: event }, event);
|
|
134
|
+
emit("pointerDownOutside", customEvent);
|
|
135
|
+
emit("interactOutside", customEvent);
|
|
136
|
+
if (!customEvent.defaultPrevented) root.close("outside");
|
|
137
|
+
}
|
|
138
|
+
function setDocumentListeners(active) {
|
|
139
|
+
const document = root.contentRef.value?.ownerDocument;
|
|
140
|
+
if (!document) return;
|
|
141
|
+
const method = active ? "addEventListener" : "removeEventListener";
|
|
142
|
+
document[method]("keydown", onDocumentKeydown);
|
|
143
|
+
document[method]("pointerdown", onDocumentPointerdown, true);
|
|
144
|
+
}
|
|
145
|
+
watch([
|
|
146
|
+
root.isOpen,
|
|
147
|
+
root.modal,
|
|
148
|
+
root.contentRef
|
|
149
|
+
], ([open, modal], _previous, onCleanup) => {
|
|
150
|
+
if (!open || !root.contentRef.value) {
|
|
151
|
+
focusTrap.deactivate({ returnFocus: false });
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
setDocumentListeners(true);
|
|
155
|
+
if (modal) focusTrap.activate();
|
|
156
|
+
else focusTrap.deactivate({ returnFocus: false });
|
|
157
|
+
onCleanup(() => setDocumentListeners(false));
|
|
158
|
+
}, {
|
|
159
|
+
flush: "post",
|
|
160
|
+
immediate: true
|
|
161
|
+
});
|
|
162
|
+
watch(id, (nextId) => {
|
|
163
|
+
root.setContent(root.contentRef.value, nextId);
|
|
164
|
+
}, { immediate: true });
|
|
165
|
+
onBeforeUnmount(() => {
|
|
166
|
+
setDocumentListeners(false);
|
|
167
|
+
focusTrap.deactivate({ returnFocus: false });
|
|
168
|
+
root.setContent(null, id.value);
|
|
169
|
+
});
|
|
170
|
+
const rootAttrs = computed(() => mergeProps(attrs, {
|
|
171
|
+
id: id.value,
|
|
172
|
+
role: props.role,
|
|
173
|
+
tabindex: root.modal.value ? -1 : void 0,
|
|
174
|
+
"aria-modal": root.modal.value ? "true" : void 0,
|
|
175
|
+
"aria-label": props.ariaLabel,
|
|
176
|
+
"aria-labelledby": ariaLabelledby.value,
|
|
177
|
+
"aria-describedby": ariaDescribedby.value,
|
|
178
|
+
"data-state": root.isOpen.value ? "open" : "closed",
|
|
179
|
+
"data-modal": root.modal.value ? "" : void 0,
|
|
180
|
+
style: { zIndex: root.layer.zIndex.value }
|
|
181
|
+
}));
|
|
182
|
+
return createIf(() => shouldRender.value, () => {
|
|
183
|
+
const n3 = createDynamicComponent(() => __props.as, { $: [() => rootAttrs.value] }, extend(() => {
|
|
184
|
+
return createSlot("default", {
|
|
185
|
+
isOpen: () => unref(root).isOpen.value,
|
|
186
|
+
close: () => unref(root).close
|
|
187
|
+
});
|
|
188
|
+
}, { _: 8 }), 1);
|
|
189
|
+
applyVShow(n3, () => unref(root).isOpen.value);
|
|
190
|
+
setTemplateRefBinding(n3, () => setElement);
|
|
191
|
+
return n3;
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
//#endregion
|
|
196
|
+
//#region src/components/dialog/dialog-description.vue
|
|
197
|
+
var dialog_description_default = /* @__PURE__ */ defineVaporComponent({
|
|
198
|
+
name: "RpDialogDescription",
|
|
199
|
+
inheritAttrs: false,
|
|
200
|
+
__name: "dialog-description",
|
|
201
|
+
props: {
|
|
202
|
+
id: {},
|
|
203
|
+
as: { default: "p" }
|
|
204
|
+
},
|
|
205
|
+
setup(__props) {
|
|
206
|
+
const props = __props;
|
|
207
|
+
const attrs = useAttrs();
|
|
208
|
+
const root = useRequiredInject(dialogRootKey, "RpDialogDescription");
|
|
209
|
+
const generatedId = useId();
|
|
210
|
+
const id = computed(() => props.id ?? `${generatedId}-dialog-description`);
|
|
211
|
+
let cleanup = root.registerDescription(id.value);
|
|
212
|
+
watch(id, (value) => {
|
|
213
|
+
cleanup();
|
|
214
|
+
cleanup = root.registerDescription(value);
|
|
215
|
+
});
|
|
216
|
+
onBeforeUnmount(() => cleanup());
|
|
217
|
+
const rootAttrs = computed(() => mergeProps(attrs, { id: id.value }));
|
|
218
|
+
return createDynamicComponent(() => __props.as, { $: [() => rootAttrs.value] }, extend(() => {
|
|
219
|
+
return createSlot();
|
|
220
|
+
}, { _: 8 }), 1);
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
//#endregion
|
|
224
|
+
//#region src/components/dialog/dialog-overlay.vue
|
|
225
|
+
var dialog_overlay_default = /* @__PURE__ */ defineVaporComponent({
|
|
226
|
+
name: "RpDialogOverlay",
|
|
227
|
+
inheritAttrs: false,
|
|
228
|
+
__name: "dialog-overlay",
|
|
229
|
+
props: {
|
|
230
|
+
as: { default: "div" },
|
|
231
|
+
forceMount: {
|
|
232
|
+
type: Boolean,
|
|
233
|
+
default: false
|
|
234
|
+
}
|
|
235
|
+
},
|
|
236
|
+
setup(__props) {
|
|
237
|
+
const props = __props;
|
|
238
|
+
const attrs = useAttrs();
|
|
239
|
+
const root = useRequiredInject(dialogRootKey, "RpDialogOverlay");
|
|
240
|
+
const element = ref(null);
|
|
241
|
+
const shouldRender = computed(() => props.forceMount || root.isOpen.value);
|
|
242
|
+
const rootAttrs = computed(() => mergeProps(attrs, {
|
|
243
|
+
"aria-hidden": "true",
|
|
244
|
+
"data-state": root.isOpen.value ? "open" : "closed",
|
|
245
|
+
style: { zIndex: root.layer.zIndex.value - 1 }
|
|
246
|
+
}));
|
|
247
|
+
function setElement(value) {
|
|
248
|
+
element.value = toDialogHTMLElement(value);
|
|
249
|
+
}
|
|
250
|
+
useOverlayLayerBranch(element, {
|
|
251
|
+
focus: false,
|
|
252
|
+
inside: false
|
|
253
|
+
});
|
|
254
|
+
return createIf(() => shouldRender.value, () => {
|
|
255
|
+
const n3 = createDynamicComponent(() => __props.as, { $: [() => rootAttrs.value] }, extend(() => {
|
|
256
|
+
return createSlot();
|
|
257
|
+
}, { _: 8 }), 1);
|
|
258
|
+
applyVShow(n3, () => unref(root).isOpen.value);
|
|
259
|
+
setTemplateRefBinding(n3, () => setElement);
|
|
260
|
+
return n3;
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
//#endregion
|
|
265
|
+
//#region src/components/dialog/dialog-portal.vue
|
|
266
|
+
var dialog_portal_default = /* @__PURE__ */ defineVaporComponent({
|
|
267
|
+
name: "RpDialogPortal",
|
|
268
|
+
__name: "dialog-portal",
|
|
269
|
+
props: {
|
|
270
|
+
teleport: {
|
|
271
|
+
type: Boolean,
|
|
272
|
+
default: true
|
|
273
|
+
},
|
|
274
|
+
teleportTo: { default: void 0 }
|
|
275
|
+
},
|
|
276
|
+
setup(__props) {
|
|
277
|
+
const props = __props;
|
|
278
|
+
const teleportTo = provideTeleportTarget(props, () => Boolean(props.teleport));
|
|
279
|
+
return createComponent(VaporTeleport, {
|
|
280
|
+
to: () => unref(teleportTo),
|
|
281
|
+
disabled: () => !__props.teleport
|
|
282
|
+
}, extend(() => {
|
|
283
|
+
return createSlot();
|
|
284
|
+
}, { _: 8 }), true);
|
|
285
|
+
}
|
|
286
|
+
});
|
|
287
|
+
//#endregion
|
|
288
|
+
//#region src/components/dialog/dialog-root.vue
|
|
289
|
+
var dialog_root_default = /* @__PURE__ */ defineVaporComponent({
|
|
290
|
+
name: "RpDialogRoot",
|
|
291
|
+
__name: "dialog-root",
|
|
292
|
+
props: {
|
|
293
|
+
open: {
|
|
294
|
+
type: Boolean,
|
|
295
|
+
default: void 0
|
|
296
|
+
},
|
|
297
|
+
defaultOpen: {
|
|
298
|
+
type: Boolean,
|
|
299
|
+
default: false
|
|
300
|
+
},
|
|
301
|
+
modal: {
|
|
302
|
+
type: Boolean,
|
|
303
|
+
default: true
|
|
304
|
+
},
|
|
305
|
+
closeOnEscape: {
|
|
306
|
+
type: Boolean,
|
|
307
|
+
default: true
|
|
308
|
+
},
|
|
309
|
+
closeOnOutsideClick: {
|
|
310
|
+
type: Boolean,
|
|
311
|
+
default: true
|
|
312
|
+
},
|
|
313
|
+
preventScroll: {
|
|
314
|
+
type: Boolean,
|
|
315
|
+
default: true
|
|
316
|
+
},
|
|
317
|
+
returnFocus: {
|
|
318
|
+
type: Boolean,
|
|
319
|
+
default: true
|
|
320
|
+
}
|
|
321
|
+
},
|
|
322
|
+
emits: ["update:open", "close"],
|
|
323
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
324
|
+
const props = __props;
|
|
325
|
+
const emit = __emit;
|
|
326
|
+
const generatedId = useId();
|
|
327
|
+
const uncontrolledOpen = ref(props.defaultOpen);
|
|
328
|
+
const isOpen = computed(() => props.open ?? uncontrolledOpen.value);
|
|
329
|
+
const modal = computed(() => props.modal);
|
|
330
|
+
const closeOnEscape = computed(() => props.closeOnEscape);
|
|
331
|
+
const closeOnOutsideClick = computed(() => props.closeOnOutsideClick);
|
|
332
|
+
const preventScroll = computed(() => props.preventScroll);
|
|
333
|
+
const returnFocus = computed(() => props.returnFocus);
|
|
334
|
+
const triggerRef = ref(null);
|
|
335
|
+
const contentRef = ref(null);
|
|
336
|
+
const contentId = ref(`${generatedId}-dialog`);
|
|
337
|
+
const titleIds = shallowRef([]);
|
|
338
|
+
const descriptionIds = shallowRef([]);
|
|
339
|
+
let restoreFocusTo = null;
|
|
340
|
+
const layer = useOverlayLayer({
|
|
341
|
+
active: isOpen,
|
|
342
|
+
element: contentRef,
|
|
343
|
+
modal,
|
|
344
|
+
modalEffects: true,
|
|
345
|
+
preventScroll,
|
|
346
|
+
baseZIndex: 1e3
|
|
347
|
+
});
|
|
348
|
+
function setOpen(value) {
|
|
349
|
+
const previous = isOpen.value;
|
|
350
|
+
if (props.open === void 0) uncontrolledOpen.value = value;
|
|
351
|
+
if (previous !== value) emit("update:open", value);
|
|
352
|
+
}
|
|
353
|
+
function rememberFocus() {
|
|
354
|
+
if (typeof document === "undefined" || restoreFocusTo) return;
|
|
355
|
+
const activeElement = document.activeElement;
|
|
356
|
+
restoreFocusTo = activeElement instanceof HTMLElement && activeElement !== document.body ? activeElement : triggerRef.value;
|
|
357
|
+
}
|
|
358
|
+
function restoreFocus() {
|
|
359
|
+
const target = restoreFocusTo ?? triggerRef.value;
|
|
360
|
+
restoreFocusTo = null;
|
|
361
|
+
if (!returnFocus.value) return;
|
|
362
|
+
nextTick(() => {
|
|
363
|
+
if (target?.isConnected) target.focus({ preventScroll: true });
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
function open() {
|
|
367
|
+
if (isOpen.value) return;
|
|
368
|
+
rememberFocus();
|
|
369
|
+
setOpen(true);
|
|
370
|
+
}
|
|
371
|
+
function close(reason = "programmatic") {
|
|
372
|
+
if (!isOpen.value) return;
|
|
373
|
+
setOpen(false);
|
|
374
|
+
emit("close", resolveDialogCloseReason(reason));
|
|
375
|
+
}
|
|
376
|
+
function toggle() {
|
|
377
|
+
if (isOpen.value) close("programmatic");
|
|
378
|
+
else open();
|
|
379
|
+
}
|
|
380
|
+
function setTrigger(element) {
|
|
381
|
+
triggerRef.value = element;
|
|
382
|
+
}
|
|
383
|
+
function setContent(element, id) {
|
|
384
|
+
contentRef.value = element;
|
|
385
|
+
contentId.value = id;
|
|
386
|
+
}
|
|
387
|
+
function registerId(target, id) {
|
|
388
|
+
target.value = [...target.value.filter((value) => value !== id), id];
|
|
389
|
+
return () => {
|
|
390
|
+
target.value = target.value.filter((value) => value !== id);
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
const context = {
|
|
394
|
+
isOpen,
|
|
395
|
+
modal,
|
|
396
|
+
closeOnEscape,
|
|
397
|
+
closeOnOutsideClick,
|
|
398
|
+
returnFocus,
|
|
399
|
+
triggerRef,
|
|
400
|
+
contentRef,
|
|
401
|
+
contentId,
|
|
402
|
+
titleIds,
|
|
403
|
+
descriptionIds,
|
|
404
|
+
layer,
|
|
405
|
+
open,
|
|
406
|
+
close,
|
|
407
|
+
toggle,
|
|
408
|
+
setTrigger,
|
|
409
|
+
setContent,
|
|
410
|
+
registerTitle: (id) => registerId(titleIds, id),
|
|
411
|
+
registerDescription: (id) => registerId(descriptionIds, id)
|
|
412
|
+
};
|
|
413
|
+
const slotProps = computed(() => ({
|
|
414
|
+
isOpen: isOpen.value,
|
|
415
|
+
zIndex: layer.zIndex.value,
|
|
416
|
+
open,
|
|
417
|
+
close,
|
|
418
|
+
toggle
|
|
419
|
+
}));
|
|
420
|
+
watch(isOpen, (value, previous) => {
|
|
421
|
+
if (value && !previous) rememberFocus();
|
|
422
|
+
else if (!value && previous) restoreFocus();
|
|
423
|
+
}, { immediate: true });
|
|
424
|
+
onBeforeUnmount(() => {
|
|
425
|
+
if (isOpen.value) restoreFocus();
|
|
426
|
+
});
|
|
427
|
+
provide(dialogRootKey, context);
|
|
428
|
+
__expose({
|
|
429
|
+
open,
|
|
430
|
+
close,
|
|
431
|
+
toggle
|
|
432
|
+
});
|
|
433
|
+
return createSlot("default", { $: [() => slotProps.value] });
|
|
434
|
+
}
|
|
435
|
+
});
|
|
436
|
+
//#endregion
|
|
437
|
+
//#region src/components/dialog/dialog-title.vue
|
|
438
|
+
var dialog_title_default = /* @__PURE__ */ defineVaporComponent({
|
|
439
|
+
name: "RpDialogTitle",
|
|
440
|
+
inheritAttrs: false,
|
|
441
|
+
__name: "dialog-title",
|
|
442
|
+
props: {
|
|
443
|
+
id: {},
|
|
444
|
+
as: { default: "h2" }
|
|
445
|
+
},
|
|
446
|
+
setup(__props) {
|
|
447
|
+
const props = __props;
|
|
448
|
+
const attrs = useAttrs();
|
|
449
|
+
const root = useRequiredInject(dialogRootKey, "RpDialogTitle");
|
|
450
|
+
const generatedId = useId();
|
|
451
|
+
const id = computed(() => props.id ?? `${generatedId}-dialog-title`);
|
|
452
|
+
let cleanup = root.registerTitle(id.value);
|
|
453
|
+
watch(id, (value) => {
|
|
454
|
+
cleanup();
|
|
455
|
+
cleanup = root.registerTitle(value);
|
|
456
|
+
});
|
|
457
|
+
onBeforeUnmount(() => cleanup());
|
|
458
|
+
const rootAttrs = computed(() => mergeProps(attrs, { id: id.value }));
|
|
459
|
+
return createDynamicComponent(() => __props.as, { $: [() => rootAttrs.value] }, extend(() => {
|
|
460
|
+
return createSlot();
|
|
461
|
+
}, { _: 8 }), 1);
|
|
462
|
+
}
|
|
463
|
+
});
|
|
464
|
+
//#endregion
|
|
465
|
+
//#region src/components/dialog/dialog-trigger.vue
|
|
466
|
+
var dialog_trigger_default = /* @__PURE__ */ defineVaporComponent({
|
|
467
|
+
name: "RpDialogTrigger",
|
|
468
|
+
inheritAttrs: false,
|
|
469
|
+
__name: "dialog-trigger",
|
|
470
|
+
props: {
|
|
471
|
+
id: {},
|
|
472
|
+
as: { default: "button" },
|
|
473
|
+
disabled: {
|
|
474
|
+
type: Boolean,
|
|
475
|
+
default: false
|
|
476
|
+
}
|
|
477
|
+
},
|
|
478
|
+
setup(__props) {
|
|
479
|
+
const props = __props;
|
|
480
|
+
const attrs = useAttrs();
|
|
481
|
+
const root = useRequiredInject(dialogRootKey, "RpDialogTrigger");
|
|
482
|
+
function setElement(value) {
|
|
483
|
+
root.setTrigger(toDialogHTMLElement(value));
|
|
484
|
+
}
|
|
485
|
+
function onClick(event) {
|
|
486
|
+
if (event.defaultPrevented || props.disabled) return;
|
|
487
|
+
root.toggle();
|
|
488
|
+
}
|
|
489
|
+
const rootAttrs = computed(() => mergeProps(attrs, {
|
|
490
|
+
id: props.id,
|
|
491
|
+
type: props.as === "button" ? "button" : void 0,
|
|
492
|
+
disabled: props.as === "button" ? props.disabled || void 0 : void 0,
|
|
493
|
+
"aria-controls": root.contentId.value,
|
|
494
|
+
"aria-expanded": root.isOpen.value,
|
|
495
|
+
"aria-haspopup": "dialog",
|
|
496
|
+
"aria-disabled": props.as === "button" ? void 0 : props.disabled || void 0,
|
|
497
|
+
"data-state": root.isOpen.value ? "open" : "closed",
|
|
498
|
+
"data-disabled": props.disabled ? "" : void 0,
|
|
499
|
+
onClick
|
|
500
|
+
}));
|
|
501
|
+
onBeforeUnmount(() => root.setTrigger(null));
|
|
502
|
+
const n1 = createDynamicComponent(() => __props.as, { $: [() => rootAttrs.value] }, extend(() => {
|
|
503
|
+
return createSlot("default", { isOpen: () => unref(root).isOpen.value });
|
|
504
|
+
}, { _: 8 }), 1);
|
|
505
|
+
setTemplateRefBinding(n1, () => setElement);
|
|
506
|
+
return n1;
|
|
507
|
+
}
|
|
508
|
+
});
|
|
509
|
+
//#endregion
|
|
510
|
+
export { dialog_overlay_default as a, dialog_close_default as c, dialog_portal_default as i, resolveDialogCloseReason as l, dialog_title_default as n, dialog_description_default as o, dialog_root_default as r, dialog_content_default as s, dialog_trigger_default as t };
|