@ac-design/design-system 2.2.1 → 2.4.0
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/lib/compat.css +421 -0
- package/dist/lib/components/AcAppSwitcher.vue.d.ts +1 -1
- package/dist/lib/components/AcAppSwitcher.vue_vue_type_script_setup_true_lang.js +23 -23
- package/dist/lib/components/AcAreaChart.vue.d.ts +1 -1
- package/dist/lib/components/AcBarChart.vue.d.ts +1 -1
- package/dist/lib/components/AcButton.vue.d.ts +25 -13
- package/dist/lib/components/AcButton.vue_vue_type_script_setup_true_lang.js +122 -71
- package/dist/lib/components/AcCard.vue.d.ts +11 -5
- package/dist/lib/components/AcCard.vue_vue_type_script_setup_true_lang.js +99 -51
- package/dist/lib/components/AcCellValue.vue.d.ts +3 -3
- package/dist/lib/components/AcCellValue.vue_vue_type_script_setup_true_lang.js +20 -20
- package/dist/lib/components/AcCheckBox.vue.d.ts +4 -1
- package/dist/lib/components/AcCheckBox.vue_vue_type_script_setup_true_lang.js +50 -50
- package/dist/lib/components/AcCircularProgress.vue.d.ts +1 -1
- package/dist/lib/components/AcCodeEditor.vue.d.ts +12 -0
- package/dist/lib/components/AcCodeEditor.vue_vue_type_script_setup_true_lang.js +240 -207
- package/dist/lib/components/AcColorInput.vue.d.ts +4 -4
- package/dist/lib/components/AcColorInput.vue_vue_type_script_setup_true_lang.js +72 -66
- package/dist/lib/components/AcCostSummary.vue.d.ts +1 -1
- package/dist/lib/components/AcDatePicker.vue.d.ts +41 -10
- package/dist/lib/components/AcDatePicker.vue_vue_type_script_setup_true_lang.js +554 -446
- package/dist/lib/components/AcDeleteModal.vue.d.ts +1 -1
- package/dist/lib/components/AcDonutChart.vue.d.ts +2 -2
- package/dist/lib/components/AcDropdown.vue.d.ts +1 -1
- package/dist/lib/components/AcDropdown.vue_vue_type_script_setup_true_lang.js +8 -8
- package/dist/lib/components/AcErrorState.vue.d.ts +1 -1
- package/dist/lib/components/AcFormFooter.vue_vue_type_script_setup_true_lang.js +8 -8
- package/dist/lib/components/AcGraphChart.vue.d.ts +2 -2
- package/dist/lib/components/AcHeader.vue.d.ts +1 -1
- package/dist/lib/components/AcInput.vue.d.ts +86 -44
- package/dist/lib/components/AcInput.vue_vue_type_script_setup_true_lang.js +319 -86
- package/dist/lib/components/AcKeyValueInput.vue.d.ts +34 -54
- package/dist/lib/components/AcKeyValueInput.vue_vue_type_script_setup_true_lang.js +134 -106
- package/dist/lib/components/AcLineChart.vue.d.ts +1 -1
- package/dist/lib/components/AcLocaleSwitcher.vue.d.ts +6 -0
- package/dist/lib/components/AcLocaleSwitcher.vue_vue_type_script_setup_true_lang.js +74 -58
- package/dist/lib/components/AcMapChart.vue.d.ts +2 -2
- package/dist/lib/components/AcModal.vue.d.ts +1 -1
- package/dist/lib/components/AcNavbar.vue.d.ts +2 -0
- package/dist/lib/components/AcNavbar.vue_vue_type_script_setup_true_lang.js +31 -25
- package/dist/lib/components/AcNotificationMenu.vue.d.ts +1 -1
- package/dist/lib/components/AcNotificationMenu.vue_vue_type_script_setup_true_lang.js +24 -24
- package/dist/lib/components/AcNumberInput.vue.d.ts +55 -45
- package/dist/lib/components/AcNumberInput.vue_vue_type_script_setup_true_lang.js +159 -99
- package/dist/lib/components/AcRadioCard.js +5 -0
- package/dist/lib/components/AcRadioCard.vue.d.ts +55 -0
- package/dist/lib/components/AcRadioCard.vue_vue_type_script_setup_true_lang.js +135 -0
- package/dist/lib/components/AcSelect.vue.d.ts +46 -6
- package/dist/lib/components/AcSelect.vue_vue_type_script_setup_true_lang.js +309 -197
- package/dist/lib/components/AcSidePanel.vue.d.ts +1 -1
- package/dist/lib/components/AcSidebar.vue.d.ts +9 -0
- package/dist/lib/components/AcSidebar.vue_vue_type_script_setup_true_lang.js +113 -94
- package/dist/lib/components/AcSidebarSection.vue_vue_type_script_setup_true_lang.js +19 -18
- package/dist/lib/components/AcSlider.vue.d.ts +2 -2
- package/dist/lib/components/AcSwitch.vue_vue_type_script_setup_true_lang.js +23 -23
- package/dist/lib/components/AcTable.vue.d.ts +50 -5
- package/dist/lib/components/AcTable.vue_vue_type_script_setup_true_lang.js +257 -129
- package/dist/lib/components/AcTagInput.vue.d.ts +23 -4
- package/dist/lib/components/AcTagInput.vue_vue_type_script_setup_true_lang.js +126 -114
- package/dist/lib/components/AcTaintInput.js +5 -0
- package/dist/lib/components/AcTaintInput.vue.d.ts +44 -0
- package/dist/lib/components/AcTaintInput.vue_vue_type_script_setup_true_lang.js +208 -0
- package/dist/lib/components/AcTextarea.vue.d.ts +64 -4
- package/dist/lib/components/AcTextarea.vue_vue_type_script_setup_true_lang.js +159 -68
- package/dist/lib/components/AcThemeMode.vue.d.ts +10 -2
- package/dist/lib/components/AcThemeMode.vue_vue_type_script_setup_true_lang.js +53 -42
- package/dist/lib/components/AcTimePicker.vue.d.ts +36 -11
- package/dist/lib/components/AcTimePicker.vue_vue_type_script_setup_true_lang.js +232 -168
- package/dist/lib/components/AcTooltip.vue.d.ts +3 -3
- package/dist/lib/components/AcUserMenu.vue.d.ts +8 -0
- package/dist/lib/components/AcUserMenu.vue_vue_type_script_setup_true_lang.js +126 -109
- package/dist/lib/components/index.d.ts +2 -0
- package/dist/lib/components/types.d.ts +2 -0
- package/dist/lib/composables/useToast.d.ts +2 -2
- package/dist/lib/index.d.ts +2 -1
- package/dist/lib/index.js +51 -49
- package/package.json +1 -1
|
@@ -1,39 +1,39 @@
|
|
|
1
1
|
import e from "./AcButton.js";
|
|
2
2
|
import t from "./AcInput.js";
|
|
3
3
|
import n from "./AcSelect.js";
|
|
4
|
-
import { Fragment as r, TransitionGroup as i, computed as a, createBlock as o, createCommentVNode as s, createElementBlock as c, createElementVNode as l, createVNode as u, defineComponent as d, mergeModels as f, nextTick as p, normalizeClass as m, openBlock as h, ref as g, renderList as ee, renderSlot as
|
|
5
|
-
import { Plus as
|
|
4
|
+
import { Fragment as r, TransitionGroup as i, computed as a, createBlock as o, createCommentVNode as s, createElementBlock as c, createElementVNode as l, createVNode as u, defineComponent as d, mergeModels as f, nextTick as p, normalizeClass as m, openBlock as h, ref as g, renderList as ee, renderSlot as te, toDisplayString as _, unref as v, useId as ne, useModel as re, watch as y, withCtx as b, withKeys as x } from "vue";
|
|
5
|
+
import { Plus as ie, Trash as ae } from "@lucide/vue";
|
|
6
6
|
//#region src/lib/components/AcKeyValueInput.vue?vue&type=script&setup=true&lang.ts
|
|
7
|
-
var
|
|
7
|
+
var oe = [
|
|
8
8
|
"aria-labelledby",
|
|
9
9
|
"aria-label",
|
|
10
10
|
"aria-describedby"
|
|
11
|
-
],
|
|
11
|
+
], se = {
|
|
12
12
|
key: 0,
|
|
13
13
|
class: "font-normal text-muted"
|
|
14
|
-
},
|
|
14
|
+
}, ce = {
|
|
15
15
|
key: 1,
|
|
16
16
|
class: "text-danger",
|
|
17
17
|
"aria-hidden": "true"
|
|
18
|
-
},
|
|
18
|
+
}, le = {
|
|
19
19
|
key: 2,
|
|
20
20
|
class: "mb-1.5 hidden grid-cols-[minmax(0,1fr)_auto] gap-x-4 sm:grid",
|
|
21
21
|
"aria-hidden": "true"
|
|
22
|
-
},
|
|
22
|
+
}, ue = { key: 0 }, de = [
|
|
23
23
|
"data-row",
|
|
24
24
|
"onFocusin",
|
|
25
25
|
"onFocusout"
|
|
26
|
-
],
|
|
26
|
+
], fe = [
|
|
27
27
|
"aria-label",
|
|
28
28
|
"title",
|
|
29
29
|
"onClick"
|
|
30
|
-
],
|
|
30
|
+
], pe = {
|
|
31
31
|
key: 4,
|
|
32
32
|
class: "text-base text-muted"
|
|
33
|
-
},
|
|
33
|
+
}, me = {
|
|
34
34
|
class: "sr-only",
|
|
35
35
|
"aria-live": "polite"
|
|
36
|
-
},
|
|
36
|
+
}, S = /*@__PURE__*/ d({
|
|
37
37
|
__name: "AcKeyValueInput",
|
|
38
38
|
props: /*@__PURE__*/ f({
|
|
39
39
|
label: { default: "" },
|
|
@@ -77,117 +77,142 @@ var T = [
|
|
|
77
77
|
readonly: {
|
|
78
78
|
type: Boolean,
|
|
79
79
|
default: !1
|
|
80
|
+
},
|
|
81
|
+
plain: {
|
|
82
|
+
type: Boolean,
|
|
83
|
+
default: !1
|
|
80
84
|
}
|
|
81
85
|
}, {
|
|
82
86
|
modelValue: { default: () => [] },
|
|
83
87
|
modelModifiers: {}
|
|
84
88
|
}),
|
|
85
89
|
emits: /*@__PURE__*/ f(["add", "remove"], ["update:modelValue"]),
|
|
86
|
-
setup(d, { expose: f, emit:
|
|
87
|
-
let
|
|
90
|
+
setup(d, { expose: f, emit: S }) {
|
|
91
|
+
let C = d, w = re(d, "modelValue"), T = S, E = ne(), D = `${E}-label`, O = `${E}-hint`, k = `${E}-msg`, A = g(null), j = 0, M = g([]), N = g(null), P = g(""), F = g([]), I = {}, L = a(() => !!w.value && !Array.isArray(w.value)), R = a(() => L.value ? F.value : w.value ?? []), z = a(() => !!C.options?.length), B = a(() => !C.disabled && !C.readonly), V = a(() => C.max !== void 0 && R.value.length >= C.max), he = a(() => C.addLabel || "Add new"), ge = a(() => [C.hint && O, C.errorMsg && k].filter(Boolean).join(" ") || void 0), H = a(() => C.plain ? z.value ? "grid-cols-[minmax(0,1fr)_minmax(0,1fr)_256px]" : "grid-cols-2" : z.value ? "sm:grid-cols-[minmax(0,1fr)_minmax(0,1fr)_256px]" : "sm:grid-cols-2"), U = a(() => C.plain ? "[&>label:first-child]:sr-only" : "sm:[&>label:first-child]:sr-only"), _e = a(() => C.size === "small" ? "size-[34px]" : "size-[38px]"), W = a(() => {
|
|
88
92
|
let e = /* @__PURE__ */ new Set();
|
|
89
|
-
return
|
|
93
|
+
return R.value.map((t, n) => {
|
|
90
94
|
let r = {}, i = t.key.trim();
|
|
91
95
|
if (i) {
|
|
92
|
-
let a =
|
|
93
|
-
!
|
|
94
|
-
} else t.value &&
|
|
95
|
-
return (i || t.value) && (r.value =
|
|
96
|
+
let a = z.value ? `${i}\u0000${t.option ?? ""}` : i;
|
|
97
|
+
!C.allowDuplicateKeys && e.has(a) && (r.key = z.value && t.option ? `“${i}” with ${G(t.option)} is already used.` : `“${i}” is already used. Keys must be unique.`), e.add(a), r.key ||= C.validateKey?.(t.key, n, R.value) || void 0;
|
|
98
|
+
} else t.value && N.value !== M.value[n] && (r.key = `Enter a key, or remove this ${C.itemName}.`);
|
|
99
|
+
return (i || t.value) && (r.value = C.validateValue?.(t.value, t.key, n, R.value) || void 0), r;
|
|
96
100
|
});
|
|
97
|
-
}),
|
|
98
|
-
function
|
|
99
|
-
return
|
|
101
|
+
}), ve = a(() => W.value.some((e) => e.key || e.value));
|
|
102
|
+
function G(e) {
|
|
103
|
+
return C.options?.find((t) => t.value === e)?.label ?? e;
|
|
100
104
|
}
|
|
101
|
-
function
|
|
102
|
-
let t =
|
|
103
|
-
return t ? `${
|
|
105
|
+
function K(e) {
|
|
106
|
+
let t = R.value[e]?.key.trim();
|
|
107
|
+
return t ? `${C.itemName} ${t}` : `${C.itemName} ${e + 1}`;
|
|
104
108
|
}
|
|
105
|
-
function
|
|
109
|
+
function q(e) {
|
|
106
110
|
return e.charAt(0).toUpperCase() + e.slice(1);
|
|
107
111
|
}
|
|
108
|
-
function
|
|
109
|
-
|
|
112
|
+
function J(e) {
|
|
113
|
+
P.value = "", p(() => P.value = e);
|
|
110
114
|
}
|
|
111
|
-
function
|
|
115
|
+
function Y(e, t) {
|
|
112
116
|
p(() => {
|
|
113
|
-
([...
|
|
117
|
+
([...A.value?.querySelectorAll(`[data-row="${e}"]`) ?? []].at(-1)?.querySelector(t === "remove" ? "[data-action='remove']" : `[data-cell="${t}"]`) ?? A.value?.querySelector("[data-action='add']"))?.focus();
|
|
114
118
|
});
|
|
115
119
|
}
|
|
120
|
+
function X(e) {
|
|
121
|
+
let t = {};
|
|
122
|
+
for (let n of e) n.key && (t[n.key] = n.value);
|
|
123
|
+
return t;
|
|
124
|
+
}
|
|
125
|
+
function ye(e, t) {
|
|
126
|
+
let n = Object.keys(e);
|
|
127
|
+
return n.length === Object.keys(t).length && n.every((n) => n in t && e[n] === t[n]);
|
|
128
|
+
}
|
|
129
|
+
function Z(e) {
|
|
130
|
+
if (!L.value) {
|
|
131
|
+
w.value = e;
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
F.value = e, I = X(e), w.value = I;
|
|
135
|
+
}
|
|
116
136
|
function Q(e, t) {
|
|
117
|
-
|
|
137
|
+
Z(R.value.map((n, r) => r === e ? {
|
|
118
138
|
...n,
|
|
119
139
|
...t
|
|
120
|
-
} : n);
|
|
140
|
+
} : n));
|
|
121
141
|
}
|
|
122
142
|
function $() {
|
|
123
|
-
if (!
|
|
143
|
+
if (!B.value || V.value) return;
|
|
124
144
|
let e = {
|
|
125
145
|
key: "",
|
|
126
146
|
value: ""
|
|
127
147
|
};
|
|
128
|
-
|
|
129
|
-
let t =
|
|
130
|
-
|
|
148
|
+
z.value && (e.option = C.defaultOption ?? C.options[0].value), M.value = [...M.value, j++], Z([...R.value, e]);
|
|
149
|
+
let t = R.value.length;
|
|
150
|
+
T("add", t), J(`${q(C.itemName)} ${t + 1} added.`), Y(t, "key");
|
|
131
151
|
}
|
|
132
|
-
function
|
|
133
|
-
if (!
|
|
134
|
-
let t =
|
|
152
|
+
function be(e) {
|
|
153
|
+
if (!B.value) return;
|
|
154
|
+
let t = R.value[e];
|
|
135
155
|
if (!t) return;
|
|
136
|
-
let n =
|
|
137
|
-
|
|
138
|
-
let r =
|
|
139
|
-
r ?
|
|
156
|
+
let n = K(e);
|
|
157
|
+
M.value = M.value.filter((t, n) => n !== e), Z(R.value.filter((t, n) => n !== e)), T("remove", t, e), J(`${q(n)} removed.`);
|
|
158
|
+
let r = R.value.length;
|
|
159
|
+
r ? Y(Math.min(e, r - 1), "remove") : p(() => A.value?.querySelector("[data-action='add']")?.focus());
|
|
140
160
|
}
|
|
141
|
-
function
|
|
142
|
-
e.isComposing || (e.preventDefault(),
|
|
161
|
+
function xe(e, t) {
|
|
162
|
+
e.isComposing || (e.preventDefault(), Y(t, "value"));
|
|
143
163
|
}
|
|
144
|
-
function
|
|
145
|
-
e.isComposing || (e.preventDefault(), t <
|
|
164
|
+
function Se(e, t) {
|
|
165
|
+
e.isComposing || (e.preventDefault(), t < R.value.length - 1 ? Y(t + 1, "key") : V.value || $());
|
|
146
166
|
}
|
|
147
|
-
function
|
|
167
|
+
function Ce(e, t) {
|
|
148
168
|
let n = e.currentTarget, r = e.relatedTarget;
|
|
149
|
-
r && (n.contains(r) || r instanceof Element && r.closest("[data-testid='ac-select-panel']")) ||
|
|
169
|
+
r && (n.contains(r) || r instanceof Element && r.closest("[data-testid='ac-select-panel']")) || N.value === t && (N.value = null);
|
|
150
170
|
}
|
|
151
|
-
return
|
|
152
|
-
|
|
171
|
+
return y(w, (e) => {
|
|
172
|
+
!e || Array.isArray(e) || ye(e, I) || (F.value = Object.entries(e).map(([e, t]) => ({
|
|
173
|
+
key: e,
|
|
174
|
+
value: String(t)
|
|
175
|
+
})), I = X(F.value));
|
|
176
|
+
}, { immediate: !0 }), y(() => R.value.length, (e) => {
|
|
177
|
+
M.value.length !== e && (M.value = Array.from({ length: e }, () => j++));
|
|
153
178
|
}, { immediate: !0 }), f({
|
|
154
179
|
add: $,
|
|
155
|
-
focus: () =>
|
|
156
|
-
hasErrors: () =>
|
|
180
|
+
focus: () => Y(0, "key"),
|
|
181
|
+
hasErrors: () => ve.value
|
|
157
182
|
}), (a, f) => (h(), c("div", {
|
|
158
183
|
ref_key: "root",
|
|
159
|
-
ref:
|
|
184
|
+
ref: A,
|
|
160
185
|
role: "group",
|
|
161
|
-
"aria-labelledby": d.label ?
|
|
162
|
-
"aria-label": d.label ? void 0 : `${
|
|
163
|
-
"aria-describedby":
|
|
186
|
+
"aria-labelledby": d.label ? D : void 0,
|
|
187
|
+
"aria-label": d.label ? void 0 : `${q(d.itemName)}s`,
|
|
188
|
+
"aria-describedby": ge.value,
|
|
164
189
|
class: m(d.disabled && "opacity-50"),
|
|
165
190
|
"data-ac-ds": "",
|
|
166
191
|
"data-testid": "ac-key-value-input"
|
|
167
192
|
}, [
|
|
168
193
|
d.label ? (h(), c("div", {
|
|
169
194
|
key: 0,
|
|
170
|
-
id:
|
|
195
|
+
id: D,
|
|
171
196
|
class: "mb-2 flex items-center gap-1 text-base font-medium text-heading"
|
|
172
197
|
}, [
|
|
173
|
-
l("span", null,
|
|
174
|
-
d.readonly ? (h(), c("span",
|
|
175
|
-
d.required ? (h(), c("span",
|
|
198
|
+
l("span", null, _(d.label), 1),
|
|
199
|
+
d.readonly ? (h(), c("span", se, "(read only)")) : s("", !0),
|
|
200
|
+
d.required ? (h(), c("span", ce, "*")) : s("", !0)
|
|
176
201
|
])) : s("", !0),
|
|
177
202
|
d.hint ? (h(), c("p", {
|
|
178
203
|
key: 1,
|
|
179
|
-
id:
|
|
204
|
+
id: O,
|
|
180
205
|
class: "mb-2 text-base text-muted"
|
|
181
|
-
},
|
|
182
|
-
|
|
183
|
-
l("span", null,
|
|
184
|
-
l("span", null,
|
|
185
|
-
|
|
186
|
-
], 2),
|
|
206
|
+
}, _(d.hint), 1)) : s("", !0),
|
|
207
|
+
R.value.length && !d.plain ? (h(), c("div", le, [l("div", { class: m(["grid gap-x-4 text-base font-medium text-muted", H.value]) }, [
|
|
208
|
+
l("span", null, _(d.keyLabel), 1),
|
|
209
|
+
l("span", null, _(d.valueLabel), 1),
|
|
210
|
+
z.value ? (h(), c("span", ue, _(d.optionLabel), 1)) : s("", !0)
|
|
211
|
+
], 2), B.value ? (h(), c("span", {
|
|
187
212
|
key: 0,
|
|
188
213
|
class: m(d.size === "small" ? "w-[34px]" : "w-[38px]")
|
|
189
214
|
}, null, 2)) : s("", !0)])) : s("", !0),
|
|
190
|
-
|
|
215
|
+
R.value.length || B.value ? (h(), o(i, {
|
|
191
216
|
key: 3,
|
|
192
217
|
tag: "div",
|
|
193
218
|
class: "relative space-y-4",
|
|
@@ -197,13 +222,13 @@ var T = [
|
|
|
197
222
|
"leave-to-class": "translate-x-5 opacity-0",
|
|
198
223
|
"move-class": "transition-transform duration-300 ease-out motion-reduce:transition-none"
|
|
199
224
|
}, {
|
|
200
|
-
default:
|
|
201
|
-
key:
|
|
225
|
+
default: b(() => [(h(!0), c(r, null, ee(R.value, (e, r) => (h(), c("div", {
|
|
226
|
+
key: M.value[r] ?? r,
|
|
202
227
|
"data-row": r,
|
|
203
|
-
class: "grid grid-cols-[minmax(0,1fr)_auto] items-start gap-x-4 max-sm:rounded-10 max-sm:border max-sm:border-border max-sm:bg-surface max-sm:p-3",
|
|
204
|
-
onFocusin: (e) =>
|
|
205
|
-
onFocusout: (e) =>
|
|
206
|
-
}, [l("div", { class: m(["grid items-start gap-x-4 gap-y-3 [&_div:has(>input)]:rounded-8 [&_input]:rounded-8 [&_input]:font-medium",
|
|
228
|
+
class: m(["grid grid-cols-[minmax(0,1fr)_auto] items-start gap-x-4", !d.plain && "max-sm:rounded-10 max-sm:border max-sm:border-border max-sm:bg-surface max-sm:p-3"]),
|
|
229
|
+
onFocusin: (e) => N.value = M.value[r] ?? null,
|
|
230
|
+
onFocusout: (e) => Ce(e, M.value[r] ?? -1)
|
|
231
|
+
}, [l("div", { class: m(["grid items-start gap-x-4 gap-y-3 [&_div:has(>input)]:rounded-8 [&_input]:rounded-8 [&_input]:font-medium", [H.value, d.plain && "[&_input]:pr-3 [&_input]:pl-3"]]) }, [
|
|
207
232
|
u(t, {
|
|
208
233
|
"data-cell": "key",
|
|
209
234
|
"model-value": e.key,
|
|
@@ -212,12 +237,12 @@ var T = [
|
|
|
212
237
|
size: d.size,
|
|
213
238
|
disabled: d.disabled,
|
|
214
239
|
readonly: d.readonly,
|
|
215
|
-
"error-msg":
|
|
240
|
+
"error-msg": W.value[r]?.key,
|
|
216
241
|
autocomplete: "off",
|
|
217
242
|
spellcheck: "false",
|
|
218
|
-
class: m([
|
|
243
|
+
class: m([U.value, d.mono && "[&_input]:font-mono"]),
|
|
219
244
|
"onUpdate:modelValue": (e) => Q(r, { key: String(e) }),
|
|
220
|
-
onKeydown:
|
|
245
|
+
onKeydown: x((e) => xe(e, r), ["enter"])
|
|
221
246
|
}, null, 8, [
|
|
222
247
|
"model-value",
|
|
223
248
|
"label",
|
|
@@ -238,12 +263,12 @@ var T = [
|
|
|
238
263
|
size: d.size,
|
|
239
264
|
disabled: d.disabled,
|
|
240
265
|
readonly: d.readonly,
|
|
241
|
-
"error-msg":
|
|
266
|
+
"error-msg": W.value[r]?.value,
|
|
242
267
|
autocomplete: "off",
|
|
243
268
|
spellcheck: "false",
|
|
244
|
-
class:
|
|
269
|
+
class: m(U.value),
|
|
245
270
|
"onUpdate:modelValue": (e) => Q(r, { value: String(e) }),
|
|
246
|
-
onKeydown:
|
|
271
|
+
onKeydown: x((e) => Se(e, r), ["enter"])
|
|
247
272
|
}, null, 8, [
|
|
248
273
|
"model-value",
|
|
249
274
|
"label",
|
|
@@ -252,22 +277,24 @@ var T = [
|
|
|
252
277
|
"disabled",
|
|
253
278
|
"readonly",
|
|
254
279
|
"error-msg",
|
|
280
|
+
"class",
|
|
255
281
|
"onUpdate:modelValue",
|
|
256
282
|
"onKeydown"
|
|
257
283
|
]),
|
|
258
|
-
|
|
284
|
+
z.value && d.readonly ? (h(), o(t, {
|
|
259
285
|
key: 0,
|
|
260
286
|
"data-cell": "option",
|
|
261
|
-
"model-value": e.option ?
|
|
287
|
+
"model-value": e.option ? G(e.option) : "",
|
|
262
288
|
label: `${d.optionLabel} ${r + 1}`,
|
|
263
289
|
size: d.size,
|
|
264
290
|
readonly: "",
|
|
265
|
-
class:
|
|
291
|
+
class: m(U.value)
|
|
266
292
|
}, null, 8, [
|
|
267
293
|
"model-value",
|
|
268
294
|
"label",
|
|
269
|
-
"size"
|
|
270
|
-
|
|
295
|
+
"size",
|
|
296
|
+
"class"
|
|
297
|
+
])) : z.value ? (h(), o(n, {
|
|
271
298
|
key: 1,
|
|
272
299
|
"data-cell": "option",
|
|
273
300
|
"model-value": e.option ?? null,
|
|
@@ -275,7 +302,7 @@ var T = [
|
|
|
275
302
|
label: `${d.optionLabel} ${r + 1}`,
|
|
276
303
|
size: d.size,
|
|
277
304
|
disabled: d.disabled,
|
|
278
|
-
class: "sm:[&>div:first-child]:sr-only",
|
|
305
|
+
class: m(d.plain ? "[&>div:first-child]:sr-only" : "sm:[&>div:first-child]:sr-only"),
|
|
279
306
|
"onUpdate:modelValue": (e) => Q(r, { option: e ?? void 0 })
|
|
280
307
|
}, null, 8, [
|
|
281
308
|
"model-value",
|
|
@@ -283,36 +310,37 @@ var T = [
|
|
|
283
310
|
"label",
|
|
284
311
|
"size",
|
|
285
312
|
"disabled",
|
|
313
|
+
"class",
|
|
286
314
|
"onUpdate:modelValue"
|
|
287
315
|
])) : s("", !0)
|
|
288
|
-
], 2),
|
|
316
|
+
], 2), B.value ? (h(), c("button", {
|
|
289
317
|
key: 0,
|
|
290
318
|
type: "button",
|
|
291
319
|
"data-action": "remove",
|
|
292
|
-
class: m(["inline-flex shrink-0 cursor-pointer items-center justify-center rounded-8 bg-danger/5 text-danger/60 transition-all duration-200 hover:bg-danger/10 hover:text-danger focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none max-sm:mt-7"
|
|
293
|
-
"aria-label": `Remove ${
|
|
320
|
+
class: m(["inline-flex shrink-0 cursor-pointer items-center justify-center rounded-8 bg-danger/5 text-danger/60 transition-all duration-200 hover:bg-danger/10 hover:text-danger focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none", [_e.value, !d.plain && "max-sm:mt-7"]]),
|
|
321
|
+
"aria-label": `Remove ${K(r)}`,
|
|
294
322
|
title: `Remove ${d.itemName}`,
|
|
295
|
-
onClick: (e) =>
|
|
296
|
-
}, [u(
|
|
323
|
+
onClick: (e) => be(r)
|
|
324
|
+
}, [u(v(ae), {
|
|
297
325
|
class: "size-[18px]",
|
|
298
326
|
"aria-hidden": "true"
|
|
299
|
-
})], 10,
|
|
327
|
+
})], 10, fe)) : s("", !0)], 42, de))), 128))]),
|
|
300
328
|
_: 1
|
|
301
|
-
})) : (h(), c("p",
|
|
302
|
-
|
|
303
|
-
|
|
329
|
+
})) : (h(), c("p", pe, "No " + _(d.itemName) + "s.", 1)),
|
|
330
|
+
te(a.$slots, "footer"),
|
|
331
|
+
B.value ? (h(), c("div", {
|
|
304
332
|
key: 5,
|
|
305
|
-
class: m(["flex items-center gap-3",
|
|
333
|
+
class: m(["flex items-center gap-3", R.value.length || a.$slots.footer ? "mt-2" : ""])
|
|
306
334
|
}, [u(e, {
|
|
307
335
|
"data-action": "add",
|
|
308
|
-
title:
|
|
336
|
+
title: he.value,
|
|
309
337
|
"aria-label": d.addLabel ? void 0 : `Add new ${d.itemName}`,
|
|
310
338
|
size: "small",
|
|
311
339
|
variant: "light",
|
|
312
|
-
disabled:
|
|
340
|
+
disabled: V.value,
|
|
313
341
|
onClick: $
|
|
314
342
|
}, {
|
|
315
|
-
icon:
|
|
343
|
+
icon: b(() => [u(v(ie), { "aria-hidden": "true" })]),
|
|
316
344
|
_: 1
|
|
317
345
|
}, 8, [
|
|
318
346
|
"title",
|
|
@@ -320,17 +348,17 @@ var T = [
|
|
|
320
348
|
"disabled"
|
|
321
349
|
]), d.max === void 0 ? s("", !0) : (h(), c("span", {
|
|
322
350
|
key: 0,
|
|
323
|
-
class: m(["text-xs text-muted tabular-nums",
|
|
324
|
-
},
|
|
351
|
+
class: m(["text-xs text-muted tabular-nums", V.value && "font-medium text-heading"])
|
|
352
|
+
}, _(R.value.length) + " of " + _(d.max), 3))], 2)) : s("", !0),
|
|
325
353
|
d.errorMsg ? (h(), c("p", {
|
|
326
354
|
key: 6,
|
|
327
|
-
id:
|
|
355
|
+
id: k,
|
|
328
356
|
class: "mt-1 text-base text-danger-strong",
|
|
329
357
|
role: "alert"
|
|
330
|
-
},
|
|
331
|
-
l("p",
|
|
332
|
-
], 10,
|
|
358
|
+
}, _(d.errorMsg), 1)) : s("", !0),
|
|
359
|
+
l("p", me, _(P.value), 1)
|
|
360
|
+
], 10, oe));
|
|
333
361
|
}
|
|
334
362
|
});
|
|
335
363
|
//#endregion
|
|
336
|
-
export {
|
|
364
|
+
export { S as default };
|
|
@@ -19,9 +19,9 @@ declare const __VLS_base: import("vue").DefineComponent<Props, {}, {}, {}, {}, i
|
|
|
19
19
|
description: string;
|
|
20
20
|
height: number;
|
|
21
21
|
points: boolean | "auto";
|
|
22
|
-
loading: boolean;
|
|
23
22
|
animation: boolean;
|
|
24
23
|
tooltip: boolean;
|
|
24
|
+
loading: boolean;
|
|
25
25
|
emptyText: string;
|
|
26
26
|
lineWidth: number;
|
|
27
27
|
renderer: "canvas" | "svg";
|
|
@@ -23,6 +23,10 @@ export interface Props {
|
|
|
23
23
|
persist?: boolean;
|
|
24
24
|
/** localStorage key for `persist`. cloud-ui uses `user-locale`. */
|
|
25
25
|
storageKey?: string;
|
|
26
|
+
/** `compact` rows run edge to edge at 36px. `comfortable` is cloud-ui's navbar language menu: 48px rounded rows inset 8px from the edge, with 20px flags. */
|
|
27
|
+
density?: "compact" | "comfortable";
|
|
28
|
+
/** A hint shown under the `icon` trigger on hover and focus, e.g. "Change language". */
|
|
29
|
+
tooltip?: string;
|
|
26
30
|
}
|
|
27
31
|
type __VLS_Props = Props;
|
|
28
32
|
type __VLS_ModelProps = {
|
|
@@ -39,10 +43,12 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
|
|
|
39
43
|
}>, {
|
|
40
44
|
variant: "icon" | "button";
|
|
41
45
|
align: "start" | "end";
|
|
46
|
+
tooltip: string;
|
|
42
47
|
ariaLabel: string;
|
|
43
48
|
menuTitle: string;
|
|
44
49
|
persist: boolean;
|
|
45
50
|
storageKey: string;
|
|
51
|
+
density: "compact" | "comfortable";
|
|
46
52
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
47
53
|
declare const _default: typeof __VLS_export;
|
|
48
54
|
export default _default;
|
|
@@ -1,23 +1,16 @@
|
|
|
1
|
-
import e from "./
|
|
2
|
-
import t from "./
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
1
|
+
import e from "./AcTooltip.js";
|
|
2
|
+
import t from "./AcDropdown.js";
|
|
3
|
+
import n from "./AcDropdownItem.js";
|
|
4
|
+
import { Fragment as r, computed as i, createBlock as a, createCommentVNode as o, createElementBlock as s, createElementVNode as c, createVNode as l, defineComponent as u, mergeModels as d, normalizeClass as f, openBlock as p, ref as m, renderList as h, toDisplayString as g, unref as _, useModel as v, withCtx as y } from "vue";
|
|
5
|
+
import { ChevronDown as b, Languages as x } from "@lucide/vue";
|
|
5
6
|
//#region src/lib/components/AcLocaleSwitcher.vue?vue&type=script&setup=true&lang.ts
|
|
6
|
-
var
|
|
7
|
-
key: 0,
|
|
8
|
-
class: "mb-2 border-b border-border px-4 py-2 text-xs font-semibold text-muted",
|
|
9
|
-
"aria-hidden": "true"
|
|
10
|
-
}, w = { class: "flex items-center gap-2" }, T = {
|
|
11
|
-
key: 0,
|
|
12
|
-
class: "shrink-0 text-xl leading-none",
|
|
13
|
-
"aria-hidden": "true"
|
|
14
|
-
}, E = ["lang"], D = {
|
|
7
|
+
var S = ["aria-label"], C = ["aria-label"], w = { class: "font-mono text-xs tracking-wide uppercase" }, T = ["lang"], E = {
|
|
15
8
|
key: 1,
|
|
16
9
|
class: "size-2 shrink-0 rounded-full bg-primary",
|
|
17
10
|
"aria-hidden": "true"
|
|
18
|
-
},
|
|
11
|
+
}, D = /*@__PURE__*/ u({
|
|
19
12
|
__name: "AcLocaleSwitcher",
|
|
20
|
-
props: /*@__PURE__*/
|
|
13
|
+
props: /*@__PURE__*/ d({
|
|
21
14
|
locales: {},
|
|
22
15
|
variant: { default: "icon" },
|
|
23
16
|
ariaLabel: { default: "Change language" },
|
|
@@ -27,85 +20,108 @@ var b = ["aria-label"], x = ["aria-label"], S = { class: "font-mono text-xs trac
|
|
|
27
20
|
type: Boolean,
|
|
28
21
|
default: !1
|
|
29
22
|
},
|
|
30
|
-
storageKey: { default: "user-locale" }
|
|
23
|
+
storageKey: { default: "user-locale" },
|
|
24
|
+
density: { default: "compact" },
|
|
25
|
+
tooltip: { default: "" }
|
|
31
26
|
}, {
|
|
32
27
|
modelValue: { default: "" },
|
|
33
28
|
modelModifiers: {}
|
|
34
29
|
}),
|
|
35
|
-
emits: /*@__PURE__*/
|
|
36
|
-
setup(
|
|
37
|
-
let
|
|
38
|
-
function
|
|
30
|
+
emits: /*@__PURE__*/ d(["change"], ["update:modelValue"]),
|
|
31
|
+
setup(u, { emit: d }) {
|
|
32
|
+
let D = u, O = v(u, "modelValue"), k = d, A = m(!1), j = i(() => D.density === "comfortable"), M = i(() => D.locales.find((e) => e.value === O.value)), N = i(() => M.value ? `${D.ariaLabel} (${M.value.label})` : D.ariaLabel);
|
|
33
|
+
function P() {
|
|
39
34
|
try {
|
|
40
|
-
return localStorage.getItem(
|
|
35
|
+
return localStorage.getItem(D.storageKey);
|
|
41
36
|
} catch {
|
|
42
37
|
return null;
|
|
43
38
|
}
|
|
44
39
|
}
|
|
45
|
-
function
|
|
46
|
-
if (e !==
|
|
47
|
-
localStorage.setItem(
|
|
40
|
+
function F(e) {
|
|
41
|
+
if (e !== O.value && (O.value = e, k("change", e), D.persist)) try {
|
|
42
|
+
localStorage.setItem(D.storageKey, e);
|
|
48
43
|
} catch {}
|
|
49
44
|
}
|
|
50
|
-
if (
|
|
51
|
-
let e =
|
|
52
|
-
e && e !==
|
|
45
|
+
if (D.persist && typeof window < "u") {
|
|
46
|
+
let e = P();
|
|
47
|
+
e && e !== O.value && D.locales.some((t) => t.value === e) && F(e);
|
|
53
48
|
}
|
|
54
|
-
return (
|
|
49
|
+
return (i, d) => u.locales.length > 1 ? (p(), a(t, {
|
|
55
50
|
key: 0,
|
|
56
|
-
|
|
57
|
-
"
|
|
51
|
+
open: A.value,
|
|
52
|
+
"onUpdate:open": d[0] ||= (e) => A.value = e,
|
|
53
|
+
align: u.align,
|
|
54
|
+
"menu-label": u.ariaLabel,
|
|
58
55
|
"data-testid": "ac-locale-switcher"
|
|
59
56
|
}, {
|
|
60
|
-
trigger:
|
|
57
|
+
trigger: y(() => [u.variant === "icon" ? (p(), a(e, {
|
|
61
58
|
key: 0,
|
|
62
|
-
|
|
63
|
-
"
|
|
64
|
-
|
|
65
|
-
},
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
59
|
+
content: u.tooltip,
|
|
60
|
+
placement: "bottom",
|
|
61
|
+
disabled: !u.tooltip || A.value
|
|
62
|
+
}, {
|
|
63
|
+
default: y(() => [c("button", {
|
|
64
|
+
type: "button",
|
|
65
|
+
"aria-label": N.value,
|
|
66
|
+
class: f(["inline-flex cursor-pointer items-center gap-2 rounded-10 px-2 py-0.5 transition-colors duration-200 hover:text-heading focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-surface focus-visible:outline-none", A.value ? "text-heading" : "text-muted"])
|
|
67
|
+
}, [l(_(x), {
|
|
68
|
+
class: "size-5",
|
|
69
|
+
"aria-hidden": "true"
|
|
70
|
+
})], 10, S)]),
|
|
71
|
+
_: 1
|
|
72
|
+
}, 8, ["content", "disabled"])) : (p(), s("button", {
|
|
69
73
|
key: 1,
|
|
70
74
|
type: "button",
|
|
71
|
-
"aria-label":
|
|
72
|
-
class:
|
|
75
|
+
"aria-label": N.value,
|
|
76
|
+
class: f(["inline-flex h-9 cursor-pointer items-center gap-1.5 rounded-10 border border-border bg-surface px-3 text-base font-medium text-heading transition-colors duration-200 hover:bg-surface-sunken/50 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-surface focus-visible:outline-none", A.value && "bg-surface-sunken/50"])
|
|
73
77
|
}, [
|
|
74
|
-
|
|
78
|
+
l(_(x), {
|
|
75
79
|
class: "size-4 text-muted",
|
|
76
80
|
"aria-hidden": "true"
|
|
77
81
|
}),
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
class:
|
|
82
|
+
c("span", w, g(M.value?.value ?? ""), 1),
|
|
83
|
+
l(_(b), {
|
|
84
|
+
class: f(["size-4 text-muted transition-transform duration-200 motion-reduce:transition-none", A.value && "rotate-180"]),
|
|
81
85
|
"aria-hidden": "true"
|
|
82
86
|
}, null, 8, ["class"])
|
|
83
|
-
], 10,
|
|
84
|
-
default:
|
|
87
|
+
], 10, C))]),
|
|
88
|
+
default: y(() => [c("div", { class: f(j.value && "flex flex-col px-2 py-1") }, [u.menuTitle ? (p(), s("p", {
|
|
89
|
+
key: 0,
|
|
90
|
+
class: f(["mb-2 border-b border-border py-2 text-xs font-semibold text-muted", j.value ? "px-3" : "px-4"]),
|
|
91
|
+
"aria-hidden": "true"
|
|
92
|
+
}, g(u.menuTitle), 3)) : o("", !0), (p(!0), s(r, null, h(u.locales, (e) => (p(), a(n, {
|
|
85
93
|
key: e.value,
|
|
86
94
|
description: e.description,
|
|
87
|
-
"aria-current": e.value ===
|
|
88
|
-
class:
|
|
89
|
-
onClick: (t) =>
|
|
95
|
+
"aria-current": e.value === O.value ? "true" : void 0,
|
|
96
|
+
class: f([e.value === O.value && "bg-surface-sunken/50", j.value && "rounded-8"]),
|
|
97
|
+
onClick: (t) => F(e.value)
|
|
90
98
|
}, {
|
|
91
|
-
default:
|
|
92
|
-
e.flag ? (
|
|
93
|
-
|
|
99
|
+
default: y(() => [c("span", { class: f(["flex items-center gap-2", j.value && "min-h-8 px-1"]) }, [
|
|
100
|
+
e.flag ? (p(), s("span", {
|
|
101
|
+
key: 0,
|
|
102
|
+
class: f(["shrink-0 leading-none", j.value ? "text-2xl" : "text-xl"]),
|
|
103
|
+
"aria-hidden": "true"
|
|
104
|
+
}, g(e.flag), 3)) : o("", !0),
|
|
105
|
+
c("span", {
|
|
94
106
|
class: "min-w-0 flex-1 truncate font-medium text-heading",
|
|
95
107
|
lang: e.value
|
|
96
|
-
},
|
|
97
|
-
e.value ===
|
|
98
|
-
])]),
|
|
108
|
+
}, g(e.label), 9, T),
|
|
109
|
+
e.value === O.value ? (p(), s("span", E)) : o("", !0)
|
|
110
|
+
], 2)]),
|
|
99
111
|
_: 2
|
|
100
112
|
}, 1032, [
|
|
101
113
|
"description",
|
|
102
114
|
"aria-current",
|
|
103
115
|
"class",
|
|
104
116
|
"onClick"
|
|
105
|
-
]))), 128))]),
|
|
117
|
+
]))), 128))], 2)]),
|
|
106
118
|
_: 1
|
|
107
|
-
}, 8, [
|
|
119
|
+
}, 8, [
|
|
120
|
+
"open",
|
|
121
|
+
"align",
|
|
122
|
+
"menu-label"
|
|
123
|
+
])) : o("", !0);
|
|
108
124
|
}
|
|
109
125
|
});
|
|
110
126
|
//#endregion
|
|
111
|
-
export {
|
|
127
|
+
export { D as default };
|