@g4rcez/components 0.2.0 → 0.2.2

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 (143) hide show
  1. package/dist/index.css +1 -1
  2. package/dist/index.js +44 -44
  3. package/dist/index.js.map +1 -1
  4. package/dist/index.mjs +10100 -9939
  5. package/dist/index.mjs.map +1 -1
  6. package/dist/index.umd.js +44 -44
  7. package/dist/index.umd.js.map +1 -1
  8. package/dist/preset/preset.tailwind.js +14 -14
  9. package/dist/preset/src/styles/common.d.ts +4 -0
  10. package/dist/preset/src/styles/common.d.ts.map +1 -1
  11. package/dist/preset/src/styles/common.js +10 -0
  12. package/dist/preset/src/styles/dark.d.ts.map +1 -1
  13. package/dist/preset/src/styles/dark.js +2 -1
  14. package/dist/preset/src/styles/design-tokens.d.ts +8 -7
  15. package/dist/preset/src/styles/design-tokens.d.ts.map +1 -1
  16. package/dist/preset/src/styles/design-tokens.js +16 -12
  17. package/dist/preset/src/styles/light.d.ts.map +1 -1
  18. package/dist/preset/src/styles/light.js +6 -5
  19. package/dist/preset/src/styles/theme.types.d.ts +10 -1
  20. package/dist/preset/src/styles/theme.types.d.ts.map +1 -1
  21. package/dist/preset.tailwind.js +14 -14
  22. package/dist/src/components/core/tag.d.ts +1 -1
  23. package/dist/src/components/core/tag.js +2 -2
  24. package/dist/src/components/display/alert.js +1 -1
  25. package/dist/src/components/display/calendar.d.ts +1 -1
  26. package/dist/src/components/display/calendar.d.ts.map +1 -1
  27. package/dist/src/components/display/calendar.js +24 -23
  28. package/dist/src/components/display/card.js +1 -1
  29. package/dist/src/components/display/empty.d.ts.map +1 -1
  30. package/dist/src/components/display/list.js +1 -1
  31. package/dist/src/components/display/tabs.d.ts.map +1 -1
  32. package/dist/src/components/display/tabs.js +2 -2
  33. package/dist/src/components/display/timeline.d.ts +8 -30
  34. package/dist/src/components/display/timeline.d.ts.map +1 -1
  35. package/dist/src/components/display/timeline.js +11 -14
  36. package/dist/src/components/floating/dropdown.js +2 -2
  37. package/dist/src/components/floating/expand.d.ts +2 -0
  38. package/dist/src/components/floating/expand.d.ts.map +1 -1
  39. package/dist/src/components/floating/expand.js +12 -5
  40. package/dist/src/components/floating/menu.js +2 -2
  41. package/dist/src/components/floating/modal.d.ts +5 -2
  42. package/dist/src/components/floating/modal.d.ts.map +1 -1
  43. package/dist/src/components/floating/modal.js +14 -7
  44. package/dist/src/components/form/autocomplete.d.ts.map +1 -1
  45. package/dist/src/components/form/autocomplete.js +27 -22
  46. package/dist/src/components/form/checkbox.d.ts +1 -0
  47. package/dist/src/components/form/checkbox.d.ts.map +1 -1
  48. package/dist/src/components/form/checkbox.js +4 -1
  49. package/dist/src/components/form/free-text.d.ts.map +1 -1
  50. package/dist/src/components/form/free-text.js +2 -2
  51. package/dist/src/components/form/input-field.d.ts +1 -0
  52. package/dist/src/components/form/input-field.d.ts.map +1 -1
  53. package/dist/src/components/form/input-field.js +2 -2
  54. package/dist/src/components/form/input.d.ts.map +1 -1
  55. package/dist/src/components/form/input.js +3 -1
  56. package/dist/src/components/form/multi-select.d.ts +19 -0
  57. package/dist/src/components/form/multi-select.d.ts.map +1 -0
  58. package/dist/src/components/form/{multi-combobox.js → multi-select.js} +45 -34
  59. package/dist/src/components/form/select.d.ts.map +1 -1
  60. package/dist/src/components/form/select.js +2 -2
  61. package/dist/src/components/form/switch.d.ts +1 -0
  62. package/dist/src/components/form/switch.d.ts.map +1 -1
  63. package/dist/src/components/form/switch.js +7 -6
  64. package/dist/src/components/index.d.ts +2 -1
  65. package/dist/src/components/index.d.ts.map +1 -1
  66. package/dist/src/components/index.js +2 -1
  67. package/dist/src/components/table/filter.d.ts.map +1 -1
  68. package/dist/src/components/table/filter.js +1 -1
  69. package/dist/src/components/table/index.d.ts.map +1 -1
  70. package/dist/src/components/table/index.js +11 -7
  71. package/dist/src/components/table/pagination.d.ts.map +1 -1
  72. package/dist/src/components/table/pagination.js +6 -6
  73. package/dist/src/components/table/table-lib.d.ts +3 -2
  74. package/dist/src/components/table/table-lib.d.ts.map +1 -1
  75. package/dist/src/components/table/table-lib.js +16 -0
  76. package/dist/src/components/table/thead.d.ts.map +1 -1
  77. package/dist/src/components/table/thead.js +27 -6
  78. package/dist/src/config/context.d.ts +17 -0
  79. package/dist/src/config/context.d.ts.map +1 -0
  80. package/dist/src/config/context.js +10 -0
  81. package/dist/src/config/default-translations.d.ts +59 -0
  82. package/dist/src/config/default-translations.d.ts.map +1 -0
  83. package/dist/src/config/default-translations.js +52 -0
  84. package/dist/src/config/default-tweaks.d.ts +12 -0
  85. package/dist/src/config/default-tweaks.d.ts.map +1 -0
  86. package/dist/src/config/default-tweaks.js +4 -0
  87. package/dist/src/hooks/use-color-parser.js +1 -1
  88. package/dist/src/hooks/use-components-provider.d.ts +4 -76
  89. package/dist/src/hooks/use-components-provider.d.ts.map +1 -1
  90. package/dist/src/hooks/use-components-provider.js +5 -63
  91. package/dist/src/hooks/use-debounce.d.ts +1 -0
  92. package/dist/src/hooks/use-debounce.d.ts.map +1 -1
  93. package/dist/src/hooks/use-debounce.js +1 -1
  94. package/dist/src/hooks/use-form.d.ts +1 -1
  95. package/dist/src/hooks/use-is-coarse-device.d.ts +2 -0
  96. package/dist/src/hooks/use-is-coarse-device.d.ts.map +1 -0
  97. package/dist/src/hooks/use-is-coarse-device.js +12 -0
  98. package/dist/src/hooks/use-locale.d.ts +1 -1
  99. package/dist/src/hooks/use-locale.d.ts.map +1 -1
  100. package/dist/src/hooks/use-locale.js +2 -2
  101. package/dist/src/hooks/use-on-event.js +1 -1
  102. package/dist/src/hooks/use-reactive.d.ts +1 -1
  103. package/dist/src/hooks/use-reactive.d.ts.map +1 -1
  104. package/dist/src/hooks/use-remove-scroll.d.ts.map +1 -1
  105. package/dist/src/hooks/use-remove-scroll.js +6 -2
  106. package/dist/src/hooks/use-swipe.d.ts +8 -0
  107. package/dist/src/hooks/use-swipe.d.ts.map +1 -0
  108. package/dist/src/hooks/use-swipe.js +16 -0
  109. package/dist/src/hooks/use-translations.d.ts +2 -2
  110. package/dist/src/hooks/use-translations.d.ts.map +1 -1
  111. package/dist/src/hooks/use-translations.js +2 -1
  112. package/dist/src/hooks/use-tweaks.d.ts +1 -1
  113. package/dist/src/hooks/use-tweaks.d.ts.map +1 -1
  114. package/dist/src/hooks/use-tweaks.js +2 -1
  115. package/dist/src/index.d.ts +10 -7
  116. package/dist/src/index.d.ts.map +1 -1
  117. package/dist/src/index.js +9 -6
  118. package/dist/src/lib/dict.d.ts +3 -3
  119. package/dist/src/lib/dict.d.ts.map +1 -1
  120. package/dist/src/lib/dict.js +9 -7
  121. package/dist/src/lib/dom.d.ts +3 -3
  122. package/dist/src/lib/dom.d.ts.map +1 -1
  123. package/dist/src/lib/dom.js +1 -1
  124. package/dist/src/lib/fns.d.ts +4 -2
  125. package/dist/src/lib/fns.d.ts.map +1 -1
  126. package/dist/src/lib/fns.js +4 -0
  127. package/dist/src/styles/common.d.ts +4 -0
  128. package/dist/src/styles/common.d.ts.map +1 -1
  129. package/dist/src/styles/common.js +10 -0
  130. package/dist/src/styles/dark.d.ts.map +1 -1
  131. package/dist/src/styles/dark.js +2 -1
  132. package/dist/src/styles/design-tokens.d.ts +8 -7
  133. package/dist/src/styles/design-tokens.d.ts.map +1 -1
  134. package/dist/src/styles/design-tokens.js +13 -10
  135. package/dist/src/styles/light.d.ts.map +1 -1
  136. package/dist/src/styles/light.js +6 -5
  137. package/dist/src/styles/theme.types.d.ts +10 -1
  138. package/dist/src/styles/theme.types.d.ts.map +1 -1
  139. package/dist/src/types.d.ts +2 -1
  140. package/dist/src/types.d.ts.map +1 -1
  141. package/package.json +2 -2
  142. package/dist/src/components/form/multi-combobox.d.ts +0 -24
  143. package/dist/src/components/form/multi-combobox.d.ts.map +0 -1
@@ -1,32 +1,10 @@
1
- import React from "react";
2
- declare const typeMap: {
3
- tag: () => null;
4
- custom: () => null;
5
- record: ({ item }: {
6
- item: TimelineItemProps;
7
- }) => import("react/jsx-runtime").JSX.Element;
1
+ import { ComponentProps, ElementType, PropsWithChildren } from "react";
2
+ import { PolymorphicProps } from "../core/polymorph";
3
+ export declare const TimelineItem: {
4
+ (props: PropsWithChildren): import("react/jsx-runtime").JSX.Element;
5
+ Icon(props: PropsWithChildren<ComponentProps<"header">>): import("react/jsx-runtime").JSX.Element;
6
+ Body<T extends ElementType = "section">(props: PropsWithChildren<PolymorphicProps<object, T>>): import("react/jsx-runtime").JSX.Element;
7
+ Right<T extends ElementType = "button">(props: PolymorphicProps<object, T>): import("react/jsx-runtime").JSX.Element;
8
8
  };
9
- export type TimelineItemType = keyof typeof typeMap;
10
- export type TimelineItemProps = {
11
- id: string | number;
12
- date: Date;
13
- type: TimelineItemType;
14
- avatar?: {
15
- img?: string;
16
- name: string;
17
- profile?: string;
18
- };
19
- text?: string;
20
- custom?: React.FC<{
21
- item: TimelineItemProps;
22
- }>;
23
- };
24
- export type TimelineProps = {
25
- items: TimelineItemProps[];
26
- Custom?: React.FC<{
27
- item: TimelineItemProps;
28
- }>;
29
- };
30
- export declare const Timeline: (props: TimelineProps) => import("react/jsx-runtime").JSX.Element;
31
- export {};
9
+ export declare const Timeline: (props: PropsWithChildren) => import("react/jsx-runtime").JSX.Element;
32
10
  //# sourceMappingURL=timeline.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"timeline.d.ts","sourceRoot":"","sources":["../../../../src/components/display/timeline.tsx"],"names":[],"mappings":"AACA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,QAAA,MAAM,OAAO;;;;cA4B+B,iBAAiB;;CAAI,CAAC;AAElE,MAAM,MAAM,gBAAgB,GAAG,MAAM,OAAO,OAAO,CAAC;AAEpD,MAAM,MAAM,iBAAiB,GAAG;IAC5B,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,IAAI,EAAE,IAAI,CAAC;IACX,IAAI,EAAE,gBAAgB,CAAC;IACvB,MAAM,CAAC,EAAE;QAAE,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC1D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC;QAAE,IAAI,EAAE,iBAAiB,CAAA;KAAE,CAAC,CAAC;CAClD,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAAE,KAAK,EAAE,iBAAiB,EAAE,CAAC;IAAC,MAAM,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC;QAAE,IAAI,EAAE,iBAAiB,CAAA;KAAE,CAAC,CAAA;CAAE,CAAC;AAE3G,eAAO,MAAM,QAAQ,GAAI,OAAO,aAAa,4CAyB5C,CAAC"}
1
+ {"version":3,"file":"timeline.d.ts","sourceRoot":"","sources":["../../../../src/components/display/timeline.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,cAAc,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE9E,OAAO,EAAa,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAEhE,eAAO,MAAM,YAAY;YAAW,iBAAiB;gBAOJ,iBAAiB,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;SAW9C,CAAC,SAAS,WAAW,qBAAqB,iBAAiB,CAAC,gBAAgB,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;UAQtF,CAAC,SAAS,WAAW,oBAAoB,gBAAgB,CAAC,MAAM,EAAE,CAAC,CAAC;CArBnH,CAAC;AA6BF,eAAO,MAAM,QAAQ,GAAI,OAAO,iBAAiB,4CAIhD,CAAC"}
@@ -1,17 +1,14 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { MessagesSquareIcon } from "lucide-react";
3
- import { Fragment } from "react";
4
- const typeMap = {
5
- tag: () => null,
6
- custom: () => null,
7
- record: ({ item }) => (_jsxs(Fragment, { children: [_jsxs("div", { className: "relative", children: [_jsx("img", { src: item.avatar?.img, alt: item.avatar?.name, className: "flex aspect-square size-12 items-center justify-center rounded-full bg-primary-hover" }), _jsx("span", { className: "absolute -bottom-0.5 -right-1 rounded-full rounded-tl bg-card-background px-0.5 py-px", children: _jsx(MessagesSquareIcon, { "aria-hidden": "true", className: "aspect-square size-5" }) })] }), _jsxs("div", { className: "min-w-0 flex-1 text-foreground", children: [_jsxs("div", { children: [_jsx("a", { href: item.avatar?.profile, className: "text-base font-medium text-primary", children: item.avatar?.name }), _jsxs("p", { className: "mt-0.5 text-sm", children: ["Commented ", item.date.toISOString()] })] }), _jsx("div", { className: "mt-2 text-wrap text-sm", children: _jsx("p", { children: item.text }) })] })] })),
2
+ import { css } from "../../lib/dom";
3
+ import { Polymorph } from "../core/polymorph";
4
+ export const TimelineItem = (props) => (_jsxs("li", { "data-component": "timeline-item", className: "relative pb-12", role: "listitem", children: [_jsx("span", { "aria-hidden": "true", className: "absolute left-6 top-8 -ml-px h-full w-0.5 bg-card-border" }), _jsx("div", { className: "relative flex items-stretch justify-start space-x-3", children: props.children })] }));
5
+ TimelineItem.Icon = function TimelineIcon(props) {
6
+ return (_jsx("header", { ...props, className: css("flex size-12 items-center justify-center rounded-full bg-primary p-2 text-primary-foreground", props.className), children: props.children }));
8
7
  };
9
- export const Timeline = (props) => {
10
- return (_jsx("div", { className: "flow-root", children: _jsx("ul", { role: "list", className: "-mb-8", children: props.items.map((item, index) => {
11
- const Render = typeMap[item.type] ?? null;
12
- if (Render === null && props.Custom) {
13
- return _jsx(props.Custom, { item: item });
14
- }
15
- return (_jsx("li", { children: _jsxs("div", { className: "relative pb-8", children: [index !== props.items.length - 1 ? (_jsx("span", { "aria-hidden": "true", className: "absolute left-5 top-5 -ml-px h-full w-0.5 bg-card-border" })) : null, _jsx("div", { className: "relative flex items-start space-x-3", children: _jsx(Render, { item: item }) })] }) }, item.id));
16
- }) }) }));
8
+ TimelineItem.Body = function TimelineItemBody(props) {
9
+ return (_jsx(Polymorph, { ...props, className: css("min-w-0 flex-1", props.className), children: props.children }));
17
10
  };
11
+ TimelineItem.Right = function TimelineItemRight(props) {
12
+ return (_jsx("footer", { className: "flex gap-6 self-stretch px-4 align-baseline", children: _jsx(Polymorph, { ...props, type: "button" }) }));
13
+ };
14
+ export const Timeline = (props) => (_jsx("ul", { "data-component": "timeline", role: "list", className: "flow-root [&>li:last-child>span[aria-hidden=true]]:hidden", children: props.children }));
@@ -32,7 +32,7 @@ export const Dropdown = (props) => {
32
32
  });
33
33
  const click = useClick(context);
34
34
  const dismiss = useDismiss(context);
35
- const role = useRole(context);
35
+ const role = useRole(context, { role: "tooltip" });
36
36
  const { getReferenceProps, getFloatingProps } = useInteractions([click, dismiss, role]);
37
- return (_jsxs(Fragment, { children: [_jsx("button", { ref: refs.setReference, ...getReferenceProps(props.buttonProps), type: "button", children: props.trigger }), open && (_jsx(FloatingPortal, { preserveTabOrder: true, id: `${headingId}-portal`, children: _jsx(FloatingFocusManager, { guards: true, restoreFocus: true, returnFocus: true, visuallyHiddenDismiss: true, context: context, modal: false, children: _jsxs("div", { className: "relative isolate z-floating min-w-96 rounded-lg border border-floating-border bg-floating-background p-6 shadow-2xl", ref: refs.setFloating, style: floatingStyles, "aria-labelledby": headingId, ...getFloatingProps(), children: [_jsx(FloatingArrow, { ref: arrowRef, context: context, strokeWidth: 0.1, className: "fill-floating-background stroke-floating-border" }), _jsx("header", { className: "mb-2", children: _jsx("h3", { className: "text-left text-2xl font-medium leading-snug tracking-wide", children: props.title }) }), props.children] }) }) }))] }));
37
+ return (_jsxs(Fragment, { children: [_jsx("button", { ref: refs.setReference, ...getReferenceProps(props.buttonProps), type: "button", children: props.trigger }), open && (_jsx(FloatingPortal, { preserveTabOrder: true, id: `${headingId}-portal`, children: _jsx(FloatingFocusManager, { guards: true, restoreFocus: true, returnFocus: true, visuallyHiddenDismiss: true, context: context, modal: false, children: _jsxs("div", { className: "relative isolate z-floating min-w-96 rounded-lg border border-floating-border bg-floating-background p-4 shadow-2xl", ref: refs.setFloating, style: floatingStyles, "aria-labelledby": headingId, ...getFloatingProps(), children: [_jsx(FloatingArrow, { ref: arrowRef, context: context, strokeWidth: 0.1, className: "fill-floating-background stroke-floating-border" }), _jsx("header", { className: "mb-2", children: _jsx("h3", { className: "text-left text-2xl font-medium leading-snug tracking-wide", children: props.title }) }), props.children] }) }) }))] }));
38
38
  };
@@ -4,6 +4,8 @@ import { Label, Override } from "../../types";
4
4
  import { ButtonProps } from "../core/button";
5
5
  export type ExpandProps = Override<ButtonProps<typeof motion.button>, {
6
6
  trigger: Label;
7
+ open?: boolean;
8
+ disabled?: boolean;
7
9
  }>;
8
10
  export declare const Expand: (props: PropsWithChildren<ExpandProps>) => import("react/jsx-runtime").JSX.Element;
9
11
  //# sourceMappingURL=expand.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"expand.d.ts","sourceRoot":"","sources":["../../../../src/components/floating/expand.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAmB,MAAM,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAA2B,MAAM,OAAO,CAAC;AACnE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAU,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAErD,MAAM,MAAM,WAAW,GAAG,QAAQ,CAAC,WAAW,CAAC,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE;IAAE,OAAO,EAAE,KAAK,CAAA;CAAE,CAAC,CAAC;AAE1F,eAAO,MAAM,MAAM,GAAI,OAAO,iBAAiB,CAAC,WAAW,CAAC,4CA4C3D,CAAC"}
1
+ {"version":3,"file":"expand.d.ts","sourceRoot":"","sources":["../../../../src/components/floating/expand.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAmB,MAAM,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAsC,MAAM,OAAO,CAAC;AAC9E,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAU,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAErD,MAAM,MAAM,WAAW,GAAG,QAAQ,CAC9B,WAAW,CAAC,OAAO,MAAM,CAAC,MAAM,CAAC,EACjC;IACI,OAAO,EAAE,KAAK,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB,CACJ,CAAC;AAEF,eAAO,MAAM,MAAM,GAAI,OAAO,iBAAiB,CAAC,WAAW,CAAC,4CAmD3D,CAAC"}
@@ -2,14 +2,17 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { FloatingFocusManager, FloatingPortal, useClick, useDismiss, useFloating, useInteractions, useRole } from "@floating-ui/react";
4
4
  import { AnimatePresence, motion } from "motion/react";
5
- import { useId, useRef, useState } from "react";
5
+ import { useEffect, useId, useRef, useState } from "react";
6
6
  import { Button } from "../core/button";
7
7
  export const Expand = (props) => {
8
8
  const root = useRef(null);
9
9
  const id = useId();
10
10
  const wrapperId = `${id}:wrapper`;
11
11
  const titleId = `${id}:title`;
12
- const [open, setOpen] = useState(false);
12
+ const [open, setOpen] = useState(props.open ?? false);
13
+ useEffect(() => {
14
+ setOpen(props.open ?? false);
15
+ }, [props.open]);
13
16
  const { context, refs } = useFloating({
14
17
  transform: true,
15
18
  open: open !== null,
@@ -17,9 +20,13 @@ export const Expand = (props) => {
17
20
  onOpenChange: setOpen,
18
21
  strategy: "absolute",
19
22
  });
20
- const click = useClick(context);
21
- const role = useRole(context);
22
- const dismiss = useDismiss(context, { escapeKey: true, referencePress: true, outsidePress: true });
23
+ const click = useClick(context, { enabled: props.disabled ?? true });
24
+ const role = useRole(context, { role: "tooltip" });
25
+ const dismiss = useDismiss(context, {
26
+ escapeKey: true,
27
+ referencePress: true,
28
+ outsidePress: true,
29
+ });
23
30
  const { getFloatingProps, getReferenceProps } = useInteractions([click, role, dismiss]);
24
31
  return (_jsxs("div", { className: "relative inline-flex items-center justify-center", ref: root, children: [_jsx(Button, { ...getReferenceProps(props), as: motion.button, layoutId: wrapperId, ref: refs.setReference, size: "small", onClick: () => setOpen(true), children: _jsx(motion.span, { layoutId: titleId, children: props.trigger }) }), _jsx(AnimatePresence, { children: open ? (_jsx(FloatingPortal, { root: root, children: _jsx(FloatingFocusManager, { visuallyHiddenDismiss: true, modal: true, closeOnFocusOut: true, context: context, children: _jsx(motion.div, { ...getFloatingProps(), ref: refs.setFloating, layoutId: wrapperId, className: "absolute -left-1/4 -top-3/4", children: props.children }) }) })) : null })] }));
25
32
  };
@@ -36,7 +36,7 @@ const MenuComponent = React.forwardRef(({ children, FloatingComponent = "div", h
36
36
  placement: isNested ? "right" : "bottom-start",
37
37
  middleware: [offset({ mainAxis: isNested ? 0 : 4, alignmentAxis: isNested ? -4 : 0 }), flip(), shift()],
38
38
  });
39
- const role = useRole(context, { role: "menu", enabled: true });
39
+ const role = useRole(context, { role: "menu" });
40
40
  const dismiss = useDismiss(context, { bubbles: true });
41
41
  const hoverModule = useHover(context, {
42
42
  move: false,
@@ -102,7 +102,7 @@ const MenuComponent = React.forwardRef(({ children, FloatingComponent = "div", h
102
102
  setHasFocusInside(false);
103
103
  parent.setHasFocusInside(true);
104
104
  },
105
- })), children: [label, isNested && (_jsxs("span", { style: { marginLeft: 10, fontSize: 10 }, children: [_jsx("span", { className: "sr-only", children: "Next menu" }), _jsx(ChevronRightIcon, { size: 14 })] }))] })) }), _jsx(MenuContext.Provider, { value: { activeIndex, setActiveIndex, getItemProps, setHasFocusInside, isOpen }, children: _jsx(FloatingList, { elementsRef: elementsRef, labelsRef: labelsRef, children: isOpen && (_jsx(FloatingPortal, { preserveTabOrder: true, children: _jsx(FloatingFocusManager, { context: context, modal: false, initialFocus: isNested ? -1 : 0, returnFocus: !isNested, children: _jsx(FloatingComponent, { ...getFloatingProps(), ref: refs.setFloating, style: { ...props.style, ...floatingStyles }, className: css("isolate z-tooltip flex flex-col items-start rounded-lg border border-floating-border bg-floating-background text-left shadow-xl outline-none", floatingClassName), children: children }) }) })) }) })] }));
105
+ })), children: [label, isNested && (_jsxs("span", { style: { marginLeft: 10, fontSize: 10 }, children: [_jsx("span", { className: "sr-only", children: "Next menu" }), _jsx(ChevronRightIcon, { size: 14 })] }))] })) }), _jsx(MenuContext.Provider, { value: { activeIndex, setActiveIndex, getItemProps, setHasFocusInside, isOpen }, children: _jsx(FloatingList, { elementsRef: elementsRef, labelsRef: labelsRef, children: isOpen && (_jsx(FloatingPortal, { preserveTabOrder: true, children: _jsx(FloatingFocusManager, { context: context, modal: false, initialFocus: isNested ? -1 : 0, returnFocus: !isNested, children: _jsx(FloatingComponent, { ...getFloatingProps(), ref: refs.setFloating, style: { ...props.style, ...floatingStyles }, className: css("isolate z-tooltip flex max-h-80 flex-col items-start overflow-y-auto rounded-lg border border-floating-border bg-floating-background text-left shadow-xl outline-none", floatingClassName), children: children }) }) })) }) })] }));
106
106
  });
107
107
  export const MenuItem = React.forwardRef(({ title, Right, disabled, children, ...props }, forwardedRef) => {
108
108
  const menu = useContext(MenuContext);
@@ -1,6 +1,8 @@
1
1
  import { HTMLMotionProps } from "motion/react";
2
2
  import React, { PropsWithChildren } from "react";
3
3
  import { Label, Override } from "../../types";
4
+ type DialogType = "dialog" | "drawer" | "sheet";
5
+ type DrawerPosition = "left" | "right";
4
6
  export type ModalProps = Override<HTMLMotionProps<"div">, ({
5
7
  title: Label;
6
8
  ariaTitle?: string;
@@ -13,15 +15,16 @@ export type ModalProps = Override<HTMLMotionProps<"div">, ({
13
15
  asChild?: boolean;
14
16
  layoutId?: string;
15
17
  resizer?: boolean;
18
+ type?: DialogType;
16
19
  className?: string;
17
20
  closable?: boolean;
18
21
  forceType?: boolean;
19
22
  overlayClassName?: string;
23
+ position?: DrawerPosition;
20
24
  overlayClickClose?: boolean;
21
- position?: "left" | "right";
22
25
  trigger?: Label | React.FC<any>;
23
- type?: "dialog" | "drawer" | "sheet";
24
26
  onChange: (nextState: boolean) => void;
25
27
  }>;
26
28
  export declare const Modal: ({ open, title, footer, asChild, trigger, children, layoutId, onChange, className, resizer, closable, forceType, overlayClassName, type: _type, position: propsPosition, overlayClickClose, ariaTitle, ...props }: PropsWithChildren<ModalProps>) => import("react/jsx-runtime").JSX.Element;
29
+ export {};
27
30
  //# sourceMappingURL=modal.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"modal.d.ts","sourceRoot":"","sources":["../../../../src/components/floating/modal.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAmB,eAAe,EAAqE,MAAM,cAAc,CAAC;AACnI,OAAO,KAAK,EAAE,EAAY,iBAAiB,EAAS,MAAM,OAAO,CAAC;AAIlE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AA2D9C,MAAM,MAAM,UAAU,GAAG,QAAQ,CAC7B,eAAe,CAAC,KAAK,CAAC,EACtB,CAAC;IAAE,KAAK,EAAE,KAAK,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,KAAK,CAAA;CAAE,CAAC,GAAG;IAC5E,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,CAAC,EAAE,KAAK,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC5B,OAAO,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;IAChC,IAAI,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAC;IACrC,QAAQ,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;CAC1C,CACJ,CAAC;AAoEF,eAAO,MAAM,KAAK,GAAI,kNAmBnB,iBAAiB,CAAC,UAAU,CAAC,4CA+G/B,CAAC"}
1
+ {"version":3,"file":"modal.d.ts","sourceRoot":"","sources":["../../../../src/components/floating/modal.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAmB,eAAe,EAAqE,MAAM,cAAc,CAAC;AACnI,OAAO,KAAK,EAAE,EAAY,iBAAiB,EAAS,MAAM,OAAO,CAAC;AAIlE,OAAO,EAAE,KAAK,EAAO,QAAQ,EAAE,MAAM,aAAa,CAAC;AA2DnD,KAAK,UAAU,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAC;AAEhD,KAAK,cAAc,GAAG,MAAM,GAAG,OAAO,CAAC;AAEvC,MAAM,MAAM,UAAU,GAAG,QAAQ,CAC7B,eAAe,CAAC,KAAK,CAAC,EACtB,CAAC;IAAE,KAAK,EAAE,KAAK,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,KAAK,CAAA;CAAE,CAAC,GAAG;IAC5E,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,CAAC,EAAE,KAAK,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,OAAO,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;IAChC,QAAQ,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;CAC1C,CACJ,CAAC;AA2EF,eAAO,MAAM,KAAK,GAAI,kNAmBnB,iBAAiB,CAAC,UAAU,CAAC,4CA8G/B,CAAC"}
@@ -28,9 +28,9 @@ const animations = {
28
28
  exit: { opacity: 0.1, translateY: "50%", animationDuration, originY: "bottom" },
29
29
  },
30
30
  dialog: {
31
+ exit: { opacity: 0, scale: 0.97, animationDuration },
31
32
  initial: { opacity: 0, scale: 0.95, animationDuration },
32
33
  enter: { opacity: 1, scale: [1.05, 1], animationDuration },
33
- exit: { opacity: 0, scale: 0.97, animationDuration },
34
34
  },
35
35
  };
36
36
  const variants = cva("z-floating border border-card-border ring-0 outline-0 appearance-none flex flex-col gap-4 flex-nowrap min-w-xs bg-floating-background", {
@@ -57,7 +57,8 @@ const Draggable = (props) => {
57
57
  const div = props.parent.current;
58
58
  const v = props.value.get() || div.getBoundingClientRect().width;
59
59
  const delta = props.position === "right" ? -info.delta.x : info.delta.x;
60
- return props.value.set(Math.abs(v + delta));
60
+ const value = Math.abs(v + delta);
61
+ return props.value.set(value);
61
62
  }
62
63
  const div = props.parent.current;
63
64
  const rect = div.getBoundingClientRect();
@@ -78,28 +79,34 @@ const Draggable = (props) => {
78
79
  : "left-2 top-1/2 h-10 w-2"), children: props.sheet ? _jsx("div", { className: "h-2 w-1/4 rounded-lg bg-floating-border" }) : null }));
79
80
  };
80
81
  const positions = { drawer: "right", sheet: "none", dialog: "none" };
82
+ const fetchPosition = (isDesktop, forceType, propsType, propsPosition) => {
83
+ const type = propsType || "dialog";
84
+ if (isDesktop)
85
+ return propsType === "drawer" ? (propsPosition ?? positions.drawer) : positions[type];
86
+ return forceType ? positions[type] : positions.sheet;
87
+ };
81
88
  export const Modal = ({ open, title, footer, asChild, trigger, children, layoutId, onChange, className, resizer = true, closable = true, forceType = false, overlayClassName = "", type: _type = "dialog", position: propsPosition, overlayClickClose = false, ariaTitle, ...props }) => {
82
89
  useRemoveScroll(open);
83
90
  const headingId = useId();
84
91
  const descriptionId = useId();
85
92
  const isDesktop = useMediaQuery("(min-width: 64rem)");
86
93
  const useResizer = _type !== "dialog";
87
- const position = isDesktop ? (_type === "drawer" ? propsPosition : positions[_type]) : forceType ? positions[_type] : positions.sheet;
94
+ const position = fetchPosition(isDesktop, forceType, _type, propsPosition);
88
95
  const func = isDesktop ? animations[_type] : forceType ? animations[_type] : animations.sheet;
89
96
  const animation = typeof func === "function" ? func(position) : func;
90
97
  const type = isDesktop ? _type : forceType ? _type : "sheet";
91
98
  const { refs, context } = useFloating({ open: open, onOpenChange: onChange });
92
99
  const click = useClick(context);
93
- const role = useRole(context);
100
+ const role = useRole(context, { role: "dialog" });
94
101
  const dismiss = useDismiss(context, { escapeKey: true, referencePress: true, outsidePress: overlayClickClose });
95
102
  const { getReferenceProps, getFloatingProps } = useInteractions([click, role, dismiss]);
96
103
  const Trigger = trigger;
97
- const value = useMotionValue(undefined);
104
+ const floatingSize = useMotionValue(undefined);
98
105
  const onClose = () => onChange(false);
99
- return (_jsxs(Fragment, { children: [trigger ? (_jsx(Fragment, { children: asChild ? (_jsx(Slot, { ref: refs.setReference, ...getReferenceProps({ layoutId: layoutId }), children: Trigger })) : (_jsx(motion.button, { ref: refs.setReference, ...getReferenceProps(), layoutId: layoutId, type: "button", children: Trigger })) })) : null, _jsx(FloatingPortal, { children: _jsx(AnimatePresence, { mode: "wait", presenceAffectsLayout: true, children: open ? (_jsx(FloatingOverlay, { lockScroll: false, className: css(`fixed inset-0 isolate z-overlay h-[100dvh] !overflow-clip bg-floating-overlay/70 ${type === "drawer" ? "" : "flex items-start justify-center p-10"}`, overlayClassName), children: _jsx(FloatingFocusManager, { visuallyHiddenDismiss: true, modal: true, closeOnFocusOut: true, context: context, children: _jsxs(motion.div, { ...props, exit: "exit", animate: "enter", initial: "initial", variants: animation, "data-component": "modal", ref: refs.setFloating, "aria-modal": open, layoutId: layoutId, className: css(variants({ position, type }), className), style: type === "drawer" ? { width: value } : { height: value }, ...(title
106
+ return (_jsxs(Fragment, { children: [trigger ? (_jsx(Fragment, { children: asChild ? (_jsx(Slot, { ref: refs.setReference, ...getReferenceProps({ layoutId: layoutId }), children: Trigger })) : (_jsx(motion.button, { ref: refs.setReference, ...getReferenceProps(), layoutId: layoutId, type: "button", children: Trigger })) })) : null, _jsx(FloatingPortal, { children: _jsx(AnimatePresence, { mode: "wait", presenceAffectsLayout: true, children: open ? (_jsx(FloatingOverlay, { lockScroll: false, className: css(`inset-0 isolate z-overlay h-[100dvh] !overflow-clip bg-floating-overlay/70 ${type === "drawer" ? "" : "flex items-start justify-center p-10"}`, overlayClassName), children: _jsx(FloatingFocusManager, { visuallyHiddenDismiss: true, modal: true, closeOnFocusOut: true, context: context, children: _jsxs(motion.div, { ...props, exit: "exit", animate: "enter", initial: "initial", variants: animation, "data-component": "modal", ref: refs.setFloating, "aria-modal": open, layoutId: layoutId, className: css(variants({ position, type }), className), style: type === "drawer" ? { width: floatingSize } : { height: floatingSize }, ...(title
100
107
  ? {
101
108
  "aria-labelledby": headingId,
102
109
  "aria-describedby": descriptionId,
103
110
  }
104
- : { "aria-label": ariaTitle }), ...getFloatingProps(), children: [title ? (_jsx("header", { className: "relative w-full", children: title ? (_jsx("h2", { id: headingId, className: "border-b border-floating-border px-8 pb-2 text-3xl font-medium leading-relaxed", children: title })) : null })) : null, _jsx("section", { className: "flex-1 overflow-y-auto px-8 py-1", children: children }), footer ? _jsx("footer", { className: "w-full border-t border-floating-border px-8 pt-4", children: footer }) : null, closable ? (_jsx("nav", { className: "absolute right-4 top-1 z-floating", children: _jsx("button", { type: "button", onClick: onClose, className: "p-1 opacity-70 transition-colors hover:text-danger hover:opacity-100 focus:text-danger", children: _jsx(XIcon, {}) }) })) : null, useResizer && resizer ? (_jsx(Draggable, { value: value, onChange: onChange, sheet: type === "sheet", parent: refs.floating, position: position })) : null] }) }) })) : null }) })] }));
111
+ : { "aria-label": ariaTitle }), ...getFloatingProps(), children: [title ? (_jsx("header", { className: "relative w-full", children: title ? (_jsx("h2", { id: headingId, className: "border-b border-floating-border px-8 pb-2 text-3xl font-medium leading-relaxed", children: title })) : null })) : null, _jsx("section", { className: "flex-1 overflow-y-auto px-8 py-1", children: children }), footer ? _jsx("footer", { className: "w-full border-t border-floating-border px-8 pt-4", children: footer }) : null, closable ? (_jsx("nav", { className: "absolute right-4 top-1 z-floating", children: _jsx("button", { type: "button", onClick: onClose, className: "p-1 opacity-70 transition-colors hover:text-danger hover:opacity-100 focus:text-danger", children: _jsx(XIcon, {}) }) })) : null, useResizer && resizer ? (_jsx(Draggable, { onChange: onChange, parent: refs.floating, position: position, sheet: type === "sheet", value: floatingSize })) : null] }) }) })) : null }) })] }));
105
112
  };
@@ -1 +1 @@
1
- {"version":3,"file":"autocomplete.d.ts","sourceRoot":"","sources":["../../../../src/components/form/autocomplete.tsx"],"names":[],"mappings":"AAiBA,OAAO,KAAoF,MAAM,OAAO,CAAC;AAOzG,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,yGAiWxB,CAAC"}
1
+ {"version":3,"file":"autocomplete.d.ts","sourceRoot":"","sources":["../../../../src/components/form/autocomplete.tsx"],"names":[],"mappings":"AAiBA,OAAO,KAAoF,MAAM,OAAO,CAAC;AAOzG,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,yGAyWxB,CAAC"}
@@ -7,6 +7,7 @@ import { AnimatePresence, motion } from "motion/react";
7
7
  import { forwardRef, Fragment, useEffect, useRef, useState } from "react";
8
8
  import { flushSync } from "react-dom";
9
9
  import { Virtuoso } from "react-virtuoso";
10
+ import { Is } from "sidekicker";
10
11
  import { useTranslations } from "../../hooks/use-translations";
11
12
  import { css, dispatchInput, initializeInputDataset } from "../../lib/dom";
12
13
  import { safeRegex } from "../../lib/fns";
@@ -29,7 +30,7 @@ const Item = forwardRef(function VirtualItem({ item, context, ...props }, ref) {
29
30
  const components = { List, Item };
30
31
  const DEFAULT_SIZE = 320;
31
32
  const MIN_SIZE = 40;
32
- export const Autocomplete = forwardRef(({ options, dynamicOption = false, feedback = null, labelClassName, emptyMessage, interactive, rightLabel, optionalText, container, hideLeft = false, right, left, error, required = false, ...props }, externalRef) => {
33
+ export const Autocomplete = forwardRef(({ left, error, right, loading, options, container, rightLabel, interactive, emptyMessage, optionalText, labelClassName, feedback = null, hideLeft = false, required = false, dynamicOption = false, ...props }, externalRef) => {
33
34
  const fieldset = useRef(null);
34
35
  const virtuoso = useRef(null);
35
36
  const defaults = props.value ?? props.defaultValue ?? "";
@@ -77,7 +78,7 @@ export const Autocomplete = forwardRef(({ options, dynamicOption = false, feedba
77
78
  if (ul.current === null)
78
79
  return;
79
80
  let size = 0;
80
- const items = Array.from(ul.current.querySelectorAll("li")).slice(0, Math.min(list.length, 10));
81
+ const items = Array.from(ul.current.querySelectorAll("li")).slice(0, Math.min(displayList.length, 10));
81
82
  items.forEach((x) => {
82
83
  const rect = x.getBoundingClientRect();
83
84
  size += rect.height;
@@ -97,7 +98,7 @@ export const Autocomplete = forwardRef(({ options, dynamicOption = false, feedba
97
98
  padding: 10,
98
99
  elementContext: "reference",
99
100
  apply(a) {
100
- const w = fieldset.current?.getBoundingClientRect().width;
101
+ const w = fieldset.current.getBoundingClientRect().width;
101
102
  const ul = a.elements.floating.querySelector("ul");
102
103
  const fullSize = ul?.getBoundingClientRect().height || 0;
103
104
  const maxH = Math.min(fullSize < MIN_SIZE ? DEFAULT_SIZE : fullSize, DEFAULT_SIZE);
@@ -131,7 +132,7 @@ export const Autocomplete = forwardRef(({ options, dynamicOption = false, feedba
131
132
  focusItemOnOpen: "auto",
132
133
  openOnArrowKeyDown: true,
133
134
  scrollItemIntoView: true,
134
- onNavigate: (n) => setIndex((prev) => n ?? prev),
135
+ // onNavigate: (n) => setIndex((prev) => n ?? prev)
135
136
  }),
136
137
  ]);
137
138
  useEffect(() => {
@@ -170,6 +171,7 @@ export const Autocomplete = forwardRef(({ options, dynamicOption = false, feedba
170
171
  refs.reference.current?.focus();
171
172
  };
172
173
  const onFocus = () => {
174
+ setIndex((prev) => (prev === null ? 0 : prev));
173
175
  setOpen(true);
174
176
  setShadow("");
175
177
  };
@@ -178,11 +180,12 @@ export const Autocomplete = forwardRef(({ options, dynamicOption = false, feedba
178
180
  setShadow("");
179
181
  setValue("");
180
182
  setLabel("");
181
- dispatchInput(refs.reference.current, "");
183
+ dispatchInput(refs.reference.current);
182
184
  setClosed();
183
185
  };
184
186
  const id = props.id || props.name;
185
- return (_jsxs(InputField, { ...props, left: left, error: error, ref: fieldset, form: props.form, name: props.name, feedback: feedback, hideLeft: hideLeft, required: required, title: props.title, container: container, rightLabel: rightLabel, interactive: interactive, id: props.name || props.id, optionalText: optionalText, componentName: "autocomplete", labelClassName: labelClassName, placeholder: props.placeholder, right: _jsxs("span", { className: "flex items-center gap-0.5", children: [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({
187
+ const isEmpty = displayList.length === 0;
188
+ 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: props.name || props.id, 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({
186
189
  ...props,
187
190
  onChange,
188
191
  onFocus,
@@ -192,44 +195,46 @@ export const Autocomplete = forwardRef(({ options, dynamicOption = false, feedba
192
195
  id: `${id}-shadow`,
193
196
  onClick: (e) => e.currentTarget.focus(),
194
197
  onKeyDown(event) {
198
+ if (event.key === "Escape") {
199
+ event.currentTarget.blur();
200
+ return setClosed();
201
+ }
202
+ if (!open)
203
+ return;
195
204
  if (event.key === "ArrowDown") {
196
- let next = index + 1;
197
- if (next > list.length - 1)
205
+ let next = Is.number(index) ? index + 1 : 0;
206
+ if (next > displayList.length - 1)
198
207
  next = 0;
199
208
  virtuoso.current?.scrollIntoView({ index: next });
200
209
  return setIndex(next);
201
210
  }
202
211
  if (event.key === "ArrowUp") {
203
- let next = index - 1;
212
+ let next = Is.number(index) ? index - 1 : displayList.length - 1;
204
213
  if (next < 0)
205
- next = list.length - 1;
214
+ next = displayList.length - 1;
206
215
  virtuoso.current?.scrollIntoView({ index: next });
207
216
  return setIndex(next);
208
217
  }
209
- if (event.key === "Escape") {
210
- event.currentTarget.blur();
211
- return setClosed();
212
- }
213
218
  if (event.key === "Enter") {
214
- if (index !== null && list[index]) {
219
+ if (index !== null && displayList[index]) {
215
220
  event.preventDefault();
216
- return onSelect(list[index], index);
221
+ return onSelect(displayList[index], index);
217
222
  }
218
- if (list.length === 1) {
223
+ if (displayList.length === 1) {
219
224
  event.preventDefault();
220
- return onSelect(list[0], 0);
225
+ return onSelect(displayList[0], 0);
221
226
  }
222
227
  }
223
228
  },
224
- }), "data-value": value, "data-error": !!error, "data-name": id, "data-target": id, required: required, value: open ? shadow : label || value, "aria-autocomplete": "list", autoComplete: "off", className: css("input placeholder-input-mask group h-input-height w-full flex-1", "rounded-md bg-transparent px-input-x py-input-y text-foreground", "outline-none transition-colors focus:ring-2 focus:ring-inset focus:ring-primary", "group-error:text-danger group-error:placeholder-input-mask-error", "group-focus-within:border-primary group-hover:border-primary", props.className) }), _jsx("input", { id: id, name: id, type: "hidden", "data-origin": id, ref: externalRef, required: required, defaultValue: props.value || value || undefined }), _jsx(FloatingPortal, { preserveTabOrder: true, children: open ? (_jsx(FloatingFocusManager, { guards: true, returnFocus: false, context: context, initialFocus: -1, visuallyHiddenDismiss: true, children: _jsxs("ul", { ...getFloatingProps({
229
+ }), "data-value": value, "data-error": !!error, "data-name": id, "data-target": id, required: required, value: open ? shadow : label || value, "aria-autocomplete": "list", autoComplete: "off", className: css("input placeholder-input-mask group h-input-height w-full flex-1", "rounded-md bg-transparent px-input-x py-input-y text-foreground", "outline-none transition-colors focus:ring-2 focus:ring-inset focus:ring-primary", "group-error:text-danger group-error:placeholder-input-mask-error", "group-focus-within:border-primary group-hover:border-primary", props.className) }), _jsx("input", { id: id, name: id, type: "hidden", "data-origin": id, ref: externalRef, required: required, defaultValue: props.value || value || undefined }), _jsx(FloatingPortal, { preserveTabOrder: true, children: open ? (_jsx(FloatingFocusManager, { guards: true, returnFocus: false, context: context, initialFocus: -1, visuallyHiddenDismiss: true, children: _jsxs(motion.ul, { ...getFloatingProps({
225
230
  ref: refs.setFloating,
226
231
  style: {
227
232
  ...transitions.styles,
228
- position: strategy,
229
- left: (x ?? 0) + (!!value ? 36 : 25),
230
233
  top: y ?? 0,
234
+ position: strategy,
235
+ left: (x ?? 0) + (value ? 36 : 25),
231
236
  },
232
- }), "data-floating": "true", className: "isolate z-floating m-0 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", children: [list.length === 0 ? (_jsx("li", { role: "option", className: "w-full border-b border-tooltip-border last:border-transparent", children: _jsx("span", { className: "flex w-full justify-between p-2 text-left text-disabled", children: emptyMessage || translation.autocompleteEmpty }) })) : null, _jsx(Virtuoso, { ref: virtuoso, data: displayList, components: components, hidden: displayList.length === 0, className: "rounded-lg border-floating-border bg-floating-background p-0 text-foreground", style: { height: h }, itemContent: (i, option) => {
237
+ }), initial: false, "data-floating": "true", animate: { height: isEmpty ? "auto" : h }, className: "isolate z-floating m-0 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", children: [isEmpty ? (_jsx("li", { role: "option", className: "w-full border-b border-tooltip-border last:border-transparent", children: _jsx("span", { className: "flex w-full justify-between p-2 text-left text-disabled", children: emptyMessage || translation.autocompleteEmpty }) })) : null, _jsx(Virtuoso, { ref: virtuoso, hidden: isEmpty, data: displayList, style: { height: h }, components: components, className: "rounded-lg border-floating-border bg-floating-background p-0 text-foreground", itemContent: (i, option) => {
233
238
  const Label = option.Render ?? Frag;
234
239
  const active = value === option.value || value === option.label;
235
240
  const selected = index === i;
@@ -3,6 +3,7 @@ import { Override } from "../../types";
3
3
  export type CheckboxProps = Override<React.PropsWithChildren<React.ComponentProps<"input">>, {
4
4
  error?: string;
5
5
  asTask?: boolean;
6
+ loading?: boolean;
6
7
  container?: string;
7
8
  labelClassName?: string;
8
9
  size?: "medium" | "large";
@@ -1 +1 @@
1
- {"version":3,"file":"checkbox.d.ts","sourceRoot":"","sources":["../../../../src/components/form/checkbox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAE1C,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,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,IAAI,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC;CAC7B,CACJ,CAAC;AAEF,eAAO,MAAM,QAAQ,qGA6BpB,CAAC"}
1
+ {"version":3,"file":"checkbox.d.ts","sourceRoot":"","sources":["../../../../src/components/form/checkbox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAE1C,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,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,IAAI,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC;CAC7B,CACJ,CAAC;AAEF,eAAO,MAAM,QAAQ,qGAiCpB,CAAC"}
@@ -1,4 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { forwardRef } from "react";
3
3
  import { css } from "../../lib/dom";
4
- export const Checkbox = forwardRef(({ children, asTask = false, labelClassName, error, className = "", size, container, ...props }, ref) => (_jsxs("label", { "data-task": asTask, "data-component": "checkbox", "data-disabled": props.disabled, "aria-disabled": props.disabled, className: css("group flex w-fit flex-wrap items-center font-normal data-[disabled=true]:cursor-not-allowed", asTask ? "group-checkbox-checked:line-through" : "", container), children: [_jsx("input", { ...props, ref: ref, type: "checkbox", "data-task": asTask, className: css("form-checkbox mr-2 inline-block size-4 appearance-none rounded border-card-border bg-origin-border text-primary focus:ring-primary disabled:opacity-70 group-aria-disabled:cursor-not-allowed", className) }), children, _jsx("span", { "data-name": "checkbox-label", className: css("min-w-full flex-1 text-xs text-danger empty:mt-0 empty:hidden", labelClassName), children: error })] })));
4
+ export const Checkbox = forwardRef(({ children, asTask = false, labelClassName, loading, error, className = "", size, container, ...props }, ref) => {
5
+ const d = props.disabled || loading;
6
+ return (_jsxs("label", { "aria-disabled": d, "data-disabled": d, "data-task": asTask, "data-component": "checkbox", className: css("group flex w-fit flex-wrap items-center font-normal data-[disabled=true]:cursor-not-allowed", asTask ? "group-checkbox-checked:line-through" : "", container), children: [_jsx("input", { ...props, ref: ref, disabled: d, type: "checkbox", "data-task": asTask, className: css("form-checkbox mr-2 inline-block size-4 appearance-none rounded border-card-border bg-origin-border text-primary focus:ring-primary disabled:opacity-70 group-aria-disabled:cursor-not-allowed", className) }), children, _jsx("span", { "data-name": "checkbox-label", className: css("min-w-full flex-1 text-xs text-danger empty:mt-0 empty:hidden", labelClassName), children: error })] }));
7
+ });
@@ -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,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC,EAChF,UAAU,CACb,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,CAAC,SAAS,WAAW,EAAE,IAAI,SAAS,gBAAgB,GAAG,mBAAmB,EAAE,KAAK,SAAS,GAAG,EACxH,SAAS,OAAO,GAAG,UAAU,GAAG,OAAO,SAAS,EAChD,aAAa,OAAO,GAAG,UAAU,EACjC,cAAc,aAAa,CAAC,CAAC,EAAE,KAAK,CAAC,EACrC,WAAW,CAAC,EAAE,EAAE,IAAI,KAAK,MAAM,IAAI,4CAqGtC,CAAC"}
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,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC,EAChF,UAAU,CACb,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,CAAC,SAAS,WAAW,EAAE,IAAI,SAAS,gBAAgB,GAAG,mBAAmB,EAAE,KAAK,SAAS,GAAG,EACxH,SAAS,OAAO,GAAG,UAAU,GAAG,OAAO,SAAS,EAChD,aAAa,OAAO,GAAG,UAAU,EACjC,cAAc,aAAa,CAAC,CAAC,EAAE,KAAK,CAAC,EACrC,WAAW,CAAC,EAAE,EAAE,IAAI,KAAK,MAAM,IAAI,4CAuGtC,CAAC"}
@@ -4,7 +4,7 @@ import { forwardRef, useEffect, useRef } from "react";
4
4
  import { css, initializeInputDataset, mergeRefs } from "../../lib/dom";
5
5
  import { InputField } from "./input-field";
6
6
  export const createFreeText = (Element, elementName, defaultProps, register) => {
7
- const FreeText = forwardRef(({ info, left, next, error, right, container, rightLabel, interactive, optionalText, type = "text", labelClassName, feedback = null, hideLeft = false, ...props }, ref) => {
7
+ const FreeText = forwardRef(({ info, left, next, error, right, container, rightLabel, interactive, optionalText, type = "text", labelClassName, feedback = null, hideLeft = false, loading, ...props }, ref) => {
8
8
  const Render = Element;
9
9
  const id = props.id ?? props.name;
10
10
  const inputRef = useRef(null);
@@ -34,7 +34,7 @@ export const createFreeText = (Element, elementName, defaultProps, register) =>
34
34
  input.removeEventListener("keydown", goNextInputImpl);
35
35
  };
36
36
  }, []);
37
- return (_jsx(InputField, { ...defaultProps, info: info, left: left, error: error, right: right, form: props.form, name: props.name, feedback: feedback, hideLeft: hideLeft, title: props.title, container: container, rightLabel: rightLabel, disabled: props.disabled, interactive: interactive, required: props.required, componentName: elementName, id: props.name || props.id, optionalText: optionalText, labelClassName: labelClassName, placeholder: props.placeholder, children: _jsx(Render, { ...defaultProps, ...props, id: id, name: id, type: type, "data-next": next, "aria-busy": props.disabled, "aria-disabled": props.disabled, "aria-readonly": props.readOnly, ref: mergeRefs(ref, inputRef), className: css("input placeholder-input-mask group h-input-height w-full flex-1", "rounded-md bg-transparent px-input-x py-input-y text-foreground", "outline-none transition-colors focus:ring-2 focus:ring-inset focus:ring-primary", "group-error:text-danger group-error:placeholder-input-mask-error", "resize-y group-focus-within:border-primary group-hover:border-primary", "disabled:cursor-not-allowed disabled:text-disabled", props.className) }) }));
37
+ return (_jsx(InputField, { ...defaultProps, info: info, left: left, error: error, right: right, loading: loading, form: props.form, name: props.name, feedback: feedback, hideLeft: hideLeft, title: props.title, container: css(container, defaultProps.container), rightLabel: rightLabel, disabled: props.disabled, interactive: interactive, required: props.required, componentName: elementName, id: props.name || props.id, optionalText: optionalText, labelClassName: labelClassName, placeholder: props.placeholder, children: _jsx(Render, { ...defaultProps, ...props, id: id, name: id, type: type, "data-next": next, "aria-busy": props.disabled, "aria-disabled": props.disabled, "aria-readonly": props.readOnly, ref: mergeRefs(ref, inputRef), className: css("input placeholder-input-mask group h-input-height w-full flex-1", "rounded-md bg-transparent px-input-x py-input-y text-foreground", "outline-none transition-colors focus:ring-2 focus:ring-inset focus:ring-primary", "group-error:text-danger group-error:placeholder-input-mask-error", "resize-y group-focus-within:border-primary group-hover:border-primary", "disabled:cursor-not-allowed disabled:text-disabled", props.className) }) }));
38
38
  });
39
39
  return FreeText;
40
40
  };
@@ -11,6 +11,7 @@ export type FeedbackProps = React.PropsWithChildren<Partial<{
11
11
  }>>;
12
12
  export declare const InputFeedback: ({ reportStatus, hideLeft, className, info, children, title }: FeedbackProps) => import("react/jsx-runtime").JSX.Element;
13
13
  export type InputFieldProps<T extends "input" | "select" | "textarea"> = PolymorphicProps<Partial<Override<FeedbackProps, {
14
+ loading: boolean;
14
15
  componentName: string;
15
16
  info: Label;
16
17
  labelClassName: string;
@@ -1 +1 @@
1
- {"version":3,"file":"input-field.d.ts","sourceRoot":"","sources":["../../../../src/components/form/input-field.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAwB,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAK5E,OAAO,EAAE,KAAK,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAG1D,MAAM,MAAM,aAAa,GAAG,KAAK,CAAC,iBAAiB,CAC/C,OAAO,CAAC;IACJ,IAAI,EAAE,KAAK,CAAC;IACZ,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,OAAO,CAAC;CACzB,CAAC,CACL,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,8DAAsE,aAAa,4CA8ChH,CAAC;AAEF,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,OAAO,GAAG,QAAQ,GAAG,UAAU,IAAI,gBAAgB,CACrF,OAAO,CACH,QAAQ,CACJ,aAAa,EACb;IACI,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,KAAK,CAAC;IACZ,cAAc,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,OAAO,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,KAAK,CAAC;IACZ,QAAQ,EAAE,KAAK,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,KAAK,CAAC;IACb,UAAU,EAAE,KAAK,CAAC;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACvB,CACJ,CACJ,EACD,CAAC,CACJ,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,CAAC,CAAC,SAAS,OAAO,GAAG,QAAQ,GAAG,UAAU,EAAE,KAAK,EAAE,iBAAiB,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,YA6EpH,CAAC"}
1
+ {"version":3,"file":"input-field.d.ts","sourceRoot":"","sources":["../../../../src/components/form/input-field.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAwB,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAI5E,OAAO,EAAE,KAAK,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAG1D,MAAM,MAAM,aAAa,GAAG,KAAK,CAAC,iBAAiB,CAC/C,OAAO,CAAC;IACJ,IAAI,EAAE,KAAK,CAAC;IACZ,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,OAAO,CAAC;CACzB,CAAC,CACL,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,8DAAsE,aAAa,4CA8ChH,CAAC;AAEF,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,OAAO,GAAG,QAAQ,GAAG,UAAU,IAAI,gBAAgB,CACrF,OAAO,CACH,QAAQ,CACJ,aAAa,EACb;IACI,OAAO,EAAE,OAAO,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,KAAK,CAAC;IACZ,cAAc,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,OAAO,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,KAAK,CAAC;IACZ,QAAQ,EAAE,KAAK,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,KAAK,CAAC;IACb,UAAU,EAAE,KAAK,CAAC;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACvB,CACJ,CACJ,EACD,CAAC,CACJ,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,CAAC,CAAC,SAAS,OAAO,GAAG,QAAQ,GAAG,UAAU,EAAE,KAAK,EAAE,iBAAiB,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,YA6EpH,CAAC"}
@@ -6,12 +6,12 @@ import { useTranslations } from "../../hooks/use-translations";
6
6
  import { useTweaks } from "../../hooks/use-tweaks";
7
7
  import { css } from "../../lib/dom";
8
8
  import { Tooltip } from "../floating/tooltip";
9
- export const InputFeedback = ({ reportStatus, hideLeft = false, className, info, children, title }) => (_jsxs("div", { className: css("w-full justify-between", hideLeft && children === null ? "hidden" : "flex", className), children: [hideLeft ? null : (_jsxs("span", { className: "flex items-center gap-1 transition-colors group-focus-within:text-primary group-hover:text-primary group-disabled:text-disabled group-error:text-danger", children: [title, reportStatus || info ? (_jsxs("span", { className: "flex items-center justify-center gap-1", children: [info ? (_jsx(Tooltip, { as: "button", type: "button", "aria-description": info, title: _jsxs("span", { className: "cursor-help", children: [_jsx("span", { className: "sr-only", children: info }), _jsx(InfoIcon, { className: "aspect-square size-3", "aria-hidden": "true", size: 16, strokeWidth: 1, absoluteStrokeWidth: true })] }), children: _jsx("div", { className: "w-full max-w-48 whitespace-break-spaces break-words", children: info }) })) : null, reportStatus ? (_jsxs(Fragment, { children: [_jsx(CheckCircle, { className: "hidden aspect-square size-3 opacity-0 transition-opacity group-assert:block group-assert:text-success group-assert:opacity-100", "aria-hidden": "true", size: 16, strokeWidth: 1, absoluteStrokeWidth: true }), _jsx(XCircle, { className: "hidden aspect-square size-3 opacity-0 transition-opacity group-error:block group-error:opacity-100", "aria-hidden": "true", size: 16, strokeWidth: 1, absoluteStrokeWidth: true })] })) : null] })) : null] })), children] }));
9
+ export const InputFeedback = ({ reportStatus, hideLeft = false, className, info, children, title }) => (_jsxs("span", { className: css("w-full justify-between", hideLeft && children === null ? "hidden" : "flex", className), children: [hideLeft ? null : (_jsxs("span", { className: "flex items-center gap-1 transition-colors group-focus-within:text-primary group-hover:text-primary group-disabled:text-disabled group-error:text-danger", children: [title, reportStatus || info ? (_jsxs("span", { className: "flex items-center justify-center gap-1", children: [info ? (_jsx(Tooltip, { as: "button", type: "button", "aria-description": info, title: _jsxs("span", { className: "cursor-help", children: [_jsx("span", { className: "sr-only", children: info }), _jsx(InfoIcon, { className: "aspect-square size-3", "aria-hidden": "true", size: 16, strokeWidth: 1, absoluteStrokeWidth: true })] }), children: _jsx("div", { className: "w-full max-w-48 whitespace-break-spaces break-words", children: info }) })) : null, reportStatus ? (_jsxs("span", { className: "flex h-3 min-w-6 items-center", 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] }));
10
10
  export const InputField = forwardRef(({ optionalText: _optionalText, left, rightLabel, container, feedback, interactive, right, info, children, error, form, id, labelClassName = "", name, title, componentName, placeholder, hideLeft = false, required, disabled, reportStatus, }, ref) => {
11
11
  const tweaks = useTweaks();
12
12
  const reportStatusDefault = reportStatus !== undefined ? reportStatus : tweaks.input.iconFeedback;
13
13
  const ID = id ?? name;
14
14
  const translation = useTranslations();
15
15
  const optionalText = _optionalText ?? translation.inputOptionalLabel;
16
- return (_jsxs("fieldset", { ref: ref, form: form, disabled: disabled, "data-error": !!error, "aria-disabled": disabled, "data-component": componentName, "data-interactive": !!interactive, className: css("group grid min-h-0 min-w-0 grid-cols-1 items-baseline", container), children: [_jsxs("label", { form: form, htmlFor: ID, className: "inline-flex cursor-text flex-row flex-wrap justify-between gap-1 text-sm transition-colors empty:hidden group-disabled:cursor-not-allowed group-error:text-danger", children: [_jsx(InputFeedback, { info: info, hideLeft: hideLeft, reportStatus: reportStatusDefault, title: title, placeholder: placeholder, children: optionalText || rightLabel ? (_jsxs(Fragment, { children: [!required ? (_jsx("span", { "aria-disabled": disabled, className: "text-opacity-70 aria-disabled:text-disabled", children: optionalText })) : null, rightLabel ? _jsx(Fragment, { children: rightLabel }) : null] })) : null }), _jsxs("div", { className: `group relative flex w-full flex-row flex-nowrap items-center gap-x-2 gap-y-1 rounded-md border border-input-border bg-transparent transition-colors group-hover:border-primary group-disabled:border-disabled group-error:border-danger ${labelClassName}`, children: [left ? _jsx("span", { className: "flex flex-nowrap gap-1 whitespace-nowrap pl-2", children: left }) : null, children, right ? _jsx("span", { className: "flex flex-nowrap gap-2 whitespace-nowrap pr-2", children: right }) : null] })] }), _jsx("p", { className: "mt-input-gap hidden flex-shrink-0 flex-grow-0 whitespace-pre-wrap text-wrap text-xs empty:mt-0 empty:hidden group-has-[input:not(:focus):invalid[data-initialized=true]]:inline-block group-error:inline-block group-error:text-danger", children: error }), _jsx("p", { className: "mt-input-gap text-xs empty:mt-0 empty:hidden group-has-[input:not(:focus):valid[data-initialized=true]]:block group-assert:block group-error:hidden", children: feedback })] }));
16
+ return (_jsxs("fieldset", { ref: ref, form: form, disabled: disabled, "data-error": !!error, "aria-disabled": disabled, "data-component": componentName, "data-interactive": !!interactive, className: css("group flex min-h-0 max-w-full min-w-0 flex-col items-start", container), children: [_jsxs("label", { form: form, htmlFor: ID, className: "text-field-label max-w-full w-full relative inline-flex cursor-text flex-row flex-wrap justify-between gap-1 text-sm transition-colors empty:hidden group-disabled:cursor-not-allowed group-error:text-danger", children: [_jsx(InputFeedback, { info: info, hideLeft: hideLeft, reportStatus: reportStatusDefault, title: title, placeholder: placeholder, children: optionalText || rightLabel ? (_jsxs(Fragment, { children: [!required ? (_jsx("span", { "aria-disabled": disabled, className: "text-opacity-70 aria-disabled:text-disabled", children: optionalText })) : null, rightLabel ? _jsx(Fragment, { children: rightLabel }) : null] })) : null }), _jsxs("div", { className: `group relative flex w-full flex-row flex-nowrap items-center gap-x-2 gap-y-1 rounded-md border border-input-border bg-transparent transition-colors group-hover:border-primary group-disabled:border-disabled group-error:border-danger ${labelClassName}`, children: [left ? _jsx("span", { className: "flex flex-nowrap gap-1 whitespace-nowrap pl-2", children: left }) : null, children, right ? _jsx("span", { className: "flex flex-nowrap gap-2 whitespace-nowrap pr-2", children: right }) : null] })] }), _jsx("p", { className: "mt-input-gap hidden whitespace-pre-wrap text-wrap text-xs empty:mt-0 empty:hidden group-has-[input:not(:focus):invalid[data-initialized=true]]:flex group-error:flex group-error:text-danger", children: error }), _jsx("p", { className: "mt-input-gap text-xs empty:mt-0 empty:hidden group-has-[input:not(:focus):valid[data-initialized=true]]:block group-assert:block group-error:hidden", children: feedback })] }));
17
17
  });
@@ -1 +1 @@
1
- {"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../../../src/components/form/input.tsx"],"names":[],"mappings":"AACA,OAAkB,EACd,QAAQ,EACR,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,OAAO,EACP,gBAAgB,EAChB,iBAAiB,EACjB,YAAY,EACf,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAkB,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5D,mBAAmB,gBAAgB,CAAC;AAEpC,MAAM,MAAM,UAAU,GAAG,aAAa,CAClC,OAAO,EACL,CAAC;IACG,IAAI,CAAC,EAAE,iBAAiB,CAAC;IACzB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,YAAY,GAAG,SAAS,CAAC;CACvC,GAAG,kBAAkB,CAAC,GACvB,CAAC;IACG,IAAI,CAAC,EAAE,gBAAgB,CAAC;IACxB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACxB,GAAG,iBAAiB,CAAC,GACtB,CAAC;IACG,IAAI,CAAC,EAAE,QAAQ,GAAG,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,MAAM,KAAK,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,GAAG,QAAQ,CAAC,CAAC;IAC9F,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACxB,GAAG,YAAY,CAAC,CACtB,CAAC;AAEF,eAAO,MAAM,KAAK,oEAA8F,CAAC"}
1
+ {"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../../../src/components/form/input.tsx"],"names":[],"mappings":"AACA,OAAkB,EACd,QAAQ,EACR,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,OAAO,EACP,gBAAgB,EAChB,iBAAiB,EACjB,YAAY,EACf,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAkB,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5D,mBAAmB,gBAAgB,CAAC;AAEpC,MAAM,MAAM,UAAU,GAAG,aAAa,CAClC,OAAO,EACL,CAAC;IACG,IAAI,CAAC,EAAE,iBAAiB,CAAC;IACzB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,YAAY,GAAG,SAAS,CAAC;CACvC,GAAG,kBAAkB,CAAC,GACvB,CAAC;IACG,IAAI,CAAC,EAAE,gBAAgB,CAAC;IACxB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACxB,GAAG,iBAAiB,CAAC,GACtB,CAAC;IACG,IAAI,CAAC,EAAE,QAAQ,GAAG,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,MAAM,KAAK,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,GAAG,QAAQ,CAAC,CAAC;IAC9F,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACxB,GAAG,YAAY,CAAC,CACtB,CAAC;AAEF,eAAO,MAAM,KAAK,oEAEhB,CAAC"}
@@ -1,4 +1,6 @@
1
1
  "use client";
2
2
  import MaskInput from "the-mask-input";
3
3
  import { createFreeText } from "./free-text";
4
- export const Input = createFreeText(MaskInput, "input", { type: "text" });
4
+ export const Input = createFreeText(MaskInput, "input", {
5
+ type: "text",
6
+ });
@@ -0,0 +1,19 @@
1
+ import React from "react";
2
+ import { Label, Override } from "../../types";
3
+ import { InputFieldProps } from "./input-field";
4
+ import { type OptionProps } from "./select";
5
+ export type MultiSelectItemProps = OptionProps & {
6
+ Render?: React.FC<OptionProps>;
7
+ };
8
+ export type MultiSelectProps = Override<InputFieldProps<"input">, {
9
+ title?: string;
10
+ value?: string[];
11
+ emptyMessage?: Label;
12
+ selectedLabel?: string;
13
+ defaultValue?: string[];
14
+ dynamicOption?: boolean;
15
+ options: MultiSelectItemProps[];
16
+ onChangeOptions?: (options: string[]) => void;
17
+ }>;
18
+ export declare const MultiSelect: React.ForwardRefExoticComponent<Omit<MultiSelectProps, "ref"> & React.RefAttributes<HTMLInputElement>>;
19
+ //# sourceMappingURL=multi-select.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"multi-select.d.ts","sourceRoot":"","sources":["../../../../src/components/form/multi-select.tsx"],"names":[],"mappings":"AAiBA,OAAO,KAA6F,MAAM,OAAO,CAAC;AAOlH,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAG9C,OAAO,EAAc,eAAe,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C,MAAM,MAAM,oBAAoB,GAAG,WAAW,GAAG;IAAE,MAAM,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAAC,CAAA;CAAE,CAAC;AAEpF,MAAM,MAAM,gBAAgB,GAAG,QAAQ,CACnC,eAAe,CAAC,OAAO,CAAC,EACxB;IACI,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,YAAY,CAAC,EAAE,KAAK,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,OAAO,EAAE,oBAAoB,EAAE,CAAC;IAChC,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;CACjD,CACJ,CAAC;AA0DF,eAAO,MAAM,WAAW,wGAkYvB,CAAC"}