@g4rcez/components 0.0.45 → 0.0.46
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/preset.tailwind.js +1 -1
- package/dist/src/components/core/button.js +2 -5
- package/dist/src/components/core/polymorph.js +2 -4
- package/dist/src/components/core/tag.js +2 -5
- package/dist/src/components/display/alert.js +3 -6
- package/dist/src/components/display/calendar.js +20 -26
- package/dist/src/components/display/card.js +1 -5
- package/dist/src/components/display/list.js +2 -2
- package/dist/src/components/display/notifications.js +3 -4
- package/dist/src/components/display/step.js +2 -2
- package/dist/src/components/display/timeline.js +2 -6
- package/dist/src/components/floating/dropdown.js +3 -4
- package/dist/src/components/floating/expand.js +1 -1
- package/dist/src/components/floating/menu.js +28 -29
- package/dist/src/components/floating/modal.js +4 -6
- package/dist/src/components/floating/tooltip.js +2 -4
- package/dist/src/components/form/autocomplete.js +46 -47
- package/dist/src/components/form/checkbox.js +1 -5
- package/dist/src/components/form/date-picker.js +5 -8
- package/dist/src/components/form/file-upload.js +5 -10
- package/dist/src/components/form/form.js +2 -3
- package/dist/src/components/form/input-field.js +2 -2
- package/dist/src/components/form/input.js +3 -6
- package/dist/src/components/form/radiobox.js +1 -5
- package/dist/src/components/form/select.js +4 -10
- package/dist/src/components/form/switch.js +6 -10
- package/dist/src/components/form/task-list.js +1 -1
- package/dist/src/components/form/transfer-list.js +2 -2
- package/dist/src/components/table/filter.js +7 -8
- package/dist/src/components/table/group.js +3 -5
- package/dist/src/components/table/index.js +27 -45
- package/dist/src/components/table/metadata.js +5 -1
- package/dist/src/components/table/pagination.js +3 -4
- package/dist/src/components/table/sort.js +2 -2
- package/dist/src/components/table/table-lib.js +13 -16
- package/dist/src/components/table/thead.js +2 -3
- package/dist/src/hooks/use-form.js +48 -20
- package/dist/src/hooks/use-translate-context.js +1 -1
- package/dist/src/lib/dom.js +1 -1
- package/dist/src/styles/design-tokens.js +5 -2
- package/package.json +5 -5
package/dist/preset.tailwind.js
CHANGED
|
@@ -18,7 +18,7 @@ const config = {
|
|
|
18
18
|
fill: COLORS,
|
|
19
19
|
colors: COLORS,
|
|
20
20
|
placeholderColor: COLORS,
|
|
21
|
-
borderColors:
|
|
21
|
+
borderColors: { ...COLORS, DEFAULT: COLORS.card.border },
|
|
22
22
|
zIndex: {
|
|
23
23
|
normal: "1",
|
|
24
24
|
tooltip: "13",
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { __rest } from "tslib";
|
|
2
1
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
2
|
import { cva } from "class-variance-authority";
|
|
4
3
|
import { forwardRef } from "react";
|
|
@@ -41,9 +40,7 @@ const buttonVariants = cva("relative overflow-hidden inline-flex duration-500 en
|
|
|
41
40
|
},
|
|
42
41
|
defaultVariants: { theme: "main", size: "default", rounded: "default" },
|
|
43
42
|
});
|
|
44
|
-
export const Button = forwardRef(function Button(
|
|
45
|
-
var _b;
|
|
46
|
-
var { className, icon, loading, theme, type = "button", size, rounded } = _a, props = __rest(_a, ["className", "icon", "loading", "theme", "type", "size", "rounded"]);
|
|
43
|
+
export const Button = forwardRef(function Button({ className, icon, loading, theme, type = "button", size, rounded, ...props }, ref) {
|
|
47
44
|
const disabled = loading || props.disabled;
|
|
48
|
-
return (_jsxs(Polymorph,
|
|
45
|
+
return (_jsxs(Polymorph, { ...props, ref: ref, type: type, "data-theme": theme, "data-loading": loading, disabled: disabled, "aria-busy": disabled || loading, as: props.as ?? "button", onClick: disabled ? undefined : props.onClick, className: css(buttonVariants({ size, rounded, theme }), className), children: [icon, props.children] }));
|
|
49
46
|
});
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { __rest } from "tslib";
|
|
2
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
2
|
import { forwardRef } from "react";
|
|
4
|
-
export const Polymorph = forwardRef(function Polymorph(
|
|
5
|
-
var { as } = _a, props = __rest(_a, ["as"]);
|
|
3
|
+
export const Polymorph = forwardRef(function Polymorph({ as, ...props }, ref) {
|
|
6
4
|
const Component = as || "span";
|
|
7
|
-
return _jsx(Component,
|
|
5
|
+
return _jsx(Component, { ...props, ref: ref });
|
|
8
6
|
});
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { __rest } from "tslib";
|
|
2
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
2
|
import { cva } from "class-variance-authority";
|
|
4
3
|
import { forwardRef } from "react";
|
|
@@ -38,8 +37,6 @@ const tagVariants = cva("inline-flex rounded-pill gap-1.5 border-2 border-transp
|
|
|
38
37
|
},
|
|
39
38
|
defaultVariants: { theme: "primary", size: "default" },
|
|
40
39
|
});
|
|
41
|
-
export const Tag = forwardRef(function Tag(
|
|
42
|
-
|
|
43
|
-
var { className, indicator = undefined, icon, loading, theme, size } = _a, props = __rest(_a, ["className", "indicator", "icon", "loading", "theme", "size"]);
|
|
44
|
-
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] })));
|
|
40
|
+
export const Tag = forwardRef(function Tag({ className, indicator = undefined, icon, loading, theme, size, ...props }, ref) {
|
|
41
|
+
return (_jsxs(Polymorph, { ...props, ref: ref, "data-theme": theme, as: props.as ?? "span", className: css(tagVariants({ size, theme }), className), children: [indicator ? _jsx("span", { className: indicatorVariant({ theme: indicator }) }) : null, icon, props.children] }));
|
|
45
42
|
});
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { __rest } from "tslib";
|
|
2
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
2
|
import { cva } from "class-variance-authority";
|
|
4
3
|
import { motion } from "framer-motion";
|
|
@@ -15,7 +14,7 @@ const transition = {
|
|
|
15
14
|
duration: 0.7,
|
|
16
15
|
ease: [0.04, 0.62, 0.23, 0.98],
|
|
17
16
|
};
|
|
18
|
-
export const Collapse = (props) => (_jsx(motion.div,
|
|
17
|
+
export const Collapse = (props) => (_jsx(motion.div, { ...props, layout: true, layoutRoot: true, layoutScroll: true, initial: false, animate: props.open.toString(), "aria-hidden": !props.open, className: props.className, exit: variants.false, transition: transition, variants: variants, children: props.children }));
|
|
19
18
|
const alertVariants = cva("p-4 w-full block border relative rounded-lg text-sm", {
|
|
20
19
|
variants: {
|
|
21
20
|
theme: {
|
|
@@ -30,8 +29,6 @@ const alertVariants = cva("p-4 w-full block border relative rounded-lg text-sm",
|
|
|
30
29
|
},
|
|
31
30
|
defaultVariants: { theme: "neutral" },
|
|
32
31
|
});
|
|
33
|
-
export const Alert = forwardRef(function Alert(
|
|
34
|
-
|
|
35
|
-
var { className, theme, Icon, onClose, open = true } = _a, props = __rest(_a, ["className", "theme", "Icon", "onClose", "open"]);
|
|
36
|
-
return (_jsx("div", { "data-open": !!open, "aria-hidden": !open, className: "pointer-events-none w-full isolate data-[open=true]:pointer-events-auto data-[open=true]:mb-4", children: _jsx(Collapse, { "data-open": !!open, open: !!open, children: _jsxs(Polymorph, Object.assign({}, props, { className: css(alertVariants({ theme }), className), ref: ref, "data-theme": theme, role: "alert", as: (_b = props.as) !== null && _b !== void 0 ? _b : "div", children: [_jsxs("h4", { className: "mb-2 flex items-center gap-2", children: [!Icon && theme === "success" ? _jsx(CheckCircleIcon, { size: 20 }) : null, !Icon && theme === "info" ? _jsx(InfoIcon, { size: 20 }) : null, !Icon && theme === "danger" ? _jsx(TriangleAlertIcon, { size: 20 }) : null, Icon, _jsx("span", { className: "tracking-3 text-balance text-lg font-semibold", children: props.title })] }), props.children, onClose !== undefined ? (_jsx("button", { type: "button", onClick: () => onClose(false), className: "absolute right-3 top-3 text-foreground transition-colors duration-300 ease-in-out hover:text-danger", children: _jsx(XIcon, { size: 20 }) })) : null] })) }) }));
|
|
32
|
+
export const Alert = forwardRef(function Alert({ className, theme, Icon, onClose, open = true, ...props }, ref) {
|
|
33
|
+
return (_jsx("div", { "data-open": !!open, "aria-hidden": !open, className: "pointer-events-none w-full isolate data-[open=true]:pointer-events-auto data-[open=true]:mb-4", children: _jsx(Collapse, { "data-open": !!open, open: !!open, children: _jsxs(Polymorph, { ...props, className: css(alertVariants({ theme }), className), ref: ref, "data-theme": theme, role: "alert", as: props.as ?? "div", children: [_jsxs("h4", { className: "mb-2 flex items-center gap-2", children: [!Icon && theme === "success" ? _jsx(CheckCircleIcon, { size: 20 }) : null, !Icon && theme === "info" ? _jsx(InfoIcon, { size: 20 }) : null, !Icon && theme === "danger" ? _jsx(TriangleAlertIcon, { size: 20 }) : null, Icon, _jsx("span", { className: "tracking-3 text-balance text-lg font-semibold", children: props.title })] }), props.children, onClose !== undefined ? (_jsx("button", { type: "button", onClick: () => onClose(false), className: "absolute right-3 top-3 text-foreground transition-colors duration-300 ease-in-out hover:text-danger", children: _jsx(XIcon, { size: 20 }) })) : null] }) }) }));
|
|
37
34
|
});
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { __rest } from "tslib";
|
|
3
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
3
|
import { addDays, addMonths, addWeeks, addYears, eachDayOfInterval, endOfWeek, isAfter, isBefore, isSameMonth, isToday, startOfDay, startOfMonth, startOfWeek, subDays, subMonths, subWeeks, subYears, } from "date-fns";
|
|
5
4
|
import { AnimatePresence, motion, MotionConfig } from "framer-motion";
|
|
@@ -39,10 +38,9 @@ const onChangeUsingKeyboard = {
|
|
|
39
38
|
const focusDate = (origin, root, next, delay = 0) => {
|
|
40
39
|
const d = next.toISOString();
|
|
41
40
|
const select = () => {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
return setTimeout(() => el === null || el === void 0 ? void 0 : el.focus({ preventScroll: false }), delay);
|
|
41
|
+
if (!!origin?.dataset.focustrap) {
|
|
42
|
+
const el = root.current?.querySelector(`button[data-focustrap="${origin?.dataset.focustrap}"]`);
|
|
43
|
+
return setTimeout(() => el?.focus({ preventScroll: false }), delay);
|
|
46
44
|
}
|
|
47
45
|
if (root.current) {
|
|
48
46
|
const element = root.current.querySelector(`button[data-date="${d}"]`);
|
|
@@ -60,8 +58,7 @@ const inRange = (start, middle, end) => {
|
|
|
60
58
|
return false;
|
|
61
59
|
return isAfter(middle, start) && isBefore(middle, end);
|
|
62
60
|
};
|
|
63
|
-
export const Calendar = (
|
|
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"]);
|
|
61
|
+
export const Calendar = ({ RenderOnDay, changeOnlyOnClick = false, disabledDate, locale, markToday = true, onChangeMonth, onChangeYear, rangeMode = false, onChange, styles, ...props }) => {
|
|
65
62
|
const translate = useTranslations();
|
|
66
63
|
const root = useRef(null);
|
|
67
64
|
const { date, range } = props;
|
|
@@ -73,7 +70,7 @@ export const Calendar = (_a) => {
|
|
|
73
70
|
year: formatYear(now),
|
|
74
71
|
months: getOptionsMonth(now, locale),
|
|
75
72
|
direction: undefined,
|
|
76
|
-
range: { from: range
|
|
73
|
+
range: { from: range?.from, to: range?.to },
|
|
77
74
|
selectMode: (rangeMode ? "from" : undefined),
|
|
78
75
|
week: eachDayOfInterval({ start: startOfWeek(now), end: endOfWeek(now) }),
|
|
79
76
|
}, (get) => ({
|
|
@@ -130,7 +127,7 @@ export const Calendar = (_a) => {
|
|
|
130
127
|
const i = month.dataset.index || "";
|
|
131
128
|
const d = new Date(get.state().date);
|
|
132
129
|
d.setMonth(+i);
|
|
133
|
-
return
|
|
130
|
+
return { ...state, date: d, year: formatYear(d) };
|
|
134
131
|
}
|
|
135
132
|
return state;
|
|
136
133
|
},
|
|
@@ -144,7 +141,7 @@ export const Calendar = (_a) => {
|
|
|
144
141
|
const date = Is.keyof(onChangeUsingKeyboard, key) ? onChangeUsingKeyboard[key](prev, e.shiftKey ? "month" : "days") : null;
|
|
145
142
|
if (date !== null) {
|
|
146
143
|
focusDate(e.target, root, date);
|
|
147
|
-
return
|
|
144
|
+
return { ...state, date, year: formatYear(date) };
|
|
148
145
|
}
|
|
149
146
|
}
|
|
150
147
|
return get.state();
|
|
@@ -153,27 +150,25 @@ export const Calendar = (_a) => {
|
|
|
153
150
|
props: { onChangeMonth, onChangeYear },
|
|
154
151
|
postMiddleware: [
|
|
155
152
|
(state, _, args) => {
|
|
156
|
-
var _a, _b;
|
|
157
153
|
const isValidMethod = args.method === "onChangeMonth" || args.method === "previousMonth" || args.method === "nextMonth";
|
|
158
154
|
if (isValidMethod)
|
|
159
|
-
|
|
155
|
+
args.props.onChangeMonth?.(state.date);
|
|
160
156
|
return state;
|
|
161
157
|
},
|
|
162
158
|
(state, _, args) => {
|
|
163
|
-
var _a, _b;
|
|
164
159
|
const isValidMethod = args.method === "onChangeYear";
|
|
165
160
|
if (isValidMethod)
|
|
166
|
-
|
|
161
|
+
args.props.onChangeYear?.(state.date);
|
|
167
162
|
return state;
|
|
168
163
|
},
|
|
169
164
|
(state, _, args) => {
|
|
170
165
|
const isValidMethod = args.method === "onSelectDate" || args.method === "setToday" || args.method === "onKeyDown";
|
|
171
166
|
if (rangeMode && isValidMethod && changeOnlyOnClick) {
|
|
172
|
-
onChange
|
|
167
|
+
onChange?.(state.range);
|
|
173
168
|
return state;
|
|
174
169
|
}
|
|
175
170
|
if (isValidMethod && changeOnlyOnClick)
|
|
176
|
-
onChange
|
|
171
|
+
onChange?.(state.date);
|
|
177
172
|
return state;
|
|
178
173
|
},
|
|
179
174
|
],
|
|
@@ -183,7 +178,7 @@ export const Calendar = (_a) => {
|
|
|
183
178
|
const monthString = formatMonth(state.date, locale);
|
|
184
179
|
useEffect(() => {
|
|
185
180
|
if (!changeOnlyOnClick)
|
|
186
|
-
onChange
|
|
181
|
+
onChange?.(state.date);
|
|
187
182
|
}, [currentAsString]);
|
|
188
183
|
const defer = useDebounce((y) => {
|
|
189
184
|
dispatch.date((prev) => {
|
|
@@ -195,21 +190,20 @@ export const Calendar = (_a) => {
|
|
|
195
190
|
const internalOnChangeYear = (e) => {
|
|
196
191
|
const value = e.currentTarget.value;
|
|
197
192
|
dispatch.onChangeYear(value);
|
|
198
|
-
onChangeYear
|
|
193
|
+
onChangeYear?.(new Date(value));
|
|
199
194
|
defer(value);
|
|
200
195
|
};
|
|
201
|
-
return (_jsx(MotionConfig, { transition: transition, children: _jsxs("div", { ref: root, className: css("relative overflow-hidden", styles
|
|
196
|
+
return (_jsx(MotionConfig, { transition: transition, children: _jsxs("div", { ref: root, className: css("relative overflow-hidden", 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
197
|
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
|
|
204
|
-
var _a, _b, _c, _d;
|
|
198
|
+
} })] }), _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?.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?.week), children: zip.map((week, index) => (_jsx("tr", { className: styles?.week, children: week.map((day) => {
|
|
205
199
|
const key = day.toISOString();
|
|
206
200
|
const isSelected = rangeMode
|
|
207
|
-
? key ===
|
|
208
|
-
: key ===
|
|
201
|
+
? key === range?.to?.toISOString() || key === range?.from?.toISOString()
|
|
202
|
+
: key === date?.toISOString();
|
|
209
203
|
const today = isToday(day) && markToday;
|
|
210
|
-
const disabledByFn =
|
|
204
|
+
const disabledByFn = disabledDate?.(day) || false;
|
|
211
205
|
const disableDate = !isSameMonth(day, state.date) || disabledByFn;
|
|
212
|
-
const isInRange = rangeMode ? inRange(range
|
|
213
|
-
return (_jsxs("td", { align: "center", className: css("relative", styles
|
|
206
|
+
const isInRange = rangeMode ? inRange(range?.from, day, range?.to) : false;
|
|
207
|
+
return (_jsxs("td", { align: "center", className: css("relative", 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?.day, isInRange ? "size-10 border border-dashed border-card-border" : ""), children: [day.getDate(), isSelected && state.range.from?.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 && state.range.to?.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
208
|
}) }, `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" }) })] }) }));
|
|
215
209
|
};
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import { __rest } from "tslib";
|
|
2
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
2
|
import { css } from "../../lib/dom";
|
|
4
3
|
import { Polymorph } from "../core/polymorph";
|
|
5
|
-
export const Card = (
|
|
6
|
-
var { children, title, as = "div", container = "", header = null, className = "" } = _a, props = __rest(_a, ["children", "title", "as", "container", "header", "className"]);
|
|
7
|
-
return (_jsxs(Polymorph, Object.assign({}, props, { as: as, className: css("flex flex-col gap-4 rounded-card border border-card-border bg-card-background py-4 pb-8 shadow", container), children: [title ? _jsx("header", { className: "mb-2 w-full border-b border-card-border px-8 pb-4 text-xl font-medium", children: title }) : header, _jsx("div", { className: css("min-w-full px-8", className), children: children })] })));
|
|
8
|
-
};
|
|
4
|
+
export const Card = ({ children, title, as = "div", container = "", header = null, className = "", ...props }) => (_jsxs(Polymorph, { ...props, as: as, className: css("flex flex-col gap-4 rounded-card border border-card-border bg-card-background py-4 pb-8 shadow", container), children: [title ? _jsx("header", { className: "mb-2 w-full border-b border-card-border px-8 pb-4 text-xl font-medium", children: title }) : header, _jsx("div", { className: css("min-w-full px-8", className), children: children })] }));
|
|
@@ -3,7 +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 }) => (_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,
|
|
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, { 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 })] }) }) }));
|
|
7
7
|
export const AnimatedList = (props) => {
|
|
8
8
|
const [selected, setSelected] = useState(null);
|
|
9
9
|
const id = useId();
|
|
@@ -23,7 +23,7 @@ export const AnimatedList = (props) => {
|
|
|
23
23
|
return (_jsxs(Fragment, { children: [_jsx(FloatItem, { refs: refs, context: context, get: getFloatingProps, item: selected, setter: clear }), _jsx("ul", { role: "list", children: items.map((x, index) => {
|
|
24
24
|
const item = x.props;
|
|
25
25
|
const innerId = `${id}-${index}`;
|
|
26
|
-
const setter = () => setSelected(
|
|
26
|
+
const setter = () => setSelected({ ...item, id: innerId });
|
|
27
27
|
const Leading = item.leading;
|
|
28
28
|
return (_jsx(motion.li, { layout: true, layoutId: `item-${innerId}`, className: `border-b border-card-border py-2 last:border-transparent`, children: _jsx(motion.div, { layoutId: `toast-${innerId}`, className: "relative", children: _jsx("div", { className: "relative flex items-start space-x-3", children: _jsxs(Fragment, { children: [item.avatar ? (_jsx("div", { children: _jsx("div", { className: "relative px-1", children: _jsx("button", { onClick: setter, className: "flex size-10 items-center justify-center ring-primary", children: item.avatar }) }) })) : null, _jsx("div", { className: "min-w-0 flex-1 py-1 text-foreground", children: _jsxs("div", { className: "flex flex-row flex-nowrap justify-between gap-4", children: [_jsxs("button", { onClick: setter, className: "ease-out cursor-pointer text-left transition-all hover:scale-105 hover:text-primary", children: [_jsx("h3", { children: item.title }), _jsx("p", { className: "text-sm leading-snug text-secondary", children: item.description })] }), Leading ? _jsx(Leading, { open: setter }) : null] }) })] }) }) }) }, innerId));
|
|
29
29
|
}) })] }));
|
|
@@ -30,8 +30,7 @@ const animatedIndex = {
|
|
|
30
30
|
default: { opacity: 1, y: [25, 30], scale: [1, 0.95] },
|
|
31
31
|
};
|
|
32
32
|
const Notification = forwardRef(function Toast(props, forwardedRef) {
|
|
33
|
-
|
|
34
|
-
const closable = (_a = props.closable) !== null && _a !== void 0 ? _a : true;
|
|
33
|
+
const closable = props.closable ?? true;
|
|
35
34
|
const duration = props.duration;
|
|
36
35
|
const variant = props.hover ? "hover" : props.isLast ? "isLast" : "other";
|
|
37
36
|
const className = variants({ theme: props.theme || "default" });
|
|
@@ -52,7 +51,7 @@ export function Notifications({ children, max = 5, duration = 5000 }) {
|
|
|
52
51
|
const notify = useCallback((text, args) => {
|
|
53
52
|
const id = window.crypto.randomUUID();
|
|
54
53
|
setMessages((prev) => {
|
|
55
|
-
const newItems = [...prev,
|
|
54
|
+
const newItems = [...prev, { ...args, id, text }];
|
|
56
55
|
if (newItems.length > max)
|
|
57
56
|
return newItems.slice(newItems.length - max, newItems.length + 1);
|
|
58
57
|
return newItems;
|
|
@@ -62,7 +61,7 @@ export function Notifications({ children, max = 5, duration = 5000 }) {
|
|
|
62
61
|
}, [max]);
|
|
63
62
|
return (_jsxs(RadixToast.Provider, { duration: duration, swipeThreshold: 150, children: [_jsx(NotificationContext.Provider, { value: notify, children: children }), _jsx(AnimatePresence, { presenceAffectsLayout: true, mode: "popLayout", children: messages.map((toast, index, list) => {
|
|
64
63
|
const close = () => setMessages((prev) => prev.filter((t) => t.id !== toast.id));
|
|
65
|
-
return (_createElement(Notification,
|
|
64
|
+
return (_createElement(Notification, { ...toast, key: toast.id, hover: hover, index: index, onClose: close, isLast: list.length - 1 === index, reversedIndex: list.length - (index + 1) }));
|
|
66
65
|
}) }), _jsx(RadixToast.Viewport, { ref: ref, "data-items": messages.length, style: {
|
|
67
66
|
justifyContent: "start",
|
|
68
67
|
height: `${(hover ? messages.length : Math.min(1, messages.length)) * 7}rem`,
|
|
@@ -12,8 +12,8 @@ const states = {
|
|
|
12
12
|
initial: { pathLength: 0, opacity: 0 },
|
|
13
13
|
animate: { pathLength: 1, opacity: 1 },
|
|
14
14
|
};
|
|
15
|
-
const ErrorIcon = (props) => (_jsxs("svg",
|
|
16
|
-
const CheckIcon = (props) => (_jsx("svg",
|
|
15
|
+
const ErrorIcon = (props) => (_jsxs("svg", { ...props, viewBox: "0 0 24 24", fill: "currentColor", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [_jsx(motion.path, { className: "currentColor", initial: states.initial, animate: states.animate, transition: iconTransitions, d: "M18 6 6 18" }), _jsx(motion.path, { className: "currentColor", initial: states.initial, animate: states.animate, transition: iconTransitions, d: "m6 6 12 12" })] }));
|
|
16
|
+
const CheckIcon = (props) => (_jsx("svg", { ...props, fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", strokeWidth: 3, children: _jsx(motion.path, { initial: states.initial, animate: states.animate, transition: iconTransitions, strokeLinecap: "round", strokeLinejoin: "round", d: "M5 13l4 4L19 7" }) }));
|
|
17
17
|
const variants = { complete: { scale: 1.25 }, active: { scale: 1, transition: { delay: 0, duration: 0.2 } } };
|
|
18
18
|
const transitions = {
|
|
19
19
|
duration: 0.6,
|
|
@@ -4,15 +4,11 @@ import { Fragment } from "react";
|
|
|
4
4
|
const typeMap = {
|
|
5
5
|
tag: () => null,
|
|
6
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
|
-
},
|
|
7
|
+
record: ({ item }) => (_jsxs(Fragment, { children: [_jsxs("div", { className: "relative", children: [_jsx("img", { src: item.avatar?.img, alt: item.avatar?.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: item.avatar?.profile, className: "text-base font-medium text-primary", children: item.avatar?.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 }) })] })] })),
|
|
11
8
|
};
|
|
12
9
|
export const Timeline = (props) => {
|
|
13
10
|
return (_jsx("div", { className: "flow-root", children: _jsx("ul", { role: "list", className: "-mb-8", children: props.items.map((item, index) => {
|
|
14
|
-
|
|
15
|
-
const Render = (_a = typeMap[item.type]) !== null && _a !== void 0 ? _a : null;
|
|
11
|
+
const Render = typeMap[item.type] ?? null;
|
|
16
12
|
if (Render === null && props.Custom) {
|
|
17
13
|
return _jsx(props.Custom, { item: item });
|
|
18
14
|
}
|
|
@@ -21,19 +21,18 @@ export const Dropdown = (props) => {
|
|
|
21
21
|
transform: true,
|
|
22
22
|
whileElementsMounted: autoUpdate,
|
|
23
23
|
onOpenChange: (nextValue, event) => {
|
|
24
|
-
|
|
25
|
-
const element = event === null || event === void 0 ? void 0 : event.relatedTarget;
|
|
24
|
+
const element = event?.relatedTarget;
|
|
26
25
|
if (element) {
|
|
27
26
|
if (element.dataset.floating === "true" && !nextValue)
|
|
28
27
|
return;
|
|
29
28
|
}
|
|
30
29
|
setOpen(nextValue);
|
|
31
|
-
|
|
30
|
+
props.onChange?.(nextValue);
|
|
32
31
|
},
|
|
33
32
|
});
|
|
34
33
|
const click = useClick(context);
|
|
35
34
|
const dismiss = useDismiss(context);
|
|
36
35
|
const role = useRole(context);
|
|
37
36
|
const { getReferenceProps, getFloatingProps } = useInteractions([click, dismiss, role]);
|
|
38
|
-
return (_jsxs(Fragment, { children: [_jsx("button",
|
|
37
|
+
return (_jsxs(Fragment, { children: [_jsx("button", { 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", { 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] }) }) }))] }));
|
|
39
38
|
};
|
|
@@ -21,5 +21,5 @@ export const Expand = (props) => {
|
|
|
21
21
|
const role = useRole(context);
|
|
22
22
|
const dismiss = useDismiss(context, { escapeKey: true, referencePress: true, outsidePress: true });
|
|
23
23
|
const { getFloatingProps, getReferenceProps } = useInteractions([click, role, dismiss]);
|
|
24
|
-
return (_jsxs("div", { className: "relative inline-flex items-center justify-center", ref: root, children: [_jsx(Button,
|
|
24
|
+
return (_jsxs("div", { className: "relative inline-flex items-center justify-center", ref: root, children: [_jsx(Button, { ...getReferenceProps(props), as: motion.button, layoutId: wrapperId, ref: refs.setReference, size: "small", onClick: () => setOpen(true), children: _jsx(motion.span, { layoutId: titleId, children: props.trigger }) }), _jsx(AnimatePresence, { children: open ? (_jsx(FloatingPortal, { root: root, children: _jsx(FloatingFocusManager, { visuallyHiddenDismiss: true, modal: true, closeOnFocusOut: true, context: context, children: _jsx(motion.div, { ...getFloatingProps(), ref: refs.setFloating, layoutId: wrapperId, className: "absolute -left-1/4 -top-3/4", children: props.children }) }) })) : null })] }));
|
|
25
25
|
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { __rest } from "tslib";
|
|
3
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
3
|
import { autoUpdate, flip, FloatingFocusManager, FloatingList, FloatingNode, FloatingPortal, FloatingTree, offset, safePolygon, shift, useClick, useDismiss, useFloating, useFloatingNodeId, useFloatingParentNodeId, useFloatingTree, useHover, useInteractions, useListItem, useListNavigation, useMergeRefs, useRole, useTypeahead, } from "@floating-ui/react";
|
|
5
4
|
import { Slot } from "@radix-ui/react-slot";
|
|
@@ -15,8 +14,7 @@ const MenuContext = createContext({
|
|
|
15
14
|
setActiveIndex: () => { },
|
|
16
15
|
setHasFocusInside: () => { },
|
|
17
16
|
});
|
|
18
|
-
const MenuComponent = React.forwardRef((
|
|
19
|
-
var { children, FloatingComponent = "div", hover = true, isParent, floatingClassName = "", label } = _a, props = __rest(_a, ["children", "FloatingComponent", "hover", "isParent", "floatingClassName", "label"]);
|
|
17
|
+
const MenuComponent = React.forwardRef(({ children, FloatingComponent = "div", hover = true, isParent, floatingClassName = "", label, ...props }, forwardedRef) => {
|
|
20
18
|
const parentId = useFloatingParentNodeId();
|
|
21
19
|
const isNested = parentId !== null;
|
|
22
20
|
const [isOpen, setIsOpen] = useState(false);
|
|
@@ -89,38 +87,39 @@ const MenuComponent = React.forwardRef((_a, forwardedRef) => {
|
|
|
89
87
|
tree.events.emit("menuopen", { parentId, nodeId });
|
|
90
88
|
}, [tree, isOpen, nodeId, parentId]);
|
|
91
89
|
const className = isParent ? props.className : css(menuItemClassName(props.className));
|
|
92
|
-
return (_jsxs(FloatingNode, { id: nodeId, children: [_jsx(Fragment, { children: props.asChild ? (_jsx(Slot,
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
90
|
+
return (_jsxs(FloatingNode, { id: nodeId, children: [_jsx(Fragment, { children: props.asChild ? (_jsx(Slot, { children: label, ref: useMergeRefs([refs.setReference, item.ref, forwardedRef]), tabIndex: !isNested ? undefined : parent.activeIndex === item.index ? 0 : -1, "data-open": isOpen ? "" : undefined, "data-nested": isNested ? "" : undefined, role: isNested ? "menuitem" : undefined, "data-focus-inside": hasFocusInside ? "" : undefined, className: className, ...getReferenceProps(parent.getItemProps({
|
|
91
|
+
...props,
|
|
92
|
+
onFocus(event) {
|
|
93
|
+
props.onFocus?.(event);
|
|
94
|
+
setHasFocusInside(false);
|
|
95
|
+
parent.setHasFocusInside(true);
|
|
96
|
+
},
|
|
97
|
+
})) })) : (_jsxs("button", { type: "button", ref: useMergeRefs([refs.setReference, item.ref, forwardedRef]), tabIndex: !isNested ? undefined : parent.activeIndex === item.index ? 0 : -1, "data-open": isOpen ? "" : undefined, "data-nested": isNested ? "" : undefined, role: isNested ? "menuitem" : undefined, "data-focus-inside": hasFocusInside ? "" : undefined, className: className, ...getReferenceProps(parent.getItemProps({
|
|
98
|
+
...props,
|
|
99
|
+
onFocus(event) {
|
|
100
|
+
props.onFocus?.(event);
|
|
101
|
+
setHasFocusInside(false);
|
|
102
|
+
parent.setHasFocusInside(true);
|
|
103
|
+
},
|
|
104
|
+
})), children: [label, isNested && (_jsxs("span", { style: { marginLeft: 10, fontSize: 10 }, children: [_jsx("span", { className: "sr-only", children: "Next menu" }), _jsx(ChevronRightIcon, { size: 14 })] }))] })) }), _jsx(MenuContext.Provider, { value: { activeIndex, setActiveIndex, getItemProps, setHasFocusInside, isOpen }, children: _jsx(FloatingList, { elementsRef: elementsRef, labelsRef: labelsRef, children: isOpen && (_jsx(FloatingPortal, { preserveTabOrder: true, children: _jsx(FloatingFocusManager, { context: context, modal: false, initialFocus: isNested ? -1 : 0, returnFocus: !isNested, children: _jsx(FloatingComponent, { ...getFloatingProps(), ref: refs.setFloating, style: { ...props.style, ...floatingStyles }, className: css("isolate z-tooltip flex flex-col items-start rounded-lg border border-floating-border bg-floating-background text-left shadow-xl outline-none", floatingClassName), children: children }) }) })) }) })] }));
|
|
103
105
|
});
|
|
104
|
-
export const MenuItem = React.forwardRef((
|
|
105
|
-
var { label, title, Right, disabled } = _a, props = __rest(_a, ["label", "title", "Right", "disabled"]);
|
|
106
|
+
export const MenuItem = React.forwardRef(({ label, title, Right, disabled, ...props }, forwardedRef) => {
|
|
106
107
|
const menu = useContext(MenuContext);
|
|
107
108
|
const item = useListItem({ label: disabled ? null : typeof label === "string" ? label : title });
|
|
108
109
|
const tree = useFloatingTree();
|
|
109
110
|
const isActive = item.index === menu.activeIndex;
|
|
110
|
-
return (_jsxs("button",
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
},
|
|
121
|
-
}), { children: [label, Right ? _jsx(Right, { size: 16 }) : null] })));
|
|
111
|
+
return (_jsxs("button", { ...props, ref: useMergeRefs([item.ref, forwardedRef]), "data-active": isActive, type: "button", role: "menuitem", disabled: disabled, tabIndex: isActive ? 0 : -1, className: menuItemClassName(props.className), ...menu.getItemProps({
|
|
112
|
+
onClick(event) {
|
|
113
|
+
props.onClick?.(event);
|
|
114
|
+
tree?.events.emit("click");
|
|
115
|
+
},
|
|
116
|
+
onFocus(event) {
|
|
117
|
+
props.onFocus?.(event);
|
|
118
|
+
menu.setHasFocusInside(true);
|
|
119
|
+
},
|
|
120
|
+
}), children: [label, Right ? _jsx(Right, { size: 16 }) : null] }));
|
|
122
121
|
});
|
|
123
122
|
export const Menu = React.forwardRef((props, ref) => {
|
|
124
123
|
const parentId = useFloatingParentNodeId();
|
|
125
|
-
return parentId !== null ? (_jsx(MenuComponent,
|
|
124
|
+
return parentId !== null ? (_jsx(MenuComponent, { ...props, isParent: false, ref: ref })) : (_jsx(FloatingTree, { children: _jsx(MenuComponent, { ...props, isParent: true, ref: ref }) }));
|
|
126
125
|
});
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { __rest } from "tslib";
|
|
3
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
3
|
import { FloatingFocusManager, FloatingOverlay, FloatingPortal, useClick, useDismiss, useFloating, useInteractions, useRole, } from "@floating-ui/react";
|
|
5
4
|
import { Slot } from "@radix-ui/react-slot";
|
|
@@ -78,8 +77,7 @@ const Draggable = (props) => {
|
|
|
78
77
|
: "left-2 top-1/2 h-10 w-2"), children: props.sheet ? _jsx("div", { className: "h-2 w-1/4 rounded-lg bg-floating-border" }) : null }));
|
|
79
78
|
};
|
|
80
79
|
const positions = { drawer: "right", sheet: "none", dialog: "none" };
|
|
81
|
-
export const Modal = (
|
|
82
|
-
var { type: _type = "dialog", resizer = true, overlayClickClose = false, forceType = false, closable = true } = _a, props = __rest(_a, ["type", "resizer", "overlayClickClose", "forceType", "closable"]);
|
|
80
|
+
export const Modal = ({ type: _type = "dialog", resizer = true, overlayClickClose = false, forceType = false, closable = true, ...props }) => {
|
|
83
81
|
const headingId = useId();
|
|
84
82
|
const descriptionId = useId();
|
|
85
83
|
const isDesktop = useMediaQuery("(min-width: 64rem)");
|
|
@@ -96,7 +94,7 @@ export const Modal = (_a) => {
|
|
|
96
94
|
const Trigger = props.trigger;
|
|
97
95
|
const value = useMotionValue(undefined);
|
|
98
96
|
const onClose = () => props.onChange(false);
|
|
99
|
-
return (_jsxs(Fragment, { children: [props.trigger ? (_jsx(Fragment, { children: props.asChild ? (_jsx(Slot,
|
|
100
|
-
|
|
101
|
-
|
|
97
|
+
return (_jsxs(Fragment, { children: [props.trigger ? (_jsx(Fragment, { children: props.asChild ? (_jsx(Slot, { ref: refs.setReference, ...getReferenceProps({
|
|
98
|
+
layoutId: props.layoutId,
|
|
99
|
+
}), children: Trigger })) : (_jsx(motion.button, { ref: refs.setReference, ...getReferenceProps(), layoutId: props.layoutId, type: "button", children: Trigger })) })) : null, _jsx(FloatingPortal, { children: _jsx(AnimatePresence, { presenceAffectsLayout: true, children: props.open ? (_jsx(FloatingOverlay, { lockScroll: true, className: `inset-0 isolate z-overlay h-[100dvh] !overflow-clip bg-floating-overlay/70 ${type === "drawer" ? "" : "grid items-end justify-center lg:items-center"}`, children: _jsx(FloatingFocusManager, { visuallyHiddenDismiss: true, modal: true, closeOnFocusOut: true, context: context, children: _jsxs(motion.div, { animate: "enter", "aria-describedby": descriptionId, "aria-labelledby": headingId, className: variants({ position, type }), exit: "exit", layoutId: props.layoutId, initial: "initial", ref: refs.setFloating, style: type === "drawer" ? { width: value } : { height: value }, variants: animation, ...getFloatingProps(), children: [props.title ? (_jsx("header", { className: "relative w-full", children: props.title ? (_jsx("h2", { className: "border-b border-floating-border px-8 pb-2 text-3xl font-medium leading-relaxed", children: props.title })) : null })) : null, _jsx("section", { className: "flex-1 overflow-y-auto px-8 py-1", children: props.children }), props.footer ? (_jsx("footer", { className: "w-full border-t border-floating-border px-8 pt-4", children: props.footer })) : null, closable ? (_jsx("nav", { className: "absolute right-4 top-1 z-floating", children: _jsx("button", { type: "button", onClick: onClose, className: "p-1 opacity-70 transition-colors hover:text-danger hover:opacity-100 focus:text-danger", children: _jsx(XIcon, {}) }) })) : null, useResizer && resizer ? (_jsx(Draggable, { onChange: props.onChange, parent: refs.floating, position: position, sheet: type === "sheet", value: value })) : null] }) }) })) : null }) })] }));
|
|
102
100
|
};
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { __rest } from "tslib";
|
|
3
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
3
|
import { arrow, autoUpdate, flip, FloatingArrow, FloatingPortal, offset, shift, useClientPoint, useDismiss, useFloating, useFocus, useHover, useInteractions, useRole, } from "@floating-ui/react";
|
|
5
4
|
import { Fragment, useRef, useState } from "react";
|
|
6
5
|
import { Polymorph } from "../../components/core/polymorph";
|
|
7
6
|
import { FLOATING_DELAY } from "../../constants";
|
|
8
|
-
export const Tooltip = (
|
|
9
|
-
var { children, followCursor = false, placement, enabled, as, title } = _a, props = __rest(_a, ["children", "followCursor", "placement", "enabled", "as", "title"]);
|
|
7
|
+
export const Tooltip = ({ children, followCursor = false, placement, enabled, as, title, ...props }) => {
|
|
10
8
|
const [open, setOpen] = useState(false);
|
|
11
9
|
const arrowRef = useRef(null);
|
|
12
10
|
const Component = as || "span";
|
|
@@ -24,5 +22,5 @@ export const Tooltip = (_a) => {
|
|
|
24
22
|
const role = useRole(context, { role: "tooltip", enabled });
|
|
25
23
|
const clientPoint = useClientPoint(context, { enabled: !!enabled && !!followCursor });
|
|
26
24
|
const { getReferenceProps, getFloatingProps } = useInteractions([hover, focus, dismiss, role, clientPoint]);
|
|
27
|
-
return (_jsxs(Fragment, { children: [_jsx(Component,
|
|
25
|
+
return (_jsxs(Fragment, { children: [_jsx(Component, { ref: refs.setReference, ...getReferenceProps(props), children: title }), _jsx(FloatingPortal, { children: open && (_jsxs(Polymorph, { ...getFloatingProps(), ref: refs.setFloating, style: floatingStyles, className: "z-tooltip rounded-lg border border-tooltip-border bg-tooltip-background p-3 text-tooltip-foreground shadow-lg", children: [_jsx(FloatingArrow, { ref: arrowRef, context: context, strokeWidth: 0.1, className: "fill-tooltip-background stroke-tooltip-border" }), children] })) })] }));
|
|
28
26
|
};
|