@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.
@@ -52,9 +52,14 @@ export declare class SulaTextfield {
52
52
  */
53
53
  maskPattern?: string | string[];
54
54
  /**
55
- * Max input length used to switch between the first and second mask pattern.
55
+ * Optional manual switch lengths used to switch between mask patterns.
56
+ * If not provided, switch lengths are automatically inferred from `maskPattern`.
57
+ *
58
+ * - When number: switches between first and second pattern at this length
59
+ * - When array: defines multiple switch points for multiple patterns
60
+ * Example: [11, 14] means 0-11 uses first pattern, 12-14 uses second, 15+ uses third
56
61
  */
57
- maskPatternSwitchMaxLength: number;
62
+ maskPatternSwitchMaxLength?: number | number[];
58
63
  /**
59
64
  * Event emitted when input is focused.
60
65
  */
@@ -90,6 +95,8 @@ export declare class SulaTextfield {
90
95
  private hasMaskPatternConfigured;
91
96
  private getMaskPatterns;
92
97
  private getMaskPatternByValueLength;
98
+ private getMaskPatternByAutoInference;
99
+ private normalizeProvidedSwitchLengths;
93
100
  handlePasswordIconClicked(): void;
94
101
  getInputIcon(): string;
95
102
  render(): any;
@@ -126,6 +126,7 @@ export default _default;
126
126
  export declare const Default: any;
127
127
  export declare const WithMask: any;
128
128
  export declare const WithCpfCnpjMask: any;
129
+ export declare const WithMultipleMasks: any;
129
130
  export declare const WithValue: any;
130
131
  export declare const WithHelpText: any;
131
132
  export declare const WithMaxLength: any;
@@ -538,10 +538,9 @@ export namespace Components {
538
538
  */
539
539
  "maskPattern"?: string | string[];
540
540
  /**
541
- * Max input length used to switch between the first and second mask pattern.
542
- * @default 14
541
+ * Optional manual switch lengths used to switch between mask patterns. If not provided, switch lengths are automatically inferred from `maskPattern`. - When number: switches between first and second pattern at this length - When array: defines multiple switch points for multiple patterns Example: [11, 14] means 0-11 uses first pattern, 12-14 uses second, 15+ uses third
543
542
  */
544
- "maskPatternSwitchMaxLength": number;
543
+ "maskPatternSwitchMaxLength"?: number | number[];
545
544
  /**
546
545
  * The textfield max length
547
546
  */
@@ -1628,10 +1627,9 @@ declare namespace LocalJSX {
1628
1627
  */
1629
1628
  "maskPattern"?: string | string[];
1630
1629
  /**
1631
- * Max input length used to switch between the first and second mask pattern.
1632
- * @default 14
1630
+ * Optional manual switch lengths used to switch between mask patterns. If not provided, switch lengths are automatically inferred from `maskPattern`. - When number: switches between first and second pattern at this length - When array: defines multiple switch points for multiple patterns Example: [11, 14] means 0-11 uses first pattern, 12-14 uses second, 15+ uses third
1633
1631
  */
1634
- "maskPatternSwitchMaxLength"?: number;
1632
+ "maskPatternSwitchMaxLength"?: number | number[];
1635
1633
  /**
1636
1634
  * The textfield max length
1637
1635
  */
@@ -22500,9 +22500,6 @@ const SulaTextfield = class {
22500
22500
  /**
22501
22501
  * The textfield status
22502
22502
  */ this.status = SulaTextfieldStatus.Default;
22503
- /**
22504
- * Max input length used to switch between the first and second mask pattern.
22505
- */ this.maskPatternSwitchMaxLength = 14;
22506
22503
  this.inputIsOpen = false;
22507
22504
  this.textValue = "";
22508
22505
  this.showPassword = false;
@@ -22616,13 +22613,13 @@ const SulaTextfield = class {
22616
22613
  }
22617
22614
  }
22618
22615
  handleInputMask(e) {
22619
- var t;
22616
+ var t, o;
22620
22617
  if (!this.inputElement) return;
22621
- const o = this.getMaskPatternByValueLength(e);
22622
- if (!o) return;
22623
22618
  const r = ((t = e !== null && e !== void 0 ? e : this.inputElement.value) !== null && t !== void 0 ? t : "").replace(/[^a-zA-Z0-9]/g, "");
22619
+ const n = this.getMaskPatternByValueLength(r, (o = e !== null && e !== void 0 ? e : this.inputElement.value) !== null && o !== void 0 ? o : "");
22620
+ if (!n) return;
22624
22621
  VMasker(this.inputElement).unMask();
22625
- this.inputElement.value = VMasker.toPattern(r, o);
22622
+ this.inputElement.value = VMasker.toPattern(r, n);
22626
22623
  }
22627
22624
  syncMaskState() {
22628
22625
  if (!this.inputElement) return;
@@ -22646,15 +22643,55 @@ const SulaTextfield = class {
22646
22643
  }
22647
22644
  return [];
22648
22645
  }
22649
- getMaskPatternByValueLength(e) {
22650
- var t, o, r;
22651
- const n = this.getMaskPatterns();
22652
- if (n.length === 0) return undefined;
22653
- if (n.length === 1) return n[0];
22654
- const a = ((o = e !== null && e !== void 0 ? e : (t = this.inputElement) === null || t === void 0 ? void 0 : t.value) !== null && o !== void 0 ? o : "").length;
22655
- const i = (r = this.maskPatternSwitchMaxLength) !== null && r !== void 0 ? r : 14;
22656
- const c = a > i ? 1 : 0;
22657
- return n[Math.min(c, n.length - 1)];
22646
+ getMaskPatternByValueLength(e, t) {
22647
+ const o = this.getMaskPatterns();
22648
+ if (o.length === 0) return undefined;
22649
+ if (o.length === 1) return o[0];
22650
+ const r = (e !== null && e !== void 0 ? e : "").length;
22651
+ const n = this.normalizeProvidedSwitchLengths();
22652
+ if (n.length === 0) {
22653
+ return this.getMaskPatternByAutoInference(o, r, t);
22654
+ }
22655
+ for (let e = 0; e < n.length; e++) {
22656
+ if (r <= n[e]) {
22657
+ return o[Math.min(e, o.length - 1)];
22658
+ }
22659
+ }
22660
+ return o[o.length - 1];
22661
+ }
22662
+ getMaskPatternByAutoInference(e, t, o) {
22663
+ const r = e.map((e => (e.match(/[9AS]/g) || []).length));
22664
+ const n = r.filter((e => e >= t && e > 0));
22665
+ if (n.length === 0) {
22666
+ return e[e.length - 1];
22667
+ }
22668
+ const a = Math.min(...n);
22669
+ const i = r.map(((e, t) => ({
22670
+ capacity: e,
22671
+ index: t
22672
+ }))).filter((e => e.capacity === a)).map((e => e.index));
22673
+ if (i.length === 1) {
22674
+ return e[i[0]];
22675
+ }
22676
+ const c = (o !== null && o !== void 0 ? o : "").replace(/[a-zA-Z0-9]/g, "");
22677
+ if (c.length > 0) {
22678
+ for (const t of i) {
22679
+ const o = e[t].replace(/[9AS]/g, "");
22680
+ if (o === c) {
22681
+ return e[t];
22682
+ }
22683
+ }
22684
+ }
22685
+ return e[i[0]];
22686
+ }
22687
+ normalizeProvidedSwitchLengths() {
22688
+ if (Array.isArray(this.maskPatternSwitchMaxLength)) {
22689
+ return this.maskPatternSwitchMaxLength.filter((e => Number.isFinite(e) && e > 0)).sort(((e, t) => e - t));
22690
+ }
22691
+ if (typeof this.maskPatternSwitchMaxLength === "number" && Number.isFinite(this.maskPatternSwitchMaxLength) && this.maskPatternSwitchMaxLength > 0) {
22692
+ return [ this.maskPatternSwitchMaxLength ];
22693
+ }
22694
+ return [];
22658
22695
  }
22659
22696
  handlePasswordIconClicked() {
22660
22697
  const e = this.inputElement.selectionStart;
@@ -22675,12 +22712,12 @@ const SulaTextfield = class {
22675
22712
  }
22676
22713
  render() {
22677
22714
  return h$1(Host, {
22678
- key: "b857d08cc9d53c1cfaa87a573d52026b9b72d088",
22715
+ key: "0dbf51792e5bdc43328820106b083d194bbcae61",
22679
22716
  ref: e => this.node = e
22680
22717
  }, h$1("div", {
22681
- key: "d173e497fbe8c78b899a1e66784d411981008abb"
22718
+ key: "3659f51f5a9d0c75909e6a6939b8ff1b5c25e377"
22682
22719
  }, h$1("div", {
22683
- key: "bc1682f30d7ffb0eb890baba6d126d3cdbaf3a20",
22720
+ key: "320da879fdea605e95525f54607c9cb285446133",
22684
22721
  id: "button-container",
22685
22722
  class: {
22686
22723
  "flex items-center border rounded-sm px-16 outline-none h-[72px] caret-brand-primary": true,
@@ -22694,17 +22731,17 @@ const SulaTextfield = class {
22694
22731
  onFocus: this.handleFocus,
22695
22732
  onClick: this.handleInputClick
22696
22733
  }, !this.disabled && h$1("div", {
22697
- key: "7e78f2a5b2d0bd3111ddfec6a592d907ac1aa078",
22734
+ key: "44777180c60bb9a21ef64cffd98f465cf15af446",
22698
22735
  class: {
22699
22736
  "hidden flex-col w-full": true,
22700
22737
  "pr-12": !!this.icon
22701
22738
  },
22702
22739
  ref: e => this.inputContainer = e
22703
22740
  }, h$1("label", {
22704
- key: "d0419a71fb3372d34b07625acd95bae71b1133a0",
22741
+ key: "75bc3b05a66ed7c00915842b275faf657b1784b3",
22705
22742
  class: "font-bold text-sm text-text-primary from-down"
22706
22743
  }, this.label), h$1("input", {
22707
- key: "11926def24206e02e0fcd0e4ba7b94664f1ca21a",
22744
+ key: "4f6bde78c385dc3c158c08be70f2277e56f7ab95",
22708
22745
  type: this.type,
22709
22746
  ref: e => this.inputElement = e,
22710
22747
  placeholder: this.placeholder,
@@ -22713,7 +22750,7 @@ const SulaTextfield = class {
22713
22750
  onFocus: this.handleInputFocus,
22714
22751
  value: this.textValue
22715
22752
  })), h$1("div", {
22716
- key: "93118f3270d2f325dd474805ed6870cb1cddb2bd",
22753
+ key: "df7e84e77d3d05ba0328f736e6c03f45d32c9c76",
22717
22754
  id: "textfield-label",
22718
22755
  class: {
22719
22756
  "text-base flex items-center": true,
@@ -22722,25 +22759,25 @@ const SulaTextfield = class {
22722
22759
  },
22723
22760
  ref: e => this.labelElement = e
22724
22761
  }, this.label), (!!this.icon || this.type === SulaTextfieldType.Password) && h$1("div", {
22725
- key: "bc78873f12cd069f1987dddbfd9eea29f5c07c8e",
22762
+ key: "55dba31d1ca9d6b213900b9a2d3aa02044b246ef",
22726
22763
  class: "flex items-center justify-center",
22727
22764
  onClick: this.handleIconClick
22728
22765
  }, h$1("sula-icon", {
22729
- key: "f8a30c1ea8f73e748ce43b4f0029a83435e88d2b",
22766
+ key: "19712e5575abb7aaef17a098de13543ed550dc6c",
22730
22767
  icon: this.getInputIcon(),
22731
22768
  customClass: `text-2xl ${this.disabled ? "text-icon-disabled" : "text-icon-primary"}`
22732
22769
  }))), (this.helpText || this.maxLength) && !this.disabled && h$1("div", {
22733
- key: "e6cc2bed4087a75fe8ed2541af38e44778144485",
22770
+ key: "0c68e89181316ffed13f212a5c7f6ba78372e83c",
22734
22771
  class: "flex justify-between items-center px-16 mt-4 text-sm"
22735
22772
  }, this.helpText && h$1("div", {
22736
- key: "ed826977d2f85c23c4e41c51bab2a35a093d4207",
22773
+ key: "af970054750c28cb8a9901fcf850c7c02fd059b9",
22737
22774
  id: "textfield-help-text",
22738
22775
  class: {
22739
22776
  "text-text-primary": this.status === SulaTextfieldStatus.Default,
22740
22777
  "text-feedback-error": this.status === SulaTextfieldStatus.Error
22741
22778
  }
22742
22779
  }, this.helpText), this.maxLength && h$1("div", {
22743
- key: "595dd29e865d45bcc1df11dc024eb1c9db77e990",
22780
+ key: "e78a661c6c614d2d6787159137cce01bf129e2c2",
22744
22781
  id: "max-length-container",
22745
22782
  class: {
22746
22783
  "text-text-primary": this.status === SulaTextfieldStatus.Default,
@@ -23031,4 +23068,4 @@ SulaTimelineList.style = sulaTimelineListCss;
23031
23068
 
23032
23069
  export { SulaAvatar as sula_avatar, SulaBadge as sula_badge, SulaBreadcrumb as sula_breadcrumb, SulaButton as sula_button, SulaCheckbox as sula_checkbox, SulaChip as sula_chip, SulaDropdown as sula_dropdown, SulaIcon as sula_icon, SulaLoader as sula_loader, SulaMenuSelectList as sula_menu_select_list, SulaModal as sula_modal, SulaProgressBar as sula_progress_bar, SulaRadioButton as sula_radio_button, SulaSearchBar as sula_search_bar, SulaSegmentedControl as sula_segmented_control, SulaSwitch as sula_switch, SulaTag as sula_tag, SulaTextarea as sula_textarea, SulaTextfield as sula_textfield, SulaTiles as sula_tiles, SulaTimelineList as sula_timeline_list };
23033
23070
  //# sourceMappingURL=sula-avatar.sula-badge.sula-breadcrumb.sula-button.sula-checkbox.sula-chip.sula-dropdown.sula-icon.sula-loader.sula-menu-select-list.sula-modal.sula-progress-bar.sula-radio-button.sula-search-bar.sula-segmented-control.sula-switch.sula-tag.sula-textarea.sula-textfield.sula-tiles.sula-timeline-list.entry.esm.js.map
23034
- //# sourceMappingURL=p-3c319b71.entry.js.map
23071
+ //# sourceMappingURL=p-f1a4d84f.entry.js.map