@m3ui-vue/m3ui-vue 1.5.0 → 1.5.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/API.md +1 -1
- package/dist/{MTextField-B72dwF6V.js → MTextField-BRntFeNR.js} +112 -78
- package/dist/MTextField-BRntFeNR.js.map +1 -0
- package/dist/api.json +1 -1
- package/dist/composables/_fieldLayout.d.ts +47 -0
- package/dist/m3ui-vue.css +1 -1
- package/dist/m3ui.js +3941 -3958
- package/dist/m3ui.js.map +1 -1
- package/dist/map.js +1 -1
- package/dist/pdf.js +1 -1
- package/dist/rich-text-editor.js +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/src/__tests__/fieldOverflow.test.ts +118 -0
- package/src/components/MAutocomplete.vue +21 -24
- package/src/components/MColorPicker.vue +3 -3
- package/src/components/MDatePicker.vue +4 -4
- package/src/components/MDateRangePicker.vue +4 -4
- package/src/components/MMaskField.vue +16 -24
- package/src/components/MMultiAutocomplete.vue +19 -25
- package/src/components/MMultiSelect.vue +20 -27
- package/src/components/MNumberField.vue +16 -26
- package/src/components/MPinInput.vue +3 -2
- package/src/components/MSearchBar.vue +2 -2
- package/src/components/MSelect.vue +16 -22
- package/src/components/MTagInput.vue +19 -26
- package/src/components/MTextField.vue +18 -46
- package/src/components/MTimePicker.vue +4 -4
- package/src/composables/_fieldLayout.ts +117 -0
- package/dist/MTextField-B72dwF6V.js.map +0 -1
package/dist/API.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { i as e } from "./useLocale-DLcG3qPC.js";
|
|
2
2
|
import { t } from "./MIcon-Bxh9j135.js";
|
|
3
|
-
import { computed as n, createCommentVNode as r, createElementBlock as i, createElementVNode as a, createTextVNode as o, createVNode as s, defineComponent as c, getCurrentInstance as l, normalizeClass as u, normalizeStyle as d, onBeforeUnmount as f, onMounted as p, openBlock as m, ref as h, renderSlot as g, toDisplayString as _, toValue as v, unref as y, useId as b, useSlots as x, watch as S } from "vue";
|
|
3
|
+
import { computed as n, createCommentVNode as r, createElementBlock as i, createElementVNode as a, createTextVNode as o, createVNode as s, defineComponent as c, getCurrentInstance as l, normalizeClass as u, normalizeStyle as d, onBeforeUnmount as f, onMounted as p, openBlock as m, ref as h, renderSlot as g, toDisplayString as _, toValue as v, unref as y, useId as b, useSlots as x, watch as S, withDirectives as C } from "vue";
|
|
4
4
|
//#region src/composables/useFieldBg.ts
|
|
5
|
-
var
|
|
5
|
+
var w = [
|
|
6
6
|
"bg-surface-container-highest",
|
|
7
7
|
"bg-surface-container-high",
|
|
8
8
|
"bg-surface-container-low",
|
|
@@ -29,11 +29,11 @@ var C = [
|
|
|
29
29
|
"bg-tertiary",
|
|
30
30
|
"bg-error"
|
|
31
31
|
];
|
|
32
|
-
function
|
|
33
|
-
for (let t of
|
|
32
|
+
function T(e) {
|
|
33
|
+
for (let t of w) if (e.classList.contains(t)) return `var(--color-${t.slice(3)})`;
|
|
34
34
|
return null;
|
|
35
35
|
}
|
|
36
|
-
function
|
|
36
|
+
function E(e) {
|
|
37
37
|
if (!e || e === "transparent") return !0;
|
|
38
38
|
let t = e.match(/^rgba?\(([^)]+)\)$/);
|
|
39
39
|
if (t) {
|
|
@@ -42,7 +42,7 @@ function T(e) {
|
|
|
42
42
|
}
|
|
43
43
|
return !1;
|
|
44
44
|
}
|
|
45
|
-
function
|
|
45
|
+
function D(e, t) {
|
|
46
46
|
let r = h("var(--color-surface)");
|
|
47
47
|
function i(n) {
|
|
48
48
|
r.value = n, e.value?.style.setProperty("--field-bg", t() ?? n);
|
|
@@ -50,7 +50,7 @@ function E(e, t) {
|
|
|
50
50
|
function a() {
|
|
51
51
|
let t = e.value?.parentElement ?? null;
|
|
52
52
|
for (; t;) {
|
|
53
|
-
let e =
|
|
53
|
+
let e = T(t);
|
|
54
54
|
if (e) {
|
|
55
55
|
i(e);
|
|
56
56
|
return;
|
|
@@ -60,7 +60,7 @@ function E(e, t) {
|
|
|
60
60
|
return;
|
|
61
61
|
}
|
|
62
62
|
let n = getComputedStyle(t).backgroundColor;
|
|
63
|
-
if (!
|
|
63
|
+
if (!E(n)) {
|
|
64
64
|
i(n);
|
|
65
65
|
return;
|
|
66
66
|
}
|
|
@@ -82,7 +82,7 @@ function E(e, t) {
|
|
|
82
82
|
}
|
|
83
83
|
//#endregion
|
|
84
84
|
//#region src/composables/useAutoGrow.ts
|
|
85
|
-
function
|
|
85
|
+
function O(e, t = {}) {
|
|
86
86
|
let n = null, r = null, i = 0;
|
|
87
87
|
function a() {
|
|
88
88
|
if (!n) return;
|
|
@@ -104,7 +104,7 @@ function D(e, t = {}) {
|
|
|
104
104
|
}
|
|
105
105
|
//#endregion
|
|
106
106
|
//#region src/composables/useDebounce.ts
|
|
107
|
-
function
|
|
107
|
+
function k(e, t) {
|
|
108
108
|
let n = null;
|
|
109
109
|
function r(...r) {
|
|
110
110
|
n && clearTimeout(n), n = setTimeout(() => {
|
|
@@ -120,33 +120,82 @@ function O(e, t) {
|
|
|
120
120
|
};
|
|
121
121
|
}
|
|
122
122
|
//#endregion
|
|
123
|
-
//#region src/
|
|
124
|
-
var
|
|
123
|
+
//#region src/composables/_fieldLayout.ts
|
|
124
|
+
var A = {
|
|
125
|
+
"right-4": "pr-4",
|
|
126
|
+
"right-10": "pr-10",
|
|
127
|
+
"right-12": "pr-12",
|
|
128
|
+
"right-16": "pr-16",
|
|
129
|
+
"right-24": "pr-24"
|
|
130
|
+
}, j = "block min-w-0 flex-1 truncate";
|
|
131
|
+
function M(e) {
|
|
132
|
+
let t = e.variant === "outlined", n = [
|
|
133
|
+
"pointer-events-none absolute truncate transition-all duration-200",
|
|
134
|
+
e.leading ? t ? "left-11" : "left-12" : t ? "left-3" : "left-4",
|
|
135
|
+
e.right
|
|
136
|
+
], r = t ? "top-1/2 -translate-y-1/2 text-body-large" : "top-[53%] -translate-y-1/2 text-body-large";
|
|
137
|
+
if (e.floated === "peer") {
|
|
138
|
+
let i = t ? e.leading ? "peer-focus:-top-2.5 peer-focus:translate-y-0 peer-focus:text-label-small peer-focus:right-auto peer-focus:max-w-[calc(100%-3.5rem)] peer-focus:bg-[var(--field-bg)] peer-focus:px-1 peer-[&:not(:placeholder-shown)]:-top-2.5 peer-[&:not(:placeholder-shown)]:translate-y-0 peer-[&:not(:placeholder-shown)]:text-label-small peer-[&:not(:placeholder-shown)]:right-auto peer-[&:not(:placeholder-shown)]:max-w-[calc(100%-3.5rem)] peer-[&:not(:placeholder-shown)]:bg-[var(--field-bg)] peer-[&:not(:placeholder-shown)]:px-1" : "peer-focus:-top-2.5 peer-focus:translate-y-0 peer-focus:text-label-small peer-focus:right-auto peer-focus:max-w-[calc(100%-1.5rem)] peer-focus:bg-[var(--field-bg)] peer-focus:px-1 peer-[&:not(:placeholder-shown)]:-top-2.5 peer-[&:not(:placeholder-shown)]:translate-y-0 peer-[&:not(:placeholder-shown)]:text-label-small peer-[&:not(:placeholder-shown)]:right-auto peer-[&:not(:placeholder-shown)]:max-w-[calc(100%-1.5rem)] peer-[&:not(:placeholder-shown)]:bg-[var(--field-bg)] peer-[&:not(:placeholder-shown)]:px-1" : "peer-focus:top-2 peer-focus:translate-y-0 peer-focus:text-label-small peer-[&:not(:placeholder-shown)]:top-2 peer-[&:not(:placeholder-shown)]:translate-y-0 peer-[&:not(:placeholder-shown)]:text-label-small";
|
|
139
|
+
return [
|
|
140
|
+
...n,
|
|
141
|
+
r,
|
|
142
|
+
i,
|
|
143
|
+
e.color
|
|
144
|
+
].join(" ");
|
|
145
|
+
}
|
|
146
|
+
let i = t ? `-top-2.5 translate-y-0 text-label-small bg-[var(--field-bg)] px-1 right-auto ${e.leading ? "max-w-[calc(100%-3.5rem)]" : "max-w-[calc(100%-1.5rem)]"}` : "top-2 translate-y-0 text-label-small";
|
|
147
|
+
return [
|
|
148
|
+
...n,
|
|
149
|
+
e.floated ? i : r,
|
|
150
|
+
e.color
|
|
151
|
+
].join(" ");
|
|
152
|
+
}
|
|
153
|
+
var N = "pointer-events-none absolute -top-2.5 left-3 max-w-[calc(100%-1.5rem)] truncate bg-(--field-bg) px-1 text-label-small";
|
|
154
|
+
function P(e) {
|
|
155
|
+
return e.tagName === "INPUT" || e.tagName === "TEXTAREA" ? e.value : (e.textContent ?? "").trim();
|
|
156
|
+
}
|
|
157
|
+
function F(e) {
|
|
158
|
+
let t = e.scrollWidth > e.clientWidth ? P(e) : "";
|
|
159
|
+
t ? e.title = t : e.removeAttribute("title");
|
|
160
|
+
}
|
|
161
|
+
var I = /* @__PURE__ */ new WeakMap(), L = {
|
|
162
|
+
mounted(e) {
|
|
163
|
+
let t = () => F(e);
|
|
164
|
+
I.set(e, t), e.addEventListener("pointerenter", t);
|
|
165
|
+
},
|
|
166
|
+
updated(e) {
|
|
167
|
+
e.hasAttribute("title") && F(e);
|
|
168
|
+
},
|
|
169
|
+
beforeUnmount(e) {
|
|
170
|
+
let t = I.get(e);
|
|
171
|
+
t && e.removeEventListener("pointerenter", t), I.delete(e);
|
|
172
|
+
}
|
|
173
|
+
}, R = { class: "flex flex-col gap-1" }, z = [
|
|
125
174
|
"id",
|
|
126
175
|
"value",
|
|
127
176
|
"rows",
|
|
128
177
|
"disabled",
|
|
129
178
|
"required"
|
|
130
|
-
],
|
|
179
|
+
], B = [
|
|
131
180
|
"id",
|
|
132
181
|
"type",
|
|
133
182
|
"value",
|
|
134
183
|
"disabled",
|
|
135
184
|
"required",
|
|
136
185
|
"autocomplete"
|
|
137
|
-
],
|
|
186
|
+
], V = ["for"], H = {
|
|
138
187
|
key: 0,
|
|
139
188
|
class: "text-error"
|
|
140
|
-
},
|
|
189
|
+
}, U = {
|
|
141
190
|
key: 3,
|
|
142
191
|
class: "absolute right-2 top-1/2 -translate-y-1/2"
|
|
143
|
-
},
|
|
192
|
+
}, W = ["aria-label"], G = {
|
|
144
193
|
key: 0,
|
|
145
194
|
class: "px-4 text-body-small text-error"
|
|
146
|
-
},
|
|
195
|
+
}, K = {
|
|
147
196
|
key: 1,
|
|
148
197
|
class: "px-4 text-body-small text-on-surface-variant"
|
|
149
|
-
},
|
|
198
|
+
}, q = /* @__PURE__ */ c({
|
|
150
199
|
__name: "MTextField",
|
|
151
200
|
props: {
|
|
152
201
|
modelValue: {},
|
|
@@ -173,70 +222,55 @@ var k = { class: "flex flex-col gap-1" }, A = [
|
|
|
173
222
|
},
|
|
174
223
|
emits: ["update:modelValue", "debounced"],
|
|
175
224
|
setup(c, { expose: l, emit: f }) {
|
|
176
|
-
let p = e(), v = c, S = f,
|
|
177
|
-
|
|
225
|
+
let p = e(), v = c, S = f, w = b(), T = x(), E = h(null), { resolvedFieldBg: j } = D(E, () => v.fieldBg), { debounced: N, cancel: P } = k((e) => S("debounced", e), v.debounce), F = h(null), I = h(null), q = n(() => F.value ?? I.value);
|
|
226
|
+
O(() => v.multiline && v.autoGrow ? F.value : null, {
|
|
178
227
|
minRows: () => v.rows,
|
|
179
228
|
maxRows: () => v.maxRows,
|
|
180
229
|
value: () => v.modelValue
|
|
181
230
|
});
|
|
182
|
-
let
|
|
183
|
-
let e =
|
|
231
|
+
let J = n(() => v.clearable && String(v.modelValue).length > 0 && !v.disabled), Y = n(() => T.trailing || v.clearable ? "right-12" : "right-4"), X = n(() => {
|
|
232
|
+
let e = v.leadingIcon ? "pl-12" : "pl-4", t = A[Y.value], n = v.multiline ? v.autoGrow ? "resize-none min-h-[56px]" : "resize-y min-h-[56px]" : "h-14", r = [
|
|
184
233
|
"peer block w-full text-body-large text-on-surface outline-none placeholder:text-transparent",
|
|
185
234
|
"transition-[border-color,border-width] duration-150",
|
|
186
235
|
"disabled:cursor-not-allowed disabled:text-on-surface/38",
|
|
187
236
|
v.error ? "caret-error" : "caret-primary",
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
237
|
+
n,
|
|
238
|
+
e,
|
|
239
|
+
t
|
|
191
240
|
];
|
|
192
241
|
return v.variant === "outlined" ? [
|
|
193
|
-
...
|
|
242
|
+
...r,
|
|
194
243
|
"rounded-xs border bg-transparent py-4",
|
|
195
244
|
v.error ? "border-error focus:border-2 focus:border-error" : "border-outline hover:border-on-surface focus:border-2 focus:border-primary",
|
|
196
245
|
"disabled:border-on-surface/12"
|
|
197
246
|
].join(" ") : [
|
|
198
|
-
...
|
|
247
|
+
...r,
|
|
199
248
|
v.multiline ? "rounded-t-xs bg-surface-container-highest border-b border-t-24 border-t-transparent pb-2" : "rounded-t-xs bg-surface-container-highest border-b pt-6 pb-2",
|
|
200
249
|
v.error ? "border-b-error focus:border-b-2 focus:border-b-error" : "border-b-on-surface-variant hover:border-b-on-surface focus:border-b-2 focus:border-b-primary",
|
|
201
250
|
"disabled:border-b-on-surface/38 disabled:bg-[color-mix(in_srgb,var(--color-on-surface)_4%,var(--color-surface-container-highest))]"
|
|
202
251
|
].join(" ");
|
|
203
|
-
}),
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
...e,
|
|
212
|
-
"peer-focus:-top-2.5 peer-focus:translate-y-0 peer-focus:text-label-small peer-focus:right-auto peer-focus:max-w-[calc(100%-1.5rem)] peer-focus:bg-[var(--field-bg)] peer-focus:px-1",
|
|
213
|
-
"peer-[&:not(:placeholder-shown)]:-top-2.5 peer-[&:not(:placeholder-shown)]:translate-y-0 peer-[&:not(:placeholder-shown)]:right-auto peer-[&:not(:placeholder-shown)]:max-w-[calc(100%-1.5rem)]",
|
|
214
|
-
"peer-[&:not(:placeholder-shown)]:text-label-small peer-[&:not(:placeholder-shown)]:bg-[var(--field-bg)] peer-[&:not(:placeholder-shown)]:px-1",
|
|
215
|
-
v.error ? "text-error peer-focus:text-error" : "text-on-surface-variant peer-focus:text-primary",
|
|
216
|
-
"peer-disabled:text-on-surface/38"
|
|
217
|
-
].join(" ") : [
|
|
218
|
-
...e,
|
|
219
|
-
"peer-focus:top-2 peer-focus:translate-y-0 peer-focus:text-label-small",
|
|
220
|
-
"peer-[&:not(:placeholder-shown)]:top-2 peer-[&:not(:placeholder-shown)]:translate-y-0 peer-[&:not(:placeholder-shown)]:text-label-small",
|
|
221
|
-
v.error ? "text-error peer-focus:text-error" : "text-on-surface-variant peer-focus:text-primary",
|
|
222
|
-
"peer-disabled:text-on-surface/38"
|
|
223
|
-
].join(" ");
|
|
224
|
-
});
|
|
225
|
-
function q(e) {
|
|
252
|
+
}), Z = n(() => M({
|
|
253
|
+
variant: v.variant,
|
|
254
|
+
leading: !!v.leadingIcon,
|
|
255
|
+
right: Y.value,
|
|
256
|
+
floated: "peer",
|
|
257
|
+
color: [v.error ? "text-error peer-focus:text-error" : "text-on-surface-variant peer-focus:text-primary", "peer-disabled:text-on-surface/38"].join(" ")
|
|
258
|
+
}));
|
|
259
|
+
function Q(e) {
|
|
226
260
|
let t = e.target;
|
|
227
|
-
S("update:modelValue", t.value), v.debounce > 0 &&
|
|
261
|
+
S("update:modelValue", t.value), v.debounce > 0 && N(t.value);
|
|
228
262
|
}
|
|
229
263
|
return l({
|
|
230
|
-
inputEl:
|
|
231
|
-
focus: (e) =>
|
|
232
|
-
blur: () =>
|
|
233
|
-
select: () =>
|
|
234
|
-
setSelectionRange: (e, t, n) =>
|
|
235
|
-
}), (e, n) => (m(), i("div",
|
|
264
|
+
inputEl: q,
|
|
265
|
+
focus: (e) => q.value?.focus(e),
|
|
266
|
+
blur: () => q.value?.blur(),
|
|
267
|
+
select: () => q.value?.select(),
|
|
268
|
+
setSelectionRange: (e, t, n) => q.value?.setSelectionRange(e, t, n)
|
|
269
|
+
}), (e, n) => (m(), i("div", R, [a("div", {
|
|
236
270
|
ref_key: "fieldBgEl",
|
|
237
|
-
ref:
|
|
271
|
+
ref: E,
|
|
238
272
|
class: u(["relative", c.variant === "outlined" ? "mt-2" : ""]),
|
|
239
|
-
style: d(c.variant === "outlined" ? { "--field-bg": y(
|
|
273
|
+
style: d(c.variant === "outlined" ? { "--field-bg": y(j) } : void 0)
|
|
240
274
|
}, [
|
|
241
275
|
c.leadingIcon ? (m(), i("div", {
|
|
242
276
|
key: 0,
|
|
@@ -248,49 +282,49 @@ var k = { class: "flex flex-col gap-1" }, A = [
|
|
|
248
282
|
c.multiline ? (m(), i("textarea", {
|
|
249
283
|
key: 1,
|
|
250
284
|
ref_key: "textareaEl",
|
|
251
|
-
ref:
|
|
252
|
-
id: y(
|
|
285
|
+
ref: F,
|
|
286
|
+
id: y(w),
|
|
253
287
|
value: String(c.modelValue),
|
|
254
288
|
rows: c.rows,
|
|
255
289
|
disabled: c.disabled,
|
|
256
290
|
required: c.required,
|
|
257
291
|
placeholder: " ",
|
|
258
|
-
class: u(
|
|
259
|
-
onInput:
|
|
260
|
-
}, null, 42,
|
|
292
|
+
class: u(X.value),
|
|
293
|
+
onInput: Q
|
|
294
|
+
}, null, 42, z)) : C((m(), i("input", {
|
|
261
295
|
key: 2,
|
|
262
296
|
ref_key: "inputOnlyEl",
|
|
263
|
-
ref:
|
|
264
|
-
id: y(
|
|
297
|
+
ref: I,
|
|
298
|
+
id: y(w),
|
|
265
299
|
type: c.type,
|
|
266
300
|
value: c.modelValue,
|
|
267
301
|
disabled: c.disabled,
|
|
268
302
|
required: c.required,
|
|
269
303
|
autocomplete: c.autocomplete,
|
|
270
304
|
placeholder: " ",
|
|
271
|
-
class: u(
|
|
272
|
-
onInput:
|
|
273
|
-
}, null, 42,
|
|
305
|
+
class: u(X.value),
|
|
306
|
+
onInput: Q
|
|
307
|
+
}, null, 42, B)), [[y(L)]]),
|
|
274
308
|
a("label", {
|
|
275
|
-
for: y(
|
|
276
|
-
class: u(
|
|
277
|
-
}, [o(_(c.label), 1), c.required ? (m(), i("span",
|
|
278
|
-
e.$slots.trailing ? (m(), i("div",
|
|
309
|
+
for: y(w),
|
|
310
|
+
class: u(Z.value)
|
|
311
|
+
}, [o(_(c.label), 1), c.required ? (m(), i("span", H, "\xA0*")) : r("", !0)], 10, V),
|
|
312
|
+
e.$slots.trailing ? (m(), i("div", U, [g(e.$slots, "trailing")])) : J.value ? (m(), i("button", {
|
|
279
313
|
key: 4,
|
|
280
314
|
"aria-label": y(p).clear,
|
|
281
315
|
type: "button",
|
|
282
316
|
class: "absolute right-3 top-1/2 -translate-y-1/2 flex h-6 w-6 cursor-pointer items-center justify-center rounded-full text-on-surface-variant transition-colors hover:bg-on-surface/8 hover:text-on-surface",
|
|
283
317
|
onClick: n[0] ||= (e) => {
|
|
284
|
-
y(
|
|
318
|
+
y(P)(), S("update:modelValue", "");
|
|
285
319
|
}
|
|
286
320
|
}, [s(t, {
|
|
287
321
|
name: "close",
|
|
288
322
|
size: 18
|
|
289
|
-
})], 8,
|
|
290
|
-
], 6), c.error && c.errorLabel ? (m(), i("p",
|
|
323
|
+
})], 8, W)) : r("", !0)
|
|
324
|
+
], 6), c.error && c.errorLabel ? (m(), i("p", G, _(c.errorLabel), 1)) : c.hint ? (m(), i("p", K, _(c.hint), 1)) : r("", !0)]));
|
|
291
325
|
}
|
|
292
326
|
});
|
|
293
327
|
//#endregion
|
|
294
|
-
export {
|
|
328
|
+
export { M as a, O as c, N as i, D as l, A as n, L as o, j as r, k as s, q as t };
|
|
295
329
|
|
|
296
|
-
//# sourceMappingURL=MTextField-
|
|
330
|
+
//# sourceMappingURL=MTextField-BRntFeNR.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MTextField-BRntFeNR.js","names":["$slots"],"sources":["../src/composables/useFieldBg.ts","../src/composables/useAutoGrow.ts","../src/composables/useDebounce.ts","../src/composables/_fieldLayout.ts","../src/components/MTextField.vue","../src/components/MTextField.vue"],"sourcesContent":["import { ref, computed, onMounted, onBeforeUnmount, type Ref } from 'vue'\n\nconst M3_BG_CLASSES = [\n 'bg-surface-container-highest',\n 'bg-surface-container-high',\n 'bg-surface-container-low',\n 'bg-surface-container-lowest',\n 'bg-surface-container',\n 'bg-surface-variant',\n 'bg-surface-bright',\n 'bg-surface-dim',\n 'bg-surface',\n 'bg-background',\n 'bg-inverse-surface',\n 'bg-primary-container',\n 'bg-secondary-container',\n 'bg-tertiary-container',\n 'bg-error-container',\n 'bg-primary-fixed',\n 'bg-primary-fixed-dim',\n 'bg-secondary-fixed',\n 'bg-secondary-fixed-dim',\n 'bg-tertiary-fixed',\n 'bg-tertiary-fixed-dim',\n 'bg-primary',\n 'bg-secondary',\n 'bg-tertiary',\n 'bg-error',\n] as const\n\nfunction findM3BgVar(el: HTMLElement): string | null {\n for (const cls of M3_BG_CLASSES) {\n if (el.classList.contains(cls)) return `var(--color-${cls.slice(3)})`\n }\n return null\n}\n\nfunction isTransparent(color: string): boolean {\n if (!color || color === 'transparent') return true\n const m = color.match(/^rgba?\\(([^)]+)\\)$/)\n if (m) {\n const parts = m[1]!.split(',').map((s) => s.trim())\n if (parts.length === 4 && parseFloat(parts[3]!) === 0) return true\n }\n return false\n}\n\n/**\n * Auto-detects the background behind `containerEl` and exposes it as `--field-bg`.\n * Prefers a CSS variable reference (e.g. var(--color-surface-container-low)) over a\n * raw computed color so the outlined label cutout transitions in sync with the rest\n * of the theme switch instead of lagging behind.\n *\n * @param containerEl The element that receives `--field-bg` as an inline style.\n * @param fieldBgProp Getter for the explicit `fieldBg` prop (overrides auto-detect).\n */\nexport function useFieldBg(\n containerEl: Ref<HTMLElement | null>,\n fieldBgProp: () => string | undefined,\n) {\n const detectedBg = ref<string>('var(--color-surface)')\n\n function applyFieldBg(value: string) {\n detectedBg.value = value\n containerEl.value?.style.setProperty('--field-bg', fieldBgProp() ?? value)\n }\n\n function resolveBg() {\n let el: HTMLElement | null = containerEl.value?.parentElement ?? null\n while (el) {\n const cssVar = findM3BgVar(el)\n if (cssVar) { applyFieldBg(cssVar); return }\n if (el === document.body) { applyFieldBg('var(--color-surface)'); return }\n const bg = getComputedStyle(el).backgroundColor\n if (!isTransparent(bg)) { applyFieldBg(bg); return }\n el = el.parentElement\n }\n applyFieldBg('var(--color-surface)')\n }\n\n let observer: MutationObserver | null = null\n\n onMounted(() => {\n resolveBg()\n observer = new MutationObserver(() => resolveBg())\n observer.observe(document.documentElement, {\n attributes: true,\n attributeFilter: ['class', 'style', 'data-theme'],\n })\n })\n\n onBeforeUnmount(() => observer?.disconnect())\n\n const resolvedFieldBg = computed(() => fieldBgProp() ?? detectedBg.value)\n\n return { resolvedFieldBg }\n}\n","import { getCurrentInstance, onBeforeUnmount, toValue, watch, type MaybeRefOrGetter, type WatchSource } from 'vue'\n\nexport interface AutoGrowOptions {\n /** Fewest rows it shrinks to (default 1) */\n minRows?: MaybeRefOrGetter<number | undefined>\n /** Most rows it grows to; past them it scrolls. Unset grows without limit */\n maxRows?: MaybeRefOrGetter<number | undefined>\n /**\n * The text, when it can change without typing (cleared after sending, an emoji inserted…): a ref or getter, so the\n * height follows. Typing is followed on its own\n */\n value?: WatchSource<unknown>\n}\n\n/**\n * Makes a `<textarea>` grow with its text, between `minRows` and `maxRows` rows, scrolling past the last one: a chat\n * composer, a comment box. Works on any textarea, styled however you like (rows are measured from its computed line\n * height, padding and border). It also follows width changes, which rewrap the text. Returns `resize()` for anything\n * else that changes the text.\n */\nexport function useAutoGrow(target: MaybeRefOrGetter<HTMLTextAreaElement | null | undefined>, options: AutoGrowOptions = {}) {\n let el: HTMLTextAreaElement | null = null\n let observer: ResizeObserver | null = null\n let lastWidth = 0\n\n function resize() {\n if (!el) return\n const cs = getComputedStyle(el)\n const px = (v: string) => parseFloat(v) || 0\n // `normal` line height has no number: about 1.5× the font size\n const lineHeight = px(cs.lineHeight) || px(cs.fontSize) * 1.5 || 24\n const padding = px(cs.paddingTop) + px(cs.paddingBottom)\n const border = cs.boxSizing === 'border-box' ? px(cs.borderTopWidth) + px(cs.borderBottomWidth) : 0\n const extra = (cs.boxSizing === 'border-box' ? padding : 0) + border\n const min = (toValue(options.minRows) ?? 1) * lineHeight + extra\n const maxRows = toValue(options.maxRows)\n const max = maxRows ? maxRows * lineHeight + extra : Infinity\n\n // Collapse first so scrollHeight measures the text, not the current height\n el.style.height = 'auto'\n const content = el.scrollHeight + border + (cs.boxSizing === 'border-box' ? 0 : -padding)\n const height = Math.min(max, Math.max(min, content))\n el.style.height = `${height}px`\n el.style.overflowY = content > max ? 'auto' : 'hidden'\n }\n\n function attach(next: HTMLTextAreaElement | null | undefined) {\n if (el) {\n el.removeEventListener('input', resize)\n observer?.disconnect()\n // Released (autoGrow turned off, another element): back to its own height\n el.style.height = ''\n el.style.overflowY = ''\n }\n el = next ?? null\n if (!el) return\n el.addEventListener('input', resize)\n if (typeof ResizeObserver !== 'undefined') {\n // Only width changes rewrap the text; our own height writes would otherwise loop\n observer ??= new ResizeObserver(([entry]) => {\n const w = entry!.contentRect.width\n if (w !== lastWidth) {\n lastWidth = w\n resize()\n }\n })\n observer.observe(el)\n }\n resize()\n }\n\n watch(() => toValue(target), attach, { immediate: true, flush: 'post' })\n watch([() => toValue(options.minRows), () => toValue(options.maxRows)], () => resize(), { flush: 'post' })\n if (options.value) watch(options.value, () => resize(), { flush: 'post' })\n if (getCurrentInstance()) onBeforeUnmount(() => attach(null))\n\n return { resize }\n}\n","import { onBeforeUnmount } from 'vue'\n\nexport function useDebounce(fn: (...args: any[]) => void, ms: number) {\n let timer: ReturnType<typeof setTimeout> | null = null\n\n function debounced(...args: any[]) {\n if (timer) clearTimeout(timer)\n timer = setTimeout(() => {\n timer = null\n fn(...args)\n }, ms)\n }\n\n function cancel() {\n if (timer) {\n clearTimeout(timer)\n timer = null\n }\n }\n\n onBeforeUnmount(cancel)\n\n return { debounced, cancel }\n}\n","import type { Directive } from 'vue'\n\n/**\n * Shared layout of the M3 text-field shell (internal, not exported from the package).\n *\n * Every field draws the same pieces: a 56px box, a label that floats from the middle of the box to its top\n * edge (filled) or onto the border (outlined), an optional leading icon and trailing buttons. The rules that\n * keep long content from running over those pieces live here, so a new field gets them by reusing this:\n *\n * - The label is inset from the right by as much as the box's own right padding (`right`), so it never runs\n * under a trailing button, floated (filled) or not. Floated on an outlined border, it shrinks to its own\n * text but stops 12px before the far corner, whatever its left offset (a leading icon moves it to 44px).\n * - A value shown as text in a fixed-height box (`FIELD_VALUE`) stays on one line and ends in \"…\", and\n * `vOverflowTitle` puts the whole of it in a tooltip only when it's cut. Screen readers get the full text\n * either way: the ellipsis is only visual.\n */\n\nexport type FieldVariant = 'filled' | 'outlined'\n\n/**\n * Right inset of the label, which must equal the field's right padding: `right-4` with nothing trailing,\n * `right-10` with a dropdown arrow, `right-12` with one trailing button, `right-16` with a clear button and\n * an arrow, `right-24` with two 32px buttons (MNumberField's stepper).\n */\nexport type FieldRightInset = 'right-4' | 'right-10' | 'right-12' | 'right-16' | 'right-24'\n\n/** Padding matching each inset, for the box itself */\nexport const FIELD_PADDING_RIGHT: Record<FieldRightInset, string> = {\n 'right-4': 'pr-4',\n 'right-10': 'pr-10',\n 'right-12': 'pr-12',\n 'right-16': 'pr-16',\n 'right-24': 'pr-24',\n}\n\n/** One line, cut with \"…\", allowed to shrink inside its flex row */\nexport const FIELD_VALUE = 'block min-w-0 flex-1 truncate'\n\nexport interface FieldLabelOptions {\n variant: FieldVariant\n /** There is a leading icon (the label starts after it) */\n leading?: boolean\n right: FieldRightInset\n /**\n * `true`/`false` when the component knows whether the label floats; `'peer'` to float it with CSS from\n * the preceding `.peer` input (focused, or its `placeholder=\" \"` not shown because it has a value)\n */\n floated: boolean | 'peer'\n /** Color classes (they depend on each component's notion of focus / error / disabled) */\n color: string\n}\n\nexport function fieldLabelClasses(o: FieldLabelOptions): string {\n const outlined = o.variant === 'outlined'\n const left = o.leading ? (outlined ? 'left-11' : 'left-12') : outlined ? 'left-3' : 'left-4'\n const base = ['pointer-events-none absolute truncate transition-all duration-200', left, o.right]\n const rest = outlined ? 'top-1/2 -translate-y-1/2 text-body-large' : 'top-[53%] -translate-y-1/2 text-body-large'\n\n if (o.floated === 'peer') {\n // Literal class names (Tailwind only sees complete strings)\n const floatedPeer = outlined\n ? o.leading\n ? 'peer-focus:-top-2.5 peer-focus:translate-y-0 peer-focus:text-label-small peer-focus:right-auto peer-focus:max-w-[calc(100%-3.5rem)] peer-focus:bg-[var(--field-bg)] peer-focus:px-1 ' +\n 'peer-[&:not(:placeholder-shown)]:-top-2.5 peer-[&:not(:placeholder-shown)]:translate-y-0 peer-[&:not(:placeholder-shown)]:text-label-small peer-[&:not(:placeholder-shown)]:right-auto peer-[&:not(:placeholder-shown)]:max-w-[calc(100%-3.5rem)] peer-[&:not(:placeholder-shown)]:bg-[var(--field-bg)] peer-[&:not(:placeholder-shown)]:px-1'\n : 'peer-focus:-top-2.5 peer-focus:translate-y-0 peer-focus:text-label-small peer-focus:right-auto peer-focus:max-w-[calc(100%-1.5rem)] peer-focus:bg-[var(--field-bg)] peer-focus:px-1 ' +\n 'peer-[&:not(:placeholder-shown)]:-top-2.5 peer-[&:not(:placeholder-shown)]:translate-y-0 peer-[&:not(:placeholder-shown)]:text-label-small peer-[&:not(:placeholder-shown)]:right-auto peer-[&:not(:placeholder-shown)]:max-w-[calc(100%-1.5rem)] peer-[&:not(:placeholder-shown)]:bg-[var(--field-bg)] peer-[&:not(:placeholder-shown)]:px-1'\n : 'peer-focus:top-2 peer-focus:translate-y-0 peer-focus:text-label-small ' +\n 'peer-[&:not(:placeholder-shown)]:top-2 peer-[&:not(:placeholder-shown)]:translate-y-0 peer-[&:not(:placeholder-shown)]:text-label-small'\n return [...base, rest, floatedPeer, o.color].join(' ')\n }\n\n const floated = outlined\n ? `-top-2.5 translate-y-0 text-label-small bg-[var(--field-bg)] px-1 right-auto ${o.leading ? 'max-w-[calc(100%-3.5rem)]' : 'max-w-[calc(100%-1.5rem)]'}`\n : 'top-2 translate-y-0 text-label-small'\n return [...base, o.floated ? floated : rest, o.color].join(' ')\n}\n\n/** A label always floated on an outlined border (the picker triggers): cut before the far corner */\nexport const OUTLINED_FLOATED_LABEL =\n 'pointer-events-none absolute -top-2.5 left-3 max-w-[calc(100%-1.5rem)] truncate bg-(--field-bg) px-1 text-label-small'\n\nfunction fullText(el: HTMLElement): string {\n // By tag, not instanceof: the element may come from another realm (an iframe, a test DOM)\n return el.tagName === 'INPUT' || el.tagName === 'TEXTAREA'\n ? (el as HTMLInputElement).value\n : (el.textContent ?? '').trim()\n}\n\nfunction updateTitle(el: HTMLElement) {\n const cut = el.scrollWidth > el.clientWidth\n const text = cut ? fullText(el) : ''\n if (text) el.title = text\n else el.removeAttribute('title')\n}\n\nconst hoverHandlers = new WeakMap<HTMLElement, () => void>()\n\n/**\n * Puts the element's whole text (an input's value, or its text content) in `title` while it's cut by\n * overflow, measured when the pointer comes in, so a value that fits gets no redundant tooltip.\n */\nexport const vOverflowTitle: Directive<HTMLElement> = {\n mounted(el) {\n const handler = () => updateTitle(el)\n hoverHandlers.set(el, handler)\n el.addEventListener('pointerenter', handler)\n },\n updated(el) {\n // A value changed while hovered: keep the tooltip in step\n if (el.hasAttribute('title')) updateTitle(el)\n },\n beforeUnmount(el) {\n const handler = hoverHandlers.get(el)\n if (handler) el.removeEventListener('pointerenter', handler)\n hoverHandlers.delete(el)\n },\n}\n","<script setup lang=\"ts\">\n/**\n * The standard single- or multi-line text input, filled or outlined, with floating label.\n *\n * @slot trailing Custom trailing content (e.g. an icon button) — replaces the built-in clear button when\n * present\n * @event update:modelValue Emitted on every keystroke — powers v-model\n * @event debounced Emitted debounce ms after the user stops typing (only when debounce > 0)\n */\nimport { computed, ref, useId, useSlots } from \"vue\";\nimport MIcon from \"./MIcon.vue\";\nimport { useAutoGrow } from \"../composables/useAutoGrow\";\nimport { useFieldBg } from \"../composables/useFieldBg\";\nimport { useDebounce } from \"../composables/useDebounce\";\nimport { useLocale } from '../composables/useLocale'\nimport { FIELD_PADDING_RIGHT, fieldLabelClasses, vOverflowTitle, type FieldRightInset } from '../composables/_fieldLayout'\n\nconst locale = useLocale()\nconst props = withDefaults(\n defineProps<{\n /** Bound value (v-model) */\n modelValue: string | number;\n /** Field label */\n label: string;\n /** HTML input type */\n type?: string;\n /** Visual style */\n variant?: \"filled\" | \"outlined\";\n /** Puts the field in error state (red border and label) */\n error?: boolean;\n /** Error message shown below the field (only visible when error is true) */\n errorLabel?: string;\n /** Hint text shown below the field */\n hint?: string;\n /** Disables the field */\n disabled?: boolean;\n /** Marks as required — adds a red asterisk after the label */\n required?: boolean;\n /** Renders a textarea instead of an input */\n multiline?: boolean;\n /** Textarea rows (when multiline); with autoGrow, the fewest it shrinks to */\n rows?: number;\n /** Multiline only: grows with the text from `rows` up to `maxRows`, instead of a fixed height with a drag handle */\n autoGrow?: boolean;\n /** With autoGrow, the most rows it grows to before scrolling. Unset grows without limit */\n maxRows?: number;\n /** Passed through to the native autocomplete attribute */\n autocomplete?: string;\n /** Material Symbol shown before the input */\n leadingIcon?: string;\n /** Show a clear button when the field has a value */\n clearable?: boolean;\n /**\n * Overrides the auto-detected background color used to cut the floating label out of the outlined border\n */\n fieldBg?: string;\n /** Delay (ms) before firing the @debounced event. v-model always updates immediately */\n debounce?: number;\n }>(),\n {\n type: \"text\",\n variant: \"filled\",\n rows: 3,\n clearable: false,\n debounce: 0,\n },\n);\n\nconst emit = defineEmits<{ \"update:modelValue\": [string]; debounced: [string] }>();\n\nconst id = useId();\nconst slots = useSlots();\n\nconst fieldBgEl = ref<HTMLElement | null>(null);\nconst { resolvedFieldBg } = useFieldBg(fieldBgEl, () => props.fieldBg);\n\nconst { debounced: emitDebounced, cancel: cancelDebounce } = useDebounce((v: string) => emit(\"debounced\", v), props.debounce)\n\nconst textareaEl = ref<HTMLTextAreaElement | null>(null);\nconst inputOnlyEl = ref<HTMLInputElement | null>(null);\nconst fieldEl = computed(() => textareaEl.value ?? inputOnlyEl.value);\nuseAutoGrow(() => (props.multiline && props.autoGrow ? textareaEl.value : null), {\n minRows: () => props.rows,\n maxRows: () => props.maxRows,\n value: () => props.modelValue,\n});\n\nconst showClear = computed(() => props.clearable && String(props.modelValue).length > 0 && !props.disabled)\n\n// The label and the text both stop before a trailing button (the #trailing slot or the clear button)\nconst rightInset = computed<FieldRightInset>(() => (slots.trailing || props.clearable ? \"right-12\" : \"right-4\"));\n\nconst inputClasses = computed(() => {\n const pl = props.leadingIcon ? \"pl-12\" : \"pl-4\";\n const pr = FIELD_PADDING_RIGHT[rightInset.value];\n const size = props.multiline ? (props.autoGrow ? \"resize-none min-h-[56px]\" : \"resize-y min-h-[56px]\") : \"h-14\";\n const base = [\n \"peer block w-full text-body-large text-on-surface outline-none placeholder:text-transparent\",\n \"transition-[border-color,border-width] duration-150\",\n \"disabled:cursor-not-allowed disabled:text-on-surface/38\",\n props.error ? \"caret-error\" : \"caret-primary\",\n size,\n pl,\n pr,\n ];\n\n if (props.variant === \"outlined\") {\n return [\n ...base,\n \"rounded-xs border bg-transparent py-4\",\n props.error\n ? \"border-error focus:border-2 focus:border-error\"\n : \"border-outline hover:border-on-surface focus:border-2 focus:border-primary\",\n \"disabled:border-on-surface/12\",\n ].join(\" \");\n }\n\n return [\n ...base,\n // Multiline: the label's 24px band is a transparent top border rather than padding, so text scrolled up is\n // clipped below the label (at the padding box) instead of running behind it; the background still fills it\n props.multiline\n ? \"rounded-t-xs bg-surface-container-highest border-b border-t-24 border-t-transparent pb-2\"\n : \"rounded-t-xs bg-surface-container-highest border-b pt-6 pb-2\",\n props.error\n ? \"border-b-error focus:border-b-2 focus:border-b-error\"\n : \"border-b-on-surface-variant hover:border-b-on-surface focus:border-b-2 focus:border-b-primary\",\n \"disabled:border-b-on-surface/38 disabled:bg-[color-mix(in_srgb,var(--color-on-surface)_4%,var(--color-surface-container-highest))]\",\n ].join(\" \");\n});\n\nconst labelClasses = computed(() =>\n fieldLabelClasses({\n variant: props.variant,\n leading: !!props.leadingIcon,\n right: rightInset.value,\n floated: 'peer',\n color: [\n props.error ? 'text-error peer-focus:text-error' : 'text-on-surface-variant peer-focus:text-primary',\n 'peer-disabled:text-on-surface/38',\n ].join(' '),\n }),\n);\n\nfunction onInput(event: Event) {\n const target = event.target as HTMLInputElement | HTMLTextAreaElement;\n emit(\"update:modelValue\", target.value);\n if (props.debounce > 0) emitDebounced(target.value)\n}\n\ndefineExpose({\n /** The `<input>` (or `<textarea>`) element */\n inputEl: fieldEl,\n /** Focuses the field */\n focus: (options?: FocusOptions) => fieldEl.value?.focus(options),\n /** Takes focus away from the field */\n blur: () => fieldEl.value?.blur(),\n /** Selects all its text */\n select: () => fieldEl.value?.select(),\n /** Selects part of its text (e.g. a file name without its extension) */\n setSelectionRange: (start: number, end: number, direction?: 'forward' | 'backward' | 'none') => fieldEl.value?.setSelectionRange(start, end, direction),\n})\n</script>\n\n<template>\n <div class=\"flex flex-col gap-1\">\n <!--\n --field-bg: background behind the floating label in outlined mode, so it\n \"cuts through\" the border. Auto-detected from the nearest opaque ancestor\n (see resolveBg); overridable via the fieldBg prop; falls back to surface.\n -->\n <div\n ref=\"fieldBgEl\"\n class=\"relative\"\n :class=\"variant === 'outlined' ? 'mt-2' : ''\"\n :style=\"variant === 'outlined' ? { '--field-bg': resolvedFieldBg } : undefined\"\n >\n <div\n v-if=\"leadingIcon\"\n class=\"pointer-events-none absolute left-3.5\"\n :class=\"[\n multiline ? 'top-[55%] -translate-y-1/2' : variant === 'filled' ? 'top-4.5' : 'top-4',\n disabled ? 'text-on-surface/38' : 'text-on-surface-variant',\n ]\"\n >\n <MIcon :name=\"leadingIcon\" :size=\"24\" />\n </div>\n\n <textarea\n v-if=\"multiline\"\n ref=\"textareaEl\"\n :id=\"id\"\n :value=\"String(modelValue)\"\n :rows=\"rows\"\n :disabled=\"disabled\"\n :required=\"required\"\n placeholder=\" \"\n :class=\"inputClasses\"\n @input=\"onInput\"\n />\n <input\n v-else\n ref=\"inputOnlyEl\"\n :id=\"id\"\n :type=\"type\"\n :value=\"modelValue\"\n :disabled=\"disabled\"\n :required=\"required\"\n :autocomplete=\"autocomplete\"\n placeholder=\" \"\n :class=\"inputClasses\"\n v-overflow-title\n @input=\"onInput\"\n />\n\n <label :for=\"id\" :class=\"labelClasses\">\n {{ label }}<span v-if=\"required\" class=\"text-error\"> *</span>\n </label>\n\n <div v-if=\"$slots.trailing\" class=\"absolute right-2 top-1/2 -translate-y-1/2\">\n <slot name=\"trailing\" />\n </div>\n <button\n :aria-label=\"locale.clear\"\n v-else-if=\"showClear\"\n type=\"button\"\n class=\"absolute right-3 top-1/2 -translate-y-1/2 flex h-6 w-6 cursor-pointer items-center justify-center rounded-full text-on-surface-variant transition-colors hover:bg-on-surface/8 hover:text-on-surface\"\n @click=\"cancelDebounce(); emit('update:modelValue', '')\"\n >\n <MIcon name=\"close\" :size=\"18\" />\n </button>\n </div>\n\n <p v-if=\"error && errorLabel\" class=\"px-4 text-body-small text-error\">{{ errorLabel }}</p>\n <p v-else-if=\"hint\" class=\"px-4 text-body-small text-on-surface-variant\">{{ hint }}</p>\n </div>\n</template>\n","<script setup lang=\"ts\">\n/**\n * The standard single- or multi-line text input, filled or outlined, with floating label.\n *\n * @slot trailing Custom trailing content (e.g. an icon button) — replaces the built-in clear button when\n * present\n * @event update:modelValue Emitted on every keystroke — powers v-model\n * @event debounced Emitted debounce ms after the user stops typing (only when debounce > 0)\n */\nimport { computed, ref, useId, useSlots } from \"vue\";\nimport MIcon from \"./MIcon.vue\";\nimport { useAutoGrow } from \"../composables/useAutoGrow\";\nimport { useFieldBg } from \"../composables/useFieldBg\";\nimport { useDebounce } from \"../composables/useDebounce\";\nimport { useLocale } from '../composables/useLocale'\nimport { FIELD_PADDING_RIGHT, fieldLabelClasses, vOverflowTitle, type FieldRightInset } from '../composables/_fieldLayout'\n\nconst locale = useLocale()\nconst props = withDefaults(\n defineProps<{\n /** Bound value (v-model) */\n modelValue: string | number;\n /** Field label */\n label: string;\n /** HTML input type */\n type?: string;\n /** Visual style */\n variant?: \"filled\" | \"outlined\";\n /** Puts the field in error state (red border and label) */\n error?: boolean;\n /** Error message shown below the field (only visible when error is true) */\n errorLabel?: string;\n /** Hint text shown below the field */\n hint?: string;\n /** Disables the field */\n disabled?: boolean;\n /** Marks as required — adds a red asterisk after the label */\n required?: boolean;\n /** Renders a textarea instead of an input */\n multiline?: boolean;\n /** Textarea rows (when multiline); with autoGrow, the fewest it shrinks to */\n rows?: number;\n /** Multiline only: grows with the text from `rows` up to `maxRows`, instead of a fixed height with a drag handle */\n autoGrow?: boolean;\n /** With autoGrow, the most rows it grows to before scrolling. Unset grows without limit */\n maxRows?: number;\n /** Passed through to the native autocomplete attribute */\n autocomplete?: string;\n /** Material Symbol shown before the input */\n leadingIcon?: string;\n /** Show a clear button when the field has a value */\n clearable?: boolean;\n /**\n * Overrides the auto-detected background color used to cut the floating label out of the outlined border\n */\n fieldBg?: string;\n /** Delay (ms) before firing the @debounced event. v-model always updates immediately */\n debounce?: number;\n }>(),\n {\n type: \"text\",\n variant: \"filled\",\n rows: 3,\n clearable: false,\n debounce: 0,\n },\n);\n\nconst emit = defineEmits<{ \"update:modelValue\": [string]; debounced: [string] }>();\n\nconst id = useId();\nconst slots = useSlots();\n\nconst fieldBgEl = ref<HTMLElement | null>(null);\nconst { resolvedFieldBg } = useFieldBg(fieldBgEl, () => props.fieldBg);\n\nconst { debounced: emitDebounced, cancel: cancelDebounce } = useDebounce((v: string) => emit(\"debounced\", v), props.debounce)\n\nconst textareaEl = ref<HTMLTextAreaElement | null>(null);\nconst inputOnlyEl = ref<HTMLInputElement | null>(null);\nconst fieldEl = computed(() => textareaEl.value ?? inputOnlyEl.value);\nuseAutoGrow(() => (props.multiline && props.autoGrow ? textareaEl.value : null), {\n minRows: () => props.rows,\n maxRows: () => props.maxRows,\n value: () => props.modelValue,\n});\n\nconst showClear = computed(() => props.clearable && String(props.modelValue).length > 0 && !props.disabled)\n\n// The label and the text both stop before a trailing button (the #trailing slot or the clear button)\nconst rightInset = computed<FieldRightInset>(() => (slots.trailing || props.clearable ? \"right-12\" : \"right-4\"));\n\nconst inputClasses = computed(() => {\n const pl = props.leadingIcon ? \"pl-12\" : \"pl-4\";\n const pr = FIELD_PADDING_RIGHT[rightInset.value];\n const size = props.multiline ? (props.autoGrow ? \"resize-none min-h-[56px]\" : \"resize-y min-h-[56px]\") : \"h-14\";\n const base = [\n \"peer block w-full text-body-large text-on-surface outline-none placeholder:text-transparent\",\n \"transition-[border-color,border-width] duration-150\",\n \"disabled:cursor-not-allowed disabled:text-on-surface/38\",\n props.error ? \"caret-error\" : \"caret-primary\",\n size,\n pl,\n pr,\n ];\n\n if (props.variant === \"outlined\") {\n return [\n ...base,\n \"rounded-xs border bg-transparent py-4\",\n props.error\n ? \"border-error focus:border-2 focus:border-error\"\n : \"border-outline hover:border-on-surface focus:border-2 focus:border-primary\",\n \"disabled:border-on-surface/12\",\n ].join(\" \");\n }\n\n return [\n ...base,\n // Multiline: the label's 24px band is a transparent top border rather than padding, so text scrolled up is\n // clipped below the label (at the padding box) instead of running behind it; the background still fills it\n props.multiline\n ? \"rounded-t-xs bg-surface-container-highest border-b border-t-24 border-t-transparent pb-2\"\n : \"rounded-t-xs bg-surface-container-highest border-b pt-6 pb-2\",\n props.error\n ? \"border-b-error focus:border-b-2 focus:border-b-error\"\n : \"border-b-on-surface-variant hover:border-b-on-surface focus:border-b-2 focus:border-b-primary\",\n \"disabled:border-b-on-surface/38 disabled:bg-[color-mix(in_srgb,var(--color-on-surface)_4%,var(--color-surface-container-highest))]\",\n ].join(\" \");\n});\n\nconst labelClasses = computed(() =>\n fieldLabelClasses({\n variant: props.variant,\n leading: !!props.leadingIcon,\n right: rightInset.value,\n floated: 'peer',\n color: [\n props.error ? 'text-error peer-focus:text-error' : 'text-on-surface-variant peer-focus:text-primary',\n 'peer-disabled:text-on-surface/38',\n ].join(' '),\n }),\n);\n\nfunction onInput(event: Event) {\n const target = event.target as HTMLInputElement | HTMLTextAreaElement;\n emit(\"update:modelValue\", target.value);\n if (props.debounce > 0) emitDebounced(target.value)\n}\n\ndefineExpose({\n /** The `<input>` (or `<textarea>`) element */\n inputEl: fieldEl,\n /** Focuses the field */\n focus: (options?: FocusOptions) => fieldEl.value?.focus(options),\n /** Takes focus away from the field */\n blur: () => fieldEl.value?.blur(),\n /** Selects all its text */\n select: () => fieldEl.value?.select(),\n /** Selects part of its text (e.g. a file name without its extension) */\n setSelectionRange: (start: number, end: number, direction?: 'forward' | 'backward' | 'none') => fieldEl.value?.setSelectionRange(start, end, direction),\n})\n</script>\n\n<template>\n <div class=\"flex flex-col gap-1\">\n <!--\n --field-bg: background behind the floating label in outlined mode, so it\n \"cuts through\" the border. Auto-detected from the nearest opaque ancestor\n (see resolveBg); overridable via the fieldBg prop; falls back to surface.\n -->\n <div\n ref=\"fieldBgEl\"\n class=\"relative\"\n :class=\"variant === 'outlined' ? 'mt-2' : ''\"\n :style=\"variant === 'outlined' ? { '--field-bg': resolvedFieldBg } : undefined\"\n >\n <div\n v-if=\"leadingIcon\"\n class=\"pointer-events-none absolute left-3.5\"\n :class=\"[\n multiline ? 'top-[55%] -translate-y-1/2' : variant === 'filled' ? 'top-4.5' : 'top-4',\n disabled ? 'text-on-surface/38' : 'text-on-surface-variant',\n ]\"\n >\n <MIcon :name=\"leadingIcon\" :size=\"24\" />\n </div>\n\n <textarea\n v-if=\"multiline\"\n ref=\"textareaEl\"\n :id=\"id\"\n :value=\"String(modelValue)\"\n :rows=\"rows\"\n :disabled=\"disabled\"\n :required=\"required\"\n placeholder=\" \"\n :class=\"inputClasses\"\n @input=\"onInput\"\n />\n <input\n v-else\n ref=\"inputOnlyEl\"\n :id=\"id\"\n :type=\"type\"\n :value=\"modelValue\"\n :disabled=\"disabled\"\n :required=\"required\"\n :autocomplete=\"autocomplete\"\n placeholder=\" \"\n :class=\"inputClasses\"\n v-overflow-title\n @input=\"onInput\"\n />\n\n <label :for=\"id\" :class=\"labelClasses\">\n {{ label }}<span v-if=\"required\" class=\"text-error\"> *</span>\n </label>\n\n <div v-if=\"$slots.trailing\" class=\"absolute right-2 top-1/2 -translate-y-1/2\">\n <slot name=\"trailing\" />\n </div>\n <button\n :aria-label=\"locale.clear\"\n v-else-if=\"showClear\"\n type=\"button\"\n class=\"absolute right-3 top-1/2 -translate-y-1/2 flex h-6 w-6 cursor-pointer items-center justify-center rounded-full text-on-surface-variant transition-colors hover:bg-on-surface/8 hover:text-on-surface\"\n @click=\"cancelDebounce(); emit('update:modelValue', '')\"\n >\n <MIcon name=\"close\" :size=\"18\" />\n </button>\n </div>\n\n <p v-if=\"error && errorLabel\" class=\"px-4 text-body-small text-error\">{{ errorLabel }}</p>\n <p v-else-if=\"hint\" class=\"px-4 text-body-small text-on-surface-variant\">{{ hint }}</p>\n </div>\n</template>\n"],"mappings":";;;;AAEA,IAAM,IAAgB;CACpB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,SAAS,EAAY,GAAgC;CACnD,KAAK,IAAM,KAAO,GAChB,IAAI,EAAG,UAAU,SAAS,CAAG,GAAG,OAAO,eAAe,EAAI,MAAM,CAAC,EAAE;CAErE,OAAO;AACT;AAEA,SAAS,EAAc,GAAwB;CAC7C,IAAI,CAAC,KAAS,MAAU,eAAe,OAAO;CAC9C,IAAM,IAAI,EAAM,MAAM,oBAAoB;CAC1C,IAAI,GAAG;EACL,IAAM,IAAQ,EAAE,EAAE,CAAE,MAAM,GAAG,CAAC,CAAC,KAAK,MAAM,EAAE,KAAK,CAAC;EAClD,IAAI,EAAM,WAAW,KAAK,WAAW,EAAM,EAAG,MAAM,GAAG,OAAO;CAChE;CACA,OAAO;AACT;AAWA,SAAgB,EACd,GACA,GACA;CACA,IAAM,IAAa,EAAY,sBAAsB;CAErD,SAAS,EAAa,GAAe;EAEnC,AADA,EAAW,QAAQ,GACnB,EAAY,OAAO,MAAM,YAAY,cAAc,EAAY,KAAK,CAAK;CAC3E;CAEA,SAAS,IAAY;EACnB,IAAI,IAAyB,EAAY,OAAO,iBAAiB;EACjE,OAAO,IAAI;GACT,IAAM,IAAS,EAAY,CAAE;GAC7B,IAAI,GAAQ;IAAE,EAAa,CAAM;IAAG;GAAO;GAC3C,IAAI,MAAO,SAAS,MAAM;IAAE,EAAa,sBAAsB;IAAG;GAAO;GACzE,IAAM,IAAK,iBAAiB,CAAE,CAAC,CAAC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