@g4rcez/components 2.0.31 → 2.0.33
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/components/core/{button.js → button.jsx} +5 -3
- package/dist/components/core/heading.d.ts +1 -1
- package/dist/components/core/heading.d.ts.map +1 -1
- package/dist/components/core/heading.jsx +4 -0
- package/dist/components/core/{polymorph.js → polymorph.jsx} +1 -2
- package/dist/components/core/render-on-view.d.ts +1 -1
- package/dist/components/core/render-on-view.d.ts.map +1 -1
- package/dist/components/core/{render-on-view.js → render-on-view.jsx} +4 -3
- package/dist/components/core/resizable.d.ts +1 -1
- package/dist/components/core/resizable.d.ts.map +1 -1
- package/dist/components/core/{resizable.js → resizable.jsx} +4 -3
- package/dist/components/core/{slot.js → slot.jsx} +8 -5
- package/dist/components/core/{tag.js → tag.jsx} +6 -3
- package/dist/components/core/typography.d.ts +5 -5
- package/dist/components/core/typography.d.ts.map +1 -1
- package/dist/components/core/typography.jsx +26 -0
- package/dist/components/display/alert.d.ts +1 -1
- package/dist/components/display/alert.d.ts.map +1 -1
- package/dist/components/display/alert.jsx +56 -0
- package/dist/components/display/calendar.d.ts +1 -1
- package/dist/components/display/calendar.d.ts.map +1 -1
- package/dist/components/display/{calendar.js → calendar.jsx} +83 -21
- package/dist/components/display/card.d.ts +3 -3
- package/dist/components/display/card.d.ts.map +1 -1
- package/dist/components/display/card.jsx +43 -0
- package/dist/components/display/empty.d.ts +1 -1
- package/dist/components/display/empty.d.ts.map +1 -1
- package/dist/components/display/empty.jsx +11 -0
- package/dist/components/display/list.d.ts +2 -2
- package/dist/components/display/list.d.ts.map +1 -1
- package/dist/components/display/list.jsx +81 -0
- package/dist/components/display/notifications.d.ts +1 -1
- package/dist/components/display/notifications.d.ts.map +1 -1
- package/dist/components/display/{notifications.js → notifications.jsx} +34 -10
- package/dist/components/display/progress.d.ts +1 -1
- package/dist/components/display/progress.d.ts.map +1 -1
- package/dist/components/display/progress.jsx +13 -0
- package/dist/components/display/shortcut.d.ts +1 -1
- package/dist/components/display/shortcut.d.ts.map +1 -1
- package/dist/components/display/shortcut.jsx +23 -0
- package/dist/components/display/skeleton.d.ts +4 -4
- package/dist/components/display/skeleton.d.ts.map +1 -1
- package/dist/components/display/skeleton.jsx +14 -0
- package/dist/components/display/spinner.d.ts +2 -2
- package/dist/components/display/spinner.d.ts.map +1 -1
- package/dist/components/display/spinner.jsx +7 -0
- package/dist/components/display/stats.d.ts +1 -1
- package/dist/components/display/stats.d.ts.map +1 -1
- package/dist/components/display/stats.jsx +20 -0
- package/dist/components/display/step.d.ts +2 -2
- package/dist/components/display/step.d.ts.map +1 -1
- package/dist/components/display/step.jsx +133 -0
- package/dist/components/display/tabs.d.ts +3 -3
- package/dist/components/display/tabs.d.ts.map +1 -1
- package/dist/components/display/{tabs.js → tabs.jsx} +21 -7
- package/dist/components/display/timeline.d.ts +6 -6
- package/dist/components/display/timeline.d.ts.map +1 -1
- package/dist/components/display/timeline.jsx +25 -0
- package/dist/components/floating/command-palette.d.ts +1 -1
- package/dist/components/floating/command-palette.d.ts.map +1 -1
- package/dist/components/floating/command-palette.jsx +187 -0
- package/dist/components/floating/dropdown.d.ts +1 -1
- package/dist/components/floating/dropdown.d.ts.map +1 -1
- package/dist/components/floating/{dropdown.js → dropdown.jsx} +17 -3
- package/dist/components/floating/expand.d.ts +1 -1
- package/dist/components/floating/expand.d.ts.map +1 -1
- package/dist/components/floating/{expand.js → expand.jsx} +14 -2
- package/dist/components/floating/{menu.js → menu.jsx} +52 -27
- package/dist/components/floating/modal.d.ts +10 -2
- package/dist/components/floating/modal.d.ts.map +1 -1
- package/dist/components/floating/modal.jsx +240 -0
- package/dist/components/floating/toolbar.d.ts +1 -1
- package/dist/components/floating/toolbar.d.ts.map +1 -1
- package/dist/components/floating/toolbar.jsx +5 -0
- package/dist/components/floating/{tooltip.js → tooltip.jsx} +12 -3
- package/dist/components/floating/wizard.d.ts +26 -0
- package/dist/components/floating/wizard.d.ts.map +1 -0
- package/dist/components/floating/wizard.jsx +164 -0
- package/dist/components/form/autocomplete.jsx +276 -0
- package/dist/components/form/checkbox.jsx +12 -0
- package/dist/components/form/{date-picker.js → date-picker.jsx} +15 -4
- package/dist/components/form/file-upload.d.ts +1 -1
- package/dist/components/form/file-upload.d.ts.map +1 -1
- package/dist/components/form/file-upload.jsx +133 -0
- package/dist/components/form/form.d.ts +1 -1
- package/dist/components/form/form.d.ts.map +1 -1
- package/dist/components/form/{form.js → form.jsx} +2 -2
- package/dist/components/form/{free-text.js → free-text.jsx} +4 -3
- package/dist/components/form/input-field.d.ts +1 -1
- package/dist/components/form/input-field.d.ts.map +1 -1
- package/dist/components/form/input-field.jsx +54 -0
- package/dist/components/form/multi-select.jsx +328 -0
- package/dist/components/form/radiobox.d.ts +1 -1
- package/dist/components/form/radiobox.d.ts.map +1 -1
- package/dist/components/form/radiobox.jsx +6 -0
- package/dist/components/form/select.jsx +42 -0
- package/dist/components/form/slider.d.ts +1 -1
- package/dist/components/form/slider.d.ts.map +1 -1
- package/dist/components/form/{slider.js → slider.jsx} +11 -3
- package/dist/components/form/switch.jsx +46 -0
- package/dist/components/form/task-list.d.ts +1 -1
- package/dist/components/form/task-list.d.ts.map +1 -1
- package/dist/components/form/{task-list.js → task-list.jsx} +1 -2
- package/dist/components/form/transfer-list.d.ts +1 -1
- package/dist/components/form/transfer-list.d.ts.map +1 -1
- package/dist/components/form/transfer-list.jsx +39 -0
- package/dist/components/index.d.ts +2 -1
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +2 -1
- package/dist/components/table/filter.d.ts +2 -2
- package/dist/components/table/filter.d.ts.map +1 -1
- package/dist/components/table/{filter.js → filter.jsx} +35 -7
- package/dist/components/table/group.d.ts +1 -1
- package/dist/components/table/group.d.ts.map +1 -1
- package/dist/components/table/group.jsx +68 -0
- package/dist/components/table/index.d.ts +1 -1
- package/dist/components/table/index.d.ts.map +1 -1
- package/dist/components/table/{index.js → index.jsx} +14 -3
- package/dist/components/table/inner-table.d.ts +1 -1
- package/dist/components/table/inner-table.d.ts.map +1 -1
- package/dist/components/table/{inner-table.js → inner-table.jsx} +23 -11
- package/dist/components/table/metadata.d.ts +1 -1
- package/dist/components/table/metadata.d.ts.map +1 -1
- package/dist/components/table/metadata.jsx +37 -0
- package/dist/components/table/pagination.d.ts +1 -1
- package/dist/components/table/pagination.d.ts.map +1 -1
- package/dist/components/table/pagination.jsx +73 -0
- package/dist/components/table/row.d.ts +1 -1
- package/dist/components/table/row.d.ts.map +1 -1
- package/dist/components/table/row.jsx +58 -0
- package/dist/components/table/sort.d.ts +2 -2
- package/dist/components/table/sort.d.ts.map +1 -1
- package/dist/components/table/{sort.js → sort.jsx} +32 -6
- package/dist/components/table/thead.d.ts +2 -1
- package/dist/components/table/thead.d.ts.map +1 -1
- package/dist/components/table/thead.jsx +103 -0
- package/dist/config/default-translations.d.ts +5 -1
- package/dist/config/default-translations.d.ts.map +1 -1
- package/dist/config/{default-translations.js → default-translations.jsx} +9 -3
- package/dist/flow/flow.d.ts +1 -1
- package/dist/flow/flow.d.ts.map +1 -1
- package/dist/flow/flow.jsx +111 -0
- package/dist/hooks/use-components-provider.d.ts +2 -2
- package/dist/hooks/use-components-provider.d.ts.map +1 -1
- package/dist/hooks/{use-components-provider.js → use-components-provider.jsx} +2 -3
- package/dist/hooks/use-resize-observer.d.ts +2 -0
- package/dist/hooks/use-resize-observer.d.ts.map +1 -0
- package/dist/hooks/use-resize-observer.js +17 -0
- package/dist/hooks/use-translations.d.ts +5 -1
- package/dist/hooks/use-translations.d.ts.map +1 -1
- package/dist/hooks/use-window-size.d.ts +5 -0
- package/dist/hooks/use-window-size.d.ts.map +1 -0
- package/dist/hooks/use-window-size.js +14 -0
- package/dist/index.css +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +12326 -14780
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +14 -31
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/dist/components/core/heading.js +0 -5
- package/dist/components/core/typography.js +0 -10
- package/dist/components/display/alert.js +0 -37
- package/dist/components/display/card.js +0 -18
- package/dist/components/display/empty.js +0 -8
- package/dist/components/display/list.js +0 -32
- package/dist/components/display/progress.js +0 -9
- package/dist/components/display/shortcut.js +0 -19
- package/dist/components/display/skeleton.js +0 -13
- package/dist/components/display/spinner.js +0 -6
- package/dist/components/display/stats.js +0 -5
- package/dist/components/display/step.js +0 -121
- package/dist/components/display/timeline.js +0 -14
- package/dist/components/floating/command-palette.js +0 -155
- package/dist/components/floating/modal.js +0 -195
- package/dist/components/floating/toolbar.js +0 -4
- package/dist/components/form/autocomplete.js +0 -247
- package/dist/components/form/checkbox.js +0 -7
- package/dist/components/form/file-upload.js +0 -88
- package/dist/components/form/input-field.js +0 -17
- package/dist/components/form/multi-select.js +0 -277
- package/dist/components/form/radiobox.js +0 -3
- package/dist/components/form/select.js +0 -31
- package/dist/components/form/switch.js +0 -36
- package/dist/components/form/transfer-list.js +0 -22
- package/dist/components/table/group.js +0 -41
- package/dist/components/table/metadata.js +0 -14
- package/dist/components/table/pagination.js +0 -42
- package/dist/components/table/row.js +0 -47
- package/dist/components/table/thead.js +0 -71
- package/dist/flow/flow.js +0 -77
- /package/dist/components/form/{formReset.js → formReset.jsx} +0 -0
- /package/dist/components/form/{input.js → input.jsx} +0 -0
- /package/dist/components/form/{textarea.js → textarea.jsx} +0 -0
- /package/dist/components/table/{table.context.js → table.context.jsx} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../../../src/components/table/filter.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA4B,MAAM,OAAO,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGtC,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAGzC,OAAO,EAAE,WAAW,EAAU,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE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AAI,CAAC,SAAS,MAAM,EAAE,2BAA2B,uBAAuB,CAAC,CAAC,CAAC,sBAiDzG,CAAC"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
1
|
import { ListFilterIcon, PlusIcon, Trash2Icon } from "lucide-react";
|
|
3
|
-
import { Fragment, useMemo } from "react";
|
|
2
|
+
import React, { Fragment, useMemo } from "react";
|
|
4
3
|
import { useTranslations } from "../../hooks/use-translations";
|
|
5
4
|
import { uuid } from "../../lib/fns";
|
|
6
5
|
import { Dropdown } from "../floating/dropdown";
|
|
@@ -86,10 +85,33 @@ export const Filter = (props) => {
|
|
|
86
85
|
const value = valueFromType(e.target);
|
|
87
86
|
props.set((prev) => prev.map((x) => (x.id === id ? { ...x, value } : x)));
|
|
88
87
|
};
|
|
89
|
-
return (
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
88
|
+
return (<Fragment>
|
|
89
|
+
<Dropdown arrow title={translation.tableFilterDropdownTitle} trigger={<span className="flex gap-1 items-center proportional-nums">
|
|
90
|
+
<ListFilterIcon size={14}/>
|
|
91
|
+
{translation.tableFilterLabel} {props.filters.length === 0 ? "" : ` (${props.filters.length})`}
|
|
92
|
+
</span>}>
|
|
93
|
+
<ul className="mt-4 space-y-2">
|
|
94
|
+
{props.filters.map((filter) => {
|
|
95
|
+
const options = operators.options[filter.type];
|
|
96
|
+
return (<li key={`filter-select-${filter.id}`} className="flex flex-nowrap gap-3">
|
|
97
|
+
<Select options={props.options} title={translation.tableFilterColumnTitle} placeholder={translation.tableFilterColumnPlaceholder} value={filter.name} data-id={filter.id} onChange={onSelectProperty}/>
|
|
98
|
+
<Select data-id={filter.id} onChange={onSelectOperation} value={filter.operation.value} options={options} title={translation.tableFilterOperatorTitle} placeholder={translation.tableFilterOperatorPlaceholder}/>
|
|
99
|
+
<Input optionalText="" data-id={filter.id} onChange={onChangeValue} value={filter.value} type={filter.type} title={translation.tableFilterValueTitle} placeholder={translation.tableFilterValuePlaceholder}/>
|
|
100
|
+
<div className="flex justify-center items-center mt-5">
|
|
101
|
+
<button data-id={filter.id} type="button" onClick={onDelete}>
|
|
102
|
+
<Trash2Icon className="text-danger" size={16}/>
|
|
103
|
+
</button>
|
|
104
|
+
</div>
|
|
105
|
+
</li>);
|
|
106
|
+
})}
|
|
107
|
+
<li>
|
|
108
|
+
<button type="button" onClick={onAddFilter} className="flex gap-1 items-center text-primary">
|
|
109
|
+
<PlusIcon size={14}/> {translation.tableFilterNewFilter}
|
|
110
|
+
</button>
|
|
111
|
+
</li>
|
|
112
|
+
</ul>
|
|
113
|
+
</Dropdown>
|
|
114
|
+
</Fragment>);
|
|
93
115
|
};
|
|
94
116
|
export const ColumnHeaderFilter = ({ filter, onDelete, set }) => {
|
|
95
117
|
const translation = useTranslations();
|
|
@@ -109,5 +131,11 @@ export const ColumnHeaderFilter = ({ filter, onDelete, set }) => {
|
|
|
109
131
|
const value = valueFromType(e.target);
|
|
110
132
|
set((prev) => prev.map((x) => (x.id === id ? { ...x, value } : x)));
|
|
111
133
|
};
|
|
112
|
-
return (
|
|
134
|
+
return (<div className="flex flex-nowrap gap-4 items-center py-2">
|
|
135
|
+
<Select data-id={filter.id} onChange={onSelectOperation} value={filter.operation.value} options={operators.options[filter.type]} title={translation.tableFilterColumnTitle} placeholder={translation.tableFilterColumnPlaceholder}/>
|
|
136
|
+
<Input optionalText=" " data-id={filter.id} onChange={onChangeValue} value={filter.value} type={filter.type} title={translation.tableFilterValueTitle} placeholder={translation.tableFilterValueTitle}/>
|
|
137
|
+
<button onClick={onDelete} data-id={filter.id} type="button" className="mt-4">
|
|
138
|
+
<Trash2Icon className="text-danger" size={14}/>
|
|
139
|
+
</button>
|
|
140
|
+
</div>);
|
|
113
141
|
};
|
|
@@ -12,6 +12,6 @@ type Props<T extends object> = TableConfiguration<T, {
|
|
|
12
12
|
groups: GroupItem<T>[];
|
|
13
13
|
setGroups: React.Dispatch<React.SetStateAction<GroupItem<T>[]>>;
|
|
14
14
|
}>;
|
|
15
|
-
export declare const Group: <T extends object>(props: Props<T>) =>
|
|
15
|
+
export declare const Group: <T extends object>(props: Props<T>) => React.JSX.Element;
|
|
16
16
|
export {};
|
|
17
17
|
//# sourceMappingURL=group.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"group.d.ts","sourceRoot":"","sources":["../../../src/components/table/group.tsx"],"names":[],"mappings":"AAIA,OAAO,KAA6B,MAAM,OAAO,CAAC;AAOlD,OAAO,EAAE,GAAG,EAAoB,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAExE,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC,GAAG;IAC/C,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC,CAAC;CACrB,CAAC;AAEF,KAAK,KAAK,CAAC,CAAC,SAAS,MAAM,IAAI,kBAAkB,CAC7C,CAAC,EACD;IACI,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;IACvB,SAAS,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;CACnE,CACJ,CAAC;AAqBF,eAAO,MAAM,KAAK,GAAI,CAAC,SAAS,MAAM,EAAE,OAAO,KAAK,CAAC,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"group.d.ts","sourceRoot":"","sources":["../../../src/components/table/group.tsx"],"names":[],"mappings":"AAIA,OAAO,KAA6B,MAAM,OAAO,CAAC;AAOlD,OAAO,EAAE,GAAG,EAAoB,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAExE,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC,GAAG;IAC/C,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC,CAAC;CACrB,CAAC;AAEF,KAAK,KAAK,CAAC,CAAC,SAAS,MAAM,IAAI,kBAAkB,CAC7C,CAAC,EACD;IACI,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;IACvB,SAAS,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;CACnE,CACJ,CAAC;AAqBF,eAAO,MAAM,KAAK,GAAI,CAAC,SAAS,MAAM,EAAE,OAAO,KAAK,CAAC,CAAC,CAAC,sBA4EtD,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { LayoutGroup, Reorder, useDragControls, useMotionValue } from "motion/react";
|
|
3
|
+
import Linq from "linq-arrays";
|
|
4
|
+
import { GripVerticalIcon, Trash2Icon, UngroupIcon } from "lucide-react";
|
|
5
|
+
import React, { Fragment, useState } from "react";
|
|
6
|
+
import { keys } from "sidekicker";
|
|
7
|
+
import { useTranslations } from "../../hooks/use-translations";
|
|
8
|
+
import { uuid } from "../../lib/fns";
|
|
9
|
+
import { Button } from "../core/button";
|
|
10
|
+
import { Dropdown } from "../floating/dropdown";
|
|
11
|
+
import { Select } from "../form/select";
|
|
12
|
+
import { createOptionCols } from "./table-lib";
|
|
13
|
+
const Item = ({ item, onPointerDown }) => {
|
|
14
|
+
const y = useMotionValue(0);
|
|
15
|
+
return (<Reorder.Item onPointerDown={onPointerDown} id={item.groupId} className="flex flex-row items-center gap-2" key={item.groupId} value={item} style={{ y }}>
|
|
16
|
+
<button type="button" className="cursor-grab">
|
|
17
|
+
<GripVerticalIcon size={14}/>
|
|
18
|
+
</button>
|
|
19
|
+
<span>{item.groupName}</span>
|
|
20
|
+
</Reorder.Item>);
|
|
21
|
+
};
|
|
22
|
+
export const Group = (props) => {
|
|
23
|
+
const translations = useTranslations();
|
|
24
|
+
const options = createOptionCols(props.cols);
|
|
25
|
+
const controls = useDragControls();
|
|
26
|
+
const [group, setGroup] = useState(props.groups[0]?.thead || "");
|
|
27
|
+
const onChange = (e) => {
|
|
28
|
+
const select = e.target;
|
|
29
|
+
const key = select.value;
|
|
30
|
+
const index = select.options.selectedIndex;
|
|
31
|
+
const label = select.options.item(index)?.label || "";
|
|
32
|
+
setGroup(label);
|
|
33
|
+
const groupBy = new Linq(props.rows).GroupBy(key);
|
|
34
|
+
const col = props.cols.find((x) => x.id === key);
|
|
35
|
+
props.setGroups(keys(groupBy).map((groupName, index) => {
|
|
36
|
+
const rows = groupBy[groupName];
|
|
37
|
+
return { ...col, groupId: uuid(), groupKey: key, index, rows, groupName: groupName };
|
|
38
|
+
}));
|
|
39
|
+
};
|
|
40
|
+
const onDelete = () => props.setGroups([]);
|
|
41
|
+
return (<Fragment>
|
|
42
|
+
<Dropdown arrow={false} title={translations.tableGroupLabel} trigger={<span className="flex items-center gap-1 proportional-nums">
|
|
43
|
+
<UngroupIcon size={14}/>
|
|
44
|
+
{translations.tableGroupLabelWithCount}
|
|
45
|
+
{props.groups.length > 0 ? ` - ${group}(${props.groups.length})` : ""}
|
|
46
|
+
</span>}>
|
|
47
|
+
<div className="flex flex-nowrap items-center">
|
|
48
|
+
<Select value={group} title="Tipo de agrupamento" onChange={onChange} options={options} placeholder="Agrupar por..."/>
|
|
49
|
+
<Button className="mt-4" onClick={onDelete} theme="raw" data-id={group}>
|
|
50
|
+
<Trash2Icon size={16} className="text-danger"/>
|
|
51
|
+
</Button>
|
|
52
|
+
</div>
|
|
53
|
+
{props.groups.length > 0 ? (<section className="my-4">
|
|
54
|
+
<header>
|
|
55
|
+
<h2 className="text-xl font-medium">Order groups</h2>
|
|
56
|
+
</header>
|
|
57
|
+
<LayoutGroup>
|
|
58
|
+
<Reorder.Group axis="y" className="relative space-y-2" drag dragControls={controls} dragListener={false} layoutScroll onReorder={props.setGroups} values={props.groups}>
|
|
59
|
+
{props.groups.map((item) => (<Item key={item.groupId} item={item} onPointerDown={(e) => {
|
|
60
|
+
controls.start(e);
|
|
61
|
+
props.setGroups([...props.groups]);
|
|
62
|
+
}}/>))}
|
|
63
|
+
</Reorder.Group>
|
|
64
|
+
</LayoutGroup>
|
|
65
|
+
</section>) : null}
|
|
66
|
+
</Dropdown>
|
|
67
|
+
</Fragment>);
|
|
68
|
+
};
|
|
@@ -16,5 +16,5 @@ export type TableProps<T extends Any> = Pick<InnerTableProps<T>, "cols" | "rows"
|
|
|
16
16
|
getScrollRef?: () => HTMLElement | undefined;
|
|
17
17
|
getRowProps: (row: T) => ComponentProps<"tr">;
|
|
18
18
|
}>;
|
|
19
|
-
export declare const Table: <T extends Any>(props: TableProps<T>) => import("react
|
|
19
|
+
export declare const Table: <T extends Any>(props: TableProps<T>) => import("react").JSX.Element;
|
|
20
20
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/table/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/table/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAsB,MAAM,OAAO,CAAC;AAG3D,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAGlC,OAAO,EAAc,eAAe,EAAE,MAAM,eAAe,CAAC;AAG5D,OAAO,EAAyB,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAGzE,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,GAAG,IAAI,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,aAAa,GAAG,QAAQ,GAAG,OAAO,CAAC,GAAG;IACvH,IAAI,EAAE,MAAM,CAAC;CACd,GAAG,OAAO,CACT,mBAAmB,CAAC,CAAC,CAAC,GAAG;IACvB,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,EAAE,OAAO,CAAC;IACpB,YAAY,EAAE,OAAO,CAAC;IACtB,YAAY,EAAE,OAAO,CAAC;IACtB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,WAAW,GAAG,SAAS,CAAC;IAC7C,WAAW,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,cAAc,CAAC,IAAI,CAAC,CAAC;CAC/C,CACF,CAAC;AASF,eAAO,MAAM,KAAK,GAAI,CAAC,SAAS,GAAG,EAAE,OAAO,UAAU,CAAC,CAAC,CAAC,gCAoHxD,CAAC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
2
|
import { AnimatePresence } from "motion/react";
|
|
4
|
-
import { useMemo } from "react";
|
|
3
|
+
import { useEffect, useMemo } from "react";
|
|
5
4
|
import { useReducer } from "use-typed-reducer";
|
|
6
5
|
import { useTweaks } from "../../hooks/use-tweaks";
|
|
7
6
|
import { InnerTable } from "./inner-table";
|
|
@@ -45,5 +44,17 @@ export const Table = (props) => {
|
|
|
45
44
|
},
|
|
46
45
|
],
|
|
47
46
|
});
|
|
48
|
-
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
dispatch.cols(props.cols);
|
|
49
|
+
}, [props.cols]);
|
|
50
|
+
return (<TableProvider value={contextState}>
|
|
51
|
+
<AnimatePresence initial={false}>
|
|
52
|
+
{operations ? (<Metadata cols={state.cols} rows={props.rows} options={optionCols} groups={state.groups} filters={state.filters} setCols={dispatch.cols} sorters={state.sorters} setGroups={dispatch.groups} setFilters={dispatch.filters} setSorters={dispatch.sorters} pagination={props.pagination ?? null} inlineFilter={props.inlineFilter ?? true} inlineSorter={props.inlineSorter ?? true}/>) : null}
|
|
53
|
+
{state.groups.length === 0 ? (<InnerTable {...props} index={0} cols={state.cols} options={optionCols} groups={state.groups} filters={state.filters} optionCols={optionCols} setCols={dispatch.cols} sorters={state.sorters} setGroups={dispatch.groups} setFilters={dispatch.filters} setSorters={dispatch.sorters} onScrollEnd={props.onScrollEnd} pagination={props.pagination ?? null} inlineFilter={props.inlineFilter ?? true} inlineSorter={props.inlineSorter ?? true}/>) : (<div className="flex flex-wrap gap-4">
|
|
54
|
+
{state.groups.map((group, index) => (<div className="min-w-full" key={`group-${group.groupId}`}>
|
|
55
|
+
<InnerTable {...props} group={group} index={index} cols={state.cols} pagination={null} rows={group.rows} options={optionCols} groups={state.groups} filters={state.filters} optionCols={optionCols} setCols={dispatch.cols} sorters={state.sorters} setGroups={dispatch.groups} setFilters={dispatch.filters} setSorters={dispatch.sorters} onScrollEnd={props.onScrollEnd} inlineFilter={props.inlineFilter ?? true} inlineSorter={props.inlineSorter ?? true}/>
|
|
56
|
+
</div>))}
|
|
57
|
+
</div>)}
|
|
58
|
+
</AnimatePresence>
|
|
59
|
+
</TableProvider>);
|
|
49
60
|
};
|
|
@@ -25,5 +25,5 @@ export type InnerTableProps<T extends Any> = HTMLAttributes<HTMLTableElement> &
|
|
|
25
25
|
getRowProps?: (_: T) => ComponentProps<"tr">;
|
|
26
26
|
setGroups: React.Dispatch<React.SetStateAction<GroupItem<T>[]>>;
|
|
27
27
|
};
|
|
28
|
-
export declare const InnerTable: <T extends Any>({ cols, filters, setCols, sorters, setFilters, setSorters, onScrollEnd, getScrollRef,
|
|
28
|
+
export declare const InnerTable: <T extends Any>({ cols, filters, setCols, sorters, setFilters, setSorters, onScrollEnd, getScrollRef, pagination, useControl, ...props }: InnerTableProps<T>) => React.JSX.Element;
|
|
29
29
|
//# sourceMappingURL=inner-table.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inner-table.d.ts","sourceRoot":"","sources":["../../../src/components/table/inner-table.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAE,cAAc,EAA2B,cAAc,EAAwC,MAAM,OAAO,CAAC;AAI7H,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAGlC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAGpC,OAAO,EAAa,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,GAAG,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAIzE,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,GAAG,IAAI,cAAc,CAAC,gBAAgB,CAAC,GAC3E,mBAAmB,CAAC,CAAC,CAAC,GAAG;IACvB,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;IACtB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,MAAM,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;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d,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;IACtB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,MAAM,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IACzB,UAAU,EAAE,WAAW,EAAE,CAAC;IAC1B,OAAO,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;IAC5B,KAAK,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC;IACtC,YAAY,CAAC,EAAE,MAAM,WAAW,GAAG,SAAS,CAAC;IAC7C,WAAW,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,cAAc,CAAC,IAAI,CAAC,CAAC;IAC7C,SAAS,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;CACjE,CAAC;AA8FJ,eAAO,MAAM,UAAU,GAAI,CAAC,SAAS,GAAG,EAAE,0HAYvC,eAAe,CAAC,CAAC,CAAC,sBA0EpB,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
1
|
import Linq from "linq-arrays";
|
|
3
2
|
import { AnimatePresence } from "motion/react";
|
|
4
3
|
import React, { Fragment, useEffect, useMemo, useRef, useState } from "react";
|
|
@@ -13,25 +12,33 @@ import { multiSort } from "./sort";
|
|
|
13
12
|
import { useTable } from "./table.context";
|
|
14
13
|
import { TableHeader } from "./thead";
|
|
15
14
|
const TableBody = React.forwardRef(({ context, className = "", ...props }, ref) => {
|
|
16
|
-
return (
|
|
15
|
+
return (<tbody {...props} role="rowgroup" className={`divide-y divide-table-border ${className}`} ref={ref}>
|
|
16
|
+
<AnimatePresence>{props.children}</AnimatePresence>
|
|
17
|
+
</tbody>);
|
|
17
18
|
});
|
|
18
|
-
const VirtualTable = React.forwardRef(({ context, className = "", ...props }, ref) => (
|
|
19
|
+
const VirtualTable = React.forwardRef(({ context, className = "", ...props }, ref) => (<table {...props} role="table" ref={ref} style={{ ...props.style, "--table-cell-padding": "0.75rem" }} className={`table w-full table-fixed border-spacing-0 border-separate text-left ${className ?? ""}`}/>));
|
|
19
20
|
const Thead = React.forwardRef(({ context, ...props }, ref) => {
|
|
20
21
|
const ctx = useTable();
|
|
21
22
|
const style = {
|
|
22
23
|
...props?.style,
|
|
23
24
|
top: Is.number(ctx.sticky) ? `${ctx.sticky}px` : undefined,
|
|
24
25
|
};
|
|
25
|
-
return (
|
|
26
|
+
return (<thead {...props} ref={ref} style={style} role="rowgroup" className="hidden top-0 bg-transparent md:table-header-group group:sticky"/>);
|
|
26
27
|
});
|
|
27
28
|
const TRow = React.forwardRef(({ context, item, ...props }, ref) => {
|
|
28
29
|
const contextProps = context?.getRowProps?.(item);
|
|
29
30
|
const innerProps = { ...props, ...contextProps };
|
|
30
|
-
return (
|
|
31
|
+
return (<tr {...innerProps} role="row" ref={ref} className={`group-table-row pb-4 flex h-fit flex-col flex-wrap justify-center gap-1 md:table-row ${props?.className ?? ""}`}/>);
|
|
31
32
|
});
|
|
32
33
|
const TFoot = React.forwardRef((props, ref) => {
|
|
33
34
|
if (props.context.loadingMore) {
|
|
34
|
-
return (
|
|
35
|
+
return (<tfoot {...props} ref={ref} className="bg-card-background">
|
|
36
|
+
<tr role="row" className="bg-card-background">
|
|
37
|
+
<td colSpan={999} className="px-2 h-14 bg-card-background">
|
|
38
|
+
<span className="block w-full h-2 rounded opacity-60 animate-pulse bg-foreground"/>
|
|
39
|
+
</td>
|
|
40
|
+
</tr>
|
|
41
|
+
</tfoot>);
|
|
35
42
|
}
|
|
36
43
|
return null;
|
|
37
44
|
});
|
|
@@ -43,12 +50,12 @@ const components = {
|
|
|
43
50
|
TableBody: TableBody,
|
|
44
51
|
};
|
|
45
52
|
const loadingArray = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
|
|
46
|
-
const EmptyContent = (props) => (
|
|
47
|
-
const EmptyCell = () =>
|
|
53
|
+
const EmptyContent = (props) => (<div className="flex justify-center items-center px-2 w-full h-48">{props.loading ? SkeletonCell : <Empty />}</div>);
|
|
54
|
+
const EmptyCell = () => <Fragment />;
|
|
48
55
|
const emptyRows = [];
|
|
49
|
-
export const InnerTable = ({ cols, filters, setCols, sorters, setFilters, setSorters, onScrollEnd, getScrollRef,
|
|
56
|
+
export const InnerTable = ({ cols, filters, setCols, sorters, setFilters, setSorters, onScrollEnd, getScrollRef, pagination = null, useControl = false, ...props }) => {
|
|
50
57
|
const ref = useRef(null);
|
|
51
|
-
const [
|
|
58
|
+
const [, setShowLoadingFooter] = useState(false);
|
|
52
59
|
const onScrollEndRef = useStableRef(onScrollEnd);
|
|
53
60
|
const loadingMoreRef = useStableRef(props.loadingMore);
|
|
54
61
|
const rows = useMemo(() => {
|
|
@@ -88,5 +95,10 @@ export const InnerTable = ({ cols, filters, setCols, sorters, setFilters, setSor
|
|
|
88
95
|
getRowProps: props.getRowProps,
|
|
89
96
|
loadingMore: props.loadingMore,
|
|
90
97
|
};
|
|
91
|
-
return (
|
|
98
|
+
return (<div className="flex relative flex-col w-full whitespace-nowrap rounded-lg group">
|
|
99
|
+
<TableVirtuoso components={components} context={context} totalCount={rows.length} itemContent={empty ? EmptyCell : Row} data={empty ? emptyRows : rows} useWindowScroll={getScrollRef ? false : true} customScrollParent={getScrollRef ? getScrollRef() : undefined} fixedHeaderContent={() => (<TableHeader headers={cols} filters={filters} setCols={setCols} sorters={sorters} setFilters={setFilters} setSorters={setSorters} loading={!!props.loading} inlineFilter={props.inlineFilter} inlineSorter={props.inlineSorter}/>)}/>
|
|
100
|
+
{empty ? <EmptyContent loading={props.loading}/> : null}
|
|
101
|
+
<div aria-hidden="true" ref={ref} className="w-full h-0.5"/>
|
|
102
|
+
{pagination !== null ? <Pagination {...pagination}/> : null}
|
|
103
|
+
</div>);
|
|
92
104
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Any } from "../../types";
|
|
2
2
|
import { TableOperationProps } from "./table-lib";
|
|
3
|
-
export declare const Metadata: <T extends Any>(props: TableOperationProps<T>) => import("react
|
|
3
|
+
export declare const Metadata: <T extends Any>(props: TableOperationProps<T>) => import("react").JSX.Element;
|
|
4
4
|
//# sourceMappingURL=metadata.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../../../src/components/table/metadata.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAIlC,OAAO,EAAE,mBAAmB,EAAiB,MAAM,aAAa,CAAC;AAEjE,eAAO,MAAM,QAAQ,GAAI,CAAC,SAAS,GAAG,EAAE,OAAO,mBAAmB,CAAC,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../../../src/components/table/metadata.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAIlC,OAAO,EAAE,mBAAmB,EAAiB,MAAM,aAAa,CAAC;AAEjE,eAAO,MAAM,QAAQ,GAAI,CAAC,SAAS,GAAG,EAAE,OAAO,mBAAmB,CAAC,CAAC,CAAC,gCA6CpE,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Filter } from "./filter";
|
|
2
|
+
import { Group } from "./group";
|
|
3
|
+
import { Sort } from "./sort";
|
|
4
|
+
import { valueFromType } from "./table-lib";
|
|
5
|
+
export const Metadata = (props) => (<header className="mb-1 min-w-full">
|
|
6
|
+
<div className="flex flex-wrap gap-y-1 gap-x-4 justify-between items-center min-w-full">
|
|
7
|
+
<div className="flex gap-4 py-2 whitespace-nowrap w-fit items-centeend">
|
|
8
|
+
<span>
|
|
9
|
+
<Filter cols={props.cols} options={props.options} filters={props.filters} set={props.setFilters}/>
|
|
10
|
+
</span>
|
|
11
|
+
<span>
|
|
12
|
+
<Sort options={props.options} cols={props.cols} sorters={props.sorters} set={props.setSorters}/>
|
|
13
|
+
</span>
|
|
14
|
+
<span>
|
|
15
|
+
<Group rows={props.rows} groups={props.groups} setGroups={props.setGroups} options={props.options} cols={props.cols}/>
|
|
16
|
+
</span>
|
|
17
|
+
</div>
|
|
18
|
+
<ul className="flex flex-row flex-wrap flex-1 flex-grow gap-4 items-center w-full md:justify-end">
|
|
19
|
+
{props.filters.map((x) => (<li key={`filter-table-${x.id}`} className="flex gap-1 items-center py-0.5 px-4 rounded-xl border border-card-border">
|
|
20
|
+
<span>
|
|
21
|
+
<span className="inline-block mr-2 rounded-full size-3 aspect-square bg-primary" aria-hidden="true"/>
|
|
22
|
+
{x.label} {x.operation.label.toLowerCase()}:
|
|
23
|
+
</span>
|
|
24
|
+
<div className="relative w-min min-w-[1ch]">
|
|
25
|
+
<span aria-hidden="true" className="invisible p-0 whitespace-pre">
|
|
26
|
+
{x.value || " "}
|
|
27
|
+
</span>
|
|
28
|
+
<input type={x.type} value={x.value} className="absolute left-0 top-0 m-0 inline-block w-full bg-transparent p-0 placeholder-primary/70 outline-none [appearance:textfield] after:empty:text-primary/70 [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none" onChange={(e) => {
|
|
29
|
+
const value = valueFromType(e.target);
|
|
30
|
+
props.setFilters((prev) => prev.map((item) => x.id === item.id
|
|
31
|
+
? { ...item, value, } : item));
|
|
32
|
+
}}/>
|
|
33
|
+
</div>
|
|
34
|
+
</li>))}
|
|
35
|
+
</ul>
|
|
36
|
+
</div>
|
|
37
|
+
</header>);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { TablePagination } from "./table-lib";
|
|
2
|
-
export declare const Pagination: (pagination: TablePagination) => import("react
|
|
2
|
+
export declare const Pagination: (pagination: TablePagination) => import("react").JSX.Element;
|
|
3
3
|
//# sourceMappingURL=pagination.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../../../src/components/table/pagination.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAuB9C,eAAO,MAAM,UAAU,GAAI,YAAY,eAAe,
|
|
1
|
+
{"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../../../src/components/table/pagination.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAuB9C,eAAO,MAAM,UAAU,GAAI,YAAY,eAAe,gCA2ErD,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { Fragment, useId, useMemo } from "react";
|
|
2
|
+
import { useTranslations } from "../../hooks/use-translations";
|
|
3
|
+
import { Polymorph } from "../core/polymorph";
|
|
4
|
+
function createPaginationItems(current, max) {
|
|
5
|
+
if (!current || !max)
|
|
6
|
+
return [];
|
|
7
|
+
const items = [1];
|
|
8
|
+
if (current === 1 && max === 1)
|
|
9
|
+
return items;
|
|
10
|
+
if (current > 4)
|
|
11
|
+
items.push("-");
|
|
12
|
+
const r = 2;
|
|
13
|
+
const r1 = current - r;
|
|
14
|
+
const r2 = current + r;
|
|
15
|
+
for (let i = r1 > 2 ? r1 : 2; i <= Math.min(max, r2); i++)
|
|
16
|
+
items.push(i);
|
|
17
|
+
const p2 = max - 2;
|
|
18
|
+
if (r2 + 1 !== p2) {
|
|
19
|
+
if (r2 + 1 < max)
|
|
20
|
+
items.push("_");
|
|
21
|
+
}
|
|
22
|
+
if (r2 < max) {
|
|
23
|
+
items.push(max - 2);
|
|
24
|
+
items.push(max - 1);
|
|
25
|
+
items.push(max);
|
|
26
|
+
}
|
|
27
|
+
return Array.from(new Set(items));
|
|
28
|
+
}
|
|
29
|
+
export const Pagination = (pagination) => {
|
|
30
|
+
const id = useId();
|
|
31
|
+
const translation = useTranslations();
|
|
32
|
+
const pageNavigation = useMemo(() => createPaginationItems(pagination.current, pagination.pages), [pagination.current, pagination.pages]);
|
|
33
|
+
const hasNext = pagination.current < pagination.pages;
|
|
34
|
+
return (<footer className="flex flex-wrap items-center justify-center gap-4 p-3 border-t-muted text-sm lg:flex-nowrap lg:justify-between">
|
|
35
|
+
<p>
|
|
36
|
+
<translation.tablePaginationFooter {...pagination} sizes={pagination.sizes} select={pagination.onChangeSize && Array.isArray(pagination.sizes) ? (<Fragment>
|
|
37
|
+
<label htmlFor={id}>{translation.tablePaginationSelectLabel}</label>
|
|
38
|
+
<select id={id} value={pagination.size} className="cursor-pointer bg-transparent" onChange={(e) => {
|
|
39
|
+
pagination.onChangeSize?.(Number(e.target.value));
|
|
40
|
+
}}>
|
|
41
|
+
{pagination.sizes.map((value) => (<option key={`pagination-opt-${value}`} value={value}>
|
|
42
|
+
{value}
|
|
43
|
+
</option>))}
|
|
44
|
+
</select>{" "}
|
|
45
|
+
</Fragment>) : null}/>
|
|
46
|
+
</p>
|
|
47
|
+
<nav>
|
|
48
|
+
<ul className="flex items-center gap-2">
|
|
49
|
+
{pagination.current > 1 ? (<li>
|
|
50
|
+
<Polymorph as={pagination.asLink || "button"} href="previous" className="">
|
|
51
|
+
{translation.tablePaginationPrevious}
|
|
52
|
+
</Polymorph>
|
|
53
|
+
</li>) : null}
|
|
54
|
+
{pageNavigation.map((x) => {
|
|
55
|
+
if (x === null)
|
|
56
|
+
return null;
|
|
57
|
+
return (<Fragment key={`pagination-${x}`}>
|
|
58
|
+
{typeof x === "string" ? (<li>...</li>) : (<li>
|
|
59
|
+
<Polymorph href={x} as={pagination.asLink || "button"} className={`cursor-pointer border-b-2 px-3 py-1 proportional-nums transition-colors hover:border-primary-subtle hover:text-primary-subtle ${x === pagination.current ? "border-primary text-primary" : "border-transparent"}`}>
|
|
60
|
+
{x}
|
|
61
|
+
</Polymorph>
|
|
62
|
+
</li>)}
|
|
63
|
+
</Fragment>);
|
|
64
|
+
})}
|
|
65
|
+
{hasNext ? (<li>
|
|
66
|
+
<Polymorph as={pagination.asLink || "button"} href="next" className="">
|
|
67
|
+
{translation.tablePaginationNext}
|
|
68
|
+
</Polymorph>
|
|
69
|
+
</li>) : null}
|
|
70
|
+
</ul>
|
|
71
|
+
</nav>
|
|
72
|
+
</footer>);
|
|
73
|
+
};
|
|
@@ -7,6 +7,6 @@ type ItemContentContext = {
|
|
|
7
7
|
loadingMore?: boolean;
|
|
8
8
|
Aside?: React.FC<CellAsideElement<any>>;
|
|
9
9
|
};
|
|
10
|
-
export declare const Row: (index: number, row: any, context: ItemContentContext) =>
|
|
10
|
+
export declare const Row: (index: number, row: any, context: ItemContentContext) => React.JSX.Element;
|
|
11
11
|
export {};
|
|
12
12
|
//# sourceMappingURL=row.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"row.d.ts","sourceRoot":"","sources":["../../../src/components/table/row.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmE,MAAM,OAAO,CAAC;AAGxF,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAElC,OAAO,EAAE,gBAAgB,EAAoB,GAAG,EAAa,MAAM,aAAa,CAAC;AAEjF,KAAK,kBAAkB,GAAG;
|
|
1
|
+
{"version":3,"file":"row.d.ts","sourceRoot":"","sources":["../../../src/components/table/row.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmE,MAAM,OAAO,CAAC;AAGxF,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAElC,OAAO,EAAE,gBAAgB,EAAoB,GAAG,EAAa,MAAM,aAAa,CAAC;AAEjF,KAAK,kBAAkB,GAAG;IACxB,IAAI,EAAE,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,KAAK,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC;CACzC,CAAC;AA6CF,eAAO,MAAM,GAAG,GAAI,OAAO,MAAM,EAAE,KAAK,GAAG,EAAE,SAAS,kBAAkB,sBAwCvE,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import React, { Fragment, useEffect, useRef, useState } from "react";
|
|
2
|
+
import { Is } from "sidekicker";
|
|
3
|
+
import { path } from "../../lib/fns";
|
|
4
|
+
import { SkeletonCell } from "../display/skeleton";
|
|
5
|
+
const RowAside = (props) => {
|
|
6
|
+
const parentRef = useRef(null);
|
|
7
|
+
const ref = useRef(null);
|
|
8
|
+
const [className, setClassName] = useState("opacity-0");
|
|
9
|
+
const ariaHidden = className === "opacity-0";
|
|
10
|
+
const onLeave = () => setClassName("opacity-0");
|
|
11
|
+
const callback = () => {
|
|
12
|
+
const child = ref.current;
|
|
13
|
+
const parent = parentRef.current;
|
|
14
|
+
if (child === null || parent === null)
|
|
15
|
+
return;
|
|
16
|
+
parent.style.left = `-${child.getBoundingClientRect().width + 4}px`;
|
|
17
|
+
};
|
|
18
|
+
const onEnter = () => setClassName("opacity-100");
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
const child = ref.current;
|
|
21
|
+
if (child === null || parent === null)
|
|
22
|
+
return;
|
|
23
|
+
callback();
|
|
24
|
+
const observer = new IntersectionObserver((entries) => entries.forEach(callback), { root: document.documentElement });
|
|
25
|
+
observer.observe(child);
|
|
26
|
+
return () => observer.disconnect();
|
|
27
|
+
}, []);
|
|
28
|
+
return (<div ref={parentRef} onMouseEnter={onEnter} onMouseLeave={onLeave} data-component="cell-aside" inert={ariaHidden ? true : undefined} tabIndex={ariaHidden ? -1 : undefined} className={`group-table-cell-aside absolute inset-0 top-0 flex h-full w-full items-stretch transition-opacity duration-300 ease-in-out ${className}`}>
|
|
29
|
+
<div ref={ref} className="block isolate">
|
|
30
|
+
{props.children}
|
|
31
|
+
</div>
|
|
32
|
+
</div>);
|
|
33
|
+
};
|
|
34
|
+
export const Row = (index, row, context) => {
|
|
35
|
+
const cols = context.cols;
|
|
36
|
+
const loading = context.loading;
|
|
37
|
+
return (<Fragment>
|
|
38
|
+
{cols.map((col, colIndex) => {
|
|
39
|
+
const matrix = `${colIndex},${index}`;
|
|
40
|
+
const value = path(row, col.id);
|
|
41
|
+
const Component = col.Element;
|
|
42
|
+
const className = col.cellProps?.className || "";
|
|
43
|
+
const exposeAside = colIndex === 0 && context.Aside && loading === false;
|
|
44
|
+
const Aside = context.Aside;
|
|
45
|
+
return (<td {...col.cellProps} role="cell" data-matrix={matrix} key={`accessor-${index}-${colIndex}`} className={`typography group-table-cell p-[var(--table-cell-padding)] whitespace-pre-wrap flex flex-col md:table-cell border-b border md:border-l-transparent md:border-b-0 border-y border-collapse border-table-border md:border-r md:last:border-r-transparent ${className}`}>
|
|
46
|
+
{exposeAside ? (<RowAside>
|
|
47
|
+
<Aside col={col} row={row} rowIndex={index}/>
|
|
48
|
+
</RowAside>) : null}
|
|
49
|
+
<span className="block text-sm font-bold leading-tight md:hidden">{col.thead}</span>
|
|
50
|
+
<span className="relative">
|
|
51
|
+
{loading ? SkeletonCell : Component ? (<Fragment>
|
|
52
|
+
<Component row={row} matrix={matrix} col={col} rowIndex={index} value={value}/>
|
|
53
|
+
</Fragment>) : (<Fragment>{Is.nil(value) ? "" : value}</Fragment>)}
|
|
54
|
+
</span>
|
|
55
|
+
</td>);
|
|
56
|
+
})}
|
|
57
|
+
</Fragment>);
|
|
58
|
+
};
|
|
@@ -19,10 +19,10 @@ type Props<T extends Any> = TableConfiguration<T, {
|
|
|
19
19
|
sorters: Sorter<T>[];
|
|
20
20
|
set: React.Dispatch<React.SetStateAction<Sorter<T>[]>>;
|
|
21
21
|
}>;
|
|
22
|
-
export declare const Sort: <T extends Any>(props: Props<T>) =>
|
|
22
|
+
export declare const Sort: <T extends Any>(props: Props<T>) => React.JSX.Element;
|
|
23
23
|
type SorterHeadProps<T extends Any> = Pick<TableOperationProps<T>, "sorters" | "setSorters"> & {
|
|
24
24
|
col: Col<T>;
|
|
25
25
|
};
|
|
26
|
-
export declare const SorterHead: <T extends Any>(props: SorterHeadProps<T>) =>
|
|
26
|
+
export declare const SorterHead: <T extends Any>(props: SorterHeadProps<T>) => React.JSX.Element;
|
|
27
27
|
export {};
|
|
28
28
|
//# sourceMappingURL=sort.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sort.d.ts","sourceRoot":"","sources":["../../../src/components/table/sort.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAwC,MAAM,OAAO,CAAC;AAG7D,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAGzC,OAAO,EAAE,GAAG,EAAY,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAErF,KAAK,KAAK,CAAC,CAAC,SAAS,GAAG,IAAI,MAAM,CAAC,SAAS,MAAM,CAAC,SAAS,MAAM,GAAG,CAAC,GAAG,KAAK,CAAC;AAE/E,aAAK,KAAK;IACN,GAAG,QAAQ;IACX,IAAI,SAAS;IACb,SAAS,cAAc;CAC1B;AAED,MAAM,MAAM,MAAM,CAAC,CAAC,SAAS,GAAG,IAAI;IAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IAAC,IAAI,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,KAAK,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC;AAY/F,eAAO,MAAM,SAAS,GAAI,CAAC,SAAS,GAAG,EAAE,OAAO,CAAC,EAAE,EAAE,QAAQ,MAAM,CAAC,CAAC,CA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K,CAAC,CAAC,SAAS,GAAG,IAAI,kBAAkB,CAC1C,CAAC,EACD;IACI,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IACf,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;IACrB,GAAG,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;CAC1D,CACJ,CAAC;AASF,eAAO,MAAM,IAAI,GAAI,CAAC,SAAS,GAAG,EAAE,OAAO,KAAK,CAAC,CAAC,CAAC,sBA0ElD,CAAC;AAEF,KAAK,eAAe,CAAC,CAAC,SAAS,GAAG,IAAI,IAAI,CAAC,mBAAmB,CAAC,CAAC,CAAC,EAAE,SAAS,GAAG,YAAY,CAAC,GAAG;IAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,CAAA;CAAE,CAAC;AAE/G,eAAO,MAAM,UAAU,GAAI,CAAC,SAAS,GAAG,EAAE,OAAO,eAAe,CAAC,CAAC,CAAC,sBAkClE,CAAC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
2
|
import { ArrowDown01Icon, ArrowUp01Icon, ArrowUpDownIcon, PlusIcon, Trash2Icon } from "lucide-react";
|
|
4
|
-
import { Fragment, useEffect, useState } from "react";
|
|
3
|
+
import React, { Fragment, useEffect, useState } from "react";
|
|
5
4
|
import { useTranslations } from "../../hooks/use-translations";
|
|
6
5
|
import { uuid } from "../../lib/fns";
|
|
7
6
|
import { Dropdown } from "../floating/dropdown";
|
|
@@ -50,9 +49,29 @@ export const Sort = (props) => {
|
|
|
50
49
|
const id = e.currentTarget.dataset.id || "";
|
|
51
50
|
props.set((prev) => prev.filter((x) => x.id !== id));
|
|
52
51
|
};
|
|
53
|
-
return (
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
return (<Fragment>
|
|
53
|
+
<Dropdown title={translation.tableSortDropdownTitle} trigger={<span className="flex items-center gap-1 proportional-nums">
|
|
54
|
+
<ArrowUpDownIcon size={14}/>
|
|
55
|
+
{translation.tableSortOrderByLabel} {props.sorters.length === 0 ? "" : ` (${props.sorters.length})`}
|
|
56
|
+
</span>}>
|
|
57
|
+
<ul className="mt-4 space-y-2">
|
|
58
|
+
{props.sorters.map((sorter) => {
|
|
59
|
+
return (<li key={`sorter-select-${sorter.id}`} className="flex flex-nowrap gap-3">
|
|
60
|
+
<Select options={props.options} value={sorter.value} onChange={onSetSorter(sorter.id)} title={translation.tableSortOrderInputTitle} placeholder={translation.tableSortOrderInputPlaceholder}/>
|
|
61
|
+
<Select onChange={onSortOrderType(sorter.id)} value={sorter.type} options={orderOptions} title={translation.tableSortTypeInputTitle} placeholder={translation.tableSortTypeInputPlaceholder}/>
|
|
62
|
+
<button className="mt-4" data-id={sorter.id} onClick={onDelete}>
|
|
63
|
+
<Trash2Icon className="text-danger" size={14}/>
|
|
64
|
+
</button>
|
|
65
|
+
</li>);
|
|
66
|
+
})}
|
|
67
|
+
<li>
|
|
68
|
+
<button type="button" onClick={onAddSorter} className="text-primary flex items-center gap-1">
|
|
69
|
+
<PlusIcon size={14}/> {translation.tableSortAddButton}
|
|
70
|
+
</button>
|
|
71
|
+
</li>
|
|
72
|
+
</ul>
|
|
73
|
+
</Dropdown>
|
|
74
|
+
</Fragment>);
|
|
56
75
|
};
|
|
57
76
|
export const SorterHead = (props) => {
|
|
58
77
|
const translations = useTranslations();
|
|
@@ -75,5 +94,12 @@ export const SorterHead = (props) => {
|
|
|
75
94
|
}, [status, props.col]);
|
|
76
95
|
const labelId = `${props.col.id}-sorter-id`;
|
|
77
96
|
const label = getLabel(props.col);
|
|
78
|
-
return (
|
|
97
|
+
return (<button aria-labelledby={labelId} className="isolate flex items-center" onClick={onClick} type="button">
|
|
98
|
+
<span id={labelId} className="sr-only">
|
|
99
|
+
{translations.tableSortDropdownTitle} {label}
|
|
100
|
+
</span>
|
|
101
|
+
{status === Order.Asc ? <ArrowUp01Icon size={14}/> : null}
|
|
102
|
+
{status === Order.Desc ? <ArrowDown01Icon size={14}/> : null}
|
|
103
|
+
{status === Order.Undefined ? <ArrowUpDownIcon size={14}/> : null}
|
|
104
|
+
</button>);
|
|
79
105
|
};
|