@g4rcez/components 0.0.24 → 0.0.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/README.md +7 -7
  2. package/dist/components/core/button.d.ts.map +1 -1
  3. package/dist/components/core/button.js +1 -1
  4. package/dist/components/core/resizable.js +1 -1
  5. package/dist/components/core/tag.d.ts.map +1 -1
  6. package/dist/components/display/alert.d.ts.map +1 -1
  7. package/dist/components/display/alert.js +5 -5
  8. package/dist/components/display/tabs.d.ts +6 -1
  9. package/dist/components/display/tabs.d.ts.map +1 -1
  10. package/dist/components/display/tabs.js +9 -4
  11. package/dist/components/floating/dropdown.d.ts +1 -0
  12. package/dist/components/floating/dropdown.d.ts.map +1 -1
  13. package/dist/components/floating/dropdown.js +1 -1
  14. package/dist/components/floating/menu.d.ts +16 -0
  15. package/dist/components/floating/menu.d.ts.map +1 -0
  16. package/dist/components/floating/menu.js +115 -0
  17. package/dist/components/floating/modal.d.ts +1 -1
  18. package/dist/components/floating/modal.d.ts.map +1 -1
  19. package/dist/components/floating/modal.js +34 -10
  20. package/dist/components/form/autocomplete.d.ts +3 -2
  21. package/dist/components/form/autocomplete.d.ts.map +1 -1
  22. package/dist/components/form/autocomplete.js +47 -22
  23. package/dist/components/form/checkbox.d.ts.map +1 -1
  24. package/dist/components/form/checkbox.js +1 -1
  25. package/dist/components/form/date-picker.d.ts.map +1 -1
  26. package/dist/components/form/date-picker.js +5 -2
  27. package/dist/components/form/input-field.d.ts +8 -5
  28. package/dist/components/form/input-field.d.ts.map +1 -1
  29. package/dist/components/form/input-field.js +8 -4
  30. package/dist/components/form/input.d.ts +1 -1
  31. package/dist/components/form/input.d.ts.map +1 -1
  32. package/dist/components/form/input.js +3 -3
  33. package/dist/components/form/radiobox.d.ts.map +1 -1
  34. package/dist/components/form/select.d.ts +2 -0
  35. package/dist/components/form/select.d.ts.map +1 -1
  36. package/dist/components/form/select.js +5 -3
  37. package/dist/components/form/switch.js +1 -1
  38. package/dist/components/index.d.ts +1 -0
  39. package/dist/components/index.d.ts.map +1 -1
  40. package/dist/components/index.js +1 -0
  41. package/dist/components/table/filter.d.ts +13 -44
  42. package/dist/components/table/filter.d.ts.map +1 -1
  43. package/dist/components/table/filter.js +41 -28
  44. package/dist/components/table/index.d.ts.map +1 -1
  45. package/dist/components/table/index.js +10 -9
  46. package/dist/components/table/pagination.d.ts.map +1 -1
  47. package/dist/components/table/pagination.js +10 -11
  48. package/dist/components/table/sort.d.ts.map +1 -1
  49. package/dist/components/table/sort.js +18 -12
  50. package/dist/components/table/table-lib.d.ts.map +1 -1
  51. package/dist/components/table/thead.d.ts +1 -0
  52. package/dist/components/table/thead.d.ts.map +1 -1
  53. package/dist/components/table/thead.js +10 -3
  54. package/dist/hooks/use-form.js +1 -1
  55. package/dist/hooks/use-media-query.d.ts +2 -0
  56. package/dist/hooks/use-media-query.d.ts.map +1 -0
  57. package/dist/hooks/use-media-query.js +25 -0
  58. package/dist/hooks/use-translate-context.d.ts +91 -0
  59. package/dist/hooks/use-translate-context.d.ts.map +1 -0
  60. package/dist/hooks/use-translate-context.js +49 -0
  61. package/dist/index.css +1 -1
  62. package/dist/index.js.map +1 -1
  63. package/dist/index.mjs +8471 -7752
  64. package/dist/index.mjs.map +1 -1
  65. package/dist/index.umd.js +46 -41
  66. package/dist/index.umd.js.map +1 -1
  67. package/dist/lib/dom.d.ts +1 -1
  68. package/dist/lib/dom.d.ts.map +1 -1
  69. package/dist/lib/dom.js +12 -4
  70. package/dist/lib/fns.d.ts +1 -0
  71. package/dist/lib/fns.d.ts.map +1 -1
  72. package/dist/lib/fns.js +2 -1
  73. package/dist/preset/preset.tailwind.js +1 -1
  74. package/dist/preset/src/styles/theme.d.ts.map +1 -1
  75. package/dist/preset/src/styles/theme.js +2 -4
  76. package/dist/preset/src/styles/theme.types.d.ts +0 -1
  77. package/dist/preset/src/styles/theme.types.d.ts.map +1 -1
  78. package/dist/styles/theme.d.ts.map +1 -1
  79. package/dist/styles/theme.js +2 -4
  80. package/dist/styles/theme.types.d.ts +0 -1
  81. package/dist/styles/theme.types.d.ts.map +1 -1
  82. package/dist/types.d.ts.map +1 -1
  83. package/package.json +190 -184
@@ -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, {}), onChange: setOpen, open: open, children: _jsx(Calendar, Object.assign({}, props, { locale: locale, date: innerDate, onChange: onChangeDate, markToday: markToday, disabledDate: disabledDate, autoFocusToday: autoFocusToday })) })] }) })));
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,16 +1,19 @@
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
- title: string | React.ReactElement | React.ReactNode;
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<{
13
- error?: string;
14
+ info: Label;
15
+ labelClassName: string;
16
+ error: string;
14
17
  hideLeft: boolean;
15
18
  interactive: boolean;
16
19
  container: string;
@@ -23,5 +26,5 @@ export type InputFieldProps<T extends "input" | "select"> = PolymorphicProps<Par
23
26
  name: string;
24
27
  placeholder: string;
25
28
  }>, T>;
26
- export declare const InputField: <T extends "input" | "select">({ optionalText, left, rightLabel, container, feedback, interactive, right, children, error, form, id, 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;
27
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;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErD,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,MAAM,MAAM,aAAa,GAAG,KAAK,CAAC,iBAAiB,CAC/C,OAAO,CAAC;IACJ,KAAK,EAAE,MAAM,GAAG,KAAK,CAAC,YAAY,GAAG,KAAK,CAAC,SAAS,CAAC;IACrD,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;AACF,eAAO,MAAM,aAAa,2DAAoE,aAAa,4CA2B1G,CAAC;AAEF,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,OAAO,GAAG,QAA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E,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
- export const InputFeedback = ({ reportStatus, hideLeft = false, className, 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 ? (_jsxs("span", { className: "flex aspect-square h-4 w-4 items-center justify-center", children: [_jsx(CheckCircle, { className: "hidden aspect-square h-3 w-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 h-3 w-3 opacity-0 transition-opacity group-error:block group-error:opacity-100", "aria-hidden": "true", size: 16, strokeWidth: 1, absoluteStrokeWidth: true })] })) : null] })), children] }));
7
- export const InputField = ({ optionalText = "Optional", left, rightLabel, container, feedback, interactive, right, children, error, form, id, name, title, placeholder, hideLeft, required, }) => {
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
- return (_jsxs("fieldset", { "data-interactive": !!interactive, "data-error": !!error, form: form, className: css("group inline-block 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, { 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", 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 group-error:text-danger mt-1 hidden text-xs group-has-[input:not(:focus):invalid[data-initialized=true]]:block", children: error }), _jsx("p", { className: "mt-1 hidden text-xs empty:mt-0 empty:hidden group-has-[input:not(:focus):valid[data-initialized=true]]:block", children: feedback })] }));
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;AACzD,OAAO,EAAE,aAAa,EAAc,eAAe,EAAE,MAAM,eAAe,CAAC;AAE3E,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,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,CA0D/B,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", container, feedback = null, next, rightLabel, optionalText, hideLeft = false, right, left } = _a, props = __rest(_a, ["type", "container", "feedback", "next", "rightLabel", "optionalText", "hideLeft", "right", "left"]);
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, Object.assign({}, props, { feedback: feedback, right: right, left: left, hideLeft: hideLeft, rightLabel: rightLabel, optionalText: optionalText, container: css("group inline-block w-full", container), 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-10 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) })) })));
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
  });
@@ -1 +1 @@
1
- {"version":3,"file":"radiobox.d.ts","sourceRoot":"","sources":["../../../src/components/form/radiobox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,MAAM,MAAM,aAAa,GAAG,QAAQ,CAChC,KAAK,CAAC,iBAAiB,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,EACtD;IACI,IAAI,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC;CAC7B,CACJ,CAAC;AAEF,eAAO,MAAM,QAAQ,4CAAkD,aAAa,4CAanF,CAAC"}
1
+ {"version":3,"file":"radiobox.d.ts","sourceRoot":"","sources":["../../../src/components/form/radiobox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,MAAM,MAAM,aAAa,GAAG,QAAQ,CAChC,KAAK,CAAC,iBAAiB,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,EACtD;IACI,IAAI,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC;CAC7B,CACJ,CAAC;AAEF,eAAO,MAAM,QAAQ,4CAAkD,aAAa,4CAiBnF,CAAC"}
@@ -3,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
@@ -1 +1 @@
1
- {"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../../../src/components/form/select.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAwC,MAAM,OAAO,CAAC;AAC7D,OAAO,EAAc,eAAe,EAAE,MAAM,eAAe,CAAC;AAE5D,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,MAAM,MAAM,WAAW,GAAG,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAEtF,MAAM,MAAM,WAAW,GAAG,QAAQ,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAE;IAAE,OAAO,EAAE,WAAW,EAAE,CAAA;CAAE,CAAC,CAAC;AAE1F,eAAO,MAAM,MAAM,oGA8CjB,CAAC"}
1
+ {"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../../../src/components/form/select.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAwC,MAAM,OAAO,CAAC;AAC7D,OAAO,EAAc,eAAe,EAAE,MAAM,eAAe,CAAC;AAE5D,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGvC,MAAM,MAAM,WAAW,GAAG,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,cAAc,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAE/G,MAAM,MAAM,WAAW,GAAG,QAAQ,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAE;IAC1D,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAA;CAC3B,CAAC,CAAC;AAEH,eAAO,MAAM,MAAM,oGAgEjB,CAAC"}
@@ -5,9 +5,11 @@ import { ChevronDown } from "lucide-react";
5
5
  import { forwardRef, useEffect, useRef } from "react";
6
6
  import { InputField } from "./input-field";
7
7
  import { css, mergeRefs } from "../../lib/dom";
8
+ import { useTranslations } from "../../hooks/use-translate-context";
8
9
  export const Select = forwardRef((_a, ref) => {
9
10
  var _b;
10
- var { container, required = true, options } = _a, props = __rest(_a, ["container", "required", "options"]);
11
+ var { required = true, options, selectContainer = "", feedback = null, labelClassName, interactive, rightLabel, optionalText, container, hideLeft = false, right, left, error } = _a, props = __rest(_a, ["required", "options", "selectContainer", "feedback", "labelClassName", "interactive", "rightLabel", "optionalText", "container", "hideLeft", "right", "left", "error"]);
12
+ const translation = useTranslations();
11
13
  const inputRef = useRef(null);
12
14
  const id = (_b = props.id) !== null && _b !== void 0 ? _b : props.name;
13
15
  useEffect(() => {
@@ -23,8 +25,8 @@ export const Select = forwardRef((_a, ref) => {
23
25
  input.removeEventListener("change", change);
24
26
  };
25
27
  }, []);
26
- return (_jsx(InputField, Object.assign({}, props, { required: required, container: css("group inline-block w-full", container), right: _jsx(ChevronDown, { size: 20 }), children: _jsxs("select", Object.assign({}, props, { ref: mergeRefs(ref, inputRef), id: id, name: id, required: required, "data-selected": !!props.value || false, className: css("input bg-transparent text-foreground select group h-10 w-full flex-1 rounded-md p-2 placeholder-input-placeholder outline-none transition-colors group-error:text-danger group-error:placeholder-input-mask-error", "data-[selected=false]:text-input-placeholder", props.className), children: [_jsx("option", { value: "", hidden: true, disabled: true, children: props.placeholder }), options.map((option) => {
28
+ return (_jsx(InputField, { container: css("group inline-block w-full", container), error: error, feedback: feedback, hideLeft: hideLeft, left: left, optionalText: optionalText, rightLabel: rightLabel, interactive: interactive, form: props.form, id: props.name || props.id, name: props.name, labelClassName: labelClassName, title: props.title, placeholder: props.placeholder, required: required, right: _jsxs("button", { type: "button", className: "hover:text-primary transition-colors", children: [_jsx(ChevronDown, { size: 20 }), _jsx("span", { className: "sr-only", children: translation.inputCaretDown })] }), children: _jsxs("select", Object.assign({}, props, { ref: mergeRefs(ref, inputRef), id: id, name: id, required: required, "data-selected": !!props.value || false, className: css("input bg-transparent text-foreground select group h-11 w-full flex-1 rounded-md p-2 placeholder-input-placeholder outline-none transition-colors group-error:text-danger group-error:placeholder-input-mask-error", "data-[selected=false]:text-input-placeholder", props.className), children: [_jsx("option", { value: "", hidden: true, disabled: true, children: props.placeholder }), options.map((option) => {
27
29
  var _a;
28
30
  return (_jsx("option", Object.assign({}, option, { children: (_a = option.label) !== null && _a !== void 0 ? _a : option.value }), `${id}-select-option-${option.value}`));
29
- })] })) })));
31
+ })] })) }));
30
32
  });
@@ -15,5 +15,5 @@ export const Switch = (_a) => {
15
15
  setInnerChecked(checked);
16
16
  (_a = props === null || props === void 0 ? void 0 : props.onCheck) === null || _a === void 0 ? void 0 : _a.call(props, checked);
17
17
  };
18
- return (_jsxs("div", { className: "flex items-center", children: [_jsx("input", Object.assign({}, props, { hidden: true, type: "checkbox", checked: checked, onChange: (e) => setInnerChecked(e.target.checked) })), _jsx("button", { type: "button", role: "switch", onClick: onCheck, "aria-checked": checked, "data-checked": checked, "aria-labelledby": `${id}-label`, className: "relative inline-flex h-6 w-11 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent data-[checked=false]:bg-input-switch-bg data-[checked=true]:bg-primary transition-colors ease-in-out focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2", children: _jsx("span", { "aria-hidden": "true", "data-checked": checked, className: "data-[checked=false]:bg-disabled data-[checked=true]:bg-input-switch inline-block size-5 aspect-square data-[checked=false]translate-x-0 data-[checked=true]:translate-x-5 transform rounded-full shadow ring-0 transition ease-in-out" }) }), _jsx("span", { className: "ml-3 text-sm", id: `${id}-label`, children: _jsx("span", { className: "font-medium text-foreground", children: children }) })] }));
18
+ return (_jsxs("div", { className: "flex items-center", children: [_jsx("input", Object.assign({}, props, { hidden: true, type: "checkbox", checked: checked, onChange: (e) => setInnerChecked(e.target.checked) })), _jsx("button", { type: "button", role: "switch", onClick: onCheck, "aria-checked": checked, "data-checked": checked, "aria-labelledby": `${id}-label`, className: "relative duration-300 inline-flex h-6 w-11 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent data-[checked=false]:bg-input-switch-bg data-[checked=true]:bg-primary transition-colors ease-in-out focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2", children: _jsx("span", { "aria-hidden": "true", "data-checked": checked, className: "data-[checked=false]:bg-disabled duration-300 data-[checked=true]:bg-input-switch inline-block size-5 aspect-square data-[checked=false]:translate-x-0 data-[checked=true]:translate-x-5 transform rounded-full shadow ring-0 transition duration-300 ease-in-out" }) }), _jsx("span", { className: "ml-3 text-sm", id: `${id}-label`, children: _jsx("span", { className: "font-medium text-foreground", children: children }) })] }));
19
19
  };
@@ -22,5 +22,6 @@ export * from "./form/select";
22
22
  export * from "./form/switch";
23
23
  export * from "./form/transfer-list";
24
24
  export * from "./table/index";
25
+ export * from "./floating/menu";
25
26
  export { createColumns, createOptionCols, type ColType, useTablePreferences, type TablePagination } from "./table/table-lib";
26
27
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC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B,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,KAAK,OAAO,EAAE,mBAAmB,EAAE,KAAK,eAAe,EAAE,MAAM,mBAAmB,CAAC"}
@@ -22,4 +22,5 @@ export * from "./form/select";
22
22
  export * from "./form/switch";
23
23
  export * from "./form/transfer-list";
24
24
  export * from "./table/index";
25
+ export * from "./floating/menu";
25
26
  export { createColumns, createOptionCols, useTablePreferences } from "./table/table-lib";
@@ -1,51 +1,16 @@
1
1
  import React from "react";
2
2
  import { AllPaths } from "sidekicker";
3
3
  import { Label } from "../../types";
4
+ import { OptionProps } from "../form/select";
4
5
  import { Col, ColType, TableConfiguration } from "./table-lib";
5
- declare const operators: {
6
- contains: {
7
- value: string;
8
- label: string;
9
- symbol: "includes";
10
- };
11
- is: {
12
- value: string;
13
- label: string;
14
- symbol: "is";
15
- };
16
- isNot: {
17
- value: string;
18
- label: string;
19
- symbol: "!==";
20
- };
21
- notContains: {
22
- value: string;
23
- label: string;
24
- symbol: "notIncludes";
25
- };
26
- lessThan: {
27
- value: string;
28
- label: string;
29
- symbol: "<=";
30
- };
31
- greaterThan: {
32
- value: string;
33
- label: string;
34
- symbol: ">=";
35
- };
36
- startsWith: {
37
- value: string;
38
- label: string;
39
- symbol: "startsWith";
40
- };
41
- endsWith: {
42
- value: string;
43
- label: string;
44
- symbol: "endsWith";
45
- };
6
+ type Operators = {
7
+ value: string;
8
+ label: string;
9
+ symbol: string;
46
10
  };
47
- type Operator = keyof typeof operators;
48
- type Operators = (typeof operators)[Operator];
11
+ type OperatorTypes = "contains" | "is" | "isNot" | "notContains" | "lessThan" | "greaterThan" | "startsWith" | "endsWith";
12
+ type Operations = Record<OperatorTypes, Operators>;
13
+ type OperationOptions = Partial<Record<ColType, OptionProps[]>>;
49
14
  type FilterValue = string | number | string[] | boolean;
50
15
  export type FilterConfig<T extends {} = {}> = {
51
16
  id: string;
@@ -60,7 +25,11 @@ type Props<T extends {}> = TableConfiguration<T, {
60
25
  filters: FilterConfig<T>[];
61
26
  set: React.Dispatch<React.SetStateAction<FilterConfig<T>[]>>;
62
27
  }>;
63
- export declare const createFilterFromCol: <T extends {}>(f: Col<T>, rest?: Partial<FilterConfig<T>>) => FilterConfig<T>;
28
+ export declare const createFilterFromCol: <T extends {}>(f: Col<T>, options: OperationOptions, operations: Operations, rest?: Partial<FilterConfig<T>>) => FilterConfig<T>;
29
+ export declare const useOperators: () => {
30
+ operationOptions: Partial<Record<ColType, OptionProps[]>>;
31
+ operations: Operations;
32
+ };
64
33
  export declare const Filter: <T extends {}>(props: Props<T>) => import("react/jsx-runtime").JSX.Element;
65
34
  type ColumnHeaderFilterProps<T extends {}> = {
66
35
  filter: FilterConfig<T>;
@@ -1 +1 @@
1
- {"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../../../src/components/table/filter.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAmB,MAAM,OAAO,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAIpC,OAAO,EAAE,GAAG,EAAE,OAAO,EAAY,kBAAkB,EAAiB,MAAM,aAAa,CAAC;AAExF,QAAA,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAS8C,CAAC;AAE9D,KAAK,QAAQ,GAAG,MAAM,OAAO,SAAS,CAAC;AAEvC,KAAK,SAAS,GAAG,CAAC,OAAO,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC;AAQ9C,KAAK,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,OAAO,CAAC;AAExD,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS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;IACf,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;IAC3B,GAAG,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;CAChE,CACJ,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,CAAC,SAAS,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC,WAAW,gBAAgB,cAAc,UAAU,SAAQ,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,KAAQ,YAAY,CAAC,CAAC,CAMnK,CAAC;AAEF,eAAO,MAAM,YAAY;;;CAwBxB,CAAA;AAED,eAAO,MAAM,MAAM,GAAI,CAAC,SAAS,EAAE,SAAS,KAAK,CAAC,CAAC,CAAC,4CAiGnD,CAAC;AAEF,KAAK,uBAAuB,CAAC,CAAC,SAAS,EAAE,IAAI;IACzC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC;IACxB,QAAQ,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;IAC3D,GAAG,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;CAChE,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,CAAC,SAAS,EAAE,6BAA6B,uBAAuB,CAAC,CAAC,CAAC,4CAsCrG,CAAC"}
@@ -1,38 +1,49 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { ListFilterIcon, PlusIcon, Trash2Icon } from "lucide-react";
3
- import { Fragment } from "react";
3
+ import { Fragment, useMemo } from "react";
4
4
  import { uuid } from "../../lib/fns";
5
5
  import { Dropdown } from "../floating/dropdown";
6
6
  import { Input } from "../form/input";
7
7
  import { Select } from "../form/select";
8
8
  import { ColType, getLabel, valueFromType } from "./table-lib";
9
- const operators = {
10
- contains: { value: "contains", label: "Contains", symbol: "includes" },
11
- is: { value: "is", label: "Is", symbol: "is" },
12
- isNot: { value: "isNot", label: "Is not", symbol: "!==" },
13
- notContains: { value: "notContains", label: "Does not contains", symbol: "notIncludes" },
14
- lessThan: { value: "lessThan", label: "Less Than", symbol: "<=" },
15
- greaterThan: { value: "greaterThan", label: "Greater than", symbol: ">=" },
16
- startsWith: { value: "startsWith", label: "Starts with", symbol: "startsWith" },
17
- endsWith: { value: "endsWith", label: "Ends with", symbol: "endsWith" },
18
- };
19
- const operatorOptions = {
20
- [ColType.Text]: [operators.is, operators.isNot, operators.contains, operators.notContains, operators.startsWith, operators.endsWith],
21
- [ColType.Boolean]: [operators.is, operators.isNot],
22
- [ColType.Number]: [operators.is, operators.isNot, operators.greaterThan, operators.lessThan],
23
- };
24
- export const createFilterFromCol = (f, rest = {}) => {
9
+ import { useTranslations } from "../../hooks/use-translate-context";
10
+ export const createFilterFromCol = (f, options, operations, rest = {}) => {
25
11
  var _a, _b;
26
12
  const name = f.id;
27
13
  const type = (_a = f.type) !== null && _a !== void 0 ? _a : ColType.Text;
28
- const operatorId = (_b = operatorOptions[type]) === null || _b === void 0 ? void 0 : _b[0].value;
29
- const operation = operators[operatorId];
14
+ const operatorId = (_b = options[type]) === null || _b === void 0 ? void 0 : _b[0].value;
15
+ const operation = operations[operatorId];
30
16
  return Object.assign({ id: uuid(), operation, label: getLabel(f), name, type, value: "" }, rest);
31
17
  };
18
+ export const useOperators = () => {
19
+ const translation = useTranslations();
20
+ const operations = useMemo(() => {
21
+ return {
22
+ contains: { value: "contains", label: translation.tableFilterTypeContains, symbol: "includes" },
23
+ is: { value: "is", label: translation.tableFilterTypeIs, symbol: "is" },
24
+ isNot: { value: "isNot", label: translation.tableFilterTypeIsNot, symbol: "!==" },
25
+ notContains: { value: "notContains", label: translation.tableFilterTypeNotContains, symbol: "notIncludes" },
26
+ lessThan: { value: "lessThan", label: translation.tableFilterTypeLessThan, symbol: "<=" },
27
+ greaterThan: { value: "greaterThan", label: translation.tableFilterTypeGreaterThan, symbol: ">=" },
28
+ startsWith: { value: "startsWith", label: translation.tableFilterTypeStartsWith, symbol: "startsWith" },
29
+ endsWith: { value: "endsWith", label: translation.tableFilterTypeEndsWith, symbol: "endsWith" },
30
+ };
31
+ }, [translation]);
32
+ const operationOptions = useMemo(() => {
33
+ return {
34
+ [ColType.Text]: [operations.is, operations.isNot, operations.contains, operations.notContains, operations.startsWith, operations.endsWith],
35
+ [ColType.Boolean]: [operations.is, operations.isNot],
36
+ [ColType.Number]: [operations.is, operations.isNot, operations.greaterThan, operations.lessThan],
37
+ };
38
+ }, [translation]);
39
+ return { operationOptions, operations };
40
+ };
32
41
  export const Filter = (props) => {
42
+ const translation = useTranslations();
43
+ const { operationOptions, operations } = useOperators();
33
44
  const onAddFilter = () => {
34
45
  const col = props.cols.at(0);
35
- props.set((prev) => [...prev, createFilterFromCol(col)]);
46
+ props.set((prev) => [...prev, createFilterFromCol(col, operationOptions, operations)]);
36
47
  };
37
48
  const onSelectProperty = (e) => {
38
49
  const changedId = e.target.dataset.id || "";
@@ -41,13 +52,13 @@ export const Filter = (props) => {
41
52
  if (changedId !== x.id)
42
53
  return x;
43
54
  const col = props.cols.find((x) => newId === x.id);
44
- return createFilterFromCol(col, { value: "" });
55
+ return createFilterFromCol(col, operationOptions, operations, { value: "" });
45
56
  }));
46
57
  };
47
58
  const onSelectOperation = (e) => {
48
59
  const id = e.target.dataset.id || "";
49
60
  const operator = e.target.value;
50
- props.set((prev) => prev.map((x) => (x.id === id ? Object.assign(Object.assign({}, x), { operation: operators[operator] }) : x)));
61
+ props.set((prev) => prev.map((x) => (x.id === id ? Object.assign(Object.assign({}, x), { operation: operations[operator] }) : x)));
51
62
  };
52
63
  const onDelete = (e) => {
53
64
  const id = e.currentTarget.dataset.id || "";
@@ -58,21 +69,23 @@ export const Filter = (props) => {
58
69
  const value = valueFromType(e.target);
59
70
  props.set((prev) => prev.map((x) => (x.id === id ? Object.assign(Object.assign({}, x), { value }) : x)));
60
71
  };
61
- return (_jsx(Fragment, { children: _jsx(Dropdown, { arrow: false, title: "Filters", trigger: _jsxs("span", { className: "flex items-center gap-1 proportional-nums", children: [_jsx(ListFilterIcon, { size: 14 }), "Filtros ", props.filters.length === 0 ? "" : ` (${props.filters.length})`] }), children: _jsxs("ul", { className: "mt-4 space-y-2", children: [props.filters.map((filter) => {
62
- const operators = operatorOptions[filter.type];
63
- return (_jsxs("li", { className: "flex flex-nowrap gap-3", children: [_jsx(Select, { title: "Filter", options: props.options, placeholder: "Name...", value: filter.name, "data-id": filter.id, onChange: onSelectProperty }), _jsx(Select, { title: "Filter type", "data-id": filter.id, onChange: onSelectOperation, value: filter.operation.value, options: operators, placeholder: "Operator..." }), _jsx(Input, { "data-id": filter.id, onChange: onChangeValue, placeholder: "Search...", title: "Value", type: filter.type, value: filter.value }), _jsx("div", { className: "flex items-center justify-center mt-5", children: _jsx("button", { "data-id": filter.id, type: "button", onClick: onDelete, children: _jsx(Trash2Icon, { className: "text-danger", size: 16 }) }) })] }, `filter-select-${filter.id}`));
64
- }), _jsx("li", { children: _jsxs("button", { type: "button", onClick: onAddFilter, className: "text-primary flex items-center gap-1", children: [_jsx(PlusIcon, { size: 14 }), " New filter"] }) })] }) }) }));
72
+ return (_jsx(Fragment, { children: _jsx(Dropdown, { arrow: true, title: translation.tableFilterDropdownTitle, trigger: _jsxs("span", { className: "flex items-center gap-1 proportional-nums", children: [_jsx(ListFilterIcon, { size: 14 }), translation.tableFilterLabel, " ", props.filters.length === 0 ? "" : ` (${props.filters.length})`] }), children: _jsxs("ul", { className: "mt-4 space-y-2", children: [props.filters.map((filter) => {
73
+ const operators = operationOptions[filter.type];
74
+ return (_jsxs("li", { className: "flex flex-nowrap gap-3", children: [_jsx(Select, { options: props.options, title: translation.tableFilterColumnTitle, placeholder: translation.tableFilterColumnPlaceholder, value: filter.name, "data-id": filter.id, onChange: onSelectProperty }), _jsx(Select, { "data-id": filter.id, onChange: onSelectOperation, value: filter.operation.value, options: operators, title: translation.tableFilterOperatorTitle, placeholder: translation.tableFilterOperatorPlaceholder }), _jsx(Input, { "data-id": filter.id, onChange: onChangeValue, title: translation.tableFilterValueTitle, placeholder: translation.tableFilterValuePlaceholder, type: filter.type, value: filter.value, optionalText: "" }), _jsx("div", { className: "flex items-center justify-center mt-5", children: _jsx("button", { "data-id": filter.id, type: "button", onClick: onDelete, children: _jsx(Trash2Icon, { className: "text-danger", size: 16 }) }) })] }, `filter-select-${filter.id}`));
75
+ }), _jsx("li", { children: _jsxs("button", { type: "button", onClick: onAddFilter, className: "text-primary flex items-center gap-1", children: [_jsx(PlusIcon, { size: 14 }), " ", translation.tableFilterNewFilter] }) })] }) }) }));
65
76
  };
66
77
  export const ColumnHeaderFilter = ({ filter, onDelete, set }) => {
78
+ const translation = useTranslations();
79
+ const { operationOptions, operations } = useOperators();
67
80
  const onSelectOperation = (e) => {
68
81
  const operator = e.target.value;
69
82
  const id = e.target.dataset.id || "";
70
- set((prev) => prev.map((x) => (x.id === id ? Object.assign(Object.assign({}, x), { operation: operators[operator] }) : x)));
83
+ set((prev) => prev.map((x) => (x.id === id ? Object.assign(Object.assign({}, x), { operation: operations[operator] }) : x)));
71
84
  };
72
85
  const onChangeValue = (e) => {
73
86
  const id = e.target.dataset.id || "";
74
87
  const value = valueFromType(e.target);
75
88
  set((prev) => prev.map((x) => (x.id === id ? Object.assign(Object.assign({}, x), { value }) : x)));
76
89
  };
77
- return (_jsxs("div", { className: "flex flex-nowrap items-center gap-4 py-2", children: [_jsx(Select, { "data-id": filter.id, onChange: onSelectOperation, options: operatorOptions[filter.type], placeholder: "Operation...", title: "Filter type", value: filter.operation.value }), _jsx(Input, { "data-id": filter.id, onChange: onChangeValue, placeholder: "Looking for...", title: "Value", type: filter.type, value: filter.value }), _jsx("button", { onClick: onDelete, "data-id": filter.id, type: "button", className: "mt-4", children: _jsx(Trash2Icon, { className: "text-danger", size: 14 }) })] }));
90
+ return (_jsxs("div", { className: "flex flex-nowrap items-center gap-4 py-2", children: [_jsx(Select, { "data-id": filter.id, onChange: onSelectOperation, options: operationOptions[filter.type], title: translation.tableFilterColumnTitle, placeholder: translation.tableFilterColumnPlaceholder, value: filter.operation.value }), _jsx(Input, { "data-id": filter.id, onChange: onChangeValue, type: filter.type, value: filter.value, title: translation.tableFilterValueTitle, placeholder: translation.tableFilterValueTitle }), _jsx("button", { onClick: onDelete, "data-id": filter.id, type: "button", className: "mt-4", children: _jsx(Trash2Icon, { className: "text-danger", size: 14 }) })] }));
78
91
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/table/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAY,cAAc,EAAwC,MAAM,OAAO,CAAC;AAM9F,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAGpC,OAAO,EAAa,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC3C,OAAO,EAAoB,GAAG,EAA+B,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAGtG,KAAK,eAAe,CAAC,CAAC,SAAS,EAAE,IAAI,cAAc,CAAC,gBAAgB,CAAC,GACjE,mBAAmB,CAAC,CAAC,CAAC,GAAG;IACrB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;IACrB,MAAM,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;IACxB,UAAU,EAAE,WAAW,EAAE,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,IAAI,EAAE,GAA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E,MAAM,IAAI,CAAC;CAC5B,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC,CAAC,GAAG;IAAE,SAAS,EAAE,MAAM,CAAC,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CAAC;AAO/E,eAAO,MAAM,KAAK,GAAI,CAAC,SAAS,EAAE,SAAS,UAAU,CAAC,CAAC,CAAC,4CAgGvD,CAAC"}
@@ -5,7 +5,7 @@ import { AnimatePresence, motion } from "framer-motion";
5
5
  import Linq from "linq-arrays";
6
6
  import React, { Fragment, useEffect, useMemo, useRef, useState } from "react";
7
7
  import { TableVirtuoso } from "react-virtuoso";
8
- import { Is } from "sidekicker";
8
+ import { clamp, Is } from "sidekicker";
9
9
  import { useReducer } from "use-typed-reducer";
10
10
  import { useCallbackRef } from "../../hooks/use-callback-ref";
11
11
  import { path } from "../../lib/fns";
@@ -14,19 +14,20 @@ import { Pagination } from "./pagination";
14
14
  import { multiSort } from "./sort";
15
15
  import { createOptionCols } from "./table-lib";
16
16
  import { TableHeader } from "./thead";
17
+ const calculateSkeletonWidth = () => clamp(40, Math.random() * 90, 90);
17
18
  const TableBody = React.forwardRef((props, ref) => {
18
19
  var _a;
19
- return (_jsx("tbody", Object.assign({}, props, { className: `divide-y divide-table-border ${(_a = props.className) !== null && _a !== void 0 ? _a : ""}`, ref: ref, children: _jsx(AnimatePresence, { children: props.children }) })));
20
+ return (_jsx("tbody", Object.assign({}, props, { role: "rowgroup", className: `divide-y divide-table-border ${(_a = props.className) !== null && _a !== void 0 ? _a : ""}`, ref: ref, children: _jsx(AnimatePresence, { children: props.children }) })));
20
21
  });
21
22
  const VirtualTable = React.forwardRef((props, ref) => {
22
23
  var _a;
23
- return (_jsx("table", Object.assign({}, props, { ref: ref, className: `table min-w-full divide-y divide-table-border table-auto text-left ${(_a = props.className) !== null && _a !== void 0 ? _a : ""}` })));
24
+ return (_jsx("table", Object.assign({}, props, { ref: ref, role: "table", className: `table min-w-full divide-y divide-table-border table-auto text-left ${(_a = props.className) !== null && _a !== void 0 ? _a : ""}` })));
24
25
  });
25
- const Thead = React.forwardRef((props, ref) => _jsx("thead", Object.assign({}, props, { className: "bg-card-background shadow-xs group:sticky top-0", ref: ref })));
26
- const TRow = React.forwardRef((props, ref) => { var _a; return _jsx("tr", Object.assign({}, props, { ref: ref, className: `table-row ${(_a = props.className) !== null && _a !== void 0 ? _a : ""}` })); });
26
+ const Thead = React.forwardRef((props, ref) => (_jsx("thead", Object.assign({}, props, { role: "rowgroup", className: "bg-card-background shadow-xs group:sticky top-0", ref: ref }))));
27
+ const TRow = React.forwardRef((props, ref) => { var _a; return _jsx("tr", Object.assign({}, props, { role: "row", ref: ref, className: `table-row ${(_a = props.className) !== null && _a !== void 0 ? _a : ""}` })); });
27
28
  const TFoot = React.forwardRef((props, ref) => {
28
29
  if (props.context.loadingMore) {
29
- return (_jsx("tfoot", Object.assign({}, props, { ref: ref, className: "bg-card-background", children: _jsx("tr", { className: "bg-card-background", children: _jsx("td", { colSpan: 999, className: "px-2 h-14 bg-card-background", children: _jsx("span", { className: "block w-full h-2 bg-foreground rounded opacity-60 animate-pulse" }) }) }) })));
30
+ return (_jsx("tfoot", Object.assign({}, props, { ref: ref, className: "bg-card-background", children: _jsx("tr", { role: "row", className: "bg-card-background", children: _jsx("td", { colSpan: 999, className: "px-2 h-14 bg-card-background", children: _jsx("span", { className: "block w-full h-2 bg-foreground rounded opacity-60 animate-pulse" }) }) }) })));
30
31
  }
31
32
  return null;
32
33
  });
@@ -45,7 +46,7 @@ const ItemContent = (index, row, context) => {
45
46
  const matrix = `${colIndex},${index}`;
46
47
  const value = path(row, col.id);
47
48
  const Component = col.Element;
48
- return (_createElement("td", Object.assign({}, col.cellProps, { "data-matrix": matrix, key: `accessor-${index}-${colIndex}`, className: "px-2 h-14 border-none first:table-cell hidden md:table-cell" }), loading ? (_jsx("div", { className: "animate-pulse h-2 bg-table-border rounded" })) : Component ? (_jsx(Component, { row: row, matrix: matrix, col: col, rowIndex: index, value: value })) : (_jsx(Fragment, { children: Is.nil(value) ? "" : value }))));
49
+ return (_createElement("td", Object.assign({}, col.cellProps, { "data-matrix": matrix, role: "cell", key: `accessor-${index}-${colIndex}`, className: "px-2 h-14 border-none first:table-cell hidden md:table-cell" }), loading ? (_jsx("div", { className: "animate-pulse h-2 bg-table-border rounded", style: { width: `${calculateSkeletonWidth()}%` } })) : Component ? (_jsx(Component, { row: row, matrix: matrix, col: col, rowIndex: index, value: value })) : (_jsx(Fragment, { children: Is.nil(value) ? "" : value }))));
49
50
  }) }));
50
51
  };
51
52
  const Frag = () => _jsx(Fragment, {});
@@ -62,7 +63,7 @@ const InnerTable = (_a) => {
62
63
  return props.rows;
63
64
  const linq = new Linq(props.rows);
64
65
  if (filters.length > 0) {
65
- filters.forEach((x) => (x.value === "" || Number.isNaN(x.value) ? undefined : linq.Where(x.name, x.operation.symbol, x.value)));
66
+ filters.forEach((x) => x.value === "" || Number.isNaN(x.value) ? undefined : linq.Where(x.name, x.operation.symbol, x.value));
66
67
  }
67
68
  if (sorters.length === 0)
68
69
  return linq.Select();
@@ -86,7 +87,7 @@ const InnerTable = (_a) => {
86
87
  observer.observe(div);
87
88
  return () => observer.disconnect();
88
89
  }, []);
89
- return (_jsxs("div", { className: "min-w-full", children: [_jsxs("div", { className: `group rounded-lg px-1 ${border ? "border border-table-border" : ""}`, children: [_jsx(TableVirtuoso, { data: rows, useWindowScroll: true, components: components, totalCount: rows.length, itemContent: ItemContent, context: { loading: props.loading, loadingMore: props.loadingMore, cols: cols }, fixedFooterContent: showLoadingFooter ? Frag : null, fixedHeaderContent: () => (_jsx(TableHeader, { sorters: sorters, setSorters: setSorters, filters: filters, setFilters: setFilters, headers: cols, setCols: setCols })) }), _jsx("div", { "aria-hidden": "true", ref: ref, className: "h-0.5 w-full" })] }), pagination !== null ? _jsx(Pagination, Object.assign({}, pagination)) : null] }));
90
+ return (_jsxs("div", { className: "min-w-full", children: [_jsxs("div", { className: `group rounded-lg px-1 ${border ? "border border-table-border" : ""}`, children: [_jsx(TableVirtuoso, { data: rows, useWindowScroll: true, components: components, totalCount: rows.length, itemContent: ItemContent, context: { loading: props.loading, loadingMore: props.loadingMore, cols: cols }, fixedFooterContent: showLoadingFooter ? Frag : null, fixedHeaderContent: () => (_jsx(TableHeader, { headers: cols, sorters: sorters, filters: filters, setCols: setCols, setSorters: setSorters, setFilters: setFilters, loading: !!props.loading })) }), _jsx("div", { "aria-hidden": "true", ref: ref, className: "h-0.5 w-full" })] }), pagination !== null ? _jsx(Pagination, Object.assign({}, pagination)) : null] }));
90
91
  };
91
92
  const dispatcherFun = (prev, setter) => typeof setter === "function" ? setter(prev) : setter;
92
93
  export const Table = (props) => {
@@ -1 +1 @@
1
- {"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../../../src/components/table/pagination.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAwB9C,eAAO,MAAM,UAAU,eAAgB,eAAe,4CA6CrD,CAAA"}
1
+ {"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../../../src/components/table/pagination.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAwB9C,eAAO,MAAM,UAAU,eAAgB,eAAe,4CAyErD,CAAC"}
@@ -1,5 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Fragment, useMemo } from "react";
2
+ import { Fragment, useId, useMemo } from "react";
3
+ import { useTranslations } from "../../hooks/use-translate-context";
3
4
  function createPaginationItems(current, max) {
4
5
  if (!current || !max)
5
6
  return [];
@@ -26,19 +27,17 @@ function createPaginationItems(current, max) {
26
27
  return Array.from(new Set(items));
27
28
  }
28
29
  export const Pagination = (pagination) => {
30
+ const id = useId();
31
+ const translation = useTranslations();
29
32
  const Render = pagination.asLink || "button";
30
33
  const pageNavigation = useMemo(() => createPaginationItems(pagination.current, pagination.pages), [pagination.current, pagination.pages]);
31
34
  const hasNext = pagination.current < pagination.pages;
32
- return _jsxs("footer", { className: "flex px-1 py-2 items-center justify-center gap-4 lg:justify-between flex-wrap lg:flex-nowrap", children: [_jsxs("p", { children: [pagination.current, " to ", pagination.pages, " of ", pagination.totalItems, " items.", pagination.onChangeSize && Array.isArray(pagination.sizes) ?
33
- _jsxs(Fragment, { children: [_jsx("select", { value: pagination.size, className: "cursor-pointer bg-transparent", onChange: e => {
34
- var _a;
35
- (_a = pagination.onChangeSize) === null || _a === void 0 ? void 0 : _a.call(pagination, Number(e.target.value));
36
- }, children: pagination.sizes.map(value => _jsx("option", { value: value, children: value })) }), " per page"] })
37
- : null] }), _jsx("nav", { children: _jsxs("ul", { className: "flex items-center gap-2", children: [pagination.current > 1 ? _jsx("li", { children: _jsx(Render, { href: "previous", className: "", children: "Previous" }) }) : null, pageNavigation.map(x => {
35
+ return (_jsxs("footer", { className: "flex px-1 py-4 items-center justify-center gap-4 lg:justify-between flex-wrap lg:flex-nowrap", children: [_jsx("p", { children: _jsx(translation.tablePaginationFooter, Object.assign({}, pagination, { sizes: pagination.sizes, select: pagination.onChangeSize && Array.isArray(pagination.sizes) ? (_jsxs(Fragment, { children: [_jsx("label", { htmlFor: id, children: translation.tablePaginationSelectLabel }), _jsx("select", { id: id, value: pagination.size, className: "cursor-pointer bg-transparent", onChange: (e) => {
36
+ var _a;
37
+ (_a = pagination.onChangeSize) === null || _a === void 0 ? void 0 : _a.call(pagination, Number(e.target.value));
38
+ }, children: pagination.sizes.map((value) => (_jsx("option", { value: value, children: value }, `pagination-opt-${value}`))) }), " "] })) : null })) }), _jsx("nav", { children: _jsxs("ul", { className: "flex items-center gap-2", children: [pagination.current > 1 ? (_jsx("li", { children: _jsx(Render, { href: "previous", className: "", children: translation.tablePaginationPrevious }) })) : null, pageNavigation.map((x) => {
38
39
  if (x === null)
39
40
  return null;
40
- return _jsx(Fragment, { children: typeof x === "string" ?
41
- _jsx("li", { children: "..." }) :
42
- _jsx("li", { children: _jsx(Render, { href: x, className: `cursor-pointer px-3 py-1 transition-colors border-b-2 hover:text-primary-subtle hover:border-primary-subtle proportional-nums ${x === pagination.current ? "text-primary border-primary" : "border-transparent"}`, children: x }) }, `pagination-${x}`) });
43
- }), hasNext ? _jsx("li", { children: _jsx(Render, { href: "next", className: "", children: "Next" }) }) : null] }) })] });
41
+ return (_jsx(Fragment, { children: typeof x === "string" ? (_jsx("li", { children: "..." })) : (_jsx("li", { children: _jsx(Render, { href: x, className: `cursor-pointer px-3 py-1 transition-colors border-b-2 hover:text-primary-subtle hover:border-primary-subtle proportional-nums ${x === pagination.current ? "text-primary border-primary" : "border-transparent"}`, children: x }) })) }, `pagination-${x}`));
42
+ }), hasNext ? (_jsx("li", { children: _jsx(Render, { href: "next", className: "", children: translation.tablePaginationNext }) })) : null] }) })] }));
44
43
  };
@@ -1 +1 @@
1
- {"version":3,"file":"sort.d.ts","sourceRoot":"","sources":["../../../src/components/table/sort.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAwC,MAAM,OAAO,CAAC;AAE7D,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAGpC,OAAO,EAAE,GAAG,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAE3E,KAAK,KAAK,CAAC,CAAC,SAAS,EAAE,IAAI,MAAM,CAAC,SAAS,MAAM,CAAC,SAAS,MAAM,GAAG,CAAC,GAAG,KAAK,CAAC;AAE9E,aAAK,KAAK;IACN,GAAG,QAAQ;IACX,IAAI,SAAS;IACb,SAAS,cAAc;CAC1B;AAED,MAAM,MAAM,MAAM,CAAC,CAAC,SAAS,EAAE,IAAI;IAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IAAC,IAAI,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,KAAK,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC;AAY9F,eAAO,MAAM,SAAS,GAAI,CAAC,SAAS,EAAE,SAA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