@mercurjs/dashboard-shared 2.1.2 → 2.2.0-canary.2

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 +77 -2
  2. package/dist/index.js +10976 -1021
  3. package/package.json +5 -5
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { QueryKey, UseQueryOptions } from '@tanstack/react-query';
2
+ import { ProductChangeActionDTO, HttpTypes } from '@mercurjs/types';
2
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
3
4
  import * as React$1 from 'react';
4
5
  import React__default, { ReactNode, PropsWithChildren, ComponentPropsWithoutRef, CSSProperties, ComponentType, Ref, RefCallback } from 'react';
5
6
  import { Tooltip, Heading, Text, DataTableColumnDef, DataTableFilter, DataTableCommand, DataTableEmptyStateProps, DataTableRowSelectionState, DataTableRow, Drawer, FocusModal, ProgressStatus } from '@medusajs/ui';
6
- import { HttpTypes } from '@mercurjs/types';
7
7
  import * as react_hook_form from 'react-hook-form';
8
8
  import { FieldValues, FieldPath, ControllerProps, UseFormReturn, Control } from 'react-hook-form';
9
9
  import { Label, Slot } from 'radix-ui';
@@ -33,6 +33,31 @@ 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 FieldDiff = {
37
+ field: string;
38
+ previous: unknown;
39
+ next: unknown;
40
+ };
41
+ type ProductChangePartition = {
42
+ updated: FieldDiff[];
43
+ added: ProductChangeActionDTO[];
44
+ removed: ProductChangeActionDTO[];
45
+ deleteRequested: boolean;
46
+ };
47
+ type ReferenceField = "brand_id" | "type_id" | "collection_id" | "categories" | "tags";
48
+ declare const REFERENCE_FIELDS: ReferenceField[];
49
+ declare const isReferenceField: (field: string) => field is ReferenceField;
50
+ declare const isImageList: (value: unknown) => value is {
51
+ url: string;
52
+ }[];
53
+ declare const extractReferenceIds: (field: ReferenceField, value: unknown) => string[];
54
+ 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;
60
+
36
61
  type Action = {
37
62
  icon: ReactNode;
38
63
  label: string;
@@ -100,6 +125,56 @@ type ConditionalTooltipProps = PropsWithChildren<ComponentPropsWithoutRef<typeof
100
125
  }>;
101
126
  declare const ConditionalTooltip: ({ children, showTooltip, ...props }: ConditionalTooltipProps) => string | number | boolean | Iterable<React$1.ReactNode> | react_jsx_runtime.JSX.Element | null | undefined;
102
127
 
128
+ type ConfirmPromptProps = {
129
+ /**
130
+ * Whether the prompt is visible. Controlled — pair with `onOpenChange`.
131
+ */
132
+ open: boolean;
133
+ onOpenChange: (open: boolean) => void;
134
+ /**
135
+ * Visual variant of the underlying `@medusajs/ui` Prompt.
136
+ * Defaults to `confirmation`.
137
+ */
138
+ variant?: "confirmation" | "danger";
139
+ title: string;
140
+ description?: ReactNode;
141
+ /**
142
+ * When provided, a `<Textarea>` is rendered between the description and the
143
+ * footer. The current value is forwarded to `onConfirm`. Omit this prop to
144
+ * render a plain confirmation prompt with no input.
145
+ */
146
+ noteLabel?: string;
147
+ noteOptional?: boolean;
148
+ notePlaceholder?: string;
149
+ /**
150
+ * Initial note value. Reset to this whenever `open` transitions to `true`.
151
+ */
152
+ defaultNote?: string;
153
+ cancelLabel?: string;
154
+ confirmLabel?: string;
155
+ /**
156
+ * Disables the inputs and footer buttons, and blocks `onOpenChange` from
157
+ * closing the dialog while a submit is in flight.
158
+ */
159
+ isLoading?: boolean;
160
+ /**
161
+ * Called when the user clicks Confirm. Receives the trimmed note (or
162
+ * `undefined` when no note input is rendered or the field is empty).
163
+ * The parent is responsible for closing the dialog once submission resolves.
164
+ */
165
+ onConfirm: (note: string | undefined) => void | Promise<void>;
166
+ };
167
+ /**
168
+ * Reusable confirmation prompt with an optional note input. Mirrors Medusa's
169
+ * `@medusajs/ui` `Prompt` shape — title, description, footer — with an
170
+ * optional `<Textarea>` slotted between the description and the footer.
171
+ *
172
+ * Use for destructive or significant actions where the operator should be
173
+ * able to attach a short note. For pure yes/no confirmations, prefer the
174
+ * `usePrompt` hook from `@medusajs/ui`.
175
+ */
176
+ declare const ConfirmPrompt: ({ open, onOpenChange, variant, title, description, noteLabel, noteOptional, notePlaceholder, defaultNote, cancelLabel, confirmLabel, isLoading, onConfirm, }: ConfirmPromptProps) => react_jsx_runtime.JSX.Element;
177
+
103
178
  declare const CustomerInfo: {
104
179
  ID: ({ data }: {
105
180
  data: HttpTypes.AdminOrder;
@@ -1099,4 +1174,4 @@ type QueryParams<T extends string> = {
1099
1174
  };
1100
1175
  declare function useQueryParams<T extends string>(keys: T[], prefix?: string): QueryParams<T>;
1101
1176
 
1102
- export { type Action, type ActionGroup, ActionMenu, AddressForm, BadgeListSummary, ChipGroup, CodeCell, CodeHeader, type Command, ConditionalTooltip, CreatedAtCell, CreatedAtHeader, CustomerInfo, DataGrid, DataTable, DateCell, DateHeader, DateRangeDisplay, EmailCell, EmailForm, EmailHeader, 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, ProgressBar, Query, 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, queryKeysFactory, useCombinedRefs, useCommandHistory, useDataTable, useDate, useDocumentDirection, useQueryParams, useRouteModal, useStackedModal, useTabManagement, useTabbedForm };
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 };