@ac-design/design-system 2.3.0 → 2.4.1
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 +211 -6
- 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 +7 -1
- package/dist/lib/components/AcButton.vue_vue_type_script_setup_true_lang.js +90 -69
- 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 +3 -3
- 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 +14 -7
- package/dist/lib/components/AcDatePicker.vue_vue_type_script_setup_true_lang.js +417 -372
- 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/AcDropdownItem.vue_vue_type_script_setup_true_lang.js +27 -30
- 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/AcInput.vue.d.ts +75 -54
- package/dist/lib/components/AcInput.vue_vue_type_script_setup_true_lang.js +253 -89
- 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/AcMapChart.vue.d.ts +2 -2
- package/dist/lib/components/AcModal.vue.d.ts +2 -2
- package/dist/lib/components/AcModal.vue_vue_type_script_setup_true_lang.js +4 -4
- 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.vue.d.ts +2 -2
- package/dist/lib/components/AcRadioCard.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/lib/components/AcSelect.vue.d.ts +35 -6
- package/dist/lib/components/AcSelect.vue_vue_type_script_setup_true_lang.js +272 -176
- package/dist/lib/components/AcSidePanel.vue.d.ts +1 -1
- package/dist/lib/components/AcSidePanel.vue_vue_type_script_setup_true_lang.js +2 -2
- 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 +37 -4
- package/dist/lib/components/AcTable.vue_vue_type_script_setup_true_lang.js +239 -131
- package/dist/lib/components/AcTagInput.vue.d.ts +22 -3
- 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 +38 -4
- package/dist/lib/components/AcTextarea.vue_vue_type_script_setup_true_lang.js +113 -53
- package/dist/lib/components/AcTimePicker.vue.d.ts +15 -8
- package/dist/lib/components/AcTimePicker.vue_vue_type_script_setup_true_lang.js +102 -70
- package/dist/lib/components/AcTooltip.vue.d.ts +3 -3
- package/dist/lib/components/index.d.ts +1 -0
- package/dist/lib/composables/useToast.d.ts +2 -2
- package/dist/lib/index.d.ts +2 -1
- package/dist/lib/index.js +31 -30
- package/package.json +1 -1
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { Fragment as e, computed as t, createCommentVNode as n, createElementBlock as r, createElementVNode as i, createVNode as a, defineComponent as o, mergeModels as s, mergeProps as c, nextTick as l, normalizeClass as u, openBlock as d, ref as f, renderList as p,
|
|
2
|
-
import { Plus as
|
|
1
|
+
import { Fragment as e, computed as t, createCommentVNode as n, createElementBlock as r, createElementVNode as i, createVNode as a, defineComponent as o, mergeModels as s, mergeProps as c, nextTick as l, normalizeClass as u, openBlock as d, ref as f, renderList as p, renderSlot as m, toDisplayString as h, unref as g, useAttrs as _, useId as v, useModel as y, vModelText as b, watch as x, withDirectives as ee, withModifiers as te } from "vue";
|
|
2
|
+
import { Plus as ne, X as S } from "@lucide/vue";
|
|
3
3
|
//#region src/lib/components/AcTagInput.vue?vue&type=script&setup=true&lang.ts
|
|
4
|
-
var
|
|
4
|
+
var re = ["for"], ie = {
|
|
5
5
|
key: 0,
|
|
6
6
|
class: "font-normal text-muted"
|
|
7
|
-
},
|
|
7
|
+
}, C = {
|
|
8
8
|
key: 1,
|
|
9
9
|
class: "text-danger",
|
|
10
10
|
"aria-hidden": "true"
|
|
11
|
-
},
|
|
11
|
+
}, ae = [
|
|
12
12
|
"id",
|
|
13
13
|
"name",
|
|
14
14
|
"placeholder",
|
|
@@ -17,26 +17,26 @@ var ie = ["for"], x = {
|
|
|
17
17
|
"aria-invalid",
|
|
18
18
|
"aria-required",
|
|
19
19
|
"aria-describedby"
|
|
20
|
-
],
|
|
20
|
+
], oe = [
|
|
21
21
|
"disabled",
|
|
22
22
|
"aria-label",
|
|
23
23
|
"title"
|
|
24
|
-
],
|
|
24
|
+
], se = ["aria-label"], ce = ["title"], le = [
|
|
25
25
|
"aria-label",
|
|
26
26
|
"title",
|
|
27
27
|
"onClick",
|
|
28
28
|
"onKeydown"
|
|
29
|
-
],
|
|
29
|
+
], ue = {
|
|
30
30
|
key: 3,
|
|
31
31
|
class: "mt-2 flex items-center justify-between gap-3 text-xs text-muted tabular-nums"
|
|
32
|
-
},
|
|
32
|
+
}, de = { key: 0 }, fe = {
|
|
33
33
|
class: "sr-only",
|
|
34
34
|
"aria-live": "polite"
|
|
35
|
-
},
|
|
35
|
+
}, w = /*@__PURE__*/ o({
|
|
36
36
|
inheritAttrs: !1,
|
|
37
37
|
__name: "AcTagInput",
|
|
38
38
|
props: /*@__PURE__*/ s({
|
|
39
|
-
label: {},
|
|
39
|
+
label: { default: "" },
|
|
40
40
|
name: { default: "" },
|
|
41
41
|
placeholder: { default: "" },
|
|
42
42
|
hint: { default: "" },
|
|
@@ -78,7 +78,12 @@ var ie = ["for"], x = {
|
|
|
78
78
|
readonly: {
|
|
79
79
|
type: Boolean,
|
|
80
80
|
default: !1
|
|
81
|
-
}
|
|
81
|
+
},
|
|
82
|
+
prepend: {
|
|
83
|
+
type: Boolean,
|
|
84
|
+
default: !1
|
|
85
|
+
},
|
|
86
|
+
requiredMessage: { default: "" }
|
|
82
87
|
}, {
|
|
83
88
|
modelValue: { default: () => [] },
|
|
84
89
|
modelModifiers: {}
|
|
@@ -88,202 +93,209 @@ var ie = ["for"], x = {
|
|
|
88
93
|
"remove",
|
|
89
94
|
"clear"
|
|
90
95
|
], ["update:modelValue"]),
|
|
91
|
-
setup(o, { expose: s, emit:
|
|
92
|
-
let
|
|
93
|
-
class:
|
|
94
|
-
style:
|
|
95
|
-
})),
|
|
96
|
-
let { class: e, style: t, ...n } =
|
|
96
|
+
setup(o, { expose: s, emit: w }) {
|
|
97
|
+
let T = o, E = y(o, "modelValue"), D = w, O = /[\s,;]+/, pe = /[,\n]+/, k = v(), A = `${k}-hint`, j = `${k}-msg`, M = `${k}-count`, N = `${k}-help`, P = _(), F = t(() => ({
|
|
98
|
+
class: P.class,
|
|
99
|
+
style: P.style
|
|
100
|
+
})), I = t(() => {
|
|
101
|
+
let { class: e, style: t, ...n } = P;
|
|
97
102
|
return n;
|
|
98
|
-
}),
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
].filter(Boolean).join(" ") || void 0),
|
|
104
|
-
function
|
|
105
|
-
|
|
103
|
+
}), L = f(null), R = f(null), z = f(""), B = f(""), V = f(""), H = f(!1), U = f(""), W = t(() => E.value ?? []), G = t(() => !T.disabled && !T.readonly), K = t(() => T.maxItems !== void 0 && W.value.length >= T.maxItems), me = t(() => T.maxItems !== void 0 && W.value.length >= T.maxItems * .8), q = t(() => B.value || V.value || T.errorMsg), he = t(() => [
|
|
104
|
+
T.hint && A,
|
|
105
|
+
q.value && j,
|
|
106
|
+
T.maxItems !== void 0 && M,
|
|
107
|
+
G.value && N
|
|
108
|
+
].filter(Boolean).join(" ") || void 0), ge = t(() => G.value ? K.value ? `Maximum ${T.maxItems} items reached` : T.placeholder || "Add item and press Enter" : ""), _e = t(() => G.value && !K.value && !!z.value.trim());
|
|
109
|
+
function J(e) {
|
|
110
|
+
U.value = "", l(() => U.value = e);
|
|
106
111
|
}
|
|
107
|
-
function
|
|
108
|
-
return
|
|
112
|
+
function ve(e, t) {
|
|
113
|
+
return T.maxItems !== void 0 && t.length >= T.maxItems ? `You can add up to ${T.maxItems} ${T.maxItems === 1 ? "value" : "values"}. Remove one first.` : !T.allowDuplicates && t.includes(e) ? `“${e}” is already added.` : T.validate?.(e, t) || "";
|
|
109
114
|
}
|
|
110
|
-
function
|
|
111
|
-
let n = [...
|
|
115
|
+
function Y(e, t) {
|
|
116
|
+
let n = [...W.value], r = [], i = [], a = "";
|
|
112
117
|
for (let o of e.split(t)) {
|
|
113
|
-
let e =
|
|
118
|
+
let e = T.transform(o);
|
|
114
119
|
if (!e) continue;
|
|
115
|
-
let t =
|
|
120
|
+
let t = ve(e, n);
|
|
116
121
|
if (t) {
|
|
117
122
|
i.push(o.trim()), a ||= t;
|
|
118
123
|
continue;
|
|
119
124
|
}
|
|
120
125
|
n.push(e), r.push(e);
|
|
121
126
|
}
|
|
122
|
-
return r.length && (
|
|
127
|
+
return r.length && (E.value = T.prepend ? [...[...r].reverse(), ...W.value] : n, V.value = "", r.forEach((e) => D("add", e)), J(r.length === 1 ? `Added ${r[0]}.` : `Added ${r.length} values.`)), z.value = i.join(", "), l(() => B.value = a), i.length > 0;
|
|
123
128
|
}
|
|
124
|
-
function
|
|
125
|
-
return !
|
|
129
|
+
function X() {
|
|
130
|
+
return !G.value || !z.value.trim() ? !1 : Y(z.value, pe);
|
|
126
131
|
}
|
|
127
|
-
function
|
|
128
|
-
if (!
|
|
129
|
-
let n =
|
|
132
|
+
function Z(e, t = !0) {
|
|
133
|
+
if (!G.value) return;
|
|
134
|
+
let n = W.value[e];
|
|
130
135
|
if (n === void 0) return;
|
|
131
|
-
let r =
|
|
132
|
-
|
|
136
|
+
let r = W.value.filter((t, n) => n !== e);
|
|
137
|
+
E.value = r, H.value = !1, B.value = "", D("remove", n, e), J(`Removed ${n}.`), Q(r), t && l(() => {
|
|
133
138
|
let t = $();
|
|
134
|
-
(t[Math.min(e, t.length - 1)] ??
|
|
139
|
+
(t[Math.min(e, t.length - 1)] ?? L.value)?.focus();
|
|
135
140
|
});
|
|
136
141
|
}
|
|
137
|
-
function
|
|
138
|
-
|
|
142
|
+
function ye() {
|
|
143
|
+
G.value && W.value.length && (E.value = [], H.value = !1, D("clear"), Q([]), J("Removed every value."), L.value?.focus());
|
|
144
|
+
}
|
|
145
|
+
function Q(e = W.value) {
|
|
146
|
+
V.value = T.required && T.requiredMessage && !e.length ? T.requiredMessage : "";
|
|
139
147
|
}
|
|
140
148
|
function $() {
|
|
141
|
-
return Array.from(
|
|
149
|
+
return Array.from(R.value?.querySelectorAll("[data-remove]") ?? []);
|
|
142
150
|
}
|
|
143
|
-
function
|
|
144
|
-
if (!
|
|
151
|
+
function be(e) {
|
|
152
|
+
if (!G.value || e.isComposing) return;
|
|
145
153
|
let t = e.target, n = t.selectionStart === 0 && t.selectionEnd === 0;
|
|
146
|
-
e.key === "Enter" || e.key === "," ? (e.preventDefault(),
|
|
154
|
+
e.key === "Enter" || e.key === "," ? (e.preventDefault(), X()) : e.key === "Tab" && !e.shiftKey && z.value.trim() ? X() : e.key === "Backspace" && !z.value && W.value.length ? (e.preventDefault(), H.value ? Z(W.value.length - 1, !1) : (H.value = !0, J(`${W.value[W.value.length - 1]} selected. Press Backspace again to remove it.`))) : e.key === "ArrowLeft" && n && W.value.length ? (e.preventDefault(), H.value = !1, $().at(-1)?.focus()) : e.key === "Escape" && (z.value || B.value) ? (e.preventDefault(), z.value = "", B.value = "") : H.value = !1;
|
|
147
155
|
}
|
|
148
|
-
function
|
|
156
|
+
function xe(e, t) {
|
|
149
157
|
let n = $();
|
|
150
|
-
e.key === "Backspace" || e.key === "Delete" ? (e.preventDefault(),
|
|
158
|
+
e.key === "Backspace" || e.key === "Delete" ? (e.preventDefault(), Z(t)) : e.key === "ArrowLeft" ? (e.preventDefault(), n[Math.max(t - 1, 0)]?.focus()) : e.key === "ArrowRight" ? (e.preventDefault(), (n[t + 1] ?? L.value)?.focus()) : e.key === "Home" ? (e.preventDefault(), n[0]?.focus()) : e.key === "End" && (e.preventDefault(), L.value?.focus());
|
|
151
159
|
}
|
|
152
|
-
function
|
|
153
|
-
if (!
|
|
160
|
+
function Se(e) {
|
|
161
|
+
if (!G.value) return;
|
|
154
162
|
let t = e.clipboardData?.getData("text") ?? "";
|
|
155
|
-
if (!
|
|
163
|
+
if (!O.test(t.trim())) return;
|
|
156
164
|
e.preventDefault();
|
|
157
|
-
let n =
|
|
158
|
-
|
|
165
|
+
let n = L.value, r = n?.selectionStart ?? z.value.length, i = n?.selectionEnd ?? z.value.length;
|
|
166
|
+
Y(z.value.slice(0, r) + t + z.value.slice(i), O);
|
|
159
167
|
}
|
|
160
|
-
function
|
|
161
|
-
|
|
168
|
+
function Ce() {
|
|
169
|
+
H.value = !1;
|
|
170
|
+
let e = !!z.value.trim();
|
|
171
|
+
T.addOnBlur && X(), T.addOnBlur && e || Q();
|
|
162
172
|
}
|
|
163
|
-
function
|
|
164
|
-
|
|
173
|
+
function we(e) {
|
|
174
|
+
T.disabled || e.target.closest("button") || L.value?.focus();
|
|
165
175
|
}
|
|
166
|
-
return
|
|
167
|
-
|
|
176
|
+
return x(z, () => {
|
|
177
|
+
B.value = "", V.value = "", H.value = !1;
|
|
168
178
|
}), s({
|
|
169
|
-
focus: () =>
|
|
170
|
-
commit: () => !
|
|
171
|
-
}), (t, s) => (d(), r("div", c(
|
|
179
|
+
focus: () => L.value?.focus(),
|
|
180
|
+
commit: () => !X()
|
|
181
|
+
}), (t, s) => (d(), r("div", c(F.value, {
|
|
172
182
|
class: ["w-full", o.disabled && "opacity-50"],
|
|
173
183
|
"data-ac-ds": "",
|
|
174
184
|
"data-testid": "ac-tag-input"
|
|
175
185
|
}), [
|
|
176
186
|
i("label", {
|
|
177
|
-
for:
|
|
187
|
+
for: g(k),
|
|
178
188
|
class: "mb-2 flex items-center gap-1 text-base font-medium text-heading"
|
|
179
189
|
}, [
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
190
|
+
m(t.$slots, "label-icon"),
|
|
191
|
+
i("span", null, h(o.label), 1),
|
|
192
|
+
m(t.$slots, "label-extra"),
|
|
193
|
+
o.readonly ? (d(), r("span", ie, "(read only)")) : n("", !0),
|
|
194
|
+
o.required ? (d(), r("span", C, "*")) : n("", !0)
|
|
195
|
+
], 8, re),
|
|
184
196
|
o.hint ? (d(), r("p", {
|
|
185
197
|
key: 0,
|
|
186
|
-
id:
|
|
198
|
+
id: A,
|
|
187
199
|
class: "mb-2 text-base text-muted"
|
|
188
|
-
},
|
|
200
|
+
}, h(o.hint), 1)) : n("", !0),
|
|
189
201
|
i("div", {
|
|
190
202
|
class: u(["flex w-full items-center rounded-10 border transition-[border-color,box-shadow,background-color] duration-200", [
|
|
191
203
|
o.size === "small" ? "h-9" : "h-10.5",
|
|
192
204
|
o.readonly ? "bg-surface-muted" : "bg-background",
|
|
193
205
|
o.disabled ? "cursor-not-allowed" : "cursor-text",
|
|
194
|
-
|
|
206
|
+
q.value ? "border-danger/50 focus-within:border-danger focus-within:shadow-[0_0_0_2px_color-mix(in_srgb,var(--color-danger)_20%,transparent)]" : ["border-border focus-within:focus-ring", !o.disabled && "hover:border-accent-active"]
|
|
195
207
|
]]),
|
|
196
|
-
onClick:
|
|
197
|
-
}, [
|
|
198
|
-
id:
|
|
208
|
+
onClick: we
|
|
209
|
+
}, [ee(i("input", c({
|
|
210
|
+
id: g(k),
|
|
199
211
|
ref_key: "input",
|
|
200
|
-
ref:
|
|
201
|
-
},
|
|
202
|
-
"onUpdate:modelValue": s[0] ||= (e) =>
|
|
212
|
+
ref: L
|
|
213
|
+
}, I.value, {
|
|
214
|
+
"onUpdate:modelValue": s[0] ||= (e) => z.value = e,
|
|
203
215
|
type: "text",
|
|
204
216
|
name: o.name,
|
|
205
|
-
placeholder:
|
|
217
|
+
placeholder: ge.value,
|
|
206
218
|
disabled: o.disabled,
|
|
207
219
|
readonly: o.readonly,
|
|
208
|
-
"aria-invalid": !!
|
|
220
|
+
"aria-invalid": !!q.value || void 0,
|
|
209
221
|
"aria-required": o.required || void 0,
|
|
210
|
-
"aria-describedby":
|
|
222
|
+
"aria-describedby": he.value,
|
|
211
223
|
autocomplete: "off",
|
|
212
224
|
autocapitalize: "off",
|
|
213
225
|
spellcheck: "false",
|
|
214
226
|
class: ["h-full min-w-0 flex-1 rounded-10 bg-transparent pr-2 text-base font-normal text-heading outline-none placeholder:text-muted/80 disabled:cursor-not-allowed", [o.mono && "font-mono", o.size === "small" ? "pl-4" : "pl-5"]],
|
|
215
|
-
onKeydown:
|
|
216
|
-
onPaste:
|
|
217
|
-
onBlur:
|
|
218
|
-
}), null, 16,
|
|
227
|
+
onKeydown: be,
|
|
228
|
+
onPaste: Se,
|
|
229
|
+
onBlur: Ce
|
|
230
|
+
}), null, 16, ae), [[b, z.value]]), i("span", { class: u(["flex shrink-0 items-center text-heading", o.size === "small" ? "mr-1" : "mr-3"]) }, [G.value && o.showClear && W.value.length ? (d(), r("button", {
|
|
219
231
|
key: 0,
|
|
220
232
|
type: "button",
|
|
221
233
|
class: u(["inline-flex cursor-pointer items-center justify-center rounded-full transition-colors hover:bg-surface-sunken focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none", o.size === "small" ? "size-7" : "size-8"]),
|
|
222
234
|
"aria-label": "Clear all values",
|
|
223
235
|
title: "Clear all items",
|
|
224
|
-
onClick:
|
|
225
|
-
}, [a(
|
|
236
|
+
onClick: ye
|
|
237
|
+
}, [a(g(S), {
|
|
226
238
|
class: "size-4",
|
|
227
239
|
"aria-hidden": "true"
|
|
228
240
|
})], 2)) : n("", !0), i("button", {
|
|
229
241
|
type: "button",
|
|
230
242
|
class: u(["inline-flex items-center justify-center rounded-full transition-colors focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none enabled:cursor-pointer enabled:hover:bg-surface-sunken disabled:cursor-not-allowed disabled:opacity-40", o.size === "small" ? "size-7" : "size-8"]),
|
|
231
|
-
disabled: !
|
|
232
|
-
"aria-label":
|
|
233
|
-
title:
|
|
243
|
+
disabled: !_e.value,
|
|
244
|
+
"aria-label": z.value.trim() ? `Add ${z.value.trim()}` : "Add item",
|
|
245
|
+
title: z.value.trim() ? `Add “${z.value.trim()}”` : "Add item",
|
|
234
246
|
tabindex: "-1",
|
|
235
|
-
onMousedown: s[1] ||=
|
|
236
|
-
onClick:
|
|
237
|
-
}, [a(
|
|
247
|
+
onMousedown: s[1] ||= te(() => {}, ["prevent"]),
|
|
248
|
+
onClick: X
|
|
249
|
+
}, [a(g(ne), {
|
|
238
250
|
class: "size-4",
|
|
239
251
|
"aria-hidden": "true"
|
|
240
|
-
})], 42,
|
|
241
|
-
|
|
252
|
+
})], 42, oe)], 2)], 2),
|
|
253
|
+
q.value ? (d(), r("p", {
|
|
242
254
|
key: 1,
|
|
243
|
-
id:
|
|
255
|
+
id: j,
|
|
244
256
|
class: "mt-1 text-base text-danger-strong",
|
|
245
257
|
role: "alert"
|
|
246
|
-
},
|
|
247
|
-
|
|
258
|
+
}, h(q.value), 1)) : n("", !0),
|
|
259
|
+
W.value.length ? (d(), r("ul", {
|
|
248
260
|
key: 2,
|
|
249
261
|
ref_key: "list",
|
|
250
|
-
ref:
|
|
262
|
+
ref: R,
|
|
251
263
|
role: "list",
|
|
252
|
-
"aria-label": o.label,
|
|
264
|
+
"aria-label": o.label || g(P)["aria-label"],
|
|
253
265
|
class: "mt-3 flex w-full flex-wrap gap-2"
|
|
254
|
-
}, [(d(!0), r(e, null, p(
|
|
266
|
+
}, [(d(!0), r(e, null, p(W.value, (e, t) => (d(), r("li", {
|
|
255
267
|
key: `${t}-${e}`,
|
|
256
|
-
class: u(["inline-flex h-8 max-w-full min-w-0 items-center justify-between gap-2 rounded-10 border px-3 text-base text-heading transition-all duration-300 hover:shadow-sm motion-reduce:transition-none", [o.mono && "font-mono",
|
|
268
|
+
class: u(["inline-flex h-8 max-w-full min-w-0 items-center justify-between gap-2 rounded-10 border px-3 text-base text-heading transition-all duration-300 hover:shadow-sm motion-reduce:transition-none", [o.mono && "font-mono", H.value && t === W.value.length - 1 ? "border-primary bg-accent-active ring-2 ring-ring" : "border-border bg-background"]]),
|
|
257
269
|
"data-testid": "ac-tag-input-chip"
|
|
258
270
|
}, [i("span", {
|
|
259
271
|
class: "truncate",
|
|
260
272
|
title: e
|
|
261
|
-
},
|
|
273
|
+
}, h(e), 9, ce), G.value ? (d(), r("button", {
|
|
262
274
|
key: 0,
|
|
263
275
|
type: "button",
|
|
264
276
|
"data-remove": "",
|
|
265
277
|
class: "inline-flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-full transition-colors hover:bg-surface-sunken focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none",
|
|
266
278
|
"aria-label": `Remove ${e}`,
|
|
267
279
|
title: `Remove ${e}`,
|
|
268
|
-
onClick: (e) =>
|
|
269
|
-
onKeydown: (e) =>
|
|
270
|
-
}, [a(
|
|
280
|
+
onClick: (e) => Z(t),
|
|
281
|
+
onKeydown: (e) => xe(e, t)
|
|
282
|
+
}, [a(g(S), {
|
|
271
283
|
class: "size-4",
|
|
272
284
|
"aria-hidden": "true"
|
|
273
|
-
})], 40,
|
|
274
|
-
|
|
285
|
+
})], 40, le)) : n("", !0)], 2))), 128))], 8, se)) : n("", !0),
|
|
286
|
+
W.value.length || o.maxItems !== void 0 ? (d(), r("div", ue, [W.value.length ? (d(), r("span", de, h(W.value.length) + " " + h(W.value.length === 1 ? "item" : "items"), 1)) : n("", !0), o.maxItems === void 0 ? n("", !0) : (d(), r("span", {
|
|
275
287
|
key: 1,
|
|
276
|
-
id:
|
|
277
|
-
class: u(["ml-auto",
|
|
278
|
-
},
|
|
279
|
-
|
|
288
|
+
id: M,
|
|
289
|
+
class: u(["ml-auto", K.value ? "text-danger-strong" : me.value && "text-warning-strong"])
|
|
290
|
+
}, h(W.value.length) + " / " + h(o.maxItems) + " items ", 3))])) : n("", !0),
|
|
291
|
+
G.value ? (d(), r("p", {
|
|
280
292
|
key: 4,
|
|
281
|
-
id:
|
|
293
|
+
id: N,
|
|
282
294
|
class: "sr-only"
|
|
283
295
|
}, "Press Enter or comma to add a value. Backspace in the empty input removes the last one.")) : n("", !0),
|
|
284
|
-
i("p",
|
|
296
|
+
i("p", fe, h(U.value), 1)
|
|
285
297
|
], 16));
|
|
286
298
|
}
|
|
287
299
|
});
|
|
288
300
|
//#endregion
|
|
289
|
-
export {
|
|
301
|
+
export { w as default };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { SelectOption } from "./types";
|
|
2
|
+
/** One Kubernetes node taint. */
|
|
3
|
+
export interface TaintItem<E = string> {
|
|
4
|
+
key: string;
|
|
5
|
+
value: string;
|
|
6
|
+
/** One of `effects`' values, e.g. `NoSchedule`. */
|
|
7
|
+
effect: E;
|
|
8
|
+
}
|
|
9
|
+
export interface Props<T> {
|
|
10
|
+
/** Effects to choose from, each with a `description` shown under its name. Defaults to Kubernetes' `NoSchedule`, `NoExecute` and `PreferNoSchedule`; pass your own to store enum numbers. The first is the default for a new row. */
|
|
11
|
+
effects?: SelectOption<T>[];
|
|
12
|
+
/** The effect that evicts running pods. Choosing it shows a warning under the rows. */
|
|
13
|
+
evictEffect?: T;
|
|
14
|
+
/** Disables every field and button. Was `is-disabled` in cloud-ui. */
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
}
|
|
17
|
+
declare const __VLS_export: <V extends string | number = string>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
18
|
+
props: import("vue").PublicProps & __VLS_PrettifyLocal<(Props<V> & {
|
|
19
|
+
/** The taints that have a key, in order. Rows without a key stay on screen but aren't in the model. */
|
|
20
|
+
modelValue?: TaintItem<V>[];
|
|
21
|
+
}) & {
|
|
22
|
+
"onUpdate:modelValue"?: ((value: TaintItem<V>[]) => any) | undefined;
|
|
23
|
+
onAdd?: (() => any) | undefined;
|
|
24
|
+
onRemove?: ((index: number) => any) | undefined;
|
|
25
|
+
}> & (typeof globalThis extends {
|
|
26
|
+
__VLS_PROPS_FALLBACK: infer P;
|
|
27
|
+
} ? P : {});
|
|
28
|
+
expose: (exposed: import("vue").ShallowUnwrapRef<{
|
|
29
|
+
/** Adds an empty row and focuses its key. */
|
|
30
|
+
add: () => void;
|
|
31
|
+
}>) => void;
|
|
32
|
+
attrs: any;
|
|
33
|
+
slots: {};
|
|
34
|
+
emit: (((evt: "add") => void) & ((evt: "remove", index: number) => void)) & ((event: "update:modelValue", value: TaintItem<V>[]) => void);
|
|
35
|
+
}>) => import("vue").VNode & {
|
|
36
|
+
__ctx?: NonNullable<Awaited<typeof __VLS_setup>>;
|
|
37
|
+
};
|
|
38
|
+
declare const _default: typeof __VLS_export;
|
|
39
|
+
export default _default;
|
|
40
|
+
type __VLS_PrettifyLocal<T> = (T extends any ? {
|
|
41
|
+
[K in keyof T]: T[K];
|
|
42
|
+
} : {
|
|
43
|
+
[K in keyof T as K]: T[K];
|
|
44
|
+
}) & {};
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import e from "./AcInput.js";
|
|
2
|
+
import t from "./AcSelect.js";
|
|
3
|
+
import { Fragment as n, TransitionGroup as r, computed as i, createCommentVNode as a, createElementBlock as o, createElementVNode as s, createStaticVNode as c, createTextVNode as l, createVNode as u, defineComponent as d, mergeModels as f, nextTick as p, openBlock as m, ref as h, renderList as g, toDisplayString as _, unref as v, useModel as y, watch as b, withCtx as x } from "vue";
|
|
4
|
+
import { Plus as ee, Trash as S, TriangleAlert as C } from "@lucide/vue";
|
|
5
|
+
//#region src/lib/components/AcTaintInput.vue?vue&type=script&setup=true&lang.ts
|
|
6
|
+
var w = { class: "relative flex-1 max-sm:basis-full" }, T = {
|
|
7
|
+
key: 0,
|
|
8
|
+
class: "mt-1.5 flex items-center gap-1.5 text-xs font-bold text-danger-strong",
|
|
9
|
+
role: "alert"
|
|
10
|
+
}, E = { class: "relative flex-1 max-sm:basis-full" }, D = { class: "w-64 max-sm:min-w-0 max-sm:flex-1" }, O = { class: "flex flex-col" }, k = { class: "text-base font-bold" }, A = { class: "text-xs text-muted" }, te = { class: "flex flex-col" }, j = { class: "text-base font-bold" }, M = { class: "text-xs text-muted" }, N = [
|
|
11
|
+
"disabled",
|
|
12
|
+
"aria-label",
|
|
13
|
+
"onClick"
|
|
14
|
+
], P = { class: "mt-4 flex" }, F = ["disabled"], I = {
|
|
15
|
+
key: 0,
|
|
16
|
+
class: "mt-6 flex items-start gap-3 rounded-8 border border-warning/20 bg-warning/5 p-4",
|
|
17
|
+
role: "note"
|
|
18
|
+
}, L = /*@__PURE__*/ d({
|
|
19
|
+
__name: "AcTaintInput",
|
|
20
|
+
props: /*@__PURE__*/ f({
|
|
21
|
+
effects: { default: () => [
|
|
22
|
+
{
|
|
23
|
+
value: "NoSchedule",
|
|
24
|
+
label: "NoSchedule",
|
|
25
|
+
description: "Does not schedule new pods"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
value: "NoExecute",
|
|
29
|
+
label: "NoExecute",
|
|
30
|
+
description: "Evicts existing pods"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
value: "PreferNoSchedule",
|
|
34
|
+
label: "PreferNoSchedule",
|
|
35
|
+
description: "Prefers not to schedule new pods"
|
|
36
|
+
}
|
|
37
|
+
] },
|
|
38
|
+
evictEffect: { default: () => "NoExecute" },
|
|
39
|
+
disabled: {
|
|
40
|
+
type: Boolean,
|
|
41
|
+
default: !1
|
|
42
|
+
}
|
|
43
|
+
}, {
|
|
44
|
+
modelValue: { default: () => [] },
|
|
45
|
+
modelModifiers: {}
|
|
46
|
+
}),
|
|
47
|
+
emits: /*@__PURE__*/ f(["add", "remove"], ["update:modelValue"]),
|
|
48
|
+
setup(d, { expose: f, emit: L }) {
|
|
49
|
+
let R = d, z = y(d, "modelValue"), B = L, V = h(null), H = 0, U = h([]), W = "", G = i(() => R.effects[0]?.value), K = i(() => U.value.some((e) => e.effect === R.evictEffect)), q = i(() => {
|
|
50
|
+
let e = /* @__PURE__ */ new Set();
|
|
51
|
+
return U.value.map((t) => {
|
|
52
|
+
if (t.key) {
|
|
53
|
+
let n = e.has(t.key);
|
|
54
|
+
return e.add(t.key), n ? "If duplicate key found , it will be overwritten" : "";
|
|
55
|
+
}
|
|
56
|
+
return !t.keyFocused && (t.value || t.effect !== G.value) ? "Key is required" : "";
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
function J(e = "", t = "", n) {
|
|
60
|
+
return {
|
|
61
|
+
id: H++,
|
|
62
|
+
key: e,
|
|
63
|
+
value: t,
|
|
64
|
+
effect: n || G.value,
|
|
65
|
+
keyFocused: !1
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
function Y(e) {
|
|
69
|
+
let t = (e ?? []).map((e) => J(e.key, e.value || "", e.effect));
|
|
70
|
+
U.value = t.length ? t : [J()], W = JSON.stringify(X());
|
|
71
|
+
}
|
|
72
|
+
function X() {
|
|
73
|
+
return U.value.filter((e) => e.key).map((e) => ({
|
|
74
|
+
key: e.key,
|
|
75
|
+
value: e.value,
|
|
76
|
+
effect: e.effect
|
|
77
|
+
}));
|
|
78
|
+
}
|
|
79
|
+
function Z() {
|
|
80
|
+
let e = X();
|
|
81
|
+
W = JSON.stringify(e), z.value = e;
|
|
82
|
+
}
|
|
83
|
+
function Q(e, t) {
|
|
84
|
+
Object.assign(e, t), Z();
|
|
85
|
+
}
|
|
86
|
+
function $() {
|
|
87
|
+
if (R.disabled) return;
|
|
88
|
+
U.value.push(J()), Z(), B("add");
|
|
89
|
+
let e = U.value.length - 1;
|
|
90
|
+
p(() => V.value?.querySelectorAll("[data-cell='key']")[e]?.focus());
|
|
91
|
+
}
|
|
92
|
+
function ne(e) {
|
|
93
|
+
R.disabled || (U.value.splice(e, 1), Z(), B("remove", e));
|
|
94
|
+
}
|
|
95
|
+
return b(z, (e) => {
|
|
96
|
+
JSON.stringify(e ?? []) !== W && Y(e);
|
|
97
|
+
}, { immediate: !0 }), f({ add: $ }), (i, f) => (m(), o("div", {
|
|
98
|
+
ref_key: "root",
|
|
99
|
+
ref: V,
|
|
100
|
+
class: "w-full",
|
|
101
|
+
"data-ac-ds": "",
|
|
102
|
+
"data-testid": "ac-taint-input"
|
|
103
|
+
}, [
|
|
104
|
+
f[3] ||= c("<div class=\"mb-2 flex items-center gap-4 text-base font-bold text-heading max-sm:hidden\" aria-hidden=\"true\"><div class=\"flex-1\">Key<span class=\"ml-1 text-danger\">*</span></div><div class=\"flex-1\">Value (Optional)</div><div class=\"w-64\">Effect</div><div class=\"w-9\"></div></div>", 1),
|
|
105
|
+
u(r, {
|
|
106
|
+
tag: "div",
|
|
107
|
+
class: "relative space-y-4",
|
|
108
|
+
"enter-active-class": "transition-all duration-300 ease-out motion-reduce:transition-none",
|
|
109
|
+
"enter-from-class": "-translate-y-2.5 opacity-0",
|
|
110
|
+
"leave-active-class": "absolute w-full transition-all duration-300 ease-out motion-reduce:transition-none",
|
|
111
|
+
"leave-to-class": "translate-x-5 opacity-0",
|
|
112
|
+
"move-class": "transition-transform duration-300 ease-out motion-reduce:transition-none"
|
|
113
|
+
}, {
|
|
114
|
+
default: x(() => [(m(!0), o(n, null, g(U.value, (n, r) => (m(), o("div", {
|
|
115
|
+
key: n.id,
|
|
116
|
+
class: "flex w-full items-start gap-4 max-sm:flex-wrap max-sm:gap-2"
|
|
117
|
+
}, [
|
|
118
|
+
s("div", w, [u(e, {
|
|
119
|
+
"data-cell": "key",
|
|
120
|
+
"model-value": n.key,
|
|
121
|
+
disabled: d.disabled,
|
|
122
|
+
invalid: !!q.value[r],
|
|
123
|
+
"aria-label": `Taint ${r + 1} key`,
|
|
124
|
+
placeholder: "Enter identifier for taint",
|
|
125
|
+
autocomplete: "off",
|
|
126
|
+
spellcheck: "false",
|
|
127
|
+
class: "[&_:has(>input)]:rounded-8 [&_input]:rounded-8 [&_input]:pr-3 [&_input]:pl-3 [&_input]:font-medium [&_input]:placeholder:text-heading/50",
|
|
128
|
+
"onUpdate:modelValue": (e) => Q(n, { key: String(e) }),
|
|
129
|
+
onFocus: (e) => n.keyFocused = !0,
|
|
130
|
+
onBlur: (e) => n.keyFocused = !1
|
|
131
|
+
}, null, 8, [
|
|
132
|
+
"model-value",
|
|
133
|
+
"disabled",
|
|
134
|
+
"invalid",
|
|
135
|
+
"aria-label",
|
|
136
|
+
"onUpdate:modelValue",
|
|
137
|
+
"onFocus",
|
|
138
|
+
"onBlur"
|
|
139
|
+
]), !n.key && !n.keyFocused && (n.value || q.value[r]) ? (m(), o("p", T, [u(v(C), {
|
|
140
|
+
class: "size-3.5 fill-danger text-surface",
|
|
141
|
+
"aria-hidden": "true"
|
|
142
|
+
}), f[0] ||= l(" Key is required ", -1)])) : a("", !0)]),
|
|
143
|
+
s("div", E, [u(e, {
|
|
144
|
+
"data-cell": "value",
|
|
145
|
+
"model-value": n.value,
|
|
146
|
+
disabled: d.disabled,
|
|
147
|
+
"aria-label": `Taint ${r + 1} value`,
|
|
148
|
+
placeholder: "Enter associated value",
|
|
149
|
+
autocomplete: "off",
|
|
150
|
+
spellcheck: "false",
|
|
151
|
+
class: "[&_:has(>input)]:rounded-8 [&_input]:rounded-8 [&_input]:pr-3 [&_input]:pl-3 [&_input]:font-medium [&_input]:placeholder:text-heading/50",
|
|
152
|
+
"onUpdate:modelValue": (e) => Q(n, { value: String(e) })
|
|
153
|
+
}, null, 8, [
|
|
154
|
+
"model-value",
|
|
155
|
+
"disabled",
|
|
156
|
+
"aria-label",
|
|
157
|
+
"onUpdate:modelValue"
|
|
158
|
+
])]),
|
|
159
|
+
s("div", D, [u(t, {
|
|
160
|
+
"model-value": n.effect,
|
|
161
|
+
options: d.effects,
|
|
162
|
+
disabled: d.disabled,
|
|
163
|
+
"aria-label": `Taint ${r + 1} effect`,
|
|
164
|
+
placeholder: "Select effect",
|
|
165
|
+
"onUpdate:modelValue": (e) => Q(n, { effect: e ?? G.value })
|
|
166
|
+
}, {
|
|
167
|
+
option: x(({ option: e }) => [s("div", O, [s("span", k, _(e.label), 1), s("span", A, _(e.description), 1)])]),
|
|
168
|
+
selected: x(({ option: e }) => [s("div", te, [s("span", j, _(e.label), 1), s("span", M, _(e.description), 1)])]),
|
|
169
|
+
_: 1
|
|
170
|
+
}, 8, [
|
|
171
|
+
"model-value",
|
|
172
|
+
"options",
|
|
173
|
+
"disabled",
|
|
174
|
+
"aria-label",
|
|
175
|
+
"onUpdate:modelValue"
|
|
176
|
+
])]),
|
|
177
|
+
s("button", {
|
|
178
|
+
type: "button",
|
|
179
|
+
class: "mt-0.5 inline-flex size-[38px] shrink-0 cursor-pointer items-center justify-center rounded-8 text-muted transition-colors duration-200 hover:bg-danger/10 hover:text-danger focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-transparent disabled:hover:text-muted",
|
|
180
|
+
disabled: d.disabled,
|
|
181
|
+
"aria-label": n.key ? `Remove taint ${n.key}` : `Remove taint ${r + 1}`,
|
|
182
|
+
title: "Remove item",
|
|
183
|
+
onClick: (e) => ne(r)
|
|
184
|
+
}, [u(v(S), {
|
|
185
|
+
class: "size-[18px]",
|
|
186
|
+
"aria-hidden": "true"
|
|
187
|
+
})], 8, N)
|
|
188
|
+
]))), 128))]),
|
|
189
|
+
_: 1
|
|
190
|
+
}),
|
|
191
|
+
s("div", P, [s("button", {
|
|
192
|
+
type: "button",
|
|
193
|
+
class: "inline-flex cursor-pointer items-center gap-1.5 rounded-4 text-base leading-5 font-bold text-primary hover:underline focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:no-underline",
|
|
194
|
+
disabled: d.disabled,
|
|
195
|
+
onClick: $
|
|
196
|
+
}, [u(v(ee), {
|
|
197
|
+
class: "size-4",
|
|
198
|
+
"aria-hidden": "true"
|
|
199
|
+
}), f[1] ||= l(" Add another taint ", -1)], 8, F)]),
|
|
200
|
+
K.value ? (m(), o("div", I, [u(v(C), {
|
|
201
|
+
class: "mt-0.5 size-5 shrink-0 text-warning",
|
|
202
|
+
"aria-hidden": "true"
|
|
203
|
+
}), f[2] ||= s("p", { class: "text-base text-heading" }, [s("span", { class: "font-bold" }, "Warning:"), l(" NoExecute taint immediately evicts any running pods on this node pool that don't have a matching toleration. ")], -1)])) : a("", !0)
|
|
204
|
+
], 512));
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
//#endregion
|
|
208
|
+
export { L as default };
|