@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.
Files changed (77) hide show
  1. package/dist/lib/compat.css +421 -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 +25 -13
  7. package/dist/lib/components/AcButton.vue_vue_type_script_setup_true_lang.js +122 -71
  8. package/dist/lib/components/AcCard.vue.d.ts +11 -5
  9. package/dist/lib/components/AcCard.vue_vue_type_script_setup_true_lang.js +99 -51
  10. package/dist/lib/components/AcCellValue.vue.d.ts +3 -3
  11. package/dist/lib/components/AcCellValue.vue_vue_type_script_setup_true_lang.js +20 -20
  12. package/dist/lib/components/AcCheckBox.vue.d.ts +4 -1
  13. package/dist/lib/components/AcCheckBox.vue_vue_type_script_setup_true_lang.js +50 -50
  14. package/dist/lib/components/AcCircularProgress.vue.d.ts +1 -1
  15. package/dist/lib/components/AcCodeEditor.vue.d.ts +12 -0
  16. package/dist/lib/components/AcCodeEditor.vue_vue_type_script_setup_true_lang.js +240 -207
  17. package/dist/lib/components/AcColorInput.vue.d.ts +4 -4
  18. package/dist/lib/components/AcColorInput.vue_vue_type_script_setup_true_lang.js +72 -66
  19. package/dist/lib/components/AcCostSummary.vue.d.ts +1 -1
  20. package/dist/lib/components/AcDatePicker.vue.d.ts +41 -10
  21. package/dist/lib/components/AcDatePicker.vue_vue_type_script_setup_true_lang.js +554 -446
  22. package/dist/lib/components/AcDeleteModal.vue.d.ts +1 -1
  23. package/dist/lib/components/AcDonutChart.vue.d.ts +2 -2
  24. package/dist/lib/components/AcDropdown.vue.d.ts +1 -1
  25. package/dist/lib/components/AcDropdown.vue_vue_type_script_setup_true_lang.js +8 -8
  26. package/dist/lib/components/AcErrorState.vue.d.ts +1 -1
  27. package/dist/lib/components/AcFormFooter.vue_vue_type_script_setup_true_lang.js +8 -8
  28. package/dist/lib/components/AcGraphChart.vue.d.ts +2 -2
  29. package/dist/lib/components/AcHeader.vue.d.ts +1 -1
  30. package/dist/lib/components/AcInput.vue.d.ts +86 -44
  31. package/dist/lib/components/AcInput.vue_vue_type_script_setup_true_lang.js +319 -86
  32. package/dist/lib/components/AcKeyValueInput.vue.d.ts +34 -54
  33. package/dist/lib/components/AcKeyValueInput.vue_vue_type_script_setup_true_lang.js +134 -106
  34. package/dist/lib/components/AcLineChart.vue.d.ts +1 -1
  35. package/dist/lib/components/AcLocaleSwitcher.vue.d.ts +6 -0
  36. package/dist/lib/components/AcLocaleSwitcher.vue_vue_type_script_setup_true_lang.js +74 -58
  37. package/dist/lib/components/AcMapChart.vue.d.ts +2 -2
  38. package/dist/lib/components/AcModal.vue.d.ts +1 -1
  39. package/dist/lib/components/AcNavbar.vue.d.ts +2 -0
  40. package/dist/lib/components/AcNavbar.vue_vue_type_script_setup_true_lang.js +31 -25
  41. package/dist/lib/components/AcNotificationMenu.vue.d.ts +1 -1
  42. package/dist/lib/components/AcNotificationMenu.vue_vue_type_script_setup_true_lang.js +24 -24
  43. package/dist/lib/components/AcNumberInput.vue.d.ts +55 -45
  44. package/dist/lib/components/AcNumberInput.vue_vue_type_script_setup_true_lang.js +159 -99
  45. package/dist/lib/components/AcRadioCard.js +5 -0
  46. package/dist/lib/components/AcRadioCard.vue.d.ts +55 -0
  47. package/dist/lib/components/AcRadioCard.vue_vue_type_script_setup_true_lang.js +135 -0
  48. package/dist/lib/components/AcSelect.vue.d.ts +46 -6
  49. package/dist/lib/components/AcSelect.vue_vue_type_script_setup_true_lang.js +309 -197
  50. package/dist/lib/components/AcSidePanel.vue.d.ts +1 -1
  51. package/dist/lib/components/AcSidebar.vue.d.ts +9 -0
  52. package/dist/lib/components/AcSidebar.vue_vue_type_script_setup_true_lang.js +113 -94
  53. package/dist/lib/components/AcSidebarSection.vue_vue_type_script_setup_true_lang.js +19 -18
  54. package/dist/lib/components/AcSlider.vue.d.ts +2 -2
  55. package/dist/lib/components/AcSwitch.vue_vue_type_script_setup_true_lang.js +23 -23
  56. package/dist/lib/components/AcTable.vue.d.ts +50 -5
  57. package/dist/lib/components/AcTable.vue_vue_type_script_setup_true_lang.js +257 -129
  58. package/dist/lib/components/AcTagInput.vue.d.ts +23 -4
  59. package/dist/lib/components/AcTagInput.vue_vue_type_script_setup_true_lang.js +126 -114
  60. package/dist/lib/components/AcTaintInput.js +5 -0
  61. package/dist/lib/components/AcTaintInput.vue.d.ts +44 -0
  62. package/dist/lib/components/AcTaintInput.vue_vue_type_script_setup_true_lang.js +208 -0
  63. package/dist/lib/components/AcTextarea.vue.d.ts +64 -4
  64. package/dist/lib/components/AcTextarea.vue_vue_type_script_setup_true_lang.js +159 -68
  65. package/dist/lib/components/AcThemeMode.vue.d.ts +10 -2
  66. package/dist/lib/components/AcThemeMode.vue_vue_type_script_setup_true_lang.js +53 -42
  67. package/dist/lib/components/AcTimePicker.vue.d.ts +36 -11
  68. package/dist/lib/components/AcTimePicker.vue_vue_type_script_setup_true_lang.js +232 -168
  69. package/dist/lib/components/AcTooltip.vue.d.ts +3 -3
  70. package/dist/lib/components/AcUserMenu.vue.d.ts +8 -0
  71. package/dist/lib/components/AcUserMenu.vue_vue_type_script_setup_true_lang.js +126 -109
  72. package/dist/lib/components/index.d.ts +2 -0
  73. package/dist/lib/components/types.d.ts +2 -0
  74. package/dist/lib/composables/useToast.d.ts +2 -2
  75. package/dist/lib/index.d.ts +2 -1
  76. package/dist/lib/index.js +51 -49
  77. package/package.json +1 -1
@@ -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 };
@@ -1,8 +1,11 @@
1
+ import type { HTMLAttributes } from "vue";
1
2
  export interface Props {
2
- /** Label above the field. Pass `placeholder` for an example value inside it. */
3
- label: string;
3
+ /** Label above the field. Pass `placeholder` for an example value inside it. Without a label, pass `aria-label`; the placeholder is the accessible name otherwise. */
4
+ label?: string;
4
5
  /** Native `name` attribute. */
5
6
  name?: string;
7
+ /** Example value shown inside the empty field. */
8
+ placeholder?: string;
6
9
  /** Visible height in lines. Unset, the field is 160px tall (about 6 lines). With `autoResize` it's the starting (minimum) height. */
7
10
  rows?: number;
8
11
  /** Grows the field with its content instead of showing a scrollbar. */
@@ -15,39 +18,96 @@ export interface Props {
15
18
  mono?: boolean;
16
19
  /** Marks the field required and adds a red asterisk. */
17
20
  required?: boolean;
21
+ /** Adds the red asterisk without native `required`, for forms that run their own validation on submit. */
22
+ requiredMark?: boolean;
18
23
  /** Disables the field. */
19
24
  disabled?: boolean;
20
25
  /** Read-only field: a muted fill, and "(read only)" after the label. */
21
26
  readonly?: boolean;
27
+ /** Text after the label of a read-only field, e.g. "(Read Only)". */
28
+ readonlyText?: string;
29
+ /** Cloud-ui v1 error look: no field fill while it shows an error, and the message in the base `text-danger` red instead of the AA `-strong` shade. */
30
+ plainError?: boolean;
31
+ /** No gap around `#label-icon` and `#label-extra`, for slot content that brings its own margin. */
32
+ flushLabelSlots?: boolean;
22
33
  /** Error text under the field. Turns the border and label red and sets `aria-invalid`. */
23
34
  errorMsg?: string;
35
+ /** Turns the border red and sets `aria-invalid` without a message, for forms that print their own. */
36
+ invalid?: boolean;
24
37
  /** Help text between the label and the field. */
25
38
  hint?: string;
39
+ /** Error shown under the field when the viewer clears it or leaves it empty, e.g. "Please enter a description". `error-msg` shows when this one doesn't. */
40
+ requiredMessage?: string;
41
+ /** With `required-message`, an empty field emits no `input` or `focusout`, as cloud-ui's v1 AcInput did. */
42
+ silentWhenEmpty?: boolean;
43
+ /** Inner spacing: `xs` 8px × 4px with 12px text, `xsmall` 12px × 6px, `small` 16px × 8px, `medium` 16px × 8px, `normal` 20px × 10px or `large` 24px × 12px with 16px text. Without `rows` or a height in `input-class`, `xs` is 60px tall, `medium` 120px, `large` 240px and the rest at least 160px. */
44
+ size?: "xs" | "xsmall" | "small" | "medium" | "normal" | "large";
45
+ /** Field look: `outline` (border on the page fill), `soft` (grey fill, no border), `ghost` (no fill or border until focus) or `none` (bare text, no border or focus style). */
46
+ variant?: "outline" | "soft" | "ghost" | "none";
47
+ /** Draws a 2px primary halo around the field to point the viewer at it. */
48
+ highlight?: boolean;
49
+ /** Classes for the `<textarea>` element itself, e.g. `h-30` for a fixed 120px height; they replace the 160px default height. `class` goes on the wrapper. */
50
+ inputClass?: HTMLAttributes["class"];
26
51
  }
27
52
  type __VLS_Props = Props;
53
+ type __VLS_Slots = {
54
+ /** Content before the label text, such as a 14px icon. */
55
+ "label-icon"?: () => unknown;
56
+ /** Content after the label text, such as "(Optional)" or an info tooltip. */
57
+ "label-extra"?: () => unknown;
58
+ };
28
59
  type __VLS_ModelProps = {
29
60
  modelValue?: string;
30
61
  };
31
62
  type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
32
- declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {
63
+ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {
33
64
  /** Moves focus to the textarea. */
34
65
  focus: () => void | undefined;
35
66
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
67
+ input: (event: Event) => any;
36
68
  "update:modelValue": (value: string) => any;
69
+ blur: (event: FocusEvent) => any;
70
+ change: (event: Event) => any;
71
+ focus: (event: FocusEvent) => any;
72
+ focusout: (event: FocusEvent) => any;
37
73
  }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
74
+ onInput?: ((event: Event) => any) | undefined;
38
75
  "onUpdate:modelValue"?: ((value: string) => any) | undefined;
76
+ onBlur?: ((event: FocusEvent) => any) | undefined;
77
+ onChange?: ((event: Event) => any) | undefined;
78
+ onFocus?: ((event: FocusEvent) => any) | undefined;
79
+ onFocusout?: ((event: FocusEvent) => any) | undefined;
39
80
  }>, {
81
+ variant: "outline" | "soft" | "ghost" | "none";
40
82
  required: boolean;
83
+ label: string;
41
84
  disabled: boolean;
42
85
  name: string;
86
+ size: "xs" | "xsmall" | "small" | "medium" | "normal" | "large";
87
+ invalid: boolean;
88
+ hint: string;
43
89
  rows: number;
44
90
  readonly: boolean;
45
- hint: string;
91
+ placeholder: string;
46
92
  errorMsg: string;
93
+ highlight: boolean;
47
94
  mono: boolean;
48
95
  maxlength: number;
96
+ requiredMark: boolean;
97
+ requiredMessage: string;
98
+ silentWhenEmpty: boolean;
99
+ readonlyText: string;
100
+ plainError: boolean;
101
+ flushLabelSlots: boolean;
102
+ inputClass: string | false | Record<string, any> | import("vue").ClassValue[] | null;
49
103
  autoResize: boolean;
50
104
  maxRows: number;
51
105
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
106
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
52
107
  declare const _default: typeof __VLS_export;
53
108
  export default _default;
109
+ type __VLS_WithSlots<T, S> = T & {
110
+ new (): {
111
+ $slots: S;
112
+ };
113
+ };
@@ -1,34 +1,30 @@
1
- import { computed as e, createCommentVNode as t, createElementBlock as n, createElementVNode as r, createTextVNode as i, defineComponent as a, mergeModels as o, mergeProps as s, nextTick as c, normalizeClass as l, onMounted as u, openBlock as d, ref as f, toDisplayString as p, unref as m, useAttrs as h, useId as g, useModel as _, vModelText as v, watch as y, withDirectives as b } from "vue";
1
+ import { computed as e, createCommentVNode as t, createElementBlock as n, createElementVNode as r, createTextVNode as i, defineComponent as a, mergeModels as o, mergeProps as s, nextTick as c, normalizeClass as l, onMounted as u, openBlock as d, ref as f, renderSlot as p, toDisplayString as m, unref as h, useAttrs as g, useId as _, useModel as v, useSlots as y, vModelText as b, watch as x, withDirectives as S } from "vue";
2
2
  //#region src/lib/components/AcTextarea.vue?vue&type=script&setup=true&lang.ts
3
- var x = ["for"], S = {
4
- key: 0,
5
- class: "text-muted"
6
- }, C = {
7
- key: 1,
8
- class: "text-danger",
9
- "aria-hidden": "true"
10
- }, w = ["id"], T = [
3
+ var ee = ["for"], C = { key: 0 }, w = ["id"], T = [
11
4
  "id",
12
5
  "name",
6
+ "placeholder",
13
7
  "rows",
14
8
  "maxlength",
15
9
  "disabled",
16
10
  "readonly",
17
11
  "required",
12
+ "aria-label",
18
13
  "aria-invalid",
19
14
  "aria-describedby"
20
15
  ], E = {
21
- key: 1,
16
+ key: 2,
22
17
  class: "mt-1 flex items-start gap-3"
23
- }, D = ["id"], O = {
18
+ }, te = ["id"], ne = {
24
19
  key: 1,
25
20
  class: "flex-1"
26
- }, k = ["id"], A = /*@__PURE__*/ a({
21
+ }, D = ["id"], O = "focus:shadow-[0_0_0_2px_color-mix(in_srgb,var(--color-danger)_20%,transparent)]", k = "focus:shadow-[0_0_0_2px_color-mix(in_srgb,var(--color-primary)_20%,transparent)]", A = /*@__PURE__*/ a({
27
22
  inheritAttrs: !1,
28
23
  __name: "AcTextarea",
29
24
  props: /*@__PURE__*/ o({
30
- label: {},
25
+ label: { default: "" },
31
26
  name: { default: "" },
27
+ placeholder: { default: void 0 },
32
28
  rows: { default: void 0 },
33
29
  autoResize: {
34
30
  type: Boolean,
@@ -44,6 +40,10 @@ var x = ["for"], S = {
44
40
  type: Boolean,
45
41
  default: !1
46
42
  },
43
+ requiredMark: {
44
+ type: Boolean,
45
+ default: !1
46
+ },
47
47
  disabled: {
48
48
  type: Boolean,
49
49
  default: !1
@@ -52,89 +52,180 @@ var x = ["for"], S = {
52
52
  type: Boolean,
53
53
  default: !1
54
54
  },
55
+ readonlyText: { default: "(read only)" },
56
+ plainError: {
57
+ type: Boolean,
58
+ default: !1
59
+ },
60
+ flushLabelSlots: {
61
+ type: Boolean,
62
+ default: !1
63
+ },
55
64
  errorMsg: { default: "" },
56
- hint: { default: "" }
65
+ invalid: {
66
+ type: Boolean,
67
+ default: !1
68
+ },
69
+ hint: { default: "" },
70
+ requiredMessage: { default: "" },
71
+ silentWhenEmpty: {
72
+ type: Boolean,
73
+ default: !1
74
+ },
75
+ size: { default: "normal" },
76
+ variant: { default: "outline" },
77
+ highlight: {
78
+ type: Boolean,
79
+ default: !1
80
+ },
81
+ inputClass: {
82
+ type: [
83
+ Boolean,
84
+ null,
85
+ String,
86
+ Object,
87
+ Array
88
+ ],
89
+ default: void 0
90
+ }
57
91
  }, {
58
92
  modelValue: { default: "" },
59
93
  modelModifiers: {}
60
94
  }),
61
- emits: ["update:modelValue"],
62
- setup(a, { expose: o }) {
63
- let A = a, j = _(a, "modelValue"), M = g(), N = h(), P = e(() => ({
64
- class: N.class,
65
- style: N.style
66
- })), F = e(() => {
67
- let { class: e, style: t, ...n } = N;
95
+ emits: /*@__PURE__*/ o([
96
+ "focus",
97
+ "blur",
98
+ "focusout",
99
+ "input",
100
+ "change"
101
+ ], ["update:modelValue"]),
102
+ setup(a, { expose: o, emit: A }) {
103
+ let j = a, M = v(a, "modelValue"), N = A, P = {
104
+ xs: "px-2 py-1 text-xs",
105
+ xsmall: "px-3 py-1.5 text-base",
106
+ small: "px-4 py-2 text-base",
107
+ medium: "px-4 py-2 text-base",
108
+ normal: "px-5 py-2.5 text-base",
109
+ large: "px-6 py-3 text-lg"
110
+ }, F = {
111
+ xs: "h-15",
112
+ xsmall: "min-h-40",
113
+ small: "min-h-40",
114
+ medium: "h-30",
115
+ normal: "min-h-40",
116
+ large: "h-60"
117
+ }, I = _(), L = g(), R = y(), z = e(() => ({
118
+ class: L.class,
119
+ style: L.style
120
+ })), B = e(() => {
121
+ let { class: e, style: t, ...n } = L;
68
122
  return n;
69
- }), I = f(null), L = f(!1), R = e(() => A.rows ?? 4), z = e(() => (j.value ?? "").length), B = e(() => A.maxlength !== void 0 && z.value >= A.maxlength), V = e(() => [
70
- A.hint && `${M}-hint`,
71
- A.errorMsg && `${M}-msg`,
72
- A.maxlength !== void 0 && `${M}-count`
123
+ }), V = f(null), H = f(!1), U = e(() => !!j.label || !!R["label-icon"] || !!R["label-extra"]), W = e(() => U.value ? void 0 : L["aria-label"] ?? j.placeholder), G = f(""), K = e(() => G.value || j.errorMsg), q = e(() => !!K.value || j.invalid), J = e(() => j.size in P ? j.size : "normal"), Y = e(() => {
124
+ let e = !j.disabled;
125
+ return j.variant === "soft" ? q.value ? `border-transparent bg-danger/5 focus:bg-danger/10 ${O}` : [
126
+ "border-transparent bg-accent focus:bg-accent-hover",
127
+ k,
128
+ e && "hover:bg-accent-hover"
129
+ ] : j.variant === "ghost" ? q.value ? `border-transparent bg-transparent focus:bg-danger/5 ${O}` : `border-transparent bg-transparent focus:bg-accent-hover ${k}` : j.variant === "none" ? ["border-transparent bg-transparent", q.value && "text-danger-strong"] : [q.value && j.plainError ? "bg-transparent" : j.readonly ? "bg-surface-muted" : "bg-background", q.value ? `border-danger/50 focus:border-danger ${O}` : ["border-border focus:focus-ring", e && "hover:border-accent-active"]];
130
+ }), X = e(() => j.rows ?? 4), Z = e(() => (M.value ?? "").length), re = e(() => j.maxlength !== void 0 && Z.value >= j.maxlength), ie = e(() => [
131
+ L["aria-describedby"],
132
+ j.hint && `${I}-hint`,
133
+ K.value && `${I}-msg`,
134
+ j.maxlength !== void 0 && `${I}-count`
73
135
  ].filter(Boolean).join(" ") || void 0);
74
- function H() {
75
- let e = I.value;
76
- if (!e || !A.autoResize) return;
77
- let t = getComputedStyle(e), n = parseFloat(t.lineHeight) || 20, r = parseFloat(t.paddingTop) + parseFloat(t.paddingBottom) + parseFloat(t.borderTopWidth) + parseFloat(t.borderBottomWidth), i = R.value * n + r, a = A.maxRows > 0 ? A.maxRows * n + r : Infinity;
136
+ function Q(e) {
137
+ j.requiredMessage && (G.value = e.target.value === "" ? j.requiredMessage : "");
138
+ }
139
+ function ae(e) {
140
+ Q(e), j.silentWhenEmpty && G.value || N("input", e);
141
+ }
142
+ function oe(e) {
143
+ Q(e), j.silentWhenEmpty && G.value || N("focusout", e);
144
+ }
145
+ function $() {
146
+ let e = V.value;
147
+ if (!e || !j.autoResize) return;
148
+ let t = getComputedStyle(e), n = parseFloat(t.lineHeight) || 20, r = parseFloat(t.paddingTop) + parseFloat(t.paddingBottom) + parseFloat(t.borderTopWidth) + parseFloat(t.borderBottomWidth), i = X.value * n + r, a = j.maxRows > 0 ? j.maxRows * n + r : Infinity;
78
149
  e.style.height = "auto";
79
150
  let o = e.scrollHeight + parseFloat(t.borderTopWidth) + parseFloat(t.borderBottomWidth);
80
- e.style.height = `${Math.min(Math.max(o, i), a)}px`, L.value = o > a;
151
+ e.style.height = `${Math.min(Math.max(o, i), a)}px`, H.value = o > a;
81
152
  }
82
- return y(j, () => c(H)), y(() => [
83
- A.autoResize,
84
- A.rows,
85
- A.maxRows
153
+ return x(M, () => c($)), x(() => [
154
+ j.autoResize,
155
+ j.rows,
156
+ j.maxRows
86
157
  ], () => {
87
- !A.autoResize && I.value && (I.value.style.height = ""), c(H);
88
- }), u(H), o({ focus: () => I.value?.focus() }), (e, o) => (d(), n("div", s(P.value, {
158
+ !j.autoResize && V.value && (V.value.style.height = ""), c($);
159
+ }), u($), o({ focus: () => V.value?.focus() }), (e, o) => (d(), n("div", s(z.value, {
89
160
  class: ["w-full", a.disabled && "opacity-50"],
90
161
  "data-ac-ds": "",
91
162
  "data-testid": "ac-textarea"
92
163
  }), [
93
- r("label", {
94
- for: m(M),
95
- class: "mb-2 flex items-center gap-1 text-base font-medium text-heading"
164
+ U.value ? (d(), n("label", {
165
+ key: 0,
166
+ for: h(I),
167
+ class: l(["mb-2 flex items-center text-base font-medium text-heading", !a.flushLabelSlots && "gap-1"])
96
168
  }, [
97
- r("span", null, p(a.label), 1),
98
- a.readonly ? (d(), n("span", S, "(read only)")) : t("", !0),
99
- a.required ? (d(), n("span", C, "*")) : t("", !0)
100
- ], 8, x),
169
+ p(e.$slots, "label-icon"),
170
+ a.label ? (d(), n("span", C, m(a.label), 1)) : t("", !0),
171
+ a.readonly ? (d(), n("span", {
172
+ key: 1,
173
+ class: l(["text-muted", a.flushLabelSlots && "ml-1"])
174
+ }, m(a.readonlyText), 3)) : t("", !0),
175
+ p(e.$slots, "label-extra"),
176
+ a.required || a.requiredMark ? (d(), n("span", {
177
+ key: 2,
178
+ class: l(["text-danger", a.flushLabelSlots && "ml-1"]),
179
+ "aria-hidden": "true"
180
+ }, "*", 2)) : t("", !0)
181
+ ], 10, ee)) : t("", !0),
101
182
  a.hint ? (d(), n("p", {
102
- key: 0,
103
- id: `${m(M)}-hint`,
183
+ key: 1,
184
+ id: `${h(I)}-hint`,
104
185
  class: "mb-2 text-base text-muted"
105
- }, p(a.hint), 9, w)) : t("", !0),
106
- b(r("textarea", s({
107
- id: m(M),
186
+ }, m(a.hint), 9, w)) : t("", !0),
187
+ S(r("textarea", s({
188
+ id: h(I),
108
189
  ref_key: "field",
109
- ref: I
110
- }, F.value, {
111
- "onUpdate:modelValue": o[0] ||= (e) => j.value = e,
190
+ ref: V
191
+ }, B.value, {
192
+ "onUpdate:modelValue": o[0] ||= (e) => M.value = e,
112
193
  name: a.name,
113
- rows: R.value,
194
+ placeholder: a.placeholder,
195
+ rows: X.value,
114
196
  maxlength: a.maxlength,
115
197
  disabled: a.disabled,
116
198
  readonly: a.readonly,
117
199
  required: a.required,
118
- "aria-invalid": !!a.errorMsg || void 0,
119
- "aria-describedby": V.value,
120
- class: ["block w-full rounded-10 border px-5 py-2.5 text-base text-heading transition-[color,background-color,border-color,box-shadow] duration-200 outline-none placeholder:text-muted/80 disabled:cursor-not-allowed", [
121
- a.readonly ? "bg-surface-muted" : "bg-background",
122
- a.rows === void 0 && "min-h-40",
200
+ "aria-label": W.value,
201
+ "aria-invalid": q.value || void 0,
202
+ "aria-describedby": ie.value,
203
+ class: ["block w-full rounded-10 border text-heading transition-[color,background-color,border-color,box-shadow] duration-200 outline-none placeholder:text-muted/80 disabled:cursor-not-allowed", [
204
+ P[J.value],
205
+ a.rows === void 0 && !a.inputClass && !a.autoResize && F[J.value],
206
+ a.rows === void 0 && !a.inputClass && a.autoResize && "min-h-40",
123
207
  a.mono ? "font-mono text-xs leading-5 font-normal" : "font-medium",
124
- a.autoResize ? L.value ? "ac-scrollbar resize-none" : "resize-none overflow-hidden" : "ac-scrollbar resize-y",
125
- a.errorMsg ? "border-danger/50 focus:border-danger focus:shadow-[0_0_0_2px_color-mix(in_srgb,var(--color-danger)_20%,transparent)]" : ["border-border focus:focus-ring", !a.disabled && "hover:border-accent-active"]
126
- ]]
127
- }), null, 16, T), [[v, j.value]]),
128
- a.errorMsg || a.maxlength !== void 0 ? (d(), n("div", E, [a.errorMsg ? (d(), n("p", {
208
+ a.autoResize ? H.value ? "ac-scrollbar resize-none" : "resize-none overflow-hidden" : "ac-scrollbar resize-y",
209
+ Y.value,
210
+ a.highlight && "ring-2 ring-primary/20 ring-offset-2 ring-offset-surface",
211
+ a.inputClass
212
+ ]],
213
+ onInput: ae,
214
+ onFocusout: oe,
215
+ onFocus: o[1] ||= (e) => N("focus", e),
216
+ onBlur: o[2] ||= (e) => N("blur", e),
217
+ onChange: o[3] ||= (e) => N("change", e)
218
+ }), null, 16, T), [[b, M.value]]),
219
+ K.value || a.maxlength !== void 0 ? (d(), n("div", E, [K.value ? (d(), n("p", {
129
220
  key: 0,
130
- id: `${m(M)}-msg`,
131
- class: "min-w-0 flex-1 text-base text-danger-strong",
221
+ id: `${h(I)}-msg`,
222
+ class: l(["min-w-0 flex-1 text-base", a.plainError ? "text-danger" : "text-danger-strong"]),
132
223
  role: "alert"
133
- }, p(a.errorMsg), 9, D)) : (d(), n("span", O)), a.maxlength === void 0 ? t("", !0) : (d(), n("p", {
224
+ }, m(K.value), 11, te)) : (d(), n("span", ne)), a.maxlength === void 0 ? t("", !0) : (d(), n("p", {
134
225
  key: 2,
135
- id: `${m(M)}-count`,
136
- class: l(["shrink-0 text-xs tabular-nums", B.value ? "font-medium text-danger-strong" : "text-muted"])
137
- }, [o[1] ||= r("span", { class: "sr-only" }, "Characters used: ", -1), i(p(z.value) + " / " + p(a.maxlength), 1)], 10, k))])) : t("", !0)
226
+ id: `${h(I)}-count`,
227
+ class: l(["shrink-0 text-xs tabular-nums", re.value ? "font-medium text-danger-strong" : "text-muted"])
228
+ }, [o[4] ||= r("span", { class: "sr-only" }, "Characters used: ", -1), i(m(Z.value) + " / " + m(a.maxlength), 1)], 10, D))])) : t("", !0)
138
229
  ], 16));
139
230
  }
140
231
  });
@@ -5,10 +5,18 @@ export interface Props {
5
5
  /** `icons` is a compact 3-icon switch; `labels` adds the words, for menus and settings pages; `toggle` is cloud-ui's sun/moon switch for the navbar (64×32px), light or dark only. */
6
6
  display?: "icons" | "labels" | "toggle";
7
7
  }
8
- declare const __VLS_export: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
8
+ type __VLS_Props = Props;
9
+ type __VLS_ModelProps = {
10
+ /** The theme as a boolean, for apps that keep it in their own store (e.g. cloud-ui's VueUse `useDark`). When bound, the switch only reads and writes this value and leaves the `dark` class and localStorage to the app. */
11
+ "dark"?: boolean | undefined;
12
+ };
13
+ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
14
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
9
15
  "set:theme": (theme: "light" | "dark") => any;
10
- }, string, import("vue").PublicProps, Readonly<Props> & Readonly<{
16
+ "update:dark": (value: boolean | undefined) => any;
17
+ }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
11
18
  "onSet:theme"?: ((theme: "light" | "dark") => any) | undefined;
19
+ "onUpdate:dark"?: ((value: boolean | undefined) => any) | undefined;
12
20
  }>, {
13
21
  display: "icons" | "labels" | "toggle";
14
22
  defaultMode: ColorMode;