@tedi-design-system/react 19.1.0-rc.2 → 19.1.0-rc.20
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/DESIGN.md +308 -0
- package/README.md +28 -0
- package/_virtual/index.es13.js +2 -2
- package/_virtual/index.es14.js +2 -2
- package/bundle-stats.html +1 -1
- package/community.cjs.js +1 -1
- package/community.es.js +215 -223
- package/component.manifest.json +1234 -0
- package/external/@floating-ui/core/dist/floating-ui.core.es.js +1 -1
- package/external/@floating-ui/dom/dist/floating-ui.dom.es.js +2 -2
- package/external/@floating-ui/react-dom/dist/floating-ui.react-dom.es.js +5 -5
- package/external/@mui/x-date-pickers/DatePicker/shared.es.js +1 -1
- package/external/@mui/x-date-pickers/DateTimePicker/shared.es.js +1 -1
- package/external/hoist-non-react-statics/external/react-is/cjs/react-is.development.cjs.js +1 -1
- package/external/hoist-non-react-statics/external/react-is/cjs/react-is.development.es.js +1 -1
- package/external/hoist-non-react-statics/external/react-is/cjs/react-is.production.min.cjs.js +1 -1
- package/external/hoist-non-react-statics/external/react-is/cjs/react-is.production.min.es.js +1 -1
- package/external/hoist-non-react-statics/external/react-is/index.cjs.js +1 -1
- package/external/hoist-non-react-statics/external/react-is/index.es.js +1 -1
- package/external/prop-types/external/react-is/cjs/react-is.development.cjs.js +1 -1
- package/external/prop-types/external/react-is/cjs/react-is.development.es.js +1 -1
- package/external/prop-types/external/react-is/cjs/react-is.production.min.cjs.js +1 -1
- package/external/prop-types/external/react-is/cjs/react-is.production.min.es.js +1 -1
- package/external/prop-types/external/react-is/index.cjs.js +1 -1
- package/external/prop-types/external/react-is/index.es.js +1 -1
- package/external/react-is/index.cjs.js +1 -1
- package/external/react-is/index.es.js +1 -1
- package/external/toposort/index.cjs.js +1 -1
- package/external/toposort/index.es.js +1 -1
- package/index.css +1 -1
- package/package.json +3 -3
- package/src/community/components/accordion/accordion.cjs.js +1 -1
- package/src/community/components/accordion/accordion.es.js +14 -9
- package/src/community/components/card/card-notification/card-notification.cjs.js +1 -1
- package/src/community/components/card/card-notification/card-notification.es.js +10 -8
- package/src/community/components/dock-panel/dock-panel.cjs.js +2 -0
- package/src/community/components/dock-panel/dock-panel.d.ts +110 -0
- package/src/community/components/dock-panel/dock-panel.es.js +138 -0
- package/src/community/components/dock-panel/dock-panel.module.scss.cjs.js +1 -0
- package/src/community/components/dock-panel/dock-panel.module.scss.es.js +18 -0
- package/src/community/components/dropdown/dropdown.cjs.js +1 -1
- package/src/community/components/dropdown/dropdown.es.js +34 -32
- package/src/community/components/form/category-search/category-search.cjs.js +1 -0
- package/src/community/components/form/category-search/category-search.d.ts +9 -0
- package/src/community/components/form/category-search/category-search.es.js +297 -0
- package/src/community/components/form/category-search/category-search.module.scss.cjs.js +1 -0
- package/src/community/components/form/category-search/category-search.module.scss.es.js +21 -0
- package/src/community/components/form/category-search/category-search.types.d.ts +162 -0
- package/src/community/components/form/category-search/define-category-search-category.cjs.js +1 -0
- package/src/community/components/form/category-search/define-category-search-category.d.ts +7 -0
- package/src/community/components/form/category-search/define-category-search-category.es.js +25 -0
- package/src/community/components/form/category-search/index.d.ts +3 -0
- package/src/community/components/form/category-search/use-category-search.cjs.js +1 -0
- package/src/community/components/form/category-search/use-category-search.d.ts +17 -0
- package/src/community/components/form/category-search/use-category-search.es.js +64 -0
- package/src/community/components/form/file-upload/file-upload.cjs.js +1 -1
- package/src/community/components/form/file-upload/file-upload.es.js +43 -41
- package/src/community/components/form/pickers/calendar/calendar.cjs.js +1 -1
- package/src/community/components/form/pickers/calendar/calendar.es.js +41 -39
- package/src/community/components/form/pickers/timepicker/timepicker.cjs.js +1 -1
- package/src/community/components/form/pickers/timepicker/timepicker.es.js +33 -31
- package/src/community/components/form/toggle/toggle.cjs.js +1 -1
- package/src/community/components/form/toggle/toggle.es.js +30 -28
- package/src/community/components/map-components/base-map-selection/base-map-option.cjs.js +1 -1
- package/src/community/components/map-components/base-map-selection/base-map-option.d.ts +8 -5
- package/src/community/components/map-components/base-map-selection/base-map-option.es.js +63 -65
- package/src/community/components/map-components/base-map-selection/base-map-selection.cjs.js +1 -1
- package/src/community/components/map-components/base-map-selection/base-map-selection.d.ts +1 -4
- package/src/community/components/map-components/base-map-selection/base-map-selection.es.js +55 -55
- package/src/community/components/map-components/carousel/carousel.cjs.js +1 -1
- package/src/community/components/map-components/carousel/carousel.es.js +19 -17
- package/src/community/components/map-components/map-button/map-button.cjs.js +1 -1
- package/src/community/components/map-components/map-button/map-button.d.ts +12 -4
- package/src/community/components/map-components/map-button/map-button.es.js +43 -40
- package/src/community/components/map-components/map-dropdown/map-dropdown.cjs.js +1 -1
- package/src/community/components/map-components/map-dropdown/map-dropdown.es.js +51 -49
- package/src/community/components/status/status.cjs.js +1 -1
- package/src/community/components/status/status.es.js +14 -12
- package/src/community/components/stepper/stepper.cjs.js +1 -1
- package/src/community/components/stepper/stepper.es.js +33 -31
- package/src/community/components/table/table.cjs.js +1 -1
- package/src/community/components/table/table.es.js +9 -9
- package/src/community/components/table-of-contents/table-of-contents.cjs.js +1 -1
- package/src/community/components/table-of-contents/table-of-contents.es.js +21 -19
- package/src/community/components/tabs/tabs/tabs.cjs.js +1 -1
- package/src/community/components/tabs/tabs/tabs.es.js +29 -27
- package/src/community/components/vertical-stepper/vertical-stepper.cjs.js +1 -1
- package/src/community/components/vertical-stepper/vertical-stepper.es.js +8 -6
- package/src/community/deprecated-exports.cjs.js +1 -0
- package/src/community/deprecated-exports.d.ts +19 -0
- package/src/community/deprecated-exports.es.js +112 -0
- package/src/community/index.d.ts +3 -0
- package/src/tedi/components/content/card/card.d.ts +4 -0
- package/src/tedi/components/content/card/card.module.scss.cjs.js +1 -1
- package/src/tedi/components/content/card/card.module.scss.es.js +3 -2
- package/src/tedi/components/content/carousel/carousel.cjs.js +1 -1
- package/src/tedi/components/content/carousel/carousel.d.ts +5 -0
- package/src/tedi/components/content/carousel/carousel.es.js +20 -20
- package/src/tedi/components/content/carousel/use-carousel.cjs.js +1 -1
- package/src/tedi/components/content/carousel/use-carousel.d.ts +1 -1
- package/src/tedi/components/content/carousel/use-carousel.es.js +127 -127
- package/src/tedi/components/content/table-card/index.d.ts +1 -0
- package/src/tedi/components/content/table-card/table-card.cjs.js +1 -0
- package/src/tedi/components/content/table-card/table-card.d.ts +131 -0
- package/src/tedi/components/content/table-card/table-card.es.js +206 -0
- package/src/tedi/components/content/table-card/table-card.module.scss.cjs.js +1 -0
- package/src/tedi/components/content/table-card/table-card.module.scss.es.js +18 -0
- package/src/tedi/components/content/text-group/text-group-list/text-group-list.cjs.js +1 -1
- package/src/tedi/components/content/text-group/text-group-list/text-group-list.d.ts +42 -0
- package/src/tedi/components/content/text-group/text-group-list/text-group-list.es.js +41 -23
- package/src/tedi/components/content/text-group/text-group.cjs.js +1 -1
- package/src/tedi/components/content/text-group/text-group.d.ts +10 -0
- package/src/tedi/components/content/text-group/text-group.es.js +14 -13
- package/src/tedi/components/content/text-group/text-group.module.scss.cjs.js +1 -1
- package/src/tedi/components/content/text-group/text-group.module.scss.es.js +5 -1
- package/src/tedi/components/filter/filter/filter.cjs.js +1 -1
- package/src/tedi/components/filter/filter/filter.d.ts +5 -0
- package/src/tedi/components/filter/filter/filter.es.js +154 -144
- package/src/tedi/components/filter/filter/filter.module.scss.cjs.js +1 -1
- package/src/tedi/components/filter/filter/filter.module.scss.es.js +2 -1
- package/src/tedi/components/form/date-field/date-field-helpers.cjs.js +1 -1
- package/src/tedi/components/form/date-field/date-field-helpers.d.ts +12 -19
- package/src/tedi/components/form/date-field/date-field-helpers.es.js +27 -21
- package/src/tedi/components/form/date-field/date-field.cjs.js +1 -1
- package/src/tedi/components/form/date-field/date-field.d.ts +1 -1
- package/src/tedi/components/form/date-field/date-field.es.js +169 -164
- package/src/tedi/components/form/date-time-field/date-time-field.cjs.js +1 -1
- package/src/tedi/components/form/date-time-field/date-time-field.es.js +181 -176
- package/src/tedi/components/form/search/index.d.ts +1 -0
- package/src/tedi/components/form/search/search.cjs.js +1 -1
- package/src/tedi/components/form/search/search.d.ts +92 -1
- package/src/tedi/components/form/search/search.es.js +265 -69
- package/src/tedi/components/form/search/search.module.scss.cjs.js +1 -1
- package/src/tedi/components/form/search/search.module.scss.es.js +9 -1
- package/src/tedi/components/form/slider/slider.cjs.js +1 -1
- package/src/tedi/components/form/slider/slider.es.js +38 -38
- package/src/tedi/components/form/slider/slider.module.scss.cjs.js +1 -1
- package/src/tedi/components/form/slider/slider.module.scss.es.js +0 -1
- package/src/tedi/components/form/textfield/textfield.cjs.js +1 -1
- package/src/tedi/components/form/textfield/textfield.es.js +21 -21
- package/src/tedi/components/form/time-field/time-field.cjs.js +1 -1
- package/src/tedi/components/form/time-field/time-field.es.js +126 -124
- package/src/tedi/components/layout/mobile-nav/components/mobile-nav-toggle/mobile-nav-toggle.cjs.js +1 -1
- package/src/tedi/components/layout/mobile-nav/components/mobile-nav-toggle/mobile-nav-toggle.d.ts +1 -1
- package/src/tedi/components/layout/mobile-nav/components/mobile-nav-toggle/mobile-nav-toggle.es.js +28 -27
- package/src/tedi/components/layout/mobile-nav/mobile-nav.cjs.js +1 -1
- package/src/tedi/components/layout/mobile-nav/mobile-nav.d.ts +1 -1
- package/src/tedi/components/layout/mobile-nav/mobile-nav.es.js +124 -92
- package/src/tedi/components/layout/sidenav/sidenav.module.scss.cjs.js +1 -1
- package/src/tedi/components/layout/sidenav/sidenav.module.scss.es.js +1 -0
- package/src/tedi/components/misc/affix/affix.cjs.js +1 -1
- package/src/tedi/components/misc/affix/affix.es.js +20 -8
- package/src/tedi/components/navigation/table-of-contents/components/table-of-contents-collapsible/table-of-contents-collapsible.cjs.js +1 -1
- package/src/tedi/components/navigation/table-of-contents/components/table-of-contents-collapsible/table-of-contents-collapsible.d.ts +9 -1
- package/src/tedi/components/navigation/table-of-contents/components/table-of-contents-collapsible/table-of-contents-collapsible.es.js +78 -39
- package/src/tedi/components/navigation/table-of-contents/components/table-of-contents-item/table-of-contents-item.d.ts +6 -0
- package/src/tedi/components/navigation/table-of-contents/components/table-of-contents-row/table-of-contents-row.cjs.js +1 -1
- package/src/tedi/components/navigation/table-of-contents/components/table-of-contents-row/table-of-contents-row.es.js +23 -28
- package/src/tedi/components/navigation/table-of-contents/table-of-contents.cjs.js +1 -1
- package/src/tedi/components/navigation/table-of-contents/table-of-contents.d.ts +32 -21
- package/src/tedi/components/navigation/table-of-contents/table-of-contents.es.js +58 -55
- package/src/tedi/components/navigation/table-of-contents/table-of-contents.module.scss.cjs.js +1 -1
- package/src/tedi/components/navigation/table-of-contents/table-of-contents.module.scss.es.js +4 -1
- package/src/tedi/components/navigation/tabs/tabs-helpers.cjs.js +1 -1
- package/src/tedi/components/navigation/tabs/tabs-helpers.d.ts +5 -0
- package/src/tedi/components/navigation/tabs/tabs-helpers.es.js +7 -4
- package/src/tedi/components/navigation/tabs/tabs-trigger/tabs-trigger.cjs.js +1 -1
- package/src/tedi/components/navigation/tabs/tabs-trigger/tabs-trigger.es.js +17 -17
- package/src/tedi/components/overlays/dropdown/dropdown.cjs.js +1 -1
- package/src/tedi/components/overlays/dropdown/dropdown.d.ts +8 -0
- package/src/tedi/components/overlays/dropdown/dropdown.es.js +82 -72
- package/src/tedi/components/overlays/dropdown/dropdown.module.scss.cjs.js +1 -1
- package/src/tedi/components/overlays/dropdown/dropdown.module.scss.es.js +1 -0
- package/src/tedi/components/overlays/overlay/overlay-trigger.cjs.js +1 -1
- package/src/tedi/components/overlays/overlay/overlay-trigger.es.js +22 -21
- package/src/tedi/helpers/warn-deprecated/warn-deprecated.cjs.js +1 -0
- package/src/tedi/helpers/warn-deprecated/warn-deprecated.d.ts +12 -0
- package/src/tedi/helpers/warn-deprecated/warn-deprecated.es.js +11 -0
- package/src/tedi/index.d.ts +2 -1
- package/src/tedi/providers/label-provider/labels-map.cjs.js +1 -1
- package/src/tedi/providers/label-provider/labels-map.d.ts +44 -2
- package/src/tedi/providers/label-provider/labels-map.es.js +43 -1
- package/tedi.cjs.js +1 -1
- package/tedi.es.js +326 -324
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
import { jsx as r, jsxs as f, Fragment as
|
|
2
|
-
import { useFloating as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import { Button as
|
|
6
|
-
import { Calendar as
|
|
7
|
-
import { getLocaleDateParts as
|
|
8
|
-
import { TextField as
|
|
1
|
+
import { jsx as r, jsxs as f, Fragment as kt } from "react/jsx-runtime";
|
|
2
|
+
import { useFloating as Mt, useInteractions as wt, useDismiss as xt, useRole as Ct, FloatingPortal as Rt, FloatingFocusManager as Vt } from "../../../../../external/@floating-ui/react/dist/floating-ui.react.es.js";
|
|
3
|
+
import V from "../../../../../external/classnames/index.es.js";
|
|
4
|
+
import we, { useState as _, useRef as Et, useEffect as se, useMemo as W, useCallback as F } from "react";
|
|
5
|
+
import { Button as xe } from "../../buttons/button/button.es.js";
|
|
6
|
+
import { Calendar as Pt } from "../../content/calendar/calendar.es.js";
|
|
7
|
+
import { getLocaleDateParts as St, buildDateRegexSource as $t, buildDisabledMatchers as At, CALENDAR_POPOVER_OFFSET as Ot, CALENDAR_POPOVER_PADDING as Ce } from "../date-field/date-field-helpers.es.js";
|
|
8
|
+
import { TextField as Lt } from "../textfield/textfield.es.js";
|
|
9
9
|
import { TimePicker as Re } from "../time-picker/time-picker.es.js";
|
|
10
10
|
import i from "./date-time-field.module.scss.es.js";
|
|
11
|
-
import { useBreakpointProps as
|
|
12
|
-
import { useLabels as
|
|
13
|
-
import
|
|
14
|
-
import { et as
|
|
15
|
-
import { autoUpdate as
|
|
16
|
-
import { offset as
|
|
17
|
-
import { dateMatchModifiers as
|
|
18
|
-
const
|
|
19
|
-
const [
|
|
20
|
-
return
|
|
21
|
-
}, le = (a) => a instanceof Date,
|
|
11
|
+
import { useBreakpointProps as Ht } from "../../../helpers/hooks/use-breakpoint-props.es.js";
|
|
12
|
+
import { useLabels as It } from "../../../providers/label-provider/use-labels.es.js";
|
|
13
|
+
import Bt, { isBreakpointBelow as Yt } from "../../../helpers/hooks/use-breakpoint.es.js";
|
|
14
|
+
import { et as zt } from "../../../../../external/react-day-picker/dist/esm/locale/et.es.js";
|
|
15
|
+
import { autoUpdate as Gt } from "../../../../../external/@floating-ui/dom/dist/floating-ui.dom.es.js";
|
|
16
|
+
import { offset as Wt, flip as jt, shift as qt, size as Ut } from "../../../../../external/@floating-ui/react-dom/dist/floating-ui.react-dom.es.js";
|
|
17
|
+
import { dateMatchModifiers as Jt } from "../../../../../external/react-day-picker/dist/esm/utils/dateMatchModifiers.es.js";
|
|
18
|
+
const u = (a) => String(a).padStart(2, "0"), b = (a) => a ? `${u(a.getHours())}:${u(a.getMinutes())}` : "00:00", v = (a, d) => {
|
|
19
|
+
const [j, p] = d.split(":"), E = Number(j), P = Number(p), S = new Date(a);
|
|
20
|
+
return S.setHours(Number.isFinite(E) ? E : 0, Number.isFinite(P) ? P : 0, 0, 0), S;
|
|
21
|
+
}, le = (a) => a instanceof Date, Kt = (a) => a ? `${a.getFullYear()}-${u(a.getMonth() + 1)}-${u(a.getDate())}T${u(a.getHours())}:${u(a.getMinutes())}` : "", Qt = (a) => {
|
|
22
22
|
if (!a) return;
|
|
23
|
-
const
|
|
24
|
-
return isNaN(
|
|
25
|
-
},
|
|
26
|
-
const { getCurrentBreakpointProps:
|
|
27
|
-
layout:
|
|
23
|
+
const d = new Date(a);
|
|
24
|
+
return isNaN(d.getTime()) ? void 0 : d;
|
|
25
|
+
}, Xt = (a) => !a || le(a) ? {} : a, Zt = (a) => le(a) ? a : void 0, ei = we.forwardRef((a, d) => {
|
|
26
|
+
const { getCurrentBreakpointProps: j } = Ht(a.defaultServerBreakpoint), { getLabel: p } = It(), E = Bt(a.defaultServerBreakpoint), P = Yt(E, "md"), {
|
|
27
|
+
layout: S = "side-by-side",
|
|
28
28
|
useNativePicker: Ve = !1,
|
|
29
|
-
monthYearSelectType:
|
|
30
|
-
timeGridVariant:
|
|
29
|
+
monthYearSelectType: Ee = "dropdown",
|
|
30
|
+
timeGridVariant: Pe,
|
|
31
31
|
showOutsideDays: Se = !0,
|
|
32
32
|
availableTimes: N,
|
|
33
|
-
timeHeading:
|
|
34
|
-
clearable:
|
|
35
|
-
} =
|
|
36
|
-
id:
|
|
37
|
-
label:
|
|
38
|
-
placeholder:
|
|
39
|
-
className:
|
|
40
|
-
value:
|
|
41
|
-
defaultValue:
|
|
42
|
-
onChange:
|
|
43
|
-
required:
|
|
44
|
-
readOnly:
|
|
33
|
+
timeHeading: q = p("dateTimeField.timeHeading"),
|
|
34
|
+
clearable: $e = !0
|
|
35
|
+
} = j(a), {
|
|
36
|
+
id: Ae,
|
|
37
|
+
label: Oe,
|
|
38
|
+
placeholder: Le,
|
|
39
|
+
className: He,
|
|
40
|
+
value: oe,
|
|
41
|
+
defaultValue: Ie,
|
|
42
|
+
onChange: U,
|
|
43
|
+
required: de,
|
|
44
|
+
readOnly: Be,
|
|
45
45
|
disabled: $,
|
|
46
46
|
minDate: ce,
|
|
47
47
|
maxDate: me,
|
|
@@ -49,29 +49,29 @@ const p = (a) => String(a).padStart(2, "0"), _ = (a) => a ? `${p(a.getHours())}:
|
|
|
49
49
|
disableFuture: ue,
|
|
50
50
|
disabledMatchers: T,
|
|
51
51
|
stepMinutes: pe = 15,
|
|
52
|
-
initialMonth:
|
|
53
|
-
locale:
|
|
52
|
+
initialMonth: J,
|
|
53
|
+
locale: Ye = zt,
|
|
54
54
|
localeCode: k = "et-EE",
|
|
55
|
-
selectTimeLabel:
|
|
56
|
-
backLabel:
|
|
57
|
-
mode:
|
|
58
|
-
selectionLevel:
|
|
59
|
-
minYear:
|
|
60
|
-
maxYear:
|
|
55
|
+
selectTimeLabel: ze = p("dateTimeField.selectTime"),
|
|
56
|
+
backLabel: Ge = p("dateTimeField.back"),
|
|
57
|
+
mode: We = "single",
|
|
58
|
+
selectionLevel: je = "days",
|
|
59
|
+
minYear: qe,
|
|
60
|
+
maxYear: Ue,
|
|
61
61
|
inputProps: s,
|
|
62
|
-
disabledDateErrorMessage:
|
|
63
|
-
} = a, l =
|
|
64
|
-
|
|
65
|
-
D || (
|
|
66
|
-
}, [D,
|
|
67
|
-
const O =
|
|
62
|
+
disabledDateErrorMessage: Je = p("dateField.disabledDateError")
|
|
63
|
+
} = a, l = We === "range", h = Ve && !l, M = l ? "side-by-side" : S, he = Pe ?? (M === "multi-step" ? "radio" : "button"), ge = oe !== void 0, [Ke, Qe] = _(Ie), y = ge ? oe : Ke, c = l ? Xt(y) : {}, m = l ? void 0 : Zt(y), [D, K] = _(!1), [Xe, Q] = _("date"), [Ze, _e] = _("days"), X = l ? c.from : m, [et, A] = _(() => X ?? J ?? /* @__PURE__ */ new Date()), be = Et(X);
|
|
64
|
+
be.current = X, se(() => {
|
|
65
|
+
D || (Q("date"), _e("days"), A(be.current ?? J ?? /* @__PURE__ */ new Date()));
|
|
66
|
+
}, [D, J]);
|
|
67
|
+
const O = W(
|
|
68
68
|
() => new Intl.DateTimeFormat(k, {
|
|
69
69
|
day: "2-digit",
|
|
70
70
|
month: "2-digit",
|
|
71
71
|
year: "numeric"
|
|
72
72
|
}),
|
|
73
73
|
[k]
|
|
74
|
-
),
|
|
74
|
+
), tt = W(
|
|
75
75
|
() => new Intl.DateTimeFormat(k, {
|
|
76
76
|
day: "2-digit",
|
|
77
77
|
month: "2-digit",
|
|
@@ -79,7 +79,7 @@ const p = (a) => String(a).padStart(2, "0"), _ = (a) => a ? `${p(a.getHours())}:
|
|
|
79
79
|
}),
|
|
80
80
|
[k]
|
|
81
81
|
), L = F(
|
|
82
|
-
(e) => e ? `${O.format(e)} ${
|
|
82
|
+
(e) => e ? `${O.format(e)} ${u(e.getHours())}:${u(e.getMinutes())}` : "",
|
|
83
83
|
[O]
|
|
84
84
|
), H = F(
|
|
85
85
|
(e) => {
|
|
@@ -89,61 +89,61 @@ const p = (a) => String(a).padStart(2, "0"), _ = (a) => a ? `${p(a.getHours())}:
|
|
|
89
89
|
return !t && !n ? "" : n ? t ? `${t} – ${n}` : n : t;
|
|
90
90
|
},
|
|
91
91
|
[L]
|
|
92
|
-
),
|
|
93
|
-
const e =
|
|
94
|
-
return (
|
|
95
|
-
const
|
|
96
|
-
if (!
|
|
97
|
-
const
|
|
98
|
-
t.forEach((
|
|
99
|
-
|
|
92
|
+
), it = W(() => {
|
|
93
|
+
const e = St(O), { fieldOrder: t } = e, n = new RegExp(`^${$t(e)}\\s+(\\d{2}):(\\d{2})$`);
|
|
94
|
+
return (Dt) => {
|
|
95
|
+
const G = Dt.trim().match(n);
|
|
96
|
+
if (!G) return;
|
|
97
|
+
const Te = {};
|
|
98
|
+
t.forEach((Ft, Tt) => {
|
|
99
|
+
Te[Ft] = Number(G[Tt + 1]);
|
|
100
100
|
});
|
|
101
|
-
const
|
|
102
|
-
if (ae === void 0 || re === void 0 || ne === void 0 ||
|
|
103
|
-
const
|
|
104
|
-
if (!(isNaN(
|
|
105
|
-
return
|
|
101
|
+
const ke = Number(G[t.length + 1]), Me = Number(G[t.length + 2]), { day: ae, month: re, year: ne } = Te;
|
|
102
|
+
if (ae === void 0 || re === void 0 || ne === void 0 || ke > 23 || Me > 59) return;
|
|
103
|
+
const R = new Date(ne, re - 1, ae, ke, Me, 0, 0);
|
|
104
|
+
if (!(isNaN(R.getTime()) || R.getFullYear() !== ne || R.getMonth() !== re - 1 || R.getDate() !== ae))
|
|
105
|
+
return R;
|
|
106
106
|
};
|
|
107
|
-
}, [O]), [
|
|
107
|
+
}, [O]), [at, Z] = _(() => H(y)), [ve, g] = _(!1);
|
|
108
108
|
se(() => {
|
|
109
|
-
|
|
109
|
+
Z(H(y));
|
|
110
110
|
}, [y, H]);
|
|
111
|
-
const
|
|
111
|
+
const rt = Mt({
|
|
112
112
|
open: D,
|
|
113
|
-
onOpenChange:
|
|
113
|
+
onOpenChange: K,
|
|
114
114
|
placement: "bottom-end",
|
|
115
115
|
middleware: [
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
padding:
|
|
116
|
+
Wt(Ot),
|
|
117
|
+
jt(),
|
|
118
|
+
qt({ padding: Ce }),
|
|
119
|
+
Ut({
|
|
120
|
+
padding: Ce,
|
|
121
121
|
apply({ availableWidth: e, elements: t }) {
|
|
122
122
|
t.floating.style.maxWidth = `${e}px`;
|
|
123
123
|
}
|
|
124
124
|
})
|
|
125
125
|
],
|
|
126
|
-
whileElementsMounted:
|
|
127
|
-
}), { refs:
|
|
128
|
-
|
|
126
|
+
whileElementsMounted: Gt
|
|
127
|
+
}), { refs: ee, context: I, x: nt, y: st, strategy: lt } = rt, ot = wt([
|
|
128
|
+
xt(I, {
|
|
129
129
|
outsidePress: (e) => {
|
|
130
130
|
const t = e.target;
|
|
131
131
|
return !(t != null && t.closest('[role="menu"], [role="listbox"]'));
|
|
132
132
|
}
|
|
133
133
|
}),
|
|
134
|
-
|
|
135
|
-
]),
|
|
134
|
+
Ct(I, { role: "dialog" })
|
|
135
|
+
]), B = we.useRef(null), dt = F(
|
|
136
136
|
(e) => {
|
|
137
|
-
|
|
137
|
+
B.current = e, typeof d == "function" ? d(e) : d && (d.current = e);
|
|
138
138
|
},
|
|
139
|
-
[
|
|
139
|
+
[d]
|
|
140
140
|
);
|
|
141
141
|
se(() => {
|
|
142
142
|
var e;
|
|
143
|
-
(e =
|
|
144
|
-
}, [
|
|
145
|
-
const
|
|
146
|
-
ge ||
|
|
143
|
+
(e = B.current) != null && e.inner && ee.setReference(B.current.inner);
|
|
144
|
+
}, [ee]);
|
|
145
|
+
const o = (e) => {
|
|
146
|
+
ge || Qe(e), U == null || U(e), Z(H(e));
|
|
147
147
|
}, w = F(
|
|
148
148
|
(e) => {
|
|
149
149
|
if (N)
|
|
@@ -156,33 +156,33 @@ const p = (a) => String(a).padStart(2, "0"), _ = (a) => a ? `${p(a.getHours())}:
|
|
|
156
156
|
return !n || n.length === 0 || n.includes(t) ? t : n[0];
|
|
157
157
|
},
|
|
158
158
|
[w]
|
|
159
|
-
),
|
|
159
|
+
), ct = (e) => {
|
|
160
160
|
if (l) {
|
|
161
161
|
const t = e;
|
|
162
162
|
if (!t || !t.from && !t.to) {
|
|
163
|
-
|
|
163
|
+
o(void 0);
|
|
164
164
|
return;
|
|
165
165
|
}
|
|
166
166
|
const n = {};
|
|
167
|
-
t.from && (n.from = v(t.from, x(t.from,
|
|
167
|
+
t.from && (n.from = v(t.from, x(t.from, b(c.from)))), t.to && (n.to = v(t.to, x(t.to, b(c.to)))), o(n);
|
|
168
168
|
return;
|
|
169
169
|
}
|
|
170
|
-
e instanceof Date ?
|
|
171
|
-
},
|
|
170
|
+
e instanceof Date ? o(v(e, x(e, b(m)))) : e === void 0 && o(void 0);
|
|
171
|
+
}, mt = (e) => {
|
|
172
172
|
if (l) {
|
|
173
|
-
|
|
173
|
+
o({ from: v(e, x(e, b(c.from))) });
|
|
174
174
|
return;
|
|
175
175
|
}
|
|
176
|
-
|
|
177
|
-
},
|
|
176
|
+
o(v(e, x(e, b(m))));
|
|
177
|
+
}, ft = (e) => {
|
|
178
178
|
const t = m ?? /* @__PURE__ */ new Date();
|
|
179
|
-
|
|
180
|
-
},
|
|
179
|
+
o(v(t, e)), M === "multi-step" && w(t) && K(!1);
|
|
180
|
+
}, ut = (e) => (t) => {
|
|
181
181
|
const n = c[e] ?? c.from ?? /* @__PURE__ */ new Date();
|
|
182
|
-
|
|
183
|
-
},
|
|
182
|
+
o({ ...c, [e]: v(n, t) });
|
|
183
|
+
}, Y = W(
|
|
184
184
|
() => [
|
|
185
|
-
...
|
|
185
|
+
...At({
|
|
186
186
|
minDate: ce,
|
|
187
187
|
maxDate: me,
|
|
188
188
|
disablePast: fe,
|
|
@@ -192,40 +192,40 @@ const p = (a) => String(a).padStart(2, "0"), _ = (a) => a ? `${p(a.getHours())}:
|
|
|
192
192
|
],
|
|
193
193
|
[ce, me, fe, ue, T]
|
|
194
194
|
), Ne = F(
|
|
195
|
-
(e) =>
|
|
196
|
-
[
|
|
197
|
-
),
|
|
198
|
-
if (
|
|
199
|
-
|
|
195
|
+
(e) => Jt(e, Y),
|
|
196
|
+
[Y]
|
|
197
|
+
), pt = (e) => {
|
|
198
|
+
if (Z(e), e === "") {
|
|
199
|
+
g(!1), o(void 0);
|
|
200
200
|
return;
|
|
201
201
|
}
|
|
202
|
-
if (
|
|
203
|
-
const n =
|
|
202
|
+
if (h) {
|
|
203
|
+
const n = Qt(e);
|
|
204
204
|
if (!n) {
|
|
205
|
-
|
|
205
|
+
g(!1);
|
|
206
206
|
return;
|
|
207
207
|
}
|
|
208
208
|
if (Ne(n)) {
|
|
209
|
-
|
|
209
|
+
g(!0);
|
|
210
210
|
return;
|
|
211
211
|
}
|
|
212
|
-
|
|
212
|
+
g(!1), o(n), A(n);
|
|
213
213
|
return;
|
|
214
214
|
}
|
|
215
215
|
if (l) return;
|
|
216
|
-
const t =
|
|
216
|
+
const t = it(e);
|
|
217
217
|
if (!t) {
|
|
218
|
-
|
|
218
|
+
g(!1);
|
|
219
219
|
return;
|
|
220
220
|
}
|
|
221
221
|
if (Ne(t)) {
|
|
222
|
-
|
|
222
|
+
g(!0);
|
|
223
223
|
return;
|
|
224
224
|
}
|
|
225
|
-
|
|
226
|
-
},
|
|
225
|
+
g(!1), o(t), A(t);
|
|
226
|
+
}, ht = () => {
|
|
227
227
|
var t;
|
|
228
|
-
const e = (t =
|
|
228
|
+
const e = (t = B.current) == null ? void 0 : t.input;
|
|
229
229
|
if (e) {
|
|
230
230
|
if (typeof e.showPicker == "function") {
|
|
231
231
|
e.showPicker();
|
|
@@ -233,51 +233,51 @@ const p = (a) => String(a).padStart(2, "0"), _ = (a) => a ? `${p(a.getHours())}:
|
|
|
233
233
|
}
|
|
234
234
|
e.focus();
|
|
235
235
|
}
|
|
236
|
-
},
|
|
236
|
+
}, gt = () => {
|
|
237
237
|
if (!$) {
|
|
238
|
-
if (
|
|
239
|
-
|
|
238
|
+
if (h) {
|
|
239
|
+
ht();
|
|
240
240
|
return;
|
|
241
241
|
}
|
|
242
|
-
|
|
242
|
+
K((e) => !e);
|
|
243
243
|
}
|
|
244
|
-
},
|
|
245
|
-
|
|
244
|
+
}, _t = M === "multi-step" ? /* @__PURE__ */ r("div", { className: i["tedi-date-time-field__select-time-wrapper"], children: /* @__PURE__ */ r(xe, { type: "button", visualType: "link", size: "small", iconLeft: "schedule", onClick: () => Q("time"), children: ze }) }) : void 0, te = /* @__PURE__ */ r(
|
|
245
|
+
Pt,
|
|
246
246
|
{
|
|
247
|
-
view:
|
|
247
|
+
view: Ze,
|
|
248
248
|
setView: _e,
|
|
249
|
-
selectionLevel:
|
|
250
|
-
currentMonth:
|
|
249
|
+
selectionLevel: je,
|
|
250
|
+
currentMonth: et,
|
|
251
251
|
setCurrentMonth: A,
|
|
252
252
|
mode: l ? "range" : "single",
|
|
253
253
|
value: l ? c : m,
|
|
254
|
-
numberOfMonths: l && !
|
|
255
|
-
locale:
|
|
254
|
+
numberOfMonths: l && !P ? 2 : 1,
|
|
255
|
+
locale: Ye,
|
|
256
256
|
localeCode: k,
|
|
257
257
|
showOutsideDays: Se,
|
|
258
|
-
monthYearSelectType:
|
|
259
|
-
minYear:
|
|
260
|
-
maxYear:
|
|
261
|
-
disabledMatchers:
|
|
262
|
-
required:
|
|
263
|
-
handleSelect:
|
|
264
|
-
applyValue:
|
|
265
|
-
footer:
|
|
266
|
-
className:
|
|
258
|
+
monthYearSelectType: Ee,
|
|
259
|
+
minYear: qe,
|
|
260
|
+
maxYear: Ue,
|
|
261
|
+
disabledMatchers: Y.length ? Y : void 0,
|
|
262
|
+
required: de,
|
|
263
|
+
handleSelect: ct,
|
|
264
|
+
applyValue: mt,
|
|
265
|
+
footer: _t,
|
|
266
|
+
className: V(
|
|
267
267
|
i["tedi-date-time-field__calendar"],
|
|
268
268
|
M === "side-by-side" && i["tedi-date-time-field__calendar--split"]
|
|
269
269
|
)
|
|
270
270
|
}
|
|
271
|
-
), ie = w(m),
|
|
271
|
+
), ie = w(m), bt = !ie || ie.length === 0, ye = /* @__PURE__ */ r(
|
|
272
272
|
Re,
|
|
273
273
|
{
|
|
274
|
-
value:
|
|
274
|
+
value: b(m),
|
|
275
275
|
stepMinutes: pe,
|
|
276
276
|
availableTimes: ie,
|
|
277
277
|
gridVariant: he,
|
|
278
|
-
onChange:
|
|
279
|
-
className:
|
|
280
|
-
[i["tedi-date-time-field__time-picker--wheel"]]:
|
|
278
|
+
onChange: ft,
|
|
279
|
+
className: V(i["tedi-date-time-field__time-picker"], {
|
|
280
|
+
[i["tedi-date-time-field__time-picker--wheel"]]: bt
|
|
281
281
|
})
|
|
282
282
|
}
|
|
283
283
|
), De = (e) => {
|
|
@@ -285,52 +285,57 @@ const p = (a) => String(a).padStart(2, "0"), _ = (a) => a ? `${p(a.getHours())}:
|
|
|
285
285
|
return /* @__PURE__ */ r(
|
|
286
286
|
Re,
|
|
287
287
|
{
|
|
288
|
-
value:
|
|
288
|
+
value: b(c[e]),
|
|
289
289
|
stepMinutes: pe,
|
|
290
290
|
availableTimes: t,
|
|
291
291
|
gridVariant: he,
|
|
292
|
-
onChange:
|
|
293
|
-
className:
|
|
292
|
+
onChange: ut(e),
|
|
293
|
+
className: V(i["tedi-date-time-field__time-picker"], {
|
|
294
294
|
[i["tedi-date-time-field__time-picker--wheel"]]: n
|
|
295
295
|
})
|
|
296
296
|
}
|
|
297
297
|
);
|
|
298
|
-
},
|
|
298
|
+
}, C = s == null ? void 0 : s.helper, z = ve ? { text: Je, type: "error" } : null, vt = z ? C ? Array.isArray(C) ? [...C, z] : [C, z] : z : C, Fe = p("dateField.openCalendar"), Nt = h ? { "aria-label": Fe } : {
|
|
299
|
+
"aria-label": Fe,
|
|
300
|
+
"aria-haspopup": "dialog",
|
|
301
|
+
"aria-expanded": D,
|
|
302
|
+
"aria-controls": D ? I.floatingId : void 0
|
|
303
|
+
}, yt = {
|
|
299
304
|
...s,
|
|
300
|
-
id:
|
|
301
|
-
label:
|
|
302
|
-
value:
|
|
303
|
-
placeholder:
|
|
304
|
-
readOnly:
|
|
305
|
+
id: Ae,
|
|
306
|
+
label: Oe,
|
|
307
|
+
value: h ? Kt(m) : at,
|
|
308
|
+
placeholder: Le,
|
|
309
|
+
readOnly: Be || !h && !!N && !!y,
|
|
305
310
|
icon: "calendar_today",
|
|
306
|
-
isClearable:
|
|
307
|
-
required:
|
|
311
|
+
isClearable: $e,
|
|
312
|
+
required: de,
|
|
308
313
|
disabled: $,
|
|
309
|
-
invalid:
|
|
314
|
+
invalid: ve || (s == null ? void 0 : s.invalid),
|
|
310
315
|
helper: vt,
|
|
311
|
-
onIconClick:
|
|
312
|
-
|
|
313
|
-
|
|
316
|
+
onIconClick: gt,
|
|
317
|
+
iconButtonProps: Nt,
|
|
318
|
+
onChange: pt,
|
|
319
|
+
className: V(i["tedi-date-time-field__textfield"], s == null ? void 0 : s.className, {
|
|
314
320
|
[i["tedi-date-time-field__icon--disabled"]]: $
|
|
315
321
|
}),
|
|
316
322
|
input: {
|
|
317
323
|
...s == null ? void 0 : s.input,
|
|
318
|
-
type:
|
|
319
|
-
"aria-expanded": u ? void 0 : D
|
|
324
|
+
type: h ? "datetime-local" : "text"
|
|
320
325
|
}
|
|
321
326
|
};
|
|
322
|
-
return /* @__PURE__ */ f(
|
|
323
|
-
/* @__PURE__ */ r("div", { className:
|
|
324
|
-
!
|
|
327
|
+
return /* @__PURE__ */ f(kt, { children: [
|
|
328
|
+
/* @__PURE__ */ r("div", { className: V(i["tedi-date-time-field__container"], He), children: /* @__PURE__ */ r(Lt, { ref: dt, ...yt }) }),
|
|
329
|
+
!h && /* @__PURE__ */ r(Rt, { children: D && !$ && /* @__PURE__ */ r(Vt, { context: I, modal: !1, initialFocus: -1, children: /* @__PURE__ */ r(
|
|
325
330
|
"div",
|
|
326
331
|
{
|
|
327
|
-
ref:
|
|
332
|
+
ref: ee.setFloating,
|
|
328
333
|
className: i["tedi-date-time-field__popup"],
|
|
329
|
-
...
|
|
334
|
+
...ot.getFloatingProps({
|
|
330
335
|
style: {
|
|
331
|
-
position:
|
|
332
|
-
top:
|
|
333
|
-
left:
|
|
336
|
+
position: lt,
|
|
337
|
+
top: st ?? 0,
|
|
338
|
+
left: nt ?? 0
|
|
334
339
|
}
|
|
335
340
|
}),
|
|
336
341
|
children: l ? /* @__PURE__ */ f("div", { className: i["tedi-date-time-field__range"], children: [
|
|
@@ -338,11 +343,11 @@ const p = (a) => String(a).padStart(2, "0"), _ = (a) => a ? `${p(a.getHours())}:
|
|
|
338
343
|
/* @__PURE__ */ r("div", { className: i["tedi-date-time-field__range-separator"], "aria-hidden": "true", children: /* @__PURE__ */ r("div", { className: i["tedi-date-time-field__range-separator-line"] }) }),
|
|
339
344
|
/* @__PURE__ */ f("div", { className: i["tedi-date-time-field__range-times"], children: [
|
|
340
345
|
/* @__PURE__ */ f("div", { className: i["tedi-date-time-field__range-time"], children: [
|
|
341
|
-
/* @__PURE__ */ r("div", { className: i["tedi-date-time-field__split-time-header"], children: /* @__PURE__ */ r("span", { className: i["tedi-date-time-field__split-heading"], children:
|
|
346
|
+
/* @__PURE__ */ r("div", { className: i["tedi-date-time-field__split-time-header"], children: /* @__PURE__ */ r("span", { className: i["tedi-date-time-field__split-heading"], children: q }) }),
|
|
342
347
|
/* @__PURE__ */ r("div", { className: i["tedi-date-time-field__split-time-body"], children: De("from") })
|
|
343
348
|
] }),
|
|
344
349
|
/* @__PURE__ */ f("div", { className: i["tedi-date-time-field__range-time"], children: [
|
|
345
|
-
/* @__PURE__ */ r("div", { className: i["tedi-date-time-field__split-time-header"], children: /* @__PURE__ */ r("span", { className: i["tedi-date-time-field__split-heading"], children:
|
|
350
|
+
/* @__PURE__ */ r("div", { className: i["tedi-date-time-field__split-time-header"], children: /* @__PURE__ */ r("span", { className: i["tedi-date-time-field__split-heading"], children: q }) }),
|
|
346
351
|
/* @__PURE__ */ r("div", { className: i["tedi-date-time-field__split-time-body"], children: De("to") })
|
|
347
352
|
] })
|
|
348
353
|
] })
|
|
@@ -350,23 +355,23 @@ const p = (a) => String(a).padStart(2, "0"), _ = (a) => a ? `${p(a.getHours())}:
|
|
|
350
355
|
te,
|
|
351
356
|
/* @__PURE__ */ r("div", { className: i["tedi-date-time-field__split-separator"], "aria-hidden": "true", children: /* @__PURE__ */ r("div", { className: i["tedi-date-time-field__split-separator-line"] }) }),
|
|
352
357
|
/* @__PURE__ */ f("div", { className: i["tedi-date-time-field__split-time"], children: [
|
|
353
|
-
/* @__PURE__ */ r("div", { className: i["tedi-date-time-field__split-time-header"], children: /* @__PURE__ */ r("span", { className: i["tedi-date-time-field__split-heading"], children:
|
|
358
|
+
/* @__PURE__ */ r("div", { className: i["tedi-date-time-field__split-time-header"], children: /* @__PURE__ */ r("span", { className: i["tedi-date-time-field__split-heading"], children: q }) }),
|
|
354
359
|
/* @__PURE__ */ r("div", { className: i["tedi-date-time-field__split-time-body"], children: ye })
|
|
355
360
|
] })
|
|
356
|
-
] }) :
|
|
361
|
+
] }) : Xe === "date" ? te : /* @__PURE__ */ f("div", { className: i["tedi-date-time-field__time-step"], children: [
|
|
357
362
|
/* @__PURE__ */ f("header", { className: i["tedi-date-time-field__time-header"], children: [
|
|
358
363
|
/* @__PURE__ */ r(
|
|
359
|
-
|
|
364
|
+
xe,
|
|
360
365
|
{
|
|
361
366
|
type: "button",
|
|
362
367
|
visualType: "link",
|
|
363
368
|
size: "small",
|
|
364
369
|
iconLeft: "arrow_back",
|
|
365
|
-
onClick: () =>
|
|
366
|
-
children:
|
|
370
|
+
onClick: () => Q("date"),
|
|
371
|
+
children: Ge
|
|
367
372
|
}
|
|
368
373
|
),
|
|
369
|
-
/* @__PURE__ */ r("span", { className: i["tedi-date-time-field__time-date"], children:
|
|
374
|
+
/* @__PURE__ */ r("span", { className: i["tedi-date-time-field__time-date"], children: tt.format(m ?? /* @__PURE__ */ new Date()) })
|
|
370
375
|
] }),
|
|
371
376
|
/* @__PURE__ */ r("div", { className: i["tedi-date-time-field__time-body"], children: ye })
|
|
372
377
|
] })
|
|
@@ -374,7 +379,7 @@ const p = (a) => String(a).padStart(2, "0"), _ = (a) => a ? `${p(a.getHours())}:
|
|
|
374
379
|
) }) })
|
|
375
380
|
] });
|
|
376
381
|
});
|
|
377
|
-
|
|
382
|
+
ei.displayName = "DateTimeField";
|
|
378
383
|
export {
|
|
379
|
-
|
|
384
|
+
ei as DateTimeField
|
|
380
385
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './search';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),C=require("../../../../../external/@floating-ui/react/dist/floating-ui.react.cjs.js"),N=require("../../../../../external/classnames/index.cjs.js"),o=require("react"),Q=require("../../base/typography/text/text.cjs.js"),Je=require("../../buttons/button/button.cjs.js"),We=require("../../loaders/spinner/spinner.cjs.js"),H=require("../../misc/option-content/option-content.cjs.js"),Xe=require("../textfield/textfield.cjs.js"),s=require("./search.module.scss.cjs.js"),Ye=require("../../../providers/label-provider/use-labels.cjs.js"),Ze=require("../../../../../external/@floating-ui/dom/dist/floating-ui.dom.cjs.js"),D=require("../../../../../external/@floating-ui/react-dom/dist/floating-ui.react-dom.cjs.js"),$e=4,G=8,fe=["a[href]","area[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])","iframe",'[tabindex]:not([tabindex="-1"])'].join(","),et=(l,m)=>m?m(l):typeof l.label=="string"?l.label:String(l.value),tt=(l,m)=>{const x=m.trim();if(!x)return l;const h=l.toLowerCase().indexOf(x.toLowerCase());return h===-1?l:r.jsxs(r.Fragment,{children:[l.slice(0,h),r.jsx(Q.Text,{element:"span",modifiers:"bold",children:l.slice(h,h+x.length)}),l.slice(h+x.length)]})},he=o.forwardRef((l,m)=>{var ue;const{id:x,placeholder:h,isClearable:pe=!0,searchIcon:L="search",onSearch:u,onChange:q,onClear:be,onFocus:F,button:a,ariaLabel:me,className:xe,input:R,value:J,defaultValue:ye,suggestions:S,onSuggestionSelect:P,loading:v=!1,minQueryLength:W=0,hideOnScroll:_e=!1,renderSuggestionContent:E,getSuggestionText:ve,noResultsText:ge,loadingText:je,resultsCountText:Ce,footer:O,...I}=l,{getLabel:y}=Ye.useLabels(),Ne=o.useId(),k=x??Ne,d=S!==void 0,i=o.useMemo(()=>Array.isArray(S)?S:[],[S]),X=J!==void 0,[Re,Y]=o.useState(ye??""),f=J??Re,[K,g]=o.useState(!1),[c,B]=o.useState(null),Z=o.useRef([]),M=o.useRef(null),j=o.useRef(null),T=o.useRef(!1);o.useImperativeHandle(m,()=>j.current,[]);const $=f.trim().length>=W,z=!v&&i.length>0,Se=o.useMemo(()=>i.reduce((e,t,n)=>t.disabled?[...e,n]:e,[]),[i]),{refs:_,floatingStyles:Ie,context:ee}=C.useFloating({open:d&&K,onOpenChange:g,placement:"bottom-start",whileElementsMounted:Ze.autoUpdate,middleware:[D.offset($e),D.flip({padding:G}),D.shift({padding:G}),D.size({padding:G,apply({rects:e,elements:t,availableHeight:n}){t.floating.style.width=`${e.reference.width}px`,t.floating.style.setProperty("--tedi-search-panel-available-height",`${n}px`)}})]}),Te=C.useDismiss(ee,{ancestorScroll:_e}),we=C.useListNavigation(ee,{listRef:Z,activeIndex:c,onNavigate:B,virtual:!0,loop:!0,disabledIndices:Se}),{getReferenceProps:Ae,getFloatingProps:De,getItemProps:Le}=C.useInteractions([Te,we]);o.useEffect(()=>{var e;_.setPositionReference(((e=j.current)==null?void 0:e.inner)??null)},[_,d]);const te=`${k}-listbox`,ne=e=>`${k}-option-${e}`,p=d&&K&&$&&(v||z||f.trim().length>0),re=()=>M.current?Array.from(M.current.querySelectorAll(fe)):[],se=(e=!0)=>{var t,n;T.current=e,(n=(t=j.current)==null?void 0:t.input)==null||n.focus()},w=()=>{g(!1),B(null)},ae=e=>{e.disabled||(X||Y(et(e,ve)),P==null||P(e),w())},qe=e=>{X||Y(e),q==null||q(e),d&&(T.current=!1,B(null),g(e.trim().length>=W))},Fe=e=>{if(F==null||F(e),!!d){if(T.current){T.current=!1;return}$&&g(!0)}},Pe=e=>{e.key==="Enter"&&(u==null||u(f))},Ee=!v&&c!==null&&!((ue=i[c])!=null&&ue.disabled)?i[c]:void 0,Oe=()=>{var b,A;const e=(b=j.current)==null?void 0:b.input;if(!e)return;const t=_.floating.current,n=Array.from(document.body.querySelectorAll(fe)).filter(U=>!(t!=null&&t.contains(U)));(A=n[n.indexOf(e)+1])==null||A.focus()},ke=e=>{if(e.key==="Enter"){if(p&&c!==null&&i[c]&&!i[c].disabled){e.preventDefault(),ae(i[c]);return}u==null||u(f),g(!1);return}if(e.key==="Tab"&&!e.shiftKey&&p&&O){const t=re();t.length&&(e.preventDefault(),t[0].focus())}},Ke=e=>{if(!d||!K)return;const t=e.relatedTarget,n=_.floating.current;t&&(e.currentTarget.contains(t)||n!=null&&n.contains(t))||w()},Be=e=>{if(e.key==="Escape"){e.preventDefault(),w(),se();return}if(e.key!=="Tab")return;const t=re(),n=t.indexOf(e.target);e.shiftKey&&n===0?(e.preventDefault(),se()):!e.shiftKey&&n===t.length-1&&(e.preventDefault(),w(),Oe())},le=typeof L=="string"?{name:L}:L,Me={color:"secondary",...le,className:N.default(le.className,I.disabled&&s.default["tedi-search__icon--disabled"])},oe=d?Ae({role:"combobox","aria-autocomplete":"list","aria-expanded":p,"aria-controls":p&&z?te:void 0,"aria-activedescendant":p&&Ee&&c!==null?ne(c):void 0,onKeyDown:ke}):{role:"searchbox"},ie={...R,...oe};if(d){const e=R==null?void 0:R.onKeyDown,t=oe.onKeyDown;ie.onKeyDown=n=>{e==null||e(n),t==null||t(n)}}const ze={...I,ref:j,id:k,value:f,onChange:qe,onClear:be,onFocus:Fe,inputClassName:N.default(s.default["tedi-search__input"],a&&s.default["tedi-search__input--has-button"],xe),placeholder:h,isClearable:pe,input:ie,...a?{}:{icon:Me},...d?{}:{onKeyDown:Pe}},Ue=e=>{var t;(t=a==null?void 0:a.onClick)==null||t.call(a,e),u==null||u(f)},Ve=me||y("search"),ce=je??y("search.loading"),de=ge??y("search.no-results"),He=Ce??(e=>y("search.results-count",e)),Ge=p?v?ce:i.length>0?He(i.length):de:"",Qe=()=>v?r.jsxs("div",{className:s.default["tedi-search__panel-status"],children:[r.jsx(We.Spinner,{size:16}),r.jsx(Q.Text,{color:"tertiary",children:ce})]}):z?r.jsx("ul",{id:te,role:"listbox",className:s.default["tedi-search__panel-list"],children:i.map((e,t)=>{const n=c===t&&!e.disabled,b=typeof(e.label??e.value)=="string"?String(e.label??e.value):void 0,A=typeof e.description=="string"?e.description:void 0,U=!E&&b?[b,A].filter(Boolean).join(", "):void 0;return r.jsx("li",{id:ne(t),role:"option","aria-selected":n,"aria-disabled":e.disabled||void 0,"aria-label":U,ref:V=>{Z.current[t]=V},className:N.default(s.default["tedi-search__option"],{[s.default["tedi-search__option--active"]]:n,[s.default["tedi-search__option--disabled"]]:e.disabled}),...Le({onClick:()=>ae(e),onMouseDown:V=>V.preventDefault()}),children:E?E(e,{active:n,query:f}):r.jsxs(H.OptionContent,{disabled:e.disabled,layout:e.description!==void 0?"vertical":"horizontal",children:[r.jsx(H.OptionContent.Label,{children:b?tt(b,f):e.label??e.value}),e.description!==void 0&&r.jsx(H.OptionContent.Meta,{children:e.description})]})},e.value)})}):r.jsx("div",{className:s.default["tedi-search__panel-status"],children:r.jsx(Q.Text,{color:"tertiary",children:de})});return r.jsxs("div",{ref:_.setReference,className:N.default(s.default["tedi-search__wrapper"],I.size==="small"&&s.default["tedi-search__wrapper--small"],I.size==="large"&&s.default["tedi-search__wrapper--large"]),role:"search","aria-label":Ve,onBlur:Ke,children:[r.jsx(Xe.TextField,{...ze}),a&&r.jsx(Je.Button,{...a,onClick:Ue,className:N.default(s.default["tedi-search__button"],!a.children&&s.default["tedi-search__button--icon-only"],a.className),"aria-label":a["aria-label"]??(a.children?void 0:y("search")),children:a.children??y("search")}),d&&r.jsx("span",{"aria-live":"polite",role:"status",className:s.default["tedi-search__announcement"],children:Ge}),p&&r.jsx(C.FloatingPortal,{children:r.jsxs("div",{ref:_.setFloating,style:Ie,className:s.default["tedi-search__panel"],...De(),children:[Qe(),O&&r.jsx("div",{ref:M,className:s.default["tedi-search__footer"],onKeyDown:Be,children:O})]})})]})});he.displayName="Search";const nt=he;exports.Search=nt;
|