@g4rcez/components 0.0.34 → 0.0.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/core/button.d.ts.map +1 -1
- package/dist/components/core/resizable.d.ts.map +1 -1
- package/dist/components/core/resizable.js +21 -18
- package/dist/components/core/tag.d.ts +5 -1
- package/dist/components/core/tag.d.ts.map +1 -1
- package/dist/components/core/tag.js +20 -7
- package/dist/components/display/calendar.d.ts +39 -8
- package/dist/components/display/calendar.d.ts.map +1 -1
- package/dist/components/display/calendar.js +111 -53
- package/dist/components/display/list.d.ts.map +1 -1
- package/dist/components/display/list.js +1 -3
- package/dist/components/display/timeline.d.ts +32 -0
- package/dist/components/display/timeline.d.ts.map +1 -0
- package/dist/components/display/timeline.js +21 -0
- package/dist/components/floating/dropdown.d.ts.map +1 -1
- package/dist/components/floating/dropdown.js +1 -2
- package/dist/components/floating/expand.d.ts +9 -0
- package/dist/components/floating/expand.d.ts.map +1 -0
- package/dist/components/floating/expand.js +25 -0
- package/dist/components/floating/menu.d.ts +5 -2
- package/dist/components/floating/menu.d.ts.map +1 -1
- package/dist/components/floating/menu.js +5 -4
- package/dist/components/floating/modal.d.ts +1 -0
- package/dist/components/floating/modal.d.ts.map +1 -1
- package/dist/components/floating/modal.js +3 -1
- package/dist/components/floating/tooltip.d.ts +3 -1
- package/dist/components/floating/tooltip.d.ts.map +1 -1
- package/dist/components/floating/tooltip.js +9 -16
- package/dist/components/form/autocomplete.d.ts.map +1 -1
- package/dist/components/form/autocomplete.js +14 -23
- package/dist/components/form/date-picker.d.ts +56 -2
- package/dist/components/form/date-picker.d.ts.map +1 -1
- package/dist/components/form/date-picker.js +16 -11
- package/dist/components/form/input.d.ts.map +1 -1
- package/dist/components/form/input.js +1 -1
- package/dist/components/form/switch.d.ts +1 -1
- package/dist/components/form/switch.d.ts.map +1 -1
- package/dist/components/form/switch.js +1 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +1 -0
- package/dist/hooks/use-form.d.ts.map +1 -1
- package/dist/hooks/use-form.js +1 -3
- package/dist/hooks/use-translate-context.d.ts +5 -1
- package/dist/hooks/use-translate-context.d.ts.map +1 -1
- package/dist/hooks/use-translate-context.js +3 -1
- package/dist/index.css +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7414 -7324
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +47 -42
- package/dist/index.umd.js.map +1 -1
- package/dist/lib/fns.d.ts +1 -0
- package/dist/lib/fns.d.ts.map +1 -1
- package/dist/lib/fns.js +10 -0
- package/dist/preset/src/styles/theme.js +2 -2
- package/dist/styles/theme.js +2 -2
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../../src/components/core/button.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../../src/components/core/button.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAElE,OAAO,KAAqB,MAAM,OAAO,CAAC;AAE1C,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAa,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE1D,QAAA,MAAM,cAAc;;;;mFA6BnB,CAAC;AAEF,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,KAAK,CAAC,WAAW,GAAG,QAAQ,IAAI,gBAAgB,CAC9E,YAAY,CAAC,OAAO,cAAc,CAAC,GAAG,OAAO,CAAC;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,EAChF,CAAC,CACJ,CAAC;AAEF,eAAO,MAAM,MAAM,EAAE,CAAC,CAAC,SAAS,KAAK,CAAC,WAAW,GAAG,QAAQ,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,GAsB7E,CAAC;AAEZ,KAAK,KAAK,GAAG;IACT,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,WAAW,EAAE,CAAC;CAC1B,CAAC;AAEF,eAAO,MAAM,WAAW,UAAW,KAAK,4CAkBvC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resizable.d.ts","sourceRoot":"","sources":["../../../src/components/core/resizable.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAuC,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"resizable.d.ts","sourceRoot":"","sources":["../../../src/components/core/resizable.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAoD5D,eAAO,MAAM,SAAS,iBAAkB,KAAK,CAAC,iBAAiB,4CAQ9D,CAAC"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { motion, useMotionValue } from "framer-motion";
|
|
4
4
|
import { useEffect, useMemo, useState } from "react";
|
|
5
|
+
import { isSsr } from "../../lib/fns";
|
|
5
6
|
const defaultState = {
|
|
6
7
|
x: 0,
|
|
7
8
|
y: 0,
|
|
@@ -15,28 +16,30 @@ const defaultState = {
|
|
|
15
16
|
const useElementRect = () => {
|
|
16
17
|
const [element, ref] = useState(null);
|
|
17
18
|
const motion = useMotionValue(defaultState);
|
|
18
|
-
const observer = useMemo(() =>
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
19
|
+
const observer = useMemo(() => isSsr()
|
|
20
|
+
? null
|
|
21
|
+
: new window.ResizeObserver((entries) => {
|
|
22
|
+
if (entries[0]) {
|
|
23
|
+
const rect = entries[0].contentRect;
|
|
24
|
+
motion.set({
|
|
25
|
+
x: rect.x,
|
|
26
|
+
y: rect.y,
|
|
27
|
+
width: rect.width,
|
|
28
|
+
height: rect.height,
|
|
29
|
+
top: rect.top,
|
|
30
|
+
left: rect.left,
|
|
31
|
+
bottom: rect.bottom,
|
|
32
|
+
right: rect.right,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}), []);
|
|
33
36
|
useEffect(() => {
|
|
34
37
|
if (!element)
|
|
35
38
|
return;
|
|
39
|
+
if (observer === null)
|
|
40
|
+
return;
|
|
36
41
|
observer.observe(element);
|
|
37
|
-
return () =>
|
|
38
|
-
observer.disconnect();
|
|
39
|
-
};
|
|
42
|
+
return () => observer.disconnect();
|
|
40
43
|
}, [element]);
|
|
41
44
|
return [ref, motion];
|
|
42
45
|
};
|
|
@@ -2,13 +2,17 @@ import { type VariantProps } from "class-variance-authority";
|
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { Label } from "../../types";
|
|
4
4
|
import { PolymorphicProps } from "./polymorph";
|
|
5
|
+
declare const indicatorVariant: (props?: ({
|
|
6
|
+
theme?: "main" | "warn" | "danger" | "secondary" | "success" | "info" | null | undefined;
|
|
7
|
+
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
5
8
|
declare const tagVariants: (props?: ({
|
|
6
9
|
size?: "big" | "small" | "default" | "icon" | null | undefined;
|
|
7
|
-
theme?: "main" | "disabled" | "loading" | "raw" | "warn" | "danger" | "secondary" | "success" | "info" | null | undefined;
|
|
10
|
+
theme?: "main" | "disabled" | "loading" | "raw" | "warn" | "danger" | "secondary" | "success" | "info" | "neutral" | null | undefined;
|
|
8
11
|
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
9
12
|
export type TagProps<T extends React.ElementType = "span"> = PolymorphicProps<VariantProps<typeof tagVariants> & Partial<{
|
|
10
13
|
icon: Label;
|
|
11
14
|
loading: boolean;
|
|
15
|
+
indicator: VariantProps<typeof indicatorVariant>["theme"];
|
|
12
16
|
}>, T>;
|
|
13
17
|
export declare const Tag: <T extends React.ElementType = "span">(props: TagProps<T>) => any;
|
|
14
18
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tag.d.ts","sourceRoot":"","sources":["../../../src/components/core/tag.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAqB,MAAM,OAAO,CAAC;AAE1C,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAa,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE1D,QAAA,MAAM,WAAW;;;
|
|
1
|
+
{"version":3,"file":"tag.d.ts","sourceRoot":"","sources":["../../../src/components/core/tag.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAqB,MAAM,OAAO,CAAC;AAE1C,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAa,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE1D,QAAA,MAAM,gBAAgB;;mFAWpB,CAAC;AAEH,QAAA,MAAM,WAAW;;;mFAyBhB,CAAC;AAEF,MAAM,MAAM,QAAQ,CAAC,CAAC,SAAS,KAAK,CAAC,WAAW,GAAG,MAAM,IAAI,gBAAgB,CACzE,YAAY,CAAC,OAAO,WAAW,CAAC,GAC5B,OAAO,CAAC;IACJ,IAAI,EAAE,KAAK,CAAC;IACZ,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,YAAY,CAAC,OAAO,gBAAgB,CAAC,CAAC,OAAO,CAAC,CAAC;CAC7D,CAAC,EACN,CAAC,CACJ,CAAC;AAEF,eAAO,MAAM,GAAG,EAAE,CAAC,CAAC,SAAS,KAAK,CAAC,WAAW,GAAG,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,KAAK,GAWrE,CAAC"}
|
|
@@ -1,9 +1,21 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
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 indicatorVariant = cva("size-2.5 aspect-square rounded-full border-0", {
|
|
8
|
+
variants: {
|
|
9
|
+
theme: {
|
|
10
|
+
warn: "bg-warn",
|
|
11
|
+
info: "bg-info",
|
|
12
|
+
main: "bg-primary",
|
|
13
|
+
danger: "bg-danger",
|
|
14
|
+
success: "bg-success",
|
|
15
|
+
secondary: "bg-secondary",
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
});
|
|
7
19
|
const tagVariants = cva("inline-flex rounded-pill gap-1.5 text-main-foreground border-2 border-transparent items-center justify-center align-middle whitespace-nowrap", {
|
|
8
20
|
variants: {
|
|
9
21
|
size: {
|
|
@@ -14,20 +26,21 @@ const tagVariants = cva("inline-flex rounded-pill gap-1.5 text-main-foreground b
|
|
|
14
26
|
},
|
|
15
27
|
theme: {
|
|
16
28
|
raw: "",
|
|
17
|
-
main: "bg-primary-subtle text-primary-hover",
|
|
18
29
|
warn: "bg-warn-subtle text-warn-hover",
|
|
30
|
+
info: "bg-info-subtle text-info-hover",
|
|
31
|
+
main: "bg-primary-subtle text-primary-hover",
|
|
19
32
|
danger: "bg-danger-subtle text-danger-hover",
|
|
20
|
-
secondary: "bg-secondary-background text-secondary-foreground",
|
|
21
33
|
success: "bg-success-subtle text-success-hover",
|
|
22
|
-
info: "bg-info-subtle text-info-hover",
|
|
23
|
-
loading: "animate-pulse bg-disabled duration-700 opacity-70",
|
|
24
34
|
disabled: "bg-disabled duration-700 opacity-70",
|
|
35
|
+
loading: "animate-pulse bg-disabled duration-700 opacity-70",
|
|
36
|
+
secondary: "bg-secondary-background text-secondary-foreground",
|
|
37
|
+
neutral: "bg-transparent border-card-border border text-foreground",
|
|
25
38
|
},
|
|
26
39
|
},
|
|
27
40
|
defaultVariants: { theme: "main", size: "default" },
|
|
28
41
|
});
|
|
29
42
|
export const Tag = forwardRef(function Tag(_a, ref) {
|
|
30
43
|
var _b;
|
|
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 : "span", className: css(tagVariants({ size, theme }), className), children: [props.children
|
|
44
|
+
var { className, indicator = undefined, icon, loading, theme, size } = _a, props = __rest(_a, ["className", "indicator", "icon", "loading", "theme", "size"]);
|
|
45
|
+
return (_jsxs(Polymorph, Object.assign({}, props, { ref: ref, "data-theme": theme, as: (_b = props.as) !== null && _b !== void 0 ? _b : "span", className: css(tagVariants({ size, theme }), className), children: [indicator ? _jsx("span", { className: indicatorVariant({ theme: indicator }) }) : null, icon, props.children] })));
|
|
33
46
|
});
|
|
@@ -1,11 +1,42 @@
|
|
|
1
|
+
import React from "react";
|
|
1
2
|
import { Locales } from "the-mask-input";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
locale?: Locales;
|
|
6
|
-
markToday?: boolean;
|
|
7
|
-
autoFocusToday?: boolean;
|
|
8
|
-
onChange?: (d: Date | undefined) => void;
|
|
3
|
+
type Range = {
|
|
4
|
+
from?: Date;
|
|
5
|
+
to?: Date;
|
|
9
6
|
};
|
|
10
|
-
|
|
7
|
+
type OnChangeDate = (d: Date | undefined) => void;
|
|
8
|
+
type OnChangeRange = (d: Range | undefined) => void;
|
|
9
|
+
export type CalendarProps<T extends "date" | "range" | undefined = undefined> = Partial<{
|
|
10
|
+
locale: Locales;
|
|
11
|
+
markToday: boolean;
|
|
12
|
+
rangeMode: boolean;
|
|
13
|
+
changeOnlyOnClick: boolean;
|
|
14
|
+
onChangeMonth: (d: Date) => void;
|
|
15
|
+
onChangeYear: (d: Date) => void;
|
|
16
|
+
RenderOnDay: React.FC<{
|
|
17
|
+
date: Date;
|
|
18
|
+
}>;
|
|
19
|
+
disabledDate: (date: Date) => boolean;
|
|
20
|
+
styles: Partial<{
|
|
21
|
+
day: string;
|
|
22
|
+
week: string;
|
|
23
|
+
weekDay: string;
|
|
24
|
+
dayFrame: string;
|
|
25
|
+
calendar: string;
|
|
26
|
+
}>;
|
|
27
|
+
} & (T extends "date" ? {
|
|
28
|
+
date: Date;
|
|
29
|
+
onChange: OnChangeDate;
|
|
30
|
+
} : T extends "range" ? {
|
|
31
|
+
range: Range;
|
|
32
|
+
onChange: OnChangeRange;
|
|
33
|
+
} : {}) & ({
|
|
34
|
+
date: Date;
|
|
35
|
+
onChange: OnChangeDate;
|
|
36
|
+
} | {
|
|
37
|
+
range: Range;
|
|
38
|
+
onChange: OnChangeRange;
|
|
39
|
+
})>;
|
|
40
|
+
export declare const Calendar: ({ RenderOnDay, changeOnlyOnClick, disabledDate, locale, markToday, onChangeMonth, onChangeYear, rangeMode, onChange, styles, ...props }: CalendarProps) => import("react/jsx-runtime").JSX.Element;
|
|
41
|
+
export {};
|
|
11
42
|
//# 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;
|
|
1
|
+
{"version":3,"file":"calendar.d.ts","sourceRoot":"","sources":["../../../src/components/display/calendar.tsx"],"names":[],"mappings":"AAsBA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAE5D,OAAqB,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAqBvD,KAAK,KAAK,GAAG;IAAE,IAAI,CAAC,EAAE,IAAI,CAAC;IAAC,EAAE,CAAC,EAAE,IAAI,CAAA;CAAE,CAAC;AAExC,KAAK,YAAY,GAAG,CAAC,CAAC,EAAE,IAAI,GAAG,SAAS,KAAK,IAAI,CAAC;AAElD,KAAK,aAAa,GAAG,CAAC,CAAC,EAAE,KAAK,GAAG,SAAS,KAAK,IAAI,CAAC;AAEpD,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,IAAI,OAAO,CACnF;IACI,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,aAAa,EAAE,CAAC,CAAC,EAAE,IAAI,KAAK,IAAI,CAAC;IACjC,YAAY,EAAE,CAAC,CAAC,EAAE,IAAI,KAAK,IAAI,CAAC;IAChC,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC;QAAE,IAAI,EAAE,IAAI,CAAA;KAAE,CAAC,CAAC;IACtC,YAAY,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC;IACtC,MAAM,EAAE,OAAO,CAAC;QACZ,GAAG,EAAE,MAAM,CAAC;QACZ,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,QAAQ,EAAE,MAAM,CAAC;QACjB,QAAQ,EAAE,MAAM,CAAC;KACpB,CAAC,CAAC;CACN,GAAG,CAAC,CAAC,SAAS,MAAM,GAAG;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,QAAQ,EAAE,YAAY,CAAA;CAAE,GAAG,CAAC,SAAS,OAAO,GAAG;IAAE,KAAK,EAAE,KAAK,CAAC;IAAC,QAAQ,EAAE,aAAa,CAAA;CAAE,GAAG,EAAE,CAAC,GAChI,CAAC;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,QAAQ,EAAE,YAAY,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,KAAK,CAAC;IAAC,QAAQ,EAAE,aAAa,CAAA;CAAE,CAAC,CAC3F,CAAC;AAoDF,eAAO,MAAM,QAAQ,4IAYlB,aAAa,4CAgRf,CAAC"}
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import { __rest } from "tslib";
|
|
2
3
|
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 { addDays, addMonths, addWeeks, addYears, eachDayOfInterval, endOfWeek, isAfter, isBefore, isSameMonth, isToday, startOfDay, startOfMonth, startOfWeek, subDays, subMonths, subWeeks, subYears, } from "date-fns";
|
|
4
5
|
import { AnimatePresence, motion, MotionConfig } from "framer-motion";
|
|
5
6
|
import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react";
|
|
6
|
-
import { useEffect } from "react";
|
|
7
|
+
import { useEffect, useRef } from "react";
|
|
7
8
|
import { Is } from "sidekicker";
|
|
8
9
|
import TheMaskInput from "the-mask-input";
|
|
9
10
|
import { useReducer } from "use-typed-reducer";
|
|
10
11
|
import { useDebounce } from "../../hooks/use-debounce";
|
|
12
|
+
import { useTranslations } from "../../hooks/use-translate-context";
|
|
11
13
|
import { css } from "../../lib/dom";
|
|
12
|
-
import {
|
|
13
|
-
const transition = { type: "spring", bounce: 0.
|
|
14
|
-
const dir = (mod) => (n = 1) => ({ x: `${100 * mod * n}%`, opacity: 0.
|
|
14
|
+
import { splitInto } from "../../lib/fns";
|
|
15
|
+
const transition = { type: "spring", bounce: 0.3, duration: 0.6 };
|
|
16
|
+
const dir = (mod) => (n = 1) => ({ x: `${100 * mod * n}%`, opacity: 0.25 });
|
|
15
17
|
const variants = {
|
|
16
18
|
middle: { x: "0%", opacity: 1 },
|
|
17
19
|
enter: dir(1),
|
|
@@ -29,67 +31,73 @@ const getOptionsMonth = (date, locale) => Array.from({ length: 12 }).map((_, i)
|
|
|
29
31
|
return (_jsx("option", { value: label, "data-index": i, children: label }, label));
|
|
30
32
|
});
|
|
31
33
|
const onChangeUsingKeyboard = {
|
|
32
|
-
ArrowLeft: (date, duration) =>
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
},
|
|
37
|
-
ArrowRight: (date, duration) => {
|
|
38
|
-
if (duration === "days")
|
|
39
|
-
return addDays(date, 1);
|
|
40
|
-
return addMonths(date, 1);
|
|
41
|
-
},
|
|
42
|
-
ArrowUp: (date, duration) => {
|
|
43
|
-
if (duration === "days")
|
|
44
|
-
return subWeeks(date, 1);
|
|
45
|
-
return subYears(date, 1);
|
|
46
|
-
},
|
|
47
|
-
ArrowDown: (date, duration) => {
|
|
48
|
-
if (duration === "days")
|
|
49
|
-
return addWeeks(date, 1);
|
|
50
|
-
return addYears(date, 1);
|
|
51
|
-
},
|
|
34
|
+
ArrowLeft: (date, duration) => (duration === "days" ? subDays(date, 1) : subMonths(date, 1)),
|
|
35
|
+
ArrowRight: (date, duration) => (duration === "days" ? addDays(date, 1) : addMonths(date, 1)),
|
|
36
|
+
ArrowUp: (date, duration) => (duration === "days" ? subWeeks(date, 1) : subYears(date, 1)),
|
|
37
|
+
ArrowDown: (date, duration) => (duration === "days" ? addWeeks(date, 1) : addYears(date, 1)),
|
|
52
38
|
};
|
|
53
|
-
const focusDate = (next, delay = 0) => {
|
|
39
|
+
const focusDate = (origin, root, next, delay = 0) => {
|
|
54
40
|
const d = next.toISOString();
|
|
55
41
|
const select = () => {
|
|
56
|
-
|
|
57
|
-
if (
|
|
58
|
-
|
|
42
|
+
var _a;
|
|
43
|
+
if (!!(origin === null || origin === void 0 ? void 0 : origin.dataset.focustrap)) {
|
|
44
|
+
const el = (_a = root.current) === null || _a === void 0 ? void 0 : _a.querySelector(`button[data-focustrap="${origin === null || origin === void 0 ? void 0 : origin.dataset.focustrap}"]`);
|
|
45
|
+
return setTimeout(() => el === null || el === void 0 ? void 0 : el.focus({ preventScroll: false }), delay);
|
|
46
|
+
}
|
|
47
|
+
if (root.current) {
|
|
48
|
+
const element = root.current.querySelector(`button[data-date="${d}"]`);
|
|
49
|
+
if (element)
|
|
50
|
+
return element.focus({ preventScroll: false });
|
|
51
|
+
}
|
|
59
52
|
};
|
|
60
53
|
if (delay === 0)
|
|
61
54
|
select();
|
|
62
55
|
setTimeout(select, delay);
|
|
63
56
|
};
|
|
64
57
|
const formatYear = (now) => now.getFullYear().toString().padStart(4, "0");
|
|
65
|
-
|
|
58
|
+
const inRange = (start, middle, end) => {
|
|
59
|
+
if (start === undefined || end === undefined)
|
|
60
|
+
return false;
|
|
61
|
+
return isAfter(middle, start) && isBefore(middle, end);
|
|
62
|
+
};
|
|
63
|
+
export const Calendar = (_a) => {
|
|
64
|
+
var { RenderOnDay, changeOnlyOnClick = false, disabledDate, locale, markToday = true, onChangeMonth, onChangeYear, rangeMode = false, onChange, styles } = _a, props = __rest(_a, ["RenderOnDay", "changeOnlyOnClick", "disabledDate", "locale", "markToday", "onChangeMonth", "onChangeYear", "rangeMode", "onChange", "styles"]);
|
|
65
|
+
const translate = useTranslations();
|
|
66
|
+
const root = useRef(null);
|
|
67
|
+
const { date, range } = props;
|
|
66
68
|
const now = date || new Date();
|
|
69
|
+
const monthClicked = useRef(null);
|
|
67
70
|
const [state, dispatch] = useReducer({
|
|
68
71
|
date: now,
|
|
69
72
|
isAnimating: false,
|
|
70
73
|
year: formatYear(now),
|
|
71
|
-
direction: undefined,
|
|
72
74
|
months: getOptionsMonth(now, locale),
|
|
75
|
+
direction: undefined,
|
|
76
|
+
range: { from: range === null || range === void 0 ? void 0 : range.from, to: range === null || range === void 0 ? void 0 : range.to },
|
|
77
|
+
selectMode: (rangeMode ? "from" : undefined),
|
|
73
78
|
week: eachDayOfInterval({ start: startOfWeek(now), end: endOfWeek(now) }),
|
|
74
79
|
}, (get) => ({
|
|
75
80
|
onChangeYear: (year) => ({ year }),
|
|
76
81
|
setToday: () => ({ date: startOfDay(new Date()) }),
|
|
77
82
|
onExitComplete: () => {
|
|
78
|
-
focusDate(get.state().date, 200);
|
|
83
|
+
focusDate(monthClicked.current || null, root, get.state().date, 200);
|
|
84
|
+
monthClicked.current = null;
|
|
79
85
|
return { isAnimating: false };
|
|
80
86
|
},
|
|
81
87
|
date: (callback) => {
|
|
82
88
|
const newDate = callback(get.state().date);
|
|
83
89
|
return { date: newDate, year: formatYear(newDate) };
|
|
84
90
|
},
|
|
85
|
-
nextMonth: () => {
|
|
91
|
+
nextMonth: (e) => {
|
|
92
|
+
monthClicked.current = e.currentTarget;
|
|
86
93
|
const state = get.state();
|
|
87
94
|
if (state.isAnimating)
|
|
88
95
|
return state;
|
|
89
96
|
const date = addMonths(state.date, 1);
|
|
90
97
|
return { date, isAnimating: true, direction: 1, year: formatYear(date) };
|
|
91
98
|
},
|
|
92
|
-
previousMonth: () => {
|
|
99
|
+
previousMonth: (e) => {
|
|
100
|
+
monthClicked.current = e.currentTarget;
|
|
93
101
|
const state = get.state();
|
|
94
102
|
if (state.isAnimating)
|
|
95
103
|
return state;
|
|
@@ -97,41 +105,86 @@ export const Calendar = ({ locale, disabledDate, markToday = true, autoFocusToda
|
|
|
97
105
|
return { date, isAnimating: true, direction: -1, year: formatYear(date) };
|
|
98
106
|
},
|
|
99
107
|
onSelectDate: (e) => {
|
|
108
|
+
const state = get.state();
|
|
109
|
+
const isRangeMode = e.currentTarget.dataset.range === "true";
|
|
100
110
|
const d = e.currentTarget.dataset.date || "";
|
|
101
111
|
const date = new Date(d);
|
|
102
|
-
return {
|
|
112
|
+
return {
|
|
113
|
+
date,
|
|
114
|
+
year: formatYear(date),
|
|
115
|
+
selectMode: state.selectMode === undefined ? undefined : state.selectMode === "from" ? "to" : "from",
|
|
116
|
+
range: !isRangeMode
|
|
117
|
+
? state.range
|
|
118
|
+
: {
|
|
119
|
+
from: state.selectMode === "from" ? date : state.range.from,
|
|
120
|
+
to: state.selectMode === "to" ? date : state.range.to,
|
|
121
|
+
},
|
|
122
|
+
};
|
|
103
123
|
},
|
|
104
124
|
onChangeMonth: (e) => {
|
|
105
125
|
const value = e.target.value;
|
|
106
126
|
const array = Array.from(e.target.options);
|
|
107
127
|
const month = array.find((x) => x.value === value);
|
|
128
|
+
const state = get.state();
|
|
108
129
|
if (month) {
|
|
109
130
|
const i = month.dataset.index || "";
|
|
110
131
|
const d = new Date(get.state().date);
|
|
111
132
|
d.setMonth(+i);
|
|
112
|
-
return { date: d, year: formatYear(d) };
|
|
133
|
+
return Object.assign(Object.assign({}, state), { date: d, year: formatYear(d) });
|
|
113
134
|
}
|
|
114
|
-
return
|
|
135
|
+
return state;
|
|
115
136
|
},
|
|
116
137
|
onKeyDown: (e) => {
|
|
117
138
|
const key = e.key;
|
|
139
|
+
const state = get.state();
|
|
118
140
|
if (key in onChangeUsingKeyboard) {
|
|
119
141
|
if (key === "ArrowUp" || key === "ArrowDown")
|
|
120
142
|
e.preventDefault();
|
|
121
143
|
const prev = get.state().date;
|
|
122
144
|
const date = Is.keyof(onChangeUsingKeyboard, key) ? onChangeUsingKeyboard[key](prev, e.shiftKey ? "month" : "days") : null;
|
|
123
145
|
if (date !== null) {
|
|
124
|
-
focusDate(date);
|
|
125
|
-
return { date, year: formatYear(date) };
|
|
146
|
+
focusDate(e.target, root, date);
|
|
147
|
+
return Object.assign(Object.assign({}, state), { date, year: formatYear(date) });
|
|
126
148
|
}
|
|
127
149
|
}
|
|
128
150
|
return get.state();
|
|
129
151
|
},
|
|
130
|
-
})
|
|
131
|
-
|
|
152
|
+
}), {
|
|
153
|
+
props: { onChangeMonth, onChangeYear },
|
|
154
|
+
postMiddleware: [
|
|
155
|
+
(state, _, args) => {
|
|
156
|
+
var _a, _b;
|
|
157
|
+
const isValidMethod = args.method === "onChangeMonth" || args.method === "previousMonth" || args.method === "nextMonth";
|
|
158
|
+
if (isValidMethod)
|
|
159
|
+
(_b = (_a = args.props).onChangeMonth) === null || _b === void 0 ? void 0 : _b.call(_a, state.date);
|
|
160
|
+
return state;
|
|
161
|
+
},
|
|
162
|
+
(state, _, args) => {
|
|
163
|
+
var _a, _b;
|
|
164
|
+
const isValidMethod = args.method === "onChangeYear";
|
|
165
|
+
if (isValidMethod)
|
|
166
|
+
(_b = (_a = args.props).onChangeYear) === null || _b === void 0 ? void 0 : _b.call(_a, state.date);
|
|
167
|
+
return state;
|
|
168
|
+
},
|
|
169
|
+
(state, _, args) => {
|
|
170
|
+
const isValidMethod = args.method === "onSelectDate" || args.method === "setToday" || args.method === "onKeyDown";
|
|
171
|
+
if (rangeMode && isValidMethod && changeOnlyOnClick) {
|
|
172
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(state.range);
|
|
173
|
+
return state;
|
|
174
|
+
}
|
|
175
|
+
if (isValidMethod && changeOnlyOnClick)
|
|
176
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(state.date);
|
|
177
|
+
return state;
|
|
178
|
+
},
|
|
179
|
+
],
|
|
180
|
+
});
|
|
181
|
+
const zip = splitInto(createDays(state.date), 7);
|
|
132
182
|
const currentAsString = state.date.toISOString();
|
|
133
183
|
const monthString = formatMonth(state.date, locale);
|
|
134
|
-
useEffect(() =>
|
|
184
|
+
useEffect(() => {
|
|
185
|
+
if (!changeOnlyOnClick)
|
|
186
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(state.date);
|
|
187
|
+
}, [currentAsString]);
|
|
135
188
|
const defer = useDebounce((y) => {
|
|
136
189
|
dispatch.date((prev) => {
|
|
137
190
|
const d = new Date(prev);
|
|
@@ -139,19 +192,24 @@ export const Calendar = ({ locale, disabledDate, markToday = true, autoFocusToda
|
|
|
139
192
|
return d;
|
|
140
193
|
});
|
|
141
194
|
}, 1200);
|
|
142
|
-
const
|
|
195
|
+
const internalOnChangeYear = (e) => {
|
|
143
196
|
const value = e.currentTarget.value;
|
|
144
197
|
dispatch.onChangeYear(value);
|
|
198
|
+
onChangeYear === null || onChangeYear === void 0 ? void 0 : onChangeYear(new Date(value));
|
|
145
199
|
defer(value);
|
|
146
200
|
};
|
|
147
|
-
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(
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
201
|
+
return (_jsx(MotionConfig, { transition: transition, children: _jsxs("div", { ref: root, className: css("relative overflow-hidden", styles === null || styles === void 0 ? void 0 : styles.calendar), children: [_jsx("div", { className: "flex flex-col justify-center rounded text-center", children: _jsx(AnimatePresence, { initial: false, mode: "popLayout", 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, { layout: true, "data-focustrap": "prev", variants: removeImmediately, onClick: dispatch.previousMonth, className: "z-calendar rounded-full p-1.5 hover:bg-primary", children: _jsx(ChevronLeftIcon, { className: "h-4 w-4" }) }), _jsx(motion.span, { layout: true, variants: variants, custom: state.direction, className: "absolute inset-0 isolate z-normal flex items-center justify-center font-semibold", children: _jsxs("span", { className: "flex w-fit items-center justify-center gap-0.5 py-1", children: [_jsx("select", { style: { width: `${monthString.length}ch` }, value: monthString, onChange: dispatch.onChangeMonth, className: "w-fit cursor-pointer appearance-none bg-transparent capitalize proportional-nums hover:text-primary", children: state.months }), _jsx(TheMaskInput, { mask: "int", value: state.year, maxLength: 4, placeholder: "YYYY", onChange: internalOnChangeYear, style: { width: `${state.year.length}ch` }, className: "w-16 cursor-pointer appearance-none bg-transparent hover:text-primary" })] }) }), _jsx(motion.button, { layout: true, "data-focustrap": "next", variants: removeImmediately, className: "z-calendar rounded-full p-1.5 hover:bg-primary", onClick: dispatch.nextMonth, children: _jsx(ChevronRightIcon, { className: "h-4 w-4" }) }), _jsx("div", { className: "absolute inset-0", style: {
|
|
202
|
+
backgroundImage: "linear-gradient(to right, hsla(var(--card-background)) 15%, transparent 30%, transparent 70%, hsla(var(--card-background)) 85%)",
|
|
203
|
+
} })] }), _jsxs(motion.table, { className: "mt-2 table min-w-full table-auto border-0", children: [_jsx("thead", { children: _jsx("tr", { children: state.week.map((dayOfWeek) => (_jsx("th", { className: css("py-2 text-sm font-medium capitalize", styles === null || styles === void 0 ? void 0 : styles.weekDay), children: dayOfWeek.toLocaleDateString(locale, { weekday: "short" }) }, dayOfWeek.toString()))) }) }), _jsx(motion.tbody, { layout: true, variants: variants, custom: state.direction, onKeyDown: dispatch.onKeyDown, className: css(styles === null || styles === void 0 ? void 0 : styles.week), children: zip.map((week, index) => (_jsx("tr", { className: styles === null || styles === void 0 ? void 0 : styles.week, children: week.map((day) => {
|
|
204
|
+
var _a, _b, _c, _d;
|
|
205
|
+
const key = day.toISOString();
|
|
206
|
+
const isSelected = rangeMode
|
|
207
|
+
? key === ((_a = range === null || range === void 0 ? void 0 : range.to) === null || _a === void 0 ? void 0 : _a.toISOString()) || key === ((_b = range === null || range === void 0 ? void 0 : range.from) === null || _b === void 0 ? void 0 : _b.toISOString())
|
|
208
|
+
: key === (date === null || date === void 0 ? void 0 : date.toISOString());
|
|
209
|
+
const today = isToday(day) && markToday;
|
|
210
|
+
const disabledByFn = (disabledDate === null || disabledDate === void 0 ? void 0 : disabledDate(day)) || false;
|
|
211
|
+
const disableDate = !isSameMonth(day, state.date) || disabledByFn;
|
|
212
|
+
const isInRange = rangeMode ? inRange(range === null || range === void 0 ? void 0 : range.from, day, range === null || range === void 0 ? void 0 : range.to) : false;
|
|
213
|
+
return (_jsxs("td", { align: "center", className: css("relative", styles === null || styles === void 0 ? void 0 : styles.dayFrame), children: [_jsxs("button", { type: "button", "data-date": key, disabled: disabledByFn, "data-range": rangeMode, onClick: dispatch.onSelectDate, "data-view": state.date.getMonth().toString(), className: css(`flex size-10 items-center justify-center rounded-full font-semibold proportional-nums disabled:cursor-not-allowed ${today ? "text-primary" : ""} ${disableDate ? "text-disabled" : ""} ${isSelected ? "bg-primary text-primary-foreground" : ""}`, styles === null || styles === void 0 ? void 0 : styles.day, isInRange ? "size-10 border border-dashed border-card-border" : ""), children: [day.getDate(), isSelected && ((_c = state.range.from) === null || _c === void 0 ? void 0 : _c.toISOString()) === key ? (_jsx("span", { className: "absolute -top-2 left-0 h-full w-full", children: _jsx("span", { className: "text-xs", children: translate.calendarFromDate }) })) : null, isSelected && ((_d = state.range.to) === null || _d === void 0 ? void 0 : _d.toISOString()) === key ? (_jsx("span", { className: "absolute -top-2 left-0 h-full w-full", children: _jsx("span", { className: "text-xs", children: translate.calendarToDate }) })) : null] }), RenderOnDay ? _jsx(RenderOnDay, { date: day }) : null] }, key));
|
|
214
|
+
}) }, `week-${week.length}-${index}`))) })] })] }, monthString) }) }), _jsx("footer", { className: "mt-2 text-center text-primary", children: _jsx("button", { className: "duration-300 transition-transform hover:scale-105", type: "button", onClick: dispatch.setToday, children: "Today" }) })] }) }));
|
|
157
215
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/components/display/list.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,EAAY,iBAAiB,EAAgC,MAAM,OAAO,CAAC;AACzF,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,KAAK,iBAAiB,GAAG;IACrB,KAAK,EAAE,KAAK,CAAC;IACb,WAAW,EAAE,KAAK,CAAC;IACnB,QAAQ,EAAE,KAAK,CAAC;IAChB,MAAM,CAAC,EAAE,KAAK,CAAC;IACf,OAAO,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC;QAAE,IAAI,EAAE,MAAM,IAAI,CAAA;KAAE,CAAC,CAAC;CAC5C,CAAC;AAIF,KAAK,iBAAiB,GAAG,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/components/display/list.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,EAAY,iBAAiB,EAAgC,MAAM,OAAO,CAAC;AACzF,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,KAAK,iBAAiB,GAAG;IACrB,KAAK,EAAE,KAAK,CAAC;IACb,WAAW,EAAE,KAAK,CAAC;IACnB,QAAQ,EAAE,KAAK,CAAC;IAChB,MAAM,CAAC,EAAE,KAAK,CAAC;IACf,OAAO,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC;QAAE,IAAI,EAAE,MAAM,IAAI,CAAA;KAAE,CAAC,CAAC;CAC5C,CAAC;AAIF,KAAK,iBAAiB,GAAG,EAAE,CAAC;AA2D5B,eAAO,MAAM,YAAY,UAAW,iBAAiB,CAAC,iBAAiB,CAAC,4CAoEvE,CAAC;AAEF,eAAO,MAAM,gBAAgB,UAAW,iBAAiB,CAAC,iBAAiB,CAAC,4CAA0C,CAAC"}
|
|
@@ -3,9 +3,7 @@ import { FloatingFocusManager, FloatingOverlay, FloatingPortal, useClick, useDis
|
|
|
3
3
|
import { AnimatePresence, motion, MotionConfig } from "framer-motion";
|
|
4
4
|
import { XIcon } from "lucide-react";
|
|
5
5
|
import React, { Fragment, useCallback, useId, useState } from "react";
|
|
6
|
-
const FloatItem = ({ item, context, setter, get, refs }) => {
|
|
7
|
-
return (_jsx(FloatingPortal, { children: _jsx(MotionConfig, { reducedMotion: "user", transition: { type: "tween", stiffness: 25, duration: 0.2 }, children: _jsxs(AnimatePresence, { presenceAffectsLayout: true, children: [_jsx(AnimatePresence, { children: item ? (_jsx(motion.div, { initial: { opacity: 0 }, animate: { opacity: 1 }, exit: { opacity: 0 }, className: "pointer-events-none fixed inset-0 top-0 z-floating h-screen w-screen bg-floating-overlay/70" })) : null }), _jsx(AnimatePresence, { children: item ? (_jsx(FloatingOverlay, { lockScroll: true, className: "absolute inset-0 z-tooltip flex items-center justify-center", children: _jsx(FloatingFocusManager, { visuallyHiddenDismiss: true, modal: true, closeOnFocusOut: true, context: context, children: _jsxs(motion.div, Object.assign({ layout: true, layoutId: `item-${item.id}`, className: "relative flex h-min w-min min-w-xs flex-col gap-4 rounded-card border border-card-border bg-card-background p-6 py-4 pb-8 shadow", ref: refs.setFloating }, get(), { children: [_jsx("nav", { className: "absolute right-4 top-1 lg:right-2", children: _jsx("button", { type: "button", onClick: setter, className: "p-1 opacity-70 transition-colors hover:text-danger hover:opacity-100 focus:text-danger", children: _jsx(XIcon, {}) }) }), _jsxs("header", { className: "flex w-full flex-wrap items-center justify-between gap-2", children: [_jsx("h3", { className: "min-w-full text-balance text-2xl font-medium", children: item.title }), _jsx("p", { className: "text-sm leading-snug text-secondary", children: item.description })] }), item.children] })) }) })) : null })] }) }) }));
|
|
8
|
-
};
|
|
6
|
+
const FloatItem = ({ item, context, setter, get, refs }) => (_jsx(FloatingPortal, { children: _jsx(MotionConfig, { reducedMotion: "user", transition: { type: "tween", stiffness: 25, duration: 0.2 }, children: _jsxs(AnimatePresence, { presenceAffectsLayout: true, children: [_jsx(AnimatePresence, { children: item ? (_jsx(motion.div, { initial: { opacity: 0 }, animate: { opacity: 1 }, exit: { opacity: 0 }, className: "pointer-events-none fixed inset-0 top-0 z-floating h-screen w-screen bg-floating-overlay/70" })) : null }), _jsx(AnimatePresence, { children: item ? (_jsx(FloatingOverlay, { lockScroll: true, className: "absolute inset-0 z-tooltip flex items-center justify-center", children: _jsx(FloatingFocusManager, { visuallyHiddenDismiss: true, modal: true, closeOnFocusOut: true, context: context, children: _jsxs(motion.div, Object.assign({ layout: true, layoutId: `item-${item.id}`, className: "relative flex h-min w-min min-w-xs flex-col gap-4 rounded-card border border-card-border bg-card-background p-6 py-4 pb-8 shadow", ref: refs.setFloating }, get(), { children: [_jsx("nav", { className: "absolute right-4 top-1 lg:right-2", children: _jsx("button", { type: "button", onClick: setter, className: "p-1 opacity-70 transition-colors hover:text-danger hover:opacity-100 focus:text-danger", children: _jsx(XIcon, {}) }) }), _jsxs("header", { className: "flex w-full flex-wrap items-center justify-between gap-2", children: [_jsx("h3", { className: "min-w-full text-balance text-2xl font-medium", children: item.title }), _jsx("p", { className: "text-sm leading-snug text-secondary", children: item.description })] }), item.children] })) }) })) : null })] }) }) }));
|
|
9
7
|
export const AnimatedList = (props) => {
|
|
10
8
|
const [selected, setSelected] = useState(null);
|
|
11
9
|
const id = useId();
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
declare const typeMap: {
|
|
3
|
+
tag: () => null;
|
|
4
|
+
custom: () => null;
|
|
5
|
+
record: ({ item }: {
|
|
6
|
+
item: TimelineItemProps;
|
|
7
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
};
|
|
9
|
+
export type TimelineItemType = keyof typeof typeMap;
|
|
10
|
+
export type TimelineItemProps = {
|
|
11
|
+
id: string | number;
|
|
12
|
+
date: Date;
|
|
13
|
+
type: TimelineItemType;
|
|
14
|
+
avatar?: {
|
|
15
|
+
img?: string;
|
|
16
|
+
name: string;
|
|
17
|
+
profile?: string;
|
|
18
|
+
};
|
|
19
|
+
text?: string;
|
|
20
|
+
custom?: React.FC<{
|
|
21
|
+
item: TimelineItemProps;
|
|
22
|
+
}>;
|
|
23
|
+
};
|
|
24
|
+
export type TimelineProps = {
|
|
25
|
+
items: TimelineItemProps[];
|
|
26
|
+
Custom?: React.FC<{
|
|
27
|
+
item: TimelineItemProps;
|
|
28
|
+
}>;
|
|
29
|
+
};
|
|
30
|
+
export declare const Timeline: (props: TimelineProps) => import("react/jsx-runtime").JSX.Element;
|
|
31
|
+
export {};
|
|
32
|
+
//# sourceMappingURL=timeline.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timeline.d.ts","sourceRoot":"","sources":["../../../src/components/display/timeline.tsx"],"names":[],"mappings":"AACA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,QAAA,MAAM,OAAO;;;;cA4B+B,iBAAiB;;CAAI,CAAC;AAElE,MAAM,MAAM,gBAAgB,GAAG,MAAM,OAAO,OAAO,CAAC;AAEpD,MAAM,MAAM,iBAAiB,GAAG;IAC5B,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,IAAI,EAAE,IAAI,CAAC;IACX,IAAI,EAAE,gBAAgB,CAAC;IACvB,MAAM,CAAC,EAAE;QAAE,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC1D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC;QAAE,IAAI,EAAE,iBAAiB,CAAA;KAAE,CAAC,CAAC;CAClD,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAAE,KAAK,EAAE,iBAAiB,EAAE,CAAC;IAAC,MAAM,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC;QAAE,IAAI,EAAE,iBAAiB,CAAA;KAAE,CAAC,CAAA;CAAE,CAAC;AAE3G,eAAO,MAAM,QAAQ,UAAW,aAAa,4CAyB5C,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { MessagesSquareIcon } from "lucide-react";
|
|
3
|
+
import { Fragment } from "react";
|
|
4
|
+
const typeMap = {
|
|
5
|
+
tag: () => null,
|
|
6
|
+
custom: () => null,
|
|
7
|
+
record: ({ item }) => {
|
|
8
|
+
var _a, _b, _c, _d;
|
|
9
|
+
return (_jsxs(Fragment, { children: [_jsxs("div", { className: "relative", children: [_jsx("img", { src: (_a = item.avatar) === null || _a === void 0 ? void 0 : _a.img, alt: (_b = item.avatar) === null || _b === void 0 ? void 0 : _b.name, className: "flex aspect-square size-12 items-center justify-center rounded-full bg-primary-hover" }), _jsx("span", { className: "absolute -bottom-0.5 -right-1 rounded-full rounded-tl bg-card-background px-0.5 py-px", children: _jsx(MessagesSquareIcon, { "aria-hidden": "true", className: "aspect-square size-5" }) })] }), _jsxs("div", { className: "min-w-0 flex-1 text-foreground", children: [_jsxs("div", { children: [_jsx("a", { href: (_c = item.avatar) === null || _c === void 0 ? void 0 : _c.profile, className: "text-base font-medium text-primary", children: (_d = item.avatar) === null || _d === void 0 ? void 0 : _d.name }), _jsxs("p", { className: "mt-0.5 text-sm", children: ["Commented ", item.date.toISOString()] })] }), _jsx("div", { className: "mt-2 text-wrap text-sm", children: _jsx("p", { children: item.text }) })] })] }));
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
export const Timeline = (props) => {
|
|
13
|
+
return (_jsx("div", { className: "flow-root", children: _jsx("ul", { role: "list", className: "-mb-8", children: props.items.map((item, index) => {
|
|
14
|
+
var _a;
|
|
15
|
+
const Render = (_a = typeMap[item.type]) !== null && _a !== void 0 ? _a : null;
|
|
16
|
+
if (Render === null && props.Custom) {
|
|
17
|
+
return _jsx(props.Custom, { item: item });
|
|
18
|
+
}
|
|
19
|
+
return (_jsx("li", { children: _jsxs("div", { className: "relative pb-8", children: [index !== props.items.length - 1 ? (_jsx("span", { "aria-hidden": "true", className: "absolute left-5 top-5 -ml-px h-full w-0.5 bg-card-border" })) : null, _jsx("div", { className: "relative flex items-start space-x-3", children: _jsx(Render, { item: item }) })] }) }, item.id));
|
|
20
|
+
}) }) }));
|
|
21
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dropdown.d.ts","sourceRoot":"","sources":["../../../src/components/floating/dropdown.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,EAAY,iBAAiB,EAAoC,MAAM,OAAO,CAAC;AAE7F,KAAK,aAAa,GAAG;IACjB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,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;IACtD,WAAW,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;CAChD,CAAC;AAEF,eAAO,MAAM,QAAQ,UAAW,iBAAiB,CAAC,aAAa,CAAC,
|
|
1
|
+
{"version":3,"file":"dropdown.d.ts","sourceRoot":"","sources":["../../../src/components/floating/dropdown.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,EAAY,iBAAiB,EAAoC,MAAM,OAAO,CAAC;AAE7F,KAAK,aAAa,GAAG;IACjB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,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;IACtD,WAAW,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;CAChD,CAAC;AAEF,eAAO,MAAM,QAAQ,UAAW,iBAAiB,CAAC,aAAa,CAAC,4CAoE/D,CAAC"}
|
|
@@ -3,7 +3,6 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { arrow, autoUpdate, flip, FloatingArrow, FloatingFocusManager, FloatingPortal, offset, shift, useClick, useDismiss, useFloating, useInteractions, useRole, } from "@floating-ui/react";
|
|
4
4
|
import { Fragment, useId, useMemo, useRef, useState } from "react";
|
|
5
5
|
export const Dropdown = (props) => {
|
|
6
|
-
var _a, _b;
|
|
7
6
|
const headingId = useId();
|
|
8
7
|
const [open, setOpen] = useState(props.open);
|
|
9
8
|
const arrowRef = useRef(null);
|
|
@@ -36,5 +35,5 @@ export const Dropdown = (props) => {
|
|
|
36
35
|
const dismiss = useDismiss(context);
|
|
37
36
|
const role = useRole(context);
|
|
38
37
|
const { getReferenceProps, getFloatingProps } = useInteractions([click, dismiss, role]);
|
|
39
|
-
return (_jsxs(Fragment, { children: [_jsx("button", Object.assign({ ref: refs.setReference }, getReferenceProps(props.buttonProps), { type: "button", children: props.trigger })), open && (_jsx(FloatingPortal, { id: `${headingId}-portal`, children: _jsx(FloatingFocusManager, {
|
|
38
|
+
return (_jsxs(Fragment, { children: [_jsx("button", Object.assign({ ref: refs.setReference }, getReferenceProps(props.buttonProps), { type: "button", children: props.trigger })), open && (_jsx(FloatingPortal, { preserveTabOrder: true, id: `${headingId}-portal`, children: _jsx(FloatingFocusManager, { guards: true, restoreFocus: true, returnFocus: true, visuallyHiddenDismiss: true, context: context, modal: false, children: _jsxs("div", Object.assign({ className: "relative isolate z-floating min-w-96 rounded-lg border border-floating-border bg-floating-background p-6 shadow-2xl", 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: "text-left text-2xl font-medium leading-snug tracking-wide", children: props.title }) }), props.children] })) }) }))] }));
|
|
40
39
|
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { motion } from "framer-motion";
|
|
2
|
+
import { PropsWithChildren } from "react";
|
|
3
|
+
import { Label, Override } from "../../types";
|
|
4
|
+
import { ButtonProps } from "../core/button";
|
|
5
|
+
export type ExpandProps = Override<ButtonProps<typeof motion.button>, {
|
|
6
|
+
trigger: Label;
|
|
7
|
+
}>;
|
|
8
|
+
export declare const Expand: (props: PropsWithChildren<ExpandProps>) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
//# sourceMappingURL=expand.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expand.d.ts","sourceRoot":"","sources":["../../../src/components/floating/expand.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAmB,MAAM,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAA2B,MAAM,OAAO,CAAC;AACnE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAU,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAErD,MAAM,MAAM,WAAW,GAAG,QAAQ,CAAC,WAAW,CAAC,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE;IAAE,OAAO,EAAE,KAAK,CAAA;CAAE,CAAC,CAAC;AAE1F,eAAO,MAAM,MAAM,UAAW,iBAAiB,CAAC,WAAW,CAAC,4CA4C3D,CAAC"}
|