maquinaweb-ui 2.29.3 → 2.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/container-animation.d.ts +2 -2
- package/dist/input-Cp3f1KmR.js +133 -0
- package/dist/input-Cp3f1KmR.js.map +1 -0
- package/dist/{input-help-C9Himejv.js → input-help-Bxsf3Cg-.js} +1 -1
- package/dist/{input-help-C9Himejv.js.map → input-help-Bxsf3Cg-.js.map} +1 -1
- package/dist/input-suggest.d.ts +3 -3
- package/dist/input-suggest.d.ts.map +1 -1
- package/dist/input-suggest.js +2 -3
- package/dist/input-suggest.js.map +1 -1
- package/dist/page-header.d.ts +2 -2
- package/dist/page-header.js +1 -1
- package/dist/remote-selector.d.ts +3 -3
- package/dist/remote-selector.js +1 -1
- package/dist/text-field.d.ts +11 -11
- package/dist/text-field.d.ts.map +1 -1
- package/dist/text-field.js +26 -27
- package/dist/text-field.js.map +1 -1
- package/dist/with-mask-DnMiJlek.d.ts +9 -0
- package/dist/with-mask-DnMiJlek.d.ts.map +1 -0
- package/package.json +5 -7
- package/dist/input-COsbbKgj.js +0 -16
- package/dist/input-COsbbKgj.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ComponentProps, ElementType } from "react";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime5 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_runtime5.JSX.Element;
|
|
27
27
|
//#endregion
|
|
28
28
|
export { ContainerAnimation, type ContainerAnimationProps };
|
|
29
29
|
//# sourceMappingURL=container-animation.d.ts.map
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { cn } from "./utils-C0f9Ma6r.js";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import inputmask from "inputmask";
|
|
4
|
+
|
|
5
|
+
//#region src/hooks/get-mask-options.ts
|
|
6
|
+
function getMaskOptions(mask, _options) {
|
|
7
|
+
const options = {
|
|
8
|
+
jitMasking: false,
|
|
9
|
+
..._options
|
|
10
|
+
};
|
|
11
|
+
if (!mask) return options;
|
|
12
|
+
const masks = {
|
|
13
|
+
datetime: {
|
|
14
|
+
alias: "datetime",
|
|
15
|
+
...options
|
|
16
|
+
},
|
|
17
|
+
email: {
|
|
18
|
+
alias: "email",
|
|
19
|
+
placeholder: "",
|
|
20
|
+
...options
|
|
21
|
+
},
|
|
22
|
+
numeric: {
|
|
23
|
+
alias: "numeric",
|
|
24
|
+
placeholder: "",
|
|
25
|
+
...options
|
|
26
|
+
},
|
|
27
|
+
currency: {
|
|
28
|
+
alias: "currency",
|
|
29
|
+
prefix: "$ ",
|
|
30
|
+
placeholder: "",
|
|
31
|
+
...options
|
|
32
|
+
},
|
|
33
|
+
decimal: {
|
|
34
|
+
alias: "decimal",
|
|
35
|
+
placeholder: "",
|
|
36
|
+
...options
|
|
37
|
+
},
|
|
38
|
+
integer: {
|
|
39
|
+
alias: "integer",
|
|
40
|
+
placeholder: "",
|
|
41
|
+
...options
|
|
42
|
+
},
|
|
43
|
+
percentage: {
|
|
44
|
+
alias: "percentage",
|
|
45
|
+
placeholder: " %",
|
|
46
|
+
suffix: " %",
|
|
47
|
+
...options
|
|
48
|
+
},
|
|
49
|
+
url: {
|
|
50
|
+
alias: "url",
|
|
51
|
+
placeholder: "https://",
|
|
52
|
+
...options
|
|
53
|
+
},
|
|
54
|
+
ip: {
|
|
55
|
+
alias: "ip",
|
|
56
|
+
...options
|
|
57
|
+
},
|
|
58
|
+
mac: {
|
|
59
|
+
alias: "mac",
|
|
60
|
+
...options
|
|
61
|
+
},
|
|
62
|
+
ssn: {
|
|
63
|
+
alias: "ssn",
|
|
64
|
+
...options
|
|
65
|
+
},
|
|
66
|
+
"brl-currency": {
|
|
67
|
+
alias: "currency",
|
|
68
|
+
prefix: "R$ ",
|
|
69
|
+
placeholder: "0,00",
|
|
70
|
+
displayFormat: "currency",
|
|
71
|
+
radixPoint: ",",
|
|
72
|
+
autoUnmask: true,
|
|
73
|
+
...options
|
|
74
|
+
},
|
|
75
|
+
cpf: {
|
|
76
|
+
mask: "999.999.999-99",
|
|
77
|
+
placeholder: "___.___.___-__",
|
|
78
|
+
...options
|
|
79
|
+
},
|
|
80
|
+
cnpj: {
|
|
81
|
+
mask: "99.999.999/9999-99",
|
|
82
|
+
placeholder: "__.___.___/____-__",
|
|
83
|
+
...options
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
if (typeof mask === "string" && masks[mask]) return masks[mask];
|
|
87
|
+
return {
|
|
88
|
+
mask,
|
|
89
|
+
...options
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
//#endregion
|
|
94
|
+
//#region src/hooks/is-server.ts
|
|
95
|
+
const isServer = !(typeof window !== "undefined" && window.document?.createElement);
|
|
96
|
+
var is_server_default = isServer;
|
|
97
|
+
|
|
98
|
+
//#endregion
|
|
99
|
+
//#region src/hooks/module-interop.ts
|
|
100
|
+
/**
|
|
101
|
+
* Synchronously resolve the default value of a module.
|
|
102
|
+
*/
|
|
103
|
+
function interopDefaultSync(module) {
|
|
104
|
+
if (typeof module === "object" && module !== null) {
|
|
105
|
+
if ("default" in module) return module.default;
|
|
106
|
+
return module;
|
|
107
|
+
}
|
|
108
|
+
return module;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
//#endregion
|
|
112
|
+
//#region src/hooks/with-mask.ts
|
|
113
|
+
function withMask(mask, options) {
|
|
114
|
+
return (input) => {
|
|
115
|
+
if (is_server_default || mask === null || !input) return;
|
|
116
|
+
interopDefaultSync(inputmask)(getMaskOptions(mask, options)).mask(input);
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
//#endregion
|
|
121
|
+
//#region src/components/ui/input.tsx
|
|
122
|
+
function Input({ className, type,...props }) {
|
|
123
|
+
return /* @__PURE__ */ jsx("input", {
|
|
124
|
+
className: cn("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input flex h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm", "focus-visible:border-ring focus-visible:ring-ring/75 focus-visible:ring-[2px]", "aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive ring-offset-[2px] transition-all duration-300", className),
|
|
125
|
+
"data-slot": "input",
|
|
126
|
+
type,
|
|
127
|
+
...props
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
//#endregion
|
|
132
|
+
export { Input, withMask };
|
|
133
|
+
//# sourceMappingURL=input-Cp3f1KmR.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input-Cp3f1KmR.js","names":["options: Options","masks: Record<string, Inputmask.Options>","isServer"],"sources":["../src/hooks/get-mask-options.ts","../src/hooks/is-server.ts","../src/hooks/module-interop.ts","../src/hooks/with-mask.ts","../src/components/ui/input.tsx"],"sourcesContent":["import type { Mask, Options } from './with-mask';\n\nexport default function getMaskOptions(\n mask?: Mask,\n _options?: Options\n): Options {\n const options: Options = {\n jitMasking: false,\n ..._options,\n };\n if (!mask) return options;\n\n const masks: Record<string, Inputmask.Options> = {\n datetime: {\n alias: 'datetime',\n ...options,\n },\n email: {\n alias: 'email',\n placeholder: '',\n ...options,\n },\n numeric: {\n alias: 'numeric',\n placeholder: '',\n ...options,\n },\n currency: {\n alias: 'currency',\n prefix: '$ ',\n placeholder: '',\n ...options,\n },\n decimal: {\n alias: 'decimal',\n placeholder: '',\n ...options,\n },\n integer: {\n alias: 'integer',\n placeholder: '',\n ...options,\n },\n percentage: {\n alias: 'percentage',\n placeholder: ' %',\n suffix: ' %',\n ...options,\n },\n url: {\n alias: 'url',\n placeholder: 'https://',\n ...options,\n },\n ip: {\n alias: 'ip',\n ...options,\n },\n mac: {\n alias: 'mac',\n ...options,\n },\n ssn: {\n alias: 'ssn',\n ...options,\n },\n\n // alias for brazilians <3\n // ty <3\n 'brl-currency': {\n alias: 'currency',\n prefix: 'R$ ',\n placeholder: '0,00',\n displayFormat: 'currency',\n radixPoint: ',',\n autoUnmask: true,\n ...options,\n },\n cpf: {\n mask: '999.999.999-99',\n placeholder: '___.___.___-__',\n ...options,\n },\n cnpj: {\n mask: '99.999.999/9999-99',\n placeholder: '__.___.___/____-__',\n ...options,\n },\n };\n\n if (typeof mask === 'string' && masks[mask]) return masks[mask];\n\n return {\n mask,\n ...options,\n };\n}\n","const isServer = !(\n typeof window !== 'undefined' && window.document?.createElement\n);\n\nexport default isServer;\n","/* eslint-disable @typescript-eslint/no-explicit-any */\n/**\n * Synchronously resolve the default value of a module.\n */\nexport default function interopDefaultSync<T = any>(module: T): T {\n if (typeof module === 'object' && module !== null) {\n if ('default' in module) {\n return module.default as T;\n }\n return module;\n }\n return module;\n}\n","import inputmask from 'inputmask';\nimport Inputmask from 'inputmask';\nimport getMaskOptions from './get-mask-options';\nimport isServer from './is-server';\nimport interopDefaultSync from './module-interop';\n\nexport type { UseFormRegister, UseFormRegisterReturn } from 'react-hook-form';\n\nexport type Mask =\n | 'datetime'\n | 'email'\n | 'numeric'\n | 'currency'\n | 'decimal'\n | 'integer'\n | 'percentage'\n | 'url'\n | 'ip'\n | 'mac'\n | 'ssn'\n | 'brl-currency'\n | 'cpf'\n | 'cnpj'\n | (string & {})\n | (string[] & {})\n | null;\nexport type Options = Inputmask.Options;\nexport type Input = HTMLInputElement | HTMLTextAreaElement | HTMLElement;\n\nexport default function withMask(mask: Mask, options?: Options) {\n return (input: Input | null): void => {\n if (isServer || mask === null || !input) return;\n\n const maskInput = interopDefaultSync(inputmask)(\n getMaskOptions(mask, options)\n );\n\n maskInput.mask(input);\n };\n}\n","import type * as React from 'react';\n\nimport { cn } from '@/lib/utils';\n\nfunction Input({ className, type, ...props }: React.ComponentProps<'input'>) {\n return (\n <input\n className={cn(\n 'file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input flex h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm',\n 'focus-visible:border-ring focus-visible:ring-ring/75 focus-visible:ring-[2px]',\n 'aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive ring-offset-[2px] transition-all duration-300',\n className\n )}\n data-slot=\"input\"\n type={type}\n {...props}\n />\n );\n}\n\nexport { Input };\n"],"mappings":";;;;;AAEA,SAAwB,eACtB,MACA,UACS;CACT,MAAMA,UAAmB;EACvB,YAAY;EACZ,GAAG;EACJ;AACD,KAAI,CAAC,KAAM,QAAO;CAElB,MAAMC,QAA2C;EAC/C,UAAU;GACR,OAAO;GACP,GAAG;GACJ;EACD,OAAO;GACL,OAAO;GACP,aAAa;GACb,GAAG;GACJ;EACD,SAAS;GACP,OAAO;GACP,aAAa;GACb,GAAG;GACJ;EACD,UAAU;GACR,OAAO;GACP,QAAQ;GACR,aAAa;GACb,GAAG;GACJ;EACD,SAAS;GACP,OAAO;GACP,aAAa;GACb,GAAG;GACJ;EACD,SAAS;GACP,OAAO;GACP,aAAa;GACb,GAAG;GACJ;EACD,YAAY;GACV,OAAO;GACP,aAAa;GACb,QAAQ;GACR,GAAG;GACJ;EACD,KAAK;GACH,OAAO;GACP,aAAa;GACb,GAAG;GACJ;EACD,IAAI;GACF,OAAO;GACP,GAAG;GACJ;EACD,KAAK;GACH,OAAO;GACP,GAAG;GACJ;EACD,KAAK;GACH,OAAO;GACP,GAAG;GACJ;EAID,gBAAgB;GACd,OAAO;GACP,QAAQ;GACR,aAAa;GACb,eAAe;GACf,YAAY;GACZ,YAAY;GACZ,GAAG;GACJ;EACD,KAAK;GACH,MAAM;GACN,aAAa;GACb,GAAG;GACJ;EACD,MAAM;GACJ,MAAM;GACN,aAAa;GACb,GAAG;GACJ;EACF;AAED,KAAI,OAAO,SAAS,YAAY,MAAM,MAAO,QAAO,MAAM;AAE1D,QAAO;EACL;EACA,GAAG;EACJ;;;;;AC/FH,MAAM,WAAW,EACf,OAAO,WAAW,eAAe,OAAO,UAAU;AAGpD,wBAAe;;;;;;;ACAf,SAAwB,mBAA4B,QAAc;AAChE,KAAI,OAAO,WAAW,YAAY,WAAW,MAAM;AACjD,MAAI,aAAa,OACf,QAAO,OAAO;AAEhB,SAAO;;AAET,QAAO;;;;;ACkBT,SAAwB,SAAS,MAAY,SAAmB;AAC9D,SAAQ,UAA8B;AACpC,MAAIC,qBAAY,SAAS,QAAQ,CAAC,MAAO;AAMzC,EAJkB,mBAAmB,UAAU,CAC7C,eAAe,MAAM,QAAQ,CAC9B,CAES,KAAK,MAAM;;;;;;ACjCzB,SAAS,MAAM,EAAE,WAAW,KAAM,GAAG,SAAwC;AAC3E,QACE,oBAAC;EACC,WAAW,GACT,mcACA,iFACA,wJACA,UACD;EACD,aAAU;EACJ;EACN,GAAI;GACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input-help-C9Himejv.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/form.tsx","../src/components/ui/tooltip.tsx","../src/components/ui/content-help.tsx","../src/components/ui/input-help.tsx"],"sourcesContent":["'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","'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"],"mappings":";;;;;;;;;;;AA2BA,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;;AA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EAChB,aAAU;EACK;EACf,GAAI;GACJ;;AAIN,SAAS,QAAQ,EACf,GAAG,SACkD;AACrD,QACE,oBAAC,6BACC,oBAAC,iBAAiB;EAAK,aAAU;EAAU,GAAI;GAAS,GACxC;;AAItB,SAAS,eAAe,EACtB,GAAG,SACqD;AACxD,QAAO,oBAAC,iBAAiB;EAAQ,aAAU;EAAkB,GAAI;GAAS;;AAG5E,SAAS,eAAe,EACtB,WACA,aAAa,GACb,SACA,GAAG,SACqD;AACxD,QACE,oBAAC,iBAAiB,oBAChB,qBAAC,iBAAiB;EAChB,WAAW,GACT,qaACA,UACD;EACD,aAAU;EACE;EACZ,GAAI;aAEH,UACD,oBAAC,iBAAiB,SAAM,WAAU,uGAAuG;GAChH,GACH;;;;;ACpD9B,MAAMA,eAMA,EAAE,UAAU,MAAM,WAAW,OAAO,OAAO,aAAa,SAAS;AACrE,QAAO,OACL,qBAAC;EAAQ,eAAe;aACtB,oBAAC;GAAe;GAAS;IAAiC,EAC1D,oBAACC,oBACC,oBAAC;GACC,WAAW,GAAG,uCAAuC,UAAU;GACzD;GACN,YAAY;aAEZ,oBAAC;IAAE,WAAU;cAA4C;KAAS;IACnD,GACH;GACR,GAEV;;;;;ACjBJ,MAAMC,aAIA,EAAE,MAAM,MAAM,gBAAgB;CAClC,MAAM,EAAE,WAAW,sBAAsB;CACzC,MAAM,WAAY,QAAQ,SAAS,SAAU;AAE7C,QACE,YACE,oBAAC;EACC,WAAW,GACT,2DACD;EACD,MAAM;YAEN,oBAAC;GACC,WAAW,GACT,iDACA,UACD;GACD,MAAK;aAEL,oBAAC,QAAK,WAAU,aAAa;IACtB;GACG"}
|
|
1
|
+
{"version":3,"file":"input-help-Bxsf3Cg-.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/form.tsx","../src/components/ui/tooltip.tsx","../src/components/ui/content-help.tsx","../src/components/ui/input-help.tsx"],"sourcesContent":["'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","'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"],"mappings":";;;;;;;;;;;AA2BA,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,qBA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K;EACf,GAAI;GACJ;;AAIN,SAAS,QAAQ,EACf,GAAG,SACkD;AACrD,QACE,oBAAC,6BACC,oBAAC,iBAAiB;EAAK,aAAU;EAAU,GAAI;GAAS,GACxC;;AAItB,SAAS,eAAe,EACtB,GAAG,SACqD;AACxD,QAAO,oBAAC,iBAAiB;EAAQ,aAAU;EAAkB,GAAI;GAAS;;AAG5E,SAAS,eAAe,EACtB,WACA,aAAa,GACb,SACA,GAAG,SACqD;AACxD,QACE,oBAAC,iBAAiB,oBAChB,qBAAC,iBAAiB;EAChB,WAAW,GACT,qaACA,UACD;EACD,aAAU;EACE;EACZ,GAAI;aAEH,UACD,oBAAC,iBAAiB,SAAM,WAAU,uGAAuG;GAChH,GACH;;;;;ACpD9B,MAAMA,eAMA,EAAE,UAAU,MAAM,WAAW,OAAO,OAAO,aAAa,SAAS;AACrE,QAAO,OACL,qBAAC;EAAQ,eAAe;aACtB,oBAAC;GAAe;GAAS;IAAiC,EAC1D,oBAACC,oBACC,oBAAC;GACC,WAAW,GAAG,uCAAuC,UAAU;GACzD;GACN,YAAY;aAEZ,oBAAC;IAAE,WAAU;cAA4C;KAAS;IACnD,GACH;GACR,GAEV;;;;;ACjBJ,MAAMC,aAIA,EAAE,MAAM,MAAM,gBAAgB;CAClC,MAAM,EAAE,WAAW,sBAAsB;CACzC,MAAM,WAAY,QAAQ,SAAS,SAAU;AAE7C,QACE,YACE,oBAAC;EACC,WAAW,GACT,2DACD;EACD,MAAM;YAEN,oBAAC;GACC,WAAW,GACT,iDACA,UACD;GACD,MAAK;aAEL,oBAAC,QAAK,WAAU,aAAa;IACtB;GACG"}
|
package/dist/input-suggest.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { Mask, Options } from "./with-mask-DnMiJlek.js";
|
|
1
2
|
import { FieldPath, FieldValues, UseControllerProps } from "react-hook-form";
|
|
2
3
|
import { Dispatch, SetStateAction } from "react";
|
|
3
|
-
import * as
|
|
4
|
-
import { Mask, Options } from "use-mask-input";
|
|
4
|
+
import * as react_jsx_runtime7 from "react/jsx-runtime";
|
|
5
5
|
import { PopoverProps } from "@radix-ui/react-popover";
|
|
6
6
|
|
|
7
7
|
//#region src/components/input-suggest/input-suggest.d.ts
|
|
@@ -65,7 +65,7 @@ declare function InputSuggest<TFieldValues extends FieldValues = FieldValues, TF
|
|
|
65
65
|
children,
|
|
66
66
|
initialParams,
|
|
67
67
|
...props
|
|
68
|
-
}: InputSuggestProps<TFieldValues, TFieldName> & PopoverProps):
|
|
68
|
+
}: InputSuggestProps<TFieldValues, TFieldName> & PopoverProps): react_jsx_runtime7.JSX.Element;
|
|
69
69
|
//#endregion
|
|
70
70
|
export { InputSuggest, type InputSuggestProps };
|
|
71
71
|
//# sourceMappingURL=input-suggest.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input-suggest.d.ts","names":[],"sources":["../src/components/input-suggest/input-suggest.tsx"],"sourcesContent":[],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"input-suggest.d.ts","names":[],"sources":["../src/components/input-suggest/input-suggest.tsx"],"sourcesContent":[],"mappings":";;;;;;;UAkCiB,uCACM,cAAc,gCAChB,UAAU,gBAAgB,UAAU,uBAC/C,mBAAmB,cAAc;;;EAH1B,QAAA,CAAA,EAAA,CAAA,MAAA,EAAiB,MAAA,EAAA,GAAA,IAAA;EAAA,QAAA,CAAA,EAOrB,QAPqB,CAOZ,cAPY,CAAA,MAAA,CAAA,CAAA;OACX,CAAA,EAAA,MAAA;aAAc,CAAA,EAAA,MAAA;WACN,CAAA,EAAA,MAAA;SAAV,EAAA,CAAA,MAAA,CAAA,EAAA,MAAA,EAAA,aAAA,CAAA,EAWD,MAXC,EAAA,GAAA;IAAoC,IAAA,CAAA,EAAA;MAAV,EAAA,EAAA,MAAA,GAAA,MAAA;MAClB,CAAA,GAAA,EAAA,MAAA,CAAA,EAAA,GAAA;IAAc,CAAA,EAAA;IAIrB,OAAA,CAAA,EAAA,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
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { Input, withMask } from "./input-Cp3f1KmR.js";
|
|
7
|
+
import { FormItem, FormLabel, FormMessage, InputHelp } from "./input-help-Bxsf3Cg-.js";
|
|
8
8
|
import { Popover, PopoverContent, PopoverTrigger, ScrollBar } from "./scroll-area-C2WadzN5.js";
|
|
9
9
|
import { useController, useFormContext } from "react-hook-form";
|
|
10
10
|
import { useCallback, useEffect, useState } from "react";
|
|
11
11
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
12
|
import { Check } from "lucide-react";
|
|
13
|
-
import { withMask } from "use-mask-input";
|
|
14
13
|
import { ScrollArea, ScrollAreaViewport } from "@radix-ui/react-scroll-area";
|
|
15
14
|
|
|
16
15
|
//#region src/components/input-suggest/input-suggest.tsx
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input-suggest.js","names":["item"],"sources":["../src/components/input-suggest/input-suggest.tsx"],"sourcesContent":["'use client';\n\nimport {\n Dispatch,\n SetStateAction,\n useCallback,\n useEffect,\n useState,\n} from 'react';\n\nimport {\n FieldPath,\n FieldValues,\n UseControllerProps,\n useController,\n useFormContext,\n} from 'react-hook-form';\nimport { Mask, type Options as MaskOptions, withMask } from 'use-mask-input';\n\nimport type { PopoverProps } from '@radix-ui/react-popover';\nimport { ScrollArea, ScrollAreaViewport } from '@radix-ui/react-scroll-area';\nimport { Input } from '@/components/ui/input';\nimport { FormItem, FormLabel, FormMessage } from '@/ui/form';\nimport { InputHelp } from '@/ui/input-help';\nimport { Popover, PopoverContent, PopoverTrigger } from '@/ui/popover';\nimport { ScrollBar } from '../ui/scroll-area';\n\nimport { Check } from 'lucide-react';\n\nimport { cn } from '@/lib/utils';\n\nexport interface InputSuggestProps<\n TFieldValues extends FieldValues = FieldValues,\n TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n> extends UseControllerProps<TFieldValues, TFieldName> {\n label: string;\n search?: string;\n onSearch?: (search: string) => void;\n setValue?: Dispatch<SetStateAction<string>>;\n value?: string;\n placeholder?: string;\n className?: string;\n useData: (\n search?: string,\n initialParams?: Object\n ) => {\n data?: {\n id: string | number;\n [key: string]: any;\n }[];\n refresh?: any;\n };\n required?: boolean;\n extra?: string;\n updateSearchOnBlur?: boolean;\n extraOnClick?: () => void;\n withPortal?: boolean;\n counter?: number;\n help?: string;\n nameSearch: string;\n prefix?: string;\n refineValue?: (value: any) => any;\n refineSuggest?: (suggest: any) => any;\n limit?: number;\n fieldValue?: string;\n mask?: Mask;\n maskOptions?: MaskOptions;\n initialParams?: Object;\n}\n\nfunction InputSuggest<\n TFieldValues extends FieldValues = FieldValues,\n TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n>({\n name,\n nameSearch,\n onSearch,\n fieldValue = 'name',\n label,\n className,\n placeholder,\n useData,\n setValue,\n required,\n disabled,\n updateSearchOnBlur = true,\n value,\n extra,\n extraOnClick,\n withPortal = false,\n counter,\n help,\n prefix,\n refineValue,\n refineSuggest,\n limit = 10,\n mask,\n maskOptions,\n children,\n initialParams,\n ...props\n}: InputSuggestProps<TFieldValues, TFieldName> & PopoverProps) {\n const form = useFormContext();\n const inputName = prefix ? `${prefix}.${name}` : name;\n const searchName = prefix ? `${prefix}.${nameSearch}` : nameSearch;\n\n const { field: searchField } = useController({\n name: searchName,\n control: form.control,\n });\n const { field, fieldState } = useController({\n name: inputName,\n control: form.control,\n });\n\n const [ariaSelected, setAriaSelected] = useState(-1);\n\n const [open, setOpen] = useState(false);\n\n const { data } = useData?.(searchField.value, initialParams);\n\n const onChange = useCallback(\n (item: any) => {\n const searchValue = item?.[fieldValue as keyof typeof item];\n searchField.onChange(searchValue);\n onSearch?.(searchValue);\n field.onChange(refineValue?.(item) || item);\n setOpen(false);\n },\n [field.value, refineValue, fieldValue]\n );\n\n const handleChange = useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n if (e.target.value === '') {\n field.onChange(null);\n }\n searchField.onChange(e.target.value);\n onSearch?.(e.target.value);\n setOpen(true);\n const item = data?.find((item) => item[fieldValue] === e.target.value);\n if (item) {\n onChange(item);\n setOpen(false);\n }\n },\n [field, searchField]\n );\n\n const handleKeyDown = useCallback(\n (e: React.KeyboardEvent<HTMLInputElement>) => {\n if (e.key === 'ArrowDown') {\n setAriaSelected((prev) => prev + 1);\n }\n if (e.key === 'ArrowUp') {\n setAriaSelected((prev) => prev - 1);\n }\n if (e.key === 'Enter' && data && data[ariaSelected]) {\n onChange(data[ariaSelected]);\n e.stopPropagation();\n e.preventDefault();\n }\n },\n []\n );\n\n useEffect(() => {\n const searchValue = field?.value?.[fieldValue as keyof typeof field.value];\n if (searchValue !== searchField.value && updateSearchOnBlur) {\n searchField.onChange(searchValue);\n onSearch?.(searchValue);\n }\n }, [field.value]);\n\n return (\n <FormItem\n className={cn('w-full flex flex-col', className)}\n id={`input-suggest-${inputName}`}\n >\n <div className=\"flex items-end gap-1.5\">\n <FormLabel htmlFor={inputName}>\n {label}:\n {required && (\n <span className=\"text-red-500 text-lg leading-[1px]\">*</span>\n )}\n </FormLabel>\n\n <InputHelp help={help} name={inputName} />\n </div>\n <Popover onOpenChange={setOpen} open={open} {...props}>\n <PopoverTrigger className=\"outline-hidden w-full relative\">\n <Input\n autoComplete=\"off\"\n className={cn(fieldState.error && 'border-destructive')}\n disabled={disabled}\n name={name}\n onChange={handleChange}\n onKeyDown={handleKeyDown}\n placeholder={placeholder}\n ref={\n mask\n ? withMask(mask, { autoUnmask: true, ...maskOptions })\n : (undefined as any)\n }\n value={searchField.value}\n />\n {children}\n </PopoverTrigger>\n {fieldState.error && <FormMessage />}\n <PopoverContent\n className={cn(\n 'mt-1 w-(--radix-popover-trigger-width) max-w-2xl p-0 z-50',\n data?.length === 0 && 'hidden'\n )}\n onOpenAutoFocus={(e) => e.preventDefault()}\n >\n <ScrollArea className=\"h-fit max-h-[300px]\" id=\"scroll\">\n <ScrollAreaViewport className=\"w-full h-fit max-h-[300px]\">\n <ul className=\"p-1\">\n {data?.slice(0, limit)?.map((item) => (\n <li\n aria-selected={data[ariaSelected]?.id === item.id}\n className={cn(\n 'relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-hidden aria-selected:bg-accent/50 aria-selected:text-accent-foreground data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 transition-all hover:bg-accent/50 hover:text-accent-foreground',\n field?.value?.id === item.id &&\n 'bg-accent! text-accent-foreground'\n )}\n key={item.id}\n onMouseDown={(e) => {\n onChange(item);\n e.preventDefault();\n }}\n >\n <span className=\"line-clamp-1 flex-1\">\n {refineSuggest\n ? refineSuggest(item)\n : item?.[fieldValue as keyof typeof item]}\n </span>\n {field?.value?.id == item.id && (\n <Check className=\"ml-auto h-4 w-4 shrink-0\" />\n )}\n </li>\n ))}\n\n {extra && (\n <li\n className={cn(\n 'flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-hidden aria-selected:bg-accent/50 aria-selected:text-accent-foreground data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 transition-all hover:text-accent-foreground sticky bottom-0.5 bg-white hover:bg-accent'\n )}\n onMouseDown={(e) => {\n e.preventDefault();\n extraOnClick?.();\n }}\n >\n <span className=\"line-clamp-1\">{extra}</span>\n </li>\n )}\n\n {(data?.length === 0 || !data) && !extra && (\n <p className=\"text-sm text-center text-accent-foreground/50 py-2\">\n Nenhum resultado encontrado.\n </p>\n )}\n </ul>\n </ScrollAreaViewport>\n <ScrollBar />\n </ScrollArea>\n </PopoverContent>\n </Popover>\n </FormItem>\n );\n}\n\nexport { InputSuggest };\n"],"mappings":";;;;;;;;;;;;;;;;AAsEA,SAAS,aAGP,EACA,MACA,YACA,UACA,aAAa,QACb,OACA,WACA,aACA,SACA,UACA,UACA,UACA,qBAAqB,MACrB,OACA,OACA,cACA,aAAa,OACb,SACA,MACA,QACA,aACA,eACA,QAAQ,IACR,MACA,aACA,UACA,cACA,GAAG,SAC0D;CAC7D,MAAM,OAAO,gBAAgB;CAC7B,MAA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C,WAAW,GACT,6TACD;UACD,cAAc,MAAM;AAClB,aAAE,gBAAgB;AAClB,2BAAgB;;oBAGlB,oBAAC;WAAK,WAAU;qBAAgB;YAAa;WAC1C;UAGL,MAAM,WAAW,KAAK,CAAC,SAAS,CAAC,SACjC,oBAAC;UAAE,WAAU;oBAAqD;WAE9D;;SAEH;QACc,EACrB,oBAAC,cAAY;OACF;MACE;;IACT;GACD"}
|
|
1
|
+
{"version":3,"file":"input-suggest.js","names":["item"],"sources":["../src/components/input-suggest/input-suggest.tsx"],"sourcesContent":["'use client';\n\nimport {\n Dispatch,\n SetStateAction,\n useCallback,\n useEffect,\n useState,\n} from 'react';\n\nimport {\n FieldPath,\n FieldValues,\n UseControllerProps,\n useController,\n useFormContext,\n} from 'react-hook-form';\nimport withMask, {\n type Mask,\n type Options as MaskOptions,\n} from '@/hooks/with-mask';\n\nimport type { PopoverProps } from '@radix-ui/react-popover';\nimport { ScrollArea, ScrollAreaViewport } from '@radix-ui/react-scroll-area';\nimport { Input } from '@/components/ui/input';\nimport { FormItem, FormLabel, FormMessage } from '@/ui/form';\nimport { InputHelp } from '@/ui/input-help';\nimport { Popover, PopoverContent, PopoverTrigger } from '@/ui/popover';\nimport { ScrollBar } from '../ui/scroll-area';\n\nimport { Check } from 'lucide-react';\n\nimport { cn } from '@/lib/utils';\n\nexport interface InputSuggestProps<\n TFieldValues extends FieldValues = FieldValues,\n TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n> extends UseControllerProps<TFieldValues, TFieldName> {\n label: string;\n search?: string;\n onSearch?: (search: string) => void;\n setValue?: Dispatch<SetStateAction<string>>;\n value?: string;\n placeholder?: string;\n className?: string;\n useData: (\n search?: string,\n initialParams?: Object\n ) => {\n data?: {\n id: string | number;\n [key: string]: any;\n }[];\n refresh?: any;\n };\n required?: boolean;\n extra?: string;\n updateSearchOnBlur?: boolean;\n extraOnClick?: () => void;\n withPortal?: boolean;\n counter?: number;\n help?: string;\n nameSearch: string;\n prefix?: string;\n refineValue?: (value: any) => any;\n refineSuggest?: (suggest: any) => any;\n limit?: number;\n fieldValue?: string;\n mask?: Mask;\n maskOptions?: MaskOptions;\n initialParams?: Object;\n}\n\nfunction InputSuggest<\n TFieldValues extends FieldValues = FieldValues,\n TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n>({\n name,\n nameSearch,\n onSearch,\n fieldValue = 'name',\n label,\n className,\n placeholder,\n useData,\n setValue,\n required,\n disabled,\n updateSearchOnBlur = true,\n value,\n extra,\n extraOnClick,\n withPortal = false,\n counter,\n help,\n prefix,\n refineValue,\n refineSuggest,\n limit = 10,\n mask,\n maskOptions,\n children,\n initialParams,\n ...props\n}: InputSuggestProps<TFieldValues, TFieldName> & PopoverProps) {\n const form = useFormContext();\n const inputName = prefix ? `${prefix}.${name}` : name;\n const searchName = prefix ? `${prefix}.${nameSearch}` : nameSearch;\n\n const { field: searchField } = useController({\n name: searchName,\n control: form.control,\n });\n const { field, fieldState } = useController({\n name: inputName,\n control: form.control,\n });\n\n const [ariaSelected, setAriaSelected] = useState(-1);\n\n const [open, setOpen] = useState(false);\n\n const { data } = useData?.(searchField.value, initialParams);\n\n const onChange = useCallback(\n (item: any) => {\n const searchValue = item?.[fieldValue as keyof typeof item];\n searchField.onChange(searchValue);\n onSearch?.(searchValue);\n field.onChange(refineValue?.(item) || item);\n setOpen(false);\n },\n [field.value, refineValue, fieldValue]\n );\n\n const handleChange = useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n if (e.target.value === '') {\n field.onChange(null);\n }\n searchField.onChange(e.target.value);\n onSearch?.(e.target.value);\n setOpen(true);\n const item = data?.find((item) => item[fieldValue] === e.target.value);\n if (item) {\n onChange(item);\n setOpen(false);\n }\n },\n [field, searchField]\n );\n\n const handleKeyDown = useCallback(\n (e: React.KeyboardEvent<HTMLInputElement>) => {\n if (e.key === 'ArrowDown') {\n setAriaSelected((prev) => prev + 1);\n }\n if (e.key === 'ArrowUp') {\n setAriaSelected((prev) => prev - 1);\n }\n if (e.key === 'Enter' && data && data[ariaSelected]) {\n onChange(data[ariaSelected]);\n e.stopPropagation();\n e.preventDefault();\n }\n },\n []\n );\n\n useEffect(() => {\n const searchValue = field?.value?.[fieldValue as keyof typeof field.value];\n if (searchValue !== searchField.value && updateSearchOnBlur) {\n searchField.onChange(searchValue);\n onSearch?.(searchValue);\n }\n }, [field.value]);\n\n return (\n <FormItem\n className={cn('w-full flex flex-col', className)}\n id={`input-suggest-${inputName}`}\n >\n <div className=\"flex items-end gap-1.5\">\n <FormLabel htmlFor={inputName}>\n {label}:\n {required && (\n <span className=\"text-red-500 text-lg leading-[1px]\">*</span>\n )}\n </FormLabel>\n\n <InputHelp help={help} name={inputName} />\n </div>\n <Popover onOpenChange={setOpen} open={open} {...props}>\n <PopoverTrigger className=\"outline-hidden w-full relative\">\n <Input\n autoComplete=\"off\"\n className={cn(fieldState.error && 'border-destructive')}\n disabled={disabled}\n name={name}\n onChange={handleChange}\n onKeyDown={handleKeyDown}\n placeholder={placeholder}\n ref={\n mask\n ? withMask(mask, { autoUnmask: true, ...maskOptions })\n : (undefined as any)\n }\n value={searchField.value}\n />\n {children}\n </PopoverTrigger>\n {fieldState.error && <FormMessage />}\n <PopoverContent\n className={cn(\n 'mt-1 w-(--radix-popover-trigger-width) max-w-2xl p-0 z-50',\n data?.length === 0 && 'hidden'\n )}\n onOpenAutoFocus={(e) => e.preventDefault()}\n >\n <ScrollArea className=\"h-fit max-h-[300px]\" id=\"scroll\">\n <ScrollAreaViewport className=\"w-full h-fit max-h-[300px]\">\n <ul className=\"p-1\">\n {data?.slice(0, limit)?.map((item) => (\n <li\n aria-selected={data[ariaSelected]?.id === item.id}\n className={cn(\n 'relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-hidden aria-selected:bg-accent/50 aria-selected:text-accent-foreground data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 transition-all hover:bg-accent/50 hover:text-accent-foreground',\n field?.value?.id === item.id &&\n 'bg-accent! text-accent-foreground'\n )}\n key={item.id}\n onMouseDown={(e) => {\n onChange(item);\n e.preventDefault();\n }}\n >\n <span className=\"line-clamp-1 flex-1\">\n {refineSuggest\n ? refineSuggest(item)\n : item?.[fieldValue as keyof typeof item]}\n </span>\n {field?.value?.id == item.id && (\n <Check className=\"ml-auto h-4 w-4 shrink-0\" />\n )}\n </li>\n ))}\n\n {extra && (\n <li\n className={cn(\n 'flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-hidden aria-selected:bg-accent/50 aria-selected:text-accent-foreground data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 transition-all hover:text-accent-foreground sticky bottom-0.5 bg-white hover:bg-accent'\n )}\n onMouseDown={(e) => {\n e.preventDefault();\n extraOnClick?.();\n }}\n >\n <span className=\"line-clamp-1\">{extra}</span>\n </li>\n )}\n\n {(data?.length === 0 || !data) && !extra && (\n <p className=\"text-sm text-center text-accent-foreground/50 py-2\">\n Nenhum resultado encontrado.\n </p>\n )}\n </ul>\n </ScrollAreaViewport>\n <ScrollBar />\n </ScrollArea>\n </PopoverContent>\n </Popover>\n </FormItem>\n );\n}\n\nexport { InputSuggest };\n"],"mappings":";;;;;;;;;;;;;;;AAyEA,SAAS,aAGP,EACA,MACA,YACA,UACA,aAAa,QACb,OACA,WACA,aACA,SACA,UACA,UACA,UACA,qBAAqB,MACrB,OACA,OACA,cACA,aAAa,OACb,SACA,MACA,QACA,aACA,eACA,QAAQ,IACR,MACA,aACA,UACA,cACA,GAAG,SAC0D;CAC7D,MAAM,OAAO,gBAAgB;CAC7B,MAAM,YAAY,SAAS,GAAG,OAAO,GAAG,SAAS;CACjD,MAAM,aAAa,SAAS,GAAG,OAAO,GAAG,eAAe;CAExD,MAAM,EAAE,OAAO,gBAAgB,cAAc;EAC3C,MAAM;EACN,SAAS,KAAK;EACf,CAAC;CACF,MAAM,EAAE,OAAO,eAAe,cAAc;EAC1C,MAAM;EACN,SAAS,KAAK;EACf,CAAC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MACE;;IACT;GACD"}
|
package/dist/page-header.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime6 from "react/jsx-runtime";
|
|
2
2
|
|
|
3
3
|
//#region src/components/page-header/page-header.d.ts
|
|
4
4
|
interface PageHeaderProps {
|
|
@@ -10,7 +10,7 @@ declare function PageHeader({
|
|
|
10
10
|
title,
|
|
11
11
|
help,
|
|
12
12
|
description
|
|
13
|
-
}: PageHeaderProps):
|
|
13
|
+
}: PageHeaderProps): react_jsx_runtime6.JSX.Element;
|
|
14
14
|
//#endregion
|
|
15
15
|
export { PageHeader, type PageHeaderProps };
|
|
16
16
|
//# sourceMappingURL=page-header.d.ts.map
|
package/dist/page-header.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
import "./utils-C0f9Ma6r.js";
|
|
5
5
|
import "./label-BqtcCyMj.js";
|
|
6
|
-
import { InputHelp } from "./input-help-
|
|
6
|
+
import { InputHelp } from "./input-help-Bxsf3Cg-.js";
|
|
7
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
8
|
|
|
9
9
|
//#region src/components/page-header/page-header.tsx
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FieldPath, FieldPathValue, FieldValues, UseControllerProps } from "react-hook-form";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
3
|
import { Options } from "nuqs";
|
|
4
4
|
import { PopoverProps } from "@radix-ui/react-popover";
|
|
5
5
|
|
|
@@ -61,7 +61,7 @@ declare function RemoteSelectorField<T, TFieldValues extends FieldValues = Field
|
|
|
61
61
|
initialRequest,
|
|
62
62
|
forceToggle,
|
|
63
63
|
...props
|
|
64
|
-
}: RemoteSelectorFieldProps<TFieldValues, TFieldName> & BaseRemoteSelectorProps<T>):
|
|
64
|
+
}: RemoteSelectorFieldProps<TFieldValues, TFieldName> & BaseRemoteSelectorProps<T>): react_jsx_runtime0.JSX.Element;
|
|
65
65
|
interface RemoteSelectorQueryProps<T> extends BaseRemoteSelectorProps<T> {
|
|
66
66
|
name: string;
|
|
67
67
|
defaultValue?: string;
|
|
@@ -81,7 +81,7 @@ declare function RemoteSelectorQuery<T>({
|
|
|
81
81
|
fieldLabel,
|
|
82
82
|
type,
|
|
83
83
|
...props
|
|
84
|
-
}: RemoteSelectorQueryProps<T>):
|
|
84
|
+
}: RemoteSelectorQueryProps<T>): react_jsx_runtime0.JSX.Element;
|
|
85
85
|
//#endregion
|
|
86
86
|
export { type BaseRemoteSelectorProps, RemoteSelectorField as RemoteSelector, RemoteSelectorField, type RemoteSelectorFieldProps, RemoteSelectorQuery, type RemoteSelectorQueryProps, type TUseData };
|
|
87
87
|
//# sourceMappingURL=remote-selector.d.ts.map
|
package/dist/remote-selector.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
import { cn } from "./utils-C0f9Ma6r.js";
|
|
5
5
|
import "./label-BqtcCyMj.js";
|
|
6
|
-
import { FormField, FormItem, FormMessage, InputHelp } from "./input-help-
|
|
6
|
+
import { FormField, FormItem, FormMessage, InputHelp } from "./input-help-Bxsf3Cg-.js";
|
|
7
7
|
import { Popover, PopoverContent, PopoverTrigger, ScrollBar } from "./scroll-area-C2WadzN5.js";
|
|
8
8
|
import { useFormContext } from "react-hook-form";
|
|
9
9
|
import { createElement, useEffect, useId, useMemo, useState } from "react";
|
package/dist/text-field.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { Options as Options$1 } from "./with-mask-DnMiJlek.js";
|
|
1
2
|
import { FieldPath, FieldPathValue, FieldValues, UseControllerProps } from "react-hook-form";
|
|
2
|
-
import * as
|
|
3
|
-
import { Options } from "
|
|
4
|
-
import { Options as Options$1 } from "nuqs";
|
|
3
|
+
import * as react_jsx_runtime1 from "react/jsx-runtime";
|
|
4
|
+
import { Options } from "nuqs";
|
|
5
5
|
|
|
6
6
|
//#region src/components/text-field/TextField.d.ts
|
|
7
|
-
type Mask
|
|
7
|
+
type Mask = 'datetime' | 'email' | 'numeric' | 'currency' | 'decimal' | 'integer' | 'percentage' | 'url' | 'ip' | 'mac' | 'ssn' | 'brl-currency' | 'cpf' | 'cnpj' | (string & {}) | (string[] & {}) | null;
|
|
8
8
|
interface InputTextProps extends React.InputHTMLAttributes<HTMLInputElement> {
|
|
9
9
|
ref?: React.ForwardedRef<HTMLInputElement>;
|
|
10
10
|
label?: string;
|
|
@@ -17,8 +17,8 @@ interface InputTextProps extends React.InputHTMLAttributes<HTMLInputElement> {
|
|
|
17
17
|
required?: boolean;
|
|
18
18
|
maskRef?: React.ForwardedRef<any>;
|
|
19
19
|
children?: React.ReactNode;
|
|
20
|
-
mask?: Mask
|
|
21
|
-
maskOptions?: Options;
|
|
20
|
+
mask?: Mask;
|
|
21
|
+
maskOptions?: Options$1;
|
|
22
22
|
error?: React.ReactNode;
|
|
23
23
|
id?: string;
|
|
24
24
|
detail?: string;
|
|
@@ -57,7 +57,7 @@ declare function InputText({
|
|
|
57
57
|
name,
|
|
58
58
|
onChange,
|
|
59
59
|
...props
|
|
60
|
-
}: InputTextProps):
|
|
60
|
+
}: InputTextProps): react_jsx_runtime1.JSX.Element;
|
|
61
61
|
interface TextFieldProps<TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> extends UseControllerProps<TFieldValues, TFieldName> {
|
|
62
62
|
disabled?: boolean;
|
|
63
63
|
required?: boolean;
|
|
@@ -75,11 +75,11 @@ declare function TextField<TFieldValues extends FieldValues = FieldValues, TFiel
|
|
|
75
75
|
transform,
|
|
76
76
|
prefix,
|
|
77
77
|
...props
|
|
78
|
-
}: TextFieldProps<TFieldValues, TFieldName> & Omit<InputTextProps, 'onChange'>):
|
|
78
|
+
}: TextFieldProps<TFieldValues, TFieldName> & Omit<InputTextProps, 'onChange'>): react_jsx_runtime1.JSX.Element;
|
|
79
79
|
interface QueryTextFieldProps extends Omit<InputTextProps, 'onChange'> {
|
|
80
80
|
name: string;
|
|
81
81
|
defaultValue?: string;
|
|
82
|
-
options?: Options
|
|
82
|
+
options?: Options;
|
|
83
83
|
onChange?: (value: string) => void;
|
|
84
84
|
}
|
|
85
85
|
declare function QueryTextField({
|
|
@@ -87,7 +87,7 @@ declare function QueryTextField({
|
|
|
87
87
|
defaultValue,
|
|
88
88
|
options,
|
|
89
89
|
...props
|
|
90
|
-
}: QueryTextFieldProps):
|
|
90
|
+
}: QueryTextFieldProps): react_jsx_runtime1.JSX.Element;
|
|
91
91
|
interface CookieTextFieldProps extends InputTextProps {
|
|
92
92
|
name: string;
|
|
93
93
|
maxAge?: number;
|
|
@@ -97,7 +97,7 @@ declare function CookieTextField({
|
|
|
97
97
|
maxAge,
|
|
98
98
|
onChange,
|
|
99
99
|
...inputProps
|
|
100
|
-
}: CookieTextFieldProps):
|
|
100
|
+
}: CookieTextFieldProps): react_jsx_runtime1.JSX.Element;
|
|
101
101
|
//#endregion
|
|
102
102
|
export { CookieTextField, type CookieTextFieldProps, InputText, type InputTextProps, QueryTextField, type QueryTextFieldProps, TextField, type TextFieldProps };
|
|
103
103
|
//# 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":";;;;;;
|
|
1
|
+
{"version":3,"file":"text-field.d.ts","names":[],"sources":["../src/components/text-field/TextField.tsx"],"sourcesContent":[],"mappings":";;;;;;KAwBK,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;WAAb,CAAA,EAAA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3,12 +3,11 @@
|
|
|
3
3
|
|
|
4
4
|
import { cn } from "./utils-C0f9Ma6r.js";
|
|
5
5
|
import { Label } from "./label-BqtcCyMj.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { useFormContext } from "react-hook-form";
|
|
6
|
+
import { Input, withMask } from "./input-Cp3f1KmR.js";
|
|
7
|
+
import { FormItem, InputHelp } from "./input-help-Bxsf3Cg-.js";
|
|
8
|
+
import { useController, useFormContext } from "react-hook-form";
|
|
9
9
|
import { useEffect, useId, useState } from "react";
|
|
10
10
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
-
import { withMask } from "use-mask-input";
|
|
12
11
|
import { useCookiesNext } from "cookies-next";
|
|
13
12
|
import { parseAsString, useQueryState } from "nuqs";
|
|
14
13
|
|
|
@@ -139,31 +138,31 @@ function TextField({ name, className, required, defaultValue, onChange, transfor
|
|
|
139
138
|
const { control, setError } = useFormContext();
|
|
140
139
|
const inputName = prefix ? `${prefix}.${name}` : name;
|
|
141
140
|
const id = useId();
|
|
142
|
-
|
|
141
|
+
const { field, fieldState } = useController({
|
|
143
142
|
control,
|
|
144
|
-
defaultValue,
|
|
145
143
|
name: inputName,
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
144
|
+
rules: { required: required ? "Campo obrigatório" : false },
|
|
145
|
+
defaultValue
|
|
146
|
+
});
|
|
147
|
+
return /* @__PURE__ */ jsx(FormItem, {
|
|
148
|
+
className: cn("w-full", className),
|
|
149
|
+
children: /* @__PURE__ */ jsx(InputText, {
|
|
150
|
+
...field,
|
|
151
|
+
...props,
|
|
152
|
+
disabled: props.disabled,
|
|
153
|
+
error: fieldState?.error?.message,
|
|
154
|
+
id: `${id}-${inputName.replaceAll(".", "-")}`,
|
|
155
|
+
name: inputName,
|
|
156
|
+
onChange: (e) => {
|
|
157
|
+
field.onChange(transform(e.target.value));
|
|
158
|
+
onChange?.(transform(e.target.value));
|
|
159
|
+
},
|
|
160
|
+
required,
|
|
161
|
+
setError: (error) => {
|
|
162
|
+
setError(inputName, { message: error || "" });
|
|
163
|
+
},
|
|
164
|
+
value: field.value || ""
|
|
165
|
+
})
|
|
167
166
|
});
|
|
168
167
|
}
|
|
169
168
|
function QueryTextField({ name, defaultValue, options,...props }) {
|
package/dist/text-field.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text-field.js","names":["defaultConfig: Intl.NumberFormatOptions","useMoneyInput","value"],"sources":["../src/hooks/use-money-input.ts","../src/components/text-field/TextField.tsx"],"sourcesContent":["'use client';\n\nimport { useEffect, useState } from 'react';\n\ntype useMoneyInputProps = {\n config?: Intl.NumberFormatOptions & { prefix?: string; suffix?: string };\n value?: number;\n onChange?: (value?: number) => void;\n};\n\nconst defaultConfig: Intl.NumberFormatOptions = {\n currency: 'BRL',\n currencyDisplay: 'symbol',\n currencySign: 'standard',\n style: 'currency',\n minimumFractionDigits: 2,\n maximumFractionDigits: 2,\n};\n\nconst useMoneyInput = ({\n config = defaultConfig,\n onChange,\n value,\n}: useMoneyInputProps) => {\n const prefix = config?.prefix || '';\n const suffix = config?.suffix || '';\n const divider = Math.pow(10, config?.maximumFractionDigits || 2);\n const moneyFormatter = Intl.NumberFormat('pt-BR', config);\n const [displayValue, setDisplayValue] = useState(() =>\n value ? `${prefix}${moneyFormatter.format(value)}${suffix}` : ''\n );\n\n const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const digits = e.target.value.replace(/\\D/g, '');\n const realValue = digits ? Number(digits) / divider : undefined;\n const formattedValue =\n digits && realValue\n ? `${prefix}${moneyFormatter.format(realValue)}${suffix}`\n : '';\n\n setDisplayValue(formattedValue);\n onChange?.(realValue);\n };\n\n useEffect(() => {\n const formatted = value\n ? `${prefix}${moneyFormatter.format(value)}${suffix}`\n : '';\n setDisplayValue(formatted);\n }, [value]);\n\n return { displayValue, handleChange };\n};\n\nexport default useMoneyInput;\n","'use client';\n\nimport { useEffect, useId, useState } 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';\nimport useMoneyInput from '@/hooks/use-money-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 { useCookiesNext } from 'cookies-next';\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 inputType?: 'default' | 'money';\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 setError?: (error: string | undefined) => void;\n moneyConfig?: Intl.NumberFormatOptions & { prefix?: string; suffix?: string };\n}\nfunction InputText({\n label,\n description,\n placeholder,\n className,\n children,\n disabled,\n type,\n required,\n maskRef,\n mask,\n inputType = 'default',\n maskOptions,\n error,\n setError,\n id,\n ref,\n detail,\n detailClassName,\n inputClassName,\n help,\n value,\n moneyConfig,\n name,\n onChange,\n ...props\n}: InputTextProps) {\n const { displayValue, handleChange } = useMoneyInput({\n config: moneyConfig,\n onChange(value) {\n onChange?.({\n ...({} as React.ChangeEvent<HTMLInputElement>),\n target: { value: value as any },\n } as React.ChangeEvent<HTMLInputElement>);\n },\n value: Number(value),\n });\n\n const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n if (inputType === 'money') {\n const rawNumber = Number(e.target.value.replace(/\\D/g, '')) / 100;\n\n if (props.max && rawNumber >= Number(props.max)) {\n setError?.(`O valor deve ser menor que ${props.max}`);\n return;\n }\n\n if (props.min && rawNumber <= Number(props.min)) {\n setError?.(`O valor deve ser maior que ${props.min}`);\n return;\n }\n\n setError?.(undefined);\n\n handleChange?.(e);\n } else {\n onChange?.(e);\n }\n };\n\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 leading-none'\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 leading-none',\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-1\">\n <div className=\"relative\">\n <Input\n className={cn(error && 'border-destructive', inputClassName)}\n disabled={disabled}\n id={id}\n onChange={handleInputChange}\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 value={value && inputType === 'money' ? displayValue : value}\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 && (\n <p className=\"text-destructive text-xs\" data-slot=\"form-message\">\n {error}\n </p>\n )}\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 prefix,\n ...props\n}: TextFieldProps<TFieldValues, TFieldName> &\n Omit<InputTextProps, 'onChange'>) {\n const { control, setError } = useFormContext();\n const inputName = prefix ? `${prefix}.${name}` : name;\n const id = useId();\n\n return (\n <FormField\n control={control}\n defaultValue={defaultValue}\n name={inputName}\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?.message}\n id={`${id}-${inputName.replaceAll('.', '-')}`}\n name={inputName}\n onChange={(e) => {\n field.onChange(transform(e.target.value));\n onChange?.(transform(e.target.value));\n }}\n required={required}\n setError={(error) => {\n setError(inputName, { message: error || '' });\n }}\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 [error, setError] = useState<string | undefined>(undefined);\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 error={error}\n onChange={(e) => {\n setFilter(e.target.value);\n props.onChange?.(e.target.value);\n }}\n setError={setError}\n />\n );\n}\n\nexport interface CookieTextFieldProps extends InputTextProps {\n name: string;\n maxAge?: number;\n}\n\nfunction CookieTextField({\n name,\n maxAge = 60 * 60 * 24 * 7,\n onChange,\n ...inputProps\n}: CookieTextFieldProps) {\n const { getCookie, setCookie, deleteCookie } = useCookiesNext();\n const [error, setError] = useState<string | undefined>(undefined);\n const [value, setValue] = useState('');\n\n useEffect(() => {\n const stored = getCookie(`input-${name}`);\n if (stored && typeof stored === 'string') {\n setValue(stored);\n onChange?.(stored as any);\n }\n }, [name, getCookie]);\n\n useEffect(() => {\n if (value !== '' && value !== undefined) {\n setCookie(`input-${name}`, value, { maxAge });\n } else {\n deleteCookie(`input-${name}`);\n }\n }, [name, value, setCookie]);\n\n return (\n <InputText\n {...inputProps}\n error={error}\n id={`cookie-${name}`}\n name={name}\n onChange={(e) => {\n setValue(e.target.value);\n onChange?.(e.target.value as any);\n }}\n setError={setError}\n value={value}\n />\n );\n}\n\nexport { InputText, TextField, QueryTextField, CookieTextField };\n"],"mappings":";;;;;;;;;;;;;;;AAUA,MAAMA,gBAA0C;CAC9C,UAAU;CACV,iBAAiB;CACjB,cAAc;CACd,OAAO;CACP,uBAAuB;CACvB,uBAAuB;CACxB;AAED,MAAM,iBAAiB,EACrB,SAAS,eACT,UACA,YACwB;CACxB,MAAM,SAAS,QAAQ,UAAU;CACjC,MAAM,SAAS,QAAQ,UAAU;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O;AAChB,cAAW,OAAc;;IAE1B,CAAC,MAAM,UAAU,CAAC;AAErB,iBAAgB;AACd,MAAI,UAAU,MAAM,UAAU,OAC5B,WAAU,SAAS,QAAQ,OAAO,EAAE,QAAQ,CAAC;MAE7C,cAAa,SAAS,OAAO;IAE9B;EAAC;EAAM;EAAO;EAAU,CAAC;AAE5B,QACE,oBAAC;EACC,GAAI;EACG;EACP,IAAI,UAAU;EACR;EACN,WAAW,MAAM;AACf,YAAS,EAAE,OAAO,MAAM;AACxB,cAAW,EAAE,OAAO,MAAa;;EAEzB;EACH;GACP"}
|
|
1
|
+
{"version":3,"file":"text-field.js","names":["defaultConfig: Intl.NumberFormatOptions","useMoneyInput","value"],"sources":["../src/hooks/use-money-input.ts","../src/components/text-field/TextField.tsx"],"sourcesContent":["'use client';\n\nimport { useEffect, useState } from 'react';\n\ntype useMoneyInputProps = {\n config?: Intl.NumberFormatOptions & { prefix?: string; suffix?: string };\n value?: number;\n onChange?: (value?: number) => void;\n};\n\nconst defaultConfig: Intl.NumberFormatOptions = {\n currency: 'BRL',\n currencyDisplay: 'symbol',\n currencySign: 'standard',\n style: 'currency',\n minimumFractionDigits: 2,\n maximumFractionDigits: 2,\n};\n\nconst useMoneyInput = ({\n config = defaultConfig,\n onChange,\n value,\n}: useMoneyInputProps) => {\n const prefix = config?.prefix || '';\n const suffix = config?.suffix || '';\n const divider = Math.pow(10, config?.maximumFractionDigits || 2);\n const moneyFormatter = Intl.NumberFormat('pt-BR', config);\n const [displayValue, setDisplayValue] = useState(() =>\n value ? `${prefix}${moneyFormatter.format(value)}${suffix}` : ''\n );\n\n const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const digits = e.target.value.replace(/\\D/g, '');\n const realValue = digits ? Number(digits) / divider : undefined;\n const formattedValue =\n digits && realValue\n ? `${prefix}${moneyFormatter.format(realValue)}${suffix}`\n : '';\n\n setDisplayValue(formattedValue);\n onChange?.(realValue);\n };\n\n useEffect(() => {\n const formatted = value\n ? `${prefix}${moneyFormatter.format(value)}${suffix}`\n : '';\n setDisplayValue(formatted);\n }, [value]);\n\n return { displayValue, handleChange };\n};\n\nexport default useMoneyInput;\n","'use client';\n\nimport { useEffect, useId, useState } from 'react';\n\nimport {\n type FieldPath,\n type FieldPathValue,\n type FieldValues,\n type UseControllerProps,\n useController,\n useFormContext,\n} from 'react-hook-form';\nimport useMoneyInput from '@/hooks/use-money-input';\nimport withMask, { type Options as MaskOptions } from '@/hooks/with-mask';\n\nimport { FormItem } 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 { useCookiesNext } from 'cookies-next';\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 inputType?: 'default' | 'money';\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 setError?: (error: string | undefined) => void;\n moneyConfig?: Intl.NumberFormatOptions & { prefix?: string; suffix?: string };\n}\nfunction InputText({\n label,\n description,\n placeholder,\n className,\n children,\n disabled,\n type,\n required,\n maskRef,\n mask,\n inputType = 'default',\n maskOptions,\n error,\n setError,\n id,\n ref,\n detail,\n detailClassName,\n inputClassName,\n help,\n value,\n moneyConfig,\n name,\n onChange,\n ...props\n}: InputTextProps) {\n const { displayValue, handleChange } = useMoneyInput({\n config: moneyConfig,\n onChange(value) {\n onChange?.({\n ...({} as React.ChangeEvent<HTMLInputElement>),\n target: { value: value as any },\n } as React.ChangeEvent<HTMLInputElement>);\n },\n value: Number(value),\n });\n\n const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n if (inputType === 'money') {\n const rawNumber = Number(e.target.value.replace(/\\D/g, '')) / 100;\n\n if (props.max && rawNumber >= Number(props.max)) {\n setError?.(`O valor deve ser menor que ${props.max}`);\n return;\n }\n\n if (props.min && rawNumber <= Number(props.min)) {\n setError?.(`O valor deve ser maior que ${props.min}`);\n return;\n }\n\n setError?.(undefined);\n\n handleChange?.(e);\n } else {\n onChange?.(e);\n }\n };\n\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 leading-none'\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 leading-none',\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-1\">\n <div className=\"relative\">\n <Input\n className={cn(error && 'border-destructive', inputClassName)}\n disabled={disabled}\n id={id}\n onChange={handleInputChange}\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 value={value && inputType === 'money' ? displayValue : value}\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 && (\n <p className=\"text-destructive text-xs\" data-slot=\"form-message\">\n {error}\n </p>\n )}\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 prefix,\n ...props\n}: TextFieldProps<TFieldValues, TFieldName> &\n Omit<InputTextProps, 'onChange'>) {\n const { control, setError } = useFormContext();\n const inputName = prefix ? `${prefix}.${name}` : name;\n const id = useId();\n const { field, fieldState } = useController({\n control,\n name: inputName,\n rules: { required: required ? 'Campo obrigatório' : false },\n defaultValue,\n });\n\n return (\n <FormItem className={cn('w-full', className)}>\n <InputText\n {...field}\n {...props}\n disabled={props.disabled}\n error={fieldState?.error?.message}\n id={`${id}-${inputName.replaceAll('.', '-')}`}\n name={inputName}\n onChange={(e) => {\n field.onChange(transform(e.target.value));\n onChange?.(transform(e.target.value));\n }}\n required={required}\n setError={(error) => {\n setError(inputName, { message: error || '' });\n }}\n value={field.value || ''}\n />\n </FormItem>\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 [error, setError] = useState<string | undefined>(undefined);\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 error={error}\n onChange={(e) => {\n setFilter(e.target.value);\n props.onChange?.(e.target.value);\n }}\n setError={setError}\n />\n );\n}\n\nexport interface CookieTextFieldProps extends InputTextProps {\n name: string;\n maxAge?: number;\n}\n\nfunction CookieTextField({\n name,\n maxAge = 60 * 60 * 24 * 7,\n onChange,\n ...inputProps\n}: CookieTextFieldProps) {\n const { getCookie, setCookie, deleteCookie } = useCookiesNext();\n const [error, setError] = useState<string | undefined>(undefined);\n const [value, setValue] = useState('');\n\n useEffect(() => {\n const stored = getCookie(`input-${name}`);\n if (stored && typeof stored === 'string') {\n setValue(stored);\n onChange?.(stored as any);\n }\n }, [name, getCookie]);\n\n useEffect(() => {\n if (value !== '' && value !== undefined) {\n setCookie(`input-${name}`, value, { maxAge });\n } else {\n deleteCookie(`input-${name}`);\n }\n }, [name, value, setCookie]);\n\n return (\n <InputText\n {...inputProps}\n error={error}\n id={`cookie-${name}`}\n name={name}\n onChange={(e) => {\n setValue(e.target.value);\n onChange?.(e.target.value as any);\n }}\n setError={setError}\n value={value}\n />\n );\n}\n\nexport { InputText, TextField, QueryTextField, CookieTextField };\n"],"mappings":";;;;;;;;;;;;;;AAUA,MAAMA,gBAA0C;CAC9C,UAAU;CACV,iBAAiB;CACjB,cAAc;CACd,OAAO;CACP,uBAAuB;CACvB,uBAAuB;CACxB;AAED,MAAM,iBAAiB,EACrB,SAAS,eACT,UACA,YACwB;CACxB,MAAM,SAAS,QAAQ,UAAU;CACjC,MAAM,SAAS,QAAQ,UAAU;CACjC,MAAM,UAAU,KAAK,IAAI,IAAI,QAAQ,yBAAyB,EAAE;CAChE,MAAM,iBAAiB,KAAK,aAAa,SAAS,OAAO;CACzD,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B,WAAU,SAAS,QAAQ,OAAO,EAAE,QAAQ,CAAC;MAE7C,cAAa,SAAS,OAAO;IAE9B;EAAC;EAAM;EAAO;EAAU,CAAC;AAE5B,QACE,oBAAC;EACC,GAAI;EACG;EACP,IAAI,UAAU;EACR;EACN,WAAW,MAAM;AACf,YAAS,EAAE,OAAO,MAAM;AACxB,cAAW,EAAE,OAAO,MAAa;;EAEzB;EACH;GACP"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import "react-hook-form";
|
|
2
|
+
import inputmask from "inputmask";
|
|
3
|
+
|
|
4
|
+
//#region src/hooks/with-mask.d.ts
|
|
5
|
+
type Mask = 'datetime' | 'email' | 'numeric' | 'currency' | 'decimal' | 'integer' | 'percentage' | 'url' | 'ip' | 'mac' | 'ssn' | 'brl-currency' | 'cpf' | 'cnpj' | (string & {}) | (string[] & {}) | null;
|
|
6
|
+
type Options = inputmask.Options;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { Mask, Options };
|
|
9
|
+
//# sourceMappingURL=with-mask-DnMiJlek.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"with-mask-DnMiJlek.d.ts","names":[],"sources":["../src/hooks/with-mask.ts"],"sourcesContent":[],"mappings":";;;;KAQY,IAAA;KAkBA,OAAA,GAAU,SAAA,CAAU"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "maquinaweb-ui",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.30.0",
|
|
4
4
|
"description": "A minimal React component library",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -68,9 +68,6 @@
|
|
|
68
68
|
"nuqs": {
|
|
69
69
|
"optional": true
|
|
70
70
|
},
|
|
71
|
-
"use-mask-input": {
|
|
72
|
-
"optional": true
|
|
73
|
-
},
|
|
74
71
|
"motion": {
|
|
75
72
|
"optional": true
|
|
76
73
|
},
|
|
@@ -92,17 +89,19 @@
|
|
|
92
89
|
"@radix-ui/react-tooltip": "^1.2.8",
|
|
93
90
|
"class-variance-authority": "^0.7.1",
|
|
94
91
|
"clsx": "^2.1.1",
|
|
92
|
+
"inputmask": "5.0.10-beta.61",
|
|
95
93
|
"tailwind-merge": "^3.3.1",
|
|
96
94
|
"use-debounce": "^10.0.6"
|
|
97
95
|
},
|
|
98
96
|
"devDependencies": {
|
|
99
|
-
"cmdk": "^1.1.1",
|
|
100
97
|
"@biomejs/biome": "^2.3.2",
|
|
101
98
|
"@semantic-release/changelog": "^6.0.3",
|
|
102
99
|
"@semantic-release/git": "^10.0.1",
|
|
103
100
|
"@tailwindcss/postcss": "^4.1.16",
|
|
101
|
+
"@types/inputmask": "^5.0.7",
|
|
104
102
|
"@types/react": "^19.2.0",
|
|
105
103
|
"@types/react-dom": "^19.2.0",
|
|
104
|
+
"cmdk": "^1.1.1",
|
|
106
105
|
"concurrently": "^9.0.0",
|
|
107
106
|
"cookies-next": "^6.1.1",
|
|
108
107
|
"glob": "^11.0.3",
|
|
@@ -121,8 +120,7 @@
|
|
|
121
120
|
"tailwindcss": "^4.1.14",
|
|
122
121
|
"tsdown": "^0.15.6",
|
|
123
122
|
"tw-animate-css": "^1.4.0",
|
|
124
|
-
"typescript": "^5.7.2"
|
|
125
|
-
"use-mask-input": "^3.5.2"
|
|
123
|
+
"typescript": "^5.7.2"
|
|
126
124
|
},
|
|
127
125
|
"keywords": [
|
|
128
126
|
"react",
|
package/dist/input-COsbbKgj.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { cn } from "./utils-C0f9Ma6r.js";
|
|
2
|
-
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
|
|
4
|
-
//#region src/components/ui/input.tsx
|
|
5
|
-
function Input({ className, type,...props }) {
|
|
6
|
-
return /* @__PURE__ */ jsx("input", {
|
|
7
|
-
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),
|
|
8
|
-
"data-slot": "input",
|
|
9
|
-
type,
|
|
10
|
-
...props
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
//#endregion
|
|
15
|
-
export { Input };
|
|
16
|
-
//# sourceMappingURL=input-COsbbKgj.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"input-COsbbKgj.js","names":[],"sources":["../src/components/ui/input.tsx"],"sourcesContent":["import type * as React from 'react';\n\nimport { cn } from '@/lib/utils';\n\nfunction Input({ className, type, ...props }: React.ComponentProps<'input'>) {\n return (\n <input\n className={cn(\n 'file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input flex h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm',\n 'focus-visible:border-ring focus-visible:ring-ring/75 focus-visible:ring-[2px]',\n 'aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive ring-offset-[2px] transition-all duration-300',\n className\n )}\n data-slot=\"input\"\n type={type}\n {...props}\n />\n );\n}\n\nexport { Input };\n"],"mappings":";;;;AAIA,SAAS,MAAM,EAAE,WAAW,KAAM,GAAG,SAAwC;AAC3E,QACE,oBAAC;EACC,WAAW,GACT,mcACA,iFACA,wJACA,UACD;EACD,aAAU;EACJ;EACN,GAAI;GACJ"}
|