@politiet/sheriff-web-components 2.9.0 → 2.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/custom-elements.json +782 -4
- package/dist/frameworks/preact.d.ts +4 -1
- package/dist/frameworks/preact.d.ts.map +1 -1
- package/dist/frameworks/react.d.ts +4 -1
- package/dist/frameworks/react.d.ts.map +1 -1
- package/dist/frameworks/solidjs.d.ts +1 -0
- package/dist/frameworks/solidjs.d.ts.map +1 -1
- package/dist/frameworks/svelte.d.ts +1 -0
- package/dist/frameworks/svelte.d.ts.map +1 -1
- package/dist/frameworks/vue.d.ts +1 -0
- package/dist/frameworks/vue.d.ts.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/react-wrappers/SDSEnvironmentBannerWrapper.d.ts +3 -0
- package/dist/react-wrappers/SDSEnvironmentBannerWrapper.d.ts.map +1 -0
- package/dist/react-wrappers/SDSEnvironmentBannerWrapper.js +10 -0
- package/dist/react-wrappers/SDSEnvironmentBannerWrapper.js.map +1 -0
- package/dist/react-wrappers/index.d.ts +1 -0
- package/dist/react-wrappers/index.d.ts.map +1 -1
- package/dist/react-wrappers/index.js +1 -0
- package/dist/react-wrappers/index.js.map +1 -1
- package/dist/sds-environment-banner/sds-environment-banner.component.d.ts +13 -0
- package/dist/sds-environment-banner/sds-environment-banner.component.d.ts.map +1 -0
- package/dist/sds-environment-banner/sds-environment-banner.component.js +36 -0
- package/dist/sds-environment-banner/sds-environment-banner.component.js.map +1 -0
- package/dist/sds-environment-banner/sds-environment-banner.d.ts +9 -0
- package/dist/sds-environment-banner/sds-environment-banner.d.ts.map +1 -0
- package/dist/sds-environment-banner/sds-environment-banner.js +15 -0
- package/dist/sds-environment-banner/sds-environment-banner.js.map +1 -0
- package/dist/sds-environment-banner/sds-environment-banner.styles.d.ts +2 -0
- package/dist/sds-environment-banner/sds-environment-banner.styles.d.ts.map +1 -0
- package/dist/sds-environment-banner/sds-environment-banner.styles.js +98 -0
- package/dist/sds-environment-banner/sds-environment-banner.styles.js.map +1 -0
- package/dist/sds-icon/sds-icon-names.d.ts +1 -1
- package/dist/sds-icon/sds-icon-names.d.ts.map +1 -1
- package/dist/sds-icon/sds-icon-names.js +484 -0
- package/dist/sds-icon/sds-icon-names.js.map +1 -1
- package/dist/sds-radio/sds-radio.d.ts.map +1 -1
- package/dist/sds-radio/sds-radio.js +4 -0
- package/dist/sds-radio/sds-radio.js.map +1 -1
- package/dist/sds-select/sds-select.component.d.ts.map +1 -1
- package/dist/sds-select/sds-select.component.js +4 -0
- package/dist/sds-select/sds-select.component.js.map +1 -1
- package/dist/sds-select/sds-select.styles.d.ts.map +1 -1
- package/dist/sds-select/sds-select.styles.js +12 -18
- package/dist/sds-select/sds-select.styles.js.map +1 -1
- package/dist/sds-textfield/sds-textfield.component.d.ts +68 -0
- package/dist/sds-textfield/sds-textfield.component.d.ts.map +1 -0
- package/dist/sds-textfield/sds-textfield.component.js +249 -0
- package/dist/sds-textfield/sds-textfield.component.js.map +1 -0
- package/dist/sds-textfield/sds-textfield.d.ts +3 -66
- package/dist/sds-textfield/sds-textfield.d.ts.map +1 -1
- package/dist/sds-textfield/sds-textfield.js +2 -241
- package/dist/sds-textfield/sds-textfield.js.map +1 -1
- package/dist/sheriff-web-components.js +148 -54
- package/package.json +12 -3
- package/web-types.json +94 -3
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { LitElement, html, nothing } from 'lit';
|
|
8
|
+
import { property, query, state } from 'lit/decorators.js';
|
|
9
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
10
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
11
|
+
import { SDSEventDispatcherMixin, SDSDelegateInteractionMixin, SDSFormControlMixin } from '../mixins';
|
|
12
|
+
import { styles } from './sds-textfield.styles';
|
|
13
|
+
export class SDSTextFieldComponent extends SDSDelegateInteractionMixin(SDSEventDispatcherMixin(SDSFormControlMixin(LitElement))) {
|
|
14
|
+
constructor() {
|
|
15
|
+
super(...arguments);
|
|
16
|
+
this.type = 'text';
|
|
17
|
+
this.required = false;
|
|
18
|
+
this.size = 'md';
|
|
19
|
+
// State
|
|
20
|
+
this.hasIcon = false;
|
|
21
|
+
/** Tracks whether the `label` slot has assigned content. */
|
|
22
|
+
this._hasSlottedLabel = false;
|
|
23
|
+
this._defaultValue = null;
|
|
24
|
+
this.handleSlotChange = (e) => {
|
|
25
|
+
const slot = e.target;
|
|
26
|
+
this.hasIcon = slot.assignedNodes({ flatten: true }).length > 0;
|
|
27
|
+
};
|
|
28
|
+
this._handleLabelSlotChange = (e) => {
|
|
29
|
+
this._hasSlottedLabel = e.target.assignedNodes().length > 0;
|
|
30
|
+
};
|
|
31
|
+
this._handleInputChange = (event) => {
|
|
32
|
+
event.stopImmediatePropagation();
|
|
33
|
+
if (this.disabled || !(event.target instanceof HTMLInputElement)) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
this.value = event.target.value;
|
|
37
|
+
this.internals.setFormValue(this.value === '' ? null : this.value);
|
|
38
|
+
this.updateValidity();
|
|
39
|
+
this.dispatchSheriffEvent(event.type);
|
|
40
|
+
};
|
|
41
|
+
this._handleSelect = (event) => {
|
|
42
|
+
event.stopImmediatePropagation();
|
|
43
|
+
if (!this.disabled) {
|
|
44
|
+
this.dispatchSheriffEvent('select');
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
this._handleFocus = (event) => {
|
|
48
|
+
event.stopImmediatePropagation();
|
|
49
|
+
this.dispatchSheriffEvent('focus');
|
|
50
|
+
};
|
|
51
|
+
this._handleBlur = (event) => {
|
|
52
|
+
event.stopImmediatePropagation();
|
|
53
|
+
this.updateValidity();
|
|
54
|
+
this.dispatchSheriffEvent('blur');
|
|
55
|
+
};
|
|
56
|
+
this._handleKeyDown = (event) => {
|
|
57
|
+
event.stopImmediatePropagation();
|
|
58
|
+
const shouldContinue = this.dispatchKeyboardEvent('keydown', event);
|
|
59
|
+
if (!shouldContinue) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (event.key !== 'Enter') {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
for (const element of Array.from(this.form?.elements ?? [])) {
|
|
66
|
+
if (element instanceof HTMLButtonElement || element instanceof HTMLInputElement) {
|
|
67
|
+
if (element.type !== 'submit') {
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
if (element.disabled) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
element.click();
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
this.form?.requestSubmit();
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
connectedCallback() {
|
|
81
|
+
super.connectedCallback();
|
|
82
|
+
this._defaultValue = this.value ?? null;
|
|
83
|
+
this.internals.setFormValue(this._defaultValue);
|
|
84
|
+
}
|
|
85
|
+
updated(changedProperties) {
|
|
86
|
+
super.updated(changedProperties);
|
|
87
|
+
if (changedProperties.has('value')) {
|
|
88
|
+
this.internals.setFormValue(this.value ?? '');
|
|
89
|
+
if (this.control) {
|
|
90
|
+
this.control.value = this.value ?? '';
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
updateValidity() {
|
|
95
|
+
if (!this.control) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
if (this.control.checkValidity()) {
|
|
99
|
+
this.internals.setValidity({});
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
this.internals.setValidity({ customError: true }, this.control.validationMessage, this.control);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
formResetCallback() {
|
|
106
|
+
this.internals.setFormValue(this._defaultValue);
|
|
107
|
+
const newValue = this._defaultValue ?? '';
|
|
108
|
+
this.control.value = newValue;
|
|
109
|
+
this.value = newValue;
|
|
110
|
+
this.updateValidity();
|
|
111
|
+
}
|
|
112
|
+
select() {
|
|
113
|
+
if (!this.disabled)
|
|
114
|
+
this.control.select();
|
|
115
|
+
}
|
|
116
|
+
get selectionStart() {
|
|
117
|
+
return this.control ? this.control.selectionStart : null;
|
|
118
|
+
}
|
|
119
|
+
set selectionStart(value) {
|
|
120
|
+
if (this.control && value !== null) {
|
|
121
|
+
this.control.selectionStart = value;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
get selectionEnd() {
|
|
125
|
+
return this.control ? this.control.selectionEnd : null;
|
|
126
|
+
}
|
|
127
|
+
set selectionEnd(value) {
|
|
128
|
+
if (this.control && value !== null) {
|
|
129
|
+
this.control.selectionEnd = value;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
setSelectionRange(start, end, direction) {
|
|
133
|
+
if (this.control) {
|
|
134
|
+
this.control.setSelectionRange(start, end, direction);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
checkValidity() {
|
|
138
|
+
return this.control.checkValidity();
|
|
139
|
+
}
|
|
140
|
+
reportValidity() {
|
|
141
|
+
return this.control.reportValidity();
|
|
142
|
+
}
|
|
143
|
+
setCustomValidity(message) {
|
|
144
|
+
this.control.setCustomValidity(message);
|
|
145
|
+
this.updateValidity();
|
|
146
|
+
}
|
|
147
|
+
render() {
|
|
148
|
+
const textfieldClasses = {
|
|
149
|
+
'sds-textfield': true,
|
|
150
|
+
'sds-textfield--error': Boolean(this.errorMessage),
|
|
151
|
+
'sds-textfield--has-icon': this.hasIcon,
|
|
152
|
+
};
|
|
153
|
+
const describedBy = [this.errorMessage ? 'error-message' : null, this.helpText ? 'help-text' : null].filter(Boolean).join(' ') || undefined;
|
|
154
|
+
const showLabel = this._hasSlottedLabel || Boolean(this.label);
|
|
155
|
+
return html `
|
|
156
|
+
<div class="${classMap(textfieldClasses)}">
|
|
157
|
+
<label for="sds-textfield" class="sds-textfield__label" ?hidden="${!showLabel}">
|
|
158
|
+
${this.readOnly ? html `<sds-icon name="lock-material-filled" size="m"></sds-icon>` : nothing}
|
|
159
|
+
<slot name="label" @slotchange="${this._handleLabelSlotChange}">${this.label}</slot>
|
|
160
|
+
</label>
|
|
161
|
+
${this.helpText ? html `<p id="help-text" class="sds-textfield__help-text">${this.helpText}</p>` : nothing}
|
|
162
|
+
<div class="sds-textfield__input-container">
|
|
163
|
+
<input
|
|
164
|
+
part="input"
|
|
165
|
+
class="sds-textfield__input"
|
|
166
|
+
type="${ifDefined(this.type)}"
|
|
167
|
+
id="sds-textfield"
|
|
168
|
+
?disabled="${this.disabled}"
|
|
169
|
+
?readonly="${this.readOnly}"
|
|
170
|
+
placeholder="${ifDefined(this.placeholder)}"
|
|
171
|
+
.value="${this.value ?? ''}"
|
|
172
|
+
name="${ifDefined(this.name)}"
|
|
173
|
+
autocomplete="${ifDefined(this.autocomplete)}"
|
|
174
|
+
?required="${this.required}"
|
|
175
|
+
pattern="${ifDefined(this.pattern)}"
|
|
176
|
+
min="${ifDefined(this.min)}"
|
|
177
|
+
minlength="${ifDefined(this.minlength)}"
|
|
178
|
+
max="${ifDefined(this.max)}"
|
|
179
|
+
maxlength="${ifDefined(this.maxlength)}"
|
|
180
|
+
aria-describedby="${ifDefined(describedBy)}"
|
|
181
|
+
aria-invalid="${this.errorMessage ? 'true' : 'false'}"
|
|
182
|
+
@input="${this._handleInputChange}"
|
|
183
|
+
@change="${this._handleInputChange}"
|
|
184
|
+
@select="${this._handleSelect}"
|
|
185
|
+
@focus="${this._handleFocus}"
|
|
186
|
+
@blur="${this._handleBlur}"
|
|
187
|
+
@keydown="${this._handleKeyDown}"
|
|
188
|
+
/>
|
|
189
|
+
<slot name="after" @slotchange="${this.handleSlotChange}" aria-hidden="true"></slot>
|
|
190
|
+
</div>
|
|
191
|
+
${this.errorMessage ? html `<sds-alert id="error-message" variant="secondary" data-palette="danger"><p slot="message">${this.errorMessage}</p></sds-alert>` : nothing}
|
|
192
|
+
</div>
|
|
193
|
+
`;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
// Styling
|
|
197
|
+
SDSTextFieldComponent.styles = [styles];
|
|
198
|
+
__decorate([
|
|
199
|
+
property({ type: String, reflect: true })
|
|
200
|
+
], SDSTextFieldComponent.prototype, "type", void 0);
|
|
201
|
+
__decorate([
|
|
202
|
+
property({ type: String })
|
|
203
|
+
], SDSTextFieldComponent.prototype, "value", void 0);
|
|
204
|
+
__decorate([
|
|
205
|
+
property({ type: String, reflect: true })
|
|
206
|
+
], SDSTextFieldComponent.prototype, "label", void 0);
|
|
207
|
+
__decorate([
|
|
208
|
+
property({ type: String, reflect: true })
|
|
209
|
+
], SDSTextFieldComponent.prototype, "placeholder", void 0);
|
|
210
|
+
__decorate([
|
|
211
|
+
property({ type: String, attribute: 'help-text', reflect: true })
|
|
212
|
+
], SDSTextFieldComponent.prototype, "helpText", void 0);
|
|
213
|
+
__decorate([
|
|
214
|
+
property({ type: String, attribute: 'error-message', reflect: true })
|
|
215
|
+
], SDSTextFieldComponent.prototype, "errorMessage", void 0);
|
|
216
|
+
__decorate([
|
|
217
|
+
property({ type: String, reflect: true })
|
|
218
|
+
], SDSTextFieldComponent.prototype, "autocomplete", void 0);
|
|
219
|
+
__decorate([
|
|
220
|
+
property({ type: Boolean, reflect: true })
|
|
221
|
+
], SDSTextFieldComponent.prototype, "required", void 0);
|
|
222
|
+
__decorate([
|
|
223
|
+
property({ type: String, reflect: true })
|
|
224
|
+
], SDSTextFieldComponent.prototype, "pattern", void 0);
|
|
225
|
+
__decorate([
|
|
226
|
+
property({ type: Number, reflect: true })
|
|
227
|
+
], SDSTextFieldComponent.prototype, "minlength", void 0);
|
|
228
|
+
__decorate([
|
|
229
|
+
property({ type: Number, reflect: true })
|
|
230
|
+
], SDSTextFieldComponent.prototype, "maxlength", void 0);
|
|
231
|
+
__decorate([
|
|
232
|
+
property({ type: String, reflect: true })
|
|
233
|
+
], SDSTextFieldComponent.prototype, "min", void 0);
|
|
234
|
+
__decorate([
|
|
235
|
+
property({ type: String, reflect: true })
|
|
236
|
+
], SDSTextFieldComponent.prototype, "max", void 0);
|
|
237
|
+
__decorate([
|
|
238
|
+
property({ type: String, reflect: true })
|
|
239
|
+
], SDSTextFieldComponent.prototype, "size", void 0);
|
|
240
|
+
__decorate([
|
|
241
|
+
state()
|
|
242
|
+
], SDSTextFieldComponent.prototype, "hasIcon", void 0);
|
|
243
|
+
__decorate([
|
|
244
|
+
state()
|
|
245
|
+
], SDSTextFieldComponent.prototype, "_hasSlottedLabel", void 0);
|
|
246
|
+
__decorate([
|
|
247
|
+
query('#sds-textfield')
|
|
248
|
+
], SDSTextFieldComponent.prototype, "control", void 0);
|
|
249
|
+
//# sourceMappingURL=sds-textfield.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sds-textfield.component.js","sourceRoot":"","sources":["../../src/sds-textfield/sds-textfield.component.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,uBAAuB,EAAE,2BAA2B,EAAE,mBAAmB,EAAE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AAgD;AACvB;IAAlE,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;uDAA2C;AACtC;IAAtE,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;2DAAmD;AAC9E;IAA1C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;2DAAkD;AAChD;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;uDAAiD;AACjD;IAA1C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;sDAAwC;AACvC;IAA1C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;wDAA4C;AAC3C;IAA1C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;wDAA4C;AAC3C;IAA1C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;kDAAgC;AAC/B;IAA1C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;kDAAgC;AAC/B;IAA1C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;mDAAwC;AAGjE;IAAhB,KAAK,EAAE;sDAAyB;AAEhB;IAAhB,KAAK,EAAE;+DAAkC;AAEjB;IAAxB,KAAK,CAAC,gBAAgB,CAAC;sDAA4B","sourcesContent":["import { LitElement, html, nothing } from 'lit';\nimport { property, query, state } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { SDSEventDispatcherMixin, SDSDelegateInteractionMixin, SDSFormControlMixin } from '../mixins';\nimport type { SDSFormControlAttributes } from '../mixins/sds-form-control-mixin';\nimport { styles } from './sds-textfield.styles';\nimport { SDS_SIZES } from '../types';\n\ntype InputType =\n\t| 'hidden'\n\t| 'text'\n\t| 'search'\n\t| 'tel'\n\t| 'url'\n\t| 'email'\n\t| 'password'\n\t| 'datetime'\n\t| 'date'\n\t| 'month'\n\t| 'week'\n\t| 'time'\n\t| 'datetime-local'\n\t| 'number'\n\t| 'range'\n\t| 'color'\n\t| 'checkbox'\n\t| 'radio'\n\t| 'file'\n\t| 'submit'\n\t| 'image'\n\t| 'reset'\n\t| 'button';\n\ntype InputSize = Extract<SDS_SIZES, 'lg' | 'md' | 'sm'>;\nexport type AutocompleteTypes =\n\t| 'off'\n\t| 'on'\n\t| 'name'\n\t| 'honorific-prefix'\n\t| 'given-name'\n\t| 'additional-name'\n\t| 'family-name'\n\t| 'honorific-suffix'\n\t| 'nickname'\n\t| 'email'\n\t| 'username'\n\t| 'new-password'\n\t| 'current-password'\n\t| 'one-time-code'\n\t| 'organization-title'\n\t| 'organization'\n\t| 'street-address'\n\t| 'address-line1'\n\t| 'address-line2'\n\t| 'address-line3'\n\t| 'address-level4'\n\t| 'address-level3'\n\t| 'address-level2'\n\t| 'address-level1'\n\t| 'country'\n\t| 'country-name'\n\t| 'postal-code'\n\t| 'cc-name'\n\t| 'cc-given-name'\n\t| 'cc-additional-name'\n\t| 'cc-family-name'\n\t| 'cc-number'\n\t| 'cc-exp'\n\t| 'cc-exp-month'\n\t| 'cc-exp-year'\n\t| 'cc-csc'\n\t| 'cc-type'\n\t| 'transaction-currency'\n\t| 'transaction-amount'\n\t| 'language'\n\t| 'bday'\n\t| 'bday-day'\n\t| 'bday-month'\n\t| 'bday-year'\n\t| 'sex'\n\t| 'tel'\n\t| 'tel-country-code'\n\t| 'tel-national'\n\t| 'tel-area-code'\n\t| 'tel-local'\n\t| 'tel-extension'\n\t| 'impp'\n\t| 'url'\n\t| 'photo';\n\nexport interface SDSTextFieldProps extends SDSFormControlAttributes {\n\tautocomplete?: AutocompleteTypes;\n\t'error-message'?: string;\n\t'help-text'?: string;\n\tlabel?: string;\n\tmaxlength?: number;\n\tminlength?: number;\n\tmin?: number | string;\n\tmax?: number | string;\n\tpattern?: string;\n\tplaceholder?: string;\n\trequired?: boolean;\n\tsize?: InputSize;\n\ttype?: InputType;\n\tvalue?: string;\n}\n\nexport class SDSTextFieldComponent extends SDSDelegateInteractionMixin(SDSEventDispatcherMixin(SDSFormControlMixin(LitElement))) {\n\t// Styling\n\tstatic override styles = [styles];\n\n\t@property({ type: String, reflect: true }) type: SDSTextFieldProps['type'] = 'text';\n\t@property({ type: String }) value?: SDSTextFieldProps['value'];\n\t@property({ type: String, reflect: true }) label?: SDSTextFieldProps['label'];\n\t@property({ type: String, reflect: true }) placeholder?: SDSTextFieldProps['placeholder'];\n\t@property({ type: String, attribute: 'help-text', reflect: true }) helpText?: SDSTextFieldProps['help-text'];\n\t@property({ type: String, attribute: 'error-message', reflect: true }) errorMessage?: SDSTextFieldProps['error-message'];\n\t@property({ type: String, reflect: true }) autocomplete?: SDSTextFieldProps['autocomplete'];\n\t@property({ type: Boolean, reflect: true }) required: SDSTextFieldProps['required'] = false;\n\t@property({ type: String, reflect: true }) pattern?: SDSTextFieldProps['pattern'];\n\t@property({ type: Number, reflect: true }) minlength?: SDSTextFieldProps['minlength'];\n\t@property({ type: Number, reflect: true }) maxlength?: SDSTextFieldProps['maxlength'];\n\t@property({ type: String, reflect: true }) min?: SDSTextFieldProps['min'];\n\t@property({ type: String, reflect: true }) max?: SDSTextFieldProps['max'];\n\t@property({ type: String, reflect: true }) size: SDSTextFieldProps['size'] = 'md';\n\n\t// State\n\t@state() private hasIcon = false;\n\t/** Tracks whether the `label` slot has assigned content. */\n\t@state() private _hasSlottedLabel = false;\n\n\t@query('#sds-textfield') control!: HTMLInputElement;\n\n\tprivate _defaultValue: string | null = null;\n\n\toverride connectedCallback() {\n\t\tsuper.connectedCallback();\n\t\tthis._defaultValue = this.value ?? null;\n\t\tthis.internals.setFormValue(this._defaultValue);\n\t}\n\n\toverride updated(changedProperties: Map<string | number | symbol, unknown>) {\n\t\tsuper.updated(changedProperties);\n\n\t\tif (changedProperties.has('value')) {\n\t\t\tthis.internals.setFormValue(this.value ?? '');\n\n\t\t\tif (this.control) {\n\t\t\t\tthis.control.value = this.value ?? '';\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate readonly handleSlotChange = (e: Event) => {\n\t\tconst slot = e.target as HTMLSlotElement;\n\t\tthis.hasIcon = slot.assignedNodes({ flatten: true }).length > 0;\n\t};\n\n\tprivate readonly _handleLabelSlotChange = (e: Event) => {\n\t\tthis._hasSlottedLabel = (e.target as HTMLSlotElement).assignedNodes().length > 0;\n\t};\n\n\toverride updateValidity() {\n\t\tif (!this.control) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.control.checkValidity()) {\n\t\t\tthis.internals.setValidity({});\n\t\t} else {\n\t\t\tthis.internals.setValidity({ customError: true }, this.control.validationMessage, this.control);\n\t\t}\n\t}\n\n\tprivate readonly _handleInputChange = (event: InputEvent) => {\n\t\tevent.stopImmediatePropagation();\n\t\tif (this.disabled || !(event.target instanceof HTMLInputElement)) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.value = event.target.value;\n\t\tthis.internals.setFormValue(this.value === '' ? null : this.value);\n\t\tthis.updateValidity();\n\t\tthis.dispatchSheriffEvent(event.type);\n\t};\n\n\tprivate readonly _handleSelect = (event: Event) => {\n\t\tevent.stopImmediatePropagation();\n\t\tif (!this.disabled) {\n\t\t\tthis.dispatchSheriffEvent('select');\n\t\t}\n\t};\n\n\tprivate readonly _handleFocus = (event: FocusEvent) => {\n\t\tevent.stopImmediatePropagation();\n\t\tthis.dispatchSheriffEvent('focus');\n\t};\n\n\tprivate readonly _handleBlur = (event: FocusEvent) => {\n\t\tevent.stopImmediatePropagation();\n\t\tthis.updateValidity();\n\t\tthis.dispatchSheriffEvent('blur');\n\t};\n\n\tprivate readonly _handleKeyDown = (event: KeyboardEvent) => {\n\t\tevent.stopImmediatePropagation();\n\n\t\tconst shouldContinue = this.dispatchKeyboardEvent('keydown', event);\n\t\tif (!shouldContinue) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (event.key !== 'Enter') {\n\t\t\treturn;\n\t\t}\n\n\t\tfor (const element of Array.from(this.form?.elements ?? [])) {\n\t\t\tif (element instanceof HTMLButtonElement || element instanceof HTMLInputElement) {\n\t\t\t\tif (element.type !== 'submit') {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tif (element.disabled) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\telement.click();\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tthis.form?.requestSubmit();\n\t};\n\n\tformResetCallback() {\n\t\tthis.internals.setFormValue(this._defaultValue);\n\n\t\tconst newValue = this._defaultValue ?? '';\n\t\tthis.control.value = newValue;\n\t\tthis.value = newValue;\n\t\tthis.updateValidity();\n\t}\n\n\tselect(): void {\n\t\tif (!this.disabled) this.control.select();\n\t}\n\n\tget selectionStart(): number | null {\n\t\treturn this.control ? this.control.selectionStart : null;\n\t}\n\n\tset selectionStart(value: number | null) {\n\t\tif (this.control && value !== null) {\n\t\t\tthis.control.selectionStart = value;\n\t\t}\n\t}\n\n\tget selectionEnd(): number | null {\n\t\treturn this.control ? this.control.selectionEnd : null;\n\t}\n\tset selectionEnd(value: number | null) {\n\t\tif (this.control && value !== null) {\n\t\t\tthis.control.selectionEnd = value;\n\t\t}\n\t}\n\n\tsetSelectionRange(start: number, end: number, direction?: 'forward' | 'backward' | 'none'): void {\n\t\tif (this.control) {\n\t\t\tthis.control.setSelectionRange(start, end, direction);\n\t\t}\n\t}\n\n\tcheckValidity(): boolean {\n\t\treturn this.control.checkValidity();\n\t}\n\n\treportValidity(): boolean {\n\t\treturn this.control.reportValidity();\n\t}\n\n\tsetCustomValidity(message: string): void {\n\t\tthis.control.setCustomValidity(message);\n\t\tthis.updateValidity();\n\t}\n\n\toverride render() {\n\t\tconst textfieldClasses = {\n\t\t\t'sds-textfield': true,\n\t\t\t'sds-textfield--error': Boolean(this.errorMessage),\n\t\t\t'sds-textfield--has-icon': this.hasIcon,\n\t\t};\n\n\t\tconst describedBy = [this.errorMessage ? 'error-message' : null, this.helpText ? 'help-text' : null].filter(Boolean).join(' ') || undefined;\n\n\t\tconst showLabel = this._hasSlottedLabel || Boolean(this.label);\n\n\t\treturn html`\n\t\t\t<div class=\"${classMap(textfieldClasses)}\">\n\t\t\t\t<label for=\"sds-textfield\" class=\"sds-textfield__label\" ?hidden=\"${!showLabel}\">\n\t\t\t\t\t${this.readOnly ? html`<sds-icon name=\"lock-material-filled\" size=\"m\"></sds-icon>` : nothing}\n\t\t\t\t\t<slot name=\"label\" @slotchange=\"${this._handleLabelSlotChange}\">${this.label}</slot>\n\t\t\t\t</label>\n\t\t\t\t${this.helpText ? html`<p id=\"help-text\" class=\"sds-textfield__help-text\">${this.helpText}</p>` : nothing}\n\t\t\t\t<div class=\"sds-textfield__input-container\">\n\t\t\t\t\t<input\n\t\t\t\t\t\tpart=\"input\"\n\t\t\t\t\t\tclass=\"sds-textfield__input\"\n\t\t\t\t\t\ttype=\"${ifDefined(this.type)}\"\n\t\t\t\t\t\tid=\"sds-textfield\"\n\t\t\t\t\t\t?disabled=\"${this.disabled}\"\n\t\t\t\t\t\t?readonly=\"${this.readOnly}\"\n\t\t\t\t\t\tplaceholder=\"${ifDefined(this.placeholder)}\"\n\t\t\t\t\t\t.value=\"${this.value ?? ''}\"\n\t\t\t\t\t\tname=\"${ifDefined(this.name)}\"\n\t\t\t\t\t\tautocomplete=\"${ifDefined(this.autocomplete as any)}\"\n\t\t\t\t\t\t?required=\"${this.required}\"\n\t\t\t\t\t\tpattern=\"${ifDefined(this.pattern)}\"\n\t\t\t\t\t\tmin=\"${ifDefined(this.min)}\"\n\t\t\t\t\t\tminlength=\"${ifDefined(this.minlength)}\"\n\t\t\t\t\t\tmax=\"${ifDefined(this.max)}\"\n\t\t\t\t\t\tmaxlength=\"${ifDefined(this.maxlength)}\"\n\t\t\t\t\t\taria-describedby=\"${ifDefined(describedBy)}\"\n\t\t\t\t\t\taria-invalid=\"${this.errorMessage ? 'true' : 'false'}\"\n\t\t\t\t\t\t@input=\"${this._handleInputChange}\"\n\t\t\t\t\t\t@change=\"${this._handleInputChange}\"\n\t\t\t\t\t\t@select=\"${this._handleSelect}\"\n\t\t\t\t\t\t@focus=\"${this._handleFocus}\"\n\t\t\t\t\t\t@blur=\"${this._handleBlur}\"\n\t\t\t\t\t\t@keydown=\"${this._handleKeyDown}\"\n\t\t\t\t\t/>\n\t\t\t\t\t<slot name=\"after\" @slotchange=\"${this.handleSlotChange}\" aria-hidden=\"true\"></slot>\n\t\t\t\t</div>\n\t\t\t\t${this.errorMessage ? html`<sds-alert id=\"error-message\" variant=\"secondary\" data-palette=\"danger\"><p slot=\"message\">${this.errorMessage}</p></sds-alert>` : nothing}\n\t\t\t</div>\n\t\t`;\n\t}\n}\n"]}
|
|
@@ -1,75 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { SDSFormControlAttributes } from '../mixins/sds-form-control-mixin';
|
|
1
|
+
import { SDSTextFieldComponent } from './sds-textfield.component';
|
|
3
2
|
import '../sds-alert/sds-alert';
|
|
4
3
|
import '../sds-icon/sds-icon';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
type InputSize = Extract<SDS_SIZES, 'lg' | 'md' | 'sm'>;
|
|
8
|
-
export type AutocompleteTypes = 'off' | 'on' | 'name' | 'honorific-prefix' | 'given-name' | 'additional-name' | 'family-name' | 'honorific-suffix' | 'nickname' | 'email' | 'username' | 'new-password' | 'current-password' | 'one-time-code' | 'organization-title' | 'organization' | 'street-address' | 'address-line1' | 'address-line2' | 'address-line3' | 'address-level4' | 'address-level3' | 'address-level2' | 'address-level1' | 'country' | 'country-name' | 'postal-code' | 'cc-name' | 'cc-given-name' | 'cc-additional-name' | 'cc-family-name' | 'cc-number' | 'cc-exp' | 'cc-exp-month' | 'cc-exp-year' | 'cc-csc' | 'cc-type' | 'transaction-currency' | 'transaction-amount' | 'language' | 'bday' | 'bday-day' | 'bday-month' | 'bday-year' | 'sex' | 'tel' | 'tel-country-code' | 'tel-national' | 'tel-area-code' | 'tel-local' | 'tel-extension' | 'impp' | 'url' | 'photo';
|
|
9
|
-
export interface SDSTextFieldProps extends SDSFormControlAttributes {
|
|
10
|
-
autocomplete?: AutocompleteTypes;
|
|
11
|
-
'error-message'?: string;
|
|
12
|
-
'help-text'?: string;
|
|
13
|
-
label?: string;
|
|
14
|
-
maxlength?: number;
|
|
15
|
-
minlength?: number;
|
|
16
|
-
min?: number | string;
|
|
17
|
-
max?: number | string;
|
|
18
|
-
pattern?: string;
|
|
19
|
-
placeholder?: string;
|
|
20
|
-
required?: boolean;
|
|
21
|
-
size?: InputSize;
|
|
22
|
-
type?: InputType;
|
|
23
|
-
value?: string;
|
|
24
|
-
}
|
|
25
|
-
declare const SDSTextField_base: import("../mixins/types").Constructable<import("../mixins/sds-delegate-interaction-mixin").DelegateInteractionMixinInterface> & import("../mixins/types").Constructable<import("../mixins/sds-event-dispatcher-mixin").SDSEventDispatcherMixinInterface> & import("../mixins/types").Constructable<import("../mixins/sds-form-control-mixin").SDSFormControlMixinInterface> & typeof LitElement;
|
|
26
|
-
export declare class SDSTextField extends SDSTextField_base {
|
|
27
|
-
static styles: import("lit").CSSResult[];
|
|
28
|
-
type: SDSTextFieldProps['type'];
|
|
29
|
-
value?: SDSTextFieldProps['value'];
|
|
30
|
-
label?: SDSTextFieldProps['label'];
|
|
31
|
-
placeholder?: SDSTextFieldProps['placeholder'];
|
|
32
|
-
helpText?: SDSTextFieldProps['help-text'];
|
|
33
|
-
errorMessage?: SDSTextFieldProps['error-message'];
|
|
34
|
-
autocomplete?: SDSTextFieldProps['autocomplete'];
|
|
35
|
-
required: SDSTextFieldProps['required'];
|
|
36
|
-
pattern?: SDSTextFieldProps['pattern'];
|
|
37
|
-
minlength?: SDSTextFieldProps['minlength'];
|
|
38
|
-
maxlength?: SDSTextFieldProps['maxlength'];
|
|
39
|
-
min?: SDSTextFieldProps['min'];
|
|
40
|
-
max?: SDSTextFieldProps['max'];
|
|
41
|
-
size: SDSTextFieldProps['size'];
|
|
42
|
-
private hasIcon;
|
|
43
|
-
/** Tracks whether the `label` slot has assigned content. */
|
|
44
|
-
private _hasSlottedLabel;
|
|
45
|
-
control: HTMLInputElement;
|
|
46
|
-
private _defaultValue;
|
|
47
|
-
connectedCallback(): void;
|
|
48
|
-
updated(changedProperties: Map<string | number | symbol, unknown>): void;
|
|
49
|
-
private readonly handleSlotChange;
|
|
50
|
-
private readonly _handleLabelSlotChange;
|
|
51
|
-
updateValidity(): void;
|
|
52
|
-
private readonly _handleInputChange;
|
|
53
|
-
private readonly _handleSelect;
|
|
54
|
-
private readonly _handleFocus;
|
|
55
|
-
private readonly _handleBlur;
|
|
56
|
-
private readonly _handleKeyDown;
|
|
57
|
-
formResetCallback(): void;
|
|
58
|
-
select(): void;
|
|
59
|
-
get selectionStart(): number | null;
|
|
60
|
-
set selectionStart(value: number | null);
|
|
61
|
-
get selectionEnd(): number | null;
|
|
62
|
-
set selectionEnd(value: number | null);
|
|
63
|
-
setSelectionRange(start: number, end: number, direction?: 'forward' | 'backward' | 'none'): void;
|
|
64
|
-
checkValidity(): boolean;
|
|
65
|
-
reportValidity(): boolean;
|
|
66
|
-
setCustomValidity(message: string): void;
|
|
67
|
-
render(): import("lit-html").TemplateResult<1>;
|
|
4
|
+
export type { AutocompleteTypes, SDSTextFieldProps } from './sds-textfield.component';
|
|
5
|
+
export declare class SDSTextField extends SDSTextFieldComponent {
|
|
68
6
|
}
|
|
69
7
|
declare global {
|
|
70
8
|
interface HTMLElementTagNameMap {
|
|
71
9
|
'sds-textfield': SDSTextField;
|
|
72
10
|
}
|
|
73
11
|
}
|
|
74
|
-
export {};
|
|
75
12
|
//# sourceMappingURL=sds-textfield.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sds-textfield.d.ts","sourceRoot":"","sources":["../../src/sds-textfield/sds-textfield.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sds-textfield.d.ts","sourceRoot":"","sources":["../../src/sds-textfield/sds-textfield.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAElE,OAAO,wBAAwB,CAAC;AAChC,OAAO,sBAAsB,CAAC;AAE9B,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAEtF,qBACa,YAAa,SAAQ,qBAAqB;CAAG;AAE1D,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,eAAe,EAAE,YAAY,CAAC;KAC9B;CACD"}
|
|
@@ -4,251 +4,12 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import { LitElement, html, nothing } from 'lit';
|
|
8
|
-
import { property, query, state } from 'lit/decorators.js';
|
|
9
|
-
import { classMap } from 'lit/directives/class-map.js';
|
|
10
|
-
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
11
7
|
import { guardedCustomElement } from '../utils/guarded-custom-element';
|
|
12
|
-
import {
|
|
13
|
-
import { styles } from './sds-textfield.styles';
|
|
8
|
+
import { SDSTextFieldComponent } from './sds-textfield.component';
|
|
14
9
|
import '../sds-alert/sds-alert';
|
|
15
10
|
import '../sds-icon/sds-icon';
|
|
16
|
-
let SDSTextField = class SDSTextField extends
|
|
17
|
-
constructor() {
|
|
18
|
-
super(...arguments);
|
|
19
|
-
this.type = 'text';
|
|
20
|
-
this.required = false;
|
|
21
|
-
this.size = 'md';
|
|
22
|
-
// State
|
|
23
|
-
this.hasIcon = false;
|
|
24
|
-
/** Tracks whether the `label` slot has assigned content. */
|
|
25
|
-
this._hasSlottedLabel = false;
|
|
26
|
-
this._defaultValue = null;
|
|
27
|
-
this.handleSlotChange = (e) => {
|
|
28
|
-
const slot = e.target;
|
|
29
|
-
this.hasIcon = slot.assignedNodes({ flatten: true }).length > 0;
|
|
30
|
-
};
|
|
31
|
-
this._handleLabelSlotChange = (e) => {
|
|
32
|
-
this._hasSlottedLabel = e.target.assignedNodes().length > 0;
|
|
33
|
-
};
|
|
34
|
-
this._handleInputChange = (event) => {
|
|
35
|
-
event.stopImmediatePropagation();
|
|
36
|
-
if (this.disabled || !(event.target instanceof HTMLInputElement)) {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
this.value = event.target.value;
|
|
40
|
-
this.internals.setFormValue(this.value === '' ? null : this.value);
|
|
41
|
-
this.updateValidity();
|
|
42
|
-
this.dispatchSheriffEvent(event.type);
|
|
43
|
-
};
|
|
44
|
-
this._handleSelect = (event) => {
|
|
45
|
-
event.stopImmediatePropagation();
|
|
46
|
-
if (!this.disabled) {
|
|
47
|
-
this.dispatchSheriffEvent('select');
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
this._handleFocus = (event) => {
|
|
51
|
-
event.stopImmediatePropagation();
|
|
52
|
-
this.dispatchSheriffEvent('focus');
|
|
53
|
-
};
|
|
54
|
-
this._handleBlur = (event) => {
|
|
55
|
-
event.stopImmediatePropagation();
|
|
56
|
-
this.updateValidity();
|
|
57
|
-
this.dispatchSheriffEvent('blur');
|
|
58
|
-
};
|
|
59
|
-
this._handleKeyDown = (event) => {
|
|
60
|
-
event.stopImmediatePropagation();
|
|
61
|
-
const shouldContinue = this.dispatchKeyboardEvent('keydown', event);
|
|
62
|
-
if (!shouldContinue) {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
if (event.key !== 'Enter') {
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
for (const element of Array.from(this.form?.elements ?? [])) {
|
|
69
|
-
if (element instanceof HTMLButtonElement || element instanceof HTMLInputElement) {
|
|
70
|
-
if (element.type !== 'submit') {
|
|
71
|
-
continue;
|
|
72
|
-
}
|
|
73
|
-
if (element.disabled) {
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
element.click();
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
this.form?.requestSubmit();
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
connectedCallback() {
|
|
84
|
-
super.connectedCallback();
|
|
85
|
-
this._defaultValue = this.value ?? null;
|
|
86
|
-
this.internals.setFormValue(this._defaultValue);
|
|
87
|
-
}
|
|
88
|
-
updated(changedProperties) {
|
|
89
|
-
super.updated(changedProperties);
|
|
90
|
-
if (changedProperties.has('value')) {
|
|
91
|
-
this.internals.setFormValue(this.value ?? '');
|
|
92
|
-
if (this.control) {
|
|
93
|
-
this.control.value = this.value ?? '';
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
updateValidity() {
|
|
98
|
-
if (!this.control) {
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
if (this.control.checkValidity()) {
|
|
102
|
-
this.internals.setValidity({});
|
|
103
|
-
}
|
|
104
|
-
else {
|
|
105
|
-
this.internals.setValidity({ customError: true }, this.control.validationMessage, this.control);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
formResetCallback() {
|
|
109
|
-
this.internals.setFormValue(this._defaultValue);
|
|
110
|
-
const newValue = this._defaultValue ?? '';
|
|
111
|
-
this.control.value = newValue;
|
|
112
|
-
this.value = newValue;
|
|
113
|
-
this.updateValidity();
|
|
114
|
-
}
|
|
115
|
-
select() {
|
|
116
|
-
if (!this.disabled)
|
|
117
|
-
this.control.select();
|
|
118
|
-
}
|
|
119
|
-
get selectionStart() {
|
|
120
|
-
return this.control ? this.control.selectionStart : null;
|
|
121
|
-
}
|
|
122
|
-
set selectionStart(value) {
|
|
123
|
-
if (this.control && value !== null) {
|
|
124
|
-
this.control.selectionStart = value;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
get selectionEnd() {
|
|
128
|
-
return this.control ? this.control.selectionEnd : null;
|
|
129
|
-
}
|
|
130
|
-
set selectionEnd(value) {
|
|
131
|
-
if (this.control && value !== null) {
|
|
132
|
-
this.control.selectionEnd = value;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
setSelectionRange(start, end, direction) {
|
|
136
|
-
if (this.control) {
|
|
137
|
-
this.control.setSelectionRange(start, end, direction);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
checkValidity() {
|
|
141
|
-
return this.control.checkValidity();
|
|
142
|
-
}
|
|
143
|
-
reportValidity() {
|
|
144
|
-
return this.control.reportValidity();
|
|
145
|
-
}
|
|
146
|
-
setCustomValidity(message) {
|
|
147
|
-
this.control.setCustomValidity(message);
|
|
148
|
-
this.updateValidity();
|
|
149
|
-
}
|
|
150
|
-
render() {
|
|
151
|
-
const textfieldClasses = {
|
|
152
|
-
'sds-textfield': true,
|
|
153
|
-
'sds-textfield--error': Boolean(this.errorMessage),
|
|
154
|
-
'sds-textfield--has-icon': this.hasIcon,
|
|
155
|
-
};
|
|
156
|
-
const describedBy = [this.errorMessage ? 'error-message' : null, this.helpText ? 'help-text' : null].filter(Boolean).join(' ') || undefined;
|
|
157
|
-
const showLabel = this._hasSlottedLabel || Boolean(this.label);
|
|
158
|
-
return html `
|
|
159
|
-
<div class="${classMap(textfieldClasses)}">
|
|
160
|
-
<label for="sds-textfield" class="sds-textfield__label" ?hidden="${!showLabel}">
|
|
161
|
-
${this.readOnly ? html `<sds-icon name="lock-material-filled" size="m"></sds-icon>` : nothing}
|
|
162
|
-
<slot name="label" @slotchange="${this._handleLabelSlotChange}">${this.label}</slot>
|
|
163
|
-
</label>
|
|
164
|
-
${this.helpText ? html `<p id="help-text" class="sds-textfield__help-text">${this.helpText}</p>` : nothing}
|
|
165
|
-
<div class="sds-textfield__input-container">
|
|
166
|
-
<input
|
|
167
|
-
part="input"
|
|
168
|
-
class="sds-textfield__input"
|
|
169
|
-
type="${ifDefined(this.type)}"
|
|
170
|
-
id="sds-textfield"
|
|
171
|
-
?disabled="${this.disabled}"
|
|
172
|
-
?readonly="${this.readOnly}"
|
|
173
|
-
placeholder="${ifDefined(this.placeholder)}"
|
|
174
|
-
.value="${this.value ?? ''}"
|
|
175
|
-
name="${ifDefined(this.name)}"
|
|
176
|
-
autocomplete="${ifDefined(this.autocomplete)}"
|
|
177
|
-
?required="${this.required}"
|
|
178
|
-
pattern="${ifDefined(this.pattern)}"
|
|
179
|
-
min="${ifDefined(this.min)}"
|
|
180
|
-
minlength="${ifDefined(this.minlength)}"
|
|
181
|
-
max="${ifDefined(this.max)}"
|
|
182
|
-
maxlength="${ifDefined(this.maxlength)}"
|
|
183
|
-
aria-describedby="${ifDefined(describedBy)}"
|
|
184
|
-
aria-invalid="${this.errorMessage ? 'true' : 'false'}"
|
|
185
|
-
@input="${this._handleInputChange}"
|
|
186
|
-
@change="${this._handleInputChange}"
|
|
187
|
-
@select="${this._handleSelect}"
|
|
188
|
-
@focus="${this._handleFocus}"
|
|
189
|
-
@blur="${this._handleBlur}"
|
|
190
|
-
@keydown="${this._handleKeyDown}"
|
|
191
|
-
/>
|
|
192
|
-
<slot name="after" @slotchange="${this.handleSlotChange}" aria-hidden="true"></slot>
|
|
193
|
-
</div>
|
|
194
|
-
${this.errorMessage ? html `<sds-alert id="error-message" variant="secondary" data-palette="danger"><p slot="message">${this.errorMessage}</p></sds-alert>` : nothing}
|
|
195
|
-
</div>
|
|
196
|
-
`;
|
|
197
|
-
}
|
|
11
|
+
let SDSTextField = class SDSTextField extends SDSTextFieldComponent {
|
|
198
12
|
};
|
|
199
|
-
// Styling
|
|
200
|
-
SDSTextField.styles = [styles];
|
|
201
|
-
__decorate([
|
|
202
|
-
property({ type: String, reflect: true })
|
|
203
|
-
], SDSTextField.prototype, "type", void 0);
|
|
204
|
-
__decorate([
|
|
205
|
-
property({ type: String })
|
|
206
|
-
], SDSTextField.prototype, "value", void 0);
|
|
207
|
-
__decorate([
|
|
208
|
-
property({ type: String, reflect: true })
|
|
209
|
-
], SDSTextField.prototype, "label", void 0);
|
|
210
|
-
__decorate([
|
|
211
|
-
property({ type: String, reflect: true })
|
|
212
|
-
], SDSTextField.prototype, "placeholder", void 0);
|
|
213
|
-
__decorate([
|
|
214
|
-
property({ type: String, attribute: 'help-text', reflect: true })
|
|
215
|
-
], SDSTextField.prototype, "helpText", void 0);
|
|
216
|
-
__decorate([
|
|
217
|
-
property({ type: String, attribute: 'error-message', reflect: true })
|
|
218
|
-
], SDSTextField.prototype, "errorMessage", void 0);
|
|
219
|
-
__decorate([
|
|
220
|
-
property({ type: String, reflect: true })
|
|
221
|
-
], SDSTextField.prototype, "autocomplete", void 0);
|
|
222
|
-
__decorate([
|
|
223
|
-
property({ type: Boolean, reflect: true })
|
|
224
|
-
], SDSTextField.prototype, "required", void 0);
|
|
225
|
-
__decorate([
|
|
226
|
-
property({ type: String, reflect: true })
|
|
227
|
-
], SDSTextField.prototype, "pattern", void 0);
|
|
228
|
-
__decorate([
|
|
229
|
-
property({ type: Number, reflect: true })
|
|
230
|
-
], SDSTextField.prototype, "minlength", void 0);
|
|
231
|
-
__decorate([
|
|
232
|
-
property({ type: Number, reflect: true })
|
|
233
|
-
], SDSTextField.prototype, "maxlength", void 0);
|
|
234
|
-
__decorate([
|
|
235
|
-
property({ type: String, reflect: true })
|
|
236
|
-
], SDSTextField.prototype, "min", void 0);
|
|
237
|
-
__decorate([
|
|
238
|
-
property({ type: String, reflect: true })
|
|
239
|
-
], SDSTextField.prototype, "max", void 0);
|
|
240
|
-
__decorate([
|
|
241
|
-
property({ type: String, reflect: true })
|
|
242
|
-
], SDSTextField.prototype, "size", void 0);
|
|
243
|
-
__decorate([
|
|
244
|
-
state()
|
|
245
|
-
], SDSTextField.prototype, "hasIcon", void 0);
|
|
246
|
-
__decorate([
|
|
247
|
-
state()
|
|
248
|
-
], SDSTextField.prototype, "_hasSlottedLabel", void 0);
|
|
249
|
-
__decorate([
|
|
250
|
-
query('#sds-textfield')
|
|
251
|
-
], SDSTextField.prototype, "control", void 0);
|
|
252
13
|
SDSTextField = __decorate([
|
|
253
14
|
guardedCustomElement('sds-textfield')
|
|
254
15
|
], SDSTextField);
|