@g4rcez/components 0.2.1 → 0.2.3
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/index.css +1 -1
- package/dist/index.js +44 -44
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +11768 -10950
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +43 -43
- package/dist/index.umd.js.map +1 -1
- package/dist/preset/preset.tailwind.js +14 -14
- package/dist/preset/src/styles/common.d.ts +4 -0
- package/dist/preset/src/styles/common.d.ts.map +1 -1
- package/dist/preset/src/styles/common.js +10 -0
- package/dist/preset/src/styles/dark.d.ts.map +1 -1
- package/dist/preset/src/styles/dark.js +2 -1
- package/dist/preset/src/styles/design-tokens.d.ts +8 -7
- package/dist/preset/src/styles/design-tokens.d.ts.map +1 -1
- package/dist/preset/src/styles/design-tokens.js +16 -12
- package/dist/preset/src/styles/light.d.ts.map +1 -1
- package/dist/preset/src/styles/light.js +6 -5
- package/dist/preset/src/styles/theme.types.d.ts +10 -1
- package/dist/preset/src/styles/theme.types.d.ts.map +1 -1
- package/dist/preset.tailwind.js +14 -14
- package/dist/src/components/core/render-on-view.d.ts.map +1 -1
- package/dist/src/components/core/render-on-view.js +1 -0
- package/dist/src/components/display/card.d.ts +9 -1
- package/dist/src/components/display/card.d.ts.map +1 -1
- package/dist/src/components/display/card.js +7 -1
- package/dist/src/components/display/list.js +1 -1
- package/dist/src/components/floating/dropdown.js +2 -2
- package/dist/src/components/floating/expand.d.ts +2 -0
- package/dist/src/components/floating/expand.d.ts.map +1 -1
- package/dist/src/components/floating/expand.js +12 -5
- package/dist/src/components/floating/menu.js +2 -2
- package/dist/src/components/floating/modal.js +1 -1
- package/dist/src/components/floating/tooltip.d.ts +1 -1
- package/dist/src/components/floating/tooltip.d.ts.map +1 -1
- package/dist/src/components/floating/tooltip.js +5 -4
- package/dist/src/components/form/autocomplete.d.ts.map +1 -1
- package/dist/src/components/form/autocomplete.js +26 -21
- package/dist/src/components/form/checkbox.d.ts +1 -0
- package/dist/src/components/form/checkbox.d.ts.map +1 -1
- package/dist/src/components/form/checkbox.js +4 -1
- package/dist/src/components/form/date-picker.d.ts.map +1 -1
- package/dist/src/components/form/date-picker.js +1 -0
- package/dist/src/components/form/free-text.d.ts.map +1 -1
- package/dist/src/components/form/free-text.js +2 -2
- package/dist/src/components/form/input-field.d.ts +1 -0
- package/dist/src/components/form/input-field.d.ts.map +1 -1
- package/dist/src/components/form/input-field.js +2 -2
- package/dist/src/components/form/input.d.ts.map +1 -1
- package/dist/src/components/form/input.js +3 -1
- package/dist/src/components/form/multi-select.d.ts.map +1 -1
- package/dist/src/components/form/multi-select.js +25 -21
- package/dist/src/components/form/select.d.ts.map +1 -1
- package/dist/src/components/form/select.js +2 -2
- package/dist/src/components/form/slider.d.ts +7 -0
- package/dist/src/components/form/slider.d.ts.map +1 -0
- package/dist/src/components/form/slider.js +35 -0
- package/dist/src/components/form/switch.d.ts +1 -0
- package/dist/src/components/form/switch.d.ts.map +1 -1
- package/dist/src/components/form/switch.js +7 -6
- package/dist/src/components/form/transfer-list.d.ts.map +1 -1
- package/dist/src/components/form/transfer-list.js +1 -0
- package/dist/src/components/index.d.ts +1 -0
- package/dist/src/components/index.d.ts.map +1 -1
- package/dist/src/components/index.js +1 -0
- package/dist/src/components/table/filter.d.ts.map +1 -1
- package/dist/src/components/table/filter.js +1 -1
- package/dist/src/components/table/index.d.ts.map +1 -1
- package/dist/src/components/table/index.js +17 -10
- package/dist/src/components/table/table-lib.d.ts +3 -2
- package/dist/src/components/table/table-lib.d.ts.map +1 -1
- package/dist/src/components/table/table-lib.js +16 -0
- package/dist/src/components/table/thead.d.ts.map +1 -1
- package/dist/src/components/table/thead.js +26 -6
- package/dist/src/config/context.d.ts.map +1 -1
- package/dist/src/config/context.js +1 -0
- package/dist/src/config/default-tweaks.d.ts +5 -0
- package/dist/src/config/default-tweaks.d.ts.map +1 -1
- package/dist/src/config/default-tweaks.js +2 -3
- package/dist/src/hooks/use-is-coarse-device.d.ts +2 -0
- package/dist/src/hooks/use-is-coarse-device.d.ts.map +1 -0
- package/dist/src/hooks/use-is-coarse-device.js +12 -0
- package/dist/src/hooks/use-remove-scroll.d.ts.map +1 -1
- package/dist/src/hooks/use-remove-scroll.js +6 -2
- package/dist/src/hooks/use-swipe.d.ts +1 -1
- package/dist/src/hooks/use-swipe.d.ts.map +1 -1
- package/dist/src/lib/dict.d.ts +1 -1
- package/dist/src/lib/dict.d.ts.map +1 -1
- package/dist/src/lib/dict.js +1 -1
- package/dist/src/lib/fns.d.ts +1 -0
- package/dist/src/lib/fns.d.ts.map +1 -1
- package/dist/src/lib/fns.js +4 -0
- package/dist/src/styles/common.d.ts +4 -0
- package/dist/src/styles/common.d.ts.map +1 -1
- package/dist/src/styles/common.js +10 -0
- package/dist/src/styles/dark.d.ts.map +1 -1
- package/dist/src/styles/dark.js +2 -1
- package/dist/src/styles/design-tokens.d.ts +8 -7
- package/dist/src/styles/design-tokens.d.ts.map +1 -1
- package/dist/src/styles/design-tokens.js +13 -10
- package/dist/src/styles/light.d.ts.map +1 -1
- package/dist/src/styles/light.js +6 -5
- package/dist/src/styles/theme.types.d.ts +10 -1
- package/dist/src/styles/theme.types.d.ts.map +1 -1
- package/package.json +4 -3
|
@@ -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;
|
|
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;AAItC,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAGzC,OAAO,E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,eAAO,MAAM,mBAAmB,GAAI,CAAC,SAAS,GAAG,EAC7C,GAAG,GAAG,CAAC,CAAC,CAAC,EACT,SAAS,gBAAgB,EACzB,YAAY,UAAU,EACtB,OAAM,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAM,KACpC,YAAY,CAAC,CAAC,CAOhB,CAAC;AAEF,eAAO,MAAM,YAAY;;;CA0CxB,CAAC;AAEF,eAAO,MAAM,MAAM,GAAI,CAAC,SAAS,MAAM,EAAE,OAAO,KAAK,CAAC,CAAC,CAAC,4CA0GvD,CAAC;AAEF,KAAK,uBAAuB,CAAC,CAAC,SAAS,MAAM,IAAI;IAC7C,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC;IACxB,QAAQ,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;IAC3D,GAAG,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;CAChE,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,CAAC,SAAS,MAAM,EAAE,2BAA2B,uBAAuB,CAAC,CAAC,CAAC,4CAiDzG,CAAC"}
|
|
@@ -109,5 +109,5 @@ export const ColumnHeaderFilter = ({ filter, onDelete, set }) => {
|
|
|
109
109
|
const value = valueFromType(e.target);
|
|
110
110
|
set((prev) => prev.map((x) => (x.id === id ? { ...x, value } : x)));
|
|
111
111
|
};
|
|
112
|
-
return (_jsxs("div", { className: "flex flex-nowrap items-center gap-4 py-2", children: [_jsx(Select, { "data-id": filter.id, onChange: onSelectOperation, value: filter.operation.value, options: operators.options[filter.type], title: translation.tableFilterColumnTitle, placeholder: translation.tableFilterColumnPlaceholder }), _jsx(Input, { "data-id": filter.id, onChange: onChangeValue, type: filter.type, value: filter.value, title: translation.tableFilterValueTitle, placeholder: translation.tableFilterValueTitle }), _jsx("button", { onClick: onDelete, "data-id": filter.id, type: "button", className: "mt-4", children: _jsx(Trash2Icon, { className: "text-danger", size: 14 }) })] }));
|
|
112
|
+
return (_jsxs("div", { className: "flex flex-nowrap items-center gap-4 py-2", children: [_jsx(Select, { "data-id": filter.id, onChange: onSelectOperation, value: filter.operation.value, options: operators.options[filter.type], title: translation.tableFilterColumnTitle, placeholder: translation.tableFilterColumnPlaceholder }), _jsx(Input, { optionalText: " ", "data-id": filter.id, onChange: onChangeValue, type: filter.type, value: filter.value, title: translation.tableFilterValueTitle, placeholder: translation.tableFilterValueTitle }), _jsx("button", { onClick: onDelete, "data-id": filter.id, type: "button", className: "mt-4", children: _jsx(Trash2Icon, { className: "text-danger", size: 14 }) })] }));
|
|
113
113
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/table/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/table/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,EAA2B,cAAc,EAAoD,MAAM,OAAO,CAAC;AAOzH,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAElC,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,EAAoB,GAAG,EAA+B,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAStG,KAAK,eAAe,CAAC,CAAC,SAAS,GAAG,IAAI,cAAc,CAAC,gBAAgB,CAAC,GAClE,mBAAmB,CAAC,CAAC,CAAC,GAAG;IACrB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,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CA8GxD,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import { createElement as _createElement } from "react";
|
|
2
3
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
4
|
import { AnimatePresence } from "motion/react";
|
|
@@ -7,6 +8,7 @@ import { TableVirtuoso } from "react-virtuoso";
|
|
|
7
8
|
import { Is } from "sidekicker";
|
|
8
9
|
import { useReducer } from "use-typed-reducer";
|
|
9
10
|
import { useStableRef } from "../../hooks/use-stable-ref";
|
|
11
|
+
import { useTweaks } from "../../hooks/use-tweaks";
|
|
10
12
|
import { path } from "../../lib/fns";
|
|
11
13
|
import { Empty } from "../display/empty";
|
|
12
14
|
import { Metadata } from "./metadata";
|
|
@@ -19,16 +21,18 @@ const useTable = () => useContext(TableContext);
|
|
|
19
21
|
const TableBody = React.forwardRef(({ context, className = "", ...props }, ref) => {
|
|
20
22
|
return (_jsx("tbody", { ...props, role: "rowgroup", className: `divide-y divide-table-border ${className}`, ref: ref, children: _jsx(AnimatePresence, { children: props.children }) }));
|
|
21
23
|
});
|
|
22
|
-
const VirtualTable = React.forwardRef(({ context, className = "", ...props }, ref) => (_jsx("table", { ...props, ref: ref, role: "table", className: `table min-w-full table-
|
|
24
|
+
const VirtualTable = React.forwardRef(({ context, className = "", ...props }, ref) => (_jsx("table", { ...props, ref: ref, role: "table", className: `table min-w-full table-fixed border-collapse divide-y divide-table-border border-0 text-left ${className ?? ""}` })));
|
|
23
25
|
const Thead = React.forwardRef(({ context, ...props }, ref) => {
|
|
24
26
|
const ctx = useTable();
|
|
25
27
|
const style = {
|
|
26
28
|
...props?.style,
|
|
27
29
|
top: Is.number(ctx.sticky) ? `${ctx.sticky}px` : undefined,
|
|
28
30
|
};
|
|
29
|
-
return _jsx("thead", { ...props, style: style, role: "rowgroup", className: "shadow-xs group:sticky top-0 bg-
|
|
31
|
+
return _jsx("thead", { ...props, style: style, role: "rowgroup", className: "shadow-xs group:sticky top-0 bg-transparent", ref: ref });
|
|
32
|
+
});
|
|
33
|
+
const TRow = React.forwardRef(({ context, item, ...props }, ref) => {
|
|
34
|
+
return _jsx("tr", { ...props, role: "row", ref: ref, className: `group table-row ${props?.className ?? ""}` });
|
|
30
35
|
});
|
|
31
|
-
const TRow = React.forwardRef(({ context, item, ...props }, ref) => (_jsx("tr", { ...props, role: "row", ref: ref, className: `table-row ${props?.className ?? ""}` })));
|
|
32
36
|
const TFoot = React.forwardRef((props, ref) => {
|
|
33
37
|
if (props.context.loadingMore) {
|
|
34
38
|
return (_jsx("tfoot", { ...props, ref: ref, className: "bg-card-background", children: _jsx("tr", { role: "row", className: "bg-card-background", children: _jsx("td", { colSpan: 999, className: "h-14 bg-card-background px-2", children: _jsx("span", { className: "block h-2 w-full animate-pulse rounded bg-foreground opacity-60" }) }) }) }));
|
|
@@ -44,7 +48,8 @@ const components = {
|
|
|
44
48
|
};
|
|
45
49
|
const loadingArray = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
|
|
46
50
|
const SkeletonLoading = _jsx("div", { className: "h-2 w-10/12 animate-pulse rounded bg-table-border" });
|
|
47
|
-
const EmptyContent = (
|
|
51
|
+
const EmptyContent = (props) => (_jsx("div", { className: "flex h-48 w-full items-center justify-center px-2", children: props.loading ? SkeletonLoading : _jsx(Empty, {}) }));
|
|
52
|
+
const EmptyCell = () => _jsx(Fragment, {});
|
|
48
53
|
const ItemContent = (index, row, context) => {
|
|
49
54
|
const cols = context.cols;
|
|
50
55
|
const loading = context.loading;
|
|
@@ -53,11 +58,11 @@ const ItemContent = (index, row, context) => {
|
|
|
53
58
|
const value = path(row, col.id);
|
|
54
59
|
const Component = col.Element;
|
|
55
60
|
const className = col.cellProps?.className || "";
|
|
56
|
-
return (_createElement("td", { ...col.cellProps, role: "cell", "data-matrix": matrix, key: `accessor-${index}-${colIndex}`, className: `hidden h-14 border-l border-table-border px-2 first:table-cell first:border-transparent md:table-cell ${className}` }, loading ? (SkeletonLoading) : Component ? (_jsx(Component, { row: row, matrix: matrix, col: col, rowIndex: index, value: value })) : (_jsx(Fragment, { children: Is.nil(value) ? "" : value }))));
|
|
61
|
+
return (_createElement("td", { ...col.cellProps, role: "cell", "data-matrix": matrix, key: `accessor-${index}-${colIndex}`, className: `relative hidden h-14 border-l border-table-border px-2 first:table-cell first:border-transparent md:table-cell ${className}` }, loading ? (SkeletonLoading) : Component ? (_jsx(Component, { row: row, matrix: matrix, col: col, rowIndex: index, value: value })) : (_jsx(Fragment, { children: Is.nil(value) ? "" : value }))));
|
|
57
62
|
}) }));
|
|
58
63
|
};
|
|
59
64
|
const Frag = () => _jsx(Fragment, {});
|
|
60
|
-
const emptyRows = [
|
|
65
|
+
const emptyRows = [];
|
|
61
66
|
const InnerTable = ({ cols, filters, setCols, sorters, setFilters, setSorters, onScrollEnd, border = false, pagination = null, useControl = false, ...props }) => {
|
|
62
67
|
const ref = useRef(null);
|
|
63
68
|
const [showLoadingFooter, setShowLoadingFooter] = useState(false);
|
|
@@ -75,7 +80,7 @@ const InnerTable = ({ cols, filters, setCols, sorters, setFilters, setSorters, o
|
|
|
75
80
|
if (sorters.length === 0)
|
|
76
81
|
return linq.Select();
|
|
77
82
|
return multiSort(linq.Select(), sorters);
|
|
78
|
-
}, [props.rows, filters, sorters
|
|
83
|
+
}, [props.loading, props.rows, useControl, filters, sorters]);
|
|
79
84
|
useEffect(() => {
|
|
80
85
|
if (ref.current === null)
|
|
81
86
|
return () => { };
|
|
@@ -91,14 +96,16 @@ const InnerTable = ({ cols, filters, setCols, sorters, setFilters, setSorters, o
|
|
|
91
96
|
});
|
|
92
97
|
observer.observe(div);
|
|
93
98
|
return () => observer.disconnect();
|
|
94
|
-
}, []);
|
|
95
|
-
|
|
99
|
+
}, [loadingMoreRef, onScrollEndRef]);
|
|
100
|
+
const empty = rows.length === 0;
|
|
101
|
+
return (_jsxs("div", { className: "min-w-full", children: [_jsxs("div", { className: `group rounded-lg ${border ? "border border-table-border" : ""}`, children: [_jsx(TableVirtuoso, { useWindowScroll: true, followOutput: "smooth", components: components, totalCount: rows.length, data: empty ? emptyRows : rows, itemContent: empty ? EmptyCell : ItemContent, fixedFooterContent: showLoadingFooter ? Frag : null, context: { loading: props.loading, loadingMore: props.loadingMore, cols: cols }, fixedHeaderContent: () => (_jsx(TableHeader, { headers: cols, filters: filters, setCols: setCols, sorters: sorters, setFilters: setFilters, setSorters: setSorters, loading: !!props.loading, inlineFilter: props.inlineFilter, inlineSorter: props.inlineSorter })) }), empty ? _jsx(EmptyContent, { loading: props.loading }) : null, _jsx("div", { "aria-hidden": "true", ref: ref, className: "h-0.5 w-full" })] }), pagination !== null ? _jsx(Pagination, { ...pagination }) : null] }));
|
|
96
102
|
};
|
|
97
103
|
const dispatcherFun = (prev, setter) => typeof setter === "function" ? setter(prev) : setter;
|
|
98
104
|
const compareAndExec = (prev, state, exec) => (prev === state ? undefined : exec?.(state));
|
|
99
105
|
export const Table = (props) => {
|
|
100
106
|
const contextState = useMemo(() => ({ sticky: props.sticky }), [props.sticky]);
|
|
101
|
-
const
|
|
107
|
+
const tweaks = useTweaks();
|
|
108
|
+
const operations = props.operations ?? tweaks.table.operations ?? true;
|
|
102
109
|
const optionCols = useMemo(() => createOptionCols(props.cols), [props.cols]);
|
|
103
110
|
const [state, dispatch] = useReducer({
|
|
104
111
|
cols: props.cols,
|
|
@@ -59,14 +59,14 @@ declare const cols: <T extends POJO>() => <K extends AllPaths<T>>(id: K, thead:
|
|
|
59
59
|
};
|
|
60
60
|
export type Col<T extends POJO> = ReturnType<ReturnType<typeof cols<T>>>;
|
|
61
61
|
export type TablePagination = {
|
|
62
|
-
sizes?: number[];
|
|
63
|
-
onChangeSize?: (size: number) => void;
|
|
64
62
|
size: number;
|
|
65
63
|
pages: number;
|
|
66
64
|
current: number;
|
|
67
65
|
hasNext: boolean;
|
|
66
|
+
sizes?: number[];
|
|
68
67
|
totalItems: number;
|
|
69
68
|
hasPrevious: boolean;
|
|
69
|
+
onChangeSize?: (size: number) => void;
|
|
70
70
|
asLink?: React.FC<React.PropsWithChildren<{
|
|
71
71
|
href: number | "previous" | "next";
|
|
72
72
|
className: string;
|
|
@@ -122,5 +122,6 @@ export declare const useTablePreferences: <T extends POJO>(name: string, cols: C
|
|
|
122
122
|
filters: FilterConfig<T>[];
|
|
123
123
|
pagination: TablePagination | null;
|
|
124
124
|
};
|
|
125
|
+
export declare const useWidthControl: <T extends object>(reorder: (c: Col<T>[]) => void) => readonly [React.RefObject<HTMLTableRowElement | null>, (cols: Col<T>[]) => void];
|
|
125
126
|
export {};
|
|
126
127
|
//# sourceMappingURL=table-lib.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table-lib.d.ts","sourceRoot":"","sources":["../../../../src/components/table/table-lib.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"table-lib.d.ts","sourceRoot":"","sources":["../../../../src/components/table/table-lib.ts"],"names":[],"mappings":"AACA,OAAO,KAA8B,MAAM,OAAO,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAKtC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,eAAO,MAAM,QAAQ,GAAI,CAAC,SAAS,IAAI,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC,sUAAuD,CAAC;AAE5G,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,IAAI,EAAE,CAAC,SAAS,IAAI,GAAG,GAAG,IAAI,CAAC,GAAG;IACvE,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IACf,OAAO,EAAE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,eAAO,MAAM,mBAAmB,GAAI,CAAC,SAAS,IAAI,EAAE,MAAM,MAAM,EAAE,MAAM,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,UAAS,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAQ;;;;;;;;;;;;uEArF1E,KAAK,CAAC,SAAS;;;;;gBAgC/C,eAAe,GAAG,IAAI;CA6ErC,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,CAAC,SAAS,MAAM,EAAE,SAAS,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,IAAI,mEAKjE,GAAG,CAAC,CAAC,CAAC,EAAE,UAYtB,CAAC"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import { useCallback, useRef } from "react";
|
|
2
3
|
import { LocalStorage } from "storage-manager-js";
|
|
3
4
|
import { useReducer } from "use-typed-reducer";
|
|
5
|
+
import { useStableRef } from "../../hooks/use-stable-ref";
|
|
4
6
|
import { isSsr } from "../../lib/fns";
|
|
5
7
|
export const getLabel = (col) => col.headerLabel ?? col.thead ?? col.id;
|
|
6
8
|
export const createOptionCols = (cols) => cols.map((opt) => ({
|
|
@@ -62,3 +64,17 @@ export const useTablePreferences = (name, cols, options = noop) => {
|
|
|
62
64
|
});
|
|
63
65
|
return { ...state, ...dispatch, name };
|
|
64
66
|
};
|
|
67
|
+
export const useWidthControl = (reorder) => {
|
|
68
|
+
const stableRef = useStableRef(reorder);
|
|
69
|
+
const ref = useRef(null);
|
|
70
|
+
const onChange = useCallback((cols) => {
|
|
71
|
+
stableRef.current(cols);
|
|
72
|
+
cols.forEach((x) => {
|
|
73
|
+
const c = ref.current.querySelector(`th[data-colid="${x.id}"]`);
|
|
74
|
+
if (!c)
|
|
75
|
+
return;
|
|
76
|
+
c.style.width = "auto";
|
|
77
|
+
});
|
|
78
|
+
}, [stableRef]);
|
|
79
|
+
return [ref, onChange];
|
|
80
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thead.d.ts","sourceRoot":"","sources":["../../../../src/components/table/thead.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"thead.d.ts","sourceRoot":"","sources":["../../../../src/components/table/thead.tsx"],"names":[],"mappings":"AAUA,OAAO,EAAE,GAAG,EAAY,mBAAmB,EAAmB,MAAM,aAAa,CAAC;AAIlF,KAAK,gBAAgB,CAAC,CAAC,SAAS,MAAM,IAAI;IACtC,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;CACrB,GAAG,IAAI,CAAC,mBAAmB,CAAC,CAAC,CAAC,EAAE,SAAS,GAAG,YAAY,GAAG,SAAS,GAAG,YAAY,GAAG,SAAS,GAAG,cAAc,GAAG,cAAc,CAAC,CAAC;AAmKpI,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,MAAM,EAAE,OAAO,gBAAgB,CAAC,CAAC,CAAC,4CAmCvE,CAAC"}
|
|
@@ -3,19 +3,21 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { AnimatePresence, motion, Reorder } from "motion/react";
|
|
4
4
|
import { Order } from "linq-arrays";
|
|
5
5
|
import { PlusIcon, SearchCheckIcon, SearchXIcon } from "lucide-react";
|
|
6
|
-
import { useCallback, useRef } from "react";
|
|
6
|
+
import { Fragment, useCallback, useRef } from "react";
|
|
7
7
|
import { useTranslations } from "../../hooks/use-translations";
|
|
8
|
+
import { useTweaks } from "../../hooks/use-tweaks";
|
|
8
9
|
import { Dropdown } from "../floating/dropdown";
|
|
9
10
|
import { ColumnHeaderFilter, createFilterFromCol, useOperators } from "./filter";
|
|
10
11
|
import { SorterHead } from "./sort";
|
|
11
|
-
import { getLabel } from "./table-lib";
|
|
12
|
+
import { getLabel, useWidthControl } from "./table-lib";
|
|
12
13
|
const dragConstraints = { top: 0, left: 0, right: 0, bottom: -1 };
|
|
13
14
|
const HeaderChild = (props) => {
|
|
15
|
+
const tweaks = useTweaks();
|
|
14
16
|
const translation = useTranslations();
|
|
15
17
|
const ownFilters = props.filters.filter((x) => x.name === props.header.id);
|
|
16
18
|
const hasFilters = ownFilters.length > 0;
|
|
17
|
-
const defaultAllowSort = props.header.allowSort ?? true;
|
|
18
|
-
const defaultAllowFilter = props.header.allowFilter ?? true;
|
|
19
|
+
const defaultAllowSort = props.header.allowSort ?? tweaks.table.sorters ?? true;
|
|
20
|
+
const defaultAllowFilter = props.header.allowFilter ?? tweaks.table.filters ?? true;
|
|
19
21
|
const operators = useOperators();
|
|
20
22
|
const FilterIcon = hasFilters ? SearchCheckIcon : SearchXIcon;
|
|
21
23
|
const th = useRef(null);
|
|
@@ -40,12 +42,30 @@ const HeaderChild = (props) => {
|
|
|
40
42
|
const ownSorter = props.sorters.find((x) => props.header.id === x.value);
|
|
41
43
|
const ariaSort = !ownSorter?.type ? "none" : ownSorter.type === Order.Asc ? "ascending" : "descending";
|
|
42
44
|
const label = getLabel(props.header);
|
|
43
|
-
return (_jsxs(Reorder.Item, { ...props.header.thProps, as: "th", ref: dragRef, initial: false, dragSnapToOrigin: true, dragDirectionLock: true, role: "columnheader", "aria-sort": ariaSort, value: props.header, "aria-busy": props.loading, whileDrag: { cursor: "grabbing" }, className: `relative hidden min-w-0 cursor-grab border
|
|
45
|
+
return (_jsxs(Reorder.Item, { ...props.header.thProps, as: "th", ref: dragRef, initial: false, dragSnapToOrigin: true, dragDirectionLock: true, role: "columnheader", "aria-sort": ariaSort, value: props.header, "aria-busy": props.loading, "data-colid": props.header.id, whileDrag: { cursor: "grabbing" }, className: `relative hidden min-w-0 cursor-grab border-0 font-medium first:table-cell md:table-cell ${props.header.thProps?.className ?? ""}`, children: [_jsx("span", { className: `flex h-full items-center justify-between bg-table-header px-2 py-4 ${props.isLast ? "rounded-tr-lg" : ""} ${props.index === 0 ? "rounded-tl-lg" : ""}`, children: _jsxs("span", { className: "flex items-center gap-1", children: [props.inlineFilter && defaultAllowFilter ? (_jsx(Dropdown, { arrow: true, trigger: _jsxs("span", { children: [_jsxs("span", { id: `${props.header.id}-filter-dropdown-button`, className: "sr-only", children: [translation.tableFilterDropdownTitleUnique, " ", label] }), _jsx(FilterIcon, { "aria-labelledby": `${props.header.id}-filter-dropdown-button`, size: 14 })] }), title: _jsxs("span", { className: "text-lg", children: [translation.tableFilterDropdownTitleUnique, " ", _jsx("span", { className: "font-medium", children: label })] }), children: _jsxs("ul", { className: "font-medium", children: [ownFilters.length === 0 ? null : (_jsx(Fragment, { children: ownFilters.map((filter) => (_jsx("li", { className: "my-1", children: _jsx(ColumnHeaderFilter, { onDelete: onDelete, filter: filter, set: props.setFilters }) }, `thead-filter-${filter.id}`))) })), _jsx("li", { children: _jsxs("button", { type: "button", className: "flex items-center gap-1 text-primary", onClick: () => props.setFilters((prev) => prev.concat(createFilterFromCol(props.header, operators.options, operators.operations))), children: [_jsx(PlusIcon, { size: 14 }), " ", translation.tableFilterNewFilter] }) })] }) })) : null, _jsx("span", { className: "pointer-events-auto text-balance text-base", children: props.header.thead }), props.inlineSorter && defaultAllowSort ? (_jsx(SorterHead, { col: props.header, setSorters: props.setSorters, sorters: props.sorters })) : null] }) }), props.isLast ? null : (_jsx(motion.button, { drag: "x", draggable: true, dragListener: true, dragMomentum: true, type: "button", animate: false, dragElastic: 0, dragPropagation: true, initial: false, dragSnapToOrigin: true, dragDirectionLock: true, "data-type": "resizer", title: props.header.id, dragConstraints: dragConstraints, className: "absolute -right-[0.5px] top-0 z-calendar block h-full w-[1px] cursor-col-resize bg-table-border hover:w-1.5 hover:bg-primary active:w-1.5 active:bg-primary", onClick: (e) => void e.currentTarget.focus(), onKeyDown: (e) => {
|
|
46
|
+
if (e.key === "ArrowLeft" || e.key === "ArrowRight") {
|
|
47
|
+
if (th.current === null)
|
|
48
|
+
return;
|
|
49
|
+
th.current.setAttribute("data-resized", "true");
|
|
50
|
+
const v = th.current.getBoundingClientRect().width;
|
|
51
|
+
const move = e.shiftKey ? 50 : 10;
|
|
52
|
+
const delta = move * (e.key === "ArrowLeft" ? -1 : 1);
|
|
53
|
+
th.current.style.width = `${Math.abs(v + delta)}px`;
|
|
54
|
+
}
|
|
55
|
+
}, onDoubleClick: () => {
|
|
44
56
|
if (th.current === null)
|
|
45
57
|
return;
|
|
58
|
+
th.current.style.width = "auto";
|
|
59
|
+
}, onDrag: (_, info) => {
|
|
60
|
+
if (th.current === null)
|
|
61
|
+
return;
|
|
62
|
+
th.current.setAttribute("data-resized", "true");
|
|
46
63
|
const v = th.current.getBoundingClientRect().width;
|
|
47
64
|
const delta = info.delta.x;
|
|
48
65
|
th.current.style.width = `${Math.abs(v + delta)}px`;
|
|
49
66
|
} }))] }));
|
|
50
67
|
};
|
|
51
|
-
export const TableHeader = (props) =>
|
|
68
|
+
export const TableHeader = (props) => {
|
|
69
|
+
const [ref, onChange] = useWidthControl(props.setCols);
|
|
70
|
+
return (_jsx(Reorder.Group, { layout: true, as: "tr", axis: "x", drag: "x", layoutRoot: true, role: "row", layoutScroll: true, ref: ref, onReorder: onChange, values: props.headers, className: "text-lg", children: _jsx(AnimatePresence, { children: props.headers.map((header, index) => (_jsx(HeaderChild, { index: index, header: header, filters: props.filters, loading: props.loading, sorters: props.sorters, setFilters: props.setFilters, setSorters: props.setSorters, inlineFilter: props.inlineFilter, inlineSorter: props.inlineSorter, isLast: index === props.headers.length - 1 }, `header-child-item-${header.id}`))) }) }));
|
|
71
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/config/context.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/config/context.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAuB,KAAK,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,EAAiB,KAAK,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE9D,MAAM,MAAM,YAAY,GAAG,OAAO,CAAC;IAC/B,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IACxB,GAAG,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;IAC3B,MAAM,EAAE,OAAO,GAAG,SAAS,CAAC;IAC5B,MAAM,EAAE,OAAO,OAAO,CAAC,IAAI,CAAC;CAC/B,CAAC,CAAC;AAEH,eAAO,MAAM,OAAO;;;;mBAHZ,QAAS,IAAI;GAQnB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default-tweaks.d.ts","sourceRoot":"","sources":["../../../src/config/default-tweaks.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,MAAM,GAAG;IACjB,KAAK,EAAE;QACH,YAAY,EAAE,OAAO,CAAC;KACzB,CAAC;CACL,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"default-tweaks.d.ts","sourceRoot":"","sources":["../../../src/config/default-tweaks.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,MAAM,GAAG;IACjB,KAAK,EAAE;QACH,OAAO,EAAE,OAAO,CAAC;QACjB,OAAO,EAAE,OAAO,CAAC;QACjB,UAAU,EAAE,OAAO,CAAC;KACvB,CAAC;IACF,KAAK,EAAE;QACH,YAAY,EAAE,OAAO,CAAC;KACzB,CAAC;CACL,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,MAG3B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-is-coarse-device.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-is-coarse-device.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,iBAAiB,QAAO,OASpC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useEffect, useRef, useState } from "react";
|
|
2
|
+
import { isSsr } from "../lib/fns";
|
|
3
|
+
const getCoarse = () => window.matchMedia("@media (pointer: coarse)");
|
|
4
|
+
export const useIsCoarseDevice = () => {
|
|
5
|
+
const ref = useRef(isSsr() ? null : getCoarse());
|
|
6
|
+
const [isCoarse, setIsCoarse] = useState(isSsr() ? false : ref.current?.matches ?? false);
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
const coerse = ref.current === null ? getCoarse() : ref.current;
|
|
9
|
+
coerse.addEventListener("change", (e) => setIsCoarse(e.matches));
|
|
10
|
+
}, []);
|
|
11
|
+
return isCoarse;
|
|
12
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-remove-scroll.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-remove-scroll.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-remove-scroll.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-remove-scroll.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,eAAe,GAAI,QAAQ,OAAO,SA4B9C,CAAC"}
|
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
import { useEffect, useRef } from "react";
|
|
2
2
|
import { hasVerticalScroll } from "../lib/dom";
|
|
3
|
-
import { isSsr } from "../lib/fns";
|
|
3
|
+
import { isMobile, isSsr } from "../lib/fns";
|
|
4
|
+
import { useIsCoarseDevice } from "./use-is-coarse-device";
|
|
4
5
|
export const useRemoveScroll = (remove) => {
|
|
6
|
+
const isCoarseDevice = useIsCoarseDevice();
|
|
5
7
|
const prev = useRef(isSsr() ? "" : document.documentElement.style.overflowY);
|
|
6
8
|
useEffect(() => {
|
|
7
9
|
const html = document.documentElement;
|
|
8
10
|
if (remove) {
|
|
9
11
|
prev.current = document.documentElement.style.overflowY;
|
|
10
12
|
html.style.overflowY = "hidden";
|
|
13
|
+
if (isCoarseDevice || isMobile())
|
|
14
|
+
return;
|
|
11
15
|
html.style.padding = hasVerticalScroll(html) ? "0 15px 0 0" : "";
|
|
12
16
|
}
|
|
13
17
|
else {
|
|
14
18
|
html.style.padding = "";
|
|
15
19
|
document.documentElement.style.overflowY = prev.current;
|
|
16
20
|
}
|
|
17
|
-
}, [remove]);
|
|
21
|
+
}, [remove, isCoarseDevice]);
|
|
18
22
|
useEffect(() => {
|
|
19
23
|
if (!remove)
|
|
20
24
|
return;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
type SwipeDirection = "left" | "right";
|
|
3
|
-
export declare function useSwipe(onSwipe: (e: React.TouchEvent,
|
|
3
|
+
export declare function useSwipe(onSwipe: (e: React.TouchEvent, d: SwipeDirection) => void, threshold: number): {
|
|
4
4
|
onTouchStart: (e: React.TouchEvent) => number;
|
|
5
5
|
onTouchEnd: (e: React.TouchEvent) => void;
|
|
6
6
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-swipe.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-swipe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAiB,MAAM,OAAO,CAAC;AAEtC,KAAK,cAAc,GAAG,MAAM,GAAG,OAAO,CAAC;AAEvC,wBAAgB,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"use-swipe.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-swipe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAiB,MAAM,OAAO,CAAC;AAEtC,KAAK,cAAc,GAAG,MAAM,GAAG,OAAO,CAAC;AAEvC,wBAAgB,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,EAAE,CAAC,EAAE,cAAc,KAAK,IAAI,EAAE,SAAS,EAAE,MAAM;sBAGxE,KAAK,CAAC,UAAU;oBAElB,KAAK,CAAC,UAAU;EAU1C"}
|
package/dist/src/lib/dict.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export declare class Dict<K, V> extends Map<K, V> {
|
|
|
3
3
|
constructor(init?: [K, V][] | Dict<K, V>);
|
|
4
4
|
set(key: K, value: V): this;
|
|
5
5
|
remove(key: K): this;
|
|
6
|
-
map(callback: (v: V) => any): any[];
|
|
6
|
+
map(callback: (v: V, i: number) => any): any[];
|
|
7
7
|
clone(fn?: (dict: Dict<K, V>) => Dict<K, V>): Dict<K, V>;
|
|
8
8
|
}
|
|
9
9
|
//# sourceMappingURL=dict.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dict.d.ts","sourceRoot":"","sources":["../../../src/lib/dict.ts"],"names":[],"mappings":"AAAA,qBAAa,IAAI,CAAC,CAAC,EAAE,CAAC,CAAE,SAAQ,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC;IACrC,OAAO,CAAC,IAAI,CAAgB;gBAET,IAAI,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC;IAOxC,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI;IAM3B,MAAM,CAAC,GAAG,EAAE,CAAC;IAMb,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,GAAG;
|
|
1
|
+
{"version":3,"file":"dict.d.ts","sourceRoot":"","sources":["../../../src/lib/dict.ts"],"names":[],"mappings":"AAAA,qBAAa,IAAI,CAAC,CAAC,EAAE,CAAC,CAAE,SAAQ,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC;IACrC,OAAO,CAAC,IAAI,CAAgB;gBAET,IAAI,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC;IAOxC,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI;IAM3B,MAAM,CAAC,GAAG,EAAE,CAAC;IAMb,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,KAAK,GAAG;IAItC,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,EAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,EAAC,CAAC,CAAC;CAKnD"}
|
package/dist/src/lib/dict.js
CHANGED
package/dist/src/lib/fns.d.ts
CHANGED
|
@@ -7,4 +7,5 @@ export declare const safeRegex: (string: string) => string;
|
|
|
7
7
|
export declare const splitInto: <T>(array: T[], size: number) => T[][];
|
|
8
8
|
export declare const negate: (b: boolean) => boolean;
|
|
9
9
|
export declare const noop: () => void;
|
|
10
|
+
export declare const isMobile: () => boolean;
|
|
10
11
|
//# sourceMappingURL=fns.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fns.d.ts","sourceRoot":"","sources":["../../../src/lib/fns.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAI/B,eAAO,MAAM,IAAI,QAAO,MAUvB,CAAC;AAUF,eAAO,MAAM,IAAI,GAAI,CAAC,SAAS,GAAG,EAAE,CAAC,SAAS,QAAQ,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,oBAGzE,CAAC;AAEF,eAAO,MAAM,KAAK,eAAsC,CAAC;AAEzD,eAAO,MAAM,SAAS,GAAI,QAAQ,MAAM,WAAkD,CAAC;AAE3F,eAAO,MAAM,SAAS,GAAI,CAAC,EAAE,OAAO,CAAC,EAAE,EAAE,MAAM,MAAM,UAQpD,CAAC;AAEF,eAAO,MAAM,MAAM,GAAI,GAAG,OAAO,YAAO,CAAC;AAEzC,eAAO,MAAM,IAAI,YAAW,CAAC"}
|
|
1
|
+
{"version":3,"file":"fns.d.ts","sourceRoot":"","sources":["../../../src/lib/fns.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAI/B,eAAO,MAAM,IAAI,QAAO,MAUvB,CAAC;AAUF,eAAO,MAAM,IAAI,GAAI,CAAC,SAAS,GAAG,EAAE,CAAC,SAAS,QAAQ,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,oBAGzE,CAAC;AAEF,eAAO,MAAM,KAAK,eAAsC,CAAC;AAEzD,eAAO,MAAM,SAAS,GAAI,QAAQ,MAAM,WAAkD,CAAC;AAE3F,eAAO,MAAM,SAAS,GAAI,CAAC,EAAE,OAAO,CAAC,EAAE,EAAE,MAAM,MAAM,UAQpD,CAAC;AAEF,eAAO,MAAM,MAAM,GAAI,GAAG,OAAO,YAAO,CAAC;AAEzC,eAAO,MAAM,IAAI,YAAW,CAAC;AAE7B,eAAO,MAAM,QAAQ,eAGpB,CAAA"}
|
package/dist/src/lib/fns.js
CHANGED
|
@@ -33,3 +33,7 @@ export const splitInto = (array, size) => {
|
|
|
33
33
|
};
|
|
34
34
|
export const negate = (b) => !b;
|
|
35
35
|
export const noop = () => { };
|
|
36
|
+
export const isMobile = () => {
|
|
37
|
+
const userAgent = navigator.userAgent || navigator.vendor || window.opera;
|
|
38
|
+
return /android|iphone|ipad|ipod|opera mini|iemobile|wpdesktop/i.test(userAgent);
|
|
39
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ZIndex } from "./theme.types";
|
|
1
2
|
export declare const rounded: {
|
|
2
3
|
readonly button: "0.4rem";
|
|
3
4
|
readonly pill: "2rem";
|
|
@@ -8,10 +9,13 @@ export declare const spacing: {
|
|
|
8
9
|
readonly base: "1rem";
|
|
9
10
|
readonly lg: "1.5rem";
|
|
10
11
|
readonly sm: "0.75rem";
|
|
12
|
+
readonly "field-height": "1.5rem";
|
|
13
|
+
readonly "field-label": "1.875rem";
|
|
11
14
|
readonly "input-height": "2.5rem";
|
|
12
15
|
readonly "input-x": "0.5rem";
|
|
13
16
|
readonly "input-y": "0.25rem";
|
|
14
17
|
readonly "input-inline": "0.25rem";
|
|
15
18
|
readonly "input-gap": "0.3rem";
|
|
16
19
|
};
|
|
20
|
+
export declare const zIndex: ZIndex;
|
|
17
21
|
//# sourceMappingURL=common.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/styles/common.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO;;;;;CAKV,CAAC;AAEX,eAAO,MAAM,OAAO
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/styles/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,eAAO,MAAM,OAAO;;;;;CAKV,CAAC;AAEX,eAAO,MAAM,OAAO;;;;;;;;;;;CAWV,CAAC;AAEX,eAAO,MAAM,MAAM,EAAE,MAOX,CAAC"}
|
|
@@ -8,9 +8,19 @@ export const spacing = {
|
|
|
8
8
|
base: "1rem",
|
|
9
9
|
lg: "1.5rem",
|
|
10
10
|
sm: "0.75rem",
|
|
11
|
+
"field-height": "1.5rem",
|
|
12
|
+
"field-label": "1.875rem",
|
|
11
13
|
"input-height": "2.5rem",
|
|
12
14
|
"input-x": "0.5rem",
|
|
13
15
|
"input-y": "0.25rem",
|
|
14
16
|
"input-inline": "0.25rem",
|
|
15
17
|
"input-gap": "0.3rem",
|
|
16
18
|
};
|
|
19
|
+
export const zIndex = {
|
|
20
|
+
normal: "1",
|
|
21
|
+
navbar: "19",
|
|
22
|
+
calendar: "2",
|
|
23
|
+
overlay: "20",
|
|
24
|
+
tooltip: "13",
|
|
25
|
+
floating: "21",
|
|
26
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dark.d.ts","sourceRoot":"","sources":["../../../src/styles/dark.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,eAAO,MAAM,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"dark.d.ts","sourceRoot":"","sources":["../../../src/styles/dark.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,eAAO,MAAM,UAAU,EAAE,YA0MxB,CAAC"}
|
package/dist/src/styles/dark.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { CSSProperties } from "react";
|
|
2
2
|
import { DesignTokens, DesignTokensBuilder, DesignTokensParser, GeneralTokens, Token } from "./theme.types";
|
|
3
3
|
export declare const parsers: {
|
|
4
|
-
cssVariable: (_: string, __: string, k: string) => `var(--${string})`;
|
|
5
|
-
rgba: (v: string) => `rgba(${string})`;
|
|
6
|
-
rgb: (v: string) => `rgb(${string})`;
|
|
7
|
-
hsl: (v: string) => `hsl(${string})`;
|
|
8
|
-
hsla: (v: string) => `hsla(${string})`;
|
|
9
4
|
hex: (v: string) => string;
|
|
10
5
|
raw: (v: string) => string;
|
|
6
|
+
hsl: (v: string) => `hsl(${string})`;
|
|
7
|
+
rgb: (v: string) => `rgb(${string})`;
|
|
8
|
+
z: (_: string, __: string, k: string) => `var(--z-${string})`;
|
|
9
|
+
hsla: (v: string) => `hsla(${string})`;
|
|
10
|
+
rgba: (v: string) => `rgba(${string})`;
|
|
11
|
+
cssVariable: (_: string, __: string, k: string) => `var(--${string})`;
|
|
11
12
|
formatWithVar: (format: string) => (_: string, __: string, v: string) => `${string}(var(--${string}), <alpha-value>)`;
|
|
12
13
|
};
|
|
13
14
|
export declare const reduceTokens: <T extends GeneralTokens>(colors: T, parse: DesignTokensBuilder, prefix?: string, append?: string) => Token[];
|
|
@@ -16,8 +17,8 @@ export declare const createStyles: {
|
|
|
16
17
|
default: (tokens: Token[]) => string;
|
|
17
18
|
dark: (tokens: Token[]) => string;
|
|
18
19
|
};
|
|
19
|
-
type TokenParsersType = "colors" | "spacing" | "rounded" | "customTokens";
|
|
20
|
-
type TokenCustomParser = (
|
|
20
|
+
type TokenParsersType = "colors" | "spacing" | "rounded" | "customTokens" | "zIndex";
|
|
21
|
+
type TokenCustomParser = (t: Token) => Token;
|
|
21
22
|
export type TokenRemap = Partial<Record<TokenParsersType, TokenCustomParser> & {
|
|
22
23
|
name: string;
|
|
23
24
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"design-tokens.d.ts","sourceRoot":"","sources":["../../../src/styles/design-tokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAE5G,eAAO,MAAM,OAAO
|
|
1
|
+
{"version":3,"file":"design-tokens.d.ts","sourceRoot":"","sources":["../../../src/styles/design-tokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAE5G,eAAO,MAAM,OAAO;aACP,MAAM;aACN,MAAM;aACN,MAAM;aACN,MAAM;;cAEL,MAAM;cACN,MAAM;;4BAEQ,MAAM,SAAS,MAAM,MAAM,MAAM,KAAK,MAAM;CAC1B,CAAC;AAE/C,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,aAAa,EAAE,QAAQ,CAAC,EAAE,OAAO,mBAAmB,EAAE,SAAQ,MAAW,EAAE,SAAQ,MAAW,KAAG,KAAK,EAQnI,CAAC;AAEX,eAAO,MAAM,kBAAkB,GAAI,CAAC,SAAS,aAAa,EAAE,EAAE,SAAS,kBAAkB,EACrF,QAAQ,CAAC,EACT,OAAO,EAAE,EACT,SAAQ,MAAW,EACnB,SAAQ,MAAW,KACpB,CAWY,CAAC;AAmBhB,eAAO,MAAM,YAAY;sBACH,KAAK,EAAE;mBACV,KAAK,EAAE;CACzB,CAAC;AAEF,KAAK,gBAAgB,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,GAAG,cAAc,GAAG,QAAQ,CAAC;AAErF,KAAK,iBAAiB,GAAG,CAAC,CAAC,EAAE,KAAK,KAAK,KAAK,CAAC;AAE7C,MAAM,MAAM,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,gBAAgB,EAAE,iBAAiB,CAAC,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAoBjG,eAAO,MAAM,WAAW,GAAI,OAAO,YAAY,EAAE,OAAO,MAAM,WAIxD,CAAC;AAEP,eAAO,MAAM,mBAAmB,GAAI,OAAO,YAAY,EAAE,MAAM,UAAU,KAAG,aAG3E,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,OAAO,YAAY,EAAE,MAAM,UAAU,WAIjE,CAAC"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
export const parsers = {
|
|
2
|
-
cssVariable: (_, __, k) => `var(--${k})`,
|
|
3
|
-
rgba: (v) => `rgba(${v})`,
|
|
4
|
-
rgb: (v) => `rgb(${v})`,
|
|
5
|
-
hsl: (v) => `hsl(${v})`,
|
|
6
|
-
hsla: (v) => `hsla(${v})`,
|
|
7
2
|
hex: (v) => v,
|
|
8
3
|
raw: (v) => v,
|
|
4
|
+
hsl: (v) => `hsl(${v})`,
|
|
5
|
+
rgb: (v) => `rgb(${v})`,
|
|
6
|
+
z: (_, __, k) => `var(--z-${k})`,
|
|
7
|
+
hsla: (v) => `hsla(${v})`,
|
|
8
|
+
rgba: (v) => `rgba(${v})`,
|
|
9
|
+
cssVariable: (_, __, k) => `var(--${k})`,
|
|
9
10
|
formatWithVar: (format) => (_, __, v) => `${format}(var(--${v}), <alpha-value>)`,
|
|
10
11
|
};
|
|
11
12
|
export const reduceTokens = (colors, parse, prefix = "", append = "") => Object.entries(colors).reduce((acc, [key, value]) => {
|
|
@@ -40,16 +41,18 @@ export const createStyles = {
|
|
|
40
41
|
default: (tokens) => createStyleContent(tokens, { result: modifiers.default }),
|
|
41
42
|
dark: (tokens) => createStyleContent(tokens, { result: modifiers.dark }),
|
|
42
43
|
};
|
|
44
|
+
const fn = (p) => (value, _, key) => {
|
|
45
|
+
const r = { key: `--${key}`, value: `${value}` };
|
|
46
|
+
return p ? p(r) : r;
|
|
47
|
+
};
|
|
48
|
+
const zIndexParser = (t) => ({ key: t.key.replace(/^--/, "--z-"), value: t.value });
|
|
43
49
|
const createTokens = (theme, map) => {
|
|
44
|
-
const fn = (p) => (value, _, key) => {
|
|
45
|
-
const r = { key: `--${key}`, value: `${value}` };
|
|
46
|
-
return p ? p(r) : r;
|
|
47
|
-
};
|
|
48
50
|
const colors = reduceTokens(theme.colors, fn(map?.colors));
|
|
49
51
|
const spacing = reduceTokens(theme.spacing, fn(map?.spacing));
|
|
50
52
|
const rounded = reduceTokens(theme.rounded, fn(map?.rounded));
|
|
53
|
+
const zIndex = reduceTokens(theme.zIndex, fn(map?.zIndex ?? zIndexParser));
|
|
51
54
|
const customTokens = theme.custom ? reduceTokens(theme.custom, fn(map?.customTokens)) : [];
|
|
52
|
-
return colors.concat(spacing, rounded, customTokens);
|
|
55
|
+
return colors.concat(spacing, rounded, customTokens, zIndex);
|
|
53
56
|
};
|
|
54
57
|
export const createTheme = (theme, name) => createStyleContent(createTokens(theme), {
|
|
55
58
|
result: (variables) => `html${name ? `.${name}` : ""} {${variables}}`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"light.d.ts","sourceRoot":"","sources":["../../../src/styles/light.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,eAAO,MAAM,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"light.d.ts","sourceRoot":"","sources":["../../../src/styles/light.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,eAAO,MAAM,WAAW,EAAE,YA0MzB,CAAC"}
|