@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,101 @@
|
|
|
1
|
+
<p-select
|
|
2
|
+
[options]="options"
|
|
3
|
+
[optionLabel]="optionLabel"
|
|
4
|
+
[optionValue]="optionValue"
|
|
5
|
+
[placeholder]="placeholder"
|
|
6
|
+
[disabled]="disabled"
|
|
7
|
+
[inputId]="inputId"
|
|
8
|
+
[name]="name"
|
|
9
|
+
[filter]="filter"
|
|
10
|
+
[filterBy]="filterBy"
|
|
11
|
+
[showClear]="showClear"
|
|
12
|
+
[ngModel]="value"
|
|
13
|
+
(ngModelChange)="onValueChange($event)"
|
|
14
|
+
appendTo="body"
|
|
15
|
+
>
|
|
16
|
+
|
|
17
|
+
@if (selectedItemTemplate) {
|
|
18
|
+
|
|
19
|
+
<ng-template
|
|
20
|
+
pTemplate="selectedItem"
|
|
21
|
+
let-selectedOption
|
|
22
|
+
>
|
|
23
|
+
|
|
24
|
+
<ng-container
|
|
25
|
+
[ngTemplateOutlet]="selectedItemTemplate.template"
|
|
26
|
+
[ngTemplateOutletContext]="{
|
|
27
|
+
$implicit: selectedOption
|
|
28
|
+
}"
|
|
29
|
+
/>
|
|
30
|
+
|
|
31
|
+
</ng-template>
|
|
32
|
+
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@if (itemTemplate) {
|
|
36
|
+
|
|
37
|
+
<ng-template
|
|
38
|
+
pTemplate="item"
|
|
39
|
+
let-option
|
|
40
|
+
>
|
|
41
|
+
|
|
42
|
+
<ng-container
|
|
43
|
+
[ngTemplateOutlet]="itemTemplate.template"
|
|
44
|
+
[ngTemplateOutletContext]="{
|
|
45
|
+
$implicit: option
|
|
46
|
+
}"
|
|
47
|
+
/>
|
|
48
|
+
|
|
49
|
+
</ng-template>
|
|
50
|
+
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
@if (headerTemplate) {
|
|
54
|
+
|
|
55
|
+
<ng-template pTemplate="header">
|
|
56
|
+
|
|
57
|
+
<ng-container
|
|
58
|
+
[ngTemplateOutlet]="headerTemplate.template"
|
|
59
|
+
/>
|
|
60
|
+
|
|
61
|
+
</ng-template>
|
|
62
|
+
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
@if (footerTemplate) {
|
|
66
|
+
|
|
67
|
+
<ng-template pTemplate="footer">
|
|
68
|
+
|
|
69
|
+
<ng-container
|
|
70
|
+
[ngTemplateOutlet]="footerTemplate.template"
|
|
71
|
+
/>
|
|
72
|
+
|
|
73
|
+
</ng-template>
|
|
74
|
+
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
@if (emptyTemplate) {
|
|
78
|
+
|
|
79
|
+
<ng-template pTemplate="empty">
|
|
80
|
+
|
|
81
|
+
<ng-container
|
|
82
|
+
[ngTemplateOutlet]="emptyTemplate.template"
|
|
83
|
+
/>
|
|
84
|
+
|
|
85
|
+
</ng-template>
|
|
86
|
+
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
@if (emptyFilterTemplate) {
|
|
90
|
+
|
|
91
|
+
<ng-template pTemplate="emptyfilter">
|
|
92
|
+
|
|
93
|
+
<ng-container
|
|
94
|
+
[ngTemplateOutlet]="emptyFilterTemplate.template"
|
|
95
|
+
/>
|
|
96
|
+
|
|
97
|
+
</ng-template>
|
|
98
|
+
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
</p-select>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { NgModule } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
import { ByteSelect } from './byte-select';
|
|
4
|
+
import { ByteSelectEmptyDirective, ByteSelectEmptyFilterDirective, ByteSelectFooterDirective, ByteSelectHeaderDirective, ByteSelectItemDirective, ByteSelectSelectedItemDirective } from './byte-select.directive';
|
|
5
|
+
|
|
6
|
+
@NgModule({
|
|
7
|
+
imports: [
|
|
8
|
+
ByteSelect,
|
|
9
|
+
ByteSelectEmptyDirective,
|
|
10
|
+
ByteSelectEmptyFilterDirective,
|
|
11
|
+
ByteSelectFooterDirective,
|
|
12
|
+
ByteSelectHeaderDirective,
|
|
13
|
+
ByteSelectItemDirective,
|
|
14
|
+
ByteSelectSelectedItemDirective
|
|
15
|
+
],
|
|
16
|
+
exports: [
|
|
17
|
+
ByteSelect,
|
|
18
|
+
ByteSelectEmptyDirective,
|
|
19
|
+
ByteSelectEmptyFilterDirective,
|
|
20
|
+
ByteSelectFooterDirective,
|
|
21
|
+
ByteSelectHeaderDirective,
|
|
22
|
+
ByteSelectItemDirective,
|
|
23
|
+
ByteSelectSelectedItemDirective
|
|
24
|
+
]
|
|
25
|
+
})
|
|
26
|
+
export class ByteSelectModule {}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { ByteSelect } from './byte-select';
|
|
4
|
+
|
|
5
|
+
describe('ByteSelect', () => {
|
|
6
|
+
let component: ByteSelect;
|
|
7
|
+
let fixture: ComponentFixture<ByteSelect>;
|
|
8
|
+
|
|
9
|
+
beforeEach(async () => {
|
|
10
|
+
await TestBed.configureTestingModule({
|
|
11
|
+
imports: [ByteSelect],
|
|
12
|
+
}).compileComponents();
|
|
13
|
+
|
|
14
|
+
fixture = TestBed.createComponent(ByteSelect);
|
|
15
|
+
component = fixture.componentInstance;
|
|
16
|
+
await fixture.whenStable();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('should create', () => {
|
|
20
|
+
expect(component).toBeTruthy();
|
|
21
|
+
});
|
|
22
|
+
});
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import {
|
|
2
|
+
applicationConfig,
|
|
3
|
+
moduleMetadata,
|
|
4
|
+
type Meta,
|
|
5
|
+
type StoryObj
|
|
6
|
+
} from '@storybook/angular';
|
|
7
|
+
|
|
8
|
+
import { ByteSelect } from './byte-select';
|
|
9
|
+
import { ByteSelectModule } from './byte-select.module';
|
|
10
|
+
|
|
11
|
+
import { provideEmpresaUI } from './../../providers/provide-empresa-ui';
|
|
12
|
+
|
|
13
|
+
const meta: Meta<ByteSelect> = {
|
|
14
|
+
title: 'Components/ByteSelect',
|
|
15
|
+
component: ByteSelect,
|
|
16
|
+
|
|
17
|
+
decorators: [
|
|
18
|
+
moduleMetadata({
|
|
19
|
+
imports: [
|
|
20
|
+
ByteSelectModule
|
|
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 selección reutilizable para formularios, basado en PrimeNG y compatible con templates personalizados.'
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export default meta;
|
|
47
|
+
|
|
48
|
+
type Story = StoryObj<ByteSelect>;
|
|
49
|
+
|
|
50
|
+
export const Normal: Story = {
|
|
51
|
+
args: {
|
|
52
|
+
options: [
|
|
53
|
+
{ name: 'Lima', code: 'LIM' },
|
|
54
|
+
{ name: 'Arequipa', code: 'AQP' },
|
|
55
|
+
{ name: 'Cusco', code: 'CUS' },
|
|
56
|
+
{ name: 'Trujillo', code: 'TRU' }
|
|
57
|
+
],
|
|
58
|
+
optionLabel: 'name',
|
|
59
|
+
optionValue: 'code',
|
|
60
|
+
placeholder: 'Seleccione una ciudad'
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export const Filter: Story = {
|
|
65
|
+
args: {
|
|
66
|
+
options: [
|
|
67
|
+
{ name: 'Lima', code: 'LIM' },
|
|
68
|
+
{ name: 'Arequipa', code: 'AQP' },
|
|
69
|
+
{ name: 'Cusco', code: 'CUS' },
|
|
70
|
+
{ name: 'Trujillo', code: 'TRU' },
|
|
71
|
+
{ name: 'Piura', code: 'PIU' }
|
|
72
|
+
],
|
|
73
|
+
optionLabel: 'name',
|
|
74
|
+
optionValue: 'code',
|
|
75
|
+
placeholder: 'Seleccione una ciudad',
|
|
76
|
+
filter: true,
|
|
77
|
+
filterBy: 'name'
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export const CustomItem: Story = {
|
|
82
|
+
render: (args) => ({
|
|
83
|
+
props: args,
|
|
84
|
+
|
|
85
|
+
template: `
|
|
86
|
+
<byte-select
|
|
87
|
+
[options]="options"
|
|
88
|
+
[optionLabel]="optionLabel"
|
|
89
|
+
[optionValue]="optionValue"
|
|
90
|
+
[placeholder]="placeholder"
|
|
91
|
+
>
|
|
92
|
+
|
|
93
|
+
<ng-template
|
|
94
|
+
byteSelectItem
|
|
95
|
+
let-option
|
|
96
|
+
>
|
|
97
|
+
<div>
|
|
98
|
+
<strong>{{ option.name }}</strong>
|
|
99
|
+
<small style="display: block;">
|
|
100
|
+
Código: {{ option.code }}
|
|
101
|
+
</small>
|
|
102
|
+
</div>
|
|
103
|
+
</ng-template>
|
|
104
|
+
|
|
105
|
+
</byte-select>
|
|
106
|
+
`
|
|
107
|
+
}),
|
|
108
|
+
|
|
109
|
+
args: {
|
|
110
|
+
options: [
|
|
111
|
+
{ name: 'Lima', code: 'LIM' },
|
|
112
|
+
{ name: 'Arequipa', code: 'AQP' },
|
|
113
|
+
{ name: 'Cusco', code: 'CUS' }
|
|
114
|
+
],
|
|
115
|
+
optionLabel: 'name',
|
|
116
|
+
optionValue: 'code',
|
|
117
|
+
placeholder: 'Seleccione una ciudad'
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
export const AllTemplates: Story = {
|
|
122
|
+
render: (args) => ({
|
|
123
|
+
props: args,
|
|
124
|
+
|
|
125
|
+
template: `
|
|
126
|
+
<byte-select
|
|
127
|
+
[options]="options"
|
|
128
|
+
[optionLabel]="optionLabel"
|
|
129
|
+
[optionValue]="optionValue"
|
|
130
|
+
[placeholder]="placeholder"
|
|
131
|
+
[filter]="filter"
|
|
132
|
+
[filterBy]="filterBy"
|
|
133
|
+
[showClear]="showClear"
|
|
134
|
+
>
|
|
135
|
+
|
|
136
|
+
<ng-template byteSelectSelectedItem let-option>
|
|
137
|
+
@if (option) {
|
|
138
|
+
<span>📍 {{ option.name }}</span>
|
|
139
|
+
}
|
|
140
|
+
</ng-template>
|
|
141
|
+
|
|
142
|
+
<ng-template byteSelectItem let-option>
|
|
143
|
+
<div>
|
|
144
|
+
<strong>{{ option.name }}</strong>
|
|
145
|
+
<small style="display: block;">
|
|
146
|
+
Código: {{ option.code }}
|
|
147
|
+
</small>
|
|
148
|
+
</div>
|
|
149
|
+
</ng-template>
|
|
150
|
+
|
|
151
|
+
<ng-template byteSelectHeader>
|
|
152
|
+
<div style="padding: 8px; font-weight: bold;">
|
|
153
|
+
Seleccione una ciudad
|
|
154
|
+
</div>
|
|
155
|
+
</ng-template>
|
|
156
|
+
|
|
157
|
+
<ng-template byteSelectFooter>
|
|
158
|
+
<div style="padding: 8px;">
|
|
159
|
+
{{ options.length }} ciudades disponibles
|
|
160
|
+
</div>
|
|
161
|
+
</ng-template>
|
|
162
|
+
|
|
163
|
+
<ng-template byteSelectEmpty>
|
|
164
|
+
<div style="padding: 10px;">
|
|
165
|
+
No hay ciudades disponibles
|
|
166
|
+
</div>
|
|
167
|
+
</ng-template>
|
|
168
|
+
|
|
169
|
+
<ng-template byteSelectEmptyFilter>
|
|
170
|
+
<div style="padding: 10px;">
|
|
171
|
+
No se encontraron resultados
|
|
172
|
+
</div>
|
|
173
|
+
</ng-template>
|
|
174
|
+
|
|
175
|
+
</byte-select>
|
|
176
|
+
`
|
|
177
|
+
}),
|
|
178
|
+
|
|
179
|
+
args: {
|
|
180
|
+
options: [
|
|
181
|
+
{ name: 'Lima', code: 'LIM' },
|
|
182
|
+
{ name: 'Arequipa', code: 'AQP' },
|
|
183
|
+
{ name: 'Cusco', code: 'CUS' },
|
|
184
|
+
{ name: 'Trujillo', code: 'TRU' },
|
|
185
|
+
{ name: 'Piura', code: 'PIU' }
|
|
186
|
+
],
|
|
187
|
+
optionLabel: 'name',
|
|
188
|
+
optionValue: 'code',
|
|
189
|
+
placeholder: 'Seleccione una ciudad',
|
|
190
|
+
filter: true,
|
|
191
|
+
filterBy: 'name',
|
|
192
|
+
showClear: true
|
|
193
|
+
}
|
|
194
|
+
};
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ChangeDetectionStrategy,
|
|
3
|
+
Component,
|
|
4
|
+
ContentChild,
|
|
5
|
+
forwardRef,
|
|
6
|
+
Input
|
|
7
|
+
} from '@angular/core';
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
FormsModule,
|
|
11
|
+
NG_VALUE_ACCESSOR
|
|
12
|
+
} from '@angular/forms';
|
|
13
|
+
|
|
14
|
+
import { SelectModule } from 'primeng/select';
|
|
15
|
+
|
|
16
|
+
import {
|
|
17
|
+
ByteSelectEmptyDirective,
|
|
18
|
+
ByteSelectEmptyFilterDirective,
|
|
19
|
+
ByteSelectFooterDirective,
|
|
20
|
+
ByteSelectHeaderDirective,
|
|
21
|
+
ByteSelectItemDirective,
|
|
22
|
+
ByteSelectSelectedItemDirective
|
|
23
|
+
} from './byte-select.directive';
|
|
24
|
+
import { NgTemplateOutlet } from '@angular/common';
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
@Component({
|
|
28
|
+
selector: 'byte-select',
|
|
29
|
+
|
|
30
|
+
imports: [
|
|
31
|
+
FormsModule,
|
|
32
|
+
SelectModule,
|
|
33
|
+
|
|
34
|
+
NgTemplateOutlet,
|
|
35
|
+
|
|
36
|
+
ByteSelectSelectedItemDirective,
|
|
37
|
+
ByteSelectItemDirective,
|
|
38
|
+
ByteSelectHeaderDirective,
|
|
39
|
+
ByteSelectFooterDirective,
|
|
40
|
+
ByteSelectEmptyDirective,
|
|
41
|
+
ByteSelectEmptyFilterDirective
|
|
42
|
+
],
|
|
43
|
+
|
|
44
|
+
templateUrl: './byte-select.html',
|
|
45
|
+
|
|
46
|
+
styleUrl: './byte-select.css',
|
|
47
|
+
|
|
48
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
49
|
+
|
|
50
|
+
providers: [
|
|
51
|
+
{
|
|
52
|
+
provide: NG_VALUE_ACCESSOR,
|
|
53
|
+
useExisting: forwardRef(() => ByteSelect),
|
|
54
|
+
multi: true
|
|
55
|
+
}
|
|
56
|
+
]
|
|
57
|
+
})
|
|
58
|
+
export class ByteSelect {
|
|
59
|
+
|
|
60
|
+
// =====================================================
|
|
61
|
+
// INPUTS
|
|
62
|
+
// =====================================================
|
|
63
|
+
|
|
64
|
+
@Input()
|
|
65
|
+
options: any[] = [];
|
|
66
|
+
|
|
67
|
+
@Input()
|
|
68
|
+
optionLabel = '';
|
|
69
|
+
|
|
70
|
+
@Input()
|
|
71
|
+
optionValue = '';
|
|
72
|
+
|
|
73
|
+
@Input()
|
|
74
|
+
placeholder = 'Seleccione';
|
|
75
|
+
|
|
76
|
+
@Input()
|
|
77
|
+
disabled = false;
|
|
78
|
+
|
|
79
|
+
@Input()
|
|
80
|
+
inputId = '';
|
|
81
|
+
|
|
82
|
+
@Input()
|
|
83
|
+
name = '';
|
|
84
|
+
|
|
85
|
+
@Input()
|
|
86
|
+
filter = false;
|
|
87
|
+
|
|
88
|
+
@Input()
|
|
89
|
+
filterBy = '';
|
|
90
|
+
|
|
91
|
+
@Input()
|
|
92
|
+
showClear = false;
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
// =====================================================
|
|
96
|
+
// CUSTOM TEMPLATES
|
|
97
|
+
// =====================================================
|
|
98
|
+
|
|
99
|
+
@ContentChild(ByteSelectSelectedItemDirective)
|
|
100
|
+
selectedItemTemplate?: ByteSelectSelectedItemDirective;
|
|
101
|
+
|
|
102
|
+
@ContentChild(ByteSelectItemDirective)
|
|
103
|
+
itemTemplate?: ByteSelectItemDirective;
|
|
104
|
+
|
|
105
|
+
@ContentChild(ByteSelectHeaderDirective)
|
|
106
|
+
headerTemplate?: ByteSelectHeaderDirective;
|
|
107
|
+
|
|
108
|
+
@ContentChild(ByteSelectFooterDirective)
|
|
109
|
+
footerTemplate?: ByteSelectFooterDirective;
|
|
110
|
+
|
|
111
|
+
@ContentChild(ByteSelectEmptyDirective)
|
|
112
|
+
emptyTemplate?: ByteSelectEmptyDirective;
|
|
113
|
+
|
|
114
|
+
@ContentChild(ByteSelectEmptyFilterDirective)
|
|
115
|
+
emptyFilterTemplate?: ByteSelectEmptyFilterDirective;
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
// =====================================================
|
|
119
|
+
// VALUE
|
|
120
|
+
// =====================================================
|
|
121
|
+
|
|
122
|
+
value: any = null;
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
// =====================================================
|
|
126
|
+
// CONTROL VALUE ACCESSOR
|
|
127
|
+
// =====================================================
|
|
128
|
+
|
|
129
|
+
private onChange: (value: any) => void = () => {};
|
|
130
|
+
|
|
131
|
+
private onTouched: () => void = () => {};
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
writeValue(value: any): void {
|
|
135
|
+
this.value = value;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
registerOnChange(fn: (value: any) => void): void {
|
|
140
|
+
this.onChange = fn;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
registerOnTouched(fn: () => void): void {
|
|
145
|
+
this.onTouched = fn;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
setDisabledState(isDisabled: boolean): void {
|
|
150
|
+
this.disabled = isDisabled;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
// =====================================================
|
|
155
|
+
// CHANGE
|
|
156
|
+
// =====================================================
|
|
157
|
+
|
|
158
|
+
onValueChange(value: any): void {
|
|
159
|
+
|
|
160
|
+
this.value = value;
|
|
161
|
+
|
|
162
|
+
this.onChange(value);
|
|
163
|
+
|
|
164
|
+
this.onTouched();
|
|
165
|
+
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<p-drawer
|
|
2
|
+
[visible]="visible"
|
|
3
|
+
(visibleChange)="onVisibleChange($event)"
|
|
4
|
+
[position]="position"
|
|
5
|
+
[modal]="modal"
|
|
6
|
+
[dismissible]="dismissible"
|
|
7
|
+
[closeOnEscape]="closeOnEscape"
|
|
8
|
+
[showCloseIcon]="showCloseIcon"
|
|
9
|
+
[blockScroll]="blockScroll"
|
|
10
|
+
[style]="style"
|
|
11
|
+
[styleClass]="styleClass"
|
|
12
|
+
[autoZIndex]="autoZIndex"
|
|
13
|
+
[baseZIndex]="baseZIndex"
|
|
14
|
+
appendTo="body"
|
|
15
|
+
>
|
|
16
|
+
|
|
17
|
+
@if (headerTemplate) {
|
|
18
|
+
|
|
19
|
+
<ng-template pTemplate="header">
|
|
20
|
+
|
|
21
|
+
<ng-container
|
|
22
|
+
[ngTemplateOutlet]="headerTemplate.template"
|
|
23
|
+
/>
|
|
24
|
+
|
|
25
|
+
</ng-template>
|
|
26
|
+
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
<ng-content></ng-content>
|
|
30
|
+
|
|
31
|
+
</p-drawer>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { NgModule } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
import { ByteSidebar } from './byte-sidebar';
|
|
4
|
+
import { ByteSidebarHeaderDirective } from './byte-sidebar.directive';
|
|
5
|
+
|
|
6
|
+
@NgModule({
|
|
7
|
+
imports: [
|
|
8
|
+
ByteSidebar,
|
|
9
|
+
ByteSidebarHeaderDirective
|
|
10
|
+
],
|
|
11
|
+
exports: [
|
|
12
|
+
ByteSidebar,
|
|
13
|
+
ByteSidebarHeaderDirective
|
|
14
|
+
]
|
|
15
|
+
})
|
|
16
|
+
export class ByteSidebarModule {}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { ByteSidebar } from './byte-sidebar';
|
|
4
|
+
|
|
5
|
+
describe('ByteSidebar', () => {
|
|
6
|
+
let component: ByteSidebar;
|
|
7
|
+
let fixture: ComponentFixture<ByteSidebar>;
|
|
8
|
+
|
|
9
|
+
beforeEach(async () => {
|
|
10
|
+
await TestBed.configureTestingModule({
|
|
11
|
+
imports: [ByteSidebar],
|
|
12
|
+
}).compileComponents();
|
|
13
|
+
|
|
14
|
+
fixture = TestBed.createComponent(ByteSidebar);
|
|
15
|
+
component = fixture.componentInstance;
|
|
16
|
+
await fixture.whenStable();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('should create', () => {
|
|
20
|
+
expect(component).toBeTruthy();
|
|
21
|
+
});
|
|
22
|
+
});
|