platformcommons-web-lib 1.0.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/commons-shared-web-ui-1.0.0.tgz +0 -0
- package/documentation/alert.md +123 -0
- package/documentation/button-dropdown.md +126 -0
- package/documentation/button.md +184 -0
- package/documentation/cards-usage-guidelines.md +131 -0
- package/documentation/configurable-form.md +605 -0
- package/documentation/confirmation-modal.md +250 -0
- package/documentation/filter-sidebar.md +178 -0
- package/documentation/filter-table-selector.md +228 -0
- package/documentation/form-builder.md +597 -0
- package/documentation/form-components.md +384 -0
- package/documentation/nav.md +427 -0
- package/documentation/pagination.md +181 -0
- package/documentation/side-nav-documentation.md +169 -0
- package/documentation/smart-form.md +2177 -0
- package/documentation/smart-table.md +1198 -0
- package/documentation/snackbar.md +118 -0
- package/documentation/style-externalization.md +88 -0
- package/documentation/summary-card.md +279 -0
- package/ng-package.json +28 -0
- package/package.json +54 -0
- package/src/lib/modules/alert/alert.models.ts +6 -0
- package/src/lib/modules/alert/alert.module.ts +16 -0
- package/src/lib/modules/alert/alert.theme.scss +85 -0
- package/src/lib/modules/alert/components/alert/alert.component.html +27 -0
- package/src/lib/modules/alert/components/alert/alert.component.scss +92 -0
- package/src/lib/modules/alert/components/alert/alert.component.ts +81 -0
- package/src/lib/modules/button/button.models.ts +13 -0
- package/src/lib/modules/button/button.module.ts +16 -0
- package/src/lib/modules/button/button.theme.scss +121 -0
- package/src/lib/modules/button/components/button/button.component.html +22 -0
- package/src/lib/modules/button/components/button/button.component.scss +88 -0
- package/src/lib/modules/button/components/button/button.component.ts +67 -0
- package/src/lib/modules/button-dropdown/button-dropdown.models.ts +26 -0
- package/src/lib/modules/button-dropdown/button-dropdown.module.ts +22 -0
- package/src/lib/modules/button-dropdown/button-dropdown.theme.scss +87 -0
- package/src/lib/modules/button-dropdown/components/button-dropdown/button-dropdown.component.html +41 -0
- package/src/lib/modules/button-dropdown/components/button-dropdown/button-dropdown.component.scss +135 -0
- package/src/lib/modules/button-dropdown/components/button-dropdown/button-dropdown.component.ts +160 -0
- package/src/lib/modules/configurable-form/component/configurable-form.component.html +294 -0
- package/src/lib/modules/configurable-form/component/configurable-form.component.scss +503 -0
- package/src/lib/modules/configurable-form/component/configurable-form.component.ts +628 -0
- package/src/lib/modules/configurable-form/configurable-form.examples.ts +154 -0
- package/src/lib/modules/configurable-form/configurable-form.model.ts +131 -0
- package/src/lib/modules/configurable-form/configurable-form.module.ts +19 -0
- package/src/lib/modules/configurable-form/configurable-form.theme.scss +78 -0
- package/src/lib/modules/confirmation-modal/components/confirmation-modal/confirmation-modal.component.html +77 -0
- package/src/lib/modules/confirmation-modal/components/confirmation-modal/confirmation-modal.component.scss +395 -0
- package/src/lib/modules/confirmation-modal/components/confirmation-modal/confirmation-modal.component.ts +266 -0
- package/src/lib/modules/confirmation-modal/confirmation-modal.models.ts +71 -0
- package/src/lib/modules/confirmation-modal/confirmation-modal.module.ts +20 -0
- package/src/lib/modules/confirmation-modal/confirmation-modal.theme.scss +87 -0
- package/src/lib/modules/filter/components/filter/filter.component.html +131 -0
- package/src/lib/modules/filter/components/filter/filter.component.scss +245 -0
- package/src/lib/modules/filter/components/filter/filter.component.ts +216 -0
- package/src/lib/modules/filter/filter.models.ts +88 -0
- package/src/lib/modules/filter/filter.module.ts +24 -0
- package/src/lib/modules/filter/filter.theme.scss +92 -0
- package/src/lib/modules/filter-sidebar/components/filter-sidebar/filter-sidebar.component.html +112 -0
- package/src/lib/modules/filter-sidebar/components/filter-sidebar/filter-sidebar.component.scss +186 -0
- package/src/lib/modules/filter-sidebar/components/filter-sidebar/filter-sidebar.component.ts +163 -0
- package/src/lib/modules/filter-sidebar/filter-sidebar.models.ts +95 -0
- package/src/lib/modules/filter-sidebar/filter-sidebar.module.ts +24 -0
- package/src/lib/modules/filter-sidebar/filter-sidebar.theme.scss +38 -0
- package/src/lib/modules/filter-table-selector/components/filter-table-selector/filter-table-selector.component.html +73 -0
- package/src/lib/modules/filter-table-selector/components/filter-table-selector/filter-table-selector.component.scss +321 -0
- package/src/lib/modules/filter-table-selector/components/filter-table-selector/filter-table-selector.component.ts +361 -0
- package/src/lib/modules/filter-table-selector/filter-table-selector.models.ts +91 -0
- package/src/lib/modules/filter-table-selector/filter-table-selector.module.ts +22 -0
- package/src/lib/modules/filter-table-selector/filter-table-selector.theme.scss +36 -0
- package/src/lib/modules/form-builder/components/field-configurator/configurator-config-panel/configurator-config-panel.component.html +63 -0
- package/src/lib/modules/form-builder/components/field-configurator/configurator-config-panel/configurator-config-panel.component.scss +496 -0
- package/src/lib/modules/form-builder/components/field-configurator/configurator-config-panel/configurator-config-panel.component.ts +445 -0
- package/src/lib/modules/form-builder/components/field-configurator/configurator-tree/configurator-tree.component.html +75 -0
- package/src/lib/modules/form-builder/components/field-configurator/configurator-tree/configurator-tree.component.scss +210 -0
- package/src/lib/modules/form-builder/components/field-configurator/configurator-tree/configurator-tree.component.ts +55 -0
- package/src/lib/modules/form-builder/components/field-configurator/field-configurator.component.html +25 -0
- package/src/lib/modules/form-builder/components/field-configurator/field-configurator.component.scss +82 -0
- package/src/lib/modules/form-builder/components/field-configurator/field-configurator.component.ts +95 -0
- package/src/lib/modules/form-builder/components/field-selection/field-selection.component.html +20 -0
- package/src/lib/modules/form-builder/components/field-selection/field-selection.component.scss +37 -0
- package/src/lib/modules/form-builder/components/field-selection/field-selection.component.ts +94 -0
- package/src/lib/modules/form-builder/components/field-selection/group-node/group-node.component.html +46 -0
- package/src/lib/modules/form-builder/components/field-selection/group-node/group-node.component.scss +102 -0
- package/src/lib/modules/form-builder/components/field-selection/group-node/group-node.component.ts +50 -0
- package/src/lib/modules/form-builder/components/field-selection/selection-field-node/selection-field-node.component.html +35 -0
- package/src/lib/modules/form-builder/components/field-selection/selection-field-node/selection-field-node.component.scss +67 -0
- package/src/lib/modules/form-builder/components/field-selection/selection-field-node/selection-field-node.component.ts +34 -0
- package/src/lib/modules/form-builder/components/field-selection/selection-section-node/selection-section-node.component.html +68 -0
- package/src/lib/modules/form-builder/components/field-selection/selection-section-node/selection-section-node.component.scss +113 -0
- package/src/lib/modules/form-builder/components/field-selection/selection-section-node/selection-section-node.component.ts +74 -0
- package/src/lib/modules/form-builder/configs/field-type-schema.map.ts +533 -0
- package/src/lib/modules/form-builder/form-builder.module.ts +36 -0
- package/src/lib/modules/form-builder/form-builder.theme.scss +212 -0
- package/src/lib/modules/form-builder/index.ts +9 -0
- package/src/lib/modules/form-builder/models/builder.models.ts +7 -0
- package/src/lib/modules/form-builder/models/field-configurator.models.ts +38 -0
- package/src/lib/modules/form-builder/models/field-selection.models.ts +51 -0
- package/src/lib/modules/form-builder/services/field-configurator.service.ts +258 -0
- package/src/lib/modules/form-builder/services/field-selection.service.ts +300 -0
- package/src/lib/modules/form-builder/services/form-schema-tree.service.ts +652 -0
- package/src/lib/modules/form-builder/tokens/builder.tokens.ts +10 -0
- package/src/lib/modules/form-builder/utils/constants.ts +43 -0
- package/src/lib/modules/form-components/components/checkbox/_theme.scss +63 -0
- package/src/lib/modules/form-components/components/checkbox/checkbox.component.html +29 -0
- package/src/lib/modules/form-components/components/checkbox/checkbox.component.scss +111 -0
- package/src/lib/modules/form-components/components/checkbox/checkbox.component.ts +207 -0
- package/src/lib/modules/form-components/components/checkbox/checkbox.models.ts +35 -0
- package/src/lib/modules/form-components/components/datepicker/_theme.scss +82 -0
- package/src/lib/modules/form-components/components/datepicker/datepicker.component.html +42 -0
- package/src/lib/modules/form-components/components/datepicker/datepicker.component.scss +115 -0
- package/src/lib/modules/form-components/components/datepicker/datepicker.component.ts +267 -0
- package/src/lib/modules/form-components/components/datepicker/datepicker.models.ts +45 -0
- package/src/lib/modules/form-components/components/dropdown/_theme.scss +91 -0
- package/src/lib/modules/form-components/components/dropdown/dropdown.component.html +74 -0
- package/src/lib/modules/form-components/components/dropdown/dropdown.component.scss +252 -0
- package/src/lib/modules/form-components/components/dropdown/dropdown.component.ts +377 -0
- package/src/lib/modules/form-components/components/dropdown/dropdown.models.ts +53 -0
- package/src/lib/modules/form-components/components/input/_theme.scss +77 -0
- package/src/lib/modules/form-components/components/input/input.component.html +51 -0
- package/src/lib/modules/form-components/components/input/input.component.scss +128 -0
- package/src/lib/modules/form-components/components/input/input.component.ts +250 -0
- package/src/lib/modules/form-components/components/input/input.models.ts +55 -0
- package/src/lib/modules/form-components/components/radio/_theme.scss +61 -0
- package/src/lib/modules/form-components/components/radio/radio.component.html +22 -0
- package/src/lib/modules/form-components/components/radio/radio.component.scss +107 -0
- package/src/lib/modules/form-components/components/radio/radio.component.ts +181 -0
- package/src/lib/modules/form-components/components/radio/radio.models.ts +39 -0
- package/src/lib/modules/form-components/components/search/_theme.scss +73 -0
- package/src/lib/modules/form-components/components/search/search.component.html +15 -0
- package/src/lib/modules/form-components/components/search/search.component.scss +87 -0
- package/src/lib/modules/form-components/components/search/search.component.ts +213 -0
- package/src/lib/modules/form-components/components/search/search.models.ts +40 -0
- package/src/lib/modules/form-components/components/toggle/_theme.scss +45 -0
- package/src/lib/modules/form-components/components/toggle/toggle.component.html +15 -0
- package/src/lib/modules/form-components/components/toggle/toggle.component.scss +81 -0
- package/src/lib/modules/form-components/components/toggle/toggle.component.ts +166 -0
- package/src/lib/modules/form-components/components/toggle/toggle.models.ts +27 -0
- package/src/lib/modules/form-components/directives/click-outside.directive.ts +22 -0
- package/src/lib/modules/form-components/form-components.module.ts +41 -0
- package/src/lib/modules/form-components/form-components.theme.scss +25 -0
- package/src/lib/modules/material/material.module.ts +94 -0
- package/src/lib/modules/nav/components/nav/nav.component.html +34 -0
- package/src/lib/modules/nav/components/nav/nav.component.scss +171 -0
- package/src/lib/modules/nav/components/nav/nav.component.ts +82 -0
- package/src/lib/modules/nav/nav.models.ts +31 -0
- package/src/lib/modules/nav/nav.module.ts +17 -0
- package/src/lib/modules/nav/nav.theme.scss +86 -0
- package/src/lib/modules/pagination/components/pagination/pagination.component.html +52 -0
- package/src/lib/modules/pagination/components/pagination/pagination.component.scss +155 -0
- package/src/lib/modules/pagination/components/pagination/pagination.component.ts +109 -0
- package/src/lib/modules/pagination/pagination.module.ts +17 -0
- package/src/lib/modules/pagination/pagination.theme.scss +66 -0
- package/src/lib/modules/side-nav/components/side-nav/side-nav.component.html +56 -0
- package/src/lib/modules/side-nav/components/side-nav/side-nav.component.scss +342 -0
- package/src/lib/modules/side-nav/components/side-nav/side-nav.component.ts +135 -0
- package/src/lib/modules/side-nav/side-nav.models.ts +38 -0
- package/src/lib/modules/side-nav/side-nav.module.ts +16 -0
- package/src/lib/modules/side-nav/side-nav.theme.scss +111 -0
- package/src/lib/modules/smart-form/components/form-field/form-field.component.html +1109 -0
- package/src/lib/modules/smart-form/components/form-field/form-field.component.scss +1860 -0
- package/src/lib/modules/smart-form/components/form-field/form-field.component.ts +2232 -0
- package/src/lib/modules/smart-form/components/form-section/form-section.component.html +64 -0
- package/src/lib/modules/smart-form/components/form-section/form-section.component.scss +209 -0
- package/src/lib/modules/smart-form/components/form-section/form-section.component.ts +119 -0
- package/src/lib/modules/smart-form/components/smart-form/smart-form.component.html +253 -0
- package/src/lib/modules/smart-form/components/smart-form/smart-form.component.scss +689 -0
- package/src/lib/modules/smart-form/components/smart-form/smart-form.component.ts +1087 -0
- package/src/lib/modules/smart-form/index.ts +10 -0
- package/src/lib/modules/smart-form/models/form-schema.model.ts +700 -0
- package/src/lib/modules/smart-form/models/hierarchy-config.model.ts +21 -0
- package/src/lib/modules/smart-form/services/expression.service.ts +75 -0
- package/src/lib/modules/smart-form/services/smart-form-controller.service.ts +65 -0
- package/src/lib/modules/smart-form/smart-form.examples.ts +1324 -0
- package/src/lib/modules/smart-form/smart-form.module.ts +36 -0
- package/src/lib/modules/smart-form/smart-form.theme.scss +890 -0
- package/src/lib/modules/smart-form/utils/translation.utils.ts +82 -0
- package/src/lib/modules/smart-form/utils/trusted-url.pipe.ts +25 -0
- package/src/lib/modules/smart-form/utils/validation.utils.ts +98 -0
- package/src/lib/modules/smart-table/components/smart-table/smart-table.component.html +283 -0
- package/src/lib/modules/smart-table/components/smart-table/smart-table.component.scss +685 -0
- package/src/lib/modules/smart-table/components/smart-table/smart-table.component.ts +1118 -0
- package/src/lib/modules/smart-table/models/table-config.model.ts +202 -0
- package/src/lib/modules/smart-table/smart-table.module.ts +30 -0
- package/src/lib/modules/smart-table/smart-table.theme.scss +335 -0
- package/src/lib/modules/smart-table/utils/safe-html.pipe.ts +22 -0
- package/src/lib/modules/smart-table/utils/smart-table.utils.ts +18 -0
- package/src/lib/modules/snackbar/components/snackbar.component.html +41 -0
- package/src/lib/modules/snackbar/components/snackbar.component.scss +99 -0
- package/src/lib/modules/snackbar/components/snackbar.component.ts +18 -0
- package/src/lib/modules/snackbar/models/snackbar.models.ts +10 -0
- package/src/lib/modules/snackbar/services/snackbar.service.ts +40 -0
- package/src/lib/modules/snackbar/snackbar.module.ts +11 -0
- package/src/lib/modules/snackbar/snackbar.theme.scss +93 -0
- package/src/lib/modules/summary-card/components/summary-card/summary-card.component.html +47 -0
- package/src/lib/modules/summary-card/components/summary-card/summary-card.component.scss +199 -0
- package/src/lib/modules/summary-card/components/summary-card/summary-card.component.ts +126 -0
- package/src/lib/modules/summary-card/summary-card.module.ts +18 -0
- package/src/lib/modules/summary-card/summary-card.theme.scss +176 -0
- package/src/lib/shared-ui.module.ts +44 -0
- package/src/lib/styles/global.scss +152 -0
- package/src/lib/styles/utilities.scss +250 -0
- package/src/lib/utils/constants.ts +11 -0
- package/src/lib/utils/storage.utils.ts +37 -0
- package/src/lib/utils/string.utils.ts +23 -0
- package/src/lib/utils/translation.utils.ts +87 -0
- package/src/public-api.ts +104 -0
- package/tsconfig.lib.json +15 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { FieldConfig, FormSchema } from '../models/form-schema.model';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Utility class for translating Smart Form schemas.
|
|
5
|
+
*/
|
|
6
|
+
export class SmartFormTranslationUtils {
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Recursively walks the schema and replaces i18n keys with values from labels map.
|
|
10
|
+
* @param schema The FormSchema to translate.
|
|
11
|
+
* @param labels The labels map (can be flat or contain labelsObject property).
|
|
12
|
+
*/
|
|
13
|
+
static translateSchema(schema: FormSchema, labels: any): void {
|
|
14
|
+
if (!schema || !labels) return;
|
|
15
|
+
|
|
16
|
+
// Support both flat labels map and the pattern used in ConfigurableForm which passes { labelsObject: ... }
|
|
17
|
+
const labelsMap = labels.labelsObject || labels;
|
|
18
|
+
const translate = (key: string) => labelsMap[key] || key;
|
|
19
|
+
|
|
20
|
+
// Root properties
|
|
21
|
+
if (schema.label) schema.label = translate(schema.label);
|
|
22
|
+
if (schema.description) schema.description = translate(schema.description);
|
|
23
|
+
|
|
24
|
+
// Submit config
|
|
25
|
+
if (schema.submitConfig) {
|
|
26
|
+
if (schema.submitConfig.successMessage) schema.submitConfig.successMessage = translate(schema.submitConfig.successMessage);
|
|
27
|
+
if (schema.submitConfig.errorMessage) schema.submitConfig.errorMessage = translate(schema.submitConfig.errorMessage);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Section config
|
|
31
|
+
if (schema.sectionConfig) {
|
|
32
|
+
this.translateSection(schema.sectionConfig, translate);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Stepper config
|
|
36
|
+
if (schema.stepperConfig?.children) {
|
|
37
|
+
schema.stepperConfig.children.forEach(field => this.translateField(field, translate));
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
private static translateSection(section: any, translate: (key: string) => string): void {
|
|
42
|
+
if (section.label) section.label = translate(section.label);
|
|
43
|
+
if (section.children) {
|
|
44
|
+
section.children.forEach((field: FieldConfig) => this.translateField(field, translate));
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
private static translateField(field: FieldConfig, translate: (key: string) => string): void {
|
|
49
|
+
if (field.label) field.label = translate(field.label);
|
|
50
|
+
if (field.placeholder) field.placeholder = translate(field.placeholder);
|
|
51
|
+
if (field.hint) field.hint = translate(field.hint);
|
|
52
|
+
|
|
53
|
+
if (field.richTextConfig?.placeholder) {
|
|
54
|
+
field.richTextConfig.placeholder = translate(field.richTextConfig.placeholder);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (field.textConfig?.patternMessage) {
|
|
58
|
+
field.textConfig.patternMessage = translate(field.textConfig.patternMessage);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (field.attachmentConfig?.acceptLabel) {
|
|
62
|
+
field.attachmentConfig.acceptLabel = translate(field.attachmentConfig.acceptLabel);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (field.optionConfig?.optionList) {
|
|
66
|
+
field.optionConfig.optionList.forEach(opt => {
|
|
67
|
+
if (opt.label) opt.label = translate(opt.label);
|
|
68
|
+
if (opt.hint) opt.hint = translate(opt.hint);
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Recurse into children (ROW or GROUP)
|
|
73
|
+
if (field.children) {
|
|
74
|
+
field.children.forEach(child => this.translateField(child, translate));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Recurse into nested section config
|
|
78
|
+
if (field.sectionConfig) {
|
|
79
|
+
this.translateSection(field.sectionConfig, translate);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Pipe, PipeTransform, SecurityContext } from '@angular/core';
|
|
2
|
+
import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Bypasses Angular's DomSanitizer for resource URLs (e.g. YouTube embed iframes).
|
|
6
|
+
* Used only for trusted URLs such as YouTube embed links derived from user-provided video IDs.
|
|
7
|
+
*/
|
|
8
|
+
@Pipe({
|
|
9
|
+
name: 'trustedUrl',
|
|
10
|
+
standalone: false
|
|
11
|
+
})
|
|
12
|
+
export class TrustedUrlPipe implements PipeTransform {
|
|
13
|
+
constructor(private sanitizer: DomSanitizer) { }
|
|
14
|
+
|
|
15
|
+
transform(url: string): SafeResourceUrl | null {
|
|
16
|
+
if (!url) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
const cleaned = this.sanitizer.sanitize(SecurityContext.URL, url);
|
|
20
|
+
if (!cleaned) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
return this.sanitizer.bypassSecurityTrustResourceUrl(cleaned);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { AbstractControl, FormGroup, ValidationErrors, ValidatorFn } from '@angular/forms';
|
|
2
|
+
|
|
3
|
+
export class ValidationUtils {
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
static email(): ValidatorFn {
|
|
8
|
+
return (control: AbstractControl): ValidationErrors | null => {
|
|
9
|
+
if (!control.value) return null;
|
|
10
|
+
const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
|
|
11
|
+
return emailRegex.test(control.value) ? null : { email: true };
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
static phone(): ValidatorFn {
|
|
16
|
+
return (control: AbstractControl): ValidationErrors | null => {
|
|
17
|
+
if (!control.value) return null;
|
|
18
|
+
const phoneRegex = /^\+?[\d\s\-\(\)]{10,}$/;
|
|
19
|
+
return phoneRegex.test(control.value) ? null : { phone: true };
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
static url(): ValidatorFn {
|
|
24
|
+
return (control: AbstractControl): ValidationErrors | null => {
|
|
25
|
+
if (!control.value) return null;
|
|
26
|
+
const urlRegex = /^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)$/;
|
|
27
|
+
return urlRegex.test(control.value) ? null : { url: true };
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
static minLength(min: number): ValidatorFn {
|
|
32
|
+
return (control: AbstractControl): ValidationErrors | null => {
|
|
33
|
+
if (!control.value) return null;
|
|
34
|
+
return control.value.length >= min ? null : { minLength: { min, actual: control.value.length } };
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
static maxLength(max: number): ValidatorFn {
|
|
39
|
+
return (control: AbstractControl): ValidationErrors | null => {
|
|
40
|
+
if (!control.value) return null;
|
|
41
|
+
return control.value.length <= max ? null : { maxLength: { max, actual: control.value.length } };
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
static pattern(pattern: string, message?: string): ValidatorFn {
|
|
46
|
+
return (control: AbstractControl): ValidationErrors | null => {
|
|
47
|
+
if (!control.value) return null;
|
|
48
|
+
const regex = new RegExp(pattern);
|
|
49
|
+
return regex.test(control.value) ? null : { pattern: { message: message || 'Invalid format' } };
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
static numberRange(min?: number, max?: number): ValidatorFn {
|
|
54
|
+
return (control: AbstractControl): ValidationErrors | null => {
|
|
55
|
+
if (!control.value && control.value !== 0) return null;
|
|
56
|
+
const value = Number(control.value);
|
|
57
|
+
if (min !== undefined && value < min) {
|
|
58
|
+
return { min: { min, actual: value } };
|
|
59
|
+
}
|
|
60
|
+
if (max !== undefined && value > max) {
|
|
61
|
+
return { max: { max, actual: value } };
|
|
62
|
+
}
|
|
63
|
+
return null;
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
static dateRange(minDate?: string, maxDate?: string): ValidatorFn {
|
|
68
|
+
return (control: AbstractControl): ValidationErrors | null => {
|
|
69
|
+
if (!control.value) return null;
|
|
70
|
+
const date = new Date(control.value);
|
|
71
|
+
if (minDate && date < new Date(minDate)) {
|
|
72
|
+
return { minDate: { minDate } };
|
|
73
|
+
}
|
|
74
|
+
if (maxDate && date > new Date(maxDate)) {
|
|
75
|
+
return { maxDate: { maxDate } };
|
|
76
|
+
}
|
|
77
|
+
return null;
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
static getErrorMessage(errors: ValidationErrors | null): string {
|
|
82
|
+
if (!errors) return '';
|
|
83
|
+
|
|
84
|
+
if (errors['required']) return 'This field is required';
|
|
85
|
+
if (errors['email']) return 'Please enter a valid email address';
|
|
86
|
+
if (errors['phone']) return 'Please enter a valid phone number';
|
|
87
|
+
if (errors['url']) return 'Please enter a valid URL';
|
|
88
|
+
if (errors['minLength']) return `Minimum length is ${errors['minLength'].min} characters`;
|
|
89
|
+
if (errors['maxLength']) return `Maximum length is ${errors['maxLength'].max} characters`;
|
|
90
|
+
if (errors['min']) return `Minimum value is ${errors['min'].min}`;
|
|
91
|
+
if (errors['max']) return `Maximum value is ${errors['max'].max}`;
|
|
92
|
+
if (errors['minDate']) return `Date must be after ${errors['minDate'].minDate}`;
|
|
93
|
+
if (errors['maxDate']) return `Date must be before ${errors['maxDate'].maxDate}`;
|
|
94
|
+
if (errors['pattern']) return errors['pattern'].message || 'Invalid format';
|
|
95
|
+
|
|
96
|
+
return 'Invalid value';
|
|
97
|
+
}
|
|
98
|
+
}
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
<div class="smart-table-outer">
|
|
2
|
+
<!-- Table Card -->
|
|
3
|
+
<div class="smart-table-wrapper">
|
|
4
|
+
<!-- Top Toolbar -->
|
|
5
|
+
<div class="st-toolbar" *ngIf="config.searchConfig?.enabled || (config.filters && config.filters.length > 0) || (config.topBarButtons && config.topBarButtons.length > 0)">
|
|
6
|
+
|
|
7
|
+
<!-- Search -->
|
|
8
|
+
<div class="st-search" *ngIf="config.searchConfig?.enabled">
|
|
9
|
+
<i class="fa fa-search"></i>
|
|
10
|
+
<input type="text" [placeholder]="config.labels?.searchPlaceholder || 'Search'" (input)="onSearch($event)">
|
|
11
|
+
</div>
|
|
12
|
+
|
|
13
|
+
<!-- Filters -->
|
|
14
|
+
<div class="st-filters" *ngIf="config.filters">
|
|
15
|
+
<div class="st-filter-item" *ngFor="let filter of config.filters">
|
|
16
|
+
<!-- Trigger -->
|
|
17
|
+
<div class="st-filter-trigger"
|
|
18
|
+
[class.active]="openFilterKey === filter.key"
|
|
19
|
+
[class.has-value]="isFilterActive(filter)"
|
|
20
|
+
(click)="toggleFilter(filter.key, $event)">
|
|
21
|
+
<span class="st-filter-trigger-label">{{ getFilterDisplay(filter) }}</span>
|
|
22
|
+
<svg class="st-filter-chevron" width="12" height="12" viewBox="0 0 12 12" fill="none">
|
|
23
|
+
<path d="M2.5 4.5L6 8L9.5 4.5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
24
|
+
</svg>
|
|
25
|
+
</div>
|
|
26
|
+
</div>
|
|
27
|
+
</div>
|
|
28
|
+
|
|
29
|
+
<!-- Top Bar Buttons -->
|
|
30
|
+
<div class="st-actions" *ngIf="config.topBarButtons">
|
|
31
|
+
<lib-button *ngFor="let btn of config.topBarButtons"
|
|
32
|
+
[variant]="btn.btnVariant || 'primary'"
|
|
33
|
+
[icon]="btn.icon || ''"
|
|
34
|
+
(click)="onTopAction(btn)">
|
|
35
|
+
{{ btn.label }}
|
|
36
|
+
</lib-button>
|
|
37
|
+
</div>
|
|
38
|
+
</div>
|
|
39
|
+
|
|
40
|
+
<!-- Selection count strip — visible whenever selectable is enabled -->
|
|
41
|
+
<div class="st-selection-strip" *ngIf="config.selectable">
|
|
42
|
+
<span class="st-selection-count">{{ selectedRows.length }} of {{ totalItems > 0 ? totalItems : data.length }} selected</span>
|
|
43
|
+
</div>
|
|
44
|
+
|
|
45
|
+
<!-- Table Container -->
|
|
46
|
+
<div class="st-table-container">
|
|
47
|
+
<div class="st-check-loader" *ngIf="loading">
|
|
48
|
+
<div class="spinner"></div>
|
|
49
|
+
</div>
|
|
50
|
+
<table class="st-table" [class.loading-data]="loading" [class.is-selectable]="config.selectable">
|
|
51
|
+
<thead>
|
|
52
|
+
<tr>
|
|
53
|
+
<th *ngIf="config.selectable" class="st-checkbox-col">
|
|
54
|
+
<input type="checkbox" (change)="onSelectAll($event)">
|
|
55
|
+
</th>
|
|
56
|
+
<th *ngFor="let col of config.columns; let colIndex = index"
|
|
57
|
+
#stickyHeader
|
|
58
|
+
[class.sortable]="col.sortable"
|
|
59
|
+
[class.sticky-col]="col.sticky"
|
|
60
|
+
[class.first-data-col]="colIndex === 0"
|
|
61
|
+
[ngStyle]="stickyColumnStyles[col.key]"
|
|
62
|
+
(click)="onSort(col)">
|
|
63
|
+
{{ col.label }}
|
|
64
|
+
<span *ngIf="col.sortable" class="sort-icon-wrap">
|
|
65
|
+
<svg width="18" height="18" viewBox="0 0 18 18" fill="none">
|
|
66
|
+
<!-- Down arrow — RIGHT side, prominent when DESC -->
|
|
67
|
+
<path d="M11.258 15.8153L14.5913 13.2699C14.7483 13.15 14.8364 12.9875 14.8364 12.818C14.8364 12.6486 14.7483 12.4861 14.5913 12.3662C14.4344 12.2464 14.2216 12.1791 13.9997 12.1791C13.7778 12.1791 13.5649 12.2464 13.408 12.3662L11.4997 13.8299V2.63636C11.4997 2.46758 11.4119 2.30572 11.2556 2.18638C11.0993 2.06704 10.8874 2 10.6663 2C10.4453 2 10.2334 2.06704 10.0771 2.18638C9.92081 2.30572 9.83301 2.46758 9.83301 2.63636V15.3635C9.83383 15.4891 9.88333 15.6117 9.97528 15.7159C10.0672 15.8201 10.1975 15.9012 10.3497 15.9489C10.4486 15.9845 10.557 16.002 10.6663 15.9998C10.776 16.0003 10.8847 15.9843 10.9863 15.9526C11.0878 15.9209 11.1801 15.8743 11.258 15.8153Z"
|
|
68
|
+
fill="black" [attr.fill-opacity]="getDescOpacity(col.key)"/>
|
|
69
|
+
<!-- Up arrow — LEFT side, prominent when ASC -->
|
|
70
|
+
<path d="M7.33316 16C7.11215 16 6.90019 15.933 6.74391 15.8136C6.58763 15.6942 6.49983 15.5324 6.49983 15.3636V4.16902L4.5915 5.63278C4.43458 5.75262 4.22175 5.81995 3.99983 5.81995C3.77791 5.81995 3.56508 5.75262 3.40816 5.63278C3.25124 5.51294 3.16309 5.3504 3.16309 5.18093C3.16309 5.01145 3.25124 4.84891 3.40816 4.72907L6.7415 2.18341C6.85868 2.0951 7.00749 2.03528 7.16915 2.01149C7.33081 1.98771 7.49807 2.00102 7.64983 2.04976C7.80201 2.0975 7.93228 2.17858 8.02423 2.28278C8.11617 2.38697 8.16567 2.50962 8.1665 2.63526V15.3636C8.1665 15.5324 8.0787 15.6942 7.92242 15.8136C7.76614 15.933 7.55418 16 7.33316 16Z"
|
|
71
|
+
fill="black" [attr.fill-opacity]="getAscOpacity(col.key)"/>
|
|
72
|
+
</svg>
|
|
73
|
+
</span>
|
|
74
|
+
</th>
|
|
75
|
+
<th *ngIf="config.actions && config.actions.length > 0" class="st-actions-col">
|
|
76
|
+
{{ config.labels?.actionColumnHeader || 'Actions' }}
|
|
77
|
+
</th>
|
|
78
|
+
</tr>
|
|
79
|
+
</thead>
|
|
80
|
+
<tbody>
|
|
81
|
+
<tr *ngFor="let row of data; let rowIndex = index" [class.editing-row]="row.isEditing" [ngClass]="row.isEditing && config.editingRowClass ? config.editingRowClass : ''">
|
|
82
|
+
<td *ngIf="config.selectable" class="st-checkbox-col">
|
|
83
|
+
<input type="checkbox" [(ngModel)]="row.selected" (change)="onRowSelect(row)">
|
|
84
|
+
</td>
|
|
85
|
+
<td *ngFor="let col of config.columns; let colIndex = index"
|
|
86
|
+
[class.sticky-col]="col.sticky"
|
|
87
|
+
[class.first-data-col]="colIndex === 0"
|
|
88
|
+
[ngStyle]="stickyColumnStyles[col.key]"
|
|
89
|
+
[class.clickable-cell]="col.clickAction"
|
|
90
|
+
(click)="onColumnClick(row, col)">
|
|
91
|
+
<!-- READ MODE -->
|
|
92
|
+
<ng-container *ngIf="!row.isEditing">
|
|
93
|
+
<!-- Text/Number/Date -->
|
|
94
|
+
<span *ngIf="col.type !== 'custom' && col.type !== 'html' && col.type !== 'badge'">
|
|
95
|
+
{{ getCellValue(row, col) }}
|
|
96
|
+
</span>
|
|
97
|
+
<!-- HTML -->
|
|
98
|
+
<div *ngIf="col.type === 'html'" [innerHTML]="getCellValue(row, col) | safeHtml"></div>
|
|
99
|
+
<!-- Badge -->
|
|
100
|
+
<span *ngIf="col.type === 'badge'" class="st-badge" [ngClass]="getBadgeClass(row, col)">
|
|
101
|
+
{{ getCellValue(row, col) }}
|
|
102
|
+
</span>
|
|
103
|
+
</ng-container>
|
|
104
|
+
|
|
105
|
+
<!-- EDIT/ADD MODE -->
|
|
106
|
+
<ng-container *ngIf="row.isEditing">
|
|
107
|
+
<!-- Multi-field cell (stacked inputs) -->
|
|
108
|
+
<div *ngIf="col.subFields" class="st-stacked-inputs">
|
|
109
|
+
<ng-container *ngFor="let sub of col.subFields">
|
|
110
|
+
<select *ngIf="sub.dataType === 'select'"
|
|
111
|
+
[(ngModel)]="row[sub.key]"
|
|
112
|
+
[disabled]="sub.editable === false || col.editConfig?.disabled"
|
|
113
|
+
class="st-cell-select">
|
|
114
|
+
<option *ngFor="let opt of sub.options" [value]="opt.value">{{ opt.label }}</option>
|
|
115
|
+
</select>
|
|
116
|
+
<!-- Date picker -->
|
|
117
|
+
<div *ngIf="sub.dataType === 'date'" class="st-date-cell">
|
|
118
|
+
<input matInput [matDatepicker]="subPicker"
|
|
119
|
+
[(ngModel)]="row[sub.key]"
|
|
120
|
+
[disabled]="sub.editable === false || col.editConfig?.disabled"
|
|
121
|
+
[placeholder]="sub.placeholder || ''"
|
|
122
|
+
class="st-cell-input"
|
|
123
|
+
(click)="subPicker.open()">
|
|
124
|
+
<mat-datepicker-toggle [for]="subPicker"></mat-datepicker-toggle>
|
|
125
|
+
<mat-datepicker #subPicker></mat-datepicker>
|
|
126
|
+
</div>
|
|
127
|
+
<input *ngIf="sub.dataType !== 'select' && sub.dataType !== 'date'"
|
|
128
|
+
[type]="sub.dataType"
|
|
129
|
+
[(ngModel)]="row[sub.key]"
|
|
130
|
+
[disabled]="sub.editable === false || col.editConfig?.disabled"
|
|
131
|
+
[placeholder]="sub.placeholder || ''"
|
|
132
|
+
class="st-cell-input">
|
|
133
|
+
</ng-container>
|
|
134
|
+
</div>
|
|
135
|
+
|
|
136
|
+
<!-- Single field cell input -->
|
|
137
|
+
<div *ngIf="!col.subFields">
|
|
138
|
+
<select *ngIf="col.dataType === 'select'"
|
|
139
|
+
[(ngModel)]="row[col.key]"
|
|
140
|
+
[disabled]="col.editable === false || col.editConfig?.disabled"
|
|
141
|
+
class="st-cell-select">
|
|
142
|
+
<option *ngFor="let opt of col.options" [value]="opt.value">{{ opt.label }}</option>
|
|
143
|
+
</select>
|
|
144
|
+
<!-- Date picker -->
|
|
145
|
+
<div *ngIf="col.dataType === 'date'" class="st-date-cell">
|
|
146
|
+
<input matInput [matDatepicker]="colPicker"
|
|
147
|
+
[(ngModel)]="row[col.key]"
|
|
148
|
+
[disabled]="col.editable === false || col.editConfig?.disabled"
|
|
149
|
+
class="st-cell-input"
|
|
150
|
+
(click)="colPicker.open()">
|
|
151
|
+
<mat-datepicker-toggle [for]="colPicker"></mat-datepicker-toggle>
|
|
152
|
+
<mat-datepicker #colPicker></mat-datepicker>
|
|
153
|
+
</div>
|
|
154
|
+
<input *ngIf="col.dataType !== 'select' && col.dataType !== 'date'"
|
|
155
|
+
[type]="col.dataType || 'text'"
|
|
156
|
+
[(ngModel)]="row[col.key]"
|
|
157
|
+
[disabled]="col.editable === false || col.editConfig?.disabled"
|
|
158
|
+
class="st-cell-input">
|
|
159
|
+
</div>
|
|
160
|
+
</ng-container>
|
|
161
|
+
</td>
|
|
162
|
+
|
|
163
|
+
<!-- Row Actions -->
|
|
164
|
+
<td *ngIf="config.actions && config.actions.length > 0" class="st-row-actions st-actions-col">
|
|
165
|
+
<div class="action-buttons">
|
|
166
|
+
<!-- EDIT MODE ACTIONS -->
|
|
167
|
+
<ng-container *ngIf="row.isEditing">
|
|
168
|
+
<div class="edit-mode-actions">
|
|
169
|
+
<lib-button variant="outline" (click)="onCancelRow(row, rowIndex); $event.stopPropagation()">
|
|
170
|
+
{{ config.labels?.cancelLabel || 'Cancel' }}
|
|
171
|
+
</lib-button>
|
|
172
|
+
<lib-button [variant]="row.isNew ? (config.labels?.addButtonVariant || 'danger') : (config.labels?.saveButtonVariant || 'primary')" (click)="onSaveRow(row); $event.stopPropagation()">
|
|
173
|
+
{{ row.isNew ? (config.labels?.addLabel || 'Add') : (config.labels?.saveLabel || 'Save') }}
|
|
174
|
+
</lib-button>
|
|
175
|
+
</div>
|
|
176
|
+
</ng-container>
|
|
177
|
+
|
|
178
|
+
<!-- READ MODE ACTIONS -->
|
|
179
|
+
<ng-container *ngIf="!row.isEditing">
|
|
180
|
+
<ng-container *ngFor="let action of config.actions; let i = index">
|
|
181
|
+
<ng-container *ngIf="action.type === 'dropdown'">
|
|
182
|
+
<div class="st-dropdown-container" (click)="$event.stopPropagation()">
|
|
183
|
+
<button class="st-dropdown-btn"
|
|
184
|
+
[class.active]="openDropdownId === (rowIndex + '-' + i)"
|
|
185
|
+
(click)="toggleDropdown(rowIndex + '-' + i, $event, action.items, row)">
|
|
186
|
+
<span class="action-circle">
|
|
187
|
+
<i class="fa fa-ellipsis-h"></i>
|
|
188
|
+
</span>
|
|
189
|
+
</button>
|
|
190
|
+
</div>
|
|
191
|
+
</ng-container>
|
|
192
|
+
<ng-container *ngIf="action.type !== 'dropdown'">
|
|
193
|
+
<lib-button
|
|
194
|
+
[variant]="action.btnVariant || 'secondary'"
|
|
195
|
+
[icon]="action.icon || ''"
|
|
196
|
+
(click)="onAction(action, row)">
|
|
197
|
+
{{ action.label }}
|
|
198
|
+
</lib-button>
|
|
199
|
+
</ng-container>
|
|
200
|
+
</ng-container>
|
|
201
|
+
</ng-container>
|
|
202
|
+
</div>
|
|
203
|
+
</td>
|
|
204
|
+
</tr>
|
|
205
|
+
<tr *ngIf="data.length === 0 && !loading">
|
|
206
|
+
<td [attr.colspan]="columnCount + (config.selectable ? 1 : 0) + (config.actions ? 1 : 0)" class="no-data">
|
|
207
|
+
{{ config.labels?.noDataMessage || 'No data available' }}
|
|
208
|
+
</td>
|
|
209
|
+
</tr>
|
|
210
|
+
</tbody>
|
|
211
|
+
</table>
|
|
212
|
+
</div>
|
|
213
|
+
|
|
214
|
+
<!-- Pagination — inside the card, sticks to the bottom -->
|
|
215
|
+
<div class="st-pagination" *ngIf="showPagination">
|
|
216
|
+
<lib-pagination
|
|
217
|
+
[totalItems]="totalItems"
|
|
218
|
+
[itemsPerPage]="config.pagination!.pageSize"
|
|
219
|
+
[currentPage]="currentPage"
|
|
220
|
+
[pageSizeOptions]="config.pagination!.pageSizeOptions"
|
|
221
|
+
(pageChange)="onPageChange($event)"
|
|
222
|
+
(itemsPerPageChange)="onPageSizeChange($event)">
|
|
223
|
+
</lib-pagination>
|
|
224
|
+
</div>
|
|
225
|
+
|
|
226
|
+
<!-- Built-in Delete Confirmation Modal -->
|
|
227
|
+
<cc-confirmation-modal
|
|
228
|
+
[isOpen]="deleteModalOpen"
|
|
229
|
+
[config]="deleteModalConfig"
|
|
230
|
+
(confirm)="onDeleteConfirm()"
|
|
231
|
+
(cancel)="onDeleteCancel()"
|
|
232
|
+
(close)="onDeleteCancel()">
|
|
233
|
+
<p>{{ deleteModalMessage }}</p>
|
|
234
|
+
</cc-confirmation-modal>
|
|
235
|
+
</div>
|
|
236
|
+
</div>
|
|
237
|
+
|
|
238
|
+
<!--
|
|
239
|
+
Filter panel portal — position:fixed keeps it above all overflow/sticky containers.
|
|
240
|
+
-->
|
|
241
|
+
<div class="st-filter-panel"
|
|
242
|
+
*ngIf="openFilterKey !== null && activeFilterData"
|
|
243
|
+
[ngStyle]="{
|
|
244
|
+
position: 'fixed',
|
|
245
|
+
top: filterPosition.top + 'px',
|
|
246
|
+
left: filterPosition.left + 'px',
|
|
247
|
+
'z-index': '99999'
|
|
248
|
+
}"
|
|
249
|
+
(click)="$event.stopPropagation()">
|
|
250
|
+
<div class="st-filter-option"
|
|
251
|
+
[class.selected]="!isFilterActive(activeFilterData)"
|
|
252
|
+
(click)="selectFilterOption(activeFilterData, null)">
|
|
253
|
+
All {{ activeFilterData.label }}
|
|
254
|
+
</div>
|
|
255
|
+
<div class="st-filter-option"
|
|
256
|
+
*ngFor="let opt of getValidFilterOptions(activeFilterData)"
|
|
257
|
+
[class.selected]="activeFilters[activeFilterData.key] === opt.value"
|
|
258
|
+
(click)="selectFilterOption(activeFilterData, opt)">
|
|
259
|
+
{{ opt.label }}
|
|
260
|
+
</div>
|
|
261
|
+
</div>
|
|
262
|
+
|
|
263
|
+
<!--
|
|
264
|
+
Dropdown portal — rendered OUTSIDE every scroll/sticky container.
|
|
265
|
+
position:fixed + z-index:99999 here is unconditionally above all sticky table cells.
|
|
266
|
+
-->
|
|
267
|
+
<div class="st-dropdown-menu st-dropdown-portal"
|
|
268
|
+
*ngIf="openDropdownId !== null && activeDropdownItems"
|
|
269
|
+
[ngStyle]="{
|
|
270
|
+
position: 'fixed',
|
|
271
|
+
top: dropdownPosition.top + 'px',
|
|
272
|
+
right: dropdownPosition.right + 'px',
|
|
273
|
+
left: 'auto',
|
|
274
|
+
'z-index': '99999'
|
|
275
|
+
}"
|
|
276
|
+
(click)="$event.stopPropagation()">
|
|
277
|
+
<button class="st-dropdown-item"
|
|
278
|
+
*ngFor="let item of activeDropdownItems"
|
|
279
|
+
(click)="onActionItemClick(item, activeDropdownRow, $event); closeDropdown()">
|
|
280
|
+
<i *ngIf="item.icon" [class]="item.icon + ' st-action-icon'"></i>
|
|
281
|
+
<span>{{ item.label }}</span>
|
|
282
|
+
</button>
|
|
283
|
+
</div>
|