@alphakits/ui 2.3.0 → 2.4.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/dist/__internal/utils/index.d.ts +1 -1
- package/dist/__internal/utils/index.js +4 -4
- package/dist/amount-input/component.js +41 -41
- package/dist/avatar/component.js +2 -18
- package/dist/badge/component.d.ts +1 -1
- package/dist/base-card/component.js +1 -7
- package/dist/bottom-sheet/component.d.ts +1 -1
- package/dist/bottom-sheet/component.js +9 -13
- package/dist/box/component.d.ts +2 -2
- package/dist/box/component.js +4 -4
- package/dist/button/component.js +9 -9
- package/dist/button-arrow/component.js +6 -1
- package/dist/calendar/component.d.ts +1 -2
- package/dist/calendar/component.js +77 -74
- package/dist/calendar/components/days-table/component.js +46 -43
- package/dist/calendar/components/header/{/321/201omponent.js → component.js} +3 -12
- package/dist/calendar/components/header/index.d.ts +1 -1
- package/dist/calendar/components/header/index.js +1 -1
- package/dist/calendar/components/months-table/{/321/201omponent.js → component.js} +7 -7
- package/dist/calendar/components/months-table/index.d.ts +1 -1
- package/dist/calendar/components/months-table/index.js +1 -1
- package/dist/calendar/components/select-button/{/321/201omponent.d.ts → component.d.ts} +3 -3
- package/dist/calendar/components/select-button/{/321/201omponent.js → component.js} +5 -11
- package/dist/calendar/components/select-button/index.d.ts +1 -1
- package/dist/calendar/components/select-button/index.js +1 -1
- package/dist/calendar/components/years-table/{/321/201omponent.js → component.js} +14 -14
- package/dist/calendar/components/years-table/index.d.ts +1 -1
- package/dist/calendar/components/years-table/index.js +1 -1
- package/dist/calendar/index.d.ts +2 -2
- package/dist/calendar/index.js +4 -4
- package/dist/calendar/use-calendar.js +51 -47
- package/dist/calendar/utils.js +7 -9
- package/dist/calendar-input/component.js +22 -22
- package/dist/card/component.js +2 -18
- package/dist/cell/base/component.js +31 -31
- package/dist/cell/pure/component.js +2 -2
- package/dist/checkbox/component.js +11 -11
- package/dist/checkbox-group/component.js +23 -24
- package/dist/checkbox-lists/component.d.ts +1 -2
- package/dist/checkbox-lists/component.js +59 -61
- package/dist/collapsable-row/addons.d.ts +3 -4
- package/dist/collapsable-row/addons.js +6 -9
- package/dist/collapsable-row/component.d.ts +1 -1
- package/dist/collapsable-row/component.js +7 -7
- package/dist/collapse/component.js +45 -54
- package/dist/copy-button/component.d.ts +1 -2
- package/dist/copy-button/component.js +1 -5
- package/dist/date/component.js +1 -1
- package/dist/date-switcher/component.d.ts +1 -2
- package/dist/date-switcher/component.js +8 -8
- package/dist/decorated-item/component.js +10 -20
- package/dist/dot/component.js +1 -4
- package/dist/empty-page/component.js +1 -9
- package/dist/filter-tag/component.d.ts +1 -1
- package/dist/flex/component.d.ts +2 -2
- package/dist/footer/component.js +57 -53
- package/dist/form/component.d.ts +1 -2
- package/dist/form/component.js +2 -12
- package/dist/form/templates/base-form/index.d.ts +3 -3
- package/dist/form/templates/base-form/index.js +26 -26
- package/dist/form/templates/filters-form/index.d.ts +1 -1
- package/dist/form/templates/filters-form/index.js +20 -23
- package/dist/form/templates/rest-form/form.d.ts +1 -2
- package/dist/form/templates/rest-form/form.js +51 -56
- package/dist/form/templates/rest-form/index.d.ts +3 -3
- package/dist/form/templates/rest-form/index.js +16 -27
- package/dist/form/utils/get-default-values.js +3 -6
- package/dist/form/utils/remove-undefined-from-object.js +1 -3
- package/dist/form-control/component.js +1 -1
- package/dist/formik/index.d.ts +2 -2
- package/dist/header-search/component.js +1 -6
- package/dist/hooks/index.d.ts +2 -2
- package/dist/hooks/index.js +10 -10
- package/dist/hooks/use-get-one/index.js +16 -16
- package/dist/icon-button/component.d.ts +3 -3
- package/dist/icon-button/component.js +2 -8
- package/dist/image/component.js +52 -30
- package/dist/image/image-base.js +1 -7
- package/dist/image/use-image-render-component.d.ts +1 -1
- package/dist/image/use-image-render-component.js +11 -14
- package/dist/image-gallery/component.js +40 -45
- package/dist/image-uploader/component.js +56 -53
- package/dist/index.js +41 -41
- package/dist/info-block-wrapper/component.d.ts +1 -1
- package/dist/input/component.js +1 -1
- package/dist/input-autocomplete/autocomplete-field/index.d.ts +1 -2
- package/dist/input-autocomplete/autocomplete-field/index.js +6 -6
- package/dist/input-autocomplete/component.d.ts +26 -26
- package/dist/input-ghost/component.d.ts +1 -1
- package/dist/link/component.d.ts +2 -2
- package/dist/link/component.js +1 -1
- package/dist/loader/component.js +6 -5
- package/dist/masked-input/component.js +7 -16
- package/dist/menu/component.js +12 -17
- package/dist/menu/components/content-header/index.js +1 -9
- package/dist/menu/components/menu-avatar/index.js +1 -6
- package/dist/menu/components/menu-button/index.js +1 -10
- package/dist/menu/components/menu-buttons-list/index.d.ts +1 -1
- package/dist/menu/components/menu-buttons-list/index.js +1 -7
- package/dist/menu/hooks/use-menu.js +12 -12
- package/dist/message/component.js +33 -14
- package/dist/modal/components/modals/modal.d.ts +1 -2
- package/dist/modal/components/modals/modal.js +30 -33
- package/dist/modal/context.js +12 -9
- package/dist/modal/hooks/use-modal.d.ts +1 -1
- package/dist/mq/component.js +1 -6
- package/dist/notification/component.js +14 -12
- package/dist/page-container/component.js +1 -6
- package/dist/page-loading/component.d.ts +1 -2
- package/dist/page-with-controls/component.js +4 -7
- package/dist/picker-button/common/labeled-button/index.js +18 -12
- package/dist/picker-button/component.js +5 -5
- package/dist/picker-button/field/{Component.d.ts → component.d.ts} +1 -2
- package/dist/picker-button/field/index.d.ts +1 -1
- package/dist/picker-button/field/index.js +1 -1
- package/dist/picker-button/index.d.ts +1 -1
- package/dist/picker-button/index.js +4 -4
- package/dist/popover/component.d.ts +2 -2
- package/dist/popover/component.js +69 -63
- package/dist/radio/component.js +7 -7
- package/dist/radio-groups/component.d.ts +1 -2
- package/dist/radio-groups/component.js +9 -7
- package/dist/select/component.d.ts +8 -9
- package/dist/select/component.js +1 -9
- package/dist/select/components/arrow/component.d.ts +1 -2
- package/dist/select/components/base-select/component.js +97 -90
- package/dist/select/components/checkmark/component.d.ts +1 -2
- package/dist/select/components/field/component.d.ts +1 -2
- package/dist/select/components/field/component.js +8 -5
- package/dist/select/components/native-select/component.js +4 -11
- package/dist/select/components/optgroup/component.d.ts +1 -2
- package/dist/select/components/optgroup/component.js +4 -4
- package/dist/select/components/option/component.js +1 -1
- package/dist/select/components/options-list/component.d.ts +1 -2
- package/dist/select/components/options-list/component.js +25 -23
- package/dist/select/components/select-search/index.d.ts +1 -1
- package/dist/select/components/select-search/index.js +28 -26
- package/dist/select/components/virtual-options-list/component.d.ts +1 -2
- package/dist/select/components/virtual-options-list/component.js +52 -45
- package/dist/select/index.js +4 -4
- package/dist/select/presets/index.d.ts +1 -1
- package/dist/select/presets/index.js +4 -4
- package/dist/select/presets/use-lazy-loading/index.d.ts +3 -4
- package/dist/select/presets/use-lazy-loading/index.js +45 -43
- package/dist/select/presets/use-select-with-loading/hook.d.ts +1 -2
- package/dist/select/presets/use-select-with-loading/hook.js +8 -1
- package/dist/select/utils.js +32 -32
- package/dist/sidepanel/component.js +21 -15
- package/dist/sidepanel-header/component.js +17 -16
- package/dist/skeleton/component.js +4 -4
- package/dist/space/component.d.ts +2 -2
- package/dist/space/component.js +42 -45
- package/dist/space/{Item.d.ts → item.d.ts} +2 -2
- package/dist/spinner/component.js +6 -5
- package/dist/stack/index.d.ts +1 -1
- package/dist/stack/index.js +5 -5
- package/dist/stepped-progress-bar/components/step-bar.js +3 -3
- package/dist/stepped-progress-bar/index.d.ts +2 -2
- package/dist/stepped-progress-bar/index.js +37 -22
- package/dist/sticker/component.js +1 -17
- package/dist/suffix-input/component.js +13 -13
- package/dist/switch/component.js +7 -7
- package/dist/table/components/cells/index.d.ts +1 -2
- package/dist/table/components/empty-list/index.d.ts +1 -2
- package/dist/table/components/error/index.d.ts +2 -3
- package/dist/table/components/error/index.js +1 -1
- package/dist/table/components/loading/index.d.ts +1 -1
- package/dist/table/components/loading/index.js +18 -12
- package/dist/table/components/pagination/index.js +56 -53
- package/dist/table/components/table-header/index.js +59 -56
- package/dist/table/hooks/use-table-data.js +63 -60
- package/dist/table/table.d.ts +1 -1
- package/dist/table/table.js +73 -73
- package/dist/table/types.d.ts +3 -3
- package/dist/table/utils/get-query-from-url.js +1 -8
- package/dist/table/utils/get-tags.d.ts +1 -1
- package/dist/table/utils/get-tags.js +9 -12
- package/dist/table/utils/index.d.ts +1 -1
- package/dist/table/utils/index.js +4 -4
- package/dist/table/utils/parse-query-params.js +5 -1
- package/dist/table/utils/prepare-rows.d.ts +1 -2
- package/dist/table/utils/prepare-rows.js +4 -3
- package/dist/table/utils/query-adapter.d.ts +1 -1
- package/dist/table/utils/query-adapter.js +5 -5
- package/dist/table/utils/remove-query-param.js +3 -1
- package/dist/table/utils/reset-query-param.js +16 -9
- package/dist/table-status/component.js +5 -1
- package/dist/textarea/component.js +36 -28
- package/dist/theme-provider/component.js +33 -29
- package/dist/toast/component.d.ts +7 -8
- package/dist/toast/component.js +65 -63
- package/dist/toast-notifier/component.js +13 -13
- package/dist/toast-notifier/use-timer.d.ts +1 -1
- package/dist/toast-notifier/use-timer.js +5 -5
- package/dist/toast-plate/component.d.ts +3 -3
- package/dist/toast-plate/component.js +7 -7
- package/dist/tooltip/component.js +35 -35
- package/dist/tooltip/node-resolver.js +7 -7
- package/dist/typings/api.d.ts +3 -5
- package/dist/typography/colors.d.ts +1 -1
- package/dist/typography/title/component.d.ts +3 -3
- package/dist/typography/title/index.d.ts +1 -1
- package/dist/typography/title/index.js +3 -3
- package/dist/utils/date/index.js +12 -2
- package/dist/utils/index.d.ts +2 -2
- package/dist/utils/index.js +14 -14
- package/dist/utils/split-amount/util.js +4 -4
- package/dist/with-suffix/component.d.ts +13 -13
- package/dist/with-suffix/component.js +8 -8
- package/package.json +9 -34
- /package/dist/__internal/utils/{getDataTestId.d.ts → get-data-test-id.d.ts} +0 -0
- /package/dist/__internal/utils/{getDataTestId.js → get-data-test-id.js} +0 -0
- /package/dist/calendar/components/header/{/321/201omponent.d.ts" → component.d.ts} +0 -0
- /package/dist/calendar/components/months-table/{/321/201omponent.d.ts" → component.d.ts} +0 -0
- /package/dist/calendar/components/years-table/{/321/201omponent.d.ts" → component.d.ts} +0 -0
- /package/dist/picker-button/field/{Component.js → component.js} +0 -0
- /package/dist/space/{Item.js → item.js} +0 -0
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import { jsxs as k, jsx as s } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
import j from "
|
|
4
|
-
import { useClickOutside as E } from "../../../hooks/useClickOutside/index.js";
|
|
2
|
+
import v from "@alphakits/icons/dist/SearchS";
|
|
3
|
+
import a, { useEffect as P, useState as C, useRef as b, useCallback as p, useMemo as j } from "react";
|
|
5
4
|
import "../../../toast-notifier/component.js";
|
|
5
|
+
import { useClickOutside as E } from "../../../hooks/useClickOutside/index.js";
|
|
6
6
|
import { safeStringify as I } from "../../../utils/safe-stringify.js";
|
|
7
7
|
import { Input as z } from "../../../input/component.js";
|
|
8
8
|
import { BaseSelect as A } from "../base-select/component.js";
|
|
9
9
|
import { OptionsList as B } from "../options-list/component.js";
|
|
10
10
|
import F from "./index.module.css.js";
|
|
11
11
|
const M = a.forwardRef(
|
|
12
|
-
({ inputProps:
|
|
12
|
+
({ inputProps: t, ...o }, n) => {
|
|
13
13
|
const i = a.useRef(null), c = a.useRef(null);
|
|
14
|
-
return
|
|
14
|
+
return P(() => {
|
|
15
15
|
i.current?.focus();
|
|
16
16
|
}, []), /* @__PURE__ */ k("div", { ref: n, children: [
|
|
17
17
|
/* @__PURE__ */ s("div", { style: { padding: "5px 20px" }, children: /* @__PURE__ */ s(
|
|
18
18
|
z,
|
|
19
19
|
{
|
|
20
20
|
size: "s",
|
|
21
|
-
leftAddons: /* @__PURE__ */ s(
|
|
22
|
-
...
|
|
21
|
+
leftAddons: /* @__PURE__ */ s(v, {}),
|
|
22
|
+
...t,
|
|
23
23
|
fieldClassName: F.innerInput,
|
|
24
24
|
block: !0,
|
|
25
25
|
ref: i
|
|
@@ -29,37 +29,39 @@ const M = a.forwardRef(
|
|
|
29
29
|
] });
|
|
30
30
|
}
|
|
31
31
|
), V = ({
|
|
32
|
-
options:
|
|
32
|
+
options: t,
|
|
33
33
|
searchType: o = "text",
|
|
34
34
|
onChange: n,
|
|
35
35
|
selected: i = "",
|
|
36
36
|
...c
|
|
37
37
|
}) => {
|
|
38
|
-
const [
|
|
38
|
+
const [L, f] = C(t), [m, d] = C(""), h = b(null), S = p(
|
|
39
39
|
(x, { value: l }) => {
|
|
40
40
|
d(l);
|
|
41
41
|
try {
|
|
42
|
-
if (!l) return f(
|
|
43
|
-
const
|
|
42
|
+
if (!l) return f(t);
|
|
43
|
+
const y = String(l).toLowerCase(), g = t.reduce(
|
|
44
44
|
(u, r) => u.concat(r.options ? r.options : [r]),
|
|
45
45
|
[]
|
|
46
|
-
).filter(
|
|
46
|
+
).filter(
|
|
47
|
+
({ key: u, value: r, content: w }) => I({ key: u, value: r, content: w }).toLowerCase().includes(y)
|
|
48
|
+
);
|
|
47
49
|
return f(g);
|
|
48
50
|
} catch {
|
|
49
51
|
return [];
|
|
50
52
|
}
|
|
51
53
|
},
|
|
52
|
-
[
|
|
53
|
-
),
|
|
54
|
-
d(""), f(
|
|
55
|
-
}, [
|
|
54
|
+
[t]
|
|
55
|
+
), e = p(() => {
|
|
56
|
+
d(""), f(t);
|
|
57
|
+
}, [t]), O = p(
|
|
56
58
|
(x) => {
|
|
57
|
-
n?.(x),
|
|
59
|
+
n?.(x), e();
|
|
58
60
|
},
|
|
59
|
-
[n,
|
|
61
|
+
[n, e]
|
|
60
62
|
);
|
|
61
|
-
E(h,
|
|
62
|
-
const
|
|
63
|
+
E(h, e);
|
|
64
|
+
const R = j(
|
|
63
65
|
() => ({
|
|
64
66
|
ref: h,
|
|
65
67
|
inputProps: {
|
|
@@ -67,22 +69,22 @@ const M = a.forwardRef(
|
|
|
67
69
|
value: m,
|
|
68
70
|
type: o,
|
|
69
71
|
clear: !0,
|
|
70
|
-
onClear:
|
|
72
|
+
onClear: e
|
|
71
73
|
}
|
|
72
74
|
}),
|
|
73
|
-
[S, m, o,
|
|
75
|
+
[S, m, o, e]
|
|
74
76
|
);
|
|
75
77
|
return /* @__PURE__ */ s(
|
|
76
78
|
A,
|
|
77
79
|
{
|
|
78
80
|
...c,
|
|
79
81
|
selected: i,
|
|
80
|
-
onChange:
|
|
82
|
+
onChange: O,
|
|
81
83
|
showEmptyOptionsList: !0,
|
|
82
84
|
OptionsList: M,
|
|
83
|
-
filteredOptions:
|
|
84
|
-
options:
|
|
85
|
-
optionsListProps:
|
|
85
|
+
filteredOptions: L,
|
|
86
|
+
options: t,
|
|
87
|
+
optionsListProps: R
|
|
86
88
|
}
|
|
87
89
|
);
|
|
88
90
|
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { default as React } from 'react';
|
|
2
1
|
import { OptionsListProps } from '../../typings';
|
|
3
2
|
export type VirtualOptionsList = OptionsListProps & {
|
|
4
3
|
overscan?: number;
|
|
5
4
|
};
|
|
6
|
-
export declare const VirtualOptionsList: ({ size, flatOptions, highlightedIndex, className, Option, open, options, overscan, Optgroup, dataTestId, emptyPlaceholder, visibleOptions, }: VirtualOptionsList) =>
|
|
5
|
+
export declare const VirtualOptionsList: ({ size, flatOptions, highlightedIndex, className, Option, open, options, overscan, Optgroup, dataTestId, emptyPlaceholder, visibleOptions, }: VirtualOptionsList) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,88 +1,95 @@
|
|
|
1
1
|
import { jsxs as v, jsx as f } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import { usePrevious as G } from "../../../hooks/usePrevious/index.js";
|
|
2
|
+
import I from "classnames";
|
|
3
|
+
import { useRef as b, useState as g, useEffect as m, useMemo as E } from "react";
|
|
4
|
+
import { useVirtual as G } from "react-virtual";
|
|
6
5
|
import "../../../toast-notifier/component.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
import { usePrevious as H } from "../../../hooks/usePrevious/index.js";
|
|
7
|
+
import { lastIndexOf as M, useVisibleOptions as P, isGroup as T } from "../../utils.js";
|
|
8
|
+
import { Optgroup as Y } from "../optgroup/component.js";
|
|
9
|
+
import o from "./index.module.css.js";
|
|
10
|
+
const U = ({
|
|
11
|
+
size: y = "s",
|
|
12
|
+
flatOptions: t = [],
|
|
13
13
|
highlightedIndex: s = -1,
|
|
14
|
-
className:
|
|
14
|
+
className: N,
|
|
15
15
|
Option: V,
|
|
16
|
-
open:
|
|
17
|
-
options:
|
|
16
|
+
open: a,
|
|
17
|
+
options: i = [],
|
|
18
18
|
overscan: z = 10,
|
|
19
|
-
Optgroup: D =
|
|
19
|
+
Optgroup: D = Y,
|
|
20
20
|
dataTestId: S,
|
|
21
|
-
emptyPlaceholder:
|
|
22
|
-
visibleOptions:
|
|
21
|
+
emptyPlaceholder: x,
|
|
22
|
+
visibleOptions: j = 5
|
|
23
23
|
}) => {
|
|
24
|
-
const
|
|
25
|
-
size:
|
|
24
|
+
const p = b(null), c = b(null), [K, L] = g(0), u = H(s) || -1, r = G({
|
|
25
|
+
size: t.length,
|
|
26
26
|
parentRef: c,
|
|
27
27
|
overscan: z
|
|
28
28
|
});
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}, [
|
|
29
|
+
m(() => {
|
|
30
|
+
a && r.scrollToIndex(s, { align: "end" });
|
|
31
|
+
}, [a, r.scrollToIndex, s]), m(() => {
|
|
32
32
|
s !== -1 && (r.virtualItems.some((e) => e.index === s) || r.scrollToIndex(s, { align: "end" }));
|
|
33
|
-
}, [s]),
|
|
34
|
-
const e = (d) => !d.disabled,
|
|
35
|
-
u <=
|
|
36
|
-
}, [
|
|
37
|
-
|
|
33
|
+
}, [s, r.scrollToIndex, r.virtualItems.some]), m(() => {
|
|
34
|
+
const e = (d) => !d.disabled, l = t.findIndex(e), n = M(t, e);
|
|
35
|
+
u <= l && s === t.length - 1 && r.scrollToIndex(n), u >= n && s === 0 && r.scrollToIndex(0);
|
|
36
|
+
}, [
|
|
37
|
+
u,
|
|
38
|
+
s,
|
|
39
|
+
r.scrollToIndex,
|
|
40
|
+
t.length,
|
|
41
|
+
t.findIndex,
|
|
42
|
+
t
|
|
43
|
+
]), m(() => {
|
|
44
|
+
L(
|
|
38
45
|
/**
|
|
39
46
|
* react-virtual может несколько раз отрендерить список с одним элементом,
|
|
40
47
|
* поэтому нужно еще раз пересчитать высоту, когда список ВИДИМЫХ пунктов будет отрендерен полностью
|
|
41
48
|
* Также, высоту нужно пересчитывать при изменении ОБЩЕГО кол-ва пунктов меню
|
|
42
49
|
*/
|
|
43
|
-
r.virtualItems.length > 1 ?
|
|
50
|
+
r.virtualItems.length > 1 ? t.length : 1
|
|
44
51
|
);
|
|
45
|
-
}, [r.virtualItems.length,
|
|
46
|
-
visibleOptions:
|
|
47
|
-
invalidate:
|
|
48
|
-
listRef:
|
|
52
|
+
}, [r.virtualItems.length, t.length]), P({
|
|
53
|
+
visibleOptions: j,
|
|
54
|
+
invalidate: K,
|
|
55
|
+
listRef: p,
|
|
49
56
|
styleTargetRef: c,
|
|
50
|
-
open:
|
|
57
|
+
open: a
|
|
51
58
|
});
|
|
52
|
-
const
|
|
59
|
+
const $ = E(() => {
|
|
53
60
|
let e = 0;
|
|
54
|
-
return
|
|
55
|
-
}, [
|
|
61
|
+
return i.reduce((l, n, d) => (T(n) ? (l[e] = d, e += n.options.length) : e += 1, l), {});
|
|
62
|
+
}, [i]);
|
|
56
63
|
return /* @__PURE__ */ v(
|
|
57
64
|
"div",
|
|
58
65
|
{
|
|
59
|
-
className:
|
|
66
|
+
className: I(o.virtualOptionsList, o[y], N),
|
|
60
67
|
ref: c,
|
|
61
68
|
"data-test-id": S,
|
|
62
69
|
children: [
|
|
63
70
|
/* @__PURE__ */ f(
|
|
64
71
|
"div",
|
|
65
72
|
{
|
|
66
|
-
className:
|
|
73
|
+
className: o.inner,
|
|
67
74
|
style: {
|
|
68
75
|
height: `${r.totalSize}px`
|
|
69
76
|
},
|
|
70
|
-
ref:
|
|
77
|
+
ref: p,
|
|
71
78
|
children: r.virtualItems.map((e) => {
|
|
72
|
-
const
|
|
79
|
+
const l = t[e.index], n = i[$[e.index]];
|
|
73
80
|
return /* @__PURE__ */ v(
|
|
74
81
|
"div",
|
|
75
82
|
{
|
|
76
83
|
ref: e.measureRef,
|
|
77
|
-
className:
|
|
78
|
-
[
|
|
84
|
+
className: I(o.virtualRow, {
|
|
85
|
+
[o.highlighted]: s === e.index
|
|
79
86
|
}),
|
|
80
87
|
style: {
|
|
81
88
|
transform: `translateY(${e.start}px)`
|
|
82
89
|
},
|
|
83
90
|
children: [
|
|
84
|
-
|
|
85
|
-
!
|
|
91
|
+
n && /* @__PURE__ */ f(D, { label: n.label }),
|
|
92
|
+
!T(l) && V({ option: l, index: e.index })
|
|
86
93
|
]
|
|
87
94
|
},
|
|
88
95
|
e.index
|
|
@@ -90,11 +97,11 @@ const R = ({
|
|
|
90
97
|
})
|
|
91
98
|
}
|
|
92
99
|
),
|
|
93
|
-
|
|
100
|
+
x && i.length === 0 && /* @__PURE__ */ f("div", { className: o.emptyPlaceholder, children: x })
|
|
94
101
|
]
|
|
95
102
|
}
|
|
96
103
|
);
|
|
97
104
|
};
|
|
98
105
|
export {
|
|
99
|
-
|
|
106
|
+
U as VirtualOptionsList
|
|
100
107
|
};
|
package/dist/select/index.js
CHANGED
|
@@ -6,8 +6,8 @@ import { Optgroup as m } from "./components/optgroup/component.js";
|
|
|
6
6
|
import { Option as l } from "./components/option/component.js";
|
|
7
7
|
import { OptionsList as c } from "./components/options-list/component.js";
|
|
8
8
|
import { VirtualOptionsList as L } from "./components/virtual-options-list/component.js";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
9
|
+
import { useLazyLoading as d } from "./presets/use-lazy-loading/index.js";
|
|
10
|
+
import { useSelectWithLoading as h } from "./presets/use-select-with-loading/hook.js";
|
|
11
11
|
import { convertToOptions as b, isGroup as j, isOptionShape as v, joinOptions as w, lastIndexOf as y, processOptions as z, useVisibleOptions as A } from "./utils.js";
|
|
12
12
|
export {
|
|
13
13
|
p as Arrow,
|
|
@@ -24,7 +24,7 @@ export {
|
|
|
24
24
|
w as joinOptions,
|
|
25
25
|
y as lastIndexOf,
|
|
26
26
|
z as processOptions,
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
d as useLazyLoading,
|
|
28
|
+
h as useSelectWithLoading,
|
|
29
29
|
A as useVisibleOptions
|
|
30
30
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { useLazyLoading as r } from "./use-lazy-loading/index.js";
|
|
2
|
+
import { useSelectWithLoading as a } from "./use-select-with-loading/hook.js";
|
|
3
3
|
export {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
r as useLazyLoading,
|
|
5
|
+
a as useSelectWithLoading
|
|
6
6
|
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { default as React } from 'react';
|
|
2
1
|
import { OptionProps, OptionShape } from '../../typings';
|
|
3
2
|
type OptionsFetcherResponse = {
|
|
4
3
|
items: Array<{
|
|
@@ -24,12 +23,12 @@ type UseLazyLoadingProps = {
|
|
|
24
23
|
};
|
|
25
24
|
export declare function useLazyLoading({ limit, initialPage, optionsFetcher, }: UseLazyLoadingProps): {
|
|
26
25
|
optionsProps: {
|
|
27
|
-
Option: (props: OptionProps) =>
|
|
26
|
+
Option: (props: OptionProps) => import("react/jsx-runtime").JSX.Element;
|
|
28
27
|
options: OptionShape[];
|
|
29
28
|
optionsListProps: {
|
|
30
|
-
ref:
|
|
29
|
+
ref: import('react').RefObject<HTMLDivElement | null>;
|
|
31
30
|
inputProps: {
|
|
32
|
-
onChange: (event:
|
|
31
|
+
onChange: (event: import('react').ChangeEvent<HTMLInputElement, Element>, payload: {
|
|
33
32
|
value: string;
|
|
34
33
|
}) => void;
|
|
35
34
|
value: string;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as x } from "react/jsx-runtime";
|
|
2
|
-
import { useReducer as b, useRef as u, useCallback as p, useEffect as
|
|
2
|
+
import { useReducer as b, useRef as u, useCallback as p, useEffect as I, useMemo as A } from "react";
|
|
3
3
|
import { Option as F } from "../../components/option/component.js";
|
|
4
4
|
import { convertToOptions as H } from "../../utils.js";
|
|
5
5
|
import "intersection-observer";
|
|
6
|
-
const U = 300,
|
|
6
|
+
const U = 300, a = {
|
|
7
7
|
fetchOptionsStart() {
|
|
8
8
|
return { type: "FETCH_OPTIONS_START" };
|
|
9
9
|
},
|
|
@@ -25,12 +25,12 @@ const U = 300, c = {
|
|
|
25
25
|
};
|
|
26
26
|
function G({
|
|
27
27
|
limit: n = 10,
|
|
28
|
-
initialPage:
|
|
29
|
-
optionsFetcher:
|
|
28
|
+
initialPage: m = 0,
|
|
29
|
+
optionsFetcher: S
|
|
30
30
|
}) {
|
|
31
31
|
const d = [], O = {
|
|
32
32
|
opened: !1,
|
|
33
|
-
page:
|
|
33
|
+
page: m,
|
|
34
34
|
options: d,
|
|
35
35
|
loading: !1,
|
|
36
36
|
allOptionsLoaded: !1,
|
|
@@ -75,37 +75,36 @@ function G({
|
|
|
75
75
|
default:
|
|
76
76
|
return e;
|
|
77
77
|
}
|
|
78
|
-
}, [
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
allOptionsLoaded: R,
|
|
85
|
-
searchText: T
|
|
86
|
-
},
|
|
87
|
-
r
|
|
88
|
-
] = b(C, O), a = u(void 0), s = p(() => {
|
|
89
|
-
r(c.fetchOptionsStart()), new Promise((e, t) => {
|
|
90
|
-
a.current?.(), a.current = t, _({ page: f, limit: n, searchText: T }).then((i) => {
|
|
78
|
+
}, [{ opened: E, page: _, options: f, loading: o, allOptionsLoaded: y, searchText: g }, r] = b(
|
|
79
|
+
C,
|
|
80
|
+
O
|
|
81
|
+
), c = u(void 0), s = p(() => {
|
|
82
|
+
r(a.fetchOptionsStart()), new Promise((e, t) => {
|
|
83
|
+
c.current?.(), c.current = t, S({ page: _, limit: n, searchText: g }).then((i) => {
|
|
91
84
|
e(i);
|
|
92
85
|
});
|
|
93
86
|
}).then((e) => {
|
|
94
|
-
const t = H(e.items), {
|
|
95
|
-
|
|
87
|
+
const t = H(e.items), {
|
|
88
|
+
meta: { totalPages: i, currentPage: h }
|
|
89
|
+
} = e;
|
|
90
|
+
r(
|
|
91
|
+
a.fetchOptionsSuccess({
|
|
92
|
+
options: t,
|
|
93
|
+
hasMore: h < i
|
|
94
|
+
})
|
|
95
|
+
), c.current = void 0;
|
|
96
96
|
}).catch(
|
|
97
97
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
98
98
|
(e) => {
|
|
99
|
-
console.log(e);
|
|
100
99
|
}
|
|
101
100
|
);
|
|
102
|
-
}, [
|
|
103
|
-
|
|
101
|
+
}, [_, n, g, S]), l = u(null);
|
|
102
|
+
I(() => {
|
|
104
103
|
let e;
|
|
105
|
-
if (
|
|
104
|
+
if (E && !o && !y) {
|
|
106
105
|
e = new IntersectionObserver(
|
|
107
|
-
([
|
|
108
|
-
|
|
106
|
+
([h]) => {
|
|
107
|
+
h.isIntersecting && (e && e.disconnect(), s());
|
|
109
108
|
},
|
|
110
109
|
{
|
|
111
110
|
root: l.current
|
|
@@ -117,30 +116,33 @@ function G({
|
|
|
117
116
|
return () => {
|
|
118
117
|
e && e.disconnect();
|
|
119
118
|
};
|
|
120
|
-
}, [
|
|
119
|
+
}, [E, y, o, s]);
|
|
121
120
|
const N = p(
|
|
122
121
|
(e) => {
|
|
123
|
-
e.open ?
|
|
122
|
+
e.open ? f.length === d.length && s() : (c.current?.(), r(a.fetchOptionsBreak())), r(a.setIsOpened(e.open ?? !1));
|
|
124
123
|
},
|
|
125
|
-
[d.length,
|
|
126
|
-
),
|
|
127
|
-
|
|
128
|
-
|
|
124
|
+
[d.length, f.length, s]
|
|
125
|
+
), R = u(void 0), T = u(void 0);
|
|
126
|
+
I(() => {
|
|
127
|
+
R.current = s;
|
|
129
128
|
}, [s]);
|
|
130
129
|
const P = p(
|
|
131
130
|
(e, t) => {
|
|
132
|
-
r(
|
|
133
|
-
|
|
131
|
+
r(a.setQueryString(t.value)), c.current?.(), l.current?.scrollTo({ top: 0 }), T.current && clearTimeout(T.current), T.current = setTimeout(() => {
|
|
132
|
+
R.current?.();
|
|
134
133
|
}, U);
|
|
135
134
|
},
|
|
136
135
|
[]
|
|
137
|
-
), v = A(
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
136
|
+
), v = A(
|
|
137
|
+
() => Array(o ? n : 0).fill(0).map((e, t) => ({
|
|
138
|
+
key: t,
|
|
139
|
+
disabled: !0,
|
|
140
|
+
content: "",
|
|
141
|
+
loading: !0
|
|
142
|
+
})),
|
|
143
|
+
[o, n]
|
|
144
|
+
), L = p(() => {
|
|
145
|
+
r(a.reset());
|
|
144
146
|
}, []);
|
|
145
147
|
return {
|
|
146
148
|
optionsProps: {
|
|
@@ -148,12 +150,12 @@ function G({
|
|
|
148
150
|
(e) => /* @__PURE__ */ x(F, { ...e, highlighted: o ? !1 : e.highlighted }),
|
|
149
151
|
[o]
|
|
150
152
|
),
|
|
151
|
-
options: [...
|
|
153
|
+
options: [...f, ...v],
|
|
152
154
|
optionsListProps: {
|
|
153
155
|
ref: l,
|
|
154
156
|
inputProps: {
|
|
155
157
|
onChange: P,
|
|
156
|
-
value:
|
|
158
|
+
value: g
|
|
157
159
|
}
|
|
158
160
|
},
|
|
159
161
|
onOpen: N
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { default as React } from 'react';
|
|
2
1
|
import { BaseSelectProps, OptionProps, OptionShape } from '../../typings';
|
|
3
2
|
type useSelectWithLoadingProps = {
|
|
4
3
|
loading?: boolean;
|
|
5
4
|
visibleOptions?: BaseSelectProps['visibleOptions'];
|
|
6
5
|
};
|
|
7
6
|
export declare function useSelectWithLoading({ loading, visibleOptions, }: useSelectWithLoadingProps): {
|
|
8
|
-
Option: (props: OptionProps) =>
|
|
7
|
+
Option: (props: OptionProps) => import("react/jsx-runtime").JSX.Element;
|
|
9
8
|
options: OptionShape[];
|
|
10
9
|
} | null;
|
|
11
10
|
export {};
|
|
@@ -8,7 +8,14 @@ function k({
|
|
|
8
8
|
visibleOptions: r = 6
|
|
9
9
|
}) {
|
|
10
10
|
const i = s(
|
|
11
|
-
(e) => /* @__PURE__ */ o(
|
|
11
|
+
(e) => /* @__PURE__ */ o(
|
|
12
|
+
f,
|
|
13
|
+
{
|
|
14
|
+
...e,
|
|
15
|
+
Checkmark: void 0,
|
|
16
|
+
highlighted: t ? !1 : e.highlighted
|
|
17
|
+
}
|
|
18
|
+
),
|
|
12
19
|
[t]
|
|
13
20
|
), l = Array(r).fill(0).map((e, n) => ({
|
|
14
21
|
key: n,
|
package/dist/select/utils.js
CHANGED
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
import { useEffect as
|
|
2
|
-
const
|
|
3
|
-
selected:
|
|
1
|
+
import { useEffect as f, isValidElement as p, cloneElement as a } from "react";
|
|
2
|
+
const y = (e) => Object.hasOwn(e, "options"), d = (e) => typeof e == "object" && e !== null && Object.hasOwn(e, "key"), O = ({
|
|
3
|
+
selected: e,
|
|
4
4
|
selectedMultiple: s
|
|
5
5
|
}) => {
|
|
6
|
-
const
|
|
7
|
-
return
|
|
6
|
+
const t = s || (e ? [e] : []);
|
|
7
|
+
return t.length ? t.reduce((r, c, o) => (p(c.content) ? r.push(a(c.content, { key: c.key })) : r.push(c.content), o < t.length - 1 && r.push(", "), r), []) : null;
|
|
8
8
|
};
|
|
9
|
-
function k(
|
|
10
|
-
const
|
|
9
|
+
function k(e, s = []) {
|
|
10
|
+
const t = [], r = Array.isArray(s) ? s : [s], c = r.filter(d), o = new Set(
|
|
11
11
|
r.filter(
|
|
12
12
|
(n) => typeof n == "string" || typeof n == "number"
|
|
13
13
|
)
|
|
14
|
-
), h = (n) =>
|
|
15
|
-
|
|
14
|
+
), h = (n) => o.has(n.key), l = (n) => {
|
|
15
|
+
t.push(n), h(n) && c.push(n);
|
|
16
16
|
};
|
|
17
|
-
return
|
|
18
|
-
|
|
19
|
-
}), { flatOptions:
|
|
17
|
+
return e.forEach((n) => {
|
|
18
|
+
y(n) ? n.options.forEach(l) : l(n);
|
|
19
|
+
}), { flatOptions: t, selectedOptions: c };
|
|
20
20
|
}
|
|
21
21
|
function E({
|
|
22
|
-
visibleOptions:
|
|
22
|
+
visibleOptions: e,
|
|
23
23
|
listRef: s,
|
|
24
|
-
styleTargetRef:
|
|
24
|
+
styleTargetRef: t = s,
|
|
25
25
|
open: r,
|
|
26
|
-
invalidate:
|
|
26
|
+
invalidate: c
|
|
27
27
|
}) {
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
if (r &&
|
|
28
|
+
f(() => {
|
|
29
|
+
const o = s.current, h = t.current;
|
|
30
|
+
if (r && o && h) {
|
|
31
31
|
const l = [].slice.call(
|
|
32
|
-
|
|
32
|
+
o.children,
|
|
33
33
|
0,
|
|
34
|
-
|
|
34
|
+
e + 1
|
|
35
35
|
);
|
|
36
|
-
let n = l.slice(0,
|
|
37
|
-
|
|
36
|
+
let n = l.slice(0, e).reduce((i, u) => i + u.clientHeight, 0);
|
|
37
|
+
e < o.children.length && (n += Math.round(l[l.length - 1].clientHeight / 2)), h.style.height = `${n}px`;
|
|
38
38
|
}
|
|
39
|
-
}, [s, r,
|
|
39
|
+
}, [s, r, t, e]);
|
|
40
40
|
}
|
|
41
|
-
const j = (
|
|
42
|
-
for (let
|
|
43
|
-
if (s(t
|
|
41
|
+
const j = (e, s) => {
|
|
42
|
+
for (let t = e.length - 1; t >= 0; t--)
|
|
43
|
+
if (s(e[t])) return t;
|
|
44
44
|
return -1;
|
|
45
|
-
},
|
|
46
|
-
key:
|
|
47
|
-
content: s &&
|
|
45
|
+
}, w = (e, s) => e.map((t) => ({
|
|
46
|
+
key: t.id,
|
|
47
|
+
content: s && t[s] || t.title || t.name
|
|
48
48
|
}));
|
|
49
49
|
export {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
w as convertToOptions,
|
|
51
|
+
y as isGroup,
|
|
52
|
+
d as isOptionShape,
|
|
53
53
|
O as joinOptions,
|
|
54
54
|
j as lastIndexOf,
|
|
55
55
|
k as processOptions,
|