maquinaweb-ui 2.30.0 → 2.30.2
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 +0 -23
- package/dist/container-animation.d.ts +2 -2
- package/dist/{input-help-Bxsf3Cg-.js → input-help-WAdTyl_h.js} +2 -2
- package/dist/{input-help-Bxsf3Cg-.js.map → input-help-WAdTyl_h.js.map} +1 -1
- package/dist/input-suggest.js +1 -1
- package/dist/page-header.d.ts +2 -2
- package/dist/page-header.js +1 -1
- package/dist/remote-selector.js +1 -1
- package/dist/text-field.d.ts +5 -5
- package/dist/text-field.d.ts.map +1 -1
- package/dist/text-field.js +2 -2
- package/dist/text-field.js.map +1 -1
- package/dist/toggle-field.d.ts +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -15,29 +15,6 @@ A minimal React component library built with TypeScript, formatted with Biome, a
|
|
|
15
15
|
bun install
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
-
## 📦 Project Structure
|
|
19
|
-
|
|
20
|
-
```
|
|
21
|
-
maquinaweb-ui/
|
|
22
|
-
├── src/
|
|
23
|
-
│ ├── components/
|
|
24
|
-
│ │ └── Button/
|
|
25
|
-
│ │ ├── Button.tsx # Component implementation
|
|
26
|
-
│ │ ├── Button.fixture.tsx # React Cosmos fixtures
|
|
27
|
-
│ │ └── index.ts # Component exports
|
|
28
|
-
│ └── index.ts # Library entry point
|
|
29
|
-
├── app/
|
|
30
|
-
│ ├── layout.tsx # Next.js root layout
|
|
31
|
-
│ └── page.tsx # Next.js preview page
|
|
32
|
-
├── dist/ # Build output (generated)
|
|
33
|
-
├── package.json
|
|
34
|
-
├── tsconfig.json
|
|
35
|
-
├── biome.json
|
|
36
|
-
├── tsup.config.ts
|
|
37
|
-
├── cosmos.config.json
|
|
38
|
-
└── next.config.ts
|
|
39
|
-
```
|
|
40
|
-
|
|
41
18
|
## 🛠️ Development
|
|
42
19
|
|
|
43
20
|
### Run Next.js Dev Server
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ComponentProps, ElementType } from "react";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime6 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_runtime6.JSX.Element;
|
|
27
27
|
//#endregion
|
|
28
28
|
export { ContainerAnimation, type ContainerAnimationProps };
|
|
29
29
|
//# sourceMappingURL=container-animation.d.ts.map
|
|
@@ -134,7 +134,7 @@ const InputHelp = ({ help, name, className }) => {
|
|
|
134
134
|
className: cn("whitespace-pre-line leading-relaxed max-w-96 text-[13px]"),
|
|
135
135
|
help: helpText,
|
|
136
136
|
children: /* @__PURE__ */ jsx("button", {
|
|
137
|
-
className: cn("
|
|
137
|
+
className: cn("size-fit hover:bg-muted rounded-sm", className),
|
|
138
138
|
type: "button",
|
|
139
139
|
children: /* @__PURE__ */ jsx(Info, { className: "size-3.5" })
|
|
140
140
|
})
|
|
@@ -143,4 +143,4 @@ const InputHelp = ({ help, name, className }) => {
|
|
|
143
143
|
|
|
144
144
|
//#endregion
|
|
145
145
|
export { FormField, FormItem, FormLabel, FormMessage, InputHelp };
|
|
146
|
-
//# sourceMappingURL=input-help-
|
|
146
|
+
//# sourceMappingURL=input-help-WAdTyl_h.js.map
|
|
@@ -1 +1 @@
|
|
|
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,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BAAgB,EAChB,GAAG,SACsD;AACzD,QACE,oBAAC,iBAAiB;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-WAdTyl_h.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('size-fit hover:bg-muted rounded-sm', className)}\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,QA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AC,iBAAiB;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,GAAG,sCAAsC,UAAU;GAC9D,MAAK;aAEL,oBAAC,QAAK,WAAU,aAAa;IACtB;GACG"}
|
package/dist/input-suggest.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { cn } from "./utils-C0f9Ma6r.js";
|
|
5
5
|
import "./label-BqtcCyMj.js";
|
|
6
6
|
import { Input, withMask } from "./input-Cp3f1KmR.js";
|
|
7
|
-
import { FormItem, FormLabel, FormMessage, InputHelp } from "./input-help-
|
|
7
|
+
import { FormItem, FormLabel, FormMessage, InputHelp } from "./input-help-WAdTyl_h.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";
|
package/dist/page-header.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime0 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_runtime0.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-WAdTyl_h.js";
|
|
7
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
8
|
|
|
9
9
|
//#region src/components/page-header/page-header.tsx
|
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-WAdTyl_h.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,6 +1,6 @@
|
|
|
1
1
|
import { Options as Options$1 } from "./with-mask-DnMiJlek.js";
|
|
2
2
|
import { FieldPath, FieldPathValue, FieldValues, UseControllerProps } from "react-hook-form";
|
|
3
|
-
import * as
|
|
3
|
+
import * as react_jsx_runtime2 from "react/jsx-runtime";
|
|
4
4
|
import { Options } from "nuqs";
|
|
5
5
|
|
|
6
6
|
//#region src/components/text-field/TextField.d.ts
|
|
@@ -57,7 +57,7 @@ declare function InputText({
|
|
|
57
57
|
name,
|
|
58
58
|
onChange,
|
|
59
59
|
...props
|
|
60
|
-
}: InputTextProps):
|
|
60
|
+
}: InputTextProps): react_jsx_runtime2.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,7 +75,7 @@ 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_runtime2.JSX.Element;
|
|
79
79
|
interface QueryTextFieldProps extends Omit<InputTextProps, 'onChange'> {
|
|
80
80
|
name: string;
|
|
81
81
|
defaultValue?: string;
|
|
@@ -87,7 +87,7 @@ declare function QueryTextField({
|
|
|
87
87
|
defaultValue,
|
|
88
88
|
options,
|
|
89
89
|
...props
|
|
90
|
-
}: QueryTextFieldProps):
|
|
90
|
+
}: QueryTextFieldProps): react_jsx_runtime2.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_runtime2.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":";;;;;;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,SAAA,GAAA,OAAA;MASF,CAAA,EAAA,MAAM;UACL,CAAM,EAAA,OAAA;SACV,CAAA,EAFG,KAAA,CAAM,YAET,CAAA,GAAA,CAAA;UACO,CAAA,EAFH,KAAA,CAAM,SAEH;MACN,CAAA,EAFD,IAEO;aAOK,CAAA,EARL,SAQK;OArBX,CAAA,EAcA,KAAA,CAAM,SAdA;EAAmB,EAAA,CAAA,EAAA,MAAA;EAuB1B,MAAA,CAAA,EAAA,MAAS;EAAA,eAAA,CAAA,EAAA,MAAA;gBAChB,CAAA,EAAA,MAAA;MACA,CAAA,EAAA,MAAA;UACA,CAAA,EAAA,CAAA,KAAA,E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AA;EAAA,IAAA;EAAA,SAAA;EAAA,QAAA;EAAA,YAAA;EAAA,QAAA;EAAA,SAAA;EAAA,MAAA;EAAA,GAAA;AAAA,CAAA,EAsJC,cAtJD,CAsJgB,YAtJhB,EAsJ8B,UAtJ9B,CAAA,GAuJA,IAvJA,CAuJK,cAvJL,EAAA,UAAA,CAAA,CAAA,EAuJgC,kBAAA,CAAA,GAAA,CAAA,OAvJhC;AACA,UAwLe,mBAAA,SAA4B,IAxL3C,CAwLgD,cAxLhD,EAAA,UAAA,CAAA,CAAA;MACA,EAAA,MAAA;cACA,CAAA,EAAA,MAAA;SACA,CAAA,EAwLU,OAxLV;UACA,CAAA,EAAA,CAAA,KAAA,EAAA,MAAA,EAAA,GAAA,IAAA;;iBA2LO,cAAA,CAxLN;EAAA,IAAA;EAAA,YAAA;EAAA,OAAA;EAAA,GAAA;AAAA,CAAA,EA6LA,mBA7LA,CAAA,EA6LmB,kBAAA,CAAA,GAAA,CAAA,OA7LnB;AAAc,UA+NA,oBAAA,SAA6B,cA/N7B,CAAA;EAAA,IAAA,EAAA,MAAA;EAoHA,MAAA,CAAA,EAAA,MAAA;;iBAgHR,eAAA,CA/Gc;EAAA,IAAA;EAAA,MAAA;EAAA,QAAA;EAAA,GAAA;AAAA,CAAA,EAoHpB,oBApHoB,CAAA,EAoHA,kBAAA,CAAA,GAAA,CAAA,OApHA"}
|
package/dist/text-field.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { cn } from "./utils-C0f9Ma6r.js";
|
|
5
5
|
import { Label } from "./label-BqtcCyMj.js";
|
|
6
6
|
import { Input, withMask } from "./input-Cp3f1KmR.js";
|
|
7
|
-
import { FormItem, InputHelp } from "./input-help-
|
|
7
|
+
import { FormItem, InputHelp } from "./input-help-WAdTyl_h.js";
|
|
8
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";
|
|
@@ -73,7 +73,7 @@ function InputText({ label, description, placeholder, className, children, disab
|
|
|
73
73
|
className: cn("w-full flex flex-col gap-1", className),
|
|
74
74
|
id: `input-${name?.replace(".", "-")}`,
|
|
75
75
|
ref,
|
|
76
|
-
children: [/* @__PURE__ */ jsxs("div", {
|
|
76
|
+
children: [(label || detail || help) && /* @__PURE__ */ jsxs("div", {
|
|
77
77
|
className: "flex items-end gap-1.5",
|
|
78
78
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
79
79
|
className: cn("flex !gap-0 flex-col", className),
|
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 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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U,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 {(label || detail || help) && (\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 )}\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,MAAM,CAAC,cAAc,mBAAmB,eACtC,QAAQ,GAAG,SAAS,eAAe,OAA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AC;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"}
|
package/dist/toggle-field.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React$1 from "react";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime8 from "react/jsx-runtime";
|
|
3
3
|
import { Item, Root } from "@radix-ui/react-toggle-group";
|
|
4
4
|
import { VariantProps } from "class-variance-authority";
|
|
5
5
|
import * as class_variance_authority_types0 from "class-variance-authority/types";
|
|
@@ -23,7 +23,7 @@ declare function ToggleGroup({
|
|
|
23
23
|
transition,
|
|
24
24
|
activeClassName,
|
|
25
25
|
...props
|
|
26
|
-
}: ToggleGroupProps):
|
|
26
|
+
}: ToggleGroupProps): react_jsx_runtime8.JSX.Element;
|
|
27
27
|
//#endregion
|
|
28
28
|
//#region src/components/toggle-field/ToggleField.d.ts
|
|
29
29
|
type ToggleOption = {
|