maquinaweb-ui 1.2.0 → 1.3.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/README.md +48 -16
- package/dist/container-animation-BbZk1MyR.js +120 -0
- package/dist/container-animation-BbZk1MyR.js.map +1 -0
- package/dist/container-animation.d.ts +2 -0
- package/dist/container-animation.js +4 -0
- package/dist/index-BC9dAmE_.d.ts +29 -0
- package/dist/index-BC9dAmE_.d.ts.map +1 -0
- package/dist/index-D9G_ksi_.d.ts +81 -0
- package/dist/index-D9G_ksi_.d.ts.map +1 -0
- package/dist/index.d.ts +3 -89
- package/dist/index.js +4 -257
- package/dist/text-field-0up45ViU.js +183 -0
- package/dist/text-field-0up45ViU.js.map +1 -0
- package/dist/text-field.d.ts +2 -0
- package/dist/text-field.js +4 -0
- package/dist/utils-C0f9Ma6r.js +11 -0
- package/dist/utils-C0f9Ma6r.js.map +1 -0
- package/package.json +25 -3
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
package/README.md
CHANGED
|
@@ -176,14 +176,18 @@ bunx semantic-release
|
|
|
176
176
|
|
|
177
177
|
## 📝 Adding New Components
|
|
178
178
|
|
|
179
|
-
|
|
179
|
+
### 🤖 Automático - Exports são Gerados Automaticamente!
|
|
180
|
+
|
|
181
|
+
Ao criar um novo componente, os exports do `package.json` são atualizados automaticamente no build.
|
|
182
|
+
|
|
183
|
+
1. Create a new component directory (use **kebab-case**):
|
|
180
184
|
```bash
|
|
181
|
-
mkdir -p src/components/
|
|
185
|
+
mkdir -p src/components/your-component
|
|
182
186
|
```
|
|
183
187
|
|
|
184
188
|
2. Create the component file:
|
|
185
189
|
```tsx
|
|
186
|
-
// src/components/
|
|
190
|
+
// src/components/your-component/YourComponent.tsx
|
|
187
191
|
export interface YourComponentProps {
|
|
188
192
|
// Your props
|
|
189
193
|
}
|
|
@@ -194,16 +198,16 @@ bunx semantic-release
|
|
|
194
198
|
}
|
|
195
199
|
```
|
|
196
200
|
|
|
197
|
-
3. Create an index file:
|
|
201
|
+
3. **REQUIRED:** Create an index file:
|
|
198
202
|
```tsx
|
|
199
|
-
// src/components/
|
|
203
|
+
// src/components/your-component/index.ts
|
|
200
204
|
export { YourComponent } from "./YourComponent";
|
|
201
205
|
export type { YourComponentProps } from "./YourComponent";
|
|
202
206
|
```
|
|
203
207
|
|
|
204
|
-
4. Create Cosmos fixtures:
|
|
208
|
+
4. (Optional) Create Cosmos fixtures:
|
|
205
209
|
```tsx
|
|
206
|
-
// src/components/
|
|
210
|
+
// src/components/your-component/YourComponent.fixture.tsx
|
|
207
211
|
import { YourComponent } from "./YourComponent";
|
|
208
212
|
|
|
209
213
|
export default {
|
|
@@ -212,13 +216,27 @@ bunx semantic-release
|
|
|
212
216
|
};
|
|
213
217
|
```
|
|
214
218
|
|
|
215
|
-
5. Export from the
|
|
219
|
+
5. (Optional) Export from the main entry point:
|
|
216
220
|
```tsx
|
|
217
221
|
// src/index.ts
|
|
218
|
-
export { YourComponent } from "./components/
|
|
219
|
-
export type { YourComponentProps } from "./components/
|
|
222
|
+
export { YourComponent } from "./components/your-component";
|
|
223
|
+
export type { YourComponentProps } from "./components/your-component";
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
6. **Build and it's ready!**
|
|
227
|
+
```bash
|
|
228
|
+
bun run build
|
|
229
|
+
# ✅ Automatically updates package.json exports
|
|
230
|
+
# ✅ Creates maquinaweb-ui/your-component entrypoint
|
|
220
231
|
```
|
|
221
232
|
|
|
233
|
+
**📖 Exports são gerados automaticamente! Veja:**
|
|
234
|
+
- **Apenas exports base são versionados no Git** (via git hooks)
|
|
235
|
+
- **Exports completos são gerados no build local** (para testes)
|
|
236
|
+
- **Exports completos são gerados no publish** (via prepublishOnly)
|
|
237
|
+
|
|
238
|
+
Para mais detalhes: [GIT_EXPORTS.md](./GIT_EXPORTS.md)
|
|
239
|
+
|
|
222
240
|
## 🔧 Configuration Files
|
|
223
241
|
|
|
224
242
|
### `tsup.config.ts`
|
|
@@ -256,20 +274,34 @@ TypeScript configuration:
|
|
|
256
274
|
|
|
257
275
|
After installing your published package:
|
|
258
276
|
|
|
277
|
+
### Basic Import (All Components)
|
|
278
|
+
|
|
259
279
|
```tsx
|
|
260
|
-
import {
|
|
280
|
+
import { TextField, ContainerAnimation } from "maquinaweb-ui";
|
|
261
281
|
|
|
262
282
|
function App() {
|
|
263
283
|
return (
|
|
264
|
-
<
|
|
265
|
-
<
|
|
266
|
-
|
|
267
|
-
</Button>
|
|
268
|
-
</div>
|
|
284
|
+
<ContainerAnimation>
|
|
285
|
+
<TextField name="email" label="Email" />
|
|
286
|
+
</ContainerAnimation>
|
|
269
287
|
);
|
|
270
288
|
}
|
|
271
289
|
```
|
|
272
290
|
|
|
291
|
+
### Tree-shakable Imports (Optimized)
|
|
292
|
+
|
|
293
|
+
This library supports multiple entrypoints for better tree-shaking:
|
|
294
|
+
|
|
295
|
+
```tsx
|
|
296
|
+
// Import only form components (~2.85 kB)
|
|
297
|
+
import { TextField, InputText } from "maquinaweb-ui/text-field";
|
|
298
|
+
|
|
299
|
+
// Import only animation components (~1.54 kB)
|
|
300
|
+
import { ContainerAnimation } from "maquinaweb-ui/animation";
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
**📖 For detailed usage and bundle size comparison, see [ENTRYPOINTS.md](./ENTRYPOINTS.md)**
|
|
304
|
+
|
|
273
305
|
## 🤝 Contributing
|
|
274
306
|
|
|
275
307
|
1. Create a new branch for your feature
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { cn } from "./utils-C0f9Ma6r.js";
|
|
2
|
+
import { useEffect, useRef, useState } from "react";
|
|
3
|
+
import * as motion from "motion/react-m";
|
|
4
|
+
|
|
5
|
+
//#region node_modules/motion-dom/dist/es/utils/resolve-elements.mjs
|
|
6
|
+
function resolveElements(elementOrSelector, scope, selectorCache) {
|
|
7
|
+
if (elementOrSelector instanceof EventTarget) return [elementOrSelector];
|
|
8
|
+
else if (typeof elementOrSelector === "string") {
|
|
9
|
+
let root = document;
|
|
10
|
+
if (scope) root = scope.current;
|
|
11
|
+
const elements = selectorCache?.[elementOrSelector] ?? root.querySelectorAll(elementOrSelector);
|
|
12
|
+
return elements ? Array.from(elements) : [];
|
|
13
|
+
}
|
|
14
|
+
return Array.from(elementOrSelector);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region node_modules/framer-motion/dist/es/render/dom/viewport/index.mjs
|
|
19
|
+
const thresholds = {
|
|
20
|
+
some: 0,
|
|
21
|
+
all: 1
|
|
22
|
+
};
|
|
23
|
+
function inView(elementOrSelector, onStart, { root, margin: rootMargin, amount = "some" } = {}) {
|
|
24
|
+
const elements = resolveElements(elementOrSelector);
|
|
25
|
+
const activeIntersections = /* @__PURE__ */ new WeakMap();
|
|
26
|
+
const onIntersectionChange = (entries) => {
|
|
27
|
+
entries.forEach((entry) => {
|
|
28
|
+
const onEnd = activeIntersections.get(entry.target);
|
|
29
|
+
/**
|
|
30
|
+
* If there's no change to the intersection, we don't need to
|
|
31
|
+
* do anything here.
|
|
32
|
+
*/
|
|
33
|
+
if (entry.isIntersecting === Boolean(onEnd)) return;
|
|
34
|
+
if (entry.isIntersecting) {
|
|
35
|
+
const newOnEnd = onStart(entry.target, entry);
|
|
36
|
+
if (typeof newOnEnd === "function") activeIntersections.set(entry.target, newOnEnd);
|
|
37
|
+
else observer.unobserve(entry.target);
|
|
38
|
+
} else if (typeof onEnd === "function") {
|
|
39
|
+
onEnd(entry);
|
|
40
|
+
activeIntersections.delete(entry.target);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
const observer = new IntersectionObserver(onIntersectionChange, {
|
|
45
|
+
root,
|
|
46
|
+
rootMargin,
|
|
47
|
+
threshold: typeof amount === "number" ? amount : thresholds[amount]
|
|
48
|
+
});
|
|
49
|
+
elements.forEach((element) => observer.observe(element));
|
|
50
|
+
return () => observer.disconnect();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
//#endregion
|
|
54
|
+
//#region node_modules/framer-motion/dist/es/utils/use-in-view.mjs
|
|
55
|
+
function useInView(ref, { root, margin, amount, once = false, initial = false } = {}) {
|
|
56
|
+
const [isInView, setInView] = useState(initial);
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
if (!ref.current || once && isInView) return;
|
|
59
|
+
const onEnter = () => {
|
|
60
|
+
setInView(true);
|
|
61
|
+
return once ? void 0 : () => setInView(false);
|
|
62
|
+
};
|
|
63
|
+
const options = {
|
|
64
|
+
root: root && root.current || void 0,
|
|
65
|
+
margin,
|
|
66
|
+
amount
|
|
67
|
+
};
|
|
68
|
+
return inView(ref.current, onEnter, options);
|
|
69
|
+
}, [
|
|
70
|
+
root,
|
|
71
|
+
ref,
|
|
72
|
+
margin,
|
|
73
|
+
once,
|
|
74
|
+
amount
|
|
75
|
+
]);
|
|
76
|
+
return isInView;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
//#endregion
|
|
80
|
+
//#region src/components/container-animation/ContainerAnimation.tsx
|
|
81
|
+
const getVariants = (position, space, delay) => {
|
|
82
|
+
const directions = {
|
|
83
|
+
top: { transform: `translateY(${space}px)` },
|
|
84
|
+
bottom: { transform: `translateY(-${space}px)` },
|
|
85
|
+
left: { transform: `translateX(${space}px)` },
|
|
86
|
+
right: { transform: `translateX(-${space}px)` }
|
|
87
|
+
};
|
|
88
|
+
return {
|
|
89
|
+
hidden: {
|
|
90
|
+
opacity: 0,
|
|
91
|
+
filter: "blur(6px)",
|
|
92
|
+
...directions[position] || directions.top
|
|
93
|
+
},
|
|
94
|
+
visible: {
|
|
95
|
+
opacity: 1,
|
|
96
|
+
filter: "blur(0px)",
|
|
97
|
+
transform: "translateY(0px) translateX(0px)",
|
|
98
|
+
transition: {
|
|
99
|
+
delay,
|
|
100
|
+
duration: .5,
|
|
101
|
+
staggerChildren: .1
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
const ContainerAnimation = ({ className, children, position = "top", delay = 0, space = 20, duration = .8, as: As = "div", distance = [95, 5], hideNotInView = false,...props }) => {
|
|
107
|
+
const ref = useRef(null);
|
|
108
|
+
const isInView = useInView(ref, {
|
|
109
|
+
once: true,
|
|
110
|
+
margin: `-${100 - (distance[0] || 0)}% 0% -${distance[1] || 0}% 0%`
|
|
111
|
+
});
|
|
112
|
+
const variants = getVariants(position, space, delay);
|
|
113
|
+
return <motion.div animate={isInView ? "visible" : "hidden"} className={cn("initial-opacity", className)} initial="hidden" transition={{ duration }} variants={variants} {...props} ref={ref}>
|
|
114
|
+
{(!hideNotInView || isInView) && children}
|
|
115
|
+
</motion.div>;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
//#endregion
|
|
119
|
+
export { ContainerAnimation };
|
|
120
|
+
//# sourceMappingURL=container-animation-BbZk1MyR.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"container-animation-BbZk1MyR.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/ContainerAnimation.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,sCA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L,WAAW,eAAe,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,CAAC,OAAO,IACN,SAAS,WAAW,YAAY,UAChC,WAAW,GAAG,mBAAmB,UAAU,EAC3C,iBACA,YAAY,EAAE,UAAU,EACxB,UAAU,cACN,OACJ,KAAK,KACN;QACG,CAAC,iBAAiB,aAAa,SAAS;IAC5C,EAAE,OAAO"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as react2 from "react";
|
|
2
|
+
import { ComponentProps, ElementType } from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/components/container-animation/ContainerAnimation.d.ts
|
|
5
|
+
type ContainerAnimationProps<T extends ElementType = 'div'> = ComponentProps<'div'> & ComponentProps<T> & {
|
|
6
|
+
position?: 'top' | 'bottom' | 'left' | 'right';
|
|
7
|
+
delay?: number;
|
|
8
|
+
space?: number;
|
|
9
|
+
duration?: number;
|
|
10
|
+
distance?: [number, number];
|
|
11
|
+
hideNotInView?: boolean;
|
|
12
|
+
as?: T | string;
|
|
13
|
+
className?: string;
|
|
14
|
+
};
|
|
15
|
+
declare const ContainerAnimation: <T extends ElementType = "div">({
|
|
16
|
+
className,
|
|
17
|
+
children,
|
|
18
|
+
position,
|
|
19
|
+
delay,
|
|
20
|
+
space,
|
|
21
|
+
duration,
|
|
22
|
+
as: As,
|
|
23
|
+
distance,
|
|
24
|
+
hideNotInView,
|
|
25
|
+
...props
|
|
26
|
+
}: ContainerAnimationProps<T>) => react2.JSX.Element;
|
|
27
|
+
//#endregion
|
|
28
|
+
export { ContainerAnimation, type ContainerAnimationProps };
|
|
29
|
+
//# sourceMappingURL=index-BC9dAmE_.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-BC9dAmE_.d.ts","names":[],"sources":["../src/components/container-animation/ContainerAnimation.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,MAAA,CAAA,GAAA,CAAA,OAfjB"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import * as react0 from "react";
|
|
2
|
+
import { FieldPath, FieldPathValue, FieldValues, UseControllerProps } from "react-hook-form";
|
|
3
|
+
import { Options } from "use-mask-input";
|
|
4
|
+
import { Options as Options$1 } from "nuqs";
|
|
5
|
+
|
|
6
|
+
//#region src/components/text-field/TextField.d.ts
|
|
7
|
+
type Mask = 'datetime' | 'email' | 'numeric' | 'currency' | 'decimal' | 'integer' | 'percentage' | 'url' | 'ip' | 'mac' | 'ssn' | 'brl-currency' | 'cpf' | 'cnpj' | (string & {}) | (string[] & {}) | null;
|
|
8
|
+
interface InputTextProps extends React.InputHTMLAttributes<HTMLInputElement> {
|
|
9
|
+
ref?: React.ForwardedRef<HTMLInputElement>;
|
|
10
|
+
label?: string;
|
|
11
|
+
placeholder?: string;
|
|
12
|
+
description?: string;
|
|
13
|
+
className?: string;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
type?: string;
|
|
16
|
+
required?: boolean;
|
|
17
|
+
maskRef?: React.ForwardedRef<any>;
|
|
18
|
+
children?: React.ReactNode;
|
|
19
|
+
mask?: Mask;
|
|
20
|
+
maskOptions?: Options;
|
|
21
|
+
error?: React.ReactNode;
|
|
22
|
+
id?: string;
|
|
23
|
+
detail?: string;
|
|
24
|
+
detailClassName?: string;
|
|
25
|
+
inputClassName?: string;
|
|
26
|
+
help?: string;
|
|
27
|
+
}
|
|
28
|
+
declare function InputText({
|
|
29
|
+
label,
|
|
30
|
+
description,
|
|
31
|
+
placeholder,
|
|
32
|
+
className,
|
|
33
|
+
children,
|
|
34
|
+
disabled,
|
|
35
|
+
type,
|
|
36
|
+
required,
|
|
37
|
+
maskRef,
|
|
38
|
+
mask,
|
|
39
|
+
maskOptions,
|
|
40
|
+
error,
|
|
41
|
+
id,
|
|
42
|
+
ref,
|
|
43
|
+
detail,
|
|
44
|
+
detailClassName,
|
|
45
|
+
inputClassName,
|
|
46
|
+
help,
|
|
47
|
+
name,
|
|
48
|
+
...props
|
|
49
|
+
}: InputTextProps): react0.JSX.Element;
|
|
50
|
+
interface TextFieldProps<TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> extends UseControllerProps<TFieldValues, TFieldName> {
|
|
51
|
+
disabled?: boolean;
|
|
52
|
+
required?: boolean;
|
|
53
|
+
children?: React.ReactNode;
|
|
54
|
+
defaultValue?: FieldPathValue<TFieldValues, TFieldName>;
|
|
55
|
+
onChange?: (value: string) => Promise<void> | void;
|
|
56
|
+
transform?: (value: string) => string;
|
|
57
|
+
}
|
|
58
|
+
declare function TextField<TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({
|
|
59
|
+
name,
|
|
60
|
+
className,
|
|
61
|
+
required,
|
|
62
|
+
defaultValue,
|
|
63
|
+
onChange,
|
|
64
|
+
transform,
|
|
65
|
+
...props
|
|
66
|
+
}: TextFieldProps<TFieldValues, TFieldName> & Omit<InputTextProps, 'onChange'>): react0.JSX.Element;
|
|
67
|
+
interface QueryTextFieldProps extends Omit<InputTextProps, 'onChange'> {
|
|
68
|
+
name: string;
|
|
69
|
+
defaultValue?: string;
|
|
70
|
+
options?: Options$1;
|
|
71
|
+
onChange?: (value: string) => void;
|
|
72
|
+
}
|
|
73
|
+
declare function QueryTextField({
|
|
74
|
+
name,
|
|
75
|
+
defaultValue,
|
|
76
|
+
options,
|
|
77
|
+
...props
|
|
78
|
+
}: QueryTextFieldProps): react0.JSX.Element;
|
|
79
|
+
//#endregion
|
|
80
|
+
export { InputText, type InputTextProps, QueryTextField, type QueryTextFieldProps, TextField, type TextFieldProps };
|
|
81
|
+
//# sourceMappingURL=index-D9G_ksi_.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-D9G_ksi_.d.ts","names":[],"sources":["../src/components/text-field/TextField.tsx"],"sourcesContent":[],"mappings":";;;;;;KAqBK,IAAA;UAmBY,cAAA,SACP,KAAA,CAAM,oBAAoB;QAC5B,KAAA,CAAM,aAAa;EArBtB,KAAA,CAAA,EAAI,MAAA;EAmBQ,WAAA,CAAA,EAAA,MACf;EAAA,WAAA,CAAA,EAAA,MAAA;WAAkC,CAAA,EAAA,MAAA;UACT,CAAA,EAAA,OAAA;MAAnB,CAAA,EAAA,MAAM;UAQF,CAAM,EAAA,OAAA;SACL,CAAA,EADD,KAAA,CAAM,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,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,MAAA,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,MAAA,CAAA,GAAA,CAAA,OAnJnB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,89 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import { Options } from "use-mask-input";
|
|
5
|
-
import { Options as Options$1 } from "nuqs";
|
|
6
|
-
|
|
7
|
-
//#region src/components/container-animation/ContainerAnimation.d.ts
|
|
8
|
-
type ContainerAnimationProps<T extends ElementType = 'div'> = ComponentProps<'div'> & ComponentProps<T> & {
|
|
9
|
-
position?: 'top' | 'bottom' | 'left' | 'right';
|
|
10
|
-
delay?: number;
|
|
11
|
-
space?: number;
|
|
12
|
-
duration?: number;
|
|
13
|
-
distance?: [number, number];
|
|
14
|
-
hideNotInView?: boolean;
|
|
15
|
-
as?: T | string;
|
|
16
|
-
className?: string;
|
|
17
|
-
};
|
|
18
|
-
declare const ContainerAnimation: <T extends ElementType = "div">({
|
|
19
|
-
className,
|
|
20
|
-
children,
|
|
21
|
-
position,
|
|
22
|
-
delay,
|
|
23
|
-
space,
|
|
24
|
-
duration,
|
|
25
|
-
as: As,
|
|
26
|
-
distance,
|
|
27
|
-
hideNotInView,
|
|
28
|
-
...props
|
|
29
|
-
}: ContainerAnimationProps<T>) => react2.JSX.Element;
|
|
30
|
-
//#endregion
|
|
31
|
-
//#region src/components/text-field/TextField.d.ts
|
|
32
|
-
type Mask = 'datetime' | 'email' | 'numeric' | 'currency' | 'decimal' | 'integer' | 'percentage' | 'url' | 'ip' | 'mac' | 'ssn' | 'brl-currency' | 'cpf' | 'cnpj' | (string & {}) | (string[] & {}) | null;
|
|
33
|
-
interface InputTextProps extends React.InputHTMLAttributes<HTMLInputElement> {
|
|
34
|
-
ref?: React.ForwardedRef<HTMLInputElement>;
|
|
35
|
-
label?: string;
|
|
36
|
-
placeholder?: string;
|
|
37
|
-
description?: string;
|
|
38
|
-
className?: string;
|
|
39
|
-
disabled?: boolean;
|
|
40
|
-
type?: string;
|
|
41
|
-
required?: boolean;
|
|
42
|
-
maskRef?: React.ForwardedRef<any>;
|
|
43
|
-
children?: React.ReactNode;
|
|
44
|
-
mask?: Mask;
|
|
45
|
-
maskOptions?: Options;
|
|
46
|
-
error?: React.ReactNode;
|
|
47
|
-
id?: string;
|
|
48
|
-
detail?: string;
|
|
49
|
-
detailClassName?: string;
|
|
50
|
-
inputClassName?: string;
|
|
51
|
-
help?: string;
|
|
52
|
-
}
|
|
53
|
-
declare function InputText({
|
|
54
|
-
label,
|
|
55
|
-
description,
|
|
56
|
-
placeholder,
|
|
57
|
-
className,
|
|
58
|
-
children,
|
|
59
|
-
disabled,
|
|
60
|
-
type,
|
|
61
|
-
required,
|
|
62
|
-
maskRef,
|
|
63
|
-
mask,
|
|
64
|
-
maskOptions,
|
|
65
|
-
error,
|
|
66
|
-
id,
|
|
67
|
-
ref,
|
|
68
|
-
detail,
|
|
69
|
-
detailClassName,
|
|
70
|
-
inputClassName,
|
|
71
|
-
help,
|
|
72
|
-
name,
|
|
73
|
-
...props
|
|
74
|
-
}: InputTextProps): react2.JSX.Element;
|
|
75
|
-
interface QueryTextFieldProps extends Omit<InputTextProps, 'onChange'> {
|
|
76
|
-
name: string;
|
|
77
|
-
defaultValue?: string;
|
|
78
|
-
options?: Options$1;
|
|
79
|
-
onChange?: (value: string) => void;
|
|
80
|
-
}
|
|
81
|
-
declare function QueryTextField({
|
|
82
|
-
name,
|
|
83
|
-
defaultValue,
|
|
84
|
-
options,
|
|
85
|
-
...props
|
|
86
|
-
}: QueryTextFieldProps): react2.JSX.Element;
|
|
87
|
-
//#endregion
|
|
88
|
-
export { ContainerAnimation, type ContainerAnimationProps, InputText, type InputTextProps, QueryTextField, type QueryTextFieldProps };
|
|
89
|
-
//# sourceMappingURL=index.d.ts.map
|
|
1
|
+
import { ContainerAnimation, ContainerAnimationProps } from "./index-BC9dAmE_.js";
|
|
2
|
+
import { InputText, InputTextProps, QueryTextField, QueryTextFieldProps } from "./index-D9G_ksi_.js";
|
|
3
|
+
export { ContainerAnimation, type ContainerAnimationProps, InputText, type InputTextProps, QueryTextField, type QueryTextFieldProps };
|
package/dist/index.js
CHANGED
|
@@ -1,258 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { twMerge } from "tailwind-merge";
|
|
5
|
-
import * as motion from "motion/react-m";
|
|
6
|
-
import "react-hook-form";
|
|
7
|
-
import { withMask } from "use-mask-input";
|
|
8
|
-
import "@radix-ui/react-slot";
|
|
9
|
-
import * as LabelPrimitive from "@radix-ui/react-label";
|
|
10
|
-
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
|
11
|
-
import { Portal } from "@radix-ui/react-tooltip";
|
|
12
|
-
import { Info } from "lucide-react";
|
|
13
|
-
import { parseAsString, useQueryState } from "nuqs";
|
|
1
|
+
import "./utils-C0f9Ma6r.js";
|
|
2
|
+
import { ContainerAnimation } from "./container-animation-BbZk1MyR.js";
|
|
3
|
+
import { InputText, QueryTextField } from "./text-field-0up45ViU.js";
|
|
14
4
|
|
|
15
|
-
|
|
16
|
-
function cn(...inputs) {
|
|
17
|
-
return twMerge(clsx(inputs));
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
//#endregion
|
|
21
|
-
//#region node_modules/motion-dom/dist/es/utils/resolve-elements.mjs
|
|
22
|
-
function resolveElements(elementOrSelector, scope, selectorCache) {
|
|
23
|
-
if (elementOrSelector instanceof EventTarget) return [elementOrSelector];
|
|
24
|
-
else if (typeof elementOrSelector === "string") {
|
|
25
|
-
let root = document;
|
|
26
|
-
if (scope) root = scope.current;
|
|
27
|
-
const elements = selectorCache?.[elementOrSelector] ?? root.querySelectorAll(elementOrSelector);
|
|
28
|
-
return elements ? Array.from(elements) : [];
|
|
29
|
-
}
|
|
30
|
-
return Array.from(elementOrSelector);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
//#endregion
|
|
34
|
-
//#region node_modules/framer-motion/dist/es/render/dom/viewport/index.mjs
|
|
35
|
-
const thresholds = {
|
|
36
|
-
some: 0,
|
|
37
|
-
all: 1
|
|
38
|
-
};
|
|
39
|
-
function inView(elementOrSelector, onStart, { root, margin: rootMargin, amount = "some" } = {}) {
|
|
40
|
-
const elements = resolveElements(elementOrSelector);
|
|
41
|
-
const activeIntersections = /* @__PURE__ */ new WeakMap();
|
|
42
|
-
const onIntersectionChange = (entries) => {
|
|
43
|
-
entries.forEach((entry) => {
|
|
44
|
-
const onEnd = activeIntersections.get(entry.target);
|
|
45
|
-
/**
|
|
46
|
-
* If there's no change to the intersection, we don't need to
|
|
47
|
-
* do anything here.
|
|
48
|
-
*/
|
|
49
|
-
if (entry.isIntersecting === Boolean(onEnd)) return;
|
|
50
|
-
if (entry.isIntersecting) {
|
|
51
|
-
const newOnEnd = onStart(entry.target, entry);
|
|
52
|
-
if (typeof newOnEnd === "function") activeIntersections.set(entry.target, newOnEnd);
|
|
53
|
-
else observer.unobserve(entry.target);
|
|
54
|
-
} else if (typeof onEnd === "function") {
|
|
55
|
-
onEnd(entry);
|
|
56
|
-
activeIntersections.delete(entry.target);
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
};
|
|
60
|
-
const observer = new IntersectionObserver(onIntersectionChange, {
|
|
61
|
-
root,
|
|
62
|
-
rootMargin,
|
|
63
|
-
threshold: typeof amount === "number" ? amount : thresholds[amount]
|
|
64
|
-
});
|
|
65
|
-
elements.forEach((element) => observer.observe(element));
|
|
66
|
-
return () => observer.disconnect();
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
//#endregion
|
|
70
|
-
//#region node_modules/framer-motion/dist/es/utils/use-in-view.mjs
|
|
71
|
-
function useInView(ref, { root, margin, amount, once = false, initial = false } = {}) {
|
|
72
|
-
const [isInView, setInView] = useState(initial);
|
|
73
|
-
useEffect(() => {
|
|
74
|
-
if (!ref.current || once && isInView) return;
|
|
75
|
-
const onEnter = () => {
|
|
76
|
-
setInView(true);
|
|
77
|
-
return once ? void 0 : () => setInView(false);
|
|
78
|
-
};
|
|
79
|
-
const options = {
|
|
80
|
-
root: root && root.current || void 0,
|
|
81
|
-
margin,
|
|
82
|
-
amount
|
|
83
|
-
};
|
|
84
|
-
return inView(ref.current, onEnter, options);
|
|
85
|
-
}, [
|
|
86
|
-
root,
|
|
87
|
-
ref,
|
|
88
|
-
margin,
|
|
89
|
-
once,
|
|
90
|
-
amount
|
|
91
|
-
]);
|
|
92
|
-
return isInView;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
//#endregion
|
|
96
|
-
//#region src/components/container-animation/ContainerAnimation.tsx
|
|
97
|
-
const getVariants = (position, space, delay) => {
|
|
98
|
-
const directions = {
|
|
99
|
-
top: { transform: `translateY(${space}px)` },
|
|
100
|
-
bottom: { transform: `translateY(-${space}px)` },
|
|
101
|
-
left: { transform: `translateX(${space}px)` },
|
|
102
|
-
right: { transform: `translateX(-${space}px)` }
|
|
103
|
-
};
|
|
104
|
-
return {
|
|
105
|
-
hidden: {
|
|
106
|
-
opacity: 0,
|
|
107
|
-
filter: "blur(6px)",
|
|
108
|
-
...directions[position] || directions.top
|
|
109
|
-
},
|
|
110
|
-
visible: {
|
|
111
|
-
opacity: 1,
|
|
112
|
-
filter: "blur(0px)",
|
|
113
|
-
transform: "translateY(0px) translateX(0px)",
|
|
114
|
-
transition: {
|
|
115
|
-
delay,
|
|
116
|
-
duration: .5,
|
|
117
|
-
staggerChildren: .1
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
};
|
|
122
|
-
const ContainerAnimation = ({ className, children, position = "top", delay = 0, space = 20, duration = .8, as: As = "div", distance = [95, 5], hideNotInView = false,...props }) => {
|
|
123
|
-
const ref = useRef(null);
|
|
124
|
-
const isInView = useInView(ref, {
|
|
125
|
-
once: true,
|
|
126
|
-
margin: `-${100 - (distance[0] || 0)}% 0% -${distance[1] || 0}% 0%`
|
|
127
|
-
});
|
|
128
|
-
const variants = getVariants(position, space, delay);
|
|
129
|
-
return <motion.div animate={isInView ? "visible" : "hidden"} className={cn("initial-opacity", className)} initial="hidden" transition={{ duration }} variants={variants} {...props} ref={ref}>
|
|
130
|
-
{(!hideNotInView || isInView) && children}
|
|
131
|
-
</motion.div>;
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
//#endregion
|
|
135
|
-
//#region src/components/ui/label.tsx
|
|
136
|
-
function Label({ className,...props }) {
|
|
137
|
-
return <LabelPrimitive.Root 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)} data-slot="label" {...props} />;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
//#endregion
|
|
141
|
-
//#region src/components/ui/form.tsx
|
|
142
|
-
const FormFieldContext = React.createContext({});
|
|
143
|
-
const FormContext = React.createContext({});
|
|
144
|
-
const useFormContextSubmit = () => {
|
|
145
|
-
const context = React.useContext(FormContext);
|
|
146
|
-
if (!context) return {};
|
|
147
|
-
return context;
|
|
148
|
-
};
|
|
149
|
-
const FormItemContext = React.createContext({});
|
|
150
|
-
|
|
151
|
-
//#endregion
|
|
152
|
-
//#region src/components/ui/input.tsx
|
|
153
|
-
function Input({ className, type,...props }) {
|
|
154
|
-
return <input 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)} data-slot="input" type={type} {...props} />;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
//#endregion
|
|
158
|
-
//#region src/components/ui/tooltip.tsx
|
|
159
|
-
function TooltipProvider({ delayDuration = 0,...props }) {
|
|
160
|
-
return <TooltipPrimitive.Provider data-slot="tooltip-provider" delayDuration={delayDuration} {...props} />;
|
|
161
|
-
}
|
|
162
|
-
function Tooltip({ ...props }) {
|
|
163
|
-
return <TooltipProvider>
|
|
164
|
-
<TooltipPrimitive.Root data-slot="tooltip" {...props} />
|
|
165
|
-
</TooltipProvider>;
|
|
166
|
-
}
|
|
167
|
-
function TooltipTrigger({ ...props }) {
|
|
168
|
-
return <TooltipPrimitive.Trigger data-slot="tooltip-trigger" {...props} />;
|
|
169
|
-
}
|
|
170
|
-
function TooltipContent({ className, sideOffset = 0, children,...props }) {
|
|
171
|
-
return <TooltipPrimitive.Portal>
|
|
172
|
-
<TooltipPrimitive.Content 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)} data-slot="tooltip-content" sideOffset={sideOffset} {...props}>
|
|
173
|
-
{children}
|
|
174
|
-
<TooltipPrimitive.Arrow className="bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]" />
|
|
175
|
-
</TooltipPrimitive.Content>
|
|
176
|
-
</TooltipPrimitive.Portal>;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
//#endregion
|
|
180
|
-
//#region src/components/ui/content-help.tsx
|
|
181
|
-
const ContentHelp = ({ children, help, className, side = "top", sideOffset = 10 }) => {
|
|
182
|
-
return help ? <Tooltip delayDuration={250}>
|
|
183
|
-
<TooltipTrigger asChild>{children}</TooltipTrigger>
|
|
184
|
-
<Portal>
|
|
185
|
-
<TooltipContent className={cn("flex items-center px-2 leading-none", className)} side={side} sideOffset={10}>
|
|
186
|
-
<p className="w-full text-wrap whitespace-break-spaces">{help}</p>
|
|
187
|
-
</TooltipContent>
|
|
188
|
-
</Portal>
|
|
189
|
-
</Tooltip> : children;
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
//#endregion
|
|
193
|
-
//#region src/components/ui/input-help.tsx
|
|
194
|
-
const InputHelp = ({ help, name, className }) => {
|
|
195
|
-
const { helper } = useFormContextSubmit();
|
|
196
|
-
const helpText = name && helper?.[name] || help;
|
|
197
|
-
return helpText && <ContentHelp className={cn("whitespace-pre-line leading-relaxed max-w-96 text-[13px]")} help={helpText}>
|
|
198
|
-
<button className={cn("mb-0.5 size-fit p-1 hover:bg-muted rounded-sm", className)} type="button">
|
|
199
|
-
<Info className="size-3.5" />
|
|
200
|
-
</button>
|
|
201
|
-
</ContentHelp>;
|
|
202
|
-
};
|
|
203
|
-
|
|
204
|
-
//#endregion
|
|
205
|
-
//#region src/components/text-field/TextField.tsx
|
|
206
|
-
function InputText({ label, description, placeholder, className, children, disabled, type, required, maskRef, mask, maskOptions, error, id, ref, detail, detailClassName, inputClassName, help, name,...props }) {
|
|
207
|
-
return <div className={cn("w-full flex flex-col gap-1", className)} id={`input-${name?.replace(".", "-")}`} ref={ref}>
|
|
208
|
-
<div className="flex items-end gap-1.5">
|
|
209
|
-
<div className={cn("flex !gap-0 flex-col", className)}>
|
|
210
|
-
{label && <Label className={cn(error && "text-destructive", className, disabled && "text-muted-foreground", "inline-flex items-center flex-row gap-0.5")} htmlFor={id}>
|
|
211
|
-
{label}:
|
|
212
|
-
{required && <span className="text-red-500 text-lg leading-[1px]">*</span>}
|
|
213
|
-
</Label>}
|
|
214
|
-
{detail && <Label className={cn("text-sm text-muted-foreground font-normal", detailClassName)} htmlFor={id}>
|
|
215
|
-
{detail}
|
|
216
|
-
</Label>}
|
|
217
|
-
</div>
|
|
218
|
-
|
|
219
|
-
<InputHelp help={help} name={name} />
|
|
220
|
-
</div>
|
|
221
|
-
<div className="flex flex-col gap-0.5">
|
|
222
|
-
<div className="relative">
|
|
223
|
-
<Input className={cn(error && "border-destructive", inputClassName)} disabled={disabled} id={id} placeholder={placeholder} ref={maskRef || (mask ? withMask(mask, {
|
|
224
|
-
autoUnmask: true,
|
|
225
|
-
...maskOptions,
|
|
226
|
-
showMaskOnHover: false,
|
|
227
|
-
showMaskOnFocus: false,
|
|
228
|
-
clearMaskOnLostFocus: true
|
|
229
|
-
}) : void 0)} type={type} {...props} />
|
|
230
|
-
{children}
|
|
231
|
-
</div>
|
|
232
|
-
{description && <p className={cn("text-sm text-muted-foreground", className)}>
|
|
233
|
-
{description}
|
|
234
|
-
</p>}
|
|
235
|
-
{error && error}
|
|
236
|
-
</div>
|
|
237
|
-
</div>;
|
|
238
|
-
}
|
|
239
|
-
function QueryTextField({ name, defaultValue, options,...props }) {
|
|
240
|
-
const id = useId();
|
|
241
|
-
const [filter, setFilter] = useQueryState(name, parseAsString.withOptions({
|
|
242
|
-
clearOnDefault: true,
|
|
243
|
-
shallow: false,
|
|
244
|
-
limitUrlUpdates: {
|
|
245
|
-
method: "debounce",
|
|
246
|
-
timeMs: 400
|
|
247
|
-
},
|
|
248
|
-
...options
|
|
249
|
-
}).withDefault(defaultValue ?? ""));
|
|
250
|
-
return <InputText id={`${id}-${name}`} name={name} value={filter} {...props} onChange={(e) => {
|
|
251
|
-
setFilter(e.target.value);
|
|
252
|
-
props.onChange?.(e.target.value);
|
|
253
|
-
}} />;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
//#endregion
|
|
257
|
-
export { ContainerAnimation, InputText, QueryTextField };
|
|
258
|
-
//# sourceMappingURL=index.js.map
|
|
5
|
+
export { ContainerAnimation, InputText, QueryTextField };
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { cn } from "./utils-C0f9Ma6r.js";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { useId } from "react";
|
|
4
|
+
import { Controller, useFormContext, useFormState } from "react-hook-form";
|
|
5
|
+
import { withMask } from "use-mask-input";
|
|
6
|
+
import "@radix-ui/react-slot";
|
|
7
|
+
import * as LabelPrimitive from "@radix-ui/react-label";
|
|
8
|
+
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
|
9
|
+
import { Portal } from "@radix-ui/react-tooltip";
|
|
10
|
+
import { Info } from "lucide-react";
|
|
11
|
+
import { parseAsString, useQueryState } from "nuqs";
|
|
12
|
+
|
|
13
|
+
//#region src/components/ui/label.tsx
|
|
14
|
+
function Label({ className,...props }) {
|
|
15
|
+
return <LabelPrimitive.Root 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)} data-slot="label" {...props} />;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region src/components/ui/form.tsx
|
|
20
|
+
const FormFieldContext = React.createContext({});
|
|
21
|
+
const FormContext = React.createContext({});
|
|
22
|
+
const useFormContextSubmit = () => {
|
|
23
|
+
const context = React.useContext(FormContext);
|
|
24
|
+
if (!context) return {};
|
|
25
|
+
return context;
|
|
26
|
+
};
|
|
27
|
+
const FormField = ({ ...props }) => {
|
|
28
|
+
return <FormFieldContext.Provider value={{ name: props.name }}>
|
|
29
|
+
<Controller {...props} />
|
|
30
|
+
</FormFieldContext.Provider>;
|
|
31
|
+
};
|
|
32
|
+
const useFormField = () => {
|
|
33
|
+
const fieldContext = React.useContext(FormFieldContext);
|
|
34
|
+
const itemContext = React.useContext(FormItemContext);
|
|
35
|
+
const { getFieldState } = useFormContext();
|
|
36
|
+
const formState = useFormState({ name: fieldContext.name });
|
|
37
|
+
const fieldState = getFieldState(fieldContext.name, formState);
|
|
38
|
+
if (!fieldContext) throw new Error("useFormField should be used within <FormField>");
|
|
39
|
+
const { id } = itemContext;
|
|
40
|
+
return {
|
|
41
|
+
id,
|
|
42
|
+
name: fieldContext.name,
|
|
43
|
+
formItemId: `${id}-form-item`,
|
|
44
|
+
formDescriptionId: `${id}-form-item-description`,
|
|
45
|
+
formMessageId: `${id}-form-item-message`,
|
|
46
|
+
...fieldState
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
const FormItemContext = React.createContext({});
|
|
50
|
+
function FormItem({ className,...props }) {
|
|
51
|
+
const id = React.useId();
|
|
52
|
+
return <FormItemContext.Provider value={{ id }}>
|
|
53
|
+
<div className={cn("flex flex-col gap-1", className)} data-slot="form-item" {...props} />
|
|
54
|
+
</FormItemContext.Provider>;
|
|
55
|
+
}
|
|
56
|
+
function FormMessage({ className,...props }) {
|
|
57
|
+
const { error, formMessageId } = useFormField();
|
|
58
|
+
const body = error ? String(error?.message ?? "") : props.children;
|
|
59
|
+
if (!body) return null;
|
|
60
|
+
return <p className={cn("text-destructive text-xs", className)} data-slot="form-message" id={formMessageId} {...props}>
|
|
61
|
+
{body}
|
|
62
|
+
</p>;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
//#endregion
|
|
66
|
+
//#region src/components/ui/input.tsx
|
|
67
|
+
function Input({ className, type,...props }) {
|
|
68
|
+
return <input 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)} data-slot="input" type={type} {...props} />;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
//#endregion
|
|
72
|
+
//#region src/components/ui/tooltip.tsx
|
|
73
|
+
function TooltipProvider({ delayDuration = 0,...props }) {
|
|
74
|
+
return <TooltipPrimitive.Provider data-slot="tooltip-provider" delayDuration={delayDuration} {...props} />;
|
|
75
|
+
}
|
|
76
|
+
function Tooltip({ ...props }) {
|
|
77
|
+
return <TooltipProvider>
|
|
78
|
+
<TooltipPrimitive.Root data-slot="tooltip" {...props} />
|
|
79
|
+
</TooltipProvider>;
|
|
80
|
+
}
|
|
81
|
+
function TooltipTrigger({ ...props }) {
|
|
82
|
+
return <TooltipPrimitive.Trigger data-slot="tooltip-trigger" {...props} />;
|
|
83
|
+
}
|
|
84
|
+
function TooltipContent({ className, sideOffset = 0, children,...props }) {
|
|
85
|
+
return <TooltipPrimitive.Portal>
|
|
86
|
+
<TooltipPrimitive.Content 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)} data-slot="tooltip-content" sideOffset={sideOffset} {...props}>
|
|
87
|
+
{children}
|
|
88
|
+
<TooltipPrimitive.Arrow className="bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]" />
|
|
89
|
+
</TooltipPrimitive.Content>
|
|
90
|
+
</TooltipPrimitive.Portal>;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
//#endregion
|
|
94
|
+
//#region src/components/ui/content-help.tsx
|
|
95
|
+
const ContentHelp = ({ children, help, className, side = "top", sideOffset = 10 }) => {
|
|
96
|
+
return help ? <Tooltip delayDuration={250}>
|
|
97
|
+
<TooltipTrigger asChild>{children}</TooltipTrigger>
|
|
98
|
+
<Portal>
|
|
99
|
+
<TooltipContent className={cn("flex items-center px-2 leading-none", className)} side={side} sideOffset={10}>
|
|
100
|
+
<p className="w-full text-wrap whitespace-break-spaces">{help}</p>
|
|
101
|
+
</TooltipContent>
|
|
102
|
+
</Portal>
|
|
103
|
+
</Tooltip> : children;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
//#endregion
|
|
107
|
+
//#region src/components/ui/input-help.tsx
|
|
108
|
+
const InputHelp = ({ help, name, className }) => {
|
|
109
|
+
const { helper } = useFormContextSubmit();
|
|
110
|
+
const helpText = name && helper?.[name] || help;
|
|
111
|
+
return helpText && <ContentHelp className={cn("whitespace-pre-line leading-relaxed max-w-96 text-[13px]")} help={helpText}>
|
|
112
|
+
<button className={cn("mb-0.5 size-fit p-1 hover:bg-muted rounded-sm", className)} type="button">
|
|
113
|
+
<Info className="size-3.5" />
|
|
114
|
+
</button>
|
|
115
|
+
</ContentHelp>;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
//#endregion
|
|
119
|
+
//#region src/components/text-field/TextField.tsx
|
|
120
|
+
function InputText({ label, description, placeholder, className, children, disabled, type, required, maskRef, mask, maskOptions, error, id, ref, detail, detailClassName, inputClassName, help, name,...props }) {
|
|
121
|
+
return <div className={cn("w-full flex flex-col gap-1", className)} id={`input-${name?.replace(".", "-")}`} ref={ref}>
|
|
122
|
+
<div className="flex items-end gap-1.5">
|
|
123
|
+
<div className={cn("flex !gap-0 flex-col", className)}>
|
|
124
|
+
{label && <Label className={cn(error && "text-destructive", className, disabled && "text-muted-foreground", "inline-flex items-center flex-row gap-0.5")} htmlFor={id}>
|
|
125
|
+
{label}:
|
|
126
|
+
{required && <span className="text-red-500 text-lg leading-[1px]">*</span>}
|
|
127
|
+
</Label>}
|
|
128
|
+
{detail && <Label className={cn("text-sm text-muted-foreground font-normal", detailClassName)} htmlFor={id}>
|
|
129
|
+
{detail}
|
|
130
|
+
</Label>}
|
|
131
|
+
</div>
|
|
132
|
+
|
|
133
|
+
<InputHelp help={help} name={name} />
|
|
134
|
+
</div>
|
|
135
|
+
<div className="flex flex-col gap-0.5">
|
|
136
|
+
<div className="relative">
|
|
137
|
+
<Input className={cn(error && "border-destructive", inputClassName)} disabled={disabled} id={id} placeholder={placeholder} ref={maskRef || (mask ? withMask(mask, {
|
|
138
|
+
autoUnmask: true,
|
|
139
|
+
...maskOptions,
|
|
140
|
+
showMaskOnHover: false,
|
|
141
|
+
showMaskOnFocus: false,
|
|
142
|
+
clearMaskOnLostFocus: true
|
|
143
|
+
}) : void 0)} type={type} {...props} />
|
|
144
|
+
{children}
|
|
145
|
+
</div>
|
|
146
|
+
{description && <p className={cn("text-sm text-muted-foreground", className)}>
|
|
147
|
+
{description}
|
|
148
|
+
</p>}
|
|
149
|
+
{error && error}
|
|
150
|
+
</div>
|
|
151
|
+
</div>;
|
|
152
|
+
}
|
|
153
|
+
const defaultTransform = (value) => value;
|
|
154
|
+
function TextField({ name, className, required, defaultValue, onChange, transform = defaultTransform,...props }) {
|
|
155
|
+
const { control } = useFormContext();
|
|
156
|
+
const id = useId();
|
|
157
|
+
return <FormField control={control} defaultValue={defaultValue} name={name} render={({ field, fieldState }) => <FormItem className={cn("w-full", className)}>
|
|
158
|
+
<InputText {...field} {...props} disabled={props.disabled} error={fieldState?.error && <FormMessage />} id={`${id}-${name}`} name={name} onChange={(e) => {
|
|
159
|
+
field.onChange(transform(e.target.value));
|
|
160
|
+
onChange?.(transform(e.target.value));
|
|
161
|
+
}} required={required} value={field.value || ""} />
|
|
162
|
+
</FormItem>} rules={{ required: required ? "Campo obrigatório" : false }} />;
|
|
163
|
+
}
|
|
164
|
+
function QueryTextField({ name, defaultValue, options,...props }) {
|
|
165
|
+
const id = useId();
|
|
166
|
+
const [filter, setFilter] = useQueryState(name, parseAsString.withOptions({
|
|
167
|
+
clearOnDefault: true,
|
|
168
|
+
shallow: false,
|
|
169
|
+
limitUrlUpdates: {
|
|
170
|
+
method: "debounce",
|
|
171
|
+
timeMs: 400
|
|
172
|
+
},
|
|
173
|
+
...options
|
|
174
|
+
}).withDefault(defaultValue ?? ""));
|
|
175
|
+
return <InputText id={`${id}-${name}`} name={name} value={filter} {...props} onChange={(e) => {
|
|
176
|
+
setFilter(e.target.value);
|
|
177
|
+
props.onChange?.(e.target.value);
|
|
178
|
+
}} />;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
//#endregion
|
|
182
|
+
export { InputText, QueryTextField, TextField };
|
|
183
|
+
//# sourceMappingURL=text-field-0up45ViU.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-field-0up45ViU.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,M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;CAClC,MAAM,EAAE,YAAY,gBAAgB;CACpC,MAAM,KAAK,OAAO;AAElB,QACE,CAAC,UACC,SAAS,SACT,cAAc,cACd,MAAM,MACN,SAAS,EAAE,OAAO,iBAChB,CAAC,SAAS,WAAW,GAAG,UAAU,UAAU,EAAE;UAC5C,CAAC,cACK,WACA,OACJ,UAAU,MAAM,UAChB,OAAO,YAAY,SAAS,CAAC,gBAC7B,IAAI,GAAG,GAAG,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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils-C0f9Ma6r.js","names":[],"sources":["../src/lib/utils.ts"],"sourcesContent":["import { type ClassValue, clsx } from 'clsx';\nimport { twMerge } from 'tailwind-merge';\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n"],"mappings":";;;;AAGA,SAAgB,GAAG,GAAG,QAAsB;AAC1C,QAAO,QAAQ,KAAK,OAAO,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "maquinaweb-ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "A minimal React component library",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -12,7 +12,18 @@
|
|
|
12
12
|
"import": "./dist/index.js",
|
|
13
13
|
"types": "./dist/index.d.ts"
|
|
14
14
|
},
|
|
15
|
-
"./
|
|
15
|
+
"./text-field": {
|
|
16
|
+
"import": "./dist/text-field.js",
|
|
17
|
+
"types": "./dist/text-field.d.ts"
|
|
18
|
+
},
|
|
19
|
+
"./container-animation": {
|
|
20
|
+
"import": "./dist/container-animation.js",
|
|
21
|
+
"types": "./dist/container-animation.d.ts"
|
|
22
|
+
},
|
|
23
|
+
"./package.json": {
|
|
24
|
+
"import": "./package.json",
|
|
25
|
+
"types": "./package.json"
|
|
26
|
+
}
|
|
16
27
|
},
|
|
17
28
|
"files": [
|
|
18
29
|
"dist",
|
|
@@ -20,14 +31,22 @@
|
|
|
20
31
|
],
|
|
21
32
|
"scripts": {
|
|
22
33
|
"dev": "concurrently \"cosmos --expose-imports\" \"next dev\"",
|
|
23
|
-
"build": "tsdown",
|
|
34
|
+
"build": "tsdown && bun run postbuild",
|
|
35
|
+
"postbuild": "bun scripts/update-exports.ts",
|
|
24
36
|
"build:vercel": "cosmos-export --expose-imports && next build && cp -R ./out/_next ./cosmos-export && cp -R ./out/cosmos ./cosmos-export",
|
|
25
37
|
"prepublishOnly": "bun run build",
|
|
38
|
+
"prepare": "husky",
|
|
39
|
+
"clean-exports": "bun scripts/clean-exports.ts",
|
|
26
40
|
"type-check": "tsc --noEmit",
|
|
27
41
|
"lint": "biome lint .",
|
|
28
42
|
"format": "biome check . --write --no-errors-on-unmatched --files-ignore-unknown=true",
|
|
29
43
|
"lint:fix": "biome check --write ."
|
|
30
44
|
},
|
|
45
|
+
"lint-staged": {
|
|
46
|
+
"package.json": [
|
|
47
|
+
"bun run clean-exports"
|
|
48
|
+
]
|
|
49
|
+
},
|
|
31
50
|
"peerDependencies": {
|
|
32
51
|
"react": "^18.0.0 || ^19.0.0",
|
|
33
52
|
"react-dom": "^18.0.0 || ^19.0.0"
|
|
@@ -61,6 +80,9 @@
|
|
|
61
80
|
"@types/react": "^19.2.0",
|
|
62
81
|
"@types/react-dom": "^19.2.0",
|
|
63
82
|
"concurrently": "^9.0.0",
|
|
83
|
+
"glob": "^11.0.3",
|
|
84
|
+
"husky": "^9.1.7",
|
|
85
|
+
"lint-staged": "^16.2.3",
|
|
64
86
|
"lucide-react": "^0.544.0",
|
|
65
87
|
"motion": "^12.23.22",
|
|
66
88
|
"next": "^15.1.0",
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/components/container-animation/ContainerAnimation.tsx","../src/components/text-field/TextField.tsx"],"sourcesContent":[],"mappings":";;;;;;;KAiDY,kCAAkC,uBAC5C,wBACE,eAAe;;;;;;EAFP,aAAA,CAAA,EAAA,OAAA;EAAuB,EAAA,CAAA,EASxB,CATwB,GAAA,MAAA;WAAW,CAAA,EAAA,MAAA;;cAaxC,kBAXa,EAAA,CAAA,UAWmB,WAXnB,GAAA,KAAA,CAAA,CAAA;EAAA,SAAA;EAAA,QAAA;EAAA,QAAA;EAAA,KAAA;EAAA,KAAA;EAAA,QAAA;EAAA,EAAA,EAWwC,EAXxC;EAAA,QAAA;EAAA,aAAA;EAAA,GAAA;AAAA,CAAA,EAsBhB,uBAtBgB,CAsBQ,CAtBR,CAAA,EAAA,GAsBU,MAAA,CAAA,GAAA,CAAA,OAtBV;;;KC9Bd,IAAA;UAmBY,cAAA,SACP,KAAA,CAAM,oBAAoB;QAC5B,KAAA,CAAM,aAAa;;EDOf,WAAA,CAAA,EAAA,MAAA;EAAuB,WAAA,CAAA,EAAA,MAAA;WAAW,CAAA,EAAA,MAAA;UAC5C,CAAA,EAAA,OAAA;MACiB,CAAA,EAAA,MAAA;UAAf,CAAA,EAAA,OAAA;SAOO,CAAA,ECRC,KAAA,CAAM,YDQP,CAAA,GAAA,CAAA;EAAC,QAAA,CAAA,ECPC,KAAA,CAAM,SDOP;EAIN,IAAA,CAAA,ECVG,IDUH;EAkCL,WAAA,CAAA,EC3Ce,OD2Cf;OAlCqC,CAAA,ECR5B,KAAA,CAAM,SDQsB;KAAqB,EAAA,MAAA;QAAA,CAAA,EAAA,MAAA;iBAAA,CAAA,EAAA,MAAA;gBAAA,CAAA,EAAA,MAAA;MAAA,CAAA,EAAA,MAAA;;iBCAlD,SAAA,CDAkD;EAAA,KAAA;EAAA,WAAA;EAAA,WAAA;EAAA,SAAA;EAAA,QAAA;EAAA,QAAA;EAAA,IAAA;EAAA,QAAA;EAAA,OAAA;EAAA,IAAA;EAAA,WAAA;EAAA,KAAA;EAAA,EAAA;EAAA,GAAA;EAAA,MAAA;EAAA,eAAA;EAAA,cAAA;EAAA,IAAA;EAAA,IAAA;EAAA,GAAA;AAAA,CAAA,ECqBxD,cDrBwD,CAAA,ECqB1C,MAAA,CAAA,GAAA,CAAA,ODrB0C;ACzCtD,UAqMY,mBAAA,SAA4B,IArMpC,CAqMyC,cArMzC,EAAA,UAAA,CAAA,CAAA;EAmBQ,IAAA,EAAA,MAAA;EACf,YAAA,CAAA,EAAA,MAAA;SAAkC,CAAA,EAoLxB,SApLwB;UACT,CAAA,EAAA,CAAA,KAAA,EAAA,MAAA,EAAA,GAAA,IAAA;;iBAuLlB,cAAA,CA/KS;EAAA,IAAA;EAAA,YAAA;EAAA,OAAA;EAAA,GAAA;AAAA,CAAA,EAoLf,mBApLe,CAAA,EAoLI,MAAA,CAAA,GAAA,CAAA,OApLJ"}
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.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/lib/utils.ts","../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/ContainerAnimation.tsx","../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":["import { type ClassValue, clsx } from 'clsx';\nimport { twMerge } from 'tailwind-merge';\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n","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","'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"],"x_google_ignoreList":[1,2,3],"mappings":";;;;;;;;;;;;;;;AAGA,SAAgB,GAAG,GAAG,QAAsB;AAC1C,QAAO,QAAQ,KAAK,OAAO,CAAC;;;;;ACJ9B,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;IACtB,MAAM,WAAW,QAAQ,MAAM,QAAQ,MAAM;AAC7C,QAAI,OAAO,aAAa,WACpB,qBAAoB,IAAI,MAAM,QAAQ,SAAS;QAG/C,UAAS,UAAU,MAAM,OAAO;cAG/B,OAAO,UAAU,YAAY;AAClC,UAAM,MAAM;AACZ,wBAAoB,OAAO,MAAM,OAAO;;IAE9C;;CAEN,MAAM,WAAW,IAAI,qBAAqB,sBAAsB;EAC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