ropav 0.0.8 → 0.0.9

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 (146) 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 +344 -0
  24. package/dist/color-picker.css +304 -0
  25. package/dist/color-picker.js +717 -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/alert/alert.d.ts +30 -0
  32. package/dist/components/alert/index.d.ts +3 -0
  33. package/dist/components/alert/index.js +2 -0
  34. package/dist/components/alert/types.d.ts +20 -0
  35. package/dist/components/alert/useAlertColor.d.ts +3 -0
  36. package/dist/components/aspect-ratio/aspect-ratio.d.ts +21 -0
  37. package/dist/components/aspect-ratio/index.d.ts +2 -0
  38. package/dist/components/aspect-ratio/index.js +2 -0
  39. package/dist/components/aspect-ratio/types.d.ts +3 -0
  40. package/dist/components/avatar/avatar.d.ts +24 -0
  41. package/dist/components/avatar/index.d.ts +3 -0
  42. package/dist/components/avatar/index.js +2 -0
  43. package/dist/components/avatar/types.d.ts +20 -0
  44. package/dist/components/avatar/useAvatarColor.d.ts +3 -0
  45. package/dist/components/badge/types.d.ts +2 -1
  46. package/dist/components/badge/useBadgeColor.d.ts +3 -8
  47. package/dist/components/button/types.d.ts +1 -0
  48. package/dist/components/button/useButtonColor.d.ts +3 -13
  49. package/dist/components/button-link/button-link.d.ts +27 -0
  50. package/dist/components/button-link/index.d.ts +2 -0
  51. package/dist/components/button-link/index.js +2 -0
  52. package/dist/components/button-link/types.d.ts +20 -0
  53. package/dist/components/checkbox/types.d.ts +1 -0
  54. package/dist/components/checkbox/useCheckbox.d.ts +2 -4
  55. package/dist/components/color-input/color-input.d.ts +29 -0
  56. package/dist/components/color-input/index.d.ts +2 -0
  57. package/dist/components/color-input/index.js +2 -0
  58. package/dist/components/color-input/types.d.ts +34 -0
  59. package/dist/components/color-input/useColorInput.d.ts +27 -0
  60. package/dist/components/color-input/useColorInputEyeDropper.d.ts +13 -0
  61. package/dist/components/color-input/useColorInputPopover.d.ts +11 -0
  62. package/dist/components/color-input/useColorInputValue.d.ts +8 -0
  63. package/dist/components/color-picker/color-picker-saturation.d.ts +21 -0
  64. package/dist/components/color-picker/color-picker-slider.d.ts +21 -0
  65. package/dist/components/color-picker/color-picker-utils.d.ts +23 -0
  66. package/dist/components/color-picker/color-picker.d.ts +23 -0
  67. package/dist/components/color-picker/index.d.ts +3 -0
  68. package/dist/components/color-picker/index.js +3 -0
  69. package/dist/components/color-picker/types.d.ts +39 -0
  70. package/dist/components/color-picker/useColorPickerDrag.d.ts +11 -0
  71. package/dist/components/color-picker/useColorPickerSwatches.d.ts +21 -0
  72. package/dist/components/color-picker/useColorPickerValue.d.ts +15 -0
  73. package/dist/components/color-swatch/color-swatch.d.ts +21 -0
  74. package/dist/components/color-swatch/index.d.ts +2 -0
  75. package/dist/components/color-swatch/index.js +2 -0
  76. package/dist/components/color-swatch/types.d.ts +6 -0
  77. package/dist/components/color-swatch/useColorSwatchColor.d.ts +5 -0
  78. package/dist/components/dropdown-menu/dropdown-menu.d.ts +2 -2
  79. package/dist/components/dropdown-menu/useDropdownMenu.d.ts +1 -1
  80. package/dist/components/dropdown-menu/useDropdownMenuNavigation.d.ts +1 -1
  81. package/dist/components/dropdown-menu/useDropdownSubmenus.d.ts +1 -1
  82. package/dist/components/field/types.d.ts +0 -2
  83. package/dist/components/field/useField.d.ts +0 -2
  84. package/dist/components/icon-button/types.d.ts +1 -0
  85. package/dist/components/input/types.d.ts +3 -0
  86. package/dist/components/number-input/index.d.ts +2 -0
  87. package/dist/components/number-input/index.js +2 -0
  88. package/dist/components/number-input/number-input.d.ts +29 -0
  89. package/dist/components/number-input/types.d.ts +34 -0
  90. package/dist/components/number-input/useNumberInput.d.ts +31 -0
  91. package/dist/components/popover/index.d.ts +1 -0
  92. package/dist/components/popover/index.js +2 -1
  93. package/dist/components/popover/types.d.ts +2 -1
  94. package/dist/components/progress/types.d.ts +1 -1
  95. package/dist/components/radio/types.d.ts +3 -0
  96. package/dist/components/radio/useRadio.d.ts +2 -4
  97. package/dist/components/select/index.d.ts +1 -1
  98. package/dist/components/select/types.d.ts +3 -0
  99. package/dist/components/slider/index.d.ts +2 -1
  100. package/dist/components/slider/index.js +2 -2
  101. package/dist/components/slider/range-slider.d.ts +45 -0
  102. package/dist/components/slider/types.d.ts +14 -2
  103. package/dist/components/slider/useRangeSlider.d.ts +59 -0
  104. package/dist/components/slider/useRangeSliderTooltipCollision.d.ts +7 -0
  105. package/dist/components/slider/useRangeSliderTooltipTransition.d.ts +4 -0
  106. package/dist/components/switch/useSwitch.d.ts +2 -3
  107. package/dist/components/tooltip/types.d.ts +1 -0
  108. package/dist/dropdown-menu.css +17 -17
  109. package/dist/field.css +15 -18
  110. package/dist/field.js +17 -35
  111. package/dist/icon-button.css +57 -236
  112. package/dist/icon-button.js +5 -6
  113. package/dist/index.d.ts +8 -0
  114. package/dist/index.js +16 -4
  115. package/dist/input.css +40 -46
  116. package/dist/input.js +39 -21
  117. package/dist/minus.js +12 -0
  118. package/dist/modal.css +9 -9
  119. package/dist/modal.js +1 -1
  120. package/dist/number-input.css +86 -0
  121. package/dist/number-input.js +350 -0
  122. package/dist/overlay.css +5 -5
  123. package/dist/overlay.js +3 -3
  124. package/dist/popover.css +54 -21
  125. package/dist/popover.js +8 -5
  126. package/dist/popover2.js +17 -0
  127. package/dist/progress.css +9 -30
  128. package/dist/progress.js +3 -6
  129. package/dist/radio.css +34 -62
  130. package/dist/radio.js +28 -16
  131. package/dist/select.css +105 -61
  132. package/dist/select.js +12 -8
  133. package/dist/slider.css +508 -41
  134. package/dist/slider.js +1122 -48
  135. package/dist/switch.css +19 -44
  136. package/dist/switch.js +4 -5
  137. package/dist/tabs.css +36 -36
  138. package/dist/tabs.js +1 -1
  139. package/dist/textarea.css +33 -25
  140. package/dist/tooltip.css +7 -35
  141. package/dist/tooltip.js +13 -8
  142. package/dist/useButtonColor.js +16 -14
  143. package/package.json +40 -8
  144. package/src/styles/_mixins.scss +25 -41
  145. package/src/styles/_tokens.scss +615 -182
  146. package/src/styles/_variables.scss +177 -49
@@ -0,0 +1,717 @@
1
+ import './color-picker.css';
2
+ import { t as bem } from "./bem.js";
3
+ import { t as parseCssColor } from "./color.js";
4
+ import { t as _plugin_vue_export_helper_default } from "./_plugin-vue_export-helper.js";
5
+ import { t as check_default } from "./check.js";
6
+ import { t as color_swatch_default } from "./color-swatch.js";
7
+ import { child, computed, createComponent, createFor, createIf, createInvoker, createSlot, createTemplateRefSetter, defineVaporComponent, delegateEvents, extend, next, on, onBeforeUnmount, ref, renderEffect, setAttr, setClass, setDynamicProps, setInsertionState, setProp, setStyle, setValue, template, unref, useAttrs } from "vue";
8
+ function clamp(value, min, max) {
9
+ return Math.min(max, Math.max(min, value));
10
+ }
11
+ function clampPercent(value) {
12
+ return clamp(Number.isFinite(value) ? value : 0, 0, 100);
13
+ }
14
+ function normalizeHue(value) {
15
+ if (!Number.isFinite(value)) return 0;
16
+ return (value % 360 + 360) % 360;
17
+ }
18
+ function normalizeHueForColor(value) {
19
+ const hue = normalizeHue(value);
20
+ return hue === 359 ? 360 : hue;
21
+ }
22
+ function clampHue(value) {
23
+ return clamp(Number.isFinite(value) ? value : 0, 0, 359);
24
+ }
25
+ function clampOpacity(value) {
26
+ return clamp(Number.isFinite(value) ? value : 100, 0, 100);
27
+ }
28
+ function roundPercent(value) {
29
+ return Math.round(value * 100) / 100;
30
+ }
31
+ function isColorPickerAlphaFormat(format) {
32
+ return format === "hexa" || format === "rgba" || format === "hsla";
33
+ }
34
+ function parseColorPickerValue(value) {
35
+ const rgb = parseCssColor(value);
36
+ if (!rgb) return void 0;
37
+ return rgbToHsv(rgb);
38
+ }
39
+ function formatColorPickerValue(color, format) {
40
+ const rgb = hsvToRgb(color.hue, color.saturation, color.value);
41
+ const opacity = clampOpacity(color.opacity);
42
+ switch (format) {
43
+ case "hex": return `#${toHexChannel(rgb.red)}${toHexChannel(rgb.green)}${toHexChannel(rgb.blue)}`;
44
+ case "hexa": return `#${toHexChannel(rgb.red)}${toHexChannel(rgb.green)}${toHexChannel(rgb.blue)}${toHexChannel(Math.round(opacity / 100 * 255))}`;
45
+ case "rgb": return `rgb(${rgb.red}, ${rgb.green}, ${rgb.blue})`;
46
+ case "rgba": return `rgba(${rgb.red}, ${rgb.green}, ${rgb.blue}, ${formatAlpha(opacity)})`;
47
+ case "hsl": {
48
+ const hsl = rgbToHsl(rgb);
49
+ return `hsl(${formatNumber(hsl.hue)}, ${formatNumber(hsl.saturation)}%, ${formatNumber(hsl.lightness)}%)`;
50
+ }
51
+ case "hsla": {
52
+ const hsl = rgbToHsl(rgb);
53
+ return `hsla(${formatNumber(hsl.hue)}, ${formatNumber(hsl.saturation)}%, ${formatNumber(hsl.lightness)}%, ${formatAlpha(opacity)})`;
54
+ }
55
+ }
56
+ }
57
+ function getHsvCssColor(hue, saturation, value) {
58
+ const rgb = hsvToRgb(hue, saturation, value);
59
+ return `rgb(${rgb.red} ${rgb.green} ${rgb.blue})`;
60
+ }
61
+ function hsvToRgb(hue, saturation, value) {
62
+ const normalizedHue = normalizeHueForColor(hue);
63
+ const s = clampPercent(saturation) / 100;
64
+ const v = clampPercent(value) / 100;
65
+ const c = v * s;
66
+ const x = c * (1 - Math.abs(normalizedHue / 60 % 2 - 1));
67
+ const m = v - c;
68
+ let r = 0;
69
+ let g = 0;
70
+ let b = 0;
71
+ if (normalizedHue < 60) {
72
+ r = c;
73
+ g = x;
74
+ } else if (normalizedHue < 120) {
75
+ r = x;
76
+ g = c;
77
+ } else if (normalizedHue < 180) {
78
+ g = c;
79
+ b = x;
80
+ } else if (normalizedHue < 240) {
81
+ g = x;
82
+ b = c;
83
+ } else if (normalizedHue < 300) {
84
+ r = x;
85
+ b = c;
86
+ } else {
87
+ r = c;
88
+ b = x;
89
+ }
90
+ return {
91
+ red: Math.round((r + m) * 255),
92
+ green: Math.round((g + m) * 255),
93
+ blue: Math.round((b + m) * 255)
94
+ };
95
+ }
96
+ function rgbToHsv({ red, green, blue, opacity }) {
97
+ const r = red / 255;
98
+ const g = green / 255;
99
+ const b = blue / 255;
100
+ const max = Math.max(r, g, b);
101
+ const delta = max - Math.min(r, g, b);
102
+ let hue = 0;
103
+ if (delta) if (max === r) hue = 60 * ((g - b) / delta % 6);
104
+ else if (max === g) hue = 60 * ((b - r) / delta + 2);
105
+ else hue = 60 * ((r - g) / delta + 4);
106
+ return {
107
+ hue: normalizeHue(hue),
108
+ saturation: roundPercent(max === 0 ? 0 : delta / max * 100),
109
+ value: roundPercent(max * 100),
110
+ opacity: roundPercent(opacity)
111
+ };
112
+ }
113
+ function rgbToHsl({ red, green, blue }) {
114
+ const r = red / 255;
115
+ const g = green / 255;
116
+ const b = blue / 255;
117
+ const max = Math.max(r, g, b);
118
+ const min = Math.min(r, g, b);
119
+ const delta = max - min;
120
+ const lightness = (max + min) / 2;
121
+ if (!delta) return {
122
+ hue: 0,
123
+ saturation: 0,
124
+ lightness: roundPercent(lightness * 100)
125
+ };
126
+ let hue;
127
+ if (max === r) hue = 60 * ((g - b) / delta % 6);
128
+ else if (max === g) hue = 60 * ((b - r) / delta + 2);
129
+ else hue = 60 * ((r - g) / delta + 4);
130
+ const saturation = delta / (1 - Math.abs(2 * lightness - 1));
131
+ return {
132
+ hue: roundPercent(normalizeHue(hue)),
133
+ saturation: roundPercent(saturation * 100),
134
+ lightness: roundPercent(lightness * 100)
135
+ };
136
+ }
137
+ function toHexChannel(value) {
138
+ return clamp(value, 0, 255).toString(16).padStart(2, "0");
139
+ }
140
+ function formatAlpha(opacity) {
141
+ return formatNumber(clampOpacity(opacity) / 100);
142
+ }
143
+ function formatNumber(value) {
144
+ return String(Math.round(value * 100) / 100);
145
+ }
146
+ //#endregion
147
+ //#region src/components/color-picker/useColorPickerDrag.ts
148
+ function useColorPickerDrag({ target, focusTarget, readonly, updateFromPointer }) {
149
+ let dragWindow = null;
150
+ function stopDragging() {
151
+ if (!dragWindow) return;
152
+ dragWindow.removeEventListener("pointermove", onPointerMove);
153
+ dragWindow.removeEventListener("pointerup", stopDragging);
154
+ dragWindow.removeEventListener("pointercancel", stopDragging);
155
+ dragWindow = null;
156
+ }
157
+ function onPointerMove(event) {
158
+ const el = target.value;
159
+ if (!el) {
160
+ stopDragging();
161
+ return;
162
+ }
163
+ updateFromPointer(event, el);
164
+ }
165
+ function onPointerDown(event) {
166
+ if (readonly()) return;
167
+ const el = target.value;
168
+ if (!el) return;
169
+ event.preventDefault();
170
+ (focusTarget?.value ?? el).focus();
171
+ updateFromPointer(event, el);
172
+ stopDragging();
173
+ dragWindow = el.ownerDocument.defaultView;
174
+ dragWindow?.addEventListener("pointermove", onPointerMove);
175
+ dragWindow?.addEventListener("pointerup", stopDragging);
176
+ dragWindow?.addEventListener("pointercancel", stopDragging);
177
+ }
178
+ onBeforeUnmount(stopDragging);
179
+ return { onPointerDown };
180
+ }
181
+ //#endregion
182
+ //#region src/components/color-picker/color-picker-saturation.vue?vue&type=script&setup=true&vapor=true&lang.ts
183
+ var t0$2 = template("<div data-v-0ff88f34 class=rp-color-picker__saturation role=group><input data-v-0ff88f34 class=\"rp-color-picker__axis-input rp-color-picker__axis-input--saturation\"type=range min=0 max=100 step=1 aria-label=Saturation aria-orientation=horizontal><input data-v-0ff88f34 class=\"rp-color-picker__axis-input rp-color-picker__axis-input--value\"type=range min=0 max=100 step=1 aria-label=Value aria-orientation=vertical><span data-v-0ff88f34 class=rp-color-picker__surface aria-hidden=true></span><span data-v-0ff88f34 class=rp-color-picker__handle aria-hidden=true>", 1);
184
+ delegateEvents("input", "keydown", "pointerdown");
185
+ //#endregion
186
+ //#region src/components/color-picker/color-picker-saturation.vue
187
+ var color_picker_saturation_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__ */ defineVaporComponent({
188
+ name: "RpColorPickerSaturation",
189
+ __name: "color-picker-saturation",
190
+ props: {
191
+ id: {},
192
+ modelValue: {},
193
+ hue: { default: 0 },
194
+ readonly: {
195
+ type: Boolean,
196
+ default: false
197
+ },
198
+ ariaLabel: {},
199
+ describedby: {},
200
+ labelledby: {}
201
+ },
202
+ emits: ["update:modelValue"],
203
+ setup(__props, { emit: __emit }) {
204
+ const props = __props;
205
+ const emit = __emit;
206
+ const saturationRef = ref(null);
207
+ const saturationInputRef = ref(null);
208
+ const saturation = computed(() => clampPercent(props.modelValue.saturation));
209
+ const value = computed(() => clampPercent(props.modelValue.value));
210
+ const hue = computed(() => normalizeHue(props.hue));
211
+ const saturationStyle = computed(() => ({
212
+ "--_rp-color-picker-hue": String(normalizeHueForColor(hue.value)),
213
+ "--_rp-color-picker-saturation-x": `${saturation.value}%`,
214
+ "--_rp-color-picker-saturation-y": `${100 - value.value}%`,
215
+ "--_rp-color-picker-current": getHsvCssColor(hue.value, saturation.value, value.value)
216
+ }));
217
+ const ariaValueText = computed(() => `${Math.round(saturation.value)}% saturation, ${Math.round(value.value)}% value`);
218
+ const groupAriaLabel = computed(() => props.labelledby ? void 0 : props.ariaLabel || "Color area");
219
+ function updateValue(nextSaturation, nextValue) {
220
+ if (props.readonly) return;
221
+ const normalizedSaturation = roundPercent(clampPercent(nextSaturation));
222
+ const normalizedValue = roundPercent(clampPercent(nextValue));
223
+ if (normalizedSaturation === saturation.value && normalizedValue === value.value) return;
224
+ emit("update:modelValue", {
225
+ saturation: normalizedSaturation,
226
+ value: normalizedValue
227
+ });
228
+ }
229
+ function updateFromPointer(e, el) {
230
+ const rect = el.getBoundingClientRect();
231
+ if (rect.width <= 0 || rect.height <= 0) return;
232
+ updateValue((e.clientX - rect.left) / rect.width * 100, 100 - (e.clientY - rect.top) / rect.height * 100);
233
+ }
234
+ const { onPointerDown } = useColorPickerDrag({
235
+ target: saturationRef,
236
+ focusTarget: saturationInputRef,
237
+ readonly: () => props.readonly,
238
+ updateFromPointer
239
+ });
240
+ function onAxisKeydown(event, axis) {
241
+ const currentValue = axis === "saturation" ? saturation.value : value.value;
242
+ const step = event.shiftKey ? 10 : 1;
243
+ let nextValue;
244
+ switch (event.key) {
245
+ case "ArrowRight":
246
+ case "ArrowUp":
247
+ nextValue = currentValue + step;
248
+ break;
249
+ case "ArrowLeft":
250
+ case "ArrowDown":
251
+ nextValue = currentValue - step;
252
+ break;
253
+ case "Home":
254
+ nextValue = 0;
255
+ break;
256
+ case "End":
257
+ nextValue = 100;
258
+ break;
259
+ }
260
+ if (nextValue === void 0) return;
261
+ event.preventDefault();
262
+ if (!props.readonly) updateAxis(axis, nextValue);
263
+ }
264
+ function onAxisInput(event, axis) {
265
+ const input = event.currentTarget;
266
+ if (!(input instanceof HTMLInputElement)) return;
267
+ if (props.readonly) {
268
+ input.value = String(axis === "saturation" ? saturation.value : value.value);
269
+ return;
270
+ }
271
+ updateAxis(axis, Number(input.value));
272
+ }
273
+ function updateAxis(axis, nextValue) {
274
+ if (axis === "saturation") updateValue(nextValue, value.value);
275
+ else updateValue(saturation.value, nextValue);
276
+ }
277
+ const _setTemplateRef = createTemplateRefSetter();
278
+ const n2 = t0$2();
279
+ const n0 = child(n2);
280
+ const n1 = next(n0, 1);
281
+ n0.$evtinput = createInvoker(($event) => onAxisInput($event, "saturation"));
282
+ n0.$evtkeydown = createInvoker(($event) => onAxisKeydown($event, "saturation"));
283
+ _setTemplateRef(n0, saturationInputRef, null, "saturationInputRef");
284
+ n1.$evtinput = createInvoker(($event) => onAxisInput($event, "value"));
285
+ n1.$evtkeydown = createInvoker(($event) => onAxisKeydown($event, "value"));
286
+ n2.$evtpointerdown = createInvoker((e) => unref(onPointerDown)(e));
287
+ _setTemplateRef(n2, saturationRef, null, "saturationRef");
288
+ renderEffect(() => {
289
+ const _describedby = __props.describedby;
290
+ const _id = __props.id;
291
+ const _saturation = saturation.value;
292
+ const _ariaValueText = ariaValueText.value;
293
+ const _value = value.value;
294
+ setStyle(n2, saturationStyle.value);
295
+ setAttr(n2, "aria-label", groupAriaLabel.value);
296
+ setAttr(n2, "aria-labelledby", __props.labelledby);
297
+ setAttr(n2, "aria-describedby", _describedby);
298
+ setAttr(n2, "aria-readonly", __props.readonly || void 0);
299
+ setAttr(n2, "data-readonly", __props.readonly || void 0);
300
+ setProp(n0, "id", _id);
301
+ setValue(n0, _saturation);
302
+ setAttr(n0, "aria-valuenow", Math.round(_saturation));
303
+ setAttr(n0, "aria-valuetext", _ariaValueText);
304
+ setAttr(n0, "aria-describedby", _describedby);
305
+ setAttr(n0, "aria-readonly", __props.readonly || void 0);
306
+ setProp(n1, "id", _id ? `${_id}-value` : void 0);
307
+ setValue(n1, _value);
308
+ setAttr(n1, "aria-valuenow", Math.round(_value));
309
+ setAttr(n1, "aria-valuetext", _ariaValueText);
310
+ setAttr(n1, "aria-describedby", _describedby);
311
+ setAttr(n1, "aria-readonly", __props.readonly || void 0);
312
+ });
313
+ return n2;
314
+ }
315
+ }), [["__scopeId", "data-v-0ff88f34"]]);
316
+ //#endregion
317
+ //#region src/components/color-picker/color-picker-slider.vue?vue&type=script&setup=true&vapor=true&lang.ts
318
+ var t0$1 = template("<div data-v-d0c81f73 role=slider tabindex=0 aria-orientation=horizontal aria-valuemin=0><span data-v-d0c81f73 aria-hidden=true></span><span data-v-d0c81f73 aria-hidden=true>", 1);
319
+ delegateEvents("pointerdown", "keydown");
320
+ //#endregion
321
+ //#region src/components/color-picker/color-picker-slider.vue
322
+ var color_picker_slider_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__ */ defineVaporComponent({
323
+ name: "RpColorPickerSlider",
324
+ __name: "color-picker-slider",
325
+ props: {
326
+ variant: {},
327
+ value: { default: 0 },
328
+ color: {},
329
+ readonly: {
330
+ type: Boolean,
331
+ default: false
332
+ }
333
+ },
334
+ emits: ["update:value"],
335
+ setup(__props, { emit: __emit }) {
336
+ const props = __props;
337
+ const emit = __emit;
338
+ const sliderRef = ref(null);
339
+ const isHue = computed(() => props.variant === "hue");
340
+ const max = computed(() => isHue.value ? 359 : 100);
341
+ const rootClass = computed(() => `rp-color-picker__${props.variant}`);
342
+ const surfaceClass = computed(() => ["rp-color-picker__slider-surface", `rp-color-picker__${props.variant}-surface`]);
343
+ const handleClass = computed(() => ["rp-color-picker__slider-handle", `rp-color-picker__${props.variant}-handle`]);
344
+ const normalizedValue = computed(() => isHue.value ? normalizeHue(props.value) : clampOpacity(props.value));
345
+ const currentOutputValue = computed(() => normalizeOutputValue(normalizedValue.value));
346
+ const sliderStyle = computed(() => {
347
+ const style = { "--_rp-color-picker-slider-x": `${currentOutputValue.value / max.value * 100}%` };
348
+ if (isHue.value) style["--_rp-color-picker-hue"] = String(normalizeHueForColor(currentOutputValue.value));
349
+ else style["--_rp-color-picker-opacity-color"] = props.color;
350
+ return style;
351
+ });
352
+ const ariaLabel = computed(() => isHue.value ? "Hue" : "Opacity");
353
+ const ariaValueText = computed(() => isHue.value ? `${Math.round(normalizedValue.value)} degrees hue` : `${Math.round(normalizedValue.value)}% opacity`);
354
+ function updateValue(nextValue) {
355
+ if (props.readonly) return;
356
+ const normalizedNextValue = normalizeOutputValue(nextValue);
357
+ if (normalizedNextValue === currentOutputValue.value) return;
358
+ emit("update:value", normalizedNextValue);
359
+ }
360
+ function updateFromPointer(e, el) {
361
+ const rect = el.getBoundingClientRect();
362
+ if (rect.width <= 0) return;
363
+ updateValue((e.clientX - rect.left) / rect.width * max.value);
364
+ }
365
+ const { onPointerDown } = useColorPickerDrag({
366
+ target: sliderRef,
367
+ readonly: () => props.readonly,
368
+ updateFromPointer
369
+ });
370
+ function onKeydown(e) {
371
+ if (props.readonly) return;
372
+ const step = e.shiftKey ? 10 : 1;
373
+ switch (e.key) {
374
+ case "ArrowRight":
375
+ case "ArrowUp":
376
+ e.preventDefault();
377
+ updateValue(normalizedValue.value + step);
378
+ break;
379
+ case "ArrowLeft":
380
+ case "ArrowDown":
381
+ e.preventDefault();
382
+ updateValue(normalizedValue.value - step);
383
+ break;
384
+ case "Home":
385
+ e.preventDefault();
386
+ updateValue(0);
387
+ break;
388
+ case "End":
389
+ e.preventDefault();
390
+ updateValue(max.value);
391
+ break;
392
+ }
393
+ }
394
+ function normalizeOutputValue(value) {
395
+ return isHue.value ? Math.round(clampHue(value)) : roundPercent(clampOpacity(value));
396
+ }
397
+ const _setTemplateRef = createTemplateRefSetter();
398
+ const n2 = t0$1();
399
+ const n0 = child(n2);
400
+ const n1 = next(n0, 1);
401
+ n2.$evtpointerdown = createInvoker((e) => unref(onPointerDown)(e));
402
+ n2.$evtkeydown = createInvoker(onKeydown);
403
+ _setTemplateRef(n2, sliderRef, null, "sliderRef");
404
+ renderEffect(() => {
405
+ setClass(n2, rootClass.value);
406
+ setStyle(n2, sliderStyle.value);
407
+ setAttr(n2, "aria-label", ariaLabel.value);
408
+ setAttr(n2, "aria-valuemax", max.value);
409
+ setAttr(n2, "aria-valuenow", Math.round(normalizedValue.value));
410
+ setAttr(n2, "aria-valuetext", ariaValueText.value);
411
+ setAttr(n2, "aria-readonly", __props.readonly || void 0);
412
+ setAttr(n2, "data-readonly", __props.readonly || void 0);
413
+ setClass(n0, surfaceClass.value);
414
+ setClass(n1, handleClass.value);
415
+ });
416
+ return n2;
417
+ }
418
+ }), [["__scopeId", "data-v-d0c81f73"]]);
419
+ //#endregion
420
+ //#region src/components/color-picker/useColorPickerSwatches.ts
421
+ var MAX_SWATCHES_PER_ROW = 15;
422
+ function useColorPickerSwatches(props, options) {
423
+ const swatchesRef = ref(null);
424
+ const focusedSwatchIndex = ref(null);
425
+ const normalizedSwatchesPerRow = computed(() => normalizeSwatchesPerRow(props.swatchesPerRow));
426
+ const validSwatches = computed(() => (props.swatches ?? []).filter((swatch) => Boolean(parseColorPickerValue(swatch))));
427
+ const swatchesStyle = computed(() => {
428
+ const swatchesPerRow = normalizedSwatchesPerRow.value;
429
+ if (!swatchesPerRow) return void 0;
430
+ return { "--_rp-color-picker-swatches-per-row": String(swatchesPerRow) };
431
+ });
432
+ const swatchSize = computed(() => normalizedSwatchesPerRow.value ? "100%" : "var(--_rp-color-picker-swatch-size)");
433
+ const selectedSwatchIndex = computed(() => validSwatches.value.findIndex((swatch) => options.isSelected(swatch)));
434
+ const tabbableSwatchIndex = computed(() => {
435
+ const focusedIndex = focusedSwatchIndex.value;
436
+ if (focusedIndex != null && focusedIndex < validSwatches.value.length) return focusedIndex;
437
+ return selectedSwatchIndex.value >= 0 ? selectedSwatchIndex.value : 0;
438
+ });
439
+ function isSwatchSelected(index) {
440
+ return selectedSwatchIndex.value === index;
441
+ }
442
+ function getSwatchTabindex(index) {
443
+ return tabbableSwatchIndex.value === index ? 0 : -1;
444
+ }
445
+ function selectSwatch(swatch) {
446
+ options.select(swatch);
447
+ }
448
+ function onSwatchFocus(index) {
449
+ focusedSwatchIndex.value = index;
450
+ }
451
+ function onSwatchesFocusout(event) {
452
+ const group = event.currentTarget;
453
+ const nextTarget = event.relatedTarget;
454
+ if (group instanceof HTMLElement && nextTarget instanceof Node && group.contains(nextTarget)) return;
455
+ focusedSwatchIndex.value = null;
456
+ }
457
+ function onSwatchKeydown(event, index) {
458
+ const offset = getNavigationOffset(event.key);
459
+ if (offset === void 0 || validSwatches.value.length === 0) return;
460
+ event.preventDefault();
461
+ const nextIndex = (index + offset + validSwatches.value.length) % validSwatches.value.length;
462
+ const nextSwatch = validSwatches.value[nextIndex];
463
+ (swatchesRef.value?.querySelectorAll(".rp-color-picker__swatch")[nextIndex])?.focus({ preventScroll: true });
464
+ if (nextSwatch) selectSwatch(nextSwatch);
465
+ }
466
+ return {
467
+ swatchesRef,
468
+ normalizedSwatchesPerRow,
469
+ validSwatches,
470
+ swatchesStyle,
471
+ swatchSize,
472
+ isSwatchSelected,
473
+ getSwatchTabindex,
474
+ selectSwatch,
475
+ onSwatchFocus,
476
+ onSwatchesFocusout,
477
+ onSwatchKeydown
478
+ };
479
+ }
480
+ function normalizeSwatchesPerRow(value) {
481
+ if (value === void 0 || !Number.isFinite(value) || value < 1) return void 0;
482
+ return Math.min(MAX_SWATCHES_PER_ROW, Math.floor(value));
483
+ }
484
+ function getNavigationOffset(key) {
485
+ switch (key) {
486
+ case "ArrowRight":
487
+ case "ArrowDown": return 1;
488
+ case "ArrowLeft":
489
+ case "ArrowUp": return -1;
490
+ default: return;
491
+ }
492
+ }
493
+ //#endregion
494
+ //#region src/components/color-picker/useColorPickerValue.ts
495
+ function useColorPickerValue(props, emitUpdate) {
496
+ const format = computed(() => props.format ?? "hex");
497
+ const emittedStringColor = ref(null);
498
+ const selectedColor = computed(() => {
499
+ const value = props.modelValue;
500
+ const cached = emittedStringColor.value;
501
+ if (cached && cached.value === value && cached.format === format.value) return cached.color;
502
+ return parseColorPickerValue(value) ?? {
503
+ hue: 0,
504
+ saturation: 100,
505
+ value: 100,
506
+ opacity: 100
507
+ };
508
+ });
509
+ const saturationValue = computed(() => ({
510
+ saturation: selectedColor.value.saturation,
511
+ value: selectedColor.value.value
512
+ }));
513
+ const opacityColor = computed(() => getHsvCssColor(selectedColor.value.hue, selectedColor.value.saturation, selectedColor.value.value));
514
+ const showAlphaControls = computed(() => isColorPickerAlphaFormat(format.value));
515
+ function updateSelection(value) {
516
+ emitColor({
517
+ saturation: value.saturation,
518
+ value: value.value,
519
+ ...value.opacity === void 0 ? {} : { opacity: value.opacity }
520
+ });
521
+ }
522
+ function updateHue(value) {
523
+ emitColor({ hue: value });
524
+ }
525
+ function updateOpacity(value) {
526
+ emitColor({ opacity: value });
527
+ }
528
+ function selectColor(value) {
529
+ if (props.readonly) return;
530
+ const parsedColor = parseColorPickerValue(value);
531
+ if (!parsedColor) return;
532
+ emitColor(normalizeColor(parsedColor));
533
+ }
534
+ function isColorSelected(value) {
535
+ const parsedColor = parseColorPickerValue(value);
536
+ if (!parsedColor) return false;
537
+ return getComparableColor(normalizeColor(parsedColor)) === getComparableColor(selectedColor.value);
538
+ }
539
+ function emitColor(nextColor) {
540
+ const color = normalizeColor({
541
+ ...selectedColor.value,
542
+ ...nextColor
543
+ });
544
+ const formattedValue = formatColorPickerValue(color, format.value);
545
+ emittedStringColor.value = {
546
+ value: formattedValue,
547
+ format: format.value,
548
+ color
549
+ };
550
+ emitUpdate(formattedValue);
551
+ }
552
+ return {
553
+ selectedColor,
554
+ saturationValue,
555
+ opacityColor,
556
+ showAlphaControls,
557
+ updateSelection,
558
+ updateHue,
559
+ updateOpacity,
560
+ selectColor,
561
+ isColorSelected
562
+ };
563
+ }
564
+ function normalizeColor(color) {
565
+ return {
566
+ hue: normalizeHue(color.hue),
567
+ saturation: roundPercent(clampPercent(color.saturation)),
568
+ value: roundPercent(clampPercent(color.value)),
569
+ opacity: roundPercent(clampOpacity(color.opacity))
570
+ };
571
+ }
572
+ function getComparableColor(color) {
573
+ return formatColorPickerValue(color, "rgba");
574
+ }
575
+ //#endregion
576
+ //#region src/components/color-picker/color-picker.vue?vue&type=script&setup=true&vapor=true&lang.ts
577
+ var t0 = template("<div data-v-38eeea2b class=rp-color-picker__header><span data-v-38eeea2b class=rp-color-picker__label>");
578
+ var t1 = template("<button data-v-38eeea2b class=rp-color-picker__swatch type=button role=radio>");
579
+ var t2 = template("<div data-v-38eeea2b class=rp-color-picker__swatches role=radiogroup>");
580
+ var t3 = template("<div data-v-38eeea2b>", 1);
581
+ delegateEvents("click", "keydown", "focusout");
582
+ //#endregion
583
+ //#region src/components/color-picker/color-picker.vue
584
+ var color_picker_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__ */ defineVaporComponent({
585
+ name: "RpColorPicker",
586
+ inheritAttrs: false,
587
+ __name: "color-picker",
588
+ props: {
589
+ id: {},
590
+ modelValue: {},
591
+ format: { default: "hex" },
592
+ size: {},
593
+ readonly: {
594
+ type: Boolean,
595
+ default: false
596
+ },
597
+ withPicker: {
598
+ type: Boolean,
599
+ default: true
600
+ },
601
+ swatches: { default: () => [] },
602
+ swatchesPerRow: {},
603
+ ariaLabel: {},
604
+ describedby: {},
605
+ labelledby: {}
606
+ },
607
+ emits: ["update:modelValue"],
608
+ setup(__props, { emit: __emit, slots: $slots }) {
609
+ const props = __props;
610
+ const emit = __emit;
611
+ const rootClass = computed(() => bem("rp-color-picker", {
612
+ [`size-${props.size}`]: Boolean(props.size),
613
+ readonly: props.readonly
614
+ }));
615
+ const attrs = useAttrs();
616
+ const rootAttrs = computed(() => {
617
+ const { disabled: _disabled, invalid: _invalid, required: _required, ...filteredAttrs } = attrs;
618
+ return filteredAttrs;
619
+ });
620
+ const { selectedColor, saturationValue, opacityColor, showAlphaControls, updateSelection, updateHue, updateOpacity, selectColor, isColorSelected } = useColorPickerValue(props, (value) => emit("update:modelValue", value));
621
+ const { swatchesRef, normalizedSwatchesPerRow, validSwatches, swatchesStyle, swatchSize, isSwatchSelected, getSwatchTabindex, selectSwatch, onSwatchFocus, onSwatchesFocusout, onSwatchKeydown } = useColorPickerSwatches(props, {
622
+ isSelected: isColorSelected,
623
+ select: selectColor
624
+ });
625
+ const _setTemplateRef = createTemplateRefSetter();
626
+ const n22 = t3();
627
+ renderEffect(() => setDynamicProps(n22, [rootAttrs.value, {
628
+ class: rootClass.value,
629
+ "data-readonly": __props.readonly || void 0
630
+ }]));
631
+ setInsertionState(n22, null, 0);
632
+ createIf(() => $slots.default, () => {
633
+ const n4 = t0();
634
+ setInsertionState(child(n4), null, 0);
635
+ createSlot("default", null, null, 1);
636
+ return n4;
637
+ });
638
+ setInsertionState(n22, null, 1);
639
+ createIf(() => __props.withPicker, () => {
640
+ return [
641
+ createComponent(color_picker_saturation_default, {
642
+ id: () => __props.id,
643
+ "model-value": () => unref(saturationValue),
644
+ hue: () => unref(selectedColor).hue,
645
+ readonly: () => __props.readonly,
646
+ "aria-label": () => __props.ariaLabel,
647
+ describedby: () => __props.describedby,
648
+ labelledby: () => __props.labelledby,
649
+ "onUpdate:modelValue": () => unref(updateSelection)
650
+ }),
651
+ createComponent(color_picker_slider_default, {
652
+ variant: "hue",
653
+ value: () => unref(selectedColor).hue,
654
+ readonly: () => __props.readonly,
655
+ "onUpdate:value": () => unref(updateHue)
656
+ }),
657
+ createIf(() => unref(showAlphaControls), () => {
658
+ return createComponent(color_picker_slider_default, {
659
+ variant: "opacity",
660
+ color: () => unref(opacityColor),
661
+ value: () => unref(selectedColor).opacity,
662
+ readonly: () => __props.readonly,
663
+ "onUpdate:value": () => unref(updateOpacity)
664
+ });
665
+ })
666
+ ];
667
+ }, null, 2);
668
+ setInsertionState(n22, null, 2);
669
+ createIf(() => unref(validSwatches).length, () => {
670
+ const n21 = t2();
671
+ renderEffect(() => {
672
+ const _withPicker = __props.withPicker;
673
+ setStyle(n21, unref(swatchesStyle));
674
+ setAttr(n21, "data-fill", unref(normalizedSwatchesPerRow) ? true : void 0);
675
+ setAttr(n21, "data-with-picker", _withPicker || void 0);
676
+ setProp(n21, "id", _withPicker ? void 0 : __props.id);
677
+ setAttr(n21, "aria-label", _withPicker ? "Color swatches" : __props.ariaLabel || "Color swatches");
678
+ setAttr(n21, "aria-describedby", _withPicker ? void 0 : __props.describedby);
679
+ setAttr(n21, "aria-labelledby", _withPicker ? void 0 : __props.labelledby);
680
+ });
681
+ setInsertionState(n21, null, 0);
682
+ createFor(() => unref(validSwatches), (_for_item0, _for_key0) => {
683
+ const n20 = t1();
684
+ renderEffect(() => {
685
+ const _readonly = __props.readonly;
686
+ const _index = _for_key0.value;
687
+ const _swatch = _for_item0.value;
688
+ setProp(n20, "disabled", _readonly);
689
+ setProp(n20, "tabindex", _readonly ? -1 : unref(getSwatchTabindex)(_index));
690
+ setAttr(n20, "aria-checked", unref(isSwatchSelected)(_index));
691
+ setAttr(n20, "aria-label", `Select color ${_swatch}`);
692
+ setProp(n20, "title", _swatch);
693
+ });
694
+ setInsertionState(n20, null, 0);
695
+ createComponent(color_swatch_default, {
696
+ color: () => _for_item0.value,
697
+ size: () => unref(swatchSize),
698
+ "aria-hidden": "true"
699
+ }, extend(() => {
700
+ return createIf(() => unref(isSwatchSelected)(_for_key0.value), () => {
701
+ return createComponent(unref(check_default), { class: "rp-color-picker__swatch-check" });
702
+ }, null, 129);
703
+ }, { _: 8 }));
704
+ n20.$evtclick = createInvoker(() => unref(selectSwatch)(_for_item0.value));
705
+ on(n20, "focus", () => unref(onSwatchFocus)(_for_key0.value));
706
+ n20.$evtkeydown = createInvoker(($event) => unref(onSwatchKeydown)($event, _for_key0.value));
707
+ return n20;
708
+ }, (swatch, index) => `${swatch}-${index}`, 9);
709
+ n21.$evtfocusout = createInvoker((e) => unref(onSwatchesFocusout)(e));
710
+ _setTemplateRef(n21, swatchesRef, null, "swatchesRef");
711
+ return n21;
712
+ });
713
+ return n22;
714
+ }
715
+ }), [["__scopeId", "data-v-38eeea2b"]]);
716
+ //#endregion
717
+ export { formatColorPickerValue as n, parseColorPickerValue as r, color_picker_default as t };