maquinaweb-ui 2.36.1 → 2.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/button-B3nLhVyZ.js +44 -0
- package/dist/button-B3nLhVyZ.js.map +1 -0
- package/dist/{container-animation.d.mts → container-animation.d.ts} +3 -3
- package/dist/container-animation.d.ts.map +1 -0
- package/dist/{container-animation.mjs → container-animation.js} +4 -3
- package/dist/container-animation.js.map +1 -0
- package/dist/date-field.d.ts +32 -0
- package/dist/date-field.d.ts.map +1 -0
- package/dist/date-field.js +281 -0
- package/dist/date-field.js.map +1 -0
- package/dist/{input-B9ebQkfm.mjs → input-Bs61WBGW.js} +3 -3
- package/dist/input-Bs61WBGW.js.map +1 -0
- package/dist/{input-help-BO1s6Ca6.mjs → input-help-BRDK0-yu.js} +25 -10
- package/dist/input-help-BRDK0-yu.js.map +1 -0
- package/dist/{input-suggest.d.mts → input-suggest.d.ts} +4 -4
- package/dist/input-suggest.d.ts.map +1 -0
- package/dist/{input-suggest.mjs → input-suggest.js} +9 -6
- package/dist/input-suggest.js.map +1 -0
- package/dist/{label-ofBNlnV2.mjs → label-Bkg7B2j8.js} +3 -3
- package/dist/label-Bkg7B2j8.js.map +1 -0
- package/dist/{page-header.d.mts → page-header.d.ts} +3 -3
- package/dist/page-header.d.ts.map +1 -0
- package/dist/{page-header.mjs → page-header.js} +5 -2
- package/dist/page-header.js.map +1 -0
- package/dist/{scroll-area-erZKDarE.mjs → popover-DwlKLFCp.js} +5 -21
- package/dist/popover-DwlKLFCp.js.map +1 -0
- package/dist/{remote-selector.d.mts → remote-selector.d.ts} +4 -4
- package/dist/remote-selector.d.ts.map +1 -0
- package/dist/{remote-selector.mjs → remote-selector.js} +18 -51
- package/dist/remote-selector.js.map +1 -0
- package/dist/scroll-area-C1kW_eA9.js +22 -0
- package/dist/scroll-area-C1kW_eA9.js.map +1 -0
- package/dist/{split-text-poor.d.mts → split-text-poor.d.ts} +1 -1
- package/dist/split-text-poor.d.ts.map +1 -0
- package/dist/{split-text-poor.mjs → split-text-poor.js} +3 -2
- package/dist/split-text-poor.js.map +1 -0
- package/dist/{text-field.d.mts → text-field.d.ts} +7 -7
- package/dist/text-field.d.ts.map +1 -0
- package/dist/{text-field.mjs → text-field.js} +10 -9
- package/dist/text-field.js.map +1 -0
- package/dist/{toggle-field.d.mts → toggle-field.d.ts} +3 -3
- package/dist/toggle-field.d.ts.map +1 -0
- package/dist/{toggle-field.mjs → toggle-field.js} +7 -6
- package/dist/toggle-field.js.map +1 -0
- package/dist/{utils-CG5oGEBQ.mjs → utils-C8_amEgK.js} +1 -1
- package/dist/utils-C8_amEgK.js.map +1 -0
- package/dist/{with-mask-110DD-Lg.d.mts → with-mask-Chm8kVE1.d.ts} +1 -1
- package/dist/with-mask-Chm8kVE1.d.ts.map +1 -0
- package/package.json +46 -12
- package/dist/container-animation.d.mts.map +0 -1
- package/dist/container-animation.mjs.map +0 -1
- package/dist/input-B9ebQkfm.mjs.map +0 -1
- package/dist/input-help-BO1s6Ca6.mjs.map +0 -1
- package/dist/input-suggest.d.mts.map +0 -1
- package/dist/input-suggest.mjs.map +0 -1
- package/dist/label-ofBNlnV2.mjs.map +0 -1
- package/dist/page-header.d.mts.map +0 -1
- package/dist/page-header.mjs.map +0 -1
- package/dist/remote-selector.d.mts.map +0 -1
- package/dist/remote-selector.mjs.map +0 -1
- package/dist/scroll-area-erZKDarE.mjs.map +0 -1
- package/dist/split-text-poor.d.mts.map +0 -1
- package/dist/split-text-poor.mjs.map +0 -1
- package/dist/text-field.d.mts.map +0 -1
- package/dist/text-field.mjs.map +0 -1
- package/dist/toggle-field.d.mts.map +0 -1
- package/dist/toggle-field.mjs.map +0 -1
- package/dist/utils-CG5oGEBQ.mjs.map +0 -1
- package/dist/with-mask-110DD-Lg.d.mts.map +0 -1
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { t as cn } from "./utils-C8_amEgK.js";
|
|
2
|
+
import "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import { cva } from "class-variance-authority";
|
|
5
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
6
|
+
|
|
7
|
+
//#region src/components/ui/button.tsx
|
|
8
|
+
const buttonVariants = cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive", {
|
|
9
|
+
variants: {
|
|
10
|
+
variant: {
|
|
11
|
+
default: "bg-primary text-primary-foreground hover:bg-primary/90",
|
|
12
|
+
destructive: "bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
|
|
13
|
+
outline: "border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",
|
|
14
|
+
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
|
15
|
+
ghost: "hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
|
|
16
|
+
link: "text-primary underline-offset-4 hover:underline"
|
|
17
|
+
},
|
|
18
|
+
size: {
|
|
19
|
+
default: "h-9 px-4 py-2 has-[>svg]:px-3",
|
|
20
|
+
sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",
|
|
21
|
+
lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
|
|
22
|
+
icon: "size-9"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
defaultVariants: {
|
|
26
|
+
variant: "default",
|
|
27
|
+
size: "default"
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
function Button({ className, variant, size, asChild = false,...props }) {
|
|
31
|
+
return /* @__PURE__ */ jsx(asChild ? Slot : "button", {
|
|
32
|
+
className: cn(buttonVariants({
|
|
33
|
+
variant,
|
|
34
|
+
size,
|
|
35
|
+
className
|
|
36
|
+
})),
|
|
37
|
+
"data-slot": "button",
|
|
38
|
+
...props
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
//#endregion
|
|
43
|
+
export { buttonVariants as n, Button as t };
|
|
44
|
+
//# sourceMappingURL=button-B3nLhVyZ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"button-B3nLhVyZ.js","names":[],"sources":["../src/components/ui/button.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Slot } from '@radix-ui/react-slot';\n\nimport { cn } from '@/lib/utils';\nimport { cva, type VariantProps } from 'class-variance-authority';\n\nconst buttonVariants = cva(\n \"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive\",\n {\n variants: {\n variant: {\n default: 'bg-primary text-primary-foreground hover:bg-primary/90',\n destructive:\n 'bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60',\n outline:\n 'border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50',\n secondary:\n 'bg-secondary text-secondary-foreground hover:bg-secondary/80',\n ghost:\n 'hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50',\n link: 'text-primary underline-offset-4 hover:underline',\n },\n size: {\n default: 'h-9 px-4 py-2 has-[>svg]:px-3',\n sm: 'h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5',\n lg: 'h-10 rounded-md px-6 has-[>svg]:px-4',\n icon: 'size-9',\n },\n },\n defaultVariants: {\n variant: 'default',\n size: 'default',\n },\n }\n);\n\nfunction Button({\n className,\n variant,\n size,\n asChild = false,\n ...props\n}: React.ComponentProps<'button'> &\n VariantProps<typeof buttonVariants> & {\n asChild?: boolean;\n }) {\n const Comp = asChild ? Slot : 'button';\n\n return (\n <Comp\n className={cn(buttonVariants({ variant, size, className }))}\n data-slot=\"button\"\n {...(props as any)}\n />\n );\n}\n\nexport { Button, buttonVariants };\n"],"mappings":";;;;;;;AAOA,MAAM,iBAAiB,IACrB,+bACA;CACE,UAAU;EACR,SAAS;GACP,SAAS;GACT,aACE;GACF,SACE;GACF,WACE;GACF,OACE;GACF,MAAM;GACP;EACD,MAAM;GACJ,SAAS;GACT,IAAI;GACJ,IAAI;GACJ,MAAM;GACP;EACF;CACD,iBAAiB;EACf,SAAS;EACT,MAAM;EACP;CACF,CACF;AAED,SAAS,OAAO,EACd,WACA,SACA,MACA,UAAU,MACV,GAAG,SAIA;AAGH,QACE,oBAHW,UAAU,OAAO;EAI1B,WAAW,GAAG,eAAe;GAAE;GAAS;GAAM;GAAW,CAAC,CAAC;EAC3D,aAAU;EACV,GAAK;GACL"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ComponentProps, ElementType } from "react";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
3
|
|
|
4
4
|
//#region src/components/container-animation/container-animation.d.ts
|
|
5
5
|
type ContainerAnimationProps<T extends ElementType = 'div'> = ComponentProps<'div'> & ComponentProps<T> & {
|
|
@@ -23,7 +23,7 @@ declare const ContainerAnimation: <T extends ElementType = "div">({
|
|
|
23
23
|
distance,
|
|
24
24
|
hideNotInView,
|
|
25
25
|
...props
|
|
26
|
-
}: ContainerAnimationProps<T>) =>
|
|
26
|
+
}: ContainerAnimationProps<T>) => react_jsx_runtime0.JSX.Element;
|
|
27
27
|
//#endregion
|
|
28
28
|
export { ContainerAnimation, type ContainerAnimationProps };
|
|
29
|
-
//# sourceMappingURL=container-animation.d.
|
|
29
|
+
//# sourceMappingURL=container-animation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"container-animation.d.ts","names":[],"sources":["../src/components/container-animation/container-animation.tsx"],"sourcesContent":[],"mappings":";;;;KAiDY,kCAAkC,uBAC5C,wBACE,eAAe;;;EAFP,KAAA,CAAA,EAAA,MAAA;EAAkC,QAAA,CAAA,EAAA,MAAA;EAC5C,QAAA,CAAA,EAAA,CAAA,MAAA,EAAA,MAAA,CAAA;EACiB,aAAA,CAAA,EAAA,OAAA;EAAf,EAAA,CAAA,EAOO,CAPP,GAAA,MAAA;EAOO,SAAA,CAAA,EAAA,MAAA;CAAC;AAEN,cAEA,kBAkCL,EAAA,CAAA,UAlCqC,WAkCrC,GAAA,KAAA,CAAA,CAAA;EAAA,SAAA;EAAA,QAAA;EAAA,QAAA;EAAA,KAAA;EAAA,KAAA;EAAA,QAAA;EAAA,EAAA,EAlC0D,EAkC1D;EAAA,QAAA;EAAA,aAAA;EAAA,GAAA;AAAA,CAAA,EAvBE,uBAuBF,CAvB0B,CAuB1B,CAAA,EAAA,GAvB4B,kBAAA,CAAA,GAAA,CAAA,OAuB5B"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
import { t as cn } from "./utils-C8_amEgK.js";
|
|
4
5
|
import { useEffect, useRef, useState } from "react";
|
|
5
6
|
import { jsx } from "react/jsx-runtime";
|
|
6
7
|
import * as motion from "motion/react-m";
|
|
@@ -106,7 +107,7 @@ const getVariants = (position, space, delay) => {
|
|
|
106
107
|
}
|
|
107
108
|
};
|
|
108
109
|
};
|
|
109
|
-
const ContainerAnimation = ({ className, children, position = "top", delay = 0, space = 20, duration = .8, as: As = "div", distance = [95, 5], hideNotInView = false
|
|
110
|
+
const ContainerAnimation = ({ className, children, position = "top", delay = 0, space = 20, duration = .8, as: As = "div", distance = [95, 5], hideNotInView = false,...props }) => {
|
|
110
111
|
const ref = useRef(null);
|
|
111
112
|
const isInView = useInView(ref, {
|
|
112
113
|
once: true,
|
|
@@ -127,4 +128,4 @@ const ContainerAnimation = ({ className, children, position = "top", delay = 0,
|
|
|
127
128
|
|
|
128
129
|
//#endregion
|
|
129
130
|
export { ContainerAnimation };
|
|
130
|
-
//# sourceMappingURL=container-animation.
|
|
131
|
+
//# sourceMappingURL=container-animation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"container-animation.js","names":[],"sources":["../node_modules/motion-dom/dist/es/utils/resolve-elements.mjs","../node_modules/framer-motion/dist/es/render/dom/viewport/index.mjs","../node_modules/framer-motion/dist/es/utils/use-in-view.mjs","../src/components/container-animation/container-animation.tsx"],"sourcesContent":["function resolveElements(elementOrSelector, scope, selectorCache) {\n if (elementOrSelector instanceof EventTarget) {\n return [elementOrSelector];\n }\n else if (typeof elementOrSelector === \"string\") {\n let root = document;\n if (scope) {\n root = scope.current;\n }\n const elements = selectorCache?.[elementOrSelector] ??\n root.querySelectorAll(elementOrSelector);\n return elements ? Array.from(elements) : [];\n }\n return Array.from(elementOrSelector);\n}\n\nexport { resolveElements };\n","import { resolveElements } from 'motion-dom';\n\nconst thresholds = {\n some: 0,\n all: 1,\n};\nfunction inView(elementOrSelector, onStart, { root, margin: rootMargin, amount = \"some\" } = {}) {\n const elements = resolveElements(elementOrSelector);\n const activeIntersections = new WeakMap();\n const onIntersectionChange = (entries) => {\n entries.forEach((entry) => {\n const onEnd = activeIntersections.get(entry.target);\n /**\n * If there's no change to the intersection, we don't need to\n * do anything here.\n */\n if (entry.isIntersecting === Boolean(onEnd))\n return;\n if (entry.isIntersecting) {\n const newOnEnd = onStart(entry.target, entry);\n if (typeof newOnEnd === \"function\") {\n activeIntersections.set(entry.target, newOnEnd);\n }\n else {\n observer.unobserve(entry.target);\n }\n }\n else if (typeof onEnd === \"function\") {\n onEnd(entry);\n activeIntersections.delete(entry.target);\n }\n });\n };\n const observer = new IntersectionObserver(onIntersectionChange, {\n root,\n rootMargin,\n threshold: typeof amount === \"number\" ? amount : thresholds[amount],\n });\n elements.forEach((element) => observer.observe(element));\n return () => observer.disconnect();\n}\n\nexport { inView };\n//# sourceMappingURL=index.mjs.map\n","\"use client\";\nimport { useState, useEffect } from 'react';\nimport { inView } from '../render/dom/viewport/index.mjs';\n\nfunction useInView(ref, { root, margin, amount, once = false, initial = false, } = {}) {\n const [isInView, setInView] = useState(initial);\n useEffect(() => {\n if (!ref.current || (once && isInView))\n return;\n const onEnter = () => {\n setInView(true);\n return once ? undefined : () => setInView(false);\n };\n const options = {\n root: (root && root.current) || undefined,\n margin,\n amount,\n };\n return inView(ref.current, onEnter, options);\n }, [root, ref, margin, once, amount]);\n return isInView;\n}\n\nexport { useInView };\n//# sourceMappingURL=use-in-view.mjs.map\n","'use client';\n\nimport { type ComponentProps, type ElementType, useRef } from 'react';\n\nimport { cn } from '@/lib/utils';\nimport { useInView } from 'motion/react';\nimport * as motion from 'motion/react-m';\n\nconst getVariants = (\n position: 'top' | 'bottom' | 'left' | 'right',\n space: number,\n delay: number\n) => {\n const directions = {\n top: {\n transform: `translateY(${space}px)`,\n },\n bottom: {\n transform: `translateY(-${space}px)`,\n },\n left: {\n transform: `translateX(${space}px)`,\n },\n right: {\n transform: `translateX(-${space}px)`,\n },\n };\n\n const dir = directions[position] || directions.top;\n\n return {\n hidden: {\n opacity: 0,\n filter: 'blur(6px)',\n ...dir,\n },\n visible: {\n opacity: 1,\n filter: 'blur(0px)',\n transform: 'translateY(0px) translateX(0px)',\n transition: {\n delay,\n duration: 0.5,\n staggerChildren: 0.1,\n },\n },\n };\n};\n\nexport type ContainerAnimationProps<T extends ElementType = 'div'> =\n ComponentProps<'div'> &\n ComponentProps<T> & {\n position?: 'top' | 'bottom' | 'left' | 'right';\n delay?: number;\n space?: number;\n duration?: number;\n distance?: [number, number];\n hideNotInView?: boolean;\n as?: T | string;\n className?: string;\n };\n\nconst ContainerAnimation = <T extends ElementType = 'div'>({\n className,\n children,\n position = 'top',\n delay = 0,\n space = 20,\n duration = 0.8,\n as: As = 'div',\n distance = [95, 5],\n hideNotInView = false,\n ...props\n}: ContainerAnimationProps<T>) => {\n const ref = useRef<HTMLElement>(null);\n const isInView = useInView(ref, {\n once: true,\n margin:\n `-${100 - (distance[0] || 0)}% 0% -${(distance[1] as number) || 0}% 0%` as any,\n });\n\n const variants = getVariants(position, space, delay);\n\n return (\n <motion.div\n animate={isInView ? 'visible' : 'hidden'}\n className={cn('initial-opacity', className)}\n initial=\"hidden\"\n transition={{ duration }}\n variants={variants}\n {...props}\n ref={ref}\n >\n {(!hideNotInView || isInView) && children}\n </motion.div>\n );\n};\n\nexport { ContainerAnimation };\n"],"x_google_ignoreList":[0,1,2],"mappings":";;;;;;;;;AAAA,SAAS,gBAAgB,mBAAmB,OAAO,eAAe;AAC9D,KAAI,6BAA6B,YAC7B,QAAO,CAAC,kBAAkB;UAErB,OAAO,sBAAsB,UAAU;EAC5C,IAAI,OAAO;AACX,MAAI,MACA,QAAO,MAAM;EAEjB,MAAM,WAAW,gBAAgB,sBAC7B,KAAK,iBAAiB,kBAAkB;AAC5C,SAAO,WAAW,MAAM,KAAK,SAAS,GAAG,EAAE;;AAE/C,QAAO,MAAM,KAAK,kBAAkB;;;;;ACXxC,MAAM,aAAa;CACf,MAAM;CACN,KAAK;CACR;AACD,SAAS,OAAO,mBAAmB,SAAS,EAAE,MAAM,QAAQ,YAAY,SAAS,WAAW,EAAE,EAAE;CAC5F,MAAM,WAAW,gBAAgB,kBAAkB;CACnD,MAAM,sCAAsB,IAAI,SAAS;CACzC,MAAM,wBAAwB,YAAY;AACtC,UAAQ,SAAS,UAAU;GACvB,MAAM,QAAQ,oBAAoB,IAAI,MAAM,OAAO;;;;;AAKnD,OAAI,MAAM,mBAAmB,QAAQ,MAAM,CACvC;AACJ,OAAI,MAAM,gBAAgB;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AiB;IAClB;GACF;EACF;;AAgBH,MAAM,sBAAqD,EACzD,WACA,UACA,WAAW,OACX,QAAQ,GACR,QAAQ,IACR,WAAW,IACX,IAAI,KAAK,OACT,WAAW,CAAC,IAAI,EAAE,EAClB,gBAAgB,MAChB,GAAG,YAC6B;CAChC,MAAM,MAAM,OAAoB,KAAK;CACrC,MAAM,WAAW,UAAU,KAAK;EAC9B,MAAM;EACN,QACE,IAAI,OAAO,SAAS,MAAM,GAAG,QAAS,SAAS,MAAiB,EAAE;EACrE,CAAC;CAEF,MAAM,WAAW,YAAY,UAAU,OAAO,MAAM;AAEpD,QACE,oBAAC,OAAO;EACN,SAAS,WAAW,YAAY;EAChC,WAAW,GAAG,mBAAmB,UAAU;EAC3C,SAAQ;EACR,YAAY,EAAE,UAAU;EACd;EACV,GAAI;EACC;aAEH,CAAC,iBAAiB,aAAa;GACtB"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { FieldPath, FieldValues, UseControllerProps } from "react-hook-form";
|
|
2
|
+
import * as react_jsx_runtime4 from "react/jsx-runtime";
|
|
3
|
+
import { Matcher } from "react-day-picker";
|
|
4
|
+
|
|
5
|
+
//#region src/components/date-field/DateField.d.ts
|
|
6
|
+
interface DateFieldProps<TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> extends Omit<UseControllerProps<TFieldValues, TFieldName>, 'disabled'> {
|
|
7
|
+
label: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
placeholder?: string;
|
|
10
|
+
className?: string;
|
|
11
|
+
disabled?: Matcher | Matcher[] | undefined;
|
|
12
|
+
inputDisabled?: boolean;
|
|
13
|
+
initialValue?: Date;
|
|
14
|
+
endMonth?: Date;
|
|
15
|
+
required?: boolean;
|
|
16
|
+
help?: string;
|
|
17
|
+
}
|
|
18
|
+
declare function DateField<TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({
|
|
19
|
+
name,
|
|
20
|
+
label,
|
|
21
|
+
description,
|
|
22
|
+
inputDisabled,
|
|
23
|
+
endMonth,
|
|
24
|
+
className,
|
|
25
|
+
disabled,
|
|
26
|
+
initialValue,
|
|
27
|
+
required,
|
|
28
|
+
help
|
|
29
|
+
}: DateFieldProps<TFieldValues, TFieldName>): react_jsx_runtime4.JSX.Element;
|
|
30
|
+
//#endregion
|
|
31
|
+
export { DateField, type DateFieldProps };
|
|
32
|
+
//# sourceMappingURL=date-field.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date-field.d.ts","names":[],"sources":["../src/components/date-field/DateField.tsx"],"sourcesContent":[],"mappings":";;;;;UA2BiB,oCACM,cAAc,gCAChB,UAAU,gBAAgB,UAAU,uBAC/C,KAAK,mBAAmB,cAAc;;;EAH/B,WAAA,CAAA,EAAA,MAAc;EACR,SAAA,CAAA,EAAA,MAAA;EAAc,QAAA,CAAA,EAOxB,OAPwB,GAOd,OAPc,EAAA,GAAA,SAAA;EACN,aAAA,CAAA,EAAA,OAAA;EAAV,YAAA,CAAA,EAQJ,IARI;EAAoC,QAAA,CAAA,EAS5C,IAT4C;EAAV,QAAA,CAAA,EAAA,OAAA;EACb,IAAA,CAAA,EAAA,MAAA;;iBAazB,SAbM,CAAA,qBAcQ,WAdR,GAcsB,WAdtB,EAAA,mBAeM,SAfN,CAegB,YAfhB,CAAA,GAegC,SAfhC,CAe0C,YAf1C,CAAA,CAAA,CAAA;EAAA,IAAA;EAAA,KAAA;EAAA,WAAA;EAAA,aAAA;EAAA,QAAA;EAAA,SAAA;EAAA,QAAA;EAAA,YAAA;EAAA,QAAA;EAAA;AAAA,CAAA,EA2BZ,cA3BY,CA2BG,YA3BH,EA2BiB,UA3BjB,CAAA,CAAA,EA2B4B,kBAAA,CAAA,GAAA,CAAA,OA3B5B"}
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
import { t as cn } from "./utils-C8_amEgK.js";
|
|
5
|
+
import "./label-Bkg7B2j8.js";
|
|
6
|
+
import { n as withMask, t as Input } from "./input-Bs61WBGW.js";
|
|
7
|
+
import { a as FormLabel, i as FormItem, n as FormDescription, o as FormMessage, r as FormField, t as InputHelp } from "./input-help-BRDK0-yu.js";
|
|
8
|
+
import { n as buttonVariants, t as Button } from "./button-B3nLhVyZ.js";
|
|
9
|
+
import { n as PopoverContent, r as PopoverTrigger, t as Popover } from "./popover-DwlKLFCp.js";
|
|
10
|
+
import { useFormContext } from "react-hook-form";
|
|
11
|
+
import * as React from "react";
|
|
12
|
+
import { useEffect, useState } from "react";
|
|
13
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
14
|
+
import { ChevronLeft, ChevronRight } from "lucide-react";
|
|
15
|
+
import { differenceInCalendarDays, isValid, parse } from "date-fns";
|
|
16
|
+
import { DayPicker, labelNext, labelPrevious, useDayPicker } from "react-day-picker";
|
|
17
|
+
import { ptBR } from "date-fns/locale";
|
|
18
|
+
|
|
19
|
+
//#region src/components/ui/calendar.tsx
|
|
20
|
+
function Calendar({ className, classNames, showOutsideDays = true, yearRange = 12, numberOfMonths,...props }) {
|
|
21
|
+
const [navView, setNavView] = React.useState("days");
|
|
22
|
+
const [displayYears, setDisplayYears] = React.useState(React.useMemo(() => {
|
|
23
|
+
const currentYear = (/* @__PURE__ */ new Date()).getFullYear();
|
|
24
|
+
return {
|
|
25
|
+
from: currentYear - Math.floor(yearRange / 2 - 1),
|
|
26
|
+
to: currentYear + Math.ceil(yearRange / 2)
|
|
27
|
+
};
|
|
28
|
+
}, [yearRange]));
|
|
29
|
+
const { onNextClick, onPrevClick, startMonth, endMonth } = props;
|
|
30
|
+
const columnsDisplayed = navView === "years" ? 1 : numberOfMonths;
|
|
31
|
+
return /* @__PURE__ */ jsx(DayPicker, {
|
|
32
|
+
className: cn("p-3", className),
|
|
33
|
+
classNames: {
|
|
34
|
+
months: "flex flex-col relative sm:flex-row gap-y-4 sm:gap-y-0",
|
|
35
|
+
month_caption: "flex justify-center h-7 mx-10 relative items-center",
|
|
36
|
+
weekdays: "flex flex-row",
|
|
37
|
+
weekday: "text-muted-foreground w-8 font-normal text-[0.8rem]",
|
|
38
|
+
month: "gap-y-4 overflow-x-hidden w-full",
|
|
39
|
+
caption: "flex justify-center pt-1 relative items-center",
|
|
40
|
+
caption_label: "text-sm font-medium truncate",
|
|
41
|
+
button_next: cn(buttonVariants({
|
|
42
|
+
variant: "outline",
|
|
43
|
+
className: "absolute right-0 h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"
|
|
44
|
+
})),
|
|
45
|
+
button_previous: cn(buttonVariants({
|
|
46
|
+
variant: "outline",
|
|
47
|
+
className: "absolute left-0 h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"
|
|
48
|
+
})),
|
|
49
|
+
nav: "flex items-start",
|
|
50
|
+
month_grid: "mt-4",
|
|
51
|
+
week: "flex w-full mt-1",
|
|
52
|
+
day: "p-0 transition-colors size-8 text-sm flex-1 flex items-center justify-center has-[button]:hover:bg-accent/90! rounded-md has-[button]:hover:aria-selected:bg-primary/50! has-[button]:hover:text-foreground has-[button]:hover:aria-selected:text-foreground",
|
|
53
|
+
day_button: cn(buttonVariants({ variant: "ghost" }), "size-8 p-0 font-normal transition-none hover:bg-transparent hover:text-inherit aria-selected:opacity-100"),
|
|
54
|
+
range_start: "day-range-start rounded-s-md",
|
|
55
|
+
range_end: "day-range-end rounded-e-md",
|
|
56
|
+
selected: "bg-primary text-primary-foreground hover:bg-primary! hover:text-primary-foreground focus:bg-primary! focus:text-primary-foreground",
|
|
57
|
+
today: "bg-accent text-accent-foreground",
|
|
58
|
+
outside: "day-outside text-muted-foreground opacity-50 aria-selected:bg-accent/50 aria-selected:text-muted-foreground aria-selected:opacity-30",
|
|
59
|
+
disabled: "text-muted-foreground opacity-50",
|
|
60
|
+
range_middle: "aria-selected:bg-accent hover:aria-selected:bg-accent! rounded-none aria-selected:text-accent-foreground hover:aria-selected:text-accent-foreground",
|
|
61
|
+
hidden: "invisible",
|
|
62
|
+
...classNames
|
|
63
|
+
},
|
|
64
|
+
components: {
|
|
65
|
+
Chevron: ({ orientation }) => {
|
|
66
|
+
return /* @__PURE__ */ jsx(orientation === "left" ? ChevronLeft : ChevronRight, { className: "h-4 w-4" });
|
|
67
|
+
},
|
|
68
|
+
Nav: ({ className: className$1, children,...props$1 }) => {
|
|
69
|
+
const { nextMonth, previousMonth, goToMonth } = useDayPicker();
|
|
70
|
+
const isPreviousDisabled = (() => {
|
|
71
|
+
if (navView === "years") return startMonth && differenceInCalendarDays(new Date(displayYears.from - 1, 0, 1), startMonth) < 0 || endMonth && differenceInCalendarDays(new Date(displayYears.from - 1, 0, 1), endMonth) > 0;
|
|
72
|
+
return !previousMonth;
|
|
73
|
+
})();
|
|
74
|
+
const isNextDisabled = (() => {
|
|
75
|
+
if (navView === "years") return startMonth && differenceInCalendarDays(new Date(displayYears.to + 1, 0, 1), startMonth) < 0 || endMonth && differenceInCalendarDays(new Date(displayYears.to + 1, 0, 1), endMonth) > 0;
|
|
76
|
+
return !nextMonth;
|
|
77
|
+
})();
|
|
78
|
+
const handlePreviousClick = React.useCallback(() => {
|
|
79
|
+
if (!previousMonth) return;
|
|
80
|
+
if (navView === "years") {
|
|
81
|
+
setDisplayYears((prev) => ({
|
|
82
|
+
from: prev.from - (prev.to - prev.from + 1),
|
|
83
|
+
to: prev.to - (prev.to - prev.from + 1)
|
|
84
|
+
}));
|
|
85
|
+
onPrevClick?.(new Date(displayYears.from - (displayYears.to - displayYears.from), 0, 1));
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
goToMonth(previousMonth);
|
|
89
|
+
onPrevClick?.(previousMonth);
|
|
90
|
+
}, [previousMonth, goToMonth]);
|
|
91
|
+
const handleNextClick = React.useCallback(() => {
|
|
92
|
+
if (navView === "years") {
|
|
93
|
+
setDisplayYears((prev) => ({
|
|
94
|
+
from: prev.from + (prev.to - prev.from + 1),
|
|
95
|
+
to: prev.to + (prev.to - prev.from + 1)
|
|
96
|
+
}));
|
|
97
|
+
onNextClick?.(new Date(displayYears.from + (displayYears.to - displayYears.from), 0, 1));
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
if (!nextMonth) return;
|
|
101
|
+
goToMonth(nextMonth);
|
|
102
|
+
onNextClick?.(nextMonth);
|
|
103
|
+
}, [goToMonth, nextMonth]);
|
|
104
|
+
return /* @__PURE__ */ jsxs("nav", {
|
|
105
|
+
className: cn("flex items-center", className$1),
|
|
106
|
+
children: [/* @__PURE__ */ jsx(Button, {
|
|
107
|
+
"aria-label": navView === "years" ? `Go to the previous ${displayYears.to - displayYears.from + 1} years` : labelPrevious(previousMonth),
|
|
108
|
+
className: "absolute left-0 h-7 w-7 bg-transparent p-0 opacity-80 hover:opacity-100",
|
|
109
|
+
disabled: isPreviousDisabled,
|
|
110
|
+
onClick: handlePreviousClick,
|
|
111
|
+
tabIndex: isPreviousDisabled ? void 0 : -1,
|
|
112
|
+
type: "button",
|
|
113
|
+
variant: "outline",
|
|
114
|
+
children: /* @__PURE__ */ jsx(ChevronLeft, { className: "h-4 w-4" })
|
|
115
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
116
|
+
"aria-label": navView === "years" ? `Go to the next ${displayYears.to - displayYears.from + 1} years` : labelNext(nextMonth),
|
|
117
|
+
className: "absolute right-0 h-7 w-7 bg-transparent p-0 opacity-80 hover:opacity-100",
|
|
118
|
+
disabled: isNextDisabled,
|
|
119
|
+
onClick: handleNextClick,
|
|
120
|
+
tabIndex: isNextDisabled ? void 0 : -1,
|
|
121
|
+
type: "button",
|
|
122
|
+
variant: "outline",
|
|
123
|
+
children: /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4" })
|
|
124
|
+
})]
|
|
125
|
+
});
|
|
126
|
+
},
|
|
127
|
+
CaptionLabel: ({ children }) => /* @__PURE__ */ jsx(Button, {
|
|
128
|
+
className: "h-7 w-full truncate text-sm font-medium capitalize",
|
|
129
|
+
onClick: () => setNavView((prev) => prev === "days" ? "years" : "days"),
|
|
130
|
+
size: "sm",
|
|
131
|
+
variant: "ghost",
|
|
132
|
+
children: navView === "days" ? children : displayYears.from + " - " + displayYears.to
|
|
133
|
+
}),
|
|
134
|
+
MonthGrid: ({ className: className$1, children,...props$1 }) => {
|
|
135
|
+
const { goToMonth } = useDayPicker();
|
|
136
|
+
if (navView === "years") return /* @__PURE__ */ jsx("div", {
|
|
137
|
+
className: cn("grid grid-cols-4 gap-y-1", className$1),
|
|
138
|
+
...props$1,
|
|
139
|
+
children: Array.from({ length: displayYears.to - displayYears.from + 1 }, (_, i) => {
|
|
140
|
+
const isBefore = differenceInCalendarDays(new Date(displayYears.from + i, 12, 31), startMonth) < 0;
|
|
141
|
+
const isAfter = differenceInCalendarDays(new Date(displayYears.from + i, 0, 0), endMonth) > 0;
|
|
142
|
+
const isDisabled = isBefore || isAfter;
|
|
143
|
+
return /* @__PURE__ */ jsx(Button, {
|
|
144
|
+
className: cn("h-10 w-full text-sm font-normal text-foreground", displayYears.from + i === (/* @__PURE__ */ new Date()).getFullYear() && "bg-accent font-medium text-accent-foreground"),
|
|
145
|
+
disabled: navView === "years" ? isDisabled : void 0,
|
|
146
|
+
onClick: () => {
|
|
147
|
+
setNavView("days");
|
|
148
|
+
goToMonth(new Date(displayYears.from + i, (/* @__PURE__ */ new Date()).getMonth()));
|
|
149
|
+
},
|
|
150
|
+
variant: "ghost",
|
|
151
|
+
children: displayYears.from + i
|
|
152
|
+
}, i);
|
|
153
|
+
})
|
|
154
|
+
});
|
|
155
|
+
return /* @__PURE__ */ jsx("table", {
|
|
156
|
+
className: className$1,
|
|
157
|
+
...props$1,
|
|
158
|
+
children
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
numberOfMonths: columnsDisplayed,
|
|
163
|
+
showOutsideDays,
|
|
164
|
+
style: { width: 248.8 * (columnsDisplayed ?? 1) + "px" },
|
|
165
|
+
...props
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
Calendar.displayName = "Calendar";
|
|
169
|
+
|
|
170
|
+
//#endregion
|
|
171
|
+
//#region src/components/ui/input-date-field.tsx
|
|
172
|
+
const InputDateField = ({ field, disabled, onFinish, id,...props }) => {
|
|
173
|
+
const [inputValue, setInputValue] = useState("");
|
|
174
|
+
const handleChange = (e) => {
|
|
175
|
+
const parts = e.target.value.split("/");
|
|
176
|
+
let day = parts[0];
|
|
177
|
+
let month = parts[1];
|
|
178
|
+
if (day && Number(day) > 31) parts[0] = day.slice(0, 1).padStart(2, "0");
|
|
179
|
+
if (month && Number(month) > 12) parts[1] = month.slice(0, 1).padStart(2, "0");
|
|
180
|
+
const newValue = parts.join("/");
|
|
181
|
+
setInputValue(parts.join("/"));
|
|
182
|
+
if (newValue.length === 10) {
|
|
183
|
+
const parsedDate = parse(newValue, "dd/MM/yyyy", /* @__PURE__ */ new Date());
|
|
184
|
+
if (isValid(parsedDate)) {
|
|
185
|
+
field.onChange(parsedDate);
|
|
186
|
+
onFinish?.();
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
useEffect(() => {
|
|
191
|
+
if (field.value) setInputValue((typeof field?.value === "string" ? new Date(field?.value) : field?.value)?.toLocaleDateString("pt-BR"));
|
|
192
|
+
else setInputValue("");
|
|
193
|
+
}, [field.value]);
|
|
194
|
+
return /* @__PURE__ */ jsx(Input, {
|
|
195
|
+
autoComplete: "off",
|
|
196
|
+
className: "w-full outline-hidden",
|
|
197
|
+
id,
|
|
198
|
+
onChange: handleChange,
|
|
199
|
+
placeholder: "Selecione a data",
|
|
200
|
+
readOnly: disabled,
|
|
201
|
+
ref: withMask("99/99/9999", { undoOnEscape: false }),
|
|
202
|
+
value: inputValue,
|
|
203
|
+
...props
|
|
204
|
+
});
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
//#endregion
|
|
208
|
+
//#region src/components/date-field/DateField.tsx
|
|
209
|
+
function DateField({ name, label, description, inputDisabled, endMonth, className, disabled, initialValue, required, help }) {
|
|
210
|
+
const form = useFormContext();
|
|
211
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
212
|
+
return /* @__PURE__ */ jsx(FormField, {
|
|
213
|
+
control: form.control,
|
|
214
|
+
defaultValue: initialValue,
|
|
215
|
+
name,
|
|
216
|
+
render: ({ field, fieldState }) => /* @__PURE__ */ jsxs(FormItem, {
|
|
217
|
+
className,
|
|
218
|
+
id: `date-${name.replace(".", "-")}`,
|
|
219
|
+
children: [
|
|
220
|
+
/* @__PURE__ */ jsxs("div", {
|
|
221
|
+
className: "flex items-end gap-1.5",
|
|
222
|
+
children: [/* @__PURE__ */ jsxs(FormLabel, {
|
|
223
|
+
htmlFor: name,
|
|
224
|
+
children: [
|
|
225
|
+
label,
|
|
226
|
+
":",
|
|
227
|
+
required && /* @__PURE__ */ jsx("span", {
|
|
228
|
+
className: "text-red-500 text-lg leading-[1px]",
|
|
229
|
+
children: "*"
|
|
230
|
+
})
|
|
231
|
+
]
|
|
232
|
+
}), /* @__PURE__ */ jsx(InputHelp, {
|
|
233
|
+
help,
|
|
234
|
+
name
|
|
235
|
+
})]
|
|
236
|
+
}),
|
|
237
|
+
/* @__PURE__ */ jsxs(Popover, {
|
|
238
|
+
onOpenChange: setIsOpen,
|
|
239
|
+
open: !inputDisabled && isOpen,
|
|
240
|
+
children: [/* @__PURE__ */ jsx(PopoverTrigger, {
|
|
241
|
+
className: "w-full mt-0! outline-hidden",
|
|
242
|
+
onClick: (event) => {
|
|
243
|
+
event.preventDefault();
|
|
244
|
+
event.stopPropagation();
|
|
245
|
+
},
|
|
246
|
+
tabIndex: -1,
|
|
247
|
+
children: /* @__PURE__ */ jsx(InputDateField, {
|
|
248
|
+
className: cn(fieldState.error && "border-destructive"),
|
|
249
|
+
disabled: inputDisabled,
|
|
250
|
+
field,
|
|
251
|
+
id: name,
|
|
252
|
+
onFinish: () => setIsOpen(false),
|
|
253
|
+
onFocus: () => setIsOpen(true)
|
|
254
|
+
})
|
|
255
|
+
}), /* @__PURE__ */ jsx(PopoverContent, {
|
|
256
|
+
className: "flex justify-center w-fit p-0",
|
|
257
|
+
onOpenAutoFocus: (e) => e.preventDefault(),
|
|
258
|
+
children: /* @__PURE__ */ jsx(Calendar, {
|
|
259
|
+
defaultMonth: field.value || /* @__PURE__ */ new Date(),
|
|
260
|
+
disabled,
|
|
261
|
+
endMonth,
|
|
262
|
+
locale: ptBR,
|
|
263
|
+
mode: "single",
|
|
264
|
+
onSelect: (date) => {
|
|
265
|
+
field.onChange(date);
|
|
266
|
+
setIsOpen(false);
|
|
267
|
+
},
|
|
268
|
+
selected: field.value
|
|
269
|
+
}, `${name}-${field.value?.toString()}`)
|
|
270
|
+
})]
|
|
271
|
+
}),
|
|
272
|
+
/* @__PURE__ */ jsx(FormDescription, { children: description }),
|
|
273
|
+
fieldState.error && /* @__PURE__ */ jsx(FormMessage, {})
|
|
274
|
+
]
|
|
275
|
+
})
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
//#endregion
|
|
280
|
+
export { DateField };
|
|
281
|
+
//# sourceMappingURL=date-field.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date-field.js","names":["props","className","InputDateField: React.FC<\n {\n field: ControllerRenderProps<any, string>;\n disabled?: boolean;\n onFinish?: () => void;\n id?: string;\n } & ComponentProps<typeof Input>\n>"],"sources":["../src/components/ui/calendar.tsx","../src/components/ui/input-date-field.tsx","../src/components/date-field/DateField.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\n\nimport { Button, buttonVariants } from '@/components/ui/button';\n\nimport { ChevronLeft, ChevronRight } from 'lucide-react';\n\nimport { cn } from '@/lib/utils';\nimport { differenceInCalendarDays } from 'date-fns';\nimport {\n DayPicker,\n labelNext,\n labelPrevious,\n useDayPicker,\n} from 'react-day-picker';\n\nexport type CalendarProps = React.ComponentProps<typeof DayPicker> & {\n /**\n * In the year view, the number of years to display at once.\n * @default 12\n */\n yearRange?: number;\n};\n\nfunction Calendar({\n className,\n classNames,\n showOutsideDays = true,\n yearRange = 12,\n numberOfMonths,\n ...props\n}: CalendarProps) {\n const [navView, setNavView] = React.useState<'days' | 'years'>('days');\n const [displayYears, setDisplayYears] = React.useState<{\n from: number;\n to: number;\n }>(\n React.useMemo(() => {\n const currentYear = new Date().getFullYear();\n return {\n from: currentYear - Math.floor(yearRange / 2 - 1),\n to: currentYear + Math.ceil(yearRange / 2),\n };\n }, [yearRange])\n );\n\n const { onNextClick, onPrevClick, startMonth, endMonth } = props;\n\n const columnsDisplayed = navView === 'years' ? 1 : numberOfMonths;\n\n return (\n <DayPicker\n className={cn('p-3', className)}\n classNames={{\n months: 'flex flex-col relative sm:flex-row gap-y-4 sm:gap-y-0',\n month_caption: 'flex justify-center h-7 mx-10 relative items-center',\n weekdays: 'flex flex-row',\n weekday: 'text-muted-foreground w-8 font-normal text-[0.8rem]',\n month: 'gap-y-4 overflow-x-hidden w-full',\n caption: 'flex justify-center pt-1 relative items-center',\n caption_label: 'text-sm font-medium truncate',\n button_next: cn(\n buttonVariants({\n variant: 'outline',\n className:\n 'absolute right-0 h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100',\n })\n ),\n button_previous: cn(\n buttonVariants({\n variant: 'outline',\n className:\n 'absolute left-0 h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100',\n })\n ),\n nav: 'flex items-start',\n month_grid: 'mt-4',\n week: 'flex w-full mt-1',\n day: 'p-0 transition-colors size-8 text-sm flex-1 flex items-center justify-center has-[button]:hover:bg-accent/90! rounded-md has-[button]:hover:aria-selected:bg-primary/50! has-[button]:hover:text-foreground has-[button]:hover:aria-selected:text-foreground',\n day_button: cn(\n buttonVariants({ variant: 'ghost' }),\n 'size-8 p-0 font-normal transition-none hover:bg-transparent hover:text-inherit aria-selected:opacity-100'\n ),\n range_start: 'day-range-start rounded-s-md',\n range_end: 'day-range-end rounded-e-md',\n selected:\n 'bg-primary text-primary-foreground hover:bg-primary! hover:text-primary-foreground focus:bg-primary! focus:text-primary-foreground',\n today: 'bg-accent text-accent-foreground',\n outside:\n 'day-outside text-muted-foreground opacity-50 aria-selected:bg-accent/50 aria-selected:text-muted-foreground aria-selected:opacity-30',\n disabled: 'text-muted-foreground opacity-50',\n range_middle:\n 'aria-selected:bg-accent hover:aria-selected:bg-accent! rounded-none aria-selected:text-accent-foreground hover:aria-selected:text-accent-foreground',\n hidden: 'invisible',\n ...classNames,\n }}\n components={{\n Chevron: ({ orientation }) => {\n const Icon = orientation === 'left' ? ChevronLeft : ChevronRight;\n return <Icon className=\"h-4 w-4\" />;\n },\n Nav: ({ className, children, ...props }) => {\n const { nextMonth, previousMonth, goToMonth } = useDayPicker();\n\n const isPreviousDisabled = (() => {\n if (navView === 'years') {\n return (\n (startMonth &&\n differenceInCalendarDays(\n new Date(displayYears.from - 1, 0, 1),\n startMonth\n ) < 0) ||\n (endMonth &&\n differenceInCalendarDays(\n new Date(displayYears.from - 1, 0, 1),\n endMonth\n ) > 0)\n );\n }\n return !previousMonth;\n })();\n\n const isNextDisabled = (() => {\n if (navView === 'years') {\n return (\n (startMonth &&\n differenceInCalendarDays(\n new Date(displayYears.to + 1, 0, 1),\n startMonth\n ) < 0) ||\n (endMonth &&\n differenceInCalendarDays(\n new Date(displayYears.to + 1, 0, 1),\n endMonth\n ) > 0)\n );\n }\n return !nextMonth;\n })();\n\n const handlePreviousClick = React.useCallback(() => {\n if (!previousMonth) return;\n if (navView === 'years') {\n setDisplayYears((prev) => ({\n from: prev.from - (prev.to - prev.from + 1),\n to: prev.to - (prev.to - prev.from + 1),\n }));\n onPrevClick?.(\n new Date(\n displayYears.from - (displayYears.to - displayYears.from),\n 0,\n 1\n )\n );\n return;\n }\n goToMonth(previousMonth);\n onPrevClick?.(previousMonth);\n }, [previousMonth, goToMonth]);\n\n const handleNextClick = React.useCallback(() => {\n if (navView === 'years') {\n setDisplayYears((prev) => ({\n from: prev.from + (prev.to - prev.from + 1),\n to: prev.to + (prev.to - prev.from + 1),\n }));\n onNextClick?.(\n new Date(\n displayYears.from + (displayYears.to - displayYears.from),\n 0,\n 1\n )\n );\n return;\n }\n if (!nextMonth) return;\n goToMonth(nextMonth);\n onNextClick?.(nextMonth);\n }, [goToMonth, nextMonth]);\n\n return (\n <nav className={cn('flex items-center', className)}>\n <Button\n aria-label={\n navView === 'years'\n ? `Go to the previous ${\n displayYears.to - displayYears.from + 1\n } years`\n : labelPrevious(previousMonth)\n }\n className=\"absolute left-0 h-7 w-7 bg-transparent p-0 opacity-80 hover:opacity-100\"\n disabled={isPreviousDisabled}\n onClick={handlePreviousClick}\n tabIndex={isPreviousDisabled ? undefined : -1}\n type=\"button\"\n variant=\"outline\"\n >\n <ChevronLeft className=\"h-4 w-4\" />\n </Button>\n\n <Button\n aria-label={\n navView === 'years'\n ? `Go to the next ${\n displayYears.to - displayYears.from + 1\n } years`\n : labelNext(nextMonth)\n }\n className=\"absolute right-0 h-7 w-7 bg-transparent p-0 opacity-80 hover:opacity-100\"\n disabled={isNextDisabled}\n onClick={handleNextClick}\n tabIndex={isNextDisabled ? undefined : -1}\n type=\"button\"\n variant=\"outline\"\n >\n <ChevronRight className=\"h-4 w-4\" />\n </Button>\n </nav>\n );\n },\n CaptionLabel: ({ children }) => (\n <Button\n className=\"h-7 w-full truncate text-sm font-medium capitalize\"\n onClick={() =>\n setNavView((prev) => (prev === 'days' ? 'years' : 'days'))\n }\n size=\"sm\"\n variant=\"ghost\"\n >\n {navView === 'days'\n ? children\n : displayYears.from + ' - ' + displayYears.to}\n </Button>\n ),\n MonthGrid: ({ className, children, ...props }) => {\n const { goToMonth } = useDayPicker();\n if (navView === 'years') {\n return (\n <div\n className={cn('grid grid-cols-4 gap-y-1', className)}\n {...props}\n >\n {Array.from(\n { length: displayYears.to - displayYears.from + 1 },\n (_, i) => {\n const isBefore =\n differenceInCalendarDays(\n new Date(displayYears.from + i, 12, 31),\n startMonth!\n ) < 0;\n\n const isAfter =\n differenceInCalendarDays(\n new Date(displayYears.from + i, 0, 0),\n endMonth!\n ) > 0;\n\n const isDisabled = isBefore || isAfter;\n return (\n <Button\n className={cn(\n 'h-10 w-full text-sm font-normal text-foreground',\n displayYears.from + i === new Date().getFullYear() &&\n 'bg-accent font-medium text-accent-foreground'\n )}\n disabled={navView === 'years' ? isDisabled : undefined}\n key={i}\n onClick={() => {\n setNavView('days');\n goToMonth(\n new Date(\n displayYears.from + i,\n new Date().getMonth()\n )\n );\n }}\n variant=\"ghost\"\n >\n {displayYears.from + i}\n </Button>\n );\n }\n )}\n </div>\n );\n }\n return (\n <table className={className} {...props}>\n {children}\n </table>\n );\n },\n }}\n numberOfMonths={columnsDisplayed}\n showOutsideDays={showOutsideDays}\n style={{\n width: 248.8 * (columnsDisplayed ?? 1) + 'px',\n }}\n {...props}\n />\n );\n}\nCalendar.displayName = 'Calendar';\n\nexport { Calendar };\n","import { ComponentProps, useEffect, useState } from 'react';\n\nimport type { ControllerRenderProps } from 'react-hook-form';\nimport withMask from '@/hooks/with-mask';\n\nimport { isValid, parse } from 'date-fns';\nimport { Input } from './input';\n\nconst InputDateField: React.FC<\n {\n field: ControllerRenderProps<any, string>;\n disabled?: boolean;\n onFinish?: () => void;\n id?: string;\n } & ComponentProps<typeof Input>\n> = ({ field, disabled, onFinish, id, ...props }) => {\n const [inputValue, setInputValue] = useState('');\n\n const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const parts = e.target.value.split('/');\n let day = parts[0];\n let month = parts[1];\n if (day && Number(day) > 31) {\n parts[0] = day.slice(0, 1).padStart(2, '0');\n }\n if (month && Number(month) > 12) {\n parts[1] = month.slice(0, 1).padStart(2, '0');\n }\n\n const newValue = parts.join('/');\n setInputValue(parts.join('/'));\n\n if (newValue.length === 10) {\n const parsedDate = parse(newValue, 'dd/MM/yyyy', new Date());\n if (isValid(parsedDate)) {\n field.onChange(parsedDate);\n onFinish?.();\n }\n }\n };\n\n useEffect(() => {\n if (field.value) {\n const value =\n typeof field?.value === 'string'\n ? new Date(field?.value)\n : field?.value;\n setInputValue(value?.toLocaleDateString('pt-BR'));\n } else {\n setInputValue('');\n }\n }, [field.value]);\n\n return (\n <Input\n autoComplete=\"off\"\n className=\"w-full outline-hidden\"\n id={id}\n onChange={handleChange}\n placeholder=\"Selecione a data\"\n readOnly={disabled}\n ref={\n withMask('99/99/9999', {\n undoOnEscape: false,\n }) as any\n }\n value={inputValue}\n {...props}\n />\n );\n};\n\nexport { InputDateField };\n","'use client';\n\nimport { useState } from 'react';\n\nimport {\n type FieldPath,\n type FieldValues,\n type UseControllerProps,\n useFormContext,\n} from 'react-hook-form';\n\nimport { Calendar } from '@/ui/calendar';\nimport {\n FormDescription,\n FormField,\n FormItem,\n FormLabel,\n FormMessage,\n} from '@/ui/form';\nimport { InputDateField } from '@/ui/input-date-field';\nimport { InputHelp } from '@/ui/input-help';\nimport { Popover, PopoverContent, PopoverTrigger } from '@/ui/popover';\n\nimport { cn } from '@/lib/utils';\nimport { ptBR } from 'date-fns/locale';\nimport type { Matcher } from 'react-day-picker';\n\nexport interface DateFieldProps<\n TFieldValues extends FieldValues = FieldValues,\n TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n> extends Omit<UseControllerProps<TFieldValues, TFieldName>, 'disabled'> {\n label: string;\n description?: string;\n placeholder?: string;\n className?: string;\n disabled?: Matcher | Matcher[] | undefined;\n inputDisabled?: boolean;\n initialValue?: Date;\n endMonth?: Date;\n required?: boolean;\n help?: string;\n}\n\nfunction DateField<\n TFieldValues extends FieldValues = FieldValues,\n TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n>({\n name,\n label,\n description,\n inputDisabled,\n endMonth,\n className,\n disabled,\n initialValue,\n required,\n help,\n}: DateFieldProps<TFieldValues, TFieldName>) {\n const form = useFormContext();\n const [isOpen, setIsOpen] = useState(false);\n\n return (\n <FormField\n control={form.control}\n defaultValue={initialValue as any}\n name={name}\n render={({ field, fieldState }) => (\n <FormItem className={className} id={`date-${name.replace('.', '-')}`}>\n <div className=\"flex items-end gap-1.5\">\n <FormLabel htmlFor={name}>\n {label}:\n {required && (\n <span className=\"text-red-500 text-lg leading-[1px]\">*</span>\n )}\n </FormLabel>\n\n <InputHelp help={help} name={name} />\n </div>\n\n <Popover onOpenChange={setIsOpen} open={!inputDisabled && isOpen}>\n <PopoverTrigger\n className=\"w-full mt-0! outline-hidden\"\n onClick={(event) => {\n event.preventDefault();\n event.stopPropagation();\n }}\n tabIndex={-1}\n >\n <InputDateField\n className={cn(fieldState.error && 'border-destructive')}\n disabled={inputDisabled}\n field={field}\n id={name}\n onFinish={() => setIsOpen(false)}\n onFocus={() => setIsOpen(true)}\n />\n </PopoverTrigger>\n <PopoverContent\n className=\"flex justify-center w-fit p-0\"\n onOpenAutoFocus={(e) => e.preventDefault()}\n >\n <Calendar\n defaultMonth={field.value || new Date()}\n disabled={disabled}\n endMonth={endMonth}\n key={`${name}-${field.value?.toString()}`}\n locale={ptBR}\n mode=\"single\"\n onSelect={(date) => {\n field.onChange(date);\n setIsOpen(false);\n }}\n selected={field.value}\n />\n </PopoverContent>\n </Popover>\n\n <FormDescription>{description}</FormDescription>\n {fieldState.error && <FormMessage />}\n </FormItem>\n )}\n />\n );\n}\n\nexport { DateField };\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAyBA,SAAS,SAAS,EAChB,WACA,YACA,kBAAkB,MAClB,YAAY,IACZ,eACA,GAAG,SACa;CAChB,MAAM,CAAC,SAAS,cAAc,MAAM,SAA2B,OAAO;CACtE,MAAM,CAAC,cAAc,mBAAmB,MAAM,SAI5C,MAAM,cAAc;EAClB,MAAM,+BAAc,IAAI,MAAM,EAAC,aAAa;AAC5C,SAAO;GACL,MAAM,cAAc,KAAK,MAAM,YAAY,IAAI,EAAE;GACjD,IAAI,cAAc,KAAK,KAAK,YAAY,EAAE;GAC3C;IACA,CAAC,UAAU,CAAC,CAChB;CAED,MAAM,EAAE,aAAa,aAAa,YAAY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,UAAU,UAAU;AAClB,aAAM,gBAAgB;AACtB,aAAM,iBAAiB;;MAEzB,UAAU;gBAEV,oBAAC;OACC,WAAW,GAAG,WAAW,SAAS,qBAAqB;OACvD,UAAU;OACH;OACP,IAAI;OACJ,gBAAgB,UAAU,MAAM;OAChC,eAAe,UAAU,KAAK;QAC9B;OACa,EACjB,oBAAC;MACC,WAAU;MACV,kBAAkB,MAAM,EAAE,gBAAgB;gBAE1C,oBAAC;OACC,cAAc,MAAM,yBAAS,IAAI,MAAM;OAC7B;OACA;OAEV,QAAQ;OACR,MAAK;OACL,WAAW,SAAS;AAClB,cAAM,SAAS,KAAK;AACpB,kBAAU,MAAM;;OAElB,UAAU,MAAM;SAPX,GAAG,KAAK,GAAG,MAAM,OAAO,UAAU,GAQvC;OACa;MACT;IAEV,oBAAC,6BAAiB,cAA8B;IAC/C,WAAW,SAAS,oBAAC,gBAAc;;IAC3B;GAEb"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as cn } from "./utils-
|
|
1
|
+
import { t as cn } from "./utils-C8_amEgK.js";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
3
|
import inputmask from "inputmask";
|
|
4
4
|
|
|
@@ -119,7 +119,7 @@ function withMask(mask, options) {
|
|
|
119
119
|
|
|
120
120
|
//#endregion
|
|
121
121
|
//#region src/components/ui/input.tsx
|
|
122
|
-
function Input({ className, type
|
|
122
|
+
function Input({ className, type,...props }) {
|
|
123
123
|
return /* @__PURE__ */ jsx("input", {
|
|
124
124
|
className: cn("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input flex h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm", "focus-visible:border-ring focus-visible:ring-ring/75 focus-visible:ring-[2px]", "aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive ring-offset-[2px] transition-all duration-300", className),
|
|
125
125
|
"data-slot": "input",
|
|
@@ -130,4 +130,4 @@ function Input({ className, type, ...props }) {
|
|
|
130
130
|
|
|
131
131
|
//#endregion
|
|
132
132
|
export { withMask as n, Input as t };
|
|
133
|
-
//# sourceMappingURL=input-
|
|
133
|
+
//# sourceMappingURL=input-Bs61WBGW.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input-Bs61WBGW.js","names":["options: Options","masks: Record<string, Inputmask.Options>","isServer"],"sources":["../src/hooks/get-mask-options.ts","../src/hooks/is-server.ts","../src/hooks/module-interop.ts","../src/hooks/with-mask.ts","../src/components/ui/input.tsx"],"sourcesContent":["import type { Mask, Options } from './with-mask';\n\nexport default function getMaskOptions(\n mask?: Mask,\n _options?: Options\n): Options {\n const options: Options = {\n jitMasking: false,\n ..._options,\n };\n if (!mask) return options;\n\n const masks: Record<string, Inputmask.Options> = {\n datetime: {\n alias: 'datetime',\n ...options,\n },\n email: {\n alias: 'email',\n placeholder: '',\n ...options,\n },\n numeric: {\n alias: 'numeric',\n placeholder: '',\n ...options,\n },\n currency: {\n alias: 'currency',\n prefix: '$ ',\n placeholder: '',\n ...options,\n },\n decimal: {\n alias: 'decimal',\n placeholder: '',\n ...options,\n },\n integer: {\n alias: 'integer',\n placeholder: '',\n ...options,\n },\n percentage: {\n alias: 'percentage',\n placeholder: ' %',\n suffix: ' %',\n ...options,\n },\n url: {\n alias: 'url',\n placeholder: 'https://',\n ...options,\n },\n ip: {\n alias: 'ip',\n ...options,\n },\n mac: {\n alias: 'mac',\n ...options,\n },\n ssn: {\n alias: 'ssn',\n ...options,\n },\n\n // alias for brazilians <3\n // ty <3\n 'brl-currency': {\n alias: 'currency',\n prefix: 'R$ ',\n placeholder: '0,00',\n displayFormat: 'currency',\n radixPoint: ',',\n autoUnmask: true,\n ...options,\n },\n cpf: {\n mask: '999.999.999-99',\n placeholder: '___.___.___-__',\n ...options,\n },\n cnpj: {\n mask: '99.999.999/9999-99',\n placeholder: '__.___.___/____-__',\n ...options,\n },\n };\n\n if (typeof mask === 'string' && masks[mask]) return masks[mask];\n\n return {\n mask,\n ...options,\n };\n}\n","const isServer = !(\n typeof window !== 'undefined' && window.document?.createElement\n);\n\nexport default isServer;\n","/* eslint-disable @typescript-eslint/no-explicit-any */\n/**\n * Synchronously resolve the default value of a module.\n */\nexport default function interopDefaultSync<T = any>(module: T): T {\n if (typeof module === 'object' && module !== null) {\n if ('default' in module) {\n return module.default as T;\n }\n return module;\n }\n return module;\n}\n","import inputmask from 'inputmask';\nimport Inputmask from 'inputmask';\nimport getMaskOptions from './get-mask-options';\nimport isServer from './is-server';\nimport interopDefaultSync from './module-interop';\n\nexport type { UseFormRegister, UseFormRegisterReturn } from 'react-hook-form';\n\nexport type Mask =\n | 'datetime'\n | 'email'\n | 'numeric'\n | 'currency'\n | 'decimal'\n | 'integer'\n | 'percentage'\n | 'url'\n | 'ip'\n | 'mac'\n | 'ssn'\n | 'brl-currency'\n | 'cpf'\n | 'cnpj'\n | (string & {})\n | (string[] & {})\n | null;\nexport type Options = Inputmask.Options;\nexport type Input = HTMLInputElement | HTMLTextAreaElement | HTMLElement;\n\nexport default function withMask(mask: Mask, options?: Options) {\n return (input: Input | null): void => {\n if (isServer || mask === null || !input) return;\n\n const maskInput = interopDefaultSync(inputmask)(\n getMaskOptions(mask, options)\n );\n\n maskInput.mask(input);\n };\n}\n","import type * as React from 'react';\n\nimport { cn } from '@/lib/utils';\n\nfunction Input({ className, type, ...props }: React.ComponentProps<'input'>) {\n return (\n <input\n className={cn(\n 'file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input flex h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm',\n 'focus-visible:border-ring focus-visible:ring-ring/75 focus-visible:ring-[2px]',\n 'aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive ring-offset-[2px] transition-all duration-300',\n className\n )}\n data-slot=\"input\"\n type={type}\n {...props}\n />\n );\n}\n\nexport { Input };\n"],"mappings":";;;;;AAEA,SAAwB,eACtB,MACA,UACS;CACT,MAAMA,UAAmB;EACvB,YAAY;EACZ,GAAG;EACJ;AACD,KAAI,CAAC,KAAM,QAAO;CAElB,MAAMC,QAA2C;EAC/C,UAAU;GACR,OAAO;GACP,GAAG;GACJ;EACD,OAAO;GACL,OAAO;GACP,aAAa;GACb,GAAG;GACJ;EACD,SAAS;GACP,OAAO;GACP,aAAa;GACb,GAAG;GACJ;EACD,UAAU;GACR,OAAO;GACP,QAAQ;GACR,aAAa;GACb,GAAG;GACJ;EACD,SAAS;GACP,OAAO;GACP,aAAa;GACb,GAAG;GACJ;EACD,SAAS;GACP,OAAO;GACP,aAAa;GACb,GAAG;GACJ;EACD,YAAY;GACV,OAAO;GACP,aAAa;GACb,QAAQ;GACR,GAAG;GACJ;EACD,KAAK;GACH,OAAO;GACP,aAAa;GACb,GAAG;GACJ;EACD,IAAI;GACF,OAAO;GACP,GAAG;GACJ;EACD,KAAK;GACH,OAAO;GACP,GAAG;GACJ;EACD,KAAK;GACH,OAAO;GACP,GAAG;GACJ;EAID,gBAAgB;GACd,OAAO;GACP,QAAQ;GACR,aAAa;GACb,eAAe;GACf,YAAY;GACZ,YAAY;GACZ,GAAG;GACJ;EACD,KAAK;GACH,MAAM;GACN,aAAa;GACb,GAAG;GACJ;EACD,MAAM;GACJ,MAAM;GACN,aAAa;GACb,GAAG;GACJ;EACF;AAED,KAAI,OAAO,SAAS,YAAY,MAAM,MAAO,QAAO,MAAM;AAE1D,QAAO;EACL;EACA,GAAG;EACJ;;;;;AC/FH,MAAM,WAAW,EACf,OAAO,WAAW,eAAe,OAAO,UAAU;AAGpD,wBAAe;;;;;;;ACAf,SAAwB,mBAA4B,QAAc;AAChE,KAAI,OAAO,WAAW,YAAY,WAAW,MAAM;AACjD,MAAI,aAAa,OACf,QAAO,OAAO;AAEhB,SAAO;;AAET,QAAO;;;;;ACkBT,SAAwB,SAAS,MAAY,SAAmB;AAC9D,SAAQ,UAA8B;AACpC,MAAIC,qBAAY,SAAS,QAAQ,CAAC,MAAO;AAMzC,EAJkB,mBAAmB,UAAU,CAC7C,eAAe,MAAM,QAAQ,CAC9B,CAES,KAAK,MAAM;;;;;;ACjCzB,SAAS,MAAM,EAAE,WAAW,KAAM,GAAG,SAAwC;AAC3E,QACE,oBAAC;EACC,WAAW,GACT,mcACA,iFACA,wJACA,UACD;EACD,aAAU;EACJ;EACN,GAAI;GACJ"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as cn } from "./utils-
|
|
2
|
-
import { t as Label } from "./label-
|
|
3
|
-
import { useFormContext, useFormState } from "react-hook-form";
|
|
1
|
+
import { t as cn } from "./utils-C8_amEgK.js";
|
|
2
|
+
import { t as Label } from "./label-Bkg7B2j8.js";
|
|
3
|
+
import { Controller, useFormContext, useFormState } from "react-hook-form";
|
|
4
4
|
import * as React from "react";
|
|
5
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
import { Info } from "lucide-react";
|
|
@@ -16,6 +16,12 @@ const useFormContextSubmit = () => {
|
|
|
16
16
|
if (!context) return {};
|
|
17
17
|
return context;
|
|
18
18
|
};
|
|
19
|
+
const FormField = ({ ...props }) => {
|
|
20
|
+
return /* @__PURE__ */ jsx(FormFieldContext.Provider, {
|
|
21
|
+
value: { name: props.name },
|
|
22
|
+
children: /* @__PURE__ */ jsx(Controller, { ...props })
|
|
23
|
+
});
|
|
24
|
+
};
|
|
19
25
|
const useFormField = () => {
|
|
20
26
|
const fieldContext = React.useContext(FormFieldContext);
|
|
21
27
|
const itemContext = React.useContext(FormItemContext);
|
|
@@ -34,7 +40,7 @@ const useFormField = () => {
|
|
|
34
40
|
};
|
|
35
41
|
};
|
|
36
42
|
const FormItemContext = React.createContext({});
|
|
37
|
-
function FormItem({ className
|
|
43
|
+
function FormItem({ className,...props }) {
|
|
38
44
|
const id = React.useId();
|
|
39
45
|
return /* @__PURE__ */ jsx(FormItemContext.Provider, {
|
|
40
46
|
value: { id },
|
|
@@ -45,7 +51,7 @@ function FormItem({ className, ...props }) {
|
|
|
45
51
|
})
|
|
46
52
|
});
|
|
47
53
|
}
|
|
48
|
-
function FormLabel({ className
|
|
54
|
+
function FormLabel({ className,...props }) {
|
|
49
55
|
const { error, formItemId } = useFormField();
|
|
50
56
|
return /* @__PURE__ */ jsx(Label, {
|
|
51
57
|
className: cn("data-[error=true]:text-destructive", className),
|
|
@@ -55,7 +61,16 @@ function FormLabel({ className, ...props }) {
|
|
|
55
61
|
...props
|
|
56
62
|
});
|
|
57
63
|
}
|
|
58
|
-
function
|
|
64
|
+
function FormDescription({ className,...props }) {
|
|
65
|
+
const { formDescriptionId } = useFormField();
|
|
66
|
+
return /* @__PURE__ */ jsx("p", {
|
|
67
|
+
className: cn("text-muted-foreground text-sm", className),
|
|
68
|
+
"data-slot": "form-description",
|
|
69
|
+
id: formDescriptionId,
|
|
70
|
+
...props
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
function FormMessage({ className,...props }) {
|
|
59
74
|
const { error, formMessageId } = useFormField();
|
|
60
75
|
const body = error ? String(error?.message ?? "") : props.children;
|
|
61
76
|
if (!body) return null;
|
|
@@ -70,7 +85,7 @@ function FormMessage({ className, ...props }) {
|
|
|
70
85
|
|
|
71
86
|
//#endregion
|
|
72
87
|
//#region src/components/ui/tooltip.tsx
|
|
73
|
-
function TooltipProvider({ delayDuration = 0
|
|
88
|
+
function TooltipProvider({ delayDuration = 0,...props }) {
|
|
74
89
|
return /* @__PURE__ */ jsx(TooltipPrimitive.Provider, {
|
|
75
90
|
"data-slot": "tooltip-provider",
|
|
76
91
|
delayDuration,
|
|
@@ -89,7 +104,7 @@ function TooltipTrigger({ ...props }) {
|
|
|
89
104
|
...props
|
|
90
105
|
});
|
|
91
106
|
}
|
|
92
|
-
function TooltipContent({ className, sideOffset = 0, children
|
|
107
|
+
function TooltipContent({ className, sideOffset = 0, children,...props }) {
|
|
93
108
|
return /* @__PURE__ */ jsx(TooltipPrimitive.Portal, { children: /* @__PURE__ */ jsxs(TooltipPrimitive.Content, {
|
|
94
109
|
className: cn("bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance", className),
|
|
95
110
|
"data-slot": "tooltip-content",
|
|
@@ -136,5 +151,5 @@ const InputHelp = ({ help, name, className }) => {
|
|
|
136
151
|
};
|
|
137
152
|
|
|
138
153
|
//#endregion
|
|
139
|
-
export {
|
|
140
|
-
//# sourceMappingURL=input-help-
|
|
154
|
+
export { FormLabel as a, FormItem as i, FormDescription as n, FormMessage as o, FormField as r, InputHelp as t };
|
|
155
|
+
//# sourceMappingURL=input-help-BRDK0-yu.js.map
|