@konce-pt/react 0.12.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +122 -64
- package/dist/accordion/accordion.d.ts +14 -6
- package/dist/accordion/accordion.js +14 -7
- package/dist/accordion/llms.txt +22 -10
- package/dist/alert/alert.d.ts +2 -2
- package/dist/alert/alert.js +2 -2
- package/dist/alert/llms.txt +10 -10
- package/dist/app-shell/app-shell.d.ts +14 -14
- package/dist/app-shell/app-shell.js +11 -11
- package/dist/app-shell/llms.txt +13 -13
- package/dist/auth/auth-types.d.ts +6 -6
- package/dist/auth/auth.d.ts +2 -2
- package/dist/auth/auth.js +7 -7
- package/dist/auth/llms.txt +9 -9
- package/dist/autocomplete/autocomplete.d.ts +19 -6
- package/dist/autocomplete/autocomplete.js +23 -10
- package/dist/autocomplete/llms.txt +16 -5
- package/dist/avatar/avatar.d.ts +6 -6
- package/dist/avatar/avatar.js +5 -5
- package/dist/avatar/llms.txt +10 -10
- package/dist/avatar-group/avatar-group.d.ts +4 -4
- package/dist/avatar-group/avatar-group.js +3 -3
- package/dist/avatar-group/llms.txt +8 -8
- package/dist/backdrop/backdrop.d.ts +7 -7
- package/dist/backdrop/backdrop.js +16 -16
- package/dist/backdrop/llms.txt +27 -27
- package/dist/badge/badge.d.ts +3 -3
- package/dist/badge/badge.js +1 -1
- package/dist/badge/llms.txt +11 -11
- package/dist/bottom-sheet/bottom-sheet.d.ts +4 -4
- package/dist/bottom-sheet/bottom-sheet.js +2 -2
- package/dist/bottom-sheet/llms.txt +9 -9
- package/dist/breadcrumb/breadcrumb.d.ts +2 -2
- package/dist/breadcrumb/breadcrumb.js +3 -3
- package/dist/breadcrumb/llms.txt +3 -3
- package/dist/button/button.d.ts +3 -3
- package/dist/button/button.js +8 -8
- package/dist/button/llms.txt +27 -19
- package/dist/button-group/button-group.d.ts +9 -9
- package/dist/button-group/button-group.js +30 -8
- package/dist/button-group/llms.txt +20 -14
- package/dist/card/card.d.ts +8 -8
- package/dist/card/card.js +6 -6
- package/dist/card/llms.txt +20 -20
- package/dist/carousel/carousel.d.ts +6 -6
- package/dist/carousel/carousel.js +4 -4
- package/dist/carousel/llms.txt +10 -10
- package/dist/charts/chart-legend.d.ts +3 -3
- package/dist/charts/chart-legend.js +1 -1
- package/dist/charts/chart-tooltip.d.ts +3 -3
- package/dist/charts/chart-tooltip.js +1 -1
- package/dist/charts/chart.d.ts +1 -1
- package/dist/charts/chart.js +8 -8
- package/dist/charts/llms.txt +6 -6
- package/dist/charts-entry/public-api.js +2 -2
- package/dist/chat/chat.d.ts +17 -10
- package/dist/chat/chat.js +42 -18
- package/dist/chat/llms.txt +32 -17
- package/dist/chat-composer/chat-composer.d.ts +17 -7
- package/dist/chat-composer/chat-composer.js +21 -8
- package/dist/chat-composer/llms.txt +20 -11
- package/dist/chat-dock/chat-dock.d.ts +11 -4
- package/dist/chat-dock/chat-dock.js +9 -6
- package/dist/chat-dock/llms.txt +15 -14
- package/dist/chat-entry/public-api.js +1 -1
- package/dist/chat-message/chat-message.d.ts +12 -5
- package/dist/chat-message/chat-message.js +17 -7
- package/dist/chat-message/llms.txt +16 -15
- package/dist/chat-typing/chat-typing.d.ts +2 -2
- package/dist/chat-typing/chat-typing.js +3 -3
- package/dist/chat-typing/llms.txt +6 -6
- package/dist/checkbox/checkbox.d.ts +13 -6
- package/dist/checkbox/checkbox.js +26 -7
- package/dist/checkbox/llms.txt +24 -12
- package/dist/chip/chip.d.ts +4 -4
- package/dist/chip/chip.js +2 -2
- package/dist/chip/llms.txt +11 -11
- package/dist/chips-input/chips-input.d.ts +4 -4
- package/dist/chips-input/chips-input.js +35 -9
- package/dist/chips-input/llms.txt +15 -8
- package/dist/clock/clock.d.ts +4 -4
- package/dist/clock/clock.js +7 -7
- package/dist/clock/llms.txt +8 -8
- package/dist/color-picker/color-picker.d.ts +6 -6
- package/dist/color-picker/color-picker.js +3 -3
- package/dist/color-picker/llms.txt +5 -5
- package/dist/confirm/confirm-container.d.ts +3 -3
- package/dist/confirm/confirm-container.js +5 -5
- package/dist/confirm/confirm-store.d.ts +4 -4
- package/dist/confirm/confirm-store.js +7 -7
- package/dist/confirm/llms.txt +6 -6
- package/dist/context-menu/context-menu.d.ts +1 -1
- package/dist/context-menu/context-menu.js +5 -5
- package/dist/context-menu/llms.txt +7 -7
- package/dist/data-table/data-table-types.d.ts +5 -5
- package/dist/data-table/data-table.d.ts +29 -8
- package/dist/data-table/data-table.js +340 -95
- package/dist/data-table/export-csv.d.ts +3 -3
- package/dist/data-table/export-csv.js +4 -4
- package/dist/data-table/llms.txt +127 -94
- package/dist/data-view/data-view.d.ts +13 -5
- package/dist/data-view/data-view.js +67 -6
- package/dist/data-view/llms.txt +29 -10
- package/dist/date-range/date-range.d.ts +9 -9
- package/dist/date-range/date-range.js +24 -24
- package/dist/date-range/llms.txt +20 -20
- package/dist/datepicker/datepicker.d.ts +10 -10
- package/dist/datepicker/datepicker.js +29 -29
- package/dist/datepicker/llms.txt +24 -24
- package/dist/dialog/dialog.d.ts +4 -4
- package/dist/dialog/dialog.js +4 -4
- package/dist/dialog/llms.txt +11 -11
- package/dist/divider/divider.d.ts +1 -1
- package/dist/divider/llms.txt +4 -4
- package/dist/drawer/drawer.d.ts +5 -5
- package/dist/drawer/drawer.js +2 -2
- package/dist/drawer/llms.txt +11 -11
- package/dist/empty/empty.d.ts +2 -2
- package/dist/empty/empty.js +1 -1
- package/dist/empty/llms.txt +9 -9
- package/dist/fab/fab.d.ts +1 -1
- package/dist/fab/fab.js +1 -1
- package/dist/fab/llms.txt +10 -6
- package/dist/fieldset/fieldset.d.ts +18 -4
- package/dist/fieldset/fieldset.js +9 -6
- package/dist/fieldset/llms.txt +26 -9
- package/dist/file-upload/file-upload.d.ts +3 -3
- package/dist/file-upload/file-upload.js +7 -7
- package/dist/file-upload/llms.txt +7 -7
- package/dist/form-field/form-field-context.d.ts +4 -4
- package/dist/form-field/form-field.d.ts +12 -4
- package/dist/form-field/form-field.js +26 -6
- package/dist/form-field/llms.txt +25 -11
- package/dist/galleria/galleria.d.ts +3 -3
- package/dist/galleria/galleria.js +5 -5
- package/dist/galleria/llms.txt +7 -7
- package/dist/grid/col.d.ts +4 -4
- package/dist/grid/col.js +2 -2
- package/dist/grid/flex.d.ts +3 -3
- package/dist/grid/flex.js +1 -1
- package/dist/grid/grid.d.ts +7 -7
- package/dist/grid/grid.js +3 -3
- package/dist/grid/layout.d.ts +2 -2
- package/dist/grid/layout.js +2 -2
- package/dist/grid/llms.txt +15 -15
- package/dist/grid-entry/public-api.js +1 -1
- package/dist/i18n/i18n-context.d.ts +3 -3
- package/dist/i18n/i18n-context.js +7 -7
- package/dist/icon/icon-registry.d.ts +3 -3
- package/dist/icon/icon-registry.js +3 -3
- package/dist/icon/icon.d.ts +4 -4
- package/dist/icon/icon.js +6 -6
- package/dist/icon/llms.txt +13 -13
- package/dist/icon-button/icon-button.d.ts +2 -2
- package/dist/icon-button/icon-button.js +1 -1
- package/dist/icon-button/llms.txt +9 -5
- package/dist/icons-entry/public-api.d.ts +2 -2
- package/dist/icons-entry/public-api.js +3 -3
- package/dist/image/image.js +1 -1
- package/dist/image/llms.txt +13 -13
- package/dist/input/input.d.ts +18 -5
- package/dist/input/input.js +21 -6
- package/dist/input/llms.txt +25 -11
- package/dist/input-mask/input-mask.d.ts +1 -1
- package/dist/input-mask/input-mask.js +2 -2
- package/dist/input-mask/llms.txt +5 -5
- package/dist/input-number/input-number.d.ts +9 -9
- package/dist/input-number/input-number.js +11 -11
- package/dist/input-number/llms.txt +14 -14
- package/dist/input-otp/input-otp.d.ts +6 -6
- package/dist/input-otp/input-otp.js +10 -10
- package/dist/input-otp/llms.txt +9 -9
- package/dist/internal/calendar-focus.d.ts +1 -1
- package/dist/internal/calendar-focus.js +3 -3
- package/dist/internal/cn.d.ts +1 -1
- package/dist/internal/mask.d.ts +2 -2
- package/dist/internal/mask.js +4 -4
- package/dist/internal/option-key.d.ts +2 -2
- package/dist/internal/option-key.js +2 -2
- package/dist/internal/option-nav.d.ts +4 -4
- package/dist/internal/option-nav.js +5 -5
- package/dist/internal/overlay-container.js +1 -1
- package/dist/internal/overlay.d.ts +3 -3
- package/dist/internal/overlay.js +8 -8
- package/dist/internal/password-strength.d.ts +2 -2
- package/dist/internal/password-strength.js +6 -6
- package/dist/internal/roving.d.ts +2 -2
- package/dist/internal/roving.js +3 -3
- package/dist/internal/scroll-lock.d.ts +1 -1
- package/dist/internal/scroll-lock.js +2 -2
- package/dist/internal/slot-children.d.ts +3 -3
- package/dist/internal/slot-children.js +4 -4
- package/dist/internal/slot.d.ts +3 -3
- package/dist/internal/slot.js +2 -2
- package/dist/internal/step.d.ts +3 -3
- package/dist/internal/step.js +4 -4
- package/dist/internal/tween.d.ts +5 -5
- package/dist/internal/tween.js +5 -5
- package/dist/internal/types.d.ts +2 -2
- package/dist/internal/use-breakpoint.d.ts +2 -2
- package/dist/internal/use-breakpoint.js +4 -4
- package/dist/internal/use-controllable-state.d.ts +1 -1
- package/dist/internal/use-controllable-state.js +3 -3
- package/dist/internal/use-id.d.ts +2 -2
- package/dist/internal/use-id.js +2 -2
- package/dist/internal/use-modal-focus.d.ts +1 -1
- package/dist/internal/use-modal-focus.js +3 -3
- package/dist/knob/knob.d.ts +4 -4
- package/dist/knob/knob.js +14 -10
- package/dist/knob/llms.txt +17 -12
- package/dist/listbox/listbox.d.ts +6 -6
- package/dist/listbox/listbox.js +9 -9
- package/dist/listbox/llms.txt +10 -10
- package/dist/loader/llms.txt +56 -0
- package/dist/loader/loader.d.ts +49 -0
- package/dist/loader/loader.js +68 -0
- package/dist/map/llms.txt +25 -22
- package/dist/map/map-create-dialog.d.ts +4 -4
- package/dist/map/map-create-dialog.js +10 -10
- package/dist/map/map-hours-field.d.ts +4 -4
- package/dist/map/map-hours-field.js +7 -7
- package/dist/map/map-image-field.d.ts +2 -2
- package/dist/map/map-image-field.js +4 -4
- package/dist/map/map-legend.d.ts +4 -4
- package/dist/map/map-legend.js +2 -2
- package/dist/map/map-poi-card.d.ts +3 -3
- package/dist/map/map-poi-card.js +9 -9
- package/dist/map/map-search.d.ts +17 -6
- package/dist/map/map-search.js +21 -18
- package/dist/map/map.d.ts +21 -14
- package/dist/map/map.js +30 -29
- package/dist/map/ports.d.ts +9 -9
- package/dist/map/ports.js +6 -6
- package/dist/map-entry/public-api.js +2 -2
- package/dist/megamenu/llms.txt +9 -9
- package/dist/megamenu/megamenu.d.ts +6 -6
- package/dist/megamenu/megamenu.js +10 -10
- package/dist/mention/llms.txt +15 -15
- package/dist/mention/mention.d.ts +5 -5
- package/dist/mention/mention.js +2 -2
- package/dist/mention/mentions.d.ts +1 -1
- package/dist/mention/mentions.js +1 -1
- package/dist/menu/llms.txt +12 -12
- package/dist/menu/menu-item.d.ts +4 -4
- package/dist/menu/menu-keys.d.ts +2 -2
- package/dist/menu/menu-keys.js +5 -5
- package/dist/menu/menu.d.ts +2 -2
- package/dist/menu/menu.js +6 -6
- package/dist/menubar/llms.txt +10 -10
- package/dist/menubar/menubar.d.ts +5 -5
- package/dist/menubar/menubar.js +10 -10
- package/dist/meter-group/llms.txt +12 -12
- package/dist/meter-group/meter-group.d.ts +2 -2
- package/dist/meter-group/meter-group.js +1 -1
- package/dist/motion/motion-context.d.ts +22 -0
- package/dist/motion/motion-context.js +28 -0
- package/dist/order-list/llms.txt +22 -10
- package/dist/order-list/order-list.d.ts +12 -4
- package/dist/order-list/order-list.js +104 -21
- package/dist/paginator/llms.txt +8 -8
- package/dist/paginator/paginator.js +1 -1
- package/dist/panel/llms.txt +25 -13
- package/dist/panel/panel.d.ts +11 -3
- package/dist/panel/panel.js +7 -4
- package/dist/password/llms.txt +16 -8
- package/dist/password/password.d.ts +2 -2
- package/dist/password/password.js +24 -3
- package/dist/peek/llms.txt +10 -10
- package/dist/peek/peek.d.ts +6 -6
- package/dist/peek/peek.js +7 -7
- package/dist/pick-list/llms.txt +33 -13
- package/dist/pick-list/pick-list.d.ts +12 -4
- package/dist/pick-list/pick-list.js +111 -23
- package/dist/popover/llms.txt +11 -11
- package/dist/popover/popover.d.ts +4 -4
- package/dist/popover/popover.js +5 -5
- package/dist/progress/llms.txt +17 -17
- package/dist/progress/progress.d.ts +7 -7
- package/dist/progress/progress.js +6 -6
- package/dist/public-api.d.ts +15 -3
- package/dist/public-api.js +13 -7
- package/dist/radio-group/llms.txt +13 -6
- package/dist/radio-group/radio-group.d.ts +11 -4
- package/dist/radio-group/radio-group.js +15 -7
- package/dist/rating/llms.txt +20 -13
- package/dist/rating/rating-pointer.d.ts +16 -0
- package/dist/rating/rating-pointer.js +26 -0
- package/dist/rating/rating.d.ts +6 -6
- package/dist/rating/rating.js +76 -12
- package/dist/rich-text/lists.d.ts +2 -2
- package/dist/rich-text/lists.js +7 -7
- package/dist/rich-text/llms.txt +26 -17
- package/dist/rich-text/rich-text.d.ts +12 -7
- package/dist/rich-text/rich-text.js +78 -54
- package/dist/rich-text/sanitize.d.ts +3 -3
- package/dist/rich-text/sanitize.js +12 -12
- package/dist/rich-text/tables.d.ts +3 -3
- package/dist/rich-text/tables.js +3 -3
- package/dist/roadmap/llms.txt +15 -15
- package/dist/roadmap/roadmap.d.ts +6 -6
- package/dist/roadmap/roadmap.js +19 -19
- package/dist/roadmap-entry/public-api.js +2 -2
- package/dist/scroll-top/llms.txt +6 -6
- package/dist/scroll-top/scroll-top.d.ts +1 -1
- package/dist/scroll-top/scroll-top.js +1 -1
- package/dist/select/llms.txt +19 -12
- package/dist/select/select.d.ts +8 -8
- package/dist/select/select.js +47 -21
- package/dist/shared/types.d.ts +5 -5
- package/dist/shared/types.js +1 -1
- package/dist/sidenav/llms.txt +9 -9
- package/dist/sidenav/sidenav.d.ts +1 -1
- package/dist/sidenav/sidenav.js +1 -1
- package/dist/skeleton/llms.txt +3 -3
- package/dist/skeleton/skeleton.d.ts +1 -1
- package/dist/skeleton/skeleton.js +1 -1
- package/dist/slider/llms.txt +32 -13
- package/dist/slider/slider-drag.d.ts +26 -0
- package/dist/slider/slider-drag.js +79 -0
- package/dist/slider/slider.d.ts +6 -5
- package/dist/slider/slider.js +27 -8
- package/dist/speech/llms.txt +97 -0
- package/dist/speech/speech-button.d.ts +44 -0
- package/dist/speech/speech-button.js +86 -0
- package/dist/speech/speech-wave.d.ts +19 -0
- package/dist/speech/speech-wave.js +16 -0
- package/dist/speech/use-speech-recognition.d.ts +81 -0
- package/dist/speech/use-speech-recognition.js +179 -0
- package/dist/speed-dial/llms.txt +14 -8
- package/dist/speed-dial/speed-dial.d.ts +1 -1
- package/dist/speed-dial/speed-dial.js +1 -1
- package/dist/spinner/llms.txt +7 -7
- package/dist/spinner/spinner.d.ts +1 -1
- package/dist/spinner/spinner.js +1 -1
- package/dist/split-button/llms.txt +21 -15
- package/dist/split-button/split-button.d.ts +2 -2
- package/dist/split-button/split-button.js +4 -4
- package/dist/splitter/llms.txt +11 -11
- package/dist/splitter/splitter.d.ts +3 -3
- package/dist/splitter/splitter.js +5 -5
- package/dist/stepper/llms.txt +33 -14
- package/dist/stepper/stepper.d.ts +6 -6
- package/dist/stepper/stepper.js +53 -10
- package/dist/switch/llms.txt +12 -5
- package/dist/switch/switch.d.ts +10 -3
- package/dist/switch/switch.js +12 -5
- package/dist/switch-group/llms.txt +9 -9
- package/dist/switch-group/switch-group.d.ts +4 -4
- package/dist/switch-group/switch-group.js +4 -4
- package/dist/tabs/llms.txt +10 -10
- package/dist/tabs/tabs.d.ts +5 -5
- package/dist/tabs/tabs.js +8 -8
- package/dist/textarea/llms.txt +23 -12
- package/dist/textarea/textarea.d.ts +19 -6
- package/dist/textarea/textarea.js +21 -7
- package/dist/timeline/llms.txt +4 -4
- package/dist/timeline/timeline.d.ts +1 -1
- package/dist/timeline/timeline.js +1 -1
- package/dist/toast/llms.txt +47 -17
- package/dist/toast/toast-container.d.ts +9 -3
- package/dist/toast/toast-container.js +17 -9
- package/dist/toast/toast-store.d.ts +40 -4
- package/dist/toast/toast-store.js +36 -1
- package/dist/toolbar/llms.txt +7 -7
- package/dist/toolbar/toolbar.d.ts +3 -3
- package/dist/toolbar/toolbar.js +2 -2
- package/dist/tooltip/llms.txt +10 -10
- package/dist/tooltip/tooltip.d.ts +3 -3
- package/dist/tooltip/tooltip.js +18 -18
- package/dist/tree/llms.txt +25 -12
- package/dist/tree/tree-keys.d.ts +5 -5
- package/dist/tree/tree-keys.js +7 -7
- package/dist/tree/tree.d.ts +14 -7
- package/dist/tree/tree.js +53 -18
- package/dist/update/llms.txt +54 -0
- package/dist/update/update.d.ts +49 -0
- package/dist/update/update.js +82 -0
- package/package.json +15 -13
package/dist/public-api.js
CHANGED
|
@@ -1,27 +1,29 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* @konce-pt/react
|
|
2
|
+
* @konce-pt/react - publiczne API.
|
|
3
3
|
*
|
|
4
4
|
* Komponenty renderują te same klasy `kpt-*` i te same tokeny `--kpt-*`, co port
|
|
5
5
|
* Angulara; warstwa CSS (`@konce-pt/styles`, `@konce-pt/grid`, `@konce-pt/tokens`)
|
|
6
6
|
* jest wspólna i nie ma tu własnych stylów.
|
|
7
7
|
*/
|
|
8
|
-
// Komponenty
|
|
8
|
+
// Komponenty - układ
|
|
9
9
|
export { KptAppShell, KptNavLabel, KptNavSection, useKptAppShell, useKptShellNavToggle } from "./app-shell/app-shell.js";
|
|
10
10
|
export { KptToolbar, KptToolbarSpacer } from "./toolbar/toolbar.js";
|
|
11
11
|
export { KptSidenav, KptSidenavFooter } from "./sidenav/sidenav.js";
|
|
12
|
-
// Komponenty
|
|
12
|
+
// Komponenty - panele
|
|
13
13
|
export { KptTabs, KptTab } from "./tabs/tabs.js";
|
|
14
14
|
export { KptAccordion, KptAccordionPanel } from "./accordion/accordion.js";
|
|
15
15
|
export { KptPanel, KptPanelActions } from "./panel/panel.js";
|
|
16
16
|
export { KptStepper, KptStep, useKptStepper } from "./stepper/stepper.js";
|
|
17
17
|
export { KptFieldset } from "./fieldset/fieldset.js";
|
|
18
18
|
export { KptTimeline } from "./timeline/timeline.js";
|
|
19
|
-
// Komponenty
|
|
19
|
+
// Komponenty - prezentacja
|
|
20
20
|
export { KptAlert } from "./alert/alert.js";
|
|
21
21
|
export { KptDivider } from "./divider/divider.js";
|
|
22
22
|
export { KptEmpty } from "./empty/empty.js";
|
|
23
23
|
export { KptProgress } from "./progress/progress.js";
|
|
24
24
|
export { KptSpinner } from "./spinner/spinner.js";
|
|
25
|
+
export { KptLoader } from "./loader/loader.js";
|
|
26
|
+
export { KptUpdate } from "./update/update.js";
|
|
25
27
|
export { KptSkeleton } from "./skeleton/skeleton.js";
|
|
26
28
|
export { KptIcon } from "./icon/icon.js";
|
|
27
29
|
export { getKptIcon, hasKptIcon, registerKptIcons } from "./icon/icon-registry.js";
|
|
@@ -30,7 +32,7 @@ export { KptBadge } from "./badge/badge.js";
|
|
|
30
32
|
export { KptBackdrop } from "./backdrop/backdrop.js";
|
|
31
33
|
export { KPT_SIGNAL_GRID_CELL, KPT_SIGNAL_GRID_DENSITY, KPT_SIGNAL_GRID_FALLOFF, KPT_SIGNAL_GRID_GAP, KPT_WAVE_AMPLITUDE, KPT_WAVE_BAND, KPT_WAVE_RESOLUTION, KPT_WAVE_ROTATION, buildSignalGrid, createBackdropRenderer, mixOklch, readCssColor, resolveWave, shiftHue, signalGridAlpha, signalGridDensity, waveIntensity, waveRamp, } from '@konce-pt/backdrop';
|
|
32
34
|
export { KptChip } from "./chip/chip.js";
|
|
33
|
-
// Komponenty
|
|
35
|
+
// Komponenty - nakładki
|
|
34
36
|
export { KptDialog, KptDialogFooter } from "./dialog/dialog.js";
|
|
35
37
|
export { KptDrawer } from "./drawer/drawer.js";
|
|
36
38
|
export { KptBottomSheet } from "./bottom-sheet/bottom-sheet.js";
|
|
@@ -54,7 +56,7 @@ export { KPT_AUTH_MIN_PASSWORD } from "./auth/auth-types.js";
|
|
|
54
56
|
export { KptConfirmContainer } from "./confirm/confirm-container.js";
|
|
55
57
|
export { kptConfirm, useKptConfirmRequest } from "./confirm/confirm-store.js";
|
|
56
58
|
export { KptToastContainer } from "./toast/toast-container.js";
|
|
57
|
-
export { kptToast, useKptToasts } from "./toast/toast-store.js";
|
|
59
|
+
export { kptToast, useKptToasts, useKptToastsPaused, resolveKptToast, KPT_TOAST_FALLBACK_DURATION } from "./toast/toast-store.js";
|
|
58
60
|
export { KptMenu } from "./menu/menu.js";
|
|
59
61
|
export { KptMenubar } from "./menubar/menubar.js";
|
|
60
62
|
export { KptMegamenu } from "./megamenu/megamenu.js";
|
|
@@ -67,7 +69,7 @@ export { KptMention } from "./mention/mention.js";
|
|
|
67
69
|
export { KptMentions } from "./mention/mentions.js";
|
|
68
70
|
export { KPT_MENTION_LIMIT, applyMention, collectMentions, filterMentions, foldMentionText, mentionQuery, mentionToken, parseMentionText, } from '@konce-pt/mention';
|
|
69
71
|
export { KptOverlay } from "./internal/overlay.js";
|
|
70
|
-
// Komponenty
|
|
72
|
+
// Komponenty - formularze
|
|
71
73
|
export { KptButtonGroup } from "./button-group/button-group.js";
|
|
72
74
|
export { KptSelect } from "./select/select.js";
|
|
73
75
|
export { KptFormField } from "./form-field/form-field.js";
|
|
@@ -97,6 +99,10 @@ export { KptPaginator } from "./paginator/paginator.js";
|
|
|
97
99
|
// Komponenty
|
|
98
100
|
export { KptButton } from "./button/button.js";
|
|
99
101
|
export { KptIconButton } from "./icon-button/icon-button.js";
|
|
102
|
+
export { KptSpeechButton } from "./speech/speech-button.js";
|
|
103
|
+
export { KptSpeechWave } from "./speech/speech-wave.js";
|
|
104
|
+
export { useKptSpeechRecognition } from "./speech/use-speech-recognition.js";
|
|
105
|
+
export { defaultSpeechLang, resolveSpeechTarget, speechSupport } from '@konce-pt/speech';
|
|
100
106
|
export { KptFab } from "./fab/fab.js";
|
|
101
107
|
export { KptSplitButton } from "./split-button/split-button.js";
|
|
102
108
|
export { KptCard, KptCardActions, KptCardFooter, KptCardHeader, KptCardLead, KptCardMedia, KptCardMeta, KptCardSection, KptCardSubtitle, KptCardTags, KptCardTitle, } from "./card/card.js";
|
|
@@ -15,14 +15,15 @@ Import: `import { KptRadioGroup } from '@konce-pt/react';`
|
|
|
15
15
|
</div>
|
|
16
16
|
|
|
17
17
|
## Props
|
|
18
|
-
- `options`: `KptOption<T>[]`
|
|
19
|
-
- `value` / `defaultValue` / `onValueChange`
|
|
20
|
-
- `name`: string
|
|
18
|
+
- `options`: `KptOption<T>[]` - `{ label, value, disabled? }`
|
|
19
|
+
- `value` / `defaultValue` / `onValueChange` - controlled or uncontrolled
|
|
20
|
+
- `name`: string - the form group name; omitted means one is generated
|
|
21
21
|
- `disabled`, `invalid`, `touched`, `onTouch()`
|
|
22
|
+
- `toggleMotion`: 'spring' | 'fade' | 'none' (default from `KptMotionProvider`, else `spring`) - see "Toggle motion"
|
|
22
23
|
- `className`, `ref` and every other `<div>` prop go to the host
|
|
23
24
|
|
|
24
25
|
## The shared name does the work
|
|
25
|
-
All inputs share one `name`, and that
|
|
26
|
+
All inputs share one `name`, and that - not any code in the component - is what makes the browser
|
|
26
27
|
treat them as one group: arrow keys move between them, only one can be checked, and a native form
|
|
27
28
|
submits a single value. The generated name is unique per instance, so two groups on one page never
|
|
28
29
|
interfere.
|
|
@@ -32,16 +33,22 @@ interfere.
|
|
|
32
33
|
<KptRadioGroup name="plan" options={plans} defaultValue="pro" />
|
|
33
34
|
|
|
34
35
|
## Screen reader and keyboard
|
|
35
|
-
`orientation`: 'vertical' (default) | 'horizontal'
|
|
36
|
+
`orientation`: 'vertical' (default) | 'horizontal' - options in a column or in a wrapping row; also
|
|
36
37
|
sets `aria-orientation`.
|
|
37
38
|
|
|
38
39
|
## Label and description
|
|
39
40
|
`id` goes to the focusable element, not the host; without one it comes from `KptFormField` or is
|
|
40
41
|
generated. A `div` with a role is not named by `label[for]`, so inside `KptFormField` it gets
|
|
41
42
|
`aria-labelledby` pointing at the wrapper's label (unless `ariaLabel` is set), and the hint or error
|
|
42
|
-
is added to `aria-describedby`. New: `id`, `ariaLabel` and `required` (
|
|
43
|
+
is added to `aria-describedby`. New: `id`, `ariaLabel` and `required` (-> `aria-required`) on the
|
|
43
44
|
`radiogroup`.
|
|
44
45
|
|
|
46
|
+
## Toggle motion
|
|
47
|
+
`toggleMotion`: `spring` - the dot pops in on a spring and the circle bounces; `fade` - a calm colour and mark transition; `none` - no
|
|
48
|
+
motion. The bounce is started by the change handler, so a control that is checked on load does not
|
|
49
|
+
move. With no value it takes `toggle` from `KptMotionProvider` (default `spring`); `enabled: false` and the
|
|
50
|
+
system "reduce motion" setting always win.
|
|
51
|
+
|
|
45
52
|
## Tokens
|
|
46
53
|
`--kpt-color-primary` (the checked dot), `--kpt-form-field-border`,
|
|
47
54
|
`--kpt-form-field-border-error`.
|
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
import type { ComponentPropsWithRef } from 'react';
|
|
2
2
|
import type { KptOption } from '../shared/types.ts';
|
|
3
|
+
import { type KptToggleMotion } from '@konce-pt/motion';
|
|
3
4
|
export interface KptRadioGroupProps<T> extends Omit<ComponentPropsWithRef<'div'>, 'onChange' | 'defaultValue'> {
|
|
5
|
+
/**
|
|
6
|
+
* Ruch przełączania: `spring` - kropka wskakuje na sprężynie, a pole odbija; `fade` - spokojne przejście koloru i znaku; `none` - bez ruchu.
|
|
7
|
+
* Bez wartości bierze `toggle` z `KptMotionProvider` (domyślnie `spring`); `enabled={false}` i systemowe
|
|
8
|
+
* "ogranicz ruch" wyłączają go zawsze.
|
|
9
|
+
*/
|
|
10
|
+
toggleMotion?: KptToggleMotion;
|
|
4
11
|
options?: readonly KptOption<T>[];
|
|
5
12
|
value?: T;
|
|
6
13
|
defaultValue?: T;
|
|
7
14
|
onValueChange?: (value: T) => void;
|
|
8
15
|
/** Nazwa grupy w formularzu; pominięta = generowana. */
|
|
9
16
|
name?: string;
|
|
10
|
-
/** Id elementu fokusowalnego (nie hosta); bez niego generowane, w `KptFormField`
|
|
17
|
+
/** Id elementu fokusowalnego (nie hosta); bez niego generowane, w `KptFormField` - z wrappera. */
|
|
11
18
|
id?: string;
|
|
12
19
|
/** Nazwa dostępna, gdy kontrolki nie opisuje etykieta (`<label for>` albo `KptFormField`). */
|
|
13
20
|
ariaLabel?: string | null;
|
|
@@ -16,7 +23,7 @@ export interface KptRadioGroupProps<T> extends Omit<ComponentPropsWithRef<'div'>
|
|
|
16
23
|
/** Układ opcji: pod sobą (domyślnie) albo w rzędzie, z zawijaniem. */
|
|
17
24
|
orientation?: 'vertical' | 'horizontal';
|
|
18
25
|
disabled?: boolean;
|
|
19
|
-
/** Tylko do odczytu
|
|
26
|
+
/** Tylko do odczytu - wybór widać, nie da się go zmienić (`aria-readonly`). */
|
|
20
27
|
readOnly?: boolean;
|
|
21
28
|
invalid?: boolean;
|
|
22
29
|
touched?: boolean;
|
|
@@ -25,10 +32,10 @@ export interface KptRadioGroupProps<T> extends Omit<ComponentPropsWithRef<'div'>
|
|
|
25
32
|
/**
|
|
26
33
|
* Grupa przycisków opcji (radio). Opcje przez `options`.
|
|
27
34
|
*
|
|
28
|
-
* Wszystkie pola dzielą jedną nazwę `name`
|
|
35
|
+
* Wszystkie pola dzielą jedną nazwę `name` - to ona, a nie kod komponentu, sprawia, że
|
|
29
36
|
* przeglądarka traktuje je jako jedną grupę i pozwala chodzić po niej strzałkami.
|
|
30
37
|
*
|
|
31
38
|
* @example
|
|
32
39
|
* <KptRadioGroup options={plans} value={plan} onValueChange={setPlan} />
|
|
33
40
|
*/
|
|
34
|
-
export declare function KptRadioGroup<T>({ options, value, defaultValue, onValueChange, name, id, ariaLabel, required, orientation, disabled, readOnly, invalid, touched, onTouch, className, ...rest }: Readonly<KptRadioGroupProps<T>>): import("react").JSX.Element;
|
|
41
|
+
export declare function KptRadioGroup<T>({ options, value, defaultValue, onValueChange, name, id, ariaLabel, required, orientation, disabled, readOnly, invalid, touched, onTouch, toggleMotion, className, ...rest }: Readonly<KptRadioGroupProps<T>>): import("react").JSX.Element;
|
|
@@ -5,17 +5,20 @@ import { optionKey } from "../internal/option-key.js";
|
|
|
5
5
|
import { useControllableState } from "../internal/use-controllable-state.js";
|
|
6
6
|
import { useKptId } from "../internal/use-id.js";
|
|
7
7
|
import { useKptFieldA11y } from "../form-field/form-field-context.js";
|
|
8
|
+
import { playPopMotion, resolveToggleMotion } from '@konce-pt/motion';
|
|
9
|
+
import { useKptMotion } from "../motion/motion-context.js";
|
|
8
10
|
/**
|
|
9
11
|
* Grupa przycisków opcji (radio). Opcje przez `options`.
|
|
10
12
|
*
|
|
11
|
-
* Wszystkie pola dzielą jedną nazwę `name`
|
|
13
|
+
* Wszystkie pola dzielą jedną nazwę `name` - to ona, a nie kod komponentu, sprawia, że
|
|
12
14
|
* przeglądarka traktuje je jako jedną grupę i pozwala chodzić po niej strzałkami.
|
|
13
15
|
*
|
|
14
16
|
* @example
|
|
15
17
|
* <KptRadioGroup options={plans} value={plan} onValueChange={setPlan} />
|
|
16
18
|
*/
|
|
17
|
-
export function KptRadioGroup({ options = [], value, defaultValue, onValueChange, name, id, ariaLabel = null, required = false, orientation = 'vertical', disabled = false, readOnly = false, invalid = false, touched, onTouch, className, ...rest }) {
|
|
18
|
-
|
|
19
|
+
export function KptRadioGroup({ options = [], value, defaultValue, onValueChange, name, id, ariaLabel = null, required = false, orientation = 'vertical', disabled = false, readOnly = false, invalid = false, touched, onTouch, toggleMotion, className, ...rest }) {
|
|
20
|
+
const motion = resolveToggleMotion(toggleMotion, useKptMotion());
|
|
21
|
+
/** Grupa nie dostaje nazwy z `label[for]` - stąd `aria-labelledby` na etykietę wrappera. */
|
|
19
22
|
const field = useKptFieldA11y(id, 'kpt-radio-group');
|
|
20
23
|
const groupName = useKptId(name, 'kpt-radio');
|
|
21
24
|
const [current, setCurrent] = useControllableState({
|
|
@@ -24,14 +27,19 @@ export function KptRadioGroup({ options = [], value, defaultValue, onValueChange
|
|
|
24
27
|
onChange: onValueChange,
|
|
25
28
|
});
|
|
26
29
|
const showInvalid = invalid && (touched ?? true);
|
|
27
|
-
return (_jsx("div", { className: cn('kpt-radio-group-host', className), ...rest, children: _jsx("div", { className: cn('kpt-radio-group', orientation === 'horizontal' && 'kpt-radio-group--horizontal'), role: "radiogroup", "aria-orientation": orientation, "aria-invalid": showInvalid || undefined, id: field.id, "aria-label": ariaLabel ?? undefined, "aria-labelledby": ariaLabel ? undefined : field.labelledBy, "aria-describedby": field.describedBy, "aria-required": required || undefined, "aria-readonly": readOnly || undefined,
|
|
30
|
+
return (_jsx("div", { className: cn('kpt-radio-group-host', className), ...rest, children: _jsx("div", { className: cn('kpt-radio-group', orientation === 'horizontal' && 'kpt-radio-group--horizontal'), "data-motion": motion, role: "radiogroup", "aria-orientation": orientation, "aria-invalid": showInvalid || undefined, id: field.id, "aria-label": ariaLabel ?? undefined, "aria-labelledby": ariaLabel ? undefined : field.labelledBy, "aria-describedby": field.describedBy, "aria-required": required || undefined, "aria-readonly": readOnly || undefined,
|
|
28
31
|
// Tylko do odczytu: strzałki natywnie przestawiałyby zaznaczenie.
|
|
29
32
|
onKeyDown: (event) => {
|
|
30
33
|
if (readOnly && ['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight', ' '].includes(event.key))
|
|
31
34
|
event.preventDefault();
|
|
32
|
-
}, children: options.map((option, index) => (_jsxs("label", { className: cn('kpt-radio', (disabled || option.disabled) && 'kpt-radio--disabled'), children: [_jsx("input", { type: "radio", className: "kpt-radio__input", name: groupName, checked: option.value === current, disabled: disabled || option.disabled, onChange: () => {
|
|
35
|
+
}, children: options.map((option, index) => (_jsxs("label", { className: cn('kpt-radio', (disabled || option.disabled) && 'kpt-radio--disabled'), children: [_jsx("input", { type: "radio", className: "kpt-radio__input", name: groupName, checked: option.value === current, disabled: disabled || option.disabled, onChange: (event) => {
|
|
33
36
|
// Pole kontrolowane: bez zmiany stanu React przywraca poprzednie zaznaczenie.
|
|
34
|
-
if (
|
|
35
|
-
|
|
37
|
+
if (readOnly)
|
|
38
|
+
return;
|
|
39
|
+
setCurrent(option.value);
|
|
40
|
+
// Wskoczenie po zmianie z ręki - z handlera, nie z CSS, bo reguła na `:checked` grałaby przy starcie.
|
|
41
|
+
const dot = event.currentTarget.nextElementSibling;
|
|
42
|
+
if (motion === 'spring' && dot instanceof HTMLElement)
|
|
43
|
+
playPopMotion(dot);
|
|
36
44
|
}, onBlur: () => onTouch?.() }), _jsx("span", { className: "kpt-radio__dot", "aria-hidden": "true" }), _jsx("span", { className: "kpt-radio__label", children: option.label })] }, optionKey(option.value, index)))) }) }));
|
|
37
45
|
}
|
package/dist/rating/llms.txt
CHANGED
|
@@ -5,32 +5,32 @@ Import: `import { KptRating } from '@konce-pt/react';`
|
|
|
5
5
|
|
|
6
6
|
## DOM
|
|
7
7
|
<div class="kpt-rating-host">
|
|
8
|
-
<div class="kpt-rating" role="radiogroup" aria-label="
|
|
9
|
-
<button class="kpt-rating__star is-filled" role="radio" aria-checked="false" tabindex="-1" aria-label="1 of 5"
|
|
10
|
-
|
|
8
|
+
<div class="kpt-rating" role="radiogroup" aria-label="...">
|
|
9
|
+
<button class="kpt-rating__star is-filled" role="radio" aria-checked="false" tabindex="-1" aria-label="1 of 5">...</button>
|
|
10
|
+
...count buttons...
|
|
11
11
|
</div>
|
|
12
12
|
</div>
|
|
13
13
|
|
|
14
14
|
## Props
|
|
15
|
-
- `value` / `defaultValue` / `onValueChange`
|
|
15
|
+
- `value` / `defaultValue` / `onValueChange` - the score as a number, `0` means unrated
|
|
16
16
|
- `count`: number (default 5)
|
|
17
|
-
- `allowHalf`: boolean
|
|
18
|
-
- `readOnly`: boolean
|
|
17
|
+
- `allowHalf`: boolean - half stars, the value goes in steps of 0.5
|
|
18
|
+
- `readOnly`: boolean - display only, no clicking and no hover preview
|
|
19
19
|
- `disabled`: boolean
|
|
20
|
-
- `onTouch()`
|
|
20
|
+
- `onTouch()` - when focus leaves the group
|
|
21
21
|
- `id`, `ariaLabel`, `required`, `invalid`, `touched`
|
|
22
22
|
- `className`, `ref` and every other `<div>` prop go to the host
|
|
23
23
|
|
|
24
24
|
## Clicking a lit star clears the score
|
|
25
25
|
Picking the star that already holds the value writes `0`, so a rating can be taken back without a
|
|
26
|
-
separate "clear" button
|
|
26
|
+
separate "clear" button - the same contract as the Angular port.
|
|
27
27
|
|
|
28
28
|
## Hover beats the value, but only while the pointer is there
|
|
29
29
|
The lit count comes from `hover || value`, so the row previews the score under the cursor and
|
|
30
30
|
falls back to the real value on `mouseleave`. `readOnly` and `disabled` freeze both.
|
|
31
31
|
|
|
32
32
|
## i18n
|
|
33
|
-
Each star is labelled from `rating.star` (`{value}`, `{max}`)
|
|
33
|
+
Each star is labelled from `rating.star` (`{value}`, `{max}`) - EN `1 of 5`, PL `1 z 5`. Override
|
|
34
34
|
per instance with the `locale` / `dictionary` props.
|
|
35
35
|
|
|
36
36
|
## Examples
|
|
@@ -38,19 +38,26 @@ per instance with the `locale` / `dictionary` props.
|
|
|
38
38
|
<KptRating value={4} readOnly />
|
|
39
39
|
|
|
40
40
|
## Half stars
|
|
41
|
-
`allowHalf` splits every star into two halves, each its own `role="radio"` ("3.5 of 5"
|
|
41
|
+
`allowHalf` splits every star into two halves, each its own `role="radio"` ("3.5 of 5" - the number
|
|
42
42
|
follows the page language, PL "3,5 z 5"), so the group keeps the radio pattern: clicking the left half
|
|
43
|
-
gives x.5, and the arrows step by 0.5. Read-only stars show the value rounded to a half (4.3
|
|
43
|
+
gives x.5, and the arrows step by 0.5. Read-only stars show the value rounded to a half (4.3 -> four
|
|
44
44
|
and a half stars) while the name carries the exact score ("4.3 of 5"), so an average can be shown
|
|
45
45
|
as it is.
|
|
46
46
|
|
|
47
|
+
## Pointer
|
|
48
|
+
Dragging across the stars (mouse or touch) picks a score: the preview follows the pointer and releasing
|
|
49
|
+
commits it - with `allowHalf` to the nearest half, in RTL mirrored; dragging past the first star clears
|
|
50
|
+
the score. A short press without movement stays a click (including a second click that clears the
|
|
51
|
+
score). Stars that light up pop in one after another - the motion follows `toggle` from `KptMotionProvider`
|
|
52
|
+
(`spring` only); `enabled: false` and the system "reduce motion" setting always win.
|
|
53
|
+
|
|
47
54
|
## Tokens
|
|
48
55
|
Lit stars `--kpt-color-warning`, empty ones `--kpt-color-border-strong`.
|
|
49
56
|
|
|
50
57
|
## Accessibility
|
|
51
58
|
`role="radiogroup"` named by `ariaLabel` or the `KptFormField` label; each star is
|
|
52
|
-
`role="radio"` with `aria-checked`, labelled from `rating.star` (`{value}`, `{max}`)
|
|
53
|
-
PL `1 z 5`. One Tab stop:
|
|
59
|
+
`role="radio"` with `aria-checked`, labelled from `rating.star` (`{value}`, `{max}`) - EN `1 of 5`,
|
|
60
|
+
PL `1 z 5`. One Tab stop: `ArrowRight`/`ArrowUp` raise the score by one, `ArrowLeft`/`ArrowDown` lower it (mirrored in RTL),
|
|
54
61
|
`Home`/`End` set the extremes, `Delete`/`Backspace` clear it; clicking the chosen star also clears it.
|
|
55
62
|
`readOnly` renders `role="img"` named "4 of 5" with no buttons, so a screen reader does not announce
|
|
56
63
|
a row of disabled controls. `touch` fires when focus leaves the group.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
interface StarRect {
|
|
2
|
+
left: number;
|
|
3
|
+
right: number;
|
|
4
|
+
width: number;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Ocena pod wskaźnikiem - z prostokątów gwiazdek w kolejności DOM. Lewa połowa gwiazdki to połówka
|
|
8
|
+
* oceny (z `allowHalf`), w RTL prawa. Przed pierwszą gwiazdką - 0 (przeciągnięcie wstecz kasuje
|
|
9
|
+
* ocenę), za ostatnią - maksimum. Przerwa między gwiazdkami należy do gwiazdki przed nią.
|
|
10
|
+
* Ta sama funkcja jest w porcie Angulara (`rating/rating-pointer.ts`).
|
|
11
|
+
*/
|
|
12
|
+
export declare function ratingValueAt(x: number, stars: readonly StarRect[], options: {
|
|
13
|
+
allowHalf: boolean;
|
|
14
|
+
rtl: boolean;
|
|
15
|
+
}): number;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ocena pod wskaźnikiem - z prostokątów gwiazdek w kolejności DOM. Lewa połowa gwiazdki to połówka
|
|
3
|
+
* oceny (z `allowHalf`), w RTL prawa. Przed pierwszą gwiazdką - 0 (przeciągnięcie wstecz kasuje
|
|
4
|
+
* ocenę), za ostatnią - maksimum. Przerwa między gwiazdkami należy do gwiazdki przed nią.
|
|
5
|
+
* Ta sama funkcja jest w porcie Angulara (`rating/rating-pointer.ts`).
|
|
6
|
+
*/
|
|
7
|
+
export function ratingValueAt(x, stars, options) {
|
|
8
|
+
if (!stars.length)
|
|
9
|
+
return 0;
|
|
10
|
+
// W RTL lustrzane odbicie osi - wtedy liczy się tak samo jak w LTR.
|
|
11
|
+
const flip = (r) => (options.rtl ? { left: -r.right, right: -r.left, width: r.width } : r);
|
|
12
|
+
const px = options.rtl ? -x : x;
|
|
13
|
+
const rects = stars.map(flip);
|
|
14
|
+
if (px < rects[0].left)
|
|
15
|
+
return 0;
|
|
16
|
+
for (let i = 0; i < rects.length; i++) {
|
|
17
|
+
const r = rects[i];
|
|
18
|
+
const end = i + 1 < rects.length ? rects[i + 1].left : r.right;
|
|
19
|
+
if (px >= end)
|
|
20
|
+
continue;
|
|
21
|
+
if (!options.allowHalf)
|
|
22
|
+
return i + 1;
|
|
23
|
+
return (px - r.left) / r.width < 0.5 ? i + 0.5 : i + 1;
|
|
24
|
+
}
|
|
25
|
+
return rects.length;
|
|
26
|
+
}
|
package/dist/rating/rating.d.ts
CHANGED
|
@@ -8,9 +8,9 @@ export interface KptRatingProps extends Omit<ComponentPropsWithRef<'div'>, 'onCh
|
|
|
8
8
|
count?: number;
|
|
9
9
|
/** Połówki gwiazdek: wartość co 0,5, każda połówka to osobne `radio`. */
|
|
10
10
|
allowHalf?: boolean;
|
|
11
|
-
/** Ocena tylko do odczytu
|
|
11
|
+
/** Ocena tylko do odczytu - bez klikania i bez podglądu pod kursorem. */
|
|
12
12
|
readOnly?: boolean;
|
|
13
|
-
/** Id grupy (nie hosta); bez niego generowane, w `KptFormField`
|
|
13
|
+
/** Id grupy (nie hosta); bez niego generowane, w `KptFormField` - z wrappera. */
|
|
14
14
|
id?: string;
|
|
15
15
|
/** Nazwa dostępna grupy, gdy nie opisuje jej etykieta (`KptFormField`). */
|
|
16
16
|
ariaLabel?: string | null;
|
|
@@ -23,13 +23,13 @@ export interface KptRatingProps extends Omit<ComponentPropsWithRef<'div'>, 'onCh
|
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
25
|
* Ocena gwiazdkami. Kliknięcie zapalonej gwiazdki zeruje ocenę, więc wystawioną można cofnąć
|
|
26
|
-
* bez osobnego przycisku
|
|
26
|
+
* bez osobnego przycisku "wyczyść".
|
|
27
27
|
*
|
|
28
28
|
* Do edycji to grupa radiowa (`role="radiogroup"`, gwiazdki jako `role="radio"`): jeden przystanek
|
|
29
29
|
* Tab, strzałki zmieniają ocenę o krok (w RTL odwrócone w poziomie), `Home`/`End` ustawiają
|
|
30
|
-
* skrajne, `Delete`/`Backspace` zeruje. Z `allowHalf` każda gwiazdka ma dwie połówki
|
|
31
|
-
* `radio` (
|
|
32
|
-
*
|
|
30
|
+
* skrajne, `Delete`/`Backspace` zeruje. Z `allowHalf` każda gwiazdka ma dwie połówki - dwa osobne
|
|
31
|
+
* `radio` ("3,5 z 5"), a krok strzałek to 0,5. Tylko do odczytu (`readOnly`) to obrazek z nazwą
|
|
32
|
+
* "4,3 z 5" - bez przycisków, które czytnik ogłaszałby jako wyłączone; gwiazdki pokazują wartość
|
|
33
33
|
* zaokrągloną do połówki.
|
|
34
34
|
*
|
|
35
35
|
* @example
|
package/dist/rating/rating.js
CHANGED
|
@@ -6,16 +6,19 @@ import { useControllableState } from "../internal/use-controllable-state.js";
|
|
|
6
6
|
import { useKptMessages } from "../i18n/i18n-context.js";
|
|
7
7
|
import { useKptFieldA11y } from "../form-field/form-field-context.js";
|
|
8
8
|
import { KptIcon } from "../icon/icon.js";
|
|
9
|
+
import { playPopMotion, resolveToggleMotion } from '@konce-pt/motion';
|
|
10
|
+
import { useKptMotion } from "../motion/motion-context.js";
|
|
11
|
+
import { ratingValueAt } from "./rating-pointer.js";
|
|
9
12
|
const fillOf = (star, shown) => shown >= star ? 'full' : shown >= star - 0.5 ? 'half' : 'empty';
|
|
10
13
|
/**
|
|
11
14
|
* Ocena gwiazdkami. Kliknięcie zapalonej gwiazdki zeruje ocenę, więc wystawioną można cofnąć
|
|
12
|
-
* bez osobnego przycisku
|
|
15
|
+
* bez osobnego przycisku "wyczyść".
|
|
13
16
|
*
|
|
14
17
|
* Do edycji to grupa radiowa (`role="radiogroup"`, gwiazdki jako `role="radio"`): jeden przystanek
|
|
15
18
|
* Tab, strzałki zmieniają ocenę o krok (w RTL odwrócone w poziomie), `Home`/`End` ustawiają
|
|
16
|
-
* skrajne, `Delete`/`Backspace` zeruje. Z `allowHalf` każda gwiazdka ma dwie połówki
|
|
17
|
-
* `radio` (
|
|
18
|
-
*
|
|
19
|
+
* skrajne, `Delete`/`Backspace` zeruje. Z `allowHalf` każda gwiazdka ma dwie połówki - dwa osobne
|
|
20
|
+
* `radio` ("3,5 z 5"), a krok strzałek to 0,5. Tylko do odczytu (`readOnly`) to obrazek z nazwą
|
|
21
|
+
* "4,3 z 5" - bez przycisków, które czytnik ogłaszałby jako wyłączone; gwiazdki pokazują wartość
|
|
19
22
|
* zaokrągloną do połówki.
|
|
20
23
|
*
|
|
21
24
|
* @example
|
|
@@ -31,17 +34,34 @@ export function KptRating({ value, defaultValue = 0, onValueChange, count = 5, a
|
|
|
31
34
|
const groupRef = useRef(null);
|
|
32
35
|
/** Prośba o fokus na przystanek Tab po najbliższym renderze (zmiana oceny klawiszem). */
|
|
33
36
|
const wantFocus = useRef(false);
|
|
37
|
+
/** Ocena przeciągana wskaźnikiem (mysz albo dotyk) - podgląd idzie za palcem, puszczenie zatwierdza. */
|
|
38
|
+
const [dragging, setDragging] = useState(false);
|
|
39
|
+
const toggleMotion = resolveToggleMotion(undefined, useKptMotion());
|
|
34
40
|
const showInvalid = invalid && (touched ?? true);
|
|
35
41
|
const stars = Array.from({ length: count }, (_, index) => index + 1);
|
|
36
42
|
const step = allowHalf ? 0.5 : 1;
|
|
37
|
-
// Podgląd pod kursorem wygrywa z oceną, ale tylko dopóki kursor jest nad gwiazdkami
|
|
43
|
+
// Podgląd pod kursorem wygrywa z oceną, ale tylko dopóki kursor jest nad gwiazdkami -
|
|
38
44
|
// po `mouseleave` wraca 0 i zapalona zostaje sama wartość.
|
|
39
45
|
const shown = hover || current;
|
|
40
|
-
/** Przystanek Tab: wybrana wartość, a bez oceny
|
|
46
|
+
/** Przystanek Tab: wybrana wartość, a bez oceny - pierwsza możliwa. */
|
|
41
47
|
const tabStop = current >= step && current <= count ? current : step;
|
|
42
|
-
/** Liczba w zapisie języka strony (
|
|
48
|
+
/** Liczba w zapisie języka strony ("3,5" po polsku). */
|
|
43
49
|
const numberFormat = new Intl.NumberFormat(activeLocale, { maximumFractionDigits: 2 });
|
|
44
50
|
const starLabel = (score) => t('rating.star', { value: numberFormat.format(score), max: count });
|
|
51
|
+
// Gwiazdki, które się zapalają (podgląd pod kursorem, przeciąganie, wybór), wskakują po kolei.
|
|
52
|
+
// Ruch idzie za globalnym `toggle` z `KptMotionProvider`; start strony się nie rusza.
|
|
53
|
+
const shownBefore = useRef(null);
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
const before = shownBefore.current;
|
|
56
|
+
shownBefore.current = shown;
|
|
57
|
+
if (before === null || shown <= before || toggleMotion !== 'spring')
|
|
58
|
+
return;
|
|
59
|
+
groupRef.current?.querySelectorAll('.kpt-rating__star').forEach((star, i) => {
|
|
60
|
+
const n = i + 1;
|
|
61
|
+
if (n > Math.ceil(before) && n <= Math.ceil(shown))
|
|
62
|
+
playPopMotion(star);
|
|
63
|
+
});
|
|
64
|
+
}, [shown, toggleMotion]);
|
|
45
65
|
useEffect(() => {
|
|
46
66
|
if (!wantFocus.current)
|
|
47
67
|
return;
|
|
@@ -51,7 +71,7 @@ export function KptRating({ value, defaultValue = 0, onValueChange, count = 5, a
|
|
|
51
71
|
const starVisual = (star, fill, children, hidden = false) => (_jsxs("span", { className: "kpt-rating__star", "data-fill": fill, "aria-hidden": hidden || undefined, children: [_jsx(KptIcon, { name: "star" }), _jsx("span", { className: "kpt-rating__fill", "aria-hidden": "true", children: _jsx(KptIcon, { name: "star" }) }), children] }, star));
|
|
52
72
|
if (readOnly) {
|
|
53
73
|
const score = starLabel(current);
|
|
54
|
-
// Gwiazdki pokazują wartość zaokrągloną do połówki (4,3
|
|
74
|
+
// Gwiazdki pokazują wartość zaokrągloną do połówki (4,3 -> 4,5), nazwa - dokładną.
|
|
55
75
|
const display = Math.round(current * 2) / 2;
|
|
56
76
|
return (_jsx("div", { className: cn('kpt-rating-host', className), ...rest, children: _jsx("div", { className: "kpt-rating kpt-rating--readonly", role: "img", id: field.id, "aria-label": ariaLabel ? `${ariaLabel}: ${score}` : score, "aria-describedby": field.describedBy, children: stars.map((star) => starVisual(star, fillOf(star, display), null, true)) }) }));
|
|
57
77
|
}
|
|
@@ -78,7 +98,7 @@ export function KptRating({ value, defaultValue = 0, onValueChange, count = 5, a
|
|
|
78
98
|
else if (event.key === 'Delete' || event.key === 'Backspace')
|
|
79
99
|
next = 0;
|
|
80
100
|
else if (event.key === ' ' || event.key === 'Enter') {
|
|
81
|
-
// Spacja na gwiazdce wybiera ją (jak radio); ponowna nie zeruje
|
|
101
|
+
// Spacja na gwiazdce wybiera ją (jak radio); ponowna nie zeruje - od tego jest Delete.
|
|
82
102
|
const score = Number(event.target.dataset['value']);
|
|
83
103
|
if (score)
|
|
84
104
|
next = score;
|
|
@@ -89,18 +109,62 @@ export function KptRating({ value, defaultValue = 0, onValueChange, count = 5, a
|
|
|
89
109
|
setCurrent(next);
|
|
90
110
|
wantFocus.current = true;
|
|
91
111
|
};
|
|
92
|
-
/**
|
|
112
|
+
/**
|
|
113
|
+
* Przeciąganie po gwiazdkach. Krótkie wciśnięcie bez ruchu zostawia sprawę kliknięciu (zachowanie
|
|
114
|
+
* jak dotąd, łącznie z ponownym kliknięciem zerującym); ruch o kilka pikseli zamienia gest w wybór
|
|
115
|
+
* przeciąganiem - także dotykiem, gdzie nie ma podglądu na `mouseenter`.
|
|
116
|
+
*/
|
|
117
|
+
const onPointerDown = (event) => {
|
|
118
|
+
if (disabled || event.button !== 0)
|
|
119
|
+
return;
|
|
120
|
+
const root = event.currentTarget;
|
|
121
|
+
const startX = event.clientX;
|
|
122
|
+
let active = false;
|
|
123
|
+
const valueAt = (x) => ratingValueAt(x, Array.from(root.querySelectorAll('.kpt-rating__star'), (el) => el.getBoundingClientRect()), { allowHalf, rtl: getComputedStyle(root).direction === 'rtl' });
|
|
124
|
+
const move = (e) => {
|
|
125
|
+
if (!active && Math.abs(e.clientX - startX) < 4)
|
|
126
|
+
return;
|
|
127
|
+
if (!active) {
|
|
128
|
+
active = true;
|
|
129
|
+
setDragging(true);
|
|
130
|
+
root.setPointerCapture(e.pointerId);
|
|
131
|
+
}
|
|
132
|
+
setHover(valueAt(e.clientX));
|
|
133
|
+
};
|
|
134
|
+
const up = (e) => {
|
|
135
|
+
root.removeEventListener('pointermove', move);
|
|
136
|
+
root.removeEventListener('pointerup', up);
|
|
137
|
+
root.removeEventListener('pointercancel', up);
|
|
138
|
+
if (!active)
|
|
139
|
+
return;
|
|
140
|
+
setDragging(false);
|
|
141
|
+
// Klik po przeciągnięciu jest skutkiem tego samego gestu - nie może drugi raz przestawić oceny.
|
|
142
|
+
// Połykamy go w fazie capture; nasłuch znika w następnej klatce, gdyby klik nie przyszedł.
|
|
143
|
+
const swallow = (ev) => ev.stopPropagation();
|
|
144
|
+
root.addEventListener('click', swallow, { capture: true, once: true });
|
|
145
|
+
requestAnimationFrame(() => root.removeEventListener('click', swallow, { capture: true }));
|
|
146
|
+
const score = valueAt(e.clientX);
|
|
147
|
+
setCurrent(score);
|
|
148
|
+
// Mysz zostaje nad gwiazdkami - podgląd i tak zgadza się z wyborem; palec odchodzi, więc czyścimy.
|
|
149
|
+
setHover(e.pointerType === 'mouse' ? score : 0);
|
|
150
|
+
onTouch?.();
|
|
151
|
+
};
|
|
152
|
+
root.addEventListener('pointermove', move);
|
|
153
|
+
root.addEventListener('pointerup', up);
|
|
154
|
+
root.addEventListener('pointercancel', up);
|
|
155
|
+
};
|
|
156
|
+
/** "Dotknięcie" dopiero przy wyjściu fokusu z całej grupy, nie przy przejściu między gwiazdkami. */
|
|
93
157
|
const onBlur = (event) => {
|
|
94
158
|
const next = event.relatedTarget;
|
|
95
159
|
if (!next || !event.currentTarget.contains(next))
|
|
96
160
|
onTouch?.();
|
|
97
161
|
};
|
|
98
|
-
/** Pola wyboru jednej gwiazdki: całość albo
|
|
162
|
+
/** Pola wyboru jednej gwiazdki: całość albo - z `allowHalf` - dwie połówki. */
|
|
99
163
|
const optionsOf = (star) => allowHalf
|
|
100
164
|
? [
|
|
101
165
|
{ score: star - 0.5, part: 'start' },
|
|
102
166
|
{ score: star, part: 'end' },
|
|
103
167
|
]
|
|
104
168
|
: [{ score: star, part: 'full' }];
|
|
105
|
-
return (_jsx("div", { className: cn('kpt-rating-host', className), ...rest, children: _jsx("div", { ref: groupRef, className: cn('kpt-rating', disabled && 'kpt-rating--disabled'), role: "radiogroup", id: field.id, "aria-label": ariaLabel ?? undefined, "aria-labelledby": ariaLabel ? undefined : field.labelledBy, "aria-describedby": field.describedBy, "aria-required": required || undefined, "aria-invalid": showInvalid || undefined, "aria-disabled": disabled || undefined, onKeyDown: onKeyDown, onBlur: onBlur, onMouseLeave: () => setHover(0), children: stars.map((star) => starVisual(star, fillOf(star, shown), optionsOf(star).map((option) => (_jsx("button", { type: "button", role: "radio", className: cn('kpt-rating__hit', `kpt-rating__hit--${option.part}`), "aria-checked": option.score === current, tabIndex: !disabled && option.score === tabStop ? 0 : -1, "aria-disabled": disabled || undefined, "data-value": option.score, "aria-label": starLabel(option.score), onClick: () => pick(option.score), onMouseEnter: () => !disabled && setHover(option.score) }, option.part))))) }) }));
|
|
169
|
+
return (_jsx("div", { className: cn('kpt-rating-host', className), ...rest, children: _jsx("div", { ref: groupRef, className: cn('kpt-rating', disabled && 'kpt-rating--disabled', dragging && 'is-dragging'), role: "radiogroup", id: field.id, "aria-label": ariaLabel ?? undefined, "aria-labelledby": ariaLabel ? undefined : field.labelledBy, "aria-describedby": field.describedBy, "aria-required": required || undefined, "aria-invalid": showInvalid || undefined, "aria-disabled": disabled || undefined, onKeyDown: onKeyDown, onBlur: onBlur, onMouseLeave: () => !dragging && setHover(0), onPointerDown: onPointerDown, children: stars.map((star) => starVisual(star, fillOf(star, shown), optionsOf(star).map((option) => (_jsx("button", { type: "button", role: "radio", className: cn('kpt-rating__hit', `kpt-rating__hit--${option.part}`), "aria-checked": option.score === current, tabIndex: !disabled && option.score === tabStop ? 0 : -1, "aria-disabled": disabled || undefined, "data-value": option.score, "aria-label": starLabel(option.score), onClick: () => pick(option.score), onMouseEnter: () => !disabled && setHover(option.score) }, option.part))))) }) }));
|
|
106
170
|
}
|
|
@@ -6,11 +6,11 @@ export declare function canIndentItem(editor: HTMLElement | null, li: HTMLLIElem
|
|
|
6
6
|
export declare function canOutdentItem(li: HTMLLIElement): boolean;
|
|
7
7
|
/**
|
|
8
8
|
* Punkty listy objęte zaznaczeniem. Przy wielu punktach operujemy na ich wspólnym poziomie
|
|
9
|
-
* zagnieżdżenia
|
|
9
|
+
* zagnieżdżenia - inaczej podpunkt dostałby wcięcie dwa razy: raz sam, raz z rodzicem.
|
|
10
10
|
*/
|
|
11
11
|
export declare function selectedItems(editor: HTMLElement | null): HTMLLIElement[];
|
|
12
12
|
/**
|
|
13
|
-
* Przesuwa zaznaczone punkty o poziom. Zwraca `true`, gdy DOM faktycznie się zmienił
|
|
13
|
+
* Przesuwa zaznaczone punkty o poziom. Zwraca `true`, gdy DOM faktycznie się zmienił - od tego
|
|
14
14
|
* zależy, czy Tab dostanie `preventDefault()`, a więc czy edytor nie stanie się pułapką
|
|
15
15
|
* klawiaturową (WCAG 2.1.2).
|
|
16
16
|
*/
|
package/dist/rich-text/lists.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* Wcięcia list. `execCommand('indent')` daje w Chrome nieprawidłowe `ul > ul` (albo `blockquote`
|
|
3
3
|
* z marginesem, który i tak zdjąłby sanitizer), więc zagnieżdżanie robimy własnym kodem DOM.
|
|
4
|
-
* Plik nie zna Reacta
|
|
4
|
+
* Plik nie zna Reacta - to czyste operacje na węzłach.
|
|
5
5
|
*/
|
|
6
6
|
/** Najbliższy punkt listy zawierający węzeł, ale tylko wewnątrz edytora. */
|
|
7
7
|
export function closestItem(editor, node) {
|
|
@@ -19,7 +19,7 @@ export function level(editor, li) {
|
|
|
19
19
|
}
|
|
20
20
|
return depth;
|
|
21
21
|
}
|
|
22
|
-
/** Najgłębszy poziom w poddrzewie punktu
|
|
22
|
+
/** Najgłębszy poziom w poddrzewie punktu - wcięcie przenosi podpunkty razem z rodzicem. */
|
|
23
23
|
function deepest(editor, li) {
|
|
24
24
|
let max = level(editor, li);
|
|
25
25
|
for (const nested of li.querySelectorAll('li')) {
|
|
@@ -35,7 +35,7 @@ export function canOutdentItem(li) {
|
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
37
37
|
* Punkty listy objęte zaznaczeniem. Przy wielu punktach operujemy na ich wspólnym poziomie
|
|
38
|
-
* zagnieżdżenia
|
|
38
|
+
* zagnieżdżenia - inaczej podpunkt dostałby wcięcie dwa razy: raz sam, raz z rodzicem.
|
|
39
39
|
*/
|
|
40
40
|
export function selectedItems(editor) {
|
|
41
41
|
const selection = window.getSelection();
|
|
@@ -68,7 +68,7 @@ export function selectedItems(editor) {
|
|
|
68
68
|
return [start];
|
|
69
69
|
return siblings.slice(Math.min(from, to), Math.max(from, to) + 1);
|
|
70
70
|
}
|
|
71
|
-
/** Zagnieżdża punkt w podliście poprzedniego punktu
|
|
71
|
+
/** Zagnieżdża punkt w podliście poprzedniego punktu - poprawne `li > ul > li`. */
|
|
72
72
|
function indentItem(editor, li, maxLevel) {
|
|
73
73
|
if (!canIndentItem(editor, li, maxLevel))
|
|
74
74
|
return false;
|
|
@@ -104,7 +104,7 @@ function outdentItem(li) {
|
|
|
104
104
|
return true;
|
|
105
105
|
}
|
|
106
106
|
/**
|
|
107
|
-
* Przesuwa zaznaczone punkty o poziom. Zwraca `true`, gdy DOM faktycznie się zmienił
|
|
107
|
+
* Przesuwa zaznaczone punkty o poziom. Zwraca `true`, gdy DOM faktycznie się zmienił - od tego
|
|
108
108
|
* zależy, czy Tab dostanie `preventDefault()`, a więc czy edytor nie stanie się pułapką
|
|
109
109
|
* klawiaturową (WCAG 2.1.2).
|
|
110
110
|
*/
|
|
@@ -119,7 +119,7 @@ export function shiftItems(editor, dir, maxLevel) {
|
|
|
119
119
|
const caret = range
|
|
120
120
|
? { sc: range.startContainer, so: range.startOffset, ec: range.endContainer, eo: range.endOffset }
|
|
121
121
|
: null;
|
|
122
|
-
// Outdent od końca
|
|
122
|
+
// Outdent od końca - inaczej `host.after()` odwróciłby kolejność przenoszonych punktów.
|
|
123
123
|
const order = dir === 'outdent' ? [...items].reverse() : items;
|
|
124
124
|
let changed = false;
|
|
125
125
|
for (const li of order) {
|
|
@@ -137,7 +137,7 @@ export function shiftItems(editor, dir, maxLevel) {
|
|
|
137
137
|
selection.addRange(restored);
|
|
138
138
|
}
|
|
139
139
|
catch {
|
|
140
|
-
/* offset przestał pasować po przeniesieniu rodzeństwa
|
|
140
|
+
/* offset przestał pasować po przeniesieniu rodzeństwa - zostaw kursor tam, gdzie jest */
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
143
|
return true;
|