@g4rcez/components 2.0.6 → 2.0.8
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/display/notifications.d.ts +1 -1
- package/dist/components/display/notifications.d.ts.map +1 -1
- package/dist/components/display/notifications.js +15 -13
- package/dist/components/floating/modal.d.ts.map +1 -1
- package/dist/components/floating/modal.js +15 -12
- package/dist/components/form/autocomplete.d.ts.map +1 -1
- package/dist/components/form/autocomplete.js +56 -61
- package/dist/components/table/index.d.ts.map +1 -1
- package/dist/components/table/index.js +3 -3
- package/dist/components/table/row.js +2 -4
- package/dist/components/table/table-lib.d.ts +2 -0
- package/dist/components/table/table-lib.d.ts.map +1 -1
- package/dist/components/table/table-lib.js +5 -2
- package/dist/components/table/thead.js +2 -2
- package/dist/flow/flow.d.ts.map +1 -1
- package/dist/flow/flow.js +10 -8
- package/dist/index.css +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4679 -4693
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +53 -53
- package/dist/index.umd.js.map +1 -1
- package/dist/preset/plugin.tailwind.d.ts +7 -4
- package/dist/preset/plugin.tailwind.d.ts.map +1 -1
- package/dist/preset/plugin.tailwind.js +20 -13
- package/dist/preset/src/styles/common.d.ts +1 -1
- package/dist/preset/src/styles/common.js +1 -1
- package/dist/preset/src/styles/dark.js +2 -2
- package/dist/styles/common.d.ts +1 -1
- package/dist/styles/common.js +1 -1
- package/dist/styles/dark.js +2 -2
- package/package.json +10 -4
|
@@ -2,7 +2,7 @@ import { type VariantProps } from "class-variance-authority";
|
|
|
2
2
|
import { type PropsWithChildren } from "react";
|
|
3
3
|
import { Label } from "../../types";
|
|
4
4
|
declare const variants: (props?: ({
|
|
5
|
-
theme?: "default" | "info" | "warn" | "danger" | "success" | null | undefined;
|
|
5
|
+
theme?: "default" | "info" | "warn" | "muted" | "danger" | "success" | "secondary" | null | undefined;
|
|
6
6
|
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
7
7
|
type NotificationOptions = Partial<{
|
|
8
8
|
title: Label;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notifications.d.ts","sourceRoot":"","sources":["../../../src/components/display/notifications.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"notifications.d.ts","sourceRoot":"","sources":["../../../src/components/display/notifications.tsx"],"names":[],"mappings":"AACA,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAIlE,OAAO,EAAgD,KAAK,iBAAiB,EAAwD,MAAM,OAAO,CAAC;AAEnJ,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,QAAA,MAAM,QAAQ;;mFAgBb,CAAC;AAEF,KAAK,mBAAmB,GAAG,OAAO,CAAC;IAC/B,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,YAAY,CAAC,OAAO,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC;CACjD,CAAC,CAAC;AAEH,KAAK,sBAAsB,GAAG;IAAE,KAAK,EAAE,MAAM,IAAI,CAAC;IAAC,KAAK,EAAE,MAAM,IAAI,CAAA;CAAE,CAAC;AAEvE,KAAK,eAAe,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,mBAAmB,KAAK,sBAAsB,CAAC;AAM3F,eAAO,MAAM,eAAe,uBAAwC,CAAC;AA+DrE,MAAM,MAAM,iBAAiB,GAAG,OAAO,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAE3E,wBAAgB,aAAa,CAAC,EAAE,QAAQ,EAAE,GAAO,EAAE,QAAe,EAAE,EAAE,iBAAiB,CAAC,iBAAiB,CAAC,2CAyDzG"}
|
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { createElement as _createElement } from "react";
|
|
3
3
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
|
-
import { Toast as RadixToast } from "radix-ui";
|
|
5
4
|
import { cva } from "class-variance-authority";
|
|
6
|
-
import { AnimatePresence, motion } from "motion/react";
|
|
7
5
|
import { XIcon } from "lucide-react";
|
|
6
|
+
import { AnimatePresence, motion } from "motion/react";
|
|
7
|
+
import { Toast as RadixToast } from "radix-ui";
|
|
8
8
|
import { createContext, forwardRef, useCallback, useContext, useEffect, useRef, useState } from "react";
|
|
9
9
|
import { useHover } from "../../hooks/use-hover";
|
|
10
|
-
const variants = cva("relative isolate z-tooltip flex justify-between overflow-hidden whitespace-nowrap rounded-lg border text-sm shadow-shadow-notification
|
|
10
|
+
const variants = cva("relative isolate z-tooltip flex justify-between overflow-hidden whitespace-nowrap rounded-lg border text-sm shadow-shadow-notification", {
|
|
11
11
|
variants: {
|
|
12
12
|
theme: {
|
|
13
|
-
warn: "bg-warn-notification/90 text-warn-hover border-warn/50",
|
|
14
|
-
info: "bg-info-notification supports-[backdrop-filter]:bg-info-notification/50 supports-[backdrop-filter]:bg-info/20 text-info border-info/50",
|
|
15
|
-
danger: "bg-danger-notification supports-[backdrop-filter]:bg-danger-notification/60 text-danger border-danger/50",
|
|
16
|
-
success: "bg-success-notification supports-[backdrop-filter]:bg-success-notification/50 text-success border-success/50",
|
|
17
13
|
default: "border-card-border bg-card-background text-foreground",
|
|
14
|
+
info: "bg-alert-info-bg text-alert-info-text border-alert-info-border",
|
|
15
|
+
warn: "bg-alert-warn-bg text-alert-warn-text border-alert-warn-border",
|
|
16
|
+
danger: "bg-alert-danger-bg text-alert-danger-text border-alert-danger-border",
|
|
17
|
+
success: "bg-alert-success-bg text-alert-success-text border-alert-success-border",
|
|
18
|
+
secondary: "bg-alert-secondary-bg text-alert-secondary-text border-alert-secondary-border",
|
|
19
|
+
muted: "bg-alert-muted-bg text-alert-muted-text border-alert-muted-border",
|
|
18
20
|
},
|
|
19
21
|
},
|
|
20
22
|
defaultVariants: { theme: "default" },
|
|
@@ -34,11 +36,11 @@ const Notification = forwardRef(function Toast(props, forwardedRef) {
|
|
|
34
36
|
const duration = props.duration;
|
|
35
37
|
const variant = props.hover ? "hover" : props.isLast ? "isLast" : "other";
|
|
36
38
|
const className = variants({ theme: props.theme || "default" });
|
|
37
|
-
return (_jsx(RadixToast.Root, { ref: forwardedRef, asChild: true, forceMount: true, onOpenChange: props.onClose, duration: duration, children: _jsx(motion.li, { layout: true, layoutScroll: true, animate: variant, "data-index": props.index, initial: { y: -100, zIndex: -1 }, className: "absolute
|
|
39
|
+
return (_jsx(RadixToast.Root, { ref: forwardedRef, asChild: true, forceMount: true, onOpenChange: props.onClose, duration: duration, children: _jsx(motion.li, { layout: true, layoutScroll: true, animate: variant, "data-index": props.index, initial: { y: -100, zIndex: -1 }, className: "text-select pointer-events-auto absolute right-0 top-0 w-80", variants: {
|
|
38
40
|
isLast: { y: 10, scale: 1, animationDuration: "300ms", opacity: 1 },
|
|
39
41
|
hover: { y: 0, position: "static", scale: 1, opacity: 1 },
|
|
40
42
|
other: animatedIndex[props.reversedIndex] || animatedIndex.default,
|
|
41
|
-
}, transition: { type: "spring", mass: 1.2, damping: 30, stiffness: 200 }, exit: { opacity: [0.9, 0], transition: { opacity: { bounce: 0.25, duration: 0.3 } } }, children: _jsxs("div", { className: className, children: [_jsxs("div", { className: "flex flex-col p-4", children: [props.title ? (_jsx(RadixToast.Title, { className: "text-lg font-medium leading-relaxed
|
|
43
|
+
}, transition: { type: "spring", mass: 1.2, damping: 30, stiffness: 200 }, exit: { opacity: [0.9, 0], transition: { opacity: { bounce: 0.25, duration: 0.3 } } }, children: _jsxs("div", { className: className, children: [_jsxs("div", { className: "flex flex-col p-4", children: [props.title ? (_jsx(RadixToast.Title, { className: "select-text truncate text-lg font-medium leading-relaxed", children: props.title })) : null, _jsx(RadixToast.Description, { className: "select-text truncate", children: props.text })] }), closable ? (_jsx(RadixToast.Close, { className: "absolute right-2 top-2 rounded-full p-1 text-foreground transition hover:bg-danger/10 hover:text-danger-hover", children: _jsx(XIcon, { className: "size-5" }) })) : null] }) }) }));
|
|
42
44
|
});
|
|
43
45
|
export function Notifications({ children, max = 5, duration = 5000 }) {
|
|
44
46
|
const ref = useRef(null);
|
|
@@ -59,10 +61,10 @@ export function Notifications({ children, max = 5, duration = 5000 }) {
|
|
|
59
61
|
const close = () => setMessages((prev) => prev.filter((x) => x.id !== id));
|
|
60
62
|
return { clear, close };
|
|
61
63
|
}, [max]);
|
|
62
|
-
return (_jsxs(RadixToast.Provider, { duration: duration, swipeThreshold: 150, children: [_jsx(NotificationContext.Provider, { value: notify, children: children }), _jsx(AnimatePresence, { presenceAffectsLayout: true, mode: "popLayout", children: messages.map((toast, index, list) => {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
return (_jsxs(RadixToast.Provider, { duration: duration, swipeThreshold: 150, children: [_jsx(NotificationContext.Provider, { value: notify, children: children }), _jsx(motion.ol, { children: _jsx(AnimatePresence, { presenceAffectsLayout: true, mode: "popLayout", children: messages.map((toast, index, list) => {
|
|
65
|
+
const close = () => setMessages((prev) => prev.filter((t) => t.id !== toast.id));
|
|
66
|
+
return (_createElement(Notification, { ...toast, hover: hover, index: index, key: toast.id, onClose: close, isLast: list.length - 1 === index, reversedIndex: list.length - (index + 1) }));
|
|
67
|
+
}) }) }), _jsx(RadixToast.Viewport, { ref: ref, "data-items": messages.length, style: {
|
|
66
68
|
justifyContent: "start",
|
|
67
69
|
height: `${(hover ? messages.length : Math.min(1, messages.length)) * 7}rem`,
|
|
68
70
|
}, className: "fixed right-4 top-10 flex w-80 list-none flex-col-reverse items-end gap-4 overflow-y-clip overflow-x-visible data-[items=true]:pb-8 max-sm:top-20" })] }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal.d.ts","sourceRoot":"","sources":["../../../src/components/floating/modal.tsx"],"names":[],"mapp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AAE,QAAQ,GAAG,SAAS,CAAC;IAC3B,YAAY,EAAE,YAAY,EAAE,CAAC;IAC7B,OAAO,EAAE,KAAK,GAAG,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;CAClC,CAAC,CACL,CAAC;AA6EF,KAAK,QAAQ,GAAG;IAAE,OAAO,EAAE,GAAG,CAAC;IAAC,QAAQ,EAAE,WAAW,GAAG,IAAI,CAAA;CAAE,CAAC;AAI/D,eAAO,MAAM,KAAK;WAtGJ,KAAK;gBAAc,MAAM;;UACzB,OAAO;cACH,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI;;YAE9B,KAAK;UACP,SAAS;cACL,OAAO;aACR,OAAO;cACN,MAAM;aACP,OAAO;eACL,MAAM;cACP,OAAO;eACN,OAAO;mBACH,MAAM;sBACH,MAAM;cACd,cAAc;uBACL,OAAO;UACpB,QAAQ,GAAG,SAAS;kBACZ,YAAY,EAAE;aACnB,KAAK,GAAG,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC;;;;eAnBmB,MAAM;YAAU,KAAK;;UAChE,OAAO;cACH,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI;;YAE9B,KAAK;UACP,SAAS;cACL,OAAO;aACR,OAAO;cACN,MAAM;aACP,OAAO;eACL,MAAM;cACP,OAAO;eACN,OAAO;mBACH,MAAM;sBACH,MAAM;cACd,cAAc;uBACL,OAAO;UACpB,QAAQ,GAAG,SAAS;kBACZ,YAAY,EAAE;aACnB,KAAK,GAAG,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC;;;2CAgSrC,CAAC"}
|
|
@@ -30,7 +30,7 @@ const animations = {
|
|
|
30
30
|
},
|
|
31
31
|
dialog: {
|
|
32
32
|
exit: { opacity: 0, scale: 0.95, animationDuration },
|
|
33
|
-
initial: { opacity: 0.5, scale: 0.95, animationDuration, transition: { duration: 0.5, ease:
|
|
33
|
+
initial: { opacity: 0.5, scale: 0.95, animationDuration, transition: { duration: 0.5, ease: "easeInOut" } },
|
|
34
34
|
enter: { opacity: 1, scale: [1.05, 1], animationDuration },
|
|
35
35
|
},
|
|
36
36
|
};
|
|
@@ -50,7 +50,7 @@ const variants = cva("z-floating border border-card-border ring-0 outline-0 appe
|
|
|
50
50
|
defaultVariants: { position: "right", type: "dialog" },
|
|
51
51
|
});
|
|
52
52
|
const dragConstraints = { top: 0, left: 0, right: 0, bottom: 0 };
|
|
53
|
-
const calculateClose = (n) => n * 0.
|
|
53
|
+
const calculateClose = (n) => n * 0.6;
|
|
54
54
|
const Draggable = (props) => {
|
|
55
55
|
const onDrag = (_, info) => {
|
|
56
56
|
if (props.parent.current) {
|
|
@@ -65,18 +65,22 @@ const Draggable = (props) => {
|
|
|
65
65
|
const rect = div.getBoundingClientRect();
|
|
66
66
|
const v = props.value.get() || rect.height;
|
|
67
67
|
const result = Math.abs(v - info.delta.y);
|
|
68
|
-
const
|
|
68
|
+
const max = window.outerHeight;
|
|
69
|
+
const screenHeightToClose = calculateClose(max);
|
|
69
70
|
if (result >= screenHeightToClose)
|
|
70
71
|
return props.value.set(result);
|
|
72
|
+
if (document.activeElement instanceof HTMLElement) {
|
|
73
|
+
document.activeElement?.blur();
|
|
74
|
+
}
|
|
71
75
|
props.onChange(false);
|
|
72
|
-
return setTimeout(() => props.value.set(
|
|
76
|
+
return setTimeout(() => props.value.set(undefined), 350);
|
|
73
77
|
}
|
|
74
78
|
};
|
|
75
79
|
return (_jsx(motion.div, { draggable: true, dragMomentum: true, dragListener: true, dragPropagation: true, onDrag: onDrag, animate: false, initial: false, dragElastic: 0, dragDirectionLock: true, dragSnapToOrigin: true, drag: props.sheet ? "y" : "x", dragConstraints: dragConstraints, whileDrag: { cursor: "grabbing" }, className: css("absolute rounded-lg", props.sheet ? "cursor-row-resize" : "cursor-col-resize bg-floating-border", props.sheet
|
|
76
80
|
? "top-1 flex h-3 w-full justify-center py-2"
|
|
77
81
|
: props.position === "left"
|
|
78
82
|
? "right-5 top-1/2 h-10 w-2"
|
|
79
|
-
: "left-2 top-1/2 h-10 w-2"), children: props.sheet ? _jsx("div", { className: "w-1/4
|
|
83
|
+
: "left-2 top-1/2 h-10 w-2"), children: props.sheet ? _jsx("div", { className: "h-2 w-1/4 rounded-lg bg-floating-border" }) : null }));
|
|
80
84
|
};
|
|
81
85
|
const positions = { drawer: "right", sheet: "none", dialog: "none" };
|
|
82
86
|
const fetchPosition = (isDesktop, forceType, propsType, propsPosition) => {
|
|
@@ -96,12 +100,11 @@ export const Modal = forwardRef(({ open, title, footer, asChild, trigger, childr
|
|
|
96
100
|
const func = isDesktop ? animations[_type] : forceType ? animations[_type] : animations.sheet;
|
|
97
101
|
const animation = typeof func === "function" ? func(position) : func;
|
|
98
102
|
const type = isDesktop ? _type : forceType ? _type : "sheet";
|
|
99
|
-
const floating = useFloating({ open
|
|
100
|
-
const click = useClick(floating.context);
|
|
103
|
+
const floating = useFloating({ open, onOpenChange: onChange });
|
|
104
|
+
const click = useClick(floating.context, {});
|
|
101
105
|
const role = useRole(floating.context, { role: roleName });
|
|
102
106
|
const dismiss = useDismiss(floating.context, {
|
|
103
107
|
escapeKey: true,
|
|
104
|
-
referencePress: true,
|
|
105
108
|
outsidePress: overlayClickClose,
|
|
106
109
|
});
|
|
107
110
|
const interactions = useInteractions([click, role, dismiss].concat(outInteractions));
|
|
@@ -109,7 +112,7 @@ export const Modal = forwardRef(({ open, title, footer, asChild, trigger, childr
|
|
|
109
112
|
const floatingSize = useMotionValue(undefined);
|
|
110
113
|
useEffect(() => {
|
|
111
114
|
floatingSize.set(undefined);
|
|
112
|
-
}, [
|
|
115
|
+
}, [type]);
|
|
113
116
|
const onClose = () => onChange(false);
|
|
114
117
|
useImperativeHandle(externalRef, () => {
|
|
115
118
|
return { context: floating.context, floating: removeScrollRef.current };
|
|
@@ -139,10 +142,10 @@ export const Modal = forwardRef(({ open, title, footer, asChild, trigger, childr
|
|
|
139
142
|
};
|
|
140
143
|
const animationProps = animated && type === "sheet"
|
|
141
144
|
? {
|
|
145
|
+
...commonAnimated,
|
|
142
146
|
dragElastic: 0,
|
|
143
147
|
onDrag: onDrag,
|
|
144
148
|
dragConstraints,
|
|
145
|
-
...commonAnimated,
|
|
146
149
|
dragListener: true,
|
|
147
150
|
dragMomentum: true,
|
|
148
151
|
dragPropagation: true,
|
|
@@ -152,7 +155,7 @@ export const Modal = forwardRef(({ open, title, footer, asChild, trigger, childr
|
|
|
152
155
|
drag: type === "sheet" ? "y" : "x",
|
|
153
156
|
}
|
|
154
157
|
: commonAnimated;
|
|
155
|
-
return (_jsxs(Fragment, { children: [trigger ? (_jsx(Fragment, { children: asChild ? (_jsx(Slot, { ref: floating.refs.setReference, ...interactions.getReferenceProps({ layoutId: layoutId }), children: Trigger })) : (_jsx(motion.button, { ref: floating.refs.setReference, ...interactions.getReferenceProps(), layoutId: layoutId, type: "button", children: Trigger })) })) : null, _jsx(FloatingPortal, { preserveTabOrder: true, children: _jsx(AnimatePresence, {
|
|
158
|
+
return (_jsxs(Fragment, { children: [trigger ? (_jsx(Fragment, { children: asChild ? (_jsx(Slot, { ref: floating.refs.setReference, ...interactions.getReferenceProps({ layoutId: layoutId }), children: Trigger })) : (_jsx(motion.button, { ref: floating.refs.setReference, ...interactions.getReferenceProps(), layoutId: layoutId, type: "button", children: Trigger })) })) : null, _jsx(FloatingPortal, { preserveTabOrder: true, children: _jsx(AnimatePresence, { propagate: true, mode: "wait", initial: false, children: open ? (_jsx(FloatingOverlay, { lockScroll: true, className: css("inset-0 isolate z-overlay h-[100dvh] !overflow-clip bg-floating-overlay/70", type === "drawer" ? "" : "flex items-start justify-center p-10", overlayClassName), children: _jsx(FloatingFocusManager, { guards: true, visuallyHiddenDismiss: true, modal: true, closeOnFocusOut: true, context: floating.context, children: _jsxs(motion.div, { ...props, ...animationProps, ...(title
|
|
156
159
|
? {
|
|
157
160
|
"aria-labelledby": headingId,
|
|
158
161
|
"aria-describedby": descriptionId,
|
|
@@ -164,5 +167,5 @@ export const Modal = forwardRef(({ open, title, footer, asChild, trigger, childr
|
|
|
164
167
|
position,
|
|
165
168
|
type,
|
|
166
169
|
}), className, "overscroll-contain"),
|
|
167
|
-
}), "data-component": "modal", style: type === "drawer" ? { width: floatingSize } : { height: floatingSize }, children: [title ? (_jsx("header", { className: "relative w-full", children: title ? (_jsx("h2", { id: headingId, className: "px-8 pb-2 text-3xl font-medium leading-relaxed
|
|
170
|
+
}), "data-component": "modal", style: type === "drawer" ? { width: floatingSize } : { height: floatingSize }, children: [title ? (_jsx("header", { className: "relative w-full", children: title ? (_jsx("h2", { id: headingId, className: "select-text border-b border-floating-border px-8 pb-2 text-3xl font-medium leading-relaxed", children: title })) : null })) : null, _jsx("section", { "data-component": "modal-body", className: css("flex-1 select-text overflow-y-auto px-8 py-1", bodyClassName), children: children }), footer ? (_jsx("footer", { className: "w-full select-text border-t border-floating-border px-8 pt-4", children: 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: onChange, value: floatingSize, sheet: type === "sheet", position: position, parent: floating.refs.floating })) : null] }) }) })) : null }, headingId) })] }));
|
|
168
171
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"autocomplete.d.ts","sourceRoot":"","sources":["../../../src/components/form/autocomplete.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAoF,MAAM,OAAO,CAAC;AASzG,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAc,eAAe,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"autocomplete.d.ts","sourceRoot":"","sources":["../../../src/components/form/autocomplete.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAoF,MAAM,OAAO,CAAC;AASzG,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAc,eAAe,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C,MAAM,MAAM,qBAAqB,GAAG,WAAW,GAAG;IAAE,MAAM,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAAC,CAAA;CAAE,CAAC;AAErF,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,GAAG;IACtE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,KAAK,CAAC;IACrB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,OAAO,EAAE,qBAAqB,EAAE,CAAC;CACpC,CAAC;AAiCF,eAAO,MAAM,YAAY,yGAsWxB,CAAC"}
|
|
@@ -13,7 +13,6 @@ import { css, dispatchInput, getRemainingSize, initializeInputDataset, mergeRefs
|
|
|
13
13
|
import { safeRegex } from "../../lib/fns";
|
|
14
14
|
import { fzf } from "../../lib/fzf";
|
|
15
15
|
import { InputField } from "./input-field";
|
|
16
|
-
import { useReducer } from "use-typed-reducer";
|
|
17
16
|
const Frag = (props) => _jsx(Fragment, { children: props.children });
|
|
18
17
|
const transitionStyles = {
|
|
19
18
|
duration: 300,
|
|
@@ -34,59 +33,43 @@ export const Autocomplete = forwardRef(({ left, error, right, loading, options,
|
|
|
34
33
|
const scroller = useRef(null);
|
|
35
34
|
const fieldset = useRef(null);
|
|
36
35
|
const virtuoso = useRef(null);
|
|
37
|
-
const defaults =
|
|
36
|
+
const defaults = props.value ?? props.defaultValue ?? "";
|
|
38
37
|
const translation = useTranslations();
|
|
39
|
-
const [state, dispatch] = useReducer({
|
|
40
|
-
open: false,
|
|
41
|
-
shadow: "",
|
|
42
|
-
value: defaults,
|
|
43
|
-
label: options.find((x) => x.value === defaults)?.label ?? defaults,
|
|
44
|
-
index: null
|
|
45
|
-
}, (get) => ({
|
|
46
|
-
open: (open) => ({ open }),
|
|
47
|
-
index: (index) => ({ index }),
|
|
48
|
-
shadow: (shadow) => ({ shadow }),
|
|
49
|
-
option: (value, label) => ({ value, label }),
|
|
50
|
-
select: (value, label, index) => ({ open: false, shadow: "", index, value, label }),
|
|
51
|
-
caretDown: () => ({ open: true, shadow: "" }),
|
|
52
|
-
onClose: () => ({ open: false, label: "", value: "", shadow: "" }),
|
|
53
|
-
onFocus: () => {
|
|
54
|
-
const prev = get.state();
|
|
55
|
-
return { index: prev.index === null ? 0 : prev.index, open: true, shadow: "" };
|
|
56
|
-
}
|
|
57
|
-
}));
|
|
58
38
|
const [h, setH] = useState(() => Math.min(320, MIN_SIZE * options.length));
|
|
39
|
+
const [open, setOpen] = useState(false);
|
|
40
|
+
const [shadow, setShadow] = useState("");
|
|
41
|
+
const [value, setValue] = useState(defaults);
|
|
42
|
+
const [label, setLabel] = useState(() => options.find((x) => x.value === defaults)?.label ?? defaults);
|
|
43
|
+
const [index, setIndex] = useState(null);
|
|
59
44
|
const listRef = useRef(emptyRef);
|
|
60
|
-
const removeScrollRef = useRemoveScroll(
|
|
61
|
-
const innerOptions = dynamicOption &&
|
|
45
|
+
const removeScrollRef = useRemoveScroll(open, "block-only");
|
|
46
|
+
const innerOptions = dynamicOption && shadow !== ""
|
|
62
47
|
? [
|
|
63
48
|
{
|
|
64
|
-
value:
|
|
65
|
-
label:
|
|
49
|
+
value: shadow,
|
|
50
|
+
label: shadow,
|
|
66
51
|
"data-dynamic": "true",
|
|
67
52
|
},
|
|
68
53
|
...options,
|
|
69
54
|
]
|
|
70
55
|
: options;
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
{ key: "label", value: state.shadow },
|
|
75
|
-
])
|
|
56
|
+
const openDropdown = () => flushSync(() => setOpen(true));
|
|
57
|
+
const list = shadow
|
|
58
|
+
? fzf(innerOptions, "value", [{ key: "value", value: shadow }, { key: "label", value: shadow }])
|
|
76
59
|
: innerOptions;
|
|
77
60
|
const setClosed = () => {
|
|
61
|
+
setOpen(false);
|
|
78
62
|
setH(0);
|
|
79
|
-
dispatch.open(false);
|
|
80
63
|
};
|
|
81
64
|
const displayList = list.filter((x) => x.hidden !== true);
|
|
82
65
|
const pattern = dynamicOption
|
|
83
66
|
? undefined
|
|
84
67
|
: `^(${options.map((x) => `${safeRegex(x.value)}${x.label ? "|" + safeRegex(x.label) : ""}`).join("|")})$`;
|
|
85
68
|
const { x, y, strategy, refs, context } = useFloating({
|
|
86
|
-
open
|
|
69
|
+
open,
|
|
87
70
|
transform: true,
|
|
71
|
+
onOpenChange: setOpen,
|
|
88
72
|
placement: "bottom-start",
|
|
89
|
-
onOpenChange: dispatch.open,
|
|
90
73
|
whileElementsMounted: autoUpdate,
|
|
91
74
|
middleware: [
|
|
92
75
|
offset(4),
|
|
@@ -115,20 +98,20 @@ export const Autocomplete = forwardRef(({ left, error, right, loading, options,
|
|
|
115
98
|
loop: true,
|
|
116
99
|
virtual: true,
|
|
117
100
|
allowEscape: true,
|
|
101
|
+
activeIndex: index,
|
|
102
|
+
selectedIndex: index,
|
|
118
103
|
focusItemOnOpen: "auto",
|
|
119
104
|
openOnArrowKeyDown: true,
|
|
120
105
|
scrollItemIntoView: true,
|
|
121
|
-
activeIndex: state.index,
|
|
122
|
-
selectedIndex: state.index,
|
|
123
106
|
}),
|
|
124
107
|
]);
|
|
125
108
|
useEffect(() => {
|
|
126
109
|
if (props.value) {
|
|
127
|
-
if (options.length === 0)
|
|
128
|
-
return dispatch.option("", "");
|
|
129
110
|
const item = options.find((x) => x.value === props.value);
|
|
130
|
-
if (item)
|
|
131
|
-
|
|
111
|
+
if (item) {
|
|
112
|
+
setLabel(item.label ?? item.value);
|
|
113
|
+
setValue(props.value);
|
|
114
|
+
}
|
|
132
115
|
}
|
|
133
116
|
}, [props.value, options.length]);
|
|
134
117
|
useEffect(() => {
|
|
@@ -139,7 +122,7 @@ export const Autocomplete = forwardRef(({ left, error, right, loading, options,
|
|
|
139
122
|
return;
|
|
140
123
|
const s = getRemainingSize(inputRef.current, window.innerHeight);
|
|
141
124
|
setTimeout(() => setH(Math.min(s, displayList.length * MIN_SIZE)), 100);
|
|
142
|
-
}, [
|
|
125
|
+
}, [shadow, open, refs.reference, displayList.length]);
|
|
143
126
|
useEffect(() => {
|
|
144
127
|
const input = refs.reference.current;
|
|
145
128
|
if (!input)
|
|
@@ -147,43 +130,55 @@ export const Autocomplete = forwardRef(({ left, error, right, loading, options,
|
|
|
147
130
|
return initializeInputDataset(input);
|
|
148
131
|
}, []);
|
|
149
132
|
const onSelect = (opt, i) => {
|
|
133
|
+
setValue(opt.value);
|
|
150
134
|
const input = refs.reference.current;
|
|
151
|
-
if (!input)
|
|
152
|
-
return
|
|
153
|
-
}
|
|
135
|
+
if (!input)
|
|
136
|
+
return;
|
|
154
137
|
input?.setAttribute("data-value", opt.value);
|
|
155
138
|
input.value = opt.value;
|
|
156
139
|
const event = new Event("change", { bubbles: false, cancelable: true });
|
|
157
140
|
input.dispatchEvent(event);
|
|
158
141
|
if (props.onChange)
|
|
159
142
|
props.onChange(event);
|
|
160
|
-
|
|
161
|
-
|
|
143
|
+
setLabel(opt.label ?? "");
|
|
144
|
+
setClosed();
|
|
145
|
+
setShadow("");
|
|
146
|
+
setIndex(i);
|
|
162
147
|
};
|
|
163
148
|
const onChange = (event) => {
|
|
164
149
|
const value = event.target.value;
|
|
165
|
-
|
|
150
|
+
setShadow(value);
|
|
166
151
|
if (!open && value === "")
|
|
167
|
-
return
|
|
152
|
+
return setOpen(true);
|
|
168
153
|
event.target.name = props.name || "";
|
|
169
|
-
return value ?
|
|
154
|
+
return value ? setOpen(true) : props.onChange?.(event);
|
|
170
155
|
};
|
|
171
156
|
const onCaretDownClick = () => {
|
|
172
|
-
|
|
157
|
+
openDropdown();
|
|
158
|
+
setShadow("");
|
|
173
159
|
refs.reference.current?.focus();
|
|
174
160
|
};
|
|
161
|
+
const onFocus = () => {
|
|
162
|
+
setIndex((prev) => (prev === null ? 0 : prev));
|
|
163
|
+
openDropdown();
|
|
164
|
+
setShadow("");
|
|
165
|
+
};
|
|
175
166
|
const onClose = () => {
|
|
176
167
|
refs.reference.current?.setAttribute("data-value", "");
|
|
177
|
-
|
|
168
|
+
setShadow("");
|
|
169
|
+
setValue("");
|
|
170
|
+
setLabel("");
|
|
178
171
|
dispatchInput(refs.reference.current);
|
|
172
|
+
setClosed();
|
|
179
173
|
};
|
|
180
174
|
const id = props.id || props.name;
|
|
181
175
|
const shadowId = `${id}-shadow`;
|
|
182
176
|
const isEmpty = displayList.length === 0;
|
|
183
|
-
return (_jsxs(InputField, { ...props, left: left, error: error, ref: fieldset, form: props.form, loading: loading, name: props.name, feedback: feedback, hideLeft: hideLeft, required: required, title: props.title, container: container, rightLabel: rightLabel, interactive: interactive, id: shadowId, optionalText: optionalText, componentName: "autocomplete", labelClassName: labelClassName, placeholder: props.placeholder, right: _jsxs("span", { className: "flex items-center gap-0.5", children: [right, _jsxs("button", { type: "button", className: "p-2 transition-colors link:text-primary md:p-1", onClick: onCaretDownClick, children: [_jsx(ChevronDown, { size: 20 }), _jsx("span", { className: "sr-only", children: translation.inputCaretDown })] }),
|
|
177
|
+
return (_jsxs(InputField, { ...props, left: left, error: error, ref: fieldset, form: props.form, loading: loading, name: props.name, feedback: feedback, hideLeft: hideLeft, required: required, title: props.title, container: container, rightLabel: rightLabel, interactive: interactive, id: shadowId, optionalText: optionalText, componentName: "autocomplete", labelClassName: labelClassName, placeholder: props.placeholder, right: _jsxs("span", { className: "flex items-center gap-0.5", children: [right, _jsxs("button", { type: "button", className: "p-2 transition-colors link:text-primary md:p-1", onClick: onCaretDownClick, children: [_jsx(ChevronDown, { size: 20 }), _jsx("span", { className: "sr-only", children: translation.inputCaretDown })] }), value ? (_jsx("button", { type: "button", onClick: onClose, className: "p-2 transition-colors link:text-danger md:p-1", children: _jsx("svg", { width: "15", height: "15", viewBox: "0 0 15 15", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: _jsx("path", { d: "M11.7816 4.03157C12.0062 3.80702 12.0062 3.44295 11.7816 3.2184C11.5571 2.99385 11.193 2.99385 10.9685 3.2184L7.50005 6.68682L4.03164 3.2184C3.80708 2.99385 3.44301 2.99385 3.21846 3.2184C2.99391 3.44295 2.99391 3.80702 3.21846 4.03157L6.68688 7.49999L3.21846 10.9684C2.99391 11.193 2.99391 11.557 3.21846 11.7816C3.44301 12.0061 3.80708 12.0061 4.03164 11.7816L7.50005 8.31316L10.9685 11.7816C11.193 12.0061 11.5571 12.0061 11.7816 11.7816C12.0062 11.557 12.0062 11.193 11.7816 10.9684L8.31322 7.49999L11.7816 4.03157Z", fill: "currentColor", fillRule: "evenodd", clipRule: "evenodd" }) }) })) : null] }), children: [_jsx("input", { "data-shadow": "true", ...getReferenceProps({
|
|
184
178
|
...props,
|
|
185
|
-
onFocus
|
|
179
|
+
onFocus,
|
|
186
180
|
pattern,
|
|
181
|
+
onChange,
|
|
187
182
|
id: shadowId,
|
|
188
183
|
name: shadowId,
|
|
189
184
|
ref: refs.setReference,
|
|
@@ -196,23 +191,23 @@ export const Autocomplete = forwardRef(({ left, error, right, loading, options,
|
|
|
196
191
|
if (!open)
|
|
197
192
|
return;
|
|
198
193
|
if (event.key === "ArrowDown") {
|
|
199
|
-
let next = Is.number(
|
|
194
|
+
let next = Is.number(index) ? index + 1 : 0;
|
|
200
195
|
if (next > displayList.length - 1)
|
|
201
196
|
next = 0;
|
|
202
197
|
virtuoso.current?.scrollIntoView({ index: next });
|
|
203
|
-
return
|
|
198
|
+
return setIndex(next);
|
|
204
199
|
}
|
|
205
200
|
if (event.key === "ArrowUp") {
|
|
206
|
-
let next = Is.number(
|
|
201
|
+
let next = Is.number(index) ? index - 1 : displayList.length - 1;
|
|
207
202
|
if (next < 0)
|
|
208
203
|
next = displayList.length - 1;
|
|
209
204
|
virtuoso.current?.scrollIntoView({ index: next });
|
|
210
|
-
return
|
|
205
|
+
return setIndex(next);
|
|
211
206
|
}
|
|
212
207
|
if (event.key === "Enter") {
|
|
213
|
-
if (
|
|
208
|
+
if (index !== null && displayList[index]) {
|
|
214
209
|
event.preventDefault();
|
|
215
|
-
return onSelect(displayList[
|
|
210
|
+
return onSelect(displayList[index], index);
|
|
216
211
|
}
|
|
217
212
|
if (displayList.length === 1) {
|
|
218
213
|
event.preventDefault();
|
|
@@ -220,7 +215,7 @@ export const Autocomplete = forwardRef(({ left, error, right, loading, options,
|
|
|
220
215
|
}
|
|
221
216
|
}
|
|
222
217
|
},
|
|
223
|
-
}), "data-
|
|
218
|
+
}), "data-value": value, "data-error": !!error, "data-name": id, "data-target": id, required: required, value: open ? shadow : options.length === 0 ? "" : label || value, "aria-autocomplete": "list", autoComplete: "off", className: css("input placeholder-input-mask group h-input-height w-full flex-1", "rounded-md bg-transparent px-input-x py-input-y text-foreground", "outline-none transition-colors focus:ring-2 focus:ring-inset focus:ring-primary", "group-error:text-danger group-error:placeholder-input-mask-error", "text-base group-focus-within:border-primary group-hover:border-primary", props.className) }), _jsx("input", { id: id, name: id, type: "hidden", "data-origin": id, ref: externalRef, required: required, defaultValue: props.value || value || undefined }), _jsx(FloatingPortal, { preserveTabOrder: true, children: open ? (_jsx(FloatingFocusManager, { modal: true, guards: true, returnFocus: false, context: context, initialFocus: -1, visuallyHiddenDismiss: true, children: _jsxs(motion.div, { ...getFloatingProps({
|
|
224
219
|
ref: mergeRefs(removeScrollRef, refs.setFloating),
|
|
225
220
|
style: { ...transitions.styles, left: x, top: y ?? 0, position: strategy },
|
|
226
221
|
}), initial: false, "data-floating": "true", animate: { height: isEmpty ? "auto" : h }, className: "isolate z-floating m-0 max-h-80 origin-[top_center] list-none overscroll-contain rounded-b-lg rounded-t-lg border border-floating-border bg-floating-background p-0 text-foreground shadow-floating ease-in-out", onAnimationComplete: () => {
|
|
@@ -232,8 +227,8 @@ export const Autocomplete = forwardRef(({ left, error, right, loading, options,
|
|
|
232
227
|
return flushSync(() => setH(sum + 10));
|
|
233
228
|
}, children: [isEmpty ? (_jsx("div", { role: "option", className: "w-full border-b border-tooltip-border", children: _jsx("span", { className: "flex w-full justify-between p-2 text-left text-disabled", children: emptyMessage || translation.autocompleteEmpty }) })) : null, _jsx(Virtuoso, { overscan: 40, ref: virtuoso, hidden: isEmpty, data: displayList, style: { height: h - 10 }, defaultItemHeight: MIN_SIZE, components: components, scrollerRef: (e) => void (scroller.current = e), className: "max-h-[calc(100%-2px)] overscroll-contain rounded-lg border-floating bg-floating-background p-0 text-foreground", itemContent: (i, option) => {
|
|
234
229
|
const Label = option.Render ?? Frag;
|
|
235
|
-
const active =
|
|
236
|
-
const selected =
|
|
230
|
+
const active = value === option.value || value === option.label;
|
|
231
|
+
const selected = index === i;
|
|
237
232
|
const children = option.label ?? option.value;
|
|
238
233
|
return (_jsx("button", { "data-value": option.value, ...getItemProps({
|
|
239
234
|
ref: (node) => void (listRef.current[i] = node),
|
|
@@ -1 +1 @@
|
|
|
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;AAMzH,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;AAIpC,OAAO,EAAa,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,GAAG,EAAoB,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAS3F,KAAK,eAAe,CAAC,CAAC,SAAS,GAAG,IAAI,cAAc,CAAC,gBAAgB,CAAC,GAClE,mBAAmB,CAAC,CAAC,CAAC,GAAG;IACrB,IAAI,EAAE,CA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QAAQ,GAAG,OAAO,CAAC,GAAG;IACrH,IAAI,EAAE,MAAM,CAAC;CAChB,GAAG,OAAO,CACP,mBAAmB,CAAC,CAAC,CAAC,GAAG;IACrB,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;CAChD,CACJ,CAAC;AASF,eAAO,MAAM,KAAK,GAAI,CAAC,SAAS,GAAG,EAAE,OAAO,UAAU,CAAC,CAAC,CAAC,4CA8GxD,CAAC"}
|
|
@@ -21,14 +21,14 @@ const useTable = () => useContext(TableContext);
|
|
|
21
21
|
const TableBody = React.forwardRef(({ context, className = "", ...props }, ref) => {
|
|
22
22
|
return (_jsx("tbody", { ...props, role: "rowgroup", className: `divide-y divide-table-border ${className}`, ref: ref, children: _jsx(AnimatePresence, { children: props.children }) }));
|
|
23
23
|
});
|
|
24
|
-
const VirtualTable = React.forwardRef(({ context, className = "", ...props }, ref) => (_jsx("table", { ...props, ref: ref, role: "table", className: `table min-w-full table-fixed border-separate text-left ${className ?? ""}` })));
|
|
24
|
+
const VirtualTable = React.forwardRef(({ context, className = "", ...props }, ref) => (_jsx("table", { ...props, ref: ref, role: "table", className: `table min-w-full table-fixed border-spacing-0 border-separate text-left ${className ?? ""}` })));
|
|
25
25
|
const Thead = React.forwardRef(({ context, ...props }, ref) => {
|
|
26
26
|
const ctx = useTable();
|
|
27
27
|
const style = {
|
|
28
28
|
...props?.style,
|
|
29
29
|
top: Is.number(ctx.sticky) ? `${ctx.sticky}px` : undefined,
|
|
30
30
|
};
|
|
31
|
-
return (_jsx("thead", { ...props, style: style, role: "rowgroup", className: "hidden top-0 bg-transparent md:table-header-group shadow-shadow-card group:sticky"
|
|
31
|
+
return (_jsx("thead", { ...props, ref: ref, style: style, role: "rowgroup", className: "hidden top-0 bg-transparent md:table-header-group shadow-shadow-card group:sticky" }));
|
|
32
32
|
});
|
|
33
33
|
const TRow = React.forwardRef(({ context, item, ...props }, ref) => {
|
|
34
34
|
return (_jsx("tr", { ...props, role: "row", ref: ref, className: `group-table-row flex h-fit flex-col flex-wrap justify-center gap-1 md:table-row ${props?.className ?? ""}` }));
|
|
@@ -87,7 +87,7 @@ const InnerTable = ({ cols, filters, setCols, sorters, setFilters, setSorters, o
|
|
|
87
87
|
}, [loadingMoreRef, onScrollEndRef]);
|
|
88
88
|
const empty = rows.length === 0;
|
|
89
89
|
const context = { loading: props.loading, loadingMore: props.loadingMore, cols: cols, Aside: props.Aside };
|
|
90
|
-
return (_jsxs("div", { className: "min-w-full", children: [_jsxs("div", { className: `group w-full relative rounded-lg ${border ? "border border-table-border" : ""}`, children: [_jsx(TableVirtuoso, { context: context, components: components, totalCount: rows.length,
|
|
90
|
+
return (_jsxs("div", { className: "min-w-full", children: [_jsxs("div", { className: `group h-full w-full relative rounded-lg ${border ? "border border-table-border" : ""}`, children: [_jsx(TableVirtuoso, { context: context, components: components, totalCount: rows.length, itemContent: empty ? EmptyCell : Row, data: empty ? emptyRows : rows, useWindowScroll: getScrollRef ? false : true, fixedFooterContent: showLoadingFooter ? Frag : null, customScrollParent: getScrollRef ? getScrollRef() : undefined, 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: "w-full h-0.5" })] }), pagination !== null ? _jsx(Pagination, { ...pagination }) : null] }));
|
|
91
91
|
};
|
|
92
92
|
const dispatcherFun = (prev, setter) => typeof setter === "function" ? setter(prev) : setter;
|
|
93
93
|
const compareAndExec = (prev, state, exec) => (prev === state ? undefined : exec?.(state));
|
|
@@ -27,9 +27,7 @@ const RowAside = (props) => {
|
|
|
27
27
|
observer.observe(child);
|
|
28
28
|
return () => observer.disconnect();
|
|
29
29
|
}, []);
|
|
30
|
-
return (_jsx("div", { ref: parentRef, onMouseEnter: onEnter, onMouseLeave: onLeave, "data-component": "cell-aside",
|
|
31
|
-
// inert={ariaHidden ? true : undefined}
|
|
32
|
-
tabIndex: ariaHidden ? -1 : undefined, className: `group-table-cell-aside absolute inset-0 top-0 flex h-full w-full min-w-8 max-w-20 items-stretch transition-opacity duration-300 ease-in-out ${className}`, children: _jsx("div", { ref: ref, className: "isolate block h-full w-auto", children: props.children }) }));
|
|
30
|
+
return (_jsx("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}`, children: _jsx("div", { ref: ref, className: "block isolate", children: props.children }) }));
|
|
33
31
|
};
|
|
34
32
|
export const Row = (index, row, context) => {
|
|
35
33
|
const cols = context.cols;
|
|
@@ -43,7 +41,7 @@ export const Row = (index, row, context) => {
|
|
|
43
41
|
const Aside = context.Aside;
|
|
44
42
|
return (_createElement("td", { ...col.cellProps, role: "cell", "data-matrix": matrix, key: `accessor-${index}-${colIndex}`, className: `group-table-cell py-2 sm:py-2 flex flex-col md:table-cell md:h-14 md:border-l md:border-table-border px-2 first:border-transparent ${className}` },
|
|
45
43
|
exposeAside ? (_jsx(RowAside, { children: _jsx(Aside, { col: col, row: row, rowIndex: index }) })) : null,
|
|
46
|
-
_jsx("span", { className: "block
|
|
44
|
+
_jsx("span", { className: "block text-sm font-bold leading-tight md:hidden", children: col.thead }),
|
|
47
45
|
_jsx("span", { className: "relative", children: loading ? (SkeletonCell) : Component ? (_jsx(Fragment, { children: _jsx(Component, { row: row, matrix: matrix, col: col, rowIndex: index, value: value }) })) : (_jsx(Fragment, { children: Is.nil(value) ? "" : value })) })));
|
|
48
46
|
}) }));
|
|
49
47
|
};
|
|
@@ -48,7 +48,9 @@ type ColOptions<T extends POJO, K extends AllPaths<T>> = Partial<{
|
|
|
48
48
|
cellProps: React.HTMLAttributes<HTMLTableCellElement>;
|
|
49
49
|
}>;
|
|
50
50
|
export type ColConstructor<T extends POJO> = {
|
|
51
|
+
getAll: () => Col<T>[];
|
|
51
52
|
remove: <K extends AllPaths<T>>(id: K) => void;
|
|
53
|
+
filter: (c: (c: Col<T>) => boolean) => Col<T>[];
|
|
52
54
|
add: <K extends AllPaths<T>>(id: K, thead: THead, props?: ColOptions<T, K>) => void;
|
|
53
55
|
};
|
|
54
56
|
declare const cols: <T extends POJO>() => <K extends AllPaths<T>>(id: K, thead: THead, options: ColOptions<T, K>) => {
|
|
@@ -1 +1 @@
|
|
|
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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AClC,SAAS,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IACpC,UAAU,EAAE,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;CAC3C,CAAC;AAEF,MAAM,MAAM,mBAAmB,CAAC,CAAC,SAAS,IAAI,IAAI,kBAAkB,CAChE,CAAC,EACD,YAAY,CAAC,CAAC,CAAC,GACf,YAAY,CAAC,CAAC,CAAC,GAAG;IACd,GAAG,CAAC,EAAE,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;CACtC,GAAG;IACA,YAAY,EAAE,OAAO,CAAC;IACtB,YAAY,EAAE,OAAO,CAAC;CACzB,CACJ,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,CAAC,SAAS,IAAI,EAAE,UAAU,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC,CAAC,KAAK,IAAI;;;;;;;;;;GAQrF,CAAC;AA0BF,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;;;;;;;;;;;;;;;;;gBAvD1G,eAAe,GAAG,IAAI;CA+ErC,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,CAAC,SAAS,MAAM,EAAE,SAAS,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,IAAI,mEAIjE,GAAG,CAAC,CAAC,CAAC,EAAE,UAWtB,CAAC;AAEF,eAAO,MAAM,mBAAmB,+BAAqG,CAAC"}
|
|
@@ -17,12 +17,15 @@ export var ColType;
|
|
|
17
17
|
ColType["Text"] = "text";
|
|
18
18
|
})(ColType || (ColType = {}));
|
|
19
19
|
export const valueFromType = (input) => (input.type === "number" ? input.valueAsNumber : input.value);
|
|
20
|
+
;
|
|
20
21
|
const cols = () => (id, thead, options) => ({ ...options, id, thead });
|
|
21
22
|
export const createColumns = (callback) => {
|
|
22
23
|
let items = [];
|
|
23
24
|
const add = (id, thead, options) => items.push({ ...options, id, thead });
|
|
24
25
|
const remove = (id) => (items = items.filter((x) => x.id !== id));
|
|
25
|
-
|
|
26
|
+
const getAll = () => Array.from(items);
|
|
27
|
+
const filter = (c) => (items = Array.from(items.filter(c)));
|
|
28
|
+
callback({ add, remove, getAll, filter });
|
|
26
29
|
return items;
|
|
27
30
|
};
|
|
28
31
|
const noop = {};
|
|
@@ -70,7 +73,7 @@ export const useWidthControl = (reorder) => {
|
|
|
70
73
|
const onChange = useCallback((cols) => {
|
|
71
74
|
stableRef.current(cols);
|
|
72
75
|
cols.forEach((x) => {
|
|
73
|
-
const c = ref.current.querySelector(`th[data-
|
|
76
|
+
const c = ref.current.querySelector(`th[data-tableheader="${x.id}"]`);
|
|
74
77
|
if (!c)
|
|
75
78
|
return;
|
|
76
79
|
c.style.width = "auto";
|
|
@@ -42,7 +42,7 @@ const HeaderChild = (props) => {
|
|
|
42
42
|
const ownSorter = props.sorters.find((x) => props.header.id === x.value);
|
|
43
43
|
const ariaSort = !ownSorter?.type ? "none" : ownSorter.type === Order.Asc ? "ascending" : "descending";
|
|
44
44
|
const label = getLabel(props.header);
|
|
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-
|
|
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-tableheader": props.header.id, whileDrag: { cursor: "grabbing" }, className: `relative min-w-0 cursor-grab font-medium ${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 gap-1 items-center", 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 gap-1 items-center 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: "text-base pointer-events-auto text-balance", 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: "block absolute top-0 h-full hover:w-1.5 active:w-1.5 -right-[0.5px] z-calendar w-[1px] cursor-col-resize bg-table-border hover:bg-primary active:bg-primary", onClick: (e) => void e.currentTarget.focus(), onKeyDown: (e) => {
|
|
46
46
|
if (e.key === "ArrowLeft" || e.key === "ArrowRight") {
|
|
47
47
|
if (th.current === null)
|
|
48
48
|
return;
|
|
@@ -67,5 +67,5 @@ const HeaderChild = (props) => {
|
|
|
67
67
|
};
|
|
68
68
|
export const TableHeader = (props) => {
|
|
69
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,
|
|
70
|
+
return (_jsx(Reorder.Group, { layout: true, as: "tr", axis: "x", drag: "x", ref: ref, layoutRoot: true, role: "row", layoutScroll: true, onReorder: onChange, values: props.headers, 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
71
|
};
|