@kouji-ui/components 0.1.1 → 0.1.2
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/fesm2022/kouji-ui-components.mjs +17668 -0
- package/fesm2022/kouji-ui-components.mjs.map +1 -0
- package/package.json +17 -10
- package/types/kouji-ui-components.d.ts +8032 -0
- package/.turbo/turbo-build.log +0 -29
- package/CHANGELOG.md +0 -192
- package/ng-package.json +0 -7
- package/src/accordion/_examples/accordion.default.example.ts +0 -31
- package/src/accordion/_examples/accordion.disabled.example.ts +0 -38
- package/src/accordion/_examples/accordion.multiple.example.ts +0 -31
- package/src/accordion/_examples/accordion.rich-content.example.ts +0 -49
- package/src/accordion/_examples/index.ts +0 -6
- package/src/accordion/accordion.arrow-nav.example.ts +0 -39
- package/src/accordion/accordion.css +0 -68
- package/src/accordion/accordion.playground.ts +0 -119
- package/src/accordion/accordion.spec.ts +0 -117
- package/src/accordion/accordion.ts +0 -153
- package/src/accordion/accordion.usage.example.ts +0 -38
- package/src/accordion/accordion.value.example.ts +0 -60
- package/src/accordion/index.ts +0 -1
- package/src/alert/_examples/alert.banner.example.ts +0 -56
- package/src/alert/_examples/alert.dismissible.example.ts +0 -53
- package/src/alert/_examples/alert.example.ts +0 -40
- package/src/alert/_examples/alert.variants.example.ts +0 -66
- package/src/alert/_examples/alert.with-actions.example.ts +0 -57
- package/src/alert/_examples/index.ts +0 -7
- package/src/alert/alert.css +0 -133
- package/src/alert/alert.playground.ts +0 -111
- package/src/alert/alert.spec.ts +0 -167
- package/src/alert/alert.ts +0 -250
- package/src/alert/alert.usage.example.ts +0 -58
- package/src/alert/index.ts +0 -8
- package/src/avatar/_examples/avatar-group.example.ts +0 -31
- package/src/avatar/_examples/avatar-group.list.example.ts +0 -45
- package/src/avatar/_examples/avatar-group.overflow.example.ts +0 -33
- package/src/avatar/_examples/avatar-group.shapes.example.ts +0 -39
- package/src/avatar/_examples/avatar-group.sizes.example.ts +0 -44
- package/src/avatar/_examples/avatar.default.example.ts +0 -18
- package/src/avatar/_examples/avatar.initials.example.ts +0 -20
- package/src/avatar/_examples/avatar.shapes.example.ts +0 -22
- package/src/avatar/_examples/avatar.sizes.example.ts +0 -26
- package/src/avatar/_examples/avatar.with-image.example.ts +0 -20
- package/src/avatar/_examples/index.ts +0 -12
- package/src/avatar/avatar-group.spec.ts +0 -138
- package/src/avatar/avatar-group.ts +0 -127
- package/src/avatar/avatar-group.usage.example.ts +0 -30
- package/src/avatar/avatar.css +0 -58
- package/src/avatar/avatar.playground.ts +0 -95
- package/src/avatar/avatar.ts +0 -123
- package/src/avatar/index.ts +0 -2
- package/src/badge/_examples/badge.default.example.ts +0 -18
- package/src/badge/_examples/badge.sizes.example.ts +0 -25
- package/src/badge/_examples/badge.variants.example.ts +0 -24
- package/src/badge/_examples/badge.with-dot.example.ts +0 -31
- package/src/badge/_examples/badge.with-icon.example.ts +0 -23
- package/src/badge/_examples/index.ts +0 -7
- package/src/badge/badge.css +0 -59
- package/src/badge/badge.playground.ts +0 -49
- package/src/badge/badge.ts +0 -86
- package/src/badge/badge.usage.example.ts +0 -22
- package/src/badge/index.ts +0 -1
- package/src/breadcrumb/_examples/breadcrumb.custom-separator.example.ts +0 -53
- package/src/breadcrumb/_examples/breadcrumb.example.ts +0 -48
- package/src/breadcrumb/_examples/breadcrumb.long-path.example.ts +0 -58
- package/src/breadcrumb/_examples/breadcrumb.truncated.example.ts +0 -59
- package/src/breadcrumb/_examples/breadcrumb.with-icons.example.ts +0 -66
- package/src/breadcrumb/_examples/index.ts +0 -7
- package/src/breadcrumb/breadcrumb.css +0 -121
- package/src/breadcrumb/breadcrumb.playground.ts +0 -93
- package/src/breadcrumb/breadcrumb.spec.ts +0 -230
- package/src/breadcrumb/breadcrumb.ts +0 -272
- package/src/breadcrumb/breadcrumb.usage.example.ts +0 -45
- package/src/breadcrumb/index.ts +0 -1
- package/src/button/_examples/button.anchor.example.ts +0 -18
- package/src/button/_examples/button.configured.example.ts +0 -43
- package/src/button/_examples/button.disabled.example.ts +0 -25
- package/src/button/_examples/button.example.ts +0 -22
- package/src/button/_examples/button.icon.example.ts +0 -27
- package/src/button/_examples/button.loading.example.ts +0 -31
- package/src/button/_examples/button.pressed.example.ts +0 -24
- package/src/button/_examples/button.sizes.example.ts +0 -26
- package/src/button/_examples/button.usage.example.ts +0 -66
- package/src/button/_examples/button.variants.example.ts +0 -26
- package/src/button/_examples/index.ts +0 -12
- package/src/button/button.css +0 -263
- package/src/button/button.playground.ts +0 -79
- package/src/button/button.spec.ts +0 -100
- package/src/button/button.ts +0 -150
- package/src/button/index.ts +0 -1
- package/src/button-group/_examples/button-group.example.ts +0 -30
- package/src/button-group/_examples/button-group.icon-only.example.ts +0 -30
- package/src/button-group/_examples/button-group.toggle.example.ts +0 -36
- package/src/button-group/_examples/button-group.variants.example.ts +0 -40
- package/src/button-group/_examples/button-group.vertical.example.ts +0 -29
- package/src/button-group/_examples/index.ts +0 -7
- package/src/button-group/button-group.css +0 -80
- package/src/button-group/button-group.playground.ts +0 -94
- package/src/button-group/button-group.spec.ts +0 -119
- package/src/button-group/button-group.ts +0 -130
- package/src/button-group/button-group.usage.example.ts +0 -35
- package/src/button-group/index.ts +0 -1
- package/src/calendar/_examples/calendar.example.ts +0 -33
- package/src/calendar/_examples/index.ts +0 -3
- package/src/calendar/calendar.css +0 -129
- package/src/calendar/calendar.playground.ts +0 -84
- package/src/calendar/calendar.spec.ts +0 -50
- package/src/calendar/calendar.ts +0 -171
- package/src/calendar/calendar.usage.example.ts +0 -33
- package/src/calendar/index.ts +0 -1
- package/src/card/_examples/card.cover.example.ts +0 -53
- package/src/card/_examples/card.example.ts +0 -27
- package/src/card/_examples/card.full.example.ts +0 -51
- package/src/card/_examples/index.ts +0 -5
- package/src/card/card.css +0 -120
- package/src/card/card.playground.ts +0 -116
- package/src/card/card.spec.ts +0 -50
- package/src/card/card.ts +0 -194
- package/src/card/card.usage.example.ts +0 -46
- package/src/card/index.ts +0 -1
- package/src/carousel/_examples/carousel.autoplay.example.ts +0 -69
- package/src/carousel/_examples/carousel.example.ts +0 -60
- package/src/carousel/_examples/carousel.indicators.example.ts +0 -64
- package/src/carousel/_examples/carousel.lazy-load.example.ts +0 -85
- package/src/carousel/_examples/carousel.tabs-pattern.example.ts +0 -61
- package/src/carousel/_examples/index.ts +0 -7
- package/src/carousel/carousel.css +0 -181
- package/src/carousel/carousel.playground.ts +0 -135
- package/src/carousel/carousel.spec.ts +0 -211
- package/src/carousel/carousel.ts +0 -399
- package/src/carousel/carousel.usage.example.ts +0 -46
- package/src/carousel/index.ts +0 -1
- package/src/cascade-select/_examples/cascade-select.data-driven.example.ts +0 -119
- package/src/cascade-select/_examples/cascade-select.disabled.example.ts +0 -74
- package/src/cascade-select/_examples/cascade-select.example.ts +0 -80
- package/src/cascade-select/_examples/cascade-select.field.example.ts +0 -73
- package/src/cascade-select/_examples/cascade-select.path.example.ts +0 -85
- package/src/cascade-select/_examples/index.ts +0 -7
- package/src/cascade-select/cascade-select.css +0 -120
- package/src/cascade-select/cascade-select.playground.ts +0 -133
- package/src/cascade-select/cascade-select.ts +0 -201
- package/src/cascade-select/cascade-select.usage.example.ts +0 -44
- package/src/cascade-select/index.ts +0 -5
- package/src/chat/_examples/chat-bubble.example.ts +0 -71
- package/src/chat/_examples/chat-bubble.grouped.example.ts +0 -69
- package/src/chat/_examples/chat-bubble.sides.example.ts +0 -41
- package/src/chat/_examples/chat-bubble.variants.example.ts +0 -58
- package/src/chat/_examples/chat-bubble.with-state.example.ts +0 -57
- package/src/chat/_examples/index.ts +0 -7
- package/src/chat/chat.css +0 -231
- package/src/chat/chat.playground.ts +0 -171
- package/src/chat/chat.spec.ts +0 -343
- package/src/chat/chat.ts +0 -269
- package/src/chat/chat.usage.example.ts +0 -49
- package/src/chat/index.ts +0 -13
- package/src/checkbox/_examples/checkbox.checked.example.ts +0 -20
- package/src/checkbox/_examples/checkbox.default.example.ts +0 -20
- package/src/checkbox/_examples/checkbox.disabled.example.ts +0 -26
- package/src/checkbox/_examples/checkbox.indeterminate.example.ts +0 -20
- package/src/checkbox/_examples/checkbox.usage.example.ts +0 -62
- package/src/checkbox/_examples/index.ts +0 -7
- package/src/checkbox/checkbox.css +0 -74
- package/src/checkbox/checkbox.playground.ts +0 -68
- package/src/checkbox/checkbox.ts +0 -122
- package/src/checkbox/index.ts +0 -1
- package/src/color-picker/_examples/color-picker.alpha.example.ts +0 -36
- package/src/color-picker/_examples/color-picker.example.ts +0 -34
- package/src/color-picker/_examples/color-picker.hex-input.example.ts +0 -53
- package/src/color-picker/_examples/color-picker.in-form.example.ts +0 -60
- package/src/color-picker/_examples/color-picker.usage.example.ts +0 -58
- package/src/color-picker/_examples/color-picker.with-presets.example.ts +0 -45
- package/src/color-picker/_examples/index.ts +0 -8
- package/src/color-picker/color-picker.css +0 -183
- package/src/color-picker/color-picker.playground.ts +0 -83
- package/src/color-picker/color-picker.spec.ts +0 -94
- package/src/color-picker/color-picker.ts +0 -234
- package/src/color-picker/index.ts +0 -1
- package/src/combobox/_examples/combobox.async.example.ts +0 -85
- package/src/combobox/_examples/combobox.empty-state.example.ts +0 -36
- package/src/combobox/_examples/combobox.example.ts +0 -36
- package/src/combobox/_examples/combobox.free-text.example.ts +0 -42
- package/src/combobox/_examples/combobox.usage.example.ts +0 -51
- package/src/combobox/_examples/combobox.with-icons.example.ts +0 -49
- package/src/combobox/_examples/index.ts +0 -8
- package/src/combobox/combobox.css +0 -101
- package/src/combobox/combobox.playground.ts +0 -90
- package/src/combobox/combobox.spec.ts +0 -111
- package/src/combobox/combobox.ts +0 -219
- package/src/combobox/index.ts +0 -6
- package/src/command-palette/_examples/command-palette.async.example.ts +0 -99
- package/src/command-palette/_examples/command-palette.dialog.example.ts +0 -90
- package/src/command-palette/_examples/command-palette.example.ts +0 -40
- package/src/command-palette/_examples/command-palette.fuzzy.example.ts +0 -54
- package/src/command-palette/_examples/command-palette.groups.example.ts +0 -55
- package/src/command-palette/_examples/command-palette.usage.example.ts +0 -49
- package/src/command-palette/_examples/index.ts +0 -8
- package/src/command-palette/command-palette.css +0 -234
- package/src/command-palette/command-palette.playground.ts +0 -119
- package/src/command-palette/command-palette.ts +0 -448
- package/src/command-palette/index.ts +0 -10
- package/src/confirm-popup/_examples/confirm-popup.destructive.example.ts +0 -72
- package/src/confirm-popup/_examples/confirm-popup.example.ts +0 -82
- package/src/confirm-popup/_examples/confirm-popup.placement.example.ts +0 -97
- package/src/confirm-popup/_examples/confirm-popup.usage.example.ts +0 -94
- package/src/confirm-popup/_examples/confirm-popup.with-message.example.ts +0 -76
- package/src/confirm-popup/_examples/index.ts +0 -7
- package/src/confirm-popup/confirm-popup.css +0 -47
- package/src/confirm-popup/confirm-popup.playground.ts +0 -109
- package/src/confirm-popup/confirm-popup.spec.ts +0 -209
- package/src/confirm-popup/confirm-popup.ts +0 -279
- package/src/confirm-popup/index.ts +0 -1
- package/src/date-picker/_examples/date-picker.disabled-dates.example.ts +0 -44
- package/src/date-picker/_examples/date-picker.example.ts +0 -38
- package/src/date-picker/_examples/date-picker.locale.example.ts +0 -50
- package/src/date-picker/_examples/date-picker.readonly.example.ts +0 -32
- package/src/date-picker/_examples/date-picker.usage.example.ts +0 -60
- package/src/date-picker/_examples/date-picker.with-min-max.example.ts +0 -47
- package/src/date-picker/_examples/index.ts +0 -8
- package/src/date-picker/date-picker.css +0 -61
- package/src/date-picker/date-picker.playground.ts +0 -79
- package/src/date-picker/date-picker.spec.ts +0 -71
- package/src/date-picker/date-picker.ts +0 -185
- package/src/date-picker/index.ts +0 -1
- package/src/dialog/_examples/dialog.confirmation.example.ts +0 -30
- package/src/dialog/_examples/dialog.default.example.ts +0 -30
- package/src/dialog/_examples/dialog.nested.example.ts +0 -86
- package/src/dialog/_examples/dialog.scrollable.example.ts +0 -30
- package/src/dialog/_examples/dialog.usage.example.ts +0 -57
- package/src/dialog/_examples/dialog.with-form.example.ts +0 -48
- package/src/dialog/_examples/index.ts +0 -8
- package/src/dialog/dialog.css +0 -56
- package/src/dialog/dialog.playground.ts +0 -136
- package/src/dialog/dialog.ts +0 -82
- package/src/dialog/index.ts +0 -1
- package/src/divider/_examples/divider.example.ts +0 -27
- package/src/divider/_examples/divider.sizes.example.ts +0 -33
- package/src/divider/_examples/divider.structural.example.ts +0 -55
- package/src/divider/_examples/divider.usage.example.ts +0 -48
- package/src/divider/_examples/divider.variants.example.ts +0 -33
- package/src/divider/_examples/divider.vertical.example.ts +0 -38
- package/src/divider/_examples/divider.with-content.example.ts +0 -38
- package/src/divider/_examples/index.ts +0 -9
- package/src/divider/divider.css +0 -93
- package/src/divider/divider.playground.ts +0 -97
- package/src/divider/divider.spec.ts +0 -207
- package/src/divider/divider.ts +0 -220
- package/src/divider/index.ts +0 -1
- package/src/drawer/_examples/drawer.example.ts +0 -30
- package/src/drawer/_examples/drawer.modal-vs-non-modal.example.ts +0 -27
- package/src/drawer/_examples/drawer.scrollable.example.ts +0 -30
- package/src/drawer/_examples/drawer.sides.example.ts +0 -32
- package/src/drawer/_examples/drawer.usage.example.ts +0 -56
- package/src/drawer/_examples/drawer.with-form.example.ts +0 -48
- package/src/drawer/_examples/index.ts +0 -8
- package/src/drawer/drawer.css +0 -130
- package/src/drawer/drawer.playground.ts +0 -107
- package/src/drawer/drawer.spec.ts +0 -216
- package/src/drawer/drawer.ts +0 -85
- package/src/drawer/index.ts +0 -1
- package/src/dropdown-menu/_examples/dropdown-menu.disabled.example.ts +0 -19
- package/src/dropdown-menu/_examples/dropdown-menu.example.ts +0 -20
- package/src/dropdown-menu/_examples/dropdown-menu.shortcuts.example.ts +0 -31
- package/src/dropdown-menu/_examples/dropdown-menu.sides.example.ts +0 -18
- package/src/dropdown-menu/_examples/dropdown-menu.usage.example.ts +0 -56
- package/src/dropdown-menu/_examples/dropdown-menu.with-icons.example.ts +0 -31
- package/src/dropdown-menu/_examples/dropdown-menu.with-separator.example.ts +0 -41
- package/src/dropdown-menu/_examples/index.ts +0 -9
- package/src/dropdown-menu/dropdown-menu.css +0 -108
- package/src/dropdown-menu/dropdown-menu.playground.ts +0 -109
- package/src/dropdown-menu/dropdown-menu.spec.ts +0 -5
- package/src/dropdown-menu/dropdown-menu.ts +0 -128
- package/src/dropdown-menu/index.ts +0 -1
- package/src/empty-state/_examples/empty-state.error.example.ts +0 -63
- package/src/empty-state/_examples/empty-state.example.ts +0 -59
- package/src/empty-state/_examples/empty-state.search.example.ts +0 -82
- package/src/empty-state/_examples/empty-state.sizes.example.ts +0 -76
- package/src/empty-state/_examples/empty-state.usage.example.ts +0 -66
- package/src/empty-state/_examples/empty-state.with-actions.example.ts +0 -68
- package/src/empty-state/_examples/index.ts +0 -8
- package/src/empty-state/empty-state.css +0 -114
- package/src/empty-state/empty-state.playground.ts +0 -87
- package/src/empty-state/empty-state.spec.ts +0 -211
- package/src/empty-state/empty-state.ts +0 -276
- package/src/empty-state/index.ts +0 -1
- package/src/example-components.ts +0 -396
- package/src/field/_examples/field.disabled.example.ts +0 -49
- package/src/field/_examples/field.example.ts +0 -51
- package/src/field/_examples/field.required.example.ts +0 -46
- package/src/field/_examples/field.with-error.example.ts +0 -73
- package/src/field/_examples/field.with-prefix-suffix.example.ts +0 -63
- package/src/field/_examples/index.ts +0 -7
- package/src/field/field.css +0 -138
- package/src/field/field.playground.ts +0 -108
- package/src/field/field.spec.ts +0 -132
- package/src/field/field.ts +0 -232
- package/src/field/field.usage.example.ts +0 -63
- package/src/field/index.ts +0 -7
- package/src/file-upload/_examples/file-upload.dropzone.example.ts +0 -32
- package/src/file-upload/_examples/file-upload.example.ts +0 -29
- package/src/file-upload/_examples/file-upload.image-preview.example.ts +0 -31
- package/src/file-upload/_examples/file-upload.multiple.example.ts +0 -23
- package/src/file-upload/_examples/file-upload.with-progress.example.ts +0 -59
- package/src/file-upload/_examples/index.ts +0 -7
- package/src/file-upload/file-upload.css +0 -207
- package/src/file-upload/file-upload.playground.ts +0 -84
- package/src/file-upload/file-upload.spec.ts +0 -94
- package/src/file-upload/file-upload.ts +0 -301
- package/src/file-upload/file-upload.usage.example.ts +0 -45
- package/src/file-upload/index.ts +0 -1
- package/src/form/_examples/form.async-submit.example.ts +0 -72
- package/src/form/_examples/form.compound.example.ts +0 -93
- package/src/form/_examples/form.example.ts +0 -70
- package/src/form/_examples/form.validation.example.ts +0 -67
- package/src/form/_examples/index.ts +0 -6
- package/src/form/form.css +0 -63
- package/src/form/form.playground.ts +0 -145
- package/src/form/form.spec.ts +0 -96
- package/src/form/form.ts +0 -216
- package/src/form/form.usage.example.ts +0 -63
- package/src/form/index.ts +0 -5
- package/src/icon/_examples/icon.gallery.example.ts +0 -199
- package/src/icon/_examples/icon.usage.example.ts +0 -46
- package/src/icon/_examples/index.ts +0 -4
- package/src/icon/icon.playground.ts +0 -63
- package/src/icon/index.ts +0 -5
- package/src/icon/lucide/icon-names.generated.ts +0 -1708
- package/src/icon/lucide/icon-names.ts +0 -18
- package/src/icon/lucide/index.ts +0 -2
- package/src/icon/lucide/provide-lucide-icons.ts +0 -96
- package/src/input/_examples/index.ts +0 -4
- package/src/input/_examples/input.color.example.ts +0 -33
- package/src/input/_examples/input.example.ts +0 -22
- package/src/input/index.ts +0 -1
- package/src/input/input.css +0 -70
- package/src/input/input.playground.ts +0 -79
- package/src/input/input.spec.ts +0 -98
- package/src/input/input.ts +0 -158
- package/src/input/input.usage.example.ts +0 -40
- package/src/input-group/_examples/index.ts +0 -7
- package/src/input-group/_examples/input-group.button.example.ts +0 -43
- package/src/input-group/_examples/input-group.example.ts +0 -39
- package/src/input-group/_examples/input-group.icon.example.ts +0 -49
- package/src/input-group/_examples/input-group.url.example.ts +0 -36
- package/src/input-group/_examples/input-group.variants.example.ts +0 -39
- package/src/input-group/index.ts +0 -1
- package/src/input-group/input-group.css +0 -125
- package/src/input-group/input-group.playground.ts +0 -90
- package/src/input-group/input-group.ts +0 -142
- package/src/input-group/input-group.usage.example.ts +0 -47
- package/src/input-mask/_examples/index.ts +0 -8
- package/src/input-mask/_examples/input-mask.credit-card.example.ts +0 -90
- package/src/input-mask/_examples/input-mask.custom-tokens.example.ts +0 -87
- package/src/input-mask/_examples/input-mask.date.example.ts +0 -61
- package/src/input-mask/_examples/input-mask.example.ts +0 -61
- package/src/input-mask/_examples/input-mask.usage.example.ts +0 -44
- package/src/input-mask/_examples/input-mask.validation.example.ts +0 -80
- package/src/input-mask/index.ts +0 -9
- package/src/input-mask/input-mask.css +0 -39
- package/src/input-mask/input-mask.playground.ts +0 -79
- package/src/input-mask/input-mask.ts +0 -130
- package/src/input-otp/_examples/index.ts +0 -8
- package/src/input-otp/_examples/input-otp.autosubmit.example.ts +0 -71
- package/src/input-otp/_examples/input-otp.example.ts +0 -47
- package/src/input-otp/_examples/input-otp.lengths.example.ts +0 -67
- package/src/input-otp/_examples/input-otp.masked.example.ts +0 -46
- package/src/input-otp/_examples/input-otp.reactive.example.ts +0 -58
- package/src/input-otp/_examples/input-otp.separator.example.ts +0 -49
- package/src/input-otp/index.ts +0 -1
- package/src/input-otp/input-otp.css +0 -87
- package/src/input-otp/input-otp.playground.ts +0 -107
- package/src/input-otp/input-otp.ts +0 -244
- package/src/input-otp/input-otp.usage.example.ts +0 -45
- package/src/kbd/_examples/index.ts +0 -6
- package/src/kbd/_examples/kbd.combo.example.ts +0 -24
- package/src/kbd/_examples/kbd.example.ts +0 -22
- package/src/kbd/_examples/kbd.in-tooltip.example.ts +0 -43
- package/src/kbd/_examples/kbd.sizes.example.ts +0 -31
- package/src/kbd/index.ts +0 -1
- package/src/kbd/kbd.css +0 -67
- package/src/kbd/kbd.playground.ts +0 -51
- package/src/kbd/kbd.spec.ts +0 -123
- package/src/kbd/kbd.ts +0 -123
- package/src/kbd/kbd.usage.example.ts +0 -38
- package/src/link/_examples/index.ts +0 -8
- package/src/link/_examples/link.disabled.example.ts +0 -23
- package/src/link/_examples/link.example.ts +0 -26
- package/src/link/_examples/link.external.example.ts +0 -33
- package/src/link/_examples/link.in-prose.example.ts +0 -36
- package/src/link/_examples/link.sizes.example.ts +0 -28
- package/src/link/_examples/link.variants.example.ts +0 -25
- package/src/link/index.ts +0 -1
- package/src/link/link.css +0 -104
- package/src/link/link.playground.ts +0 -98
- package/src/link/link.spec.ts +0 -146
- package/src/link/link.ts +0 -133
- package/src/link/link.usage.example.ts +0 -37
- package/src/list/_examples/index.ts +0 -7
- package/src/list/_examples/list.divided.example.ts +0 -32
- package/src/list/_examples/list.example.ts +0 -31
- package/src/list/_examples/list.interactive.example.ts +0 -51
- package/src/list/_examples/list.nav.example.ts +0 -44
- package/src/list/_examples/list.with-icons.example.ts +0 -97
- package/src/list/index.ts +0 -1
- package/src/list/list.css +0 -166
- package/src/list/list.playground.ts +0 -90
- package/src/list/list.spec.ts +0 -121
- package/src/list/list.ts +0 -227
- package/src/list/list.usage.example.ts +0 -45
- package/src/menubar/_examples/index.ts +0 -6
- package/src/menubar/_examples/menubar.disabled-item.example.ts +0 -23
- package/src/menubar/_examples/menubar.example.ts +0 -22
- package/src/menubar/_examples/menubar.with-shortcuts.example.ts +0 -33
- package/src/menubar/_examples/menubar.with-submenu.example.ts +0 -76
- package/src/menubar/index.ts +0 -1
- package/src/menubar/menubar.css +0 -62
- package/src/menubar/menubar.playground.ts +0 -96
- package/src/menubar/menubar.ts +0 -160
- package/src/menubar/menubar.usage.example.ts +0 -33
- package/src/number-input/_examples/index.ts +0 -7
- package/src/number-input/_examples/number-input.currency.example.ts +0 -35
- package/src/number-input/_examples/number-input.decimal.example.ts +0 -34
- package/src/number-input/_examples/number-input.example.ts +0 -24
- package/src/number-input/_examples/number-input.min-max.example.ts +0 -33
- package/src/number-input/_examples/number-input.with-stepper.example.ts +0 -45
- package/src/number-input/index.ts +0 -1
- package/src/number-input/number-input.css +0 -115
- package/src/number-input/number-input.playground.ts +0 -92
- package/src/number-input/number-input.spec.ts +0 -102
- package/src/number-input/number-input.ts +0 -212
- package/src/number-input/number-input.usage.example.ts +0 -73
- package/src/overlay/overlay.css +0 -32
- package/src/overlay-badge/_examples/index.ts +0 -7
- package/src/overlay-badge/_examples/overlay-badge.described.example.ts +0 -36
- package/src/overlay-badge/_examples/overlay-badge.dot.example.ts +0 -28
- package/src/overlay-badge/_examples/overlay-badge.example.ts +0 -34
- package/src/overlay-badge/_examples/overlay-badge.on-avatar.example.ts +0 -38
- package/src/overlay-badge/_examples/overlay-badge.positions.example.ts +0 -39
- package/src/overlay-badge/index.ts +0 -1
- package/src/overlay-badge/overlay-badge.css +0 -118
- package/src/overlay-badge/overlay-badge.playground.ts +0 -92
- package/src/overlay-badge/overlay-badge.spec.ts +0 -174
- package/src/overlay-badge/overlay-badge.ts +0 -232
- package/src/overlay-badge/overlay-badge.usage.example.ts +0 -44
- package/src/pagination/_examples/index.ts +0 -7
- package/src/pagination/_examples/pagination.boundaries.example.ts +0 -56
- package/src/pagination/_examples/pagination.compact.example.ts +0 -42
- package/src/pagination/_examples/pagination.example.ts +0 -55
- package/src/pagination/_examples/pagination.large.example.ts +0 -54
- package/src/pagination/_examples/pagination.with-info.example.ts +0 -49
- package/src/pagination/index.ts +0 -1
- package/src/pagination/pagination.css +0 -146
- package/src/pagination/pagination.playground.ts +0 -107
- package/src/pagination/pagination.spec.ts +0 -202
- package/src/pagination/pagination.ts +0 -432
- package/src/pagination/pagination.usage.example.ts +0 -50
- package/src/password-input/_examples/index.ts +0 -6
- package/src/password-input/_examples/password-input.example.ts +0 -24
- package/src/password-input/_examples/password-input.strength.example.ts +0 -45
- package/src/password-input/_examples/password-input.toggle.example.ts +0 -43
- package/src/password-input/_examples/password-input.with-rules.example.ts +0 -78
- package/src/password-input/index.ts +0 -1
- package/src/password-input/password-input.css +0 -155
- package/src/password-input/password-input.playground.ts +0 -81
- package/src/password-input/password-input.spec.ts +0 -129
- package/src/password-input/password-input.ts +0 -254
- package/src/password-input/password-input.usage.example.ts +0 -55
- package/src/playground-types.ts +0 -47
- package/src/popover/_examples/index.ts +0 -7
- package/src/popover/_examples/popover.cancellable.example.ts +0 -20
- package/src/popover/_examples/popover.example.ts +0 -20
- package/src/popover/_examples/popover.modal.example.ts +0 -22
- package/src/popover/_examples/popover.sides.example.ts +0 -37
- package/src/popover/_examples/popover.with-form.example.ts +0 -38
- package/src/popover/index.ts +0 -1
- package/src/popover/popover.css +0 -71
- package/src/popover/popover.playground.ts +0 -86
- package/src/popover/popover.spec.ts +0 -5
- package/src/popover/popover.ts +0 -94
- package/src/popover/popover.usage.example.ts +0 -48
- package/src/progress-bar/_examples/index.ts +0 -7
- package/src/progress-bar/_examples/progress-bar.example.ts +0 -22
- package/src/progress-bar/_examples/progress-bar.indeterminate.example.ts +0 -23
- package/src/progress-bar/_examples/progress-bar.sizes.example.ts +0 -29
- package/src/progress-bar/_examples/progress-bar.variants.example.ts +0 -30
- package/src/progress-bar/_examples/progress-bar.with-label.example.ts +0 -30
- package/src/progress-bar/index.ts +0 -1
- package/src/progress-bar/progress-bar.css +0 -113
- package/src/progress-bar/progress-bar.playground.ts +0 -87
- package/src/progress-bar/progress-bar.spec.ts +0 -233
- package/src/progress-bar/progress-bar.ts +0 -155
- package/src/progress-bar/progress-bar.usage.example.ts +0 -52
- package/src/public-api.ts +0 -61
- package/src/radio/_examples/index.ts +0 -6
- package/src/radio/_examples/radio.default.example.ts +0 -26
- package/src/radio/_examples/radio.disabled.example.ts +0 -26
- package/src/radio/_examples/radio.group.example.ts +0 -27
- package/src/radio/_examples/radio.inline.example.ts +0 -26
- package/src/radio/index.ts +0 -1
- package/src/radio/radio.css +0 -58
- package/src/radio/radio.playground.ts +0 -90
- package/src/radio/radio.ts +0 -143
- package/src/radio/radio.usage.example.ts +0 -54
- package/src/select/_examples/index.ts +0 -6
- package/src/select/_examples/select.default.example.ts +0 -26
- package/src/select/_examples/select.disabled.example.ts +0 -24
- package/src/select/_examples/select.grouped.example.ts +0 -37
- package/src/select/_examples/select.placeholder.example.ts +0 -26
- package/src/select/index.ts +0 -1
- package/src/select/select.css +0 -65
- package/src/select/select.playground.ts +0 -81
- package/src/select/select.ts +0 -176
- package/src/select/select.usage.example.ts +0 -64
- package/src/skeleton/_examples/index.ts +0 -6
- package/src/skeleton/_examples/skeleton.animations.example.ts +0 -52
- package/src/skeleton/_examples/skeleton.card.example.ts +0 -68
- package/src/skeleton/_examples/skeleton.example.ts +0 -24
- package/src/skeleton/_examples/skeleton.shapes.example.ts +0 -55
- package/src/skeleton/index.ts +0 -1
- package/src/skeleton/skeleton.css +0 -111
- package/src/skeleton/skeleton.playground.ts +0 -80
- package/src/skeleton/skeleton.spec.ts +0 -126
- package/src/skeleton/skeleton.ts +0 -155
- package/src/skeleton/skeleton.usage.example.ts +0 -49
- package/src/slider/_examples/index.ts +0 -7
- package/src/slider/_examples/slider.example.ts +0 -41
- package/src/slider/_examples/slider.formatted.example.ts +0 -53
- package/src/slider/_examples/slider.range.example.ts +0 -48
- package/src/slider/_examples/slider.vertical.example.ts +0 -48
- package/src/slider/_examples/slider.with-marks.example.ts +0 -46
- package/src/slider/index.ts +0 -1
- package/src/slider/slider.css +0 -172
- package/src/slider/slider.playground.ts +0 -88
- package/src/slider/slider.spec.ts +0 -139
- package/src/slider/slider.ts +0 -246
- package/src/slider/slider.usage.example.ts +0 -68
- package/src/speed-dial/_examples/index.ts +0 -7
- package/src/speed-dial/_examples/speed-dial.directions.example.ts +0 -85
- package/src/speed-dial/_examples/speed-dial.disabled.example.ts +0 -71
- package/src/speed-dial/_examples/speed-dial.example.ts +0 -48
- package/src/speed-dial/_examples/speed-dial.usage.example.ts +0 -59
- package/src/speed-dial/_examples/speed-dial.with-tooltips.example.ts +0 -65
- package/src/speed-dial/index.ts +0 -1
- package/src/speed-dial/speed-dial.css +0 -137
- package/src/speed-dial/speed-dial.playground.ts +0 -137
- package/src/speed-dial/speed-dial.spec.ts +0 -191
- package/src/speed-dial/speed-dial.ts +0 -257
- package/src/spinner/_examples/index.ts +0 -8
- package/src/spinner/_examples/spinner.animations.example.ts +0 -54
- package/src/spinner/_examples/spinner.example.ts +0 -26
- package/src/spinner/_examples/spinner.in-button.example.ts +0 -51
- package/src/spinner/_examples/spinner.sizes.example.ts +0 -31
- package/src/spinner/_examples/spinner.usage.example.ts +0 -45
- package/src/spinner/_examples/spinner.variants.example.ts +0 -34
- package/src/spinner/index.ts +0 -1
- package/src/spinner/spinner.css +0 -161
- package/src/spinner/spinner.playground.ts +0 -68
- package/src/spinner/spinner.spec.ts +0 -184
- package/src/spinner/spinner.ts +0 -185
- package/src/stepper/_examples/index.ts +0 -8
- package/src/stepper/_examples/stepper.example.ts +0 -62
- package/src/stepper/_examples/stepper.non-linear.example.ts +0 -63
- package/src/stepper/_examples/stepper.optional-step.example.ts +0 -62
- package/src/stepper/_examples/stepper.usage.example.ts +0 -73
- package/src/stepper/_examples/stepper.vertical.example.ts +0 -66
- package/src/stepper/_examples/stepper.with-error.example.ts +0 -63
- package/src/stepper/index.ts +0 -1
- package/src/stepper/stepper.css +0 -147
- package/src/stepper/stepper.playground.ts +0 -88
- package/src/stepper/stepper.spec.ts +0 -200
- package/src/stepper/stepper.ts +0 -242
- package/src/table/_examples/index.ts +0 -23
- package/src/table/_examples/table.column-pinning.example.ts +0 -55
- package/src/table/_examples/table.column-resize.example.ts +0 -49
- package/src/table/_examples/table.column-visibility.example.ts +0 -52
- package/src/table/_examples/table.density.example.ts +0 -71
- package/src/table/_examples/table.editable.example.ts +0 -85
- package/src/table/_examples/table.empty-and-error.example.ts +0 -112
- package/src/table/_examples/table.example.ts +0 -45
- package/src/table/_examples/table.export.example.ts +0 -82
- package/src/table/_examples/table.filterable.example.ts +0 -67
- package/src/table/_examples/table.grouping.example.ts +0 -63
- package/src/table/_examples/table.keyboard.example.ts +0 -115
- package/src/table/_examples/table.master-detail.example.ts +0 -102
- package/src/table/_examples/table.persistence.example.ts +0 -85
- package/src/table/_examples/table.playground.ts +0 -154
- package/src/table/_examples/table.row-pinning.example.ts +0 -71
- package/src/table/_examples/table.selection.example.ts +0 -67
- package/src/table/_examples/table.server-mode.example.ts +0 -120
- package/src/table/_examples/table.sortable.example.ts +0 -49
- package/src/table/_examples/table.theming.example.ts +0 -64
- package/src/table/_examples/table.usage.example.ts +0 -90
- package/src/table/_examples/table.virtualized.example.ts +0 -122
- package/src/table/index.ts +0 -11
- package/src/table/table-cell-editor-outlet.ts +0 -111
- package/src/table/table-editors/boolean-editor.ts +0 -71
- package/src/table/table-editors/date-editor.ts +0 -117
- package/src/table/table-editors/editors.spec.ts +0 -147
- package/src/table/table-editors/index.ts +0 -41
- package/src/table/table-editors/number-editor.ts +0 -89
- package/src/table/table-editors/select-editor.ts +0 -107
- package/src/table/table-editors/text-editor.ts +0 -82
- package/src/table/table-export.spec.ts +0 -33
- package/src/table/table-export.ts +0 -53
- package/src/table/table-filter-outlet.ts +0 -137
- package/src/table/table-filters/date-filter.ts +0 -122
- package/src/table/table-filters/filters.css +0 -53
- package/src/table/table-filters/filters.spec.ts +0 -277
- package/src/table/table-filters/index.ts +0 -11
- package/src/table/table-filters/number-filter.ts +0 -232
- package/src/table/table-filters/select-filter.ts +0 -129
- package/src/table/table-filters/text-filter.ts +0 -110
- package/src/table/table-pagination.spec.ts +0 -118
- package/src/table/table-pagination.ts +0 -191
- package/src/table/table-side-panel.spec.ts +0 -170
- package/src/table/table-side-panel.ts +0 -263
- package/src/table/table-status-bar.spec.ts +0 -78
- package/src/table/table-status-bar.ts +0 -70
- package/src/table/table-toolbar.spec.ts +0 -180
- package/src/table/table-toolbar.ts +0 -244
- package/src/table/table-virtual.spec.ts +0 -103
- package/src/table/table-virtual.ts +0 -180
- package/src/table/table.css +0 -468
- package/src/table/table.spec.ts +0 -175
- package/src/table/table.ts +0 -1009
- package/src/tabs/_examples/index.ts +0 -8
- package/src/tabs/_examples/tabs.controlled.example.ts +0 -59
- package/src/tabs/_examples/tabs.disabled.example.ts +0 -34
- package/src/tabs/_examples/tabs.example.ts +0 -34
- package/src/tabs/_examples/tabs.manual-activation.example.ts +0 -34
- package/src/tabs/_examples/tabs.usage.example.ts +0 -43
- package/src/tabs/_examples/tabs.vertical.example.ts +0 -33
- package/src/tabs/index.ts +0 -1
- package/src/tabs/tabs.css +0 -80
- package/src/tabs/tabs.playground.ts +0 -88
- package/src/tabs/tabs.spec.ts +0 -135
- package/src/tabs/tabs.ts +0 -204
- package/src/tag/_examples/index.ts +0 -9
- package/src/tag/_examples/tag.example.ts +0 -22
- package/src/tag/_examples/tag.list.example.ts +0 -38
- package/src/tag/_examples/tag.removable.example.ts +0 -39
- package/src/tag/_examples/tag.selectable.example.ts +0 -33
- package/src/tag/_examples/tag.sizes.example.ts +0 -25
- package/src/tag/_examples/tag.usage.example.ts +0 -62
- package/src/tag/_examples/tag.variants.example.ts +0 -29
- package/src/tag/index.ts +0 -1
- package/src/tag/tag.css +0 -167
- package/src/tag/tag.playground.ts +0 -63
- package/src/tag/tag.spec.ts +0 -153
- package/src/tag/tag.ts +0 -186
- package/src/test-setup.ts +0 -5
- package/src/textarea/_examples/index.ts +0 -8
- package/src/textarea/_examples/textarea.autoresize.example.ts +0 -37
- package/src/textarea/_examples/textarea.character-count.example.ts +0 -34
- package/src/textarea/_examples/textarea.example.ts +0 -22
- package/src/textarea/_examples/textarea.no-resize.example.ts +0 -28
- package/src/textarea/_examples/textarea.usage.example.ts +0 -50
- package/src/textarea/_examples/textarea.with-field.example.ts +0 -66
- package/src/textarea/index.ts +0 -1
- package/src/textarea/textarea.css +0 -117
- package/src/textarea/textarea.playground.ts +0 -70
- package/src/textarea/textarea.spec.ts +0 -161
- package/src/textarea/textarea.ts +0 -339
- package/src/time-picker/_examples/index.ts +0 -8
- package/src/time-picker/_examples/time-picker.12-hour.example.ts +0 -24
- package/src/time-picker/_examples/time-picker.example.ts +0 -24
- package/src/time-picker/_examples/time-picker.formatted.example.ts +0 -32
- package/src/time-picker/_examples/time-picker.range.example.ts +0 -54
- package/src/time-picker/_examples/time-picker.usage.example.ts +0 -53
- package/src/time-picker/_examples/time-picker.with-seconds.example.ts +0 -24
- package/src/time-picker/index.ts +0 -1
- package/src/time-picker/time-picker.css +0 -126
- package/src/time-picker/time-picker.playground.ts +0 -72
- package/src/time-picker/time-picker.spec.ts +0 -77
- package/src/time-picker/time-picker.ts +0 -207
- package/src/toast/_examples/index.ts +0 -7
- package/src/toast/_examples/toast.default.example.ts +0 -37
- package/src/toast/_examples/toast.dismissible.example.ts +0 -38
- package/src/toast/_examples/toast.usage.example.ts +0 -57
- package/src/toast/_examples/toast.variants.example.ts +0 -43
- package/src/toast/_examples/toast.with-action.example.ts +0 -46
- package/src/toast/index.ts +0 -1
- package/src/toast/toast.css +0 -115
- package/src/toast/toast.playground.ts +0 -61
- package/src/toast/toast.ts +0 -168
- package/src/toggle/_examples/index.ts +0 -7
- package/src/toggle/_examples/toggle.checked.example.ts +0 -20
- package/src/toggle/_examples/toggle.default.example.ts +0 -20
- package/src/toggle/_examples/toggle.disabled.example.ts +0 -26
- package/src/toggle/_examples/toggle.usage.example.ts +0 -51
- package/src/toggle/_examples/toggle.with-label.example.ts +0 -30
- package/src/toggle/index.ts +0 -1
- package/src/toggle/toggle.css +0 -123
- package/src/toggle/toggle.playground.ts +0 -65
- package/src/toggle/toggle.ts +0 -113
- package/src/tooltip/_examples/index.ts +0 -9
- package/src/tooltip/_examples/tooltip.delays.example.ts +0 -16
- package/src/tooltip/_examples/tooltip.disabled.example.ts +0 -16
- package/src/tooltip/_examples/tooltip.example.ts +0 -16
- package/src/tooltip/_examples/tooltip.group.example.ts +0 -20
- package/src/tooltip/_examples/tooltip.rich.example.ts +0 -19
- package/src/tooltip/_examples/tooltip.sides.example.ts +0 -18
- package/src/tooltip/_examples/tooltip.usage.example.ts +0 -50
- package/src/tooltip/index.ts +0 -1
- package/src/tooltip/tooltip.css +0 -61
- package/src/tooltip/tooltip.playground.ts +0 -79
- package/src/tooltip/tooltip.spec.ts +0 -5
- package/src/tooltip/tooltip.ts +0 -102
- package/src/tree-select/_examples/index.ts +0 -8
- package/src/tree-select/_examples/tree-select.disabled.example.ts +0 -106
- package/src/tree-select/_examples/tree-select.example.ts +0 -65
- package/src/tree-select/_examples/tree-select.expanded.example.ts +0 -72
- package/src/tree-select/_examples/tree-select.field.example.ts +0 -77
- package/src/tree-select/_examples/tree-select.multi.example.ts +0 -73
- package/src/tree-select/_examples/tree-select.usage.example.ts +0 -85
- package/src/tree-select/index.ts +0 -1
- package/src/tree-select/tree-select.css +0 -220
- package/src/tree-select/tree-select.playground.ts +0 -83
- package/src/tree-select/tree-select.ts +0 -348
- package/src/typography/_examples/index.ts +0 -9
- package/src/typography/_examples/typography.blockquote.example.ts +0 -34
- package/src/typography/_examples/typography.code.example.ts +0 -32
- package/src/typography/_examples/typography.example.ts +0 -42
- package/src/typography/_examples/typography.lead.example.ts +0 -37
- package/src/typography/_examples/typography.muted.example.ts +0 -27
- package/src/typography/_examples/typography.truncate.example.ts +0 -41
- package/src/typography/_examples/typography.usage.example.ts +0 -44
- package/src/typography/index.ts +0 -8
- package/src/typography/typography.playground.ts +0 -101
- package/src/typography/typography.spec.ts +0 -70
- package/src/typography/typography.ts +0 -105
- package/tsconfig.lib.json +0 -25
- package/tsconfig.lib.prod.json +0 -17
- package/tsconfig.spec.json +0 -16
- package/vite.config.ts +0 -33
|
@@ -1,277 +0,0 @@
|
|
|
1
|
-
import { TestBed } from '@angular/core/testing';
|
|
2
|
-
import { By } from '@angular/platform-browser';
|
|
3
|
-
import type { Column, Table } from '@tanstack/angular-table';
|
|
4
|
-
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
5
|
-
import { KjSelect } from '@kouji-ui/core';
|
|
6
|
-
import { KjSelectComponent } from '../../select/select';
|
|
7
|
-
import { KjDatePickerComponent } from '../../date-picker/date-picker';
|
|
8
|
-
import { KjNumberInputComponent } from '../../number-input/number-input';
|
|
9
|
-
import {
|
|
10
|
-
KJ_FILTER_CONTEXT,
|
|
11
|
-
type KjFilterContext,
|
|
12
|
-
} from './text-filter';
|
|
13
|
-
import { KjTextFilter } from './text-filter';
|
|
14
|
-
import { KjNumberFilter } from './number-filter';
|
|
15
|
-
import { KjDateFilter } from './date-filter';
|
|
16
|
-
import { KjSelectFilter } from './select-filter';
|
|
17
|
-
|
|
18
|
-
interface StubColumn {
|
|
19
|
-
id: string;
|
|
20
|
-
columnDef: { header: string };
|
|
21
|
-
getFilterValue: ReturnType<typeof vi.fn>;
|
|
22
|
-
setFilterValue: ReturnType<typeof vi.fn>;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function makeColumn(opts: {
|
|
26
|
-
header?: string;
|
|
27
|
-
id?: string;
|
|
28
|
-
initial?: unknown;
|
|
29
|
-
} = {}): StubColumn {
|
|
30
|
-
return {
|
|
31
|
-
id: opts.id ?? 'col',
|
|
32
|
-
columnDef: { header: opts.header ?? 'Name' },
|
|
33
|
-
getFilterValue: vi.fn().mockReturnValue(opts.initial),
|
|
34
|
-
setFilterValue: vi.fn(),
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function toLocalIso(d: Date | null | undefined): string | null {
|
|
39
|
-
if (!d) return null;
|
|
40
|
-
const y = d.getFullYear();
|
|
41
|
-
const m = String(d.getMonth() + 1).padStart(2, '0');
|
|
42
|
-
const day = String(d.getDate()).padStart(2, '0');
|
|
43
|
-
return `${y}-${m}-${day}`;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function provideCtx(column: StubColumn): { provide: typeof KJ_FILTER_CONTEXT; useValue: KjFilterContext } {
|
|
47
|
-
const ctx: KjFilterContext = {
|
|
48
|
-
column: column as unknown as Column<unknown, unknown>,
|
|
49
|
-
table: {} as Table<unknown>,
|
|
50
|
-
};
|
|
51
|
-
return { provide: KJ_FILTER_CONTEXT, useValue: ctx };
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// ---------- KjTextFilter ----------
|
|
55
|
-
|
|
56
|
-
describe('KjTextFilter', () => {
|
|
57
|
-
beforeEach(() => {
|
|
58
|
-
vi.useFakeTimers();
|
|
59
|
-
});
|
|
60
|
-
afterEach(() => {
|
|
61
|
-
vi.useRealTimers();
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it('seeds the input from column.getFilterValue() on init', () => {
|
|
65
|
-
const column = makeColumn({ header: 'Name', initial: 'alice' });
|
|
66
|
-
TestBed.configureTestingModule({
|
|
67
|
-
imports: [KjTextFilter],
|
|
68
|
-
providers: [provideCtx(column)],
|
|
69
|
-
});
|
|
70
|
-
const fixture = TestBed.createComponent(KjTextFilter);
|
|
71
|
-
fixture.detectChanges();
|
|
72
|
-
expect(column.getFilterValue).toHaveBeenCalled();
|
|
73
|
-
const input = fixture.nativeElement.querySelector('input') as HTMLInputElement;
|
|
74
|
-
expect(input.value).toBe('alice');
|
|
75
|
-
// Accessible name comes from the wrapping <label>'s visually-hidden caption.
|
|
76
|
-
const labelText = (fixture.nativeElement.querySelector('label')?.textContent ?? '').trim();
|
|
77
|
-
expect(labelText).toBe('Filter by Name');
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
it('typing calls column.setFilterValue after the 300ms debounce', () => {
|
|
81
|
-
const column = makeColumn({ header: 'Name' });
|
|
82
|
-
TestBed.configureTestingModule({
|
|
83
|
-
imports: [KjTextFilter],
|
|
84
|
-
providers: [provideCtx(column)],
|
|
85
|
-
});
|
|
86
|
-
const fixture = TestBed.createComponent(KjTextFilter);
|
|
87
|
-
fixture.detectChanges();
|
|
88
|
-
const input = fixture.nativeElement.querySelector('input') as HTMLInputElement;
|
|
89
|
-
|
|
90
|
-
input.value = 'bob';
|
|
91
|
-
input.dispatchEvent(new Event('input', { bubbles: true }));
|
|
92
|
-
// Before debounce elapses, no write.
|
|
93
|
-
expect(column.setFilterValue).not.toHaveBeenCalled();
|
|
94
|
-
|
|
95
|
-
vi.advanceTimersByTime(300);
|
|
96
|
-
expect(column.setFilterValue).toHaveBeenCalledTimes(1);
|
|
97
|
-
expect(column.setFilterValue).toHaveBeenCalledWith({
|
|
98
|
-
filterType: 'text',
|
|
99
|
-
type: 'contains',
|
|
100
|
-
filter: 'bob',
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
// ---------- KjNumberFilter ----------
|
|
106
|
-
|
|
107
|
-
describe('KjNumberFilter', () => {
|
|
108
|
-
it('seeds the inRange operator + both inputs from a legacy [min, max] tuple', () => {
|
|
109
|
-
const column = makeColumn({ header: 'Age', initial: [18, 65] });
|
|
110
|
-
TestBed.configureTestingModule({
|
|
111
|
-
imports: [KjNumberFilter],
|
|
112
|
-
providers: [provideCtx(column)],
|
|
113
|
-
});
|
|
114
|
-
const fixture = TestBed.createComponent(KjNumberFilter);
|
|
115
|
-
fixture.detectChanges();
|
|
116
|
-
const pickers = fixture.debugElement
|
|
117
|
-
.queryAll(By.directive(KjNumberInputComponent))
|
|
118
|
-
.map((d) => d.componentInstance as KjNumberInputComponent);
|
|
119
|
-
expect(pickers.length).toBe(2);
|
|
120
|
-
expect(pickers[0].kjValue()).toBe(18);
|
|
121
|
-
expect(pickers[1].kjValue()).toBe(65);
|
|
122
|
-
expect(pickers[0].kjAriaLabel()).toBe('Filter Age minimum');
|
|
123
|
-
expect(pickers[1].kjAriaLabel()).toBe('Filter Age maximum');
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
it('default operator is `equals` and renders a single primary input', () => {
|
|
127
|
-
const column = makeColumn({ header: 'Age' });
|
|
128
|
-
TestBed.configureTestingModule({
|
|
129
|
-
imports: [KjNumberFilter],
|
|
130
|
-
providers: [provideCtx(column)],
|
|
131
|
-
});
|
|
132
|
-
const fixture = TestBed.createComponent(KjNumberFilter);
|
|
133
|
-
fixture.detectChanges();
|
|
134
|
-
const pickers = fixture.debugElement.queryAll(By.directive(KjNumberInputComponent));
|
|
135
|
-
expect(pickers.length).toBe(1);
|
|
136
|
-
(pickers[0].componentInstance as KjNumberInputComponent).kjValue.set(21);
|
|
137
|
-
expect(column.setFilterValue).toHaveBeenLastCalledWith({
|
|
138
|
-
filterType: 'number', type: 'equals', filter: 21,
|
|
139
|
-
});
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
it('switching operator to `inRange` via the native <select> reveals the second input', () => {
|
|
143
|
-
const column = makeColumn({ header: 'Age' });
|
|
144
|
-
TestBed.configureTestingModule({
|
|
145
|
-
imports: [KjNumberFilter],
|
|
146
|
-
providers: [provideCtx(column)],
|
|
147
|
-
});
|
|
148
|
-
const fixture = TestBed.createComponent(KjNumberFilter);
|
|
149
|
-
fixture.detectChanges();
|
|
150
|
-
const select = fixture.debugElement.query(By.directive(KjSelectComponent));
|
|
151
|
-
expect(select).toBeTruthy();
|
|
152
|
-
select.triggerEventHandler('valueChange', 'inRange');
|
|
153
|
-
fixture.detectChanges();
|
|
154
|
-
const pickers = fixture.debugElement.queryAll(By.directive(KjNumberInputComponent));
|
|
155
|
-
expect(pickers.length).toBe(2);
|
|
156
|
-
(pickers[0].componentInstance as KjNumberInputComponent).kjValue.set(10);
|
|
157
|
-
(pickers[1].componentInstance as KjNumberInputComponent).kjValue.set(20);
|
|
158
|
-
expect(column.setFilterValue).toHaveBeenLastCalledWith({
|
|
159
|
-
filterType: 'number', type: 'inRange', filter: 10, filterTo: 20,
|
|
160
|
-
});
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
it('`blank` operator hides the inputs and writes a no-value model', () => {
|
|
164
|
-
const column = makeColumn({ header: 'Age' });
|
|
165
|
-
TestBed.configureTestingModule({
|
|
166
|
-
imports: [KjNumberFilter],
|
|
167
|
-
providers: [provideCtx(column)],
|
|
168
|
-
});
|
|
169
|
-
const fixture = TestBed.createComponent(KjNumberFilter);
|
|
170
|
-
fixture.detectChanges();
|
|
171
|
-
const select = fixture.debugElement.query(By.directive(KjSelectComponent));
|
|
172
|
-
select.triggerEventHandler('valueChange', 'blank');
|
|
173
|
-
fixture.detectChanges();
|
|
174
|
-
const pickers = fixture.debugElement.queryAll(By.directive(KjNumberInputComponent));
|
|
175
|
-
expect(pickers.length).toBe(0);
|
|
176
|
-
expect(column.setFilterValue).toHaveBeenLastCalledWith({
|
|
177
|
-
filterType: 'number', type: 'blank',
|
|
178
|
-
});
|
|
179
|
-
});
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
// ---------- KjDateFilter ----------
|
|
183
|
-
|
|
184
|
-
describe('KjDateFilter', () => {
|
|
185
|
-
it('seeds both from/to inputs from an existing [from, to] tuple', () => {
|
|
186
|
-
const column = makeColumn({
|
|
187
|
-
header: 'Joined',
|
|
188
|
-
initial: ['2024-01-01', '2024-12-31'],
|
|
189
|
-
});
|
|
190
|
-
TestBed.configureTestingModule({
|
|
191
|
-
imports: [KjDateFilter],
|
|
192
|
-
providers: [provideCtx(column)],
|
|
193
|
-
});
|
|
194
|
-
const fixture = TestBed.createComponent(KjDateFilter);
|
|
195
|
-
fixture.detectChanges();
|
|
196
|
-
const [fromPicker, toPicker] = fixture.debugElement
|
|
197
|
-
.queryAll(By.directive(KjDatePickerComponent))
|
|
198
|
-
.map((d) => d.componentInstance as KjDatePickerComponent);
|
|
199
|
-
expect(toLocalIso(fromPicker.kjValue())).toBe('2024-01-01');
|
|
200
|
-
expect(toLocalIso(toPicker.kjValue())).toBe('2024-12-31');
|
|
201
|
-
const captions = Array.from(
|
|
202
|
-
fixture.nativeElement.querySelectorAll('.kj-date-filter__caption'),
|
|
203
|
-
) as HTMLElement[];
|
|
204
|
-
expect((captions[0].textContent ?? '').trim()).toBe('Filter by Joined from date');
|
|
205
|
-
expect((captions[1].textContent ?? '').trim()).toBe('Filter by Joined to date');
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
it('typing in from/to writes a [from, to] tuple via setFilterValue', () => {
|
|
209
|
-
const column = makeColumn({ header: 'Joined' });
|
|
210
|
-
TestBed.configureTestingModule({
|
|
211
|
-
imports: [KjDateFilter],
|
|
212
|
-
providers: [provideCtx(column)],
|
|
213
|
-
});
|
|
214
|
-
const fixture = TestBed.createComponent(KjDateFilter);
|
|
215
|
-
fixture.detectChanges();
|
|
216
|
-
const [fromPicker, toPicker] = fixture.debugElement
|
|
217
|
-
.queryAll(By.directive(KjDatePickerComponent))
|
|
218
|
-
.map((d) => d.componentInstance as KjDatePickerComponent);
|
|
219
|
-
|
|
220
|
-
fromPicker.kjValue.set(new Date(2025, 2, 1));
|
|
221
|
-
expect(column.setFilterValue).toHaveBeenLastCalledWith({
|
|
222
|
-
filterType: 'date', type: 'inRange', dateFrom: '2025-03-01', dateTo: undefined,
|
|
223
|
-
});
|
|
224
|
-
|
|
225
|
-
toPicker.kjValue.set(new Date(2025, 3, 1));
|
|
226
|
-
expect(column.setFilterValue).toHaveBeenLastCalledWith({
|
|
227
|
-
filterType: 'date', type: 'inRange', dateFrom: '2025-03-01', dateTo: '2025-04-01',
|
|
228
|
-
});
|
|
229
|
-
});
|
|
230
|
-
});
|
|
231
|
-
|
|
232
|
-
// ---------- KjSelectFilter ----------
|
|
233
|
-
|
|
234
|
-
describe('KjSelectFilter', () => {
|
|
235
|
-
const OPTIONS = [
|
|
236
|
-
{ label: 'Active', value: 'active' },
|
|
237
|
-
{ label: 'Archived', value: 'archived' },
|
|
238
|
-
];
|
|
239
|
-
|
|
240
|
-
it('seeds the dropdown to the option matching column.getFilterValue()', () => {
|
|
241
|
-
const column = makeColumn({ header: 'Status', initial: 'archived' });
|
|
242
|
-
TestBed.configureTestingModule({
|
|
243
|
-
imports: [KjSelectFilter],
|
|
244
|
-
providers: [provideCtx(column)],
|
|
245
|
-
});
|
|
246
|
-
const fixture = TestBed.createComponent(KjSelectFilter);
|
|
247
|
-
fixture.componentRef.setInput('options', OPTIONS);
|
|
248
|
-
fixture.detectChanges();
|
|
249
|
-
const select = fixture.debugElement.query(By.directive(KjSelect))
|
|
250
|
-
.injector.get(KjSelect);
|
|
251
|
-
// "archived" is at OPTIONS[1] → key "1".
|
|
252
|
-
expect(select.kjSelectValue()).toBe('1');
|
|
253
|
-
const labelText = (fixture.nativeElement.querySelector('label')?.textContent ?? '').trim();
|
|
254
|
-
expect(labelText).toContain('Filter by Status');
|
|
255
|
-
});
|
|
256
|
-
|
|
257
|
-
it('selecting an option writes its raw value; selecting "All" clears the filter', () => {
|
|
258
|
-
const column = makeColumn({ header: 'Status' });
|
|
259
|
-
TestBed.configureTestingModule({
|
|
260
|
-
imports: [KjSelectFilter],
|
|
261
|
-
providers: [provideCtx(column)],
|
|
262
|
-
});
|
|
263
|
-
const fixture = TestBed.createComponent(KjSelectFilter);
|
|
264
|
-
fixture.componentRef.setInput('options', OPTIONS);
|
|
265
|
-
fixture.detectChanges();
|
|
266
|
-
const select = fixture.debugElement.query(By.directive(KjSelect))
|
|
267
|
-
.injector.get(KjSelect);
|
|
268
|
-
|
|
269
|
-
select.kjSelectValue.set('0'); // "Active"
|
|
270
|
-
expect(column.setFilterValue).toHaveBeenLastCalledWith({
|
|
271
|
-
filterType: 'set', values: ['active'],
|
|
272
|
-
});
|
|
273
|
-
|
|
274
|
-
select.kjSelectValue.set('__kj_filter_all__');
|
|
275
|
-
expect(column.setFilterValue).toHaveBeenLastCalledWith(undefined);
|
|
276
|
-
});
|
|
277
|
-
});
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export {
|
|
2
|
-
KJ_FILTER_CONTEXT,
|
|
3
|
-
KjTextFilter,
|
|
4
|
-
type KjFilterContext,
|
|
5
|
-
} from './text-filter';
|
|
6
|
-
export { KjNumberFilter, type KjNumberRange } from './number-filter';
|
|
7
|
-
export { KjDateFilter, type KjDateRange } from './date-filter';
|
|
8
|
-
export {
|
|
9
|
-
KjSelectFilter,
|
|
10
|
-
type KjSelectFilterOption,
|
|
11
|
-
} from './select-filter';
|
|
@@ -1,232 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ChangeDetectionStrategy,
|
|
3
|
-
Component,
|
|
4
|
-
ViewEncapsulation,
|
|
5
|
-
computed,
|
|
6
|
-
inject,
|
|
7
|
-
signal,
|
|
8
|
-
} from '@angular/core';
|
|
9
|
-
import type { Column } from '@tanstack/angular-table';
|
|
10
|
-
import type { KjNumberFilterModel, KjNumberFilterType } from '@kouji-ui/core';
|
|
11
|
-
import { KjNumberInputComponent } from '../../number-input/number-input';
|
|
12
|
-
import { KjOptionComponent, KjSelectComponent } from '../../select/select';
|
|
13
|
-
import { KJ_FILTER_CONTEXT, type KjFilterContext } from './text-filter';
|
|
14
|
-
|
|
15
|
-
/** Legacy tuple shape — kept exported because external consumers still pass
|
|
16
|
-
* `[min, max]` into `column.setFilterValue` for `inRange`-style filters. */
|
|
17
|
-
export type KjNumberRange = [min: number | undefined, max: number | undefined];
|
|
18
|
-
|
|
19
|
-
interface OperatorDescriptor {
|
|
20
|
-
readonly value: KjNumberFilterType;
|
|
21
|
-
readonly label: string;
|
|
22
|
-
/** How many number inputs to render after the operator picker. */
|
|
23
|
-
readonly inputs: 0 | 1 | 2;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/** Operators offered by the number filter, in display order. */
|
|
27
|
-
const OPERATORS: readonly OperatorDescriptor[] = [
|
|
28
|
-
{ value: 'equals', label: '=', inputs: 1 },
|
|
29
|
-
{ value: 'notEquals', label: '≠', inputs: 1 },
|
|
30
|
-
{ value: 'greaterThan', label: '>', inputs: 1 },
|
|
31
|
-
{ value: 'greaterThanOrEqual', label: '≥', inputs: 1 },
|
|
32
|
-
{ value: 'lessThan', label: '<', inputs: 1 },
|
|
33
|
-
{ value: 'lessThanOrEqual', label: '≤', inputs: 1 },
|
|
34
|
-
{ value: 'inRange', label: 'Between', inputs: 2 },
|
|
35
|
-
{ value: 'blank', label: 'Is blank', inputs: 0 },
|
|
36
|
-
{ value: 'notBlank', label: 'Not blank', inputs: 0 },
|
|
37
|
-
];
|
|
38
|
-
|
|
39
|
-
const OP_BY_VALUE: ReadonlyMap<KjNumberFilterType, OperatorDescriptor> = new Map(
|
|
40
|
-
OPERATORS.map(o => [o.value, o] as const),
|
|
41
|
-
);
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Number filter UI: an operator picker followed by one or two compact number
|
|
45
|
-
* inputs (zero for `blank` / `notBlank`). Writes a structured
|
|
46
|
-
* {@link KjNumberFilterModel} to `column.setFilterValue(...)` so the filter
|
|
47
|
-
* round-trips through `gridApi.filter.getModel()` for SSR backends.
|
|
48
|
-
*
|
|
49
|
-
* Backwards-compatibility: an `[min, max]` tuple persisted by the previous
|
|
50
|
-
* iteration is read on init and surfaced as `inRange`, so users who saved a
|
|
51
|
-
* table state under the old shape don't lose their filter.
|
|
52
|
-
*
|
|
53
|
-
* @doc-keyboard
|
|
54
|
-
* Tab — Moves focus between the operator picker and the inputs
|
|
55
|
-
* Enter — Commits the typed value (native number input semantics)
|
|
56
|
-
* ArrowUp/Down — Increment / decrement the focused input by 1
|
|
57
|
-
*/
|
|
58
|
-
@Component({
|
|
59
|
-
selector: 'kj-number-filter',
|
|
60
|
-
standalone: true,
|
|
61
|
-
imports: [KjNumberInputComponent, KjSelectComponent, KjOptionComponent],
|
|
62
|
-
styleUrl: './filters.css',
|
|
63
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
64
|
-
encapsulation: ViewEncapsulation.None,
|
|
65
|
-
host: {
|
|
66
|
-
class: 'kj-number-filter',
|
|
67
|
-
},
|
|
68
|
-
template: `
|
|
69
|
-
<kj-select
|
|
70
|
-
class="kj-number-filter__operator"
|
|
71
|
-
kjSize="xs"
|
|
72
|
-
[value]="operator()"
|
|
73
|
-
(valueChange)="onOperatorChange($event)"
|
|
74
|
-
[attr.aria-label]="operatorAriaLabel()"
|
|
75
|
-
>
|
|
76
|
-
@for (op of operators; track op.value) {
|
|
77
|
-
<kj-option [value]="op.value" [kjLabel]="op.label">{{ op.label }}</kj-option>
|
|
78
|
-
}
|
|
79
|
-
</kj-select>
|
|
80
|
-
|
|
81
|
-
@if (inputsForOperator() >= 1) {
|
|
82
|
-
<kj-number-input
|
|
83
|
-
class="kj-number-filter__input kj-number-filter__input--primary"
|
|
84
|
-
kjSize="xs"
|
|
85
|
-
[kjAriaLabel]="primaryAriaLabel()"
|
|
86
|
-
[kjValue]="$any(primary())"
|
|
87
|
-
(kjValueChange)="onPrimaryChange($event)"
|
|
88
|
-
/>
|
|
89
|
-
}
|
|
90
|
-
@if (inputsForOperator() === 2) {
|
|
91
|
-
<kj-number-input
|
|
92
|
-
class="kj-number-filter__input kj-number-filter__input--secondary"
|
|
93
|
-
kjSize="xs"
|
|
94
|
-
[kjAriaLabel]="secondaryAriaLabel()"
|
|
95
|
-
[kjValue]="$any(secondary())"
|
|
96
|
-
(kjValueChange)="onSecondaryChange($event)"
|
|
97
|
-
/>
|
|
98
|
-
}
|
|
99
|
-
`,
|
|
100
|
-
})
|
|
101
|
-
export class KjNumberFilter<TData = unknown> {
|
|
102
|
-
private readonly ctx = inject<KjFilterContext<TData>>(KJ_FILTER_CONTEXT);
|
|
103
|
-
|
|
104
|
-
/** @internal — exposed for template iteration. */
|
|
105
|
-
protected readonly operators = OPERATORS;
|
|
106
|
-
|
|
107
|
-
protected readonly operator = signal<KjNumberFilterType>('equals');
|
|
108
|
-
protected readonly primary = signal<number | undefined>(undefined);
|
|
109
|
-
protected readonly secondary = signal<number | undefined>(undefined);
|
|
110
|
-
|
|
111
|
-
protected readonly inputsForOperator = computed(
|
|
112
|
-
() => OP_BY_VALUE.get(this.operator())?.inputs ?? 1,
|
|
113
|
-
);
|
|
114
|
-
|
|
115
|
-
private readonly columnLabel = computed(() => headerLabel(this.ctx.column));
|
|
116
|
-
protected readonly operatorAriaLabel = computed(
|
|
117
|
-
() => `${this.columnLabel()} filter operator`,
|
|
118
|
-
);
|
|
119
|
-
protected readonly primaryAriaLabel = computed(() => {
|
|
120
|
-
const op = OP_BY_VALUE.get(this.operator());
|
|
121
|
-
return op?.inputs === 2
|
|
122
|
-
? `Filter ${this.columnLabel()} minimum`
|
|
123
|
-
: `Filter ${this.columnLabel()} value`;
|
|
124
|
-
});
|
|
125
|
-
protected readonly secondaryAriaLabel = computed(
|
|
126
|
-
() => `Filter ${this.columnLabel()} maximum`,
|
|
127
|
-
);
|
|
128
|
-
|
|
129
|
-
constructor() {
|
|
130
|
-
// Seed from any pre-existing filter value, honouring three shapes:
|
|
131
|
-
// - new structured `KjNumberFilterModel`
|
|
132
|
-
// - legacy `[min, max]` tuple (still emitted by URL state from older clients)
|
|
133
|
-
// - empty / null / undefined → defaults
|
|
134
|
-
const v = this.ctx.column.getFilterValue();
|
|
135
|
-
if (Array.isArray(v)) {
|
|
136
|
-
const [min, max] = v as KjNumberRange;
|
|
137
|
-
// [n, undefined] → equals; [undefined, n] → equals on n; [a, b] → inRange.
|
|
138
|
-
if (min !== undefined && max !== undefined) {
|
|
139
|
-
this.operator.set('inRange');
|
|
140
|
-
this.primary.set(min);
|
|
141
|
-
this.secondary.set(max);
|
|
142
|
-
} else if (min !== undefined) {
|
|
143
|
-
this.operator.set('greaterThanOrEqual');
|
|
144
|
-
this.primary.set(min);
|
|
145
|
-
} else if (max !== undefined) {
|
|
146
|
-
this.operator.set('lessThanOrEqual');
|
|
147
|
-
this.primary.set(max);
|
|
148
|
-
}
|
|
149
|
-
} else if (v && typeof v === 'object'
|
|
150
|
-
&& (v as { filterType?: string }).filterType === 'number') {
|
|
151
|
-
const m = v as KjNumberFilterModel;
|
|
152
|
-
this.operator.set(m.type);
|
|
153
|
-
this.primary.set(m.filter);
|
|
154
|
-
this.secondary.set(m.filterTo);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
protected onOperatorChange(next: unknown): void {
|
|
159
|
-
const op = (typeof next === 'string' ? next : String(next ?? '')) as KjNumberFilterType;
|
|
160
|
-
if (!OP_BY_VALUE.has(op)) return;
|
|
161
|
-
const descriptor = OP_BY_VALUE.get(op)!;
|
|
162
|
-
this.operator.set(op);
|
|
163
|
-
// Drop the secondary input when we're no longer in a 2-input operator;
|
|
164
|
-
// drop both when switching to `blank` / `notBlank`. This keeps the model
|
|
165
|
-
// shape consistent with `descriptor.inputs`.
|
|
166
|
-
if (descriptor.inputs === 0) {
|
|
167
|
-
this.primary.set(undefined);
|
|
168
|
-
this.secondary.set(undefined);
|
|
169
|
-
} else if (descriptor.inputs === 1) {
|
|
170
|
-
this.secondary.set(undefined);
|
|
171
|
-
}
|
|
172
|
-
this.commit();
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
protected onPrimaryChange(value: number | null): void {
|
|
176
|
-
this.primary.set(normalise(value));
|
|
177
|
-
this.commit();
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
protected onSecondaryChange(value: number | null): void {
|
|
181
|
-
this.secondary.set(normalise(value));
|
|
182
|
-
this.commit();
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
private commit(): void {
|
|
186
|
-
const type = this.operator();
|
|
187
|
-
const descriptor = OP_BY_VALUE.get(type);
|
|
188
|
-
if (!descriptor) {
|
|
189
|
-
this.ctx.column.setFilterValue(undefined);
|
|
190
|
-
return;
|
|
191
|
-
}
|
|
192
|
-
if (descriptor.inputs === 0) {
|
|
193
|
-
const model: KjNumberFilterModel = { filterType: 'number', type };
|
|
194
|
-
this.ctx.column.setFilterValue(model);
|
|
195
|
-
return;
|
|
196
|
-
}
|
|
197
|
-
const primary = this.primary();
|
|
198
|
-
// 1- or 2-input operator with no primary set is a no-op (cleared state).
|
|
199
|
-
if (primary === undefined && descriptor.inputs >= 1) {
|
|
200
|
-
this.ctx.column.setFilterValue(undefined);
|
|
201
|
-
return;
|
|
202
|
-
}
|
|
203
|
-
if (descriptor.inputs === 1) {
|
|
204
|
-
const model: KjNumberFilterModel = { filterType: 'number', type, filter: primary };
|
|
205
|
-
this.ctx.column.setFilterValue(model);
|
|
206
|
-
return;
|
|
207
|
-
}
|
|
208
|
-
// inRange (2 inputs): keep the filter active even when only one side is
|
|
209
|
-
// typed — TanStack's matcher reads the open side as ±∞.
|
|
210
|
-
const secondary = this.secondary();
|
|
211
|
-
if (primary === undefined && secondary === undefined) {
|
|
212
|
-
this.ctx.column.setFilterValue(undefined);
|
|
213
|
-
return;
|
|
214
|
-
}
|
|
215
|
-
const model: KjNumberFilterModel = {
|
|
216
|
-
filterType: 'number',
|
|
217
|
-
type,
|
|
218
|
-
filter: primary,
|
|
219
|
-
filterTo: secondary,
|
|
220
|
-
};
|
|
221
|
-
this.ctx.column.setFilterValue(model);
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
function normalise(value: number | null | undefined): number | undefined {
|
|
226
|
-
return value != null && Number.isFinite(value) ? value : undefined;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
function headerLabel<TData>(column: Column<TData, unknown>): string {
|
|
230
|
-
const header = column.columnDef.header;
|
|
231
|
-
return typeof header === 'string' ? header : column.id;
|
|
232
|
-
}
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ChangeDetectionStrategy,
|
|
3
|
-
Component,
|
|
4
|
-
ViewEncapsulation,
|
|
5
|
-
computed,
|
|
6
|
-
inject,
|
|
7
|
-
input,
|
|
8
|
-
} from '@angular/core';
|
|
9
|
-
import type { Column } from '@tanstack/angular-table';
|
|
10
|
-
import { KjVisuallyHidden, type KjColumnMeta, type KjSetFilterModel } from '@kouji-ui/core';
|
|
11
|
-
import { KjOptionComponent, KjSelectComponent } from '../../select/select';
|
|
12
|
-
import { KJ_FILTER_CONTEXT, type KjFilterContext } from './text-filter';
|
|
13
|
-
|
|
14
|
-
/** Option descriptor for the select filter dropdown. */
|
|
15
|
-
export interface KjSelectFilterOption {
|
|
16
|
-
readonly label: string;
|
|
17
|
-
readonly value: unknown;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/** Sentinel value used by the "All" option to clear the column filter. */
|
|
21
|
-
const ALL_VALUE = '__kj_filter_all__';
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Select-filter UI. Renders a styled `<kj-select>` bound to the column's
|
|
25
|
-
* filter value. Choosing the leading "All" entry clears the filter
|
|
26
|
-
* (`setFilterValue(undefined)`); any other choice writes the option's
|
|
27
|
-
* `value` verbatim.
|
|
28
|
-
*
|
|
29
|
-
* The dropdown is wrapped in a `<label>` carrying visually-hidden caption
|
|
30
|
-
* text so screen readers announce the filtered column.
|
|
31
|
-
*/
|
|
32
|
-
@Component({
|
|
33
|
-
selector: 'kj-select-filter',
|
|
34
|
-
standalone: true,
|
|
35
|
-
imports: [KjSelectComponent, KjOptionComponent, KjVisuallyHidden],
|
|
36
|
-
styleUrl: './filters.css',
|
|
37
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
38
|
-
encapsulation: ViewEncapsulation.None,
|
|
39
|
-
host: {
|
|
40
|
-
class: 'kj-select-filter',
|
|
41
|
-
},
|
|
42
|
-
template: `
|
|
43
|
-
<div class="kj-select-filter__label">
|
|
44
|
-
<span kjVisuallyHidden>{{ ariaLabel() }}</span>
|
|
45
|
-
<kj-select
|
|
46
|
-
class="kj-select-filter__control"
|
|
47
|
-
kjSize="xs"
|
|
48
|
-
[value]="currentValueKey()"
|
|
49
|
-
(valueChange)="onChange($event)"
|
|
50
|
-
>
|
|
51
|
-
<kj-option [value]="allKey" [kjLabel]="allLabel()">{{ allLabel() }}</kj-option>
|
|
52
|
-
@for (opt of resolvedOptions(); track $index) {
|
|
53
|
-
<kj-option [value]="keyOf($index)" [kjLabel]="opt.label">{{ opt.label }}</kj-option>
|
|
54
|
-
}
|
|
55
|
-
</kj-select>
|
|
56
|
-
</div>
|
|
57
|
-
`,
|
|
58
|
-
})
|
|
59
|
-
export class KjSelectFilter<TData = unknown> {
|
|
60
|
-
private readonly ctx = inject<KjFilterContext<TData>>(KJ_FILTER_CONTEXT);
|
|
61
|
-
|
|
62
|
-
/** Options shown in the dropdown. Optional — if omitted, the filter
|
|
63
|
-
* derives entries from the column's `meta.kj.selectOptions` so consumers
|
|
64
|
-
* don't need to wire two places. The leading "All" entry is rendered
|
|
65
|
-
* automatically either way. */
|
|
66
|
-
readonly options = input<readonly KjSelectFilterOption[] | null>(null);
|
|
67
|
-
/** Label for the "clear filter" entry. */
|
|
68
|
-
readonly allLabel = input<string>('All');
|
|
69
|
-
|
|
70
|
-
/** Effective option set — `[options]` input wins over column meta2ui
|
|
71
|
-
*
|
|
72
|
-
. */
|
|
73
|
-
protected readonly resolvedOptions = computed<readonly KjSelectFilterOption[]>(() => {
|
|
74
|
-
const supplied = this.options();
|
|
75
|
-
if (supplied && supplied.length > 0) return supplied;
|
|
76
|
-
const meta = (this.ctx.column.columnDef.meta as { kj?: KjColumnMeta<TData> } | undefined)?.kj;
|
|
77
|
-
const raw = meta?.selectOptions ?? [];
|
|
78
|
-
return raw.map<KjSelectFilterOption>((o) =>
|
|
79
|
-
typeof o === 'object' && o !== null && 'label' in (o as object) && 'value' in (o as object)
|
|
80
|
-
? (o as KjSelectFilterOption)
|
|
81
|
-
: { label: String(o), value: o },
|
|
82
|
-
);
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
/** @internal — exposed for template binding. */
|
|
86
|
-
protected readonly allKey = ALL_VALUE;
|
|
87
|
-
|
|
88
|
-
protected readonly ariaLabel = computed(() => `Filter by ${headerLabel(this.ctx.column)}`);
|
|
89
|
-
|
|
90
|
-
/** Maps the column's current filter value back to the matching option index, or `ALL_VALUE`. */
|
|
91
|
-
protected readonly currentValueKey = computed(() => {
|
|
92
|
-
const current = this.ctx.column.getFilterValue();
|
|
93
|
-
if (current === undefined || current === null) return ALL_VALUE;
|
|
94
|
-
// Single value (legacy) OR `KjSetFilterModel` with one entry.
|
|
95
|
-
const value =
|
|
96
|
-
current &&
|
|
97
|
-
typeof current === 'object' &&
|
|
98
|
-
(current as { filterType?: string }).filterType === 'set'
|
|
99
|
-
? ((current as KjSetFilterModel).values[0] as unknown)
|
|
100
|
-
: current;
|
|
101
|
-
const idx = this.resolvedOptions().findIndex((o) => Object.is(o.value, value));
|
|
102
|
-
return idx === -1 ? ALL_VALUE : this.keyOf(idx);
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
protected keyOf(index: number): string {
|
|
106
|
-
return String(index);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
protected onChange(value: unknown): void {
|
|
110
|
-
const key = typeof value === 'string' ? value : String(value ?? '');
|
|
111
|
-
if (key === ALL_VALUE || key === '') {
|
|
112
|
-
this.ctx.column.setFilterValue(undefined);
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
const idx = Number(key);
|
|
116
|
-
const opt = this.resolvedOptions()[idx];
|
|
117
|
-
if (!opt) {
|
|
118
|
-
this.ctx.column.setFilterValue(undefined);
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
const model: KjSetFilterModel = { filterType: 'set', values: [opt.value] };
|
|
122
|
-
this.ctx.column.setFilterValue(model);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
function headerLabel<TData>(column: Column<TData, unknown>): string {
|
|
127
|
-
const header = column.columnDef.header;
|
|
128
|
-
return typeof header === 'string' ? header : column.id;
|
|
129
|
-
}
|