@g4rcez/components 0.0.24 → 0.0.26
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/README.md +7 -7
- package/dist/components/core/button.d.ts.map +1 -1
- package/dist/components/core/button.js +1 -1
- package/dist/components/core/resizable.js +1 -1
- package/dist/components/core/tag.d.ts.map +1 -1
- package/dist/components/display/alert.d.ts.map +1 -1
- package/dist/components/display/alert.js +5 -5
- package/dist/components/display/tabs.d.ts +6 -1
- package/dist/components/display/tabs.d.ts.map +1 -1
- package/dist/components/display/tabs.js +9 -4
- package/dist/components/floating/dropdown.d.ts +1 -0
- package/dist/components/floating/dropdown.d.ts.map +1 -1
- package/dist/components/floating/dropdown.js +1 -1
- package/dist/components/floating/menu.d.ts +16 -0
- package/dist/components/floating/menu.d.ts.map +1 -0
- package/dist/components/floating/menu.js +115 -0
- package/dist/components/floating/modal.d.ts +1 -1
- package/dist/components/floating/modal.d.ts.map +1 -1
- package/dist/components/floating/modal.js +34 -10
- package/dist/components/form/autocomplete.d.ts +3 -2
- package/dist/components/form/autocomplete.d.ts.map +1 -1
- package/dist/components/form/autocomplete.js +47 -22
- package/dist/components/form/checkbox.d.ts.map +1 -1
- package/dist/components/form/checkbox.js +1 -1
- package/dist/components/form/date-picker.d.ts.map +1 -1
- package/dist/components/form/date-picker.js +5 -2
- package/dist/components/form/input-field.d.ts +8 -5
- package/dist/components/form/input-field.d.ts.map +1 -1
- package/dist/components/form/input-field.js +8 -4
- package/dist/components/form/input.d.ts +1 -1
- package/dist/components/form/input.d.ts.map +1 -1
- package/dist/components/form/input.js +3 -3
- package/dist/components/form/radiobox.d.ts.map +1 -1
- package/dist/components/form/select.d.ts +2 -0
- package/dist/components/form/select.d.ts.map +1 -1
- package/dist/components/form/select.js +5 -3
- 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/components/table/filter.d.ts +13 -44
- package/dist/components/table/filter.d.ts.map +1 -1
- package/dist/components/table/filter.js +41 -28
- package/dist/components/table/index.d.ts.map +1 -1
- package/dist/components/table/index.js +10 -9
- package/dist/components/table/pagination.d.ts.map +1 -1
- package/dist/components/table/pagination.js +10 -11
- package/dist/components/table/sort.d.ts.map +1 -1
- package/dist/components/table/sort.js +18 -12
- package/dist/components/table/table-lib.d.ts.map +1 -1
- package/dist/components/table/thead.d.ts +1 -0
- package/dist/components/table/thead.d.ts.map +1 -1
- package/dist/components/table/thead.js +10 -3
- package/dist/hooks/use-form.js +1 -1
- package/dist/hooks/use-media-query.d.ts +2 -0
- package/dist/hooks/use-media-query.d.ts.map +1 -0
- package/dist/hooks/use-media-query.js +25 -0
- package/dist/hooks/use-translate-context.d.ts +91 -0
- package/dist/hooks/use-translate-context.d.ts.map +1 -0
- package/dist/hooks/use-translate-context.js +49 -0
- package/dist/index.css +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8471 -7752
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +46 -41
- package/dist/index.umd.js.map +1 -1
- package/dist/lib/dom.d.ts +1 -1
- package/dist/lib/dom.d.ts.map +1 -1
- package/dist/lib/dom.js +12 -4
- package/dist/lib/fns.d.ts +1 -0
- package/dist/lib/fns.d.ts.map +1 -1
- package/dist/lib/fns.js +2 -1
- package/dist/preset/preset.tailwind.js +1 -1
- package/dist/preset/src/styles/theme.d.ts.map +1 -1
- package/dist/preset/src/styles/theme.js +2 -4
- package/dist/preset/src/styles/theme.types.d.ts +0 -1
- package/dist/preset/src/styles/theme.types.d.ts.map +1 -1
- package/dist/styles/theme.d.ts.map +1 -1
- package/dist/styles/theme.js +2 -4
- package/dist/styles/theme.types.d.ts +0 -1
- package/dist/styles/theme.types.d.ts.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +190 -184
package/README.md
CHANGED
|
@@ -27,10 +27,10 @@ The difference between then is:
|
|
|
27
27
|
|
|
28
28
|
# Tasks
|
|
29
29
|
|
|
30
|
-
-
|
|
31
|
-
-
|
|
32
|
-
-
|
|
33
|
-
-
|
|
34
|
-
-
|
|
35
|
-
-
|
|
36
|
-
-
|
|
30
|
+
- [x] TailwindCSS Plugin
|
|
31
|
+
- [x] Hook to work with forms
|
|
32
|
+
- [ ] Alerts
|
|
33
|
+
- [x] Notion Table
|
|
34
|
+
- [x] Dropdown
|
|
35
|
+
- [ ] Dark mode toggler
|
|
36
|
+
- [ ] Write docs
|
|
@@ -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;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,cAAc;;;;mFA4BnB,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,
|
|
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;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,cAAc;;;;mFA4BnB,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"}
|
|
@@ -34,6 +34,6 @@ export const Button = forwardRef(function Button(_a, ref) {
|
|
|
34
34
|
var _b;
|
|
35
35
|
var { className, icon, loading, theme, type = "button", size, rounded } = _a, props = __rest(_a, ["className", "icon", "loading", "theme", "type", "size", "rounded"]);
|
|
36
36
|
const disabled = loading || props.disabled;
|
|
37
|
-
return (_jsxs(Polymorph, Object.assign({}, props, { ref: ref, type: type, "data-theme": theme, "data-loading": loading, disabled: disabled, as: (_b = props.as) !== null && _b !== void 0 ? _b : "button", onClick: disabled ? undefined : props.onClick, className: css(buttonVariants({ size, rounded, theme }), className), children: [props.children, icon] })));
|
|
37
|
+
return (_jsxs(Polymorph, Object.assign({}, props, { ref: ref, type: type, "data-theme": theme, "data-loading": loading, disabled: disabled, "aria-busy": disabled || loading, as: (_b = props.as) !== null && _b !== void 0 ? _b : "button", onClick: disabled ? undefined : props.onClick, className: css(buttonVariants({ size, rounded, theme }), className), children: [props.children, icon] })));
|
|
38
38
|
});
|
|
39
39
|
export const ButtonGroup = (props) => (_jsx("ul", { className: "border-main-bg text-main-foreground flex w-full flex-row rounded-md border-2", children: props.buttons.map((button) => (_jsx("li", { className: "flex flex-1", children: _jsx("button", Object.assign({}, button, { type: button.type || "button", "data-active": props.active === button.name ? "true" : "false", className: css("flex flex-1 items-center gap-1.5 rounded-sm border-r-2 px-4 py-2 last:border-r-0", "cursor-pointer justify-center whitespace-nowrap align-middle font-medium", "focus-visible:ring-ring shadow-sm focus-visible:outline-none focus-visible:ring-2 disabled:text-opacity-80", "data-[active=true]:bg-main-bg text-body data-[active=true]:text-main transition-colors ease-in disabled:cursor-not-allowed disabled:bg-opacity-50") })) }, `button-group-${button.name}`))) }));
|
|
@@ -4,5 +4,5 @@ import { motion } from "framer-motion";
|
|
|
4
4
|
import useMeasure from "react-use-measure";
|
|
5
5
|
export const Resizable = ({ children }) => {
|
|
6
6
|
const [ref, bounds] = useMeasure();
|
|
7
|
-
return (_jsx(motion.div, { animate: { height: bounds.height > 0 ? bounds.height :
|
|
7
|
+
return (_jsx(motion.div, { animate: { height: bounds.height > 0 ? bounds.height : "auto" }, children: _jsx("div", { ref: ref, children: children }) }));
|
|
8
8
|
};
|
|
@@ -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;;;mFAwBhB,CAAC;AAEF,MAAM,MAAM,QAAQ,CAAC,CAAC,SAAS,KAAK,CAAC,WAAW,GAAG,MAAM,IAAI,gBAAgB,CACzE,YAAY,CAAC,OAAO,WAAW,CAAC,GAAG,OAAO,CAAC;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,EAC7E,CAAC,CACJ,CAAC;AAEF,eAAO,MAAM,GAAG,EAAE,CAAC,CAAC,SAAS,KAAK,CAAC,WAAW,GAAG,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,KAAK,
|
|
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;;;mFAwBhB,CAAC;AAEF,MAAM,MAAM,QAAQ,CAAC,CAAC,SAAS,KAAK,CAAC,WAAW,GAAG,MAAM,IAAI,gBAAgB,CACzE,YAAY,CAAC,OAAO,WAAW,CAAC,GAAG,OAAO,CAAC;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,EAC7E,CAAC,CACJ,CAAC;AAEF,eAAO,MAAM,GAAG,EAAE,CAAC,CAAC,SAAS,KAAK,CAAC,WAAW,GAAG,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,KAAK,GAUrE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alert.d.ts","sourceRoot":"","sources":["../../../src/components/display/alert.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAElE,OAAO,KAAqB,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAa,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,EAAE,eAAe,EAAU,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAc1C,KAAK,aAAa,GAAG;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,GAAG,eAAe,CAAC,SAAS,CAAC,CAAC;AAEpE,eAAO,MAAM,QAAQ,UAAW,iBAAiB,CAAC,aAAa,CAAC,4CAgB/D,CAAC;
|
|
1
|
+
{"version":3,"file":"alert.d.ts","sourceRoot":"","sources":["../../../src/components/display/alert.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAElE,OAAO,KAAqB,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAa,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,EAAE,eAAe,EAAU,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAc1C,KAAK,aAAa,GAAG;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,GAAG,eAAe,CAAC,SAAS,CAAC,CAAC;AAEpE,eAAO,MAAM,QAAQ,UAAW,iBAAiB,CAAC,aAAa,CAAC,4CAgB/D,CAAC;AAEF,QAAA,MAAM,aAAa;;mFASjB,CAAC;AAEH,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,KAAK,CAAC,WAAW,GAAG,KAAK,IAAI,gBAAgB,CAC1E,YAAY,CAAC,OAAO,aAAa,CAAC,GAC9B,OAAO,CAAC;IACJ,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;CACzC,CAAC,EACN,CAAC,CACJ,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,CAAC,CAAC,SAAS,KAAK,CAAC,WAAW,GAAG,KAAK,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,GAsCxE,CAAC"}
|
|
@@ -8,12 +8,12 @@ import { motion } from "framer-motion";
|
|
|
8
8
|
import { css } from "../../lib/dom";
|
|
9
9
|
const variants = {
|
|
10
10
|
true: { opacity: 1, height: "auto" },
|
|
11
|
-
false: { opacity: [0.7, 0.3, 0], height: 0 }
|
|
11
|
+
false: { opacity: [0.7, 0.3, 0], height: 0 },
|
|
12
12
|
};
|
|
13
13
|
const transition = {
|
|
14
14
|
type: "tween",
|
|
15
15
|
duration: 0.7,
|
|
16
|
-
ease: [0.04, 0.62, 0.23, 0.98]
|
|
16
|
+
ease: [0.04, 0.62, 0.23, 0.98],
|
|
17
17
|
};
|
|
18
18
|
export const Collapse = (props) => (_jsx(motion.section, Object.assign({}, props, { layout: true, layoutRoot: true, layoutScroll: true, initial: props.open, animate: props.open.toString(), "aria-hidden": !props.open, className: props.className, exit: variants.false, transition: transition, variants: variants, children: props.children })));
|
|
19
19
|
const alertVariants = cva("px-4 py-4 border relative rounded-lg text-sm", {
|
|
@@ -21,10 +21,10 @@ const alertVariants = cva("px-4 py-4 border relative rounded-lg text-sm", {
|
|
|
21
21
|
theme: {
|
|
22
22
|
neutral: "border-border bg-background",
|
|
23
23
|
danger: "text-danger-contrast bg-danger/10 border-danger/50",
|
|
24
|
-
success: "text-success-contrast bg-success/10 border-success/50"
|
|
25
|
-
}
|
|
24
|
+
success: "text-success-contrast bg-success/10 border-success/50",
|
|
25
|
+
},
|
|
26
26
|
},
|
|
27
|
-
defaultVariants: { theme: "neutral" }
|
|
27
|
+
defaultVariants: { theme: "neutral" },
|
|
28
28
|
});
|
|
29
29
|
export const Alert = forwardRef(function Alert(_a, ref) {
|
|
30
30
|
var _b;
|
|
@@ -9,7 +9,12 @@ export type TabsProps = {
|
|
|
9
9
|
export declare const Tabs: (props: PropsWithChildren<TabsProps>) => import("react/jsx-runtime").JSX.Element;
|
|
10
10
|
export type TabProps = {
|
|
11
11
|
id: string;
|
|
12
|
-
title:
|
|
12
|
+
title: string;
|
|
13
|
+
label?: undefined;
|
|
14
|
+
} | {
|
|
15
|
+
id: string;
|
|
16
|
+
title: Omit<Label, string>;
|
|
17
|
+
label: string;
|
|
13
18
|
};
|
|
14
19
|
export declare const Tab: (props: PropsWithChildren<TabProps>) => import("react/jsx-runtime").JSX.Element;
|
|
15
20
|
//# sourceMappingURL=tabs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tabs.d.ts","sourceRoot":"","sources":["../../../src/components/display/tabs.tsx"],"names":[],"mappings":"AAEA,OAAc,EAA2B,iBAAiB,EAAiC,MAAM,OAAO,CAAC;AAEzG,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"tabs.d.ts","sourceRoot":"","sources":["../../../src/components/display/tabs.tsx"],"names":[],"mappings":"AAEA,OAAc,EAA2B,iBAAiB,EAAiC,MAAM,OAAO,CAAC;AAEzG,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAKpC,MAAM,MAAM,SAAS,GAAG;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAIF,eAAO,MAAM,IAAI,UAAW,iBAAiB,CAAC,SAAS,CAAC,4CA6GvD,CAAC;AAIF,MAAM,MAAM,QAAQ,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,SAAS,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEpI,eAAO,MAAM,GAAG,UAAW,iBAAiB,CAAC,QAAQ,CAAC,4CAGrD,CAAC"}
|
|
@@ -4,6 +4,7 @@ import { motion, useMotionValue } from "framer-motion";
|
|
|
4
4
|
import React, { createContext, Fragment, useContext, useEffect, useRef } from "react";
|
|
5
5
|
import { useReactive } from "../../hooks/use-reactive";
|
|
6
6
|
import { Card } from "./card";
|
|
7
|
+
import { Select } from "../form/select";
|
|
7
8
|
const Context = createContext("");
|
|
8
9
|
export const Tabs = (props) => {
|
|
9
10
|
const [active, setActive] = useReactive(props.active);
|
|
@@ -53,10 +54,14 @@ export const Tabs = (props) => {
|
|
|
53
54
|
left.set(anchor.offsetLeft);
|
|
54
55
|
setActive(anchor.dataset.id || "");
|
|
55
56
|
};
|
|
56
|
-
return (_jsx(Context.Provider, { value: active, children: _jsx(Card, { className: props.className, container: "pt-0", header: _jsxs("header", { ref: ref, className: "border-b border-card-border relative mb-2", children: [_jsx(motion.div, { layout: true, initial: false, "aria-hidden": "true", style: { left, width }, transition: { type: "tween", left, width }, className: "w-28 h-0.5 bg-primary absolute bottom-0 duration-300 transition-all hidden
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
return (_jsx(Context.Provider, { value: active, children: _jsx(Card, { className: props.className, container: "pt-0", header: _jsxs("header", { ref: ref, className: "border-b border-card-border relative mb-2", children: [_jsx(motion.div, { layout: true, initial: false, "aria-hidden": "true", style: { left, width }, transition: { type: "tween", left, width }, className: "w-28 h-0.5 bg-primary absolute bottom-0 duration-300 transition-all hidden lg:block" }), _jsxs("nav", { children: [_jsx(Select, { onChange: (e) => setActive(e.target.value), value: active, hideLeft: true, container: "container rounded mt-4 lg:mt-0 min-w-full lg:hidden inline-flex px-6 w-full mx-auto", labelClassName: "border-transparent rounded-none", rightLabel: null, options: items.map((x) => {
|
|
58
|
+
var _a;
|
|
59
|
+
const inner = x.props;
|
|
60
|
+
return { value: inner.id, label: (_a = inner.label) !== null && _a !== void 0 ? _a : inner.title };
|
|
61
|
+
}) }), _jsx("ul", { className: "hidden lg:flex divide-x divide-card-border overflow-x-auto justify-between md:justify-start", children: items.map((x) => {
|
|
62
|
+
const inner = x.props;
|
|
63
|
+
return (_jsx("li", { "data-id": inner.id, "data-active": active === inner.id, className: "data-[active=true]:text-primary w-full md:w-auto", children: _jsx(Render, { "data-id": inner.id, onClick: onClick, "aria-current": "page", className: "px-10 py-4 block font-medium w-full whitespace-nowrap", href: props.useHash ? `#${inner.id}` : undefined, children: inner.title }) }, `tab-header-${inner.id}`));
|
|
64
|
+
}) })] })] }), children: props.children }) }));
|
|
60
65
|
};
|
|
61
66
|
const useTabs = () => useContext(Context);
|
|
62
67
|
export const Tab = (props) => {
|
|
@@ -7,6 +7,7 @@ type DropdownProps = {
|
|
|
7
7
|
onChange?: (nextValue: boolean) => void;
|
|
8
8
|
trigger: React.ReactElement | React.ReactNode;
|
|
9
9
|
title?: React.ReactNode | React.ReactElement | string;
|
|
10
|
+
buttonProps?: React.ComponentProps<"button">;
|
|
10
11
|
};
|
|
11
12
|
export declare const Dropdown: (props: PropsWithChildren<DropdownProps>) => import("react/jsx-runtime").JSX.Element;
|
|
12
13
|
export {};
|
|
@@ -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;
|
|
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,4CA0E/D,CAAC"}
|
|
@@ -36,5 +36,5 @@ export const Dropdown = (props) => {
|
|
|
36
36
|
const dismiss = useDismiss(context);
|
|
37
37
|
const role = useRole(context);
|
|
38
38
|
const { getReferenceProps, getFloatingProps } = useInteractions([click, dismiss, role]);
|
|
39
|
-
return (_jsxs(Fragment, { children: [_jsx("button", Object.assign({ ref: refs.setReference }, getReferenceProps(), { type: "button", children: props.trigger })), open && (_jsx(FloatingPortal, { id: `${headingId}-portal`, children: _jsx(FloatingFocusManager, { restoreFocus: (_a = props.restoreFocus) !== null && _a !== void 0 ? _a : true, returnFocus: (_b = props.restoreFocus) !== null && _b !== void 0 ? _b : true, visuallyHiddenDismiss: true, context: context, modal: false, children: _jsxs("div", Object.assign({ className: "bg-floating-background relative min-w-96 isolate z-floating border shadow-2xl p-6 border-floating-border rounded-lg", ref: refs.setFloating, style: floatingStyles, "aria-labelledby": headingId }, getFloatingProps(), { children: [_jsx(FloatingArrow, { ref: arrowRef, context: context, strokeWidth: 0.1, className: "fill-floating-background stroke-floating-border" }), _jsx("header", { className: "mb-2", children: _jsx("h3", { className: "leading-snug font-medium text-2xl tracking-wide text-left", children: props.title }) }), props.children] })) }) }))] }));
|
|
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, { restoreFocus: (_a = props.restoreFocus) !== null && _a !== void 0 ? _a : true, returnFocus: (_b = props.restoreFocus) !== null && _b !== void 0 ? _b : true, visuallyHiddenDismiss: true, context: context, modal: false, children: _jsxs("div", Object.assign({ className: "bg-floating-background relative min-w-96 isolate z-floating border shadow-2xl p-6 border-floating-border rounded-lg", ref: refs.setFloating, style: floatingStyles, "aria-labelledby": headingId }, getFloatingProps(), { children: [_jsx(FloatingArrow, { ref: arrowRef, context: context, strokeWidth: 0.1, className: "fill-floating-background stroke-floating-border" }), _jsx("header", { className: "mb-2", children: _jsx("h3", { className: "leading-snug font-medium text-2xl tracking-wide text-left", children: props.title }) }), props.children] })) }) }))] }));
|
|
40
40
|
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { LucideProps } from "lucide-react";
|
|
2
|
+
import React from "react";
|
|
3
|
+
type MenuItemProps = {
|
|
4
|
+
label: string;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
Right?: React.FC<LucideProps>;
|
|
7
|
+
};
|
|
8
|
+
export declare const MenuItem: React.ForwardRefExoticComponent<MenuItemProps & React.ButtonHTMLAttributes<HTMLButtonElement> & React.RefAttributes<HTMLButtonElement>>;
|
|
9
|
+
export declare const Menu: React.ForwardRefExoticComponent<Omit<Partial<{
|
|
10
|
+
isParent: boolean;
|
|
11
|
+
label: string;
|
|
12
|
+
nested: boolean;
|
|
13
|
+
children: React.ReactNode;
|
|
14
|
+
}> & React.HTMLProps<HTMLButtonElement>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=menu.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"menu.d.ts","sourceRoot":"","sources":["../../../src/components/floating/menu.tsx"],"names":[],"mappings":"AAyBA,OAAO,EAAoB,WAAW,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,KAAiE,MAAM,OAAO,CAAC;AA2JtF,KAAK,aAAa,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAAC,CAAA;CAAE,CAAC;AAE1F,eAAO,MAAM,QAAQ,yIAgCpB,CAAC;AAEF,eAAO,MAAM,IAAI;cA1KH,OAAO;WACV,MAAM;YACL,OAAO;cACL,KAAK,CAAC,SAAS;yFAgL3B,CAAC"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
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";
|
|
4
|
+
import { ChevronRightIcon } from "lucide-react";
|
|
5
|
+
import React, { createContext, useContext, useEffect, useRef, useState } from "react";
|
|
6
|
+
import { css } from "../../lib/dom";
|
|
7
|
+
const menuItemClassName = (highlight = "data-[open]:bg-primary focus:bg-primary") => `w-full outline-none px-2 py-1 rounded items-center flex justify-between text-left min-w-32 ${highlight} aria-expanded:opacity-80`;
|
|
8
|
+
const MenuContext = createContext({
|
|
9
|
+
isOpen: false,
|
|
10
|
+
activeIndex: null,
|
|
11
|
+
getItemProps: () => ({}),
|
|
12
|
+
setActiveIndex: () => { },
|
|
13
|
+
setHasFocusInside: () => { },
|
|
14
|
+
});
|
|
15
|
+
const MenuComponent = React.forwardRef((_a, forwardedRef) => {
|
|
16
|
+
var { children, label, isParent } = _a, props = __rest(_a, ["children", "label", "isParent"]);
|
|
17
|
+
const parentId = useFloatingParentNodeId();
|
|
18
|
+
const isNested = parentId !== null;
|
|
19
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
20
|
+
const [hasFocusInside, setHasFocusInside] = useState(false);
|
|
21
|
+
const [activeIndex, setActiveIndex] = useState(null);
|
|
22
|
+
const elementsRef = useRef([]);
|
|
23
|
+
const labelsRef = useRef([]);
|
|
24
|
+
const parent = useContext(MenuContext);
|
|
25
|
+
const tree = useFloatingTree();
|
|
26
|
+
const nodeId = useFloatingNodeId();
|
|
27
|
+
const item = useListItem();
|
|
28
|
+
const { floatingStyles, refs, context } = useFloating({
|
|
29
|
+
nodeId,
|
|
30
|
+
open: isOpen,
|
|
31
|
+
transform: true,
|
|
32
|
+
onOpenChange: setIsOpen,
|
|
33
|
+
whileElementsMounted: autoUpdate,
|
|
34
|
+
placement: isNested ? "right-start" : "bottom-start",
|
|
35
|
+
middleware: [offset({ mainAxis: isNested ? 0 : 4, alignmentAxis: isNested ? -4 : 0 }), flip(), shift()],
|
|
36
|
+
});
|
|
37
|
+
const role = useRole(context, { role: "menu", enabled: true });
|
|
38
|
+
const dismiss = useDismiss(context, { bubbles: true });
|
|
39
|
+
const hover = useHover(context, {
|
|
40
|
+
enabled: true,
|
|
41
|
+
delay: { open: 75 },
|
|
42
|
+
handleClose: safePolygon({ blockPointerEvents: true }),
|
|
43
|
+
});
|
|
44
|
+
const click = useClick(context, {
|
|
45
|
+
event: "mousedown",
|
|
46
|
+
toggle: !isNested,
|
|
47
|
+
ignoreMouse: isNested,
|
|
48
|
+
keyboardHandlers: true,
|
|
49
|
+
});
|
|
50
|
+
const listNavigation = useListNavigation(context, {
|
|
51
|
+
loop: true,
|
|
52
|
+
activeIndex,
|
|
53
|
+
virtual: true,
|
|
54
|
+
nested: isNested,
|
|
55
|
+
allowEscape: true,
|
|
56
|
+
listRef: elementsRef,
|
|
57
|
+
scrollItemIntoView: true,
|
|
58
|
+
onNavigate: setActiveIndex,
|
|
59
|
+
});
|
|
60
|
+
const typeahead = useTypeahead(context, {
|
|
61
|
+
activeIndex,
|
|
62
|
+
listRef: labelsRef,
|
|
63
|
+
onMatch: isOpen ? setActiveIndex : undefined,
|
|
64
|
+
});
|
|
65
|
+
const { getReferenceProps, getFloatingProps, getItemProps } = useInteractions([hover, click, role, dismiss, listNavigation, typeahead]);
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
if (!tree)
|
|
68
|
+
return;
|
|
69
|
+
const handleTreeClick = () => setIsOpen(false);
|
|
70
|
+
const onSubMenuOpen = (event) => {
|
|
71
|
+
if (event.nodeId !== nodeId && event.parentId === parentId) {
|
|
72
|
+
setIsOpen(false);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
tree.events.on("click", handleTreeClick);
|
|
76
|
+
tree.events.on("menuopen", onSubMenuOpen);
|
|
77
|
+
return () => {
|
|
78
|
+
tree.events.off("click", handleTreeClick);
|
|
79
|
+
tree.events.off("menuopen", onSubMenuOpen);
|
|
80
|
+
};
|
|
81
|
+
}, [tree, nodeId, parentId]);
|
|
82
|
+
useEffect(() => {
|
|
83
|
+
if (isOpen && tree)
|
|
84
|
+
tree.events.emit("menuopen", { parentId, nodeId });
|
|
85
|
+
}, [tree, isOpen, nodeId, parentId]);
|
|
86
|
+
return (_jsxs(FloatingNode, { id: nodeId, children: [_jsxs("button", Object.assign({ 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: isParent ? css(props.className) : isNested ? menuItemClassName(props.className) : menuItemClassName(props.className) }, getReferenceProps(parent.getItemProps(Object.assign(Object.assign({}, props), { onFocus(event) {
|
|
87
|
+
var _a;
|
|
88
|
+
(_a = props.onFocus) === null || _a === void 0 ? void 0 : _a.call(props, event);
|
|
89
|
+
setHasFocusInside(false);
|
|
90
|
+
parent.setHasFocusInside(true);
|
|
91
|
+
} }))), { 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("div", Object.assign({ ref: refs.setFloating, style: floatingStyles, className: "bg-floating-background outline-none items-start border text-left shadow-xl border-floating-border flex flex-col rounded-lg" }, getFloatingProps(), { children: children })) }) })) }) })] }));
|
|
92
|
+
});
|
|
93
|
+
export const MenuItem = React.forwardRef((_a, forwardedRef) => {
|
|
94
|
+
var { label, Right, disabled } = _a, props = __rest(_a, ["label", "Right", "disabled"]);
|
|
95
|
+
const menu = useContext(MenuContext);
|
|
96
|
+
const item = useListItem({ label: disabled ? null : label });
|
|
97
|
+
const tree = useFloatingTree();
|
|
98
|
+
const isActive = item.index === menu.activeIndex;
|
|
99
|
+
return (_jsxs("button", Object.assign({}, props, { ref: useMergeRefs([item.ref, forwardedRef]), type: "button", role: "menuitem", disabled: disabled, tabIndex: isActive ? 0 : -1, className: menuItemClassName(props.className) }, menu.getItemProps({
|
|
100
|
+
onClick(event) {
|
|
101
|
+
var _a;
|
|
102
|
+
(_a = props.onClick) === null || _a === void 0 ? void 0 : _a.call(props, event);
|
|
103
|
+
tree === null || tree === void 0 ? void 0 : tree.events.emit("click");
|
|
104
|
+
},
|
|
105
|
+
onFocus(event) {
|
|
106
|
+
var _a;
|
|
107
|
+
(_a = props.onFocus) === null || _a === void 0 ? void 0 : _a.call(props, event);
|
|
108
|
+
menu.setHasFocusInside(true);
|
|
109
|
+
},
|
|
110
|
+
}), { children: [label, Right ? _jsx(Right, { size: 16 }) : null] })));
|
|
111
|
+
});
|
|
112
|
+
export const Menu = React.forwardRef((props, ref) => {
|
|
113
|
+
const parentId = useFloatingParentNodeId();
|
|
114
|
+
return parentId !== null ? (_jsx(MenuComponent, Object.assign({}, props, { isParent: false, ref: ref }))) : (_jsx(FloatingTree, { children: _jsx(MenuComponent, Object.assign({}, props, { isParent: true, ref: ref })) }));
|
|
115
|
+
});
|
|
@@ -12,5 +12,5 @@ export type DrawerProps = {
|
|
|
12
12
|
trigger?: Label | React.FC<any>;
|
|
13
13
|
onChange: (nextState: boolean) => void;
|
|
14
14
|
};
|
|
15
|
-
export declare const Modal: ({ type, resizer, ...props }: PropsWithChildren<DrawerProps>) => import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export declare const Modal: ({ type: _type, resizer, ...props }: PropsWithChildren<DrawerProps>) => import("react/jsx-runtime").JSX.Element;
|
|
16
16
|
//# sourceMappingURL=modal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal.d.ts","sourceRoot":"","sources":["../../../src/components/floating/modal.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,EAAY,iBAAiB,EAAS,MAAM,OAAO,CAAC;AAClE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"modal.d.ts","sourceRoot":"","sources":["../../../src/components/floating/modal.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,EAAY,iBAAiB,EAAS,MAAM,OAAO,CAAC;AAClE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAwDpC,MAAM,MAAM,WAAW,GAAG;IACtB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,CAAC,EAAE,KAAK,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC3B,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC5B,OAAO,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;IAChC,QAAQ,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;CAC1C,CAAC;AAsDF,eAAO,MAAM,KAAK,uCAA0D,iBAAiB,CAAC,WAAW,CAAC,4CAqFzG,CAAC"}
|
|
@@ -7,7 +7,9 @@ import { cva } from "class-variance-authority";
|
|
|
7
7
|
import { AnimatePresence, motion, useMotionValue } from "framer-motion";
|
|
8
8
|
import { XIcon } from "lucide-react";
|
|
9
9
|
import { Fragment, useId } from "react";
|
|
10
|
-
|
|
10
|
+
import { useMediaQuery } from "../../hooks/use-media-query";
|
|
11
|
+
import { css } from "../../lib/dom";
|
|
12
|
+
const animationDuration = "600ms";
|
|
11
13
|
const createDrawerAnimation = (side) => ({
|
|
12
14
|
initial: { [side]: "-60%", opacity: 0.8, animationDuration },
|
|
13
15
|
enter: { [side]: 0, opacity: 1, animationDuration },
|
|
@@ -17,6 +19,11 @@ const drawerLeft = createDrawerAnimation("left");
|
|
|
17
19
|
const drawerRight = createDrawerAnimation("right");
|
|
18
20
|
const animations = {
|
|
19
21
|
drawer: (type) => (type === "left" ? drawerLeft : drawerRight),
|
|
22
|
+
sheet: {
|
|
23
|
+
initial: { opacity: 0, scaleY: 0.95, animationDuration, originY: "bottom" },
|
|
24
|
+
enter: { opacity: 1, scaleY: 1, animationDuration, originY: "bottom" },
|
|
25
|
+
exit: { opacity: 0, scaleY: 0.8, animationDuration, originY: "bottom" },
|
|
26
|
+
},
|
|
20
27
|
dialog: {
|
|
21
28
|
initial: { opacity: 0, scale: 0.95, animationDuration },
|
|
22
29
|
enter: { opacity: 1, scale: [1.05, 1], animationDuration },
|
|
@@ -28,6 +35,7 @@ const variants = cva("isolate ring-0 outline-0 appearance-none flex flex-col gap
|
|
|
28
35
|
type: {
|
|
29
36
|
drawer: "max-h-screen max-w-[90%] w-auto h-screen min-h-0",
|
|
30
37
|
dialog: "max-h-[calc(100lvh-10%)] container h-[inherit] rounded-lg py-8",
|
|
38
|
+
sheet: "w-full absolute bottom-0 max-h-[calc(100lvh-10%)] pt-6 pb-4 rounded-t-lg"
|
|
31
39
|
},
|
|
32
40
|
position: {
|
|
33
41
|
none: "",
|
|
@@ -41,21 +49,37 @@ const dragConstraints = { top: 0, left: 0, right: 0, bottom: 0 };
|
|
|
41
49
|
const Draggable = (props) => {
|
|
42
50
|
const handleDrag = (_, info) => {
|
|
43
51
|
if (props.parent.current) {
|
|
52
|
+
if (!props.sheet) {
|
|
53
|
+
const div = props.parent.current;
|
|
54
|
+
const v = props.value.get() || div.getBoundingClientRect().width;
|
|
55
|
+
const delta = props.type === "right" ? -info.delta.x : info.delta.x;
|
|
56
|
+
props.value.set(Math.abs(v + delta));
|
|
57
|
+
}
|
|
44
58
|
const div = props.parent.current;
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
|
|
59
|
+
const rect = div.getBoundingClientRect();
|
|
60
|
+
const v = props.value.get() || rect.height;
|
|
61
|
+
const result = Math.abs(v - info.delta.y);
|
|
62
|
+
const twentyPercentScreen = window.outerHeight * 0.68;
|
|
63
|
+
if (result < twentyPercentScreen) {
|
|
64
|
+
props.onChange(false);
|
|
65
|
+
return setTimeout(() => props.value.set(window.outerHeight * 0.9), 350);
|
|
66
|
+
}
|
|
67
|
+
return props.value.set(result);
|
|
48
68
|
}
|
|
49
69
|
};
|
|
50
|
-
return (_jsx(motion.div, { drag: "x", dragElastic: 0, dragMomentum: false, onDrag: handleDrag, dragConstraints: dragConstraints, whileDrag: { cursor: "grabbing" }, className:
|
|
70
|
+
return (_jsx(motion.div, { drag: "x", dragElastic: 0, dragMomentum: false, onDrag: handleDrag, dragConstraints: dragConstraints, whileDrag: { cursor: "grabbing" }, className: css("absolute rounded-lg cursor-grab bg-floating-border", props.sheet ? "left-1/2 top-2 w-16 h-2" : (props.type === "left" ? "top-1/2 right-5 h-10 w-2" : "top-1/2 left-2 h-10 w-2")) }));
|
|
51
71
|
};
|
|
72
|
+
const positions = { "drawer": "right", "sheet": "none", "dialog": "none" };
|
|
52
73
|
export const Modal = (_a) => {
|
|
53
|
-
var { type = "dialog", resizer = true } = _a, props = __rest(_a, ["type", "resizer"]);
|
|
54
|
-
const isDialog = type === "dialog";
|
|
55
|
-
const position = isDialog ? "none" : props.position || "left";
|
|
56
|
-
const animation = isDialog ? animations.dialog : animations.drawer(position);
|
|
74
|
+
var { type: _type = "dialog", resizer = true } = _a, props = __rest(_a, ["type", "resizer"]);
|
|
57
75
|
const headingId = useId();
|
|
58
76
|
const descriptionId = useId();
|
|
77
|
+
const isDesktop = useMediaQuery("(min-width: 48rem)");
|
|
78
|
+
const useResizer = _type === "drawer" || !isDesktop;
|
|
79
|
+
const position = isDesktop ? positions[_type] : positions.sheet;
|
|
80
|
+
const func = isDesktop ? animations[_type] : animations.sheet;
|
|
81
|
+
const animation = typeof func === "function" ? func(position) : func;
|
|
82
|
+
const type = isDesktop ? _type : "sheet";
|
|
59
83
|
const { refs, context } = useFloating({ open: props.open, onOpenChange: props.onChange });
|
|
60
84
|
const click = useClick(context);
|
|
61
85
|
const role = useRole(context);
|
|
@@ -63,5 +87,5 @@ export const Modal = (_a) => {
|
|
|
63
87
|
const { getReferenceProps, getFloatingProps } = useInteractions([click, role, dismiss]);
|
|
64
88
|
const Trigger = props.trigger;
|
|
65
89
|
const value = useMotionValue(undefined);
|
|
66
|
-
return (_jsxs(Fragment, { children: [props.trigger ? _jsx(Fragment, { children: props.asChild ? (_jsx(Slot, Object.assign({ ref: refs.setReference }, getReferenceProps(), { children: Trigger }))) : (_jsx("button", Object.assign({ ref: refs.setReference }, getReferenceProps(), { type: "button", children: Trigger }))) }) : null, _jsx(FloatingPortal, { children: _jsx(AnimatePresence, { presenceAffectsLayout: true, children: props.open && (_jsx(FloatingOverlay, { lockScroll: true, className: `relative !overflow-clip h-[100dvh] z-floating bg-floating-overlay/70 ${type === "drawer" ? "" : "grid justify-center p-8"}`, children: _jsx(FloatingFocusManager, { modal: true, closeOnFocusOut: true, context: context, children: _jsxs(motion.div, Object.assign({ animate: "enter", "aria-describedby": descriptionId, "aria-labelledby": headingId, className: variants({ position, type }), exit: "exit", initial: "initial", ref: refs.setFloating, variants: animation, style: { width: value } }, getFloatingProps(), { children: [
|
|
90
|
+
return (_jsxs(Fragment, { children: [props.trigger ? (_jsx(Fragment, { children: props.asChild ? (_jsx(Slot, Object.assign({ ref: refs.setReference }, getReferenceProps(), { children: Trigger }))) : (_jsx("button", Object.assign({ ref: refs.setReference }, getReferenceProps(), { type: "button", children: Trigger }))) })) : null, _jsx(FloatingPortal, { children: _jsx(AnimatePresence, { presenceAffectsLayout: true, children: props.open && (_jsx(FloatingOverlay, { lockScroll: true, className: `relative !overflow-clip h-[100dvh] z-floating bg-floating-overlay/70 ${type === "drawer" ? "" : "grid justify-center p-8"}`, children: _jsx(FloatingFocusManager, { modal: true, closeOnFocusOut: true, context: context, children: _jsxs(motion.div, Object.assign({ animate: "enter", "aria-describedby": descriptionId, "aria-labelledby": headingId, className: variants({ position, type }), exit: "exit", initial: "initial", ref: refs.setFloating, variants: animation, style: isDesktop ? { width: value } : { height: value } }, getFloatingProps(), { children: [useResizer && resizer ? _jsx(Draggable, { onChange: props.onChange, sheet: !isDesktop, value: value, parent: refs.floating, type: position }) : null, props.title || props.closable ? (_jsxs("header", { className: "w-full relative", children: [props.title ? (_jsx("h2", { className: "px-8 pb-4 border-b border-floating-border text-3xl font-medium leading-relaxed", children: props.title })) : null, props.closable !== false ? (_jsx("nav", { className: "absolute -top-1 right-8", children: _jsx("button", { type: "button", onClick: () => props.onChange(false), className: "p-1 transition-colors hover:text-danger focus:text-danger", children: _jsx(XIcon, {}) }) })) : null] })) : null, _jsx("div", { className: "flex-1 px-8 overflow-y-auto", children: props.children }), props.footer ? (_jsx("footer", { className: "px-8 border-t border-floating-border pt-4 w-full", children: props.footer })) : null] })) }) })) }) })] }));
|
|
67
91
|
};
|
|
@@ -7,10 +7,11 @@ type ItemProps = Omit<React.HTMLProps<HTMLLIElement>, "children"> & {
|
|
|
7
7
|
option: OptionProps;
|
|
8
8
|
};
|
|
9
9
|
export declare const Option: React.ForwardRefExoticComponent<Omit<ItemProps, "ref"> & React.RefAttributes<HTMLLIElement>>;
|
|
10
|
-
type
|
|
10
|
+
export type AutocompleteProps = Omit<InputFieldProps<"input">, "value"> & {
|
|
11
11
|
value?: string;
|
|
12
12
|
options: OptionProps[];
|
|
13
|
+
dynamicOption?: boolean;
|
|
13
14
|
};
|
|
14
|
-
export declare const Autocomplete: React.ForwardRefExoticComponent<Omit<
|
|
15
|
+
export declare const Autocomplete: React.ForwardRefExoticComponent<Omit<AutocompleteProps, "ref"> & React.RefAttributes<HTMLInputElement>>;
|
|
15
16
|
export {};
|
|
16
17
|
//# sourceMappingURL=autocomplete.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"autocomplete.d.ts","sourceRoot":"","sources":["../../../src/components/form/autocomplete.tsx"],"names":[],"mappings":"AAgBA,OAAO,
|
|
1
|
+
{"version":3,"file":"autocomplete.d.ts","sourceRoot":"","sources":["../../../src/components/form/autocomplete.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAuE,MAAM,OAAO,CAAC;AAG5F,OAAO,EAAc,eAAe,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,UAAU,CAAC;AAI5C,KAAK,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,aAAa,CAAC,EAAE,UAAU,CAAC,GAAG;IAChE,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,WAAW,CAAC;CACvB,CAAC;AAEF,eAAO,MAAM,MAAM,8FAWjB,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,GAAG;IACtE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,aAAa,CAAC,EAAE,OAAO,CAAC;CAC3B,CAAC;AAaF,eAAO,MAAM,YAAY,yGAmNxB,CAAC"}
|
|
@@ -5,10 +5,12 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
5
5
|
import { autoUpdate, FloatingFocusManager, FloatingPortal, offset, size, useDismiss, useFloating, useInteractions, useListNavigation, useRole, useTransitionStyles, } from "@floating-ui/react";
|
|
6
6
|
import Fuzzy from "fuzzy-search";
|
|
7
7
|
import { ChevronDown } from "lucide-react";
|
|
8
|
-
import { forwardRef, useImperativeHandle, useRef, useState } from "react";
|
|
8
|
+
import { forwardRef, useEffect, useImperativeHandle, useRef, useState } from "react";
|
|
9
9
|
import { usePrevious } from "../../hooks/use-previous";
|
|
10
10
|
import { css, dispatchInput } from "../../lib/dom";
|
|
11
11
|
import { InputField } from "./input-field";
|
|
12
|
+
import { safeRegex } from "../../lib/fns";
|
|
13
|
+
import { useTranslations } from "../../hooks/use-translate-context";
|
|
12
14
|
export const Option = forwardRef((_a, ref) => {
|
|
13
15
|
var _b;
|
|
14
16
|
var { selected, active, onClick, option } = _a, rest = __rest(_a, ["selected", "active", "onClick", "option"]);
|
|
@@ -23,15 +25,31 @@ const transitionStyles = {
|
|
|
23
25
|
const fuzzyOptions = { caseSensitive: false, sort: false };
|
|
24
26
|
const emptyRef = [];
|
|
25
27
|
export const Autocomplete = forwardRef((_a, externalRef) => {
|
|
26
|
-
var _b, _c;
|
|
27
|
-
var { options, required =
|
|
28
|
+
var _b, _c, _d, _e;
|
|
29
|
+
var { options, dynamicOption = false, feedback = null, labelClassName, interactive, rightLabel, optionalText, container, hideLeft = false, right, left, error, required = false } = _a, props = __rest(_a, ["options", "dynamicOption", "feedback", "labelClassName", "interactive", "rightLabel", "optionalText", "container", "hideLeft", "right", "left", "error", "required"]);
|
|
30
|
+
const translation = useTranslations();
|
|
31
|
+
const ref = useRef(null);
|
|
28
32
|
const [open, setOpen] = useState(false);
|
|
29
33
|
const [shadow, setShadow] = useState("");
|
|
30
34
|
const [value, setValue] = useState((_c = (_b = props.value) !== null && _b !== void 0 ? _b : props.defaultValue) !== null && _c !== void 0 ? _c : "");
|
|
35
|
+
const [label, setLabel] = useState((_e = (_d = props.value) !== null && _d !== void 0 ? _d : props.defaultValue) !== null && _e !== void 0 ? _e : "");
|
|
31
36
|
const [index, setIndex] = useState(null);
|
|
32
37
|
const listRef = useRef(emptyRef);
|
|
33
38
|
const previousIndex = usePrevious(index);
|
|
34
|
-
const
|
|
39
|
+
const innerOptions = dynamicOption && shadow !== "" ? [
|
|
40
|
+
{ value: shadow, label: shadow, "data-dynamic": "true" },
|
|
41
|
+
...options
|
|
42
|
+
] : options;
|
|
43
|
+
const list = new Fuzzy(innerOptions, ["value", "label"], fuzzyOptions).search(shadow);
|
|
44
|
+
const pattern = dynamicOption ? undefined : `^(${options.map((x) => `${safeRegex(x.value)}${x.label ? "|" + safeRegex(x.label) : ""}`).join("|")})$`;
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
var _a;
|
|
47
|
+
if (props.value) {
|
|
48
|
+
setValue(props.value);
|
|
49
|
+
const item = options.find((x) => x.value === props.value);
|
|
50
|
+
setValue((_a = item === null || item === void 0 ? void 0 : item.label) !== null && _a !== void 0 ? _a : props.value);
|
|
51
|
+
}
|
|
52
|
+
}, [props.value]);
|
|
35
53
|
const { x, y, strategy, refs, context } = useFloating({
|
|
36
54
|
open,
|
|
37
55
|
transform: true,
|
|
@@ -78,8 +96,12 @@ export const Autocomplete = forwardRef((_a, externalRef) => {
|
|
|
78
96
|
}),
|
|
79
97
|
]);
|
|
80
98
|
const onSelect = (opt) => {
|
|
99
|
+
var _a, _b;
|
|
81
100
|
setValue(opt.value);
|
|
82
|
-
|
|
101
|
+
setLabel((_a = opt.label) !== null && _a !== void 0 ? _a : "");
|
|
102
|
+
const fakeEvent = dispatchInput(ref.current, opt.value);
|
|
103
|
+
if (fakeEvent)
|
|
104
|
+
(_b = props.onChange) === null || _b === void 0 ? void 0 : _b.call(props, fakeEvent);
|
|
83
105
|
setOpen(false);
|
|
84
106
|
setShadow("");
|
|
85
107
|
};
|
|
@@ -89,6 +111,7 @@ export const Autocomplete = forwardRef((_a, externalRef) => {
|
|
|
89
111
|
setShadow(value);
|
|
90
112
|
if (!open && value === "")
|
|
91
113
|
return setOpen(true);
|
|
114
|
+
event.target.name = props.name || "";
|
|
92
115
|
return value ? setOpen(true) : (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, event);
|
|
93
116
|
};
|
|
94
117
|
const onFocus = () => {
|
|
@@ -98,32 +121,34 @@ export const Autocomplete = forwardRef((_a, externalRef) => {
|
|
|
98
121
|
const onClose = () => {
|
|
99
122
|
setShadow("");
|
|
100
123
|
setValue("");
|
|
124
|
+
setLabel("");
|
|
101
125
|
dispatchInput(refs.reference.current, "");
|
|
102
126
|
setOpen(false);
|
|
103
127
|
};
|
|
104
|
-
return (_jsxs(
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
128
|
+
return (_jsxs(InputField, Object.assign({}, props, { container: css("group inline-block w-full", container), error: error, feedback: feedback, form: props.form, hideLeft: hideLeft, id: props.name || props.id, interactive: interactive, labelClassName: labelClassName, left: left, name: props.name, optionalText: optionalText, placeholder: props.placeholder, required: required, rightLabel: rightLabel, title: props.title, right: _jsxs("span", { className: "flex items-center gap-0.5", children: [_jsxs("button", { type: "button", className: "link:text-primary transition-colors", children: [_jsx(ChevronDown, { size: 20 }), _jsx("span", { className: "sr-only", children: translation.inputCaretDown })] }), value ? (_jsx("button", { type: "button", onClick: onClose, className: "link:text-danger transition-colors", children: _jsx("svg", { width: "15", height: "15", viewBox: "0 0 15 15", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: _jsx("path", { d: "M11.7816 4.03157C12.0062 3.80702 12.0062 3.44295 11.7816 3.2184C11.5571 2.99385 11.193 2.99385 10.9685 3.2184L7.50005 6.68682L4.03164 3.2184C3.80708 2.99385 3.44301 2.99385 3.21846 3.2184C2.99391 3.44295 2.99391 3.80702 3.21846 4.03157L6.68688 7.49999L3.21846 10.9684C2.99391 11.193 2.99391 11.557 3.21846 11.7816C3.44301 12.0061 3.80708 12.0061 4.03164 11.7816L7.50005 8.31316L10.9685 11.7816C11.193 12.0061 11.5571 12.0061 11.7816 11.7816C12.0062 11.557 12.0062 11.193 11.7816 10.9684L8.31322 7.49999L11.7816 4.03157Z", fill: "currentColor", fillRule: "evenodd", clipRule: "evenodd" }) }) })) : null] }), children: [_jsx("input", { ref: ref, required: required, type: "hidden", name: props.name, defaultValue: props.value || value || undefined }), _jsx("input", Object.assign({}, getReferenceProps(Object.assign(Object.assign({}, props), { onChange,
|
|
129
|
+
onFocus,
|
|
130
|
+
pattern, ref: refs.setReference, name: undefined, onClick: (e) => e.currentTarget.focus(), onKeyDown(event) {
|
|
131
|
+
if (event.key === "Escape") {
|
|
132
|
+
event.currentTarget.blur();
|
|
133
|
+
return setOpen(false);
|
|
134
|
+
}
|
|
135
|
+
if (event.key === "Enter") {
|
|
136
|
+
if (index !== null && list[index]) {
|
|
137
|
+
event.preventDefault();
|
|
138
|
+
return onSelect(list[index]);
|
|
109
139
|
}
|
|
110
|
-
if (
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
return onSelect(list[index]);
|
|
114
|
-
}
|
|
115
|
-
if (list.length === 1) {
|
|
116
|
-
event.preventDefault();
|
|
117
|
-
return onSelect(list[0]);
|
|
118
|
-
}
|
|
140
|
+
if (list.length === 1) {
|
|
141
|
+
event.preventDefault();
|
|
142
|
+
return onSelect(list[0]);
|
|
119
143
|
}
|
|
120
|
-
}
|
|
144
|
+
}
|
|
145
|
+
} })), { required: required, value: open ? shadow : label || value, "aria-autocomplete": "list", autoComplete: "off", className: css("input text-foreground text-base group h-11 w-full flex-1 rounded-md bg-transparent p-2 placeholder-input-mask outline-none transition-colors group-error:text-danger group-error:placeholder-input-mask-error", !!right || shadow ? "pe-12" : "", !!left ? "ps-8" : "", props.className) })), _jsx(FloatingPortal, { preserveTabOrder: true, children: open ? (_jsx(FloatingFocusManager, { guards: true, returnFocus: false, context: context, initialFocus: -1, visuallyHiddenDismiss: true, children: _jsx("ul", Object.assign({}, getFloatingProps({
|
|
121
146
|
ref: refs.setFloating,
|
|
122
147
|
style: Object.assign({ position: strategy, left: x !== null && x !== void 0 ? x : 0, top: y !== null && y !== void 0 ? y : 0 }, transitions.styles),
|
|
123
148
|
}), { "data-floating": "true", className: "bg-floating-background shadow-floating text-foreground list-none p-0 m-0 rounded-b-lg overflow-auto origin-[top_center] overflow-y-auto z-floating", children: list.map((option, i) => (_createElement(Option, Object.assign({}, getItemProps({
|
|
124
149
|
onClick: () => onSelect(option),
|
|
125
150
|
ref: (node) => void (listRef.current[i] = node),
|
|
126
151
|
selected: index === i,
|
|
127
|
-
active: value === option.value
|
|
128
|
-
}), { key: `${option.value}-option`, option: option, selected: index === i, active: value === option.value })))) })) }) })] }));
|
|
152
|
+
active: value === option.value,
|
|
153
|
+
}), { key: `${option.value}-option`, option: option, selected: index === i, active: value === option.value })))) })) })) : null })] })));
|
|
129
154
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkbox.d.ts","sourceRoot":"","sources":["../../../src/components/form/checkbox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,MAAM,MAAM,aAAa,GAAG,QAAQ,CAChC,KAAK,CAAC,iBAAiB,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,EACtD;IACI,IAAI,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC;CAC7B,CACJ,CAAC;AAEF,eAAO,MAAM,QAAQ,4CAAkD,aAAa,
|
|
1
|
+
{"version":3,"file":"checkbox.d.ts","sourceRoot":"","sources":["../../../src/components/form/checkbox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,MAAM,MAAM,aAAa,GAAG,QAAQ,CAChC,KAAK,CAAC,iBAAiB,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,EACtD;IACI,IAAI,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC;CAC7B,CACJ,CAAC;AAEF,eAAO,MAAM,QAAQ,4CAAkD,aAAa,4CAiBnF,CAAC"}
|
|
@@ -3,5 +3,5 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { css } from "../../lib/dom";
|
|
4
4
|
export const Checkbox = (_a) => {
|
|
5
5
|
var { children, className = "", size } = _a, props = __rest(_a, ["children", "className", "size"]);
|
|
6
|
-
return (_jsxs("label", { "data-disabled": props.disabled, "aria-disabled": props.disabled, className: "group font-normal flex items-center gap-2 data-[disabled=true]:cursor-not-allowed", children: [_jsx("input", Object.assign({}, props, { type: "checkbox", className: css("form-checkbox
|
|
6
|
+
return (_jsxs("label", { "data-disabled": props.disabled, "aria-disabled": props.disabled, className: "group font-normal flex items-center gap-2 data-[disabled=true]:cursor-not-allowed", children: [_jsx("input", Object.assign({}, props, { type: "checkbox", className: css("form-checkbox size-4 rounded border-card-border text-primary focus:ring-primary appearance-none inline-block bg-origin-border group-aria-disabled:cursor-not-allowed disabled:opacity-70", className) }, props)), children] }));
|
|
7
7
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date-picker.d.ts","sourceRoot":"","sources":["../../../src/components/form/date-picker.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAY,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAE9D,OAAO,EAAS,UAAU,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"date-picker.d.ts","sourceRoot":"","sources":["../../../src/components/form/date-picker.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAY,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAE9D,OAAO,EAAS,UAAU,EAAE,MAAM,SAAS,CAAC;AAG5C,KAAK,eAAe,GAAG,QAAQ,CAAC,UAAU,EAAE,aAAa,GAAG,EAAE,CAAC,CAAC;AAyBhE,eAAO,MAAM,UAAU,kFAAmF,eAAe,4CAoFxH,CAAC"}
|