@proveanything/smartlinks-utils-ui 0.7.0 → 0.7.1
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/chunk-RBKJ4LZG.js +28 -0
- package/dist/chunk-RBKJ4LZG.js.map +1 -0
- package/dist/components/AssetPicker/index.js +1 -1
- package/dist/components/ConditionsEditor/index.js +1 -1
- package/dist/components/FontPicker/index.js +1 -1
- package/dist/components/IconPicker/index.js +1 -1
- package/dist/components/RecordsAdmin/index.js +354 -31
- package/dist/components/RecordsAdmin/index.js.map +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-HXJLROC2.js +0 -28
- package/dist/chunk-HXJLROC2.js.map +0 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { styleInject } from '../../chunk-
|
|
1
|
+
import { styleInject } from '../../chunk-RBKJ4LZG.js';
|
|
2
2
|
import { FacetRuleEditor } from '../../chunk-JMCV6FOW.js';
|
|
3
3
|
import { useFacets } from '../../chunk-4LHF5JB7.js';
|
|
4
4
|
import { cn } from '../../chunk-L7FQ52F5.js';
|
|
5
5
|
import { listRecords, parsedRefToTarget, parsedRefToScope, matchRecords, scopesEqual, getRecordById, updateRecord, createRecord, upsertRecord, removeRecord } from '../../chunk-KFKVGUUP.js';
|
|
6
6
|
export { bulkDelete, bulkUpsert, createRecord, getRecordById, listRecords, matchRecords, parsedRefToScope, parsedRefToTarget, removeRecord, restoreRecord, scopesEqual, upsertRecord } from '../../chunk-KFKVGUUP.js';
|
|
7
7
|
import { createContext, useMemo, useState, useEffect, useCallback, useRef, useContext, createElement, useId } from 'react';
|
|
8
|
-
import { ChevronDown, Database, Lightbulb, SearchX, Inbox, LayoutGrid, Eye, MoreHorizontal, Download, Upload, Trash2, Copy, Pencil, Plus, CircleDashed, ArrowDownLeft, CheckCircle2, SlidersHorizontal, Globe, Tag, Boxes, Layers, Package, Rows3, List, ChevronRight, Eraser, ClipboardPaste, Box, X, Image, Table, ArrowLeft, ChevronLeft, AlertTriangle, Info, HelpCircle, Search, CornerDownLeft, Circle, AlertCircle, Undo2, Save, BookOpen, Target, Settings2 } from 'lucide-react';
|
|
8
|
+
import { ChevronDown, Database, Lightbulb, SearchX, Inbox, LayoutGrid, Eye, MoreHorizontal, Download, Upload, Trash2, Copy, Pencil, Plus, CircleDashed, ArrowDownLeft, CheckCircle2, SlidersHorizontal, Globe, Tag, Boxes, Layers, Package, Rows3, List, ChevronRight, Eraser, ClipboardPaste, Box, X, Image, Table, ArrowLeft, ChevronLeft, AlertTriangle, Info, HelpCircle, Search, CornerDownLeft, Circle, AlertCircle, Undo2, Save, ArrowRight, BookOpen, Target, Settings2 } from 'lucide-react';
|
|
9
9
|
import { useQueryClient, useInfiniteQuery, useQuery } from '@tanstack/react-query';
|
|
10
10
|
import { createPortal } from 'react-dom';
|
|
11
11
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
@@ -1883,6 +1883,7 @@ function applyRuleFilters(items, filters) {
|
|
|
1883
1883
|
return true;
|
|
1884
1884
|
});
|
|
1885
1885
|
}
|
|
1886
|
+
var COLLAPSED_FACET_CAP = 6;
|
|
1886
1887
|
function FacetBrowseFilter({
|
|
1887
1888
|
facets,
|
|
1888
1889
|
value,
|
|
@@ -1895,39 +1896,61 @@ function FacetBrowseFilter({
|
|
|
1895
1896
|
[facets]
|
|
1896
1897
|
);
|
|
1897
1898
|
const [openKey, setOpenKey] = useState(value?.facetKey ?? firstUsable ?? null);
|
|
1899
|
+
const [allExpanded, setAllExpanded] = useState(false);
|
|
1898
1900
|
const effectiveOpen = value?.facetKey ?? openKey ?? firstUsable ?? null;
|
|
1899
1901
|
if (isLoading) {
|
|
1900
1902
|
return /* @__PURE__ */ jsx("div", { className: "ra-rule-filters", "aria-busy": "true", children: /* @__PURE__ */ jsx("div", { className: "ra-rule-filters-row", children: /* @__PURE__ */ jsx("span", { className: "ra-rule-filter-chip", "data-active": "false", children: "Loading facets\u2026" }) }) });
|
|
1901
1903
|
}
|
|
1902
1904
|
if (!facets.length) return null;
|
|
1903
1905
|
const openFacet = facets.find((f) => f.key === effectiveOpen) ?? null;
|
|
1906
|
+
const overflow = facets.length - COLLAPSED_FACET_CAP;
|
|
1907
|
+
let visibleFacets = facets;
|
|
1908
|
+
if (!allExpanded && overflow > 0) {
|
|
1909
|
+
const head = facets.slice(0, COLLAPSED_FACET_CAP);
|
|
1910
|
+
const activeFacet = value ? facets.find((f) => f.key === value.facetKey) : null;
|
|
1911
|
+
visibleFacets = activeFacet && !head.includes(activeFacet) ? [...head.slice(0, COLLAPSED_FACET_CAP - 1), activeFacet] : head;
|
|
1912
|
+
}
|
|
1904
1913
|
return /* @__PURE__ */ jsxs("div", { className: "ra-rule-filters", role: "group", "aria-label": "Browse by facet", children: [
|
|
1905
|
-
/* @__PURE__ */
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1914
|
+
/* @__PURE__ */ jsxs("div", { className: "ra-rule-filters-row", children: [
|
|
1915
|
+
visibleFacets.map((f) => {
|
|
1916
|
+
const active = effectiveOpen === f.key;
|
|
1917
|
+
const isFiltered = value?.facetKey === f.key;
|
|
1918
|
+
return /* @__PURE__ */ jsxs(
|
|
1919
|
+
"button",
|
|
1920
|
+
{
|
|
1921
|
+
type: "button",
|
|
1922
|
+
className: "ra-rule-filter-chip",
|
|
1923
|
+
"data-active": isFiltered ? "true" : "false",
|
|
1924
|
+
"aria-pressed": active,
|
|
1925
|
+
onClick: () => {
|
|
1926
|
+
if (isFiltered) {
|
|
1927
|
+
onChange(null);
|
|
1928
|
+
return;
|
|
1929
|
+
}
|
|
1930
|
+
setOpenKey(f.key);
|
|
1931
|
+
},
|
|
1932
|
+
title: `Browse ${f.label ?? f.key} values`,
|
|
1933
|
+
children: [
|
|
1934
|
+
/* @__PURE__ */ jsx("span", { className: "ra-rule-filter-chip-label", children: f.label ?? f.key }),
|
|
1935
|
+
/* @__PURE__ */ jsx("span", { className: "ra-rule-filter-chip-count", children: f.values.length })
|
|
1936
|
+
]
|
|
1937
|
+
},
|
|
1938
|
+
f.key
|
|
1939
|
+
);
|
|
1940
|
+
}),
|
|
1941
|
+
overflow > 0 && /* @__PURE__ */ jsx(
|
|
1909
1942
|
"button",
|
|
1910
1943
|
{
|
|
1911
1944
|
type: "button",
|
|
1945
|
+
onClick: () => setAllExpanded((v) => !v),
|
|
1912
1946
|
className: "ra-rule-filter-chip",
|
|
1913
|
-
"data-active":
|
|
1914
|
-
"aria-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
setOpenKey(f.key);
|
|
1921
|
-
},
|
|
1922
|
-
title: `Browse ${f.label ?? f.key} values`,
|
|
1923
|
-
children: [
|
|
1924
|
-
/* @__PURE__ */ jsx("span", { className: "ra-rule-filter-chip-label", children: f.label ?? f.key }),
|
|
1925
|
-
/* @__PURE__ */ jsx("span", { className: "ra-rule-filter-chip-count", children: f.values.length })
|
|
1926
|
-
]
|
|
1927
|
-
},
|
|
1928
|
-
f.key
|
|
1929
|
-
);
|
|
1930
|
-
}) }),
|
|
1947
|
+
"data-active": "false",
|
|
1948
|
+
"aria-expanded": allExpanded,
|
|
1949
|
+
title: allExpanded ? "Show fewer facets" : `Show all ${facets.length} facets`,
|
|
1950
|
+
children: /* @__PURE__ */ jsx("span", { className: "ra-rule-filter-chip-label", children: allExpanded ? "Show fewer" : `Show all (${facets.length})` })
|
|
1951
|
+
}
|
|
1952
|
+
)
|
|
1953
|
+
] }),
|
|
1931
1954
|
openFacet && openFacet.values.length > 0 && /* @__PURE__ */ jsx(
|
|
1932
1955
|
"div",
|
|
1933
1956
|
{
|
|
@@ -3794,6 +3817,198 @@ function ShellHeader({
|
|
|
3794
3817
|
}
|
|
3795
3818
|
) });
|
|
3796
3819
|
}
|
|
3820
|
+
function NewRuleWizard({
|
|
3821
|
+
SL,
|
|
3822
|
+
collectionId,
|
|
3823
|
+
appId,
|
|
3824
|
+
step,
|
|
3825
|
+
rule,
|
|
3826
|
+
onRuleChange,
|
|
3827
|
+
onCancel,
|
|
3828
|
+
onNext,
|
|
3829
|
+
onBack,
|
|
3830
|
+
children,
|
|
3831
|
+
itemNoun = "record"
|
|
3832
|
+
}) {
|
|
3833
|
+
const preview = useRulePreview({ SL, collectionId, appId, rule });
|
|
3834
|
+
const canProceed = isFacetRuleValid(rule);
|
|
3835
|
+
if (step === 1) {
|
|
3836
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex h-full flex-col overflow-hidden", children: [
|
|
3837
|
+
/* @__PURE__ */ jsx(
|
|
3838
|
+
WizardStepHeader,
|
|
3839
|
+
{
|
|
3840
|
+
step: 1,
|
|
3841
|
+
totalSteps: 2,
|
|
3842
|
+
title: "Configure rule",
|
|
3843
|
+
description: "Pick the facet conditions that decide which products this rule applies to.",
|
|
3844
|
+
onCancel
|
|
3845
|
+
}
|
|
3846
|
+
),
|
|
3847
|
+
/* @__PURE__ */ jsx("div", { className: "flex-1 min-h-0 overflow-auto px-5 py-4", children: /* @__PURE__ */ jsx(
|
|
3848
|
+
FacetRuleEditor,
|
|
3849
|
+
{
|
|
3850
|
+
value: rule,
|
|
3851
|
+
onChange: onRuleChange,
|
|
3852
|
+
collectionId,
|
|
3853
|
+
preview,
|
|
3854
|
+
description: "The new rule will apply to every product whose facets match every clause below."
|
|
3855
|
+
}
|
|
3856
|
+
) }),
|
|
3857
|
+
/* @__PURE__ */ jsx(
|
|
3858
|
+
WizardFooter,
|
|
3859
|
+
{
|
|
3860
|
+
left: /* @__PURE__ */ jsx(
|
|
3861
|
+
"button",
|
|
3862
|
+
{
|
|
3863
|
+
type: "button",
|
|
3864
|
+
onClick: onCancel,
|
|
3865
|
+
className: "ra-btn",
|
|
3866
|
+
"data-variant": "ghost",
|
|
3867
|
+
children: "Cancel"
|
|
3868
|
+
}
|
|
3869
|
+
),
|
|
3870
|
+
right: /* @__PURE__ */ jsxs(
|
|
3871
|
+
"button",
|
|
3872
|
+
{
|
|
3873
|
+
type: "button",
|
|
3874
|
+
onClick: onNext,
|
|
3875
|
+
disabled: !canProceed,
|
|
3876
|
+
className: "ra-btn",
|
|
3877
|
+
"data-variant": "primary",
|
|
3878
|
+
children: [
|
|
3879
|
+
/* @__PURE__ */ jsx("span", { children: "Next" }),
|
|
3880
|
+
/* @__PURE__ */ jsx(ArrowRight, { "aria-hidden": "true", className: "w-4 h-4" })
|
|
3881
|
+
]
|
|
3882
|
+
}
|
|
3883
|
+
),
|
|
3884
|
+
hint: !canProceed ? "Add at least one facet clause with values to continue." : preview.totalMatches != null ? `${preview.totalMatches} product${preview.totalMatches === 1 ? "" : "s"} currently match this rule.` : void 0
|
|
3885
|
+
}
|
|
3886
|
+
)
|
|
3887
|
+
] });
|
|
3888
|
+
}
|
|
3889
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex h-full flex-col overflow-hidden", children: [
|
|
3890
|
+
/* @__PURE__ */ jsx(
|
|
3891
|
+
WizardStepHeader,
|
|
3892
|
+
{
|
|
3893
|
+
step: 2,
|
|
3894
|
+
totalSteps: 2,
|
|
3895
|
+
title: `Configure ${itemNoun}`,
|
|
3896
|
+
description: preview.totalMatches != null ? `This rule currently matches ${preview.totalMatches} product${preview.totalMatches === 1 ? "" : "s"}.` : "Fill in the details for this rule.",
|
|
3897
|
+
onCancel,
|
|
3898
|
+
onBack
|
|
3899
|
+
}
|
|
3900
|
+
),
|
|
3901
|
+
/* @__PURE__ */ jsx("div", { className: "flex-1 min-h-0 overflow-hidden", children })
|
|
3902
|
+
] });
|
|
3903
|
+
}
|
|
3904
|
+
function WizardStepHeader({
|
|
3905
|
+
step,
|
|
3906
|
+
totalSteps,
|
|
3907
|
+
title,
|
|
3908
|
+
description,
|
|
3909
|
+
onCancel,
|
|
3910
|
+
onBack
|
|
3911
|
+
}) {
|
|
3912
|
+
return /* @__PURE__ */ jsxs(
|
|
3913
|
+
"div",
|
|
3914
|
+
{
|
|
3915
|
+
className: "flex items-start gap-3 px-5 py-3 border-b",
|
|
3916
|
+
style: { borderColor: "hsl(var(--ra-border))", background: "hsl(var(--ra-muted) / 0.4)" },
|
|
3917
|
+
children: [
|
|
3918
|
+
/* @__PURE__ */ jsxs("div", { className: "flex-1 min-w-0", children: [
|
|
3919
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 mb-0.5", children: [
|
|
3920
|
+
/* @__PURE__ */ jsxs(
|
|
3921
|
+
"span",
|
|
3922
|
+
{
|
|
3923
|
+
className: "text-[10px] font-semibold uppercase tracking-wider px-1.5 py-0.5 rounded",
|
|
3924
|
+
style: {
|
|
3925
|
+
color: "hsl(var(--ra-accent))",
|
|
3926
|
+
background: "hsl(var(--ra-accent) / 0.12)"
|
|
3927
|
+
},
|
|
3928
|
+
children: [
|
|
3929
|
+
"Step ",
|
|
3930
|
+
step,
|
|
3931
|
+
" of ",
|
|
3932
|
+
totalSteps
|
|
3933
|
+
]
|
|
3934
|
+
}
|
|
3935
|
+
),
|
|
3936
|
+
/* @__PURE__ */ jsx(
|
|
3937
|
+
"h2",
|
|
3938
|
+
{
|
|
3939
|
+
className: "text-sm font-semibold m-0",
|
|
3940
|
+
style: { color: "hsl(var(--ra-text))" },
|
|
3941
|
+
children: title
|
|
3942
|
+
}
|
|
3943
|
+
)
|
|
3944
|
+
] }),
|
|
3945
|
+
description ? /* @__PURE__ */ jsx(
|
|
3946
|
+
"p",
|
|
3947
|
+
{
|
|
3948
|
+
className: "text-xs m-0",
|
|
3949
|
+
style: { color: "hsl(var(--ra-muted-text))" },
|
|
3950
|
+
children: description
|
|
3951
|
+
}
|
|
3952
|
+
) : null
|
|
3953
|
+
] }),
|
|
3954
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5 shrink-0", children: [
|
|
3955
|
+
onBack ? /* @__PURE__ */ jsxs(
|
|
3956
|
+
"button",
|
|
3957
|
+
{
|
|
3958
|
+
type: "button",
|
|
3959
|
+
onClick: onBack,
|
|
3960
|
+
className: "ra-btn",
|
|
3961
|
+
"data-variant": "ghost",
|
|
3962
|
+
"aria-label": "Back to rule",
|
|
3963
|
+
children: [
|
|
3964
|
+
/* @__PURE__ */ jsx(ArrowLeft, { "aria-hidden": "true", className: "w-4 h-4" }),
|
|
3965
|
+
/* @__PURE__ */ jsx("span", { children: "Back" })
|
|
3966
|
+
]
|
|
3967
|
+
}
|
|
3968
|
+
) : null,
|
|
3969
|
+
/* @__PURE__ */ jsx(
|
|
3970
|
+
"button",
|
|
3971
|
+
{
|
|
3972
|
+
type: "button",
|
|
3973
|
+
onClick: onCancel,
|
|
3974
|
+
className: "ra-btn",
|
|
3975
|
+
"data-variant": "ghost",
|
|
3976
|
+
"aria-label": "Cancel new rule",
|
|
3977
|
+
title: "Cancel",
|
|
3978
|
+
style: { width: "2rem", height: "2rem", padding: 0, justifyContent: "center" },
|
|
3979
|
+
children: /* @__PURE__ */ jsx(X, { "aria-hidden": "true", className: "w-4 h-4" })
|
|
3980
|
+
}
|
|
3981
|
+
)
|
|
3982
|
+
] })
|
|
3983
|
+
]
|
|
3984
|
+
}
|
|
3985
|
+
);
|
|
3986
|
+
}
|
|
3987
|
+
function WizardFooter({
|
|
3988
|
+
left,
|
|
3989
|
+
right,
|
|
3990
|
+
hint
|
|
3991
|
+
}) {
|
|
3992
|
+
return /* @__PURE__ */ jsxs(
|
|
3993
|
+
"div",
|
|
3994
|
+
{
|
|
3995
|
+
className: "flex items-center gap-3 px-5 py-3 border-t",
|
|
3996
|
+
style: { borderColor: "hsl(var(--ra-border))", background: "hsl(var(--ra-surface))" },
|
|
3997
|
+
children: [
|
|
3998
|
+
/* @__PURE__ */ jsx("div", { className: "flex items-center gap-2", children: left }),
|
|
3999
|
+
hint ? /* @__PURE__ */ jsx(
|
|
4000
|
+
"span",
|
|
4001
|
+
{
|
|
4002
|
+
className: "text-xs flex-1 min-w-0 truncate",
|
|
4003
|
+
style: { color: "hsl(var(--ra-muted-text))" },
|
|
4004
|
+
children: hint
|
|
4005
|
+
}
|
|
4006
|
+
) : /* @__PURE__ */ jsx("div", { className: "flex-1" }),
|
|
4007
|
+
/* @__PURE__ */ jsx("div", { className: "flex items-center gap-2 shrink-0", children: right })
|
|
4008
|
+
]
|
|
4009
|
+
}
|
|
4010
|
+
);
|
|
4011
|
+
}
|
|
3797
4012
|
var UnsavedBanner = ({
|
|
3798
4013
|
label,
|
|
3799
4014
|
context,
|
|
@@ -4157,6 +4372,8 @@ function RecordsAdminShell(props) {
|
|
|
4157
4372
|
const [facetBrowseFilter, setFacetBrowseFilter] = useState(null);
|
|
4158
4373
|
const [selectedRecordId, setSelectedRecordId] = useState(null);
|
|
4159
4374
|
const [draftKind, setDraftKind] = useState(null);
|
|
4375
|
+
const [ruleWizardStep, setRuleWizardStep] = useState(null);
|
|
4376
|
+
const [ruleWizardRule, setRuleWizardRule] = useState(null);
|
|
4160
4377
|
const [selectedProductId, setSelectedProductId] = useState(
|
|
4161
4378
|
contextScope?.productId
|
|
4162
4379
|
);
|
|
@@ -4260,6 +4477,9 @@ function RecordsAdminShell(props) {
|
|
|
4260
4477
|
return null;
|
|
4261
4478
|
}
|
|
4262
4479
|
if (selectedRecordId === DRAFT_ID) {
|
|
4480
|
+
if (draftKind === "rule") {
|
|
4481
|
+
return { ...parseRef(""), kind: "rule", raw: "rule:__draft__" };
|
|
4482
|
+
}
|
|
4263
4483
|
return parseRef("");
|
|
4264
4484
|
}
|
|
4265
4485
|
const hit = recordList.items.find((it) => it.id === selectedRecordId);
|
|
@@ -4276,7 +4496,7 @@ function RecordsAdminShell(props) {
|
|
|
4276
4496
|
return parseRef(buildRef({ productId: selectedProductId, batchId: selectedBatchId }));
|
|
4277
4497
|
}
|
|
4278
4498
|
return parseRef(buildRef({ productId: selectedProductId }));
|
|
4279
|
-
}, [activeScope, cardinality, selectedRecordId, recordList.items, selectedProductId, drillTab, selectedVariantId, selectedBatchId]);
|
|
4499
|
+
}, [activeScope, cardinality, selectedRecordId, draftKind, recordList.items, selectedProductId, drillTab, selectedVariantId, selectedBatchId]);
|
|
4280
4500
|
const isCollection = cardinality === "collection";
|
|
4281
4501
|
const editingItemRecordId = isCollection ? selectedItemId : null;
|
|
4282
4502
|
const collectionItems = useCollectionItems({
|
|
@@ -4401,9 +4621,14 @@ function RecordsAdminShell(props) {
|
|
|
4401
4621
|
// section can render its empty-state picker. For existing rule records
|
|
4402
4622
|
// pull the saved rule off the resolved record. Pinned scopes get `null`
|
|
4403
4623
|
// and the Targeting section stays hidden.
|
|
4404
|
-
initialFacetRule: editingTargetScope?.kind === "rule" ? resolved.facetRule ?? { all: [] } : null,
|
|
4624
|
+
initialFacetRule: editingTargetScope?.kind === "rule" ? ruleWizardStep === 2 && ruleWizardRule ? ruleWizardRule : resolved.facetRule ?? { all: [] } : ruleWizardStep === 2 && ruleWizardRule && isCollection && !!selectedItemId ? ruleWizardRule : null,
|
|
4405
4625
|
onSaved: () => {
|
|
4406
4626
|
onTelemetry?.({ type: "record.save", recordType, ref: editingTargetScope?.raw ?? "", isCreate: resolved.source !== "self" });
|
|
4627
|
+
if (ruleWizardStep !== null) {
|
|
4628
|
+
setRuleWizardStep(null);
|
|
4629
|
+
setRuleWizardRule(null);
|
|
4630
|
+
setDraftKind(null);
|
|
4631
|
+
}
|
|
4407
4632
|
refetchAll();
|
|
4408
4633
|
},
|
|
4409
4634
|
onDeleted: () => {
|
|
@@ -4910,10 +5135,38 @@ function RecordsAdminShell(props) {
|
|
|
4910
5135
|
const onCreateRule = useCallback(() => {
|
|
4911
5136
|
void runWithGuard(() => {
|
|
4912
5137
|
if (activeScope !== "rule") setActiveScope("rule");
|
|
4913
|
-
setSelectedRecordId(
|
|
5138
|
+
setSelectedRecordId(null);
|
|
5139
|
+
setSelectedItemId(null);
|
|
4914
5140
|
setDraftKind("rule");
|
|
5141
|
+
setRuleWizardRule({ all: [] });
|
|
5142
|
+
setRuleWizardStep(1);
|
|
4915
5143
|
});
|
|
4916
5144
|
}, [runWithGuard, activeScope]);
|
|
5145
|
+
const onCancelRuleWizard = useCallback(() => {
|
|
5146
|
+
setRuleWizardStep(null);
|
|
5147
|
+
setRuleWizardRule(null);
|
|
5148
|
+
setSelectedRecordId(null);
|
|
5149
|
+
setSelectedItemId(null);
|
|
5150
|
+
setDraftKind(null);
|
|
5151
|
+
}, []);
|
|
5152
|
+
const onRuleWizardNext = useCallback(() => {
|
|
5153
|
+
if (cardinality === "collection") {
|
|
5154
|
+
setRuleWizardStep(2);
|
|
5155
|
+
} else {
|
|
5156
|
+
setRuleWizardStep(2);
|
|
5157
|
+
setSelectedRecordId(DRAFT_ID);
|
|
5158
|
+
}
|
|
5159
|
+
}, [cardinality]);
|
|
5160
|
+
const onRuleWizardBack = useCallback(() => {
|
|
5161
|
+
setRuleWizardStep(1);
|
|
5162
|
+
setSelectedRecordId(null);
|
|
5163
|
+
setSelectedItemId(null);
|
|
5164
|
+
}, []);
|
|
5165
|
+
const onRuleWizardCreateItem = useCallback(() => {
|
|
5166
|
+
if (!isCollection) return;
|
|
5167
|
+
const id = generateItemId ? generateItemId() : DRAFT_ID;
|
|
5168
|
+
setSelectedItemId(id);
|
|
5169
|
+
}, [isCollection, generateItemId]);
|
|
4917
5170
|
const hasGlobalRecord = useMemo(
|
|
4918
5171
|
() => recordList.items.some((it) => !it.scope.productId && !it.scope.facetId && !it.scope.variantId && !it.scope.batchId && !it.scope.proofId),
|
|
4919
5172
|
[recordList.items]
|
|
@@ -4994,6 +5247,10 @@ function RecordsAdminShell(props) {
|
|
|
4994
5247
|
} else {
|
|
4995
5248
|
setSelectedRecordId(item.id ?? null);
|
|
4996
5249
|
setDraftKind(null);
|
|
5250
|
+
if (ruleWizardStep !== null) {
|
|
5251
|
+
setRuleWizardStep(null);
|
|
5252
|
+
setRuleWizardRule(null);
|
|
5253
|
+
}
|
|
4997
5254
|
}
|
|
4998
5255
|
});
|
|
4999
5256
|
};
|
|
@@ -5140,6 +5397,11 @@ function RecordsAdminShell(props) {
|
|
|
5140
5397
|
onChange: (s) => {
|
|
5141
5398
|
void runWithGuard(() => {
|
|
5142
5399
|
onTelemetry?.({ type: "scope.change", recordType, from: activeScope, to: s });
|
|
5400
|
+
if (ruleWizardStep !== null) {
|
|
5401
|
+
setRuleWizardStep(null);
|
|
5402
|
+
setRuleWizardRule(null);
|
|
5403
|
+
setDraftKind(null);
|
|
5404
|
+
}
|
|
5143
5405
|
setActiveScope(s);
|
|
5144
5406
|
});
|
|
5145
5407
|
},
|
|
@@ -5277,7 +5539,68 @@ function RecordsAdminShell(props) {
|
|
|
5277
5539
|
] })
|
|
5278
5540
|
] }) }),
|
|
5279
5541
|
/* @__PURE__ */ jsxs("main", { className: "overflow-hidden", children: [
|
|
5280
|
-
|
|
5542
|
+
ruleWizardStep !== null && /* @__PURE__ */ jsxs(
|
|
5543
|
+
NewRuleWizard,
|
|
5544
|
+
{
|
|
5545
|
+
SL,
|
|
5546
|
+
collectionId,
|
|
5547
|
+
appId,
|
|
5548
|
+
step: ruleWizardStep,
|
|
5549
|
+
rule: ruleWizardRule,
|
|
5550
|
+
onRuleChange: setRuleWizardRule,
|
|
5551
|
+
onCancel: onCancelRuleWizard,
|
|
5552
|
+
onNext: onRuleWizardNext,
|
|
5553
|
+
onBack: onRuleWizardBack,
|
|
5554
|
+
itemNoun,
|
|
5555
|
+
children: [
|
|
5556
|
+
ruleWizardStep === 2 && !isCollection && editingTargetScope && renderEditorWithPreview(),
|
|
5557
|
+
ruleWizardStep === 2 && isCollection && !selectedItemId && /* @__PURE__ */ jsx("div", { className: "h-full flex items-center justify-center px-6 py-10", children: /* @__PURE__ */ jsxs("div", { className: "max-w-sm text-center space-y-3", children: [
|
|
5558
|
+
/* @__PURE__ */ jsxs(
|
|
5559
|
+
"h3",
|
|
5560
|
+
{
|
|
5561
|
+
className: "text-base font-semibold m-0",
|
|
5562
|
+
style: { color: "hsl(var(--ra-text))" },
|
|
5563
|
+
children: [
|
|
5564
|
+
"Create your first ",
|
|
5565
|
+
itemNoun,
|
|
5566
|
+
" for this rule"
|
|
5567
|
+
]
|
|
5568
|
+
}
|
|
5569
|
+
),
|
|
5570
|
+
/* @__PURE__ */ jsxs(
|
|
5571
|
+
"p",
|
|
5572
|
+
{
|
|
5573
|
+
className: "text-sm m-0",
|
|
5574
|
+
style: { color: "hsl(var(--ra-muted-text))" },
|
|
5575
|
+
children: [
|
|
5576
|
+
"The rule is set up. Now add the first ",
|
|
5577
|
+
itemNoun,
|
|
5578
|
+
" that should apply to every product matching it. You can add more later."
|
|
5579
|
+
]
|
|
5580
|
+
}
|
|
5581
|
+
),
|
|
5582
|
+
/* @__PURE__ */ jsxs(
|
|
5583
|
+
"button",
|
|
5584
|
+
{
|
|
5585
|
+
type: "button",
|
|
5586
|
+
onClick: onRuleWizardCreateItem,
|
|
5587
|
+
className: "ra-btn",
|
|
5588
|
+
"data-variant": "primary",
|
|
5589
|
+
children: [
|
|
5590
|
+
/* @__PURE__ */ jsx(Plus, { "aria-hidden": "true", className: "w-4 h-4" }),
|
|
5591
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
5592
|
+
"Create first ",
|
|
5593
|
+
itemNoun
|
|
5594
|
+
] })
|
|
5595
|
+
]
|
|
5596
|
+
}
|
|
5597
|
+
)
|
|
5598
|
+
] }) }),
|
|
5599
|
+
ruleWizardStep === 2 && isCollection && !!selectedItemId && editingTargetScope && renderEditorWithPreview()
|
|
5600
|
+
]
|
|
5601
|
+
}
|
|
5602
|
+
),
|
|
5603
|
+
ruleWizardStep === null && isCollection && editingScope && !selectedItemId && /* @__PURE__ */ jsx(
|
|
5281
5604
|
ItemListView,
|
|
5282
5605
|
{
|
|
5283
5606
|
items: collectionItems.items,
|
|
@@ -5295,8 +5618,8 @@ function RecordsAdminShell(props) {
|
|
|
5295
5618
|
i18n
|
|
5296
5619
|
}
|
|
5297
5620
|
),
|
|
5298
|
-
!isCollection && !editingScope && activeScope === "product" && !selectedProductId && /* @__PURE__ */ jsx(EmptyState, { title: i18n.emptyTitle, body: i18n.emptyBody }),
|
|
5299
|
-
isProductTab && selectedProductId && (!isCollection || selectedItemId) && /* @__PURE__ */ jsx(
|
|
5621
|
+
ruleWizardStep === null && !isCollection && !editingScope && activeScope === "product" && !selectedProductId && /* @__PURE__ */ jsx(EmptyState, { title: i18n.emptyTitle, body: i18n.emptyBody }),
|
|
5622
|
+
ruleWizardStep === null && isProductTab && selectedProductId && (!isCollection || selectedItemId) && /* @__PURE__ */ jsx(
|
|
5300
5623
|
ProductDrillDown,
|
|
5301
5624
|
{
|
|
5302
5625
|
productLabel: productBrowse.items.find((p) => p.id === selectedProductId)?.name ?? selectedProductId,
|
|
@@ -5333,7 +5656,7 @@ function RecordsAdminShell(props) {
|
|
|
5333
5656
|
)
|
|
5334
5657
|
}
|
|
5335
5658
|
),
|
|
5336
|
-
!isProductTab && editingTargetScope && (!isCollection || selectedItemId) && renderEditorWithPreview()
|
|
5659
|
+
ruleWizardStep === null && !isProductTab && editingTargetScope && (!isCollection || selectedItemId) && renderEditorWithPreview()
|
|
5337
5660
|
] })
|
|
5338
5661
|
]
|
|
5339
5662
|
}
|