@g4rcez/components 2.0.7 → 2.0.9

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.
@@ -20,21 +20,23 @@ export type CalendarProps = Partial<{
20
20
  markRange: boolean;
21
21
  markToday: boolean;
22
22
  rangeMode: boolean;
23
+ datetimeTitle: string;
23
24
  styles: CalendarStyles;
25
+ type?: "date" | "datetime";
24
26
  changeOnlyOnClick: boolean;
25
27
  locale: Locales | undefined;
26
28
  onChangeYear: (d: Date) => void;
27
29
  onChangeMonth: (d: Date) => void;
30
+ disabledDate: (date: Date) => boolean;
28
31
  RenderOnDay: React.FC<{
29
32
  date: Date;
30
33
  }>;
31
- disabledDate: (date: Date) => boolean;
32
34
  onChange: OnChangeRange | OnChangeDate;
33
35
  labelRange: {
34
36
  to: string;
35
37
  from: string;
36
38
  };
37
39
  }>;
38
- export declare const Calendar: ({ RenderOnDay, changeOnlyOnClick, labelRange, disabledDate, locale, markToday, onChangeMonth, onChangeYear, rangeMode, onChange, styles, markRange, ...props }: CalendarProps) => import("react/jsx-runtime").JSX.Element;
40
+ export declare const Calendar: ({ RenderOnDay, changeOnlyOnClick, labelRange, disabledDate, locale, markToday, onChangeMonth, onChangeYear, rangeMode, onChange, styles, markRange, type, datetimeTitle, ...props }: CalendarProps) => import("react/jsx-runtime").JSX.Element;
39
41
  export {};
40
42
  //# sourceMappingURL=calendar.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"calendar.d.ts","sourceRoot":"","sources":["../../../src/components/display/calendar.tsx"],"names":[],"mappings":"AAiBA,OAAO,KAA4C,MAAM,OAAO,CAAC;AAEjE,OAAqB,EAAE,KAAK,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAuB5D,KAAK,KAAK,GAAG;IAAE,IAAI,CAAC,EAAE,IAAI,CAAC;IAAC,EAAE,CAAC,EAAE,IAAI,CAAA;CAAE,CAAC;AAExC,KAAK,YAAY,GAAG,CAAC,CAAC,EAAE,IAA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AAI,CAAC,EAAE,MAAM,GAAG,UAAU,CAAA;IAC1B,iBAAiB,EAAE,OAAO,CAAC;IAC3B,MAAM,EAAE,OAAO,GAAG,SAAS,CAAC;IAC5B,YAAY,EAAE,CAAC,CAAC,EAAE,IAAI,KAAK,IAAI,CAAC;IAChC,aAAa,EAAE,CAAC,CAAC,EAAE,IAAI,KAAK,IAAI,CAAC;IACjC,YAAY,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC;IACtC,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC;QAAE,IAAI,EAAE,IAAI,CAAA;KAAE,CAAC,CAAC;IACtC,QAAQ,EAAE,aAAa,GAAG,YAAY,CAAC;IACvC,UAAU,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CAC5C,CAAC,CAAC;AA0IH,eAAO,MAAM,QAAQ,GAAI,qLAgBtB,aAAa,4CA+Rf,CAAC"}
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { add, eachDayOfInterval, endOfWeek, isAfter, isBefore, isSameMonth, isToday, setYear, startOfDay, startOfMonth, startOfWeek, sub, } from "date-fns";
3
+ import { add, eachDayOfInterval, endOfWeek, isAfter, isBefore, isSameMonth, isToday, setYear, startOfDay, startOfMonth, startOfWeek, sub, format, set, } from "date-fns";
4
4
  import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react";
5
5
  import { AnimatePresence, motion, MotionConfig } from "motion/react";
6
6
  import { useEffect, useRef } from "react";
@@ -13,6 +13,8 @@ import { useSwipe } from "../../hooks/use-swipe";
13
13
  import { useTranslations } from "../../hooks/use-translations";
14
14
  import { css } from "../../lib/dom";
15
15
  import { splitInto, uuid } from "../../lib/fns";
16
+ import { Input } from "../form/input";
17
+ const timeRegex = /^(?<hour>\d\d):(?<min>\d\d)$/;
16
18
  const transition = { type: "spring", bounce: 0.3, duration: 0.6 };
17
19
  const dir = (mod) => (n = 1) => ({ x: `${100 * mod * n}%`, opacity: 0.25 });
18
20
  const variants = {
@@ -68,7 +70,7 @@ const CalendarBody = (props) => {
68
70
  const key = day.toISOString();
69
71
  const isSelected = props.rangeMode
70
72
  ? key === props.range?.to?.toISOString() || key === props.range?.from?.toISOString()
71
- : key === props.date?.toISOString();
73
+ : key === (props.date ? startOfDay(props.date).toISOString() : undefined);
72
74
  const today = isToday(day) && props.markToday;
73
75
  const disabledByFn = props.disabledDate?.(day) || false;
74
76
  const sameMonth = isSameMonth(day, props.stateDate);
@@ -78,8 +80,8 @@ const CalendarBody = (props) => {
78
80
  }) }, `week-${week.length}-${index}`));
79
81
  }) }));
80
82
  };
81
- const setToday = () => startOfDay(new Date());
82
- export const Calendar = ({ RenderOnDay, changeOnlyOnClick = false, labelRange, disabledDate, locale, markToday = true, onChangeMonth, onChangeYear, rangeMode = false, onChange, styles, markRange = true, ...props }) => {
83
+ const getToday = () => startOfDay(new Date());
84
+ export const Calendar = ({ RenderOnDay, changeOnlyOnClick = false, labelRange, disabledDate, locale, markToday = true, onChangeMonth, onChangeYear, rangeMode = false, onChange, styles, markRange = true, type = "date", datetimeTitle, ...props }) => {
83
85
  const id = useRef(uuid());
84
86
  const translations = useTranslations();
85
87
  const currentLocale = useLocale(locale);
@@ -217,11 +219,21 @@ export const Calendar = ({ RenderOnDay, changeOnlyOnClick = false, labelRange, d
217
219
  return direction === "right" ? dispatch.previousMonth() : dispatch.nextMonth();
218
220
  }, 10);
219
221
  const onSetToday = () => {
220
- const d = setToday();
222
+ const d = getToday();
221
223
  dispatch.date(() => d);
222
224
  onChange?.(d);
223
225
  };
224
226
  return (_jsx(MotionConfig, { transition: transition, children: _jsxs("div", { ref: root, "data-component": "calendar", onTouchEnd: swipe.onTouchEnd, onTouchStart: swipe.onTouchStart, className: css("relative overflow-hidden", Is.function(styles?.calendar) ? styles?.calendar(allDaysOfMonth) : styles?.calendar), children: [_jsx("div", { className: "flex flex-col justify-center rounded text-center", children: _jsx(AnimatePresence, { initial: false, mode: "popLayout", custom: state.direction, onExitComplete: dispatch.onExitComplete, children: _jsxs(motion.div, { initial: "enter", animate: "middle", exit: "exit", children: [_jsxs("header", { className: "relative flex justify-between", children: [_jsx(motion.button, { layout: true, type: "button", "data-focustrap": "prev", variants: removeImmediately, onClick: dispatch.previousMonth, title: translations.calendarBackMonth, className: "z-calendar rounded-full p-1.5 hover:bg-primary hover:text-primary-foreground", children: _jsx(ChevronLeftIcon, { className: "h-4 w-4" }) }), _jsx(motion.span, { layout: true, variants: variants, custom: state.direction, className: "absolute inset-0 isolate z-normal flex items-center justify-center font-semibold", children: _jsxs("span", { className: "flex w-fit items-center justify-center gap-0.5 py-1", children: [_jsx("select", { value: monthString, onChange: dispatch.onChangeMonth, "aria-label": translations.calendarMonthLabel, style: { width: `${monthString.length + 1}ch` }, className: "cursor-pointer appearance-none bg-transparent capitalize proportional-nums hover:text-primary", children: state.months }), _jsx(TheMaskInput, { mask: "int", maxLength: 4, placeholder: "YYYY", value: state.year, onChange: internalOnChangeYear, style: { width: `${state.year.length}ch` }, className: "w-16 cursor-pointer appearance-none bg-transparent hover:text-primary" })] }) }), _jsx(motion.button, { layout: true, type: "button", "data-focustrap": "next", variants: removeImmediately, onClick: dispatch.nextMonth, title: translations.calendarNextMonth, className: "z-calendar rounded-full p-1.5 hover:bg-primary hover:text-primary-foreground", children: _jsx(ChevronRightIcon, { className: "h-4 w-4" }) }), _jsx("div", { className: "absolute inset-0", style: {
225
227
  backgroundImage: "linear-gradient(to right, hsla(var(--card-background)) 15%, transparent 30%, transparent 70%, hsla(var(--card-background)) 85%)",
226
- } })] }), _jsxs(motion.table, { className: "mt-2 table min-w-full table-auto border-0", children: [_jsx("thead", { children: _jsx("tr", { children: state.week.map((dayOfWeek) => (_jsx("th", { role: "columnheader", className: css("py-2 text-sm font-medium capitalize", Is.function(styles?.weekDay) ? styles.weekDay(dayOfWeek) : styles?.weekDay), children: dayOfWeek.toLocaleDateString(currentLocale, { weekday: "short" }) }, dayOfWeek.toString()))) }) }), _jsx(CalendarBody, { zip: zip, range: range, styles: styles, date: date || null, dispatch: dispatch, markRange: markRange, markToday: markToday, rangeMode: rangeMode, stateDate: state.date, labelRange: labelRange, stateRange: state.range, RenderOnDay: RenderOnDay, direction: state.direction, disabledDate: disabledDate, onKeyDown: dispatch.onKeyDown })] })] }, monthString) }) }), _jsx("footer", { className: "mt-2 text-center text-primary", children: _jsx("button", { type: "button", onClick: onSetToday, className: "transition-transform duration-300 hover:scale-105", children: translations.calendarToday }) })] }) }));
228
+ } })] }), _jsxs(motion.table, { className: "mt-2 table min-w-full table-auto border-0", children: [_jsx("thead", { children: _jsx("tr", { children: state.week.map((dayOfWeek) => (_jsx("th", { role: "columnheader", className: css("py-2 text-sm font-medium capitalize", Is.function(styles?.weekDay) ? styles.weekDay(dayOfWeek) : styles?.weekDay), children: dayOfWeek.toLocaleDateString(currentLocale, { weekday: "short" }) }, dayOfWeek.toString()))) }) }), _jsx(CalendarBody, { zip: zip, range: range, styles: styles, date: date || null, dispatch: dispatch, markRange: markRange, markToday: markToday, rangeMode: rangeMode, stateDate: state.date, labelRange: labelRange, stateRange: state.range, RenderOnDay: RenderOnDay, direction: state.direction, disabledDate: disabledDate, onKeyDown: dispatch.onKeyDown })] })] }, monthString) }) }), type === "datetime" ? (_jsx("section", { className: "grid items-center my-4", children: _jsx(Input, { info: null, mask: "time", optionalText: " ", container: "w-full", reportStatus: false, defaultValue: date ? format(date, "HH:mm") : undefined, title: datetimeTitle || translations.calendarDatetimeTitle, onChange: e => {
229
+ const value = e.target.value;
230
+ const match = timeRegex.exec(value);
231
+ if (!match)
232
+ return;
233
+ const hour = match.groups.hour;
234
+ const min = match.groups.min;
235
+ const d = set(state.date, { hours: Number(hour), minutes: Number(min), seconds: 0 });
236
+ dispatch.date(() => d);
237
+ onChange?.(d);
238
+ } }) })) : null, _jsx("footer", { className: "mt-2 text-center text-primary", children: _jsx("button", { type: "button", onClick: onSetToday, className: "transition-transform duration-300 hover:scale-105", children: translations.calendarToday }) })] }) }));
227
239
  };
@@ -1 +1 @@
1
- {"version":3,"file":"dropdown.d.ts","sourceRoot":"","sources":["../../../src/components/floating/dropdown.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,EAAY,iBAAiB,EAAoC,MAAM,OAAO,CAAC;AAE7F,KAAK,aAAa,GAAG;IACjB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;IACxC,OAAO,EAAE,KAAK,CAAC,YAAY,GAAG,KAAK,CAAC,SAAS,CAAC;IAC9C,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC,YAAY,GAAG,MAAM,CAAC;IACtD,WAAW,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;CAChD,CAAC;AAEF,eAAO,MAAM,QAAQ,GAAI,OAAO,iBAAiB,CAAC,aAAa,CAAC,4CAoE/D,CAAC"}
1
+ {"version":3,"file":"dropdown.d.ts","sourceRoot":"","sources":["../../../src/components/floating/dropdown.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,EAAY,iBAAiB,EAA+C,MAAM,OAAO,CAAC;AAExG,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,GAAI,OAAO,iBAAiB,CAAC,aAAa,CAAC,4CAqE/D,CAAC"}
@@ -1,10 +1,11 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { arrow, autoUpdate, flip, FloatingArrow, FloatingFocusManager, FloatingPortal, offset, shift, useClick, useDismiss, useFloating, useInteractions, useRole, } from "@floating-ui/react";
4
- import { Fragment, useId, useMemo, useRef, useState } from "react";
4
+ import { Fragment, useEffect, useId, useMemo, useRef, useState } from "react";
5
5
  export const Dropdown = (props) => {
6
6
  const headingId = useId();
7
7
  const [open, setOpen] = useState(props.open);
8
+ useEffect(() => setOpen(props.open), [props.open]);
8
9
  const arrowRef = useRef(null);
9
10
  const middleware = useMemo(() => [
10
11
  offset(10),
@@ -1 +1 @@
1
- {"version":3,"file":"autocomplete.d.ts","sourceRoot":"","sources":["../../../src/components/form/autocomplete.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAoF,MAAM,OAAO,CAAC;AASzG,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAc,eAAe,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,UAAU,CAAC;AAG5C,MAAM,MAAM,qBAAqB,GAAG,WAAW,GAAG;IAAE,MAAM,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAAC,CAAA;CAAE,CAAC;AAErF,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,GAAG;IACtE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,KAAK,CAAC;IACrB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,OAAO,EAAE,qBAAqB,EAAE,CAAC;CACpC,CAAC;AAiCF,eAAO,MAAM,YAAY,yGA0WxB,CAAC"}
1
+ {"version":3,"file":"autocomplete.d.ts","sourceRoot":"","sources":["../../../src/components/form/autocomplete.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAoF,MAAM,OAAO,CAAC;AASzG,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,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,iBAAiB,GAAG,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,GAAG;IACtE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,KAAK,CAAC;IACrB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,OAAO,EAAE,qBAAqB,EAAE,CAAC;CACpC,CAAC;AAiCF,eAAO,MAAM,YAAY,yGAsWxB,CAAC"}
@@ -13,7 +13,6 @@ import { css, dispatchInput, getRemainingSize, initializeInputDataset, mergeRefs
13
13
  import { safeRegex } from "../../lib/fns";
14
14
  import { fzf } from "../../lib/fzf";
15
15
  import { InputField } from "./input-field";
16
- import { useReducer } from "use-typed-reducer";
17
16
  const Frag = (props) => _jsx(Fragment, { children: props.children });
18
17
  const transitionStyles = {
19
18
  duration: 300,
@@ -34,59 +33,43 @@ export const Autocomplete = forwardRef(({ left, error, right, loading, options,
34
33
  const scroller = useRef(null);
35
34
  const fieldset = useRef(null);
36
35
  const virtuoso = useRef(null);
37
- const defaults = options.length === 0 ? "" : props.value ?? props.defaultValue ?? "";
36
+ const defaults = props.value ?? props.defaultValue ?? "";
38
37
  const translation = useTranslations();
39
- const [state, dispatch] = useReducer({
40
- open: false,
41
- shadow: "",
42
- value: defaults,
43
- label: options.find((x) => x.value === defaults)?.label ?? defaults,
44
- index: null
45
- }, (get) => ({
46
- open: (open) => ({ open }),
47
- index: (index) => ({ index }),
48
- shadow: (shadow) => ({ shadow }),
49
- option: (value, label) => ({ value, label }),
50
- select: (value, label, index) => ({ open: false, shadow: "", index, value, label }),
51
- caretDown: () => ({ open: true, shadow: "" }),
52
- onClose: () => ({ open: false, label: "", value: "", shadow: "" }),
53
- onFocus: () => {
54
- const prev = get.state();
55
- return { index: prev.index === null ? 0 : prev.index, open: true, shadow: "" };
56
- }
57
- }));
58
38
  const [h, setH] = useState(() => Math.min(320, MIN_SIZE * options.length));
39
+ const [open, setOpen] = useState(false);
40
+ const [shadow, setShadow] = useState("");
41
+ const [value, setValue] = useState(defaults);
42
+ const [label, setLabel] = useState(() => options.find((x) => x.value === defaults)?.label ?? defaults);
43
+ const [index, setIndex] = useState(null);
59
44
  const listRef = useRef(emptyRef);
60
- const removeScrollRef = useRemoveScroll(state.open, "block-only");
61
- const innerOptions = dynamicOption && state.shadow !== ""
45
+ const removeScrollRef = useRemoveScroll(open, "block-only");
46
+ const innerOptions = dynamicOption && shadow !== ""
62
47
  ? [
63
48
  {
64
- value: state.shadow,
65
- label: state.shadow,
49
+ value: shadow,
50
+ label: shadow,
66
51
  "data-dynamic": "true",
67
52
  },
68
53
  ...options,
69
54
  ]
70
55
  : options;
71
- const list = state.shadow
72
- ? fzf(innerOptions, "value", [
73
- { key: "value", value: state.shadow },
74
- { key: "label", value: state.shadow },
75
- ])
56
+ const openDropdown = () => flushSync(() => setOpen(true));
57
+ const list = shadow
58
+ ? fzf(innerOptions, "value", [{ key: "value", value: shadow }, { key: "label", value: shadow }])
76
59
  : innerOptions;
77
60
  const setClosed = () => {
61
+ setOpen(false);
78
62
  setH(0);
79
- dispatch.open(false);
80
63
  };
81
64
  const displayList = list.filter((x) => x.hidden !== true);
82
65
  const pattern = dynamicOption
83
66
  ? undefined
84
67
  : `^(${options.map((x) => `${safeRegex(x.value)}${x.label ? "|" + safeRegex(x.label) : ""}`).join("|")})$`;
85
68
  const { x, y, strategy, refs, context } = useFloating({
86
- open: state.open,
69
+ open,
87
70
  transform: true,
71
+ onOpenChange: setOpen,
88
72
  placement: "bottom-start",
89
- onOpenChange: dispatch.open,
90
73
  whileElementsMounted: autoUpdate,
91
74
  middleware: [
92
75
  offset(4),
@@ -115,20 +98,20 @@ export const Autocomplete = forwardRef(({ left, error, right, loading, options,
115
98
  loop: true,
116
99
  virtual: true,
117
100
  allowEscape: true,
101
+ activeIndex: index,
102
+ selectedIndex: index,
118
103
  focusItemOnOpen: "auto",
119
104
  openOnArrowKeyDown: true,
120
105
  scrollItemIntoView: true,
121
- activeIndex: state.index,
122
- selectedIndex: state.index,
123
106
  }),
124
107
  ]);
125
108
  useEffect(() => {
126
109
  if (props.value) {
127
- if (options.length === 0)
128
- return dispatch.option("", "");
129
110
  const item = options.find((x) => x.value === props.value);
130
- if (item)
131
- return dispatch.option(item.value, item.label ?? item.value);
111
+ if (item) {
112
+ setLabel(item.label ?? item.value);
113
+ setValue(props.value);
114
+ }
132
115
  }
133
116
  }, [props.value, options.length]);
134
117
  useEffect(() => {
@@ -139,7 +122,7 @@ export const Autocomplete = forwardRef(({ left, error, right, loading, options,
139
122
  return;
140
123
  const s = getRemainingSize(inputRef.current, window.innerHeight);
141
124
  setTimeout(() => setH(Math.min(s, displayList.length * MIN_SIZE)), 100);
142
- }, [state.shadow, state.open, refs.reference, displayList.length]);
125
+ }, [shadow, open, refs.reference, displayList.length]);
143
126
  useEffect(() => {
144
127
  const input = refs.reference.current;
145
128
  if (!input)
@@ -147,43 +130,55 @@ export const Autocomplete = forwardRef(({ left, error, right, loading, options,
147
130
  return initializeInputDataset(input);
148
131
  }, []);
149
132
  const onSelect = (opt, i) => {
133
+ setValue(opt.value);
150
134
  const input = refs.reference.current;
151
- if (!input) {
152
- return void dispatch.option(opt.value, opt.label ?? opt.value);
153
- }
135
+ if (!input)
136
+ return;
154
137
  input?.setAttribute("data-value", opt.value);
155
138
  input.value = opt.value;
156
139
  const event = new Event("change", { bubbles: false, cancelable: true });
157
140
  input.dispatchEvent(event);
158
141
  if (props.onChange)
159
142
  props.onChange(event);
160
- const label = options.find(x => x.value === opt.value)?.label || opt.value;
161
- dispatch.select(opt.value, label, i);
143
+ setLabel(opt.label ?? "");
144
+ setClosed();
145
+ setShadow("");
146
+ setIndex(i);
162
147
  };
163
148
  const onChange = (event) => {
164
149
  const value = event.target.value;
165
- dispatch.shadow(value);
150
+ setShadow(value);
166
151
  if (!open && value === "")
167
- return dispatch.open(true);
152
+ return setOpen(true);
168
153
  event.target.name = props.name || "";
169
- return value ? dispatch.open(true) : props.onChange?.(event);
154
+ return value ? setOpen(true) : props.onChange?.(event);
170
155
  };
171
156
  const onCaretDownClick = () => {
172
- dispatch.caretDown();
157
+ openDropdown();
158
+ setShadow("");
173
159
  refs.reference.current?.focus();
174
160
  };
161
+ const onFocus = () => {
162
+ setIndex((prev) => (prev === null ? 0 : prev));
163
+ openDropdown();
164
+ setShadow("");
165
+ };
175
166
  const onClose = () => {
176
167
  refs.reference.current?.setAttribute("data-value", "");
177
- dispatch.onClose();
168
+ setShadow("");
169
+ setValue("");
170
+ setLabel("");
178
171
  dispatchInput(refs.reference.current);
172
+ setClosed();
179
173
  };
180
174
  const id = props.id || props.name;
181
175
  const shadowId = `${id}-shadow`;
182
176
  const isEmpty = displayList.length === 0;
183
- return (_jsxs(InputField, { ...props, left: left, error: error, ref: fieldset, form: props.form, loading: loading, name: props.name, feedback: feedback, hideLeft: hideLeft, required: required, title: props.title, container: container, rightLabel: rightLabel, interactive: interactive, id: shadowId, optionalText: optionalText, componentName: "autocomplete", labelClassName: labelClassName, placeholder: props.placeholder, right: _jsxs("span", { className: "flex items-center gap-0.5", children: [right, _jsxs("button", { type: "button", className: "p-2 transition-colors link:text-primary md:p-1", onClick: onCaretDownClick, children: [_jsx(ChevronDown, { size: 20 }), _jsx("span", { className: "sr-only", children: translation.inputCaretDown })] }), state.value ? (_jsx("button", { type: "button", onClick: onClose, className: "p-2 transition-colors link:text-danger md:p-1", 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", { "data-shadow": "true", ...getReferenceProps({
177
+ return (_jsxs(InputField, { ...props, left: left, error: error, ref: fieldset, form: props.form, loading: loading, name: props.name, feedback: feedback, hideLeft: hideLeft, required: required, title: props.title, container: container, rightLabel: rightLabel, interactive: interactive, id: shadowId, optionalText: optionalText, componentName: "autocomplete", labelClassName: labelClassName, placeholder: props.placeholder, right: _jsxs("span", { className: "flex items-center gap-0.5", children: [right, _jsxs("button", { type: "button", className: "p-2 transition-colors link:text-primary md:p-1", onClick: onCaretDownClick, children: [_jsx(ChevronDown, { size: 20 }), _jsx("span", { className: "sr-only", children: translation.inputCaretDown })] }), value ? (_jsx("button", { type: "button", onClick: onClose, className: "p-2 transition-colors link:text-danger md:p-1", 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", { "data-shadow": "true", ...getReferenceProps({
184
178
  ...props,
185
- onFocus: dispatch.onFocus,
179
+ onFocus,
186
180
  pattern,
181
+ onChange,
187
182
  id: shadowId,
188
183
  name: shadowId,
189
184
  ref: refs.setReference,
@@ -196,23 +191,23 @@ export const Autocomplete = forwardRef(({ left, error, right, loading, options,
196
191
  if (!open)
197
192
  return;
198
193
  if (event.key === "ArrowDown") {
199
- let next = Is.number(state.index) ? state.index + 1 : 0;
194
+ let next = Is.number(index) ? index + 1 : 0;
200
195
  if (next > displayList.length - 1)
201
196
  next = 0;
202
197
  virtuoso.current?.scrollIntoView({ index: next });
203
- return dispatch.index(next);
198
+ return setIndex(next);
204
199
  }
205
200
  if (event.key === "ArrowUp") {
206
- let next = Is.number(state.index) ? state.index - 1 : displayList.length - 1;
201
+ let next = Is.number(index) ? index - 1 : displayList.length - 1;
207
202
  if (next < 0)
208
203
  next = displayList.length - 1;
209
204
  virtuoso.current?.scrollIntoView({ index: next });
210
- return dispatch.index(next);
205
+ return setIndex(next);
211
206
  }
212
207
  if (event.key === "Enter") {
213
- if (state.index !== null && displayList[state.index]) {
208
+ if (index !== null && displayList[index]) {
214
209
  event.preventDefault();
215
- return onSelect(displayList[state.index], state.index);
210
+ return onSelect(displayList[index], index);
216
211
  }
217
212
  if (displayList.length === 1) {
218
213
  event.preventDefault();
@@ -220,7 +215,7 @@ export const Autocomplete = forwardRef(({ left, error, right, loading, options,
220
215
  }
221
216
  }
222
217
  },
223
- }), "data-name": id, "data-target": id, autoComplete: "off", onChange: onChange, required: required, "data-error": !!error, "aria-autocomplete": "list", "data-value": state.value, placeholder: props.placeholder, value: state.open ? state.shadow : state.label || state.value, 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", "text-base 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 || state.value || undefined }), _jsx(FloatingPortal, { preserveTabOrder: true, children: open ? (_jsx(FloatingFocusManager, { modal: true, guards: true, returnFocus: false, context: context, initialFocus: -1, visuallyHiddenDismiss: true, children: _jsxs(motion.div, { ...getFloatingProps({
218
+ }), "data-value": value, "data-error": !!error, "data-name": id, "data-target": id, required: required, value: open ? shadow : options.length === 0 ? "" : 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", "text-base 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, { modal: true, guards: true, returnFocus: false, context: context, initialFocus: -1, visuallyHiddenDismiss: true, children: _jsxs(motion.div, { ...getFloatingProps({
224
219
  ref: mergeRefs(removeScrollRef, refs.setFloating),
225
220
  style: { ...transitions.styles, left: x, top: y ?? 0, position: strategy },
226
221
  }), initial: false, "data-floating": "true", animate: { height: isEmpty ? "auto" : h }, className: "isolate z-floating m-0 max-h-80 origin-[top_center] list-none overscroll-contain rounded-b-lg rounded-t-lg border border-floating-border bg-floating-background p-0 text-foreground shadow-floating ease-in-out", onAnimationComplete: () => {
@@ -232,8 +227,8 @@ export const Autocomplete = forwardRef(({ left, error, right, loading, options,
232
227
  return flushSync(() => setH(sum + 10));
233
228
  }, children: [isEmpty ? (_jsx("div", { role: "option", className: "w-full border-b border-tooltip-border", children: _jsx("span", { className: "flex w-full justify-between p-2 text-left text-disabled", children: emptyMessage || translation.autocompleteEmpty }) })) : null, _jsx(Virtuoso, { overscan: 40, ref: virtuoso, hidden: isEmpty, data: displayList, style: { height: h - 10 }, defaultItemHeight: MIN_SIZE, components: components, scrollerRef: (e) => void (scroller.current = e), className: "max-h-[calc(100%-2px)] overscroll-contain rounded-lg border-floating bg-floating-background p-0 text-foreground", itemContent: (i, option) => {
234
229
  const Label = option.Render ?? Frag;
235
- const active = state.value === option.value || state.value === option.label;
236
- const selected = state.index === i;
230
+ const active = value === option.value || value === option.label;
231
+ const selected = index === i;
237
232
  const children = option.label ?? option.value;
238
233
  return (_jsx("button", { "data-value": option.value, ...getItemProps({
239
234
  ref: (node) => void (listRef.current[i] = node),
@@ -2,6 +2,8 @@ import React from "react";
2
2
  import { Override } from "../../types";
3
3
  import { CalendarProps } from "../display/calendar";
4
4
  import { InputProps } from "./input";
5
- export type DatePickerProps = Omit<Override<InputProps, CalendarProps>, "currency">;
5
+ export type DatePickerProps = Omit<Override<InputProps, CalendarProps & {
6
+ clickToClose?: boolean;
7
+ }>, "currency">;
6
8
  export declare const DatePicker: React.ForwardRefExoticComponent<Omit<DatePickerProps, "ref"> & React.RefAttributes<HTMLInputElement>>;
7
9
  //# sourceMappingURL=date-picker.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"date-picker.d.ts","sourceRoot":"","sources":["../../../src/components/form/date-picker.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAyD,MAAM,OAAO,CAAC;AAI9E,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAY,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAE9D,OAAO,EAAS,UAAU,EAAE,MAAM,SAAS,CAAC;AAE5C,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC,EAAE,UAAU,CAAC,CAAC;AAmCpF,eAAO,MAAM,UAAU,uGA2GtB,CAAC"}
1
+ {"version":3,"file":"date-picker.d.ts","sourceRoot":"","sources":["../../../src/components/form/date-picker.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAyD,MAAM,OAAO,CAAC;AAI9E,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAY,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAE9D,OAAO,EAAS,UAAU,EAAE,MAAM,SAAS,CAAC;AAE5C,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,aAAa,GAAG;IACpE,YAAY,CAAC,EAAE,OAAO,CAAA;CACzB,CAAC,EAAE,UAAU,CAAC,CAAA;AA6Cf,eAAO,MAAM,UAAU,uGAmHtB,CAAC"}
@@ -14,33 +14,47 @@ const parts = {
14
14
  year: () => [/\d/, /\d/, /\d/, /\d/],
15
15
  month: () => [/\d/, /\d/],
16
16
  day: () => [/\d/, /\d/],
17
+ hour: () => [/\d/, /\d/],
18
+ minute: () => [/\d/, /\d/],
17
19
  literal: (str) => str.split(""),
18
20
  };
19
21
  const placeholders = {
20
- year: () => "yyyy",
21
- month: () => "MM",
22
22
  day: () => "dd",
23
+ hour: () => "HH",
24
+ month: () => "MM",
25
+ minute: () => "mm",
26
+ year: () => "yyyy",
23
27
  literal: (str) => str,
24
28
  };
25
29
  const partValues = {
26
- literal: (date, str) => str,
27
- year: (date) => date.getFullYear(),
30
+ literal: (_, str) => str,
31
+ hour: (date) => date.getHours().toString(),
32
+ year: (date) => date.getFullYear().toString(),
33
+ minute: (date) => date.getMinutes().toString(),
28
34
  day: (date) => date.getDate().toString().padStart(2, "0"),
29
35
  month: (date) => (date.getMonth() + 1).toString().padStart(2, "0"),
30
36
  };
31
37
  const formatParts = (datetimeFormat, date) => {
32
38
  try {
33
- return datetimeFormat.formatToParts(date);
39
+ return datetimeFormat.formatToParts(date).map(x => {
40
+ if ((x.type === "literal" && x.value === ", ")) {
41
+ return { type: x.type, value: " " };
42
+ }
43
+ return x;
44
+ });
34
45
  }
35
46
  catch (e) {
36
47
  return [];
37
48
  }
38
49
  };
39
- export const DatePicker = forwardRef(({ date, locale: inputLocal, disabledDate, onChange, markToday, ...props }, externalRef) => {
50
+ export const DatePicker = forwardRef(({ date, locale: inputLocal, disabledDate, onChange, markToday, clickToClose, type, ...props }, externalRef) => {
51
+ console.log(props.datetimeTitle, props);
40
52
  const locale = useLocale(inputLocal);
41
53
  const labelId = useId();
42
54
  const translation = useTranslations();
43
- const datetimeFormat = useMemo(() => new Intl.DateTimeFormat(locale), [locale]);
55
+ const datetimeFormat = useMemo(() => new Intl.DateTimeFormat(locale, type === "datetime"
56
+ ? { day: "numeric", month: "numeric", year: "numeric", hour: "numeric", minute: "numeric" }
57
+ : { day: "numeric", month: "numeric", year: "numeric" }), [locale, type]);
44
58
  const [innerDate, setInnerDate] = useState(date || undefined);
45
59
  const [open, setOpen] = useState(false);
46
60
  const mask = formatParts(datetimeFormat, fixedDate).flatMap((x) => (Is.keyof(parts, x.type) ? parts[x.type](x.value) : []));
@@ -57,7 +71,8 @@ export const DatePicker = forwardRef(({ date, locale: inputLocal, disabledDate,
57
71
  return typeof x === "string" ? c === x : x.test(c);
58
72
  });
59
73
  if (matches) {
60
- const d = startOfDay(parse(v, placeholder, new Date()));
74
+ const parsed = parse(v, placeholder, new Date());
75
+ const d = type === "datetime" ? parsed : startOfDay(parsed);
61
76
  setInnerDate(d);
62
77
  return onChange?.(d);
63
78
  }
@@ -68,11 +83,13 @@ export const DatePicker = forwardRef(({ date, locale: inputLocal, disabledDate,
68
83
  const onChangeDate = (d) => {
69
84
  setInnerDate(d);
70
85
  onChange?.(d);
86
+ if (clickToClose)
87
+ setOpen(false);
71
88
  if (d)
72
89
  return setValue(format(d, placeholder));
73
90
  return setValue("");
74
91
  };
75
92
  const validDate = isValid(innerDate);
76
93
  const htmlValue = validDate ? innerDate.toISOString() : undefined;
77
- return (_jsx(Input, { ...props, mask: mask, value: value, id: undefined, name: undefined, "data-value": htmlValue, formNoValidate: !open, "data-target": props.name, "data-component": "date-picker", onChange: onChangeDateInput, required: props.required ?? true, error: open ? undefined : props.error, placeholder: props.placeholder ?? placeholder, right: _jsxs(Fragment, { children: [_jsx("input", { "data-origin": props.name, defaultValue: htmlValue, form: props.form, hidden: true, id: props.name, name: props.name, ref: externalRef, type: "date" }), _jsx(Dropdown, { open: open, 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, { ...props, locale: locale, changeOnlyOnClick: true, markToday: markToday, onChange: onChangeDate, disabledDate: disabledDate, date: validDate ? innerDate : undefined }) })] }) }));
94
+ return (_jsx(Input, { ...props, mask: mask, value: value, id: undefined, name: undefined, "data-value": htmlValue, formNoValidate: !open, "data-target": props.name, "data-component": "date-picker", onChange: onChangeDateInput, required: props.required ?? true, error: open ? undefined : props.error, placeholder: props.placeholder || placeholder, right: _jsxs(Fragment, { children: [_jsx("input", { "data-origin": props.name, defaultValue: htmlValue, form: props.form, hidden: true, id: props.name, name: props.name, ref: externalRef, type: "date" }), _jsx(Dropdown, { open: open, onChange: setOpen, buttonProps: { "aria-describedby": labelId }, trigger: _jsxs("span", { "aria-labelledby": labelId, children: [_jsx("span", { id: labelId, className: "sr-only", children: translation.datePickerCalendarButtonLabel }), _jsx(CalendarIcon, {})] }), children: _jsx(Calendar, { ...props, type: type, locale: locale, changeOnlyOnClick: true, markToday: markToday, onChange: onChangeDate, disabledDate: disabledDate, date: validDate ? innerDate : undefined }) })] }) }));
78
95
  });
@@ -6,6 +6,6 @@ export type FreeTextProps<T extends FreeTextTag, ExtraProps extends Any> = Overr
6
6
  next: string;
7
7
  type: InputTypes;
8
8
  }>, ExtraProps>;
9
- export declare const createFreeText: <T extends FreeTextTag, Html extends HTMLInputElement | HTMLTextAreaElement, Extra extends Any>(Element: "input" | "textarea" | typeof MaskInput, elementName: "input" | "textarea", defaultProps: FreeTextProps<T, Extra>, register?: (el: Html) => () => void) => ReactComponent<FreeTextProps<T, Extra>>;
9
+ export declare const createFreeText: <const T extends FreeTextTag, const Html extends HTMLInputElement | HTMLTextAreaElement, Extra extends Any>(Element: "input" | "textarea" | typeof MaskInput, elementName: "input" | "textarea", defaultProps: FreeTextProps<T, Extra>, register?: (el: Html) => () => void) => ReactComponent<FreeTextProps<T, Extra>>;
10
10
  export {};
11
11
  //# sourceMappingURL=free-text.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"free-text.d.ts","sourceRoot":"","sources":["../../../src/components/form/free-text.tsx"],"names":[],"mappings":"AAEA,OAAO,SAAS,EAAE,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEvD,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC5D,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,GAAG,IAAI,QAAQ,CAC/E,eAAe,CAAC,CAAC,CAAC,GAAG,aAAa,GAAG,OAAO,CA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AK,CAAC,EACrC,WAAW,CAAC,EAAE,EAAE,IAAI,KAAK,MAAM,IAAI,4CAuGtC,CAAC"}
@@ -5,6 +5,7 @@ export declare const defaultTranslations: {
5
5
  calendarFromDate: string;
6
6
  calendarMonthLabel: string;
7
7
  calendarNextMonth: string;
8
+ calendarDatetimeTitle: string;
8
9
  calendarToDate: string;
9
10
  calendarToday: string;
10
11
  commandPaletteEmpty: string;
@@ -1 +1 @@
1
- {"version":3,"file":"default-translations.d.ts","sourceRoot":"","sources":["../../src/config/default-translations.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wCAsCQ;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;;;;;;;;;;;;;;;4BAqB7G;QAAE,CAAC,EAAE,MAAM,CAAA;KAAE;;CAExC,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,OAAO,mBAAmB,CAAC"}
1
+ {"version":3,"file":"default-translations.d.ts","sourceRoot":"","sources":["../../src/config/default-translations.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wCAuCQ;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;;;;;;;;;;;;;;;4BAqB7G;QAAE,CAAC,EAAE,MAAM,CAAA;KAAE;;CAExC,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,OAAO,mBAAmB,CAAC"}
@@ -6,6 +6,7 @@ export const defaultTranslations = {
6
6
  calendarFromDate: "From",
7
7
  calendarMonthLabel: "Month",
8
8
  calendarNextMonth: "Next month",
9
+ calendarDatetimeTitle: "Time",
9
10
  calendarToDate: "To",
10
11
  calendarToday: "Today",
11
12
  commandPaletteEmpty: "Nothing here...",
@@ -386,7 +386,7 @@ export declare const useForm: <T extends z.ZodObject<any>>(schema: T, formName:
386
386
  onTransitionStart?: React.TransitionEventHandler<HTMLFormElement> | undefined;
387
387
  onTransitionStartCapture?: React.TransitionEventHandler<HTMLFormElement> | undefined;
388
388
  };
389
- datepicker: <Props extends DatePickerProps>(name: AllPaths<z.TypeOf<T>>, props?: Props) => Props;
389
+ datepicker: (name: AllPaths<z.TypeOf<T>>, props?: DatePickerProps) => DatePickerProps;
390
390
  name: string;
391
391
  multiselect: <Props extends MultiSelectProps>(name: AllPaths<z.TypeOf<T>>, props?: Props) => Props;
392
392
  disabled: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"use-form.d.ts","sourceRoot":"","sources":["../../src/hooks/use-form.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAE,KAAK,cAAc,EAA4C,MAAM,OAAO,CAAC;AAC7F,OAAO,EAAE,KAAK,QAAQ,EAAe,MAAM,YAAY,CAAC;AAExD,OAAO,EAAE,CAAC,EAAa,MAAM,KAAK,CAAC;AACnC,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,eAAe,EAEf,UAAU,EACV,gBAAgB,EAChB,WAAW,EACX,WAAW,EACX,aAAa,EACd,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AA6GzC;;;;GAIG;AACH,eAAO,MAAM,UAAU,GAAI,MAAM,eAAe,KAAG,GAIlD,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,CAAC,SAAS,CAAC,CAAC,SAAS,CA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A+LjH,KAAK,SAAS,UAAU,uCAAuB,KAAK,KAAU,KAAK;;;aA/GlE,KAAK,SAAS,WAAW,GAAG,iBAAiB,uCAAuB,KAAK,KAAU,KAAK;eA4BtF,KAAK,SAAS,aAAa,GAAG,WAAW,uCAAuB,KAAK,KAAU,KAAK;sBAmK7E,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,OAAO,KAAK,CAAC,SAAS,CAAC,eAAe,CAAC;;eAxI7E,KAAK,SAAS,aAAa,uCAAuB,KAAK,KAAU,KAAK;uBA1G9E,eAAe,aAAa,KAAK,CAAC,SAAS,CAAC,eAAe,CAAC;yBA2S1C,cAAc,CAAC,MAAM,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sDAvRT,eAAe,KAAU,eAAe;;kBAoH5D,KAAK,SAAS,gBAAgB,uCAAuB,KAAK,KAAU,KAAK;;CA8L/F,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,OAAO,eAAe,GAAG,IAAI,KAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAC9B,CAAC"}
@@ -4,6 +4,7 @@ export declare const useTranslations: () => {
4
4
  calendarFromDate: string;
5
5
  calendarMonthLabel: string;
6
6
  calendarNextMonth: string;
7
+ calendarDatetimeTitle: string;
7
8
  calendarToDate: string;
8
9
  calendarToday: string;
9
10
  commandPaletteEmpty: string;
@@ -1 +1 @@
1
- {"version":3,"file":"use-translations.d.ts","sourceRoot":"","sources":["../../src/hooks/use-translations.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAKs0C,CAAC;;;;;;;;;;;;;;;;;;;;;;CADl2C,CAAC"}
1
+ {"version":3,"file":"use-translations.d.ts","sourceRoot":"","sources":["../../src/hooks/use-translations.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAKy2C,CAAC;;;;;;;;;;;;;;;;;;;;;;CADr4C,CAAC"}