@sula-tech/webcomponents 0.11.3 → 0.12.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/loader.cjs.js +1 -1
- package/dist/cjs/sula-avatar_21.cjs.entry.js +84 -18
- package/dist/cjs/sula-avatar_21.cjs.entry.js.map +1 -1
- package/dist/cjs/webcomponents.cjs.js +1 -1
- package/dist/collection/components/sula-textfield/sula-textfield.css +1 -1
- package/dist/collection/components/sula-textfield/sula-textfield.js +122 -18
- package/dist/collection/components/sula-textfield/sula-textfield.js.map +1 -1
- package/dist/collection/components/sula-textfield/sula-textfield.stories.js +28 -1
- package/dist/collection/components/sula-textfield/sula-textfield.stories.js.map +1 -1
- package/dist/components/sula-textfield.js +88 -19
- package/dist/components/sula-textfield.js.map +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/sula-avatar_21.entry.js +84 -18
- package/dist/esm/sula-avatar_21.entry.js.map +1 -1
- package/dist/esm/webcomponents.js +1 -1
- package/dist/types/components/sula-textfield/sula-textfield.d.ts +16 -2
- package/dist/types/components/sula-textfield/sula-textfield.stories.d.ts +13 -0
- package/dist/types/components.d.ts +17 -2
- package/dist/webcomponents/{p-0749814d.entry.js → p-3c319b71.entry.js} +92 -32
- package/dist/webcomponents/p-3c319b71.entry.js.map +1 -0
- package/dist/webcomponents/webcomponents.esm.js +9 -6
- package/package.json +1 -1
- package/dist/webcomponents/p-0749814d.entry.js.map +0 -1
|
@@ -18,7 +18,7 @@ var patchBrowser = () => {
|
|
|
18
18
|
|
|
19
19
|
patchBrowser().then(async (options) => {
|
|
20
20
|
await index.globalScripts();
|
|
21
|
-
return index.bootstrapLazy([["sula-avatar_21.cjs",[[1,"sula-modal",{"opened":[1028],"blockBodyScroll":[1028,"block-body-scroll"],"closeOnClickOutside":[1028,"close-on-click-outside"],"type":[1],"headerIcon":[1,"header-icon"],"modalTitle":[1,"modal-title"],"promoImage":[1,"promo-image"],"subTitle":[1,"sub-title"],"primaryButtonText":[1,"primary-button-text"],"secondaryButtonText":[1,"secondary-button-text"],"slotOverflow":[1,"slot-overflow"],"isAnimating":[32],"shouldRender":[32]},null,{"opened":["handleOpenedChange"]}],[1,"sula-chip",{"text":[1025],"appearance":[1025],"disabled":[1028],"items":[1040],"selected":[1028],"isFocused":[32],"showItems":[32]},[[4,"click","handleDocumentClick"]]],[1,"sula-dropdown",{"label":[1025],"disabled":[1028],"items":[1040],"value":[1040],"searchable":[516],"menuMaxHeight":[2,"menu-max-height"],"selectedItem":[32],"showItems":[32],"isFocused":[32],"searchTerm":[32],"filteredItems":[32],"openUpward":[32]},[[4,"click","handleDocumentClick"],[9,"resize","handleWindowResize"]],{"value":["handleValueChange"],"showItems":["handleShowItemsChange"]}],[1,"sula-avatar",{"size":[1],"imageUrl":[1,"image-url"],"text":[1],"icon":[1]}],[1,"sula-badge",{"status":[1025],"size":[1025],"type":[1025],"text":[1025],"icon":[1025],"hasSlotContent":[32]}],[1,"sula-breadcrumb",{"items":[1040]}],[1,"sula-checkbox",{"type":[1025],"label":[1025],"subTitle":[1025,"sub-title"],"disabled":[1028],"checked":[1028],"isFocus":[32]}],[1,"sula-progress-bar",{"appearance":[1025],"state":[1025],"topLabel":[1025,"top-label"],"bottomLabel":[1025,"bottom-label"],"progress":[1026],"showProgress":[1028,"show-progress"]},null,{"progress":["validateProgress"]}],[1,"sula-search-bar",{"value":[1025],"searchBarStyle":[1025,"search-bar-style"],"placeholder":[1025],"leftIcon":[1025,"left-icon"],"rightIcon":[1025,"right-icon"],"isFocused":[32],"textValue":[32]}],[1,"sula-segmented-control",{"items":[1040],"type":[1025],"size":[1025],"color":[1025]}],[1,"sula-tag",{"label":[1025],"icon":[1025],"iconStatus":[1025,"icon-status"],"size":[1025],"appearance":[1025],"fontWeight":[1025,"font-weight"]}],[1,"sula-textfield",{"value":[1025],"type":[1],"status":[1025],"label":[1],"placeholder":[1],"disabled":[1028],"helpText":[1,"help-text"],"maxLength":[2,"max-length"],"icon":[1],"maskPattern":[1,"mask-pattern"],"inputIsOpen":[32],"textValue":[32],"showPassword":[32],"inputIsFocused":[32]},[[4,"click","handleClick"]],{"value":["watchValueHandler"]}],[1,"sula-tiles",{"type":[1],"size":[1],"ellipsis":[4],"icon":[1],"text":[1],"subText":[1,"sub-text"],"disabled":[4]}],[1,"sula-timeline-list",{"sulaTimelineList":[1040,"sula-timeline-list"]}],[1,"sula-radio-button",{"checked":[1028],"label":[1025],"disabled":[1028],"radioIsFocus":[32]}],[1,"sula-switch",{"type":[1025],"active":[1028],"disabled":[1028],"label":[1025],"subTitle":[1025,"sub-title"],"responsive":[4],"isFocus":[32]}],[1,"sula-textarea",{"value":[1025],"status":[1025],"label":[1],"placeholder":[1],"disabled":[1028],"helpText":[1,"help-text"],"maxLength":[2,"max-length"],"rows":[2],"isActive":[32],"textValue":[32],"textareaIsFocused":[32],"labelPadding":[32]},[[4,"click","handleClick"]],{"value":["watchValueHandler"]}],[1,"sula-button",{"text":[1025],"icon":[1025],"leftIcon":[1025,"left-icon"],"rightIcon":[1025,"right-icon"],"appearance":[1025],"type":[1025],"size":[1025],"status":[1025],"loading":[1028],"buttonDisabled":[1028,"button-disabled"],"fullWidth":[1028,"full-width"]}],[1,"sula-loader",{"size":[1],"animationInstance":[32]}],[1,"sula-menu-select-list",{"items":[1040],"fullWidth":[4,"full-width"],"maxHeight":[2,"max-height"],"selectedValue":[16,"selected-value"]}],[0,"sula-icon",{"icon":[1],"customClass":[1,"custom-class"]}]]]], options);
|
|
21
|
+
return index.bootstrapLazy([["sula-avatar_21.cjs",[[1,"sula-modal",{"opened":[1028],"blockBodyScroll":[1028,"block-body-scroll"],"closeOnClickOutside":[1028,"close-on-click-outside"],"type":[1],"headerIcon":[1,"header-icon"],"modalTitle":[1,"modal-title"],"promoImage":[1,"promo-image"],"subTitle":[1,"sub-title"],"primaryButtonText":[1,"primary-button-text"],"secondaryButtonText":[1,"secondary-button-text"],"slotOverflow":[1,"slot-overflow"],"isAnimating":[32],"shouldRender":[32]},null,{"opened":["handleOpenedChange"]}],[1,"sula-chip",{"text":[1025],"appearance":[1025],"disabled":[1028],"items":[1040],"selected":[1028],"isFocused":[32],"showItems":[32]},[[4,"click","handleDocumentClick"]]],[1,"sula-dropdown",{"label":[1025],"disabled":[1028],"items":[1040],"value":[1040],"searchable":[516],"menuMaxHeight":[2,"menu-max-height"],"selectedItem":[32],"showItems":[32],"isFocused":[32],"searchTerm":[32],"filteredItems":[32],"openUpward":[32]},[[4,"click","handleDocumentClick"],[9,"resize","handleWindowResize"]],{"value":["handleValueChange"],"showItems":["handleShowItemsChange"]}],[1,"sula-avatar",{"size":[1],"imageUrl":[1,"image-url"],"text":[1],"icon":[1]}],[1,"sula-badge",{"status":[1025],"size":[1025],"type":[1025],"text":[1025],"icon":[1025],"hasSlotContent":[32]}],[1,"sula-breadcrumb",{"items":[1040]}],[1,"sula-checkbox",{"type":[1025],"label":[1025],"subTitle":[1025,"sub-title"],"disabled":[1028],"checked":[1028],"isFocus":[32]}],[1,"sula-progress-bar",{"appearance":[1025],"state":[1025],"topLabel":[1025,"top-label"],"bottomLabel":[1025,"bottom-label"],"progress":[1026],"showProgress":[1028,"show-progress"]},null,{"progress":["validateProgress"]}],[1,"sula-search-bar",{"value":[1025],"searchBarStyle":[1025,"search-bar-style"],"placeholder":[1025],"leftIcon":[1025,"left-icon"],"rightIcon":[1025,"right-icon"],"isFocused":[32],"textValue":[32]}],[1,"sula-segmented-control",{"items":[1040],"type":[1025],"size":[1025],"color":[1025]}],[1,"sula-tag",{"label":[1025],"icon":[1025],"iconStatus":[1025,"icon-status"],"size":[1025],"appearance":[1025],"fontWeight":[1025,"font-weight"]}],[1,"sula-textfield",{"value":[1025],"type":[1],"status":[1025],"label":[1],"placeholder":[1],"disabled":[1028],"helpText":[1,"help-text"],"maxLength":[2,"max-length"],"icon":[1],"maskPattern":[1,"mask-pattern"],"maskPatternSwitchMaxLength":[2,"mask-pattern-switch-max-length"],"inputIsOpen":[32],"textValue":[32],"showPassword":[32],"inputIsFocused":[32]},[[4,"click","handleClick"]],{"value":["watchValueHandler"],"maskPattern":["watchMaskPatternHandler"],"maskPatternSwitchMaxLength":["watchMaskPatternSwitchMaxLengthHandler"]}],[1,"sula-tiles",{"type":[1],"size":[1],"ellipsis":[4],"icon":[1],"text":[1],"subText":[1,"sub-text"],"disabled":[4]}],[1,"sula-timeline-list",{"sulaTimelineList":[1040,"sula-timeline-list"]}],[1,"sula-radio-button",{"checked":[1028],"label":[1025],"disabled":[1028],"radioIsFocus":[32]}],[1,"sula-switch",{"type":[1025],"active":[1028],"disabled":[1028],"label":[1025],"subTitle":[1025,"sub-title"],"responsive":[4],"isFocus":[32]}],[1,"sula-textarea",{"value":[1025],"status":[1025],"label":[1],"placeholder":[1],"disabled":[1028],"helpText":[1,"help-text"],"maxLength":[2,"max-length"],"rows":[2],"isActive":[32],"textValue":[32],"textareaIsFocused":[32],"labelPadding":[32]},[[4,"click","handleClick"]],{"value":["watchValueHandler"]}],[1,"sula-button",{"text":[1025],"icon":[1025],"leftIcon":[1025,"left-icon"],"rightIcon":[1025,"right-icon"],"appearance":[1025],"type":[1025],"size":[1025],"status":[1025],"loading":[1028],"buttonDisabled":[1028,"button-disabled"],"fullWidth":[1028,"full-width"]}],[1,"sula-loader",{"size":[1],"animationInstance":[32]}],[1,"sula-menu-select-list",{"items":[1040],"fullWidth":[4,"full-width"],"maxHeight":[2,"max-height"],"selectedValue":[16,"selected-value"]}],[0,"sula-icon",{"icon":[1],"customClass":[1,"custom-class"]}]]]], options);
|
|
22
22
|
});
|
|
23
23
|
|
|
24
24
|
exports.setNonce = index.setNonce;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
*,:after,:before{--tw-ring-color:rgba(59,130,246,.5);--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(147,197,253,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: ;border:0 solid #e5e7eb;box-sizing:border-box}::backdrop{--tw-ring-color:rgba(59,130,246,.5);--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(147,197,253,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }/*! tailwindcss v3.4.17 | MIT License | https://tailwindcss.com*/:after,:before{--tw-content:""}:host,html{-webkit-text-size-adjust:100%;font-feature-settings:normal;-webkit-tap-highlight-color:transparent;font-family:ui-sans-serif,system-ui,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-variation-settings:normal;line-height:1.5;-moz-tab-size:4;tab-size:4}body{line-height:inherit;margin:0}hr{border-top-width:1px;color:inherit;height:0}abbr:where([title]){text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-feature-settings:normal;font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:1em;font-variation-settings:normal}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{border-collapse:collapse;border-color:inherit;text-indent:0}button,input,optgroup,select,textarea{font-feature-settings:inherit;color:inherit;font-family:inherit;font-size:100%;font-variation-settings:inherit;font-weight:inherit;letter-spacing:inherit;line-height:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,fieldset,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::placeholder,textarea::placeholder{color:#9ca3af;opacity:1}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{height:auto;max-width:100%}[hidden]:where(:not([hidden=until-found])){display:none}.block{display:block}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.outline{outline-style:solid}:host{display:block}.button-focus{outline:2px solid var(--color-feedback-informational)!important;outline-offset:2px!important}.button-error{outline:2px solid var(--color-feedback-error)!important;outline-offset:2px!important}.from-down{animation:from-down .2s ease-in-out}.from-up{animation:from-up .2s ease-in-out}@keyframes from-down{0%{opacity:0;transform:translateY(75%)}to{opacity:1;transform:translateY(0)}}@keyframes from-up{0%{opacity:0;transform:translateY(-75%)}to{opacity:1;transform:translateY(0)}}:root{--color-green-50:#f1f9f4;--color-green-100:#e6f4ed;--color-green-200:#cae7d8;--color-green-300:#a0d4b8;--color-green-400:#68bb8e;--color-green-500:#04843f;--color-green-600:#037236;--color-green-700:#03632f;--color-green-800:#035428;--color-green-900:#024521;--color-green-950:#012b15;--color-red-50:#fef6f6;--color-red-100:#fde8e8;--color-red-200:#fad1d1;--color-red-300:#f7abab;--color-red-400:#f17474;--color-red-500:#c80505;--color-red-600:#b30404;--color-red-700:#9f0404;--color-red-800:#860303;--color-red-900:#6d0303;--color-red-950:#330d00;--color-yellow-50:#fdf4e7;--color-yellow-100:#fcedd9;--color-yellow-200:#fae0bd;--color-yellow-300:#f6c788;--color-yellow-400:#f3b159;--color-yellow-500:#ef9928;--color-yellow-600:#e49226;--color-yellow-700:#d17e10;--color-yellow-800:#b46d0e;--color-yellow-900:#93590b;--color-yellow-950:#402705;--color-orange-50:#fef4f1;--color-orange-100:#fde8e2;--color-orange-200:#fbd2c6;--color-orange-300:#f8b4a0;--color-orange-400:#f58e70;--color-orange-500:#f05223;--color-orange-600:#ea4210;--color-orange-700:#d23b0e;--color-orange-800:#b5330c;--color-orange-900:#942a0a;--color-orange-950:#401204;--color-blue-50:#ecf0f9;--color-blue-100:#dde3f4;--color-blue-200:#b2c2e5;--color-blue-300:#7994d2;--color-blue-400:#4066bf;--color-blue-500:#001e64;--color-blue-600:#001c5c;--color-blue-700:#00174c;--color-blue-800:#00123d;--color-blue-900:#000f33;--color-blue-950:#000d2b;--color-ambar-50:#fff6eb;--color-ambar-100:#ffefdc;--color-ambar-200:#fedfb9;--color-ambar-300:#fdca8b;--color-ambar-400:#fdb359;--color-ambar-500:#fc9c26;--color-ambar-600:#ec8403;--color-ambar-700:#d87803;--color-ambar-800:#ba6803;--color-ambar-900:#975402;--color-ambar-950:#402301;--color-gray-50:#fff;--color-gray-100:#f3f4f4;--color-gray-200:#e5e6e6;--color-gray-300:#bfc0c0;--color-gray-400:#acaeae;--color-gray-500:#949595;--color-gray-600:#737575;--color-gray-700:#6c6e6e;--color-gray-800:#313333;--color-gray-900:#272929;--color-gray-950:#191d1d;--color-white-opacity-50:#ffffff0d;--color-white-opacity-100:#ffffff1a;--color-white-opacity-200:#ffffff26;--color-white-opacity-300:#ffffff45;--color-white-opacity-400:#ffffff5c;--color-white-opacity-500:#ffffff80;--color-white-opacity-600:#ffffff8c;--color-white-opacity-700:#ffffffa3;--color-white-opacity-800:#ffffffba;--color-white-opacity-900:#fffc;--color-white-opacity-950:#ffffffe8;--color-ciano-50:#f1f6fe;--color-ciano-100:#dfeafc;--color-ciano-200:#c3d9f9;--color-ciano-300:#90b9f4;--color-ciano-400:#5d98ee;--color-ciano-500:#1769e0;--color-ciano-600:#155fcb;--color-ciano-700:#1355b4;--color-ciano-800:#104899;--color-ciano-900:#0d3b7d;--color-ciano-950:#071e40;--color-extra-color-blue-light:#e7f0f4;--color-extra-color-blue-dark:#162931;--color-black-opacity-50:rgba(25,29,29,.02);--color-black-opacity-100:rgba(25,29,29,.05);--color-black-opacity-200:rgba(25,29,29,.11);--color-black-opacity-300:rgba(25,29,29,.28);--color-black-opacity-400:rgba(25,29,29,.36);--color-black-opacity-500:rgba(25,29,29,.44);--color-black-opacity-600:rgba(25,29,29,.62);--color-black-opacity-700:rgba(25,29,29,.64);--color-black-opacity-800:rgba(25,29,29,.72);--color-black-opacity-900:rgba(25,29,29,.8);--color-black-opacity-950:rgba(25,29,29,.96);--color-shadow-opacity-50:rgba(0,0,0,.04);--color-shadow-opacity-100:rgba(0,0,0,.06);--color-shadow-opacity-200:rgba(0,0,0,.12);--color-shadow-opacity-300:rgba(0,0,0,.2);--color-shadow-opacity-400:rgba(0,0,0,.32);--color-shadow-opacity-500:rgba(0,0,0,.5);--color-shadow-opacity-600:rgba(0,0,0,.55);--color-shadow-opacity-700:rgba(0,0,0,.64);--color-shadow-opacity-800:rgba(0,0,0,.73);--color-shadow-opacity-900:rgba(0,0,0,.8);--color-shadow-opacity-950:rgba(0,0,0,.91);--color-feedback-success:#04843f;--color-feedback-error:#c80505;--color-feedback-informational:#1355b4;--color-feedback-alert:#ef9928;--color-brand-primary:#f05223;--color-brand-secondary:#001c5c;--color-brand-tertiary-1:#1769e0;--color-brand-tertiary-2:#fc9c26;--color-surface-body:#fff;--color-surface-on-body:#f3f4f4;--color-surface-on-body-blue:#e7f0f4;--color-surface-on-body-brand:#fff6eb;--color-surface-on-body-feedback-success:#e6f4ed;--color-surface-on-body-feedback-error:#fde8e8;--color-surface-on-body-feedback-alert:#fdf4e7;--color-surface-on-body-feedback-info:#dfeafc;--color-text-brand:#f05223;--color-text-primary:#313333;--color-text-secondary:#6c6e6e;--color-text-disabled:#949595;--color-text-link:#1355b4;--color-states-empty-bg-hover:rgba(25,29,29,.05);--color-states-empty-bg-pressed:rgba(25,29,29,.11);--color-states-bg-disabled:rgba(25,29,29,.02);--color-states-bg-focus:#1355b4;--color-states-primary-hover:#ea4210;--color-states-primary-pressed:#d23b0e;--color-states-danger-hover:#b30404;--color-states-danger-pressed:#9f0404;--color-states-negative-hover:#e5e6e6;--color-states-negative-pressed:#bfc0c0;--color-icon-primary:#6c6e6e;--color-icon-secondary:#fff;--color-icon-tertiary:#b30404;--color-icon-disabled:#acaeae;--color-neutral-neutral-1:#fff;--color-neutral-neutral-2:#f3f4f4;--color-neutral-neutral-3:#acaeae;--color-neutral-neutral-4:#949595;--color-neutral-neutral-5:#737575;--color-neutral-neutral-6:#6c6e6e;--color-neutral-neutral-7:#313333;--color-neutral-neutral-8:#272929;--color-negative-negative-1:#fff;--color-negative-negative-2:#313333;--color-opacity-body:#fffc;--color-opacity-on-body:rgba(25,29,29,.02);--color-opacity-overlay:rgba(25,29,29,.62);--color-opacity-on-overlay:#ffffff1a;--color-line-input:#949595;--color-line-general-strong:#bfc0c0;--color-line-general:#e5e6e6;--color-line-hair:rgba(25,29,29,.05);--color-box-shadow-body:#fff;--color-box-shadow-shadow-color-1:rgba(0,0,0,.04);--color-box-shadow-shadow-color-2:rgba(0,0,0,.06)}.static{position:static}.mt-4{margin-top:.25rem}.flex{display:flex}.hidden{display:none}.h-\[72px\]{height:72px}.w-full{width:100%}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.flex-row{flex-direction:row}.flex-col{flex-direction:column}.items-center{align-items:center}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.rounded-sm{border-radius:.75rem}.border{border-width:1px}.border-line-general{border-color:var(--color-line-general)}.border-line-input{border-color:var(--color-line-input)}.bg-states-bg-disabled{background-color:var(--color-states-bg-disabled)}.bg-surface-body{background-color:var(--color-surface-body)}.bg-transparent{background-color:transparent}.px-16{padding-left:1rem;padding-right:1rem}.pr-12{padding-right:.75rem}.text-2xl{font-size:1.5rem;line-height:2rem}.text-base{font-size:1rem;line-height:1.5rem}.text-sm{font-size:.875rem;line-height:1.25rem}.font-bold{font-weight:700}.text-feedback-error{color:var(--color-feedback-error)}.text-icon-disabled{color:var(--color-icon-disabled)}.text-icon-primary{color:var(--color-icon-primary)}.text-text-disabled{color:var(--color-text-disabled)}.text-text-primary{color:var(--color-text-primary)}.caret-brand-primary{caret-color:var(--color-brand-primary)}.shadow{--tw-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px -1px rgba(0,0,0,.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color),0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.outline-none{outline:2px solid transparent;outline-offset:2px}
|
|
1
|
+
*,:after,:before{--tw-ring-color:rgba(59,130,246,.5);--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(147,197,253,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: ;border:0 solid #e5e7eb;box-sizing:border-box}::backdrop{--tw-ring-color:rgba(59,130,246,.5);--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:rgba(147,197,253,.5);--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }/*! tailwindcss v3.4.17 | MIT License | https://tailwindcss.com*/:after,:before{--tw-content:""}:host,html{-webkit-text-size-adjust:100%;font-feature-settings:normal;-webkit-tap-highlight-color:transparent;font-family:ui-sans-serif,system-ui,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-variation-settings:normal;line-height:1.5;-moz-tab-size:4;tab-size:4}body{line-height:inherit;margin:0}hr{border-top-width:1px;color:inherit;height:0}abbr:where([title]){text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-feature-settings:normal;font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:1em;font-variation-settings:normal}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{border-collapse:collapse;border-color:inherit;text-indent:0}button,input,optgroup,select,textarea{font-feature-settings:inherit;color:inherit;font-family:inherit;font-size:100%;font-variation-settings:inherit;font-weight:inherit;letter-spacing:inherit;line-height:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,fieldset,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::placeholder,textarea::placeholder{color:#9ca3af;opacity:1}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{height:auto;max-width:100%}[hidden]:where(:not([hidden=until-found])){display:none}.block{display:block}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.outline{outline-style:solid}:host{display:block}.button-focus{outline:2px solid var(--color-feedback-informational)!important;outline-offset:2px!important}.button-error{outline:2px solid var(--color-feedback-error)!important;outline-offset:2px!important}.from-down{animation:from-down .2s ease-in-out}.from-up{animation:from-up .2s ease-in-out}@keyframes from-down{0%{opacity:0;transform:translateY(75%)}to{opacity:1;transform:translateY(0)}}@keyframes from-up{0%{opacity:0;transform:translateY(-75%)}to{opacity:1;transform:translateY(0)}}:root{--color-green-50:#f1f9f4;--color-green-100:#e6f4ed;--color-green-200:#cae7d8;--color-green-300:#a0d4b8;--color-green-400:#68bb8e;--color-green-500:#04843f;--color-green-600:#037236;--color-green-700:#03632f;--color-green-800:#035428;--color-green-900:#024521;--color-green-950:#012b15;--color-red-50:#fef6f6;--color-red-100:#fde8e8;--color-red-200:#fad1d1;--color-red-300:#f7abab;--color-red-400:#f17474;--color-red-500:#c80505;--color-red-600:#b30404;--color-red-700:#9f0404;--color-red-800:#860303;--color-red-900:#6d0303;--color-red-950:#330d00;--color-yellow-50:#fdf4e7;--color-yellow-100:#fcedd9;--color-yellow-200:#fae0bd;--color-yellow-300:#f6c788;--color-yellow-400:#f3b159;--color-yellow-500:#ef9928;--color-yellow-600:#e49226;--color-yellow-700:#d17e10;--color-yellow-800:#b46d0e;--color-yellow-900:#93590b;--color-yellow-950:#402705;--color-orange-50:#fef4f1;--color-orange-100:#fde8e2;--color-orange-200:#fbd2c6;--color-orange-300:#f8b4a0;--color-orange-400:#f58e70;--color-orange-500:#f05223;--color-orange-600:#ea4210;--color-orange-700:#d23b0e;--color-orange-800:#b5330c;--color-orange-900:#942a0a;--color-orange-950:#401204;--color-blue-50:#ecf0f9;--color-blue-100:#dde3f4;--color-blue-200:#b2c2e5;--color-blue-300:#7994d2;--color-blue-400:#4066bf;--color-blue-500:#001e64;--color-blue-600:#001c5c;--color-blue-700:#00174c;--color-blue-800:#00123d;--color-blue-900:#000f33;--color-blue-950:#000d2b;--color-ambar-50:#fff6eb;--color-ambar-100:#ffefdc;--color-ambar-200:#fedfb9;--color-ambar-300:#fdca8b;--color-ambar-400:#fdb359;--color-ambar-500:#fc9c26;--color-ambar-600:#ec8403;--color-ambar-700:#d87803;--color-ambar-800:#ba6803;--color-ambar-900:#975402;--color-ambar-950:#402301;--color-gray-50:#fff;--color-gray-100:#f3f4f4;--color-gray-200:#e5e6e6;--color-gray-300:#bfc0c0;--color-gray-400:#acaeae;--color-gray-500:#949595;--color-gray-600:#737575;--color-gray-700:#6c6e6e;--color-gray-800:#313333;--color-gray-900:#272929;--color-gray-950:#191d1d;--color-white-opacity-50:#ffffff0d;--color-white-opacity-100:#ffffff1a;--color-white-opacity-200:#ffffff26;--color-white-opacity-300:#ffffff45;--color-white-opacity-400:#ffffff5c;--color-white-opacity-500:#ffffff80;--color-white-opacity-600:#ffffff8c;--color-white-opacity-700:#ffffffa3;--color-white-opacity-800:#ffffffba;--color-white-opacity-900:#fffc;--color-white-opacity-950:#ffffffe8;--color-ciano-50:#f1f6fe;--color-ciano-100:#dfeafc;--color-ciano-200:#c3d9f9;--color-ciano-300:#90b9f4;--color-ciano-400:#5d98ee;--color-ciano-500:#1769e0;--color-ciano-600:#155fcb;--color-ciano-700:#1355b4;--color-ciano-800:#104899;--color-ciano-900:#0d3b7d;--color-ciano-950:#071e40;--color-extra-color-blue-light:#e7f0f4;--color-extra-color-blue-dark:#162931;--color-black-opacity-50:rgba(25,29,29,.02);--color-black-opacity-100:rgba(25,29,29,.05);--color-black-opacity-200:rgba(25,29,29,.11);--color-black-opacity-300:rgba(25,29,29,.28);--color-black-opacity-400:rgba(25,29,29,.36);--color-black-opacity-500:rgba(25,29,29,.44);--color-black-opacity-600:rgba(25,29,29,.62);--color-black-opacity-700:rgba(25,29,29,.64);--color-black-opacity-800:rgba(25,29,29,.72);--color-black-opacity-900:rgba(25,29,29,.8);--color-black-opacity-950:rgba(25,29,29,.96);--color-shadow-opacity-50:rgba(0,0,0,.04);--color-shadow-opacity-100:rgba(0,0,0,.06);--color-shadow-opacity-200:rgba(0,0,0,.12);--color-shadow-opacity-300:rgba(0,0,0,.2);--color-shadow-opacity-400:rgba(0,0,0,.32);--color-shadow-opacity-500:rgba(0,0,0,.5);--color-shadow-opacity-600:rgba(0,0,0,.55);--color-shadow-opacity-700:rgba(0,0,0,.64);--color-shadow-opacity-800:rgba(0,0,0,.73);--color-shadow-opacity-900:rgba(0,0,0,.8);--color-shadow-opacity-950:rgba(0,0,0,.91);--color-feedback-success:#04843f;--color-feedback-error:#c80505;--color-feedback-informational:#1355b4;--color-feedback-alert:#ef9928;--color-brand-primary:#f05223;--color-brand-secondary:#001c5c;--color-brand-tertiary-1:#1769e0;--color-brand-tertiary-2:#fc9c26;--color-surface-body:#fff;--color-surface-on-body:#f3f4f4;--color-surface-on-body-blue:#e7f0f4;--color-surface-on-body-brand:#fff6eb;--color-surface-on-body-feedback-success:#e6f4ed;--color-surface-on-body-feedback-error:#fde8e8;--color-surface-on-body-feedback-alert:#fdf4e7;--color-surface-on-body-feedback-info:#dfeafc;--color-text-brand:#f05223;--color-text-primary:#313333;--color-text-secondary:#6c6e6e;--color-text-disabled:#949595;--color-text-link:#1355b4;--color-states-empty-bg-hover:rgba(25,29,29,.05);--color-states-empty-bg-pressed:rgba(25,29,29,.11);--color-states-bg-disabled:rgba(25,29,29,.02);--color-states-bg-focus:#1355b4;--color-states-primary-hover:#ea4210;--color-states-primary-pressed:#d23b0e;--color-states-danger-hover:#b30404;--color-states-danger-pressed:#9f0404;--color-states-negative-hover:#e5e6e6;--color-states-negative-pressed:#bfc0c0;--color-icon-primary:#6c6e6e;--color-icon-secondary:#fff;--color-icon-tertiary:#b30404;--color-icon-disabled:#acaeae;--color-neutral-neutral-1:#fff;--color-neutral-neutral-2:#f3f4f4;--color-neutral-neutral-3:#acaeae;--color-neutral-neutral-4:#949595;--color-neutral-neutral-5:#737575;--color-neutral-neutral-6:#6c6e6e;--color-neutral-neutral-7:#313333;--color-neutral-neutral-8:#272929;--color-negative-negative-1:#fff;--color-negative-negative-2:#313333;--color-opacity-body:#fffc;--color-opacity-on-body:rgba(25,29,29,.02);--color-opacity-overlay:rgba(25,29,29,.62);--color-opacity-on-overlay:#ffffff1a;--color-line-input:#949595;--color-line-general-strong:#bfc0c0;--color-line-general:#e5e6e6;--color-line-hair:rgba(25,29,29,.05);--color-box-shadow-body:#fff;--color-box-shadow-shadow-color-1:rgba(0,0,0,.04);--color-box-shadow-shadow-color-2:rgba(0,0,0,.06)}.static{position:static}.mt-4{margin-top:.25rem}.flex{display:flex}.hidden{display:none}.h-\[72px\]{height:72px}.w-full{width:100%}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.flex-row{flex-direction:row}.flex-col{flex-direction:column}.items-center{align-items:center}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.rounded-sm{border-radius:.75rem}.border{border-width:1px}.border-line-general{border-color:var(--color-line-general)}.border-line-input{border-color:var(--color-line-input)}.bg-states-bg-disabled{background-color:var(--color-states-bg-disabled)}.bg-surface-body{background-color:var(--color-surface-body)}.bg-transparent{background-color:transparent}.px-16{padding-left:1rem;padding-right:1rem}.pr-12{padding-right:.75rem}.text-2xl{font-size:1.5rem;line-height:2rem}.text-base{font-size:1rem;line-height:1.5rem}.text-sm{font-size:.875rem;line-height:1.25rem}.font-bold{font-weight:700}.text-feedback-error{color:var(--color-feedback-error)}.text-icon-disabled{color:var(--color-icon-disabled)}.text-icon-primary{color:var(--color-icon-primary)}.text-text-disabled{color:var(--color-text-disabled)}.text-text-primary{color:var(--color-text-primary)}.caret-brand-primary{caret-color:var(--color-brand-primary)}.shadow{--tw-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px -1px rgba(0,0,0,.1);--tw-shadow-colored:0 1px 3px 0 var(--tw-shadow-color),0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.outline-none{outline:2px solid transparent;outline-offset:2px}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}
|
|
@@ -11,6 +11,10 @@ export class SulaTextfield {
|
|
|
11
11
|
* The textfield status
|
|
12
12
|
*/
|
|
13
13
|
this.status = SulaTextfieldStatus.Default;
|
|
14
|
+
/**
|
|
15
|
+
* Max input length used to switch between the first and second mask pattern.
|
|
16
|
+
*/
|
|
17
|
+
this.maskPatternSwitchMaxLength = 14;
|
|
14
18
|
this.inputIsOpen = false;
|
|
15
19
|
this.textValue = '';
|
|
16
20
|
this.showPassword = false;
|
|
@@ -19,13 +23,16 @@ export class SulaTextfield {
|
|
|
19
23
|
this.toggleOptions(true);
|
|
20
24
|
};
|
|
21
25
|
this.handleInputChanges = (event) => {
|
|
22
|
-
if (this.maskPattern && this.inputElement) {
|
|
23
|
-
this.handleInputMask();
|
|
24
|
-
}
|
|
25
26
|
const newValue = event.target.value;
|
|
26
|
-
|
|
27
|
-
this.
|
|
28
|
-
|
|
27
|
+
let valueToPersist = newValue;
|
|
28
|
+
if (this.hasMaskPatternConfigured() && this.inputElement) {
|
|
29
|
+
this.handleInputMask(newValue);
|
|
30
|
+
valueToPersist = this.inputElement.value;
|
|
31
|
+
}
|
|
32
|
+
this.valueChangedWithoutMask.emit(valueToPersist.replace(/\D/g, ''));
|
|
33
|
+
this.textValue = valueToPersist;
|
|
34
|
+
this.value = valueToPersist;
|
|
35
|
+
this.valueChanged.emit(valueToPersist);
|
|
29
36
|
};
|
|
30
37
|
this.handleFocus = () => {
|
|
31
38
|
if (this.disabled)
|
|
@@ -50,16 +57,21 @@ export class SulaTextfield {
|
|
|
50
57
|
};
|
|
51
58
|
}
|
|
52
59
|
watchValueHandler(newValue) {
|
|
53
|
-
|
|
54
|
-
|
|
60
|
+
const normalizedValue = newValue || '';
|
|
61
|
+
this.textValue = normalizedValue;
|
|
62
|
+
if (this.inputElement && this.inputElement.value !== normalizedValue) {
|
|
55
63
|
const cursorPosition = this.inputElement.selectionStart;
|
|
56
|
-
this.inputElement.value =
|
|
64
|
+
this.inputElement.value = normalizedValue;
|
|
65
|
+
if (this.hasMaskPatternConfigured()) {
|
|
66
|
+
this.handleInputMask(normalizedValue);
|
|
67
|
+
this.textValue = this.inputElement.value;
|
|
68
|
+
}
|
|
57
69
|
if (this.inputIsFocused && cursorPosition !== null) {
|
|
58
|
-
const newPosition = Math.min(cursorPosition,
|
|
70
|
+
const newPosition = Math.min(cursorPosition, this.inputElement.value.length);
|
|
59
71
|
this.inputElement.setSelectionRange(newPosition, newPosition);
|
|
60
72
|
}
|
|
61
73
|
}
|
|
62
|
-
if (
|
|
74
|
+
if (this.textValue && this.textValue.trim().length > 0) {
|
|
63
75
|
this.inputIsOpen = true;
|
|
64
76
|
this.changeElementsStyle();
|
|
65
77
|
}
|
|
@@ -68,6 +80,12 @@ export class SulaTextfield {
|
|
|
68
80
|
this.changeElementsStyle();
|
|
69
81
|
}
|
|
70
82
|
}
|
|
83
|
+
watchMaskPatternHandler() {
|
|
84
|
+
this.syncMaskState();
|
|
85
|
+
}
|
|
86
|
+
watchMaskPatternSwitchMaxLengthHandler() {
|
|
87
|
+
this.syncMaskState();
|
|
88
|
+
}
|
|
71
89
|
handleClick(event) {
|
|
72
90
|
if (!this.node || !this.inputIsFocused)
|
|
73
91
|
return;
|
|
@@ -92,8 +110,10 @@ export class SulaTextfield {
|
|
|
92
110
|
if (this.textValue && this.textValue.trim().length > 0) {
|
|
93
111
|
this.changeElementsStyle();
|
|
94
112
|
}
|
|
95
|
-
if (this.
|
|
113
|
+
if (this.hasMaskPatternConfigured() && this.inputElement) {
|
|
96
114
|
this.handleInputMask();
|
|
115
|
+
this.textValue = this.inputElement.value;
|
|
116
|
+
this.value = this.inputElement.value;
|
|
97
117
|
}
|
|
98
118
|
}
|
|
99
119
|
toggleOptions(inputIsOpen) {
|
|
@@ -112,8 +132,51 @@ export class SulaTextfield {
|
|
|
112
132
|
this.labelElement.classList.add('from-up');
|
|
113
133
|
}
|
|
114
134
|
}
|
|
115
|
-
handleInputMask() {
|
|
116
|
-
|
|
135
|
+
handleInputMask(inputValue) {
|
|
136
|
+
var _a;
|
|
137
|
+
if (!this.inputElement)
|
|
138
|
+
return;
|
|
139
|
+
const maskPattern = this.getMaskPatternByValueLength(inputValue);
|
|
140
|
+
if (!maskPattern)
|
|
141
|
+
return;
|
|
142
|
+
const valueWithoutMask = ((_a = inputValue !== null && inputValue !== void 0 ? inputValue : this.inputElement.value) !== null && _a !== void 0 ? _a : '').replace(/[^a-zA-Z0-9]/g, '');
|
|
143
|
+
VMasker(this.inputElement).unMask();
|
|
144
|
+
this.inputElement.value = VMasker.toPattern(valueWithoutMask, maskPattern);
|
|
145
|
+
}
|
|
146
|
+
syncMaskState() {
|
|
147
|
+
if (!this.inputElement)
|
|
148
|
+
return;
|
|
149
|
+
if (!this.hasMaskPatternConfigured()) {
|
|
150
|
+
VMasker(this.inputElement).unMask();
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
this.handleInputMask();
|
|
154
|
+
this.textValue = this.inputElement.value;
|
|
155
|
+
this.value = this.inputElement.value;
|
|
156
|
+
}
|
|
157
|
+
hasMaskPatternConfigured() {
|
|
158
|
+
return this.getMaskPatterns().length > 0;
|
|
159
|
+
}
|
|
160
|
+
getMaskPatterns() {
|
|
161
|
+
if (Array.isArray(this.maskPattern)) {
|
|
162
|
+
return this.maskPattern.map(pattern => pattern === null || pattern === void 0 ? void 0 : pattern.trim()).filter(Boolean);
|
|
163
|
+
}
|
|
164
|
+
if (typeof this.maskPattern === 'string' && this.maskPattern.trim().length > 0) {
|
|
165
|
+
return [this.maskPattern.trim()];
|
|
166
|
+
}
|
|
167
|
+
return [];
|
|
168
|
+
}
|
|
169
|
+
getMaskPatternByValueLength(inputValue) {
|
|
170
|
+
var _a, _b, _c;
|
|
171
|
+
const patterns = this.getMaskPatterns();
|
|
172
|
+
if (patterns.length === 0)
|
|
173
|
+
return undefined;
|
|
174
|
+
if (patterns.length === 1)
|
|
175
|
+
return patterns[0];
|
|
176
|
+
const currentValueLength = ((_b = inputValue !== null && inputValue !== void 0 ? inputValue : (_a = this.inputElement) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : '').length;
|
|
177
|
+
const switchMaxLength = (_c = this.maskPatternSwitchMaxLength) !== null && _c !== void 0 ? _c : 14;
|
|
178
|
+
const selectedIndex = currentValueLength > switchMaxLength ? 1 : 0;
|
|
179
|
+
return patterns[Math.min(selectedIndex, patterns.length - 1)];
|
|
117
180
|
}
|
|
118
181
|
handlePasswordIconClicked() {
|
|
119
182
|
const cursorPosition = this.inputElement.selectionStart;
|
|
@@ -133,14 +196,14 @@ export class SulaTextfield {
|
|
|
133
196
|
return this.icon;
|
|
134
197
|
}
|
|
135
198
|
render() {
|
|
136
|
-
return (h(Host, { key: '
|
|
199
|
+
return (h(Host, { key: 'b857d08cc9d53c1cfaa87a573d52026b9b72d088', ref: node => (this.node = node) }, h("div", { key: 'd173e497fbe8c78b899a1e66784d411981008abb' }, h("div", { key: 'bc1682f30d7ffb0eb890baba6d126d3cdbaf3a20', id: "button-container", class: {
|
|
137
200
|
'flex items-center border rounded-sm px-16 outline-none h-[72px] caret-brand-primary': true,
|
|
138
201
|
'flex-row justify-between': !!this.icon || this.type === SulaTextfieldType.Password,
|
|
139
202
|
'button-focus': this.inputIsFocused && !this.disabled && this.status === SulaTextfieldStatus.Default,
|
|
140
203
|
'button-error': this.status === SulaTextfieldStatus.Error && !this.disabled,
|
|
141
204
|
'bg-states-bg-disabled border-line-general cursor-not-allowed': this.disabled,
|
|
142
205
|
'bg-surface-body border-line-input cursor-pointer': !this.disabled,
|
|
143
|
-
}, tabIndex: 0, onFocus: this.handleFocus, onClick: this.handleInputClick }, !this.disabled && (h("div", { key: '
|
|
206
|
+
}, tabIndex: 0, onFocus: this.handleFocus, onClick: this.handleInputClick }, !this.disabled && (h("div", { key: '7e78f2a5b2d0bd3111ddfec6a592d907ac1aa078', class: { 'hidden flex-col w-full': true, 'pr-12': !!this.icon }, ref: node => (this.inputContainer = node) }, h("label", { key: 'd0419a71fb3372d34b07625acd95bae71b1133a0', class: "font-bold text-sm text-text-primary from-down" }, this.label), h("input", { key: '11926def24206e02e0fcd0e4ba7b94664f1ca21a', 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 }))), h("div", { key: '93118f3270d2f325dd474805ed6870cb1cddb2bd', 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) && (h("div", { key: 'bc78873f12cd069f1987dddbfd9eea29f5c07c8e', class: "flex items-center justify-center", onClick: this.handleIconClick }, h("sula-icon", { key: 'f8a30c1ea8f73e748ce43b4f0029a83435e88d2b', icon: this.getInputIcon(), customClass: `text-2xl ${this.disabled ? 'text-icon-disabled' : 'text-icon-primary'}` })))), (this.helpText || this.maxLength) && !this.disabled && (h("div", { key: 'e6cc2bed4087a75fe8ed2541af38e44778144485', class: "flex justify-between items-center px-16 mt-4 text-sm" }, this.helpText && (h("div", { key: 'ed826977d2f85c23c4e41c51bab2a35a093d4207', id: "textfield-help-text", class: { 'text-text-primary': this.status === SulaTextfieldStatus.Default, 'text-feedback-error': this.status === SulaTextfieldStatus.Error } }, this.helpText)), this.maxLength && (h("div", { key: '595dd29e865d45bcc1df11dc024eb1c9db77e990', 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)))))));
|
|
144
207
|
}
|
|
145
208
|
static get is() { return "sula-textfield"; }
|
|
146
209
|
static get encapsulation() { return "shadow"; }
|
|
@@ -346,8 +409,8 @@ export class SulaTextfield {
|
|
|
346
409
|
"attribute": "mask-pattern",
|
|
347
410
|
"mutable": false,
|
|
348
411
|
"complexType": {
|
|
349
|
-
"original": "string",
|
|
350
|
-
"resolved": "string",
|
|
412
|
+
"original": "string | string[]",
|
|
413
|
+
"resolved": "string | string[]",
|
|
351
414
|
"references": {}
|
|
352
415
|
},
|
|
353
416
|
"required": false,
|
|
@@ -359,6 +422,26 @@ export class SulaTextfield {
|
|
|
359
422
|
"getter": false,
|
|
360
423
|
"setter": false,
|
|
361
424
|
"reflect": false
|
|
425
|
+
},
|
|
426
|
+
"maskPatternSwitchMaxLength": {
|
|
427
|
+
"type": "number",
|
|
428
|
+
"attribute": "mask-pattern-switch-max-length",
|
|
429
|
+
"mutable": false,
|
|
430
|
+
"complexType": {
|
|
431
|
+
"original": "number",
|
|
432
|
+
"resolved": "number",
|
|
433
|
+
"references": {}
|
|
434
|
+
},
|
|
435
|
+
"required": false,
|
|
436
|
+
"optional": false,
|
|
437
|
+
"docs": {
|
|
438
|
+
"tags": [],
|
|
439
|
+
"text": "Max input length used to switch between the first and second mask pattern."
|
|
440
|
+
},
|
|
441
|
+
"getter": false,
|
|
442
|
+
"setter": false,
|
|
443
|
+
"reflect": false,
|
|
444
|
+
"defaultValue": "14"
|
|
362
445
|
}
|
|
363
446
|
};
|
|
364
447
|
}
|
|
@@ -386,6 +469,21 @@ export class SulaTextfield {
|
|
|
386
469
|
"resolved": "string",
|
|
387
470
|
"references": {}
|
|
388
471
|
}
|
|
472
|
+
}, {
|
|
473
|
+
"method": "valueChangedWithoutMask",
|
|
474
|
+
"name": "valueChangedWithoutMask",
|
|
475
|
+
"bubbles": true,
|
|
476
|
+
"cancelable": true,
|
|
477
|
+
"composed": true,
|
|
478
|
+
"docs": {
|
|
479
|
+
"tags": [],
|
|
480
|
+
"text": "Event emitted when input value changes without mask pattern applied."
|
|
481
|
+
},
|
|
482
|
+
"complexType": {
|
|
483
|
+
"original": "string",
|
|
484
|
+
"resolved": "string",
|
|
485
|
+
"references": {}
|
|
486
|
+
}
|
|
389
487
|
}, {
|
|
390
488
|
"method": "focusedOn",
|
|
391
489
|
"name": "focusedOn",
|
|
@@ -422,6 +520,12 @@ export class SulaTextfield {
|
|
|
422
520
|
return [{
|
|
423
521
|
"propName": "value",
|
|
424
522
|
"methodName": "watchValueHandler"
|
|
523
|
+
}, {
|
|
524
|
+
"propName": "maskPattern",
|
|
525
|
+
"methodName": "watchMaskPatternHandler"
|
|
526
|
+
}, {
|
|
527
|
+
"propName": "maskPatternSwitchMaxLength",
|
|
528
|
+
"methodName": "watchMaskPatternSwitchMaxLengthHandler"
|
|
425
529
|
}];
|
|
426
530
|
}
|
|
427
531
|
static get listeners() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sula-textfield.js","sourceRoot":"","sources":["../../../src/components/sula-textfield/sula-textfield.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAgB,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AACpG,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACtF,OAAO,OAAO,MAAM,gBAAgB,CAAC;AAOrC,MAAM,OAAO,aAAa;IAL1B;QAYE;;WAEG;QACK,SAAI,GAAsB,iBAAiB,CAAC,IAAI,CAAC;QAEzD;;WAEG;QACsB,WAAM,GAAwB,mBAAmB,CAAC,OAAO,CAAC;QA2DnF,gBAAW,GAAG,KAAK,CAAC;QAGpB,cAAS,GAAW,EAAE,CAAC;QAGvB,iBAAY,GAAG,KAAK,CAAC;QAGrB,mBAAc,GAAG,KAAK,CAAC;QAkEvB,qBAAgB,GAAG,GAAG,EAAE;YACtB,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;Q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P;oBACA,IAAI,CAAC,SAAS,IAAI,CACjB,4DACE,EAAE,EAAC,sBAAsB,EACzB,KAAK,EAAE,EAAE,mBAAmB,EAAE,IAAI,CAAC,MAAM,KAAK,mBAAmB,CAAC,OAAO,EAAE,qBAAqB,EAAE,IAAI,CAAC,MAAM,KAAK,mBAAmB,CAAC,KAAK,EAAE;wBAE5I,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;;wBAAG,IAAI,CAAC,SAAS,CACxD,CACP,CACG,CACP,CACG,CACD,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Event, EventEmitter, Host, Listen, Prop, State, Watch, h } from '@stencil/core';\nimport { SulaTextfieldStatus, SulaTextfieldType } from './model/sula-textfield.model';\nimport VMasker from 'vanilla-masker';\n\n@Component({\n tag: 'sula-textfield',\n styleUrl: 'sula-textfield.scss',\n shadow: true,\n})\nexport class SulaTextfield {\n /**\n * Value for the input.\n */\n @Prop({ mutable: true })\n value?: string;\n\n /**\n * The textfield type\n */\n @Prop() type: SulaTextfieldType = SulaTextfieldType.Text;\n\n /**\n * The textfield status\n */\n @Prop({ mutable: true }) status: SulaTextfieldStatus = SulaTextfieldStatus.Default;\n\n /**\n * The textfield label\n */\n @Prop() label: string;\n\n /**\n * The textfield placeholder\n */\n @Prop() placeholder: string;\n\n /**\n * The textfield is disabled\n */\n @Prop({ mutable: true }) disabled: boolean;\n\n /**\n * The help text for textfield\n */\n @Prop() helpText?: string;\n\n /**\n * The textfield max length\n */\n @Prop() maxLength?: number;\n\n /**\n * The textfield icon\n */\n @Prop() icon?: string;\n\n /**\n * Event emitted when input value changes.\n */\n @Event()\n valueChanged: EventEmitter<string>;\n\n /**\n * The textfield mask pattern\n * The mask pattern should follow the VMasker pattern format\n * More info: https://github.com/vanilla-masker/vanilla-masker?tab=readme-ov-file#custom-pattern\n */\n @Prop()\n maskPattern?: string;\n\n /**\n * Event emitted when input is focused.\n */\n @Event()\n focusedOn: EventEmitter<void>;\n\n /**\n * Event emitted when input is focused out.\n */\n @Event()\n focusedOut: EventEmitter<void>;\n\n @State()\n inputIsOpen = false;\n\n @State()\n textValue: string = '';\n\n @State()\n showPassword = false;\n\n @State()\n inputIsFocused = false;\n\n @Watch('value')\n watchValueHandler(newValue: string) {\n this.textValue = newValue;\n\n if (this.inputElement && this.inputElement.value !== newValue) {\n const cursorPosition = this.inputElement.selectionStart;\n this.inputElement.value = newValue || '';\n\n if (this.inputIsFocused && cursorPosition !== null) {\n const newPosition = Math.min(cursorPosition, (newValue || '').length);\n this.inputElement.setSelectionRange(newPosition, newPosition);\n }\n }\n\n if (newValue && newValue.trim().length > 0) {\n this.inputIsOpen = true;\n this.changeElementsStyle();\n } else if (!this.inputIsFocused) {\n this.inputIsOpen = false;\n this.changeElementsStyle();\n }\n }\n\n inputContainer: HTMLDivElement;\n inputElement: HTMLInputElement;\n labelElement: HTMLDivElement;\n\n node?: HTMLElement;\n\n @Listen('click', { target: 'document' })\n handleClick(event: Event) {\n if (!this.node || !this.inputIsFocused) return;\n\n const clickInside = this.node.contains(event.target as Node);\n\n if (!clickInside) {\n this.toggleOptions(false);\n this.focusedOut.emit();\n this.inputIsFocused = false;\n }\n }\n\n componentWillLoad() {\n if (this.value && this.value.trim().length > 0) {\n this.textValue = this.value;\n this.inputIsOpen = true;\n }\n }\n\n componentDidLoad() {\n if (this.value && this.value.trim().length > 0 && this.inputElement) {\n this.inputElement.value = this.value;\n this.textValue = this.value;\n }\n \n if (this.textValue && this.textValue.trim().length > 0) {\n this.changeElementsStyle();\n }\n\n if (this.maskPattern && this.inputElement) {\n this.handleInputMask();\n }\n }\n\n handleInputClick = () => {\n this.toggleOptions(true);\n };\n\n toggleOptions(inputIsOpen: boolean) {\n if ((this.inputIsOpen && this.textValue && this.textValue.length > 0) || this.disabled) return;\n\n this.inputIsOpen = inputIsOpen;\n this.changeElementsStyle();\n this.inputElement.focus();\n }\n\n changeElementsStyle() {\n if (!this.inputContainer || !this.labelElement) return;\n\n this.inputContainer.style.display = this.inputIsOpen ? 'flex' : 'none';\n this.labelElement.style.display = this.inputIsOpen ? 'none' : 'block';\n if (!this.inputIsOpen) {\n this.labelElement.classList.add('from-up');\n }\n }\n\n handleInputChanges = (event: InputEvent) => {\n if (this.maskPattern && this.inputElement) {\n this.handleInputMask();\n }\n const newValue = (event.target as HTMLInputElement).value;\n this.textValue = newValue;\n this.value = newValue;\n\n this.valueChanged.emit(newValue);\n };\n\n handleFocus = () => {\n if (this.disabled) return;\n this.toggleOptions(true);\n this.inputElement.focus();\n };\n\n handleBlur = () => {\n this.toggleOptions(false);\n\n this.focusedOut.emit();\n this.inputIsFocused = false;\n };\n\n handleInputFocus = () => {\n this.focusedOn.emit();\n this.inputIsFocused = true;\n };\n\n handleIconClick = (event: MouseEvent) => {\n if (this.type === SulaTextfieldType.Password) {\n event.stopPropagation();\n this.handlePasswordIconClicked();\n }\n };\n\n handleInputMask() {\n VMasker(this.inputElement).maskPattern(this.maskPattern);\n }\n\n handlePasswordIconClicked() {\n const cursorPosition = this.inputElement.selectionStart;\n const inputValue = this.inputElement.value;\n const inputType = this.showPassword ? SulaTextfieldType.Password : SulaTextfieldType.Text;\n\n this.inputElement.setAttribute('type', inputType);\n this.showPassword = !this.showPassword;\n\n setTimeout(() => {\n this.inputElement.value = inputValue;\n\n this.inputElement.setSelectionRange(cursorPosition, cursorPosition);\n }, 0);\n }\n\n getInputIcon() {\n if (this.type === SulaTextfieldType.Password) {\n return this.showPassword ? 'ph ph-eye' : 'ph ph-eye-slash';\n }\n\n return this.icon;\n }\n\n render() {\n return (\n <Host ref={node => (this.node = node)}>\n <div>\n <div\n id=\"button-container\"\n class={{\n 'flex items-center border rounded-sm px-16 outline-none h-[72px] caret-brand-primary': true,\n 'flex-row justify-between': !!this.icon || this.type === SulaTextfieldType.Password,\n 'button-focus': this.inputIsFocused && !this.disabled && this.status === SulaTextfieldStatus.Default,\n 'button-error': this.status === SulaTextfieldStatus.Error && !this.disabled,\n 'bg-states-bg-disabled border-line-general cursor-not-allowed': this.disabled,\n 'bg-surface-body border-line-input cursor-pointer': !this.disabled,\n }}\n tabIndex={0}\n onFocus={this.handleFocus}\n onClick={this.handleInputClick}\n >\n {!this.disabled && (\n <div class={{ 'hidden flex-col w-full': true, 'pr-12': !!this.icon }} ref={node => (this.inputContainer = node)}>\n <label class=\"font-bold text-sm text-text-primary from-down\">{this.label}</label>\n <input\n type={this.type}\n ref={node => (this.inputElement = node)}\n placeholder={this.placeholder}\n class=\"outline-none text-base text-text-primary bg-transparent\"\n onInput={this.handleInputChanges}\n onFocus={this.handleInputFocus}\n value={this.textValue}\n />\n </div>\n )}\n\n <div\n id=\"textfield-label\"\n class={{ 'text-base flex items-center': true, 'text-text-primary': !this.disabled, 'text-text-disabled': this.disabled }}\n ref={node => (this.labelElement = node)}\n >\n {this.label}\n </div>\n\n {(!!this.icon || this.type === SulaTextfieldType.Password) && (\n <div class=\"flex items-center justify-center\" onClick={this.handleIconClick}>\n <sula-icon icon={this.getInputIcon()} customClass={`text-2xl ${this.disabled ? 'text-icon-disabled' : 'text-icon-primary'}`} />\n </div>\n )}\n </div>\n\n {(this.helpText || this.maxLength) && !this.disabled && (\n <div class=\"flex justify-between items-center px-16 mt-4 text-sm\">\n {this.helpText && (\n <div\n id=\"textfield-help-text\"\n class={{ 'text-text-primary': this.status === SulaTextfieldStatus.Default, 'text-feedback-error': this.status === SulaTextfieldStatus.Error }}\n >\n {this.helpText}\n </div>\n )}\n {this.maxLength && (\n <div\n id=\"max-length-container\"\n class={{ 'text-text-primary': this.status === SulaTextfieldStatus.Default, 'text-feedback-error': this.status === SulaTextfieldStatus.Error }}\n >\n {this.textValue ? this.textValue.length : 0}/{this.maxLength}\n </div>\n )}\n </div>\n )}\n </div>\n </Host>\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sula-textfield.js","sourceRoot":"","sources":["../../../src/components/sula-textfield/sula-textfield.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAgB,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AACpG,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACtF,OAAO,OAAO,MAAM,gBAAgB,CAAC;AAOrC,MAAM,OAAO,aAAa;IAL1B;QAYE;;WAEG;QACK,SAAI,GAAsB,iBAAiB,CAAC,IAAI,CAAC;QAEzD;;WAEG;QACsB,WAAM,GAAwB,mBAAmB,CAAC,OAAO,CAAC;QAoDnF;;WAEG;QAEH,+BAA0B,GAAW,EAAE,CAAC;QAexC,gBAAW,GAAG,KAAK,CAAC;QAGpB,cAAS,GAAW,EAAE,CAAC;QAGvB,iBAAY,GAAG,KAAK,CAAC;QAGrB,mBAAc,GAAG,KAAK,CAAC;QAoFvB,qBAAgB,GAAG,GAAG,EAAE;YACtB,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QAC3B,CAAC,CAAC;QAoBF,uBAAkB,GAAG,CAAC,KAAiB,EAAE,EAAE;YACzC,MAAM,QAAQ,GAAI,KAAK,CAAC,MAA2B,CAAC,KAAK,CAAC;YAC1D,IAAI,cAAc,GAAG,QAAQ,CAAC;YAE9B,IAAI,IAAI,CAAC,wBAAwB,EAAE,IAAI,IAAI,CAAC,YAAY,EA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,qBAAqB,EAAE,IAAI,CAAC,MAAM,KAAK,mBAAmB,CAAC,KAAK,EAAE,IAE5I,IAAI,CAAC,QAAQ,CACV,CACP;oBACA,IAAI,CAAC,SAAS,IAAI,CACjB,4DACE,EAAE,EAAC,sBAAsB,EACzB,KAAK,EAAE,EAAE,mBAAmB,EAAE,IAAI,CAAC,MAAM,KAAK,mBAAmB,CAAC,OAAO,EAAE,qBAAqB,EAAE,IAAI,CAAC,MAAM,KAAK,mBAAmB,CAAC,KAAK,EAAE;wBAE5I,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;;wBAAG,IAAI,CAAC,SAAS,CACxD,CACP,CACG,CACP,CACG,CACD,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Event, EventEmitter, Host, Listen, Prop, State, Watch, h } from '@stencil/core';\nimport { SulaTextfieldStatus, SulaTextfieldType } from './model/sula-textfield.model';\nimport VMasker from 'vanilla-masker';\n\n@Component({\n tag: 'sula-textfield',\n styleUrl: 'sula-textfield.scss',\n shadow: true,\n})\nexport class SulaTextfield {\n /**\n * Value for the input.\n */\n @Prop({ mutable: true })\n value?: string;\n\n /**\n * The textfield type\n */\n @Prop() type: SulaTextfieldType = SulaTextfieldType.Text;\n\n /**\n * The textfield status\n */\n @Prop({ mutable: true }) status: SulaTextfieldStatus = SulaTextfieldStatus.Default;\n\n /**\n * The textfield label\n */\n @Prop() label: string;\n\n /**\n * The textfield placeholder\n */\n @Prop() placeholder: string;\n\n /**\n * The textfield is disabled\n */\n @Prop({ mutable: true }) disabled: boolean;\n\n /**\n * The help text for textfield\n */\n @Prop() helpText?: string;\n\n /**\n * The textfield max length\n */\n @Prop() maxLength?: number;\n\n /**\n * The textfield icon\n */\n @Prop() icon?: string;\n\n /**\n * Event emitted when input value changes.\n */\n @Event()\n valueChanged: EventEmitter<string>;\n\n /**\n * Event emitted when input value changes without mask pattern applied.\n */\n @Event()\n valueChangedWithoutMask: EventEmitter<string>;\n\n /**\n * The textfield mask pattern\n * The mask pattern should follow the VMasker pattern format\n * More info: https://github.com/vanilla-masker/vanilla-masker?tab=readme-ov-file#custom-pattern\n */\n @Prop()\n maskPattern?: string | string[];\n\n /**\n * Max input length used to switch between the first and second mask pattern.\n */\n @Prop()\n maskPatternSwitchMaxLength: number = 14;\n\n /**\n * Event emitted when input is focused.\n */\n @Event()\n focusedOn: EventEmitter<void>;\n\n /**\n * Event emitted when input is focused out.\n */\n @Event()\n focusedOut: EventEmitter<void>;\n\n @State()\n inputIsOpen = false;\n\n @State()\n textValue: string = '';\n\n @State()\n showPassword = false;\n\n @State()\n inputIsFocused = false;\n\n @Watch('value')\n watchValueHandler(newValue: string) {\n const normalizedValue = newValue || '';\n this.textValue = normalizedValue;\n\n if (this.inputElement && this.inputElement.value !== normalizedValue) {\n const cursorPosition = this.inputElement.selectionStart;\n this.inputElement.value = normalizedValue;\n\n if (this.hasMaskPatternConfigured()) {\n this.handleInputMask(normalizedValue);\n this.textValue = this.inputElement.value;\n }\n\n if (this.inputIsFocused && cursorPosition !== null) {\n const newPosition = Math.min(cursorPosition, this.inputElement.value.length);\n this.inputElement.setSelectionRange(newPosition, newPosition);\n }\n }\n\n if (this.textValue && this.textValue.trim().length > 0) {\n this.inputIsOpen = true;\n this.changeElementsStyle();\n } else if (!this.inputIsFocused) {\n this.inputIsOpen = false;\n this.changeElementsStyle();\n }\n }\n\n @Watch('maskPattern')\n watchMaskPatternHandler() {\n this.syncMaskState();\n }\n\n @Watch('maskPatternSwitchMaxLength')\n watchMaskPatternSwitchMaxLengthHandler() {\n this.syncMaskState();\n }\n\n inputContainer: HTMLDivElement;\n inputElement: HTMLInputElement;\n labelElement: HTMLDivElement;\n\n node?: HTMLElement;\n\n @Listen('click', { target: 'document' })\n handleClick(event: Event) {\n if (!this.node || !this.inputIsFocused) return;\n\n const clickInside = this.node.contains(event.target as Node);\n\n if (!clickInside) {\n this.toggleOptions(false);\n this.focusedOut.emit();\n this.inputIsFocused = false;\n }\n }\n\n componentWillLoad() {\n if (this.value && this.value.trim().length > 0) {\n this.textValue = this.value;\n this.inputIsOpen = true;\n }\n }\n\n componentDidLoad() {\n if (this.value && this.value.trim().length > 0 && this.inputElement) {\n this.inputElement.value = this.value;\n this.textValue = this.value;\n }\n \n if (this.textValue && this.textValue.trim().length > 0) {\n this.changeElementsStyle();\n }\n\n if (this.hasMaskPatternConfigured() && this.inputElement) {\n this.handleInputMask();\n this.textValue = this.inputElement.value;\n this.value = this.inputElement.value;\n }\n }\n\n handleInputClick = () => {\n this.toggleOptions(true);\n };\n\n toggleOptions(inputIsOpen: boolean) {\n if ((this.inputIsOpen && this.textValue && this.textValue.length > 0) || this.disabled) return;\n\n this.inputIsOpen = inputIsOpen;\n this.changeElementsStyle();\n this.inputElement.focus();\n }\n\n changeElementsStyle() {\n if (!this.inputContainer || !this.labelElement) return;\n\n this.inputContainer.style.display = this.inputIsOpen ? 'flex' : 'none';\n this.labelElement.style.display = this.inputIsOpen ? 'none' : 'block';\n if (!this.inputIsOpen) {\n this.labelElement.classList.add('from-up');\n }\n }\n\n handleInputChanges = (event: InputEvent) => {\n const newValue = (event.target as HTMLInputElement).value;\n let valueToPersist = newValue;\n\n if (this.hasMaskPatternConfigured() && this.inputElement) {\n this.handleInputMask(newValue);\n valueToPersist = this.inputElement.value;\n }\n this.valueChangedWithoutMask.emit(valueToPersist.replace(/\\D/g, ''));\n this.textValue = valueToPersist;\n this.value = valueToPersist;\n\n this.valueChanged.emit(valueToPersist);\n };\n\n handleFocus = () => {\n if (this.disabled) return;\n this.toggleOptions(true);\n this.inputElement.focus();\n };\n\n handleBlur = () => {\n this.toggleOptions(false);\n\n this.focusedOut.emit();\n this.inputIsFocused = false;\n };\n\n handleInputFocus = () => {\n this.focusedOn.emit();\n this.inputIsFocused = true;\n };\n\n handleIconClick = (event: MouseEvent) => {\n if (this.type === SulaTextfieldType.Password) {\n event.stopPropagation();\n this.handlePasswordIconClicked();\n }\n };\n\n handleInputMask(inputValue?: string) {\n if (!this.inputElement) return;\n\n const maskPattern = this.getMaskPatternByValueLength(inputValue);\n if (!maskPattern) return;\n\n const valueWithoutMask = (inputValue ?? this.inputElement.value ?? '').replace(/[^a-zA-Z0-9]/g, '');\n VMasker(this.inputElement).unMask();\n this.inputElement.value = (VMasker as any).toPattern(valueWithoutMask, maskPattern);\n }\n\n private syncMaskState() {\n if (!this.inputElement) return;\n\n if (!this.hasMaskPatternConfigured()) {\n VMasker(this.inputElement).unMask();\n return;\n }\n\n this.handleInputMask();\n this.textValue = this.inputElement.value;\n this.value = this.inputElement.value;\n }\n\n private hasMaskPatternConfigured(): boolean {\n return this.getMaskPatterns().length > 0;\n }\n\n private getMaskPatterns(): string[] {\n if (Array.isArray(this.maskPattern)) {\n return this.maskPattern.map(pattern => pattern?.trim()).filter(Boolean);\n }\n\n if (typeof this.maskPattern === 'string' && this.maskPattern.trim().length > 0) {\n return [this.maskPattern.trim()];\n }\n\n return [];\n }\n\n private getMaskPatternByValueLength(inputValue?: string): string | undefined {\n const patterns = this.getMaskPatterns();\n if (patterns.length === 0) return undefined;\n if (patterns.length === 1) return patterns[0];\n\n const currentValueLength = (inputValue ?? this.inputElement?.value ?? '').length;\n const switchMaxLength = this.maskPatternSwitchMaxLength ?? 14;\n const selectedIndex = currentValueLength > switchMaxLength ? 1 : 0;\n\n return patterns[Math.min(selectedIndex, patterns.length - 1)];\n }\n\n handlePasswordIconClicked() {\n const cursorPosition = this.inputElement.selectionStart;\n const inputValue = this.inputElement.value;\n const inputType = this.showPassword ? SulaTextfieldType.Password : SulaTextfieldType.Text;\n\n this.inputElement.setAttribute('type', inputType);\n this.showPassword = !this.showPassword;\n\n setTimeout(() => {\n this.inputElement.value = inputValue;\n\n this.inputElement.setSelectionRange(cursorPosition, cursorPosition);\n }, 0);\n }\n\n getInputIcon() {\n if (this.type === SulaTextfieldType.Password) {\n return this.showPassword ? 'ph ph-eye' : 'ph ph-eye-slash';\n }\n\n return this.icon;\n }\n\n render() {\n return (\n <Host ref={node => (this.node = node)}>\n <div>\n <div\n id=\"button-container\"\n class={{\n 'flex items-center border rounded-sm px-16 outline-none h-[72px] caret-brand-primary': true,\n 'flex-row justify-between': !!this.icon || this.type === SulaTextfieldType.Password,\n 'button-focus': this.inputIsFocused && !this.disabled && this.status === SulaTextfieldStatus.Default,\n 'button-error': this.status === SulaTextfieldStatus.Error && !this.disabled,\n 'bg-states-bg-disabled border-line-general cursor-not-allowed': this.disabled,\n 'bg-surface-body border-line-input cursor-pointer': !this.disabled,\n }}\n tabIndex={0}\n onFocus={this.handleFocus}\n onClick={this.handleInputClick}\n >\n {!this.disabled && (\n <div class={{ 'hidden flex-col w-full': true, 'pr-12': !!this.icon }} ref={node => (this.inputContainer = node)}>\n <label class=\"font-bold text-sm text-text-primary from-down\">{this.label}</label>\n <input\n type={this.type}\n ref={node => (this.inputElement = node)}\n placeholder={this.placeholder}\n class=\"outline-none text-base text-text-primary bg-transparent\"\n onInput={this.handleInputChanges}\n onFocus={this.handleInputFocus}\n value={this.textValue}\n />\n </div>\n )}\n\n <div\n id=\"textfield-label\"\n class={{ 'text-base flex items-center': true, 'text-text-primary': !this.disabled, 'text-text-disabled': this.disabled }}\n ref={node => (this.labelElement = node)}\n >\n {this.label}\n </div>\n\n {(!!this.icon || this.type === SulaTextfieldType.Password) && (\n <div class=\"flex items-center justify-center\" onClick={this.handleIconClick}>\n <sula-icon icon={this.getInputIcon()} customClass={`text-2xl ${this.disabled ? 'text-icon-disabled' : 'text-icon-primary'}`} />\n </div>\n )}\n </div>\n\n {(this.helpText || this.maxLength) && !this.disabled && (\n <div class=\"flex justify-between items-center px-16 mt-4 text-sm\">\n {this.helpText && (\n <div\n id=\"textfield-help-text\"\n class={{ 'text-text-primary': this.status === SulaTextfieldStatus.Default, 'text-feedback-error': this.status === SulaTextfieldStatus.Error }}\n >\n {this.helpText}\n </div>\n )}\n {this.maxLength && (\n <div\n id=\"max-length-container\"\n class={{ 'text-text-primary': this.status === SulaTextfieldStatus.Default, 'text-feedback-error': this.status === SulaTextfieldStatus.Error }}\n >\n {this.textValue ? this.textValue.length : 0}/{this.maxLength}\n </div>\n )}\n </div>\n )}\n </div>\n </Host>\n );\n }\n}\n"]}
|
|
@@ -38,7 +38,7 @@ export default {
|
|
|
38
38
|
},
|
|
39
39
|
},
|
|
40
40
|
maskPattern: {
|
|
41
|
-
control: '
|
|
41
|
+
control: 'object',
|
|
42
42
|
defaultValue: '',
|
|
43
43
|
description: `Padrão de máscara utilizando vanilla-masker.
|
|
44
44
|
|
|
@@ -94,6 +94,14 @@ textfield.placeholder = '00.000.000/0000-00';
|
|
|
94
94
|
required: false,
|
|
95
95
|
},
|
|
96
96
|
},
|
|
97
|
+
maskPatternSwitchMaxLength: {
|
|
98
|
+
control: 'number',
|
|
99
|
+
defaultValue: 14,
|
|
100
|
+
description: 'Max length to switch between maskPattern[0] and maskPattern[1]',
|
|
101
|
+
type: {
|
|
102
|
+
required: false,
|
|
103
|
+
},
|
|
104
|
+
},
|
|
97
105
|
placeholder: {
|
|
98
106
|
control: 'text',
|
|
99
107
|
defaultValue: 'Placeholder',
|
|
@@ -138,6 +146,10 @@ textfield.placeholder = '00.000.000/0000-00';
|
|
|
138
146
|
action: 'valueChanged',
|
|
139
147
|
description: 'Evento emitido quando o valor muda',
|
|
140
148
|
},
|
|
149
|
+
valueChangedWithoutMask: {
|
|
150
|
+
action: 'valueChangedWithoutMask',
|
|
151
|
+
description: 'Evento emitido quando o valor muda, sem a máscara (se aplicada)',
|
|
152
|
+
},
|
|
141
153
|
focusedOn: {
|
|
142
154
|
action: 'focusedOn',
|
|
143
155
|
description: 'Evento emitido quando o campo recebe foco',
|
|
@@ -176,6 +188,7 @@ const Template = args => {
|
|
|
176
188
|
if (args.icon)
|
|
177
189
|
el.icon = args.icon;
|
|
178
190
|
el.addEventListener('valueChanged', args.valueChanged);
|
|
191
|
+
el.addEventListener('valueChangedWithoutMask', args.valueChangedWithoutMask);
|
|
179
192
|
el.addEventListener('focusedOn', args.focusedOn);
|
|
180
193
|
el.addEventListener('focusedOut', args.focusedOut);
|
|
181
194
|
container.appendChild(el);
|
|
@@ -206,6 +219,20 @@ WithMask.args = {
|
|
|
206
219
|
icon: '',
|
|
207
220
|
maskPattern: '(99) 99999-9999',
|
|
208
221
|
};
|
|
222
|
+
export const WithCpfCnpjMask = Template.bind({});
|
|
223
|
+
WithCpfCnpjMask.args = {
|
|
224
|
+
value: '',
|
|
225
|
+
type: SulaTextfieldType.Text,
|
|
226
|
+
status: SulaTextfieldStatus.Default,
|
|
227
|
+
label: 'CPF ou CNPJ',
|
|
228
|
+
placeholder: 'Digite CPF ou CNPJ',
|
|
229
|
+
disabled: false,
|
|
230
|
+
helpText: '',
|
|
231
|
+
maxLength: 0,
|
|
232
|
+
icon: '',
|
|
233
|
+
maskPattern: ['999.999.999-99', '99.999.999/9999-99'],
|
|
234
|
+
maskPatternSwitchMaxLength: 14,
|
|
235
|
+
};
|
|
209
236
|
export const WithValue = Template.bind({});
|
|
210
237
|
WithValue.args = Object.assign(Object.assign({}, Default.args), { value: 'John Doe', label: 'Nome completo' });
|
|
211
238
|
export const WithHelpText = Template.bind({});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sula-textfield.stories.js","sourceRoot":"","sources":["../../../src/components/sula-textfield/sula-textf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C,IAAI,CAAC,EAAE,CAAC,CAAC;AACpD,kBAAkB,CAAC,IAAI,mCAClB,OAAO,CAAC,IAAI,KACf,MAAM,EAAE,mBAAmB,CAAC,KAAK,EACjC,KAAK,EAAE,UAAU,EACjB,WAAW,EAAE,qBAAqB,EAClC,SAAS,EAAE,EAAE,EACb,QAAQ,EAAE,gCAAgC,EAC1C,KAAK,EAAE,0EAA0E,GAClF,CAAC","sourcesContent":["import { SulaTextfieldStatus, SulaTextfieldType } from './model/sula-textfield.model';\n\nexport default {\n title: 'Components/sula-textfield',\n tags: ['autodocs'],\n argTypes: {\n value: {\n control: 'text',\n defaultValue: '',\n description: 'Value for the input',\n type: {\n required: false,\n },\n },\n type: {\n control: { type: 'select' },\n options: Object.values(SulaTextfieldType),\n defaultValue: SulaTextfieldType.Text,\n description: 'The textfield type',\n type: {\n required: false,\n },\n },\n status: {\n control: { type: 'select' },\n options: Object.values(SulaTextfieldStatus),\n defaultValue: SulaTextfieldStatus.Default,\n description: 'The textfield status',\n type: {\n required: false,\n },\n },\n label: {\n control: 'text',\n defaultValue: 'Label',\n description: 'The textfield label',\n type: {\n required: false,\n },\n },\n maskPattern: {\n control: 'text',\n defaultValue: '',\n description: `Padrão de máscara utilizando vanilla-masker.\n\n**Caracteres disponíveis:**\n- \\`9\\` → Aceita apenas números (0-9)\n- \\`A\\` → Aceita apenas letras (a-z, A-Z)\n- \\`S\\` → Aceita letras e números\n- Outros caracteres são tratados como literais (parênteses, traços, pontos, etc.)\n\n**Exemplos de máscaras comuns:**\n- Telefone: \\`(99) 99999-9999\\`\n- CPF: \\`999.999.999-99\\`\n- CNPJ: \\`SS.SSS.SSS/SSSS-99\\` (alfanumérico)\n- CEP: \\`99999-999\\`\n- Data: \\`99/99/9999\\`\n- Cartão de crédito: \\`9999 9999 9999 9999\\`\n- Hora: \\`99:99\\`\n- Placa de carro: \\`AAA-9A99\\`\n\n**Formas de uso:**\n\n1. **Via HTML:**\n\\`\\`\\`html\n<sula-textfield \n label=\"Telefone\" \n mask-pattern=\"(99) 99999-9999\"\n placeholder=\"(00) 00000-0000\">\n</sula-textfield>\n\\`\\`\\`\n\n2. **Via JavaScript:**\n\\`\\`\\`javascript\nconst textfield = document.createElement('sula-textfield');\ntextfield.label = 'CNPJ';\ntextfield.maskPattern = 'SS.SSS.SSS/SSSS-99';\ntextfield.placeholder = '00.000.000/0000-00';\n\\`\\`\\`\n\n3. **Via Framework (React, Angular, Vue):**\n\\`\\`\\`jsx\n<sula-textfield \n label=\"CEP\"\n mask-pattern=\"99999-999\"\n placeholder=\"00000-000\">\n</sula-textfield>\n\\`\\`\\`\n\n**Observações:**\n- A máscara é apenas visual (formata mas não valida)\n- O valor emitido no evento \\`valueChanged\\` já vem formatado\n- A máscara é aplicada automaticamente conforme o usuário digita`,\n type: {\n required: false,\n },\n },\n placeholder: {\n control: 'text',\n defaultValue: 'Placeholder',\n description: 'The textfield placeholder',\n type: {\n required: false,\n },\n },\n disabled: {\n control: 'boolean',\n defaultValue: false,\n description: 'The textfield is disabled',\n type: {\n required: false,\n },\n },\n helpText: {\n control: 'text',\n defaultValue: '',\n description: 'The help text for textfield',\n type: {\n required: false,\n },\n },\n maxLength: {\n control: 'number',\n defaultValue: 0,\n description: 'The textfield max length',\n type: {\n required: false,\n },\n },\n icon: {\n control: 'text',\n defaultValue: '',\n description: 'The textfield icon',\n type: {\n required: false,\n },\n },\n valueChanged: {\n action: 'valueChanged',\n description: 'Evento emitido quando o valor muda',\n },\n focusedOn: {\n action: 'focusedOn',\n description: 'Evento emitido quando o campo recebe foco',\n },\n focusedOut: {\n action: 'focusedOut',\n description: 'Evento emitido quando o campo perde foco',\n },\n },\n parameters: {\n docs: {\n description: {\n component:\n 'O componente Textfield Sula Design System é utilizado para inclusão de informações em formulários e telas de cadastro. Foi desenvolvido suportando feedback text, helped text, ícones e senhas.',\n },\n },\n },\n};\n\nconst Template = args => {\n const container = document.createElement('div');\n container.style.maxWidth = '400px';\n container.style.margin = '20px';\n\n const el = document.createElement('sula-textfield');\n\n if (args.value) el.value = args.value;\n el.type = args.type;\n el.status = args.status;\n el.label = args.label;\n el.placeholder = args.placeholder;\n el.disabled = args.disabled;\n if (args.maskPattern) el.maskPattern = args.maskPattern;\n if (args.helpText) el.helpText = args.helpText;\n if (args.maxLength > 0) el.maxLength = args.maxLength;\n if (args.icon) el.icon = args.icon;\n\n el.addEventListener('valueChanged', args.valueChanged);\n el.addEventListener('focusedOn', args.focusedOn);\n el.addEventListener('focusedOut', args.focusedOut);\n\n container.appendChild(el);\n\n return container;\n};\n\nexport const Default = Template.bind({});\nDefault.args = {\n value: '',\n type: SulaTextfieldType.Text,\n status: SulaTextfieldStatus.Default,\n label: 'Nome',\n placeholder: 'Digite seu nome',\n disabled: false,\n helpText: '',\n maxLength: 0,\n icon: '',\n};\n\nexport const WithMask = Template.bind({});\nWithMask.args = {\n value: '',\n type: SulaTextfieldType.Text,\n status: SulaTextfieldStatus.Default,\n label: 'Telefone',\n placeholder: 'Digite seu telefone',\n disabled: false,\n helpText: '',\n maxLength: 0,\n icon: '',\n maskPattern: '(99) 99999-9999',\n};\n\nexport const WithValue = Template.bind({});\nWithValue.args = {\n ...Default.args,\n value: 'John Doe',\n label: 'Nome completo',\n};\n\nexport const WithHelpText = Template.bind({});\nWithHelpText.args = {\n ...Default.args,\n label: 'E-mail',\n placeholder: 'Digite seu e-mail',\n helpText: 'Informe um e-mail válido',\n};\n\nexport const WithMaxLength = Template.bind({});\nWithMaxLength.args = {\n ...Default.args,\n label: 'Descrição',\n placeholder: 'Digite uma descrição',\n maxLength: 100,\n helpText: 'Máximo de 100 caracteres',\n};\n\nexport const WithIcon = Template.bind({});\nWithIcon.args = {\n ...Default.args,\n label: 'Pesquisar',\n placeholder: 'Digite sua busca',\n icon: 'ph ph-magnifying-glass',\n};\n\nexport const Password = Template.bind({});\nPassword.args = {\n ...Default.args,\n type: SulaTextfieldType.Password,\n label: 'Senha',\n placeholder: 'Digite sua senha',\n};\n\nexport const Error = Template.bind({});\nError.args = {\n ...Default.args,\n status: SulaTextfieldStatus.Error,\n label: 'E-mail',\n placeholder: 'Digite seu e-mail',\n helpText: 'E-mail inválido',\n};\n\nexport const Disabled = Template.bind({});\nDisabled.args = {\n ...Default.args,\n disabled: true,\n label: 'Campo desabilitado',\n};\n\nexport const WithIconAndHelpText = Template.bind({});\nWithIconAndHelpText.args = {\n ...Default.args,\n label: 'Endereço',\n placeholder: 'Digite seu endereço',\n icon: 'ph ph-map-pin',\n helpText: 'Informe o endereço completo',\n};\n\nexport const ErrorWithMaxLength = Template.bind({});\nErrorWithMaxLength.args = {\n ...Default.args,\n status: SulaTextfieldStatus.Error,\n label: 'Mensagem',\n placeholder: 'Digite sua mensagem',\n maxLength: 50,\n helpText: 'Excedeu o limite de caracteres',\n value: 'Esta é uma mensagem de teste que excede o limite de caracteres permitido',\n};\n"]}
|
|
1
|
+
{"version":3,"file":"sula-textfield.stories.js","sourceRoot":"","sources":["../../../src/components/sula-textfield/sula-textfield.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEtF,eAAe;IACb,KAAK,EAAE,2BAA2B;IAClC,IAAI,EAAE,CAAC,UAAU,CAAC;IAClB,QAAQ,EAAE;QACR,KAAK,EAAE;YACL,OAAO,EAAE,MAAM;YACf,YAAY,EAAE,EAAE;YAChB,WAAW,EAAE,qBAAqB;YAClC,IAAI,EAAE;gBACJ,QAAQ,EAAE,KAAK;aAChB;SACF;QACD,IAAI,EAAE;YACJ,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YAC3B,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,iBAAiB,CAAC;YACzC,YAAY,EAAE,iBAAiB,CAAC,IAAI;YACpC,WAAW,EAAE,oBAAoB;YACjC,IAAI,EAAE;gBACJ,QAAQ,EAAE,KAAK;aAChB;SACF;QACD,MAAM,EAAE;YACN,OAAO,EAAE,EAAE,IAAI,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UAAU,EACjB,WAAW,EAAE,qBAAqB,EAClC,IAAI,EAAE,eAAe,EACrB,QAAQ,EAAE,6BAA6B,GACxC,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACpD,kBAAkB,CAAC,IAAI,mCAClB,OAAO,CAAC,IAAI,KACf,MAAM,EAAE,mBAAmB,CAAC,KAAK,EACjC,KAAK,EAAE,UAAU,EACjB,WAAW,EAAE,qBAAqB,EAClC,SAAS,EAAE,EAAE,EACb,QAAQ,EAAE,gCAAgC,EAC1C,KAAK,EAAE,0EAA0E,GAClF,CAAC","sourcesContent":["import { SulaTextfieldStatus, SulaTextfieldType } from './model/sula-textfield.model';\n\nexport default {\n title: 'Components/sula-textfield',\n tags: ['autodocs'],\n argTypes: {\n value: {\n control: 'text',\n defaultValue: '',\n description: 'Value for the input',\n type: {\n required: false,\n },\n },\n type: {\n control: { type: 'select' },\n options: Object.values(SulaTextfieldType),\n defaultValue: SulaTextfieldType.Text,\n description: 'The textfield type',\n type: {\n required: false,\n },\n },\n status: {\n control: { type: 'select' },\n options: Object.values(SulaTextfieldStatus),\n defaultValue: SulaTextfieldStatus.Default,\n description: 'The textfield status',\n type: {\n required: false,\n },\n },\n label: {\n control: 'text',\n defaultValue: 'Label',\n description: 'The textfield label',\n type: {\n required: false,\n },\n },\n maskPattern: {\n control: 'object',\n defaultValue: '',\n description: `Padrão de máscara utilizando vanilla-masker.\n\n**Caracteres disponíveis:**\n- \\`9\\` → Aceita apenas números (0-9)\n- \\`A\\` → Aceita apenas letras (a-z, A-Z)\n- \\`S\\` → Aceita letras e números\n- Outros caracteres são tratados como literais (parênteses, traços, pontos, etc.)\n\n**Exemplos de máscaras comuns:**\n- Telefone: \\`(99) 99999-9999\\`\n- CPF: \\`999.999.999-99\\`\n- CNPJ: \\`SS.SSS.SSS/SSSS-99\\` (alfanumérico)\n- CEP: \\`99999-999\\`\n- Data: \\`99/99/9999\\`\n- Cartão de crédito: \\`9999 9999 9999 9999\\`\n- Hora: \\`99:99\\`\n- Placa de carro: \\`AAA-9A99\\`\n\n**Formas de uso:**\n\n1. **Via HTML:**\n\\`\\`\\`html\n<sula-textfield \n label=\"Telefone\" \n mask-pattern=\"(99) 99999-9999\"\n placeholder=\"(00) 00000-0000\">\n</sula-textfield>\n\\`\\`\\`\n\n2. **Via JavaScript:**\n\\`\\`\\`javascript\nconst textfield = document.createElement('sula-textfield');\ntextfield.label = 'CNPJ';\ntextfield.maskPattern = 'SS.SSS.SSS/SSSS-99';\ntextfield.placeholder = '00.000.000/0000-00';\n\\`\\`\\`\n\n3. **Via Framework (React, Angular, Vue):**\n\\`\\`\\`jsx\n<sula-textfield \n label=\"CEP\"\n mask-pattern=\"99999-999\"\n placeholder=\"00000-000\">\n</sula-textfield>\n\\`\\`\\`\n\n**Observações:**\n- A máscara é apenas visual (formata mas não valida)\n- O valor emitido no evento \\`valueChanged\\` já vem formatado\n- A máscara é aplicada automaticamente conforme o usuário digita`,\n type: {\n required: false,\n },\n },\n maskPatternSwitchMaxLength: {\n control: 'number',\n defaultValue: 14,\n description: 'Max length to switch between maskPattern[0] and maskPattern[1]',\n type: {\n required: false,\n },\n },\n placeholder: {\n control: 'text',\n defaultValue: 'Placeholder',\n description: 'The textfield placeholder',\n type: {\n required: false,\n },\n },\n disabled: {\n control: 'boolean',\n defaultValue: false,\n description: 'The textfield is disabled',\n type: {\n required: false,\n },\n },\n helpText: {\n control: 'text',\n defaultValue: '',\n description: 'The help text for textfield',\n type: {\n required: false,\n },\n },\n maxLength: {\n control: 'number',\n defaultValue: 0,\n description: 'The textfield max length',\n type: {\n required: false,\n },\n },\n icon: {\n control: 'text',\n defaultValue: '',\n description: 'The textfield icon',\n type: {\n required: false,\n },\n },\n valueChanged: {\n action: 'valueChanged',\n description: 'Evento emitido quando o valor muda',\n },\n valueChangedWithoutMask: {\n action: 'valueChangedWithoutMask',\n description: 'Evento emitido quando o valor muda, sem a máscara (se aplicada)',\n },\n focusedOn: {\n action: 'focusedOn',\n description: 'Evento emitido quando o campo recebe foco',\n },\n focusedOut: {\n action: 'focusedOut',\n description: 'Evento emitido quando o campo perde foco',\n },\n },\n parameters: {\n docs: {\n description: {\n component:\n 'O componente Textfield Sula Design System é utilizado para inclusão de informações em formulários e telas de cadastro. Foi desenvolvido suportando feedback text, helped text, ícones e senhas.',\n },\n },\n },\n};\n\nconst Template = args => {\n const container = document.createElement('div');\n container.style.maxWidth = '400px';\n container.style.margin = '20px';\n\n const el = document.createElement('sula-textfield') as any;\n\n if (args.value) el.value = args.value;\n el.type = args.type;\n el.status = args.status;\n el.label = args.label;\n el.placeholder = args.placeholder;\n el.disabled = args.disabled;\n if (args.maskPattern) el.maskPattern = args.maskPattern;\n if (args.helpText) el.helpText = args.helpText;\n if (args.maxLength > 0) el.maxLength = args.maxLength;\n if (args.icon) el.icon = args.icon;\n\n el.addEventListener('valueChanged', args.valueChanged);\n el.addEventListener('valueChangedWithoutMask', args.valueChangedWithoutMask);\n el.addEventListener('focusedOn', args.focusedOn);\n el.addEventListener('focusedOut', args.focusedOut);\n\n container.appendChild(el);\n\n return container;\n};\n\nexport const Default = Template.bind({});\nDefault.args = {\n value: '',\n type: SulaTextfieldType.Text,\n status: SulaTextfieldStatus.Default,\n label: 'Nome',\n placeholder: 'Digite seu nome',\n disabled: false,\n helpText: '',\n maxLength: 0,\n icon: '',\n};\n\nexport const WithMask = Template.bind({});\nWithMask.args = {\n value: '',\n type: SulaTextfieldType.Text,\n status: SulaTextfieldStatus.Default,\n label: 'Telefone',\n placeholder: 'Digite seu telefone',\n disabled: false,\n helpText: '',\n maxLength: 0,\n icon: '',\n maskPattern: '(99) 99999-9999',\n};\n\nexport const WithCpfCnpjMask = Template.bind({});\nWithCpfCnpjMask.args = {\n value: '',\n type: SulaTextfieldType.Text,\n status: SulaTextfieldStatus.Default,\n label: 'CPF ou CNPJ',\n placeholder: 'Digite CPF ou CNPJ',\n disabled: false,\n helpText: '',\n maxLength: 0,\n icon: '',\n maskPattern: ['999.999.999-99', '99.999.999/9999-99'],\n maskPatternSwitchMaxLength: 14,\n};\n\nexport const WithValue = Template.bind({});\nWithValue.args = {\n ...Default.args,\n value: 'John Doe',\n label: 'Nome completo',\n};\n\nexport const WithHelpText = Template.bind({});\nWithHelpText.args = {\n ...Default.args,\n label: 'E-mail',\n placeholder: 'Digite seu e-mail',\n helpText: 'Informe um e-mail válido',\n};\n\nexport const WithMaxLength = Template.bind({});\nWithMaxLength.args = {\n ...Default.args,\n label: 'Descrição',\n placeholder: 'Digite uma descrição',\n maxLength: 100,\n helpText: 'Máximo de 100 caracteres',\n};\n\nexport const WithIcon = Template.bind({});\nWithIcon.args = {\n ...Default.args,\n label: 'Pesquisar',\n placeholder: 'Digite sua busca',\n icon: 'ph ph-magnifying-glass',\n};\n\nexport const Password = Template.bind({});\nPassword.args = {\n ...Default.args,\n type: SulaTextfieldType.Password,\n label: 'Senha',\n placeholder: 'Digite sua senha',\n};\n\nexport const Error = Template.bind({});\nError.args = {\n ...Default.args,\n status: SulaTextfieldStatus.Error,\n label: 'E-mail',\n placeholder: 'Digite seu e-mail',\n helpText: 'E-mail inválido',\n};\n\nexport const Disabled = Template.bind({});\nDisabled.args = {\n ...Default.args,\n disabled: true,\n label: 'Campo desabilitado',\n};\n\nexport const WithIconAndHelpText = Template.bind({});\nWithIconAndHelpText.args = {\n ...Default.args,\n label: 'Endereço',\n placeholder: 'Digite seu endereço',\n icon: 'ph ph-map-pin',\n helpText: 'Informe o endereço completo',\n};\n\nexport const ErrorWithMaxLength = Template.bind({});\nErrorWithMaxLength.args = {\n ...Default.args,\n status: SulaTextfieldStatus.Error,\n label: 'Mensagem',\n placeholder: 'Digite sua mensagem',\n maxLength: 50,\n helpText: 'Excedeu o limite de caracteres',\n value: 'Esta é uma mensagem de teste que excede o limite de caracteres permitido',\n};\n"]}
|