@g4rcez/components 0.0.43 → 0.0.45

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 (218) hide show
  1. package/dist/index.css +1 -1
  2. package/dist/index.js +21 -21
  3. package/dist/index.js.map +1 -1
  4. package/dist/index.mjs +1624 -1524
  5. package/dist/index.mjs.map +1 -1
  6. package/dist/index.umd.js +41 -41
  7. package/dist/index.umd.js.map +1 -1
  8. package/dist/preset/preset.tailwind.d.ts +2 -2
  9. package/dist/preset/preset.tailwind.d.ts.map +1 -1
  10. package/dist/preset/preset.tailwind.js +5 -5
  11. package/dist/preset/src/styles/dark.d.ts.map +1 -1
  12. package/dist/preset/src/styles/dark.js +37 -0
  13. package/dist/preset/src/styles/light.d.ts.map +1 -1
  14. package/dist/preset/src/styles/light.js +37 -0
  15. package/dist/preset/src/styles/theme.types.d.ts +5 -0
  16. package/dist/preset/src/styles/theme.types.d.ts.map +1 -1
  17. package/dist/preset.tailwind.d.ts +2 -2
  18. package/dist/preset.tailwind.d.ts.map +1 -1
  19. package/dist/preset.tailwind.js +5 -5
  20. package/dist/src/components/core/button.d.ts +1 -1
  21. package/dist/src/components/core/button.d.ts.map +1 -1
  22. package/dist/src/components/core/button.js +10 -4
  23. package/dist/src/components/display/alert.d.ts +4 -3
  24. package/dist/src/components/display/alert.d.ts.map +1 -1
  25. package/dist/src/components/display/alert.js +12 -9
  26. package/dist/src/components/form/autocomplete.d.ts +1 -2
  27. package/dist/src/components/form/autocomplete.d.ts.map +1 -1
  28. package/dist/src/components/form/autocomplete.js +4 -3
  29. package/dist/src/components/form/input-field.js +1 -1
  30. package/dist/src/hooks/use-form.d.ts +2 -7
  31. package/dist/src/hooks/use-form.d.ts.map +1 -1
  32. package/dist/src/hooks/use-form.js +13 -3
  33. package/dist/src/styles/dark.d.ts.map +1 -1
  34. package/dist/src/styles/dark.js +37 -0
  35. package/dist/src/styles/light.d.ts.map +1 -1
  36. package/dist/src/styles/light.js +37 -0
  37. package/dist/src/styles/theme.types.d.ts +5 -0
  38. package/dist/src/styles/theme.types.d.ts.map +1 -1
  39. package/package.json +8 -2
  40. package/dist/components/core/button.d.ts +0 -16
  41. package/dist/components/core/button.d.ts.map +0 -1
  42. package/dist/components/core/button.js +0 -43
  43. package/dist/components/core/polymorph.d.ts +0 -10
  44. package/dist/components/core/polymorph.d.ts.map +0 -1
  45. package/dist/components/core/polymorph.js +0 -8
  46. package/dist/components/core/resizable.d.ts +0 -3
  47. package/dist/components/core/resizable.d.ts.map +0 -1
  48. package/dist/components/core/resizable.js +0 -50
  49. package/dist/components/core/tag.d.ts +0 -19
  50. package/dist/components/core/tag.d.ts.map +0 -1
  51. package/dist/components/core/tag.js +0 -45
  52. package/dist/components/display/alert.d.ts +0 -19
  53. package/dist/components/display/alert.d.ts.map +0 -1
  54. package/dist/components/display/alert.js +0 -34
  55. package/dist/components/display/calendar.d.ts +0 -42
  56. package/dist/components/display/calendar.d.ts.map +0 -1
  57. package/dist/components/display/calendar.js +0 -215
  58. package/dist/components/display/card.d.ts +0 -10
  59. package/dist/components/display/card.d.ts.map +0 -1
  60. package/dist/components/display/card.js +0 -8
  61. package/dist/components/display/list.d.ts +0 -16
  62. package/dist/components/display/list.d.ts.map +0 -1
  63. package/dist/components/display/list.js +0 -31
  64. package/dist/components/display/notifications.d.ts +0 -25
  65. package/dist/components/display/notifications.d.ts.map +0 -1
  66. package/dist/components/display/notifications.js +0 -70
  67. package/dist/components/display/stats.d.ts +0 -10
  68. package/dist/components/display/stats.d.ts.map +0 -1
  69. package/dist/components/display/stats.js +0 -5
  70. package/dist/components/display/tabs.d.ts +0 -20
  71. package/dist/components/display/tabs.d.ts.map +0 -1
  72. package/dist/components/display/tabs.js +0 -67
  73. package/dist/components/display/timeline.d.ts +0 -32
  74. package/dist/components/display/timeline.d.ts.map +0 -1
  75. package/dist/components/display/timeline.js +0 -21
  76. package/dist/components/floating/dropdown.d.ts +0 -14
  77. package/dist/components/floating/dropdown.d.ts.map +0 -1
  78. package/dist/components/floating/dropdown.js +0 -39
  79. package/dist/components/floating/expand.d.ts +0 -9
  80. package/dist/components/floating/expand.d.ts.map +0 -1
  81. package/dist/components/floating/expand.js +0 -25
  82. package/dist/components/floating/menu.d.ts +0 -52
  83. package/dist/components/floating/menu.d.ts.map +0 -1
  84. package/dist/components/floating/menu.js +0 -126
  85. package/dist/components/floating/modal.d.ts +0 -19
  86. package/dist/components/floating/modal.d.ts.map +0 -1
  87. package/dist/components/floating/modal.js +0 -102
  88. package/dist/components/floating/toolbar.d.ts +0 -6
  89. package/dist/components/floating/toolbar.d.ts.map +0 -1
  90. package/dist/components/floating/toolbar.js +0 -4
  91. package/dist/components/floating/tooltip.d.ts +0 -12
  92. package/dist/components/floating/tooltip.d.ts.map +0 -1
  93. package/dist/components/floating/tooltip.js +0 -28
  94. package/dist/components/form/autocomplete.d.ts +0 -17
  95. package/dist/components/form/autocomplete.d.ts.map +0 -1
  96. package/dist/components/form/autocomplete.js +0 -152
  97. package/dist/components/form/checkbox.d.ts +0 -11
  98. package/dist/components/form/checkbox.d.ts.map +0 -1
  99. package/dist/components/form/checkbox.js +0 -8
  100. package/dist/components/form/date-picker.d.ts +0 -61
  101. package/dist/components/form/date-picker.d.ts.map +0 -1
  102. package/dist/components/form/date-picker.js +0 -78
  103. package/dist/components/form/file-upload.d.ts +0 -12
  104. package/dist/components/form/file-upload.d.ts.map +0 -1
  105. package/dist/components/form/file-upload.js +0 -62
  106. package/dist/components/form/form.d.ts +0 -4
  107. package/dist/components/form/form.d.ts.map +0 -1
  108. package/dist/components/form/form.js +0 -28
  109. package/dist/components/form/input-field.d.ts +0 -30
  110. package/dist/components/form/input-field.d.ts.map +0 -1
  111. package/dist/components/form/input-field.js +0 -14
  112. package/dist/components/form/input.d.ts +0 -9
  113. package/dist/components/form/input.d.ts.map +0 -1
  114. package/dist/components/form/input.js +0 -38
  115. package/dist/components/form/radiobox.d.ts +0 -7
  116. package/dist/components/form/radiobox.d.ts.map +0 -1
  117. package/dist/components/form/radiobox.js +0 -7
  118. package/dist/components/form/select.d.ts +0 -13
  119. package/dist/components/form/select.d.ts.map +0 -1
  120. package/dist/components/form/select.js +0 -33
  121. package/dist/components/form/switch.d.ts +0 -8
  122. package/dist/components/form/switch.d.ts.map +0 -1
  123. package/dist/components/form/switch.js +0 -39
  124. package/dist/components/form/task-list.d.ts +0 -3
  125. package/dist/components/form/task-list.d.ts.map +0 -1
  126. package/dist/components/form/task-list.js +0 -26
  127. package/dist/components/form/transfer-list.d.ts +0 -14
  128. package/dist/components/form/transfer-list.d.ts.map +0 -1
  129. package/dist/components/form/transfer-list.js +0 -21
  130. package/dist/components/index.d.ts +0 -30
  131. package/dist/components/index.d.ts.map +0 -1
  132. package/dist/components/index.js +0 -29
  133. package/dist/components/table/filter.d.ts +0 -41
  134. package/dist/components/table/filter.d.ts.map +0 -1
  135. package/dist/components/table/filter.js +0 -91
  136. package/dist/components/table/group.d.ts +0 -17
  137. package/dist/components/table/group.d.ts.map +0 -1
  138. package/dist/components/table/group.js +0 -43
  139. package/dist/components/table/index.d.ts +0 -38
  140. package/dist/components/table/index.d.ts.map +0 -1
  141. package/dist/components/table/index.js +0 -145
  142. package/dist/components/table/metadata.d.ts +0 -3
  143. package/dist/components/table/metadata.d.ts.map +0 -1
  144. package/dist/components/table/metadata.js +0 -10
  145. package/dist/components/table/pagination.d.ts +0 -3
  146. package/dist/components/table/pagination.d.ts.map +0 -1
  147. package/dist/components/table/pagination.js +0 -43
  148. package/dist/components/table/sort.d.ts +0 -28
  149. package/dist/components/table/sort.d.ts.map +0 -1
  150. package/dist/components/table/sort.js +0 -79
  151. package/dist/components/table/table-lib.d.ts +0 -122
  152. package/dist/components/table/table-lib.d.ts.map +0 -1
  153. package/dist/components/table/table-lib.js +0 -51
  154. package/dist/components/table/thead.d.ts +0 -8
  155. package/dist/components/table/thead.d.ts.map +0 -1
  156. package/dist/components/table/thead.js +0 -29
  157. package/dist/constants.d.ts +0 -3
  158. package/dist/constants.d.ts.map +0 -1
  159. package/dist/constants.js +0 -2
  160. package/dist/hooks/use-callback-ref.d.ts +0 -3
  161. package/dist/hooks/use-callback-ref.d.ts.map +0 -1
  162. package/dist/hooks/use-callback-ref.js +0 -8
  163. package/dist/hooks/use-click-outside.d.ts +0 -3
  164. package/dist/hooks/use-click-outside.d.ts.map +0 -1
  165. package/dist/hooks/use-click-outside.js +0 -17
  166. package/dist/hooks/use-debounce.d.ts +0 -4
  167. package/dist/hooks/use-debounce.d.ts.map +0 -1
  168. package/dist/hooks/use-debounce.js +0 -12
  169. package/dist/hooks/use-form.d.ts +0 -41
  170. package/dist/hooks/use-form.d.ts.map +0 -1
  171. package/dist/hooks/use-form.js +0 -169
  172. package/dist/hooks/use-hover.d.ts +0 -3
  173. package/dist/hooks/use-hover.d.ts.map +0 -1
  174. package/dist/hooks/use-hover.js +0 -18
  175. package/dist/hooks/use-media-query.d.ts +0 -2
  176. package/dist/hooks/use-media-query.d.ts.map +0 -1
  177. package/dist/hooks/use-media-query.js +0 -25
  178. package/dist/hooks/use-mutable-state.d.ts +0 -2
  179. package/dist/hooks/use-mutable-state.d.ts.map +0 -1
  180. package/dist/hooks/use-mutable-state.js +0 -8
  181. package/dist/hooks/use-on-event.d.ts +0 -4
  182. package/dist/hooks/use-on-event.d.ts.map +0 -1
  183. package/dist/hooks/use-on-event.js +0 -7
  184. package/dist/hooks/use-parent.d.ts +0 -3
  185. package/dist/hooks/use-parent.d.ts.map +0 -1
  186. package/dist/hooks/use-parent.js +0 -21
  187. package/dist/hooks/use-previous.d.ts +0 -2
  188. package/dist/hooks/use-previous.d.ts.map +0 -1
  189. package/dist/hooks/use-previous.js +0 -8
  190. package/dist/hooks/use-reactive.d.ts +0 -2
  191. package/dist/hooks/use-reactive.d.ts.map +0 -1
  192. package/dist/hooks/use-reactive.js +0 -8
  193. package/dist/hooks/use-stable-ref.d.ts +0 -2
  194. package/dist/hooks/use-stable-ref.d.ts.map +0 -1
  195. package/dist/hooks/use-stable-ref.js +0 -8
  196. package/dist/hooks/use-translate-context.d.ts +0 -99
  197. package/dist/hooks/use-translate-context.d.ts.map +0 -1
  198. package/dist/hooks/use-translate-context.js +0 -53
  199. package/dist/index.d.ts +0 -12
  200. package/dist/index.d.ts.map +0 -1
  201. package/dist/lib/dom.d.ts +0 -9
  202. package/dist/lib/dom.d.ts.map +0 -1
  203. package/dist/lib/dom.js +0 -34
  204. package/dist/lib/fns.d.ts +0 -7
  205. package/dist/lib/fns.d.ts.map +0 -1
  206. package/dist/lib/fns.js +0 -26
  207. package/dist/styles/design-tokens.d.ts +0 -19
  208. package/dist/styles/design-tokens.d.ts.map +0 -1
  209. package/dist/styles/design-tokens.js +0 -52
  210. package/dist/styles/theme.d.ts +0 -4
  211. package/dist/styles/theme.d.ts.map +0 -1
  212. package/dist/styles/theme.js +0 -294
  213. package/dist/styles/theme.types.d.ts +0 -101
  214. package/dist/styles/theme.types.d.ts.map +0 -1
  215. package/dist/styles/theme.types.js +0 -1
  216. package/dist/types.d.ts +0 -10
  217. package/dist/types.d.ts.map +0 -1
  218. package/dist/types.js +0 -1
@@ -1,102 +0,0 @@
1
- "use client";
2
- import { __rest } from "tslib";
3
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
4
- import { FloatingFocusManager, FloatingOverlay, FloatingPortal, useClick, useDismiss, useFloating, useInteractions, useRole, } from "@floating-ui/react";
5
- import { Slot } from "@radix-ui/react-slot";
6
- import { cva } from "class-variance-authority";
7
- import { AnimatePresence, motion, useMotionValue } from "framer-motion";
8
- import { XIcon } from "lucide-react";
9
- import { Fragment, useId } from "react";
10
- import { useMediaQuery } from "../../hooks/use-media-query";
11
- import { css } from "../../lib/dom";
12
- const animationDuration = "600ms";
13
- const drawerLeft = {
14
- initial: { translateX: ["-30%", "0%"], opacity: 0.8, animationDuration },
15
- enter: { translateX: ["-30%", "0%"], opacity: 1, animationDuration },
16
- exit: { translateX: ["0%", "-30%"], opacity: 0, animationDuration },
17
- };
18
- const drawerRight = {
19
- initial: { translateX: ["30%", "0%"], opacity: 0.8 },
20
- enter: { translateX: "0%", opacity: 1, animationDuration },
21
- exit: { translateX: ["0%", "30%"], opacity: 0, animationDuration },
22
- };
23
- const animations = {
24
- drawer: (type) => (type === "left" ? drawerLeft : drawerRight),
25
- sheet: {
26
- initial: { opacity: 0.5, translateY: "25%", animationDuration, originY: "bottom" },
27
- enter: { opacity: 1, translateY: "0%", animationDuration, originY: "bottom" },
28
- exit: { opacity: 0.1, translateY: "50%", animationDuration, originY: "bottom" },
29
- },
30
- dialog: {
31
- initial: { opacity: 0, scale: 0.95, animationDuration },
32
- enter: { opacity: 1, scale: [1.05, 1], animationDuration },
33
- exit: { opacity: 0, scale: 0.97, animationDuration },
34
- },
35
- };
36
- const variants = cva("isolate 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", {
37
- variants: {
38
- type: {
39
- drawer: "max-h-screen max-w-[90%] absolute w-fit h-screen min-h-0",
40
- dialog: "max-h-[calc(100lvh-10%)] relative container h-min rounded-lg py-4",
41
- sheet: "w-screen absolute bottom-0 h-[85vh] max-h-[85vh] max-h-[85svh] pt-6 pb-4 rounded-t-lg",
42
- },
43
- position: {
44
- none: "",
45
- right: "py-4 absolute right-0 top-0 rounded-l-lg",
46
- left: "py-4 absolute left-0 top-0 rounded-r-lg",
47
- },
48
- },
49
- defaultVariants: { position: "right", type: "dialog" },
50
- });
51
- const dragConstraints = { top: 0, left: 0, right: 0, bottom: -1 };
52
- const calculateClose = (n) => n * 0.62;
53
- const Draggable = (props) => {
54
- const onDrag = (_, info) => {
55
- if (props.parent.current) {
56
- if (!props.sheet) {
57
- const div = props.parent.current;
58
- const v = props.value.get() || div.getBoundingClientRect().width;
59
- const delta = props.position === "right" ? -info.delta.x : info.delta.x;
60
- return props.value.set(Math.abs(v + delta));
61
- }
62
- const div = props.parent.current;
63
- const rect = div.getBoundingClientRect();
64
- const v = props.value.get() || rect.height;
65
- const result = Math.abs(v - info.delta.y);
66
- const screenHeightToClose = calculateClose(window.outerHeight);
67
- if (result < screenHeightToClose) {
68
- props.onChange(false);
69
- return setTimeout(() => props.value.set(window.outerHeight), 350);
70
- }
71
- return props.value.set(result);
72
- }
73
- };
74
- return (_jsx(motion.div, { draggable: true, dragMomentum: true, dragListener: true, dragPropagation: true, onDrag: onDrag, animate: false, initial: false, dragElastic: 0, dragDirectionLock: true, dragSnapToOrigin: true, drag: props.sheet ? "y" : "x", dragConstraints: dragConstraints, whileDrag: { cursor: "grabbing" }, className: css("absolute rounded-lg", props.sheet ? "cursor-row-resize" : "cursor-col-resize bg-floating-border", props.sheet
75
- ? "top-1 flex h-3 w-full justify-center py-2"
76
- : props.position === "left"
77
- ? "right-5 top-1/2 h-10 w-2"
78
- : "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
- const positions = { drawer: "right", sheet: "none", dialog: "none" };
81
- export const Modal = (_a) => {
82
- var { type: _type = "dialog", resizer = true, overlayClickClose = false, forceType = false, closable = true } = _a, props = __rest(_a, ["type", "resizer", "overlayClickClose", "forceType", "closable"]);
83
- const headingId = useId();
84
- const descriptionId = useId();
85
- const isDesktop = useMediaQuery("(min-width: 64rem)");
86
- const useResizer = _type !== "dialog";
87
- const position = isDesktop ? (_type === "drawer" ? props.position : positions[_type]) : forceType ? positions[_type] : positions.sheet;
88
- const func = isDesktop ? animations[_type] : forceType ? animations[_type] : animations.sheet;
89
- const animation = typeof func === "function" ? func(position) : func;
90
- const type = isDesktop ? _type : forceType ? _type : "sheet";
91
- const { refs, context } = useFloating({ open: props.open, onOpenChange: props.onChange });
92
- const click = useClick(context);
93
- const role = useRole(context);
94
- const dismiss = useDismiss(context, { escapeKey: true, referencePress: true, outsidePress: overlayClickClose });
95
- const { getReferenceProps, getFloatingProps } = useInteractions([click, role, dismiss]);
96
- const Trigger = props.trigger;
97
- const value = useMotionValue(undefined);
98
- const onClose = () => props.onChange(false);
99
- return (_jsxs(Fragment, { children: [props.trigger ? (_jsx(Fragment, { children: props.asChild ? (_jsx(Slot, Object.assign({ ref: refs.setReference }, getReferenceProps({
100
- layoutId: props.layoutId,
101
- }), { children: Trigger }))) : (_jsx(motion.button, Object.assign({ ref: refs.setReference }, getReferenceProps(), { layoutId: props.layoutId, type: "button", children: Trigger }))) })) : null, _jsx(FloatingPortal, { children: _jsx(AnimatePresence, { presenceAffectsLayout: true, children: props.open ? (_jsx(FloatingOverlay, { lockScroll: true, className: `inset-0 isolate z-overlay h-[100dvh] !overflow-clip bg-floating-overlay/70 ${type === "drawer" ? "" : "grid items-end justify-center lg:items-center"}`, children: _jsx(FloatingFocusManager, { visuallyHiddenDismiss: true, modal: true, closeOnFocusOut: true, context: context, children: _jsxs(motion.div, Object.assign({ animate: "enter", "aria-describedby": descriptionId, "aria-labelledby": headingId, className: variants({ position, type }), exit: "exit", layoutId: props.layoutId, initial: "initial", ref: refs.setFloating, style: type === "drawer" ? { width: value } : { height: value }, variants: animation }, getFloatingProps(), { children: [props.title ? (_jsx("header", { className: "relative w-full", children: props.title ? (_jsx("h2", { className: "border-b border-floating-border px-8 pb-2 text-3xl font-medium leading-relaxed", children: props.title })) : null })) : null, _jsx("section", { className: "flex-1 overflow-y-auto px-8 py-1", children: props.children }), props.footer ? (_jsx("footer", { className: "w-full border-t border-floating-border px-8 pt-4", children: props.footer })) : null, closable ? (_jsx("nav", { className: "absolute right-4 top-1 z-floating", children: _jsx("button", { type: "button", onClick: onClose, className: "p-1 opacity-70 transition-colors hover:text-danger hover:opacity-100 focus:text-danger", children: _jsx(XIcon, {}) }) })) : null, useResizer && resizer ? (_jsx(Draggable, { onChange: props.onChange, parent: refs.floating, position: position, sheet: type === "sheet", value: value })) : null] })) }) })) : null }) })] }));
102
- };
@@ -1,6 +0,0 @@
1
- import { PropsWithChildren } from "react";
2
- export type ToolbarProps = {
3
- root?: HTMLElement;
4
- };
5
- export declare const Toolbar: (props: PropsWithChildren<ToolbarProps>) => import("react/jsx-runtime").JSX.Element;
6
- //# sourceMappingURL=toolbar.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"toolbar.d.ts","sourceRoot":"","sources":["../../../src/components/floating/toolbar.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE1C,MAAM,MAAM,YAAY,GAAG;IACvB,IAAI,CAAC,EAAE,WAAW,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,OAAO,UAAW,iBAAiB,CAAC,YAAY,CAAC,4CAI7D,CAAC"}
@@ -1,4 +0,0 @@
1
- "use client";
2
- import { jsx as _jsx } from "react/jsx-runtime";
3
- import { motion } from "framer-motion";
4
- export const Toolbar = (props) => (_jsx(motion.div, { className: "sticky bottom-4 flex items-center justify-center rounded-lg border border-card-border bg-background p-4", children: props.children }));
@@ -1,12 +0,0 @@
1
- import { type Placement } from "@floating-ui/react";
2
- import React from "react";
3
- import { PolymorphicProps } from "../../components/core/polymorph";
4
- import { ComponentLike, Label, Override } from "../../types";
5
- export type TooltipProps<T extends ComponentLike = "span"> = Override<PolymorphicProps<React.ComponentProps<T>, T>, {
6
- title: Label;
7
- enabled?: boolean;
8
- placement?: Placement;
9
- followCursor?: boolean;
10
- }>;
11
- export declare const Tooltip: <T extends ComponentLike = "span">({ children, followCursor, placement, enabled, as, title, ...props }: TooltipProps<T>) => import("react/jsx-runtime").JSX.Element;
12
- //# sourceMappingURL=tooltip.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tooltip.d.ts","sourceRoot":"","sources":["../../../src/components/floating/tooltip.tsx"],"names":[],"mappings":"AACA,OAAO,EAOH,KAAK,SAAS,EASjB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAqC,MAAM,OAAO,CAAC;AAC1D,OAAO,EAAa,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAE9E,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE7D,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,aAAa,GAAG,MAAM,IAAI,QAAQ,CACjE,gBAAgB,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAC5C;IACI,KAAK,EAAE,KAAK,CAAC;IACb,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,YAAY,CAAC,EAAE,OAAO,CAAC;CAC1B,CACJ,CAAC;AAEF,eAAO,MAAM,OAAO,GAAI,CAAC,SAAS,aAAa,gFAAwF,YAAY,CAAC,CAAC,CAAC,4CAuCrJ,CAAC"}
@@ -1,28 +0,0 @@
1
- "use client";
2
- import { __rest } from "tslib";
3
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
4
- import { arrow, autoUpdate, flip, FloatingArrow, FloatingPortal, offset, shift, useClientPoint, useDismiss, useFloating, useFocus, useHover, useInteractions, useRole, } from "@floating-ui/react";
5
- import { Fragment, useRef, useState } from "react";
6
- import { Polymorph } from "../../components/core/polymorph";
7
- import { FLOATING_DELAY } from "../../constants";
8
- export const Tooltip = (_a) => {
9
- var { children, followCursor = false, placement, enabled, as, title } = _a, props = __rest(_a, ["children", "followCursor", "placement", "enabled", "as", "title"]);
10
- const [open, setOpen] = useState(false);
11
- const arrowRef = useRef(null);
12
- const Component = as || "span";
13
- const { refs, floatingStyles, context } = useFloating({
14
- open,
15
- placement,
16
- transform: true,
17
- onOpenChange: setOpen,
18
- whileElementsMounted: autoUpdate,
19
- middleware: [offset(5), flip({ fallbackAxisSideDirection: "start" }), shift(), arrow({ element: arrowRef, padding: 5 })],
20
- });
21
- const hover = useHover(context, { move: true, enabled, delay: { open: FLOATING_DELAY } });
22
- const focus = useFocus(context, { enabled });
23
- const dismiss = useDismiss(context, { enabled });
24
- const role = useRole(context, { role: "tooltip", enabled });
25
- const clientPoint = useClientPoint(context, { enabled: !!enabled && !!followCursor });
26
- const { getReferenceProps, getFloatingProps } = useInteractions([hover, focus, dismiss, role, clientPoint]);
27
- return (_jsxs(Fragment, { children: [_jsx(Component, Object.assign({ ref: refs.setReference }, getReferenceProps(props), { children: title })), _jsx(FloatingPortal, { children: open && (_jsxs(Polymorph, Object.assign({}, getFloatingProps(), { ref: refs.setFloating, style: floatingStyles, className: "z-tooltip rounded-lg border border-tooltip-border bg-tooltip-background p-3 text-tooltip-foreground shadow-lg", children: [_jsx(FloatingArrow, { ref: arrowRef, context: context, strokeWidth: 0.1, className: "fill-tooltip-background stroke-tooltip-border" }), children] }))) })] }));
28
- };
@@ -1,17 +0,0 @@
1
- import React from "react";
2
- import { InputFieldProps } from "./input-field";
3
- import { type OptionProps } from "./select";
4
- type ItemProps = Omit<React.HTMLProps<HTMLLIElement>, "children"> & {
5
- selected: boolean;
6
- active: boolean;
7
- option: OptionProps;
8
- };
9
- export declare const Option: React.ForwardRefExoticComponent<Omit<ItemProps, "ref"> & React.RefAttributes<HTMLLIElement>>;
10
- export type AutocompleteProps = Omit<InputFieldProps<"input">, "value"> & {
11
- value?: string;
12
- options: OptionProps[];
13
- dynamicOption?: boolean;
14
- };
15
- export declare const Autocomplete: React.ForwardRefExoticComponent<Omit<AutocompleteProps, "ref"> & React.RefAttributes<HTMLInputElement>>;
16
- export {};
17
- //# sourceMappingURL=autocomplete.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"autocomplete.d.ts","sourceRoot":"","sources":["../../../src/components/form/autocomplete.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAkD,MAAM,OAAO,CAAC;AAIvE,OAAO,EAAc,eAAe,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C,KAAK,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,aAAa,CAAC,EAAE,UAAU,CAAC,GAAG;IAChE,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,WAAW,CAAC;CACvB,CAAC;AAEF,eAAO,MAAM,MAAM,8FAmBjB,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,GAAG;IACtE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,aAAa,CAAC,EAAE,OAAO,CAAC;CAC3B,CAAC;AAaF,eAAO,MAAM,YAAY,yGAmPxB,CAAC"}
@@ -1,152 +0,0 @@
1
- "use client";
2
- import { __rest } from "tslib";
3
- import { createElement as _createElement } from "react";
4
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
5
- import { autoUpdate, FloatingFocusManager, FloatingPortal, offset, size, useDismiss, useFloating, useInteractions, useListNavigation, useRole, useTransitionStyles, } from "@floating-ui/react";
6
- import Fuzzy from "fuzzy-search";
7
- import { CheckIcon, ChevronDown } from "lucide-react";
8
- import { forwardRef, useEffect, useRef, useState } from "react";
9
- import { useTranslations } from "../../hooks/use-translate-context";
10
- import { css, dispatchInput, initializeInputDataset } from "../../lib/dom";
11
- import { safeRegex } from "../../lib/fns";
12
- import { InputField } from "./input-field";
13
- export const Option = forwardRef((_a, ref) => {
14
- var _b;
15
- var { selected, active, onClick, option } = _a, rest = __rest(_a, ["selected", "active", "onClick", "option"]);
16
- return (_jsx("li", Object.assign({}, rest, { ref: ref, role: "option", "aria-selected": active, className: "w-full border-b border-tooltip-border last:border-transparent", children: _jsxs("button", { type: "button", "data-value": option.value, onClick: onClick, "aria-selected": active, "aria-checked": active, "aria-current": active, className: `flex w-full cursor-pointer justify-between p-2 text-left ${active ? "bg-primary text-primary-foreground" : ""} ${selected ? "bg-primary/70 text-primary-foreground" : ""}`, children: [(_b = option.label) !== null && _b !== void 0 ? _b : option.value, active ? (_jsx("span", { children: _jsx(CheckIcon, { "aria-hidden": true, className: "text-current", absoluteStrokeWidth: true, strokeWidth: 2, size: 22 }) })) : null] }) })));
17
- });
18
- const transitionStyles = {
19
- duration: 300,
20
- initial: { transform: "scaleY(0)", opacity: 0.4 },
21
- open: { transform: "scaleY(1)", opacity: 1 },
22
- close: { transform: "scaleY(0)", opacity: 0 },
23
- };
24
- const fuzzyOptions = { caseSensitive: false, sort: false };
25
- const emptyRef = [];
26
- export const Autocomplete = forwardRef((_a, externalRef) => {
27
- var _b, _c, _d, _e;
28
- var { options, dynamicOption = false, feedback = null, labelClassName, interactive, rightLabel, optionalText, container, hideLeft = false, right, left, error, required = false } = _a, props = __rest(_a, ["options", "dynamicOption", "feedback", "labelClassName", "interactive", "rightLabel", "optionalText", "container", "hideLeft", "right", "left", "error", "required"]);
29
- const translation = useTranslations();
30
- const ref = useRef(null);
31
- const [open, setOpen] = useState(false);
32
- const [shadow, setShadow] = useState("");
33
- const [value, setValue] = useState((_c = (_b = props.value) !== null && _b !== void 0 ? _b : props.defaultValue) !== null && _c !== void 0 ? _c : "");
34
- const [label, setLabel] = useState((_e = (_d = props.value) !== null && _d !== void 0 ? _d : props.defaultValue) !== null && _e !== void 0 ? _e : "");
35
- const [index, setIndex] = useState(null);
36
- const listRef = useRef(emptyRef);
37
- const innerOptions = dynamicOption && shadow !== "" ? [{ value: shadow, label: shadow, "data-dynamic": "true" }, ...options] : options;
38
- const list = new Fuzzy(innerOptions, ["value", "label"], fuzzyOptions).search(shadow);
39
- const pattern = dynamicOption
40
- ? undefined
41
- : `^(${options.map((x) => `${safeRegex(x.value)}${x.label ? "|" + safeRegex(x.label) : ""}`).join("|")})$`;
42
- useEffect(() => {
43
- const input = refs.reference.current;
44
- if (!input)
45
- return;
46
- return initializeInputDataset(input);
47
- }, []);
48
- useEffect(() => {
49
- var _a;
50
- if (props.value) {
51
- const item = options.find((x) => x.value === props.value);
52
- setValue((_a = item === null || item === void 0 ? void 0 : item.label) !== null && _a !== void 0 ? _a : props.value);
53
- }
54
- }, [props.value]);
55
- const { x, y, strategy, refs, context } = useFloating({
56
- open,
57
- transform: true,
58
- onOpenChange: setOpen,
59
- whileElementsMounted: autoUpdate,
60
- middleware: [
61
- offset(4),
62
- size({
63
- padding: 10,
64
- apply(a) {
65
- Object.assign(a.elements.floating.style, {
66
- width: `${a.rects.reference.width}px`,
67
- maxHeight: `${Math.min(480, a.availableHeight)}px`,
68
- });
69
- },
70
- }),
71
- ],
72
- });
73
- const transitions = useTransitionStyles(context, transitionStyles);
74
- const { getReferenceProps, getFloatingProps, getItemProps } = useInteractions([
75
- useRole(context, { role: "listbox" }),
76
- useDismiss(context),
77
- useListNavigation(context, {
78
- activeIndex: index,
79
- allowEscape: true,
80
- cols: 0,
81
- focusItemOnOpen: "auto",
82
- listRef,
83
- loop: true,
84
- openOnArrowKeyDown: true,
85
- scrollItemIntoView: true,
86
- selectedIndex: index,
87
- virtual: true,
88
- onNavigate: (n) => setIndex((prev) => n !== null && n !== void 0 ? n : prev),
89
- }),
90
- ]);
91
- const onSelect = (opt, i) => {
92
- var _a, _b, _c;
93
- setValue(opt.value);
94
- (_a = refs.reference.current) === null || _a === void 0 ? void 0 : _a.setAttribute("data-value", opt.value);
95
- setLabel((_b = opt.label) !== null && _b !== void 0 ? _b : "");
96
- const fakeEvent = dispatchInput(ref.current, opt.value);
97
- if (fakeEvent)
98
- (_c = props.onChange) === null || _c === void 0 ? void 0 : _c.call(props, fakeEvent);
99
- setOpen(false);
100
- setShadow("");
101
- setIndex(i);
102
- };
103
- const onChange = (event) => {
104
- var _a;
105
- const value = event.target.value;
106
- setShadow(value);
107
- if (!open && value === "")
108
- return setOpen(true);
109
- event.target.name = props.name || "";
110
- return value ? setOpen(true) : (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, event);
111
- };
112
- const onFocus = () => {
113
- setOpen(true);
114
- setShadow("");
115
- };
116
- const onClose = () => {
117
- var _a;
118
- setShadow("");
119
- setValue("");
120
- (_a = refs.reference.current) === null || _a === void 0 ? void 0 : _a.setAttribute("data-value", "");
121
- setLabel("");
122
- dispatchInput(refs.reference.current, "");
123
- setOpen(false);
124
- };
125
- const id = props.id || props.name;
126
- return (_jsxs(InputField, Object.assign({}, props, { container: css("group inline-block w-full", container), error: error, feedback: feedback, form: props.form, hideLeft: hideLeft, id: props.name || props.id, interactive: interactive, labelClassName: labelClassName, left: left, name: props.name, optionalText: optionalText, placeholder: props.placeholder, required: required, rightLabel: rightLabel, title: props.title, right: _jsxs("span", { className: "flex items-center gap-0.5", children: [_jsxs("button", { type: "button", className: "transition-colors link:text-primary", children: [_jsx(ChevronDown, { size: 20 }), _jsx("span", { className: "sr-only", children: translation.inputCaretDown })] }), value ? (_jsx("button", { type: "button", onClick: onClose, className: "transition-colors link:text-danger", 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", Object.assign({}, getReferenceProps(Object.assign(Object.assign({}, props), { onChange,
127
- onFocus,
128
- pattern, ref: refs.setReference, name: `${id}-shadow`, id: `${id}-shadow`, onClick: (e) => e.currentTarget.focus(), onKeyDown(event) {
129
- if (event.key === "Escape") {
130
- event.currentTarget.blur();
131
- return setOpen(false);
132
- }
133
- if (event.key === "Enter") {
134
- if (index !== null && list[index]) {
135
- event.preventDefault();
136
- return onSelect(list[index], index);
137
- }
138
- if (list.length === 1) {
139
- event.preventDefault();
140
- return onSelect(list[0], 0);
141
- }
142
- }
143
- } })), { "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-10 w-full flex-1 rounded-md bg-transparent px-2 py-1 text-base text-foreground outline-none transition-colors group-error:text-danger group-error:placeholder-input-mask-error", !!right || shadow ? "pe-12" : "", !!left ? "ps-8" : "", 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: _jsx("ul", Object.assign({}, getFloatingProps({
144
- ref: refs.setFloating,
145
- style: Object.assign({ position: strategy, left: x !== null && x !== void 0 ? x : 0, top: y !== null && y !== void 0 ? y : 0 }, transitions.styles),
146
- }), { "data-floating": "true", className: "z-floating m-0 origin-[top_center] list-none overflow-auto overflow-y-auto rounded-b-lg rounded-t-lg border border-floating-border bg-floating-background p-0 text-foreground shadow-floating", children: list.map((option, i) => (_createElement(Option, Object.assign({}, getItemProps({
147
- onClick: () => onSelect(option, i),
148
- ref: (node) => void (listRef.current[i] = node),
149
- selected: index === i,
150
- active: value === option.value,
151
- }), { key: `${option.value}-option`, option: option, selected: index === i, active: value === option.value })))) })) })) : null })] })));
152
- });
@@ -1,11 +0,0 @@
1
- import React from "react";
2
- import { Override } from "../../types";
3
- export type CheckboxProps = Override<React.PropsWithChildren<React.ComponentProps<"input">>, {
4
- error?: string;
5
- asTask?: boolean;
6
- container?: string;
7
- labelClassName?: string;
8
- size?: "medium" | "large";
9
- }>;
10
- export declare const Checkbox: React.ForwardRefExoticComponent<Omit<CheckboxProps, "ref"> & React.RefAttributes<HTMLInputElement>>;
11
- //# sourceMappingURL=checkbox.d.ts.map
@@ -1 +0,0 @@
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,qGA4BpB,CAAC"}
@@ -1,8 +0,0 @@
1
- import { __rest } from "tslib";
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { forwardRef } from "react";
4
- import { css } from "../../lib/dom";
5
- export const Checkbox = forwardRef((_a, ref) => {
6
- var { children, asTask = false, labelClassName, error, className = "", size, container } = _a, props = __rest(_a, ["children", "asTask", "labelClassName", "error", "className", "size", "container"]);
7
- return (_jsxs("label", { "data-task": asTask, "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", Object.assign({}, 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 })] }));
8
- });
@@ -1,61 +0,0 @@
1
- import React from "react";
2
- import { Override } from "../../types";
3
- import { CalendarProps } from "../display/calendar";
4
- import { InputProps } from "./input";
5
- export type DatePickerProps = Override<InputProps, CalendarProps<"date">>;
6
- export declare const DatePicker: React.ForwardRefExoticComponent<(Omit<Omit<InputProps, "onChange" | "date" | "locale" | "markToday" | "rangeMode" | "changeOnlyOnClick" | "onChangeMonth" | "onChangeYear" | "RenderOnDay" | "disabledDate" | "styles"> & Partial<{
7
- locale: import("the-mask-input").Locales;
8
- markToday: boolean;
9
- rangeMode: boolean;
10
- changeOnlyOnClick: boolean;
11
- onChangeMonth: (d: Date) => void;
12
- onChangeYear: (d: Date) => void;
13
- RenderOnDay: React.FC<{
14
- date: Date;
15
- }>;
16
- disabledDate: (date: Date) => boolean;
17
- styles: Partial<{
18
- day: string;
19
- week: string;
20
- weekDay: string;
21
- dayFrame: string;
22
- calendar: string;
23
- }>;
24
- } & {
25
- date: Date;
26
- onChange: (d: Date | undefined) => void;
27
- } & {
28
- date: Date;
29
- onChange: (d: Date | undefined) => void;
30
- }>, "ref"> | Omit<Omit<InputProps, "onChange" | "date" | "locale" | "markToday" | "rangeMode" | "changeOnlyOnClick" | "onChangeMonth" | "onChangeYear" | "RenderOnDay" | "disabledDate" | "styles"> & Partial<{
31
- locale: import("the-mask-input").Locales;
32
- markToday: boolean;
33
- rangeMode: boolean;
34
- changeOnlyOnClick: boolean;
35
- onChangeMonth: (d: Date) => void;
36
- onChangeYear: (d: Date) => void;
37
- RenderOnDay: React.FC<{
38
- date: Date;
39
- }>;
40
- disabledDate: (date: Date) => boolean;
41
- styles: Partial<{
42
- day: string;
43
- week: string;
44
- weekDay: string;
45
- dayFrame: string;
46
- calendar: string;
47
- }>;
48
- } & {
49
- date: Date;
50
- onChange: (d: Date | undefined) => void;
51
- } & {
52
- range: {
53
- from?: Date;
54
- to?: Date;
55
- };
56
- onChange: (d: {
57
- from?: Date;
58
- to?: Date;
59
- } | undefined) => void;
60
- }>, "ref">) & React.RefAttributes<HTMLInputElement>>;
61
- //# sourceMappingURL=date-picker.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"date-picker.d.ts","sourceRoot":"","sources":["../../../src/components/form/date-picker.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAyD,MAAM,OAAO,CAAC;AAG9E,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAY,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAE9D,OAAO,EAAS,UAAU,EAAE,MAAM,SAAS,CAAC;AAE5C,MAAM,MAAM,eAAe,GAAG,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC;AAmC1E,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oDAyGtB,CAAC"}
@@ -1,78 +0,0 @@
1
- import { __rest } from "tslib";
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { format, isValid, parse, startOfDay } from "date-fns";
4
- import { CalendarIcon } from "lucide-react";
5
- import { forwardRef, Fragment, useId, useMemo, useState } from "react";
6
- import { Is } from "sidekicker";
7
- import { useTranslations } from "../../hooks/use-translate-context";
8
- import { Calendar } from "../display/calendar";
9
- import { Dropdown } from "../floating/dropdown";
10
- import { Input } from "./input";
11
- const fixedDate = new Date(1970, 11, 31);
12
- const parts = {
13
- year: () => [/\d/, /\d/, /\d/, /\d/],
14
- month: () => [/\d/, /\d/],
15
- day: () => [/\d/, /\d/],
16
- literal: (str) => str.split(""),
17
- };
18
- const placeholders = {
19
- year: () => "yyyy",
20
- month: () => "MM",
21
- day: () => "dd",
22
- literal: (str) => str,
23
- };
24
- const partValues = {
25
- literal: (date, str) => str,
26
- year: (date) => date.getFullYear(),
27
- day: (date) => date.getDate().toString().padStart(2, "0"),
28
- month: (date) => (date.getMonth() + 1).toString().padStart(2, "0"),
29
- };
30
- const formatParts = (datetimeFormat, date) => {
31
- try {
32
- return datetimeFormat.formatToParts(date);
33
- }
34
- catch (e) {
35
- return [];
36
- }
37
- };
38
- export const DatePicker = forwardRef((_a, externalRef) => {
39
- var _b;
40
- var { date, locale, disabledDate, onChange, markToday } = _a, props = __rest(_a, ["date", "locale", "disabledDate", "onChange", "markToday"]);
41
- const labelId = useId();
42
- const translation = useTranslations();
43
- const datetimeFormat = useMemo(() => new Intl.DateTimeFormat(locale), [locale]);
44
- const [innerDate, setInnerDate] = useState(date || undefined);
45
- const [open, setOpen] = useState(false);
46
- const mask = formatParts(datetimeFormat, fixedDate).flatMap((x) => (Is.keyof(parts, x.type) ? parts[x.type](x.value) : []));
47
- const placeholder = formatParts(datetimeFormat, fixedDate).reduce((acc, x) => acc + (Is.keyof(placeholders, x.type) ? placeholders[x.type](x.value) : ""), "");
48
- const [value, setValue] = useState(!innerDate
49
- ? ""
50
- : formatParts(datetimeFormat, innerDate).reduce((acc, x) => acc + (Is.keyof(parts, x.type) ? partValues[x.type](innerDate, x.value) : ""), ""));
51
- const onChangeDateInput = (e) => {
52
- const v = e.target.value;
53
- setValue(v);
54
- if (mask.length === v.length) {
55
- const matches = mask.every((x, i) => {
56
- const c = v.charAt(i);
57
- return typeof x === "string" ? c === x : x.test(c);
58
- });
59
- if (matches) {
60
- const d = startOfDay(parse(v, placeholder, new Date()));
61
- setInnerDate(d);
62
- return onChange === null || onChange === void 0 ? void 0 : onChange(d);
63
- }
64
- }
65
- setInnerDate(undefined);
66
- return onChange === null || onChange === void 0 ? void 0 : onChange(undefined);
67
- };
68
- const onChangeDate = (d) => {
69
- setInnerDate(d);
70
- onChange === null || onChange === void 0 ? void 0 : onChange(d);
71
- if (d)
72
- return setValue(format(d, placeholder));
73
- return setValue("");
74
- };
75
- const validDate = isValid(innerDate);
76
- const htmlValue = validDate ? innerDate.toISOString() : undefined;
77
- return (_jsx(Input, Object.assign({}, props, { mask: mask, value: value, "data-value": htmlValue, "data-target": props.name, className: "uppercase", formNoValidate: !open, placeholder: placeholder, onChange: onChangeDateInput, required: (_b = props.required) !== null && _b !== void 0 ? _b : true, error: open ? undefined : props.error, name: undefined, id: undefined, right: _jsxs(Fragment, { children: [_jsx("input", { "data-origin": props.name, hidden: true, type: "date", id: props.name, ref: externalRef, name: props.name, defaultValue: htmlValue }), _jsx(Dropdown, { open: open, onChange: setOpen, trigger: _jsxs("span", { "aria-labelledby": labelId, children: [_jsx("span", { id: labelId, className: "sr-only", children: translation.datePickerCalendarButtonLabel }), _jsx(CalendarIcon, {})] }), buttonProps: { "aria-describedby": labelId }, children: _jsx(Calendar, Object.assign({}, props, { locale: locale, changeOnlyOnClick: true, markToday: markToday, onChange: onChangeDate, disabledDate: disabledDate, date: validDate ? innerDate : undefined })) })] }) })));
78
- });
@@ -1,12 +0,0 @@
1
- import React from "react";
2
- import { DropzoneProps } from "react-dropzone";
3
- import { Override } from "sidekicker";
4
- type Props = Override<React.ComponentProps<"input">, DropzoneProps> & {
5
- onDeleteFile?: (file: File) => void;
6
- files?: File[];
7
- idle?: React.ReactElement;
8
- onDrop?: (file: File[]) => void;
9
- };
10
- export declare const FileUpload: ({ idle, onDeleteFile, onDrop, ...props }: Props) => import("react/jsx-runtime").JSX.Element;
11
- export {};
12
- //# sourceMappingURL=file-upload.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"file-upload.d.ts","sourceRoot":"","sources":["../../../src/components/form/file-upload.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAwC,MAAM,OAAO,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAe,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGtC,KAAK,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,aAAa,CAAC,GAAG;IAClE,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IACpC,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC;IACf,IAAI,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC;IAC1B,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,IAAI,CAAC;CACnC,CAAC;AAmGF,eAAO,MAAM,UAAU,6CAA4D,KAAK,4CAiBvF,CAAC"}
@@ -1,62 +0,0 @@
1
- "use client";
2
- import { __rest } from "tslib";
3
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
4
- import { FileIcon, Trash2Icon, UploadIcon } from "lucide-react";
5
- import prettyBytes from "pretty-bytes";
6
- import { Fragment, useEffect, useState } from "react";
7
- import { useDropzone } from "react-dropzone";
8
- import { Button } from "../core/button";
9
- const mime = {
10
- isImage: (file) => file.type.includes("image"),
11
- };
12
- const FileViewer = (props) => {
13
- const [info, setInfo] = useState({ url: "", type: "", size: "" });
14
- useEffect(() => {
15
- if (mime.isImage(props.file)) {
16
- const url = URL.createObjectURL(props.file);
17
- setInfo({ url, type: "img", size: prettyBytes(props.file.size) });
18
- return () => {
19
- URL.revokeObjectURL(url);
20
- };
21
- }
22
- setInfo({ url: "", type: props.file.type, size: prettyBytes(props.file.size) });
23
- }, [props.file]);
24
- if (info.type === "img") {
25
- return (_jsxs("div", { className: "flex flex-row gap-jade-200 items-center justify-between w-full", children: [_jsxs("header", { className: "flex flex-row gap-jade-200 items-center", children: [_jsx("img", { src: info.url, className: "size-jade-500 rounded-jade-xsmall", alt: `Miniatura do arquivo ${props.file.name}` }), _jsxs("div", { className: "flex flex-col", children: [_jsx("span", { children: props.file.name }), _jsx("span", { children: info.size })] })] }), _jsx(Button, { className: "isolate", type: "button", theme: "raw", onClick: (e) => {
26
- var _a;
27
- e.stopPropagation();
28
- (_a = props.onDeleteFile) === null || _a === void 0 ? void 0 : _a.call(props, props.file);
29
- }, children: _jsx(Trash2Icon, {}) })] }));
30
- }
31
- return (_jsxs("div", { className: "flex flex-row gap-jade-200 items-center justify-between w-full", children: [_jsxs("header", { className: "flex flex-row gap-4 items-center", children: [_jsx(FileIcon, { size: 48 }), _jsxs("div", { className: "flex flex-col text-left justify-start items-start", children: [_jsx("span", { children: props.file.name }), _jsx("span", { children: info.size })] })] }), _jsx(Button, { className: "isolate", type: "button", theme: "raw", onClick: (e) => {
32
- var _a;
33
- e.stopPropagation();
34
- (_a = props.onDeleteFile) === null || _a === void 0 ? void 0 : _a.call(props, props.file);
35
- }, children: _jsx(Trash2Icon, { className: "text-danger" }) })] }));
36
- };
37
- const DefaultViewer = (props) => {
38
- return (_jsx("ul", { className: "w-full space-y-jade-200", children: props.files.map((file) => {
39
- return _jsx(FileViewer, { onDeleteFile: props.onDeleteFile, file: file }, file.name);
40
- }) }));
41
- };
42
- const InteractiveArea = (props) => {
43
- if (props.isDragActive) {
44
- return _jsx("p", { children: "Solte os arquivos selecionados" });
45
- }
46
- if (props.files.length > 0) {
47
- return _jsx(DefaultViewer, { onDeleteFile: props.onDeleteFile, files: props.files });
48
- }
49
- return _jsx(Fragment, { children: props.idle });
50
- };
51
- const DefaultIdle = (_jsxs("div", { className: "flex flex-col gap-4 justify-center items-center", children: [_jsx(UploadIcon, { size: 64 }), _jsxs("p", { children: ["You can drag your files or", " ", _jsx("button", { className: "text-primary underline", type: "button", children: "drag to here" })] })] }));
52
- export const FileUpload = (_a) => {
53
- var _b, _c;
54
- var { idle = DefaultIdle, onDeleteFile, onDrop } = _a, props = __rest(_a, ["idle", "onDeleteFile", "onDrop"]);
55
- const [files, setFiles] = useState([]);
56
- const drop = (x) => {
57
- onDrop === null || onDrop === void 0 ? void 0 : onDrop(x);
58
- setFiles(x);
59
- };
60
- const { getRootProps, getInputProps, isDragActive } = useDropzone({ onDrop: drop });
61
- return (_jsxs("div", Object.assign({}, getRootProps(), { "data-active": ((_b = props.files) === null || _b === void 0 ? void 0 : _b.length) ? props.files.length > 0 : false, className: "flex text-foreground flex-col items-center justify-center border-2 rounded-lg p-6 border-card-border data-[active=true]:bg-card-background data-[active=true]:border-solid data-[active=false]:border-dashed", children: [_jsx("input", Object.assign({}, getInputProps(props), { name: props.name, id: props.name })), _jsx(InteractiveArea, { onDeleteFile: onDeleteFile, isDragActive: isDragActive, idle: idle, files: (_c = props.files) !== null && _c !== void 0 ? _c : files })] })));
62
- };
@@ -1,4 +0,0 @@
1
- import React from "react";
2
- export declare const formReset: (form?: HTMLFormElement | null) => void;
3
- export declare const Form: (props: React.ComponentProps<"form">) => import("react/jsx-runtime").JSX.Element;
4
- //# sourceMappingURL=form.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"form.d.ts","sourceRoot":"","sources":["../../../src/components/form/form.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,eAAO,MAAM,SAAS,UAAW,eAAe,GAAG,IAAI,SAatD,CAAC;AAEF,eAAO,MAAM,IAAI,UAAW,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,4CAOvD,CAAC"}