@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,89 +1,92 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as r, jsx as s } from "react/jsx-runtime";
|
|
2
2
|
import f from "@alphakits/icons/dist/ChevronForwardS";
|
|
3
|
-
import
|
|
3
|
+
import d from "classnames";
|
|
4
4
|
import { Button as h } from "../../../button/component.js";
|
|
5
|
-
import { Typography as
|
|
6
|
-
import { translate as
|
|
5
|
+
import { Typography as m } from "../../../typography/component.js";
|
|
6
|
+
import { translate as y } from "../../languages/index.js";
|
|
7
7
|
import i from "./index.module.css.js";
|
|
8
|
-
function
|
|
9
|
-
const
|
|
10
|
-
let
|
|
8
|
+
function b(p, o) {
|
|
9
|
+
const g = p - 2, c = p + 2 + 1, a = [], n = [];
|
|
10
|
+
let l = 0;
|
|
11
11
|
for (let e = 1; e <= o; e++)
|
|
12
|
-
(e === 1 || e === o || e >=
|
|
13
|
-
return
|
|
14
|
-
|
|
15
|
-
}),
|
|
12
|
+
(e === 1 || e === o || e >= g && e < c) && a.push(e);
|
|
13
|
+
return a.forEach((e) => {
|
|
14
|
+
l && (e - l === 2 ? n.push({ key: `page-${l + 1}`, type: "page", page: l + 1 }) : e - l !== 1 && n.push({ key: `ellipsis-${l}-${e}`, type: "ellipsis" })), n.push({ key: `page-${e}`, type: "page", page: e }), l = e;
|
|
15
|
+
}), n;
|
|
16
16
|
}
|
|
17
|
-
const
|
|
18
|
-
pagesCount:
|
|
17
|
+
const T = ({
|
|
18
|
+
pagesCount: p,
|
|
19
19
|
currentPage: o,
|
|
20
20
|
recordsPerPage: v = 30,
|
|
21
|
-
total:
|
|
21
|
+
total: g,
|
|
22
22
|
language: c,
|
|
23
|
-
addParam:
|
|
23
|
+
addParam: a
|
|
24
24
|
}) => {
|
|
25
|
-
const
|
|
26
|
-
return /* @__PURE__ */
|
|
27
|
-
/* @__PURE__ */
|
|
28
|
-
/* @__PURE__ */ s(
|
|
29
|
-
/* @__PURE__ */ s(
|
|
25
|
+
const n = b(o, p), l = o === 1, e = o === p;
|
|
26
|
+
return /* @__PURE__ */ r("div", { className: i.pagination_wrap, children: [
|
|
27
|
+
/* @__PURE__ */ r("div", { className: i.pages_info, children: [
|
|
28
|
+
/* @__PURE__ */ s(m.Text, { view: "title", weight: "medium", color: "secondary", children: y(c)("totalCount") }),
|
|
29
|
+
/* @__PURE__ */ s(m.Text, { view: "title", weight: "medium", color: "primary", children: g })
|
|
30
30
|
] }),
|
|
31
|
-
/* @__PURE__ */ s("div", { className: i.pagination_center, children:
|
|
31
|
+
/* @__PURE__ */ s("div", { className: i.pagination_center, children: n.length > 1 && /* @__PURE__ */ r("div", { className: i.pagination, children: [
|
|
32
32
|
/* @__PURE__ */ s(
|
|
33
33
|
h,
|
|
34
34
|
{
|
|
35
|
-
className:
|
|
35
|
+
className: d(i.prev_btn, i.btn, {
|
|
36
|
+
[i.disabled_btn]: l
|
|
37
|
+
}),
|
|
36
38
|
leftAddons: /* @__PURE__ */ s(f, {}),
|
|
37
39
|
view: "ghost",
|
|
38
|
-
onClick: () =>
|
|
39
|
-
disabled:
|
|
40
|
+
onClick: () => a({ page: o - 1 }),
|
|
41
|
+
disabled: l
|
|
40
42
|
}
|
|
41
43
|
),
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
i.pagination_btn,
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
44
|
+
n.map(
|
|
45
|
+
(t) => t.type === "page" ? /* @__PURE__ */ s(
|
|
46
|
+
h,
|
|
47
|
+
{
|
|
48
|
+
className: d(i.pagination_btn, {
|
|
49
|
+
[i.active]: t.page === o
|
|
50
|
+
}),
|
|
51
|
+
size: "xs",
|
|
52
|
+
view: "ghost",
|
|
53
|
+
onClick: () => a({ page: t.page }),
|
|
54
|
+
children: t.page
|
|
55
|
+
},
|
|
56
|
+
t.key
|
|
57
|
+
) : /* @__PURE__ */ s(
|
|
58
|
+
h,
|
|
59
|
+
{
|
|
60
|
+
className: d(i.pagination_btn),
|
|
61
|
+
view: "ghost",
|
|
62
|
+
disabled: !0,
|
|
63
|
+
children: "..."
|
|
64
|
+
},
|
|
65
|
+
t.key
|
|
66
|
+
)
|
|
67
|
+
),
|
|
65
68
|
/* @__PURE__ */ s(
|
|
66
69
|
h,
|
|
67
70
|
{
|
|
68
|
-
className:
|
|
71
|
+
className: d(i.btn, { [i.disabled_btn]: e }),
|
|
69
72
|
leftAddons: /* @__PURE__ */ s(f, {}),
|
|
70
73
|
view: "ghost",
|
|
71
74
|
onClick: () => {
|
|
72
|
-
|
|
75
|
+
a({ page: o + 1 });
|
|
73
76
|
},
|
|
74
77
|
disabled: e
|
|
75
78
|
}
|
|
76
79
|
)
|
|
77
80
|
] }) }),
|
|
78
|
-
/* @__PURE__ */
|
|
79
|
-
/* @__PURE__ */ s(
|
|
81
|
+
/* @__PURE__ */ r("div", { className: i.select_wrap, children: [
|
|
82
|
+
/* @__PURE__ */ s(m.Text, { view: "title", weight: "medium", color: "secondary", children: y(c)("resultsOnPage") }),
|
|
80
83
|
/* @__PURE__ */ s(
|
|
81
84
|
"select",
|
|
82
85
|
{
|
|
83
86
|
value: v,
|
|
84
87
|
className: i.select,
|
|
85
88
|
onChange: (t) => {
|
|
86
|
-
|
|
89
|
+
a({ page: 1, limit: t.target.value });
|
|
87
90
|
},
|
|
88
91
|
children: [5, 10, 20, 30, 40, 50].map((t) => /* @__PURE__ */ s("option", { value: t, children: t }, t))
|
|
89
92
|
}
|
|
@@ -92,5 +95,5 @@ const j = ({
|
|
|
92
95
|
] });
|
|
93
96
|
};
|
|
94
97
|
export {
|
|
95
|
-
|
|
98
|
+
T as Pagination
|
|
96
99
|
};
|
|
@@ -1,87 +1,90 @@
|
|
|
1
|
-
import { jsxs as n, jsx as t
|
|
2
|
-
import
|
|
3
|
-
import $ from "@alphakits/icons/dist/
|
|
4
|
-
import A from "
|
|
5
|
-
import {
|
|
6
|
-
import E from "
|
|
7
|
-
import { Button as
|
|
8
|
-
import { Flex as
|
|
9
|
-
import { HeaderSearch as
|
|
10
|
-
import { translate as
|
|
1
|
+
import { jsxs as n, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import R from "@alphakits/icons/dist/ControllerS";
|
|
3
|
+
import $ from "@alphakits/icons/dist/PlusS";
|
|
4
|
+
import A from "classnames";
|
|
5
|
+
import { useState as h, useEffect as b, useRef as B, useCallback as v } from "react";
|
|
6
|
+
import { useDebounce as E } from "rooks";
|
|
7
|
+
import { Button as g } from "../../../button/component.js";
|
|
8
|
+
import { Flex as F } from "../../../flex/component.js";
|
|
9
|
+
import { HeaderSearch as H } from "../../../header-search/component.js";
|
|
10
|
+
import { translate as I } from "../../languages/index.js";
|
|
11
11
|
import r from "./index.module.css.js";
|
|
12
|
-
const
|
|
13
|
-
tags:
|
|
14
|
-
searchPlaceholder:
|
|
12
|
+
const U = ({
|
|
13
|
+
tags: a,
|
|
14
|
+
searchPlaceholder: C = "Type something..",
|
|
15
15
|
searchText: o,
|
|
16
|
-
hideSearch:
|
|
17
|
-
compact:
|
|
18
|
-
rightHeaderAddons:
|
|
16
|
+
hideSearch: x,
|
|
17
|
+
compact: S = !1,
|
|
18
|
+
rightHeaderAddons: V,
|
|
19
19
|
leftHeaderAddons: c,
|
|
20
|
-
addParam:
|
|
21
|
-
onCreateClick:
|
|
22
|
-
onFiltersClick:
|
|
23
|
-
createButtonLabel:
|
|
24
|
-
showFiltersButton:
|
|
25
|
-
filtersButtonLabel:
|
|
26
|
-
language:
|
|
20
|
+
addParam: i,
|
|
21
|
+
onCreateClick: m,
|
|
22
|
+
onFiltersClick: y,
|
|
23
|
+
createButtonLabel: N,
|
|
24
|
+
showFiltersButton: j,
|
|
25
|
+
filtersButtonLabel: D,
|
|
26
|
+
language: k
|
|
27
27
|
}) => {
|
|
28
|
-
const [
|
|
29
|
-
|
|
28
|
+
const [w, u] = h(o ?? ""), [d, f] = h(o ?? "");
|
|
29
|
+
b(() => {
|
|
30
30
|
const e = `${o ?? ""}`;
|
|
31
|
-
s.current = e.trim(),
|
|
31
|
+
s.current = e.trim(), u(e), f(e);
|
|
32
32
|
}, [o]);
|
|
33
|
-
const
|
|
34
|
-
|
|
33
|
+
const p = E((e) => f(e), 500), s = B("");
|
|
34
|
+
b(() => {
|
|
35
35
|
const e = `${d || ""}`.trim();
|
|
36
|
-
s.current !== e && (
|
|
37
|
-
}, [d]);
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
36
|
+
s.current !== e && (i({ searchText: e, page: 1 }), s.current = e);
|
|
37
|
+
}, [d, i]);
|
|
38
|
+
const l = v(
|
|
39
|
+
(e) => {
|
|
40
|
+
u(e), p(e);
|
|
41
|
+
},
|
|
42
|
+
[p]
|
|
43
|
+
), z = v(() => {
|
|
44
|
+
l("");
|
|
45
|
+
}, [l]);
|
|
46
|
+
return /* @__PURE__ */ n("div", { className: A(r.table_header, { [r.compact]: S }), children: [
|
|
44
47
|
/* @__PURE__ */ n("div", { className: r.actions, children: [
|
|
45
|
-
/* @__PURE__ */ n(
|
|
46
|
-
!
|
|
47
|
-
|
|
48
|
+
/* @__PURE__ */ n(F, { justify: "start", gap: "md", children: [
|
|
49
|
+
!x && /* @__PURE__ */ t(
|
|
50
|
+
H,
|
|
48
51
|
{
|
|
49
|
-
value:
|
|
50
|
-
onChange:
|
|
52
|
+
value: w,
|
|
53
|
+
onChange: l,
|
|
51
54
|
onClear: z,
|
|
52
|
-
placeholder:
|
|
55
|
+
placeholder: C
|
|
53
56
|
}
|
|
54
57
|
),
|
|
55
|
-
c &&
|
|
58
|
+
c && c
|
|
56
59
|
] }),
|
|
57
60
|
/* @__PURE__ */ n("div", { className: r.buttons, children: [
|
|
58
|
-
|
|
59
|
-
!!
|
|
60
|
-
|
|
61
|
+
V,
|
|
62
|
+
!!m && /* @__PURE__ */ t(
|
|
63
|
+
g,
|
|
61
64
|
{
|
|
62
65
|
dataTestId: "createbtn",
|
|
63
|
-
onClick:
|
|
66
|
+
onClick: m,
|
|
64
67
|
view: "primary",
|
|
65
|
-
leftAddons: /* @__PURE__ */ t(
|
|
68
|
+
leftAddons: /* @__PURE__ */ t($, {}),
|
|
66
69
|
size: "xs",
|
|
67
|
-
children:
|
|
70
|
+
children: N || I(k)("create")
|
|
68
71
|
}
|
|
69
72
|
),
|
|
70
|
-
|
|
71
|
-
|
|
73
|
+
j && /* @__PURE__ */ t(
|
|
74
|
+
g,
|
|
72
75
|
{
|
|
73
|
-
leftAddons: /* @__PURE__ */ t(
|
|
74
|
-
onClick:
|
|
76
|
+
leftAddons: /* @__PURE__ */ t(R, {}),
|
|
77
|
+
onClick: y,
|
|
75
78
|
view: "outlined",
|
|
76
79
|
size: "xs",
|
|
77
|
-
children:
|
|
80
|
+
children: D
|
|
78
81
|
}
|
|
79
82
|
)
|
|
80
83
|
] })
|
|
81
84
|
] }),
|
|
82
|
-
!!
|
|
85
|
+
!!a.length && /* @__PURE__ */ t("div", { className: r.tags, children: a })
|
|
83
86
|
] });
|
|
84
87
|
};
|
|
85
88
|
export {
|
|
86
|
-
|
|
89
|
+
U as TableHeader
|
|
87
90
|
};
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import { useState as u, useCallback as
|
|
1
|
+
import { useState as u, useCallback as c, useEffect as D } from "react";
|
|
2
2
|
import { addQueryParam as z } from "../utils/add-query-param.js";
|
|
3
3
|
import { getQueryFromUrl as I } from "../utils/get-query-from-url.js";
|
|
4
4
|
import "query-string";
|
|
5
5
|
import { removeQueryParam as R } from "../utils/remove-query-param.js";
|
|
6
6
|
import { resetQueryParam as V } from "../utils/reset-query-param.js";
|
|
7
|
-
import { serializeData as
|
|
8
|
-
const
|
|
7
|
+
import { serializeData as b } from "../utils/serialize-data.js";
|
|
8
|
+
const A = {
|
|
9
9
|
page: 1,
|
|
10
10
|
limit: 10,
|
|
11
11
|
where: {}
|
|
12
12
|
// остальное добавится по мере нужды (searchText, sort, order и т.д.)
|
|
13
13
|
};
|
|
14
|
-
function
|
|
15
|
-
const
|
|
16
|
-
...
|
|
14
|
+
function v(f, s) {
|
|
15
|
+
const n = f ?? A, a = {
|
|
16
|
+
...n,
|
|
17
17
|
...s,
|
|
18
18
|
where: {
|
|
19
|
-
...
|
|
19
|
+
...n.where ?? {},
|
|
20
20
|
...s.where ?? {}
|
|
21
21
|
}
|
|
22
22
|
};
|
|
23
23
|
return a.page && (a.page = +a.page), a.limit && (a.limit = +a.limit), a;
|
|
24
24
|
}
|
|
25
|
-
function K({ promise:
|
|
26
|
-
const [a,
|
|
27
|
-
(t) =>
|
|
28
|
-
[
|
|
29
|
-
),
|
|
25
|
+
function K({ promise: f, records: s, fromPath: n = !0 }) {
|
|
26
|
+
const [a, Q] = u([]), [E, g] = u(!0), [C, d] = u(!1), [L, P] = u(0), [S, T] = u(1), [o, m] = u(void 0), w = c(
|
|
27
|
+
(t) => n ? I() : t ?? o ?? A,
|
|
28
|
+
[n, o]
|
|
29
|
+
), r = c(
|
|
30
30
|
async (t) => {
|
|
31
|
-
const e =
|
|
32
|
-
if (Array.isArray(s) && (g(!1),
|
|
31
|
+
const e = w(t);
|
|
32
|
+
if (Array.isArray(s) && (g(!1), Q(b(s, e))), m(e), f) {
|
|
33
33
|
d(!1), g(!0);
|
|
34
34
|
try {
|
|
35
35
|
const {
|
|
36
|
-
data: { items:
|
|
37
|
-
} = await
|
|
38
|
-
|
|
36
|
+
data: { items: i, meta: y }
|
|
37
|
+
} = await f(e);
|
|
38
|
+
P(y.totalItems), T(y.totalPages), Q(i || []);
|
|
39
39
|
} catch {
|
|
40
40
|
d(!0);
|
|
41
41
|
} finally {
|
|
@@ -43,66 +43,69 @@ function K({ promise: c, records: s, fromPath: r = !0 }) {
|
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
|
-
[
|
|
47
|
-
),
|
|
46
|
+
[w, s, f]
|
|
47
|
+
), U = c(
|
|
48
48
|
(t) => {
|
|
49
|
-
if (
|
|
50
|
-
z(t),
|
|
49
|
+
if (n) {
|
|
50
|
+
z(t), r();
|
|
51
51
|
return;
|
|
52
52
|
}
|
|
53
|
-
const e =
|
|
54
|
-
|
|
53
|
+
const e = v(o, t);
|
|
54
|
+
m(e), r(e);
|
|
55
55
|
},
|
|
56
|
-
[
|
|
57
|
-
),
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
56
|
+
[n, o, r]
|
|
57
|
+
), p = c(
|
|
58
|
+
(t, e, i) => {
|
|
59
|
+
const y = t ?? A, l = {
|
|
60
|
+
...y,
|
|
61
|
+
where: { ...y.where ?? {} }
|
|
62
|
+
}, x = l.where?.[e];
|
|
63
|
+
if (Array.isArray(x) && i != null) {
|
|
64
|
+
const h = x.filter((k) => String(k) !== String(i));
|
|
65
|
+
h.length ? l.where[e] = h : delete l.where[e];
|
|
66
|
+
} else
|
|
67
|
+
l.where && e in l.where && delete l.where[e];
|
|
68
|
+
return l;
|
|
69
|
+
},
|
|
70
|
+
[]
|
|
71
|
+
), q = c(
|
|
69
72
|
(t, e) => {
|
|
70
|
-
if (
|
|
71
|
-
R(t, e),
|
|
73
|
+
if (n) {
|
|
74
|
+
R(t, e), r();
|
|
72
75
|
return;
|
|
73
76
|
}
|
|
74
|
-
const
|
|
75
|
-
|
|
77
|
+
const i = p(o, t, e);
|
|
78
|
+
m(i), r(i);
|
|
76
79
|
},
|
|
77
|
-
[
|
|
78
|
-
), F =
|
|
80
|
+
[n, o, r, p]
|
|
81
|
+
), F = c(
|
|
79
82
|
(t) => {
|
|
80
|
-
if (
|
|
81
|
-
V(t),
|
|
83
|
+
if (n) {
|
|
84
|
+
V(t), r();
|
|
82
85
|
return;
|
|
83
86
|
}
|
|
84
|
-
const e =
|
|
85
|
-
|
|
87
|
+
const e = v(A, t);
|
|
88
|
+
m(e), r(e);
|
|
86
89
|
},
|
|
87
|
-
[
|
|
90
|
+
[n, r]
|
|
88
91
|
);
|
|
89
|
-
return
|
|
90
|
-
|
|
91
|
-
}, []),
|
|
92
|
+
return D(() => {
|
|
93
|
+
r();
|
|
94
|
+
}, [r]), D(() => {
|
|
92
95
|
if (Array.isArray(s)) {
|
|
93
|
-
const t =
|
|
94
|
-
|
|
96
|
+
const t = w();
|
|
97
|
+
m(t), g(!1), Q(b(s, t));
|
|
95
98
|
}
|
|
96
|
-
}, [s]), {
|
|
97
|
-
loading:
|
|
98
|
-
error:
|
|
99
|
+
}, [s, w]), {
|
|
100
|
+
loading: E,
|
|
101
|
+
error: C,
|
|
99
102
|
data: a,
|
|
100
|
-
total:
|
|
101
|
-
params:
|
|
102
|
-
pagesCount:
|
|
103
|
-
updateData:
|
|
103
|
+
total: L,
|
|
104
|
+
params: o,
|
|
105
|
+
pagesCount: S,
|
|
106
|
+
updateData: r,
|
|
104
107
|
// НОВОЕ: наружу отдаём универсальные методы для управления параметрами
|
|
105
|
-
addParam:
|
|
108
|
+
addParam: U,
|
|
106
109
|
removeParam: q,
|
|
107
110
|
resetParams: F
|
|
108
111
|
};
|
package/dist/table/table.d.ts
CHANGED
|
@@ -35,5 +35,5 @@ export type TableProps<T extends object> = Records<T> & {
|
|
|
35
35
|
language: 'de' | 'ru' | 'en';
|
|
36
36
|
fromPath?: boolean;
|
|
37
37
|
} & FiltersButton;
|
|
38
|
-
export declare function Table<T extends object>({ columns, searchPlaceholder, records, hideSearch, rightHeaderAddons, leftHeaderAddons, filtersButtonLabel, createButtonLabel, loading, height, view, tagsBuilder, promise, onRowClick, onCreateClick, onFiltersClick, refetch, language, fromPath, }: TableProps<T>):
|
|
38
|
+
export declare function Table<T extends object>({ columns, searchPlaceholder, records, hideSearch, rightHeaderAddons, leftHeaderAddons, filtersButtonLabel, createButtonLabel, loading, height, view, tagsBuilder, promise, onRowClick, onCreateClick, onFiltersClick, refetch, language, fromPath, }: TableProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
39
39
|
export {};
|