@ac-design/design-system 2.3.0 → 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.
Files changed (60) hide show
  1. package/dist/lib/compat.css +211 -0
  2. package/dist/lib/components/AcAppSwitcher.vue.d.ts +1 -1
  3. package/dist/lib/components/AcAppSwitcher.vue_vue_type_script_setup_true_lang.js +23 -23
  4. package/dist/lib/components/AcAreaChart.vue.d.ts +1 -1
  5. package/dist/lib/components/AcBarChart.vue.d.ts +1 -1
  6. package/dist/lib/components/AcButton.vue.d.ts +7 -1
  7. package/dist/lib/components/AcButton.vue_vue_type_script_setup_true_lang.js +90 -69
  8. package/dist/lib/components/AcCellValue.vue.d.ts +3 -3
  9. package/dist/lib/components/AcCellValue.vue_vue_type_script_setup_true_lang.js +20 -20
  10. package/dist/lib/components/AcCheckBox.vue.d.ts +4 -1
  11. package/dist/lib/components/AcCheckBox.vue_vue_type_script_setup_true_lang.js +50 -50
  12. package/dist/lib/components/AcCircularProgress.vue.d.ts +1 -1
  13. package/dist/lib/components/AcCodeEditor.vue.d.ts +12 -0
  14. package/dist/lib/components/AcCodeEditor.vue_vue_type_script_setup_true_lang.js +240 -207
  15. package/dist/lib/components/AcColorInput.vue.d.ts +3 -3
  16. package/dist/lib/components/AcColorInput.vue_vue_type_script_setup_true_lang.js +72 -66
  17. package/dist/lib/components/AcCostSummary.vue.d.ts +1 -1
  18. package/dist/lib/components/AcDatePicker.vue.d.ts +14 -7
  19. package/dist/lib/components/AcDatePicker.vue_vue_type_script_setup_true_lang.js +417 -372
  20. package/dist/lib/components/AcDeleteModal.vue.d.ts +1 -1
  21. package/dist/lib/components/AcDonutChart.vue.d.ts +2 -2
  22. package/dist/lib/components/AcDropdown.vue.d.ts +1 -1
  23. package/dist/lib/components/AcDropdown.vue_vue_type_script_setup_true_lang.js +8 -8
  24. package/dist/lib/components/AcFormFooter.vue_vue_type_script_setup_true_lang.js +8 -8
  25. package/dist/lib/components/AcGraphChart.vue.d.ts +2 -2
  26. package/dist/lib/components/AcInput.vue.d.ts +75 -54
  27. package/dist/lib/components/AcInput.vue_vue_type_script_setup_true_lang.js +253 -89
  28. package/dist/lib/components/AcKeyValueInput.vue.d.ts +34 -54
  29. package/dist/lib/components/AcKeyValueInput.vue_vue_type_script_setup_true_lang.js +134 -106
  30. package/dist/lib/components/AcLineChart.vue.d.ts +1 -1
  31. package/dist/lib/components/AcMapChart.vue.d.ts +2 -2
  32. package/dist/lib/components/AcModal.vue.d.ts +1 -1
  33. package/dist/lib/components/AcNotificationMenu.vue.d.ts +1 -1
  34. package/dist/lib/components/AcNotificationMenu.vue_vue_type_script_setup_true_lang.js +24 -24
  35. package/dist/lib/components/AcNumberInput.vue.d.ts +55 -45
  36. package/dist/lib/components/AcNumberInput.vue_vue_type_script_setup_true_lang.js +159 -99
  37. package/dist/lib/components/AcRadioCard.vue.d.ts +2 -2
  38. package/dist/lib/components/AcRadioCard.vue_vue_type_script_setup_true_lang.js +1 -1
  39. package/dist/lib/components/AcSelect.vue.d.ts +35 -6
  40. package/dist/lib/components/AcSelect.vue_vue_type_script_setup_true_lang.js +272 -176
  41. package/dist/lib/components/AcSidePanel.vue.d.ts +1 -1
  42. package/dist/lib/components/AcSlider.vue.d.ts +2 -2
  43. package/dist/lib/components/AcSwitch.vue_vue_type_script_setup_true_lang.js +23 -23
  44. package/dist/lib/components/AcTable.vue.d.ts +37 -4
  45. package/dist/lib/components/AcTable.vue_vue_type_script_setup_true_lang.js +239 -131
  46. package/dist/lib/components/AcTagInput.vue.d.ts +22 -3
  47. package/dist/lib/components/AcTagInput.vue_vue_type_script_setup_true_lang.js +126 -114
  48. package/dist/lib/components/AcTaintInput.js +5 -0
  49. package/dist/lib/components/AcTaintInput.vue.d.ts +44 -0
  50. package/dist/lib/components/AcTaintInput.vue_vue_type_script_setup_true_lang.js +208 -0
  51. package/dist/lib/components/AcTextarea.vue.d.ts +38 -4
  52. package/dist/lib/components/AcTextarea.vue_vue_type_script_setup_true_lang.js +113 -53
  53. package/dist/lib/components/AcTimePicker.vue.d.ts +15 -8
  54. package/dist/lib/components/AcTimePicker.vue_vue_type_script_setup_true_lang.js +102 -70
  55. package/dist/lib/components/AcTooltip.vue.d.ts +3 -3
  56. package/dist/lib/components/index.d.ts +1 -0
  57. package/dist/lib/composables/useToast.d.ts +2 -2
  58. package/dist/lib/index.d.ts +2 -1
  59. package/dist/lib/index.js +31 -30
  60. 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, toDisplayString as m, unref as h, useAttrs as g, useId as _, useModel as v, vModelText as y, watch as ee, withDirectives as te, withModifiers as ne } from "vue";
2
- import { Plus as re, X as b } from "@lucide/vue";
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 ie = ["for"], x = {
4
+ var re = ["for"], ie = {
5
5
  key: 0,
6
6
  class: "font-normal text-muted"
7
- }, ae = {
7
+ }, C = {
8
8
  key: 1,
9
9
  class: "text-danger",
10
10
  "aria-hidden": "true"
11
- }, S = [
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
- ], C = [
20
+ ], oe = [
21
21
  "disabled",
22
22
  "aria-label",
23
23
  "title"
24
- ], oe = ["aria-label"], se = ["title"], ce = [
24
+ ], se = ["aria-label"], ce = ["title"], le = [
25
25
  "aria-label",
26
26
  "title",
27
27
  "onClick",
28
28
  "onKeydown"
29
- ], le = {
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
- }, w = { key: 0 }, T = {
32
+ }, de = { key: 0 }, fe = {
33
33
  class: "sr-only",
34
34
  "aria-live": "polite"
35
- }, E = /*@__PURE__*/ o({
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: E }) {
92
- let D = o, O = v(o, "modelValue"), k = E, A = /[\s,;]+/, ue = /[,\n]+/, j = _(), M = `${j}-hint`, N = `${j}-msg`, P = `${j}-count`, F = `${j}-help`, I = g(), L = t(() => ({
93
- class: I.class,
94
- style: I.style
95
- })), R = t(() => {
96
- let { class: e, style: t, ...n } = I;
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
- }), z = f(null), B = f(null), V = f(""), H = f(""), U = f(!1), W = f(""), G = t(() => O.value ?? []), K = t(() => !D.disabled && !D.readonly), q = t(() => D.maxItems !== void 0 && G.value.length >= D.maxItems), de = t(() => D.maxItems !== void 0 && G.value.length >= D.maxItems * .8), J = t(() => H.value || D.errorMsg), fe = t(() => [
99
- D.hint && M,
100
- J.value && N,
101
- D.maxItems !== void 0 && P,
102
- K.value && F
103
- ].filter(Boolean).join(" ") || void 0), pe = t(() => K.value ? q.value ? `Maximum ${D.maxItems} items reached` : D.placeholder || "Add item and press Enter" : ""), me = t(() => K.value && !q.value && !!V.value.trim());
104
- function Y(e) {
105
- W.value = "", l(() => W.value = e);
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 he(e, t) {
108
- return D.maxItems !== void 0 && t.length >= D.maxItems ? `You can add up to ${D.maxItems} ${D.maxItems === 1 ? "value" : "values"}. Remove one first.` : !D.allowDuplicates && t.includes(e) ? `“${e}” is already added.` : D.validate?.(e, t) || "";
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 X(e, t) {
111
- let n = [...G.value], r = [], i = [], a = "";
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 = D.transform(o);
118
+ let e = T.transform(o);
114
119
  if (!e) continue;
115
- let t = he(e, n);
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 && (O.value = n, r.forEach((e) => k("add", e)), Y(r.length === 1 ? `Added ${r[0]}.` : `Added ${r.length} values.`)), V.value = i.join(", "), l(() => H.value = a), i.length > 0;
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 Z() {
125
- return !K.value || !V.value.trim() ? !1 : X(V.value, ue);
129
+ function X() {
130
+ return !G.value || !z.value.trim() ? !1 : Y(z.value, pe);
126
131
  }
127
- function Q(e, t = !0) {
128
- if (!K.value) return;
129
- let n = G.value[e];
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 = G.value.filter((t, n) => n !== e);
132
- O.value = r, U.value = !1, H.value = "", k("remove", n, e), Y(`Removed ${n}.`), t && l(() => {
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)] ?? z.value)?.focus();
139
+ (t[Math.min(e, t.length - 1)] ?? L.value)?.focus();
135
140
  });
136
141
  }
137
- function ge() {
138
- K.value && G.value.length && (O.value = [], U.value = !1, k("clear"), Y("Removed every value."), z.value?.focus());
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(B.value?.querySelectorAll("[data-remove]") ?? []);
149
+ return Array.from(R.value?.querySelectorAll("[data-remove]") ?? []);
142
150
  }
143
- function _e(e) {
144
- if (!K.value || e.isComposing) return;
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(), Z()) : e.key === "Tab" && !e.shiftKey && V.value.trim() ? Z() : e.key === "Backspace" && !V.value && G.value.length ? (e.preventDefault(), U.value ? Q(G.value.length - 1, !1) : (U.value = !0, Y(`${G.value[G.value.length - 1]} selected. Press Backspace again to remove it.`))) : e.key === "ArrowLeft" && n && G.value.length ? (e.preventDefault(), U.value = !1, $().at(-1)?.focus()) : e.key === "Escape" && (V.value || H.value) ? (e.preventDefault(), V.value = "", H.value = "") : U.value = !1;
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 ve(e, t) {
156
+ function xe(e, t) {
149
157
  let n = $();
150
- e.key === "Backspace" || e.key === "Delete" ? (e.preventDefault(), Q(t)) : e.key === "ArrowLeft" ? (e.preventDefault(), n[Math.max(t - 1, 0)]?.focus()) : e.key === "ArrowRight" ? (e.preventDefault(), (n[t + 1] ?? z.value)?.focus()) : e.key === "Home" ? (e.preventDefault(), n[0]?.focus()) : e.key === "End" && (e.preventDefault(), z.value?.focus());
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 ye(e) {
153
- if (!K.value) return;
160
+ function Se(e) {
161
+ if (!G.value) return;
154
162
  let t = e.clipboardData?.getData("text") ?? "";
155
- if (!A.test(t.trim())) return;
163
+ if (!O.test(t.trim())) return;
156
164
  e.preventDefault();
157
- let n = z.value, r = n?.selectionStart ?? V.value.length, i = n?.selectionEnd ?? V.value.length;
158
- X(V.value.slice(0, r) + t + V.value.slice(i), A);
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 be() {
161
- U.value = !1, D.addOnBlur && Z();
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 xe(e) {
164
- D.disabled || e.target.closest("button") || z.value?.focus();
173
+ function we(e) {
174
+ T.disabled || e.target.closest("button") || L.value?.focus();
165
175
  }
166
- return ee(V, () => {
167
- H.value = "", U.value = !1;
176
+ return x(z, () => {
177
+ B.value = "", V.value = "", H.value = !1;
168
178
  }), s({
169
- focus: () => z.value?.focus(),
170
- commit: () => !Z()
171
- }), (t, s) => (d(), r("div", c(L.value, {
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: h(j),
187
+ for: g(k),
178
188
  class: "mb-2 flex items-center gap-1 text-base font-medium text-heading"
179
189
  }, [
180
- i("span", null, m(o.label), 1),
181
- o.readonly ? (d(), r("span", x, "(read only)")) : n("", !0),
182
- o.required ? (d(), r("span", ae, "*")) : n("", !0)
183
- ], 8, ie),
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: M,
198
+ id: A,
187
199
  class: "mb-2 text-base text-muted"
188
- }, m(o.hint), 1)) : n("", !0),
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
- J.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"]
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: xe
197
- }, [te(i("input", c({
198
- id: h(j),
208
+ onClick: we
209
+ }, [ee(i("input", c({
210
+ id: g(k),
199
211
  ref_key: "input",
200
- ref: z
201
- }, R.value, {
202
- "onUpdate:modelValue": s[0] ||= (e) => V.value = 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: pe.value,
217
+ placeholder: ge.value,
206
218
  disabled: o.disabled,
207
219
  readonly: o.readonly,
208
- "aria-invalid": !!J.value || void 0,
220
+ "aria-invalid": !!q.value || void 0,
209
221
  "aria-required": o.required || void 0,
210
- "aria-describedby": fe.value,
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: _e,
216
- onPaste: ye,
217
- onBlur: be
218
- }), null, 16, S), [[y, V.value]]), i("span", { class: u(["flex shrink-0 items-center text-heading", o.size === "small" ? "mr-1" : "mr-3"]) }, [K.value && o.showClear && G.value.length ? (d(), r("button", {
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: ge
225
- }, [a(h(b), {
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: !me.value,
232
- "aria-label": V.value.trim() ? `Add ${V.value.trim()}` : "Add item",
233
- title: V.value.trim() ? `Add “${V.value.trim()}”` : "Add item",
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] ||= ne(() => {}, ["prevent"]),
236
- onClick: Z
237
- }, [a(h(re), {
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, C)], 2)], 2),
241
- J.value ? (d(), r("p", {
252
+ })], 42, oe)], 2)], 2),
253
+ q.value ? (d(), r("p", {
242
254
  key: 1,
243
- id: N,
255
+ id: j,
244
256
  class: "mt-1 text-base text-danger-strong",
245
257
  role: "alert"
246
- }, m(J.value), 1)) : n("", !0),
247
- G.value.length ? (d(), r("ul", {
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: B,
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(G.value, (e, t) => (d(), r("li", {
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", U.value && t === G.value.length - 1 ? "border-primary bg-accent-active ring-2 ring-ring" : "border-border bg-background"]]),
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
- }, m(e), 9, se), K.value ? (d(), r("button", {
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) => Q(t),
269
- onKeydown: (e) => ve(e, t)
270
- }, [a(h(b), {
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, ce)) : n("", !0)], 2))), 128))], 8, oe)) : n("", !0),
274
- G.value.length || o.maxItems !== void 0 ? (d(), r("div", le, [G.value.length ? (d(), r("span", w, m(G.value.length) + " " + m(G.value.length === 1 ? "item" : "items"), 1)) : n("", !0), o.maxItems === void 0 ? n("", !0) : (d(), r("span", {
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: P,
277
- class: u(["ml-auto", q.value ? "text-danger-strong" : de.value && "text-warning-strong"])
278
- }, m(G.value.length) + " / " + m(o.maxItems) + " items ", 3))])) : n("", !0),
279
- K.value ? (d(), r("p", {
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: F,
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", T, m(W.value), 1)
296
+ i("p", fe, h(U.value), 1)
285
297
  ], 16));
286
298
  }
287
299
  });
288
300
  //#endregion
289
- export { E as default };
301
+ export { w as default };
@@ -0,0 +1,5 @@
1
+ import e from "./AcTaintInput.vue_vue_type_script_setup_true_lang.js";
2
+ //#region src/lib/components/AcTaintInput.vue
3
+ var t = e;
4
+ //#endregion
5
+ export { t 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 };