@g4rcez/components 0.0.25 → 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/dist/components/core/button.d.ts.map +1 -1
- package/dist/components/core/button.js +1 -1
- package/dist/components/display/tabs.d.ts.map +1 -1
- package/dist/components/display/tabs.js +2 -2
- 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 +33 -9
- package/dist/components/form/autocomplete.d.ts +3 -3
- package/dist/components/form/autocomplete.d.ts.map +1 -1
- package/dist/components/form/autocomplete.js +29 -20
- 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 +6 -4
- 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/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/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 +7 -4
- package/dist/components/table/sort.d.ts.map +1 -1
- package/dist/components/table/sort.js +18 -12
- 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-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 +8224 -7571
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +47 -42
- package/dist/index.umd.js.map +1 -1
- package/dist/lib/fns.d.ts +1 -0
- package/dist/lib/fns.d.ts.map +1 -1
- package/dist/lib/fns.js +1 -0
- 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/package.json +7 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../../src/components/core/button.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;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}`))) }));
|
|
@@ -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,7 +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 {
|
|
7
|
+
import { Select } from "../form/select";
|
|
8
8
|
const Context = createContext("");
|
|
9
9
|
export const Tabs = (props) => {
|
|
10
10
|
const [active, setActive] = useReactive(props.active);
|
|
@@ -54,7 +54,7 @@ export const Tabs = (props) => {
|
|
|
54
54
|
left.set(anchor.offsetLeft);
|
|
55
55
|
setActive(anchor.dataset.id || "");
|
|
56
56
|
};
|
|
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(
|
|
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
58
|
var _a;
|
|
59
59
|
const inner = x.props;
|
|
60
60
|
return { value: inner.id, label: (_a = inner.label) !== null && _a !== void 0 ? _a : inner.title };
|
|
@@ -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,6 +7,8 @@ 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
|
+
import { useMediaQuery } from "../../hooks/use-media-query";
|
|
11
|
+
import { css } from "../../lib/dom";
|
|
10
12
|
const animationDuration = "600ms";
|
|
11
13
|
const createDrawerAnimation = (side) => ({
|
|
12
14
|
initial: { [side]: "-60%", opacity: 0.8, 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,11 +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
|
-
|
|
13
|
+
dynamicOption?: boolean;
|
|
14
14
|
};
|
|
15
|
-
export declare const Autocomplete: React.ForwardRefExoticComponent<Omit<
|
|
15
|
+
export declare const Autocomplete: React.ForwardRefExoticComponent<Omit<AutocompleteProps, "ref"> & React.RefAttributes<HTMLInputElement>>;
|
|
16
16
|
export {};
|
|
17
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,KAAuE,MAAM,OAAO,CAAC;AAG5F,OAAO,EAAc,eAAe,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,UAAU,CAAC;
|
|
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"}
|
|
@@ -9,6 +9,8 @@ import { forwardRef, useEffect, useImperativeHandle, useRef, useState } from "re
|
|
|
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"]);
|
|
@@ -24,7 +26,8 @@ const fuzzyOptions = { caseSensitive: false, sort: false };
|
|
|
24
26
|
const emptyRef = [];
|
|
25
27
|
export const Autocomplete = forwardRef((_a, externalRef) => {
|
|
26
28
|
var _b, _c, _d, _e;
|
|
27
|
-
var { options,
|
|
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();
|
|
28
31
|
const ref = useRef(null);
|
|
29
32
|
const [open, setOpen] = useState(false);
|
|
30
33
|
const [shadow, setShadow] = useState("");
|
|
@@ -33,7 +36,12 @@ export const Autocomplete = forwardRef((_a, externalRef) => {
|
|
|
33
36
|
const [index, setIndex] = useState(null);
|
|
34
37
|
const listRef = useRef(emptyRef);
|
|
35
38
|
const previousIndex = usePrevious(index);
|
|
36
|
-
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("|")})$`;
|
|
37
45
|
useEffect(() => {
|
|
38
46
|
var _a;
|
|
39
47
|
if (props.value) {
|
|
@@ -117,23 +125,24 @@ export const Autocomplete = forwardRef((_a, externalRef) => {
|
|
|
117
125
|
dispatchInput(refs.reference.current, "");
|
|
118
126
|
setOpen(false);
|
|
119
127
|
};
|
|
120
|
-
return (_jsxs(
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
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]);
|
|
139
|
+
}
|
|
140
|
+
if (list.length === 1) {
|
|
141
|
+
event.preventDefault();
|
|
142
|
+
return onSelect(list[0]);
|
|
143
|
+
}
|
|
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({
|
|
137
146
|
ref: refs.setFloating,
|
|
138
147
|
style: Object.assign({ position: strategy, left: x !== null && x !== void 0 ? x : 0, top: y !== null && y !== void 0 ? y : 0 }, transitions.styles),
|
|
139
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({
|
|
@@ -141,5 +150,5 @@ export const Autocomplete = forwardRef((_a, externalRef) => {
|
|
|
141
150
|
ref: (node) => void (listRef.current[i] = node),
|
|
142
151
|
selected: index === i,
|
|
143
152
|
active: value === option.value,
|
|
144
|
-
}), { key: `${option.value}-option`, option: option, selected: index === i, active: value === option.value })))) })) })) : null })] }));
|
|
153
|
+
}), { key: `${option.value}-option`, option: option, selected: index === i, active: value === option.value })))) })) })) : null })] })));
|
|
145
154
|
});
|
|
@@ -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"}
|
|
@@ -2,11 +2,12 @@ import { __rest } from "tslib";
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { format, parse, startOfDay } from "date-fns";
|
|
4
4
|
import { CalendarIcon } from "lucide-react";
|
|
5
|
-
import { Fragment, useMemo, useState } from "react";
|
|
5
|
+
import { Fragment, useId, useMemo, useState } from "react";
|
|
6
6
|
import { Is } from "sidekicker";
|
|
7
7
|
import { Calendar } from "../display/calendar";
|
|
8
8
|
import { Dropdown } from "../floating/dropdown";
|
|
9
9
|
import { Input } from "./input";
|
|
10
|
+
import { useTranslations } from "../../hooks/use-translate-context";
|
|
10
11
|
const fixedDate = new Date(1970, 11, 31);
|
|
11
12
|
const parts = {
|
|
12
13
|
year: () => [/\d/, /\d/, /\d/, /\d/],
|
|
@@ -29,6 +30,8 @@ const partValues = {
|
|
|
29
30
|
export const DatePicker = (_a) => {
|
|
30
31
|
var _b;
|
|
31
32
|
var { date, locale, disabledDate, autoFocusToday, onChange, markToday } = _a, props = __rest(_a, ["date", "locale", "disabledDate", "autoFocusToday", "onChange", "markToday"]);
|
|
33
|
+
const labelId = useId();
|
|
34
|
+
const translation = useTranslations();
|
|
32
35
|
const datetimeFormat = useMemo(() => new Intl.DateTimeFormat(locale), [locale]);
|
|
33
36
|
const [innerDate, setInnerDate] = useState(date || undefined);
|
|
34
37
|
const [open, setOpen] = useState(false);
|
|
@@ -61,5 +64,5 @@ export const DatePicker = (_a) => {
|
|
|
61
64
|
onChange === null || onChange === void 0 ? void 0 : onChange(d);
|
|
62
65
|
setValue(format(d, placeholder));
|
|
63
66
|
};
|
|
64
|
-
return (_jsx(Input, Object.assign({}, props, { mask: mask, value: value, onChange: onChangeDateInput, className: "uppercase", formNoValidate: !open, placeholder: placeholder, required: (_b = props.required) !== null && _b !== void 0 ? _b : true, error: open ? undefined : props.error, name: props.name ? `${props.name}-picker` : props.name, right: _jsxs(Fragment, { children: [_jsx("input", { defaultValue: innerDate === null || innerDate === void 0 ? void 0 : innerDate.toISOString(), hidden: true, type: "date", name: props.name }), _jsx(Dropdown, { restoreFocus: true, trigger: _jsx(CalendarIcon, {}),
|
|
67
|
+
return (_jsx(Input, Object.assign({}, props, { mask: mask, value: value, onChange: onChangeDateInput, className: "uppercase", formNoValidate: !open, placeholder: placeholder, required: (_b = props.required) !== null && _b !== void 0 ? _b : true, error: open ? undefined : props.error, name: props.name ? `${props.name}-picker` : props.name, right: _jsxs(Fragment, { children: [_jsx("input", { defaultValue: innerDate === null || innerDate === void 0 ? void 0 : innerDate.toISOString(), hidden: true, type: "date", name: props.name }), _jsx(Dropdown, { open: open, restoreFocus: true, onChange: setOpen, trigger: _jsxs("span", { "aria-labelledby": labelId, children: [_jsx("span", { id: labelId, className: "sr-only", children: translation.datePickerCalendarButtonLabel }), _jsx(CalendarIcon, {})] }), buttonProps: { "aria-describedby": labelId }, children: _jsx(Calendar, Object.assign({}, props, { locale: locale, date: innerDate, onChange: onChangeDate, markToday: markToday, disabledDate: disabledDate, autoFocusToday: autoFocusToday })) })] }) })));
|
|
65
68
|
};
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import React, { PropsWithChildren } from "react";
|
|
2
|
-
import { PolymorphicProps } from "../core/polymorph";
|
|
3
2
|
import { Label } from "../../types";
|
|
3
|
+
import { PolymorphicProps } from "../core/polymorph";
|
|
4
4
|
export type FeedbackProps = React.PropsWithChildren<Partial<{
|
|
5
|
-
|
|
5
|
+
info: Label;
|
|
6
|
+
title: Label;
|
|
6
7
|
hideLeft?: boolean;
|
|
7
8
|
className?: string;
|
|
8
9
|
placeholder: string;
|
|
9
10
|
reportStatus: boolean;
|
|
10
11
|
}>>;
|
|
11
|
-
export declare const InputFeedback: ({ reportStatus, hideLeft, className, children, title }: FeedbackProps) => import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export declare const InputFeedback: ({ reportStatus, hideLeft, className, info, children, title }: FeedbackProps) => import("react/jsx-runtime").JSX.Element;
|
|
12
13
|
export type InputFieldProps<T extends "input" | "select"> = PolymorphicProps<Partial<{
|
|
14
|
+
info: Label;
|
|
13
15
|
labelClassName: string;
|
|
14
16
|
error: string;
|
|
15
17
|
hideLeft: boolean;
|
|
@@ -24,5 +26,5 @@ export type InputFieldProps<T extends "input" | "select"> = PolymorphicProps<Par
|
|
|
24
26
|
name: string;
|
|
25
27
|
placeholder: string;
|
|
26
28
|
}>, T>;
|
|
27
|
-
export declare const InputField: <T extends "input" | "select">({ optionalText, left, rightLabel, container, feedback, interactive, right, children, error, form, id, labelClassName, name, title, placeholder, hideLeft, required, }: PropsWithChildren<InputFieldProps<T>>) => import("react/jsx-runtime").JSX.Element;
|
|
29
|
+
export declare const InputField: <T extends "input" | "select">({ optionalText: _optionalText, left, rightLabel, container, feedback, interactive, right, info, children, error, form, id, labelClassName, name, title, placeholder, hideLeft, required, }: PropsWithChildren<InputFieldProps<T>>) => import("react/jsx-runtime").JSX.Element;
|
|
28
30
|
//# sourceMappingURL=input-field.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input-field.d.ts","sourceRoot":"","sources":["../../../src/components/form/input-field.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAY,iBAAiB,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"input-field.d.ts","sourceRoot":"","sources":["../../../src/components/form/input-field.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAY,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAG3D,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAGrD,MAAM,MAAM,aAAa,GAAG,KAAK,CAAC,iBAAiB,CAC/C,OAAO,CAAC;IACJ,IAAI,EAAE,KAAK,CAAC;IACZ,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,OAAO,CAAC;CACzB,CAAC,CACL,CAAC;AAEF,eAAO,MAAM,aAAa,iEAA0E,aAAa,4CAiDhH,CAAC;AAEF,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,OAAO,GAAG,QAAQ,IAAI,gBAAgB,CACxE,OAAO,CAAC;IACJ,IAAI,EAAE,KAAK,CAAC;IACZ,cAAc,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,OAAO,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,KAAK,CAAC;IACZ,QAAQ,EAAE,KAAK,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,KAAK,CAAC;IACb,UAAU,EAAE,KAAK,CAAC;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACvB,CAAC,EACF,CAAC,CACJ,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,CAAC,SAAS,OAAO,GAAG,QAAQ,8LAmBpD,iBAAiB,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,4CAmCvC,CAAC"}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { CheckCircle, XCircle } from "lucide-react";
|
|
3
|
+
import { CheckCircle, InfoIcon, XCircle } from "lucide-react";
|
|
4
4
|
import { Fragment } from "react";
|
|
5
|
+
import { useTranslations } from "../../hooks/use-translate-context";
|
|
5
6
|
import { css } from "../../lib/dom";
|
|
6
|
-
|
|
7
|
-
export const
|
|
7
|
+
import { Tooltip } from "../floating/tooltip";
|
|
8
|
+
export const InputFeedback = ({ reportStatus, hideLeft = false, className, info, children, title }) => (_jsxs("div", { className: css("w-full justify-between", hideLeft && children === null ? "hidden" : "flex", className), children: [hideLeft ? null : (_jsxs("span", { className: "flex items-center gap-1 group-hover:text-primary group-focus-within:text-primary transition-colors group-error:text-danger", children: [title, reportStatus || info ? (_jsxs("span", { className: "flex gap-1 items-center justify-center", children: [info ? (_jsx(Tooltip, { title: _jsxs("span", { children: [_jsx("span", { className: "sr-only", children: info }), _jsx(InfoIcon, { className: "aspect-square size-3", "aria-hidden": "true", size: 16, strokeWidth: 1, absoluteStrokeWidth: true })] }), children: info })) : null, reportStatus ? (_jsxs(Fragment, { children: [_jsx(CheckCircle, { className: "hidden aspect-square size-3 opacity-0 transition-opacity group-assert:block group-assert:text-success group-assert:opacity-100", "aria-hidden": "true", size: 16, strokeWidth: 1, absoluteStrokeWidth: true }), _jsx(XCircle, { className: "hidden aspect-square size-3 opacity-0 transition-opacity group-error:block group-error:opacity-100", "aria-hidden": "true", size: 16, strokeWidth: 1, absoluteStrokeWidth: true })] })) : null] })) : null] })), children] }));
|
|
9
|
+
export const InputField = ({ optionalText: _optionalText, left, rightLabel, container, feedback, interactive, right, info, children, error, form, id, labelClassName = "", name, title, placeholder, hideLeft, required, }) => {
|
|
8
10
|
const ID = id !== null && id !== void 0 ? id : name;
|
|
9
|
-
|
|
11
|
+
const translation = useTranslations();
|
|
12
|
+
const optionalText = _optionalText !== null && _optionalText !== void 0 ? _optionalText : translation.inputOptionalLabel;
|
|
13
|
+
return (_jsxs("fieldset", { form: form, "data-error": !!error, "data-interactive": !!interactive, className: css("group inline-flex gap-1.5 w-full", container), children: [_jsxs("label", { form: form, htmlFor: ID, className: "inline-flex w-full cursor-text flex-row flex-wrap justify-between gap-1 text-sm transition-colors empty:hidden group-error:text-danger group-hover:border-primary", children: [!hideLeft && !rightLabel ? (_jsx(InputFeedback, { info: info, hideLeft: hideLeft, reportStatus: true, title: title, placeholder: placeholder, children: optionalText || rightLabel ? (_jsxs(Fragment, { children: [!required ? _jsx("span", { className: "text-opacity-70", children: optionalText }) : null, rightLabel ? _jsx(Fragment, { children: rightLabel }) : null] })) : null })) : null, _jsxs("div", { className: `relative group flex w-full flex-row flex-nowrap items-center gap-x-2 gap-y-1 rounded-md border border-input-border bg-transparent transition-colors group-focus-within:border-primary group-hover:border-primary group-error:border-danger ${labelClassName}`, children: [left ? _jsx("span", { className: "absolute left-0 flex flex-nowrap gap-1 whitespace-nowrap pl-2", children: left }) : null, children, right ? _jsx("span", { className: "absolute right-0 flex flex-nowrap gap-2 whitespace-nowrap pr-1", children: right }) : null] })] }), _jsx("p", { className: "group-error:block empty:hidden group-error:text-danger hidden text-xs group-has-[input:not(:focus):invalid[data-initialized=true]]:block", children: error }), _jsx("p", { className: "text-xs group-assert:block group-error:hidden empty:mt-0 empty:hidden group-has-[input:not(:focus):valid[data-initialized=true]]:block", children: feedback })] }));
|
|
10
14
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { TheMaskProps } from "the-mask-input";
|
|
3
|
-
import { FeedbackProps, InputFieldProps } from "./input-field";
|
|
4
3
|
import { Override } from "../../types";
|
|
4
|
+
import { FeedbackProps, InputFieldProps } from "./input-field";
|
|
5
5
|
export type InputProps = Override<InputFieldProps<"input">, TheMaskProps & FeedbackProps & {
|
|
6
6
|
next?: string;
|
|
7
7
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../../src/components/form/input.tsx"],"names":[],"mappings":"AACA,OAAO,KAAwC,MAAM,OAAO,CAAC;AAC7D,OAAkB,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../../src/components/form/input.tsx"],"names":[],"mappings":"AACA,OAAO,KAAwC,MAAM,OAAO,CAAC;AAC7D,OAAkB,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEzD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,aAAa,EAAc,eAAe,EAAE,MAAM,eAAe,CAAC;AAE3E,MAAM,MAAM,UAAU,GAAG,QAAQ,CAC7B,eAAe,CAAC,OAAO,CAAC,EACxB,YAAY,GACR,aAAa,GAAG;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB,CACR,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC,UAAU,CAqF/B,CAAC"}
|
|
@@ -3,11 +3,11 @@ import { __rest } from "tslib";
|
|
|
3
3
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
4
|
import { forwardRef, useEffect, useRef } from "react";
|
|
5
5
|
import MaskInput from "the-mask-input";
|
|
6
|
-
import { InputField } from "./input-field";
|
|
7
6
|
import { css, mergeRefs } from "../../lib/dom";
|
|
7
|
+
import { InputField } from "./input-field";
|
|
8
8
|
export const Input = forwardRef((_a, ref) => {
|
|
9
9
|
var _b;
|
|
10
|
-
var { type = "text",
|
|
10
|
+
var { type = "text", feedback = null, info, labelClassName, next, interactive, rightLabel, optionalText, container, hideLeft = false, right, left, error } = _a, props = __rest(_a, ["type", "feedback", "info", "labelClassName", "next", "interactive", "rightLabel", "optionalText", "container", "hideLeft", "right", "left", "error"]);
|
|
11
11
|
const id = (_b = props.id) !== null && _b !== void 0 ? _b : props.name;
|
|
12
12
|
const inputRef = useRef(null);
|
|
13
13
|
useEffect(() => {
|
|
@@ -35,5 +35,5 @@ export const Input = forwardRef((_a, ref) => {
|
|
|
35
35
|
input.removeEventListener("focus", focus);
|
|
36
36
|
};
|
|
37
37
|
}, []);
|
|
38
|
-
return (_jsx(InputField,
|
|
38
|
+
return (_jsx(InputField, { info: info, container: css("group inline-block w-full", container), error: error, feedback: feedback, hideLeft: hideLeft, left: left, optionalText: optionalText, right: right, rightLabel: rightLabel, interactive: interactive, form: props.form, id: props.name || props.id, name: props.name, labelClassName: labelClassName, title: props.title, placeholder: props.placeholder, required: props.required, children: _jsx(MaskInput, Object.assign({}, props, { type: type, "data-next": next, ref: mergeRefs(ref, inputRef), id: id, name: id, className: css("input text-foreground 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 ? "pe-4" : "", !!left ? "ps-4" : "", props.className) })) }));
|
|
39
39
|
});
|
|
@@ -3,9 +3,11 @@ import { InputFieldProps } from "./input-field";
|
|
|
3
3
|
import { Override } from "../../types";
|
|
4
4
|
export type OptionProps = Override<React.ComponentProps<"option">, {
|
|
5
5
|
value: string;
|
|
6
|
+
"data-dynamic"?: string;
|
|
6
7
|
}>;
|
|
7
8
|
export type SelectProps = Override<InputFieldProps<"select">, {
|
|
8
9
|
options: OptionProps[];
|
|
10
|
+
selectContainer?: string;
|
|
9
11
|
}>;
|
|
10
12
|
export declare const Select: React.ForwardRefExoticComponent<Omit<SelectProps, "ref"> & React.RefAttributes<HTMLSelectElement>>;
|
|
11
13
|
//# sourceMappingURL=select.d.ts.map
|