@g4rcez/components 0.0.62 → 0.0.64
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/index.css +1 -1
- package/dist/index.js +45 -45
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7520 -7505
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +45 -45
- package/dist/index.umd.js.map +1 -1
- package/dist/src/components/floating/modal.js +1 -1
- package/dist/src/components/form/autocomplete.d.ts +1 -0
- package/dist/src/components/form/autocomplete.d.ts.map +1 -1
- package/dist/src/components/form/autocomplete.js +24 -16
- package/dist/src/components/form/date-picker.d.ts +2 -2
- package/dist/src/components/form/free-text.d.ts.map +1 -1
- package/dist/src/components/form/free-text.js +1 -1
- package/dist/src/components/form/input-field.d.ts +1 -1
- package/dist/src/components/form/input-field.d.ts.map +1 -1
- package/dist/src/components/form/input-field.js +5 -5
- package/dist/src/components/form/input.d.ts +16 -3
- package/dist/src/components/form/input.d.ts.map +1 -1
- package/dist/src/hooks/use-components-provider.d.ts +2 -0
- package/dist/src/hooks/use-components-provider.d.ts.map +1 -1
- package/dist/src/hooks/use-components-provider.js +2 -5
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/lib/fns.d.ts.map +1 -1
- package/dist/src/lib/fns.js +12 -5
- package/package.json +1 -1
|
@@ -96,5 +96,5 @@ export const Modal = ({ type: _type = "dialog", resizer = true, overlayClickClos
|
|
|
96
96
|
const onClose = () => props.onChange(false);
|
|
97
97
|
return (_jsxs(Fragment, { children: [props.trigger ? (_jsx(Fragment, { children: props.asChild ? (_jsx(Slot, { ref: refs.setReference, ...getReferenceProps({
|
|
98
98
|
layoutId: props.layoutId,
|
|
99
|
-
}), children: Trigger })) : (_jsx(motion.button, { ref: refs.setReference, ...getReferenceProps(), layoutId: props.layoutId, type: "button", children: Trigger })) })) : null, _jsx(FloatingPortal, { children: _jsx(AnimatePresence, { presenceAffectsLayout: true, children: props.open ? (_jsx(FloatingOverlay, { lockScroll: true, className: `inset-0 isolate z-overlay h-[100dvh] !overflow-clip bg-floating-overlay/70 ${type === "drawer" ? "" : "
|
|
99
|
+
}), children: Trigger })) : (_jsx(motion.button, { ref: refs.setReference, ...getReferenceProps(), layoutId: props.layoutId, type: "button", children: Trigger })) })) : null, _jsx(FloatingPortal, { children: _jsx(AnimatePresence, { presenceAffectsLayout: true, children: props.open ? (_jsx(FloatingOverlay, { lockScroll: true, className: `inset-0 isolate z-overlay h-[100dvh] !overflow-clip bg-floating-overlay/70 ${type === "drawer" ? "" : "flex items-start justify-center p-10"}`, children: _jsx(FloatingFocusManager, { visuallyHiddenDismiss: true, modal: true, closeOnFocusOut: true, context: context, children: _jsxs(motion.div, { exit: "exit", animate: "enter", initial: "initial", variants: animation, ref: refs.setFloating, "aria-modal": props.open, layoutId: props.layoutId, "aria-labelledby": headingId, "aria-describedby": descriptionId, className: variants({ position, type }), style: type === "drawer" ? { width: value } : { height: value }, ...getFloatingProps(), children: [props.title ? (_jsx("header", { className: "relative w-full", children: props.title ? (_jsx("h2", { className: "border-b border-floating-border px-8 pb-2 text-3xl font-medium leading-relaxed", children: props.title })) : null })) : null, _jsx("section", { className: "flex-1 overflow-y-auto px-8 py-1", children: props.children }), props.footer ? (_jsx("footer", { className: "w-full border-t border-floating-border px-8 pt-4", children: props.footer })) : null, closable ? (_jsx("nav", { className: "absolute right-4 top-1 z-floating", children: _jsx("button", { type: "button", onClick: onClose, className: "p-1 opacity-70 transition-colors hover:text-danger hover:opacity-100 focus:text-danger", children: _jsx(XIcon, {}) }) })) : null, useResizer && resizer ? (_jsx(Draggable, { onChange: props.onChange, parent: refs.floating, position: position, sheet: type === "sheet", value: value })) : null] }) }) })) : null }) })] }));
|
|
100
100
|
};
|
|
@@ -12,6 +12,7 @@ export type AutocompleteOptionProps = Omit<React.HTMLProps<HTMLLIElement>, "chil
|
|
|
12
12
|
export declare const Option: React.ForwardRefExoticComponent<Omit<AutocompleteOptionProps, "ref"> & React.RefAttributes<HTMLLIElement>>;
|
|
13
13
|
export type AutocompleteProps = Omit<InputFieldProps<"input">, "value"> & {
|
|
14
14
|
value?: string;
|
|
15
|
+
emptyMessage?: string;
|
|
15
16
|
dynamicOption?: boolean;
|
|
16
17
|
options: AutocompleteItemProps[];
|
|
17
18
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"autocomplete.d.ts","sourceRoot":"","sources":["../../../../src/components/form/autocomplete.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAoF,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"autocomplete.d.ts","sourceRoot":"","sources":["../../../../src/components/form/autocomplete.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAoF,MAAM,OAAO,CAAC;AAKzG,OAAO,EAAc,eAAe,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C,MAAM,MAAM,qBAAqB,GAAG,WAAW,GAAG;IAAE,MAAM,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAAC,CAAA;CAAE,CAAC;AAErF,MAAM,MAAM,uBAAuB,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,aAAa,CAAC,EAAE,UAAU,CAAC,GAAG;IACrF,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,qBAAqB,CAAC;CACjC,CAAC;AAIF,eAAO,MAAM,MAAM,4GA2BjB,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,GAAG;IACtE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,OAAO,EAAE,qBAAqB,EAAE,CAAC;CACpC,CAAC;AAaF,eAAO,MAAM,YAAY,yGAgSxB,CAAC"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { autoUpdate, FloatingFocusManager, FloatingPortal, offset, size, useDismiss, useFloating, useInteractions, useListNavigation, useRole, useTransitionStyles, } from "@floating-ui/react";
|
|
4
4
|
import Fuzzy from "fuzzy-search";
|
|
5
|
-
import { CheckIcon, ChevronDown } from "lucide-react";
|
|
5
|
+
import { CheckIcon, ChevronDown, XIcon } from "lucide-react";
|
|
6
6
|
import { forwardRef, Fragment, useEffect, useRef, useState } from "react";
|
|
7
7
|
import { useTranslations } from "../../hooks/use-components-provider";
|
|
8
8
|
import { css, dispatchInput, initializeInputDataset } from "../../lib/dom";
|
|
@@ -15,7 +15,7 @@ export const Option = forwardRef(({ selected, active, onClick, option, ...props
|
|
|
15
15
|
if (option.hidden) {
|
|
16
16
|
return null;
|
|
17
17
|
}
|
|
18
|
-
return (_jsx("li", { ...props, ref: ref, role: "option", "aria-selected": active, className: "w-full border-b border-tooltip-border last:border-
|
|
18
|
+
return (_jsx("li", { ...props, ref: ref, role: "option", "aria-selected": active, className: "w-full min-w-0 container border-b border-tooltip-border last:border-b-0", children: _jsxs("button", { type: "button", "aria-checked": active, "aria-current": active, "aria-selected": active, onClick: onClick, "data-value": option.value, "aria-busy": option.disabled, className: `flex w-full cursor-pointer justify-between p-2 text-left ${active ? "bg-primary-hover text-primary-foreground" : ""} ${selected ? "bg-primary text-primary-foreground" : ""}`, children: [_jsx(Label, { ...props, label: option.label, value: option.value, children: children }), active ? (_jsx("span", { children: _jsx(CheckIcon, { "aria-hidden": true, className: "text-current", absoluteStrokeWidth: true, strokeWidth: 2, size: 22 }) })) : null] }) }));
|
|
19
19
|
});
|
|
20
20
|
const transitionStyles = {
|
|
21
21
|
duration: 300,
|
|
@@ -25,15 +25,16 @@ const transitionStyles = {
|
|
|
25
25
|
};
|
|
26
26
|
const fuzzyOptions = { caseSensitive: false, sort: false };
|
|
27
27
|
const emptyRef = [];
|
|
28
|
-
export const Autocomplete = forwardRef(({
|
|
29
|
-
const defaults = props.value ?? props.defaultValue ?? "";
|
|
28
|
+
export const Autocomplete = forwardRef(({ left, error, right, options, container, rightLabel, interactive, emptyMessage, optionalText, labelClassName, feedback = null, hideLeft = false, required = false, dynamicOption = false, ...props }, externalRef) => {
|
|
30
29
|
const translation = useTranslations();
|
|
30
|
+
const defaults = props.value ?? props.defaultValue ?? "";
|
|
31
31
|
const [open, setOpen] = useState(false);
|
|
32
32
|
const [shadow, setShadow] = useState("");
|
|
33
33
|
const [value, setValue] = useState(defaults);
|
|
34
34
|
const [label, setLabel] = useState(() => options.find((x) => x.value === defaults)?.label ?? defaults);
|
|
35
35
|
const [index, setIndex] = useState(null);
|
|
36
36
|
const listRef = useRef(emptyRef);
|
|
37
|
+
const fieldset = useRef(null);
|
|
37
38
|
const innerOptions = dynamicOption && shadow !== ""
|
|
38
39
|
? [
|
|
39
40
|
{
|
|
@@ -63,16 +64,18 @@ export const Autocomplete = forwardRef(({ options, dynamicOption = false, feedba
|
|
|
63
64
|
middleware: [
|
|
64
65
|
offset(4),
|
|
65
66
|
size({
|
|
66
|
-
elementContext: "reference",
|
|
67
67
|
padding: 10,
|
|
68
|
+
elementContext: "reference",
|
|
68
69
|
apply(a) {
|
|
69
70
|
const html = a.elements.reference;
|
|
70
71
|
const parent = html.parentElement;
|
|
71
|
-
const
|
|
72
|
+
const max = fieldset.current?.getBoundingClientRect().width;
|
|
73
|
+
const w = parent?.getBoundingClientRect().width || 0;
|
|
72
74
|
Object.assign(a.elements.floating.style, {
|
|
73
75
|
width: `${w}px`,
|
|
74
|
-
|
|
75
|
-
|
|
76
|
+
overflowY: "auto",
|
|
77
|
+
maxWidth: `${max}px`,
|
|
78
|
+
minWidth: `${max}px`,
|
|
76
79
|
maxHeight: `${Math.min(250, a.availableHeight)}px`,
|
|
77
80
|
});
|
|
78
81
|
},
|
|
@@ -131,16 +134,21 @@ export const Autocomplete = forwardRef(({ options, dynamicOption = false, feedba
|
|
|
131
134
|
setOpen(true);
|
|
132
135
|
setShadow("");
|
|
133
136
|
};
|
|
134
|
-
const
|
|
137
|
+
const onOpenCaret = () => {
|
|
138
|
+
setOpen(true);
|
|
139
|
+
refs.reference.current?.focus();
|
|
140
|
+
};
|
|
141
|
+
const onClose = (e) => {
|
|
142
|
+
e.stopPropagation();
|
|
143
|
+
refs.reference.current?.setAttribute("data-value", "");
|
|
144
|
+
dispatchInput(refs.reference.current, "");
|
|
135
145
|
setShadow("");
|
|
136
146
|
setValue("");
|
|
137
|
-
refs.reference.current?.setAttribute("data-value", "");
|
|
138
147
|
setLabel("");
|
|
139
|
-
dispatchInput(refs.reference.current, "");
|
|
140
148
|
setOpen(false);
|
|
141
149
|
};
|
|
142
150
|
const id = props.id || props.name;
|
|
143
|
-
return (_jsxs(InputField, { ...props, left: left, error: error, form: props.form, name: props.name, feedback: feedback, hideLeft: hideLeft, required: required, title: props.title, container: container, rightLabel: rightLabel, interactive: interactive, id: props.name || props.id, optionalText: optionalText, componentName: "autocomplete", labelClassName: labelClassName, placeholder: props.placeholder, right: _jsxs("span", { className: "flex items-center gap-0.5", children: [_jsxs("button", { type: "button", className: "transition-colors link:text-primary", children: [_jsx(ChevronDown, { size: 20 }), _jsx("span", { className: "sr-only", children: translation.inputCaretDown })] }), value ? (
|
|
151
|
+
return (_jsxs(InputField, { ...props, left: left, error: error, ref: fieldset, form: props.form, name: props.name, feedback: feedback, hideLeft: hideLeft, required: required, title: props.title, container: container, rightLabel: rightLabel, disabled: props.disabled, interactive: interactive, id: props.name || props.id, optionalText: optionalText, componentName: "autocomplete", labelClassName: labelClassName, placeholder: props.placeholder, right: _jsxs("span", { className: "flex items-center gap-0.5", children: [_jsxs("button", { disabled: props.disabled, onClick: onOpenCaret, type: "button", className: "transition-colors disabled:link:text-disabled link:text-primary disabled:text-disabled", children: [_jsx(ChevronDown, { size: 20 }), _jsx("span", { className: "sr-only", children: translation.inputCaretDown })] }), value ? (_jsxs("button", { type: "button", onClick: onClose, className: "isolate relative transition-colors link:text-danger", children: [_jsx(XIcon, { size: 15 }), _jsx("span", { className: "sr-only", children: translation.inputCloseValue })] })) : null] }), children: [_jsx("input", { ...getReferenceProps({
|
|
144
152
|
...props,
|
|
145
153
|
onChange,
|
|
146
154
|
onFocus,
|
|
@@ -165,20 +173,20 @@ export const Autocomplete = forwardRef(({ options, dynamicOption = false, feedba
|
|
|
165
173
|
}
|
|
166
174
|
}
|
|
167
175
|
},
|
|
168
|
-
}), "data-value": value, "data-error": !!error, "data-name": id, "data-target": id, required: required, value: open ? shadow : label || value, "aria-autocomplete": "list", autoComplete: "off", className: css("input placeholder-input-mask group h-input-height w-full flex-1", "rounded-md bg-transparent px-input-x py-input-y text-foreground", "outline-none transition-colors focus:ring-2 focus:ring-inset focus:ring-primary", "group-error:text-danger group-error:placeholder-input-mask-error", "group-focus-within:border-primary group-hover:border-primary", props.className) }), _jsx("input", { id: id, name: id, type: "hidden", "data-origin": id, ref: externalRef, required: required, defaultValue: props.value || value || undefined }), _jsx(FloatingPortal, { preserveTabOrder: true, children: open ? (_jsx(FloatingFocusManager, { guards: true, returnFocus: false, context: context, initialFocus: -1, visuallyHiddenDismiss: true, children: _jsxs("ul", { ...getFloatingProps({
|
|
176
|
+
}), "data-value": value, "data-error": !!error, "data-name": id, "data-target": id, required: required, value: open ? shadow : label || value, "aria-autocomplete": "list", autoComplete: "off", className: css("input placeholder-input-mask group h-input-height w-full flex-1", "rounded-md bg-transparent px-input-x py-input-y text-foreground", "outline-none transition-colors focus:ring-2 focus:ring-inset focus:ring-primary", "group-error:text-danger group-error:placeholder-input-mask-error", "group-focus-within:border-primary group-hover:border-primary line-clamp-1", props.className) }), _jsx("input", { id: id, name: id, type: "hidden", "data-origin": id, ref: externalRef, required: required, defaultValue: props.value || value || undefined }), _jsx(FloatingPortal, { preserveTabOrder: true, children: open ? (_jsx(FloatingFocusManager, { disabled: props.disabled, guards: true, returnFocus: false, context: context, initialFocus: -1, visuallyHiddenDismiss: true, children: _jsxs("ul", { ...getFloatingProps({
|
|
169
177
|
ref: refs.setFloating,
|
|
170
178
|
style: {
|
|
171
179
|
position: strategy,
|
|
172
|
-
left: (x ?? 0) + (!!value ? 26 :
|
|
180
|
+
left: (x ?? 0) + (!!value ? 26 : 18),
|
|
173
181
|
top: y ?? 0,
|
|
174
182
|
...transitions.styles,
|
|
175
183
|
},
|
|
176
|
-
}), "data-floating": "true", className: "z-floating m-0 origin-[top_center] list-none overflow-auto overflow-y-auto overscroll-contain rounded-b-lg rounded-t-lg border border-floating-border bg-floating-background p-0 text-foreground shadow-floating", children: [list.map((option, i) => {
|
|
184
|
+
}), "data-floating": "true", className: "container z-floating m-0 origin-[top_center] list-none overflow-auto overflow-y-auto overscroll-contain rounded-b-lg rounded-t-lg border border-floating-border bg-floating-background p-0 text-foreground shadow-floating", children: [list.map((option, i) => {
|
|
177
185
|
const active = value === option.value || value === option.label;
|
|
178
186
|
return (_jsx(Option, { ...getItemProps({
|
|
179
187
|
onClick: () => onSelect(option, i),
|
|
180
188
|
ref: (node) => void (listRef.current[i] = node),
|
|
181
189
|
selected: index === i,
|
|
182
190
|
}), option: option, active: active, selected: index === i }, `${option.value}-option`));
|
|
183
|
-
}), list.length === 0 ? (_jsx("li", { role: "option", className: "w-full border-b border-tooltip-border last:border-
|
|
191
|
+
}), list.length === 0 ? (_jsx("li", { role: "option", className: "w-full border-b border-tooltip-border last:border-b-0", children: _jsx("span", { className: "flex w-full justify-between p-2 text-left text-disabled", children: emptyMessage || translation.autocompleteEmpty }) })) : null] }) })) : null })] }));
|
|
184
192
|
});
|
|
@@ -4,7 +4,7 @@ import { CalendarProps } from "../display/calendar";
|
|
|
4
4
|
import { InputProps } from "./input";
|
|
5
5
|
export type DatePickerProps = Override<InputProps, CalendarProps<"date">>;
|
|
6
6
|
export declare const DatePicker: React.ForwardRefExoticComponent<(Omit<Omit<InputProps, "onChange" | "date" | "locale" | "markRange" | "markToday" | "rangeMode" | "styles" | "changeOnlyOnClick" | "onChangeYear" | "onChangeMonth" | "RenderOnDay" | "disabledDate" | "labelRange"> & Partial<{
|
|
7
|
-
locale: import("the-mask-input").Locales;
|
|
7
|
+
locale: import("the-mask-input/dist/src/types").Locales;
|
|
8
8
|
markRange: boolean;
|
|
9
9
|
markToday: boolean;
|
|
10
10
|
rangeMode: boolean;
|
|
@@ -33,7 +33,7 @@ export declare const DatePicker: React.ForwardRefExoticComponent<(Omit<Omit<Inpu
|
|
|
33
33
|
date: Date;
|
|
34
34
|
onChange: (d: Date | undefined) => void;
|
|
35
35
|
}>, "ref"> | Omit<Omit<InputProps, "onChange" | "date" | "locale" | "markRange" | "markToday" | "rangeMode" | "styles" | "changeOnlyOnClick" | "onChangeYear" | "onChangeMonth" | "RenderOnDay" | "disabledDate" | "labelRange"> & Partial<{
|
|
36
|
-
locale: import("the-mask-input").Locales;
|
|
36
|
+
locale: import("the-mask-input/dist/src/types").Locales;
|
|
37
37
|
markRange: boolean;
|
|
38
38
|
markToday: boolean;
|
|
39
39
|
rangeMode: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"free-text.d.ts","sourceRoot":"","sources":["../../../../src/components/form/free-text.tsx"],"names":[],"mappings":"AACA,OAAO,KAAwC,MAAM,OAAO,CAAC;AAC7D,OAAO,SAAS,EAAE,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"free-text.d.ts","sourceRoot":"","sources":["../../../../src/components/form/free-text.tsx"],"names":[],"mappings":"AACA,OAAO,KAAwC,MAAM,OAAO,CAAC;AAC7D,OAAO,SAAS,EAAE,EAAE,UAAU,EAAY,MAAM,gBAAgB,CAAC;AAEjE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,aAAa,EAAc,eAAe,EAAE,MAAM,eAAe,CAAC;AAE3E,KAAK,WAAW,GAAG,OAAO,GAAG,UAAU,CAAC;AAExC,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,WAAW,EAAE,UAAU,SAAS,MAAM,IAAI,QAAQ,CAClF,UAAU,GAAG,aAAa,EAC1B,eAAe,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC,CACnE,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,CAAC,SAAS,WAAW,EAAE,IAAI,SAAS,gBAAgB,GAAG,mBAAmB,EAAE,KAAK,SAAS,MAAM,WAClH,OAAO,GAAG,UAAU,GAAG,OAAO,SAAS,eACnC,OAAO,GAAG,UAAU,gBACnB,aAAa,CAAC,CAAC,EAAE,KAAK,CAAC,aAC1B,CAAC,EAAE,EAAE,IAAI,KAAK,MAAM,IAAI,sCAqGtC,CAAC"}
|
|
@@ -34,7 +34,7 @@ export const createFreeText = (Element, elementName, defaultProps, register) =>
|
|
|
34
34
|
input.removeEventListener("keydown", goNextInputImpl);
|
|
35
35
|
};
|
|
36
36
|
}, []);
|
|
37
|
-
return (_jsx(InputField, { ...defaultProps, componentName: elementName, info: info, container: 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(Render, { ...defaultProps, ...props, id: id, name: id, type: type, "data-next": next, "aria-busy": props.disabled, "aria-disabled": props.disabled, "aria-readonly": props.readOnly, ref: mergeRefs(ref, inputRef), className: css("input placeholder-input-mask group h-input-height w-full flex-1", "rounded-md bg-transparent px-input-x py-input-y text-foreground", "outline-none transition-colors focus:ring-2 focus:ring-inset focus:ring-primary", "group-error:text-danger group-error:placeholder-input-mask-error", "resize-y group-focus-within:border-primary group-hover:border-primary", props.className) }) }));
|
|
37
|
+
return (_jsx(InputField, { ...defaultProps, componentName: elementName, info: info, container: 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, disabled: props.disabled, children: _jsx(Render, { ...defaultProps, ...props, id: id, name: id, type: type, "data-next": next, "aria-busy": props.disabled, "aria-disabled": props.disabled, "aria-readonly": props.readOnly, ref: mergeRefs(ref, inputRef), className: css("input placeholder-input-mask group h-input-height w-full flex-1", "rounded-md bg-transparent px-input-x py-input-y text-foreground", "outline-none transition-colors focus:ring-2 focus:ring-inset focus:ring-primary", "group-error:text-danger group-error:placeholder-input-mask-error", "resize-y group-focus-within:border-primary group-hover:border-primary", "disabled:cursor-not-allowed disabled:text-disabled", props.className) }) }));
|
|
38
38
|
});
|
|
39
39
|
return FreeText;
|
|
40
40
|
};
|
|
@@ -27,5 +27,5 @@ export type InputFieldProps<T extends "input" | "select" | "textarea"> = Polymor
|
|
|
27
27
|
name: string;
|
|
28
28
|
placeholder: string;
|
|
29
29
|
}>, T>;
|
|
30
|
-
export declare const InputField: <T extends "input" | "select" | "textarea">(
|
|
30
|
+
export declare const InputField: <T extends "input" | "select" | "textarea">(props: PropsWithChildren<InputFieldProps<T>>) => React.ReactElement;
|
|
31
31
|
//# 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,
|
|
1
|
+
{"version":3,"file":"input-field.d.ts","sourceRoot":"","sources":["../../../../src/components/form/input-field.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAwB,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAGvE,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,4CA6ChH,CAAC;AAEF,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,OAAO,GAAG,QAAQ,GAAG,UAAU,IAAI,gBAAgB,CACrF,OAAO,CAAC;IACJ,aAAa,EAAE,MAAM,CAAC;IACtB,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,EAAE,CAAC,CAAC,SAAS,OAAO,GAAG,QAAQ,GAAG,UAAU,EAAE,KAAK,EAAE,iBAAiB,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,YA0EpH,CAAC"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { CheckCircle, InfoIcon, XCircle } from "lucide-react";
|
|
4
|
-
import { Fragment } from "react";
|
|
4
|
+
import { forwardRef, Fragment } from "react";
|
|
5
5
|
import { useTranslations } from "../../hooks/use-components-provider";
|
|
6
6
|
import { css } from "../../lib/dom";
|
|
7
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 transition-colors group-focus-within:text-primary group-hover:text-primary group-error:text-danger", children: [title, reportStatus || info ? (_jsxs("span", { className: "flex items-center justify-center gap-1", children: [info ? (_jsx(Tooltip, { as: "button", type: "button", title: _jsxs("span", { className: "cursor-help", 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: _jsx("div", { className: "w-full max-w-48 whitespace-break-spaces break-words", 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, componentName, placeholder, hideLeft = false, required, }) => {
|
|
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 transition-colors group-focus-within:text-primary group-hover:text-primary group-disabled:text-disabled group-error:text-danger", children: [title, reportStatus || info ? (_jsxs("span", { className: "flex items-center justify-center gap-1", children: [info ? (_jsx(Tooltip, { as: "button", type: "button", title: _jsxs("span", { className: "cursor-help", 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: _jsx("div", { className: "w-full max-w-48 whitespace-break-spaces break-words", 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 = forwardRef(({ optionalText: _optionalText, left, rightLabel, container, feedback, interactive, right, info, children, error, form, id, labelClassName = "", name, title, componentName, placeholder, hideLeft = false, required, disabled, }, ref) => {
|
|
10
10
|
const ID = id ?? name;
|
|
11
11
|
const translation = useTranslations();
|
|
12
12
|
const optionalText = _optionalText ?? translation.inputOptionalLabel;
|
|
13
|
-
return (_jsxs("fieldset", { form: form, "data-error": !!error, "data-component": componentName, "data-interactive": !!interactive, className: css("group grid min-h-0 min-w-0 grid-cols-1 items-baseline", container), children: [_jsxs("label", { form: form, htmlFor: ID, className: "inline-flex cursor-text flex-row flex-wrap justify-between gap-1 text-sm transition-colors empty:hidden group-error:text-danger", children: [_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 }), _jsxs("div", { className: `group relative 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-hover:border-primary group-error:border-danger ${labelClassName}`, children: [left ? _jsx("span", { className: "flex flex-nowrap gap-1 whitespace-nowrap pl-2", children: left }) : null, children, right ? _jsx("span", { className: "flex flex-nowrap gap-2 whitespace-nowrap pr-2", children: right }) : null] })] }), _jsx("p", { className: "mt-input-gap hidden flex-shrink-0 flex-grow-0 whitespace-pre-wrap text-wrap text-xs empty:mt-0 empty:hidden group-has-[input:not(:focus):invalid[data-initialized=true]]:inline-block group-error:inline-block group-error:text-danger", children: error }), _jsx("p", { className: "mt-input-gap text-xs empty:mt-0 empty:hidden group-has-[input:not(:focus):valid[data-initialized=true]]:block group-assert:block group-error:hidden", children: feedback })] }));
|
|
14
|
-
};
|
|
13
|
+
return (_jsxs("fieldset", { ref: ref, form: form, disabled: disabled, "data-error": !!error, "aria-disabled": disabled, "data-component": componentName, "data-interactive": !!interactive, className: css("group grid min-h-0 min-w-0 grid-cols-1 items-baseline", container), children: [_jsxs("label", { form: form, htmlFor: ID, className: "inline-flex cursor-text flex-row flex-wrap justify-between gap-1 text-sm transition-colors empty:hidden group-disabled:cursor-not-allowed group-error:text-danger", children: [_jsx(InputFeedback, { info: info, hideLeft: hideLeft, reportStatus: true, title: title, placeholder: placeholder, children: optionalText || rightLabel ? (_jsxs(Fragment, { children: [!required ? (_jsx("span", { "aria-disabled": disabled, className: "text-opacity-70 aria-disabled:text-disabled", children: optionalText })) : null, rightLabel ? _jsx(Fragment, { children: rightLabel }) : null] })) : null }), _jsxs("div", { className: `group relative 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-hover:border-primary group-disabled:border-disabled group-error:border-danger ${labelClassName}`, children: [left ? _jsx("span", { className: "flex flex-nowrap gap-1 whitespace-nowrap pl-2", children: left }) : null, children, right ? _jsx("span", { className: "flex flex-nowrap gap-2 whitespace-nowrap pr-2", children: right }) : null] })] }), _jsx("p", { className: "mt-input-gap hidden flex-shrink-0 flex-grow-0 whitespace-pre-wrap text-wrap text-xs empty:mt-0 empty:hidden group-has-[input:not(:focus):invalid[data-initialized=true]]:inline-block group-error:inline-block group-error:text-danger", children: error }), _jsx("p", { className: "mt-input-gap text-xs empty:mt-0 empty:hidden group-has-[input:not(:focus):valid[data-initialized=true]]:block group-assert:block group-error:hidden", children: feedback })] }));
|
|
14
|
+
});
|
|
@@ -1,5 +1,18 @@
|
|
|
1
|
-
import { TheMaskProps } from "the-mask-input";
|
|
1
|
+
import { AllMasks, CurrencyCode, CurrencyInputProps, CurrencyMaskTypes, Locales, PercentInputMask, PercentInputProps, TheMaskProps } from "the-mask-input";
|
|
2
2
|
import { FreeTextProps } from "./free-text";
|
|
3
|
-
export type
|
|
4
|
-
export
|
|
3
|
+
export type * from "the-mask-input";
|
|
4
|
+
export type InputProps = FreeTextProps<"input", ({
|
|
5
|
+
mask?: CurrencyMaskTypes;
|
|
6
|
+
locale?: Locales;
|
|
7
|
+
currency?: CurrencyCode;
|
|
8
|
+
} & CurrencyInputProps) | ({
|
|
9
|
+
mask?: PercentInputMask;
|
|
10
|
+
locale?: Locales;
|
|
11
|
+
currency?: undefined;
|
|
12
|
+
} & PercentInputProps) | ({
|
|
13
|
+
mask?: AllMasks | Array<string | RegExp> | ((p: string) => Array<string | RegExp> | AllMasks);
|
|
14
|
+
locale?: undefined;
|
|
15
|
+
currency?: undefined;
|
|
16
|
+
} & TheMaskProps)>;
|
|
17
|
+
export declare const Input: import("react").FC<FreeTextProps<"input", InputProps>>;
|
|
5
18
|
//# sourceMappingURL=input.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../../../src/components/form/input.tsx"],"names":[],"mappings":"AACA,OAAkB,
|
|
1
|
+
{"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../../../src/components/form/input.tsx"],"names":[],"mappings":"AACA,OAAkB,EACd,QAAQ,EACR,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,OAAO,EACP,gBAAgB,EAChB,iBAAiB,EACjB,YAAY,EACf,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAkB,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5D,mBAAmB,gBAAgB,CAAC;AAEpC,MAAM,MAAM,UAAU,GAAG,aAAa,CAClC,OAAO,EACL,CAAC;IACG,IAAI,CAAC,EAAE,iBAAiB,CAAC;IACzB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,YAAY,CAAC;CAC3B,GAAG,kBAAkB,CAAC,GACvB,CAAC;IACG,IAAI,CAAC,EAAE,gBAAgB,CAAC;IACxB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACxB,GAAG,iBAAiB,CAAC,GACtB,CAAC;IACG,IAAI,CAAC,EAAE,QAAQ,GAAG,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,MAAM,KAAK,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,GAAG,QAAQ,CAAC,CAAC;IAC9F,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACxB,GAAG,YAAY,CAAC,CACtB,CAAC;AAEF,eAAO,MAAM,KAAK,wDAA8F,CAAC"}
|
|
@@ -4,6 +4,7 @@ import { Locales } from "the-mask-input";
|
|
|
4
4
|
declare const defaultTranslations: {
|
|
5
5
|
emptyDataMessage: string;
|
|
6
6
|
inputCaretDown: string;
|
|
7
|
+
inputCloseValue: string;
|
|
7
8
|
datePickerCalendarButtonLabel: string;
|
|
8
9
|
inputOptionalLabel: string;
|
|
9
10
|
autocompleteEmpty: string;
|
|
@@ -62,6 +63,7 @@ export declare const useLocale: () => Locales | undefined;
|
|
|
62
63
|
export declare const useTranslations: () => {
|
|
63
64
|
emptyDataMessage: string;
|
|
64
65
|
inputCaretDown: string;
|
|
66
|
+
inputCloseValue: string;
|
|
65
67
|
datePickerCalendarButtonLabel: string;
|
|
66
68
|
inputOptionalLabel: string;
|
|
67
69
|
autocompleteEmpty: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-components-provider.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-components-provider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAA2B,iBAAiB,EAAuB,MAAM,OAAO,CAAC;AAC/F,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEzC,QAAA,MAAM,mBAAmB
|
|
1
|
+
{"version":3,"file":"use-components-provider.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-components-provider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAA2B,iBAAiB,EAAuB,MAAM,OAAO,CAAC;AAC/F,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEzC,QAAA,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wCAgDe;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,KAAK,CAAC,SAAS,CAAA;KAAE;;;;CASxI,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,OAAO,mBAAmB,CAAC;AAQtD,KAAK,YAAY,GAAG,OAAO,CAAC;IACxB,GAAG,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;IAC3B,MAAM,EAAE,OAAO,GAAG,SAAS,CAAC;IAC5B,MAAM,EAAE,OAAO,OAAO,CAAC,IAAI,CAAC;CAC/B,CAAC,CAAC;AAEH,eAAO,MAAM,kBAAkB,UAAW,iBAAiB,CAAC,YAAY,CAAC,4CAMxE,CAAC;AAEF,eAAO,MAAM,SAAS,QAAO,OAAO,GAAG,SAItC,CAAC;AAEF,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wCAvCY;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,KAAK,CAAC,SAAS,CAAA;KAAE;;;;CA2CxI,CAAC;AAEF,eAAO,MAAM,cAAc,wCAI1B,CAAC"}
|
|
@@ -5,6 +5,7 @@ import { parsers } from "../../preset.tailwind";
|
|
|
5
5
|
const defaultTranslations = {
|
|
6
6
|
emptyDataMessage: "No data",
|
|
7
7
|
inputCaretDown: "Click to see all options",
|
|
8
|
+
inputCloseValue: "Click to clear the value",
|
|
8
9
|
datePickerCalendarButtonLabel: "Click to open a date picker",
|
|
9
10
|
inputOptionalLabel: "Optional",
|
|
10
11
|
autocompleteEmpty: "Nothing here...",
|
|
@@ -52,11 +53,7 @@ const Context = createContext({
|
|
|
52
53
|
locale: undefined,
|
|
53
54
|
});
|
|
54
55
|
export const ComponentsProvider = (props) => {
|
|
55
|
-
const memoMap = useMemo(() => ({
|
|
56
|
-
locale: props.locale,
|
|
57
|
-
translations: { ...defaultTranslations, ...props.map },
|
|
58
|
-
colorTokenParser: props.parser || parsers.hsla,
|
|
59
|
-
}), [props]);
|
|
56
|
+
const memoMap = useMemo(() => ({ locale: props.locale, translations: { ...defaultTranslations, ...props.map }, colorTokenParser: props.parser || parsers.hsla, }), [props]);
|
|
60
57
|
return _jsx(Context.Provider, { value: memoMap, children: props.children });
|
|
61
58
|
};
|
|
62
59
|
export const useLocale = () => {
|
package/dist/src/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export * from "./components";
|
|
|
2
2
|
export * from "./hooks/use-form";
|
|
3
3
|
export * from "./hooks/use-previous";
|
|
4
4
|
export * from "./hooks/use-reactive";
|
|
5
|
-
export { ComponentsProvider, useTranslations } from "./hooks/use-components-provider";
|
|
5
|
+
export { ComponentsProvider, useTranslations, type Translations, useLocale, useColorParser } from "./hooks/use-components-provider";
|
|
6
6
|
export * from "./lib/dom";
|
|
7
7
|
export * from "./lib/fns";
|
|
8
8
|
export * from "./styles/theme";
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,KAAK,YAAY,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACpI,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC;AACvC,mBAAmB,SAAS,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC"}
|
package/dist/src/index.js
CHANGED
|
@@ -2,7 +2,7 @@ export * from "./components";
|
|
|
2
2
|
export * from "./hooks/use-form";
|
|
3
3
|
export * from "./hooks/use-previous";
|
|
4
4
|
export * from "./hooks/use-reactive";
|
|
5
|
-
export { ComponentsProvider, useTranslations } from "./hooks/use-components-provider";
|
|
5
|
+
export { ComponentsProvider, useTranslations, useLocale, useColorParser } from "./hooks/use-components-provider";
|
|
6
6
|
export * from "./lib/dom";
|
|
7
7
|
export * from "./lib/fns";
|
|
8
8
|
export * from "./styles/theme";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fns.d.ts","sourceRoot":"","sources":["../../../src/lib/fns.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"fns.d.ts","sourceRoot":"","sources":["../../../src/lib/fns.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAI3C,eAAO,MAAM,IAAI,QAAO,MAUvB,CAAC;AAUF,eAAO,MAAM,IAAI,GAAI,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,QAGxE,CAAC;AAEF,eAAO,MAAM,KAAK,eAAsC,CAAC;AAEzD,eAAO,MAAM,SAAS,WAAY,MAAM,WAAkD,CAAC;AAE3F,eAAO,MAAM,SAAS,GAAI,CAAC,yBAAqB,CAAC,EAAE,QAAQ,MAAM,UAQhE,CAAC"}
|
package/dist/src/lib/fns.js
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
const toHex = (n, length = 2) => n.toString(16).padStart(length, "0");
|
|
2
|
+
export const uuid = () => {
|
|
3
|
+
const now = Date.now();
|
|
4
|
+
const timeHigh = ((now / 1000) & 0x0fff) | 0x7000;
|
|
5
|
+
const timeLow = now % 1000;
|
|
6
|
+
const randomBytes = new Uint8Array(10);
|
|
7
|
+
for (let i = 0; i < randomBytes.length; i++) {
|
|
8
|
+
randomBytes[i] = Math.floor(Math.random() * 256);
|
|
9
|
+
}
|
|
10
|
+
randomBytes[0] = (randomBytes[0] & 0x3f) | 0x80;
|
|
11
|
+
return `${toHex(timeHigh, 4) + toHex(timeLow, 3)}-${toHex(randomBytes[0]) + toHex(randomBytes[1])}-${toHex(randomBytes[2]) + toHex(randomBytes[3])}-${toHex(randomBytes[4]) + toHex(randomBytes[5])}-${toHex(randomBytes[6]) + toHex(randomBytes[7]) + toHex(randomBytes[8]) + toHex(randomBytes[9])}`;
|
|
12
|
+
};
|
|
6
13
|
const travel = (path, regexp, obj) => path
|
|
7
14
|
.split(regexp)
|
|
8
15
|
.filter(Boolean)
|