@enos5/enos-vue-default 1.8.0 → 1.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/ColorPicker.vue.d.ts +18 -0
- package/dist/components/ConfirmationModal.vue.d.ts +1 -1
- package/dist/components/DialogModal.vue.d.ts +1 -1
- package/dist/components/InputGroup.vue.d.ts +18 -0
- package/dist/components/Modal.vue.d.ts +1 -1
- package/dist/index.js +21 -21
- package/dist/index.node.js +21 -21
- package/dist/{plugin-ODQo1Iv8.js → plugin-DYTVm2W1.js} +858 -240
- package/dist/plugin-DYTVm2W1.js.map +1 -0
- package/dist/styles.css +188 -38
- package/package.json +1 -1
- package/dist/plugin-ODQo1Iv8.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ref, computed, watch, openBlock, createElementBlock, createElementVNode, Fragment, renderList, normalizeClass, normalizeStyle, toDisplayString, createBlock, createCommentVNode, renderSlot, createVNode, Transition, withCtx, mergeProps, useSlots, unref, withDirectives, vShow, useAttrs, vModelCheckbox, onMounted, nextTick, onBeforeUnmount, Teleport, withModifiers, onUnmounted, inject, provide, defineComponent, isVNode, cloneVNode, resolveDynamicComponent, createTextVNode, h, vModelText, createSlots } from "vue";
|
|
2
|
-
import { LockClosedIcon, ChevronDownIcon, PhotoIcon, ExclamationCircleIcon, ExclamationTriangleIcon, ChevronUpIcon, MagnifyingGlassIcon, CheckIcon, PencilSquareIcon } from "@heroicons/vue/24/outline";
|
|
2
|
+
import { LockClosedIcon, ChevronDownIcon, PhotoIcon, EyeDropperIcon, ExclamationCircleIcon, ExclamationTriangleIcon, ChevronUpIcon, MagnifyingGlassIcon, CheckIcon, PencilSquareIcon } from "@heroicons/vue/24/outline";
|
|
3
3
|
import Editor from "@tinymce/tinymce-vue";
|
|
4
4
|
import { Link } from "@inertiajs/vue3";
|
|
5
5
|
const _hoisted_1$E = { class: "border-b border-neutral-200 bg-neutral-50/80 p-2 dark:border-neutral-800 dark:bg-neutral-900/80" };
|
|
@@ -306,7 +306,7 @@ const _hoisted_1$B = { class: "md:col-span-1 flex justify-between" };
|
|
|
306
306
|
const _hoisted_2$m = { class: "px-4 sm:px-0" };
|
|
307
307
|
const _hoisted_3$g = { class: "text-xl font-semibold tracking-tight text-neutral-950 dark:text-neutral-50" };
|
|
308
308
|
const _hoisted_4$b = { class: "mt-1 max-w-2xl text-sm text-neutral-600 dark:text-neutral-200" };
|
|
309
|
-
const _hoisted_5$
|
|
309
|
+
const _hoisted_5$9 = { class: "px-4 sm:px-0" };
|
|
310
310
|
function _sfc_render(_ctx, _cache) {
|
|
311
311
|
return openBlock(), createElementBlock("div", _hoisted_1$B, [
|
|
312
312
|
createElementVNode("div", _hoisted_2$m, [
|
|
@@ -317,7 +317,7 @@ function _sfc_render(_ctx, _cache) {
|
|
|
317
317
|
renderSlot(_ctx.$slots, "description")
|
|
318
318
|
])
|
|
319
319
|
]),
|
|
320
|
-
createElementVNode("div", _hoisted_5$
|
|
320
|
+
createElementVNode("div", _hoisted_5$9, [
|
|
321
321
|
renderSlot(_ctx.$slots, "aside")
|
|
322
322
|
])
|
|
323
323
|
]);
|
|
@@ -621,21 +621,21 @@ const _hoisted_2$k = {
|
|
|
621
621
|
};
|
|
622
622
|
const _hoisted_3$e = ["type", "value", "disabled"];
|
|
623
623
|
const _hoisted_4$a = ["aria-label"];
|
|
624
|
-
const _hoisted_5$
|
|
624
|
+
const _hoisted_5$8 = {
|
|
625
625
|
key: 0,
|
|
626
626
|
class: "h-5 w-5",
|
|
627
627
|
fill: "none",
|
|
628
628
|
stroke: "currentColor",
|
|
629
629
|
viewBox: "0 0 24 24"
|
|
630
630
|
};
|
|
631
|
-
const _hoisted_6$
|
|
631
|
+
const _hoisted_6$8 = {
|
|
632
632
|
key: 1,
|
|
633
633
|
class: "h-5 w-5",
|
|
634
634
|
fill: "none",
|
|
635
635
|
stroke: "currentColor",
|
|
636
636
|
viewBox: "0 0 24 24"
|
|
637
637
|
};
|
|
638
|
-
const DEFAULT_MAX_LENGTH$
|
|
638
|
+
const DEFAULT_MAX_LENGTH$1 = 254;
|
|
639
639
|
const _sfc_main$I = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
|
|
640
640
|
__name: "TextInput",
|
|
641
641
|
props: {
|
|
@@ -666,7 +666,7 @@ const _sfc_main$I = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
|
|
|
666
666
|
const inputAttrs = computed(() => {
|
|
667
667
|
const { class: _class, type: _type, ...rest } = attrs;
|
|
668
668
|
if (rest.maxlength === void 0) {
|
|
669
|
-
rest.maxlength = DEFAULT_MAX_LENGTH$
|
|
669
|
+
rest.maxlength = DEFAULT_MAX_LENGTH$1;
|
|
670
670
|
}
|
|
671
671
|
return rest;
|
|
672
672
|
});
|
|
@@ -718,14 +718,14 @@ const _sfc_main$I = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
|
|
|
718
718
|
"aria-label": revealed.value ? "Hide password" : "Show password",
|
|
719
719
|
onClick: toggleVisibility
|
|
720
720
|
}, [
|
|
721
|
-
revealed.value ? (openBlock(), createElementBlock("svg", _hoisted_5$
|
|
721
|
+
revealed.value ? (openBlock(), createElementBlock("svg", _hoisted_5$8, [..._cache[2] || (_cache[2] = [
|
|
722
722
|
createElementVNode("path", {
|
|
723
723
|
"stroke-linecap": "round",
|
|
724
724
|
"stroke-linejoin": "round",
|
|
725
725
|
"stroke-width": "2",
|
|
726
726
|
d: "M13.875 18.825A10.05 10.05 0 0112 19c-5 0-9.27-3.11-11-7 1.01-2.27 2.78-4.1 5-5.32m3.08-1.3A9.96 9.96 0 0112 5c5 0 9.27 3.11 11 7a11.03 11.03 0 01-4.16 4.91M15 12a3 3 0 00-3-3m0 0a3 3 0 00-2.94 3.59M3 3l18 18"
|
|
727
727
|
}, null, -1)
|
|
728
|
-
])])) : (openBlock(), createElementBlock("svg", _hoisted_6$
|
|
728
|
+
])])) : (openBlock(), createElementBlock("svg", _hoisted_6$8, [..._cache[3] || (_cache[3] = [
|
|
729
729
|
createElementVNode("path", {
|
|
730
730
|
"stroke-linecap": "round",
|
|
731
731
|
"stroke-linejoin": "round",
|
|
@@ -745,7 +745,7 @@ const _sfc_main$I = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
|
|
|
745
745
|
}
|
|
746
746
|
});
|
|
747
747
|
const _hoisted_1$u = ["value", "disabled"];
|
|
748
|
-
const DEFAULT_MAX_LENGTH
|
|
748
|
+
const DEFAULT_MAX_LENGTH = 1e3;
|
|
749
749
|
const _sfc_main$H = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
|
|
750
750
|
__name: "TextArea",
|
|
751
751
|
props: {
|
|
@@ -772,7 +772,7 @@ const _sfc_main$H = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
|
|
|
772
772
|
const textareaAttrs = computed(() => {
|
|
773
773
|
const { class: _class, ...rest } = attrs;
|
|
774
774
|
if (rest.maxlength === void 0) {
|
|
775
|
-
rest.maxlength = DEFAULT_MAX_LENGTH
|
|
775
|
+
rest.maxlength = DEFAULT_MAX_LENGTH;
|
|
776
776
|
}
|
|
777
777
|
return rest;
|
|
778
778
|
});
|
|
@@ -1427,17 +1427,17 @@ const _hoisted_2$i = {
|
|
|
1427
1427
|
};
|
|
1428
1428
|
const _hoisted_3$c = ["value", "disabled"];
|
|
1429
1429
|
const _hoisted_4$9 = { class: "p-4" };
|
|
1430
|
-
const _hoisted_5$
|
|
1431
|
-
const _hoisted_6$
|
|
1432
|
-
const _hoisted_7$
|
|
1433
|
-
const _hoisted_8$
|
|
1434
|
-
const _hoisted_9$
|
|
1435
|
-
const _hoisted_10$
|
|
1436
|
-
const _hoisted_11$
|
|
1437
|
-
const _hoisted_12$
|
|
1438
|
-
const _hoisted_13$
|
|
1439
|
-
const _hoisted_14$
|
|
1440
|
-
const _hoisted_15$
|
|
1430
|
+
const _hoisted_5$7 = { class: "mb-4 flex items-center justify-between" };
|
|
1431
|
+
const _hoisted_6$7 = { class: "text-sm font-medium text-neutral-900 dark:text-neutral-50" };
|
|
1432
|
+
const _hoisted_7$7 = { class: "grid grid-cols-7 gap-1 mb-2" };
|
|
1433
|
+
const _hoisted_8$5 = { class: "grid grid-cols-7 gap-1" };
|
|
1434
|
+
const _hoisted_9$4 = ["disabled", "onClick", "onMouseenter"];
|
|
1435
|
+
const _hoisted_10$4 = { class: "mt-4 pt-4 border-t border-neutral-200 dark:border-neutral-800" };
|
|
1436
|
+
const _hoisted_11$4 = { class: "flex items-center justify-between" };
|
|
1437
|
+
const _hoisted_12$3 = { class: "text-xs text-neutral-500 dark:text-neutral-400" };
|
|
1438
|
+
const _hoisted_13$3 = { key: 0 };
|
|
1439
|
+
const _hoisted_14$3 = { key: 1 };
|
|
1440
|
+
const _hoisted_15$3 = { key: 2 };
|
|
1441
1441
|
const _sfc_main$D = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
|
|
1442
1442
|
__name: "DateRangeInput",
|
|
1443
1443
|
props: {
|
|
@@ -1725,7 +1725,7 @@ const _sfc_main$D = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
|
|
|
1725
1725
|
}, ["stop"]))
|
|
1726
1726
|
}, [
|
|
1727
1727
|
createElementVNode("div", _hoisted_4$9, [
|
|
1728
|
-
createElementVNode("div", _hoisted_5$
|
|
1728
|
+
createElementVNode("div", _hoisted_5$7, [
|
|
1729
1729
|
createElementVNode("button", {
|
|
1730
1730
|
type: "button",
|
|
1731
1731
|
class: "p-1 rounded hover:bg-neutral-100 dark:hover:bg-neutral-800 transition-colors",
|
|
@@ -1745,7 +1745,7 @@ const _sfc_main$D = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
|
|
|
1745
1745
|
})
|
|
1746
1746
|
], -1)
|
|
1747
1747
|
])]),
|
|
1748
|
-
createElementVNode("div", _hoisted_6$
|
|
1748
|
+
createElementVNode("div", _hoisted_6$7, toDisplayString(monthNames.value[currentMonth.value]) + " " + toDisplayString(currentYear.value), 1),
|
|
1749
1749
|
createElementVNode("button", {
|
|
1750
1750
|
type: "button",
|
|
1751
1751
|
class: "p-1 rounded hover:bg-neutral-100 dark:hover:bg-neutral-800 transition-colors",
|
|
@@ -1766,7 +1766,7 @@ const _sfc_main$D = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
|
|
|
1766
1766
|
], -1)
|
|
1767
1767
|
])])
|
|
1768
1768
|
]),
|
|
1769
|
-
createElementVNode("div", _hoisted_7$
|
|
1769
|
+
createElementVNode("div", _hoisted_7$7, [
|
|
1770
1770
|
(openBlock(true), createElementBlock(Fragment, null, renderList(dayNames.value, (day) => {
|
|
1771
1771
|
return openBlock(), createElementBlock("div", {
|
|
1772
1772
|
key: day,
|
|
@@ -1774,7 +1774,7 @@ const _sfc_main$D = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
|
|
|
1774
1774
|
}, toDisplayString(day), 1);
|
|
1775
1775
|
}), 128))
|
|
1776
1776
|
]),
|
|
1777
|
-
createElementVNode("div", _hoisted_8$
|
|
1777
|
+
createElementVNode("div", _hoisted_8$5, [
|
|
1778
1778
|
(openBlock(true), createElementBlock(Fragment, null, renderList(calendarDays.value, (day) => {
|
|
1779
1779
|
return openBlock(), createElementBlock("div", {
|
|
1780
1780
|
key: day.date.toISOString(),
|
|
@@ -1799,14 +1799,14 @@ const _sfc_main$D = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
|
|
|
1799
1799
|
onClick: ($event) => selectDate(day.date),
|
|
1800
1800
|
onMouseenter: ($event) => handleDateHover(day.date),
|
|
1801
1801
|
onMouseleave: handleDateLeave
|
|
1802
|
-
}, toDisplayString(day.date.getDate()), 43, _hoisted_9$
|
|
1802
|
+
}, toDisplayString(day.date.getDate()), 43, _hoisted_9$4)
|
|
1803
1803
|
]);
|
|
1804
1804
|
}), 128))
|
|
1805
1805
|
]),
|
|
1806
|
-
createElementVNode("div", _hoisted_10$
|
|
1807
|
-
createElementVNode("div", _hoisted_11$
|
|
1808
|
-
createElementVNode("div", _hoisted_12$
|
|
1809
|
-
startDate.value && endDate.value ? (openBlock(), createElementBlock("div", _hoisted_13$
|
|
1806
|
+
createElementVNode("div", _hoisted_10$4, [
|
|
1807
|
+
createElementVNode("div", _hoisted_11$4, [
|
|
1808
|
+
createElementVNode("div", _hoisted_12$3, [
|
|
1809
|
+
startDate.value && endDate.value ? (openBlock(), createElementBlock("div", _hoisted_13$3, " Range: " + toDisplayString(daysBetween.value) + " days ", 1)) : startDate.value ? (openBlock(), createElementBlock("div", _hoisted_14$3, " Select end date ")) : (openBlock(), createElementBlock("div", _hoisted_15$3, " Select start date "))
|
|
1810
1810
|
]),
|
|
1811
1811
|
startDate.value || endDate.value ? (openBlock(), createElementBlock("button", {
|
|
1812
1812
|
key: 0,
|
|
@@ -1830,10 +1830,10 @@ const _hoisted_4$8 = {
|
|
|
1830
1830
|
key: 0,
|
|
1831
1831
|
class: "mt-4 rounded-lg border border-neutral-200 bg-neutral-50 p-4 dark:border-neutral-800 dark:bg-neutral-900/50"
|
|
1832
1832
|
};
|
|
1833
|
-
const _hoisted_5$
|
|
1834
|
-
const _hoisted_6$
|
|
1835
|
-
const _hoisted_7$
|
|
1836
|
-
const _hoisted_8$
|
|
1833
|
+
const _hoisted_5$6 = { class: "flex items-center space-x-4" };
|
|
1834
|
+
const _hoisted_6$6 = ["src"];
|
|
1835
|
+
const _hoisted_7$6 = { class: "text-sm font-medium text-neutral-900 dark:text-neutral-50" };
|
|
1836
|
+
const _hoisted_8$4 = { class: "text-xs text-neutral-500 dark:text-neutral-200" };
|
|
1837
1837
|
const _sfc_main$C = {
|
|
1838
1838
|
__name: "ImageInput",
|
|
1839
1839
|
props: {
|
|
@@ -1880,15 +1880,15 @@ const _sfc_main$C = {
|
|
|
1880
1880
|
}), null, 16, _hoisted_3$b)
|
|
1881
1881
|
]),
|
|
1882
1882
|
props.currentImageUrl ? (openBlock(), createElementBlock("div", _hoisted_4$8, [
|
|
1883
|
-
createElementVNode("div", _hoisted_5$
|
|
1883
|
+
createElementVNode("div", _hoisted_5$6, [
|
|
1884
1884
|
createElementVNode("img", {
|
|
1885
1885
|
src: props.currentImageUrl,
|
|
1886
1886
|
alt: "Current logo",
|
|
1887
1887
|
class: "h-16 w-auto max-w-24 object-contain rounded-lg shadow-sm"
|
|
1888
|
-
}, null, 8, _hoisted_6$
|
|
1888
|
+
}, null, 8, _hoisted_6$6),
|
|
1889
1889
|
createElementVNode("div", null, [
|
|
1890
|
-
createElementVNode("p", _hoisted_7$
|
|
1891
|
-
createElementVNode("p", _hoisted_8$
|
|
1890
|
+
createElementVNode("p", _hoisted_7$6, toDisplayString(props.currentLabel), 1),
|
|
1891
|
+
createElementVNode("p", _hoisted_8$4, toDisplayString(props.currentSubtext), 1)
|
|
1892
1892
|
])
|
|
1893
1893
|
])
|
|
1894
1894
|
])) : createCommentVNode("", true)
|
|
@@ -2121,7 +2121,7 @@ const _sfc_main$y = {
|
|
|
2121
2121
|
return (_ctx, _cache) => {
|
|
2122
2122
|
return openBlock(), createElementBlock("div", _hoisted_1$m, [
|
|
2123
2123
|
(openBlock(true), createElementBlock(Fragment, null, renderList(normalizedOptions.value, (option) => {
|
|
2124
|
-
return openBlock(), createBlock(_sfc_main$
|
|
2124
|
+
return openBlock(), createBlock(_sfc_main$v, {
|
|
2125
2125
|
key: `radio-${__props.name ?? "group"}-${option}`,
|
|
2126
2126
|
type: "radio-input",
|
|
2127
2127
|
"model-value": props.modelValue,
|
|
@@ -2261,17 +2261,761 @@ const _sfc_main$x = {
|
|
|
2261
2261
|
};
|
|
2262
2262
|
}
|
|
2263
2263
|
};
|
|
2264
|
-
const _hoisted_1$k =
|
|
2265
|
-
const _hoisted_2$e =
|
|
2264
|
+
const _hoisted_1$k = { class: "relative w-full" };
|
|
2265
|
+
const _hoisted_2$e = ["name", "value", "disabled", "required"];
|
|
2266
|
+
const _hoisted_3$a = ["disabled", "aria-expanded"];
|
|
2267
|
+
const _hoisted_4$7 = { class: "color-picker-checker relative inline-flex size-10 shrink-0 overflow-hidden rounded-lg border border-neutral-200 dark:border-neutral-700" };
|
|
2268
|
+
const _hoisted_5$5 = { class: "min-w-0 flex-1" };
|
|
2269
|
+
const _hoisted_6$5 = { class: "block truncate font-mono text-sm text-neutral-900 dark:text-neutral-50" };
|
|
2270
|
+
const _hoisted_7$5 = { class: "rounded-2xl border border-neutral-200 bg-white/96 p-4 shadow-2xl shadow-neutral-950/12 backdrop-blur dark:border-neutral-800 dark:bg-neutral-950/96 dark:shadow-black/30" };
|
|
2271
|
+
const _hoisted_8$3 = { class: "flex items-start gap-3" };
|
|
2272
|
+
const _hoisted_9$3 = { class: "color-picker-checker relative size-14 shrink-0 overflow-hidden rounded-xl border border-neutral-200 dark:border-neutral-700" };
|
|
2273
|
+
const _hoisted_10$3 = { class: "min-w-0 flex-1" };
|
|
2274
|
+
const _hoisted_11$3 = { class: "truncate font-mono text-base text-neutral-900 dark:text-neutral-50" };
|
|
2275
|
+
const _hoisted_12$2 = ["disabled"];
|
|
2276
|
+
const _hoisted_13$2 = { class: "mt-4 space-y-4" };
|
|
2277
|
+
const _hoisted_14$2 = ["aria-label", "aria-valuenow"];
|
|
2278
|
+
const _hoisted_15$2 = {
|
|
2279
|
+
key: 0,
|
|
2280
|
+
class: "absolute inset-0 bg-[linear-gradient(to_right,#fff,transparent)]"
|
|
2281
|
+
};
|
|
2282
|
+
const _hoisted_16$1 = {
|
|
2283
|
+
key: 2,
|
|
2284
|
+
class: "absolute inset-0 bg-[linear-gradient(to_top,#000,transparent)]"
|
|
2285
|
+
};
|
|
2286
|
+
const _hoisted_17$1 = { class: "space-y-3" };
|
|
2287
|
+
const _hoisted_18$1 = {
|
|
2288
|
+
key: 0,
|
|
2289
|
+
class: "space-y-2"
|
|
2290
|
+
};
|
|
2291
|
+
const _hoisted_19 = { class: "flex items-center justify-between text-xs font-medium text-neutral-500 dark:text-neutral-400" };
|
|
2292
|
+
const _hoisted_20 = ["for"];
|
|
2293
|
+
const _hoisted_21 = ["id", "disabled", "value"];
|
|
2294
|
+
const _hoisted_22 = {
|
|
2295
|
+
key: 1,
|
|
2296
|
+
class: "space-y-2"
|
|
2297
|
+
};
|
|
2298
|
+
const _hoisted_23 = { class: "flex items-center justify-between text-xs font-medium text-neutral-500 dark:text-neutral-400" };
|
|
2299
|
+
const _hoisted_24 = ["for"];
|
|
2300
|
+
const _hoisted_25 = ["id", "disabled", "value"];
|
|
2301
|
+
const _hoisted_26 = { class: "space-y-2" };
|
|
2302
|
+
const _hoisted_27 = ["for"];
|
|
2303
|
+
const _hoisted_28 = ["id", "maxlength", "placeholder", "value", "disabled"];
|
|
2304
|
+
const DEFAULT_HEX = "#000000";
|
|
2305
|
+
const DEFAULT_ALPHA = 255;
|
|
2306
|
+
const PICKER_PANEL_WIDTH = 320;
|
|
2307
|
+
const PICKER_PANEL_GAP = 8;
|
|
2308
|
+
const _sfc_main$w = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
|
|
2309
|
+
__name: "ColorPicker",
|
|
2310
|
+
props: {
|
|
2311
|
+
modelValue: {
|
|
2312
|
+
type: [String, null],
|
|
2313
|
+
default: ""
|
|
2314
|
+
},
|
|
2315
|
+
disabled: {
|
|
2316
|
+
type: Boolean,
|
|
2317
|
+
default: false
|
|
2318
|
+
},
|
|
2319
|
+
disabledClass: {
|
|
2320
|
+
type: String,
|
|
2321
|
+
default: "!border-neutral-200 !bg-neutral-100 !text-neutral-500 dark:!border-neutral-800 dark:!bg-neutral-900 dark:!text-neutral-500"
|
|
2322
|
+
},
|
|
2323
|
+
allowAlpha: {
|
|
2324
|
+
type: Boolean,
|
|
2325
|
+
default: false
|
|
2326
|
+
},
|
|
2327
|
+
variant: {
|
|
2328
|
+
type: String,
|
|
2329
|
+
default: "classic"
|
|
2330
|
+
}
|
|
2331
|
+
},
|
|
2332
|
+
emits: ["update:modelValue", "blur"],
|
|
2333
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
2334
|
+
const props = __props;
|
|
2335
|
+
const emit = __emit;
|
|
2336
|
+
const attrs = useAttrs();
|
|
2337
|
+
const triggerRef = ref(null);
|
|
2338
|
+
const panelRef = ref(null);
|
|
2339
|
+
const hexInputRef = ref(null);
|
|
2340
|
+
const saturationRef = ref(null);
|
|
2341
|
+
const isOpen = ref(false);
|
|
2342
|
+
const supportsEyeDropper = ref(false);
|
|
2343
|
+
const lastEmittedValue = ref("");
|
|
2344
|
+
const hue = ref(220);
|
|
2345
|
+
const saturation = ref(84);
|
|
2346
|
+
const brightness = ref(92);
|
|
2347
|
+
const alpha = ref(DEFAULT_ALPHA);
|
|
2348
|
+
const displayValue = ref("");
|
|
2349
|
+
const panelStyle = ref({
|
|
2350
|
+
position: "fixed",
|
|
2351
|
+
left: "0px",
|
|
2352
|
+
top: "0px",
|
|
2353
|
+
visibility: "hidden",
|
|
2354
|
+
width: `${PICKER_PANEL_WIDTH}px`,
|
|
2355
|
+
zIndex: "9999"
|
|
2356
|
+
});
|
|
2357
|
+
let dragCleanup = null;
|
|
2358
|
+
let revealFrame = null;
|
|
2359
|
+
const clamp = (value, min, max) => Math.min(max, Math.max(min, value));
|
|
2360
|
+
const parseHexColor = (value) => {
|
|
2361
|
+
if (typeof value !== "string") {
|
|
2362
|
+
return null;
|
|
2363
|
+
}
|
|
2364
|
+
const trimmed = value.trim();
|
|
2365
|
+
if (trimmed === "") {
|
|
2366
|
+
return null;
|
|
2367
|
+
}
|
|
2368
|
+
const withHash = trimmed.startsWith("#") ? trimmed : `#${trimmed}`;
|
|
2369
|
+
const shortRgbMatch = withHash.match(/^#([0-9a-fA-F]{3})$/);
|
|
2370
|
+
if (shortRgbMatch) {
|
|
2371
|
+
const expanded = shortRgbMatch[1].split("").map((char) => char.repeat(2)).join("").toUpperCase();
|
|
2372
|
+
return { hex6: `#${expanded}`, alpha: DEFAULT_ALPHA };
|
|
2373
|
+
}
|
|
2374
|
+
const longRgbMatch = withHash.match(/^#([0-9a-fA-F]{6})$/);
|
|
2375
|
+
if (longRgbMatch) {
|
|
2376
|
+
return { hex6: `#${longRgbMatch[1].toUpperCase()}`, alpha: DEFAULT_ALPHA };
|
|
2377
|
+
}
|
|
2378
|
+
const shortRgbaMatch = withHash.match(/^#([0-9a-fA-F]{4})$/);
|
|
2379
|
+
if (shortRgbaMatch) {
|
|
2380
|
+
const expanded = shortRgbaMatch[1].split("").map((char) => char.repeat(2)).join("").toUpperCase();
|
|
2381
|
+
return {
|
|
2382
|
+
hex6: `#${expanded.slice(0, 6)}`,
|
|
2383
|
+
alpha: Number.parseInt(expanded.slice(6, 8), 16)
|
|
2384
|
+
};
|
|
2385
|
+
}
|
|
2386
|
+
const longRgbaMatch = withHash.match(/^#([0-9a-fA-F]{8})$/);
|
|
2387
|
+
if (longRgbaMatch) {
|
|
2388
|
+
const expanded = longRgbaMatch[1].toUpperCase();
|
|
2389
|
+
return {
|
|
2390
|
+
hex6: `#${expanded.slice(0, 6)}`,
|
|
2391
|
+
alpha: Number.parseInt(expanded.slice(6, 8), 16)
|
|
2392
|
+
};
|
|
2393
|
+
}
|
|
2394
|
+
return null;
|
|
2395
|
+
};
|
|
2396
|
+
const formatColor = (parsedColor, allowAlpha = false) => {
|
|
2397
|
+
if (!parsedColor) {
|
|
2398
|
+
return "";
|
|
2399
|
+
}
|
|
2400
|
+
if (!allowAlpha) {
|
|
2401
|
+
return parsedColor.hex6;
|
|
2402
|
+
}
|
|
2403
|
+
return `${parsedColor.hex6}${parsedColor.alpha.toString(16).padStart(2, "0").toUpperCase()}`;
|
|
2404
|
+
};
|
|
2405
|
+
const normalizeModelValue = (value, allowAlpha = false) => {
|
|
2406
|
+
const parsed = parseHexColor(value);
|
|
2407
|
+
if (!parsed) {
|
|
2408
|
+
return "";
|
|
2409
|
+
}
|
|
2410
|
+
return formatColor({
|
|
2411
|
+
hex6: parsed.hex6,
|
|
2412
|
+
alpha: allowAlpha ? parsed.alpha : DEFAULT_ALPHA
|
|
2413
|
+
}, allowAlpha);
|
|
2414
|
+
};
|
|
2415
|
+
const hexToRgb = (hex6) => {
|
|
2416
|
+
const normalized = hex6.replace("#", "");
|
|
2417
|
+
return {
|
|
2418
|
+
red: Number.parseInt(normalized.slice(0, 2), 16),
|
|
2419
|
+
green: Number.parseInt(normalized.slice(2, 4), 16),
|
|
2420
|
+
blue: Number.parseInt(normalized.slice(4, 6), 16)
|
|
2421
|
+
};
|
|
2422
|
+
};
|
|
2423
|
+
const rgbToHex = ({ red, green, blue }) => {
|
|
2424
|
+
const toHex = (value) => clamp(Math.round(value), 0, 255).toString(16).padStart(2, "0").toUpperCase();
|
|
2425
|
+
return `#${toHex(red)}${toHex(green)}${toHex(blue)}`;
|
|
2426
|
+
};
|
|
2427
|
+
const rgbToHsv = ({ red, green, blue }) => {
|
|
2428
|
+
const r = red / 255;
|
|
2429
|
+
const g = green / 255;
|
|
2430
|
+
const b = blue / 255;
|
|
2431
|
+
const max = Math.max(r, g, b);
|
|
2432
|
+
const min = Math.min(r, g, b);
|
|
2433
|
+
const delta = max - min;
|
|
2434
|
+
let nextHue = hue.value;
|
|
2435
|
+
if (delta !== 0) {
|
|
2436
|
+
if (max === r) {
|
|
2437
|
+
nextHue = 60 * ((g - b) / delta % 6);
|
|
2438
|
+
} else if (max === g) {
|
|
2439
|
+
nextHue = 60 * ((b - r) / delta + 2);
|
|
2440
|
+
} else {
|
|
2441
|
+
nextHue = 60 * ((r - g) / delta + 4);
|
|
2442
|
+
}
|
|
2443
|
+
}
|
|
2444
|
+
if (nextHue < 0) {
|
|
2445
|
+
nextHue += 360;
|
|
2446
|
+
}
|
|
2447
|
+
const nextSaturation = max === 0 ? 0 : delta / max * 100;
|
|
2448
|
+
const nextBrightness = max * 100;
|
|
2449
|
+
return {
|
|
2450
|
+
hue: clamp(nextHue, 0, 360),
|
|
2451
|
+
saturation: clamp(nextSaturation, 0, 100),
|
|
2452
|
+
brightness: clamp(nextBrightness, 0, 100)
|
|
2453
|
+
};
|
|
2454
|
+
};
|
|
2455
|
+
const hsvToRgb = ({ hue: colorHue, saturation: colorSaturation, brightness: colorBrightness }) => {
|
|
2456
|
+
const h2 = (colorHue % 360 + 360) % 360;
|
|
2457
|
+
const s = clamp(colorSaturation, 0, 100) / 100;
|
|
2458
|
+
const v = clamp(colorBrightness, 0, 100) / 100;
|
|
2459
|
+
const chroma = v * s;
|
|
2460
|
+
const x = chroma * (1 - Math.abs(h2 / 60 % 2 - 1));
|
|
2461
|
+
const match = v - chroma;
|
|
2462
|
+
let rPrime = 0;
|
|
2463
|
+
let gPrime = 0;
|
|
2464
|
+
let bPrime = 0;
|
|
2465
|
+
if (h2 < 60) {
|
|
2466
|
+
rPrime = chroma;
|
|
2467
|
+
gPrime = x;
|
|
2468
|
+
} else if (h2 < 120) {
|
|
2469
|
+
rPrime = x;
|
|
2470
|
+
gPrime = chroma;
|
|
2471
|
+
} else if (h2 < 180) {
|
|
2472
|
+
gPrime = chroma;
|
|
2473
|
+
bPrime = x;
|
|
2474
|
+
} else if (h2 < 240) {
|
|
2475
|
+
gPrime = x;
|
|
2476
|
+
bPrime = chroma;
|
|
2477
|
+
} else if (h2 < 300) {
|
|
2478
|
+
rPrime = x;
|
|
2479
|
+
bPrime = chroma;
|
|
2480
|
+
} else {
|
|
2481
|
+
rPrime = chroma;
|
|
2482
|
+
bPrime = x;
|
|
2483
|
+
}
|
|
2484
|
+
return {
|
|
2485
|
+
red: Math.round((rPrime + match) * 255),
|
|
2486
|
+
green: Math.round((gPrime + match) * 255),
|
|
2487
|
+
blue: Math.round((bPrime + match) * 255)
|
|
2488
|
+
};
|
|
2489
|
+
};
|
|
2490
|
+
const alphaPercentFromByte = (value) => Math.round(clamp(value, 0, 255) * 100 / 255);
|
|
2491
|
+
const alphaByteFromPercent = (value) => Math.round(clamp(Number(value) || 0, 0, 100) * 255 / 100);
|
|
2492
|
+
const currentRgb = computed(() => hsvToRgb({
|
|
2493
|
+
hue: hue.value,
|
|
2494
|
+
saturation: saturation.value,
|
|
2495
|
+
brightness: brightness.value
|
|
2496
|
+
}));
|
|
2497
|
+
const currentColor = computed(() => ({
|
|
2498
|
+
hex6: rgbToHex(currentRgb.value),
|
|
2499
|
+
alpha: clamp(alpha.value, 0, 255)
|
|
2500
|
+
}));
|
|
2501
|
+
const normalizedValue = computed(() => normalizeModelValue(props.modelValue, props.allowAlpha));
|
|
2502
|
+
const emittedValue = computed(() => formatColor(currentColor.value, props.allowAlpha));
|
|
2503
|
+
const opacityPercent = computed(() => alphaPercentFromByte(alpha.value));
|
|
2504
|
+
const swatchColor = computed(() => {
|
|
2505
|
+
const { red, green, blue } = currentRgb.value;
|
|
2506
|
+
return `rgba(${red}, ${green}, ${blue}, ${clamp(alpha.value / 255, 0, 1)})`;
|
|
2507
|
+
});
|
|
2508
|
+
const hueColor = computed(() => rgbToHex(hsvToRgb({ hue: hue.value, saturation: 100, brightness: 100 })));
|
|
2509
|
+
const isRainbowVariant = computed(() => props.variant === "rainbow");
|
|
2510
|
+
const alphaGradient = computed(() => {
|
|
2511
|
+
const { red, green, blue } = currentRgb.value;
|
|
2512
|
+
return `linear-gradient(90deg, rgba(${red}, ${green}, ${blue}, 0) 0%, rgba(${red}, ${green}, ${blue}, 1) 100%)`;
|
|
2513
|
+
});
|
|
2514
|
+
const saturationHandleStyle = computed(() => ({
|
|
2515
|
+
left: `${isRainbowVariant.value ? hue.value / 360 * 100 : saturation.value}%`,
|
|
2516
|
+
top: `${isRainbowVariant.value ? brightness.value >= 100 ? saturation.value / 2 : 50 + (100 - brightness.value) / 2 : 100 - brightness.value}%`
|
|
2517
|
+
}));
|
|
2518
|
+
const saturationAreaStyle = computed(() => isRainbowVariant.value ? {
|
|
2519
|
+
background: "linear-gradient(90deg, #ff0000 0%, #ffff00 16.66%, #00ff00 33.33%, #00ffff 50%, #0000ff 66.66%, #ff00ff 83.33%, #ff0000 100%)"
|
|
2520
|
+
} : {
|
|
2521
|
+
backgroundColor: hueColor.value
|
|
2522
|
+
});
|
|
2523
|
+
const saturationAreaLabel = computed(() => isRainbowVariant.value ? `Rainbow color area for ${emittedValue.value}` : `Saturation and brightness for ${emittedValue.value}`);
|
|
2524
|
+
const fieldId = computed(() => {
|
|
2525
|
+
const id = attrs.id;
|
|
2526
|
+
return typeof id === "string" && id !== "" ? id : void 0;
|
|
2527
|
+
});
|
|
2528
|
+
const fieldName = computed(() => {
|
|
2529
|
+
const name = attrs.name;
|
|
2530
|
+
return typeof name === "string" && name !== "" ? name : void 0;
|
|
2531
|
+
});
|
|
2532
|
+
const triggerAttrs = computed(() => {
|
|
2533
|
+
const {
|
|
2534
|
+
class: _class,
|
|
2535
|
+
name: _name,
|
|
2536
|
+
autofocus: _autofocus,
|
|
2537
|
+
required: _required,
|
|
2538
|
+
placeholder: _placeholder,
|
|
2539
|
+
maxlength: _maxlength,
|
|
2540
|
+
...rest
|
|
2541
|
+
} = attrs;
|
|
2542
|
+
return {
|
|
2543
|
+
...rest,
|
|
2544
|
+
id: fieldId.value
|
|
2545
|
+
};
|
|
2546
|
+
});
|
|
2547
|
+
const triggerClasses = computed(() => [
|
|
2548
|
+
"group flex w-full items-center gap-3 rounded-lg border border-neutral-200 bg-white px-3 py-3 text-left text-sm text-neutral-950 shadow-sm outline-none transition-colors focus:border-neutral-900 focus:ring-2 focus:ring-neutral-950/10 dark:border-neutral-800 dark:bg-neutral-950 dark:text-neutral-50 dark:focus:border-neutral-100 dark:focus:ring-neutral-100/10",
|
|
2549
|
+
attrs.class,
|
|
2550
|
+
props.disabled ? props.disabledClass : ""
|
|
2551
|
+
]);
|
|
2552
|
+
const hiddenInputRequired = computed(() => Boolean(attrs.required) && !props.disabled);
|
|
2553
|
+
const hexInputPlaceholder = computed(() => props.allowAlpha ? "#RRGGBBAA" : "#RRGGBB");
|
|
2554
|
+
const canUseEyeDropper = computed(() => supportsEyeDropper.value && !props.disabled);
|
|
2555
|
+
const normalizedVariant = computed(() => isRainbowVariant.value ? "rainbow" : "classic");
|
|
2556
|
+
const syncFromNormalizedValue = (value) => {
|
|
2557
|
+
const parsed = parseHexColor(value) ?? { hex6: DEFAULT_HEX, alpha: DEFAULT_ALPHA };
|
|
2558
|
+
const rgb = hexToRgb(parsed.hex6);
|
|
2559
|
+
const hsv = rgbToHsv(rgb);
|
|
2560
|
+
hue.value = hsv.hue;
|
|
2561
|
+
saturation.value = hsv.saturation;
|
|
2562
|
+
brightness.value = hsv.brightness;
|
|
2563
|
+
alpha.value = props.allowAlpha ? parsed.alpha : DEFAULT_ALPHA;
|
|
2564
|
+
displayValue.value = formatColor({
|
|
2565
|
+
hex6: parsed.hex6,
|
|
2566
|
+
alpha: props.allowAlpha ? parsed.alpha : DEFAULT_ALPHA
|
|
2567
|
+
}, props.allowAlpha);
|
|
2568
|
+
};
|
|
2569
|
+
const emitCurrentColor = () => {
|
|
2570
|
+
displayValue.value = emittedValue.value;
|
|
2571
|
+
lastEmittedValue.value = emittedValue.value;
|
|
2572
|
+
emit("update:modelValue", emittedValue.value);
|
|
2573
|
+
};
|
|
2574
|
+
watch([normalizedValue, () => props.allowAlpha, normalizedVariant], ([nextValue, allowAlpha, variant], [, previousAllowAlpha, previousVariant]) => {
|
|
2575
|
+
if (allowAlpha === previousAllowAlpha && nextValue === lastEmittedValue.value) {
|
|
2576
|
+
displayValue.value = nextValue;
|
|
2577
|
+
lastEmittedValue.value = "";
|
|
2578
|
+
return;
|
|
2579
|
+
}
|
|
2580
|
+
if (variant !== previousVariant) {
|
|
2581
|
+
lastEmittedValue.value = "";
|
|
2582
|
+
}
|
|
2583
|
+
lastEmittedValue.value = "";
|
|
2584
|
+
syncFromNormalizedValue(nextValue);
|
|
2585
|
+
});
|
|
2586
|
+
const updatePanelPosition = () => {
|
|
2587
|
+
if (!triggerRef.value || !panelRef.value) {
|
|
2588
|
+
return;
|
|
2589
|
+
}
|
|
2590
|
+
const rect = triggerRef.value.getBoundingClientRect();
|
|
2591
|
+
const panelWidth = panelRef.value.offsetWidth || PICKER_PANEL_WIDTH;
|
|
2592
|
+
const panelHeight = panelRef.value.offsetHeight || 0;
|
|
2593
|
+
const viewportWidth = window.innerWidth;
|
|
2594
|
+
const viewportHeight = window.innerHeight;
|
|
2595
|
+
let left = rect.left;
|
|
2596
|
+
if (left + panelWidth > viewportWidth - PICKER_PANEL_GAP) {
|
|
2597
|
+
left = viewportWidth - panelWidth - PICKER_PANEL_GAP;
|
|
2598
|
+
}
|
|
2599
|
+
left = Math.max(PICKER_PANEL_GAP, left);
|
|
2600
|
+
const spaceBelow = viewportHeight - rect.bottom - PICKER_PANEL_GAP;
|
|
2601
|
+
const spaceAbove = rect.top - PICKER_PANEL_GAP;
|
|
2602
|
+
const openUpward = spaceBelow < panelHeight && spaceAbove > spaceBelow;
|
|
2603
|
+
panelStyle.value = {
|
|
2604
|
+
position: "fixed",
|
|
2605
|
+
left: `${left}px`,
|
|
2606
|
+
...openUpward ? { bottom: `${viewportHeight - rect.top + PICKER_PANEL_GAP}px` } : { top: `${rect.bottom + PICKER_PANEL_GAP}px` },
|
|
2607
|
+
width: `${panelWidth}px`,
|
|
2608
|
+
zIndex: "9999",
|
|
2609
|
+
visibility: panelStyle.value.visibility
|
|
2610
|
+
};
|
|
2611
|
+
};
|
|
2612
|
+
const revealPanel = async () => {
|
|
2613
|
+
if (!isOpen.value) {
|
|
2614
|
+
return;
|
|
2615
|
+
}
|
|
2616
|
+
if (revealFrame !== null) {
|
|
2617
|
+
cancelAnimationFrame(revealFrame);
|
|
2618
|
+
revealFrame = null;
|
|
2619
|
+
}
|
|
2620
|
+
panelStyle.value = {
|
|
2621
|
+
...panelStyle.value,
|
|
2622
|
+
visibility: "hidden"
|
|
2623
|
+
};
|
|
2624
|
+
await nextTick();
|
|
2625
|
+
updatePanelPosition();
|
|
2626
|
+
revealFrame = requestAnimationFrame(() => {
|
|
2627
|
+
if (!isOpen.value) {
|
|
2628
|
+
return;
|
|
2629
|
+
}
|
|
2630
|
+
panelStyle.value = {
|
|
2631
|
+
...panelStyle.value,
|
|
2632
|
+
visibility: "visible"
|
|
2633
|
+
};
|
|
2634
|
+
});
|
|
2635
|
+
};
|
|
2636
|
+
const closePanel = () => {
|
|
2637
|
+
isOpen.value = false;
|
|
2638
|
+
};
|
|
2639
|
+
const togglePanel = async () => {
|
|
2640
|
+
if (props.disabled) {
|
|
2641
|
+
return;
|
|
2642
|
+
}
|
|
2643
|
+
isOpen.value = !isOpen.value;
|
|
2644
|
+
if (isOpen.value) {
|
|
2645
|
+
displayValue.value = emittedValue.value;
|
|
2646
|
+
await revealPanel();
|
|
2647
|
+
await nextTick();
|
|
2648
|
+
hexInputRef.value?.focus();
|
|
2649
|
+
hexInputRef.value?.select();
|
|
2650
|
+
}
|
|
2651
|
+
};
|
|
2652
|
+
const closeOnOutsidePointer = (event) => {
|
|
2653
|
+
if (!isOpen.value) {
|
|
2654
|
+
return;
|
|
2655
|
+
}
|
|
2656
|
+
const target = event.target;
|
|
2657
|
+
if (!(target instanceof Node)) {
|
|
2658
|
+
return;
|
|
2659
|
+
}
|
|
2660
|
+
if (triggerRef.value?.contains(target) || panelRef.value?.contains(target)) {
|
|
2661
|
+
return;
|
|
2662
|
+
}
|
|
2663
|
+
closePanel();
|
|
2664
|
+
};
|
|
2665
|
+
const closeOnEscape = (event) => {
|
|
2666
|
+
if (event.key === "Escape" && isOpen.value) {
|
|
2667
|
+
closePanel();
|
|
2668
|
+
triggerRef.value?.focus();
|
|
2669
|
+
}
|
|
2670
|
+
};
|
|
2671
|
+
const handleViewportChange = () => {
|
|
2672
|
+
if (isOpen.value) {
|
|
2673
|
+
updatePanelPosition();
|
|
2674
|
+
}
|
|
2675
|
+
};
|
|
2676
|
+
const beginDrag = (event, updateFromPointer) => {
|
|
2677
|
+
if (props.disabled) {
|
|
2678
|
+
return;
|
|
2679
|
+
}
|
|
2680
|
+
event.preventDefault();
|
|
2681
|
+
updateFromPointer(event);
|
|
2682
|
+
const handleMove = (moveEvent) => updateFromPointer(moveEvent);
|
|
2683
|
+
const handleUp = () => {
|
|
2684
|
+
window.removeEventListener("pointermove", handleMove);
|
|
2685
|
+
window.removeEventListener("pointerup", handleUp);
|
|
2686
|
+
dragCleanup = null;
|
|
2687
|
+
};
|
|
2688
|
+
window.addEventListener("pointermove", handleMove);
|
|
2689
|
+
window.addEventListener("pointerup", handleUp, { once: true });
|
|
2690
|
+
dragCleanup = handleUp;
|
|
2691
|
+
};
|
|
2692
|
+
const updateFromSaturationPointer = (event) => {
|
|
2693
|
+
if (!saturationRef.value) {
|
|
2694
|
+
return;
|
|
2695
|
+
}
|
|
2696
|
+
const rect = saturationRef.value.getBoundingClientRect();
|
|
2697
|
+
const xPercent = clamp((event.clientX - rect.left) / rect.width * 100, 0, 100);
|
|
2698
|
+
const yPercent = clamp((event.clientY - rect.top) / rect.height * 100, 0, 100);
|
|
2699
|
+
if (isRainbowVariant.value) {
|
|
2700
|
+
hue.value = clamp(xPercent / 100 * 360, 0, 360);
|
|
2701
|
+
if (yPercent <= 50) {
|
|
2702
|
+
saturation.value = clamp(yPercent / 50 * 100, 0, 100);
|
|
2703
|
+
brightness.value = 100;
|
|
2704
|
+
} else {
|
|
2705
|
+
saturation.value = 100;
|
|
2706
|
+
brightness.value = clamp(100 - (yPercent - 50) / 50 * 100, 0, 100);
|
|
2707
|
+
}
|
|
2708
|
+
} else {
|
|
2709
|
+
saturation.value = xPercent;
|
|
2710
|
+
brightness.value = clamp(100 - yPercent, 0, 100);
|
|
2711
|
+
}
|
|
2712
|
+
emitCurrentColor();
|
|
2713
|
+
};
|
|
2714
|
+
const updateFromSaturationKey = (event) => {
|
|
2715
|
+
const step = event.shiftKey ? 10 : 2;
|
|
2716
|
+
if (event.key === "ArrowLeft") {
|
|
2717
|
+
if (isRainbowVariant.value) {
|
|
2718
|
+
hue.value = clamp(hue.value - step * 3.6, 0, 360);
|
|
2719
|
+
} else {
|
|
2720
|
+
saturation.value = clamp(saturation.value - step, 0, 100);
|
|
2721
|
+
}
|
|
2722
|
+
} else if (event.key === "ArrowRight") {
|
|
2723
|
+
if (isRainbowVariant.value) {
|
|
2724
|
+
hue.value = clamp(hue.value + step * 3.6, 0, 360);
|
|
2725
|
+
} else {
|
|
2726
|
+
saturation.value = clamp(saturation.value + step, 0, 100);
|
|
2727
|
+
}
|
|
2728
|
+
} else if (event.key === "ArrowUp") {
|
|
2729
|
+
if (isRainbowVariant.value) {
|
|
2730
|
+
if (brightness.value < 100) {
|
|
2731
|
+
brightness.value = clamp(brightness.value + step, 0, 100);
|
|
2732
|
+
} else {
|
|
2733
|
+
saturation.value = clamp(saturation.value - step, 0, 100);
|
|
2734
|
+
}
|
|
2735
|
+
} else {
|
|
2736
|
+
brightness.value = clamp(brightness.value + step, 0, 100);
|
|
2737
|
+
}
|
|
2738
|
+
} else if (event.key === "ArrowDown") {
|
|
2739
|
+
if (isRainbowVariant.value) {
|
|
2740
|
+
if (saturation.value < 100 || brightness.value === 100) {
|
|
2741
|
+
saturation.value = clamp(saturation.value + step, 0, 100);
|
|
2742
|
+
} else {
|
|
2743
|
+
brightness.value = clamp(brightness.value - step, 0, 100);
|
|
2744
|
+
}
|
|
2745
|
+
} else {
|
|
2746
|
+
brightness.value = clamp(brightness.value - step, 0, 100);
|
|
2747
|
+
}
|
|
2748
|
+
} else {
|
|
2749
|
+
return;
|
|
2750
|
+
}
|
|
2751
|
+
event.preventDefault();
|
|
2752
|
+
emitCurrentColor();
|
|
2753
|
+
};
|
|
2754
|
+
const handleHueInput = (event) => {
|
|
2755
|
+
hue.value = clamp(Number(event.target?.value ?? hue.value) || 0, 0, 360);
|
|
2756
|
+
emitCurrentColor();
|
|
2757
|
+
};
|
|
2758
|
+
const handleAlphaInput = (event) => {
|
|
2759
|
+
alpha.value = alphaByteFromPercent(event.target?.value ?? opacityPercent.value);
|
|
2760
|
+
emitCurrentColor();
|
|
2761
|
+
};
|
|
2762
|
+
const handleHexInput = (event) => {
|
|
2763
|
+
const nextValue = String(event.target?.value ?? "");
|
|
2764
|
+
displayValue.value = nextValue;
|
|
2765
|
+
const parsed = parseHexColor(nextValue);
|
|
2766
|
+
if (!parsed) {
|
|
2767
|
+
return;
|
|
2768
|
+
}
|
|
2769
|
+
const normalized = formatColor({
|
|
2770
|
+
hex6: parsed.hex6,
|
|
2771
|
+
alpha: props.allowAlpha ? parsed.alpha : DEFAULT_ALPHA
|
|
2772
|
+
}, props.allowAlpha);
|
|
2773
|
+
syncFromNormalizedValue(normalized);
|
|
2774
|
+
lastEmittedValue.value = normalized;
|
|
2775
|
+
emit("update:modelValue", normalized);
|
|
2776
|
+
};
|
|
2777
|
+
const handleHexBlur = (event) => {
|
|
2778
|
+
displayValue.value = emittedValue.value;
|
|
2779
|
+
emit("blur", event);
|
|
2780
|
+
};
|
|
2781
|
+
const pickFromScreen = async () => {
|
|
2782
|
+
if (!canUseEyeDropper.value) {
|
|
2783
|
+
return;
|
|
2784
|
+
}
|
|
2785
|
+
try {
|
|
2786
|
+
const eyeDropper = new window.EyeDropper();
|
|
2787
|
+
const result = await eyeDropper.open();
|
|
2788
|
+
const picked = parseHexColor(result?.sRGBHex);
|
|
2789
|
+
if (!picked) {
|
|
2790
|
+
return;
|
|
2791
|
+
}
|
|
2792
|
+
const normalized = formatColor({
|
|
2793
|
+
hex6: picked.hex6,
|
|
2794
|
+
alpha: props.allowAlpha ? alpha.value : DEFAULT_ALPHA
|
|
2795
|
+
}, props.allowAlpha);
|
|
2796
|
+
syncFromNormalizedValue(normalized);
|
|
2797
|
+
lastEmittedValue.value = normalized;
|
|
2798
|
+
emit("update:modelValue", normalized);
|
|
2799
|
+
} catch (error) {
|
|
2800
|
+
if (error?.name !== "AbortError") {
|
|
2801
|
+
console.error("EyeDropper failed", error);
|
|
2802
|
+
}
|
|
2803
|
+
}
|
|
2804
|
+
};
|
|
2805
|
+
onMounted(() => {
|
|
2806
|
+
supportsEyeDropper.value = typeof window !== "undefined" && "EyeDropper" in window;
|
|
2807
|
+
syncFromNormalizedValue(normalizedValue.value);
|
|
2808
|
+
if (attrs.autofocus !== void 0) {
|
|
2809
|
+
triggerRef.value?.focus();
|
|
2810
|
+
}
|
|
2811
|
+
document.addEventListener("pointerdown", closeOnOutsidePointer, true);
|
|
2812
|
+
document.addEventListener("keydown", closeOnEscape);
|
|
2813
|
+
window.addEventListener("resize", handleViewportChange);
|
|
2814
|
+
window.addEventListener("scroll", handleViewportChange, true);
|
|
2815
|
+
});
|
|
2816
|
+
onUnmounted(() => {
|
|
2817
|
+
if (revealFrame !== null) {
|
|
2818
|
+
cancelAnimationFrame(revealFrame);
|
|
2819
|
+
}
|
|
2820
|
+
dragCleanup?.();
|
|
2821
|
+
document.removeEventListener("pointerdown", closeOnOutsidePointer, true);
|
|
2822
|
+
document.removeEventListener("keydown", closeOnEscape);
|
|
2823
|
+
window.removeEventListener("resize", handleViewportChange);
|
|
2824
|
+
window.removeEventListener("scroll", handleViewportChange, true);
|
|
2825
|
+
});
|
|
2826
|
+
watch(isOpen, (open) => {
|
|
2827
|
+
if (open) {
|
|
2828
|
+
revealPanel();
|
|
2829
|
+
}
|
|
2830
|
+
});
|
|
2831
|
+
__expose({ focus: () => triggerRef.value?.focus() });
|
|
2832
|
+
return (_ctx, _cache) => {
|
|
2833
|
+
return openBlock(), createElementBlock("div", _hoisted_1$k, [
|
|
2834
|
+
fieldName.value ? (openBlock(), createElementBlock("input", {
|
|
2835
|
+
key: 0,
|
|
2836
|
+
type: "hidden",
|
|
2837
|
+
name: fieldName.value,
|
|
2838
|
+
value: emittedValue.value,
|
|
2839
|
+
disabled: props.disabled,
|
|
2840
|
+
required: hiddenInputRequired.value
|
|
2841
|
+
}, null, 8, _hoisted_2$e)) : createCommentVNode("", true),
|
|
2842
|
+
createElementVNode("button", mergeProps({
|
|
2843
|
+
ref_key: "triggerRef",
|
|
2844
|
+
ref: triggerRef
|
|
2845
|
+
}, triggerAttrs.value, {
|
|
2846
|
+
type: "button",
|
|
2847
|
+
class: triggerClasses.value,
|
|
2848
|
+
disabled: props.disabled,
|
|
2849
|
+
"aria-expanded": isOpen.value,
|
|
2850
|
+
"aria-haspopup": "dialog",
|
|
2851
|
+
onClick: togglePanel
|
|
2852
|
+
}), [
|
|
2853
|
+
createElementVNode("span", _hoisted_4$7, [
|
|
2854
|
+
createElementVNode("span", {
|
|
2855
|
+
class: "absolute inset-0",
|
|
2856
|
+
style: normalizeStyle({ backgroundColor: swatchColor.value })
|
|
2857
|
+
}, null, 4)
|
|
2858
|
+
]),
|
|
2859
|
+
createElementVNode("span", _hoisted_5$5, [
|
|
2860
|
+
_cache[1] || (_cache[1] = createElementVNode("span", { class: "block text-xs font-medium uppercase tracking-[0.16em] text-neutral-500 dark:text-neutral-400" }, "Color", -1)),
|
|
2861
|
+
createElementVNode("span", _hoisted_6$5, toDisplayString(emittedValue.value), 1)
|
|
2862
|
+
]),
|
|
2863
|
+
createVNode(unref(ChevronDownIcon), {
|
|
2864
|
+
class: normalizeClass(["size-4 shrink-0 text-neutral-400 transition-transform dark:text-neutral-500", isOpen.value ? "rotate-180" : ""])
|
|
2865
|
+
}, null, 8, ["class"])
|
|
2866
|
+
], 16, _hoisted_3$a),
|
|
2867
|
+
(openBlock(), createBlock(Teleport, { to: "body" }, [
|
|
2868
|
+
createVNode(Transition, {
|
|
2869
|
+
"enter-active-class": "transition duration-150 ease-out",
|
|
2870
|
+
"enter-from-class": "opacity-0 translate-y-1",
|
|
2871
|
+
"enter-to-class": "opacity-100 translate-y-0",
|
|
2872
|
+
"leave-active-class": "transition duration-100 ease-in",
|
|
2873
|
+
"leave-from-class": "opacity-100 translate-y-0",
|
|
2874
|
+
"leave-to-class": "opacity-0 translate-y-1"
|
|
2875
|
+
}, {
|
|
2876
|
+
default: withCtx(() => [
|
|
2877
|
+
isOpen.value ? (openBlock(), createElementBlock("div", {
|
|
2878
|
+
key: 0,
|
|
2879
|
+
ref_key: "panelRef",
|
|
2880
|
+
ref: panelRef,
|
|
2881
|
+
class: "z-50",
|
|
2882
|
+
style: normalizeStyle(panelStyle.value)
|
|
2883
|
+
}, [
|
|
2884
|
+
createElementVNode("div", _hoisted_7$5, [
|
|
2885
|
+
createElementVNode("div", _hoisted_8$3, [
|
|
2886
|
+
createElementVNode("div", _hoisted_9$3, [
|
|
2887
|
+
createElementVNode("span", {
|
|
2888
|
+
class: "absolute inset-0",
|
|
2889
|
+
style: normalizeStyle({ backgroundColor: swatchColor.value })
|
|
2890
|
+
}, null, 4)
|
|
2891
|
+
]),
|
|
2892
|
+
createElementVNode("div", _hoisted_10$3, [
|
|
2893
|
+
_cache[2] || (_cache[2] = createElementVNode("p", { class: "text-xs font-medium uppercase tracking-[0.16em] text-neutral-500 dark:text-neutral-400" }, "Selected color", -1)),
|
|
2894
|
+
createElementVNode("p", _hoisted_11$3, toDisplayString(emittedValue.value), 1)
|
|
2895
|
+
]),
|
|
2896
|
+
supportsEyeDropper.value ? (openBlock(), createElementBlock("button", {
|
|
2897
|
+
key: 0,
|
|
2898
|
+
type: "button",
|
|
2899
|
+
class: normalizeClass(["inline-flex size-10 items-center justify-center rounded-xl border border-neutral-200 text-neutral-600 transition-colors hover:bg-neutral-100 focus:outline-none focus:ring-2 focus:ring-neutral-950/10 dark:border-neutral-800 dark:text-neutral-300 dark:hover:bg-neutral-900 dark:focus:ring-neutral-100/10", props.disabled ? "cursor-not-allowed opacity-50" : ""]),
|
|
2900
|
+
disabled: props.disabled,
|
|
2901
|
+
"aria-label": "Pick color from screen",
|
|
2902
|
+
onClick: pickFromScreen
|
|
2903
|
+
}, [
|
|
2904
|
+
createVNode(unref(EyeDropperIcon), { class: "size-5" })
|
|
2905
|
+
], 10, _hoisted_12$2)) : createCommentVNode("", true)
|
|
2906
|
+
]),
|
|
2907
|
+
createElementVNode("div", _hoisted_13$2, [
|
|
2908
|
+
createElementVNode("div", {
|
|
2909
|
+
ref_key: "saturationRef",
|
|
2910
|
+
ref: saturationRef,
|
|
2911
|
+
class: "relative h-48 cursor-crosshair overflow-hidden rounded-2xl border border-neutral-200 dark:border-neutral-800",
|
|
2912
|
+
style: normalizeStyle(saturationAreaStyle.value),
|
|
2913
|
+
tabindex: "0",
|
|
2914
|
+
role: "slider",
|
|
2915
|
+
"aria-label": saturationAreaLabel.value,
|
|
2916
|
+
"aria-valuemin": 0,
|
|
2917
|
+
"aria-valuemax": 100,
|
|
2918
|
+
"aria-valuenow": Math.round(saturation.value),
|
|
2919
|
+
onPointerdown: _cache[0] || (_cache[0] = ($event) => beginDrag($event, updateFromSaturationPointer)),
|
|
2920
|
+
onKeydown: updateFromSaturationKey
|
|
2921
|
+
}, [
|
|
2922
|
+
!isRainbowVariant.value ? (openBlock(), createElementBlock("div", _hoisted_15$2)) : createCommentVNode("", true),
|
|
2923
|
+
isRainbowVariant.value ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
|
|
2924
|
+
_cache[3] || (_cache[3] = createElementVNode("div", { class: "absolute inset-x-0 top-0 h-1/2 bg-[linear-gradient(to_bottom,#fff,transparent)]" }, null, -1)),
|
|
2925
|
+
_cache[4] || (_cache[4] = createElementVNode("div", { class: "absolute inset-x-0 bottom-0 h-1/2 bg-[linear-gradient(to_bottom,transparent,#000)]" }, null, -1))
|
|
2926
|
+
], 64)) : (openBlock(), createElementBlock("div", _hoisted_16$1)),
|
|
2927
|
+
createElementVNode("span", {
|
|
2928
|
+
class: "pointer-events-none absolute size-4 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-white shadow-[0_0_0_1px_rgba(0,0,0,0.3)]",
|
|
2929
|
+
style: normalizeStyle(saturationHandleStyle.value)
|
|
2930
|
+
}, null, 4)
|
|
2931
|
+
], 44, _hoisted_14$2),
|
|
2932
|
+
createElementVNode("div", _hoisted_17$1, [
|
|
2933
|
+
!isRainbowVariant.value ? (openBlock(), createElementBlock("div", _hoisted_18$1, [
|
|
2934
|
+
createElementVNode("div", _hoisted_19, [
|
|
2935
|
+
createElementVNode("label", {
|
|
2936
|
+
for: fieldId.value ? `${fieldId.value}-hue` : void 0
|
|
2937
|
+
}, "Hue", 8, _hoisted_20),
|
|
2938
|
+
createElementVNode("span", null, toDisplayString(Math.round(hue.value)) + "°", 1)
|
|
2939
|
+
]),
|
|
2940
|
+
createElementVNode("input", {
|
|
2941
|
+
id: fieldId.value ? `${fieldId.value}-hue` : void 0,
|
|
2942
|
+
type: "range",
|
|
2943
|
+
min: "0",
|
|
2944
|
+
max: "360",
|
|
2945
|
+
step: "1",
|
|
2946
|
+
class: "color-picker-range",
|
|
2947
|
+
disabled: props.disabled,
|
|
2948
|
+
value: hue.value,
|
|
2949
|
+
style: { "background": "linear-gradient(90deg, #FF0000 0%, #FFFF00 17%, #00FF00 33%, #00FFFF 50%, #0000FF 67%, #FF00FF 83%, #FF0000 100%)" },
|
|
2950
|
+
onInput: handleHueInput
|
|
2951
|
+
}, null, 40, _hoisted_21)
|
|
2952
|
+
])) : createCommentVNode("", true),
|
|
2953
|
+
props.allowAlpha ? (openBlock(), createElementBlock("div", _hoisted_22, [
|
|
2954
|
+
createElementVNode("div", _hoisted_23, [
|
|
2955
|
+
createElementVNode("label", {
|
|
2956
|
+
for: fieldId.value ? `${fieldId.value}-alpha` : void 0
|
|
2957
|
+
}, "Opacity", 8, _hoisted_24),
|
|
2958
|
+
createElementVNode("span", null, toDisplayString(opacityPercent.value) + "%", 1)
|
|
2959
|
+
]),
|
|
2960
|
+
createElementVNode("input", {
|
|
2961
|
+
id: fieldId.value ? `${fieldId.value}-alpha` : void 0,
|
|
2962
|
+
type: "range",
|
|
2963
|
+
min: "0",
|
|
2964
|
+
max: "100",
|
|
2965
|
+
step: "1",
|
|
2966
|
+
class: "color-picker-range",
|
|
2967
|
+
disabled: props.disabled,
|
|
2968
|
+
value: opacityPercent.value,
|
|
2969
|
+
style: normalizeStyle({ background: alphaGradient.value }),
|
|
2970
|
+
onInput: handleAlphaInput
|
|
2971
|
+
}, null, 44, _hoisted_25)
|
|
2972
|
+
])) : createCommentVNode("", true)
|
|
2973
|
+
]),
|
|
2974
|
+
createElementVNode("div", _hoisted_26, [
|
|
2975
|
+
createElementVNode("label", {
|
|
2976
|
+
for: fieldId.value ? `${fieldId.value}-hex` : void 0,
|
|
2977
|
+
class: "text-xs font-medium uppercase tracking-[0.16em] text-neutral-500 dark:text-neutral-400"
|
|
2978
|
+
}, "Hex value", 8, _hoisted_27),
|
|
2979
|
+
createElementVNode("input", {
|
|
2980
|
+
id: fieldId.value ? `${fieldId.value}-hex` : void 0,
|
|
2981
|
+
ref_key: "hexInputRef",
|
|
2982
|
+
ref: hexInputRef,
|
|
2983
|
+
type: "text",
|
|
2984
|
+
inputmode: "text",
|
|
2985
|
+
spellcheck: "false",
|
|
2986
|
+
autocapitalize: "characters",
|
|
2987
|
+
maxlength: props.allowAlpha ? 9 : 7,
|
|
2988
|
+
placeholder: hexInputPlaceholder.value,
|
|
2989
|
+
class: "w-full rounded-xl border border-neutral-200 bg-white px-3 py-2.5 font-mono text-sm text-neutral-950 shadow-sm outline-none transition-colors focus:border-neutral-900 focus:ring-2 focus:ring-neutral-950/10 dark:border-neutral-800 dark:bg-neutral-950 dark:text-neutral-50 dark:focus:border-neutral-100 dark:focus:ring-neutral-100/10",
|
|
2990
|
+
value: displayValue.value,
|
|
2991
|
+
disabled: props.disabled,
|
|
2992
|
+
onInput: handleHexInput,
|
|
2993
|
+
onBlur: handleHexBlur
|
|
2994
|
+
}, null, 40, _hoisted_28)
|
|
2995
|
+
])
|
|
2996
|
+
])
|
|
2997
|
+
])
|
|
2998
|
+
], 4)) : createCommentVNode("", true)
|
|
2999
|
+
]),
|
|
3000
|
+
_: 1
|
|
3001
|
+
})
|
|
3002
|
+
]))
|
|
3003
|
+
]);
|
|
3004
|
+
};
|
|
3005
|
+
}
|
|
3006
|
+
});
|
|
3007
|
+
const ColorPicker = /* @__PURE__ */ _export_sfc(_sfc_main$w, [["__scopeId", "data-v-b86f621b"]]);
|
|
3008
|
+
const _hoisted_1$j = ["for"];
|
|
3009
|
+
const _hoisted_2$d = {
|
|
2266
3010
|
key: 1,
|
|
2267
3011
|
class: "text-xs text-gray-500 mb-1 block"
|
|
2268
3012
|
};
|
|
2269
|
-
const _hoisted_3$
|
|
2270
|
-
key:
|
|
3013
|
+
const _hoisted_3$9 = {
|
|
3014
|
+
key: 18,
|
|
2271
3015
|
class: "flex items-center mt-2 text-sm text-red-600"
|
|
2272
3016
|
};
|
|
2273
3017
|
const defaultFieldClass = "block w-full rounded-lg border border-neutral-200 bg-white px-4 py-3 text-sm text-neutral-950 placeholder:text-neutral-400 shadow-sm transition-all duration-200 focus:border-neutral-900 focus:outline-none focus:ring-2 focus:ring-neutral-950/10 dark:border-neutral-800 dark:bg-neutral-950 dark:text-neutral-50 dark:placeholder:text-neutral-500 dark:focus:border-neutral-100 dark:focus:ring-neutral-100/10";
|
|
2274
|
-
const _sfc_main$
|
|
3018
|
+
const _sfc_main$v = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
|
|
2275
3019
|
__name: "InputGroup",
|
|
2276
3020
|
props: {
|
|
2277
3021
|
type: {
|
|
@@ -2445,6 +3189,14 @@ const _sfc_main$w = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
|
|
|
2445
3189
|
locale: {
|
|
2446
3190
|
type: String,
|
|
2447
3191
|
default: "fr-CA"
|
|
3192
|
+
},
|
|
3193
|
+
allowAlpha: {
|
|
3194
|
+
type: Boolean,
|
|
3195
|
+
default: false
|
|
3196
|
+
},
|
|
3197
|
+
variant: {
|
|
3198
|
+
type: String,
|
|
3199
|
+
default: "classic"
|
|
2448
3200
|
}
|
|
2449
3201
|
},
|
|
2450
3202
|
emits: ["update:modelValue", "blur"],
|
|
@@ -2471,8 +3223,7 @@ const _sfc_main$w = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
|
|
|
2471
3223
|
"tel",
|
|
2472
3224
|
"search",
|
|
2473
3225
|
"month",
|
|
2474
|
-
"week"
|
|
2475
|
-
"color"
|
|
3226
|
+
"week"
|
|
2476
3227
|
];
|
|
2477
3228
|
const noComponentTypes = [];
|
|
2478
3229
|
const isImageType = computed(() => props.type === "image");
|
|
@@ -2488,6 +3239,7 @@ const _sfc_main$w = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
|
|
|
2488
3239
|
const isDateRangeType = computed(() => props.type === "daterange");
|
|
2489
3240
|
const isTextareaType = computed(() => props.type === "textarea");
|
|
2490
3241
|
const isTinyEditorType = computed(() => props.type === "tiny-editor");
|
|
3242
|
+
const isColorPickerType = computed(() => props.type === "color");
|
|
2491
3243
|
const isSelectType = computed(() => props.type === "select");
|
|
2492
3244
|
const isTextLikeType = computed(() => textLikeTypes.includes(props.type));
|
|
2493
3245
|
const isNoComponentType = computed(() => noComponentTypes.includes(props.type));
|
|
@@ -2630,67 +3382,80 @@ const _sfc_main$w = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
|
|
|
2630
3382
|
disabled: props.disabled,
|
|
2631
3383
|
disabledClass: props.disabledClass
|
|
2632
3384
|
}));
|
|
3385
|
+
const colorPickerBindings = computed(() => ({
|
|
3386
|
+
...attrs,
|
|
3387
|
+
class: [attrs.class],
|
|
3388
|
+
name: props.name,
|
|
3389
|
+
modelValue: typeof props.modelValue === "string" ? props.modelValue : "",
|
|
3390
|
+
disabled: props.disabled,
|
|
3391
|
+
disabledClass: props.disabledClass,
|
|
3392
|
+
allowAlpha: props.allowAlpha,
|
|
3393
|
+
variant: props.variant
|
|
3394
|
+
}));
|
|
2633
3395
|
return (_ctx, _cache) => {
|
|
2634
3396
|
return openBlock(), createElementBlock("div", null, [
|
|
2635
3397
|
__props.label && !showsInlineChoiceControl.value ? (openBlock(), createElementBlock("label", {
|
|
2636
3398
|
key: 0,
|
|
2637
3399
|
for: fieldId.value,
|
|
2638
3400
|
class: "text-base font-semibold text-gray-900 dark:text-gray-50 mb-1 block"
|
|
2639
|
-
}, toDisplayString(__props.label), 9, _hoisted_1$
|
|
2640
|
-
__props.helperText && !showsInlineChoiceControl.value ? (openBlock(), createElementBlock("span", _hoisted_2$
|
|
3401
|
+
}, toDisplayString(__props.label), 9, _hoisted_1$j)) : createCommentVNode("", true),
|
|
3402
|
+
__props.helperText && !showsInlineChoiceControl.value ? (openBlock(), createElementBlock("span", _hoisted_2$d, toDisplayString(__props.helperText), 1)) : createCommentVNode("", true),
|
|
2641
3403
|
isTextareaType.value ? (openBlock(), createBlock(_sfc_main$H, mergeProps({ key: 2 }, textAreaBindings.value, {
|
|
2642
3404
|
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => emit("update:modelValue", $event)),
|
|
2643
3405
|
onBlur: _cache[1] || (_cache[1] = ($event) => emit("blur", $event))
|
|
2644
3406
|
}), null, 16)) : isTinyEditorType.value ? (openBlock(), createBlock(_sfc_main$x, mergeProps({ key: 3 }, tinyEditorBindings.value, {
|
|
2645
3407
|
"onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => emit("update:modelValue", $event)),
|
|
2646
3408
|
onBlur: _cache[3] || (_cache[3] = ($event) => emit("blur", $event))
|
|
2647
|
-
}), null, 16)) :
|
|
3409
|
+
}), null, 16)) : isColorPickerType.value ? (openBlock(), createBlock(ColorPicker, mergeProps({ key: 4 }, colorPickerBindings.value, {
|
|
2648
3410
|
"onUpdate:modelValue": _cache[4] || (_cache[4] = ($event) => emit("update:modelValue", $event)),
|
|
2649
3411
|
onBlur: _cache[5] || (_cache[5] = ($event) => emit("blur", $event))
|
|
2650
|
-
}), null, 16)) :
|
|
3412
|
+
}), null, 16)) : isSelectType.value ? (openBlock(), createBlock(_sfc_main$F, mergeProps({ key: 5 }, selectBindings.value, {
|
|
2651
3413
|
"onUpdate:modelValue": _cache[6] || (_cache[6] = ($event) => emit("update:modelValue", $event)),
|
|
2652
3414
|
onBlur: _cache[7] || (_cache[7] = ($event) => emit("blur", $event))
|
|
2653
|
-
}), null, 16)) :
|
|
3415
|
+
}), null, 16)) : isDateType.value ? (openBlock(), createBlock(DateInput, mergeProps({ key: 6 }, dateBindings.value, {
|
|
2654
3416
|
"onUpdate:modelValue": _cache[8] || (_cache[8] = ($event) => emit("update:modelValue", $event)),
|
|
2655
3417
|
onBlur: _cache[9] || (_cache[9] = ($event) => emit("blur", $event))
|
|
2656
|
-
}), null, 16)) :
|
|
3418
|
+
}), null, 16)) : isDateRangeType.value ? (openBlock(), createBlock(DateRangeInput, mergeProps({ key: 7 }, dateRangeBindings.value, {
|
|
2657
3419
|
"onUpdate:modelValue": _cache[10] || (_cache[10] = ($event) => emit("update:modelValue", $event)),
|
|
2658
3420
|
onBlur: _cache[11] || (_cache[11] = ($event) => emit("blur", $event))
|
|
2659
|
-
}), null, 16)) :
|
|
3421
|
+
}), null, 16)) : isTextLikeType.value ? (openBlock(), createBlock(_sfc_main$I, mergeProps({ key: 8 }, textInputBindings.value, {
|
|
2660
3422
|
"onUpdate:modelValue": _cache[12] || (_cache[12] = ($event) => emit("update:modelValue", $event)),
|
|
2661
3423
|
onBlur: _cache[13] || (_cache[13] = ($event) => emit("blur", $event))
|
|
2662
|
-
}), null, 16)) :
|
|
3424
|
+
}), null, 16)) : isImageType.value ? (openBlock(), createBlock(_sfc_main$C, mergeProps({ key: 9 }, imageBindings.value, {
|
|
2663
3425
|
"onUpdate:modelValue": _cache[14] || (_cache[14] = ($event) => emit("update:modelValue", $event)),
|
|
2664
3426
|
onBlur: _cache[15] || (_cache[15] = ($event) => emit("blur", $event))
|
|
2665
|
-
}), null, 16)) :
|
|
3427
|
+
}), null, 16)) : isCheckboxSingleType.value ? (openBlock(), createBlock(_sfc_main$J, mergeProps({ key: 10 }, checkboxSingleBindings.value, {
|
|
2666
3428
|
"onUpdate:modelValue": _cache[16] || (_cache[16] = ($event) => emit("update:modelValue", $event)),
|
|
2667
3429
|
onBlur: _cache[17] || (_cache[17] = ($event) => emit("blur", $event))
|
|
2668
|
-
}), null, 16)) :
|
|
3430
|
+
}), null, 16)) : isRadioSingleType.value ? (openBlock(), createBlock(_sfc_main$A, mergeProps({ key: 11 }, radioSingleBindings.value, {
|
|
2669
3431
|
"onUpdate:modelValue": _cache[18] || (_cache[18] = ($event) => emit("update:modelValue", $event)),
|
|
2670
3432
|
onBlur: _cache[19] || (_cache[19] = ($event) => emit("blur", $event))
|
|
2671
|
-
}), null, 16)) :
|
|
3433
|
+
}), null, 16)) : isToggleSingleType.value ? (openBlock(), createBlock(_sfc_main$z, mergeProps({ key: 12 }, toggleSingleBindings.value, {
|
|
2672
3434
|
"onUpdate:modelValue": _cache[20] || (_cache[20] = ($event) => emit("update:modelValue", $event)),
|
|
2673
3435
|
onBlur: _cache[21] || (_cache[21] = ($event) => emit("blur", $event))
|
|
2674
|
-
}), null, 16)) :
|
|
3436
|
+
}), null, 16)) : isNotationType.value ? (openBlock(), createBlock(_sfc_main$B, mergeProps({ key: 13 }, notationBindings.value, {
|
|
2675
3437
|
"onUpdate:modelValue": _cache[22] || (_cache[22] = ($event) => emit("update:modelValue", $event)),
|
|
2676
3438
|
onBlur: _cache[23] || (_cache[23] = ($event) => emit("blur", $event))
|
|
2677
|
-
}), null, 16)) :
|
|
3439
|
+
}), null, 16)) : isCheckboxType.value ? (openBlock(), createBlock(_sfc_main$u, mergeProps({ key: 14 }, checkboxBindings.value, {
|
|
2678
3440
|
"onUpdate:modelValue": _cache[24] || (_cache[24] = ($event) => emit("update:modelValue", $event)),
|
|
2679
3441
|
onBlur: _cache[25] || (_cache[25] = ($event) => emit("blur", $event))
|
|
3442
|
+
}), null, 16)) : isRadioType.value ? (openBlock(), createBlock(_sfc_main$y, mergeProps({ key: 15 }, radioBindings.value, {
|
|
3443
|
+
"onUpdate:modelValue": _cache[26] || (_cache[26] = ($event) => emit("update:modelValue", $event)),
|
|
3444
|
+
onBlur: _cache[27] || (_cache[27] = ($event) => emit("blur", $event))
|
|
2680
3445
|
}), null, 16)) : isNoComponentType.value ? renderSlot(_ctx.$slots, "unsupported-type", {
|
|
2681
|
-
key:
|
|
3446
|
+
key: 16,
|
|
2682
3447
|
type: __props.type,
|
|
2683
3448
|
modelValue: __props.modelValue,
|
|
2684
3449
|
updateValue,
|
|
2685
3450
|
attrs: unref(attrs)
|
|
2686
3451
|
}) : renderSlot(_ctx.$slots, "unsupported-type", {
|
|
2687
|
-
key:
|
|
3452
|
+
key: 17,
|
|
2688
3453
|
type: __props.type,
|
|
2689
3454
|
modelValue: __props.modelValue,
|
|
2690
3455
|
updateValue,
|
|
2691
3456
|
attrs: unref(attrs)
|
|
2692
3457
|
}),
|
|
2693
|
-
hasError.value ? (openBlock(), createElementBlock("div", _hoisted_3$
|
|
3458
|
+
hasError.value ? (openBlock(), createElementBlock("div", _hoisted_3$9, [
|
|
2694
3459
|
createVNode(unref(ExclamationCircleIcon), { class: "mr-1 h-4 w-4 flex-shrink-0" }),
|
|
2695
3460
|
createElementVNode("span", null, toDisplayString(__props.errorMessage), 1)
|
|
2696
3461
|
])) : createCommentVNode("", true)
|
|
@@ -2698,8 +3463,8 @@ const _sfc_main$w = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
|
|
|
2698
3463
|
};
|
|
2699
3464
|
}
|
|
2700
3465
|
});
|
|
2701
|
-
const _hoisted_1$
|
|
2702
|
-
const _sfc_main$
|
|
3466
|
+
const _hoisted_1$i = { class: "flex flex-wrap gap-3" };
|
|
3467
|
+
const _sfc_main$u = {
|
|
2703
3468
|
__name: "CheckboxMultipleInput",
|
|
2704
3469
|
props: {
|
|
2705
3470
|
modelValue: {
|
|
@@ -2740,9 +3505,9 @@ const _sfc_main$v = {
|
|
|
2740
3505
|
emit("update:modelValue", nextSelection);
|
|
2741
3506
|
};
|
|
2742
3507
|
return (_ctx, _cache) => {
|
|
2743
|
-
return openBlock(), createElementBlock("div", _hoisted_1$
|
|
3508
|
+
return openBlock(), createElementBlock("div", _hoisted_1$i, [
|
|
2744
3509
|
(openBlock(true), createElementBlock(Fragment, null, renderList(normalizedOptions.value, (option) => {
|
|
2745
|
-
return openBlock(), createBlock(_sfc_main$
|
|
3510
|
+
return openBlock(), createBlock(_sfc_main$v, {
|
|
2746
3511
|
key: `checkbox-${option}`,
|
|
2747
3512
|
type: "checkbox-input",
|
|
2748
3513
|
name: __props.name,
|
|
@@ -2758,153 +3523,6 @@ const _sfc_main$v = {
|
|
|
2758
3523
|
};
|
|
2759
3524
|
}
|
|
2760
3525
|
};
|
|
2761
|
-
const _hoisted_1$i = { class: "relative" };
|
|
2762
|
-
const _hoisted_2$d = ["disabled", "aria-label"];
|
|
2763
|
-
const _hoisted_3$9 = ["value", "disabled"];
|
|
2764
|
-
const _hoisted_4$7 = ["value", "disabled"];
|
|
2765
|
-
const DEFAULT_COLOR = "#000000";
|
|
2766
|
-
const DEFAULT_MAX_LENGTH = 7;
|
|
2767
|
-
const _sfc_main$u = /* @__PURE__ */ Object.assign({ inheritAttrs: false }, {
|
|
2768
|
-
__name: "ColorPicker",
|
|
2769
|
-
props: {
|
|
2770
|
-
modelValue: {
|
|
2771
|
-
type: [String, null],
|
|
2772
|
-
default: ""
|
|
2773
|
-
},
|
|
2774
|
-
disabled: {
|
|
2775
|
-
type: Boolean,
|
|
2776
|
-
default: false
|
|
2777
|
-
},
|
|
2778
|
-
disabledClass: {
|
|
2779
|
-
type: String,
|
|
2780
|
-
default: "!border-neutral-200 !bg-neutral-100 !text-neutral-500 dark:!border-neutral-800 dark:!bg-neutral-900 dark:!text-neutral-500"
|
|
2781
|
-
}
|
|
2782
|
-
},
|
|
2783
|
-
emits: ["update:modelValue", "blur"],
|
|
2784
|
-
setup(__props, { expose: __expose, emit: __emit }) {
|
|
2785
|
-
const props = __props;
|
|
2786
|
-
const emit = __emit;
|
|
2787
|
-
const attrs = useAttrs();
|
|
2788
|
-
const textInput = ref(null);
|
|
2789
|
-
const nativeInput = ref(null);
|
|
2790
|
-
const normalizeHexColor = (value) => {
|
|
2791
|
-
if (typeof value !== "string") {
|
|
2792
|
-
return "";
|
|
2793
|
-
}
|
|
2794
|
-
const trimmed = value.trim();
|
|
2795
|
-
if (trimmed === "") {
|
|
2796
|
-
return "";
|
|
2797
|
-
}
|
|
2798
|
-
const withHash = trimmed.startsWith("#") ? trimmed : `#${trimmed}`;
|
|
2799
|
-
const shortMatch = withHash.match(/^#([0-9a-fA-F]{3})$/);
|
|
2800
|
-
if (shortMatch) {
|
|
2801
|
-
const [, shortValue] = shortMatch;
|
|
2802
|
-
return `#${shortValue.split("").map((char) => char.repeat(2)).join("").toUpperCase()}`;
|
|
2803
|
-
}
|
|
2804
|
-
const longMatch = withHash.match(/^#([0-9a-fA-F]{6})$/);
|
|
2805
|
-
if (longMatch) {
|
|
2806
|
-
return `#${longMatch[1].toUpperCase()}`;
|
|
2807
|
-
}
|
|
2808
|
-
return "";
|
|
2809
|
-
};
|
|
2810
|
-
const normalizedModelValue = computed(() => normalizeHexColor(props.modelValue));
|
|
2811
|
-
const fallbackColor = computed(() => normalizedModelValue.value || DEFAULT_COLOR);
|
|
2812
|
-
const displayValue = ref(normalizedModelValue.value);
|
|
2813
|
-
const textInputAttrs = computed(() => {
|
|
2814
|
-
const { class: _class, type: _type, ...rest } = attrs;
|
|
2815
|
-
if (rest.maxlength === void 0) {
|
|
2816
|
-
rest.maxlength = DEFAULT_MAX_LENGTH;
|
|
2817
|
-
}
|
|
2818
|
-
return rest;
|
|
2819
|
-
});
|
|
2820
|
-
const textInputClasses = computed(() => [
|
|
2821
|
-
"w-full min-w-0 rounded-lg border border-neutral-200 bg-white px-4 py-3 text-sm text-neutral-950 shadow-sm outline-none transition-colors placeholder:text-neutral-400 focus:border-neutral-900 focus:ring-2 focus:ring-neutral-950/10 dark:border-neutral-800 dark:bg-neutral-950 dark:text-neutral-50 dark:placeholder:text-neutral-500 dark:focus:border-neutral-100 dark:focus:ring-neutral-100/10",
|
|
2822
|
-
"pl-16",
|
|
2823
|
-
attrs.class
|
|
2824
|
-
]);
|
|
2825
|
-
watch(normalizedModelValue, (nextValue) => {
|
|
2826
|
-
displayValue.value = nextValue;
|
|
2827
|
-
});
|
|
2828
|
-
const emitNormalizedColor = (value) => {
|
|
2829
|
-
const normalized = normalizeHexColor(value);
|
|
2830
|
-
if (!normalized) {
|
|
2831
|
-
return false;
|
|
2832
|
-
}
|
|
2833
|
-
emit("update:modelValue", normalized);
|
|
2834
|
-
return true;
|
|
2835
|
-
};
|
|
2836
|
-
const handleTextInput = (event) => {
|
|
2837
|
-
const nextValue = String(event.target?.value ?? "");
|
|
2838
|
-
displayValue.value = nextValue;
|
|
2839
|
-
emitNormalizedColor(nextValue);
|
|
2840
|
-
};
|
|
2841
|
-
const handleNativeInput = (event) => {
|
|
2842
|
-
const nextValue = String(event.target?.value ?? "");
|
|
2843
|
-
const normalized = normalizeHexColor(nextValue) || DEFAULT_COLOR;
|
|
2844
|
-
displayValue.value = normalized;
|
|
2845
|
-
emit("update:modelValue", normalized);
|
|
2846
|
-
};
|
|
2847
|
-
const handleBlur = (event) => {
|
|
2848
|
-
displayValue.value = normalizedModelValue.value;
|
|
2849
|
-
emit("blur", event);
|
|
2850
|
-
};
|
|
2851
|
-
const openNativePicker = () => {
|
|
2852
|
-
if (props.disabled) {
|
|
2853
|
-
return;
|
|
2854
|
-
}
|
|
2855
|
-
nativeInput.value?.click();
|
|
2856
|
-
};
|
|
2857
|
-
onMounted(() => {
|
|
2858
|
-
if (textInput.value?.hasAttribute("autofocus")) {
|
|
2859
|
-
textInput.value.focus();
|
|
2860
|
-
}
|
|
2861
|
-
});
|
|
2862
|
-
__expose({ focus: () => textInput.value?.focus() });
|
|
2863
|
-
return (_ctx, _cache) => {
|
|
2864
|
-
return openBlock(), createElementBlock("div", _hoisted_1$i, [
|
|
2865
|
-
createElementVNode("button", {
|
|
2866
|
-
type: "button",
|
|
2867
|
-
class: normalizeClass(["absolute inset-y-0 left-0 my-2 ml-2 inline-flex w-10 items-center justify-center rounded-md border border-neutral-200 bg-white shadow-sm transition-colors focus:outline-none focus:ring-2 focus:ring-neutral-950/10 dark:border-neutral-800 dark:bg-neutral-950 dark:focus:ring-neutral-100/10", props.disabled ? "cursor-not-allowed opacity-60" : "cursor-pointer"]),
|
|
2868
|
-
disabled: props.disabled,
|
|
2869
|
-
"aria-label": `Choose color${normalizedModelValue.value ? ` ${normalizedModelValue.value}` : ""}`,
|
|
2870
|
-
onClick: openNativePicker
|
|
2871
|
-
}, [
|
|
2872
|
-
createElementVNode("span", {
|
|
2873
|
-
class: "h-5 w-5 rounded border border-black/10 dark:border-white/10",
|
|
2874
|
-
style: normalizeStyle({ backgroundColor: fallbackColor.value })
|
|
2875
|
-
}, null, 4)
|
|
2876
|
-
], 10, _hoisted_2$d),
|
|
2877
|
-
createElementVNode("input", {
|
|
2878
|
-
ref_key: "nativeInput",
|
|
2879
|
-
ref: nativeInput,
|
|
2880
|
-
type: "color",
|
|
2881
|
-
tabindex: "-1",
|
|
2882
|
-
"aria-hidden": "true",
|
|
2883
|
-
class: "pointer-events-none absolute h-0 w-0 opacity-0",
|
|
2884
|
-
value: fallbackColor.value,
|
|
2885
|
-
disabled: props.disabled,
|
|
2886
|
-
onInput: handleNativeInput,
|
|
2887
|
-
onChange: handleNativeInput
|
|
2888
|
-
}, null, 40, _hoisted_3$9),
|
|
2889
|
-
createElementVNode("input", mergeProps({
|
|
2890
|
-
ref_key: "textInput",
|
|
2891
|
-
ref: textInput
|
|
2892
|
-
}, textInputAttrs.value, {
|
|
2893
|
-
type: "text",
|
|
2894
|
-
inputmode: "text",
|
|
2895
|
-
spellcheck: "false",
|
|
2896
|
-
autocapitalize: "characters",
|
|
2897
|
-
placeholder: "#RRGGBB",
|
|
2898
|
-
class: [textInputClasses.value, props.disabled ? props.disabledClass : null],
|
|
2899
|
-
value: displayValue.value,
|
|
2900
|
-
disabled: props.disabled,
|
|
2901
|
-
onInput: handleTextInput,
|
|
2902
|
-
onBlur: handleBlur
|
|
2903
|
-
}), null, 16, _hoisted_4$7)
|
|
2904
|
-
]);
|
|
2905
|
-
};
|
|
2906
|
-
}
|
|
2907
|
-
});
|
|
2908
3526
|
const _sfc_main$t = {
|
|
2909
3527
|
__name: "Modal",
|
|
2910
3528
|
props: {
|
|
@@ -5137,7 +5755,7 @@ const _sfc_main$2 = {
|
|
|
5137
5755
|
isEditingRow(item, index) && column.slot && unref(slots)[getEditSlotName(column)] ? renderSlot(_ctx.$slots, getEditSlotName(column), mergeProps({
|
|
5138
5756
|
key: 0,
|
|
5139
5757
|
ref_for: true
|
|
5140
|
-
}, getSlotBindings(item, column, index))) : isEditingRow(item, index) && column.input ? (openBlock(), createBlock(_sfc_main$
|
|
5758
|
+
}, getSlotBindings(item, column, index))) : isEditingRow(item, index) && column.input ? (openBlock(), createBlock(_sfc_main$v, {
|
|
5141
5759
|
key: 1,
|
|
5142
5760
|
type: getInputType(column),
|
|
5143
5761
|
class: normalizeClass(getInputClass(column)),
|
|
@@ -5365,8 +5983,8 @@ const components = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePr
|
|
|
5365
5983
|
CardTabs: _sfc_main$T,
|
|
5366
5984
|
Checkbox: _sfc_main$K,
|
|
5367
5985
|
CheckboxInput: _sfc_main$J,
|
|
5368
|
-
CheckboxMultipleInput: _sfc_main$
|
|
5369
|
-
ColorPicker
|
|
5986
|
+
CheckboxMultipleInput: _sfc_main$u,
|
|
5987
|
+
ColorPicker,
|
|
5370
5988
|
ConfirmationModal: _sfc_main$s,
|
|
5371
5989
|
CustomSelect: _sfc_main$G,
|
|
5372
5990
|
DateInput,
|
|
@@ -5378,7 +5996,7 @@ const components = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePr
|
|
|
5378
5996
|
FormSection: _sfc_main$o,
|
|
5379
5997
|
ImageInput: _sfc_main$C,
|
|
5380
5998
|
InputError: _sfc_main$n,
|
|
5381
|
-
InputGroup: _sfc_main$
|
|
5999
|
+
InputGroup: _sfc_main$v,
|
|
5382
6000
|
InputLabel: _sfc_main$m,
|
|
5383
6001
|
LinkButton: _sfc_main$l,
|
|
5384
6002
|
Modal: _sfc_main$t,
|
|
@@ -5423,9 +6041,9 @@ const plugin = {
|
|
|
5423
6041
|
};
|
|
5424
6042
|
export {
|
|
5425
6043
|
_sfc_main$x as $,
|
|
5426
|
-
_sfc_main$
|
|
5427
|
-
_sfc_main$
|
|
5428
|
-
|
|
6044
|
+
_sfc_main$y as A,
|
|
6045
|
+
_sfc_main$k as B,
|
|
6046
|
+
ColorPicker as C,
|
|
5429
6047
|
DateInput as D,
|
|
5430
6048
|
_sfc_main$F as E,
|
|
5431
6049
|
_sfc_main$j as F,
|
|
@@ -5462,23 +6080,23 @@ export {
|
|
|
5462
6080
|
_sfc_main$T as f,
|
|
5463
6081
|
_sfc_main$K as g,
|
|
5464
6082
|
_sfc_main$J as h,
|
|
5465
|
-
_sfc_main$
|
|
5466
|
-
_sfc_main$
|
|
5467
|
-
_sfc_main$
|
|
5468
|
-
|
|
5469
|
-
|
|
5470
|
-
_sfc_main$
|
|
5471
|
-
_sfc_main$
|
|
5472
|
-
_sfc_main$
|
|
5473
|
-
|
|
5474
|
-
|
|
5475
|
-
_sfc_main$
|
|
5476
|
-
_sfc_main$
|
|
5477
|
-
_sfc_main$
|
|
5478
|
-
_sfc_main$
|
|
5479
|
-
_sfc_main$
|
|
5480
|
-
_sfc_main$
|
|
5481
|
-
_sfc_main$
|
|
5482
|
-
_sfc_main$
|
|
6083
|
+
_sfc_main$u as i,
|
|
6084
|
+
_sfc_main$s as j,
|
|
6085
|
+
_sfc_main$G as k,
|
|
6086
|
+
DateRangeInput as l,
|
|
6087
|
+
_sfc_main$r as m,
|
|
6088
|
+
_sfc_main$R as n,
|
|
6089
|
+
_sfc_main$q as o,
|
|
6090
|
+
_sfc_main$p as p,
|
|
6091
|
+
plugin as q,
|
|
6092
|
+
_sfc_main$o as r,
|
|
6093
|
+
_sfc_main$C as s,
|
|
6094
|
+
_sfc_main$n as t,
|
|
6095
|
+
_sfc_main$v as u,
|
|
6096
|
+
_sfc_main$m as v,
|
|
6097
|
+
_sfc_main$l as w,
|
|
6098
|
+
_sfc_main$t as x,
|
|
6099
|
+
_sfc_main$B as y,
|
|
6100
|
+
_sfc_main$A as z
|
|
5483
6101
|
};
|
|
5484
|
-
//# sourceMappingURL=plugin-
|
|
6102
|
+
//# sourceMappingURL=plugin-DYTVm2W1.js.map
|