primekit 1.0.9 → 1.0.10
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 +25 -25
- package/ng-package.json +8 -0
- package/package.json +12 -25
- package/src/assets/images/empty-table.svg +25 -25
- package/src/lib/lib/atomix-alert/atomix-alert.component.css +67 -0
- package/src/lib/lib/atomix-alert/atomix-alert.component.html +7 -0
- package/src/lib/lib/atomix-alert/atomix-alert.component.spec.ts +154 -0
- package/src/lib/lib/atomix-alert/atomix-alert.component.ts +75 -0
- package/src/lib/lib/atomix-autocomplete/atomix-autocomplete.component.html +35 -0
- package/src/lib/lib/atomix-autocomplete/atomix-autocomplete.component.scss +72 -0
- package/src/lib/lib/atomix-autocomplete/atomix-autocomplete.component.spec.ts +210 -0
- package/src/lib/lib/atomix-autocomplete/atomix-autocomplete.component.ts +70 -0
- package/src/lib/lib/atomix-button/atomix-button.component.css +70 -0
- package/src/lib/lib/atomix-button/atomix-button.component.html +20 -0
- package/src/lib/lib/atomix-button/atomix-button.component.spec.ts +135 -0
- package/src/lib/lib/atomix-button/atomix-button.component.ts +28 -0
- package/{lib/lib/atomix-button/atomix-button.models.d.ts → src/lib/lib/atomix-button/atomix-button.models.ts} +2 -2
- package/src/lib/lib/atomix-calendar/atomix-calendar.component.css +5 -0
- package/src/lib/lib/atomix-calendar/atomix-calendar.component.html +20 -0
- package/src/lib/lib/atomix-calendar/atomix-calendar.component.spec.ts +145 -0
- package/src/lib/lib/atomix-calendar/atomix-calendar.component.ts +71 -0
- package/src/lib/lib/atomix-card/atomix-card.component.css +4 -0
- package/src/lib/lib/atomix-card/atomix-card.component.html +3 -0
- package/src/lib/lib/atomix-card/atomix-card.component.spec.ts +63 -0
- package/src/lib/lib/atomix-card/atomix-card.component.ts +13 -0
- package/src/lib/lib/atomix-confirmation-dialog/atomix-confirmation-dialog.component.css +12 -0
- package/src/lib/lib/atomix-confirmation-dialog/atomix-confirmation-dialog.component.html +9 -0
- package/src/lib/lib/atomix-confirmation-dialog/atomix-confirmation-dialog.component.spec.ts +63 -0
- package/src/lib/lib/atomix-confirmation-dialog/atomix-confirmation-dialog.component.ts +22 -0
- package/src/lib/lib/atomix-daterange-calendar/atomix-daterange-calendar.component.html +233 -0
- package/src/lib/lib/atomix-daterange-calendar/atomix-daterange-calendar.component.scss +266 -0
- package/src/lib/lib/atomix-daterange-calendar/atomix-daterange-calendar.component.spec.ts +1465 -0
- package/src/lib/lib/atomix-daterange-calendar/atomix-daterange-calendar.component.ts +717 -0
- package/src/lib/lib/atomix-divider/atomix-divider.component.css +0 -0
- package/src/lib/lib/atomix-divider/atomix-divider.component.html +7 -0
- package/src/lib/lib/atomix-divider/atomix-divider.component.spec.ts +91 -0
- package/src/lib/lib/atomix-divider/atomix-divider.component.ts +17 -0
- package/src/lib/lib/atomix-dropdown/atomix-dropdown.component.css +25 -0
- package/src/lib/lib/atomix-dropdown/atomix-dropdown.component.html +37 -0
- package/src/lib/lib/atomix-dropdown/atomix-dropdown.component.spec.ts +178 -0
- package/src/lib/lib/atomix-dropdown/atomix-dropdown.component.ts +89 -0
- package/src/lib/lib/atomix-dynamic-dialog/atomix-dynamic-dialog.component.css +0 -0
- package/src/lib/lib/atomix-dynamic-dialog/atomix-dynamic-dialog.component.html +0 -0
- package/src/lib/lib/atomix-dynamic-dialog/atomix-dynamic-dialog.component.spec.ts +128 -0
- package/src/lib/lib/atomix-dynamic-dialog/atomix-dynamic-dialog.component.ts +42 -0
- package/src/lib/lib/atomix-dynamic-dialog/atomix-dynamic-dialog.models.ts +12 -0
- package/src/lib/lib/atomix-form/atomix-form-autocomplete/atomix-form-autocomplete.component.html +20 -0
- package/src/lib/lib/atomix-form/atomix-form-autocomplete/atomix-form-autocomplete.component.scss +7 -0
- package/src/lib/lib/atomix-form/atomix-form-autocomplete/atomix-form-autocomplete.component.spec.ts +169 -0
- package/src/lib/lib/atomix-form/atomix-form-autocomplete/atomix-form-autocomplete.component.ts +41 -0
- package/src/lib/lib/atomix-form/atomix-form-calendar/atomix-form-calendar.component.html +21 -0
- package/src/lib/lib/atomix-form/atomix-form-calendar/atomix-form-calendar.component.scss +7 -0
- package/src/lib/lib/atomix-form/atomix-form-calendar/atomix-form-calendar.component.spec.ts +142 -0
- package/src/lib/lib/atomix-form/atomix-form-calendar/atomix-form-calendar.component.ts +32 -0
- package/src/lib/lib/atomix-form/atomix-form-checkbox/atomix-form-checkbox.component.html +13 -0
- package/src/lib/lib/atomix-form/atomix-form-checkbox/atomix-form-checkbox.component.scss +14 -0
- package/src/lib/lib/atomix-form/atomix-form-checkbox/atomix-form-checkbox.component.spec.ts +112 -0
- package/src/lib/lib/atomix-form/atomix-form-checkbox/atomix-form-checkbox.component.ts +28 -0
- package/src/lib/lib/atomix-form/atomix-form-chips/atomix-form-chips.component.html +20 -0
- package/src/lib/lib/atomix-form/atomix-form-chips/atomix-form-chips.component.scss +3 -0
- package/src/lib/lib/atomix-form/atomix-form-chips/atomix-form-chips.component.spec.ts +153 -0
- package/src/lib/lib/atomix-form/atomix-form-chips/atomix-form-chips.component.ts +28 -0
- package/src/lib/lib/atomix-form/atomix-form-chips/form.chips.models.ts +5 -0
- package/src/lib/lib/atomix-form/atomix-form-dropdown/atomix-form-dropdown.component.html +24 -0
- package/src/lib/lib/atomix-form/atomix-form-dropdown/atomix-form-dropdown.component.scss +15 -0
- package/src/lib/lib/atomix-form/atomix-form-dropdown/atomix-form-dropdown.component.spec.ts +156 -0
- package/src/lib/lib/atomix-form/atomix-form-dropdown/atomix-form-dropdown.component.ts +36 -0
- package/src/lib/lib/atomix-form/atomix-form-input-component/atomix-form-input-component.component.html +33 -0
- package/src/lib/lib/atomix-form/atomix-form-input-component/atomix-form-input-component.component.scss +32 -0
- package/src/lib/lib/atomix-form/atomix-form-input-component/atomix-form-input-component.component.spec.ts +156 -0
- package/src/lib/lib/atomix-form/atomix-form-input-component/atomix-form-input-component.component.ts +42 -0
- package/src/lib/lib/atomix-form/atomix-form-inputmask-component/atomix-form-inputmask-component.component.html +14 -0
- package/src/lib/lib/atomix-form/atomix-form-inputmask-component/atomix-form-inputmask-component.component.scss +0 -0
- package/src/lib/lib/atomix-form/atomix-form-inputmask-component/atomix-form-inputmask-component.component.spec.ts +104 -0
- package/src/lib/lib/atomix-form/atomix-form-inputmask-component/atomix-form-inputmask-component.component.ts +24 -0
- package/src/lib/lib/atomix-form/atomix-form-password-component/atomix-form-password-component.component.html +16 -0
- package/src/lib/lib/atomix-form/atomix-form-password-component/atomix-form-password-component.component.scss +0 -0
- package/src/lib/lib/atomix-form/atomix-form-password-component/atomix-form-password-component.component.spec.ts +92 -0
- package/src/lib/lib/atomix-form/atomix-form-password-component/atomix-form-password-component.component.ts +24 -0
- package/src/lib/lib/atomix-form/atomix-form-radio-button/atomix-radio-button.component.html +23 -0
- package/src/lib/lib/atomix-form/atomix-form-radio-button/atomix-radio-button.component.scss +3 -0
- package/src/lib/lib/atomix-form/atomix-form-radio-button/atomix-radio-button.component.spec.ts +126 -0
- package/src/lib/lib/atomix-form/atomix-form-radio-button/atomix-radio-button.component.ts +26 -0
- package/src/lib/lib/atomix-form/atomix-form-textarea/atomix-form-textarea.component.html +17 -0
- package/src/lib/lib/atomix-form/atomix-form-textarea/atomix-form-textarea.component.scss +6 -0
- package/src/lib/lib/atomix-form/atomix-form-textarea/atomix-form-textarea.component.spec.ts +120 -0
- package/src/lib/lib/atomix-form/atomix-form-textarea/atomix-form-textarea.component.ts +24 -0
- package/src/lib/lib/atomix-input/atomix-input.component.css +52 -0
- package/src/lib/lib/atomix-input/atomix-input.component.html +45 -0
- package/src/lib/lib/atomix-input/atomix-input.component.spec.ts +229 -0
- package/src/lib/lib/atomix-input/atomix-input.component.ts +64 -0
- package/src/lib/lib/atomix-input-switch/atomix-input-switch.component.css +12 -0
- package/src/lib/lib/atomix-input-switch/atomix-input-switch.component.html +17 -0
- package/src/lib/lib/atomix-input-switch/atomix-input-switch.component.spec.ts +173 -0
- package/src/lib/lib/atomix-input-switch/atomix-input-switch.component.ts +62 -0
- package/src/lib/lib/atomix-loading-overlay/atomix-loading-overlay.component.html +47 -0
- package/src/lib/lib/atomix-loading-overlay/atomix-loading-overlay.component.scss +14 -0
- package/src/lib/lib/atomix-loading-overlay/atomix-loading-overlay.component.spec.ts +21 -0
- package/src/lib/lib/atomix-loading-overlay/atomix-loading-overlay.component.ts +25 -0
- package/src/lib/lib/atomix-messages/messages.component.css +0 -0
- package/src/lib/lib/atomix-messages/messages.component.html +9 -0
- package/src/lib/lib/atomix-messages/messages.component.spec.ts +115 -0
- package/src/lib/lib/atomix-messages/messages.component.ts +17 -0
- package/src/lib/lib/atomix-pagination/atomix-pagination.component.css +19 -0
- package/src/lib/lib/atomix-pagination/atomix-pagination.component.html +24 -0
- package/src/lib/lib/atomix-pagination/atomix-pagination.component.spec.ts +98 -0
- package/src/lib/lib/atomix-pagination/atomix-pagination.component.ts +36 -0
- package/src/lib/lib/atomix-radio-button/atomix-radio-button.component.css +0 -0
- package/src/lib/lib/atomix-radio-button/atomix-radio-button.component.html +7 -0
- package/src/lib/lib/atomix-radio-button/atomix-radio-button.component.spec.ts +116 -0
- package/src/lib/lib/atomix-radio-button/atomix-radio-button.component.ts +37 -0
- package/src/lib/lib/atomix-search-dropdown/atomix-search-dropdown.component.css +49 -0
- package/src/lib/lib/atomix-search-dropdown/atomix-search-dropdown.component.html +68 -0
- package/src/lib/lib/atomix-search-dropdown/atomix-search-dropdown.component.spec.ts +282 -0
- package/src/lib/lib/atomix-search-dropdown/atomix-search-dropdown.component.ts +119 -0
- package/{lib/lib/atomix-select-button/atomix-select-button-models.d.ts → src/lib/lib/atomix-select-button/atomix-select-button-models.ts} +4 -4
- package/src/lib/lib/atomix-select-button/atomix-select-button.component.css +5 -0
- package/src/lib/lib/atomix-select-button/atomix-select-button.component.html +7 -0
- package/src/lib/lib/atomix-select-button/atomix-select-button.component.spec.ts +73 -0
- package/src/lib/lib/atomix-select-button/atomix-select-button.component.ts +19 -0
- package/src/lib/lib/atomix-snackbar/atomix-snackbar.component.css +30 -0
- package/src/lib/lib/atomix-snackbar/atomix-snackbar.component.html +4 -0
- package/src/lib/lib/atomix-snackbar/atomix-snackbar.component.spec.ts +60 -0
- package/src/lib/lib/atomix-snackbar/atomix-snackbar.component.ts +27 -0
- package/src/lib/lib/atomix-spinner/atomix-spinner.component.css +0 -0
- package/src/lib/lib/atomix-spinner/atomix-spinner.component.html +7 -0
- package/src/lib/lib/atomix-spinner/atomix-spinner.component.spec.ts +70 -0
- package/src/lib/lib/atomix-spinner/atomix-spinner.component.ts +13 -0
- package/src/lib/lib/atomix-steps/atomix-steps.component.html +9 -0
- package/src/lib/lib/atomix-steps/atomix-steps.component.scss +0 -0
- package/src/lib/lib/atomix-steps/atomix-steps.component.spec.ts +120 -0
- package/src/lib/lib/atomix-steps/atomix-steps.component.ts +32 -0
- package/src/lib/lib/atomix-tabMenu/atomix-tabMenu.component.css +0 -0
- package/src/lib/lib/atomix-tabMenu/atomix-tabMenu.component.html +26 -0
- package/src/lib/lib/atomix-tabMenu/atomix-tabMenu.component.spec.ts +106 -0
- package/src/lib/lib/atomix-tabMenu/atomix-tabMenu.component.ts +36 -0
- package/src/lib/lib/atomix-table/atomix-table.component.css +152 -0
- package/src/lib/lib/atomix-table/atomix-table.component.html +647 -0
- package/src/lib/lib/atomix-table/atomix-table.component.spec.ts +1648 -0
- package/src/lib/lib/atomix-table/atomix-table.component.ts +422 -0
- package/src/lib/lib/atomix-table/atomix-table.models.ts +39 -0
- package/src/lib/lib/atomix-tag/atomix-tag.component.css +0 -0
- package/src/lib/lib/atomix-tag/atomix-tag.component.html +6 -0
- package/src/lib/lib/atomix-tag/atomix-tag.component.spec.ts +47 -0
- package/src/lib/lib/atomix-tag/atomix-tag.component.ts +13 -0
- package/src/lib/lib/utils/prime-icons.util.spec.ts +21 -0
- package/src/lib/lib/utils/prime-icons.util.ts +11 -0
- package/src/lib/primekit.component.spec.ts +19 -0
- package/src/lib/primekit.component.ts +10 -0
- package/src/lib/primekit.module.spec.ts +155 -0
- package/src/lib/primekit.module.ts +183 -0
- package/src/lib/primekit.service.spec.ts +17 -0
- package/src/lib/primekit.service.ts +8 -0
- package/{public-api.d.ts → src/public-api.ts} +47 -37
- package/tsconfig.lib.json +13 -0
- package/tsconfig.lib.prod.json +11 -0
- package/tsconfig.spec.json +10 -0
- package/esm2022/lib/lib/atomix-alert/atomix-alert.component.mjs +0 -76
- package/esm2022/lib/lib/atomix-autocomplete/atomix-autocomplete.component.mjs +0 -108
- package/esm2022/lib/lib/atomix-button/atomix-button.component.mjs +0 -49
- package/esm2022/lib/lib/atomix-button/atomix-button.models.mjs +0 -2
- package/esm2022/lib/lib/atomix-calendar/atomix-calendar.component.mjs +0 -90
- package/esm2022/lib/lib/atomix-card/atomix-card.component.mjs +0 -24
- package/esm2022/lib/lib/atomix-confirmation-dialog/atomix-confirmation-dialog.component.mjs +0 -28
- package/esm2022/lib/lib/atomix-daterange-calendar/atomix-daterange-calendar.component.mjs +0 -648
- package/esm2022/lib/lib/atomix-divider/atomix-divider.component.mjs +0 -27
- package/esm2022/lib/lib/atomix-dropdown/atomix-dropdown.component.mjs +0 -105
- package/esm2022/lib/lib/atomix-dynamic-dialog/atomix-dynamic-dialog.component.mjs +0 -38
- package/esm2022/lib/lib/atomix-dynamic-dialog/atomix-dynamic-dialog.models.mjs +0 -2
- package/esm2022/lib/lib/atomix-form/atomix-form-autocomplete/atomix-form-autocomplete.component.mjs +0 -67
- package/esm2022/lib/lib/atomix-form/atomix-form-calendar/atomix-form-calendar.component.mjs +0 -59
- package/esm2022/lib/lib/atomix-form/atomix-form-checkbox/atomix-form-checkbox.component.mjs +0 -48
- package/esm2022/lib/lib/atomix-form/atomix-form-chips/atomix-form-chips.component.mjs +0 -54
- package/esm2022/lib/lib/atomix-form/atomix-form-chips/form.chips.models.mjs +0 -2
- package/esm2022/lib/lib/atomix-form/atomix-form-dropdown/atomix-form-dropdown.component.mjs +0 -70
- package/esm2022/lib/lib/atomix-form/atomix-form-input-component/atomix-form-input-component.component.mjs +0 -80
- package/esm2022/lib/lib/atomix-form/atomix-form-inputmask-component/atomix-form-inputmask-component.component.mjs +0 -48
- package/esm2022/lib/lib/atomix-form/atomix-form-password-component/atomix-form-password-component.component.mjs +0 -48
- package/esm2022/lib/lib/atomix-form/atomix-form-radio-button/atomix-radio-button.component.mjs +0 -46
- package/esm2022/lib/lib/atomix-form/atomix-form-textarea/atomix-form-textarea.component.mjs +0 -46
- package/esm2022/lib/lib/atomix-input/atomix-input.component.mjs +0 -94
- package/esm2022/lib/lib/atomix-input-switch/atomix-input-switch.component.mjs +0 -85
- package/esm2022/lib/lib/atomix-messages/messages.component.mjs +0 -33
- package/esm2022/lib/lib/atomix-pagination/atomix-pagination.component.mjs +0 -48
- package/esm2022/lib/lib/atomix-radio-button/atomix-radio-button.component.mjs +0 -50
- package/esm2022/lib/lib/atomix-search-dropdown/atomix-search-dropdown.component.mjs +0 -149
- package/esm2022/lib/lib/atomix-select-button/atomix-select-button-models.mjs +0 -2
- package/esm2022/lib/lib/atomix-select-button/atomix-select-button.component.mjs +0 -25
- package/esm2022/lib/lib/atomix-snackbar/atomix-snackbar.component.mjs +0 -29
- package/esm2022/lib/lib/atomix-spinner/atomix-spinner.component.mjs +0 -24
- package/esm2022/lib/lib/atomix-steps/atomix-steps.component.mjs +0 -41
- package/esm2022/lib/lib/atomix-tabMenu/atomix-tabMenu.component.mjs +0 -51
- package/esm2022/lib/lib/atomix-table/atomix-table.component.mjs +0 -454
- package/esm2022/lib/lib/atomix-table/atomix-table.models.mjs +0 -2
- package/esm2022/lib/lib/atomix-tag/atomix-tag.component.mjs +0 -24
- package/esm2022/lib/lib/utils/prime-icons.util.mjs +0 -10
- package/esm2022/lib/primekit.component.mjs +0 -11
- package/esm2022/lib/primekit.module.mjs +0 -313
- package/esm2022/lib/primekit.service.mjs +0 -14
- package/esm2022/primekit.mjs +0 -5
- package/esm2022/public-api.mjs +0 -43
- package/fesm2022/primekit.mjs +0 -3041
- package/fesm2022/primekit.mjs.map +0 -1
- package/index.d.ts +0 -5
- package/lib/lib/atomix-alert/atomix-alert.component.d.ts +0 -22
- package/lib/lib/atomix-autocomplete/atomix-autocomplete.component.d.ts +0 -34
- package/lib/lib/atomix-button/atomix-button.component.d.ts +0 -19
- package/lib/lib/atomix-calendar/atomix-calendar.component.d.ts +0 -27
- package/lib/lib/atomix-card/atomix-card.component.d.ts +0 -9
- package/lib/lib/atomix-confirmation-dialog/atomix-confirmation-dialog.component.d.ts +0 -12
- package/lib/lib/atomix-daterange-calendar/atomix-daterange-calendar.component.d.ts +0 -72
- package/lib/lib/atomix-divider/atomix-divider.component.d.ts +0 -12
- package/lib/lib/atomix-dropdown/atomix-dropdown.component.d.ts +0 -50
- package/lib/lib/atomix-dynamic-dialog/atomix-dynamic-dialog.component.d.ts +0 -15
- package/lib/lib/atomix-dynamic-dialog/atomix-dynamic-dialog.models.d.ts +0 -11
- package/lib/lib/atomix-form/atomix-form-autocomplete/atomix-form-autocomplete.component.d.ts +0 -25
- package/lib/lib/atomix-form/atomix-form-calendar/atomix-form-calendar.component.d.ts +0 -23
- package/lib/lib/atomix-form/atomix-form-checkbox/atomix-form-checkbox.component.d.ts +0 -18
- package/lib/lib/atomix-form/atomix-form-chips/atomix-form-chips.component.d.ts +0 -19
- package/lib/lib/atomix-form/atomix-form-chips/form.chips.models.d.ts +0 -5
- package/lib/lib/atomix-form/atomix-form-dropdown/atomix-form-dropdown.component.d.ts +0 -25
- package/lib/lib/atomix-form/atomix-form-input-component/atomix-form-input-component.component.d.ts +0 -28
- package/lib/lib/atomix-form/atomix-form-inputmask-component/atomix-form-inputmask-component.component.d.ts +0 -17
- package/lib/lib/atomix-form/atomix-form-password-component/atomix-form-password-component.component.d.ts +0 -17
- package/lib/lib/atomix-form/atomix-form-radio-button/atomix-radio-button.component.d.ts +0 -19
- package/lib/lib/atomix-form/atomix-form-textarea/atomix-form-textarea.component.d.ts +0 -17
- package/lib/lib/atomix-input/atomix-input.component.d.ts +0 -29
- package/lib/lib/atomix-input-switch/atomix-input-switch.component.d.ts +0 -30
- package/lib/lib/atomix-messages/messages.component.d.ts +0 -13
- package/lib/lib/atomix-pagination/atomix-pagination.component.d.ts +0 -19
- package/lib/lib/atomix-radio-button/atomix-radio-button.component.d.ts +0 -15
- package/lib/lib/atomix-search-dropdown/atomix-search-dropdown.component.d.ts +0 -60
- package/lib/lib/atomix-select-button/atomix-select-button.component.d.ts +0 -12
- package/lib/lib/atomix-snackbar/atomix-snackbar.component.d.ts +0 -12
- package/lib/lib/atomix-spinner/atomix-spinner.component.d.ts +0 -9
- package/lib/lib/atomix-steps/atomix-steps.component.d.ts +0 -19
- package/lib/lib/atomix-tabMenu/atomix-tabMenu.component.d.ts +0 -19
- package/lib/lib/atomix-table/atomix-table.component.d.ts +0 -119
- package/lib/lib/atomix-table/atomix-table.models.d.ts +0 -43
- package/lib/lib/atomix-tag/atomix-tag.component.d.ts +0 -9
- package/lib/lib/utils/prime-icons.util.d.ts +0 -3
- package/lib/primekit.component.d.ts +0 -5
- package/lib/primekit.module.d.ts +0 -70
- package/lib/primekit.service.d.ts +0 -6
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
.lib-error-asterisk {
|
|
2
|
+
color: red;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.filter-dropdown-icon {
|
|
6
|
+
position: absolute;
|
|
7
|
+
top: 50%;
|
|
8
|
+
right: 10px;
|
|
9
|
+
transform: translateY(-50%);
|
|
10
|
+
z-index: 1;
|
|
11
|
+
cursor: pointer;
|
|
12
|
+
color: #6c757d;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.filter-dropdown-icon-left {
|
|
16
|
+
right: 40px; /* Move left to make space for search icon on right */
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.search-icon.with-label,
|
|
20
|
+
.filter-dropdown-icon.with-label {
|
|
21
|
+
top: 88%;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.search-icon {
|
|
25
|
+
position: absolute;
|
|
26
|
+
top: 50%;
|
|
27
|
+
transform: translateY(-50%);
|
|
28
|
+
z-index: 1;
|
|
29
|
+
color: var(--primary-text-color) !important;
|
|
30
|
+
font-size: 1rem;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.search-icon-left {
|
|
34
|
+
left: 10px;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.search-icon-right {
|
|
38
|
+
right: 0px;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.with-search-icon-left {
|
|
42
|
+
padding-left: 30px !important;
|
|
43
|
+
padding-right: 30px !important;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.with-search-icon-right {
|
|
47
|
+
padding-right: 60px;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
::ng-deep .lib-input-field {
|
|
51
|
+
border-radius: var(--global-border-radius);
|
|
52
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<label *ngIf="label" for="name"
|
|
2
|
+
>{{ label }}
|
|
3
|
+
<span *ngIf="isLabelRequired" class="lib-error-asterisk">*</span></label
|
|
4
|
+
>
|
|
5
|
+
|
|
6
|
+
<i
|
|
7
|
+
class="pi pi-search search-icon"
|
|
8
|
+
[ngClass]="
|
|
9
|
+
(searchIconPosition === 'left' ? 'search-icon-left' : 'search-icon-right') +
|
|
10
|
+
(label ? ' with-label' : '')
|
|
11
|
+
"
|
|
12
|
+
*ngIf="withSearchIcon"
|
|
13
|
+
(click)="onEnter()"
|
|
14
|
+
></i>
|
|
15
|
+
|
|
16
|
+
<input
|
|
17
|
+
[id]="name"
|
|
18
|
+
type="text"
|
|
19
|
+
pInputText
|
|
20
|
+
[value]="value"
|
|
21
|
+
[attr.placeholder]="placeholder"
|
|
22
|
+
(input)="onInput($event)"
|
|
23
|
+
(keydown.enter)="onEnter()"
|
|
24
|
+
[ngClass]="
|
|
25
|
+
class +
|
|
26
|
+
' lib-input-field' +
|
|
27
|
+
(withSearchIcon ? ' with-search-icon-' + searchIconPosition : '') +
|
|
28
|
+
(isCrossRequired ? ' with-cross-icon' : '')
|
|
29
|
+
"
|
|
30
|
+
autocomplete="new-password"
|
|
31
|
+
[disabled]="disabled"
|
|
32
|
+
[type]="type"
|
|
33
|
+
#inputEl
|
|
34
|
+
/>
|
|
35
|
+
<i
|
|
36
|
+
class="pi pi-times filter-dropdown-icon"
|
|
37
|
+
[ngClass]="
|
|
38
|
+
(withSearchIcon && searchIconPosition === 'right'
|
|
39
|
+
? 'filter-dropdown-icon-left'
|
|
40
|
+
: '') + (label ? ' with-label' : '')
|
|
41
|
+
"
|
|
42
|
+
style="cursor: pointer"
|
|
43
|
+
(click)="clearValue()"
|
|
44
|
+
*ngIf="isCrossRequired && value !== ''"
|
|
45
|
+
></i>
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
|
2
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
3
|
+
import { AtomixInputComponent } from './atomix-input.component';
|
|
4
|
+
|
|
5
|
+
describe('AtomixInputComponent', () => {
|
|
6
|
+
let component: AtomixInputComponent;
|
|
7
|
+
let fixture: ComponentFixture<AtomixInputComponent>;
|
|
8
|
+
|
|
9
|
+
beforeEach(() => {
|
|
10
|
+
TestBed.configureTestingModule({
|
|
11
|
+
declarations: [AtomixInputComponent],
|
|
12
|
+
schemas: [NO_ERRORS_SCHEMA],
|
|
13
|
+
});
|
|
14
|
+
fixture = TestBed.createComponent(AtomixInputComponent);
|
|
15
|
+
component = fixture.componentInstance;
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('should create', () => {
|
|
19
|
+
expect(component).toBeTruthy();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
describe('input bindings', () => {
|
|
23
|
+
it('should have default placeholder as empty string', () => {
|
|
24
|
+
expect(component.placeholder).toBe('');
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('should accept placeholder input', () => {
|
|
28
|
+
component.placeholder = 'Enter value';
|
|
29
|
+
fixture.detectChanges();
|
|
30
|
+
expect(component.placeholder).toBe('Enter value');
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('should have default type as text', () => {
|
|
34
|
+
expect(component.type).toBe('text');
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('should accept type input', () => {
|
|
38
|
+
component.type = 'password';
|
|
39
|
+
fixture.detectChanges();
|
|
40
|
+
expect(component.type).toBe('password');
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('should have default label as empty string', () => {
|
|
44
|
+
expect(component.label).toBe('');
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('should accept label input', () => {
|
|
48
|
+
component.label = 'Username';
|
|
49
|
+
fixture.detectChanges();
|
|
50
|
+
expect(component.label).toBe('Username');
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('should have default disabled as false', () => {
|
|
54
|
+
expect(component.disabled).toBe(false);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('should accept disabled input', () => {
|
|
58
|
+
component.disabled = true;
|
|
59
|
+
fixture.detectChanges();
|
|
60
|
+
expect(component.disabled).toBe(true);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('should have default value as empty string', () => {
|
|
64
|
+
expect(component.value).toBe('');
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('should accept value input', () => {
|
|
68
|
+
component.value = 'test value';
|
|
69
|
+
fixture.detectChanges();
|
|
70
|
+
expect(component.value).toBe('test value');
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it('should have default name as empty string', () => {
|
|
74
|
+
expect(component.name).toBe('');
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('should accept name input', () => {
|
|
78
|
+
component.name = 'email';
|
|
79
|
+
fixture.detectChanges();
|
|
80
|
+
expect(component.name).toBe('email');
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it('should have default withSearchIcon as false', () => {
|
|
84
|
+
expect(component.withSearchIcon).toBe(false);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it('should accept withSearchIcon input', () => {
|
|
88
|
+
component.withSearchIcon = true;
|
|
89
|
+
fixture.detectChanges();
|
|
90
|
+
expect(component.withSearchIcon).toBe(true);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it('should have default searchIconPosition as right', () => {
|
|
94
|
+
expect(component.searchIconPosition).toBe('right');
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it('should accept searchIconPosition input', () => {
|
|
98
|
+
component.searchIconPosition = 'left';
|
|
99
|
+
fixture.detectChanges();
|
|
100
|
+
expect(component.searchIconPosition).toBe('left');
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it('should have default isCrossRequired as true', () => {
|
|
104
|
+
expect(component.isCrossRequired).toBe(true);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it('should accept isCrossRequired input', () => {
|
|
108
|
+
component.isCrossRequired = false;
|
|
109
|
+
fixture.detectChanges();
|
|
110
|
+
expect(component.isCrossRequired).toBe(false);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it('should have default isLabelRequired as false', () => {
|
|
114
|
+
expect(component.isLabelRequired).toBe(false);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it('should accept isLabelRequired input', () => {
|
|
118
|
+
component.isLabelRequired = true;
|
|
119
|
+
fixture.detectChanges();
|
|
120
|
+
expect(component.isLabelRequired).toBe(true);
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
describe('value change emission', () => {
|
|
125
|
+
it('should emit changeValueHandler on input', () => {
|
|
126
|
+
const emitSpy = jest.fn();
|
|
127
|
+
component.changeValueHandler.subscribe(emitSpy);
|
|
128
|
+
|
|
129
|
+
const mockEvent = { target: { value: 'hello' } } as unknown as Event;
|
|
130
|
+
component.onInput(mockEvent);
|
|
131
|
+
|
|
132
|
+
expect(emitSpy).toHaveBeenCalledWith('hello');
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
it('should update value property on input', () => {
|
|
136
|
+
const mockEvent = { target: { value: 'world' } } as unknown as Event;
|
|
137
|
+
component.onInput(mockEvent);
|
|
138
|
+
|
|
139
|
+
expect(component.value).toBe('world');
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
it('should emit valueChange on enter', () => {
|
|
143
|
+
const emitSpy = jest.fn();
|
|
144
|
+
component.valueChange.subscribe(emitSpy);
|
|
145
|
+
|
|
146
|
+
component.value = 'search term';
|
|
147
|
+
component.onEnter();
|
|
148
|
+
|
|
149
|
+
expect(emitSpy).toHaveBeenCalledWith('search term');
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
it('should clear value and emit on clearValue', () => {
|
|
153
|
+
const changeEmitSpy = jest.fn();
|
|
154
|
+
const valueChangeEmitSpy = jest.fn();
|
|
155
|
+
component.changeValueHandler.subscribe(changeEmitSpy);
|
|
156
|
+
component.valueChange.subscribe(valueChangeEmitSpy);
|
|
157
|
+
|
|
158
|
+
component.value = 'some text';
|
|
159
|
+
component.clearValue();
|
|
160
|
+
|
|
161
|
+
expect(component.value).toBe('');
|
|
162
|
+
expect(changeEmitSpy).toHaveBeenCalledWith('');
|
|
163
|
+
expect(valueChangeEmitSpy).toHaveBeenCalledWith('');
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
it('should emit valueChange with empty string when search is cleared', () => {
|
|
167
|
+
const emitSpy = jest.fn();
|
|
168
|
+
component.valueChange.subscribe(emitSpy);
|
|
169
|
+
|
|
170
|
+
component.value = 'existing';
|
|
171
|
+
const mockEvent = { target: { value: '' } } as unknown as Event;
|
|
172
|
+
component.onSearchClear(mockEvent);
|
|
173
|
+
|
|
174
|
+
expect(component.value).toBe('');
|
|
175
|
+
expect(emitSpy).toHaveBeenCalledWith('');
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
it('should not emit valueChange when search input is not empty', () => {
|
|
179
|
+
const emitSpy = jest.fn();
|
|
180
|
+
component.valueChange.subscribe(emitSpy);
|
|
181
|
+
|
|
182
|
+
component.value = 'existing';
|
|
183
|
+
const mockEvent = { target: { value: 'still typing' } } as unknown as Event;
|
|
184
|
+
component.onSearchClear(mockEvent);
|
|
185
|
+
|
|
186
|
+
expect(component.value).toBe('existing');
|
|
187
|
+
expect(emitSpy).not.toHaveBeenCalled();
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
describe('ngAfterViewInit', () => {
|
|
192
|
+
it('should call focus on inputEl when autofocus is true', () => {
|
|
193
|
+
jest.useFakeTimers();
|
|
194
|
+
component.autofocus = true;
|
|
195
|
+
component.inputEl = { nativeElement: { focus: jest.fn() } } as any;
|
|
196
|
+
|
|
197
|
+
component.ngAfterViewInit();
|
|
198
|
+
jest.runAllTimers();
|
|
199
|
+
|
|
200
|
+
expect(component.inputEl.nativeElement.focus).toHaveBeenCalled();
|
|
201
|
+
jest.useRealTimers();
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
it('should not call focus when autofocus is false', () => {
|
|
205
|
+
jest.useFakeTimers();
|
|
206
|
+
component.autofocus = false;
|
|
207
|
+
component.inputEl = { nativeElement: { focus: jest.fn() } } as any;
|
|
208
|
+
|
|
209
|
+
component.ngAfterViewInit();
|
|
210
|
+
jest.runAllTimers();
|
|
211
|
+
|
|
212
|
+
expect(component.inputEl.nativeElement.focus).not.toHaveBeenCalled();
|
|
213
|
+
jest.useRealTimers();
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
describe('focus', () => {
|
|
218
|
+
it('should call focus on the native input element', () => {
|
|
219
|
+
component.inputEl = { nativeElement: { focus: jest.fn() } } as any;
|
|
220
|
+
component.focus();
|
|
221
|
+
expect(component.inputEl.nativeElement.focus).toHaveBeenCalled();
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
it('should handle undefined inputEl gracefully', () => {
|
|
225
|
+
component.inputEl = undefined as any;
|
|
226
|
+
expect(() => component.focus()).not.toThrow();
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
});
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Component,
|
|
3
|
+
Input,
|
|
4
|
+
Output,
|
|
5
|
+
EventEmitter,
|
|
6
|
+
ElementRef,
|
|
7
|
+
ViewChild,
|
|
8
|
+
} from '@angular/core';
|
|
9
|
+
|
|
10
|
+
@Component({
|
|
11
|
+
selector: 'atomix-input',
|
|
12
|
+
templateUrl: './atomix-input.component.html',
|
|
13
|
+
styleUrls: ['./atomix-input.component.css'],
|
|
14
|
+
})
|
|
15
|
+
export class AtomixInputComponent {
|
|
16
|
+
@ViewChild('inputEl') inputEl!: ElementRef<HTMLInputElement>;
|
|
17
|
+
@Input() value: string = '';
|
|
18
|
+
@Input() name: string = '';
|
|
19
|
+
@Input() type: string = 'text';
|
|
20
|
+
@Input() placeholder: string = '';
|
|
21
|
+
@Output() valueChange = new EventEmitter<string>();
|
|
22
|
+
@Input() withSearchIcon: boolean = false;
|
|
23
|
+
@Input() searchIconPosition: 'left' | 'right' = 'right';
|
|
24
|
+
@Input() iconName: string = '';
|
|
25
|
+
@Input() containerClass: string = '';
|
|
26
|
+
@Input() class: string = '';
|
|
27
|
+
@Input() disabled: boolean = false;
|
|
28
|
+
@Input() isCrossRequired: boolean = true;
|
|
29
|
+
@Input() label: string = '';
|
|
30
|
+
@Input() isLabelRequired: boolean = false;
|
|
31
|
+
@Input() autofocus: boolean = false;
|
|
32
|
+
@Output() changeValueHandler = new EventEmitter<string>();
|
|
33
|
+
|
|
34
|
+
ngAfterViewInit(): void {
|
|
35
|
+
if (this.autofocus) {
|
|
36
|
+
// Timeout ensures input is available in the DOM
|
|
37
|
+
setTimeout(() => this.inputEl?.nativeElement?.focus());
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
onInput(event: Event): void {
|
|
42
|
+
const input = event.target as HTMLInputElement;
|
|
43
|
+
this.value = input.value;
|
|
44
|
+
this.changeValueHandler.emit(this.value);
|
|
45
|
+
}
|
|
46
|
+
onEnter(): void {
|
|
47
|
+
this.valueChange.emit(this.value);
|
|
48
|
+
}
|
|
49
|
+
clearValue(): void {
|
|
50
|
+
this.value = '';
|
|
51
|
+
this.changeValueHandler.emit(this.value);
|
|
52
|
+
this.onEnter();
|
|
53
|
+
}
|
|
54
|
+
onSearchClear(event: Event) {
|
|
55
|
+
const input = event.target as HTMLInputElement;
|
|
56
|
+
if (input.value === '') {
|
|
57
|
+
this.value = '';
|
|
58
|
+
this.valueChange.emit('');
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
focus(): void {
|
|
62
|
+
this.inputEl?.nativeElement?.focus();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<p-inputSwitch
|
|
2
|
+
[(ngModel)]="value"
|
|
3
|
+
[trueValue]="trueValue"
|
|
4
|
+
[falseValue]="falseValue"
|
|
5
|
+
[style]="style"
|
|
6
|
+
[styleClass]="styleClass"
|
|
7
|
+
[tabindex]="tabindex"
|
|
8
|
+
[inputId]="inputId"
|
|
9
|
+
[attr.name]="name"
|
|
10
|
+
[disabled]="disabled"
|
|
11
|
+
[readonly]="readonly"
|
|
12
|
+
[ariaLabel]="ariaLabel"
|
|
13
|
+
[ariaLabelledBy]="ariaLabelledBy"
|
|
14
|
+
[autofocus]="autofocus"
|
|
15
|
+
(onChange)="handleChange($event)"
|
|
16
|
+
(onBlur)="onTouched()"
|
|
17
|
+
></p-inputSwitch>
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
|
2
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
3
|
+
import { AtomixInputSwitchComponent } from './atomix-input-switch.component';
|
|
4
|
+
|
|
5
|
+
describe('AtomixInputSwitchComponent', () => {
|
|
6
|
+
let component: AtomixInputSwitchComponent;
|
|
7
|
+
let fixture: ComponentFixture<AtomixInputSwitchComponent>;
|
|
8
|
+
|
|
9
|
+
beforeEach(() => {
|
|
10
|
+
TestBed.configureTestingModule({
|
|
11
|
+
declarations: [AtomixInputSwitchComponent],
|
|
12
|
+
schemas: [NO_ERRORS_SCHEMA],
|
|
13
|
+
});
|
|
14
|
+
fixture = TestBed.createComponent(AtomixInputSwitchComponent);
|
|
15
|
+
component = fixture.componentInstance;
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('should create', () => {
|
|
19
|
+
expect(component).toBeTruthy();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
describe('input bindings', () => {
|
|
23
|
+
it('should have default disabled as false', () => {
|
|
24
|
+
expect(component.disabled).toBe(false);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('should accept disabled input', () => {
|
|
28
|
+
component.disabled = true;
|
|
29
|
+
expect(component.disabled).toBe(true);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('should have default readonly as false', () => {
|
|
33
|
+
expect(component.readonly).toBe(false);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('should accept readonly input', () => {
|
|
37
|
+
component.readonly = true;
|
|
38
|
+
expect(component.readonly).toBe(true);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('should have default trueValue as true', () => {
|
|
42
|
+
expect(component.trueValue).toBe(true);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('should accept custom trueValue', () => {
|
|
46
|
+
component.trueValue = 'yes';
|
|
47
|
+
expect(component.trueValue).toBe('yes');
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('should have default falseValue as false', () => {
|
|
51
|
+
expect(component.falseValue).toBe(false);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('should accept custom falseValue', () => {
|
|
55
|
+
component.falseValue = 'no';
|
|
56
|
+
expect(component.falseValue).toBe('no');
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('should have default value as false', () => {
|
|
60
|
+
expect(component.value).toBe(false);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('should have default autofocus as false', () => {
|
|
64
|
+
expect(component.autofocus).toBe(false);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('should accept style input', () => {
|
|
68
|
+
component.style = { width: '100px' };
|
|
69
|
+
expect(component.style).toEqual({ width: '100px' });
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it('should accept styleClass input', () => {
|
|
73
|
+
component.styleClass = 'custom-class';
|
|
74
|
+
expect(component.styleClass).toBe('custom-class');
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('should accept inputId input', () => {
|
|
78
|
+
component.inputId = 'my-switch';
|
|
79
|
+
expect(component.inputId).toBe('my-switch');
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('should accept name input', () => {
|
|
83
|
+
component.name = 'toggle';
|
|
84
|
+
expect(component.name).toBe('toggle');
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
describe('toggle value emission', () => {
|
|
89
|
+
it('should set value to trueValue when toggled on', () => {
|
|
90
|
+
component.handleChange({ checked: true } as any);
|
|
91
|
+
expect(component.value).toBe(true);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it('should set value to falseValue when toggled off', () => {
|
|
95
|
+
component.value = true;
|
|
96
|
+
component.handleChange({ checked: false } as any);
|
|
97
|
+
expect(component.value).toBe(false);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it('should call onChange with the new value when toggled', () => {
|
|
101
|
+
const onChangeSpy = jest.fn();
|
|
102
|
+
component.registerOnChange(onChangeSpy);
|
|
103
|
+
|
|
104
|
+
component.handleChange({ checked: true } as any);
|
|
105
|
+
|
|
106
|
+
expect(onChangeSpy).toHaveBeenCalledWith(true);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it('should call onTouched when toggled', () => {
|
|
110
|
+
const onTouchedSpy = jest.fn();
|
|
111
|
+
component.registerOnTouched(onTouchedSpy);
|
|
112
|
+
|
|
113
|
+
component.handleChange({ checked: true } as any);
|
|
114
|
+
|
|
115
|
+
expect(onTouchedSpy).toHaveBeenCalled();
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it('should use custom trueValue/falseValue when toggled', () => {
|
|
119
|
+
const onChangeSpy = jest.fn();
|
|
120
|
+
component.registerOnChange(onChangeSpy);
|
|
121
|
+
component.trueValue = 'active';
|
|
122
|
+
component.falseValue = 'inactive';
|
|
123
|
+
|
|
124
|
+
component.handleChange({ checked: true } as any);
|
|
125
|
+
expect(component.value).toBe('active');
|
|
126
|
+
expect(onChangeSpy).toHaveBeenCalledWith('active');
|
|
127
|
+
|
|
128
|
+
component.handleChange({ checked: false } as any);
|
|
129
|
+
expect(component.value).toBe('inactive');
|
|
130
|
+
expect(onChangeSpy).toHaveBeenCalledWith('inactive');
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
describe('ControlValueAccessor', () => {
|
|
135
|
+
it('should write value via writeValue', () => {
|
|
136
|
+
component.writeValue(true);
|
|
137
|
+
expect(component.value).toBe(true);
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
it('should set falseValue when writeValue receives null', () => {
|
|
141
|
+
component.falseValue = 'off';
|
|
142
|
+
component.writeValue(null);
|
|
143
|
+
expect(component.value).toBe('off');
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
it('should set falseValue when writeValue receives undefined', () => {
|
|
147
|
+
component.writeValue(undefined);
|
|
148
|
+
expect(component.value).toBe(false);
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
it('should set disabled state via setDisabledState', () => {
|
|
152
|
+
component.setDisabledState(true);
|
|
153
|
+
expect(component.disabled).toBe(true);
|
|
154
|
+
|
|
155
|
+
component.setDisabledState(false);
|
|
156
|
+
expect(component.disabled).toBe(false);
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
it('should register onChange function', () => {
|
|
160
|
+
const fn = jest.fn();
|
|
161
|
+
component.registerOnChange(fn);
|
|
162
|
+
component.onChange('test');
|
|
163
|
+
expect(fn).toHaveBeenCalledWith('test');
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
it('should register onTouched function', () => {
|
|
167
|
+
const fn = jest.fn();
|
|
168
|
+
component.registerOnTouched(fn);
|
|
169
|
+
component.onTouched();
|
|
170
|
+
expect(fn).toHaveBeenCalled();
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
});
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Component, Input, forwardRef } from '@angular/core';
|
|
2
|
+
import {
|
|
3
|
+
ControlValueAccessor,
|
|
4
|
+
NG_VALUE_ACCESSOR,
|
|
5
|
+
FormControl,
|
|
6
|
+
} from '@angular/forms';
|
|
7
|
+
import { InputSwitchChangeEvent } from 'primeng/inputswitch';
|
|
8
|
+
|
|
9
|
+
@Component({
|
|
10
|
+
selector: 'atomix-inputSwitch',
|
|
11
|
+
templateUrl: './atomix-input-switch.component.html',
|
|
12
|
+
styleUrls: ['./atomix-input-switch.component.css'],
|
|
13
|
+
providers: [
|
|
14
|
+
{
|
|
15
|
+
provide: NG_VALUE_ACCESSOR,
|
|
16
|
+
useExisting: forwardRef(() => AtomixInputSwitchComponent),
|
|
17
|
+
multi: true,
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
})
|
|
21
|
+
export class AtomixInputSwitchComponent implements ControlValueAccessor {
|
|
22
|
+
@Input() style?: { [key: string]: any };
|
|
23
|
+
@Input() styleClass?: string;
|
|
24
|
+
@Input() tabindex?: number;
|
|
25
|
+
@Input() inputId?: string;
|
|
26
|
+
@Input() name?: string;
|
|
27
|
+
@Input() disabled = false;
|
|
28
|
+
@Input() readonly = false;
|
|
29
|
+
@Input() trueValue: any = true;
|
|
30
|
+
@Input() falseValue: any = false;
|
|
31
|
+
@Input() ariaLabel?: string;
|
|
32
|
+
@Input() ariaLabelledBy?: string;
|
|
33
|
+
@Input() autofocus = false;
|
|
34
|
+
@Input() formControl?: FormControl;
|
|
35
|
+
|
|
36
|
+
value: any = false;
|
|
37
|
+
|
|
38
|
+
onChange = (_: any) => {};
|
|
39
|
+
onTouched = () => {};
|
|
40
|
+
|
|
41
|
+
writeValue(value: any): void {
|
|
42
|
+
this.value = value ?? this.falseValue;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
registerOnChange(fn: any): void {
|
|
46
|
+
this.onChange = fn;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
registerOnTouched(fn: any): void {
|
|
50
|
+
this.onTouched = fn;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
setDisabledState(disabled: boolean): void {
|
|
54
|
+
this.disabled = disabled;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
handleChange(event: InputSwitchChangeEvent) {
|
|
58
|
+
this.value = event.checked ? this.trueValue : this.falseValue;
|
|
59
|
+
this.onChange(this.value);
|
|
60
|
+
this.onTouched();
|
|
61
|
+
}
|
|
62
|
+
}
|