@es.framework/ng.ui.core 2.0.58
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/README.md +3 -0
- package/attachments/README.md +3 -0
- package/base-crud/README.md +3 -0
- package/breadcrumb/README.md +3 -0
- package/checkbox/README.md +3 -0
- package/collapsible/README.md +3 -0
- package/color-picker/README.md +3 -0
- package/column-settings-popover/README.md +3 -0
- package/custom-switch/README.md +3 -0
- package/datepicker/README.md +3 -0
- package/deactivation-reason/README.md +3 -0
- package/excel-import/README.md +3 -0
- package/fesm2022/es.framework-ng.ui.core-attachments.mjs +217 -0
- package/fesm2022/es.framework-ng.ui.core-attachments.mjs.map +1 -0
- package/fesm2022/es.framework-ng.ui.core-base-crud.mjs +370 -0
- package/fesm2022/es.framework-ng.ui.core-base-crud.mjs.map +1 -0
- package/fesm2022/es.framework-ng.ui.core-breadcrumb.mjs +145 -0
- package/fesm2022/es.framework-ng.ui.core-breadcrumb.mjs.map +1 -0
- package/fesm2022/es.framework-ng.ui.core-checkbox.mjs +131 -0
- package/fesm2022/es.framework-ng.ui.core-checkbox.mjs.map +1 -0
- package/fesm2022/es.framework-ng.ui.core-collapsible.mjs +90 -0
- package/fesm2022/es.framework-ng.ui.core-collapsible.mjs.map +1 -0
- package/fesm2022/es.framework-ng.ui.core-color-picker.mjs +87 -0
- package/fesm2022/es.framework-ng.ui.core-color-picker.mjs.map +1 -0
- package/fesm2022/es.framework-ng.ui.core-column-settings-popover.mjs +183 -0
- package/fesm2022/es.framework-ng.ui.core-column-settings-popover.mjs.map +1 -0
- package/fesm2022/es.framework-ng.ui.core-custom-switch.mjs +119 -0
- package/fesm2022/es.framework-ng.ui.core-custom-switch.mjs.map +1 -0
- package/fesm2022/es.framework-ng.ui.core-datepicker.mjs +519 -0
- package/fesm2022/es.framework-ng.ui.core-datepicker.mjs.map +1 -0
- package/fesm2022/es.framework-ng.ui.core-deactivation-reason.mjs +144 -0
- package/fesm2022/es.framework-ng.ui.core-deactivation-reason.mjs.map +1 -0
- package/fesm2022/es.framework-ng.ui.core-excel-import.mjs +566 -0
- package/fesm2022/es.framework-ng.ui.core-excel-import.mjs.map +1 -0
- package/fesm2022/es.framework-ng.ui.core-filter-templates.mjs +386 -0
- package/fesm2022/es.framework-ng.ui.core-filter-templates.mjs.map +1 -0
- package/fesm2022/es.framework-ng.ui.core-form-button.mjs +62 -0
- package/fesm2022/es.framework-ng.ui.core-form-button.mjs.map +1 -0
- package/fesm2022/es.framework-ng.ui.core-form-field.mjs +155 -0
- package/fesm2022/es.framework-ng.ui.core-form-field.mjs.map +1 -0
- package/fesm2022/es.framework-ng.ui.core-form-template.mjs +37 -0
- package/fesm2022/es.framework-ng.ui.core-form-template.mjs.map +1 -0
- package/fesm2022/es.framework-ng.ui.core-formly-avatar-image.mjs +132 -0
- package/fesm2022/es.framework-ng.ui.core-formly-avatar-image.mjs.map +1 -0
- package/fesm2022/es.framework-ng.ui.core-formly-avatar-label.mjs +89 -0
- package/fesm2022/es.framework-ng.ui.core-formly-avatar-label.mjs.map +1 -0
- package/fesm2022/es.framework-ng.ui.core-formly-button-selector.mjs +195 -0
- package/fesm2022/es.framework-ng.ui.core-formly-button-selector.mjs.map +1 -0
- package/fesm2022/es.framework-ng.ui.core-formly-button.mjs +73 -0
- package/fesm2022/es.framework-ng.ui.core-formly-button.mjs.map +1 -0
- package/fesm2022/es.framework-ng.ui.core-formly-presets.mjs +201 -0
- package/fesm2022/es.framework-ng.ui.core-formly-presets.mjs.map +1 -0
- package/fesm2022/es.framework-ng.ui.core-formly-prime-icon-picker.mjs +542 -0
- package/fesm2022/es.framework-ng.ui.core-formly-prime-icon-picker.mjs.map +1 -0
- package/fesm2022/es.framework-ng.ui.core-formly-split-button.mjs +62 -0
- package/fesm2022/es.framework-ng.ui.core-formly-split-button.mjs.map +1 -0
- package/fesm2022/es.framework-ng.ui.core-formly-ui-all.mjs +422 -0
- package/fesm2022/es.framework-ng.ui.core-formly-ui-all.mjs.map +1 -0
- package/fesm2022/es.framework-ng.ui.core-formly-ui.mjs +48 -0
- package/fesm2022/es.framework-ng.ui.core-formly-ui.mjs.map +1 -0
- package/fesm2022/es.framework-ng.ui.core-formly-username-with-domain.mjs +85 -0
- package/fesm2022/es.framework-ng.ui.core-formly-username-with-domain.mjs.map +1 -0
- package/fesm2022/es.framework-ng.ui.core-generic-assets.mjs +22 -0
- package/fesm2022/es.framework-ng.ui.core-generic-assets.mjs.map +1 -0
- package/fesm2022/es.framework-ng.ui.core-generic-autocomplete.mjs +173 -0
- package/fesm2022/es.framework-ng.ui.core-generic-autocomplete.mjs.map +1 -0
- package/fesm2022/es.framework-ng.ui.core-generic-button.mjs +150 -0
- package/fesm2022/es.framework-ng.ui.core-generic-button.mjs.map +1 -0
- package/fesm2022/es.framework-ng.ui.core-generic-card.mjs +218 -0
- package/fesm2022/es.framework-ng.ui.core-generic-card.mjs.map +1 -0
- package/fesm2022/es.framework-ng.ui.core-generic-crud-table.mjs +929 -0
- package/fesm2022/es.framework-ng.ui.core-generic-crud-table.mjs.map +1 -0
- package/fesm2022/es.framework-ng.ui.core-generic-dialog.mjs +321 -0
- package/fesm2022/es.framework-ng.ui.core-generic-dialog.mjs.map +1 -0
- package/fesm2022/es.framework-ng.ui.core-generic-errormessage.mjs +35 -0
- package/fesm2022/es.framework-ng.ui.core-generic-errormessage.mjs.map +1 -0
- package/fesm2022/es.framework-ng.ui.core-generic-formly-fields.mjs +63 -0
- package/fesm2022/es.framework-ng.ui.core-generic-formly-fields.mjs.map +1 -0
- package/fesm2022/es.framework-ng.ui.core-generic-loadingspinner.mjs +34 -0
- package/fesm2022/es.framework-ng.ui.core-generic-loadingspinner.mjs.map +1 -0
- package/fesm2022/es.framework-ng.ui.core-generic-report-tabs.mjs +196 -0
- package/fesm2022/es.framework-ng.ui.core-generic-report-tabs.mjs.map +1 -0
- package/fesm2022/es.framework-ng.ui.core-generic-report.mjs +556 -0
- package/fesm2022/es.framework-ng.ui.core-generic-report.mjs.map +1 -0
- package/fesm2022/es.framework-ng.ui.core-generic-search-advanced.mjs +2995 -0
- package/fesm2022/es.framework-ng.ui.core-generic-search-advanced.mjs.map +1 -0
- package/fesm2022/es.framework-ng.ui.core-generic-search.mjs +103 -0
- package/fesm2022/es.framework-ng.ui.core-generic-search.mjs.map +1 -0
- package/fesm2022/es.framework-ng.ui.core-generic-selector.mjs +684 -0
- package/fesm2022/es.framework-ng.ui.core-generic-selector.mjs.map +1 -0
- package/fesm2022/es.framework-ng.ui.core-generic-table.mjs +388 -0
- package/fesm2022/es.framework-ng.ui.core-generic-table.mjs.map +1 -0
- package/fesm2022/es.framework-ng.ui.core-generic-view.mjs +465 -0
- package/fesm2022/es.framework-ng.ui.core-generic-view.mjs.map +1 -0
- package/fesm2022/es.framework-ng.ui.core-header-wrapper.mjs +31 -0
- package/fesm2022/es.framework-ng.ui.core-header-wrapper.mjs.map +1 -0
- package/fesm2022/es.framework-ng.ui.core-icon-picker.mjs +205 -0
- package/fesm2022/es.framework-ng.ui.core-icon-picker.mjs.map +1 -0
- package/fesm2022/es.framework-ng.ui.core-input-switch.mjs +102 -0
- package/fesm2022/es.framework-ng.ui.core-input-switch.mjs.map +1 -0
- package/fesm2022/es.framework-ng.ui.core-input-with-icon.mjs +67 -0
- package/fesm2022/es.framework-ng.ui.core-input-with-icon.mjs.map +1 -0
- package/fesm2022/es.framework-ng.ui.core-input.mjs +250 -0
- package/fesm2022/es.framework-ng.ui.core-input.mjs.map +1 -0
- package/fesm2022/es.framework-ng.ui.core-label-type.mjs +184 -0
- package/fesm2022/es.framework-ng.ui.core-label-type.mjs.map +1 -0
- package/fesm2022/es.framework-ng.ui.core-loading-skeletons.mjs +66 -0
- package/fesm2022/es.framework-ng.ui.core-loading-skeletons.mjs.map +1 -0
- package/fesm2022/es.framework-ng.ui.core-odata-query-builder.mjs +307 -0
- package/fesm2022/es.framework-ng.ui.core-odata-query-builder.mjs.map +1 -0
- package/fesm2022/es.framework-ng.ui.core-query-type.mjs +162 -0
- package/fesm2022/es.framework-ng.ui.core-query-type.mjs.map +1 -0
- package/fesm2022/es.framework-ng.ui.core-radio.mjs +120 -0
- package/fesm2022/es.framework-ng.ui.core-radio.mjs.map +1 -0
- package/fesm2022/es.framework-ng.ui.core-repeat.mjs +290 -0
- package/fesm2022/es.framework-ng.ui.core-repeat.mjs.map +1 -0
- package/fesm2022/es.framework-ng.ui.core-select.mjs +179 -0
- package/fesm2022/es.framework-ng.ui.core-select.mjs.map +1 -0
- package/fesm2022/es.framework-ng.ui.core-sidebar-cards.mjs +52 -0
- package/fesm2022/es.framework-ng.ui.core-sidebar-cards.mjs.map +1 -0
- package/fesm2022/es.framework-ng.ui.core-sidebar-toggles.mjs +53 -0
- package/fesm2022/es.framework-ng.ui.core-sidebar-toggles.mjs.map +1 -0
- package/fesm2022/es.framework-ng.ui.core-tabs.mjs +57 -0
- package/fesm2022/es.framework-ng.ui.core-tabs.mjs.map +1 -0
- package/fesm2022/es.framework-ng.ui.core-tag-type.mjs +209 -0
- package/fesm2022/es.framework-ng.ui.core-tag-type.mjs.map +1 -0
- package/fesm2022/es.framework-ng.ui.core-text-editor.mjs +58 -0
- package/fesm2022/es.framework-ng.ui.core-text-editor.mjs.map +1 -0
- package/fesm2022/es.framework-ng.ui.core-textarea.mjs +93 -0
- package/fesm2022/es.framework-ng.ui.core-textarea.mjs.map +1 -0
- package/fesm2022/es.framework-ng.ui.core-wrappers.mjs +245 -0
- package/fesm2022/es.framework-ng.ui.core-wrappers.mjs.map +1 -0
- package/fesm2022/es.framework-ng.ui.core.mjs +20 -0
- package/fesm2022/es.framework-ng.ui.core.mjs.map +1 -0
- package/filter-templates/README.md +3 -0
- package/form-button/README.md +3 -0
- package/form-field/README.md +3 -0
- package/form-template/README.md +3 -0
- package/formly-avatar-image/README.md +3 -0
- package/formly-avatar-label/README.md +3 -0
- package/formly-button/README.md +3 -0
- package/formly-button-selector/README.md +3 -0
- package/formly-presets/README.md +3 -0
- package/formly-prime-icon-picker/README.md +3 -0
- package/formly-split-button/README.md +3 -0
- package/formly-ui/README.md +3 -0
- package/formly-ui-all/README.md +3 -0
- package/formly-username-with-domain/README.md +3 -0
- package/generic-assets/README.md +3 -0
- package/generic-autocomplete/README.md +3 -0
- package/generic-button/README.md +3 -0
- package/generic-card/README.md +3 -0
- package/generic-crud-table/README.md +3 -0
- package/generic-dialog/README.md +3 -0
- package/generic-errormessage/README.md +3 -0
- package/generic-formly-fields/README.md +3 -0
- package/generic-loadingspinner/README.md +3 -0
- package/generic-report/README.md +3 -0
- package/generic-report-tabs/README.md +0 -0
- package/generic-search/README.md +3 -0
- package/generic-search-advanced/README.md +3 -0
- package/generic-selector/README.md +3 -0
- package/generic-table/README.md +3 -0
- package/generic-view/README.md +3 -0
- package/header-wrapper/README.md +3 -0
- package/icon-picker/README.md +3 -0
- package/input/README.md +3 -0
- package/input-switch/README.md +3 -0
- package/input-with-icon/README.md +3 -0
- package/label-type/README.md +3 -0
- package/loading-skeletons/README.md +3 -0
- package/odata-query-builder/README.md +3 -0
- package/package.json +264 -0
- package/query-type/README.md +3 -0
- package/radio/README.md +3 -0
- package/repeat/README.md +3 -0
- package/select/README.md +3 -0
- package/sidebar-cards/README.md +3 -0
- package/sidebar-toggles/README.md +3 -0
- package/styles.css +2 -0
- package/tabs/README.md +3 -0
- package/tag-type/README.md +3 -0
- package/text-editor/README.md +3 -0
- package/textarea/README.md +3 -0
- package/types/es.framework-ng.ui.core-attachments.d.ts +38 -0
- package/types/es.framework-ng.ui.core-base-crud.d.ts +74 -0
- package/types/es.framework-ng.ui.core-breadcrumb.d.ts +17 -0
- package/types/es.framework-ng.ui.core-checkbox.d.ts +33 -0
- package/types/es.framework-ng.ui.core-collapsible.d.ts +18 -0
- package/types/es.framework-ng.ui.core-color-picker.d.ts +16 -0
- package/types/es.framework-ng.ui.core-column-settings-popover.d.ts +46 -0
- package/types/es.framework-ng.ui.core-custom-switch.d.ts +19 -0
- package/types/es.framework-ng.ui.core-datepicker.d.ts +23 -0
- package/types/es.framework-ng.ui.core-deactivation-reason.d.ts +32 -0
- package/types/es.framework-ng.ui.core-excel-import.d.ts +69 -0
- package/types/es.framework-ng.ui.core-filter-templates.d.ts +57 -0
- package/types/es.framework-ng.ui.core-form-button.d.ts +17 -0
- package/types/es.framework-ng.ui.core-form-field.d.ts +30 -0
- package/types/es.framework-ng.ui.core-form-template.d.ts +16 -0
- package/types/es.framework-ng.ui.core-formly-avatar-image.d.ts +18 -0
- package/types/es.framework-ng.ui.core-formly-avatar-label.d.ts +36 -0
- package/types/es.framework-ng.ui.core-formly-button-selector.d.ts +35 -0
- package/types/es.framework-ng.ui.core-formly-button.d.ts +20 -0
- package/types/es.framework-ng.ui.core-formly-presets.d.ts +37 -0
- package/types/es.framework-ng.ui.core-formly-prime-icon-picker.d.ts +45 -0
- package/types/es.framework-ng.ui.core-formly-split-button.d.ts +23 -0
- package/types/es.framework-ng.ui.core-formly-ui-all.d.ts +40 -0
- package/types/es.framework-ng.ui.core-formly-ui.d.ts +13 -0
- package/types/es.framework-ng.ui.core-formly-username-with-domain.d.ts +19 -0
- package/types/es.framework-ng.ui.core-generic-assets.d.ts +10 -0
- package/types/es.framework-ng.ui.core-generic-autocomplete.d.ts +41 -0
- package/types/es.framework-ng.ui.core-generic-button.d.ts +39 -0
- package/types/es.framework-ng.ui.core-generic-card.d.ts +93 -0
- package/types/es.framework-ng.ui.core-generic-crud-table.d.ts +293 -0
- package/types/es.framework-ng.ui.core-generic-dialog.d.ts +93 -0
- package/types/es.framework-ng.ui.core-generic-errormessage.d.ts +17 -0
- package/types/es.framework-ng.ui.core-generic-formly-fields.d.ts +26 -0
- package/types/es.framework-ng.ui.core-generic-loadingspinner.d.ts +16 -0
- package/types/es.framework-ng.ui.core-generic-report-tabs.d.ts +21 -0
- package/types/es.framework-ng.ui.core-generic-report.d.ts +121 -0
- package/types/es.framework-ng.ui.core-generic-search-advanced.d.ts +305 -0
- package/types/es.framework-ng.ui.core-generic-search.d.ts +36 -0
- package/types/es.framework-ng.ui.core-generic-selector.d.ts +99 -0
- package/types/es.framework-ng.ui.core-generic-table.d.ts +84 -0
- package/types/es.framework-ng.ui.core-generic-view.d.ts +97 -0
- package/types/es.framework-ng.ui.core-header-wrapper.d.ts +15 -0
- package/types/es.framework-ng.ui.core-icon-picker.d.ts +30 -0
- package/types/es.framework-ng.ui.core-input-switch.d.ts +16 -0
- package/types/es.framework-ng.ui.core-input-with-icon.d.ts +17 -0
- package/types/es.framework-ng.ui.core-input.d.ts +47 -0
- package/types/es.framework-ng.ui.core-label-type.d.ts +38 -0
- package/types/es.framework-ng.ui.core-loading-skeletons.d.ts +17 -0
- package/types/es.framework-ng.ui.core-odata-query-builder.d.ts +87 -0
- package/types/es.framework-ng.ui.core-query-type.d.ts +37 -0
- package/types/es.framework-ng.ui.core-radio.d.ts +38 -0
- package/types/es.framework-ng.ui.core-repeat.d.ts +31 -0
- package/types/es.framework-ng.ui.core-select.d.ts +42 -0
- package/types/es.framework-ng.ui.core-sidebar-cards.d.ts +25 -0
- package/types/es.framework-ng.ui.core-sidebar-toggles.d.ts +25 -0
- package/types/es.framework-ng.ui.core-tabs.d.ts +17 -0
- package/types/es.framework-ng.ui.core-tag-type.d.ts +34 -0
- package/types/es.framework-ng.ui.core-text-editor.d.ts +16 -0
- package/types/es.framework-ng.ui.core-textarea.d.ts +36 -0
- package/types/es.framework-ng.ui.core-wrappers.d.ts +36 -0
- package/types/es.framework-ng.ui.core.d.ts +8 -0
- package/wrappers/README.md +3 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { NgModule, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
3
|
+
import { CommonModule } from '@angular/common';
|
|
4
|
+
import * as i1 from '@angular/forms';
|
|
5
|
+
import { ReactiveFormsModule, FormsModule } from '@angular/forms';
|
|
6
|
+
import { FieldType } from '@ngx-formly/core';
|
|
7
|
+
import { TranslatePipe } from '@es.framework/ng.core/pipes';
|
|
8
|
+
import { ToggleSwitch } from 'primeng/toggleswitch';
|
|
9
|
+
import * as i2 from 'primeng/tooltip';
|
|
10
|
+
import { TooltipModule, Tooltip } from 'primeng/tooltip';
|
|
11
|
+
|
|
12
|
+
class CustomSwitchModule {
|
|
13
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: CustomSwitchModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
14
|
+
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: CustomSwitchModule, imports: [CommonModule] });
|
|
15
|
+
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: CustomSwitchModule, imports: [CommonModule] });
|
|
16
|
+
}
|
|
17
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: CustomSwitchModule, decorators: [{
|
|
18
|
+
type: NgModule,
|
|
19
|
+
args: [{
|
|
20
|
+
imports: [CommonModule],
|
|
21
|
+
}]
|
|
22
|
+
}] });
|
|
23
|
+
|
|
24
|
+
class CustomSwitchFieldComponent extends FieldType {
|
|
25
|
+
updateModel(value) {
|
|
26
|
+
this.formControl.setValue(value);
|
|
27
|
+
// التحويل الآمن للمفتاح
|
|
28
|
+
const key = Array.isArray(this.key) ? this.key.join('.') : this.key;
|
|
29
|
+
if (this.model && key) {
|
|
30
|
+
this.model[key] = value ? 1 : 2;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
ngAfterViewInit() {
|
|
34
|
+
const key = Array.isArray(this.key) ? this.key.join('.') : this.key;
|
|
35
|
+
if (!key)
|
|
36
|
+
return;
|
|
37
|
+
if (this.model[key] === undefined) {
|
|
38
|
+
this.model[key] = 1;
|
|
39
|
+
this.formControl.setValue(true);
|
|
40
|
+
}
|
|
41
|
+
else if (this.model[key] === 1) {
|
|
42
|
+
this.formControl.setValue(true);
|
|
43
|
+
}
|
|
44
|
+
else if (this.model[key] === 2) {
|
|
45
|
+
this.formControl.setValue(false);
|
|
46
|
+
}
|
|
47
|
+
// ✅ تأكد أن الموديل دائماً رقم 1 أو 2
|
|
48
|
+
this.model[key] = this.formControl.value ? 1 : 2;
|
|
49
|
+
}
|
|
50
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: CustomSwitchFieldComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
51
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.1.3", type: CustomSwitchFieldComponent, isStandalone: true, selector: "formly-field-custom-switch", usesInheritance: true, ngImport: i0, template: `
|
|
52
|
+
<div class="flex items-center justify-between rtl:flex-row-reverse w-full px-2 py-1"
|
|
53
|
+
style=" border-radius: var(--p-inputtext-border-radius);">
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
<label [for]="id" class="font-bold text-lg text-gray-800">
|
|
57
|
+
{{ (to.label ?? '') | translate }}
|
|
58
|
+
|
|
59
|
+
@if (to.required) {
|
|
60
|
+
<span class="text-red-500">*</span>
|
|
61
|
+
}
|
|
62
|
+
</label>
|
|
63
|
+
|
|
64
|
+
<!-- التبديل نفسه -->
|
|
65
|
+
<p-toggleSwitch
|
|
66
|
+
[formControl]="formControl"
|
|
67
|
+
[inputId]="id"
|
|
68
|
+
[disabled]="to.disabled || false"
|
|
69
|
+
[pTooltip]="field.props['tooltip']"
|
|
70
|
+
[styleClass]="''"
|
|
71
|
+
(onChange)="updateModel($event.checked)"
|
|
72
|
+
></p-toggleSwitch>
|
|
73
|
+
|
|
74
|
+
</div>
|
|
75
|
+
|
|
76
|
+
`, isInline: true, dependencies: [{ kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "ngmodule", type: FormsModule }, { kind: "component", type: ToggleSwitch, selector: "p-toggleswitch, p-toggleSwitch, p-toggle-switch", inputs: ["styleClass", "tabindex", "inputId", "readonly", "trueValue", "falseValue", "ariaLabel", "size", "ariaLabelledBy", "autofocus"], outputs: ["onChange"] }, { kind: "ngmodule", type: TooltipModule }, { kind: "directive", type: i2.Tooltip, selector: "[pTooltip]", inputs: ["tooltipPosition", "tooltipEvent", "positionStyle", "tooltipStyleClass", "tooltipZIndex", "escape", "showDelay", "hideDelay", "life", "positionTop", "positionLeft", "autoHide", "fitContent", "hideOnEscape", "pTooltip", "tooltipDisabled", "tooltipOptions", "appendTo", "ptTooltip"] }, { kind: "pipe", type: TranslatePipe, name: "translate" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
77
|
+
}
|
|
78
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: CustomSwitchFieldComponent, decorators: [{
|
|
79
|
+
type: Component,
|
|
80
|
+
args: [{
|
|
81
|
+
selector: 'formly-field-custom-switch',
|
|
82
|
+
standalone: true,
|
|
83
|
+
imports: [ReactiveFormsModule, FormsModule, ToggleSwitch, TranslatePipe, TooltipModule, Tooltip],
|
|
84
|
+
template: `
|
|
85
|
+
<div class="flex items-center justify-between rtl:flex-row-reverse w-full px-2 py-1"
|
|
86
|
+
style=" border-radius: var(--p-inputtext-border-radius);">
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
<label [for]="id" class="font-bold text-lg text-gray-800">
|
|
90
|
+
{{ (to.label ?? '') | translate }}
|
|
91
|
+
|
|
92
|
+
@if (to.required) {
|
|
93
|
+
<span class="text-red-500">*</span>
|
|
94
|
+
}
|
|
95
|
+
</label>
|
|
96
|
+
|
|
97
|
+
<!-- التبديل نفسه -->
|
|
98
|
+
<p-toggleSwitch
|
|
99
|
+
[formControl]="formControl"
|
|
100
|
+
[inputId]="id"
|
|
101
|
+
[disabled]="to.disabled || false"
|
|
102
|
+
[pTooltip]="field.props['tooltip']"
|
|
103
|
+
[styleClass]="''"
|
|
104
|
+
(onChange)="updateModel($event.checked)"
|
|
105
|
+
></p-toggleSwitch>
|
|
106
|
+
|
|
107
|
+
</div>
|
|
108
|
+
|
|
109
|
+
`,
|
|
110
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
111
|
+
}]
|
|
112
|
+
}] });
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Generated bundle index. Do not edit.
|
|
116
|
+
*/
|
|
117
|
+
|
|
118
|
+
export { CustomSwitchFieldComponent, CustomSwitchModule };
|
|
119
|
+
//# sourceMappingURL=es.framework-ng.ui.core-custom-switch.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"es.framework-ng.ui.core-custom-switch.mjs","sources":["../../../../libs/ng.ui.core/custom-switch/src/lib/custom-switch-module.ts","../../../../libs/ng.ui.core/custom-switch/src/lib/custom-switch.ts","../../../../libs/ng.ui.core/custom-switch/src/es.framework-ng.ui.core-custom-switch.ts"],"sourcesContent":["import { NgModule } from '@angular/core';\nimport { CommonModule } from '@angular/common';\n\n@NgModule({\n imports: [CommonModule],\n})\nexport class CustomSwitchModule {}\n","\r\nimport { AfterViewInit, ChangeDetectionStrategy, Component } from '@angular/core';\r\nimport { ReactiveFormsModule, FormsModule } from '@angular/forms';\r\nimport { FieldType, FieldTypeConfig, FormlyAttributes } from '@ngx-formly/core';\r\nimport { TranslatePipe } from '@es.framework/ng.core/pipes';\r\nimport { ToggleSwitch } from 'primeng/toggleswitch';\r\nimport { TooltipModule, Tooltip } from 'primeng/tooltip';\r\n\r\n@Component({\r\n selector: 'formly-field-custom-switch',\r\n standalone: true,\r\n imports: [ReactiveFormsModule, FormsModule, ToggleSwitch, TranslatePipe, TooltipModule, Tooltip],\r\n template: `\r\n <div class=\"flex items-center justify-between rtl:flex-row-reverse w-full px-2 py-1\"\r\n style=\" border-radius: var(--p-inputtext-border-radius);\">\r\n \r\n \r\n <label [for]=\"id\" class=\"font-bold text-lg text-gray-800\">\r\n {{ (to.label ?? '') | translate }}\r\n \r\n @if (to.required) {\r\n <span class=\"text-red-500\">*</span>\r\n }\r\n </label>\r\n \r\n <!-- التبديل نفسه -->\r\n <p-toggleSwitch\r\n [formControl]=\"formControl\"\r\n [inputId]=\"id\"\r\n [disabled]=\"to.disabled || false\"\r\n [pTooltip]=\"field.props['tooltip']\"\r\n [styleClass]=\"''\"\r\n (onChange)=\"updateModel($event.checked)\"\r\n ></p-toggleSwitch>\r\n \r\n </div>\r\n \r\n `,\r\n changeDetection: ChangeDetectionStrategy.OnPush,\r\n})\r\nexport class CustomSwitchFieldComponent extends FieldType<FieldTypeConfig> implements AfterViewInit {\r\n\r\n updateModel(value: boolean) {\r\n this.formControl.setValue(value);\r\n\r\n // التحويل الآمن للمفتاح\r\n const key = Array.isArray(this.key) ? this.key.join('.') : this.key;\r\n\r\n if (this.model && key) {\r\n this.model[key] = value ? 1 : 2;\r\n }\r\n }\r\n\r\n ngAfterViewInit() {\r\n const key = Array.isArray(this.key) ? this.key.join('.') : this.key;\r\n\r\n if (!key) return;\r\n\r\n if (this.model[key] === undefined) {\r\n this.model[key] = 1;\r\n this.formControl.setValue(true);\r\n }\r\n else if (this.model[key] === 1) {\r\n this.formControl.setValue(true);\r\n }\r\n else if (this.model[key] === 2) {\r\n this.formControl.setValue(false);\r\n }\r\n\r\n // ✅ تأكد أن الموديل دائماً رقم 1 أو 2\r\n this.model[key] = this.formControl.value ? 1 : 2;\r\n}\r\n\r\n}\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,519 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { NgModule, inject, ChangeDetectorRef, ViewChild, Component } from '@angular/core';
|
|
3
|
+
import * as i2 from '@angular/common';
|
|
4
|
+
import { CommonModule } from '@angular/common';
|
|
5
|
+
import * as i1$1 from '@ngx-formly/core';
|
|
6
|
+
import { FieldType, FormlyAttributes, FormlyModule } from '@ngx-formly/core';
|
|
7
|
+
import * as i1 from '@angular/forms';
|
|
8
|
+
import { FormControl, FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|
9
|
+
import * as i3 from 'primeng/datepicker';
|
|
10
|
+
import { DatePickerModule } from 'primeng/datepicker';
|
|
11
|
+
import * as i4 from 'primeng/button';
|
|
12
|
+
import { ButtonModule } from 'primeng/button';
|
|
13
|
+
import * as i5 from 'primeng/inputtext';
|
|
14
|
+
import { InputTextModule } from 'primeng/inputtext';
|
|
15
|
+
import { DialogModule } from 'primeng/dialog';
|
|
16
|
+
import { TranslatePipe } from '@es.framework/ng.core/pipes';
|
|
17
|
+
import * as i6 from 'primeng/inputgroup';
|
|
18
|
+
import { InputGroupModule } from 'primeng/inputgroup';
|
|
19
|
+
import * as i7 from 'primeng/inputgroupaddon';
|
|
20
|
+
import { InputGroupAddonModule } from 'primeng/inputgroupaddon';
|
|
21
|
+
import { SelectModule } from 'primeng/select';
|
|
22
|
+
import { FormlyFormFieldModule } from '@es.framework/ng.ui.core/form-field';
|
|
23
|
+
|
|
24
|
+
class DatepickerModule {
|
|
25
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: DatepickerModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
26
|
+
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: DatepickerModule, imports: [CommonModule] });
|
|
27
|
+
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: DatepickerModule, imports: [CommonModule] });
|
|
28
|
+
}
|
|
29
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: DatepickerModule, decorators: [{
|
|
30
|
+
type: NgModule,
|
|
31
|
+
args: [{
|
|
32
|
+
imports: [CommonModule],
|
|
33
|
+
}]
|
|
34
|
+
}] });
|
|
35
|
+
|
|
36
|
+
class FormlyFieldDatepicker extends FieldType {
|
|
37
|
+
datepickerComp;
|
|
38
|
+
dialogVisible = false;
|
|
39
|
+
cdr = inject(ChangeDetectorRef);
|
|
40
|
+
get mode() {
|
|
41
|
+
return this.props['mode'] || 'date';
|
|
42
|
+
}
|
|
43
|
+
dateControl = new FormControl(null);
|
|
44
|
+
timeControl = new FormControl(null);
|
|
45
|
+
ampmControl = new FormControl('AM');
|
|
46
|
+
get displayValue() {
|
|
47
|
+
const datePart = this.dateControl.value ? this.dateControl.value.toLocaleDateString() : '';
|
|
48
|
+
const timePart = this.timeControl.value && this.mode !== 'date'
|
|
49
|
+
? `${this.timeControl.value} ${this.ampmControl.value}`
|
|
50
|
+
: '';
|
|
51
|
+
if (this.mode === 'date')
|
|
52
|
+
return datePart;
|
|
53
|
+
if (this.mode === 'time')
|
|
54
|
+
return timePart;
|
|
55
|
+
if (this.mode === 'datetime')
|
|
56
|
+
return datePart && timePart ? `${datePart} ${timePart}` : datePart || timePart || '';
|
|
57
|
+
return '';
|
|
58
|
+
}
|
|
59
|
+
ngOnInit() {
|
|
60
|
+
this.setInitialValue(this.formControl.value);
|
|
61
|
+
this.formControl.valueChanges.subscribe((value) => {
|
|
62
|
+
this.setInitialValue(value);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
setInitialValue(value) {
|
|
66
|
+
if (!value) {
|
|
67
|
+
this.dateControl.setValue(null, { emitEvent: false });
|
|
68
|
+
this.timeControl.setValue(null, { emitEvent: false });
|
|
69
|
+
this.ampmControl.setValue('AM', { emitEvent: false });
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
// --- 1. HANDLE DATE PART ---
|
|
73
|
+
if (this.mode !== 'time') {
|
|
74
|
+
const dateStr = value.split('T')[0];
|
|
75
|
+
let dt = null;
|
|
76
|
+
if (dateStr.includes('-')) {
|
|
77
|
+
const parts = dateStr.split('-');
|
|
78
|
+
if (parts[0].length === 4) {
|
|
79
|
+
// Format: yyyy-MM-dd (ISO)
|
|
80
|
+
dt = new Date(dateStr);
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
// Format: dd-MM-yyyy
|
|
84
|
+
const [day, month, year] = parts;
|
|
85
|
+
dt = new Date(`${year}-${month}-${day}`);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
dt = new Date(dateStr);
|
|
90
|
+
}
|
|
91
|
+
if (dt && !isNaN(dt.getTime())) {
|
|
92
|
+
this.dateControl.setValue(dt, { emitEvent: false });
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
// --- 2. HANDLE TIME PART ---
|
|
96
|
+
if (this.mode !== 'date') {
|
|
97
|
+
let timeStr = '';
|
|
98
|
+
if (this.mode === 'time') {
|
|
99
|
+
// Expecting "HH:mm:ss" or "HH:mm" or "HH:mm AM/PM"
|
|
100
|
+
timeStr = value.split(' ')[0]; // Take only the time part, ignore any existing "AM/PM" string
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
// mode is 'datetime', expecting "yyyy-MM-ddTHH:mm:ss"
|
|
104
|
+
const tPart = value.split('T')[1];
|
|
105
|
+
if (tPart)
|
|
106
|
+
timeStr = tPart.substring(0, 5); // Take "HH:mm"
|
|
107
|
+
}
|
|
108
|
+
if (timeStr && timeStr.includes(':')) {
|
|
109
|
+
const parts = timeStr.split(':');
|
|
110
|
+
let hours = parseInt(parts[0], 10);
|
|
111
|
+
const minutes = parseInt(parts[1], 10) || 0;
|
|
112
|
+
// Logic to determine AM/PM from 24-hour input
|
|
113
|
+
const ampm = hours >= 12 ? 'PM' : 'AM';
|
|
114
|
+
// Convert 24h to 12h for the UI input
|
|
115
|
+
hours = hours % 12;
|
|
116
|
+
if (hours === 0)
|
|
117
|
+
hours = 12;
|
|
118
|
+
this.timeControl.setValue(`${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}`, { emitEvent: false });
|
|
119
|
+
this.ampmControl.setValue(ampm, { emitEvent: false });
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
openDialog() {
|
|
124
|
+
this.dialogVisible = true;
|
|
125
|
+
}
|
|
126
|
+
saveDialog() {
|
|
127
|
+
this.updateModel(false);
|
|
128
|
+
this.dialogVisible = false;
|
|
129
|
+
}
|
|
130
|
+
autoFixDate(e) {
|
|
131
|
+
let v = e.target.value.replace(/\D/g, '');
|
|
132
|
+
if (v.length === 8) {
|
|
133
|
+
const dd = v.substring(0, 2);
|
|
134
|
+
const mm = v.substring(2, 4);
|
|
135
|
+
const yyyy = v.substring(4, 8);
|
|
136
|
+
const formatted = `${dd}-${mm}-${yyyy}`;
|
|
137
|
+
this.dateControl.setValue(formatted, { emitEvent: true });
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
onDateChange(UIInput) {
|
|
141
|
+
this.updateModel(UIInput);
|
|
142
|
+
}
|
|
143
|
+
onTimeInput(event) {
|
|
144
|
+
if (this.mode === 'date')
|
|
145
|
+
return;
|
|
146
|
+
let input = event.target.value;
|
|
147
|
+
input = input.replace(/\D/g, '');
|
|
148
|
+
if (input.length > 2)
|
|
149
|
+
input = input.slice(0, 2) + ':' + input.slice(2, 4);
|
|
150
|
+
input = input.slice(0, 5);
|
|
151
|
+
this.timeControl.setValue(input, { emitEvent: false });
|
|
152
|
+
}
|
|
153
|
+
onTimeChange() {
|
|
154
|
+
if (this.mode === 'date')
|
|
155
|
+
return;
|
|
156
|
+
const value = this.timeControl.value;
|
|
157
|
+
if (!value)
|
|
158
|
+
return;
|
|
159
|
+
let [hourStr, minuteStr] = value.split(':');
|
|
160
|
+
let hours = parseInt(hourStr ?? '12', 10);
|
|
161
|
+
let minutes = parseInt(minuteStr ?? '0', 10);
|
|
162
|
+
if (isNaN(hours) || hours < 1)
|
|
163
|
+
hours = 1;
|
|
164
|
+
if (hours > 12)
|
|
165
|
+
hours = 12;
|
|
166
|
+
if (isNaN(minutes) || minutes < 0)
|
|
167
|
+
minutes = 0;
|
|
168
|
+
if (minutes > 59)
|
|
169
|
+
minutes = 59;
|
|
170
|
+
this.timeControl.setValue(`${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}`);
|
|
171
|
+
this.updateModel(false);
|
|
172
|
+
}
|
|
173
|
+
toggleAmPm() {
|
|
174
|
+
this.ampmControl.setValue(this.ampmControl.value === 'AM' ? 'PM' : 'AM');
|
|
175
|
+
this.updateModel(false);
|
|
176
|
+
}
|
|
177
|
+
updateModel(UIInput) {
|
|
178
|
+
const dateVal = this.dateControl.value;
|
|
179
|
+
const timeVal = this.timeControl.value;
|
|
180
|
+
const ampm = this.ampmControl.value ?? 'AM';
|
|
181
|
+
// --- CASE 1: TIME ONLY ---
|
|
182
|
+
if (this.mode === 'time') {
|
|
183
|
+
if (timeVal) {
|
|
184
|
+
let [hourStr, minuteStr] = timeVal.split(':');
|
|
185
|
+
let hours = parseInt(hourStr, 10) || 0;
|
|
186
|
+
let minutes = parseInt(minuteStr, 10) || 0;
|
|
187
|
+
// Convert 12-hour format (UI) to 24-hour format (Backend TimeSpan)
|
|
188
|
+
if (ampm === 'PM' && hours < 12)
|
|
189
|
+
hours += 12;
|
|
190
|
+
if (ampm === 'AM' && hours === 12)
|
|
191
|
+
hours = 0;
|
|
192
|
+
// Format as HH:mm:ss for C# TimeSpan compatibility
|
|
193
|
+
const val = `${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}:00`;
|
|
194
|
+
this.formControl.setValue(val, { emitEvent: true });
|
|
195
|
+
if (this.props.change) {
|
|
196
|
+
this.props.change(this.field, { item: this.model });
|
|
197
|
+
this.cdr.detectChanges();
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
// --- CASE 2: DATE ONLY ---
|
|
202
|
+
else if (this.mode === 'date') {
|
|
203
|
+
if (dateVal) {
|
|
204
|
+
let dt;
|
|
205
|
+
if (typeof dateVal === 'string' && dateVal.includes('-')) {
|
|
206
|
+
const [day, month, year] = dateVal.split('-');
|
|
207
|
+
const fullYear = year.length === 2 ? `20${year}` : year;
|
|
208
|
+
dt = new Date(`${fullYear}-${month}-${day}`);
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
dt = new Date(dateVal);
|
|
212
|
+
}
|
|
213
|
+
if (isNaN(dt.getTime())) {
|
|
214
|
+
dt = new Date();
|
|
215
|
+
}
|
|
216
|
+
const val = `${dt.getFullYear()}-` +
|
|
217
|
+
`${(dt.getMonth() + 1).toString().padStart(2, '0')}-` +
|
|
218
|
+
`${dt.getDate().toString().padStart(2, '0')}`;
|
|
219
|
+
this.formControl.setValue(val, { emitEvent: true });
|
|
220
|
+
if (this.props.change) {
|
|
221
|
+
this.props.change(this.field, { item: this.model });
|
|
222
|
+
this.cdr.detectChanges();
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
// --- CASE 3: DATETIME ---
|
|
227
|
+
else if (this.mode === 'datetime') {
|
|
228
|
+
if (dateVal) {
|
|
229
|
+
let hours = 0;
|
|
230
|
+
let minutes = 0;
|
|
231
|
+
if (timeVal && timeVal.trim() !== '') {
|
|
232
|
+
const [h, m] = timeVal.split(':');
|
|
233
|
+
hours = parseInt(h, 10) || 0;
|
|
234
|
+
minutes = parseInt(m, 10) || 0;
|
|
235
|
+
// Convert to 24-hour format
|
|
236
|
+
if (ampm === 'PM' && hours < 12)
|
|
237
|
+
hours += 12;
|
|
238
|
+
if (ampm === 'AM' && hours === 12)
|
|
239
|
+
hours = 0;
|
|
240
|
+
}
|
|
241
|
+
let dt;
|
|
242
|
+
if (typeof dateVal === 'string' && dateVal.includes('-')) {
|
|
243
|
+
const [day, month, year] = dateVal.split('-');
|
|
244
|
+
const fullYear = year.length === 2 ? `20${year}` : year;
|
|
245
|
+
dt = new Date(`${fullYear}-${month}-${day}`);
|
|
246
|
+
}
|
|
247
|
+
else {
|
|
248
|
+
dt = new Date(dateVal);
|
|
249
|
+
}
|
|
250
|
+
dt.setHours(hours, minutes, 0, 0);
|
|
251
|
+
if (isNaN(dt.getTime())) {
|
|
252
|
+
this.formControl.setValue(null);
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
// Format as YYYY-MM-DDTHH:mm:ss
|
|
256
|
+
const val = `${dt.getFullYear()}-` +
|
|
257
|
+
`${(dt.getMonth() + 1).toString().padStart(2, '0')}-` +
|
|
258
|
+
`${dt.getDate().toString().padStart(2, '0')}T` +
|
|
259
|
+
`${dt.getHours().toString().padStart(2, '0')}:` +
|
|
260
|
+
`${dt.getMinutes().toString().padStart(2, '0')}:00`;
|
|
261
|
+
this.formControl.setValue(val, { emitEvent: true });
|
|
262
|
+
if (this.props.change) {
|
|
263
|
+
this.props.change(this.field, { item: this.model });
|
|
264
|
+
this.cdr.detectChanges();
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: FormlyFieldDatepicker, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
270
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.1.3", type: FormlyFieldDatepicker, isStandalone: true, selector: "formly-field-primeng-datepicker", viewQueries: [{ propertyName: "datepickerComp", first: true, predicate: ["datepickerComp"], descendants: true }], usesInheritance: true, ngImport: i0, template: `
|
|
271
|
+
|
|
272
|
+
<p-inputGroup class="w-full">
|
|
273
|
+
<!-- [inputStyle]="{'border-left':'0'}" -->
|
|
274
|
+
@if (mode !== 'time') {
|
|
275
|
+
<!-- [(ngModel)]="dateControl.value" -->
|
|
276
|
+
<p-datepicker
|
|
277
|
+
#datepickerComp
|
|
278
|
+
[formControl]="dateControl"
|
|
279
|
+
dateFormat="dd-mm-yy"
|
|
280
|
+
dataType="string"
|
|
281
|
+
placeholder="DD-MM-YYYY"
|
|
282
|
+
[showIcon]="false"
|
|
283
|
+
inputId="buttondisplay"
|
|
284
|
+
[showOnFocus]="true"
|
|
285
|
+
appendTo="body"
|
|
286
|
+
class="w-full rounded-none"
|
|
287
|
+
inputStyleClass="rtl:border-r-0 ltr:border-l-0"
|
|
288
|
+
dropdownMode="current"
|
|
289
|
+
[formlyAttributes]="field"
|
|
290
|
+
[disabled]="!!props.disabled"
|
|
291
|
+
(onSelect)="onDateChange(true)"
|
|
292
|
+
(onInput)="onDateChange(true)"
|
|
293
|
+
[selectionMode]="props['selectionMode'] || 'single'"
|
|
294
|
+
></p-datepicker>
|
|
295
|
+
<!-- (onInput)="autoFixDate($event)" -->
|
|
296
|
+
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
@if (mode !== 'date') {
|
|
300
|
+
<input
|
|
301
|
+
pInputText
|
|
302
|
+
type="text"
|
|
303
|
+
placeholder="00:00"
|
|
304
|
+
maxlength="5"
|
|
305
|
+
[formControl]="timeControl"
|
|
306
|
+
(input)="onTimeInput($event)"
|
|
307
|
+
(blur)="onTimeChange()"
|
|
308
|
+
class="w-20"
|
|
309
|
+
[ngStyle]="{
|
|
310
|
+
'border-radius': mode == 'time' ? '':'0px',
|
|
311
|
+
'width': '53px !important',
|
|
312
|
+
'padding-left': mode == 'time' ? '':'2px',
|
|
313
|
+
'padding-right': mode == 'time' ? '':'2px',
|
|
314
|
+
'border-left':mode == 'time' ? '': '0px',
|
|
315
|
+
'border-right': mode == 'time' ? '': '0px'
|
|
316
|
+
}"
|
|
317
|
+
[classList]="mode == 'time' ? 'p-autocomplete-input p-component p-inputtext' : ''"
|
|
318
|
+
/>
|
|
319
|
+
|
|
320
|
+
<p-inputGroupAddon [style]="{'padding': 'initial'}">
|
|
321
|
+
<select
|
|
322
|
+
(change)="toggleAmPm()"
|
|
323
|
+
[disabled]="!!props.disabled"
|
|
324
|
+
style=" padding-top: 0.4rem;
|
|
325
|
+
padding-bottom: 0.5rem; padding-left: 0.5rem;
|
|
326
|
+
padding-right: 0.5rem;
|
|
327
|
+
background: var(--p-button-secondary-background);
|
|
328
|
+
"
|
|
329
|
+
class=" pr-8 bg-white text-gray-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent disabled:opacity-50 disabled:cursor-not-allowed appearance-none"
|
|
330
|
+
>
|
|
331
|
+
<option value="AM" [selected]="ampmControl.value === 'AM'">{{'AM' | translate}}</option>
|
|
332
|
+
<option value="PM" [selected]="ampmControl.value === 'PM'">{{'PM' | translate}}</option>
|
|
333
|
+
</select>
|
|
334
|
+
</p-inputGroupAddon>
|
|
335
|
+
}
|
|
336
|
+
@if (mode == 'time') {
|
|
337
|
+
<p-inputGroupAddon>
|
|
338
|
+
<p-button
|
|
339
|
+
tabindex="-1"
|
|
340
|
+
[disabled]="!!props.disabled"
|
|
341
|
+
icon="pi pi-clock"
|
|
342
|
+
severity="primary"
|
|
343
|
+
/>
|
|
344
|
+
</p-inputGroupAddon>
|
|
345
|
+
}
|
|
346
|
+
@if (mode !== 'time') {
|
|
347
|
+
<p-inputGroupAddon>
|
|
348
|
+
<p-button
|
|
349
|
+
tabindex="-1"
|
|
350
|
+
[disabled]="!!props.disabled"
|
|
351
|
+
icon="pi pi-calendar"
|
|
352
|
+
(click)="datepickerComp.toggle()"
|
|
353
|
+
severity="primary"
|
|
354
|
+
/>
|
|
355
|
+
</p-inputGroupAddon>
|
|
356
|
+
}
|
|
357
|
+
</p-inputGroup>
|
|
358
|
+
|
|
359
|
+
`, isInline: true, dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i1.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.MaxLengthValidator, selector: "[maxlength][formControlName],[maxlength][formControl],[maxlength][ngModel]", inputs: ["maxlength"] }, { kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i2.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "ngmodule", type: DatePickerModule }, { kind: "component", type: i3.DatePicker, selector: "p-datePicker, p-datepicker, p-date-picker", inputs: ["iconDisplay", "styleClass", "inputStyle", "inputId", "inputStyleClass", "placeholder", "ariaLabelledBy", "ariaLabel", "iconAriaLabel", "dateFormat", "multipleSeparator", "rangeSeparator", "inline", "showOtherMonths", "selectOtherMonths", "showIcon", "icon", "readonlyInput", "shortYearCutoff", "hourFormat", "timeOnly", "stepHour", "stepMinute", "stepSecond", "showSeconds", "showOnFocus", "showWeek", "startWeekFromFirstDayOfYear", "showClear", "dataType", "selectionMode", "maxDateCount", "showButtonBar", "todayButtonStyleClass", "clearButtonStyleClass", "autofocus", "autoZIndex", "baseZIndex", "panelStyleClass", "panelStyle", "keepInvalid", "hideOnDateTimeSelect", "touchUI", "timeSeparator", "focusTrap", "showTransitionOptions", "hideTransitionOptions", "tabindex", "minDate", "maxDate", "disabledDates", "disabledDays", "showTime", "responsiveOptions", "numberOfMonths", "firstDayOfWeek", "view", "defaultDate", "appendTo"], outputs: ["onFocus", "onBlur", "onClose", "onSelect", "onClear", "onInput", "onTodayClick", "onClearClick", "onMonthChange", "onYearChange", "onClickOutside", "onShow"] }, { kind: "ngmodule", type: ButtonModule }, { kind: "component", type: i4.Button, selector: "p-button", inputs: ["hostName", "type", "badge", "disabled", "raised", "rounded", "text", "plain", "outlined", "link", "tabindex", "size", "variant", "style", "styleClass", "badgeClass", "badgeSeverity", "ariaLabel", "autofocus", "iconPos", "icon", "label", "loading", "loadingIcon", "severity", "buttonProps", "fluid"], outputs: ["onClick", "onFocus", "onBlur"] }, { kind: "ngmodule", type: InputTextModule }, { kind: "directive", type: i5.InputText, selector: "[pInputText]", inputs: ["hostName", "ptInputText", "pSize", "variant", "fluid", "invalid"] }, { kind: "ngmodule", type: DialogModule }, { kind: "ngmodule", type: InputGroupModule }, { kind: "component", type: i6.InputGroup, selector: "p-inputgroup, p-inputGroup, p-input-group", inputs: ["styleClass"] }, { kind: "ngmodule", type: InputGroupAddonModule }, { kind: "component", type: i7.InputGroupAddon, selector: "p-inputgroup-addon, p-inputGroupAddon", inputs: ["style", "styleClass"] }, { kind: "directive", type: FormlyAttributes, selector: "[formlyAttributes]", inputs: ["formlyAttributes", "id"] }, { kind: "ngmodule", type: SelectModule }, { kind: "pipe", type: TranslatePipe, name: "translate" }] });
|
|
360
|
+
}
|
|
361
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: FormlyFieldDatepicker, decorators: [{
|
|
362
|
+
type: Component,
|
|
363
|
+
args: [{
|
|
364
|
+
selector: 'formly-field-primeng-datepicker',
|
|
365
|
+
standalone: true,
|
|
366
|
+
imports: [
|
|
367
|
+
FormsModule,
|
|
368
|
+
CommonModule,
|
|
369
|
+
ReactiveFormsModule,
|
|
370
|
+
DatePickerModule,
|
|
371
|
+
ButtonModule,
|
|
372
|
+
InputTextModule,
|
|
373
|
+
DialogModule,
|
|
374
|
+
TranslatePipe,
|
|
375
|
+
InputGroupModule,
|
|
376
|
+
InputGroupAddonModule,
|
|
377
|
+
FormlyAttributes,
|
|
378
|
+
SelectModule,
|
|
379
|
+
],
|
|
380
|
+
template: `
|
|
381
|
+
|
|
382
|
+
<p-inputGroup class="w-full">
|
|
383
|
+
<!-- [inputStyle]="{'border-left':'0'}" -->
|
|
384
|
+
@if (mode !== 'time') {
|
|
385
|
+
<!-- [(ngModel)]="dateControl.value" -->
|
|
386
|
+
<p-datepicker
|
|
387
|
+
#datepickerComp
|
|
388
|
+
[formControl]="dateControl"
|
|
389
|
+
dateFormat="dd-mm-yy"
|
|
390
|
+
dataType="string"
|
|
391
|
+
placeholder="DD-MM-YYYY"
|
|
392
|
+
[showIcon]="false"
|
|
393
|
+
inputId="buttondisplay"
|
|
394
|
+
[showOnFocus]="true"
|
|
395
|
+
appendTo="body"
|
|
396
|
+
class="w-full rounded-none"
|
|
397
|
+
inputStyleClass="rtl:border-r-0 ltr:border-l-0"
|
|
398
|
+
dropdownMode="current"
|
|
399
|
+
[formlyAttributes]="field"
|
|
400
|
+
[disabled]="!!props.disabled"
|
|
401
|
+
(onSelect)="onDateChange(true)"
|
|
402
|
+
(onInput)="onDateChange(true)"
|
|
403
|
+
[selectionMode]="props['selectionMode'] || 'single'"
|
|
404
|
+
></p-datepicker>
|
|
405
|
+
<!-- (onInput)="autoFixDate($event)" -->
|
|
406
|
+
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
@if (mode !== 'date') {
|
|
410
|
+
<input
|
|
411
|
+
pInputText
|
|
412
|
+
type="text"
|
|
413
|
+
placeholder="00:00"
|
|
414
|
+
maxlength="5"
|
|
415
|
+
[formControl]="timeControl"
|
|
416
|
+
(input)="onTimeInput($event)"
|
|
417
|
+
(blur)="onTimeChange()"
|
|
418
|
+
class="w-20"
|
|
419
|
+
[ngStyle]="{
|
|
420
|
+
'border-radius': mode == 'time' ? '':'0px',
|
|
421
|
+
'width': '53px !important',
|
|
422
|
+
'padding-left': mode == 'time' ? '':'2px',
|
|
423
|
+
'padding-right': mode == 'time' ? '':'2px',
|
|
424
|
+
'border-left':mode == 'time' ? '': '0px',
|
|
425
|
+
'border-right': mode == 'time' ? '': '0px'
|
|
426
|
+
}"
|
|
427
|
+
[classList]="mode == 'time' ? 'p-autocomplete-input p-component p-inputtext' : ''"
|
|
428
|
+
/>
|
|
429
|
+
|
|
430
|
+
<p-inputGroupAddon [style]="{'padding': 'initial'}">
|
|
431
|
+
<select
|
|
432
|
+
(change)="toggleAmPm()"
|
|
433
|
+
[disabled]="!!props.disabled"
|
|
434
|
+
style=" padding-top: 0.4rem;
|
|
435
|
+
padding-bottom: 0.5rem; padding-left: 0.5rem;
|
|
436
|
+
padding-right: 0.5rem;
|
|
437
|
+
background: var(--p-button-secondary-background);
|
|
438
|
+
"
|
|
439
|
+
class=" pr-8 bg-white text-gray-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent disabled:opacity-50 disabled:cursor-not-allowed appearance-none"
|
|
440
|
+
>
|
|
441
|
+
<option value="AM" [selected]="ampmControl.value === 'AM'">{{'AM' | translate}}</option>
|
|
442
|
+
<option value="PM" [selected]="ampmControl.value === 'PM'">{{'PM' | translate}}</option>
|
|
443
|
+
</select>
|
|
444
|
+
</p-inputGroupAddon>
|
|
445
|
+
}
|
|
446
|
+
@if (mode == 'time') {
|
|
447
|
+
<p-inputGroupAddon>
|
|
448
|
+
<p-button
|
|
449
|
+
tabindex="-1"
|
|
450
|
+
[disabled]="!!props.disabled"
|
|
451
|
+
icon="pi pi-clock"
|
|
452
|
+
severity="primary"
|
|
453
|
+
/>
|
|
454
|
+
</p-inputGroupAddon>
|
|
455
|
+
}
|
|
456
|
+
@if (mode !== 'time') {
|
|
457
|
+
<p-inputGroupAddon>
|
|
458
|
+
<p-button
|
|
459
|
+
tabindex="-1"
|
|
460
|
+
[disabled]="!!props.disabled"
|
|
461
|
+
icon="pi pi-calendar"
|
|
462
|
+
(click)="datepickerComp.toggle()"
|
|
463
|
+
severity="primary"
|
|
464
|
+
/>
|
|
465
|
+
</p-inputGroupAddon>
|
|
466
|
+
}
|
|
467
|
+
</p-inputGroup>
|
|
468
|
+
|
|
469
|
+
`,
|
|
470
|
+
}]
|
|
471
|
+
}], propDecorators: { datepickerComp: [{
|
|
472
|
+
type: ViewChild,
|
|
473
|
+
args: ['datepickerComp']
|
|
474
|
+
}] } });
|
|
475
|
+
|
|
476
|
+
function withFormlyFieldDatepicker() {
|
|
477
|
+
return {
|
|
478
|
+
types: [
|
|
479
|
+
{
|
|
480
|
+
name: 'datepicker',
|
|
481
|
+
component: FormlyFieldDatepicker,
|
|
482
|
+
wrappers: ['form-field'],
|
|
483
|
+
},
|
|
484
|
+
],
|
|
485
|
+
};
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
class FormlyDatepickerModule {
|
|
489
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: FormlyDatepickerModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
490
|
+
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "21.1.3", ngImport: i0, type: FormlyDatepickerModule, imports: [CommonModule,
|
|
491
|
+
ReactiveFormsModule,
|
|
492
|
+
DatePickerModule,
|
|
493
|
+
FormlyFormFieldModule, i1$1.FormlyModule] });
|
|
494
|
+
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: FormlyDatepickerModule, imports: [CommonModule,
|
|
495
|
+
ReactiveFormsModule,
|
|
496
|
+
DatePickerModule,
|
|
497
|
+
FormlyFormFieldModule,
|
|
498
|
+
FormlyModule.forChild(withFormlyFieldDatepicker())] });
|
|
499
|
+
}
|
|
500
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: FormlyDatepickerModule, decorators: [{
|
|
501
|
+
type: NgModule,
|
|
502
|
+
args: [{
|
|
503
|
+
// declarations: [FormlyFieldDatepicker],
|
|
504
|
+
imports: [
|
|
505
|
+
CommonModule,
|
|
506
|
+
ReactiveFormsModule,
|
|
507
|
+
DatePickerModule,
|
|
508
|
+
FormlyFormFieldModule,
|
|
509
|
+
FormlyModule.forChild(withFormlyFieldDatepicker()),
|
|
510
|
+
],
|
|
511
|
+
}]
|
|
512
|
+
}] });
|
|
513
|
+
|
|
514
|
+
/**
|
|
515
|
+
* Generated bundle index. Do not edit.
|
|
516
|
+
*/
|
|
517
|
+
|
|
518
|
+
export { DatepickerModule, FormlyDatepickerModule, withFormlyFieldDatepicker };
|
|
519
|
+
//# sourceMappingURL=es.framework-ng.ui.core-datepicker.mjs.map
|