ropav 0.0.8 → 0.0.10

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 (232) hide show
  1. package/dist/accordion.css +10 -10
  2. package/dist/accordion.js +2 -2
  3. package/dist/alert.css +109 -0
  4. package/dist/alert.js +168 -0
  5. package/dist/aspect-ratio.css +17 -0
  6. package/dist/aspect-ratio.js +26 -0
  7. package/dist/avatar.css +97 -0
  8. package/dist/avatar.js +161 -0
  9. package/dist/badge.css +40 -115
  10. package/dist/badge.js +19 -16
  11. package/dist/base.css +609 -180
  12. package/dist/button-link.css +161 -0
  13. package/dist/button-link.js +108 -0
  14. package/dist/button.css +50 -229
  15. package/dist/button.js +7 -9
  16. package/dist/card.css +12 -12
  17. package/dist/check.js +12 -0
  18. package/dist/checkbox.css +16 -57
  19. package/dist/checkbox.js +14 -31
  20. package/dist/collapse.css +2 -2
  21. package/dist/collapse.js +1 -1
  22. package/dist/color-input.css +108 -0
  23. package/dist/color-input.js +349 -0
  24. package/dist/color-picker.css +304 -0
  25. package/dist/color-picker.js +797 -0
  26. package/dist/color-picker2.js +18 -0
  27. package/dist/color-swatch.css +50 -0
  28. package/dist/color-swatch.js +73 -0
  29. package/dist/color.js +190 -0
  30. package/dist/componentColors.js +206 -13
  31. package/dist/components/accordion/accordion-item.d.ts +4 -4
  32. package/dist/components/accordion/accordion.d.ts +1 -1
  33. package/dist/components/accordion/index.d.ts +4 -4
  34. package/dist/components/accordion/types.d.ts +1 -1
  35. package/dist/components/accordion/useAccordion.d.ts +1 -1
  36. package/dist/components/alert/alert.d.ts +30 -0
  37. package/dist/components/alert/index.d.ts +3 -0
  38. package/dist/components/alert/index.js +2 -0
  39. package/dist/components/alert/types.d.ts +20 -0
  40. package/dist/components/alert/useAlertColor.d.ts +3 -0
  41. package/dist/components/aspect-ratio/aspect-ratio.d.ts +21 -0
  42. package/dist/components/aspect-ratio/index.d.ts +2 -0
  43. package/dist/components/aspect-ratio/index.js +2 -0
  44. package/dist/components/aspect-ratio/types.d.ts +3 -0
  45. package/dist/components/avatar/avatar.d.ts +24 -0
  46. package/dist/components/avatar/index.d.ts +3 -0
  47. package/dist/components/avatar/index.js +2 -0
  48. package/dist/components/avatar/types.d.ts +20 -0
  49. package/dist/components/avatar/useAvatarColor.d.ts +3 -0
  50. package/dist/components/badge/badge.d.ts +1 -1
  51. package/dist/components/badge/index.d.ts +3 -3
  52. package/dist/components/badge/types.d.ts +3 -2
  53. package/dist/components/badge/useBadgeColor.d.ts +3 -8
  54. package/dist/components/button/button.d.ts +1 -1
  55. package/dist/components/button/index.d.ts +2 -2
  56. package/dist/components/button/types.d.ts +2 -1
  57. package/dist/components/button/useButtonColor.d.ts +3 -13
  58. package/dist/components/button-group/button-group.d.ts +1 -1
  59. package/dist/components/button-group/index.d.ts +2 -2
  60. package/dist/components/button-link/button-link.d.ts +27 -0
  61. package/dist/components/button-link/index.d.ts +2 -0
  62. package/dist/components/button-link/index.js +2 -0
  63. package/dist/components/button-link/types.d.ts +20 -0
  64. package/dist/components/card/card.d.ts +1 -1
  65. package/dist/components/card/index.d.ts +2 -2
  66. package/dist/components/checkbox/checkbox.d.ts +1 -1
  67. package/dist/components/checkbox/index.d.ts +2 -2
  68. package/dist/components/checkbox/types.d.ts +2 -1
  69. package/dist/components/checkbox/useCheckbox.d.ts +4 -6
  70. package/dist/components/collapse/collapse.d.ts +2 -2
  71. package/dist/components/collapse/index.d.ts +3 -3
  72. package/dist/components/collapse/useCollapse.d.ts +1 -1
  73. package/dist/components/color-input/color-input.d.ts +29 -0
  74. package/dist/components/color-input/index.d.ts +2 -0
  75. package/dist/components/color-input/index.js +2 -0
  76. package/dist/components/color-input/types.d.ts +35 -0
  77. package/dist/components/color-input/useColorInput.d.ts +27 -0
  78. package/dist/components/color-input/useColorInputEyeDropper.d.ts +13 -0
  79. package/dist/components/color-input/useColorInputPopover.d.ts +11 -0
  80. package/dist/components/color-input/useColorInputValue.d.ts +8 -0
  81. package/dist/components/color-picker/color-picker-saturation.d.ts +21 -0
  82. package/dist/components/color-picker/color-picker-slider.d.ts +21 -0
  83. package/dist/components/color-picker/color-picker-utils.d.ts +23 -0
  84. package/dist/components/color-picker/color-picker.d.ts +23 -0
  85. package/dist/components/color-picker/index.d.ts +3 -0
  86. package/dist/components/color-picker/index.js +3 -0
  87. package/dist/components/color-picker/types.d.ts +39 -0
  88. package/dist/components/color-picker/useColorPickerDrag.d.ts +16 -0
  89. package/dist/components/color-picker/useColorPickerSwatches.d.ts +21 -0
  90. package/dist/components/color-picker/useColorPickerValue.d.ts +15 -0
  91. package/dist/components/color-swatch/color-swatch.d.ts +21 -0
  92. package/dist/components/color-swatch/index.d.ts +2 -0
  93. package/dist/components/color-swatch/index.js +2 -0
  94. package/dist/components/color-swatch/types.d.ts +6 -0
  95. package/dist/components/color-swatch/useColorSwatchColor.d.ts +5 -0
  96. package/dist/components/dropdown-menu/dropdown-menu-items.d.ts +15 -6
  97. package/dist/components/dropdown-menu/dropdown-menu-utils.d.ts +1 -1
  98. package/dist/components/dropdown-menu/dropdown-menu.d.ts +3 -3
  99. package/dist/components/dropdown-menu/index.d.ts +3 -3
  100. package/dist/components/dropdown-menu/useDropdownMenu.d.ts +11 -10
  101. package/dist/components/dropdown-menu/useDropdownMenuDisclosure.d.ts +2 -2
  102. package/dist/components/dropdown-menu/useDropdownMenuDom.d.ts +2 -2
  103. package/dist/components/dropdown-menu/useDropdownMenuHoverIntent.d.ts +2 -2
  104. package/dist/components/dropdown-menu/useDropdownMenuInteractions.d.ts +2 -2
  105. package/dist/components/dropdown-menu/useDropdownMenuNavigation.d.ts +3 -3
  106. package/dist/components/dropdown-menu/useDropdownMenuRenderItems.d.ts +12 -4
  107. package/dist/components/dropdown-menu/useDropdownSubmenus.d.ts +3 -3
  108. package/dist/components/field/field.d.ts +2 -2
  109. package/dist/components/field/index.d.ts +2 -2
  110. package/dist/components/field/types.d.ts +0 -2
  111. package/dist/components/field/useField.d.ts +1 -3
  112. package/dist/components/icon-button/icon-button.d.ts +1 -1
  113. package/dist/components/icon-button/index.d.ts +2 -2
  114. package/dist/components/icon-button/types.d.ts +2 -1
  115. package/dist/components/input/index.d.ts +2 -2
  116. package/dist/components/input/input.d.ts +1 -1
  117. package/dist/components/input/types.d.ts +3 -0
  118. package/dist/components/input/useInput.d.ts +2 -2
  119. package/dist/components/modal/index.d.ts +2 -2
  120. package/dist/components/modal/modal.d.ts +1 -1
  121. package/dist/components/modal/types.d.ts +1 -1
  122. package/dist/components/modal/useModal.d.ts +1 -1
  123. package/dist/components/number-input/index.d.ts +2 -0
  124. package/dist/components/number-input/index.js +2 -0
  125. package/dist/components/number-input/number-input.d.ts +29 -0
  126. package/dist/components/number-input/types.d.ts +34 -0
  127. package/dist/components/number-input/useNumberInput.d.ts +31 -0
  128. package/dist/components/overlay/index.d.ts +2 -2
  129. package/dist/components/overlay/overlay.d.ts +1 -1
  130. package/dist/components/overlay/useOverlay.d.ts +1 -1
  131. package/dist/components/popover/index.d.ts +3 -2
  132. package/dist/components/popover/index.js +2 -1
  133. package/dist/components/popover/popover.d.ts +2 -2
  134. package/dist/components/popover/types.d.ts +3 -1
  135. package/dist/components/popover/usePopover.d.ts +2 -1
  136. package/dist/components/progress/index.d.ts +3 -3
  137. package/dist/components/progress/progress.d.ts +1 -1
  138. package/dist/components/progress/types.d.ts +2 -2
  139. package/dist/components/progress/useProgress.d.ts +2 -2
  140. package/dist/components/radio/index.d.ts +3 -3
  141. package/dist/components/radio/radio-group.d.ts +1 -1
  142. package/dist/components/radio/radio.d.ts +1 -1
  143. package/dist/components/radio/types.d.ts +4 -1
  144. package/dist/components/radio/useRadio.d.ts +4 -6
  145. package/dist/components/select/index.d.ts +2 -2
  146. package/dist/components/select/select.d.ts +1 -1
  147. package/dist/components/select/types.d.ts +3 -0
  148. package/dist/components/select/useSelect.d.ts +2 -2
  149. package/dist/components/slider/index.d.ts +4 -3
  150. package/dist/components/slider/index.js +2 -2
  151. package/dist/components/slider/range-slider-tooltip.d.ts +34 -0
  152. package/dist/components/slider/range-slider.d.ts +37 -0
  153. package/dist/components/slider/slider.d.ts +1 -1
  154. package/dist/components/slider/sliderCore.d.ts +35 -0
  155. package/dist/components/slider/types.d.ts +15 -6
  156. package/dist/components/slider/useRangeSlider.d.ts +57 -0
  157. package/dist/components/slider/useRangeSliderPointer.d.ts +19 -0
  158. package/dist/components/slider/useRangeSliderTooltipCollision.d.ts +36 -0
  159. package/dist/components/slider/useRangeSliderTooltipState.d.ts +23 -0
  160. package/dist/components/slider/useSlider.d.ts +11 -15
  161. package/dist/components/switch/index.d.ts +2 -2
  162. package/dist/components/switch/switch.d.ts +1 -1
  163. package/dist/components/switch/types.d.ts +1 -1
  164. package/dist/components/switch/useSwitch.d.ts +4 -5
  165. package/dist/components/tabs/index.d.ts +6 -6
  166. package/dist/components/tabs/tabs-content.d.ts +2 -2
  167. package/dist/components/tabs/tabs-list.d.ts +4 -4
  168. package/dist/components/tabs/tabs-trigger.d.ts +5 -5
  169. package/dist/components/tabs/tabs.d.ts +5 -5
  170. package/dist/components/tabs/useTabs.d.ts +1 -1
  171. package/dist/components/textarea/index.d.ts +2 -2
  172. package/dist/components/textarea/textarea.d.ts +1 -1
  173. package/dist/components/textarea/useTextarea.d.ts +2 -2
  174. package/dist/components/toast/defaults.d.ts +7 -0
  175. package/dist/components/toast/index.d.ts +7 -0
  176. package/dist/components/toast/index.js +2 -0
  177. package/dist/components/toast/toast-provider.d.ts +21 -0
  178. package/dist/components/toast/toast-viewport.d.ts +34 -0
  179. package/dist/components/toast/toast.d.ts +31 -0
  180. package/dist/components/toast/types.d.ts +106 -0
  181. package/dist/components/toast/useToast.d.ts +4 -0
  182. package/dist/components/toast/useToastColor.d.ts +3 -0
  183. package/dist/components/toast/useToastState.d.ts +2 -0
  184. package/dist/components/tooltip/index.d.ts +2 -2
  185. package/dist/components/tooltip/tooltip.d.ts +2 -2
  186. package/dist/components/tooltip/types.d.ts +2 -1
  187. package/dist/components/tooltip/useTooltip.d.ts +3 -1
  188. package/dist/dropdown-menu.css +17 -17
  189. package/dist/dropdown-menu.js +160 -39
  190. package/dist/field.css +15 -18
  191. package/dist/field.js +17 -35
  192. package/dist/icon-button.css +57 -236
  193. package/dist/icon-button.js +5 -6
  194. package/dist/index.d.ts +31 -22
  195. package/dist/index.js +17 -4
  196. package/dist/input.css +40 -46
  197. package/dist/input.js +39 -21
  198. package/dist/minus.js +12 -0
  199. package/dist/modal.css +9 -9
  200. package/dist/modal.js +1 -1
  201. package/dist/number-input.css +86 -0
  202. package/dist/number-input.js +350 -0
  203. package/dist/overlay.css +5 -5
  204. package/dist/overlay.js +3 -3
  205. package/dist/popover.css +62 -29
  206. package/dist/popover.js +33 -19
  207. package/dist/popover2.js +17 -0
  208. package/dist/progress.css +9 -30
  209. package/dist/progress.js +3 -6
  210. package/dist/radio.css +34 -62
  211. package/dist/radio.js +28 -16
  212. package/dist/rafScheduler.js +34 -0
  213. package/dist/select.css +105 -61
  214. package/dist/select.js +12 -8
  215. package/dist/slider.css +719 -125
  216. package/dist/slider.js +1251 -149
  217. package/dist/switch.css +19 -44
  218. package/dist/switch.js +4 -5
  219. package/dist/tabs.css +36 -36
  220. package/dist/tabs.js +1 -1
  221. package/dist/textarea.css +33 -25
  222. package/dist/textarea.js +8 -2
  223. package/dist/toast.css +232 -0
  224. package/dist/toast.js +679 -0
  225. package/dist/tooltip.css +7 -35
  226. package/dist/tooltip.js +30 -18
  227. package/dist/useButtonColor.js +16 -14
  228. package/dist/utils/componentColors.d.ts +60 -0
  229. package/package.json +55 -15
  230. package/src/styles/_mixins.scss +25 -41
  231. package/src/styles/_tokens.scss +615 -182
  232. package/src/styles/_variables.scss +177 -49
package/dist/toast.js ADDED
@@ -0,0 +1,679 @@
1
+ import './toast.css';
2
+ import { t as x_default } from "./x.js";
3
+ import { t as bem } from "./bem.js";
4
+ import { i as getComponentVariantColorRoles, t as componentColors } from "./componentColors.js";
5
+ import { t as _plugin_vue_export_helper_default } from "./_plugin-vue_export-helper.js";
6
+ import { VaporTeleport, VaporTransition, VaporTransitionGroup, computed, createComponent, createFor, createIf, createInvoker, createSlot, defineVaporComponent, delegateEvents, extend, inject, nextTick, on, onBeforeUnmount, onMounted, provide, ref, renderEffect, setAttr, setClass, setInsertionState, setProp, setStyle, setText, template, toDisplayString, toValue, txt, unref, useId, useSlots, watch } from "vue";
7
+ //#region src/components/toast/defaults.ts
8
+ var DEFAULT_TOAST_DURATION = 5e3;
9
+ var DEFAULT_TOAST_ROLE = "status";
10
+ var DEFAULT_TOAST_CLOSE_LABEL = "Close toast";
11
+ //#endregion
12
+ //#region src/components/toast/useToastColor.ts
13
+ function getToastColorStyle(color, variant, autoContrast) {
14
+ if (!color && !variant) return void 0;
15
+ const resolvedVariant = variant ?? "surface";
16
+ const roles = getComponentVariantColorRoles({
17
+ color,
18
+ variant: resolvedVariant,
19
+ defaultColor: "cyan",
20
+ autoContrast
21
+ });
22
+ if (!roles) return void 0;
23
+ return {
24
+ "--_rp-toast-bg": roles.background,
25
+ "--_rp-toast-fg": resolvedVariant === "solid" ? roles.color : "var(--rp-color-text)",
26
+ "--_rp-toast-title-fg": resolvedVariant === "solid" ? roles.color : "var(--rp-color-text)",
27
+ "--_rp-toast-icon-fg": roles.color,
28
+ "--_rp-toast-border": roles.border
29
+ };
30
+ }
31
+ //#endregion
32
+ //#region src/components/toast/toast.vue?vue&type=script&setup=true&vapor=true&lang.ts
33
+ var t0$1 = template("<div data-v-face18fc class=rp-toast__icon aria-hidden=true>");
34
+ var t1 = template(" ");
35
+ var t2 = template("<div data-v-face18fc class=rp-toast__title>");
36
+ var t3 = template("<p data-v-face18fc class=rp-toast__description> ");
37
+ var t4 = template("<div data-v-face18fc class=rp-toast__body>");
38
+ var t5 = template("<div data-v-face18fc class=rp-toast__content>");
39
+ var t6 = template("<div data-v-face18fc class=rp-toast__action>");
40
+ var t7 = template("<button data-v-face18fc class=rp-toast__close type=button>");
41
+ var t8 = template("<div data-v-face18fc>");
42
+ delegateEvents("click", "focusin", "focusout");
43
+ //#endregion
44
+ //#region src/components/toast/toast.vue
45
+ var toast_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__ */ defineVaporComponent({
46
+ name: "RpToast",
47
+ __name: "toast",
48
+ props: {
49
+ open: {
50
+ type: Boolean,
51
+ default: void 0
52
+ },
53
+ title: { default: "" },
54
+ description: { default: "" },
55
+ variant: {},
56
+ color: {},
57
+ autoContrast: { type: Boolean },
58
+ radius: {},
59
+ role: { default: DEFAULT_TOAST_ROLE },
60
+ duration: { default: DEFAULT_TOAST_DURATION },
61
+ pauseOnHover: {
62
+ type: Boolean,
63
+ default: true
64
+ },
65
+ pauseOnFocus: {
66
+ type: Boolean,
67
+ default: true
68
+ },
69
+ closable: {
70
+ type: Boolean,
71
+ default: true
72
+ },
73
+ closeLabel: { default: DEFAULT_TOAST_CLOSE_LABEL }
74
+ },
75
+ emits: [
76
+ "update:open",
77
+ "close",
78
+ "after-leave"
79
+ ],
80
+ setup(__props, { emit: __emit, slots: $slots }) {
81
+ const props = __props;
82
+ const emit = __emit;
83
+ const slots = useSlots();
84
+ const localOpen = ref(props.open ?? true);
85
+ const isMounted = ref(false);
86
+ const pausedByHover = ref(false);
87
+ const pausedByFocus = ref(false);
88
+ let closePending = false;
89
+ let timer;
90
+ let timerStartedAt = 0;
91
+ let remainingDuration = 0;
92
+ watch(() => props.open, (open) => {
93
+ if (open !== void 0) localOpen.value = open;
94
+ if (open) closePending = false;
95
+ });
96
+ watch(() => props.pauseOnHover, (pauseOnHover) => {
97
+ if (pauseOnHover || !pausedByHover.value) return;
98
+ pausedByHover.value = false;
99
+ resumeTimer();
100
+ });
101
+ watch(() => props.pauseOnFocus, (pauseOnFocus) => {
102
+ if (pauseOnFocus || !pausedByFocus.value) return;
103
+ pausedByFocus.value = false;
104
+ resumeTimer();
105
+ });
106
+ const isOpen = computed(() => props.open ?? localOpen.value);
107
+ const hasTitle = computed(() => Boolean(props.title || slots.title));
108
+ const hasDescription = computed(() => Boolean(props.description));
109
+ const hasContent = computed(() => Boolean(hasTitle.value || hasDescription.value || slots.default));
110
+ const resolvedRole = computed(() => props.role === "none" ? void 0 : props.role);
111
+ const hasIcon = computed(() => Boolean(slots.icon));
112
+ const rootClass = computed(() => bem("rp-toast", {
113
+ [props.variant ?? ""]: Boolean(props.variant),
114
+ [`radius-${props.radius}`]: Boolean(props.radius)
115
+ }));
116
+ const rootStyle = computed(() => getToastColorStyle(props.color, props.variant, props.autoContrast));
117
+ watch([isOpen, () => props.duration], ([open], [wasOpen]) => {
118
+ if (!isMounted.value) return;
119
+ if (!open || !wasOpen) {
120
+ pausedByHover.value = false;
121
+ pausedByFocus.value = false;
122
+ }
123
+ resetTimer();
124
+ });
125
+ onMounted(() => {
126
+ isMounted.value = true;
127
+ resetTimer();
128
+ });
129
+ onBeforeUnmount(clearTimer);
130
+ function getDuration() {
131
+ return Number.isFinite(props.duration) && props.duration > 0 ? props.duration : 0;
132
+ }
133
+ function resetTimer() {
134
+ clearTimer();
135
+ remainingDuration = getDuration();
136
+ scheduleTimer();
137
+ }
138
+ function scheduleTimer() {
139
+ if (!isOpen.value || remainingDuration <= 0 || pausedByHover.value || pausedByFocus.value) return;
140
+ timerStartedAt = Date.now();
141
+ timer = setTimeout(() => {
142
+ timer = void 0;
143
+ remainingDuration = 0;
144
+ closeToast("timeout");
145
+ }, remainingDuration);
146
+ }
147
+ function clearTimer() {
148
+ if (timer === void 0) return;
149
+ clearTimeout(timer);
150
+ timer = void 0;
151
+ }
152
+ function pauseTimer() {
153
+ if (timer === void 0) return;
154
+ remainingDuration = Math.max(0, remainingDuration - (Date.now() - timerStartedAt));
155
+ clearTimer();
156
+ if (remainingDuration === 0) closeToast("timeout");
157
+ }
158
+ function resumeTimer() {
159
+ if (pausedByHover.value || pausedByFocus.value) return;
160
+ scheduleTimer();
161
+ }
162
+ function onMouseenter() {
163
+ if (!props.pauseOnHover) return;
164
+ pausedByHover.value = true;
165
+ pauseTimer();
166
+ }
167
+ function onMouseleave() {
168
+ if (!props.pauseOnHover) return;
169
+ pausedByHover.value = false;
170
+ resumeTimer();
171
+ }
172
+ function onFocusin() {
173
+ if (!props.pauseOnFocus) return;
174
+ pausedByFocus.value = true;
175
+ pauseTimer();
176
+ }
177
+ function onFocusout(event) {
178
+ if (!props.pauseOnFocus) return;
179
+ const currentTarget = event.currentTarget;
180
+ if (currentTarget instanceof HTMLElement && event.relatedTarget instanceof Node && currentTarget.contains(event.relatedTarget)) return;
181
+ pausedByFocus.value = false;
182
+ resumeTimer();
183
+ }
184
+ function closeToast(reason) {
185
+ if (closePending) return;
186
+ closePending = true;
187
+ clearTimer();
188
+ localOpen.value = false;
189
+ emit("update:open", false);
190
+ emit("close", reason);
191
+ if (isOpen.value) {
192
+ resetTimer();
193
+ nextTick(() => {
194
+ if (isOpen.value) closePending = false;
195
+ });
196
+ }
197
+ }
198
+ const _on_after_leave = () => emit("after-leave");
199
+ return createComponent(VaporTransition, {
200
+ name: "rp-toast",
201
+ onAfterLeave: () => _on_after_leave
202
+ }, extend(() => {
203
+ return createIf(() => isOpen.value, () => {
204
+ const n30 = t8();
205
+ renderEffect(() => {
206
+ setClass(n30, rootClass.value);
207
+ setStyle(n30, rootStyle.value);
208
+ setProp(n30, "role", resolvedRole.value);
209
+ });
210
+ setInsertionState(n30, null, 0);
211
+ createIf(() => hasIcon.value, () => {
212
+ const n5 = t0$1();
213
+ setInsertionState(n5, null, 0);
214
+ createSlot("icon", null, null, 1);
215
+ return n5;
216
+ });
217
+ setInsertionState(n30, null, 1);
218
+ createIf(() => hasContent.value, () => {
219
+ const n21 = t5();
220
+ setInsertionState(n21, null, 0);
221
+ createIf(() => hasTitle.value, () => {
222
+ const n13 = t2();
223
+ setInsertionState(n13, null, 0);
224
+ createSlot("title", null, () => {
225
+ const n12 = t1();
226
+ renderEffect(() => setText(n12, toDisplayString(__props.title)));
227
+ return n12;
228
+ }, 1);
229
+ return n13;
230
+ });
231
+ setInsertionState(n21, null, 1);
232
+ createIf(() => hasDescription.value, () => {
233
+ const n16 = t3();
234
+ const x16 = txt(n16);
235
+ renderEffect(() => setText(x16, toDisplayString(__props.description)));
236
+ return n16;
237
+ });
238
+ setInsertionState(n21, null, 2);
239
+ createIf(() => $slots.default, () => {
240
+ const n20 = t4();
241
+ setInsertionState(n20, null, 0);
242
+ createSlot("default", null, null, 1);
243
+ return n20;
244
+ });
245
+ return n21;
246
+ });
247
+ setInsertionState(n30, null, 2);
248
+ createIf(() => $slots.action, () => {
249
+ const n25 = t6();
250
+ setInsertionState(n25, null, 0);
251
+ createSlot("action", null, null, 1);
252
+ return n25;
253
+ });
254
+ setInsertionState(n30, null, 3);
255
+ createIf(() => __props.closable, () => {
256
+ const n29 = t7();
257
+ renderEffect(() => setAttr(n29, "aria-label", __props.closeLabel));
258
+ setInsertionState(n29, null, 0);
259
+ createComponent(unref(x_default), { "aria-hidden": "true" });
260
+ n29.$evtclick = createInvoker(() => closeToast("dismiss"));
261
+ return n29;
262
+ });
263
+ on(n30, "mouseenter", onMouseenter);
264
+ on(n30, "mouseleave", onMouseleave);
265
+ n30.$evtfocusin = createInvoker(onFocusin);
266
+ n30.$evtfocusout = createInvoker(onFocusout);
267
+ return n30;
268
+ }, null, 129);
269
+ }, { _: 8 }), true);
270
+ }
271
+ }), [["__scopeId", "data-v-face18fc"]]);
272
+ //#endregion
273
+ //#region src/components/toast/types.ts
274
+ var toastColors = componentColors;
275
+ var toastVariants = [
276
+ "subtle",
277
+ "surface",
278
+ "outline",
279
+ "solid"
280
+ ];
281
+ var toastRadiuses = [
282
+ "none",
283
+ "xs",
284
+ "sm",
285
+ "md",
286
+ "lg",
287
+ "xl"
288
+ ];
289
+ var toastPositions = [
290
+ "top-left",
291
+ "top-center",
292
+ "top-right",
293
+ "bottom-left",
294
+ "bottom-center",
295
+ "bottom-right"
296
+ ];
297
+ var toastTypes = [
298
+ "default",
299
+ "success",
300
+ "error",
301
+ "warning",
302
+ "info"
303
+ ];
304
+ var toastProviderKey = Symbol("toast-provider");
305
+ //#endregion
306
+ //#region src/components/toast/useToast.ts
307
+ var TYPE_DEFAULTS = {
308
+ default: {},
309
+ success: { color: "green" },
310
+ error: {
311
+ color: "red",
312
+ role: "alert"
313
+ },
314
+ warning: {
315
+ color: "yellow",
316
+ role: "alert"
317
+ },
318
+ info: { color: "blue" }
319
+ };
320
+ function withoutUndefined(value) {
321
+ return Object.fromEntries(Object.entries(value).filter(([, entry]) => entry !== void 0));
322
+ }
323
+ function normalizeMax(max) {
324
+ if (max === Infinity) return Infinity;
325
+ if (!Number.isFinite(max)) return 5;
326
+ return Math.max(1, Math.floor(max ?? 5));
327
+ }
328
+ function normalizeInput(input, options) {
329
+ return {
330
+ ...typeof input === "string" ? { title: input } : input,
331
+ ...options
332
+ };
333
+ }
334
+ function splitOptions(options) {
335
+ const { id, type, onClose, ...toastProps } = options;
336
+ return {
337
+ id,
338
+ type,
339
+ onClose,
340
+ toastProps: withoutUndefined(toastProps)
341
+ };
342
+ }
343
+ function getProviderDefaults(props) {
344
+ return withoutUndefined({
345
+ duration: props.duration ?? 5e3,
346
+ variant: props.variant,
347
+ color: props.color,
348
+ autoContrast: props.autoContrast,
349
+ radius: props.radius,
350
+ role: props.role,
351
+ pauseOnHover: props.pauseOnHover ?? true,
352
+ pauseOnFocus: props.pauseOnFocus ?? true,
353
+ closable: props.closable ?? true,
354
+ closeLabel: props.closeLabel ?? "Close toast"
355
+ });
356
+ }
357
+ function replaceAt(items, index, value) {
358
+ const nextItems = items.slice();
359
+ nextItems[index] = value;
360
+ return nextItems;
361
+ }
362
+ function notify(item, reason) {
363
+ item.onClose?.(reason);
364
+ }
365
+ function partitionOverflow(items, max) {
366
+ if (max === Infinity || items.length <= max) return {
367
+ kept: items,
368
+ evicted: []
369
+ };
370
+ const overflow = items.length - max;
371
+ return {
372
+ kept: items.slice(overflow),
373
+ evicted: items.slice(0, overflow)
374
+ };
375
+ }
376
+ function provideToast(props) {
377
+ const scopeId = useId();
378
+ const items = ref([]);
379
+ const toasts = computed(() => items.value);
380
+ const records = /* @__PURE__ */ new Map();
381
+ let sequence = 0;
382
+ function createInstanceId() {
383
+ sequence += 1;
384
+ return `${scopeId}-toast-${sequence}`;
385
+ }
386
+ function resolveItem(id, instanceId, record) {
387
+ return {
388
+ id,
389
+ instanceId,
390
+ type: record.type,
391
+ props: {
392
+ ...TYPE_DEFAULTS[record.type],
393
+ ...getProviderDefaults(props),
394
+ ...record.props
395
+ },
396
+ onClose: record.onClose
397
+ };
398
+ }
399
+ function forget(removedItems) {
400
+ for (const item of removedItems) records.delete(item.instanceId);
401
+ }
402
+ function notifyAll(removedItems, reason) {
403
+ for (const item of removedItems) notify(item, reason);
404
+ }
405
+ function create(type, input, options) {
406
+ const split = splitOptions(normalizeInput(input, options));
407
+ const instanceId = createInstanceId();
408
+ const id = split.id ?? instanceId;
409
+ const record = {
410
+ type: split.type ?? type,
411
+ props: split.toastProps,
412
+ onClose: split.onClose
413
+ };
414
+ const item = resolveItem(id, instanceId, record);
415
+ const replaced = items.value.filter((current) => current.id === id);
416
+ const { kept, evicted } = partitionOverflow([...items.value.filter((current) => current.id !== id), item], normalizeMax(props.max));
417
+ records.set(instanceId, record);
418
+ forget([...replaced, ...evicted]);
419
+ items.value = kept;
420
+ notifyAll([...replaced, ...evicted], "dismiss");
421
+ return id;
422
+ }
423
+ function show(input, options) {
424
+ return create("default", input, options);
425
+ }
426
+ function success(input, options) {
427
+ return create("success", input, options);
428
+ }
429
+ function error(input, options) {
430
+ return create("error", input, options);
431
+ }
432
+ function warning(input, options) {
433
+ return create("warning", input, options);
434
+ }
435
+ function info(input, options) {
436
+ return create("info", input, options);
437
+ }
438
+ function update(id, options) {
439
+ const index = items.value.findIndex((item) => item.id === id);
440
+ if (index === -1) return;
441
+ const current = items.value[index];
442
+ const record = records.get(current.instanceId);
443
+ if (!record) return;
444
+ const { type, onClose, ...toastProps } = options;
445
+ const nextRecord = {
446
+ type: type ?? record.type,
447
+ props: {
448
+ ...record.props,
449
+ ...withoutUndefined(toastProps)
450
+ },
451
+ onClose: Object.hasOwn(options, "onClose") ? onClose : record.onClose
452
+ };
453
+ records.set(current.instanceId, nextRecord);
454
+ items.value = replaceAt(items.value, index, resolveItem(current.id, current.instanceId, nextRecord));
455
+ }
456
+ function closeAt(index, reason) {
457
+ if (index === -1) return;
458
+ const current = items.value[index];
459
+ records.delete(current.instanceId);
460
+ items.value = items.value.filter((_, currentIndex) => currentIndex !== index);
461
+ notify(current, reason);
462
+ }
463
+ function dismiss(id, reason = "dismiss") {
464
+ closeAt(items.value.findIndex((item) => item.id === id), reason);
465
+ }
466
+ function dismissInstance(instanceId, reason = "dismiss") {
467
+ closeAt(items.value.findIndex((item) => item.instanceId === instanceId), reason);
468
+ }
469
+ function dismissAll(reason = "dismiss") {
470
+ const dismissed = items.value;
471
+ records.clear();
472
+ items.value = [];
473
+ notifyAll(dismissed, reason);
474
+ }
475
+ const context = {
476
+ toasts,
477
+ show,
478
+ success,
479
+ error,
480
+ warning,
481
+ info,
482
+ update,
483
+ dismiss,
484
+ dismissAll,
485
+ dismissInstance
486
+ };
487
+ provide(toastProviderKey, context);
488
+ watch(() => normalizeMax(props.max), (max) => {
489
+ const { kept, evicted } = partitionOverflow(items.value, max);
490
+ if (evicted.length === 0) return;
491
+ forget(evicted);
492
+ items.value = kept;
493
+ notifyAll(evicted, "dismiss");
494
+ }, { flush: "sync" });
495
+ return context;
496
+ }
497
+ function useToastContext(consumer) {
498
+ const context = inject(toastProviderKey);
499
+ if (!context) throw new Error(`[Ropav] ${consumer} must be used inside <ToastProvider>.`);
500
+ return context;
501
+ }
502
+ function useToast() {
503
+ return useToastContext("useToast()");
504
+ }
505
+ //#endregion
506
+ //#region src/components/toast/toast-provider.vue
507
+ var toast_provider_default = /* @__PURE__ */ defineVaporComponent({
508
+ name: "RpToastProvider",
509
+ __name: "toast-provider",
510
+ props: {
511
+ max: { default: 5 },
512
+ duration: { default: DEFAULT_TOAST_DURATION },
513
+ variant: { default: void 0 },
514
+ color: { default: void 0 },
515
+ autoContrast: {
516
+ type: Boolean,
517
+ default: void 0
518
+ },
519
+ radius: { default: void 0 },
520
+ role: { default: void 0 },
521
+ pauseOnHover: {
522
+ type: Boolean,
523
+ default: true
524
+ },
525
+ pauseOnFocus: {
526
+ type: Boolean,
527
+ default: true
528
+ },
529
+ closable: {
530
+ type: Boolean,
531
+ default: true
532
+ },
533
+ closeLabel: { default: DEFAULT_TOAST_CLOSE_LABEL }
534
+ },
535
+ setup(__props) {
536
+ provideToast(__props);
537
+ return createSlot();
538
+ }
539
+ });
540
+ //#endregion
541
+ //#region src/components/toast/toast-viewport.vue?vue&type=script&setup=true&vapor=true&lang.ts
542
+ var t0 = template("<li data-v-e4c0bb63 class=rp-toast-viewport__item>");
543
+ //#endregion
544
+ //#region src/components/toast/toast-viewport.vue
545
+ var toast_viewport_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__ */ defineVaporComponent({
546
+ name: "RpToastViewport",
547
+ __name: "toast-viewport",
548
+ props: {
549
+ position: { default: "top-right" },
550
+ label: { default: "Notifications" },
551
+ teleport: {
552
+ type: Boolean,
553
+ default: true
554
+ },
555
+ teleportTo: { default: "body" }
556
+ },
557
+ setup(__props, { slots: $slots }) {
558
+ const props = __props;
559
+ const context = useToastContext("<ToastViewport>");
560
+ function reverseToasts(toasts) {
561
+ return toasts.map((_, index) => toasts[toasts.length - index - 1]);
562
+ }
563
+ const orderedToasts = computed(() => props.position.startsWith("top") ? reverseToasts(context.toasts.value) : context.toasts.value);
564
+ function dismiss(toast) {
565
+ context.dismissInstance(toast.instanceId);
566
+ }
567
+ return createComponent(VaporTeleport, {
568
+ to: () => __props.teleportTo,
569
+ disabled: () => !__props.teleport
570
+ }, () => {
571
+ return createComponent(VaporTransitionGroup, {
572
+ tag: "ol",
573
+ name: "rp-toast-viewport-item",
574
+ class: () => [
575
+ "rp-toast-viewport",
576
+ `rp-toast-viewport--${__props.position}`,
577
+ { "rp-toast-viewport--empty": orderedToasts.value.length === 0 }
578
+ ],
579
+ "data-position": () => __props.position,
580
+ "aria-label": () => __props.label
581
+ }, extend(() => {
582
+ return createFor(() => orderedToasts.value, (_for_item0) => {
583
+ const n10 = t0();
584
+ setInsertionState(n10, null, 0);
585
+ createComponent(toast_default, { $: [() => _for_item0.value.props, {
586
+ open: true,
587
+ onClose: () => ($event) => unref(context).dismissInstance(_for_item0.value.instanceId, $event)
588
+ }] }, { $: [
589
+ () => $slots.icon ? {
590
+ name: "icon",
591
+ fn: () => {
592
+ return createSlot("icon", {
593
+ toast: () => _for_item0.value,
594
+ dismiss: () => (() => dismiss(_for_item0.value))
595
+ }, null, 1);
596
+ }
597
+ } : void 0,
598
+ () => $slots.action ? {
599
+ name: "action",
600
+ fn: () => {
601
+ return createSlot("action", {
602
+ toast: () => _for_item0.value,
603
+ dismiss: () => (() => dismiss(_for_item0.value))
604
+ }, null, 1);
605
+ }
606
+ } : void 0,
607
+ { "default": extend(() => {
608
+ return createIf(() => $slots.default, () => {
609
+ return createSlot("default", {
610
+ toast: () => _for_item0.value,
611
+ dismiss: () => (() => dismiss(_for_item0.value))
612
+ }, null, 1);
613
+ }, null, 129);
614
+ }, { _: 8 }) }
615
+ ] });
616
+ return n10;
617
+ }, (toast) => toast.instanceId, 40);
618
+ }, { _: 8 }));
619
+ }, true);
620
+ }
621
+ }), [["__scopeId", "data-v-e4c0bb63"]]);
622
+ //#endregion
623
+ //#region src/components/toast/useToastState.ts
624
+ function optionValue(value) {
625
+ return toValue(value);
626
+ }
627
+ function useToastState(options = {}) {
628
+ const uncontrolledOpen = ref(options.defaultOpen ?? false);
629
+ const closeReason = ref(null);
630
+ const controlledOpen = computed(() => optionValue(options.open));
631
+ const isOpen = computed(() => controlledOpen.value ?? uncontrolledOpen.value);
632
+ const lastCloseReason = computed(() => closeReason.value);
633
+ watch(controlledOpen, (nextOpen) => {
634
+ if (nextOpen === void 0) return;
635
+ uncontrolledOpen.value = nextOpen;
636
+ if (nextOpen) closeReason.value = null;
637
+ }, {
638
+ flush: "sync",
639
+ immediate: true
640
+ });
641
+ const toastProps = computed(() => ({
642
+ open: isOpen.value,
643
+ "onUpdate:open": setOpen,
644
+ onClose: handleToastClose
645
+ }));
646
+ function setOpen(nextOpen) {
647
+ if (nextOpen === isOpen.value) return;
648
+ if (controlledOpen.value === void 0) uncontrolledOpen.value = nextOpen;
649
+ if (nextOpen) closeReason.value = null;
650
+ options.onOpenChange?.(nextOpen);
651
+ }
652
+ function open() {
653
+ setOpen(true);
654
+ }
655
+ function close(reason = "dismiss") {
656
+ if (!isOpen.value) return;
657
+ setOpen(false);
658
+ handleToastClose(reason);
659
+ }
660
+ function toggle() {
661
+ if (isOpen.value) close();
662
+ else open();
663
+ }
664
+ function handleToastClose(reason) {
665
+ closeReason.value = reason;
666
+ options.onClose?.(reason);
667
+ }
668
+ return {
669
+ isOpen,
670
+ lastCloseReason,
671
+ toastProps,
672
+ setOpen,
673
+ open,
674
+ close,
675
+ toggle
676
+ };
677
+ }
678
+ //#endregion
679
+ export { toastColors as a, toastTypes as c, useToast as i, toastVariants as l, toast_viewport_default as n, toastPositions as o, toast_provider_default as r, toastRadiuses as s, useToastState as t, toast_default as u };