@g4rcez/components 0.0.16 → 0.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/core/tag.d.ts.map +1 -1
- package/dist/components/core/tag.js +6 -9
- package/dist/components/display/card.d.ts +7 -2
- package/dist/components/display/card.d.ts.map +1 -1
- package/dist/components/display/card.js +6 -4
- package/dist/components/display/stats.d.ts +10 -0
- package/dist/components/display/stats.d.ts.map +1 -0
- package/dist/components/display/stats.js +5 -0
- package/dist/components/display/tabs.d.ts +14 -0
- package/dist/components/display/tabs.d.ts.map +1 -0
- package/dist/components/display/tabs.js +64 -0
- package/dist/components/floating/dropdown.d.ts.map +1 -1
- package/dist/components/floating/dropdown.js +6 -14
- package/dist/components/floating/modal.d.ts +5 -4
- package/dist/components/floating/modal.d.ts.map +1 -1
- package/dist/components/floating/modal.js +41 -12
- package/dist/components/floating/tooltip.d.ts +1 -1
- package/dist/components/floating/tooltip.d.ts.map +1 -1
- package/dist/components/floating/tooltip.js +3 -3
- package/dist/components/form/checkbox.d.ts +7 -0
- package/dist/components/form/checkbox.d.ts.map +1 -0
- package/dist/components/form/checkbox.js +7 -0
- package/dist/components/form/transfer-list.d.ts +14 -0
- package/dist/components/form/transfer-list.d.ts.map +1 -0
- package/dist/components/form/transfer-list.js +21 -0
- package/dist/components/index.d.ts +5 -1
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +5 -1
- package/dist/components/table/filter.d.ts +2 -1
- package/dist/components/table/filter.d.ts.map +1 -1
- package/dist/components/table/filter.js +5 -5
- package/dist/components/table/group.js +3 -3
- package/dist/components/table/index.d.ts +5 -1
- package/dist/components/table/index.d.ts.map +1 -1
- package/dist/components/table/index.js +54 -16
- package/dist/components/table/metadata.js +1 -1
- package/dist/components/table/sort.d.ts.map +1 -1
- package/dist/components/table/sort.js +5 -4
- package/dist/components/table/table-lib.d.ts +17 -17
- package/dist/components/table/table-lib.d.ts.map +1 -1
- package/dist/components/table/thead.d.ts.map +1 -1
- package/dist/components/table/thead.js +7 -12
- package/dist/hooks/use-callback-ref.d.ts +3 -0
- package/dist/hooks/use-callback-ref.d.ts.map +1 -0
- package/dist/hooks/use-callback-ref.js +8 -0
- package/dist/hooks/use-mutable-state.d.ts +2 -0
- package/dist/hooks/use-mutable-state.d.ts.map +1 -0
- package/dist/hooks/use-mutable-state.js +8 -0
- package/dist/hooks/use-parent.d.ts +3 -0
- package/dist/hooks/use-parent.d.ts.map +1 -0
- package/dist/hooks/use-parent.js +22 -0
- package/dist/index.css +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +12145 -11746
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +39 -34
- package/dist/index.umd.js.map +1 -1
- package/dist/preset/preset.tailwind.d.ts.map +1 -1
- package/dist/preset/preset.tailwind.js +3 -1
- package/dist/preset/src/styles/theme.d.ts.map +1 -1
- package/dist/preset/src/styles/theme.js +16 -21
- package/dist/preset/src/styles/theme.types.d.ts +2 -1
- package/dist/preset/src/styles/theme.types.d.ts.map +1 -1
- package/dist/styles/theme.d.ts.map +1 -1
- package/dist/styles/theme.js +16 -21
- package/dist/styles/theme.types.d.ts +2 -1
- package/dist/styles/theme.types.d.ts.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +3 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tag.d.ts","sourceRoot":"","sources":["../../../src/components/core/tag.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAqB,MAAM,OAAO,CAAC;AAE1C,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAa,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE1D,QAAA,MAAM,WAAW;;;mFAwBhB,CAAC;AAEF,MAAM,MAAM,QAAQ,CAAC,CAAC,SAAS,KAAK,CAAC,WAAW,GAAG,MAAM,IAAI,gBAAgB,CACzE,YAAY,CAAC,OAAO,WAAW,CAAC,GAAG,OAAO,CAAC;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,EAC7E,CAAC,CACJ,CAAC;AAEF,eAAO,MAAM,GAAG,EAAE,CAAC,CAAC,SAAS,KAAK,CAAC,WAAW,GAAG,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,KAAK,
|
|
1
|
+
{"version":3,"file":"tag.d.ts","sourceRoot":"","sources":["../../../src/components/core/tag.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAqB,MAAM,OAAO,CAAC;AAE1C,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAa,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE1D,QAAA,MAAM,WAAW;;;mFAwBhB,CAAC;AAEF,MAAM,MAAM,QAAQ,CAAC,CAAC,SAAS,KAAK,CAAC,WAAW,GAAG,MAAM,IAAI,gBAAgB,CACzE,YAAY,CAAC,OAAO,WAAW,CAAC,GAAG,OAAO,CAAC;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,EAC7E,CAAC,CACJ,CAAC;AAEF,eAAO,MAAM,GAAG,EAAE,CAAC,CAAC,SAAS,KAAK,CAAC,WAAW,GAAG,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,KAAK,GAgBrE,CAAC"}
|
|
@@ -4,13 +4,13 @@ import { cva } from "class-variance-authority";
|
|
|
4
4
|
import { forwardRef } from "react";
|
|
5
5
|
import { css } from "../../lib/dom";
|
|
6
6
|
import { Polymorph } from "./polymorph";
|
|
7
|
-
const tagVariants = cva("inline-flex rounded-pill
|
|
7
|
+
const tagVariants = cva("inline-flex rounded-pill gap-1.5 text-main-foreground border-2 border-transparent items-center justify-center align-middle whitespace-nowrap", {
|
|
8
8
|
variants: {
|
|
9
9
|
size: {
|
|
10
|
-
default: "h-8 px-4 py-2",
|
|
11
|
-
big: "h-12 px-6 py-4",
|
|
12
|
-
small: "h-10 p-2 text-sm",
|
|
13
10
|
icon: "p-1",
|
|
11
|
+
big: "h-12 px-6 py-4",
|
|
12
|
+
default: "h-8 px-4 py-2",
|
|
13
|
+
small: "h-6 p-2 px-3 text-sm",
|
|
14
14
|
},
|
|
15
15
|
theme: {
|
|
16
16
|
raw: "",
|
|
@@ -26,11 +26,8 @@ const tagVariants = cva("inline-flex rounded-pill bg-opacity-90 gap-1.5 text-mai
|
|
|
26
26
|
},
|
|
27
27
|
defaultVariants: { theme: "main", size: "default" },
|
|
28
28
|
});
|
|
29
|
-
export const Tag = forwardRef(function
|
|
29
|
+
export const Tag = forwardRef(function Tag(_a, ref) {
|
|
30
30
|
var _b;
|
|
31
31
|
var { className, icon, loading, theme, size } = _a, props = __rest(_a, ["className", "icon", "loading", "theme", "size"]);
|
|
32
|
-
return (_jsxs(Polymorph, Object.assign({}, props, { ref: ref, "data-theme": theme, as: (_b = props.as) !== null && _b !== void 0 ? _b : "
|
|
33
|
-
size,
|
|
34
|
-
theme: loading ? "loading" : (theme === null || theme === void 0 ? void 0 : theme.disabled) ? "disabled" : theme,
|
|
35
|
-
}), className), children: [props.children, icon] })));
|
|
32
|
+
return (_jsxs(Polymorph, Object.assign({}, props, { ref: ref, "data-theme": theme, as: (_b = props.as) !== null && _b !== void 0 ? _b : "span", className: css(tagVariants({ size, theme }), className), children: [props.children, icon] })));
|
|
36
33
|
});
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import React, { PropsWithChildren } from "react";
|
|
2
|
-
|
|
3
|
-
export
|
|
2
|
+
import { Label, Override } from "../../types";
|
|
3
|
+
export type CardProps = Override<React.ComponentProps<"div">, {
|
|
4
|
+
title?: Label;
|
|
5
|
+
container?: string;
|
|
6
|
+
header?: React.ReactElement | null;
|
|
7
|
+
}>;
|
|
8
|
+
export declare const Card: ({ children, title, container, header, className, ...props }: PropsWithChildren<CardProps>) => import("react/jsx-runtime").JSX.Element;
|
|
4
9
|
//# sourceMappingURL=card.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"card.d.ts","sourceRoot":"","sources":["../../../src/components/display/card.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"card.d.ts","sourceRoot":"","sources":["../../../src/components/display/card.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAEjD,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAG9C,MAAM,MAAM,SAAS,GAAG,QAAQ,CAC5B,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,EAC3B;IACI,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,KAAK,CAAC,YAAY,GAAG,IAAI,CAAC;CACtC,CACJ,CAAC;AAEF,eAAO,MAAM,IAAI,gEAAkF,iBAAiB,CAAC,SAAS,CAAC,4CAS9H,CAAC"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { css } from "../../lib/dom";
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
import { Polymorph } from "../core/polymorph";
|
|
5
|
+
export const Card = (_a) => {
|
|
6
|
+
var { children, title, container = "", header = null, className = "" } = _a, props = __rest(_a, ["children", "title", "container", "header", "className"]);
|
|
7
|
+
return (_jsxs(Polymorph, Object.assign({}, props, { as: "div", className: css("rounded-card flex flex-col gap-4 bg-card-background py-4 pb-8 border-card-border border shadow", container), children: [title ? _jsx("header", { className: "w-full px-8 pb-4 mb-2 border-b border-card-border font-medium text-xl", children: title }) : header, _jsx("div", { className: `min-w-full px-8 ${className}`, children: children })] })));
|
|
6
8
|
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Label } from "../../types";
|
|
3
|
+
export type StatsProps = {
|
|
4
|
+
title: Label;
|
|
5
|
+
Icon: React.FC<any>;
|
|
6
|
+
iconContainer?: string;
|
|
7
|
+
footer?: React.ReactElement;
|
|
8
|
+
};
|
|
9
|
+
export declare const Stats: (props: React.PropsWithChildren<StatsProps>) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
//# sourceMappingURL=stats.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stats.d.ts","sourceRoot":"","sources":["../../../src/components/display/stats.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,MAAM,MAAM,UAAU,GAAG;IACrB,KAAK,EAAE,KAAK,CAAC;IACb,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC;CAC/B,CAAC;AAEF,eAAO,MAAM,KAAK,UAAW,KAAK,CAAC,iBAAiB,CAAC,UAAU,CAAC,4CAmB/D,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { css } from "../../lib/dom";
|
|
3
|
+
export const Stats = (props) => {
|
|
4
|
+
return (_jsxs("div", { className: "divide-y divide-card-border bg-card-background shadow border border-card-border rounded-card", children: [_jsxs("header", { className: "p-6 items-start flex gap-4", children: [_jsx("div", { className: css("size-10 p-8 rounded-card flex items-center justify-center aspect-square bg-primary", props.iconContainer), children: _jsx("div", { children: _jsx(props.Icon, { className: "size-10 aspect-square text-primary-foreground" }) }) }), _jsxs("div", { className: "flex flex-col gap-1", children: [_jsx("header", { children: _jsx("h3", { className: "text-base leading-none", children: props.title }) }), _jsx("p", { className: "text-4xl font-semibold", children: props.children })] })] }), props.footer ? _jsx("footer", { className: "px-6 py-2", children: props.footer }) : null] }));
|
|
5
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { PropsWithChildren } from "react";
|
|
2
|
+
import { Label } from "../../types";
|
|
3
|
+
export type TabsProps = {
|
|
4
|
+
active: string;
|
|
5
|
+
onChange?: (id: string) => void;
|
|
6
|
+
useHash?: boolean;
|
|
7
|
+
};
|
|
8
|
+
export declare const Tabs: (props: PropsWithChildren<TabsProps>) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export type TabProps = {
|
|
10
|
+
id: string;
|
|
11
|
+
title: Label;
|
|
12
|
+
};
|
|
13
|
+
export declare const Tab: (props: PropsWithChildren<TabProps>) => import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
//# sourceMappingURL=tabs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tabs.d.ts","sourceRoot":"","sources":["../../../src/components/display/tabs.tsx"],"names":[],"mappings":"AACA,OAAc,EAA2B,iBAAiB,EAAiC,MAAM,OAAO,CAAC;AAEzG,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAGpC,MAAM,MAAM,SAAS,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAI/F,eAAO,MAAM,IAAI,UAAW,iBAAiB,CAAC,SAAS,CAAC,4CAgGvD,CAAC;AAIF,MAAM,MAAM,QAAQ,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE,CAAC;AAEpD,eAAO,MAAM,GAAG,UAAW,iBAAiB,CAAC,QAAQ,CAAC,4CAGrD,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { motion, useMotionValue } from "framer-motion";
|
|
3
|
+
import React, { createContext, Fragment, useContext, useEffect, useRef } from "react";
|
|
4
|
+
import { useReactive } from "../../hooks/use-reactive";
|
|
5
|
+
import { Card } from "./card";
|
|
6
|
+
const Context = createContext("");
|
|
7
|
+
export const Tabs = (props) => {
|
|
8
|
+
const [active, setActive] = useReactive(props.active);
|
|
9
|
+
const left = useMotionValue(0);
|
|
10
|
+
const width = useMotionValue(0);
|
|
11
|
+
const ref = useRef(null);
|
|
12
|
+
const Render = props.useHash ? "a" : "button";
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
const header = ref.current;
|
|
15
|
+
if (header === null)
|
|
16
|
+
return;
|
|
17
|
+
const resize = (element) => {
|
|
18
|
+
if (!element)
|
|
19
|
+
return;
|
|
20
|
+
const rect = element.getBoundingClientRect();
|
|
21
|
+
width.set(rect.width);
|
|
22
|
+
left.set(element.offsetLeft);
|
|
23
|
+
};
|
|
24
|
+
const listener = () => {
|
|
25
|
+
const element = header.querySelector(`li[data-active=true]`);
|
|
26
|
+
return void resize(element);
|
|
27
|
+
};
|
|
28
|
+
window.addEventListener("resize", listener);
|
|
29
|
+
let first = header.querySelector(`li[data-active=true]`);
|
|
30
|
+
const hash = window.location.hash.replace(/^#/, "");
|
|
31
|
+
if (props.active === "" && hash !== "") {
|
|
32
|
+
first = header.querySelector(`li[data-id=${hash}]`);
|
|
33
|
+
setActive(hash);
|
|
34
|
+
}
|
|
35
|
+
if (first === null) {
|
|
36
|
+
first = header.querySelector(`li[data-id]`);
|
|
37
|
+
const id = first.getAttribute("data-id") || "";
|
|
38
|
+
setActive(id);
|
|
39
|
+
}
|
|
40
|
+
resize(first);
|
|
41
|
+
return () => window.removeEventListener("resize", listener);
|
|
42
|
+
}, []);
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
if (props.onChange)
|
|
45
|
+
props.onChange(active);
|
|
46
|
+
}, [props.onChange, active]);
|
|
47
|
+
const items = React.Children.toArray(props.children);
|
|
48
|
+
const onClick = (e) => {
|
|
49
|
+
const anchor = e.currentTarget;
|
|
50
|
+
const rect = anchor.getBoundingClientRect();
|
|
51
|
+
width.set(rect.width);
|
|
52
|
+
left.set(anchor.offsetLeft);
|
|
53
|
+
setActive(anchor.dataset.id || "");
|
|
54
|
+
};
|
|
55
|
+
return (_jsx(Context.Provider, { value: active, children: _jsx(Card, { container: "pt-0", header: _jsxs("header", { ref: ref, className: "border-b border-card-border relative mb-2", children: [_jsx(motion.div, { layout: true, initial: false, "aria-hidden": "true", style: { left, width }, transition: { type: "tween", left, width }, className: "w-28 h-0.5 bg-primary absolute bottom-0 duration-300 transition-all hidden md:block" }), _jsx("nav", { children: _jsx("ul", { className: "divide-x divide-card-border overflow-x-auto flex justify-between md:justify-start", children: items.map((x) => {
|
|
56
|
+
const inner = x.props;
|
|
57
|
+
return (_jsx("li", { "data-id": inner.id, "data-active": active === inner.id, className: "data-[active=true]:text-primary w-full md:w-auto", children: _jsx(Render, { "data-id": inner.id, onClick: onClick, "aria-current": "page", className: "px-10 py-4 block font-medium w-full whitespace-nowrap", href: props.useHash ? `#${inner.id}` : undefined, children: inner.title }) }, `tab-header-${inner.id}`));
|
|
58
|
+
}) }) })] }), children: props.children }) }));
|
|
59
|
+
};
|
|
60
|
+
const useTabs = () => useContext(Context);
|
|
61
|
+
export const Tab = (props) => {
|
|
62
|
+
const active = useTabs();
|
|
63
|
+
return _jsx(Fragment, { children: props.id === active ? props.children : null });
|
|
64
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dropdown.d.ts","sourceRoot":"","sources":["../../../src/components/floating/dropdown.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"dropdown.d.ts","sourceRoot":"","sources":["../../../src/components/floating/dropdown.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,EAAmB,iBAAiB,EAA6B,MAAM,OAAO,CAAC;AAE7F,KAAK,aAAa,GAAG;IACjB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;IACxC,OAAO,EAAE,KAAK,CAAC,YAAY,GAAG,KAAK,CAAC,SAAS,CAAC;IAC9C,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC,YAAY,GAAG,MAAM,CAAC;CACzD,CAAC;AAEF,eAAO,MAAM,QAAQ,UAAW,iBAAiB,CAAC,aAAa,CAAC,4CA4D/D,CAAC"}
|
|
@@ -1,23 +1,16 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { arrow, autoUpdate, flip, FloatingArrow, FloatingFocusManager, offset, shift, useClick, useDismiss, useFloating,
|
|
3
|
-
import { Fragment, useMemo, useRef, useState } from "react";
|
|
2
|
+
import { arrow, autoUpdate, flip, FloatingArrow, FloatingFocusManager, FloatingPortal, offset, shift, useClick, useDismiss, useFloating, useInteractions, useRole, } from "@floating-ui/react";
|
|
3
|
+
import { Fragment, useId, useMemo, useRef, useState } from "react";
|
|
4
4
|
export const Dropdown = (props) => {
|
|
5
|
+
const headingId = useId();
|
|
5
6
|
const [open, setOpen] = useState(props.open);
|
|
6
7
|
const arrowRef = useRef(null);
|
|
7
|
-
const middleware = useMemo(() => [
|
|
8
|
-
offset(10),
|
|
9
|
-
flip({ fallbackAxisSideDirection: "end" }),
|
|
10
|
-
shift(),
|
|
11
|
-
arrow({
|
|
12
|
-
padding: 5,
|
|
13
|
-
element: arrowRef,
|
|
14
|
-
}),
|
|
15
|
-
], [props.arrow]);
|
|
8
|
+
const middleware = useMemo(() => [offset(10), flip({ fallbackAxisSideDirection: "end" }), shift(), arrow({ padding: 5, element: arrowRef })], [props.arrow]);
|
|
16
9
|
const { refs, floatingStyles, context } = useFloating({
|
|
17
10
|
open,
|
|
11
|
+
middleware,
|
|
18
12
|
transform: true,
|
|
19
13
|
whileElementsMounted: autoUpdate,
|
|
20
|
-
middleware,
|
|
21
14
|
onOpenChange: (nextValue, event) => {
|
|
22
15
|
var _a;
|
|
23
16
|
const element = event === null || event === void 0 ? void 0 : event.relatedTarget;
|
|
@@ -33,6 +26,5 @@ export const Dropdown = (props) => {
|
|
|
33
26
|
const dismiss = useDismiss(context);
|
|
34
27
|
const role = useRole(context);
|
|
35
28
|
const { getReferenceProps, getFloatingProps } = useInteractions([click, dismiss, role]);
|
|
36
|
-
|
|
37
|
-
return (_jsxs(Fragment, { children: [_jsx("button", Object.assign({ ref: refs.setReference }, getReferenceProps(), { children: props.trigger })), open && (_jsx(FloatingFocusManager, { returnFocus: true, visuallyHiddenDismiss: true, restoreFocus: true, context: context, modal: false, children: _jsxs("div", Object.assign({ className: "bg-floating-background isolate z-floating border shadow-2xl p-6 border-floating-border rounded-lg", ref: refs.setFloating, style: floatingStyles, "aria-labelledby": headingId }, getFloatingProps(), { children: [_jsx(FloatingArrow, { ref: arrowRef, context: context, strokeWidth: 0.1, className: "fill-floating-background stroke-floating-border" }), _jsx("header", { className: "mb-2", children: _jsx("h3", { className: "leading-snug font-medium text-2xl tracking-tight text-left", children: props.title }) }), props.children] })) }))] }));
|
|
29
|
+
return (_jsxs(Fragment, { children: [_jsx("button", Object.assign({ ref: refs.setReference }, getReferenceProps(), { type: "button", children: props.trigger })), open && (_jsx(FloatingPortal, { id: `${headingId}-portal`, children: _jsx(FloatingFocusManager, { returnFocus: true, visuallyHiddenDismiss: true, restoreFocus: true, context: context, modal: false, children: _jsxs("div", Object.assign({ className: "bg-floating-background relative min-w-96 isolate z-floating border shadow-2xl p-6 border-floating-border rounded-lg", ref: refs.setFloating, style: floatingStyles, "aria-labelledby": headingId }, getFloatingProps(), { children: [_jsx(FloatingArrow, { ref: arrowRef, context: context, strokeWidth: 0.1, className: "fill-floating-background stroke-floating-border" }), _jsx("header", { className: "mb-2", children: _jsx("h3", { className: "leading-snug font-medium text-2xl tracking-tight text-left", children: props.title }) }), props.children] })) }) }))] }));
|
|
38
30
|
};
|
|
@@ -2,13 +2,14 @@ import React, { PropsWithChildren } from "react";
|
|
|
2
2
|
import { Label } from "../../types";
|
|
3
3
|
export type DrawerProps = {
|
|
4
4
|
title?: Label;
|
|
5
|
-
footer?: Label;
|
|
6
5
|
open: boolean;
|
|
6
|
+
footer?: Label;
|
|
7
|
+
resizer?: boolean;
|
|
7
8
|
asChild?: boolean;
|
|
8
|
-
trigger: Label | React.FC<any>;
|
|
9
|
-
onChange: (nextState: boolean) => void;
|
|
10
9
|
type?: "dialog" | "drawer";
|
|
11
10
|
position?: "left" | "right";
|
|
11
|
+
trigger: Label | React.FC<any>;
|
|
12
|
+
onChange: (nextState: boolean) => void;
|
|
12
13
|
};
|
|
13
|
-
export declare const Modal: (props: PropsWithChildren<DrawerProps>) => import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export declare const Modal: ({ type, resizer, ...props }: PropsWithChildren<DrawerProps>) => import("react/jsx-runtime").JSX.Element;
|
|
14
15
|
//# sourceMappingURL=modal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal.d.ts","sourceRoot":"","sources":["../../../src/components/floating/modal.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,EAAY,iBAAiB,
|
|
1
|
+
{"version":3,"file":"modal.d.ts","sourceRoot":"","sources":["../../../src/components/floating/modal.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,EAAY,iBAAiB,EAAS,MAAM,OAAO,CAAC;AAClE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AA6CpC,MAAM,MAAM,WAAW,GAAG;IACtB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,CAAC,EAAE,KAAK,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC3B,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC5B,OAAO,EAAE,KAAK,GAAG,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;IAC/B,QAAQ,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;CAC1C,CAAC;AAiCF,eAAO,MAAM,KAAK,gCAAmD,iBAAiB,CAAC,WAAW,CAAC,4CA+DlG,CAAC"}
|
|
@@ -1,14 +1,31 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import { __rest } from "tslib";
|
|
2
3
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { FloatingFocusManager, FloatingOverlay, FloatingPortal, useClick, useDismiss, useFloating,
|
|
4
|
+
import { FloatingFocusManager, FloatingOverlay, FloatingPortal, useClick, useDismiss, useFloating, useInteractions, useRole, } from "@floating-ui/react";
|
|
4
5
|
import { Slot } from "@radix-ui/react-slot";
|
|
5
6
|
import { cva } from "class-variance-authority";
|
|
6
|
-
import {
|
|
7
|
-
|
|
7
|
+
import { AnimatePresence, motion, useMotionValue } from "framer-motion";
|
|
8
|
+
import { Fragment, useId } from "react";
|
|
9
|
+
const createDrawerAnimation = (side) => ({
|
|
10
|
+
initial: { [side]: "-60%", opacity: 0.8 },
|
|
11
|
+
enter: { [side]: 0, opacity: 1 },
|
|
12
|
+
exit: { [side]: "-60%", opacity: 0.8 },
|
|
13
|
+
});
|
|
14
|
+
const drawerLeft = createDrawerAnimation("left");
|
|
15
|
+
const drawerRight = createDrawerAnimation("right");
|
|
16
|
+
const animations = {
|
|
17
|
+
drawer: (type) => (type === "left" ? drawerLeft : drawerRight),
|
|
18
|
+
dialog: {
|
|
19
|
+
initial: { opacity: 0, scale: 0.9 },
|
|
20
|
+
enter: { opacity: 1, scale: [1.125, 1] },
|
|
21
|
+
exit: { opacity: 0, scale: 0.9 },
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
const variants = cva("isolate ring-0 outline-0 appearance-none container flex flex-col gap-4 flex-nowrap min-w-xs bg-floating-background", {
|
|
8
25
|
variants: {
|
|
9
26
|
type: {
|
|
10
27
|
drawer: "max-h-screen h-screen min-h-0",
|
|
11
|
-
dialog: "max-h-[calc(100lvh-
|
|
28
|
+
dialog: "max-h-[calc(100lvh-10%)] h-[inherit] relative rounded-lg py-8",
|
|
12
29
|
},
|
|
13
30
|
position: {
|
|
14
31
|
none: "",
|
|
@@ -18,19 +35,31 @@ const variants = cva("ring-0 outline-0 appearance-none container flex flex-col g
|
|
|
18
35
|
},
|
|
19
36
|
defaultVariants: { position: "right", type: "dialog" },
|
|
20
37
|
});
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const
|
|
38
|
+
const dragConstraints = { top: 0, left: 0, right: 0, bottom: 0 };
|
|
39
|
+
const Draggable = (props) => {
|
|
40
|
+
const handleDrag = (_, info) => {
|
|
41
|
+
if (props.parent.current) {
|
|
42
|
+
const div = props.parent.current;
|
|
43
|
+
const v = props.value.get() || div.getBoundingClientRect().width;
|
|
44
|
+
const delta = props.type === "right" ? -info.delta.x : info.delta.x;
|
|
45
|
+
props.value.set(Math.abs(v + delta));
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
return (_jsx(motion.div, { drag: "x", dragElastic: 0, dragMomentum: false, onDrag: handleDrag, dragConstraints: dragConstraints, whileDrag: { cursor: "grabbing" }, className: `absolute top-1/2 ${props.type === "left" ? "right-5" : "left-2"} rounded-lg cursor-grab h-10 w-2 bg-floating-border` }));
|
|
49
|
+
};
|
|
50
|
+
export const Modal = (_a) => {
|
|
51
|
+
var { type = "dialog", resizer = true } = _a, props = __rest(_a, ["type", "resizer"]);
|
|
52
|
+
const isDialog = type === "dialog";
|
|
53
|
+
const position = isDialog ? "none" : props.position || "left";
|
|
54
|
+
const animation = isDialog ? animations.dialog : animations.drawer(position);
|
|
24
55
|
const headingId = useId();
|
|
25
56
|
const descriptionId = useId();
|
|
26
|
-
const { refs, context } = useFloating({
|
|
27
|
-
open: props.open,
|
|
28
|
-
onOpenChange: props.onChange,
|
|
29
|
-
});
|
|
57
|
+
const { refs, context } = useFloating({ open: props.open, onOpenChange: props.onChange });
|
|
30
58
|
const click = useClick(context);
|
|
31
59
|
const role = useRole(context);
|
|
32
60
|
const dismiss = useDismiss(context, { escapeKey: true, referencePress: true, outsidePress: false });
|
|
33
61
|
const { getReferenceProps, getFloatingProps } = useInteractions([click, role, dismiss]);
|
|
34
62
|
const Trigger = props.trigger;
|
|
35
|
-
|
|
63
|
+
const value = useMotionValue(undefined);
|
|
64
|
+
return (_jsxs(Fragment, { children: [props.asChild ? (_jsx(Slot, Object.assign({ ref: refs.setReference }, getReferenceProps(), { children: Trigger }))) : (_jsx("button", Object.assign({ ref: refs.setReference }, getReferenceProps(), { type: "button", children: Trigger }))), _jsx(FloatingPortal, { children: _jsx(AnimatePresence, { presenceAffectsLayout: true, children: props.open && (_jsx(FloatingOverlay, { lockScroll: true, className: `relative !overflow-clip h-[100dvh] z-floating bg-floating-overlay/70 ${type === "drawer" ? "" : "grid items-baseline p-8"}`, children: _jsx(FloatingFocusManager, { modal: true, closeOnFocusOut: true, context: context, children: _jsxs(motion.div, Object.assign({ animate: "enter", "aria-describedby": descriptionId, "aria-labelledby": headingId, className: variants({ position, type }), exit: "exit", initial: "initial", ref: refs.setFloating, variants: animation, style: { width: value } }, getFloatingProps(), { children: [!isDialog && resizer ? _jsx(Draggable, { value: value, parent: refs.floating, type: position }) : null, props.title ? (_jsx("header", { className: "w-full", children: _jsx("h2", { className: "px-8 pb-4 border-b border-floating-border text-3xl font-medium leading-relaxed", children: props.title }) })) : null, _jsx("div", { className: "flex-1 px-8 overflow-y-auto", children: props.children }), props.footer ? (_jsx("footer", { className: "px-8 border-t border-floating-border pt-4 w-full", children: props.footer })) : null] })) }) })) }) })] }));
|
|
36
65
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { PolymorphicProps } from "../../components/core/polymorph";
|
|
3
3
|
import { Label, Override } from "../../types";
|
|
4
|
-
type TooltipProps = Override<PolymorphicProps<React.ComponentProps<"button">, "
|
|
4
|
+
type TooltipProps = Override<PolymorphicProps<React.ComponentProps<"button">, "span">, {
|
|
5
5
|
title: Label;
|
|
6
6
|
}>;
|
|
7
7
|
export declare const Tooltip: ({ children, as, title, ...props }: TooltipProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tooltip.d.ts","sourceRoot":"","sources":["../../../src/components/floating/tooltip.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAqC,MAAM,OAAO,CAAC;AAC1D,OAAO,EAAa,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAC9E,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE9C,KAAK,YAAY,GAAG,QAAQ,CAAC,gBAAgB,CAAC,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,
|
|
1
|
+
{"version":3,"file":"tooltip.d.ts","sourceRoot":"","sources":["../../../src/components/floating/tooltip.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAqC,MAAM,OAAO,CAAC;AAC1D,OAAO,EAAa,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAC9E,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE9C,KAAK,YAAY,GAAG,QAAQ,CAAC,gBAAgB,CAAC,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,EAAE;IAAE,KAAK,EAAE,KAAK,CAAA;CAAE,CAAC,CAAC;AAEzG,eAAO,MAAM,OAAO,sCAAuC,YAAY,4CA6CtE,CAAC"}
|
|
@@ -7,7 +7,7 @@ export const Tooltip = (_a) => {
|
|
|
7
7
|
var { children, as, title } = _a, props = __rest(_a, ["children", "as", "title"]);
|
|
8
8
|
const [isOpen, setIsOpen] = useState(false);
|
|
9
9
|
const arrowRef = useRef(null);
|
|
10
|
-
const Component = as || "
|
|
10
|
+
const Component = as || "span";
|
|
11
11
|
const { refs, floatingStyles, context } = useFloating({
|
|
12
12
|
open: isOpen,
|
|
13
13
|
onOpenChange: setIsOpen,
|
|
@@ -23,10 +23,10 @@ export const Tooltip = (_a) => {
|
|
|
23
23
|
}),
|
|
24
24
|
],
|
|
25
25
|
});
|
|
26
|
-
const hover = useHover(context, { move:
|
|
26
|
+
const hover = useHover(context, { move: true });
|
|
27
27
|
const focus = useFocus(context);
|
|
28
28
|
const dismiss = useDismiss(context);
|
|
29
29
|
const role = useRole(context, { role: "tooltip" });
|
|
30
30
|
const { getReferenceProps, getFloatingProps } = useInteractions([hover, focus, dismiss, role]);
|
|
31
|
-
return (_jsxs(Fragment, { children: [_jsx(Component, Object.assign({ ref: refs.setReference }, getReferenceProps(props), { children: title })), _jsx(FloatingPortal, { children: isOpen && (_jsxs(Polymorph, Object.assign({ ref: refs.setFloating, style: floatingStyles
|
|
31
|
+
return (_jsxs(Fragment, { children: [_jsx(Component, Object.assign({ ref: refs.setReference }, getReferenceProps(props), { children: title })), _jsx(FloatingPortal, { children: isOpen && (_jsxs(Polymorph, Object.assign({}, getFloatingProps(), { ref: refs.setFloating, style: floatingStyles, className: "bg-tooltip-background text-tooltip-foreground border border-tooltip-border p-3 rounded-lg", children: [_jsx(FloatingArrow, { ref: arrowRef, context: context, strokeWidth: 0.1, className: "fill-tooltip-background stroke-tooltip-border" }), children] }))) })] }));
|
|
32
32
|
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Override } from "../../types";
|
|
3
|
+
export type CheckboxProps = Override<React.PropsWithChildren<React.ComponentProps<"input">>, {
|
|
4
|
+
size?: "medium" | "large";
|
|
5
|
+
}>;
|
|
6
|
+
export declare const Checkbox: ({ children, className, size, ...props }: CheckboxProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
//# sourceMappingURL=checkbox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkbox.d.ts","sourceRoot":"","sources":["../../../src/components/form/checkbox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,MAAM,MAAM,aAAa,GAAG,QAAQ,CAChC,KAAK,CAAC,iBAAiB,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,EACtD;IACI,IAAI,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC;CAC7B,CACJ,CAAC;AAEF,eAAO,MAAM,QAAQ,4CAAkD,aAAa,4CAanF,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { css } from "../../lib/dom";
|
|
4
|
+
export const Checkbox = (_a) => {
|
|
5
|
+
var { children, className = "", size } = _a, props = __rest(_a, ["children", "className", "size"]);
|
|
6
|
+
return (_jsxs("label", { className: "font-normal flex items-center gap-2", children: [_jsx("input", Object.assign({}, props, { type: "checkbox", className: css("form-checkbox h-4 w-4 app rounded border-card-border text-primary focus:ring-primary appearance-none inline-block bg-origin-border select-none", className) }, props)), children] }));
|
|
7
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { POJO, SetState } from "../../types";
|
|
3
|
+
export type TransferListProps<T> = {
|
|
4
|
+
source: T[];
|
|
5
|
+
target: T[];
|
|
6
|
+
Item: React.FC<{
|
|
7
|
+
data: T;
|
|
8
|
+
}>;
|
|
9
|
+
reference: keyof T;
|
|
10
|
+
setSource: SetState<T[]>;
|
|
11
|
+
setTarget: SetState<T[]>;
|
|
12
|
+
};
|
|
13
|
+
export declare const TransferList: <T extends POJO, K extends keyof T>(props: TransferListProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
//# sourceMappingURL=transfer-list.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transfer-list.d.ts","sourceRoot":"","sources":["../../../src/components/form/transfer-list.tsx"],"names":[],"mappings":"AACA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAG5D,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAK7C,MAAM,MAAM,iBAAiB,CAAC,CAAC,IAAI;IAC/B,MAAM,EAAE,CAAC,EAAE,CAAC;IACZ,MAAM,EAAE,CAAC,EAAE,CAAC;IACZ,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC;QAAE,IAAI,EAAE,CAAC,CAAA;KAAE,CAAC,CAAC;IAC5B,SAAS,EAAE,MAAM,CAAC,CAAC;IACnB,SAAS,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC;IACzB,SAAS,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC;CAC5B,CAAC;AAWF,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,IAAI,EAAE,CAAC,SAAS,MAAM,CAAC,SAAS,iBAAiB,CAAC,CAAC,CAAC,4CAgC1F,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ChevronRightIcon } from "lucide-react";
|
|
3
|
+
import { forwardRef, Fragment, useRef } from "react";
|
|
4
|
+
import { Virtuoso } from "react-virtuoso";
|
|
5
|
+
import { useParentHeight } from "../../hooks/use-parent";
|
|
6
|
+
import { Button } from "../core/button";
|
|
7
|
+
import { Checkbox } from "../form/checkbox";
|
|
8
|
+
import { Input } from "./input";
|
|
9
|
+
const components = {
|
|
10
|
+
Item: forwardRef(function InnerList(props, ref) {
|
|
11
|
+
return _jsx("li", Object.assign({}, props, { ref: ref, className: "flex items-center gap-1 justify-between" }));
|
|
12
|
+
}),
|
|
13
|
+
List: forwardRef(function InnerList(props, ref) {
|
|
14
|
+
return _jsx("ul", Object.assign({}, props, { ref: ref, className: "space-y-3" }));
|
|
15
|
+
}),
|
|
16
|
+
};
|
|
17
|
+
export const TransferList = (props) => {
|
|
18
|
+
const ref = useRef(null);
|
|
19
|
+
const h = useParentHeight(ref);
|
|
20
|
+
return (_jsxs("div", { className: "flex flex-row gap-4", ref: ref, children: [_jsxs("div", { className: "py-8 space-y-4 min-w-64 w-fit flex flex-col whitespace-nowrap rounded-lg border border-card-border", children: [_jsx("header", { className: "border-b border-card-border pb-2" }), _jsxs("div", { className: "px-8 space-y-2", children: [_jsx(Input, { rightLabel: "", title: "Search", placeholder: "Looking for..." }), _jsx(Virtuoso, { height: h, useWindowScroll: true, data: props.source, components: components, itemContent: (_, row) => (_jsx(Fragment, { children: _jsx(Checkbox, { children: _jsx(props.Item, { data: row }) }) })) })] })] }), _jsx("div", { children: _jsx(Button, { children: _jsx(ChevronRightIcon, {}) }) }), _jsx("div", {})] }));
|
|
21
|
+
};
|
|
@@ -6,13 +6,17 @@ export * from "./form/form";
|
|
|
6
6
|
export * from "./form/select";
|
|
7
7
|
export * from "./form/switch";
|
|
8
8
|
export * from "./form/input-field";
|
|
9
|
+
export * from "./form/transfer-list";
|
|
10
|
+
export * from "./form/checkbox";
|
|
9
11
|
export * from "./core/button";
|
|
10
12
|
export * from "./core/polymorph";
|
|
11
13
|
export * from "./core/tag";
|
|
12
14
|
export * from "./display/card";
|
|
15
|
+
export * from "./display/stats";
|
|
16
|
+
export * from "./display/tabs";
|
|
13
17
|
export * from "./floating/dropdown";
|
|
14
18
|
export * from "./floating/tooltip";
|
|
15
19
|
export * from "./floating/modal";
|
|
16
20
|
export * from "./table/index";
|
|
17
|
-
export { createColumns, createOptionCols, useTablePreferences } from "./table/table-lib";
|
|
21
|
+
export { createColumns, createOptionCols, ColType, useTablePreferences } from "./table/table-lib";
|
|
18
22
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/components/index.js
CHANGED
|
@@ -6,12 +6,16 @@ export * from "./form/form";
|
|
|
6
6
|
export * from "./form/select";
|
|
7
7
|
export * from "./form/switch";
|
|
8
8
|
export * from "./form/input-field";
|
|
9
|
+
export * from "./form/transfer-list";
|
|
10
|
+
export * from "./form/checkbox";
|
|
9
11
|
export * from "./core/button";
|
|
10
12
|
export * from "./core/polymorph";
|
|
11
13
|
export * from "./core/tag";
|
|
12
14
|
export * from "./display/card";
|
|
15
|
+
export * from "./display/stats";
|
|
16
|
+
export * from "./display/tabs";
|
|
13
17
|
export * from "./floating/dropdown";
|
|
14
18
|
export * from "./floating/tooltip";
|
|
15
19
|
export * from "./floating/modal";
|
|
16
20
|
export * from "./table/index";
|
|
17
|
-
export { createColumns, createOptionCols, useTablePreferences } from "./table/table-lib";
|
|
21
|
+
export { createColumns, createOptionCols, ColType, useTablePreferences } from "./table/table-lib";
|
|
@@ -64,8 +64,9 @@ export declare const createFilterFromCol: <T extends {}>(f: Col<T>, rest?: Parti
|
|
|
64
64
|
export declare const Filter: <T extends {}>(props: Props<T>) => import("react/jsx-runtime").JSX.Element;
|
|
65
65
|
type ColumnHeaderFilterProps<T extends {}> = {
|
|
66
66
|
filter: FilterConfig<T>;
|
|
67
|
+
onDelete: (e: React.MouseEvent<HTMLButtonElement>) => void;
|
|
67
68
|
set: React.Dispatch<React.SetStateAction<FilterConfig<T>[]>>;
|
|
68
69
|
};
|
|
69
|
-
export declare const ColumnHeaderFilter: <T extends {}>({ filter, set }: ColumnHeaderFilterProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
70
|
+
export declare const ColumnHeaderFilter: <T extends {}>({ filter, onDelete, set }: ColumnHeaderFilterProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
70
71
|
export {};
|
|
71
72
|
//# sourceMappingURL=filter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../../../src/components/table/filter.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAmB,MAAM,OAAO,CAAC;AACxC,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,KAAmB,MAAM,OAAO,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAIpC,OAAO,EAAE,GAAG,EAAE,OAAO,EAAY,kBAAkB,EAAiB,MAAM,aAAa,CAAC;AAExF,QAAA,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAS8C,CAAC;AAE9D,KAAK,QAAQ,GAAG,MAAM,OAAO,SAAS,CAAC;AAEvC,KAAK,SAAS,GAAG,CAAC,OAAO,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC;AAQ9C,KAAK,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,OAAO,CAAC;AAExD,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,EAAE,GAAG,EAAE,IAAI;IAC1C,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,KAAK,CAAC;IACb,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;IAClB,IAAI,EAAE,OAAO,CAAC;IACd,SAAS,EAAE,SAAS,CAAC;IACrB,KAAK,EAAE,WAAW,CAAC;CACtB,CAAC;AAEF,KAAK,KAAK,CAAC,CAAC,SAAS,EAAE,IAAI,kBAAkB,CACzC,CAAC,EACD;IACI,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IACf,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;IAC3B,GAAG,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;CAChE,CACJ,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,CAAC,SAAS,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC,SAAQ,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,KAAQ,YAAY,CAAC,CAAC,CAMhH,CAAC;AAEF,eAAO,MAAM,MAAM,GAAI,CAAC,SAAS,EAAE,SAAS,KAAK,CAAC,CAAC,CAAC,4CA6FnD,CAAC;AAEF,KAAK,uBAAuB,CAAC,CAAC,SAAS,EAAE,IAAI;IACzC,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,EAAE,6BAA6B,uBAAuB,CAAC,CAAC,CAAC,4CAmCrG,CAAC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { PlusIcon, SearchIcon, Trash2Icon } from "lucide-react";
|
|
3
3
|
import { Fragment } from "react";
|
|
4
|
+
import { uuid } from "../../lib/fns";
|
|
4
5
|
import { Dropdown } from "../floating/dropdown";
|
|
5
6
|
import { Input } from "../form/input";
|
|
6
7
|
import { Select } from "../form/select";
|
|
7
|
-
import { uuid } from "../../lib/fns";
|
|
8
8
|
import { ColType, getLabel, valueFromType } from "./table-lib";
|
|
9
9
|
const operators = {
|
|
10
10
|
contains: { value: "contains", label: "Contains", symbol: "includes" },
|
|
@@ -60,10 +60,10 @@ export const Filter = (props) => {
|
|
|
60
60
|
};
|
|
61
61
|
return (_jsx(Fragment, { children: _jsx(Dropdown, { arrow: false, title: "Filters", trigger: _jsxs("span", { className: "flex items-center gap-1 proportional-nums", children: [_jsx(SearchIcon, { size: 14 }), "Filtros ", props.filters.length === 0 ? "" : ` (${props.filters.length})`] }), children: _jsxs("ul", { className: "mt-4 space-y-2", children: [props.filters.map((filter) => {
|
|
62
62
|
const operators = operatorOptions[filter.type];
|
|
63
|
-
return (_jsxs("li", { className: "flex flex-nowrap gap-3", children: [_jsx(Select, { title: "
|
|
64
|
-
}), _jsx("li", { children: _jsxs("button", { type: "button", onClick: onAddFilter, className: "text-primary flex items-center gap-1", children: [_jsx(PlusIcon, { size: 14 }), "
|
|
63
|
+
return (_jsxs("li", { className: "flex flex-nowrap gap-3", children: [_jsx(Select, { title: "Filter", options: props.options, placeholder: "Name...", value: filter.name, "data-id": filter.id, onChange: onSelectProperty }), _jsx(Select, { title: "Filter type", "data-id": filter.id, onChange: onSelectOperation, value: filter.operation.value, options: operators, placeholder: "Operator..." }), _jsx(Input, { "data-id": filter.id, onChange: onChangeValue, placeholder: "Search...", title: "Value", type: filter.type, value: filter.value }), _jsx("div", { className: "flex items-center justify-center mt-5", children: _jsx("button", { "data-id": filter.id, type: "button", onClick: onDelete, children: _jsx(Trash2Icon, { className: "text-danger", size: 16 }) }) })] }, `filter-select-${filter.id}`));
|
|
64
|
+
}), _jsx("li", { children: _jsxs("button", { type: "button", onClick: onAddFilter, className: "text-primary flex items-center gap-1", children: [_jsx(PlusIcon, { size: 14 }), " New filter"] }) })] }) }) }));
|
|
65
65
|
};
|
|
66
|
-
export const ColumnHeaderFilter = ({ filter, set }) => {
|
|
66
|
+
export const ColumnHeaderFilter = ({ filter, onDelete, set }) => {
|
|
67
67
|
const onSelectOperation = (e) => {
|
|
68
68
|
const operator = e.target.value;
|
|
69
69
|
const id = e.target.dataset.id || "";
|
|
@@ -74,5 +74,5 @@ export const ColumnHeaderFilter = ({ filter, set }) => {
|
|
|
74
74
|
const value = valueFromType(e.target);
|
|
75
75
|
set((prev) => prev.map((x) => (x.id === id ? Object.assign(Object.assign({}, x), { value }) : x)));
|
|
76
76
|
};
|
|
77
|
-
return (_jsxs("div", { className: "flex flex-nowrap items-center gap-4 py-2", children: [_jsx(Select, { onChange: onSelectOperation,
|
|
77
|
+
return (_jsxs("div", { className: "flex flex-nowrap items-center gap-4 py-2", children: [_jsx(Select, { onChange: onSelectOperation, options: operatorOptions[filter.type], placeholder: "Operation...", title: "Filter type", value: filter.operation.value }), _jsx(Input, { "data-id": filter.id, onChange: onChangeValue, placeholder: "Looking for...", title: "Value", type: filter.type, value: filter.value }), _jsx("button", { onClick: onDelete, "data-id": filter.id, type: "button", className: "mt-4", children: _jsx(Trash2Icon, { className: "text-danger", size: 14 }) })] }));
|
|
78
78
|
};
|
|
@@ -12,7 +12,7 @@ import { Select } from "../form/select";
|
|
|
12
12
|
import { createOptionCols } from "./table-lib";
|
|
13
13
|
const Item = ({ item, onPointerDown }) => {
|
|
14
14
|
const y = useMotionValue(0);
|
|
15
|
-
return (_jsxs(Reorder.Item, { onPointerDown: onPointerDown, id: item.groupId, className: "flex flex-row items-center gap-2", value: item, style: { y }, children: [_jsx("button", { className: "cursor-grab", children: _jsx(GripVerticalIcon, { size: 14 }) }), _jsx("span", { children: item.groupName })] }, item.groupId));
|
|
15
|
+
return (_jsxs(Reorder.Item, { onPointerDown: onPointerDown, id: item.groupId, className: "flex flex-row items-center gap-2", value: item, style: { y }, children: [_jsx("button", { type: "button", className: "cursor-grab", children: _jsx(GripVerticalIcon, { size: 14 }) }), _jsx("span", { children: item.groupName })] }, item.groupId));
|
|
16
16
|
};
|
|
17
17
|
export const Group = (props) => {
|
|
18
18
|
var _a;
|
|
@@ -33,8 +33,8 @@ export const Group = (props) => {
|
|
|
33
33
|
return Object.assign(Object.assign({}, col), { groupId: uuid(), groupKey: key, index, rows, groupName: groupName });
|
|
34
34
|
}));
|
|
35
35
|
};
|
|
36
|
-
const onDelete = (
|
|
37
|
-
return (_jsx(Fragment, { children: _jsxs(Dropdown, { arrow: false, title: "Groups", trigger: _jsxs("span", { className: "flex items-center gap-1 proportional-nums", children: [_jsx(GroupIcon, { size: 14 }), "Groups", props.groups.length > 0 ? ` - ${group}(${props.groups.length})` : ""] }), children: [_jsxs("div", { className: "flex flex-nowrap items-center", children: [_jsx(Select, { value: group, title: "Tipo de agrupamento", onChange: onChange, options: options, placeholder: "Agrupar por..." }), _jsx(Button, { className: "mt-4", onClick: onDelete, theme: "raw", "data-id": group, children: _jsx(Trash2Icon, { size: 16, className: "text-danger" }) })] }), props.groups.length > 0 ? (_jsxs("section", { className: "my-4", children: [_jsx("header", { children: _jsx("h2", { className: "text-xl font-medium", children: "
|
|
36
|
+
const onDelete = () => props.setGroups([]);
|
|
37
|
+
return (_jsx(Fragment, { children: _jsxs(Dropdown, { arrow: false, title: "Groups", trigger: _jsxs("span", { className: "flex items-center gap-1 proportional-nums", children: [_jsx(GroupIcon, { size: 14 }), "Groups", props.groups.length > 0 ? ` - ${group}(${props.groups.length})` : ""] }), children: [_jsxs("div", { className: "flex flex-nowrap items-center", children: [_jsx(Select, { value: group, title: "Tipo de agrupamento", onChange: onChange, options: options, placeholder: "Agrupar por..." }), _jsx(Button, { className: "mt-4", onClick: onDelete, theme: "raw", "data-id": group, children: _jsx(Trash2Icon, { size: 16, className: "text-danger" }) })] }), props.groups.length > 0 ? (_jsxs("section", { className: "my-4", children: [_jsx("header", { children: _jsx("h2", { className: "text-xl font-medium", children: "Order groups" }) }), _jsx(LayoutGroup, { children: _jsx(Reorder.Group, { axis: "y", className: "relative space-y-2", drag: true, dragControls: controls, dragListener: false, layoutScroll: true, onReorder: props.setGroups, values: props.groups, children: props.groups.map((item) => (_jsx(Item, { item: item, onPointerDown: (e) => {
|
|
38
38
|
controls.start(e);
|
|
39
39
|
props.setGroups([...props.groups]);
|
|
40
40
|
} }, item.groupId))) }) })] })) : null] }) }));
|
|
@@ -16,9 +16,13 @@ type InnerTableProps<T extends {}> = HTMLAttributes<HTMLTableElement> & TableOpe
|
|
|
16
16
|
showMetadata?: boolean;
|
|
17
17
|
filters?: FilterConfig<T>[];
|
|
18
18
|
setGroups: React.Dispatch<React.SetStateAction<GroupItem<T>[]>>;
|
|
19
|
+
onScrollEnd?: () => void;
|
|
20
|
+
loadingMore?: boolean;
|
|
19
21
|
};
|
|
20
|
-
export type TableProps<T extends {}> = Pick<InnerTableProps<T>, "cols" | "rows"> & {
|
|
22
|
+
export type TableProps<T extends {}> = Pick<InnerTableProps<T>, "cols" | "rows" | "loadingMore"> & {
|
|
21
23
|
name: string;
|
|
24
|
+
operations?: boolean;
|
|
25
|
+
onScrollEnd?: () => void;
|
|
22
26
|
} & Partial<TableOperationProps<T> & {
|
|
23
27
|
reference: keyof T;
|
|
24
28
|
loading: boolean;
|