@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/map/map-search.js
CHANGED
|
@@ -1,76 +1,103 @@
|
|
|
1
|
+
'use client';
|
|
1
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
+
import { useEffect, useId, useMemo, useRef, useState } from 'react';
|
|
3
4
|
import { cn } from "../internal/cn.js";
|
|
4
5
|
import { useKptMessages } from "../i18n/i18n-context.js";
|
|
5
6
|
import { KptIcon } from "../icon/icon.js";
|
|
7
|
+
import { KptSpeechButton } from "../speech/speech-button.js";
|
|
6
8
|
/**
|
|
7
9
|
* Wyszukiwarka adresów: pole z podpowiedziami z geokodera. Wynik wyboru leci w `onSelect`,
|
|
8
|
-
* a co z nim zrobić
|
|
10
|
+
* a co z nim zrobić - decyduje rodzic (`KptMap` przenosi na niego widok).
|
|
9
11
|
*
|
|
10
12
|
* Świadomie **nie** stoi na `KptAutocomplete`: tamten filtruje opcje po stronie klienta (wyniki
|
|
11
13
|
* geokodera, tolerancyjne na literówki, wypadałyby z listy), a jego wartością jest sam `string`
|
|
12
|
-
*
|
|
14
|
+
* - nie ma czym przewieźć współrzędnych.
|
|
13
15
|
*
|
|
14
16
|
* @example
|
|
15
17
|
* <KptMapSearch geocoder={geocoder} viewbox={bounds} onSelect={goTo} />
|
|
16
18
|
*/
|
|
17
|
-
export function KptMapSearch({ geocoder = null, placeholder = '', minLength = 3, debounce = 300, limit = 5, countryCodes = null, viewbox = null, disabled = false, onSelect, onClear, locale: localeOverride, dictionary, className, ...rest }) {
|
|
19
|
+
export function KptMapSearch({ geocoder = null, placeholder = '', minLength = 3, debounce = 300, limit = 5, countryCodes = null, viewbox = null, disabled = false, speech = false, speechLang, speechColor, onSelect, onClear, locale: localeOverride, dictionary, className, ...rest }) {
|
|
18
20
|
const { t, locale } = useKptMessages({ locale: localeOverride, dictionary });
|
|
19
21
|
const uid = useId();
|
|
20
22
|
/** Tekst widoczny w polu. Wybór podpowiedzi wpisuje tu jego etykietę. */
|
|
21
23
|
const [query, setQuery] = useState('');
|
|
22
24
|
/**
|
|
23
25
|
* Fraza do odpytania geokodera. Osobna od `query`, bo wybór podpowiedzi zmienia treść pola
|
|
24
|
-
*
|
|
26
|
+
* - a to nie może wywołać kolejnego zapytania o coś, co już znaleźliśmy.
|
|
25
27
|
*/
|
|
26
28
|
const [term, setTerm] = useState('');
|
|
27
29
|
const [results, setResults] = useState([]);
|
|
28
|
-
|
|
29
|
-
/** Trwa dociąganie współrzędnych wybranej podpowiedzi — inny moment niż czekanie na listę. */
|
|
30
|
+
/** Trwa dociąganie współrzędnych wybranej podpowiedzi - inny moment niż czekanie na listę. */
|
|
30
31
|
const [resolving, setResolving] = useState(false);
|
|
31
|
-
/** Czy jakieś zapytanie już wróciło
|
|
32
|
+
/** Czy jakieś zapytanie już wróciło - bez tego "brak wyników" mignąłby przed pierwszym. */
|
|
32
33
|
const [searched, setSearched] = useState(false);
|
|
33
34
|
const [open, setOpen] = useState(false);
|
|
34
35
|
const [activeIndex, setActiveIndex] = useState(-1);
|
|
35
|
-
/** Nie udało się ustalić miejsca wybranej podpowiedzi
|
|
36
|
+
/** Nie udało się ustalić miejsca wybranej podpowiedzi - komunikat zamiast cichej ciszy. */
|
|
36
37
|
const [unresolved, setUnresolved] = useState(false);
|
|
37
|
-
/** Przerywacz dociągania w locie
|
|
38
|
+
/** Przerywacz dociągania w locie - kolejny wybór i czyszczenie pola go używają. */
|
|
38
39
|
const pending = useRef(null);
|
|
40
|
+
/** Pole - cel dyktowania (`speech`). */
|
|
41
|
+
const inputRef = useRef(null);
|
|
39
42
|
const canSearch = !!geocoder?.search;
|
|
43
|
+
/*
|
|
44
|
+
* Zapytanie do geokodera jako wartość: nowa tożsamość = nowe zapytanie. `viewbox` i `countryCodes`
|
|
45
|
+
* wchodzą jako klucze tekstowe - rodzic podaje je zwykle świeżą tablicą w każdym renderze, a to
|
|
46
|
+
* restartowałoby odliczanie przy każdym ruchu mapy i zapytanie nigdy by nie wyszło.
|
|
47
|
+
*/
|
|
48
|
+
const needle = term.trim();
|
|
49
|
+
const viewboxKey = viewbox ? JSON.stringify(viewbox) : '';
|
|
50
|
+
const countryKey = countryCodes?.join(',') ?? '';
|
|
51
|
+
const request = useMemo(() => {
|
|
52
|
+
if (!geocoder?.search || needle.length < minLength)
|
|
53
|
+
return null;
|
|
54
|
+
return {
|
|
55
|
+
geocoder,
|
|
56
|
+
needle,
|
|
57
|
+
options: {
|
|
58
|
+
language: locale,
|
|
59
|
+
limit,
|
|
60
|
+
viewbox: viewboxKey ? JSON.parse(viewboxKey) : undefined,
|
|
61
|
+
countryCodes: countryKey ? countryKey.split(',') : undefined,
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
}, [geocoder, needle, minLength, locale, limit, viewboxKey, countryKey]);
|
|
65
|
+
/** Zapytanie, na które przyszła już odpowiedź (albo błąd). */
|
|
66
|
+
const [settled, setSettled] = useState(null);
|
|
67
|
+
const loading = request !== null && settled !== request;
|
|
68
|
+
// Fraza za krótka (albo brak geokodera) - lista i stan wracają do zera. W renderze, nie w efekcie,
|
|
69
|
+
// żeby nie mignęła jedna klatka starych wyników.
|
|
70
|
+
const [hadRequest, setHadRequest] = useState(request !== null);
|
|
71
|
+
if (hadRequest !== (request !== null)) {
|
|
72
|
+
setHadRequest(request !== null);
|
|
73
|
+
if (!request) {
|
|
74
|
+
setResults([]);
|
|
75
|
+
setSearched(false);
|
|
76
|
+
setActiveIndex(-1);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
40
79
|
const busy = loading || resolving;
|
|
41
80
|
const tooShort = query.trim().length > 0 && query.trim().length < minLength;
|
|
42
81
|
const hasPanel = open && (tooShort || busy || results.length > 0 || searched);
|
|
43
|
-
const applyResults = useCallback((found) => {
|
|
44
|
-
// Podpowiedź bez współrzędnych ma sens tylko wtedy, gdy port umie ją uzupełnić —
|
|
45
|
-
// pozycja, która nie ma dokąd polecieć, jest gorsza od jej braku.
|
|
46
|
-
setResults(geocoder?.resolve ? found : found.filter((suggestion) => suggestion.at));
|
|
47
|
-
setLoading(false);
|
|
48
|
-
setSearched(true);
|
|
49
|
-
setActiveIndex(-1);
|
|
50
|
-
setOpen(true);
|
|
51
|
-
}, [geocoder]);
|
|
52
82
|
// Odpytanie geokodera po odczekaniu `debounce` od ostatniego znaku. Sprzątanie kasuje
|
|
53
|
-
// zarówno niewystrzelony timer, jak i zapytanie w locie
|
|
83
|
+
// zarówno niewystrzelony timer, jak i zapytanie w locie - adapter przerywa wtedy `fetch`.
|
|
54
84
|
useEffect(() => {
|
|
55
|
-
|
|
56
|
-
if (!geocoder?.search || needle.length < minLength) {
|
|
57
|
-
setResults([]);
|
|
58
|
-
setLoading(false);
|
|
59
|
-
setSearched(false);
|
|
60
|
-
setActiveIndex(-1);
|
|
85
|
+
if (!request)
|
|
61
86
|
return;
|
|
62
|
-
}
|
|
63
|
-
|
|
87
|
+
const { geocoder: port, needle: phrase, options } = request;
|
|
88
|
+
const applyResults = (found) => {
|
|
89
|
+
// Podpowiedź bez współrzędnych ma sens tylko wtedy, gdy port umie ją uzupełnić -
|
|
90
|
+
// pozycja, która nie ma dokąd polecieć, jest gorsza od jej braku.
|
|
91
|
+
setResults(port.resolve ? found : found.filter((suggestion) => suggestion.at));
|
|
92
|
+
setSettled(request);
|
|
93
|
+
setSearched(true);
|
|
94
|
+
setActiveIndex(-1);
|
|
95
|
+
setOpen(true);
|
|
96
|
+
};
|
|
64
97
|
const controller = new AbortController();
|
|
65
98
|
const timer = setTimeout(() => {
|
|
66
|
-
|
|
67
|
-
.search(
|
|
68
|
-
language: locale,
|
|
69
|
-
limit,
|
|
70
|
-
viewbox: viewbox ?? undefined,
|
|
71
|
-
countryCodes: countryCodes ?? undefined,
|
|
72
|
-
signal: controller.signal,
|
|
73
|
-
})
|
|
99
|
+
port
|
|
100
|
+
.search(phrase, { ...options, signal: controller.signal })
|
|
74
101
|
.then((found) => {
|
|
75
102
|
if (!controller.signal.aborted)
|
|
76
103
|
applyResults(found);
|
|
@@ -85,7 +112,7 @@ export function KptMapSearch({ geocoder = null, placeholder = '', minLength = 3,
|
|
|
85
112
|
clearTimeout(timer);
|
|
86
113
|
controller.abort();
|
|
87
114
|
};
|
|
88
|
-
}, [
|
|
115
|
+
}, [request, debounce]);
|
|
89
116
|
useEffect(() => () => pending.current?.abort(), []);
|
|
90
117
|
const status = (() => {
|
|
91
118
|
if (tooShort)
|
|
@@ -102,11 +129,11 @@ export function KptMapSearch({ geocoder = null, placeholder = '', minLength = 3,
|
|
|
102
129
|
})();
|
|
103
130
|
/**
|
|
104
131
|
* Wybór podpowiedzi. Dostawca, który podał współrzędne na liście, emituje natychmiast;
|
|
105
|
-
* podpowiedź bez `at` trzeba najpierw uzupełnić
|
|
132
|
+
* podpowiedź bez `at` trzeba najpierw uzupełnić - jedno wywołanie `resolve()` na *wybór*,
|
|
106
133
|
* nigdy w trakcie pisania.
|
|
107
134
|
*/
|
|
108
135
|
const pick = (suggestion) => {
|
|
109
|
-
// Etykieta wraca do pola, ale `term` zostaje
|
|
136
|
+
// Etykieta wraca do pola, ale `term` zostaje - inaczej wybór odpaliłby kolejne zapytanie.
|
|
110
137
|
setQuery(suggestion.label);
|
|
111
138
|
setActiveIndex(-1);
|
|
112
139
|
setUnresolved(false);
|
|
@@ -171,14 +198,14 @@ export function KptMapSearch({ geocoder = null, placeholder = '', minLength = 3,
|
|
|
171
198
|
case 'Enter': {
|
|
172
199
|
const result = results[activeIndex];
|
|
173
200
|
if (result) {
|
|
174
|
-
// Pole bywa w formularzu aplikacji
|
|
201
|
+
// Pole bywa w formularzu aplikacji - Enter nie ma go wysyłać.
|
|
175
202
|
event.preventDefault();
|
|
176
203
|
pick(result);
|
|
177
204
|
}
|
|
178
205
|
break;
|
|
179
206
|
}
|
|
180
207
|
case 'Escape':
|
|
181
|
-
// Pierwszy Esc zamyka listę, drugi czyści pole
|
|
208
|
+
// Pierwszy Esc zamyka listę, drugi czyści pole - jak w polu wyszukiwania przeglądarki.
|
|
182
209
|
if (open)
|
|
183
210
|
setOpen(false);
|
|
184
211
|
else if (query)
|
|
@@ -189,12 +216,12 @@ export function KptMapSearch({ geocoder = null, placeholder = '', minLength = 3,
|
|
|
189
216
|
}
|
|
190
217
|
};
|
|
191
218
|
const optionId = (index) => `${uid}-opt-${index}`;
|
|
192
|
-
return (_jsxs("div", { className: cn('kpt-map-search', className), ...rest, children: [_jsxs("div", { className: "kpt-map-search__field", children: [_jsx("span", { className: "kpt-map-search__icon", "aria-hidden": "true", children: _jsx(KptIcon, { name: "search" }) }), _jsx("input", { className: "kpt-map-search__input", type: "text", autoComplete: "off", autoCapitalize: "off", spellCheck: false, role: "combobox", "aria-autocomplete": "list", id: uid, value: query, placeholder: placeholder || t('map.search.placeholder'), disabled: disabled || !canSearch, "aria-label": t('map.search.label'), "aria-expanded": hasPanel, "aria-busy": busy || undefined, "aria-controls": hasPanel ? `${uid}-
|
|
219
|
+
return (_jsxs("div", { className: cn('kpt-map-search', className), ...rest, children: [_jsxs("div", { className: "kpt-map-search__field", children: [_jsx("span", { className: "kpt-map-search__icon", "aria-hidden": "true", children: _jsx(KptIcon, { name: "search" }) }), _jsx("input", { ref: inputRef, className: "kpt-map-search__input", type: "text", autoComplete: "off", autoCapitalize: "off", spellCheck: false, role: "combobox", "aria-autocomplete": "list", id: uid, value: query, placeholder: placeholder || t('map.search.placeholder'), disabled: disabled || !canSearch, "aria-label": t('map.search.label'), "aria-expanded": hasPanel, "aria-busy": busy || undefined, "aria-controls": hasPanel && results.length && !tooShort && !busy ? `${uid}-list` : undefined, "aria-activedescendant": activeIndex >= 0 ? optionId(activeIndex) : undefined, onChange: (event) => {
|
|
193
220
|
setQuery(event.target.value);
|
|
194
221
|
setTerm(event.target.value);
|
|
195
222
|
setOpen(true);
|
|
196
223
|
setUnresolved(false);
|
|
197
|
-
}, onFocus: () => setOpen(true), onBlur: () => setOpen(false), onKeyDown: onKeyDown }), query ? (_jsx("button", { className: "kpt-map-search__clear", type: "button", "aria-label": t('map.search.clear'), title: t('map.search.clear'), onClick: clear, children: _jsx(KptIcon, { name: "x" }) })) : null] }), hasPanel ? (_jsx("div", { className: "kpt-map-search__panel", id: `${uid}-panel`, children: tooShort ? (_jsx("p", { className: "kpt-map-search__note", children: t('map.search.minLength', { count: minLength }) })) : busy ? (_jsx("p", { className: "kpt-map-search__note", children: t('map.search.searching') })) : results.length ? (_jsx("ul", { className: "kpt-map-search__list", role: "listbox", "aria-label": t('map.search.results'), children: results.map((result, index) => (_jsxs("li", { className: cn('kpt-map-search__option', index === activeIndex && 'is-active'), role: "option", id: optionId(index), "aria-selected": index === activeIndex, onMouseDown: (event) => {
|
|
224
|
+
}, onFocus: () => setOpen(true), onBlur: () => setOpen(false), onKeyDown: onKeyDown }), query ? (_jsx("button", { className: "kpt-map-search__clear", type: "button", "aria-label": t('map.search.clear'), title: t('map.search.clear'), onClick: clear, children: _jsx(KptIcon, { name: "x" }) })) : null, speech ? (_jsx(KptSpeechButton, { listeningColor: speechColor, target: inputRef, lang: speechLang, mode: "replace", continuous: false, size: "sm", unsupported: "hide", disabled: disabled || !canSearch, hostProps: { className: 'kpt-map-search__speech' } })) : null] }), hasPanel ? (_jsx("div", { className: "kpt-map-search__panel", id: `${uid}-panel`, children: tooShort ? (_jsx("p", { className: "kpt-map-search__note", children: t('map.search.minLength', { count: minLength }) })) : busy ? (_jsx("p", { className: "kpt-map-search__note", children: t('map.search.searching') })) : results.length ? (_jsx("ul", { className: "kpt-map-search__list", id: `${uid}-list`, role: "listbox", "aria-label": t('map.search.results'), children: results.map((result, index) => (_jsxs("li", { className: cn('kpt-map-search__option', index === activeIndex && 'is-active'), role: "option", id: optionId(index), "aria-selected": index === activeIndex, onMouseDown: (event) => {
|
|
198
225
|
event.preventDefault();
|
|
199
226
|
pick(result);
|
|
200
227
|
}, onMouseEnter: () => setActiveIndex(index), children: [_jsx("span", { className: "kpt-map-search__pin", "aria-hidden": "true", children: _jsx(KptIcon, { name: "map-pin" }) }), _jsx("span", { className: "kpt-map-search__label", children: result.label })] }, result.id))) })) : (_jsx("p", { className: "kpt-map-search__note", children: t('map.search.noResults') })) })) : null, _jsx("p", { className: "kpt-map-search__status", "aria-live": "polite", children: status })] }));
|
package/dist/map/map.d.ts
CHANGED
|
@@ -2,7 +2,8 @@ import type { KptClusterOptions, KptLatLng, KptMapBounds, KptMapCategory, KptMap
|
|
|
2
2
|
import { type ComponentPropsWithRef, type ReactNode } from 'react';
|
|
3
3
|
import { type KptI18nOverrides } from '../i18n/i18n-context.tsx';
|
|
4
4
|
import type { KptMapGeocoderPort, KptMapGeolocationPort } from './ports.ts';
|
|
5
|
-
|
|
5
|
+
import type { KptSpeechColor } from '../speech/speech-button.tsx';
|
|
6
|
+
/** Kontekst treści popupu - odpowiednik kontekstu szablonu `kptMapPopup` z portu Angulara. */
|
|
6
7
|
export interface KptMapPopupContext<T> {
|
|
7
8
|
location: KptMapLocation<T>;
|
|
8
9
|
data: T | undefined;
|
|
@@ -11,7 +12,7 @@ export interface KptMapPopupContext<T> {
|
|
|
11
12
|
distance: number | null;
|
|
12
13
|
close: () => void;
|
|
13
14
|
}
|
|
14
|
-
/** Kontekst własnego formularza
|
|
15
|
+
/** Kontekst własnego formularza "dodaj lokalizację". */
|
|
15
16
|
export interface KptMapCreateFormApi {
|
|
16
17
|
at: KptLatLng;
|
|
17
18
|
category: KptMapCategory;
|
|
@@ -21,7 +22,7 @@ export interface KptMapCreateFormApi {
|
|
|
21
22
|
export interface KptMapProps<T = unknown> extends Omit<ComponentPropsWithRef<'div'>, 'children' | 'onSelect'>, KptI18nOverrides {
|
|
22
23
|
locations: readonly KptMapLocation<T>[];
|
|
23
24
|
categories: readonly KptMapCategory[];
|
|
24
|
-
/** Kod kraju z presetów (`PL`, `DE`, `EU
|
|
25
|
+
/** Kod kraju z presetów (`PL`, `DE`, `EU`...). Nieznany kod cofa się do Polski. */
|
|
25
26
|
country?: string;
|
|
26
27
|
/** Jawny widok startowy; nadpisuje `country`. */
|
|
27
28
|
view?: KptMapView | null;
|
|
@@ -36,16 +37,16 @@ export interface KptMapProps<T = unknown> extends Omit<ComponentPropsWithRef<'di
|
|
|
36
37
|
/** Renderuje legendę pod mapą. */
|
|
37
38
|
legend?: boolean;
|
|
38
39
|
legendCounts?: boolean;
|
|
39
|
-
/** Identyfikatory ukrytych kategorii
|
|
40
|
+
/** Identyfikatory ukrytych kategorii - kontrolowane albo niekontrolowane. */
|
|
40
41
|
hiddenCategories?: string[];
|
|
41
42
|
defaultHiddenCategories?: string[];
|
|
42
43
|
onHiddenCategoriesChange?: (hidden: string[]) => void;
|
|
43
44
|
showUserLocation?: boolean;
|
|
44
45
|
/** Przy każdej nowej pozycji centruje mapę na użytkowniku. */
|
|
45
46
|
followUser?: boolean;
|
|
46
|
-
/** Źródło pozycji użytkownika. Bez niego kontrolka
|
|
47
|
+
/** Źródło pozycji użytkownika. Bez niego kontrolka "moje położenie" nie ma czego pokazać. */
|
|
47
48
|
geolocation?: KptMapGeolocationPort | null;
|
|
48
|
-
/** Włącza menu
|
|
49
|
+
/** Włącza menu "Dodaj lokalizację" pod prawym przyciskiem myszy. */
|
|
49
50
|
allowCreate?: boolean;
|
|
50
51
|
/** Pokazuje wyszukiwarkę adresów. Wymaga geokodera **z metodą `search()`**. */
|
|
51
52
|
search?: boolean;
|
|
@@ -60,29 +61,35 @@ export interface KptMapProps<T = unknown> extends Omit<ComponentPropsWithRef<'di
|
|
|
60
61
|
searchZoom?: number;
|
|
61
62
|
/** Zostawia tymczasową pinezkę w znalezionym punkcie. */
|
|
62
63
|
searchMarker?: boolean;
|
|
63
|
-
/**
|
|
64
|
+
/** Mikrofon w wyszukiwarce - adres podyktowany zamiast wpisanego (patrz `KptMapSearch`). */
|
|
65
|
+
searchSpeech?: boolean;
|
|
66
|
+
/** Język dyktowania adresu (BCP 47); bez niego z `KptI18nProvider`. */
|
|
67
|
+
searchSpeechLang?: string;
|
|
68
|
+
/** Kolor "stop" i fali w trakcie nasłuchu; domyślnie kolor motywu. */
|
|
69
|
+
searchSpeechColor?: KptSpeechColor;
|
|
70
|
+
/** Geokoder tej mapy - obsługuje i wyszukiwarkę, i podpowiedzi adresu w formularzu. */
|
|
64
71
|
geocoder?: KptMapGeocoderPort | null;
|
|
65
72
|
/** `card` oddaje popup w całości treści: bez paddingu, szerszy, z przewijaniem. */
|
|
66
73
|
popupLayout?: 'plain' | 'card';
|
|
67
74
|
/** Punkt odniesienia dystansu w popupie; `null` = pozycja użytkownika. */
|
|
68
75
|
distanceFrom?: KptLatLng | null;
|
|
69
76
|
height?: string;
|
|
70
|
-
/** Bez znaczenia dla silnika Google
|
|
77
|
+
/** Bez znaczenia dla silnika Google - kafle i atrybucję dostarcza tam Google. */
|
|
71
78
|
tileUrl?: string | null;
|
|
72
79
|
attribution?: string | null;
|
|
73
80
|
/**
|
|
74
|
-
* Fabryka silnika tej mapy. W Reakcie nie ma DI, więc to jedyna droga
|
|
81
|
+
* Fabryka silnika tej mapy. W Reakcie nie ma DI, więc to jedyna droga - i dobrze:
|
|
75
82
|
* dwie mapy o różnych silnikach mieszczą się na stronie bez żadnych opakowań.
|
|
76
83
|
* Czytana raz, przy inicjalizacji.
|
|
77
84
|
*/
|
|
78
85
|
engine: KptMapEngineFactory;
|
|
79
86
|
/** Treść popupu. Bez niej popup pokazuje tytuł i nazwę kategorii. */
|
|
80
87
|
renderPopup?: (context: KptMapPopupContext<T>) => ReactNode;
|
|
81
|
-
/** Własny formularz
|
|
88
|
+
/** Własny formularz "dodaj lokalizację"; jego obecność wyłącza formularz ze schemy. */
|
|
82
89
|
renderCreateForm?: (api: KptMapCreateFormApi) => ReactNode;
|
|
83
90
|
onLocationClick?: (location: KptMapLocation<T>) => void;
|
|
84
91
|
onClusterClick?: (cluster: KptMapCluster<T>) => void;
|
|
85
|
-
/** Komponent **nie dopisuje** nic do `locations`
|
|
92
|
+
/** Komponent **nie dopisuje** nic do `locations` - źródłem prawdy jest aplikacja. */
|
|
86
93
|
onLocationCreate?: (event: KptMapCreateEvent) => void;
|
|
87
94
|
/** Wybrano podpowiedź wyszukiwarki; mapa już przeniosła widok. */
|
|
88
95
|
onSearchSelect?: (result: KptMapSearchResult) => void;
|
|
@@ -93,12 +100,17 @@ export interface KptMapProps<T = unknown> extends Omit<ComponentPropsWithRef<'di
|
|
|
93
100
|
}) => void;
|
|
94
101
|
onUserPositionChange?: (position: KptMapUserPosition | null) => void;
|
|
95
102
|
onUserLocationError?: (error: KptMapGeolocationError) => void;
|
|
103
|
+
/**
|
|
104
|
+
* Silnika nie udało się uruchomić - brak paczki `leaflet`, odrzucony klucz Google. Błąd i tak
|
|
105
|
+
* trafia do konsoli; callback pozwala aplikacji pokazać własny komunikat zamiast szarego prostokąta.
|
|
106
|
+
*/
|
|
107
|
+
onEngineError?: (error: unknown) => void;
|
|
96
108
|
}
|
|
97
109
|
/**
|
|
98
110
|
* Mapa z konfigurowalnymi znacznikami: kategorie z kolorem i ikoną, grupowanie z licznikiem,
|
|
99
111
|
* popup szczegółów, legenda, wyszukiwarka adresów i dodawanie lokalizacji prawym przyciskiem.
|
|
100
112
|
*
|
|
101
|
-
* Silnik (Leaflet albo Google) przychodzi propem `engine` z `@konce-pt/map`
|
|
113
|
+
* Silnik (Leaflet albo Google) przychodzi propem `engine` z `@konce-pt/map` - ta sama warstwa,
|
|
102
114
|
* na której stoi port Angulara. Leaflet ładuje się dynamicznym `import()`, więc aplikacja bez
|
|
103
115
|
* mapy go nie pobiera; wymaga też arkusza `leaflet/dist/leaflet.css`.
|
|
104
116
|
*
|
|
@@ -110,4 +122,4 @@ export interface KptMapProps<T = unknown> extends Omit<ComponentPropsWithRef<'di
|
|
|
110
122
|
* renderPopup={({ location, data }) => <strong>{location.title}</strong>}
|
|
111
123
|
* />
|
|
112
124
|
*/
|
|
113
|
-
export declare function KptMap<T = unknown>({ locations, categories, country, view, bounds, restrictToCountry, cluster, clusterOptions, clusterColorBy, legend, legendCounts, hiddenCategories, defaultHiddenCategories, onHiddenCategoriesChange, showUserLocation, followUser, geolocation, allowCreate, search, searchPlaceholder, searchOptions, searchZoom, searchMarker, geocoder, popupLayout, distanceFrom, height, tileUrl, attribution, engine, renderPopup, renderCreateForm, onLocationClick, onClusterClick, onLocationCreate, onSearchSelect, onViewChange, onUserPositionChange, onUserLocationError, locale: localeOverride, dictionary, className, style, ...rest }: Readonly<KptMapProps<T>>): import("react").JSX.Element;
|
|
125
|
+
export declare function KptMap<T = unknown>({ locations, categories, country, view, bounds, restrictToCountry, cluster, clusterOptions, clusterColorBy, legend, legendCounts, hiddenCategories, defaultHiddenCategories, onHiddenCategoriesChange, showUserLocation, followUser, geolocation, allowCreate, search, searchPlaceholder, searchOptions, searchZoom, searchMarker, searchSpeech, searchSpeechLang, searchSpeechColor, geocoder, popupLayout, distanceFrom, height, tileUrl, attribution, engine, renderPopup, renderCreateForm, onLocationClick, onClusterClick, onLocationCreate, onSearchSelect, onViewChange, onUserPositionChange, onUserLocationError, onEngineError, locale: localeOverride, dictionary, className, style, ...rest }: Readonly<KptMapProps<T>>): import("react").JSX.Element;
|