@kouji-ui/components 0.1.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/.turbo/turbo-build.log +29 -0
- package/CHANGELOG.md +192 -0
- package/ng-package.json +7 -0
- package/package.json +43 -0
- package/src/accordion/_examples/accordion.default.example.ts +31 -0
- package/src/accordion/_examples/accordion.disabled.example.ts +38 -0
- package/src/accordion/_examples/accordion.multiple.example.ts +31 -0
- package/src/accordion/_examples/accordion.rich-content.example.ts +49 -0
- package/src/accordion/_examples/index.ts +6 -0
- package/src/accordion/accordion.arrow-nav.example.ts +39 -0
- package/src/accordion/accordion.css +68 -0
- package/src/accordion/accordion.playground.ts +119 -0
- package/src/accordion/accordion.spec.ts +117 -0
- package/src/accordion/accordion.ts +153 -0
- package/src/accordion/accordion.usage.example.ts +38 -0
- package/src/accordion/accordion.value.example.ts +60 -0
- package/src/accordion/index.ts +1 -0
- package/src/alert/_examples/alert.banner.example.ts +56 -0
- package/src/alert/_examples/alert.dismissible.example.ts +53 -0
- package/src/alert/_examples/alert.example.ts +40 -0
- package/src/alert/_examples/alert.variants.example.ts +66 -0
- package/src/alert/_examples/alert.with-actions.example.ts +57 -0
- package/src/alert/_examples/index.ts +7 -0
- package/src/alert/alert.css +133 -0
- package/src/alert/alert.playground.ts +111 -0
- package/src/alert/alert.spec.ts +167 -0
- package/src/alert/alert.ts +250 -0
- package/src/alert/alert.usage.example.ts +58 -0
- package/src/alert/index.ts +8 -0
- package/src/avatar/_examples/avatar-group.example.ts +31 -0
- package/src/avatar/_examples/avatar-group.list.example.ts +45 -0
- package/src/avatar/_examples/avatar-group.overflow.example.ts +33 -0
- package/src/avatar/_examples/avatar-group.shapes.example.ts +39 -0
- package/src/avatar/_examples/avatar-group.sizes.example.ts +44 -0
- package/src/avatar/_examples/avatar.default.example.ts +18 -0
- package/src/avatar/_examples/avatar.initials.example.ts +20 -0
- package/src/avatar/_examples/avatar.shapes.example.ts +22 -0
- package/src/avatar/_examples/avatar.sizes.example.ts +26 -0
- package/src/avatar/_examples/avatar.with-image.example.ts +20 -0
- package/src/avatar/_examples/index.ts +12 -0
- package/src/avatar/avatar-group.spec.ts +138 -0
- package/src/avatar/avatar-group.ts +127 -0
- package/src/avatar/avatar-group.usage.example.ts +30 -0
- package/src/avatar/avatar.css +58 -0
- package/src/avatar/avatar.playground.ts +95 -0
- package/src/avatar/avatar.ts +123 -0
- package/src/avatar/index.ts +2 -0
- package/src/badge/_examples/badge.default.example.ts +18 -0
- package/src/badge/_examples/badge.sizes.example.ts +25 -0
- package/src/badge/_examples/badge.variants.example.ts +24 -0
- package/src/badge/_examples/badge.with-dot.example.ts +31 -0
- package/src/badge/_examples/badge.with-icon.example.ts +23 -0
- package/src/badge/_examples/index.ts +7 -0
- package/src/badge/badge.css +59 -0
- package/src/badge/badge.playground.ts +49 -0
- package/src/badge/badge.ts +86 -0
- package/src/badge/badge.usage.example.ts +22 -0
- package/src/badge/index.ts +1 -0
- package/src/breadcrumb/_examples/breadcrumb.custom-separator.example.ts +53 -0
- package/src/breadcrumb/_examples/breadcrumb.example.ts +48 -0
- package/src/breadcrumb/_examples/breadcrumb.long-path.example.ts +58 -0
- package/src/breadcrumb/_examples/breadcrumb.truncated.example.ts +59 -0
- package/src/breadcrumb/_examples/breadcrumb.with-icons.example.ts +66 -0
- package/src/breadcrumb/_examples/index.ts +7 -0
- package/src/breadcrumb/breadcrumb.css +121 -0
- package/src/breadcrumb/breadcrumb.playground.ts +93 -0
- package/src/breadcrumb/breadcrumb.spec.ts +230 -0
- package/src/breadcrumb/breadcrumb.ts +272 -0
- package/src/breadcrumb/breadcrumb.usage.example.ts +45 -0
- package/src/breadcrumb/index.ts +1 -0
- package/src/button/_examples/button.anchor.example.ts +18 -0
- package/src/button/_examples/button.configured.example.ts +43 -0
- package/src/button/_examples/button.disabled.example.ts +25 -0
- package/src/button/_examples/button.example.ts +22 -0
- package/src/button/_examples/button.icon.example.ts +27 -0
- package/src/button/_examples/button.loading.example.ts +31 -0
- package/src/button/_examples/button.pressed.example.ts +24 -0
- package/src/button/_examples/button.sizes.example.ts +26 -0
- package/src/button/_examples/button.usage.example.ts +66 -0
- package/src/button/_examples/button.variants.example.ts +26 -0
- package/src/button/_examples/index.ts +12 -0
- package/src/button/button.css +263 -0
- package/src/button/button.playground.ts +79 -0
- package/src/button/button.spec.ts +100 -0
- package/src/button/button.ts +150 -0
- package/src/button/index.ts +1 -0
- package/src/button-group/_examples/button-group.example.ts +30 -0
- package/src/button-group/_examples/button-group.icon-only.example.ts +30 -0
- package/src/button-group/_examples/button-group.toggle.example.ts +36 -0
- package/src/button-group/_examples/button-group.variants.example.ts +40 -0
- package/src/button-group/_examples/button-group.vertical.example.ts +29 -0
- package/src/button-group/_examples/index.ts +7 -0
- package/src/button-group/button-group.css +80 -0
- package/src/button-group/button-group.playground.ts +94 -0
- package/src/button-group/button-group.spec.ts +119 -0
- package/src/button-group/button-group.ts +130 -0
- package/src/button-group/button-group.usage.example.ts +35 -0
- package/src/button-group/index.ts +1 -0
- package/src/calendar/_examples/calendar.example.ts +33 -0
- package/src/calendar/_examples/index.ts +3 -0
- package/src/calendar/calendar.css +129 -0
- package/src/calendar/calendar.playground.ts +84 -0
- package/src/calendar/calendar.spec.ts +50 -0
- package/src/calendar/calendar.ts +171 -0
- package/src/calendar/calendar.usage.example.ts +33 -0
- package/src/calendar/index.ts +1 -0
- package/src/card/_examples/card.cover.example.ts +53 -0
- package/src/card/_examples/card.example.ts +27 -0
- package/src/card/_examples/card.full.example.ts +51 -0
- package/src/card/_examples/index.ts +5 -0
- package/src/card/card.css +120 -0
- package/src/card/card.playground.ts +116 -0
- package/src/card/card.spec.ts +50 -0
- package/src/card/card.ts +194 -0
- package/src/card/card.usage.example.ts +46 -0
- package/src/card/index.ts +1 -0
- package/src/carousel/_examples/carousel.autoplay.example.ts +69 -0
- package/src/carousel/_examples/carousel.example.ts +60 -0
- package/src/carousel/_examples/carousel.indicators.example.ts +64 -0
- package/src/carousel/_examples/carousel.lazy-load.example.ts +85 -0
- package/src/carousel/_examples/carousel.tabs-pattern.example.ts +61 -0
- package/src/carousel/_examples/index.ts +7 -0
- package/src/carousel/carousel.css +181 -0
- package/src/carousel/carousel.playground.ts +135 -0
- package/src/carousel/carousel.spec.ts +211 -0
- package/src/carousel/carousel.ts +399 -0
- package/src/carousel/carousel.usage.example.ts +46 -0
- package/src/carousel/index.ts +1 -0
- package/src/cascade-select/_examples/cascade-select.data-driven.example.ts +119 -0
- package/src/cascade-select/_examples/cascade-select.disabled.example.ts +74 -0
- package/src/cascade-select/_examples/cascade-select.example.ts +80 -0
- package/src/cascade-select/_examples/cascade-select.field.example.ts +73 -0
- package/src/cascade-select/_examples/cascade-select.path.example.ts +85 -0
- package/src/cascade-select/_examples/index.ts +7 -0
- package/src/cascade-select/cascade-select.css +120 -0
- package/src/cascade-select/cascade-select.playground.ts +133 -0
- package/src/cascade-select/cascade-select.ts +201 -0
- package/src/cascade-select/cascade-select.usage.example.ts +44 -0
- package/src/cascade-select/index.ts +5 -0
- package/src/chat/_examples/chat-bubble.example.ts +71 -0
- package/src/chat/_examples/chat-bubble.grouped.example.ts +69 -0
- package/src/chat/_examples/chat-bubble.sides.example.ts +41 -0
- package/src/chat/_examples/chat-bubble.variants.example.ts +58 -0
- package/src/chat/_examples/chat-bubble.with-state.example.ts +57 -0
- package/src/chat/_examples/index.ts +7 -0
- package/src/chat/chat.css +231 -0
- package/src/chat/chat.playground.ts +171 -0
- package/src/chat/chat.spec.ts +343 -0
- package/src/chat/chat.ts +269 -0
- package/src/chat/chat.usage.example.ts +49 -0
- package/src/chat/index.ts +13 -0
- package/src/checkbox/_examples/checkbox.checked.example.ts +20 -0
- package/src/checkbox/_examples/checkbox.default.example.ts +20 -0
- package/src/checkbox/_examples/checkbox.disabled.example.ts +26 -0
- package/src/checkbox/_examples/checkbox.indeterminate.example.ts +20 -0
- package/src/checkbox/_examples/checkbox.usage.example.ts +62 -0
- package/src/checkbox/_examples/index.ts +7 -0
- package/src/checkbox/checkbox.css +74 -0
- package/src/checkbox/checkbox.playground.ts +68 -0
- package/src/checkbox/checkbox.ts +122 -0
- package/src/checkbox/index.ts +1 -0
- package/src/color-picker/_examples/color-picker.alpha.example.ts +36 -0
- package/src/color-picker/_examples/color-picker.example.ts +34 -0
- package/src/color-picker/_examples/color-picker.hex-input.example.ts +53 -0
- package/src/color-picker/_examples/color-picker.in-form.example.ts +60 -0
- package/src/color-picker/_examples/color-picker.usage.example.ts +58 -0
- package/src/color-picker/_examples/color-picker.with-presets.example.ts +45 -0
- package/src/color-picker/_examples/index.ts +8 -0
- package/src/color-picker/color-picker.css +183 -0
- package/src/color-picker/color-picker.playground.ts +83 -0
- package/src/color-picker/color-picker.spec.ts +94 -0
- package/src/color-picker/color-picker.ts +234 -0
- package/src/color-picker/index.ts +1 -0
- package/src/combobox/_examples/combobox.async.example.ts +85 -0
- package/src/combobox/_examples/combobox.empty-state.example.ts +36 -0
- package/src/combobox/_examples/combobox.example.ts +36 -0
- package/src/combobox/_examples/combobox.free-text.example.ts +42 -0
- package/src/combobox/_examples/combobox.usage.example.ts +51 -0
- package/src/combobox/_examples/combobox.with-icons.example.ts +49 -0
- package/src/combobox/_examples/index.ts +8 -0
- package/src/combobox/combobox.css +101 -0
- package/src/combobox/combobox.playground.ts +90 -0
- package/src/combobox/combobox.spec.ts +111 -0
- package/src/combobox/combobox.ts +219 -0
- package/src/combobox/index.ts +6 -0
- package/src/command-palette/_examples/command-palette.async.example.ts +99 -0
- package/src/command-palette/_examples/command-palette.dialog.example.ts +90 -0
- package/src/command-palette/_examples/command-palette.example.ts +40 -0
- package/src/command-palette/_examples/command-palette.fuzzy.example.ts +54 -0
- package/src/command-palette/_examples/command-palette.groups.example.ts +55 -0
- package/src/command-palette/_examples/command-palette.usage.example.ts +49 -0
- package/src/command-palette/_examples/index.ts +8 -0
- package/src/command-palette/command-palette.css +234 -0
- package/src/command-palette/command-palette.playground.ts +119 -0
- package/src/command-palette/command-palette.ts +448 -0
- package/src/command-palette/index.ts +10 -0
- package/src/confirm-popup/_examples/confirm-popup.destructive.example.ts +72 -0
- package/src/confirm-popup/_examples/confirm-popup.example.ts +82 -0
- package/src/confirm-popup/_examples/confirm-popup.placement.example.ts +97 -0
- package/src/confirm-popup/_examples/confirm-popup.usage.example.ts +94 -0
- package/src/confirm-popup/_examples/confirm-popup.with-message.example.ts +76 -0
- package/src/confirm-popup/_examples/index.ts +7 -0
- package/src/confirm-popup/confirm-popup.css +47 -0
- package/src/confirm-popup/confirm-popup.playground.ts +109 -0
- package/src/confirm-popup/confirm-popup.spec.ts +209 -0
- package/src/confirm-popup/confirm-popup.ts +279 -0
- package/src/confirm-popup/index.ts +1 -0
- package/src/date-picker/_examples/date-picker.disabled-dates.example.ts +44 -0
- package/src/date-picker/_examples/date-picker.example.ts +38 -0
- package/src/date-picker/_examples/date-picker.locale.example.ts +50 -0
- package/src/date-picker/_examples/date-picker.readonly.example.ts +32 -0
- package/src/date-picker/_examples/date-picker.usage.example.ts +60 -0
- package/src/date-picker/_examples/date-picker.with-min-max.example.ts +47 -0
- package/src/date-picker/_examples/index.ts +8 -0
- package/src/date-picker/date-picker.css +61 -0
- package/src/date-picker/date-picker.playground.ts +79 -0
- package/src/date-picker/date-picker.spec.ts +71 -0
- package/src/date-picker/date-picker.ts +185 -0
- package/src/date-picker/index.ts +1 -0
- package/src/dialog/_examples/dialog.confirmation.example.ts +30 -0
- package/src/dialog/_examples/dialog.default.example.ts +30 -0
- package/src/dialog/_examples/dialog.nested.example.ts +86 -0
- package/src/dialog/_examples/dialog.scrollable.example.ts +30 -0
- package/src/dialog/_examples/dialog.usage.example.ts +57 -0
- package/src/dialog/_examples/dialog.with-form.example.ts +48 -0
- package/src/dialog/_examples/index.ts +8 -0
- package/src/dialog/dialog.css +56 -0
- package/src/dialog/dialog.playground.ts +136 -0
- package/src/dialog/dialog.ts +82 -0
- package/src/dialog/index.ts +1 -0
- package/src/divider/_examples/divider.example.ts +27 -0
- package/src/divider/_examples/divider.sizes.example.ts +33 -0
- package/src/divider/_examples/divider.structural.example.ts +55 -0
- package/src/divider/_examples/divider.usage.example.ts +48 -0
- package/src/divider/_examples/divider.variants.example.ts +33 -0
- package/src/divider/_examples/divider.vertical.example.ts +38 -0
- package/src/divider/_examples/divider.with-content.example.ts +38 -0
- package/src/divider/_examples/index.ts +9 -0
- package/src/divider/divider.css +93 -0
- package/src/divider/divider.playground.ts +97 -0
- package/src/divider/divider.spec.ts +207 -0
- package/src/divider/divider.ts +220 -0
- package/src/divider/index.ts +1 -0
- package/src/drawer/_examples/drawer.example.ts +30 -0
- package/src/drawer/_examples/drawer.modal-vs-non-modal.example.ts +27 -0
- package/src/drawer/_examples/drawer.scrollable.example.ts +30 -0
- package/src/drawer/_examples/drawer.sides.example.ts +32 -0
- package/src/drawer/_examples/drawer.usage.example.ts +56 -0
- package/src/drawer/_examples/drawer.with-form.example.ts +48 -0
- package/src/drawer/_examples/index.ts +8 -0
- package/src/drawer/drawer.css +130 -0
- package/src/drawer/drawer.playground.ts +107 -0
- package/src/drawer/drawer.spec.ts +216 -0
- package/src/drawer/drawer.ts +85 -0
- package/src/drawer/index.ts +1 -0
- package/src/dropdown-menu/_examples/dropdown-menu.disabled.example.ts +19 -0
- package/src/dropdown-menu/_examples/dropdown-menu.example.ts +20 -0
- package/src/dropdown-menu/_examples/dropdown-menu.shortcuts.example.ts +31 -0
- package/src/dropdown-menu/_examples/dropdown-menu.sides.example.ts +18 -0
- package/src/dropdown-menu/_examples/dropdown-menu.usage.example.ts +56 -0
- package/src/dropdown-menu/_examples/dropdown-menu.with-icons.example.ts +31 -0
- package/src/dropdown-menu/_examples/dropdown-menu.with-separator.example.ts +41 -0
- package/src/dropdown-menu/_examples/index.ts +9 -0
- package/src/dropdown-menu/dropdown-menu.css +108 -0
- package/src/dropdown-menu/dropdown-menu.playground.ts +109 -0
- package/src/dropdown-menu/dropdown-menu.spec.ts +5 -0
- package/src/dropdown-menu/dropdown-menu.ts +128 -0
- package/src/dropdown-menu/index.ts +1 -0
- package/src/empty-state/_examples/empty-state.error.example.ts +63 -0
- package/src/empty-state/_examples/empty-state.example.ts +59 -0
- package/src/empty-state/_examples/empty-state.search.example.ts +82 -0
- package/src/empty-state/_examples/empty-state.sizes.example.ts +76 -0
- package/src/empty-state/_examples/empty-state.usage.example.ts +66 -0
- package/src/empty-state/_examples/empty-state.with-actions.example.ts +68 -0
- package/src/empty-state/_examples/index.ts +8 -0
- package/src/empty-state/empty-state.css +114 -0
- package/src/empty-state/empty-state.playground.ts +87 -0
- package/src/empty-state/empty-state.spec.ts +211 -0
- package/src/empty-state/empty-state.ts +276 -0
- package/src/empty-state/index.ts +1 -0
- package/src/example-components.ts +396 -0
- package/src/field/_examples/field.disabled.example.ts +49 -0
- package/src/field/_examples/field.example.ts +51 -0
- package/src/field/_examples/field.required.example.ts +46 -0
- package/src/field/_examples/field.with-error.example.ts +73 -0
- package/src/field/_examples/field.with-prefix-suffix.example.ts +63 -0
- package/src/field/_examples/index.ts +7 -0
- package/src/field/field.css +138 -0
- package/src/field/field.playground.ts +108 -0
- package/src/field/field.spec.ts +132 -0
- package/src/field/field.ts +232 -0
- package/src/field/field.usage.example.ts +63 -0
- package/src/field/index.ts +7 -0
- package/src/file-upload/_examples/file-upload.dropzone.example.ts +32 -0
- package/src/file-upload/_examples/file-upload.example.ts +29 -0
- package/src/file-upload/_examples/file-upload.image-preview.example.ts +31 -0
- package/src/file-upload/_examples/file-upload.multiple.example.ts +23 -0
- package/src/file-upload/_examples/file-upload.with-progress.example.ts +59 -0
- package/src/file-upload/_examples/index.ts +7 -0
- package/src/file-upload/file-upload.css +207 -0
- package/src/file-upload/file-upload.playground.ts +84 -0
- package/src/file-upload/file-upload.spec.ts +94 -0
- package/src/file-upload/file-upload.ts +301 -0
- package/src/file-upload/file-upload.usage.example.ts +45 -0
- package/src/file-upload/index.ts +1 -0
- package/src/form/_examples/form.async-submit.example.ts +72 -0
- package/src/form/_examples/form.compound.example.ts +93 -0
- package/src/form/_examples/form.example.ts +70 -0
- package/src/form/_examples/form.validation.example.ts +67 -0
- package/src/form/_examples/index.ts +6 -0
- package/src/form/form.css +63 -0
- package/src/form/form.playground.ts +145 -0
- package/src/form/form.spec.ts +96 -0
- package/src/form/form.ts +216 -0
- package/src/form/form.usage.example.ts +63 -0
- package/src/form/index.ts +5 -0
- package/src/icon/_examples/icon.gallery.example.ts +199 -0
- package/src/icon/_examples/icon.usage.example.ts +46 -0
- package/src/icon/_examples/index.ts +4 -0
- package/src/icon/icon.playground.ts +63 -0
- package/src/icon/index.ts +5 -0
- package/src/icon/lucide/icon-names.generated.ts +1708 -0
- package/src/icon/lucide/icon-names.ts +18 -0
- package/src/icon/lucide/index.ts +2 -0
- package/src/icon/lucide/provide-lucide-icons.ts +96 -0
- package/src/input/_examples/index.ts +4 -0
- package/src/input/_examples/input.color.example.ts +33 -0
- package/src/input/_examples/input.example.ts +22 -0
- package/src/input/index.ts +1 -0
- package/src/input/input.css +70 -0
- package/src/input/input.playground.ts +79 -0
- package/src/input/input.spec.ts +98 -0
- package/src/input/input.ts +158 -0
- package/src/input/input.usage.example.ts +40 -0
- package/src/input-group/_examples/index.ts +7 -0
- package/src/input-group/_examples/input-group.button.example.ts +43 -0
- package/src/input-group/_examples/input-group.example.ts +39 -0
- package/src/input-group/_examples/input-group.icon.example.ts +49 -0
- package/src/input-group/_examples/input-group.url.example.ts +36 -0
- package/src/input-group/_examples/input-group.variants.example.ts +39 -0
- package/src/input-group/index.ts +1 -0
- package/src/input-group/input-group.css +125 -0
- package/src/input-group/input-group.playground.ts +90 -0
- package/src/input-group/input-group.ts +142 -0
- package/src/input-group/input-group.usage.example.ts +47 -0
- package/src/input-mask/_examples/index.ts +8 -0
- package/src/input-mask/_examples/input-mask.credit-card.example.ts +90 -0
- package/src/input-mask/_examples/input-mask.custom-tokens.example.ts +87 -0
- package/src/input-mask/_examples/input-mask.date.example.ts +61 -0
- package/src/input-mask/_examples/input-mask.example.ts +61 -0
- package/src/input-mask/_examples/input-mask.usage.example.ts +44 -0
- package/src/input-mask/_examples/input-mask.validation.example.ts +80 -0
- package/src/input-mask/index.ts +9 -0
- package/src/input-mask/input-mask.css +39 -0
- package/src/input-mask/input-mask.playground.ts +79 -0
- package/src/input-mask/input-mask.ts +130 -0
- package/src/input-otp/_examples/index.ts +8 -0
- package/src/input-otp/_examples/input-otp.autosubmit.example.ts +71 -0
- package/src/input-otp/_examples/input-otp.example.ts +47 -0
- package/src/input-otp/_examples/input-otp.lengths.example.ts +67 -0
- package/src/input-otp/_examples/input-otp.masked.example.ts +46 -0
- package/src/input-otp/_examples/input-otp.reactive.example.ts +58 -0
- package/src/input-otp/_examples/input-otp.separator.example.ts +49 -0
- package/src/input-otp/index.ts +1 -0
- package/src/input-otp/input-otp.css +87 -0
- package/src/input-otp/input-otp.playground.ts +107 -0
- package/src/input-otp/input-otp.ts +244 -0
- package/src/input-otp/input-otp.usage.example.ts +45 -0
- package/src/kbd/_examples/index.ts +6 -0
- package/src/kbd/_examples/kbd.combo.example.ts +24 -0
- package/src/kbd/_examples/kbd.example.ts +22 -0
- package/src/kbd/_examples/kbd.in-tooltip.example.ts +43 -0
- package/src/kbd/_examples/kbd.sizes.example.ts +31 -0
- package/src/kbd/index.ts +1 -0
- package/src/kbd/kbd.css +67 -0
- package/src/kbd/kbd.playground.ts +51 -0
- package/src/kbd/kbd.spec.ts +123 -0
- package/src/kbd/kbd.ts +123 -0
- package/src/kbd/kbd.usage.example.ts +38 -0
- package/src/link/_examples/index.ts +8 -0
- package/src/link/_examples/link.disabled.example.ts +23 -0
- package/src/link/_examples/link.example.ts +26 -0
- package/src/link/_examples/link.external.example.ts +33 -0
- package/src/link/_examples/link.in-prose.example.ts +36 -0
- package/src/link/_examples/link.sizes.example.ts +28 -0
- package/src/link/_examples/link.variants.example.ts +25 -0
- package/src/link/index.ts +1 -0
- package/src/link/link.css +104 -0
- package/src/link/link.playground.ts +98 -0
- package/src/link/link.spec.ts +146 -0
- package/src/link/link.ts +133 -0
- package/src/link/link.usage.example.ts +37 -0
- package/src/list/_examples/index.ts +7 -0
- package/src/list/_examples/list.divided.example.ts +32 -0
- package/src/list/_examples/list.example.ts +31 -0
- package/src/list/_examples/list.interactive.example.ts +51 -0
- package/src/list/_examples/list.nav.example.ts +44 -0
- package/src/list/_examples/list.with-icons.example.ts +97 -0
- package/src/list/index.ts +1 -0
- package/src/list/list.css +166 -0
- package/src/list/list.playground.ts +90 -0
- package/src/list/list.spec.ts +121 -0
- package/src/list/list.ts +227 -0
- package/src/list/list.usage.example.ts +45 -0
- package/src/menubar/_examples/index.ts +6 -0
- package/src/menubar/_examples/menubar.disabled-item.example.ts +23 -0
- package/src/menubar/_examples/menubar.example.ts +22 -0
- package/src/menubar/_examples/menubar.with-shortcuts.example.ts +33 -0
- package/src/menubar/_examples/menubar.with-submenu.example.ts +76 -0
- package/src/menubar/index.ts +1 -0
- package/src/menubar/menubar.css +62 -0
- package/src/menubar/menubar.playground.ts +96 -0
- package/src/menubar/menubar.ts +160 -0
- package/src/menubar/menubar.usage.example.ts +33 -0
- package/src/number-input/_examples/index.ts +7 -0
- package/src/number-input/_examples/number-input.currency.example.ts +35 -0
- package/src/number-input/_examples/number-input.decimal.example.ts +34 -0
- package/src/number-input/_examples/number-input.example.ts +24 -0
- package/src/number-input/_examples/number-input.min-max.example.ts +33 -0
- package/src/number-input/_examples/number-input.with-stepper.example.ts +45 -0
- package/src/number-input/index.ts +1 -0
- package/src/number-input/number-input.css +115 -0
- package/src/number-input/number-input.playground.ts +92 -0
- package/src/number-input/number-input.spec.ts +102 -0
- package/src/number-input/number-input.ts +212 -0
- package/src/number-input/number-input.usage.example.ts +73 -0
- package/src/overlay/overlay.css +32 -0
- package/src/overlay-badge/_examples/index.ts +7 -0
- package/src/overlay-badge/_examples/overlay-badge.described.example.ts +36 -0
- package/src/overlay-badge/_examples/overlay-badge.dot.example.ts +28 -0
- package/src/overlay-badge/_examples/overlay-badge.example.ts +34 -0
- package/src/overlay-badge/_examples/overlay-badge.on-avatar.example.ts +38 -0
- package/src/overlay-badge/_examples/overlay-badge.positions.example.ts +39 -0
- package/src/overlay-badge/index.ts +1 -0
- package/src/overlay-badge/overlay-badge.css +118 -0
- package/src/overlay-badge/overlay-badge.playground.ts +92 -0
- package/src/overlay-badge/overlay-badge.spec.ts +174 -0
- package/src/overlay-badge/overlay-badge.ts +232 -0
- package/src/overlay-badge/overlay-badge.usage.example.ts +44 -0
- package/src/pagination/_examples/index.ts +7 -0
- package/src/pagination/_examples/pagination.boundaries.example.ts +56 -0
- package/src/pagination/_examples/pagination.compact.example.ts +42 -0
- package/src/pagination/_examples/pagination.example.ts +55 -0
- package/src/pagination/_examples/pagination.large.example.ts +54 -0
- package/src/pagination/_examples/pagination.with-info.example.ts +49 -0
- package/src/pagination/index.ts +1 -0
- package/src/pagination/pagination.css +146 -0
- package/src/pagination/pagination.playground.ts +107 -0
- package/src/pagination/pagination.spec.ts +202 -0
- package/src/pagination/pagination.ts +432 -0
- package/src/pagination/pagination.usage.example.ts +50 -0
- package/src/password-input/_examples/index.ts +6 -0
- package/src/password-input/_examples/password-input.example.ts +24 -0
- package/src/password-input/_examples/password-input.strength.example.ts +45 -0
- package/src/password-input/_examples/password-input.toggle.example.ts +43 -0
- package/src/password-input/_examples/password-input.with-rules.example.ts +78 -0
- package/src/password-input/index.ts +1 -0
- package/src/password-input/password-input.css +155 -0
- package/src/password-input/password-input.playground.ts +81 -0
- package/src/password-input/password-input.spec.ts +129 -0
- package/src/password-input/password-input.ts +254 -0
- package/src/password-input/password-input.usage.example.ts +55 -0
- package/src/playground-types.ts +47 -0
- package/src/popover/_examples/index.ts +7 -0
- package/src/popover/_examples/popover.cancellable.example.ts +20 -0
- package/src/popover/_examples/popover.example.ts +20 -0
- package/src/popover/_examples/popover.modal.example.ts +22 -0
- package/src/popover/_examples/popover.sides.example.ts +37 -0
- package/src/popover/_examples/popover.with-form.example.ts +38 -0
- package/src/popover/index.ts +1 -0
- package/src/popover/popover.css +71 -0
- package/src/popover/popover.playground.ts +86 -0
- package/src/popover/popover.spec.ts +5 -0
- package/src/popover/popover.ts +94 -0
- package/src/popover/popover.usage.example.ts +48 -0
- package/src/progress-bar/_examples/index.ts +7 -0
- package/src/progress-bar/_examples/progress-bar.example.ts +22 -0
- package/src/progress-bar/_examples/progress-bar.indeterminate.example.ts +23 -0
- package/src/progress-bar/_examples/progress-bar.sizes.example.ts +29 -0
- package/src/progress-bar/_examples/progress-bar.variants.example.ts +30 -0
- package/src/progress-bar/_examples/progress-bar.with-label.example.ts +30 -0
- package/src/progress-bar/index.ts +1 -0
- package/src/progress-bar/progress-bar.css +113 -0
- package/src/progress-bar/progress-bar.playground.ts +87 -0
- package/src/progress-bar/progress-bar.spec.ts +233 -0
- package/src/progress-bar/progress-bar.ts +155 -0
- package/src/progress-bar/progress-bar.usage.example.ts +52 -0
- package/src/public-api.ts +61 -0
- package/src/radio/_examples/index.ts +6 -0
- package/src/radio/_examples/radio.default.example.ts +26 -0
- package/src/radio/_examples/radio.disabled.example.ts +26 -0
- package/src/radio/_examples/radio.group.example.ts +27 -0
- package/src/radio/_examples/radio.inline.example.ts +26 -0
- package/src/radio/index.ts +1 -0
- package/src/radio/radio.css +58 -0
- package/src/radio/radio.playground.ts +90 -0
- package/src/radio/radio.ts +143 -0
- package/src/radio/radio.usage.example.ts +54 -0
- package/src/select/_examples/index.ts +6 -0
- package/src/select/_examples/select.default.example.ts +26 -0
- package/src/select/_examples/select.disabled.example.ts +24 -0
- package/src/select/_examples/select.grouped.example.ts +37 -0
- package/src/select/_examples/select.placeholder.example.ts +26 -0
- package/src/select/index.ts +1 -0
- package/src/select/select.css +65 -0
- package/src/select/select.playground.ts +81 -0
- package/src/select/select.ts +176 -0
- package/src/select/select.usage.example.ts +64 -0
- package/src/skeleton/_examples/index.ts +6 -0
- package/src/skeleton/_examples/skeleton.animations.example.ts +52 -0
- package/src/skeleton/_examples/skeleton.card.example.ts +68 -0
- package/src/skeleton/_examples/skeleton.example.ts +24 -0
- package/src/skeleton/_examples/skeleton.shapes.example.ts +55 -0
- package/src/skeleton/index.ts +1 -0
- package/src/skeleton/skeleton.css +111 -0
- package/src/skeleton/skeleton.playground.ts +80 -0
- package/src/skeleton/skeleton.spec.ts +126 -0
- package/src/skeleton/skeleton.ts +155 -0
- package/src/skeleton/skeleton.usage.example.ts +49 -0
- package/src/slider/_examples/index.ts +7 -0
- package/src/slider/_examples/slider.example.ts +41 -0
- package/src/slider/_examples/slider.formatted.example.ts +53 -0
- package/src/slider/_examples/slider.range.example.ts +48 -0
- package/src/slider/_examples/slider.vertical.example.ts +48 -0
- package/src/slider/_examples/slider.with-marks.example.ts +46 -0
- package/src/slider/index.ts +1 -0
- package/src/slider/slider.css +172 -0
- package/src/slider/slider.playground.ts +88 -0
- package/src/slider/slider.spec.ts +139 -0
- package/src/slider/slider.ts +246 -0
- package/src/slider/slider.usage.example.ts +68 -0
- package/src/speed-dial/_examples/index.ts +7 -0
- package/src/speed-dial/_examples/speed-dial.directions.example.ts +85 -0
- package/src/speed-dial/_examples/speed-dial.disabled.example.ts +71 -0
- package/src/speed-dial/_examples/speed-dial.example.ts +48 -0
- package/src/speed-dial/_examples/speed-dial.usage.example.ts +59 -0
- package/src/speed-dial/_examples/speed-dial.with-tooltips.example.ts +65 -0
- package/src/speed-dial/index.ts +1 -0
- package/src/speed-dial/speed-dial.css +137 -0
- package/src/speed-dial/speed-dial.playground.ts +137 -0
- package/src/speed-dial/speed-dial.spec.ts +191 -0
- package/src/speed-dial/speed-dial.ts +257 -0
- package/src/spinner/_examples/index.ts +8 -0
- package/src/spinner/_examples/spinner.animations.example.ts +54 -0
- package/src/spinner/_examples/spinner.example.ts +26 -0
- package/src/spinner/_examples/spinner.in-button.example.ts +51 -0
- package/src/spinner/_examples/spinner.sizes.example.ts +31 -0
- package/src/spinner/_examples/spinner.usage.example.ts +45 -0
- package/src/spinner/_examples/spinner.variants.example.ts +34 -0
- package/src/spinner/index.ts +1 -0
- package/src/spinner/spinner.css +161 -0
- package/src/spinner/spinner.playground.ts +68 -0
- package/src/spinner/spinner.spec.ts +184 -0
- package/src/spinner/spinner.ts +185 -0
- package/src/stepper/_examples/index.ts +8 -0
- package/src/stepper/_examples/stepper.example.ts +62 -0
- package/src/stepper/_examples/stepper.non-linear.example.ts +63 -0
- package/src/stepper/_examples/stepper.optional-step.example.ts +62 -0
- package/src/stepper/_examples/stepper.usage.example.ts +73 -0
- package/src/stepper/_examples/stepper.vertical.example.ts +66 -0
- package/src/stepper/_examples/stepper.with-error.example.ts +63 -0
- package/src/stepper/index.ts +1 -0
- package/src/stepper/stepper.css +147 -0
- package/src/stepper/stepper.playground.ts +88 -0
- package/src/stepper/stepper.spec.ts +200 -0
- package/src/stepper/stepper.ts +242 -0
- package/src/table/_examples/index.ts +23 -0
- package/src/table/_examples/table.column-pinning.example.ts +55 -0
- package/src/table/_examples/table.column-resize.example.ts +49 -0
- package/src/table/_examples/table.column-visibility.example.ts +52 -0
- package/src/table/_examples/table.density.example.ts +71 -0
- package/src/table/_examples/table.editable.example.ts +85 -0
- package/src/table/_examples/table.empty-and-error.example.ts +112 -0
- package/src/table/_examples/table.example.ts +45 -0
- package/src/table/_examples/table.export.example.ts +82 -0
- package/src/table/_examples/table.filterable.example.ts +67 -0
- package/src/table/_examples/table.grouping.example.ts +63 -0
- package/src/table/_examples/table.keyboard.example.ts +115 -0
- package/src/table/_examples/table.master-detail.example.ts +102 -0
- package/src/table/_examples/table.persistence.example.ts +85 -0
- package/src/table/_examples/table.playground.ts +154 -0
- package/src/table/_examples/table.row-pinning.example.ts +71 -0
- package/src/table/_examples/table.selection.example.ts +67 -0
- package/src/table/_examples/table.server-mode.example.ts +120 -0
- package/src/table/_examples/table.sortable.example.ts +49 -0
- package/src/table/_examples/table.theming.example.ts +64 -0
- package/src/table/_examples/table.usage.example.ts +90 -0
- package/src/table/_examples/table.virtualized.example.ts +122 -0
- package/src/table/index.ts +11 -0
- package/src/table/table-cell-editor-outlet.ts +111 -0
- package/src/table/table-editors/boolean-editor.ts +71 -0
- package/src/table/table-editors/date-editor.ts +117 -0
- package/src/table/table-editors/editors.spec.ts +147 -0
- package/src/table/table-editors/index.ts +41 -0
- package/src/table/table-editors/number-editor.ts +89 -0
- package/src/table/table-editors/select-editor.ts +107 -0
- package/src/table/table-editors/text-editor.ts +82 -0
- package/src/table/table-export.spec.ts +33 -0
- package/src/table/table-export.ts +53 -0
- package/src/table/table-filter-outlet.ts +137 -0
- package/src/table/table-filters/date-filter.ts +122 -0
- package/src/table/table-filters/filters.css +53 -0
- package/src/table/table-filters/filters.spec.ts +277 -0
- package/src/table/table-filters/index.ts +11 -0
- package/src/table/table-filters/number-filter.ts +232 -0
- package/src/table/table-filters/select-filter.ts +129 -0
- package/src/table/table-filters/text-filter.ts +110 -0
- package/src/table/table-pagination.spec.ts +118 -0
- package/src/table/table-pagination.ts +191 -0
- package/src/table/table-side-panel.spec.ts +170 -0
- package/src/table/table-side-panel.ts +263 -0
- package/src/table/table-status-bar.spec.ts +78 -0
- package/src/table/table-status-bar.ts +70 -0
- package/src/table/table-toolbar.spec.ts +180 -0
- package/src/table/table-toolbar.ts +244 -0
- package/src/table/table-virtual.spec.ts +103 -0
- package/src/table/table-virtual.ts +180 -0
- package/src/table/table.css +468 -0
- package/src/table/table.spec.ts +175 -0
- package/src/table/table.ts +1009 -0
- package/src/tabs/_examples/index.ts +8 -0
- package/src/tabs/_examples/tabs.controlled.example.ts +59 -0
- package/src/tabs/_examples/tabs.disabled.example.ts +34 -0
- package/src/tabs/_examples/tabs.example.ts +34 -0
- package/src/tabs/_examples/tabs.manual-activation.example.ts +34 -0
- package/src/tabs/_examples/tabs.usage.example.ts +43 -0
- package/src/tabs/_examples/tabs.vertical.example.ts +33 -0
- package/src/tabs/index.ts +1 -0
- package/src/tabs/tabs.css +80 -0
- package/src/tabs/tabs.playground.ts +88 -0
- package/src/tabs/tabs.spec.ts +135 -0
- package/src/tabs/tabs.ts +204 -0
- package/src/tag/_examples/index.ts +9 -0
- package/src/tag/_examples/tag.example.ts +22 -0
- package/src/tag/_examples/tag.list.example.ts +38 -0
- package/src/tag/_examples/tag.removable.example.ts +39 -0
- package/src/tag/_examples/tag.selectable.example.ts +33 -0
- package/src/tag/_examples/tag.sizes.example.ts +25 -0
- package/src/tag/_examples/tag.usage.example.ts +62 -0
- package/src/tag/_examples/tag.variants.example.ts +29 -0
- package/src/tag/index.ts +1 -0
- package/src/tag/tag.css +167 -0
- package/src/tag/tag.playground.ts +63 -0
- package/src/tag/tag.spec.ts +153 -0
- package/src/tag/tag.ts +186 -0
- package/src/test-setup.ts +5 -0
- package/src/textarea/_examples/index.ts +8 -0
- package/src/textarea/_examples/textarea.autoresize.example.ts +37 -0
- package/src/textarea/_examples/textarea.character-count.example.ts +34 -0
- package/src/textarea/_examples/textarea.example.ts +22 -0
- package/src/textarea/_examples/textarea.no-resize.example.ts +28 -0
- package/src/textarea/_examples/textarea.usage.example.ts +50 -0
- package/src/textarea/_examples/textarea.with-field.example.ts +66 -0
- package/src/textarea/index.ts +1 -0
- package/src/textarea/textarea.css +117 -0
- package/src/textarea/textarea.playground.ts +70 -0
- package/src/textarea/textarea.spec.ts +161 -0
- package/src/textarea/textarea.ts +339 -0
- package/src/time-picker/_examples/index.ts +8 -0
- package/src/time-picker/_examples/time-picker.12-hour.example.ts +24 -0
- package/src/time-picker/_examples/time-picker.example.ts +24 -0
- package/src/time-picker/_examples/time-picker.formatted.example.ts +32 -0
- package/src/time-picker/_examples/time-picker.range.example.ts +54 -0
- package/src/time-picker/_examples/time-picker.usage.example.ts +53 -0
- package/src/time-picker/_examples/time-picker.with-seconds.example.ts +24 -0
- package/src/time-picker/index.ts +1 -0
- package/src/time-picker/time-picker.css +126 -0
- package/src/time-picker/time-picker.playground.ts +72 -0
- package/src/time-picker/time-picker.spec.ts +77 -0
- package/src/time-picker/time-picker.ts +207 -0
- package/src/toast/_examples/index.ts +7 -0
- package/src/toast/_examples/toast.default.example.ts +37 -0
- package/src/toast/_examples/toast.dismissible.example.ts +38 -0
- package/src/toast/_examples/toast.usage.example.ts +57 -0
- package/src/toast/_examples/toast.variants.example.ts +43 -0
- package/src/toast/_examples/toast.with-action.example.ts +46 -0
- package/src/toast/index.ts +1 -0
- package/src/toast/toast.css +115 -0
- package/src/toast/toast.playground.ts +61 -0
- package/src/toast/toast.ts +168 -0
- package/src/toggle/_examples/index.ts +7 -0
- package/src/toggle/_examples/toggle.checked.example.ts +20 -0
- package/src/toggle/_examples/toggle.default.example.ts +20 -0
- package/src/toggle/_examples/toggle.disabled.example.ts +26 -0
- package/src/toggle/_examples/toggle.usage.example.ts +51 -0
- package/src/toggle/_examples/toggle.with-label.example.ts +30 -0
- package/src/toggle/index.ts +1 -0
- package/src/toggle/toggle.css +123 -0
- package/src/toggle/toggle.playground.ts +65 -0
- package/src/toggle/toggle.ts +113 -0
- package/src/tooltip/_examples/index.ts +9 -0
- package/src/tooltip/_examples/tooltip.delays.example.ts +16 -0
- package/src/tooltip/_examples/tooltip.disabled.example.ts +16 -0
- package/src/tooltip/_examples/tooltip.example.ts +16 -0
- package/src/tooltip/_examples/tooltip.group.example.ts +20 -0
- package/src/tooltip/_examples/tooltip.rich.example.ts +19 -0
- package/src/tooltip/_examples/tooltip.sides.example.ts +18 -0
- package/src/tooltip/_examples/tooltip.usage.example.ts +50 -0
- package/src/tooltip/index.ts +1 -0
- package/src/tooltip/tooltip.css +61 -0
- package/src/tooltip/tooltip.playground.ts +79 -0
- package/src/tooltip/tooltip.spec.ts +5 -0
- package/src/tooltip/tooltip.ts +102 -0
- package/src/tree-select/_examples/index.ts +8 -0
- package/src/tree-select/_examples/tree-select.disabled.example.ts +106 -0
- package/src/tree-select/_examples/tree-select.example.ts +65 -0
- package/src/tree-select/_examples/tree-select.expanded.example.ts +72 -0
- package/src/tree-select/_examples/tree-select.field.example.ts +77 -0
- package/src/tree-select/_examples/tree-select.multi.example.ts +73 -0
- package/src/tree-select/_examples/tree-select.usage.example.ts +85 -0
- package/src/tree-select/index.ts +1 -0
- package/src/tree-select/tree-select.css +220 -0
- package/src/tree-select/tree-select.playground.ts +83 -0
- package/src/tree-select/tree-select.ts +348 -0
- package/src/typography/_examples/index.ts +9 -0
- package/src/typography/_examples/typography.blockquote.example.ts +34 -0
- package/src/typography/_examples/typography.code.example.ts +32 -0
- package/src/typography/_examples/typography.example.ts +42 -0
- package/src/typography/_examples/typography.lead.example.ts +37 -0
- package/src/typography/_examples/typography.muted.example.ts +27 -0
- package/src/typography/_examples/typography.truncate.example.ts +41 -0
- package/src/typography/_examples/typography.usage.example.ts +44 -0
- package/src/typography/index.ts +8 -0
- package/src/typography/typography.playground.ts +101 -0
- package/src/typography/typography.spec.ts +70 -0
- package/src/typography/typography.ts +105 -0
- package/tsconfig.lib.json +25 -0
- package/tsconfig.lib.prod.json +17 -0
- package/tsconfig.spec.json +16 -0
- package/vite.config.ts +33 -0
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ChangeDetectionStrategy,
|
|
3
|
+
Component,
|
|
4
|
+
ElementRef,
|
|
5
|
+
inject,
|
|
6
|
+
signal,
|
|
7
|
+
} from '@angular/core';
|
|
8
|
+
import { kjColumn } from '@kouji-ui/core';
|
|
9
|
+
import { KjTableComponent } from '../table';
|
|
10
|
+
import { KjButtonComponent } from '../../button/button';
|
|
11
|
+
|
|
12
|
+
interface Row {
|
|
13
|
+
readonly id: string;
|
|
14
|
+
readonly name: string;
|
|
15
|
+
readonly score: number;
|
|
16
|
+
readonly city: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const CITIES = ['Paris', 'Tokyo', 'Lagos', 'Lima', 'Oslo', 'Cairo'];
|
|
20
|
+
|
|
21
|
+
function makeRows(n: number): Row[] {
|
|
22
|
+
const out = new Array<Row>(n);
|
|
23
|
+
for (let i = 0; i < n; i++) {
|
|
24
|
+
out[i] = {
|
|
25
|
+
id: String(i),
|
|
26
|
+
name: `User ${i}`,
|
|
27
|
+
score: (i * 37) % 1000,
|
|
28
|
+
city: CITIES[i % CITIES.length]!,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
return out;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* 10,000 rows force-virtualized via `[kjVirtual]="true"` with a 32px row
|
|
36
|
+
* estimate. Only the visible window is rendered; scroll position drives the
|
|
37
|
+
* virtualizer. The "scroll to row 5000" button demonstrates programmatic jump
|
|
38
|
+
* by computing offset = rowIndex × estimatedSize.
|
|
39
|
+
*/
|
|
40
|
+
@Component({
|
|
41
|
+
selector: 'kj-table-virtualized-example',
|
|
42
|
+
standalone: true,
|
|
43
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
44
|
+
imports: [KjTableComponent, KjButtonComponent],
|
|
45
|
+
styles: [`
|
|
46
|
+
:host {
|
|
47
|
+
/* Container-driven sizing: we own the box that the kj-table fills.
|
|
48
|
+
Width is explicit so the table doesn't collapse to its 0-width
|
|
49
|
+
content (the virtualizer hides rows until it has a viewport rect,
|
|
50
|
+
and an unwidthed flex column has 0-width children — chicken/egg). */
|
|
51
|
+
display: block;
|
|
52
|
+
width: 100%;
|
|
53
|
+
font-family: var(--kj-font-sans);
|
|
54
|
+
color: var(--kj-fg-default);
|
|
55
|
+
}
|
|
56
|
+
.toolbar {
|
|
57
|
+
display: flex;
|
|
58
|
+
gap: var(--kj-space-md);
|
|
59
|
+
align-items: center;
|
|
60
|
+
margin-bottom: var(--kj-space-md);
|
|
61
|
+
font-size: var(--kj-text-sm);
|
|
62
|
+
color: var(--kj-fg-muted);
|
|
63
|
+
}
|
|
64
|
+
/* Sized box the table fills. The body scrolls inside this 400px height
|
|
65
|
+
and the virtualizer's ResizeObserver gets a non-zero viewport from
|
|
66
|
+
the start. */
|
|
67
|
+
.kj-virt-frame {
|
|
68
|
+
display: flex;
|
|
69
|
+
flex-direction: column;
|
|
70
|
+
height: 400px;
|
|
71
|
+
min-width: 0;
|
|
72
|
+
border: 1px solid var(--kj-border-default);
|
|
73
|
+
border-radius: var(--kj-radius-field);
|
|
74
|
+
background: var(--kj-bg-surface);
|
|
75
|
+
overflow: hidden;
|
|
76
|
+
}
|
|
77
|
+
.kj-virt-frame kj-table {
|
|
78
|
+
flex: 1 1 auto;
|
|
79
|
+
min-height: 0;
|
|
80
|
+
}
|
|
81
|
+
`],
|
|
82
|
+
template: `
|
|
83
|
+
<div class="toolbar">
|
|
84
|
+
<kj-button kjVariant="outline" kjSize="sm" (click)="scrollToRow(5000)">
|
|
85
|
+
Scroll to row 5000
|
|
86
|
+
</kj-button>
|
|
87
|
+
<span>Total: {{ data().length }} rows</span>
|
|
88
|
+
</div>
|
|
89
|
+
<div class="kj-virt-frame">
|
|
90
|
+
<kj-table
|
|
91
|
+
[kjData]="data()"
|
|
92
|
+
[kjColumns]="cols"
|
|
93
|
+
[kjVirtual]="true"
|
|
94
|
+
[kjEstimatedRowSize]="rowSize"
|
|
95
|
+
/>
|
|
96
|
+
</div>
|
|
97
|
+
`,
|
|
98
|
+
})
|
|
99
|
+
export class KjTableVirtualizedExample {
|
|
100
|
+
private readonly host: ElementRef<HTMLElement> = inject(ElementRef);
|
|
101
|
+
|
|
102
|
+
protected readonly rowSize = 32;
|
|
103
|
+
protected readonly data = signal<Row[]>(makeRows(10_000));
|
|
104
|
+
|
|
105
|
+
protected readonly cols = [
|
|
106
|
+
kjColumn<Row>({ accessorKey: 'id', header: 'ID' }),
|
|
107
|
+
kjColumn<Row>({ accessorKey: 'name', header: 'Name' }),
|
|
108
|
+
kjColumn<Row>({ accessorKey: 'score', header: 'Score' }),
|
|
109
|
+
kjColumn<Row>({ accessorKey: 'city', header: 'City' }),
|
|
110
|
+
];
|
|
111
|
+
|
|
112
|
+
protected scrollToRow(index: number): void {
|
|
113
|
+
// The scroll viewport is the table's own body — that's what the
|
|
114
|
+
// virtualizer attaches to (it walks up from `<tbody>` to find the
|
|
115
|
+
// wrapper's `.kj-table-body`).
|
|
116
|
+
const scroller = this.host.nativeElement.querySelector<HTMLElement>(
|
|
117
|
+
'kj-table .kj-table-body',
|
|
118
|
+
);
|
|
119
|
+
if (!scroller) return;
|
|
120
|
+
scroller.scrollTop = index * this.rowSize;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './table';
|
|
2
|
+
export * from './table-toolbar';
|
|
3
|
+
export * from './table-pagination';
|
|
4
|
+
export * from './table-side-panel';
|
|
5
|
+
export * from './table-status-bar';
|
|
6
|
+
export * from './table-export';
|
|
7
|
+
export * from './table-virtual';
|
|
8
|
+
export * from './table-editors';
|
|
9
|
+
export * from './table-filters';
|
|
10
|
+
export * from './table-cell-editor-outlet';
|
|
11
|
+
export * from './table-filter-outlet';
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DestroyRef,
|
|
3
|
+
Directive,
|
|
4
|
+
EnvironmentInjector,
|
|
5
|
+
Injector,
|
|
6
|
+
Type,
|
|
7
|
+
ViewContainerRef,
|
|
8
|
+
effect,
|
|
9
|
+
inject,
|
|
10
|
+
input,
|
|
11
|
+
output,
|
|
12
|
+
untracked,
|
|
13
|
+
type ComponentRef,
|
|
14
|
+
} from '@angular/core';
|
|
15
|
+
import { KJ_EDITOR_CONTRACT, type KjEditorContract } from './table-editors';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Structural outlet that mounts a cell editor component into its own
|
|
19
|
+
* `ViewContainerRef`. Replaces the old anchor-`<span>` + `querySelectorAll`
|
|
20
|
+
* sync loop: Angular's view lifecycle now owns mount and tear-down, so when
|
|
21
|
+
* the host `@if` removes the directive the editor is destroyed automatically.
|
|
22
|
+
*
|
|
23
|
+
* Place inside the cell's edit branch:
|
|
24
|
+
*
|
|
25
|
+
* ```html
|
|
26
|
+
* @if (isEditing(c)) {
|
|
27
|
+
* <ng-container
|
|
28
|
+
* kjCellEditorOutlet
|
|
29
|
+
* [kjEditor]="editorTypeFor(c)"
|
|
30
|
+
* [kjValue]="c.getValue()"
|
|
31
|
+
* (commit)="onEditCommit(c, $event)"
|
|
32
|
+
* (cancel)="onEditCancel()"
|
|
33
|
+
* />
|
|
34
|
+
* }
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* The directive wires `KJ_EDITOR_CONTRACT` so each editor sees the same
|
|
38
|
+
* `{ value, commit, cancel }` shape it does today — no editor changes needed.
|
|
39
|
+
*/
|
|
40
|
+
@Directive({
|
|
41
|
+
selector: '[kjCellEditorOutlet]',
|
|
42
|
+
standalone: true,
|
|
43
|
+
})
|
|
44
|
+
export class KjCellEditorOutlet {
|
|
45
|
+
/** Editor component class to mount. `null` mounts nothing. */
|
|
46
|
+
readonly kjEditor = input<Type<unknown> | null>(null);
|
|
47
|
+
|
|
48
|
+
/** Initial value seeded into the editor's `KJ_EDITOR_CONTRACT`. */
|
|
49
|
+
readonly kjValue = input<unknown>(undefined);
|
|
50
|
+
|
|
51
|
+
/** Extra column meta forwarded to the editor through the contract —
|
|
52
|
+
* used to hand off things like select options without binding inputs
|
|
53
|
+
* on a dynamically-created component. */
|
|
54
|
+
readonly kjMeta = input<Record<string, unknown> | undefined>(undefined);
|
|
55
|
+
|
|
56
|
+
/** Fired when the editor calls `contract.commit(next)`. */
|
|
57
|
+
readonly commit = output<unknown>();
|
|
58
|
+
|
|
59
|
+
/** Fired when the editor calls `contract.cancel()`. */
|
|
60
|
+
readonly editCancel = output<void>();
|
|
61
|
+
|
|
62
|
+
private readonly vcr = inject(ViewContainerRef);
|
|
63
|
+
private readonly envInjector = inject(EnvironmentInjector);
|
|
64
|
+
private readonly parentInjector = inject(Injector);
|
|
65
|
+
private readonly destroyRef = inject(DestroyRef);
|
|
66
|
+
|
|
67
|
+
private ref: ComponentRef<unknown> | null = null;
|
|
68
|
+
|
|
69
|
+
constructor() {
|
|
70
|
+
// Re-mount whenever the editor type changes. The initial value is
|
|
71
|
+
// captured non-reactively — we don't want every keystroke in the editor
|
|
72
|
+
// to re-seed it. Commit/cancel callbacks read the latest outputs at
|
|
73
|
+
// emit time, so they always wire through to the live component instance.
|
|
74
|
+
effect(() => {
|
|
75
|
+
const editor = this.kjEditor();
|
|
76
|
+
this.tearDown();
|
|
77
|
+
if (!editor) return;
|
|
78
|
+
|
|
79
|
+
const initialValue = untracked(() => this.kjValue());
|
|
80
|
+
const meta = untracked(() => this.kjMeta());
|
|
81
|
+
const contract: KjEditorContract<unknown> = {
|
|
82
|
+
value: initialValue,
|
|
83
|
+
commit: (next: unknown) => this.commit.emit(next),
|
|
84
|
+
cancel: () => this.editCancel.emit(),
|
|
85
|
+
meta,
|
|
86
|
+
};
|
|
87
|
+
const childInjector = Injector.create({
|
|
88
|
+
providers: [{ provide: KJ_EDITOR_CONTRACT, useValue: contract }],
|
|
89
|
+
parent: this.parentInjector,
|
|
90
|
+
});
|
|
91
|
+
this.ref = this.vcr.createComponent(editor, {
|
|
92
|
+
environmentInjector: this.envInjector,
|
|
93
|
+
injector: childInjector,
|
|
94
|
+
});
|
|
95
|
+
// Force the editor's view to materialize NOW so its child
|
|
96
|
+
// components (and their constructors — KjSelectTrigger registers
|
|
97
|
+
// itself with KjSelect at construction time) run synchronously.
|
|
98
|
+
// Without this, an effect-based focus call could fire before the
|
|
99
|
+
// trigger directive existed.
|
|
100
|
+
this.ref.changeDetectorRef.detectChanges();
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
this.destroyRef.onDestroy(() => this.tearDown());
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
private tearDown(): void {
|
|
107
|
+
this.ref?.destroy();
|
|
108
|
+
this.ref = null;
|
|
109
|
+
this.vcr.clear();
|
|
110
|
+
}
|
|
111
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ChangeDetectionStrategy,
|
|
3
|
+
Component,
|
|
4
|
+
ElementRef,
|
|
5
|
+
ViewEncapsulation,
|
|
6
|
+
afterNextRender,
|
|
7
|
+
inject,
|
|
8
|
+
signal,
|
|
9
|
+
} from '@angular/core';
|
|
10
|
+
import { KjToggleComponent } from '../../toggle/toggle';
|
|
11
|
+
import { KJ_EDITOR_CONTRACT, type KjEditorContract } from './index';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Inline boolean cell editor for `<kj-table>`. Renders the styled
|
|
15
|
+
* `<kj-toggle>` component (a real `<button role="switch">` with theme
|
|
16
|
+
* tokens) so cell editors stay consistent with the rest of the design
|
|
17
|
+
* system.
|
|
18
|
+
*
|
|
19
|
+
* Each toggle commits the new draft immediately. Escape cancels.
|
|
20
|
+
*/
|
|
21
|
+
@Component({
|
|
22
|
+
selector: 'kj-boolean-editor',
|
|
23
|
+
standalone: true,
|
|
24
|
+
imports: [KjToggleComponent],
|
|
25
|
+
template: `
|
|
26
|
+
<kj-toggle
|
|
27
|
+
class="kj-editor kj-editor--boolean"
|
|
28
|
+
appearance="switch"
|
|
29
|
+
[(pressed)]="draft"
|
|
30
|
+
(click)="ctx.commit(draft())"
|
|
31
|
+
(keydown.enter)="toggleAndCommit(); $event.preventDefault()"
|
|
32
|
+
(keydown.space)="toggleAndCommit(); $event.preventDefault()"
|
|
33
|
+
(keydown.escape)="cancel(); $event.stopPropagation()"
|
|
34
|
+
>
|
|
35
|
+
{{ draft() ? 'On' : 'Off' }}
|
|
36
|
+
</kj-toggle>
|
|
37
|
+
`,
|
|
38
|
+
encapsulation: ViewEncapsulation.None,
|
|
39
|
+
host: { style: 'display: contents;' },
|
|
40
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
41
|
+
})
|
|
42
|
+
export class KjBooleanEditor {
|
|
43
|
+
protected readonly ctx = inject(KJ_EDITOR_CONTRACT) as KjEditorContract<boolean>;
|
|
44
|
+
private readonly hostEl: ElementRef<HTMLElement> = inject(ElementRef);
|
|
45
|
+
|
|
46
|
+
protected readonly draft = signal<boolean>(false);
|
|
47
|
+
|
|
48
|
+
constructor() {
|
|
49
|
+
this.draft.set(!!this.ctx.value);
|
|
50
|
+
afterNextRender(() => {
|
|
51
|
+
const btn = this.hostEl.nativeElement.querySelector<HTMLButtonElement>('button');
|
|
52
|
+
btn?.focus();
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
protected cancel(): void {
|
|
57
|
+
this.ctx.cancel();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Flip the draft and commit. The `[(pressed)]` two-way binding into the
|
|
62
|
+
* kj-toggle handles updating its visual state — and the toggle's own
|
|
63
|
+
* `pressedChange` will also fire commit, but `ctx.commit` is idempotent
|
|
64
|
+
* from the host's perspective so a single user action -> single commit.
|
|
65
|
+
*/
|
|
66
|
+
protected toggleAndCommit(): void {
|
|
67
|
+
const next = !this.draft();
|
|
68
|
+
this.draft.set(next);
|
|
69
|
+
this.ctx.commit(next);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ChangeDetectionStrategy,
|
|
3
|
+
Component,
|
|
4
|
+
ElementRef,
|
|
5
|
+
ViewEncapsulation,
|
|
6
|
+
afterNextRender,
|
|
7
|
+
inject,
|
|
8
|
+
signal,
|
|
9
|
+
} from '@angular/core';
|
|
10
|
+
import { KjDatePickerComponent } from '../../date-picker/date-picker';
|
|
11
|
+
import { KJ_EDITOR_CONTRACT, type KjEditorContract } from './index';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Inline date cell editor for `<kj-table>`. Renders the styled
|
|
15
|
+
* `<kj-date-picker>` component (a typed input plus a popover calendar)
|
|
16
|
+
* so cell editors stay consistent with the rest of the design system.
|
|
17
|
+
*
|
|
18
|
+
* The contract uses real `Date | null`. We bind to a draft signal that
|
|
19
|
+
* mirrors the picker's `kjValue` model. Commits on Enter; cancels on
|
|
20
|
+
* Escape. Blur is intentionally NOT wired here — the styled picker's
|
|
21
|
+
* trigger directive emits `focusout` events during mount (the calendar
|
|
22
|
+
* popover and the calendar input swap focus internally) so a blur
|
|
23
|
+
* listener would fire prematurely. The host (table cell) can use
|
|
24
|
+
* the contract's external lifecycle to handle commit-on-cell-blur.
|
|
25
|
+
*/
|
|
26
|
+
@Component({
|
|
27
|
+
selector: 'kj-date-editor',
|
|
28
|
+
standalone: true,
|
|
29
|
+
imports: [KjDatePickerComponent],
|
|
30
|
+
template: `
|
|
31
|
+
<kj-date-picker
|
|
32
|
+
class="kj-editor kj-editor--date"
|
|
33
|
+
kjLocale="sv-SE"
|
|
34
|
+
[(kjValue)]="draft"
|
|
35
|
+
(keydown)="onKeydown($event)"
|
|
36
|
+
/>
|
|
37
|
+
`,
|
|
38
|
+
encapsulation: ViewEncapsulation.None,
|
|
39
|
+
host: { style: 'display: contents;' },
|
|
40
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
41
|
+
})
|
|
42
|
+
export class KjDateEditor {
|
|
43
|
+
private readonly ctx = inject(KJ_EDITOR_CONTRACT) as KjEditorContract<Date | null>;
|
|
44
|
+
private readonly hostEl: ElementRef<HTMLElement> = inject(ElementRef);
|
|
45
|
+
private settled = false;
|
|
46
|
+
|
|
47
|
+
protected readonly draft = signal<Date | null>(null);
|
|
48
|
+
|
|
49
|
+
constructor() {
|
|
50
|
+
const v = this.ctx.value;
|
|
51
|
+
this.draft.set(v instanceof Date && !Number.isNaN(v.getTime()) ? v : null);
|
|
52
|
+
afterNextRender(() => {
|
|
53
|
+
const input = this.hostEl.nativeElement.querySelector<HTMLInputElement>('input');
|
|
54
|
+
input?.focus();
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
protected commit(): void {
|
|
59
|
+
if (this.settled) return;
|
|
60
|
+
// Parse the input's typed text directly — at the moment Enter fires the
|
|
61
|
+
// styled date-picker has already pushed the parsed Date into its kjValue
|
|
62
|
+
// model via the trigger directive, but signal-propagation timing across
|
|
63
|
+
// the two-way binding chain (root context -> wrapper -> draft) is not
|
|
64
|
+
// guaranteed to be flushed before our handler runs. Reading the input
|
|
65
|
+
// element gives us a deterministic source of truth.
|
|
66
|
+
const input = this.hostEl.nativeElement.querySelector<HTMLInputElement>('input');
|
|
67
|
+
const raw = (input?.value ?? '').trim();
|
|
68
|
+
if (raw === '') {
|
|
69
|
+
this.settled = true;
|
|
70
|
+
this.ctx.commit(null);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const parsed = parseIsoLike(raw) ?? this.draft();
|
|
74
|
+
if (!parsed || Number.isNaN(parsed.getTime())) {
|
|
75
|
+
this.settled = true;
|
|
76
|
+
this.ctx.cancel();
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
this.settled = true;
|
|
80
|
+
this.ctx.commit(parsed);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
protected cancel(): void {
|
|
84
|
+
if (this.settled) return;
|
|
85
|
+
this.settled = true;
|
|
86
|
+
this.ctx.cancel();
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
protected onKeydown(event: KeyboardEvent): void {
|
|
90
|
+
if (event.key === 'Enter') {
|
|
91
|
+
this.commit();
|
|
92
|
+
} else if (event.key === 'Escape') {
|
|
93
|
+
event.stopPropagation();
|
|
94
|
+
this.cancel();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Parse the most common date shapes (ISO `YYYY-MM-DD`, also Swedish/locale
|
|
101
|
+
* forms that share that order). Falls back to `new Date(raw)` for ISO-with-
|
|
102
|
+
* time variants. Returns `null` for anything unparseable.
|
|
103
|
+
*/
|
|
104
|
+
function parseIsoLike(raw: string): Date | null {
|
|
105
|
+
const iso = /^(\d{4})-(\d{2})-(\d{2})$/.exec(raw);
|
|
106
|
+
if (iso) {
|
|
107
|
+
const y = Number(iso[1]);
|
|
108
|
+
const m = Number(iso[2]) - 1;
|
|
109
|
+
const d = Number(iso[3]);
|
|
110
|
+
const out = new Date(y, m, d);
|
|
111
|
+
if (out.getFullYear() === y && out.getMonth() === m && out.getDate() === d) return out;
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
const fallback = new Date(raw);
|
|
115
|
+
return Number.isNaN(fallback.getTime()) ? null : fallback;
|
|
116
|
+
}
|
|
117
|
+
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { Component, Type } from '@angular/core';
|
|
2
|
+
import { fireEvent, render } from '@testing-library/angular';
|
|
3
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
4
|
+
import {
|
|
5
|
+
KJ_EDITOR_CONTRACT,
|
|
6
|
+
KjBooleanEditor,
|
|
7
|
+
KjDateEditor,
|
|
8
|
+
KjNumberEditor,
|
|
9
|
+
KjSelectEditor,
|
|
10
|
+
KjTextEditor,
|
|
11
|
+
type KjEditorContract,
|
|
12
|
+
} from './index';
|
|
13
|
+
|
|
14
|
+
function makeCtx<T>(initial: T): KjEditorContract<T> & { commit: ReturnType<typeof vi.fn>; cancel: ReturnType<typeof vi.fn> } {
|
|
15
|
+
return {
|
|
16
|
+
value: initial,
|
|
17
|
+
commit: vi.fn(),
|
|
18
|
+
cancel: vi.fn(),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async function mount<T>(cmp: Type<T>, ctx: KjEditorContract<unknown>, host?: Type<unknown>) {
|
|
23
|
+
return render(host ?? cmp, {
|
|
24
|
+
imports: [cmp],
|
|
25
|
+
providers: [{ provide: KJ_EDITOR_CONTRACT, useValue: ctx }],
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
describe('KjTextEditor', () => {
|
|
30
|
+
it('reads initial value and commits on Enter', async () => {
|
|
31
|
+
const ctx = makeCtx<string>('hello');
|
|
32
|
+
const { container } = await mount(KjTextEditor, ctx);
|
|
33
|
+
const input = container.querySelector('input') as HTMLInputElement;
|
|
34
|
+
expect(input.value).toBe('hello');
|
|
35
|
+
fireEvent.input(input, { target: { value: 'world' } });
|
|
36
|
+
fireEvent.keyDown(input, { key: 'Enter' });
|
|
37
|
+
expect(ctx.commit).toHaveBeenCalledWith('world');
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('calls cancel on Escape', async () => {
|
|
41
|
+
const ctx = makeCtx<string>('abc');
|
|
42
|
+
const { container } = await mount(KjTextEditor, ctx);
|
|
43
|
+
const input = container.querySelector('input') as HTMLInputElement;
|
|
44
|
+
fireEvent.keyDown(input, { key: 'Escape' });
|
|
45
|
+
expect(ctx.cancel).toHaveBeenCalled();
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
describe('KjNumberEditor', () => {
|
|
50
|
+
it('reads initial number and commits parsed number on Enter', async () => {
|
|
51
|
+
const ctx = makeCtx<number>(42);
|
|
52
|
+
const { container } = await mount(KjNumberEditor, ctx);
|
|
53
|
+
const input = container.querySelector('input') as HTMLInputElement;
|
|
54
|
+
expect(input.value).toBe('42');
|
|
55
|
+
fireEvent.input(input, { target: { value: '99' } });
|
|
56
|
+
fireEvent.keyDown(input, { key: 'Enter' });
|
|
57
|
+
expect(ctx.commit).toHaveBeenCalledWith(99);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('calls cancel on Escape', async () => {
|
|
61
|
+
const ctx = makeCtx<number>(1);
|
|
62
|
+
const { container } = await mount(KjNumberEditor, ctx);
|
|
63
|
+
const input = container.querySelector('input') as HTMLInputElement;
|
|
64
|
+
fireEvent.keyDown(input, { key: 'Escape' });
|
|
65
|
+
expect(ctx.cancel).toHaveBeenCalled();
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
describe('KjDateEditor', () => {
|
|
70
|
+
it('reads initial date as ISO string and commits Date on Enter', async () => {
|
|
71
|
+
const seed = new Date(2026, 0, 15);
|
|
72
|
+
const ctx = makeCtx<Date | null>(seed);
|
|
73
|
+
const { container } = await mount(KjDateEditor, ctx);
|
|
74
|
+
const input = container.querySelector('input') as HTMLInputElement;
|
|
75
|
+
expect(input.value).toBe('2026-01-15');
|
|
76
|
+
fireEvent.input(input, { target: { value: '2026-05-17' } });
|
|
77
|
+
fireEvent.keyDown(input, { key: 'Enter' });
|
|
78
|
+
expect(ctx.commit).toHaveBeenCalledTimes(1);
|
|
79
|
+
const committed = (ctx.commit as ReturnType<typeof vi.fn>).mock.calls[0]?.[0] as Date;
|
|
80
|
+
expect(committed).toBeInstanceOf(Date);
|
|
81
|
+
expect(committed.getFullYear()).toBe(2026);
|
|
82
|
+
expect(committed.getMonth()).toBe(4);
|
|
83
|
+
expect(committed.getDate()).toBe(17);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it('calls cancel on Escape', async () => {
|
|
87
|
+
const ctx = makeCtx<Date | null>(null);
|
|
88
|
+
const { container } = await mount(KjDateEditor, ctx);
|
|
89
|
+
const input = container.querySelector('input') as HTMLInputElement;
|
|
90
|
+
fireEvent.keyDown(input, { key: 'Escape' });
|
|
91
|
+
expect(ctx.cancel).toHaveBeenCalled();
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
describe('KjSelectEditor', () => {
|
|
96
|
+
@Component({
|
|
97
|
+
standalone: true,
|
|
98
|
+
imports: [KjSelectEditor],
|
|
99
|
+
template: `<kj-select-editor [kjOptions]="opts" />`,
|
|
100
|
+
})
|
|
101
|
+
class SelectHost {
|
|
102
|
+
readonly opts: ReadonlyArray<string> = ['a', 'b', 'c'];
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
it('reads initial value and commits selected option on activation', async () => {
|
|
106
|
+
const ctx = makeCtx<unknown>('b');
|
|
107
|
+
const { container } = await mount(KjSelectEditor, ctx, SelectHost);
|
|
108
|
+
// The styled kj-select renders a trigger button + portalled listbox.
|
|
109
|
+
// Activate the trigger, then click the third option.
|
|
110
|
+
const trigger = container.querySelector('button') as HTMLButtonElement;
|
|
111
|
+
expect(trigger).toBeTruthy();
|
|
112
|
+
fireEvent.click(trigger);
|
|
113
|
+
// Options are portalled to document.body via the overlay primitive.
|
|
114
|
+
const options = document.querySelectorAll('[kjOption], [role="option"]');
|
|
115
|
+
expect(options.length).toBe(3);
|
|
116
|
+
fireEvent.click(options[2] as HTMLElement);
|
|
117
|
+
expect(ctx.commit).toHaveBeenCalledWith('c');
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it('calls cancel on Escape', async () => {
|
|
121
|
+
const ctx = makeCtx<unknown>('a');
|
|
122
|
+
const { container } = await mount(KjSelectEditor, ctx, SelectHost);
|
|
123
|
+
const trigger = container.querySelector('button') as HTMLButtonElement;
|
|
124
|
+
fireEvent.keyDown(trigger, { key: 'Escape' });
|
|
125
|
+
expect(ctx.cancel).toHaveBeenCalled();
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
describe('KjBooleanEditor', () => {
|
|
130
|
+
it('reads initial value and commits toggled value on Enter', async () => {
|
|
131
|
+
const ctx = makeCtx<boolean>(false);
|
|
132
|
+
const { container } = await mount(KjBooleanEditor, ctx);
|
|
133
|
+
const btn = container.querySelector('button') as HTMLButtonElement;
|
|
134
|
+
// The styled kj-toggle uses role="switch" + aria-pressed (per APG button-with-state pattern).
|
|
135
|
+
expect(btn.getAttribute('aria-pressed')).toBe('false');
|
|
136
|
+
fireEvent.keyDown(btn, { key: 'Enter' });
|
|
137
|
+
expect(ctx.commit).toHaveBeenCalledWith(true);
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
it('calls cancel on Escape', async () => {
|
|
141
|
+
const ctx = makeCtx<boolean>(true);
|
|
142
|
+
const { container } = await mount(KjBooleanEditor, ctx);
|
|
143
|
+
const btn = container.querySelector('button') as HTMLButtonElement;
|
|
144
|
+
fireEvent.keyDown(btn, { key: 'Escape' });
|
|
145
|
+
expect(ctx.cancel).toHaveBeenCalled();
|
|
146
|
+
});
|
|
147
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { InjectionToken } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Contract handed to a cell editor when the user enters edit mode.
|
|
5
|
+
*
|
|
6
|
+
* The host (a table cell) wires up:
|
|
7
|
+
* - `value` — the current cell value to seed the editor with;
|
|
8
|
+
* - `commit(next)` — called when the editor wants to persist the new value
|
|
9
|
+
* (Enter, blur for text-like editors, or change for select/boolean);
|
|
10
|
+
* - `cancel()` — called when the user aborts editing (Escape).
|
|
11
|
+
*
|
|
12
|
+
* Editors should not assume anything about how the host applies the commit —
|
|
13
|
+
* they just call `commit(next)` with the resolved value.
|
|
14
|
+
*/
|
|
15
|
+
export interface KjEditorContract<TValue> {
|
|
16
|
+
/** Initial value shown when the editor mounts. */
|
|
17
|
+
value: TValue;
|
|
18
|
+
/** Persist the new value. */
|
|
19
|
+
commit: (next: TValue) => void;
|
|
20
|
+
/** Discard the in-progress edit. */
|
|
21
|
+
cancel: () => void;
|
|
22
|
+
/** Column meta forwarded to the editor — e.g. select options, min/max
|
|
23
|
+
* for number editors, custom params. Editors read what they need and
|
|
24
|
+
* ignore the rest. */
|
|
25
|
+
meta?: Record<string, unknown>;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* DI token for the {@link KjEditorContract}. The table cell that mounts an
|
|
30
|
+
* editor provides this token; each editor injects it and reacts to its
|
|
31
|
+
* `value` / `commit` / `cancel` hooks.
|
|
32
|
+
*/
|
|
33
|
+
export const KJ_EDITOR_CONTRACT = new InjectionToken<KjEditorContract<unknown>>(
|
|
34
|
+
'kj.editor.contract',
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
export * from './text-editor';
|
|
38
|
+
export * from './number-editor';
|
|
39
|
+
export * from './date-editor';
|
|
40
|
+
export * from './select-editor';
|
|
41
|
+
export * from './boolean-editor';
|