@spectrum-web-components/textfield 0.0.0-20241209155954

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.
@@ -0,0 +1,347 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __decorateClass = (decorators, target, key, kind) => {
5
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
6
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
7
+ if (decorator = decorators[i])
8
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
9
+ if (kind && result) __defProp(target, key, result);
10
+ return result;
11
+ };
12
+ import {
13
+ html,
14
+ nothing,
15
+ SizedMixin
16
+ } from "@spectrum-web-components/base";
17
+ import {
18
+ ifDefined,
19
+ live
20
+ } from "@spectrum-web-components/base/src/directives.js";
21
+ import {
22
+ property,
23
+ query,
24
+ state
25
+ } from "@spectrum-web-components/base/src/decorators.js";
26
+ import { ManageHelpText } from "@spectrum-web-components/help-text/src/manage-help-text.js";
27
+ import { Focusable } from "@spectrum-web-components/shared/src/focusable.js";
28
+ import "@spectrum-web-components/icons-ui/icons/sp-icon-checkmark100.js";
29
+ import "@spectrum-web-components/icons-workflow/icons/sp-icon-alert.js";
30
+ import textfieldStyles from "./textfield.css.js";
31
+ import checkmarkStyles from "@spectrum-web-components/icon/src/spectrum-icon-checkmark.css.js";
32
+ import checkmarkSmallOverrides from "@spectrum-web-components/icon/src/icon-checkmark-overrides.css.js";
33
+ const textfieldTypes = ["text", "url", "tel", "email", "password"];
34
+ export class TextfieldBase extends ManageHelpText(
35
+ SizedMixin(Focusable, {
36
+ noDefaultSize: true
37
+ })
38
+ ) {
39
+ constructor() {
40
+ super(...arguments);
41
+ this.allowedKeys = "";
42
+ this.focused = false;
43
+ this.invalid = false;
44
+ this.label = "";
45
+ this.placeholder = "";
46
+ this._type = "text";
47
+ this.grows = false;
48
+ this.maxlength = -1;
49
+ this.minlength = -1;
50
+ this.multiline = false;
51
+ this.readonly = false;
52
+ this.rows = -1;
53
+ this.valid = false;
54
+ this._value = "";
55
+ this.quiet = false;
56
+ this.required = false;
57
+ }
58
+ static get styles() {
59
+ return [textfieldStyles, checkmarkStyles, checkmarkSmallOverrides];
60
+ }
61
+ set type(val) {
62
+ const prev = this._type;
63
+ this._type = val;
64
+ this.requestUpdate("type", prev);
65
+ }
66
+ get type() {
67
+ var _a;
68
+ return (_a = textfieldTypes.find((t) => t === this._type)) != null ? _a : "text";
69
+ }
70
+ set value(value) {
71
+ if (value === this.value) {
72
+ return;
73
+ }
74
+ const oldValue = this._value;
75
+ this._value = value;
76
+ this.requestUpdate("value", oldValue);
77
+ }
78
+ get value() {
79
+ return this._value;
80
+ }
81
+ get focusElement() {
82
+ return this.inputElement;
83
+ }
84
+ /**
85
+ * Sets the start and end positions of the current selection.
86
+ *
87
+ * @param selectionStart The 0-based index of the first selected character. An index greater than the length of the
88
+ * element's value is treated as pointing to the end of the value.
89
+ * @param selectionEnd The 0-based index of the character after the last selected character. An index greater than
90
+ * the length of the element's value is treated as pointing to the end of the value.
91
+ * @param [selectionDirection="none"] A string indicating the direction in which the selection is considered to
92
+ * have been performed.
93
+ */
94
+ setSelectionRange(selectionStart, selectionEnd, selectionDirection = "none") {
95
+ this.inputElement.setSelectionRange(
96
+ selectionStart,
97
+ selectionEnd,
98
+ selectionDirection
99
+ );
100
+ }
101
+ /**
102
+ * Selects all the text.
103
+ */
104
+ select() {
105
+ this.inputElement.select();
106
+ }
107
+ handleInput(_event) {
108
+ if (this.allowedKeys && this.inputElement.value) {
109
+ const regExp = new RegExp(`^[${this.allowedKeys}]*$`, "u");
110
+ if (!regExp.test(this.inputElement.value)) {
111
+ const selectionStart = this.inputElement.selectionStart;
112
+ const nextSelectStart = selectionStart - 1;
113
+ this.inputElement.value = this.value.toString();
114
+ this.inputElement.setSelectionRange(
115
+ nextSelectStart,
116
+ nextSelectStart
117
+ );
118
+ return;
119
+ }
120
+ }
121
+ this.value = this.inputElement.value;
122
+ }
123
+ handleChange() {
124
+ this.dispatchEvent(
125
+ new Event("change", {
126
+ bubbles: true,
127
+ composed: true
128
+ })
129
+ );
130
+ }
131
+ onFocus() {
132
+ this.focused = !this.readonly && true;
133
+ }
134
+ onBlur(_event) {
135
+ this.focused = !this.readonly && false;
136
+ }
137
+ handleInputElementPointerdown() {
138
+ }
139
+ renderStateIcons() {
140
+ if (this.invalid) {
141
+ return html`
142
+ <sp-icon-alert id="invalid" class="icon"></sp-icon-alert>
143
+ `;
144
+ } else if (this.valid) {
145
+ return html`
146
+ <sp-icon-checkmark100
147
+ id="valid"
148
+ class="icon spectrum-UIIcon-Checkmark100"
149
+ ></sp-icon-checkmark100>
150
+ `;
151
+ }
152
+ return nothing;
153
+ }
154
+ get displayValue() {
155
+ return this.value.toString();
156
+ }
157
+ // prettier-ignore
158
+ get renderMultiline() {
159
+ return html`
160
+ ${this.multiline && this.grows && this.rows === -1 ? html`
161
+ <div id="sizer" class="input" aria-hidden="true">${this.value}&#8203;
162
+ </div>
163
+ ` : nothing}
164
+ <!-- @ts-ignore -->
165
+ <textarea
166
+ name=${ifDefined(this.name || void 0)}
167
+ aria-describedby=${this.helpTextId}
168
+ aria-label=${this.label || this.appliedLabel || this.placeholder}
169
+ aria-invalid=${ifDefined(this.invalid || void 0)}
170
+ class="input"
171
+ maxlength=${ifDefined(
172
+ this.maxlength > -1 ? this.maxlength : void 0
173
+ )}
174
+ minlength=${ifDefined(
175
+ this.minlength > -1 ? this.minlength : void 0
176
+ )}
177
+ title=${this.invalid ? "" : nothing}
178
+ pattern=${ifDefined(this.pattern)}
179
+ placeholder=${this.placeholder}
180
+ .value=${this.displayValue}
181
+ @change=${this.handleChange}
182
+ @input=${this.handleInput}
183
+ @focus=${this.onFocus}
184
+ @blur=${this.onBlur}
185
+ ?disabled=${this.disabled}
186
+ ?required=${this.required}
187
+ ?readonly=${this.readonly}
188
+ rows=${ifDefined(this.rows > -1 ? this.rows : void 0)}
189
+ autocomplete=${ifDefined(this.autocomplete)}
190
+ ></textarea>
191
+ `;
192
+ }
193
+ get renderInput() {
194
+ return html`
195
+ <!-- @ts-ignore -->
196
+ <input
197
+ name=${ifDefined(this.name || void 0)}
198
+ type=${this.type}
199
+ aria-describedby=${this.helpTextId}
200
+ aria-label=${this.label || this.appliedLabel || this.placeholder}
201
+ aria-invalid=${ifDefined(this.invalid || void 0)}
202
+ class="input"
203
+ title=${this.invalid ? "" : nothing}
204
+ maxlength=${ifDefined(
205
+ this.maxlength > -1 ? this.maxlength : void 0
206
+ )}
207
+ minlength=${ifDefined(
208
+ this.minlength > -1 ? this.minlength : void 0
209
+ )}
210
+ pattern=${ifDefined(this.pattern)}
211
+ placeholder=${this.placeholder}
212
+ .value=${live(this.displayValue)}
213
+ @change=${this.handleChange}
214
+ @input=${this.handleInput}
215
+ @pointerdown=${this.handleInputElementPointerdown}
216
+ @focus=${this.onFocus}
217
+ @blur=${this.onBlur}
218
+ ?disabled=${this.disabled}
219
+ ?required=${this.required}
220
+ ?readonly=${this.readonly}
221
+ autocomplete=${ifDefined(this.autocomplete)}
222
+ />
223
+ `;
224
+ }
225
+ renderField() {
226
+ return html`
227
+ ${this.renderStateIcons()}
228
+ ${this.multiline ? this.renderMultiline : this.renderInput}
229
+ `;
230
+ }
231
+ render() {
232
+ return html`
233
+ <div id="textfield">${this.renderField()}</div>
234
+ ${this.renderHelpText(this.invalid)}
235
+ `;
236
+ }
237
+ update(changedProperties) {
238
+ if (changedProperties.has("value") || changedProperties.has("required") && this.required) {
239
+ this.updateComplete.then(() => {
240
+ this.checkValidity();
241
+ });
242
+ }
243
+ super.update(changedProperties);
244
+ }
245
+ checkValidity() {
246
+ let validity = this.inputElement.checkValidity();
247
+ if (this.required || this.value && this.pattern) {
248
+ if ((this.disabled || this.multiline) && this.pattern) {
249
+ const regex = new RegExp(`^${this.pattern}$`, "u");
250
+ validity = regex.test(this.value.toString());
251
+ }
252
+ if (typeof this.minlength !== "undefined") {
253
+ validity = validity && this.value.toString().length >= this.minlength;
254
+ }
255
+ this.valid = validity;
256
+ this.invalid = !validity;
257
+ }
258
+ return validity;
259
+ }
260
+ }
261
+ __decorateClass([
262
+ state()
263
+ ], TextfieldBase.prototype, "appliedLabel", 2);
264
+ __decorateClass([
265
+ property({ attribute: "allowed-keys" })
266
+ ], TextfieldBase.prototype, "allowedKeys", 2);
267
+ __decorateClass([
268
+ property({ type: Boolean, reflect: true })
269
+ ], TextfieldBase.prototype, "focused", 2);
270
+ __decorateClass([
271
+ query(".input:not(#sizer)")
272
+ ], TextfieldBase.prototype, "inputElement", 2);
273
+ __decorateClass([
274
+ property({ type: Boolean, reflect: true })
275
+ ], TextfieldBase.prototype, "invalid", 2);
276
+ __decorateClass([
277
+ property()
278
+ ], TextfieldBase.prototype, "label", 2);
279
+ __decorateClass([
280
+ property({ type: String, reflect: true })
281
+ ], TextfieldBase.prototype, "name", 2);
282
+ __decorateClass([
283
+ property()
284
+ ], TextfieldBase.prototype, "placeholder", 2);
285
+ __decorateClass([
286
+ state()
287
+ ], TextfieldBase.prototype, "type", 1);
288
+ __decorateClass([
289
+ property({ attribute: "type", reflect: true })
290
+ ], TextfieldBase.prototype, "_type", 2);
291
+ __decorateClass([
292
+ property()
293
+ ], TextfieldBase.prototype, "pattern", 2);
294
+ __decorateClass([
295
+ property({ type: Boolean, reflect: true })
296
+ ], TextfieldBase.prototype, "grows", 2);
297
+ __decorateClass([
298
+ property({ type: Number })
299
+ ], TextfieldBase.prototype, "maxlength", 2);
300
+ __decorateClass([
301
+ property({ type: Number })
302
+ ], TextfieldBase.prototype, "minlength", 2);
303
+ __decorateClass([
304
+ property({ type: Boolean, reflect: true })
305
+ ], TextfieldBase.prototype, "multiline", 2);
306
+ __decorateClass([
307
+ property({ type: Boolean, reflect: true })
308
+ ], TextfieldBase.prototype, "readonly", 2);
309
+ __decorateClass([
310
+ property({ type: Number })
311
+ ], TextfieldBase.prototype, "rows", 2);
312
+ __decorateClass([
313
+ property({ type: Boolean, reflect: true })
314
+ ], TextfieldBase.prototype, "valid", 2);
315
+ __decorateClass([
316
+ property({ type: String })
317
+ ], TextfieldBase.prototype, "value", 1);
318
+ __decorateClass([
319
+ property({ type: Boolean, reflect: true })
320
+ ], TextfieldBase.prototype, "quiet", 2);
321
+ __decorateClass([
322
+ property({ type: Boolean, reflect: true })
323
+ ], TextfieldBase.prototype, "required", 2);
324
+ __decorateClass([
325
+ property({ type: String, reflect: true })
326
+ ], TextfieldBase.prototype, "autocomplete", 2);
327
+ export class Textfield extends TextfieldBase {
328
+ constructor() {
329
+ super(...arguments);
330
+ this._value = "";
331
+ }
332
+ set value(value) {
333
+ if (value === this.value) {
334
+ return;
335
+ }
336
+ const oldValue = this._value;
337
+ this._value = value;
338
+ this.requestUpdate("value", oldValue);
339
+ }
340
+ get value() {
341
+ return this._value;
342
+ }
343
+ }
344
+ __decorateClass([
345
+ property({ type: String })
346
+ ], Textfield.prototype, "value", 1);
347
+ //# sourceMappingURL=Textfield.dev.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["Textfield.ts"],
4
+ "sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport {\n CSSResultArray,\n html,\n nothing,\n PropertyValues,\n SizedMixin,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport {\n ifDefined,\n live,\n} from '@spectrum-web-components/base/src/directives.js';\nimport {\n property,\n query,\n state,\n} from '@spectrum-web-components/base/src/decorators.js';\n\nimport { ManageHelpText } from '@spectrum-web-components/help-text/src/manage-help-text.js';\nimport { Focusable } from '@spectrum-web-components/shared/src/focusable.js';\nimport '@spectrum-web-components/icons-ui/icons/sp-icon-checkmark100.js';\nimport '@spectrum-web-components/icons-workflow/icons/sp-icon-alert.js';\n\nimport textfieldStyles from './textfield.css.js';\nimport checkmarkStyles from '@spectrum-web-components/icon/src/spectrum-icon-checkmark.css.js';\nimport checkmarkSmallOverrides from '@spectrum-web-components/icon/src/icon-checkmark-overrides.css.js';\n\nconst textfieldTypes = ['text', 'url', 'tel', 'email', 'password'] as const;\nexport type TextfieldType = (typeof textfieldTypes)[number];\n\n/**\n * @fires input - The value of the element has changed.\n * @fires change - An alteration to the value of the element has been committed by the user.\n */\nexport class TextfieldBase extends ManageHelpText(\n SizedMixin(Focusable, {\n noDefaultSize: true,\n })\n) {\n public static override get styles(): CSSResultArray {\n return [textfieldStyles, checkmarkStyles, checkmarkSmallOverrides];\n }\n\n @state()\n protected appliedLabel?: string;\n\n /**\n * A regular expression outlining the keys that will be allowed to update the value of the form control.\n */\n @property({ attribute: 'allowed-keys' })\n allowedKeys = '';\n\n /**\n * @private\n */\n @property({ type: Boolean, reflect: true })\n public focused = false;\n\n @query('.input:not(#sizer)')\n protected inputElement!: HTMLInputElement | HTMLTextAreaElement;\n\n /**\n * Whether the `value` held by the form control is invalid.\n */\n @property({ type: Boolean, reflect: true })\n public invalid = false;\n\n /**\n * A string applied via `aria-label` to the form control when a user visible label is not provided.\n */\n @property()\n public label = '';\n\n /**\n * Name of the form control.\n */\n @property({ type: String, reflect: true })\n public name: string | undefined;\n\n /**\n * Text that appears in the form control when it has no value set\n */\n @property()\n public placeholder = '';\n\n @state()\n set type(val: TextfieldType) {\n const prev = this._type;\n this._type = val;\n this.requestUpdate('type', prev);\n }\n\n get type(): TextfieldType {\n return textfieldTypes.find((t) => t === this._type) ?? 'text';\n }\n\n /**\n * @private\n * This binding allows for invalid value for `type` to still be reflected to the DOM\n */\n @property({ attribute: 'type', reflect: true })\n private _type: TextfieldType = 'text';\n\n /**\n * Pattern the `value` must match to be valid\n */\n @property()\n public pattern?: string;\n\n /**\n * Whether a form control delivered with the `multiline` attribute will change size\n * vertically to accomodate longer input\n */\n @property({ type: Boolean, reflect: true })\n public grows = false;\n\n /**\n * Defines the maximum string length that the user can enter\n */\n @property({ type: Number })\n public maxlength = -1;\n\n /**\n * Defines the minimum string length that the user can enter\n */\n @property({ type: Number })\n public minlength = -1;\n\n /**\n * Whether the form control should accept a value longer than one line\n */\n @property({ type: Boolean, reflect: true })\n public multiline = false;\n\n /**\n * Whether a user can interact with the value of the form control\n */\n @property({ type: Boolean, reflect: true })\n public readonly = false;\n\n /**\n * The specific number of rows the form control should provide in the user interface\n */\n @property({ type: Number })\n public rows = -1;\n\n /**\n * Whether the `value` held by the form control is valid.\n */\n @property({ type: Boolean, reflect: true })\n public valid = false;\n\n /**\n * The value held by the form control\n */\n @property({ type: String })\n public set value(value: string | number) {\n if (value === this.value) {\n return;\n }\n const oldValue = this._value;\n this._value = value;\n this.requestUpdate('value', oldValue);\n }\n\n public get value(): string | number {\n return this._value;\n }\n\n protected _value: string | number = '';\n\n /**\n * Whether to display the form control with no visible background\n */\n @property({ type: Boolean, reflect: true })\n public quiet = false;\n\n /**\n * Whether the form control will be found to be invalid when it holds no `value`\n */\n @property({ type: Boolean, reflect: true })\n public required = false;\n\n /**\n * What form of assistance should be provided when attempting to supply a value to the form control\n */\n @property({ type: String, reflect: true })\n public autocomplete?:\n | 'list'\n | 'none'\n | HTMLInputElement['autocomplete']\n | HTMLTextAreaElement['autocomplete'];\n\n public override get focusElement(): HTMLInputElement | HTMLTextAreaElement {\n return this.inputElement;\n }\n\n /**\n * Sets the start and end positions of the current selection.\n *\n * @param selectionStart The 0-based index of the first selected character. An index greater than the length of the\n * element's value is treated as pointing to the end of the value.\n * @param selectionEnd The 0-based index of the character after the last selected character. An index greater than\n * the length of the element's value is treated as pointing to the end of the value.\n * @param [selectionDirection=\"none\"] A string indicating the direction in which the selection is considered to\n * have been performed.\n */\n public setSelectionRange(\n selectionStart: number,\n selectionEnd: number,\n selectionDirection: 'forward' | 'backward' | 'none' = 'none'\n ): void {\n this.inputElement.setSelectionRange(\n selectionStart,\n selectionEnd,\n selectionDirection\n );\n }\n\n /**\n * Selects all the text.\n */\n public select(): void {\n this.inputElement.select();\n }\n\n protected handleInput(_event: Event): void {\n if (this.allowedKeys && this.inputElement.value) {\n const regExp = new RegExp(`^[${this.allowedKeys}]*$`, 'u');\n if (!regExp.test(this.inputElement.value)) {\n const selectionStart = this.inputElement\n .selectionStart as number;\n const nextSelectStart = selectionStart - 1;\n this.inputElement.value = this.value.toString();\n this.inputElement.setSelectionRange(\n nextSelectStart,\n nextSelectStart\n );\n return;\n }\n }\n this.value = this.inputElement.value;\n }\n\n protected handleChange(): void {\n this.dispatchEvent(\n new Event('change', {\n bubbles: true,\n composed: true,\n })\n );\n }\n\n protected onFocus(): void {\n this.focused = !this.readonly && true;\n }\n\n protected onBlur(_event: FocusEvent): void {\n this.focused = !this.readonly && false;\n }\n\n protected handleInputElementPointerdown(): void {}\n\n protected renderStateIcons(): TemplateResult | typeof nothing {\n if (this.invalid) {\n return html`\n <sp-icon-alert id=\"invalid\" class=\"icon\"></sp-icon-alert>\n `;\n } else if (this.valid) {\n return html`\n <sp-icon-checkmark100\n id=\"valid\"\n class=\"icon spectrum-UIIcon-Checkmark100\"\n ></sp-icon-checkmark100>\n `;\n }\n return nothing;\n }\n\n protected get displayValue(): string {\n return this.value.toString();\n }\n\n // prettier-ignore\n private get renderMultiline(): TemplateResult {\n return html`\n ${this.multiline && this.grows && this.rows === -1\n ? html`\n <div id=\"sizer\" class=\"input\" aria-hidden=\"true\">${this.value}&#8203;\n </div>\n `\n : nothing}\n <!-- @ts-ignore -->\n <textarea\n name=${ifDefined(this.name || undefined)}\n aria-describedby=${this.helpTextId}\n aria-label=${this.label ||\n this.appliedLabel ||\n this.placeholder}\n aria-invalid=${ifDefined(this.invalid || undefined)}\n class=\"input\"\n maxlength=${ifDefined(\n this.maxlength > -1 ? this.maxlength : undefined\n )}\n minlength=${ifDefined(\n this.minlength > -1 ? this.minlength : undefined\n )}\n title=${this.invalid ? '' : nothing}\n pattern=${ifDefined(this.pattern)}\n placeholder=${this.placeholder}\n .value=${this.displayValue}\n @change=${this.handleChange}\n @input=${this.handleInput}\n @focus=${this.onFocus}\n @blur=${this.onBlur}\n ?disabled=${this.disabled}\n ?required=${this.required}\n ?readonly=${this.readonly}\n rows=${ifDefined(this.rows > -1 ? this.rows : undefined)}\n autocomplete=${ifDefined(this.autocomplete)}\n ></textarea>\n `;\n }\n\n private get renderInput(): TemplateResult {\n return html`\n <!-- @ts-ignore -->\n <input\n name=${ifDefined(this.name || undefined)}\n type=${this.type}\n aria-describedby=${this.helpTextId}\n aria-label=${this.label ||\n this.appliedLabel ||\n this.placeholder}\n aria-invalid=${ifDefined(this.invalid || undefined)}\n class=\"input\"\n title=${this.invalid ? '' : nothing}\n maxlength=${ifDefined(\n this.maxlength > -1 ? this.maxlength : undefined\n )}\n minlength=${ifDefined(\n this.minlength > -1 ? this.minlength : undefined\n )}\n pattern=${ifDefined(this.pattern)}\n placeholder=${this.placeholder}\n .value=${live(this.displayValue)}\n @change=${this.handleChange}\n @input=${this.handleInput}\n @pointerdown=${this.handleInputElementPointerdown}\n @focus=${this.onFocus}\n @blur=${this.onBlur}\n ?disabled=${this.disabled}\n ?required=${this.required}\n ?readonly=${this.readonly}\n autocomplete=${ifDefined(this.autocomplete)}\n />\n `;\n }\n\n protected renderField(): TemplateResult {\n return html`\n ${this.renderStateIcons()}\n ${this.multiline ? this.renderMultiline : this.renderInput}\n `;\n }\n\n protected override render(): TemplateResult {\n return html`\n <div id=\"textfield\">${this.renderField()}</div>\n ${this.renderHelpText(this.invalid)}\n `;\n }\n\n protected override update(changedProperties: PropertyValues): void {\n if (\n changedProperties.has('value') ||\n (changedProperties.has('required') && this.required)\n ) {\n this.updateComplete.then(() => {\n this.checkValidity();\n });\n }\n super.update(changedProperties);\n }\n\n public checkValidity(): boolean {\n let validity = this.inputElement.checkValidity();\n if (this.required || (this.value && this.pattern)) {\n if ((this.disabled || this.multiline) && this.pattern) {\n const regex = new RegExp(`^${this.pattern}$`, 'u');\n validity = regex.test(this.value.toString());\n }\n if (typeof this.minlength !== 'undefined') {\n validity =\n validity && this.value.toString().length >= this.minlength;\n }\n this.valid = validity;\n this.invalid = !validity;\n }\n return validity;\n }\n}\n\n/**\n * @element sp-textfield\n * @slot help-text - default or non-negative help text to associate to your form element\n * @slot negative-help-text - negative help text to associate to your form element when `invalid`\n */\nexport class Textfield extends TextfieldBase {\n @property({ type: String })\n public override set value(value: string) {\n if (value === this.value) {\n return;\n }\n const oldValue = this._value;\n this._value = value;\n this.requestUpdate('value', oldValue);\n }\n\n public override get value(): string {\n return this._value;\n }\n\n protected override _value = '';\n}\n"],
5
+ "mappings": ";;;;;;;;;;;AAYA;AAAA,EAEI;AAAA,EACA;AAAA,EAEA;AAAA,OAEG;AACP;AAAA,EACI;AAAA,EACA;AAAA,OACG;AACP;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,OACG;AAEP,SAAS,sBAAsB;AAC/B,SAAS,iBAAiB;AAC1B,OAAO;AACP,OAAO;AAEP,OAAO,qBAAqB;AAC5B,OAAO,qBAAqB;AAC5B,OAAO,6BAA6B;AAEpC,MAAM,iBAAiB,CAAC,QAAQ,OAAO,OAAO,SAAS,UAAU;AAO1D,aAAM,sBAAsB;AAAA,EAC/B,WAAW,WAAW;AAAA,IAClB,eAAe;AAAA,EACnB,CAAC;AACL,EAAE;AAAA,EAJK;AAAA;AAgBH,uBAAc;AAMd,SAAO,UAAU;AASjB,SAAO,UAAU;AAMjB,SAAO,QAAQ;AAYf,SAAO,cAAc;AAkBrB,SAAQ,QAAuB;AAa/B,SAAO,QAAQ;AAMf,SAAO,YAAY;AAMnB,SAAO,YAAY;AAMnB,SAAO,YAAY;AAMnB,SAAO,WAAW;AAMlB,SAAO,OAAO;AAMd,SAAO,QAAQ;A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AM,WAAW,KAAK;AACtB,SAAK,SAAS;AACd,SAAK,cAAc,SAAS,QAAQ;AAAA,EACxC;AAAA,EAEA,IAAoB,QAAgB;AAChC,WAAO,KAAK;AAAA,EAChB;AAGJ;AAdwB;AAAA,EADnB,SAAS,EAAE,MAAM,OAAO,CAAC;AAAA,GADjB,UAEW;",
6
+ "names": []
7
+ }
@@ -0,0 +1,68 @@
1
+ "use strict";var c=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var t=(p,a,e,l)=>{for(var r=l>1?void 0:l?m(a,e):a,u=p.length-1,h;u>=0;u--)(h=p[u])&&(r=(l?h(a,e,r):h(r))||r);return l&&r&&c(a,e,r),r};import{html as s,nothing as o,SizedMixin as v}from"@spectrum-web-components/base";import{ifDefined as n,live as y}from"@spectrum-web-components/base/src/directives.js";import{property as i,query as b,state as d}from"@spectrum-web-components/base/src/decorators.js";import{ManageHelpText as g}from"@spectrum-web-components/help-text/src/manage-help-text.js";import{Focusable as f}from"@spectrum-web-components/shared/src/focusable.js";import"@spectrum-web-components/icons-ui/icons/sp-icon-checkmark100.js";import"@spectrum-web-components/icons-workflow/icons/sp-icon-alert.js";import $ from"./textfield.css.js";import E from"@spectrum-web-components/icon/src/spectrum-icon-checkmark.css.js";import S from"@spectrum-web-components/icon/src/icon-checkmark-overrides.css.js";const w=["text","url","tel","email","password"];export class TextfieldBase extends g(v(f,{noDefaultSize:!0})){constructor(){super(...arguments);this.allowedKeys="";this.focused=!1;this.invalid=!1;this.label="";this.placeholder="";this._type="text";this.grows=!1;this.maxlength=-1;this.minlength=-1;this.multiline=!1;this.readonly=!1;this.rows=-1;this.valid=!1;this._value="";this.quiet=!1;this.required=!1}static get styles(){return[$,E,S]}set type(e){const l=this._type;this._type=e,this.requestUpdate("type",l)}get type(){var e;return(e=w.find(l=>l===this._type))!=null?e:"text"}set value(e){if(e===this.value)return;const l=this._value;this._value=e,this.requestUpdate("value",l)}get value(){return this._value}get focusElement(){return this.inputElement}setSelectionRange(e,l,r="none"){this.inputElement.setSelectionRange(e,l,r)}select(){this.inputElement.select()}handleInput(e){if(this.allowedKeys&&this.inputElement.value&&!new RegExp(`^[${this.allowedKeys}]*$`,"u").test(this.inputElement.value)){const u=this.inputElement.selectionStart-1;this.inputElement.value=this.value.toString(),this.inputElement.setSelectionRange(u,u);return}this.value=this.inputElement.value}handleChange(){this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}onFocus(){this.focused=!this.readonly&&!0}onBlur(e){this.focused=!this.readonly&&!1}handleInputElementPointerdown(){}renderStateIcons(){return this.invalid?s`
2
+ <sp-icon-alert id="invalid" class="icon"></sp-icon-alert>
3
+ `:this.valid?s`
4
+ <sp-icon-checkmark100
5
+ id="valid"
6
+ class="icon spectrum-UIIcon-Checkmark100"
7
+ ></sp-icon-checkmark100>
8
+ `:o}get displayValue(){return this.value.toString()}get renderMultiline(){return s`
9
+ ${this.multiline&&this.grows&&this.rows===-1?s`
10
+ <div id="sizer" class="input" aria-hidden="true">${this.value}&#8203;
11
+ </div>
12
+ `:o}
13
+ <!-- @ts-ignore -->
14
+ <textarea
15
+ name=${n(this.name||void 0)}
16
+ aria-describedby=${this.helpTextId}
17
+ aria-label=${this.label||this.appliedLabel||this.placeholder}
18
+ aria-invalid=${n(this.invalid||void 0)}
19
+ class="input"
20
+ maxlength=${n(this.maxlength>-1?this.maxlength:void 0)}
21
+ minlength=${n(this.minlength>-1?this.minlength:void 0)}
22
+ title=${this.invalid?"":o}
23
+ pattern=${n(this.pattern)}
24
+ placeholder=${this.placeholder}
25
+ .value=${this.displayValue}
26
+ @change=${this.handleChange}
27
+ @input=${this.handleInput}
28
+ @focus=${this.onFocus}
29
+ @blur=${this.onBlur}
30
+ ?disabled=${this.disabled}
31
+ ?required=${this.required}
32
+ ?readonly=${this.readonly}
33
+ rows=${n(this.rows>-1?this.rows:void 0)}
34
+ autocomplete=${n(this.autocomplete)}
35
+ ></textarea>
36
+ `}get renderInput(){return s`
37
+ <!-- @ts-ignore -->
38
+ <input
39
+ name=${n(this.name||void 0)}
40
+ type=${this.type}
41
+ aria-describedby=${this.helpTextId}
42
+ aria-label=${this.label||this.appliedLabel||this.placeholder}
43
+ aria-invalid=${n(this.invalid||void 0)}
44
+ class="input"
45
+ title=${this.invalid?"":o}
46
+ maxlength=${n(this.maxlength>-1?this.maxlength:void 0)}
47
+ minlength=${n(this.minlength>-1?this.minlength:void 0)}
48
+ pattern=${n(this.pattern)}
49
+ placeholder=${this.placeholder}
50
+ .value=${y(this.displayValue)}
51
+ @change=${this.handleChange}
52
+ @input=${this.handleInput}
53
+ @pointerdown=${this.handleInputElementPointerdown}
54
+ @focus=${this.onFocus}
55
+ @blur=${this.onBlur}
56
+ ?disabled=${this.disabled}
57
+ ?required=${this.required}
58
+ ?readonly=${this.readonly}
59
+ autocomplete=${n(this.autocomplete)}
60
+ />
61
+ `}renderField(){return s`
62
+ ${this.renderStateIcons()}
63
+ ${this.multiline?this.renderMultiline:this.renderInput}
64
+ `}render(){return s`
65
+ <div id="textfield">${this.renderField()}</div>
66
+ ${this.renderHelpText(this.invalid)}
67
+ `}update(e){(e.has("value")||e.has("required")&&this.required)&&this.updateComplete.then(()=>{this.checkValidity()}),super.update(e)}checkValidity(){let e=this.inputElement.checkValidity();return(this.required||this.value&&this.pattern)&&((this.disabled||this.multiline)&&this.pattern&&(e=new RegExp(`^${this.pattern}$`,"u").test(this.value.toString())),typeof this.minlength!="undefined"&&(e=e&&this.value.toString().length>=this.minlength),this.valid=e,this.invalid=!e),e}}t([d()],TextfieldBase.prototype,"appliedLabel",2),t([i({attribute:"allowed-keys"})],TextfieldBase.prototype,"allowedKeys",2),t([i({type:Boolean,reflect:!0})],TextfieldBase.prototype,"focused",2),t([b(".input:not(#sizer)")],TextfieldBase.prototype,"inputElement",2),t([i({type:Boolean,reflect:!0})],TextfieldBase.prototype,"invalid",2),t([i()],TextfieldBase.prototype,"label",2),t([i({type:String,reflect:!0})],TextfieldBase.prototype,"name",2),t([i()],TextfieldBase.prototype,"placeholder",2),t([d()],TextfieldBase.prototype,"type",1),t([i({attribute:"type",reflect:!0})],TextfieldBase.prototype,"_type",2),t([i()],TextfieldBase.prototype,"pattern",2),t([i({type:Boolean,reflect:!0})],TextfieldBase.prototype,"grows",2),t([i({type:Number})],TextfieldBase.prototype,"maxlength",2),t([i({type:Number})],TextfieldBase.prototype,"minlength",2),t([i({type:Boolean,reflect:!0})],TextfieldBase.prototype,"multiline",2),t([i({type:Boolean,reflect:!0})],TextfieldBase.prototype,"readonly",2),t([i({type:Number})],TextfieldBase.prototype,"rows",2),t([i({type:Boolean,reflect:!0})],TextfieldBase.prototype,"valid",2),t([i({type:String})],TextfieldBase.prototype,"value",1),t([i({type:Boolean,reflect:!0})],TextfieldBase.prototype,"quiet",2),t([i({type:Boolean,reflect:!0})],TextfieldBase.prototype,"required",2),t([i({type:String,reflect:!0})],TextfieldBase.prototype,"autocomplete",2);export class Textfield extends TextfieldBase{constructor(){super(...arguments);this._value=""}set value(e){if(e===this.value)return;const l=this._value;this._value=e,this.requestUpdate("value",l)}get value(){return this._value}}t([i({type:String})],Textfield.prototype,"value",1);
68
+ //# sourceMappingURL=Textfield.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["Textfield.ts"],
4
+ "sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport {\n CSSResultArray,\n html,\n nothing,\n PropertyValues,\n SizedMixin,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport {\n ifDefined,\n live,\n} from '@spectrum-web-components/base/src/directives.js';\nimport {\n property,\n query,\n state,\n} from '@spectrum-web-components/base/src/decorators.js';\n\nimport { ManageHelpText } from '@spectrum-web-components/help-text/src/manage-help-text.js';\nimport { Focusable } from '@spectrum-web-components/shared/src/focusable.js';\nimport '@spectrum-web-components/icons-ui/icons/sp-icon-checkmark100.js';\nimport '@spectrum-web-components/icons-workflow/icons/sp-icon-alert.js';\n\nimport textfieldStyles from './textfield.css.js';\nimport checkmarkStyles from '@spectrum-web-components/icon/src/spectrum-icon-checkmark.css.js';\nimport checkmarkSmallOverrides from '@spectrum-web-components/icon/src/icon-checkmark-overrides.css.js';\n\nconst textfieldTypes = ['text', 'url', 'tel', 'email', 'password'] as const;\nexport type TextfieldType = (typeof textfieldTypes)[number];\n\n/**\n * @fires input - The value of the element has changed.\n * @fires change - An alteration to the value of the element has been committed by the user.\n */\nexport class TextfieldBase extends ManageHelpText(\n SizedMixin(Focusable, {\n noDefaultSize: true,\n })\n) {\n public static override get styles(): CSSResultArray {\n return [textfieldStyles, checkmarkStyles, checkmarkSmallOverrides];\n }\n\n @state()\n protected appliedLabel?: string;\n\n /**\n * A regular expression outlining the keys that will be allowed to update the value of the form control.\n */\n @property({ attribute: 'allowed-keys' })\n allowedKeys = '';\n\n /**\n * @private\n */\n @property({ type: Boolean, reflect: true })\n public focused = false;\n\n @query('.input:not(#sizer)')\n protected inputElement!: HTMLInputElement | HTMLTextAreaElement;\n\n /**\n * Whether the `value` held by the form control is invalid.\n */\n @property({ type: Boolean, reflect: true })\n public invalid = false;\n\n /**\n * A string applied via `aria-label` to the form control when a user visible label is not provided.\n */\n @property()\n public label = '';\n\n /**\n * Name of the form control.\n */\n @property({ type: String, reflect: true })\n public name: string | undefined;\n\n /**\n * Text that appears in the form control when it has no value set\n */\n @property()\n public placeholder = '';\n\n @state()\n set type(val: TextfieldType) {\n const prev = this._type;\n this._type = val;\n this.requestUpdate('type', prev);\n }\n\n get type(): TextfieldType {\n return textfieldTypes.find((t) => t === this._type) ?? 'text';\n }\n\n /**\n * @private\n * This binding allows for invalid value for `type` to still be reflected to the DOM\n */\n @property({ attribute: 'type', reflect: true })\n private _type: TextfieldType = 'text';\n\n /**\n * Pattern the `value` must match to be valid\n */\n @property()\n public pattern?: string;\n\n /**\n * Whether a form control delivered with the `multiline` attribute will change size\n * vertically to accomodate longer input\n */\n @property({ type: Boolean, reflect: true })\n public grows = false;\n\n /**\n * Defines the maximum string length that the user can enter\n */\n @property({ type: Number })\n public maxlength = -1;\n\n /**\n * Defines the minimum string length that the user can enter\n */\n @property({ type: Number })\n public minlength = -1;\n\n /**\n * Whether the form control should accept a value longer than one line\n */\n @property({ type: Boolean, reflect: true })\n public multiline = false;\n\n /**\n * Whether a user can interact with the value of the form control\n */\n @property({ type: Boolean, reflect: true })\n public readonly = false;\n\n /**\n * The specific number of rows the form control should provide in the user interface\n */\n @property({ type: Number })\n public rows = -1;\n\n /**\n * Whether the `value` held by the form control is valid.\n */\n @property({ type: Boolean, reflect: true })\n public valid = false;\n\n /**\n * The value held by the form control\n */\n @property({ type: String })\n public set value(value: string | number) {\n if (value === this.value) {\n return;\n }\n const oldValue = this._value;\n this._value = value;\n this.requestUpdate('value', oldValue);\n }\n\n public get value(): string | number {\n return this._value;\n }\n\n protected _value: string | number = '';\n\n /**\n * Whether to display the form control with no visible background\n */\n @property({ type: Boolean, reflect: true })\n public quiet = false;\n\n /**\n * Whether the form control will be found to be invalid when it holds no `value`\n */\n @property({ type: Boolean, reflect: true })\n public required = false;\n\n /**\n * What form of assistance should be provided when attempting to supply a value to the form control\n */\n @property({ type: String, reflect: true })\n public autocomplete?:\n | 'list'\n | 'none'\n | HTMLInputElement['autocomplete']\n | HTMLTextAreaElement['autocomplete'];\n\n public override get focusElement(): HTMLInputElement | HTMLTextAreaElement {\n return this.inputElement;\n }\n\n /**\n * Sets the start and end positions of the current selection.\n *\n * @param selectionStart The 0-based index of the first selected character. An index greater than the length of the\n * element's value is treated as pointing to the end of the value.\n * @param selectionEnd The 0-based index of the character after the last selected character. An index greater than\n * the length of the element's value is treated as pointing to the end of the value.\n * @param [selectionDirection=\"none\"] A string indicating the direction in which the selection is considered to\n * have been performed.\n */\n public setSelectionRange(\n selectionStart: number,\n selectionEnd: number,\n selectionDirection: 'forward' | 'backward' | 'none' = 'none'\n ): void {\n this.inputElement.setSelectionRange(\n selectionStart,\n selectionEnd,\n selectionDirection\n );\n }\n\n /**\n * Selects all the text.\n */\n public select(): void {\n this.inputElement.select();\n }\n\n protected handleInput(_event: Event): void {\n if (this.allowedKeys && this.inputElement.value) {\n const regExp = new RegExp(`^[${this.allowedKeys}]*$`, 'u');\n if (!regExp.test(this.inputElement.value)) {\n const selectionStart = this.inputElement\n .selectionStart as number;\n const nextSelectStart = selectionStart - 1;\n this.inputElement.value = this.value.toString();\n this.inputElement.setSelectionRange(\n nextSelectStart,\n nextSelectStart\n );\n return;\n }\n }\n this.value = this.inputElement.value;\n }\n\n protected handleChange(): void {\n this.dispatchEvent(\n new Event('change', {\n bubbles: true,\n composed: true,\n })\n );\n }\n\n protected onFocus(): void {\n this.focused = !this.readonly && true;\n }\n\n protected onBlur(_event: FocusEvent): void {\n this.focused = !this.readonly && false;\n }\n\n protected handleInputElementPointerdown(): void {}\n\n protected renderStateIcons(): TemplateResult | typeof nothing {\n if (this.invalid) {\n return html`\n <sp-icon-alert id=\"invalid\" class=\"icon\"></sp-icon-alert>\n `;\n } else if (this.valid) {\n return html`\n <sp-icon-checkmark100\n id=\"valid\"\n class=\"icon spectrum-UIIcon-Checkmark100\"\n ></sp-icon-checkmark100>\n `;\n }\n return nothing;\n }\n\n protected get displayValue(): string {\n return this.value.toString();\n }\n\n // prettier-ignore\n private get renderMultiline(): TemplateResult {\n return html`\n ${this.multiline && this.grows && this.rows === -1\n ? html`\n <div id=\"sizer\" class=\"input\" aria-hidden=\"true\">${this.value}&#8203;\n </div>\n `\n : nothing}\n <!-- @ts-ignore -->\n <textarea\n name=${ifDefined(this.name || undefined)}\n aria-describedby=${this.helpTextId}\n aria-label=${this.label ||\n this.appliedLabel ||\n this.placeholder}\n aria-invalid=${ifDefined(this.invalid || undefined)}\n class=\"input\"\n maxlength=${ifDefined(\n this.maxlength > -1 ? this.maxlength : undefined\n )}\n minlength=${ifDefined(\n this.minlength > -1 ? this.minlength : undefined\n )}\n title=${this.invalid ? '' : nothing}\n pattern=${ifDefined(this.pattern)}\n placeholder=${this.placeholder}\n .value=${this.displayValue}\n @change=${this.handleChange}\n @input=${this.handleInput}\n @focus=${this.onFocus}\n @blur=${this.onBlur}\n ?disabled=${this.disabled}\n ?required=${this.required}\n ?readonly=${this.readonly}\n rows=${ifDefined(this.rows > -1 ? this.rows : undefined)}\n autocomplete=${ifDefined(this.autocomplete)}\n ></textarea>\n `;\n }\n\n private get renderInput(): TemplateResult {\n return html`\n <!-- @ts-ignore -->\n <input\n name=${ifDefined(this.name || undefined)}\n type=${this.type}\n aria-describedby=${this.helpTextId}\n aria-label=${this.label ||\n this.appliedLabel ||\n this.placeholder}\n aria-invalid=${ifDefined(this.invalid || undefined)}\n class=\"input\"\n title=${this.invalid ? '' : nothing}\n maxlength=${ifDefined(\n this.maxlength > -1 ? this.maxlength : undefined\n )}\n minlength=${ifDefined(\n this.minlength > -1 ? this.minlength : undefined\n )}\n pattern=${ifDefined(this.pattern)}\n placeholder=${this.placeholder}\n .value=${live(this.displayValue)}\n @change=${this.handleChange}\n @input=${this.handleInput}\n @pointerdown=${this.handleInputElementPointerdown}\n @focus=${this.onFocus}\n @blur=${this.onBlur}\n ?disabled=${this.disabled}\n ?required=${this.required}\n ?readonly=${this.readonly}\n autocomplete=${ifDefined(this.autocomplete)}\n />\n `;\n }\n\n protected renderField(): TemplateResult {\n return html`\n ${this.renderStateIcons()}\n ${this.multiline ? this.renderMultiline : this.renderInput}\n `;\n }\n\n protected override render(): TemplateResult {\n return html`\n <div id=\"textfield\">${this.renderField()}</div>\n ${this.renderHelpText(this.invalid)}\n `;\n }\n\n protected override update(changedProperties: PropertyValues): void {\n if (\n changedProperties.has('value') ||\n (changedProperties.has('required') && this.required)\n ) {\n this.updateComplete.then(() => {\n this.checkValidity();\n });\n }\n super.update(changedProperties);\n }\n\n public checkValidity(): boolean {\n let validity = this.inputElement.checkValidity();\n if (this.required || (this.value && this.pattern)) {\n if ((this.disabled || this.multiline) && this.pattern) {\n const regex = new RegExp(`^${this.pattern}$`, 'u');\n validity = regex.test(this.value.toString());\n }\n if (typeof this.minlength !== 'undefined') {\n validity =\n validity && this.value.toString().length >= this.minlength;\n }\n this.valid = validity;\n this.invalid = !validity;\n }\n return validity;\n }\n}\n\n/**\n * @element sp-textfield\n * @slot help-text - default or non-negative help text to associate to your form element\n * @slot negative-help-text - negative help text to associate to your form element when `invalid`\n */\nexport class Textfield extends TextfieldBase {\n @property({ type: String })\n public override set value(value: string) {\n if (value === this.value) {\n return;\n }\n const oldValue = this._value;\n this._value = value;\n this.requestUpdate('value', oldValue);\n }\n\n public override get value(): string {\n return this._value;\n }\n\n protected override _value = '';\n}\n"],
5
+ "mappings": "qNAYA,OAEI,QAAAA,EACA,WAAAC,EAEA,cAAAC,MAEG,gCACP,OACI,aAAAC,EACA,QAAAC,MACG,kDACP,OACI,YAAAC,EACA,SAAAC,EACA,SAAAC,MACG,kDAEP,OAAS,kBAAAC,MAAsB,6DAC/B,OAAS,aAAAC,MAAiB,mDAC1B,MAAO,kEACP,MAAO,iEAEP,OAAOC,MAAqB,qBAC5B,OAAOC,MAAqB,mEAC5B,OAAOC,MAA6B,oEAEpC,MAAMC,EAAiB,CAAC,OAAQ,MAAO,MAAO,QAAS,UAAU,EAO1D,aAAM,sBAAsBL,EAC/BN,EAAWO,EAAW,CAClB,cAAe,EACnB,CAAC,CACL,CAAE,CAJK,kCAgBH,iBAAc,GAMd,KAAO,QAAU,GASjB,KAAO,QAAU,GAMjB,KAAO,MAAQ,GAYf,KAAO,YAAc,GAkBrB,KAAQ,MAAuB,OAa/B,KAAO,MAAQ,GAMf,KAAO,UAAY,GAMnB,KAAO,UAAY,GAMnB,KAAO,UAAY,GAMnB,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,cAwGF,wBAMAsB,EAAA,CADNtB,EAAS,CAAE,KAAM,MAAO,CAAC,GA7GjB,cA8GF,oBAMAsB,EAAA,CADNtB,EAAS,CAAE,KAAM,QAAS,QAAS,EAAK,CAAC,GAnHjC,cAoHF,qBAMIsB,EAAA,CADVtB,EAAS,CAAE,KAAM,MAAO,CAAC,GAzHjB,cA0HE,qBAmBJsB,EAAA,CADNtB,EAAS,CAAE,KAAM,QAAS,QAAS,EAAK,CAAC,GA5IjC,cA6IF,qBAMAsB,EAAA,CADNtB,EAAS,CAAE,KAAM,QAAS,QAAS,EAAK,CAAC,GAlJjC,cAmJF,wBAMAsB,EAAA,CADNtB,EAAS,CAAE,KAAM,OAAQ,QAAS,EAAK,CAAC,GAxJhC,cAyJF,4BA6NJ,aAAM,kBAAkB,aAAc,CAAtC,kCAeH,KAAmB,OAAS,GAb5B,IAAoB,MAAMa,EAAe,CACrC,GAAIA,IAAU,KAAK,MACf,OAEJ,MAAMC,EAAW,KAAK,OACtB,KAAK,OAASD,EACd,KAAK,cAAc,QAASC,CAAQ,CACxC,CAEA,IAAoB,OAAgB,CAChC,OAAO,KAAK,MAChB,CAGJ,CAdwBQ,EAAA,CADnBtB,EAAS,CAAE,KAAM,MAAO,CAAC,GADjB,UAEW",
6
+ "names": ["html", "nothing", "SizedMixin", "ifDefined", "live", "property", "query", "state", "ManageHelpText", "Focusable", "textfieldStyles", "checkmarkStyles", "checkmarkSmallOverrides", "textfieldTypes", "val", "prev", "_a", "t", "value", "oldValue", "selectionStart", "selectionEnd", "selectionDirection", "_event", "nextSelectStart", "changedProperties", "validity", "__decorateClass"]
7
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './Textfield.js';
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ export * from "./Textfield.dev.js";
3
+ //# sourceMappingURL=index.dev.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["index.ts"],
4
+ "sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nexport * from './Textfield.dev.js'\n"],
5
+ "mappings": ";AAWA,cAAc;",
6
+ "names": []
7
+ }
package/src/index.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";export*from"./Textfield.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["index.ts"],
4
+ "sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nexport * from './Textfield.js';\n"],
5
+ "mappings": "aAWA,WAAc",
6
+ "names": []
7
+ }
@@ -0,0 +1,80 @@
1
+ // @ts-check
2
+ /*
3
+ Copyright 2023 Adobe. All rights reserved.
4
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License. You may obtain a copy
6
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
7
+
8
+ Unless required by applicable law or agreed to in writing, software distributed under
9
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
10
+ OF ANY KIND, either express or implied. See the License for the specific language
11
+ governing permissions and limitations under the License.
12
+ */
13
+
14
+ import {
15
+ builder,
16
+ converterFor,
17
+ } from '../../../tasks/process-spectrum-utils.js';
18
+
19
+ const converter = converterFor('spectrum-Textfield');
20
+
21
+ /**
22
+ * @type { import('../../../tasks/spectrum-css-converter').SpectrumCSSConverter }
23
+ */
24
+ export default {
25
+ conversions: [
26
+ {
27
+ inPackage: '@spectrum-css/textfield',
28
+ outPackage: 'textfield',
29
+ fileName: 'textfield',
30
+ hoistCustomPropertiesFrom: 'spectrum-Textfield',
31
+ excludeByComponents: [builder.class('🤫')],
32
+ components: [
33
+ converter.classToId('spectrum-Textfield', 'textfield'),
34
+ converter.classToClass('spectrum-Textfield-input', 'input'),
35
+ {
36
+ find: [
37
+ builder.class('spectrum-Textfield-input'),
38
+ builder.class('focus-ring'),
39
+ ],
40
+ replace: [
41
+ { replace: builder.class('input') },
42
+ { replace: builder.pseudoClass('focus-visible') },
43
+ ],
44
+ hoist: false,
45
+ },
46
+ // Default to `size='m'` without needing the attribute
47
+ converter.classToHost('spectrum-Textfield--sizeM'),
48
+ ...converter.enumerateAttributes(
49
+ [
50
+ ['spectrum-Textfield--sizeS', 's'],
51
+ ['spectrum-Textfield--sizeL', 'l'],
52
+ ['spectrum-Textfield--sizeXL', 'xl'],
53
+ ],
54
+ 'size'
55
+ ),
56
+ converter.classToClass(
57
+ 'spectrum-Textfield-validationIcon',
58
+ 'icon'
59
+ ),
60
+ converter.classToClass(
61
+ 'spectrum-Textfield-icon',
62
+ 'icon-workflow'
63
+ ),
64
+ converter.classToClass('spectrum-Search-icon', 'icon-search'),
65
+ converter.classToAttribute('spectrum-Textfield--multiline'),
66
+ converter.classToAttribute('spectrum-Textfield--quiet'),
67
+ converter.classToAttribute(
68
+ 'spectrum-Textfield--grows',
69
+ 'grows'
70
+ ),
71
+ converter.classToAttribute('is-focused', 'focused'),
72
+ converter.classToAttribute('is-keyboardFocused', 'focused'),
73
+ converter.classToAttribute('is-valid', 'valid'),
74
+ converter.classToAttribute('is-invalid', 'invalid'),
75
+ converter.classToAttribute('is-disabled', 'disabled'),
76
+ converter.classToAttribute('is-readOnly', 'readonly'),
77
+ ],
78
+ },
79
+ ],
80
+ };
@@ -0,0 +1,2 @@
1
+ declare const styles: import("@spectrum-web-components/base").CSSResult;
2
+ export default styles;