@sula-tech/webcomponents 0.12.0 → 0.13.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/dist/cjs/sula-avatar_21.cjs.entry.js +51 -15
- package/dist/cjs/sula-avatar_21.cjs.entry.js.map +1 -1
- package/dist/collection/components/sula-textfield/sula-textfield.js +56 -21
- package/dist/collection/components/sula-textfield/sula-textfield.js.map +1 -1
- package/dist/collection/components/sula-textfield/sula-textfield.stories.js +69 -5
- package/dist/collection/components/sula-textfield/sula-textfield.stories.js.map +1 -1
- package/dist/components/sula-textfield.js +51 -15
- package/dist/components/sula-textfield.js.map +1 -1
- package/dist/esm/sula-avatar_21.entry.js +51 -15
- package/dist/esm/sula-avatar_21.entry.js.map +1 -1
- package/dist/types/components/sula-textfield/sula-textfield.d.ts +9 -2
- package/dist/types/components/sula-textfield/sula-textfield.stories.d.ts +1 -0
- package/dist/types/components.d.ts +4 -6
- package/dist/webcomponents/{p-3c319b71.entry.js → p-f1a4d84f.entry.js} +66 -29
- package/dist/webcomponents/p-f1a4d84f.entry.js.map +1 -0
- package/dist/webcomponents/webcomponents.esm.js +1 -1
- package/package.json +1 -1
- package/dist/webcomponents/p-3c319b71.entry.js.map +0 -1
|
@@ -29045,10 +29045,6 @@ const SulaTextfield = class {
|
|
|
29045
29045
|
* The textfield status
|
|
29046
29046
|
*/
|
|
29047
29047
|
this.status = SulaTextfieldStatus.Default;
|
|
29048
|
-
/**
|
|
29049
|
-
* Max input length used to switch between the first and second mask pattern.
|
|
29050
|
-
*/
|
|
29051
|
-
this.maskPatternSwitchMaxLength = 14;
|
|
29052
29048
|
this.inputIsOpen = false;
|
|
29053
29049
|
this.textValue = '';
|
|
29054
29050
|
this.showPassword = false;
|
|
@@ -29167,13 +29163,13 @@ const SulaTextfield = class {
|
|
|
29167
29163
|
}
|
|
29168
29164
|
}
|
|
29169
29165
|
handleInputMask(inputValue) {
|
|
29170
|
-
var _a;
|
|
29166
|
+
var _a, _b;
|
|
29171
29167
|
if (!this.inputElement)
|
|
29172
29168
|
return;
|
|
29173
|
-
const
|
|
29169
|
+
const valueWithoutMask = ((_a = inputValue !== null && inputValue !== void 0 ? inputValue : this.inputElement.value) !== null && _a !== void 0 ? _a : '').replace(/[^a-zA-Z0-9]/g, '');
|
|
29170
|
+
const maskPattern = this.getMaskPatternByValueLength(valueWithoutMask, (_b = inputValue !== null && inputValue !== void 0 ? inputValue : this.inputElement.value) !== null && _b !== void 0 ? _b : '');
|
|
29174
29171
|
if (!maskPattern)
|
|
29175
29172
|
return;
|
|
29176
|
-
const valueWithoutMask = ((_a = inputValue !== null && inputValue !== void 0 ? inputValue : this.inputElement.value) !== null && _a !== void 0 ? _a : '').replace(/[^a-zA-Z0-9]/g, '');
|
|
29177
29173
|
VMasker(this.inputElement).unMask();
|
|
29178
29174
|
this.inputElement.value = VMasker.toPattern(valueWithoutMask, maskPattern);
|
|
29179
29175
|
}
|
|
@@ -29200,17 +29196,57 @@ const SulaTextfield = class {
|
|
|
29200
29196
|
}
|
|
29201
29197
|
return [];
|
|
29202
29198
|
}
|
|
29203
|
-
getMaskPatternByValueLength(inputValue) {
|
|
29204
|
-
var _a, _b, _c;
|
|
29199
|
+
getMaskPatternByValueLength(inputValue, rawInputValue) {
|
|
29205
29200
|
const patterns = this.getMaskPatterns();
|
|
29206
29201
|
if (patterns.length === 0)
|
|
29207
29202
|
return undefined;
|
|
29208
29203
|
if (patterns.length === 1)
|
|
29209
29204
|
return patterns[0];
|
|
29210
|
-
const currentValueLength = (
|
|
29211
|
-
const
|
|
29212
|
-
|
|
29213
|
-
|
|
29205
|
+
const currentValueLength = (inputValue !== null && inputValue !== void 0 ? inputValue : '').length;
|
|
29206
|
+
const providedSwitchLengths = this.normalizeProvidedSwitchLengths();
|
|
29207
|
+
if (providedSwitchLengths.length === 0) {
|
|
29208
|
+
return this.getMaskPatternByAutoInference(patterns, currentValueLength, rawInputValue);
|
|
29209
|
+
}
|
|
29210
|
+
for (let i = 0; i < providedSwitchLengths.length; i++) {
|
|
29211
|
+
if (currentValueLength <= providedSwitchLengths[i]) {
|
|
29212
|
+
return patterns[Math.min(i, patterns.length - 1)];
|
|
29213
|
+
}
|
|
29214
|
+
}
|
|
29215
|
+
return patterns[patterns.length - 1];
|
|
29216
|
+
}
|
|
29217
|
+
getMaskPatternByAutoInference(patterns, currentValueLength, rawInputValue) {
|
|
29218
|
+
const capacities = patterns.map(pattern => (pattern.match(/[9AS]/g) || []).length);
|
|
29219
|
+
const eligibleCapacities = capacities.filter(capacity => capacity >= currentValueLength && capacity > 0);
|
|
29220
|
+
if (eligibleCapacities.length === 0) {
|
|
29221
|
+
return patterns[patterns.length - 1];
|
|
29222
|
+
}
|
|
29223
|
+
const selectedCapacity = Math.min(...eligibleCapacities);
|
|
29224
|
+
const candidateIndexes = capacities
|
|
29225
|
+
.map((capacity, index) => ({ capacity, index }))
|
|
29226
|
+
.filter(item => item.capacity === selectedCapacity)
|
|
29227
|
+
.map(item => item.index);
|
|
29228
|
+
if (candidateIndexes.length === 1) {
|
|
29229
|
+
return patterns[candidateIndexes[0]];
|
|
29230
|
+
}
|
|
29231
|
+
const rawLiterals = (rawInputValue !== null && rawInputValue !== void 0 ? rawInputValue : '').replace(/[a-zA-Z0-9]/g, '');
|
|
29232
|
+
if (rawLiterals.length > 0) {
|
|
29233
|
+
for (const candidateIndex of candidateIndexes) {
|
|
29234
|
+
const patternLiterals = patterns[candidateIndex].replace(/[9AS]/g, '');
|
|
29235
|
+
if (patternLiterals === rawLiterals) {
|
|
29236
|
+
return patterns[candidateIndex];
|
|
29237
|
+
}
|
|
29238
|
+
}
|
|
29239
|
+
}
|
|
29240
|
+
return patterns[candidateIndexes[0]];
|
|
29241
|
+
}
|
|
29242
|
+
normalizeProvidedSwitchLengths() {
|
|
29243
|
+
if (Array.isArray(this.maskPatternSwitchMaxLength)) {
|
|
29244
|
+
return this.maskPatternSwitchMaxLength.filter(value => Number.isFinite(value) && value > 0).sort((a, b) => a - b);
|
|
29245
|
+
}
|
|
29246
|
+
if (typeof this.maskPatternSwitchMaxLength === 'number' && Number.isFinite(this.maskPatternSwitchMaxLength) && this.maskPatternSwitchMaxLength > 0) {
|
|
29247
|
+
return [this.maskPatternSwitchMaxLength];
|
|
29248
|
+
}
|
|
29249
|
+
return [];
|
|
29214
29250
|
}
|
|
29215
29251
|
handlePasswordIconClicked() {
|
|
29216
29252
|
const cursorPosition = this.inputElement.selectionStart;
|
|
@@ -29230,14 +29266,14 @@ const SulaTextfield = class {
|
|
|
29230
29266
|
return this.icon;
|
|
29231
29267
|
}
|
|
29232
29268
|
render() {
|
|
29233
|
-
return (index.h(index.Host, { key: '
|
|
29269
|
+
return (index.h(index.Host, { key: '0dbf51792e5bdc43328820106b083d194bbcae61', ref: node => (this.node = node) }, index.h("div", { key: '3659f51f5a9d0c75909e6a6939b8ff1b5c25e377' }, index.h("div", { key: '320da879fdea605e95525f54607c9cb285446133', id: "button-container", class: {
|
|
29234
29270
|
'flex items-center border rounded-sm px-16 outline-none h-[72px] caret-brand-primary': true,
|
|
29235
29271
|
'flex-row justify-between': !!this.icon || this.type === SulaTextfieldType.Password,
|
|
29236
29272
|
'button-focus': this.inputIsFocused && !this.disabled && this.status === SulaTextfieldStatus.Default,
|
|
29237
29273
|
'button-error': this.status === SulaTextfieldStatus.Error && !this.disabled,
|
|
29238
29274
|
'bg-states-bg-disabled border-line-general cursor-not-allowed': this.disabled,
|
|
29239
29275
|
'bg-surface-body border-line-input cursor-pointer': !this.disabled,
|
|
29240
|
-
}, tabIndex: 0, onFocus: this.handleFocus, onClick: this.handleInputClick }, !this.disabled && (index.h("div", { key: '
|
|
29276
|
+
}, tabIndex: 0, onFocus: this.handleFocus, onClick: this.handleInputClick }, !this.disabled && (index.h("div", { key: '44777180c60bb9a21ef64cffd98f465cf15af446', class: { 'hidden flex-col w-full': true, 'pr-12': !!this.icon }, ref: node => (this.inputContainer = node) }, index.h("label", { key: '75bc3b05a66ed7c00915842b275faf657b1784b3', class: "font-bold text-sm text-text-primary from-down" }, this.label), index.h("input", { key: '4f6bde78c385dc3c158c08be70f2277e56f7ab95', type: this.type, ref: node => (this.inputElement = node), placeholder: this.placeholder, class: "outline-none text-base text-text-primary bg-transparent", onInput: this.handleInputChanges, onFocus: this.handleInputFocus, value: this.textValue }))), index.h("div", { key: 'df7e84e77d3d05ba0328f736e6c03f45d32c9c76', id: "textfield-label", class: { 'text-base flex items-center': true, 'text-text-primary': !this.disabled, 'text-text-disabled': this.disabled }, ref: node => (this.labelElement = node) }, this.label), (!!this.icon || this.type === SulaTextfieldType.Password) && (index.h("div", { key: '55dba31d1ca9d6b213900b9a2d3aa02044b246ef', class: "flex items-center justify-center", onClick: this.handleIconClick }, index.h("sula-icon", { key: '19712e5575abb7aaef17a098de13543ed550dc6c', icon: this.getInputIcon(), customClass: `text-2xl ${this.disabled ? 'text-icon-disabled' : 'text-icon-primary'}` })))), (this.helpText || this.maxLength) && !this.disabled && (index.h("div", { key: '0c68e89181316ffed13f212a5c7f6ba78372e83c', class: "flex justify-between items-center px-16 mt-4 text-sm" }, this.helpText && (index.h("div", { key: 'af970054750c28cb8a9901fcf850c7c02fd059b9', id: "textfield-help-text", class: { 'text-text-primary': this.status === SulaTextfieldStatus.Default, 'text-feedback-error': this.status === SulaTextfieldStatus.Error } }, this.helpText)), this.maxLength && (index.h("div", { key: 'e78a661c6c614d2d6787159137cce01bf129e2c2', id: "max-length-container", class: { 'text-text-primary': this.status === SulaTextfieldStatus.Default, 'text-feedback-error': this.status === SulaTextfieldStatus.Error } }, this.textValue ? this.textValue.length : 0, "/", this.maxLength)))))));
|
|
29241
29277
|
}
|
|
29242
29278
|
static get watchers() { return {
|
|
29243
29279
|
"value": ["watchValueHandler"],
|