@g4rcez/components 0.0.18 → 0.0.19

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 (49) hide show
  1. package/dist/components/core/resizable.d.ts +3 -0
  2. package/dist/components/core/resizable.d.ts.map +1 -0
  3. package/dist/components/core/resizable.js +8 -0
  4. package/dist/components/display/calendar.d.ts +11 -0
  5. package/dist/components/display/calendar.d.ts.map +1 -0
  6. package/dist/components/display/calendar.js +154 -0
  7. package/dist/components/display/tabs.d.ts.map +1 -1
  8. package/dist/components/display/tabs.js +1 -0
  9. package/dist/components/floating/dropdown.d.ts.map +1 -1
  10. package/dist/components/floating/dropdown.js +2 -1
  11. package/dist/components/floating/tooltip.d.ts.map +1 -1
  12. package/dist/components/floating/tooltip.js +2 -1
  13. package/dist/components/form/autocomplete.d.ts.map +1 -1
  14. package/dist/components/form/autocomplete.js +5 -3
  15. package/dist/components/form/date-picker.d.ts +11 -0
  16. package/dist/components/form/date-picker.d.ts.map +1 -0
  17. package/dist/components/form/date-picker.js +61 -0
  18. package/dist/components/form/file-upload.d.ts.map +1 -1
  19. package/dist/components/form/file-upload.js +1 -0
  20. package/dist/components/form/switch.d.ts.map +1 -1
  21. package/dist/components/form/switch.js +1 -0
  22. package/dist/components/index.d.ts +2 -0
  23. package/dist/components/index.d.ts.map +1 -1
  24. package/dist/components/index.js +2 -0
  25. package/dist/components/table/thead.js +1 -1
  26. package/dist/hooks/use-debounce.d.ts +4 -0
  27. package/dist/hooks/use-debounce.d.ts.map +1 -0
  28. package/dist/hooks/use-debounce.js +12 -0
  29. package/dist/index.css +1 -1
  30. package/dist/index.js.map +1 -1
  31. package/dist/index.mjs +13422 -10197
  32. package/dist/index.mjs.map +1 -1
  33. package/dist/index.umd.js +62 -52
  34. package/dist/index.umd.js.map +1 -1
  35. package/dist/lib/dom.d.ts +1 -0
  36. package/dist/lib/dom.d.ts.map +1 -1
  37. package/dist/lib/dom.js +7 -0
  38. package/dist/preset/preset.tailwind.d.ts +1 -1
  39. package/dist/preset/preset.tailwind.d.ts.map +1 -1
  40. package/dist/preset/preset.tailwind.js +6 -3
  41. package/dist/preset/src/styles/theme.d.ts.map +1 -1
  42. package/dist/preset/src/styles/theme.js +9 -4
  43. package/dist/preset/src/styles/theme.types.d.ts +1 -0
  44. package/dist/preset/src/styles/theme.types.d.ts.map +1 -1
  45. package/dist/styles/theme.d.ts.map +1 -1
  46. package/dist/styles/theme.js +9 -4
  47. package/dist/styles/theme.types.d.ts +1 -0
  48. package/dist/styles/theme.types.d.ts.map +1 -1
  49. package/package.json +19 -10
@@ -0,0 +1,3 @@
1
+ import React from "react";
2
+ export declare const Resizable: ({ children }: React.PropsWithChildren) => import("react/jsx-runtime").JSX.Element;
3
+ //# sourceMappingURL=resizable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resizable.d.ts","sourceRoot":"","sources":["../../../src/components/core/resizable.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,eAAO,MAAM,SAAS,iBAAkB,KAAK,CAAC,iBAAiB,4CAO9D,CAAC"}
@@ -0,0 +1,8 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { motion } from "framer-motion";
4
+ import useMeasure from "react-use-measure";
5
+ export const Resizable = ({ children }) => {
6
+ const [ref, bounds] = useMeasure();
7
+ return (_jsx(motion.div, { animate: { height: bounds.height > 0 ? bounds.height : 'auto' }, children: _jsx("div", { ref: ref, children: children }) }));
8
+ };
@@ -0,0 +1,11 @@
1
+ import { Locales } from "the-mask-input";
2
+ type CalendarProps = {
3
+ date?: Date;
4
+ locale?: Locales;
5
+ markToday?: boolean;
6
+ autoFocusToday?: boolean;
7
+ onChange?: (d: Date) => void;
8
+ };
9
+ export declare const Calendar: ({ locale, markToday, autoFocusToday, date, onChange }: CalendarProps) => import("react/jsx-runtime").JSX.Element;
10
+ export {};
11
+ //# sourceMappingURL=calendar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calendar.d.ts","sourceRoot":"","sources":["../../../src/components/display/calendar.tsx"],"names":[],"mappings":"AAsBA,OAAqB,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAmBvD,KAAK,aAAa,GAAG;IACjB,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,KAAK,IAAI,CAAC;CAChC,CAAC;AAmDF,eAAO,MAAM,QAAQ,0DAAyE,aAAa,4CA0L1G,CAAC"}
@@ -0,0 +1,154 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { addDays, addMonths, addWeeks, addYears, eachDayOfInterval, endOfWeek, isSameMonth, isToday, startOfDay, startOfMonth, startOfWeek, subDays, subMonths, subWeeks, subYears, } from "date-fns";
4
+ import { AnimatePresence, motion, MotionConfig } from "framer-motion";
5
+ import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react";
6
+ import { useEffect } from "react";
7
+ import { Is } from "sidekicker";
8
+ import TheMaskInput from "the-mask-input";
9
+ import { useReducer } from "use-typed-reducer";
10
+ import { useDebounce } from "../../hooks/use-debounce";
11
+ import { Resizable } from "../core/resizable";
12
+ const transition = { type: "tween", bounce: 0.15, duration: 0.3 };
13
+ const dir = (mod) => (n = 1) => ({ x: `${100 * mod * n}%`, opacity: 0.5 });
14
+ const variants = {
15
+ middle: { x: "0%", opacity: 1 },
16
+ enter: dir(1),
17
+ exit: dir(-1),
18
+ };
19
+ const removeImmediately = { exit: { visibility: "hidden" } };
20
+ const createDays = (month) => {
21
+ const start = startOfWeek(startOfMonth(month));
22
+ return eachDayOfInterval({ start, end: addDays(start, 41) });
23
+ };
24
+ const formatMonth = (d, locale) => d.toLocaleDateString(locale, { month: "long" });
25
+ const getOptionsMonth = (date, locale) => Array.from({ length: 12 }).map((_, i) => {
26
+ const month = startOfMonth(new Date(date).setMonth(i));
27
+ const label = formatMonth(month, locale);
28
+ return (_jsx("option", { value: label, "data-index": i, children: label }, label));
29
+ });
30
+ const onChangeUsingKeyboard = {
31
+ ArrowLeft: (date, duration) => {
32
+ if (duration === "days")
33
+ return subDays(date, 1);
34
+ return subMonths(date, 1);
35
+ },
36
+ ArrowRight: (date, duration) => {
37
+ if (duration === "days")
38
+ return addDays(date, 1);
39
+ return addMonths(date, 1);
40
+ },
41
+ ArrowUp: (date, duration) => {
42
+ if (duration === "days")
43
+ return subWeeks(date, 1);
44
+ return subYears(date, 1);
45
+ },
46
+ ArrowDown: (date, duration) => {
47
+ if (duration === "days")
48
+ return addWeeks(date, 1);
49
+ return addYears(date, 1);
50
+ },
51
+ };
52
+ const focusDate = (next, delay = 0) => {
53
+ const d = next.toISOString();
54
+ const select = () => {
55
+ const element = document.querySelector(`button[data-date="${d}"]`);
56
+ if (element)
57
+ return element.focus({ preventScroll: false });
58
+ };
59
+ if (delay === 0)
60
+ select();
61
+ setTimeout(select, delay);
62
+ };
63
+ const formatYear = (now) => now.getFullYear().toString().padStart(4, "0");
64
+ export const Calendar = ({ locale, markToday = true, autoFocusToday = true, date, onChange }) => {
65
+ const now = date || new Date();
66
+ const [state, dispatch] = useReducer({
67
+ date: now,
68
+ isAnimating: false,
69
+ year: formatYear(now),
70
+ direction: undefined,
71
+ months: getOptionsMonth(now, locale),
72
+ week: eachDayOfInterval({ start: startOfWeek(now), end: endOfWeek(now) }),
73
+ }, (get) => ({
74
+ onChangeYear: (year) => ({ year }),
75
+ setToday: () => ({ date: startOfDay(new Date()) }),
76
+ onExitComplete: () => {
77
+ focusDate(get.state().date, 200);
78
+ return { isAnimating: false };
79
+ },
80
+ date: (callback) => {
81
+ const newDate = callback(get.state().date);
82
+ return { date: newDate, year: formatYear(newDate) };
83
+ },
84
+ nextMonth: () => {
85
+ const state = get.state();
86
+ if (state.isAnimating)
87
+ return state;
88
+ const date = addMonths(state.date, 1);
89
+ return { date, isAnimating: true, direction: 1, year: formatYear(date) };
90
+ },
91
+ previousMonth: () => {
92
+ const state = get.state();
93
+ if (state.isAnimating)
94
+ return state;
95
+ const date = subMonths(state.date, 1);
96
+ return { date, isAnimating: true, direction: -1, year: formatYear(date) };
97
+ },
98
+ onSelectDate: (e) => {
99
+ const d = e.currentTarget.dataset.date || "";
100
+ const date = new Date(d);
101
+ return { date, year: formatYear(date) };
102
+ },
103
+ onChangeMonth: (e) => {
104
+ const value = e.target.value;
105
+ const array = Array.from(e.target.options);
106
+ const month = array.find((x) => x.value === value);
107
+ if (month) {
108
+ const i = month.dataset.index || "";
109
+ const d = new Date(get.state().date);
110
+ d.setMonth(+i);
111
+ return { date: d, year: formatYear(d) };
112
+ }
113
+ return get.state();
114
+ },
115
+ onKeyDown: (e) => {
116
+ const key = e.key;
117
+ if (key in onChangeUsingKeyboard) {
118
+ if (key === "ArrowUp" || key === "ArrowDown")
119
+ e.preventDefault();
120
+ const prev = get.state().date;
121
+ const date = Is.keyof(onChangeUsingKeyboard, key) ? onChangeUsingKeyboard[key](prev, e.shiftKey ? "month" : "days") : null;
122
+ if (date !== null) {
123
+ focusDate(date);
124
+ return { date, year: formatYear(date) };
125
+ }
126
+ }
127
+ return get.state();
128
+ },
129
+ }));
130
+ const days = createDays(state.date);
131
+ const currentAsString = state.date.toISOString();
132
+ const monthString = formatMonth(state.date, locale);
133
+ useEffect(() => onChange === null || onChange === void 0 ? void 0 : onChange(state.date), [currentAsString]);
134
+ const defer = useDebounce((y) => {
135
+ dispatch.date((prev) => {
136
+ const d = new Date(prev);
137
+ d.setFullYear(+y);
138
+ return d;
139
+ });
140
+ }, 700);
141
+ const onChangeYear = (e) => {
142
+ const value = e.currentTarget.value;
143
+ dispatch.onChangeYear(value);
144
+ defer(value);
145
+ };
146
+ return (_jsx(MotionConfig, { transition: transition, children: _jsxs("div", { className: "relative overflow-hidden", children: [_jsx("div", { className: "flex flex-col justify-center rounded text-center", children: _jsx(Resizable, { children: _jsx(AnimatePresence, { mode: "popLayout", initial: false, custom: state.direction, onExitComplete: dispatch.onExitComplete, children: _jsxs(motion.div, { initial: "enter", animate: "middle", exit: "exit", children: [_jsxs("header", { className: "relative flex justify-between", children: [_jsx(motion.button, { onClick: dispatch.previousMonth, variants: removeImmediately, className: "z-calendar rounded-full p-1.5 hover:bg-primary-subtle", children: _jsx(ChevronLeftIcon, { className: "h-4 w-4" }) }), _jsx(motion.span, { variants: variants, custom: state.direction, className: "absolute z-normal isolate inset-0 flex items-center justify-center font-semibold", children: _jsxs("span", { className: "w-fit flex items-center justify-center gap-0.5 py-1", children: [_jsx("select", { style: { width: `${monthString.length}ch` }, value: monthString, onChange: dispatch.onChangeMonth, className: "appearance-none capitalize bg-transparent proportional-nums hover:text-primary cursor-pointer w-fit", children: state.months }), _jsx(TheMaskInput, { mask: "int", value: state.year, maxLength: 4, placeholder: "YYYY", onChange: onChangeYear, style: { width: `${state.year.length}ch` }, className: "w-16 bg-transparent appearance-none hover:text-primary cursor-pointer" })] }) }), _jsx(motion.button, { variants: removeImmediately, className: "z-calendar rounded-full p-1.5 hover:bg-primary-subtle", onClick: dispatch.nextMonth, children: _jsx(ChevronRightIcon, { className: "h-4 w-4" }) }), _jsx("div", { className: "absolute inset-0", style: {
147
+ backgroundImage: "linear-gradient(to right, hsla(var(--card-background)) 15%, transparent 30%, transparent 70%, hsla(var(--card-background)) 85%)",
148
+ } })] }), _jsx("div", { className: "mt-4 grid grid-cols-7 gap-y-4", children: state.week.map((dayOfWeek) => (_jsx("span", { className: "font-medium capitalize text-sm", children: dayOfWeek.toLocaleDateString(locale, { weekday: "short" }) }, dayOfWeek.toString()))) }), _jsx(motion.ul, { onKeyDown: dispatch.onKeyDown, variants: variants, custom: state.direction, className: "mt-4 pb-2 grid grid-cols-7 gap-y-4", children: days.map((day) => {
149
+ const key = day.toISOString();
150
+ const isSelected = key === currentAsString;
151
+ const today = isToday(day) && markToday;
152
+ return (_jsx("li", { className: "w-full flex items-center justify-center", children: _jsx("button", { type: "button", "data-date": key, onClick: dispatch.onSelectDate, "data-view": state.date.getMonth().toString(), className: `size-8 rounded-full font-semibold flex items-center justify-center proportional-nums ${today ? "text-primary" : ""} ${isSameMonth(day, state.date) ? "" : "text-disabled"} ${isSelected ? "bg-primary text-primary-foreground" : ""}`, children: day.getDate() }) }, key));
153
+ }) })] }, monthString) }) }) }), _jsx("footer", { className: "text-center text-primary mt-2", children: _jsx("button", { type: "button", onClick: dispatch.setToday, children: "Today" }) })] }) }));
154
+ };
@@ -1 +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"}
1
+ {"version":3,"file":"tabs.d.ts","sourceRoot":"","sources":["../../../src/components/display/tabs.tsx"],"names":[],"mappings":"AAEA,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"}
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
3
  import { motion, useMotionValue } from "framer-motion";
3
4
  import React, { createContext, Fragment, useContext, useEffect, useRef } from "react";
@@ -1 +1 @@
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
+ {"version":3,"file":"dropdown.d.ts","sourceRoot":"","sources":["../../../src/components/floating/dropdown.tsx"],"names":[],"mappings":"AAgBA,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,3 +1,4 @@
1
+ "use client";
1
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
3
  import { arrow, autoUpdate, flip, FloatingArrow, FloatingFocusManager, FloatingPortal, offset, shift, useClick, useDismiss, useFloating, useInteractions, useRole, } from "@floating-ui/react";
3
4
  import { Fragment, useId, useMemo, useRef, useState } from "react";
@@ -26,5 +27,5 @@ export const Dropdown = (props) => {
26
27
  const dismiss = useDismiss(context);
27
28
  const role = useRole(context);
28
29
  const { getReferenceProps, getFloatingProps } = useInteractions([click, dismiss, role]);
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] })) }) }))] }));
30
+ 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-wide text-left", children: props.title }) }), props.children] })) }) }))] }));
30
31
  };
@@ -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,MAAM,CAAC,EAAE;IAAE,KAAK,EAAE,KAAK,CAAA;CAAE,CAAC,CAAC;AAEzG,eAAO,MAAM,OAAO,sCAAuC,YAAY,4CA6CtE,CAAC"}
1
+ {"version":3,"file":"tooltip.d.ts","sourceRoot":"","sources":["../../../src/components/floating/tooltip.tsx"],"names":[],"mappings":"AAgBA,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"}
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { __rest } from "tslib";
2
3
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
4
  import { arrow, autoUpdate, flip, FloatingArrow, FloatingPortal, offset, shift, useDismiss, useFloating, useFocus, useHover, useInteractions, useRole, } from "@floating-ui/react";
@@ -28,5 +29,5 @@ export const Tooltip = (_a) => {
28
29
  const dismiss = useDismiss(context);
29
30
  const role = useRole(context, { role: "tooltip" });
30
31
  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({}, 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
+ 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 z-tooltip 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
33
  };
@@ -1 +1 @@
1
- {"version":3,"file":"autocomplete.d.ts","sourceRoot":"","sources":["../../../src/components/form/autocomplete.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAA4D,MAAM,OAAO,CAAC;AACjF,OAAO,EAAc,eAAe,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,UAAU,CAAC;AAI5C,KAAK,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,aAAa,CAAC,EAAE,UAAU,CAAC,GAAG;IAChE,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,WAAW,CAAC;CACvB,CAAC;AAEF,eAAO,MAAM,MAAM,8FAWjB,CAAC;AAEH,KAAK,WAAW,GAAG,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,GAAG;IACzD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,WAAW,EAAE,CAAC;CAC1B,CAAC;AAaF,eAAO,MAAM,YAAY,mGAoKvB,CAAC"}
1
+ {"version":3,"file":"autocomplete.d.ts","sourceRoot":"","sources":["../../../src/components/form/autocomplete.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAA4D,MAAM,OAAO,CAAC;AAGjF,OAAO,EAAc,eAAe,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C,KAAK,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,aAAa,CAAC,EAAE,UAAU,CAAC,GAAG;IAChE,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,WAAW,CAAC;CACvB,CAAC;AAEF,eAAO,MAAM,MAAM,8FAWjB,CAAC;AAEH,KAAK,WAAW,GAAG,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,GAAG;IACzD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,WAAW,EAAE,CAAC;CAC1B,CAAC;AAaF,eAAO,MAAM,YAAY,mGAsKvB,CAAC"}
@@ -6,9 +6,9 @@ import { autoUpdate, FloatingFocusManager, FloatingPortal, offset, size, useDism
6
6
  import Fuzzy from "fuzzy-search";
7
7
  import { ChevronDown } from "lucide-react";
8
8
  import { forwardRef, useImperativeHandle, useRef, useState } from "react";
9
- import { InputField } from "./input-field";
10
9
  import { usePrevious } from "../../hooks/use-previous";
11
- import { css } from "../../lib/dom";
10
+ import { css, dispatchInput } from "../../lib/dom";
11
+ import { InputField } from "./input-field";
12
12
  export const Option = forwardRef((_a, ref) => {
13
13
  var _b;
14
14
  var { selected, active, onClick, option } = _a, rest = __rest(_a, ["selected", "active", "onClick", "option"]);
@@ -16,7 +16,7 @@ export const Option = forwardRef((_a, ref) => {
16
16
  });
17
17
  const transitionStyles = {
18
18
  duration: 300,
19
- initial: { transform: "scaleY(0)", opacity: 0.2 },
19
+ initial: { transform: "scaleY(0)", opacity: 0.4 },
20
20
  open: { transform: "scaleY(1)", opacity: 1 },
21
21
  close: { transform: "scaleY(0)", opacity: 0 },
22
22
  };
@@ -79,6 +79,7 @@ export const Autocomplete = forwardRef((_a, externalRef) => {
79
79
  ]);
80
80
  const onSelect = (opt) => {
81
81
  setValue(opt.value);
82
+ dispatchInput(refs.reference.current, opt.value);
82
83
  setOpen(false);
83
84
  setShadow("");
84
85
  };
@@ -97,6 +98,7 @@ export const Autocomplete = forwardRef((_a, externalRef) => {
97
98
  const onClose = () => {
98
99
  setShadow("");
99
100
  setValue("");
101
+ dispatchInput(refs.reference.current, "");
100
102
  setOpen(false);
101
103
  };
102
104
  return (_jsxs("fieldset", { className: "relative w-auto", children: [_jsx(InputField, Object.assign({}, props, { required: required, right: _jsxs("span", { className: "flex items-center gap-0.5", children: [_jsx(ChevronDown, { size: 20 }), value ? (_jsx("button", { type: "button", onClick: onClose, className: "link:text-danger transition-colors", children: _jsx("svg", { width: "15", height: "15", viewBox: "0 0 15 15", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: _jsx("path", { d: "M11.7816 4.03157C12.0062 3.80702 12.0062 3.44295 11.7816 3.2184C11.5571 2.99385 11.193 2.99385 10.9685 3.2184L7.50005 6.68682L4.03164 3.2184C3.80708 2.99385 3.44301 2.99385 3.21846 3.2184C2.99391 3.44295 2.99391 3.80702 3.21846 4.03157L6.68688 7.49999L3.21846 10.9684C2.99391 11.193 2.99391 11.557 3.21846 11.7816C3.44301 12.0061 3.80708 12.0061 4.03164 11.7816L7.50005 8.31316L10.9685 11.7816C11.193 12.0061 11.5571 12.0061 11.7816 11.7816C12.0062 11.557 12.0062 11.193 11.7816 10.9684L8.31322 7.49999L11.7816 4.03157Z", fill: "currentColor", fillRule: "evenodd", clipRule: "evenodd" }) }) })) : null] }), children: _jsx("input", Object.assign({}, getReferenceProps(Object.assign(Object.assign({}, props), { onChange,
@@ -0,0 +1,11 @@
1
+ import { Locales } from "the-mask-input";
2
+ import { Override } from "../../types";
3
+ import { InputProps } from "./input";
4
+ type DatePickerProps = Override<InputProps, {
5
+ date?: Date;
6
+ locale?: Locales;
7
+ onChange?: (date: Date) => void;
8
+ }>;
9
+ export declare const DatePicker: (props: DatePickerProps) => import("react/jsx-runtime").JSX.Element;
10
+ export {};
11
+ //# sourceMappingURL=date-picker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"date-picker.d.ts","sourceRoot":"","sources":["../../../src/components/form/date-picker.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEzC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGvC,OAAO,EAAS,UAAU,EAAE,MAAM,SAAS,CAAC;AAE5C,KAAK,eAAe,GAAG,QAAQ,CAC3B,UAAU,EACV;IACI,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;CACnC,CACJ,CAAC;AAyBF,eAAO,MAAM,UAAU,UAAW,eAAe,4CAyDhD,CAAC"}
@@ -0,0 +1,61 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { format, parse, startOfDay } from "date-fns";
3
+ import { CalendarIcon } from "lucide-react";
4
+ import { Fragment, useState } from "react";
5
+ import { Is } from "sidekicker";
6
+ import { Calendar } from "../display/calendar";
7
+ import { Dropdown } from "../floating/dropdown";
8
+ import { Input } from "./input";
9
+ const fixedDate = new Date(1970, 11, 31);
10
+ const parts = {
11
+ year: () => [/\d/, /\d/, /\d/, /\d/],
12
+ month: () => [/\d/, /\d/],
13
+ day: () => [/\d/, /\d/],
14
+ literal: (str) => str.split(""),
15
+ };
16
+ const placeholders = {
17
+ year: () => "yyyy",
18
+ month: () => "MM",
19
+ day: () => "dd",
20
+ literal: (str) => str,
21
+ };
22
+ const partValues = {
23
+ literal: (date, str) => str,
24
+ year: (date) => date.getFullYear(),
25
+ day: (date) => date.getDate().toString().padStart(2, "0"),
26
+ month: (date) => (date.getMonth() + 1).toString().padStart(2, "0"),
27
+ };
28
+ export const DatePicker = (props) => {
29
+ var _a;
30
+ const locale = new Intl.DateTimeFormat(props.locale);
31
+ const [date, setDate] = useState(props.date || undefined);
32
+ const [open, setOpen] = useState(false);
33
+ const mask = locale.formatToParts(fixedDate).flatMap((x) => (Is.keyof(parts, x.type) ? parts[x.type](x.value) : []));
34
+ const placeholder = locale
35
+ .formatToParts(fixedDate)
36
+ .reduce((acc, x) => acc + (Is.keyof(placeholders, x.type) ? placeholders[x.type](x.value) : ""), "");
37
+ const [value, setValue] = useState(!date ? "" : locale.formatToParts(date).reduce((acc, x) => acc + (Is.keyof(parts, x.type) ? partValues[x.type](date, x.value) : ""), ""));
38
+ const onChange = (e) => {
39
+ var _a;
40
+ const v = e.target.value;
41
+ setValue(v);
42
+ if (mask.length === v.length) {
43
+ const matches = mask.every((x, i) => {
44
+ const c = v.charAt(i);
45
+ return typeof x === "string" ? c === x : x.test(c);
46
+ });
47
+ if (matches) {
48
+ const d = startOfDay(parse(v, placeholder, new Date()));
49
+ setDate(d);
50
+ (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, d);
51
+ }
52
+ }
53
+ };
54
+ const onChangeDate = (d) => {
55
+ var _a;
56
+ setDate(d);
57
+ (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, d);
58
+ setValue(format(d, placeholder));
59
+ };
60
+ return (_jsx(Input, Object.assign({}, props, { mask: mask, value: value, onChange: onChange, className: "uppercase", formNoValidate: !open, placeholder: placeholder, required: (_a = props.required) !== null && _a !== void 0 ? _a : true, error: open ? undefined : props.error, name: props.name ? `${props.name}-picker` : props.name, right: _jsxs(Fragment, { children: [_jsx("input", { defaultValue: date === null || date === void 0 ? void 0 : date.toISOString(), hidden: true, type: "date", name: props.name }), _jsx(Dropdown, { trigger: _jsx(CalendarIcon, {}), onChange: setOpen, open: open, children: _jsx(Calendar, { date: date, onChange: onChangeDate, locale: props.locale }) })] }) })));
61
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"file-upload.d.ts","sourceRoot":"","sources":["../../../src/components/form/file-upload.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAwC,MAAM,OAAO,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAe,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGtC,KAAK,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,aAAa,CAAC,GAAG;IAClE,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IACpC,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC;IACf,IAAI,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC;IAC1B,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,IAAI,CAAC;CACnC,CAAC;AAmGF,eAAO,MAAM,UAAU,6CAA4D,KAAK,4CAiBvF,CAAC"}
1
+ {"version":3,"file":"file-upload.d.ts","sourceRoot":"","sources":["../../../src/components/form/file-upload.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAwC,MAAM,OAAO,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAe,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGtC,KAAK,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,aAAa,CAAC,GAAG;IAClE,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IACpC,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC;IACf,IAAI,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC;IAC1B,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,IAAI,CAAC;CACnC,CAAC;AAmGF,eAAO,MAAM,UAAU,6CAA4D,KAAK,4CAiBvF,CAAC"}
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { __rest } from "tslib";
2
3
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
4
  import { FileIcon, Trash2Icon, UploadIcon } from "lucide-react";
@@ -1 +1 @@
1
- {"version":3,"file":"switch.d.ts","sourceRoot":"","sources":["../../../src/components/form/switch.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA0B,MAAM,OAAO,CAAC;AAE/C,KAAK,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,UAAU,CAAC,GAAG;IAAE,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAA;CAAE,CAAC;AAEhH,eAAO,MAAM,MAAM,2BAA4B,WAAW,4CAmCzD,CAAC"}
1
+ {"version":3,"file":"switch.d.ts","sourceRoot":"","sources":["../../../src/components/form/switch.tsx"],"names":[],"mappings":"AACA,OAAO,KAA0B,MAAM,OAAO,CAAC;AAE/C,KAAK,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,UAAU,CAAC,GAAG;IAAE,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAA;CAAE,CAAC;AAEhH,eAAO,MAAM,MAAM,2BAA4B,WAAW,4CAmCzD,CAAC"}
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { __rest } from "tslib";
2
3
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
4
  import { useId, useState } from "react";
@@ -8,12 +8,14 @@ export * from "./form/switch";
8
8
  export * from "./form/input-field";
9
9
  export * from "./form/transfer-list";
10
10
  export * from "./form/checkbox";
11
+ export * from "./form/date-picker";
11
12
  export * from "./core/button";
12
13
  export * from "./core/polymorph";
13
14
  export * from "./core/tag";
14
15
  export * from "./display/card";
15
16
  export * from "./display/stats";
16
17
  export * from "./display/tabs";
18
+ export * from "./display/calendar";
17
19
  export * from "./floating/dropdown";
18
20
  export * from "./floating/tooltip";
19
21
  export * from "./floating/modal";
@@ -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,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"}
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,oBAAoB,CAAC;AACnC,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,oBAAoB,CAAC;AACnC,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"}
@@ -8,12 +8,14 @@ export * from "./form/switch";
8
8
  export * from "./form/input-field";
9
9
  export * from "./form/transfer-list";
10
10
  export * from "./form/checkbox";
11
+ export * from "./form/date-picker";
11
12
  export * from "./core/button";
12
13
  export * from "./core/polymorph";
13
14
  export * from "./core/tag";
14
15
  export * from "./display/card";
15
16
  export * from "./display/stats";
16
17
  export * from "./display/tabs";
18
+ export * from "./display/calendar";
17
19
  export * from "./floating/dropdown";
18
20
  export * from "./floating/tooltip";
19
21
  export * from "./floating/modal";
@@ -15,6 +15,6 @@ const HeaderChild = (props) => {
15
15
  const id = e.currentTarget.dataset.id || "";
16
16
  return props.setFilters((prev) => prev.filter((x) => x.id !== id));
17
17
  };
18
- return (_jsx(Reorder.Item, Object.assign({}, props.header.thProps, { as: "th", exit: exit, initial: false, dragSnapToOrigin: true, dragDirectionLock: true, value: props.header, whileDrag: whileDrag, animate: targetTransitionAnimate, className: `hidden px-2 py-4 first:table-cell md:table-cell ${(_b = (_a = props.header.thProps) === null || _a === void 0 ? void 0 : _a.className) !== null && _b !== void 0 ? _b : ""}`, children: _jsx("span", { className: "flex items-center justify-between", children: _jsxs("span", { className: "flex items-center gap-1", children: [_jsx(Dropdown, { title: `Filter by ${getLabel(props.header)}`, arrow: true, trigger: _jsx(SearchIcon, { size: 14 }), children: (ownFilters.length === 0) === null ? null : (_jsxs("ul", { className: "font-medium", children: [ownFilters.map((filter) => (_jsx("li", { className: "my-1", children: _jsx(ColumnHeaderFilter, { onDelete: onDelete, filter: filter, set: props.setFilters }) }, `thead-filter-${filter.id}`))), _jsx("li", { children: _jsxs("button", { onClick: () => props.setFilters((prev) => prev.concat(createFilterFromCol(props.header))), className: "flex items-center", children: [_jsx(PlusIcon, { size: 14 }), " Add"] }) })] })) }), _jsx("span", { className: "pointer-events-auto text-balance text-base", children: props.header.thead }), _jsx(SorterHead, { col: props.header, setSorters: props.setSorters, sorters: props.sorters })] }) }) })));
18
+ return (_jsx(Reorder.Item, Object.assign({}, props.header.thProps, { as: "th", exit: exit, initial: false, dragSnapToOrigin: true, dragDirectionLock: true, value: props.header, whileDrag: whileDrag, animate: targetTransitionAnimate, className: `hidden font-medium text-secondary px-2 py-4 first:table-cell md:table-cell ${(_b = (_a = props.header.thProps) === null || _a === void 0 ? void 0 : _a.className) !== null && _b !== void 0 ? _b : ""}`, children: _jsx("span", { className: "flex items-center justify-between", children: _jsxs("span", { className: "flex items-center gap-1", children: [_jsx(Dropdown, { title: `Filter by ${getLabel(props.header)}`, arrow: true, trigger: _jsx(SearchIcon, { size: 14 }), children: (ownFilters.length === 0) === null ? null : (_jsxs("ul", { className: "font-medium", children: [ownFilters.map((filter) => (_jsx("li", { className: "my-1", children: _jsx(ColumnHeaderFilter, { onDelete: onDelete, filter: filter, set: props.setFilters }) }, `thead-filter-${filter.id}`))), _jsx("li", { children: _jsxs("button", { onClick: () => props.setFilters((prev) => prev.concat(createFilterFromCol(props.header))), className: "flex items-center", children: [_jsx(PlusIcon, { size: 14 }), " Add"] }) })] })) }), _jsx("span", { className: "pointer-events-auto text-balance text-base", children: props.header.thead }), _jsx(SorterHead, { col: props.header, setSorters: props.setSorters, sorters: props.sorters })] }) }) })));
19
19
  };
20
20
  export const TableHeader = (props) => (_jsx(Reorder.Group, { as: "tr", axis: "x", drag: true, layout: true, layoutRoot: true, layoutScroll: true, initial: false, values: props.headers, onReorder: props.setCols, className: "bg-table-background border-none text-lg", children: _jsx(AnimatePresence, { children: props.headers.map((header) => (_jsx(HeaderChild, { setFilters: props.setFilters, filters: props.filters, setSorters: props.setSorters, sorters: props.sorters, header: header }, `header-child-item-${header.id}`))) }) }));
@@ -0,0 +1,4 @@
1
+ type Fn = (...a: any[]) => any;
2
+ export declare function useDebounce<T extends Fn>(fn: T, delay: number): (...args: any[]) => void;
3
+ export {};
4
+ //# sourceMappingURL=use-debounce.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-debounce.d.ts","sourceRoot":"","sources":["../../src/hooks/use-debounce.ts"],"names":[],"mappings":"AAEA,KAAK,EAAE,GAAG,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC;AAU/B,wBAAgB,WAAW,CAAC,CAAC,SAAS,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,4BAG7D"}
@@ -0,0 +1,12 @@
1
+ import { useRef } from "react";
2
+ const debounce = (fn, ms = 0) => {
3
+ let timeoutId = undefined;
4
+ return function debounced(...args) {
5
+ clearTimeout(timeoutId);
6
+ timeoutId = setTimeout(() => fn(...args), ms);
7
+ };
8
+ };
9
+ export function useDebounce(fn, delay) {
10
+ const debouncedValue = useRef(debounce(fn, delay));
11
+ return debouncedValue.current;
12
+ }