@govbr-ds/webcomponents 2.0.0-next.19 → 2.0.0-next.20
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/br-button_2.cjs.entry.js +1 -1
- package/dist/cjs/br-button_2.cjs.entry.js.map +1 -1
- package/dist/cjs/br-input.cjs.entry.js +13 -9
- package/dist/cjs/br-input.cjs.entry.js.map +1 -1
- package/dist/cjs/br-tag.cjs.entry.js +88 -0
- package/dist/cjs/br-tag.cjs.entry.js.map +1 -0
- package/dist/cjs/br-textarea.cjs.entry.js +1 -1
- package/dist/cjs/br-upload.cjs.entry.js +1 -1
- package/dist/cjs/index-81c11ce2.js +4 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/webcomponents.cjs.js +1 -1
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/icon/icon.css +1 -1
- package/dist/collection/components/input/input.js +152 -10
- package/dist/collection/components/input/input.js.map +1 -1
- package/dist/collection/components/tag/tag.css +643 -0
- package/dist/collection/components/tag/tag.js +256 -0
- package/dist/collection/components/tag/tag.js.map +1 -0
- package/dist/collection/components/textarea/textarea.js +1 -1
- package/dist/collection/components/upload/upload.js +1 -1
- package/dist/collection/pages/components/input/index.js +9 -0
- package/dist/collection/pages/components/tag/index.js +18 -0
- package/dist/collection/pages/scripts/menu.js +22 -22
- package/dist/collection/scripts/menu.js +146 -0
- package/dist/components/br-avatar.js +1 -1
- package/dist/components/br-icon.js +1 -1
- package/dist/components/br-input.js +1 -1
- package/dist/components/br-input.js.map +1 -1
- package/dist/components/br-message.js +1 -1
- package/dist/components/br-tag.d.ts +11 -0
- package/dist/components/br-tag.js +6 -0
- package/dist/components/br-tag.js.map +1 -0
- package/dist/components/br-textarea.js +1 -1
- package/dist/components/br-upload.js +1 -1
- package/dist/components/{p-a23c3f6b.js → p-64831033.js} +2 -2
- package/dist/components/{p-a23c3f6b.js.map → p-64831033.js.map} +1 -1
- package/dist/esm/br-button_2.entry.js +1 -1
- package/dist/esm/br-button_2.entry.js.map +1 -1
- package/dist/esm/br-input.entry.js +13 -9
- package/dist/esm/br-input.entry.js.map +1 -1
- package/dist/esm/br-tag.entry.js +84 -0
- package/dist/esm/br-tag.entry.js.map +1 -0
- package/dist/esm/br-textarea.entry.js +1 -1
- package/dist/esm/br-upload.entry.js +1 -1
- package/dist/esm/index-aab4a630.js +4 -0
- package/dist/esm/loader.js +1 -1
- package/dist/esm/webcomponents.js +1 -1
- package/dist/esm-es5/br-button_2.entry.js +1 -1
- package/dist/esm-es5/br-button_2.entry.js.map +1 -1
- package/dist/esm-es5/br-input.entry.js +1 -1
- package/dist/esm-es5/br-input.entry.js.map +1 -1
- package/dist/esm-es5/br-tag.entry.js +6 -0
- package/dist/esm-es5/br-tag.entry.js.map +1 -0
- package/dist/esm-es5/br-textarea.entry.js +2 -2
- package/dist/esm-es5/br-upload.entry.js +1 -1
- package/dist/esm-es5/index-aab4a630.js +1 -1
- package/dist/esm-es5/index-aab4a630.js.map +1 -1
- package/dist/esm-es5/loader.js +1 -1
- package/dist/esm-es5/loader.js.map +1 -1
- package/dist/esm-es5/webcomponents.js +1 -1
- package/dist/esm-es5/webcomponents.js.map +1 -1
- package/dist/types/components/input/input.d.ts +32 -0
- package/dist/types/components/tag/tag.d.ts +73 -0
- package/dist/types/components.d.ts +172 -0
- package/dist/webcomponents/{p-2cc63872.system.entry.js → p-28476b17.system.entry.js} +2 -2
- package/dist/webcomponents/p-447c8036.entry.js +6 -0
- package/dist/webcomponents/p-447c8036.entry.js.map +1 -0
- package/dist/webcomponents/p-55604b7f.system.entry.js +6 -0
- package/dist/webcomponents/p-55604b7f.system.entry.js.map +1 -0
- package/dist/webcomponents/{p-fd6c166e.entry.js → p-61523bc9.entry.js} +2 -2
- package/dist/webcomponents/{p-28aa7e4d.system.entry.js → p-8f156fc4.system.entry.js} +2 -2
- package/dist/webcomponents/p-8f156fc4.system.entry.js.map +1 -0
- package/dist/webcomponents/{p-3c4dea67.entry.js → p-9f0d01d1.entry.js} +2 -2
- package/dist/webcomponents/p-9f0d01d1.entry.js.map +1 -0
- package/dist/webcomponents/p-b88a5d9a.system.js +2 -2
- package/dist/webcomponents/p-b88a5d9a.system.js.map +1 -1
- package/dist/webcomponents/{p-34cec0b3.system.entry.js → p-baad00f8.system.entry.js} +2 -2
- package/dist/webcomponents/{p-155191ea.entry.js → p-d174c8cd.entry.js} +2 -2
- package/dist/webcomponents/{p-2cef0b07.system.entry.js → p-d83e2172.system.entry.js} +2 -2
- package/dist/webcomponents/{p-2cef0b07.system.entry.js.map → p-d83e2172.system.entry.js.map} +1 -1
- package/dist/webcomponents/{p-66b81760.entry.js → p-e6d921ef.entry.js} +2 -2
- package/dist/webcomponents/{p-66b81760.entry.js.map → p-e6d921ef.entry.js.map} +1 -1
- package/dist/webcomponents/webcomponents.esm.js +1 -1
- package/dist/webcomponents/webcomponents.esm.js.map +1 -1
- package/hydrate/index.js +123 -13
- package/hydrate/index.mjs +123 -13
- package/package.json +2 -2
- package/vscode-data.json +103 -0
- package/dist/webcomponents/p-28aa7e4d.system.entry.js.map +0 -1
- package/dist/webcomponents/p-3c4dea67.entry.js.map +0 -1
- /package/dist/webcomponents/{p-2cc63872.system.entry.js.map → p-28476b17.system.entry.js.map} +0 -0
- /package/dist/webcomponents/{p-fd6c166e.entry.js.map → p-61523bc9.entry.js.map} +0 -0
- /package/dist/webcomponents/{p-34cec0b3.system.entry.js.map → p-baad00f8.system.entry.js.map} +0 -0
- /package/dist/webcomponents/{p-155191ea.entry.js.map → p-d174c8cd.entry.js.map} +0 -0
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Construído com @govbr-ds/webcomponents
|
|
3
|
+
* Padrão Digital de Governo.
|
|
4
|
+
*/
|
|
5
|
+
import { h, Host } from "@stencil/core";
|
|
6
|
+
import { inheritAriaAttributes } from "../../utils/inherited-attributes";
|
|
7
|
+
/**
|
|
8
|
+
* Para uma descrição detalhada, consulte a [documentação do GovBR-DS](https://www.gov.br/ds/components/tag?tab=designer).
|
|
9
|
+
*
|
|
10
|
+
* @slot default - Slot utilizado para inserir conteúdo adicional na tag, como texto ou elementos HTML extras.
|
|
11
|
+
*/
|
|
12
|
+
export class Tag {
|
|
13
|
+
constructor() {
|
|
14
|
+
this.inheritedAttributes = {};
|
|
15
|
+
this.handleClose = () => {
|
|
16
|
+
this.el.remove();
|
|
17
|
+
};
|
|
18
|
+
this.label = '';
|
|
19
|
+
this.iconName = '';
|
|
20
|
+
this.color = '';
|
|
21
|
+
this.density = 'small';
|
|
22
|
+
this.shape = 'default';
|
|
23
|
+
this.status = false;
|
|
24
|
+
this.interaction = false;
|
|
25
|
+
this.disabled = false;
|
|
26
|
+
this.stateIconName = 'fa-solid:car';
|
|
27
|
+
}
|
|
28
|
+
componentWillLoad() {
|
|
29
|
+
this.brWillLoad.emit();
|
|
30
|
+
this.inheritedAttributes = inheritAriaAttributes(this.el);
|
|
31
|
+
}
|
|
32
|
+
getCssClassMap() {
|
|
33
|
+
const classes = {
|
|
34
|
+
'br-tag': true,
|
|
35
|
+
interaction: this.interaction,
|
|
36
|
+
[this.color]: this.color !== '',
|
|
37
|
+
small: this.density === 'small',
|
|
38
|
+
medium: this.density === 'medium',
|
|
39
|
+
large: this.density === 'large',
|
|
40
|
+
count: this.shape === 'rounded' ? true : false,
|
|
41
|
+
icon: this.shape === 'circle' ? true : false,
|
|
42
|
+
status: this.status,
|
|
43
|
+
};
|
|
44
|
+
return classes;
|
|
45
|
+
}
|
|
46
|
+
renderIcon() {
|
|
47
|
+
if (this.iconName.trim().length === 0)
|
|
48
|
+
return null;
|
|
49
|
+
return h("br-icon", { style: { fontSize: 'var(--icon-size-base)' }, "icon-name": this.iconName, "aria-hidden": "true" });
|
|
50
|
+
}
|
|
51
|
+
renderLabel() {
|
|
52
|
+
if (this.shape === 'circle' || this.status)
|
|
53
|
+
return null;
|
|
54
|
+
return (h("span", { id: "interactivetag1", "aria-label": this.label }, this.label));
|
|
55
|
+
}
|
|
56
|
+
renderCloseButton() {
|
|
57
|
+
if (!this.interaction)
|
|
58
|
+
return null;
|
|
59
|
+
return (h("br-button", { type: "button", shape: "circle", emphasis: !this.interaction ? 'tertiary' : 'primary', "aria-label": "Fechar", colorMode: !this.interaction ? 'dark' : null, "aria-describedby": "interactivetag1", onClick: this.handleClose, disabled: this.disabled }, h("br-icon", { "icon-name": "fa-solid:times" })));
|
|
60
|
+
}
|
|
61
|
+
renderStatusLabel() {
|
|
62
|
+
if (!this.status)
|
|
63
|
+
return null;
|
|
64
|
+
return (h("span", { class: "tag-spacing-status", id: "interactivetag1", "aria-label": this.label }, this.label));
|
|
65
|
+
}
|
|
66
|
+
render() {
|
|
67
|
+
return (h(Host, { key: '2ae1b9e249097b66fb02e0c903e294f73aad6bc0' }, h("div", { key: '65f39b80147b977231e8bb9566f2aa1797597646', class: "tag-position" }, h("span", Object.assign({ key: '452777774bfdba4a5eed2af6bb429f02f8dd9ed3', class: this.getCssClassMap() }, this.inheritedAttributes, { role: "alert", "aria-live": "assertive" }), this.renderIcon(), this.renderLabel(), this.renderCloseButton(), h("slot", { key: 'c3cad61c4e5d7b683c9b4a6b66fbf0b62a56ac8a' })), this.renderStatusLabel())));
|
|
68
|
+
}
|
|
69
|
+
static get is() { return "br-tag"; }
|
|
70
|
+
static get encapsulation() { return "shadow"; }
|
|
71
|
+
static get formAssociated() { return true; }
|
|
72
|
+
static get originalStyleUrls() {
|
|
73
|
+
return {
|
|
74
|
+
"$": ["tag.scss"]
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
static get styleUrls() {
|
|
78
|
+
return {
|
|
79
|
+
"$": ["tag.css"]
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
static get properties() {
|
|
83
|
+
return {
|
|
84
|
+
"label": {
|
|
85
|
+
"type": "string",
|
|
86
|
+
"mutable": false,
|
|
87
|
+
"complexType": {
|
|
88
|
+
"original": "string",
|
|
89
|
+
"resolved": "string",
|
|
90
|
+
"references": {}
|
|
91
|
+
},
|
|
92
|
+
"required": false,
|
|
93
|
+
"optional": false,
|
|
94
|
+
"docs": {
|
|
95
|
+
"tags": [],
|
|
96
|
+
"text": "A propriedade 'label' \u00E9 uma string que representa o texto a ser exibido no componente.\nEla \u00E9 refletida no DOM, permitindo que altera\u00E7\u00F5es no valor sejam refletidas no elemento HTML correspondente."
|
|
97
|
+
},
|
|
98
|
+
"attribute": "label",
|
|
99
|
+
"reflect": true,
|
|
100
|
+
"defaultValue": "''"
|
|
101
|
+
},
|
|
102
|
+
"iconName": {
|
|
103
|
+
"type": "string",
|
|
104
|
+
"mutable": false,
|
|
105
|
+
"complexType": {
|
|
106
|
+
"original": "string",
|
|
107
|
+
"resolved": "string",
|
|
108
|
+
"references": {}
|
|
109
|
+
},
|
|
110
|
+
"required": false,
|
|
111
|
+
"optional": false,
|
|
112
|
+
"docs": {
|
|
113
|
+
"tags": [],
|
|
114
|
+
"text": "A propriedade 'iconName' define o nome do \u00EDcone que ser\u00E1 exibido ao lado do texto.\nO valor padr\u00E3o \u00E9 'fa-solid:car', que corresponde a um \u00EDcone de carro da biblioteca Font Awesome."
|
|
115
|
+
},
|
|
116
|
+
"attribute": "icon-name",
|
|
117
|
+
"reflect": true,
|
|
118
|
+
"defaultValue": "''"
|
|
119
|
+
},
|
|
120
|
+
"color": {
|
|
121
|
+
"type": "string",
|
|
122
|
+
"mutable": false,
|
|
123
|
+
"complexType": {
|
|
124
|
+
"original": "string",
|
|
125
|
+
"resolved": "string",
|
|
126
|
+
"references": {}
|
|
127
|
+
},
|
|
128
|
+
"required": false,
|
|
129
|
+
"optional": false,
|
|
130
|
+
"docs": {
|
|
131
|
+
"tags": [],
|
|
132
|
+
"text": "A propriedade 'color' permite definir a cor do componente.\nAceita valores como 'red', 'blue', entre outros, e \u00E9 refletida no DOM."
|
|
133
|
+
},
|
|
134
|
+
"attribute": "color",
|
|
135
|
+
"reflect": true,
|
|
136
|
+
"defaultValue": "''"
|
|
137
|
+
},
|
|
138
|
+
"density": {
|
|
139
|
+
"type": "string",
|
|
140
|
+
"mutable": false,
|
|
141
|
+
"complexType": {
|
|
142
|
+
"original": "'small' | 'medium' | 'large'",
|
|
143
|
+
"resolved": "\"large\" | \"medium\" | \"small\"",
|
|
144
|
+
"references": {}
|
|
145
|
+
},
|
|
146
|
+
"required": false,
|
|
147
|
+
"optional": false,
|
|
148
|
+
"docs": {
|
|
149
|
+
"tags": [],
|
|
150
|
+
"text": "A propriedade 'density' permite definir a densidade do componente.\nAceita valores como 'small', 'medium' e 'large', e \u00E9 refletida no DOM."
|
|
151
|
+
},
|
|
152
|
+
"attribute": "density",
|
|
153
|
+
"reflect": true,
|
|
154
|
+
"defaultValue": "'small'"
|
|
155
|
+
},
|
|
156
|
+
"shape": {
|
|
157
|
+
"type": "string",
|
|
158
|
+
"mutable": false,
|
|
159
|
+
"complexType": {
|
|
160
|
+
"original": "'circle' | 'rounded' | 'default'",
|
|
161
|
+
"resolved": "\"circle\" | \"default\" | \"rounded\"",
|
|
162
|
+
"references": {}
|
|
163
|
+
},
|
|
164
|
+
"required": false,
|
|
165
|
+
"optional": false,
|
|
166
|
+
"docs": {
|
|
167
|
+
"tags": [],
|
|
168
|
+
"text": "A propriedade 'shape' define o formato do componente.\nValores poss\u00EDveis:\n- 'circle': Componente com formato circular.\n- 'rounded': Componente com bordas arredondadas.\n- 'default': Componente com formato padr\u00E3o."
|
|
169
|
+
},
|
|
170
|
+
"attribute": "shape",
|
|
171
|
+
"reflect": true,
|
|
172
|
+
"defaultValue": "'default'"
|
|
173
|
+
},
|
|
174
|
+
"status": {
|
|
175
|
+
"type": "boolean",
|
|
176
|
+
"mutable": false,
|
|
177
|
+
"complexType": {
|
|
178
|
+
"original": "boolean",
|
|
179
|
+
"resolved": "boolean",
|
|
180
|
+
"references": {}
|
|
181
|
+
},
|
|
182
|
+
"required": false,
|
|
183
|
+
"optional": false,
|
|
184
|
+
"docs": {
|
|
185
|
+
"tags": [],
|
|
186
|
+
"text": "A propriedade 'status' \u00E9 um booleano que indica se o status deve ser exibido.\nSe definido como true, o status ser\u00E1 mostrado ao lado do texto."
|
|
187
|
+
},
|
|
188
|
+
"attribute": "status",
|
|
189
|
+
"reflect": true,
|
|
190
|
+
"defaultValue": "false"
|
|
191
|
+
},
|
|
192
|
+
"interaction": {
|
|
193
|
+
"type": "boolean",
|
|
194
|
+
"mutable": false,
|
|
195
|
+
"complexType": {
|
|
196
|
+
"original": "boolean",
|
|
197
|
+
"resolved": "boolean",
|
|
198
|
+
"references": {}
|
|
199
|
+
},
|
|
200
|
+
"required": false,
|
|
201
|
+
"optional": false,
|
|
202
|
+
"docs": {
|
|
203
|
+
"tags": [],
|
|
204
|
+
"text": "A propriedade 'interaction' \u00E9 um booleano que indica se a intera\u00E7\u00E3o deve ser habilitada.\nSe definido como true, o componente permitir\u00E1 intera\u00E7\u00F5es do usu\u00E1rio."
|
|
205
|
+
},
|
|
206
|
+
"attribute": "interaction",
|
|
207
|
+
"reflect": true,
|
|
208
|
+
"defaultValue": "false"
|
|
209
|
+
},
|
|
210
|
+
"disabled": {
|
|
211
|
+
"type": "boolean",
|
|
212
|
+
"mutable": false,
|
|
213
|
+
"complexType": {
|
|
214
|
+
"original": "boolean",
|
|
215
|
+
"resolved": "boolean",
|
|
216
|
+
"references": {}
|
|
217
|
+
},
|
|
218
|
+
"required": false,
|
|
219
|
+
"optional": false,
|
|
220
|
+
"docs": {
|
|
221
|
+
"tags": [],
|
|
222
|
+
"text": "A propriedade 'disabled' \u00E9 um booleano que indica se o componente deve estar desabilitado.\nSe definido como true, o componente n\u00E3o permitir\u00E1 intera\u00E7\u00F5es do usu\u00E1rio."
|
|
223
|
+
},
|
|
224
|
+
"attribute": "disabled",
|
|
225
|
+
"reflect": true,
|
|
226
|
+
"defaultValue": "false"
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
static get states() {
|
|
231
|
+
return {
|
|
232
|
+
"stateIconName": {}
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
static get events() {
|
|
236
|
+
return [{
|
|
237
|
+
"method": "brWillLoad",
|
|
238
|
+
"name": "brWillLoad",
|
|
239
|
+
"bubbles": true,
|
|
240
|
+
"cancelable": true,
|
|
241
|
+
"composed": true,
|
|
242
|
+
"docs": {
|
|
243
|
+
"tags": [],
|
|
244
|
+
"text": "Emite um evento antes que o componente seja carregado pela primeira vez.\nUtilize este evento para realizar tarefas de inicializa\u00E7\u00E3o antes do componente ser exibido.\nConsulte a documenta\u00E7\u00E3o do [Stencil](https://stenciljs.com/docs/component-lifecycle#componentwillload) para mais detalhes."
|
|
245
|
+
},
|
|
246
|
+
"complexType": {
|
|
247
|
+
"original": "void",
|
|
248
|
+
"resolved": "void",
|
|
249
|
+
"references": {}
|
|
250
|
+
}
|
|
251
|
+
}];
|
|
252
|
+
}
|
|
253
|
+
static get elementRef() { return "el"; }
|
|
254
|
+
static get attachInternalsMemberName() { return "elementInternals"; }
|
|
255
|
+
}
|
|
256
|
+
//# sourceMappingURL=tag.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tag.js","sourceRoot":"","sources":["../../../../src/components/tag/tag.tsx"],"names":[],"mappings":"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","sourcesContent":["import { AttachInternals, Component, Element, Event, EventEmitter, h, Host, Prop, State } from '@stencil/core'\n\nimport { Attributes, inheritAriaAttributes } from '../../utils/inherited-attributes'\nimport { CssClassMap } from '../../utils/interfaces'\n\n/**\n * Para uma descrição detalhada, consulte a [documentação do GovBR-DS](https://www.gov.br/ds/components/tag?tab=designer).\n *\n * @slot default - Slot utilizado para inserir conteúdo adicional na tag, como texto ou elementos HTML extras.\n */\n@Component({\n tag: 'br-tag',\n styleUrl: 'tag.scss',\n shadow: true,\n formAssociated: true,\n})\nexport class Tag {\n /**\n * Referência ao elemento host do componente.\n * Utilize esta propriedade para acessar e manipular o elemento do DOM associado ao componente.\n */\n @Element() el: HTMLBrTagElement\n\n @AttachInternals() elementInternals: ElementInternals\n\n /**\n * A propriedade 'label' é uma string que representa o texto a ser exibido no componente.\n * Ela é refletida no DOM, permitindo que alterações no valor sejam refletidas no elemento HTML correspondente.\n */\n @Prop({ reflect: true }) label: string = ''\n\n /**\n * A propriedade 'iconName' define o nome do ícone que será exibido ao lado do texto.\n * O valor padrão é 'fa-solid:car', que corresponde a um ícone de carro da biblioteca Font Awesome.\n */\n @Prop({ reflect: true }) iconName: string = ''\n\n /**\n * A propriedade 'color' permite definir a cor do componente.\n * Aceita valores como 'red', 'blue', entre outros, e é refletida no DOM.\n */\n @Prop({ reflect: true }) color: string = ''\n\n /**\n * A propriedade 'density' permite definir a densidade do componente.\n * Aceita valores como 'small', 'medium' e 'large', e é refletida no DOM.\n */\n @Prop({ reflect: true }) density: 'small' | 'medium' | 'large' = 'small'\n\n /**\n * A propriedade 'shape' define o formato do componente.\n * Valores possíveis:\n * - 'circle': Componente com formato circular.\n * - 'rounded': Componente com bordas arredondadas.\n * - 'default': Componente com formato padrão.\n */\n @Prop({ reflect: true }) shape: 'circle' | 'rounded' | 'default' = 'default'\n\n /**\n * A propriedade 'status' é um booleano que indica se o status deve ser exibido.\n * Se definido como true, o status será mostrado ao lado do texto.\n */\n @Prop({ reflect: true }) status: boolean = false\n\n /**\n * A propriedade 'interaction' é um booleano que indica se a interação deve ser habilitada.\n * Se definido como true, o componente permitirá interações do usuário.\n */\n @Prop({ reflect: true }) interaction: boolean = false\n\n /**\n * A propriedade 'disabled' é um booleano que indica se o componente deve estar desabilitado.\n * Se definido como true, o componente não permitirá interações do usuário.\n */\n @Prop({ reflect: true }) disabled: boolean = false\n\n @State() stateIconName: string = 'fa-solid:car'\n\n /**\n * Emite um evento antes que o componente seja carregado pela primeira vez.\n * Utilize este evento para realizar tarefas de inicialização antes do componente ser exibido.\n * Consulte a documentação do [Stencil](https://stenciljs.com/docs/component-lifecycle#componentwillload) para mais detalhes.\n */\n @Event() brWillLoad: EventEmitter<void>\n componentWillLoad() {\n this.brWillLoad.emit()\n this.inheritedAttributes = inheritAriaAttributes(this.el)\n }\n\n private getCssClassMap(): CssClassMap {\n const classes: CssClassMap = {\n 'br-tag': true,\n interaction: this.interaction,\n [this.color]: this.color !== '',\n small: this.density === 'small',\n medium: this.density === 'medium',\n large: this.density === 'large',\n count: this.shape === 'rounded' ? true : false,\n icon: this.shape === 'circle' ? true : false,\n status: this.status,\n }\n\n return classes\n }\n\n private inheritedAttributes: Attributes = {}\n\n private renderIcon() {\n if (this.iconName.trim().length === 0) return null\n return <br-icon style={{ fontSize: 'var(--icon-size-base)' }} icon-name={this.iconName} aria-hidden=\"true\" />\n }\n\n private renderLabel() {\n if (this.shape === 'circle' || this.status) return null\n return (\n <span id=\"interactivetag1\" aria-label={this.label}>\n {this.label}\n </span>\n )\n }\n\n private renderCloseButton() {\n if (!this.interaction) return null\n return (\n <br-button\n type=\"button\"\n shape=\"circle\"\n emphasis={!this.interaction ? 'tertiary' : 'primary'}\n aria-label=\"Fechar\"\n colorMode={!this.interaction ? 'dark' : null}\n aria-describedby=\"interactivetag1\"\n onClick={this.handleClose}\n disabled={this.disabled}\n >\n <br-icon icon-name=\"fa-solid:times\"></br-icon>\n </br-button>\n )\n }\n\n private renderStatusLabel() {\n if (!this.status) return null\n return (\n <span class=\"tag-spacing-status\" id=\"interactivetag1\" aria-label={this.label}>\n {this.label}\n </span>\n )\n }\n\n private handleClose = () => {\n this.el.remove()\n }\n\n render() {\n return (\n <Host>\n <div class=\"tag-position\">\n <span class={this.getCssClassMap()} {...this.inheritedAttributes} role=\"alert\" aria-live=\"assertive\">\n {this.renderIcon()}\n {this.renderLabel()}\n {this.renderCloseButton()}\n <slot></slot>\n </span>\n {this.renderStatusLabel()}\n </div>\n </Host>\n )\n }\n}\n"]}
|
|
@@ -76,7 +76,7 @@ export class Textarea {
|
|
|
76
76
|
render() {
|
|
77
77
|
const caracteresRestantes = this.maxlength - this.currentLength;
|
|
78
78
|
const mostrarLimite = this.currentLength > 0;
|
|
79
|
-
return (h(Host, { key: '
|
|
79
|
+
return (h(Host, { key: '8bb5ea9efb0e2ee82d1c4074d7f9a8332fcfb635' }, h("div", Object.assign({ key: 'cedcc004557860b4b2724c5180f2c012a109fcc1', class: this.getCssClassMap() }, this.inheritedAttributes), h("div", { key: '3998a88b69f3dddc63ea41d08db7de96af28d25d', class: this.isInline ? 'row' : '' }, this.isInline ? (h("div", { class: "col-auto pt-half" }, h("label", { htmlFor: this.customId }, this.label))) : (h("label", { htmlFor: this.customId }, this.label)), h("div", { key: '8f94f9c2aaf2758e5ee9be6938be50ce8c82db7c', class: this.isInline ? 'col' : '' }, h("textarea", Object.assign({ key: 'a642046a4dd9da93ac051eb6bf0ecfe711433680', id: this.customId, value: this.value, placeholder: this.placeholder, disabled: this.disabled, onInput: this.handleChange }, (this.maxlength > 0 ? { maxLength: this.maxlength } : {}))), h("div", { key: 'b859da1b3f48ed513e32374251a31ad3fc0f108f', class: "text-base mt-1" }, this.maxlength > 0 && (h("div", { key: '0aaebed51ac98b00c4fca6e7d857664d117b0d74' }, mostrarLimite ? (h("span", { class: "restantes", "aria-live": "polite", role: "status", id: "limitmax" }, "Restam ", h("strong", null, caracteresRestantes), " caracteres")) : (h("span", { class: "limit", "aria-live": "polite" }, "Limite m\u00E1ximo de ", h("strong", null, this.maxlength), " caracteres"))))), h("slot", { key: 'e24c4673cc638ce9e37acf05d2d80fea32b7f8fa' }))))));
|
|
80
80
|
}
|
|
81
81
|
static get is() { return "br-textarea"; }
|
|
82
82
|
static get encapsulation() { return "shadow"; }
|
|
@@ -133,7 +133,7 @@ export class Upload {
|
|
|
133
133
|
fileInput.click();
|
|
134
134
|
}
|
|
135
135
|
render() {
|
|
136
|
-
return (h(Host, { key: '
|
|
136
|
+
return (h(Host, { key: 'aab6988f0879747fdb594e3810704e497718635c' }, h("div", { key: '274726af605123e4be46cd995b295c8eb147cbf4', class: this.getCssClassMap() }, h("label", { key: '40753e4671f13bd2daab5c823284e64dd104214b', class: "upload-label", form: "single-file" }, h("span", { key: 'd49a6054c231e556bb40ee4c8b06f0c8ff950507' }, this.label)), h("button", { key: 'dafa2d9c447bb65f01e9b5dbd81f63dde33d38d2', class: "upload-button", type: "button", "aria-hidden": "true", tabIndex: this.disabled ? -1 : 0, disabled: this.disabled, "aria-label": "Selecionar arquivo para upload", onClick: () => this.handleFileSelection(), onDrop: (event) => this.handleDrop(event), onDragOver: (event) => this.handleDragOver(event) }, h("br-icon", { key: '22b4bf3b4618ecdff30cdcb8db2185db6da0af5f', "icon-name": "fa-solid:upload", height: "16", "aria-hidden": "true" }), h("span", { key: 'f8a3fbc9629d7a8cd85eb434d922356b5c61ab22' }, "Selecione o arquivo")), h("input", Object.assign({ key: '83b65e6e1a55db70d42c6075bea037d58b86c457', class: "upload-input", id: "single-file", type: "file", "aria-hidden": "null", "aria-label": "enviar arquivo", onChange: ($event) => this.onInputChange($event.target.files) }, this.inheritedAttributes, { multiple: this.multiple, disabled: this.disabled, accept: this.accept })), h("div", { key: '0a7a7f508c8379986a56d1a2aa5773b0f0709c17', id: "list-files", class: "upload-list" }, this.filesSelected ? this.renderFilesUploaded() : null))));
|
|
137
137
|
}
|
|
138
138
|
static get is() { return "br-upload"; }
|
|
139
139
|
static get encapsulation() { return "shadow"; }
|
|
@@ -15,4 +15,13 @@ if (!window.elementsToListen && !window.eventsToListen) {
|
|
|
15
15
|
})
|
|
16
16
|
})
|
|
17
17
|
})
|
|
18
|
+
|
|
19
|
+
function validateForm() {
|
|
20
|
+
const input = document.querySelector('#pattern')
|
|
21
|
+
if (!input.validity.valid) {
|
|
22
|
+
alert('Por favor, insira um código de país válido com três letras.')
|
|
23
|
+
return false // Impede o envio do formulário
|
|
24
|
+
}
|
|
25
|
+
return true // Permite o envio do formulário
|
|
26
|
+
}
|
|
18
27
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
if (!window.elementsToListen && !window.eventsToListen) {
|
|
2
|
+
const elementsToListen = document.querySelectorAll("br-tag");
|
|
3
|
+
|
|
4
|
+
const eventsToListen = ["click"];
|
|
5
|
+
|
|
6
|
+
elementsToListen.forEach((domElement) => {
|
|
7
|
+
eventsToListen.forEach((event) => {
|
|
8
|
+
domElement.addEventListener(event, function (event) {
|
|
9
|
+
console.log({
|
|
10
|
+
Evento: event.type,
|
|
11
|
+
Elemento: domElement.outerHTML,
|
|
12
|
+
...(event.detail && { Detail: event.detail }),
|
|
13
|
+
...(event.data && { Data: event.data }),
|
|
14
|
+
})
|
|
15
|
+
})
|
|
16
|
+
})
|
|
17
|
+
})
|
|
18
|
+
}
|
|
@@ -27,7 +27,7 @@ const MENU_ITEMS = [
|
|
|
27
27
|
{
|
|
28
28
|
path: 'input',
|
|
29
29
|
name: 'Input',
|
|
30
|
-
files: ['state', 'with-button', 'highlight', 'inline', 'density'],
|
|
30
|
+
files: ['state', 'with-button', 'highlight', 'inline', 'density', 'propriedades'],
|
|
31
31
|
},
|
|
32
32
|
{
|
|
33
33
|
path: 'item',
|
|
@@ -54,15 +54,15 @@ const MENU_ITEMS = [
|
|
|
54
54
|
name: 'Switch',
|
|
55
55
|
files: ['label', 'has-icon', 'density', 'state'],
|
|
56
56
|
},
|
|
57
|
+
{
|
|
58
|
+
path: 'tag',
|
|
59
|
+
name: 'Tag',
|
|
60
|
+
files: ['tag', 'densitys', 'status', 'interaction', 'icons', 'counts'],
|
|
61
|
+
},
|
|
57
62
|
{
|
|
58
63
|
path: 'textarea',
|
|
59
64
|
name: 'Textarea',
|
|
60
|
-
files: [
|
|
61
|
-
'simples',
|
|
62
|
-
'contador',
|
|
63
|
-
'density',
|
|
64
|
-
'inline',
|
|
65
|
-
],
|
|
65
|
+
files: ['simples', 'contador', 'density', 'inline'],
|
|
66
66
|
},
|
|
67
67
|
{
|
|
68
68
|
path: 'upload',
|
|
@@ -97,7 +97,7 @@ const CLEAR_MENU_FILTER = document.getElementById('clear-menu-filter')
|
|
|
97
97
|
const menuButton = document.getElementById('menu-button')
|
|
98
98
|
const responsiveMenuButton = document.getElementById('responsive-menu-button')
|
|
99
99
|
const menuElement = document.getElementById('main-navigation')
|
|
100
|
-
const iconElement = menuButton.querySelector('i')
|
|
100
|
+
const iconElement = menuButton.querySelector('i')
|
|
101
101
|
|
|
102
102
|
function setLinks() {
|
|
103
103
|
MENU_ITEMS.forEach((page) => {
|
|
@@ -109,7 +109,7 @@ function setLinks() {
|
|
|
109
109
|
event.preventDefault()
|
|
110
110
|
|
|
111
111
|
if (link.classList.contains('active')) {
|
|
112
|
-
return
|
|
112
|
+
return
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
removeAllActiveClasses()
|
|
@@ -118,7 +118,7 @@ function setLinks() {
|
|
|
118
118
|
window.history.pushState({}, '', `/${page.path}`)
|
|
119
119
|
|
|
120
120
|
if (window.innerWidth <= 575) {
|
|
121
|
-
toggleMenu()
|
|
121
|
+
toggleMenu()
|
|
122
122
|
}
|
|
123
123
|
})
|
|
124
124
|
|
|
@@ -143,7 +143,7 @@ function setLinks() {
|
|
|
143
143
|
event.preventDefault()
|
|
144
144
|
|
|
145
145
|
if (link.classList.contains('active')) {
|
|
146
|
-
return
|
|
146
|
+
return
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
removeAllActiveClasses()
|
|
@@ -152,7 +152,7 @@ function setLinks() {
|
|
|
152
152
|
window.history.pushState({}, '', `/${page.path}`)
|
|
153
153
|
|
|
154
154
|
if (window.innerWidth <= 575) {
|
|
155
|
-
toggleMenu()
|
|
155
|
+
toggleMenu()
|
|
156
156
|
}
|
|
157
157
|
})
|
|
158
158
|
|
|
@@ -187,15 +187,15 @@ window.addEventListener('load', () => {
|
|
|
187
187
|
menuButton.addEventListener('click', toggleMenu)
|
|
188
188
|
responsiveMenuButton.addEventListener('click', toggleMenu)
|
|
189
189
|
|
|
190
|
-
const mediaQuery = window.matchMedia(
|
|
191
|
-
mediaQuery.addEventListener('change', handleMediaChange)
|
|
190
|
+
const mediaQuery = window.matchMedia('(min-width: 576px)')
|
|
191
|
+
mediaQuery.addEventListener('change', handleMediaChange)
|
|
192
192
|
|
|
193
193
|
function handleMediaChange(event) {
|
|
194
|
-
if (event.matches && responsiveMenuButton) responsiveMenuButton.style.display = 'none'
|
|
195
|
-
if (!event.matches && responsiveMenuButton) responsiveMenuButton.style.display = ''
|
|
194
|
+
if (event.matches && responsiveMenuButton) responsiveMenuButton.style.display = 'none'
|
|
195
|
+
if (!event.matches && responsiveMenuButton) responsiveMenuButton.style.display = ''
|
|
196
196
|
}
|
|
197
197
|
|
|
198
|
-
handleMediaChange(mediaQuery)
|
|
198
|
+
handleMediaChange(mediaQuery)
|
|
199
199
|
|
|
200
200
|
MENU_FILTER.addEventListener('input', filterMenu)
|
|
201
201
|
CLEAR_MENU_FILTER.addEventListener('click', clearInput)
|
|
@@ -209,13 +209,13 @@ function removeAllActiveClasses() {
|
|
|
209
209
|
}
|
|
210
210
|
|
|
211
211
|
function toggleMenu() {
|
|
212
|
-
menuElement.classList.toggle('active')
|
|
212
|
+
menuElement.classList.toggle('active')
|
|
213
213
|
|
|
214
214
|
if (menuElement.classList.contains('active')) {
|
|
215
|
-
iconElement.classList.remove('fa-bars')
|
|
216
|
-
iconElement.classList.add('fa-times')
|
|
215
|
+
iconElement.classList.remove('fa-bars')
|
|
216
|
+
iconElement.classList.add('fa-times')
|
|
217
217
|
} else {
|
|
218
|
-
iconElement.classList.add('fa-bars')
|
|
219
|
-
iconElement.classList.remove('fa-times')
|
|
218
|
+
iconElement.classList.add('fa-bars')
|
|
219
|
+
iconElement.classList.remove('fa-times')
|
|
220
220
|
}
|
|
221
221
|
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
const MENU_ITEMS = [
|
|
2
|
+
{
|
|
3
|
+
path: 'avatar',
|
|
4
|
+
name: 'Avatar',
|
|
5
|
+
files: ['fotografico.html', 'iconico.html', 'letra.html'],
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
path: 'button',
|
|
9
|
+
name: 'Button',
|
|
10
|
+
files: ['colorMode.html', 'density.html', 'emphasis.html', 'iconPosition.html', 'shape.html', 'state.html'],
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
path: 'checkbox',
|
|
14
|
+
name: 'Checkbox',
|
|
15
|
+
files: ['hiddenLabel.html', 'horizontal.html', 'indeterminate.html', 'slotted.html', 'state.html', 'vertical.html'],
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
path: 'dropdown',
|
|
19
|
+
name: 'Dropdown',
|
|
20
|
+
files: ['dropdown.html'],
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
path: 'icon',
|
|
24
|
+
name: 'Icon',
|
|
25
|
+
files: ['flip.html', 'font-awesome.html', 'inline.html', 'rotate.html', 'width-height.html'],
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
path: 'input',
|
|
29
|
+
name: 'Input',
|
|
30
|
+
files: ['state.html', 'icon-button.html', 'highlight.html', 'inline.html', 'density.html'],
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
path: 'item',
|
|
34
|
+
name: 'Item',
|
|
35
|
+
files: ['density.html', 'item.html', 'state.html', 'selection.html'],
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
path: 'list',
|
|
39
|
+
name: 'List',
|
|
40
|
+
files: ['list.html', 'density.html', 'grouped.html', 'horizontal.html'],
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
path: 'loading',
|
|
44
|
+
name: 'Loading',
|
|
45
|
+
files: ['indeterminate.html', 'progress.html'],
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
path: 'message',
|
|
49
|
+
name: 'Message',
|
|
50
|
+
files: ['feedback.html', 'message.html'],
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
path: 'radio',
|
|
54
|
+
name: 'Radio',
|
|
55
|
+
files: ['radio-group.html', 'has-hidden-label.html', 'slotted.html', 'state.html'],
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
path: 'switch',
|
|
59
|
+
name: 'Switch',
|
|
60
|
+
files: ['label.html', 'hasIcon.html', 'density.html', 'state.html'],
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
path: 'textarea',
|
|
64
|
+
name: 'Textarea',
|
|
65
|
+
files: [
|
|
66
|
+
'textarea-contador.html',
|
|
67
|
+
'textarea-density.html',
|
|
68
|
+
'textarea-label-left.html',
|
|
69
|
+
'textarea-theme.html',
|
|
70
|
+
'textarea.html',
|
|
71
|
+
],
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
path: 'upload',
|
|
75
|
+
name: 'Upload',
|
|
76
|
+
files: ['single.html', 'multiple.html', 'restricted.html', 'disabled.html'],
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
path: 'tag',
|
|
80
|
+
name: 'Tag',
|
|
81
|
+
<<<<<<< HEAD
|
|
82
|
+
files: [['tag.html', 'densitys.html', 'status.html', 'interaction.html', 'icons.html', 'counts.html']],
|
|
83
|
+
=======
|
|
84
|
+
files: ['tag.html'],
|
|
85
|
+
>>>>>>> next
|
|
86
|
+
},
|
|
87
|
+
]
|
|
88
|
+
|
|
89
|
+
const MENU_BODY = document.querySelector('.menu-body')
|
|
90
|
+
const MENU_FILTER = document.getElementById('menu-filter')
|
|
91
|
+
const CLEAR_BUTTON = document.getElementById('clear-button')
|
|
92
|
+
|
|
93
|
+
// Função para definir links do menu
|
|
94
|
+
function setLinks() {
|
|
95
|
+
MENU_ITEMS.forEach((page) => {
|
|
96
|
+
const link = document.createElement('a')
|
|
97
|
+
link.href = `/${page.path}`
|
|
98
|
+
link.className = 'menu-item br-link'
|
|
99
|
+
link.textContent = page.name
|
|
100
|
+
link.addEventListener('click', (event) => {
|
|
101
|
+
event.preventDefault()
|
|
102
|
+
removeAllActiveClasses()
|
|
103
|
+
link.classList.add('active')
|
|
104
|
+
loadPage(page.path, page.files)
|
|
105
|
+
window.history.pushState({}, '', `/${page.path}`)
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
MENU_BODY.appendChild(link)
|
|
109
|
+
})
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Função para filtrar o menu
|
|
113
|
+
function filterMenu() {
|
|
114
|
+
const filterValue = MENU_FILTER.value.toLowerCase()
|
|
115
|
+
const menuItems = MENU_BODY.querySelectorAll('.menu-item')
|
|
116
|
+
|
|
117
|
+
menuItems.forEach((item) => {
|
|
118
|
+
if (item.textContent.toLowerCase().includes(filterValue)) {
|
|
119
|
+
item.style.display = '' // Exibir item
|
|
120
|
+
} else {
|
|
121
|
+
item.style.display = 'none' // Ocultar item
|
|
122
|
+
}
|
|
123
|
+
})
|
|
124
|
+
|
|
125
|
+
CLEAR_BUTTON.style.display = filterValue ? 'block' : 'none'
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// Função para limpar o input
|
|
129
|
+
function clearInput() {
|
|
130
|
+
MENU_FILTER.value = ''
|
|
131
|
+
filterMenu()
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// Função para carregar links de menu e página da URL
|
|
135
|
+
window.addEventListener('load', () => {
|
|
136
|
+
setLinks()
|
|
137
|
+
loadPageFromURL()
|
|
138
|
+
|
|
139
|
+
// Adicionar funcionalidade de exibir/esconder o menu ao clicar no botão
|
|
140
|
+
const menuButton = document.getElementById('menu-button')
|
|
141
|
+
menuButton.addEventListener('click', toggleMenu)
|
|
142
|
+
|
|
143
|
+
// Adicionar funcionalidade de filtro ao campo de entrada
|
|
144
|
+
MENU_FILTER.addEventListener('input', filterMenu)
|
|
145
|
+
CLEAR_BUTTON.addEventListener('click', clearInput)
|
|
146
|
+
})
|