maquinaweb-ui 2.0.0 → 2.0.1
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/container-animation.d.ts +2 -2
- package/dist/container-animation.d.ts.map +1 -1
- package/dist/container-animation.js +11 -3
- package/dist/container-animation.js.map +1 -1
- package/dist/split-text-poor.js +21 -13
- package/dist/split-text-poor.js.map +1 -1
- package/dist/text-field.d.ts +4 -4
- package/dist/text-field.d.ts.map +1 -1
- package/dist/text-field.js +165 -76
- package/dist/text-field.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as react2 from "react";
|
|
2
1
|
import { ComponentProps, ElementType } from "react";
|
|
2
|
+
import * as react_jsx_runtime2 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_runtime2.JSX.Element;
|
|
27
27
|
//#endregion
|
|
28
28
|
export { ContainerAnimation, type ContainerAnimationProps };
|
|
29
29
|
//# sourceMappingURL=container-animation.d.ts.map
|
|
@@ -1 +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;EAAuB,QAAA,CAAA,EAAA,MAAA;UAAW,CAAA,EAAA,CAAA,MAAA,EAAA,MAAA,CAAA;eAC5C,CAAA,EAAA,OAAA;KACiB,EAOR,CAPQ,GAAA,MAAA;WAAf,CAAA,EAAA,MAAA;;cAWE,kBAJM,EAAA,CAAA,UAI0B,WAJ1B,GAAA,KAAA,CAAA,CAAA;EAAA,SAAA;EAAA,QAAA;EAAA,QAAA;EAAA,KAAA;EAAA,KAAA;EAAA,QAAA;EAAA,EAAA,EAI+C,EAJ/C;EAAA,QAAA;EAAA,aAAA;EAAA,GAAA;AAAA,CAAA,EAeT,uBAfS,CAee,CAff,CAAA,EAAA,GAeiB,
|
|
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;EAAuB,QAAA,CAAA,EAAA,MAAA;UAAW,CAAA,EAAA,CAAA,MAAA,EAAA,MAAA,CAAA;eAC5C,CAAA,EAAA,OAAA;KACiB,EAOR,CAPQ,GAAA,MAAA;WAAf,CAAA,EAAA,MAAA;;cAWE,kBAJM,EAAA,CAAA,UAI0B,WAJ1B,GAAA,KAAA,CAAA,CAAA;EAAA,SAAA;EAAA,QAAA;EAAA,QAAA;EAAA,KAAA;EAAA,KAAA;EAAA,QAAA;EAAA,EAAA,EAI+C,EAJ/C;EAAA,QAAA;EAAA,aAAA;EAAA,GAAA;AAAA,CAAA,EAeT,uBAfS,CAee,CAff,CAAA,EAAA,GAeiB,kBAAA,CAAA,GAAA,CAAA,OAfjB"}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
import { cn } from "./utils-C0f9Ma6r.js";
|
|
5
5
|
import { useEffect, useRef, useState } from "react";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
7
|
import * as motion from "motion/react-m";
|
|
7
8
|
|
|
8
9
|
//#region node_modules/motion-dom/dist/es/utils/resolve-elements.mjs
|
|
@@ -113,9 +114,16 @@ const ContainerAnimation = ({ className, children, position = "top", delay = 0,
|
|
|
113
114
|
margin: `-${100 - (distance[0] || 0)}% 0% -${distance[1] || 0}% 0%`
|
|
114
115
|
});
|
|
115
116
|
const variants = getVariants(position, space, delay);
|
|
116
|
-
return
|
|
117
|
-
|
|
118
|
-
|
|
117
|
+
return /* @__PURE__ */ jsx(motion.div, {
|
|
118
|
+
animate: isInView ? "visible" : "hidden",
|
|
119
|
+
className: cn("initial-opacity", className),
|
|
120
|
+
initial: "hidden",
|
|
121
|
+
transition: { duration },
|
|
122
|
+
variants,
|
|
123
|
+
...props,
|
|
124
|
+
ref,
|
|
125
|
+
children: (!hideNotInView || isInView) && children
|
|
126
|
+
});
|
|
119
127
|
};
|
|
120
128
|
|
|
121
129
|
//#endregion
|
|
@@ -1 +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","\"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","'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":"
|
|
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","\"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","'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,S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e,MAAM,MACjC;EACF;AAID,QAAO;EACL,QAAQ;GACN,SAAS;GACT,QAAQ;GACR,GANQ,WAAW,aAAa,WAAW;GAO5C;EACD,SAAS;GACP,SAAS;GACT,QAAQ;GACR,WAAW;GACX,YAAY;IACV;IACA,UAAU;IACV,iBAAiB;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"}
|
package/dist/split-text-poor.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
import { cn } from "./utils-C0f9Ma6r.js";
|
|
5
5
|
import { Children, cloneElement, isValidElement } from "react";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
7
|
import * as motion from "motion/react-m";
|
|
7
8
|
|
|
8
9
|
//#region src/components/split-text-poor/split-text-poor.tsx
|
|
@@ -47,23 +48,30 @@ const SplitTextPoor = ({ children, className, config = "default", as: As = "div"
|
|
|
47
48
|
const wrapWords = (node) => {
|
|
48
49
|
if (typeof node === "string") return node.split(split).map((word, index) => {
|
|
49
50
|
wordIndex++;
|
|
50
|
-
return
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
51
|
+
return /* @__PURE__ */ jsxs(motion.span, {
|
|
52
|
+
custom: {
|
|
53
|
+
index: wordIndex - 1,
|
|
54
|
+
delay
|
|
55
|
+
},
|
|
56
|
+
initial: "hidden",
|
|
57
|
+
style: {
|
|
58
|
+
display: "inline-block",
|
|
59
|
+
whiteSpace: "nowrap"
|
|
60
|
+
},
|
|
61
|
+
variants: selectedConfig,
|
|
62
|
+
viewport: { once: true },
|
|
63
|
+
whileInView: "visible",
|
|
64
|
+
children: [word, index < node.split(split).length - 1 && "\xA0"]
|
|
65
|
+
}, index);
|
|
60
66
|
});
|
|
61
67
|
if (isValidElement(node)) return cloneElement(node, { children: Children.map(node.props.children, wrapWords) });
|
|
62
68
|
return node;
|
|
63
69
|
};
|
|
64
|
-
return
|
|
65
|
-
|
|
66
|
-
|
|
70
|
+
return /* @__PURE__ */ jsx(As, {
|
|
71
|
+
className: cn(className, "initial-opacity will-change-[transform,filter]"),
|
|
72
|
+
style: { display: "inline-block" },
|
|
73
|
+
children: Children.map(children, wrapWords)
|
|
74
|
+
});
|
|
67
75
|
};
|
|
68
76
|
|
|
69
77
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"split-text-poor.js","names":["SplitTextPoor: React.FC<SplitTextPoorProps>"],"sources":["../src/components/split-text-poor/split-text-poor.tsx"],"sourcesContent":["'use client';\n\nimport { Children, cloneElement, isValidElement } from 'react';\n\nimport { cn } from '@/lib/utils';\nimport * as motion from 'motion/react-m';\n\nconst defaultConfig = {\n hidden: {\n transform: 'translateY(20px) skewY(6deg)',\n opacity: 0,\n filter: 'blur(7px)',\n },\n visible: ({ index, delay }: { index: number; delay: number }) => ({\n transform: 'translateY(0px) skewY(0deg)',\n opacity: 1,\n filter: 'blur(0px)',\n transition: {\n duration: 0.4,\n delay: index * 0.08 + delay,\n },\n }),\n};\n\nconst configs = {\n sm: {\n hidden: {\n transform: 'translateY(10px)',\n filter: 'blur(7px)',\n opacity: 0,\n },\n visible: ({ index, delay }: { index: number; delay: number }) => ({\n transform: 'translateY(0px)',\n filter: 'blur(0px)',\n opacity: 1,\n transition: {\n duration: 0.4,\n delay: index * 0.06 + delay,\n },\n }),\n },\n default: defaultConfig,\n};\n\nexport type SplitTextPoorProps = {\n children: React.ReactNode;\n className?: string;\n config?: keyof typeof configs;\n split?: string;\n delay?: number;\n as?: any;\n};\n\nconst SplitTextPoor: React.FC<SplitTextPoorProps> = ({\n children,\n className,\n config = 'default',\n as: As = 'div',\n split = ' ',\n delay = 0,\n}) => {\n const selectedConfig = configs[config] || defaultConfig;\n let wordIndex = 0;\n\n const wrapWords = (node: React.ReactNode): React.ReactNode => {\n if (typeof node === 'string') {\n return node.split(split).map((word, index) => {\n wordIndex++;\n return (\n <motion.span\n custom={{\n index: wordIndex - 1,\n delay,\n }}\n initial=\"hidden\"\n key={index}\n style={{ display: 'inline-block', whiteSpace: 'nowrap' }}\n variants={selectedConfig}\n viewport={{ once: true }}\n whileInView=\"visible\"\n >\n {word}\n {index < node.split(split).length - 1 && '\\u00A0'}\n </motion.span>\n );\n });\n }\n\n if (isValidElement(node)) {\n return cloneElement(node, {\n children: Children.map((node.props as any).children, wrapWords),\n } as any);\n }\n\n return node;\n };\n\n return (\n <As\n className={cn(\n className,\n 'initial-opacity will-change-[transform,filter]'\n )}\n style={{ display: 'inline-block' }}\n >\n {Children.map(children, wrapWords)}\n </As>\n );\n};\n\nexport { SplitTextPoor };\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"split-text-poor.js","names":["SplitTextPoor: React.FC<SplitTextPoorProps>"],"sources":["../src/components/split-text-poor/split-text-poor.tsx"],"sourcesContent":["'use client';\n\nimport { Children, cloneElement, isValidElement } from 'react';\n\nimport { cn } from '@/lib/utils';\nimport * as motion from 'motion/react-m';\n\nconst defaultConfig = {\n hidden: {\n transform: 'translateY(20px) skewY(6deg)',\n opacity: 0,\n filter: 'blur(7px)',\n },\n visible: ({ index, delay }: { index: number; delay: number }) => ({\n transform: 'translateY(0px) skewY(0deg)',\n opacity: 1,\n filter: 'blur(0px)',\n transition: {\n duration: 0.4,\n delay: index * 0.08 + delay,\n },\n }),\n};\n\nconst configs = {\n sm: {\n hidden: {\n transform: 'translateY(10px)',\n filter: 'blur(7px)',\n opacity: 0,\n },\n visible: ({ index, delay }: { index: number; delay: number }) => ({\n transform: 'translateY(0px)',\n filter: 'blur(0px)',\n opacity: 1,\n transition: {\n duration: 0.4,\n delay: index * 0.06 + delay,\n },\n }),\n },\n default: defaultConfig,\n};\n\nexport type SplitTextPoorProps = {\n children: React.ReactNode;\n className?: string;\n config?: keyof typeof configs;\n split?: string;\n delay?: number;\n as?: any;\n};\n\nconst SplitTextPoor: React.FC<SplitTextPoorProps> = ({\n children,\n className,\n config = 'default',\n as: As = 'div',\n split = ' ',\n delay = 0,\n}) => {\n const selectedConfig = configs[config] || defaultConfig;\n let wordIndex = 0;\n\n const wrapWords = (node: React.ReactNode): React.ReactNode => {\n if (typeof node === 'string') {\n return node.split(split).map((word, index) => {\n wordIndex++;\n return (\n <motion.span\n custom={{\n index: wordIndex - 1,\n delay,\n }}\n initial=\"hidden\"\n key={index}\n style={{ display: 'inline-block', whiteSpace: 'nowrap' }}\n variants={selectedConfig}\n viewport={{ once: true }}\n whileInView=\"visible\"\n >\n {word}\n {index < node.split(split).length - 1 && '\\u00A0'}\n </motion.span>\n );\n });\n }\n\n if (isValidElement(node)) {\n return cloneElement(node, {\n children: Children.map((node.props as any).children, wrapWords),\n } as any);\n }\n\n return node;\n };\n\n return (\n <As\n className={cn(\n className,\n 'initial-opacity will-change-[transform,filter]'\n )}\n style={{ display: 'inline-block' }}\n >\n {Children.map(children, wrapWords)}\n </As>\n );\n};\n\nexport { SplitTextPoor };\n"],"mappings":";;;;;;;;;AAOA,MAAM,gBAAgB;CACpB,QAAQ;EACN,WAAW;EACX,SAAS;EACT,QAAQ;EACT;CACD,UAAU,EAAE,OAAO,aAA+C;EAChE,WAAW;EACX,SAAS;EACT,QAAQ;EACR,YAAY;GACV,UAAU;GACV,OAAO,QAAQ,MAAO;GACvB;EACF;CACF;AAED,MAAM,UAAU;CACd,IAAI;EACF,QAAQ;GACN,WAAW;GACX,QAAQ;GACR,SAAS;GACV;EACD,UAAU,EAAE,OAAO,aAA+C;GAChE,WAAW;GACX,QAAQ;GACR,SAAS;GACT,YAAY;IACV,UAAU;IACV,OAAO,QAAQ,MAAO;IACvB;GACF;EACF;CACD,SAAS;CACV;AAWD,MAAMA,iBAA+C,EACnD,UACA,WACA,SAAS,WACT,IAAI,KAAK,OACT,QAAQ,KACR,QAAQ,QACJ;CACJ,MAAM,iBAAiB,QAAQ,WAAW;CAC1C,IAAI,YAAY;CAEhB,MAAM,aAAa,SAA2C;AAC5D,MAAI,OAAO,SAAS,SAClB,QAAO,KAAK,MAAM,MAAM,CAAC,KAAK,MAAM,UAAU;AAC5C;AACA,UACE,qBAAC,OAAO;IACN,QAAQ;KACN,OAAO,YAAY;KACnB;KACD;IACD,SAAQ;IAER,OAAO;KAAE,SAAS;KAAgB,YAAY;KAAU;IACxD,UAAU;IACV,UAAU,EAAE,MAAM,MAAM;IACxB,aAAY;eAEX,MACA,QAAQ,KAAK,MAAM,MAAM,CAAC,SAAS,KAAK;MAPpC,MAQO;IAEhB;AAGJ,MAAI,eAAe,KAAK,CACtB,QAAO,aAAa,MAAM,EACxB,UAAU,SAAS,IAAK,KAAK,MAAc,UAAU,UAAU,EAChE,CAAQ;AAGX,SAAO;;AAGT,QACE,oBAAC;EACC,WAAW,GACT,WACA,iDACD;EACD,OAAO,EAAE,SAAS,gBAAgB;YAEjC,SAAS,IAAI,UAAU,UAAU;GAC/B"}
|
package/dist/text-field.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as react0 from "react";
|
|
2
1
|
import { FieldPath, FieldPathValue, FieldValues, UseControllerProps } from "react-hook-form";
|
|
3
2
|
import { Options } from "use-mask-input";
|
|
3
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
4
4
|
import { Options as Options$1 } from "nuqs";
|
|
5
5
|
|
|
6
6
|
//#region src/components/text-field/TextField.d.ts
|
|
@@ -46,7 +46,7 @@ declare function InputText({
|
|
|
46
46
|
help,
|
|
47
47
|
name,
|
|
48
48
|
...props
|
|
49
|
-
}: InputTextProps):
|
|
49
|
+
}: InputTextProps): react_jsx_runtime0.JSX.Element;
|
|
50
50
|
interface TextFieldProps<TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> extends UseControllerProps<TFieldValues, TFieldName> {
|
|
51
51
|
disabled?: boolean;
|
|
52
52
|
required?: boolean;
|
|
@@ -63,7 +63,7 @@ declare function TextField<TFieldValues extends FieldValues = FieldValues, TFiel
|
|
|
63
63
|
onChange,
|
|
64
64
|
transform,
|
|
65
65
|
...props
|
|
66
|
-
}: TextFieldProps<TFieldValues, TFieldName> & Omit<InputTextProps, 'onChange'>):
|
|
66
|
+
}: TextFieldProps<TFieldValues, TFieldName> & Omit<InputTextProps, 'onChange'>): react_jsx_runtime0.JSX.Element;
|
|
67
67
|
interface QueryTextFieldProps extends Omit<InputTextProps, 'onChange'> {
|
|
68
68
|
name: string;
|
|
69
69
|
defaultValue?: string;
|
|
@@ -75,7 +75,7 @@ declare function QueryTextField({
|
|
|
75
75
|
defaultValue,
|
|
76
76
|
options,
|
|
77
77
|
...props
|
|
78
|
-
}: QueryTextFieldProps):
|
|
78
|
+
}: QueryTextFieldProps): react_jsx_runtime0.JSX.Element;
|
|
79
79
|
//#endregion
|
|
80
80
|
export { InputText, type InputTextProps, QueryTextField, type QueryTextFieldProps, TextField, type TextFieldProps };
|
|
81
81
|
//# sourceMappingURL=text-field.d.ts.map
|
package/dist/text-field.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text-field.d.ts","names":[],"sources":["../src/components/text-field/TextField.tsx"],"sourcesContent":[],"mappings":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GmB,SAnGnB,CAmG6B,YAnG7B,CAAA,GAmG6C,SAnG7C,CAmGuD,YAnGvD,CAAA,CAAA,CAAA;EAAA,IAAA;EAAA,SAAA;EAAA,QAAA;EAAA,YAAA;EAAA,QAAA;EAAA,SAAA;EAAA,GAAA;AAAA,CAAA,EA4GC,cA5GD,CA4GgB,YA5GhB,EA4G8B,UA5G9B,CAAA,GA6GA,IA7GA,CA6GK,cA7GL,EAAA,UAAA,CAAA,CAAA,EA6GgC,kBAAA,CAAA,GAAA,CAAA,OA7GhC;AACA,UA8Ie,mBAAA,SAA4B,IA9I3C,CA8IgD,cA9IhD,EAAA,UAAA,CAAA,CAAA;MACA,EAAA,MAAA;cACA,CAAA,EAAA,MAAA;SACA,CAAA,EA8IU,SA9IV;UACA,CAAA,EAAA,CAAA,KAAA,EAAA,MAAA,EAAA,GAAA,IAAA;;iBAiJO,cAAA,CA9IN;EAAA,IAAA;EAAA,YAAA;EAAA,OAAA;EAAA,GAAA;AAAA,CAAA,EAmJA,mBAnJA,CAAA,EAmJmB,kBAAA,CAAA,GAAA,CAAA,OAnJnB"}
|
package/dist/text-field.js
CHANGED
|
@@ -8,6 +8,7 @@ import { Controller, useFormContext, useFormState } from "react-hook-form";
|
|
|
8
8
|
import { withMask } from "use-mask-input";
|
|
9
9
|
import "@radix-ui/react-slot";
|
|
10
10
|
import * as LabelPrimitive from "@radix-ui/react-label";
|
|
11
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
12
|
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
|
12
13
|
import { Portal } from "@radix-ui/react-tooltip";
|
|
13
14
|
import { Info } from "lucide-react";
|
|
@@ -15,7 +16,11 @@ import { parseAsString, useQueryState } from "nuqs";
|
|
|
15
16
|
|
|
16
17
|
//#region src/components/ui/label.tsx
|
|
17
18
|
function Label({ className,...props }) {
|
|
18
|
-
return
|
|
19
|
+
return /* @__PURE__ */ jsx(LabelPrimitive.Root, {
|
|
20
|
+
className: cn("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50", className),
|
|
21
|
+
"data-slot": "label",
|
|
22
|
+
...props
|
|
23
|
+
});
|
|
19
24
|
}
|
|
20
25
|
|
|
21
26
|
//#endregion
|
|
@@ -28,9 +33,10 @@ const useFormContextSubmit = () => {
|
|
|
28
33
|
return context;
|
|
29
34
|
};
|
|
30
35
|
const FormField = ({ ...props }) => {
|
|
31
|
-
return
|
|
32
|
-
|
|
33
|
-
|
|
36
|
+
return /* @__PURE__ */ jsx(FormFieldContext.Provider, {
|
|
37
|
+
value: { name: props.name },
|
|
38
|
+
children: /* @__PURE__ */ jsx(Controller, { ...props })
|
|
39
|
+
});
|
|
34
40
|
};
|
|
35
41
|
const useFormField = () => {
|
|
36
42
|
const fieldContext = React.useContext(FormFieldContext);
|
|
@@ -52,58 +58,88 @@ const useFormField = () => {
|
|
|
52
58
|
const FormItemContext = React.createContext({});
|
|
53
59
|
function FormItem({ className,...props }) {
|
|
54
60
|
const id = React.useId();
|
|
55
|
-
return
|
|
56
|
-
|
|
57
|
-
|
|
61
|
+
return /* @__PURE__ */ jsx(FormItemContext.Provider, {
|
|
62
|
+
value: { id },
|
|
63
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
64
|
+
className: cn("flex flex-col gap-1", className),
|
|
65
|
+
"data-slot": "form-item",
|
|
66
|
+
...props
|
|
67
|
+
})
|
|
68
|
+
});
|
|
58
69
|
}
|
|
59
70
|
function FormMessage({ className,...props }) {
|
|
60
71
|
const { error, formMessageId } = useFormField();
|
|
61
72
|
const body = error ? String(error?.message ?? "") : props.children;
|
|
62
73
|
if (!body) return null;
|
|
63
|
-
return
|
|
64
|
-
|
|
65
|
-
|
|
74
|
+
return /* @__PURE__ */ jsx("p", {
|
|
75
|
+
className: cn("text-destructive text-xs", className),
|
|
76
|
+
"data-slot": "form-message",
|
|
77
|
+
id: formMessageId,
|
|
78
|
+
...props,
|
|
79
|
+
children: body
|
|
80
|
+
});
|
|
66
81
|
}
|
|
67
82
|
|
|
68
83
|
//#endregion
|
|
69
84
|
//#region src/components/ui/input.tsx
|
|
70
85
|
function Input({ className, type,...props }) {
|
|
71
|
-
return
|
|
86
|
+
return /* @__PURE__ */ jsx("input", {
|
|
87
|
+
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),
|
|
88
|
+
"data-slot": "input",
|
|
89
|
+
type,
|
|
90
|
+
...props
|
|
91
|
+
});
|
|
72
92
|
}
|
|
73
93
|
|
|
74
94
|
//#endregion
|
|
75
95
|
//#region src/components/ui/tooltip.tsx
|
|
76
96
|
function TooltipProvider({ delayDuration = 0,...props }) {
|
|
77
|
-
return
|
|
97
|
+
return /* @__PURE__ */ jsx(TooltipPrimitive.Provider, {
|
|
98
|
+
"data-slot": "tooltip-provider",
|
|
99
|
+
delayDuration,
|
|
100
|
+
...props
|
|
101
|
+
});
|
|
78
102
|
}
|
|
79
103
|
function Tooltip({ ...props }) {
|
|
80
|
-
return
|
|
81
|
-
|
|
82
|
-
|
|
104
|
+
return /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsx(TooltipPrimitive.Root, {
|
|
105
|
+
"data-slot": "tooltip",
|
|
106
|
+
...props
|
|
107
|
+
}) });
|
|
83
108
|
}
|
|
84
109
|
function TooltipTrigger({ ...props }) {
|
|
85
|
-
return
|
|
110
|
+
return /* @__PURE__ */ jsx(TooltipPrimitive.Trigger, {
|
|
111
|
+
"data-slot": "tooltip-trigger",
|
|
112
|
+
...props
|
|
113
|
+
});
|
|
86
114
|
}
|
|
87
115
|
function TooltipContent({ className, sideOffset = 0, children,...props }) {
|
|
88
|
-
return
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
116
|
+
return /* @__PURE__ */ jsx(TooltipPrimitive.Portal, { children: /* @__PURE__ */ jsxs(TooltipPrimitive.Content, {
|
|
117
|
+
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),
|
|
118
|
+
"data-slot": "tooltip-content",
|
|
119
|
+
sideOffset,
|
|
120
|
+
...props,
|
|
121
|
+
children: [children, /* @__PURE__ */ jsx(TooltipPrimitive.Arrow, { className: "bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]" })]
|
|
122
|
+
}) });
|
|
94
123
|
}
|
|
95
124
|
|
|
96
125
|
//#endregion
|
|
97
126
|
//#region src/components/ui/content-help.tsx
|
|
98
127
|
const ContentHelp = ({ children, help, className, side = "top", sideOffset = 10 }) => {
|
|
99
|
-
return help ?
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
128
|
+
return help ? /* @__PURE__ */ jsxs(Tooltip, {
|
|
129
|
+
delayDuration: 250,
|
|
130
|
+
children: [/* @__PURE__ */ jsx(TooltipTrigger, {
|
|
131
|
+
asChild: true,
|
|
132
|
+
children
|
|
133
|
+
}), /* @__PURE__ */ jsx(Portal, { children: /* @__PURE__ */ jsx(TooltipContent, {
|
|
134
|
+
className: cn("flex items-center px-2 leading-none", className),
|
|
135
|
+
side,
|
|
136
|
+
sideOffset: 10,
|
|
137
|
+
children: /* @__PURE__ */ jsx("p", {
|
|
138
|
+
className: "w-full text-wrap whitespace-break-spaces",
|
|
139
|
+
children: help
|
|
140
|
+
})
|
|
141
|
+
}) })]
|
|
142
|
+
}) : children;
|
|
107
143
|
};
|
|
108
144
|
|
|
109
145
|
//#endregion
|
|
@@ -111,58 +147,105 @@ const ContentHelp = ({ children, help, className, side = "top", sideOffset = 10
|
|
|
111
147
|
const InputHelp = ({ help, name, className }) => {
|
|
112
148
|
const { helper } = useFormContextSubmit();
|
|
113
149
|
const helpText = name && helper?.[name] || help;
|
|
114
|
-
return helpText &&
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
150
|
+
return helpText && /* @__PURE__ */ jsx(ContentHelp, {
|
|
151
|
+
className: cn("whitespace-pre-line leading-relaxed max-w-96 text-[13px]"),
|
|
152
|
+
help: helpText,
|
|
153
|
+
children: /* @__PURE__ */ jsx("button", {
|
|
154
|
+
className: cn("mb-0.5 size-fit p-1 hover:bg-muted rounded-sm", className),
|
|
155
|
+
type: "button",
|
|
156
|
+
children: /* @__PURE__ */ jsx(Info, { className: "size-3.5" })
|
|
157
|
+
})
|
|
158
|
+
});
|
|
119
159
|
};
|
|
120
160
|
|
|
121
161
|
//#endregion
|
|
122
162
|
//#region src/components/text-field/TextField.tsx
|
|
123
163
|
function InputText({ label, description, placeholder, className, children, disabled, type, required, maskRef, mask, maskOptions, error, id, ref, detail, detailClassName, inputClassName, help, name,...props }) {
|
|
124
|
-
return
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
164
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
165
|
+
className: cn("w-full flex flex-col gap-1", className),
|
|
166
|
+
id: `input-${name?.replace(".", "-")}`,
|
|
167
|
+
ref,
|
|
168
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
169
|
+
className: "flex items-end gap-1.5",
|
|
170
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
171
|
+
className: cn("flex !gap-0 flex-col", className),
|
|
172
|
+
children: [label && /* @__PURE__ */ jsxs(Label, {
|
|
173
|
+
className: cn(error && "text-destructive", className, disabled && "text-muted-foreground", "inline-flex items-center flex-row gap-0.5"),
|
|
174
|
+
htmlFor: id,
|
|
175
|
+
children: [
|
|
176
|
+
label,
|
|
177
|
+
":",
|
|
178
|
+
required && /* @__PURE__ */ jsx("span", {
|
|
179
|
+
className: "text-red-500 text-lg leading-[1px]",
|
|
180
|
+
children: "*"
|
|
181
|
+
})
|
|
182
|
+
]
|
|
183
|
+
}), detail && /* @__PURE__ */ jsx(Label, {
|
|
184
|
+
className: cn("text-sm text-muted-foreground font-normal", detailClassName),
|
|
185
|
+
htmlFor: id,
|
|
186
|
+
children: detail
|
|
187
|
+
})]
|
|
188
|
+
}), /* @__PURE__ */ jsx(InputHelp, {
|
|
189
|
+
help,
|
|
190
|
+
name
|
|
191
|
+
})]
|
|
192
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
193
|
+
className: "flex flex-col gap-0.5",
|
|
194
|
+
children: [
|
|
195
|
+
/* @__PURE__ */ jsxs("div", {
|
|
196
|
+
className: "relative",
|
|
197
|
+
children: [/* @__PURE__ */ jsx(Input, {
|
|
198
|
+
className: cn(error && "border-destructive", inputClassName),
|
|
199
|
+
disabled,
|
|
200
|
+
id,
|
|
201
|
+
placeholder,
|
|
202
|
+
ref: maskRef || (mask ? withMask(mask, {
|
|
203
|
+
autoUnmask: true,
|
|
204
|
+
...maskOptions,
|
|
205
|
+
showMaskOnHover: false,
|
|
206
|
+
showMaskOnFocus: false,
|
|
207
|
+
clearMaskOnLostFocus: true
|
|
208
|
+
}) : void 0),
|
|
209
|
+
type,
|
|
210
|
+
...props
|
|
211
|
+
}), children]
|
|
212
|
+
}),
|
|
213
|
+
description && /* @__PURE__ */ jsx("p", {
|
|
214
|
+
className: cn("text-sm text-muted-foreground", className),
|
|
215
|
+
children: description
|
|
216
|
+
}),
|
|
217
|
+
error && error
|
|
218
|
+
]
|
|
219
|
+
})]
|
|
220
|
+
});
|
|
155
221
|
}
|
|
156
222
|
const defaultTransform = (value) => value;
|
|
157
223
|
function TextField({ name, className, required, defaultValue, onChange, transform = defaultTransform,...props }) {
|
|
158
224
|
const { control } = useFormContext();
|
|
159
225
|
const id = useId();
|
|
160
|
-
return
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
226
|
+
return /* @__PURE__ */ jsx(FormField, {
|
|
227
|
+
control,
|
|
228
|
+
defaultValue,
|
|
229
|
+
name,
|
|
230
|
+
render: ({ field, fieldState }) => /* @__PURE__ */ jsx(FormItem, {
|
|
231
|
+
className: cn("w-full", className),
|
|
232
|
+
children: /* @__PURE__ */ jsx(InputText, {
|
|
233
|
+
...field,
|
|
234
|
+
...props,
|
|
235
|
+
disabled: props.disabled,
|
|
236
|
+
error: fieldState?.error && /* @__PURE__ */ jsx(FormMessage, {}),
|
|
237
|
+
id: `${id}-${name}`,
|
|
238
|
+
name,
|
|
239
|
+
onChange: (e) => {
|
|
240
|
+
field.onChange(transform(e.target.value));
|
|
241
|
+
onChange?.(transform(e.target.value));
|
|
242
|
+
},
|
|
243
|
+
required,
|
|
244
|
+
value: field.value || ""
|
|
245
|
+
})
|
|
246
|
+
}),
|
|
247
|
+
rules: { required: required ? "Campo obrigatório" : false }
|
|
248
|
+
});
|
|
166
249
|
}
|
|
167
250
|
function QueryTextField({ name, defaultValue, options,...props }) {
|
|
168
251
|
const id = useId();
|
|
@@ -175,10 +258,16 @@ function QueryTextField({ name, defaultValue, options,...props }) {
|
|
|
175
258
|
},
|
|
176
259
|
...options
|
|
177
260
|
}).withDefault(defaultValue ?? ""));
|
|
178
|
-
return
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
261
|
+
return /* @__PURE__ */ jsx(InputText, {
|
|
262
|
+
id: `${id}-${name}`,
|
|
263
|
+
name,
|
|
264
|
+
value: filter,
|
|
265
|
+
...props,
|
|
266
|
+
onChange: (e) => {
|
|
267
|
+
setFilter(e.target.value);
|
|
268
|
+
props.onChange?.(e.target.value);
|
|
269
|
+
}
|
|
270
|
+
});
|
|
182
271
|
}
|
|
183
272
|
|
|
184
273
|
//#endregion
|
package/dist/text-field.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text-field.js","names":["ContentHelp: React.FC<{\n children: React.ReactNode;\n help?: React.ReactNode | string;\n className?: string;\n side?: 'top' | 'right' | 'bottom' | 'left';\n sideOffset?: number;\n}>","TooltipPortal","InputHelp: React.FC<{\n help?: string;\n name?: string;\n className?: string;\n}>"],"sources":["../src/components/ui/label.tsx","../src/components/ui/form.tsx","../src/components/ui/input.tsx","../src/components/ui/tooltip.tsx","../src/components/ui/content-help.tsx","../src/components/ui/input-help.tsx","../src/components/text-field/TextField.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\n\nimport * as LabelPrimitive from '@radix-ui/react-label';\n\nimport { cn } from '@/lib/utils';\n\nfunction Label({\n className,\n ...props\n}: React.ComponentProps<typeof LabelPrimitive.Root>) {\n return (\n <LabelPrimitive.Root\n className={cn(\n 'flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50',\n className\n )}\n data-slot=\"label\"\n {...props}\n />\n );\n}\n\nexport { Label };\n","'use client';\n\nimport * as React from 'react';\n\nimport {\n Controller,\n type ControllerProps,\n type FieldPath,\n type FieldValues,\n FormProvider,\n useFormContext,\n useFormState,\n} from 'react-hook-form';\n\nimport type * as LabelPrimitive from '@radix-ui/react-label';\nimport { Slot } from '@radix-ui/react-slot';\nimport { Label } from '@/components/ui/label';\n\nimport { cn } from '@/lib/utils';\n\ntype FormFieldContextValue<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n> = {\n name: TName;\n};\n\nconst FormFieldContext = React.createContext<FormFieldContextValue>(\n {} as FormFieldContextValue\n);\n\nconst FormContext = React.createContext<{\n onSubmit?: (data?: FieldValues) => void;\n helper?: Record<string, string>;\n}>({});\n\nexport const useFormContextSubmit = () => {\n const context = React.useContext(FormContext);\n if (!context) {\n return {};\n }\n return context;\n};\n\nconst Form: React.FC<\n React.ComponentProps<typeof FormProvider<FieldValues>> & {\n onSubmit?: (data?: FieldValues) => void;\n helper?: Record<string, string>;\n }\n> = ({ onSubmit, helper, ...props }) => {\n return (\n <FormContext.Provider value={{ onSubmit, helper }}>\n <FormProvider {...props} />\n </FormContext.Provider>\n );\n};\n\nconst FormField = <\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n>({\n ...props\n}: ControllerProps<TFieldValues, TName>) => {\n return (\n <FormFieldContext.Provider value={{ name: props.name }}>\n <Controller {...props} />\n </FormFieldContext.Provider>\n );\n};\n\nconst useFormField = () => {\n const fieldContext = React.useContext(FormFieldContext);\n const itemContext = React.useContext(FormItemContext);\n const { getFieldState } = useFormContext();\n const formState = useFormState({ name: fieldContext.name });\n const fieldState = getFieldState(fieldContext.name, formState);\n\n if (!fieldContext) {\n throw new Error('useFormField should be used within <FormField>');\n }\n\n const { id } = itemContext;\n\n return {\n id,\n name: fieldContext.name,\n formItemId: `${id}-form-item`,\n formDescriptionId: `${id}-form-item-description`,\n formMessageId: `${id}-form-item-message`,\n ...fieldState,\n };\n};\n\ntype FormItemContextValue = {\n id: string;\n};\n\nconst FormItemContext = React.createContext<FormItemContextValue>(\n {} as FormItemContextValue\n);\n\nfunction FormItem({ className, ...props }: React.ComponentProps<'div'>) {\n const id = React.useId();\n\n return (\n <FormItemContext.Provider value={{ id }}>\n <div\n className={cn('flex flex-col gap-1', className)}\n data-slot=\"form-item\"\n {...props}\n />\n </FormItemContext.Provider>\n );\n}\n\nfunction FormLabel({\n className,\n ...props\n}: React.ComponentProps<typeof LabelPrimitive.Root>) {\n const { error, formItemId } = useFormField();\n\n return (\n <Label\n className={cn('data-[error=true]:text-destructive', className)}\n data-error={!!error}\n data-slot=\"form-label\"\n htmlFor={formItemId}\n {...props}\n />\n );\n}\n\nfunction FormControl({ ...props }: React.ComponentProps<typeof Slot>) {\n const { error, formItemId, formDescriptionId, formMessageId } =\n useFormField();\n\n return (\n <Slot\n aria-describedby={\n !error\n ? `${formDescriptionId}`\n : `${formDescriptionId} ${formMessageId}`\n }\n aria-invalid={!!error}\n data-slot=\"form-control\"\n id={formItemId}\n {...props}\n />\n );\n}\n\nfunction FormDescription({ className, ...props }: React.ComponentProps<'p'>) {\n const { formDescriptionId } = useFormField();\n\n return (\n <p\n className={cn('text-muted-foreground text-sm', className)}\n data-slot=\"form-description\"\n id={formDescriptionId}\n {...props}\n />\n );\n}\n\nfunction FormMessage({ className, ...props }: React.ComponentProps<'p'>) {\n const { error, formMessageId } = useFormField();\n const body = error ? String(error?.message ?? '') : props.children;\n\n if (!body) {\n return null;\n }\n\n return (\n <p\n className={cn('text-destructive text-xs', className)}\n data-slot=\"form-message\"\n id={formMessageId}\n {...props}\n >\n {body}\n </p>\n );\n}\n\nexport {\n useFormField,\n Form,\n FormItem,\n FormLabel,\n FormControl,\n FormDescription,\n FormMessage,\n FormField,\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","'use client';\n\nimport * as React from 'react';\n\nimport * as TooltipPrimitive from '@radix-ui/react-tooltip';\n\nimport { cn } from '@/lib/utils';\n\nfunction TooltipProvider({\n delayDuration = 0,\n ...props\n}: React.ComponentProps<typeof TooltipPrimitive.Provider>) {\n return (\n <TooltipPrimitive.Provider\n data-slot=\"tooltip-provider\"\n delayDuration={delayDuration}\n {...props}\n />\n );\n}\n\nfunction Tooltip({\n ...props\n}: React.ComponentProps<typeof TooltipPrimitive.Root>) {\n return (\n <TooltipProvider>\n <TooltipPrimitive.Root data-slot=\"tooltip\" {...props} />\n </TooltipProvider>\n );\n}\n\nfunction TooltipTrigger({\n ...props\n}: React.ComponentProps<typeof TooltipPrimitive.Trigger>) {\n return <TooltipPrimitive.Trigger data-slot=\"tooltip-trigger\" {...props} />;\n}\n\nfunction TooltipContent({\n className,\n sideOffset = 0,\n children,\n ...props\n}: React.ComponentProps<typeof TooltipPrimitive.Content>) {\n return (\n <TooltipPrimitive.Portal>\n <TooltipPrimitive.Content\n className={cn(\n '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',\n className\n )}\n data-slot=\"tooltip-content\"\n sideOffset={sideOffset}\n {...props}\n >\n {children}\n <TooltipPrimitive.Arrow className=\"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]\" />\n </TooltipPrimitive.Content>\n </TooltipPrimitive.Portal>\n );\n}\n\nexport { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider };\n","import { Portal as TooltipPortal } from '@radix-ui/react-tooltip';\n\nimport { cn } from '@/lib/utils';\nimport { Tooltip, TooltipContent, TooltipTrigger } from './tooltip';\n\nconst ContentHelp: React.FC<{\n children: React.ReactNode;\n help?: React.ReactNode | string;\n className?: string;\n side?: 'top' | 'right' | 'bottom' | 'left';\n sideOffset?: number;\n}> = ({ children, help, className, side = 'top', sideOffset = 10 }) => {\n return help ? (\n <Tooltip delayDuration={250}>\n <TooltipTrigger asChild>{children as any}</TooltipTrigger>\n <TooltipPortal>\n <TooltipContent\n className={cn('flex items-center px-2 leading-none', className)}\n side={side}\n sideOffset={10}\n >\n <p className=\"w-full text-wrap whitespace-break-spaces\">{help}</p>\n </TooltipContent>\n </TooltipPortal>\n </Tooltip>\n ) : (\n children\n );\n};\n\nexport { ContentHelp };\n","'use client';\n\nimport { ContentHelp } from '@/components/ui/content-help';\n\nimport { Info } from 'lucide-react';\n\nimport { cn } from '@/lib/utils';\nimport { useFormContextSubmit } from './form';\n\nconst InputHelp: React.FC<{\n help?: string;\n name?: string;\n className?: string;\n}> = ({ help, name, className }) => {\n const { helper } = useFormContextSubmit();\n const helpText = (name && helper?.[name]) || help;\n\n return (\n helpText && (\n <ContentHelp\n className={cn(\n 'whitespace-pre-line leading-relaxed max-w-96 text-[13px]'\n )}\n help={helpText}\n >\n <button\n className={cn(\n 'mb-0.5 size-fit p-1 hover:bg-muted rounded-sm',\n className\n )}\n type=\"button\"\n >\n <Info className=\"size-3.5\" />\n </button>\n </ContentHelp>\n )\n );\n};\nexport { InputHelp };\n","'use client';\n\nimport { useId } from 'react';\n\nimport {\n type FieldPath,\n type FieldPathValue,\n type FieldValues,\n type UseControllerProps,\n useFormContext,\n} from 'react-hook-form';\nimport { type Options as MaskOptions, withMask } from 'use-mask-input';\n\nimport { FormField, FormItem, FormMessage } from '@/components/ui/form';\nimport { Input } from '@/components/ui/input';\nimport { InputHelp } from '@/components/ui/input-help';\nimport { Label } from '@/components/ui/label';\n\nimport { cn } from '@/lib/utils';\nimport { type Options, parseAsString, useQueryState } from 'nuqs';\n\ntype 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;\n\nexport interface InputTextProps\n extends React.InputHTMLAttributes<HTMLInputElement> {\n ref?: React.ForwardedRef<HTMLInputElement>;\n label?: string;\n placeholder?: string;\n description?: string;\n className?: string;\n disabled?: boolean;\n type?: string;\n required?: boolean;\n maskRef?: React.ForwardedRef<any>;\n children?: React.ReactNode;\n mask?: Mask;\n maskOptions?: MaskOptions;\n error?: React.ReactNode;\n id?: string;\n detail?: string;\n detailClassName?: string;\n inputClassName?: string;\n help?: string;\n}\n\nfunction InputText({\n label,\n description,\n placeholder,\n className,\n children,\n disabled,\n type,\n required,\n maskRef,\n mask,\n maskOptions,\n error,\n id,\n ref,\n detail,\n detailClassName,\n inputClassName,\n help,\n name,\n ...props\n}: InputTextProps) {\n return (\n <div\n className={cn('w-full flex flex-col gap-1', className)}\n id={`input-${name?.replace('.', '-')}`}\n ref={ref}\n >\n <div className=\"flex items-end gap-1.5\">\n <div className={cn('flex !gap-0 flex-col', className)}>\n {label && (\n <Label\n className={cn(\n error && 'text-destructive',\n className,\n disabled && 'text-muted-foreground',\n 'inline-flex items-center flex-row gap-0.5'\n )}\n htmlFor={id}\n >\n {label}:\n {required && (\n <span className=\"text-red-500 text-lg leading-[1px]\">*</span>\n )}\n </Label>\n )}\n {detail && (\n <Label\n className={cn(\n 'text-sm text-muted-foreground font-normal',\n detailClassName\n )}\n htmlFor={id}\n >\n {detail}\n </Label>\n )}\n </div>\n\n <InputHelp help={help} name={name} />\n </div>\n <div className=\"flex flex-col gap-0.5\">\n <div className=\"relative\">\n <Input\n className={cn(error && 'border-destructive', inputClassName)}\n disabled={disabled}\n id={id}\n placeholder={placeholder}\n ref={\n maskRef ||\n ((mask\n ? withMask(mask, {\n autoUnmask: true,\n ...maskOptions,\n showMaskOnHover: false,\n showMaskOnFocus: false,\n clearMaskOnLostFocus: true,\n })\n : undefined) as any)\n }\n type={type}\n {...props}\n />\n {children}\n </div>\n {description && (\n <p className={cn('text-sm text-muted-foreground', className)}>\n {description}\n </p>\n )}\n {error && error}\n </div>\n </div>\n );\n}\n\nexport interface TextFieldProps<\n TFieldValues extends FieldValues = FieldValues,\n TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n> extends UseControllerProps<TFieldValues, TFieldName> {\n disabled?: boolean;\n required?: boolean;\n children?: React.ReactNode;\n defaultValue?: FieldPathValue<TFieldValues, TFieldName>;\n onChange?: (value: string) => Promise<void> | void;\n transform?: (value: string) => string;\n}\n\nconst defaultTransform = (value: string) => value;\n\nfunction TextField<\n TFieldValues extends FieldValues = FieldValues,\n TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n>({\n name,\n className,\n required,\n defaultValue,\n onChange,\n transform = defaultTransform,\n ...props\n}: TextFieldProps<TFieldValues, TFieldName> &\n Omit<InputTextProps, 'onChange'>) {\n const { control } = useFormContext();\n const id = useId();\n\n return (\n <FormField\n control={control}\n defaultValue={defaultValue}\n name={name}\n render={({ field, fieldState }) => (\n <FormItem className={cn('w-full', className)}>\n <InputText\n {...field}\n {...props}\n disabled={props.disabled}\n error={fieldState?.error && <FormMessage />}\n id={`${id}-${name}`}\n name={name}\n onChange={(e) => {\n field.onChange(transform(e.target.value));\n onChange?.(transform(e.target.value));\n }}\n required={required}\n value={field.value || ''}\n />\n </FormItem>\n )}\n rules={{\n required: required ? 'Campo obrigatório' : false,\n }}\n />\n );\n}\n\nexport interface QueryTextFieldProps extends Omit<InputTextProps, 'onChange'> {\n name: string;\n defaultValue?: string;\n options?: Options;\n onChange?: (value: string) => void;\n}\n\nfunction QueryTextField({\n name,\n defaultValue,\n options,\n ...props\n}: QueryTextFieldProps) {\n const id = useId();\n const [filter, setFilter] = useQueryState(\n name,\n parseAsString\n .withOptions({\n clearOnDefault: true,\n shallow: false,\n limitUrlUpdates: {\n method: 'debounce',\n timeMs: 400,\n },\n ...options,\n })\n .withDefault(defaultValue ?? '')\n );\n\n return (\n <InputText\n id={`${id}-${name}`}\n name={name}\n value={filter}\n {...props}\n onChange={(e) => {\n setFilter(e.target.value);\n props.onChange?.(e.target.value);\n }}\n />\n );\n}\n\nexport { InputText, TextField, QueryTextField };\n"],"mappings":";;;;;;;;;;;;;;;;AAQA,SAAS,MAAM,EACb,UACA,GAAG,SACgD;AACnD,QACE,CAAC,eAAe,KACd,WAAW,GACT,uNACA,UACD,EACD,sBACI;;;;;ACQV,MAAM,mBAAmB,MAAM,cAC7B,EAAE,CACH;AAED,MAAM,cAAc,MAAM,cAGvB,EAAE,CAAC;AAEN,MAAa,6BAA6B;CACxC,MAAM,UAAU,MAAM,WAAW,YAAY;AAC7C,KAAI,CAAC,QACH,QAAO,EAAE;AAEX,QAAO;;AAgBT,MAAM,aAGJ,EACA,GAAG,YACuC;AAC1C,QACE,CAAC,iBAAiB,SAAS,OAAO,EAAE,MAAM,MAAM,MAAM,EAAE;MACtD,CAAC,eAAe,SAAS;IAC3B,EAAE,iBAAiB;;AAIvB,MAAM,qBAAqB;CACzB,MAAM,eAAe,MAAM,WAAW,iBAA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,GAAG,QACb,MAAM,MACN,WAAW,MAAM;AACf,QAAM,SAAS,UAAU,EAAE,OAAO,MAAM,CAAC;AACzC,aAAW,UAAU,EAAE,OAAO,MAAM,CAAC;IAEvC,UAAU,UACV,OAAO,MAAM,SAAS,MACtB;QACJ,EAAE,WAEJ,OAAO,EACL,UAAU,WAAW,sBAAsB,OAC5C;;AAYP,SAAS,eAAe,EACtB,MACA,cACA,QACA,GAAG,SACmB;CACtB,MAAM,KAAK,OAAO;CAClB,MAAM,CAAC,QAAQ,aAAa,cAC1B,MACA,cACG,YAAY;EACX,gBAAgB;EAChB,SAAS;EACT,iBAAiB;GACf,QAAQ;GACR,QAAQ;GACT;EACD,GAAG;EACJ,CAAC,CACD,YAAY,gBAAgB,GAAG,CACnC;AAED,QACE,CAAC,UACC,IAAI,GAAG,GAAG,GAAG,QACb,MAAM,MACN,OAAO,YACH,OACJ,WAAW,MAAM;AACf,YAAU,EAAE,OAAO,MAAM;AACzB,QAAM,WAAW,EAAE,OAAO,MAAM"}
|
|
1
|
+
{"version":3,"file":"text-field.js","names":["ContentHelp: React.FC<{\n children: React.ReactNode;\n help?: React.ReactNode | string;\n className?: string;\n side?: 'top' | 'right' | 'bottom' | 'left';\n sideOffset?: number;\n}>","TooltipPortal","InputHelp: React.FC<{\n help?: string;\n name?: string;\n className?: string;\n}>"],"sources":["../src/components/ui/label.tsx","../src/components/ui/form.tsx","../src/components/ui/input.tsx","../src/components/ui/tooltip.tsx","../src/components/ui/content-help.tsx","../src/components/ui/input-help.tsx","../src/components/text-field/TextField.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\n\nimport * as LabelPrimitive from '@radix-ui/react-label';\n\nimport { cn } from '@/lib/utils';\n\nfunction Label({\n className,\n ...props\n}: React.ComponentProps<typeof LabelPrimitive.Root>) {\n return (\n <LabelPrimitive.Root\n className={cn(\n 'flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50',\n className\n )}\n data-slot=\"label\"\n {...props}\n />\n );\n}\n\nexport { Label };\n","'use client';\n\nimport * as React from 'react';\n\nimport {\n Controller,\n type ControllerProps,\n type FieldPath,\n type FieldValues,\n FormProvider,\n useFormContext,\n useFormState,\n} from 'react-hook-form';\n\nimport type * as LabelPrimitive from '@radix-ui/react-label';\nimport { Slot } from '@radix-ui/react-slot';\nimport { Label } from '@/components/ui/label';\n\nimport { cn } from '@/lib/utils';\n\ntype FormFieldContextValue<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n> = {\n name: TName;\n};\n\nconst FormFieldContext = React.createContext<FormFieldContextValue>(\n {} as FormFieldContextValue\n);\n\nconst FormContext = React.createContext<{\n onSubmit?: (data?: FieldValues) => void;\n helper?: Record<string, string>;\n}>({});\n\nexport const useFormContextSubmit = () => {\n const context = React.useContext(FormContext);\n if (!context) {\n return {};\n }\n return context;\n};\n\nconst Form: React.FC<\n React.ComponentProps<typeof FormProvider<FieldValues>> & {\n onSubmit?: (data?: FieldValues) => void;\n helper?: Record<string, string>;\n }\n> = ({ onSubmit, helper, ...props }) => {\n return (\n <FormContext.Provider value={{ onSubmit, helper }}>\n <FormProvider {...props} />\n </FormContext.Provider>\n );\n};\n\nconst FormField = <\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n>({\n ...props\n}: ControllerProps<TFieldValues, TName>) => {\n return (\n <FormFieldContext.Provider value={{ name: props.name }}>\n <Controller {...props} />\n </FormFieldContext.Provider>\n );\n};\n\nconst useFormField = () => {\n const fieldContext = React.useContext(FormFieldContext);\n const itemContext = React.useContext(FormItemContext);\n const { getFieldState } = useFormContext();\n const formState = useFormState({ name: fieldContext.name });\n const fieldState = getFieldState(fieldContext.name, formState);\n\n if (!fieldContext) {\n throw new Error('useFormField should be used within <FormField>');\n }\n\n const { id } = itemContext;\n\n return {\n id,\n name: fieldContext.name,\n formItemId: `${id}-form-item`,\n formDescriptionId: `${id}-form-item-description`,\n formMessageId: `${id}-form-item-message`,\n ...fieldState,\n };\n};\n\ntype FormItemContextValue = {\n id: string;\n};\n\nconst FormItemContext = React.createContext<FormItemContextValue>(\n {} as FormItemContextValue\n);\n\nfunction FormItem({ className, ...props }: React.ComponentProps<'div'>) {\n const id = React.useId();\n\n return (\n <FormItemContext.Provider value={{ id }}>\n <div\n className={cn('flex flex-col gap-1', className)}\n data-slot=\"form-item\"\n {...props}\n />\n </FormItemContext.Provider>\n );\n}\n\nfunction FormLabel({\n className,\n ...props\n}: React.ComponentProps<typeof LabelPrimitive.Root>) {\n const { error, formItemId } = useFormField();\n\n return (\n <Label\n className={cn('data-[error=true]:text-destructive', className)}\n data-error={!!error}\n data-slot=\"form-label\"\n htmlFor={formItemId}\n {...props}\n />\n );\n}\n\nfunction FormControl({ ...props }: React.ComponentProps<typeof Slot>) {\n const { error, formItemId, formDescriptionId, formMessageId } =\n useFormField();\n\n return (\n <Slot\n aria-describedby={\n !error\n ? `${formDescriptionId}`\n : `${formDescriptionId} ${formMessageId}`\n }\n aria-invalid={!!error}\n data-slot=\"form-control\"\n id={formItemId}\n {...props}\n />\n );\n}\n\nfunction FormDescription({ className, ...props }: React.ComponentProps<'p'>) {\n const { formDescriptionId } = useFormField();\n\n return (\n <p\n className={cn('text-muted-foreground text-sm', className)}\n data-slot=\"form-description\"\n id={formDescriptionId}\n {...props}\n />\n );\n}\n\nfunction FormMessage({ className, ...props }: React.ComponentProps<'p'>) {\n const { error, formMessageId } = useFormField();\n const body = error ? String(error?.message ?? '') : props.children;\n\n if (!body) {\n return null;\n }\n\n return (\n <p\n className={cn('text-destructive text-xs', className)}\n data-slot=\"form-message\"\n id={formMessageId}\n {...props}\n >\n {body}\n </p>\n );\n}\n\nexport {\n useFormField,\n Form,\n FormItem,\n FormLabel,\n FormControl,\n FormDescription,\n FormMessage,\n FormField,\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","'use client';\n\nimport * as React from 'react';\n\nimport * as TooltipPrimitive from '@radix-ui/react-tooltip';\n\nimport { cn } from '@/lib/utils';\n\nfunction TooltipProvider({\n delayDuration = 0,\n ...props\n}: React.ComponentProps<typeof TooltipPrimitive.Provider>) {\n return (\n <TooltipPrimitive.Provider\n data-slot=\"tooltip-provider\"\n delayDuration={delayDuration}\n {...props}\n />\n );\n}\n\nfunction Tooltip({\n ...props\n}: React.ComponentProps<typeof TooltipPrimitive.Root>) {\n return (\n <TooltipProvider>\n <TooltipPrimitive.Root data-slot=\"tooltip\" {...props} />\n </TooltipProvider>\n );\n}\n\nfunction TooltipTrigger({\n ...props\n}: React.ComponentProps<typeof TooltipPrimitive.Trigger>) {\n return <TooltipPrimitive.Trigger data-slot=\"tooltip-trigger\" {...props} />;\n}\n\nfunction TooltipContent({\n className,\n sideOffset = 0,\n children,\n ...props\n}: React.ComponentProps<typeof TooltipPrimitive.Content>) {\n return (\n <TooltipPrimitive.Portal>\n <TooltipPrimitive.Content\n className={cn(\n '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',\n className\n )}\n data-slot=\"tooltip-content\"\n sideOffset={sideOffset}\n {...props}\n >\n {children}\n <TooltipPrimitive.Arrow className=\"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]\" />\n </TooltipPrimitive.Content>\n </TooltipPrimitive.Portal>\n );\n}\n\nexport { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider };\n","import { Portal as TooltipPortal } from '@radix-ui/react-tooltip';\n\nimport { cn } from '@/lib/utils';\nimport { Tooltip, TooltipContent, TooltipTrigger } from './tooltip';\n\nconst ContentHelp: React.FC<{\n children: React.ReactNode;\n help?: React.ReactNode | string;\n className?: string;\n side?: 'top' | 'right' | 'bottom' | 'left';\n sideOffset?: number;\n}> = ({ children, help, className, side = 'top', sideOffset = 10 }) => {\n return help ? (\n <Tooltip delayDuration={250}>\n <TooltipTrigger asChild>{children as any}</TooltipTrigger>\n <TooltipPortal>\n <TooltipContent\n className={cn('flex items-center px-2 leading-none', className)}\n side={side}\n sideOffset={10}\n >\n <p className=\"w-full text-wrap whitespace-break-spaces\">{help}</p>\n </TooltipContent>\n </TooltipPortal>\n </Tooltip>\n ) : (\n children\n );\n};\n\nexport { ContentHelp };\n","'use client';\n\nimport { ContentHelp } from '@/components/ui/content-help';\n\nimport { Info } from 'lucide-react';\n\nimport { cn } from '@/lib/utils';\nimport { useFormContextSubmit } from './form';\n\nconst InputHelp: React.FC<{\n help?: string;\n name?: string;\n className?: string;\n}> = ({ help, name, className }) => {\n const { helper } = useFormContextSubmit();\n const helpText = (name && helper?.[name]) || help;\n\n return (\n helpText && (\n <ContentHelp\n className={cn(\n 'whitespace-pre-line leading-relaxed max-w-96 text-[13px]'\n )}\n help={helpText}\n >\n <button\n className={cn(\n 'mb-0.5 size-fit p-1 hover:bg-muted rounded-sm',\n className\n )}\n type=\"button\"\n >\n <Info className=\"size-3.5\" />\n </button>\n </ContentHelp>\n )\n );\n};\nexport { InputHelp };\n","'use client';\n\nimport { useId } from 'react';\n\nimport {\n type FieldPath,\n type FieldPathValue,\n type FieldValues,\n type UseControllerProps,\n useFormContext,\n} from 'react-hook-form';\nimport { type Options as MaskOptions, withMask } from 'use-mask-input';\n\nimport { FormField, FormItem, FormMessage } from '@/components/ui/form';\nimport { Input } from '@/components/ui/input';\nimport { InputHelp } from '@/components/ui/input-help';\nimport { Label } from '@/components/ui/label';\n\nimport { cn } from '@/lib/utils';\nimport { type Options, parseAsString, useQueryState } from 'nuqs';\n\ntype 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;\n\nexport interface InputTextProps\n extends React.InputHTMLAttributes<HTMLInputElement> {\n ref?: React.ForwardedRef<HTMLInputElement>;\n label?: string;\n placeholder?: string;\n description?: string;\n className?: string;\n disabled?: boolean;\n type?: string;\n required?: boolean;\n maskRef?: React.ForwardedRef<any>;\n children?: React.ReactNode;\n mask?: Mask;\n maskOptions?: MaskOptions;\n error?: React.ReactNode;\n id?: string;\n detail?: string;\n detailClassName?: string;\n inputClassName?: string;\n help?: string;\n}\n\nfunction InputText({\n label,\n description,\n placeholder,\n className,\n children,\n disabled,\n type,\n required,\n maskRef,\n mask,\n maskOptions,\n error,\n id,\n ref,\n detail,\n detailClassName,\n inputClassName,\n help,\n name,\n ...props\n}: InputTextProps) {\n return (\n <div\n className={cn('w-full flex flex-col gap-1', className)}\n id={`input-${name?.replace('.', '-')}`}\n ref={ref}\n >\n <div className=\"flex items-end gap-1.5\">\n <div className={cn('flex !gap-0 flex-col', className)}>\n {label && (\n <Label\n className={cn(\n error && 'text-destructive',\n className,\n disabled && 'text-muted-foreground',\n 'inline-flex items-center flex-row gap-0.5'\n )}\n htmlFor={id}\n >\n {label}:\n {required && (\n <span className=\"text-red-500 text-lg leading-[1px]\">*</span>\n )}\n </Label>\n )}\n {detail && (\n <Label\n className={cn(\n 'text-sm text-muted-foreground font-normal',\n detailClassName\n )}\n htmlFor={id}\n >\n {detail}\n </Label>\n )}\n </div>\n\n <InputHelp help={help} name={name} />\n </div>\n <div className=\"flex flex-col gap-0.5\">\n <div className=\"relative\">\n <Input\n className={cn(error && 'border-destructive', inputClassName)}\n disabled={disabled}\n id={id}\n placeholder={placeholder}\n ref={\n maskRef ||\n ((mask\n ? withMask(mask, {\n autoUnmask: true,\n ...maskOptions,\n showMaskOnHover: false,\n showMaskOnFocus: false,\n clearMaskOnLostFocus: true,\n })\n : undefined) as any)\n }\n type={type}\n {...props}\n />\n {children}\n </div>\n {description && (\n <p className={cn('text-sm text-muted-foreground', className)}>\n {description}\n </p>\n )}\n {error && error}\n </div>\n </div>\n );\n}\n\nexport interface TextFieldProps<\n TFieldValues extends FieldValues = FieldValues,\n TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n> extends UseControllerProps<TFieldValues, TFieldName> {\n disabled?: boolean;\n required?: boolean;\n children?: React.ReactNode;\n defaultValue?: FieldPathValue<TFieldValues, TFieldName>;\n onChange?: (value: string) => Promise<void> | void;\n transform?: (value: string) => string;\n}\n\nconst defaultTransform = (value: string) => value;\n\nfunction TextField<\n TFieldValues extends FieldValues = FieldValues,\n TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n>({\n name,\n className,\n required,\n defaultValue,\n onChange,\n transform = defaultTransform,\n ...props\n}: TextFieldProps<TFieldValues, TFieldName> &\n Omit<InputTextProps, 'onChange'>) {\n const { control } = useFormContext();\n const id = useId();\n\n return (\n <FormField\n control={control}\n defaultValue={defaultValue}\n name={name}\n render={({ field, fieldState }) => (\n <FormItem className={cn('w-full', className)}>\n <InputText\n {...field}\n {...props}\n disabled={props.disabled}\n error={fieldState?.error && <FormMessage />}\n id={`${id}-${name}`}\n name={name}\n onChange={(e) => {\n field.onChange(transform(e.target.value));\n onChange?.(transform(e.target.value));\n }}\n required={required}\n value={field.value || ''}\n />\n </FormItem>\n )}\n rules={{\n required: required ? 'Campo obrigatório' : false,\n }}\n />\n );\n}\n\nexport interface QueryTextFieldProps extends Omit<InputTextProps, 'onChange'> {\n name: string;\n defaultValue?: string;\n options?: Options;\n onChange?: (value: string) => void;\n}\n\nfunction QueryTextField({\n name,\n defaultValue,\n options,\n ...props\n}: QueryTextFieldProps) {\n const id = useId();\n const [filter, setFilter] = useQueryState(\n name,\n parseAsString\n .withOptions({\n clearOnDefault: true,\n shallow: false,\n limitUrlUpdates: {\n method: 'debounce',\n timeMs: 400,\n },\n ...options,\n })\n .withDefault(defaultValue ?? '')\n );\n\n return (\n <InputText\n id={`${id}-${name}`}\n name={name}\n value={filter}\n {...props}\n onChange={(e) => {\n setFilter(e.target.value);\n props.onChange?.(e.target.value);\n }}\n />\n );\n}\n\nexport { InputText, TextField, QueryTextField };\n"],"mappings":";;;;;;;;;;;;;;;;;AAQA,SAAS,MAAM,EACb,UACA,GAAG,SACgD;AACnD,QACE,oBAAC,eAAe;EACd,WAAW,GACT,uNACA,UACD;EACD,aAAU;EACV,GAAI;GACJ;;;;;ACON,MAAM,mBAAmB,MAAM,cAC7B,EAAE,CACH;AAED,MAAM,cAAc,MAAM,cAGvB,EAAE,CAAC;AAEN,MAAa,6BAA6B;CACxC,MAAM,UAAU,MAAM,WAAW,YAAY;AAC7C,KAAI,CAAC,QACH,QAAO,EAAE;AAEX,QAAO;;AAgBT,MAAM,aAGJ,EACA,GAAG,YACuC;AAC1C,QACE,oBAAC,iBAAiB;EAAS,OAAO,EAAE,MAAM,MAAM,MAAM;YACpD,oBAAC,cAAW,GAAI,QAAS;GACC;;AAIhC,MAAM,qBAAqB;CACzB,MAAM,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