@konce-pt/react 0.11.2 → 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 +128 -64
- package/dist/accordion/accordion.d.ts +14 -6
- package/dist/accordion/accordion.js +25 -17
- package/dist/accordion/llms.txt +22 -10
- package/dist/alert/alert.d.ts +2 -2
- package/dist/alert/alert.js +3 -2
- package/dist/alert/llms.txt +10 -9
- package/dist/app-shell/app-shell.d.ts +14 -14
- package/dist/app-shell/app-shell.js +22 -15
- package/dist/app-shell/llms.txt +16 -15
- package/dist/auth/auth-types.d.ts +6 -6
- package/dist/auth/auth.d.ts +2 -2
- package/dist/auth/auth.js +24 -15
- package/dist/auth/llms.txt +12 -11
- package/dist/autocomplete/autocomplete.d.ts +19 -6
- package/dist/autocomplete/autocomplete.js +32 -11
- package/dist/autocomplete/llms.txt +19 -5
- package/dist/avatar/avatar.d.ts +6 -6
- package/dist/avatar/avatar.js +6 -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 +4 -3
- package/dist/avatar-group/llms.txt +8 -8
- package/dist/backdrop/backdrop.d.ts +7 -26
- package/dist/backdrop/backdrop.js +32 -27
- 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 +8 -3
- package/dist/bottom-sheet/bottom-sheet.js +5 -4
- package/dist/bottom-sheet/llms.txt +11 -8
- package/dist/breadcrumb/breadcrumb.d.ts +8 -2
- package/dist/breadcrumb/breadcrumb.js +11 -3
- package/dist/breadcrumb/llms.txt +10 -2
- package/dist/button/button.d.ts +3 -3
- package/dist/button/button.js +10 -9
- package/dist/button/llms.txt +27 -19
- package/dist/button-group/button-group.d.ts +18 -5
- package/dist/button-group/button-group.js +54 -6
- package/dist/button-group/llms.txt +27 -18
- package/dist/card/card.d.ts +8 -8
- package/dist/card/card.js +10 -9
- package/dist/card/llms.txt +20 -20
- package/dist/carousel/carousel.d.ts +6 -6
- package/dist/carousel/carousel.js +8 -5
- package/dist/carousel/llms.txt +10 -10
- package/dist/charts/chart-legend.d.ts +3 -3
- package/dist/charts/chart-legend.js +2 -1
- package/dist/charts/chart-tooltip.d.ts +3 -3
- package/dist/charts/chart-tooltip.js +1 -1
- package/dist/charts/chart.d.ts +4 -3
- package/dist/charts/chart.js +18 -10
- package/dist/charts/llms.txt +10 -7
- package/dist/charts-entry/public-api.js +2 -2
- package/dist/chat/chat.d.ts +17 -10
- package/dist/chat/chat.js +77 -23
- package/dist/chat/llms.txt +39 -15
- package/dist/chat-composer/chat-composer.d.ts +20 -7
- package/dist/chat-composer/chat-composer.js +29 -7
- 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 +10 -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 +19 -8
- 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 +4 -3
- package/dist/chat-typing/llms.txt +6 -6
- package/dist/checkbox/checkbox.d.ts +13 -6
- package/dist/checkbox/checkbox.js +31 -5
- package/dist/checkbox/llms.txt +26 -11
- package/dist/chip/chip.d.ts +4 -4
- package/dist/chip/chip.js +3 -2
- package/dist/chip/llms.txt +11 -11
- package/dist/chips-input/chips-input.d.ts +6 -4
- package/dist/chips-input/chips-input.js +47 -12
- package/dist/chips-input/llms.txt +18 -8
- package/dist/clock/clock.d.ts +11 -6
- package/dist/clock/clock.js +38 -8
- package/dist/clock/llms.txt +12 -8
- package/dist/color-picker/color-picker.d.ts +9 -5
- package/dist/color-picker/color-picker.js +37 -18
- package/dist/color-picker/llms.txt +8 -5
- package/dist/confirm/confirm-container.d.ts +3 -3
- package/dist/confirm/confirm-container.js +6 -5
- package/dist/confirm/confirm-store.d.ts +4 -4
- package/dist/confirm/confirm-store.js +11 -5
- package/dist/confirm/llms.txt +8 -7
- package/dist/context-menu/context-menu.d.ts +1 -1
- package/dist/context-menu/context-menu.js +37 -14
- package/dist/context-menu/llms.txt +10 -7
- package/dist/data-table/data-table-types.d.ts +5 -5
- package/dist/data-table/data-table.d.ts +37 -5
- package/dist/data-table/data-table.js +426 -119
- package/dist/data-table/export-csv.d.ts +3 -3
- package/dist/data-table/export-csv.js +8 -10
- package/dist/data-table/llms.txt +127 -79
- package/dist/data-view/data-view.d.ts +13 -5
- package/dist/data-view/data-view.js +68 -6
- package/dist/data-view/llms.txt +29 -10
- package/dist/date-range/date-range.d.ts +20 -8
- package/dist/date-range/date-range.js +86 -63
- package/dist/date-range/llms.txt +32 -18
- package/dist/datepicker/datepicker.d.ts +22 -8
- package/dist/datepicker/datepicker.js +103 -71
- package/dist/datepicker/llms.txt +36 -22
- package/dist/dialog/dialog.d.ts +4 -4
- package/dist/dialog/dialog.js +32 -11
- package/dist/dialog/llms.txt +13 -10
- package/dist/divider/divider.d.ts +7 -1
- package/dist/divider/divider.js +3 -2
- package/dist/divider/llms.txt +4 -3
- package/dist/drawer/drawer.d.ts +9 -4
- package/dist/drawer/drawer.js +5 -4
- package/dist/drawer/llms.txt +13 -10
- 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 +12 -6
- package/dist/fieldset/llms.txt +26 -9
- package/dist/file-upload/file-upload.d.ts +8 -2
- package/dist/file-upload/file-upload.js +22 -11
- package/dist/file-upload/llms.txt +12 -9
- 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 +27 -6
- package/dist/form-field/llms.txt +25 -11
- package/dist/galleria/galleria.d.ts +3 -3
- package/dist/galleria/galleria.js +9 -6
- 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 +6 -6
- package/dist/i18n/i18n-context.js +27 -5
- 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 +10 -7
- 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 +5 -5
- package/dist/image/llms.txt +13 -13
- package/dist/input/input.d.ts +18 -5
- package/dist/input/input.js +22 -6
- package/dist/input/llms.txt +25 -11
- package/dist/input-mask/input-mask.d.ts +7 -2
- package/dist/input-mask/input-mask.js +17 -43
- package/dist/input-mask/llms.txt +8 -5
- package/dist/input-number/input-number.d.ts +11 -9
- package/dist/input-number/input-number.js +25 -21
- package/dist/input-number/llms.txt +17 -14
- package/dist/input-otp/input-otp.d.ts +18 -5
- package/dist/input-otp/input-otp.js +48 -24
- package/dist/input-otp/llms.txt +18 -7
- 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 +14 -0
- package/dist/internal/mask.js +62 -0
- package/dist/internal/number-group.d.ts +22 -0
- package/dist/internal/number-group.js +53 -0
- package/dist/internal/option-key.d.ts +6 -0
- package/dist/internal/option-key.js +8 -0
- 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 +40 -10
- package/dist/internal/password-strength.d.ts +6 -0
- package/dist/internal/password-strength.js +74 -0
- package/dist/internal/roving.d.ts +2 -2
- package/dist/internal/roving.js +3 -3
- package/dist/internal/scroll-lock.d.ts +6 -0
- package/dist/internal/scroll-lock.js +35 -0
- package/dist/internal/slot-children.d.ts +13 -0
- package/dist/internal/slot-children.js +31 -0
- package/dist/internal/slot.d.ts +3 -3
- package/dist/internal/slot.js +2 -2
- package/dist/internal/step.d.ts +12 -0
- package/dist/internal/step.js +31 -0
- package/dist/internal/tween.d.ts +5 -5
- package/dist/internal/tween.js +7 -8
- 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 +5 -0
- package/dist/internal/use-controllable-state.js +25 -4
- 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 +2 -1
- package/dist/internal/use-modal-focus.js +14 -3
- package/dist/knob/knob.d.ts +7 -4
- package/dist/knob/knob.js +27 -22
- package/dist/knob/llms.txt +18 -11
- package/dist/listbox/listbox.d.ts +8 -6
- package/dist/listbox/listbox.js +37 -17
- package/dist/listbox/llms.txt +12 -9
- 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 +30 -23
- package/dist/map/map-create-dialog.d.ts +4 -4
- package/dist/map/map-create-dialog.js +36 -28
- package/dist/map/map-hours-field.d.ts +4 -4
- package/dist/map/map-hours-field.js +8 -7
- package/dist/map/map-image-field.d.ts +2 -2
- package/dist/map/map-image-field.js +6 -5
- package/dist/map/map-legend.d.ts +4 -4
- package/dist/map/map-legend.js +3 -2
- package/dist/map/map-poi-card.d.ts +3 -3
- package/dist/map/map-poi-card.js +10 -9
- package/dist/map/map-search.d.ts +17 -6
- package/dist/map/map-search.js +70 -43
- package/dist/map/map.d.ts +25 -13
- package/dist/map/map.js +86 -57
- 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 +18 -7
- package/dist/megamenu/megamenu.d.ts +12 -6
- package/dist/megamenu/megamenu.js +23 -14
- 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-rows.js +1 -0
- package/dist/menu/menu.d.ts +2 -2
- package/dist/menu/menu.js +15 -8
- package/dist/menubar/llms.txt +19 -8
- package/dist/menubar/menubar.d.ts +11 -5
- package/dist/menubar/menubar.js +23 -11
- 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 +2 -1
- package/dist/motion/motion-context.d.ts +22 -0
- package/dist/motion/motion-context.js +28 -0
- package/dist/order-list/llms.txt +24 -9
- package/dist/order-list/order-list.d.ts +12 -4
- package/dist/order-list/order-list.js +123 -25
- package/dist/paginator/llms.txt +8 -8
- package/dist/paginator/paginator.js +7 -4
- package/dist/panel/llms.txt +25 -13
- package/dist/panel/panel.d.ts +11 -3
- package/dist/panel/panel.js +12 -7
- package/dist/password/llms.txt +19 -7
- package/dist/password/password.d.ts +2 -2
- package/dist/password/password.js +27 -16
- package/dist/peek/llms.txt +11 -11
- package/dist/peek/peek.d.ts +6 -6
- package/dist/peek/peek.js +41 -19
- package/dist/pick-list/llms.txt +35 -12
- package/dist/pick-list/pick-list.d.ts +12 -4
- package/dist/pick-list/pick-list.js +128 -24
- package/dist/popover/llms.txt +13 -10
- package/dist/popover/popover.d.ts +6 -4
- package/dist/popover/popover.js +14 -7
- package/dist/progress/llms.txt +17 -17
- package/dist/progress/progress.d.ts +7 -7
- package/dist/progress/progress.js +7 -6
- package/dist/public-api.d.ts +16 -4
- package/dist/public-api.js +13 -7
- package/dist/radio-group/llms.txt +16 -6
- package/dist/radio-group/radio-group.d.ts +12 -3
- package/dist/radio-group/radio-group.js +23 -4
- 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 +77 -12
- package/dist/rich-text/lists.d.ts +2 -2
- package/dist/rich-text/lists.js +7 -7
- package/dist/rich-text/llms.txt +35 -12
- package/dist/rich-text/rich-text.d.ts +13 -14
- package/dist/rich-text/rich-text.js +311 -142
- package/dist/rich-text/sanitize.d.ts +11 -2
- package/dist/rich-text/sanitize.js +80 -32
- package/dist/rich-text/tables.d.ts +3 -3
- package/dist/rich-text/tables.js +3 -3
- package/dist/roadmap/llms.txt +23 -17
- package/dist/roadmap/roadmap.d.ts +6 -6
- package/dist/roadmap/roadmap.js +102 -25
- 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 +2 -1
- package/dist/select/llms.txt +22 -12
- package/dist/select/select.d.ts +10 -8
- package/dist/select/select.js +87 -47
- package/dist/shared/types.d.ts +22 -1
- package/dist/shared/types.js +9 -1
- package/dist/sidenav/llms.txt +9 -9
- package/dist/sidenav/sidenav.d.ts +2 -3
- package/dist/sidenav/sidenav.js +5 -4
- 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 +34 -12
- package/dist/slider/slider-drag.d.ts +26 -0
- package/dist/slider/slider-drag.js +79 -0
- package/dist/slider/slider.d.ts +8 -5
- package/dist/slider/slider.js +38 -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 +3 -2
- package/dist/spinner/llms.txt +7 -7
- package/dist/spinner/spinner.d.ts +1 -1
- package/dist/spinner/spinner.js +2 -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 +13 -6
- package/dist/splitter/llms.txt +11 -11
- package/dist/splitter/splitter.d.ts +3 -3
- package/dist/splitter/splitter.js +25 -10
- package/dist/stepper/llms.txt +35 -13
- package/dist/stepper/stepper.d.ts +6 -6
- package/dist/stepper/stepper.js +60 -13
- package/dist/switch/llms.txt +15 -5
- package/dist/switch/switch.d.ts +10 -3
- package/dist/switch/switch.js +18 -4
- package/dist/switch-group/llms.txt +11 -8
- package/dist/switch-group/switch-group.d.ts +6 -4
- package/dist/switch-group/switch-group.js +9 -7
- package/dist/tabs/llms.txt +12 -9
- package/dist/tabs/tabs.d.ts +5 -5
- package/dist/tabs/tabs.js +36 -20
- package/dist/textarea/llms.txt +23 -12
- package/dist/textarea/textarea.d.ts +19 -6
- package/dist/textarea/textarea.js +22 -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 +50 -17
- package/dist/toast/toast-container.d.ts +9 -3
- package/dist/toast/toast-container.js +18 -9
- package/dist/toast/toast-store.d.ts +42 -2
- 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 +14 -12
- package/dist/tooltip/tooltip.d.ts +5 -4
- package/dist/tooltip/tooltip.js +100 -41
- package/dist/tree/llms.txt +25 -11
- package/dist/tree/tree-keys.d.ts +5 -5
- package/dist/tree/tree-keys.js +7 -7
- package/dist/tree/tree.d.ts +17 -5
- package/dist/tree/tree.js +62 -20
- 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 +18 -15
package/dist/rating/rating.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
'use client';
|
|
1
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
3
|
import { useEffect, useRef, useState } from 'react';
|
|
3
4
|
import { cn } from "../internal/cn.js";
|
|
@@ -5,16 +6,19 @@ import { useControllableState } from "../internal/use-controllable-state.js";
|
|
|
5
6
|
import { useKptMessages } from "../i18n/i18n-context.js";
|
|
6
7
|
import { useKptFieldA11y } from "../form-field/form-field-context.js";
|
|
7
8
|
import { KptIcon } from "../icon/icon.js";
|
|
9
|
+
import { playPopMotion, resolveToggleMotion } from '@konce-pt/motion';
|
|
10
|
+
import { useKptMotion } from "../motion/motion-context.js";
|
|
11
|
+
import { ratingValueAt } from "./rating-pointer.js";
|
|
8
12
|
const fillOf = (star, shown) => shown >= star ? 'full' : shown >= star - 0.5 ? 'half' : 'empty';
|
|
9
13
|
/**
|
|
10
14
|
* Ocena gwiazdkami. Kliknięcie zapalonej gwiazdki zeruje ocenę, więc wystawioną można cofnąć
|
|
11
|
-
* bez osobnego przycisku
|
|
15
|
+
* bez osobnego przycisku "wyczyść".
|
|
12
16
|
*
|
|
13
17
|
* Do edycji to grupa radiowa (`role="radiogroup"`, gwiazdki jako `role="radio"`): jeden przystanek
|
|
14
18
|
* Tab, strzałki zmieniają ocenę o krok (w RTL odwrócone w poziomie), `Home`/`End` ustawiają
|
|
15
|
-
* skrajne, `Delete`/`Backspace` zeruje. Z `allowHalf` każda gwiazdka ma dwie połówki
|
|
16
|
-
* `radio` (
|
|
17
|
-
*
|
|
19
|
+
* skrajne, `Delete`/`Backspace` zeruje. Z `allowHalf` każda gwiazdka ma dwie połówki - dwa osobne
|
|
20
|
+
* `radio` ("3,5 z 5"), a krok strzałek to 0,5. Tylko do odczytu (`readOnly`) to obrazek z nazwą
|
|
21
|
+
* "4,3 z 5" - bez przycisków, które czytnik ogłaszałby jako wyłączone; gwiazdki pokazują wartość
|
|
18
22
|
* zaokrągloną do połówki.
|
|
19
23
|
*
|
|
20
24
|
* @example
|
|
@@ -30,17 +34,34 @@ export function KptRating({ value, defaultValue = 0, onValueChange, count = 5, a
|
|
|
30
34
|
const groupRef = useRef(null);
|
|
31
35
|
/** Prośba o fokus na przystanek Tab po najbliższym renderze (zmiana oceny klawiszem). */
|
|
32
36
|
const wantFocus = useRef(false);
|
|
37
|
+
/** Ocena przeciągana wskaźnikiem (mysz albo dotyk) - podgląd idzie za palcem, puszczenie zatwierdza. */
|
|
38
|
+
const [dragging, setDragging] = useState(false);
|
|
39
|
+
const toggleMotion = resolveToggleMotion(undefined, useKptMotion());
|
|
33
40
|
const showInvalid = invalid && (touched ?? true);
|
|
34
41
|
const stars = Array.from({ length: count }, (_, index) => index + 1);
|
|
35
42
|
const step = allowHalf ? 0.5 : 1;
|
|
36
|
-
// Podgląd pod kursorem wygrywa z oceną, ale tylko dopóki kursor jest nad gwiazdkami
|
|
43
|
+
// Podgląd pod kursorem wygrywa z oceną, ale tylko dopóki kursor jest nad gwiazdkami -
|
|
37
44
|
// po `mouseleave` wraca 0 i zapalona zostaje sama wartość.
|
|
38
45
|
const shown = hover || current;
|
|
39
|
-
/** Przystanek Tab: wybrana wartość, a bez oceny
|
|
46
|
+
/** Przystanek Tab: wybrana wartość, a bez oceny - pierwsza możliwa. */
|
|
40
47
|
const tabStop = current >= step && current <= count ? current : step;
|
|
41
|
-
/** Liczba w zapisie języka strony (
|
|
48
|
+
/** Liczba w zapisie języka strony ("3,5" po polsku). */
|
|
42
49
|
const numberFormat = new Intl.NumberFormat(activeLocale, { maximumFractionDigits: 2 });
|
|
43
50
|
const starLabel = (score) => t('rating.star', { value: numberFormat.format(score), max: count });
|
|
51
|
+
// Gwiazdki, które się zapalają (podgląd pod kursorem, przeciąganie, wybór), wskakują po kolei.
|
|
52
|
+
// Ruch idzie za globalnym `toggle` z `KptMotionProvider`; start strony się nie rusza.
|
|
53
|
+
const shownBefore = useRef(null);
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
const before = shownBefore.current;
|
|
56
|
+
shownBefore.current = shown;
|
|
57
|
+
if (before === null || shown <= before || toggleMotion !== 'spring')
|
|
58
|
+
return;
|
|
59
|
+
groupRef.current?.querySelectorAll('.kpt-rating__star').forEach((star, i) => {
|
|
60
|
+
const n = i + 1;
|
|
61
|
+
if (n > Math.ceil(before) && n <= Math.ceil(shown))
|
|
62
|
+
playPopMotion(star);
|
|
63
|
+
});
|
|
64
|
+
}, [shown, toggleMotion]);
|
|
44
65
|
useEffect(() => {
|
|
45
66
|
if (!wantFocus.current)
|
|
46
67
|
return;
|
|
@@ -50,7 +71,7 @@ export function KptRating({ value, defaultValue = 0, onValueChange, count = 5, a
|
|
|
50
71
|
const starVisual = (star, fill, children, hidden = false) => (_jsxs("span", { className: "kpt-rating__star", "data-fill": fill, "aria-hidden": hidden || undefined, children: [_jsx(KptIcon, { name: "star" }), _jsx("span", { className: "kpt-rating__fill", "aria-hidden": "true", children: _jsx(KptIcon, { name: "star" }) }), children] }, star));
|
|
51
72
|
if (readOnly) {
|
|
52
73
|
const score = starLabel(current);
|
|
53
|
-
// Gwiazdki pokazują wartość zaokrągloną do połówki (4,3
|
|
74
|
+
// Gwiazdki pokazują wartość zaokrągloną do połówki (4,3 -> 4,5), nazwa - dokładną.
|
|
54
75
|
const display = Math.round(current * 2) / 2;
|
|
55
76
|
return (_jsx("div", { className: cn('kpt-rating-host', className), ...rest, children: _jsx("div", { className: "kpt-rating kpt-rating--readonly", role: "img", id: field.id, "aria-label": ariaLabel ? `${ariaLabel}: ${score}` : score, "aria-describedby": field.describedBy, children: stars.map((star) => starVisual(star, fillOf(star, display), null, true)) }) }));
|
|
56
77
|
}
|
|
@@ -77,7 +98,7 @@ export function KptRating({ value, defaultValue = 0, onValueChange, count = 5, a
|
|
|
77
98
|
else if (event.key === 'Delete' || event.key === 'Backspace')
|
|
78
99
|
next = 0;
|
|
79
100
|
else if (event.key === ' ' || event.key === 'Enter') {
|
|
80
|
-
// Spacja na gwiazdce wybiera ją (jak radio); ponowna nie zeruje
|
|
101
|
+
// Spacja na gwiazdce wybiera ją (jak radio); ponowna nie zeruje - od tego jest Delete.
|
|
81
102
|
const score = Number(event.target.dataset['value']);
|
|
82
103
|
if (score)
|
|
83
104
|
next = score;
|
|
@@ -88,18 +109,62 @@ export function KptRating({ value, defaultValue = 0, onValueChange, count = 5, a
|
|
|
88
109
|
setCurrent(next);
|
|
89
110
|
wantFocus.current = true;
|
|
90
111
|
};
|
|
91
|
-
/**
|
|
112
|
+
/**
|
|
113
|
+
* Przeciąganie po gwiazdkach. Krótkie wciśnięcie bez ruchu zostawia sprawę kliknięciu (zachowanie
|
|
114
|
+
* jak dotąd, łącznie z ponownym kliknięciem zerującym); ruch o kilka pikseli zamienia gest w wybór
|
|
115
|
+
* przeciąganiem - także dotykiem, gdzie nie ma podglądu na `mouseenter`.
|
|
116
|
+
*/
|
|
117
|
+
const onPointerDown = (event) => {
|
|
118
|
+
if (disabled || event.button !== 0)
|
|
119
|
+
return;
|
|
120
|
+
const root = event.currentTarget;
|
|
121
|
+
const startX = event.clientX;
|
|
122
|
+
let active = false;
|
|
123
|
+
const valueAt = (x) => ratingValueAt(x, Array.from(root.querySelectorAll('.kpt-rating__star'), (el) => el.getBoundingClientRect()), { allowHalf, rtl: getComputedStyle(root).direction === 'rtl' });
|
|
124
|
+
const move = (e) => {
|
|
125
|
+
if (!active && Math.abs(e.clientX - startX) < 4)
|
|
126
|
+
return;
|
|
127
|
+
if (!active) {
|
|
128
|
+
active = true;
|
|
129
|
+
setDragging(true);
|
|
130
|
+
root.setPointerCapture(e.pointerId);
|
|
131
|
+
}
|
|
132
|
+
setHover(valueAt(e.clientX));
|
|
133
|
+
};
|
|
134
|
+
const up = (e) => {
|
|
135
|
+
root.removeEventListener('pointermove', move);
|
|
136
|
+
root.removeEventListener('pointerup', up);
|
|
137
|
+
root.removeEventListener('pointercancel', up);
|
|
138
|
+
if (!active)
|
|
139
|
+
return;
|
|
140
|
+
setDragging(false);
|
|
141
|
+
// Klik po przeciągnięciu jest skutkiem tego samego gestu - nie może drugi raz przestawić oceny.
|
|
142
|
+
// Połykamy go w fazie capture; nasłuch znika w następnej klatce, gdyby klik nie przyszedł.
|
|
143
|
+
const swallow = (ev) => ev.stopPropagation();
|
|
144
|
+
root.addEventListener('click', swallow, { capture: true, once: true });
|
|
145
|
+
requestAnimationFrame(() => root.removeEventListener('click', swallow, { capture: true }));
|
|
146
|
+
const score = valueAt(e.clientX);
|
|
147
|
+
setCurrent(score);
|
|
148
|
+
// Mysz zostaje nad gwiazdkami - podgląd i tak zgadza się z wyborem; palec odchodzi, więc czyścimy.
|
|
149
|
+
setHover(e.pointerType === 'mouse' ? score : 0);
|
|
150
|
+
onTouch?.();
|
|
151
|
+
};
|
|
152
|
+
root.addEventListener('pointermove', move);
|
|
153
|
+
root.addEventListener('pointerup', up);
|
|
154
|
+
root.addEventListener('pointercancel', up);
|
|
155
|
+
};
|
|
156
|
+
/** "Dotknięcie" dopiero przy wyjściu fokusu z całej grupy, nie przy przejściu między gwiazdkami. */
|
|
92
157
|
const onBlur = (event) => {
|
|
93
158
|
const next = event.relatedTarget;
|
|
94
159
|
if (!next || !event.currentTarget.contains(next))
|
|
95
160
|
onTouch?.();
|
|
96
161
|
};
|
|
97
|
-
/** Pola wyboru jednej gwiazdki: całość albo
|
|
162
|
+
/** Pola wyboru jednej gwiazdki: całość albo - z `allowHalf` - dwie połówki. */
|
|
98
163
|
const optionsOf = (star) => allowHalf
|
|
99
164
|
? [
|
|
100
165
|
{ score: star - 0.5, part: 'start' },
|
|
101
166
|
{ score: star, part: 'end' },
|
|
102
167
|
]
|
|
103
168
|
: [{ score: star, part: 'full' }];
|
|
104
|
-
return (_jsx("div", { className: cn('kpt-rating-host', className), ...rest, children: _jsx("div", { ref: groupRef, className: cn('kpt-rating', disabled && 'kpt-rating--disabled'), role: "radiogroup", id: field.id, "aria-label": ariaLabel ?? undefined, "aria-labelledby": ariaLabel ? undefined : field.labelledBy, "aria-describedby": field.describedBy, "aria-required": required || undefined, "aria-invalid": showInvalid || undefined, "aria-disabled": disabled || undefined, onKeyDown: onKeyDown, onBlur: onBlur, onMouseLeave: () => setHover(0), children: stars.map((star) => starVisual(star, fillOf(star, shown), optionsOf(star).map((option) => (_jsx("button", { type: "button", role: "radio", className: cn('kpt-rating__hit', `kpt-rating__hit--${option.part}`), "aria-checked": option.score === current, tabIndex: !disabled && option.score === tabStop ? 0 : -1, "aria-disabled": disabled || undefined, "data-value": option.score, "aria-label": starLabel(option.score), onClick: () => pick(option.score), onMouseEnter: () => !disabled && setHover(option.score) }, option.part))))) }) }));
|
|
169
|
+
return (_jsx("div", { className: cn('kpt-rating-host', className), ...rest, children: _jsx("div", { ref: groupRef, className: cn('kpt-rating', disabled && 'kpt-rating--disabled', dragging && 'is-dragging'), role: "radiogroup", id: field.id, "aria-label": ariaLabel ?? undefined, "aria-labelledby": ariaLabel ? undefined : field.labelledBy, "aria-describedby": field.describedBy, "aria-required": required || undefined, "aria-invalid": showInvalid || undefined, "aria-disabled": disabled || undefined, onKeyDown: onKeyDown, onBlur: onBlur, onMouseLeave: () => !dragging && setHover(0), onPointerDown: onPointerDown, children: stars.map((star) => starVisual(star, fillOf(star, shown), optionsOf(star).map((option) => (_jsx("button", { type: "button", role: "radio", className: cn('kpt-rating__hit', `kpt-rating__hit--${option.part}`), "aria-checked": option.score === current, tabIndex: !disabled && option.score === tabStop ? 0 : -1, "aria-disabled": disabled || undefined, "data-value": option.score, "aria-label": starLabel(option.score), onClick: () => pick(option.score), onMouseEnter: () => !disabled && setHover(option.score) }, option.part))))) }) }));
|
|
105
170
|
}
|
|
@@ -6,11 +6,11 @@ export declare function canIndentItem(editor: HTMLElement | null, li: HTMLLIElem
|
|
|
6
6
|
export declare function canOutdentItem(li: HTMLLIElement): boolean;
|
|
7
7
|
/**
|
|
8
8
|
* Punkty listy objęte zaznaczeniem. Przy wielu punktach operujemy na ich wspólnym poziomie
|
|
9
|
-
* zagnieżdżenia
|
|
9
|
+
* zagnieżdżenia - inaczej podpunkt dostałby wcięcie dwa razy: raz sam, raz z rodzicem.
|
|
10
10
|
*/
|
|
11
11
|
export declare function selectedItems(editor: HTMLElement | null): HTMLLIElement[];
|
|
12
12
|
/**
|
|
13
|
-
* Przesuwa zaznaczone punkty o poziom. Zwraca `true`, gdy DOM faktycznie się zmienił
|
|
13
|
+
* Przesuwa zaznaczone punkty o poziom. Zwraca `true`, gdy DOM faktycznie się zmienił - od tego
|
|
14
14
|
* zależy, czy Tab dostanie `preventDefault()`, a więc czy edytor nie stanie się pułapką
|
|
15
15
|
* klawiaturową (WCAG 2.1.2).
|
|
16
16
|
*/
|
package/dist/rich-text/lists.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* Wcięcia list. `execCommand('indent')` daje w Chrome nieprawidłowe `ul > ul` (albo `blockquote`
|
|
3
3
|
* z marginesem, który i tak zdjąłby sanitizer), więc zagnieżdżanie robimy własnym kodem DOM.
|
|
4
|
-
* Plik nie zna Reacta
|
|
4
|
+
* Plik nie zna Reacta - to czyste operacje na węzłach.
|
|
5
5
|
*/
|
|
6
6
|
/** Najbliższy punkt listy zawierający węzeł, ale tylko wewnątrz edytora. */
|
|
7
7
|
export function closestItem(editor, node) {
|
|
@@ -19,7 +19,7 @@ export function level(editor, li) {
|
|
|
19
19
|
}
|
|
20
20
|
return depth;
|
|
21
21
|
}
|
|
22
|
-
/** Najgłębszy poziom w poddrzewie punktu
|
|
22
|
+
/** Najgłębszy poziom w poddrzewie punktu - wcięcie przenosi podpunkty razem z rodzicem. */
|
|
23
23
|
function deepest(editor, li) {
|
|
24
24
|
let max = level(editor, li);
|
|
25
25
|
for (const nested of li.querySelectorAll('li')) {
|
|
@@ -35,7 +35,7 @@ export function canOutdentItem(li) {
|
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
37
37
|
* Punkty listy objęte zaznaczeniem. Przy wielu punktach operujemy na ich wspólnym poziomie
|
|
38
|
-
* zagnieżdżenia
|
|
38
|
+
* zagnieżdżenia - inaczej podpunkt dostałby wcięcie dwa razy: raz sam, raz z rodzicem.
|
|
39
39
|
*/
|
|
40
40
|
export function selectedItems(editor) {
|
|
41
41
|
const selection = window.getSelection();
|
|
@@ -68,7 +68,7 @@ export function selectedItems(editor) {
|
|
|
68
68
|
return [start];
|
|
69
69
|
return siblings.slice(Math.min(from, to), Math.max(from, to) + 1);
|
|
70
70
|
}
|
|
71
|
-
/** Zagnieżdża punkt w podliście poprzedniego punktu
|
|
71
|
+
/** Zagnieżdża punkt w podliście poprzedniego punktu - poprawne `li > ul > li`. */
|
|
72
72
|
function indentItem(editor, li, maxLevel) {
|
|
73
73
|
if (!canIndentItem(editor, li, maxLevel))
|
|
74
74
|
return false;
|
|
@@ -104,7 +104,7 @@ function outdentItem(li) {
|
|
|
104
104
|
return true;
|
|
105
105
|
}
|
|
106
106
|
/**
|
|
107
|
-
* Przesuwa zaznaczone punkty o poziom. Zwraca `true`, gdy DOM faktycznie się zmienił
|
|
107
|
+
* Przesuwa zaznaczone punkty o poziom. Zwraca `true`, gdy DOM faktycznie się zmienił - od tego
|
|
108
108
|
* zależy, czy Tab dostanie `preventDefault()`, a więc czy edytor nie stanie się pułapką
|
|
109
109
|
* klawiaturową (WCAG 2.1.2).
|
|
110
110
|
*/
|
|
@@ -119,7 +119,7 @@ export function shiftItems(editor, dir, maxLevel) {
|
|
|
119
119
|
const caret = range
|
|
120
120
|
? { sc: range.startContainer, so: range.startOffset, ec: range.endContainer, eo: range.endOffset }
|
|
121
121
|
: null;
|
|
122
|
-
// Outdent od końca
|
|
122
|
+
// Outdent od końca - inaczej `host.after()` odwróciłby kolejność przenoszonych punktów.
|
|
123
123
|
const order = dir === 'outdent' ? [...items].reverse() : items;
|
|
124
124
|
let changed = false;
|
|
125
125
|
for (const li of order) {
|
|
@@ -137,7 +137,7 @@ export function shiftItems(editor, dir, maxLevel) {
|
|
|
137
137
|
selection.addRange(restored);
|
|
138
138
|
}
|
|
139
139
|
catch {
|
|
140
|
-
/* offset przestał pasować po przeniesieniu rodzeństwa
|
|
140
|
+
/* offset przestał pasować po przeniesieniu rodzeństwa - zostaw kursor tam, gdzie jest */
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
143
|
return true;
|
package/dist/rich-text/llms.txt
CHANGED
|
@@ -5,24 +5,24 @@ editing. The value is HTML.
|
|
|
5
5
|
Import: `import { KptRichText, type KptRichTool } from '@konce-pt/react';`
|
|
6
6
|
|
|
7
7
|
## Props
|
|
8
|
-
- `value` / `defaultValue` / `onValueChange`
|
|
9
|
-
- `toolbar`: `KptRichTool[] | KptRichTool[][]`
|
|
8
|
+
- `value` / `defaultValue` / `onValueChange` - the HTML
|
|
9
|
+
- `toolbar`: `KptRichTool[] | KptRichTool[][]` - a flat list, or groups = sections separated by a
|
|
10
10
|
divider. Leaving a tool or a group out disables it; the full toolbar in 5 sections by default.
|
|
11
11
|
- `placeholder`, `maxListLevel` (6), `disabled`, `invalid`, `touched`, `onTouch()`
|
|
12
|
-
- `mentions`: `readonly KptMentionItem[]`, `mentionLimit` (8), `onMention(item)`
|
|
12
|
+
- `mentions`: `readonly KptMentionItem[]`, `mentionLimit` (8), `onMention(item)` - suggestions
|
|
13
13
|
for `@`; an empty list turns the mechanism off, so `@` stays an ordinary character
|
|
14
14
|
- `className`, `ref` and every other `<div>` prop go to the host
|
|
15
15
|
|
|
16
16
|
## Mentions (`@`)
|
|
17
17
|
With `mentions` set, typing `@` opens a suggestion list anchored at the caret: arrows move through
|
|
18
18
|
it, Enter or Tab inserts, Escape closes. The query is read from the **text node** at the caret and
|
|
19
|
-
recognised by `mentionQuery()` from `@konce-pt/mention`
|
|
19
|
+
recognised by `mentionQuery()` from `@konce-pt/mention` - the same rules as in the Angular port.
|
|
20
20
|
An inserted mention is `<span class="kpt-mention" data-mention="id" contenteditable="false">@Name`
|
|
21
21
|
plus a non-breaking space: the id survives saving, the flag keeps the mention in one piece and the
|
|
22
22
|
space gives the caret a place to stand after it.
|
|
23
23
|
|
|
24
24
|
## Tools (KptRichTool)
|
|
25
|
-
Clipboard: `copy`, `paste` (sanitized), `pasteText`. Style: `heading` (a panel: Normal + H1
|
|
25
|
+
Clipboard: `copy`, `paste` (sanitized), `pasteText`. Style: `heading` (a panel: Normal + H1-H6).
|
|
26
26
|
Format: `bold`, `italic`, `underline`, `strike`, `ul`, `ol`, `indent`, `outdent`.
|
|
27
27
|
Colours: `foreColor`, `backColor` (a palette + a native colour input). Alignment: `alignLeft`,
|
|
28
28
|
`alignCenter`, `alignRight`, `alignJustify`. Plus `link`, `table`, `clear`, `html`.
|
|
@@ -30,32 +30,43 @@ Colours: `foreColor`, `backColor` (a palette + a native colour input). Alignment
|
|
|
30
30
|
## The editor is not rendered by React
|
|
31
31
|
`contentEditable` cannot be a React-rendered subtree: re-rendering would wipe the selection and the
|
|
32
32
|
caret on every keystroke. The value is written into the DOM by hand, only when it differs from what
|
|
33
|
-
is already there
|
|
33
|
+
is already there - so typing never triggers a rewrite, and sanitization runs solely on writes
|
|
34
34
|
coming from the application or the HTML source view.
|
|
35
35
|
|
|
36
36
|
## Everything that enters the DOM is sanitized
|
|
37
37
|
Not just paste: a `value` from a database, a CMS or another user is untrusted too. Tags outside the
|
|
38
38
|
allowlist are unwrapped (the text survives), `on*` handlers and `javascript:` URLs are dropped,
|
|
39
39
|
`style` is filtered declaration by declaration. `sanitize.ts` knows nothing about React.
|
|
40
|
+
Links keep only relative addresses and `http(s):`, `mailto:`, `tel:` - the same allowlist as the link tool, so
|
|
41
|
+
`data:`, `vbscript:` or `blob:` from a paste are dropped. `class` keeps only the editor's own classes
|
|
42
|
+
(`kpt-rt-*`, `kpt-mention`), a link with `target` always gets `rel="noopener noreferrer"`, and when the
|
|
43
|
+
sanitizer removed something, the cleaned HTML is written back to `value` - the model never holds the
|
|
44
|
+
unsafe original (a pure formatting difference does not touch it, so a clean value does not dirty a form).
|
|
40
45
|
|
|
41
46
|
## Lists are indented by our own DOM code
|
|
42
47
|
`execCommand('indent')` produces invalid `ul > ul` in Chrome, so nesting goes through `lists.ts`
|
|
43
48
|
(`li > ul > li`, a sublist inherits the parent's type). Tab and Shift+Tab indent and outdent, but
|
|
44
|
-
only when the operation actually changed something
|
|
49
|
+
only when the operation actually changed something - otherwise Tab stays native and the editor
|
|
45
50
|
never becomes a keyboard trap (WCAG 2.1.2). In a table cell Tab moves to the next cell; a list
|
|
46
51
|
inside the cell takes precedence.
|
|
47
52
|
|
|
48
53
|
## The toolbar is one Tab stop
|
|
49
54
|
The toolbar is a named `role="toolbar"` ("Formatting", `richText.toolbar`) with a roving tabindex:
|
|
50
|
-
|
|
55
|
+
`ArrowLeft`/`ArrowRight` (mirrored in RTL) and `Home`/`End` move between tools, skipping disabled ones; the stop
|
|
51
56
|
remembers the last tool, so Tab from the toolbar goes straight to the editor.
|
|
52
57
|
|
|
58
|
+
Tool panels open in the overlay container at the end of `<body>`, so focus moves into them:
|
|
59
|
+
the paragraph style list is a `listbox` (`ArrowUp`/`ArrowDown`, `Home`/`End`, `Enter`/`Space` picks, `Escape`/`Tab` close);
|
|
60
|
+
the table grid is one stop (arrows change the size 1-8, the size is announced, `Enter` inserts);
|
|
61
|
+
the colour palette starts on the first swatch (`ArrowLeft`/`ArrowRight` between swatches, `Tab` cycles inside the
|
|
62
|
+
panel). `Escape` closes any of them and returns focus to the tool.
|
|
63
|
+
|
|
53
64
|
## Tables
|
|
54
|
-
Insert from an
|
|
65
|
+
Insert from an 8x8 grid popover. Dragging across cells makes a rectangular selection that grows
|
|
55
66
|
until it fully covers merged cells on its edges. Right-click opens the menu: insert and delete rows
|
|
56
|
-
and columns, header row and column (td
|
|
67
|
+
and columns, header row and column (td<->th), cell background, alignment, borders, merge and split,
|
|
57
68
|
delete the table. Dragging a column's right edge changes its width. `tables.ts` holds the grid
|
|
58
|
-
math
|
|
69
|
+
math - also framework-free.
|
|
59
70
|
|
|
60
71
|
## Point-anchored panels
|
|
61
72
|
The table menu and its popovers have no trigger element, so they do not go through `KptOverlay`:
|
|
@@ -87,5 +98,17 @@ their hex codes. The table size grid is still mouse-only.
|
|
|
87
98
|
`id` goes to the focusable element, not the host; without one it comes from `KptFormField` or is
|
|
88
99
|
generated. A `div` with a role is not named by `label[for]`, so inside `KptFormField` it gets
|
|
89
100
|
`aria-labelledby` pointing at the wrapper's label (unless `ariaLabel` is set), and the hint or error
|
|
90
|
-
is added to `aria-describedby`. New: `id`, `ariaLabel` and `required` (
|
|
101
|
+
is added to `aria-describedby`. New: `id`, `ariaLabel` and `required` (-> `aria-required`) on the
|
|
91
102
|
`role="textbox"` area.
|
|
103
|
+
|
|
104
|
+
## Read-only and required
|
|
105
|
+
`readOnly` keeps the content selectable and copyable but not editable (`aria-readonly`); the toolbar is disabled.
|
|
106
|
+
|
|
107
|
+
## Dictation
|
|
108
|
+
The `dictate` tool (not in the default toolbar) dictates at the caret: final text goes in through
|
|
109
|
+
`insertText` (native undo, `input` -> value); interim text is an overlay next to the caret
|
|
110
|
+
(`.kpt-speech-ghost`) and never enters the HTML. Hidden without browser support, stopped by the HTML
|
|
111
|
+
source view and by `disabled` / `readOnly`. Language: `speechLang` (BCP 47, default from
|
|
112
|
+
`KptI18nProvider`), listening colour: `speechColor` (theme colour by default).
|
|
113
|
+
|
|
114
|
+
<KptRichText value={body} onValueChange={setBody} toolbar={[['bold', 'italic'], ['dictate']]} />
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { type ComponentPropsWithRef } from 'react';
|
|
2
2
|
import { type KptMentionItem } from '@konce-pt/mention';
|
|
3
3
|
import { type KptI18nOverrides } from '../i18n/i18n-context.tsx';
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
import { type KptSpeechColor } from '../speech/speech-button.tsx';
|
|
5
|
+
export type KptRichTool = 'copy' | 'paste' | 'pasteText' | 'heading' | 'bold' | 'italic' | 'underline' | 'strike' | 'ul' | 'ol' | 'indent' | 'outdent' | 'foreColor' | 'backColor' | 'alignLeft' | 'alignCenter' | 'alignRight' | 'alignJustify' | 'link' | 'table' | 'clear' | 'html' | 'dictate';
|
|
6
|
+
/** Pasek: płaska lista narzędzi albo grupy - sekcje rozdzielone separatorem. */
|
|
6
7
|
export type KptRichToolbar = readonly KptRichTool[] | readonly (readonly KptRichTool[])[];
|
|
7
8
|
export interface KptRichTextProps extends Omit<ComponentPropsWithRef<'div'>, 'onChange' | 'children'>, KptI18nOverrides {
|
|
8
9
|
/** Wartość jako HTML. */
|
|
@@ -11,15 +12,17 @@ export interface KptRichTextProps extends Omit<ComponentPropsWithRef<'div'>, 'on
|
|
|
11
12
|
onValueChange?: (value: string) => void;
|
|
12
13
|
toolbar?: KptRichToolbar;
|
|
13
14
|
placeholder?: string;
|
|
14
|
-
/** Maksymalna głębokość zagnieżdżenia list (Tab,
|
|
15
|
+
/** Maksymalna głębokość zagnieżdżenia list (Tab, "Dodaj wcięcie"). */
|
|
15
16
|
maxListLevel?: number;
|
|
16
|
-
/** Id elementu fokusowalnego (nie hosta); bez niego generowane, w `KptFormField`
|
|
17
|
+
/** Id elementu fokusowalnego (nie hosta); bez niego generowane, w `KptFormField` - z wrappera. */
|
|
17
18
|
id?: string;
|
|
18
19
|
/** Nazwa dostępna, gdy kontrolki nie opisuje etykieta (`<label for>` albo `KptFormField`). */
|
|
19
20
|
ariaLabel?: string | null;
|
|
20
21
|
/** Oznacza pole jako wymagane atrybutem `aria-required`. */
|
|
21
22
|
required?: boolean;
|
|
22
23
|
disabled?: boolean;
|
|
24
|
+
/** Tylko do odczytu - treść da się zaznaczyć i skopiować, nie edytować (`aria-readonly`). */
|
|
25
|
+
readOnly?: boolean;
|
|
23
26
|
invalid?: boolean;
|
|
24
27
|
touched?: boolean;
|
|
25
28
|
onTouch?: () => void;
|
|
@@ -30,15 +33,11 @@ export interface KptRichTextProps extends Omit<ComponentPropsWithRef<'div'>, 'on
|
|
|
30
33
|
mentions?: readonly KptMentionItem[];
|
|
31
34
|
/** Ile podpowiedzi naraz. */
|
|
32
35
|
mentionLimit?: number;
|
|
33
|
-
/** Wstawiona wzmianka
|
|
36
|
+
/** Wstawiona wzmianka - moment na powiadomienie osoby albo dopięcie powiązania. */
|
|
34
37
|
onMention?: (item: KptMentionItem) => void;
|
|
38
|
+
/** Język narzędzia `dictate` (BCP 47); bez niego z `KptI18nProvider`. */
|
|
39
|
+
speechLang?: string;
|
|
40
|
+
/** Kolor "stop" i fali w trakcie nasłuchu; domyślnie kolor motywu. */
|
|
41
|
+
speechColor?: KptSpeechColor;
|
|
35
42
|
}
|
|
36
|
-
|
|
37
|
-
* Lekki edytor tekstu sformatowanego na `contenteditable`, z konfigurowalnym paskiem sekcji
|
|
38
|
-
* i edycją tabel. Wartością jest HTML.
|
|
39
|
-
*
|
|
40
|
-
* @example
|
|
41
|
-
* <KptRichText value={html} onValueChange={setHtml} />
|
|
42
|
-
* <KptRichText value={html} onValueChange={setHtml} toolbar={[['bold', 'italic'], ['link']]} />
|
|
43
|
-
*/
|
|
44
|
-
export declare function KptRichText({ value, defaultValue, onValueChange, toolbar, placeholder, maxListLevel, id, ariaLabel, required, disabled, invalid, touched, onTouch, mentions, mentionLimit, onMention, locale, dictionary, className, ...rest }: Readonly<KptRichTextProps>): import("react").JSX.Element;
|
|
43
|
+
export declare function KptRichText({ value, defaultValue, onValueChange, toolbar, placeholder, maxListLevel, id, ariaLabel, required, disabled: disabledProp, readOnly, invalid, touched, onTouch, mentions, mentionLimit, onMention, speechLang, speechColor, locale, dictionary, className, ...rest }: Readonly<KptRichTextProps>): import("react").JSX.Element;
|