@konce-pt/react 0.12.0 → 0.15.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 +12 -7
- package/dist/dialog/dialog.js +4 -4
- package/dist/dialog/llms.txt +14 -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
|
@@ -19,10 +19,10 @@ const EMPTY_RANGE = { start: '', end: '' };
|
|
|
19
19
|
* `visibleMonths` pokazuje kilka miesięcy obok siebie, a zakres podświetla się ciągłym pasmem
|
|
20
20
|
* przez wszystkie panele.
|
|
21
21
|
*
|
|
22
|
-
* Klawiatura jak w `KptDatepicker`: `Enter`/`Spacja
|
|
23
|
-
* zakresu (albo dziś), strzałki, `Home`/`End` i `PageUp`/`PageDown` (z `Shift`
|
|
22
|
+
* Klawiatura jak w `KptDatepicker`: `Enter`/`Spacja`/`ArrowDown` otwierają panel z fokusem na początku
|
|
23
|
+
* zakresu (albo dziś), strzałki, `Home`/`End` i `PageUp`/`PageDown` (z `Shift` - rok) chodzą po
|
|
24
24
|
* dniach przez wszystkie panele, `Tab` krąży w panelu, `Escape` i wybór końca oddają fokus polu.
|
|
25
|
-
* Krańce i środek zakresu są w nazwie dnia (
|
|
25
|
+
* Krańce i środek zakresu są w nazwie dnia ("..., początek zakresu"), a wybór i przewinięcie miesiąca
|
|
26
26
|
* ogłasza region `polite`. Pole to `role="combobox"` z `aria-haspopup="dialog"`, więc niesie
|
|
27
27
|
* `aria-required`, `aria-readonly` i `aria-invalid`. Tydzień zaczyna się wg aktywnego języka.
|
|
28
28
|
*
|
|
@@ -32,7 +32,7 @@ const EMPTY_RANGE = { start: '', end: '' };
|
|
|
32
32
|
*/
|
|
33
33
|
export function KptDateRange({ value, defaultValue = EMPTY_RANGE, onValueChange, mode = 'date', visibleMonths = 1, hourFormat = 24, minuteStep = 1, placeholder, displayFormat = 'pl', firstDayOfWeek = null, open, onOpenChange, minDate = null, maxDate = null, ariaLabel = null, id, disabled = false, readOnly = false, required = false, invalid = false, touched, onTouch, locale, dictionary, className, ...rest }) {
|
|
34
34
|
const { t, locale: activeLocale } = useKptMessages({ locale, dictionary });
|
|
35
|
-
/** `div` z rolą nie dostaje nazwy z `label[for]`
|
|
35
|
+
/** `div` z rolą nie dostaje nazwy z `label[for]` - stąd `aria-labelledby` na etykietę wrappera. */
|
|
36
36
|
const field = useKptFieldA11y(id, 'kpt-date-range');
|
|
37
37
|
const [current, setCurrent] = useControllableState({ value, defaultValue, onChange: onValueChange });
|
|
38
38
|
const [isOpen, setOpen] = useControllableState({ value: open, defaultValue: false, onChange: onOpenChange });
|
|
@@ -40,14 +40,14 @@ export function KptDateRange({ value, defaultValue = EMPTY_RANGE, onValueChange,
|
|
|
40
40
|
const triggerRef = useRef(null);
|
|
41
41
|
const panelRef = useRef(null);
|
|
42
42
|
const panelId = useKptId(undefined, 'kpt-date-range-panel');
|
|
43
|
-
/** Dzień z fokusem
|
|
43
|
+
/** Dzień z fokusem - jedyny przystanek Tab siatek dni (roving tabindex przez wszystkie panele). */
|
|
44
44
|
const [focusIso, setFocusIso] = useState('');
|
|
45
45
|
/** Komunikat regionu `polite` po wyborze początku i całego zakresu. */
|
|
46
46
|
const [announcement, setAnnouncement] = useState('');
|
|
47
|
-
/** Prośba o przeniesienie fokusu po najbliższym renderze (otwarcie, ruch klawiszem)
|
|
47
|
+
/** Prośba o przeniesienie fokusu po najbliższym renderze (otwarcie, ruch klawiszem) - licznik w stanie. */
|
|
48
48
|
const [focusRequest, setFocusRequest] = useState(0);
|
|
49
49
|
const requestFocus = () => setFocusRequest((n) => n + 1);
|
|
50
|
-
/**
|
|
50
|
+
/** "Dziś" liczone przy każdym otwarciu - panel otwarty po północy nie pokazuje wczorajszego dnia. */
|
|
51
51
|
const [today, setToday] = useState(() => new Date());
|
|
52
52
|
const todayIso = toIso(today);
|
|
53
53
|
const firstDay = firstDayOfWeek ?? kptFirstDayOfWeek(activeLocale);
|
|
@@ -57,7 +57,7 @@ export function KptDateRange({ value, defaultValue = EMPTY_RANGE, onValueChange,
|
|
|
57
57
|
const [startTime, setStartTime] = useState('');
|
|
58
58
|
const [endTime, setEndTime] = useState('');
|
|
59
59
|
const [timeEnd, setTimeEnd] = useState('start');
|
|
60
|
-
// Część kalendarzowa zakresu w trybie datetime
|
|
60
|
+
// Część kalendarzowa zakresu w trybie datetime - wartość powstaje dopiero przy "Gotowe".
|
|
61
61
|
const [startDate, setStartDate] = useState('');
|
|
62
62
|
const [endDate, setEndDate] = useState('');
|
|
63
63
|
const months = monthNames(activeLocale);
|
|
@@ -69,7 +69,7 @@ export function KptDateRange({ value, defaultValue = EMPTY_RANGE, onValueChange,
|
|
|
69
69
|
const date = parseDate(iso);
|
|
70
70
|
return date ? dayFormat.format(date) : iso;
|
|
71
71
|
};
|
|
72
|
-
/** Pełna nazwa dnia z rolą w zakresie
|
|
72
|
+
/** Pełna nazwa dnia z rolą w zakresie - kolor pasma nie jest jedynym nośnikiem informacji. */
|
|
73
73
|
const dayLabel = (cell) => {
|
|
74
74
|
const name = dayName(cell.iso);
|
|
75
75
|
if (cell.isStart)
|
|
@@ -89,7 +89,7 @@ export function KptDateRange({ value, defaultValue = EMPTY_RANGE, onValueChange,
|
|
|
89
89
|
if (!start)
|
|
90
90
|
return '';
|
|
91
91
|
if (mode === 'time') {
|
|
92
|
-
return end ? `${fmtTime(start)}
|
|
92
|
+
return end ? `${fmtTime(start)} - ${fmtTime(end)}` : `${fmtTime(start)} - ...`;
|
|
93
93
|
}
|
|
94
94
|
if (mode === 'datetime') {
|
|
95
95
|
const one = (v) => {
|
|
@@ -97,13 +97,13 @@ export function KptDateRange({ value, defaultValue = EMPTY_RANGE, onValueChange,
|
|
|
97
97
|
const time = fmtTime(timePart(v));
|
|
98
98
|
return time ? `${date} ${time}` : date;
|
|
99
99
|
};
|
|
100
|
-
return end ? `${one(start)}
|
|
100
|
+
return end ? `${one(start)} - ${one(end)}` : `${one(start)} - ...`;
|
|
101
101
|
}
|
|
102
102
|
const fmt = (iso) => displayDate(iso, displayFormat, activeLocale);
|
|
103
|
-
return end ? `${fmt(start)}
|
|
103
|
+
return end ? `${fmt(start)} - ${fmt(end)}` : `${fmt(start)} - ...`;
|
|
104
104
|
})();
|
|
105
|
-
// Panel otwiera też `open` z zewnątrz
|
|
106
|
-
// otwarty, wzorcem
|
|
105
|
+
// Panel otwiera też `open` z zewnątrz - stan początkowy liczymy przy każdym przejściu w stan
|
|
106
|
+
// otwarty, wzorcem "poprzednia wartość w stanie" (bez efektu i klatki ze starym widokiem).
|
|
107
107
|
const [wasOpen, setWasOpen] = useState(isOpen);
|
|
108
108
|
if (wasOpen !== isOpen) {
|
|
109
109
|
setWasOpen(isOpen);
|
|
@@ -142,12 +142,12 @@ export function KptDateRange({ value, defaultValue = EMPTY_RANGE, onValueChange,
|
|
|
142
142
|
setOpen(false);
|
|
143
143
|
onTouch?.();
|
|
144
144
|
};
|
|
145
|
-
/** Zamknięcie z powrotem fokusu na pole
|
|
145
|
+
/** Zamknięcie z powrotem fokusu na pole - po wyborze z klawiatury, `Escape`. */
|
|
146
146
|
const closeAndFocus = () => {
|
|
147
147
|
close();
|
|
148
148
|
triggerRef.current?.focus();
|
|
149
149
|
};
|
|
150
|
-
// Fokus po renderze. Panel w nakładce jest niewidoczny do pierwszego pomiaru
|
|
150
|
+
// Fokus po renderze. Panel w nakładce jest niewidoczny do pierwszego pomiaru - stąd rAF.
|
|
151
151
|
const focusActive = useEffectEvent(() => focusCalendarActive(panelRef.current, focusIso));
|
|
152
152
|
useEffect(() => {
|
|
153
153
|
if (!isOpen || focusRequest === 0)
|
|
@@ -155,7 +155,7 @@ export function KptDateRange({ value, defaultValue = EMPTY_RANGE, onValueChange,
|
|
|
155
155
|
const frame = requestAnimationFrame(() => focusActive());
|
|
156
156
|
return () => cancelAnimationFrame(frame);
|
|
157
157
|
}, [focusRequest, isOpen]);
|
|
158
|
-
/** Przesuwa okno paneli tak, żeby miesiąc dnia `iso` był widoczny
|
|
158
|
+
/** Przesuwa okno paneli tak, żeby miesiąc dnia `iso` był widoczny - z najmniejszym skokiem. */
|
|
159
159
|
const revealMonth = (iso) => {
|
|
160
160
|
const target = +iso.slice(0, 4) * 12 + (+iso.slice(5, 7) - 1);
|
|
161
161
|
const first = page.y * 12 + page.m;
|
|
@@ -176,7 +176,7 @@ export function KptDateRange({ value, defaultValue = EMPTY_RANGE, onValueChange,
|
|
|
176
176
|
revealMonth(next);
|
|
177
177
|
requestFocus();
|
|
178
178
|
};
|
|
179
|
-
/** Strzałki
|
|
179
|
+
/** Strzałki < >: fokus zostaje na strzałce, ale przystanek siatki idzie za stroną. */
|
|
180
180
|
const turnPage = (dir) => {
|
|
181
181
|
const first = page.y * 12 + page.m + dir;
|
|
182
182
|
setPage({ y: Math.floor(first / 12), m: ((first % 12) + 12) % 12 });
|
|
@@ -184,11 +184,11 @@ export function KptDateRange({ value, defaultValue = EMPTY_RANGE, onValueChange,
|
|
|
184
184
|
setAnnouncement(Array.from({ length: panelCount }, (_, i) => {
|
|
185
185
|
const month = first + i;
|
|
186
186
|
return `${months[((month % 12) + 12) % 12]} ${Math.floor(month / 12)}`;
|
|
187
|
-
}).join('
|
|
187
|
+
}).join(' - '));
|
|
188
188
|
const moved = moveFocusDate(focusIso, dir === 1 ? 'PageDown' : 'PageUp', { minDate, maxDate, firstDay });
|
|
189
189
|
if (moved) {
|
|
190
190
|
const target = +moved.slice(0, 4) * 12 + (+moved.slice(5, 7) - 1);
|
|
191
|
-
// Nowe okno zaczyna się od `first`
|
|
191
|
+
// Nowe okno zaczyna się od `first` - dzień spoza niego nie dostałby przystanku Tab.
|
|
192
192
|
if (target >= first && target < first + panelCount)
|
|
193
193
|
setFocusIso(moved);
|
|
194
194
|
}
|
|
@@ -224,12 +224,12 @@ export function KptDateRange({ value, defaultValue = EMPTY_RANGE, onValueChange,
|
|
|
224
224
|
setStartDate(next.start);
|
|
225
225
|
setEndDate(next.end);
|
|
226
226
|
announce(next.start, next.end);
|
|
227
|
-
return; // czas do wyboru
|
|
227
|
+
return; // czas do wyboru -> zamknięcie przez "Gotowe"
|
|
228
228
|
}
|
|
229
229
|
const next = pickRangeDay(current, iso);
|
|
230
230
|
setCurrent(next);
|
|
231
231
|
announce(next.start, next.end);
|
|
232
|
-
// Panel zostaje otwarty do czasu domknięcia zakresu
|
|
232
|
+
// Panel zostaje otwarty do czasu domknięcia zakresu - inaczej drugi klik nie miałby gdzie paść.
|
|
233
233
|
if (next.end)
|
|
234
234
|
closeAndFocus();
|
|
235
235
|
};
|
|
@@ -277,7 +277,7 @@ export function KptDateRange({ value, defaultValue = EMPTY_RANGE, onValueChange,
|
|
|
277
277
|
clear(event);
|
|
278
278
|
}
|
|
279
279
|
},
|
|
280
|
-
// Przy otwartym panelu fokus idzie do kalendarza
|
|
280
|
+
// Przy otwartym panelu fokus idzie do kalendarza - "dotknięcie" wyśle dopiero zamknięcie.
|
|
281
281
|
onBlur: () => !isOpen && onTouch?.(), children: [display ? (_jsx("span", { className: "kpt-date-range__value", children: display })) : (_jsx("span", { className: "kpt-date-range__placeholder", children: placeholder ?? t('dateRange.placeholder') })), _jsx("span", { className: "kpt-date-range__spacer" }), display && !readOnly ? (_jsx("button", { type: "button", className: "kpt-date-range__clear", tabIndex: -1, onClick: clear, "aria-label": t('common.clear'), children: _jsx(KptIcon, { name: "x" }) })) : null, _jsx(KptIcon, { className: "kpt-date-range__icon", name: "calendar" })] }), _jsx(KptOverlay, { open: isOpen, anchor: anchor, onClose: close, offset: 4, children: _jsxs("div", { ref: panelRef, id: panelId, role: "dialog", "aria-label": t('dateRange.dialog'), className: cn('kpt-calendar', mode === 'time' && 'kpt-calendar--clock', mode !== 'time' && 'kpt-calendar--range', multi && mode !== 'time' && 'kpt-calendar--multi'), onKeyDown: (event) => {
|
|
282
282
|
if (event.key === 'Escape') {
|
|
283
283
|
event.preventDefault();
|
|
@@ -288,7 +288,7 @@ export function KptDateRange({ value, defaultValue = EMPTY_RANGE, onValueChange,
|
|
|
288
288
|
trapTab(event.currentTarget, event.nativeEvent);
|
|
289
289
|
}
|
|
290
290
|
}, children: [_jsx("span", { className: "kpt-calendar__live", "aria-live": "polite", children: announcement }), mode === 'time' ? (_jsxs(_Fragment, { children: [_jsxs("div", { className: "kpt-range-tabs", children: [_jsx("button", { type: "button", className: cn(timeEnd === 'start' && 'is-active'), onClick: () => setTimeEnd('start'), children: t('dateRange.from') }), _jsx("button", { type: "button", className: cn(timeEnd === 'end' && 'is-active'), onClick: () => setTimeEnd('end'), children: t('dateRange.to') })] }), _jsx(KptClock
|
|
291
|
-
// Klucz na edytowanym końcu wymusza remount przy przełączeniu Od/Koniec
|
|
291
|
+
// Klucz na edytowanym końcu wymusza remount przy przełączeniu Od/Koniec - tarcza ma
|
|
292
292
|
// wtedy wrócić do etapu godzin, tak jak dwie osobne instancje w porcie Angulara.
|
|
293
293
|
, { value: clockValue, onValueChange: setClockValue, hourFormat: hourFormat, minuteStep: minuteStep }, timeEnd), _jsx("div", { className: "kpt-calendar__footer", children: _jsx(KptButton, { size: "sm", onClick: commit, children: t('common.done') }) })] })) : (_jsxs(_Fragment, { children: [_jsx("div", { className: "kpt-calendar__panels", children: panels.map((panel, index) => (_jsxs("div", { className: "kpt-calendar__panel", children: [_jsxs("div", { className: "kpt-calendar__header", children: [index === 0 ? (_jsx("button", { type: "button", className: "kpt-calendar__nav", onClick: () => turnPage(-1), "aria-label": t('datepicker.prevMonth'), children: _jsx(KptIcon, { name: "chevron-left" }) })) : (_jsx("span", { className: "kpt-calendar__nav-slot" })), _jsx("span", { className: "kpt-calendar__title", children: panel.label }), index === panels.length - 1 ? (_jsx("button", { type: "button", className: "kpt-calendar__nav", onClick: () => turnPage(1), "aria-label": t('datepicker.nextMonth'), children: _jsx(KptIcon, { name: "chevron-right" }) })) : (_jsx("span", { className: "kpt-calendar__nav-slot" }))] }), _jsx("div", { className: "kpt-calendar__weekdays", children: weekdays.map((weekday) => (_jsx("span", { className: "kpt-calendar__weekday", children: weekday }, weekday))) }), _jsx("div", { className: "kpt-calendar__grid", onKeyDown: onDayKeyDown, children: panel.weeks.flat().map((cell) => cell.blank ? (_jsx("span", { className: "kpt-calendar__day kpt-calendar__day--blank" }, cell.iso)) : (_jsx("button", { type: "button", className: cn('kpt-calendar__day', !cell.inMonth && 'kpt-calendar__day--muted', cell.today && 'kpt-calendar__day--today', cell.inRange && 'kpt-calendar__day--range', cell.rangeStart && 'kpt-calendar__day--range-start', cell.rangeEnd && 'kpt-calendar__day--range-end', (cell.isStart || cell.isEnd) && 'kpt-calendar__day--selected'), "data-iso": cell.iso, tabIndex: cell.iso === focusIso ? 0 : -1, "aria-label": dayLabel(cell), "aria-current": cell.today ? 'date' : undefined, "aria-pressed": cell.isStart || cell.isEnd, disabled: cell.disabled, onClick: () => selectDay(cell.iso), children: cell.day }, cell.iso))) })] }, panel.key))) }), mode === 'datetime' ? (_jsxs(_Fragment, { children: [_jsxs("div", { className: "kpt-range-tabs", children: [_jsx("button", { type: "button", className: cn(timeEnd === 'start' && 'is-active'), onClick: () => setTimeEnd('start'), children: t('dateRange.fromTime') }), _jsx("button", { type: "button", className: cn(timeEnd === 'end' && 'is-active'), onClick: () => setTimeEnd('end'), children: t('dateRange.toTime') })] }), _jsx(KptClock, { value: clockValue, onValueChange: setClockValue, hourFormat: hourFormat, minuteStep: minuteStep }, timeEnd), _jsx("div", { className: "kpt-calendar__footer", children: _jsx(KptButton, { size: "sm", onClick: commit, children: t('common.done') }) })] })) : null] }))] }) })] }));
|
|
294
294
|
}
|
package/dist/date-range/llms.txt
CHANGED
|
@@ -6,48 +6,48 @@ Import: `import { KptDateRange, type KptDateRangeValue } from '@konce-pt/react';
|
|
|
6
6
|
## DOM
|
|
7
7
|
<div class="kpt-date-range-host">
|
|
8
8
|
<div class="kpt-date-range" role="combobox" tabindex="0" aria-haspopup="dialog">
|
|
9
|
-
<span class="kpt-date-range__value">08.09.2026
|
|
10
|
-
|
|
9
|
+
<span class="kpt-date-range__value">08.09.2026 - 14.09.2026</span>
|
|
10
|
+
...clear, icon...
|
|
11
11
|
</div>
|
|
12
12
|
</div>
|
|
13
|
-
<!-- in a portal: <div class="kpt-calendar kpt-calendar--range kpt-calendar--multi"
|
|
13
|
+
<!-- in a portal: <div class="kpt-calendar kpt-calendar--range kpt-calendar--multi">...</div> -->
|
|
14
14
|
|
|
15
15
|
## Props
|
|
16
|
-
- `value` / `defaultValue` / `onValueChange`
|
|
16
|
+
- `value` / `defaultValue` / `onValueChange` - `{ start, end }`: dates 'YYYY-MM-DD',
|
|
17
17
|
datetime 'YYYY-MM-DDTHH:mm', times 'HH:mm'
|
|
18
18
|
- `mode`: `'date'` (default) | `'datetime'` | `'time'`
|
|
19
|
-
- `visibleMonths`: number (default 1, clamped to 1
|
|
19
|
+
- `visibleMonths`: number (default 1, clamped to 1-3) - months side by side; ignored in 'time' mode
|
|
20
20
|
- `hourFormat`: 12 | 24 (default 24); `minuteStep`: number (default 1)
|
|
21
|
-
- `placeholder`
|
|
21
|
+
- `placeholder` - without one it falls back to `dateRange.placeholder`
|
|
22
22
|
- `displayFormat`: `'pl'` (default) | `'iso'` | `'locale'`
|
|
23
23
|
- `minDate`, `maxDate`: 'YYYY-MM-DD' bounds (inclusive); days outside are disabled
|
|
24
|
-
- `ariaLabel`
|
|
24
|
+
- `ariaLabel` - the accessible name when no `<label for>` describes the field
|
|
25
25
|
- `disabled`, `invalid`, `touched`
|
|
26
|
-
- `onTouch()`
|
|
26
|
+
- `onTouch()` - fires when the panel closes or focus leaves the closed trigger
|
|
27
27
|
- `className`, `ref` and every other `<div>` prop go to the host
|
|
28
28
|
|
|
29
29
|
## Two clicks, one band
|
|
30
30
|
The first click sets `start`, the second `end`, a third starts over; clicking before the start
|
|
31
31
|
normalizes the order rather than producing a reversed range (`pickRangeDay` in `@konce-pt/datetime`).
|
|
32
|
-
The panel stays open until the range closes
|
|
32
|
+
The panel stays open until the range closes - the second click needs somewhere to land.
|
|
33
33
|
|
|
34
34
|
With several panels the adjacent-month days become blank slots: otherwise the same date would be
|
|
35
35
|
clickable twice, and the band would paint in both places.
|
|
36
36
|
|
|
37
37
|
## Keyboard
|
|
38
38
|
As in the date picker: the trigger has `aria-haspopup="dialog"` and `aria-expanded`; `Enter`, `Space`
|
|
39
|
-
and
|
|
40
|
-
or today. The arrows, `Home`/`End` and `PageUp`/`PageDown` (with `Shift`
|
|
39
|
+
and `ArrowDown` open the panel (a `role="dialog"` named "Choose a date range") with focus on the range start,
|
|
40
|
+
or today. The arrows, `Home`/`End` and `PageUp`/`PageDown` (with `Shift` - a year) walk the days across
|
|
41
41
|
every panel, shifting the set of months when focus leaves it. `Tab` cycles inside the panel, `Escape`
|
|
42
42
|
closes it, and picking the end (or "Done") returns focus to the trigger. `Delete`/`Backspace` on the
|
|
43
43
|
trigger clears the range.
|
|
44
44
|
|
|
45
|
-
Each day is named with the full date and its role in the range ("
|
|
46
|
-
"
|
|
47
|
-
`aria-current="date"`. After the first pick a polite live region says "Start:
|
|
45
|
+
Each day is named with the full date and its role in the range ("..., start of range", "..., end of range",
|
|
46
|
+
"..., in range") - the band colour is not the only carrier. The ends have `aria-pressed`, today has
|
|
47
|
+
`aria-current="date"`. After the first pick a polite live region says "Start: ... Choose the end date.".
|
|
48
48
|
|
|
49
49
|
## The clock remounts when the end switches
|
|
50
|
-
`key={timeEnd}` on `KptClock`, so the dial returns to the hours stage after the From/To toggle
|
|
50
|
+
`key={timeEnd}` on `KptClock`, so the dial returns to the hours stage after the From/To toggle -
|
|
51
51
|
in Angular that came for free from two separate template branches.
|
|
52
52
|
|
|
53
53
|
## Examples
|
|
@@ -62,16 +62,16 @@ from the `dateRange`, `datepicker` and `common` namespaces.
|
|
|
62
62
|
|
|
63
63
|
## Week start, display format and field state
|
|
64
64
|
- The week starts by the active language (`Intl.Locale#getWeekInfo`, with a fallback list of regions):
|
|
65
|
-
en / en-US on Sunday, pl, de, en-GB on Monday. `firstDayOfWeek` (1 = Monday
|
|
65
|
+
en / en-US on Sunday, pl, de, en-GB on Monday. `firstDayOfWeek` (1 = Monday ... 7 = Sunday) overrides it;
|
|
66
66
|
the headers, the grid and `Home`/`End` follow it.
|
|
67
|
-
- `displayFormat`: `'pl'` (DD.MM.YYYY, default), `'iso'` (YYYY-MM-DD) or `'locale'`
|
|
67
|
+
- `displayFormat`: `'pl'` (DD.MM.YYYY, default), `'iso'` (YYYY-MM-DD) or `'locale'` - order and separators
|
|
68
68
|
from `Intl` (en-US: MM/DD/YYYY). The placeholder follows the format and its letters follow the language
|
|
69
69
|
(EN `YYYY`, PL `RRRR`, the `datepicker.yearToken`/`monthToken`/`dayToken` keys). AM/PM come from `Intl`.
|
|
70
70
|
- The field is `role="combobox"` with `aria-haspopup="dialog"` (the APG select-only combobox), so it carries
|
|
71
|
-
`aria-required` (`required`), `aria-readonly` (`readOnly`
|
|
71
|
+
`aria-required` (`required`), `aria-readonly` (`readOnly` - the value shows, the panel does not open,
|
|
72
72
|
there is no clear button) and `aria-invalid`.
|
|
73
|
-
- Turning the page with
|
|
74
|
-
"October, Choose month"
|
|
73
|
+
- Turning the page with < > is announced (`aria-live="polite"`); the title buttons are named
|
|
74
|
+
"October, Choose month" - the visible text first (WCAG 2.5.3). Clearing the value counts as a touch.
|
|
75
75
|
- "Today" is computed on every open, so a panel opened after midnight marks the right day.
|
|
76
76
|
|
|
77
77
|
## Label and description
|
|
@@ -16,25 +16,25 @@ export interface KptDatepickerProps extends Omit<ComponentPropsWithRef<'div'>, '
|
|
|
16
16
|
/** Prezentacja miesiąca w trybie 'month' i w etykietach: słownie czy liczbą. */
|
|
17
17
|
monthDisplay?: 'long' | 'number';
|
|
18
18
|
/**
|
|
19
|
-
* Zapis daty: `'pl'` (DD.MM.RRRR, domyślnie), `'iso'` albo `'locale'`
|
|
19
|
+
* Zapis daty: `'pl'` (DD.MM.RRRR, domyślnie), `'iso'` albo `'locale'` - kolejność i separatory
|
|
20
20
|
* z `Intl` dla aktywnego języka. Placeholder idzie za formatem, a jego litery za językiem.
|
|
21
21
|
*/
|
|
22
22
|
displayFormat?: KptDateDisplayFormat;
|
|
23
|
-
/** Pierwszy dzień tygodnia (1 = poniedziałek
|
|
23
|
+
/** Pierwszy dzień tygodnia (1 = poniedziałek ... 7 = niedziela); `null` = wg aktywnego języka. */
|
|
24
24
|
firstDayOfWeek?: KptFirstDayOfWeek | null;
|
|
25
25
|
hourFormat?: 12 | 24;
|
|
26
26
|
minuteStep?: number;
|
|
27
|
-
/** Stan panelu
|
|
27
|
+
/** Stan panelu - pozwala otworzyć kalendarz z zewnątrz i wiedzieć, kiedy wybór się skończył. */
|
|
28
28
|
open?: boolean;
|
|
29
29
|
onOpenChange?: (open: boolean) => void;
|
|
30
30
|
/** Nazwa dostępna, gdy pola nie opisuje `<label for>`. */
|
|
31
31
|
ariaLabel?: string | null;
|
|
32
|
-
/** Id pola (nie hosta); bez niego generowane, w `KptFormField`
|
|
32
|
+
/** Id pola (nie hosta); bez niego generowane, w `KptFormField` - z wrappera. */
|
|
33
33
|
id?: string;
|
|
34
34
|
disabled?: boolean;
|
|
35
|
-
/** Tylko do odczytu
|
|
35
|
+
/** Tylko do odczytu - wartość widać, panel się nie otwiera (`aria-readonly`). */
|
|
36
36
|
readOnly?: boolean;
|
|
37
|
-
/** Pole wymagane
|
|
37
|
+
/** Pole wymagane - `aria-required`. */
|
|
38
38
|
required?: boolean;
|
|
39
39
|
invalid?: boolean;
|
|
40
40
|
touched?: boolean;
|
|
@@ -42,18 +42,18 @@ export interface KptDatepickerProps extends Omit<ComponentPropsWithRef<'div'>, '
|
|
|
42
42
|
}
|
|
43
43
|
/**
|
|
44
44
|
* Wybór daty i godziny z własnym kalendarzem. Panel jest stosem widoków
|
|
45
|
-
* dekady
|
|
45
|
+
* dekady -> lata -> miesiące -> dni: klik w komórkę schodzi poziom niżej, klik w tytuł wchodzi wyżej.
|
|
46
46
|
*
|
|
47
|
-
* Klawiatura według wzorca WAI-ARIA
|
|
47
|
+
* Klawiatura według wzorca WAI-ARIA "date picker dialog": `Enter`/`Spacja`/`ArrowDown` na polu otwierają
|
|
48
48
|
* kalendarz i przenoszą fokus na wybrany (albo dzisiejszy) dzień. W siatce dni strzałki chodzą
|
|
49
49
|
* o dzień i tydzień, `Home`/`End` na początek i koniec tygodnia, `PageUp`/`PageDown` o miesiąc
|
|
50
|
-
* (z `Shift`
|
|
50
|
+
* (z `Shift` - o rok); w siatkach miesięcy, lat i dekad strzałki chodzą po komórkach. `Tab` krąży
|
|
51
51
|
* w panelu, `Escape` zamyka go, a wybór i zamknięcie oddają fokus polu. `Delete`/`Backspace` na polu
|
|
52
52
|
* czyści wartość.
|
|
53
53
|
*
|
|
54
54
|
* Pole to `role="combobox"` z `aria-haspopup="dialog"`, więc niesie `aria-required`,
|
|
55
55
|
* `aria-readonly` i `aria-invalid`. Tydzień zaczyna się wg aktywnego języka, chyba że podano
|
|
56
|
-
* `firstDayOfWeek`; przewinięcie strony strzałką
|
|
56
|
+
* `firstDayOfWeek`; przewinięcie strony strzałką < > jest ogłaszane.
|
|
57
57
|
*
|
|
58
58
|
* @example
|
|
59
59
|
* <KptDatepicker value={date} onValueChange={setDate} startView="decade" minDate="1920-01-01" />
|
|
@@ -15,18 +15,18 @@ import { useKptId } from "../internal/use-id.js";
|
|
|
15
15
|
import { focusCalendarActive, trapTab } from "../internal/calendar-focus.js";
|
|
16
16
|
/**
|
|
17
17
|
* Wybór daty i godziny z własnym kalendarzem. Panel jest stosem widoków
|
|
18
|
-
* dekady
|
|
18
|
+
* dekady -> lata -> miesiące -> dni: klik w komórkę schodzi poziom niżej, klik w tytuł wchodzi wyżej.
|
|
19
19
|
*
|
|
20
|
-
* Klawiatura według wzorca WAI-ARIA
|
|
20
|
+
* Klawiatura według wzorca WAI-ARIA "date picker dialog": `Enter`/`Spacja`/`ArrowDown` na polu otwierają
|
|
21
21
|
* kalendarz i przenoszą fokus na wybrany (albo dzisiejszy) dzień. W siatce dni strzałki chodzą
|
|
22
22
|
* o dzień i tydzień, `Home`/`End` na początek i koniec tygodnia, `PageUp`/`PageDown` o miesiąc
|
|
23
|
-
* (z `Shift`
|
|
23
|
+
* (z `Shift` - o rok); w siatkach miesięcy, lat i dekad strzałki chodzą po komórkach. `Tab` krąży
|
|
24
24
|
* w panelu, `Escape` zamyka go, a wybór i zamknięcie oddają fokus polu. `Delete`/`Backspace` na polu
|
|
25
25
|
* czyści wartość.
|
|
26
26
|
*
|
|
27
27
|
* Pole to `role="combobox"` z `aria-haspopup="dialog"`, więc niesie `aria-required`,
|
|
28
28
|
* `aria-readonly` i `aria-invalid`. Tydzień zaczyna się wg aktywnego języka, chyba że podano
|
|
29
|
-
* `firstDayOfWeek`; przewinięcie strony strzałką
|
|
29
|
+
* `firstDayOfWeek`; przewinięcie strony strzałką < > jest ogłaszane.
|
|
30
30
|
*
|
|
31
31
|
* @example
|
|
32
32
|
* <KptDatepicker value={date} onValueChange={setDate} startView="decade" minDate="1920-01-01" />
|
|
@@ -34,18 +34,18 @@ import { focusCalendarActive, trapTab } from "../internal/calendar-focus.js";
|
|
|
34
34
|
*/
|
|
35
35
|
export function KptDatepicker({ value, defaultValue = '', onValueChange, selectionMode = 'date', startView = null, minDate = null, maxDate = null, placeholder = '', monthDisplay = 'long', displayFormat = 'pl', firstDayOfWeek = null, hourFormat = 24, minuteStep = 1, open, onOpenChange, ariaLabel = null, id, disabled = false, readOnly = false, required = false, invalid = false, touched, onTouch, locale, dictionary, className, ...rest }) {
|
|
36
36
|
const { t, locale: activeLocale } = useKptMessages({ locale, dictionary });
|
|
37
|
-
/** `div` z rolą nie dostaje nazwy z `label[for]`
|
|
37
|
+
/** `div` z rolą nie dostaje nazwy z `label[for]` - stąd `aria-labelledby` na etykietę wrappera. */
|
|
38
38
|
const field = useKptFieldA11y(id, 'kpt-datepicker');
|
|
39
39
|
const [current, setCurrent] = useControllableState({ value, defaultValue, onChange: onValueChange });
|
|
40
40
|
const [isOpen, setOpen] = useControllableState({ value: open, defaultValue: false, onChange: onOpenChange });
|
|
41
41
|
const [anchor, setAnchor] = useState(null);
|
|
42
42
|
const triggerRef = useRef(null);
|
|
43
|
-
/**
|
|
43
|
+
/** "Dziś" liczone przy każdym otwarciu - panel otwarty po północy nie pokazuje wczorajszego dnia. */
|
|
44
44
|
const [today, setToday] = useState(() => new Date());
|
|
45
45
|
const todayIso = toIso(today);
|
|
46
46
|
const firstDay = firstDayOfWeek ?? kptFirstDayOfWeek(activeLocale);
|
|
47
47
|
const periods = dayPeriodLabels(activeLocale);
|
|
48
|
-
/** Ogłoszenie strony kalendarza po przewinięciu strzałką
|
|
48
|
+
/** Ogłoszenie strony kalendarza po przewinięciu strzałką < >. */
|
|
49
49
|
const [pageAnnouncement, setPageAnnouncement] = useState('');
|
|
50
50
|
const showInvalid = invalid && (touched ?? true);
|
|
51
51
|
const [page, setPage] = useState(() => initialPage(current, selectionMode, today));
|
|
@@ -53,7 +53,7 @@ export function KptDatepicker({ value, defaultValue = '', onValueChange, selecti
|
|
|
53
53
|
const [timeStr, setTimeStr] = useState('');
|
|
54
54
|
const [pendingDate, setPendingDate] = useState('');
|
|
55
55
|
const [dtView, setDtView] = useState('calendar');
|
|
56
|
-
/** Dzień z fokusem w siatce dni
|
|
56
|
+
/** Dzień z fokusem w siatce dni - jedyny przystanek Tab siatki (roving tabindex). */
|
|
57
57
|
const [focusIso, setFocusIso] = useState('');
|
|
58
58
|
/** Komórka z fokusem w siatkach miesięcy, lat i dekad. */
|
|
59
59
|
const [focusCell, setFocusCell] = useState(0);
|
|
@@ -61,16 +61,16 @@ export function KptDatepicker({ value, defaultValue = '', onValueChange, selecti
|
|
|
61
61
|
const panelRef = useRef(null);
|
|
62
62
|
/**
|
|
63
63
|
* Prośba o przeniesienie fokusu po najbliższym renderze (otwarcie, ruch klawiszem, zmiana
|
|
64
|
-
* poziomu)
|
|
64
|
+
* poziomu) - licznik w stanie, nie ref zapisywany w renderze.
|
|
65
65
|
*/
|
|
66
66
|
const [focusRequest, setFocusRequest] = useState(0);
|
|
67
67
|
const requestFocus = () => setFocusRequest((n) => n + 1);
|
|
68
68
|
const months = monthNames(activeLocale);
|
|
69
69
|
const weekdays = orderWeekdays(weekdayNames(activeLocale), firstDay);
|
|
70
70
|
const commitLevel = commitLevelFor(selectionMode);
|
|
71
|
-
// Panel można otworzyć także z zewnątrz (`open`), nie tylko klikiem w trigger
|
|
72
|
-
// czasu ustawiamy więc przy każdym przejściu w stan otwarty. Wzorzec
|
|
73
|
-
// w stanie
|
|
71
|
+
// Panel można otworzyć także z zewnątrz (`open`), nie tylko klikiem w trigger - widok i bufor
|
|
72
|
+
// czasu ustawiamy więc przy każdym przejściu w stan otwarty. Wzorzec "poprzednia wartość
|
|
73
|
+
// w stanie" z react.dev: stan liczy się w tym samym renderze, bez efektu i bez klatki ze starym
|
|
74
74
|
// widokiem. Późniejsze zmiany wartości w otwartym panelu go nie resetują.
|
|
75
75
|
const [wasOpen, setWasOpen] = useState(isOpen);
|
|
76
76
|
if (wasOpen !== isOpen) {
|
|
@@ -114,12 +114,12 @@ export function KptDatepicker({ value, defaultValue = '', onValueChange, selecti
|
|
|
114
114
|
setOpen(false);
|
|
115
115
|
onTouch?.();
|
|
116
116
|
};
|
|
117
|
-
/** Zamknięcie z powrotem fokusu na pole
|
|
117
|
+
/** Zamknięcie z powrotem fokusu na pole - po wyborze z klawiatury, `Escape`. */
|
|
118
118
|
const closeAndFocus = () => {
|
|
119
119
|
close();
|
|
120
120
|
triggerRef.current?.focus();
|
|
121
121
|
};
|
|
122
|
-
// Fokus po renderze. Panel w nakładce jest niewidoczny do pierwszego pomiaru
|
|
122
|
+
// Fokus po renderze. Panel w nakładce jest niewidoczny do pierwszego pomiaru - stąd rAF.
|
|
123
123
|
// `focusIso` czytamy przez zdarzenie efektu: liczy się prośba, nie każda zmiana dnia.
|
|
124
124
|
const focusActive = useEffectEvent(() => focusCalendarActive(panelRef.current, focusIso));
|
|
125
125
|
useEffect(() => {
|
|
@@ -128,7 +128,7 @@ export function KptDatepicker({ value, defaultValue = '', onValueChange, selecti
|
|
|
128
128
|
const frame = requestAnimationFrame(() => focusActive());
|
|
129
129
|
return () => cancelAnimationFrame(frame);
|
|
130
130
|
}, [focusRequest, isOpen]);
|
|
131
|
-
//
|
|
131
|
+
// -- Prezentacja w triggerze --
|
|
132
132
|
const effectivePlaceholder = (() => {
|
|
133
133
|
if (placeholder)
|
|
134
134
|
return placeholder;
|
|
@@ -149,7 +149,7 @@ export function KptDatepicker({ value, defaultValue = '', onValueChange, selecti
|
|
|
149
149
|
return datePlaceholder(displayFormat, tokens, 'date', activeLocale);
|
|
150
150
|
}
|
|
151
151
|
})();
|
|
152
|
-
/** Wartość niepasująca do formatu trybu daje pusty tekst
|
|
152
|
+
/** Wartość niepasująca do formatu trybu daje pusty tekst - trigger nie pokazuje śmieci. */
|
|
153
153
|
const display = (() => {
|
|
154
154
|
if (!current)
|
|
155
155
|
return '';
|
|
@@ -179,7 +179,7 @@ export function KptDatepicker({ value, defaultValue = '', onValueChange, selecti
|
|
|
179
179
|
return displayDate(current, displayFormat, activeLocale);
|
|
180
180
|
}
|
|
181
181
|
})();
|
|
182
|
-
//
|
|
182
|
+
// -- Siatki --
|
|
183
183
|
const selectedDateIso = selectionMode === 'datetime' ? pendingDate : current;
|
|
184
184
|
const weeks = buildDayGrid({ page, selectedIso: selectedDateIso, todayIso, minDate, maxDate, firstDay });
|
|
185
185
|
const selectedYM = selectedYearMonth(selectionMode === 'datetime' ? pendingDate : current, selectionMode);
|
|
@@ -205,7 +205,7 @@ export function KptDatepicker({ value, defaultValue = '', onValueChange, selecti
|
|
|
205
205
|
return now >= 0 ? now : Math.max(0, levelCells.findIndex((c) => !c.disabled));
|
|
206
206
|
})();
|
|
207
207
|
const activeCell = focusCell >= 0 && focusCell < levelCells.length ? focusCell : defaultCell;
|
|
208
|
-
/** Pełna nazwa dnia dla czytnika (
|
|
208
|
+
/** Pełna nazwa dnia dla czytnika ("czwartek, 8 października 2026") - sama liczba nic nie mówi. */
|
|
209
209
|
const dayFormat = new Intl.DateTimeFormat(activeLocale, { weekday: 'long', day: 'numeric', month: 'long', year: 'numeric' });
|
|
210
210
|
const dayName = (iso) => {
|
|
211
211
|
const date = parseDate(iso);
|
|
@@ -231,20 +231,20 @@ export function KptDatepicker({ value, defaultValue = '', onValueChange, selecti
|
|
|
231
231
|
setFocusCell(next);
|
|
232
232
|
requestFocus();
|
|
233
233
|
};
|
|
234
|
-
/** Tytuł, który kliknięto, znika razem z poziomem
|
|
234
|
+
/** Tytuł, który kliknięto, znika razem z poziomem - fokus idzie do nowej siatki. */
|
|
235
235
|
const goTo = (level) => {
|
|
236
236
|
setPanelView(level);
|
|
237
237
|
setFocusCell(-1);
|
|
238
238
|
requestFocus();
|
|
239
239
|
};
|
|
240
|
-
/** Strzałki
|
|
240
|
+
/** Strzałki < >: fokus zostaje na strzałce, ale przystanek siatki dni idzie za stroną. */
|
|
241
241
|
const turnPage = (dir) => {
|
|
242
242
|
const next = pageBy(page, panelView, dir);
|
|
243
243
|
setPage(next);
|
|
244
244
|
setPageAnnouncement(pageTitle(next));
|
|
245
245
|
if (panelView === 'day') {
|
|
246
246
|
const moved = moveFocusDate(focusIso, dir === 1 ? 'PageDown' : 'PageUp', { minDate, maxDate, firstDay });
|
|
247
|
-
// Dzień przycięty do granicy może leżeć poza nową stroną
|
|
247
|
+
// Dzień przycięty do granicy może leżeć poza nową stroną - wtedy pierwszy dozwolony dzień miesiąca.
|
|
248
248
|
const inPage = moved?.startsWith(`${next.y}-${pad(next.m + 1)}`);
|
|
249
249
|
const fallback = buildDayGrid({ page: next, selectedIso: selectedDateIso, todayIso, minDate, maxDate, firstDay })
|
|
250
250
|
.flat()
|
|
@@ -257,7 +257,7 @@ export function KptDatepicker({ value, defaultValue = '', onValueChange, selecti
|
|
|
257
257
|
setFocusCell(-1);
|
|
258
258
|
}
|
|
259
259
|
};
|
|
260
|
-
/** Tytuł strony do ogłoszenia
|
|
260
|
+
/** Tytuł strony do ogłoszenia - miesiąc z rokiem, rok albo zakres lat. */
|
|
261
261
|
const pageTitle = (target) => {
|
|
262
262
|
switch (panelView) {
|
|
263
263
|
case 'day':
|
|
@@ -265,9 +265,9 @@ export function KptDatepicker({ value, defaultValue = '', onValueChange, selecti
|
|
|
265
265
|
case 'month':
|
|
266
266
|
return String(target.y);
|
|
267
267
|
case 'year':
|
|
268
|
-
return `${decadeStart(target.y)}
|
|
268
|
+
return `${decadeStart(target.y)} - ${decadeStart(target.y) + 9}`;
|
|
269
269
|
default:
|
|
270
|
-
return `${centuryStart(target.y)}
|
|
270
|
+
return `${centuryStart(target.y)} - ${centuryStart(target.y) + 119}`;
|
|
271
271
|
}
|
|
272
272
|
};
|
|
273
273
|
const navLabel = (dir) => {
|
|
@@ -282,12 +282,12 @@ export function KptDatepicker({ value, defaultValue = '', onValueChange, selecti
|
|
|
282
282
|
return t(dir === 'prev' ? 'datepicker.prevMonth' : 'datepicker.nextMonth');
|
|
283
283
|
}
|
|
284
284
|
};
|
|
285
|
-
//
|
|
285
|
+
// -- Wybór --
|
|
286
286
|
const selectDay = (iso, cellDisabled) => {
|
|
287
287
|
if (cellDisabled)
|
|
288
288
|
return;
|
|
289
289
|
if (selectionMode === 'datetime') {
|
|
290
|
-
setPendingDate(iso); // czas jeszcze do wyboru
|
|
290
|
+
setPendingDate(iso); // czas jeszcze do wyboru - zamyka dopiero "Gotowe"
|
|
291
291
|
return;
|
|
292
292
|
}
|
|
293
293
|
setCurrent(iso);
|
|
@@ -333,7 +333,7 @@ export function KptDatepicker({ value, defaultValue = '', onValueChange, selecti
|
|
|
333
333
|
return;
|
|
334
334
|
setCurrent('');
|
|
335
335
|
setPendingDate('');
|
|
336
|
-
// Wyczyszczenie to interakcja z polem
|
|
336
|
+
// Wyczyszczenie to interakcja z polem - błąd "wymagane" ma się pokazać od razu.
|
|
337
337
|
onTouch?.();
|
|
338
338
|
};
|
|
339
339
|
const timeParts = parseTime(timeStr);
|
|
@@ -353,7 +353,7 @@ export function KptDatepicker({ value, defaultValue = '', onValueChange, selecti
|
|
|
353
353
|
clear(event);
|
|
354
354
|
}
|
|
355
355
|
},
|
|
356
|
-
// Przy otwartym panelu fokus idzie do kalendarza
|
|
356
|
+
// Przy otwartym panelu fokus idzie do kalendarza - "dotknięcie" wyśle dopiero zamknięcie.
|
|
357
357
|
onBlur: () => !isOpen && onTouch?.(), children: [display ? (_jsx("span", { className: "kpt-datepicker__value", children: display })) : (_jsx("span", { className: "kpt-datepicker__placeholder", children: effectivePlaceholder })), _jsx("span", { className: "kpt-datepicker__spacer" }), display && !readOnly ? (_jsx("button", { type: "button", className: "kpt-datepicker__clear", tabIndex: -1, onClick: clear, "aria-label": t('common.clear'), children: _jsx(KptIcon, { name: "x" }) })) : null, _jsx(KptIcon, { className: "kpt-datepicker__icon", name: selectionMode === 'time' ? 'clock' : 'calendar' })] }), _jsx(KptOverlay, { open: isOpen, anchor: anchor, onClose: close, offset: 4, children: _jsxs("div", { ref: panelRef, id: panelId, role: "dialog", "aria-label": t('datepicker.dialog'), className: cn('kpt-calendar', showClock && 'kpt-calendar--clock'), onKeyDown: (event) => {
|
|
358
358
|
if (event.key === 'Escape') {
|
|
359
359
|
event.preventDefault();
|
|
@@ -363,5 +363,5 @@ export function KptDatepicker({ value, defaultValue = '', onValueChange, selecti
|
|
|
363
363
|
else if (event.key === 'Tab') {
|
|
364
364
|
trapTab(event.currentTarget, event.nativeEvent);
|
|
365
365
|
}
|
|
366
|
-
}, children: [showClock ? (_jsxs(_Fragment, { children: [selectionMode === 'datetime' ? (_jsxs("div", { className: "kpt-calendar__header", children: [_jsx("button", { type: "button", className: "kpt-calendar__nav", onClick: () => setDtView('calendar'), "aria-label": t('datepicker.calendar'), children: _jsx(KptIcon, { name: "chevron-left" }) }), _jsx("span", { className: "kpt-calendar__title", children: t('datepicker.time') })] })) : null, _jsx(KptClock, { value: timeStr, onValueChange: setTimeStr, hourFormat: hourFormat, minuteStep: minuteStep })] })) : (_jsxs(_Fragment, { children: [_jsx("span", { className: "kpt-calendar__live", "aria-live": "polite", children: pageAnnouncement }), _jsxs("div", { className: "kpt-calendar__header", children: [hasNav ? (_jsx("button", { type: "button", className: "kpt-calendar__nav", disabled: !canPageBack(page, panelView, minDate), onClick: () => turnPage(-1), "aria-label": navLabel('prev'), children: _jsx(KptIcon, { name: "chevron-left" }) })) : null, _jsxs("span", { className: "kpt-calendar__titles", children: [panelView === 'day' ? (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", className: "kpt-calendar__title-btn", onClick: () => goTo('month'), "aria-label": `${months[page.m]}, ${t('datepicker.chooseMonth')}`, children: months[page.m] }), _jsx("button", { type: "button", className: "kpt-calendar__title-btn", onClick: () => goTo('year'), "aria-label": `${page.y}, ${t('datepicker.chooseYear')}`, children: page.y })] })) : null, panelView === 'month' ? (selectionMode === 'month' ? (_jsx("span", { className: "kpt-calendar__title", children: t('datepicker.month') })) : (_jsx("button", { type: "button", className: "kpt-calendar__title-btn", onClick: () => goTo('year'), "aria-label": `${page.y}, ${t('datepicker.chooseYear')}`, children: page.y }))) : null, panelView === 'year' ? (_jsx("button", { type: "button", className: "kpt-calendar__title-btn", onClick: () => goTo('decade'), "aria-label": `${decadeStart(page.y)}
|
|
366
|
+
}, children: [showClock ? (_jsxs(_Fragment, { children: [selectionMode === 'datetime' ? (_jsxs("div", { className: "kpt-calendar__header", children: [_jsx("button", { type: "button", className: "kpt-calendar__nav", onClick: () => setDtView('calendar'), "aria-label": t('datepicker.calendar'), children: _jsx(KptIcon, { name: "chevron-left" }) }), _jsx("span", { className: "kpt-calendar__title", children: t('datepicker.time') })] })) : null, _jsx(KptClock, { value: timeStr, onValueChange: setTimeStr, hourFormat: hourFormat, minuteStep: minuteStep })] })) : (_jsxs(_Fragment, { children: [_jsx("span", { className: "kpt-calendar__live", "aria-live": "polite", children: pageAnnouncement }), _jsxs("div", { className: "kpt-calendar__header", children: [hasNav ? (_jsx("button", { type: "button", className: "kpt-calendar__nav", disabled: !canPageBack(page, panelView, minDate), onClick: () => turnPage(-1), "aria-label": navLabel('prev'), children: _jsx(KptIcon, { name: "chevron-left" }) })) : null, _jsxs("span", { className: "kpt-calendar__titles", children: [panelView === 'day' ? (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", className: "kpt-calendar__title-btn", onClick: () => goTo('month'), "aria-label": `${months[page.m]}, ${t('datepicker.chooseMonth')}`, children: months[page.m] }), _jsx("button", { type: "button", className: "kpt-calendar__title-btn", onClick: () => goTo('year'), "aria-label": `${page.y}, ${t('datepicker.chooseYear')}`, children: page.y })] })) : null, panelView === 'month' ? (selectionMode === 'month' ? (_jsx("span", { className: "kpt-calendar__title", children: t('datepicker.month') })) : (_jsx("button", { type: "button", className: "kpt-calendar__title-btn", onClick: () => goTo('year'), "aria-label": `${page.y}, ${t('datepicker.chooseYear')}`, children: page.y }))) : null, panelView === 'year' ? (_jsx("button", { type: "button", className: "kpt-calendar__title-btn", onClick: () => goTo('decade'), "aria-label": `${decadeStart(page.y)} - ${decadeStart(page.y) + 9}, ${t('datepicker.chooseDecade')}`, children: `${decadeStart(page.y)} - ${decadeStart(page.y) + 9}` })) : null, panelView === 'decade' ? (_jsx("span", { className: "kpt-calendar__title", children: `${centuryStart(page.y)} - ${centuryStart(page.y) + 119}` })) : null] }), hasNav ? (_jsx("button", { type: "button", className: "kpt-calendar__nav", disabled: !canPageForward(page, panelView, maxDate), onClick: () => turnPage(1), "aria-label": navLabel('next'), children: _jsx(KptIcon, { name: "chevron-right" }) })) : null] }), panelView === 'day' ? (_jsxs(_Fragment, { children: [_jsx("div", { className: "kpt-calendar__weekdays", children: weekdays.map((weekday) => (_jsx("span", { className: "kpt-calendar__weekday", children: weekday }, weekday))) }), _jsx("div", { className: "kpt-calendar__grid", onKeyDown: onDayKeyDown, children: weeks.flat().map((cell) => (_jsx("button", { type: "button", className: cn('kpt-calendar__day', !cell.inMonth && 'kpt-calendar__day--muted', cell.today && 'kpt-calendar__day--today', cell.selected && 'kpt-calendar__day--selected'), "data-iso": cell.iso, tabIndex: cell.iso === focusIso ? 0 : -1, "aria-label": dayName(cell.iso), "aria-current": cell.today ? 'date' : undefined, disabled: cell.disabled, "aria-pressed": cell.selected, onClick: () => selectDay(cell.iso, cell.disabled), children: cell.day }, cell.iso))) })] })) : (_jsx("div", { className: cn('kpt-calendar__grid kpt-calendar__grid--cells', panelView === 'decade' && 'kpt-calendar__grid--decades'), onKeyDown: onCellKeyDown, children: levelCells.map((cell, index) => (_jsx("button", { type: "button", className: cn('kpt-calendar__cell', cell.selected && 'kpt-calendar__cell--selected', cell.current && 'kpt-calendar__cell--current'), tabIndex: index === activeCell ? 0 : -1, disabled: cell.disabled, "aria-pressed": cell.selected, onClick: () => selectCell(cell), children: cell.label }, cell.label))) })), selectionMode === 'datetime' ? (_jsxs("button", { type: "button", className: "kpt-calendar__timebar", onClick: () => setDtView('clock'), children: [_jsx(KptIcon, { name: "clock" }), _jsx("span", { children: formatTime(timeParts?.h ?? 0, timeParts?.m ?? 0, hourFormat, periods) })] })) : null] })), hasFooter ? (_jsx("div", { className: "kpt-calendar__footer", children: _jsx(KptButton, { size: "sm", onClick: commit, children: t('common.done') }) })) : null] }) })] }));
|
|
367
367
|
}
|