@g4rcez/components 0.0.61 → 0.0.63
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 +45 -45
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4673 -4655
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +46 -46
- package/dist/index.umd.js.map +1 -1
- package/dist/src/components/display/empty.d.ts +7 -0
- package/dist/src/components/display/empty.d.ts.map +1 -0
- package/dist/src/components/display/empty.js +8 -0
- package/dist/src/components/floating/modal.js +1 -1
- package/dist/src/components/index.d.ts +2 -1
- package/dist/src/components/index.d.ts.map +1 -1
- package/dist/src/components/index.js +2 -1
- package/dist/src/components/table/index.d.ts.map +1 -1
- package/dist/src/components/table/index.js +12 -9
- package/dist/src/hooks/use-components-provider.d.ts +3 -1
- package/dist/src/hooks/use-components-provider.d.ts.map +1 -1
- package/dist/src/hooks/use-components-provider.js +2 -5
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/lib/fns.d.ts.map +1 -1
- package/dist/src/lib/fns.js +12 -5
- package/package.json +1 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type LucideProps } from "lucide-react";
|
|
2
|
+
import React from "react";
|
|
3
|
+
export type EmptyProps = {
|
|
4
|
+
Icon?: React.FC<LucideProps>;
|
|
5
|
+
};
|
|
6
|
+
export declare const Empty: (props: EmptyProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
//# sourceMappingURL=empty.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"empty.d.ts","sourceRoot":"","sources":["../../../../src/components/display/empty.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAY,MAAM,cAAc,CAAC;AAC1D,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,MAAM,MAAM,UAAU,GAAG;IACrB,IAAI,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC;CAChC,CAAC;AAEF,eAAO,MAAM,KAAK,UAAW,UAAU,4CAStC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { FileIcon } from "lucide-react";
|
|
3
|
+
import { useTranslations } from "../../hooks/use-components-provider";
|
|
4
|
+
export const Empty = (props) => {
|
|
5
|
+
const Icon = props.Icon ?? FileIcon;
|
|
6
|
+
const translate = useTranslations();
|
|
7
|
+
return (_jsxs("div", { className: "flex w-full flex-col items-center justify-center gap-4 px-8 py-12", children: [_jsx(Icon, { size: 64, className: "text-disabled" }), _jsx("p", { className: "text-disabled", children: translate.emptyDataMessage })] }));
|
|
8
|
+
};
|
|
@@ -96,5 +96,5 @@ export const Modal = ({ type: _type = "dialog", resizer = true, overlayClickClos
|
|
|
96
96
|
const onClose = () => props.onChange(false);
|
|
97
97
|
return (_jsxs(Fragment, { children: [props.trigger ? (_jsx(Fragment, { children: props.asChild ? (_jsx(Slot, { ref: refs.setReference, ...getReferenceProps({
|
|
98
98
|
layoutId: props.layoutId,
|
|
99
|
-
}), children: Trigger })) : (_jsx(motion.button, { ref: refs.setReference, ...getReferenceProps(), layoutId: props.layoutId, type: "button", children: Trigger })) })) : null, _jsx(FloatingPortal, { children: _jsx(AnimatePresence, { presenceAffectsLayout: true, children: props.open ? (_jsx(FloatingOverlay, { lockScroll: true, className: `inset-0 isolate z-overlay h-[100dvh] !overflow-clip bg-floating-overlay/70 ${type === "drawer" ? "" : "
|
|
99
|
+
}), children: Trigger })) : (_jsx(motion.button, { ref: refs.setReference, ...getReferenceProps(), layoutId: props.layoutId, type: "button", children: Trigger })) })) : null, _jsx(FloatingPortal, { children: _jsx(AnimatePresence, { presenceAffectsLayout: true, children: props.open ? (_jsx(FloatingOverlay, { lockScroll: true, className: `inset-0 isolate z-overlay h-[100dvh] !overflow-clip bg-floating-overlay/70 ${type === "drawer" ? "" : "flex items-start justify-center p-10"}`, children: _jsx(FloatingFocusManager, { visuallyHiddenDismiss: true, modal: true, closeOnFocusOut: true, context: context, children: _jsxs(motion.div, { exit: "exit", animate: "enter", initial: "initial", variants: animation, ref: refs.setFloating, "aria-modal": props.open, layoutId: props.layoutId, "aria-labelledby": headingId, "aria-describedby": descriptionId, className: variants({ position, type }), style: type === "drawer" ? { width: value } : { height: value }, ...getFloatingProps(), children: [props.title ? (_jsx("header", { className: "relative w-full", children: props.title ? (_jsx("h2", { className: "border-b border-floating-border px-8 pb-2 text-3xl font-medium leading-relaxed", children: props.title })) : null })) : null, _jsx("section", { className: "flex-1 overflow-y-auto px-8 py-1", children: props.children }), props.footer ? (_jsx("footer", { className: "w-full border-t border-floating-border px-8 pt-4", children: props.footer })) : null, closable ? (_jsx("nav", { className: "absolute right-4 top-1 z-floating", children: _jsx("button", { type: "button", onClick: onClose, className: "p-1 opacity-70 transition-colors hover:text-danger hover:opacity-100 focus:text-danger", children: _jsx(XIcon, {}) }) })) : null, useResizer && resizer ? (_jsx(Draggable, { onChange: props.onChange, parent: refs.floating, position: position, sheet: type === "sheet", value: value })) : null] }) }) })) : null }) })] }));
|
|
100
100
|
};
|
|
@@ -5,6 +5,7 @@ export * from "./core/tag";
|
|
|
5
5
|
export * from "./display/alert";
|
|
6
6
|
export * from "./display/calendar";
|
|
7
7
|
export * from "./display/card";
|
|
8
|
+
export * from "./display/empty";
|
|
8
9
|
export * from "./display/notifications";
|
|
9
10
|
export * from "./display/stats";
|
|
10
11
|
export * from "./display/tabs";
|
|
@@ -20,12 +21,12 @@ export * from "./form/date-picker";
|
|
|
20
21
|
export * from "./form/file-upload";
|
|
21
22
|
export * from "./form/form";
|
|
22
23
|
export * from "./form/input";
|
|
23
|
-
export * from "./form/textarea";
|
|
24
24
|
export * from "./form/input-field";
|
|
25
25
|
export * from "./form/radiobox";
|
|
26
26
|
export * from "./form/select";
|
|
27
27
|
export * from "./form/switch";
|
|
28
28
|
export * from "./form/task-list";
|
|
29
|
+
export * from "./form/textarea";
|
|
29
30
|
export * from "./form/transfer-list";
|
|
30
31
|
export * from "./table/index";
|
|
31
32
|
export { createColumns, createOptionCols, type ColType, useTablePreferences, type TablePagination } from "./table/table-lib";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,yBAAyB,CAAC;AACxC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC;AACxC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,KAAK,OAAO,EAAE,mBAAmB,EAAE,KAAK,eAAe,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -5,6 +5,7 @@ export * from "./core/tag";
|
|
|
5
5
|
export * from "./display/alert";
|
|
6
6
|
export * from "./display/calendar";
|
|
7
7
|
export * from "./display/card";
|
|
8
|
+
export * from "./display/empty";
|
|
8
9
|
export * from "./display/notifications";
|
|
9
10
|
export * from "./display/stats";
|
|
10
11
|
export * from "./display/tabs";
|
|
@@ -20,12 +21,12 @@ export * from "./form/date-picker";
|
|
|
20
21
|
export * from "./form/file-upload";
|
|
21
22
|
export * from "./form/form";
|
|
22
23
|
export * from "./form/input";
|
|
23
|
-
export * from "./form/textarea";
|
|
24
24
|
export * from "./form/input-field";
|
|
25
25
|
export * from "./form/radiobox";
|
|
26
26
|
export * from "./form/select";
|
|
27
27
|
export * from "./form/switch";
|
|
28
28
|
export * from "./form/task-list";
|
|
29
|
+
export * from "./form/textarea";
|
|
29
30
|
export * from "./form/transfer-list";
|
|
30
31
|
export * from "./table/index";
|
|
31
32
|
export { createColumns, createOptionCols, useTablePreferences } from "./table/table-lib";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/table/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAA2B,cAAc,EAAoD,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/table/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAA2B,cAAc,EAAoD,MAAM,OAAO,CAAC;AAOzH,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,EAAE,IAAI,cAAc,CAAC,gBAAgB,CAAC,GACjE,mBAAmB,CAAC,CAAC,CAAC,GAAG;IACrB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;IACrB,MAAM,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;IACxB,UAAU,EAAE,WAAW,EAAE,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;IACtB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,OAAO,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;IAC5B,SAAS,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAChE,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IACzB,WAAW,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AA0MN,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,EAAE,IAAI,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,aAAa,GAAG,QAAQ,CAAC,GAAG;IAC1G,IAAI,EAAE,MAAM,CAAC;CAChB,GAAG,OAAO,CACH,mBAAmB,CAAC,CAAC,CAAC,GAAG;IACrB,YAAY,EAAE,OAAO,CAAC;IACtB,YAAY,EAAE,OAAO,CAAC;IACtB,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,OAAO,CAAC;CACvB,CACJ,CAAC;AASN,eAAO,MAAM,KAAK,GAAI,CAAC,SAAS,EAAE,SAAS,UAAU,CAAC,CAAC,CAAC,4CA6GvD,CAAC"}
|
|
@@ -8,6 +8,7 @@ import { Is } from "sidekicker";
|
|
|
8
8
|
import { useReducer } from "use-typed-reducer";
|
|
9
9
|
import { useCallbackRef } from "../../hooks/use-callback-ref";
|
|
10
10
|
import { path } from "../../lib/fns";
|
|
11
|
+
import { Empty } from "../display/empty";
|
|
11
12
|
import { Metadata } from "./metadata";
|
|
12
13
|
import { Pagination } from "./pagination";
|
|
13
14
|
import { multiSort } from "./sort";
|
|
@@ -42,6 +43,8 @@ const components = {
|
|
|
42
43
|
TableFoot: TFoot,
|
|
43
44
|
};
|
|
44
45
|
const loadingArray = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
|
|
46
|
+
const SkeletonLoading = _jsx("div", { className: "h-2 w-10/12 animate-pulse rounded bg-table-border" });
|
|
47
|
+
const EmptyContent = (_, __, context) => (_jsx("td", { role: "cell", colSpan: context.cols.length, className: "hidden h-14 border-l border-table-border px-2 first:table-cell first:border-transparent md:table-cell", children: context.loading ? SkeletonLoading : _jsx(Empty, {}) }));
|
|
45
48
|
const ItemContent = (index, row, context) => {
|
|
46
49
|
const cols = context.cols;
|
|
47
50
|
const loading = context.loading;
|
|
@@ -50,11 +53,12 @@ const ItemContent = (index, row, context) => {
|
|
|
50
53
|
const value = path(row, col.id);
|
|
51
54
|
const Component = col.Element;
|
|
52
55
|
const className = col.cellProps?.className || "";
|
|
53
|
-
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 ? (
|
|
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 }))));
|
|
54
57
|
}) }));
|
|
55
58
|
};
|
|
56
59
|
const Frag = () => _jsx(Fragment, {});
|
|
57
|
-
const
|
|
60
|
+
const emptyRows = [{}];
|
|
61
|
+
const InnerTable = ({ cols, filters, setCols, sorters, setFilters, setSorters, onScrollEnd, border = false, pagination = null, useControl = false, ...props }) => {
|
|
58
62
|
const ref = useRef(null);
|
|
59
63
|
const [showLoadingFooter, setShowLoadingFooter] = useState(false);
|
|
60
64
|
const onScrollEndRef = useCallbackRef(onScrollEnd);
|
|
@@ -73,9 +77,8 @@ const InnerTable = ({ filters, pagination = null, onScrollEnd, useControl = fals
|
|
|
73
77
|
return multiSort(linq.Select(), sorters);
|
|
74
78
|
}, [props.rows, filters, sorters, props.loading]);
|
|
75
79
|
useEffect(() => {
|
|
76
|
-
if (ref.current === null)
|
|
80
|
+
if (ref.current === null)
|
|
77
81
|
return () => { };
|
|
78
|
-
}
|
|
79
82
|
const div = ref.current;
|
|
80
83
|
const observer = new IntersectionObserver((entries) => {
|
|
81
84
|
const endOfPage = entries[entries.length - 1];
|
|
@@ -89,7 +92,7 @@ const InnerTable = ({ filters, pagination = null, onScrollEnd, useControl = fals
|
|
|
89
92
|
observer.observe(div);
|
|
90
93
|
return () => observer.disconnect();
|
|
91
94
|
}, []);
|
|
92
|
-
return (_jsxs("div", { className: "min-w-full", children: [_jsxs("div", { className: `group rounded-lg ${border ? "border border-table-border" : ""}`, children: [_jsx(TableVirtuoso, {
|
|
95
|
+
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: rows.length === 0 ? emptyRows : rows, fixedFooterContent: showLoadingFooter ? Frag : null, itemContent: rows.length === 0 ? EmptyContent : ItemContent, 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 })) }), _jsx("div", { "aria-hidden": "true", ref: ref, className: "h-0.5 w-full" })] }), pagination !== null ? _jsx(Pagination, { ...pagination }) : null] }));
|
|
93
96
|
};
|
|
94
97
|
const dispatcherFun = (prev, setter) => typeof setter === "function" ? setter(prev) : setter;
|
|
95
98
|
const compareAndExec = (prev, state, exec) => (prev === state ? undefined : exec?.(state));
|
|
@@ -99,9 +102,9 @@ export const Table = (props) => {
|
|
|
99
102
|
const optionCols = useMemo(() => createOptionCols(props.cols), [props.cols]);
|
|
100
103
|
const [state, dispatch] = useReducer({
|
|
101
104
|
cols: props.cols,
|
|
102
|
-
filters: (props.filters ?? []),
|
|
103
|
-
groups: (props.groups ?? []),
|
|
104
105
|
sorters: (props.sorters ?? []),
|
|
106
|
+
groups: (props.groups ?? []),
|
|
107
|
+
filters: (props.filters ?? []),
|
|
105
108
|
}, (get) => {
|
|
106
109
|
const create = (key) => (arg) => {
|
|
107
110
|
const state = get.state();
|
|
@@ -109,9 +112,9 @@ export const Table = (props) => {
|
|
|
109
112
|
};
|
|
110
113
|
return {
|
|
111
114
|
cols: create("cols"),
|
|
112
|
-
filters: create("filters"),
|
|
113
|
-
groups: create("groups"),
|
|
114
115
|
sorters: create("sorters"),
|
|
116
|
+
groups: create("groups"),
|
|
117
|
+
filters: create("filters"),
|
|
115
118
|
};
|
|
116
119
|
}, {
|
|
117
120
|
postMiddleware: [
|
|
@@ -2,6 +2,7 @@ import React, { PropsWithChildren } from "react";
|
|
|
2
2
|
import { parsers } from "../../preset.tailwind";
|
|
3
3
|
import { Locales } from "the-mask-input";
|
|
4
4
|
declare const defaultTranslations: {
|
|
5
|
+
emptyDataMessage: string;
|
|
5
6
|
inputCaretDown: string;
|
|
6
7
|
datePickerCalendarButtonLabel: string;
|
|
7
8
|
inputOptionalLabel: string;
|
|
@@ -50,7 +51,7 @@ declare const defaultTranslations: {
|
|
|
50
51
|
calendarToDate: string;
|
|
51
52
|
calendarToday: string;
|
|
52
53
|
};
|
|
53
|
-
type Translations = typeof defaultTranslations;
|
|
54
|
+
export type Translations = typeof defaultTranslations;
|
|
54
55
|
type ContextProps = Partial<{
|
|
55
56
|
map: Partial<Translations>;
|
|
56
57
|
locale: Locales | undefined;
|
|
@@ -59,6 +60,7 @@ type ContextProps = Partial<{
|
|
|
59
60
|
export declare const ComponentsProvider: (props: PropsWithChildren<ContextProps>) => import("react/jsx-runtime").JSX.Element;
|
|
60
61
|
export declare const useLocale: () => Locales | undefined;
|
|
61
62
|
export declare const useTranslations: () => {
|
|
63
|
+
emptyDataMessage: string;
|
|
62
64
|
inputCaretDown: string;
|
|
63
65
|
datePickerCalendarButtonLabel: string;
|
|
64
66
|
inputOptionalLabel: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-components-provider.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-components-provider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAA2B,iBAAiB,EAAuB,MAAM,OAAO,CAAC;AAC/F,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEzC,QAAA,MAAM,mBAAmB
|
|
1
|
+
{"version":3,"file":"use-components-provider.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-components-provider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAA2B,iBAAiB,EAAuB,MAAM,OAAO,CAAC;AAC/F,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEzC,QAAA,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wCA+Ce;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,KAAK,CAAC,SAAS,CAAA;KAAE;;;;CASxI,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,OAAO,mBAAmB,CAAC;AAQtD,KAAK,YAAY,GAAG,OAAO,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,kBAAkB,UAAW,iBAAiB,CAAC,YAAY,CAAC,4CAMxE,CAAC;AAEF,eAAO,MAAM,SAAS,QAAO,OAAO,GAAG,SAItC,CAAC;AAEF,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wCAvCY;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,KAAK,CAAC,SAAS,CAAA;KAAE;;;;CA2CxI,CAAC;AAEF,eAAO,MAAM,cAAc,wCAI1B,CAAC"}
|
|
@@ -3,6 +3,7 @@ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
|
3
3
|
import { createContext, Fragment, useContext, useMemo } from "react";
|
|
4
4
|
import { parsers } from "../../preset.tailwind";
|
|
5
5
|
const defaultTranslations = {
|
|
6
|
+
emptyDataMessage: "No data",
|
|
6
7
|
inputCaretDown: "Click to see all options",
|
|
7
8
|
datePickerCalendarButtonLabel: "Click to open a date picker",
|
|
8
9
|
inputOptionalLabel: "Optional",
|
|
@@ -51,11 +52,7 @@ const Context = createContext({
|
|
|
51
52
|
locale: undefined,
|
|
52
53
|
});
|
|
53
54
|
export const ComponentsProvider = (props) => {
|
|
54
|
-
const memoMap = useMemo(() => ({
|
|
55
|
-
locale: props.locale,
|
|
56
|
-
translations: { ...defaultTranslations, ...props.map },
|
|
57
|
-
colorTokenParser: props.parser || parsers.hsla,
|
|
58
|
-
}), [props]);
|
|
55
|
+
const memoMap = useMemo(() => ({ locale: props.locale, translations: { ...defaultTranslations, ...props.map }, colorTokenParser: props.parser || parsers.hsla, }), [props]);
|
|
59
56
|
return _jsx(Context.Provider, { value: memoMap, children: props.children });
|
|
60
57
|
};
|
|
61
58
|
export const useLocale = () => {
|
package/dist/src/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export * from "./components";
|
|
|
2
2
|
export * from "./hooks/use-form";
|
|
3
3
|
export * from "./hooks/use-previous";
|
|
4
4
|
export * from "./hooks/use-reactive";
|
|
5
|
-
export { ComponentsProvider, useTranslations } from "./hooks/use-components-provider";
|
|
5
|
+
export { ComponentsProvider, useTranslations, type Translations, useLocale, useColorParser } from "./hooks/use-components-provider";
|
|
6
6
|
export * from "./lib/dom";
|
|
7
7
|
export * from "./lib/fns";
|
|
8
8
|
export * from "./styles/theme";
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,KAAK,YAAY,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACpI,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC;AACvC,mBAAmB,SAAS,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC"}
|
package/dist/src/index.js
CHANGED
|
@@ -2,7 +2,7 @@ export * from "./components";
|
|
|
2
2
|
export * from "./hooks/use-form";
|
|
3
3
|
export * from "./hooks/use-previous";
|
|
4
4
|
export * from "./hooks/use-reactive";
|
|
5
|
-
export { ComponentsProvider, useTranslations } from "./hooks/use-components-provider";
|
|
5
|
+
export { ComponentsProvider, useTranslations, useLocale, useColorParser } from "./hooks/use-components-provider";
|
|
6
6
|
export * from "./lib/dom";
|
|
7
7
|
export * from "./lib/fns";
|
|
8
8
|
export * from "./styles/theme";
|
|
@@ -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;
|
|
1
|
+
{"version":3,"file":"fns.d.ts","sourceRoot":"","sources":["../../../src/lib/fns.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAI3C,eAAO,MAAM,IAAI,QAAO,MAUvB,CAAC;AAUF,eAAO,MAAM,IAAI,GAAI,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,QAGxE,CAAC;AAEF,eAAO,MAAM,KAAK,eAAsC,CAAC;AAEzD,eAAO,MAAM,SAAS,WAAY,MAAM,WAAkD,CAAC;AAE3F,eAAO,MAAM,SAAS,GAAI,CAAC,yBAAqB,CAAC,EAAE,QAAQ,MAAM,UAQhE,CAAC"}
|
package/dist/src/lib/fns.js
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
const toHex = (n, length = 2) => n.toString(16).padStart(length, "0");
|
|
2
|
+
export const uuid = () => {
|
|
3
|
+
const now = Date.now();
|
|
4
|
+
const timeHigh = ((now / 1000) & 0x0fff) | 0x7000;
|
|
5
|
+
const timeLow = now % 1000;
|
|
6
|
+
const randomBytes = new Uint8Array(10);
|
|
7
|
+
for (let i = 0; i < randomBytes.length; i++) {
|
|
8
|
+
randomBytes[i] = Math.floor(Math.random() * 256);
|
|
9
|
+
}
|
|
10
|
+
randomBytes[0] = (randomBytes[0] & 0x3f) | 0x80;
|
|
11
|
+
return `${toHex(timeHigh, 4) + toHex(timeLow, 3)}-${toHex(randomBytes[0]) + toHex(randomBytes[1])}-${toHex(randomBytes[2]) + toHex(randomBytes[3])}-${toHex(randomBytes[4]) + toHex(randomBytes[5])}-${toHex(randomBytes[6]) + toHex(randomBytes[7]) + toHex(randomBytes[8]) + toHex(randomBytes[9])}`;
|
|
12
|
+
};
|
|
6
13
|
const travel = (path, regexp, obj) => path
|
|
7
14
|
.split(regexp)
|
|
8
15
|
.filter(Boolean)
|