@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,121 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ChangeDetectionStrategy,
|
|
3
|
+
Component,
|
|
4
|
+
ContentChild,
|
|
5
|
+
EventEmitter,
|
|
6
|
+
Input,
|
|
7
|
+
Output
|
|
8
|
+
} from '@angular/core';
|
|
9
|
+
|
|
10
|
+
import { NgTemplateOutlet } from '@angular/common';
|
|
11
|
+
|
|
12
|
+
import { DialogModule } from 'primeng/dialog';
|
|
13
|
+
|
|
14
|
+
import {
|
|
15
|
+
ByteDialogHeaderDirective,
|
|
16
|
+
ByteDialogFooterDirective
|
|
17
|
+
} from './byte-dialog.directive';
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@Component({
|
|
21
|
+
selector: 'byte-dialog',
|
|
22
|
+
|
|
23
|
+
imports: [
|
|
24
|
+
DialogModule,
|
|
25
|
+
|
|
26
|
+
NgTemplateOutlet,
|
|
27
|
+
|
|
28
|
+
ByteDialogHeaderDirective,
|
|
29
|
+
ByteDialogFooterDirective
|
|
30
|
+
],
|
|
31
|
+
|
|
32
|
+
templateUrl: './byte-dialog.html',
|
|
33
|
+
|
|
34
|
+
styleUrl: './byte-dialog.css',
|
|
35
|
+
|
|
36
|
+
changeDetection: ChangeDetectionStrategy.OnPush
|
|
37
|
+
})
|
|
38
|
+
export class ByteDialog {
|
|
39
|
+
|
|
40
|
+
// =====================================================
|
|
41
|
+
// INPUTS
|
|
42
|
+
// =====================================================
|
|
43
|
+
|
|
44
|
+
@Input()
|
|
45
|
+
visible = false;
|
|
46
|
+
|
|
47
|
+
@Input()
|
|
48
|
+
header = '';
|
|
49
|
+
|
|
50
|
+
@Input()
|
|
51
|
+
modal = true;
|
|
52
|
+
|
|
53
|
+
@Input()
|
|
54
|
+
closable = true;
|
|
55
|
+
|
|
56
|
+
@Input()
|
|
57
|
+
draggable = true;
|
|
58
|
+
|
|
59
|
+
@Input()
|
|
60
|
+
resizable = false;
|
|
61
|
+
|
|
62
|
+
@Input()
|
|
63
|
+
dismissableMask = false;
|
|
64
|
+
|
|
65
|
+
@Input()
|
|
66
|
+
closeOnEscape = true;
|
|
67
|
+
|
|
68
|
+
@Input()
|
|
69
|
+
maximizable = false;
|
|
70
|
+
|
|
71
|
+
@Input()
|
|
72
|
+
blockScroll = true;
|
|
73
|
+
|
|
74
|
+
@Input()
|
|
75
|
+
position: 'center' | 'top' | 'bottom' | 'left' | 'right' | 'topleft' | 'topright' | 'bottomleft' | 'bottomright' = 'center';
|
|
76
|
+
|
|
77
|
+
@Input()
|
|
78
|
+
style: { [klass: string]: any } | null = null;
|
|
79
|
+
|
|
80
|
+
@Input()
|
|
81
|
+
styleClass = '';
|
|
82
|
+
|
|
83
|
+
@Input()
|
|
84
|
+
contentStyle: { [klass: string]: any } | null = null;
|
|
85
|
+
|
|
86
|
+
@Input()
|
|
87
|
+
breakpoints: { [key: string]: string } | null = null;
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
// =====================================================
|
|
91
|
+
// OUTPUTS
|
|
92
|
+
// =====================================================
|
|
93
|
+
|
|
94
|
+
@Output()
|
|
95
|
+
visibleChange = new EventEmitter<boolean>();
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
// =====================================================
|
|
99
|
+
// CUSTOM TEMPLATES
|
|
100
|
+
// =====================================================
|
|
101
|
+
|
|
102
|
+
@ContentChild(ByteDialogHeaderDirective)
|
|
103
|
+
headerTemplate?: ByteDialogHeaderDirective;
|
|
104
|
+
|
|
105
|
+
@ContentChild(ByteDialogFooterDirective)
|
|
106
|
+
footerTemplate?: ByteDialogFooterDirective;
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
// =====================================================
|
|
110
|
+
// CHANGE
|
|
111
|
+
// =====================================================
|
|
112
|
+
|
|
113
|
+
onVisibleChange(value: boolean): void {
|
|
114
|
+
|
|
115
|
+
this.visible = value;
|
|
116
|
+
|
|
117
|
+
this.visibleChange.emit(value);
|
|
118
|
+
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
}
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import {
|
|
2
|
+
applicationConfig,
|
|
3
|
+
moduleMetadata,
|
|
4
|
+
type Meta,
|
|
5
|
+
type StoryObj
|
|
6
|
+
} from '@storybook/angular';
|
|
7
|
+
|
|
8
|
+
import { ByteDialog } from './byte-dialog';
|
|
9
|
+
import { ByteDialogModule } from './byte-dialog.module';
|
|
10
|
+
|
|
11
|
+
import { provideEmpresaUI } from './../../providers/provide-empresa-ui';
|
|
12
|
+
import { ByteButtonModule } from '../byte-button/byte-button.module';
|
|
13
|
+
|
|
14
|
+
const meta: Meta<ByteDialog> = {
|
|
15
|
+
title: 'Components/ByteDialog',
|
|
16
|
+
component: ByteDialog,
|
|
17
|
+
|
|
18
|
+
decorators: [
|
|
19
|
+
moduleMetadata({
|
|
20
|
+
imports: [
|
|
21
|
+
ByteDialogModule,
|
|
22
|
+
ByteButtonModule
|
|
23
|
+
]
|
|
24
|
+
}),
|
|
25
|
+
|
|
26
|
+
(story, context) =>
|
|
27
|
+
applicationConfig({
|
|
28
|
+
providers: [
|
|
29
|
+
provideEmpresaUI({
|
|
30
|
+
theme: context.globals['theme']
|
|
31
|
+
})
|
|
32
|
+
]
|
|
33
|
+
})(story, context)
|
|
34
|
+
],
|
|
35
|
+
|
|
36
|
+
tags: ['autodocs'],
|
|
37
|
+
|
|
38
|
+
parameters: {
|
|
39
|
+
docs: {
|
|
40
|
+
description: {
|
|
41
|
+
component:
|
|
42
|
+
'Componente de diálogo modal reutilizable, basado en PrimeNG y compatible con templates personalizados de header y footer.'
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export default meta;
|
|
49
|
+
|
|
50
|
+
type Story = StoryObj<ByteDialog>;
|
|
51
|
+
|
|
52
|
+
export const Normal: Story = {
|
|
53
|
+
render: (args) => ({
|
|
54
|
+
props: {
|
|
55
|
+
...args,
|
|
56
|
+
visible: false,
|
|
57
|
+
abrir(this: any) {
|
|
58
|
+
this.visible = true;
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
template: `
|
|
63
|
+
<byte-button (click)="abrir()" label="Abrir diálogo"></byte-button>
|
|
64
|
+
|
|
65
|
+
<byte-dialog
|
|
66
|
+
[(visible)]="visible"
|
|
67
|
+
[header]="header"
|
|
68
|
+
[modal]="modal"
|
|
69
|
+
>
|
|
70
|
+
<p>Este es el contenido del diálogo.</p>
|
|
71
|
+
</byte-dialog>
|
|
72
|
+
`
|
|
73
|
+
}),
|
|
74
|
+
|
|
75
|
+
args: {
|
|
76
|
+
header: 'Título del diálogo',
|
|
77
|
+
modal: true
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export const NonModal: Story = {
|
|
82
|
+
render: (args) => ({
|
|
83
|
+
props: {
|
|
84
|
+
...args,
|
|
85
|
+
visible: false,
|
|
86
|
+
abrir(this: any) {
|
|
87
|
+
this.visible = true;
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
|
|
91
|
+
template: `
|
|
92
|
+
<byte-button (click)="abrir()" label="Abrir diálogo"></byte-button>
|
|
93
|
+
|
|
94
|
+
<byte-dialog
|
|
95
|
+
[(visible)]="visible"
|
|
96
|
+
[header]="header"
|
|
97
|
+
[modal]="modal"
|
|
98
|
+
[dismissableMask]="dismissableMask"
|
|
99
|
+
>
|
|
100
|
+
<p>Este diálogo no bloquea la interacción con el resto de la página.</p>
|
|
101
|
+
</byte-dialog>
|
|
102
|
+
`
|
|
103
|
+
}),
|
|
104
|
+
|
|
105
|
+
args: {
|
|
106
|
+
header: 'Diálogo no modal',
|
|
107
|
+
modal: false,
|
|
108
|
+
dismissableMask: false
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
export const Maximizable: Story = {
|
|
113
|
+
render: (args) => ({
|
|
114
|
+
props: {
|
|
115
|
+
...args,
|
|
116
|
+
visible: false,
|
|
117
|
+
abrir(this: any) {
|
|
118
|
+
this.visible = true;
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
|
|
122
|
+
template: `
|
|
123
|
+
<byte-button (click)="abrir()" label="Abrir diálogo"></byte-button>
|
|
124
|
+
|
|
125
|
+
<byte-dialog
|
|
126
|
+
[(visible)]="visible"
|
|
127
|
+
[header]="header"
|
|
128
|
+
[modal]="modal"
|
|
129
|
+
[maximizable]="maximizable"
|
|
130
|
+
>
|
|
131
|
+
<p>Este diálogo se puede maximizar con el ícono en la cabecera.</p>
|
|
132
|
+
</byte-dialog>
|
|
133
|
+
`
|
|
134
|
+
}),
|
|
135
|
+
|
|
136
|
+
args: {
|
|
137
|
+
header: 'Diálogo maximizable',
|
|
138
|
+
modal: true,
|
|
139
|
+
maximizable: true
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
export const WithFooterActions: Story = {
|
|
144
|
+
render: (args) => ({
|
|
145
|
+
props: {
|
|
146
|
+
...args,
|
|
147
|
+
visible: false,
|
|
148
|
+
abrir(this: any) {
|
|
149
|
+
this.visible = true;
|
|
150
|
+
},
|
|
151
|
+
cerrar(this: any) {
|
|
152
|
+
this.visible = false;
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
|
|
156
|
+
template: `
|
|
157
|
+
<byte-button (click)="abrir()" label="Eliminar registro"></byte-button>
|
|
158
|
+
|
|
159
|
+
<byte-dialog
|
|
160
|
+
[(visible)]="visible"
|
|
161
|
+
[header]="header"
|
|
162
|
+
[modal]="modal"
|
|
163
|
+
>
|
|
164
|
+
<p>¿Estás seguro de que deseas eliminar este registro? Esta acción no se puede deshacer.</p>
|
|
165
|
+
|
|
166
|
+
<ng-template byteDialogFooter>
|
|
167
|
+
<byte-button (click)="cerrar()" label="Cancelar" severity="warn"></byte-button>
|
|
168
|
+
<byte-button (click)="cerrar()" style="font-weight: bold;" label="Eliminar" severity="danger"></byte-button>
|
|
169
|
+
</ng-template>
|
|
170
|
+
</byte-dialog>
|
|
171
|
+
`
|
|
172
|
+
}),
|
|
173
|
+
|
|
174
|
+
args: {
|
|
175
|
+
header: 'Confirmar eliminación',
|
|
176
|
+
modal: true
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
export const CustomHeader: Story = {
|
|
181
|
+
render: (args) => ({
|
|
182
|
+
props: {
|
|
183
|
+
...args,
|
|
184
|
+
visible: false,
|
|
185
|
+
abrir(this: any) {
|
|
186
|
+
this.visible = true;
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
|
|
190
|
+
template: `
|
|
191
|
+
<byte-button (click)="abrir()" label="Abrir diálogo"></byte-button>
|
|
192
|
+
|
|
193
|
+
<byte-dialog
|
|
194
|
+
[(visible)]="visible"
|
|
195
|
+
[modal]="modal"
|
|
196
|
+
>
|
|
197
|
+
<ng-template byteDialogHeader>
|
|
198
|
+
<div style="display: flex; align-items: center; gap: 8px;">
|
|
199
|
+
<strong>⚠️ Atención</strong>
|
|
200
|
+
</div>
|
|
201
|
+
</ng-template>
|
|
202
|
+
|
|
203
|
+
<p>Contenido con encabezado personalizado.</p>
|
|
204
|
+
|
|
205
|
+
<ng-template byteDialogFooter>
|
|
206
|
+
<byte-button (click)="visible = false" label="Entendido"></byte-button>
|
|
207
|
+
</ng-template>
|
|
208
|
+
</byte-dialog>
|
|
209
|
+
`
|
|
210
|
+
}),
|
|
211
|
+
|
|
212
|
+
args: {
|
|
213
|
+
modal: true
|
|
214
|
+
}
|
|
215
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
}
|
|
17
|
+
|
|
18
|
+
.byte-input-label{
|
|
19
|
+
display: block;
|
|
20
|
+
margin-bottom: 0.5rem;
|
|
21
|
+
font-size: 0.88rem;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.byte-input-error {
|
|
25
|
+
display: block;
|
|
26
|
+
margin-top: 0.5rem;
|
|
27
|
+
font-size: 0.70rem;
|
|
28
|
+
color: var(--p-red-500, #ef4444);
|
|
29
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
@if (label) {
|
|
2
|
+
<label [for]="inputId" class="byte-input-label">
|
|
3
|
+
{{ label }}
|
|
4
|
+
|
|
5
|
+
@if (required) {
|
|
6
|
+
<span>*</span>
|
|
7
|
+
}
|
|
8
|
+
</label>
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
@if (typeInput === 'text') {
|
|
12
|
+
|
|
13
|
+
<input
|
|
14
|
+
pInputText
|
|
15
|
+
[id]="inputId"
|
|
16
|
+
[name]="name"
|
|
17
|
+
[placeholder]="placeholder"
|
|
18
|
+
[disabled]="disabled"
|
|
19
|
+
[required]="required"
|
|
20
|
+
[ngModel]="value"
|
|
21
|
+
(ngModelChange)="onValueChange($event)"
|
|
22
|
+
/>
|
|
23
|
+
|
|
24
|
+
} @else if (typeInput === 'number') {
|
|
25
|
+
|
|
26
|
+
<p-inputnumber
|
|
27
|
+
[inputId]="inputId"
|
|
28
|
+
[name]="name"
|
|
29
|
+
[placeholder]="placeholder"
|
|
30
|
+
[disabled]="disabled"
|
|
31
|
+
[min]="min"
|
|
32
|
+
[max]="max"
|
|
33
|
+
[step]="step"
|
|
34
|
+
[ngModel]="value"
|
|
35
|
+
(ngModelChange)="onValueChange($event)"
|
|
36
|
+
/>
|
|
37
|
+
|
|
38
|
+
} @else if (typeInput === 'area') {
|
|
39
|
+
|
|
40
|
+
<textarea
|
|
41
|
+
pTextarea
|
|
42
|
+
[id]="inputId"
|
|
43
|
+
[name]="name"
|
|
44
|
+
[placeholder]="placeholder"
|
|
45
|
+
[disabled]="disabled"
|
|
46
|
+
[required]="required"
|
|
47
|
+
[rows]="rows"
|
|
48
|
+
[ngModel]="value"
|
|
49
|
+
(ngModelChange)="onValueChange($event)"
|
|
50
|
+
></textarea>
|
|
51
|
+
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@if (error) {
|
|
55
|
+
<small class="byte-input-error">
|
|
56
|
+
{{ error }}
|
|
57
|
+
</small>
|
|
58
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { ByteInput } from './byte-input';
|
|
4
|
+
|
|
5
|
+
describe('ByteInput', () => {
|
|
6
|
+
let component: ByteInput;
|
|
7
|
+
let fixture: ComponentFixture<ByteInput>;
|
|
8
|
+
|
|
9
|
+
beforeEach(async () => {
|
|
10
|
+
await TestBed.configureTestingModule({
|
|
11
|
+
imports: [ByteInput],
|
|
12
|
+
}).compileComponents();
|
|
13
|
+
|
|
14
|
+
fixture = TestBed.createComponent(ByteInput);
|
|
15
|
+
component = fixture.componentInstance;
|
|
16
|
+
await fixture.whenStable();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('should create', () => {
|
|
20
|
+
expect(component).toBeTruthy();
|
|
21
|
+
});
|
|
22
|
+
});
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { applicationConfig, type Meta, type StoryObj } from '@storybook/angular';
|
|
2
|
+
|
|
3
|
+
import { ByteInput } from './byte-input';
|
|
4
|
+
|
|
5
|
+
import {provideEmpresaUI} from './../../providers/provide-empresa-ui';
|
|
6
|
+
|
|
7
|
+
const meta: Meta<ByteInput> = {
|
|
8
|
+
title: 'Components/ByteInput',
|
|
9
|
+
component: ByteInput,
|
|
10
|
+
decorators: [
|
|
11
|
+
(story, context) => applicationConfig({
|
|
12
|
+
providers: [
|
|
13
|
+
provideEmpresaUI({
|
|
14
|
+
theme: context.globals['theme']
|
|
15
|
+
})
|
|
16
|
+
]
|
|
17
|
+
})(story, context)
|
|
18
|
+
],
|
|
19
|
+
tags: ['autodocs'],
|
|
20
|
+
|
|
21
|
+
parameters: {
|
|
22
|
+
forceRemount: true,
|
|
23
|
+
docs: {
|
|
24
|
+
description: {
|
|
25
|
+
component: `Componente de entrada para formularios.`
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export default meta;
|
|
32
|
+
|
|
33
|
+
type Story = StoryObj<ByteInput>;
|
|
34
|
+
|
|
35
|
+
export const Text: Story = {
|
|
36
|
+
args:{
|
|
37
|
+
typeInput: 'text'
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export const Number: Story = {
|
|
42
|
+
args:{
|
|
43
|
+
typeInput: 'number'
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export const Area: Story = {
|
|
48
|
+
args:{
|
|
49
|
+
typeInput: 'area'
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export const Forms: Story = {
|
|
54
|
+
args:{
|
|
55
|
+
typeInput: 'text',
|
|
56
|
+
label: 'Ingrese nombre',
|
|
57
|
+
error: 'Error al escribir el nombre',
|
|
58
|
+
inputId: 'name'
|
|
59
|
+
}
|
|
60
|
+
};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ChangeDetectionStrategy,
|
|
3
|
+
Component,
|
|
4
|
+
forwardRef,
|
|
5
|
+
Input
|
|
6
|
+
} from '@angular/core';
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
ControlValueAccessor,
|
|
10
|
+
FormsModule,
|
|
11
|
+
NG_VALUE_ACCESSOR
|
|
12
|
+
} from '@angular/forms';
|
|
13
|
+
|
|
14
|
+
import { InputNumberModule } from 'primeng/inputnumber';
|
|
15
|
+
import { InputTextModule } from 'primeng/inputtext';
|
|
16
|
+
import { TextareaModule } from 'primeng/textarea';
|
|
17
|
+
|
|
18
|
+
export type InputType = 'text' | 'number' | 'area';
|
|
19
|
+
|
|
20
|
+
@Component({
|
|
21
|
+
selector: 'byte-input',
|
|
22
|
+
standalone: true,
|
|
23
|
+
imports: [
|
|
24
|
+
FormsModule,
|
|
25
|
+
InputTextModule,
|
|
26
|
+
InputNumberModule,
|
|
27
|
+
TextareaModule
|
|
28
|
+
],
|
|
29
|
+
templateUrl: './byte-input.html',
|
|
30
|
+
styleUrl: './byte-input.css',
|
|
31
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
32
|
+
|
|
33
|
+
providers: [
|
|
34
|
+
{
|
|
35
|
+
provide: NG_VALUE_ACCESSOR,
|
|
36
|
+
useExisting: forwardRef(() => ByteInput),
|
|
37
|
+
multi: true
|
|
38
|
+
}
|
|
39
|
+
]
|
|
40
|
+
})
|
|
41
|
+
export class ByteInput implements ControlValueAccessor {
|
|
42
|
+
|
|
43
|
+
@Input() typeInput: InputType = 'text';
|
|
44
|
+
|
|
45
|
+
@Input() label = '';
|
|
46
|
+
|
|
47
|
+
@Input() error = '';
|
|
48
|
+
|
|
49
|
+
@Input() placeholder = '';
|
|
50
|
+
|
|
51
|
+
@Input() disabled = false;
|
|
52
|
+
|
|
53
|
+
@Input() required = false;
|
|
54
|
+
|
|
55
|
+
@Input() inputId = '';
|
|
56
|
+
|
|
57
|
+
@Input() name = '';
|
|
58
|
+
|
|
59
|
+
@Input() rows = 3;
|
|
60
|
+
|
|
61
|
+
@Input() min?: number;
|
|
62
|
+
|
|
63
|
+
@Input() max?: number;
|
|
64
|
+
|
|
65
|
+
@Input() step = 1;
|
|
66
|
+
|
|
67
|
+
value: string | number | null = null;
|
|
68
|
+
|
|
69
|
+
private onChange: (value: string | number | null) => void = () => {};
|
|
70
|
+
|
|
71
|
+
private onTouched: () => void = () => {};
|
|
72
|
+
|
|
73
|
+
writeValue(value: string | number | null): void {
|
|
74
|
+
this.value = value;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
registerOnChange(
|
|
78
|
+
fn: (value: string | number | null) => void
|
|
79
|
+
): void {
|
|
80
|
+
this.onChange = fn;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
registerOnTouched(fn: () => void): void {
|
|
84
|
+
this.onTouched = fn;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
setDisabledState(isDisabled: boolean): void {
|
|
88
|
+
this.disabled = isDisabled;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
onValueChange(value: string | number | null): void {
|
|
92
|
+
this.value = value;
|
|
93
|
+
|
|
94
|
+
this.onChange(value);
|
|
95
|
+
this.onTouched();
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -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,61 @@
|
|
|
1
|
+
import { Directive, TemplateRef } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
@Directive({
|
|
4
|
+
selector: 'ng-template[byteSelectSelectedItem]',
|
|
5
|
+
standalone: true
|
|
6
|
+
})
|
|
7
|
+
export class ByteSelectSelectedItemDirective {
|
|
8
|
+
constructor(
|
|
9
|
+
public template: TemplateRef<any>
|
|
10
|
+
) {}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
@Directive({
|
|
14
|
+
selector: 'ng-template[byteSelectItem]',
|
|
15
|
+
standalone: true
|
|
16
|
+
})
|
|
17
|
+
export class ByteSelectItemDirective {
|
|
18
|
+
constructor(
|
|
19
|
+
public template: TemplateRef<any>
|
|
20
|
+
) {}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@Directive({
|
|
24
|
+
selector: 'ng-template[byteSelectHeader]',
|
|
25
|
+
standalone: true
|
|
26
|
+
})
|
|
27
|
+
export class ByteSelectHeaderDirective {
|
|
28
|
+
constructor(
|
|
29
|
+
public template: TemplateRef<any>
|
|
30
|
+
) {}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@Directive({
|
|
34
|
+
selector: 'ng-template[byteSelectFooter]',
|
|
35
|
+
standalone: true
|
|
36
|
+
})
|
|
37
|
+
export class ByteSelectFooterDirective {
|
|
38
|
+
constructor(
|
|
39
|
+
public template: TemplateRef<any>
|
|
40
|
+
) {}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@Directive({
|
|
44
|
+
selector: 'ng-template[byteSelectEmpty]',
|
|
45
|
+
standalone: true
|
|
46
|
+
})
|
|
47
|
+
export class ByteSelectEmptyDirective {
|
|
48
|
+
constructor(
|
|
49
|
+
public template: TemplateRef<any>
|
|
50
|
+
) {}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
@Directive({
|
|
54
|
+
selector: 'ng-template[byteSelectEmptyFilter]',
|
|
55
|
+
standalone: true
|
|
56
|
+
})
|
|
57
|
+
export class ByteSelectEmptyFilterDirective {
|
|
58
|
+
constructor(
|
|
59
|
+
public template: TemplateRef<any>
|
|
60
|
+
) {}
|
|
61
|
+
}
|