@kouji-ui/core 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/kouji-ui-core.mjs +26789 -0
- package/fesm2022/kouji-ui-core.mjs.map +1 -0
- package/package.json +5 -6
- package/types/kouji-ui-core.d.ts +13545 -0
- package/.turbo/turbo-build.log +0 -30
- package/CHANGELOG.md +0 -190
- package/ng-package.json +0 -11
- package/src/a11y/.gitkeep +0 -0
- package/src/a11y/aria-describedby.spec.ts +0 -55
- package/src/a11y/aria-describedby.ts +0 -37
- package/src/a11y/aria-labelledby.spec.ts +0 -55
- package/src/a11y/aria-labelledby.ts +0 -38
- package/src/a11y/focus-trap.spec.ts +0 -86
- package/src/a11y/focus-trap.ts +0 -72
- package/src/a11y/index.ts +0 -10
- package/src/a11y/live-region.spec.ts +0 -58
- package/src/a11y/live-region.ts +0 -50
- package/src/a11y/roving-tabindex.spec.ts +0 -201
- package/src/a11y/roving-tabindex.ts +0 -153
- package/src/a11y/visually-hidden.spec.ts +0 -34
- package/src/a11y/visually-hidden.ts +0 -26
- package/src/accordion/accordion.context.ts +0 -44
- package/src/accordion/accordion.spec.ts +0 -242
- package/src/accordion/accordion.ts +0 -401
- package/src/accordion/index.ts +0 -8
- package/src/alert/alert.context.ts +0 -28
- package/src/alert/alert.spec.ts +0 -217
- package/src/alert/alert.ts +0 -417
- package/src/alert/config.ts +0 -46
- package/src/alert/index.ts +0 -19
- package/src/avatar/avatar-group.context.ts +0 -45
- package/src/avatar/avatar-group.spec.ts +0 -358
- package/src/avatar/avatar-group.ts +0 -259
- package/src/avatar/avatar.spec.ts +0 -18
- package/src/avatar/avatar.ts +0 -39
- package/src/avatar/index.ts +0 -11
- package/src/badge/badge.spec.ts +0 -28
- package/src/badge/badge.ts +0 -35
- package/src/badge/index.ts +0 -1
- package/src/breadcrumb/breadcrumb-current.ts +0 -38
- package/src/breadcrumb/breadcrumb-ellipsis.ts +0 -71
- package/src/breadcrumb/breadcrumb-item.ts +0 -41
- package/src/breadcrumb/breadcrumb-link.ts +0 -44
- package/src/breadcrumb/breadcrumb-list.ts +0 -42
- package/src/breadcrumb/breadcrumb-separator.ts +0 -45
- package/src/breadcrumb/breadcrumb.context.ts +0 -45
- package/src/breadcrumb/breadcrumb.spec.ts +0 -354
- package/src/breadcrumb/breadcrumb.ts +0 -239
- package/src/breadcrumb/config.ts +0 -84
- package/src/breadcrumb/index.ts +0 -18
- package/src/button/_examples/button.example.ts +0 -71
- package/src/button/_examples/button.finance.example.ts +0 -83
- package/src/button/_examples/button.retro.example.ts +0 -91
- package/src/button/_examples/button.sizes.example.ts +0 -60
- package/src/button/_examples/index.ts +0 -6
- package/src/button/button.spec.ts +0 -163
- package/src/button/button.ts +0 -142
- package/src/button/config.spec.ts +0 -33
- package/src/button/config.ts +0 -45
- package/src/button/index.ts +0 -2
- package/src/button-group/button-group.context.ts +0 -28
- package/src/button-group/button-group.spec.ts +0 -99
- package/src/button-group/button-group.ts +0 -99
- package/src/button-group/index.ts +0 -2
- package/src/calendar/calendar-day.ts +0 -102
- package/src/calendar/calendar-grid.ts +0 -90
- package/src/calendar/calendar-header.ts +0 -65
- package/src/calendar/calendar.context.ts +0 -53
- package/src/calendar/calendar.spec.ts +0 -225
- package/src/calendar/calendar.ts +0 -233
- package/src/calendar/date-utils.ts +0 -225
- package/src/calendar/index.ts +0 -28
- package/src/carousel/carousel.context.ts +0 -81
- package/src/carousel/carousel.spec.ts +0 -337
- package/src/carousel/carousel.ts +0 -919
- package/src/carousel/index.ts +0 -22
- package/src/cascade-select/cascade-select-option.ts +0 -205
- package/src/cascade-select/cascade-select-panel.ts +0 -106
- package/src/cascade-select/cascade-select-root.ts +0 -265
- package/src/cascade-select/cascade-select-sub-panel.ts +0 -168
- package/src/cascade-select/cascade-select-trigger.ts +0 -44
- package/src/cascade-select/cascade-select.context.ts +0 -71
- package/src/cascade-select/cascade-select.spec.ts +0 -241
- package/src/cascade-select/cascade-select.ts +0 -5
- package/src/cascade-select/index.ts +0 -11
- package/src/chart/chart.spec.ts +0 -27
- package/src/chart/chart.ts +0 -52
- package/src/chart/index.ts +0 -1
- package/src/chat/chat-avatar.ts +0 -31
- package/src/chat/chat-bubble.ts +0 -49
- package/src/chat/chat-footer.ts +0 -67
- package/src/chat/chat-header.ts +0 -41
- package/src/chat/chat-log.ts +0 -43
- package/src/chat/chat.context.ts +0 -64
- package/src/chat/chat.spec.ts +0 -341
- package/src/chat/chat.ts +0 -191
- package/src/chat/config.ts +0 -53
- package/src/chat/index.ts +0 -21
- package/src/checkbox/checkbox.spec.ts +0 -35
- package/src/checkbox/checkbox.ts +0 -89
- package/src/checkbox/index.ts +0 -1
- package/src/color-picker/color-picker.context.ts +0 -74
- package/src/color-picker/color-picker.spec.ts +0 -241
- package/src/color-picker/color-picker.ts +0 -698
- package/src/color-picker/color-picker.utils.ts +0 -140
- package/src/color-picker/index.ts +0 -28
- package/src/combobox/combobox-input.ts +0 -143
- package/src/combobox/combobox-listbox.ts +0 -49
- package/src/combobox/combobox-option.ts +0 -43
- package/src/combobox/combobox-root.ts +0 -281
- package/src/combobox/combobox.spec.ts +0 -75
- package/src/combobox/combobox.ts +0 -4
- package/src/combobox/index.ts +0 -4
- package/src/command-palette/command-empty.ts +0 -36
- package/src/command-palette/command-group.ts +0 -21
- package/src/command-palette/command-input.ts +0 -70
- package/src/command-palette/command-item.ts +0 -60
- package/src/command-palette/command-list.ts +0 -25
- package/src/command-palette/command-palette-dialog.ts +0 -74
- package/src/command-palette/command-palette-trigger.ts +0 -64
- package/src/command-palette/command-palette.filters.ts +0 -53
- package/src/command-palette/command-palette.spec.ts +0 -349
- package/src/command-palette/command-palette.ts +0 -204
- package/src/command-palette/command-separator.ts +0 -18
- package/src/command-palette/index.ts +0 -15
- package/src/confirm-popup/confirm-popup-action.ts +0 -39
- package/src/confirm-popup/confirm-popup-cancel.ts +0 -38
- package/src/confirm-popup/confirm-popup-content.ts +0 -113
- package/src/confirm-popup/confirm-popup-message.ts +0 -36
- package/src/confirm-popup/confirm-popup-trigger.ts +0 -31
- package/src/confirm-popup/confirm-popup.context.ts +0 -41
- package/src/confirm-popup/confirm-popup.spec.ts +0 -337
- package/src/confirm-popup/confirm-popup.ts +0 -109
- package/src/confirm-popup/index.ts +0 -12
- package/src/date-picker/date-picker-calendar.ts +0 -65
- package/src/date-picker/date-picker-trigger.ts +0 -215
- package/src/date-picker/date-picker.context.ts +0 -50
- package/src/date-picker/date-picker.spec.ts +0 -117
- package/src/date-picker/date-picker.ts +0 -127
- package/src/date-picker/index.ts +0 -7
- package/src/dialog/_examples/dialog.confirm.example.ts +0 -145
- package/src/dialog/_examples/dialog.example.ts +0 -106
- package/src/dialog/_examples/dialog.finance.example.ts +0 -121
- package/src/dialog/_examples/dialog.retro.example.ts +0 -126
- package/src/dialog/_examples/index.ts +0 -6
- package/src/dialog/dialog.ref.ts +0 -42
- package/src/dialog/dialog.service.ts +0 -66
- package/src/dialog/dialog.spec.ts +0 -37
- package/src/dialog/dialog.ts +0 -26
- package/src/dialog/index.ts +0 -3
- package/src/divider/divider.spec.ts +0 -223
- package/src/divider/divider.ts +0 -137
- package/src/divider/index.ts +0 -5
- package/src/drawer/drawer.ref.ts +0 -63
- package/src/drawer/drawer.service.ts +0 -106
- package/src/drawer/drawer.spec.ts +0 -117
- package/src/drawer/drawer.ts +0 -122
- package/src/drawer/index.ts +0 -10
- package/src/dropdown-menu/dropdown-menu-content.ts +0 -258
- package/src/dropdown-menu/dropdown-menu-group.ts +0 -31
- package/src/dropdown-menu/dropdown-menu-item.ts +0 -51
- package/src/dropdown-menu/dropdown-menu-label.ts +0 -41
- package/src/dropdown-menu/dropdown-menu-separator.ts +0 -27
- package/src/dropdown-menu/dropdown-menu-trigger.ts +0 -140
- package/src/dropdown-menu/dropdown-menu.spec.ts +0 -265
- package/src/dropdown-menu/dropdown-menu.ts +0 -60
- package/src/dropdown-menu/index.ts +0 -15
- package/src/example-components.ts +0 -42
- package/src/field/field-error.ts +0 -49
- package/src/field/field-group.ts +0 -39
- package/src/field/field-help.ts +0 -47
- package/src/field/field-label.ts +0 -30
- package/src/field/field.context.ts +0 -28
- package/src/field/field.spec.ts +0 -179
- package/src/field/field.ts +0 -121
- package/src/field/index.ts +0 -6
- package/src/file-upload/file-upload.context.ts +0 -89
- package/src/file-upload/file-upload.spec.ts +0 -290
- package/src/file-upload/file-upload.ts +0 -639
- package/src/file-upload/file-upload.types.ts +0 -59
- package/src/file-upload/index.ts +0 -23
- package/src/form/form-error-summary.ts +0 -87
- package/src/form/form-field.context.ts +0 -3
- package/src/form/form-field.spec.ts +0 -25
- package/src/form/form-field.ts +0 -52
- package/src/form/form.context.ts +0 -53
- package/src/form/form.spec.ts +0 -162
- package/src/form/form.ts +0 -326
- package/src/form/index.ts +0 -11
- package/src/icon/E2E.md +0 -14
- package/src/icon/icon.directive.spec.ts +0 -198
- package/src/icon/icon.directive.ts +0 -113
- package/src/icon/icon.mode.spec.ts +0 -29
- package/src/icon/icon.mode.ts +0 -23
- package/src/icon/icon.providers.spec.ts +0 -63
- package/src/icon/icon.providers.ts +0 -47
- package/src/icon/icon.resolver.spec.ts +0 -96
- package/src/icon/icon.resolver.ts +0 -49
- package/src/icon/icon.tokens.ts +0 -88
- package/src/icon/icon.types.ts +0 -48
- package/src/icon/index.ts +0 -21
- package/src/input/index.ts +0 -1
- package/src/input/input.spec.ts +0 -43
- package/src/input/input.ts +0 -89
- package/src/input-group/index.ts +0 -3
- package/src/input-group/input-group-addon.ts +0 -92
- package/src/input-group/input-group.context.ts +0 -27
- package/src/input-group/input-group.spec.ts +0 -186
- package/src/input-group/input-group.ts +0 -136
- package/src/input-mask/index.ts +0 -11
- package/src/input-mask/input-mask.compile.ts +0 -69
- package/src/input-mask/input-mask.engine.ts +0 -376
- package/src/input-mask/input-mask.presets.ts +0 -24
- package/src/input-mask/input-mask.spec.ts +0 -304
- package/src/input-mask/input-mask.tokens.ts +0 -49
- package/src/input-mask/input-mask.ts +0 -280
- package/src/input-otp/index.ts +0 -2
- package/src/input-otp/input-otp.context.ts +0 -41
- package/src/input-otp/input-otp.spec.ts +0 -308
- package/src/input-otp/input-otp.ts +0 -470
- package/src/kbd/index.ts +0 -1
- package/src/kbd/kbd.spec.ts +0 -127
- package/src/kbd/kbd.ts +0 -132
- package/src/link/config.ts +0 -44
- package/src/link/index.ts +0 -2
- package/src/link/link.spec.ts +0 -246
- package/src/link/link.ts +0 -226
- package/src/list/index.ts +0 -11
- package/src/list/list.spec.ts +0 -237
- package/src/list/list.ts +0 -277
- package/src/menubar/index.ts +0 -7
- package/src/menubar/menubar-item.ts +0 -204
- package/src/menubar/menubar.context.ts +0 -43
- package/src/menubar/menubar.spec.ts +0 -433
- package/src/menubar/menubar.ts +0 -309
- package/src/number-input/index.ts +0 -4
- package/src/number-input/number-input-group.ts +0 -64
- package/src/number-input/number-input.context.ts +0 -31
- package/src/number-input/number-input.format.ts +0 -148
- package/src/number-input/number-input.spec.ts +0 -170
- package/src/number-input/number-input.ts +0 -457
- package/src/number-input/number-stepper.ts +0 -193
- package/src/overlay-badge/index.ts +0 -7
- package/src/overlay-badge/overlay-badge-content.ts +0 -73
- package/src/overlay-badge/overlay-badge.context.ts +0 -37
- package/src/overlay-badge/overlay-badge.spec.ts +0 -220
- package/src/overlay-badge/overlay-badge.ts +0 -128
- package/src/pagination/config.ts +0 -82
- package/src/pagination/index.ts +0 -19
- package/src/pagination/page-tokens.ts +0 -78
- package/src/pagination/pagination-ellipsis.ts +0 -69
- package/src/pagination/pagination-first.ts +0 -84
- package/src/pagination/pagination-info.ts +0 -70
- package/src/pagination/pagination-item.ts +0 -81
- package/src/pagination/pagination-last.ts +0 -85
- package/src/pagination/pagination-next.ts +0 -86
- package/src/pagination/pagination-previous.ts +0 -90
- package/src/pagination/pagination.context.ts +0 -52
- package/src/pagination/pagination.spec.ts +0 -388
- package/src/pagination/pagination.ts +0 -288
- package/src/password-input/index.ts +0 -15
- package/src/password-input/password-input.context.ts +0 -65
- package/src/password-input/password-input.scorer.ts +0 -34
- package/src/password-input/password-input.spec.ts +0 -274
- package/src/password-input/password-input.ts +0 -488
- package/src/popover/_examples/index.ts +0 -5
- package/src/popover/_examples/popover.example.ts +0 -92
- package/src/popover/_examples/popover.finance.example.ts +0 -106
- package/src/popover/_examples/popover.retro.example.ts +0 -103
- package/src/popover/index.ts +0 -5
- package/src/popover/popover-arrow.ts +0 -30
- package/src/popover/popover-close.ts +0 -36
- package/src/popover/popover-content.ts +0 -41
- package/src/popover/popover-title.ts +0 -39
- package/src/popover/popover-trigger.ts +0 -40
- package/src/popover/popover.spec.ts +0 -59
- package/src/popover/popover.ts +0 -5
- package/src/presets/bind-presets.spec.ts +0 -50
- package/src/presets/bind-presets.ts +0 -43
- package/src/presets/index.ts +0 -3
- package/src/presets/size.spec.ts +0 -67
- package/src/presets/size.ts +0 -59
- package/src/presets/variant.spec.ts +0 -72
- package/src/presets/variant.ts +0 -62
- package/src/primitives/.gitkeep +0 -0
- package/src/primitives/directionality/directionality.spec.ts +0 -112
- package/src/primitives/directionality/directionality.ts +0 -89
- package/src/primitives/directionality/index.ts +0 -1
- package/src/primitives/forms/form-control.spec.ts +0 -67
- package/src/primitives/forms/form-control.ts +0 -94
- package/src/primitives/forms/index.ts +0 -1
- package/src/primitives/index.ts +0 -6
- package/src/primitives/interaction/disabled.spec.ts +0 -47
- package/src/primitives/interaction/disabled.ts +0 -31
- package/src/primitives/interaction/focus-ring.spec.ts +0 -62
- package/src/primitives/interaction/focus-ring.ts +0 -59
- package/src/primitives/interaction/index.ts +0 -2
- package/src/primitives/list/filterable-list.spec.ts +0 -114
- package/src/primitives/list/filterable-list.ts +0 -126
- package/src/primitives/list/group.spec.ts +0 -99
- package/src/primitives/list/group.ts +0 -139
- package/src/primitives/list/index.ts +0 -8
- package/src/primitives/list/inject-helpers.ts +0 -8
- package/src/primitives/list/item.spec.ts +0 -173
- package/src/primitives/list/item.ts +0 -222
- package/src/primitives/list/navigator.spec.ts +0 -286
- package/src/primitives/list/navigator.ts +0 -238
- package/src/primitives/list/selection.spec.ts +0 -214
- package/src/primitives/list/selection.ts +0 -339
- package/src/primitives/list/tokens.ts +0 -106
- package/src/primitives/list/type-ahead.spec.ts +0 -58
- package/src/primitives/list/type-ahead.ts +0 -46
- package/src/primitives/overlay/backdrop.spec.ts +0 -54
- package/src/primitives/overlay/backdrop.ts +0 -31
- package/src/primitives/overlay/builder.spec.ts +0 -38
- package/src/primitives/overlay/builder.ts +0 -151
- package/src/primitives/overlay/container.ts +0 -42
- package/src/primitives/overlay/context.ts +0 -14
- package/src/primitives/overlay/controller.spec.ts +0 -86
- package/src/primitives/overlay/controller.ts +0 -190
- package/src/primitives/overlay/id.spec.ts +0 -24
- package/src/primitives/overlay/id.ts +0 -17
- package/src/primitives/overlay/index.ts +0 -18
- package/src/primitives/overlay/overlay.css +0 -42
- package/src/primitives/overlay/panel.spec.ts +0 -52
- package/src/primitives/overlay/panel.ts +0 -102
- package/src/primitives/overlay/stack.spec.ts +0 -55
- package/src/primitives/overlay/stack.ts +0 -113
- package/src/primitives/overlay/strategies/backdrop/blurred.spec.ts +0 -11
- package/src/primitives/overlay/strategies/backdrop/blurred.ts +0 -5
- package/src/primitives/overlay/strategies/backdrop/none.spec.ts +0 -10
- package/src/primitives/overlay/strategies/backdrop/none.ts +0 -9
- package/src/primitives/overlay/strategies/backdrop/solid.spec.ts +0 -18
- package/src/primitives/overlay/strategies/backdrop/solid.ts +0 -23
- package/src/primitives/overlay/strategies/focus-trap/inert-based.spec.ts +0 -28
- package/src/primitives/overlay/strategies/focus-trap/inert-based.ts +0 -38
- package/src/primitives/overlay/strategies/focus-trap/no-trap.spec.ts +0 -9
- package/src/primitives/overlay/strategies/focus-trap/no-trap.ts +0 -8
- package/src/primitives/overlay/strategies/focus-trap/tab-cycle.spec.ts +0 -49
- package/src/primitives/overlay/strategies/focus-trap/tab-cycle.ts +0 -85
- package/src/primitives/overlay/strategies/index.ts +0 -34
- package/src/primitives/overlay/strategies/live-announcer/_announce.ts +0 -35
- package/src/primitives/overlay/strategies/live-announcer/assertive.spec.ts +0 -21
- package/src/primitives/overlay/strategies/live-announcer/assertive.ts +0 -11
- package/src/primitives/overlay/strategies/live-announcer/polite.spec.ts +0 -21
- package/src/primitives/overlay/strategies/live-announcer/polite.ts +0 -11
- package/src/primitives/overlay/strategies/live-announcer/silent.spec.ts +0 -12
- package/src/primitives/overlay/strategies/live-announcer/silent.ts +0 -5
- package/src/primitives/overlay/strategies/mount/body-portal.spec.ts +0 -40
- package/src/primitives/overlay/strategies/mount/body-portal.ts +0 -91
- package/src/primitives/overlay/strategies/mount/in-container.spec.ts +0 -43
- package/src/primitives/overlay/strategies/mount/in-container.ts +0 -39
- package/src/primitives/overlay/strategies/mount/in-place.spec.ts +0 -40
- package/src/primitives/overlay/strategies/mount/in-place.ts +0 -20
- package/src/primitives/overlay/strategies/position/anchored-to.spec.ts +0 -56
- package/src/primitives/overlay/strategies/position/anchored-to.ts +0 -248
- package/src/primitives/overlay/strategies/position/corner.spec.ts +0 -36
- package/src/primitives/overlay/strategies/position/corner.ts +0 -33
- package/src/primitives/overlay/strategies/position/edge-sheet.spec.ts +0 -32
- package/src/primitives/overlay/strategies/position/edge-sheet.ts +0 -36
- package/src/primitives/overlay/strategies/position/in-place-sibling.spec.ts +0 -25
- package/src/primitives/overlay/strategies/position/in-place-sibling.ts +0 -13
- package/src/primitives/overlay/strategies/position/point-at.spec.ts +0 -40
- package/src/primitives/overlay/strategies/position/point-at.ts +0 -34
- package/src/primitives/overlay/strategies/position/viewport-centered.spec.ts +0 -31
- package/src/primitives/overlay/strategies/position/viewport-centered.ts +0 -31
- package/src/primitives/overlay/strategies/scroll-lock/css-clip.spec.ts +0 -15
- package/src/primitives/overlay/strategies/scroll-lock/css-clip.ts +0 -39
- package/src/primitives/overlay/strategies/scroll-lock/html-overflow.spec.ts +0 -21
- package/src/primitives/overlay/strategies/scroll-lock/html-overflow.ts +0 -44
- package/src/primitives/overlay/strategies/scroll-lock/none.spec.ts +0 -9
- package/src/primitives/overlay/strategies/scroll-lock/none.ts +0 -5
- package/src/primitives/overlay/strategies/trigger-event/on-click.spec.ts +0 -32
- package/src/primitives/overlay/strategies/trigger-event/on-click.ts +0 -28
- package/src/primitives/overlay/strategies/trigger-event/on-context-menu.spec.ts +0 -45
- package/src/primitives/overlay/strategies/trigger-event/on-context-menu.ts +0 -70
- package/src/primitives/overlay/strategies/trigger-event/on-focus-or-input.spec.ts +0 -35
- package/src/primitives/overlay/strategies/trigger-event/on-focus-or-input.ts +0 -34
- package/src/primitives/overlay/strategies/trigger-event/on-focus.spec.ts +0 -64
- package/src/primitives/overlay/strategies/trigger-event/on-focus.ts +0 -37
- package/src/primitives/overlay/strategies/trigger-event/on-hotkey.spec.ts +0 -37
- package/src/primitives/overlay/strategies/trigger-event/on-hotkey.ts +0 -59
- package/src/primitives/overlay/strategies/trigger-event/on-hover.spec.ts +0 -34
- package/src/primitives/overlay/strategies/trigger-event/on-hover.ts +0 -86
- package/src/primitives/overlay/strategies/trigger-event/programmatic.spec.ts +0 -16
- package/src/primitives/overlay/strategies/trigger-event/programmatic.ts +0 -12
- package/src/primitives/overlay/tokens.ts +0 -54
- package/src/primitives/overlay/trigger.spec.ts +0 -103
- package/src/primitives/overlay/trigger.ts +0 -75
- package/src/primitives/overlay/types.ts +0 -24
- package/src/primitives/overlay/wrapper.ts +0 -50
- package/src/primitives/signals/deep-signal.ts +0 -109
- package/src/primitives/signals/index.ts +0 -1
- package/src/progress-bar/config.ts +0 -48
- package/src/progress-bar/index.ts +0 -12
- package/src/progress-bar/progress-bar-fill.ts +0 -37
- package/src/progress-bar/progress-bar.context.ts +0 -34
- package/src/progress-bar/progress-bar.spec.ts +0 -423
- package/src/progress-bar/progress-bar.ts +0 -217
- package/src/public-api.ts +0 -84
- package/src/radio/index.ts +0 -2
- package/src/radio/radio.context.ts +0 -3
- package/src/radio/radio.spec.ts +0 -36
- package/src/radio/radio.ts +0 -66
- package/src/select/index.ts +0 -4
- package/src/select/select-content.ts +0 -69
- package/src/select/select-option.ts +0 -35
- package/src/select/select-root.ts +0 -129
- package/src/select/select-trigger.ts +0 -93
- package/src/select/select.spec.ts +0 -138
- package/src/select/select.ts +0 -4
- package/src/skeleton/index.ts +0 -5
- package/src/skeleton/skeleton.spec.ts +0 -115
- package/src/skeleton/skeleton.ts +0 -56
- package/src/slider/index.ts +0 -10
- package/src/slider/slider-range.ts +0 -49
- package/src/slider/slider-thumb.ts +0 -335
- package/src/slider/slider-track.ts +0 -70
- package/src/slider/slider.context.ts +0 -79
- package/src/slider/slider.geometry.ts +0 -73
- package/src/slider/slider.spec.ts +0 -216
- package/src/slider/slider.ts +0 -443
- package/src/speed-dial/index.ts +0 -10
- package/src/speed-dial/speed-dial-action.ts +0 -40
- package/src/speed-dial/speed-dial-actions.ts +0 -31
- package/src/speed-dial/speed-dial-trigger.ts +0 -55
- package/src/speed-dial/speed-dial.context.ts +0 -36
- package/src/speed-dial/speed-dial.spec.ts +0 -143
- package/src/speed-dial/speed-dial.ts +0 -127
- package/src/spinner/config.ts +0 -48
- package/src/spinner/index.ts +0 -8
- package/src/spinner/spinner.spec.ts +0 -262
- package/src/spinner/spinner.ts +0 -129
- package/src/stepper/index.ts +0 -15
- package/src/stepper/stepper.context.ts +0 -63
- package/src/stepper/stepper.spec.ts +0 -403
- package/src/stepper/stepper.ts +0 -544
- package/src/styles/docs-themes.css +0 -82
- package/src/styles.css +0 -17
- package/src/table/column-helpers.spec.ts +0 -74
- package/src/table/column-helpers.ts +0 -68
- package/src/table/filter-fns.ts +0 -230
- package/src/table/filter-models.spec.ts +0 -240
- package/src/table/filter-models.ts +0 -124
- package/src/table/filter-params.ts +0 -90
- package/src/table/grid-api-impl.ts +0 -321
- package/src/table/grid-api.spec.ts +0 -178
- package/src/table/grid-api.ts +0 -285
- package/src/table/index.ts +0 -73
- package/src/table/table-cell.spec.ts +0 -43
- package/src/table/table-cell.ts +0 -38
- package/src/table/table-filter-outlet.ts +0 -120
- package/src/table/table-header.spec.ts +0 -54
- package/src/table/table-header.ts +0 -63
- package/src/table/table-keyboard.spec.ts +0 -68
- package/src/table/table-keyboard.ts +0 -107
- package/src/table/table-resource.spec.ts +0 -37
- package/src/table/table-resource.ts +0 -36
- package/src/table/table-row.spec.ts +0 -54
- package/src/table/table-row.ts +0 -31
- package/src/table/table-storage.spec.ts +0 -67
- package/src/table/table-storage.ts +0 -76
- package/src/table/table.spec.ts +0 -172
- package/src/table/table.ts +0 -281
- package/src/table/table.types.ts +0 -83
- package/src/tabs/index.ts +0 -7
- package/src/tabs/tabs.context.ts +0 -32
- package/src/tabs/tabs.spec.ts +0 -352
- package/src/tabs/tabs.ts +0 -364
- package/src/tag/config.ts +0 -53
- package/src/tag/index.ts +0 -7
- package/src/tag/tag-list.ts +0 -76
- package/src/tag/tag-remove.ts +0 -61
- package/src/tag/tag.context.ts +0 -36
- package/src/tag/tag.spec.ts +0 -240
- package/src/tag/tag.ts +0 -203
- package/src/test-setup.ts +0 -5
- package/src/textarea/config.ts +0 -42
- package/src/textarea/index.ts +0 -8
- package/src/textarea/textarea.spec.ts +0 -176
- package/src/textarea/textarea.ts +0 -235
- package/src/time-picker/index.ts +0 -15
- package/src/time-picker/time-picker-meridiem.ts +0 -123
- package/src/time-picker/time-picker-segment.ts +0 -318
- package/src/time-picker/time-picker.context.ts +0 -38
- package/src/time-picker/time-picker.format.ts +0 -181
- package/src/time-picker/time-picker.spec.ts +0 -189
- package/src/time-picker/time-picker.ts +0 -274
- package/src/toast/_examples/index.ts +0 -5
- package/src/toast/_examples/toast.example.ts +0 -282
- package/src/toast/_examples/toast.finance.example.ts +0 -180
- package/src/toast/_examples/toast.retro.example.ts +0 -161
- package/src/toast/index.ts +0 -28
- package/src/toast/toast.ref.ts +0 -26
- package/src/toast/toast.service.ts +0 -339
- package/src/toast/toast.spec.ts +0 -247
- package/src/toast/toast.strategy.ts +0 -112
- package/src/toast/toast.ts +0 -463
- package/src/toast/toast.types.ts +0 -5
- package/src/toggle/index.ts +0 -1
- package/src/toggle/toggle.spec.ts +0 -24
- package/src/toggle/toggle.ts +0 -48
- package/src/tooltip/_examples/index.ts +0 -6
- package/src/tooltip/_examples/tooltip.example.ts +0 -82
- package/src/tooltip/_examples/tooltip.finance.example.ts +0 -97
- package/src/tooltip/_examples/tooltip.placements.example.ts +0 -83
- package/src/tooltip/_examples/tooltip.retro.example.ts +0 -107
- package/src/tooltip/index.ts +0 -4
- package/src/tooltip/tooltip-arrow.ts +0 -31
- package/src/tooltip/tooltip-content.ts +0 -38
- package/src/tooltip/tooltip-group.ts +0 -32
- package/src/tooltip/tooltip-trigger.ts +0 -47
- package/src/tooltip/tooltip.spec.ts +0 -40
- package/src/tooltip/tooltip.ts +0 -5
- package/src/tree-select/index.ts +0 -12
- package/src/tree-select/tree-select-content.ts +0 -199
- package/src/tree-select/tree-select-node.ts +0 -132
- package/src/tree-select/tree-select-root.ts +0 -272
- package/src/tree-select/tree-select-trigger.ts +0 -90
- package/src/tree-select/tree-select.context.ts +0 -63
- package/src/tree-select/tree-select.spec.ts +0 -433
- package/src/tree-select/tree-select.ts +0 -2
- package/src/typography/blockquote.ts +0 -57
- package/src/typography/code.ts +0 -53
- package/src/typography/index.ts +0 -22
- package/src/typography/lead.ts +0 -49
- package/src/typography/muted.ts +0 -29
- package/src/typography/truncate.ts +0 -99
- package/src/typography/typography.spec.ts +0 -203
- package/tsconfig.lib.json +0 -21
- package/tsconfig.lib.prod.json +0 -17
- package/tsconfig.spec.json +0 -18
- package/vite.config.ts +0 -27
- /package/{src/icon → icon}/icon.css +0 -0
- /package/{src/typography → typography}/prose.css +0 -0
|
@@ -1,698 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
booleanAttribute,
|
|
3
|
-
Directive,
|
|
4
|
-
ElementRef,
|
|
5
|
-
computed,
|
|
6
|
-
effect,
|
|
7
|
-
inject,
|
|
8
|
-
input,
|
|
9
|
-
output,
|
|
10
|
-
signal,
|
|
11
|
-
} from '@angular/core';
|
|
12
|
-
import { KjDisabled, KjFocusRing, KjFormControl } from '../primitives';
|
|
13
|
-
import { KjOverlayController } from '../primitives/overlay/controller';
|
|
14
|
-
import { KjOverlayTrigger } from '../primitives/overlay/trigger';
|
|
15
|
-
import { KjOverlayPanel } from '../primitives/overlay/panel';
|
|
16
|
-
import {
|
|
17
|
-
KJ_OVERLAY_TRIGGER_EVENT_STRATEGY,
|
|
18
|
-
KJ_OVERLAY_PANEL_ROLE,
|
|
19
|
-
KJ_OVERLAY_MOUNT_STRATEGY,
|
|
20
|
-
KJ_OVERLAY_POSITION_STRATEGY,
|
|
21
|
-
} from '../primitives/overlay/tokens';
|
|
22
|
-
import type { KjSide, KjAlign } from '../primitives/overlay/types';
|
|
23
|
-
import { onClick } from '../primitives/overlay/strategies/trigger-event/on-click';
|
|
24
|
-
import { bodyPortal } from '../primitives/overlay/strategies/mount/body-portal';
|
|
25
|
-
import { anchoredTo } from '../primitives/overlay/strategies/position/anchored-to';
|
|
26
|
-
import {
|
|
27
|
-
KJ_COLOR_PICKER,
|
|
28
|
-
type KjColorFormat,
|
|
29
|
-
type KjColorPickerContext,
|
|
30
|
-
type KjColorPreset,
|
|
31
|
-
type KjColorValue,
|
|
32
|
-
} from './color-picker.context';
|
|
33
|
-
import {
|
|
34
|
-
kjClamp,
|
|
35
|
-
kjHsvToHsl,
|
|
36
|
-
kjHsvToRgb,
|
|
37
|
-
kjParseHex,
|
|
38
|
-
kjRgbToHex,
|
|
39
|
-
kjRgbToHsv,
|
|
40
|
-
kjRound,
|
|
41
|
-
type KjHsv,
|
|
42
|
-
} from './color-picker.utils';
|
|
43
|
-
|
|
44
|
-
let _kjColorPickerIdCounter = 0;
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Root color-picker state container.
|
|
48
|
-
*
|
|
49
|
-
* Owns the canonical HSV+alpha state and Angular forms integration through
|
|
50
|
-
* composed `KjFormControl`. Provides `KJ_COLOR_PICKER` so every sub-directive
|
|
51
|
-
* (`KjColorPickerTrigger`, `KjColorPickerPanel`, `KjColorPickerArea`,
|
|
52
|
-
* `KjColorPickerHueSlider`, `KjColorPickerAlphaSlider`,
|
|
53
|
-
* `KjColorPickerInput`) reads the same derived signals and writes through
|
|
54
|
-
* the same mutators. The open / closed UI flag and panel positioning are
|
|
55
|
-
* delegated to the overlay primitives — the controller, the click trigger
|
|
56
|
-
* strategy, the body-portal mount, and the anchored-to position strategy
|
|
57
|
-
* are all provided here so the trigger and panel sub-directives share the
|
|
58
|
-
* same overlay scope.
|
|
59
|
-
*
|
|
60
|
-
* ```html
|
|
61
|
-
* <div kjColorPicker [(ngModel)]="brand" kjFormat="hex" kjShowAlpha>
|
|
62
|
-
* <button kjColorPickerTrigger></button>
|
|
63
|
-
* <div kjColorPickerPanel>
|
|
64
|
-
* <div kjColorPickerArea></div>
|
|
65
|
-
* <input kjColorPickerHueSlider />
|
|
66
|
-
* <input kjColorPickerAlphaSlider />
|
|
67
|
-
* <input kjColorPickerInput />
|
|
68
|
-
* </div>
|
|
69
|
-
* </div>
|
|
70
|
-
* ```
|
|
71
|
-
*
|
|
72
|
-
* @doc
|
|
73
|
-
* @doc-example Default
|
|
74
|
-
* @doc-file color-picker.example.ts
|
|
75
|
-
* @doc-category Core/Inputs
|
|
76
|
-
* @doc-name color-picker
|
|
77
|
-
* @doc-description Unstyled color-picker root that owns HSV+alpha state and emits hex, RGB, or HSL values.
|
|
78
|
-
* @doc-is-main
|
|
79
|
-
*/
|
|
80
|
-
@Directive({
|
|
81
|
-
selector: '[kjColorPicker]',
|
|
82
|
-
standalone: true,
|
|
83
|
-
hostDirectives: [
|
|
84
|
-
{ directive: KjDisabled, inputs: ['kjDisabled'] },
|
|
85
|
-
KjFormControl,
|
|
86
|
-
],
|
|
87
|
-
providers: [
|
|
88
|
-
{ provide: KJ_COLOR_PICKER, useExisting: KjColorPicker },
|
|
89
|
-
KjOverlayController,
|
|
90
|
-
{ provide: KJ_OVERLAY_TRIGGER_EVENT_STRATEGY, useFactory: () => onClick() },
|
|
91
|
-
{ provide: KJ_OVERLAY_PANEL_ROLE, useValue: 'dialog' as const },
|
|
92
|
-
{ provide: KJ_OVERLAY_MOUNT_STRATEGY, useFactory: () => bodyPortal() },
|
|
93
|
-
{ provide: KJ_OVERLAY_POSITION_STRATEGY, useFactory: () => anchoredTo() },
|
|
94
|
-
],
|
|
95
|
-
exportAs: 'kjColorPicker',
|
|
96
|
-
})
|
|
97
|
-
export class KjColorPicker implements KjColorPickerContext {
|
|
98
|
-
/** @internal */
|
|
99
|
-
readonly formCtrl = inject(KjFormControl);
|
|
100
|
-
private readonly disabledPrim = inject(KjDisabled);
|
|
101
|
-
/** @internal */
|
|
102
|
-
readonly overlay = inject(KjOverlayController);
|
|
103
|
-
|
|
104
|
-
/** Output format. Determines the shape emitted via `ngModelChange` / `kjCommit`. */
|
|
105
|
-
readonly kjFormat = input<KjColorFormat>('hex');
|
|
106
|
-
|
|
107
|
-
/** When true, the alpha slider is mounted and hex emit flips to 8 chars when α<1. */
|
|
108
|
-
readonly kjShowAlpha = input<boolean, unknown>(false, { transform: booleanAttribute });
|
|
109
|
-
|
|
110
|
-
/** When true and `kjShowAlpha=true`, hex always emits 8 chars (stable shape). */
|
|
111
|
-
readonly kjAlwaysEmitAlpha = input<boolean, unknown>(false, { transform: booleanAttribute });
|
|
112
|
-
|
|
113
|
-
/** Preset swatches; an empty array hides the preset row. */
|
|
114
|
-
readonly kjPresets = input<readonly KjColorPreset[]>([]);
|
|
115
|
-
|
|
116
|
-
/** Touched-gated invalid posture; mirrors `KjInput`. */
|
|
117
|
-
readonly kjInvalid = input<boolean, unknown>(false, { transform: booleanAttribute });
|
|
118
|
-
|
|
119
|
-
/** Override the default "Color picker" name on the trigger. */
|
|
120
|
-
readonly kjAriaLabel = input<string | undefined>(undefined);
|
|
121
|
-
|
|
122
|
-
/** Side the popup panel is anchored to relative to its trigger. */
|
|
123
|
-
readonly kjSide = input<KjSide>('bottom');
|
|
124
|
-
|
|
125
|
-
/** Alignment of the popup panel along its anchored side. */
|
|
126
|
-
readonly kjAlign = input<KjAlign>('start');
|
|
127
|
-
|
|
128
|
-
/** Fires whenever the panel transitions between open and closed. */
|
|
129
|
-
readonly kjOpenChange = output<boolean>();
|
|
130
|
-
|
|
131
|
-
/** Fires when the user commits a color (panel close, hex enter, preset click). */
|
|
132
|
-
readonly kjCommit = output<KjColorValue>();
|
|
133
|
-
|
|
134
|
-
// ── canonical state ────────────────────────────────────────────────
|
|
135
|
-
private readonly _hue = signal(0);
|
|
136
|
-
private readonly _saturation = signal(0);
|
|
137
|
-
private readonly _value = signal(0);
|
|
138
|
-
private readonly _alpha = signal(1);
|
|
139
|
-
|
|
140
|
-
readonly hue = this._hue.asReadonly();
|
|
141
|
-
readonly saturation = this._saturation.asReadonly();
|
|
142
|
-
readonly value = this._value.asReadonly();
|
|
143
|
-
readonly alpha = this._alpha.asReadonly();
|
|
144
|
-
/** Bridged to the overlay controller's open state. */
|
|
145
|
-
readonly open = this.overlay.isOpen;
|
|
146
|
-
|
|
147
|
-
readonly disabled = this.disabledPrim.disabled;
|
|
148
|
-
readonly format = computed(() => this.kjFormat());
|
|
149
|
-
readonly showAlpha = computed(() => this.kjShowAlpha());
|
|
150
|
-
readonly presets = computed(() => this.kjPresets());
|
|
151
|
-
|
|
152
|
-
// Stable wiring ids used by the input / area / labels — the overlay
|
|
153
|
-
// primitives mint their own ids on the trigger and panel hosts.
|
|
154
|
-
private readonly _id = ++_kjColorPickerIdCounter;
|
|
155
|
-
readonly panelId = signal(`kj-color-picker-panel-${this._id}`).asReadonly();
|
|
156
|
-
readonly triggerId = signal(`kj-color-picker-trigger-${this._id}`).asReadonly();
|
|
157
|
-
|
|
158
|
-
// ── derived projections ────────────────────────────────────────────
|
|
159
|
-
readonly rgb = computed(() => kjHsvToRgb({
|
|
160
|
-
h: this._hue(), s: this._saturation(), v: this._value(), a: this._alpha(),
|
|
161
|
-
}));
|
|
162
|
-
readonly hsv = computed<KjHsv>(() => ({
|
|
163
|
-
h: this._hue(), s: this._saturation(), v: this._value(), a: this._alpha(),
|
|
164
|
-
}));
|
|
165
|
-
readonly hsl = computed(() => kjHsvToHsl(this.hsv()));
|
|
166
|
-
readonly hex = computed(() => {
|
|
167
|
-
const includeAlpha = this.kjShowAlpha()
|
|
168
|
-
&& (this.kjAlwaysEmitAlpha() || this._alpha() < 1);
|
|
169
|
-
return kjRgbToHex(this.rgb(), includeAlpha);
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
/** The current value projected through the active `kjFormat`. */
|
|
173
|
-
readonly currentValue = computed<KjColorValue>(() => projectValue(
|
|
174
|
-
this.kjFormat(),
|
|
175
|
-
this.hex(),
|
|
176
|
-
this.rgb(),
|
|
177
|
-
this.hsl(),
|
|
178
|
-
this.kjShowAlpha(),
|
|
179
|
-
));
|
|
180
|
-
|
|
181
|
-
// ── form integration ───────────────────────────────────────────────
|
|
182
|
-
// Track the last value we *emitted* so writeValue → state → emit doesn't
|
|
183
|
-
// loop. We compare against the currentValue projection.
|
|
184
|
-
private _suppressEmit = false;
|
|
185
|
-
// The state-projection effect runs once on subscription with the picker's
|
|
186
|
-
// DEFAULT HSV state (which projects to `#000000`). That used to fire
|
|
187
|
-
// `notifyChange` BEFORE the form's initial `writeValue(...)` reached us,
|
|
188
|
-
// so a `[ngModel]`-bound consumer received `#000000` ahead of its real
|
|
189
|
-
// value — corrupting the bound state. Swallow the bootstrap pass so
|
|
190
|
-
// emissions only flow after either an external write or a real user
|
|
191
|
-
// interaction.
|
|
192
|
-
private _initialEmitConsumed = false;
|
|
193
|
-
|
|
194
|
-
constructor() {
|
|
195
|
-
const pos = inject(KJ_OVERLAY_POSITION_STRATEGY) as ReturnType<typeof anchoredTo>;
|
|
196
|
-
pos.configure({ side: this.kjSide, align: this.kjAlign });
|
|
197
|
-
// External writes (writeValue / setValue) parse into HSV state.
|
|
198
|
-
effect(() => {
|
|
199
|
-
const incoming = this.formCtrl.value();
|
|
200
|
-
if (incoming === undefined || incoming === null || incoming === '') return;
|
|
201
|
-
this._suppressEmit = true;
|
|
202
|
-
try {
|
|
203
|
-
this.applyExternal(incoming);
|
|
204
|
-
} finally {
|
|
205
|
-
this._suppressEmit = false;
|
|
206
|
-
}
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
// Internal state changes propagate to the form layer.
|
|
210
|
-
effect(() => {
|
|
211
|
-
const next = this.currentValue();
|
|
212
|
-
if (this._suppressEmit) return;
|
|
213
|
-
if (!this._initialEmitConsumed) {
|
|
214
|
-
this._initialEmitConsumed = true;
|
|
215
|
-
return;
|
|
216
|
-
}
|
|
217
|
-
const current = this.formCtrl.value();
|
|
218
|
-
// Avoid spamming when the value is structurally unchanged.
|
|
219
|
-
if (sameValue(current, next)) return;
|
|
220
|
-
this.formCtrl.notifyChange(next);
|
|
221
|
-
});
|
|
222
|
-
|
|
223
|
-
// Bridge overlay open/close transitions to the consumer-facing
|
|
224
|
-
// outputs. Only emit when the state genuinely flips (the controller
|
|
225
|
-
// exposes both open/opening and closed/closing — collapse to a
|
|
226
|
-
// boolean and dedupe).
|
|
227
|
-
let lastOpen = this.overlay.isOpen();
|
|
228
|
-
effect(() => {
|
|
229
|
-
const isOpen = this.overlay.isOpen();
|
|
230
|
-
if (isOpen === lastOpen) return;
|
|
231
|
-
lastOpen = isOpen;
|
|
232
|
-
this.kjOpenChange.emit(isOpen);
|
|
233
|
-
if (!isOpen) this.kjCommit.emit(this.currentValue());
|
|
234
|
-
});
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
// ── mutators ───────────────────────────────────────────────────────
|
|
238
|
-
setHue(h: number): void {
|
|
239
|
-
if (this.disabled()) return;
|
|
240
|
-
this._hue.set(((h % 360) + 360) % 360);
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
setSaturationValue(s: number, v: number): void {
|
|
244
|
-
if (this.disabled()) return;
|
|
245
|
-
this._saturation.set(kjClamp(s, 0, 1));
|
|
246
|
-
this._value.set(kjClamp(v, 0, 1));
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
setAlpha(a: number): void {
|
|
250
|
-
if (this.disabled()) return;
|
|
251
|
-
if (!this.kjShowAlpha()) return;
|
|
252
|
-
this._alpha.set(kjClamp(a, 0, 1));
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
setHex(hex: string): boolean {
|
|
256
|
-
if (this.disabled()) return false;
|
|
257
|
-
const rgb = kjParseHex(hex);
|
|
258
|
-
if (!rgb) return false;
|
|
259
|
-
const hsv = kjRgbToHsv(rgb);
|
|
260
|
-
this._hue.set(hsv.h);
|
|
261
|
-
this._saturation.set(hsv.s);
|
|
262
|
-
this._value.set(hsv.v);
|
|
263
|
-
if (this.kjShowAlpha()) this._alpha.set(rgb.a);
|
|
264
|
-
return true;
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
setRgb(r: number, g: number, b: number, a?: number): void {
|
|
268
|
-
if (this.disabled()) return;
|
|
269
|
-
const rgb = {
|
|
270
|
-
r: kjClamp(r, 0, 255),
|
|
271
|
-
g: kjClamp(g, 0, 255),
|
|
272
|
-
b: kjClamp(b, 0, 255),
|
|
273
|
-
a: a === undefined ? this._alpha() : kjClamp(a, 0, 1),
|
|
274
|
-
};
|
|
275
|
-
const hsv = kjRgbToHsv(rgb);
|
|
276
|
-
this._hue.set(hsv.h);
|
|
277
|
-
this._saturation.set(hsv.s);
|
|
278
|
-
this._value.set(hsv.v);
|
|
279
|
-
if (this.kjShowAlpha() && a !== undefined) this._alpha.set(rgb.a);
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
setOpen(open: boolean): void {
|
|
283
|
-
if (this.disabled() && open) return;
|
|
284
|
-
if (this.overlay.isOpen() === open) return;
|
|
285
|
-
if (open) this.overlay.open();
|
|
286
|
-
else this.overlay.close('programmatic');
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
toggle(): void {
|
|
290
|
-
this.setOpen(!this.overlay.isOpen());
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
/** @internal */
|
|
294
|
-
private applyExternal(v: unknown): void {
|
|
295
|
-
if (typeof v === 'string') {
|
|
296
|
-
this.setHex(v);
|
|
297
|
-
return;
|
|
298
|
-
}
|
|
299
|
-
if (Array.isArray(v) && v.length >= 3) {
|
|
300
|
-
const [r, g, b, a] = v as number[];
|
|
301
|
-
this.setRgb(r, g, b, a);
|
|
302
|
-
return;
|
|
303
|
-
}
|
|
304
|
-
if (v && typeof v === 'object') {
|
|
305
|
-
const o = v as Record<string, number>;
|
|
306
|
-
if ('h' in o && 's' in o && 'l' in o) {
|
|
307
|
-
// Convert HSL → HSV by way of RGB so alpha and round-tripping
|
|
308
|
-
// are consistent with the rest of the pipeline.
|
|
309
|
-
const hslToRgb = hslToRgbValue(o['h'], o['s'], o['l']);
|
|
310
|
-
this.setRgb(hslToRgb.r, hslToRgb.g, hslToRgb.b, 'a' in o ? o['a'] : undefined);
|
|
311
|
-
} else if ('r' in o && 'g' in o && 'b' in o) {
|
|
312
|
-
this.setRgb(o['r'], o['g'], o['b'], 'a' in o ? o['a'] : undefined);
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
function projectValue(
|
|
319
|
-
fmt: KjColorFormat,
|
|
320
|
-
hex: string,
|
|
321
|
-
rgb: { r: number; g: number; b: number; a: number },
|
|
322
|
-
hsl: { h: number; s: number; l: number; a: number },
|
|
323
|
-
showAlpha: boolean,
|
|
324
|
-
): KjColorValue {
|
|
325
|
-
if (fmt === 'hex') return hex;
|
|
326
|
-
if (fmt === 'rgb') {
|
|
327
|
-
return showAlpha
|
|
328
|
-
? [rgb.r, rgb.g, rgb.b, kjRound(rgb.a, 2)] as const
|
|
329
|
-
: [rgb.r, rgb.g, rgb.b] as const;
|
|
330
|
-
}
|
|
331
|
-
return showAlpha
|
|
332
|
-
? { h: kjRound(hsl.h, 1), s: kjRound(hsl.s, 3), l: kjRound(hsl.l, 3), a: kjRound(hsl.a, 2) }
|
|
333
|
-
: { h: kjRound(hsl.h, 1), s: kjRound(hsl.s, 3), l: kjRound(hsl.l, 3) };
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
function sameValue(a: unknown, b: unknown): boolean {
|
|
337
|
-
if (a === b) return true;
|
|
338
|
-
if (typeof a === 'string' || typeof b === 'string') return a === b;
|
|
339
|
-
if (Array.isArray(a) && Array.isArray(b)) {
|
|
340
|
-
if (a.length !== b.length) return false;
|
|
341
|
-
for (let i = 0; i < a.length; i++) if (a[i] !== b[i]) return false;
|
|
342
|
-
return true;
|
|
343
|
-
}
|
|
344
|
-
if (a && b && typeof a === 'object' && typeof b === 'object') {
|
|
345
|
-
const ka = Object.keys(a as object);
|
|
346
|
-
const kb = Object.keys(b as object);
|
|
347
|
-
if (ka.length !== kb.length) return false;
|
|
348
|
-
for (const k of ka) {
|
|
349
|
-
if ((a as Record<string, unknown>)[k] !== (b as Record<string, unknown>)[k]) return false;
|
|
350
|
-
}
|
|
351
|
-
return true;
|
|
352
|
-
}
|
|
353
|
-
return false;
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
function hslToRgbValue(h: number, s: number, l: number): { r: number; g: number; b: number } {
|
|
357
|
-
// Standard HSL → RGB; matches CSS Color spec.
|
|
358
|
-
const C = (1 - Math.abs(2 * l - 1)) * s;
|
|
359
|
-
const hp = (((h % 360) + 360) % 360) / 60;
|
|
360
|
-
const X = C * (1 - Math.abs((hp % 2) - 1));
|
|
361
|
-
let r = 0, g = 0, b = 0;
|
|
362
|
-
if (hp < 1) { r = C; g = X; }
|
|
363
|
-
else if (hp < 2) { r = X; g = C; }
|
|
364
|
-
else if (hp < 3) { g = C; b = X; }
|
|
365
|
-
else if (hp < 4) { g = X; b = C; }
|
|
366
|
-
else if (hp < 5) { r = X; b = C; }
|
|
367
|
-
else { r = C; b = X; }
|
|
368
|
-
const m = l - C / 2;
|
|
369
|
-
return {
|
|
370
|
-
r: Math.round((r + m) * 255),
|
|
371
|
-
g: Math.round((g + m) * 255),
|
|
372
|
-
b: Math.round((b + m) * 255),
|
|
373
|
-
};
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
// ────────────────────────────────────────────────────────────────────
|
|
377
|
-
// Sub-directives
|
|
378
|
-
// ────────────────────────────────────────────────────────────────────
|
|
379
|
-
|
|
380
|
-
/**
|
|
381
|
-
* Trigger button that opens the color-picker panel and renders the
|
|
382
|
-
* current color as its background. Composes `KjOverlayTrigger` for the
|
|
383
|
-
* shared overlay state machine; the click strategy and panel role are
|
|
384
|
-
* provided by the root `KjColorPicker` so the trigger and panel share
|
|
385
|
-
* the same controller instance. `aria-haspopup="dialog"`, `aria-expanded`
|
|
386
|
-
* and `aria-controls` are wired by the overlay primitive.
|
|
387
|
-
*
|
|
388
|
-
* @doc-category Core/Inputs
|
|
389
|
-
* @doc
|
|
390
|
-
* @doc-name color-picker
|
|
391
|
-
*/
|
|
392
|
-
@Directive({
|
|
393
|
-
selector: '[kjColorPickerTrigger]',
|
|
394
|
-
standalone: true,
|
|
395
|
-
hostDirectives: [
|
|
396
|
-
KjFocusRing,
|
|
397
|
-
{ directive: KjOverlayTrigger, inputs: ['kjOpen'] },
|
|
398
|
-
],
|
|
399
|
-
host: {
|
|
400
|
-
'type': 'button',
|
|
401
|
-
'[id]': 'ctx.triggerId()',
|
|
402
|
-
'[attr.aria-haspopup]': '"dialog"',
|
|
403
|
-
'[attr.aria-label]': 'ariaLabel()',
|
|
404
|
-
'[attr.aria-disabled]': 'ctx.disabled() ? "true" : null',
|
|
405
|
-
'[attr.data-disabled]': 'ctx.disabled() ? "" : null',
|
|
406
|
-
'[style.--kj-color-picker-current]': 'ctx.hex()',
|
|
407
|
-
},
|
|
408
|
-
})
|
|
409
|
-
export class KjColorPickerTrigger {
|
|
410
|
-
/** @internal */
|
|
411
|
-
readonly ctx = inject(KJ_COLOR_PICKER);
|
|
412
|
-
private readonly root = inject(KjColorPicker);
|
|
413
|
-
|
|
414
|
-
/** @internal */
|
|
415
|
-
readonly ariaLabel = computed(() =>
|
|
416
|
-
this.root.kjAriaLabel() || `Color picker, current value ${this.ctx.hex()}`);
|
|
417
|
-
|
|
418
|
-
private readonly _overlayTrigger = inject(KjOverlayTrigger, { self: true });
|
|
419
|
-
/** The controller of the composed `KjOverlayTrigger`, exposed for sibling `[kjFor]` panels. */
|
|
420
|
-
get controller() {
|
|
421
|
-
return this._overlayTrigger.controller;
|
|
422
|
-
}
|
|
423
|
-
attachPanel(panel: KjOverlayPanel): void {
|
|
424
|
-
this._overlayTrigger.attachPanel(panel);
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
/**
|
|
429
|
-
* Popup panel container. Composes `KjOverlayPanel` for state-driven
|
|
430
|
-
* mount/position and the standard `role="dialog"` / `[hidden]` wiring;
|
|
431
|
-
* the mount and position strategies are provided by the root
|
|
432
|
-
* `KjColorPicker`.
|
|
433
|
-
*
|
|
434
|
-
* @doc-category Core/Inputs
|
|
435
|
-
* @doc
|
|
436
|
-
* @doc-name color-picker
|
|
437
|
-
*/
|
|
438
|
-
@Directive({
|
|
439
|
-
selector: '[kjColorPickerPanel]',
|
|
440
|
-
standalone: true,
|
|
441
|
-
hostDirectives: [
|
|
442
|
-
{ directive: KjOverlayPanel, inputs: ['kjFor'] },
|
|
443
|
-
],
|
|
444
|
-
providers: [
|
|
445
|
-
{ provide: KJ_OVERLAY_PANEL_ROLE, useValue: 'dialog' as const },
|
|
446
|
-
],
|
|
447
|
-
host: {
|
|
448
|
-
'[attr.aria-labelledby]': 'ctx.triggerId()',
|
|
449
|
-
},
|
|
450
|
-
})
|
|
451
|
-
export class KjColorPickerPanel {
|
|
452
|
-
/** @internal */
|
|
453
|
-
readonly ctx = inject(KJ_COLOR_PICKER);
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
/**
|
|
457
|
-
* Two-axis saturation/value rectangle. Pointer drag updates both axes;
|
|
458
|
-
* arrow keys step ±1% (Shift = ±10%). Single `role="slider"` per the
|
|
459
|
-
* APG color-picker pattern; full state announced via `aria-valuetext`.
|
|
460
|
-
*
|
|
461
|
-
* @doc-category Core/Inputs
|
|
462
|
-
* @doc
|
|
463
|
-
* @doc-name color-picker
|
|
464
|
-
*/
|
|
465
|
-
@Directive({
|
|
466
|
-
selector: '[kjColorPickerArea]',
|
|
467
|
-
standalone: true,
|
|
468
|
-
hostDirectives: [KjFocusRing],
|
|
469
|
-
host: {
|
|
470
|
-
'role': 'slider',
|
|
471
|
-
'tabindex': '0',
|
|
472
|
-
'[attr.aria-label]': '"Color saturation and value"',
|
|
473
|
-
'[attr.aria-orientation]': '"horizontal"',
|
|
474
|
-
'[attr.aria-valuemin]': '0',
|
|
475
|
-
'[attr.aria-valuemax]': '100',
|
|
476
|
-
'[attr.aria-valuenow]': 'ariaValueNow()',
|
|
477
|
-
'[attr.aria-valuetext]': 'ariaValueText()',
|
|
478
|
-
'[attr.aria-disabled]': 'ctx.disabled() ? "true" : null',
|
|
479
|
-
'[style.--kj-color-picker-hue]': 'ctx.hue()',
|
|
480
|
-
'[style.--kj-color-picker-x]': 'ctx.saturation()',
|
|
481
|
-
'[style.--kj-color-picker-y]': 'ctx.value()',
|
|
482
|
-
'(pointerdown)': 'onPointerDown($event)',
|
|
483
|
-
'(keydown)': 'onKeydown($event)',
|
|
484
|
-
},
|
|
485
|
-
})
|
|
486
|
-
export class KjColorPickerArea {
|
|
487
|
-
/** @internal */
|
|
488
|
-
readonly ctx = inject(KJ_COLOR_PICKER);
|
|
489
|
-
private readonly el = inject<ElementRef<HTMLElement>>(ElementRef);
|
|
490
|
-
|
|
491
|
-
/** @internal */
|
|
492
|
-
readonly ariaValueNow = computed(() => Math.round(this.ctx.saturation() * 100));
|
|
493
|
-
/** @internal */
|
|
494
|
-
readonly ariaValueText = computed(() => {
|
|
495
|
-
const s = Math.round(this.ctx.saturation() * 100);
|
|
496
|
-
const v = Math.round(this.ctx.value() * 100);
|
|
497
|
-
const h = Math.round(this.ctx.hue());
|
|
498
|
-
return `Saturation ${s} percent, value ${v} percent, hue ${h} degrees`;
|
|
499
|
-
});
|
|
500
|
-
|
|
501
|
-
/** @internal */
|
|
502
|
-
onPointerDown(event: PointerEvent): void {
|
|
503
|
-
if (this.ctx.disabled()) return;
|
|
504
|
-
const target = this.el.nativeElement;
|
|
505
|
-
target.setPointerCapture?.(event.pointerId);
|
|
506
|
-
this.update(event);
|
|
507
|
-
const move = (e: PointerEvent) => this.update(e);
|
|
508
|
-
const up = (e: PointerEvent) => {
|
|
509
|
-
target.releasePointerCapture?.(e.pointerId);
|
|
510
|
-
target.removeEventListener('pointermove', move);
|
|
511
|
-
target.removeEventListener('pointerup', up);
|
|
512
|
-
target.removeEventListener('pointercancel', up);
|
|
513
|
-
};
|
|
514
|
-
target.addEventListener('pointermove', move);
|
|
515
|
-
target.addEventListener('pointerup', up);
|
|
516
|
-
target.addEventListener('pointercancel', up);
|
|
517
|
-
}
|
|
518
|
-
|
|
519
|
-
private update(event: PointerEvent): void {
|
|
520
|
-
const rect = this.el.nativeElement.getBoundingClientRect();
|
|
521
|
-
if (rect.width === 0 || rect.height === 0) return;
|
|
522
|
-
const x = kjClamp((event.clientX - rect.left) / rect.width, 0, 1);
|
|
523
|
-
// Visual y=0 is value=1 (top of rectangle = brightest).
|
|
524
|
-
const y = 1 - kjClamp((event.clientY - rect.top) / rect.height, 0, 1);
|
|
525
|
-
this.ctx.setSaturationValue(x, y);
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
/** @internal */
|
|
529
|
-
onKeydown(event: Event): void {
|
|
530
|
-
if (this.ctx.disabled()) return;
|
|
531
|
-
const ke = event as KeyboardEvent;
|
|
532
|
-
const step = ke.shiftKey ? 0.1 : 0.01;
|
|
533
|
-
let s = this.ctx.saturation();
|
|
534
|
-
let v = this.ctx.value();
|
|
535
|
-
let handled = true;
|
|
536
|
-
switch (ke.key) {
|
|
537
|
-
case 'ArrowRight': s = kjClamp(s + step, 0, 1); break;
|
|
538
|
-
case 'ArrowLeft': s = kjClamp(s - step, 0, 1); break;
|
|
539
|
-
case 'ArrowUp': v = kjClamp(v + step, 0, 1); break;
|
|
540
|
-
case 'ArrowDown': v = kjClamp(v - step, 0, 1); break;
|
|
541
|
-
case 'Home': s = 0; break;
|
|
542
|
-
case 'End': s = 1; break;
|
|
543
|
-
case 'PageUp': v = 1; break;
|
|
544
|
-
case 'PageDown': v = 0; break;
|
|
545
|
-
default: handled = false;
|
|
546
|
-
}
|
|
547
|
-
if (handled) {
|
|
548
|
-
event.preventDefault();
|
|
549
|
-
this.ctx.setSaturationValue(s, v);
|
|
550
|
-
}
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
/**
|
|
555
|
-
* Hue slider. Renders as a native `<input type="range">` so screen
|
|
556
|
-
* readers and keyboard users get the standard `role="slider"` model
|
|
557
|
-
* for free; the visual track gradient is rendered via the wrapper
|
|
558
|
-
* stylesheet.
|
|
559
|
-
*
|
|
560
|
-
* @doc-category Core/Inputs
|
|
561
|
-
* @doc
|
|
562
|
-
* @doc-name color-picker
|
|
563
|
-
*/
|
|
564
|
-
@Directive({
|
|
565
|
-
selector: 'input[kjColorPickerHueSlider]',
|
|
566
|
-
standalone: true,
|
|
567
|
-
hostDirectives: [KjFocusRing],
|
|
568
|
-
host: {
|
|
569
|
-
'type': 'range',
|
|
570
|
-
'min': '0',
|
|
571
|
-
'max': '360',
|
|
572
|
-
'step': '1',
|
|
573
|
-
'[attr.aria-label]': '"Hue"',
|
|
574
|
-
'[attr.aria-valuetext]': 'ariaValueText()',
|
|
575
|
-
'[attr.aria-disabled]': 'ctx.disabled() ? "true" : null',
|
|
576
|
-
'[disabled]': 'ctx.disabled() || null',
|
|
577
|
-
'[value]': 'Math.round(ctx.hue())',
|
|
578
|
-
'(input)': 'onInput($event)',
|
|
579
|
-
},
|
|
580
|
-
})
|
|
581
|
-
export class KjColorPickerHueSlider {
|
|
582
|
-
/** @internal */
|
|
583
|
-
readonly ctx = inject(KJ_COLOR_PICKER);
|
|
584
|
-
/** @internal */
|
|
585
|
-
protected readonly Math = Math;
|
|
586
|
-
/** @internal */
|
|
587
|
-
readonly ariaValueText = computed(() => `Hue ${Math.round(this.ctx.hue())} degrees`);
|
|
588
|
-
|
|
589
|
-
/** @internal */
|
|
590
|
-
onInput(event: Event): void {
|
|
591
|
-
const v = Number((event.target as HTMLInputElement).value);
|
|
592
|
-
if (Number.isFinite(v)) this.ctx.setHue(v);
|
|
593
|
-
}
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
/**
|
|
597
|
-
* Optional alpha slider. Mounts only when `KjColorPicker.kjShowAlpha`
|
|
598
|
-
* is true; otherwise the wrapper hides it. Like the hue slider it
|
|
599
|
-
* delegates to a native range input for AT support.
|
|
600
|
-
*
|
|
601
|
-
* @doc-category Core/Inputs
|
|
602
|
-
* @doc
|
|
603
|
-
* @doc-name color-picker
|
|
604
|
-
*/
|
|
605
|
-
@Directive({
|
|
606
|
-
selector: 'input[kjColorPickerAlphaSlider]',
|
|
607
|
-
standalone: true,
|
|
608
|
-
hostDirectives: [KjFocusRing],
|
|
609
|
-
host: {
|
|
610
|
-
'type': 'range',
|
|
611
|
-
'min': '0',
|
|
612
|
-
'max': '100',
|
|
613
|
-
'step': '1',
|
|
614
|
-
'[attr.aria-label]': '"Opacity"',
|
|
615
|
-
'[attr.aria-valuetext]': 'ariaValueText()',
|
|
616
|
-
'[attr.aria-disabled]': 'ctx.disabled() ? "true" : null',
|
|
617
|
-
'[disabled]': 'ctx.disabled() || !ctx.showAlpha() || null',
|
|
618
|
-
'[value]': 'Math.round(ctx.alpha() * 100)',
|
|
619
|
-
'(input)': 'onInput($event)',
|
|
620
|
-
},
|
|
621
|
-
})
|
|
622
|
-
export class KjColorPickerAlphaSlider {
|
|
623
|
-
/** @internal */
|
|
624
|
-
readonly ctx = inject(KJ_COLOR_PICKER);
|
|
625
|
-
/** @internal */
|
|
626
|
-
protected readonly Math = Math;
|
|
627
|
-
/** @internal */
|
|
628
|
-
readonly ariaValueText = computed(() =>
|
|
629
|
-
`Opacity ${Math.round(this.ctx.alpha() * 100)} percent`);
|
|
630
|
-
|
|
631
|
-
/** @internal */
|
|
632
|
-
onInput(event: Event): void {
|
|
633
|
-
const pct = Number((event.target as HTMLInputElement).value);
|
|
634
|
-
if (Number.isFinite(pct)) this.ctx.setAlpha(pct / 100);
|
|
635
|
-
}
|
|
636
|
-
}
|
|
637
|
-
|
|
638
|
-
/**
|
|
639
|
-
* Hex / CSS-color text input. Commits on blur or Enter; reverts to the
|
|
640
|
-
* canonical value on parse failure. Pattern attribute restricts to
|
|
641
|
-
* 3 / 4 / 6 / 8 hex digits with optional leading hash.
|
|
642
|
-
*
|
|
643
|
-
* @doc-category Core/Inputs
|
|
644
|
-
* @doc
|
|
645
|
-
* @doc-name color-picker
|
|
646
|
-
*/
|
|
647
|
-
@Directive({
|
|
648
|
-
selector: 'input[kjColorPickerInput]',
|
|
649
|
-
standalone: true,
|
|
650
|
-
hostDirectives: [KjFocusRing],
|
|
651
|
-
host: {
|
|
652
|
-
'type': 'text',
|
|
653
|
-
'autocomplete': 'off',
|
|
654
|
-
'autocapitalize': 'off',
|
|
655
|
-
'spellcheck': 'false',
|
|
656
|
-
'pattern': '^#?[0-9a-fA-F]{3,8}$',
|
|
657
|
-
'[attr.aria-label]': '"Hex color value"',
|
|
658
|
-
'[attr.aria-invalid]': 'invalid() ? "true" : null',
|
|
659
|
-
'[attr.aria-disabled]': 'ctx.disabled() ? "true" : null',
|
|
660
|
-
'[disabled]': 'ctx.disabled() || null',
|
|
661
|
-
'[value]': 'displayValue()',
|
|
662
|
-
'(blur)': 'commit($event)',
|
|
663
|
-
'(keydown.enter)': 'commit($event)',
|
|
664
|
-
'(input)': 'onInput($event)',
|
|
665
|
-
},
|
|
666
|
-
})
|
|
667
|
-
export class KjColorPickerInput {
|
|
668
|
-
/** @internal */
|
|
669
|
-
readonly ctx = inject(KJ_COLOR_PICKER);
|
|
670
|
-
|
|
671
|
-
private readonly _draft = signal<string | null>(null);
|
|
672
|
-
private readonly _invalid = signal(false);
|
|
673
|
-
|
|
674
|
-
/** @internal */
|
|
675
|
-
readonly invalid = this._invalid.asReadonly();
|
|
676
|
-
/** @internal */
|
|
677
|
-
readonly displayValue = computed(() => this._draft() ?? this.ctx.hex());
|
|
678
|
-
|
|
679
|
-
/** @internal */
|
|
680
|
-
onInput(event: Event): void {
|
|
681
|
-
this._draft.set((event.target as HTMLInputElement).value);
|
|
682
|
-
}
|
|
683
|
-
|
|
684
|
-
/** @internal */
|
|
685
|
-
commit(event: Event): void {
|
|
686
|
-
const draft = this._draft();
|
|
687
|
-
if (draft == null) return;
|
|
688
|
-
const ok = this.ctx.setHex(draft);
|
|
689
|
-
this._invalid.set(!ok);
|
|
690
|
-
if (ok) {
|
|
691
|
-
this._draft.set(null);
|
|
692
|
-
} else if (event.type === 'blur') {
|
|
693
|
-
// Revert on blur if invalid.
|
|
694
|
-
this._draft.set(null);
|
|
695
|
-
this._invalid.set(false);
|
|
696
|
-
}
|
|
697
|
-
}
|
|
698
|
-
}
|