@sula-tech/webcomponents 0.1.0 → 0.2.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/{index-7973b779.js → index-3eac14f6.js} +102 -4
- package/dist/cjs/index-3eac14f6.js.map +1 -0
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/{sula-avatar_3.cjs.entry.js → sula-avatar_4.cjs.entry.js} +133 -5
- package/dist/cjs/sula-avatar_4.cjs.entry.js.map +1 -0
- package/dist/cjs/webcomponents.cjs.js +2 -2
- package/dist/collection/collection-manifest.json +2 -1
- package/dist/collection/components/sula-avatar/sula-avatar.css +1 -1
- package/dist/collection/components/sula-avatar/sula-avatar.stories.js +14 -17
- package/dist/collection/components/sula-avatar/sula-avatar.stories.js.map +1 -1
- package/dist/collection/components/sula-button/sula-button.css +1 -1
- package/dist/collection/components/sula-button/sula-button.stories.js +36 -9
- package/dist/collection/components/sula-button/sula-button.stories.js.map +1 -1
- package/dist/collection/components/sula-icon/sula-icon.css +1 -1
- package/dist/collection/components/sula-icon/sula-icon.stories.js +35 -14
- package/dist/collection/components/sula-icon/sula-icon.stories.js.map +1 -1
- package/dist/collection/components/sula-textfield/model/sula-textfield.model.js +11 -0
- package/dist/collection/components/sula-textfield/model/sula-textfield.model.js.map +1 -0
- package/dist/collection/components/sula-textfield/sula-textfield.css +1 -0
- package/dist/collection/components/sula-textfield/sula-textfield.js +376 -0
- package/dist/collection/components/sula-textfield/sula-textfield.js.map +1 -0
- package/dist/collection/components/sula-textfield/sula-textfield.stories.js +148 -0
- package/dist/collection/components/sula-textfield/sula-textfield.stories.js.map +1 -0
- package/dist/components/index.js +1 -1
- package/dist/components/{p-81fcc74a.js → p-a07ff261.js} +3 -3
- package/dist/components/{p-81fcc74a.js.map → p-a07ff261.js.map} +1 -1
- package/dist/components/{p-d3ba6302.js → p-ca146b16.js} +91 -5
- package/dist/components/p-ca146b16.js.map +1 -0
- package/dist/components/sula-avatar.js +3 -3
- package/dist/components/sula-avatar.js.map +1 -1
- package/dist/components/sula-button.js +3 -3
- package/dist/components/sula-button.js.map +1 -1
- package/dist/components/sula-icon.js +1 -1
- package/dist/components/sula-textfield.d.ts +11 -0
- package/dist/components/sula-textfield.js +171 -0
- package/dist/components/sula-textfield.js.map +1 -0
- package/dist/esm/{index-9bf8f892.js → index-1dc4ae53.js} +102 -4
- package/dist/esm/index-1dc4ae53.js.map +1 -0
- package/dist/esm/loader.js +3 -3
- package/dist/esm/{sula-avatar_3.entry.js → sula-avatar_4.entry.js} +133 -6
- package/dist/esm/sula-avatar_4.entry.js.map +1 -0
- package/dist/esm/webcomponents.js +3 -3
- package/dist/types/components/sula-avatar/sula-avatar.stories.d.ts +0 -1
- package/dist/types/components/sula-button/sula-button.stories.d.ts +2 -0
- package/dist/types/components/sula-icon/sula-icon.stories.d.ts +5 -2
- package/dist/types/components/sula-textfield/model/sula-textfield.model.d.ts +8 -0
- package/dist/types/components/sula-textfield/sula-textfield.d.ts +74 -0
- package/dist/types/components/sula-textfield/sula-textfield.stories.d.ts +108 -0
- package/dist/types/components.d.ts +116 -0
- package/dist/webcomponents/{p-82d7a024.entry.js → p-77709b3c.entry.js} +201 -9
- package/dist/webcomponents/p-77709b3c.entry.js.map +1 -0
- package/dist/webcomponents/{p-cca32e44.js → p-fbee9d79.js} +426 -325
- package/dist/webcomponents/p-fbee9d79.js.map +1 -0
- package/dist/webcomponents/webcomponents.esm.js +27 -13
- package/dist/webcomponents/webcomponents.esm.js.map +1 -1
- package/package.json +20 -27
- package/dist/cjs/index-7973b779.js.map +0 -1
- package/dist/cjs/sula-avatar_3.cjs.entry.js.map +0 -1
- package/dist/components/p-d3ba6302.js.map +0 -1
- package/dist/esm/index-9bf8f892.js.map +0 -1
- package/dist/esm/sula-avatar_3.entry.js.map +0 -1
- package/dist/webcomponents/p-82d7a024.entry.js.map +0 -1
- package/dist/webcomponents/p-cca32e44.js.map +0 -1
|
@@ -1,19 +1,10 @@
|
|
|
1
1
|
export default {
|
|
2
2
|
title: 'Components/sula-icon',
|
|
3
|
-
decorators: [
|
|
4
|
-
SulaIcon => {
|
|
5
|
-
return `
|
|
6
|
-
<div>
|
|
7
|
-
${SulaIcon()}
|
|
8
|
-
</div>
|
|
9
|
-
`;
|
|
10
|
-
},
|
|
11
|
-
],
|
|
12
3
|
tags: ['autodocs'],
|
|
13
4
|
argTypes: {
|
|
14
5
|
icon: {
|
|
15
6
|
control: 'text',
|
|
16
|
-
defaultValue: '
|
|
7
|
+
defaultValue: 'ph ph-house',
|
|
17
8
|
description: 'The icon name.',
|
|
18
9
|
type: {
|
|
19
10
|
required: true,
|
|
@@ -21,7 +12,7 @@ export default {
|
|
|
21
12
|
},
|
|
22
13
|
customClass: {
|
|
23
14
|
control: 'text',
|
|
24
|
-
defaultValue: '
|
|
15
|
+
defaultValue: '',
|
|
25
16
|
description: 'Custom class to be applied to the icon.',
|
|
26
17
|
type: {
|
|
27
18
|
required: false,
|
|
@@ -29,10 +20,40 @@ export default {
|
|
|
29
20
|
},
|
|
30
21
|
},
|
|
31
22
|
};
|
|
32
|
-
const Template = args =>
|
|
33
|
-
|
|
34
|
-
|
|
23
|
+
const Template = args => {
|
|
24
|
+
const container = document.createElement('div');
|
|
25
|
+
container.style.margin = '20px';
|
|
26
|
+
container.style.fontSize = '24px'; // Tamanho maior para melhor visualização
|
|
27
|
+
const el = document.createElement('sula-icon');
|
|
28
|
+
el.setAttribute('icon', args.icon);
|
|
29
|
+
if (args.customClass)
|
|
30
|
+
el.setAttribute('custom-class', args.customClass);
|
|
31
|
+
container.appendChild(el);
|
|
32
|
+
return container;
|
|
33
|
+
};
|
|
34
|
+
export const Default = Template.bind({});
|
|
35
|
+
Default.args = {
|
|
35
36
|
icon: 'ph ph-house',
|
|
36
37
|
customClass: '',
|
|
37
38
|
};
|
|
39
|
+
export const WithCustomClass = Template.bind({});
|
|
40
|
+
WithCustomClass.args = {
|
|
41
|
+
icon: 'ph ph-user',
|
|
42
|
+
customClass: 'custom-icon-class',
|
|
43
|
+
};
|
|
44
|
+
export const ArrowIcon = Template.bind({});
|
|
45
|
+
ArrowIcon.args = {
|
|
46
|
+
icon: 'ph ph-arrow-right',
|
|
47
|
+
customClass: '',
|
|
48
|
+
};
|
|
49
|
+
export const CalendarIcon = Template.bind({});
|
|
50
|
+
CalendarIcon.args = {
|
|
51
|
+
icon: 'ph ph-calendar',
|
|
52
|
+
customClass: '',
|
|
53
|
+
};
|
|
54
|
+
export const SearchIcon = Template.bind({});
|
|
55
|
+
SearchIcon.args = {
|
|
56
|
+
icon: 'ph ph-magnifying-glass',
|
|
57
|
+
customClass: '',
|
|
58
|
+
};
|
|
38
59
|
//# sourceMappingURL=sula-icon.stories.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sula-icon.stories.js","sourceRoot":"","sources":["../../../src/components/sula-icon/sula-icon.stories.tsx"],"names":[],"mappings":"AAAA,eAAe;IACb,KAAK,EAAE,sBAAsB;IAC7B,
|
|
1
|
+
{"version":3,"file":"sula-icon.stories.js","sourceRoot":"","sources":["../../../src/components/sula-icon/sula-icon.stories.tsx"],"names":[],"mappings":"AAAA,eAAe;IACb,KAAK,EAAE,sBAAsB;IAC7B,IAAI,EAAE,CAAC,UAAU,CAAC;IAClB,QAAQ,EAAE;QACR,IAAI,EAAE;YACJ,OAAO,EAAE,MAAM;YACf,YAAY,EAAE,aAAa;YAC3B,WAAW,EAAE,gBAAgB;YAC7B,IAAI,EAAE;gBACJ,QAAQ,EAAE,IAAI;aACf;SACF;QACD,WAAW,EAAE;YACX,OAAO,EAAE,MAAM;YACf,YAAY,EAAE,EAAE;YAChB,WAAW,EAAE,yCAAyC;YACtD,IAAI,EAAE;gBACJ,QAAQ,EAAE,KAAK;aAChB;SACF;KACF;CACF,CAAC;AAEF,MAAM,QAAQ,GAAG,IAAI,CAAC,EAAE;IACtB,MAAM,SAAS,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC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AAC5C,UAAU,CAAC,IAAI,GAAG;IAChB,IAAI,EAAE,wBAAwB;IAC9B,WAAW,EAAE,EAAE;CAChB,CAAC","sourcesContent":["export default {\n title: 'Components/sula-icon',\n tags: ['autodocs'],\n argTypes: {\n icon: {\n control: 'text',\n defaultValue: 'ph ph-house',\n description: 'The icon name.',\n type: {\n required: true,\n },\n },\n customClass: {\n control: 'text',\n defaultValue: '',\n description: 'Custom class to be applied to the icon.',\n type: {\n required: false,\n },\n },\n },\n};\n\nconst Template = args => {\n const container = document.createElement('div');\n container.style.margin = '20px';\n container.style.fontSize = '24px'; // Tamanho maior para melhor visualização\n\n const el = document.createElement('sula-icon');\n \n el.setAttribute('icon', args.icon);\n if (args.customClass) el.setAttribute('custom-class', args.customClass);\n \n container.appendChild(el);\n \n return container;\n};\n\nexport const Default = Template.bind({});\nDefault.args = {\n icon: 'ph ph-house',\n customClass: '',\n};\n\nexport const WithCustomClass = Template.bind({});\nWithCustomClass.args = {\n icon: 'ph ph-user',\n customClass: 'custom-icon-class',\n};\n\nexport const ArrowIcon = Template.bind({});\nArrowIcon.args = {\n icon: 'ph ph-arrow-right',\n customClass: '',\n};\n\nexport const CalendarIcon = Template.bind({});\nCalendarIcon.args = {\n icon: 'ph ph-calendar',\n customClass: '',\n};\n\nexport const SearchIcon = Template.bind({});\nSearchIcon.args = {\n icon: 'ph ph-magnifying-glass',\n customClass: '',\n};\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export var SulaTextfieldType;
|
|
2
|
+
(function (SulaTextfieldType) {
|
|
3
|
+
SulaTextfieldType["Text"] = "text";
|
|
4
|
+
SulaTextfieldType["Password"] = "password";
|
|
5
|
+
})(SulaTextfieldType || (SulaTextfieldType = {}));
|
|
6
|
+
export var SulaTextfieldStatus;
|
|
7
|
+
(function (SulaTextfieldStatus) {
|
|
8
|
+
SulaTextfieldStatus["Default"] = "default";
|
|
9
|
+
SulaTextfieldStatus["Error"] = "error";
|
|
10
|
+
})(SulaTextfieldStatus || (SulaTextfieldStatus = {}));
|
|
11
|
+
//# sourceMappingURL=sula-textfield.model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sula-textfield.model.js","sourceRoot":"","sources":["../../../../src/components/sula-textfield/model/sula-textfield.model.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,iBAGX;AAHD,WAAY,iBAAiB;IAC3B,kCAAa,CAAA;IACb,0CAAqB,CAAA;AACvB,CAAC,EAHW,iBAAiB,KAAjB,iBAAiB,QAG5B;AAED,MAAM,CAAN,IAAY,mBAGX;AAHD,WAAY,mBAAmB;IAC7B,0CAAmB,CAAA;IACnB,sCAAe,CAAA;AACjB,CAAC,EAHW,mBAAmB,KAAnB,mBAAmB,QAG9B","sourcesContent":["export enum SulaTextfieldType {\n Text = 'text',\n Password = 'password',\n}\n\nexport enum SulaTextfieldStatus {\n Default = 'default',\n Error = 'error',\n}\n"]}
|
|
@@ -0,0 +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{box-shadow:0 0 0 2px #fff,0 0 0 4px var(--color-feedback-informational)!important;outline:none!important}.button-error{box-shadow:0 0 0 2px #fff,0 0 0 4px var(--color-feedback-error)!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:#02361a;--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:#500202;--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:#683f08;--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:#691e07;--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:#6a3b01;--color-gray-50:#fff;--color-gray-100:#f4f4f4;--color-gray-200:#e6e6e6;--color-gray-300:#c3c3c3;--color-gray-400:#b9b9b9;--color-gray-500:#949494;--color-gray-600:#737373;--color-gray-700:#5c5c5c;--color-gray-800:#323232;--color-gray-900:#292929;--color-gray-950:#141414;--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:#0a2e61;--color-extra-color-blue-light:#e7f0f4;--color-extra-color-blue-dark:#162931;--color-black-opacity-50:#14141405;--color-black-opacity-100:#1414141a;--color-black-opacity-200:#14141426;--color-black-opacity-300:#14141445;--color-black-opacity-400:#1414145c;--color-black-opacity-500:#14141480;--color-black-opacity-600:#1414148c;--color-black-opacity-700:#141414a3;--color-black-opacity-800:#141414ba;--color-black-opacity-900:#141414cc;--color-black-opacity-950:#141414e8;--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:#f4f4f4;--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:#323232;--color-text-secondary:#5c5c5c;--color-text-disabled:#949494;--color-text-link:#1355b4;--color-states-empty-bg-hover:#1414141a;--color-states-empty-bg-pressed:#14141426;--color-states-bg-disabled:#14141405;--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:#e6e6e6;--color-states-negative-pressed:#c3c3c3;--color-icon-primary:#5c5c5c;--color-icon-secondary:#fff;--color-icon-disabled:#b9b9b9;--color-neutral-neutral-1:#fff;--color-neutral-neutral-2:#f4f4f4;--color-neutral-neutral-3:#b9b9b9;--color-neutral-neutral-4:#949494;--color-neutral-neutral-5:#737373;--color-neutral-neutral-6:#5c5c5c;--color-neutral-neutral-7:#323232;--color-neutral-neutral-8:#292929;--color-negative-negative-1:#fff;--color-negative-negative-2:#323232;--color-opacity-body:#fffc;--color-opacity-on-body:#14141405;--color-opacity-overlay:#1414148c;--color-opacity-on-overlay:#ffffff1a;--color-line-input:#949494;--color-line-general-strong:#c3c3c3;--color-line-general:#e6e6e6}.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)}.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}
|
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
import { Host, h } from "@stencil/core";
|
|
2
|
+
import { SulaTextfieldStatus, SulaTextfieldType } from "./model/sula-textfield.model";
|
|
3
|
+
export class SulaTextfield {
|
|
4
|
+
constructor() {
|
|
5
|
+
/**
|
|
6
|
+
* The textfield type
|
|
7
|
+
*/
|
|
8
|
+
this.type = SulaTextfieldType.Text;
|
|
9
|
+
/**
|
|
10
|
+
* The textfield status
|
|
11
|
+
*/
|
|
12
|
+
this.status = SulaTextfieldStatus.Default;
|
|
13
|
+
this.inputIsOpen = false;
|
|
14
|
+
this.textValue = '';
|
|
15
|
+
this.showPassword = false;
|
|
16
|
+
this.inputIsFocused = false;
|
|
17
|
+
this.handleInputClick = () => {
|
|
18
|
+
this.toggleOptions(true);
|
|
19
|
+
};
|
|
20
|
+
this.handleInputChanges = (event) => {
|
|
21
|
+
const newValue = event.target.value;
|
|
22
|
+
this.textValue = newValue;
|
|
23
|
+
this.valueChanged.emit(newValue);
|
|
24
|
+
};
|
|
25
|
+
this.handleFocus = () => {
|
|
26
|
+
if (this.disabled)
|
|
27
|
+
return;
|
|
28
|
+
this.toggleOptions(true);
|
|
29
|
+
this.inputElement.focus();
|
|
30
|
+
};
|
|
31
|
+
this.handleBlur = () => {
|
|
32
|
+
this.toggleOptions(false);
|
|
33
|
+
this.focusedOut.emit();
|
|
34
|
+
this.inputIsFocused = false;
|
|
35
|
+
};
|
|
36
|
+
this.handleInputFocus = () => {
|
|
37
|
+
this.focusedOn.emit();
|
|
38
|
+
this.inputIsFocused = true;
|
|
39
|
+
};
|
|
40
|
+
this.handleIconClick = (event) => {
|
|
41
|
+
if (this.type === SulaTextfieldType.Password) {
|
|
42
|
+
event.stopPropagation();
|
|
43
|
+
this.handlePasswordIconClicked();
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
handleClick(event) {
|
|
48
|
+
if (!this.node)
|
|
49
|
+
return;
|
|
50
|
+
const clickInside = this.node.contains(event.target);
|
|
51
|
+
if (!clickInside) {
|
|
52
|
+
this.toggleOptions(false);
|
|
53
|
+
this.focusedOut.emit();
|
|
54
|
+
this.inputIsFocused = false;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
componentWillLoad() {
|
|
58
|
+
if (this.value && this.value.trim().length > 0) {
|
|
59
|
+
this.textValue = this.value;
|
|
60
|
+
this.inputIsOpen = true;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
componentDidLoad() {
|
|
64
|
+
if (this.textValue && this.textValue.trim().length > 0) {
|
|
65
|
+
this.changeElementsStyle();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
toggleOptions(inputIsOpen) {
|
|
69
|
+
if ((this.inputIsOpen && this.textValue && this.textValue.length > 0) || this.disabled)
|
|
70
|
+
return;
|
|
71
|
+
this.inputIsOpen = inputIsOpen;
|
|
72
|
+
this.changeElementsStyle();
|
|
73
|
+
this.inputElement.focus();
|
|
74
|
+
}
|
|
75
|
+
changeElementsStyle() {
|
|
76
|
+
this.inputContainer.style.display = this.inputIsOpen ? 'flex' : 'none';
|
|
77
|
+
this.labelElement.style.display = this.inputIsOpen ? 'none' : 'block';
|
|
78
|
+
if (!this.inputIsOpen) {
|
|
79
|
+
this.labelElement.classList.add('from-up');
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
handlePasswordIconClicked() {
|
|
83
|
+
const cursorPosition = this.inputElement.selectionStart;
|
|
84
|
+
const inputValue = this.inputElement.value;
|
|
85
|
+
const inputType = this.showPassword ? SulaTextfieldType.Password : SulaTextfieldType.Text;
|
|
86
|
+
this.inputElement.setAttribute('type', inputType);
|
|
87
|
+
this.showPassword = !this.showPassword;
|
|
88
|
+
setTimeout(() => {
|
|
89
|
+
this.inputElement.value = inputValue;
|
|
90
|
+
this.inputElement.setSelectionRange(cursorPosition, cursorPosition);
|
|
91
|
+
}, 0);
|
|
92
|
+
}
|
|
93
|
+
getInputIcon() {
|
|
94
|
+
if (this.type === SulaTextfieldType.Password) {
|
|
95
|
+
return this.showPassword ? 'ph ph-eye' : 'ph ph-eye-slash';
|
|
96
|
+
}
|
|
97
|
+
return this.icon;
|
|
98
|
+
}
|
|
99
|
+
render() {
|
|
100
|
+
return (h(Host, { key: 'a8bac04c291ef9f7f894b8ee191fb47f223023ce', ref: node => (this.node = node) }, h("div", { key: '5ec9505052d5fee9d54459dea2c1281842bbf61a' }, h("div", { key: '3d8e4377e67e755815446f58bad127fcad4575d4', id: "button-container", class: {
|
|
101
|
+
'flex items-center border rounded-sm px-16 outline-none h-[72px] caret-brand-primary': true,
|
|
102
|
+
'flex-row justify-between': !!this.icon || this.type === SulaTextfieldType.Password,
|
|
103
|
+
'button-focus': this.inputIsFocused && !this.disabled && this.status === SulaTextfieldStatus.Default,
|
|
104
|
+
'button-error': this.status === SulaTextfieldStatus.Error && !this.disabled,
|
|
105
|
+
'bg-states-bg-disabled border-line-general cursor-not-allowed': this.disabled,
|
|
106
|
+
'bg-surface-body border-line-input cursor-pointer': !this.disabled,
|
|
107
|
+
}, tabIndex: 0, onFocus: this.handleFocus, onClick: this.handleInputClick }, !this.disabled && (h("div", { key: '67286a579ce0cece357d02673c4ac695c56fe23d', class: { 'hidden flex-col w-full': true, 'pr-12': !!this.icon }, ref: node => (this.inputContainer = node) }, h("label", { key: 'f2915de1058c93d3937726dcef145cb9e217aed2', class: "font-bold text-sm text-text-primary from-down" }, this.label), h("input", { key: '09f663b3cc2c3dbd58cda35cb949fcd708c87111', type: this.type, ref: node => (this.inputElement = node), placeholder: this.placeholder, class: "outline-none text-base text-text-primary", onInput: this.handleInputChanges, onFocus: this.handleInputFocus, value: this.value }))), h("div", { key: '68615e768117e4f3d0eb09d9a8f56878e61377e0', 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: 'cfe8edb41b2163e391ec9c6615c77afc69fc35a4', class: "flex items-center justify-center", onClick: this.handleIconClick }, h("sula-icon", { key: '2676c22599c2df06eb8cc4bb1fa425e702166e11', icon: this.getInputIcon(), customClass: `text-2xl ${this.disabled ? 'text-icon-disabled' : 'text-icon-primary'}` })))), (this.helpText || this.maxLength) && !this.disabled && (h("div", { key: '77956a01dd5670649edbb65ada3e08831b6347dc', class: "flex justify-between items-center px-16 mt-4 text-sm" }, this.helpText && (h("div", { key: '7e2ac49e3a1e8cf596313d34f084ac2b2b209797', 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: '322b4c132531b57c7e503464d4bb6115311201b2', 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)))))));
|
|
108
|
+
}
|
|
109
|
+
static get is() { return "sula-textfield"; }
|
|
110
|
+
static get encapsulation() { return "shadow"; }
|
|
111
|
+
static get originalStyleUrls() {
|
|
112
|
+
return {
|
|
113
|
+
"$": ["sula-textfield.scss"]
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
static get styleUrls() {
|
|
117
|
+
return {
|
|
118
|
+
"$": ["sula-textfield.css"]
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
static get properties() {
|
|
122
|
+
return {
|
|
123
|
+
"value": {
|
|
124
|
+
"type": "string",
|
|
125
|
+
"mutable": true,
|
|
126
|
+
"complexType": {
|
|
127
|
+
"original": "string",
|
|
128
|
+
"resolved": "string",
|
|
129
|
+
"references": {}
|
|
130
|
+
},
|
|
131
|
+
"required": false,
|
|
132
|
+
"optional": true,
|
|
133
|
+
"docs": {
|
|
134
|
+
"tags": [],
|
|
135
|
+
"text": "Value for the input."
|
|
136
|
+
},
|
|
137
|
+
"getter": false,
|
|
138
|
+
"setter": false,
|
|
139
|
+
"attribute": "value",
|
|
140
|
+
"reflect": false
|
|
141
|
+
},
|
|
142
|
+
"type": {
|
|
143
|
+
"type": "string",
|
|
144
|
+
"mutable": false,
|
|
145
|
+
"complexType": {
|
|
146
|
+
"original": "SulaTextfieldType",
|
|
147
|
+
"resolved": "SulaTextfieldType.Password | SulaTextfieldType.Text",
|
|
148
|
+
"references": {
|
|
149
|
+
"SulaTextfieldType": {
|
|
150
|
+
"location": "import",
|
|
151
|
+
"path": "./model/sula-textfield.model",
|
|
152
|
+
"id": "src/components/sula-textfield/model/sula-textfield.model.ts::SulaTextfieldType"
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
"required": false,
|
|
157
|
+
"optional": false,
|
|
158
|
+
"docs": {
|
|
159
|
+
"tags": [],
|
|
160
|
+
"text": "The textfield type"
|
|
161
|
+
},
|
|
162
|
+
"getter": false,
|
|
163
|
+
"setter": false,
|
|
164
|
+
"attribute": "type",
|
|
165
|
+
"reflect": false,
|
|
166
|
+
"defaultValue": "SulaTextfieldType.Text"
|
|
167
|
+
},
|
|
168
|
+
"status": {
|
|
169
|
+
"type": "string",
|
|
170
|
+
"mutable": true,
|
|
171
|
+
"complexType": {
|
|
172
|
+
"original": "SulaTextfieldStatus",
|
|
173
|
+
"resolved": "SulaTextfieldStatus.Default | SulaTextfieldStatus.Error",
|
|
174
|
+
"references": {
|
|
175
|
+
"SulaTextfieldStatus": {
|
|
176
|
+
"location": "import",
|
|
177
|
+
"path": "./model/sula-textfield.model",
|
|
178
|
+
"id": "src/components/sula-textfield/model/sula-textfield.model.ts::SulaTextfieldStatus"
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
"required": false,
|
|
183
|
+
"optional": false,
|
|
184
|
+
"docs": {
|
|
185
|
+
"tags": [],
|
|
186
|
+
"text": "The textfield status"
|
|
187
|
+
},
|
|
188
|
+
"getter": false,
|
|
189
|
+
"setter": false,
|
|
190
|
+
"attribute": "status",
|
|
191
|
+
"reflect": false,
|
|
192
|
+
"defaultValue": "SulaTextfieldStatus.Default"
|
|
193
|
+
},
|
|
194
|
+
"label": {
|
|
195
|
+
"type": "string",
|
|
196
|
+
"mutable": false,
|
|
197
|
+
"complexType": {
|
|
198
|
+
"original": "string",
|
|
199
|
+
"resolved": "string",
|
|
200
|
+
"references": {}
|
|
201
|
+
},
|
|
202
|
+
"required": false,
|
|
203
|
+
"optional": false,
|
|
204
|
+
"docs": {
|
|
205
|
+
"tags": [],
|
|
206
|
+
"text": "The textfield label"
|
|
207
|
+
},
|
|
208
|
+
"getter": false,
|
|
209
|
+
"setter": false,
|
|
210
|
+
"attribute": "label",
|
|
211
|
+
"reflect": false
|
|
212
|
+
},
|
|
213
|
+
"placeholder": {
|
|
214
|
+
"type": "string",
|
|
215
|
+
"mutable": false,
|
|
216
|
+
"complexType": {
|
|
217
|
+
"original": "string",
|
|
218
|
+
"resolved": "string",
|
|
219
|
+
"references": {}
|
|
220
|
+
},
|
|
221
|
+
"required": false,
|
|
222
|
+
"optional": false,
|
|
223
|
+
"docs": {
|
|
224
|
+
"tags": [],
|
|
225
|
+
"text": "The textfield placeholder"
|
|
226
|
+
},
|
|
227
|
+
"getter": false,
|
|
228
|
+
"setter": false,
|
|
229
|
+
"attribute": "placeholder",
|
|
230
|
+
"reflect": false
|
|
231
|
+
},
|
|
232
|
+
"disabled": {
|
|
233
|
+
"type": "boolean",
|
|
234
|
+
"mutable": true,
|
|
235
|
+
"complexType": {
|
|
236
|
+
"original": "boolean",
|
|
237
|
+
"resolved": "boolean",
|
|
238
|
+
"references": {}
|
|
239
|
+
},
|
|
240
|
+
"required": false,
|
|
241
|
+
"optional": false,
|
|
242
|
+
"docs": {
|
|
243
|
+
"tags": [],
|
|
244
|
+
"text": "The textfield is disabled"
|
|
245
|
+
},
|
|
246
|
+
"getter": false,
|
|
247
|
+
"setter": false,
|
|
248
|
+
"attribute": "disabled",
|
|
249
|
+
"reflect": false
|
|
250
|
+
},
|
|
251
|
+
"helpText": {
|
|
252
|
+
"type": "string",
|
|
253
|
+
"mutable": false,
|
|
254
|
+
"complexType": {
|
|
255
|
+
"original": "string",
|
|
256
|
+
"resolved": "string",
|
|
257
|
+
"references": {}
|
|
258
|
+
},
|
|
259
|
+
"required": false,
|
|
260
|
+
"optional": true,
|
|
261
|
+
"docs": {
|
|
262
|
+
"tags": [],
|
|
263
|
+
"text": "The help text for textfield"
|
|
264
|
+
},
|
|
265
|
+
"getter": false,
|
|
266
|
+
"setter": false,
|
|
267
|
+
"attribute": "help-text",
|
|
268
|
+
"reflect": false
|
|
269
|
+
},
|
|
270
|
+
"maxLength": {
|
|
271
|
+
"type": "number",
|
|
272
|
+
"mutable": false,
|
|
273
|
+
"complexType": {
|
|
274
|
+
"original": "number",
|
|
275
|
+
"resolved": "number",
|
|
276
|
+
"references": {}
|
|
277
|
+
},
|
|
278
|
+
"required": false,
|
|
279
|
+
"optional": true,
|
|
280
|
+
"docs": {
|
|
281
|
+
"tags": [],
|
|
282
|
+
"text": "The textfield max length"
|
|
283
|
+
},
|
|
284
|
+
"getter": false,
|
|
285
|
+
"setter": false,
|
|
286
|
+
"attribute": "max-length",
|
|
287
|
+
"reflect": false
|
|
288
|
+
},
|
|
289
|
+
"icon": {
|
|
290
|
+
"type": "string",
|
|
291
|
+
"mutable": false,
|
|
292
|
+
"complexType": {
|
|
293
|
+
"original": "string",
|
|
294
|
+
"resolved": "string",
|
|
295
|
+
"references": {}
|
|
296
|
+
},
|
|
297
|
+
"required": false,
|
|
298
|
+
"optional": true,
|
|
299
|
+
"docs": {
|
|
300
|
+
"tags": [],
|
|
301
|
+
"text": "The textfield icon"
|
|
302
|
+
},
|
|
303
|
+
"getter": false,
|
|
304
|
+
"setter": false,
|
|
305
|
+
"attribute": "icon",
|
|
306
|
+
"reflect": false
|
|
307
|
+
}
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
static get states() {
|
|
311
|
+
return {
|
|
312
|
+
"inputIsOpen": {},
|
|
313
|
+
"textValue": {},
|
|
314
|
+
"showPassword": {},
|
|
315
|
+
"inputIsFocused": {}
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
static get events() {
|
|
319
|
+
return [{
|
|
320
|
+
"method": "valueChanged",
|
|
321
|
+
"name": "valueChanged",
|
|
322
|
+
"bubbles": true,
|
|
323
|
+
"cancelable": true,
|
|
324
|
+
"composed": true,
|
|
325
|
+
"docs": {
|
|
326
|
+
"tags": [],
|
|
327
|
+
"text": "Event emitted when input value changes."
|
|
328
|
+
},
|
|
329
|
+
"complexType": {
|
|
330
|
+
"original": "string",
|
|
331
|
+
"resolved": "string",
|
|
332
|
+
"references": {}
|
|
333
|
+
}
|
|
334
|
+
}, {
|
|
335
|
+
"method": "focusedOn",
|
|
336
|
+
"name": "focusedOn",
|
|
337
|
+
"bubbles": true,
|
|
338
|
+
"cancelable": true,
|
|
339
|
+
"composed": true,
|
|
340
|
+
"docs": {
|
|
341
|
+
"tags": [],
|
|
342
|
+
"text": "Event emitted when input is focused."
|
|
343
|
+
},
|
|
344
|
+
"complexType": {
|
|
345
|
+
"original": "void",
|
|
346
|
+
"resolved": "void",
|
|
347
|
+
"references": {}
|
|
348
|
+
}
|
|
349
|
+
}, {
|
|
350
|
+
"method": "focusedOut",
|
|
351
|
+
"name": "focusedOut",
|
|
352
|
+
"bubbles": true,
|
|
353
|
+
"cancelable": true,
|
|
354
|
+
"composed": true,
|
|
355
|
+
"docs": {
|
|
356
|
+
"tags": [],
|
|
357
|
+
"text": "Event emitted when input is focused out."
|
|
358
|
+
},
|
|
359
|
+
"complexType": {
|
|
360
|
+
"original": "void",
|
|
361
|
+
"resolved": "void",
|
|
362
|
+
"references": {}
|
|
363
|
+
}
|
|
364
|
+
}];
|
|
365
|
+
}
|
|
366
|
+
static get listeners() {
|
|
367
|
+
return [{
|
|
368
|
+
"name": "click",
|
|
369
|
+
"method": "handleClick",
|
|
370
|
+
"target": "document",
|
|
371
|
+
"capture": false,
|
|
372
|
+
"passive": false
|
|
373
|
+
}];
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
//# sourceMappingURL=sula-textfield.js.map
|
|
@@ -0,0 +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,CAAC,EAAE,MAAM,eAAe,CAAC;AAC7F,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAOtF,MAAM,OAAO,aAAa;IAL1B;QAYE;;WAEG;QACK,SAAI,GAAsB,iBAAiB,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O,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, h } from '@stencil/core';\nimport { SulaTextfieldStatus, SulaTextfieldType } from './model/sula-textfield.model';\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 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 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) 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.textValue && this.textValue.trim().length > 0) {\n this.changeElementsStyle();\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 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 this.textValue = 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 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\"\n onInput={this.handleInputChanges}\n onFocus={this.handleInputFocus}\n value={this.value}\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 id=\"textfield-help-text\" class={{ 'text-text-primary': this.status === SulaTextfieldStatus.Default, 'text-feedback-error': this.status === SulaTextfieldStatus.Error }}>\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"]}
|