@4byte/shared-lib 0.0.1
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/.editorconfig +17 -0
- package/.prettierrc +12 -0
- package/.vscode/extensions.json +4 -0
- package/.vscode/launch.json +20 -0
- package/.vscode/mcp.json +9 -0
- package/.vscode/tasks.json +42 -0
- package/README.md +284 -0
- package/angular.json +211 -0
- package/ng-package.json +11 -0
- package/package.json +44 -0
- package/projects/storybook-host/.storybook/main.ts +20 -0
- package/projects/storybook-host/.storybook/preview.ts +74 -0
- package/projects/storybook-host/.storybook/tsconfig.doc.json +10 -0
- package/projects/storybook-host/.storybook/tsconfig.json +22 -0
- package/projects/storybook-host/.storybook/tutorial/Installation.mdx +6 -0
- package/projects/storybook-host/.storybook/tutorial/Introduction.mdx +18 -0
- package/projects/storybook-host/.storybook/tutorial/Theming.mdx +14 -0
- package/projects/storybook-host/.storybook/typings.d.ts +4 -0
- package/projects/storybook-host/documentation.json +605 -0
- package/projects/storybook-host/public/favicon.ico +0 -0
- package/projects/storybook-host/src/app/app.config.ts +8 -0
- package/projects/storybook-host/src/app/app.css +0 -0
- package/projects/storybook-host/src/app/app.html +343 -0
- package/projects/storybook-host/src/app/app.ts +11 -0
- package/projects/storybook-host/src/index.html +13 -0
- package/projects/storybook-host/src/main.ts +6 -0
- package/projects/storybook-host/src/stories/assets/accessibility.png +0 -0
- package/projects/storybook-host/src/stories/assets/accessibility.svg +1 -0
- package/projects/storybook-host/src/stories/assets/addon-library.png +0 -0
- package/projects/storybook-host/src/stories/assets/assets.png +0 -0
- package/projects/storybook-host/src/stories/assets/avif-test-image.avif +0 -0
- package/projects/storybook-host/src/stories/assets/context.png +0 -0
- package/projects/storybook-host/src/stories/assets/discord.svg +1 -0
- package/projects/storybook-host/src/stories/assets/docs.png +0 -0
- package/projects/storybook-host/src/stories/assets/figma-plugin.png +0 -0
- package/projects/storybook-host/src/stories/assets/github.svg +1 -0
- package/projects/storybook-host/src/stories/assets/share.png +0 -0
- package/projects/storybook-host/src/stories/assets/styling.png +0 -0
- package/projects/storybook-host/src/stories/assets/testing.png +0 -0
- package/projects/storybook-host/src/stories/assets/theming.png +0 -0
- package/projects/storybook-host/src/stories/assets/tutorials.svg +1 -0
- package/projects/storybook-host/src/stories/assets/youtube.svg +1 -0
- package/projects/storybook-host/src/stories/button.component.ts +50 -0
- package/projects/storybook-host/src/stories/button.css +30 -0
- package/projects/storybook-host/src/stories/button.stories.ts +49 -0
- package/projects/storybook-host/src/stories/header.component.ts +78 -0
- package/projects/storybook-host/src/stories/header.css +32 -0
- package/projects/storybook-host/src/stories/header.stories.ts +33 -0
- package/projects/storybook-host/src/stories/page.component.ts +84 -0
- package/projects/storybook-host/src/stories/page.css +68 -0
- package/projects/storybook-host/src/stories/page.stories.ts +32 -0
- package/projects/storybook-host/src/stories/user.ts +3 -0
- package/projects/storybook-host/src/styles.css +1 -0
- package/projects/storybook-host/tsconfig.app.json +15 -0
- package/projects/storybook-host/tsconfig.spec.json +15 -0
- package/src/lib/components/byte-button/byte-button-group/byte-button-group.css +27 -0
- package/src/lib/components/byte-button/byte-button-group/byte-button-group.html +6 -0
- package/src/lib/components/byte-button/byte-button-group/byte-button-group.spec.ts +22 -0
- package/src/lib/components/byte-button/byte-button-group/byte-button-group.ts +35 -0
- package/src/lib/components/byte-button/byte-button.css +0 -0
- package/src/lib/components/byte-button/byte-button.directive.ts +17 -0
- package/src/lib/components/byte-button/byte-button.html +29 -0
- package/src/lib/components/byte-button/byte-button.module.ts +19 -0
- package/src/lib/components/byte-button/byte-button.stories.ts +449 -0
- package/src/lib/components/byte-button/byte-button.ts +129 -0
- package/src/lib/components/byte-dialog/byte-dialog.css +0 -0
- package/src/lib/components/byte-dialog/byte-dialog.directive.ts +21 -0
- package/src/lib/components/byte-dialog/byte-dialog.html +47 -0
- package/src/lib/components/byte-dialog/byte-dialog.module.ts +21 -0
- package/src/lib/components/byte-dialog/byte-dialog.spec.ts +22 -0
- package/src/lib/components/byte-dialog/byte-dialog.ts +121 -0
- package/src/lib/components/byte-dialog/byte.dialog.stories.ts +215 -0
- package/src/lib/components/byte-input/byte-input.css +29 -0
- package/src/lib/components/byte-input/byte-input.html +58 -0
- package/src/lib/components/byte-input/byte-input.spec.ts +22 -0
- package/src/lib/components/byte-input/byte-input.stories.ts +60 -0
- package/src/lib/components/byte-input/byte-input.ts +97 -0
- package/src/lib/components/byte-select/byte-select.css +16 -0
- package/src/lib/components/byte-select/byte-select.directive.ts +61 -0
- package/src/lib/components/byte-select/byte-select.html +101 -0
- package/src/lib/components/byte-select/byte-select.module.ts +26 -0
- package/src/lib/components/byte-select/byte-select.spec.ts +22 -0
- package/src/lib/components/byte-select/byte-select.stories.ts +194 -0
- package/src/lib/components/byte-select/byte-select.ts +168 -0
- package/src/lib/components/byte-select/index.ts +3 -0
- package/src/lib/components/byte-sidebar/byte-sidebar.css +0 -0
- package/src/lib/components/byte-sidebar/byte-sidebar.directive.ts +11 -0
- package/src/lib/components/byte-sidebar/byte-sidebar.html +31 -0
- package/src/lib/components/byte-sidebar/byte-sidebar.module.ts +16 -0
- package/src/lib/components/byte-sidebar/byte-sidebar.spec.ts +22 -0
- package/src/lib/components/byte-sidebar/byte-sidebar.stories.ts +190 -0
- package/src/lib/components/byte-sidebar/byte-sidebar.ts +108 -0
- package/src/lib/components/byte-table/byte-table.css +0 -0
- package/src/lib/components/byte-table/byte-table.directive.ts +49 -0
- package/src/lib/components/byte-table/byte-table.html +102 -0
- package/src/lib/components/byte-table/byte-table.module.ts +33 -0
- package/src/lib/components/byte-table/byte-table.spec.ts +22 -0
- package/src/lib/components/byte-table/byte-table.stories.ts +296 -0
- package/src/lib/components/byte-table/byte-table.ts +162 -0
- package/src/lib/components/calendar/calendar.css +16 -0
- package/src/lib/components/calendar/calendar.html +15 -0
- package/src/lib/components/calendar/calendar.spec.ts +22 -0
- package/src/lib/components/calendar/calendar.stories.ts +153 -0
- package/src/lib/components/calendar/calendar.ts +89 -0
- package/src/lib/components/select/select.css +16 -0
- package/src/lib/components/select/select.html +14 -0
- package/src/lib/components/select/select.spec.ts +22 -0
- package/src/lib/components/select/select.ts +73 -0
- package/src/lib/config/empresa-ui.token.ts +5 -0
- package/src/lib/providers/empresa-ui-config.ts +8 -0
- package/src/lib/providers/provide-empresa-ui.ts +42 -0
- package/src/lib/themes/CRM-Theme.ts +34 -0
- package/src/lib/themes/aura.ts +3 -0
- package/src/lib/themes/index.ts +2 -0
- package/src/lib/themes/registry.ts +9 -0
- package/src/lib/utils/inject-prime-icons.ts +12 -0
- package/src/public-api.ts +30 -0
- package/tsconfig.json +45 -0
- package/tsconfig.lib.json +11 -0
- package/tsconfig.lib.prod.json +9 -0
- package/tsconfig.spec.json +8 -0
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
import {
|
|
2
|
+
applicationConfig,
|
|
3
|
+
moduleMetadata,
|
|
4
|
+
type Meta,
|
|
5
|
+
type StoryObj
|
|
6
|
+
} from '@storybook/angular';
|
|
7
|
+
|
|
8
|
+
import { ByteTable } from './byte-table';
|
|
9
|
+
import { ByteTableModule } from './byte-table.module';
|
|
10
|
+
|
|
11
|
+
import { provideEmpresaUI } from './../../providers/provide-empresa-ui';
|
|
12
|
+
|
|
13
|
+
const meta: Meta<ByteTable> = {
|
|
14
|
+
title: 'Components/ByteTable',
|
|
15
|
+
component: ByteTable,
|
|
16
|
+
|
|
17
|
+
decorators: [
|
|
18
|
+
moduleMetadata({
|
|
19
|
+
imports: [
|
|
20
|
+
ByteTableModule
|
|
21
|
+
]
|
|
22
|
+
}),
|
|
23
|
+
|
|
24
|
+
(story, context) =>
|
|
25
|
+
applicationConfig({
|
|
26
|
+
providers: [
|
|
27
|
+
provideEmpresaUI({
|
|
28
|
+
theme: context.globals['theme']
|
|
29
|
+
})
|
|
30
|
+
]
|
|
31
|
+
})(story, context)
|
|
32
|
+
],
|
|
33
|
+
|
|
34
|
+
tags: ['autodocs'],
|
|
35
|
+
|
|
36
|
+
parameters: {
|
|
37
|
+
docs: {
|
|
38
|
+
description: {
|
|
39
|
+
component:
|
|
40
|
+
'Componente de tabla reutilizable para listados, basado en PrimeNG y compatible con templates personalizados.'
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export default meta;
|
|
47
|
+
|
|
48
|
+
type Story = StoryObj<ByteTable>;
|
|
49
|
+
|
|
50
|
+
const ciudades = [
|
|
51
|
+
{ name: 'Lima', code: 'LIM', poblacion: 9674755 },
|
|
52
|
+
{ name: 'Arequipa', code: 'AQP', poblacion: 1080635 },
|
|
53
|
+
{ name: 'Cusco', code: 'CUS', poblacion: 447588 },
|
|
54
|
+
{ name: 'Trujillo', code: 'TRU', poblacion: 970736 },
|
|
55
|
+
{ name: 'Piura', code: 'PIU', poblacion: 802067 }
|
|
56
|
+
];
|
|
57
|
+
|
|
58
|
+
const columnas = [
|
|
59
|
+
{ field: 'name', header: 'Ciudad' },
|
|
60
|
+
{ field: 'code', header: 'Código' },
|
|
61
|
+
{ field: 'poblacion', header: 'Población' }
|
|
62
|
+
];
|
|
63
|
+
|
|
64
|
+
export const Normal: Story = {
|
|
65
|
+
render: (args) => ({
|
|
66
|
+
props: args,
|
|
67
|
+
|
|
68
|
+
template: `
|
|
69
|
+
<byte-table
|
|
70
|
+
[value]="value"
|
|
71
|
+
[columns]="columns"
|
|
72
|
+
>
|
|
73
|
+
|
|
74
|
+
<ng-template byteTableHeader let-columns>
|
|
75
|
+
<tr>
|
|
76
|
+
@for (col of columns; track col.field) {
|
|
77
|
+
<th>{{ col.header }}</th>
|
|
78
|
+
}
|
|
79
|
+
</tr>
|
|
80
|
+
</ng-template>
|
|
81
|
+
|
|
82
|
+
<ng-template byteTableBody let-rowData let-columns="columns">
|
|
83
|
+
<tr>
|
|
84
|
+
<td>{{ rowData.name }}</td>
|
|
85
|
+
<td>{{ rowData.code }}</td>
|
|
86
|
+
<td>{{ rowData.poblacion }}</td>
|
|
87
|
+
<!--@for (col of columns; track col.field) {
|
|
88
|
+
<td>{{ rowData[col.field] }}</td>
|
|
89
|
+
}-->
|
|
90
|
+
</tr>
|
|
91
|
+
</ng-template>
|
|
92
|
+
|
|
93
|
+
</byte-table>
|
|
94
|
+
`
|
|
95
|
+
}),
|
|
96
|
+
|
|
97
|
+
args: {
|
|
98
|
+
value: ciudades,
|
|
99
|
+
columns: columnas
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export const Pagination: Story = {
|
|
104
|
+
render: (args) => ({
|
|
105
|
+
props: args,
|
|
106
|
+
|
|
107
|
+
template: `
|
|
108
|
+
<byte-table
|
|
109
|
+
[value]="value"
|
|
110
|
+
[columns]="columns"
|
|
111
|
+
[paginator]="paginator"
|
|
112
|
+
[rows]="rows"
|
|
113
|
+
[rowsPerPageOptions]="rowsPerPageOptions"
|
|
114
|
+
>
|
|
115
|
+
|
|
116
|
+
<ng-template byteTableHeader let-columns>
|
|
117
|
+
<tr>
|
|
118
|
+
@for (col of columns; track col.field) {
|
|
119
|
+
<th>{{ col.header }}</th>
|
|
120
|
+
}
|
|
121
|
+
</tr>
|
|
122
|
+
</ng-template>
|
|
123
|
+
|
|
124
|
+
<ng-template byteTableBody let-rowData let-columns="columns">
|
|
125
|
+
<tr>
|
|
126
|
+
@for (col of columns; track col.field) {
|
|
127
|
+
<td>{{ rowData[col.field] }}</td>
|
|
128
|
+
}
|
|
129
|
+
</tr>
|
|
130
|
+
</ng-template>
|
|
131
|
+
|
|
132
|
+
</byte-table>
|
|
133
|
+
`
|
|
134
|
+
}),
|
|
135
|
+
|
|
136
|
+
args: {
|
|
137
|
+
value: ciudades,
|
|
138
|
+
columns: columnas,
|
|
139
|
+
paginator: true,
|
|
140
|
+
rows: 2,
|
|
141
|
+
rowsPerPageOptions: [2, 5, 10]
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
export const Selection: Story = {
|
|
146
|
+
render: (args) => ({
|
|
147
|
+
props: args,
|
|
148
|
+
|
|
149
|
+
template: `
|
|
150
|
+
<byte-table
|
|
151
|
+
[value]="value"
|
|
152
|
+
[columns]="columns"
|
|
153
|
+
[selectionMode]="selectionMode"
|
|
154
|
+
[(ngModel)]="selection"
|
|
155
|
+
>
|
|
156
|
+
|
|
157
|
+
<ng-template byteTableHeader let-columns>
|
|
158
|
+
<tr>
|
|
159
|
+
<th style="width: 3rem"></th>
|
|
160
|
+
@for (col of columns; track col.field) {
|
|
161
|
+
<th>{{ col.header }}</th>
|
|
162
|
+
}
|
|
163
|
+
</tr>
|
|
164
|
+
</ng-template>
|
|
165
|
+
|
|
166
|
+
<ng-template byteTableBody let-rowData let-columns="columns">
|
|
167
|
+
<tr>
|
|
168
|
+
<td>
|
|
169
|
+
<p-tableCheckbox [value]="rowData" />
|
|
170
|
+
</td>
|
|
171
|
+
@for (col of columns; track col.field) {
|
|
172
|
+
<td>{{ rowData[col.field] }}</td>
|
|
173
|
+
}
|
|
174
|
+
</tr>
|
|
175
|
+
</ng-template>
|
|
176
|
+
|
|
177
|
+
</byte-table>
|
|
178
|
+
`
|
|
179
|
+
}),
|
|
180
|
+
|
|
181
|
+
args: {
|
|
182
|
+
value: ciudades,
|
|
183
|
+
columns: columnas,
|
|
184
|
+
selectionMode: 'multiple'
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
export const CustomBody: Story = {
|
|
189
|
+
render: (args) => ({
|
|
190
|
+
props: args,
|
|
191
|
+
|
|
192
|
+
template: `
|
|
193
|
+
<byte-table
|
|
194
|
+
[value]="value"
|
|
195
|
+
[columns]="columns"
|
|
196
|
+
>
|
|
197
|
+
|
|
198
|
+
<ng-template byteTableHeader let-columns>
|
|
199
|
+
<tr>
|
|
200
|
+
@for (col of columns; track col.field) {
|
|
201
|
+
<th>{{ col.header }}</th>
|
|
202
|
+
}
|
|
203
|
+
</tr>
|
|
204
|
+
</ng-template>
|
|
205
|
+
|
|
206
|
+
<ng-template byteTableBody let-rowData let-columns="columns">
|
|
207
|
+
<tr>
|
|
208
|
+
@for (col of columns; track col.field) {
|
|
209
|
+
<td>
|
|
210
|
+
@if (col.field === 'poblacion') {
|
|
211
|
+
<strong>{{ rowData[col.field] | number }}</strong>
|
|
212
|
+
} @else {
|
|
213
|
+
{{ rowData[col.field] }}
|
|
214
|
+
}
|
|
215
|
+
</td>
|
|
216
|
+
}
|
|
217
|
+
</tr>
|
|
218
|
+
</ng-template>
|
|
219
|
+
|
|
220
|
+
</byte-table>
|
|
221
|
+
`
|
|
222
|
+
}),
|
|
223
|
+
|
|
224
|
+
args: {
|
|
225
|
+
value: ciudades,
|
|
226
|
+
columns: columnas
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
export const AllTemplates: Story = {
|
|
231
|
+
render: (args) => ({
|
|
232
|
+
props: args,
|
|
233
|
+
|
|
234
|
+
template: `
|
|
235
|
+
<byte-table
|
|
236
|
+
[value]="value"
|
|
237
|
+
[columns]="columns"
|
|
238
|
+
[paginator]="paginator"
|
|
239
|
+
[rows]="rows"
|
|
240
|
+
>
|
|
241
|
+
|
|
242
|
+
<ng-template byteTableCaption>
|
|
243
|
+
<div style="font-weight: bold;">
|
|
244
|
+
Ciudades del Perú
|
|
245
|
+
</div>
|
|
246
|
+
</ng-template>
|
|
247
|
+
|
|
248
|
+
<ng-template byteTableHeader let-columns>
|
|
249
|
+
<tr>
|
|
250
|
+
@for (col of columns; track col.field) {
|
|
251
|
+
<th>{{ col.header }}</th>
|
|
252
|
+
}
|
|
253
|
+
</tr>
|
|
254
|
+
</ng-template>
|
|
255
|
+
|
|
256
|
+
<ng-template byteTableBody let-rowData let-columns="columns">
|
|
257
|
+
<tr>
|
|
258
|
+
@for (col of columns; track col.field) {
|
|
259
|
+
<td>{{ rowData[col.field] }}</td>
|
|
260
|
+
}
|
|
261
|
+
</tr>
|
|
262
|
+
</ng-template>
|
|
263
|
+
|
|
264
|
+
<ng-template byteTableFooter let-columns>
|
|
265
|
+
<tr>
|
|
266
|
+
<td [attr.colspan]="columns.length">
|
|
267
|
+
Total: {{ value.length }} ciudades
|
|
268
|
+
</td>
|
|
269
|
+
</tr>
|
|
270
|
+
</ng-template>
|
|
271
|
+
|
|
272
|
+
<ng-template byteTableEmptyMessage>
|
|
273
|
+
<tr>
|
|
274
|
+
<td colspan="3">
|
|
275
|
+
No hay ciudades disponibles
|
|
276
|
+
</td>
|
|
277
|
+
</tr>
|
|
278
|
+
</ng-template>
|
|
279
|
+
|
|
280
|
+
<ng-template byteTableSummary>
|
|
281
|
+
<div>
|
|
282
|
+
{{ value.length }} registros en total
|
|
283
|
+
</div>
|
|
284
|
+
</ng-template>
|
|
285
|
+
|
|
286
|
+
</byte-table>
|
|
287
|
+
`
|
|
288
|
+
}),
|
|
289
|
+
|
|
290
|
+
args: {
|
|
291
|
+
value: ciudades,
|
|
292
|
+
columns: columnas,
|
|
293
|
+
paginator: true,
|
|
294
|
+
rows: 3
|
|
295
|
+
}
|
|
296
|
+
};
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ChangeDetectionStrategy,
|
|
3
|
+
Component,
|
|
4
|
+
ContentChild,
|
|
5
|
+
forwardRef,
|
|
6
|
+
Input
|
|
7
|
+
} from '@angular/core';
|
|
8
|
+
|
|
9
|
+
import { NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
10
|
+
|
|
11
|
+
import { TableModule } from 'primeng/table';
|
|
12
|
+
import { NgTemplateOutlet } from '@angular/common';
|
|
13
|
+
|
|
14
|
+
import {
|
|
15
|
+
ByteTableCaptionDirective,
|
|
16
|
+
ByteTableHeaderDirective,
|
|
17
|
+
ByteTableBodyDirective,
|
|
18
|
+
ByteTableFooterDirective,
|
|
19
|
+
ByteTableEmptyMessageDirective,
|
|
20
|
+
ByteTableSummaryDirective
|
|
21
|
+
} from './byte-table.directive';
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@Component({
|
|
25
|
+
selector: 'byte-table',
|
|
26
|
+
|
|
27
|
+
imports: [
|
|
28
|
+
TableModule,
|
|
29
|
+
|
|
30
|
+
NgTemplateOutlet,
|
|
31
|
+
|
|
32
|
+
ByteTableCaptionDirective,
|
|
33
|
+
ByteTableHeaderDirective,
|
|
34
|
+
ByteTableBodyDirective,
|
|
35
|
+
ByteTableFooterDirective,
|
|
36
|
+
ByteTableEmptyMessageDirective,
|
|
37
|
+
ByteTableSummaryDirective
|
|
38
|
+
],
|
|
39
|
+
|
|
40
|
+
templateUrl: './byte-table.html',
|
|
41
|
+
|
|
42
|
+
styleUrl: './byte-table.css',
|
|
43
|
+
|
|
44
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
45
|
+
|
|
46
|
+
providers: [
|
|
47
|
+
{
|
|
48
|
+
provide: NG_VALUE_ACCESSOR,
|
|
49
|
+
useExisting: forwardRef(() => ByteTable),
|
|
50
|
+
multi: true
|
|
51
|
+
}
|
|
52
|
+
]
|
|
53
|
+
})
|
|
54
|
+
export class ByteTable {
|
|
55
|
+
|
|
56
|
+
// =====================================================
|
|
57
|
+
// INPUTS
|
|
58
|
+
// =====================================================
|
|
59
|
+
|
|
60
|
+
@Input()
|
|
61
|
+
value: any[] = [];
|
|
62
|
+
|
|
63
|
+
@Input()
|
|
64
|
+
columns: any[] = [];
|
|
65
|
+
|
|
66
|
+
@Input()
|
|
67
|
+
paginator = false;
|
|
68
|
+
|
|
69
|
+
@Input()
|
|
70
|
+
rows = 10;
|
|
71
|
+
|
|
72
|
+
@Input()
|
|
73
|
+
rowsPerPageOptions: number[] = [10, 25, 50];
|
|
74
|
+
|
|
75
|
+
@Input()
|
|
76
|
+
loading = false;
|
|
77
|
+
|
|
78
|
+
@Input()
|
|
79
|
+
sortField = '';
|
|
80
|
+
|
|
81
|
+
@Input()
|
|
82
|
+
sortOrder = 1;
|
|
83
|
+
|
|
84
|
+
@Input()
|
|
85
|
+
selectionMode: 'single' | 'multiple' | null = null;
|
|
86
|
+
|
|
87
|
+
@Input()
|
|
88
|
+
dataKey = '';
|
|
89
|
+
|
|
90
|
+
@Input()
|
|
91
|
+
scrollable = false;
|
|
92
|
+
|
|
93
|
+
@Input()
|
|
94
|
+
tableStyle: { [klass: string]: any } | null = null;
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
// =====================================================
|
|
98
|
+
// CUSTOM TEMPLATES
|
|
99
|
+
// =====================================================
|
|
100
|
+
|
|
101
|
+
@ContentChild(ByteTableCaptionDirective)
|
|
102
|
+
captionTemplate?: ByteTableCaptionDirective;
|
|
103
|
+
|
|
104
|
+
@ContentChild(ByteTableHeaderDirective)
|
|
105
|
+
headerTemplate?: ByteTableHeaderDirective;
|
|
106
|
+
|
|
107
|
+
@ContentChild(ByteTableBodyDirective)
|
|
108
|
+
bodyTemplate?: ByteTableBodyDirective;
|
|
109
|
+
|
|
110
|
+
@ContentChild(ByteTableFooterDirective)
|
|
111
|
+
footerTemplate?: ByteTableFooterDirective;
|
|
112
|
+
|
|
113
|
+
@ContentChild(ByteTableEmptyMessageDirective)
|
|
114
|
+
emptyMessageTemplate?: ByteTableEmptyMessageDirective;
|
|
115
|
+
|
|
116
|
+
@ContentChild(ByteTableSummaryDirective)
|
|
117
|
+
summaryTemplate?: ByteTableSummaryDirective;
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
// =====================================================
|
|
121
|
+
// SELECTION (CVA)
|
|
122
|
+
// =====================================================
|
|
123
|
+
|
|
124
|
+
selection: any = null;
|
|
125
|
+
|
|
126
|
+
private onChange: (value: any) => void = () => {};
|
|
127
|
+
|
|
128
|
+
private onTouched: () => void = () => {};
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
writeValue(value: any): void {
|
|
132
|
+
this.selection = value;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
registerOnChange(fn: (value: any) => void): void {
|
|
137
|
+
this.onChange = fn;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
registerOnTouched(fn: () => void): void {
|
|
142
|
+
this.onTouched = fn;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
setDisabledState(isDisabled: boolean): void {
|
|
147
|
+
// p-table no tiene un "disabled" nativo global; se puede usar
|
|
148
|
+
// para deshabilitar selección si lo necesitas más adelante.
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
onSelectionChange(value: any): void {
|
|
153
|
+
|
|
154
|
+
this.selection = value;
|
|
155
|
+
|
|
156
|
+
this.onChange(value);
|
|
157
|
+
|
|
158
|
+
this.onTouched();
|
|
159
|
+
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
display: block;
|
|
3
|
+
width: 100%;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
:host ::ng-deep .p-inputtext,
|
|
7
|
+
:host ::ng-deep .p-inputnumber,
|
|
8
|
+
:host ::ng-deep .p-textarea,
|
|
9
|
+
:host ::ng-deep .p-datepicker,
|
|
10
|
+
:host ::ng-deep .p-select {
|
|
11
|
+
width: 100%;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
:host ::ng-deep .p-inputnumber-input {
|
|
15
|
+
width: 100%;
|
|
16
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<p-datepicker
|
|
2
|
+
[(ngModel)]="value"
|
|
3
|
+
[dateFormat]="dateFormat"
|
|
4
|
+
[placeholder]="placeholder"
|
|
5
|
+
[showIcon]="showIcon"
|
|
6
|
+
[disabled]="disabled"
|
|
7
|
+
[minDate]="minDate"
|
|
8
|
+
[maxDate]="maxDate"
|
|
9
|
+
[readonlyInput]="readonlyInput"
|
|
10
|
+
[showClear]="showClear"
|
|
11
|
+
[inputId]="inputId"
|
|
12
|
+
[name]="name"
|
|
13
|
+
(ngModelChange)="onValueChange($event)"
|
|
14
|
+
appendTo="body"
|
|
15
|
+
/>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { Calendar } from './calendar';
|
|
4
|
+
|
|
5
|
+
describe('Calendar', () => {
|
|
6
|
+
let component: Calendar;
|
|
7
|
+
let fixture: ComponentFixture<Calendar>;
|
|
8
|
+
|
|
9
|
+
beforeEach(async () => {
|
|
10
|
+
await TestBed.configureTestingModule({
|
|
11
|
+
imports: [Calendar],
|
|
12
|
+
}).compileComponents();
|
|
13
|
+
|
|
14
|
+
fixture = TestBed.createComponent(Calendar);
|
|
15
|
+
component = fixture.componentInstance;
|
|
16
|
+
await fixture.whenStable();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('should create', () => {
|
|
20
|
+
expect(component).toBeTruthy();
|
|
21
|
+
});
|
|
22
|
+
});
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { applicationConfig, type Meta, type StoryObj } from '@storybook/angular';
|
|
2
|
+
|
|
3
|
+
import { Calendar } from './calendar';
|
|
4
|
+
import { provideEmpresaUI } from './../../providers/provide-empresa-ui';
|
|
5
|
+
|
|
6
|
+
const meta: Meta<Calendar> = {
|
|
7
|
+
title: 'Components/ByteCalendar',
|
|
8
|
+
component: Calendar,
|
|
9
|
+
|
|
10
|
+
decorators: [
|
|
11
|
+
(story, context) =>
|
|
12
|
+
applicationConfig({
|
|
13
|
+
providers: [
|
|
14
|
+
provideEmpresaUI({
|
|
15
|
+
theme: context.globals['theme'],
|
|
16
|
+
}),
|
|
17
|
+
],
|
|
18
|
+
})(story, context),
|
|
19
|
+
],
|
|
20
|
+
|
|
21
|
+
tags: ['autodocs'],
|
|
22
|
+
|
|
23
|
+
parameters: {
|
|
24
|
+
docs: {
|
|
25
|
+
description: {
|
|
26
|
+
component:
|
|
27
|
+
'Componente de calendario reutilizable basado en PrimeNG. Compatible con formularios mediante ControlValueAccessor.',
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
argTypes: {
|
|
33
|
+
dateFormat: {
|
|
34
|
+
control: 'text',
|
|
35
|
+
description: 'Formato utilizado para mostrar la fecha.',
|
|
36
|
+
table: {
|
|
37
|
+
defaultValue: { summary: 'dd/mm/yy' },
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
placeholder: {
|
|
42
|
+
control: 'text',
|
|
43
|
+
description: 'Texto mostrado cuando no se ha seleccionado una fecha.',
|
|
44
|
+
table: {
|
|
45
|
+
defaultValue: { summary: 'dd/mm/yyyy' },
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
showIcon: {
|
|
50
|
+
control: 'boolean',
|
|
51
|
+
description: 'Muestra u oculta el icono del calendario.',
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
disabled: {
|
|
55
|
+
control: 'boolean',
|
|
56
|
+
description: 'Deshabilita el calendario.',
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
minDate: {
|
|
60
|
+
control: 'date',
|
|
61
|
+
description: 'Fecha mínima que puede seleccionarse.',
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
maxDate: {
|
|
65
|
+
control: 'date',
|
|
66
|
+
description: 'Fecha máxima que puede seleccionarse.',
|
|
67
|
+
},
|
|
68
|
+
|
|
69
|
+
readonlyInput: {
|
|
70
|
+
control: 'boolean',
|
|
71
|
+
description: 'Impide escribir directamente en el input.',
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
showClear: {
|
|
75
|
+
control: 'boolean',
|
|
76
|
+
description: 'Muestra el botón para limpiar la fecha.',
|
|
77
|
+
},
|
|
78
|
+
|
|
79
|
+
inputId: {
|
|
80
|
+
control: 'text',
|
|
81
|
+
description: 'Identificador del input.',
|
|
82
|
+
},
|
|
83
|
+
|
|
84
|
+
name: {
|
|
85
|
+
control: 'text',
|
|
86
|
+
description: 'Nombre del campo.',
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export default meta;
|
|
92
|
+
|
|
93
|
+
type Story = StoryObj<Calendar>;
|
|
94
|
+
|
|
95
|
+
export const Default: Story = {
|
|
96
|
+
args: {
|
|
97
|
+
dateFormat: 'dd/mm/yy',
|
|
98
|
+
placeholder: 'dd/mm/yyyy',
|
|
99
|
+
showIcon: true,
|
|
100
|
+
disabled: false,
|
|
101
|
+
readonlyInput: false,
|
|
102
|
+
showClear: false,
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export const WithDate: Story = {
|
|
107
|
+
args: {
|
|
108
|
+
dateFormat: 'dd/mm/yy',
|
|
109
|
+
placeholder: 'dd/mm/yyyy',
|
|
110
|
+
showIcon: true,
|
|
111
|
+
value: new Date(),
|
|
112
|
+
},
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
export const WithoutIcon: Story = {
|
|
116
|
+
args: {
|
|
117
|
+
placeholder: 'Seleccione una fecha',
|
|
118
|
+
showIcon: false,
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
export const WithClear: Story = {
|
|
123
|
+
args: {
|
|
124
|
+
placeholder: 'Seleccione una fecha',
|
|
125
|
+
showIcon: true,
|
|
126
|
+
showClear: true,
|
|
127
|
+
},
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
export const Readonly: Story = {
|
|
131
|
+
args: {
|
|
132
|
+
placeholder: 'Seleccione una fecha',
|
|
133
|
+
showIcon: true,
|
|
134
|
+
readonlyInput: false,
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
export const Disabled: Story = {
|
|
139
|
+
args: {
|
|
140
|
+
placeholder: 'Seleccione una fecha',
|
|
141
|
+
showIcon: true,
|
|
142
|
+
disabled: true,
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
export const DateRange: Story = {
|
|
147
|
+
args: {
|
|
148
|
+
placeholder: 'Seleccione una fecha',
|
|
149
|
+
showIcon: true,
|
|
150
|
+
minDate: new Date(2026, 0, 1),
|
|
151
|
+
maxDate: new Date(2026, 11, 31),
|
|
152
|
+
},
|
|
153
|
+
};
|