@digital-realty/ix-textbox 2.4.5 → 2.4.6-IXUAT-11121.553801
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/IxTextbox.d.ts +21 -0
- package/dist/IxTextbox.js +35 -2
- package/dist/IxTextbox.js.map +1 -1
- package/dist/ix-textbox.min.js +5 -5
- package/package.json +3 -3
package/dist/IxTextbox.d.ts
CHANGED
|
@@ -26,6 +26,16 @@ export declare class IxTextbox extends IxTextboxBase {
|
|
|
26
26
|
errorText: string;
|
|
27
27
|
label: string;
|
|
28
28
|
required: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Screen-reader text appended to the label when `required` is true.
|
|
31
|
+
* Defaults to "required" (English). Overridden for i18n by consumer apps.
|
|
32
|
+
*
|
|
33
|
+
* The visible asterisk (rendered by MD3 when `required` is true) is
|
|
34
|
+
* kept as the visual affordance for sighted users; this string is
|
|
35
|
+
* ONLY appended to the accessible name so NVDA reads
|
|
36
|
+
* "First name, required" instead of "First name, star".
|
|
37
|
+
*/
|
|
38
|
+
requiredText: string;
|
|
29
39
|
/**
|
|
30
40
|
* The current value of the text field. It is always a string.
|
|
31
41
|
*/
|
|
@@ -189,6 +199,17 @@ export declare class IxTextbox extends IxTextboxBase {
|
|
|
189
199
|
* @returns The search result text.
|
|
190
200
|
*/
|
|
191
201
|
private setSearchResultText;
|
|
202
|
+
/**
|
|
203
|
+
* Merge consumer-supplied ARIA attributes with the required-field
|
|
204
|
+
* accessible name. MD3 renders a visual asterisk but does not expose a
|
|
205
|
+
* useful spoken cue in every screen reader.
|
|
206
|
+
*
|
|
207
|
+
* This getter injects `aria-label="${label}, ${requiredText}"` when
|
|
208
|
+
* required, but only if the consumer has not supplied their own
|
|
209
|
+
* `aria-label`, in which case their value takes precedence. It also sets
|
|
210
|
+
* `aria-required="true"` when required.
|
|
211
|
+
*/
|
|
212
|
+
private get _effectiveAriaAttributes();
|
|
192
213
|
protected render(): import("lit-html").TemplateResult<1 | 2 | 3>;
|
|
193
214
|
}
|
|
194
215
|
export {};
|
package/dist/IxTextbox.js
CHANGED
|
@@ -31,6 +31,16 @@ export class IxTextbox extends IxTextboxBase {
|
|
|
31
31
|
this.errorText = '';
|
|
32
32
|
this.label = '';
|
|
33
33
|
this.required = false;
|
|
34
|
+
/**
|
|
35
|
+
* Screen-reader text appended to the label when `required` is true.
|
|
36
|
+
* Defaults to "required" (English). Overridden for i18n by consumer apps.
|
|
37
|
+
*
|
|
38
|
+
* The visible asterisk (rendered by MD3 when `required` is true) is
|
|
39
|
+
* kept as the visual affordance for sighted users; this string is
|
|
40
|
+
* ONLY appended to the accessible name so NVDA reads
|
|
41
|
+
* "First name, required" instead of "First name, star".
|
|
42
|
+
*/
|
|
43
|
+
this.requiredText = 'required';
|
|
34
44
|
/**
|
|
35
45
|
* The current value of the text field. It is always a string.
|
|
36
46
|
*/
|
|
@@ -290,6 +300,26 @@ export class IxTextbox extends IxTextboxBase {
|
|
|
290
300
|
}
|
|
291
301
|
return `${this.searchResultIndex}/${this.searchResultCount} results`;
|
|
292
302
|
}
|
|
303
|
+
/**
|
|
304
|
+
* Merge consumer-supplied ARIA attributes with the required-field
|
|
305
|
+
* accessible name. MD3 renders a visual asterisk but does not expose a
|
|
306
|
+
* useful spoken cue in every screen reader.
|
|
307
|
+
*
|
|
308
|
+
* This getter injects `aria-label="${label}, ${requiredText}"` when
|
|
309
|
+
* required, but only if the consumer has not supplied their own
|
|
310
|
+
* `aria-label`, in which case their value takes precedence. It also sets
|
|
311
|
+
* `aria-required="true"` when required.
|
|
312
|
+
*/
|
|
313
|
+
get _effectiveAriaAttributes() {
|
|
314
|
+
const merged = { ...this.ariaAttributes };
|
|
315
|
+
if (this.required) {
|
|
316
|
+
merged['aria-required'] = 'true';
|
|
317
|
+
if (!merged['aria-label'] && this.label) {
|
|
318
|
+
merged['aria-label'] = `${this.label}, ${this.requiredText}`;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
return merged;
|
|
322
|
+
}
|
|
293
323
|
render() {
|
|
294
324
|
var _a, _b;
|
|
295
325
|
if (this.type === 'tel') {
|
|
@@ -305,7 +335,7 @@ export class IxTextbox extends IxTextboxBase {
|
|
|
305
335
|
label=${this.label}
|
|
306
336
|
name=${this.name}
|
|
307
337
|
.value=${(_a = this.value) !== null && _a !== void 0 ? _a : ''}
|
|
308
|
-
${spread(this.
|
|
338
|
+
${spread(this._effectiveAriaAttributes)}
|
|
309
339
|
></ix-phone-input>`;
|
|
310
340
|
}
|
|
311
341
|
const tag = this.filled
|
|
@@ -343,7 +373,7 @@ export class IxTextbox extends IxTextboxBase {
|
|
|
343
373
|
name=${this.name}
|
|
344
374
|
.value=${(_b = this.value) !== null && _b !== void 0 ? _b : ''}
|
|
345
375
|
@input=${this.onInput}
|
|
346
|
-
${spread(this.
|
|
376
|
+
${spread(this._effectiveAriaAttributes)}
|
|
347
377
|
>
|
|
348
378
|
${this.leadingIcon
|
|
349
379
|
? html `<ix-icon slot="leading-icon">${this.leadingIcon}</ix-icon>`
|
|
@@ -409,6 +439,9 @@ __decorate([
|
|
|
409
439
|
__decorate([
|
|
410
440
|
property({ type: Boolean, reflect: true })
|
|
411
441
|
], IxTextbox.prototype, "required", void 0);
|
|
442
|
+
__decorate([
|
|
443
|
+
property({ attribute: 'required-text' })
|
|
444
|
+
], IxTextbox.prototype, "requiredText", void 0);
|
|
412
445
|
__decorate([
|
|
413
446
|
property()
|
|
414
447
|
], IxTextbox.prototype, "value", void 0);
|
package/dist/IxTextbox.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IxTextbox.js","sourceRoot":"","sources":["../src/IxTextbox.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAChD,OAAO,EAAE,IAAI,IAAI,UAAU,EAAe,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC9E,OAAO,EAAE,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AAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;2CAAkB;AAOjB;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;2CAAkB;AAQjD;IAAX,QAAQ,EAAE;uCAAW;AAsBtB;IADC,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;uCAC4B;AAQ3B;IAA5B,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;+CAAmB;AAKtC;IAAR,KAAK,EAAE;0CAA0B","sourcesContent":["import { html, LitElement, nothing } from 'lit';\nimport { html as staticHtml, StaticValue, literal } from 'lit/static-html.js';\nimport { property, query, state } from 'lit/decorators.js';\nimport '@material/web/textfield/filled-text-field.js';\nimport '@material/web/textfield/outlined-text-field.js';\nimport {\n TextFieldType,\n UnsupportedTextFieldType,\n} from '@material/web/textfield/internal/text-field.js';\nimport { AriaForwardMixin } from '@digital-realty/ix-shared-fns/aria-forward-mixin.js';\nimport { spread } from '@open-wc/lit-helpers';\nimport '@digital-realty/ix-icon/ix-icon.js';\nimport '@digital-realty/ix-phone-input/ix-phone-input.js';\n\nconst IxTextboxBase = AriaForwardMixin(LitElement);\n\nexport class IxTextbox extends IxTextboxBase {\n @query('.textfield')\n readonly component!: HTMLInputElement;\n\n @property({ type: Boolean, reflect: true }) filled = false;\n\n @property({ type: Boolean, reflect: true }) disabled = false;\n\n /**\n * Gets or sets whether or not the text field is in a visually invalid state.\n *\n * Calling `reportValidity()` will automatically update `error`.\n */\n @property({ type: Boolean, reflect: true }) error = false;\n\n /**\n * The error message that replaces supporting text when `error` is true. If\n * `errorText` is an empty string, then the supporting text will continue to\n * show.\n *\n * Calling `reportValidity()` will automatically update `errorText` to the\n * native `validationMessage`.\n */\n @property({ attribute: 'error-text' }) errorText = '';\n\n @property() label = '';\n\n @property({ type: Boolean, reflect: true }) required = false;\n\n /**\n * The current value of the text field. It is always a string.\n */\n @property() value = '';\n\n /**\n * The name of the text field. It is always a string.\n */\n @property() name = '';\n\n /**\n * An optional prefix to display before the input value.\n */\n @property({ attribute: 'prefix-text' }) prefixText = '';\n\n /**\n * An optional suffix to display after the input value.\n */\n @property({ attribute: 'suffix-text' }) suffixText = '';\n\n /**\n * Name of icon. It is always a string.\n */\n @property({ attribute: 'leading-icon' })\n leadingIcon = '';\n\n /**\n * Name of icon. It is always a string.\n */\n @property({ attribute: 'trailing-icon' })\n trailingIcon = '';\n\n /**\n * Enables navigation icons for search input types.\n */\n @property({ type: Boolean }) searchEnabled = false;\n\n /**\n * The number of search results found.\n */\n @property({ type: Number }) searchResultCount = 0;\n\n /**\n * The index of the selected search result. This property is 1-based (i.e. begins with 1, not zero-based).\n */\n @property({ type: Number }) searchResultIndex = 0;\n\n /**\n * Conveys additional information below the text field, such as how it should\n * be used.\n */\n @property({ attribute: 'supporting-text' }) supportingText = '';\n\n /**\n * Override the input text CSS `direction`. Useful for RTL languages that use\n * LTR notation for fractions.\n */\n @property({ attribute: 'text-direction' }) textDirection = '';\n\n /**\n * The number of rows to display for a `type=\"textarea\"` text field.\n * Defaults to 2.\n */\n @property({ type: Number }) rows = 2;\n\n // <input> properties\n @property({ reflect: true }) override inputMode = '';\n\n /**\n * Defines the greatest value in the range of permitted values.\n *\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#max\n */\n @property() max = '';\n\n /**\n * The maximum number of characters a user can enter into the text field. Set\n * to -1 for none.\n *\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#maxlength\n */\n @property({ type: Number }) maxLength = -1;\n\n /**\n * Defines the most negative value in the range of permitted values.\n *\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#min\n */\n @property() min = '';\n\n /**\n * The minimum number of characters a user can enter into the text field. Set\n * to -1 for none.\n *\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#minlength\n */\n @property({ type: Number }) minLength = -1;\n\n /**\n * A regular expression that the text field's value must match to pass\n * constraint validation.\n *\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#pattern\n */\n @property() pattern = '';\n\n @property({ reflect: true }) placeholder = '';\n\n /**\n * Indicates whether or not a user should be able to edit the text field's\n * value.\n *\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#readonly\n */\n @property({ type: Boolean, reflect: true }) readOnly = false;\n\n /**\n * Indicates that input accepts multiple email addresses.\n *\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/email#multiple\n */\n @property({ type: Boolean, reflect: true }) multiple = false;\n\n /**\n * Returns or sets the element's step attribute, which works with min and max\n * to limit the increments at which a numeric or date-time value can be set.\n *\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#step\n */\n @property() step = '';\n\n /**\n * The `<input>` type to use, defaults to \"text\". The type greatly changes how\n * the text field behaves.\n *\n * Text fields support a limited number of `<input>` types:\n *\n * - text\n * - textarea\n * - email\n * - number\n * - password\n * - search\n * - tel\n * - url\n *\n * See\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#input_types\n * for more details on each input type.\n */\n @property({ reflect: true })\n type: TextFieldType | UnsupportedTextFieldType = 'text';\n\n /**\n * Describes what, if any, type of autocomplete functionality the input\n * should provide.\n *\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete\n */\n @property({ reflect: true }) autocomplete = '';\n\n /**\n * True if the input has text.\n */\n @state() hasText: boolean = false;\n\n textarea: HTMLElement | null | undefined;\n\n handleKeydownHandler: any = undefined;\n\n connectedCallback() {\n super.connectedCallback();\n\n if (this.type === 'textarea') {\n this.addEventListener('input', this.resizeTextArea);\n this.addEventListener('keydown', this.resizeTextArea);\n window.addEventListener('load', this.resizeTextArea);\n }\n }\n\n async firstUpdated() {\n if (this.type === 'textarea') {\n if (this.component instanceof LitElement) {\n await this.component.updateComplete;\n }\n await this.updateComplete;\n\n this.textarea = this.component?.shadowRoot?.querySelector('textarea');\n this.resizeTextArea();\n }\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n\n if (this.handleKeydownHandler) {\n this.removeEventListener('input', this.resizeTextArea);\n this.removeEventListener('keydown', this.resizeTextArea);\n window.removeEventListener('load', this.resizeTextArea);\n }\n }\n\n resizeTextArea = () => {\n if (this.textarea) {\n this.textarea.style.height = 'auto';\n if (this.textarea.scrollHeight > 0) {\n this.textarea.style.height = `${this.textarea.scrollHeight}px`;\n }\n }\n };\n\n focus() {\n this.component.focus();\n }\n\n protected createRenderRoot() {\n return this;\n }\n\n renderStyles() {\n return html`\n <style>\n [error] {\n --md-outlined-field-outline-width: 2px;\n }\n ix-textbox {\n &.comment {\n --md-outlined-text-field-container-shape: 32px;\n --md-outlined-text-field-outline-color: rgba(9, 34, 65, 0.12);\n --md-outlined-text-field-outline-width: 1px;\n --md-outlined-text-field-hover-outline-color: rgba(9, 34, 65, 0.12);\n --md-outlined-text-field-hover-outline-width: 1px;\n --md-outlined-text-field-focus-outline-color: rgba(9, 34, 65, 0.12);\n --md-outlined-text-field-focus-outline-width: 1px;\n --md-outlined-text-field-input-text-placeholder-color: rgba(\n 9,\n 34,\n 65,\n 0.42\n );\n --md-filled-text-field-focus-active-indicator-color: rgba(\n 9,\n 34,\n 65,\n 0.12\n );\n --md-outlined-text-field-input-text-color: rgb(9, 34, 65);\n --md-outlined-field-leading-space: 8px;\n }\n [type='textarea'] {\n resize: none;\n }\n }\n </style>\n `;\n }\n\n /**\n * Handles search navigation icon clicks and emits search-navigation event.\n */\n private onSearchNavigation(e: CustomEvent, direction: string) {\n this.dispatchEvent(\n new CustomEvent('search-navigation', {\n detail: { direction },\n bubbles: true,\n composed: true,\n })\n );\n }\n\n /**\n * Handles input event and sets hasText state when an input event is received.\n */\n private onInput = (e: Event) => {\n const input = e.target as HTMLInputElement;\n this.hasText = input.value.length > 0;\n\n this.dispatchEvent(\n new CustomEvent('search-text-change', {\n detail: { searchText: input.value },\n })\n );\n };\n\n /**\n * Clears the input field and resets hasText state.\n */\n private clearInput = () => {\n this.value = '';\n this.hasText = false;\n this.dispatchEvent(new Event('input', { bubbles: true, composed: true }));\n };\n\n /**\n * Sets the search result text based on the current search state.\n * @returns The search result text.\n */\n private setSearchResultText(): string {\n if (this.searchResultCount === 0) {\n return `${this.searchResultCount} results`;\n }\n\n if (this.searchResultIndex === 0) {\n return `${this.searchResultCount} results`;\n }\n\n return `${this.searchResultIndex}/${this.searchResultCount} results`;\n }\n\n protected override render() {\n if (this.type === 'tel') {\n return html`<ix-phone-input\n class=\"textfield\"\n style=\"display: block;\"\n ?disabled=${this.disabled}\n ?required=${this.required}\n ?error=${this.error}\n error-text=${this.errorText}\n supporting-text=${this.supportingText}\n type=${this.type}\n label=${this.label}\n name=${this.name}\n .value=${this.value ?? ''}\n ${spread(this.ariaAttributes)}\n ></ix-phone-input>`;\n }\n\n const tag: StaticValue = this.filled\n ? literal`md-filled-text-field`\n : literal`md-outlined-text-field`;\n\n return staticHtml`\n ${this.renderStyles()}\n <${tag}\n class=\"textfield\"\n style=\"display: block;\"\n ?disabled=${this.disabled}\n ?required=${this.required}\n ?error=${this.error}\n ?multipule=${this.multiple}\n ?readOnly=${this.readOnly}\n ?has-leading-icon=${this.leadingIcon.length > 0}\n ?has-trailing-icon=${this.trailingIcon.length > 0}\n step=${this.step || nothing}\n autocomplete=${this.autocomplete || nothing}\n error-text=${this.errorText}\n placeholder=${this.placeholder}\n text-direction=${this.textDirection}\n rows=${this.rows}\n max=${this.max}\n maxLength=${this.maxLength}\n min=${this.min}\n minLength=${this.minLength}\n pattern=${this.pattern}\n prefix-text=${this.prefixText}\n suffix-text=${this.suffixText}\n supporting-text=${this.supportingText}\n inputMode=${this.inputMode}\n type=${this.type}\n label=${this.label}\n name=${this.name}\n .value=${this.value ?? ''}\n @input=${this.onInput}\n ${spread(this.ariaAttributes)}\n >\n ${\n this.leadingIcon\n ? html`<ix-icon slot=\"leading-icon\">${this.leadingIcon}</ix-icon>`\n : nothing\n }\n ${\n this.searchEnabled && this.hasText && this.value.length > 1\n ? html`<div\n style=\"font-size: 14px; align-items: center;\"\n slot=\"trailing-icon\"\n >\n ${this.setSearchResultText()}\n </div>`\n : nothing\n }\n ${\n this.searchEnabled && this.searchResultCount > 0\n ? html`<ix-icon\n style=\"padding: 0px 3px; align-items: center; cursor: pointer;\"\n slot=\"trailing-icon\"\n @click=${(ev: CustomEvent) =>\n this.onSearchNavigation(ev, 'previous')}\n >chevron_left</ix-icon\n >\n\n <ix-icon\n slot=\"trailing-icon\"\n style=\"padding: 0px 3px; align-items: center; cursor: pointer;\"\n @click=${(ev: CustomEvent) =>\n this.onSearchNavigation(ev, 'next')}\n >chevron_right</ix-icon\n >`\n : nothing\n }\n ${\n this.hasText\n ? html`<ix-icon\n style=\"padding: 0px 3px; align-items: center; cursor: pointer;\"\n slot=\"trailing-icon\"\n @click=${this.clearInput}\n >close</ix-icon\n >`\n : nothing\n }\n ${\n this.trailingIcon\n ? html`<ix-icon slot=\"trailing-icon\"\n >${this.trailingIcon}</ix-icon\n >`\n : nothing\n }\n </${tag}>\n `;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"IxTextbox.js","sourceRoot":"","sources":["../src/IxTextbox.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAChD,OAAO,EAAE,IAAI,IAAI,UAAU,EAAe,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC9E,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,8CAA8C,CAAC;AACtD,OAAO,gDAAgD,CAAC;AAKxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qDAAqD,CAAC;AACvF,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,oCAAoC,CAAC;AAC5C,OAAO,kDAAkD,CAAC;AAE1D,MAAM,aAAa,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAC;AAEnD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AAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4CAAgB;AAQ/B;IAAX,QAAQ,EAAE;0CAAc;AAEI;IAA5B,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;8CAAkB;AAQF;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;2CAAkB;AAOjB;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;2CAAkB;AAQjD;IAAX,QAAQ,EAAE;uCAAW;AAsBtB;IADC,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;uCAC4B;AAQ3B;IAA5B,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;+CAAmB;AAKtC;IAAR,KAAK,EAAE;0CAA0B","sourcesContent":["import { html, LitElement, nothing } from 'lit';\nimport { html as staticHtml, StaticValue, literal } from 'lit/static-html.js';\nimport { property, query, state } from 'lit/decorators.js';\nimport '@material/web/textfield/filled-text-field.js';\nimport '@material/web/textfield/outlined-text-field.js';\nimport {\n TextFieldType,\n UnsupportedTextFieldType,\n} from '@material/web/textfield/internal/text-field.js';\nimport { AriaForwardMixin } from '@digital-realty/ix-shared-fns/aria-forward-mixin.js';\nimport { spread } from '@open-wc/lit-helpers';\nimport '@digital-realty/ix-icon/ix-icon.js';\nimport '@digital-realty/ix-phone-input/ix-phone-input.js';\n\nconst IxTextboxBase = AriaForwardMixin(LitElement);\n\nexport class IxTextbox extends IxTextboxBase {\n @query('.textfield')\n readonly component!: HTMLInputElement;\n\n @property({ type: Boolean, reflect: true }) filled = false;\n\n @property({ type: Boolean, reflect: true }) disabled = false;\n\n /**\n * Gets or sets whether or not the text field is in a visually invalid state.\n *\n * Calling `reportValidity()` will automatically update `error`.\n */\n @property({ type: Boolean, reflect: true }) error = false;\n\n /**\n * The error message that replaces supporting text when `error` is true. If\n * `errorText` is an empty string, then the supporting text will continue to\n * show.\n *\n * Calling `reportValidity()` will automatically update `errorText` to the\n * native `validationMessage`.\n */\n @property({ attribute: 'error-text' }) errorText = '';\n\n @property() label = '';\n\n @property({ type: Boolean, reflect: true }) required = false;\n\n /**\n * Screen-reader text appended to the label when `required` is true.\n * Defaults to \"required\" (English). Overridden for i18n by consumer apps.\n *\n * The visible asterisk (rendered by MD3 when `required` is true) is\n * kept as the visual affordance for sighted users; this string is\n * ONLY appended to the accessible name so NVDA reads\n * \"First name, required\" instead of \"First name, star\".\n */\n @property({ attribute: 'required-text' }) requiredText = 'required';\n\n /**\n * The current value of the text field. It is always a string.\n */\n @property() value = '';\n\n /**\n * The name of the text field. It is always a string.\n */\n @property() name = '';\n\n /**\n * An optional prefix to display before the input value.\n */\n @property({ attribute: 'prefix-text' }) prefixText = '';\n\n /**\n * An optional suffix to display after the input value.\n */\n @property({ attribute: 'suffix-text' }) suffixText = '';\n\n /**\n * Name of icon. It is always a string.\n */\n @property({ attribute: 'leading-icon' })\n leadingIcon = '';\n\n /**\n * Name of icon. It is always a string.\n */\n @property({ attribute: 'trailing-icon' })\n trailingIcon = '';\n\n /**\n * Enables navigation icons for search input types.\n */\n @property({ type: Boolean }) searchEnabled = false;\n\n /**\n * The number of search results found.\n */\n @property({ type: Number }) searchResultCount = 0;\n\n /**\n * The index of the selected search result. This property is 1-based (i.e. begins with 1, not zero-based).\n */\n @property({ type: Number }) searchResultIndex = 0;\n\n /**\n * Conveys additional information below the text field, such as how it should\n * be used.\n */\n @property({ attribute: 'supporting-text' }) supportingText = '';\n\n /**\n * Override the input text CSS `direction`. Useful for RTL languages that use\n * LTR notation for fractions.\n */\n @property({ attribute: 'text-direction' }) textDirection = '';\n\n /**\n * The number of rows to display for a `type=\"textarea\"` text field.\n * Defaults to 2.\n */\n @property({ type: Number }) rows = 2;\n\n // <input> properties\n @property({ reflect: true }) override inputMode = '';\n\n /**\n * Defines the greatest value in the range of permitted values.\n *\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#max\n */\n @property() max = '';\n\n /**\n * The maximum number of characters a user can enter into the text field. Set\n * to -1 for none.\n *\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#maxlength\n */\n @property({ type: Number }) maxLength = -1;\n\n /**\n * Defines the most negative value in the range of permitted values.\n *\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#min\n */\n @property() min = '';\n\n /**\n * The minimum number of characters a user can enter into the text field. Set\n * to -1 for none.\n *\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#minlength\n */\n @property({ type: Number }) minLength = -1;\n\n /**\n * A regular expression that the text field's value must match to pass\n * constraint validation.\n *\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#pattern\n */\n @property() pattern = '';\n\n @property({ reflect: true }) placeholder = '';\n\n /**\n * Indicates whether or not a user should be able to edit the text field's\n * value.\n *\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#readonly\n */\n @property({ type: Boolean, reflect: true }) readOnly = false;\n\n /**\n * Indicates that input accepts multiple email addresses.\n *\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/email#multiple\n */\n @property({ type: Boolean, reflect: true }) multiple = false;\n\n /**\n * Returns or sets the element's step attribute, which works with min and max\n * to limit the increments at which a numeric or date-time value can be set.\n *\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#step\n */\n @property() step = '';\n\n /**\n * The `<input>` type to use, defaults to \"text\". The type greatly changes how\n * the text field behaves.\n *\n * Text fields support a limited number of `<input>` types:\n *\n * - text\n * - textarea\n * - email\n * - number\n * - password\n * - search\n * - tel\n * - url\n *\n * See\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#input_types\n * for more details on each input type.\n */\n @property({ reflect: true })\n type: TextFieldType | UnsupportedTextFieldType = 'text';\n\n /**\n * Describes what, if any, type of autocomplete functionality the input\n * should provide.\n *\n * https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete\n */\n @property({ reflect: true }) autocomplete = '';\n\n /**\n * True if the input has text.\n */\n @state() hasText: boolean = false;\n\n textarea: HTMLElement | null | undefined;\n\n handleKeydownHandler: any = undefined;\n\n connectedCallback() {\n super.connectedCallback();\n\n if (this.type === 'textarea') {\n this.addEventListener('input', this.resizeTextArea);\n this.addEventListener('keydown', this.resizeTextArea);\n window.addEventListener('load', this.resizeTextArea);\n }\n }\n\n async firstUpdated() {\n if (this.type === 'textarea') {\n if (this.component instanceof LitElement) {\n await this.component.updateComplete;\n }\n await this.updateComplete;\n\n this.textarea = this.component?.shadowRoot?.querySelector('textarea');\n this.resizeTextArea();\n }\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n\n if (this.handleKeydownHandler) {\n this.removeEventListener('input', this.resizeTextArea);\n this.removeEventListener('keydown', this.resizeTextArea);\n window.removeEventListener('load', this.resizeTextArea);\n }\n }\n\n resizeTextArea = () => {\n if (this.textarea) {\n this.textarea.style.height = 'auto';\n if (this.textarea.scrollHeight > 0) {\n this.textarea.style.height = `${this.textarea.scrollHeight}px`;\n }\n }\n };\n\n focus() {\n this.component.focus();\n }\n\n protected createRenderRoot() {\n return this;\n }\n\n renderStyles() {\n return html`\n <style>\n [error] {\n --md-outlined-field-outline-width: 2px;\n }\n ix-textbox {\n &.comment {\n --md-outlined-text-field-container-shape: 32px;\n --md-outlined-text-field-outline-color: rgba(9, 34, 65, 0.12);\n --md-outlined-text-field-outline-width: 1px;\n --md-outlined-text-field-hover-outline-color: rgba(9, 34, 65, 0.12);\n --md-outlined-text-field-hover-outline-width: 1px;\n --md-outlined-text-field-focus-outline-color: rgba(9, 34, 65, 0.12);\n --md-outlined-text-field-focus-outline-width: 1px;\n --md-outlined-text-field-input-text-placeholder-color: rgba(\n 9,\n 34,\n 65,\n 0.42\n );\n --md-filled-text-field-focus-active-indicator-color: rgba(\n 9,\n 34,\n 65,\n 0.12\n );\n --md-outlined-text-field-input-text-color: rgb(9, 34, 65);\n --md-outlined-field-leading-space: 8px;\n }\n [type='textarea'] {\n resize: none;\n }\n }\n </style>\n `;\n }\n\n /**\n * Handles search navigation icon clicks and emits search-navigation event.\n */\n private onSearchNavigation(e: CustomEvent, direction: string) {\n this.dispatchEvent(\n new CustomEvent('search-navigation', {\n detail: { direction },\n bubbles: true,\n composed: true,\n })\n );\n }\n\n /**\n * Handles input event and sets hasText state when an input event is received.\n */\n private onInput = (e: Event) => {\n const input = e.target as HTMLInputElement;\n this.hasText = input.value.length > 0;\n\n this.dispatchEvent(\n new CustomEvent('search-text-change', {\n detail: { searchText: input.value },\n })\n );\n };\n\n /**\n * Clears the input field and resets hasText state.\n */\n private clearInput = () => {\n this.value = '';\n this.hasText = false;\n this.dispatchEvent(new Event('input', { bubbles: true, composed: true }));\n };\n\n /**\n * Sets the search result text based on the current search state.\n * @returns The search result text.\n */\n private setSearchResultText(): string {\n if (this.searchResultCount === 0) {\n return `${this.searchResultCount} results`;\n }\n\n if (this.searchResultIndex === 0) {\n return `${this.searchResultCount} results`;\n }\n\n return `${this.searchResultIndex}/${this.searchResultCount} results`;\n }\n\n /**\n * Merge consumer-supplied ARIA attributes with the required-field\n * accessible name. MD3 renders a visual asterisk but does not expose a\n * useful spoken cue in every screen reader.\n *\n * This getter injects `aria-label=\"${label}, ${requiredText}\"` when\n * required, but only if the consumer has not supplied their own\n * `aria-label`, in which case their value takes precedence. It also sets\n * `aria-required=\"true\"` when required.\n */\n private get _effectiveAriaAttributes(): Record<string, string> {\n const merged: Record<string, string> = { ...this.ariaAttributes };\n if (this.required) {\n merged['aria-required'] = 'true';\n if (!merged['aria-label'] && this.label) {\n merged['aria-label'] = `${this.label}, ${this.requiredText}`;\n }\n }\n return merged;\n }\n\n protected override render() {\n if (this.type === 'tel') {\n return html`<ix-phone-input\n class=\"textfield\"\n style=\"display: block;\"\n ?disabled=${this.disabled}\n ?required=${this.required}\n ?error=${this.error}\n error-text=${this.errorText}\n supporting-text=${this.supportingText}\n type=${this.type}\n label=${this.label}\n name=${this.name}\n .value=${this.value ?? ''}\n ${spread(this._effectiveAriaAttributes)}\n ></ix-phone-input>`;\n }\n\n const tag: StaticValue = this.filled\n ? literal`md-filled-text-field`\n : literal`md-outlined-text-field`;\n\n return staticHtml`\n ${this.renderStyles()}\n <${tag}\n class=\"textfield\"\n style=\"display: block;\"\n ?disabled=${this.disabled}\n ?required=${this.required}\n ?error=${this.error}\n ?multipule=${this.multiple}\n ?readOnly=${this.readOnly}\n ?has-leading-icon=${this.leadingIcon.length > 0}\n ?has-trailing-icon=${this.trailingIcon.length > 0}\n step=${this.step || nothing}\n autocomplete=${this.autocomplete || nothing}\n error-text=${this.errorText}\n placeholder=${this.placeholder}\n text-direction=${this.textDirection}\n rows=${this.rows}\n max=${this.max}\n maxLength=${this.maxLength}\n min=${this.min}\n minLength=${this.minLength}\n pattern=${this.pattern}\n prefix-text=${this.prefixText}\n suffix-text=${this.suffixText}\n supporting-text=${this.supportingText}\n inputMode=${this.inputMode}\n type=${this.type}\n label=${this.label}\n name=${this.name}\n .value=${this.value ?? ''}\n @input=${this.onInput}\n ${spread(this._effectiveAriaAttributes)}\n >\n ${\n this.leadingIcon\n ? html`<ix-icon slot=\"leading-icon\">${this.leadingIcon}</ix-icon>`\n : nothing\n }\n ${\n this.searchEnabled && this.hasText && this.value.length > 1\n ? html`<div\n style=\"font-size: 14px; align-items: center;\"\n slot=\"trailing-icon\"\n >\n ${this.setSearchResultText()}\n </div>`\n : nothing\n }\n ${\n this.searchEnabled && this.searchResultCount > 0\n ? html`<ix-icon\n style=\"padding: 0px 3px; align-items: center; cursor: pointer;\"\n slot=\"trailing-icon\"\n @click=${(ev: CustomEvent) =>\n this.onSearchNavigation(ev, 'previous')}\n >chevron_left</ix-icon\n >\n\n <ix-icon\n slot=\"trailing-icon\"\n style=\"padding: 0px 3px; align-items: center; cursor: pointer;\"\n @click=${(ev: CustomEvent) =>\n this.onSearchNavigation(ev, 'next')}\n >chevron_right</ix-icon\n >`\n : nothing\n }\n ${\n this.hasText\n ? html`<ix-icon\n style=\"padding: 0px 3px; align-items: center; cursor: pointer;\"\n slot=\"trailing-icon\"\n @click=${this.clearInput}\n >close</ix-icon\n >`\n : nothing\n }\n ${\n this.trailingIcon\n ? html`<ix-icon slot=\"trailing-icon\"\n >${this.trailingIcon}</ix-icon\n >`\n : nothing\n }\n </${tag}>\n `;\n }\n}\n"]}
|
package/dist/ix-textbox.min.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{__decorate as t}from"tslib";import{LitElement as e,html as i,nothing as o}from"lit";import{literal as r,html as s}from"lit/static-html.js";import{query as n,property as l,state as a}from"lit/decorators.js";import"@material/web/textfield/filled-text-field.js";import"@material/web/textfield/outlined-text-field.js";import{AriaForwardMixin as d}from"@digital-realty/ix-shared-fns/aria-forward-mixin.js";import{spread as h}from"@open-wc/lit-helpers";import"@digital-realty/ix-icon/ix-icon.js";import"@digital-realty/ix-phone-input/ix-phone-input.js";const p=d(e);class c extends p{constructor(){super(...arguments),this.filled=!1,this.disabled=!1,this.error=!1,this.errorText="",this.label="",this.required=!1,this.value="",this.name="",this.prefixText="",this.suffixText="",this.leadingIcon="",this.trailingIcon="",this.searchEnabled=!1,this.searchResultCount=0,this.searchResultIndex=0,this.supportingText="",this.textDirection="",this.rows=2,this.inputMode="",this.max="",this.maxLength=-1,this.min="",this.minLength=-1,this.pattern="",this.placeholder="",this.readOnly=!1,this.multiple=!1,this.step="",this.type="text",this.autocomplete="",this.hasText=!1,this.handleKeydownHandler=void 0,this.resizeTextArea=()=>{this.textarea&&(this.textarea.style.height="auto",this.textarea.scrollHeight>0&&(this.textarea.style.height=`${this.textarea.scrollHeight}px`))},this.onInput=t=>{const e=t.target;this.hasText=e.value.length>0,this.dispatchEvent(new CustomEvent("search-text-change",{detail:{searchText:e.value}}))},this.clearInput=()=>{this.value="",this.hasText=!1,this.dispatchEvent(new Event("input",{bubbles:!0,composed:!0}))}}connectedCallback(){super.connectedCallback(),"textarea"===this.type&&(this.addEventListener("input",this.resizeTextArea),this.addEventListener("keydown",this.resizeTextArea),window.addEventListener("load",this.resizeTextArea))}async firstUpdated(){var t,i;"textarea"===this.type&&(this.component instanceof e&&await this.component.updateComplete,await this.updateComplete,this.textarea=null===(i=null===(t=this.component)||void 0===t?void 0:t.shadowRoot)||void 0===i?void 0:i.querySelector("textarea"),this.resizeTextArea())}disconnectedCallback(){super.disconnectedCallback(),this.handleKeydownHandler&&(this.removeEventListener("input",this.resizeTextArea),this.removeEventListener("keydown",this.resizeTextArea),window.removeEventListener("load",this.resizeTextArea))}focus(){this.component.focus()}createRenderRoot(){return this}renderStyles(){return i`
|
|
1
|
+
import{__decorate as t}from"tslib";import{LitElement as e,html as i,nothing as o}from"lit";import{literal as r,html as s}from"lit/static-html.js";import{query as n,property as l,state as a}from"lit/decorators.js";import"@material/web/textfield/filled-text-field.js";import"@material/web/textfield/outlined-text-field.js";import{AriaForwardMixin as d}from"@digital-realty/ix-shared-fns/aria-forward-mixin.js";import{spread as h}from"@open-wc/lit-helpers";import"@digital-realty/ix-icon/ix-icon.js";import"@digital-realty/ix-phone-input/ix-phone-input.js";const p=d(e);class c extends p{constructor(){super(...arguments),this.filled=!1,this.disabled=!1,this.error=!1,this.errorText="",this.label="",this.required=!1,this.requiredText="required",this.value="",this.name="",this.prefixText="",this.suffixText="",this.leadingIcon="",this.trailingIcon="",this.searchEnabled=!1,this.searchResultCount=0,this.searchResultIndex=0,this.supportingText="",this.textDirection="",this.rows=2,this.inputMode="",this.max="",this.maxLength=-1,this.min="",this.minLength=-1,this.pattern="",this.placeholder="",this.readOnly=!1,this.multiple=!1,this.step="",this.type="text",this.autocomplete="",this.hasText=!1,this.handleKeydownHandler=void 0,this.resizeTextArea=()=>{this.textarea&&(this.textarea.style.height="auto",this.textarea.scrollHeight>0&&(this.textarea.style.height=`${this.textarea.scrollHeight}px`))},this.onInput=t=>{const e=t.target;this.hasText=e.value.length>0,this.dispatchEvent(new CustomEvent("search-text-change",{detail:{searchText:e.value}}))},this.clearInput=()=>{this.value="",this.hasText=!1,this.dispatchEvent(new Event("input",{bubbles:!0,composed:!0}))}}connectedCallback(){super.connectedCallback(),"textarea"===this.type&&(this.addEventListener("input",this.resizeTextArea),this.addEventListener("keydown",this.resizeTextArea),window.addEventListener("load",this.resizeTextArea))}async firstUpdated(){var t,i;"textarea"===this.type&&(this.component instanceof e&&await this.component.updateComplete,await this.updateComplete,this.textarea=null===(i=null===(t=this.component)||void 0===t?void 0:t.shadowRoot)||void 0===i?void 0:i.querySelector("textarea"),this.resizeTextArea())}disconnectedCallback(){super.disconnectedCallback(),this.handleKeydownHandler&&(this.removeEventListener("input",this.resizeTextArea),this.removeEventListener("keydown",this.resizeTextArea),window.removeEventListener("load",this.resizeTextArea))}focus(){this.component.focus()}createRenderRoot(){return this}renderStyles(){return i`
|
|
2
2
|
<style>
|
|
3
3
|
[error] {
|
|
4
4
|
--md-outlined-field-outline-width: 2px;
|
|
@@ -32,7 +32,7 @@ import{__decorate as t}from"tslib";import{LitElement as e,html as i,nothing as o
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
</style>
|
|
35
|
-
`}onSearchNavigation(t,e){this.dispatchEvent(new CustomEvent("search-navigation",{detail:{direction:e},bubbles:!0,composed:!0}))}setSearchResultText(){return 0===this.searchResultCount||0===this.searchResultIndex?`${this.searchResultCount} results`:`${this.searchResultIndex}/${this.searchResultCount} results`}render(){var t,e;if("tel"===this.type)return i`<ix-phone-input
|
|
35
|
+
`}onSearchNavigation(t,e){this.dispatchEvent(new CustomEvent("search-navigation",{detail:{direction:e},bubbles:!0,composed:!0}))}setSearchResultText(){return 0===this.searchResultCount||0===this.searchResultIndex?`${this.searchResultCount} results`:`${this.searchResultIndex}/${this.searchResultCount} results`}get _effectiveAriaAttributes(){const t={...this.ariaAttributes};return this.required&&(t["aria-required"]="true",!t["aria-label"]&&this.label&&(t["aria-label"]=`${this.label}, ${this.requiredText}`)),t}render(){var t,e;if("tel"===this.type)return i`<ix-phone-input
|
|
36
36
|
class="textfield"
|
|
37
37
|
style="display: block;"
|
|
38
38
|
?disabled=${this.disabled}
|
|
@@ -44,7 +44,7 @@ import{__decorate as t}from"tslib";import{LitElement as e,html as i,nothing as o
|
|
|
44
44
|
label=${this.label}
|
|
45
45
|
name=${this.name}
|
|
46
46
|
.value=${null!==(t=this.value)&&void 0!==t?t:""}
|
|
47
|
-
${h(this.
|
|
47
|
+
${h(this._effectiveAriaAttributes)}
|
|
48
48
|
></ix-phone-input>`;const n=this.filled?r`md-filled-text-field`:r`md-outlined-text-field`;return s`
|
|
49
49
|
${this.renderStyles()}
|
|
50
50
|
<${n}
|
|
@@ -77,7 +77,7 @@ import{__decorate as t}from"tslib";import{LitElement as e,html as i,nothing as o
|
|
|
77
77
|
name=${this.name}
|
|
78
78
|
.value=${null!==(e=this.value)&&void 0!==e?e:""}
|
|
79
79
|
@input=${this.onInput}
|
|
80
|
-
${h(this.
|
|
80
|
+
${h(this._effectiveAriaAttributes)}
|
|
81
81
|
>
|
|
82
82
|
${this.leadingIcon?i`<ix-icon slot="leading-icon">${this.leadingIcon}</ix-icon>`:o}
|
|
83
83
|
${this.searchEnabled&&this.hasText&&this.value.length>1?i`<div
|
|
@@ -109,4 +109,4 @@ import{__decorate as t}from"tslib";import{LitElement as e,html as i,nothing as o
|
|
|
109
109
|
>${this.trailingIcon}</ix-icon
|
|
110
110
|
>`:o}
|
|
111
111
|
</${n}>
|
|
112
|
-
`}}t([n(".textfield")],c.prototype,"component",void 0),t([l({type:Boolean,reflect:!0})],c.prototype,"filled",void 0),t([l({type:Boolean,reflect:!0})],c.prototype,"disabled",void 0),t([l({type:Boolean,reflect:!0})],c.prototype,"error",void 0),t([l({attribute:"error-text"})],c.prototype,"errorText",void 0),t([l()],c.prototype,"label",void 0),t([l({type:Boolean,reflect:!0})],c.prototype,"required",void 0),t([l()],c.prototype,"value",void 0),t([l()],c.prototype,"name",void 0),t([l({attribute:"prefix-text"})],c.prototype,"prefixText",void 0),t([l({attribute:"suffix-text"})],c.prototype,"suffixText",void 0),t([l({attribute:"leading-icon"})],c.prototype,"leadingIcon",void 0),t([l({attribute:"trailing-icon"})],c.prototype,"trailingIcon",void 0),t([l({type:Boolean})],c.prototype,"searchEnabled",void 0),t([l({type:Number})],c.prototype,"searchResultCount",void 0),t([l({type:Number})],c.prototype,"searchResultIndex",void 0),t([l({attribute:"supporting-text"})],c.prototype,"supportingText",void 0),t([l({attribute:"text-direction"})],c.prototype,"textDirection",void 0),t([l({type:Number})],c.prototype,"rows",void 0),t([l({reflect:!0})],c.prototype,"inputMode",void 0),t([l()],c.prototype,"max",void 0),t([l({type:Number})],c.prototype,"maxLength",void 0),t([l()],c.prototype,"min",void 0),t([l({type:Number})],c.prototype,"minLength",void 0),t([l()],c.prototype,"pattern",void 0),t([l({reflect:!0})],c.prototype,"placeholder",void 0),t([l({type:Boolean,reflect:!0})],c.prototype,"readOnly",void 0),t([l({type:Boolean,reflect:!0})],c.prototype,"multiple",void 0),t([l()],c.prototype,"step",void 0),t([l({reflect:!0})],c.prototype,"type",void 0),t([l({reflect:!0})],c.prototype,"autocomplete",void 0),t([a()],c.prototype,"hasText",void 0),customElements.define("ix-textbox",c);
|
|
112
|
+
`}}t([n(".textfield")],c.prototype,"component",void 0),t([l({type:Boolean,reflect:!0})],c.prototype,"filled",void 0),t([l({type:Boolean,reflect:!0})],c.prototype,"disabled",void 0),t([l({type:Boolean,reflect:!0})],c.prototype,"error",void 0),t([l({attribute:"error-text"})],c.prototype,"errorText",void 0),t([l()],c.prototype,"label",void 0),t([l({type:Boolean,reflect:!0})],c.prototype,"required",void 0),t([l({attribute:"required-text"})],c.prototype,"requiredText",void 0),t([l()],c.prototype,"value",void 0),t([l()],c.prototype,"name",void 0),t([l({attribute:"prefix-text"})],c.prototype,"prefixText",void 0),t([l({attribute:"suffix-text"})],c.prototype,"suffixText",void 0),t([l({attribute:"leading-icon"})],c.prototype,"leadingIcon",void 0),t([l({attribute:"trailing-icon"})],c.prototype,"trailingIcon",void 0),t([l({type:Boolean})],c.prototype,"searchEnabled",void 0),t([l({type:Number})],c.prototype,"searchResultCount",void 0),t([l({type:Number})],c.prototype,"searchResultIndex",void 0),t([l({attribute:"supporting-text"})],c.prototype,"supportingText",void 0),t([l({attribute:"text-direction"})],c.prototype,"textDirection",void 0),t([l({type:Number})],c.prototype,"rows",void 0),t([l({reflect:!0})],c.prototype,"inputMode",void 0),t([l()],c.prototype,"max",void 0),t([l({type:Number})],c.prototype,"maxLength",void 0),t([l()],c.prototype,"min",void 0),t([l({type:Number})],c.prototype,"minLength",void 0),t([l()],c.prototype,"pattern",void 0),t([l({reflect:!0})],c.prototype,"placeholder",void 0),t([l({type:Boolean,reflect:!0})],c.prototype,"readOnly",void 0),t([l({type:Boolean,reflect:!0})],c.prototype,"multiple",void 0),t([l()],c.prototype,"step",void 0),t([l({reflect:!0})],c.prototype,"type",void 0),t([l({reflect:!0})],c.prototype,"autocomplete",void 0),t([a()],c.prototype,"hasText",void 0),customElements.define("ix-textbox",c);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@digital-realty/ix-textbox",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.6-IXUAT-11121.553801",
|
|
4
4
|
"description": "Webcomponent ix-textbox following open-wc recommendations",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Digital Realty",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@digital-realty/ix-icon": "^1.3.4",
|
|
36
|
-
"@digital-realty/ix-phone-input": "^2.4.
|
|
36
|
+
"@digital-realty/ix-phone-input": "^2.4.6-IXUAT-11121.553801",
|
|
37
37
|
"@digital-realty/ix-shared-fns": "^1.1.4",
|
|
38
38
|
"@lit/react": "^1.0.2",
|
|
39
39
|
"@material/web": "2.4.0",
|
|
@@ -106,5 +106,5 @@
|
|
|
106
106
|
"README.md",
|
|
107
107
|
"LICENSE"
|
|
108
108
|
],
|
|
109
|
-
"gitHead": "
|
|
109
|
+
"gitHead": "f269b9632ceda861509a10f18afb55a58d9d44de"
|
|
110
110
|
}
|