@gmcode/forms 0.2.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/index.d.mts +19 -30
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +36 -62
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -8
package/README.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { i18n as i18n$1 } from "i18next";
|
|
2
2
|
import { Button, Field, FieldSet } from "@gmcode/react-ui";
|
|
3
|
-
import { Control, ControllerRenderProps,
|
|
4
|
-
import {
|
|
3
|
+
import { Control, ControllerRenderProps, FieldPath, FieldValues, FieldValues as FieldValues$1, UseFormReturn, UseFormSetValue } from "react-hook-form";
|
|
4
|
+
import { ErrorData, ErrorData as ErrorData$1, RouteDefinition, RouteDefinition as RouteDefinition$1 } from "@gmcode/inertia-hook-form";
|
|
5
|
+
import { InputCheckboxRule, InputColorRule, InputEmailRule, InputNumberRule, InputPasswordRule, InputRule, InputSelectRule, InputTextRule, Message, MessageParams, Ruleset, Ruleset as Ruleset$1, Sanitized, SanitizedValues, SanitizedValues as SanitizedValues$1, Schema, Schema as Schema$1, SchemaOptions, SchemaRule, SchemaValues } from "@gmcode/tsv-input";
|
|
6
|
+
import { InferSchema, useTsvResolver } from "@gmcode/tsv-hookform";
|
|
5
7
|
import { ChangeEventHandler, ComponentProps, FC, HTMLInputAutoCompleteAttribute, HTMLInputTypeAttribute, ReactNode, SVGProps } from "react";
|
|
6
|
-
import { InputCheckboxRule, InputColorRule, InputEmailRule, InputNumberRule, InputPasswordRule, InputRule, InputSelectRule, InputTextRule, Message, MessageParams, MessageParams as MessageParams$1, Ruleset, Ruleset as Ruleset$1, Sanitized, SanitizedValues, Schema, SchemaOptions, SchemaRule, SchemaValues } from "@gmcode/tsv-input";
|
|
7
8
|
import { DayPickerLocale, Matcher } from "react-day-picker";
|
|
8
9
|
import { Checkbox as Checkbox$1 } from "radix-ui";
|
|
9
|
-
import { CancelTokenCallback, FormDataErrors, GlobalEventCallback, RequestPayload } from "@inertiajs/core";
|
|
10
|
+
import { CancelTokenCallback, FormDataErrors, GlobalEventCallback, Method, RequestPayload } from "@inertiajs/core";
|
|
10
11
|
import { TextareaHeightChangeMeta } from "react-textarea-autosize";
|
|
11
12
|
//#region src/i18n.d.ts
|
|
12
13
|
/**
|
|
@@ -14,26 +15,6 @@ import { TextareaHeightChangeMeta } from "react-textarea-autosize";
|
|
|
14
15
|
*/
|
|
15
16
|
declare const i18n: i18n$1;
|
|
16
17
|
//#endregion
|
|
17
|
-
//#region src/types/index.d.ts
|
|
18
|
-
type Method = 'get' | 'post' | 'put' | 'delete' | 'patch';
|
|
19
|
-
type RouteDefinition<TMethod extends Method | Method[]> = {
|
|
20
|
-
url: string;
|
|
21
|
-
} & (TMethod extends Method[] ? {
|
|
22
|
-
methods: TMethod;
|
|
23
|
-
} : {
|
|
24
|
-
method: TMethod;
|
|
25
|
-
});
|
|
26
|
-
interface Option {
|
|
27
|
-
id?: string;
|
|
28
|
-
key?: string | number;
|
|
29
|
-
label: ReactNode;
|
|
30
|
-
value: string;
|
|
31
|
-
}
|
|
32
|
-
interface ErrorData {
|
|
33
|
-
message?: string;
|
|
34
|
-
params?: MessageParams$1;
|
|
35
|
-
}
|
|
36
|
-
//#endregion
|
|
37
18
|
//#region src/components/calendar-field.d.ts
|
|
38
19
|
export declare function CalendarField<TFieldValues extends FieldValues$1 = FieldValues$1>({ control, dateToString, disabled, inputId, inputName, label, locale, stringToDate, ...props }: ComponentProps<typeof Field> & {
|
|
39
20
|
control: Control<TFieldValues>;
|
|
@@ -80,9 +61,17 @@ export declare function EmailField<TFieldValues extends FieldValues$1 = FieldVal
|
|
|
80
61
|
//#endregion
|
|
81
62
|
//#region src/components/error-monitor.d.ts
|
|
82
63
|
export declare function ErrorMonitor({ error }: {
|
|
83
|
-
error?: ErrorData;
|
|
64
|
+
error?: ErrorData$1;
|
|
84
65
|
}): import("react").JSX.Element | null;
|
|
85
66
|
//#endregion
|
|
67
|
+
//#region src/types/index.d.ts
|
|
68
|
+
interface Option {
|
|
69
|
+
id?: string;
|
|
70
|
+
key?: string | number;
|
|
71
|
+
label: ReactNode;
|
|
72
|
+
value: string;
|
|
73
|
+
}
|
|
74
|
+
//#endregion
|
|
86
75
|
//#region src/components/fancy-radio-field.d.ts
|
|
87
76
|
export declare function FancyRadioField<TFieldValues extends FieldValues$1 = FieldValues$1>({ control, defaultValue, description, disabled, groupId, inputName, label, options, ...props }: ComponentProps<typeof FieldSet> & {
|
|
88
77
|
control: Control<TFieldValues>;
|
|
@@ -103,9 +92,9 @@ type RenderFN<TValues extends FieldValues$1> = ({ errors, form, loading }: {
|
|
|
103
92
|
form: UseFormReturn<TValues>;
|
|
104
93
|
loading: boolean;
|
|
105
94
|
}) => ReactNode;
|
|
106
|
-
export declare function Form<TRuleset extends Ruleset$1,
|
|
95
|
+
export declare function Form<TRuleset extends Ruleset$1, TValues extends SanitizedValues$1<TRuleset>>({ children, className, defaults, onBefore, onBeforeUpdate, onCancel, onCancelToken, onError, onFinish, onFlash, onPrefetched, onPrefetching, onProgress, onStart, onSuccess, preserveScroll, resetOnSuccess, rootError: displayRootError, route, schema, setDefaultsOnSuccess, ...props }: Omit<ComponentProps<'form'>, 'action' | 'children' | 'method' | 'onSubmit'> & {
|
|
107
96
|
children: RenderFN<TValues>;
|
|
108
|
-
defaults?: Partial<
|
|
97
|
+
defaults?: Partial<TValues>;
|
|
109
98
|
onBefore?: GlobalEventCallback<'before', RequestPayload>;
|
|
110
99
|
onBeforeUpdate?: GlobalEventCallback<'beforeUpdate', RequestPayload>;
|
|
111
100
|
onCancel?: GlobalEventCallback<'cancel', RequestPayload>;
|
|
@@ -135,8 +124,8 @@ export declare function Form<TRuleset extends Ruleset$1, TSchema extends Schema<
|
|
|
135
124
|
* @defaultValue `"flash"`
|
|
136
125
|
*/
|
|
137
126
|
rootError?: 'flash' | 'monitor' | 'none';
|
|
138
|
-
route: RouteDefinition<Method>;
|
|
139
|
-
schema: Schema<TRuleset>;
|
|
127
|
+
route: RouteDefinition$1<Method>;
|
|
128
|
+
schema: Schema$1<TRuleset>;
|
|
140
129
|
/**
|
|
141
130
|
* Set the submitted values as default values on success.
|
|
142
131
|
*
|
|
@@ -249,5 +238,5 @@ export declare function TextareaField<TFieldValues extends FieldValues$1 = Field
|
|
|
249
238
|
resize?: 'both' | 'none' | 'x' | 'y';
|
|
250
239
|
}): import("react").JSX.Element;
|
|
251
240
|
//#endregion
|
|
252
|
-
export { type ErrorData, type FieldValues, type InferSchema, InputCheckboxRule, InputColorRule, InputEmailRule, InputNumberRule, InputPasswordRule, InputRule, InputSelectRule, InputTextRule, Message, type MessageParams, type
|
|
241
|
+
export { type ErrorData, type FieldValues, type InferSchema, InputCheckboxRule, InputColorRule, InputEmailRule, InputNumberRule, InputPasswordRule, InputRule, InputSelectRule, InputTextRule, Message, type MessageParams, type Option, type RouteDefinition, type Ruleset, type Sanitized, type SanitizedValues, Schema, type SchemaOptions, type SchemaRule, type SchemaValues, i18n, useTsvResolver };
|
|
253
242
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/i18n.ts","../src/
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/i18n.ts","../src/components/calendar-field.tsx","../src/components/checkbox-field.tsx","../src/components/input-field.tsx","../src/components/email-field.tsx","../src/components/error-monitor.tsx","../src/types/index.d.ts","../src/components/fancy-radio-field.tsx","../src/components/form.tsx","../src/components/hidden-field.tsx","../src/components/info-checkbox-field.tsx","../src/components/nullable-select-field.tsx","../src/components/numeric-field.tsx","../src/components/password-field.tsx","../src/components/select-field.tsx","../src/components/submit.tsx","../src/components/switch-field.tsx","../src/components/text-field.tsx","../src/components/textarea-field.tsx"],"mappings":";;;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f,SAAS,QAAQ;EACjB;EACA;EACA;EACA,WAAW,UAAU;EACrB;EACA;EACA,OAAO;EACP;IACE;IACA;IACA,UAAU,gBAAgB;IAC1B;;oBAEH,IAAA;;;wBC7Ee,cAAc,qBAAqB,gBAAc,iBAC/D,cACA,SACG,SACF,sBAAsB,WAAW,iCAAc,IAAA;;;wBCYlC,YAAY,qBAAqB,gBAAc,iBAC7D,cACA,SACA,aACA,UACA,SACA,WACA,OACA,SACA,gBACG,SACF,sBAAsB;EACvB,eAAe;EACf,SAAS,QAAQ;EACjB;EACA;EACA;EACA,WAAW,UAAU;EACrB;EACA,SAAS;EACT;EACA,OAAO;oBACR,IAAA;;;wBCtCe,SACd,OACA,SACA,SACG,SACF,sBAAsB;EACvB;EACA;oBACD,IAAA;;;wBCLe,YAAY,qBAAqB,gBAAc,iBAC7D,SACA,UACA,SACA,WACA,OACA,iBACA,aACA,UACA,gBACA,UACG,SACF,sBAAsB;EACvB,SAAS,QAAQ;EACjB;EACA;EACA,WAAW,UAAU;EACrB;EACA,mBACE,SAAS,WAAkB,cAC3B,OAAO,sBAAsB,cAAc,UAAU;EAEvD;EACA;EACA;oBACD,IAAA;;;wBC5Be,UAAU,qBAAqB,gBAAc,iBAC3D,cACA,SACG,SACF,sBAAsB,WAAW,iCAAc,IAAA;;;wBCDlC,cAAc,qBAAqB,gBAAc,iBAC/D,mBACA,SACA,SACA,WACA,OACA,SACA,SACA,gBACA,aACA,WACG,SACF,sBAAsB;EACvB;EACA,SAAS,QAAQ;EACjB;EACA,WAAW,UAAU;EACrB;EACA;EACA;EACA,kBAAkB,gBAAgB,MAAM;EACxC;EACA;oBACD,IAAA"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { t as en_default } from "./en-Bh8xi5UO.mjs";
|
|
2
2
|
import { createInstance } from "i18next";
|
|
3
3
|
import { Button, Calendar, Checkbox, Field, FieldDescription, FieldError, FieldLabel, FieldSet, Input, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, Label, RadioGroup, RadioGroupItem, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, Spinner, Switch, TextareaAutosize, cn, flash } from "@gmcode/react-ui";
|
|
4
|
-
import { Controller
|
|
4
|
+
import { Controller } from "react-hook-form";
|
|
5
5
|
import { c } from "react/compiler-runtime";
|
|
6
6
|
import { useTranslation } from "react-i18next";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { useForm as useForm$1 } from "@inertiajs/react";
|
|
10
|
-
import { useEffect, useState } from "react";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { useForm } from "@gmcode/inertia-hook-form";
|
|
11
9
|
import { Minus, Plus, X } from "lucide-react";
|
|
12
10
|
import { InputCheckboxRule, InputColorRule, InputEmailRule, InputNumberRule, InputPasswordRule, InputRule, InputSelectRule, InputTextRule, Message, Schema } from "@gmcode/tsv-input";
|
|
11
|
+
import { useTsvResolver } from "@gmcode/tsv-hookform";
|
|
13
12
|
|
|
14
13
|
//#region src/i18n.ts
|
|
15
14
|
/**
|
|
@@ -26,9 +25,9 @@ i18n.init();
|
|
|
26
25
|
//#region src/components/error-monitor.tsx
|
|
27
26
|
function ErrorMonitor(t0) {
|
|
28
27
|
const $ = c(9);
|
|
29
|
-
if ($[0] !== "
|
|
28
|
+
if ($[0] !== "6dee9717d046302b6cdb441db2e279dbed96c05721a318a7b315d46bc6bc9913") {
|
|
30
29
|
for (let $i = 0; $i < 9; $i += 1) $[$i] = Symbol.for("react.memo_cache_sentinel");
|
|
31
|
-
$[0] = "
|
|
30
|
+
$[0] = "6dee9717d046302b6cdb441db2e279dbed96c05721a318a7b315d46bc6bc9913";
|
|
32
31
|
}
|
|
33
32
|
const { error } = t0;
|
|
34
33
|
const { t } = useTranslation("forms");
|
|
@@ -378,69 +377,44 @@ function _temp$2(option) {
|
|
|
378
377
|
//#endregion
|
|
379
378
|
//#region src/components/form.tsx
|
|
380
379
|
function Form({ children, className, defaults = {}, onBefore, onBeforeUpdate, onCancel, onCancelToken, onError, onFinish, onFlash, onPrefetched, onPrefetching, onProgress, onStart, onSuccess, preserveScroll = true, resetOnSuccess = true, rootError: displayRootError = "flash", route, schema, setDefaultsOnSuccess = false, ...props }) {
|
|
381
|
-
const [rootError, setRootError] = useState();
|
|
382
|
-
const defaultValues = Object.fromEntries(Object.keys(schema.ruleset).map((field) => [field, defaults[field] ?? ""]));
|
|
383
|
-
const reactForm = useForm({
|
|
384
|
-
defaultValues,
|
|
385
|
-
resolver: useTsvResolver$1(schema)
|
|
386
|
-
});
|
|
387
|
-
const inertiaForm = useForm$1(defaultValues);
|
|
388
380
|
function onErrorWithToast(errors) {
|
|
389
|
-
if (errors.root) {
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
title: errors.root
|
|
393
|
-
});
|
|
394
|
-
else if (displayRootError === "monitor") setRootError({ message: errors.root });
|
|
395
|
-
}
|
|
396
|
-
if (onError) onError(errors);
|
|
397
|
-
}
|
|
398
|
-
function onSuccessWithReset(page) {
|
|
399
|
-
if (setDefaultsOnSuccess) {
|
|
400
|
-
inertiaForm.setDefaults();
|
|
401
|
-
reactForm.reset(reactForm.getValues());
|
|
402
|
-
}
|
|
403
|
-
if (resetOnSuccess) {
|
|
404
|
-
inertiaForm.reset();
|
|
405
|
-
reactForm.reset();
|
|
406
|
-
}
|
|
407
|
-
if (onSuccess) onSuccess(page);
|
|
408
|
-
}
|
|
409
|
-
function onSubmit(values) {
|
|
410
|
-
inertiaForm.transform(() => values);
|
|
411
|
-
inertiaForm[route.method](route.url, {
|
|
412
|
-
onBefore,
|
|
413
|
-
onBeforeUpdate,
|
|
414
|
-
onCancel,
|
|
415
|
-
onCancelToken,
|
|
416
|
-
onError: onErrorWithToast,
|
|
417
|
-
onFinish,
|
|
418
|
-
onFlash,
|
|
419
|
-
onPrefetched,
|
|
420
|
-
onPrefetching,
|
|
421
|
-
onProgress,
|
|
422
|
-
onStart,
|
|
423
|
-
onSuccess: onSuccessWithReset,
|
|
424
|
-
preserveScroll
|
|
381
|
+
if (errors.root && displayRootError === "flash") flash({
|
|
382
|
+
level: "error",
|
|
383
|
+
title: errors.root
|
|
425
384
|
});
|
|
385
|
+
if (onError) onError(errors);
|
|
426
386
|
}
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
387
|
+
const { errors: errors_0, form, loading, onSubmit } = useForm({
|
|
388
|
+
defaults,
|
|
389
|
+
onBefore,
|
|
390
|
+
onBeforeUpdate,
|
|
391
|
+
onCancel,
|
|
392
|
+
onCancelToken,
|
|
393
|
+
onError: onErrorWithToast,
|
|
394
|
+
onFinish,
|
|
395
|
+
onFlash,
|
|
396
|
+
onPrefetched,
|
|
397
|
+
onPrefetching,
|
|
398
|
+
onProgress,
|
|
399
|
+
onStart,
|
|
400
|
+
onSuccess,
|
|
401
|
+
preserveScroll,
|
|
402
|
+
resetOnSuccess,
|
|
403
|
+
route,
|
|
404
|
+
schema,
|
|
405
|
+
setDefaultsOnSuccess
|
|
406
|
+
});
|
|
433
407
|
return /* @__PURE__ */ jsxs("form", {
|
|
434
408
|
action: route.url,
|
|
435
409
|
className: cn("grid gap-6", className),
|
|
436
410
|
method: route.method,
|
|
437
|
-
onSubmit
|
|
411
|
+
onSubmit,
|
|
438
412
|
...props,
|
|
439
|
-
children: [
|
|
440
|
-
errors:
|
|
441
|
-
form
|
|
442
|
-
loading
|
|
443
|
-
})
|
|
413
|
+
children: [children({
|
|
414
|
+
errors: errors_0,
|
|
415
|
+
form,
|
|
416
|
+
loading
|
|
417
|
+
}), displayRootError === "monitor" && /* @__PURE__ */ jsx(ErrorMonitor, { error: { message: errors_0.root } })]
|
|
444
418
|
});
|
|
445
419
|
}
|
|
446
420
|
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["error","labelClassName","label","autoComplete","inputClassName","placeholder","readOnly","type","control","disabled","inputName","label","description","defaultValue","control","disabled","inputName","label","autoComplete","placeholder","description","control","disabled","inputName","$","label","autoComplete","placeholder","description","control","disabled","inputName"],"sources":["../src/i18n.ts","../src/components/error-monitor.tsx","../src/lib/utils.ts","../src/components/calendar-field.tsx","../src/components/checkbox-field.tsx","../src/components/input-field.tsx","../src/components/email-field.tsx","../src/components/fancy-radio-field.tsx","../src/components/form.tsx","../src/components/hidden-field.tsx","../src/components/info-checkbox-field.tsx","../src/components/nullable-select-field.tsx","../src/components/numeric-field.tsx","../src/components/password-field.tsx","../src/components/select-field.tsx","../src/components/submit.tsx","../src/components/switch-field.tsx","../src/components/text-field.tsx","../src/components/textarea-field.tsx"],"sourcesContent":["import { type i18n as Ti18n, createInstance } from 'i18next'\nimport en from '@/locales/en'\n\n/**\n * @deprecated Use the `forms` namespace instead.\n */\nconst i18n: Ti18n = createInstance({\n fallbackLng: 'en',\n interpolation: { escapeValue: false },\n resources: { en }\n})\n\nvoid i18n.init()\n\nexport default i18n\n","import { FieldError } from '@gmcode/react-ui'\nimport { useTranslation } from 'react-i18next'\nimport type { ErrorData } from '@/types'\n\nexport function ErrorMonitor({ error }: { error?: ErrorData }) {\n // i18n\n const { t } = useTranslation('forms')\n\n if (!error?.message) {\n return null\n }\n\n if (t.name === 'notReadyT') {\n return <FieldError errors={error} />\n }\n\n // @ts-expect-error: assert error.message to be a translation key\n return <FieldError errors={{ message: t(error.message, error.params) }} />\n}\n","/**\n * Convert a javascript `Date` object to a string with the format `aaaa-mm-dd`.\n */\nexport function dateToString(date: Date): string {\n return `${date.getFullYear()}-${(date.getMonth() + 1 + '').padStart(2, '0')}-${(date.getDate() + '').padStart(2, '0')}`\n}\n\n/**\n * Convert a string to a javascript `Date` object or undefined if the string is\n * not a valid date.\n */\nexport function stringToDate(string: string | undefined): Date | undefined {\n if (!string) {\n return undefined\n }\n\n const date = new Date(string)\n\n if (isNaN(date.getFullYear())) {\n return undefined\n }\n\n return date\n}\n","import { Calendar, Field, FieldLabel } from '@gmcode/react-ui'\nimport type { ComponentProps } from 'react'\nimport type { DayPickerLocale, Matcher } from 'react-day-picker'\nimport { type Control, Controller, type FieldPath } from 'react-hook-form'\nimport type { FieldValues } from 'react-hook-form'\nimport { ErrorMonitor } from '@/components/error-monitor'\nimport {\n dateToString as defaultDateToString,\n stringToDate as defaultStringToDate\n} from '@/lib/utils'\n\nexport function CalendarField<TFieldValues extends FieldValues = FieldValues>({\n control,\n dateToString = defaultDateToString,\n disabled,\n inputId,\n inputName,\n label,\n locale,\n stringToDate = defaultStringToDate,\n ...props\n}: ComponentProps<typeof Field> & {\n control: Control<TFieldValues>\n dateToString?: (date: Date) => string\n disabled?: Matcher | Matcher[]\n inputId?: string\n inputName: FieldPath<TFieldValues>\n label?: string\n locale?: Partial<DayPickerLocale>\n stringToDate?: (string: string | undefined) => Date | undefined\n}) {\n return (\n <Controller\n control={control}\n name={inputName}\n render={({ field, fieldState }) => (\n <Field\n data-invalid={fieldState.invalid}\n {...props}\n >\n {label && (\n <FieldLabel htmlFor={inputId ?? inputName}>{label}</FieldLabel>\n )}\n\n <Calendar\n aria-invalid={fieldState.invalid}\n className=\"w-full rounded-md border\"\n disabled={disabled}\n fixedWeeks={true}\n id={inputId ?? (label ? inputName : undefined)}\n locale={locale}\n mode=\"single\"\n onSelect={(date) => field.onChange(date ? dateToString(date) : '')}\n selected={stringToDate(field.value)}\n />\n\n <ErrorMonitor error={fieldState.error} />\n </Field>\n )}\n />\n )\n}\n","import { Checkbox, Field, FieldLabel } from '@gmcode/react-ui'\nimport type { Checkbox as CheckboxPrimitive } from 'radix-ui'\nimport type { ComponentProps } from 'react'\nimport { type Control, Controller, type FieldPath } from 'react-hook-form'\nimport type { ControllerRenderProps, FieldValues } from 'react-hook-form'\nimport { ErrorMonitor } from '@/components/error-monitor'\n\nexport function CheckboxField<TFieldValues extends FieldValues = FieldValues>({\n control,\n disabled,\n inputId,\n inputName,\n label,\n onCheckedChange,\n orientation = 'horizontal',\n readOnly,\n uncheckedValue = '',\n value = 'true',\n ...props\n}: ComponentProps<typeof Field> & {\n control: Control<TFieldValues>\n disabled?: boolean\n inputId?: string\n inputName: FieldPath<TFieldValues>\n label?: string\n onCheckedChange?: (\n checked: CheckboxPrimitive.CheckedState,\n field: ControllerRenderProps<TFieldValues, FieldPath<TFieldValues>>\n ) => void\n readOnly?: boolean\n uncheckedValue?: string\n value?: string\n}) {\n return (\n <Controller\n control={control}\n disabled={disabled}\n name={inputName}\n render={({ field, fieldState }) => (\n <Field\n data-invalid={fieldState.invalid}\n orientation={orientation}\n {...props}\n >\n <Checkbox\n aria-invalid={fieldState.invalid}\n aria-readonly={readOnly}\n checked={field.value === value}\n className=\"aria-readonly:opacity-50\"\n disabled={field.disabled}\n id={inputId ?? (label ? inputName : undefined)}\n name={field.name}\n onBlur={field.onBlur}\n onCheckedChange={(checked) => {\n if (!readOnly) {\n field.onChange(checked === true ? value : uncheckedValue)\n if (onCheckedChange) onCheckedChange(checked, field)\n }\n }}\n ref={field.ref}\n value={value}\n />\n\n {label && (\n <FieldLabel htmlFor={inputId ?? inputName}>{label}</FieldLabel>\n )}\n\n <ErrorMonitor error={fieldState.error} />\n </Field>\n )}\n />\n )\n}\n","import { Field, FieldLabel, Input } from '@gmcode/react-ui'\nimport type {\n ChangeEventHandler,\n ComponentProps,\n HTMLInputAutoCompleteAttribute,\n HTMLInputTypeAttribute\n} from 'react'\nimport { type Control, Controller, type FieldPath } from 'react-hook-form'\nimport type { FieldValues } from 'react-hook-form'\nimport { ErrorMonitor } from '@/components/error-monitor'\n\nexport function InputField<TFieldValues extends FieldValues = FieldValues>({\n autoComplete,\n control,\n disabled,\n inputClassName,\n inputId,\n inputName,\n label,\n labelClassName,\n placeholder,\n readOnly,\n type,\n ...props\n}: Omit<ComponentProps<typeof Field>, 'onChange'> & {\n autoComplete?: HTMLInputAutoCompleteAttribute\n control: Control<TFieldValues>\n disabled?: boolean\n inputClassName?: string\n inputId?: string\n inputName: FieldPath<TFieldValues>\n label?: string\n labelClassName?: string\n onChange?: ChangeEventHandler<HTMLDivElement, HTMLInputElement>\n placeholder?: string\n readOnly?: boolean\n type?: HTMLInputTypeAttribute\n}) {\n return (\n <Controller\n control={control}\n disabled={disabled}\n name={inputName}\n render={({ field, fieldState }) => (\n <Field\n data-invalid={fieldState.invalid}\n {...props}\n >\n {label && (\n <FieldLabel\n className={labelClassName}\n htmlFor={inputId ?? inputName}\n >\n {label}\n </FieldLabel>\n )}\n\n <Input\n aria-invalid={fieldState.invalid}\n autoComplete={autoComplete}\n className={inputClassName}\n id={inputId ?? (label ? inputName : undefined)}\n placeholder={placeholder}\n readOnly={readOnly}\n type={type}\n {...field}\n />\n\n <ErrorMonitor error={fieldState.error} />\n </Field>\n )}\n />\n )\n}\n","import type { ComponentProps } from 'react'\nimport type { FieldValues } from 'react-hook-form'\nimport { InputField } from '@/components/input-field'\n\nexport function EmailField<TFieldValues extends FieldValues = FieldValues>({\n autoComplete = 'on',\n type = 'email',\n ...props\n}: ComponentProps<typeof InputField<TFieldValues>>) {\n return (\n <InputField\n autoComplete={autoComplete}\n type={type}\n {...props}\n />\n )\n}\n","import {\n FieldDescription,\n FieldLabel,\n FieldSet,\n Label,\n RadioGroup,\n RadioGroupItem\n} from '@gmcode/react-ui'\nimport type { ComponentProps, FC, SVGProps } from 'react'\nimport { type Control, Controller, type FieldPath } from 'react-hook-form'\nimport type { FieldValues } from 'react-hook-form'\nimport { ErrorMonitor } from '@/components/error-monitor'\nimport type { Option } from '@/types'\n\nexport function FancyRadioField<\n TFieldValues extends FieldValues = FieldValues\n>({\n control,\n defaultValue,\n description,\n disabled,\n groupId,\n inputName,\n label,\n options,\n ...props\n}: ComponentProps<typeof FieldSet> & {\n control: Control<TFieldValues>\n defaultValue: string\n description?: string\n disabled?: boolean\n groupId?: string\n inputName: FieldPath<TFieldValues>\n label?: string\n options: Array<Option & { Icon?: FC<SVGProps<SVGSVGElement>> }>\n}) {\n return (\n <Controller\n control={control}\n disabled={disabled}\n name={inputName}\n render={({ field, fieldState }) => (\n <FieldSet\n data-invalid={fieldState.invalid}\n {...props}\n >\n {label && (\n <FieldLabel htmlFor={groupId ?? inputName}>{label}</FieldLabel>\n )}\n\n {description && <FieldDescription>{description}</FieldDescription>}\n\n <ErrorMonitor error={fieldState.error} />\n\n <RadioGroup\n defaultValue={defaultValue}\n disabled={field.disabled}\n id={groupId ?? (label ? inputName : undefined)}\n name={field.name}\n onBlur={field.onBlur}\n onValueChange={field.onChange}\n ref={field.ref}\n >\n {options.map((option) => (\n <Label\n className=\"rounded-md border ring-ring/50 transition-all hover:bg-accent/50 has-focus-visible:ring-[3px]\"\n data-slot=\"field-label\"\n key={option.key ?? option.id ?? option.value}\n >\n <div className=\"flex w-full items-center gap-3 rounded-md p-3 transition-all has-aria-checked:border-l-8 has-aria-checked:border-ring\">\n <RadioGroupItem\n className=\"sr-only\"\n id={option.id}\n value={option.value}\n />\n {option.Icon && <option.Icon />}\n {option.label}\n </div>\n </Label>\n ))}\n </RadioGroup>\n </FieldSet>\n )}\n />\n )\n}\n","import { cn, flash } from '@gmcode/react-ui'\nimport { type InferSchema, useTsvResolver } from '@gmcode/tsv-hookform'\nimport type { Ruleset } from '@gmcode/tsv-input'\nimport type {\n CancelTokenCallback,\n Errors,\n FormDataErrors,\n GlobalEventCallback,\n Page,\n RequestPayload,\n SharedPageProps\n} from '@inertiajs/core'\nimport { useForm as useInertiaForm } from '@inertiajs/react'\nimport { type ComponentProps, type ReactNode, useEffect, useState } from 'react'\nimport type {\n DefaultValues,\n FieldValues,\n Path,\n UseFormReturn\n} from 'react-hook-form'\nimport { useForm as userReactForm } from 'react-hook-form'\nimport { ErrorMonitor } from '@/components/error-monitor'\nimport type { Schema } from '@/index'\nimport type { ErrorData, Method, RouteDefinition } from '@/types'\n\ntype RenderFN<TValues extends FieldValues> = ({\n errors,\n form,\n loading\n}: {\n errors: FormDataErrors<object>\n form: UseFormReturn<TValues>\n loading: boolean\n}) => ReactNode\n\nexport function Form<\n TRuleset extends Ruleset,\n TSchema extends Schema<TRuleset>,\n TValues extends InferSchema<TSchema>\n>({\n children,\n className,\n defaults = {},\n onBefore,\n onBeforeUpdate,\n onCancel,\n onCancelToken,\n onError,\n onFinish,\n onFlash,\n onPrefetched,\n onPrefetching,\n onProgress,\n onStart,\n onSuccess,\n preserveScroll = true,\n resetOnSuccess = true,\n rootError: displayRootError = 'flash',\n route,\n schema,\n setDefaultsOnSuccess = false,\n ...props\n}: Omit<\n ComponentProps<'form'>,\n 'action' | 'children' | 'method' | 'onSubmit'\n> & {\n children: RenderFN<TValues>\n defaults?: Partial<DefaultValues<TValues>>\n onBefore?: GlobalEventCallback<'before', RequestPayload>\n onBeforeUpdate?: GlobalEventCallback<'beforeUpdate', RequestPayload>\n onCancel?: GlobalEventCallback<'cancel', RequestPayload>\n onCancelToken?: CancelTokenCallback\n onError?: GlobalEventCallback<'error', RequestPayload>\n onFinish?: GlobalEventCallback<'finish', RequestPayload>\n onFlash?: GlobalEventCallback<'flash', RequestPayload>\n onPrefetched?: GlobalEventCallback<'prefetched', RequestPayload>\n onPrefetching?: GlobalEventCallback<'prefetching', RequestPayload>\n onProgress?: GlobalEventCallback<'progress', RequestPayload>\n onStart?: GlobalEventCallback<'start', RequestPayload>\n onSuccess?: GlobalEventCallback<'success', RequestPayload>\n preserveScroll?: boolean\n /**\n * Reset input values to their defaults on success.\n *\n * @defaultValue `true`\n */\n resetOnSuccess?: boolean\n /**\n * How to display the root error from inertia.\n *\n * - `\"flash\"` - use the Toaster component\n * - `\"monitor\"` - use the ErrorMonitor component\n * - `\"none\"` - don't display the root error\n *\n * @defaultValue `\"flash\"`\n */\n rootError?: 'flash' | 'monitor' | 'none'\n route: RouteDefinition<Method>\n schema: Schema<TRuleset>\n /**\n * Set the submitted values as default values on success.\n *\n * @defaultValue `false`\n */\n setDefaultsOnSuccess?: boolean\n}) {\n const [rootError, setRootError] = useState<ErrorData>()\n\n const defaultValues = Object.fromEntries(\n Object.keys(schema.ruleset).map((field) => [field, defaults[field] ?? ''])\n ) as DefaultValues<TValues>\n\n // React Hook Form\n const reactForm = userReactForm<TValues>({\n defaultValues,\n resolver: useTsvResolver(schema)\n })\n\n // Inertia\n const inertiaForm = useInertiaForm<object>(defaultValues)\n\n function onErrorWithToast(errors: Errors) {\n if (errors.root) {\n if (displayRootError === 'flash') {\n flash({ level: 'error', title: errors.root })\n } else if (displayRootError === 'monitor') {\n setRootError({ message: errors.root })\n }\n }\n\n if (onError) {\n onError(errors)\n }\n }\n\n function onSuccessWithReset(page: Page<SharedPageProps>) {\n if (setDefaultsOnSuccess) {\n inertiaForm.setDefaults()\n reactForm.reset(reactForm.getValues())\n }\n\n if (resetOnSuccess) {\n inertiaForm.reset()\n reactForm.reset()\n }\n\n if (onSuccess) {\n onSuccess(page)\n }\n }\n\n // Submit handler\n function onSubmit(values: TValues) {\n inertiaForm.transform(() => values)\n inertiaForm[route.method](route.url, {\n onBefore,\n onBeforeUpdate,\n onCancel,\n onCancelToken,\n onError: onErrorWithToast,\n onFinish,\n onFlash,\n onPrefetched,\n onPrefetching,\n onProgress,\n onStart,\n onSuccess: onSuccessWithReset,\n preserveScroll\n })\n }\n\n // Add inertia (server) errors to react form.\n useEffect(() => {\n for (const [key, error] of Object.entries(inertiaForm.errors)) {\n if (error) {\n reactForm.setError(key as Path<TValues>, {\n message: error as string,\n type: 'inertia'\n })\n }\n }\n }, [inertiaForm.errors, reactForm])\n\n return (\n <form\n action={route.url}\n className={cn('grid gap-6', className)}\n method={route.method}\n onSubmit={reactForm.handleSubmit(onSubmit)}\n {...props}\n >\n <>\n {children({\n errors: inertiaForm.errors,\n form: reactForm,\n loading: inertiaForm.processing\n })}\n </>\n\n {displayRootError === 'monitor' && <ErrorMonitor error={rootError} />}\n </form>\n )\n}\n","import { cn } from '@gmcode/react-ui'\nimport type { ComponentProps } from 'react'\nimport type { FieldValues } from 'react-hook-form'\nimport { InputField } from '@/components/input-field'\n\nexport function HiddenField<TFieldValues extends FieldValues = FieldValues>({\n autoComplete = 'off',\n className,\n type = 'hidden',\n ...props\n}: ComponentProps<typeof InputField<TFieldValues>>) {\n return (\n <InputField\n autoComplete={autoComplete}\n className={cn('hidden', className)}\n type={type}\n {...props}\n />\n )\n}\n","import { Checkbox, Field, Label, cn } from '@gmcode/react-ui'\nimport type { Checkbox as CheckboxPrimitive } from 'radix-ui'\nimport type { ComponentProps } from 'react'\nimport { type Control, Controller, type FieldPath } from 'react-hook-form'\nimport type { ControllerRenderProps, FieldValues } from 'react-hook-form'\nimport { ErrorMonitor } from '@/components/error-monitor'\n\nexport function InfoCheckboxField<\n TFieldValues extends FieldValues = FieldValues\n>({\n children,\n className,\n control,\n disabled,\n inputId,\n inputName,\n label,\n onCheckedChange,\n orientation = 'horizontal',\n readOnly,\n text,\n uncheckedValue = '',\n value = 'true',\n ...props\n}: ComponentProps<typeof Field> & {\n control: Control<TFieldValues>\n disabled?: boolean\n inputId?: string\n inputName: FieldPath<TFieldValues>\n label?: string\n onCheckedChange?: (\n checked: CheckboxPrimitive.CheckedState,\n field: ControllerRenderProps<TFieldValues, FieldPath<TFieldValues>>\n ) => void\n readOnly?: boolean\n text?: string\n uncheckedValue?: string\n value?: string\n}) {\n return (\n <Controller\n control={control}\n disabled={disabled}\n name={inputName}\n render={({ field, fieldState }) => (\n <Field\n className={cn('block', className)}\n data-invalid={fieldState.invalid}\n orientation={orientation}\n {...props}\n >\n <Label\n className=\"flex items-start gap-3 rounded-lg border p-3 hover:bg-accent/50 has-aria-checked:border-info-foreground has-aria-checked:bg-info\"\n data-slot=\"field-label\"\n >\n <Checkbox\n aria-invalid={fieldState.invalid}\n aria-readonly={readOnly}\n checked={field.value === value}\n className=\"aria-readonly:opacity-50 data-[state=checked]:border-info-foreground data-[state=checked]:bg-info-foreground data-[state=checked]:text-white dark:data-[state=checked]:border-info-foreground dark:data-[state=checked]:bg-info-foreground\"\n disabled={field.disabled}\n id={inputId}\n name={field.name}\n onBlur={field.onBlur}\n onCheckedChange={(checked) => {\n if (!readOnly) {\n field.onChange(checked === true ? value : uncheckedValue)\n if (onCheckedChange) onCheckedChange(checked, field)\n }\n }}\n ref={field.ref}\n value={value}\n />\n\n <div className=\"grid gap-1.5 font-normal\">\n <p className=\"text-sm leading-none font-medium\">{label}</p>\n {text ? (\n <p className=\"text-sm text-muted-foreground\">{text}</p>\n ) : (\n children\n )}\n <ErrorMonitor error={fieldState.error} />\n </div>\n </Label>\n </Field>\n )}\n />\n )\n}\n","import {\n Button,\n Field,\n FieldDescription,\n FieldLabel,\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue\n} from '@gmcode/react-ui'\nimport { X } from 'lucide-react'\nimport type {\n ComponentProps,\n HTMLInputAutoCompleteAttribute,\n HTMLInputTypeAttribute\n} from 'react'\nimport { type Control, Controller, type FieldPath } from 'react-hook-form'\nimport type {\n FieldPathValue,\n FieldValues,\n UseFormSetValue\n} from 'react-hook-form'\nimport { useTranslation } from 'react-i18next'\nimport { ErrorMonitor } from '@/components/error-monitor'\nimport type { Option } from '@/types'\n\nexport function NullableSelectField<\n TFieldValues extends FieldValues = FieldValues\n>({\n autoComplete,\n control,\n description,\n disabled,\n inputId,\n inputName,\n label,\n options,\n placeholder,\n setValue,\n ...props\n}: ComponentProps<typeof Field> & {\n autoComplete?: HTMLInputAutoCompleteAttribute\n control: Control<TFieldValues>\n description?: string\n disabled?: boolean\n inputId?: string\n inputName: FieldPath<TFieldValues>\n label?: string\n options: Option[]\n placeholder?: string\n setValue: UseFormSetValue<TFieldValues>\n type?: HTMLInputTypeAttribute\n}) {\n // i18n\n const { t } = useTranslation('forms')\n\n return (\n <Controller\n control={control}\n disabled={disabled}\n name={inputName}\n render={({ field, fieldState }) => (\n <Field\n data-invalid={fieldState.invalid}\n {...props}\n >\n {label && (\n <FieldLabel htmlFor={inputId ?? inputName}>{label}</FieldLabel>\n )}\n\n <div className=\"flex items-end gap-4\">\n <Select\n autoComplete={autoComplete}\n disabled={field.disabled}\n name={field.name}\n onValueChange={field.onChange}\n value={field.value}\n >\n <SelectTrigger\n aria-invalid={fieldState.invalid}\n className=\"flex-1 overflow-hidden\"\n id={inputId ?? (label ? inputName : undefined)}\n >\n <SelectValue placeholder={placeholder} />\n </SelectTrigger>\n <SelectContent>\n {options.map((option) => (\n <SelectItem\n id={option.id}\n key={option.key ?? option.id ?? option.value}\n value={option.value}\n >\n {option.label}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n\n <Button\n aria-label={t(($) => $.reset)}\n className=\"flex-none\"\n onClick={() =>\n setValue(\n inputName,\n '' as FieldPathValue<TFieldValues, FieldPath<TFieldValues>>\n )\n }\n type=\"button\"\n variant=\"outline\"\n >\n <X />\n </Button>\n </div>\n\n {description && <FieldDescription>{description}</FieldDescription>}\n\n <ErrorMonitor error={fieldState.error} />\n </Field>\n )}\n />\n )\n}\n","import {\n Field,\n FieldLabel,\n InputGroup,\n InputGroupAddon,\n InputGroupButton,\n InputGroupInput\n} from '@gmcode/react-ui'\nimport { Minus, Plus } from 'lucide-react'\nimport type {\n ComponentProps,\n HTMLInputAutoCompleteAttribute,\n HTMLInputTypeAttribute\n} from 'react'\nimport { type Control, Controller, type FieldPath } from 'react-hook-form'\nimport type {\n FieldPathValue,\n FieldValues,\n UseFormSetValue\n} from 'react-hook-form'\nimport { useTranslation } from 'react-i18next'\nimport { ErrorMonitor } from '@/components/error-monitor'\n\nfunction stepInput(\n original: string,\n add: boolean,\n step?: number,\n min?: number,\n max?: number\n) {\n let parsed = Number(original)\n\n if (isNaN(parsed)) {\n return ''\n }\n\n if (add) {\n parsed += step === undefined ? 1 : step\n } else {\n parsed -= step === undefined ? 1 : step\n }\n\n if (min !== undefined) {\n parsed = Math.max(parsed, min)\n }\n\n if (max !== undefined) {\n parsed = Math.min(parsed, max)\n }\n\n return parsed.toString()\n}\n\nexport function NumericField<TFieldValues extends FieldValues = FieldValues>({\n autoComplete,\n control,\n disabled,\n inputId,\n inputMode = 'numeric',\n inputName,\n label,\n placeholder,\n type,\n ui,\n ...props\n}: ComponentProps<typeof Field> & {\n autoComplete?: HTMLInputAutoCompleteAttribute\n control: Control<TFieldValues>\n disabled?: boolean\n inputId?: string\n inputMode?: 'decimal' | 'numeric'\n inputName: FieldPath<TFieldValues>\n label?: string\n placeholder?: string\n type?: HTMLInputTypeAttribute\n ui?: {\n max?: number\n min?: number\n setValue: UseFormSetValue<TFieldValues>\n step?: number\n }\n}) {\n // i18n\n const { t } = useTranslation('forms')\n\n function stepValue(value: string, add: boolean) {\n if (ui?.setValue) {\n ui.setValue(\n inputName,\n stepInput(value, add, ui.step, ui.min, ui.max) as FieldPathValue<\n TFieldValues,\n FieldPath<TFieldValues>\n >,\n { shouldValidate: true }\n )\n }\n }\n\n return (\n <Controller\n control={control}\n disabled={disabled}\n name={inputName}\n render={({ field, fieldState }) => (\n <Field\n data-invalid={fieldState.invalid}\n {...props}\n >\n {label && (\n <FieldLabel htmlFor={inputId ?? inputName}>{label}</FieldLabel>\n )}\n\n <InputGroup>\n <InputGroupInput\n aria-invalid={fieldState.invalid}\n autoComplete={autoComplete}\n id={inputId ?? (label ? inputName : undefined)}\n inputMode={inputMode}\n placeholder={placeholder}\n type={type}\n {...field}\n />\n\n {ui && (\n <InputGroupAddon align=\"inline-end\">\n <InputGroupButton\n aria-label={t(($) => $.decrease)}\n disabled={disabled}\n onClick={() => stepValue(field.value, false)}\n size=\"icon-xs\"\n >\n <Minus />\n </InputGroupButton>\n\n <InputGroupButton\n aria-label={t(($) => $.increase)}\n disabled={disabled}\n onClick={() => stepValue(field.value, true)}\n size=\"icon-xs\"\n >\n <Plus />\n </InputGroupButton>\n </InputGroupAddon>\n )}\n </InputGroup>\n\n <ErrorMonitor error={fieldState.error} />\n </Field>\n )}\n />\n )\n}\n","import type { ComponentProps } from 'react'\nimport type { FieldValues } from 'react-hook-form'\nimport { InputField } from '@/components/input-field'\n\nexport function PasswordField<TFieldValues extends FieldValues = FieldValues>({\n autoComplete = 'off',\n type = 'password',\n ...props\n}: ComponentProps<typeof InputField<TFieldValues>>) {\n return (\n <InputField\n autoComplete={autoComplete}\n type={type}\n {...props}\n />\n )\n}\n","import {\n Field,\n FieldDescription,\n FieldLabel,\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue\n} from '@gmcode/react-ui'\nimport type {\n ComponentProps,\n HTMLInputAutoCompleteAttribute,\n HTMLInputTypeAttribute\n} from 'react'\nimport { type Control, Controller, type FieldPath } from 'react-hook-form'\nimport type { FieldValues } from 'react-hook-form'\nimport { ErrorMonitor } from '@/components/error-monitor'\nimport type { Option } from '@/types'\n\nexport function SelectField<TFieldValues extends FieldValues = FieldValues>({\n autoComplete,\n control,\n description,\n disabled,\n inputId,\n inputName,\n label,\n options,\n placeholder,\n ...props\n}: ComponentProps<typeof Field> & {\n autoComplete?: HTMLInputAutoCompleteAttribute\n control: Control<TFieldValues>\n description?: string\n disabled?: boolean\n inputId?: string\n inputName: FieldPath<TFieldValues>\n label?: string\n options: Option[]\n placeholder?: string\n type?: HTMLInputTypeAttribute\n}) {\n return (\n <Controller\n control={control}\n disabled={disabled}\n name={inputName}\n render={({ field, fieldState }) => (\n <Field\n data-invalid={fieldState.invalid}\n {...props}\n >\n {label && (\n <FieldLabel htmlFor={inputId ?? inputName}>{label}</FieldLabel>\n )}\n\n <Select\n autoComplete={autoComplete}\n disabled={field.disabled}\n name={field.name}\n onValueChange={field.onChange}\n value={field.value}\n >\n <SelectTrigger\n aria-invalid={fieldState.invalid}\n id={inputId ?? (label ? inputName : undefined)}\n >\n <SelectValue placeholder={placeholder} />\n </SelectTrigger>\n <SelectContent>\n {options.map((option) => (\n <SelectItem\n id={option.id}\n key={option.key ?? option.id ?? option.value}\n value={option.value}\n >\n {option.label}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n\n {description && <FieldDescription>{description}</FieldDescription>}\n\n <ErrorMonitor error={fieldState.error} />\n </Field>\n )}\n />\n )\n}\n","import { Button, Spinner, cn } from '@gmcode/react-ui'\nimport type { ComponentProps } from 'react'\nimport { useTranslation } from 'react-i18next'\n\nexport function Submit({\n label,\n loading = false,\n type = 'submit',\n ...props\n}: ComponentProps<typeof Button> & {\n label?: string\n loading?: boolean\n}) {\n // i18n\n const { t } = useTranslation('forms')\n\n return (\n <Button\n disabled={loading}\n type={type}\n {...props}\n >\n <div className=\"relative\">\n <span className={cn({ invisible: loading })}>\n {label ?? t(($) => $.submit)}\n </span>\n <Spinner\n className={cn(\n 'trans absolute top-1/2 left-1/2 hidden -translate-x-1/2 -translate-y-1/2',\n { block: loading }\n )}\n />\n </div>\n </Button>\n )\n}\n","import { Field, FieldLabel, Switch } from '@gmcode/react-ui'\nimport type { Checkbox as CheckboxPrimitive } from 'radix-ui'\nimport type { ComponentProps } from 'react'\nimport { type Control, Controller, type FieldPath } from 'react-hook-form'\nimport type { ControllerRenderProps, FieldValues } from 'react-hook-form'\nimport { ErrorMonitor } from '@/components/error-monitor'\n\nexport function SwitchField<TFieldValues extends FieldValues = FieldValues>({\n control,\n disabled,\n inputId,\n inputName,\n label,\n onCheckedChange,\n orientation = 'horizontal',\n readOnly,\n uncheckedValue = '',\n value = 'true',\n ...props\n}: ComponentProps<typeof Field> & {\n control: Control<TFieldValues>\n disabled?: boolean\n inputId?: string\n inputName: FieldPath<TFieldValues>\n label?: string\n onCheckedChange?: (\n checked: CheckboxPrimitive.CheckedState,\n field: ControllerRenderProps<TFieldValues, FieldPath<TFieldValues>>\n ) => void\n readOnly?: boolean\n uncheckedValue?: string\n value?: string\n}) {\n return (\n <Controller\n control={control}\n disabled={disabled}\n name={inputName}\n render={({ field, fieldState }) => (\n <Field\n data-invalid={fieldState.invalid}\n orientation={orientation}\n {...props}\n >\n <Switch\n aria-invalid={fieldState.invalid}\n aria-readonly={readOnly}\n checked={field.value === value}\n className=\"aria-readonly:opacity-50\"\n disabled={field.disabled}\n id={inputId ?? (label ? inputName : undefined)}\n name={field.name}\n onBlur={field.onBlur}\n onCheckedChange={(checked) => {\n if (!readOnly) {\n field.onChange(checked === true ? value : uncheckedValue)\n if (onCheckedChange) onCheckedChange(checked, field)\n }\n }}\n ref={field.ref}\n value={value}\n />\n\n {label && (\n <FieldLabel htmlFor={inputId ?? inputName}>{label}</FieldLabel>\n )}\n\n <ErrorMonitor error={fieldState.error} />\n </Field>\n )}\n />\n )\n}\n","import type { ComponentProps } from 'react'\nimport type { FieldValues } from 'react-hook-form'\nimport { InputField } from '@/components/input-field'\n\nexport function TextField<TFieldValues extends FieldValues = FieldValues>({\n autoComplete = 'on',\n type = 'text',\n ...props\n}: ComponentProps<typeof InputField<TFieldValues>>) {\n return (\n <InputField\n autoComplete={autoComplete}\n type={type}\n {...props}\n />\n )\n}\n","import { Field, FieldLabel, TextareaAutosize, cn } from '@gmcode/react-ui'\nimport type { ComponentProps } from 'react'\nimport { type Control, Controller, type FieldPath } from 'react-hook-form'\nimport type { FieldValues } from 'react-hook-form'\nimport type { TextareaHeightChangeMeta } from 'react-textarea-autosize'\nimport { ErrorMonitor } from '@/components/error-monitor'\n\nexport function TextareaField<TFieldValues extends FieldValues = FieldValues>({\n cacheMeasurements,\n control,\n inputId,\n inputName,\n label,\n maxRows,\n minRows,\n onHeightChange,\n placeholder,\n resize = 'none',\n ...props\n}: ComponentProps<typeof Field> & {\n cacheMeasurements?: boolean\n control: Control<TFieldValues>\n inputId?: string\n inputName: FieldPath<TFieldValues>\n label?: string\n maxRows?: number\n minRows?: number\n onHeightChange?: (height: number, meta: TextareaHeightChangeMeta) => void\n placeholder?: string\n resize?: 'both' | 'none' | 'x' | 'y'\n}) {\n return (\n <Controller\n control={control}\n name={inputName}\n render={({ field, fieldState }) => (\n <Field\n data-invalid={fieldState.invalid}\n {...props}\n >\n {label && (\n <FieldLabel htmlFor={inputId ?? inputName}>{label}</FieldLabel>\n )}\n\n <TextareaAutosize\n aria-invalid={fieldState.invalid}\n autoComplete=\"off\"\n cacheMeasurements={cacheMeasurements}\n className={cn({\n resize: resize === 'both',\n 'resize-none': resize === 'none',\n 'resize-x': resize === 'x',\n 'resize-y': resize === 'y'\n })}\n id={inputId ?? (label ? inputName : undefined)}\n maxRows={maxRows}\n minRows={minRows}\n onHeightChange={onHeightChange}\n placeholder={placeholder}\n {...field}\n />\n\n <ErrorMonitor error={fieldState.error} />\n </Field>\n )}\n />\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAMA,MAAM,OAAc,eAAe;CACjC,aAAa;CACb,eAAe,EAAE,aAAa,MAAM;CACpC,WAAW,EAAE,eAAG;AAClB,CAAC;AAEI,KAAK,KAAK;;;;ACRf,SAAO,aAAA,IAAA;CAAA,MAAA,IAAA,EAAA,CAAA;CAAA,IAAA,EAAA,OAAA,oEAAA;EAAA,KAAA,IAAA,KAAA,GAAA,KAAA,GAAA,MAAA,GAAA,EAAA,MAAA,OAAA,IAAA,2BAAA;EAAA,EAAA,KAAA;CAAA;CAAsB,MAAA,EAAA,UAAA;CAE3B,MAAA,EAAA,MAAc,eAAe,OAAO;CAEpC,IAAI,CAAC,OAAK,SAAS,OACV;CAGT,IAAI,EAAC,SAAU,aAAW;EAAA,IAAA;EAAA,IAAA,EAAA,OAAA,OAAA;GACjB,KAAA,oBAAC,YAAD,EAAoBA,QAAA,MAAK;GAAI,EAAA,KAAA;GAAA,EAAA,KAAA;EAAA,OAAA,KAAA,EAAA;EAAA,OAA7B;CAA6B;CACrC,IAAA;CAAA,IAAA,EAAA,OAAA,MAAA,WAAA,EAAA,OAAA,MAAA,UAAA,EAAA,OAAA,GAAA;EAGqC,KAAA,EAAE,MAAK,SAAU,MAAK,MAAO;EAAC,EAAA,KAAA,MAAA;EAAA,EAAA,KAAA,MAAA;EAAA,EAAA,KAAA;EAAA,EAAA,KAAA;CAAA,OAAA,KAAA,EAAA;CAAA,IAAA;CAAA,IAAA,EAAA,OAAA,IAAA;EAA7D,KAAA,oBAAC,YAAD,EAAoB,QAAA,EAAA,SAAW,GAA+B,EAAC;EAAI,EAAA,KAAA;EAAA,EAAA,KAAA;CAAA,OAAA,KAAA,EA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,aACA,SAAS,QACT,GAAG,SAYF;CACD,OACE,oBAAC,YAAD;EACW;EACT,MAAM;EACN,SAAS,EAAE,OAAO,iBAChB,qBAAC,OAAD;GACE,gBAAc,WAAW;GACzB,GAAI;aAFN;IAIG,SACC,oBAAC,YAAD;KAAY,SAAS,WAAW;eAAY;IAAkB;IAGhE,oBAAC,kBAAD;KACE,gBAAc,WAAW;KACzB,cAAa;KACM;KACnB,WAAW,GAAG;MACZ,QAAQ,WAAW;MACnB,eAAe,WAAW;MAC1B,YAAY,WAAW;MACvB,YAAY,WAAW;KACzB,CAAC;KACD,IAAI,YAAY,QAAQ,YAAY;KAC3B;KACA;KACO;KACH;KACb,GAAI;IAAM;IAGZ,oBAAC,cAAD,EAAc,OAAO,WAAW,MAAM;GACjC;;CACP;AAGR"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["error","labelClassName","label","autoComplete","inputClassName","placeholder","readOnly","type","control","disabled","inputName","label","description","defaultValue","control","disabled","inputName","errors","label","autoComplete","placeholder","description","control","disabled","inputName","$","label","autoComplete","placeholder","description","control","disabled","inputName"],"sources":["../src/i18n.ts","../src/components/error-monitor.tsx","../src/lib/utils.ts","../src/components/calendar-field.tsx","../src/components/checkbox-field.tsx","../src/components/input-field.tsx","../src/components/email-field.tsx","../src/components/fancy-radio-field.tsx","../src/components/form.tsx","../src/components/hidden-field.tsx","../src/components/info-checkbox-field.tsx","../src/components/nullable-select-field.tsx","../src/components/numeric-field.tsx","../src/components/password-field.tsx","../src/components/select-field.tsx","../src/components/submit.tsx","../src/components/switch-field.tsx","../src/components/text-field.tsx","../src/components/textarea-field.tsx"],"sourcesContent":["import { type i18n as Ti18n, createInstance } from 'i18next'\nimport en from '@/locales/en'\n\n/**\n * @deprecated Use the `forms` namespace instead.\n */\nconst i18n: Ti18n = createInstance({\n fallbackLng: 'en',\n interpolation: { escapeValue: false },\n resources: { en }\n})\n\nvoid i18n.init()\n\nexport default i18n\n","import type { ErrorData } from '@gmcode/inertia-hook-form'\nimport { FieldError } from '@gmcode/react-ui'\nimport { useTranslation } from 'react-i18next'\n\nexport function ErrorMonitor({ error }: { error?: ErrorData }) {\n // i18n\n const { t } = useTranslation('forms')\n\n if (!error?.message) {\n return null\n }\n\n if (t.name === 'notReadyT') {\n return <FieldError errors={error} />\n }\n\n // @ts-expect-error: assert error.message to be a translation key\n return <FieldError errors={{ message: t(error.message, error.params) }} />\n}\n","/**\n * Convert a javascript `Date` object to a string with the format `aaaa-mm-dd`.\n */\nexport function dateToString(date: Date): string {\n return `${date.getFullYear()}-${(date.getMonth() + 1 + '').padStart(2, '0')}-${(date.getDate() + '').padStart(2, '0')}`\n}\n\n/**\n * Convert a string to a javascript `Date` object or undefined if the string is\n * not a valid date.\n */\nexport function stringToDate(string: string | undefined): Date | undefined {\n if (!string) {\n return undefined\n }\n\n const date = new Date(string)\n\n if (isNaN(date.getFullYear())) {\n return undefined\n }\n\n return date\n}\n","import { Calendar, Field, FieldLabel } from '@gmcode/react-ui'\nimport type { ComponentProps } from 'react'\nimport type { DayPickerLocale, Matcher } from 'react-day-picker'\nimport { type Control, Controller, type FieldPath } from 'react-hook-form'\nimport type { FieldValues } from 'react-hook-form'\nimport { ErrorMonitor } from '@/components/error-monitor'\nimport {\n dateToString as defaultDateToString,\n stringToDate as defaultStringToDate\n} from '@/lib/utils'\n\nexport function CalendarField<TFieldValues extends FieldValues = FieldValues>({\n control,\n dateToString = defaultDateToString,\n disabled,\n inputId,\n inputName,\n label,\n locale,\n stringToDate = defaultStringToDate,\n ...props\n}: ComponentProps<typeof Field> & {\n control: Control<TFieldValues>\n dateToString?: (date: Date) => string\n disabled?: Matcher | Matcher[]\n inputId?: string\n inputName: FieldPath<TFieldValues>\n label?: string\n locale?: Partial<DayPickerLocale>\n stringToDate?: (string: string | undefined) => Date | undefined\n}) {\n return (\n <Controller\n control={control}\n name={inputName}\n render={({ field, fieldState }) => (\n <Field\n data-invalid={fieldState.invalid}\n {...props}\n >\n {label && (\n <FieldLabel htmlFor={inputId ?? inputName}>{label}</FieldLabel>\n )}\n\n <Calendar\n aria-invalid={fieldState.invalid}\n className=\"w-full rounded-md border\"\n disabled={disabled}\n fixedWeeks={true}\n id={inputId ?? (label ? inputName : undefined)}\n locale={locale}\n mode=\"single\"\n onSelect={(date) => field.onChange(date ? dateToString(date) : '')}\n selected={stringToDate(field.value)}\n />\n\n <ErrorMonitor error={fieldState.error} />\n </Field>\n )}\n />\n )\n}\n","import { Checkbox, Field, FieldLabel } from '@gmcode/react-ui'\nimport type { Checkbox as CheckboxPrimitive } from 'radix-ui'\nimport type { ComponentProps } from 'react'\nimport { type Control, Controller, type FieldPath } from 'react-hook-form'\nimport type { ControllerRenderProps, FieldValues } from 'react-hook-form'\nimport { ErrorMonitor } from '@/components/error-monitor'\n\nexport function CheckboxField<TFieldValues extends FieldValues = FieldValues>({\n control,\n disabled,\n inputId,\n inputName,\n label,\n onCheckedChange,\n orientation = 'horizontal',\n readOnly,\n uncheckedValue = '',\n value = 'true',\n ...props\n}: ComponentProps<typeof Field> & {\n control: Control<TFieldValues>\n disabled?: boolean\n inputId?: string\n inputName: FieldPath<TFieldValues>\n label?: string\n onCheckedChange?: (\n checked: CheckboxPrimitive.CheckedState,\n field: ControllerRenderProps<TFieldValues, FieldPath<TFieldValues>>\n ) => void\n readOnly?: boolean\n uncheckedValue?: string\n value?: string\n}) {\n return (\n <Controller\n control={control}\n disabled={disabled}\n name={inputName}\n render={({ field, fieldState }) => (\n <Field\n data-invalid={fieldState.invalid}\n orientation={orientation}\n {...props}\n >\n <Checkbox\n aria-invalid={fieldState.invalid}\n aria-readonly={readOnly}\n checked={field.value === value}\n className=\"aria-readonly:opacity-50\"\n disabled={field.disabled}\n id={inputId ?? (label ? inputName : undefined)}\n name={field.name}\n onBlur={field.onBlur}\n onCheckedChange={(checked) => {\n if (!readOnly) {\n field.onChange(checked === true ? value : uncheckedValue)\n if (onCheckedChange) onCheckedChange(checked, field)\n }\n }}\n ref={field.ref}\n value={value}\n />\n\n {label && (\n <FieldLabel htmlFor={inputId ?? inputName}>{label}</FieldLabel>\n )}\n\n <ErrorMonitor error={fieldState.error} />\n </Field>\n )}\n />\n )\n}\n","import { Field, FieldLabel, Input } from '@gmcode/react-ui'\nimport type {\n ChangeEventHandler,\n ComponentProps,\n HTMLInputAutoCompleteAttribute,\n HTMLInputTypeAttribute\n} from 'react'\nimport { type Control, Controller, type FieldPath } from 'react-hook-form'\nimport type { FieldValues } from 'react-hook-form'\nimport { ErrorMonitor } from '@/components/error-monitor'\n\nexport function InputField<TFieldValues extends FieldValues = FieldValues>({\n autoComplete,\n control,\n disabled,\n inputClassName,\n inputId,\n inputName,\n label,\n labelClassName,\n placeholder,\n readOnly,\n type,\n ...props\n}: Omit<ComponentProps<typeof Field>, 'onChange'> & {\n autoComplete?: HTMLInputAutoCompleteAttribute\n control: Control<TFieldValues>\n disabled?: boolean\n inputClassName?: string\n inputId?: string\n inputName: FieldPath<TFieldValues>\n label?: string\n labelClassName?: string\n onChange?: ChangeEventHandler<HTMLDivElement, HTMLInputElement>\n placeholder?: string\n readOnly?: boolean\n type?: HTMLInputTypeAttribute\n}) {\n return (\n <Controller\n control={control}\n disabled={disabled}\n name={inputName}\n render={({ field, fieldState }) => (\n <Field\n data-invalid={fieldState.invalid}\n {...props}\n >\n {label && (\n <FieldLabel\n className={labelClassName}\n htmlFor={inputId ?? inputName}\n >\n {label}\n </FieldLabel>\n )}\n\n <Input\n aria-invalid={fieldState.invalid}\n autoComplete={autoComplete}\n className={inputClassName}\n id={inputId ?? (label ? inputName : undefined)}\n placeholder={placeholder}\n readOnly={readOnly}\n type={type}\n {...field}\n />\n\n <ErrorMonitor error={fieldState.error} />\n </Field>\n )}\n />\n )\n}\n","import type { ComponentProps } from 'react'\nimport type { FieldValues } from 'react-hook-form'\nimport { InputField } from '@/components/input-field'\n\nexport function EmailField<TFieldValues extends FieldValues = FieldValues>({\n autoComplete = 'on',\n type = 'email',\n ...props\n}: ComponentProps<typeof InputField<TFieldValues>>) {\n return (\n <InputField\n autoComplete={autoComplete}\n type={type}\n {...props}\n />\n )\n}\n","import {\n FieldDescription,\n FieldLabel,\n FieldSet,\n Label,\n RadioGroup,\n RadioGroupItem\n} from '@gmcode/react-ui'\nimport type { ComponentProps, FC, SVGProps } from 'react'\nimport { type Control, Controller, type FieldPath } from 'react-hook-form'\nimport type { FieldValues } from 'react-hook-form'\nimport { ErrorMonitor } from '@/components/error-monitor'\nimport type { Option } from '@/types'\n\nexport function FancyRadioField<\n TFieldValues extends FieldValues = FieldValues\n>({\n control,\n defaultValue,\n description,\n disabled,\n groupId,\n inputName,\n label,\n options,\n ...props\n}: ComponentProps<typeof FieldSet> & {\n control: Control<TFieldValues>\n defaultValue: string\n description?: string\n disabled?: boolean\n groupId?: string\n inputName: FieldPath<TFieldValues>\n label?: string\n options: Array<Option & { Icon?: FC<SVGProps<SVGSVGElement>> }>\n}) {\n return (\n <Controller\n control={control}\n disabled={disabled}\n name={inputName}\n render={({ field, fieldState }) => (\n <FieldSet\n data-invalid={fieldState.invalid}\n {...props}\n >\n {label && (\n <FieldLabel htmlFor={groupId ?? inputName}>{label}</FieldLabel>\n )}\n\n {description && <FieldDescription>{description}</FieldDescription>}\n\n <ErrorMonitor error={fieldState.error} />\n\n <RadioGroup\n defaultValue={defaultValue}\n disabled={field.disabled}\n id={groupId ?? (label ? inputName : undefined)}\n name={field.name}\n onBlur={field.onBlur}\n onValueChange={field.onChange}\n ref={field.ref}\n >\n {options.map((option) => (\n <Label\n className=\"rounded-md border ring-ring/50 transition-all hover:bg-accent/50 has-focus-visible:ring-[3px]\"\n data-slot=\"field-label\"\n key={option.key ?? option.id ?? option.value}\n >\n <div className=\"flex w-full items-center gap-3 rounded-md p-3 transition-all has-aria-checked:border-l-8 has-aria-checked:border-ring\">\n <RadioGroupItem\n className=\"sr-only\"\n id={option.id}\n value={option.value}\n />\n {option.Icon && <option.Icon />}\n {option.label}\n </div>\n </Label>\n ))}\n </RadioGroup>\n </FieldSet>\n )}\n />\n )\n}\n","import { useForm, type RouteDefinition } from '@gmcode/inertia-hook-form'\nimport { cn, flash } from '@gmcode/react-ui'\nimport type { Ruleset, SanitizedValues, Schema } from '@gmcode/tsv-input'\nimport type {\n CancelTokenCallback,\n Errors,\n FormDataErrors,\n GlobalEventCallback,\n Method,\n RequestPayload\n} from '@inertiajs/core'\nimport type { ComponentProps, ReactNode } from 'react'\nimport type { FieldValues, UseFormReturn } from 'react-hook-form'\nimport { ErrorMonitor } from '@/components/error-monitor'\n\ntype RenderFN<TValues extends FieldValues> = ({\n errors,\n form,\n loading\n}: {\n errors: FormDataErrors<object>\n form: UseFormReturn<TValues>\n loading: boolean\n}) => ReactNode\n\nexport function Form<\n TRuleset extends Ruleset,\n TValues extends SanitizedValues<TRuleset>\n>({\n children,\n className,\n defaults = {},\n onBefore,\n onBeforeUpdate,\n onCancel,\n onCancelToken,\n onError,\n onFinish,\n onFlash,\n onPrefetched,\n onPrefetching,\n onProgress,\n onStart,\n onSuccess,\n preserveScroll = true,\n resetOnSuccess = true,\n rootError: displayRootError = 'flash',\n route,\n schema,\n setDefaultsOnSuccess = false,\n ...props\n}: Omit<\n ComponentProps<'form'>,\n 'action' | 'children' | 'method' | 'onSubmit'\n> & {\n children: RenderFN<TValues>\n defaults?: Partial<TValues>\n onBefore?: GlobalEventCallback<'before', RequestPayload>\n onBeforeUpdate?: GlobalEventCallback<'beforeUpdate', RequestPayload>\n onCancel?: GlobalEventCallback<'cancel', RequestPayload>\n onCancelToken?: CancelTokenCallback\n onError?: GlobalEventCallback<'error', RequestPayload>\n onFinish?: GlobalEventCallback<'finish', RequestPayload>\n onFlash?: GlobalEventCallback<'flash', RequestPayload>\n onPrefetched?: GlobalEventCallback<'prefetched', RequestPayload>\n onPrefetching?: GlobalEventCallback<'prefetching', RequestPayload>\n onProgress?: GlobalEventCallback<'progress', RequestPayload>\n onStart?: GlobalEventCallback<'start', RequestPayload>\n onSuccess?: GlobalEventCallback<'success', RequestPayload>\n preserveScroll?: boolean\n /**\n * Reset input values to their defaults on success.\n *\n * @defaultValue `true`\n */\n resetOnSuccess?: boolean\n /**\n * How to display the root error from inertia.\n *\n * - `\"flash\"` - use the Toaster component\n * - `\"monitor\"` - use the ErrorMonitor component\n * - `\"none\"` - don't display the root error\n *\n * @defaultValue `\"flash\"`\n */\n rootError?: 'flash' | 'monitor' | 'none'\n route: RouteDefinition<Method>\n schema: Schema<TRuleset>\n /**\n * Set the submitted values as default values on success.\n *\n * @defaultValue `false`\n */\n setDefaultsOnSuccess?: boolean\n}) {\n function onErrorWithToast(errors: Errors) {\n if (errors.root && displayRootError === 'flash') {\n flash({ level: 'error', title: errors.root })\n }\n\n if (onError) {\n onError(errors)\n }\n }\n\n const { errors, form, loading, onSubmit } = useForm({\n defaults,\n onBefore,\n onBeforeUpdate,\n onCancel,\n onCancelToken,\n onError: onErrorWithToast,\n onFinish,\n onFlash,\n onPrefetched,\n onPrefetching,\n onProgress,\n onStart,\n onSuccess,\n preserveScroll,\n resetOnSuccess,\n route,\n schema,\n setDefaultsOnSuccess\n })\n\n return (\n <form\n action={route.url}\n className={cn('grid gap-6', className)}\n method={route.method}\n onSubmit={onSubmit}\n {...props}\n >\n {children({\n errors,\n form,\n loading\n })}\n\n {displayRootError === 'monitor' && (\n <ErrorMonitor error={{ message: errors.root }} />\n )}\n </form>\n )\n}\n","import { cn } from '@gmcode/react-ui'\nimport type { ComponentProps } from 'react'\nimport type { FieldValues } from 'react-hook-form'\nimport { InputField } from '@/components/input-field'\n\nexport function HiddenField<TFieldValues extends FieldValues = FieldValues>({\n autoComplete = 'off',\n className,\n type = 'hidden',\n ...props\n}: ComponentProps<typeof InputField<TFieldValues>>) {\n return (\n <InputField\n autoComplete={autoComplete}\n className={cn('hidden', className)}\n type={type}\n {...props}\n />\n )\n}\n","import { Checkbox, Field, Label, cn } from '@gmcode/react-ui'\nimport type { Checkbox as CheckboxPrimitive } from 'radix-ui'\nimport type { ComponentProps } from 'react'\nimport { type Control, Controller, type FieldPath } from 'react-hook-form'\nimport type { ControllerRenderProps, FieldValues } from 'react-hook-form'\nimport { ErrorMonitor } from '@/components/error-monitor'\n\nexport function InfoCheckboxField<\n TFieldValues extends FieldValues = FieldValues\n>({\n children,\n className,\n control,\n disabled,\n inputId,\n inputName,\n label,\n onCheckedChange,\n orientation = 'horizontal',\n readOnly,\n text,\n uncheckedValue = '',\n value = 'true',\n ...props\n}: ComponentProps<typeof Field> & {\n control: Control<TFieldValues>\n disabled?: boolean\n inputId?: string\n inputName: FieldPath<TFieldValues>\n label?: string\n onCheckedChange?: (\n checked: CheckboxPrimitive.CheckedState,\n field: ControllerRenderProps<TFieldValues, FieldPath<TFieldValues>>\n ) => void\n readOnly?: boolean\n text?: string\n uncheckedValue?: string\n value?: string\n}) {\n return (\n <Controller\n control={control}\n disabled={disabled}\n name={inputName}\n render={({ field, fieldState }) => (\n <Field\n className={cn('block', className)}\n data-invalid={fieldState.invalid}\n orientation={orientation}\n {...props}\n >\n <Label\n className=\"flex items-start gap-3 rounded-lg border p-3 hover:bg-accent/50 has-aria-checked:border-info-foreground has-aria-checked:bg-info\"\n data-slot=\"field-label\"\n >\n <Checkbox\n aria-invalid={fieldState.invalid}\n aria-readonly={readOnly}\n checked={field.value === value}\n className=\"aria-readonly:opacity-50 data-[state=checked]:border-info-foreground data-[state=checked]:bg-info-foreground data-[state=checked]:text-white dark:data-[state=checked]:border-info-foreground dark:data-[state=checked]:bg-info-foreground\"\n disabled={field.disabled}\n id={inputId}\n name={field.name}\n onBlur={field.onBlur}\n onCheckedChange={(checked) => {\n if (!readOnly) {\n field.onChange(checked === true ? value : uncheckedValue)\n if (onCheckedChange) onCheckedChange(checked, field)\n }\n }}\n ref={field.ref}\n value={value}\n />\n\n <div className=\"grid gap-1.5 font-normal\">\n <p className=\"text-sm leading-none font-medium\">{label}</p>\n {text ? (\n <p className=\"text-sm text-muted-foreground\">{text}</p>\n ) : (\n children\n )}\n <ErrorMonitor error={fieldState.error} />\n </div>\n </Label>\n </Field>\n )}\n />\n )\n}\n","import {\n Button,\n Field,\n FieldDescription,\n FieldLabel,\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue\n} from '@gmcode/react-ui'\nimport { X } from 'lucide-react'\nimport type {\n ComponentProps,\n HTMLInputAutoCompleteAttribute,\n HTMLInputTypeAttribute\n} from 'react'\nimport { type Control, Controller, type FieldPath } from 'react-hook-form'\nimport type {\n FieldPathValue,\n FieldValues,\n UseFormSetValue\n} from 'react-hook-form'\nimport { useTranslation } from 'react-i18next'\nimport { ErrorMonitor } from '@/components/error-monitor'\nimport type { Option } from '@/types'\n\nexport function NullableSelectField<\n TFieldValues extends FieldValues = FieldValues\n>({\n autoComplete,\n control,\n description,\n disabled,\n inputId,\n inputName,\n label,\n options,\n placeholder,\n setValue,\n ...props\n}: ComponentProps<typeof Field> & {\n autoComplete?: HTMLInputAutoCompleteAttribute\n control: Control<TFieldValues>\n description?: string\n disabled?: boolean\n inputId?: string\n inputName: FieldPath<TFieldValues>\n label?: string\n options: Option[]\n placeholder?: string\n setValue: UseFormSetValue<TFieldValues>\n type?: HTMLInputTypeAttribute\n}) {\n // i18n\n const { t } = useTranslation('forms')\n\n return (\n <Controller\n control={control}\n disabled={disabled}\n name={inputName}\n render={({ field, fieldState }) => (\n <Field\n data-invalid={fieldState.invalid}\n {...props}\n >\n {label && (\n <FieldLabel htmlFor={inputId ?? inputName}>{label}</FieldLabel>\n )}\n\n <div className=\"flex items-end gap-4\">\n <Select\n autoComplete={autoComplete}\n disabled={field.disabled}\n name={field.name}\n onValueChange={field.onChange}\n value={field.value}\n >\n <SelectTrigger\n aria-invalid={fieldState.invalid}\n className=\"flex-1 overflow-hidden\"\n id={inputId ?? (label ? inputName : undefined)}\n >\n <SelectValue placeholder={placeholder} />\n </SelectTrigger>\n <SelectContent>\n {options.map((option) => (\n <SelectItem\n id={option.id}\n key={option.key ?? option.id ?? option.value}\n value={option.value}\n >\n {option.label}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n\n <Button\n aria-label={t(($) => $.reset)}\n className=\"flex-none\"\n onClick={() =>\n setValue(\n inputName,\n '' as FieldPathValue<TFieldValues, FieldPath<TFieldValues>>\n )\n }\n type=\"button\"\n variant=\"outline\"\n >\n <X />\n </Button>\n </div>\n\n {description && <FieldDescription>{description}</FieldDescription>}\n\n <ErrorMonitor error={fieldState.error} />\n </Field>\n )}\n />\n )\n}\n","import {\n Field,\n FieldLabel,\n InputGroup,\n InputGroupAddon,\n InputGroupButton,\n InputGroupInput\n} from '@gmcode/react-ui'\nimport { Minus, Plus } from 'lucide-react'\nimport type {\n ComponentProps,\n HTMLInputAutoCompleteAttribute,\n HTMLInputTypeAttribute\n} from 'react'\nimport { type Control, Controller, type FieldPath } from 'react-hook-form'\nimport type {\n FieldPathValue,\n FieldValues,\n UseFormSetValue\n} from 'react-hook-form'\nimport { useTranslation } from 'react-i18next'\nimport { ErrorMonitor } from '@/components/error-monitor'\n\nfunction stepInput(\n original: string,\n add: boolean,\n step?: number,\n min?: number,\n max?: number\n) {\n let parsed = Number(original)\n\n if (isNaN(parsed)) {\n return ''\n }\n\n if (add) {\n parsed += step === undefined ? 1 : step\n } else {\n parsed -= step === undefined ? 1 : step\n }\n\n if (min !== undefined) {\n parsed = Math.max(parsed, min)\n }\n\n if (max !== undefined) {\n parsed = Math.min(parsed, max)\n }\n\n return parsed.toString()\n}\n\nexport function NumericField<TFieldValues extends FieldValues = FieldValues>({\n autoComplete,\n control,\n disabled,\n inputId,\n inputMode = 'numeric',\n inputName,\n label,\n placeholder,\n type,\n ui,\n ...props\n}: ComponentProps<typeof Field> & {\n autoComplete?: HTMLInputAutoCompleteAttribute\n control: Control<TFieldValues>\n disabled?: boolean\n inputId?: string\n inputMode?: 'decimal' | 'numeric'\n inputName: FieldPath<TFieldValues>\n label?: string\n placeholder?: string\n type?: HTMLInputTypeAttribute\n ui?: {\n max?: number\n min?: number\n setValue: UseFormSetValue<TFieldValues>\n step?: number\n }\n}) {\n // i18n\n const { t } = useTranslation('forms')\n\n function stepValue(value: string, add: boolean) {\n if (ui?.setValue) {\n ui.setValue(\n inputName,\n stepInput(value, add, ui.step, ui.min, ui.max) as FieldPathValue<\n TFieldValues,\n FieldPath<TFieldValues>\n >,\n { shouldValidate: true }\n )\n }\n }\n\n return (\n <Controller\n control={control}\n disabled={disabled}\n name={inputName}\n render={({ field, fieldState }) => (\n <Field\n data-invalid={fieldState.invalid}\n {...props}\n >\n {label && (\n <FieldLabel htmlFor={inputId ?? inputName}>{label}</FieldLabel>\n )}\n\n <InputGroup>\n <InputGroupInput\n aria-invalid={fieldState.invalid}\n autoComplete={autoComplete}\n id={inputId ?? (label ? inputName : undefined)}\n inputMode={inputMode}\n placeholder={placeholder}\n type={type}\n {...field}\n />\n\n {ui && (\n <InputGroupAddon align=\"inline-end\">\n <InputGroupButton\n aria-label={t(($) => $.decrease)}\n disabled={disabled}\n onClick={() => stepValue(field.value, false)}\n size=\"icon-xs\"\n >\n <Minus />\n </InputGroupButton>\n\n <InputGroupButton\n aria-label={t(($) => $.increase)}\n disabled={disabled}\n onClick={() => stepValue(field.value, true)}\n size=\"icon-xs\"\n >\n <Plus />\n </InputGroupButton>\n </InputGroupAddon>\n )}\n </InputGroup>\n\n <ErrorMonitor error={fieldState.error} />\n </Field>\n )}\n />\n )\n}\n","import type { ComponentProps } from 'react'\nimport type { FieldValues } from 'react-hook-form'\nimport { InputField } from '@/components/input-field'\n\nexport function PasswordField<TFieldValues extends FieldValues = FieldValues>({\n autoComplete = 'off',\n type = 'password',\n ...props\n}: ComponentProps<typeof InputField<TFieldValues>>) {\n return (\n <InputField\n autoComplete={autoComplete}\n type={type}\n {...props}\n />\n )\n}\n","import {\n Field,\n FieldDescription,\n FieldLabel,\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue\n} from '@gmcode/react-ui'\nimport type {\n ComponentProps,\n HTMLInputAutoCompleteAttribute,\n HTMLInputTypeAttribute\n} from 'react'\nimport { type Control, Controller, type FieldPath } from 'react-hook-form'\nimport type { FieldValues } from 'react-hook-form'\nimport { ErrorMonitor } from '@/components/error-monitor'\nimport type { Option } from '@/types'\n\nexport function SelectField<TFieldValues extends FieldValues = FieldValues>({\n autoComplete,\n control,\n description,\n disabled,\n inputId,\n inputName,\n label,\n options,\n placeholder,\n ...props\n}: ComponentProps<typeof Field> & {\n autoComplete?: HTMLInputAutoCompleteAttribute\n control: Control<TFieldValues>\n description?: string\n disabled?: boolean\n inputId?: string\n inputName: FieldPath<TFieldValues>\n label?: string\n options: Option[]\n placeholder?: string\n type?: HTMLInputTypeAttribute\n}) {\n return (\n <Controller\n control={control}\n disabled={disabled}\n name={inputName}\n render={({ field, fieldState }) => (\n <Field\n data-invalid={fieldState.invalid}\n {...props}\n >\n {label && (\n <FieldLabel htmlFor={inputId ?? inputName}>{label}</FieldLabel>\n )}\n\n <Select\n autoComplete={autoComplete}\n disabled={field.disabled}\n name={field.name}\n onValueChange={field.onChange}\n value={field.value}\n >\n <SelectTrigger\n aria-invalid={fieldState.invalid}\n id={inputId ?? (label ? inputName : undefined)}\n >\n <SelectValue placeholder={placeholder} />\n </SelectTrigger>\n <SelectContent>\n {options.map((option) => (\n <SelectItem\n id={option.id}\n key={option.key ?? option.id ?? option.value}\n value={option.value}\n >\n {option.label}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n\n {description && <FieldDescription>{description}</FieldDescription>}\n\n <ErrorMonitor error={fieldState.error} />\n </Field>\n )}\n />\n )\n}\n","import { Button, Spinner, cn } from '@gmcode/react-ui'\nimport type { ComponentProps } from 'react'\nimport { useTranslation } from 'react-i18next'\n\nexport function Submit({\n label,\n loading = false,\n type = 'submit',\n ...props\n}: ComponentProps<typeof Button> & {\n label?: string\n loading?: boolean\n}) {\n // i18n\n const { t } = useTranslation('forms')\n\n return (\n <Button\n disabled={loading}\n type={type}\n {...props}\n >\n <div className=\"relative\">\n <span className={cn({ invisible: loading })}>\n {label ?? t(($) => $.submit)}\n </span>\n <Spinner\n className={cn(\n 'trans absolute top-1/2 left-1/2 hidden -translate-x-1/2 -translate-y-1/2',\n { block: loading }\n )}\n />\n </div>\n </Button>\n )\n}\n","import { Field, FieldLabel, Switch } from '@gmcode/react-ui'\nimport type { Checkbox as CheckboxPrimitive } from 'radix-ui'\nimport type { ComponentProps } from 'react'\nimport { type Control, Controller, type FieldPath } from 'react-hook-form'\nimport type { ControllerRenderProps, FieldValues } from 'react-hook-form'\nimport { ErrorMonitor } from '@/components/error-monitor'\n\nexport function SwitchField<TFieldValues extends FieldValues = FieldValues>({\n control,\n disabled,\n inputId,\n inputName,\n label,\n onCheckedChange,\n orientation = 'horizontal',\n readOnly,\n uncheckedValue = '',\n value = 'true',\n ...props\n}: ComponentProps<typeof Field> & {\n control: Control<TFieldValues>\n disabled?: boolean\n inputId?: string\n inputName: FieldPath<TFieldValues>\n label?: string\n onCheckedChange?: (\n checked: CheckboxPrimitive.CheckedState,\n field: ControllerRenderProps<TFieldValues, FieldPath<TFieldValues>>\n ) => void\n readOnly?: boolean\n uncheckedValue?: string\n value?: string\n}) {\n return (\n <Controller\n control={control}\n disabled={disabled}\n name={inputName}\n render={({ field, fieldState }) => (\n <Field\n data-invalid={fieldState.invalid}\n orientation={orientation}\n {...props}\n >\n <Switch\n aria-invalid={fieldState.invalid}\n aria-readonly={readOnly}\n checked={field.value === value}\n className=\"aria-readonly:opacity-50\"\n disabled={field.disabled}\n id={inputId ?? (label ? inputName : undefined)}\n name={field.name}\n onBlur={field.onBlur}\n onCheckedChange={(checked) => {\n if (!readOnly) {\n field.onChange(checked === true ? value : uncheckedValue)\n if (onCheckedChange) onCheckedChange(checked, field)\n }\n }}\n ref={field.ref}\n value={value}\n />\n\n {label && (\n <FieldLabel htmlFor={inputId ?? inputName}>{label}</FieldLabel>\n )}\n\n <ErrorMonitor error={fieldState.error} />\n </Field>\n )}\n />\n )\n}\n","import type { ComponentProps } from 'react'\nimport type { FieldValues } from 'react-hook-form'\nimport { InputField } from '@/components/input-field'\n\nexport function TextField<TFieldValues extends FieldValues = FieldValues>({\n autoComplete = 'on',\n type = 'text',\n ...props\n}: ComponentProps<typeof InputField<TFieldValues>>) {\n return (\n <InputField\n autoComplete={autoComplete}\n type={type}\n {...props}\n />\n )\n}\n","import { Field, FieldLabel, TextareaAutosize, cn } from '@gmcode/react-ui'\nimport type { ComponentProps } from 'react'\nimport { type Control, Controller, type FieldPath } from 'react-hook-form'\nimport type { FieldValues } from 'react-hook-form'\nimport type { TextareaHeightChangeMeta } from 'react-textarea-autosize'\nimport { ErrorMonitor } from '@/components/error-monitor'\n\nexport function TextareaField<TFieldValues extends FieldValues = FieldValues>({\n cacheMeasurements,\n control,\n inputId,\n inputName,\n label,\n maxRows,\n minRows,\n onHeightChange,\n placeholder,\n resize = 'none',\n ...props\n}: ComponentProps<typeof Field> & {\n cacheMeasurements?: boolean\n control: Control<TFieldValues>\n inputId?: string\n inputName: FieldPath<TFieldValues>\n label?: string\n maxRows?: number\n minRows?: number\n onHeightChange?: (height: number, meta: TextareaHeightChangeMeta) => void\n placeholder?: string\n resize?: 'both' | 'none' | 'x' | 'y'\n}) {\n return (\n <Controller\n control={control}\n name={inputName}\n render={({ field, fieldState }) => (\n <Field\n data-invalid={fieldState.invalid}\n {...props}\n >\n {label && (\n <FieldLabel htmlFor={inputId ?? inputName}>{label}</FieldLabel>\n )}\n\n <TextareaAutosize\n aria-invalid={fieldState.invalid}\n autoComplete=\"off\"\n cacheMeasurements={cacheMeasurements}\n className={cn({\n resize: resize === 'both',\n 'resize-none': resize === 'none',\n 'resize-x': resize === 'x',\n 'resize-y': resize === 'y'\n })}\n id={inputId ?? (label ? inputName : undefined)}\n maxRows={maxRows}\n minRows={minRows}\n onHeightChange={onHeightChange}\n placeholder={placeholder}\n {...field}\n />\n\n <ErrorMonitor error={fieldState.error} />\n </Field>\n )}\n />\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAMA,MAAM,OAAc,eAAe;CACjC,aAAa;CACb,eAAe,EAAE,aA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eAAe,MACf,OAAO,QACP,GAAG,SAC+C;CAClD,OACE,oBAAC,YAAD;EACgB;EACR;EACN,GAAI;CAAM;AAGhB;;;;ACTA,SAAgB,cAA8D,EAC5E,mBACA,SACA,SACA,WACA,OACA,SACA,SACA,gBACA,aACA,SAAS,QACT,GAAG,SAYF;CACD,OACE,oBAAC,YAAD;EACW;EACT,MAAM;EACN,SAAS,EAAE,OAAO,iBAChB,qBAAC,OAAD;GACE,gBAAc,WAAW;GACzB,GAAI;aAFN;IAIG,SACC,oBAAC,YAAD;KAAY,SAAS,WAAW;eAAY;IAAkB;IAGhE,oBAAC,kBAAD;KACE,gBAAc,WAAW;KACzB,cAAa;KACM;KACnB,WAAW,GAAG;MACZ,QAAQ,WAAW;MACnB,eAAe,WAAW;MAC1B,YAAY,WAAW;MACvB,YAAY,WAAW;KACzB,CAAC;KACD,IAAI,YAAY,QAAQ,YAAY;KAC3B;KACA;KACO;KACH;KACb,GAAI;IAAM;IAGZ,oBAAC,cAAD,EAAc,OAAO,WAAW,MAAM;GACjC;;CACP;AAGR"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gmcode/forms",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Fully functional inertia react forms with client side validations.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"i18next",
|
|
@@ -32,15 +32,14 @@
|
|
|
32
32
|
"./package.json": "./package.json"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@gmcode/
|
|
35
|
+
"@gmcode/inertia-hook-form": "0.0.2",
|
|
36
|
+
"@gmcode/react-ui": "0.4.2",
|
|
36
37
|
"@gmcode/tsv-hookform": "0.1.8",
|
|
37
|
-
"@gmcode/tsv-input": "0.
|
|
38
|
-
"i18next": "^26.3.4",
|
|
38
|
+
"@gmcode/tsv-input": "0.4.0",
|
|
39
39
|
"lucide-react": "^1.16.0",
|
|
40
|
-
"radix-ui": "^1.
|
|
40
|
+
"radix-ui": "^1.6.7",
|
|
41
41
|
"react-day-picker": "^10.0.1",
|
|
42
42
|
"react-hook-form": "^7.71.2",
|
|
43
|
-
"react-i18next": "^17.0.8",
|
|
44
43
|
"react-textarea-autosize": "^8.5.9"
|
|
45
44
|
},
|
|
46
45
|
"devDependencies": {
|
|
@@ -61,12 +60,14 @@
|
|
|
61
60
|
"peerDependencies": {
|
|
62
61
|
"@inertiajs/core": "^3.5.0",
|
|
63
62
|
"@inertiajs/react": "^3.5.0",
|
|
63
|
+
"i18next": "^26.3.4",
|
|
64
64
|
"react": "^19.2.7",
|
|
65
|
-
"react-dom": "^19.2.7"
|
|
65
|
+
"react-dom": "^19.2.7",
|
|
66
|
+
"react-i18next": "^17.0.8"
|
|
66
67
|
},
|
|
67
68
|
"scripts": {
|
|
68
69
|
"build": "vp pack",
|
|
69
70
|
"test": "vp test run --coverage && badge",
|
|
70
|
-
"test:ui": "vp test watch --browser.headless=false"
|
|
71
|
+
"test:ui": "vp test watch --browser.headless=false --standalone"
|
|
71
72
|
}
|
|
72
73
|
}
|