@g4rcez/components 0.0.16 → 0.0.17

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.
Files changed (67) hide show
  1. package/dist/components/core/tag.js +2 -2
  2. package/dist/components/display/card.d.ts +7 -2
  3. package/dist/components/display/card.d.ts.map +1 -1
  4. package/dist/components/display/card.js +6 -4
  5. package/dist/components/display/stats.d.ts +10 -0
  6. package/dist/components/display/stats.d.ts.map +1 -0
  7. package/dist/components/display/stats.js +5 -0
  8. package/dist/components/display/tabs.d.ts +14 -0
  9. package/dist/components/display/tabs.d.ts.map +1 -0
  10. package/dist/components/display/tabs.js +64 -0
  11. package/dist/components/floating/dropdown.d.ts.map +1 -1
  12. package/dist/components/floating/dropdown.js +6 -14
  13. package/dist/components/floating/modal.d.ts +5 -4
  14. package/dist/components/floating/modal.d.ts.map +1 -1
  15. package/dist/components/floating/modal.js +44 -12
  16. package/dist/components/form/checkbox.d.ts +7 -0
  17. package/dist/components/form/checkbox.d.ts.map +1 -0
  18. package/dist/components/form/checkbox.js +7 -0
  19. package/dist/components/form/transfer-list.d.ts +14 -0
  20. package/dist/components/form/transfer-list.d.ts.map +1 -0
  21. package/dist/components/form/transfer-list.js +21 -0
  22. package/dist/components/index.d.ts +5 -1
  23. package/dist/components/index.d.ts.map +1 -1
  24. package/dist/components/index.js +5 -1
  25. package/dist/components/table/filter.d.ts +2 -1
  26. package/dist/components/table/filter.d.ts.map +1 -1
  27. package/dist/components/table/filter.js +5 -5
  28. package/dist/components/table/group.js +3 -3
  29. package/dist/components/table/index.d.ts +5 -1
  30. package/dist/components/table/index.d.ts.map +1 -1
  31. package/dist/components/table/index.js +54 -16
  32. package/dist/components/table/metadata.js +1 -1
  33. package/dist/components/table/sort.d.ts.map +1 -1
  34. package/dist/components/table/sort.js +5 -4
  35. package/dist/components/table/table-lib.d.ts +17 -17
  36. package/dist/components/table/table-lib.d.ts.map +1 -1
  37. package/dist/components/table/thead.d.ts.map +1 -1
  38. package/dist/components/table/thead.js +7 -12
  39. package/dist/hooks/use-callback-ref.d.ts +3 -0
  40. package/dist/hooks/use-callback-ref.d.ts.map +1 -0
  41. package/dist/hooks/use-callback-ref.js +8 -0
  42. package/dist/hooks/use-mutable-state.d.ts +2 -0
  43. package/dist/hooks/use-mutable-state.d.ts.map +1 -0
  44. package/dist/hooks/use-mutable-state.js +8 -0
  45. package/dist/hooks/use-parent.d.ts +3 -0
  46. package/dist/hooks/use-parent.d.ts.map +1 -0
  47. package/dist/hooks/use-parent.js +22 -0
  48. package/dist/index.css +1 -1
  49. package/dist/index.d.ts +1 -1
  50. package/dist/index.d.ts.map +1 -1
  51. package/dist/index.js +1 -1
  52. package/dist/index.js.map +1 -1
  53. package/dist/index.mjs +12110 -11696
  54. package/dist/index.mjs.map +1 -1
  55. package/dist/index.umd.js +39 -34
  56. package/dist/index.umd.js.map +1 -1
  57. package/dist/preset/preset.tailwind.d.ts.map +1 -1
  58. package/dist/preset/preset.tailwind.js +2 -0
  59. package/dist/preset/src/styles/theme.js +4 -4
  60. package/dist/preset/src/styles/theme.types.d.ts +1 -1
  61. package/dist/preset/src/styles/theme.types.d.ts.map +1 -1
  62. package/dist/styles/theme.js +4 -4
  63. package/dist/styles/theme.types.d.ts +1 -1
  64. package/dist/styles/theme.types.d.ts.map +1 -1
  65. package/dist/types.d.ts +1 -1
  66. package/dist/types.d.ts.map +1 -1
  67. package/package.json +3 -1
@@ -4,7 +4,7 @@ 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 bg-opacity-90 gap-1.5 text-main-foreground border-2 border-transparent items-center justify-center align-middle cursor-pointer whitespace-nowrap font-medium", {
7
+ const tagVariants = cva("inline-flex rounded-pill bg-opacity-90 gap-1.5 text-main-foreground border-2 border-transparent items-center justify-center align-middle whitespace-nowrap font-medium", {
8
8
  variants: {
9
9
  size: {
10
10
  default: "h-8 px-4 py-2",
@@ -29,7 +29,7 @@ const tagVariants = cva("inline-flex rounded-pill bg-opacity-90 gap-1.5 text-mai
29
29
  export const Tag = forwardRef(function Button(_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 : "button", className: css(tagVariants({
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({
33
33
  size,
34
34
  theme: loading ? "loading" : (theme === null || theme === void 0 ? void 0 : theme.disabled) ? "disabled" : theme,
35
35
  }), className), children: [props.children, icon] })));
@@ -1,4 +1,9 @@
1
1
  import React, { PropsWithChildren } from "react";
2
- export type CardProps = React.ComponentProps<"div">;
3
- export declare const Card: (props: PropsWithChildren<CardProps>) => import("react/jsx-runtime").JSX.Element;
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;AAIjD,MAAM,MAAM,SAAS,GAAG,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;AACpD,eAAO,MAAM,IAAI,UAAW,iBAAiB,CAAC,SAAS,CAAC,4CAEvD,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 { jsx as _jsx } from "react/jsx-runtime";
2
- import { Polymorph } from "../core/polymorph";
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
- export const Card = (props) => {
5
- return _jsx(Polymorph, Object.assign({}, props, { as: "div", className: css("rounded-lg bg-card-background p-8 border-card-border border shadow", props.className) }));
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,EAAY,iBAAiB,EAA6B,MAAM,OAAO,CAAC;AAEtF,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,4CAmE/D,CAAC"}
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, useId, useInteractions, useRole, } from "@floating-ui/react";
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
- const headingId = useId();
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":[],"mapp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C;CAC1C,CAAC;AAiCF,eAAO,MAAM,KAAK,gCAAmD,iBAAiB,CAAC,WAAW,CAAC,4CA+DlG,CAAC"}
@@ -1,14 +1,34 @@
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, useId, useInteractions, useRole, } from "@floating-ui/react";
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 { Fragment } from "react";
7
- const variants = cva("ring-0 outline-0 appearance-none container flex flex-col gap-4 flex-nowrap min-w-xs bg-floating-background", {
7
+ import { AnimatePresence, motion, useMotionValue } from "framer-motion";
8
+ import { Fragment, useId } from "react";
9
+ const drawerLeft = {
10
+ initial: { left: "-48rem", opacity: 0.4 },
11
+ enter: { left: 0, opacity: 1 },
12
+ exit: { left: "-48rem", opacity: 0.4 },
13
+ };
14
+ const drawerRight = {
15
+ initial: { right: "-48rem", opacity: 0.4 },
16
+ enter: { right: 0, opacity: 1 },
17
+ exit: { right: "-48rem", opacity: 0.4 },
18
+ };
19
+ const animations = {
20
+ drawer: (type) => (type === "left" ? drawerLeft : drawerRight),
21
+ dialog: {
22
+ initial: { opacity: 0, scale: 0.9 },
23
+ enter: { opacity: 1, scale: [1.05, 1] },
24
+ exit: { opacity: 0, scale: 0.9 },
25
+ },
26
+ };
27
+ 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
28
  variants: {
9
29
  type: {
10
30
  drawer: "max-h-screen h-screen min-h-0",
11
- dialog: "max-h-[calc(100lvh-5%)] rounded-lg py-8",
31
+ dialog: "max-h-[calc(100lvh-10%)] h-[inherit] relative rounded-lg py-8",
12
32
  },
13
33
  position: {
14
34
  none: "",
@@ -18,19 +38,31 @@ const variants = cva("ring-0 outline-0 appearance-none container flex flex-col g
18
38
  },
19
39
  defaultVariants: { position: "right", type: "dialog" },
20
40
  });
21
- export const Modal = (props) => {
22
- const type = props.type || "dialog";
23
- const position = type === "dialog" ? "none" : props.position || "left";
41
+ const dragConstraints = { top: 0, left: 0, right: 0, bottom: 0 };
42
+ const Draggable = (props) => {
43
+ const handleDrag = (_, info) => {
44
+ if (props.parent.current) {
45
+ const div = props.parent.current;
46
+ const v = props.value.get() || div.getBoundingClientRect().width;
47
+ const delta = props.type === "right" ? -info.delta.x : info.delta.x;
48
+ props.value.set(Math.abs(v + delta));
49
+ }
50
+ };
51
+ 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` }));
52
+ };
53
+ export const Modal = (_a) => {
54
+ var { type = "dialog", resizer = true } = _a, props = __rest(_a, ["type", "resizer"]);
55
+ const isDialog = type === "dialog";
56
+ const position = isDialog ? "none" : props.position || "left";
57
+ const animation = isDialog ? animations.dialog : animations.drawer(position);
24
58
  const headingId = useId();
25
59
  const descriptionId = useId();
26
- const { refs, context } = useFloating({
27
- open: props.open,
28
- onOpenChange: props.onChange,
29
- });
60
+ const { refs, context } = useFloating({ open: props.open, onOpenChange: props.onChange });
30
61
  const click = useClick(context);
31
62
  const role = useRole(context);
32
63
  const dismiss = useDismiss(context, { escapeKey: true, referencePress: true, outsidePress: false });
33
64
  const { getReferenceProps, getFloatingProps } = useInteractions([click, role, dismiss]);
34
65
  const Trigger = props.trigger;
35
- return (_jsxs(Fragment, { children: [props.asChild ? (_jsx(Slot, Object.assign({ ref: refs.setReference }, getReferenceProps(), { children: Trigger }))) : (_jsx("button", Object.assign({ ref: refs.setReference }, getReferenceProps(), { children: Trigger }))), _jsx(FloatingPortal, { children: props.open && (_jsx(FloatingOverlay, { className: `relative bg-floating-overlay/70 ${type === "drawer" ? "" : "grid items-baseline p-8"}`, lockScroll: true, children: _jsx(FloatingFocusManager, { closeOnFocusOut: true, context: context, children: _jsxs("div", Object.assign({ ref: refs.setFloating, "aria-labelledby": headingId, "aria-describedby": descriptionId, className: variants({ position, type }) }, getFloatingProps(), { children: [_jsx("span", { className: "w-5 h-2" }), props.title ? (_jsx("header", { className: "w-full", children: _jsx("h2", { className: "px-8 pb-4 border-b text-3xl font-medium leading-relaxed", children: props.title }) })) : null, _jsx("div", { className: "flex-1 px-8 overflow-scroll", children: props.children }), props.footer ? _jsx("footer", { className: "px-8 border-t pt-4 w-full", children: props.footer }) : null] })) }) })) })] }));
66
+ const value = useMotionValue(undefined);
67
+ 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
68
  };
@@ -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"}
@@ -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;AAKtC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,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;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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: "Filtro", options: props.options, placeholder: "Seleciona um campo...", value: filter.name, "data-id": filter.id, onChange: onSelectProperty }), _jsx(Select, { title: "Tipo do filtro", "data-id": filter.id, onChange: onSelectOperation, value: filter.operation.value, options: operators, placeholder: "Opera\u00E7\u00E3o..." }), _jsx(Input, { "data-id": filter.id, onChange: onChangeValue, placeholder: "Buscar por...", title: "Valor do filtro", 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 }), " Adicionar novo filtro"] }) })] }) }) }));
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, value: filter.operation.value, options: operatorOptions[filter.type], placeholder: "Operation..." }), _jsx(Input, { type: filter.type, "data-id": filter.id, onChange: onChangeValue, placeholder: "Looking for...", value: filter.value })] }));
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 = (e) => 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: "Ordenar grupos" }) }), _jsx(LayoutGroup, { children: _jsx(Reorder.Group, { axis: "y", className: "relative space-y-2", dragListener: false, dragControls: controls, drag: true, layoutScroll: true, onReorder: props.setGroups, values: props.groups, children: props.groups.map((item) => (_jsx(Item, { item: item, onPointerDown: (e) => {
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;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/table/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAY,cAAc,EAAW,MAAM,OAAO,CAAC;AAKjE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEpC,OAAO,EAAa,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC3C,OAAO,EAAoB,GAAG,EAA+B,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAGtG,KAAK,eAAe,CAAC,CAAC,SAAS,EAAE,IAAI,cAAc,CAAC,gBAAgB,CAAC,GACjE,mBAAmB,CAAC,CAAC,CAAC,GAAG;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,K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