@sula-tech/webcomponents 0.7.6 → 0.9.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-Bbryl0vg.js → index-LR6yFDX7.js} +16 -2
- package/dist/cjs/index-LR6yFDX7.js.map +1 -0
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/{sula-avatar_18.cjs.entry.js → sula-avatar_19.cjs.entry.js} +612 -45
- package/dist/cjs/sula-avatar_19.cjs.entry.js.map +1 -0
- package/dist/cjs/webcomponents.cjs.js +2 -2
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/sula-button/sula-button.css +1 -1
- package/dist/collection/components/sula-chip/sula-chip.css +1 -1
- package/dist/collection/components/sula-dropdown/sula-dropdown.css +1 -1
- package/dist/collection/components/sula-dropdown/sula-dropdown.js +74 -9
- package/dist/collection/components/sula-dropdown/sula-dropdown.js.map +1 -1
- package/dist/collection/components/sula-dropdown/sula-dropdown.stories.js +53 -0
- package/dist/collection/components/sula-dropdown/sula-dropdown.stories.js.map +1 -1
- package/dist/collection/components/sula-icon/sula-icon.css +1 -1
- package/dist/collection/components/sula-icon/sula-icon.js +1 -1
- package/dist/collection/components/sula-loader/sula-loader.css +1 -1
- package/dist/collection/components/sula-loader/sula-loader.js +1 -1
- package/dist/collection/components/sula-menu-select-list/sula-menu-select-list.css +1 -1
- package/dist/collection/components/sula-menu-select-list/sula-menu-select-list.js +33 -2
- package/dist/collection/components/sula-menu-select-list/sula-menu-select-list.js.map +1 -1
- package/dist/collection/components/sula-modal/model/sula-modal.model.js +16 -0
- package/dist/collection/components/sula-modal/model/sula-modal.model.js.map +1 -0
- package/dist/collection/components/sula-modal/sula-modal.css +1 -0
- package/dist/collection/components/sula-modal/sula-modal.js +558 -0
- package/dist/collection/components/sula-modal/sula-modal.js.map +1 -0
- package/dist/collection/components/sula-modal/sula-modal.stories.js +193 -0
- package/dist/collection/components/sula-modal/sula-modal.stories.js.map +1 -0
- package/dist/collection/components/sula-progress-bar/sula-progress-bar.js +2 -2
- package/dist/collection/components/sula-radio-button/sula-radio-button.js +2 -2
- package/dist/collection/components/sula-search-bar/sula-search-bar.js +2 -2
- package/dist/collection/components/sula-switch/sula-switch.js +4 -4
- package/dist/collection/components/sula-tag/sula-tag.js +3 -3
- package/dist/collection/components/sula-textarea/sula-textarea.js +6 -6
- package/dist/collection/components/sula-textfield/sula-textfield.js +31 -2
- package/dist/collection/components/sula-textfield/sula-textfield.js.map +1 -1
- package/dist/collection/components/sula-textfield/sula-textfield.stories.js +22 -0
- package/dist/collection/components/sula-textfield/sula-textfield.stories.js.map +1 -1
- package/dist/collection/components/sula-tiles/sula-tiles.js +1 -1
- package/dist/collection/components/sula-timeline-list/sula-timeline-list.js +1 -1
- package/dist/components/index.js +19 -0
- package/dist/components/index.js.map +1 -1
- package/dist/components/p-B85MJLTf.js +8 -0
- package/dist/components/p-B85MJLTf.js.map +1 -0
- package/dist/components/p-BhxK9El6.js +231 -0
- package/dist/components/p-BhxK9El6.js.map +1 -0
- package/dist/components/{p-DoGc7jLn.js → p-CyIObO0v.js} +5 -8
- package/dist/components/p-CyIObO0v.js.map +1 -0
- package/dist/components/{p-BNtk_d_S.js → p-DvWN7hVP.js} +14 -6
- package/dist/components/p-DvWN7hVP.js.map +1 -0
- package/dist/components/{p-BrY8WoEl.js → p-ff6chV3i.js} +4 -4
- package/dist/components/{p-BrY8WoEl.js.map → p-ff6chV3i.js.map} +1 -1
- package/dist/components/sula-avatar.js +1 -1
- package/dist/components/sula-badge.js +1 -1
- package/dist/components/sula-button.js +1 -226
- package/dist/components/sula-button.js.map +1 -1
- package/dist/components/sula-checkbox.js +1 -1
- package/dist/components/sula-chip.js +3 -3
- package/dist/components/sula-chip.js.map +1 -1
- package/dist/components/sula-dropdown.js +60 -14
- package/dist/components/sula-dropdown.js.map +1 -1
- package/dist/components/sula-icon.js +1 -1
- package/dist/components/sula-loader.js +1 -1
- package/dist/components/sula-menu-select-list.js +1 -1
- package/dist/components/sula-modal.d.ts +11 -0
- package/dist/components/sula-modal.js +332 -0
- package/dist/components/sula-modal.js.map +1 -0
- package/dist/components/sula-progress-bar.js +3 -3
- package/dist/components/sula-radio-button.js +2 -2
- package/dist/components/sula-search-bar.js +3 -3
- package/dist/components/sula-switch.js +4 -4
- package/dist/components/sula-tag.js +4 -4
- package/dist/components/sula-textarea.js +6 -6
- package/dist/components/sula-textfield.js +249 -3
- package/dist/components/sula-textfield.js.map +1 -1
- package/dist/components/sula-tiles.js +2 -2
- package/dist/components/sula-timeline-list.js +2 -2
- package/dist/esm/{index-or7qTZgT.js → index-CrFclBiX.js} +16 -2
- package/dist/esm/index-CrFclBiX.js.map +1 -0
- package/dist/esm/loader.js +3 -3
- package/dist/esm/{sula-avatar_18.entry.js → sula-avatar_19.entry.js} +612 -46
- package/dist/esm/sula-avatar_19.entry.js.map +1 -0
- package/dist/esm/webcomponents.js +3 -3
- package/dist/types/components/sula-dropdown/sula-dropdown.d.ts +11 -0
- package/dist/types/components/sula-dropdown/sula-dropdown.stories.d.ts +10 -0
- package/dist/types/components/sula-menu-select-list/sula-menu-select-list.d.ts +4 -0
- package/dist/types/components/sula-modal/model/sula-modal.model.d.ts +13 -0
- package/dist/types/components/sula-modal/sula-modal.d.ts +94 -0
- package/dist/types/components/sula-modal/sula-modal.stories.d.ts +83 -0
- package/dist/types/components/sula-textfield/sula-textfield.d.ts +7 -0
- package/dist/types/components/sula-textfield/sula-textfield.stories.d.ts +9 -0
- package/dist/types/components.d.ts +178 -0
- package/dist/webcomponents/{p-or7qTZgT.js → p-CrFclBiX.js} +28 -16
- package/dist/webcomponents/p-CrFclBiX.js.map +1 -0
- package/dist/webcomponents/{p-af46ad3b.entry.js → p-e4fa59d5.entry.js} +854 -285
- package/dist/webcomponents/p-e4fa59d5.entry.js.map +1 -0
- package/dist/webcomponents/webcomponents.esm.js +42 -20
- package/package.json +4 -4
- package/dist/cjs/index-Bbryl0vg.js.map +0 -1
- package/dist/cjs/sula-avatar_18.cjs.entry.js.map +0 -1
- package/dist/components/p-BNtk_d_S.js.map +0 -1
- package/dist/components/p-DoGc7jLn.js.map +0 -1
- package/dist/esm/index-or7qTZgT.js.map +0 -1
- package/dist/esm/sula-avatar_18.entry.js.map +0 -1
- package/dist/webcomponents/p-af46ad3b.entry.js.map +0 -1
- package/dist/webcomponents/p-or7qTZgT.js.map +0 -1
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { SulaModalType, SulaModalSlotOverflow } from "./model/sula-modal.model";
|
|
2
|
+
export default {
|
|
3
|
+
title: 'Components/sula-modal',
|
|
4
|
+
tags: ['autodocs'],
|
|
5
|
+
argTypes: {
|
|
6
|
+
opened: {
|
|
7
|
+
control: 'boolean',
|
|
8
|
+
description: 'Controla se a modal está aberta',
|
|
9
|
+
},
|
|
10
|
+
type: {
|
|
11
|
+
control: { type: 'select' },
|
|
12
|
+
options: Object.values(SulaModalType),
|
|
13
|
+
},
|
|
14
|
+
modalTitle: {
|
|
15
|
+
control: 'text',
|
|
16
|
+
description: 'Título da modal',
|
|
17
|
+
},
|
|
18
|
+
subTitle: {
|
|
19
|
+
control: 'text',
|
|
20
|
+
description: 'Subtítulo da modal',
|
|
21
|
+
},
|
|
22
|
+
headerIcon: {
|
|
23
|
+
control: 'text',
|
|
24
|
+
description: 'Ícone do header',
|
|
25
|
+
},
|
|
26
|
+
promoImage: {
|
|
27
|
+
control: 'text',
|
|
28
|
+
description: 'URL da imagem promocional (para modal promo)',
|
|
29
|
+
},
|
|
30
|
+
primaryButtonText: {
|
|
31
|
+
control: 'text',
|
|
32
|
+
description: 'Texto do botão primário',
|
|
33
|
+
},
|
|
34
|
+
secondaryButtonText: {
|
|
35
|
+
control: 'text',
|
|
36
|
+
description: 'Texto do botão secundário',
|
|
37
|
+
},
|
|
38
|
+
slotOverflow: {
|
|
39
|
+
control: { type: 'select' },
|
|
40
|
+
options: Object.values(SulaModalSlotOverflow),
|
|
41
|
+
},
|
|
42
|
+
blockBodyScroll: {
|
|
43
|
+
control: 'boolean',
|
|
44
|
+
description: 'Bloqueia o scroll do body',
|
|
45
|
+
},
|
|
46
|
+
closeOnClickOutside: {
|
|
47
|
+
control: 'boolean',
|
|
48
|
+
description: 'Fecha ao clicar fora',
|
|
49
|
+
},
|
|
50
|
+
modalClosed: {
|
|
51
|
+
action: 'modalClosed',
|
|
52
|
+
description: 'Evento emitido ao fechar a modal',
|
|
53
|
+
},
|
|
54
|
+
primaryButtonClicked: {
|
|
55
|
+
action: 'primaryButtonClicked',
|
|
56
|
+
description: 'Evento emitido ao clicar no botão primário',
|
|
57
|
+
},
|
|
58
|
+
secondaryButtonClicked: {
|
|
59
|
+
action: 'secondaryButtonClicked',
|
|
60
|
+
description: 'Evento emitido ao clicar no botão secundário',
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
parameters: {
|
|
64
|
+
docs: {
|
|
65
|
+
description: {
|
|
66
|
+
component: `
|
|
67
|
+
O componente **Sula Modal** é utilizado para exibir conteúdos em destaque sobrepostos à interface principal.
|
|
68
|
+
### Características principais:
|
|
69
|
+
- Suporte a diferentes tipos de modal (alerta, custom, promo, side, etc)
|
|
70
|
+
- Título, subtítulo, ícone e imagem promocional
|
|
71
|
+
- Botões primário e secundário
|
|
72
|
+
- Controle de overflow e scroll
|
|
73
|
+
- Eventos de fechamento e clique nos botões
|
|
74
|
+
`,
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
const Template = args => {
|
|
80
|
+
const container = document.createElement('div');
|
|
81
|
+
container.style.margin = '20px';
|
|
82
|
+
container.style.display = 'flex';
|
|
83
|
+
container.style.alignItems = 'center';
|
|
84
|
+
container.style.justifyContent = 'center';
|
|
85
|
+
container.style.minHeight = '80vh';
|
|
86
|
+
const el = document.createElement('sula-modal');
|
|
87
|
+
el.setAttribute('opened', args.opened ? 'true' : 'false');
|
|
88
|
+
el.setAttribute('type', args.type);
|
|
89
|
+
if (args.modalTitle)
|
|
90
|
+
el.setAttribute('modal-title', args.modalTitle);
|
|
91
|
+
if (args.subTitle)
|
|
92
|
+
el.setAttribute('sub-title', args.subTitle);
|
|
93
|
+
if (args.headerIcon)
|
|
94
|
+
el.setAttribute('header-icon', args.headerIcon);
|
|
95
|
+
if (args.promoImage)
|
|
96
|
+
el.setAttribute('promo-image', args.promoImage);
|
|
97
|
+
if (args.primaryButtonText)
|
|
98
|
+
el.setAttribute('primary-button-text', args.primaryButtonText);
|
|
99
|
+
if (args.secondaryButtonText)
|
|
100
|
+
el.setAttribute('secondary-button-text', args.secondaryButtonText);
|
|
101
|
+
el.setAttribute('slot-overflow', args.slotOverflow);
|
|
102
|
+
el.setAttribute('block-body-scroll', args.blockBodyScroll ? 'true' : 'false');
|
|
103
|
+
el.setAttribute('close-on-click-outside', args.closeOnClickOutside ? 'true' : 'false');
|
|
104
|
+
el.addEventListener('modalClosed', args.modalClosed);
|
|
105
|
+
el.addEventListener('primaryButtonClicked', args.primaryButtonClicked);
|
|
106
|
+
el.addEventListener('secondaryButtonClicked', args.secondaryButtonClicked);
|
|
107
|
+
// Conteúdo customizável para slot
|
|
108
|
+
if (args.slotContent) {
|
|
109
|
+
const slotDiv = document.createElement('div');
|
|
110
|
+
slotDiv.innerHTML = args.slotContent;
|
|
111
|
+
el.appendChild(slotDiv);
|
|
112
|
+
}
|
|
113
|
+
container.appendChild(el);
|
|
114
|
+
return container;
|
|
115
|
+
};
|
|
116
|
+
export const Playground = Template.bind({});
|
|
117
|
+
Playground.args = {
|
|
118
|
+
opened: true,
|
|
119
|
+
type: SulaModalType.Custom,
|
|
120
|
+
modalTitle: 'Título da Modal',
|
|
121
|
+
subTitle: 'Subtítulo explicativo',
|
|
122
|
+
headerIcon: 'ph ph-info',
|
|
123
|
+
primaryButtonText: 'Confirmar',
|
|
124
|
+
secondaryButtonText: 'Cancelar',
|
|
125
|
+
slotOverflow: SulaModalSlotOverflow.Auto,
|
|
126
|
+
blockBodyScroll: true,
|
|
127
|
+
closeOnClickOutside: true,
|
|
128
|
+
slotContent: '<p>Conteúdo customizável da modal.</p>',
|
|
129
|
+
};
|
|
130
|
+
export const AlertType = Template.bind({});
|
|
131
|
+
AlertType.args = Object.assign(Object.assign({}, Playground.args), { type: SulaModalType.Alert, modalTitle: 'Atenção', subTitle: 'Esta é uma modal de alerta.', headerIcon: 'ph ph-warning', primaryButtonText: 'OK', secondaryButtonText: '', slotContent: '' });
|
|
132
|
+
AlertType.parameters = {
|
|
133
|
+
docs: {
|
|
134
|
+
description: {
|
|
135
|
+
story: 'Modal do tipo alerta, com ícone e botão primário.',
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
export const PromoType = Template.bind({});
|
|
140
|
+
PromoType.args = Object.assign(Object.assign({}, Playground.args), { type: SulaModalType.Promo, promoImage: 'https://picsum.photos/600/800', modalTitle: 'Promoção Especial', subTitle: 'Aproveite esta oferta!', slotContent: '<p>Conteúdo promocional.</p>' });
|
|
141
|
+
PromoType.parameters = {
|
|
142
|
+
docs: {
|
|
143
|
+
description: {
|
|
144
|
+
story: 'Modal promocional com imagem e conteúdo customizável.',
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
};
|
|
148
|
+
export const SideType = Template.bind({});
|
|
149
|
+
SideType.args = Object.assign(Object.assign({}, Playground.args), { type: SulaModalType.Side, modalTitle: 'Menu Lateral', subTitle: '', slotContent: '<ul><li>Item 1</li><li>Item 2</li></ul>' });
|
|
150
|
+
SideType.parameters = {
|
|
151
|
+
docs: {
|
|
152
|
+
description: {
|
|
153
|
+
story: 'Modal lateral (side modal) para navegação ou menus.',
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
};
|
|
157
|
+
export const ListType = Template.bind({});
|
|
158
|
+
ListType.args = Object.assign(Object.assign({}, Playground.args), { type: SulaModalType.List, modalTitle: 'Lista de Itens', subTitle: 'Modal para exibir listas.', slotContent: '<ol><li>Primeiro item</li><li>Segundo item</li><li>Terceiro item</li></ol>' });
|
|
159
|
+
ListType.parameters = {
|
|
160
|
+
docs: {
|
|
161
|
+
description: {
|
|
162
|
+
story: 'Modal do tipo lista, ideal para exibir listas de itens.',
|
|
163
|
+
},
|
|
164
|
+
},
|
|
165
|
+
};
|
|
166
|
+
export const CustomFullType = Template.bind({});
|
|
167
|
+
CustomFullType.args = Object.assign(Object.assign({}, Playground.args), { type: SulaModalType.CustomFull, modalTitle: 'Modal Custom Full', subTitle: 'Modal customizada em tela cheia.', slotContent: '<div style="height:300px;display:flex;align-items:center;justify-content:center"><h2>Conteúdo Full</h2></div>' });
|
|
168
|
+
CustomFullType.parameters = {
|
|
169
|
+
docs: {
|
|
170
|
+
description: {
|
|
171
|
+
story: 'Modal customizada ocupando toda a tela.',
|
|
172
|
+
},
|
|
173
|
+
},
|
|
174
|
+
};
|
|
175
|
+
export const SpecialSideType = Template.bind({});
|
|
176
|
+
SpecialSideType.args = Object.assign(Object.assign({}, Playground.args), { type: SulaModalType.SpecialSide, modalTitle: 'Modal Lateral Especial', subTitle: 'Modal lateral com layout especial.', promoImage: 'https://picsum.photos/1920/1080', slotContent: '<div style="padding:24px"><h3>Conteúdo Especial</h3><p>Layout diferenciado para casos especiais.</p></div>' });
|
|
177
|
+
SpecialSideType.parameters = {
|
|
178
|
+
docs: {
|
|
179
|
+
description: {
|
|
180
|
+
story: 'Modal lateral especial para layouts diferenciados.',
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
};
|
|
184
|
+
export const WithCustomSlot = Template.bind({});
|
|
185
|
+
WithCustomSlot.args = Object.assign(Object.assign({}, Playground.args), { type: SulaModalType.Custom, slotContent: '<div style="padding:16px"><h3>Slot Customizado</h3><p>Qualquer conteúdo pode ser inserido aqui.</p></div>' });
|
|
186
|
+
WithCustomSlot.parameters = {
|
|
187
|
+
docs: {
|
|
188
|
+
description: {
|
|
189
|
+
story: 'Exemplo de modal custom com conteúdo via slot.',
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
};
|
|
193
|
+
//# sourceMappingURL=sula-modal.stories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sula-modal.stories.js","sourceRoot":"","sources":["../../../src/components/sula-modal/sula-modal.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEhF,eAAe;IACb,KAAK,EAAE,uBAAuB;IAC9B,IAAI,EAAE,CAAC,UAAU,CAAC;IAClB,QAAQ,EAAE;QACR,MAAM,EAAE;YACN,OAAO,EAAE,SAAS;YAClB,WAAW,EAAE,iCAAiC;SAC/C;QACD,IAAI,EAAE;YACJ,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YAC3B,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC;SACtC;QACD,UAAU,EAAE;YACV,OAAO,EAAE,MAAM;YACf,WAAW,EAAE,iBAAiB;SAC/B;QACD,QAAQ,EAAE;YACR,OAAO,EAAE,MAAM;YACf,WAAW,EAAE,oBAAoB;SAClC;QACD,UAAU,EAAE;YACV,OAAO,EAAE,MAAM;YACf,WAAW,EAAE,iBAAiB;SAC/B;QACD,UAAU,EAAE;YACV,OAAO,EAAE,MAAM;YACf,WAAW,EAAE,8CAA8C;SAC5D;QACD,iBAAiB,EAAE;YACjB,OAAO,EAAE,MAAM;YACf,WAAW,EAAE,yBAAyB;SACvC;QACD,mBAAmB,EAAE;YACnB,OAAO,EAAE,MAAM;YACf,WAAW,EAAE,2BAA2B;SACzC;QACD,YAAY,EAAE;YACZ,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YAC3B,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,qBAAqB,CAAC;SAC9C;QACD,eAAe,EAAE;YACf,OAAO,EAAE,SAAS;YAClB,WAAW,EAAE,2BAA2B;SACzC;QACD,mBAAmB,EAAE;YACnB,OAAO,EAAE,SAAS;YAClB,WA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,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACjD,eAAe,CAAC,IAAI,mCACf,UAAU,CAAC,IAAI,KAClB,IAAI,EAAE,aAAa,CAAC,WAAW,EAC/B,UAAU,EAAE,wBAAwB,EACpC,QAAQ,EAAE,oCAAoC,EAC9C,UAAU,EAAE,iCAAiC,EAC7C,WAAW,EAAE,4GAA4G,GAC1H,CAAC;AACF,eAAe,CAAC,UAAU,GAAG;IAC3B,IAAI,EAAE;QACJ,WAAW,EAAE;YACX,KAAK,EAAE,oDAAoD;SAC5D;KACF;CACF,CAAC;AACF,MAAM,CAAC,MAAM,cAAc,GAAG,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAChD,cAAc,CAAC,IAAI,mCACd,UAAU,CAAC,IAAI,KAClB,IAAI,EAAE,aAAa,CAAC,MAAM,EAC1B,WAAW,EAAE,2GAA2G,GACzH,CAAC;AACF,cAAc,CAAC,UAAU,GAAG;IAC1B,IAAI,EAAE;QACJ,WAAW,EAAE;YACX,KAAK,EAAE,gDAAgD;SACxD;KACF;CACF,CAAC","sourcesContent":["import { SulaModalType, SulaModalSlotOverflow } from './model/sula-modal.model';\n\nexport default {\n title: 'Components/sula-modal',\n tags: ['autodocs'],\n argTypes: {\n opened: {\n control: 'boolean',\n description: 'Controla se a modal está aberta',\n },\n type: {\n control: { type: 'select' },\n options: Object.values(SulaModalType),\n },\n modalTitle: {\n control: 'text',\n description: 'Título da modal',\n },\n subTitle: {\n control: 'text',\n description: 'Subtítulo da modal',\n },\n headerIcon: {\n control: 'text',\n description: 'Ícone do header',\n },\n promoImage: {\n control: 'text',\n description: 'URL da imagem promocional (para modal promo)',\n },\n primaryButtonText: {\n control: 'text',\n description: 'Texto do botão primário',\n },\n secondaryButtonText: {\n control: 'text',\n description: 'Texto do botão secundário',\n },\n slotOverflow: {\n control: { type: 'select' },\n options: Object.values(SulaModalSlotOverflow),\n },\n blockBodyScroll: {\n control: 'boolean',\n description: 'Bloqueia o scroll do body',\n },\n closeOnClickOutside: {\n control: 'boolean',\n description: 'Fecha ao clicar fora',\n },\n modalClosed: {\n action: 'modalClosed',\n description: 'Evento emitido ao fechar a modal',\n },\n primaryButtonClicked: {\n action: 'primaryButtonClicked',\n description: 'Evento emitido ao clicar no botão primário',\n },\n secondaryButtonClicked: {\n action: 'secondaryButtonClicked',\n description: 'Evento emitido ao clicar no botão secundário',\n },\n },\n parameters: {\n docs: {\n description: {\n component: `\nO componente **Sula Modal** é utilizado para exibir conteúdos em destaque sobrepostos à interface principal.\n### Características principais:\n - Suporte a diferentes tipos de modal (alerta, custom, promo, side, etc)\n - Título, subtítulo, ícone e imagem promocional\n - Botões primário e secundário\n - Controle de overflow e scroll\n - Eventos de fechamento e clique nos botões\n\t\t\t\t`,\n },\n },\n },\n};\n\nconst Template = args => {\n const container = document.createElement('div');\n container.style.margin = '20px';\n container.style.display = 'flex';\n container.style.alignItems = 'center';\n container.style.justifyContent = 'center';\n container.style.minHeight = '80vh';\n const el = document.createElement('sula-modal');\n\n el.setAttribute('opened', args.opened ? 'true' : 'false');\n el.setAttribute('type', args.type);\n if (args.modalTitle) el.setAttribute('modal-title', args.modalTitle);\n if (args.subTitle) el.setAttribute('sub-title', args.subTitle);\n if (args.headerIcon) el.setAttribute('header-icon', args.headerIcon);\n if (args.promoImage) el.setAttribute('promo-image', args.promoImage);\n if (args.primaryButtonText) el.setAttribute('primary-button-text', args.primaryButtonText);\n if (args.secondaryButtonText) el.setAttribute('secondary-button-text', args.secondaryButtonText);\n el.setAttribute('slot-overflow', args.slotOverflow);\n el.setAttribute('block-body-scroll', args.blockBodyScroll ? 'true' : 'false');\n el.setAttribute('close-on-click-outside', args.closeOnClickOutside ? 'true' : 'false');\n\n el.addEventListener('modalClosed', args.modalClosed);\n el.addEventListener('primaryButtonClicked', args.primaryButtonClicked);\n el.addEventListener('secondaryButtonClicked', args.secondaryButtonClicked);\n\n // Conteúdo customizável para slot\n if (args.slotContent) {\n const slotDiv = document.createElement('div');\n slotDiv.innerHTML = args.slotContent;\n el.appendChild(slotDiv);\n }\n\n container.appendChild(el);\n return container;\n};\n\nexport const Playground = Template.bind({});\nPlayground.args = {\n opened: true,\n type: SulaModalType.Custom,\n modalTitle: 'Título da Modal',\n subTitle: 'Subtítulo explicativo',\n headerIcon: 'ph ph-info',\n primaryButtonText: 'Confirmar',\n secondaryButtonText: 'Cancelar',\n slotOverflow: SulaModalSlotOverflow.Auto,\n blockBodyScroll: true,\n closeOnClickOutside: true,\n slotContent: '<p>Conteúdo customizável da modal.</p>',\n};\nexport const AlertType = Template.bind({});\nAlertType.args = {\n ...Playground.args,\n type: SulaModalType.Alert,\n modalTitle: 'Atenção',\n subTitle: 'Esta é uma modal de alerta.',\n headerIcon: 'ph ph-warning',\n primaryButtonText: 'OK',\n secondaryButtonText: '',\n slotContent: '',\n};\nAlertType.parameters = {\n docs: {\n description: {\n story: 'Modal do tipo alerta, com ícone e botão primário.',\n },\n },\n};\nexport const PromoType = Template.bind({});\nPromoType.args = {\n ...Playground.args,\n type: SulaModalType.Promo,\n promoImage: 'https://picsum.photos/600/800',\n modalTitle: 'Promoção Especial',\n subTitle: 'Aproveite esta oferta!',\n slotContent: '<p>Conteúdo promocional.</p>',\n};\nPromoType.parameters = {\n docs: {\n description: {\n story: 'Modal promocional com imagem e conteúdo customizável.',\n },\n },\n};\nexport const SideType = Template.bind({});\nSideType.args = {\n ...Playground.args,\n type: SulaModalType.Side,\n modalTitle: 'Menu Lateral',\n subTitle: '',\n slotContent: '<ul><li>Item 1</li><li>Item 2</li></ul>',\n};\nSideType.parameters = {\n docs: {\n description: {\n story: 'Modal lateral (side modal) para navegação ou menus.',\n },\n },\n};\n\nexport const ListType = Template.bind({});\nListType.args = {\n ...Playground.args,\n type: SulaModalType.List,\n modalTitle: 'Lista de Itens',\n subTitle: 'Modal para exibir listas.',\n slotContent: '<ol><li>Primeiro item</li><li>Segundo item</li><li>Terceiro item</li></ol>',\n};\nListType.parameters = {\n docs: {\n description: {\n story: 'Modal do tipo lista, ideal para exibir listas de itens.',\n },\n },\n};\n\nexport const CustomFullType = Template.bind({});\nCustomFullType.args = {\n ...Playground.args,\n type: SulaModalType.CustomFull,\n modalTitle: 'Modal Custom Full',\n subTitle: 'Modal customizada em tela cheia.',\n slotContent: '<div style=\"height:300px;display:flex;align-items:center;justify-content:center\"><h2>Conteúdo Full</h2></div>',\n};\nCustomFullType.parameters = {\n docs: {\n description: {\n story: 'Modal customizada ocupando toda a tela.',\n },\n },\n};\n\nexport const SpecialSideType = Template.bind({});\nSpecialSideType.args = {\n ...Playground.args,\n type: SulaModalType.SpecialSide,\n modalTitle: 'Modal Lateral Especial',\n subTitle: 'Modal lateral com layout especial.',\n promoImage: 'https://picsum.photos/1920/1080',\n slotContent: '<div style=\"padding:24px\"><h3>Conteúdo Especial</h3><p>Layout diferenciado para casos especiais.</p></div>',\n};\nSpecialSideType.parameters = {\n docs: {\n description: {\n story: 'Modal lateral especial para layouts diferenciados.',\n },\n },\n};\nexport const WithCustomSlot = Template.bind({});\nWithCustomSlot.args = {\n ...Playground.args,\n type: SulaModalType.Custom,\n slotContent: '<div style=\"padding:16px\"><h3>Slot Customizado</h3><p>Qualquer conteúdo pode ser inserido aqui.</p></div>',\n};\nWithCustomSlot.parameters = {\n docs: {\n description: {\n story: 'Exemplo de modal custom com conteúdo via slot.',\n },\n },\n};\n"]}
|
|
@@ -53,10 +53,10 @@ export class SulaProgressBar {
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
render() {
|
|
56
|
-
return (h(Host, { key: '
|
|
56
|
+
return (h(Host, { key: '5f7922714d99330253ee04dbfe197b8cffb60e33' }, h("div", { key: '5246d62bfcb514b5976d698bb07699e9df7ae864', class: "flex flex-col w-full space-y-8" }, h("div", { key: '5f46e226f9c515d0640bafb42bb882580254e747', class: "flex justify-between items-center" }, h("label", { key: 'f61b7f5a837961a03ea1e4e72d803831c40189c5', class: "text-sm text-text-secondary leading-[14px]" }, this.topLabel), this.getProgressBarStateElement()), h("div", { key: 'b8631511218ace18082299186507c924d34da696', style: { width: `${this.progress}%` }, class: {
|
|
57
57
|
'h-12 rounded-xxl': true,
|
|
58
58
|
[this.getProgressBarStyle()]: true,
|
|
59
|
-
} }), h("label", { key: '
|
|
59
|
+
} }), h("label", { key: '1d73f69f9868c2ae1be227d00c17b348021e1bb7', class: "text-sm text-text-secondary leading-[14px]" }, this.bottomLabel))));
|
|
60
60
|
}
|
|
61
61
|
static get is() { return "sula-progress-bar"; }
|
|
62
62
|
static get encapsulation() { return "shadow"; }
|
|
@@ -34,14 +34,14 @@ export class SulaRadioButton {
|
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
render() {
|
|
37
|
-
return (h(Host, { key: '
|
|
37
|
+
return (h(Host, { key: 'ec9162a63e7ef550bad0fac4f50201c545e36b7a' }, h("div", { key: '2acbb141714c47d79ef1517b25125d57d7773a43', class: { 'w-fit': true, 'flex items-center': !!this.label }, onClick: this.handleClick }, h("div", { key: 'fe8c9b23d3e43981e36d199e951128c07bfdef98', class: {
|
|
38
38
|
'min-w-[30px] min-h-[30px] rounded-full flex justify-center items-center outline-none': true,
|
|
39
39
|
'active:bg-states-empty-bg-pressed cursor-pointer': !this.disabled,
|
|
40
40
|
'bg-brand-primary': this.checked,
|
|
41
41
|
'border border-line-input': !this.checked,
|
|
42
42
|
'container-focus': this.radioIsFocus,
|
|
43
43
|
'bg-states-bg-disabled border-2 border-states-bg-disabled cursor-not-allowed': this.disabled,
|
|
44
|
-
}, tabIndex: 0, onFocus: this.handleFocus, onBlur: this.handleFocusOut }, this.checked && h("div", { key: '
|
|
44
|
+
}, tabIndex: 0, onFocus: this.handleFocus, onBlur: this.handleFocusOut }, this.checked && h("div", { key: 'e82a794f53e8771171008696a19c176594e36c29', class: "bg-transparent border-2 border-negative-negative-1 w-[18px] h-[18px] rounded-full" })), this.label && h("label", { key: '77844f1c95772931153a75298dc871f787e60dde', class: { 'ml-16 text-base text-text-primary': true, 'cursor-pointer': !this.disabled } }, this.label))));
|
|
45
45
|
}
|
|
46
46
|
static get is() { return "sula-radio-button"; }
|
|
47
47
|
static get encapsulation() { return "shadow"; }
|
|
@@ -43,11 +43,11 @@ export class SulaSearchBar {
|
|
|
43
43
|
return style[this.searchBarStyle];
|
|
44
44
|
}
|
|
45
45
|
render() {
|
|
46
|
-
return (h(Host, { key: '
|
|
46
|
+
return (h(Host, { key: '7ac3cb2028df077a2489a7343c7618f04976e211' }, h("div", { key: '720808c66eb0b5eeaaf38384e9c954ce2a2f42ff', class: {
|
|
47
47
|
'flex flex-row items-center space-x-12 px-16 rounded-xxl h-44 caret-brand-primary outline-none group': true,
|
|
48
48
|
[this.getStyleClass()]: true,
|
|
49
49
|
'search-bar-focus': this.isFocused,
|
|
50
|
-
}, tabIndex: 0, onFocus: this.handleInputFocus, onClick: this.handleInputFocus }, !this.isFocused && this.leftIcon && (h("div", { key: '
|
|
50
|
+
}, tabIndex: 0, onFocus: this.handleInputFocus, onClick: this.handleInputFocus }, !this.isFocused && this.leftIcon && (h("div", { key: '0d5668fc5b271feb3c7b5aea735652c2f2abdeb1', class: "flex justify-center items-center leading-6" }, h("sula-icon", { key: '0f61816afeef7db9f9c36fed903c87ea9d71edc5', icon: this.leftIcon, customClass: "text-2xl text-icon-primary group-hover:text-brand-primary" }))), h("input", { key: '27f2199404e9c197fb8d31cc8a8ab53c32f38c2e', ref: node => (this.inputElement = node), type: "text", class: "outline-none border-none w-full bg-transparent text-text-primary", placeholder: this.placeholder, onBlur: this.handleInputBlur, value: this.value, onInput: this.handleValueChanges }), this.rightIcon && (h("div", { key: 'c47335437563eb82df68215411f6add6f91c41a7', class: "flex justify-center items-center leading-6 cursor-pointer", onClick: this.handleRightIconClick, onMouseDown: e => e.preventDefault() }, h("sula-icon", { key: '83759286dee48cea835b9a16a970d4bc16c33f83', icon: this.rightIcon, customClass: "text-2xl text-icon-primary" }))))));
|
|
51
51
|
}
|
|
52
52
|
static get is() { return "sula-search-bar"; }
|
|
53
53
|
static get encapsulation() { return "shadow"; }
|
|
@@ -35,23 +35,23 @@ export class SulaSwitch {
|
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
37
|
render() {
|
|
38
|
-
return (h(Host, { key: '
|
|
38
|
+
return (h(Host, { key: 'bbc4902ea0d731995e0c8600243018a171b65120' }, h("div", { key: 'b7e277261642fb9c909a8549dfe7a6295cb4dc01', class: {
|
|
39
39
|
'outline-none': true,
|
|
40
40
|
'flex items-center space-x-12': !!this.label && this.type === SulaSwitchType.Default,
|
|
41
41
|
'flex items-center justify-between bg-surface-on-body rounded-md w-[280px] min-h-[85px] px-24 py-16': this.type === SulaSwitchType.List,
|
|
42
42
|
'hover:bg-states-empty-bg-hover active:bg-states-empty-bg-pressed cursor-pointer': this.type === SulaSwitchType.List && !this.disabled,
|
|
43
43
|
'container-focus': this.isFocus && this.type === SulaSwitchType.List,
|
|
44
|
-
}, onFocus: this.handleFocus, onBlur: this.handleBlur, onClick: this.handleClick, tabIndex: 0 }, this.type === SulaSwitchType.List && (h("div", { key: '
|
|
44
|
+
}, onFocus: this.handleFocus, onBlur: this.handleBlur, onClick: this.handleClick, tabIndex: 0 }, this.type === SulaSwitchType.List && (h("div", { key: 'd15acc295e424576ab121dd5419465539ecfe440', class: "flex flex-col flex-1 mr-16 overflow-hidden" }, !!this.label && h("label", { key: '01e72df5708151314ff0155bcf7d9a7fafbd55e2', class: "text-text-primary font-bold text-base cursor-pointer break-words" }, this.label), !!this.subTitle && h("span", { key: 'c6871b59d4fe3094196bff0c78463910a2c900bd', class: "text-text-secondary text-base break-words" }, this.subTitle))), h("div", { key: 'ec2df308d747f232d71dc9d3dbd6fc99c25f85d8', class: {
|
|
45
45
|
'switch-container w-56 h-32 flex items-center rounded-xxl p-2 outline-none': true,
|
|
46
46
|
'switch-on bg-brand-primary justify-end': this.active,
|
|
47
47
|
'switch-off bg-neutral-neutral-3 justify-start': !this.active,
|
|
48
48
|
'cursor-not-allowed bg-states-bg-disabled': this.disabled,
|
|
49
49
|
'switch-focus': this.isFocus && this.type === SulaSwitchType.Default,
|
|
50
|
-
}, tabIndex: 0, onFocus: this.handleFocus, onBlur: this.handleBlur }, h("div", { key: '
|
|
50
|
+
}, tabIndex: 0, onFocus: this.handleFocus, onBlur: this.handleBlur }, h("div", { key: 'a10f04862c4257df7a1753d0569dc32e8c0cd099', class: {
|
|
51
51
|
'switch-thumb w-[28px] h-[28px] rounded-full flex justify-center items-center': true,
|
|
52
52
|
'bg-negative-negative-1': !this.disabled,
|
|
53
53
|
'bg-states-bg-disabled shadow-md': this.disabled,
|
|
54
|
-
} }, h("div", { key: '
|
|
54
|
+
} }, h("div", { key: '50c1173d038c8db02559aa6041bffc42a318964a', class: {
|
|
55
55
|
'switch-indicator rounded-full': true,
|
|
56
56
|
'switch-indicator-on w-12 h-12 bg-brand-primary': this.active,
|
|
57
57
|
'switch-indicator-off w-[10px] h-4 bg-neutral-neutral-4': !this.active,
|
|
@@ -72,14 +72,14 @@ export class SulaTag {
|
|
|
72
72
|
return iconStatusStyles[this.iconStatus];
|
|
73
73
|
}
|
|
74
74
|
render() {
|
|
75
|
-
return (h(Host, { key: '
|
|
75
|
+
return (h(Host, { key: 'ef5f2947ea5a21a8f924a6b5140ea9382c268ac4' }, h("div", { key: 'bd55eb96395012c1a3634d193e14069a88be1b2d', class: {
|
|
76
76
|
'flex items-center rounded-xxl w-fit': true,
|
|
77
77
|
[this.getSizeClass()]: true,
|
|
78
78
|
[this.getAppearanceClass()]: true,
|
|
79
|
-
} }, this.icon && (h("div", { key: '
|
|
79
|
+
} }, this.icon && (h("div", { key: '6c37c84e7a215d0bb8f29048c0e53f4f0fa7953e', class: {
|
|
80
80
|
'flex justify-center items-center mr-8 rounded-full leading-4 px-2 py-1': true,
|
|
81
81
|
[this.getIconStatusClass()]: true,
|
|
82
|
-
} }, h("sula-icon", { key: '
|
|
82
|
+
} }, h("sula-icon", { key: 'f5ce8b83627858d804b67b15372173a94d1d4695', icon: this.icon, "custom-class": "text-base text-negative-negative-1 leading-4" }))), h("span", { key: 'ca436796841e583b7e5d80278cd3d0d7138678f3', class: {
|
|
83
83
|
'text-base leading-4': true,
|
|
84
84
|
[this.getTextColorClass()]: true,
|
|
85
85
|
[this.getTextWeightClass()]: true,
|
|
@@ -124,32 +124,32 @@ export class SulaTextarea {
|
|
|
124
124
|
}
|
|
125
125
|
render() {
|
|
126
126
|
const containerHeight = this.rows * 24 + 48;
|
|
127
|
-
return (h(Host, { key: '
|
|
127
|
+
return (h(Host, { key: '2fcc7b99d23820764799bcf3eed0a7605c9d2f72', ref: node => (this.node = node) }, h("div", { key: '5b6fecfaef896755b1862cf8468fb31297169885' }, h("div", { key: 'ed641bb610135c66bd663bfa284f0d81e7e1738d', id: "textarea-container", class: {
|
|
128
128
|
'relative border rounded-sm px-16 py-12 outline-none caret-brand-primary': true,
|
|
129
129
|
'textarea-focus': this.textareaIsFocused && !this.disabled && this.status === SulaTextareaStatus.Default,
|
|
130
130
|
'textarea-error': this.status === SulaTextareaStatus.Error && !this.disabled,
|
|
131
131
|
'bg-states-bg-disabled border-line-general cursor-not-allowed': this.disabled,
|
|
132
132
|
'bg-surface-body border-line-input cursor-text': !this.disabled,
|
|
133
|
-
}, style: { height: `${containerHeight}px` }, tabIndex: 0, onFocus: this.handleFocus, onClick: this.handleTextareaClick }, h("label", { key: '
|
|
133
|
+
}, style: { height: `${containerHeight}px` }, tabIndex: 0, onFocus: this.handleFocus, onClick: this.handleTextareaClick }, h("label", { key: '69ad1cd86d7395ecdeb7a6aeac02273370a10fef', class: {
|
|
134
134
|
'text-base top-16 left-12 absolute transition-all duration-200 ease-in-out pointer-events-none z-10 w-[85%]': true,
|
|
135
135
|
'text-text-primary': !this.disabled && (this.isActive || this.status === SulaTextareaStatus.Default),
|
|
136
136
|
'text-text-disabled': this.disabled,
|
|
137
137
|
'bg-surface-body': !this.disabled && this.isActive,
|
|
138
|
-
}, ref: node => (this.labelElement = node) }, this.label), h("label", { key: '
|
|
138
|
+
}, ref: node => (this.labelElement = node) }, this.label), h("label", { key: '0352260db567f497becd5f8f347cf206aecb595b', class: {
|
|
139
139
|
'absolute font-bold transition-all duration-200 ease-in-out pointer-events-none z-10 active-label hidden from-down': true,
|
|
140
140
|
'text-sm top-12 left-16': this.isActive,
|
|
141
141
|
'text-text-primary': !this.disabled && (this.isActive || this.status === SulaTextareaStatus.Default),
|
|
142
142
|
'text-text-disabled': this.disabled,
|
|
143
143
|
'bg-surface-body': !this.disabled && this.isActive,
|
|
144
|
-
}, ref: node => (this.activeLabelElement = node) }, this.label), h("textarea", { key: '
|
|
144
|
+
}, ref: node => (this.activeLabelElement = node) }, this.label), h("textarea", { key: 'edeacd0e14078081c1d5986e60852b8ed5b6a6a6', ref: node => (this.textareaElement = node), placeholder: this.isActive ? this.placeholder : '', rows: this.rows, maxLength: this.maxLength, disabled: this.disabled, class: {
|
|
145
145
|
'w-full h-full outline-none text-base bg-transparent border-none resize-none': true,
|
|
146
146
|
'text-text-primary': !this.disabled,
|
|
147
147
|
'text-text-disabled cursor-not-allowed overflow-hidden': this.disabled,
|
|
148
|
-
}, style: { paddingTop: this.isActive ? `${this.labelPadding}px` : '0' }, onInput: this.handleTextareaChanges, onFocus: this.handleTextareaFocus, onBlur: this.handleBlur, value: this.textValue })), (this.helpText || this.maxLength) && (h("div", { key: '
|
|
148
|
+
}, style: { paddingTop: this.isActive ? `${this.labelPadding}px` : '0' }, onInput: this.handleTextareaChanges, onFocus: this.handleTextareaFocus, onBlur: this.handleBlur, value: this.textValue })), (this.helpText || this.maxLength) && (h("div", { key: 'f1036cde3cf5bbd60fba5938fc2054d12d110624', class: "flex justify-between items-center px-16 mt-4 text-sm" }, this.helpText && (h("div", { key: 'db55a3ae78e63964a9d26a8cd44a71874a500004', id: "textarea-help-text", class: {
|
|
149
149
|
'text-text-primary': this.status === SulaTextareaStatus.Default && !this.disabled,
|
|
150
150
|
'text-feedback-error': this.status === SulaTextareaStatus.Error && !this.disabled,
|
|
151
151
|
'text-text-disabled': this.disabled,
|
|
152
|
-
} }, this.helpText)), this.maxLength && (h("div", { key: '
|
|
152
|
+
} }, this.helpText)), this.maxLength && (h("div", { key: '4e73a6934d1b959c86fa2c9f4cfb5dadaf20e943', id: "max-length-container", class: {
|
|
153
153
|
'text-text-primary': this.status === SulaTextareaStatus.Default && !this.disabled,
|
|
154
154
|
'text-feedback-error': this.status === SulaTextareaStatus.Error && !this.disabled,
|
|
155
155
|
'text-text-disabled': this.disabled,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Host, h } from "@stencil/core";
|
|
2
2
|
import { SulaTextfieldStatus, SulaTextfieldType } from "./model/sula-textfield.model";
|
|
3
|
+
import VMasker from "vanilla-masker";
|
|
3
4
|
export class SulaTextfield {
|
|
4
5
|
constructor() {
|
|
5
6
|
/**
|
|
@@ -18,6 +19,9 @@ export class SulaTextfield {
|
|
|
18
19
|
this.toggleOptions(true);
|
|
19
20
|
};
|
|
20
21
|
this.handleInputChanges = (event) => {
|
|
22
|
+
if (this.maskPattern && this.inputElement) {
|
|
23
|
+
this.handleInputMask();
|
|
24
|
+
}
|
|
21
25
|
const newValue = event.target.value;
|
|
22
26
|
this.textValue = newValue;
|
|
23
27
|
this.value = newValue;
|
|
@@ -84,6 +88,9 @@ export class SulaTextfield {
|
|
|
84
88
|
if (this.textValue && this.textValue.trim().length > 0) {
|
|
85
89
|
this.changeElementsStyle();
|
|
86
90
|
}
|
|
91
|
+
if (this.maskPattern && this.inputElement) {
|
|
92
|
+
this.handleInputMask();
|
|
93
|
+
}
|
|
87
94
|
}
|
|
88
95
|
toggleOptions(inputIsOpen) {
|
|
89
96
|
if ((this.inputIsOpen && this.textValue && this.textValue.length > 0) || this.disabled)
|
|
@@ -101,6 +108,9 @@ export class SulaTextfield {
|
|
|
101
108
|
this.labelElement.classList.add('from-up');
|
|
102
109
|
}
|
|
103
110
|
}
|
|
111
|
+
handleInputMask() {
|
|
112
|
+
VMasker(this.inputElement).maskPattern(this.maskPattern);
|
|
113
|
+
}
|
|
104
114
|
handlePasswordIconClicked() {
|
|
105
115
|
const cursorPosition = this.inputElement.selectionStart;
|
|
106
116
|
const inputValue = this.inputElement.value;
|
|
@@ -119,14 +129,14 @@ export class SulaTextfield {
|
|
|
119
129
|
return this.icon;
|
|
120
130
|
}
|
|
121
131
|
render() {
|
|
122
|
-
return (h(Host, { key: '
|
|
132
|
+
return (h(Host, { key: '7f3d6752bea3a556fa77a52513eabe0655d9234d', ref: node => (this.node = node) }, h("div", { key: 'cd9cbc06a0244161c06e770d87834ddd7311ada3' }, h("div", { key: 'b66f4f6f2a5cfdcbc212264d500d219b4deb335e', id: "button-container", class: {
|
|
123
133
|
'flex items-center border rounded-sm px-16 outline-none h-[72px] caret-brand-primary': true,
|
|
124
134
|
'flex-row justify-between': !!this.icon || this.type === SulaTextfieldType.Password,
|
|
125
135
|
'button-focus': this.inputIsFocused && !this.disabled && this.status === SulaTextfieldStatus.Default,
|
|
126
136
|
'button-error': this.status === SulaTextfieldStatus.Error && !this.disabled,
|
|
127
137
|
'bg-states-bg-disabled border-line-general cursor-not-allowed': this.disabled,
|
|
128
138
|
'bg-surface-body border-line-input cursor-pointer': !this.disabled,
|
|
129
|
-
}, tabIndex: 0, onFocus: this.handleFocus, onClick: this.handleInputClick }, !this.disabled && (h("div", { key: '
|
|
139
|
+
}, tabIndex: 0, onFocus: this.handleFocus, onClick: this.handleInputClick }, !this.disabled && (h("div", { key: '79eabd37134b96bbb5a315ca73d81d0c8be01ce4', class: { 'hidden flex-col w-full': true, 'pr-12': !!this.icon }, ref: node => (this.inputContainer = node) }, h("label", { key: 'd24af603a0e365d1482daea31b75fa8e86fd5e8a', class: "font-bold text-sm text-text-primary from-down" }, this.label), h("input", { key: 'aea523483b4a39f31b0d2c9506001d69c397da70', 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: '2e3d9fbe37ba1dc5aceea8e8ce7e6152f740a955', 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: 'd6f5aacd486e093d64307117d8c6b0bfea460f49', class: "flex items-center justify-center", onClick: this.handleIconClick }, h("sula-icon", { key: 'cfc400df76f2c487a09b641c101543a3e2895bd1', icon: this.getInputIcon(), customClass: `text-2xl ${this.disabled ? 'text-icon-disabled' : 'text-icon-primary'}` })))), (this.helpText || this.maxLength) && !this.disabled && (h("div", { key: '8d450abc836ba702aeda16f4f6c1d379373ee698', class: "flex justify-between items-center px-16 mt-4 text-sm" }, this.helpText && (h("div", { key: 'e0d25ac6878865510a0afc793d81b07d8a016bb5', 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: '6384a6d5468b03bef0ddf2e0345438efe1b5fd32', 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)))))));
|
|
130
140
|
}
|
|
131
141
|
static get is() { return "sula-textfield"; }
|
|
132
142
|
static get encapsulation() { return "shadow"; }
|
|
@@ -326,6 +336,25 @@ export class SulaTextfield {
|
|
|
326
336
|
"getter": false,
|
|
327
337
|
"setter": false,
|
|
328
338
|
"reflect": false
|
|
339
|
+
},
|
|
340
|
+
"maskPattern": {
|
|
341
|
+
"type": "string",
|
|
342
|
+
"attribute": "mask-pattern",
|
|
343
|
+
"mutable": false,
|
|
344
|
+
"complexType": {
|
|
345
|
+
"original": "string",
|
|
346
|
+
"resolved": "string",
|
|
347
|
+
"references": {}
|
|
348
|
+
},
|
|
349
|
+
"required": false,
|
|
350
|
+
"optional": true,
|
|
351
|
+
"docs": {
|
|
352
|
+
"tags": [],
|
|
353
|
+
"text": "The textfield mask pattern\nThe mask pattern should follow the VMasker pattern format\nMore info: https://github.com/vanilla-masker/vanilla-masker?tab=readme-ov-file#custom-pattern"
|
|
354
|
+
},
|
|
355
|
+
"getter": false,
|
|
356
|
+
"setter": false,
|
|
357
|
+
"reflect": false
|
|
329
358
|
}
|
|
330
359
|
};
|
|
331
360
|
}
|
|
@@ -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;AAOtF,MAAM,OAAO,aAAa;IAL1B;QAYE;;WAEG;QACK,SAAI,GAAsB,iBAAiB,CAAC,IAAI,CAAC;QAEzD;;WAEG;QACsB,WAAM,GAAwB,mBAAmB,CAAC,OAAO,CAAC;QAmDnF,gBAAW,GAAG,KAAK,CAAC;QAGpB,cAAS,GAAW,EAAE,CAAC;QAGvB,iBAAY,GAAG,KAAK,CAAC;QAGrB,mBAAc,GAAG,KAAK,CAAC;QAyDvB,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,SAAS,GAAG,QAAQ,CAAC;YAC1B,IAAI,CAAC,KAAK,GAAG,QAAQ,CAAC;YAEtB,IAAI,CAAC,YAAY,CAAC,IAAI,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I,CAAC,QAAQ,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,CACtD,4DAAK,KAAK,EAAC,sDAAsD;oBAC9D,IAAI,CAAC,QAAQ,IAAI,CAChB,4DACE,EAAE,EAAC,qBAAqB,EACxB,KAAK,EAAE,EAAE,mBAAmB,EAAE,IAAI,CAAC,MAAM,KAAK,mBAAmB,CAAC,OAAO,EAAE,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';\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 @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.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 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 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 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;QA2DnF,gBAAW,GAAG,KAAK,CAAC;QAGpB,cAAS,GAAW,EAAE,CAAC;QAGvB,iBAAY,GAAG,KAAK,CAAC;QAGrB,mBAAc,GAAG,KAAK,CAAC;QA6DvB,qBAAgB,GAAG,GAAG,EAAE;YACtB,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QAC3B,CAAC,CAAC;QAoBF,uBAAkB,GAAG,CAAC,KAAiB,EAAE,EAAE;YACzC,IAAI,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;gBAC1C,IAAI,CAAC,eAAe,EAAE,CAAC;YACzB,CAAC;YACD,MAAM,QAAQ,GAAI,KAAK,CAAC,MAA2B,CAAC,KAAK,CAAC;YAC1D,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;Y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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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.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"]}
|
|
@@ -37,6 +37,14 @@ export default {
|
|
|
37
37
|
required: false,
|
|
38
38
|
},
|
|
39
39
|
},
|
|
40
|
+
maskPattern: {
|
|
41
|
+
control: 'text',
|
|
42
|
+
defaultValue: '',
|
|
43
|
+
description: 'The textfield mask pattern',
|
|
44
|
+
type: {
|
|
45
|
+
required: false,
|
|
46
|
+
},
|
|
47
|
+
},
|
|
40
48
|
placeholder: {
|
|
41
49
|
control: 'text',
|
|
42
50
|
defaultValue: 'Placeholder',
|
|
@@ -110,6 +118,7 @@ const Template = args => {
|
|
|
110
118
|
el.setAttribute('label', args.label);
|
|
111
119
|
el.setAttribute('placeholder', args.placeholder);
|
|
112
120
|
el.setAttribute('disabled', args.disabled.toString());
|
|
121
|
+
el.setAttribute('mask-pattern', args.maskPattern);
|
|
113
122
|
if (args.helpText)
|
|
114
123
|
el.setAttribute('help-text', args.helpText);
|
|
115
124
|
if (args.maxLength > 0)
|
|
@@ -134,6 +143,19 @@ Default.args = {
|
|
|
134
143
|
maxLength: 0,
|
|
135
144
|
icon: '',
|
|
136
145
|
};
|
|
146
|
+
export const WithMask = Template.bind({});
|
|
147
|
+
WithMask.args = {
|
|
148
|
+
value: '',
|
|
149
|
+
type: SulaTextfieldType.Text,
|
|
150
|
+
status: SulaTextfieldStatus.Default,
|
|
151
|
+
label: 'Telefone',
|
|
152
|
+
placeholder: 'Digite seu telefone',
|
|
153
|
+
disabled: false,
|
|
154
|
+
helpText: '',
|
|
155
|
+
maxLength: 0,
|
|
156
|
+
icon: '',
|
|
157
|
+
maskPattern: '(99) 99999-9999',
|
|
158
|
+
};
|
|
137
159
|
export const WithValue = Template.bind({});
|
|
138
160
|
WithValue.args = Object.assign(Object.assign({}, Default.args), { value: 'John Doe', label: 'Nome completo' });
|
|
139
161
|
export const WithHelpText = Template.bind({});
|