ropav 0.0.11 → 0.0.13

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 (126) hide show
  1. package/README.md +3 -0
  2. package/dist/checkbox.css +32 -32
  3. package/dist/checkbox.js +33 -14
  4. package/dist/color-input.css +19 -19
  5. package/dist/color-input.js +35 -17
  6. package/dist/components/checkbox/types.d.ts +5 -1
  7. package/dist/components/checkbox/useCheckbox.d.ts +1 -1
  8. package/dist/components/color-input/types.d.ts +4 -1
  9. package/dist/components/color-input/useColorInput.d.ts +1 -1
  10. package/dist/components/color-input/useColorInputValue.d.ts +1 -1
  11. package/dist/components/dialog/dialog-close.d.ts +21 -0
  12. package/dist/components/dialog/dialog-content.d.ts +32 -0
  13. package/dist/components/dialog/dialog-core.d.ts +27 -0
  14. package/dist/components/dialog/dialog-description.d.ts +21 -0
  15. package/dist/components/dialog/dialog-overlay.d.ts +21 -0
  16. package/dist/components/dialog/dialog-portal.d.ts +21 -0
  17. package/dist/components/dialog/dialog-root.d.ts +28 -0
  18. package/dist/components/dialog/dialog-title.d.ts +21 -0
  19. package/dist/components/dialog/dialog-trigger.d.ts +23 -0
  20. package/dist/components/dialog/index.d.ts +9 -0
  21. package/dist/components/dialog/index.js +2 -0
  22. package/dist/components/dialog/types.d.ts +61 -0
  23. package/dist/components/dropdown-menu/dropdown-menu-checkbox-item.d.ts +24 -0
  24. package/dist/components/dropdown-menu/dropdown-menu-content.d.ts +34 -0
  25. package/dist/components/dropdown-menu/dropdown-menu-context-trigger.d.ts +23 -0
  26. package/dist/components/dropdown-menu/dropdown-menu-item-indicator.d.ts +24 -0
  27. package/dist/components/dropdown-menu/dropdown-menu-item-row.d.ts +28 -0
  28. package/dist/components/dropdown-menu/dropdown-menu-item.d.ts +23 -0
  29. package/dist/components/dropdown-menu/dropdown-menu-items.d.ts +24 -22
  30. package/dist/components/dropdown-menu/dropdown-menu-label.d.ts +21 -0
  31. package/dist/components/dropdown-menu/dropdown-menu-outside.d.ts +3 -0
  32. package/dist/components/dropdown-menu/dropdown-menu-portal.d.ts +21 -0
  33. package/dist/components/dropdown-menu/dropdown-menu-primitive-core.d.ts +110 -0
  34. package/dist/components/dropdown-menu/dropdown-menu-primitives.d.ts +15 -724
  35. package/dist/components/dropdown-menu/dropdown-menu-radio-group.d.ts +25 -0
  36. package/dist/components/dropdown-menu/dropdown-menu-radio-item.d.ts +23 -0
  37. package/dist/components/dropdown-menu/dropdown-menu-root.d.ts +30 -0
  38. package/dist/components/dropdown-menu/dropdown-menu-separator.d.ts +19 -0
  39. package/dist/components/dropdown-menu/dropdown-menu-sub-content.d.ts +34 -0
  40. package/dist/components/dropdown-menu/dropdown-menu-sub-trigger.d.ts +28 -0
  41. package/dist/components/dropdown-menu/dropdown-menu-sub.d.ts +28 -0
  42. package/dist/components/dropdown-menu/dropdown-menu-trigger.d.ts +23 -0
  43. package/dist/components/dropdown-menu/dropdown-menu.d.ts +5 -2
  44. package/dist/components/dropdown-menu/index.d.ts +28 -49
  45. package/dist/components/dropdown-menu/index.js +2 -2
  46. package/dist/components/dropdown-menu/types.d.ts +8 -3
  47. package/dist/components/dropdown-menu/useDropdownMenu.d.ts +8 -4
  48. package/dist/components/dropdown-menu/useDropdownMenuDisclosure.d.ts +7 -2
  49. package/dist/components/dropdown-menu/useDropdownMenuPortalPosition.d.ts +3 -3
  50. package/dist/components/dropdown-menu/useDropdownMenuPrimitiveContent.d.ts +27 -0
  51. package/dist/components/dropdown-menu/useDropdownMenuRenderItems.d.ts +2 -0
  52. package/dist/components/floating/index.d.ts +3 -1
  53. package/dist/components/floating/index.js +3 -0
  54. package/dist/components/floating/types.d.ts +86 -1
  55. package/dist/components/floating/useFloatingPosition.d.ts +3 -26
  56. package/dist/components/floating/useHoverDisclosure.d.ts +2 -0
  57. package/dist/components/input/input.d.ts +4 -1
  58. package/dist/components/input/types.d.ts +3 -1
  59. package/dist/components/modal/index.d.ts +1 -1
  60. package/dist/components/modal/modal.d.ts +3 -1
  61. package/dist/components/modal/types.d.ts +3 -0
  62. package/dist/components/modal/useModal.d.ts +7 -4
  63. package/dist/components/number-input/types.d.ts +3 -1
  64. package/dist/components/number-input/useNumberInput.d.ts +2 -1
  65. package/dist/components/popover/usePopover.d.ts +2 -2
  66. package/dist/components/radio/types.d.ts +17 -1
  67. package/dist/components/radio/useRadio.d.ts +3 -0
  68. package/dist/components/select/select.d.ts +4 -1
  69. package/dist/components/select/types.d.ts +6 -1
  70. package/dist/components/select/useSelect.d.ts +3 -2
  71. package/dist/components/slider/index.d.ts +1 -1
  72. package/dist/components/slider/range-slider.d.ts +3 -3
  73. package/dist/components/slider/types.d.ts +11 -3
  74. package/dist/components/slider/useRangeSlider.d.ts +1 -1
  75. package/dist/components/slider/useSlider.d.ts +1 -1
  76. package/dist/components/switch/types.d.ts +5 -1
  77. package/dist/components/switch/useSwitch.d.ts +1 -1
  78. package/dist/components/teleport-provider/index.d.ts +1 -0
  79. package/dist/components/teleport-provider/index.js +2 -1
  80. package/dist/components/teleport-provider/useTeleportTarget.d.ts +4 -3
  81. package/dist/components/textarea/types.d.ts +4 -1
  82. package/dist/components/textarea/useTextarea.d.ts +1 -1
  83. package/dist/components/toast/index.d.ts +2 -1
  84. package/dist/components/toast/index.js +2 -2
  85. package/dist/components/toast/toast-store.d.ts +2 -0
  86. package/dist/components/toast/types.d.ts +10 -4
  87. package/dist/components/toast/useToast.d.ts +2 -2
  88. package/dist/components/tooltip/useTooltip.d.ts +3 -3
  89. package/dist/composables/useOverlayLayer.d.ts +32 -0
  90. package/dist/dialog.js +510 -0
  91. package/dist/dropdown-menu.css +4 -5
  92. package/dist/dropdown-menu.js +1155 -886
  93. package/dist/floating.js +403 -0
  94. package/dist/index.d.ts +1 -0
  95. package/dist/index.js +7 -4
  96. package/dist/input.css +24 -24
  97. package/dist/input.js +21 -11
  98. package/dist/legacy-unlayered.css +424 -503
  99. package/dist/modal.css +28 -28
  100. package/dist/modal.js +141 -200
  101. package/dist/number-input.css +20 -20
  102. package/dist/number-input.js +44 -16
  103. package/dist/popover.css +4 -4
  104. package/dist/popover.js +29 -40
  105. package/dist/radio.css +18 -18
  106. package/dist/radio.js +96 -18
  107. package/dist/select.css +54 -43
  108. package/dist/select.js +185 -67
  109. package/dist/slider.css +183 -202
  110. package/dist/slider.js +138 -37
  111. package/dist/switch.css +17 -17
  112. package/dist/switch.js +31 -13
  113. package/dist/textarea.css +26 -26
  114. package/dist/textarea.js +19 -9
  115. package/dist/toast.js +110 -99
  116. package/dist/tooltip.css +5 -80
  117. package/dist/tooltip.js +11 -3
  118. package/dist/useControlState.js +4 -0
  119. package/dist/useFloatingPosition.js +86 -39
  120. package/dist/useFormControl.js +107 -0
  121. package/dist/useOverlayLayer.js +262 -0
  122. package/dist/useTeleportTarget.js +21 -10
  123. package/docs/public-floating-api.md +159 -0
  124. package/docs/public-styles-api.md +2 -1
  125. package/package.json +10 -6
  126. 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 };
@@ -1,15 +1,14 @@
1
1
  @layer ropav.components {
2
2
  .rp-dropdown-menu {
3
- --_rp-dropdown-menu-radius: var(--rp-radius-sm);
4
- --_rp-dropdown-menu-focused-bg: var(--rp-color-default-hover);
5
- --_rp-dropdown-menu-arrow-size: 0.5rem;
6
3
  position: relative;
7
4
  display: inline-flex;
8
5
  font-family: var(--rp-font-family);
9
6
  vertical-align: middle;
10
7
  }
11
- html.dark .rp-dropdown-menu, [data-rp-color-scheme=dark] .rp-dropdown-menu {
12
- --_rp-dropdown-menu-focused-bg: var(--rp-color-disabled);
8
+ .rp-dropdown-menu__content, .rp-dropdown-menu__submenu {
9
+ --_rp-dropdown-menu-radius: var(--rp-radius-sm);
10
+ --_rp-dropdown-menu-focused-bg: var(--rp-color-default-hover);
11
+ --_rp-dropdown-menu-arrow-size: 0.5rem;
13
12
  }
14
13
  .rp-dropdown-menu--disabled {
15
14
  opacity: var(--rp-opacity-disabled);