@kouji-ui/core 0.0.4 → 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 +7 -4
- package/CHANGELOG.md +169 -0
- package/ng-package.json +5 -1
- package/package.json +18 -6
- package/src/a11y/aria-describedby.ts +7 -3
- package/src/a11y/aria-labelledby.spec.ts +55 -0
- package/src/a11y/aria-labelledby.ts +38 -0
- package/src/a11y/focus-trap.ts +4 -2
- package/src/a11y/index.ts +1 -0
- package/src/a11y/live-region.ts +4 -2
- package/src/a11y/roving-tabindex.spec.ts +139 -0
- package/src/a11y/roving-tabindex.ts +56 -7
- package/src/a11y/visually-hidden.ts +4 -2
- package/src/accordion/accordion.context.ts +22 -0
- package/src/accordion/accordion.spec.ts +233 -23
- package/src/accordion/accordion.ts +311 -39
- package/src/accordion/index.ts +8 -2
- package/src/alert/alert.context.ts +28 -0
- package/src/alert/alert.spec.ts +217 -0
- package/src/alert/alert.ts +417 -0
- package/src/alert/config.ts +46 -0
- package/src/alert/index.ts +19 -0
- package/src/avatar/avatar-group.context.ts +45 -0
- package/src/avatar/avatar-group.spec.ts +358 -0
- package/src/avatar/avatar-group.ts +259 -0
- package/src/avatar/avatar.ts +17 -4
- package/src/avatar/index.ts +11 -1
- package/src/badge/badge.spec.ts +8 -0
- package/src/badge/badge.ts +24 -3
- package/src/breadcrumb/breadcrumb-current.ts +38 -0
- package/src/breadcrumb/breadcrumb-ellipsis.ts +71 -0
- package/src/breadcrumb/breadcrumb-item.ts +41 -0
- package/src/breadcrumb/breadcrumb-link.ts +44 -0
- package/src/breadcrumb/breadcrumb-list.ts +42 -0
- package/src/breadcrumb/breadcrumb-separator.ts +45 -0
- package/src/breadcrumb/breadcrumb.context.ts +45 -0
- package/src/breadcrumb/breadcrumb.spec.ts +354 -0
- package/src/breadcrumb/breadcrumb.ts +239 -0
- package/src/breadcrumb/config.ts +84 -0
- package/src/breadcrumb/index.ts +18 -0
- package/src/button/_examples/button.example.ts +71 -0
- package/src/button/_examples/button.finance.example.ts +83 -0
- package/src/button/_examples/button.retro.example.ts +91 -0
- package/src/button/_examples/button.sizes.example.ts +60 -0
- package/src/button/_examples/index.ts +6 -0
- package/src/button/button.spec.ts +139 -8
- package/src/button/button.ts +114 -16
- package/src/button/config.spec.ts +33 -0
- package/src/button/config.ts +45 -0
- package/src/button/index.ts +2 -1
- package/src/button-group/button-group.context.ts +28 -0
- package/src/button-group/button-group.spec.ts +99 -0
- package/src/button-group/button-group.ts +99 -0
- package/src/button-group/index.ts +2 -0
- package/src/calendar/calendar-day.ts +102 -0
- package/src/calendar/calendar-grid.ts +90 -0
- package/src/calendar/calendar-header.ts +65 -0
- package/src/calendar/calendar.context.ts +53 -0
- package/src/calendar/calendar.spec.ts +225 -0
- package/src/calendar/calendar.ts +233 -0
- package/src/calendar/date-utils.ts +225 -0
- package/src/calendar/index.ts +28 -0
- package/src/carousel/carousel.context.ts +81 -0
- package/src/carousel/carousel.spec.ts +337 -0
- package/src/carousel/carousel.ts +919 -0
- package/src/carousel/index.ts +22 -0
- package/src/cascade-select/cascade-select-option.ts +205 -0
- package/src/cascade-select/cascade-select-panel.ts +106 -0
- package/src/cascade-select/cascade-select-root.ts +265 -0
- package/src/cascade-select/cascade-select-sub-panel.ts +168 -0
- package/src/cascade-select/cascade-select-trigger.ts +44 -0
- package/src/cascade-select/cascade-select.context.ts +71 -0
- package/src/cascade-select/cascade-select.spec.ts +241 -0
- package/src/cascade-select/cascade-select.ts +5 -0
- package/src/cascade-select/index.ts +11 -0
- package/src/chart/chart.ts +6 -2
- package/src/chat/chat-avatar.ts +31 -0
- package/src/chat/chat-bubble.ts +49 -0
- package/src/chat/chat-footer.ts +67 -0
- package/src/chat/chat-header.ts +41 -0
- package/src/chat/chat-log.ts +43 -0
- package/src/chat/chat.context.ts +64 -0
- package/src/chat/chat.spec.ts +341 -0
- package/src/chat/chat.ts +191 -0
- package/src/chat/config.ts +53 -0
- package/src/chat/index.ts +21 -0
- package/src/checkbox/checkbox.ts +9 -2
- package/src/color-picker/color-picker.context.ts +74 -0
- package/src/color-picker/color-picker.spec.ts +241 -0
- package/src/color-picker/color-picker.ts +698 -0
- package/src/color-picker/color-picker.utils.ts +140 -0
- package/src/color-picker/index.ts +28 -0
- package/src/combobox/combobox-input.ts +143 -0
- package/src/combobox/combobox-listbox.ts +49 -0
- package/src/combobox/combobox-option.ts +43 -0
- package/src/combobox/combobox-root.ts +281 -0
- package/src/combobox/combobox.spec.ts +75 -0
- package/src/combobox/combobox.ts +4 -0
- package/src/combobox/index.ts +4 -0
- package/src/command-palette/command-empty.ts +36 -0
- package/src/command-palette/command-group.ts +21 -0
- package/src/command-palette/command-input.ts +70 -0
- package/src/command-palette/command-item.ts +60 -0
- package/src/command-palette/command-list.ts +25 -0
- package/src/command-palette/command-palette-dialog.ts +74 -0
- package/src/command-palette/command-palette-trigger.ts +64 -0
- package/src/command-palette/command-palette.filters.ts +53 -0
- package/src/command-palette/command-palette.spec.ts +349 -0
- package/src/command-palette/command-palette.ts +204 -0
- package/src/command-palette/command-separator.ts +18 -0
- package/src/command-palette/index.ts +15 -0
- package/src/confirm-popup/confirm-popup-action.ts +39 -0
- package/src/confirm-popup/confirm-popup-cancel.ts +38 -0
- package/src/confirm-popup/confirm-popup-content.ts +113 -0
- package/src/confirm-popup/confirm-popup-message.ts +36 -0
- package/src/confirm-popup/confirm-popup-trigger.ts +31 -0
- package/src/confirm-popup/confirm-popup.context.ts +41 -0
- package/src/confirm-popup/confirm-popup.spec.ts +337 -0
- package/src/confirm-popup/confirm-popup.ts +109 -0
- package/src/confirm-popup/index.ts +12 -0
- package/src/date-picker/date-picker-calendar.ts +65 -0
- package/src/date-picker/date-picker-trigger.ts +215 -0
- package/src/date-picker/date-picker.context.ts +50 -0
- package/src/date-picker/date-picker.spec.ts +117 -0
- package/src/date-picker/date-picker.ts +127 -0
- package/src/date-picker/index.ts +7 -0
- package/src/dialog/_examples/dialog.confirm.example.ts +145 -0
- package/src/dialog/_examples/dialog.example.ts +106 -0
- package/src/dialog/_examples/dialog.finance.example.ts +121 -0
- package/src/dialog/_examples/dialog.retro.example.ts +126 -0
- package/src/dialog/_examples/index.ts +6 -0
- package/src/dialog/dialog.ref.ts +42 -0
- package/src/dialog/dialog.service.ts +57 -167
- package/src/dialog/dialog.spec.ts +35 -120
- package/src/dialog/dialog.ts +17 -192
- package/src/dialog/index.ts +3 -9
- package/src/divider/divider.spec.ts +223 -0
- package/src/divider/divider.ts +137 -0
- package/src/divider/index.ts +5 -0
- package/src/drawer/drawer.ref.ts +63 -0
- package/src/drawer/drawer.service.ts +106 -0
- package/src/drawer/drawer.spec.ts +117 -0
- package/src/drawer/drawer.ts +122 -0
- package/src/drawer/index.ts +10 -0
- package/src/dropdown-menu/dropdown-menu-content.ts +258 -0
- package/src/dropdown-menu/dropdown-menu-group.ts +31 -0
- package/src/dropdown-menu/dropdown-menu-item.ts +51 -0
- package/src/dropdown-menu/dropdown-menu-label.ts +41 -0
- package/src/dropdown-menu/dropdown-menu-separator.ts +27 -0
- package/src/dropdown-menu/dropdown-menu-trigger.ts +140 -0
- package/src/dropdown-menu/dropdown-menu.spec.ts +265 -0
- package/src/dropdown-menu/dropdown-menu.ts +60 -0
- package/src/dropdown-menu/index.ts +15 -0
- package/src/example-components.ts +39 -30
- package/src/field/field-error.ts +49 -0
- package/src/field/field-group.ts +39 -0
- package/src/field/field-help.ts +47 -0
- package/src/field/field-label.ts +30 -0
- package/src/field/field.context.ts +28 -0
- package/src/field/field.spec.ts +179 -0
- package/src/field/field.ts +121 -0
- package/src/field/index.ts +6 -0
- package/src/file-upload/file-upload.context.ts +89 -0
- package/src/file-upload/file-upload.spec.ts +290 -0
- package/src/file-upload/file-upload.ts +639 -0
- package/src/file-upload/file-upload.types.ts +59 -0
- package/src/file-upload/index.ts +23 -0
- package/src/form/form-error-summary.ts +87 -0
- package/src/form/form-field.context.ts +3 -0
- package/src/form/form-field.spec.ts +25 -0
- package/src/form/form-field.ts +52 -0
- package/src/form/form.context.ts +52 -2
- package/src/form/form.spec.ts +155 -18
- package/src/form/form.ts +315 -35
- package/src/form/index.ts +11 -2
- package/src/icon/E2E.md +14 -0
- package/src/icon/icon.css +40 -0
- package/src/icon/icon.directive.spec.ts +198 -0
- package/src/icon/icon.directive.ts +113 -0
- package/src/icon/icon.mode.spec.ts +29 -0
- package/src/icon/icon.mode.ts +23 -0
- package/src/icon/icon.providers.spec.ts +63 -0
- package/src/icon/icon.providers.ts +47 -0
- package/src/icon/icon.resolver.spec.ts +96 -0
- package/src/icon/icon.resolver.ts +49 -0
- package/src/icon/icon.tokens.ts +88 -0
- package/src/icon/icon.types.ts +48 -0
- package/src/icon/index.ts +21 -0
- package/src/input/input.ts +12 -3
- package/src/input-group/index.ts +3 -0
- package/src/input-group/input-group-addon.ts +92 -0
- package/src/input-group/input-group.context.ts +27 -0
- package/src/input-group/input-group.spec.ts +186 -0
- package/src/input-group/input-group.ts +136 -0
- package/src/input-mask/index.ts +11 -0
- package/src/input-mask/input-mask.compile.ts +69 -0
- package/src/input-mask/input-mask.engine.ts +376 -0
- package/src/input-mask/input-mask.presets.ts +24 -0
- package/src/input-mask/input-mask.spec.ts +304 -0
- package/src/input-mask/input-mask.tokens.ts +49 -0
- package/src/input-mask/input-mask.ts +280 -0
- package/src/input-otp/index.ts +2 -0
- package/src/input-otp/input-otp.context.ts +41 -0
- package/src/input-otp/input-otp.spec.ts +308 -0
- package/src/input-otp/input-otp.ts +470 -0
- package/src/kbd/index.ts +1 -0
- package/src/kbd/kbd.spec.ts +127 -0
- package/src/kbd/kbd.ts +132 -0
- package/src/link/config.ts +44 -0
- package/src/link/index.ts +2 -0
- package/src/link/link.spec.ts +246 -0
- package/src/link/link.ts +226 -0
- package/src/list/index.ts +11 -0
- package/src/list/list.spec.ts +237 -0
- package/src/list/list.ts +277 -0
- package/src/menubar/index.ts +7 -0
- package/src/menubar/menubar-item.ts +204 -0
- package/src/menubar/menubar.context.ts +43 -0
- package/src/menubar/menubar.spec.ts +433 -0
- package/src/menubar/menubar.ts +309 -0
- package/src/number-input/index.ts +4 -0
- package/src/number-input/number-input-group.ts +64 -0
- package/src/number-input/number-input.context.ts +31 -0
- package/src/number-input/number-input.format.ts +148 -0
- package/src/number-input/number-input.spec.ts +170 -0
- package/src/number-input/number-input.ts +457 -0
- package/src/number-input/number-stepper.ts +193 -0
- package/src/overlay-badge/index.ts +7 -0
- package/src/overlay-badge/overlay-badge-content.ts +73 -0
- package/src/overlay-badge/overlay-badge.context.ts +37 -0
- package/src/overlay-badge/overlay-badge.spec.ts +220 -0
- package/src/overlay-badge/overlay-badge.ts +128 -0
- package/src/pagination/config.ts +82 -0
- package/src/pagination/index.ts +19 -0
- package/src/pagination/page-tokens.ts +78 -0
- package/src/pagination/pagination-ellipsis.ts +69 -0
- package/src/pagination/pagination-first.ts +84 -0
- package/src/pagination/pagination-info.ts +70 -0
- package/src/pagination/pagination-item.ts +81 -0
- package/src/pagination/pagination-last.ts +85 -0
- package/src/pagination/pagination-next.ts +86 -0
- package/src/pagination/pagination-previous.ts +90 -0
- package/src/pagination/pagination.context.ts +52 -0
- package/src/pagination/pagination.spec.ts +388 -0
- package/src/pagination/pagination.ts +288 -0
- package/src/password-input/index.ts +15 -0
- package/src/password-input/password-input.context.ts +65 -0
- package/src/password-input/password-input.scorer.ts +34 -0
- package/src/password-input/password-input.spec.ts +274 -0
- package/src/password-input/password-input.ts +488 -0
- package/src/popover/_examples/index.ts +5 -0
- package/src/popover/_examples/popover.example.ts +92 -0
- package/src/popover/_examples/popover.finance.example.ts +106 -0
- package/src/popover/_examples/popover.retro.example.ts +103 -0
- package/src/popover/index.ts +5 -12
- package/src/popover/popover-arrow.ts +30 -0
- package/src/popover/popover-close.ts +36 -0
- package/src/popover/popover-content.ts +41 -0
- package/src/popover/popover-title.ts +39 -0
- package/src/popover/popover-trigger.ts +40 -0
- package/src/popover/popover.spec.ts +51 -44
- package/src/popover/popover.ts +5 -124
- package/src/presets/bind-presets.spec.ts +50 -0
- package/src/presets/bind-presets.ts +43 -0
- package/src/presets/index.ts +3 -0
- package/src/presets/size.spec.ts +67 -0
- package/src/presets/size.ts +59 -0
- package/src/presets/variant.spec.ts +72 -0
- package/src/presets/variant.ts +62 -0
- package/src/primitives/directionality/directionality.spec.ts +112 -0
- package/src/primitives/directionality/directionality.ts +89 -0
- package/src/primitives/directionality/index.ts +1 -0
- package/src/primitives/forms/form-control.spec.ts +11 -3
- package/src/primitives/forms/form-control.ts +6 -2
- package/src/primitives/index.ts +3 -0
- package/src/primitives/interaction/disabled.ts +12 -5
- package/src/primitives/interaction/focus-ring.ts +4 -2
- package/src/primitives/list/filterable-list.spec.ts +114 -0
- package/src/primitives/list/filterable-list.ts +126 -0
- package/src/primitives/list/group.spec.ts +99 -0
- package/src/primitives/list/group.ts +139 -0
- package/src/primitives/list/index.ts +8 -0
- package/src/primitives/list/inject-helpers.ts +8 -0
- package/src/primitives/list/item.spec.ts +173 -0
- package/src/primitives/list/item.ts +222 -0
- package/src/primitives/list/navigator.spec.ts +286 -0
- package/src/primitives/list/navigator.ts +238 -0
- package/src/primitives/list/selection.spec.ts +214 -0
- package/src/primitives/list/selection.ts +339 -0
- package/src/primitives/list/tokens.ts +106 -0
- package/src/primitives/list/type-ahead.spec.ts +58 -0
- package/src/primitives/list/type-ahead.ts +46 -0
- package/src/primitives/overlay/backdrop.spec.ts +54 -0
- package/src/primitives/overlay/backdrop.ts +31 -0
- package/src/primitives/overlay/builder.spec.ts +38 -0
- package/src/primitives/overlay/builder.ts +151 -0
- package/src/primitives/overlay/container.ts +42 -0
- package/src/primitives/overlay/context.ts +14 -0
- package/src/primitives/overlay/controller.spec.ts +86 -0
- package/src/primitives/overlay/controller.ts +190 -0
- package/src/primitives/overlay/id.spec.ts +24 -0
- package/src/primitives/overlay/id.ts +17 -0
- package/src/primitives/overlay/index.ts +18 -1
- package/src/primitives/overlay/overlay.css +42 -0
- package/src/primitives/overlay/panel.spec.ts +52 -0
- package/src/primitives/overlay/panel.ts +102 -0
- package/src/primitives/overlay/stack.spec.ts +55 -0
- package/src/primitives/overlay/stack.ts +113 -0
- package/src/primitives/overlay/strategies/backdrop/blurred.spec.ts +11 -0
- package/src/primitives/overlay/strategies/backdrop/blurred.ts +5 -0
- package/src/primitives/overlay/strategies/backdrop/none.spec.ts +10 -0
- package/src/primitives/overlay/strategies/backdrop/none.ts +9 -0
- package/src/primitives/overlay/strategies/backdrop/solid.spec.ts +18 -0
- package/src/primitives/overlay/strategies/backdrop/solid.ts +23 -0
- package/src/primitives/overlay/strategies/focus-trap/inert-based.spec.ts +28 -0
- package/src/primitives/overlay/strategies/focus-trap/inert-based.ts +38 -0
- package/src/primitives/overlay/strategies/focus-trap/no-trap.spec.ts +9 -0
- package/src/primitives/overlay/strategies/focus-trap/no-trap.ts +8 -0
- package/src/primitives/overlay/strategies/focus-trap/tab-cycle.spec.ts +49 -0
- package/src/primitives/overlay/strategies/focus-trap/tab-cycle.ts +85 -0
- package/src/primitives/overlay/strategies/index.ts +34 -0
- package/src/primitives/overlay/strategies/live-announcer/_announce.ts +35 -0
- package/src/primitives/overlay/strategies/live-announcer/assertive.spec.ts +21 -0
- package/src/primitives/overlay/strategies/live-announcer/assertive.ts +11 -0
- package/src/primitives/overlay/strategies/live-announcer/polite.spec.ts +21 -0
- package/src/primitives/overlay/strategies/live-announcer/polite.ts +11 -0
- package/src/primitives/overlay/strategies/live-announcer/silent.spec.ts +12 -0
- package/src/primitives/overlay/strategies/live-announcer/silent.ts +5 -0
- package/src/primitives/overlay/strategies/mount/body-portal.spec.ts +40 -0
- package/src/primitives/overlay/strategies/mount/body-portal.ts +91 -0
- package/src/primitives/overlay/strategies/mount/in-container.spec.ts +43 -0
- package/src/primitives/overlay/strategies/mount/in-container.ts +39 -0
- package/src/primitives/overlay/strategies/mount/in-place.spec.ts +40 -0
- package/src/primitives/overlay/strategies/mount/in-place.ts +20 -0
- package/src/primitives/overlay/strategies/position/anchored-to.spec.ts +56 -0
- package/src/primitives/overlay/strategies/position/anchored-to.ts +248 -0
- package/src/primitives/overlay/strategies/position/corner.spec.ts +36 -0
- package/src/primitives/overlay/strategies/position/corner.ts +33 -0
- package/src/primitives/overlay/strategies/position/edge-sheet.spec.ts +32 -0
- package/src/primitives/overlay/strategies/position/edge-sheet.ts +36 -0
- package/src/primitives/overlay/strategies/position/in-place-sibling.spec.ts +25 -0
- package/src/primitives/overlay/strategies/position/in-place-sibling.ts +13 -0
- package/src/primitives/overlay/strategies/position/point-at.spec.ts +40 -0
- package/src/primitives/overlay/strategies/position/point-at.ts +34 -0
- package/src/primitives/overlay/strategies/position/viewport-centered.spec.ts +31 -0
- package/src/primitives/overlay/strategies/position/viewport-centered.ts +31 -0
- package/src/primitives/overlay/strategies/scroll-lock/css-clip.spec.ts +15 -0
- package/src/primitives/overlay/strategies/scroll-lock/css-clip.ts +39 -0
- package/src/primitives/overlay/strategies/scroll-lock/html-overflow.spec.ts +21 -0
- package/src/primitives/overlay/strategies/scroll-lock/html-overflow.ts +44 -0
- package/src/primitives/overlay/strategies/scroll-lock/none.spec.ts +9 -0
- package/src/primitives/overlay/strategies/scroll-lock/none.ts +5 -0
- package/src/primitives/overlay/strategies/trigger-event/on-click.spec.ts +32 -0
- package/src/primitives/overlay/strategies/trigger-event/on-click.ts +28 -0
- package/src/primitives/overlay/strategies/trigger-event/on-context-menu.spec.ts +45 -0
- package/src/primitives/overlay/strategies/trigger-event/on-context-menu.ts +70 -0
- package/src/primitives/overlay/strategies/trigger-event/on-focus-or-input.spec.ts +35 -0
- package/src/primitives/overlay/strategies/trigger-event/on-focus-or-input.ts +34 -0
- package/src/primitives/overlay/strategies/trigger-event/on-focus.spec.ts +64 -0
- package/src/primitives/overlay/strategies/trigger-event/on-focus.ts +37 -0
- package/src/primitives/overlay/strategies/trigger-event/on-hotkey.spec.ts +37 -0
- package/src/primitives/overlay/strategies/trigger-event/on-hotkey.ts +59 -0
- package/src/primitives/overlay/strategies/trigger-event/on-hover.spec.ts +34 -0
- package/src/primitives/overlay/strategies/trigger-event/on-hover.ts +86 -0
- package/src/primitives/overlay/strategies/trigger-event/programmatic.spec.ts +16 -0
- package/src/primitives/overlay/strategies/trigger-event/programmatic.ts +12 -0
- package/src/primitives/overlay/tokens.ts +54 -0
- package/src/primitives/overlay/trigger.spec.ts +103 -0
- package/src/primitives/overlay/trigger.ts +75 -0
- package/src/primitives/overlay/types.ts +24 -0
- package/src/primitives/overlay/wrapper.ts +50 -0
- package/src/primitives/signals/deep-signal.ts +109 -0
- package/src/primitives/signals/index.ts +1 -0
- package/src/progress-bar/config.ts +48 -0
- package/src/progress-bar/index.ts +12 -0
- package/src/progress-bar/progress-bar-fill.ts +37 -0
- package/src/progress-bar/progress-bar.context.ts +34 -0
- package/src/progress-bar/progress-bar.spec.ts +423 -0
- package/src/progress-bar/progress-bar.ts +217 -0
- package/src/public-api.ts +58 -9
- package/src/radio/radio.ts +14 -3
- package/src/select/index.ts +4 -2
- package/src/select/select-content.ts +69 -0
- package/src/select/select-option.ts +35 -0
- package/src/select/select-root.ts +129 -0
- package/src/select/select-trigger.ts +93 -0
- package/src/select/select.spec.ts +133 -140
- package/src/select/select.ts +4 -250
- package/src/skeleton/index.ts +5 -0
- package/src/skeleton/skeleton.spec.ts +115 -0
- package/src/skeleton/skeleton.ts +56 -0
- package/src/slider/index.ts +10 -0
- package/src/slider/slider-range.ts +49 -0
- package/src/slider/slider-thumb.ts +335 -0
- package/src/slider/slider-track.ts +70 -0
- package/src/slider/slider.context.ts +79 -0
- package/src/slider/slider.geometry.ts +73 -0
- package/src/slider/slider.spec.ts +216 -0
- package/src/slider/slider.ts +443 -0
- package/src/speed-dial/index.ts +10 -0
- package/src/speed-dial/speed-dial-action.ts +40 -0
- package/src/speed-dial/speed-dial-actions.ts +31 -0
- package/src/speed-dial/speed-dial-trigger.ts +55 -0
- package/src/speed-dial/speed-dial.context.ts +36 -0
- package/src/speed-dial/speed-dial.spec.ts +143 -0
- package/src/speed-dial/speed-dial.ts +127 -0
- package/src/spinner/config.ts +48 -0
- package/src/spinner/index.ts +8 -0
- package/src/spinner/spinner.spec.ts +262 -0
- package/src/spinner/spinner.ts +129 -0
- package/src/stepper/index.ts +15 -0
- package/src/stepper/stepper.context.ts +63 -0
- package/src/stepper/stepper.spec.ts +403 -0
- package/src/stepper/stepper.ts +544 -0
- package/src/styles.css +17 -0
- package/src/table/column-helpers.spec.ts +74 -0
- package/src/table/column-helpers.ts +68 -0
- package/src/table/filter-fns.ts +230 -0
- package/src/table/filter-models.spec.ts +240 -0
- package/src/table/filter-models.ts +124 -0
- package/src/table/filter-params.ts +90 -0
- package/src/table/grid-api-impl.ts +321 -0
- package/src/table/grid-api.spec.ts +178 -0
- package/src/table/grid-api.ts +285 -0
- package/src/table/index.ts +73 -1
- package/src/table/table-cell.spec.ts +43 -0
- package/src/table/table-cell.ts +38 -0
- package/src/table/table-filter-outlet.ts +120 -0
- package/src/table/table-header.spec.ts +54 -0
- package/src/table/table-header.ts +63 -0
- package/src/table/table-keyboard.spec.ts +68 -0
- package/src/table/table-keyboard.ts +107 -0
- package/src/table/table-resource.spec.ts +37 -0
- package/src/table/table-resource.ts +36 -0
- package/src/table/table-row.spec.ts +54 -0
- package/src/table/table-row.ts +31 -0
- package/src/table/table-storage.spec.ts +67 -0
- package/src/table/table-storage.ts +76 -0
- package/src/table/table.spec.ts +101 -42
- package/src/table/table.ts +228 -73
- package/src/table/table.types.ts +83 -0
- package/src/tabs/index.ts +7 -2
- package/src/tabs/tabs.context.ts +27 -4
- package/src/tabs/tabs.spec.ts +336 -24
- package/src/tabs/tabs.ts +313 -79
- package/src/tag/config.ts +53 -0
- package/src/tag/index.ts +7 -0
- package/src/tag/tag-list.ts +76 -0
- package/src/tag/tag-remove.ts +61 -0
- package/src/tag/tag.context.ts +36 -0
- package/src/tag/tag.spec.ts +240 -0
- package/src/tag/tag.ts +203 -0
- package/src/textarea/config.ts +42 -0
- package/src/textarea/index.ts +8 -0
- package/src/textarea/textarea.spec.ts +176 -0
- package/src/textarea/textarea.ts +235 -0
- package/src/time-picker/index.ts +15 -0
- package/src/time-picker/time-picker-meridiem.ts +123 -0
- package/src/time-picker/time-picker-segment.ts +318 -0
- package/src/time-picker/time-picker.context.ts +38 -0
- package/src/time-picker/time-picker.format.ts +181 -0
- package/src/time-picker/time-picker.spec.ts +189 -0
- package/src/time-picker/time-picker.ts +274 -0
- package/src/toast/_examples/index.ts +5 -0
- package/src/toast/_examples/toast.example.ts +282 -0
- package/src/toast/_examples/toast.finance.example.ts +180 -0
- package/src/toast/_examples/toast.retro.example.ts +161 -0
- package/src/toast/index.ts +8 -1
- package/src/toast/toast.ref.ts +26 -0
- package/src/toast/toast.service.ts +227 -41
- package/src/toast/toast.spec.ts +166 -14
- package/src/toast/toast.strategy.ts +10 -0
- package/src/toast/toast.ts +177 -21
- package/src/toggle/toggle.ts +10 -2
- package/src/tooltip/_examples/index.ts +6 -0
- package/src/tooltip/_examples/tooltip.example.ts +82 -0
- package/src/tooltip/_examples/tooltip.finance.example.ts +97 -0
- package/src/tooltip/_examples/tooltip.placements.example.ts +83 -0
- package/src/tooltip/_examples/tooltip.retro.example.ts +107 -0
- package/src/tooltip/index.ts +4 -5
- package/src/tooltip/tooltip-arrow.ts +31 -0
- package/src/tooltip/tooltip-content.ts +38 -0
- package/src/tooltip/tooltip-group.ts +32 -0
- package/src/tooltip/tooltip-trigger.ts +47 -0
- package/src/tooltip/tooltip.spec.ts +38 -102
- package/src/tooltip/tooltip.ts +5 -129
- package/src/tree-select/index.ts +12 -0
- package/src/tree-select/tree-select-content.ts +199 -0
- package/src/tree-select/tree-select-node.ts +132 -0
- package/src/tree-select/tree-select-root.ts +272 -0
- package/src/tree-select/tree-select-trigger.ts +90 -0
- package/src/tree-select/tree-select.context.ts +63 -0
- package/src/tree-select/tree-select.spec.ts +433 -0
- package/src/tree-select/tree-select.ts +2 -0
- package/src/typography/blockquote.ts +57 -0
- package/src/typography/code.ts +53 -0
- package/src/typography/index.ts +22 -0
- package/src/typography/lead.ts +49 -0
- package/src/typography/muted.ts +29 -0
- package/src/typography/prose.css +312 -0
- package/src/typography/truncate.ts +99 -0
- package/src/typography/typography.spec.ts +203 -0
- package/tsconfig.lib.json +9 -1
- package/tsconfig.lib.prod.json +7 -1
- package/tsconfig.spec.json +9 -1
- package/vite.config.ts +8 -0
- package/src/button/button.example.ts +0 -30
- package/src/button/button.finance.example.ts +0 -37
- package/src/button/button.retro.example.ts +0 -47
- package/src/button/button.sizes.example.ts +0 -25
- package/src/dialog/dialog.confirm.example.ts +0 -57
- package/src/dialog/dialog.context.ts +0 -11
- package/src/dialog/dialog.example.ts +0 -40
- package/src/dialog/dialog.finance.example.ts +0 -47
- package/src/dialog/dialog.retro.example.ts +0 -46
- package/src/menu/index.ts +0 -2
- package/src/menu/menu.context.ts +0 -10
- package/src/menu/menu.example.ts +0 -39
- package/src/menu/menu.spec.ts +0 -168
- package/src/menu/menu.ts +0 -176
- package/src/popover/popover.context.ts +0 -18
- package/src/popover/popover.example.ts +0 -50
- package/src/popover/popover.finance.example.ts +0 -52
- package/src/popover/popover.retro.example.ts +0 -53
- package/src/primitives/overlay/overlay.spec.ts +0 -90
- package/src/primitives/overlay/overlay.ts +0 -106
- package/src/select/select.context.ts +0 -3
- package/src/toast/toast.example.ts +0 -134
- package/src/toast/toast.finance.example.ts +0 -68
- package/src/toast/toast.retro.example.ts +0 -69
- package/src/tooltip/tooltip.example.ts +0 -46
- package/src/tooltip/tooltip.finance.example.ts +0 -54
- package/src/tooltip/tooltip.placements.example.ts +0 -56
- package/src/tooltip/tooltip.retro.example.ts +0 -65
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { render, fireEvent } from '@testing-library/angular';
|
|
2
|
+
import { axe, toHaveNoViolations } from 'jest-axe';
|
|
3
|
+
import { KjNumberInput } from './number-input';
|
|
4
|
+
import { KjNumberStepper } from './number-stepper';
|
|
5
|
+
import { KjNumberInputGroup } from './number-input-group';
|
|
6
|
+
|
|
7
|
+
expect.extend(toHaveNoViolations);
|
|
8
|
+
|
|
9
|
+
describe('KjNumberInput', () => {
|
|
10
|
+
it('sets role=spinbutton on the host input', async () => {
|
|
11
|
+
const { container } = await render(`<input kjNumberInput aria-label="Qty" />`, { imports: [KjNumberInput] });
|
|
12
|
+
expect(container.querySelector('input')).toHaveAttribute('role', 'spinbutton');
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it('reflects aria-valuemin / aria-valuemax / aria-valuenow', async () => {
|
|
16
|
+
const { container } = await render(
|
|
17
|
+
`<input kjNumberInput aria-label="Qty" [kjMin]="0" [kjMax]="10" [kjValue]="3" />`,
|
|
18
|
+
{ imports: [KjNumberInput] },
|
|
19
|
+
);
|
|
20
|
+
const input = container.querySelector('input')!;
|
|
21
|
+
expect(input).toHaveAttribute('aria-valuemin', '0');
|
|
22
|
+
expect(input).toHaveAttribute('aria-valuemax', '10');
|
|
23
|
+
expect(input).toHaveAttribute('aria-valuenow', '3');
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('omits aria-valuemin / max when bounds are unset', async () => {
|
|
27
|
+
const { container } = await render(`<input kjNumberInput aria-label="Qty" [kjValue]="3" />`, {
|
|
28
|
+
imports: [KjNumberInput],
|
|
29
|
+
});
|
|
30
|
+
const input = container.querySelector('input')!;
|
|
31
|
+
expect(input).not.toHaveAttribute('aria-valuemin');
|
|
32
|
+
expect(input).not.toHaveAttribute('aria-valuemax');
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('ArrowUp increments by step (snapped to the lattice)', async () => {
|
|
36
|
+
const { container } = await render(
|
|
37
|
+
`<input kjNumberInput aria-label="Qty" [kjValue]="2" [kjStep]="2" />`,
|
|
38
|
+
{ imports: [KjNumberInput] },
|
|
39
|
+
);
|
|
40
|
+
const input = container.querySelector('input')!;
|
|
41
|
+
fireEvent.keyDown(input, { key: 'ArrowUp' });
|
|
42
|
+
expect(input).toHaveAttribute('aria-valuenow', '4');
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('ArrowDown decrements by step', async () => {
|
|
46
|
+
const { container } = await render(
|
|
47
|
+
`<input kjNumberInput aria-label="Qty" [kjValue]="3" [kjStep]="1" />`,
|
|
48
|
+
{ imports: [KjNumberInput] },
|
|
49
|
+
);
|
|
50
|
+
const input = container.querySelector('input')!;
|
|
51
|
+
fireEvent.keyDown(input, { key: 'ArrowDown' });
|
|
52
|
+
expect(input).toHaveAttribute('aria-valuenow', '2');
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('PageUp adds pageStep (10× step by default)', async () => {
|
|
56
|
+
const { container } = await render(
|
|
57
|
+
`<input kjNumberInput aria-label="Qty" [kjValue]="0" [kjStep]="2" />`,
|
|
58
|
+
{ imports: [KjNumberInput] },
|
|
59
|
+
);
|
|
60
|
+
const input = container.querySelector('input')!;
|
|
61
|
+
fireEvent.keyDown(input, { key: 'PageUp' });
|
|
62
|
+
expect(input).toHaveAttribute('aria-valuenow', '20');
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('Home jumps to kjMin and End jumps to kjMax', async () => {
|
|
66
|
+
const { container } = await render(
|
|
67
|
+
`<input kjNumberInput aria-label="Qty" [kjValue]="3" [kjMin]="0" [kjMax]="10" />`,
|
|
68
|
+
{ imports: [KjNumberInput] },
|
|
69
|
+
);
|
|
70
|
+
const input = container.querySelector('input')!;
|
|
71
|
+
fireEvent.keyDown(input, { key: 'Home' });
|
|
72
|
+
expect(input).toHaveAttribute('aria-valuenow', '0');
|
|
73
|
+
fireEvent.keyDown(input, { key: 'End' });
|
|
74
|
+
expect(input).toHaveAttribute('aria-valuenow', '10');
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('clamps to kjMax when stepping past the upper bound', async () => {
|
|
78
|
+
const { container } = await render(
|
|
79
|
+
`<input kjNumberInput aria-label="Qty" [kjValue]="9" [kjStep]="5" [kjMax]="10" />`,
|
|
80
|
+
{ imports: [KjNumberInput] },
|
|
81
|
+
);
|
|
82
|
+
const input = container.querySelector('input')!;
|
|
83
|
+
fireEvent.keyDown(input, { key: 'ArrowUp' });
|
|
84
|
+
expect(input).toHaveAttribute('aria-valuenow', '10');
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it('uses type="text" by default', async () => {
|
|
88
|
+
const { container } = await render(`<input kjNumberInput aria-label="A" />`, { imports: [KjNumberInput] });
|
|
89
|
+
expect(container.querySelector('input')).toHaveAttribute('type', 'text');
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it('uses type="number" when kjUseNativeNumber=true', async () => {
|
|
93
|
+
const { container } = await render(
|
|
94
|
+
`<input kjNumberInput aria-label="B" kjUseNativeNumber />`,
|
|
95
|
+
{ imports: [KjNumberInput] },
|
|
96
|
+
);
|
|
97
|
+
expect(container.querySelector('input')).toHaveAttribute('type', 'number');
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it('passes axe audit with a label', async () => {
|
|
101
|
+
const { container } = await render(
|
|
102
|
+
`<label for="qty">Quantity</label><input id="qty" kjNumberInput [kjValue]="3" />`,
|
|
103
|
+
{ imports: [KjNumberInput] },
|
|
104
|
+
);
|
|
105
|
+
expect(await axe(container)).toHaveNoViolations();
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
describe('KjNumberStepper', () => {
|
|
110
|
+
it('increments the value when clicked with kjStep="up"', async () => {
|
|
111
|
+
const { container } = await render(
|
|
112
|
+
`<div kjNumberInputGroup>
|
|
113
|
+
<input kjNumberInput aria-label="Qty" [kjValue]="3" />
|
|
114
|
+
<button kjNumberStepper kjStep="up" aria-label="Increase">+</button>
|
|
115
|
+
</div>`,
|
|
116
|
+
{ imports: [KjNumberInput, KjNumberStepper, KjNumberInputGroup] },
|
|
117
|
+
);
|
|
118
|
+
const input = container.querySelector('input')!;
|
|
119
|
+
const button = container.querySelector('button')!;
|
|
120
|
+
fireEvent.click(button);
|
|
121
|
+
expect(input).toHaveAttribute('aria-valuenow', '4');
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it('decrements the value when clicked with kjStep="down"', async () => {
|
|
125
|
+
const { container } = await render(
|
|
126
|
+
`<div kjNumberInputGroup>
|
|
127
|
+
<input kjNumberInput aria-label="Qty" [kjValue]="3" />
|
|
128
|
+
<button kjNumberStepper kjStep="down" aria-label="Decrease">-</button>
|
|
129
|
+
</div>`,
|
|
130
|
+
{ imports: [KjNumberInput, KjNumberStepper, KjNumberInputGroup] },
|
|
131
|
+
);
|
|
132
|
+
const input = container.querySelector('input')!;
|
|
133
|
+
const button = container.querySelector('button')!;
|
|
134
|
+
fireEvent.click(button);
|
|
135
|
+
expect(input).toHaveAttribute('aria-valuenow', '2');
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
it('reflects bounds-aware aria-disabled when at the max bound', async () => {
|
|
139
|
+
const { container } = await render(
|
|
140
|
+
`<div kjNumberInputGroup>
|
|
141
|
+
<input kjNumberInput aria-label="Qty" [kjValue]="10" [kjMax]="10" />
|
|
142
|
+
<button kjNumberStepper kjStep="up" aria-label="Increase">+</button>
|
|
143
|
+
</div>`,
|
|
144
|
+
{ imports: [KjNumberInput, KjNumberStepper, KjNumberInputGroup] },
|
|
145
|
+
);
|
|
146
|
+
expect(container.querySelector('button')).toHaveAttribute('aria-disabled', 'true');
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
it('forces type="button" on the host', async () => {
|
|
150
|
+
const { container } = await render(
|
|
151
|
+
`<div kjNumberInputGroup>
|
|
152
|
+
<input kjNumberInput aria-label="Qty" />
|
|
153
|
+
<button kjNumberStepper kjStep="up" aria-label="Increase">+</button>
|
|
154
|
+
</div>`,
|
|
155
|
+
{ imports: [KjNumberInput, KjNumberStepper, KjNumberInputGroup] },
|
|
156
|
+
);
|
|
157
|
+
expect(container.querySelector('button')).toHaveAttribute('type', 'button');
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
it('is removed from the tab sequence (tabindex="-1")', async () => {
|
|
161
|
+
const { container } = await render(
|
|
162
|
+
`<div kjNumberInputGroup>
|
|
163
|
+
<input kjNumberInput aria-label="Qty" />
|
|
164
|
+
<button kjNumberStepper kjStep="up" aria-label="Increase">+</button>
|
|
165
|
+
</div>`,
|
|
166
|
+
{ imports: [KjNumberInput, KjNumberStepper, KjNumberInputGroup] },
|
|
167
|
+
);
|
|
168
|
+
expect(container.querySelector('button')).toHaveAttribute('tabindex', '-1');
|
|
169
|
+
});
|
|
170
|
+
});
|
|
@@ -0,0 +1,457 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Directive,
|
|
3
|
+
ElementRef,
|
|
4
|
+
LOCALE_ID,
|
|
5
|
+
booleanAttribute,
|
|
6
|
+
computed,
|
|
7
|
+
effect,
|
|
8
|
+
inject,
|
|
9
|
+
input,
|
|
10
|
+
model,
|
|
11
|
+
numberAttribute,
|
|
12
|
+
signal,
|
|
13
|
+
} from '@angular/core';
|
|
14
|
+
import { KjDisabled, KjFocusRing, KjFormControl } from '../primitives';
|
|
15
|
+
import { KJ_NUMBER_INPUT, KjNumberInputContext } from './number-input.context';
|
|
16
|
+
import { KjNumberInputGroup } from './number-input-group';
|
|
17
|
+
import {
|
|
18
|
+
clamp,
|
|
19
|
+
formatForEdit,
|
|
20
|
+
formatNumber,
|
|
21
|
+
parseNumber,
|
|
22
|
+
snapToStep,
|
|
23
|
+
type KjNumberFormatOptions,
|
|
24
|
+
} from './number-input.format';
|
|
25
|
+
|
|
26
|
+
let nextId = 0;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Enhances a native `<input>` with numeric-spinbox semantics: bounded
|
|
30
|
+
* `kjMin` / `kjMax` / `kjStep`, increment / decrement on ArrowUp / ArrowDown,
|
|
31
|
+
* PageUp / PageDown / Home / End, optional locale-aware display formatting via
|
|
32
|
+
* `Intl.NumberFormat`, and the WAI-ARIA `spinbutton` contract
|
|
33
|
+
* (`aria-valuemin` / `aria-valuemax` / `aria-valuenow` / `aria-valuetext`).
|
|
34
|
+
*
|
|
35
|
+
* The directive is a sibling to `[kjInput]`, not a sub-directive: the CVA
|
|
36
|
+
* model is `number | null` (not `string | null`) and the keyboard contract
|
|
37
|
+
* adds Arrow / Page / Home / End semantics. The two are mutually exclusive on
|
|
38
|
+
* the same element.
|
|
39
|
+
*
|
|
40
|
+
* Compose with `[kjNumberStepper]` on sibling buttons (typically inside a
|
|
41
|
+
* `[kjNumberInputGroup]`) to add increment / decrement triggers with
|
|
42
|
+
* long-press auto-repeat.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```html
|
|
46
|
+
* <input kjNumberInput [(kjValue)]="qty" [kjMin]="0" [kjMax]="100" [kjStep]="1" />
|
|
47
|
+
* ```
|
|
48
|
+
* @doc
|
|
49
|
+
* @doc-example Default
|
|
50
|
+
* @doc-file number-input.example.ts
|
|
51
|
+
* @doc-example With stepper buttons
|
|
52
|
+
* @doc-file number-input.with-stepper.example.ts
|
|
53
|
+
* @doc-example Min / max / step
|
|
54
|
+
* @doc-file number-input.min-max.example.ts
|
|
55
|
+
* @doc-example Decimal precision
|
|
56
|
+
* @doc-file number-input.decimal.example.ts
|
|
57
|
+
* @doc-example Currency formatting
|
|
58
|
+
* @doc-file number-input.currency.example.ts
|
|
59
|
+
* @doc-category Core/Inputs
|
|
60
|
+
* @doc-name number-input
|
|
61
|
+
* @doc-description Adds numeric spinbutton behaviour to a native input with min, max, step, and locale formatting.
|
|
62
|
+
* @doc-is-main
|
|
63
|
+
*/
|
|
64
|
+
@Directive({
|
|
65
|
+
selector: '[kjNumberInput]',
|
|
66
|
+
standalone: true,
|
|
67
|
+
hostDirectives: [
|
|
68
|
+
{ directive: KjDisabled, inputs: ['kjDisabled'] },
|
|
69
|
+
KjFocusRing,
|
|
70
|
+
KjFormControl,
|
|
71
|
+
],
|
|
72
|
+
providers: [{ provide: KJ_NUMBER_INPUT, useExisting: KjNumberInput }],
|
|
73
|
+
exportAs: 'kjNumberInput',
|
|
74
|
+
host: {
|
|
75
|
+
'[attr.role]': '"spinbutton"',
|
|
76
|
+
'[attr.type]': 'kjUseNativeNumber() ? "number" : "text"',
|
|
77
|
+
'[attr.inputmode]': 'inputMode()',
|
|
78
|
+
'[attr.id]': 'inputId()',
|
|
79
|
+
'[attr.aria-valuemin]': 'isFiniteMin() ? kjMin() : null',
|
|
80
|
+
'[attr.aria-valuemax]': 'isFiniteMax() ? kjMax() : null',
|
|
81
|
+
'[attr.aria-valuenow]': 'kjValue() ?? null',
|
|
82
|
+
'[attr.aria-valuetext]': 'ariaValueText()',
|
|
83
|
+
'[attr.aria-invalid]': 'ariaInvalid()',
|
|
84
|
+
'[attr.aria-readonly]': 'kjReadonly() ? "true" : null',
|
|
85
|
+
'[attr.readonly]': 'kjReadonly() ? "" : null',
|
|
86
|
+
'[attr.disabled]': 'formCtrl.disabled() ? "" : null',
|
|
87
|
+
'[attr.aria-label]': 'kjAriaLabel()',
|
|
88
|
+
'(focus)': 'onFocus()',
|
|
89
|
+
'(blur)': 'onBlur()',
|
|
90
|
+
'(input)': 'onInput($event)',
|
|
91
|
+
'(keydown)': 'onKeydown($event)',
|
|
92
|
+
},
|
|
93
|
+
})
|
|
94
|
+
export class KjNumberInput implements KjNumberInputContext {
|
|
95
|
+
/** @internal */
|
|
96
|
+
readonly formCtrl = inject(KjFormControl);
|
|
97
|
+
private readonly el = inject<ElementRef<HTMLInputElement>>(ElementRef);
|
|
98
|
+
private readonly localeId = inject(LOCALE_ID);
|
|
99
|
+
private readonly group = inject(KjNumberInputGroup, { optional: true, skipSelf: true });
|
|
100
|
+
|
|
101
|
+
/** Two-way bindable numeric model. `null` for empty. */
|
|
102
|
+
readonly kjValue = model<number | null>(null);
|
|
103
|
+
|
|
104
|
+
/** Minimum allowed value. `undefined` → unbounded (`-Infinity`). */
|
|
105
|
+
readonly kjMin = input<number | undefined, unknown>(undefined, { transform: optionalNumber });
|
|
106
|
+
|
|
107
|
+
/** Maximum allowed value. `undefined` → unbounded (`+Infinity`). */
|
|
108
|
+
readonly kjMax = input<number | undefined, unknown>(undefined, { transform: optionalNumber });
|
|
109
|
+
|
|
110
|
+
/** Step amount for ArrowUp / ArrowDown / stepper presses. */
|
|
111
|
+
readonly kjStep = input<number, unknown>(1, { transform: numberAttribute });
|
|
112
|
+
|
|
113
|
+
/** PageUp / PageDown amount. Defaults to `kjStep * 10` if `undefined`. */
|
|
114
|
+
readonly kjPageStep = input<number | undefined, unknown>(undefined, { transform: optionalNumber });
|
|
115
|
+
|
|
116
|
+
/** Lattice base for snap-to-step. Defaults to `kjMin` if defined, else `0`. */
|
|
117
|
+
readonly kjStepBase = input<number | undefined, unknown>(undefined, { transform: optionalNumber });
|
|
118
|
+
|
|
119
|
+
/** When `false`, blur on empty snaps to `clamp(0, kjMin, kjMax)`. */
|
|
120
|
+
readonly kjAllowEmpty = input<boolean, unknown>(true, { transform: booleanAttribute });
|
|
121
|
+
|
|
122
|
+
/** When `false`, the decimal separator is rejected on type. */
|
|
123
|
+
readonly kjAllowDecimals = input<boolean, unknown>(true, { transform: booleanAttribute });
|
|
124
|
+
|
|
125
|
+
/** When `false`, the sign character is rejected and `kjMin` is floored at `0`. */
|
|
126
|
+
readonly kjAllowNegative = input<boolean, unknown>(true, { transform: booleanAttribute });
|
|
127
|
+
|
|
128
|
+
/** Read-only state. Reflects `aria-readonly` and `[readonly]`. */
|
|
129
|
+
readonly kjReadonly = input<boolean, unknown>(false, { transform: booleanAttribute });
|
|
130
|
+
|
|
131
|
+
/** External invalid signal. OR'd with bounds + form invalidity for `aria-invalid`. */
|
|
132
|
+
readonly kjInvalid = input<boolean, unknown>(false, { transform: booleanAttribute });
|
|
133
|
+
|
|
134
|
+
/** Opts into native `<input type="number">` mode. Disables the mask + locale formatting. */
|
|
135
|
+
readonly kjUseNativeNumber = input<boolean, unknown>(false, { transform: booleanAttribute });
|
|
136
|
+
|
|
137
|
+
/** Drives `Intl.NumberFormat` style. Ignored when `kjUseNativeNumber=true`. */
|
|
138
|
+
readonly kjFormat = input<'decimal' | 'currency' | 'percent' | 'unit'>('decimal');
|
|
139
|
+
|
|
140
|
+
/** BCP-47 tag. Falls back to the injected `LOCALE_ID`. */
|
|
141
|
+
readonly kjLocale = input<string | undefined>(undefined);
|
|
142
|
+
|
|
143
|
+
/** ISO 4217 code (e.g. `'USD'`). Required when `kjFormat="currency"`. */
|
|
144
|
+
readonly kjCurrency = input<string | undefined>(undefined);
|
|
145
|
+
|
|
146
|
+
/** Currency display mode. */
|
|
147
|
+
readonly kjCurrencyDisplay = input<'symbol' | 'narrowSymbol' | 'code' | 'name'>('symbol');
|
|
148
|
+
|
|
149
|
+
/** Unit identifier (e.g. `'kilometer'`). Required when `kjFormat="unit"`. */
|
|
150
|
+
readonly kjUnit = input<string | undefined>(undefined);
|
|
151
|
+
|
|
152
|
+
/** Unit display mode. */
|
|
153
|
+
readonly kjUnitDisplay = input<'short' | 'long' | 'narrow'>('short');
|
|
154
|
+
|
|
155
|
+
/** Whether to use thousands grouping in the formatted display. */
|
|
156
|
+
readonly kjUseGrouping = input<boolean, unknown>(true, { transform: booleanAttribute });
|
|
157
|
+
|
|
158
|
+
/** Minimum fraction digits forwarded to `Intl.NumberFormat`. */
|
|
159
|
+
readonly kjMinimumFractionDigits = input<number | undefined, unknown>(undefined, { transform: optionalNumber });
|
|
160
|
+
|
|
161
|
+
/** Maximum fraction digits forwarded to `Intl.NumberFormat`. */
|
|
162
|
+
readonly kjMaximumFractionDigits = input<number | undefined, unknown>(undefined, { transform: optionalNumber });
|
|
163
|
+
|
|
164
|
+
/** Minimum integer digits forwarded to `Intl.NumberFormat`. */
|
|
165
|
+
readonly kjMinimumIntegerDigits = input<number | undefined, unknown>(undefined, { transform: optionalNumber });
|
|
166
|
+
|
|
167
|
+
/** Minimum significant digits forwarded to `Intl.NumberFormat`. */
|
|
168
|
+
readonly kjMinimumSignificantDigits = input<number | undefined, unknown>(undefined, { transform: optionalNumber });
|
|
169
|
+
|
|
170
|
+
/** Maximum significant digits forwarded to `Intl.NumberFormat`. */
|
|
171
|
+
readonly kjMaximumSignificantDigits = input<number | undefined, unknown>(undefined, { transform: optionalNumber });
|
|
172
|
+
|
|
173
|
+
/** Forwarded to `[attr.aria-label]`. */
|
|
174
|
+
readonly kjAriaLabel = input<string | null>(null);
|
|
175
|
+
|
|
176
|
+
// ── Internal state ────────────────────────────────────────────────────────
|
|
177
|
+
|
|
178
|
+
private readonly editing = signal(false);
|
|
179
|
+
private readonly _id = `kj-number-${++nextId}`;
|
|
180
|
+
|
|
181
|
+
/** Computed effective minimum (number; `-Infinity` if unbounded). */
|
|
182
|
+
readonly min = computed(() => {
|
|
183
|
+
const explicit = this.kjMin();
|
|
184
|
+
const base = explicit === undefined ? -Infinity : explicit;
|
|
185
|
+
return this.kjAllowNegative() ? base : Math.max(0, base);
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
/** Computed effective maximum (number; `+Infinity` if unbounded). */
|
|
189
|
+
readonly max = computed(() => {
|
|
190
|
+
const explicit = this.kjMax();
|
|
191
|
+
return explicit === undefined ? Infinity : explicit;
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
readonly step = computed(() => this.kjStep());
|
|
195
|
+
readonly pageStep = computed(() => this.kjPageStep() ?? this.kjStep() * 10);
|
|
196
|
+
readonly disabled = computed(() => this.formCtrl.disabled());
|
|
197
|
+
readonly readonly = computed(() => this.kjReadonly());
|
|
198
|
+
|
|
199
|
+
/** @internal */
|
|
200
|
+
readonly value = this.kjValue.asReadonly();
|
|
201
|
+
|
|
202
|
+
protected readonly isFiniteMin = computed(() => Number.isFinite(this.min()));
|
|
203
|
+
protected readonly isFiniteMax = computed(() => Number.isFinite(this.max()));
|
|
204
|
+
|
|
205
|
+
protected readonly inputId = computed(() => this.el.nativeElement.id || this._id);
|
|
206
|
+
|
|
207
|
+
protected readonly inputMode = computed(() => {
|
|
208
|
+
if (this.kjUseNativeNumber()) return null;
|
|
209
|
+
if (this.kjFormat() === 'decimal' && !this.kjAllowDecimals()) return 'numeric';
|
|
210
|
+
return 'decimal';
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
/** Formatter options derived from the public inputs. */
|
|
214
|
+
private readonly formatOptions = computed<KjNumberFormatOptions>(() => ({
|
|
215
|
+
locale: this.kjLocale() ?? this.localeId,
|
|
216
|
+
format: this.kjFormat(),
|
|
217
|
+
currency: this.kjCurrency(),
|
|
218
|
+
currencyDisplay: this.kjCurrencyDisplay(),
|
|
219
|
+
unit: this.kjUnit(),
|
|
220
|
+
unitDisplay: this.kjUnitDisplay(),
|
|
221
|
+
useGrouping: this.kjUseGrouping(),
|
|
222
|
+
minimumFractionDigits: this.kjMinimumFractionDigits(),
|
|
223
|
+
maximumFractionDigits: this.kjMaximumFractionDigits(),
|
|
224
|
+
minimumIntegerDigits: this.kjMinimumIntegerDigits(),
|
|
225
|
+
minimumSignificantDigits: this.kjMinimumSignificantDigits(),
|
|
226
|
+
maximumSignificantDigits: this.kjMaximumSignificantDigits(),
|
|
227
|
+
}));
|
|
228
|
+
|
|
229
|
+
/** Out-of-range when the value falls outside [min, max]. Used for `aria-invalid`. */
|
|
230
|
+
protected readonly outOfRange = computed(() => {
|
|
231
|
+
const v = this.kjValue();
|
|
232
|
+
if (v == null) return false;
|
|
233
|
+
return v < this.min() || v > this.max();
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
protected readonly ariaInvalid = computed(() => {
|
|
237
|
+
const touched = this.formCtrl.touched();
|
|
238
|
+
const invalid = this.kjInvalid() || this.outOfRange();
|
|
239
|
+
return touched && invalid ? 'true' : null;
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
protected readonly ariaValueText = computed(() => {
|
|
243
|
+
const v = this.kjValue();
|
|
244
|
+
if (v == null) return null;
|
|
245
|
+
return formatNumber(v, this.formatOptions());
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
constructor() {
|
|
249
|
+
// Register with an enclosing group so sibling steppers can find us.
|
|
250
|
+
this.group?.register(this);
|
|
251
|
+
|
|
252
|
+
// Bridge the model ↔ KjFormControl value so reactive forms see numeric values.
|
|
253
|
+
effect(() => {
|
|
254
|
+
const cvaValue = this.formCtrl.value();
|
|
255
|
+
if (cvaValue === undefined) return;
|
|
256
|
+
const num = cvaValue == null ? null : typeof cvaValue === 'number' ? cvaValue : parseNumber(String(cvaValue), this.formatOptions());
|
|
257
|
+
if (num !== this.kjValue()) this.kjValue.set(num);
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
// Reflect the numeric model back to the native input — formatted when not editing,
|
|
261
|
+
// raw-edit form when editing or when in native-number mode.
|
|
262
|
+
effect(() => {
|
|
263
|
+
const value = this.kjValue();
|
|
264
|
+
const editing = this.editing();
|
|
265
|
+
const native = this.kjUseNativeNumber();
|
|
266
|
+
const el = this.el.nativeElement;
|
|
267
|
+
if (value == null) {
|
|
268
|
+
if (el.value !== '') el.value = '';
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
let next: string;
|
|
272
|
+
if (native) {
|
|
273
|
+
next = String(value);
|
|
274
|
+
} else if (editing) {
|
|
275
|
+
// Percent: the user thinks of `50` even though we store `0.5`.
|
|
276
|
+
const display = this.kjFormat() === 'percent' ? value * 100 : value;
|
|
277
|
+
next = formatForEdit(display, this.kjLocale() ?? this.localeId);
|
|
278
|
+
} else {
|
|
279
|
+
next = formatNumber(value, this.formatOptions());
|
|
280
|
+
}
|
|
281
|
+
if (el.value !== next) el.value = next;
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
// Clamp the value when min/max change at runtime.
|
|
285
|
+
effect(() => {
|
|
286
|
+
const v = this.kjValue();
|
|
287
|
+
if (v == null) return;
|
|
288
|
+
const min = this.min();
|
|
289
|
+
const max = this.max();
|
|
290
|
+
if (v < min || v > max) {
|
|
291
|
+
const clamped = clamp(v, min, max);
|
|
292
|
+
if (clamped !== v) {
|
|
293
|
+
this.kjValue.set(clamped);
|
|
294
|
+
this.formCtrl.notifyChange(clamped);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
// ── KjNumberInputContext ──────────────────────────────────────────────────
|
|
301
|
+
|
|
302
|
+
/** @internal */
|
|
303
|
+
stepBy(units: number, amount?: number): void {
|
|
304
|
+
if (this.kjReadonly() || this.formCtrl.disabled()) return;
|
|
305
|
+
const stepAmount = amount ?? this.kjStep();
|
|
306
|
+
const current = this.kjValue() ?? this.fallbackForStep();
|
|
307
|
+
const base = this.kjStepBase() ?? (this.kjMin() ?? 0);
|
|
308
|
+
const next = snapToStep(current + units * stepAmount, stepAmount, base);
|
|
309
|
+
this.commit(clamp(next, this.min(), this.max()));
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/** @internal */
|
|
313
|
+
setValue(value: number | null): void {
|
|
314
|
+
if (value == null) {
|
|
315
|
+
this.commit(null);
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
const base = this.kjStepBase() ?? (this.kjMin() ?? 0);
|
|
319
|
+
const snapped = snapToStep(value, this.kjStep(), base);
|
|
320
|
+
this.commit(clamp(snapped, this.min(), this.max()));
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
// ── Event handlers ────────────────────────────────────────────────────────
|
|
324
|
+
|
|
325
|
+
/** @internal */
|
|
326
|
+
onFocus(): void {
|
|
327
|
+
if (this.kjUseNativeNumber()) return;
|
|
328
|
+
this.editing.set(true);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/** @internal */
|
|
332
|
+
onBlur(): void {
|
|
333
|
+
this.editing.set(false);
|
|
334
|
+
this.formCtrl.notifyTouched();
|
|
335
|
+
// Commit current edit buffer.
|
|
336
|
+
const raw = this.el.nativeElement.value;
|
|
337
|
+
if (raw === '' || raw == null) {
|
|
338
|
+
if (this.kjAllowEmpty()) {
|
|
339
|
+
this.commit(null);
|
|
340
|
+
} else {
|
|
341
|
+
this.commit(clamp(0, this.min(), this.max()));
|
|
342
|
+
}
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
const parsed = this.kjUseNativeNumber()
|
|
346
|
+
? Number(raw)
|
|
347
|
+
: parseNumber(raw, this.formatOptions());
|
|
348
|
+
if (parsed == null || !Number.isFinite(parsed)) {
|
|
349
|
+
this.commit(null);
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
this.commit(clamp(parsed, this.min(), this.max()));
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/** @internal */
|
|
356
|
+
onInput(event: Event): void {
|
|
357
|
+
const raw = (event.target as HTMLInputElement).value;
|
|
358
|
+
// While editing we keep the model in sync so `aria-valuenow` updates with typing.
|
|
359
|
+
if (this.kjUseNativeNumber()) {
|
|
360
|
+
const n = raw === '' ? null : Number(raw);
|
|
361
|
+
const next = n != null && Number.isFinite(n) ? n : null;
|
|
362
|
+
this.kjValue.set(next);
|
|
363
|
+
this.formCtrl.notifyChange(next);
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
366
|
+
const parsed = parseNumber(raw, this.formatOptions());
|
|
367
|
+
this.kjValue.set(parsed);
|
|
368
|
+
this.formCtrl.notifyChange(parsed);
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
/** @internal */
|
|
372
|
+
onKeydown(event: KeyboardEvent): void {
|
|
373
|
+
if (this.kjReadonly() || this.formCtrl.disabled()) return;
|
|
374
|
+
switch (event.key) {
|
|
375
|
+
case 'ArrowUp':
|
|
376
|
+
event.preventDefault();
|
|
377
|
+
this.stepBy(1);
|
|
378
|
+
break;
|
|
379
|
+
case 'ArrowDown':
|
|
380
|
+
event.preventDefault();
|
|
381
|
+
this.stepBy(-1);
|
|
382
|
+
break;
|
|
383
|
+
case 'PageUp':
|
|
384
|
+
event.preventDefault();
|
|
385
|
+
this.stepBy(1, this.pageStep());
|
|
386
|
+
break;
|
|
387
|
+
case 'PageDown':
|
|
388
|
+
event.preventDefault();
|
|
389
|
+
this.stepBy(-1, this.pageStep());
|
|
390
|
+
break;
|
|
391
|
+
case 'Home':
|
|
392
|
+
if (Number.isFinite(this.min())) {
|
|
393
|
+
event.preventDefault();
|
|
394
|
+
this.commit(this.min());
|
|
395
|
+
}
|
|
396
|
+
break;
|
|
397
|
+
case 'End':
|
|
398
|
+
if (Number.isFinite(this.max())) {
|
|
399
|
+
event.preventDefault();
|
|
400
|
+
this.commit(this.max());
|
|
401
|
+
}
|
|
402
|
+
break;
|
|
403
|
+
default:
|
|
404
|
+
if (this.kjUseNativeNumber()) return;
|
|
405
|
+
// Character filter: drop disallowed chars (decimal, sign) when restricted.
|
|
406
|
+
if (event.key.length === 1 && !event.ctrlKey && !event.metaKey && !event.altKey) {
|
|
407
|
+
if (event.key === '.' || event.key === ',') {
|
|
408
|
+
if (!this.kjAllowDecimals()) event.preventDefault();
|
|
409
|
+
} else if (event.key === '-' || event.key === '+') {
|
|
410
|
+
if (!this.kjAllowNegative()) event.preventDefault();
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
// ── Internals ─────────────────────────────────────────────────────────────
|
|
417
|
+
|
|
418
|
+
private commit(next: number | null): void {
|
|
419
|
+
if (next === this.kjValue()) {
|
|
420
|
+
// Still re-render the formatted display in case the editing buffer drifted.
|
|
421
|
+
this.refreshDisplay();
|
|
422
|
+
return;
|
|
423
|
+
}
|
|
424
|
+
this.kjValue.set(next);
|
|
425
|
+
this.formCtrl.notifyChange(next);
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
private refreshDisplay(): void {
|
|
429
|
+
const el = this.el.nativeElement;
|
|
430
|
+
const value = this.kjValue();
|
|
431
|
+
if (value == null) {
|
|
432
|
+
el.value = '';
|
|
433
|
+
return;
|
|
434
|
+
}
|
|
435
|
+
if (this.kjUseNativeNumber()) {
|
|
436
|
+
el.value = String(value);
|
|
437
|
+
return;
|
|
438
|
+
}
|
|
439
|
+
el.value = this.editing()
|
|
440
|
+
? formatForEdit(this.kjFormat() === 'percent' ? value * 100 : value, this.kjLocale() ?? this.localeId)
|
|
441
|
+
: formatNumber(value, this.formatOptions());
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
private fallbackForStep(): number {
|
|
445
|
+
const min = this.min();
|
|
446
|
+
if (Number.isFinite(min)) return min;
|
|
447
|
+
const max = this.max();
|
|
448
|
+
if (Number.isFinite(max)) return max;
|
|
449
|
+
return 0;
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
function optionalNumber(v: unknown): number | undefined {
|
|
454
|
+
if (v === undefined || v === null || v === '') return undefined;
|
|
455
|
+
const n = typeof v === 'number' ? v : Number(v);
|
|
456
|
+
return Number.isFinite(n) ? n : undefined;
|
|
457
|
+
}
|