@g4rcez/components 0.0.19 → 0.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/display/calendar.d.ts +3 -3
- package/dist/components/display/calendar.d.ts.map +1 -1
- package/dist/components/display/calendar.js +7 -5
- package/dist/components/floating/modal.d.ts +2 -1
- package/dist/components/floating/modal.d.ts.map +1 -1
- package/dist/components/floating/modal.js +12 -10
- package/dist/components/form/date-picker.d.ts +3 -7
- package/dist/components/form/date-picker.d.ts.map +1 -1
- package/dist/components/form/date-picker.js +20 -16
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/table/index.d.ts +2 -0
- package/dist/components/table/index.d.ts.map +1 -1
- package/dist/components/table/index.js +24 -4
- package/dist/components/table/pagination.d.ts +2 -0
- package/dist/components/table/pagination.d.ts.map +1 -0
- package/dist/components/table/pagination.js +24 -0
- package/dist/components/table/table-lib.d.ts +18 -5
- package/dist/components/table/table-lib.d.ts.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4584 -4498
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +42 -37
- package/dist/index.umd.js.map +1 -1
- package/dist/preset/preset.tailwind.js +1 -1
- package/dist/preset/src/styles/theme.js +1 -1
- package/dist/styles/theme.js +1 -1
- package/package.json +1 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Locales } from "the-mask-input";
|
|
2
|
-
type CalendarProps = {
|
|
2
|
+
export type CalendarProps = {
|
|
3
|
+
disabledDate?: (date: Date) => boolean;
|
|
3
4
|
date?: Date;
|
|
4
5
|
locale?: Locales;
|
|
5
6
|
markToday?: boolean;
|
|
6
7
|
autoFocusToday?: boolean;
|
|
7
8
|
onChange?: (d: Date) => void;
|
|
8
9
|
};
|
|
9
|
-
export declare const Calendar: ({ locale, markToday, autoFocusToday, date, onChange }: CalendarProps) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
-
export {};
|
|
10
|
+
export declare const Calendar: ({ locale, disabledDate, markToday, autoFocusToday, date, onChange }: CalendarProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
11
|
//# sourceMappingURL=calendar.d.ts.map
|
|
@@ -1 +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,
|
|
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,MAAM,MAAM,aAAa,GAAG;IACxB,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC;IACvC,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,wEAAuF,aAAa,4CAmMxH,CAAC"}
|
|
@@ -9,7 +9,7 @@ import TheMaskInput from "the-mask-input";
|
|
|
9
9
|
import { useReducer } from "use-typed-reducer";
|
|
10
10
|
import { useDebounce } from "../../hooks/use-debounce";
|
|
11
11
|
import { Resizable } from "../core/resizable";
|
|
12
|
-
const transition = { type: "
|
|
12
|
+
const transition = { type: "spring", bounce: 0.1, duration: 0.3 };
|
|
13
13
|
const dir = (mod) => (n = 1) => ({ x: `${100 * mod * n}%`, opacity: 0.5 });
|
|
14
14
|
const variants = {
|
|
15
15
|
middle: { x: "0%", opacity: 1 },
|
|
@@ -61,7 +61,7 @@ const focusDate = (next, delay = 0) => {
|
|
|
61
61
|
setTimeout(select, delay);
|
|
62
62
|
};
|
|
63
63
|
const formatYear = (now) => now.getFullYear().toString().padStart(4, "0");
|
|
64
|
-
export const Calendar = ({ locale, markToday = true, autoFocusToday = true, date, onChange }) => {
|
|
64
|
+
export const Calendar = ({ locale, disabledDate, markToday = true, autoFocusToday = true, date, onChange }) => {
|
|
65
65
|
const now = date || new Date();
|
|
66
66
|
const [state, dispatch] = useReducer({
|
|
67
67
|
date: now,
|
|
@@ -143,12 +143,14 @@ export const Calendar = ({ locale, markToday = true, autoFocusToday = true, date
|
|
|
143
143
|
dispatch.onChangeYear(value);
|
|
144
144
|
defer(value);
|
|
145
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: {
|
|
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, { presenceAffectsLayout: true, 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
147
|
backgroundImage: "linear-gradient(to right, hsla(var(--card-background)) 15%, transparent 30%, transparent 70%, hsla(var(--card-background)) 85%)",
|
|
148
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
149
|
const key = day.toISOString();
|
|
150
150
|
const isSelected = key === currentAsString;
|
|
151
151
|
const today = isToday(day) && markToday;
|
|
152
|
-
|
|
153
|
-
|
|
152
|
+
const disabledByFn = (disabledDate === null || disabledDate === void 0 ? void 0 : disabledDate(day)) || false;
|
|
153
|
+
const disableDate = !isSameMonth(day, state.date) || disabledByFn;
|
|
154
|
+
return (_jsx("li", { className: "w-full flex items-center justify-center", children: _jsx("button", { type: "button", "data-date": key, disabled: disabledByFn, onClick: dispatch.onSelectDate, "data-view": state.date.getMonth().toString(), className: `size-8 disabled:cursor-not-allowed rounded-full font-semibold flex items-center justify-center proportional-nums ${today ? "text-primary" : ""} ${disableDate ? "text-disabled" : ""} ${isSelected ? "bg-primary text-primary-foreground" : ""}`, children: day.getDate() }) }, key));
|
|
155
|
+
}) })] }, monthString) }) }) }), _jsx("footer", { className: "text-center text-primary mt-2", children: _jsx("button", { className: "hover:scale-105 transition-transform duration-300", type: "button", onClick: dispatch.setToday, children: "Today" }) })] }) }));
|
|
154
156
|
};
|
|
@@ -6,9 +6,10 @@ export type DrawerProps = {
|
|
|
6
6
|
footer?: Label;
|
|
7
7
|
resizer?: boolean;
|
|
8
8
|
asChild?: boolean;
|
|
9
|
+
closable?: boolean;
|
|
9
10
|
type?: "dialog" | "drawer";
|
|
10
11
|
position?: "left" | "right";
|
|
11
|
-
trigger
|
|
12
|
+
trigger?: Label | React.FC<any>;
|
|
12
13
|
onChange: (nextState: boolean) => void;
|
|
13
14
|
};
|
|
14
15
|
export declare const Modal: ({ type, resizer, ...props }: PropsWithChildren<DrawerProps>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal.d.ts","sourceRoot":"","sources":["../../../src/components/floating/modal.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"modal.d.ts","sourceRoot":"","sources":["../../../src/components/floating/modal.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,EAAY,iBAAiB,EAAS,MAAM,OAAO,CAAC;AAClE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AA+CpC,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,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC3B,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC5B,OAAO,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;IAChC,QAAQ,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;CAC1C,CAAC;AAiCF,eAAO,MAAM,KAAK,gCAAmD,iBAAiB,CAAC,WAAW,CAAC,4CA8ElG,CAAC"}
|
|
@@ -5,27 +5,29 @@ import { FloatingFocusManager, FloatingOverlay, FloatingPortal, useClick, useDis
|
|
|
5
5
|
import { Slot } from "@radix-ui/react-slot";
|
|
6
6
|
import { cva } from "class-variance-authority";
|
|
7
7
|
import { AnimatePresence, motion, useMotionValue } from "framer-motion";
|
|
8
|
+
import { XIcon } from "lucide-react";
|
|
8
9
|
import { Fragment, useId } from "react";
|
|
10
|
+
const animationDuration = '600ms';
|
|
9
11
|
const createDrawerAnimation = (side) => ({
|
|
10
|
-
initial: { [side]: "-60%", opacity: 0.8 },
|
|
11
|
-
enter: { [side]: 0, opacity: 1 },
|
|
12
|
-
exit: { [side]: "-
|
|
12
|
+
initial: { [side]: "-60%", opacity: 0.8, animationDuration },
|
|
13
|
+
enter: { [side]: 0, opacity: 1, animationDuration },
|
|
14
|
+
exit: { [side]: ["-50%", "-90%"], opacity: 0, animationDuration },
|
|
13
15
|
});
|
|
14
16
|
const drawerLeft = createDrawerAnimation("left");
|
|
15
17
|
const drawerRight = createDrawerAnimation("right");
|
|
16
18
|
const animations = {
|
|
17
19
|
drawer: (type) => (type === "left" ? drawerLeft : drawerRight),
|
|
18
20
|
dialog: {
|
|
19
|
-
initial: { opacity: 0, scale: 0.
|
|
20
|
-
enter: { opacity: 1, scale: [1.
|
|
21
|
-
exit: { opacity: 0, scale: 0.
|
|
21
|
+
initial: { opacity: 0, scale: 0.95, animationDuration },
|
|
22
|
+
enter: { opacity: 1, scale: [1.05, 1], animationDuration },
|
|
23
|
+
exit: { opacity: 0, scale: 0.97, animationDuration },
|
|
22
24
|
},
|
|
23
25
|
};
|
|
24
|
-
const variants = cva("isolate ring-0 outline-0 appearance-none
|
|
26
|
+
const variants = cva("isolate ring-0 outline-0 appearance-none flex flex-col gap-4 flex-nowrap min-w-xs bg-floating-background", {
|
|
25
27
|
variants: {
|
|
26
28
|
type: {
|
|
27
|
-
drawer: "max-h-screen h-screen min-h-0",
|
|
28
|
-
dialog: "max-h-[calc(100lvh-10%)] h-[inherit]
|
|
29
|
+
drawer: "max-h-screen max-w-[90%] w-auto h-screen min-h-0",
|
|
30
|
+
dialog: "max-h-[calc(100lvh-10%)] container h-[inherit] rounded-lg py-8",
|
|
29
31
|
},
|
|
30
32
|
position: {
|
|
31
33
|
none: "",
|
|
@@ -61,5 +63,5 @@ export const Modal = (_a) => {
|
|
|
61
63
|
const { getReferenceProps, getFloatingProps } = useInteractions([click, role, dismiss]);
|
|
62
64
|
const Trigger = props.trigger;
|
|
63
65
|
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
|
|
66
|
+
return (_jsxs(Fragment, { children: [props.trigger ? _jsx(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 }))) }) : null, _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 justify-center 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 || props.closable ? (_jsxs("header", { className: "w-full relative", children: [props.title ? (_jsx("h2", { className: "px-8 pb-4 border-b border-floating-border text-3xl font-medium leading-relaxed", children: props.title })) : null, props.closable !== false ? (_jsx("nav", { className: "absolute -top-1 right-8", children: _jsx("button", { type: "button", onClick: () => { var _a; return (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, false); }, className: "p-1 transition-colors hover:text-danger focus:text-danger", children: _jsx(XIcon, {}) }) })) : null] })) : 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] })) }) })) }) })] }));
|
|
65
67
|
};
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import { Locales } from "the-mask-input";
|
|
2
1
|
import { Override } from "../../types";
|
|
2
|
+
import { CalendarProps } from "../display/calendar";
|
|
3
3
|
import { InputProps } from "./input";
|
|
4
|
-
type DatePickerProps = Override<InputProps, {
|
|
5
|
-
|
|
6
|
-
locale?: Locales;
|
|
7
|
-
onChange?: (date: Date) => void;
|
|
8
|
-
}>;
|
|
9
|
-
export declare const DatePicker: (props: DatePickerProps) => import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
type DatePickerProps = Override<InputProps, CalendarProps & {}>;
|
|
5
|
+
export declare const DatePicker: ({ date, locale, disabledDate, autoFocusToday, onChange, markToday, ...props }: DatePickerProps) => import("react/jsx-runtime").JSX.Element;
|
|
10
6
|
export {};
|
|
11
7
|
//# sourceMappingURL=date-picker.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date-picker.d.ts","sourceRoot":"","sources":["../../../src/components/form/date-picker.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"date-picker.d.ts","sourceRoot":"","sources":["../../../src/components/form/date-picker.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAY,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAE9D,OAAO,EAAS,UAAU,EAAE,MAAM,SAAS,CAAC;AAE5C,KAAK,eAAe,GAAG,QAAQ,CAAC,UAAU,EAAE,aAAa,GAAG,EAAE,CAAC,CAAC;AAyBhE,eAAO,MAAM,UAAU,kFAAmF,eAAe,4CAuExH,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
1
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
3
|
import { format, parse, startOfDay } from "date-fns";
|
|
3
4
|
import { CalendarIcon } from "lucide-react";
|
|
4
|
-
import { Fragment, useState } from "react";
|
|
5
|
+
import { Fragment, useMemo, useState } from "react";
|
|
5
6
|
import { Is } from "sidekicker";
|
|
6
7
|
import { Calendar } from "../display/calendar";
|
|
7
8
|
import { Dropdown } from "../floating/dropdown";
|
|
@@ -25,18 +26,22 @@ const partValues = {
|
|
|
25
26
|
day: (date) => date.getDate().toString().padStart(2, "0"),
|
|
26
27
|
month: (date) => (date.getMonth() + 1).toString().padStart(2, "0"),
|
|
27
28
|
};
|
|
28
|
-
export const DatePicker = (
|
|
29
|
-
var
|
|
30
|
-
|
|
31
|
-
const
|
|
29
|
+
export const DatePicker = (_a) => {
|
|
30
|
+
var _b;
|
|
31
|
+
var { date, locale, disabledDate, autoFocusToday, onChange, markToday } = _a, props = __rest(_a, ["date", "locale", "disabledDate", "autoFocusToday", "onChange", "markToday"]);
|
|
32
|
+
const datetimeFormat = useMemo(() => new Intl.DateTimeFormat(locale), [locale]);
|
|
33
|
+
const [innerDate, setInnerDate] = useState(date || undefined);
|
|
32
34
|
const [open, setOpen] = useState(false);
|
|
33
|
-
const mask =
|
|
34
|
-
const placeholder =
|
|
35
|
+
const mask = datetimeFormat.formatToParts(fixedDate).flatMap((x) => (Is.keyof(parts, x.type) ? parts[x.type](x.value) : []));
|
|
36
|
+
const placeholder = datetimeFormat
|
|
35
37
|
.formatToParts(fixedDate)
|
|
36
38
|
.reduce((acc, x) => acc + (Is.keyof(placeholders, x.type) ? placeholders[x.type](x.value) : ""), "");
|
|
37
|
-
const [value, setValue] = useState(!
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
const [value, setValue] = useState(!innerDate
|
|
40
|
+
? ""
|
|
41
|
+
: datetimeFormat
|
|
42
|
+
.formatToParts(innerDate)
|
|
43
|
+
.reduce((acc, x) => acc + (Is.keyof(parts, x.type) ? partValues[x.type](innerDate, x.value) : ""), ""));
|
|
44
|
+
const onChangeDateInput = (e) => {
|
|
40
45
|
const v = e.target.value;
|
|
41
46
|
setValue(v);
|
|
42
47
|
if (mask.length === v.length) {
|
|
@@ -46,16 +51,15 @@ export const DatePicker = (props) => {
|
|
|
46
51
|
});
|
|
47
52
|
if (matches) {
|
|
48
53
|
const d = startOfDay(parse(v, placeholder, new Date()));
|
|
49
|
-
|
|
50
|
-
|
|
54
|
+
setInnerDate(d);
|
|
55
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(d);
|
|
51
56
|
}
|
|
52
57
|
}
|
|
53
58
|
};
|
|
54
59
|
const onChangeDate = (d) => {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, d);
|
|
60
|
+
setInnerDate(d);
|
|
61
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(d);
|
|
58
62
|
setValue(format(d, placeholder));
|
|
59
63
|
};
|
|
60
|
-
return (_jsx(Input, Object.assign({}, props, { mask: mask, value: value, onChange:
|
|
64
|
+
return (_jsx(Input, Object.assign({}, props, { mask: mask, value: value, onChange: onChangeDateInput, className: "uppercase", formNoValidate: !open, placeholder: placeholder, required: (_b = props.required) !== null && _b !== void 0 ? _b : true, error: open ? undefined : props.error, name: props.name ? `${props.name}-picker` : props.name, right: _jsxs(Fragment, { children: [_jsx("input", { defaultValue: innerDate === null || innerDate === void 0 ? void 0 : innerDate.toISOString(), hidden: true, type: "date", name: props.name }), _jsx(Dropdown, { trigger: _jsx(CalendarIcon, {}), onChange: setOpen, open: open, children: _jsx(Calendar, Object.assign({}, props, { locale: locale, date: innerDate, onChange: onChangeDate, markToday: markToday, disabledDate: disabledDate, autoFocusToday: autoFocusToday })) })] }) })));
|
|
61
65
|
};
|
|
@@ -20,5 +20,5 @@ export * from "./floating/dropdown";
|
|
|
20
20
|
export * from "./floating/tooltip";
|
|
21
21
|
export * from "./floating/modal";
|
|
22
22
|
export * from "./table/index";
|
|
23
|
-
export { createColumns, createOptionCols, ColType, useTablePreferences } from "./table/table-lib";
|
|
23
|
+
export { createColumns, createOptionCols, type ColType, useTablePreferences, type TablePagination } from "./table/table-lib";
|
|
24
24
|
//# 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,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"}
|
|
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,KAAK,OAAO,EAAE,mBAAmB,EAAE,KAAK,eAAe,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/components/index.js
CHANGED
|
@@ -20,4 +20,4 @@ export * from "./floating/dropdown";
|
|
|
20
20
|
export * from "./floating/tooltip";
|
|
21
21
|
export * from "./floating/modal";
|
|
22
22
|
export * from "./table/index";
|
|
23
|
-
export { createColumns, createOptionCols,
|
|
23
|
+
export { createColumns, createOptionCols, useTablePreferences } from "./table/table-lib";
|
|
@@ -5,6 +5,7 @@ import { GroupItem } from "./group";
|
|
|
5
5
|
import { Sorter } from "./sort";
|
|
6
6
|
import { Col, TableOperationProps } from "./table-lib";
|
|
7
7
|
type InnerTableProps<T extends {}> = HTMLAttributes<HTMLTableElement> & TableOperationProps<T> & {
|
|
8
|
+
useControl?: boolean;
|
|
8
9
|
loading?: boolean;
|
|
9
10
|
group?: GroupItem<T>;
|
|
10
11
|
groups?: GroupItem<T>[];
|
|
@@ -20,6 +21,7 @@ type InnerTableProps<T extends {}> = HTMLAttributes<HTMLTableElement> & TableOpe
|
|
|
20
21
|
loadingMore?: boolean;
|
|
21
22
|
};
|
|
22
23
|
export type TableProps<T extends {}> = Pick<InnerTableProps<T>, "cols" | "rows" | "loadingMore"> & {
|
|
24
|
+
useControl?: boolean;
|
|
23
25
|
name: string;
|
|
24
26
|
operations?: boolean;
|
|
25
27
|
onScrollEnd?: () => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/table/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAY,cAAc,EAAwC,MAAM,OAAO,CAAC;AAM9F,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,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/table/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAY,cAAc,EAAwC,MAAM,OAAO,CAAC;AAM9F,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,EAAmB,MAAM,aAAa,CAAC;AAOvH,KAAK,eAAe,CAAC,CAAC,SAAS,EAAE,IAAI,cAAc,CAAC,gBAAgB,CAAC,GACjE,mBAAmB,CAAC,CAAC,CAAC,GAAG;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;IACrB,MAAM,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;IACxB,UAAU,EAAE,WAAW,EAAE,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;IACtB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,OAAO,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;IAC5B,SAAS,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAChE,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IACzB,WAAW,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAgMN,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,EAAE,IAAI,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,aAAa,CAAC,GAAG;IAC/F,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;CAC5B,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC,CAAC,GAAG;IAAE,SAAS,EAAE,MAAM,CAAC,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CAAC;AAO/E,eAAO,MAAM,KAAK,GAAI,CAAC,SAAS,EAAE,SAAS,UAAU,CAAC,CAAC,CAAC,4CAgGvD,CAAC"}
|
|
@@ -13,6 +13,7 @@ import { Metadata } from "./metadata";
|
|
|
13
13
|
import { multiSort } from "./sort";
|
|
14
14
|
import { createOptionCols } from "./table-lib";
|
|
15
15
|
import { TableHeader } from "./thead";
|
|
16
|
+
import { createPaginationItems } from "./pagination";
|
|
16
17
|
const TableBody = React.forwardRef((props, ref) => {
|
|
17
18
|
var _a;
|
|
18
19
|
return (_jsx("tbody", Object.assign({}, props, { className: `divide-y divide-table-border ${(_a = props.className) !== null && _a !== void 0 ? _a : ""}`, ref: ref, children: _jsx(AnimatePresence, { children: props.children }) })));
|
|
@@ -48,8 +49,25 @@ const ItemContent = (index, row, context) => {
|
|
|
48
49
|
}) }));
|
|
49
50
|
};
|
|
50
51
|
const Frag = () => _jsx(Fragment, {});
|
|
52
|
+
const Pagination = (pagination) => {
|
|
53
|
+
const Render = pagination.asLink || "button";
|
|
54
|
+
const pageNavigation = useMemo(() => createPaginationItems(pagination.current, pagination.pages), [pagination.current, pagination.pages]);
|
|
55
|
+
const hasNext = pagination.current < pagination.pages;
|
|
56
|
+
return _jsxs("footer", { className: "flex px-1 py-2 items-center justify-between flex-nowrap", children: [_jsxs("p", { children: [pagination.current, " to ", pagination.pages, " of ", pagination.totalItems, " items.", pagination.onChangeSize && Array.isArray(pagination.sizes) ?
|
|
57
|
+
_jsxs(Fragment, { children: [_jsx("select", { className: "cursor-pointer", onChange: e => {
|
|
58
|
+
var _a;
|
|
59
|
+
(_a = pagination.onChangeSize) === null || _a === void 0 ? void 0 : _a.call(pagination, Number(e.target.value));
|
|
60
|
+
}, children: pagination.sizes.map(value => _jsx("option", { value: value, children: value })) }), " per page"] })
|
|
61
|
+
: null] }), _jsx("nav", { children: _jsxs("ul", { className: "flex items-center gap-2", children: [pagination.current > 1 ? _jsx("li", { children: _jsx(Render, { href: "previous", className: "", children: "Previous" }) }) : null, pageNavigation.map(x => {
|
|
62
|
+
if (x === null)
|
|
63
|
+
return null;
|
|
64
|
+
return _jsx(Fragment, { children: typeof x === "string" ?
|
|
65
|
+
_jsx("li", { children: "..." }) :
|
|
66
|
+
_jsx("li", { children: _jsx(Render, { href: x, className: `cursor-pointer px-3 py-1 transition-colors border-b-2 hover:text-primary-subtle hover:border-primary-subtle proportional-nums ${x === pagination.current ? "text-primary border-primary" : "border-transparent"}`, children: x }) }, `pagination-${x}`) });
|
|
67
|
+
}), hasNext ? _jsx("li", { children: _jsx(Render, { href: "next", className: "", children: "Next" }) }) : null] }) })] });
|
|
68
|
+
};
|
|
51
69
|
const InnerTable = (_a) => {
|
|
52
|
-
var { filters, onScrollEnd, setCols, setFilters, sorters, cols, setSorters } = _a, props = __rest(_a, ["filters", "onScrollEnd", "setCols", "setFilters", "sorters", "cols", "setSorters"]);
|
|
70
|
+
var { filters, pagination = null, onScrollEnd, useControl = false, setCols, setFilters, sorters, cols, setSorters } = _a, props = __rest(_a, ["filters", "pagination", "onScrollEnd", "useControl", "setCols", "setFilters", "sorters", "cols", "setSorters"]);
|
|
53
71
|
const ref = useRef(null);
|
|
54
72
|
const [showLoadingFooter, setShowLoadingFooter] = useState(false);
|
|
55
73
|
const onScrollEndRef = useCallbackRef(onScrollEnd);
|
|
@@ -57,6 +75,8 @@ const InnerTable = (_a) => {
|
|
|
57
75
|
const rows = useMemo(() => {
|
|
58
76
|
if (props.loading)
|
|
59
77
|
return loadingArray;
|
|
78
|
+
if (useControl)
|
|
79
|
+
return props.rows;
|
|
60
80
|
const linq = new Linq(props.rows);
|
|
61
81
|
if (filters.length > 0) {
|
|
62
82
|
filters.forEach((x) => (x.value === "" || Number.isNaN(x.value) ? undefined : linq.Where(x.name, x.operation.symbol, x.value)));
|
|
@@ -84,11 +104,11 @@ const InnerTable = (_a) => {
|
|
|
84
104
|
observer.observe(div);
|
|
85
105
|
return () => observer.disconnect();
|
|
86
106
|
}, []);
|
|
87
|
-
return (_jsxs("div", { className: "group border border-table-border rounded-lg px-1
|
|
107
|
+
return (_jsxs("div", { className: "min-w-full", children: [_jsxs("div", { className: "group border border-table-border rounded-lg px-1", children: [_jsx(TableVirtuoso, { data: rows, useWindowScroll: true, components: components, totalCount: rows.length, itemContent: ItemContent, context: { loading: props.loading, loadingMore: props.loadingMore, cols: cols }, fixedFooterContent: showLoadingFooter ? Frag : null, fixedHeaderContent: () => (_jsx(TableHeader, { sorters: sorters, setSorters: setSorters, filters: filters, setFilters: setFilters, headers: cols, setCols: setCols })) }), _jsx("div", { "aria-hidden": "true", ref: ref, className: "h-0.5 w-full" })] }), pagination !== null ? _jsx(Pagination, Object.assign({}, pagination)) : null] }));
|
|
88
108
|
};
|
|
89
109
|
const dispatcherFun = (prev, setter) => typeof setter === "function" ? setter(prev) : setter;
|
|
90
110
|
export const Table = (props) => {
|
|
91
|
-
var _a, _b, _c, _d;
|
|
111
|
+
var _a, _b, _c, _d, _e, _f;
|
|
92
112
|
const operations = (_a = props.operations) !== null && _a !== void 0 ? _a : true;
|
|
93
113
|
const optionCols = useMemo(() => createOptionCols(props.cols), [props.cols]);
|
|
94
114
|
const [state, dispatch] = useReducer({
|
|
@@ -116,5 +136,5 @@ export const Table = (props) => {
|
|
|
116
136
|
},
|
|
117
137
|
],
|
|
118
138
|
});
|
|
119
|
-
return (_jsxs("div", { className: "relative min-w-full", children: [operations ? (_jsx(Metadata, { setCols: dispatch.cols, rows: props.rows, cols: state.cols, filters: state.filters, groups: state.groups, options: optionCols, setFilters: dispatch.filters, setGroups: dispatch.groups, setSorters: dispatch.sorters, sorters: state.sorters })) : null, state.groups.length === 0 ? (_jsx(InnerTable, Object.assign({}, props, { onScrollEnd: props.onScrollEnd, cols: state.cols, filters: state.filters, groups: state.groups, index: 0, optionCols: optionCols, options: optionCols, setCols: dispatch.cols, setFilters: dispatch.filters, setGroups: dispatch.groups, setSorters: dispatch.sorters, sorters: state.sorters }))) : (_jsx("div", { className: "flex flex-wrap gap-4", children: state.groups.map((group, index) => (_jsx(motion.div, { className: "min-w-full", children: _jsx(InnerTable, Object.assign({}, props, { onScrollEnd: props.onScrollEnd, cols: state.cols, filters: state.filters, group: group, groups: state.groups, index: index, optionCols: optionCols, options: optionCols, rows: group.rows, setCols: dispatch.cols, setFilters: dispatch.filters, setGroups: dispatch.groups, setSorters: dispatch.sorters, sorters: state.sorters })) }, `group-${group.groupId}`))) }))] }));
|
|
139
|
+
return (_jsxs("div", { className: "relative min-w-full", children: [operations ? (_jsx(Metadata, { setCols: dispatch.cols, rows: props.rows, cols: state.cols, filters: state.filters, groups: state.groups, options: optionCols, setFilters: dispatch.filters, setGroups: dispatch.groups, setSorters: dispatch.sorters, sorters: state.sorters, pagination: (_e = props.pagination) !== null && _e !== void 0 ? _e : null })) : null, state.groups.length === 0 ? (_jsx(InnerTable, Object.assign({}, props, { onScrollEnd: props.onScrollEnd, cols: state.cols, filters: state.filters, groups: state.groups, index: 0, optionCols: optionCols, options: optionCols, setCols: dispatch.cols, setFilters: dispatch.filters, setGroups: dispatch.groups, setSorters: dispatch.sorters, sorters: state.sorters, pagination: (_f = props.pagination) !== null && _f !== void 0 ? _f : null }))) : (_jsx("div", { className: "flex flex-wrap gap-4", children: state.groups.map((group, index) => (_jsx(motion.div, { className: "min-w-full", children: _jsx(InnerTable, Object.assign({}, props, { pagination: null, onScrollEnd: props.onScrollEnd, cols: state.cols, filters: state.filters, group: group, groups: state.groups, index: index, optionCols: optionCols, options: optionCols, rows: group.rows, setCols: dispatch.cols, setFilters: dispatch.filters, setGroups: dispatch.groups, setSorters: dispatch.sorters, sorters: state.sorters })) }, `group-${group.groupId}`))) }))] }));
|
|
120
140
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../../../src/components/table/pagination.ts"],"names":[],"mappings":"AAAA,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,uBAoBjE"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export function createPaginationItems(current, max) {
|
|
2
|
+
if (!current || !max)
|
|
3
|
+
return [];
|
|
4
|
+
const items = [1];
|
|
5
|
+
if (current === 1 && max === 1)
|
|
6
|
+
return items;
|
|
7
|
+
if (current > 4)
|
|
8
|
+
items.push("-");
|
|
9
|
+
let r = 2, r1 = current - r, r2 = current + r;
|
|
10
|
+
for (let i = r1 > 2 ? r1 : 2; i <= Math.min(max, r2); i++)
|
|
11
|
+
items.push(i);
|
|
12
|
+
const p2 = max - 2;
|
|
13
|
+
const p1 = max - 1;
|
|
14
|
+
if (r2 + 1 !== p2) {
|
|
15
|
+
if (r2 + 1 < max)
|
|
16
|
+
items.push("_");
|
|
17
|
+
}
|
|
18
|
+
if (r2 < max) {
|
|
19
|
+
items.push(max - 2);
|
|
20
|
+
items.push(max - 1);
|
|
21
|
+
items.push(max);
|
|
22
|
+
}
|
|
23
|
+
return Array.from(new Set(items));
|
|
24
|
+
}
|
|
@@ -20,10 +20,7 @@ export declare enum ColType {
|
|
|
20
20
|
export declare const valueFromType: (input: HTMLInputElement) => string | number;
|
|
21
21
|
type THead = React.ReactElement | React.ReactNode;
|
|
22
22
|
export type ColMatrix = `${number},${number}`;
|
|
23
|
-
type ParsePath<path, output extends string[] = [], currentChunk extends string = ""> = path extends number ? [`${path}`] : path extends `${infer first}${infer rest}` ? first extends "." | "[" | "]" ? ParsePath<rest, [
|
|
24
|
-
...output,
|
|
25
|
-
...(currentChunk extends "" ? [] : [currentChunk])
|
|
26
|
-
], ""> : ParsePath<rest, output, `${currentChunk}${first}`> : [...output, ...(currentChunk extends "" ? [] : [currentChunk])];
|
|
23
|
+
type ParsePath<path, output extends string[] = [], currentChunk extends string = ""> = path extends number ? [`${path}`] : path extends `${infer first}${infer rest}` ? first extends "." | "[" | "]" ? ParsePath<rest, [...output, ...(currentChunk extends "" ? [] : [currentChunk])], ""> : ParsePath<rest, output, `${currentChunk}${first}`> : [...output, ...(currentChunk extends "" ? [] : [currentChunk])];
|
|
27
24
|
type RecursiveGet<Obj, pathList> = Obj extends any ? pathList extends [infer first, ...infer rest] ? first extends keyof Obj ? RecursiveGet<Obj[first], rest> : [first, Obj] extends [`${number}` | "number", readonly any[]] ? RecursiveGet<Extract<Obj, any[]>[number], rest> : undefined : Obj : never;
|
|
28
25
|
type GetFromPath<Obj, path> = RecursiveGet<Obj, ParsePath<path>>;
|
|
29
26
|
export type CellPropsElement<T extends POJO, K extends AllPaths<T>> = {
|
|
@@ -59,12 +56,27 @@ declare const cols: <T extends POJO>() => <K extends AllPaths<T>>(id: K, thead:
|
|
|
59
56
|
Element?: ((props: CellPropsElement<T, K>) => React.ReactNode) | undefined;
|
|
60
57
|
};
|
|
61
58
|
export type Col<T extends POJO> = ReturnType<ReturnType<typeof cols<T>>>;
|
|
59
|
+
export type TablePagination = {
|
|
60
|
+
sizes?: number[];
|
|
61
|
+
onChangeSize?: (size: number) => void;
|
|
62
|
+
size: number;
|
|
63
|
+
pages: number;
|
|
64
|
+
current: number;
|
|
65
|
+
hasNext: boolean;
|
|
66
|
+
totalItems: number;
|
|
67
|
+
hasPrevious: boolean;
|
|
68
|
+
asLink?: React.FC<React.PropsWithChildren<{
|
|
69
|
+
href: number | "previous" | "next";
|
|
70
|
+
className: string;
|
|
71
|
+
}>>;
|
|
72
|
+
};
|
|
62
73
|
type TableGetters<T extends POJO> = {
|
|
63
74
|
rows: T[];
|
|
64
75
|
cols: Col<T>[];
|
|
65
|
-
groups: GroupItem<T>[];
|
|
66
76
|
sorters: Sorter<T>[];
|
|
77
|
+
groups: GroupItem<T>[];
|
|
67
78
|
filters: FilterConfig<T>[];
|
|
79
|
+
pagination: TablePagination | null;
|
|
68
80
|
};
|
|
69
81
|
type TableSetters<T extends POJO> = {
|
|
70
82
|
setCols: SetState<Col<T>[]>;
|
|
@@ -101,6 +113,7 @@ export declare const useTablePreferences: <T extends POJO>(name: string, options
|
|
|
101
113
|
groups: GroupItem<T>[];
|
|
102
114
|
sorters: Sorter<T>[];
|
|
103
115
|
filters: FilterConfig<T>[];
|
|
116
|
+
pagination: TablePagination | null;
|
|
104
117
|
};
|
|
105
118
|
export {};
|
|
106
119
|
//# sourceMappingURL=table-lib.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table-lib.d.ts","sourceRoot":"","sources":["../../../src/components/table/table-lib.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGtC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO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