@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
|
@@ -1,30 +1,43 @@
|
|
|
1
1
|
import { type ComponentPropsWithRef } from 'react';
|
|
2
|
+
import type { KptSpeechMode } from '@konce-pt/speech';
|
|
2
3
|
import type { KptHostProps } from '../internal/types.ts';
|
|
4
|
+
import { type KptSpeechColor } from '../speech/speech-button.tsx';
|
|
3
5
|
export interface KptTextareaProps extends Omit<ComponentPropsWithRef<'textarea'>, 'required'> {
|
|
4
6
|
/** Dopasowuje wysokość pola do treści przy każdej zmianie. */
|
|
5
7
|
autoResize?: boolean;
|
|
6
8
|
/** Oznacza pole jako wymagane atrybutem `aria-required`, a NIE natywnym `required`. */
|
|
7
9
|
required?: boolean;
|
|
8
|
-
/** Licznik
|
|
10
|
+
/** Licznik "12 / 280" pod polem (wymaga `maxLength`), czytany razem z polem przez `aria-describedby`. */
|
|
9
11
|
counter?: boolean;
|
|
10
12
|
/** Pole jest nieprawidłowe. Widoczne dopiero, gdy `touched` też jest prawdziwe. */
|
|
11
13
|
invalid?: boolean;
|
|
12
14
|
/** Czy pole było dotknięte; pominięty = stan błędu pokazuje się od razu po `invalid`. */
|
|
13
15
|
touched?: boolean;
|
|
14
|
-
/** Wygodniejszy odpowiednik `onChange`
|
|
16
|
+
/** Wygodniejszy odpowiednik `onChange` - dostaje samą wartość. */
|
|
15
17
|
onValueChange?: (value: string) => void;
|
|
16
|
-
/** Wywoływane na `blur`
|
|
18
|
+
/** Wywoływane na `blur` - moment, w którym pole staje się dotknięte. */
|
|
17
19
|
onTouch?: () => void;
|
|
18
20
|
/** Propsy wrappera hosta (`.kpt-textarea-host`). `className` i `ref` idą na `<textarea>`. */
|
|
19
21
|
hostProps?: KptHostProps<'span'>;
|
|
22
|
+
/**
|
|
23
|
+
* Mikrofon w górnym rogu pola (Web Speech API); dolny róg zostaje dla uchwytu zmiany rozmiaru.
|
|
24
|
+
* Bez wsparcia przeglądarki się nie pokazuje.
|
|
25
|
+
*/
|
|
26
|
+
speech?: boolean;
|
|
27
|
+
/** Język dyktowania (BCP 47); bez niego z `KptI18nProvider`. */
|
|
28
|
+
speechLang?: string;
|
|
29
|
+
/** Kolor "stop" i fali w trakcie nasłuchu; domyślnie kolor motywu. */
|
|
30
|
+
speechColor?: KptSpeechColor;
|
|
31
|
+
/** `insert` (domyślnie, w kursor), `append` albo `replace` (czyści pole w chwili kliknięcia). */
|
|
32
|
+
speechMode?: KptSpeechMode;
|
|
20
33
|
}
|
|
21
34
|
/**
|
|
22
35
|
* Pole wieloliniowe (textarea), z opcjonalnym auto-resize.
|
|
23
36
|
*
|
|
24
|
-
* Działa kontrolowane (`value` + `onValueChange`) i niekontrolowane (`defaultValue`)
|
|
37
|
+
* Działa kontrolowane (`value` + `onValueChange`) i niekontrolowane (`defaultValue`) - auto-resize
|
|
25
38
|
* czyta wysokość wprost z DOM, więc jest poprawny w obu trybach, także dla wartości początkowej.
|
|
26
39
|
*
|
|
27
40
|
* @example
|
|
28
|
-
* <KptTextarea name="notes" placeholder="Notatki
|
|
41
|
+
* <KptTextarea name="notes" placeholder="Notatki..." autoResize />
|
|
29
42
|
*/
|
|
30
|
-
export declare function KptTextarea({ autoResize, required, invalid, touched, onValueChange, onTouch, hostProps, className, id, rows, onChange, onBlur, ref, 'aria-invalid': ariaInvalid, 'aria-describedby': ariaDescribedBy, counter, ...rest }: Readonly<KptTextareaProps>): import("react").JSX.Element;
|
|
43
|
+
export declare function KptTextarea({ autoResize, required, invalid, touched, onValueChange, onTouch, hostProps, className, id, rows, onChange, onBlur, ref, 'aria-invalid': ariaInvalid, 'aria-describedby': ariaDescribedBy, counter, speech, speechLang, speechColor, speechMode, ...rest }: Readonly<KptTextareaProps>): import("react").JSX.Element;
|
|
@@ -4,36 +4,49 @@ import { useCallback, useLayoutEffect, useRef, useState } from 'react';
|
|
|
4
4
|
import { cn } from "../internal/cn.js";
|
|
5
5
|
import { composeRefs } from "../internal/compose-refs.js";
|
|
6
6
|
import { joinIds, useKptFieldA11y } from "../form-field/form-field-context.js";
|
|
7
|
+
import { KptSpeechButton } from "../speech/speech-button.js";
|
|
8
|
+
import { useKptSpeechRecognition } from "../speech/use-speech-recognition.js";
|
|
7
9
|
/**
|
|
8
10
|
* Pole wieloliniowe (textarea), z opcjonalnym auto-resize.
|
|
9
11
|
*
|
|
10
|
-
* Działa kontrolowane (`value` + `onValueChange`) i niekontrolowane (`defaultValue`)
|
|
12
|
+
* Działa kontrolowane (`value` + `onValueChange`) i niekontrolowane (`defaultValue`) - auto-resize
|
|
11
13
|
* czyta wysokość wprost z DOM, więc jest poprawny w obu trybach, także dla wartości początkowej.
|
|
12
14
|
*
|
|
13
15
|
* @example
|
|
14
|
-
* <KptTextarea name="notes" placeholder="Notatki
|
|
16
|
+
* <KptTextarea name="notes" placeholder="Notatki..." autoResize />
|
|
15
17
|
*/
|
|
16
|
-
export function KptTextarea({ autoResize = false, required = false, invalid = false, touched, onValueChange, onTouch, hostProps, className, id, rows = 3, onChange, onBlur, ref, 'aria-invalid': ariaInvalid, 'aria-describedby': ariaDescribedBy, counter = false, ...rest }) {
|
|
18
|
+
export function KptTextarea({ autoResize = false, required = false, invalid = false, touched, onValueChange, onTouch, hostProps, className, id, rows = 3, onChange, onBlur, ref, 'aria-invalid': ariaInvalid, 'aria-describedby': ariaDescribedBy, counter = false, speech = false, speechLang, speechColor, speechMode = 'insert', ...rest }) {
|
|
17
19
|
const { className: hostClassName, ...hostRest } = hostProps ?? {};
|
|
18
20
|
const field = useKptFieldA11y(id, 'kpt-textarea');
|
|
19
21
|
const textareaId = field.id;
|
|
20
22
|
const innerRef = useRef(null);
|
|
21
|
-
// Długość tekstu dla licznika: w trybie kontrolowanym z `value`, w niekontrolowanym
|
|
23
|
+
// Długość tekstu dla licznika: w trybie kontrolowanym z `value`, w niekontrolowanym - z wpisów.
|
|
22
24
|
const [typedLength, setTypedLength] = useState(() => String(rest.value ?? rest.defaultValue ?? '').length);
|
|
23
25
|
const length = rest.value !== undefined ? String(rest.value).length : typedLength;
|
|
24
26
|
const showCounter = counter && !!rest.maxLength;
|
|
25
27
|
const counterId = `${textareaId}-counter`;
|
|
26
28
|
const showInvalid = invalid && (touched ?? true);
|
|
29
|
+
// Dyktowanie: przed pomiarem wysokości - hook przywraca tekst tymczasowy w swoim efekcie
|
|
30
|
+
// układu, więc `resize` niżej liczy pole razem z nim. Bez `speech` kontroler nie tworzy sesji.
|
|
31
|
+
const mic = useKptSpeechRecognition({
|
|
32
|
+
enabled: speech,
|
|
33
|
+
target: innerRef,
|
|
34
|
+
lang: speechLang,
|
|
35
|
+
mode: speechMode,
|
|
36
|
+
continuous: speechMode !== 'replace',
|
|
37
|
+
disabled: !!rest.disabled || !!rest.readOnly,
|
|
38
|
+
});
|
|
39
|
+
const speechState = speech && mic.available ? (mic.listening ? 'listening' : 'idle') : undefined;
|
|
27
40
|
const resize = useCallback(() => {
|
|
28
41
|
const el = innerRef.current;
|
|
29
42
|
if (!el || !autoResize)
|
|
30
43
|
return;
|
|
31
|
-
// Zerowanie przed odczytem `scrollHeight` jest konieczne
|
|
44
|
+
// Zerowanie przed odczytem `scrollHeight` jest konieczne - bez niego pole potrafi tylko
|
|
32
45
|
// rosnąć, bo `scrollHeight` nigdy nie spada poniżej bieżącej wysokości.
|
|
33
46
|
el.style.height = 'auto';
|
|
34
47
|
el.style.height = `${el.scrollHeight}px`;
|
|
35
48
|
}, [autoResize]);
|
|
36
|
-
// Wartość początkowa i każda zmiana z zewnątrz (tryb kontrolowany)
|
|
49
|
+
// Wartość początkowa i każda zmiana z zewnątrz (tryb kontrolowany) - przed malowaniem,
|
|
37
50
|
// żeby pole nie mrugnęło niedopasowaną wysokością.
|
|
38
51
|
useLayoutEffect(resize);
|
|
39
52
|
const handleChange = useCallback((event) => {
|
|
@@ -46,5 +59,6 @@ export function KptTextarea({ autoResize = false, required = false, invalid = fa
|
|
|
46
59
|
onBlur?.(event);
|
|
47
60
|
onTouch?.();
|
|
48
61
|
}, [onBlur, onTouch]);
|
|
49
|
-
|
|
62
|
+
const textarea = (_jsx("textarea", { className: cn('kpt-textarea__field', className), id: textareaId, "aria-describedby": joinIds(ariaDescribedBy, field.describedBy, showCounter && counterId), rows: rows, ref: composeRefs(innerRef, ref), "aria-required": required || undefined, "aria-invalid": ariaInvalid ?? (showInvalid || undefined), onChange: handleChange, onBlur: handleBlur, ...rest }));
|
|
63
|
+
return (_jsxs("span", { className: cn('kpt-textarea-host', hostClassName), "data-speech": speechState, ...hostRest, children: [speech ? (_jsxs("span", { className: "kpt-textarea__box", children: [textarea, _jsx(KptSpeechButton, { listeningColor: speechColor, speech: mic, size: "sm", unsupported: "hide", disabled: !!rest.disabled || !!rest.readOnly, hostProps: { className: 'kpt-textarea__speech' } })] })) : (textarea), showCounter ? (_jsxs("span", { className: "kpt-textarea__counter", id: counterId, children: [length, " / ", rest.maxLength] })) : null] }));
|
|
50
64
|
}
|
package/dist/timeline/llms.txt
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
# KptTimeline (@konce-pt/react)
|
|
2
2
|
|
|
3
|
-
A timeline
|
|
3
|
+
A timeline - a vertical list of events with markers.
|
|
4
4
|
Import: `import { KptTimeline } from '@konce-pt/react';`
|
|
5
5
|
|
|
6
6
|
## DOM
|
|
7
7
|
<div class="kpt-timeline-host">
|
|
8
8
|
<ol class="kpt-timeline">
|
|
9
9
|
<li class="kpt-timeline__item">
|
|
10
|
-
<div class="kpt-timeline__marker" data-variant="success"
|
|
10
|
+
<div class="kpt-timeline__marker" data-variant="success">...icon...</div>
|
|
11
11
|
<div class="kpt-timeline__content">
|
|
12
12
|
<div class="kpt-timeline__header">
|
|
13
13
|
<span class="kpt-timeline__title">Order created</span>
|
|
14
14
|
<span class="kpt-timeline__time">10:02</span>
|
|
15
15
|
</div>
|
|
16
|
-
<p class="kpt-timeline__desc"
|
|
16
|
+
<p class="kpt-timeline__desc">...</p>
|
|
17
17
|
</div>
|
|
18
18
|
</li>
|
|
19
19
|
</ol>
|
|
@@ -29,7 +29,7 @@ Import: `import { KptTimeline } from '@konce-pt/react';`
|
|
|
29
29
|
- `variant?`: `'neutral' | 'primary' | 'success' | 'danger' | 'warning' | 'info'` (default `'primary'`)
|
|
30
30
|
|
|
31
31
|
## The variant is an attribute, not a class
|
|
32
|
-
The marker carries `data-variant`, and the SCSS maps it to `--_color`
|
|
32
|
+
The marker carries `data-variant`, and the SCSS maps it to `--_color` - the same contract as every
|
|
33
33
|
other component in the library, so a new variant is a token, not a new class.
|
|
34
34
|
|
|
35
35
|
## The connecting line is a pseudo-element
|
|
@@ -11,7 +11,7 @@ export interface KptTimelineProps extends ComponentPropsWithRef<'div'> {
|
|
|
11
11
|
items?: readonly KptTimelineItem[];
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
|
-
* Oś czasu
|
|
14
|
+
* Oś czasu - pionowa lista zdarzeń z markerami.
|
|
15
15
|
*
|
|
16
16
|
* @example
|
|
17
17
|
* <KptTimeline items={[{ title: 'Utworzono', time: '10:00', variant: 'success', icon: 'check' }]} />
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { cn } from "../internal/cn.js";
|
|
3
3
|
import { KptIcon } from "../icon/icon.js";
|
|
4
4
|
/**
|
|
5
|
-
* Oś czasu
|
|
5
|
+
* Oś czasu - pionowa lista zdarzeń z markerami.
|
|
6
6
|
*
|
|
7
7
|
* @example
|
|
8
8
|
* <KptTimeline items={[{ title: 'Utworzono', time: '10:00', variant: 'success', icon: 'check' }]} />
|
package/dist/toast/llms.txt
CHANGED
|
@@ -5,15 +5,15 @@ Import: `import { kptToast, KptToastContainer } from '@konce-pt/react';`
|
|
|
5
5
|
|
|
6
6
|
## DOM
|
|
7
7
|
<div class="kpt-toast-container-host">
|
|
8
|
-
<div class="kpt-toast-container" role="region" aria-label="Notifications">
|
|
9
|
-
<div class="kpt-toast" data-variant="success">
|
|
10
|
-
<span class="kpt-icon-host kpt-toast__icon"
|
|
8
|
+
<div class="kpt-toast-container" role="region" data-position="bottom-end" aria-label="Notifications">
|
|
9
|
+
<div class="kpt-toast" data-variant="success" data-appearance="outline">
|
|
10
|
+
<span class="kpt-icon-host kpt-toast__icon">...</span>
|
|
11
11
|
<div class="kpt-toast__content">
|
|
12
12
|
<div class="kpt-toast__title">Saved</div>
|
|
13
13
|
<div class="kpt-toast__message">Your changes are stored.</div>
|
|
14
14
|
</div>
|
|
15
15
|
<button class="kpt-toast__action" type="button">Undo</button>
|
|
16
|
-
<button class="kpt-toast__close" type="button" aria-label="Close"
|
|
16
|
+
<button class="kpt-toast__close" type="button" aria-label="Close">...</button>
|
|
17
17
|
</div>
|
|
18
18
|
</div>
|
|
19
19
|
<span class="kpt-toast-container__live" aria-live="polite" aria-atomic="true">Saved. Your changes are stored.</span>
|
|
@@ -21,15 +21,17 @@ Import: `import { kptToast, KptToastContainer } from '@konce-pt/react';`
|
|
|
21
21
|
</div>
|
|
22
22
|
|
|
23
23
|
## kptToast
|
|
24
|
-
- `show(message, options?)`
|
|
25
|
-
- `info` / `success` / `warning` / `error`
|
|
26
|
-
- `dismiss(id)`, `clear()`, `pause()`, `resume()`
|
|
27
|
-
- options: `title`, `variant`, `duration` (ms, default 4000; `0` disables auto-dismiss), `action: { label, run }
|
|
24
|
+
- `show(message, options?)` - returns the toast id
|
|
25
|
+
- `info` / `success` / `warning` / `error` - the same, with the variant preset
|
|
26
|
+
- `dismiss(id)`, `clear()`, `pause()`, `resume()`, `configure(config)`
|
|
27
|
+
- options: `title`, `variant`, `duration` (ms, default 4000; `0` disables auto-dismiss), `action: { label, run }`,
|
|
28
|
+
`position`, `appearance` ('outline' | 'filled'), `closable` (default true), `progress` (default false)
|
|
29
|
+
- `useKptToasts()`, `useKptToastsPaused()` - the queue and the paused state as hooks
|
|
28
30
|
|
|
29
31
|
## A module singleton, not a provider
|
|
30
32
|
The store lives in the module, which is the closest equivalent of Angular's
|
|
31
|
-
`providedIn: 'root'`. `kptToast.error(...)` therefore works from anywhere
|
|
32
|
-
React tree, in a data-layer error handler or an HTTP interceptor
|
|
33
|
+
`providedIn: 'root'`. `kptToast.error(...)` therefore works from anywhere - including outside the
|
|
34
|
+
React tree, in a data-layer error handler or an HTTP interceptor - with no provider wrapping the
|
|
33
35
|
application. `useKptToasts()` exposes the current list when you want to render them yourself.
|
|
34
36
|
|
|
35
37
|
## Placement
|
|
@@ -42,26 +44,54 @@ mounts are kept in the store and appear as soon as it does.
|
|
|
42
44
|
|
|
43
45
|
kptToast.success('Saved', { title: 'Saved' });
|
|
44
46
|
kptToast.error('Could not connect to the server.', { title: 'Error', duration: 0 });
|
|
45
|
-
const id = kptToast.info('Uploading
|
|
47
|
+
const id = kptToast.info('Uploading...', { duration: 0 });
|
|
46
48
|
kptToast.dismiss(id);
|
|
47
49
|
|
|
50
|
+
## Position
|
|
51
|
+
`<KptToastContainer position="top-end" />` - the corner for toasts without their own `position`:
|
|
52
|
+
`top-start`, `top-center`, `top-end`, `bottom-start`, `bottom-center`, `bottom-end` (default).
|
|
53
|
+
`start`/`end` are logical (they swap in RTL). Each corner is its own stack (`data-position`); the
|
|
54
|
+
newest toast is always next to the edge (bottom of a bottom stack, top of a top one) and slides in
|
|
55
|
+
from it. Distance from the edge: `--kpt-toast-offset` (default `--kpt-space-4`) plus the safe area;
|
|
56
|
+
below 40rem a stack takes the full width. One toast can go elsewhere: `{ position: 'bottom-center' }`.
|
|
57
|
+
|
|
58
|
+
## Appearance
|
|
59
|
+
`appearance: 'outline'` (default) - a raised surface with the accent on the start edge;
|
|
60
|
+
`'filled'` - the whole toast in the variant colour, content in `--kpt-color-<role>-contrast` (white
|
|
61
|
+
on every variant in the light theme, dark in the dark theme).
|
|
62
|
+
Icon, text, action and close button are centred on one axis.
|
|
63
|
+
|
|
64
|
+
## Closing and the time bar
|
|
65
|
+
`closable: false` hides the close button. A toast without the close button, without an action and
|
|
66
|
+
with `duration: 0` could never be closed, so it gets `KPT_TOAST_FALLBACK_DURATION` (5000 ms).
|
|
67
|
+
`progress: true` draws a time bar at the bottom that shrinks over `duration` and stops while the
|
|
68
|
+
timers are paused (`useKptToastsPaused()` -> `data-paused` on the stack). It ignores the motion switch -
|
|
69
|
+
it shows time, it is not decoration.
|
|
70
|
+
|
|
71
|
+
## App-wide defaults
|
|
72
|
+
kptToast.configure({ appearance: 'filled', progress: true, duration: 5000 }); // once, at startup
|
|
73
|
+
`KptToastConfig`: `duration`, `appearance`, `closable`, `progress`. Order: toast option >
|
|
74
|
+
`kptToast.configure` > library default. `resolveKptToast(id, message, options, config)` is the same
|
|
75
|
+
resolution as a pure function.
|
|
76
|
+
|
|
48
77
|
## Actions and pausing
|
|
49
|
-
`action: { label, run }` adds one button to the toast (typically
|
|
78
|
+
`action: { label, run }` adds one button to the toast (typically "Undo"); a click calls `run` and
|
|
50
79
|
dismisses the toast. Give such toasts a longer `duration`, and keep the action available elsewhere.
|
|
51
80
|
`pause()` / `resume()` stop and continue every timer; the container calls them on hover and focus,
|
|
52
81
|
and resumes by itself when the stack empties.
|
|
53
82
|
|
|
54
83
|
## Tokens
|
|
55
|
-
The
|
|
56
|
-
|
|
84
|
+
The accent of each variant (`--kpt-color-info` / `-success` / `-warning` / `-danger`), the content
|
|
85
|
+
of `filled` (`--kpt-color-<role>-contrast`), `--kpt-color-surface-raised`, `--kpt-elevation-3`,
|
|
86
|
+
`--kpt-toast-offset`, `--kpt-z-toast`.
|
|
57
87
|
|
|
58
88
|
## Accessibility
|
|
59
|
-
Announcements go through two permanent, visually hidden live regions next to the stack
|
|
60
|
-
`aria-live="polite"` for ordinary toasts and `aria-live="assertive"` for `danger`
|
|
89
|
+
Announcements go through two permanent, visually hidden live regions next to the stack -
|
|
90
|
+
`aria-live="polite"` for ordinary toasts and `aria-live="assertive"` for `danger` - and not through
|
|
61
91
|
the toasts themselves: a live region has to exist before content appears in it, and nested regions
|
|
62
92
|
are read twice by some screen readers. Each region is cleared before it is written, so the same
|
|
63
93
|
text twice is announced twice, and a dismissed toast never re-announces an older one. While there
|
|
64
|
-
are toasts the stack is `role="region"` named `toast.region` (
|
|
94
|
+
are toasts the stack is `role="region"` named `toast.region` ("Notifications"). Pointer or focus on
|
|
65
95
|
the stack pauses every timer (WCAG 2.2.1); the timers resume with the time that was left. The close
|
|
66
96
|
button is labelled from `common.close`.
|
|
67
97
|
|
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
import { type ComponentPropsWithRef } from 'react';
|
|
2
2
|
import { type KptI18nOverrides } from '../i18n/i18n-context.tsx';
|
|
3
|
+
import { type KptToastPosition } from './toast-store.ts';
|
|
3
4
|
export interface KptToastContainerProps extends ComponentPropsWithRef<'div'>, KptI18nOverrides {
|
|
5
|
+
/** Położenie toastów, które nie podały własnego `position`. Domyślnie `bottom-end`. */
|
|
6
|
+
position?: KptToastPosition;
|
|
4
7
|
}
|
|
5
8
|
/**
|
|
6
9
|
* Kontener renderujący toasty z `kptToast`. Umieść raz w aplikacji, np. w komponencie głównym.
|
|
7
10
|
*
|
|
8
|
-
* Ogłaszanie idzie przez dwa stałe, niewidoczne regiony na żywo
|
|
9
|
-
* i natychmiastowy dla błędów
|
|
11
|
+
* Ogłaszanie idzie przez dwa stałe, niewidoczne regiony na żywo - uprzejmy dla zwykłych toastów
|
|
12
|
+
* i natychmiastowy dla błędów - a nie przez same toasty: region musi istnieć, zanim pojawi się
|
|
10
13
|
* w nim treść, a zagnieżdżone regiony część czytników ogłasza dwa razy. Gdy wskaźnik albo fokus
|
|
11
14
|
* jest na toastach, liczniki stoją, więc komunikat nie znika w trakcie czytania.
|
|
12
15
|
*
|
|
16
|
+
* Toasty rosną w rogu z `position` kontenera albo z własnego `position` - każdy róg to osobny stos,
|
|
17
|
+
* przy górnej krawędzi najnowszy jest na górze, przy dolnej na dole.
|
|
18
|
+
*
|
|
13
19
|
* @example
|
|
14
20
|
* <KptToastContainer />
|
|
15
21
|
* // gdziekolwiek: kptToast.success('Zapisano');
|
|
16
22
|
*/
|
|
17
|
-
export declare function KptToastContainer({ locale, dictionary, className, ...rest }: Readonly<KptToastContainerProps>): import("react").JSX.Element;
|
|
23
|
+
export declare function KptToastContainer({ position, locale, dictionary, className, ...rest }: Readonly<KptToastContainerProps>): import("react").JSX.Element;
|
|
@@ -4,7 +4,9 @@ import { useEffect, useRef, useState } from 'react';
|
|
|
4
4
|
import { cn } from "../internal/cn.js";
|
|
5
5
|
import { useKptMessages } from "../i18n/i18n-context.js";
|
|
6
6
|
import { KptIcon } from "../icon/icon.js";
|
|
7
|
-
import { kptToast, useKptToasts } from "./toast-store.js";
|
|
7
|
+
import { kptToast, useKptToasts, useKptToastsPaused } from "./toast-store.js";
|
|
8
|
+
/** Kolejność grup w DOM - stała, żeby dodanie toastu w innym rogu nie przestawiało pozostałych. */
|
|
9
|
+
const POSITIONS = ['top-start', 'top-center', 'top-end', 'bottom-start', 'bottom-center', 'bottom-end'];
|
|
8
10
|
const ICONS = {
|
|
9
11
|
info: 'info',
|
|
10
12
|
success: 'circle-check',
|
|
@@ -14,21 +16,27 @@ const ICONS = {
|
|
|
14
16
|
/**
|
|
15
17
|
* Kontener renderujący toasty z `kptToast`. Umieść raz w aplikacji, np. w komponencie głównym.
|
|
16
18
|
*
|
|
17
|
-
* Ogłaszanie idzie przez dwa stałe, niewidoczne regiony na żywo
|
|
18
|
-
* i natychmiastowy dla błędów
|
|
19
|
+
* Ogłaszanie idzie przez dwa stałe, niewidoczne regiony na żywo - uprzejmy dla zwykłych toastów
|
|
20
|
+
* i natychmiastowy dla błędów - a nie przez same toasty: region musi istnieć, zanim pojawi się
|
|
19
21
|
* w nim treść, a zagnieżdżone regiony część czytników ogłasza dwa razy. Gdy wskaźnik albo fokus
|
|
20
22
|
* jest na toastach, liczniki stoją, więc komunikat nie znika w trakcie czytania.
|
|
21
23
|
*
|
|
24
|
+
* Toasty rosną w rogu z `position` kontenera albo z własnego `position` - każdy róg to osobny stos,
|
|
25
|
+
* przy górnej krawędzi najnowszy jest na górze, przy dolnej na dole.
|
|
26
|
+
*
|
|
22
27
|
* @example
|
|
23
28
|
* <KptToastContainer />
|
|
24
29
|
* // gdziekolwiek: kptToast.success('Zapisano');
|
|
25
30
|
*/
|
|
26
|
-
export function KptToastContainer({ locale, dictionary, className, ...rest }) {
|
|
31
|
+
export function KptToastContainer({ position = 'bottom-end', locale, dictionary, className, ...rest }) {
|
|
27
32
|
const { t } = useKptMessages({ locale, dictionary });
|
|
28
33
|
const toasts = useKptToasts();
|
|
34
|
+
const paused = useKptToastsPaused();
|
|
35
|
+
// Toasty pogrupowane po rogu; tylko niepuste grupy, każda w osobnym przypiętym stosie.
|
|
36
|
+
const groups = POSITIONS.map((at) => ({ position: at, toasts: toasts.filter((toast) => (toast.position ?? position) === at) })).filter((group) => group.toasts.length);
|
|
29
37
|
const [politeText, setPoliteText] = useState('');
|
|
30
38
|
const [alertText, setAlertText] = useState('');
|
|
31
|
-
// Ostatni ogłoszony toast
|
|
39
|
+
// Ostatni ogłoszony toast - zamknięcie nowszego nie może ponownie ogłosić starszego.
|
|
32
40
|
const lastAnnounced = useRef(0);
|
|
33
41
|
const holds = useRef(new Set());
|
|
34
42
|
const hold = (reason, on) => {
|
|
@@ -42,7 +50,7 @@ export function KptToastContainer({ locale, dictionary, className, ...rest }) {
|
|
|
42
50
|
kptToast.resume();
|
|
43
51
|
};
|
|
44
52
|
useEffect(() => {
|
|
45
|
-
// Pusty kontener nie dostanie już `mouseleave`, więc zdejmujemy wstrzymanie sami
|
|
53
|
+
// Pusty kontener nie dostanie już `mouseleave`, więc zdejmujemy wstrzymanie sami -
|
|
46
54
|
// inaczej kolejne toasty czekałyby w nieskończoność.
|
|
47
55
|
if (!toasts.length && holds.current.size) {
|
|
48
56
|
holds.current.clear();
|
|
@@ -56,7 +64,7 @@ export function KptToastContainer({ locale, dictionary, className, ...rest }) {
|
|
|
56
64
|
for (const toast of fresh) {
|
|
57
65
|
const text = toast.title ? `${toast.title}. ${toast.message}` : toast.message;
|
|
58
66
|
const set = toast.variant === 'danger' ? setAlertText : setPoliteText;
|
|
59
|
-
// Czyścimy region przed wpisaniem
|
|
67
|
+
// Czyścimy region przed wpisaniem - ten sam tekst drugi raz inaczej nie zostałby ogłoszony.
|
|
60
68
|
set('');
|
|
61
69
|
frames.push(requestAnimationFrame(() => set(text)));
|
|
62
70
|
}
|
|
@@ -68,8 +76,8 @@ export function KptToastContainer({ locale, dictionary, className, ...rest }) {
|
|
|
68
76
|
return;
|
|
69
77
|
hold('focus', false);
|
|
70
78
|
};
|
|
71
|
-
return (_jsxs("div", { className: cn('kpt-toast-container-host', className), ...rest, children: [_jsx("div", { className: "kpt-toast-container", role:
|
|
79
|
+
return (_jsxs("div", { className: cn('kpt-toast-container-host', className), ...rest, children: [groups.map((group) => (_jsx("div", { className: "kpt-toast-container", role: "region", "data-position": group.position, "data-paused": paused ? '' : undefined, "aria-label": t('toast.region'), onMouseEnter: () => hold('pointer', true), onMouseLeave: () => hold('pointer', false), onFocus: () => hold('focus', true), onBlur: onBlur, children: group.toasts.map((toast) => (_jsxs("div", { className: "kpt-toast", "data-variant": toast.variant, "data-appearance": toast.appearance, children: [_jsx(KptIcon, { className: "kpt-toast__icon", name: ICONS[toast.variant] }), _jsxs("div", { className: "kpt-toast__content", children: [toast.title ? _jsx("div", { className: "kpt-toast__title", children: toast.title }) : null, _jsx("div", { className: "kpt-toast__message", children: toast.message })] }), toast.action ? (_jsx("button", { className: "kpt-toast__action", type: "button", onClick: () => {
|
|
72
80
|
toast.action?.run();
|
|
73
81
|
kptToast.dismiss(toast.id);
|
|
74
|
-
}, children: toast.action.label })) : null, _jsx("button", { className: "kpt-toast__close", type: "button", onClick: () => kptToast.dismiss(toast.id), "aria-label": t('common.close'), children: _jsx(KptIcon, { name: "x" }) })] }, toast.id))) }), _jsx("span", { className: "kpt-toast-container__live", "aria-live": "polite", "aria-atomic": "true", children: politeText }), _jsx("span", { className: "kpt-toast-container__live", "aria-live": "assertive", "aria-atomic": "true", children: alertText })] }));
|
|
82
|
+
}, children: toast.action.label })) : null, toast.closable ? (_jsx("button", { className: "kpt-toast__close", type: "button", onClick: () => kptToast.dismiss(toast.id), "aria-label": t('common.close'), children: _jsx(KptIcon, { name: "x" }) })) : null, toast.progress && toast.duration > 0 ? (_jsx("span", { className: "kpt-toast__timer", "aria-hidden": "true", style: { '--_duration': `${toast.duration}ms` } })) : null] }, toast.id))) }, group.position))), _jsx("span", { className: "kpt-toast-container__live", "aria-live": "polite", "aria-atomic": "true", children: politeText }), _jsx("span", { className: "kpt-toast-container__live", "aria-live": "assertive", "aria-atomic": "true", children: alertText })] }));
|
|
75
83
|
}
|
|
@@ -1,23 +1,54 @@
|
|
|
1
1
|
import type { KptAlertVariant } from '../shared/types.ts';
|
|
2
|
-
/** Przycisk akcji w toaście, np.
|
|
2
|
+
/** Przycisk akcji w toaście, np. "Cofnij". Kliknięcie uruchamia `run` i zamyka toast. */
|
|
3
3
|
export interface KptToastAction {
|
|
4
4
|
label: string;
|
|
5
5
|
run: () => void;
|
|
6
6
|
}
|
|
7
|
+
/**
|
|
8
|
+
* Róg albo środek krawędzi okna, przy którym rosną toasty. `start`/`end` są logiczne - w układzie
|
|
9
|
+
* od prawej do lewej zamieniają się stronami same.
|
|
10
|
+
*/
|
|
11
|
+
export type KptToastPosition = 'top-start' | 'top-center' | 'top-end' | 'bottom-start' | 'bottom-center' | 'bottom-end';
|
|
12
|
+
/** `outline` - jasna powierzchnia z akcentem na krawędzi; `filled` - całe tło w barwie wariantu. */
|
|
13
|
+
export type KptToastAppearance = 'outline' | 'filled';
|
|
7
14
|
export interface KptToast {
|
|
8
15
|
id: number;
|
|
9
16
|
message: string;
|
|
10
17
|
title?: string;
|
|
11
18
|
variant: KptAlertVariant;
|
|
12
19
|
/**
|
|
13
|
-
* Czas życia w ms; 0 = bez auto-zamykania. Domyślnie 4000 ms, a dla toastu z `action`
|
|
14
|
-
* użytkownik klawiatury albo czytnika nie zdąży dojść do przycisku
|
|
15
|
-
* strony, zanim toast zniknie (WCAG 2.2.1). Jawne `duration` zawsze wygrywa
|
|
20
|
+
* Czas życia w ms; 0 = bez auto-zamykania. Domyślnie 4000 ms, a dla toastu z `action` - 0:
|
|
21
|
+
* użytkownik klawiatury albo czytnika nie zdąży dojść do przycisku "Cofnij" w kontenerze na końcu
|
|
22
|
+
* strony, zanim toast zniknie (WCAG 2.2.1). Jawne `duration` zawsze wygrywa - poza jednym
|
|
23
|
+
* przypadkiem: toast bez X, bez akcji i bez czasu nie dałby się zamknąć, więc dostaje 5000 ms.
|
|
16
24
|
*/
|
|
17
25
|
duration: number;
|
|
18
26
|
action?: KptToastAction;
|
|
27
|
+
/** Położenie tego toastu; bez wartości - `position` kontenera. */
|
|
28
|
+
position?: KptToastPosition;
|
|
29
|
+
appearance: KptToastAppearance;
|
|
30
|
+
/** `false` chowa przycisk X. */
|
|
31
|
+
closable: boolean;
|
|
32
|
+
/** Pasek czasu na dole toastu - kurczy się do zamknięcia i staje razem z licznikiem. */
|
|
33
|
+
progress: boolean;
|
|
19
34
|
}
|
|
20
35
|
export type KptToastOptions = Partial<Omit<KptToast, 'id' | 'message'>>;
|
|
36
|
+
/** Wartości domyślne toastów całej aplikacji - `kptToast.configure(...)`. Opcje toastu wygrywają. */
|
|
37
|
+
export interface KptToastConfig {
|
|
38
|
+
/** Czas życia toastu bez akcji (ms). Domyślnie 4000. */
|
|
39
|
+
duration?: number;
|
|
40
|
+
appearance?: KptToastAppearance;
|
|
41
|
+
closable?: boolean;
|
|
42
|
+
progress?: boolean;
|
|
43
|
+
}
|
|
44
|
+
/** Czas toastu, którego inaczej nie dałoby się zamknąć (bez X, bez akcji, bez czasu). */
|
|
45
|
+
export declare const KPT_TOAST_FALLBACK_DURATION = 5000;
|
|
46
|
+
/**
|
|
47
|
+
* Pełny toast z opcji i konfiguracji. Kolejność: opcja toastu > `kptToast.configure` > wartość
|
|
48
|
+
* biblioteki. Na końcu bezpiecznik: toast, którego nie da się zamknąć ani przyciskiem, ani akcją,
|
|
49
|
+
* dostaje czas, bo inaczej zostałby na ekranie na zawsze.
|
|
50
|
+
*/
|
|
51
|
+
export declare function resolveKptToast(id: number, message: string, options: KptToastOptions, config: KptToastConfig | null): KptToast;
|
|
21
52
|
declare function show(message: string, options?: KptToastOptions): number;
|
|
22
53
|
declare function dismiss(id: number): void;
|
|
23
54
|
declare function clear(): void;
|
|
@@ -25,8 +56,11 @@ declare function clear(): void;
|
|
|
25
56
|
declare function pause(): void;
|
|
26
57
|
/** Wznawia liczniki od pozostałego czasu. */
|
|
27
58
|
declare function resume(): void;
|
|
59
|
+
/** Domyślny wygląd i zachowanie toastów w całej aplikacji; wołaj raz, przy starcie. */
|
|
60
|
+
declare function configure(next: KptToastConfig): void;
|
|
28
61
|
/** Powiadomienia (toasty). Renderuje je `<KptToastContainer />`, umieszczony raz w aplikacji. */
|
|
29
62
|
export declare const kptToast: {
|
|
63
|
+
configure: typeof configure;
|
|
30
64
|
show: typeof show;
|
|
31
65
|
info: (message: string, options?: KptToastOptions) => number;
|
|
32
66
|
success: (message: string, options?: KptToastOptions) => number;
|
|
@@ -39,4 +73,6 @@ export declare const kptToast: {
|
|
|
39
73
|
};
|
|
40
74
|
/** Bieżąca lista toastów. Używane przez kontener; przydaje się też do własnego renderowania. */
|
|
41
75
|
export declare function useKptToasts(): KptToast[];
|
|
76
|
+
/** Czy liczniki stoją (wskaźnik albo fokus na toastach, albo `kptToast.pause()`). */
|
|
77
|
+
export declare function useKptToastsPaused(): boolean;
|
|
42
78
|
export {};
|
|
@@ -1,7 +1,31 @@
|
|
|
1
1
|
import { useSyncExternalStore } from 'react';
|
|
2
|
+
/** Czas toastu, którego inaczej nie dałoby się zamknąć (bez X, bez akcji, bez czasu). */
|
|
3
|
+
export const KPT_TOAST_FALLBACK_DURATION = 5000;
|
|
4
|
+
/**
|
|
5
|
+
* Pełny toast z opcji i konfiguracji. Kolejność: opcja toastu > `kptToast.configure` > wartość
|
|
6
|
+
* biblioteki. Na końcu bezpiecznik: toast, którego nie da się zamknąć ani przyciskiem, ani akcją,
|
|
7
|
+
* dostaje czas, bo inaczej zostałby na ekranie na zawsze.
|
|
8
|
+
*/
|
|
9
|
+
export function resolveKptToast(id, message, options, config) {
|
|
10
|
+
const closable = options.closable ?? config?.closable ?? true;
|
|
11
|
+
let duration = options.duration ?? (options.action ? 0 : (config?.duration ?? 4000));
|
|
12
|
+
if (!closable && !options.action && duration <= 0)
|
|
13
|
+
duration = KPT_TOAST_FALLBACK_DURATION;
|
|
14
|
+
return {
|
|
15
|
+
variant: 'info',
|
|
16
|
+
...options,
|
|
17
|
+
id,
|
|
18
|
+
message,
|
|
19
|
+
duration,
|
|
20
|
+
closable,
|
|
21
|
+
appearance: options.appearance ?? config?.appearance ?? 'outline',
|
|
22
|
+
progress: options.progress ?? config?.progress ?? false,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
2
25
|
let toasts = [];
|
|
3
26
|
let seq = 0;
|
|
4
27
|
let paused = false;
|
|
28
|
+
let config = null;
|
|
5
29
|
const timers = new Map();
|
|
6
30
|
const listeners = new Set();
|
|
7
31
|
function emit() {
|
|
@@ -10,7 +34,7 @@ function emit() {
|
|
|
10
34
|
}
|
|
11
35
|
function show(message, options = {}) {
|
|
12
36
|
const id = ++seq;
|
|
13
|
-
const toast =
|
|
37
|
+
const toast = resolveKptToast(id, message, options, config);
|
|
14
38
|
toasts = [...toasts, toast];
|
|
15
39
|
emit();
|
|
16
40
|
if (toast.duration > 0) {
|
|
@@ -48,6 +72,7 @@ function pause() {
|
|
|
48
72
|
if (paused)
|
|
49
73
|
return;
|
|
50
74
|
paused = true;
|
|
75
|
+
emit();
|
|
51
76
|
const now = Date.now();
|
|
52
77
|
for (const timer of timers.values()) {
|
|
53
78
|
if (!timer.handle)
|
|
@@ -62,11 +87,17 @@ function resume() {
|
|
|
62
87
|
if (!paused)
|
|
63
88
|
return;
|
|
64
89
|
paused = false;
|
|
90
|
+
emit();
|
|
65
91
|
for (const id of timers.keys())
|
|
66
92
|
start(id);
|
|
67
93
|
}
|
|
94
|
+
/** Domyślny wygląd i zachowanie toastów w całej aplikacji; wołaj raz, przy starcie. */
|
|
95
|
+
function configure(next) {
|
|
96
|
+
config = { ...next };
|
|
97
|
+
}
|
|
68
98
|
/** Powiadomienia (toasty). Renderuje je `<KptToastContainer />`, umieszczony raz w aplikacji. */
|
|
69
99
|
export const kptToast = {
|
|
100
|
+
configure,
|
|
70
101
|
show,
|
|
71
102
|
info: (message, options) => show(message, { ...options, variant: 'info' }),
|
|
72
103
|
success: (message, options) => show(message, { ...options, variant: 'success' }),
|
|
@@ -88,3 +119,7 @@ function subscribe(listener) {
|
|
|
88
119
|
export function useKptToasts() {
|
|
89
120
|
return useSyncExternalStore(subscribe, () => toasts, () => EMPTY);
|
|
90
121
|
}
|
|
122
|
+
/** Czy liczniki stoją (wskaźnik albo fokus na toastach, albo `kptToast.pause()`). */
|
|
123
|
+
export function useKptToastsPaused() {
|
|
124
|
+
return useSyncExternalStore(subscribe, () => paused, () => false);
|
|
125
|
+
}
|
package/dist/toolbar/llms.txt
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
# KptToolbar (@konce-pt/react)
|
|
2
2
|
|
|
3
|
-
The top bar
|
|
3
|
+
The top bar - a horizontal strip for application content (logo, actions).
|
|
4
4
|
Import: `import { KptToolbar, KptToolbarSpacer } from '@konce-pt/react';`
|
|
5
5
|
|
|
6
6
|
## DOM
|
|
7
7
|
<div class="kpt-toolbar kpt-toolbar--elevated">
|
|
8
|
-
|
|
8
|
+
...children...
|
|
9
9
|
<span kpttoolbarspacer=""></span>
|
|
10
|
-
|
|
10
|
+
...children...
|
|
11
11
|
</div>
|
|
12
12
|
|
|
13
13
|
## Props
|
|
14
|
-
- `elevated`: boolean
|
|
15
|
-
- `wrap`: boolean
|
|
14
|
+
- `elevated`: boolean - adds a shadow under the bar
|
|
15
|
+
- `wrap`: boolean - lets the content wrap onto further rows when it runs out of room
|
|
16
16
|
- `className`, `ref` and every other `<div>` prop go to the bar itself
|
|
17
17
|
|
|
18
18
|
`wrap` is opt-in because wrapping changes what `<KptToolbarSpacer>` does: in a single-row bar it
|
|
@@ -30,10 +30,10 @@ serves both ports).
|
|
|
30
30
|
<KptButton variant="text">Sign out</KptButton>
|
|
31
31
|
</KptToolbar>
|
|
32
32
|
|
|
33
|
-
<KptAppShell toolbar={<KptToolbar elevated
|
|
33
|
+
<KptAppShell toolbar={<KptToolbar elevated>...</KptToolbar>} sidenav={...}>...</KptAppShell>
|
|
34
34
|
|
|
35
35
|
## Responsiveness
|
|
36
|
-
Below the `sm` breakpoint the bar shrinks on its own
|
|
36
|
+
Below the `sm` breakpoint the bar shrinks on its own - a lower height
|
|
37
37
|
(`--kpt-toolbar-height-compact`), narrower inline padding and a smaller gap. No props involved.
|
|
38
38
|
|
|
39
39
|
## Tokens
|
|
@@ -4,13 +4,13 @@ export interface KptToolbarProps extends ComponentPropsWithRef<'div'> {
|
|
|
4
4
|
elevated?: boolean;
|
|
5
5
|
/**
|
|
6
6
|
* Pozwala zawartości paska zawinąć się do kolejnych wierszy, gdy zabraknie miejsca.
|
|
7
|
-
* Opcjonalne, bo zawijanie zmienia zachowanie `<KptToolbarSpacer>`
|
|
7
|
+
* Opcjonalne, bo zawijanie zmienia zachowanie `<KptToolbarSpacer>` - w jednowierszowym
|
|
8
8
|
* pasku rozpycha on treść, a w zawijanym potrafi zepchnąć resztę do nowego wiersza.
|
|
9
9
|
*/
|
|
10
10
|
wrap?: boolean;
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
13
|
-
* Górny pasek (toolbar)
|
|
13
|
+
* Górny pasek (toolbar) - pozioma belka na treść aplikacji (logo, akcje).
|
|
14
14
|
* Poniżej breakpointa `sm` pasek sam zbiega się do niższej wysokości i węższych marginesów.
|
|
15
15
|
*
|
|
16
16
|
* @example
|
|
@@ -22,7 +22,7 @@ export interface KptToolbarProps extends ComponentPropsWithRef<'div'> {
|
|
|
22
22
|
*/
|
|
23
23
|
export declare function KptToolbar({ elevated, wrap, className, ...rest }: Readonly<KptToolbarProps>): import("react").JSX.Element;
|
|
24
24
|
/**
|
|
25
|
-
* Elastyczny odstęp rozpychający zawartość paska. Nosi atrybut `kpttoolbarspacer`
|
|
25
|
+
* Elastyczny odstęp rozpychający zawartość paska. Nosi atrybut `kpttoolbarspacer` -
|
|
26
26
|
* to po nim celuje wspólny SCSS (nazwy atrybutów w selektorach CSS są w HTML
|
|
27
27
|
* case-insensitive, więc jedna reguła obsługuje oba porty).
|
|
28
28
|
*/
|
package/dist/toolbar/toolbar.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { cn } from "../internal/cn.js";
|
|
3
3
|
/**
|
|
4
|
-
* Górny pasek (toolbar)
|
|
4
|
+
* Górny pasek (toolbar) - pozioma belka na treść aplikacji (logo, akcje).
|
|
5
5
|
* Poniżej breakpointa `sm` pasek sam zbiega się do niższej wysokości i węższych marginesów.
|
|
6
6
|
*
|
|
7
7
|
* @example
|
|
@@ -15,7 +15,7 @@ export function KptToolbar({ elevated = false, wrap = false, className, ...rest
|
|
|
15
15
|
return (_jsx("div", { className: cn('kpt-toolbar', elevated && 'kpt-toolbar--elevated', className), "data-wrap": wrap ? '' : undefined, ...rest }));
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
|
-
* Elastyczny odstęp rozpychający zawartość paska. Nosi atrybut `kpttoolbarspacer`
|
|
18
|
+
* Elastyczny odstęp rozpychający zawartość paska. Nosi atrybut `kpttoolbarspacer` -
|
|
19
19
|
* to po nim celuje wspólny SCSS (nazwy atrybutów w selektorach CSS są w HTML
|
|
20
20
|
* case-insensitive, więc jedna reguła obsługuje oba porty).
|
|
21
21
|
*/
|