@mercurjs/dashboard-shared 2.3.9-canary.3 → 2.3.9-canary.5
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/index.d.ts +153 -13
- package/dist/index.js +425 -124
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -579,8 +579,9 @@ interface SidebarLinkProps {
|
|
|
579
579
|
labelKey: string;
|
|
580
580
|
descriptionKey: string;
|
|
581
581
|
icon: ReactNode;
|
|
582
|
+
dataTestid?: string;
|
|
582
583
|
}
|
|
583
|
-
declare const SidebarLink: ({ to, labelKey, descriptionKey, icon, }: SidebarLinkProps) => react_jsx_runtime.JSX.Element;
|
|
584
|
+
declare const SidebarLink: ({ to, labelKey, descriptionKey, icon, dataTestid, }: SidebarLinkProps) => react_jsx_runtime.JSX.Element;
|
|
584
585
|
|
|
585
586
|
type SkeletonProps = {
|
|
586
587
|
className?: string;
|
|
@@ -1816,6 +1817,14 @@ type ResolvedFormField = {
|
|
|
1816
1817
|
name: string;
|
|
1817
1818
|
field: CustomFormField;
|
|
1818
1819
|
};
|
|
1820
|
+
/**
|
|
1821
|
+
* A config entry keyed by a built-in field id. `field: null` removes the
|
|
1822
|
+
* built-in; a field replaces it.
|
|
1823
|
+
*/
|
|
1824
|
+
type FormFieldOverride = {
|
|
1825
|
+
overridden: boolean;
|
|
1826
|
+
field: CustomFormField | null;
|
|
1827
|
+
};
|
|
1819
1828
|
type OnboardingStep = {
|
|
1820
1829
|
id: string;
|
|
1821
1830
|
label?: string;
|
|
@@ -1896,8 +1905,15 @@ declare class ExtensionRegistry {
|
|
|
1896
1905
|
getActionLock(model: string, action: string, entity: unknown): string | undefined;
|
|
1897
1906
|
getActivity(model: string, entity: unknown): ActivityEntry[];
|
|
1898
1907
|
private resolveFormFields;
|
|
1899
|
-
|
|
1900
|
-
|
|
1908
|
+
private formEntriesFor;
|
|
1909
|
+
/**
|
|
1910
|
+
* Custom form fields added to a model's form zone (and optional tab). Entries
|
|
1911
|
+
* keyed by one of the host's `builtInFieldIds` are overrides, not additions,
|
|
1912
|
+
* and are read through `getFormFieldOverride` instead.
|
|
1913
|
+
*/
|
|
1914
|
+
getFormFields(model: string, zone: string, tab?: string, builtInFieldIds?: string[], exactTab?: boolean): ResolvedFormField[];
|
|
1915
|
+
/** Replacement (or removal, `field: null`) of a built-in form field. */
|
|
1916
|
+
getFormFieldOverride(model: string, zone: string, id: string, tab?: string, exactTab?: boolean): FormFieldOverride;
|
|
1901
1917
|
/**
|
|
1902
1918
|
* Resolves the onboarding wizard steps: built-ins merged with every
|
|
1903
1919
|
* `zone: "onboarding"` form entry for the model. Later configs win per tab.
|
|
@@ -1907,8 +1923,11 @@ declare class ExtensionRegistry {
|
|
|
1907
1923
|
getAllFormFields(model: string): ResolvedFormField[];
|
|
1908
1924
|
/** Section display contributions (field add/replace/remove + actions). */
|
|
1909
1925
|
getDisplays(model: string, zone: string): ResolvedDisplays;
|
|
1910
|
-
/**
|
|
1911
|
-
|
|
1926
|
+
/**
|
|
1927
|
+
* Merged table extension for a model. `zone` picks the table: `"list"` is the
|
|
1928
|
+
* model's list page, and also matches `list` blocks that omit a zone.
|
|
1929
|
+
*/
|
|
1930
|
+
getListExtension(model: string, zone?: string): CustomListExtension;
|
|
1912
1931
|
}
|
|
1913
1932
|
|
|
1914
1933
|
type RenderDefaultProps = {
|
|
@@ -2054,19 +2073,43 @@ declare function groupNavItems<T extends {
|
|
|
2054
2073
|
groups: NavItemGroup<T>[];
|
|
2055
2074
|
};
|
|
2056
2075
|
|
|
2057
|
-
type
|
|
2076
|
+
type AnyControl<TFieldValues extends FieldValues, TContext, TTransformed> = Control<TFieldValues, TContext, TTransformed>;
|
|
2077
|
+
type FormExtensionZoneProps<TFieldValues extends FieldValues = FieldValues, TContext = unknown, TTransformed = TFieldValues> = {
|
|
2058
2078
|
model: string;
|
|
2059
2079
|
zone: string;
|
|
2060
2080
|
tab?: string;
|
|
2061
|
-
control:
|
|
2081
|
+
control: AnyControl<TFieldValues, TContext, TTransformed>;
|
|
2062
2082
|
data?: unknown;
|
|
2083
|
+
/** The form's own field ids; config entries for them are overrides. */
|
|
2084
|
+
builtInFieldIds?: string[];
|
|
2085
|
+
/**
|
|
2086
|
+
* Render only fields aimed at `tab`. A tabbed form sets it on every tab but
|
|
2087
|
+
* the first, so untabbed fields render once.
|
|
2088
|
+
*/
|
|
2089
|
+
exactTab?: boolean;
|
|
2063
2090
|
};
|
|
2064
2091
|
/**
|
|
2065
2092
|
* Renders a model's custom form fields for a given zone/tab under the
|
|
2066
2093
|
* `additional_data.<field>` RHF namespace (Medusa's convention), through the
|
|
2067
2094
|
* mandated `Form.Field → Form.Item` primitive chain.
|
|
2068
2095
|
*/
|
|
2069
|
-
declare const FormExtensionZone: ({ model, zone, tab, control, data, }: FormExtensionZoneProps) => react_jsx_runtime.JSX.Element | null;
|
|
2096
|
+
declare const FormExtensionZone: <TFieldValues extends FieldValues, TContext, TTransformed>({ model, zone, tab, control, data, builtInFieldIds, exactTab, }: FormExtensionZoneProps<TFieldValues, TContext, TTransformed>) => react_jsx_runtime.JSX.Element | null;
|
|
2097
|
+
type ExtendableFormFieldProps<TFieldValues extends FieldValues = FieldValues, TContext = unknown, TTransformed = TFieldValues> = {
|
|
2098
|
+
model: string;
|
|
2099
|
+
zone: string;
|
|
2100
|
+
tab?: string;
|
|
2101
|
+
/** The built-in field's form key, which is also its override id. */
|
|
2102
|
+
id: string;
|
|
2103
|
+
control: AnyControl<TFieldValues, TContext, TTransformed>;
|
|
2104
|
+
data?: unknown;
|
|
2105
|
+
children: ReactNode;
|
|
2106
|
+
};
|
|
2107
|
+
/**
|
|
2108
|
+
* Wraps one of a form's own fields so `forms[].fields[id]` can replace it (the
|
|
2109
|
+
* replacement binds to the same form key; validation stays the base schema's)
|
|
2110
|
+
* or remove it (`null`, the field keeps its default value).
|
|
2111
|
+
*/
|
|
2112
|
+
declare const ExtendableFormField: <TFieldValues extends FieldValues, TContext, TTransformed>({ model, zone, tab, id, control, data, children, }: ExtendableFormFieldProps<TFieldValues, TContext, TTransformed>) => react_jsx_runtime.JSX.Element | null;
|
|
2070
2113
|
|
|
2071
2114
|
type DisplayExtensionZoneProps = {
|
|
2072
2115
|
model: string;
|
|
@@ -2136,6 +2179,11 @@ declare function useDisplayFieldOverride(model: string, zone: string, id: string
|
|
|
2136
2179
|
type UseExtendableTableProps<TData> = {
|
|
2137
2180
|
/** Model whose custom-fields `list` block extends this table (e.g. `product`). */
|
|
2138
2181
|
model: string;
|
|
2182
|
+
/**
|
|
2183
|
+
* Which of the model's tables this is. Defaults to `"list"` (the list page);
|
|
2184
|
+
* embedded tables pass their own zone so `list` blocks can target them.
|
|
2185
|
+
*/
|
|
2186
|
+
zone?: string;
|
|
2139
2187
|
/** Base columns to extend. */
|
|
2140
2188
|
columns: ColumnDef<TData, unknown>[];
|
|
2141
2189
|
};
|
|
@@ -2156,7 +2204,52 @@ type ExtendableTable<TData> = {
|
|
|
2156
2204
|
* (merge them into the base filters with `mergeListFilters`) and `bulkActions`
|
|
2157
2205
|
* for the caller to render.
|
|
2158
2206
|
*/
|
|
2159
|
-
declare function useExtendableTable<TData>({ model, columns: baseColumns, }: UseExtendableTableProps<TData>): ExtendableTable<TData>;
|
|
2207
|
+
declare function useExtendableTable<TData>({ model, zone, columns: baseColumns, }: UseExtendableTableProps<TData>): ExtendableTable<TData>;
|
|
2208
|
+
|
|
2209
|
+
type GridFieldName<TData> = (context: {
|
|
2210
|
+
row: {
|
|
2211
|
+
original: TData;
|
|
2212
|
+
};
|
|
2213
|
+
}) => string | null;
|
|
2214
|
+
type ExtensionGridColumnArgs<TData> = {
|
|
2215
|
+
id: string;
|
|
2216
|
+
field: CustomFormField;
|
|
2217
|
+
/** Form path the cell edits; `null` renders it read-only. */
|
|
2218
|
+
getFieldName: GridFieldName<TData>;
|
|
2219
|
+
};
|
|
2220
|
+
type UseExtendableGridProps<TData> = {
|
|
2221
|
+
model: string;
|
|
2222
|
+
zone: string;
|
|
2223
|
+
tab?: string;
|
|
2224
|
+
/** Base data-grid columns (built with the panel's `createDataGridHelper`). */
|
|
2225
|
+
columns: ColumnDef<TData, unknown>[];
|
|
2226
|
+
/** Base column ids that can't be removed or replaced (e.g. the row title). */
|
|
2227
|
+
lockedColumnIds?: string[];
|
|
2228
|
+
/**
|
|
2229
|
+
* Whether config fields the grid doesn't ship become columns. Off for grids
|
|
2230
|
+
* whose rows have nowhere to save `additional_data`.
|
|
2231
|
+
*/
|
|
2232
|
+
allowAdd?: boolean;
|
|
2233
|
+
/**
|
|
2234
|
+
* Form path of a row's entry (e.g. `variants.3`); added fields bind to
|
|
2235
|
+
* `<path>.additional_data.<id>`. `null` keeps the row read-only. Omit it
|
|
2236
|
+
* together with `allowAdd: false`.
|
|
2237
|
+
*/
|
|
2238
|
+
getRowPath?: (row: TData) => string | null;
|
|
2239
|
+
/**
|
|
2240
|
+
* Builds a grid column for a config field. Panels ship their own DataGrid
|
|
2241
|
+
* cells, so the cell rendering stays on the panel side.
|
|
2242
|
+
*/
|
|
2243
|
+
createColumn: (args: ExtensionGridColumnArgs<TData>) => ColumnDef<TData, unknown>;
|
|
2244
|
+
};
|
|
2245
|
+
/**
|
|
2246
|
+
* Applies a form tab's `forms[].fields` to a data grid, the way
|
|
2247
|
+
* `<ExtendableFormField>` does for a regular form: a base column id + `null`
|
|
2248
|
+
* removes the column, a base id + field replaces how it renders (it keeps
|
|
2249
|
+
* editing the base column's form path), and any other key appends an editable
|
|
2250
|
+
* column bound to the row's `additional_data`.
|
|
2251
|
+
*/
|
|
2252
|
+
declare function useExtendableGrid<TData>(props: UseExtendableGridProps<TData>): ColumnDef<TData, unknown>[];
|
|
2160
2253
|
|
|
2161
2254
|
type Keyed = {
|
|
2162
2255
|
key: string;
|
|
@@ -2211,14 +2304,54 @@ declare function createFormHelper<TData>(): {
|
|
|
2211
2304
|
nullable: typeof z.nullable;
|
|
2212
2305
|
coerce: typeof z.coerce;
|
|
2213
2306
|
};
|
|
2307
|
+
type FormFieldInputType = "text" | "number" | "boolean" | "select" | "textarea";
|
|
2308
|
+
/** Input kind for a custom field: its explicit `type`, else its zod type. */
|
|
2309
|
+
declare function resolveFormFieldType(field: CustomFormField): FormFieldInputType;
|
|
2214
2310
|
/**
|
|
2215
2311
|
* Build the `additional_data` zod object for a model's custom fields, to merge
|
|
2216
2312
|
* into a form's base schema. Custom-field values live under `additional_data`
|
|
2217
2313
|
* so the built-in create/edit validators never see them.
|
|
2218
2314
|
*/
|
|
2219
|
-
declare function buildAdditionalDataSchema(registry: ExtensionRegistry, model: string, zone?: string, tab?: string): z.ZodObject<Record<string, z.ZodTypeAny>>;
|
|
2315
|
+
declare function buildAdditionalDataSchema(registry: ExtensionRegistry, model: string, zone?: string, tab?: string, builtInFieldIds?: string[]): z.ZodObject<Record<string, z.ZodTypeAny>>;
|
|
2220
2316
|
/** Resolve default values for a model's custom fields from the loaded entity. */
|
|
2221
|
-
declare function buildAdditionalDataDefaults(registry: ExtensionRegistry, model: string, data?: unknown, zone?: string, tab?: string): Record<string, unknown>;
|
|
2317
|
+
declare function buildAdditionalDataDefaults(registry: ExtensionRegistry, model: string, data?: unknown, zone?: string, tab?: string, builtInFieldIds?: string[]): Record<string, unknown>;
|
|
2318
|
+
type AdditionalDataScope = {
|
|
2319
|
+
model: string;
|
|
2320
|
+
zone: string;
|
|
2321
|
+
/**
|
|
2322
|
+
* Tabs whose fields land in this form state. Untabbed fields of the zone are
|
|
2323
|
+
* included unless `exactTab` is set.
|
|
2324
|
+
*/
|
|
2325
|
+
tabs?: string[];
|
|
2326
|
+
exactTab?: boolean;
|
|
2327
|
+
builtInFieldIds?: string[];
|
|
2328
|
+
};
|
|
2329
|
+
/**
|
|
2330
|
+
* `additional_data` schema and defaults for the fields of a zone's tabs. A
|
|
2331
|
+
* tabbed form passes its regular tabs; a data-grid tab passes `[tab]` with
|
|
2332
|
+
* `exactTab`, so the result describes one row.
|
|
2333
|
+
*/
|
|
2334
|
+
declare function buildScopedAdditionalData(registry: ExtensionRegistry, { model, zone, tabs, exactTab, builtInFieldIds }: AdditionalDataScope, data?: unknown): {
|
|
2335
|
+
schema: z.ZodObject<Record<string, z.ZodTypeAny>>;
|
|
2336
|
+
defaults: Record<string, unknown>;
|
|
2337
|
+
};
|
|
2338
|
+
type AdditionalDataRows = {
|
|
2339
|
+
/** Form key of the row array (e.g. `variants`). */
|
|
2340
|
+
path: string;
|
|
2341
|
+
schema: z.ZodObject<Record<string, z.ZodTypeAny>>;
|
|
2342
|
+
/** Rows that are submitted; others skip validation. */
|
|
2343
|
+
include?: (row: Record<string, unknown>) => boolean;
|
|
2344
|
+
};
|
|
2345
|
+
/**
|
|
2346
|
+
* Validates custom fields on top of a base schema that can't be extended (a
|
|
2347
|
+
* refined object). Errors land on `additional_data.<field>` and
|
|
2348
|
+
* `<rows.path>.<i>.additional_data.<field>`, so form fields and grid cells
|
|
2349
|
+
* show them in place.
|
|
2350
|
+
*/
|
|
2351
|
+
declare function refineAdditionalData<TSchema extends z.ZodTypeAny>(schema: TSchema, { additionalData, rows, }: {
|
|
2352
|
+
additionalData?: z.ZodObject<Record<string, z.ZodTypeAny>>;
|
|
2353
|
+
rows?: AdditionalDataRows;
|
|
2354
|
+
}): TSchema;
|
|
2222
2355
|
|
|
2223
2356
|
type WithAdditionalData<T> = T & {
|
|
2224
2357
|
additional_data?: Record<string, unknown>;
|
|
@@ -2240,6 +2373,11 @@ interface UseExtendableFormProps<TSchema extends ZodObject<Record<string, z.ZodT
|
|
|
2240
2373
|
*/
|
|
2241
2374
|
zone?: string;
|
|
2242
2375
|
tab?: string;
|
|
2376
|
+
/**
|
|
2377
|
+
* Ids of the form's own fields. Config entries keyed by one of them replace
|
|
2378
|
+
* or remove that field (`<ExtendableFormField>`) instead of adding one.
|
|
2379
|
+
*/
|
|
2380
|
+
builtInFieldIds?: string[];
|
|
2243
2381
|
}
|
|
2244
2382
|
/**
|
|
2245
2383
|
* `useForm` that merges a model's registered custom fields into the base
|
|
@@ -2248,7 +2386,7 @@ interface UseExtendableFormProps<TSchema extends ZodObject<Record<string, z.ZodT
|
|
|
2248
2386
|
* built-in validators never see them; the extension registry provides the
|
|
2249
2387
|
* per-field zod validation and default values.
|
|
2250
2388
|
*/
|
|
2251
|
-
declare const useExtendableForm: <TSchema extends ZodObject<Record<string, z.ZodTypeAny>>, TContext = unknown, TTransformedValues extends FieldValues = WithAdditionalData<z.infer<TSchema>>>({ schema: baseSchema, defaultValues: baseDefaultValues, model, data, zone, tab, ...props }: UseExtendableFormProps<TSchema, TContext, unknown, TTransformedValues>) => react_hook_form.UseFormReturn<WithAdditionalData<z.core.output<TSchema>>, TContext, TTransformedValues>;
|
|
2389
|
+
declare const useExtendableForm: <TSchema extends ZodObject<Record<string, z.ZodTypeAny>>, TContext = unknown, TTransformedValues extends FieldValues = WithAdditionalData<z.infer<TSchema>>>({ schema: baseSchema, defaultValues: baseDefaultValues, model, data, zone, tab, builtInFieldIds, ...props }: UseExtendableFormProps<TSchema, TContext, unknown, TTransformedValues>) => react_hook_form.UseFormReturn<WithAdditionalData<z.core.output<TSchema>>, TContext, TTransformedValues>;
|
|
2252
2390
|
|
|
2253
2391
|
/** Returns a lookup for the lock reason plugins declare on an entity's action. */
|
|
2254
2392
|
declare const useActionLocks: (model: string, entity: unknown) => (action: string) => string | undefined;
|
|
@@ -2431,4 +2569,6 @@ declare const RICH_TEXT_ALLOWED_ATTRIBUTES: string[];
|
|
|
2431
2569
|
declare const isHtml: (value?: string | null) => boolean;
|
|
2432
2570
|
declare const plainTextToHtml: (value?: string | null) => string;
|
|
2433
2571
|
|
|
2434
|
-
|
|
2572
|
+
declare const getListInitialData: <TData>(queryParams: Record<string, string | undefined>, loaderData: TData | undefined) => TData | undefined;
|
|
2573
|
+
|
|
2574
|
+
export { type Action, type ActionGroup, ActionMenu, type AdditionalDataScope, AddressForm, AddressSchema, type AttributeChange, type AttributeChangeKind, AttributeValueInput, BadgeListSummary, CORE_ENTRY_PREFIX, CORE_LAYOUTS, ChipGroup, ChipInput, CodeCell, CodeHeader, Combobox, type Command, ConditionalTooltip, ConfirmPrompt, type ConfirmPromptProps, type CoreNavItem, CountrySelect, CreatedAtCell, CreatedAtHeader, type CurrencyInfo, type CustomFieldsModule, CustomerInfo, DataGrid, DataTable, DateCell, DateHeader, DateRangeDisplay, DeprecatedPercentageInput, type DetailPageDefaultsOptions, type DisplayEntry, DisplayExtensionZone, type DisplayExtensionZoneProps, DisplayField, type DisplayFieldProps, DisplaySection, type DisplaySectionField, type DisplaySectionProps, type EditAttributeAttribute, EditAttributeForm, type EditAttributeFormProps, EmailCell, EmailForm, EmailHeader, EmailSchema, type EntryRenderer, ErrorBoundary, ExtendableFormField, type ExtendableFormFieldProps, type ExtendableTable, type ExtensionGridColumnArgs, ExtensionProvider, type ExtensionProviderProps, ExtensionRegistry, type ExtractableOffer, type ExtractableOffers, type FieldDiff, FilePreview, type FileType, FileUpload, type FileUploadProps, type Filter, FilterGroup, Form, FormExtensionZone, type FormExtensionZoneProps, type FormFieldInputType, type FormFieldOverride, GeneralSectionSkeleton, type GridFieldName, HandleInput, HeadingSkeleton, IconAvatar, IconButtonSkeleton, ImageAvatar, type ImageRef, IncludesTaxTooltip, InfiniteList, JsonViewSection, JsonViewSectionSkeleton, KeyboundForm, LayoutComposer, type LayoutComposerProps, LayoutEntry, type LayoutEntryProps, type LayoutModule, LinkButton, ListBadge, ListSummary, Listicle, type ListicleProps, LocalizedTablePagination, type MediaDiff, MetadataForm, MetadataSection, MoneyAmountCell, NameCell, NameHeader, type NavGroup, type NavGroupItem, type NavItemGroup, type NavigationModule, NoRecords, type NoRecordsProps, NoResults, type NoResultsProps, type OnboardingStep, type OnboardingStepDefault, OrderBy, PercentageInput, PermissionAction, type PermissionActionProps, PermissionGuard, type PermissionGuardProps, type PermissionedCommand, PermissionsContext, PermissionsProvider, type PermissionsProviderProps, PlaceholderCell, type PreferenceModule, PriceListDateStatus, type PriceListGridGroupRow, type PriceListGridOfferRow, type PriceListGridRow, PriceListStatus, PriceListType, type ProductAttributeBatchPayload, ProductAttributeSection, type ProductAttributeSectionProps, type ProductChangeAttribute, ProductChangePanel, type ProductChangePanelProps, type ProductChangeProduct, type ProductChangeResolvers, type ProductChangeVariant, type ProductChangeView, ProgressBar, ProvinceSelect, Query, REFERENCE_FIELDS, RICH_TEXT_ALLOWED_ATTRIBUTES, RICH_TEXT_ALLOWED_TAGS, type RawEntry, type ReferenceField, type RenderDefaultProps, type ResolvedAttribute, type ResolvedDisplays, type ResolvedFormField, RichText, RichTextEditor, type RichTextEditorProps, RouteDrawer, RouteFocusModal, RoutePermissionGuard, SIDEBAR_MENU_CONTENT, SIDEBAR_RAIL_FADE, SectionNoAccess, SectionRow, type SectionRowProps, type SectionWidget, type SectionWidgetMap, SegmentedControl, type SegmentedControlOption, SidebarContext, type SidebarContextValue, SidebarLink, type SidebarLinkProps, SidebarProvider, type SidebarState, SingleColumnLayoutComponent, SingleColumnPage, SingleColumnPageSkeleton, Skeleton, SortableList, SortableTree, StackedDrawer, StackedFocusModal, type StaticCountry, StatusCell, SwitchBox, type TQueryKey, type TabDefinition, TabbedForm, TableFooterSkeleton, TableSectionSkeleton, TableSkeleton, TextCell, TextHeader, TextSkeleton, Thumbnail, TransferOwnershipSchema, TwoColumnLayoutComponent, TwoColumnPage, TwoColumnPageSkeleton, type UseExtendableFormProps, type UseExtendableGridProps, type UseExtendableTableProps, type UseQueryOptionsWrapper, type VariantGroup, VisuallyHidden, type Widget, type WidgetModule, type WidgetPlacement, type WidgetTab, type WidgetTabs, WidgetZone, type WidgetZoneProps, type ZoneWidgets, _DataTable, applyActionPermissions, applyNavGroups, applyNavOverrides, applyReplacements, buildAdditionalDataDefaults, buildAdditionalDataSchema, buildCoreEntries, buildDisplayEntries, buildOfferGridData, buildProductChangeView, buildScopedAdditionalData, buildWidgetEntries, countries, createDataGridHelper, createDataGridPriceColumns, createFormHelper, createWithPermission, currencies, detailPageDefaultEntries, extractPricesFromOffers, extractReferenceIds, extractSectionElements, filterCommandsByPermission, formatFieldValue, genericForwardRef, getCountryByIso2, getCurrencySymbol, getDecimalDigits, getExtensionRegistry, getFormattedAddress, getFormattedCountry, getLinkQuery, getListInitialData, getLocaleAmount, getNativeSymbol, getPriceListStatus, getStylizedAmount, groupNavItems, humanizeFieldName, isAmountLessThenRoundingError, isForbidden, isHtml, isImageList, isOrderActionable, isOrderAwaitingAction, isPermitted, isPriceListGroupRow, isProductRow, isReferenceField, isSameAddress, linkFields, mergeLayoutPreferences, mergeListFilters, navOverridesFromPreferences, permissionMapAllows, plainTextToHtml, productChangeViewHasContent, queryClient, queryKeysFactory, refineAdditionalData, resolveFormFieldType, resolveRouteOverrides, richTextContentClasses, sanitizeRichText, toPermissionList, useActionLocks, useCan, useCollapsedSidebar, useCombinedRefs, useCommandHistory, useDataTable, useDate, useDisplayFieldOverride, useDocumentDirection, useExpandedSidebar, useExtendableForm, useExtendableGrid, useExtendableTable, useExtension, useExtensionActivity, useLinkQuery, usePermissionGate, usePermissions, usePermittedCommands, useQueryParams, useResourcePermissions, useRouteModal, useSidebar, useSidebarMenuPlacement, useStackedModal, useTabManagement, useTabbedForm, useWidgetTabs, withLinkFields };
|
package/dist/index.js
CHANGED
|
@@ -10010,7 +10010,8 @@ var require_common40 = __commonJS({
|
|
|
10010
10010
|
"../types/dist/payout/common.js"(exports) {
|
|
10011
10011
|
"use strict";
|
|
10012
10012
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10013
|
-
exports.
|
|
10013
|
+
exports.PayoutStatusReason = exports.PayoutModuleEvents = exports.PayoutStatus = exports.PayoutKycStatus = exports.PayoutAccountStatus = void 0;
|
|
10014
|
+
exports.resolvePayoutModuleOptions = resolvePayoutModuleOptions;
|
|
10014
10015
|
var PayoutAccountStatus;
|
|
10015
10016
|
(function(PayoutAccountStatus2) {
|
|
10016
10017
|
PayoutAccountStatus2["PENDING"] = "pending";
|
|
@@ -10018,26 +10019,53 @@ var require_common40 = __commonJS({
|
|
|
10018
10019
|
PayoutAccountStatus2["RESTRICTED"] = "restricted";
|
|
10019
10020
|
PayoutAccountStatus2["REJECTED"] = "rejected";
|
|
10020
10021
|
})(PayoutAccountStatus || (exports.PayoutAccountStatus = PayoutAccountStatus = {}));
|
|
10022
|
+
var PayoutKycStatus;
|
|
10023
|
+
(function(PayoutKycStatus2) {
|
|
10024
|
+
PayoutKycStatus2["PENDING_SUBMISSION"] = "pending_submission";
|
|
10025
|
+
PayoutKycStatus2["PENDING_APPROVAL"] = "pending_approval";
|
|
10026
|
+
PayoutKycStatus2["APPROVED"] = "approved";
|
|
10027
|
+
PayoutKycStatus2["REFUSED"] = "refused";
|
|
10028
|
+
})(PayoutKycStatus || (exports.PayoutKycStatus = PayoutKycStatus = {}));
|
|
10021
10029
|
var PayoutStatus;
|
|
10022
10030
|
(function(PayoutStatus2) {
|
|
10023
10031
|
PayoutStatus2["PENDING"] = "pending";
|
|
10032
|
+
PayoutStatus2["ON_HOLD"] = "on_hold";
|
|
10024
10033
|
PayoutStatus2["PROCESSING"] = "processing";
|
|
10025
10034
|
PayoutStatus2["PAID"] = "paid";
|
|
10026
10035
|
PayoutStatus2["FAILED"] = "failed";
|
|
10027
|
-
PayoutStatus2["
|
|
10036
|
+
PayoutStatus2["ABORTED"] = "aborted";
|
|
10028
10037
|
})(PayoutStatus || (exports.PayoutStatus = PayoutStatus = {}));
|
|
10029
|
-
|
|
10030
|
-
|
|
10031
|
-
|
|
10032
|
-
|
|
10033
|
-
|
|
10034
|
-
}
|
|
10035
|
-
|
|
10036
|
-
|
|
10037
|
-
|
|
10038
|
-
|
|
10039
|
-
|
|
10040
|
-
|
|
10038
|
+
exports.PayoutModuleEvents = {
|
|
10039
|
+
ACCOUNT_UPDATED: "payout_account.updated",
|
|
10040
|
+
PAYOUT_FAILED: "payout.failed",
|
|
10041
|
+
PAYOUT_REVERSAL_FAILED: "payout.reversal_failed",
|
|
10042
|
+
WEBHOOK_RECEIVED: "payout.webhook_received"
|
|
10043
|
+
};
|
|
10044
|
+
function resolvePayoutModuleOptions(options) {
|
|
10045
|
+
return {
|
|
10046
|
+
onboarding: {
|
|
10047
|
+
returnUrl: "",
|
|
10048
|
+
refreshBaseUrl: "",
|
|
10049
|
+
prefill: false,
|
|
10050
|
+
tokenTtlSeconds: 24 * 60 * 60,
|
|
10051
|
+
...options?.onboarding ?? {}
|
|
10052
|
+
}
|
|
10053
|
+
};
|
|
10054
|
+
}
|
|
10055
|
+
exports.PayoutStatusReason = {
|
|
10056
|
+
ACCOUNT_NOT_READY: "account_not_ready",
|
|
10057
|
+
ACCOUNT_PAYOUTS_DISABLED: "account_payouts_disabled",
|
|
10058
|
+
ORDER_NOT_READY: "order_not_ready",
|
|
10059
|
+
ORDER_ABORTED: "order_aborted",
|
|
10060
|
+
PAYMENT_NOT_READY: "payment_not_ready",
|
|
10061
|
+
PAYMENT_FAILED: "payment_failed",
|
|
10062
|
+
PAYMENT_CANCELED: "payment_canceled",
|
|
10063
|
+
PAYMENT_REFUNDED: "payment_refunded",
|
|
10064
|
+
PAYOUT_NOT_READY: "payout_not_ready",
|
|
10065
|
+
REFUND_ABORTED: "refund_aborted",
|
|
10066
|
+
REFUND_ABSORBED: "refund_absorbed",
|
|
10067
|
+
INVALID_AMOUNT: "invalid_amount",
|
|
10068
|
+
PROVIDER_ERROR: "provider_error"
|
|
10041
10069
|
};
|
|
10042
10070
|
}
|
|
10043
10071
|
});
|
|
@@ -10047,6 +10075,25 @@ var require_provider11 = __commonJS({
|
|
|
10047
10075
|
"../types/dist/payout/provider.js"(exports) {
|
|
10048
10076
|
"use strict";
|
|
10049
10077
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10078
|
+
exports.PayoutProviderError = exports.PayoutProviderErrorCode = void 0;
|
|
10079
|
+
var PayoutProviderErrorCode;
|
|
10080
|
+
(function(PayoutProviderErrorCode2) {
|
|
10081
|
+
PayoutProviderErrorCode2["UNKNOWN"] = "unknown";
|
|
10082
|
+
PayoutProviderErrorCode2["REFUSED"] = "refused";
|
|
10083
|
+
PayoutProviderErrorCode2["FINAL"] = "final";
|
|
10084
|
+
})(PayoutProviderErrorCode || (exports.PayoutProviderErrorCode = PayoutProviderErrorCode = {}));
|
|
10085
|
+
var PayoutProviderError = class extends Error {
|
|
10086
|
+
constructor(message, options) {
|
|
10087
|
+
super(message);
|
|
10088
|
+
__publicField(this, "code");
|
|
10089
|
+
this.name = "PayoutProviderError";
|
|
10090
|
+
this.code = options?.code ?? (options?.final ? PayoutProviderErrorCode.FINAL : PayoutProviderErrorCode.UNKNOWN);
|
|
10091
|
+
}
|
|
10092
|
+
get final() {
|
|
10093
|
+
return this.code === PayoutProviderErrorCode.FINAL;
|
|
10094
|
+
}
|
|
10095
|
+
};
|
|
10096
|
+
exports.PayoutProviderError = PayoutProviderError;
|
|
10050
10097
|
}
|
|
10051
10098
|
});
|
|
10052
10099
|
|
|
@@ -10058,6 +10105,14 @@ var require_mutations24 = __commonJS({
|
|
|
10058
10105
|
}
|
|
10059
10106
|
});
|
|
10060
10107
|
|
|
10108
|
+
// ../types/dist/payout/service.js
|
|
10109
|
+
var require_service31 = __commonJS({
|
|
10110
|
+
"../types/dist/payout/service.js"(exports) {
|
|
10111
|
+
"use strict";
|
|
10112
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10113
|
+
}
|
|
10114
|
+
});
|
|
10115
|
+
|
|
10061
10116
|
// ../types/dist/payout/index.js
|
|
10062
10117
|
var require_payout2 = __commonJS({
|
|
10063
10118
|
"../types/dist/payout/index.js"(exports) {
|
|
@@ -10082,6 +10137,7 @@ var require_payout2 = __commonJS({
|
|
|
10082
10137
|
__exportStar(require_common40(), exports);
|
|
10083
10138
|
__exportStar(require_provider11(), exports);
|
|
10084
10139
|
__exportStar(require_mutations24(), exports);
|
|
10140
|
+
__exportStar(require_service31(), exports);
|
|
10085
10141
|
}
|
|
10086
10142
|
});
|
|
10087
10143
|
|
|
@@ -10102,7 +10158,7 @@ var require_mutations25 = __commonJS({
|
|
|
10102
10158
|
});
|
|
10103
10159
|
|
|
10104
10160
|
// ../types/dist/offer/service.js
|
|
10105
|
-
var
|
|
10161
|
+
var require_service32 = __commonJS({
|
|
10106
10162
|
"../types/dist/offer/service.js"(exports) {
|
|
10107
10163
|
"use strict";
|
|
10108
10164
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -10153,7 +10209,7 @@ var require_offer2 = __commonJS({
|
|
|
10153
10209
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10154
10210
|
__exportStar(require_common41(), exports);
|
|
10155
10211
|
__exportStar(require_mutations25(), exports);
|
|
10156
|
-
__exportStar(
|
|
10212
|
+
__exportStar(require_service32(), exports);
|
|
10157
10213
|
__exportStar(require_leadtime(), exports);
|
|
10158
10214
|
}
|
|
10159
10215
|
});
|
|
@@ -10341,6 +10397,7 @@ var require_modules = __commonJS({
|
|
|
10341
10397
|
MercurModules2["CODEGEN"] = "codegen";
|
|
10342
10398
|
MercurModules2["PROMOTION_COST"] = "promotion_cost";
|
|
10343
10399
|
MercurModules2["REVIEW"] = "review";
|
|
10400
|
+
MercurModules2["TELEMETRY"] = "telemetry";
|
|
10344
10401
|
})(MercurModules || (exports.MercurModules = MercurModules = {}));
|
|
10345
10402
|
}
|
|
10346
10403
|
});
|
|
@@ -15886,9 +15943,10 @@ var SidebarLink = ({
|
|
|
15886
15943
|
to,
|
|
15887
15944
|
labelKey,
|
|
15888
15945
|
descriptionKey,
|
|
15889
|
-
icon
|
|
15946
|
+
icon,
|
|
15947
|
+
dataTestid
|
|
15890
15948
|
}) => {
|
|
15891
|
-
return /* @__PURE__ */ jsx28(Link6, { to, className: "group outline-none", children: /* @__PURE__ */ jsx28("div", { className: "flex flex-col gap-2 px-2 pb-2", children: /* @__PURE__ */ jsx28("div", { className: "shadow-elevation-card-rest bg-ui-bg-component transition-fg hover:bg-ui-bg-component-hover active:bg-ui-bg-component-pressed group-focus-visible:shadow-borders-interactive-with-active rounded-md px-4 py-2", children: /* @__PURE__ */ jsxs21("div", { className: "flex items-center gap-4", children: [
|
|
15949
|
+
return /* @__PURE__ */ jsx28(Link6, { to, className: "group outline-none", "data-testid": dataTestid, children: /* @__PURE__ */ jsx28("div", { className: "flex flex-col gap-2 px-2 pb-2", children: /* @__PURE__ */ jsx28("div", { className: "shadow-elevation-card-rest bg-ui-bg-component transition-fg hover:bg-ui-bg-component-hover active:bg-ui-bg-component-pressed group-focus-visible:shadow-borders-interactive-with-active rounded-md px-4 py-2", children: /* @__PURE__ */ jsxs21("div", { className: "flex items-center gap-4", children: [
|
|
15892
15950
|
/* @__PURE__ */ jsx28(IconAvatar, { children: icon }),
|
|
15893
15951
|
/* @__PURE__ */ jsxs21("div", { className: "flex flex-1 flex-col", children: [
|
|
15894
15952
|
/* @__PURE__ */ jsx28(Text11, { size: "small", leading: "compact", weight: "plus", children: labelKey }),
|
|
@@ -26223,13 +26281,32 @@ var ExtensionRegistry = class {
|
|
|
26223
26281
|
}
|
|
26224
26282
|
return [...byName.values()];
|
|
26225
26283
|
}
|
|
26226
|
-
|
|
26227
|
-
|
|
26284
|
+
// An entry without a tab belongs to every tab of its zone, unless the host
|
|
26285
|
+
// asks for `exactTab` (a data grid tab only takes fields aimed at it).
|
|
26286
|
+
formEntriesFor(model, zone, tab, exactTab = false) {
|
|
26228
26287
|
return this.resolveFormFields(model).filter((entry) => {
|
|
26229
26288
|
if (entry.zone !== zone) return false;
|
|
26230
|
-
if (!entry.tab) return
|
|
26289
|
+
if (!entry.tab) return !exactTab;
|
|
26231
26290
|
return !!tab && entry.tab === tab;
|
|
26232
|
-
})
|
|
26291
|
+
});
|
|
26292
|
+
}
|
|
26293
|
+
/**
|
|
26294
|
+
* Custom form fields added to a model's form zone (and optional tab). Entries
|
|
26295
|
+
* keyed by one of the host's `builtInFieldIds` are overrides, not additions,
|
|
26296
|
+
* and are read through `getFormFieldOverride` instead.
|
|
26297
|
+
*/
|
|
26298
|
+
getFormFields(model, zone, tab, builtInFieldIds = [], exactTab = false) {
|
|
26299
|
+
const builtIns = new Set(builtInFieldIds);
|
|
26300
|
+
return this.formEntriesFor(model, zone, tab, exactTab).flatMap(
|
|
26301
|
+
({ name, field }) => field && !builtIns.has(name) ? [{ name, field }] : []
|
|
26302
|
+
);
|
|
26303
|
+
}
|
|
26304
|
+
/** Replacement (or removal, `field: null`) of a built-in form field. */
|
|
26305
|
+
getFormFieldOverride(model, zone, id, tab, exactTab = false) {
|
|
26306
|
+
const entry = this.formEntriesFor(model, zone, tab, exactTab).find(
|
|
26307
|
+
(e) => e.name === id
|
|
26308
|
+
);
|
|
26309
|
+
return entry ? { overridden: true, field: entry.field } : { overridden: false, field: null };
|
|
26233
26310
|
}
|
|
26234
26311
|
/**
|
|
26235
26312
|
* Resolves the onboarding wizard steps: built-ins merged with every
|
|
@@ -26280,7 +26357,9 @@ var ExtensionRegistry = class {
|
|
|
26280
26357
|
}
|
|
26281
26358
|
/** All custom form fields for a model, keyed for schema/default building. */
|
|
26282
26359
|
getAllFormFields(model) {
|
|
26283
|
-
return this.resolveFormFields(model).
|
|
26360
|
+
return this.resolveFormFields(model).flatMap(
|
|
26361
|
+
({ name, field }) => field ? [{ name, field }] : []
|
|
26362
|
+
);
|
|
26284
26363
|
}
|
|
26285
26364
|
/** Section display contributions (field add/replace/remove + actions). */
|
|
26286
26365
|
getDisplays(model, zone) {
|
|
@@ -26296,16 +26375,21 @@ var ExtensionRegistry = class {
|
|
|
26296
26375
|
actions.sort((a, b) => (a.rank ?? 0) - (b.rank ?? 0));
|
|
26297
26376
|
return { fields: [...fields.values()], actions };
|
|
26298
26377
|
}
|
|
26299
|
-
/**
|
|
26300
|
-
|
|
26378
|
+
/**
|
|
26379
|
+
* Merged table extension for a model. `zone` picks the table: `"list"` is the
|
|
26380
|
+
* model's list page, and also matches `list` blocks that omit a zone.
|
|
26381
|
+
*/
|
|
26382
|
+
getListExtension(model, zone = "list") {
|
|
26301
26383
|
const columns = /* @__PURE__ */ new Map();
|
|
26302
26384
|
const filters = /* @__PURE__ */ new Map();
|
|
26303
26385
|
const bulkActions = [];
|
|
26304
26386
|
const columnVisibility = {};
|
|
26305
26387
|
let columnOrder = [];
|
|
26306
|
-
|
|
26307
|
-
|
|
26308
|
-
|
|
26388
|
+
const lists = this.configsFor(model).flatMap(
|
|
26389
|
+
(config3) => config3.list ? [config3.list].flat() : []
|
|
26390
|
+
);
|
|
26391
|
+
for (const list of lists) {
|
|
26392
|
+
if ((list.zone ?? "list") !== zone) continue;
|
|
26309
26393
|
for (const column of list.columns ?? []) columns.set(column.id, column);
|
|
26310
26394
|
for (const filter of list.filters ?? []) filters.set(filter.key, filter);
|
|
26311
26395
|
if (list.bulkActions) bulkActions.push(...list.bulkActions);
|
|
@@ -26590,8 +26674,24 @@ function groupNavItems(items, groups = []) {
|
|
|
26590
26674
|
}
|
|
26591
26675
|
|
|
26592
26676
|
// src/extensions/form-extension-zone.tsx
|
|
26593
|
-
import { Input as Input10, Switch as Switch2, Textarea as Textarea4 } from "@medusajs/ui";
|
|
26594
|
-
|
|
26677
|
+
import { Input as Input10, Select as Select5, Switch as Switch2, Textarea as Textarea4 } from "@medusajs/ui";
|
|
26678
|
+
|
|
26679
|
+
// src/extensions/custom-fields-form.ts
|
|
26680
|
+
import { z as z3 } from "zod";
|
|
26681
|
+
function createFormHelper() {
|
|
26682
|
+
return {
|
|
26683
|
+
define: (field) => field,
|
|
26684
|
+
string: () => z3.string(),
|
|
26685
|
+
number: () => z3.number(),
|
|
26686
|
+
boolean: () => z3.boolean(),
|
|
26687
|
+
date: () => z3.date(),
|
|
26688
|
+
array: z3.array,
|
|
26689
|
+
object: z3.object,
|
|
26690
|
+
null: () => z3.null(),
|
|
26691
|
+
nullable: z3.nullable,
|
|
26692
|
+
coerce: z3.coerce
|
|
26693
|
+
};
|
|
26694
|
+
}
|
|
26595
26695
|
var ZOD_WRAPPER_TYPES = /* @__PURE__ */ new Set([
|
|
26596
26696
|
"optional",
|
|
26597
26697
|
"nullable",
|
|
@@ -26601,7 +26701,8 @@ var ZOD_WRAPPER_TYPES = /* @__PURE__ */ new Set([
|
|
|
26601
26701
|
"readonly",
|
|
26602
26702
|
"catch"
|
|
26603
26703
|
]);
|
|
26604
|
-
function
|
|
26704
|
+
function resolveFormFieldType(field) {
|
|
26705
|
+
if (field.type) return field.type;
|
|
26605
26706
|
let def = field.validation?.def;
|
|
26606
26707
|
while (def && ZOD_WRAPPER_TYPES.has(def.type ?? "")) {
|
|
26607
26708
|
def = def.innerType?.def;
|
|
@@ -26609,29 +26710,123 @@ function zodType(field) {
|
|
|
26609
26710
|
switch (def?.type) {
|
|
26610
26711
|
case "boolean":
|
|
26611
26712
|
case "number":
|
|
26612
|
-
case "string":
|
|
26613
26713
|
return def.type;
|
|
26714
|
+
case "string":
|
|
26715
|
+
return "text";
|
|
26614
26716
|
default:
|
|
26615
26717
|
return "textarea";
|
|
26616
26718
|
}
|
|
26617
26719
|
}
|
|
26618
|
-
|
|
26619
|
-
const
|
|
26720
|
+
function buildAdditionalDataSchema(registry, model, zone, tab, builtInFieldIds) {
|
|
26721
|
+
const shape = {};
|
|
26722
|
+
const fields = zone ? registry.getFormFields(model, zone, tab, builtInFieldIds) : registry.getAllFormFields(model);
|
|
26723
|
+
for (const { name, field } of fields) {
|
|
26724
|
+
shape[name] = field.validation;
|
|
26725
|
+
}
|
|
26726
|
+
return z3.object(shape);
|
|
26727
|
+
}
|
|
26728
|
+
function buildAdditionalDataDefaults(registry, model, data, zone, tab, builtInFieldIds) {
|
|
26729
|
+
const defaults = {};
|
|
26730
|
+
const fields = zone ? registry.getFormFields(model, zone, tab, builtInFieldIds) : registry.getAllFormFields(model);
|
|
26731
|
+
for (const { name, field } of fields) {
|
|
26732
|
+
if (typeof field.defaultValue === "function") {
|
|
26733
|
+
defaults[name] = field.defaultValue(data);
|
|
26734
|
+
} else if (field.defaultValue !== void 0) {
|
|
26735
|
+
defaults[name] = field.defaultValue;
|
|
26736
|
+
}
|
|
26737
|
+
}
|
|
26738
|
+
return defaults;
|
|
26739
|
+
}
|
|
26740
|
+
function buildScopedAdditionalData(registry, { model, zone, tabs, exactTab, builtInFieldIds }, data) {
|
|
26741
|
+
const fields = /* @__PURE__ */ new Map();
|
|
26742
|
+
for (const tab of tabs?.length ? tabs : [void 0]) {
|
|
26743
|
+
for (const { name, field } of registry.getFormFields(
|
|
26744
|
+
model,
|
|
26745
|
+
zone,
|
|
26746
|
+
tab,
|
|
26747
|
+
builtInFieldIds,
|
|
26748
|
+
exactTab
|
|
26749
|
+
)) {
|
|
26750
|
+
fields.set(name, field);
|
|
26751
|
+
}
|
|
26752
|
+
}
|
|
26753
|
+
const shape = {};
|
|
26754
|
+
const defaults = {};
|
|
26755
|
+
for (const [name, field] of fields) {
|
|
26756
|
+
shape[name] = field.validation;
|
|
26757
|
+
if (typeof field.defaultValue === "function") {
|
|
26758
|
+
defaults[name] = field.defaultValue(data);
|
|
26759
|
+
} else if (field.defaultValue !== void 0) {
|
|
26760
|
+
defaults[name] = field.defaultValue;
|
|
26761
|
+
}
|
|
26762
|
+
}
|
|
26763
|
+
return { schema: z3.object(shape), defaults };
|
|
26764
|
+
}
|
|
26765
|
+
function refineAdditionalData(schema, {
|
|
26766
|
+
additionalData,
|
|
26767
|
+
rows
|
|
26768
|
+
}) {
|
|
26769
|
+
const hasFields = (s) => !!s && Object.keys(s.shape).length > 0;
|
|
26770
|
+
if (!hasFields(additionalData) && !hasFields(rows?.schema)) return schema;
|
|
26771
|
+
return schema.superRefine((value, ctx) => {
|
|
26772
|
+
const report = (target, data, prefix) => {
|
|
26773
|
+
const result = target.safeParse(data ?? {});
|
|
26774
|
+
if (result.success) return;
|
|
26775
|
+
for (const issue of result.error.issues) {
|
|
26776
|
+
ctx.addIssue({
|
|
26777
|
+
code: "custom",
|
|
26778
|
+
message: issue.message,
|
|
26779
|
+
path: [...prefix, ...issue.path.map((p) => p)]
|
|
26780
|
+
});
|
|
26781
|
+
}
|
|
26782
|
+
};
|
|
26783
|
+
const values = value;
|
|
26784
|
+
if (additionalData && hasFields(additionalData)) {
|
|
26785
|
+
report(additionalData, values.additional_data, ["additional_data"]);
|
|
26786
|
+
}
|
|
26787
|
+
if (rows && hasFields(rows.schema)) {
|
|
26788
|
+
const list = values[rows.path] ?? [];
|
|
26789
|
+
list.forEach((row, index) => {
|
|
26790
|
+
if (rows.include && !rows.include(row)) return;
|
|
26791
|
+
report(rows.schema, row.additional_data, [
|
|
26792
|
+
rows.path,
|
|
26793
|
+
index,
|
|
26794
|
+
"additional_data"
|
|
26795
|
+
]);
|
|
26796
|
+
});
|
|
26797
|
+
}
|
|
26798
|
+
});
|
|
26799
|
+
}
|
|
26800
|
+
|
|
26801
|
+
// src/extensions/form-extension-zone.tsx
|
|
26802
|
+
import { Fragment as Fragment9, jsx as jsx82, jsxs as jsxs58 } from "react/jsx-runtime";
|
|
26803
|
+
var ExtensionField = ({ name, path, field, control, data }) => {
|
|
26804
|
+
const type = resolveFormFieldType(field);
|
|
26620
26805
|
const Component = field.component;
|
|
26621
26806
|
return /* @__PURE__ */ jsx82(
|
|
26622
26807
|
Form.Field,
|
|
26623
26808
|
{
|
|
26624
26809
|
control,
|
|
26625
|
-
name:
|
|
26810
|
+
name: path,
|
|
26626
26811
|
render: ({ field: rhf }) => /* @__PURE__ */ jsxs58(Form.Item, { children: [
|
|
26627
26812
|
/* @__PURE__ */ jsx82(Form.Label, { children: field.label ?? name }),
|
|
26628
26813
|
field.description && /* @__PURE__ */ jsx82(Form.Hint, { children: field.description }),
|
|
26629
|
-
/* @__PURE__ */ jsx82(Form.Control, { children: Component ? /* @__PURE__ */ jsx82(Component, {}) : type === "boolean" ? /* @__PURE__ */ jsx82(
|
|
26814
|
+
/* @__PURE__ */ jsx82(Form.Control, { children: Component ? /* @__PURE__ */ jsx82(Component, { field: rhf, data }) : type === "boolean" ? /* @__PURE__ */ jsx82(
|
|
26630
26815
|
Switch2,
|
|
26631
26816
|
{
|
|
26632
26817
|
checked: !!rhf.value,
|
|
26633
26818
|
onCheckedChange: rhf.onChange
|
|
26634
26819
|
}
|
|
26820
|
+
) : type === "select" ? /* @__PURE__ */ jsxs58(
|
|
26821
|
+
Select5,
|
|
26822
|
+
{
|
|
26823
|
+
value: rhf.value ?? "",
|
|
26824
|
+
onValueChange: rhf.onChange,
|
|
26825
|
+
children: [
|
|
26826
|
+
/* @__PURE__ */ jsx82(Select5.Trigger, { ref: rhf.ref, children: /* @__PURE__ */ jsx82(Select5.Value, { placeholder: field.placeholder }) }),
|
|
26827
|
+
/* @__PURE__ */ jsx82(Select5.Content, { children: (field.options ?? []).map((option) => /* @__PURE__ */ jsx82(Select5.Item, { value: option.value, children: option.label }, option.value)) })
|
|
26828
|
+
]
|
|
26829
|
+
}
|
|
26635
26830
|
) : type === "number" ? /* @__PURE__ */ jsx82(
|
|
26636
26831
|
Input10,
|
|
26637
26832
|
{
|
|
@@ -26640,7 +26835,7 @@ var ExtensionField = ({ name, field, control }) => {
|
|
|
26640
26835
|
...rhf,
|
|
26641
26836
|
value: rhf.value ?? ""
|
|
26642
26837
|
}
|
|
26643
|
-
) : type === "
|
|
26838
|
+
) : type === "text" ? /* @__PURE__ */ jsx82(
|
|
26644
26839
|
Input10,
|
|
26645
26840
|
{
|
|
26646
26841
|
placeholder: field.placeholder,
|
|
@@ -26660,30 +26855,68 @@ var ExtensionField = ({ name, field, control }) => {
|
|
|
26660
26855
|
}
|
|
26661
26856
|
);
|
|
26662
26857
|
};
|
|
26858
|
+
var widen = (control) => control;
|
|
26663
26859
|
var FormExtensionZone = ({
|
|
26664
26860
|
model,
|
|
26665
26861
|
zone,
|
|
26666
26862
|
tab,
|
|
26667
26863
|
control,
|
|
26668
|
-
data
|
|
26864
|
+
data,
|
|
26865
|
+
builtInFieldIds,
|
|
26866
|
+
exactTab
|
|
26669
26867
|
}) => {
|
|
26670
|
-
const fields = useExtension().getFormFields(
|
|
26868
|
+
const fields = useExtension().getFormFields(
|
|
26869
|
+
model,
|
|
26870
|
+
zone,
|
|
26871
|
+
tab,
|
|
26872
|
+
builtInFieldIds,
|
|
26873
|
+
exactTab
|
|
26874
|
+
);
|
|
26671
26875
|
if (fields.length === 0) return null;
|
|
26672
26876
|
return /* @__PURE__ */ jsx82("div", { className: "flex flex-col gap-y-4", children: fields.map(({ name, field }) => /* @__PURE__ */ jsx82(
|
|
26673
26877
|
ExtensionField,
|
|
26674
26878
|
{
|
|
26675
26879
|
name,
|
|
26880
|
+
path: `additional_data.${name}`,
|
|
26676
26881
|
field,
|
|
26677
|
-
control,
|
|
26882
|
+
control: widen(control),
|
|
26678
26883
|
data
|
|
26679
26884
|
},
|
|
26680
26885
|
name
|
|
26681
26886
|
)) });
|
|
26682
26887
|
};
|
|
26888
|
+
var ExtendableFormField = ({
|
|
26889
|
+
model,
|
|
26890
|
+
zone,
|
|
26891
|
+
tab,
|
|
26892
|
+
id,
|
|
26893
|
+
control,
|
|
26894
|
+
data,
|
|
26895
|
+
children
|
|
26896
|
+
}) => {
|
|
26897
|
+
const { overridden, field } = useExtension().getFormFieldOverride(
|
|
26898
|
+
model,
|
|
26899
|
+
zone,
|
|
26900
|
+
id,
|
|
26901
|
+
tab
|
|
26902
|
+
);
|
|
26903
|
+
if (!overridden) return /* @__PURE__ */ jsx82(Fragment9, { children });
|
|
26904
|
+
if (!field) return null;
|
|
26905
|
+
return /* @__PURE__ */ jsx82(
|
|
26906
|
+
ExtensionField,
|
|
26907
|
+
{
|
|
26908
|
+
name: id,
|
|
26909
|
+
path: id,
|
|
26910
|
+
field,
|
|
26911
|
+
control: widen(control),
|
|
26912
|
+
data
|
|
26913
|
+
}
|
|
26914
|
+
);
|
|
26915
|
+
};
|
|
26683
26916
|
|
|
26684
26917
|
// src/extensions/display-extension-zone.tsx
|
|
26685
|
-
import { Fragment as
|
|
26686
|
-
import { Fragment as
|
|
26918
|
+
import { Fragment as Fragment10 } from "react";
|
|
26919
|
+
import { Fragment as Fragment11, jsx as jsx83, jsxs as jsxs59 } from "react/jsx-runtime";
|
|
26687
26920
|
var DisplayExtensionZone = ({
|
|
26688
26921
|
model,
|
|
26689
26922
|
zone,
|
|
@@ -26694,7 +26927,7 @@ var DisplayExtensionZone = ({
|
|
|
26694
26927
|
const builtIn = new Set(builtInFieldIds);
|
|
26695
26928
|
const added = fields.filter((f) => f.component && !builtIn.has(f.id));
|
|
26696
26929
|
if (added.length === 0 && actions.length === 0) return null;
|
|
26697
|
-
return /* @__PURE__ */ jsxs59(
|
|
26930
|
+
return /* @__PURE__ */ jsxs59(Fragment11, { children: [
|
|
26698
26931
|
added.map(({ id, component: Component }) => {
|
|
26699
26932
|
const C = Component;
|
|
26700
26933
|
return /* @__PURE__ */ jsx83(C, { data }, id);
|
|
@@ -26716,14 +26949,14 @@ var DisplayField = ({
|
|
|
26716
26949
|
if (overridden) {
|
|
26717
26950
|
return Component ? /* @__PURE__ */ jsx83(Component, { data }) : null;
|
|
26718
26951
|
}
|
|
26719
|
-
return /* @__PURE__ */ jsx83(
|
|
26952
|
+
return /* @__PURE__ */ jsx83(Fragment10, { children });
|
|
26720
26953
|
};
|
|
26721
26954
|
var DisplaySection = ({
|
|
26722
26955
|
model,
|
|
26723
26956
|
zone,
|
|
26724
26957
|
data,
|
|
26725
26958
|
fields
|
|
26726
|
-
}) => /* @__PURE__ */ jsxs59(
|
|
26959
|
+
}) => /* @__PURE__ */ jsxs59(Fragment11, { children: [
|
|
26727
26960
|
fields.map(({ id, render }) => /* @__PURE__ */ jsx83(DisplayField, { model, zone, id, data, children: render }, id)),
|
|
26728
26961
|
/* @__PURE__ */ jsx83(
|
|
26729
26962
|
DisplayExtensionZone,
|
|
@@ -26754,9 +26987,10 @@ function columnId(col) {
|
|
|
26754
26987
|
}
|
|
26755
26988
|
function useExtendableTable({
|
|
26756
26989
|
model,
|
|
26990
|
+
zone = "list",
|
|
26757
26991
|
columns: baseColumns
|
|
26758
26992
|
}) {
|
|
26759
|
-
const ext = useExtension().getListExtension(model);
|
|
26993
|
+
const ext = useExtension().getListExtension(model, zone);
|
|
26760
26994
|
return useMemo18(() => {
|
|
26761
26995
|
const helper = createColumnHelper2();
|
|
26762
26996
|
const build = (c) => helper.display({
|
|
@@ -26798,6 +27032,88 @@ function useExtendableTable({
|
|
|
26798
27032
|
}, [baseColumns, ext]);
|
|
26799
27033
|
}
|
|
26800
27034
|
|
|
27035
|
+
// src/extensions/use-extendable-grid.ts
|
|
27036
|
+
import { useMemo as useMemo19 } from "react";
|
|
27037
|
+
var columnId2 = (col) => col.id;
|
|
27038
|
+
var baseFieldName = (col) => col.meta?.field ?? (() => null);
|
|
27039
|
+
function applyGridExtension(extension, {
|
|
27040
|
+
model,
|
|
27041
|
+
zone,
|
|
27042
|
+
tab,
|
|
27043
|
+
columns: baseColumns,
|
|
27044
|
+
lockedColumnIds,
|
|
27045
|
+
allowAdd = true,
|
|
27046
|
+
getRowPath,
|
|
27047
|
+
createColumn
|
|
27048
|
+
}) {
|
|
27049
|
+
const locked = new Set(lockedColumnIds);
|
|
27050
|
+
const builtInIds = baseColumns.flatMap((c) => columnId2(c) ?? []);
|
|
27051
|
+
const columns = baseColumns.flatMap((col) => {
|
|
27052
|
+
const id = columnId2(col);
|
|
27053
|
+
if (!id || locked.has(id)) return [col];
|
|
27054
|
+
const { overridden, field } = extension.getFormFieldOverride(
|
|
27055
|
+
model,
|
|
27056
|
+
zone,
|
|
27057
|
+
id,
|
|
27058
|
+
tab,
|
|
27059
|
+
true
|
|
27060
|
+
);
|
|
27061
|
+
if (!overridden) return [col];
|
|
27062
|
+
if (!field) return [];
|
|
27063
|
+
return [createColumn({ id, field, getFieldName: baseFieldName(col) })];
|
|
27064
|
+
});
|
|
27065
|
+
const added = allowAdd ? extension.getFormFields(model, zone, tab, builtInIds, true) : [];
|
|
27066
|
+
for (const { name, field } of added) {
|
|
27067
|
+
columns.push(
|
|
27068
|
+
createColumn({
|
|
27069
|
+
id: name,
|
|
27070
|
+
field,
|
|
27071
|
+
getFieldName: (context) => {
|
|
27072
|
+
const path = getRowPath?.(context.row.original) ?? null;
|
|
27073
|
+
return path ? `${path}.additional_data.${name}` : null;
|
|
27074
|
+
}
|
|
27075
|
+
})
|
|
27076
|
+
);
|
|
27077
|
+
}
|
|
27078
|
+
return columns;
|
|
27079
|
+
}
|
|
27080
|
+
function useExtendableGrid(props) {
|
|
27081
|
+
const extension = useExtension();
|
|
27082
|
+
const {
|
|
27083
|
+
model,
|
|
27084
|
+
zone,
|
|
27085
|
+
tab,
|
|
27086
|
+
columns,
|
|
27087
|
+
lockedColumnIds,
|
|
27088
|
+
allowAdd,
|
|
27089
|
+
getRowPath,
|
|
27090
|
+
createColumn
|
|
27091
|
+
} = props;
|
|
27092
|
+
return useMemo19(
|
|
27093
|
+
() => applyGridExtension(extension, {
|
|
27094
|
+
model,
|
|
27095
|
+
zone,
|
|
27096
|
+
tab,
|
|
27097
|
+
columns,
|
|
27098
|
+
lockedColumnIds,
|
|
27099
|
+
allowAdd,
|
|
27100
|
+
getRowPath,
|
|
27101
|
+
createColumn
|
|
27102
|
+
}),
|
|
27103
|
+
[
|
|
27104
|
+
extension,
|
|
27105
|
+
model,
|
|
27106
|
+
zone,
|
|
27107
|
+
tab,
|
|
27108
|
+
columns,
|
|
27109
|
+
lockedColumnIds,
|
|
27110
|
+
allowAdd,
|
|
27111
|
+
getRowPath,
|
|
27112
|
+
createColumn
|
|
27113
|
+
]
|
|
27114
|
+
);
|
|
27115
|
+
}
|
|
27116
|
+
|
|
26801
27117
|
// src/extensions/list-filters.ts
|
|
26802
27118
|
var isRemoval = (filter) => "remove" in filter && filter.remove === true;
|
|
26803
27119
|
function mergeListFilters(base, extensions) {
|
|
@@ -26841,46 +27157,9 @@ var useLinkQuery = (model, base) => {
|
|
|
26841
27157
|
return { fields: base ? withLinkFields(base, links) : linkFields(links) };
|
|
26842
27158
|
};
|
|
26843
27159
|
|
|
26844
|
-
// src/extensions/custom-fields-form.ts
|
|
26845
|
-
import { z as z3 } from "zod";
|
|
26846
|
-
function createFormHelper() {
|
|
26847
|
-
return {
|
|
26848
|
-
define: (field) => field,
|
|
26849
|
-
string: () => z3.string(),
|
|
26850
|
-
number: () => z3.number(),
|
|
26851
|
-
boolean: () => z3.boolean(),
|
|
26852
|
-
date: () => z3.date(),
|
|
26853
|
-
array: z3.array,
|
|
26854
|
-
object: z3.object,
|
|
26855
|
-
null: () => z3.null(),
|
|
26856
|
-
nullable: z3.nullable,
|
|
26857
|
-
coerce: z3.coerce
|
|
26858
|
-
};
|
|
26859
|
-
}
|
|
26860
|
-
function buildAdditionalDataSchema(registry, model, zone, tab) {
|
|
26861
|
-
const shape = {};
|
|
26862
|
-
const fields = zone ? registry.getFormFields(model, zone, tab) : registry.getAllFormFields(model);
|
|
26863
|
-
for (const { name, field } of fields) {
|
|
26864
|
-
shape[name] = field.validation;
|
|
26865
|
-
}
|
|
26866
|
-
return z3.object(shape);
|
|
26867
|
-
}
|
|
26868
|
-
function buildAdditionalDataDefaults(registry, model, data, zone, tab) {
|
|
26869
|
-
const defaults = {};
|
|
26870
|
-
const fields = zone ? registry.getFormFields(model, zone, tab) : registry.getAllFormFields(model);
|
|
26871
|
-
for (const { name, field } of fields) {
|
|
26872
|
-
if (typeof field.defaultValue === "function") {
|
|
26873
|
-
defaults[name] = field.defaultValue(data);
|
|
26874
|
-
} else if (field.defaultValue !== void 0) {
|
|
26875
|
-
defaults[name] = field.defaultValue;
|
|
26876
|
-
}
|
|
26877
|
-
}
|
|
26878
|
-
return defaults;
|
|
26879
|
-
}
|
|
26880
|
-
|
|
26881
27160
|
// src/extensions/use-extendable-form.ts
|
|
26882
27161
|
import { zodResolver as zodResolver3 } from "@hookform/resolvers/zod";
|
|
26883
|
-
import { useMemo as
|
|
27162
|
+
import { useMemo as useMemo20 } from "react";
|
|
26884
27163
|
import { useForm as useForm3 } from "react-hook-form";
|
|
26885
27164
|
import { z as z4 } from "zod";
|
|
26886
27165
|
var useExtendableForm = ({
|
|
@@ -26890,14 +27169,21 @@ var useExtendableForm = ({
|
|
|
26890
27169
|
data,
|
|
26891
27170
|
zone,
|
|
26892
27171
|
tab,
|
|
27172
|
+
builtInFieldIds,
|
|
26893
27173
|
...props
|
|
26894
27174
|
}) => {
|
|
26895
27175
|
const extension = useExtension();
|
|
26896
|
-
const schema =
|
|
26897
|
-
const additionalData = buildAdditionalDataSchema(
|
|
27176
|
+
const schema = useMemo20(() => {
|
|
27177
|
+
const additionalData = buildAdditionalDataSchema(
|
|
27178
|
+
extension,
|
|
27179
|
+
model,
|
|
27180
|
+
zone,
|
|
27181
|
+
tab,
|
|
27182
|
+
builtInFieldIds
|
|
27183
|
+
).partial().optional();
|
|
26898
27184
|
return typeof baseSchema.extend === "function" ? baseSchema.extend({ additional_data: additionalData }) : baseSchema.and(z4.object({ additional_data: additionalData }));
|
|
26899
|
-
}, [baseSchema, extension, model, zone, tab]);
|
|
26900
|
-
const defaultValues =
|
|
27185
|
+
}, [baseSchema, extension, model, zone, tab, builtInFieldIds]);
|
|
27186
|
+
const defaultValues = useMemo20(
|
|
26901
27187
|
() => ({
|
|
26902
27188
|
...baseDefaultValues,
|
|
26903
27189
|
additional_data: buildAdditionalDataDefaults(
|
|
@@ -26905,10 +27191,11 @@ var useExtendableForm = ({
|
|
|
26905
27191
|
model,
|
|
26906
27192
|
data,
|
|
26907
27193
|
zone,
|
|
26908
|
-
tab
|
|
27194
|
+
tab,
|
|
27195
|
+
builtInFieldIds
|
|
26909
27196
|
)
|
|
26910
27197
|
}),
|
|
26911
|
-
[baseDefaultValues, extension, model, data, zone, tab]
|
|
27198
|
+
[baseDefaultValues, extension, model, data, zone, tab, builtInFieldIds]
|
|
26912
27199
|
);
|
|
26913
27200
|
return useForm3({
|
|
26914
27201
|
...props,
|
|
@@ -26918,7 +27205,7 @@ var useExtendableForm = ({
|
|
|
26918
27205
|
};
|
|
26919
27206
|
|
|
26920
27207
|
// src/extensions/action-locks.ts
|
|
26921
|
-
import { useCallback as useCallback22, useMemo as
|
|
27208
|
+
import { useCallback as useCallback22, useMemo as useMemo21 } from "react";
|
|
26922
27209
|
var useActionLocks = (model, entity) => {
|
|
26923
27210
|
const registry = useExtension();
|
|
26924
27211
|
return useCallback22(
|
|
@@ -26928,7 +27215,7 @@ var useActionLocks = (model, entity) => {
|
|
|
26928
27215
|
};
|
|
26929
27216
|
var useExtensionActivity = (model, entity) => {
|
|
26930
27217
|
const registry = useExtension();
|
|
26931
|
-
return
|
|
27218
|
+
return useMemo21(
|
|
26932
27219
|
() => registry.getActivity(model, entity),
|
|
26933
27220
|
[registry, model, entity]
|
|
26934
27221
|
);
|
|
@@ -27166,17 +27453,17 @@ import {
|
|
|
27166
27453
|
Children as Children3,
|
|
27167
27454
|
createContext as createContext9,
|
|
27168
27455
|
useContext as useContext13,
|
|
27169
|
-
useMemo as
|
|
27456
|
+
useMemo as useMemo23
|
|
27170
27457
|
} from "react";
|
|
27171
27458
|
import { useTranslation as useTranslation36 } from "react-i18next";
|
|
27172
27459
|
|
|
27173
27460
|
// src/components/tabbed-form/use-tab-management.ts
|
|
27174
|
-
import { useCallback as useCallback23, useEffect as useEffect20, useMemo as
|
|
27461
|
+
import { useCallback as useCallback23, useEffect as useEffect20, useMemo as useMemo22, useState as useState31 } from "react";
|
|
27175
27462
|
var useTabManagement = ({
|
|
27176
27463
|
tabs,
|
|
27177
27464
|
form
|
|
27178
27465
|
}) => {
|
|
27179
|
-
const visibleTabs =
|
|
27466
|
+
const visibleTabs = useMemo22(
|
|
27180
27467
|
() => tabs.filter((t2) => !t2.isVisible || t2.isVisible(form)),
|
|
27181
27468
|
[tabs, form]
|
|
27182
27469
|
);
|
|
@@ -27285,11 +27572,11 @@ function Root6({
|
|
|
27285
27572
|
transformTabs
|
|
27286
27573
|
}) {
|
|
27287
27574
|
const { t: t2 } = useTranslation36();
|
|
27288
|
-
const { tabs: rawTabs, elements } =
|
|
27575
|
+
const { tabs: rawTabs, elements } = useMemo23(
|
|
27289
27576
|
() => collectTabs(children),
|
|
27290
27577
|
[children]
|
|
27291
27578
|
);
|
|
27292
|
-
const tabs =
|
|
27579
|
+
const tabs = useMemo23(
|
|
27293
27580
|
() => transformTabs ? transformTabs(rawTabs) : rawTabs,
|
|
27294
27581
|
[transformTabs, rawTabs]
|
|
27295
27582
|
);
|
|
@@ -27420,7 +27707,7 @@ import { memo } from "react";
|
|
|
27420
27707
|
// src/components/table/data-table/data-table-filter/data-table-filter.tsx
|
|
27421
27708
|
import { Button as Button13, clx as clx48 } from "@medusajs/ui";
|
|
27422
27709
|
import { Popover as RadixPopover8 } from "radix-ui";
|
|
27423
|
-
import { useCallback as useCallback26, useEffect as useEffect23, useMemo as
|
|
27710
|
+
import { useCallback as useCallback26, useEffect as useEffect23, useMemo as useMemo25, useRef as useRef18, useState as useState36 } from "react";
|
|
27424
27711
|
import { useSearchParams as useSearchParams7 } from "react-router-dom";
|
|
27425
27712
|
import { useTranslation as useTranslation41 } from "react-i18next";
|
|
27426
27713
|
|
|
@@ -27442,7 +27729,7 @@ import { EllipseMiniSolid as EllipseMiniSolid2 } from "@medusajs/icons";
|
|
|
27442
27729
|
import { DatePicker, Text as Text20, clx as clx44 } from "@medusajs/ui";
|
|
27443
27730
|
import isEqual from "lodash.isequal";
|
|
27444
27731
|
import { Popover as RadixPopover4 } from "radix-ui";
|
|
27445
|
-
import { useMemo as
|
|
27732
|
+
import { useMemo as useMemo24, useState as useState32 } from "react";
|
|
27446
27733
|
import { t } from "i18next";
|
|
27447
27734
|
import { useTranslation as useTranslation38 } from "react-i18next";
|
|
27448
27735
|
|
|
@@ -27800,7 +28087,7 @@ var today = /* @__PURE__ */ new Date();
|
|
|
27800
28087
|
today.setHours(0, 0, 0, 0);
|
|
27801
28088
|
var usePresets = () => {
|
|
27802
28089
|
const { t: t2 } = useTranslation38();
|
|
27803
|
-
return
|
|
28090
|
+
return useMemo24(
|
|
27804
28091
|
() => [
|
|
27805
28092
|
{
|
|
27806
28093
|
label: t2("filters.date.today"),
|
|
@@ -28419,7 +28706,7 @@ var DataTableFilter2 = ({
|
|
|
28419
28706
|
return /* @__PURE__ */ jsx92(
|
|
28420
28707
|
DataTableFilterContext.Provider,
|
|
28421
28708
|
{
|
|
28422
|
-
value:
|
|
28709
|
+
value: useMemo25(
|
|
28423
28710
|
() => ({
|
|
28424
28711
|
removeFilter,
|
|
28425
28712
|
removeAllFilters
|
|
@@ -28782,7 +29069,7 @@ import {
|
|
|
28782
29069
|
flexRender as flexRender2
|
|
28783
29070
|
} from "@tanstack/react-table";
|
|
28784
29071
|
import {
|
|
28785
|
-
Fragment as
|
|
29072
|
+
Fragment as Fragment12,
|
|
28786
29073
|
useEffect as useEffect25,
|
|
28787
29074
|
useRef as useRef19,
|
|
28788
29075
|
useState as useState38,
|
|
@@ -28988,7 +29275,7 @@ var DataTableRoot = ({
|
|
|
28988
29275
|
}) }),
|
|
28989
29276
|
/* @__PURE__ */ jsx96(CommandBar.Seperator, {}),
|
|
28990
29277
|
commands?.map((command, index) => {
|
|
28991
|
-
return /* @__PURE__ */ jsxs70(
|
|
29278
|
+
return /* @__PURE__ */ jsxs70(Fragment12, { children: [
|
|
28992
29279
|
/* @__PURE__ */ jsx96(
|
|
28993
29280
|
CommandBar.Command,
|
|
28994
29281
|
{
|
|
@@ -29382,7 +29669,7 @@ import {
|
|
|
29382
29669
|
getPaginationRowModel,
|
|
29383
29670
|
useReactTable as useReactTable2
|
|
29384
29671
|
} from "@tanstack/react-table";
|
|
29385
|
-
import { useEffect as useEffect26, useMemo as
|
|
29672
|
+
import { useEffect as useEffect26, useMemo as useMemo26, useState as useState39 } from "react";
|
|
29386
29673
|
import { useSearchParams as useSearchParams9 } from "react-router-dom";
|
|
29387
29674
|
var useDataTable2 = ({
|
|
29388
29675
|
data = [],
|
|
@@ -29405,7 +29692,7 @@ var useDataTable2 = ({
|
|
|
29405
29692
|
pageIndex: offset ? Math.ceil(Number(offset) / _pageSize) : 0,
|
|
29406
29693
|
pageSize: _pageSize
|
|
29407
29694
|
});
|
|
29408
|
-
const pagination =
|
|
29695
|
+
const pagination = useMemo26(
|
|
29409
29696
|
() => ({
|
|
29410
29697
|
pageIndex,
|
|
29411
29698
|
pageSize
|
|
@@ -29467,7 +29754,7 @@ var useDataTable2 = ({
|
|
|
29467
29754
|
};
|
|
29468
29755
|
|
|
29469
29756
|
// src/permissions/permissions-provider.tsx
|
|
29470
|
-
import { useCallback as useCallback28, useMemo as
|
|
29757
|
+
import { useCallback as useCallback28, useMemo as useMemo27 } from "react";
|
|
29471
29758
|
import { jsx as jsx109 } from "react/jsx-runtime";
|
|
29472
29759
|
var PermissionsProvider = ({
|
|
29473
29760
|
permissions = null,
|
|
@@ -29497,7 +29784,7 @@ var PermissionsProvider = ({
|
|
|
29497
29784
|
(list) => !permissions || list.every(hasPermission),
|
|
29498
29785
|
[permissions, hasPermission]
|
|
29499
29786
|
);
|
|
29500
|
-
const value =
|
|
29787
|
+
const value = useMemo27(
|
|
29501
29788
|
() => ({
|
|
29502
29789
|
permissions,
|
|
29503
29790
|
isLoading,
|
|
@@ -29523,7 +29810,7 @@ var usePermissions = () => {
|
|
|
29523
29810
|
};
|
|
29524
29811
|
|
|
29525
29812
|
// src/permissions/permission-guard.tsx
|
|
29526
|
-
import { Fragment as
|
|
29813
|
+
import { Fragment as Fragment13, jsx as jsx110 } from "react/jsx-runtime";
|
|
29527
29814
|
var PermissionGuard = ({
|
|
29528
29815
|
children,
|
|
29529
29816
|
permission,
|
|
@@ -29533,13 +29820,13 @@ var PermissionGuard = ({
|
|
|
29533
29820
|
const { hasAnyPermission, hasAllPermissions } = usePermissions();
|
|
29534
29821
|
const list = Array.isArray(permission) ? permission : [permission];
|
|
29535
29822
|
const allowed = requireAll ? hasAllPermissions(list) : hasAnyPermission(list);
|
|
29536
|
-
return /* @__PURE__ */ jsx110(
|
|
29823
|
+
return /* @__PURE__ */ jsx110(Fragment13, { children: allowed ? children : fallback });
|
|
29537
29824
|
};
|
|
29538
29825
|
|
|
29539
29826
|
// src/permissions/route-permission-guard.tsx
|
|
29540
29827
|
import { ExclamationCircle as ExclamationCircle5 } from "@medusajs/icons";
|
|
29541
29828
|
import { Container as Container6, Heading as Heading10, Text as Text22 } from "@medusajs/ui";
|
|
29542
|
-
import { useMemo as
|
|
29829
|
+
import { useMemo as useMemo28 } from "react";
|
|
29543
29830
|
import { useTranslation as useTranslation50 } from "react-i18next";
|
|
29544
29831
|
import { Navigate as Navigate2, Outlet as Outlet3, useMatches } from "react-router-dom";
|
|
29545
29832
|
import { jsx as jsx111, jsxs as jsxs74 } from "react/jsx-runtime";
|
|
@@ -29572,7 +29859,7 @@ var readRequirementFromHandle = (handle) => {
|
|
|
29572
29859
|
var RoutePermissionGuard = () => {
|
|
29573
29860
|
const matches = useMatches();
|
|
29574
29861
|
const { hasAnyPermission, hasAllPermissions, isLoading } = usePermissions();
|
|
29575
|
-
const requirement =
|
|
29862
|
+
const requirement = useMemo28(() => {
|
|
29576
29863
|
for (let i = matches.length - 1; i >= 0; i--) {
|
|
29577
29864
|
const found = readRequirementFromHandle(matches[i].handle);
|
|
29578
29865
|
if (found) {
|
|
@@ -29610,10 +29897,10 @@ var AccessDenied = ({
|
|
|
29610
29897
|
};
|
|
29611
29898
|
|
|
29612
29899
|
// src/permissions/use-resource-permissions.tsx
|
|
29613
|
-
import { useMemo as
|
|
29900
|
+
import { useMemo as useMemo29 } from "react";
|
|
29614
29901
|
var useResourcePermissions = (key) => {
|
|
29615
29902
|
const { can, isLoading } = usePermissions();
|
|
29616
|
-
return
|
|
29903
|
+
return useMemo29(
|
|
29617
29904
|
() => ({
|
|
29618
29905
|
canView: can(key, "view"),
|
|
29619
29906
|
canEdit: can(key, "edit"),
|
|
@@ -29680,7 +29967,7 @@ import { createContext as createContext11 } from "react";
|
|
|
29680
29967
|
var SidebarContext = createContext11(null);
|
|
29681
29968
|
|
|
29682
29969
|
// src/providers/sidebar-provider/sidebar-provider.tsx
|
|
29683
|
-
import { useCallback as useCallback29, useEffect as useEffect27, useMemo as
|
|
29970
|
+
import { useCallback as useCallback29, useEffect as useEffect27, useMemo as useMemo30, useState as useState40 } from "react";
|
|
29684
29971
|
import { useLocation as useLocation4 } from "react-router-dom";
|
|
29685
29972
|
import { jsx as jsx114 } from "react/jsx-runtime";
|
|
29686
29973
|
var SidebarProvider = ({ children }) => {
|
|
@@ -29697,7 +29984,7 @@ var SidebarProvider = ({ children }) => {
|
|
|
29697
29984
|
setMobile((open) => !open);
|
|
29698
29985
|
}
|
|
29699
29986
|
}, []);
|
|
29700
|
-
const value =
|
|
29987
|
+
const value = useMemo30(
|
|
29701
29988
|
() => ({
|
|
29702
29989
|
state: desktop ? "expanded" : "collapsed",
|
|
29703
29990
|
desktop,
|
|
@@ -29752,22 +30039,22 @@ var useSidebarMenuPlacement = (align) => {
|
|
|
29752
30039
|
};
|
|
29753
30040
|
|
|
29754
30041
|
// src/layout-composer/layout-composer.tsx
|
|
29755
|
-
import { Fragment as
|
|
30042
|
+
import { Fragment as Fragment16, useContext as useContext18, useMemo as useMemo31 } from "react";
|
|
29756
30043
|
import { Outlet as Outlet4 } from "react-router-dom";
|
|
29757
30044
|
|
|
29758
30045
|
// src/layout-composer/entries.ts
|
|
29759
30046
|
import {
|
|
29760
30047
|
Children as Children4,
|
|
29761
|
-
Fragment as
|
|
30048
|
+
Fragment as Fragment15,
|
|
29762
30049
|
createElement as createElement3,
|
|
29763
30050
|
isValidElement as isValidElement2
|
|
29764
30051
|
} from "react";
|
|
29765
30052
|
|
|
29766
30053
|
// src/layout-composer/entry.tsx
|
|
29767
|
-
import { Fragment as
|
|
30054
|
+
import { Fragment as Fragment14 } from "react";
|
|
29768
30055
|
import { jsx as jsx115 } from "react/jsx-runtime";
|
|
29769
30056
|
function LayoutEntry({ children }) {
|
|
29770
|
-
return /* @__PURE__ */ jsx115(
|
|
30057
|
+
return /* @__PURE__ */ jsx115(Fragment14, { children });
|
|
29771
30058
|
}
|
|
29772
30059
|
LayoutEntry.displayName = "LayoutEntry";
|
|
29773
30060
|
|
|
@@ -29788,7 +30075,7 @@ function collectElements(node) {
|
|
|
29788
30075
|
const elements = [];
|
|
29789
30076
|
Children4.forEach(node, (child) => {
|
|
29790
30077
|
if (!isValidElement2(child)) return;
|
|
29791
|
-
if (child.type ===
|
|
30078
|
+
if (child.type === Fragment15) {
|
|
29792
30079
|
elements.push(...collectElements(child.props.children));
|
|
29793
30080
|
return;
|
|
29794
30081
|
}
|
|
@@ -29897,7 +30184,7 @@ var LayoutComposerRoot = ({
|
|
|
29897
30184
|
const registry = useExtension();
|
|
29898
30185
|
const permissions = useContext18(PermissionsContext);
|
|
29899
30186
|
const layout = registry.getLayout(preferredLayoutId);
|
|
29900
|
-
const entriesBySection =
|
|
30187
|
+
const entriesBySection = useMemo31(() => {
|
|
29901
30188
|
const sectionIds = layout?.sections.map((section) => section.id) ?? [];
|
|
29902
30189
|
const validSections = new Set(sectionIds);
|
|
29903
30190
|
const core = buildCoreEntries(extractSectionElements(sections));
|
|
@@ -29921,7 +30208,7 @@ var LayoutComposerRoot = ({
|
|
|
29921
30208
|
}
|
|
29922
30209
|
const rendered = {};
|
|
29923
30210
|
for (const section of layout.sections) {
|
|
29924
|
-
rendered[section.id] = (entriesBySection[section.id] ?? []).filter((entry) => !entry.hidden).map((entry) => /* @__PURE__ */ jsx116(
|
|
30211
|
+
rendered[section.id] = (entriesBySection[section.id] ?? []).filter((entry) => !entry.hidden).map((entry) => /* @__PURE__ */ jsx116(Fragment16, { children: entry.render(data) }, entry.entryId));
|
|
29925
30212
|
}
|
|
29926
30213
|
const LayoutComponent = layout.Component;
|
|
29927
30214
|
return /* @__PURE__ */ jsxs75("div", { className: "flex w-full flex-col gap-y-3", "data-testid": testId, children: [
|
|
@@ -29934,9 +30221,9 @@ var LayoutComposer = Object.assign(LayoutComposerRoot, {
|
|
|
29934
30221
|
});
|
|
29935
30222
|
|
|
29936
30223
|
// src/layout-composer/detail-page-defaults.tsx
|
|
29937
|
-
import { Fragment as
|
|
30224
|
+
import { Fragment as Fragment17, jsx as jsx117, jsxs as jsxs76 } from "react/jsx-runtime";
|
|
29938
30225
|
function detailPageDefaultEntries(data, { metadata = true, jsonView = true } = {}) {
|
|
29939
|
-
return /* @__PURE__ */ jsxs76(
|
|
30226
|
+
return /* @__PURE__ */ jsxs76(Fragment17, { children: [
|
|
29940
30227
|
metadata && /* @__PURE__ */ jsx117(LayoutEntry, { id: "MetadataSection", children: /* @__PURE__ */ jsx117(MetadataSection, { data }) }),
|
|
29941
30228
|
jsonView && /* @__PURE__ */ jsx117(LayoutEntry, { id: "JsonViewSection", children: /* @__PURE__ */ jsx117(JsonViewSection, { data }) })
|
|
29942
30229
|
] });
|
|
@@ -30098,6 +30385,14 @@ var extractPricesFromOffers = (offers, regions) => {
|
|
|
30098
30385
|
return [...currencyPrices, ...regionPrices];
|
|
30099
30386
|
});
|
|
30100
30387
|
};
|
|
30388
|
+
|
|
30389
|
+
// src/lib/list-initial-data.ts
|
|
30390
|
+
var getListInitialData = (queryParams, loaderData) => {
|
|
30391
|
+
const hasParams = Object.values(queryParams).some(
|
|
30392
|
+
(value) => value !== void 0 && value !== ""
|
|
30393
|
+
);
|
|
30394
|
+
return hasParams ? void 0 : loaderData;
|
|
30395
|
+
};
|
|
30101
30396
|
export {
|
|
30102
30397
|
ActionMenu,
|
|
30103
30398
|
AddressForm,
|
|
@@ -30132,6 +30427,7 @@ export {
|
|
|
30132
30427
|
EmailHeader,
|
|
30133
30428
|
EmailSchema,
|
|
30134
30429
|
ErrorBoundary,
|
|
30430
|
+
ExtendableFormField,
|
|
30135
30431
|
ExtensionProvider,
|
|
30136
30432
|
ExtensionRegistry,
|
|
30137
30433
|
FilePreview,
|
|
@@ -30230,6 +30526,7 @@ export {
|
|
|
30230
30526
|
buildDisplayEntries,
|
|
30231
30527
|
buildOfferGridData,
|
|
30232
30528
|
buildProductChangeView,
|
|
30529
|
+
buildScopedAdditionalData,
|
|
30233
30530
|
buildWidgetEntries,
|
|
30234
30531
|
countries,
|
|
30235
30532
|
createDataGridHelper,
|
|
@@ -30251,6 +30548,7 @@ export {
|
|
|
30251
30548
|
getFormattedAddress,
|
|
30252
30549
|
getFormattedCountry,
|
|
30253
30550
|
getLinkQuery,
|
|
30551
|
+
getListInitialData,
|
|
30254
30552
|
getLocaleAmount,
|
|
30255
30553
|
getNativeSymbol,
|
|
30256
30554
|
getPriceListStatus,
|
|
@@ -30277,6 +30575,8 @@ export {
|
|
|
30277
30575
|
productChangeViewHasContent,
|
|
30278
30576
|
queryClient,
|
|
30279
30577
|
queryKeysFactory,
|
|
30578
|
+
refineAdditionalData,
|
|
30579
|
+
resolveFormFieldType,
|
|
30280
30580
|
resolveRouteOverrides,
|
|
30281
30581
|
richTextContentClasses,
|
|
30282
30582
|
sanitizeRichText,
|
|
@@ -30292,6 +30592,7 @@ export {
|
|
|
30292
30592
|
useDocumentDirection,
|
|
30293
30593
|
useExpandedSidebar,
|
|
30294
30594
|
useExtendableForm,
|
|
30595
|
+
useExtendableGrid,
|
|
30295
30596
|
useExtendableTable,
|
|
30296
30597
|
useExtension,
|
|
30297
30598
|
useExtensionActivity,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mercurjs/dashboard-shared",
|
|
3
|
-
"version": "2.3.9-canary.
|
|
3
|
+
"version": "2.3.9-canary.5",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/mercurjs/mercur",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"@medusajs/dashboard": "2.22.0",
|
|
35
35
|
"@medusajs/icons": "2.22.0",
|
|
36
36
|
"@medusajs/ui": "4.2.3",
|
|
37
|
-
"@mercurjs/client": "2.3.9-canary.
|
|
37
|
+
"@mercurjs/client": "2.3.9-canary.5",
|
|
38
38
|
"@radix-ui/react-dialog": "1.1.19",
|
|
39
39
|
"@radix-ui/react-dismissable-layer": "1.1.4",
|
|
40
40
|
"@tanstack/react-query": "5.64.2",
|
|
@@ -70,9 +70,9 @@
|
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
72
|
"@medusajs/types": "2.22.0",
|
|
73
|
-
"@mercurjs/core": "2.3.9-canary.
|
|
74
|
-
"@mercurjs/dashboard-sdk": "2.3.9-canary.
|
|
75
|
-
"@mercurjs/types": "2.3.9-canary.
|
|
73
|
+
"@mercurjs/core": "2.3.9-canary.5",
|
|
74
|
+
"@mercurjs/dashboard-sdk": "2.3.9-canary.5",
|
|
75
|
+
"@mercurjs/types": "2.3.9-canary.5",
|
|
76
76
|
"@types/lodash.debounce": "^4.0.8",
|
|
77
77
|
"@types/react": "^18.3.2",
|
|
78
78
|
"@types/react-dom": "^18.2.22",
|