@dev-tcloud/tcloud-ui 6.15.0 → 6.18.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/docs/tcloud-ui-accordion.md +345 -0
- package/docs/tcloud-ui-actions.md +88 -0
- package/docs/tcloud-ui-alert-banner.md +104 -0
- package/docs/tcloud-ui-array-to-text.md +361 -0
- package/docs/tcloud-ui-breadcrumb.md +103 -0
- package/docs/tcloud-ui-bytes.md +109 -0
- package/docs/tcloud-ui-calendar.md +387 -0
- package/docs/tcloud-ui-card-accordion.md +266 -0
- package/docs/tcloud-ui-card-title.md +47 -0
- package/docs/tcloud-ui-card.md +40 -0
- package/docs/tcloud-ui-choice-issues.md +59 -0
- package/docs/tcloud-ui-cnpj.md +102 -0
- package/docs/tcloud-ui-container.md +171 -0
- package/docs/tcloud-ui-cpf.md +102 -0
- package/docs/tcloud-ui-currency.md +271 -0
- package/docs/tcloud-ui-data-list.md +91 -0
- package/docs/tcloud-ui-datebr.md +139 -0
- package/docs/tcloud-ui-datepicker-time.md +191 -0
- package/docs/tcloud-ui-datepicker.md +186 -0
- package/docs/tcloud-ui-dropdown-multi.md +444 -0
- package/docs/tcloud-ui-dropdown.md +369 -0
- package/docs/tcloud-ui-el-copy.md +113 -0
- package/docs/tcloud-ui-empty-content.md +412 -0
- package/docs/tcloud-ui-faq.md +496 -0
- package/docs/tcloud-ui-filter-bar.md +86 -0
- package/docs/tcloud-ui-filters.md +337 -0
- package/docs/tcloud-ui-hover-parent.md +467 -0
- package/docs/tcloud-ui-icon-button.md +104 -0
- package/docs/tcloud-ui-input-container.md +520 -0
- package/docs/tcloud-ui-input-password.md +258 -0
- package/docs/tcloud-ui-input-search.md +314 -0
- package/docs/tcloud-ui-label-token.md +286 -0
- package/docs/tcloud-ui-legend.md +72 -0
- package/docs/tcloud-ui-line-step-circle.md +98 -0
- package/docs/tcloud-ui-line-step-title.md +194 -0
- package/docs/tcloud-ui-linha-logo.md +550 -0
- package/docs/tcloud-ui-loading.md +88 -0
- package/docs/tcloud-ui-message.md +539 -0
- package/docs/tcloud-ui-modal.md +196 -0
- package/docs/tcloud-ui-monthname.md +123 -0
- package/docs/tcloud-ui-multi-input.md +290 -0
- package/docs/tcloud-ui-multi-select.md +311 -0
- package/docs/tcloud-ui-multiples-values.md +157 -0
- package/docs/tcloud-ui-not-found.md +88 -0
- package/docs/tcloud-ui-number-step.md +134 -0
- package/docs/tcloud-ui-pagination.md +579 -0
- package/docs/tcloud-ui-progress-bar.md +65 -0
- package/docs/tcloud-ui-radio.md +83 -0
- package/docs/tcloud-ui-reorder-items.md +418 -0
- package/docs/tcloud-ui-respective.md +167 -0
- package/docs/tcloud-ui-scroll-box.md +109 -0
- package/docs/tcloud-ui-search-bar.md +88 -0
- package/docs/tcloud-ui-search-in-object.md +143 -0
- package/docs/tcloud-ui-search-input.md +74 -0
- package/docs/tcloud-ui-skeleton-loading.md +394 -0
- package/docs/tcloud-ui-slide-toggle.md +210 -0
- package/docs/tcloud-ui-statusinfo.md +138 -0
- package/docs/tcloud-ui-tab-group.md +376 -0
- package/docs/tcloud-ui-tab-menu.md +109 -0
- package/docs/tcloud-ui-table.md +96 -0
- package/docs/tcloud-ui-tag.md +379 -0
- package/docs/tcloud-ui-tc-badge.md +168 -0
- package/docs/tcloud-ui-tc-btn.md +189 -0
- package/docs/tcloud-ui-tc-colors.md +204 -0
- package/docs/tcloud-ui-tc-form-control.md +200 -0
- package/docs/tcloud-ui-tc-text.md +139 -0
- package/docs/tcloud-ui-tc-title.md +118 -0
- package/docs/tcloud-ui-tcloud-form.md +55 -0
- package/docs/tcloud-ui-toast.md +83 -0
- package/docs/tcloud-ui-tooltip.md +88 -0
- package/docs/tcloud-ui-topology.md +232 -0
- package/docs/tcloud-ui-upload-area.md +195 -0
- package/docs/tcloud-ui-welcome.md +112 -0
- package/docs/tcloud-ui-wizard-steps.md +103 -0
- package/js/tcloud-ui-app.js +11 -0
- package/package.json +1 -1
- package/scss/tcloud-revitalizacao/components/_tcloud-ui-table.scss +95 -0
- package/scss/tcloud-revitalizacao/tc-rev-styles.scss +1 -1
- package/scss/tcloud-revitalizacao/components/_tc-rev-table.scss +0 -57
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
# Skeleton Loading
|
|
2
|
+
|
|
3
|
+
## Características
|
|
4
|
+
|
|
5
|
+
O componente `tcloud-ui-skeleton-loading` é um componente de carregamento que exibe um placeholder animado (shimmer effect) enquanto o conteúdo está sendo carregado. É ideal para melhorar a experiência do usuário durante operações assíncronas, fornecendo feedback visual de que algo está acontecendo.
|
|
6
|
+
|
|
7
|
+
## Instalação
|
|
8
|
+
|
|
9
|
+
Para utilizar o componente Skeleton Loading, importe o módulo `TCloudUiModule`:
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
import { TCloudUiModule } from '@tcloud-ui/lib';
|
|
13
|
+
import { Component } from '@angular/core';
|
|
14
|
+
|
|
15
|
+
@Component({
|
|
16
|
+
selector: 'app-example',
|
|
17
|
+
standalone: true,
|
|
18
|
+
imports: [TCloudUiModule],
|
|
19
|
+
template: `
|
|
20
|
+
<tcloud-ui-skeleton-loading></tcloud-ui-skeleton-loading>
|
|
21
|
+
`
|
|
22
|
+
})
|
|
23
|
+
export class ExampleComponent {}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Ou importe diretamente o componente:
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
import { TCloudUiSkeletonLoadingComponent } from '@tcloud-ui/lib';
|
|
30
|
+
|
|
31
|
+
@Component({
|
|
32
|
+
selector: 'app-example',
|
|
33
|
+
standalone: true,
|
|
34
|
+
imports: [TCloudUiSkeletonLoadingComponent],
|
|
35
|
+
template: `...`
|
|
36
|
+
})
|
|
37
|
+
export class ExampleComponent {}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Propriedades (API)
|
|
41
|
+
|
|
42
|
+
### Inputs
|
|
43
|
+
|
|
44
|
+
| Nome | Tipo | Descrição | Valor Default |
|
|
45
|
+
|------|------|-----------|---------------|
|
|
46
|
+
| `width` | `string` | Largura do placeholder em unidades CSS | `'10rem'` |
|
|
47
|
+
| `height` | `string` | Altura do placeholder em unidades CSS | `'1.25rem'` |
|
|
48
|
+
| `borderRadius` | `string` | Raio de borda do placeholder em unidades CSS | `'0.3rem'` |
|
|
49
|
+
|
|
50
|
+
## Características Técnicas
|
|
51
|
+
|
|
52
|
+
- **Animação**: Shimmer gradient que se move horizontalmente
|
|
53
|
+
- **Duração**: 2 segundos por ciclo
|
|
54
|
+
- **Loop**: Infinito e contínuo
|
|
55
|
+
- **Gradiente**: Linear 90 graus da esquerda para direita
|
|
56
|
+
- **Responsividade**: Suporta unidades CSS relativas (rem, em, %) e absolutas (px)
|
|
57
|
+
|
|
58
|
+
## Exemplos de Uso
|
|
59
|
+
|
|
60
|
+
### Uso Básico
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
import { Component } from '@angular/core';
|
|
64
|
+
import { TCloudUiModule } from '@tcloud-ui/lib';
|
|
65
|
+
|
|
66
|
+
@Component({
|
|
67
|
+
selector: 'app-basic-skeleton',
|
|
68
|
+
standalone: true,
|
|
69
|
+
imports: [TCloudUiModule],
|
|
70
|
+
template: `
|
|
71
|
+
<!-- Placeholder padrão -->
|
|
72
|
+
<tcloud-ui-skeleton-loading></tcloud-ui-skeleton-loading>
|
|
73
|
+
|
|
74
|
+
<!-- Placeholder grande para títulos -->
|
|
75
|
+
<tcloud-ui-skeleton-loading
|
|
76
|
+
[width]="'15rem'"
|
|
77
|
+
[height]="'2rem'">
|
|
78
|
+
</tcloud-ui-skeleton-loading>
|
|
79
|
+
|
|
80
|
+
<!-- Placeholder pequeno para texto -->
|
|
81
|
+
<tcloud-ui-skeleton-loading
|
|
82
|
+
[width]="'20rem'"
|
|
83
|
+
[height]="'0.75rem'">
|
|
84
|
+
</tcloud-ui-skeleton-loading>
|
|
85
|
+
`
|
|
86
|
+
})
|
|
87
|
+
export class BasicSkeletonComponent {}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Carregamento de Dados
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
import { Component, signal } from '@angular/core';
|
|
94
|
+
import { TCloudUiModule } from '@tcloud-ui/lib';
|
|
95
|
+
import { CommonModule } from '@angular/common';
|
|
96
|
+
|
|
97
|
+
@Component({
|
|
98
|
+
selector: 'app-data-loading-skeleton',
|
|
99
|
+
standalone: true,
|
|
100
|
+
imports: [CommonModule, TCloudUiModule],
|
|
101
|
+
template: `
|
|
102
|
+
<div class="container">
|
|
103
|
+
@if (loading()) {
|
|
104
|
+
<div class="skeleton-wrapper">
|
|
105
|
+
<tcloud-ui-skeleton-loading
|
|
106
|
+
[width]="'100%'"
|
|
107
|
+
[height]="'2rem'">
|
|
108
|
+
</tcloud-ui-skeleton-loading>
|
|
109
|
+
<tcloud-ui-skeleton-loading
|
|
110
|
+
[width]="'100%'"
|
|
111
|
+
[height]="'1rem'"
|
|
112
|
+
class="mt-2">
|
|
113
|
+
</tcloud-ui-skeleton-loading>
|
|
114
|
+
<tcloud-ui-skeleton-loading
|
|
115
|
+
[width]="'80%'"
|
|
116
|
+
[height]="'1rem'"
|
|
117
|
+
class="mt-2">
|
|
118
|
+
</tcloud-ui-skeleton-loading>
|
|
119
|
+
</div>
|
|
120
|
+
} @else {
|
|
121
|
+
<h2>{{ title() }}</h2>
|
|
122
|
+
<p>{{ description() }}</p>
|
|
123
|
+
}
|
|
124
|
+
</div>
|
|
125
|
+
`,
|
|
126
|
+
styles: [`
|
|
127
|
+
.container {
|
|
128
|
+
padding: 1rem;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.skeleton-wrapper {
|
|
132
|
+
display: flex;
|
|
133
|
+
flex-direction: column;
|
|
134
|
+
gap: 0.75rem;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.mt-2 {
|
|
138
|
+
margin-top: 0.5rem;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
h2 {
|
|
142
|
+
margin: 0 0 0.5rem 0;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
p {
|
|
146
|
+
margin: 0;
|
|
147
|
+
color: #666;
|
|
148
|
+
}
|
|
149
|
+
`]
|
|
150
|
+
})
|
|
151
|
+
export class DataLoadingSkeletonComponent {
|
|
152
|
+
loading = signal<boolean>(true);
|
|
153
|
+
title = signal<string>('Título do Conteúdo');
|
|
154
|
+
description = signal<string>('Descrição detalhada sobre o conteúdo carregado');
|
|
155
|
+
|
|
156
|
+
constructor() {
|
|
157
|
+
setTimeout(() => {
|
|
158
|
+
this.loading.set(false);
|
|
159
|
+
}, 3000);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### Layout com Múltiplos Placeholders
|
|
165
|
+
|
|
166
|
+
```typescript
|
|
167
|
+
import { Component, signal } from '@angular/core';
|
|
168
|
+
import { TCloudUiModule } from '@tcloud-ui/lib';
|
|
169
|
+
import { CommonModule } from '@angular/common';
|
|
170
|
+
|
|
171
|
+
@Component({
|
|
172
|
+
selector: 'app-card-skeleton',
|
|
173
|
+
standalone: true,
|
|
174
|
+
imports: [CommonModule, TCloudUiModule],
|
|
175
|
+
template: `
|
|
176
|
+
<div class="card">
|
|
177
|
+
@if (loading()) {
|
|
178
|
+
<div class="card-skeleton">
|
|
179
|
+
<tcloud-ui-skeleton-loading
|
|
180
|
+
[width]="'100%'"
|
|
181
|
+
[height]="'12rem'"
|
|
182
|
+
[borderRadius]="'0.5rem'">
|
|
183
|
+
</tcloud-ui-skeleton-loading>
|
|
184
|
+
|
|
185
|
+
<div class="card-content">
|
|
186
|
+
<tcloud-ui-skeleton-loading
|
|
187
|
+
[width]="'80%'"
|
|
188
|
+
[height]="'1.5rem'">
|
|
189
|
+
</tcloud-ui-skeleton-loading>
|
|
190
|
+
|
|
191
|
+
<tcloud-ui-skeleton-loading
|
|
192
|
+
[width]="'100%'"
|
|
193
|
+
[height]="'1rem'"
|
|
194
|
+
class="mt-1">
|
|
195
|
+
</tcloud-ui-skeleton-loading>
|
|
196
|
+
|
|
197
|
+
<tcloud-ui-skeleton-loading
|
|
198
|
+
[width]="'90%'"
|
|
199
|
+
[height]="'1rem'"
|
|
200
|
+
class="mt-1">
|
|
201
|
+
</tcloud-ui-skeleton-loading>
|
|
202
|
+
</div>
|
|
203
|
+
</div>
|
|
204
|
+
} @else {
|
|
205
|
+
<img [src]="imageUrl()" alt="Card image" class="card-image">
|
|
206
|
+
<div class="card-content">
|
|
207
|
+
<h3>{{ cardTitle() }}</h3>
|
|
208
|
+
<p>{{ cardDescription() }}</p>
|
|
209
|
+
</div>
|
|
210
|
+
}
|
|
211
|
+
</div>
|
|
212
|
+
`,
|
|
213
|
+
styles: [`
|
|
214
|
+
.card {
|
|
215
|
+
border: 1px solid #e0e0e0;
|
|
216
|
+
border-radius: 0.5rem;
|
|
217
|
+
overflow: hidden;
|
|
218
|
+
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
.card-skeleton {
|
|
222
|
+
padding: 1rem;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
.card-image {
|
|
226
|
+
width: 100%;
|
|
227
|
+
height: 12rem;
|
|
228
|
+
object-fit: cover;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
.card-content {
|
|
232
|
+
padding: 1rem;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
.card-content h3 {
|
|
236
|
+
margin: 0 0 0.5rem 0;
|
|
237
|
+
font-size: 1.25rem;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
.card-content p {
|
|
241
|
+
margin: 0;
|
|
242
|
+
color: #666;
|
|
243
|
+
font-size: 0.875rem;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
.mt-1 {
|
|
247
|
+
margin-top: 0.5rem;
|
|
248
|
+
}
|
|
249
|
+
`]
|
|
250
|
+
})
|
|
251
|
+
export class CardSkeletonComponent {
|
|
252
|
+
loading = signal<boolean>(true);
|
|
253
|
+
imageUrl = signal<string>('https://via.placeholder.com/300x150');
|
|
254
|
+
cardTitle = signal<string>('Título do Card');
|
|
255
|
+
cardDescription = signal<string>('Descrição breve do conteúdo do card que será exibida aqui.');
|
|
256
|
+
|
|
257
|
+
constructor() {
|
|
258
|
+
setTimeout(() => {
|
|
259
|
+
this.loading.set(false);
|
|
260
|
+
}, 2000);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
### Variações de Tamanho
|
|
266
|
+
|
|
267
|
+
```typescript
|
|
268
|
+
import { Component } from '@angular/core';
|
|
269
|
+
import { TCloudUiModule } from '@tcloud-ui/lib';
|
|
270
|
+
|
|
271
|
+
@Component({
|
|
272
|
+
selector: 'app-skeleton-variants',
|
|
273
|
+
standalone: true,
|
|
274
|
+
imports: [TCloudUiModule],
|
|
275
|
+
template: `
|
|
276
|
+
<div class="variants-container">
|
|
277
|
+
<div class="variant">
|
|
278
|
+
<h4>Pequeno (Texto)</h4>
|
|
279
|
+
<tcloud-ui-skeleton-loading
|
|
280
|
+
[width]="'10rem'"
|
|
281
|
+
[height]="'0.75rem'">
|
|
282
|
+
</tcloud-ui-skeleton-loading>
|
|
283
|
+
</div>
|
|
284
|
+
|
|
285
|
+
<div class="variant">
|
|
286
|
+
<h4>Médio (Padrão)</h4>
|
|
287
|
+
<tcloud-ui-skeleton-loading
|
|
288
|
+
[width]="'15rem'"
|
|
289
|
+
[height]="'1.25rem'">
|
|
290
|
+
</tcloud-ui-skeleton-loading>
|
|
291
|
+
</div>
|
|
292
|
+
|
|
293
|
+
<div class="variant">
|
|
294
|
+
<h4>Grande (Título)</h4>
|
|
295
|
+
<tcloud-ui-skeleton-loading
|
|
296
|
+
[width]="'20rem'"
|
|
297
|
+
[height]="'2rem'">
|
|
298
|
+
</tcloud-ui-skeleton-loading>
|
|
299
|
+
</div>
|
|
300
|
+
|
|
301
|
+
<div class="variant">
|
|
302
|
+
<h4>Cheio (100%)</h4>
|
|
303
|
+
<tcloud-ui-skeleton-loading
|
|
304
|
+
[width]="'100%'"
|
|
305
|
+
[height]="'3rem'">
|
|
306
|
+
</tcloud-ui-skeleton-loading>
|
|
307
|
+
</div>
|
|
308
|
+
|
|
309
|
+
<div class="variant">
|
|
310
|
+
<h4>Arredondado</h4>
|
|
311
|
+
<tcloud-ui-skeleton-loading
|
|
312
|
+
[width]="'8rem'"
|
|
313
|
+
[height]="'8rem'"
|
|
314
|
+
[borderRadius]="'50%'">
|
|
315
|
+
</tcloud-ui-skeleton-loading>
|
|
316
|
+
</div>
|
|
317
|
+
</div>
|
|
318
|
+
`,
|
|
319
|
+
styles: [`
|
|
320
|
+
.variants-container {
|
|
321
|
+
display: grid;
|
|
322
|
+
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
|
|
323
|
+
gap: 2rem;
|
|
324
|
+
padding: 1rem;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
.variant {
|
|
328
|
+
border: 1px solid #e0e0e0;
|
|
329
|
+
padding: 1rem;
|
|
330
|
+
border-radius: 0.5rem;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
.variant h4 {
|
|
334
|
+
margin: 0 0 1rem 0;
|
|
335
|
+
font-size: 0.875rem;
|
|
336
|
+
font-weight: 600;
|
|
337
|
+
color: #333;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
tcloud-ui-skeleton-loading {
|
|
341
|
+
display: block;
|
|
342
|
+
}
|
|
343
|
+
`]
|
|
344
|
+
})
|
|
345
|
+
export class SkeletonVariantsComponent {}
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
## Boas Práticas
|
|
349
|
+
|
|
350
|
+
1. **Use em operações assíncronas**: Exiba o skeleton loading enquanto dados estão sendo carregados de uma API
|
|
351
|
+
2. **Combine com estrutura real**: Mantenha o layout do skeleton similar ao conteúdo real que será exibido
|
|
352
|
+
3. **Tempo apropriado**: Não use por muito tempo; idealmente 2-5 segundos é o esperado
|
|
353
|
+
4. **Acessibilidade**: Considere adicionar um `aria-label` para leitores de tela
|
|
354
|
+
5. **Dimensões realistas**: Use dimensões que correspondem ao conteúdo que será carregado
|
|
355
|
+
|
|
356
|
+
## Casos de Uso
|
|
357
|
+
|
|
358
|
+
- Carregamento de listas e tabelas
|
|
359
|
+
- Carregamento de cards e imagens
|
|
360
|
+
- Carregamento de conteúdo de detalhes
|
|
361
|
+
- Simulação de estrutura durante requisições HTTP
|
|
362
|
+
- Feedback visual em operações que levam tempo
|
|
363
|
+
|
|
364
|
+
## Performance
|
|
365
|
+
|
|
366
|
+
O componente Skeleton Loading é otimizado para performance:
|
|
367
|
+
- Utiliza animação CSS pura (não JavaScript)
|
|
368
|
+
- Renderização eficiente sem reflows desnecessários
|
|
369
|
+
- Suporta múltiplas instâncias sem impacto significativo
|
|
370
|
+
|
|
371
|
+
## Responsividade
|
|
372
|
+
|
|
373
|
+
O componente funciona com qualquer unidade CSS, facilitando layouts responsivos:
|
|
374
|
+
|
|
375
|
+
```typescript
|
|
376
|
+
// Em desktop
|
|
377
|
+
<tcloud-ui-skeleton-loading [width]="'100%'" [height]="'2rem'"></tcloud-ui-skeleton-loading>
|
|
378
|
+
|
|
379
|
+
// Em mobile - ajuste via CSS media queries ou propriedades dinâmicas
|
|
380
|
+
<tcloud-ui-skeleton-loading
|
|
381
|
+
[width]="isMobile() ? '100%' : '50%'"
|
|
382
|
+
[height]="'1.5rem'">
|
|
383
|
+
</tcloud-ui-skeleton-loading>
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
## Compatibilidade
|
|
387
|
+
|
|
388
|
+
- **Angular**: 16+
|
|
389
|
+
- **Browsers**: Todos os navegadores modernos que suportam CSS Grid e Flexbox
|
|
390
|
+
- **CSS Variables**: Utiliza variáveis CSS customizáveis
|
|
391
|
+
|
|
392
|
+
## Suporte
|
|
393
|
+
|
|
394
|
+
Para reportar problemas, sugestões ou criar pull requests, visite o repositório oficial do projeto.
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
# Slide Toggle
|
|
2
|
+
|
|
3
|
+
## Características
|
|
4
|
+
|
|
5
|
+
A diretiva `tcloudUiSlideToggle` transforma um `<input type="checkbox">` em um toggle switch estilizado. Aplica automaticamente a classe CSS `tcloud-ui-slide-toggle` ao elemento host, transformando a aparência padrão do checkbox em um controle de alternância visual com animação suave de transição.
|
|
6
|
+
|
|
7
|
+
## Instalação
|
|
8
|
+
|
|
9
|
+
Para utilizar a diretiva Slide Toggle, importe o módulo `TCloudUiModule`:
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
import { TCloudUiModule } from '@tcloud-ui/lib';
|
|
13
|
+
import { Component } from '@angular/core';
|
|
14
|
+
|
|
15
|
+
@Component({
|
|
16
|
+
selector: 'app-example',
|
|
17
|
+
standalone: true,
|
|
18
|
+
imports: [TCloudUiModule],
|
|
19
|
+
template: `<input type="checkbox" tcloudUiSlideToggle />`
|
|
20
|
+
})
|
|
21
|
+
export class ExampleComponent {}
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Ou importe diretamente a diretiva:
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
import { TCloudUiSlideToggleDirective } from '@tcloud-ui/lib';
|
|
28
|
+
|
|
29
|
+
@Component({
|
|
30
|
+
selector: 'app-example',
|
|
31
|
+
standalone: true,
|
|
32
|
+
imports: [TCloudUiSlideToggleDirective],
|
|
33
|
+
template: `<input type="checkbox" tcloudUiSlideToggle />`
|
|
34
|
+
})
|
|
35
|
+
export class ExampleComponent {}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Propriedades (API)
|
|
39
|
+
|
|
40
|
+
### Inputs
|
|
41
|
+
|
|
42
|
+
| Nome | Tipo | Descrição | Valor Default |
|
|
43
|
+
|------|------|-----------|---------------|
|
|
44
|
+
| (nativo) `disabled` | `boolean` | Desabilita o toggle, alterando cursor e estilo visual | `false` |
|
|
45
|
+
| (nativo) `checked` | `boolean` | Estado inicial do toggle | `false` |
|
|
46
|
+
|
|
47
|
+
### Outputs
|
|
48
|
+
|
|
49
|
+
| Nome | Tipo de Evento | Descrição |
|
|
50
|
+
|------|----------------|-----------|
|
|
51
|
+
| (nativo) `change` | `Event` | Evento nativo disparado quando o estado do checkbox muda |
|
|
52
|
+
|
|
53
|
+
### Selector
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
input[type="checkbox"][tcloudUiSlideToggle]
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
A diretiva só é aplicável a elementos `<input type="checkbox">` que possuam o atributo `tcloudUiSlideToggle`.
|
|
60
|
+
|
|
61
|
+
## Exemplos de Uso
|
|
62
|
+
|
|
63
|
+
### Uso Básico
|
|
64
|
+
|
|
65
|
+
```typescript
|
|
66
|
+
import { Component } from '@angular/core';
|
|
67
|
+
import { TCloudUiModule } from '@tcloud-ui/lib';
|
|
68
|
+
|
|
69
|
+
@Component({
|
|
70
|
+
selector: 'app-basic-toggle',
|
|
71
|
+
standalone: true,
|
|
72
|
+
imports: [TCloudUiModule],
|
|
73
|
+
template: `
|
|
74
|
+
<input type="checkbox" tcloudUiSlideToggle />
|
|
75
|
+
`
|
|
76
|
+
})
|
|
77
|
+
export class BasicToggleComponent {}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Com Two-Way Binding (ngModel)
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
import { Component } from '@angular/core';
|
|
84
|
+
import { TCloudUiModule } from '@tcloud-ui/lib';
|
|
85
|
+
import { FormsModule } from '@angular/forms';
|
|
86
|
+
|
|
87
|
+
@Component({
|
|
88
|
+
selector: 'app-bound-toggle',
|
|
89
|
+
standalone: true,
|
|
90
|
+
imports: [TCloudUiModule, FormsModule],
|
|
91
|
+
template: `
|
|
92
|
+
<label>
|
|
93
|
+
<input type="checkbox" tcloudUiSlideToggle [(ngModel)]="isActive" />
|
|
94
|
+
{{ isActive ? 'Ativo' : 'Inativo' }}
|
|
95
|
+
</label>
|
|
96
|
+
`
|
|
97
|
+
})
|
|
98
|
+
export class BoundToggleComponent {
|
|
99
|
+
isActive = false;
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Estado Desabilitado
|
|
104
|
+
|
|
105
|
+
```typescript
|
|
106
|
+
import { Component } from '@angular/core';
|
|
107
|
+
import { TCloudUiModule } from '@tcloud-ui/lib';
|
|
108
|
+
|
|
109
|
+
@Component({
|
|
110
|
+
selector: 'app-disabled-toggle',
|
|
111
|
+
standalone: true,
|
|
112
|
+
imports: [TCloudUiModule],
|
|
113
|
+
template: `
|
|
114
|
+
<div>
|
|
115
|
+
<p>Desabilitado (off):</p>
|
|
116
|
+
<input type="checkbox" tcloudUiSlideToggle [disabled]="true" />
|
|
117
|
+
</div>
|
|
118
|
+
|
|
119
|
+
<div>
|
|
120
|
+
<p>Desabilitado (on):</p>
|
|
121
|
+
<input type="checkbox" tcloudUiSlideToggle [disabled]="true" [checked]="true" />
|
|
122
|
+
</div>
|
|
123
|
+
`
|
|
124
|
+
})
|
|
125
|
+
export class DisabledToggleComponent {}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Em Formulário Reativo
|
|
129
|
+
|
|
130
|
+
```typescript
|
|
131
|
+
import { Component, OnInit } from '@angular/core';
|
|
132
|
+
import { TCloudUiModule } from '@tcloud-ui/lib';
|
|
133
|
+
import { FormBuilder, FormGroup, ReactiveFormsModule } from '@angular/forms';
|
|
134
|
+
|
|
135
|
+
@Component({
|
|
136
|
+
selector: 'app-reactive-toggle',
|
|
137
|
+
standalone: true,
|
|
138
|
+
imports: [TCloudUiModule, ReactiveFormsModule],
|
|
139
|
+
template: `
|
|
140
|
+
<form [formGroup]="form">
|
|
141
|
+
<label>
|
|
142
|
+
Notificações por e-mail
|
|
143
|
+
<input type="checkbox" tcloudUiSlideToggle formControlName="emailNotifications" />
|
|
144
|
+
</label>
|
|
145
|
+
|
|
146
|
+
<label>
|
|
147
|
+
Modo escuro
|
|
148
|
+
<input type="checkbox" tcloudUiSlideToggle formControlName="darkMode" />
|
|
149
|
+
</label>
|
|
150
|
+
</form>
|
|
151
|
+
|
|
152
|
+
<pre>{{ form.value | json }}</pre>
|
|
153
|
+
`
|
|
154
|
+
})
|
|
155
|
+
export class ReactiveToggleComponent implements OnInit {
|
|
156
|
+
form!: FormGroup;
|
|
157
|
+
|
|
158
|
+
constructor(private fb: FormBuilder) {}
|
|
159
|
+
|
|
160
|
+
ngOnInit(): void {
|
|
161
|
+
this.form = this.fb.group({
|
|
162
|
+
emailNotifications: [true],
|
|
163
|
+
darkMode: [false]
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### Uso com Evento de Mudança
|
|
170
|
+
|
|
171
|
+
```typescript
|
|
172
|
+
import { Component } from '@angular/core';
|
|
173
|
+
import { TCloudUiModule } from '@tcloud-ui/lib';
|
|
174
|
+
|
|
175
|
+
@Component({
|
|
176
|
+
selector: 'app-event-toggle',
|
|
177
|
+
standalone: true,
|
|
178
|
+
imports: [TCloudUiModule],
|
|
179
|
+
template: `
|
|
180
|
+
<input
|
|
181
|
+
type="checkbox"
|
|
182
|
+
tcloudUiSlideToggle
|
|
183
|
+
(change)="onToggleChange($event)"
|
|
184
|
+
/>
|
|
185
|
+
<p>Último estado: {{ lastState }}</p>
|
|
186
|
+
`
|
|
187
|
+
})
|
|
188
|
+
export class EventToggleComponent {
|
|
189
|
+
lastState: string = 'N/A';
|
|
190
|
+
|
|
191
|
+
onToggleChange(event: Event): void {
|
|
192
|
+
const checked = (event.target as HTMLInputElement).checked;
|
|
193
|
+
this.lastState = checked ? 'Ligado' : 'Desligado';
|
|
194
|
+
console.log('Toggle alterado para:', this.lastState);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
## Comportamento Visual
|
|
200
|
+
|
|
201
|
+
- **Off**: Fundo cinza (`--c-neutral-300`) com indicador circular branco à esquerda
|
|
202
|
+
- **On**: Fundo na cor primária (`--c-primary-500`) com indicador circular branco à direita
|
|
203
|
+
- **Disabled**: Fundo cinza com cursor `not-allowed`
|
|
204
|
+
- **Transição**: Animação suave de 0.2s ao alternar estados
|
|
205
|
+
|
|
206
|
+
## Compatibilidade
|
|
207
|
+
|
|
208
|
+
- **Angular**: 16+
|
|
209
|
+
- **Browsers**: Todos os navegadores modernos
|
|
210
|
+
- **Formulários**: Compatível com `ngModel`, `FormControl` e formulários reativos
|