maquinaweb-ui 2.37.0 → 2.38.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/date-field.d.ts +6 -3
- package/dist/date-field.d.ts.map +1 -1
- package/dist/date-field.js +30 -14
- package/dist/date-field.js.map +1 -1
- package/dist/{input-help-BRDK0-yu.js → input-help-D1JqF0YH.js} +3 -9
- package/dist/input-help-D1JqF0YH.js.map +1 -0
- package/dist/input-suggest.d.ts +2 -2
- package/dist/input-suggest.js +1 -1
- 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.js +1 -1
- package/package.json +1 -1
- package/dist/input-help-BRDK0-yu.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ComponentProps, ElementType } from "react";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime8 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_runtime8.JSX.Element;
|
|
27
27
|
//#endregion
|
|
28
28
|
export { ContainerAnimation, type ContainerAnimationProps };
|
|
29
29
|
//# sourceMappingURL=container-animation.d.ts.map
|
package/dist/date-field.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FieldPath, FieldValues, UseControllerProps } from "react-hook-form";
|
|
2
|
-
import * as
|
|
2
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
3
|
import { Matcher } from "react-day-picker";
|
|
4
4
|
|
|
5
5
|
//#region src/components/date-field/DateField.d.ts
|
|
@@ -14,6 +14,8 @@ interface DateFieldProps<TFieldValues extends FieldValues = FieldValues, TFieldN
|
|
|
14
14
|
endMonth?: Date;
|
|
15
15
|
required?: boolean;
|
|
16
16
|
help?: string;
|
|
17
|
+
/** Quando true, o valor será formatado como string YYYY-MM-DD ao invés de Date com horário */
|
|
18
|
+
dateOnly?: boolean;
|
|
17
19
|
}
|
|
18
20
|
declare function DateField<TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>({
|
|
19
21
|
name,
|
|
@@ -25,8 +27,9 @@ declare function DateField<TFieldValues extends FieldValues = FieldValues, TFiel
|
|
|
25
27
|
disabled,
|
|
26
28
|
initialValue,
|
|
27
29
|
required,
|
|
28
|
-
help
|
|
29
|
-
|
|
30
|
+
help,
|
|
31
|
+
dateOnly
|
|
32
|
+
}: DateFieldProps<TFieldValues, TFieldName>): react_jsx_runtime0.JSX.Element;
|
|
30
33
|
//#endregion
|
|
31
34
|
export { DateField, type DateFieldProps };
|
|
32
35
|
//# sourceMappingURL=date-field.d.ts.map
|
package/dist/date-field.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date-field.d.ts","names":[],"sources":["../src/components/date-field/DateField.tsx"],"sourcesContent":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"date-field.d.ts","names":[],"sources":["../src/components/date-field/DateField.tsx"],"sourcesContent":[],"mappings":";;;;;UA6BiB,oCACM,cAAc,gCAChB,UAAU,gBAAgB,UAAU,uBAC/C,KAAK,mBAAmB,cAAc;;;EAH/B,WAAA,CAAA,EAAA,MAAc;EACR,SAAA,CAAA,EAAA,MAAA;EAAc,QAAA,CAAA,EAOxB,OAPwB,GAOd,OAPc,EAAA,GAAA,SAAA;EACN,aAAA,CAAA,EAAA,OAAA;EAAV,YAAA,CAAA,EAQJ,IARI;EAAoC,QAAA,CAAA,EAS5C,IAT4C;EAAV,QAAA,CAAA,EAAA,OAAA;EACb,IAAA,CAAA,EAAA,MAAA;EAAc;EAAjC,QAAA,CAAA,EAAA,OAAA;;iBAeN,SAVc,CAAA,qBAWA,WAXA,GAWc,WAXd,EAAA,mBAYF,SAZE,CAYQ,YAZR,CAAA,GAYwB,SAZxB,CAYkC,YAZlC,CAAA,CAAA,CAAA;EAAA,IAAA;EAAA,KAAA;EAAA,WAAA;EAAA,aAAA;EAAA,QAAA;EAAA,SAAA;EAAA,QAAA;EAAA,YAAA;EAAA,QAAA;EAAA,IAAA;EAAA;AAAA,CAAA,EAyBpB,cAzBoB,CAyBL,YAzBK,EAyBS,UAzBT,CAAA,CAAA,EAyBoB,kBAAA,CAAA,GAAA,CAAA,OAzBpB"}
|
package/dist/date-field.js
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
import { t as cn } from "./utils-C8_amEgK.js";
|
|
5
5
|
import "./label-Bkg7B2j8.js";
|
|
6
6
|
import { n as withMask, t as Input } from "./input-Bs61WBGW.js";
|
|
7
|
-
import { a as FormLabel, i as FormItem, n as FormDescription, o as FormMessage, r as
|
|
7
|
+
import { a as FormLabel, i as FormItem, n as FormDescription, o as FormMessage, r as FormFieldContext, t as InputHelp } from "./input-help-D1JqF0YH.js";
|
|
8
8
|
import { n as buttonVariants, t as Button } from "./button-B3nLhVyZ.js";
|
|
9
9
|
import { n as PopoverContent, r as PopoverTrigger, t as Popover } from "./popover-DwlKLFCp.js";
|
|
10
|
-
import { useFormContext } from "react-hook-form";
|
|
10
|
+
import { useController, useFormContext } from "react-hook-form";
|
|
11
11
|
import * as React from "react";
|
|
12
12
|
import { useEffect, useState } from "react";
|
|
13
13
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -169,7 +169,7 @@ Calendar.displayName = "Calendar";
|
|
|
169
169
|
|
|
170
170
|
//#endregion
|
|
171
171
|
//#region src/components/ui/input-date-field.tsx
|
|
172
|
-
const InputDateField = ({ field, disabled, onFinish, id,...props }) => {
|
|
172
|
+
const InputDateField = ({ field, disabled, onFinish, id, dateOnly,...props }) => {
|
|
173
173
|
const [inputValue, setInputValue] = useState("");
|
|
174
174
|
const handleChange = (e) => {
|
|
175
175
|
const parts = e.target.value.split("/");
|
|
@@ -182,7 +182,12 @@ const InputDateField = ({ field, disabled, onFinish, id,...props }) => {
|
|
|
182
182
|
if (newValue.length === 10) {
|
|
183
183
|
const parsedDate = parse(newValue, "dd/MM/yyyy", /* @__PURE__ */ new Date());
|
|
184
184
|
if (isValid(parsedDate)) {
|
|
185
|
-
|
|
185
|
+
if (dateOnly) {
|
|
186
|
+
const year = parsedDate.getFullYear();
|
|
187
|
+
const monthStr = String(parsedDate.getMonth() + 1).padStart(2, "0");
|
|
188
|
+
const dayStr = String(parsedDate.getDate()).padStart(2, "0");
|
|
189
|
+
field.onChange(`${year}-${monthStr}-${dayStr}`);
|
|
190
|
+
} else field.onChange(parsedDate);
|
|
186
191
|
onFinish?.();
|
|
187
192
|
}
|
|
188
193
|
}
|
|
@@ -206,14 +211,27 @@ const InputDateField = ({ field, disabled, onFinish, id,...props }) => {
|
|
|
206
211
|
|
|
207
212
|
//#endregion
|
|
208
213
|
//#region src/components/date-field/DateField.tsx
|
|
209
|
-
function DateField({ name, label, description, inputDisabled, endMonth, className, disabled, initialValue, required, help }) {
|
|
214
|
+
function DateField({ name, label, description, inputDisabled, endMonth, className, disabled, initialValue, required, help, dateOnly }) {
|
|
210
215
|
const form = useFormContext();
|
|
211
|
-
const
|
|
212
|
-
return /* @__PURE__ */ jsx(FormField, {
|
|
213
|
-
control: form.control,
|
|
214
|
-
defaultValue: initialValue,
|
|
216
|
+
const { field, fieldState } = useController({
|
|
215
217
|
name,
|
|
216
|
-
|
|
218
|
+
defaultValue: initialValue,
|
|
219
|
+
rules: { required },
|
|
220
|
+
control: form.control
|
|
221
|
+
});
|
|
222
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
223
|
+
const handleSelect = (date) => {
|
|
224
|
+
if (dateOnly && date) {
|
|
225
|
+
const year = date.getFullYear();
|
|
226
|
+
const month = String(date.getMonth() + 1).padStart(2, "0");
|
|
227
|
+
const day = String(date.getDate()).padStart(2, "0");
|
|
228
|
+
field.onChange(`${year}-${month}-${day}`);
|
|
229
|
+
} else field.onChange(date);
|
|
230
|
+
setIsOpen(false);
|
|
231
|
+
};
|
|
232
|
+
return /* @__PURE__ */ jsx(FormFieldContext.Provider, {
|
|
233
|
+
value: { name },
|
|
234
|
+
children: /* @__PURE__ */ jsxs(FormItem, {
|
|
217
235
|
className,
|
|
218
236
|
id: `date-${name.replace(".", "-")}`,
|
|
219
237
|
children: [
|
|
@@ -246,6 +264,7 @@ function DateField({ name, label, description, inputDisabled, endMonth, classNam
|
|
|
246
264
|
tabIndex: -1,
|
|
247
265
|
children: /* @__PURE__ */ jsx(InputDateField, {
|
|
248
266
|
className: cn(fieldState.error && "border-destructive"),
|
|
267
|
+
dateOnly,
|
|
249
268
|
disabled: inputDisabled,
|
|
250
269
|
field,
|
|
251
270
|
id: name,
|
|
@@ -261,10 +280,7 @@ function DateField({ name, label, description, inputDisabled, endMonth, classNam
|
|
|
261
280
|
endMonth,
|
|
262
281
|
locale: ptBR,
|
|
263
282
|
mode: "single",
|
|
264
|
-
onSelect:
|
|
265
|
-
field.onChange(date);
|
|
266
|
-
setIsOpen(false);
|
|
267
|
-
},
|
|
283
|
+
onSelect: handleSelect,
|
|
268
284
|
selected: field.value
|
|
269
285
|
}, `${name}-${field.value?.toString()}`)
|
|
270
286
|
})]
|
package/dist/date-field.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date-field.js","names":["props","className","InputDateField: React.FC<\n {\n field: ControllerRenderProps<any, string>;\n disabled?: boolean;\n onFinish?: () => void;\n id?: string;\n } & ComponentProps<typeof Input>\n>"],"sources":["../src/components/ui/calendar.tsx","../src/components/ui/input-date-field.tsx","../src/components/date-field/DateField.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\n\nimport { Button, buttonVariants } from '@/components/ui/button';\n\nimport { ChevronLeft, ChevronRight } from 'lucide-react';\n\nimport { cn } from '@/lib/utils';\nimport { differenceInCalendarDays } from 'date-fns';\nimport {\n DayPicker,\n labelNext,\n labelPrevious,\n useDayPicker,\n} from 'react-day-picker';\n\nexport type CalendarProps = React.ComponentProps<typeof DayPicker> & {\n /**\n * In the year view, the number of years to display at once.\n * @default 12\n */\n yearRange?: number;\n};\n\nfunction Calendar({\n className,\n classNames,\n showOutsideDays = true,\n yearRange = 12,\n numberOfMonths,\n ...props\n}: CalendarProps) {\n const [navView, setNavView] = React.useState<'days' | 'years'>('days');\n const [displayYears, setDisplayYears] = React.useState<{\n from: number;\n to: number;\n }>(\n React.useMemo(() => {\n const currentYear = new Date().getFullYear();\n return {\n from: currentYear - Math.floor(yearRange / 2 - 1),\n to: currentYear + Math.ceil(yearRange / 2),\n };\n }, [yearRange])\n );\n\n const { onNextClick, onPrevClick, startMonth, endMonth } = props;\n\n const columnsDisplayed = navView === 'years' ? 1 : numberOfMonths;\n\n return (\n <DayPicker\n className={cn('p-3', className)}\n classNames={{\n months: 'flex flex-col relative sm:flex-row gap-y-4 sm:gap-y-0',\n month_caption: 'flex justify-center h-7 mx-10 relative items-center',\n weekdays: 'flex flex-row',\n weekday: 'text-muted-foreground w-8 font-normal text-[0.8rem]',\n month: 'gap-y-4 overflow-x-hidden w-full',\n caption: 'flex justify-center pt-1 relative items-center',\n caption_label: 'text-sm font-medium truncate',\n button_next: cn(\n buttonVariants({\n variant: 'outline',\n className:\n 'absolute right-0 h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100',\n })\n ),\n button_previous: cn(\n buttonVariants({\n variant: 'outline',\n className:\n 'absolute left-0 h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100',\n })\n ),\n nav: 'flex items-start',\n month_grid: 'mt-4',\n week: 'flex w-full mt-1',\n day: 'p-0 transition-colors size-8 text-sm flex-1 flex items-center justify-center has-[button]:hover:bg-accent/90! rounded-md has-[button]:hover:aria-selected:bg-primary/50! has-[button]:hover:text-foreground has-[button]:hover:aria-selected:text-foreground',\n day_button: cn(\n buttonVariants({ variant: 'ghost' }),\n 'size-8 p-0 font-normal transition-none hover:bg-transparent hover:text-inherit aria-selected:opacity-100'\n ),\n range_start: 'day-range-start rounded-s-md',\n range_end: 'day-range-end rounded-e-md',\n selected:\n 'bg-primary text-primary-foreground hover:bg-primary! hover:text-primary-foreground focus:bg-primary! focus:text-primary-foreground',\n today: 'bg-accent text-accent-foreground',\n outside:\n 'day-outside text-muted-foreground opacity-50 aria-selected:bg-accent/50 aria-selected:text-muted-foreground aria-selected:opacity-30',\n disabled: 'text-muted-foreground opacity-50',\n range_middle:\n 'aria-selected:bg-accent hover:aria-selected:bg-accent! rounded-none aria-selected:text-accent-foreground hover:aria-selected:text-accent-foreground',\n hidden: 'invisible',\n ...classNames,\n }}\n components={{\n Chevron: ({ orientation }) => {\n const Icon = orientation === 'left' ? ChevronLeft : ChevronRight;\n return <Icon className=\"h-4 w-4\" />;\n },\n Nav: ({ className, children, ...props }) => {\n const { nextMonth, previousMonth, goToMonth } = useDayPicker();\n\n const isPreviousDisabled = (() => {\n if (navView === 'years') {\n return (\n (startMonth &&\n differenceInCalendarDays(\n new Date(displayYears.from - 1, 0, 1),\n startMonth\n ) < 0) ||\n (endMonth &&\n differenceInCalendarDays(\n new Date(displayYears.from - 1, 0, 1),\n endMonth\n ) > 0)\n );\n }\n return !previousMonth;\n })();\n\n const isNextDisabled = (() => {\n if (navView === 'years') {\n return (\n (startMonth &&\n differenceInCalendarDays(\n new Date(displayYears.to + 1, 0, 1),\n startMonth\n ) < 0) ||\n (endMonth &&\n differenceInCalendarDays(\n new Date(displayYears.to + 1, 0, 1),\n endMonth\n ) > 0)\n );\n }\n return !nextMonth;\n })();\n\n const handlePreviousClick = React.useCallback(() => {\n if (!previousMonth) return;\n if (navView === 'years') {\n setDisplayYears((prev) => ({\n from: prev.from - (prev.to - prev.from + 1),\n to: prev.to - (prev.to - prev.from + 1),\n }));\n onPrevClick?.(\n new Date(\n displayYears.from - (displayYears.to - displayYears.from),\n 0,\n 1\n )\n );\n return;\n }\n goToMonth(previousMonth);\n onPrevClick?.(previousMonth);\n }, [previousMonth, goToMonth]);\n\n const handleNextClick = React.useCallback(() => {\n if (navView === 'years') {\n setDisplayYears((prev) => ({\n from: prev.from + (prev.to - prev.from + 1),\n to: prev.to + (prev.to - prev.from + 1),\n }));\n onNextClick?.(\n new Date(\n displayYears.from + (displayYears.to - displayYears.from),\n 0,\n 1\n )\n );\n return;\n }\n if (!nextMonth) return;\n goToMonth(nextMonth);\n onNextClick?.(nextMonth);\n }, [goToMonth, nextMonth]);\n\n return (\n <nav className={cn('flex items-center', className)}>\n <Button\n aria-label={\n navView === 'years'\n ? `Go to the previous ${\n displayYears.to - displayYears.from + 1\n } years`\n : labelPrevious(previousMonth)\n }\n className=\"absolute left-0 h-7 w-7 bg-transparent p-0 opacity-80 hover:opacity-100\"\n disabled={isPreviousDisabled}\n onClick={handlePreviousClick}\n tabIndex={isPreviousDisabled ? undefined : -1}\n type=\"button\"\n variant=\"outline\"\n >\n <ChevronLeft className=\"h-4 w-4\" />\n </Button>\n\n <Button\n aria-label={\n navView === 'years'\n ? `Go to the next ${\n displayYears.to - displayYears.from + 1\n } years`\n : labelNext(nextMonth)\n }\n className=\"absolute right-0 h-7 w-7 bg-transparent p-0 opacity-80 hover:opacity-100\"\n disabled={isNextDisabled}\n onClick={handleNextClick}\n tabIndex={isNextDisabled ? undefined : -1}\n type=\"button\"\n variant=\"outline\"\n >\n <ChevronRight className=\"h-4 w-4\" />\n </Button>\n </nav>\n );\n },\n CaptionLabel: ({ children }) => (\n <Button\n className=\"h-7 w-full truncate text-sm font-medium capitalize\"\n onClick={() =>\n setNavView((prev) => (prev === 'days' ? 'years' : 'days'))\n }\n size=\"sm\"\n variant=\"ghost\"\n >\n {navView === 'days'\n ? children\n : displayYears.from + ' - ' + displayYears.to}\n </Button>\n ),\n MonthGrid: ({ className, children, ...props }) => {\n const { goToMonth } = useDayPicker();\n if (navView === 'years') {\n return (\n <div\n className={cn('grid grid-cols-4 gap-y-1', className)}\n {...props}\n >\n {Array.from(\n { length: displayYears.to - displayYears.from + 1 },\n (_, i) => {\n const isBefore =\n differenceInCalendarDays(\n new Date(displayYears.from + i, 12, 31),\n startMonth!\n ) < 0;\n\n const isAfter =\n differenceInCalendarDays(\n new Date(displayYears.from + i, 0, 0),\n endMonth!\n ) > 0;\n\n const isDisabled = isBefore || isAfter;\n return (\n <Button\n className={cn(\n 'h-10 w-full text-sm font-normal text-foreground',\n displayYears.from + i === new Date().getFullYear() &&\n 'bg-accent font-medium text-accent-foreground'\n )}\n disabled={navView === 'years' ? isDisabled : undefined}\n key={i}\n onClick={() => {\n setNavView('days');\n goToMonth(\n new Date(\n displayYears.from + i,\n new Date().getMonth()\n )\n );\n }}\n variant=\"ghost\"\n >\n {displayYears.from + i}\n </Button>\n );\n }\n )}\n </div>\n );\n }\n return (\n <table className={className} {...props}>\n {children}\n </table>\n );\n },\n }}\n numberOfMonths={columnsDisplayed}\n showOutsideDays={showOutsideDays}\n style={{\n width: 248.8 * (columnsDisplayed ?? 1) + 'px',\n }}\n {...props}\n />\n );\n}\nCalendar.displayName = 'Calendar';\n\nexport { Calendar };\n","import { ComponentProps, useEffect, useState } from 'react';\n\nimport type { ControllerRenderProps } from 'react-hook-form';\nimport withMask from '@/hooks/with-mask';\n\nimport { isValid, parse } from 'date-fns';\nimport { Input } from './input';\n\nconst InputDateField: React.FC<\n {\n field: ControllerRenderProps<any, string>;\n disabled?: boolean;\n onFinish?: () => void;\n id?: string;\n } & ComponentProps<typeof Input>\n> = ({ field, disabled, onFinish, id, ...props }) => {\n const [inputValue, setInputValue] = useState('');\n\n const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const parts = e.target.value.split('/');\n let day = parts[0];\n let month = parts[1];\n if (day && Number(day) > 31) {\n parts[0] = day.slice(0, 1).padStart(2, '0');\n }\n if (month && Number(month) > 12) {\n parts[1] = month.slice(0, 1).padStart(2, '0');\n }\n\n const newValue = parts.join('/');\n setInputValue(parts.join('/'));\n\n if (newValue.length === 10) {\n const parsedDate = parse(newValue, 'dd/MM/yyyy', new Date());\n if (isValid(parsedDate)) {\n field.onChange(parsedDate);\n onFinish?.();\n }\n }\n };\n\n useEffect(() => {\n if (field.value) {\n const value =\n typeof field?.value === 'string'\n ? new Date(field?.value)\n : field?.value;\n setInputValue(value?.toLocaleDateString('pt-BR'));\n } else {\n setInputValue('');\n }\n }, [field.value]);\n\n return (\n <Input\n autoComplete=\"off\"\n className=\"w-full outline-hidden\"\n id={id}\n onChange={handleChange}\n placeholder=\"Selecione a data\"\n readOnly={disabled}\n ref={\n withMask('99/99/9999', {\n undoOnEscape: false,\n }) as any\n }\n value={inputValue}\n {...props}\n />\n );\n};\n\nexport { InputDateField };\n","'use client';\n\nimport { useState } from 'react';\n\nimport {\n type FieldPath,\n type FieldValues,\n type UseControllerProps,\n useFormContext,\n} from 'react-hook-form';\n\nimport { Calendar } from '@/ui/calendar';\nimport {\n FormDescription,\n FormField,\n FormItem,\n FormLabel,\n FormMessage,\n} from '@/ui/form';\nimport { InputDateField } from '@/ui/input-date-field';\nimport { InputHelp } from '@/ui/input-help';\nimport { Popover, PopoverContent, PopoverTrigger } from '@/ui/popover';\n\nimport { cn } from '@/lib/utils';\nimport { ptBR } from 'date-fns/locale';\nimport type { Matcher } from 'react-day-picker';\n\nexport interface DateFieldProps<\n TFieldValues extends FieldValues = FieldValues,\n TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n> extends Omit<UseControllerProps<TFieldValues, TFieldName>, 'disabled'> {\n label: string;\n description?: string;\n placeholder?: string;\n className?: string;\n disabled?: Matcher | Matcher[] | undefined;\n inputDisabled?: boolean;\n initialValue?: Date;\n endMonth?: Date;\n required?: boolean;\n help?: string;\n}\n\nfunction DateField<\n TFieldValues extends FieldValues = FieldValues,\n TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n>({\n name,\n label,\n description,\n inputDisabled,\n endMonth,\n className,\n disabled,\n initialValue,\n required,\n help,\n}: DateFieldProps<TFieldValues, TFieldName>) {\n const form = useFormContext();\n const [isOpen, setIsOpen] = useState(false);\n\n return (\n <FormField\n control={form.control}\n defaultValue={initialValue as any}\n name={name}\n render={({ field, fieldState }) => (\n <FormItem className={className} id={`date-${name.replace('.', '-')}`}>\n <div className=\"flex items-end gap-1.5\">\n <FormLabel htmlFor={name}>\n {label}:\n {required && (\n <span className=\"text-red-500 text-lg leading-[1px]\">*</span>\n )}\n </FormLabel>\n\n <InputHelp help={help} name={name} />\n </div>\n\n <Popover onOpenChange={setIsOpen} open={!inputDisabled && isOpen}>\n <PopoverTrigger\n className=\"w-full mt-0! outline-hidden\"\n onClick={(event) => {\n event.preventDefault();\n event.stopPropagation();\n }}\n tabIndex={-1}\n >\n <InputDateField\n className={cn(fieldState.error && 'border-destructive')}\n disabled={inputDisabled}\n field={field}\n id={name}\n onFinish={() => setIsOpen(false)}\n onFocus={() => setIsOpen(true)}\n />\n </PopoverTrigger>\n <PopoverContent\n className=\"flex justify-center w-fit p-0\"\n onOpenAutoFocus={(e) => e.preventDefault()}\n >\n <Calendar\n defaultMonth={field.value || new Date()}\n disabled={disabled}\n endMonth={endMonth}\n key={`${name}-${field.value?.toString()}`}\n locale={ptBR}\n mode=\"single\"\n onSelect={(date) => {\n field.onChange(date);\n setIsOpen(false);\n }}\n selected={field.value}\n />\n </PopoverContent>\n </Popover>\n\n <FormDescription>{description}</FormDescription>\n {fieldState.error && <FormMessage />}\n </FormItem>\n )}\n />\n );\n}\n\nexport { DateField };\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAyBA,SAAS,SAAS,EAChB,WACA,YACA,kBAAkB,MAClB,YAAY,IACZ,eACA,GAAG,SACa;CAChB,MAAM,CAAC,SAAS,cAAc,MAAM,SAA2B,OAAO;CACtE,MAAM,C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,QAAQ,KAAK,IAAI;;IAChE,qBAAC;KAAI,WAAU;gBACb,qBAAC;MAAU,SAAS;;OACjB;OAAM;OACN,YACC,oBAAC;QAAK,WAAU;kBAAqC;SAAQ;;OAErD,EAEZ,oBAAC;MAAgB;MAAY;OAAQ;MACjC;IAEN,qBAAC;KAAQ,cAAc;KAAW,MAAM,CAAC,iBAAiB;gBACxD,oBAAC;MACC,WAAU;MACV,UAAU,UAAU;AAClB,aAAM,gBAAgB;AACtB,aAAM,iBAAiB;;MAEzB,UAAU;gBAEV,oBAAC;OACC,WAAW,GAAG,WAAW,SAAS,qBAAqB;OACvD,UAAU;OACH;OACP,IAAI;OACJ,gBAAgB,UAAU,MAAM;OAChC,eAAe,UAAU,KAAK;QAC9B;OACa,EACjB,oBAAC;MACC,WAAU;MACV,kBAAkB,MAAM,EAAE,gBAAgB;gBAE1C,oBAAC;OACC,cAAc,MAAM,yBAAS,IAAI,MAAM;OAC7B;OACA;OAEV,QAAQ;OACR,MAAK;OACL,WAAW,SAAS;AAClB,cAAM,SAAS,KAAK;AACpB,kBAAU,MAAM;;OAElB,UAAU,MAAM;SAPX,GAAG,KAAK,GAAG,MAAM,OAAO,UAAU,GAQvC;OACa;MACT;IAEV,oBAAC,6BAAiB,cAA8B;IAC/C,WAAW,SAAS,oBAAC,gBAAc;;IAC3B;GAEb"}
|
|
1
|
+
{"version":3,"file":"date-field.js","names":["props","className","InputDateField: React.FC<\n {\n field: ControllerRenderProps<any, string>;\n disabled?: boolean;\n onFinish?: () => void;\n id?: string;\n dateOnly?: boolean;\n } & ComponentProps<typeof Input>\n>"],"sources":["../src/components/ui/calendar.tsx","../src/components/ui/input-date-field.tsx","../src/components/date-field/DateField.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\n\nimport { Button, buttonVariants } from '@/components/ui/button';\n\nimport { ChevronLeft, ChevronRight } from 'lucide-react';\n\nimport { cn } from '@/lib/utils';\nimport { differenceInCalendarDays } from 'date-fns';\nimport {\n DayPicker,\n labelNext,\n labelPrevious,\n useDayPicker,\n} from 'react-day-picker';\n\nexport type CalendarProps = React.ComponentProps<typeof DayPicker> & {\n /**\n * In the year view, the number of years to display at once.\n * @default 12\n */\n yearRange?: number;\n};\n\nfunction Calendar({\n className,\n classNames,\n showOutsideDays = true,\n yearRange = 12,\n numberOfMonths,\n ...props\n}: CalendarProps) {\n const [navView, setNavView] = React.useState<'days' | 'years'>('days');\n const [displayYears, setDisplayYears] = React.useState<{\n from: number;\n to: number;\n }>(\n React.useMemo(() => {\n const currentYear = new Date().getFullYear();\n return {\n from: currentYear - Math.floor(yearRange / 2 - 1),\n to: currentYear + Math.ceil(yearRange / 2),\n };\n }, [yearRange])\n );\n\n const { onNextClick, onPrevClick, startMonth, endMonth } = props;\n\n const columnsDisplayed = navView === 'years' ? 1 : numberOfMonths;\n\n return (\n <DayPicker\n className={cn('p-3', className)}\n classNames={{\n months: 'flex flex-col relative sm:flex-row gap-y-4 sm:gap-y-0',\n month_caption: 'flex justify-center h-7 mx-10 relative items-center',\n weekdays: 'flex flex-row',\n weekday: 'text-muted-foreground w-8 font-normal text-[0.8rem]',\n month: 'gap-y-4 overflow-x-hidden w-full',\n caption: 'flex justify-center pt-1 relative items-center',\n caption_label: 'text-sm font-medium truncate',\n button_next: cn(\n buttonVariants({\n variant: 'outline',\n className:\n 'absolute right-0 h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100',\n })\n ),\n button_previous: cn(\n buttonVariants({\n variant: 'outline',\n className:\n 'absolute left-0 h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100',\n })\n ),\n nav: 'flex items-start',\n month_grid: 'mt-4',\n week: 'flex w-full mt-1',\n day: 'p-0 transition-colors size-8 text-sm flex-1 flex items-center justify-center has-[button]:hover:bg-accent/90! rounded-md has-[button]:hover:aria-selected:bg-primary/50! has-[button]:hover:text-foreground has-[button]:hover:aria-selected:text-foreground',\n day_button: cn(\n buttonVariants({ variant: 'ghost' }),\n 'size-8 p-0 font-normal transition-none hover:bg-transparent hover:text-inherit aria-selected:opacity-100'\n ),\n range_start: 'day-range-start rounded-s-md',\n range_end: 'day-range-end rounded-e-md',\n selected:\n 'bg-primary text-primary-foreground hover:bg-primary! hover:text-primary-foreground focus:bg-primary! focus:text-primary-foreground',\n today: 'bg-accent text-accent-foreground',\n outside:\n 'day-outside text-muted-foreground opacity-50 aria-selected:bg-accent/50 aria-selected:text-muted-foreground aria-selected:opacity-30',\n disabled: 'text-muted-foreground opacity-50',\n range_middle:\n 'aria-selected:bg-accent hover:aria-selected:bg-accent! rounded-none aria-selected:text-accent-foreground hover:aria-selected:text-accent-foreground',\n hidden: 'invisible',\n ...classNames,\n }}\n components={{\n Chevron: ({ orientation }) => {\n const Icon = orientation === 'left' ? ChevronLeft : ChevronRight;\n return <Icon className=\"h-4 w-4\" />;\n },\n Nav: ({ className, children, ...props }) => {\n const { nextMonth, previousMonth, goToMonth } = useDayPicker();\n\n const isPreviousDisabled = (() => {\n if (navView === 'years') {\n return (\n (startMonth &&\n differenceInCalendarDays(\n new Date(displayYears.from - 1, 0, 1),\n startMonth\n ) < 0) ||\n (endMonth &&\n differenceInCalendarDays(\n new Date(displayYears.from - 1, 0, 1),\n endMonth\n ) > 0)\n );\n }\n return !previousMonth;\n })();\n\n const isNextDisabled = (() => {\n if (navView === 'years') {\n return (\n (startMonth &&\n differenceInCalendarDays(\n new Date(displayYears.to + 1, 0, 1),\n startMonth\n ) < 0) ||\n (endMonth &&\n differenceInCalendarDays(\n new Date(displayYears.to + 1, 0, 1),\n endMonth\n ) > 0)\n );\n }\n return !nextMonth;\n })();\n\n const handlePreviousClick = React.useCallback(() => {\n if (!previousMonth) return;\n if (navView === 'years') {\n setDisplayYears((prev) => ({\n from: prev.from - (prev.to - prev.from + 1),\n to: prev.to - (prev.to - prev.from + 1),\n }));\n onPrevClick?.(\n new Date(\n displayYears.from - (displayYears.to - displayYears.from),\n 0,\n 1\n )\n );\n return;\n }\n goToMonth(previousMonth);\n onPrevClick?.(previousMonth);\n }, [previousMonth, goToMonth]);\n\n const handleNextClick = React.useCallback(() => {\n if (navView === 'years') {\n setDisplayYears((prev) => ({\n from: prev.from + (prev.to - prev.from + 1),\n to: prev.to + (prev.to - prev.from + 1),\n }));\n onNextClick?.(\n new Date(\n displayYears.from + (displayYears.to - displayYears.from),\n 0,\n 1\n )\n );\n return;\n }\n if (!nextMonth) return;\n goToMonth(nextMonth);\n onNextClick?.(nextMonth);\n }, [goToMonth, nextMonth]);\n\n return (\n <nav className={cn('flex items-center', className)}>\n <Button\n aria-label={\n navView === 'years'\n ? `Go to the previous ${\n displayYears.to - displayYears.from + 1\n } years`\n : labelPrevious(previousMonth)\n }\n className=\"absolute left-0 h-7 w-7 bg-transparent p-0 opacity-80 hover:opacity-100\"\n disabled={isPreviousDisabled}\n onClick={handlePreviousClick}\n tabIndex={isPreviousDisabled ? undefined : -1}\n type=\"button\"\n variant=\"outline\"\n >\n <ChevronLeft className=\"h-4 w-4\" />\n </Button>\n\n <Button\n aria-label={\n navView === 'years'\n ? `Go to the next ${\n displayYears.to - displayYears.from + 1\n } years`\n : labelNext(nextMonth)\n }\n className=\"absolute right-0 h-7 w-7 bg-transparent p-0 opacity-80 hover:opacity-100\"\n disabled={isNextDisabled}\n onClick={handleNextClick}\n tabIndex={isNextDisabled ? undefined : -1}\n type=\"button\"\n variant=\"outline\"\n >\n <ChevronRight className=\"h-4 w-4\" />\n </Button>\n </nav>\n );\n },\n CaptionLabel: ({ children }) => (\n <Button\n className=\"h-7 w-full truncate text-sm font-medium capitalize\"\n onClick={() =>\n setNavView((prev) => (prev === 'days' ? 'years' : 'days'))\n }\n size=\"sm\"\n variant=\"ghost\"\n >\n {navView === 'days'\n ? children\n : displayYears.from + ' - ' + displayYears.to}\n </Button>\n ),\n MonthGrid: ({ className, children, ...props }) => {\n const { goToMonth } = useDayPicker();\n if (navView === 'years') {\n return (\n <div\n className={cn('grid grid-cols-4 gap-y-1', className)}\n {...props}\n >\n {Array.from(\n { length: displayYears.to - displayYears.from + 1 },\n (_, i) => {\n const isBefore =\n differenceInCalendarDays(\n new Date(displayYears.from + i, 12, 31),\n startMonth!\n ) < 0;\n\n const isAfter =\n differenceInCalendarDays(\n new Date(displayYears.from + i, 0, 0),\n endMonth!\n ) > 0;\n\n const isDisabled = isBefore || isAfter;\n return (\n <Button\n className={cn(\n 'h-10 w-full text-sm font-normal text-foreground',\n displayYears.from + i === new Date().getFullYear() &&\n 'bg-accent font-medium text-accent-foreground'\n )}\n disabled={navView === 'years' ? isDisabled : undefined}\n key={i}\n onClick={() => {\n setNavView('days');\n goToMonth(\n new Date(\n displayYears.from + i,\n new Date().getMonth()\n )\n );\n }}\n variant=\"ghost\"\n >\n {displayYears.from + i}\n </Button>\n );\n }\n )}\n </div>\n );\n }\n return (\n <table className={className} {...props}>\n {children}\n </table>\n );\n },\n }}\n numberOfMonths={columnsDisplayed}\n showOutsideDays={showOutsideDays}\n style={{\n width: 248.8 * (columnsDisplayed ?? 1) + 'px',\n }}\n {...props}\n />\n );\n}\nCalendar.displayName = 'Calendar';\n\nexport { Calendar };\n","import { ComponentProps, useEffect, useState } from 'react';\n\nimport type { ControllerRenderProps } from 'react-hook-form';\nimport withMask from '@/hooks/with-mask';\n\nimport { isValid, parse } from 'date-fns';\nimport { Input } from './input';\n\nconst InputDateField: React.FC<\n {\n field: ControllerRenderProps<any, string>;\n disabled?: boolean;\n onFinish?: () => void;\n id?: string;\n dateOnly?: boolean;\n } & ComponentProps<typeof Input>\n> = ({ field, disabled, onFinish, id, dateOnly, ...props }) => {\n const [inputValue, setInputValue] = useState('');\n\n const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const parts = e.target.value.split('/');\n let day = parts[0];\n let month = parts[1];\n if (day && Number(day) > 31) {\n parts[0] = day.slice(0, 1).padStart(2, '0');\n }\n if (month && Number(month) > 12) {\n parts[1] = month.slice(0, 1).padStart(2, '0');\n }\n\n const newValue = parts.join('/');\n setInputValue(parts.join('/'));\n\n if (newValue.length === 10) {\n const parsedDate = parse(newValue, 'dd/MM/yyyy', new Date());\n if (isValid(parsedDate)) {\n if (dateOnly) {\n const year = parsedDate.getFullYear();\n const monthStr = String(parsedDate.getMonth() + 1).padStart(2, '0');\n const dayStr = String(parsedDate.getDate()).padStart(2, '0');\n field.onChange(`${year}-${monthStr}-${dayStr}`);\n } else {\n field.onChange(parsedDate);\n }\n onFinish?.();\n }\n }\n };\n\n useEffect(() => {\n if (field.value) {\n const value =\n typeof field?.value === 'string'\n ? new Date(field?.value)\n : field?.value;\n setInputValue(value?.toLocaleDateString('pt-BR'));\n } else {\n setInputValue('');\n }\n }, [field.value]);\n\n return (\n <Input\n autoComplete=\"off\"\n className=\"w-full outline-hidden\"\n id={id}\n onChange={handleChange}\n placeholder=\"Selecione a data\"\n readOnly={disabled}\n ref={\n withMask('99/99/9999', {\n undoOnEscape: false,\n }) as any\n }\n value={inputValue}\n {...props}\n />\n );\n};\n\nexport { InputDateField };\n","'use client';\n\nimport { useState } from 'react';\n\nimport {\n type FieldPath,\n type FieldValues,\n type UseControllerProps,\n useController,\n useFormContext,\n} from 'react-hook-form';\n\nimport { Calendar } from '@/ui/calendar';\nimport {\n FormDescription,\n FormField,\n FormFieldContext,\n FormItem,\n FormLabel,\n FormMessage,\n} from '@/ui/form';\nimport { InputDateField } from '@/ui/input-date-field';\nimport { InputHelp } from '@/ui/input-help';\nimport { Popover, PopoverContent, PopoverTrigger } from '@/ui/popover';\n\nimport { cn } from '@/lib/utils';\nimport { ptBR } from 'date-fns/locale';\nimport type { Matcher } from 'react-day-picker';\n\nexport interface DateFieldProps<\n TFieldValues extends FieldValues = FieldValues,\n TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n> extends Omit<UseControllerProps<TFieldValues, TFieldName>, 'disabled'> {\n label: string;\n description?: string;\n placeholder?: string;\n className?: string;\n disabled?: Matcher | Matcher[] | undefined;\n inputDisabled?: boolean;\n initialValue?: Date;\n endMonth?: Date;\n required?: boolean;\n help?: string;\n /** Quando true, o valor será formatado como string YYYY-MM-DD ao invés de Date com horário */\n dateOnly?: boolean;\n}\n\nfunction DateField<\n TFieldValues extends FieldValues = FieldValues,\n TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n>({\n name,\n label,\n description,\n inputDisabled,\n endMonth,\n className,\n disabled,\n initialValue,\n required,\n help,\n dateOnly,\n}: DateFieldProps<TFieldValues, TFieldName>) {\n const form = useFormContext();\n const { field, fieldState } = useController({\n name,\n defaultValue: initialValue as any,\n rules: { required },\n control: form.control,\n });\n\n const [isOpen, setIsOpen] = useState(false);\n const handleSelect = (date: Date | undefined) => {\n if (dateOnly && date) {\n const year = date.getFullYear();\n const month = String(date.getMonth() + 1).padStart(2, '0');\n const day = String(date.getDate()).padStart(2, '0');\n field.onChange(`${year}-${month}-${day}`);\n } else {\n field.onChange(date);\n }\n setIsOpen(false);\n };\n\n return (\n <FormFieldContext.Provider value={{ name }}>\n <FormItem className={className} id={`date-${name.replace('.', '-')}`}>\n <div className=\"flex items-end gap-1.5\">\n <FormLabel htmlFor={name}>\n {label}:\n {required && (\n <span className=\"text-red-500 text-lg leading-[1px]\">*</span>\n )}\n </FormLabel>\n\n <InputHelp help={help} name={name} />\n </div>\n\n <Popover onOpenChange={setIsOpen} open={!inputDisabled && isOpen}>\n <PopoverTrigger\n className=\"w-full mt-0! outline-hidden\"\n onClick={(event) => {\n event.preventDefault();\n event.stopPropagation();\n }}\n tabIndex={-1}\n >\n <InputDateField\n className={cn(fieldState.error && 'border-destructive')}\n dateOnly={dateOnly}\n disabled={inputDisabled}\n field={field}\n id={name}\n onFinish={() => setIsOpen(false)}\n onFocus={() => setIsOpen(true)}\n />\n </PopoverTrigger>\n <PopoverContent\n className=\"flex justify-center w-fit p-0\"\n onOpenAutoFocus={(e) => e.preventDefault()}\n >\n <Calendar\n defaultMonth={field.value || new Date()}\n disabled={disabled}\n endMonth={endMonth}\n key={`${name}-${field.value?.toString()}`}\n locale={ptBR}\n mode=\"single\"\n onSelect={handleSelect}\n selected={field.value}\n />\n </PopoverContent>\n </Popover>\n\n <FormDescription>{description}</FormDescription>\n {fieldState.error && <FormMessage />}\n </FormItem>\n </FormFieldContext.Provider>\n );\n}\n\nexport { DateField };\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAyBA,SAAS,SAAS,EAChB,WACA,YACA,kBAAkB,MAClB,YAAY,IACZ,eACA,GAAG,SACa;CAChB,MAAM,CAAC,SAAS,cAAc,MAAM,SAA2B,OAAO;CACtE,MAAM,CAAC,cAAc,mBAAmB,MAAM,SAI5C,MAAM,cAAc;EAClB,MAAM,+BAAc,IAAI,MAAM,EAAC,aAAa;AAC5C,SAAO;GACL,MAAM,cAAc,KAAK,MAAM,YAAY,IAAI,EAAE;GACjD,IAAI,cAAc,KAAK,KAAK,YAAY,EAAE;GAC3C;IACA,CAAC,UAAU,CAAC,CAChB;CAED,MAAM,EAAE,aAAa,aAAa,YAAY,aAAa;CAE3D,MAAM,mBAAmB,YAAY,UAAU,IAAI;AAEnD,QACE,oBAAC;EACC,WAAW,GAAG,OAAO,UAAU;EAC/B,YAAY;GACV,QAAQ;GACR,eAAe;GACf,UAAU;GACV,SAAS;GACT,OAAO;GACP,SAAS;GACT,eAAe;GACf,aAAa,GACX,eAAe;IACb,SAAS;IACT,WACE;IACH,CAAC,CACH;GACD,iBAAiB,GACf,eAAe;IACb,SAAS;IACT,WACE;IACH,CAAC,CACH;GACD,KAAK;GACL,YAAY;GACZ,MAAM;GACN,KAAK;GACL,YAAY,GACV,eAAe,EAAE,SAAS,SAAS,CAAC,EACpC,2GACD;GACD,aAAa;GACb,WAAW;GACX,UACE;GACF,OAAO;GACP,SACE;GACF,UAAU;GACV,cACE;GACF,QAAQ;GACR,GAAG;GACJ;EACD,YAAY;GACV,UAAU,EAAE,kBAAkB;AAE5B,WAAO,oBADM,gBAAgB,SAAS,cAAc,gBACvC,WAAU,YAAY;;GAErC,MAAM,EAAE,wBAAW,SAAU,GAAGA,cAAY;IAC1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,WAAU;MACV,UAAU,UAAU;AAClB,aAAM,gBAAgB;AACtB,aAAM,iBAAiB;;MAEzB,UAAU;gBAEV,oBAAC;OACC,WAAW,GAAG,WAAW,SAAS,qBAAqB;OAC7C;OACV,UAAU;OACH;OACP,IAAI;OACJ,gBAAgB,UAAU,MAAM;OAChC,eAAe,UAAU,KAAK;QAC9B;OACa,EACjB,oBAAC;MACC,WAAU;MACV,kBAAkB,MAAM,EAAE,gBAAgB;gBAE1C,oBAAC;OACC,cAAc,MAAM,yBAAS,IAAI,MAAM;OAC7B;OACA;OAEV,QAAQ;OACR,MAAK;OACL,UAAU;OACV,UAAU,MAAM;SAJX,GAAG,KAAK,GAAG,MAAM,OAAO,UAAU,GAKvC;OACa;MACT;IAEV,oBAAC,6BAAiB,cAA8B;IAC/C,WAAW,SAAS,oBAAC,gBAAc;;IAC3B;GACe"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as cn } from "./utils-C8_amEgK.js";
|
|
2
2
|
import { t as Label } from "./label-Bkg7B2j8.js";
|
|
3
|
-
import {
|
|
3
|
+
import { useFormContext, useFormState } from "react-hook-form";
|
|
4
4
|
import * as React from "react";
|
|
5
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
import { Info } from "lucide-react";
|
|
@@ -16,12 +16,6 @@ const useFormContextSubmit = () => {
|
|
|
16
16
|
if (!context) return {};
|
|
17
17
|
return context;
|
|
18
18
|
};
|
|
19
|
-
const FormField = ({ ...props }) => {
|
|
20
|
-
return /* @__PURE__ */ jsx(FormFieldContext.Provider, {
|
|
21
|
-
value: { name: props.name },
|
|
22
|
-
children: /* @__PURE__ */ jsx(Controller, { ...props })
|
|
23
|
-
});
|
|
24
|
-
};
|
|
25
19
|
const useFormField = () => {
|
|
26
20
|
const fieldContext = React.useContext(FormFieldContext);
|
|
27
21
|
const itemContext = React.useContext(FormItemContext);
|
|
@@ -151,5 +145,5 @@ const InputHelp = ({ help, name, className }) => {
|
|
|
151
145
|
};
|
|
152
146
|
|
|
153
147
|
//#endregion
|
|
154
|
-
export { FormLabel as a, FormItem as i, FormDescription as n, FormMessage as o,
|
|
155
|
-
//# sourceMappingURL=input-help-
|
|
148
|
+
export { FormLabel as a, FormItem as i, FormDescription as n, FormMessage as o, FormFieldContext as r, InputHelp as t };
|
|
149
|
+
//# sourceMappingURL=input-help-D1JqF0YH.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input-help-D1JqF0YH.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\nexport const 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('mb-0.5 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,MAAa,mBAAmB,MAAM,cACpC,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;;AA6BT,MAAM,qBAAqB;CACzB,MAAM,eAAe,MAAM,WAAW,iBAAiB;CACvD,MAAM,cAAc,MAAM,WAAW,gBAAgB;CACrD,MAAM,EAAE,kBAAkB,gBAAgB;CAC1C,MAAM,YAAY,aAAa,EAAE,MAAM,aAAa,MAAM,CAAC;CAC3D,MAAM,aAAa,cAAc,aAAa,MAAM,UAAU;AAE9D,KAAI,CAAC,aACH,OAAM,IAAI,MAAM,iDAAiD;CAGnE,MAAM,EAAE,OAAO;AAEf,QAAO;EACL;EACA,MAAM,aAAa;EACnB,YAAY,GAAG,GAAG;EAClB,mBAAmB,GAAG,GAAG;EACzB,eAAe,GAAG,GAAG;EACrB,GAAG;EACJ;;AAOH,MAAM,kBAAkB,MAAM,cAC5B,EAAE,CACH;AAED,SAAS,SAAS,EAAE,UAAW,GAAG,SAAsC;CACtE,MAAM,KAAK,MAAM,OAAO;AAExB,QACE,oBAAC,gBAAgB;EAAS,OAAO,EAAE,IAAI;YACrC,oBAAC;GACC,WAAW,GAAG,uBAAuB,UAAU;GAC/C,aAAU;GACV,GAAI;IACJ;GACuB;;AAI/B,SAAS,UAAU,EACjB,UACA,GAAG,SACgD;CACnD,MAAM,EAAE,OAAO,eAAe,cAAc;AAE5C,QACE,oBAAC;EACC,WAAW,GAAG,sCAAsC,UAAU;EAC9D,cAAY,CAAC,CAAC;EACd,aAAU;EACV,SAAS;EACT,GAAI;GACJ;;AAuBN,SAAS,gBAAgB,EAAE,UAAW,GAAG,SAAoC;CAC3E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J,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,6CAA6C,UAAU;GACrE,MAAK;aAEL,oBAAC,QAAK,WAAU,aAAa;IACtB;GACG"}
|
package/dist/input-suggest.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { n as Options, t as Mask } from "./with-mask-Chm8kVE1.js";
|
|
2
2
|
import { FieldPath, FieldValues, UseControllerProps } from "react-hook-form";
|
|
3
3
|
import { Dispatch, SetStateAction } from "react";
|
|
4
|
-
import * as
|
|
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
|
|
@@ -71,7 +71,7 @@ declare function InputSuggest<TFieldValues extends FieldValues = FieldValues, TF
|
|
|
71
71
|
debounceTime,
|
|
72
72
|
maxWait,
|
|
73
73
|
...props
|
|
74
|
-
}: InputSuggestProps<TFieldValues, TFieldName> & PopoverProps):
|
|
74
|
+
}: InputSuggestProps<TFieldValues, TFieldName> & PopoverProps): react_jsx_runtime7.JSX.Element;
|
|
75
75
|
//#endregion
|
|
76
76
|
export { InputSuggest, type InputSuggestProps };
|
|
77
77
|
//# sourceMappingURL=input-suggest.d.ts.map
|
package/dist/input-suggest.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { t as cn } from "./utils-C8_amEgK.js";
|
|
5
5
|
import "./label-Bkg7B2j8.js";
|
|
6
6
|
import { n as withMask, t as Input } from "./input-Bs61WBGW.js";
|
|
7
|
-
import { a as FormLabel, i as FormItem, o as FormMessage, t as InputHelp } from "./input-help-
|
|
7
|
+
import { a as FormLabel, i as FormItem, o as FormMessage, t as InputHelp } from "./input-help-D1JqF0YH.js";
|
|
8
8
|
import { n as PopoverContent, r as PopoverTrigger, t as Popover } from "./popover-DwlKLFCp.js";
|
|
9
9
|
import { t as ScrollBar } from "./scroll-area-C1kW_eA9.js";
|
|
10
10
|
import { useController, useFormContext } from "react-hook-form";
|
package/dist/page-header.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
import "./utils-C8_amEgK.js";
|
|
5
5
|
import "./label-Bkg7B2j8.js";
|
|
6
|
-
import { t as InputHelp } from "./input-help-
|
|
6
|
+
import { t as InputHelp } from "./input-help-D1JqF0YH.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 { t as cn } from "./utils-C8_amEgK.js";
|
|
5
5
|
import "./label-Bkg7B2j8.js";
|
|
6
|
-
import { i as FormItem, o as FormMessage, t as InputHelp } from "./input-help-
|
|
6
|
+
import { i as FormItem, o as FormMessage, t as InputHelp } from "./input-help-D1JqF0YH.js";
|
|
7
7
|
import { t as Button } from "./button-B3nLhVyZ.js";
|
|
8
8
|
import { n as PopoverContent, r as PopoverTrigger, t as Popover } from "./popover-DwlKLFCp.js";
|
|
9
9
|
import { t as ScrollBar } from "./scroll-area-C1kW_eA9.js";
|
package/dist/text-field.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { n as Options$1 } from "./with-mask-Chm8kVE1.js";
|
|
2
2
|
import { FieldPath, FieldPathValue, FieldValues, UseControllerProps } from "react-hook-form";
|
|
3
|
-
import * as
|
|
3
|
+
import * as react_jsx_runtime3 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_runtime3.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_runtime3.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_runtime3.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_runtime3.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.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { t as cn } from "./utils-C8_amEgK.js";
|
|
5
5
|
import { t as Label } from "./label-Bkg7B2j8.js";
|
|
6
6
|
import { n as withMask, t as Input } from "./input-Bs61WBGW.js";
|
|
7
|
-
import { i as FormItem, t as InputHelp } from "./input-help-
|
|
7
|
+
import { i as FormItem, t as InputHelp } from "./input-help-D1JqF0YH.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";
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"input-help-BRDK0-yu.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('mb-0.5 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,QAAS;GACC;;AAIhC,MAAM,qBAAqB;CACzB,MAAM,eAAe,MAAM,WAAW,iBAAiB;CACvD,MAAM,cAAc,MAAM,WAAW,gBAAgB;CACrD,MAAM,EAAE,kBAAkB,gBAAgB;CAC1C,MAAM,YAAY,aAAa,EAAE,MAAM,aAAa,MAAM,CAAC;CAC3D,MAAM,aAAa,cAAc,aAAa,MAAM,UAAU;AAE9D,KAAI,CAAC,aACH,OAAM,IAAI,MAAM,iDAAiD;CAGnE,MAAM,EAAE,OAAO;AAEf,QAAO;EACL;EACA,MAAM,aAAa;EACnB,YAAY,GAAG,GAAG;EAClB,mBAAmB,GAAG,GAAG;EACzB,eAAe,GAAG,GAAG;EACrB,GAAG;EACJ;;AAOH,MAAM,kBAAkB,MAAM,cAC5B,EAAE,CACH;AAED,SAAS,SAAS,EAAE,UAAW,GAAG,SAAsC;CACtE,MAAM,KAAK,MAAM,OAAO;AAExB,QACE,oBAAC,gBAAgB;EAAS,OAAO,EAAE,IAAI;YACrC,oBAAC;GACC,WAAW,GAAG,uBAAuB,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