@matter-server/dashboard 0.2.0-alpha.0-00000000-000000000 → 0.2.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.
@@ -1,2086 +0,0 @@
1
- import { _ as __decorate, n as n$1, o as o$1, r as r$1, e, i as i$1, f as e$1, A, b, D, E as EASING, a as i$2, t, g as e$2, h as i$3, j as t$1, k as E, l as internals, m as mixinDelegatesAria, p as mixinElementInternals, u, q as i$4 } from './matter-dashboard-app-BazvuIIi.js';
2
- import { r as redispatchEvent } from './prevent_default-D4GG_QeD.js';
3
-
4
- /**
5
- * @license
6
- * Copyright 2021 Google LLC
7
- * SPDX-License-Identifier: Apache-2.0
8
- */
9
- /**
10
- * A field component.
11
- */
12
- class Field extends i$1 {
13
- constructor() {
14
- super(...arguments);
15
- this.disabled = false;
16
- this.error = false;
17
- this.focused = false;
18
- this.label = '';
19
- this.noAsterisk = false;
20
- this.populated = false;
21
- this.required = false;
22
- this.resizable = false;
23
- this.supportingText = '';
24
- this.errorText = '';
25
- this.count = -1;
26
- this.max = -1;
27
- /**
28
- * Whether or not the field has leading content.
29
- */
30
- this.hasStart = false;
31
- /**
32
- * Whether or not the field has trailing content.
33
- */
34
- this.hasEnd = false;
35
- this.isAnimating = false;
36
- /**
37
- * When set to true, the error text's `role="alert"` will be removed, then
38
- * re-added after an animation frame. This will re-announce an error message
39
- * to screen readers.
40
- */
41
- this.refreshErrorAlert = false;
42
- this.disableTransitions = false;
43
- }
44
- get counterText() {
45
- // Count and max are typed as number, but can be set to null when Lit removes
46
- // their attributes. These getters coerce back to a number for calculations.
47
- const countAsNumber = this.count ?? -1;
48
- const maxAsNumber = this.max ?? -1;
49
- // Counter does not show if count is negative, or max is negative or 0.
50
- if (countAsNumber < 0 || maxAsNumber <= 0) {
51
- return '';
52
- }
53
- return `${countAsNumber} / ${maxAsNumber}`;
54
- }
55
- get supportingOrErrorText() {
56
- return this.error && this.errorText ? this.errorText : this.supportingText;
57
- }
58
- /**
59
- * Re-announces the field's error supporting text to screen readers.
60
- *
61
- * Error text announces to screen readers anytime it is visible and changes.
62
- * Use the method to re-announce the message when the text has not changed,
63
- * but announcement is still needed (such as for `reportValidity()`).
64
- */
65
- reannounceError() {
66
- this.refreshErrorAlert = true;
67
- }
68
- update(props) {
69
- // Client-side property updates
70
- const isDisabledChanging = props.has('disabled') && props.get('disabled') !== undefined;
71
- if (isDisabledChanging) {
72
- this.disableTransitions = true;
73
- }
74
- // When disabling, remove focus styles if focused.
75
- if (this.disabled && this.focused) {
76
- props.set('focused', true);
77
- this.focused = false;
78
- }
79
- // Animate if focused or populated change.
80
- this.animateLabelIfNeeded({
81
- wasFocused: props.get('focused'),
82
- wasPopulated: props.get('populated')
83
- });
84
- super.update(props);
85
- }
86
- render() {
87
- var _this$renderOutline, _this$renderBackgroun, _this$renderStateLaye, _this$renderIndicator;
88
- const floatingLabel = this.renderLabel(/*isFloating*/true);
89
- const restingLabel = this.renderLabel(/*isFloating*/false);
90
- const outline = (_this$renderOutline = this.renderOutline) === null || _this$renderOutline === void 0 ? void 0 : _this$renderOutline.call(this, floatingLabel);
91
- const classes = {
92
- 'disabled': this.disabled,
93
- 'disable-transitions': this.disableTransitions,
94
- 'error': this.error && !this.disabled,
95
- 'focused': this.focused,
96
- 'with-start': this.hasStart,
97
- 'with-end': this.hasEnd,
98
- 'populated': this.populated,
99
- 'resizable': this.resizable,
100
- 'required': this.required,
101
- 'no-label': !this.label
102
- };
103
- return b`
104
- <div class="field ${e$1(classes)}">
105
- <div class="container-overflow">
106
- ${(_this$renderBackgroun = this.renderBackground) === null || _this$renderBackgroun === void 0 ? void 0 : _this$renderBackgroun.call(this)}
107
- <slot name="container"></slot>
108
- ${(_this$renderStateLaye = this.renderStateLayer) === null || _this$renderStateLaye === void 0 ? void 0 : _this$renderStateLaye.call(this)} ${(_this$renderIndicator = this.renderIndicator) === null || _this$renderIndicator === void 0 ? void 0 : _this$renderIndicator.call(this)} ${outline}
109
- <div class="container">
110
- <div class="start">
111
- <slot name="start"></slot>
112
- </div>
113
- <div class="middle">
114
- <div class="label-wrapper">
115
- ${restingLabel} ${outline ? A : floatingLabel}
116
- </div>
117
- <div class="content">
118
- <slot></slot>
119
- </div>
120
- </div>
121
- <div class="end">
122
- <slot name="end"></slot>
123
- </div>
124
- </div>
125
- </div>
126
- ${this.renderSupportingText()}
127
- </div>
128
- `;
129
- }
130
- updated(changed) {
131
- if (changed.has('supportingText') || changed.has('errorText') || changed.has('count') || changed.has('max')) {
132
- this.updateSlottedAriaDescribedBy();
133
- }
134
- if (this.refreshErrorAlert) {
135
- // The past render cycle removed the role="alert" from the error message.
136
- // Re-add it after an animation frame to re-announce the error.
137
- requestAnimationFrame(() => {
138
- this.refreshErrorAlert = false;
139
- });
140
- }
141
- if (this.disableTransitions) {
142
- requestAnimationFrame(() => {
143
- this.disableTransitions = false;
144
- });
145
- }
146
- }
147
- renderSupportingText() {
148
- const {
149
- supportingOrErrorText,
150
- counterText
151
- } = this;
152
- if (!supportingOrErrorText && !counterText) {
153
- return A;
154
- }
155
- // Always render the supporting text span so that our `space-around`
156
- // container puts the counter at the end.
157
- const start = b`<span>${supportingOrErrorText}</span>`;
158
- // Conditionally render counter so we don't render the extra `gap`.
159
- // TODO(b/244473435): add aria-label and announcements
160
- const end = counterText ? b`<span class="counter">${counterText}</span>` : A;
161
- // Announce if there is an error and error text visible.
162
- // If refreshErrorAlert is true, do not announce. This will remove the
163
- // role="alert" attribute. Another render cycle will happen after an
164
- // animation frame to re-add the role.
165
- const shouldErrorAnnounce = this.error && this.errorText && !this.refreshErrorAlert;
166
- const role = shouldErrorAnnounce ? 'alert' : A;
167
- return b`
168
- <div class="supporting-text" role=${role}>${start}${end}</div>
169
- <slot
170
- name="aria-describedby"
171
- @slotchange=${this.updateSlottedAriaDescribedBy}></slot>
172
- `;
173
- }
174
- updateSlottedAriaDescribedBy() {
175
- for (const element of this.slottedAriaDescribedBy) {
176
- D(b`${this.supportingOrErrorText} ${this.counterText}`, element);
177
- element.setAttribute('hidden', '');
178
- }
179
- }
180
- renderLabel(isFloating) {
181
- if (!this.label) {
182
- return A;
183
- }
184
- let visible;
185
- if (isFloating) {
186
- // Floating label is visible when focused/populated or when animating.
187
- visible = this.focused || this.populated || this.isAnimating;
188
- } else {
189
- // Resting label is visible when unfocused. It is never visible while
190
- // animating.
191
- visible = !this.focused && !this.populated && !this.isAnimating;
192
- }
193
- const classes = {
194
- 'hidden': !visible,
195
- 'floating': isFloating,
196
- 'resting': !isFloating
197
- };
198
- // Add '*' if a label is present and the field is required
199
- const labelText = `${this.label}${this.required && !this.noAsterisk ? '*' : ''}`;
200
- return b`
201
- <span class="label ${e$1(classes)}" aria-hidden=${!visible}
202
- >${labelText}</span
203
- >
204
- `;
205
- }
206
- animateLabelIfNeeded({
207
- wasFocused,
208
- wasPopulated
209
- }) {
210
- var _this$labelAnimation, _this$floatingLabelEl, _this$labelAnimation2;
211
- if (!this.label) {
212
- return;
213
- }
214
- wasFocused ?? (wasFocused = this.focused);
215
- wasPopulated ?? (wasPopulated = this.populated);
216
- const wasFloating = wasFocused || wasPopulated;
217
- const shouldBeFloating = this.focused || this.populated;
218
- if (wasFloating === shouldBeFloating) {
219
- return;
220
- }
221
- this.isAnimating = true;
222
- (_this$labelAnimation = this.labelAnimation) === null || _this$labelAnimation === void 0 || _this$labelAnimation.cancel();
223
- // Only one label is visible at a time for clearer text rendering.
224
- // The floating label is visible and used during animation. At the end of
225
- // the animation, it will either remain visible (if floating) or hide and
226
- // the resting label will be shown.
227
- //
228
- // We don't use forward filling because if the dimensions of the text field
229
- // change (leading icon removed, density changes, etc), then the animation
230
- // will be inaccurate.
231
- //
232
- // Re-calculating the animation each time will prevent any visual glitches
233
- // from appearing.
234
- // TODO(b/241113345): use animation tokens
235
- this.labelAnimation = (_this$floatingLabelEl = this.floatingLabelEl) === null || _this$floatingLabelEl === void 0 ? void 0 : _this$floatingLabelEl.animate(this.getLabelKeyframes(), {
236
- duration: 150,
237
- easing: EASING.STANDARD
238
- });
239
- (_this$labelAnimation2 = this.labelAnimation) === null || _this$labelAnimation2 === void 0 || _this$labelAnimation2.addEventListener('finish', () => {
240
- // At the end of the animation, update the visible label.
241
- this.isAnimating = false;
242
- });
243
- }
244
- getLabelKeyframes() {
245
- const {
246
- floatingLabelEl,
247
- restingLabelEl
248
- } = this;
249
- if (!floatingLabelEl || !restingLabelEl) {
250
- return [];
251
- }
252
- const {
253
- x: floatingX,
254
- y: floatingY,
255
- height: floatingHeight
256
- } = floatingLabelEl.getBoundingClientRect();
257
- const {
258
- x: restingX,
259
- y: restingY,
260
- height: restingHeight
261
- } = restingLabelEl.getBoundingClientRect();
262
- const floatingScrollWidth = floatingLabelEl.scrollWidth;
263
- const restingScrollWidth = restingLabelEl.scrollWidth;
264
- // Scale by width ratio instead of font size since letter-spacing will scale
265
- // incorrectly. Using the width we can better approximate the adjusted
266
- // scale and compensate for tracking and overflow.
267
- // (use scrollWidth instead of width to account for clipped labels)
268
- const scale = restingScrollWidth / floatingScrollWidth;
269
- const xDelta = restingX - floatingX;
270
- // The line-height of the resting and floating label are different. When
271
- // we move the floating label down to the resting label's position, it won't
272
- // exactly match because of this. We need to adjust by half of what the
273
- // final scaled floating label's height will be.
274
- const yDelta = restingY - floatingY + Math.round((restingHeight - floatingHeight * scale) / 2);
275
- // Create the two transforms: floating to resting (using the calculations
276
- // above), and resting to floating (re-setting the transform to initial
277
- // values).
278
- const restTransform = `translateX(${xDelta}px) translateY(${yDelta}px) scale(${scale})`;
279
- const floatTransform = `translateX(0) translateY(0) scale(1)`;
280
- // Constrain the floating labels width to a scaled percentage of the
281
- // resting label's width. This will prevent long clipped labels from
282
- // overflowing the container.
283
- const restingClientWidth = restingLabelEl.clientWidth;
284
- const isRestingClipped = restingScrollWidth > restingClientWidth;
285
- const width = isRestingClipped ? `${restingClientWidth / scale}px` : '';
286
- if (this.focused || this.populated) {
287
- return [{
288
- transform: restTransform,
289
- width
290
- }, {
291
- transform: floatTransform,
292
- width
293
- }];
294
- }
295
- return [{
296
- transform: floatTransform,
297
- width
298
- }, {
299
- transform: restTransform,
300
- width
301
- }];
302
- }
303
- getSurfacePositionClientRect() {
304
- return this.containerEl.getBoundingClientRect();
305
- }
306
- }
307
- __decorate([n$1({
308
- type: Boolean
309
- })], Field.prototype, "disabled", void 0);
310
- __decorate([n$1({
311
- type: Boolean
312
- })], Field.prototype, "error", void 0);
313
- __decorate([n$1({
314
- type: Boolean
315
- })], Field.prototype, "focused", void 0);
316
- __decorate([n$1()], Field.prototype, "label", void 0);
317
- __decorate([n$1({
318
- type: Boolean,
319
- attribute: 'no-asterisk'
320
- })], Field.prototype, "noAsterisk", void 0);
321
- __decorate([n$1({
322
- type: Boolean
323
- })], Field.prototype, "populated", void 0);
324
- __decorate([n$1({
325
- type: Boolean
326
- })], Field.prototype, "required", void 0);
327
- __decorate([n$1({
328
- type: Boolean
329
- })], Field.prototype, "resizable", void 0);
330
- __decorate([n$1({
331
- attribute: 'supporting-text'
332
- })], Field.prototype, "supportingText", void 0);
333
- __decorate([n$1({
334
- attribute: 'error-text'
335
- })], Field.prototype, "errorText", void 0);
336
- __decorate([n$1({
337
- type: Number
338
- })], Field.prototype, "count", void 0);
339
- __decorate([n$1({
340
- type: Number
341
- })], Field.prototype, "max", void 0);
342
- __decorate([n$1({
343
- type: Boolean,
344
- attribute: 'has-start'
345
- })], Field.prototype, "hasStart", void 0);
346
- __decorate([n$1({
347
- type: Boolean,
348
- attribute: 'has-end'
349
- })], Field.prototype, "hasEnd", void 0);
350
- __decorate([o$1({
351
- slot: 'aria-describedby'
352
- })], Field.prototype, "slottedAriaDescribedBy", void 0);
353
- __decorate([r$1()], Field.prototype, "isAnimating", void 0);
354
- __decorate([r$1()], Field.prototype, "refreshErrorAlert", void 0);
355
- __decorate([r$1()], Field.prototype, "disableTransitions", void 0);
356
- __decorate([e('.label.floating')], Field.prototype, "floatingLabelEl", void 0);
357
- __decorate([e('.label.resting')], Field.prototype, "restingLabelEl", void 0);
358
- __decorate([e('.container')], Field.prototype, "containerEl", void 0);
359
-
360
- /**
361
- * @license
362
- * Copyright 2021 Google LLC
363
- * SPDX-License-Identifier: Apache-2.0
364
- */
365
- /**
366
- * An outlined field component.
367
- */
368
- class OutlinedField extends Field {
369
- renderOutline(floatingLabel) {
370
- return b`
371
- <div class="outline">
372
- <div class="outline-start"></div>
373
- <div class="outline-notch">
374
- <div class="outline-panel-inactive"></div>
375
- <div class="outline-panel-active"></div>
376
- <div class="outline-label">${floatingLabel}</div>
377
- </div>
378
- <div class="outline-end"></div>
379
- </div>
380
- `;
381
- }
382
- }
383
-
384
- /**
385
- * @license
386
- * Copyright 2024 Google LLC
387
- * SPDX-License-Identifier: Apache-2.0
388
- */
389
- // Generated stylesheet for ./field/internal/outlined-styles.css.
390
- const styles$3 = i$2`@layer styles{:host{--_bottom-space: var(--md-outlined-field-bottom-space, 16px);--_content-color: var(--md-outlined-field-content-color, var(--md-sys-color-on-surface, #1d1b20));--_content-font: var(--md-outlined-field-content-font, var(--md-sys-typescale-body-large-font, var(--md-ref-typeface-plain, Roboto)));--_content-line-height: var(--md-outlined-field-content-line-height, var(--md-sys-typescale-body-large-line-height, 1.5rem));--_content-size: var(--md-outlined-field-content-size, var(--md-sys-typescale-body-large-size, 1rem));--_content-space: var(--md-outlined-field-content-space, 16px);--_content-weight: var(--md-outlined-field-content-weight, var(--md-sys-typescale-body-large-weight, var(--md-ref-typeface-weight-regular, 400)));--_disabled-content-color: var(--md-outlined-field-disabled-content-color, var(--md-sys-color-on-surface, #1d1b20));--_disabled-content-opacity: var(--md-outlined-field-disabled-content-opacity, 0.38);--_disabled-label-text-color: var(--md-outlined-field-disabled-label-text-color, var(--md-sys-color-on-surface, #1d1b20));--_disabled-label-text-opacity: var(--md-outlined-field-disabled-label-text-opacity, 0.38);--_disabled-leading-content-color: var(--md-outlined-field-disabled-leading-content-color, var(--md-sys-color-on-surface, #1d1b20));--_disabled-leading-content-opacity: var(--md-outlined-field-disabled-leading-content-opacity, 0.38);--_disabled-outline-color: var(--md-outlined-field-disabled-outline-color, var(--md-sys-color-on-surface, #1d1b20));--_disabled-outline-opacity: var(--md-outlined-field-disabled-outline-opacity, 0.12);--_disabled-outline-width: var(--md-outlined-field-disabled-outline-width, 1px);--_disabled-supporting-text-color: var(--md-outlined-field-disabled-supporting-text-color, var(--md-sys-color-on-surface, #1d1b20));--_disabled-supporting-text-opacity: var(--md-outlined-field-disabled-supporting-text-opacity, 0.38);--_disabled-trailing-content-color: var(--md-outlined-field-disabled-trailing-content-color, var(--md-sys-color-on-surface, #1d1b20));--_disabled-trailing-content-opacity: var(--md-outlined-field-disabled-trailing-content-opacity, 0.38);--_error-content-color: var(--md-outlined-field-error-content-color, var(--md-sys-color-on-surface, #1d1b20));--_error-focus-content-color: var(--md-outlined-field-error-focus-content-color, var(--md-sys-color-on-surface, #1d1b20));--_error-focus-label-text-color: var(--md-outlined-field-error-focus-label-text-color, var(--md-sys-color-error, #b3261e));--_error-focus-leading-content-color: var(--md-outlined-field-error-focus-leading-content-color, var(--md-sys-color-on-surface-variant, #49454f));--_error-focus-outline-color: var(--md-outlined-field-error-focus-outline-color, var(--md-sys-color-error, #b3261e));--_error-focus-supporting-text-color: var(--md-outlined-field-error-focus-supporting-text-color, var(--md-sys-color-error, #b3261e));--_error-focus-trailing-content-color: var(--md-outlined-field-error-focus-trailing-content-color, var(--md-sys-color-error, #b3261e));--_error-hover-content-color: var(--md-outlined-field-error-hover-content-color, var(--md-sys-color-on-surface, #1d1b20));--_error-hover-label-text-color: var(--md-outlined-field-error-hover-label-text-color, var(--md-sys-color-on-error-container, #410e0b));--_error-hover-leading-content-color: var(--md-outlined-field-error-hover-leading-content-color, var(--md-sys-color-on-surface-variant, #49454f));--_error-hover-outline-color: var(--md-outlined-field-error-hover-outline-color, var(--md-sys-color-on-error-container, #410e0b));--_error-hover-supporting-text-color: var(--md-outlined-field-error-hover-supporting-text-color, var(--md-sys-color-error, #b3261e));--_error-hover-trailing-content-color: var(--md-outlined-field-error-hover-trailing-content-color, var(--md-sys-color-on-error-container, #410e0b));--_error-label-text-color: var(--md-outlined-field-error-label-text-color, var(--md-sys-color-error, #b3261e));--_error-leading-content-color: var(--md-outlined-field-error-leading-content-color, var(--md-sys-color-on-surface-variant, #49454f));--_error-outline-color: var(--md-outlined-field-error-outline-color, var(--md-sys-color-error, #b3261e));--_error-supporting-text-color: var(--md-outlined-field-error-supporting-text-color, var(--md-sys-color-error, #b3261e));--_error-trailing-content-color: var(--md-outlined-field-error-trailing-content-color, var(--md-sys-color-error, #b3261e));--_focus-content-color: var(--md-outlined-field-focus-content-color, var(--md-sys-color-on-surface, #1d1b20));--_focus-label-text-color: var(--md-outlined-field-focus-label-text-color, var(--md-sys-color-primary, #6750a4));--_focus-leading-content-color: var(--md-outlined-field-focus-leading-content-color, var(--md-sys-color-on-surface-variant, #49454f));--_focus-outline-color: var(--md-outlined-field-focus-outline-color, var(--md-sys-color-primary, #6750a4));--_focus-outline-width: var(--md-outlined-field-focus-outline-width, 3px);--_focus-supporting-text-color: var(--md-outlined-field-focus-supporting-text-color, var(--md-sys-color-on-surface-variant, #49454f));--_focus-trailing-content-color: var(--md-outlined-field-focus-trailing-content-color, var(--md-sys-color-on-surface-variant, #49454f));--_hover-content-color: var(--md-outlined-field-hover-content-color, var(--md-sys-color-on-surface, #1d1b20));--_hover-label-text-color: var(--md-outlined-field-hover-label-text-color, var(--md-sys-color-on-surface, #1d1b20));--_hover-leading-content-color: var(--md-outlined-field-hover-leading-content-color, var(--md-sys-color-on-surface-variant, #49454f));--_hover-outline-color: var(--md-outlined-field-hover-outline-color, var(--md-sys-color-on-surface, #1d1b20));--_hover-outline-width: var(--md-outlined-field-hover-outline-width, 1px);--_hover-supporting-text-color: var(--md-outlined-field-hover-supporting-text-color, var(--md-sys-color-on-surface-variant, #49454f));--_hover-trailing-content-color: var(--md-outlined-field-hover-trailing-content-color, var(--md-sys-color-on-surface-variant, #49454f));--_label-text-color: var(--md-outlined-field-label-text-color, var(--md-sys-color-on-surface-variant, #49454f));--_label-text-font: var(--md-outlined-field-label-text-font, var(--md-sys-typescale-body-large-font, var(--md-ref-typeface-plain, Roboto)));--_label-text-line-height: var(--md-outlined-field-label-text-line-height, var(--md-sys-typescale-body-large-line-height, 1.5rem));--_label-text-padding-bottom: var(--md-outlined-field-label-text-padding-bottom, 8px);--_label-text-populated-line-height: var(--md-outlined-field-label-text-populated-line-height, var(--md-sys-typescale-body-small-line-height, 1rem));--_label-text-populated-size: var(--md-outlined-field-label-text-populated-size, var(--md-sys-typescale-body-small-size, 0.75rem));--_label-text-size: var(--md-outlined-field-label-text-size, var(--md-sys-typescale-body-large-size, 1rem));--_label-text-weight: var(--md-outlined-field-label-text-weight, var(--md-sys-typescale-body-large-weight, var(--md-ref-typeface-weight-regular, 400)));--_leading-content-color: var(--md-outlined-field-leading-content-color, var(--md-sys-color-on-surface-variant, #49454f));--_leading-space: var(--md-outlined-field-leading-space, 16px);--_outline-color: var(--md-outlined-field-outline-color, var(--md-sys-color-outline, #79747e));--_outline-label-padding: var(--md-outlined-field-outline-label-padding, 4px);--_outline-width: var(--md-outlined-field-outline-width, 1px);--_supporting-text-color: var(--md-outlined-field-supporting-text-color, var(--md-sys-color-on-surface-variant, #49454f));--_supporting-text-font: var(--md-outlined-field-supporting-text-font, var(--md-sys-typescale-body-small-font, var(--md-ref-typeface-plain, Roboto)));--_supporting-text-leading-space: var(--md-outlined-field-supporting-text-leading-space, 16px);--_supporting-text-line-height: var(--md-outlined-field-supporting-text-line-height, var(--md-sys-typescale-body-small-line-height, 1rem));--_supporting-text-size: var(--md-outlined-field-supporting-text-size, var(--md-sys-typescale-body-small-size, 0.75rem));--_supporting-text-top-space: var(--md-outlined-field-supporting-text-top-space, 4px);--_supporting-text-trailing-space: var(--md-outlined-field-supporting-text-trailing-space, 16px);--_supporting-text-weight: var(--md-outlined-field-supporting-text-weight, var(--md-sys-typescale-body-small-weight, var(--md-ref-typeface-weight-regular, 400)));--_top-space: var(--md-outlined-field-top-space, 16px);--_trailing-content-color: var(--md-outlined-field-trailing-content-color, var(--md-sys-color-on-surface-variant, #49454f));--_trailing-space: var(--md-outlined-field-trailing-space, 16px);--_with-leading-content-leading-space: var(--md-outlined-field-with-leading-content-leading-space, 12px);--_with-trailing-content-trailing-space: var(--md-outlined-field-with-trailing-content-trailing-space, 12px);--_container-shape-start-start: var(--md-outlined-field-container-shape-start-start, var(--md-outlined-field-container-shape, var(--md-sys-shape-corner-extra-small, 4px)));--_container-shape-start-end: var(--md-outlined-field-container-shape-start-end, var(--md-outlined-field-container-shape, var(--md-sys-shape-corner-extra-small, 4px)));--_container-shape-end-end: var(--md-outlined-field-container-shape-end-end, var(--md-outlined-field-container-shape, var(--md-sys-shape-corner-extra-small, 4px)));--_container-shape-end-start: var(--md-outlined-field-container-shape-end-start, var(--md-outlined-field-container-shape, var(--md-sys-shape-corner-extra-small, 4px)))}.outline{border-color:var(--_outline-color);border-radius:inherit;display:flex;pointer-events:none;height:100%;position:absolute;width:100%;z-index:1}.outline-start::before,.outline-start::after,.outline-panel-inactive::before,.outline-panel-inactive::after,.outline-panel-active::before,.outline-panel-active::after,.outline-end::before,.outline-end::after{border:inherit;content:"";inset:0;position:absolute}.outline-start,.outline-end{border:inherit;border-radius:inherit;box-sizing:border-box;position:relative}.outline-start::before,.outline-start::after,.outline-end::before,.outline-end::after{border-bottom-style:solid;border-top-style:solid}.outline-start::after,.outline-end::after{opacity:0;transition:opacity 150ms cubic-bezier(0.2, 0, 0, 1)}.focused .outline-start::after,.focused .outline-end::after{opacity:1}.outline-start::before,.outline-start::after{border-inline-start-style:solid;border-inline-end-style:none;border-start-start-radius:inherit;border-start-end-radius:0;border-end-start-radius:inherit;border-end-end-radius:0;margin-inline-end:var(--_outline-label-padding)}.outline-end{flex-grow:1;margin-inline-start:calc(-1*var(--_outline-label-padding))}.outline-end::before,.outline-end::after{border-inline-start-style:none;border-inline-end-style:solid;border-start-start-radius:0;border-start-end-radius:inherit;border-end-start-radius:0;border-end-end-radius:inherit}.outline-notch{align-items:flex-start;border:inherit;display:flex;margin-inline-start:calc(-1*var(--_outline-label-padding));margin-inline-end:var(--_outline-label-padding);max-width:calc(100% - var(--_leading-space) - var(--_trailing-space));padding:0 var(--_outline-label-padding);position:relative}.no-label .outline-notch{display:none}.outline-panel-inactive,.outline-panel-active{border:inherit;border-bottom-style:solid;inset:0;position:absolute}.outline-panel-inactive::before,.outline-panel-inactive::after,.outline-panel-active::before,.outline-panel-active::after{border-top-style:solid;border-bottom:none;bottom:auto;transform:scaleX(1);transition:transform 150ms cubic-bezier(0.2, 0, 0, 1)}.outline-panel-inactive::before,.outline-panel-active::before{right:50%;transform-origin:top left}.outline-panel-inactive::after,.outline-panel-active::after{left:50%;transform-origin:top right}.populated .outline-panel-inactive::before,.populated .outline-panel-inactive::after,.populated .outline-panel-active::before,.populated .outline-panel-active::after,.focused .outline-panel-inactive::before,.focused .outline-panel-inactive::after,.focused .outline-panel-active::before,.focused .outline-panel-active::after{transform:scaleX(0)}.outline-panel-active{opacity:0;transition:opacity 150ms cubic-bezier(0.2, 0, 0, 1)}.focused .outline-panel-active{opacity:1}.outline-label{display:flex;max-width:100%;transform:translateY(calc(-100% + var(--_label-text-padding-bottom)))}.outline-start,.field:not(.with-start) .content ::slotted(*){padding-inline-start:max(var(--_leading-space),max(var(--_container-shape-start-start),var(--_container-shape-end-start)) + var(--_outline-label-padding))}.field:not(.with-start) .label-wrapper{margin-inline-start:max(var(--_leading-space),max(var(--_container-shape-start-start),var(--_container-shape-end-start)) + var(--_outline-label-padding))}.field:not(.with-end) .content ::slotted(*){padding-inline-end:max(var(--_trailing-space),max(var(--_container-shape-start-end),var(--_container-shape-end-end)))}.field:not(.with-end) .label-wrapper{margin-inline-end:max(var(--_trailing-space),max(var(--_container-shape-start-end),var(--_container-shape-end-end)))}.outline-start::before,.outline-end::before,.outline-panel-inactive,.outline-panel-inactive::before,.outline-panel-inactive::after{border-width:var(--_outline-width)}:hover .outline{border-color:var(--_hover-outline-color);color:var(--_hover-outline-color)}:hover .outline-start::before,:hover .outline-end::before,:hover .outline-panel-inactive,:hover .outline-panel-inactive::before,:hover .outline-panel-inactive::after{border-width:var(--_hover-outline-width)}.focused .outline{border-color:var(--_focus-outline-color);color:var(--_focus-outline-color)}.outline-start::after,.outline-end::after,.outline-panel-active,.outline-panel-active::before,.outline-panel-active::after{border-width:var(--_focus-outline-width)}.disabled .outline{border-color:var(--_disabled-outline-color);color:var(--_disabled-outline-color)}.disabled .outline-start,.disabled .outline-end,.disabled .outline-panel-inactive{opacity:var(--_disabled-outline-opacity)}.disabled .outline-start::before,.disabled .outline-end::before,.disabled .outline-panel-inactive,.disabled .outline-panel-inactive::before,.disabled .outline-panel-inactive::after{border-width:var(--_disabled-outline-width)}.error .outline{border-color:var(--_error-outline-color);color:var(--_error-outline-color)}.error:hover .outline{border-color:var(--_error-hover-outline-color);color:var(--_error-hover-outline-color)}.error.focused .outline{border-color:var(--_error-focus-outline-color);color:var(--_error-focus-outline-color)}.resizable .container{bottom:var(--_focus-outline-width);inset-inline-end:var(--_focus-outline-width);clip-path:inset(var(--_focus-outline-width) 0 0 var(--_focus-outline-width))}.resizable .container>*{top:var(--_focus-outline-width);inset-inline-start:var(--_focus-outline-width)}.resizable .container:dir(rtl){clip-path:inset(var(--_focus-outline-width) var(--_focus-outline-width) 0 0)}}@layer hcm{@media(forced-colors: active){.disabled .outline{border-color:GrayText;color:GrayText}.disabled :is(.outline-start,.outline-end,.outline-panel-inactive){opacity:1}}}
391
- `;
392
-
393
- /**
394
- * @license
395
- * Copyright 2024 Google LLC
396
- * SPDX-License-Identifier: Apache-2.0
397
- */
398
- // Generated stylesheet for ./field/internal/shared-styles.css.
399
- const styles$2 = i$2`:host{display:inline-flex;resize:both}.field{display:flex;flex:1;flex-direction:column;writing-mode:horizontal-tb;max-width:100%}.container-overflow{border-start-start-radius:var(--_container-shape-start-start);border-start-end-radius:var(--_container-shape-start-end);border-end-end-radius:var(--_container-shape-end-end);border-end-start-radius:var(--_container-shape-end-start);display:flex;height:100%;position:relative}.container{align-items:center;border-radius:inherit;display:flex;flex:1;max-height:100%;min-height:100%;min-width:min-content;position:relative}.field,.container-overflow{resize:inherit}.resizable:not(.disabled) .container{resize:inherit;overflow:hidden}.disabled{pointer-events:none}slot[name=container]{border-radius:inherit}slot[name=container]::slotted(*){border-radius:inherit;inset:0;pointer-events:none;position:absolute}@layer styles{.start,.middle,.end{display:flex;box-sizing:border-box;height:100%;position:relative}.start{color:var(--_leading-content-color)}.end{color:var(--_trailing-content-color)}.start,.end{align-items:center;justify-content:center}.with-start .start{margin-inline:var(--_with-leading-content-leading-space) var(--_content-space)}.with-end .end{margin-inline:var(--_content-space) var(--_with-trailing-content-trailing-space)}.middle{align-items:stretch;align-self:baseline;flex:1}.content{color:var(--_content-color);display:flex;flex:1;opacity:0;transition:opacity 83ms cubic-bezier(0.2, 0, 0, 1)}.no-label .content,.focused .content,.populated .content{opacity:1;transition-delay:67ms}:is(.disabled,.disable-transitions) .content{transition:none}.content ::slotted(*){all:unset;color:currentColor;font-family:var(--_content-font);font-size:var(--_content-size);line-height:var(--_content-line-height);font-weight:var(--_content-weight);width:100%;overflow-wrap:revert;white-space:revert}.content ::slotted(:not(textarea)){padding-top:var(--_top-space);padding-bottom:var(--_bottom-space)}.content ::slotted(textarea){margin-top:var(--_top-space);margin-bottom:var(--_bottom-space)}:hover .content{color:var(--_hover-content-color)}:hover .start{color:var(--_hover-leading-content-color)}:hover .end{color:var(--_hover-trailing-content-color)}.focused .content{color:var(--_focus-content-color)}.focused .start{color:var(--_focus-leading-content-color)}.focused .end{color:var(--_focus-trailing-content-color)}.disabled .content{color:var(--_disabled-content-color)}.disabled.no-label .content,.disabled.focused .content,.disabled.populated .content{opacity:var(--_disabled-content-opacity)}.disabled .start{color:var(--_disabled-leading-content-color);opacity:var(--_disabled-leading-content-opacity)}.disabled .end{color:var(--_disabled-trailing-content-color);opacity:var(--_disabled-trailing-content-opacity)}.error .content{color:var(--_error-content-color)}.error .start{color:var(--_error-leading-content-color)}.error .end{color:var(--_error-trailing-content-color)}.error:hover .content{color:var(--_error-hover-content-color)}.error:hover .start{color:var(--_error-hover-leading-content-color)}.error:hover .end{color:var(--_error-hover-trailing-content-color)}.error.focused .content{color:var(--_error-focus-content-color)}.error.focused .start{color:var(--_error-focus-leading-content-color)}.error.focused .end{color:var(--_error-focus-trailing-content-color)}}@layer hcm{@media(forced-colors: active){.disabled :is(.start,.content,.end){color:GrayText;opacity:1}}}@layer styles{.label{box-sizing:border-box;color:var(--_label-text-color);overflow:hidden;max-width:100%;text-overflow:ellipsis;white-space:nowrap;z-index:1;font-family:var(--_label-text-font);font-size:var(--_label-text-size);line-height:var(--_label-text-line-height);font-weight:var(--_label-text-weight);width:min-content}.label-wrapper{inset:0;pointer-events:none;position:absolute}.label.resting{position:absolute;top:var(--_top-space)}.label.floating{font-size:var(--_label-text-populated-size);line-height:var(--_label-text-populated-line-height);transform-origin:top left}.label.hidden{opacity:0}.no-label .label{display:none}.label-wrapper{inset:0;position:absolute;text-align:initial}:hover .label{color:var(--_hover-label-text-color)}.focused .label{color:var(--_focus-label-text-color)}.disabled .label{color:var(--_disabled-label-text-color)}.disabled .label:not(.hidden){opacity:var(--_disabled-label-text-opacity)}.error .label{color:var(--_error-label-text-color)}.error:hover .label{color:var(--_error-hover-label-text-color)}.error.focused .label{color:var(--_error-focus-label-text-color)}}@layer hcm{@media(forced-colors: active){.disabled .label:not(.hidden){color:GrayText;opacity:1}}}@layer styles{.supporting-text{color:var(--_supporting-text-color);display:flex;font-family:var(--_supporting-text-font);font-size:var(--_supporting-text-size);line-height:var(--_supporting-text-line-height);font-weight:var(--_supporting-text-weight);gap:16px;justify-content:space-between;padding-inline-start:var(--_supporting-text-leading-space);padding-inline-end:var(--_supporting-text-trailing-space);padding-top:var(--_supporting-text-top-space)}.supporting-text :nth-child(2){flex-shrink:0}:hover .supporting-text{color:var(--_hover-supporting-text-color)}.focus .supporting-text{color:var(--_focus-supporting-text-color)}.disabled .supporting-text{color:var(--_disabled-supporting-text-color);opacity:var(--_disabled-supporting-text-opacity)}.error .supporting-text{color:var(--_error-supporting-text-color)}.error:hover .supporting-text{color:var(--_error-hover-supporting-text-color)}.error.focus .supporting-text{color:var(--_error-focus-supporting-text-color)}}@layer hcm{@media(forced-colors: active){.disabled .supporting-text{color:GrayText;opacity:1}}}
400
- `;
401
-
402
- /**
403
- * @license
404
- * Copyright 2021 Google LLC
405
- * SPDX-License-Identifier: Apache-2.0
406
- */
407
- /**
408
- * TODO(b/228525797): add docs
409
- * @final
410
- * @suppress {visibility}
411
- */
412
- let MdOutlinedField = class MdOutlinedField extends OutlinedField {};
413
- MdOutlinedField.styles = [styles$2, styles$3];
414
- MdOutlinedField = __decorate([t('md-outlined-field')], MdOutlinedField);
415
-
416
- /**
417
- * @license
418
- * Copyright 2024 Google LLC
419
- * SPDX-License-Identifier: Apache-2.0
420
- */
421
- // Generated stylesheet for ./textfield/internal/outlined-styles.css.
422
- const styles$1 = i$2`:host{--_caret-color: var(--md-outlined-text-field-caret-color, var(--md-sys-color-primary, #6750a4));--_disabled-input-text-color: var(--md-outlined-text-field-disabled-input-text-color, var(--md-sys-color-on-surface, #1d1b20));--_disabled-input-text-opacity: var(--md-outlined-text-field-disabled-input-text-opacity, 0.38);--_disabled-label-text-color: var(--md-outlined-text-field-disabled-label-text-color, var(--md-sys-color-on-surface, #1d1b20));--_disabled-label-text-opacity: var(--md-outlined-text-field-disabled-label-text-opacity, 0.38);--_disabled-leading-icon-color: var(--md-outlined-text-field-disabled-leading-icon-color, var(--md-sys-color-on-surface, #1d1b20));--_disabled-leading-icon-opacity: var(--md-outlined-text-field-disabled-leading-icon-opacity, 0.38);--_disabled-outline-color: var(--md-outlined-text-field-disabled-outline-color, var(--md-sys-color-on-surface, #1d1b20));--_disabled-outline-opacity: var(--md-outlined-text-field-disabled-outline-opacity, 0.12);--_disabled-outline-width: var(--md-outlined-text-field-disabled-outline-width, 1px);--_disabled-supporting-text-color: var(--md-outlined-text-field-disabled-supporting-text-color, var(--md-sys-color-on-surface, #1d1b20));--_disabled-supporting-text-opacity: var(--md-outlined-text-field-disabled-supporting-text-opacity, 0.38);--_disabled-trailing-icon-color: var(--md-outlined-text-field-disabled-trailing-icon-color, var(--md-sys-color-on-surface, #1d1b20));--_disabled-trailing-icon-opacity: var(--md-outlined-text-field-disabled-trailing-icon-opacity, 0.38);--_error-focus-caret-color: var(--md-outlined-text-field-error-focus-caret-color, var(--md-sys-color-error, #b3261e));--_error-focus-input-text-color: var(--md-outlined-text-field-error-focus-input-text-color, var(--md-sys-color-on-surface, #1d1b20));--_error-focus-label-text-color: var(--md-outlined-text-field-error-focus-label-text-color, var(--md-sys-color-error, #b3261e));--_error-focus-leading-icon-color: var(--md-outlined-text-field-error-focus-leading-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_error-focus-outline-color: var(--md-outlined-text-field-error-focus-outline-color, var(--md-sys-color-error, #b3261e));--_error-focus-supporting-text-color: var(--md-outlined-text-field-error-focus-supporting-text-color, var(--md-sys-color-error, #b3261e));--_error-focus-trailing-icon-color: var(--md-outlined-text-field-error-focus-trailing-icon-color, var(--md-sys-color-error, #b3261e));--_error-hover-input-text-color: var(--md-outlined-text-field-error-hover-input-text-color, var(--md-sys-color-on-surface, #1d1b20));--_error-hover-label-text-color: var(--md-outlined-text-field-error-hover-label-text-color, var(--md-sys-color-on-error-container, #410e0b));--_error-hover-leading-icon-color: var(--md-outlined-text-field-error-hover-leading-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_error-hover-outline-color: var(--md-outlined-text-field-error-hover-outline-color, var(--md-sys-color-on-error-container, #410e0b));--_error-hover-supporting-text-color: var(--md-outlined-text-field-error-hover-supporting-text-color, var(--md-sys-color-error, #b3261e));--_error-hover-trailing-icon-color: var(--md-outlined-text-field-error-hover-trailing-icon-color, var(--md-sys-color-on-error-container, #410e0b));--_error-input-text-color: var(--md-outlined-text-field-error-input-text-color, var(--md-sys-color-on-surface, #1d1b20));--_error-label-text-color: var(--md-outlined-text-field-error-label-text-color, var(--md-sys-color-error, #b3261e));--_error-leading-icon-color: var(--md-outlined-text-field-error-leading-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_error-outline-color: var(--md-outlined-text-field-error-outline-color, var(--md-sys-color-error, #b3261e));--_error-supporting-text-color: var(--md-outlined-text-field-error-supporting-text-color, var(--md-sys-color-error, #b3261e));--_error-trailing-icon-color: var(--md-outlined-text-field-error-trailing-icon-color, var(--md-sys-color-error, #b3261e));--_focus-input-text-color: var(--md-outlined-text-field-focus-input-text-color, var(--md-sys-color-on-surface, #1d1b20));--_focus-label-text-color: var(--md-outlined-text-field-focus-label-text-color, var(--md-sys-color-primary, #6750a4));--_focus-leading-icon-color: var(--md-outlined-text-field-focus-leading-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_focus-outline-color: var(--md-outlined-text-field-focus-outline-color, var(--md-sys-color-primary, #6750a4));--_focus-outline-width: var(--md-outlined-text-field-focus-outline-width, 3px);--_focus-supporting-text-color: var(--md-outlined-text-field-focus-supporting-text-color, var(--md-sys-color-on-surface-variant, #49454f));--_focus-trailing-icon-color: var(--md-outlined-text-field-focus-trailing-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_hover-input-text-color: var(--md-outlined-text-field-hover-input-text-color, var(--md-sys-color-on-surface, #1d1b20));--_hover-label-text-color: var(--md-outlined-text-field-hover-label-text-color, var(--md-sys-color-on-surface, #1d1b20));--_hover-leading-icon-color: var(--md-outlined-text-field-hover-leading-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_hover-outline-color: var(--md-outlined-text-field-hover-outline-color, var(--md-sys-color-on-surface, #1d1b20));--_hover-outline-width: var(--md-outlined-text-field-hover-outline-width, 1px);--_hover-supporting-text-color: var(--md-outlined-text-field-hover-supporting-text-color, var(--md-sys-color-on-surface-variant, #49454f));--_hover-trailing-icon-color: var(--md-outlined-text-field-hover-trailing-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_input-text-color: var(--md-outlined-text-field-input-text-color, var(--md-sys-color-on-surface, #1d1b20));--_input-text-font: var(--md-outlined-text-field-input-text-font, var(--md-sys-typescale-body-large-font, var(--md-ref-typeface-plain, Roboto)));--_input-text-line-height: var(--md-outlined-text-field-input-text-line-height, var(--md-sys-typescale-body-large-line-height, 1.5rem));--_input-text-placeholder-color: var(--md-outlined-text-field-input-text-placeholder-color, var(--md-sys-color-on-surface-variant, #49454f));--_input-text-prefix-color: var(--md-outlined-text-field-input-text-prefix-color, var(--md-sys-color-on-surface-variant, #49454f));--_input-text-size: var(--md-outlined-text-field-input-text-size, var(--md-sys-typescale-body-large-size, 1rem));--_input-text-suffix-color: var(--md-outlined-text-field-input-text-suffix-color, var(--md-sys-color-on-surface-variant, #49454f));--_input-text-weight: var(--md-outlined-text-field-input-text-weight, var(--md-sys-typescale-body-large-weight, var(--md-ref-typeface-weight-regular, 400)));--_label-text-color: var(--md-outlined-text-field-label-text-color, var(--md-sys-color-on-surface-variant, #49454f));--_label-text-font: var(--md-outlined-text-field-label-text-font, var(--md-sys-typescale-body-large-font, var(--md-ref-typeface-plain, Roboto)));--_label-text-line-height: var(--md-outlined-text-field-label-text-line-height, var(--md-sys-typescale-body-large-line-height, 1.5rem));--_label-text-populated-line-height: var(--md-outlined-text-field-label-text-populated-line-height, var(--md-sys-typescale-body-small-line-height, 1rem));--_label-text-populated-size: var(--md-outlined-text-field-label-text-populated-size, var(--md-sys-typescale-body-small-size, 0.75rem));--_label-text-size: var(--md-outlined-text-field-label-text-size, var(--md-sys-typescale-body-large-size, 1rem));--_label-text-weight: var(--md-outlined-text-field-label-text-weight, var(--md-sys-typescale-body-large-weight, var(--md-ref-typeface-weight-regular, 400)));--_leading-icon-color: var(--md-outlined-text-field-leading-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_leading-icon-size: var(--md-outlined-text-field-leading-icon-size, 24px);--_outline-color: var(--md-outlined-text-field-outline-color, var(--md-sys-color-outline, #79747e));--_outline-width: var(--md-outlined-text-field-outline-width, 1px);--_supporting-text-color: var(--md-outlined-text-field-supporting-text-color, var(--md-sys-color-on-surface-variant, #49454f));--_supporting-text-font: var(--md-outlined-text-field-supporting-text-font, var(--md-sys-typescale-body-small-font, var(--md-ref-typeface-plain, Roboto)));--_supporting-text-line-height: var(--md-outlined-text-field-supporting-text-line-height, var(--md-sys-typescale-body-small-line-height, 1rem));--_supporting-text-size: var(--md-outlined-text-field-supporting-text-size, var(--md-sys-typescale-body-small-size, 0.75rem));--_supporting-text-weight: var(--md-outlined-text-field-supporting-text-weight, var(--md-sys-typescale-body-small-weight, var(--md-ref-typeface-weight-regular, 400)));--_trailing-icon-color: var(--md-outlined-text-field-trailing-icon-color, var(--md-sys-color-on-surface-variant, #49454f));--_trailing-icon-size: var(--md-outlined-text-field-trailing-icon-size, 24px);--_container-shape-start-start: var(--md-outlined-text-field-container-shape-start-start, var(--md-outlined-text-field-container-shape, var(--md-sys-shape-corner-extra-small, 4px)));--_container-shape-start-end: var(--md-outlined-text-field-container-shape-start-end, var(--md-outlined-text-field-container-shape, var(--md-sys-shape-corner-extra-small, 4px)));--_container-shape-end-end: var(--md-outlined-text-field-container-shape-end-end, var(--md-outlined-text-field-container-shape, var(--md-sys-shape-corner-extra-small, 4px)));--_container-shape-end-start: var(--md-outlined-text-field-container-shape-end-start, var(--md-outlined-text-field-container-shape, var(--md-sys-shape-corner-extra-small, 4px)));--_icon-input-space: var(--md-outlined-text-field-icon-input-space, 16px);--_leading-space: var(--md-outlined-text-field-leading-space, 16px);--_trailing-space: var(--md-outlined-text-field-trailing-space, 16px);--_top-space: var(--md-outlined-text-field-top-space, 16px);--_bottom-space: var(--md-outlined-text-field-bottom-space, 16px);--_input-text-prefix-trailing-space: var(--md-outlined-text-field-input-text-prefix-trailing-space, 2px);--_input-text-suffix-leading-space: var(--md-outlined-text-field-input-text-suffix-leading-space, 2px);--_focus-caret-color: var(--md-outlined-text-field-focus-caret-color, var(--md-sys-color-primary, #6750a4));--_with-leading-icon-leading-space: var(--md-outlined-text-field-with-leading-icon-leading-space, 12px);--_with-trailing-icon-trailing-space: var(--md-outlined-text-field-with-trailing-icon-trailing-space, 12px);--md-outlined-field-bottom-space: var(--_bottom-space);--md-outlined-field-container-shape-end-end: var(--_container-shape-end-end);--md-outlined-field-container-shape-end-start: var(--_container-shape-end-start);--md-outlined-field-container-shape-start-end: var(--_container-shape-start-end);--md-outlined-field-container-shape-start-start: var(--_container-shape-start-start);--md-outlined-field-content-color: var(--_input-text-color);--md-outlined-field-content-font: var(--_input-text-font);--md-outlined-field-content-line-height: var(--_input-text-line-height);--md-outlined-field-content-size: var(--_input-text-size);--md-outlined-field-content-space: var(--_icon-input-space);--md-outlined-field-content-weight: var(--_input-text-weight);--md-outlined-field-disabled-content-color: var(--_disabled-input-text-color);--md-outlined-field-disabled-content-opacity: var(--_disabled-input-text-opacity);--md-outlined-field-disabled-label-text-color: var(--_disabled-label-text-color);--md-outlined-field-disabled-label-text-opacity: var(--_disabled-label-text-opacity);--md-outlined-field-disabled-leading-content-color: var(--_disabled-leading-icon-color);--md-outlined-field-disabled-leading-content-opacity: var(--_disabled-leading-icon-opacity);--md-outlined-field-disabled-outline-color: var(--_disabled-outline-color);--md-outlined-field-disabled-outline-opacity: var(--_disabled-outline-opacity);--md-outlined-field-disabled-outline-width: var(--_disabled-outline-width);--md-outlined-field-disabled-supporting-text-color: var(--_disabled-supporting-text-color);--md-outlined-field-disabled-supporting-text-opacity: var(--_disabled-supporting-text-opacity);--md-outlined-field-disabled-trailing-content-color: var(--_disabled-trailing-icon-color);--md-outlined-field-disabled-trailing-content-opacity: var(--_disabled-trailing-icon-opacity);--md-outlined-field-error-content-color: var(--_error-input-text-color);--md-outlined-field-error-focus-content-color: var(--_error-focus-input-text-color);--md-outlined-field-error-focus-label-text-color: var(--_error-focus-label-text-color);--md-outlined-field-error-focus-leading-content-color: var(--_error-focus-leading-icon-color);--md-outlined-field-error-focus-outline-color: var(--_error-focus-outline-color);--md-outlined-field-error-focus-supporting-text-color: var(--_error-focus-supporting-text-color);--md-outlined-field-error-focus-trailing-content-color: var(--_error-focus-trailing-icon-color);--md-outlined-field-error-hover-content-color: var(--_error-hover-input-text-color);--md-outlined-field-error-hover-label-text-color: var(--_error-hover-label-text-color);--md-outlined-field-error-hover-leading-content-color: var(--_error-hover-leading-icon-color);--md-outlined-field-error-hover-outline-color: var(--_error-hover-outline-color);--md-outlined-field-error-hover-supporting-text-color: var(--_error-hover-supporting-text-color);--md-outlined-field-error-hover-trailing-content-color: var(--_error-hover-trailing-icon-color);--md-outlined-field-error-label-text-color: var(--_error-label-text-color);--md-outlined-field-error-leading-content-color: var(--_error-leading-icon-color);--md-outlined-field-error-outline-color: var(--_error-outline-color);--md-outlined-field-error-supporting-text-color: var(--_error-supporting-text-color);--md-outlined-field-error-trailing-content-color: var(--_error-trailing-icon-color);--md-outlined-field-focus-content-color: var(--_focus-input-text-color);--md-outlined-field-focus-label-text-color: var(--_focus-label-text-color);--md-outlined-field-focus-leading-content-color: var(--_focus-leading-icon-color);--md-outlined-field-focus-outline-color: var(--_focus-outline-color);--md-outlined-field-focus-outline-width: var(--_focus-outline-width);--md-outlined-field-focus-supporting-text-color: var(--_focus-supporting-text-color);--md-outlined-field-focus-trailing-content-color: var(--_focus-trailing-icon-color);--md-outlined-field-hover-content-color: var(--_hover-input-text-color);--md-outlined-field-hover-label-text-color: var(--_hover-label-text-color);--md-outlined-field-hover-leading-content-color: var(--_hover-leading-icon-color);--md-outlined-field-hover-outline-color: var(--_hover-outline-color);--md-outlined-field-hover-outline-width: var(--_hover-outline-width);--md-outlined-field-hover-supporting-text-color: var(--_hover-supporting-text-color);--md-outlined-field-hover-trailing-content-color: var(--_hover-trailing-icon-color);--md-outlined-field-label-text-color: var(--_label-text-color);--md-outlined-field-label-text-font: var(--_label-text-font);--md-outlined-field-label-text-line-height: var(--_label-text-line-height);--md-outlined-field-label-text-populated-line-height: var(--_label-text-populated-line-height);--md-outlined-field-label-text-populated-size: var(--_label-text-populated-size);--md-outlined-field-label-text-size: var(--_label-text-size);--md-outlined-field-label-text-weight: var(--_label-text-weight);--md-outlined-field-leading-content-color: var(--_leading-icon-color);--md-outlined-field-leading-space: var(--_leading-space);--md-outlined-field-outline-color: var(--_outline-color);--md-outlined-field-outline-width: var(--_outline-width);--md-outlined-field-supporting-text-color: var(--_supporting-text-color);--md-outlined-field-supporting-text-font: var(--_supporting-text-font);--md-outlined-field-supporting-text-line-height: var(--_supporting-text-line-height);--md-outlined-field-supporting-text-size: var(--_supporting-text-size);--md-outlined-field-supporting-text-weight: var(--_supporting-text-weight);--md-outlined-field-top-space: var(--_top-space);--md-outlined-field-trailing-content-color: var(--_trailing-icon-color);--md-outlined-field-trailing-space: var(--_trailing-space);--md-outlined-field-with-leading-content-leading-space: var(--_with-leading-icon-leading-space);--md-outlined-field-with-trailing-content-trailing-space: var(--_with-trailing-icon-trailing-space)}
423
- `;
424
-
425
- /**
426
- * @license
427
- * Copyright 2020 Google LLC
428
- * SPDX-License-Identifier: BSD-3-Clause
429
- */
430
- const r = o => void 0 === o.strings,
431
- m = {},
432
- p = (o, t = m) => o._$AH = t;
433
-
434
- /**
435
- * @license
436
- * Copyright 2020 Google LLC
437
- * SPDX-License-Identifier: BSD-3-Clause
438
- */
439
- const l = e$2(class extends i$3 {
440
- constructor(r$1) {
441
- if (super(r$1), r$1.type !== t$1.PROPERTY && r$1.type !== t$1.ATTRIBUTE && r$1.type !== t$1.BOOLEAN_ATTRIBUTE) throw Error("The `live` directive is not allowed on child or event bindings");
442
- if (!r(r$1)) throw Error("`live` bindings can only contain a single expression");
443
- }
444
- render(r) {
445
- return r;
446
- }
447
- update(i, [t]) {
448
- if (t === E || t === A) return t;
449
- const o = i.element,
450
- l = i.name;
451
- if (i.type === t$1.PROPERTY) {
452
- if (t === o[l]) return E;
453
- } else if (i.type === t$1.BOOLEAN_ATTRIBUTE) {
454
- if (!!t === o.hasAttribute(l)) return E;
455
- } else if (i.type === t$1.ATTRIBUTE && o.getAttribute(l) === t + "") return E;
456
- return p(i), t;
457
- }
458
- });
459
-
460
- /**
461
- * @license
462
- * Copyright 2018 Google LLC
463
- * SPDX-License-Identifier: BSD-3-Clause
464
- */
465
- const n = "important",
466
- i = " !" + n,
467
- o = e$2(class extends i$3 {
468
- constructor(t) {
469
- var _t$strings;
470
- if (super(t), t.type !== t$1.ATTRIBUTE || "style" !== t.name || ((_t$strings = t.strings) === null || _t$strings === void 0 ? void 0 : _t$strings.length) > 2) throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.");
471
- }
472
- render(t) {
473
- return Object.keys(t).reduce((e, r) => {
474
- const s = t[r];
475
- return null == s ? e : e + `${r = r.includes("-") ? r : r.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g, "-$&").toLowerCase()}:${s};`;
476
- }, "");
477
- }
478
- update(e, [r]) {
479
- const {
480
- style: s
481
- } = e.element;
482
- if (void 0 === this.ft) return this.ft = new Set(Object.keys(r)), this.render(r);
483
- for (const t of this.ft) null == r[t] && (this.ft.delete(t), t.includes("-") ? s.removeProperty(t) : s[t] = null);
484
- for (const t in r) {
485
- const e = r[t];
486
- if (null != e) {
487
- this.ft.add(t);
488
- const r = "string" == typeof e && e.endsWith(i);
489
- t.includes("-") || r ? s.setProperty(t, r ? e.slice(0, -11) : e, r ? n : "") : s[t] = e;
490
- }
491
- }
492
- return E;
493
- }
494
- });
495
-
496
- /**
497
- * @license
498
- * Copyright 2022 Google LLC
499
- * SPDX-License-Identifier: Apache-2.0
500
- */
501
- const stringConverter = {
502
- fromAttribute(value) {
503
- return value ?? '';
504
- },
505
- toAttribute(value) {
506
- return value || null;
507
- }
508
- };
509
-
510
- /**
511
- * @license
512
- * Copyright 2023 Google LLC
513
- * SPDX-License-Identifier: Apache-2.0
514
- */
515
- /**
516
- * A symbol property used to create a constraint validation `Validator`.
517
- * Required for all `mixinConstraintValidation()` elements.
518
- */
519
- const createValidator = Symbol('createValidator');
520
- /**
521
- * A symbol property used to return an anchor for constraint validation popups.
522
- * Required for all `mixinConstraintValidation()` elements.
523
- */
524
- const getValidityAnchor = Symbol('getValidityAnchor');
525
- // Private symbol members, used to avoid name clashing.
526
- const privateValidator = Symbol('privateValidator');
527
- const privateSyncValidity = Symbol('privateSyncValidity');
528
- const privateCustomValidationMessage = Symbol('privateCustomValidationMessage');
529
- /**
530
- * Mixes in constraint validation APIs for an element.
531
- *
532
- * See https://developer.mozilla.org/en-US/docs/Web/HTML/Constraint_validation
533
- * for more details.
534
- *
535
- * Implementations must provide a validator to cache and compute its validity,
536
- * along with a shadow root element to anchor validation popups to.
537
- *
538
- * @example
539
- * ```ts
540
- * const baseClass = mixinConstraintValidation(
541
- * mixinFormAssociated(mixinElementInternals(LitElement))
542
- * );
543
- *
544
- * class MyCheckbox extends baseClass {
545
- * \@property({type: Boolean}) checked = false;
546
- * \@property({type: Boolean}) required = false;
547
- *
548
- * [createValidator]() {
549
- * return new CheckboxValidator(() => this);
550
- * }
551
- *
552
- * [getValidityAnchor]() {
553
- * return this.renderRoot.querySelector('.root');
554
- * }
555
- * }
556
- * ```
557
- *
558
- * @param base The class to mix functionality into.
559
- * @return The provided class with `ConstraintValidation` mixed in.
560
- */
561
- function mixinConstraintValidation(base) {
562
- var _a;
563
- class ConstraintValidationElement extends base {
564
- constructor() {
565
- super(...arguments);
566
- /**
567
- * Needed for Safari, see https://bugs.webkit.org/show_bug.cgi?id=261432
568
- * Replace with this[internals].validity.customError when resolved.
569
- */
570
- this[_a] = '';
571
- }
572
- get validity() {
573
- this[privateSyncValidity]();
574
- return this[internals].validity;
575
- }
576
- get validationMessage() {
577
- this[privateSyncValidity]();
578
- return this[internals].validationMessage;
579
- }
580
- get willValidate() {
581
- this[privateSyncValidity]();
582
- return this[internals].willValidate;
583
- }
584
- checkValidity() {
585
- this[privateSyncValidity]();
586
- return this[internals].checkValidity();
587
- }
588
- reportValidity() {
589
- this[privateSyncValidity]();
590
- return this[internals].reportValidity();
591
- }
592
- setCustomValidity(error) {
593
- this[privateCustomValidationMessage] = error;
594
- this[privateSyncValidity]();
595
- }
596
- requestUpdate(name, oldValue, options) {
597
- super.requestUpdate(name, oldValue, options);
598
- this[privateSyncValidity]();
599
- }
600
- firstUpdated(changed) {
601
- super.firstUpdated(changed);
602
- // Sync the validity again when the element first renders, since the
603
- // validity anchor is now available.
604
- //
605
- // Elements that `delegatesFocus: true` to an `<input>` will throw an
606
- // error in Chrome and Safari when a form tries to submit or call
607
- // `form.reportValidity()`:
608
- // "An invalid form control with name='' is not focusable"
609
- //
610
- // The validity anchor MUST be provided in `internals.setValidity()` and
611
- // MUST be the `<input>` element rendered.
612
- //
613
- // See https://lit.dev/playground/#gist=6c26e418e0010f7a5aac15005cde8bde
614
- // for a reproduction.
615
- this[privateSyncValidity]();
616
- }
617
- [(_a = privateCustomValidationMessage, privateSyncValidity)]() {
618
- if (!this[privateValidator]) {
619
- this[privateValidator] = this[createValidator]();
620
- }
621
- const {
622
- validity,
623
- validationMessage: nonCustomValidationMessage
624
- } = this[privateValidator].getValidity();
625
- const customError = !!this[privateCustomValidationMessage];
626
- const validationMessage = this[privateCustomValidationMessage] || nonCustomValidationMessage;
627
- this[internals].setValidity({
628
- ...validity,
629
- customError
630
- }, validationMessage, this[getValidityAnchor]() ?? undefined);
631
- }
632
- [createValidator]() {
633
- throw new Error('Implement [createValidator]');
634
- }
635
- [getValidityAnchor]() {
636
- throw new Error('Implement [getValidityAnchor]');
637
- }
638
- }
639
- return ConstraintValidationElement;
640
- }
641
-
642
- /**
643
- * @license
644
- * Copyright 2023 Google LLC
645
- * SPDX-License-Identifier: Apache-2.0
646
- */
647
- /**
648
- * A symbol property to retrieve the form value for an element.
649
- */
650
- const getFormValue = Symbol('getFormValue');
651
- /**
652
- * A symbol property to retrieve the form state for an element.
653
- */
654
- const getFormState = Symbol('getFormState');
655
- /**
656
- * Mixes in form-associated behavior for a class. This allows an element to add
657
- * values to `<form>` elements.
658
- *
659
- * Implementing classes should provide a `[formValue]` to return the current
660
- * value of the element, as well as reset and restore callbacks.
661
- *
662
- * @example
663
- * ```ts
664
- * const base = mixinFormAssociated(mixinElementInternals(LitElement));
665
- *
666
- * class MyControl extends base {
667
- * \@property()
668
- * value = '';
669
- *
670
- * override [getFormValue]() {
671
- * return this.value;
672
- * }
673
- *
674
- * override formResetCallback() {
675
- * const defaultValue = this.getAttribute('value');
676
- * this.value = defaultValue;
677
- * }
678
- *
679
- * override formStateRestoreCallback(state: string) {
680
- * this.value = state;
681
- * }
682
- * }
683
- * ```
684
- *
685
- * Elements may optionally provide a `[formState]` if their values do not
686
- * represent the state of the component.
687
- *
688
- * @example
689
- * ```ts
690
- * const base = mixinFormAssociated(mixinElementInternals(LitElement));
691
- *
692
- * class MyCheckbox extends base {
693
- * \@property()
694
- * value = 'on';
695
- *
696
- * \@property({type: Boolean})
697
- * checked = false;
698
- *
699
- * override [getFormValue]() {
700
- * return this.checked ? this.value : null;
701
- * }
702
- *
703
- * override [getFormState]() {
704
- * return String(this.checked);
705
- * }
706
- *
707
- * override formResetCallback() {
708
- * const defaultValue = this.hasAttribute('checked');
709
- * this.checked = defaultValue;
710
- * }
711
- *
712
- * override formStateRestoreCallback(state: string) {
713
- * this.checked = Boolean(state);
714
- * }
715
- * }
716
- * ```
717
- *
718
- * IMPORTANT: Requires declares for lit-analyzer
719
- * @example
720
- * ```ts
721
- * const base = mixinFormAssociated(mixinElementInternals(LitElement));
722
- * class MyControl extends base {
723
- * // Writable mixin properties for lit-html binding, needed for lit-analyzer
724
- * declare disabled: boolean;
725
- * declare name: string;
726
- * }
727
- * ```
728
- *
729
- * @param base The class to mix functionality into. The base class must use
730
- * `mixinElementInternals()`.
731
- * @return The provided class with `FormAssociated` mixed in.
732
- */
733
- function mixinFormAssociated(base) {
734
- class FormAssociatedElement extends base {
735
- get form() {
736
- return this[internals].form;
737
- }
738
- get labels() {
739
- return this[internals].labels;
740
- }
741
- // Use @property for the `name` and `disabled` properties to add them to the
742
- // `observedAttributes` array and trigger `attributeChangedCallback()`.
743
- //
744
- // We don't use Lit's default getter/setter (`noAccessor: true`) because
745
- // the attributes need to be updated synchronously to work with synchronous
746
- // form APIs, and Lit updates attributes async by default.
747
- get name() {
748
- return this.getAttribute('name') ?? '';
749
- }
750
- set name(name) {
751
- // Note: setting name to null or empty does not remove the attribute.
752
- this.setAttribute('name', name);
753
- // We don't need to call `requestUpdate()` since it's called synchronously
754
- // in `attributeChangedCallback()`.
755
- }
756
- get disabled() {
757
- return this.hasAttribute('disabled');
758
- }
759
- set disabled(disabled) {
760
- this.toggleAttribute('disabled', disabled);
761
- // We don't need to call `requestUpdate()` since it's called synchronously
762
- // in `attributeChangedCallback()`.
763
- }
764
- attributeChangedCallback(name, old, value) {
765
- // Manually `requestUpdate()` for `name` and `disabled` when their
766
- // attribute or property changes.
767
- // The properties update their attributes, so this callback is invoked
768
- // immediately when the properties are set. We call `requestUpdate()` here
769
- // instead of letting Lit set the properties from the attribute change.
770
- // That would cause the properties to re-set the attribute and invoke this
771
- // callback again in a loop. This leads to stale state when Lit tries to
772
- // determine if a property changed or not.
773
- if (name === 'name' || name === 'disabled') {
774
- // Disabled's value is only false if the attribute is missing and null.
775
- const oldValue = name === 'disabled' ? old !== null : old;
776
- // Trigger a lit update when the attribute changes.
777
- this.requestUpdate(name, oldValue);
778
- return;
779
- }
780
- super.attributeChangedCallback(name, old, value);
781
- }
782
- requestUpdate(name, oldValue, options) {
783
- super.requestUpdate(name, oldValue, options);
784
- // If any properties change, update the form value, which may have changed
785
- // as well.
786
- // Update the form value synchronously in `requestUpdate()` rather than
787
- // `update()` or `updated()`, which are async. This is necessary to ensure
788
- // that form data is updated in time for synchronous event listeners.
789
- this[internals].setFormValue(this[getFormValue](), this[getFormState]());
790
- }
791
- [getFormValue]() {
792
- // Closure does not allow abstract symbol members, so a default
793
- // implementation is needed.
794
- throw new Error('Implement [getFormValue]');
795
- }
796
- [getFormState]() {
797
- return this[getFormValue]();
798
- }
799
- formDisabledCallback(disabled) {
800
- this.disabled = disabled;
801
- }
802
- }
803
- /** @nocollapse */
804
- FormAssociatedElement.formAssociated = true;
805
- __decorate([n$1({
806
- noAccessor: true
807
- })], FormAssociatedElement.prototype, "name", null);
808
- __decorate([n$1({
809
- type: Boolean,
810
- noAccessor: true
811
- })], FormAssociatedElement.prototype, "disabled", null);
812
- return FormAssociatedElement;
813
- }
814
-
815
- /**
816
- * @license
817
- * Copyright 2023 Google LLC
818
- * SPDX-License-Identifier: Apache-2.0
819
- */
820
- /**
821
- * A symbol property used for a callback when validity has been reported.
822
- */
823
- const onReportValidity = Symbol('onReportValidity');
824
- // Private symbol members, used to avoid name clashing.
825
- const privateCleanupFormListeners = Symbol('privateCleanupFormListeners');
826
- const privateDoNotReportInvalid = Symbol('privateDoNotReportInvalid');
827
- const privateIsSelfReportingValidity = Symbol('privateIsSelfReportingValidity');
828
- const privateCallOnReportValidity = Symbol('privateCallOnReportValidity');
829
- /**
830
- * Mixes in a callback for constraint validation when validity should be
831
- * styled and reported to the user.
832
- *
833
- * This is commonly used in text-field-like controls that display error styles
834
- * and error messages.
835
- *
836
- * @example
837
- * ```ts
838
- * const baseClass = mixinOnReportValidity(
839
- * mixinConstraintValidation(
840
- * mixinFormAssociated(mixinElementInternals(LitElement)),
841
- * ),
842
- * );
843
- *
844
- * class MyField extends baseClass {
845
- * \@property({type: Boolean}) error = false;
846
- * \@property() errorMessage = '';
847
- *
848
- * [onReportValidity](invalidEvent: Event | null) {
849
- * this.error = !!invalidEvent;
850
- * this.errorMessage = this.validationMessage;
851
- *
852
- * // Optionally prevent platform popup from displaying
853
- * invalidEvent?.preventDefault();
854
- * }
855
- * }
856
- * ```
857
- *
858
- * @param base The class to mix functionality into.
859
- * @return The provided class with `OnReportValidity` mixed in.
860
- */
861
- function mixinOnReportValidity(base) {
862
- var _a, _b, _c;
863
- class OnReportValidityElement extends base {
864
- // Mixins must have a constructor with `...args: any[]`
865
- // tslint:disable-next-line:no-any
866
- constructor(...args) {
867
- super(...args);
868
- /**
869
- * Used to clean up event listeners when a new form is associated.
870
- */
871
- this[_a] = new AbortController();
872
- /**
873
- * Used to determine if an invalid event should report validity. Invalid
874
- * events from `checkValidity()` do not trigger reporting.
875
- */
876
- this[_b] = false;
877
- /**
878
- * Used to determine if the control is reporting validity from itself, or
879
- * if a `<form>` is causing the validity report. Forms have different
880
- * control focusing behavior.
881
- */
882
- this[_c] = false;
883
- this.addEventListener('invalid', invalidEvent => {
884
- // Listen for invalid events dispatched by a `<form>` when it tries to
885
- // submit and the element is invalid. We ignore events dispatched when
886
- // calling `checkValidity()` as well as untrusted events, since the
887
- // `reportValidity()` and `<form>`-dispatched events are always
888
- // trusted.
889
- if (this[privateDoNotReportInvalid] || !invalidEvent.isTrusted) {
890
- return;
891
- }
892
- this.addEventListener('invalid', () => {
893
- // A normal bubbling phase event listener. By adding it here, we
894
- // ensure it's the last event listener that is called during the
895
- // bubbling phase.
896
- this[privateCallOnReportValidity](invalidEvent);
897
- }, {
898
- once: true
899
- });
900
- }, {
901
- // Listen during the capture phase, which will happen before the
902
- // bubbling phase. That way, we can add a final event listener that
903
- // will run after other event listeners, and we can check if it was
904
- // default prevented. This works because invalid does not bubble.
905
- capture: true
906
- });
907
- }
908
- checkValidity() {
909
- this[privateDoNotReportInvalid] = true;
910
- const valid = super.checkValidity();
911
- this[privateDoNotReportInvalid] = false;
912
- return valid;
913
- }
914
- reportValidity() {
915
- this[privateIsSelfReportingValidity] = true;
916
- const valid = super.reportValidity();
917
- // Constructor's invalid listener will handle reporting invalid events.
918
- if (valid) {
919
- this[privateCallOnReportValidity](null);
920
- }
921
- this[privateIsSelfReportingValidity] = false;
922
- return valid;
923
- }
924
- [(_a = privateCleanupFormListeners, _b = privateDoNotReportInvalid, _c = privateIsSelfReportingValidity, privateCallOnReportValidity)](invalidEvent) {
925
- // Since invalid events do not bubble to parent listeners, and because
926
- // our invalid listeners are added lazily after other listeners, we can
927
- // reliably read `defaultPrevented` synchronously without worrying
928
- // about waiting for another listener that could cancel it.
929
- const wasCanceled = invalidEvent === null || invalidEvent === void 0 ? void 0 : invalidEvent.defaultPrevented;
930
- if (wasCanceled) {
931
- return;
932
- }
933
- this[onReportValidity](invalidEvent);
934
- // If an implementation calls invalidEvent.preventDefault() to stop the
935
- // platform popup from displaying, focusing is also prevented, so we need
936
- // to manually focus.
937
- const implementationCanceledFocus = !wasCanceled && (invalidEvent === null || invalidEvent === void 0 ? void 0 : invalidEvent.defaultPrevented);
938
- if (!implementationCanceledFocus) {
939
- return;
940
- }
941
- // The control should be focused when:
942
- // - `control.reportValidity()` is called (self-reporting).
943
- // - a form is reporting validity for its controls and this is the first
944
- // invalid control.
945
- if (this[privateIsSelfReportingValidity] || isFirstInvalidControlInForm(this[internals].form, this)) {
946
- this.focus();
947
- }
948
- }
949
- [onReportValidity](invalidEvent) {
950
- throw new Error('Implement [onReportValidity]');
951
- }
952
- formAssociatedCallback(form) {
953
- // can't use super.formAssociatedCallback?.() due to closure
954
- if (super.formAssociatedCallback) {
955
- super.formAssociatedCallback(form);
956
- }
957
- // Clean up previous form listeners.
958
- this[privateCleanupFormListeners].abort();
959
- if (!form) {
960
- return;
961
- }
962
- this[privateCleanupFormListeners] = new AbortController();
963
- // Add a listener that fires when the form runs constraint validation and
964
- // the control is valid, so that it may remove its error styles.
965
- //
966
- // This happens on `form.reportValidity()` and `form.requestSubmit()`
967
- // (both when the submit fails and passes).
968
- addFormReportValidListener(this, form, () => {
969
- this[privateCallOnReportValidity](null);
970
- }, this[privateCleanupFormListeners].signal);
971
- }
972
- }
973
- return OnReportValidityElement;
974
- }
975
- /**
976
- * Add a listener that fires when a form runs constraint validation on a control
977
- * and it is valid. This is needed to clear previously invalid styles.
978
- *
979
- * @param control The control of the form to listen for valid events.
980
- * @param form The control's form that can run constraint validation.
981
- * @param onControlValid A listener that is called when the form runs constraint
982
- * validation and the control is valid.
983
- * @param cleanup A cleanup signal to remove the listener.
984
- */
985
- function addFormReportValidListener(control, form, onControlValid, cleanup) {
986
- const validateHooks = getFormValidateHooks(form);
987
- // When a form validates its controls, check if an invalid event is dispatched
988
- // on the control. If it is not, then inform the control to report its valid
989
- // state.
990
- let controlFiredInvalid = false;
991
- let cleanupInvalidListener;
992
- let isNextSubmitFromHook = false;
993
- validateHooks.addEventListener('before', () => {
994
- isNextSubmitFromHook = true;
995
- cleanupInvalidListener = new AbortController();
996
- controlFiredInvalid = false;
997
- control.addEventListener('invalid', () => {
998
- controlFiredInvalid = true;
999
- }, {
1000
- signal: cleanupInvalidListener.signal
1001
- });
1002
- }, {
1003
- signal: cleanup
1004
- });
1005
- validateHooks.addEventListener('after', () => {
1006
- var _cleanupInvalidListen;
1007
- isNextSubmitFromHook = false;
1008
- (_cleanupInvalidListen = cleanupInvalidListener) === null || _cleanupInvalidListen === void 0 || _cleanupInvalidListen.abort();
1009
- if (controlFiredInvalid) {
1010
- return;
1011
- }
1012
- onControlValid();
1013
- }, {
1014
- signal: cleanup
1015
- });
1016
- // The above hooks handle imperatively submitting the form, but not
1017
- // declaratively submitting the form. This happens when:
1018
- // 1. A non-custom element `<button type="submit">` is clicked.
1019
- // 2. Enter is pressed on a non-custom element text editable `<input>`.
1020
- form.addEventListener('submit', () => {
1021
- // This submit was from `form.requestSubmit()`, which already calls the
1022
- // listener.
1023
- if (isNextSubmitFromHook) {
1024
- return;
1025
- }
1026
- onControlValid();
1027
- }, {
1028
- signal: cleanup
1029
- });
1030
- // Note: it is a known limitation that we cannot detect if a form tries to
1031
- // submit declaratively, but fails to do so because an unrelated sibling
1032
- // control failed its constraint validation.
1033
- //
1034
- // Since we cannot detect when that happens, a previously invalid control may
1035
- // not clear its error styling when it becomes valid again.
1036
- //
1037
- // To work around this, call `form.reportValidity()` when submitting a form
1038
- // declaratively. This can be down on the `<button type="submit">`'s click or
1039
- // the text editable `<input>`'s 'Enter' keydown.
1040
- }
1041
- const FORM_VALIDATE_HOOKS = new WeakMap();
1042
- /**
1043
- * Get a hooks `EventTarget` that dispatches 'before' and 'after' events that
1044
- * fire before a form runs constraint validation and immediately after it
1045
- * finishes running constraint validation on its controls.
1046
- *
1047
- * This happens during `form.reportValidity()` and `form.requestSubmit()`.
1048
- *
1049
- * @param form The form to get or set up hooks for.
1050
- * @return A hooks `EventTarget` to add listeners to.
1051
- */
1052
- function getFormValidateHooks(form) {
1053
- if (!FORM_VALIDATE_HOOKS.has(form)) {
1054
- // Patch form methods to add event listener hooks. These are needed to react
1055
- // to form behaviors that do not dispatch events, such as a form asking its
1056
- // controls to report their validity.
1057
- //
1058
- // We should only patch the methods once, since multiple controls and other
1059
- // forces may want to patch this method. We cannot reliably clean it up if
1060
- // there are multiple patched and re-patched methods referring holding
1061
- // references to each other.
1062
- //
1063
- // Instead, we never clean up the patch but add and clean up event listeners
1064
- // added to the hooks after the patch.
1065
- const hooks = new EventTarget();
1066
- FORM_VALIDATE_HOOKS.set(form, hooks);
1067
- // Add hooks to support notifying before and after a form has run constraint
1068
- // validation on its controls.
1069
- // Note: `form.submit()` does not run constraint validation per spec.
1070
- for (const methodName of ['reportValidity', 'requestSubmit']) {
1071
- const superMethod = form[methodName];
1072
- form[methodName] = function () {
1073
- hooks.dispatchEvent(new Event('before'));
1074
- const result = Reflect.apply(superMethod, this, arguments);
1075
- hooks.dispatchEvent(new Event('after'));
1076
- return result;
1077
- };
1078
- }
1079
- }
1080
- return FORM_VALIDATE_HOOKS.get(form);
1081
- }
1082
- /**
1083
- * Checks if a control is the first invalid control in a form.
1084
- *
1085
- * @param form The control's form. When `null`, the control doesn't have a form
1086
- * and the method returns true.
1087
- * @param control The control to check.
1088
- * @return True if there is no form or if the control is the form's first
1089
- * invalid control.
1090
- */
1091
- function isFirstInvalidControlInForm(form, control) {
1092
- if (!form) {
1093
- return true;
1094
- }
1095
- let firstInvalidControl;
1096
- for (const element of form.elements) {
1097
- if (element.matches(':invalid')) {
1098
- firstInvalidControl = element;
1099
- break;
1100
- }
1101
- }
1102
- return firstInvalidControl === control;
1103
- }
1104
-
1105
- /**
1106
- * @license
1107
- * Copyright 2023 Google LLC
1108
- * SPDX-License-Identifier: Apache-2.0
1109
- */
1110
- /**
1111
- * A class that computes and caches `ValidityStateFlags` for a component with
1112
- * a given `State` interface.
1113
- *
1114
- * Cached performance before computing validity is important since constraint
1115
- * validation must be checked frequently and synchronously when properties
1116
- * change.
1117
- *
1118
- * @template State The expected interface of properties relevant to constraint
1119
- * validation.
1120
- */
1121
- class Validator {
1122
- /**
1123
- * Creates a new validator.
1124
- *
1125
- * @param getCurrentState A callback that returns the current state of
1126
- * constraint validation-related properties.
1127
- */
1128
- constructor(getCurrentState) {
1129
- this.getCurrentState = getCurrentState;
1130
- /**
1131
- * The current validity state and message. This is cached and returns if
1132
- * constraint validation state does not change.
1133
- */
1134
- this.currentValidity = {
1135
- validity: {},
1136
- validationMessage: ''
1137
- };
1138
- }
1139
- /**
1140
- * Returns the current `ValidityStateFlags` and validation message for the
1141
- * validator.
1142
- *
1143
- * If the constraint validation state has not changed, this will return a
1144
- * cached result. This is important since `getValidity()` can be called
1145
- * frequently in response to synchronous property changes.
1146
- *
1147
- * @return The current validity and validation message.
1148
- */
1149
- getValidity() {
1150
- const state = this.getCurrentState();
1151
- const hasStateChanged = !this.prevState || !this.equals(this.prevState, state);
1152
- if (!hasStateChanged) {
1153
- return this.currentValidity;
1154
- }
1155
- const {
1156
- validity,
1157
- validationMessage
1158
- } = this.computeValidity(state);
1159
- this.prevState = this.copy(state);
1160
- this.currentValidity = {
1161
- validationMessage,
1162
- validity: {
1163
- // Change any `ValidityState` instances into `ValidityStateFlags` since
1164
- // `ValidityState` cannot be easily `{...spread}`.
1165
- badInput: validity.badInput,
1166
- customError: validity.customError,
1167
- patternMismatch: validity.patternMismatch,
1168
- rangeOverflow: validity.rangeOverflow,
1169
- rangeUnderflow: validity.rangeUnderflow,
1170
- stepMismatch: validity.stepMismatch,
1171
- tooLong: validity.tooLong,
1172
- tooShort: validity.tooShort,
1173
- typeMismatch: validity.typeMismatch,
1174
- valueMissing: validity.valueMissing
1175
- }
1176
- };
1177
- return this.currentValidity;
1178
- }
1179
- }
1180
-
1181
- /**
1182
- * @license
1183
- * Copyright 2023 Google LLC
1184
- * SPDX-License-Identifier: Apache-2.0
1185
- */
1186
- /**
1187
- * A validator that provides constraint validation that emulates `<input>` and
1188
- * `<textarea>` validation.
1189
- */
1190
- class TextFieldValidator extends Validator {
1191
- computeValidity({
1192
- state,
1193
- renderedControl
1194
- }) {
1195
- let inputOrTextArea = renderedControl;
1196
- if (isInputState(state) && !inputOrTextArea) {
1197
- // Get cached <input> or create it.
1198
- inputOrTextArea = this.inputControl || document.createElement('input');
1199
- // Cache the <input> to re-use it next time.
1200
- this.inputControl = inputOrTextArea;
1201
- } else if (!inputOrTextArea) {
1202
- // Get cached <textarea> or create it.
1203
- inputOrTextArea = this.textAreaControl || document.createElement('textarea');
1204
- // Cache the <textarea> to re-use it next time.
1205
- this.textAreaControl = inputOrTextArea;
1206
- }
1207
- // Set this variable so we can check it for input-specific properties.
1208
- const input = isInputState(state) ? inputOrTextArea : null;
1209
- // Set input's "type" first, since this can change the other properties
1210
- if (input) {
1211
- input.type = state.type;
1212
- }
1213
- if (inputOrTextArea.value !== state.value) {
1214
- // Only programmatically set the value if there's a difference. When using
1215
- // the rendered control, the value will always be up to date. Setting the
1216
- // property (even if it's the same string) will reset the internal <input>
1217
- // dirty flag, making minlength and maxlength validation reset.
1218
- inputOrTextArea.value = state.value;
1219
- }
1220
- inputOrTextArea.required = state.required;
1221
- // The following IDLAttribute properties will always hydrate an attribute,
1222
- // even if set to a the default value ('' or -1). The presence of the
1223
- // attribute triggers constraint validation, so we must remove the attribute
1224
- // when empty.
1225
- if (input) {
1226
- const inputState = state;
1227
- if (inputState.pattern) {
1228
- input.pattern = inputState.pattern;
1229
- } else {
1230
- input.removeAttribute('pattern');
1231
- }
1232
- if (inputState.min) {
1233
- input.min = inputState.min;
1234
- } else {
1235
- input.removeAttribute('min');
1236
- }
1237
- if (inputState.max) {
1238
- input.max = inputState.max;
1239
- } else {
1240
- input.removeAttribute('max');
1241
- }
1242
- if (inputState.step) {
1243
- input.step = inputState.step;
1244
- } else {
1245
- input.removeAttribute('step');
1246
- }
1247
- }
1248
- // Use -1 to represent no minlength and maxlength, which is what the
1249
- // platform input returns. However, it will throw an error if you try to
1250
- // manually set it to -1.
1251
- //
1252
- // While the type is `number`, it may actually be `null` at runtime.
1253
- // `null > -1` is true since `null` coerces to `0`, so we default null and
1254
- // undefined to -1.
1255
- //
1256
- // We set attributes instead of properties since setting a property may
1257
- // throw an out of bounds error in relation to the other property.
1258
- // Attributes will not throw errors while the state is updating.
1259
- if ((state.minLength ?? -1) > -1) {
1260
- inputOrTextArea.setAttribute('minlength', String(state.minLength));
1261
- } else {
1262
- inputOrTextArea.removeAttribute('minlength');
1263
- }
1264
- if ((state.maxLength ?? -1) > -1) {
1265
- inputOrTextArea.setAttribute('maxlength', String(state.maxLength));
1266
- } else {
1267
- inputOrTextArea.removeAttribute('maxlength');
1268
- }
1269
- return {
1270
- validity: inputOrTextArea.validity,
1271
- validationMessage: inputOrTextArea.validationMessage
1272
- };
1273
- }
1274
- equals({
1275
- state: prev
1276
- }, {
1277
- state: next
1278
- }) {
1279
- // Check shared input and textarea properties
1280
- const inputOrTextAreaEqual = prev.type === next.type && prev.value === next.value && prev.required === next.required && prev.minLength === next.minLength && prev.maxLength === next.maxLength;
1281
- if (!isInputState(prev) || !isInputState(next)) {
1282
- // Both are textareas, all relevant properties are equal.
1283
- return inputOrTextAreaEqual;
1284
- }
1285
- // Check additional input-specific properties.
1286
- return inputOrTextAreaEqual && prev.pattern === next.pattern && prev.min === next.min && prev.max === next.max && prev.step === next.step;
1287
- }
1288
- copy({
1289
- state
1290
- }) {
1291
- // Don't hold a reference to the rendered control when copying since we
1292
- // don't use it when checking if the state changed.
1293
- return {
1294
- state: isInputState(state) ? this.copyInput(state) : this.copyTextArea(state),
1295
- renderedControl: null
1296
- };
1297
- }
1298
- copyInput(state) {
1299
- const {
1300
- type,
1301
- pattern,
1302
- min,
1303
- max,
1304
- step
1305
- } = state;
1306
- return {
1307
- ...this.copySharedState(state),
1308
- type,
1309
- pattern,
1310
- min,
1311
- max,
1312
- step
1313
- };
1314
- }
1315
- copyTextArea(state) {
1316
- return {
1317
- ...this.copySharedState(state),
1318
- type: state.type
1319
- };
1320
- }
1321
- copySharedState({
1322
- value,
1323
- required,
1324
- minLength,
1325
- maxLength
1326
- }) {
1327
- return {
1328
- value,
1329
- required,
1330
- minLength,
1331
- maxLength
1332
- };
1333
- }
1334
- }
1335
- function isInputState(state) {
1336
- return state.type !== 'textarea';
1337
- }
1338
-
1339
- /**
1340
- * @license
1341
- * Copyright 2021 Google LLC
1342
- * SPDX-License-Identifier: Apache-2.0
1343
- */
1344
- // Separate variable needed for closure.
1345
- const textFieldBaseClass = mixinDelegatesAria(mixinOnReportValidity(mixinConstraintValidation(mixinFormAssociated(mixinElementInternals(i$1)))));
1346
- /**
1347
- * A text field component.
1348
- *
1349
- * @fires select {Event} The native `select` event on
1350
- * [`<input>`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/select_event)
1351
- * --bubbles
1352
- * @fires change {Event} The native `change` event on
1353
- * [`<input>`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/change_event)
1354
- * --bubbles
1355
- * @fires input {InputEvent} The native `input` event on
1356
- * [`<input>`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/input_event)
1357
- * --bubbles --composed
1358
- */
1359
- class TextField extends textFieldBaseClass {
1360
- constructor() {
1361
- super(...arguments);
1362
- /**
1363
- * Gets or sets whether or not the text field is in a visually invalid state.
1364
- *
1365
- * This error state overrides the error state controlled by
1366
- * `reportValidity()`.
1367
- */
1368
- this.error = false;
1369
- /**
1370
- * The error message that replaces supporting text when `error` is true. If
1371
- * `errorText` is an empty string, then the supporting text will continue to
1372
- * show.
1373
- *
1374
- * This error message overrides the error message displayed by
1375
- * `reportValidity()`.
1376
- */
1377
- this.errorText = '';
1378
- /**
1379
- * The floating Material label of the textfield component. It informs the user
1380
- * about what information is requested for a text field. It is aligned with
1381
- * the input text, is always visible, and it floats when focused or when text
1382
- * is entered into the textfield. This label also sets accessibilty labels,
1383
- * but the accessible label is overriden by `aria-label`.
1384
- *
1385
- * Learn more about floating labels from the Material Design guidelines:
1386
- * https://m3.material.io/components/text-fields/guidelines
1387
- */
1388
- this.label = '';
1389
- /**
1390
- * Disables the asterisk on the floating label, when the text field is
1391
- * required.
1392
- */
1393
- this.noAsterisk = false;
1394
- /**
1395
- * Indicates that the user must specify a value for the input before the
1396
- * owning form can be submitted and will render an error state when
1397
- * `reportValidity()` is invoked when value is empty. Additionally the
1398
- * floating label will render an asterisk `"*"` when true.
1399
- *
1400
- * https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/required
1401
- */
1402
- this.required = false;
1403
- /**
1404
- * The current value of the text field. It is always a string.
1405
- */
1406
- this.value = '';
1407
- /**
1408
- * An optional prefix to display before the input value.
1409
- */
1410
- this.prefixText = '';
1411
- /**
1412
- * An optional suffix to display after the input value.
1413
- */
1414
- this.suffixText = '';
1415
- /**
1416
- * Whether or not the text field has a leading icon. Used for SSR.
1417
- */
1418
- this.hasLeadingIcon = false;
1419
- /**
1420
- * Whether or not the text field has a trailing icon. Used for SSR.
1421
- */
1422
- this.hasTrailingIcon = false;
1423
- /**
1424
- * Conveys additional information below the text field, such as how it should
1425
- * be used.
1426
- */
1427
- this.supportingText = '';
1428
- /**
1429
- * Override the input text CSS `direction`. Useful for RTL languages that use
1430
- * LTR notation for fractions.
1431
- */
1432
- this.textDirection = '';
1433
- /**
1434
- * The number of rows to display for a `type="textarea"` text field.
1435
- * Defaults to 2.
1436
- */
1437
- this.rows = 2;
1438
- /**
1439
- * The number of cols to display for a `type="textarea"` text field.
1440
- * Defaults to 20.
1441
- */
1442
- this.cols = 20;
1443
- // <input> properties
1444
- this.inputMode = '';
1445
- /**
1446
- * Defines the greatest value in the range of permitted values.
1447
- *
1448
- * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#max
1449
- */
1450
- this.max = '';
1451
- /**
1452
- * The maximum number of characters a user can enter into the text field. Set
1453
- * to -1 for none.
1454
- *
1455
- * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#maxlength
1456
- */
1457
- this.maxLength = -1;
1458
- /**
1459
- * Defines the most negative value in the range of permitted values.
1460
- *
1461
- * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#min
1462
- */
1463
- this.min = '';
1464
- /**
1465
- * The minimum number of characters a user can enter into the text field. Set
1466
- * to -1 for none.
1467
- *
1468
- * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#minlength
1469
- */
1470
- this.minLength = -1;
1471
- /**
1472
- * When true, hide the spinner for `type="number"` text fields.
1473
- */
1474
- this.noSpinner = false;
1475
- /**
1476
- * A regular expression that the text field's value must match to pass
1477
- * constraint validation.
1478
- *
1479
- * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#pattern
1480
- */
1481
- this.pattern = '';
1482
- /**
1483
- * Defines the text displayed in the textfield when it has no value. Provides
1484
- * a brief hint to the user as to the expected type of data that should be
1485
- * entered into the control. Unlike `label`, the placeholder is not visible
1486
- * and does not float when the textfield has a value.
1487
- *
1488
- * https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/placeholder
1489
- */
1490
- this.placeholder = '';
1491
- /**
1492
- * Indicates whether or not a user should be able to edit the text field's
1493
- * value.
1494
- *
1495
- * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#readonly
1496
- */
1497
- this.readOnly = false;
1498
- /**
1499
- * Indicates that input accepts multiple email addresses.
1500
- *
1501
- * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/email#multiple
1502
- */
1503
- this.multiple = false;
1504
- /**
1505
- * Returns or sets the element's step attribute, which works with min and max
1506
- * to limit the increments at which a numeric or date-time value can be set.
1507
- *
1508
- * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#step
1509
- */
1510
- this.step = '';
1511
- /**
1512
- * The `<input>` type to use, defaults to "text". The type greatly changes how
1513
- * the text field behaves.
1514
- *
1515
- * Text fields support a limited number of `<input>` types:
1516
- *
1517
- * - text
1518
- * - textarea
1519
- * - email
1520
- * - number
1521
- * - password
1522
- * - search
1523
- * - tel
1524
- * - url
1525
- *
1526
- * See
1527
- * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#input_types
1528
- * for more details on each input type.
1529
- */
1530
- this.type = 'text';
1531
- /**
1532
- * Describes what, if any, type of autocomplete functionality the input
1533
- * should provide.
1534
- *
1535
- * https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete
1536
- */
1537
- this.autocomplete = '';
1538
- /**
1539
- * Returns true when the text field has been interacted with. Native
1540
- * validation errors only display in response to user interactions.
1541
- */
1542
- this.dirty = false;
1543
- this.focused = false;
1544
- /**
1545
- * Whether or not a native error has been reported via `reportValidity()`.
1546
- */
1547
- this.nativeError = false;
1548
- /**
1549
- * The validation message displayed from a native error via
1550
- * `reportValidity()`.
1551
- */
1552
- this.nativeErrorText = '';
1553
- }
1554
- /**
1555
- * Gets or sets the direction in which selection occurred.
1556
- */
1557
- get selectionDirection() {
1558
- return this.getInputOrTextarea().selectionDirection;
1559
- }
1560
- set selectionDirection(value) {
1561
- this.getInputOrTextarea().selectionDirection = value;
1562
- }
1563
- /**
1564
- * Gets or sets the end position or offset of a text selection.
1565
- */
1566
- get selectionEnd() {
1567
- return this.getInputOrTextarea().selectionEnd;
1568
- }
1569
- set selectionEnd(value) {
1570
- this.getInputOrTextarea().selectionEnd = value;
1571
- }
1572
- /**
1573
- * Gets or sets the starting position or offset of a text selection.
1574
- */
1575
- get selectionStart() {
1576
- return this.getInputOrTextarea().selectionStart;
1577
- }
1578
- set selectionStart(value) {
1579
- this.getInputOrTextarea().selectionStart = value;
1580
- }
1581
- /**
1582
- * The text field's value as a number.
1583
- */
1584
- get valueAsNumber() {
1585
- const input = this.getInput();
1586
- if (!input) {
1587
- return NaN;
1588
- }
1589
- return input.valueAsNumber;
1590
- }
1591
- set valueAsNumber(value) {
1592
- const input = this.getInput();
1593
- if (!input) {
1594
- return;
1595
- }
1596
- input.valueAsNumber = value;
1597
- this.value = input.value;
1598
- }
1599
- /**
1600
- * The text field's value as a Date.
1601
- */
1602
- get valueAsDate() {
1603
- const input = this.getInput();
1604
- if (!input) {
1605
- return null;
1606
- }
1607
- return input.valueAsDate;
1608
- }
1609
- set valueAsDate(value) {
1610
- const input = this.getInput();
1611
- if (!input) {
1612
- return;
1613
- }
1614
- input.valueAsDate = value;
1615
- this.value = input.value;
1616
- }
1617
- get hasError() {
1618
- return this.error || this.nativeError;
1619
- }
1620
- /**
1621
- * Selects all the text in the text field.
1622
- *
1623
- * https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/select
1624
- */
1625
- select() {
1626
- this.getInputOrTextarea().select();
1627
- }
1628
- setRangeText(...args) {
1629
- // Calling setRangeText with 1 vs 3-4 arguments has different behavior.
1630
- // Use spread syntax and type casting to ensure correct usage.
1631
- this.getInputOrTextarea().setRangeText(...args);
1632
- this.value = this.getInputOrTextarea().value;
1633
- }
1634
- /**
1635
- * Sets the start and end positions of a selection in the text field.
1636
- *
1637
- * https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange
1638
- *
1639
- * @param start The offset into the text field for the start of the selection.
1640
- * @param end The offset into the text field for the end of the selection.
1641
- * @param direction The direction in which the selection is performed.
1642
- */
1643
- setSelectionRange(start, end, direction) {
1644
- this.getInputOrTextarea().setSelectionRange(start, end, direction);
1645
- }
1646
- /**
1647
- * Shows the browser picker for an input element of type "date", "time", etc.
1648
- *
1649
- * For a full list of supported types, see:
1650
- * https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/showPicker#browser_compatibility
1651
- *
1652
- * https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/showPicker
1653
- */
1654
- showPicker() {
1655
- const input = this.getInput();
1656
- if (!input) {
1657
- return;
1658
- }
1659
- input.showPicker();
1660
- }
1661
- /**
1662
- * Decrements the value of a numeric type text field by `step` or `n` `step`
1663
- * number of times.
1664
- *
1665
- * https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/stepDown
1666
- *
1667
- * @param stepDecrement The number of steps to decrement, defaults to 1.
1668
- */
1669
- stepDown(stepDecrement) {
1670
- const input = this.getInput();
1671
- if (!input) {
1672
- return;
1673
- }
1674
- input.stepDown(stepDecrement);
1675
- this.value = input.value;
1676
- }
1677
- /**
1678
- * Increments the value of a numeric type text field by `step` or `n` `step`
1679
- * number of times.
1680
- *
1681
- * https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/stepUp
1682
- *
1683
- * @param stepIncrement The number of steps to increment, defaults to 1.
1684
- */
1685
- stepUp(stepIncrement) {
1686
- const input = this.getInput();
1687
- if (!input) {
1688
- return;
1689
- }
1690
- input.stepUp(stepIncrement);
1691
- this.value = input.value;
1692
- }
1693
- /**
1694
- * Reset the text field to its default value.
1695
- */
1696
- reset() {
1697
- this.dirty = false;
1698
- this.value = this.getAttribute('value') ?? '';
1699
- this.nativeError = false;
1700
- this.nativeErrorText = '';
1701
- }
1702
- attributeChangedCallback(attribute, newValue, oldValue) {
1703
- if (attribute === 'value' && this.dirty) {
1704
- // After user input, changing the value attribute no longer updates the
1705
- // text field's value (until reset). This matches native <input> behavior.
1706
- return;
1707
- }
1708
- super.attributeChangedCallback(attribute, newValue, oldValue);
1709
- }
1710
- render() {
1711
- const classes = {
1712
- 'disabled': this.disabled,
1713
- 'error': !this.disabled && this.hasError,
1714
- 'textarea': this.type === 'textarea',
1715
- 'no-spinner': this.noSpinner
1716
- };
1717
- return b`
1718
- <span class="text-field ${e$1(classes)}">
1719
- ${this.renderField()}
1720
- </span>
1721
- `;
1722
- }
1723
- updated(changedProperties) {
1724
- // Keep changedProperties arg so that subclasses may call it
1725
- // If a property such as `type` changes and causes the internal <input>
1726
- // value to change without dispatching an event, re-sync it.
1727
- const value = this.getInputOrTextarea().value;
1728
- if (this.value !== value) {
1729
- // Note this is typically inefficient in updated() since it schedules
1730
- // another update. However, it is needed for the <input> to fully render
1731
- // before checking its value.
1732
- this.value = value;
1733
- }
1734
- }
1735
- renderField() {
1736
- return u`<${this.fieldTag}
1737
- class="field"
1738
- count=${this.value.length}
1739
- ?disabled=${this.disabled}
1740
- ?error=${this.hasError}
1741
- error-text=${this.getErrorText()}
1742
- ?focused=${this.focused}
1743
- ?has-end=${this.hasTrailingIcon}
1744
- ?has-start=${this.hasLeadingIcon}
1745
- label=${this.label}
1746
- ?no-asterisk=${this.noAsterisk}
1747
- max=${this.maxLength}
1748
- ?populated=${!!this.value}
1749
- ?required=${this.required}
1750
- ?resizable=${this.type === 'textarea'}
1751
- supporting-text=${this.supportingText}
1752
- >
1753
- ${this.renderLeadingIcon()}
1754
- ${this.renderInputOrTextarea()}
1755
- ${this.renderTrailingIcon()}
1756
- <div id="description" slot="aria-describedby"></div>
1757
- <slot name="container" slot="container"></slot>
1758
- </${this.fieldTag}>`;
1759
- }
1760
- renderLeadingIcon() {
1761
- return b`
1762
- <span class="icon leading" slot="start">
1763
- <slot name="leading-icon" @slotchange=${this.handleIconChange}></slot>
1764
- </span>
1765
- `;
1766
- }
1767
- renderTrailingIcon() {
1768
- return b`
1769
- <span class="icon trailing" slot="end">
1770
- <slot name="trailing-icon" @slotchange=${this.handleIconChange}></slot>
1771
- </span>
1772
- `;
1773
- }
1774
- renderInputOrTextarea() {
1775
- const style = {
1776
- 'direction': this.textDirection
1777
- };
1778
- const ariaLabel = this.ariaLabel || this.label || A;
1779
- // lit-anaylzer `autocomplete` types are too strict
1780
- // tslint:disable-next-line:no-any
1781
- const autocomplete = this.autocomplete;
1782
- // These properties may be set to null if the attribute is removed, and
1783
- // `null > -1` is incorrectly `true`.
1784
- const hasMaxLength = (this.maxLength ?? -1) > -1;
1785
- const hasMinLength = (this.minLength ?? -1) > -1;
1786
- if (this.type === 'textarea') {
1787
- return b`
1788
- <textarea
1789
- class="input"
1790
- style=${o(style)}
1791
- aria-describedby="description"
1792
- aria-invalid=${this.hasError}
1793
- aria-label=${ariaLabel}
1794
- autocomplete=${autocomplete || A}
1795
- name=${this.name || A}
1796
- ?disabled=${this.disabled}
1797
- maxlength=${hasMaxLength ? this.maxLength : A}
1798
- minlength=${hasMinLength ? this.minLength : A}
1799
- placeholder=${this.placeholder || A}
1800
- ?readonly=${this.readOnly}
1801
- ?required=${this.required}
1802
- rows=${this.rows}
1803
- cols=${this.cols}
1804
- .value=${l(this.value)}
1805
- @change=${this.redispatchEvent}
1806
- @focus=${this.handleFocusChange}
1807
- @blur=${this.handleFocusChange}
1808
- @input=${this.handleInput}
1809
- @select=${this.redispatchEvent}></textarea>
1810
- `;
1811
- }
1812
- const prefix = this.renderPrefix();
1813
- const suffix = this.renderSuffix();
1814
- // TODO(b/243805848): remove `as unknown as number` and `as any` once lit
1815
- // analyzer is fixed
1816
- // tslint:disable-next-line:no-any
1817
- const inputMode = this.inputMode;
1818
- return b`
1819
- <div class="input-wrapper">
1820
- ${prefix}
1821
- <input
1822
- class="input"
1823
- style=${o(style)}
1824
- aria-describedby="description"
1825
- aria-invalid=${this.hasError}
1826
- aria-label=${ariaLabel}
1827
- autocomplete=${autocomplete || A}
1828
- name=${this.name || A}
1829
- ?disabled=${this.disabled}
1830
- inputmode=${inputMode || A}
1831
- max=${this.max || A}
1832
- maxlength=${hasMaxLength ? this.maxLength : A}
1833
- min=${this.min || A}
1834
- minlength=${hasMinLength ? this.minLength : A}
1835
- pattern=${this.pattern || A}
1836
- placeholder=${this.placeholder || A}
1837
- ?readonly=${this.readOnly}
1838
- ?required=${this.required}
1839
- ?multiple=${this.multiple}
1840
- step=${this.step || A}
1841
- type=${this.type}
1842
- .value=${l(this.value)}
1843
- @change=${this.redispatchEvent}
1844
- @focus=${this.handleFocusChange}
1845
- @blur=${this.handleFocusChange}
1846
- @input=${this.handleInput}
1847
- @select=${this.redispatchEvent} />
1848
- ${suffix}
1849
- </div>
1850
- `;
1851
- }
1852
- renderPrefix() {
1853
- return this.renderAffix(this.prefixText, /* isSuffix */false);
1854
- }
1855
- renderSuffix() {
1856
- return this.renderAffix(this.suffixText, /* isSuffix */true);
1857
- }
1858
- renderAffix(text, isSuffix) {
1859
- if (!text) {
1860
- return A;
1861
- }
1862
- const classes = {
1863
- 'suffix': isSuffix,
1864
- 'prefix': !isSuffix
1865
- };
1866
- return b`<span class="${e$1(classes)}">${text}</span>`;
1867
- }
1868
- getErrorText() {
1869
- return this.error ? this.errorText : this.nativeErrorText;
1870
- }
1871
- handleFocusChange() {
1872
- var _this$inputOrTextarea;
1873
- // When calling focus() or reportValidity() during change, it's possible
1874
- // for blur to be called after the new focus event. Rather than set
1875
- // `this.focused` to true/false on focus/blur, we always set it to whether
1876
- // or not the input itself is focused.
1877
- this.focused = ((_this$inputOrTextarea = this.inputOrTextarea) === null || _this$inputOrTextarea === void 0 ? void 0 : _this$inputOrTextarea.matches(':focus')) ?? false;
1878
- }
1879
- handleInput(event) {
1880
- this.dirty = true;
1881
- this.value = event.target.value;
1882
- }
1883
- redispatchEvent(event) {
1884
- redispatchEvent(this, event);
1885
- }
1886
- getInputOrTextarea() {
1887
- if (!this.inputOrTextarea) {
1888
- // If the input is not yet defined, synchronously render.
1889
- // e.g.
1890
- // const textField = document.createElement('md-outlined-text-field');
1891
- // document.body.appendChild(textField);
1892
- // textField.focus(); // synchronously render
1893
- this.connectedCallback();
1894
- this.scheduleUpdate();
1895
- }
1896
- if (this.isUpdatePending) {
1897
- // If there are pending updates, synchronously perform them. This ensures
1898
- // that constraint validation properties (like `required`) are synced
1899
- // before interacting with input APIs that depend on them.
1900
- this.scheduleUpdate();
1901
- }
1902
- return this.inputOrTextarea;
1903
- }
1904
- getInput() {
1905
- if (this.type === 'textarea') {
1906
- return null;
1907
- }
1908
- return this.getInputOrTextarea();
1909
- }
1910
- handleIconChange() {
1911
- this.hasLeadingIcon = this.leadingIcons.length > 0;
1912
- this.hasTrailingIcon = this.trailingIcons.length > 0;
1913
- }
1914
- [getFormValue]() {
1915
- return this.value;
1916
- }
1917
- formResetCallback() {
1918
- this.reset();
1919
- }
1920
- formStateRestoreCallback(state) {
1921
- this.value = state;
1922
- }
1923
- focus() {
1924
- // Required for the case that the user slots a focusable element into the
1925
- // leading icon slot such as an iconbutton due to how delegatesFocus works.
1926
- this.getInputOrTextarea().focus();
1927
- }
1928
- [createValidator]() {
1929
- return new TextFieldValidator(() => ({
1930
- state: this,
1931
- renderedControl: this.inputOrTextarea
1932
- }));
1933
- }
1934
- [getValidityAnchor]() {
1935
- return this.inputOrTextarea;
1936
- }
1937
- [onReportValidity](invalidEvent) {
1938
- // Prevent default pop-up behavior.
1939
- invalidEvent === null || invalidEvent === void 0 || invalidEvent.preventDefault();
1940
- const prevMessage = this.getErrorText();
1941
- this.nativeError = !!invalidEvent;
1942
- this.nativeErrorText = this.validationMessage;
1943
- if (prevMessage === this.getErrorText()) {
1944
- var _this$field;
1945
- (_this$field = this.field) === null || _this$field === void 0 || _this$field.reannounceError();
1946
- }
1947
- }
1948
- }
1949
- /** @nocollapse */
1950
- TextField.shadowRootOptions = {
1951
- ...i$1.shadowRootOptions,
1952
- delegatesFocus: true
1953
- };
1954
- __decorate([n$1({
1955
- type: Boolean,
1956
- reflect: true
1957
- })], TextField.prototype, "error", void 0);
1958
- __decorate([n$1({
1959
- attribute: 'error-text'
1960
- })], TextField.prototype, "errorText", void 0);
1961
- __decorate([n$1()], TextField.prototype, "label", void 0);
1962
- __decorate([n$1({
1963
- type: Boolean,
1964
- attribute: 'no-asterisk'
1965
- })], TextField.prototype, "noAsterisk", void 0);
1966
- __decorate([n$1({
1967
- type: Boolean,
1968
- reflect: true
1969
- })], TextField.prototype, "required", void 0);
1970
- __decorate([n$1()], TextField.prototype, "value", void 0);
1971
- __decorate([n$1({
1972
- attribute: 'prefix-text'
1973
- })], TextField.prototype, "prefixText", void 0);
1974
- __decorate([n$1({
1975
- attribute: 'suffix-text'
1976
- })], TextField.prototype, "suffixText", void 0);
1977
- __decorate([n$1({
1978
- type: Boolean,
1979
- attribute: 'has-leading-icon'
1980
- })], TextField.prototype, "hasLeadingIcon", void 0);
1981
- __decorate([n$1({
1982
- type: Boolean,
1983
- attribute: 'has-trailing-icon'
1984
- })], TextField.prototype, "hasTrailingIcon", void 0);
1985
- __decorate([n$1({
1986
- attribute: 'supporting-text'
1987
- })], TextField.prototype, "supportingText", void 0);
1988
- __decorate([n$1({
1989
- attribute: 'text-direction'
1990
- })], TextField.prototype, "textDirection", void 0);
1991
- __decorate([n$1({
1992
- type: Number
1993
- })], TextField.prototype, "rows", void 0);
1994
- __decorate([n$1({
1995
- type: Number
1996
- })], TextField.prototype, "cols", void 0);
1997
- __decorate([n$1({
1998
- reflect: true
1999
- })], TextField.prototype, "inputMode", void 0);
2000
- __decorate([n$1()], TextField.prototype, "max", void 0);
2001
- __decorate([n$1({
2002
- type: Number
2003
- })], TextField.prototype, "maxLength", void 0);
2004
- __decorate([n$1()], TextField.prototype, "min", void 0);
2005
- __decorate([n$1({
2006
- type: Number
2007
- })], TextField.prototype, "minLength", void 0);
2008
- __decorate([n$1({
2009
- type: Boolean,
2010
- attribute: 'no-spinner'
2011
- })], TextField.prototype, "noSpinner", void 0);
2012
- __decorate([n$1()], TextField.prototype, "pattern", void 0);
2013
- __decorate([n$1({
2014
- reflect: true,
2015
- converter: stringConverter
2016
- })], TextField.prototype, "placeholder", void 0);
2017
- __decorate([n$1({
2018
- type: Boolean,
2019
- reflect: true
2020
- })], TextField.prototype, "readOnly", void 0);
2021
- __decorate([n$1({
2022
- type: Boolean,
2023
- reflect: true
2024
- })], TextField.prototype, "multiple", void 0);
2025
- __decorate([n$1()], TextField.prototype, "step", void 0);
2026
- __decorate([n$1({
2027
- reflect: true
2028
- })], TextField.prototype, "type", void 0);
2029
- __decorate([n$1({
2030
- reflect: true
2031
- })], TextField.prototype, "autocomplete", void 0);
2032
- __decorate([r$1()], TextField.prototype, "dirty", void 0);
2033
- __decorate([r$1()], TextField.prototype, "focused", void 0);
2034
- __decorate([r$1()], TextField.prototype, "nativeError", void 0);
2035
- __decorate([r$1()], TextField.prototype, "nativeErrorText", void 0);
2036
- __decorate([e('.input')], TextField.prototype, "inputOrTextarea", void 0);
2037
- __decorate([e('.field')], TextField.prototype, "field", void 0);
2038
- __decorate([o$1({
2039
- slot: 'leading-icon'
2040
- })], TextField.prototype, "leadingIcons", void 0);
2041
- __decorate([o$1({
2042
- slot: 'trailing-icon'
2043
- })], TextField.prototype, "trailingIcons", void 0);
2044
-
2045
- /**
2046
- * @license
2047
- * Copyright 2021 Google LLC
2048
- * SPDX-License-Identifier: Apache-2.0
2049
- */
2050
- /**
2051
- * An outlined text field component
2052
- */
2053
- class OutlinedTextField extends TextField {
2054
- constructor() {
2055
- super(...arguments);
2056
- this.fieldTag = i$4`md-outlined-field`;
2057
- }
2058
- }
2059
-
2060
- /**
2061
- * @license
2062
- * Copyright 2024 Google LLC
2063
- * SPDX-License-Identifier: Apache-2.0
2064
- */
2065
- // Generated stylesheet for ./textfield/internal/shared-styles.css.
2066
- const styles = i$2`:host{display:inline-flex;outline:none;resize:both;text-align:start;-webkit-tap-highlight-color:rgba(0,0,0,0)}.text-field,.field{width:100%}.text-field{display:inline-flex}.field{cursor:text}.disabled .field{cursor:default}.text-field,.textarea .field{resize:inherit}slot[name=container]{border-radius:inherit}.icon{color:currentColor;display:flex;align-items:center;justify-content:center;fill:currentColor;position:relative}.icon ::slotted(*){display:flex;position:absolute}[has-start] .icon.leading{font-size:var(--_leading-icon-size);height:var(--_leading-icon-size);width:var(--_leading-icon-size)}[has-end] .icon.trailing{font-size:var(--_trailing-icon-size);height:var(--_trailing-icon-size);width:var(--_trailing-icon-size)}.input-wrapper{display:flex}.input-wrapper>*{all:inherit;padding:0}.input{caret-color:var(--_caret-color);overflow-x:hidden;text-align:inherit}.input::placeholder{color:currentColor;opacity:1}.input::-webkit-calendar-picker-indicator{display:none}.input::-webkit-search-decoration,.input::-webkit-search-cancel-button{display:none}@media(forced-colors: active){.input{background:none}}.no-spinner .input::-webkit-inner-spin-button,.no-spinner .input::-webkit-outer-spin-button{display:none}.no-spinner .input[type=number]{-moz-appearance:textfield}:focus-within .input{caret-color:var(--_focus-caret-color)}.error:focus-within .input{caret-color:var(--_error-focus-caret-color)}.text-field:not(.disabled) .prefix{color:var(--_input-text-prefix-color)}.text-field:not(.disabled) .suffix{color:var(--_input-text-suffix-color)}.text-field:not(.disabled) .input::placeholder{color:var(--_input-text-placeholder-color)}.prefix,.suffix{text-wrap:nowrap;width:min-content}.prefix{padding-inline-end:var(--_input-text-prefix-trailing-space)}.suffix{padding-inline-start:var(--_input-text-suffix-leading-space)}
2067
- `;
2068
-
2069
- /**
2070
- * @license
2071
- * Copyright 2021 Google LLC
2072
- * SPDX-License-Identifier: Apache-2.0
2073
- */
2074
- /**
2075
- * TODO(b/228525797): Add docs
2076
- * @final
2077
- * @suppress {visibility}
2078
- */
2079
- let MdOutlinedTextField = class MdOutlinedTextField extends OutlinedTextField {
2080
- constructor() {
2081
- super(...arguments);
2082
- this.fieldTag = i$4`md-outlined-field`;
2083
- }
2084
- };
2085
- MdOutlinedTextField.styles = [styles, styles$1];
2086
- MdOutlinedTextField = __decorate([t('md-outlined-text-field')], MdOutlinedTextField);