@vendure/dashboard 3.7.4-master-202609290215 → 3.7.4-master-202609300217
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/bundle/chunks/{2SSKDMRQ-DvYnkA4d.js → 2SSKDMRQ-BpCuVzuI.js} +2 -2
- package/dist/bundle/chunks/{AP7HFJJL-CjVnFK_p.js → AP7HFJJL-eTX6nwhe.js} +1 -1
- package/dist/bundle/chunks/{WDYDFRGG-BNhQ-gUX.js → WDYDFRGG-D09CtNqO.js} +2 -2
- package/dist/bundle/chunks/{locale-b6gE3S6H.js → locale-DvfAgkVa.js} +1 -1
- package/dist/bundle/chunks/{main-C0yRaSy4.js → main-eE-Qo1Dr.js} +3 -3
- package/dist/bundle/chunks/{use-job-queue-polling-BGkZa_AL.js → use-job-queue-polling-1x9ESPDt.js} +11 -10
- package/dist/bundle/lib.js +2 -2
- package/dist/bundle/main.js +2 -2
- package/package.json +3 -3
- package/src/lib/framework/form-engine/form-schema-tools.spec.ts +60 -4
- package/src/lib/framework/form-engine/form-schema-tools.ts +20 -4
- package/src/lib/framework/form-engine/use-generated-form.spec.tsx +133 -0
- package/src/lib/framework/form-engine/use-generated-form.tsx +8 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as createLocalStorage, T as THEME_PREFERENCE, P as PiPProvider, a as ThemeContext, b as ParentPanel, C as ContentView, Q as QueryDevtoolsContext } from "./AP7HFJJL-
|
|
2
|
-
import { g as getPreferredColorScheme, c as createMemo, a as createComponent } from "./main-
|
|
1
|
+
import { c as createLocalStorage, T as THEME_PREFERENCE, P as PiPProvider, a as ThemeContext, b as ParentPanel, C as ContentView, Q as QueryDevtoolsContext } from "./AP7HFJJL-eTX6nwhe.js";
|
|
2
|
+
import { g as getPreferredColorScheme, c as createMemo, a as createComponent } from "./main-eE-Qo1Dr.js";
|
|
3
3
|
var DevtoolsPanelComponent = (props) => {
|
|
4
4
|
const [localStore, setLocalStore] = createLocalStorage({
|
|
5
5
|
prefix: "TanstackQueryDevtools"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { b as createContext, d as createSignal, o as onMount, e as createEffect, c as createMemo, a as createComponent, P as Portal, m as memo, S as Show, t as template, i as insert, f as createRenderEffect, h as className, j as clearDelegatedEvents, k as delegateEvents, u as useContext, l as onCleanup, s as sortFns, n as mutationSortFns, p as on, q as setAttribute, r as getSidedProp, v as use, w as convertRemToPixels, x as createUniqueId, y as batch, z as getQueryStatusLabel, A as getMutationStatusColor, B as getQueryStatusColor, C as getQueryStatusColorByLabel, D as displayValue, F as For, E as untrack, $ as $TRACK, G as useTransition, H as spread, I as mergeProps, J as createRoot, K as serialize, L as Index, M as updateNestedDataByPath, N as addEventListener, O as stringify, Q as Match, R as Switch, T as deleteNestedDataByPath, U as splitProps, V as Dynamic, W as createComputed } from "./main-
|
|
1
|
+
import { b as createContext, d as createSignal, o as onMount, e as createEffect, c as createMemo, a as createComponent, P as Portal, m as memo, S as Show, t as template, i as insert, f as createRenderEffect, h as className, j as clearDelegatedEvents, k as delegateEvents, u as useContext, l as onCleanup, s as sortFns, n as mutationSortFns, p as on, q as setAttribute, r as getSidedProp, v as use, w as convertRemToPixels, x as createUniqueId, y as batch, z as getQueryStatusLabel, A as getMutationStatusColor, B as getQueryStatusColor, C as getQueryStatusColorByLabel, D as displayValue, F as For, E as untrack, $ as $TRACK, G as useTransition, H as spread, I as mergeProps, J as createRoot, K as serialize, L as Index, M as updateNestedDataByPath, N as addEventListener, O as stringify, Q as Match, R as Switch, T as deleteNestedDataByPath, U as splitProps, V as Dynamic, W as createComputed } from "./main-eE-Qo1Dr.js";
|
|
2
2
|
var isNonNullable = (i2) => i2 != null;
|
|
3
3
|
var filterNonNullable = (arr) => arr.filter(isNonNullable);
|
|
4
4
|
function chain(callbacks) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as createLocalStorage, T as THEME_PREFERENCE, P as PiPProvider, a as ThemeContext, D as Devtools, Q as QueryDevtoolsContext } from "./AP7HFJJL-
|
|
2
|
-
import { g as getPreferredColorScheme, c as createMemo, a as createComponent } from "./main-
|
|
1
|
+
import { c as createLocalStorage, T as THEME_PREFERENCE, P as PiPProvider, a as ThemeContext, D as Devtools, Q as QueryDevtoolsContext } from "./AP7HFJJL-eTX6nwhe.js";
|
|
2
|
+
import { g as getPreferredColorScheme, c as createMemo, a as createComponent } from "./main-eE-Qo1Dr.js";
|
|
3
3
|
var DevtoolsComponent = (props) => {
|
|
4
4
|
const [localStore, setLocalStore] = createLocalStorage({
|
|
5
5
|
prefix: "TanstackQueryDevtools"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { op as normalizeDates$1, oq as startOfWeek$1, or as buildFormatLongFn$1, os as buildLocalizeFn$1, ot as buildMatchFn$1, ou as buildMatchPatternFn$1, ov as toDate$1, ow as match$1l, ox as localize$1n, oy as formatRelative$1n, oz as formatDistance$1n, oA as DateLib, oB as enUS$1 } from "./use-job-queue-polling-
|
|
1
|
+
import { op as normalizeDates$1, oq as startOfWeek$1, or as buildFormatLongFn$1, os as buildLocalizeFn$1, ot as buildMatchFn$1, ou as buildMatchPatternFn$1, ov as toDate$1, ow as match$1l, ox as localize$1n, oy as formatRelative$1n, oz as formatDistance$1n, oA as DateLib, oB as enUS$1 } from "./use-job-queue-polling-1x9ESPDt.js";
|
|
2
2
|
function isSameWeek$1(laterDate, earlierDate, options2) {
|
|
3
3
|
const [laterDate_, earlierDate_] = normalizeDates$1(
|
|
4
4
|
options2?.in,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { c as createLucideIcon, nu as loadI18nMessages, nE as UserSettingsProvider, nF as ThemeProvider, nG as AuthProvider, nH as ServerConfigProvider, nI as ChannelProvider, nJ as AlertsProvider, l5 as CustomProviders, df as objectType, du as stringType, mV as useAuth, gv as LoginForm, hq as LoginBranding, gk as AppLayout, nK as endOfDay, nL as startOfMonth, bD as useUserSettings, nc as usePermissions, kx as getDashboardWidgetRegistry, eL as Page, eM as PageTitle, eN as PageActionBar, me as ActionBarItem, gi as DateRangePicker, dP as Button, eP as PageLayout, mp as FullWidthPageBlock, kA as WidgetFiltersProvider, i$ as GridLayout, ky as getDashboardWidget, nb as usePaginatedList, mF as api, kV as getMutationName, fA as DataTableBulkActionItem, nM as Trash, mN as graphql, gf as useGeneratedColumns, fU as DataTable, gY as CountrySelector, jt as Sheet, jA as SheetTrigger, jv as SheetContent, jy as SheetHeader, jz as SheetTitle, jw as SheetDescription, jm as ScrollArea, mx as ListPage, dQ as Plus, h3 as DetailPageButton, eX as BooleanDisplayBadge, dR as Badge, mS as setSettingsStoreValueDocument, nN as createColumnHelper, gX as CopyableText, jV as Switch$1, iE as Dialog, iM as DialogTrigger, iG as DialogContent, iJ as DialogHeader, iD as DialogTitle, iH as DialogDescription, eZ as JsonViewer, iI as DialogFooter, dO as Input, n7 as useLocalFormat, bR as DropdownMenu, bS as DropdownMenuTrigger, bT as Ellipsis, bV as DropdownMenuContent, bW as DropdownMenuItem, nO as Clock, nP as Check, nQ as RefreshCw, nR as ChevronDown, nS as EllipsisVertical, bF as Select, bG as SelectTrigger, bI as SelectValue, bJ as SelectContent, bK as SelectItem, gJ as AssignToChannelBulkAction, mW as useChannel, hs as RemoveFromChannelBulkAction, mJ as configurableOperationFragment, nq as LS_KEY_SHIPPING_TEST_ADDRESS, hR as AccordionItem, hS as AccordionTrigger, hQ as AccordionContent, i_ as Form, eS as FormFieldWrapper, nT as AddressCountrySelect, nr as LS_KEY_SHIPPING_TEST_ORDER, nU as useReactTable, nV as getCoreRowModel, jW as Table, k0 as TableHeader, k1 as TableRow, j$ as TableHead, nW as flexRender, jX as TableBody, jZ as TableCell, hr as ProductVariantSelector, hJ as VendureImage, bZ as Trash2, e$ as Money, ij as Card, ip as CardHeader, iq as CardTitle, il as CardContent, i3 as Alert, i4 as AlertDescription, hP as Accordion, hG as RichTextDescriptionCell, nt as SUPER_ADMIN_ROLE_CODE, nl as CUSTOMER_ROLE_CODE, nX as Layers, gP as ChannelCodeLabel, hz as RoleCodeLabel, mH as getEntityDuplicatorsDocument, nY as getInitialConfigArgValue, gS as ConfigurableOperationInput, mG as duplicateEntityDocument, nZ as Copy, h5 as ErrorPage, kI as extendDetailFormQuery, kP as addCustomFields, mA as getDetailQueryOptions, eJ as useDetailPage, eQ as PageBlock, eR as DetailFormGrid, jd as PasswordInput, eU as CustomFieldsPageBlock, mI as assetFragment, h7 as FacetValueSelector, h6 as FacetValueChip, gL as usePriceFactor, fF as FacetValueFacetedFilter, hC as StockLevelLabel, mM as errorResultFragment, mL as configurableOperationDefFragment, bC as useServerConfig, hD as CustomerCell, hE as OrderStateCell, hF as OrderMoneyCell, eH as NEW_ENTITY_PATH, hh as LanguageSelector, mP as schemaLanguageCodes, fb as NumberInput, hn as PaginatedListDataTable, hm as PaginatedListDataTableKey, h2 as CustomerSelector, n_ as useDebounce, bX as Folder, n$ as Search, o0 as ChevronRight, o1 as getExpandedRowModel, fO as getItemParentId, fR as calculateDragTargetPosition, fQ as isCircularReference, fS as calculateSiblingIndex, o2 as deleteAssetsDocument, cW as enumType, cP as coerce, gD as AssetGallery, mw as detailPageRouteLoader, hH as TaxCategorySelector, hO as ZoneSelector, k7 as Textarea, gV as ConfigurableOperationSelector, eT as TranslatableFormFieldWrapper, fq as RichTextInput, n5 as useGroupedPermissions, ke as TooltipProvider, kc as Tooltip, kf as TooltipTrigger, o3 as Info, kd as TooltipContent, gQ as ChannelSelector, gU as ConfigurableOperationMultiSelector, f7 as DateTimeInput, dS as X, cM as arrayType, nD as a, k2 as Tabs, k4 as TabsList, k5 as TabsTrigger, o4 as Link$1, k3 as TabsContent, iu as Command, iy as CommandInput, iA as CommandList, iw as CommandEmpty, iz as CommandItem, cO as booleanType, cl as ZodIssueCode, dq as recordType, C as Checkbox, iQ as Field, iT as FieldError, fa as MoneyInput, gW as ConfirmationDialog, hU as AlertDialog, hX as AlertDialogContent, h_ as AlertDialogHeader, hT as AlertDialogTitle, hY as AlertDialogDescription, hZ as AlertDialogFooter, hW as AlertDialogCancel, hV as AlertDialogAction, ho as PermissionGuard, na as usePage, fs as SlugInput, gN as AssignedFacetValues, gM as AssignedChannels, h4 as EntityAssets, dV as Separator, g_ as CustomFieldsForm, iV as FieldLabel, m$ as useDynamicTranslations, o5 as getTypeForState, bH as cn, nn as DEFAULT_CHANNEL_CODE, fp as createRelationSelectorConfig, fo as RelationSelector, j5 as Label, o6 as CircleAlert, mX as useCustomFieldConfig, gj as LabeledData, ir as Collapsible, is as CollapsibleTrigger, it as CollapsibleContent, o7 as Globe, md as HistoryEntry, o8 as SquarePen, hf as useHistoryNoteEditor, hd as HistoryTimelineWithGrouping, hc as HistoryNoteInput, ha as HistoryNoteEditor, hb as HistoryNoteEntry, jS as Skeleton, kR as getFieldsFromDocumentNode, fL as getColumnVisibility, o9 as Pencil, oa as stateTypeToBadgeVariant, ob as ChevronLeft, g$ as CustomerAddressForm$1, oc as Users, h0 as CustomerGroupChip, h1 as CustomerGroupSelector, od as availableCountriesQueryKey, oe as Eye, i5 as AlertTitle, n6 as useJobQueuePolling, hB as SellerSelector, gZ as CurrencySelector, of as tagListDocument, og as updateTagDocument, oh as deleteTagDocument, oi as createTagDocument, je as Popover, jj as PopoverTrigger, oj as ChevronsUpDown, jf as PopoverContent, ix as CommandGroup, ok as Settings2, ol as assetDetailDocument, om as assetUpdateDocument, gB as AssetFocalPointEditor, gI as AssetProperties, gG as AssetPreviewSelector, on as Focus, hA as RoleSelector, hj as MultiSelect, oo as useRedirectToListOnNotFound, fh as SingleRelationInput, lD as useGeneratedForm, de as numberType, f0 as AffixedInput, iF as DialogClose, jU as Spinner, lq as useDashboardExtensions, kH as registerDefaults, l7 as executeDashboardExtensionCallbacks, jT as Toaster, mB as useExtendedRouter, mZ as useDisplayLocale, nh as useUiLanguageLoader, kL as setCustomFieldsMap, iN as DirectionProvider, kM as clearCustomFieldsMap } from "./use-job-queue-polling-
|
|
2
|
+
import { c as createLucideIcon, nu as loadI18nMessages, nE as UserSettingsProvider, nF as ThemeProvider, nG as AuthProvider, nH as ServerConfigProvider, nI as ChannelProvider, nJ as AlertsProvider, l5 as CustomProviders, df as objectType, du as stringType, mV as useAuth, gv as LoginForm, hq as LoginBranding, gk as AppLayout, nK as endOfDay, nL as startOfMonth, bD as useUserSettings, nc as usePermissions, kx as getDashboardWidgetRegistry, eL as Page, eM as PageTitle, eN as PageActionBar, me as ActionBarItem, gi as DateRangePicker, dP as Button, eP as PageLayout, mp as FullWidthPageBlock, kA as WidgetFiltersProvider, i$ as GridLayout, ky as getDashboardWidget, nb as usePaginatedList, mF as api, kV as getMutationName, fA as DataTableBulkActionItem, nM as Trash, mN as graphql, gf as useGeneratedColumns, fU as DataTable, gY as CountrySelector, jt as Sheet, jA as SheetTrigger, jv as SheetContent, jy as SheetHeader, jz as SheetTitle, jw as SheetDescription, jm as ScrollArea, mx as ListPage, dQ as Plus, h3 as DetailPageButton, eX as BooleanDisplayBadge, dR as Badge, mS as setSettingsStoreValueDocument, nN as createColumnHelper, gX as CopyableText, jV as Switch$1, iE as Dialog, iM as DialogTrigger, iG as DialogContent, iJ as DialogHeader, iD as DialogTitle, iH as DialogDescription, eZ as JsonViewer, iI as DialogFooter, dO as Input, n7 as useLocalFormat, bR as DropdownMenu, bS as DropdownMenuTrigger, bT as Ellipsis, bV as DropdownMenuContent, bW as DropdownMenuItem, nO as Clock, nP as Check, nQ as RefreshCw, nR as ChevronDown, nS as EllipsisVertical, bF as Select, bG as SelectTrigger, bI as SelectValue, bJ as SelectContent, bK as SelectItem, gJ as AssignToChannelBulkAction, mW as useChannel, hs as RemoveFromChannelBulkAction, mJ as configurableOperationFragment, nq as LS_KEY_SHIPPING_TEST_ADDRESS, hR as AccordionItem, hS as AccordionTrigger, hQ as AccordionContent, i_ as Form, eS as FormFieldWrapper, nT as AddressCountrySelect, nr as LS_KEY_SHIPPING_TEST_ORDER, nU as useReactTable, nV as getCoreRowModel, jW as Table, k0 as TableHeader, k1 as TableRow, j$ as TableHead, nW as flexRender, jX as TableBody, jZ as TableCell, hr as ProductVariantSelector, hJ as VendureImage, bZ as Trash2, e$ as Money, ij as Card, ip as CardHeader, iq as CardTitle, il as CardContent, i3 as Alert, i4 as AlertDescription, hP as Accordion, hG as RichTextDescriptionCell, nt as SUPER_ADMIN_ROLE_CODE, nl as CUSTOMER_ROLE_CODE, nX as Layers, gP as ChannelCodeLabel, hz as RoleCodeLabel, mH as getEntityDuplicatorsDocument, nY as getInitialConfigArgValue, gS as ConfigurableOperationInput, mG as duplicateEntityDocument, nZ as Copy, h5 as ErrorPage, kI as extendDetailFormQuery, kP as addCustomFields, mA as getDetailQueryOptions, eJ as useDetailPage, eQ as PageBlock, eR as DetailFormGrid, jd as PasswordInput, eU as CustomFieldsPageBlock, mI as assetFragment, h7 as FacetValueSelector, h6 as FacetValueChip, gL as usePriceFactor, fF as FacetValueFacetedFilter, hC as StockLevelLabel, mM as errorResultFragment, mL as configurableOperationDefFragment, bC as useServerConfig, hD as CustomerCell, hE as OrderStateCell, hF as OrderMoneyCell, eH as NEW_ENTITY_PATH, hh as LanguageSelector, mP as schemaLanguageCodes, fb as NumberInput, hn as PaginatedListDataTable, hm as PaginatedListDataTableKey, h2 as CustomerSelector, n_ as useDebounce, bX as Folder, n$ as Search, o0 as ChevronRight, o1 as getExpandedRowModel, fO as getItemParentId, fR as calculateDragTargetPosition, fQ as isCircularReference, fS as calculateSiblingIndex, o2 as deleteAssetsDocument, cW as enumType, cP as coerce, gD as AssetGallery, mw as detailPageRouteLoader, hH as TaxCategorySelector, hO as ZoneSelector, k7 as Textarea, gV as ConfigurableOperationSelector, eT as TranslatableFormFieldWrapper, fq as RichTextInput, n5 as useGroupedPermissions, ke as TooltipProvider, kc as Tooltip, kf as TooltipTrigger, o3 as Info, kd as TooltipContent, gQ as ChannelSelector, gU as ConfigurableOperationMultiSelector, f7 as DateTimeInput, dS as X, cM as arrayType, nD as a, k2 as Tabs, k4 as TabsList, k5 as TabsTrigger, o4 as Link$1, k3 as TabsContent, iu as Command, iy as CommandInput, iA as CommandList, iw as CommandEmpty, iz as CommandItem, cO as booleanType, cl as ZodIssueCode, dq as recordType, C as Checkbox, iQ as Field, iT as FieldError, fa as MoneyInput, gW as ConfirmationDialog, hU as AlertDialog, hX as AlertDialogContent, h_ as AlertDialogHeader, hT as AlertDialogTitle, hY as AlertDialogDescription, hZ as AlertDialogFooter, hW as AlertDialogCancel, hV as AlertDialogAction, ho as PermissionGuard, na as usePage, fs as SlugInput, gN as AssignedFacetValues, gM as AssignedChannels, h4 as EntityAssets, dV as Separator, g_ as CustomFieldsForm, iV as FieldLabel, m$ as useDynamicTranslations, o5 as getTypeForState, bH as cn, nn as DEFAULT_CHANNEL_CODE, fp as createRelationSelectorConfig, fo as RelationSelector, j5 as Label, o6 as CircleAlert, mX as useCustomFieldConfig, gj as LabeledData, ir as Collapsible, is as CollapsibleTrigger, it as CollapsibleContent, o7 as Globe, md as HistoryEntry, o8 as SquarePen, hf as useHistoryNoteEditor, hd as HistoryTimelineWithGrouping, hc as HistoryNoteInput, ha as HistoryNoteEditor, hb as HistoryNoteEntry, jS as Skeleton, kR as getFieldsFromDocumentNode, fL as getColumnVisibility, o9 as Pencil, oa as stateTypeToBadgeVariant, ob as ChevronLeft, g$ as CustomerAddressForm$1, oc as Users, h0 as CustomerGroupChip, h1 as CustomerGroupSelector, od as availableCountriesQueryKey, oe as Eye, i5 as AlertTitle, n6 as useJobQueuePolling, hB as SellerSelector, gZ as CurrencySelector, of as tagListDocument, og as updateTagDocument, oh as deleteTagDocument, oi as createTagDocument, je as Popover, jj as PopoverTrigger, oj as ChevronsUpDown, jf as PopoverContent, ix as CommandGroup, ok as Settings2, ol as assetDetailDocument, om as assetUpdateDocument, gB as AssetFocalPointEditor, gI as AssetProperties, gG as AssetPreviewSelector, on as Focus, hA as RoleSelector, hj as MultiSelect, oo as useRedirectToListOnNotFound, fh as SingleRelationInput, lD as useGeneratedForm, de as numberType, f0 as AffixedInput, iF as DialogClose, jU as Spinner, lq as useDashboardExtensions, kH as registerDefaults, l7 as executeDashboardExtensionCallbacks, jT as Toaster, mB as useExtendedRouter, mZ as useDisplayLocale, nh as useUiLanguageLoader, kL as setCustomFieldsMap, iN as DirectionProvider, kM as clearCustomFieldsMap } from "./use-job-queue-polling-1x9ESPDt.js";
|
|
3
3
|
import { toast } from "sonner";
|
|
4
4
|
import { i18n } from "@lingui/core";
|
|
5
5
|
import { I18nProvider as I18nProvider$1, useLingui, Trans } from "@lingui/react";
|
|
@@ -2948,7 +2948,7 @@ var TanstackQueryDevtools = class {
|
|
|
2948
2948
|
if (this.#Component) {
|
|
2949
2949
|
Devtools = this.#Component;
|
|
2950
2950
|
} else {
|
|
2951
|
-
Devtools = lazy(() => import("./WDYDFRGG-
|
|
2951
|
+
Devtools = lazy(() => import("./WDYDFRGG-D09CtNqO.js"));
|
|
2952
2952
|
this.#Component = Devtools;
|
|
2953
2953
|
}
|
|
2954
2954
|
setupStyleSheet(this.#styleNonce, this.#shadowDOMTarget);
|
|
@@ -3086,7 +3086,7 @@ var TanstackQueryDevtoolsPanel = class {
|
|
|
3086
3086
|
if (this.#Component) {
|
|
3087
3087
|
Devtools = this.#Component;
|
|
3088
3088
|
} else {
|
|
3089
|
-
Devtools = lazy(() => import("./2SSKDMRQ-
|
|
3089
|
+
Devtools = lazy(() => import("./2SSKDMRQ-BpCuVzuI.js"));
|
|
3090
3090
|
this.#Component = Devtools;
|
|
3091
3091
|
}
|
|
3092
3092
|
setupStyleSheet(this.#styleNonce, this.#shadowDOMTarget);
|
package/dist/bundle/chunks/{use-job-queue-polling-BGkZa_AL.js → use-job-queue-polling-1x9ESPDt.js}
RENAMED
|
@@ -39350,7 +39350,7 @@ function useDayPickerLocale() {
|
|
|
39350
39350
|
} = useDisplayLocale();
|
|
39351
39351
|
const [calendarLocale, setCalendarLocale] = useState(void 0);
|
|
39352
39352
|
useEffect(() => {
|
|
39353
|
-
import("./locale-
|
|
39353
|
+
import("./locale-DvfAgkVa.js").then((mod) => {
|
|
39354
39354
|
setCalendarLocale(bcpTagToDatePickerLocale(bcp47Tag, mod));
|
|
39355
39355
|
});
|
|
39356
39356
|
}, [bcp47Tag]);
|
|
@@ -130446,12 +130446,12 @@ function createStructFieldSchema(structFieldConfig) {
|
|
|
130446
130446
|
}
|
|
130447
130447
|
return objectType(nestedSchema);
|
|
130448
130448
|
}
|
|
130449
|
-
function applyCustomFieldModifiers(zodType, customField) {
|
|
130449
|
+
function applyCustomFieldModifiers(zodType, customField, isCreateForm) {
|
|
130450
130450
|
let modifiedType = zodType;
|
|
130451
130451
|
if (customField.list) {
|
|
130452
130452
|
modifiedType = arrayType(modifiedType);
|
|
130453
130453
|
}
|
|
130454
|
-
if (customField.nullable !== false || customField.readonly) {
|
|
130454
|
+
if (customField.nullable !== false || customField.readonly || isCreateForm) {
|
|
130455
130455
|
modifiedType = modifiedType.optional().nullable();
|
|
130456
130456
|
}
|
|
130457
130457
|
if (customField.readonly) {
|
|
@@ -130459,7 +130459,7 @@ function applyCustomFieldModifiers(zodType, customField) {
|
|
|
130459
130459
|
}
|
|
130460
130460
|
return modifiedType;
|
|
130461
130461
|
}
|
|
130462
|
-
function processCustomFieldsSchema(customFieldConfigs, isTranslationContext) {
|
|
130462
|
+
function processCustomFieldsSchema(customFieldConfigs, isTranslationContext, isCreateForm) {
|
|
130463
130463
|
const customFieldsSchema = {};
|
|
130464
130464
|
const translatableTypes = ["localeString", "localeText"];
|
|
130465
130465
|
const filteredCustomFields = customFieldConfigs.filter((cf) => {
|
|
@@ -130476,13 +130476,13 @@ function processCustomFieldsSchema(customFieldConfigs, isTranslationContext) {
|
|
|
130476
130476
|
} else {
|
|
130477
130477
|
zodType = createCustomFieldValidationSchema(customField);
|
|
130478
130478
|
}
|
|
130479
|
-
zodType = applyCustomFieldModifiers(zodType, customField);
|
|
130479
|
+
zodType = applyCustomFieldModifiers(zodType, customField, isCreateForm);
|
|
130480
130480
|
const schemaPropertyName = getGraphQlInputName(customField);
|
|
130481
130481
|
customFieldsSchema[schemaPropertyName] = zodType;
|
|
130482
130482
|
}
|
|
130483
130483
|
return customFieldsSchema;
|
|
130484
130484
|
}
|
|
130485
|
-
function createFormSchemaFromFields(fields, customFieldConfigs, isTranslationContext = false) {
|
|
130485
|
+
function createFormSchemaFromFields(fields, customFieldConfigs, isTranslationContext = false, isCreateForm = false) {
|
|
130486
130486
|
const schemaConfig = {};
|
|
130487
130487
|
for (const field of fields) {
|
|
130488
130488
|
const isScalar = isScalarType(field.type);
|
|
@@ -130490,11 +130490,11 @@ function createFormSchemaFromFields(fields, customFieldConfigs, isTranslationCon
|
|
|
130490
130490
|
if ((isScalar || isEnum) && field.name !== "customFields") {
|
|
130491
130491
|
schemaConfig[field.name] = getZodTypeFromField(field);
|
|
130492
130492
|
} else if (field.name === "customFields") {
|
|
130493
|
-
const customFieldsSchema = customFieldConfigs && customFieldConfigs.length > 0 ? processCustomFieldsSchema(customFieldConfigs, isTranslationContext) : {};
|
|
130493
|
+
const customFieldsSchema = customFieldConfigs && customFieldConfigs.length > 0 ? processCustomFieldsSchema(customFieldConfigs, isTranslationContext, isCreateForm) : {};
|
|
130494
130494
|
schemaConfig[field.name] = objectType(customFieldsSchema).passthrough().optional();
|
|
130495
130495
|
} else if (field.typeInfo) {
|
|
130496
130496
|
const isNestedTranslationContext = field.name === "translations" || isTranslationContext;
|
|
130497
|
-
let nestedType = createFormSchemaFromFields(field.typeInfo, customFieldConfigs, isNestedTranslationContext);
|
|
130497
|
+
let nestedType = createFormSchemaFromFields(field.typeInfo, customFieldConfigs, isNestedTranslationContext, isCreateForm);
|
|
130498
130498
|
if (field.nullable) {
|
|
130499
130499
|
nestedType = nestedType.optional().nullable();
|
|
130500
130500
|
}
|
|
@@ -130670,10 +130670,11 @@ function useGeneratedForm(options) {
|
|
|
130670
130670
|
}, [extendSchema]);
|
|
130671
130671
|
const updateFields = useMemo(() => document2 ? getOperationVariablesFields(document2, varName) : [], [document2, varName]);
|
|
130672
130672
|
const availableLanguages = serverConfig?.availableLanguages ?? EMPTY_LANGUAGES;
|
|
130673
|
+
const isCreateForm = !entity;
|
|
130673
130674
|
const schema = useMemo(() => {
|
|
130674
|
-
const generated = createFormSchemaFromFields(updateFields, customFieldConfig);
|
|
130675
|
+
const generated = createFormSchemaFromFields(updateFields, customFieldConfig, false, isCreateForm);
|
|
130675
130676
|
return extendSchemaRef.current?.(generated) ?? generated;
|
|
130676
|
-
}, [updateFields, customFieldConfig]);
|
|
130677
|
+
}, [updateFields, customFieldConfig, isCreateForm]);
|
|
130677
130678
|
const defaultValues = useMemo(() => getDefaultValuesFromFields(updateFields, activeChannel?.defaultLanguageCode, customFieldConfig), [updateFields, activeChannel?.defaultLanguageCode, customFieldConfig]);
|
|
130678
130679
|
const processedEntity = useMemo(() => ensureTranslationsForAllLanguages(entity, availableLanguages, defaultValues), [entity, availableLanguages, defaultValues]);
|
|
130679
130680
|
const processedDefaultValues = useMemo(() => ensureTranslationsForAllLanguages(defaultValues, availableLanguages, defaultValues) ?? defaultValues, [defaultValues, availableLanguages]);
|
package/dist/bundle/lib.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as createLucideIcon, g as getComputedStyle$1, i as isHTMLElement, r as round, a as createLucideIcon$1, b as isFieldDisabled, C as Checkbox, u as useBaseUiId, d as useIsoLayoutEffect, f as formatErrorMessage, e as useRenderElement, N as NOOP, h as useTransitionStatus, j as useStableCallback, k as useOpenChangeComplete, t as transitionStatusMapping, l as useTimeout, m as createSelector, n as compareItemEquality, o as hasNullItemLabel, s as stringifyAsLabel, p as defaultItemEquality, q as useFormContext, v as useFieldRootContext, w as useLabelableId, x as useControlled, E as EMPTY_ARRAY, y as useRefWithInit, z as isGroupedItems, S as Store, A as EMPTY_OBJECT, B as stringifyAsValue, D as useStore, F as useValueAsRef, G as useOpenInteractionType, H as useField, I as createGenericEventDetails, J as inputClear, K as inputChange, L as createChangeEventDetails, M as focusOut, O as outsidePress, P as getTarget, Q as itemPress, R as selectedValueIncludes, T as removeItem, U as none, V as findItemIndex, W as useValueChanged, X as useFloatingRootContext, Y as useClick, Z as inputPress, _ as useDismiss, $ as contains, a0 as useListNavigation, a1 as useInteractions, a2 as useOnFirstRender, a3 as useMergedRefs, a4 as visuallyHiddenInput, a5 as visuallyHidden, a6 as resolveMultipleLabels, a7 as resolveSelectedLabel, a8 as fieldValidityMapping, a9 as pressableTriggerOpenStateMapping, aa as useButton, ab as closePress, ac as useLabelableContext, ad as useDirection, ae as DEFAULT_FIELD_STATE_ATTRIBUTES, af as resolveAriaLabelledBy, ag as stopEvent, ah as isFirefox, ai as escapeKey, aj as isAndroid, ak as useTypeahead, al as listNavigation, am as ownerDocument, an as getPseudoElementBounds, ao as CompositeList, ap as FloatingPortal, aq as DROPDOWN_COLLISION_AVOIDANCE, ar as useAnchorPositioning, as as useScrollLock, at as InternalBackdrop, au as inertValue, av as getDisabledMountTransitionStyles, aw as popupStateMapping, ax as FloatingFocusManager, ay as useCompositeListItem, az as IndexGuessBehavior, aA as chipRemovePress, aB as triggerOpenStateMapping, aC as clearPress, aD as useId, aE as ContextMenuRootContext, aF as MenuRootContext, aG as MenuRoot, aH as useContextMenuRootContext, aI as useMenuRootContext, aJ as findRootOwnerId, aK as cancelOpen, aL as triggerPress, aM as MenubarContext, aN as FloatingTree, aO as CompositeRoot, aP as useFloatingNodeId, aQ as useFloatingTree, aR as useMenubarContext, aS as FloatingNode, aT as useFloatingParentNodeId, aU as linkPress, aV as activeElement, aW as triggerHover, aX as getEmptyRootContext, aY as useHoverFloatingInteraction, aZ as getNodeChildren, a_ as useAnimationFrame, a$ as useAnimationsFinished, b0 as getWindow, b1 as TransitionStatusDataAttributes, b2 as useHoverInteractionSharedState, b3 as clearSafePolygonPointerEventsMutation, b4 as useHoverReferenceInteraction, b5 as safePolygon, b6 as isWebKit, b7 as CompositeItem, b8 as FocusGuard, b9 as isOutsideEvent, ba as getPreviousTabbable, bb as ownerVisuallyHidden, bc as isTabbable, bd as getNextTabbable, be as getTabbableAfterElement, bf as applySafePolygonPointerEventsMutation, bg as PATIENT_CLICK_THRESHOLD, bh as POPUP_COLLISION_AVOIDANCE, bi as adaptiveOrigin, bj as enableFocusInside, bk as disableFocusInside, bl as clamp, bm as warn, bn as getDefaultLabelId, bo as keyboard, bp as isElement, bq as drag, br as trackPress, bs as useCSPContext, bt as useOnMount, bu as mergeProps, bv as COMPOSITE_KEYS, bw as HOME, bx as END, by as ARROW_LEFT, bz as ARROW_DOWN, bA as ARROW_RIGHT, bB as ARROW_UP, bC as useServerConfig, bD as useUserSettings, bE as useSortedLanguages, bF as Select, bG as SelectTrigger, bH as cn, bI as SelectValue, bJ as SelectContent, bK as SelectItem, bL as useSidebar, bM as SidebarGroup, bN as SidebarGroupLabel, bO as SidebarMenu, bP as SidebarMenuItem, bQ as SidebarMenuButton, bR as DropdownMenu, bS as DropdownMenuTrigger, bT as Ellipsis, bU as SidebarMenuAction, bV as DropdownMenuContent, bW as DropdownMenuItem, bX as Folder, bY as DropdownMenuSeparator, bZ as Trash2, b_ as BRAND, b$ as DIRTY, c0 as EMPTY_PATH, c1 as INVALID, c2 as NEVER, c3 as OK, c4 as ParseStatus, c5 as ZodType, c6 as ZodAny, c7 as ZodArray, c8 as ZodBigInt, c9 as ZodBoolean, ca as ZodBranded, cb as ZodCatch, cc as ZodDate, cd as ZodDefault, ce as ZodDiscriminatedUnion, cf as ZodEffects, cg as ZodEnum, ch as ZodError, ci as ZodFirstPartyTypeKind, cj as ZodFunction, ck as ZodIntersection, cl as ZodIssueCode, cm as ZodLazy, cn as ZodLiteral, co as ZodMap, cp as ZodNaN, cq as ZodNativeEnum, cr as ZodNever, cs as ZodNull, ct as ZodNullable, cu as ZodNumber, cv as ZodObject, cw as ZodOptional, cx as ZodParsedType, cy as ZodPipeline, cz as ZodPromise, cA as ZodReadonly, cB as ZodRecord, cC as ZodSet, cD as ZodString, cE as ZodSymbol, cF as ZodTuple, cG as ZodUndefined, cH as ZodUnion, cI as ZodUnknown, cJ as ZodVoid, cK as addIssueToContext, cL as anyType, cM as arrayType, cN as bigIntType, cO as booleanType, cP as coerce, cQ as custom, cR as dateType, cS as datetimeRegex, cT as errorMap, cU as discriminatedUnionType, cV as effectsType, cW as enumType, cX as functionType, cY as getErrorMap, cZ as getParsedType, c_ as instanceOfType, c$ as intersectionType, d0 as isAborted, d1 as isAsync, d2 as isDirty, d3 as isValid, d4 as late, d5 as lazyType, d6 as literalType, d7 as makeIssue, d8 as mapType, d9 as nanType, da as nativeEnumType, db as neverType, dc as nullType, dd as nullableType, de as numberType, df as objectType, dg as objectUtil, dh as oboolean, di as onumber, dj as optionalType, dk as ostring, dl as pipelineType, dm as preprocessType, dn as promiseType, dp as quotelessJson, dq as recordType, dr as setType, ds as setErrorMap, dt as strictObjectType, du as stringType, dv as symbolType, dw as tupleType, dx as undefinedType, dy as unionType, dz as unknownType, dA as util, dB as voidType, dC as MotionConfigContext, dD as isHTMLElement$1, dE as useConstant, dF as PresenceContext, dG as usePresence, dH as useIsomorphicLayoutEffect$1, dI as LayoutGroupContext, dJ as frame, dK as animateVisualElement, dL as setTarget, dM as invariant, dN as resolveElements, dO as Input, dP as Button, dQ as Plus, dR as Badge, dS as X, dT as cn$1, dU as cva, dV as Separator, dW as useRender, dX as Button$1, dY as ChevronLeft, dZ as ChevronRight, d_ as throttle, d$ as warn$1, e0 as isPercent, e1 as getDisplayName, e2 as clsx, e3 as Tooltip, e4 as Legend, e5 as X$1, e6 as InputGroup, e7 as InputGroupInput, e8 as InputGroupAddon, e9 as InputGroupButton, ea as Check, eb as Separator$1, ec as ChevronDown, ed as MenuCheckboxItem, ee as MenuCheckboxItemIndicator, ef as MenuPortal, eg as MenuPositioner, eh as MenuPopup, ei as MenuGroup, ej as MenuItem, ek as MenuGroupLabel, el as MenuRadioGroup, em as MenuRadioItem, en as MenuRadioItemIndicator, eo as MenuSubmenuRoot, ep as MenuSubmenuTrigger, eq as Close, er as Description, es as Title, et as Trigger, eu as Root$1, ev as Content$1, ew as Overlay$1, ex as Portal$1, ey as DropdownMenuContent$1, ez as DropdownMenuGroup, eA as DropdownMenuLabel, eB as DropdownMenuPortal, eC as DropdownMenuRadioGroup, eD as DropdownMenuShortcut, eE as DropdownMenuSub, eF as DropdownMenuSubContent, eG as DropdownMenuSubTrigger, eH as NEW_ENTITY_PATH, eI as getEntityName, eJ as useDetailPage, eK as getOperationVariablesFields, eL as Page, eM as PageTitle, eN as PageActionBar, eO as PageActionBarRight, eP as PageLayout, eQ as PageBlock, eR as DetailFormGrid, eS as FormFieldWrapper, eT as TranslatableFormFieldWrapper, eU as CustomFieldsPageBlock, eV as DefaultInputForType } from "./chunks/use-job-queue-polling-
|
|
2
|
-
import { nk, hP, hQ, hR, hS, me, mf, fz, fx, f0, i3, i6, i4, hU, hV, hW, hX, hY, hZ, h_, h$, i0, i1, hT, i2, kj, i5, gw, kk, gy, gx, gk, gl, gA, gB, gD, gE, gH, gF, gG, gI, gJ, gK, gM, gN, fV, eX, eW, f1, i8, i9, ia, ib, ic, id, ie, nl, ih, ii, ij, ik, il, im, io, ip, iq, gO, gP, gQ, gm, ir, it, is, fy, f2, iu, iv, iw, ix, iy, iz, iA, iB, iC, gR, gS, f3, gU, gV, gW, gX, gY, hM, nm, gZ, f4, g_, lu, l5, g$, hD, h0, f5, h1, h2, fX, nn, kq, fU, fW, fA, fB, fC, fD, f_, fG, fI, fH, fJ, g0, g2, fK, fE, g4, fT, gi, eY, f7, f8, h3, mg, gn, gu, iE, iF, iG, iH, iI, iJ, iK, iL, iD, iM, iN, ko, iO, iP, h4, h5, h6, fF, f9, h7, iQ, iR, iS, iT, iU, iV, iW, iX, iY, iZ, i_, lv, mp, go, g5, g6, i$, md, h8, h9, ha, hb, hc, he, hd, j0, j1, j2, g7, f$, hg, ht, j3, j4, e_, eZ, no, np, nq, nr, ns, j5, gj, gp, hh, hu, mx, ml, hq, gv, hi, g8, gq, hp, kt, e$, fa, fi, hj, g9, g1, gr, gs, gt, hk, fb, hF, hE, lC, mo, mm, mn, mr, hl, hn, hm, j6, j7, j8, j9, ja, jb, jc, fc, jd, ho, hK, je, jf, jg, jh, ji, jj, fg, ff, hr, jk, jl, ga, fo, fm, hs, hN, hv, hG, hw, fq, hz, hA, g3, nt, gb, gc, jm, jn, jo, jp, jq, jr, js, fr, hB, jt, ju, jv, jw, jx, jy, jz, jA, jB, jC, jD, jE, jF, jG, jH, jI, jJ, jK, jL, jM, jN, jO, jP, jQ, jR, fh, jS, fs, jU, hC, ft, fu, jV, jW, jX, jY, jZ, hx, hy, j_, j$, k0, k1, k2, k3, k4, k5, hH, fv, k7, fw, hL, jT, ka, k8, k9, kc, kd, ke, kf, hI, gg, hJ, gh, kp, kz, kA, hO, kC, lf, kP, kO, lt, lb, le, kE, mu, mv, kG, mF, gz, ly, mI, i7, fZ, ig, fR, fS, nz, kM, fl, mK, mL, mJ, lG, gC, lw, fp, fk, l8, mw, mG, mM, l7, kI, kJ, my, lZ, nA, la, ld, ki, kh, kB, fL, kN, mc, mi, l1, mk, ky, kx, lz, lx, ls, mA, l9, mH, k_, n2, kR, lB, lc, fO, fP, kD, kQ, kV, ms, kU, kW, kS, kT, mR, fN, mE, kX, ma, kF, lA, mC, kK, mN, m7, m4, l0, gT, lQ, m0, fQ, lK, lJ, lT, m1, kZ, m6, lS, l$, lR, l_, m2, lN, lP, m5, mq, m3, lU, kY, lL, lM, lX, lY, lV, lW, lO, m9, kr, ks, nu, fd, fe, nv, m8, gd, nB, l6, ku, kv, fY, fM, fj, mO, kg, lg, mh, l2, l3, mj, kw, lh, kH, li, lj, lk, ll, lm, ln, mz, lo, mD, lp, lF, nC, l4, kl, mQ, mP, km, kL, mt, mS, lH, lI, k6, kb, lE, mb, mU, mT, ge, mV, mW, kn, mX, lq, mY, f6, mZ, m_, m$, n0, n1, mB, n3, n4, gf, lD, n5, hf, n8, ne, n6, k$, n7, lr, nw, na, n9, nb, nc, gL, fn, ng, nd, nx, nf, ny, nh, ni, nj, nD } from "./chunks/use-job-queue-polling-
|
|
1
|
+
import { c as createLucideIcon, g as getComputedStyle$1, i as isHTMLElement, r as round, a as createLucideIcon$1, b as isFieldDisabled, C as Checkbox, u as useBaseUiId, d as useIsoLayoutEffect, f as formatErrorMessage, e as useRenderElement, N as NOOP, h as useTransitionStatus, j as useStableCallback, k as useOpenChangeComplete, t as transitionStatusMapping, l as useTimeout, m as createSelector, n as compareItemEquality, o as hasNullItemLabel, s as stringifyAsLabel, p as defaultItemEquality, q as useFormContext, v as useFieldRootContext, w as useLabelableId, x as useControlled, E as EMPTY_ARRAY, y as useRefWithInit, z as isGroupedItems, S as Store, A as EMPTY_OBJECT, B as stringifyAsValue, D as useStore, F as useValueAsRef, G as useOpenInteractionType, H as useField, I as createGenericEventDetails, J as inputClear, K as inputChange, L as createChangeEventDetails, M as focusOut, O as outsidePress, P as getTarget, Q as itemPress, R as selectedValueIncludes, T as removeItem, U as none, V as findItemIndex, W as useValueChanged, X as useFloatingRootContext, Y as useClick, Z as inputPress, _ as useDismiss, $ as contains, a0 as useListNavigation, a1 as useInteractions, a2 as useOnFirstRender, a3 as useMergedRefs, a4 as visuallyHiddenInput, a5 as visuallyHidden, a6 as resolveMultipleLabels, a7 as resolveSelectedLabel, a8 as fieldValidityMapping, a9 as pressableTriggerOpenStateMapping, aa as useButton, ab as closePress, ac as useLabelableContext, ad as useDirection, ae as DEFAULT_FIELD_STATE_ATTRIBUTES, af as resolveAriaLabelledBy, ag as stopEvent, ah as isFirefox, ai as escapeKey, aj as isAndroid, ak as useTypeahead, al as listNavigation, am as ownerDocument, an as getPseudoElementBounds, ao as CompositeList, ap as FloatingPortal, aq as DROPDOWN_COLLISION_AVOIDANCE, ar as useAnchorPositioning, as as useScrollLock, at as InternalBackdrop, au as inertValue, av as getDisabledMountTransitionStyles, aw as popupStateMapping, ax as FloatingFocusManager, ay as useCompositeListItem, az as IndexGuessBehavior, aA as chipRemovePress, aB as triggerOpenStateMapping, aC as clearPress, aD as useId, aE as ContextMenuRootContext, aF as MenuRootContext, aG as MenuRoot, aH as useContextMenuRootContext, aI as useMenuRootContext, aJ as findRootOwnerId, aK as cancelOpen, aL as triggerPress, aM as MenubarContext, aN as FloatingTree, aO as CompositeRoot, aP as useFloatingNodeId, aQ as useFloatingTree, aR as useMenubarContext, aS as FloatingNode, aT as useFloatingParentNodeId, aU as linkPress, aV as activeElement, aW as triggerHover, aX as getEmptyRootContext, aY as useHoverFloatingInteraction, aZ as getNodeChildren, a_ as useAnimationFrame, a$ as useAnimationsFinished, b0 as getWindow, b1 as TransitionStatusDataAttributes, b2 as useHoverInteractionSharedState, b3 as clearSafePolygonPointerEventsMutation, b4 as useHoverReferenceInteraction, b5 as safePolygon, b6 as isWebKit, b7 as CompositeItem, b8 as FocusGuard, b9 as isOutsideEvent, ba as getPreviousTabbable, bb as ownerVisuallyHidden, bc as isTabbable, bd as getNextTabbable, be as getTabbableAfterElement, bf as applySafePolygonPointerEventsMutation, bg as PATIENT_CLICK_THRESHOLD, bh as POPUP_COLLISION_AVOIDANCE, bi as adaptiveOrigin, bj as enableFocusInside, bk as disableFocusInside, bl as clamp, bm as warn, bn as getDefaultLabelId, bo as keyboard, bp as isElement, bq as drag, br as trackPress, bs as useCSPContext, bt as useOnMount, bu as mergeProps, bv as COMPOSITE_KEYS, bw as HOME, bx as END, by as ARROW_LEFT, bz as ARROW_DOWN, bA as ARROW_RIGHT, bB as ARROW_UP, bC as useServerConfig, bD as useUserSettings, bE as useSortedLanguages, bF as Select, bG as SelectTrigger, bH as cn, bI as SelectValue, bJ as SelectContent, bK as SelectItem, bL as useSidebar, bM as SidebarGroup, bN as SidebarGroupLabel, bO as SidebarMenu, bP as SidebarMenuItem, bQ as SidebarMenuButton, bR as DropdownMenu, bS as DropdownMenuTrigger, bT as Ellipsis, bU as SidebarMenuAction, bV as DropdownMenuContent, bW as DropdownMenuItem, bX as Folder, bY as DropdownMenuSeparator, bZ as Trash2, b_ as BRAND, b$ as DIRTY, c0 as EMPTY_PATH, c1 as INVALID, c2 as NEVER, c3 as OK, c4 as ParseStatus, c5 as ZodType, c6 as ZodAny, c7 as ZodArray, c8 as ZodBigInt, c9 as ZodBoolean, ca as ZodBranded, cb as ZodCatch, cc as ZodDate, cd as ZodDefault, ce as ZodDiscriminatedUnion, cf as ZodEffects, cg as ZodEnum, ch as ZodError, ci as ZodFirstPartyTypeKind, cj as ZodFunction, ck as ZodIntersection, cl as ZodIssueCode, cm as ZodLazy, cn as ZodLiteral, co as ZodMap, cp as ZodNaN, cq as ZodNativeEnum, cr as ZodNever, cs as ZodNull, ct as ZodNullable, cu as ZodNumber, cv as ZodObject, cw as ZodOptional, cx as ZodParsedType, cy as ZodPipeline, cz as ZodPromise, cA as ZodReadonly, cB as ZodRecord, cC as ZodSet, cD as ZodString, cE as ZodSymbol, cF as ZodTuple, cG as ZodUndefined, cH as ZodUnion, cI as ZodUnknown, cJ as ZodVoid, cK as addIssueToContext, cL as anyType, cM as arrayType, cN as bigIntType, cO as booleanType, cP as coerce, cQ as custom, cR as dateType, cS as datetimeRegex, cT as errorMap, cU as discriminatedUnionType, cV as effectsType, cW as enumType, cX as functionType, cY as getErrorMap, cZ as getParsedType, c_ as instanceOfType, c$ as intersectionType, d0 as isAborted, d1 as isAsync, d2 as isDirty, d3 as isValid, d4 as late, d5 as lazyType, d6 as literalType, d7 as makeIssue, d8 as mapType, d9 as nanType, da as nativeEnumType, db as neverType, dc as nullType, dd as nullableType, de as numberType, df as objectType, dg as objectUtil, dh as oboolean, di as onumber, dj as optionalType, dk as ostring, dl as pipelineType, dm as preprocessType, dn as promiseType, dp as quotelessJson, dq as recordType, dr as setType, ds as setErrorMap, dt as strictObjectType, du as stringType, dv as symbolType, dw as tupleType, dx as undefinedType, dy as unionType, dz as unknownType, dA as util, dB as voidType, dC as MotionConfigContext, dD as isHTMLElement$1, dE as useConstant, dF as PresenceContext, dG as usePresence, dH as useIsomorphicLayoutEffect$1, dI as LayoutGroupContext, dJ as frame, dK as animateVisualElement, dL as setTarget, dM as invariant, dN as resolveElements, dO as Input, dP as Button, dQ as Plus, dR as Badge, dS as X, dT as cn$1, dU as cva, dV as Separator, dW as useRender, dX as Button$1, dY as ChevronLeft, dZ as ChevronRight, d_ as throttle, d$ as warn$1, e0 as isPercent, e1 as getDisplayName, e2 as clsx, e3 as Tooltip, e4 as Legend, e5 as X$1, e6 as InputGroup, e7 as InputGroupInput, e8 as InputGroupAddon, e9 as InputGroupButton, ea as Check, eb as Separator$1, ec as ChevronDown, ed as MenuCheckboxItem, ee as MenuCheckboxItemIndicator, ef as MenuPortal, eg as MenuPositioner, eh as MenuPopup, ei as MenuGroup, ej as MenuItem, ek as MenuGroupLabel, el as MenuRadioGroup, em as MenuRadioItem, en as MenuRadioItemIndicator, eo as MenuSubmenuRoot, ep as MenuSubmenuTrigger, eq as Close, er as Description, es as Title, et as Trigger, eu as Root$1, ev as Content$1, ew as Overlay$1, ex as Portal$1, ey as DropdownMenuContent$1, ez as DropdownMenuGroup, eA as DropdownMenuLabel, eB as DropdownMenuPortal, eC as DropdownMenuRadioGroup, eD as DropdownMenuShortcut, eE as DropdownMenuSub, eF as DropdownMenuSubContent, eG as DropdownMenuSubTrigger, eH as NEW_ENTITY_PATH, eI as getEntityName, eJ as useDetailPage, eK as getOperationVariablesFields, eL as Page, eM as PageTitle, eN as PageActionBar, eO as PageActionBarRight, eP as PageLayout, eQ as PageBlock, eR as DetailFormGrid, eS as FormFieldWrapper, eT as TranslatableFormFieldWrapper, eU as CustomFieldsPageBlock, eV as DefaultInputForType } from "./chunks/use-job-queue-polling-1x9ESPDt.js";
|
|
2
|
+
import { nk, hP, hQ, hR, hS, me, mf, fz, fx, f0, i3, i6, i4, hU, hV, hW, hX, hY, hZ, h_, h$, i0, i1, hT, i2, kj, i5, gw, kk, gy, gx, gk, gl, gA, gB, gD, gE, gH, gF, gG, gI, gJ, gK, gM, gN, fV, eX, eW, f1, i8, i9, ia, ib, ic, id, ie, nl, ih, ii, ij, ik, il, im, io, ip, iq, gO, gP, gQ, gm, ir, it, is, fy, f2, iu, iv, iw, ix, iy, iz, iA, iB, iC, gR, gS, f3, gU, gV, gW, gX, gY, hM, nm, gZ, f4, g_, lu, l5, g$, hD, h0, f5, h1, h2, fX, nn, kq, fU, fW, fA, fB, fC, fD, f_, fG, fI, fH, fJ, g0, g2, fK, fE, g4, fT, gi, eY, f7, f8, h3, mg, gn, gu, iE, iF, iG, iH, iI, iJ, iK, iL, iD, iM, iN, ko, iO, iP, h4, h5, h6, fF, f9, h7, iQ, iR, iS, iT, iU, iV, iW, iX, iY, iZ, i_, lv, mp, go, g5, g6, i$, md, h8, h9, ha, hb, hc, he, hd, j0, j1, j2, g7, f$, hg, ht, j3, j4, e_, eZ, no, np, nq, nr, ns, j5, gj, gp, hh, hu, mx, ml, hq, gv, hi, g8, gq, hp, kt, e$, fa, fi, hj, g9, g1, gr, gs, gt, hk, fb, hF, hE, lC, mo, mm, mn, mr, hl, hn, hm, j6, j7, j8, j9, ja, jb, jc, fc, jd, ho, hK, je, jf, jg, jh, ji, jj, fg, ff, hr, jk, jl, ga, fo, fm, hs, hN, hv, hG, hw, fq, hz, hA, g3, nt, gb, gc, jm, jn, jo, jp, jq, jr, js, fr, hB, jt, ju, jv, jw, jx, jy, jz, jA, jB, jC, jD, jE, jF, jG, jH, jI, jJ, jK, jL, jM, jN, jO, jP, jQ, jR, fh, jS, fs, jU, hC, ft, fu, jV, jW, jX, jY, jZ, hx, hy, j_, j$, k0, k1, k2, k3, k4, k5, hH, fv, k7, fw, hL, jT, ka, k8, k9, kc, kd, ke, kf, hI, gg, hJ, gh, kp, kz, kA, hO, kC, lf, kP, kO, lt, lb, le, kE, mu, mv, kG, mF, gz, ly, mI, i7, fZ, ig, fR, fS, nz, kM, fl, mK, mL, mJ, lG, gC, lw, fp, fk, l8, mw, mG, mM, l7, kI, kJ, my, lZ, nA, la, ld, ki, kh, kB, fL, kN, mc, mi, l1, mk, ky, kx, lz, lx, ls, mA, l9, mH, k_, n2, kR, lB, lc, fO, fP, kD, kQ, kV, ms, kU, kW, kS, kT, mR, fN, mE, kX, ma, kF, lA, mC, kK, mN, m7, m4, l0, gT, lQ, m0, fQ, lK, lJ, lT, m1, kZ, m6, lS, l$, lR, l_, m2, lN, lP, m5, mq, m3, lU, kY, lL, lM, lX, lY, lV, lW, lO, m9, kr, ks, nu, fd, fe, nv, m8, gd, nB, l6, ku, kv, fY, fM, fj, mO, kg, lg, mh, l2, l3, mj, kw, lh, kH, li, lj, lk, ll, lm, ln, mz, lo, mD, lp, lF, nC, l4, kl, mQ, mP, km, kL, mt, mS, lH, lI, k6, kb, lE, mb, mU, mT, ge, mV, mW, kn, mX, lq, mY, f6, mZ, m_, m$, n0, n1, mB, n3, n4, gf, lD, n5, hf, n8, ne, n6, k$, n7, lr, nw, na, n9, nb, nc, gL, fn, ng, nd, nx, nf, ny, nh, ni, nj, nD } from "./chunks/use-job-queue-polling-1x9ESPDt.js";
|
|
3
3
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
4
4
|
import * as React from "react";
|
|
5
5
|
import React__default, { useId as useId$1, useRef, useContext, useInsertionEffect, useMemo, Children, isValidElement, useState, createContext, useCallback, useEffect, forwardRef, useImperativeHandle, cloneElement, useLayoutEffect, useSyncExternalStore } from "react";
|
package/dist/bundle/main.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "react/jsx-runtime";
|
|
2
|
-
import "./chunks/use-job-queue-polling-
|
|
2
|
+
import "./chunks/use-job-queue-polling-1x9ESPDt.js";
|
|
3
3
|
import "sonner";
|
|
4
|
-
import "./chunks/main-
|
|
4
|
+
import "./chunks/main-eE-Qo1Dr.js";
|
|
5
5
|
import "@tanstack/react-router";
|
|
6
6
|
import "react";
|
|
7
7
|
import "react-dom";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vendure/dashboard",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "3.7.4-master-
|
|
4
|
+
"version": "3.7.4-master-202609300217",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -140,8 +140,8 @@
|
|
|
140
140
|
"@storybook/addon-vitest": "^10.3.1",
|
|
141
141
|
"@storybook/react-vite": "^10.3.1",
|
|
142
142
|
"@types/node": "^22.19.0",
|
|
143
|
-
"@vendure/common": "^3.7.4-master-
|
|
144
|
-
"@vendure/core": "^3.7.4-master-
|
|
143
|
+
"@vendure/common": "^3.7.4-master-202609300217",
|
|
144
|
+
"@vendure/core": "^3.7.4-master-202609300217",
|
|
145
145
|
"@vitest/browser": "^3.2.4",
|
|
146
146
|
"@vitest/coverage-v8": "^3.2.4",
|
|
147
147
|
"eslint": "^9.39.0",
|
|
@@ -334,12 +334,12 @@ describe('form-schema-tools', () => {
|
|
|
334
334
|
});
|
|
335
335
|
|
|
336
336
|
// Guards against the readonly fix accidentally making every field optional.
|
|
337
|
-
// A plain nullable: false field (no readonly) must still reject null/undefined
|
|
337
|
+
// A plain nullable: false field (no readonly) must still reject null/undefined on an
|
|
338
|
+
// update form: the column is NOT NULL, so clearing the input must keep the form invalid.
|
|
339
|
+
// (The create form is deliberately lenient instead — see the #5241 tests below.)
|
|
338
340
|
it('should reject null/undefined for non-readonly custom fields with nullable false', () => {
|
|
339
341
|
const fields = [createMockField('customFields', 'Object', false, false, [])];
|
|
340
|
-
const customFields = [
|
|
341
|
-
createMockCustomField('sku', 'string', { nullable: false }),
|
|
342
|
-
];
|
|
342
|
+
const customFields = [createMockCustomField('sku', 'string', { nullable: false })];
|
|
343
343
|
|
|
344
344
|
const schema = createFormSchemaFromFields(fields, customFields, false);
|
|
345
345
|
|
|
@@ -353,6 +353,19 @@ describe('form-schema-tools', () => {
|
|
|
353
353
|
expect(() => schema.parse(undefinedData)).toThrow();
|
|
354
354
|
});
|
|
355
355
|
|
|
356
|
+
// #5241: a create form accepts an empty nullable: false custom field. The create submit path
|
|
357
|
+
// strips the null (`stripNullNullableFields`), so the column's SQL DEFAULT applies.
|
|
358
|
+
it('should accept null and a missing value for nullable: false custom fields on a create form', () => {
|
|
359
|
+
const fields = [createMockField('customFields', 'Object', false, false, [])];
|
|
360
|
+
const customFields = [createMockCustomField('sku', 'string', { nullable: false })];
|
|
361
|
+
|
|
362
|
+
const createSchema = createFormSchemaFromFields(fields, customFields, false, true);
|
|
363
|
+
|
|
364
|
+
expect(() => createSchema.parse({ customFields: { sku: 'AB-123' } })).not.toThrow();
|
|
365
|
+
expect(() => createSchema.parse({ customFields: { sku: null } })).not.toThrow();
|
|
366
|
+
expect(() => createSchema.parse({ customFields: {} })).not.toThrow();
|
|
367
|
+
});
|
|
368
|
+
|
|
356
369
|
it('should only include non-translatable fields in root context', () => {
|
|
357
370
|
const fields = [createMockField('customFields', 'Object', false, false, [])];
|
|
358
371
|
const customFields = [
|
|
@@ -833,6 +846,49 @@ describe('form-schema-tools', () => {
|
|
|
833
846
|
expect(defaults.customFields.featureType).toBeNull();
|
|
834
847
|
});
|
|
835
848
|
|
|
849
|
+
// #5241: the null seeded for a nullable: false custom field passes the create schema only.
|
|
850
|
+
// It is stripped on submit, so the SQL DEFAULT applies. The update schema rejects it (NOT NULL).
|
|
851
|
+
it.each([
|
|
852
|
+
['int', 'Int'],
|
|
853
|
+
['float', 'Float'],
|
|
854
|
+
['datetime', 'DateTime'],
|
|
855
|
+
])('non-nullable %s custom field defaults to null, accepted on create only', (type, graphQlType) => {
|
|
856
|
+
const fields: FieldInfo[] = [
|
|
857
|
+
createMockField('customFields', 'Object', false, false, [
|
|
858
|
+
createMockField('position', graphQlType, true),
|
|
859
|
+
]),
|
|
860
|
+
];
|
|
861
|
+
const customFieldConfigs = [createMockCustomField('position', type, { nullable: false })];
|
|
862
|
+
|
|
863
|
+
const defaults = getDefaultValuesFromFields(fields, 'en', customFieldConfigs);
|
|
864
|
+
expect(defaults.customFields.position).toBeNull();
|
|
865
|
+
|
|
866
|
+
const createSchema = createFormSchemaFromFields(fields, customFieldConfigs, false, true);
|
|
867
|
+
expect(() => createSchema.parse(defaults)).not.toThrow();
|
|
868
|
+
|
|
869
|
+
// On an update the entity always supplies a value (the column is NOT NULL);
|
|
870
|
+
// clearing the input produces a null, which stays rejected.
|
|
871
|
+
const updateSchema = createFormSchemaFromFields(fields, customFieldConfigs, false, false);
|
|
872
|
+
expect(() => updateSchema.parse(defaults)).toThrow();
|
|
873
|
+
});
|
|
874
|
+
|
|
875
|
+
// Guards against regressing #4328 / PR #4339: a genuinely nullable numeric custom field
|
|
876
|
+
// keeps defaulting to null, which its schema keeps accepting.
|
|
877
|
+
it('nullable int custom field still defaults to null', () => {
|
|
878
|
+
const fields: FieldInfo[] = [
|
|
879
|
+
createMockField('customFields', 'Object', false, false, [
|
|
880
|
+
createMockField('position', 'Int', true),
|
|
881
|
+
]),
|
|
882
|
+
];
|
|
883
|
+
const customFieldConfigs = [createMockCustomField('position', 'int', { nullable: true })];
|
|
884
|
+
|
|
885
|
+
const defaults = getDefaultValuesFromFields(fields, 'en', customFieldConfigs);
|
|
886
|
+
const schema = createFormSchemaFromFields(fields, customFieldConfigs, false);
|
|
887
|
+
|
|
888
|
+
expect(defaults.customFields.position).toBeNull();
|
|
889
|
+
expect(() => schema.parse(defaults)).not.toThrow();
|
|
890
|
+
});
|
|
891
|
+
|
|
836
892
|
it('applyNullableSelectCustomFieldDefaults should normalize empty string to null', () => {
|
|
837
893
|
const values = { customFields: { featureType: '' } };
|
|
838
894
|
const customFieldConfigs = [
|
|
@@ -247,17 +247,29 @@ function createStructFieldSchema(structFieldConfig: StructCustomFieldConfig): Zo
|
|
|
247
247
|
* Many custom fields can be configured as lists (arrays) and/or nullable, so this helper
|
|
248
248
|
* centralizes that logic to avoid duplication.
|
|
249
249
|
*
|
|
250
|
+
* A create form also accepts an empty value for a `nullable: false` custom field (#5241). Every
|
|
251
|
+
* custom field is nullable in the GraphQL input type, so such a field is seeded `null`, and the
|
|
252
|
+
* create submit path strips that null from the payload (`stripNullNullableFields`). The server
|
|
253
|
+
* guarantees the field has a `defaultValue` backing the column's SQL DEFAULT, so the database
|
|
254
|
+
* supplies the value. The update schema keeps requiring one: the column is NOT NULL, so clearing
|
|
255
|
+
* the input must keep the form invalid, exactly as the server would reject that write.
|
|
256
|
+
*
|
|
250
257
|
* @param zodType - The base Zod schema to modify
|
|
251
258
|
* @param customField - Custom field config containing list/nullable flags
|
|
259
|
+
* @param isCreateForm - Whether the schema is for a create form (no entity yet)
|
|
252
260
|
* @returns Modified Zod schema with list/nullable modifiers applied
|
|
253
261
|
*/
|
|
254
|
-
function applyCustomFieldModifiers(
|
|
262
|
+
function applyCustomFieldModifiers(
|
|
263
|
+
zodType: ZodType,
|
|
264
|
+
customField: CustomFieldConfig,
|
|
265
|
+
isCreateForm: boolean,
|
|
266
|
+
): ZodType {
|
|
255
267
|
let modifiedType = zodType;
|
|
256
268
|
|
|
257
269
|
if (customField.list) {
|
|
258
270
|
modifiedType = z.array(modifiedType);
|
|
259
271
|
}
|
|
260
|
-
if (customField.nullable !== false || customField.readonly) {
|
|
272
|
+
if (customField.nullable !== false || customField.readonly || isCreateForm) {
|
|
261
273
|
modifiedType = modifiedType.optional().nullable();
|
|
262
274
|
}
|
|
263
275
|
if (customField.readonly) {
|
|
@@ -273,11 +285,13 @@ function applyCustomFieldModifiers(zodType: ZodType, customField: CustomFieldCon
|
|
|
273
285
|
*
|
|
274
286
|
* @param customFieldConfigs - Array of all custom field configurations
|
|
275
287
|
* @param isTranslationContext - Whether we're processing fields for translation forms
|
|
288
|
+
* @param isCreateForm - Whether the schema is for a create form (no entity yet)
|
|
276
289
|
* @returns Zod schema shape for the entire customFields object
|
|
277
290
|
*/
|
|
278
291
|
function processCustomFieldsSchema(
|
|
279
292
|
customFieldConfigs: CustomFieldConfig[],
|
|
280
293
|
isTranslationContext: boolean,
|
|
294
|
+
isCreateForm: boolean,
|
|
281
295
|
): ZodRawShape {
|
|
282
296
|
const customFieldsSchema: ZodRawShape = {};
|
|
283
297
|
const translatableTypes = ['localeString', 'localeText'];
|
|
@@ -299,7 +313,7 @@ function processCustomFieldsSchema(
|
|
|
299
313
|
zodType = createCustomFieldValidationSchema(customField);
|
|
300
314
|
}
|
|
301
315
|
|
|
302
|
-
zodType = applyCustomFieldModifiers(zodType, customField);
|
|
316
|
+
zodType = applyCustomFieldModifiers(zodType, customField, isCreateForm);
|
|
303
317
|
const schemaPropertyName = getGraphQlInputName(customField);
|
|
304
318
|
customFieldsSchema[schemaPropertyName] = zodType;
|
|
305
319
|
}
|
|
@@ -311,6 +325,7 @@ export function createFormSchemaFromFields(
|
|
|
311
325
|
fields: FieldInfo[],
|
|
312
326
|
customFieldConfigs?: CustomFieldConfig[],
|
|
313
327
|
isTranslationContext = false,
|
|
328
|
+
isCreateForm = false,
|
|
314
329
|
) {
|
|
315
330
|
const schemaConfig: ZodRawShape = {};
|
|
316
331
|
|
|
@@ -323,7 +338,7 @@ export function createFormSchemaFromFields(
|
|
|
323
338
|
} else if (field.name === 'customFields') {
|
|
324
339
|
const customFieldsSchema =
|
|
325
340
|
customFieldConfigs && customFieldConfigs.length > 0
|
|
326
|
-
? processCustomFieldsSchema(customFieldConfigs, isTranslationContext)
|
|
341
|
+
? processCustomFieldsSchema(customFieldConfigs, isTranslationContext, isCreateForm)
|
|
327
342
|
: {};
|
|
328
343
|
// Use .passthrough() to preserve custom field values that aren't in the schema
|
|
329
344
|
// This is essential for nested entities (e.g., ProductVariantPrice) whose custom
|
|
@@ -335,6 +350,7 @@ export function createFormSchemaFromFields(
|
|
|
335
350
|
field.typeInfo,
|
|
336
351
|
customFieldConfigs,
|
|
337
352
|
isNestedTranslationContext,
|
|
353
|
+
isCreateForm,
|
|
338
354
|
);
|
|
339
355
|
|
|
340
356
|
if (field.nullable) {
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { act, createElement, useState } from 'react';
|
|
2
|
+
import { createRoot } from 'react-dom/client';
|
|
3
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
4
|
+
|
|
5
|
+
import { FieldInfo } from '../document-introspection/get-document-structure.js';
|
|
6
|
+
import { useGeneratedForm } from './use-generated-form.js';
|
|
7
|
+
|
|
8
|
+
(globalThis as any).IS_REACT_ACT_ENVIRONMENT = true;
|
|
9
|
+
|
|
10
|
+
vi.mock('../../hooks/use-channel.js', () => ({
|
|
11
|
+
useChannel: () => ({ activeChannel: { defaultLanguageCode: 'en' } }),
|
|
12
|
+
}));
|
|
13
|
+
|
|
14
|
+
vi.mock('../../hooks/use-server-config.js', () => ({
|
|
15
|
+
useServerConfig: () => ({ availableLanguages: ['en'] }),
|
|
16
|
+
}));
|
|
17
|
+
|
|
18
|
+
// Mirrors `CreateStockLocationInput`: every custom field is nullable in the GraphQL input type,
|
|
19
|
+
// whatever its `nullable` setting in the custom field config.
|
|
20
|
+
const inputFields: FieldInfo[] = [
|
|
21
|
+
{ name: 'name', type: 'String', nullable: false, list: false, isPaginatedList: false, isScalar: true },
|
|
22
|
+
{
|
|
23
|
+
name: 'customFields',
|
|
24
|
+
type: 'CreateStockLocationCustomFieldsInput',
|
|
25
|
+
nullable: true,
|
|
26
|
+
list: false,
|
|
27
|
+
isPaginatedList: false,
|
|
28
|
+
isScalar: false,
|
|
29
|
+
typeInfo: [
|
|
30
|
+
{
|
|
31
|
+
name: 'defaultMinStock',
|
|
32
|
+
type: 'Int',
|
|
33
|
+
nullable: true,
|
|
34
|
+
list: false,
|
|
35
|
+
isPaginatedList: false,
|
|
36
|
+
isScalar: true,
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
},
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
vi.mock('virtual:admin-api-schema', () => {
|
|
43
|
+
return import('../document-introspection/testing-utils.js').then(m => m.getMockSchemaInfo());
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
vi.mock('../document-introspection/get-document-structure.js', async importOriginal => ({
|
|
47
|
+
...(await importOriginal<object>()),
|
|
48
|
+
getOperationVariablesFields: () => inputFields,
|
|
49
|
+
}));
|
|
50
|
+
|
|
51
|
+
// The document is only read through the mocked `getOperationVariablesFields` above.
|
|
52
|
+
const createDocument = {} as any;
|
|
53
|
+
|
|
54
|
+
const customFieldConfig = [{ name: 'defaultMinStock', type: 'int', nullable: false }] as any;
|
|
55
|
+
|
|
56
|
+
async function renderForm(initialEntity?: Record<string, any>) {
|
|
57
|
+
let form: ReturnType<typeof useGeneratedForm>['form'] | undefined;
|
|
58
|
+
let isValid: boolean | undefined;
|
|
59
|
+
let setEntity: (entity: Record<string, any>) => void = () => undefined;
|
|
60
|
+
function Probe() {
|
|
61
|
+
const [entity, set] = useState(initialEntity);
|
|
62
|
+
setEntity = set;
|
|
63
|
+
form = useGeneratedForm({
|
|
64
|
+
document: createDocument,
|
|
65
|
+
varName: 'input',
|
|
66
|
+
entity,
|
|
67
|
+
customFieldConfig,
|
|
68
|
+
setValues: e => ({ name: e.name, customFields: e.customFields }),
|
|
69
|
+
}).form;
|
|
70
|
+
isValid = form.formState.isValid;
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
const root = createRoot(document.createElement('div'));
|
|
74
|
+
await act(async () => {
|
|
75
|
+
root.render(createElement(Probe));
|
|
76
|
+
});
|
|
77
|
+
return {
|
|
78
|
+
getForm: () => form as NonNullable<typeof form>,
|
|
79
|
+
getIsValid: () => isValid,
|
|
80
|
+
setEntity: (entity: Record<string, any>) => act(async () => setEntity(entity)),
|
|
81
|
+
unmount: () => act(() => root.unmount()),
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const existingStockLocation = { id: '1', name: 'Warehouse', customFields: { defaultMinStock: 5 } };
|
|
86
|
+
|
|
87
|
+
// #5241: a nullable: false int custom field must not leave a create form invalid at mount
|
|
88
|
+
describe('useGeneratedForm with a nullable: false custom field', () => {
|
|
89
|
+
it('create form is valid once the required built-in fields are filled', async () => {
|
|
90
|
+
const { getForm, getIsValid, unmount } = await renderForm(undefined);
|
|
91
|
+
await act(async () => {
|
|
92
|
+
getForm().setValue('name', 'Warehouse', { shouldValidate: true });
|
|
93
|
+
});
|
|
94
|
+
expect(getIsValid()).toBe(true);
|
|
95
|
+
let valid: boolean | undefined;
|
|
96
|
+
await act(async () => {
|
|
97
|
+
valid = await getForm().trigger();
|
|
98
|
+
});
|
|
99
|
+
expect(valid).toBe(true);
|
|
100
|
+
unmount();
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it('update form still rejects a cleared value', async () => {
|
|
104
|
+
const { getForm, getIsValid, unmount } = await renderForm(existingStockLocation);
|
|
105
|
+
expect(getIsValid()).toBe(true);
|
|
106
|
+
await act(async () => {
|
|
107
|
+
getForm().setValue('customFields.defaultMinStock' as any, null, { shouldValidate: true });
|
|
108
|
+
});
|
|
109
|
+
expect(getIsValid()).toBe(false);
|
|
110
|
+
unmount();
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
// `useGeneratedForm` is public, and an extension may pass an entity loaded after the first render.
|
|
114
|
+
it('switches to the update schema when the entity arrives after the first render', async () => {
|
|
115
|
+
const { getForm, setEntity, unmount } = await renderForm(undefined);
|
|
116
|
+
let validBefore: boolean | undefined;
|
|
117
|
+
await act(async () => {
|
|
118
|
+
validBefore = await getForm().trigger('customFields.defaultMinStock' as any);
|
|
119
|
+
});
|
|
120
|
+
expect(validBefore).toBe(true);
|
|
121
|
+
await setEntity(existingStockLocation);
|
|
122
|
+
expect(getForm().getValues('customFields.defaultMinStock' as any)).toBe(5);
|
|
123
|
+
await act(async () => {
|
|
124
|
+
getForm().setValue('customFields.defaultMinStock' as any, null);
|
|
125
|
+
});
|
|
126
|
+
let validAfter: boolean | undefined;
|
|
127
|
+
await act(async () => {
|
|
128
|
+
validAfter = await getForm().trigger();
|
|
129
|
+
});
|
|
130
|
+
expect(validAfter).toBe(false);
|
|
131
|
+
unmount();
|
|
132
|
+
});
|
|
133
|
+
});
|
|
@@ -166,14 +166,20 @@ export function useGeneratedForm<
|
|
|
166
166
|
// config hasn't changed.
|
|
167
167
|
const availableLanguages = serverConfig?.availableLanguages ?? EMPTY_LANGUAGES;
|
|
168
168
|
|
|
169
|
+
// A create form has no entity. `useDetailPage` reads the entity through a suspended query, so
|
|
170
|
+
// `isCreateForm` stays constant there and the resolver is not swapped. A caller that passes the
|
|
171
|
+
// entity after the first render gets the update schema once it arrives. See
|
|
172
|
+
// `applyCustomFieldModifiers` (#5241).
|
|
173
|
+
const isCreateForm = !entity;
|
|
174
|
+
|
|
169
175
|
// Without memoisation these objects/arrays are rebuilt on every render of
|
|
170
176
|
// the parent route. When the schema changes identity, react-hook-form's
|
|
171
177
|
// resolver is replaced and the form re-validates everything; when
|
|
172
178
|
// defaultValues changes identity it can also reset uncontrolled inputs.
|
|
173
179
|
const schema = useMemo(() => {
|
|
174
|
-
const generated = createFormSchemaFromFields(updateFields, customFieldConfig);
|
|
180
|
+
const generated = createFormSchemaFromFields(updateFields, customFieldConfig, false, isCreateForm);
|
|
175
181
|
return extendSchemaRef.current?.(generated) ?? generated;
|
|
176
|
-
}, [updateFields, customFieldConfig]);
|
|
182
|
+
}, [updateFields, customFieldConfig, isCreateForm]);
|
|
177
183
|
const defaultValues = useMemo(
|
|
178
184
|
() => getDefaultValuesFromFields(updateFields, activeChannel?.defaultLanguageCode, customFieldConfig),
|
|
179
185
|
[updateFields, activeChannel?.defaultLanguageCode, customFieldConfig],
|