@mercurjs/dashboard-shared 2.2.0-canary.3 → 2.2.0-canary.30

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.
Files changed (3) hide show
  1. package/dist/index.d.ts +97 -12
  2. package/dist/index.js +3796 -2875
  3. package/package.json +6 -6
package/dist/index.d.ts CHANGED
@@ -33,18 +33,50 @@ type TQueryKey<TKey, TListQuery = any, TDetailQuery = string> = {
33
33
  type UseQueryOptionsWrapper<TQueryFn = unknown, E = Error, TQueryKey extends QueryKey = QueryKey> = Omit<UseQueryOptions<TQueryFn, E, TQueryFn, TQueryKey>, "queryKey" | "queryFn">;
34
34
  declare const queryKeysFactory: <T, TListQueryType = any, TDetailQueryType = string>(globalKey: T) => TQueryKey<T, TListQueryType, TDetailQueryType>;
35
35
 
36
+ type ImageRef = {
37
+ url: string;
38
+ };
39
+ type MediaDiff = {
40
+ added: ImageRef[];
41
+ removed: ImageRef[];
42
+ };
36
43
  type FieldDiff = {
37
44
  field: string;
38
45
  previous: unknown;
39
46
  next: unknown;
40
- };
41
- type ProductChangePartition = {
42
- updated: FieldDiff[];
43
- added: ProductChangeActionDTO[];
44
- removed: ProductChangeActionDTO[];
47
+ variant_id?: string;
48
+ };
49
+ type AttributeChangeKind = "added" | "removed" | "updated";
50
+ type AttributeChange = {
51
+ kind: AttributeChangeKind;
52
+ /** Set for existing (catalog) attributes referenced by id. */
53
+ attributeId?: string;
54
+ /** Set for inline attributes created in the same request (no id yet). */
55
+ inlineTitle?: string;
56
+ /** Value ids to associate / add (select types or shared axis subset). */
57
+ addValueIds: string[];
58
+ /** New value names to create (inline / exclusive axis). */
59
+ addValueNames: string[];
60
+ /** Value ids removed (updates only). */
61
+ removeValueIds: string[];
62
+ /** Free-form scalar for text / unit / toggle attributes. */
63
+ scalarValue?: string | number | boolean;
64
+ };
65
+ type VariantGroup = {
66
+ variantId: string;
67
+ fieldDiffs: FieldDiff[];
68
+ media: MediaDiff;
69
+ };
70
+ type ProductChangeView = {
71
+ productUpdated: FieldDiff[];
72
+ productMedia: MediaDiff;
73
+ attributes: AttributeChange[];
74
+ variantsAdded: ProductChangeActionDTO[];
75
+ variantsRemoved: ProductChangeActionDTO[];
76
+ variantGroups: VariantGroup[];
45
77
  deleteRequested: boolean;
46
78
  };
47
- type ReferenceField = "brand_id" | "type_id" | "collection_id" | "categories" | "tags";
79
+ type ReferenceField = "type_id" | "collection_id" | "categories" | "tags";
48
80
  declare const REFERENCE_FIELDS: ReferenceField[];
49
81
  declare const isReferenceField: (field: string) => field is ReferenceField;
50
82
  declare const isImageList: (value: unknown) => value is {
@@ -52,11 +84,13 @@ declare const isImageList: (value: unknown) => value is {
52
84
  }[];
53
85
  declare const extractReferenceIds: (field: ReferenceField, value: unknown) => string[];
54
86
  declare const humanizeFieldName: (field: string) => string;
55
- declare const formatFieldValue: (value: unknown, field?: string) => string;
56
- declare const partitionProductChangeActions: (actions: ProductChangeActionDTO[]) => ProductChangePartition;
57
- declare const describeProductChangeAction: (action: ProductChangeActionDTO, fallbacks: {
58
- variant: string;
59
- }) => string;
87
+ type BooleanLabels = {
88
+ true: string;
89
+ false: string;
90
+ };
91
+ declare const formatFieldValue: (value: unknown, field?: string, booleanLabels?: BooleanLabels) => string;
92
+ declare const buildProductChangeView: (actions: ProductChangeActionDTO[]) => ProductChangeView;
93
+ declare const productChangeViewHasContent: (view: ProductChangeView) => boolean;
60
94
 
61
95
  type Action = {
62
96
  icon: ReactNode;
@@ -340,6 +374,57 @@ type MetadataSectionProps<TData extends object> = {
340
374
  };
341
375
  declare const MetadataSection: <TData extends object>({ data, href, }: MetadataSectionProps<TData>) => react_jsx_runtime.JSX.Element | null;
342
376
 
377
+ type WrappedAttributeValue = {
378
+ id: string;
379
+ name?: string | null;
380
+ };
381
+ type ProductChangeAttribute = {
382
+ id: string;
383
+ name?: string | null;
384
+ /** Values currently selected on the product (the "previous" side). */
385
+ values?: WrappedAttributeValue[] | null;
386
+ /** Every possible value of the attribute, used to resolve value ids. */
387
+ all_values?: WrappedAttributeValue[] | null;
388
+ };
389
+ type ProductChangeVariant = {
390
+ id: string;
391
+ title?: string | null;
392
+ sku?: string | null;
393
+ images?: {
394
+ url: string;
395
+ }[] | null;
396
+ };
397
+ type ProductChangeProduct = {
398
+ id: string;
399
+ title?: string | null;
400
+ thumbnail?: string | null;
401
+ variants?: (ProductChangeVariant | null)[] | null;
402
+ attributes?: ProductChangeAttribute[] | null;
403
+ };
404
+ type ResolvedAttribute = {
405
+ name: string;
406
+ values: {
407
+ id: string;
408
+ name: string;
409
+ }[];
410
+ };
411
+ type ProductChangeResolvers = {
412
+ getType: (id: string) => Promise<string | null | undefined>;
413
+ getCollection: (id: string) => Promise<string | null | undefined>;
414
+ getCategory: (id: string) => Promise<string | null | undefined>;
415
+ getTag: (id: string) => Promise<string | null | undefined>;
416
+ getAttribute: (id: string) => Promise<ResolvedAttribute | null | undefined>;
417
+ getVariant: (variantId: string) => Promise<ProductChangeVariant | null | undefined>;
418
+ };
419
+ type ProductChangePanelProps = {
420
+ product: ProductChangeProduct;
421
+ actions: ProductChangeActionDTO[];
422
+ resolvers: ProductChangeResolvers;
423
+ headerDescription?: ReactNode;
424
+ footer?: ReactNode;
425
+ };
426
+ declare const ProductChangePanel: ({ product, actions, resolvers, headerDescription, footer, }: ProductChangePanelProps) => react_jsx_runtime.JSX.Element | null;
427
+
343
428
  interface ProgressBarProps {
344
429
  /**
345
430
  * The duration of the animation in seconds.
@@ -1174,4 +1259,4 @@ type QueryParams<T extends string> = {
1174
1259
  };
1175
1260
  declare function useQueryParams<T extends string>(keys: T[], prefix?: string): QueryParams<T>;
1176
1261
 
1177
- export { type Action, type ActionGroup, ActionMenu, AddressForm, BadgeListSummary, ChipGroup, CodeCell, CodeHeader, type Command, ConditionalTooltip, ConfirmPrompt, type ConfirmPromptProps, CreatedAtCell, CreatedAtHeader, CustomerInfo, DataGrid, DataTable, DateCell, DateHeader, DateRangeDisplay, EmailCell, EmailForm, EmailHeader, type FieldDiff, FilePreview, type FileType, FileUpload, type FileUploadProps, type Filter, FilterGroup, Form, GeneralSectionSkeleton, HeadingSkeleton, IconAvatar, IconButtonSkeleton, ImageAvatar, IncludesTaxTooltip, InfiniteList, JsonViewSection, JsonViewSectionSkeleton, LinkButton, ListSummary, Listicle, type ListicleProps, MetadataForm, MetadataSection, MoneyAmountCell, NameCell, NameHeader, NoRecords, NoResults, type NoResultsProps, OrderBy, PlaceholderCell, type ProductChangePartition, ProgressBar, Query, REFERENCE_FIELDS, type ReferenceField, RouteDrawer, RouteFocusModal, SectionRow, type SectionRowProps, SegmentedControl, type SegmentedControlOption, SidebarLink, type SidebarLinkProps, SingleColumnPage, SingleColumnPageSkeleton, Skeleton, SortableList, SortableTree, StackedDrawer, StackedFocusModal, StatusCell, SwitchBox, type TQueryKey, type TabDefinition, TabbedForm, TableFooterSkeleton, TableSectionSkeleton, TableSkeleton, TextCell, TextHeader, TextSkeleton, Thumbnail, TwoColumnPage, TwoColumnPageSkeleton, type UseQueryOptionsWrapper, _DataTable, createDataGridHelper, createDataGridPriceColumns, describeProductChangeAction, extractReferenceIds, formatFieldValue, humanizeFieldName, isImageList, isReferenceField, partitionProductChangeActions, queryKeysFactory, useCombinedRefs, useCommandHistory, useDataTable, useDate, useDocumentDirection, useQueryParams, useRouteModal, useStackedModal, useTabManagement, useTabbedForm };
1262
+ export { type Action, type ActionGroup, ActionMenu, AddressForm, type AttributeChange, type AttributeChangeKind, BadgeListSummary, ChipGroup, CodeCell, CodeHeader, type Command, ConditionalTooltip, ConfirmPrompt, type ConfirmPromptProps, CreatedAtCell, CreatedAtHeader, CustomerInfo, DataGrid, DataTable, DateCell, DateHeader, DateRangeDisplay, EmailCell, EmailForm, EmailHeader, type FieldDiff, FilePreview, type FileType, FileUpload, type FileUploadProps, type Filter, FilterGroup, Form, GeneralSectionSkeleton, HeadingSkeleton, IconAvatar, IconButtonSkeleton, ImageAvatar, type ImageRef, IncludesTaxTooltip, InfiniteList, JsonViewSection, JsonViewSectionSkeleton, LinkButton, ListSummary, Listicle, type ListicleProps, type MediaDiff, MetadataForm, MetadataSection, MoneyAmountCell, NameCell, NameHeader, NoRecords, NoResults, type NoResultsProps, OrderBy, PlaceholderCell, type ProductChangeAttribute, ProductChangePanel, type ProductChangePanelProps, type ProductChangeProduct, type ProductChangeResolvers, type ProductChangeVariant, type ProductChangeView, ProgressBar, Query, REFERENCE_FIELDS, type ReferenceField, type ResolvedAttribute, RouteDrawer, RouteFocusModal, SectionRow, type SectionRowProps, SegmentedControl, type SegmentedControlOption, SidebarLink, type SidebarLinkProps, SingleColumnPage, SingleColumnPageSkeleton, Skeleton, SortableList, SortableTree, StackedDrawer, StackedFocusModal, StatusCell, SwitchBox, type TQueryKey, type TabDefinition, TabbedForm, TableFooterSkeleton, TableSectionSkeleton, TableSkeleton, TextCell, TextHeader, TextSkeleton, Thumbnail, TwoColumnPage, TwoColumnPageSkeleton, type UseQueryOptionsWrapper, type VariantGroup, _DataTable, buildProductChangeView, createDataGridHelper, createDataGridPriceColumns, extractReferenceIds, formatFieldValue, humanizeFieldName, isImageList, isReferenceField, productChangeViewHasContent, queryKeysFactory, useCombinedRefs, useCommandHistory, useDataTable, useDate, useDocumentDirection, useQueryParams, useRouteModal, useStackedModal, useTabManagement, useTabbedForm };