@mercurjs/dashboard-shared 2.2.1 → 2.3.0-canary.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +100 -6
- package/dist/index.js +243 -28
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { QueryKey, UseQueryOptions } from '@tanstack/react-query';
|
|
2
|
-
import { ProductChangeActionDTO, HttpTypes, AttributeType, ProductAttributeBatchInput, ProductAttributeDTO } from '@mercurjs/types';
|
|
2
|
+
import { ProductChangeActionDTO, HttpTypes, AttributeType, ProductAttributeBatchInput, ProductAttributeDTO, OfferDTO } from '@mercurjs/types';
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
4
|
import * as React$1 from 'react';
|
|
5
5
|
import React__default, { ReactNode, PropsWithChildren, ComponentPropsWithoutRef, CSSProperties, ComponentType, Ref, RefCallback } from 'react';
|
|
@@ -236,8 +236,9 @@ type NoResultsProps = {
|
|
|
236
236
|
title?: string;
|
|
237
237
|
message?: string;
|
|
238
238
|
className?: string;
|
|
239
|
+
icon?: React__default.ReactNode;
|
|
239
240
|
};
|
|
240
|
-
declare const NoResults: ({ title, message, className }: NoResultsProps) => react_jsx_runtime.JSX.Element;
|
|
241
|
+
declare const NoResults: ({ title, message, className, icon, }: NoResultsProps) => react_jsx_runtime.JSX.Element;
|
|
241
242
|
type ActionProps = {
|
|
242
243
|
action?: {
|
|
243
244
|
to: string;
|
|
@@ -1147,6 +1148,10 @@ interface DataTableRootProps<TData> {
|
|
|
1147
1148
|
* Whether the table is empty due to no results from the active query
|
|
1148
1149
|
*/
|
|
1149
1150
|
noResults?: boolean;
|
|
1151
|
+
/**
|
|
1152
|
+
* Props forwarded to the NoResults empty state (title / message / icon)
|
|
1153
|
+
*/
|
|
1154
|
+
noResultsProps?: Pick<NoResultsProps, "title" | "message" | "icon">;
|
|
1150
1155
|
/**
|
|
1151
1156
|
* Whether to display the tables header
|
|
1152
1157
|
*/
|
|
@@ -1157,16 +1162,17 @@ interface DataTableRootProps<TData> {
|
|
|
1157
1162
|
layout?: "fill" | "fit";
|
|
1158
1163
|
}
|
|
1159
1164
|
|
|
1160
|
-
interface DataTableProps<TData> extends Omit<DataTableRootProps<TData>, "noResults">, DataTableQueryProps<TData> {
|
|
1165
|
+
interface DataTableProps<TData> extends Omit<DataTableRootProps<TData>, "noResults" | "noResultsProps">, DataTableQueryProps<TData> {
|
|
1161
1166
|
isLoading?: boolean;
|
|
1162
1167
|
pageSize: number;
|
|
1163
1168
|
queryObject?: Record<string, any>;
|
|
1164
|
-
noRecords?: Pick<
|
|
1169
|
+
noRecords?: Pick<NoRecordsProps, "title" | "message" | "icon" | "action">;
|
|
1170
|
+
noResults?: Pick<NoResultsProps, "title" | "message" | "icon">;
|
|
1165
1171
|
}
|
|
1166
1172
|
/**
|
|
1167
1173
|
* @deprecated Use the DataTable component from "/components/data-table" instead
|
|
1168
1174
|
*/
|
|
1169
|
-
declare const _DataTable: <TData>({ table, columns, pagination, navigateTo, commands, count, search, orderBy, filters, prefix, queryObject, pageSize, isLoading, noHeader, layout, noRecords: noRecordsProps, }: DataTableProps<TData>) => react_jsx_runtime.JSX.Element;
|
|
1175
|
+
declare const _DataTable: <TData>({ table, columns, pagination, navigateTo, commands, count, search, orderBy, filters, prefix, queryObject, pageSize, isLoading, noHeader, layout, noRecords: noRecordsProps, noResults: noResultsProps, }: DataTableProps<TData>) => react_jsx_runtime.JSX.Element;
|
|
1170
1176
|
|
|
1171
1177
|
type Option = {
|
|
1172
1178
|
label: string;
|
|
@@ -1621,4 +1627,92 @@ interface UseExtendableFormProps<TSchema extends ZodObject<Record<string, z.ZodT
|
|
|
1621
1627
|
*/
|
|
1622
1628
|
declare const useExtendableForm: <TSchema extends ZodObject<Record<string, z.ZodTypeAny>>, TContext = unknown, TTransformedValues extends FieldValues | undefined = undefined>({ schema: baseSchema, defaultValues: baseDefaultValues, model, data, zone, tab, ...props }: UseExtendableFormProps<TSchema, TContext>) => react_hook_form.UseFormReturn<WithAdditionalData<z.TypeOf<TSchema>>, TContext, TTransformedValues>;
|
|
1623
1629
|
|
|
1624
|
-
|
|
1630
|
+
/**
|
|
1631
|
+
* Re-implementation of enums from `@medusajs/medusa` as they cannot be imported
|
|
1632
|
+
* directly. Shared by the admin and vendor price-list surfaces.
|
|
1633
|
+
*/
|
|
1634
|
+
declare enum PriceListStatus {
|
|
1635
|
+
ACTIVE = "active",
|
|
1636
|
+
DRAFT = "draft"
|
|
1637
|
+
}
|
|
1638
|
+
declare enum PriceListDateStatus {
|
|
1639
|
+
SCHEDULED = "scheduled",
|
|
1640
|
+
EXPIRED = "expired"
|
|
1641
|
+
}
|
|
1642
|
+
declare enum PriceListType {
|
|
1643
|
+
SALE = "sale",
|
|
1644
|
+
OVERRIDE = "override"
|
|
1645
|
+
}
|
|
1646
|
+
|
|
1647
|
+
/**
|
|
1648
|
+
* The Prices grid is keyed by **offer**, not variant: the same product sold by
|
|
1649
|
+
* two sellers must show as two separate groups (product + seller) with their own
|
|
1650
|
+
* variant rows, never merged. Each offer row binds prices to `offers.<offer_id>`.
|
|
1651
|
+
*/
|
|
1652
|
+
type PriceListGridGroupRow = {
|
|
1653
|
+
__group: true;
|
|
1654
|
+
id: string;
|
|
1655
|
+
product_title: string;
|
|
1656
|
+
product_thumbnail?: string | null;
|
|
1657
|
+
seller_name: string;
|
|
1658
|
+
};
|
|
1659
|
+
type PriceListGridOfferRow = {
|
|
1660
|
+
__group: false;
|
|
1661
|
+
id: string;
|
|
1662
|
+
offer_id: string;
|
|
1663
|
+
variant_id: string;
|
|
1664
|
+
variant_title: string;
|
|
1665
|
+
product_id: string;
|
|
1666
|
+
seller_name: string;
|
|
1667
|
+
sku: string;
|
|
1668
|
+
};
|
|
1669
|
+
type PriceListGridRow = PriceListGridGroupRow | PriceListGridOfferRow;
|
|
1670
|
+
declare const isPriceListGroupRow: (row: PriceListGridRow) => row is PriceListGridGroupRow;
|
|
1671
|
+
type ProductWithVariants = {
|
|
1672
|
+
variants?: {
|
|
1673
|
+
id: string;
|
|
1674
|
+
title?: string | null;
|
|
1675
|
+
}[] | null;
|
|
1676
|
+
};
|
|
1677
|
+
/**
|
|
1678
|
+
* Turn the selected offers + their products into the interleaved grid rows for
|
|
1679
|
+
* the Prices grid: one group header per (product, seller) followed by that
|
|
1680
|
+
* seller's variant/offer rows. The same product from two sellers yields two
|
|
1681
|
+
* separate groups. Also returns offer_id -> variant_id for seeding the form.
|
|
1682
|
+
*/
|
|
1683
|
+
declare const buildOfferGridData: (offers: OfferDTO[], products: ProductWithVariants[]) => {
|
|
1684
|
+
gridData: PriceListGridRow[];
|
|
1685
|
+
variantIdByOffer: Record<string, string>;
|
|
1686
|
+
};
|
|
1687
|
+
|
|
1688
|
+
declare const getPriceListStatus: (t: TFunction<"translation">, priceList: HttpTypes.AdminPriceList) => {
|
|
1689
|
+
color: "green" | "grey" | "orange" | "red";
|
|
1690
|
+
text: string;
|
|
1691
|
+
status: string;
|
|
1692
|
+
};
|
|
1693
|
+
declare const isProductRow: (row: HttpTypes.AdminProduct | HttpTypes.AdminProductVariant) => row is HttpTypes.AdminProduct;
|
|
1694
|
+
type OfferCurrencyPrice = {
|
|
1695
|
+
amount?: string | number;
|
|
1696
|
+
};
|
|
1697
|
+
type ExtractableOffer = {
|
|
1698
|
+
variant_id: string;
|
|
1699
|
+
currency_prices?: Record<string, OfferCurrencyPrice | undefined>;
|
|
1700
|
+
region_prices?: Record<string, OfferCurrencyPrice | undefined>;
|
|
1701
|
+
};
|
|
1702
|
+
type ExtractableOffers = Record<string, ExtractableOffer>;
|
|
1703
|
+
/**
|
|
1704
|
+
* Build the API price payload from the offer-keyed grid state. Each price
|
|
1705
|
+
* carries its `offer_id` rule so the override is scoped to that seller's offer
|
|
1706
|
+
* and never leaks onto another seller's offer of the same variant.
|
|
1707
|
+
*/
|
|
1708
|
+
declare const extractPricesFromOffers: (offers: ExtractableOffers, regions: HttpTypes.AdminRegion[]) => {
|
|
1709
|
+
amount: number;
|
|
1710
|
+
rules: {
|
|
1711
|
+
region_id?: string | undefined;
|
|
1712
|
+
offer_id: string;
|
|
1713
|
+
};
|
|
1714
|
+
currency_code: string;
|
|
1715
|
+
variant_id: string;
|
|
1716
|
+
}[];
|
|
1717
|
+
|
|
1718
|
+
export { type Action, type ActionGroup, ActionMenu, AddressForm, type AttributeChange, type AttributeChangeKind, AttributeValueInput, BadgeListSummary, ChipGroup, CodeCell, CodeHeader, type Command, ConditionalTooltip, ConfirmPrompt, type ConfirmPromptProps, type CoreNavItem, CreatedAtCell, CreatedAtHeader, type CustomFieldsModule, CustomerInfo, DataGrid, DataTable, DateCell, DateHeader, DateRangeDisplay, DisplayExtensionZone, type DisplayExtensionZoneProps, DisplayField, type DisplayFieldProps, DisplaySection, type DisplaySectionField, type DisplaySectionProps, type EditAttributeAttribute, EditAttributeForm, type EditAttributeFormProps, EmailCell, EmailForm, EmailHeader, type ExtendableTable, ExtensionProvider, type ExtensionProviderProps, ExtensionRegistry, type ExtractableOffer, type ExtractableOffers, type FieldDiff, FilePreview, type FileType, FileUpload, type FileUploadProps, type Filter, FilterGroup, Form, FormExtensionZone, type FormExtensionZoneProps, GeneralSectionSkeleton, HeadingSkeleton, IconAvatar, IconButtonSkeleton, ImageAvatar, type ImageRef, IncludesTaxTooltip, InfiniteList, JsonViewSection, JsonViewSectionSkeleton, LinkButton, ListBadge, ListSummary, Listicle, type ListicleProps, type MediaDiff, MetadataForm, MetadataSection, MoneyAmountCell, NameCell, NameHeader, type NavigationModule, NoRecords, type NoRecordsProps, NoResults, type NoResultsProps, OrderBy, PlaceholderCell, 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, Query, REFERENCE_FIELDS, type ReferenceField, type ResolvedAttribute, type ResolvedDisplays, type ResolvedFormField, 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 UseExtendableFormProps, type UseExtendableTableProps, type UseQueryOptionsWrapper, type VariantGroup, type Widget, type WidgetModule, type WidgetPlacement, WidgetZone, type WidgetZoneProps, type ZoneWidgets, _DataTable, applyNavOverrides, buildAdditionalDataDefaults, buildAdditionalDataSchema, buildOfferGridData, buildProductChangeView, createDataGridHelper, createDataGridPriceColumns, createFormHelper, extractPricesFromOffers, extractReferenceIds, formatFieldValue, getExtensionRegistry, getLinkQuery, getPriceListStatus, humanizeFieldName, isImageList, isPriceListGroupRow, isProductRow, isReferenceField, linkFields, productChangeViewHasContent, queryKeysFactory, useCombinedRefs, useCommandHistory, useDataTable, useDate, useDisplayFieldOverride, useDocumentDirection, useExtendableForm, useExtendableTable, useExtension, useLinkQuery, useQueryParams, useRouteModal, useStackedModal, useTabManagement, useTabbedForm, withLinkFields };
|
package/dist/index.js
CHANGED
|
@@ -9901,6 +9901,48 @@ var require_promotion_cost = __commonJS({
|
|
|
9901
9901
|
}
|
|
9902
9902
|
});
|
|
9903
9903
|
|
|
9904
|
+
// ../types/dist/review/common.js
|
|
9905
|
+
var require_common42 = __commonJS({
|
|
9906
|
+
"../types/dist/review/common.js"(exports) {
|
|
9907
|
+
"use strict";
|
|
9908
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9909
|
+
}
|
|
9910
|
+
});
|
|
9911
|
+
|
|
9912
|
+
// ../types/dist/review/mutation.js
|
|
9913
|
+
var require_mutation3 = __commonJS({
|
|
9914
|
+
"../types/dist/review/mutation.js"(exports) {
|
|
9915
|
+
"use strict";
|
|
9916
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9917
|
+
}
|
|
9918
|
+
});
|
|
9919
|
+
|
|
9920
|
+
// ../types/dist/review/index.js
|
|
9921
|
+
var require_review = __commonJS({
|
|
9922
|
+
"../types/dist/review/index.js"(exports) {
|
|
9923
|
+
"use strict";
|
|
9924
|
+
var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
|
|
9925
|
+
if (k2 === void 0) k2 = k;
|
|
9926
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9927
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9928
|
+
desc = { enumerable: true, get: function() {
|
|
9929
|
+
return m[k];
|
|
9930
|
+
} };
|
|
9931
|
+
}
|
|
9932
|
+
Object.defineProperty(o, k2, desc);
|
|
9933
|
+
}) : (function(o, m, k, k2) {
|
|
9934
|
+
if (k2 === void 0) k2 = k;
|
|
9935
|
+
o[k2] = m[k];
|
|
9936
|
+
}));
|
|
9937
|
+
var __exportStar = exports && exports.__exportStar || function(m, exports2) {
|
|
9938
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p)) __createBinding(exports2, m, p);
|
|
9939
|
+
};
|
|
9940
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9941
|
+
__exportStar(require_common42(), exports);
|
|
9942
|
+
__exportStar(require_mutation3(), exports);
|
|
9943
|
+
}
|
|
9944
|
+
});
|
|
9945
|
+
|
|
9904
9946
|
// ../types/dist/product/status.js
|
|
9905
9947
|
var require_status = __commonJS({
|
|
9906
9948
|
"../types/dist/product/status.js"(exports) {
|
|
@@ -9917,7 +9959,7 @@ var require_status = __commonJS({
|
|
|
9917
9959
|
});
|
|
9918
9960
|
|
|
9919
9961
|
// ../types/dist/product/common.js
|
|
9920
|
-
var
|
|
9962
|
+
var require_common43 = __commonJS({
|
|
9921
9963
|
"../types/dist/product/common.js"(exports) {
|
|
9922
9964
|
"use strict";
|
|
9923
9965
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -9983,7 +10025,7 @@ var require_product5 = __commonJS({
|
|
|
9983
10025
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p)) __createBinding(exports2, m, p);
|
|
9984
10026
|
};
|
|
9985
10027
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9986
|
-
__exportStar(
|
|
10028
|
+
__exportStar(require_common43(), exports);
|
|
9987
10029
|
__exportStar(require_mutations26(), exports);
|
|
9988
10030
|
}
|
|
9989
10031
|
});
|
|
@@ -10008,6 +10050,7 @@ var require_modules = __commonJS({
|
|
|
10008
10050
|
MercurModules2["ADMIN_UI"] = "admin_ui";
|
|
10009
10051
|
MercurModules2["CODEGEN"] = "codegen";
|
|
10010
10052
|
MercurModules2["PROMOTION_COST"] = "promotion_cost";
|
|
10053
|
+
MercurModules2["REVIEW"] = "review";
|
|
10011
10054
|
})(MercurModules || (exports.MercurModules = MercurModules = {}));
|
|
10012
10055
|
}
|
|
10013
10056
|
});
|
|
@@ -10096,6 +10139,7 @@ var require_dist2 = __commonJS({
|
|
|
10096
10139
|
__exportStar(require_payout2(), exports);
|
|
10097
10140
|
__exportStar(require_offer2(), exports);
|
|
10098
10141
|
__exportStar(require_promotion_cost(), exports);
|
|
10142
|
+
__exportStar(require_review(), exports);
|
|
10099
10143
|
var status_1 = require_status();
|
|
10100
10144
|
Object.defineProperty(exports, "ProductStatus", { enumerable: true, get: function() {
|
|
10101
10145
|
return status_1.ProductStatus;
|
|
@@ -10122,12 +10166,10 @@ var queryKeysFactory = (globalKey) => {
|
|
|
10122
10166
|
const queryKeyFactory = {
|
|
10123
10167
|
all: [globalKey],
|
|
10124
10168
|
lists: () => [...queryKeyFactory.all, "list"],
|
|
10125
|
-
// @ts-expect-error
|
|
10126
10169
|
list: (query) => [...queryKeyFactory.lists(), query ? { query } : void 0].filter(
|
|
10127
10170
|
(k) => !!k
|
|
10128
10171
|
),
|
|
10129
10172
|
details: () => [...queryKeyFactory.all, "detail"],
|
|
10130
|
-
// @ts-expect-error
|
|
10131
10173
|
detail: (id, query) => [...queryKeyFactory.details(), id, query ? { query } : void 0].filter(
|
|
10132
10174
|
(k) => !!k
|
|
10133
10175
|
)
|
|
@@ -12769,7 +12811,12 @@ import { Button as Button2, Text as Text3, clx as clx6 } from "@medusajs/ui";
|
|
|
12769
12811
|
import { useTranslation as useTranslation7 } from "react-i18next";
|
|
12770
12812
|
import { Link as Link3 } from "react-router-dom";
|
|
12771
12813
|
import { jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
12772
|
-
var NoResults = ({
|
|
12814
|
+
var NoResults = ({
|
|
12815
|
+
title,
|
|
12816
|
+
message,
|
|
12817
|
+
className,
|
|
12818
|
+
icon = /* @__PURE__ */ jsx9(MagnifyingGlass, {})
|
|
12819
|
+
}) => {
|
|
12773
12820
|
const { t: t2 } = useTranslation7();
|
|
12774
12821
|
return /* @__PURE__ */ jsx9(
|
|
12775
12822
|
"div",
|
|
@@ -12779,7 +12826,7 @@ var NoResults = ({ title, message, className }) => {
|
|
|
12779
12826
|
className
|
|
12780
12827
|
),
|
|
12781
12828
|
children: /* @__PURE__ */ jsxs8("div", { className: "flex flex-col items-center gap-y-2", children: [
|
|
12782
|
-
|
|
12829
|
+
icon,
|
|
12783
12830
|
/* @__PURE__ */ jsx9(Text3, { size: "small", leading: "compact", weight: "plus", children: title ?? t2("general.noResultsTitle") }),
|
|
12784
12831
|
/* @__PURE__ */ jsx9(Text3, { size: "small", className: "text-ui-fg-subtle", children: message ?? t2("general.noResultsMessage") })
|
|
12785
12832
|
] })
|
|
@@ -16521,7 +16568,7 @@ var useDataGridCellSnapshot = ({
|
|
|
16521
16568
|
form
|
|
16522
16569
|
}) => {
|
|
16523
16570
|
const [snapshot, setSnapshot] = useState9(null);
|
|
16524
|
-
const { getValues, setValue: setValue2 } = form;
|
|
16571
|
+
const { getValues: getValues2, setValue: setValue2 } = form;
|
|
16525
16572
|
const createSnapshot = useCallback4(
|
|
16526
16573
|
(cell) => {
|
|
16527
16574
|
if (!cell) {
|
|
@@ -16531,7 +16578,7 @@ var useDataGridCellSnapshot = ({
|
|
|
16531
16578
|
if (!field) {
|
|
16532
16579
|
return null;
|
|
16533
16580
|
}
|
|
16534
|
-
const value =
|
|
16581
|
+
const value = getValues2(field);
|
|
16535
16582
|
setSnapshot((curr) => {
|
|
16536
16583
|
if (curr?.field === field) {
|
|
16537
16584
|
return curr;
|
|
@@ -16539,7 +16586,7 @@ var useDataGridCellSnapshot = ({
|
|
|
16539
16586
|
return { field, value };
|
|
16540
16587
|
});
|
|
16541
16588
|
},
|
|
16542
|
-
[
|
|
16589
|
+
[getValues2, matrix]
|
|
16543
16590
|
);
|
|
16544
16591
|
const restoreSnapshot = useCallback4(() => {
|
|
16545
16592
|
if (!snapshot) {
|
|
@@ -16767,18 +16814,18 @@ var useDataGridFormHandlers = ({
|
|
|
16767
16814
|
form,
|
|
16768
16815
|
anchor
|
|
16769
16816
|
}) => {
|
|
16770
|
-
const { getValues, reset } = form;
|
|
16817
|
+
const { getValues: getValues2, reset } = form;
|
|
16771
16818
|
const getSelectionValues = useCallback8(
|
|
16772
16819
|
(fields) => {
|
|
16773
16820
|
if (!fields.length) {
|
|
16774
16821
|
return [];
|
|
16775
16822
|
}
|
|
16776
|
-
const allValues =
|
|
16823
|
+
const allValues = getValues2();
|
|
16777
16824
|
return fields.map((field) => {
|
|
16778
16825
|
return field.split(".").reduce((obj, key) => obj?.[key], allValues);
|
|
16779
16826
|
});
|
|
16780
16827
|
},
|
|
16781
|
-
[
|
|
16828
|
+
[getValues2]
|
|
16782
16829
|
);
|
|
16783
16830
|
const setSelectionValues = useCallback8(
|
|
16784
16831
|
async (fields, values, isHistory) => {
|
|
@@ -16790,7 +16837,7 @@ var useDataGridFormHandlers = ({
|
|
|
16790
16837
|
return;
|
|
16791
16838
|
}
|
|
16792
16839
|
const convertedValues = convertArrayToPrimitive(values, type);
|
|
16793
|
-
const currentValues =
|
|
16840
|
+
const currentValues = getValues2();
|
|
16794
16841
|
fields.forEach((field, index) => {
|
|
16795
16842
|
if (!field) {
|
|
16796
16843
|
return;
|
|
@@ -16805,7 +16852,7 @@ var useDataGridFormHandlers = ({
|
|
|
16805
16852
|
keepDefaultValues: true
|
|
16806
16853
|
});
|
|
16807
16854
|
},
|
|
16808
|
-
[matrix, anchor,
|
|
16855
|
+
[matrix, anchor, getValues2, reset]
|
|
16809
16856
|
);
|
|
16810
16857
|
return {
|
|
16811
16858
|
getSelectionValues,
|
|
@@ -16935,7 +16982,7 @@ var useDataGridKeydownEvent = ({
|
|
|
16935
16982
|
setSingleRange,
|
|
16936
16983
|
setRangeEnd,
|
|
16937
16984
|
onEditingChangeHandler,
|
|
16938
|
-
getValues,
|
|
16985
|
+
getValues: getValues2,
|
|
16939
16986
|
setValue: setValue2,
|
|
16940
16987
|
execute,
|
|
16941
16988
|
undo,
|
|
@@ -17055,7 +17102,7 @@ var useDataGridKeydownEvent = ({
|
|
|
17055
17102
|
return;
|
|
17056
17103
|
}
|
|
17057
17104
|
createSnapshot(anchor2);
|
|
17058
|
-
const current =
|
|
17105
|
+
const current = getValues2(field);
|
|
17059
17106
|
const next = "";
|
|
17060
17107
|
const command = new DataGridUpdateCommand({
|
|
17061
17108
|
next,
|
|
@@ -17070,7 +17117,7 @@ var useDataGridKeydownEvent = ({
|
|
|
17070
17117
|
execute(command);
|
|
17071
17118
|
input.focus();
|
|
17072
17119
|
},
|
|
17073
|
-
[matrix, queryTool,
|
|
17120
|
+
[matrix, queryTool, getValues2, execute, setValue2, createSnapshot]
|
|
17074
17121
|
);
|
|
17075
17122
|
const handleSpaceKeyTogglableNumber = useCallback9(
|
|
17076
17123
|
(anchor2) => {
|
|
@@ -17080,7 +17127,7 @@ var useDataGridKeydownEvent = ({
|
|
|
17080
17127
|
return;
|
|
17081
17128
|
}
|
|
17082
17129
|
createSnapshot(anchor2);
|
|
17083
|
-
const current =
|
|
17130
|
+
const current = getValues2(field);
|
|
17084
17131
|
let checked = current.checked;
|
|
17085
17132
|
if (!current.disabledToggle) {
|
|
17086
17133
|
checked = false;
|
|
@@ -17099,7 +17146,7 @@ var useDataGridKeydownEvent = ({
|
|
|
17099
17146
|
execute(command);
|
|
17100
17147
|
input.focus();
|
|
17101
17148
|
},
|
|
17102
|
-
[matrix, queryTool,
|
|
17149
|
+
[matrix, queryTool, getValues2, execute, setValue2, createSnapshot]
|
|
17103
17150
|
);
|
|
17104
17151
|
const handleSpaceKey = useCallback9(
|
|
17105
17152
|
(e) => {
|
|
@@ -17203,7 +17250,7 @@ var useDataGridKeydownEvent = ({
|
|
|
17203
17250
|
if (!field) {
|
|
17204
17251
|
return;
|
|
17205
17252
|
}
|
|
17206
|
-
const current =
|
|
17253
|
+
const current = getValues2(field);
|
|
17207
17254
|
let next;
|
|
17208
17255
|
if (typeof current === "boolean") {
|
|
17209
17256
|
next = !current;
|
|
@@ -17223,7 +17270,7 @@ var useDataGridKeydownEvent = ({
|
|
|
17223
17270
|
execute(command);
|
|
17224
17271
|
handleMoveOnEnter(e, anchor2);
|
|
17225
17272
|
},
|
|
17226
|
-
[execute,
|
|
17273
|
+
[execute, getValues2, handleMoveOnEnter, matrix, setValue2]
|
|
17227
17274
|
);
|
|
17228
17275
|
const handleEnterKey = useCallback9(
|
|
17229
17276
|
(e) => {
|
|
@@ -19139,7 +19186,7 @@ var DataGridRoot = ({
|
|
|
19139
19186
|
const {
|
|
19140
19187
|
register,
|
|
19141
19188
|
control,
|
|
19142
|
-
getValues,
|
|
19189
|
+
getValues: getValues2,
|
|
19143
19190
|
setValue: setValue2,
|
|
19144
19191
|
formState: { errors }
|
|
19145
19192
|
} = state;
|
|
@@ -19369,7 +19416,7 @@ var DataGridRoot = ({
|
|
|
19369
19416
|
setTrapActive,
|
|
19370
19417
|
setRangeEnd,
|
|
19371
19418
|
getSelectionValues,
|
|
19372
|
-
getValues,
|
|
19419
|
+
getValues: getValues2,
|
|
19373
19420
|
setSelectionValues,
|
|
19374
19421
|
onEditingChangeHandler,
|
|
19375
19422
|
restoreSnapshot,
|
|
@@ -25016,7 +25063,7 @@ var SelectFilter = ({
|
|
|
25016
25063
|
return /* @__PURE__ */ jsxs58(
|
|
25017
25064
|
Command.Item,
|
|
25018
25065
|
{
|
|
25019
|
-
className: "bg-ui-bg-base hover:bg-ui-bg-base-hover aria-selected:bg-ui-bg-base-pressed focus-visible:bg-ui-bg-base-pressed text-ui-fg-base data-[disabled]:text-ui-fg-disabled txt-compact-small relative flex cursor-pointer select-none items-center gap-x-2 rounded-md px-2 py-1.5 outline-none transition-colors data-[disabled]:pointer-events-none",
|
|
25066
|
+
className: "bg-ui-bg-base hover:bg-ui-bg-base-hover aria-selected:bg-ui-bg-base-pressed focus-visible:bg-ui-bg-base-pressed text-ui-fg-base data-[disabled=true]:text-ui-fg-disabled txt-compact-small relative flex cursor-pointer select-none items-center gap-x-2 rounded-md px-2 py-1.5 outline-none transition-colors data-[disabled=true]:pointer-events-none",
|
|
25020
25067
|
value: option.label,
|
|
25021
25068
|
onSelect: () => {
|
|
25022
25069
|
handleSelect(option.value);
|
|
@@ -25583,6 +25630,7 @@ var DataTableRoot = ({
|
|
|
25583
25630
|
commands,
|
|
25584
25631
|
count = 0,
|
|
25585
25632
|
noResults = false,
|
|
25633
|
+
noResultsProps,
|
|
25586
25634
|
noHeader = false,
|
|
25587
25635
|
layout = "fit"
|
|
25588
25636
|
}) => {
|
|
@@ -25748,7 +25796,7 @@ var DataTableRoot = ({
|
|
|
25748
25796
|
row.id
|
|
25749
25797
|
);
|
|
25750
25798
|
}) })
|
|
25751
|
-
] }) : /* @__PURE__ */ jsx88("div", { className: clx44({ "border-b": layout === "fit" }), children: /* @__PURE__ */ jsx88(NoResults, {}) })
|
|
25799
|
+
] }) : /* @__PURE__ */ jsx88("div", { className: clx44({ "border-b": layout === "fit" }), children: /* @__PURE__ */ jsx88(NoResults, { ...noResultsProps }) })
|
|
25752
25800
|
}
|
|
25753
25801
|
),
|
|
25754
25802
|
pagination && /* @__PURE__ */ jsx88("div", { className: clx44({ "border-t": layout === "fill" }), children: /* @__PURE__ */ jsx88(
|
|
@@ -25825,7 +25873,8 @@ var _DataTable = ({
|
|
|
25825
25873
|
isLoading = false,
|
|
25826
25874
|
noHeader = false,
|
|
25827
25875
|
layout = "fit",
|
|
25828
|
-
noRecords: noRecordsProps = {}
|
|
25876
|
+
noRecords: noRecordsProps = {},
|
|
25877
|
+
noResults: noResultsProps = {}
|
|
25829
25878
|
}) => {
|
|
25830
25879
|
if (isLoading) {
|
|
25831
25880
|
return /* @__PURE__ */ jsx89(
|
|
@@ -25841,7 +25890,7 @@ var _DataTable = ({
|
|
|
25841
25890
|
);
|
|
25842
25891
|
}
|
|
25843
25892
|
const noQuery = Object.values(queryObject).filter((v) => Boolean(v)).length === 0;
|
|
25844
|
-
const
|
|
25893
|
+
const showNoResults = !isLoading && count === 0 && !noQuery;
|
|
25845
25894
|
const noRecords = !isLoading && count === 0 && noQuery;
|
|
25846
25895
|
if (noRecords) {
|
|
25847
25896
|
return /* @__PURE__ */ jsx89(
|
|
@@ -25879,7 +25928,8 @@ var _DataTable = ({
|
|
|
25879
25928
|
pagination: true,
|
|
25880
25929
|
navigateTo,
|
|
25881
25930
|
commands,
|
|
25882
|
-
noResults,
|
|
25931
|
+
noResults: showNoResults,
|
|
25932
|
+
noResultsProps,
|
|
25883
25933
|
noHeader,
|
|
25884
25934
|
layout
|
|
25885
25935
|
}
|
|
@@ -26203,6 +26253,163 @@ var useDataTable2 = ({
|
|
|
26203
26253
|
});
|
|
26204
26254
|
return { table };
|
|
26205
26255
|
};
|
|
26256
|
+
|
|
26257
|
+
// src/price-lists/constants.ts
|
|
26258
|
+
var PriceListStatus = /* @__PURE__ */ ((PriceListStatus2) => {
|
|
26259
|
+
PriceListStatus2["ACTIVE"] = "active";
|
|
26260
|
+
PriceListStatus2["DRAFT"] = "draft";
|
|
26261
|
+
return PriceListStatus2;
|
|
26262
|
+
})(PriceListStatus || {});
|
|
26263
|
+
var PriceListDateStatus = /* @__PURE__ */ ((PriceListDateStatus2) => {
|
|
26264
|
+
PriceListDateStatus2["SCHEDULED"] = "scheduled";
|
|
26265
|
+
PriceListDateStatus2["EXPIRED"] = "expired";
|
|
26266
|
+
return PriceListDateStatus2;
|
|
26267
|
+
})(PriceListDateStatus || {});
|
|
26268
|
+
var PriceListType = /* @__PURE__ */ ((PriceListType2) => {
|
|
26269
|
+
PriceListType2["SALE"] = "sale";
|
|
26270
|
+
PriceListType2["OVERRIDE"] = "override";
|
|
26271
|
+
return PriceListType2;
|
|
26272
|
+
})(PriceListType || {});
|
|
26273
|
+
|
|
26274
|
+
// src/price-lists/build-offer-grid-data.ts
|
|
26275
|
+
var isPriceListGroupRow = (row) => row.__group === true;
|
|
26276
|
+
var buildOfferGridData = (offers, products) => {
|
|
26277
|
+
const variantTitle = {};
|
|
26278
|
+
const variantOrder = {};
|
|
26279
|
+
for (const product of products) {
|
|
26280
|
+
;
|
|
26281
|
+
(product.variants ?? []).forEach((variant, index) => {
|
|
26282
|
+
variantTitle[variant.id] = variant.title ?? "";
|
|
26283
|
+
variantOrder[variant.id] = index;
|
|
26284
|
+
});
|
|
26285
|
+
}
|
|
26286
|
+
const variantIdByOffer = {};
|
|
26287
|
+
const groups = /* @__PURE__ */ new Map();
|
|
26288
|
+
for (const offer of offers) {
|
|
26289
|
+
variantIdByOffer[offer.id] = offer.variant_id;
|
|
26290
|
+
const key = `${offer.product_id}::${offer.seller_id}`;
|
|
26291
|
+
const group = groups.get(key);
|
|
26292
|
+
if (group) {
|
|
26293
|
+
group.offers.push(offer);
|
|
26294
|
+
} else {
|
|
26295
|
+
groups.set(key, {
|
|
26296
|
+
product_title: offer.product?.title ?? "",
|
|
26297
|
+
product_thumbnail: offer.product?.thumbnail ?? null,
|
|
26298
|
+
seller_name: offer.seller?.name ?? "",
|
|
26299
|
+
offers: [offer]
|
|
26300
|
+
});
|
|
26301
|
+
}
|
|
26302
|
+
}
|
|
26303
|
+
const gridData = [];
|
|
26304
|
+
for (const [key, group] of groups) {
|
|
26305
|
+
gridData.push({
|
|
26306
|
+
__group: true,
|
|
26307
|
+
id: `group-${key}`,
|
|
26308
|
+
product_title: group.product_title,
|
|
26309
|
+
product_thumbnail: group.product_thumbnail,
|
|
26310
|
+
seller_name: group.seller_name
|
|
26311
|
+
});
|
|
26312
|
+
const sortedOffers = [...group.offers].sort((a, b) => {
|
|
26313
|
+
const oa = variantOrder[a.variant_id];
|
|
26314
|
+
const ob = variantOrder[b.variant_id];
|
|
26315
|
+
if (oa !== void 0 && ob !== void 0 && oa !== ob) {
|
|
26316
|
+
return oa - ob;
|
|
26317
|
+
}
|
|
26318
|
+
return (variantTitle[a.variant_id] ?? a.sku ?? "").localeCompare(
|
|
26319
|
+
variantTitle[b.variant_id] ?? b.sku ?? ""
|
|
26320
|
+
);
|
|
26321
|
+
});
|
|
26322
|
+
for (const offer of sortedOffers) {
|
|
26323
|
+
gridData.push({
|
|
26324
|
+
__group: false,
|
|
26325
|
+
id: offer.id,
|
|
26326
|
+
offer_id: offer.id,
|
|
26327
|
+
variant_id: offer.variant_id,
|
|
26328
|
+
variant_title: variantTitle[offer.variant_id] ?? offer.sku ?? "",
|
|
26329
|
+
product_id: offer.product_id,
|
|
26330
|
+
seller_name: group.seller_name,
|
|
26331
|
+
sku: offer.sku ?? ""
|
|
26332
|
+
});
|
|
26333
|
+
}
|
|
26334
|
+
}
|
|
26335
|
+
return { gridData, variantIdByOffer };
|
|
26336
|
+
};
|
|
26337
|
+
|
|
26338
|
+
// src/price-lists/utils.ts
|
|
26339
|
+
import i18n from "i18next";
|
|
26340
|
+
var castNumber = (number) => typeof number === "string" ? Number(number.replace(",", ".")) : number;
|
|
26341
|
+
var getValues = (priceList) => {
|
|
26342
|
+
const startsAt = priceList.starts_at;
|
|
26343
|
+
const endsAt = priceList.ends_at;
|
|
26344
|
+
const isExpired = endsAt ? new Date(endsAt) < /* @__PURE__ */ new Date() : false;
|
|
26345
|
+
const isScheduled = startsAt ? new Date(startsAt) > /* @__PURE__ */ new Date() : false;
|
|
26346
|
+
const isDraft = priceList.status === "draft" /* DRAFT */;
|
|
26347
|
+
return {
|
|
26348
|
+
isExpired,
|
|
26349
|
+
isScheduled,
|
|
26350
|
+
isDraft
|
|
26351
|
+
};
|
|
26352
|
+
};
|
|
26353
|
+
var getPriceListStatus = (t2, priceList) => {
|
|
26354
|
+
const { isExpired, isScheduled, isDraft } = getValues(priceList);
|
|
26355
|
+
let text = t2("priceLists.fields.status.options.active");
|
|
26356
|
+
let color = "green";
|
|
26357
|
+
let status = "active" /* ACTIVE */;
|
|
26358
|
+
if (isDraft) {
|
|
26359
|
+
color = "grey";
|
|
26360
|
+
text = t2("priceLists.fields.status.options.draft");
|
|
26361
|
+
status = "draft" /* DRAFT */;
|
|
26362
|
+
}
|
|
26363
|
+
if (isExpired) {
|
|
26364
|
+
color = "red";
|
|
26365
|
+
text = t2("priceLists.fields.status.options.expired");
|
|
26366
|
+
status = "expired" /* EXPIRED */;
|
|
26367
|
+
}
|
|
26368
|
+
if (isScheduled) {
|
|
26369
|
+
color = "orange";
|
|
26370
|
+
text = t2("priceLists.fields.status.options.scheduled");
|
|
26371
|
+
status = "scheduled" /* SCHEDULED */;
|
|
26372
|
+
}
|
|
26373
|
+
return {
|
|
26374
|
+
color,
|
|
26375
|
+
text,
|
|
26376
|
+
status
|
|
26377
|
+
};
|
|
26378
|
+
};
|
|
26379
|
+
var isProductRow = (row) => {
|
|
26380
|
+
return "variants" in row;
|
|
26381
|
+
};
|
|
26382
|
+
var extractPricesFromOffers = (offers, regions) => {
|
|
26383
|
+
return Object.entries(offers).flatMap(([offerId, offer]) => {
|
|
26384
|
+
const extractPriceDetails = (price, priceType, id) => {
|
|
26385
|
+
const currencyCode = priceType === "currency" ? id : regions.find((r) => r.id === id)?.currency_code;
|
|
26386
|
+
if (!currencyCode) {
|
|
26387
|
+
throw new Response(
|
|
26388
|
+
JSON.stringify({
|
|
26389
|
+
message: i18n.t("validation.currencyCodeNotFound")
|
|
26390
|
+
}),
|
|
26391
|
+
{ status: 400, headers: { "Content-Type": "application/json" } }
|
|
26392
|
+
);
|
|
26393
|
+
}
|
|
26394
|
+
return {
|
|
26395
|
+
amount: castNumber(price.amount),
|
|
26396
|
+
rules: {
|
|
26397
|
+
offer_id: offerId,
|
|
26398
|
+
...priceType === "region" ? { region_id: id } : {}
|
|
26399
|
+
},
|
|
26400
|
+
currency_code: currencyCode,
|
|
26401
|
+
variant_id: offer.variant_id
|
|
26402
|
+
};
|
|
26403
|
+
};
|
|
26404
|
+
const currencyPrices = Object.entries(offer.currency_prices || {}).flatMap(
|
|
26405
|
+
([currencyCode, currencyPrice]) => currencyPrice?.amount ? [extractPriceDetails(currencyPrice, "currency", currencyCode)] : []
|
|
26406
|
+
);
|
|
26407
|
+
const regionPrices = Object.entries(offer.region_prices || {}).flatMap(
|
|
26408
|
+
([regionId, regionPrice]) => regionPrice?.amount ? [extractPriceDetails(regionPrice, "region", regionId)] : []
|
|
26409
|
+
);
|
|
26410
|
+
return [...currencyPrices, ...regionPrices];
|
|
26411
|
+
});
|
|
26412
|
+
};
|
|
26206
26413
|
export {
|
|
26207
26414
|
ActionMenu,
|
|
26208
26415
|
AddressForm,
|
|
@@ -26257,6 +26464,9 @@ export {
|
|
|
26257
26464
|
NoResults,
|
|
26258
26465
|
OrderBy,
|
|
26259
26466
|
PlaceholderCell,
|
|
26467
|
+
PriceListDateStatus,
|
|
26468
|
+
PriceListStatus,
|
|
26469
|
+
PriceListType,
|
|
26260
26470
|
ProductAttributeSection,
|
|
26261
26471
|
ProductChangePanel,
|
|
26262
26472
|
ProgressBar,
|
|
@@ -26291,16 +26501,21 @@ export {
|
|
|
26291
26501
|
applyNavOverrides,
|
|
26292
26502
|
buildAdditionalDataDefaults,
|
|
26293
26503
|
buildAdditionalDataSchema,
|
|
26504
|
+
buildOfferGridData,
|
|
26294
26505
|
buildProductChangeView,
|
|
26295
26506
|
createDataGridHelper,
|
|
26296
26507
|
createDataGridPriceColumns,
|
|
26297
26508
|
createFormHelper,
|
|
26509
|
+
extractPricesFromOffers,
|
|
26298
26510
|
extractReferenceIds,
|
|
26299
26511
|
formatFieldValue,
|
|
26300
26512
|
getExtensionRegistry,
|
|
26301
26513
|
getLinkQuery,
|
|
26514
|
+
getPriceListStatus,
|
|
26302
26515
|
humanizeFieldName,
|
|
26303
26516
|
isImageList,
|
|
26517
|
+
isPriceListGroupRow,
|
|
26518
|
+
isProductRow,
|
|
26304
26519
|
isReferenceField,
|
|
26305
26520
|
linkFields,
|
|
26306
26521
|
productChangeViewHasContent,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mercurjs/dashboard-shared",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0-canary.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/mercurjs/mercur",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"build": "tsup"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@mercurjs/client": "2.
|
|
26
|
+
"@mercurjs/client": "2.3.0-canary.0",
|
|
27
27
|
"@ariakit/react": "^0.4.15",
|
|
28
28
|
"@babel/runtime": "^8.0.0",
|
|
29
29
|
"@dnd-kit/core": "^6.1.0",
|
|
@@ -63,9 +63,9 @@
|
|
|
63
63
|
"zod": "4.4.3"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
|
-
"@mercurjs/types": "2.
|
|
67
|
-
"@mercurjs/core": "2.
|
|
68
|
-
"@mercurjs/dashboard-sdk": "2.
|
|
66
|
+
"@mercurjs/types": "2.3.0-canary.0",
|
|
67
|
+
"@mercurjs/core": "2.3.0-canary.0",
|
|
68
|
+
"@mercurjs/dashboard-sdk": "2.3.0-canary.0",
|
|
69
69
|
"tsup": "^8.0.2",
|
|
70
70
|
"typescript": "5.9.3",
|
|
71
71
|
"@types/lodash.debounce": "^4.0.8",
|