@stachelock/ui 0.1.1 → 0.1.4
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/CalendarHeader.vue_vue_type_script_setup_true_lang-Cirr0hMB.js +70 -0
- package/dist/CalendarHeader.vue_vue_type_script_setup_true_lang-Cirr0hMB.js.map +1 -0
- package/dist/CheckboxInput.vue_vue_type_script_setup_true_lang-tYAo46wK.js +186 -0
- package/dist/CheckboxInput.vue_vue_type_script_setup_true_lang-tYAo46wK.js.map +1 -0
- package/dist/ComboboxInput.vue_vue_type_script_setup_true_lang-2dJNxQUF.js +1300 -0
- package/dist/ComboboxInput.vue_vue_type_script_setup_true_lang-2dJNxQUF.js.map +1 -0
- package/dist/DashboardLayout.vue_vue_type_script_setup_true_lang-VeZhdPhj.js +187 -0
- package/dist/DashboardLayout.vue_vue_type_script_setup_true_lang-VeZhdPhj.js.map +1 -0
- package/dist/DayCalendar.vue_vue_type_script_setup_true_lang-xE5bCa3O.js +123 -0
- package/dist/DayCalendar.vue_vue_type_script_setup_true_lang-xE5bCa3O.js.map +1 -0
- package/dist/DefaultLayout.vue_vue_type_script_setup_true_lang-BZAz6aC-.js +85 -0
- package/dist/DefaultLayout.vue_vue_type_script_setup_true_lang-BZAz6aC-.js.map +1 -0
- package/dist/DynamicForm.vue_vue_type_script_setup_true_lang-BpfPAZiT.js +217 -0
- package/dist/DynamicForm.vue_vue_type_script_setup_true_lang-BpfPAZiT.js.map +1 -0
- package/dist/DynamicFormField.vue_vue_type_script_setup_true_lang-DvT03FIS.js +169 -0
- package/dist/DynamicFormField.vue_vue_type_script_setup_true_lang-DvT03FIS.js.map +1 -0
- package/dist/EventCard.vue_vue_type_script_setup_true_lang-YV1lfgUY.js +157 -0
- package/dist/EventCard.vue_vue_type_script_setup_true_lang-YV1lfgUY.js.map +1 -0
- package/dist/EventsList.vue_vue_type_script_setup_true_lang-Cn_WOpZi.js +103 -0
- package/dist/EventsList.vue_vue_type_script_setup_true_lang-Cn_WOpZi.js.map +1 -0
- package/dist/HeaderLayout.vue_vue_type_script_setup_true_lang-BY2G6hCc.js +49 -0
- package/dist/HeaderLayout.vue_vue_type_script_setup_true_lang-BY2G6hCc.js.map +1 -0
- package/dist/MonthCalendar.vue_vue_type_script_setup_true_lang-B9Bs0z8j.js +66 -0
- package/dist/MonthCalendar.vue_vue_type_script_setup_true_lang-B9Bs0z8j.js.map +1 -0
- package/dist/NavigationGroup.vue_vue_type_script_setup_true_lang-2WURj34G.js +29 -0
- package/dist/NavigationGroup.vue_vue_type_script_setup_true_lang-2WURj34G.js.map +1 -0
- package/dist/NavigationItem.vue_vue_type_script_setup_true_lang-DiNg3gz2.js +51 -0
- package/dist/NavigationItem.vue_vue_type_script_setup_true_lang-DiNg3gz2.js.map +1 -0
- package/dist/SelectInput.vue_vue_type_script_setup_true_lang-BPjHLHdM.js +522 -0
- package/dist/SelectInput.vue_vue_type_script_setup_true_lang-BPjHLHdM.js.map +1 -0
- package/dist/SidebarLayout.vue_vue_type_script_setup_true_lang-J1nfUTdM.js +174 -0
- package/dist/SidebarLayout.vue_vue_type_script_setup_true_lang-J1nfUTdM.js.map +1 -0
- package/dist/SwitchInput.vue_vue_type_script_setup_true_lang-BFr2SByh.js +273 -0
- package/dist/SwitchInput.vue_vue_type_script_setup_true_lang-BFr2SByh.js.map +1 -0
- package/dist/TagifyInput.vue_vue_type_script_setup_true_lang-DRR6jt_8.js +240 -0
- package/dist/TagifyInput.vue_vue_type_script_setup_true_lang-DRR6jt_8.js.map +1 -0
- package/dist/TextAreaInput.vue_vue_type_script_setup_true_lang-CbR651TU.js +158 -0
- package/dist/TextAreaInput.vue_vue_type_script_setup_true_lang-CbR651TU.js.map +1 -0
- package/dist/UiAvatar.vue_vue_type_script_setup_true_lang-CDNjUA1L.js +108 -0
- package/dist/UiAvatar.vue_vue_type_script_setup_true_lang-CDNjUA1L.js.map +1 -0
- package/dist/UiBreadcrumb.vue_vue_type_script_setup_true_lang-quGuN9v4.js +82 -0
- package/dist/UiBreadcrumb.vue_vue_type_script_setup_true_lang-quGuN9v4.js.map +1 -0
- package/dist/UiLoading.vue_vue_type_script_setup_true_lang-DCz52-Me.js +131 -0
- package/dist/UiLoading.vue_vue_type_script_setup_true_lang-DCz52-Me.js.map +1 -0
- package/dist/UiModal.vue_vue_type_script_setup_true_lang-SAo39zpS.js +163 -0
- package/dist/UiModal.vue_vue_type_script_setup_true_lang-SAo39zpS.js.map +1 -0
- package/dist/UiNavLink.vue_vue_type_script_setup_true_lang-Bz5oiCCk.js +222 -0
- package/dist/UiNavLink.vue_vue_type_script_setup_true_lang-Bz5oiCCk.js.map +1 -0
- package/dist/UiProgressBar.vue_vue_type_script_setup_true_lang-0zFKwh43.js +46 -0
- package/dist/UiProgressBar.vue_vue_type_script_setup_true_lang-0zFKwh43.js.map +1 -0
- package/dist/UiTable.vue_vue_type_script_setup_true_lang-hI1_xamh.js +211 -0
- package/dist/UiTable.vue_vue_type_script_setup_true_lang-hI1_xamh.js.map +1 -0
- package/dist/UiTransition.vue_vue_type_script_setup_true_lang-DwBTj18t.js +66 -0
- package/dist/UiTransition.vue_vue_type_script_setup_true_lang-DwBTj18t.js.map +1 -0
- package/dist/WeekCalendar.vue_vue_type_script_setup_true_lang-DAFQiRI9.js +154 -0
- package/dist/WeekCalendar.vue_vue_type_script_setup_true_lang-DAFQiRI9.js.map +1 -0
- package/dist/XMarkIcon-C4wILUsz.js +40 -0
- package/dist/XMarkIcon-C4wILUsz.js.map +1 -0
- package/dist/YearCalendar.vue_vue_type_script_setup_true_lang-BfJkvmpN.js +29 -0
- package/dist/YearCalendar.vue_vue_type_script_setup_true_lang-BfJkvmpN.js.map +1 -0
- package/dist/_plugin-vue_export-helper-CHgC5LLL.js +10 -0
- package/dist/_plugin-vue_export-helper-CHgC5LLL.js.map +1 -0
- package/dist/calculate-active-index-CksdUwZY.js +87 -0
- package/dist/calculate-active-index-CksdUwZY.js.map +1 -0
- package/dist/calendar-905Ofszh.js +77 -0
- package/dist/calendar-905Ofszh.js.map +1 -0
- package/dist/calendars/CalendarDashboard.d.ts +3 -0
- package/dist/calendars/CalendarDashboard.js +72 -0
- package/dist/calendars/CalendarDashboard.js.map +1 -0
- package/dist/calendars/CalendarHeader.d.ts +3 -0
- package/dist/calendars/CalendarHeader.js +5 -0
- package/dist/calendars/CalendarHeader.js.map +1 -0
- package/dist/calendars/DayCalendar.d.ts +3 -0
- package/dist/calendars/DayCalendar.js +5 -0
- package/dist/calendars/DayCalendar.js.map +1 -0
- package/dist/calendars/EventCard.d.ts +3 -0
- package/dist/calendars/EventCard.js +5 -0
- package/dist/calendars/EventCard.js.map +1 -0
- package/dist/calendars/EventsList.d.ts +3 -0
- package/dist/calendars/EventsList.js +5 -0
- package/dist/calendars/EventsList.js.map +1 -0
- package/dist/calendars/MonthCalendar.d.ts +3 -0
- package/dist/calendars/MonthCalendar.js +5 -0
- package/dist/calendars/MonthCalendar.js.map +1 -0
- package/dist/calendars/WeekCalendar.d.ts +3 -0
- package/dist/calendars/WeekCalendar.js +5 -0
- package/dist/calendars/WeekCalendar.js.map +1 -0
- package/dist/calendars/YearCalendar.d.ts +3 -0
- package/dist/calendars/YearCalendar.js +5 -0
- package/dist/calendars/YearCalendar.js.map +1 -0
- package/dist/components/Avatar.d.ts +3 -0
- package/dist/components/Avatar.js +5 -0
- package/dist/components/Avatar.js.map +1 -0
- package/dist/components/Badge.d.ts +3 -0
- package/dist/components/Badge.js +42 -0
- package/dist/components/Badge.js.map +1 -0
- package/dist/components/Breadcrumb.d.ts +3 -0
- package/dist/components/Breadcrumb.js +5 -0
- package/dist/components/Breadcrumb.js.map +1 -0
- package/dist/components/Button.d.ts +3 -0
- package/dist/components/Button.js +197 -0
- package/dist/components/Button.js.map +1 -0
- package/dist/components/Loading.d.ts +3 -0
- package/dist/components/Loading.js +5 -0
- package/dist/components/Loading.js.map +1 -0
- package/dist/components/LoadingDots.d.ts +3 -0
- package/dist/components/LoadingDots.js +69 -0
- package/dist/components/LoadingDots.js.map +1 -0
- package/dist/components/Modal.d.ts +3 -0
- package/dist/components/Modal.js +5 -0
- package/dist/components/Modal.js.map +1 -0
- package/dist/components/NavLink.d.ts +3 -0
- package/dist/components/NavLink.js +5 -0
- package/dist/components/NavLink.js.map +1 -0
- package/dist/components/ProgressBar.d.ts +3 -0
- package/dist/components/ProgressBar.js +5 -0
- package/dist/components/ProgressBar.js.map +1 -0
- package/dist/components/RadialProgressBar.d.ts +3 -0
- package/dist/components/RadialProgressBar.js +5 -0
- package/dist/components/RadialProgressBar.js.map +1 -0
- package/dist/components/Table.d.ts +3 -0
- package/dist/components/Table.js +5 -0
- package/dist/components/Table.js.map +1 -0
- package/dist/components/TextInput.d.ts +3 -0
- package/dist/components/TextInput.js +111 -0
- package/dist/components/TextInput.js.map +1 -0
- package/dist/components/Transition.d.ts +3 -0
- package/dist/components/Transition.js +5 -0
- package/dist/components/Transition.js.map +1 -0
- package/dist/description-CBd3BJ9O.js +30 -0
- package/dist/description-CBd3BJ9O.js.map +1 -0
- package/dist/dialog-U1KNiPzc.js +493 -0
- package/dist/dialog-U1KNiPzc.js.map +1 -0
- package/dist/form-DQKuKVqJ.js +51 -0
- package/dist/form-DQKuKVqJ.js.map +1 -0
- package/dist/forms/DynamicForm.d.ts +3 -0
- package/dist/forms/DynamicForm.js +5 -0
- package/dist/forms/DynamicForm.js.map +1 -0
- package/dist/forms/DynamicFormField.d.ts +3 -0
- package/dist/forms/DynamicFormField.js +5 -0
- package/dist/forms/DynamicFormField.js.map +1 -0
- package/dist/forms/FormFieldWrapper.d.ts +3 -0
- package/dist/forms/FormFieldWrapper.js +187 -0
- package/dist/forms/FormFieldWrapper.js.map +1 -0
- package/dist/id-DafBB_QF.js +20 -0
- package/dist/id-DafBB_QF.js.map +1 -0
- package/dist/index.js +266 -4564
- package/dist/index.js.map +1 -1
- package/dist/inputs/CheckboxInput.d.ts +3 -0
- package/dist/inputs/CheckboxInput.js +5 -0
- package/dist/inputs/CheckboxInput.js.map +1 -0
- package/dist/inputs/ComboboxInput.d.ts +3 -0
- package/dist/inputs/ComboboxInput.js +5 -0
- package/dist/inputs/ComboboxInput.js.map +1 -0
- package/dist/inputs/SelectInput.d.ts +3 -0
- package/dist/inputs/SelectInput.js +5 -0
- package/dist/inputs/SelectInput.js.map +1 -0
- package/dist/inputs/SwitchInput.d.ts +3 -0
- package/dist/inputs/SwitchInput.js +5 -0
- package/dist/inputs/SwitchInput.js.map +1 -0
- package/dist/inputs/TagifyInput.d.ts +3 -0
- package/dist/inputs/TagifyInput.js +5 -0
- package/dist/inputs/TagifyInput.js.map +1 -0
- package/dist/inputs/TextAreaInput.d.ts +3 -0
- package/dist/inputs/TextAreaInput.js +5 -0
- package/dist/inputs/TextAreaInput.js.map +1 -0
- package/dist/keyboard-DJD8TwH4.js +113 -0
- package/dist/keyboard-DJD8TwH4.js.map +1 -0
- package/dist/layouts/DashboardLayout.d.ts +3 -0
- package/dist/layouts/DashboardLayout.js +5 -0
- package/dist/layouts/DashboardLayout.js.map +1 -0
- package/dist/layouts/DefaultLayout.d.ts +3 -0
- package/dist/layouts/DefaultLayout.js +5 -0
- package/dist/layouts/DefaultLayout.js.map +1 -0
- package/dist/layouts/HeaderLayout.d.ts +3 -0
- package/dist/layouts/HeaderLayout.js +5 -0
- package/dist/layouts/HeaderLayout.js.map +1 -0
- package/dist/layouts/NavigationGroup.d.ts +3 -0
- package/dist/layouts/NavigationGroup.js +5 -0
- package/dist/layouts/NavigationGroup.js.map +1 -0
- package/dist/layouts/NavigationItem.d.ts +3 -0
- package/dist/layouts/NavigationItem.js +5 -0
- package/dist/layouts/NavigationItem.js.map +1 -0
- package/dist/layouts/SidebarLayout.d.ts +3 -0
- package/dist/layouts/SidebarLayout.js +5 -0
- package/dist/layouts/SidebarLayout.js.map +1 -0
- package/dist/open-closed-DgcU-HDT.js +179 -0
- package/dist/open-closed-DgcU-HDT.js.map +1 -0
- package/dist/src/components/UiLoadingDots.d.ts +1 -1
- package/dist/src/components/UiNavLink.d.ts +1 -1
- package/dist/src/components/inputs/ComboboxInput.d.ts +2 -2
- package/dist/src/components/inputs/SelectInput.d.ts +2 -2
- package/dist/src/components/layouts/DashboardLayout.d.ts.map +1 -1
- package/dist/src/components/layouts/DefaultLayout.d.ts +1 -1
- package/dist/src/components/layouts/SidebarLayout.d.ts.map +1 -1
- package/dist/transition-CuxxW9dY.js +209 -0
- package/dist/transition-CuxxW9dY.js.map +1 -0
- package/package.json +2 -3
- package/dist/CheckboxInput-rWkcde69.js +0 -5
- package/dist/CheckboxInput-rWkcde69.js.map +0 -1
- package/dist/ComboboxInput-B98P_8CZ.js +0 -5
- package/dist/ComboboxInput-B98P_8CZ.js.map +0 -1
- package/dist/SelectInput-B5liNv7H.js +0 -5
- package/dist/SelectInput-B5liNv7H.js.map +0 -1
- package/dist/SwitchInput-D1k9O8gn.js +0 -5
- package/dist/SwitchInput-D1k9O8gn.js.map +0 -1
- package/dist/TextAreaInput-Di6Kstic.js +0 -5
- package/dist/TextAreaInput-Di6Kstic.js.map +0 -1
- package/dist/UiLoading-BuzCrLqO.js +0 -5
- package/dist/UiLoading-BuzCrLqO.js.map +0 -1
- package/dist/index.umd.cjs +0 -11
- package/dist/index.umd.cjs.map +0 -1
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import { createElementBlock as c, openBlock as i, createElementVNode as d, defineComponent as V, ref as p, watch as z, onMounted as A, createBlock as T, withCtx as g, normalizeClass as U, Fragment as S, renderList as k, withDirectives as C, toDisplayString as h, normalizeStyle as F, withKeys as L, withModifiers as y, vModelText as B, createVNode as Q, unref as R, createCommentVNode as K, renderSlot as N, nextTick as W } from "vue";
|
|
2
|
+
import Z from "./components/Badge.js";
|
|
3
|
+
import j from "./forms/FormFieldWrapper.js";
|
|
4
|
+
function G(s, b) {
|
|
5
|
+
return i(), c("svg", {
|
|
6
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
7
|
+
viewBox: "0 0 20 20",
|
|
8
|
+
fill: "currentColor",
|
|
9
|
+
"aria-hidden": "true",
|
|
10
|
+
"data-slot": "icon"
|
|
11
|
+
}, [
|
|
12
|
+
d("path", { d: "M6.28 5.22a.75.75 0 0 0-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 1 0 1.06 1.06L10 11.06l3.72 3.72a.75.75 0 1 0 1.06-1.06L11.06 10l3.72-3.72a.75.75 0 0 0-1.06-1.06L10 8.94 6.28 5.22Z" })
|
|
13
|
+
]);
|
|
14
|
+
}
|
|
15
|
+
const H = { key: 0 }, P = ["onUpdate:modelValue", "placeholder", "disabled", "onKeydown", "onBlur"], X = ["onClick", "disabled"], Y = { class: "sl-flex-1 sl-min-w-0 sl-relative" }, _ = ["placeholder", "disabled", "onKeydown"], ee = { class: "sl-absolute sl-inset-y-0 sl-right-0 sl-flex sl-items-center sl-pr-3 sl-pointer-events-auto" }, te = {
|
|
16
|
+
key: 0,
|
|
17
|
+
class: "sl-absolute sl-z-50 sl-mt-1 sl-max-h-60 sl-w-full sl-overflow-auto sl-rounded-md sl-bg-white sl-py-1 sl-text-base sl-shadow-lg sl-ring-1 sl-ring-black sl-ring-opacity-5 focus:sl-outline-none sm:sl-text-sm"
|
|
18
|
+
}, le = ["onClick"], se = { class: "sl-flex" }, ae = { class: "sl-truncate sl-font-semibold" }, ne = { class: "sl-block sl-truncate" }, oe = {
|
|
19
|
+
key: 0,
|
|
20
|
+
class: "sl-ml-2 sl-truncate sl-text-gray-500"
|
|
21
|
+
}, de = /* @__PURE__ */ V({
|
|
22
|
+
__name: "TagifyInput",
|
|
23
|
+
props: {
|
|
24
|
+
items: {
|
|
25
|
+
type: Array,
|
|
26
|
+
required: !0
|
|
27
|
+
},
|
|
28
|
+
value: {
|
|
29
|
+
type: Array,
|
|
30
|
+
default: () => []
|
|
31
|
+
},
|
|
32
|
+
name: {
|
|
33
|
+
type: String,
|
|
34
|
+
required: !0
|
|
35
|
+
},
|
|
36
|
+
label: {
|
|
37
|
+
type: String,
|
|
38
|
+
required: !1
|
|
39
|
+
},
|
|
40
|
+
itemKey: {
|
|
41
|
+
type: String,
|
|
42
|
+
default: "id"
|
|
43
|
+
},
|
|
44
|
+
itemText: {
|
|
45
|
+
type: String,
|
|
46
|
+
default: "value"
|
|
47
|
+
},
|
|
48
|
+
itemSubtext: {
|
|
49
|
+
type: String,
|
|
50
|
+
default: "name"
|
|
51
|
+
},
|
|
52
|
+
showSubext: {
|
|
53
|
+
type: Boolean,
|
|
54
|
+
default: !0
|
|
55
|
+
},
|
|
56
|
+
tagDisplayKey: {
|
|
57
|
+
type: String,
|
|
58
|
+
default: "name"
|
|
59
|
+
},
|
|
60
|
+
tertiaryLabel: {
|
|
61
|
+
type: String,
|
|
62
|
+
required: !1
|
|
63
|
+
},
|
|
64
|
+
pattern: {
|
|
65
|
+
type: RegExp,
|
|
66
|
+
default: null
|
|
67
|
+
},
|
|
68
|
+
inline: {
|
|
69
|
+
type: Boolean,
|
|
70
|
+
default: !1
|
|
71
|
+
},
|
|
72
|
+
placeholder: {
|
|
73
|
+
type: String,
|
|
74
|
+
default: "Add a tag..."
|
|
75
|
+
},
|
|
76
|
+
disabled: {
|
|
77
|
+
type: Boolean,
|
|
78
|
+
default: !1
|
|
79
|
+
},
|
|
80
|
+
optional: {
|
|
81
|
+
type: Boolean,
|
|
82
|
+
default: !1
|
|
83
|
+
},
|
|
84
|
+
errorMessage: {
|
|
85
|
+
type: String,
|
|
86
|
+
default: ""
|
|
87
|
+
},
|
|
88
|
+
hasInputRing: {
|
|
89
|
+
type: Boolean,
|
|
90
|
+
default: !1
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
emits: ["update:value", "update:query", "invalid-tag"],
|
|
94
|
+
setup(s, { expose: b, emit: D }) {
|
|
95
|
+
const t = s, m = D, r = p(""), v = p([]), n = p(JSON.parse(JSON.stringify(t.value))), f = p(!1);
|
|
96
|
+
z(
|
|
97
|
+
() => t.value,
|
|
98
|
+
(e) => {
|
|
99
|
+
JSON.stringify(e) !== JSON.stringify(n.value) && (n.value = JSON.parse(JSON.stringify(e)));
|
|
100
|
+
},
|
|
101
|
+
{ deep: !0 }
|
|
102
|
+
);
|
|
103
|
+
const q = (e) => e[t.itemSubtext] || e[t.itemText], E = (e) => e[t.itemSubtext] ? e[t.itemText] : void 0, I = (e) => e[t.tagDisplayKey] || e[t.itemText], $ = () => {
|
|
104
|
+
if (r.value && r.value.length > 0) {
|
|
105
|
+
m("update:query", r.value);
|
|
106
|
+
const e = r.value.toLowerCase();
|
|
107
|
+
v.value = t.items.filter((a) => a[t.itemText]?.toLowerCase().includes(e) || a[t.itemSubtext]?.toLowerCase().includes(e)), f.value = !0;
|
|
108
|
+
} else
|
|
109
|
+
v.value = [], f.value = !1;
|
|
110
|
+
}, J = () => {
|
|
111
|
+
const e = r.value.trim();
|
|
112
|
+
if (e === "")
|
|
113
|
+
return;
|
|
114
|
+
let a = null;
|
|
115
|
+
const l = e.toLowerCase(), u = t.items.find(
|
|
116
|
+
(o) => o[t.itemText]?.toLowerCase() === l || o[t.itemSubtext]?.toLowerCase() === l
|
|
117
|
+
);
|
|
118
|
+
if (u)
|
|
119
|
+
a = { ...u };
|
|
120
|
+
else if (t.pattern && t.pattern.test(e))
|
|
121
|
+
a = { id: null, [t.itemText]: e };
|
|
122
|
+
else
|
|
123
|
+
return;
|
|
124
|
+
n.value.some(
|
|
125
|
+
(o) => o[t.itemText] === a[t.itemText]
|
|
126
|
+
) || (n.value.push(a), m("update:value", n.value)), r.value = "", v.value = [], f.value = !1;
|
|
127
|
+
}, M = (e) => {
|
|
128
|
+
const a = e[t.itemText].trim();
|
|
129
|
+
n.value.some(
|
|
130
|
+
(l) => l[t.itemText] === a
|
|
131
|
+
) || (n.value.push({ ...e }), m("update:value", n.value)), r.value = "", v.value = [], f.value = !1;
|
|
132
|
+
}, x = (e) => {
|
|
133
|
+
n.value.splice(e, 1), m("update:value", n.value);
|
|
134
|
+
}, O = (e) => {
|
|
135
|
+
n.value[e].isEditing = !0, W(() => {
|
|
136
|
+
});
|
|
137
|
+
}, w = (e) => {
|
|
138
|
+
const a = n.value[e];
|
|
139
|
+
if (a) {
|
|
140
|
+
a.isEditing = !1;
|
|
141
|
+
const l = a[t.itemText].trim();
|
|
142
|
+
if (t.pattern && !t.pattern.test(l)) {
|
|
143
|
+
m("invalid-tag", l), x(e);
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
a[t.itemText] = l, m("update:value", n.value);
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
return A(() => {
|
|
150
|
+
v.value = [];
|
|
151
|
+
}), b({
|
|
152
|
+
selectedTags: n
|
|
153
|
+
}), (e, a) => (i(), T(j, {
|
|
154
|
+
id: s.name,
|
|
155
|
+
name: s.name,
|
|
156
|
+
label: s.label,
|
|
157
|
+
"tertiary-label": s.tertiaryLabel,
|
|
158
|
+
"error-message": s.errorMessage,
|
|
159
|
+
disabled: s.disabled,
|
|
160
|
+
optional: s.optional
|
|
161
|
+
}, {
|
|
162
|
+
"tertiary-label-overlay": g(() => [
|
|
163
|
+
N(e.$slots, "tertiary-overlay")
|
|
164
|
+
]),
|
|
165
|
+
default: g(() => [
|
|
166
|
+
d("div", {
|
|
167
|
+
class: U(["sl-flex sl-flex-wrap sl-items-center sl-gap-4 sl-rounded-md sl-bg-white sl-px-3 sm:sl-text-sm sm:sl-leading-6", s.inline ? null : "sl-shadow-sm sl-border sl-border-gray-300 focus-within:sl-ring-2 focus-within:sl-ring-stachelock-600"])
|
|
168
|
+
}, [
|
|
169
|
+
(i(!0), c(S, null, k(n.value, (l, u) => (i(), T(Z, {
|
|
170
|
+
key: u,
|
|
171
|
+
onClick: (o) => O(u),
|
|
172
|
+
theme: "primary",
|
|
173
|
+
size: "sm"
|
|
174
|
+
}, {
|
|
175
|
+
default: g(() => [
|
|
176
|
+
l.isEditing ? C((i(), c("input", {
|
|
177
|
+
key: 1,
|
|
178
|
+
ref_for: !0,
|
|
179
|
+
ref: "editInput",
|
|
180
|
+
"onUpdate:modelValue": (o) => l[t.itemText] = o,
|
|
181
|
+
placeholder: s.placeholder,
|
|
182
|
+
disabled: s.disabled,
|
|
183
|
+
onKeydown: L(y((o) => w(u), ["prevent"]), ["enter"]),
|
|
184
|
+
onBlur: (o) => w(u),
|
|
185
|
+
class: "sl-bg-transparent sl-border-none sl-outline-none sl-text-stachelock-600 sl-text-sm placeholder:sl-text-stachelock-400/80 focus:sl-ring-0 focus:sl-ring-stachelock-600 focus:sl-rounded-lg -sl-mx-3 -sl-my-2",
|
|
186
|
+
style: F({ width: l[t.itemText].length + 4 + "ch" })
|
|
187
|
+
}, null, 44, P)), [
|
|
188
|
+
[B, l[t.itemText]]
|
|
189
|
+
]) : (i(), c("span", H, h(I(l)), 1)),
|
|
190
|
+
d("button", {
|
|
191
|
+
type: "button",
|
|
192
|
+
class: "sl-ml-2 sl-text-stachelock-600 hover:sl-text-stachelock-400 focus:sl-outline-none",
|
|
193
|
+
onClick: y((o) => x(u), ["stop"]),
|
|
194
|
+
disabled: s.disabled
|
|
195
|
+
}, [
|
|
196
|
+
Q(R(G), { class: "sl-h-4 sl-w-4" })
|
|
197
|
+
], 8, X)
|
|
198
|
+
]),
|
|
199
|
+
_: 2
|
|
200
|
+
}, 1032, ["onClick"]))), 128)),
|
|
201
|
+
d("div", Y, [
|
|
202
|
+
C(d("input", {
|
|
203
|
+
ref: "input",
|
|
204
|
+
"onUpdate:modelValue": a[0] || (a[0] = (l) => r.value = l),
|
|
205
|
+
placeholder: s.placeholder,
|
|
206
|
+
onInput: $,
|
|
207
|
+
disabled: s.disabled,
|
|
208
|
+
onKeydown: L(y(J, ["prevent"]), ["enter"]),
|
|
209
|
+
class: "sl-w-full sl-border-none sl-outline-none sl-rounded-md focus:sl-ring-0 sl-text-sm sl-font-light -sl-mx-3 sl-pr-12"
|
|
210
|
+
}, null, 40, _), [
|
|
211
|
+
[B, r.value]
|
|
212
|
+
]),
|
|
213
|
+
d("div", ee, [
|
|
214
|
+
N(e.$slots, "input-overlay")
|
|
215
|
+
]),
|
|
216
|
+
f.value && !s.disabled ? (i(), c("div", te, [
|
|
217
|
+
(i(!0), c(S, null, k(v.value, (l) => (i(), c("div", {
|
|
218
|
+
key: l[s.itemKey],
|
|
219
|
+
class: "sl-cursor-pointer sl-select-none sl-py-2 sl-pl-3 sl-pr-9 hover:sl-bg-stachelock-600 hover:sl-text-white",
|
|
220
|
+
onClick: y((u) => M(l), ["prevent"])
|
|
221
|
+
}, [
|
|
222
|
+
d("div", se, [
|
|
223
|
+
d("span", ae, [
|
|
224
|
+
d("span", ne, h(q(l)), 1)
|
|
225
|
+
]),
|
|
226
|
+
s.showSubext ? (i(), c("span", oe, h(E(l)), 1)) : K("", !0)
|
|
227
|
+
])
|
|
228
|
+
], 8, le))), 128))
|
|
229
|
+
])) : K("", !0)
|
|
230
|
+
])
|
|
231
|
+
], 2)
|
|
232
|
+
]),
|
|
233
|
+
_: 3
|
|
234
|
+
}, 8, ["id", "name", "label", "tertiary-label", "error-message", "disabled", "optional"]));
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
export {
|
|
238
|
+
de as _
|
|
239
|
+
};
|
|
240
|
+
//# sourceMappingURL=TagifyInput.vue_vue_type_script_setup_true_lang-DRR6jt_8.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TagifyInput.vue_vue_type_script_setup_true_lang-DRR6jt_8.js","sources":["../node_modules/@heroicons/vue/20/solid/esm/XMarkIcon.js","../src/components/inputs/TagifyInput.vue"],"sourcesContent":["import { createElementVNode as _createElementVNode, openBlock as _openBlock, createElementBlock as _createElementBlock } from \"vue\"\n\nexport default function render(_ctx, _cache) {\n return (_openBlock(), _createElementBlock(\"svg\", {\n xmlns: \"http://www.w3.org/2000/svg\",\n viewBox: \"0 0 20 20\",\n fill: \"currentColor\",\n \"aria-hidden\": \"true\",\n \"data-slot\": \"icon\"\n }, [\n _createElementVNode(\"path\", { d: \"M6.28 5.22a.75.75 0 0 0-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 1 0 1.06 1.06L10 11.06l3.72 3.72a.75.75 0 1 0 1.06-1.06L11.06 10l3.72-3.72a.75.75 0 0 0-1.06-1.06L10 8.94 6.28 5.22Z\" })\n ]))\n}","<template>\n <FormFieldWrapper\n :id=\"name\"\n :name=\"name\"\n :label=\"label\"\n :tertiary-label=\"tertiaryLabel\"\n :error-message=\"errorMessage\"\n :disabled=\"disabled\"\n :optional=\"optional\"\n >\n <template #tertiary-label-overlay>\n <slot name=\"tertiary-overlay\"></slot>\n </template>\n \n <div class=\"sl-flex sl-flex-wrap sl-items-center sl-gap-4 sl-rounded-md sl-bg-white sl-px-3 sm:sl-text-sm sm:sl-leading-6\"\n :class=\"inline ? null : 'sl-shadow-sm sl-border sl-border-gray-300 focus-within:sl-ring-2 focus-within:sl-ring-stachelock-600'\">\n <!-- Display selected tags as badges -->\n <UiBadge v-for=\"(tag, index) in selectedTags\" :key=\"index\" @click=\"editTag(index)\" theme=\"primary\" size=\"sm\">\n <span v-if=\"!tag.isEditing\">{{ tagDisplay(tag) }}</span>\n <input v-else ref=\"editInput\" v-model=\"tag[props.itemText]\" :placeholder=\"placeholder\"\n :disabled=\"disabled\" @keydown.enter.prevent=\"stopEditingTag(index)\"\n @blur=\"stopEditingTag(index)\"\n class=\"sl-bg-transparent sl-border-none sl-outline-none sl-text-stachelock-600 sl-text-sm placeholder:sl-text-stachelock-400/80 focus:sl-ring-0 focus:sl-ring-stachelock-600 focus:sl-rounded-lg -sl-mx-3 -sl-my-2\"\n :style=\"{ width: tag[props.itemText].length + 4 + 'ch' }\" />\n <button type=\"button\" class=\"sl-ml-2 sl-text-stachelock-600 hover:sl-text-stachelock-400 focus:sl-outline-none\"\n @click.stop=\"removeTag(index)\" :disabled=\"disabled\">\n <XMarkIcon class=\"sl-h-4 sl-w-4\" />\n </button>\n </UiBadge>\n <!-- Input for adding new tags -->\n <div class=\"sl-flex-1 sl-min-w-0 sl-relative\">\n <input ref=\"input\" v-model=\"query\" :placeholder=\"placeholder\" @input=\"filterItems\"\n :disabled=\"disabled\" @keydown.enter.prevent=\"addTag\"\n class=\"sl-w-full sl-border-none sl-outline-none sl-rounded-md focus:sl-ring-0 sl-text-sm sl-font-light -sl-mx-3 sl-pr-12\" />\n <!-- Overlay slot aligned to the far right -->\n <div class=\"sl-absolute sl-inset-y-0 sl-right-0 sl-flex sl-items-center sl-pr-3 sl-pointer-events-auto\">\n <slot name=\"input-overlay\" />\n </div>\n <!-- Suggestions Dropdown -->\n <div v-if=\"showDropdown && !disabled\"\n class=\"sl-absolute sl-z-50 sl-mt-1 sl-max-h-60 sl-w-full sl-overflow-auto sl-rounded-md sl-bg-white sl-py-1 sl-text-base sl-shadow-lg sl-ring-1 sl-ring-black sl-ring-opacity-5 focus:sl-outline-none sm:sl-text-sm\">\n <div v-for=\"item in filteredItems\" :key=\"item[itemKey]\"\n class=\"sl-cursor-pointer sl-select-none sl-py-2 sl-pl-3 sl-pr-9 hover:sl-bg-stachelock-600 hover:sl-text-white\"\n @click.prevent=\"selectSuggestion(item)\">\n <div class=\"sl-flex\">\n <span class=\"sl-truncate sl-font-semibold\">\n <span class=\"sl-block sl-truncate\">{{ itemDisplay(item) }}</span>\n </span>\n <span v-if=\"showSubext\" class=\"sl-ml-2 sl-truncate sl-text-gray-500\">\n {{ itemSecondaryDisplay(item) }}\n </span>\n </div>\n </div>\n </div>\n </div>\n </div>\n </FormFieldWrapper>\n</template>\n\n<script lang=\"ts\" setup>\nimport { ref, watch, onMounted, nextTick } from 'vue';\nimport { XMarkIcon } from '@heroicons/vue/20/solid';\nimport UiBadge from '../UiBadge.vue';\nimport FormFieldWrapper from '../forms/FormFieldWrapper.vue';\n\ninterface Item {\n id: string | number | null;\n [key: string]: any; // Allows dynamic keys like 'value' or 'name'\n}\n\nconst props = defineProps({\n items: {\n type: Array as () => Item[],\n required: true,\n },\n value: {\n type: Array as () => Item[],\n default: () => [],\n },\n name: {\n type: String,\n required: true,\n },\n label: {\n type: String,\n required: false,\n },\n itemKey: {\n type: String,\n default: 'id',\n },\n itemText: {\n type: String,\n default: 'value',\n },\n itemSubtext: {\n type: String,\n default: 'name',\n },\n showSubext: {\n type: Boolean,\n default: true\n },\n tagDisplayKey: {\n type: String,\n default: 'name',\n },\n tertiaryLabel: {\n type: String,\n required: false,\n },\n pattern: {\n type: RegExp,\n default: null,\n },\n inline: {\n type: Boolean,\n default: false,\n },\n placeholder: {\n type: String,\n default: 'Add a tag...',\n },\n disabled: {\n type: Boolean,\n default: false\n },\n optional: {\n type: Boolean,\n default: false\n },\n errorMessage: {\n type: String,\n default: ''\n },\n hasInputRing: {\n type: Boolean,\n default: false\n }\n});\n\nconst emits = defineEmits(['update:value', 'update:query', 'invalid-tag']);\n\nconst query = ref<string>('');\nconst filteredItems = ref<Item[]>([]);\nconst selectedTags = ref<Item[]>(JSON.parse(JSON.stringify(props.value)));\nconst showDropdown = ref(false);\n\nwatch(\n () => props.value,\n (newVal) => {\n if (JSON.stringify(newVal) !== JSON.stringify(selectedTags.value)) {\n selectedTags.value = JSON.parse(JSON.stringify(newVal));\n }\n },\n { deep: true }\n);\n\nconst itemDisplay = (item: Item) => item[props.itemSubtext] || item[props.itemText];\nconst itemSecondaryDisplay = (item: Item) => item[props.itemSubtext] ? item[props.itemText] : undefined;\nconst tagDisplay = (tag: Item) => tag[props.tagDisplayKey] || tag[props.itemText];\n\nconst filterItems = () => {\n if (query.value && query.value.length > 0) {\n emits('update:query', query.value);\n\n // Simple filtering logic\n const lowerQuery = query.value.toLowerCase();\n filteredItems.value = props.items.filter((item) => {\n return (\n item[props.itemText]?.toLowerCase().includes(lowerQuery) ||\n item[props.itemSubtext]?.toLowerCase().includes(lowerQuery)\n );\n });\n showDropdown.value = true;\n } else {\n filteredItems.value = [];\n showDropdown.value = false;\n }\n};\n\nconst addTag = () => {\n const trimmedQuery = query.value.trim();\n if (trimmedQuery === '') {\n return;\n }\n\n let tagToAdd: Item | null = null;\n\n const lowerQuery = trimmedQuery.toLowerCase();\n\n // Check if the query matches any item in the items list\n const matchedItem = props.items.find(\n (item) =>\n item[props.itemText]?.toLowerCase() === lowerQuery ||\n item[props.itemSubtext]?.toLowerCase() === lowerQuery\n );\n\n if (matchedItem) {\n tagToAdd = { ...matchedItem };\n } else if (props.pattern && props.pattern.test(trimmedQuery)) {\n // Create a new item if it doesn't exist and matches the pattern\n tagToAdd = { id: null, [props.itemText]: trimmedQuery };\n } else {\n // Do not emit invalid-tag here; let the user continue typing\n return;\n }\n\n // Avoid duplicates\n if (\n !selectedTags.value.some(\n (tag) => tag[props.itemText] === tagToAdd![props.itemText]\n )\n ) {\n selectedTags.value.push(tagToAdd!);\n emits('update:value', selectedTags.value);\n }\n\n query.value = '';\n filteredItems.value = [];\n showDropdown.value = false;\n};\n\nconst selectSuggestion = (item: Item) => {\n const valueToTest = item[props.itemText].trim();\n\n // Avoid duplicates\n if (\n !selectedTags.value.some(\n (tag) => tag[props.itemText] === valueToTest\n )\n ) {\n selectedTags.value.push({ ...item });\n emits('update:value', selectedTags.value);\n }\n query.value = '';\n filteredItems.value = [];\n showDropdown.value = false;\n};\n\nconst removeTag = (index: number) => {\n selectedTags.value.splice(index, 1);\n emits('update:value', selectedTags.value);\n};\n\nconst editTag = (index: number) => {\n selectedTags.value[index].isEditing = true;\n nextTick(() => {\n // Focus logic can be added here if needed\n });\n};\n\nconst stopEditingTag = (index: number) => {\n const tag = selectedTags.value[index];\n if (tag) {\n tag.isEditing = false;\n const valueToTest = tag[props.itemText].trim();\n\n // Validate tag if pattern is provided\n if (props.pattern && !props.pattern.test(valueToTest)) {\n emits('invalid-tag', valueToTest);\n removeTag(index);\n return;\n }\n\n // Update the tag value after trimming\n tag[props.itemText] = valueToTest;\n emits('update:value', selectedTags.value);\n }\n};\n\nonMounted(() => {\n // Initialize filteredItems\n filteredItems.value = [];\n});\n\ndefineExpose({\n selectedTags,\n});\n</script>\n\n<style scoped>\n</style>\n"],"names":["render","_ctx","_cache","_openBlock","_createElementBlock","_createElementVNode","props","__props","emits","__emit","query","ref","filteredItems","selectedTags","showDropdown","watch","newVal","itemDisplay","item","itemSecondaryDisplay","tagDisplay","tag","filterItems","lowerQuery","addTag","trimmedQuery","tagToAdd","matchedItem","selectSuggestion","valueToTest","removeTag","index","editTag","nextTick","stopEditingTag","onMounted","__expose","_createBlock","FormFieldWrapper","_renderSlot","_normalizeClass","_Fragment","_renderList","UiBadge","$event","_withKeys","_withModifiers","_hoisted_1","_toDisplayString","_createVNode","_unref","XMarkIcon","_hoisted_4","_hoisted_6","_hoisted_7","_hoisted_9","_hoisted_10","_hoisted_11","_hoisted_12"],"mappings":";;;AAEe,SAASA,EAAOC,GAAMC,GAAQ;AAC3C,SAAQC,EAAU,GAAIC,EAAoB,OAAO;AAAA,IAC/C,OAAO;AAAA,IACP,SAAS;AAAA,IACT,MAAM;AAAA,IACN,eAAe;AAAA,IACf,aAAa;AAAA,EACjB,GAAK;AAAA,IACDC,EAAoB,QAAQ,EAAE,GAAG,qLAAoL,CAAE;AAAA,EAC3N,CAAG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC0DA,UAAMC,IAAQC,GAuERC,IAAQC,GAERC,IAAQC,EAAY,EAAE,GACtBC,IAAgBD,EAAY,EAAE,GAC9BE,IAAeF,EAAY,KAAK,MAAM,KAAK,UAAUL,EAAM,KAAK,CAAC,CAAC,GAClEQ,IAAeH,EAAI,EAAK;AAE9B,IAAAI;AAAA,MACE,MAAMT,EAAM;AAAA,MACZ,CAACU,MAAW;AACV,QAAI,KAAK,UAAUA,CAAM,MAAM,KAAK,UAAUH,EAAa,KAAK,MAC9DA,EAAa,QAAQ,KAAK,MAAM,KAAK,UAAUG,CAAM,CAAC;AAAA,MAE1D;AAAA,MACA,EAAE,MAAM,GAAA;AAAA,IAAK;AAGf,UAAMC,IAAc,CAACC,MAAeA,EAAKZ,EAAM,WAAW,KAAKY,EAAKZ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1,158 @@
|
|
|
1
|
+
import { defineComponent as S, ref as z, watch as h, computed as F, createElementBlock as d, openBlock as u, createVNode as O, unref as a, withCtx as g, createElementVNode as f, withDirectives as I, createCommentVNode as b, mergeProps as N, isRef as R, vModelText as j, toDisplayString as i } from "vue";
|
|
2
|
+
import { useField as A } from "vee-validate";
|
|
3
|
+
import D from "./forms/FormFieldWrapper.js";
|
|
4
|
+
import { g as E } from "./id-DafBB_QF.js";
|
|
5
|
+
const L = { class: "sl-w-full" }, T = { class: "sl-relative" }, P = ["id", "name", "disabled", "placeholder", "spellcheck", "rows", "maxlength"], U = {
|
|
6
|
+
key: 0,
|
|
7
|
+
class: "sl-absolute sl-bottom-2 sl-right-2 sl-text-xs sl-text-slate-500 sl-pointer-events-none"
|
|
8
|
+
}, W = { key: 0 }, Q = /* @__PURE__ */ S({
|
|
9
|
+
__name: "TextAreaInput",
|
|
10
|
+
props: {
|
|
11
|
+
name: {},
|
|
12
|
+
label: {},
|
|
13
|
+
placeholder: {},
|
|
14
|
+
disabled: { type: Boolean },
|
|
15
|
+
rules: {},
|
|
16
|
+
validateOnMount: { type: Boolean },
|
|
17
|
+
successMessage: {},
|
|
18
|
+
tertiaryLabel: {},
|
|
19
|
+
spellcheck: { type: Boolean, default: !0 },
|
|
20
|
+
rows: { default: 4 },
|
|
21
|
+
maxlength: {},
|
|
22
|
+
inputClass: {},
|
|
23
|
+
inputStyle: { type: [Boolean, null, String, Object, Array] },
|
|
24
|
+
lazy: { type: Boolean, default: !1 },
|
|
25
|
+
modelValue: {},
|
|
26
|
+
boxShadow: { type: Boolean, default: !1 }
|
|
27
|
+
},
|
|
28
|
+
emits: ["update:modelValue", "blur", "focus"],
|
|
29
|
+
setup(y, { expose: v, emit: w }) {
|
|
30
|
+
const s = y, n = w, t = z(), c = E(s.name), { value: l, errorMessage: m, handleBlur: k, handleChange: p, meta: r } = A(
|
|
31
|
+
() => s.name,
|
|
32
|
+
s.rules,
|
|
33
|
+
{
|
|
34
|
+
validateOnMount: s.validateOnMount,
|
|
35
|
+
initialValue: s.modelValue,
|
|
36
|
+
syncVModel: !0
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
h(
|
|
40
|
+
() => s.modelValue,
|
|
41
|
+
(e) => {
|
|
42
|
+
e !== l.value && (l.value = e || "");
|
|
43
|
+
}
|
|
44
|
+
), h(
|
|
45
|
+
l,
|
|
46
|
+
(e) => {
|
|
47
|
+
n("update:modelValue", e);
|
|
48
|
+
}
|
|
49
|
+
);
|
|
50
|
+
const B = F(() => {
|
|
51
|
+
const e = [
|
|
52
|
+
"sl-w-full",
|
|
53
|
+
"sl-px-3",
|
|
54
|
+
"sl-py-2",
|
|
55
|
+
"sl-text-sm",
|
|
56
|
+
"sl-border",
|
|
57
|
+
"sl-rounded-md",
|
|
58
|
+
"sl-bg-white",
|
|
59
|
+
"sl-transition-all",
|
|
60
|
+
"sl-duration-200",
|
|
61
|
+
"focus:sl-outline-none",
|
|
62
|
+
"focus:sl-ring-2",
|
|
63
|
+
"focus:sl-ring-stachelock-500",
|
|
64
|
+
"focus:sl-border-stachelock-500",
|
|
65
|
+
"sl-resize-y",
|
|
66
|
+
"sl-min-h-[80px]"
|
|
67
|
+
];
|
|
68
|
+
return s.disabled ? e.push(
|
|
69
|
+
"sl-bg-gray-50",
|
|
70
|
+
"sl-text-gray-500",
|
|
71
|
+
"sl-cursor-not-allowed",
|
|
72
|
+
"sl-border-gray-200"
|
|
73
|
+
) : m.value ? e.push(
|
|
74
|
+
"sl-border-red-300",
|
|
75
|
+
"focus:sl-ring-red-500",
|
|
76
|
+
"focus:sl-border-red-500"
|
|
77
|
+
) : r.valid && r.touched ? e.push(
|
|
78
|
+
"sl-border-green-300",
|
|
79
|
+
"focus:sl-ring-green-500",
|
|
80
|
+
"focus:sl-border-green-500"
|
|
81
|
+
) : e.push(
|
|
82
|
+
"sl-border-gray-300",
|
|
83
|
+
"hover:sl-border-gray-400"
|
|
84
|
+
), e.join(" ");
|
|
85
|
+
}), M = (e) => {
|
|
86
|
+
const o = e.target;
|
|
87
|
+
s.lazy || p(o.value);
|
|
88
|
+
}, V = (e) => {
|
|
89
|
+
if (s.lazy) {
|
|
90
|
+
const o = e.target;
|
|
91
|
+
p(o.value);
|
|
92
|
+
}
|
|
93
|
+
k(e), n("blur", e);
|
|
94
|
+
}, C = (e) => {
|
|
95
|
+
n("focus", e);
|
|
96
|
+
};
|
|
97
|
+
return v({
|
|
98
|
+
focus: () => {
|
|
99
|
+
t.value?.focus();
|
|
100
|
+
},
|
|
101
|
+
blur: () => {
|
|
102
|
+
t.value?.blur();
|
|
103
|
+
},
|
|
104
|
+
textareaRef: t
|
|
105
|
+
}), (e, o) => (u(), d("div", L, [
|
|
106
|
+
O(D, {
|
|
107
|
+
id: a(c),
|
|
108
|
+
name: e.name,
|
|
109
|
+
label: e.label,
|
|
110
|
+
disabled: e.disabled,
|
|
111
|
+
optional: !e.rules,
|
|
112
|
+
"tertiary-label": e.tertiaryLabel,
|
|
113
|
+
"box-shadow": e.boxShadow,
|
|
114
|
+
"error-message": a(m),
|
|
115
|
+
"success-message": e.successMessage,
|
|
116
|
+
"is-valid": a(r).valid,
|
|
117
|
+
"is-touched": a(r).touched
|
|
118
|
+
}, {
|
|
119
|
+
"success-message": g(() => [
|
|
120
|
+
e.successMessage ? (u(), d("span", W, i(e.successMessage), 1)) : b("", !0)
|
|
121
|
+
]),
|
|
122
|
+
default: g(() => [
|
|
123
|
+
f("div", T, [
|
|
124
|
+
I(f("textarea", N({
|
|
125
|
+
id: a(c),
|
|
126
|
+
ref_key: "textareaRef",
|
|
127
|
+
ref: t,
|
|
128
|
+
"onUpdate:modelValue": o[0] || (o[0] = (x) => R(l) ? l.value = x : null),
|
|
129
|
+
name: e.name,
|
|
130
|
+
disabled: e.disabled,
|
|
131
|
+
placeholder: e.placeholder,
|
|
132
|
+
class: [
|
|
133
|
+
B.value,
|
|
134
|
+
e.inputClass
|
|
135
|
+
],
|
|
136
|
+
style: e.inputStyle,
|
|
137
|
+
spellcheck: e.spellcheck,
|
|
138
|
+
rows: e.rows,
|
|
139
|
+
maxlength: e.maxlength
|
|
140
|
+
}, e.$attrs, {
|
|
141
|
+
onBlur: V,
|
|
142
|
+
onFocus: C,
|
|
143
|
+
onInput: M
|
|
144
|
+
}), null, 16, P), [
|
|
145
|
+
[j, a(l)]
|
|
146
|
+
]),
|
|
147
|
+
e.maxlength !== void 0 ? (u(), d("div", U, i(a(l)?.length || 0) + "/" + i(e.maxlength), 1)) : b("", !0)
|
|
148
|
+
])
|
|
149
|
+
]),
|
|
150
|
+
_: 1
|
|
151
|
+
}, 8, ["id", "name", "label", "disabled", "optional", "tertiary-label", "box-shadow", "error-message", "success-message", "is-valid", "is-touched"])
|
|
152
|
+
]));
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
export {
|
|
156
|
+
Q as _
|
|
157
|
+
};
|
|
158
|
+
//# sourceMappingURL=TextAreaInput.vue_vue_type_script_setup_true_lang-CbR651TU.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextAreaInput.vue_vue_type_script_setup_true_lang-CbR651TU.js","sources":["../src/components/inputs/TextAreaInput.vue"],"sourcesContent":["<template>\n <div class=\"sl-w-full\">\n <FormFieldWrapper\n :id=\"id\"\n :name=\"name\"\n :label=\"label\"\n :disabled=\"disabled\"\n :optional=\"!rules\"\n :tertiary-label=\"tertiaryLabel\"\n :box-shadow=\"boxShadow\"\n :error-message=\"errorMessage\"\n :success-message=\"successMessage\"\n :is-valid=\"meta.valid\"\n :is-touched=\"meta.touched\"\n >\n <div class=\"sl-relative\">\n <textarea\n :id=\"id\"\n ref=\"textareaRef\"\n v-model=\"value\"\n :name=\"name\"\n :disabled=\"disabled\"\n :placeholder=\"placeholder\"\n :class=\"[\n textareaClasses,\n inputClass\n ]\"\n :style=\"inputStyle\"\n :spellcheck=\"spellcheck\"\n :rows=\"rows\"\n :maxlength=\"maxlength\"\n v-bind=\"$attrs\"\n @blur=\"onBlur\"\n @focus=\"onFocus\"\n @input=\"onInput\"\n />\n \n <!-- Character count -->\n <div \n v-if=\"maxlength !== undefined\" \n class=\"sl-absolute sl-bottom-2 sl-right-2 sl-text-xs sl-text-slate-500 sl-pointer-events-none\"\n >\n {{ value?.length || 0 }}/{{ maxlength }}\n </div>\n </div>\n \n <template #success-message>\n <span v-if=\"successMessage\">{{ successMessage }}</span>\n </template>\n </FormFieldWrapper>\n </div>\n</template>\n\n<script setup lang=\"ts\">\nimport { computed, ref, watch, type StyleValue } from 'vue'\nimport { useField } from 'vee-validate'\nimport FormFieldWrapper from '../forms/FormFieldWrapper.vue'\nimport type { ValidationRule } from '../../types/form'\nimport { generateId } from '../../utils/id'\n\ninterface Props {\n name: string\n label?: string\n placeholder?: string\n disabled?: boolean\n rules?: ValidationRule\n validateOnMount?: boolean\n successMessage?: string\n tertiaryLabel?: string\n spellcheck?: boolean\n rows?: number\n maxlength?: number\n inputClass?: string\n inputStyle?: StyleValue\n lazy?: boolean\n modelValue?: string\n boxShadow?: boolean\n}\n\nconst props = withDefaults(defineProps<Props>(), {\n spellcheck: true,\n rows: 4,\n lazy: false,\n boxShadow: false\n})\n\nconst emit = defineEmits<{\n 'update:modelValue': [value: string]\n blur: [event: FocusEvent]\n focus: [event: FocusEvent]\n}>()\n\nconst textareaRef = ref<HTMLTextAreaElement>()\nconst id = generateId(props.name)\n\n// Use vee-validate for form validation\nconst { value, errorMessage, handleBlur, handleChange, meta } = useField(\n () => props.name,\n props.rules,\n {\n validateOnMount: props.validateOnMount,\n initialValue: props.modelValue,\n syncVModel: true\n }\n)\n\n// Sync with v-model\nwatch(\n () => props.modelValue,\n (newValue) => {\n if (newValue !== value.value) {\n value.value = newValue || ''\n }\n }\n)\n\nwatch(\n value,\n (newValue) => {\n emit('update:modelValue', newValue)\n }\n)\n\nconst textareaClasses = computed(() => {\n const baseClasses = [\n 'sl-w-full',\n 'sl-px-3',\n 'sl-py-2',\n 'sl-text-sm',\n 'sl-border',\n 'sl-rounded-md',\n 'sl-bg-white',\n 'sl-transition-all',\n 'sl-duration-200',\n 'focus:sl-outline-none',\n 'focus:sl-ring-2',\n 'focus:sl-ring-stachelock-500',\n 'focus:sl-border-stachelock-500',\n 'sl-resize-y',\n 'sl-min-h-[80px]'\n ]\n\n if (props.disabled) {\n baseClasses.push(\n 'sl-bg-gray-50',\n 'sl-text-gray-500',\n 'sl-cursor-not-allowed',\n 'sl-border-gray-200'\n )\n } else if (errorMessage.value) {\n baseClasses.push(\n 'sl-border-red-300',\n 'focus:sl-ring-red-500',\n 'focus:sl-border-red-500'\n )\n } else if (meta.valid && meta.touched) {\n baseClasses.push(\n 'sl-border-green-300',\n 'focus:sl-ring-green-500',\n 'focus:sl-border-green-500'\n )\n } else {\n baseClasses.push(\n 'sl-border-gray-300',\n 'hover:sl-border-gray-400'\n )\n }\n\n return baseClasses.join(' ')\n})\n\nconst onInput = (event: Event) => {\n const target = event.target as HTMLTextAreaElement\n if (!props.lazy) {\n handleChange(target.value)\n }\n}\n\nconst onBlur = (event: FocusEvent) => {\n if (props.lazy) {\n const target = event.target as HTMLTextAreaElement\n handleChange(target.value)\n }\n handleBlur(event)\n emit('blur', event)\n}\n\nconst onFocus = (event: FocusEvent) => {\n emit('focus', event)\n}\n\nconst focus = () => {\n textareaRef.value?.focus()\n}\n\nconst blur = () => {\n textareaRef.value?.blur()\n}\n\ndefineExpose({\n focus,\n blur,\n textareaRef\n})\n</script>\n\n\n"],"names":["props","__props","emit","__emit","textareaRef","ref","id","generateId","value","errorMessage","handleBlur","handleChange","meta","useField","watch","newValue","textareaClasses","computed","baseClasses","onInput","event","target","onBlur","onFocus","__expose","_openBlock","_createElementBlock","_hoisted_1","_createVNode","FormFieldWrapper","_unref","name","label","disabled","rules","tertiaryLabel","boxShadow","successMessage","_createElementVNode","_hoisted_2","_withDirectives","_mergeProps","$event","placeholder","inputClass","inputStyle","spellcheck","rows","maxlength","$attrs","_hoisted_4","_toDisplayString"],"mappings":";;;;;;;;;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AAAA;AAAAA,cACN,UAAUE,EAAAA;AAAAA,cACV,aAAaU,EAAAA;AAAAA,cACb,OAAK;AAAA,gBAAgB3B,EAAA;AAAA,gBAA6B4B,EAAAA;AAAAA,cAAAA;AAAAA,cAIlD,OAAOC,EAAAA;AAAAA,cACP,YAAYC,EAAAA;AAAAA,cACZ,MAAMC,EAAAA;AAAAA,cACN,WAAWC,EAAAA;AAAAA,YAAAA,GACJC,EAAAA,QAAM;AAAA,cACb,QAAA3B;AAAA,cACA,SAAAC;AAAA,cACA,SAAAJ;AAAA,YAAA;kBAfQW,EAAAtB,CAAA,CAAK;AAAA,YAAA;YAoBRwC,EAAAA,cAAc,eADtBtB,EAKM,OALNwB,GAKMC,EADDrB,EAAAtB,CAAA,GAAO,UAAM,CAAA,IAAQ,MAAC2C,EAAGH,EAAAA,SAAS,GAAA,CAAA;;;;;;;;"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { defineComponent as b, ref as _, computed as r, createElementBlock as i, openBlock as u, normalizeClass as c, createCommentVNode as p, createElementVNode as z, toDisplayString as P } from "vue";
|
|
2
|
+
const C = {
|
|
3
|
+
key: 0,
|
|
4
|
+
class: "sl-h-full sl-w-full"
|
|
5
|
+
}, U = ["src", "alt"], E = /* @__PURE__ */ b({
|
|
6
|
+
__name: "UiAvatar",
|
|
7
|
+
props: {
|
|
8
|
+
data: {},
|
|
9
|
+
name: {},
|
|
10
|
+
imageUrl: {},
|
|
11
|
+
size: { default: "md" },
|
|
12
|
+
color: { default: "sl-bg-stachelock-600" },
|
|
13
|
+
ring: { default: "sl-ring-white" },
|
|
14
|
+
rounded: { default: "sl-rounded-full" },
|
|
15
|
+
fallbackInitials: { default: "?" },
|
|
16
|
+
fallbackIcon: {},
|
|
17
|
+
imagePath: { default: "image.url" },
|
|
18
|
+
namePath: { default: "name" }
|
|
19
|
+
},
|
|
20
|
+
setup(v) {
|
|
21
|
+
const e = v, o = _(!1), k = () => {
|
|
22
|
+
o.value = !0;
|
|
23
|
+
}, f = {
|
|
24
|
+
xs: "sl-h-6 sl-w-6",
|
|
25
|
+
sm: "sl-h-8 sl-w-8",
|
|
26
|
+
md: "sl-h-12 sl-w-12",
|
|
27
|
+
lg: "sl-h-16 sl-w-16",
|
|
28
|
+
xl: "sl-h-20 sl-w-20",
|
|
29
|
+
"2xl": "sl-h-24 sl-w-24"
|
|
30
|
+
}, w = r(() => typeof e.size == "number" ? `sl-h-${e.size} sl-w-${e.size}` : f[e.size] || f.md), n = (l, t) => {
|
|
31
|
+
if (!l) return;
|
|
32
|
+
const a = Array.isArray(t) ? t : t.split(".");
|
|
33
|
+
let s = l;
|
|
34
|
+
for (const g of a)
|
|
35
|
+
if (s && typeof s == "object" && g in s)
|
|
36
|
+
s = s[g];
|
|
37
|
+
else
|
|
38
|
+
return;
|
|
39
|
+
return s;
|
|
40
|
+
}, m = r(() => {
|
|
41
|
+
if (e.imageUrl) return e.imageUrl;
|
|
42
|
+
if (e.data && e.imagePath) {
|
|
43
|
+
const l = n(e.data, e.imagePath);
|
|
44
|
+
if (l) return l;
|
|
45
|
+
}
|
|
46
|
+
if (e.data) {
|
|
47
|
+
const l = [
|
|
48
|
+
"profile_image.url",
|
|
49
|
+
"image.url",
|
|
50
|
+
"avatar.url",
|
|
51
|
+
"photo.url",
|
|
52
|
+
"picture.url"
|
|
53
|
+
];
|
|
54
|
+
for (const t of l) {
|
|
55
|
+
const a = n(e.data, t);
|
|
56
|
+
if (a) return a;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return null;
|
|
60
|
+
}), d = r(() => {
|
|
61
|
+
if (e.name) return e.name;
|
|
62
|
+
if (e.data && e.namePath) {
|
|
63
|
+
const l = n(e.data, e.namePath);
|
|
64
|
+
if (l) return l;
|
|
65
|
+
}
|
|
66
|
+
if (e.data) {
|
|
67
|
+
const l = [
|
|
68
|
+
"name",
|
|
69
|
+
"display_name",
|
|
70
|
+
"full_name",
|
|
71
|
+
"username",
|
|
72
|
+
"title"
|
|
73
|
+
];
|
|
74
|
+
for (const t of l) {
|
|
75
|
+
const a = n(e.data, t);
|
|
76
|
+
if (a) return a;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return "";
|
|
80
|
+
}), h = r(() => !!m.value), y = r(() => {
|
|
81
|
+
const l = d.value;
|
|
82
|
+
if (!l || l.trim() === "")
|
|
83
|
+
return e.fallbackInitials;
|
|
84
|
+
const t = l.split(" ").filter(Boolean);
|
|
85
|
+
return t.length === 0 ? e.fallbackInitials : t.length === 1 ? t[0][0].toUpperCase() : (t[0][0] + t[t.length - 1][0]).toUpperCase();
|
|
86
|
+
});
|
|
87
|
+
return (l, t) => (u(), i("div", {
|
|
88
|
+
class: c(["sl-relative sl-inline-block", [w.value, l.ring, l.rounded]])
|
|
89
|
+
}, [
|
|
90
|
+
h.value && !o.value ? (u(), i("div", C, [
|
|
91
|
+
z("img", {
|
|
92
|
+
src: m.value,
|
|
93
|
+
alt: d.value,
|
|
94
|
+
class: c(["sl-h-full sl-w-full sl-object-cover", l.rounded]),
|
|
95
|
+
onError: k
|
|
96
|
+
}, null, 42, U)
|
|
97
|
+
])) : p("", !0),
|
|
98
|
+
!h.value || o.value ? (u(), i("div", {
|
|
99
|
+
key: 1,
|
|
100
|
+
class: c(["sl-h-full sl-w-full sl-flex sl-items-center sl-justify-center sl-font-semibold sl-text-white", [l.color, l.rounded]])
|
|
101
|
+
}, P(y.value), 3)) : p("", !0)
|
|
102
|
+
], 2));
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
export {
|
|
106
|
+
E as _
|
|
107
|
+
};
|
|
108
|
+
//# sourceMappingURL=UiAvatar.vue_vue_type_script_setup_true_lang-CDNjUA1L.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UiAvatar.vue_vue_type_script_setup_true_lang-CDNjUA1L.js","sources":["../src/components/UiAvatar.vue"],"sourcesContent":["<template>\n <div class=\"sl-relative sl-inline-block\" :class=\"[sizeClass, ring, rounded]\">\n <div v-if=\"hasImage && !imageError\" class=\"sl-h-full sl-w-full\">\n <img\n :src=\"imageUrl\"\n :alt=\"displayName\"\n class=\"sl-h-full sl-w-full sl-object-cover\"\n :class=\"rounded\"\n @error=\"handleImageError\"\n />\n </div>\n <div v-if=\"!hasImage || imageError\" class=\"sl-h-full sl-w-full sl-flex sl-items-center sl-justify-center sl-font-semibold sl-text-white\"\n :class=\"[color, rounded]\">\n {{ initials }}\n </div>\n </div>\n</template>\n\n<script setup lang=\"ts\">\nimport { computed, ref } from 'vue';\n\ninterface AvatarProps {\n // Flexible data object - can be any object with optional name and image properties\n data?: Record<string, any>;\n \n // Direct properties for simple use cases\n name?: string;\n imageUrl?: string;\n \n // Size options\n size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | number;\n \n // Styling options\n color?: string;\n ring?: string;\n rounded?: string;\n \n // Image fallback options\n fallbackInitials?: string;\n fallbackIcon?: string;\n \n // Custom image path keys for different data structures\n imagePath?: string | string[]; // e.g., 'profile_image.url' or ['profile_image', 'url']\n namePath?: string | string[]; // e.g., 'display_name' or ['user', 'profile', 'name']\n}\n\nconst props = withDefaults(defineProps<AvatarProps>(), {\n size: 'md',\n color: 'sl-bg-stachelock-600',\n ring: 'sl-ring-white',\n rounded: 'sl-rounded-full',\n fallbackInitials: '?',\n imagePath: 'image.url',\n namePath: 'name'\n});\n\nconst imageError = ref(false);\n\nconst handleImageError = () => {\n imageError.value = true;\n};\n\n// Size classes mapping\nconst sizeClasses: Record<string, string> = {\n xs: 'sl-h-6 sl-w-6',\n sm: 'sl-h-8 sl-w-8',\n md: 'sl-h-12 sl-w-12',\n lg: 'sl-h-16 sl-w-16',\n xl: 'sl-h-20 sl-w-20',\n '2xl': 'sl-h-24 sl-w-24',\n};\n\nconst sizeClass = computed(() => {\n if (typeof props.size === 'number') {\n return `sl-h-${props.size} sl-w-${props.size}`;\n }\n return sizeClasses[props.size] || sizeClasses.md;\n});\n\n// Helper function to get nested object values\nconst getNestedValue = (obj: any, path: string | string[]): any => {\n if (!obj) return undefined;\n \n const keys = Array.isArray(path) ? path : path.split('.');\n let current = obj;\n \n for (const key of keys) {\n if (current && typeof current === 'object' && key in current) {\n current = current[key];\n } else {\n return undefined;\n }\n }\n \n return current;\n};\n\n// Get image URL from various sources\nconst imageUrl = computed(() => {\n // Direct imageUrl prop takes precedence\n if (props.imageUrl) return props.imageUrl;\n \n // Try to get from data object using imagePath\n if (props.data && props.imagePath) {\n const url = getNestedValue(props.data, props.imagePath);\n if (url) return url;\n }\n \n // Fallback to common image paths if no specific path provided\n if (props.data) {\n const commonPaths = [\n 'profile_image.url',\n 'image.url',\n 'avatar.url',\n 'photo.url',\n 'picture.url'\n ];\n \n for (const path of commonPaths) {\n const url = getNestedValue(props.data, path);\n if (url) return url;\n }\n }\n \n return null;\n});\n\n// Get display name from various sources\nconst displayName = computed(() => {\n // Direct name prop takes precedence\n if (props.name) return props.name;\n \n // Try to get from data object using namePath\n if (props.data && props.namePath) {\n const name = getNestedValue(props.data, props.namePath);\n if (name) return name;\n }\n \n // Fallback to common name paths if no specific path provided\n if (props.data) {\n const commonPaths = [\n 'name',\n 'display_name',\n 'full_name',\n 'username',\n 'title'\n ];\n \n for (const path of commonPaths) {\n const name = getNestedValue(props.data, path);\n if (name) return name;\n }\n }\n \n return '';\n});\n\nconst hasImage = computed(() => {\n return !!imageUrl.value;\n});\n\nconst initials = computed(() => {\n const name = displayName.value;\n \n if (!name || name.trim() === '') {\n return props.fallbackInitials;\n }\n\n const names = name.split(' ').filter(Boolean);\n if (names.length === 0) {\n return props.fallbackInitials;\n }\n\n if (names.length === 1) {\n return names[0][0].toUpperCase();\n } else {\n return (names[0][0] + names[names.length - 1][0]).toUpperCase();\n }\n});\n</script>\n\n<style scoped>\n</style>\n"],"names":["props","__props","imageError","ref","handleImageError","sizeClasses","sizeClass","computed","getNestedValue","obj","path","keys","current","key","imageUrl","url","commonPaths","displayName","name","hasImage","initials","names","_createElementBlock","ring","rounded","_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AAe,EAAA,SAAYjB,EAAA,cAAxBoB,EAGM,OAAA;AAAA;QAH8B,OAAKM,EAAA,CAAC,gGAA8F,CAC7HC,EAAAA,OAAOL,EAAAA,OAAO,CAAA,CAAA;AAAA,MAAA,KACpBJ,EAAA,KAAQ,GAAA,CAAA;;;;"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { createElementBlock as o, openBlock as a, createElementVNode as c, defineComponent as v, ref as m, computed as x, watchEffect as w, Fragment as B, renderList as P, createBlock as k, createCommentVNode as C, createVNode as y, unref as N, withCtx as E, createTextVNode as V, toDisplayString as L } from "vue";
|
|
2
|
+
import { u as S, a as D, _ as R } from "./UiNavLink.vue_vue_type_script_setup_true_lang-Bz5oiCCk.js";
|
|
3
|
+
function U(d, n) {
|
|
4
|
+
return a(), o("svg", {
|
|
5
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
6
|
+
viewBox: "0 0 20 20",
|
|
7
|
+
fill: "currentColor",
|
|
8
|
+
"aria-hidden": "true",
|
|
9
|
+
"data-slot": "icon"
|
|
10
|
+
}, [
|
|
11
|
+
c("path", {
|
|
12
|
+
"fill-rule": "evenodd",
|
|
13
|
+
d: "M8.22 5.22a.75.75 0 0 1 1.06 0l4.25 4.25a.75.75 0 0 1 0 1.06l-4.25 4.25a.75.75 0 0 1-1.06-1.06L11.94 10 8.22 6.28a.75.75 0 0 1 0-1.06Z",
|
|
14
|
+
"clip-rule": "evenodd"
|
|
15
|
+
})
|
|
16
|
+
]);
|
|
17
|
+
}
|
|
18
|
+
const j = {
|
|
19
|
+
class: "sl-hidden sm:sl-flex",
|
|
20
|
+
"aria-label": "Breadcrumb"
|
|
21
|
+
}, A = {
|
|
22
|
+
role: "list",
|
|
23
|
+
class: "sl-flex sl-items-center sl-space-x-4"
|
|
24
|
+
}, F = { class: "sl-flex sl-items-center" }, Z = /* @__PURE__ */ v({
|
|
25
|
+
__name: "UiBreadcrumb",
|
|
26
|
+
setup(d) {
|
|
27
|
+
const n = m([]), h = S(), f = D(), i = m(""), p = x(() => n.value.map((s) => {
|
|
28
|
+
const t = s.name.trim();
|
|
29
|
+
return {
|
|
30
|
+
...s,
|
|
31
|
+
name: t.length > 12 ? t.slice(0, 12) + "..." : t
|
|
32
|
+
};
|
|
33
|
+
})), _ = async () => {
|
|
34
|
+
const s = h.path;
|
|
35
|
+
i.value = s;
|
|
36
|
+
const t = s.split("/").filter(Boolean), e = [];
|
|
37
|
+
for (const [l, r] of t.entries()) {
|
|
38
|
+
let u;
|
|
39
|
+
u = r.charAt(0).toUpperCase() + r.slice(1).toLowerCase(), e.push({
|
|
40
|
+
name: u,
|
|
41
|
+
fullPath: "/" + t.slice(0, l + 1).join("/")
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
n.value = e;
|
|
45
|
+
}, g = (s, t) => {
|
|
46
|
+
const e = f.resolve(s.fullPath), l = e.matched.some((r) => r.meta?.isErrorPage);
|
|
47
|
+
(!e || e.matched.length === 0 || l) && (t.preventDefault(), t.stopPropagation(), console.warn("Breadcrumb route not found or is an error page:", s.fullPath));
|
|
48
|
+
};
|
|
49
|
+
return w(() => {
|
|
50
|
+
_();
|
|
51
|
+
}), (s, t) => (a(), o("nav", j, [
|
|
52
|
+
c("ol", A, [
|
|
53
|
+
(a(!0), o(B, null, P(p.value, (e, l) => (a(), o("li", {
|
|
54
|
+
key: e.fullPath
|
|
55
|
+
}, [
|
|
56
|
+
c("div", F, [
|
|
57
|
+
l !== 0 ? (a(), k(N(U), {
|
|
58
|
+
key: 0,
|
|
59
|
+
class: "sl-h-5 sl-w-5 sl-flex-shrink-0 sl-text-gray-400 sl-mr-3",
|
|
60
|
+
"aria-hidden": "true"
|
|
61
|
+
})) : C("", !0),
|
|
62
|
+
y(R, {
|
|
63
|
+
to: e.fullPath,
|
|
64
|
+
onClick: (r) => g(e, r),
|
|
65
|
+
"aria-current": e.fullPath === i.value ? "page" : void 0,
|
|
66
|
+
class: "sl-text-sm sl-font-medium sl-text-gray-500 hover:sl-text-gray-700 sl-truncate sl-overflow-ellipsis"
|
|
67
|
+
}, {
|
|
68
|
+
default: E(() => [
|
|
69
|
+
V(L(e.name), 1)
|
|
70
|
+
]),
|
|
71
|
+
_: 2
|
|
72
|
+
}, 1032, ["to", "onClick", "aria-current"])
|
|
73
|
+
])
|
|
74
|
+
]))), 128))
|
|
75
|
+
])
|
|
76
|
+
]));
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
export {
|
|
80
|
+
Z as _
|
|
81
|
+
};
|
|
82
|
+
//# sourceMappingURL=UiBreadcrumb.vue_vue_type_script_setup_true_lang-quGuN9v4.js.map
|