@tacdaed/fragments 1.0.0-beta.0 → 1.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/ng-package.json +25 -0
- package/package.json +22 -29
- package/src/lib/components/accordion/accordion.component.html +103 -0
- package/src/lib/components/accordion/accordion.component.scss +382 -0
- package/src/lib/components/accordion/accordion.component.spec.ts +147 -0
- package/src/lib/components/accordion/accordion.component.ts +211 -0
- package/src/lib/components/accordion/accordion.type.ts +82 -0
- package/src/lib/components/breadcrumb/breadcrumb.component.html +43 -0
- package/src/lib/components/breadcrumb/breadcrumb.component.scss +112 -0
- package/src/lib/components/breadcrumb/breadcrumb.component.spec.ts +33 -0
- package/src/lib/components/breadcrumb/breadcrumb.component.ts +103 -0
- package/src/lib/components/breadcrumb/breadcrumb.interface.ts +7 -0
- package/src/lib/components/button/button.component.html +57 -0
- package/src/lib/components/button/button.component.scss +445 -0
- package/src/lib/components/button/button.component.spec.ts +99 -0
- package/src/lib/components/button/button.component.ts +143 -0
- package/src/lib/components/button/button.type.ts +7 -0
- package/src/lib/components/card/card.component.html +44 -0
- package/src/lib/components/card/card.component.scss +114 -0
- package/src/lib/components/card/card.component.spec.ts +65 -0
- package/src/lib/components/card/card.component.ts +21 -0
- package/src/lib/components/card/card.type.ts +3 -0
- package/src/lib/components/code-block/code-block.component.html +55 -0
- package/src/lib/components/code-block/code-block.component.scss +122 -0
- package/src/lib/components/code-block/code-block.component.spec.ts +81 -0
- package/src/lib/components/code-block/code-block.component.ts +302 -0
- package/src/lib/components/code-block/code-block.interface.ts +28 -0
- package/src/lib/components/code-block/code-block.type.ts +73 -0
- package/src/lib/components/decorative/sparkle-field/sparkle-field.component.html +14 -0
- package/src/lib/components/decorative/sparkle-field/sparkle-field.component.scss +20 -0
- package/src/lib/components/decorative/sparkle-field/sparkle-field.component.spec.ts +38 -0
- package/src/lib/components/decorative/sparkle-field/sparkle-field.component.ts +181 -0
- package/src/lib/components/input/input-base.ts +187 -0
- package/src/lib/components/input/input-calendar/input-calendar.component.html +76 -0
- package/src/lib/components/input/input-calendar/input-calendar.component.scss +179 -0
- package/src/lib/components/input/input-calendar/input-calendar.component.spec.ts +44 -0
- package/src/lib/components/input/input-calendar/input-calendar.component.ts +299 -0
- package/src/lib/components/input/input-checkbox/input-checkbox.component.html +37 -0
- package/src/lib/components/input/input-checkbox/input-checkbox.component.scss +128 -0
- package/src/lib/components/input/input-checkbox/input-checkbox.component.spec.ts +43 -0
- package/src/lib/components/input/input-checkbox/input-checkbox.component.ts +112 -0
- package/src/lib/components/input/input-checkbox-group/input-checkbox-group.component.html +43 -0
- package/src/lib/components/input/input-checkbox-group/input-checkbox-group.component.scss +140 -0
- package/src/lib/components/input/input-checkbox-group/input-checkbox-group.component.spec.ts +62 -0
- package/src/lib/components/input/input-checkbox-group/input-checkbox-group.component.ts +136 -0
- package/src/lib/components/input/input-clock-picker/input-clock-picker.component.html +81 -0
- package/src/lib/components/input/input-clock-picker/input-clock-picker.component.scss +228 -0
- package/src/lib/components/input/input-clock-picker/input-clock-picker.component.spec.ts +62 -0
- package/src/lib/components/input/input-clock-picker/input-clock-picker.component.ts +178 -0
- package/src/lib/components/input/input-consts.ts +132 -0
- package/src/lib/components/input/input-date/input-date-validators.ts +41 -0
- package/src/lib/components/input/input-date/input-date.component.html +41 -0
- package/src/lib/components/input/input-date/input-date.component.scss +95 -0
- package/src/lib/components/input/input-date/input-date.component.spec.ts +43 -0
- package/src/lib/components/input/input-date/input-date.component.ts +359 -0
- package/src/lib/components/input/input-date-time/input-date-time.component.html +70 -0
- package/src/lib/components/input/input-date-time/input-date-time.component.scss +133 -0
- package/src/lib/components/input/input-date-time/input-date-time.component.spec.ts +36 -0
- package/src/lib/components/input/input-date-time/input-date-time.component.ts +387 -0
- package/src/lib/components/input/input-file-upload/input-file-upload.component.html +89 -0
- package/src/lib/components/input/input-file-upload/input-file-upload.component.scss +171 -0
- package/src/lib/components/input/input-file-upload/input-file-upload.component.spec.ts +43 -0
- package/src/lib/components/input/input-file-upload/input-file-upload.component.ts +351 -0
- package/src/lib/components/input/input-interface.ts +8 -0
- package/src/lib/components/input/input-number/input-number-validators.ts +0 -0
- package/src/lib/components/input/input-number/input-number.component.html +51 -0
- package/src/lib/components/input/input-number/input-number.component.scss +140 -0
- package/src/lib/components/input/input-number/input-number.component.spec.ts +44 -0
- package/src/lib/components/input/input-number/input-number.component.ts +343 -0
- package/src/lib/components/input/input-radio-group/input-radio-group.component.html +44 -0
- package/src/lib/components/input/input-radio-group/input-radio-group.component.scss +139 -0
- package/src/lib/components/input/input-radio-group/input-radio-group.component.spec.ts +58 -0
- package/src/lib/components/input/input-radio-group/input-radio-group.component.ts +132 -0
- package/src/lib/components/input/input-slider/input-slider.component.html +111 -0
- package/src/lib/components/input/input-slider/input-slider.component.scss +203 -0
- package/src/lib/components/input/input-slider/input-slider.component.spec.ts +46 -0
- package/src/lib/components/input/input-slider/input-slider.component.ts +410 -0
- package/src/lib/components/input/input-text/input-text-validators.ts +67 -0
- package/src/lib/components/input/input-text/input-text.component.html +71 -0
- package/src/lib/components/input/input-text/input-text.component.scss +118 -0
- package/src/lib/components/input/input-text/input-text.component.spec.ts +55 -0
- package/src/lib/components/input/input-text/input-text.component.ts +215 -0
- package/src/lib/components/input/input-time/input-time-validators.ts +42 -0
- package/src/lib/components/input/input-time/input-time.component.html +92 -0
- package/src/lib/components/input/input-time/input-time.component.scss +191 -0
- package/src/lib/components/input/input-time/input-time.component.spec.ts +39 -0
- package/src/lib/components/input/input-time/input-time.component.ts +691 -0
- package/src/lib/components/input/input-toggle-switch/input-toggle-switch.component.html +36 -0
- package/src/lib/components/input/input-toggle-switch/input-toggle-switch.component.scss +121 -0
- package/src/lib/components/input/input-toggle-switch/input-toggle-switch.component.spec.ts +54 -0
- package/src/lib/components/input/input-toggle-switch/input-toggle-switch.component.ts +117 -0
- package/src/lib/components/input/input-type.ts +18 -0
- package/src/lib/components/input/input-validation/input-validation.component.html +19 -0
- package/src/lib/components/input/input-validation/input-validation.component.scss +39 -0
- package/src/lib/components/input/input-validation/input-validation.component.spec.ts +45 -0
- package/src/lib/components/input/input-validation/input-validation.component.ts +13 -0
- package/src/lib/components/input/input.pipe.ts +14 -0
- package/src/lib/components/layout/container/container.component.html +1 -0
- package/src/lib/components/layout/container/container.component.scss +33 -0
- package/src/lib/components/layout/container/container.component.ts +32 -0
- package/src/lib/components/layout/container/container.type.ts +1 -0
- package/src/lib/components/layout/divider/divider.component.html +1 -0
- package/src/lib/components/layout/divider/divider.component.scss +60 -0
- package/src/lib/components/layout/divider/divider.component.ts +38 -0
- package/src/lib/components/layout/divider/divider.type.ts +2 -0
- package/src/lib/components/layout/section/section.component.html +21 -0
- package/src/lib/components/layout/section/section.component.scss +43 -0
- package/src/lib/components/layout/section/section.component.ts +33 -0
- package/src/lib/components/layout/section/section.type.ts +2 -0
- package/src/lib/components/layout/separator/separator.component.html +9 -0
- package/src/lib/components/layout/separator/separator.component.scss +52 -0
- package/src/lib/components/layout/separator/separator.component.ts +25 -0
- package/src/lib/components/layout/separator/separator.type.ts +1 -0
- package/src/lib/components/loader/content-blur/content-blur.component.html +13 -0
- package/src/lib/components/loader/content-blur/content-blur.component.scss +43 -0
- package/src/lib/components/loader/content-blur/content-blur.component.spec.ts +42 -0
- package/src/lib/components/loader/content-blur/content-blur.component.ts +34 -0
- package/src/lib/components/loader/loader.type.ts +2 -0
- package/src/lib/components/loader/progress-bar/progress-bar.component.html +26 -0
- package/src/lib/components/loader/progress-bar/progress-bar.component.scss +151 -0
- package/src/lib/components/loader/progress-bar/progress-bar.component.spec.ts +47 -0
- package/src/lib/components/loader/progress-bar/progress-bar.component.ts +28 -0
- package/src/lib/components/loader/progress-bar/progress-bar.type.ts +8 -0
- package/src/lib/components/loader/pulse-loader/pulse-loader.component.html +12 -0
- package/src/lib/components/loader/pulse-loader/pulse-loader.component.scss +202 -0
- package/src/lib/components/loader/pulse-loader/pulse-loader.component.spec.ts +55 -0
- package/src/lib/components/loader/pulse-loader/pulse-loader.component.ts +73 -0
- package/src/lib/components/loader/pulse-loader/pulse-loader.type.ts +6 -0
- package/src/lib/components/loader/skeleton-loader/skeleton-loader.component.html +13 -0
- package/src/lib/components/loader/skeleton-loader/skeleton-loader.component.scss +113 -0
- package/src/lib/components/loader/skeleton-loader/skeleton-loader.component.spec.ts +37 -0
- package/src/lib/components/loader/skeleton-loader/skeleton-loader.component.ts +51 -0
- package/src/lib/components/loader/skeleton-loader/skeleton-loader.type.ts +6 -0
- package/src/lib/components/loader/spinner/spinner.component.html +20 -0
- package/src/lib/components/loader/spinner/spinner.component.scss +137 -0
- package/src/lib/components/loader/spinner/spinner.component.spec.ts +43 -0
- package/src/lib/components/loader/spinner/spinner.component.ts +32 -0
- package/src/lib/components/loader/spinner/spinner.type.ts +6 -0
- package/src/lib/components/modal/modal.component.html +47 -0
- package/src/lib/components/modal/modal.component.scss +139 -0
- package/src/lib/components/modal/modal.component.spec.ts +60 -0
- package/src/lib/components/modal/modal.component.ts +83 -0
- package/src/lib/components/modal/modal.type.ts +9 -0
- package/src/lib/components/morph/blob-moph/blob-moprh.component.spec.ts +79 -0
- package/src/lib/components/morph/blob-moph/blob-moprh.component.ts +96 -0
- package/src/lib/components/morph/blob-moph/blob-morph.component.html +34 -0
- package/src/lib/components/morph/blob-moph/blob-morph.component.scss +7 -0
- package/src/lib/components/morph/morph.abstract.ts +13 -0
- package/src/lib/components/pagination/pagination.interface.ts +4 -0
- package/src/lib/components/pagination/small-pagination/small-pagination.component.html +61 -0
- package/src/lib/components/pagination/small-pagination/small-pagination.component.scss +187 -0
- package/src/lib/components/pagination/small-pagination/small-pagination.component.spec.ts +88 -0
- package/src/lib/components/pagination/small-pagination/small-pagination.component.ts +177 -0
- package/src/lib/components/selection-lists/multi-select/multi-select.component.html +170 -0
- package/src/lib/components/selection-lists/multi-select/multi-select.component.scss +312 -0
- package/src/lib/components/selection-lists/multi-select/multi-select.component.spec.ts +61 -0
- package/src/lib/components/selection-lists/multi-select/multi-select.component.ts +372 -0
- package/src/lib/components/selection-lists/selection-list/selection-list.component.html +125 -0
- package/src/lib/components/selection-lists/selection-list/selection-list.component.scss +267 -0
- package/src/lib/components/selection-lists/selection-list/selection-list.component.spec.ts +66 -0
- package/src/lib/components/selection-lists/selection-list/selection-list.component.ts +315 -0
- package/src/lib/components/selection-lists/selection-lists-base.ts +35 -0
- package/src/lib/components/selection-lists/selection-lists-const.ts +17 -0
- package/src/lib/components/selection-lists/selection-lists-interface.ts +7 -0
- package/src/lib/components/selection-lists/selection-lists.type.ts +1 -0
- package/src/lib/components/side-nav/side-nav.component.html +101 -0
- package/src/lib/components/side-nav/side-nav.component.scss +295 -0
- package/src/lib/components/side-nav/side-nav.component.spec.ts +0 -0
- package/src/lib/components/side-nav/side-nav.component.ts +18 -0
- package/src/lib/components/side-nav/side-nav.type.ts +28 -0
- package/src/lib/components/snackbar/snackbar.component.html +33 -0
- package/src/lib/components/snackbar/snackbar.component.scss +195 -0
- package/src/lib/components/snackbar/snackbar.component.ts +112 -0
- package/src/lib/components/snackbar/snackbar.type.ts +27 -0
- package/src/lib/components/status/chip/chip.component.html +51 -0
- package/src/lib/components/status/chip/chip.component.scss +149 -0
- package/src/lib/components/status/chip/chip.component.spec.ts +62 -0
- package/src/lib/components/status/chip/chip.component.ts +83 -0
- package/src/lib/components/status/chip/chip.type.ts +42 -0
- package/src/lib/components/status/directives/badge/badge.directive.spec.ts +60 -0
- package/src/lib/components/status/directives/badge/badge.directive.ts +190 -0
- package/src/lib/components/status/directives/badge/badge.interface.ts +19 -0
- package/src/lib/components/status/pill/pill.component.html +40 -0
- package/src/lib/components/status/pill/pill.component.scss +113 -0
- package/src/lib/components/status/pill/pill.component.spec.ts +47 -0
- package/src/lib/components/status/pill/pill.component.ts +83 -0
- package/src/lib/components/status/pill/pill.type.ts +42 -0
- package/src/lib/components/status/status.interface.ts +57 -0
- package/src/lib/components/status/status.type.ts +62 -0
- package/src/lib/components/status/tag/tag.component.html +39 -0
- package/src/lib/components/status/tag/tag.component.scss +140 -0
- package/src/lib/components/status/tag/tag.component.spec.ts +47 -0
- package/src/lib/components/status/tag/tag.component.ts +83 -0
- package/src/lib/components/status/tag/tag.type.ts +42 -0
- package/src/lib/components/stepper/stepper.component.html +83 -0
- package/src/lib/components/stepper/stepper.component.scss +196 -0
- package/src/lib/components/stepper/stepper.component.ts +482 -0
- package/src/lib/components/stepper/stepper.type.ts +60 -0
- package/src/lib/components/table/table.component.html +438 -0
- package/src/lib/components/table/table.component.scss +259 -0
- package/src/lib/components/table/table.component.spec.ts +117 -0
- package/src/lib/components/table/table.component.ts +215 -0
- package/src/lib/components/table/table.enum.ts +4 -0
- package/src/lib/components/table/table.function.ts +47 -0
- package/src/lib/components/table/table.interface.ts +143 -0
- package/src/lib/components/table/table.pipe.ts +62 -0
- package/src/lib/components/table/table.type.ts +15 -0
- package/src/lib/components/tabs/tabs.component.html +88 -0
- package/src/lib/components/tabs/tabs.component.scss +305 -0
- package/src/lib/components/tabs/tabs.component.spec.ts +94 -0
- package/src/lib/components/tabs/tabs.component.ts +282 -0
- package/src/lib/components/tabs/tabs.type.ts +81 -0
- package/src/lib/components/title-bar/title-bar.component.html +21 -0
- package/src/lib/components/title-bar/title-bar.component.scss +139 -0
- package/src/lib/components/title-bar/title-bar.component.spec.ts +44 -0
- package/src/lib/components/title-bar/title-bar.component.ts +13 -0
- package/src/lib/components/toast/toast.component.html +36 -0
- package/src/lib/components/toast/toast.component.scss +241 -0
- package/src/lib/components/toast/toast.component.ts +165 -0
- package/src/lib/components/toast/toast.type.ts +37 -0
- package/src/lib/components/toast-stack/toast-stack.component.html +30 -0
- package/src/lib/components/toast-stack/toast-stack.component.scss +35 -0
- package/src/lib/components/toast-stack/toast-stack.component.ts +51 -0
- package/src/lib/consts/country-prefix.ts +244 -0
- package/src/lib/directives/tooltip/popover.directive.ts +274 -0
- package/src/lib/directives/tooltip/tooltip.directive.spec.ts +86 -0
- package/src/lib/directives/tooltip/tooltip.directive.ts +234 -0
- package/src/lib/directives/tooltip/tooltip.interface.ts +29 -0
- package/src/lib/directives/tooltip/tooltip.type.ts +9 -0
- package/src/lib/interfaces/common.interfaces.ts +4 -0
- package/src/lib/pipes/chunk.pipe.ts +16 -0
- package/src/lib/pipes/safe-html.pipe.ts +14 -0
- package/src/lib/pipes/sanitize-html.pipe.ts +23 -0
- package/src/lib/types/base.types.ts +23 -0
- package/src/lib/types/common.types.ts +98 -0
- package/src/lib/types/form.types.ts +5 -0
- package/src/lib/utils/common.utils.ts +53 -0
- package/src/lib/utils/date.utils.ts +474 -0
- package/src/lib/utils/number.utils.ts +16 -0
- package/src/lib/utils/uuid.utils.ts +39 -0
- package/src/public-api.ts +114 -0
- package/tsconfig.lib.json +17 -0
- package/tsconfig.lib.prod.json +10 -0
- package/tsconfig.spec.json +9 -0
- package/fesm2022/fragments.mjs +0 -8928
- package/fesm2022/fragments.mjs.map +0 -1
- package/index.d.ts +0 -3929
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
<div class="frg-multi-select" [class.multi-select-error]="hasError">
|
|
2
|
+
<label [attr.for]="id + '-options'">{{ label }}</label>
|
|
3
|
+
|
|
4
|
+
@if(hasSearch) {
|
|
5
|
+
<div class="options-search">
|
|
6
|
+
<input
|
|
7
|
+
#searchInput
|
|
8
|
+
type="text"
|
|
9
|
+
[attr.name]="id + '-options'"
|
|
10
|
+
[attr.id]="id + '-options'"
|
|
11
|
+
class="options-search__input"
|
|
12
|
+
[class.open]="isOpen"
|
|
13
|
+
[attr.placeholder]="'Search…'"
|
|
14
|
+
aria-label="Search options"
|
|
15
|
+
role="searchbox"
|
|
16
|
+
[value]="searchTerm"
|
|
17
|
+
(input)="onSearch($event)"
|
|
18
|
+
(blur)="onBlur($event)"
|
|
19
|
+
(focus)="onFocus()"
|
|
20
|
+
(keydown)="onSearchKeyDown($event)"
|
|
21
|
+
/>
|
|
22
|
+
<ng-container [ngTemplateOutlet]="buttonsTemplate"></ng-container>
|
|
23
|
+
</div>
|
|
24
|
+
|
|
25
|
+
@if(showChips && selectedItems.length) {
|
|
26
|
+
<div class="selected-chips selected-chips--below">
|
|
27
|
+
@for(item of selectedItems; track item.id) {
|
|
28
|
+
<frg-chip
|
|
29
|
+
[id]="item.id"
|
|
30
|
+
[label]="item.label || ''"
|
|
31
|
+
size="sm"
|
|
32
|
+
[style]="chipsStyle"
|
|
33
|
+
[removable]="true"
|
|
34
|
+
[disabled]="disabled"
|
|
35
|
+
(removed)="removeItemById($event)"
|
|
36
|
+
></frg-chip>
|
|
37
|
+
}
|
|
38
|
+
</div>
|
|
39
|
+
} @else if(selectedItems.length) {
|
|
40
|
+
<div class="selected-labels">
|
|
41
|
+
{{ selectedLabels }}
|
|
42
|
+
</div>
|
|
43
|
+
}
|
|
44
|
+
} @else {
|
|
45
|
+
<div class="frg-multi-select__handle-buttons">
|
|
46
|
+
@if(showChips) {
|
|
47
|
+
<div
|
|
48
|
+
class="custom-select custom-select--chips"
|
|
49
|
+
[id]="id + '-options'"
|
|
50
|
+
[attr.name]="id + '-options'"
|
|
51
|
+
[class.open]="isOpen"
|
|
52
|
+
[class.disabled]="disabled"
|
|
53
|
+
[attr.tabindex]="disabled ? -1 : 0"
|
|
54
|
+
[attr.aria-expanded]="isOpen"
|
|
55
|
+
(click)="toggleDropdown($event)"
|
|
56
|
+
(keydown)="onKeyDown($event)"
|
|
57
|
+
[attr.aria-controls]="id + '-options'"
|
|
58
|
+
>
|
|
59
|
+
@if(selectedItems.length) {
|
|
60
|
+
<div class="selected-chips">
|
|
61
|
+
@for(item of selectedItems; track item.id) {
|
|
62
|
+
<frg-chip
|
|
63
|
+
[id]="item.id"
|
|
64
|
+
[label]="item.label || ''"
|
|
65
|
+
size="sm"
|
|
66
|
+
[style]="chipsStyle"
|
|
67
|
+
[removable]="true"
|
|
68
|
+
[disabled]="disabled"
|
|
69
|
+
(removed)="removeItemById($event)"
|
|
70
|
+
></frg-chip>
|
|
71
|
+
}
|
|
72
|
+
</div>
|
|
73
|
+
} @else {
|
|
74
|
+
<span class="selected-labels__text selected-labels__placeholder">{{ placeholder || 'Select.' }}</span>
|
|
75
|
+
}
|
|
76
|
+
</div>
|
|
77
|
+
} @else {
|
|
78
|
+
<button
|
|
79
|
+
type="button"
|
|
80
|
+
class="custom-select"
|
|
81
|
+
[id]="id + '-options'"
|
|
82
|
+
[attr.name]="id + '-options'"
|
|
83
|
+
[class.open]="isOpen"
|
|
84
|
+
[disabled]="disabled"
|
|
85
|
+
[attr.aria-expanded]="isOpen"
|
|
86
|
+
(click)="toggleDropdown($event)"
|
|
87
|
+
(keydown)="onKeyDown($event)"
|
|
88
|
+
[attr.aria-controls]="id + '-options'"
|
|
89
|
+
>
|
|
90
|
+
@if(valuesTemplate) {
|
|
91
|
+
<ng-container
|
|
92
|
+
[ngTemplateOutlet]="valuesTemplate"
|
|
93
|
+
[ngTemplateOutletContext]="{ $implicit: selectedItems }"
|
|
94
|
+
></ng-container>
|
|
95
|
+
} @else {
|
|
96
|
+
<span class="selected-labels__text" [class.selected-labels__placeholder]="!selectedItems.length">{{ selectedLabels }}</span>
|
|
97
|
+
}
|
|
98
|
+
</button>
|
|
99
|
+
}
|
|
100
|
+
<ng-container [ngTemplateOutlet]="buttonsTemplate"></ng-container>
|
|
101
|
+
</div>
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
@if(isOpen) {
|
|
105
|
+
<div
|
|
106
|
+
class="options"
|
|
107
|
+
[id]="id + '-options'"
|
|
108
|
+
[class.open-up]="openDirection === 'top'"
|
|
109
|
+
[class.open-down]="openDirection === 'down'"
|
|
110
|
+
>
|
|
111
|
+
@for(item of filteredItems; track item.id; let idx = $index) {
|
|
112
|
+
<button
|
|
113
|
+
#optionButton
|
|
114
|
+
type="button"
|
|
115
|
+
class="option"
|
|
116
|
+
[class.disabled]="item.disabled"
|
|
117
|
+
[class.selected]="selectedIds.includes(item.id)"
|
|
118
|
+
[disabled]="item.disabled"
|
|
119
|
+
(focus)="onFocus()"
|
|
120
|
+
(blur)="onBlur($event)"
|
|
121
|
+
(click)="selectItem(item, $event)"
|
|
122
|
+
(keydown)="onOptionKeyDown($event, item, idx)"
|
|
123
|
+
>
|
|
124
|
+
<input
|
|
125
|
+
type="checkbox"
|
|
126
|
+
[attr.id]="id + '-option-' + idx"
|
|
127
|
+
[attr.name]="id + '-option'"
|
|
128
|
+
[checked]="item.selected"
|
|
129
|
+
readonly
|
|
130
|
+
/>
|
|
131
|
+
@if(optionTemplate) {
|
|
132
|
+
<ng-container [ngTemplateOutlet]="optionTemplate" [ngTemplateOutletContext]="{ $implicit: item }"></ng-container>
|
|
133
|
+
} @else {
|
|
134
|
+
{{ item.label }}
|
|
135
|
+
}
|
|
136
|
+
</button>
|
|
137
|
+
}
|
|
138
|
+
</div>
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
<frg-input-validation
|
|
142
|
+
[errorList]="errorList"
|
|
143
|
+
[isFormInvalid]="hasError"
|
|
144
|
+
></frg-input-validation>
|
|
145
|
+
</div>
|
|
146
|
+
|
|
147
|
+
<ng-template #buttonsTemplate>
|
|
148
|
+
<div class="multi-select__actions">
|
|
149
|
+
@if((value && selectedItems.length) || (hasSearch && searchTerm.length)) {
|
|
150
|
+
<button
|
|
151
|
+
type="button"
|
|
152
|
+
class="clear-button"
|
|
153
|
+
aria-label="Clear selection"
|
|
154
|
+
(click)="clearValue($event)"
|
|
155
|
+
>
|
|
156
|
+
<span class="fas fa-xmark"></span>
|
|
157
|
+
</button>
|
|
158
|
+
}
|
|
159
|
+
<button
|
|
160
|
+
type="button"
|
|
161
|
+
class="arrow-button"
|
|
162
|
+
[class.open]="isOpen"
|
|
163
|
+
aria-label="Toggle dropdown"
|
|
164
|
+
(click)="toggleDropdown($event)"
|
|
165
|
+
>
|
|
166
|
+
<span class="arrow-icon fas fa-chevron-down"></span>
|
|
167
|
+
</button>
|
|
168
|
+
</div>
|
|
169
|
+
</ng-template>
|
|
170
|
+
|
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
@use "sass:color";
|
|
2
|
+
@use './../../../../../assets/styles/scss/variables' as *;
|
|
3
|
+
|
|
4
|
+
:host {
|
|
5
|
+
display: block;
|
|
6
|
+
font-family: $input-font-family;
|
|
7
|
+
|
|
8
|
+
label {
|
|
9
|
+
display: flex;
|
|
10
|
+
font-size: $font-size-xs;
|
|
11
|
+
color: $input-text-color;
|
|
12
|
+
padding: $input-padding 0;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.frg-multi-select {
|
|
16
|
+
position: relative;
|
|
17
|
+
display: inline-block;
|
|
18
|
+
width: 100%;
|
|
19
|
+
|
|
20
|
+
.options-search {
|
|
21
|
+
position: relative;
|
|
22
|
+
display: flex;
|
|
23
|
+
align-items: center;
|
|
24
|
+
width: 100%;
|
|
25
|
+
border-bottom: 2px solid $input-border-color;
|
|
26
|
+
transition: border-color 0.3s;
|
|
27
|
+
|
|
28
|
+
&:has(.open) {
|
|
29
|
+
border-color: $input-focus-border-color;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
&.focus,
|
|
33
|
+
&:focus-visible,
|
|
34
|
+
&:hover {
|
|
35
|
+
border-color: $input-focus-border-color;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
&__input {
|
|
39
|
+
flex: 1;
|
|
40
|
+
padding: $input-padding;
|
|
41
|
+
padding-right: 3rem;
|
|
42
|
+
border: none;
|
|
43
|
+
background: transparent;
|
|
44
|
+
font-family: $input-font-family;
|
|
45
|
+
font-size: 1rem;
|
|
46
|
+
color: $color-dark-neutral;
|
|
47
|
+
cursor: pointer;
|
|
48
|
+
outline: none;
|
|
49
|
+
|
|
50
|
+
&::placeholder {
|
|
51
|
+
color: $input-text-color;
|
|
52
|
+
opacity: 0.7;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
&:disabled {
|
|
56
|
+
cursor: not-allowed;
|
|
57
|
+
opacity: 0.6;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
&__handle-buttons {
|
|
63
|
+
display: flex;
|
|
64
|
+
align-items: center;
|
|
65
|
+
width: 100%;
|
|
66
|
+
border-bottom: 2px solid $input-border-color;
|
|
67
|
+
background: transparent;
|
|
68
|
+
font-family: $input-font-family;
|
|
69
|
+
color: $input-text-color;
|
|
70
|
+
cursor: pointer;
|
|
71
|
+
transition: border-color 0.3s;
|
|
72
|
+
position: relative;
|
|
73
|
+
|
|
74
|
+
&:has(.open) {
|
|
75
|
+
border-color: $input-focus-border-color;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
&:hover,
|
|
79
|
+
&:focus-visible,
|
|
80
|
+
&.focus {
|
|
81
|
+
border-color: $input-focus-border-color;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.custom-select {
|
|
85
|
+
flex: 1 1 auto;
|
|
86
|
+
min-width: 0;
|
|
87
|
+
display: flex;
|
|
88
|
+
align-items: center;
|
|
89
|
+
padding: $input-padding;
|
|
90
|
+
padding-right: 3rem;
|
|
91
|
+
border: none;
|
|
92
|
+
background: transparent;
|
|
93
|
+
text-align: left;
|
|
94
|
+
font-size: 1rem;
|
|
95
|
+
overflow: hidden;
|
|
96
|
+
|
|
97
|
+
&:focus-visible {
|
|
98
|
+
outline: none;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
&:disabled {
|
|
102
|
+
cursor: not-allowed;
|
|
103
|
+
opacity: 0.6;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
&.open {
|
|
107
|
+
border-bottom-color: $color-primary;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.item-label {
|
|
111
|
+
flex: 1 1 auto;
|
|
112
|
+
min-width: 0; // critical for ellipsis in flex
|
|
113
|
+
overflow: hidden;
|
|
114
|
+
white-space: nowrap;
|
|
115
|
+
text-overflow: ellipsis;
|
|
116
|
+
opacity: 0.7;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.selected {
|
|
120
|
+
flex: 1 1 auto;
|
|
121
|
+
min-width: 0;
|
|
122
|
+
overflow: hidden;
|
|
123
|
+
white-space: nowrap;
|
|
124
|
+
text-overflow: ellipsis;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.custom-select--chips {
|
|
129
|
+
min-height: 2.25rem;
|
|
130
|
+
cursor: pointer;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.custom-select--chips.disabled {
|
|
134
|
+
cursor: not-allowed;
|
|
135
|
+
opacity: 0.6;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.multi-select__actions {
|
|
141
|
+
position: absolute;
|
|
142
|
+
right: 0;
|
|
143
|
+
top: 50%;
|
|
144
|
+
transform: translateY(-50%);
|
|
145
|
+
display: inline-flex;
|
|
146
|
+
align-items: center;
|
|
147
|
+
padding-right: 0.25rem;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.options {
|
|
151
|
+
position: absolute;
|
|
152
|
+
left: 0;
|
|
153
|
+
right: 0;
|
|
154
|
+
background: #fff;
|
|
155
|
+
border-radius: 0.25rem;
|
|
156
|
+
box-shadow: $box-shadow-md;
|
|
157
|
+
z-index: 10;
|
|
158
|
+
max-height: 240px;
|
|
159
|
+
overflow-y: auto;
|
|
160
|
+
animation: dropdown-fade-in 0.2s ease-in-out;
|
|
161
|
+
|
|
162
|
+
&::-webkit-scrollbar {
|
|
163
|
+
width: 0.3rem;
|
|
164
|
+
background-color: transparent;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
&::-webkit-scrollbar-thumb {
|
|
168
|
+
background-color: $color-primary;
|
|
169
|
+
border-radius: 0.1rem;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
&::-webkit-scrollbar-thumb:hover {
|
|
173
|
+
background-color: color.adjust($color-primary, $lightness: -10%);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.option {
|
|
177
|
+
display: inline-flex;
|
|
178
|
+
gap: .75rem;
|
|
179
|
+
width: 100%;
|
|
180
|
+
padding: 0.5rem 1rem;
|
|
181
|
+
background: transparent;
|
|
182
|
+
border: none;
|
|
183
|
+
text-align: left;
|
|
184
|
+
color: $input-text-color;
|
|
185
|
+
font-size: 0.95rem;
|
|
186
|
+
cursor: pointer;
|
|
187
|
+
transition: background-color 0.15s ease, color 0.15s ease;
|
|
188
|
+
|
|
189
|
+
&:hover:not(:disabled),
|
|
190
|
+
&:focus-visible:not(:disabled) {
|
|
191
|
+
background-color: color.scale($color-primary, $lightness: 90%);
|
|
192
|
+
outline: none;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
&.selected {
|
|
196
|
+
background-color: color.scale($color-primary, $lightness: 85%);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
&:disabled,
|
|
200
|
+
&.disabled {
|
|
201
|
+
opacity: 0.5;
|
|
202
|
+
cursor: not-allowed;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
&.open-down {
|
|
207
|
+
top: calc(100% + 0.25rem);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
&.open-up {
|
|
211
|
+
bottom: calc(100% + 0.25rem);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
.clear-button,
|
|
216
|
+
.arrow-button {
|
|
217
|
+
background: transparent;
|
|
218
|
+
border: none;
|
|
219
|
+
cursor: pointer;
|
|
220
|
+
padding: 0;
|
|
221
|
+
width: 1.25rem;
|
|
222
|
+
height: 1.25rem;
|
|
223
|
+
display: flex;
|
|
224
|
+
align-items: center;
|
|
225
|
+
justify-content: center;
|
|
226
|
+
font-size: 0.75rem;
|
|
227
|
+
line-height: 1;
|
|
228
|
+
color: $color-dark-neutral;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
.clear-button .fas {
|
|
232
|
+
line-height: 1;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
.arrow-button {
|
|
236
|
+
display: flex;
|
|
237
|
+
align-items: center;
|
|
238
|
+
justify-content: center;
|
|
239
|
+
background: transparent;
|
|
240
|
+
border: none;
|
|
241
|
+
cursor: pointer;
|
|
242
|
+
transition: transform 0.3s ease;
|
|
243
|
+
|
|
244
|
+
&:disabled {
|
|
245
|
+
cursor: not-allowed;
|
|
246
|
+
opacity: 0.5;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
.arrow-icon {
|
|
251
|
+
font-size: 0.75rem;
|
|
252
|
+
transition: transform 0.3s ease;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
.arrow-button.open .arrow-icon {
|
|
256
|
+
transform: rotate(180deg);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
.selected-labels {
|
|
260
|
+
padding: .2rem .5rem;
|
|
261
|
+
font-size: .875rem;
|
|
262
|
+
color: $color-dark-neutral;
|
|
263
|
+
|
|
264
|
+
&__text {
|
|
265
|
+
color: $color-dark-neutral;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
&__placeholder {
|
|
269
|
+
color: $input-text-color;
|
|
270
|
+
opacity: 0.7;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
.selected-chips {
|
|
275
|
+
display: flex;
|
|
276
|
+
flex-wrap: wrap;
|
|
277
|
+
align-items: center;
|
|
278
|
+
gap: 0.25rem;
|
|
279
|
+
min-height: 1.5rem;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
.selected-chips--below {
|
|
283
|
+
padding: 0.25rem 0.5rem 0;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
.custom-select--chips.disabled frg-chip {
|
|
287
|
+
pointer-events: none;
|
|
288
|
+
opacity: 0.6;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
&.multi-select-error .options-search,
|
|
292
|
+
&.multi-select-error .frg-multi-select__handle-buttons {
|
|
293
|
+
border-bottom-color: $color-danger;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
&.multi-select-error label {
|
|
297
|
+
color: $color-danger;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
@keyframes dropdown-fade-in {
|
|
301
|
+
from {
|
|
302
|
+
opacity: 0;
|
|
303
|
+
transform: translateY(-10px);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
to {
|
|
307
|
+
opacity: 1;
|
|
308
|
+
transform: translateY(0);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
import { By } from '@angular/platform-browser';
|
|
3
|
+
import { MultiSelectComponent } from './multi-select.component';
|
|
4
|
+
import { SelectionListItem } from '../selection-lists-interface';
|
|
5
|
+
|
|
6
|
+
describe('MultiSelectComponent', () => {
|
|
7
|
+
let fixture: ComponentFixture<MultiSelectComponent<string>>;
|
|
8
|
+
let component: MultiSelectComponent<string>;
|
|
9
|
+
|
|
10
|
+
const items: SelectionListItem<string>[] = [
|
|
11
|
+
{ id: 'a', label: 'Alpha', value: 'alpha', selected: false },
|
|
12
|
+
{ id: 'b', label: 'Beta', value: 'beta', selected: false }
|
|
13
|
+
];
|
|
14
|
+
|
|
15
|
+
beforeEach(async () => {
|
|
16
|
+
await TestBed.configureTestingModule({
|
|
17
|
+
imports: [MultiSelectComponent]
|
|
18
|
+
}).compileComponents();
|
|
19
|
+
|
|
20
|
+
fixture = TestBed.createComponent(MultiSelectComponent<string>);
|
|
21
|
+
component = fixture.componentInstance;
|
|
22
|
+
component.items = [...items];
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('opens dropdown when trigger is clicked', () => {
|
|
26
|
+
fixture.detectChanges();
|
|
27
|
+
|
|
28
|
+
const trigger = fixture.debugElement.query(By.css('.custom-select'));
|
|
29
|
+
trigger.nativeElement.click();
|
|
30
|
+
|
|
31
|
+
expect((component as any).isOpen).toBeTrue();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('selects multiple items and updates value', () => {
|
|
35
|
+
const onChangeSpy = jasmine.createSpy('onChange');
|
|
36
|
+
component.registerOnChange(onChangeSpy);
|
|
37
|
+
|
|
38
|
+
fixture.detectChanges();
|
|
39
|
+
|
|
40
|
+
component.selectItem(items[0], new Event('click'));
|
|
41
|
+
component.selectItem(items[1], new Event('click'));
|
|
42
|
+
|
|
43
|
+
expect(component.value).toEqual(['alpha', 'beta']);
|
|
44
|
+
expect((component as any).selectedIds).toEqual(['a', 'b']);
|
|
45
|
+
expect(onChangeSpy).toHaveBeenCalledWith(['alpha', 'beta']);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('clears selections', () => {
|
|
49
|
+
component.items = [
|
|
50
|
+
{ id: 'a', label: 'Alpha', value: 'alpha', selected: true },
|
|
51
|
+
{ id: 'b', label: 'Beta', value: 'beta', selected: true }
|
|
52
|
+
];
|
|
53
|
+
(component as any).selectedIds = ['a', 'b'];
|
|
54
|
+
component.value = ['alpha', 'beta'];
|
|
55
|
+
|
|
56
|
+
(component as any).clearValue(new MouseEvent('click'));
|
|
57
|
+
|
|
58
|
+
expect(component.value).toBeNull();
|
|
59
|
+
expect((component as any).selectedIds.length).toBe(0);
|
|
60
|
+
});
|
|
61
|
+
});
|