@caratlogic/design-system 0.1.39 → 0.1.40
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/components/inventory/AuditTimeline.d.ts +4 -0
- package/dist/components/inventory/AuditTimeline.d.ts.map +1 -1
- package/dist/components/organisms/AuditHistoryPanel/AuditHistoryTimeline.d.ts.map +1 -1
- package/dist/index.cjs.js +48 -14
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +48 -15
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
|
@@ -35,7 +35,11 @@ export interface PillData {
|
|
|
35
35
|
newVal?: string;
|
|
36
36
|
/** 'added' = green item pill, 'removed' = red item pill */
|
|
37
37
|
variant?: 'added' | 'removed';
|
|
38
|
+
/** Set for rich-text fields, which show what happened instead of a value. */
|
|
39
|
+
changeNote?: 'added' | 'updated' | 'removed';
|
|
38
40
|
}
|
|
41
|
+
/** "Customer Notes were updated" / "Description was added". */
|
|
42
|
+
export declare function richTextChangeText(pill: PillData): string;
|
|
39
43
|
export declare function getChangePills(row: AuditRow, config: AuditCellConfig): PillData[];
|
|
40
44
|
export declare function ChangePill({ pill }: {
|
|
41
45
|
pill: PillData;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuditTimeline.d.ts","sourceRoot":"","sources":["../../../src/components/inventory/AuditTimeline.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,YAAY,EAEb,MAAM,qCAAqC,CAAC;AAK7C,MAAM,MAAM,QAAQ,GAAG,YAAY,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC;AAIrD,MAAM,WAAW,eAAe;IAC9B,sDAAsD;IACtD,KAAK,EAAE,MAAM,CAAC;IACd,sDAAsD;IACtD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,wDAAwD;IACxD,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gEAAgE;IAChE,mBAAmB,CAAC,EAAE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AE,eAAe,CAAC;CACzB,2CAiCA;AAED,wBAAgB,sBAAsB,CAAC,EAAE,KAAS,EAAE,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,2CA2BvE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuditHistoryTimeline.d.ts","sourceRoot":"","sources":["../../../../src/components/organisms/AuditHistoryPanel/AuditHistoryTimeline.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAEhC,OAAO,
|
|
1
|
+
{"version":3,"file":"AuditHistoryTimeline.d.ts","sourceRoot":"","sources":["../../../../src/components/organisms/AuditHistoryPanel/AuditHistoryTimeline.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAEhC,OAAO,EAGL,KAAK,eAAe,EACpB,KAAK,QAAQ,EAEd,MAAM,sCAAsC,CAAC;AAkK9C,UAAU,yBAAyB;IACjC,IAAI,EAAE,QAAQ,EAAE,CAAC;IACjB,MAAM,EAAE,eAAe,CAAC;CACzB;AAED,eAAO,MAAM,oBAAoB,EAAE,EAAE,CAAC,yBAAyB,CAoD9D,CAAC;AAEF,eAAO,MAAM,2BAA2B,EAAE,EAAE,CAAC;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAW9D,CAAC"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -70289,6 +70289,12 @@ function formatPrimitive(val) {
|
|
|
70289
70289
|
}
|
|
70290
70290
|
return null;
|
|
70291
70291
|
}
|
|
70292
|
+
// Rich-text fields (from a formatting editor) are stored as HTML; the timeline names the change
|
|
70293
|
+
// without showing the value. Detected by content, since plain-text `notes` (gems, splits) still show.
|
|
70294
|
+
const HTML_TAG_RE = /<\/?[a-z][^>]*>/i;
|
|
70295
|
+
function isRichText(val) {
|
|
70296
|
+
return typeof val === 'string' && HTML_TAG_RE.test(val);
|
|
70297
|
+
}
|
|
70292
70298
|
const MEDIA_KEYS = new Set(['urls', 'keys']);
|
|
70293
70299
|
const INTERNAL_KEYS = new Set(['createdAt', 'updatedAt', '__v']);
|
|
70294
70300
|
function mediaCount(v, singular, plural) {
|
|
@@ -70317,6 +70323,10 @@ function flattenRecord(obj, prefix = '') {
|
|
|
70317
70323
|
if (INTERNAL_KEYS.has(k))
|
|
70318
70324
|
continue;
|
|
70319
70325
|
const label = prefix ? `${prefix} › ${toLabel(k)}` : toLabel(k);
|
|
70326
|
+
if (isRichText(v)) {
|
|
70327
|
+
result.push({ label, value: '', richText: true });
|
|
70328
|
+
continue;
|
|
70329
|
+
}
|
|
70320
70330
|
if ((k === 'images' || k === 'videos') &&
|
|
70321
70331
|
typeof v === 'object' &&
|
|
70322
70332
|
!Array.isArray(v)) {
|
|
@@ -70474,8 +70484,13 @@ function generateTitle(row, config) {
|
|
|
70474
70484
|
if (productItemsLabel)
|
|
70475
70485
|
return `${name} updated ${labels.length} fields and product ${productItemsLabel}`;
|
|
70476
70486
|
const first = labels[0];
|
|
70477
|
-
const
|
|
70478
|
-
const
|
|
70487
|
+
const newEntry = newEntries.find((e) => e.label === first);
|
|
70488
|
+
const newVal = newEntry?.value;
|
|
70489
|
+
const oldEntry = oldEntries.find((e) => e.label === first);
|
|
70490
|
+
const hasOld = !!oldEntry;
|
|
70491
|
+
const richChange = richTextChange(oldEntry, newEntry);
|
|
70492
|
+
if (totalCount === 1 && richChange)
|
|
70493
|
+
return `${name} ${richChange} ${first}`;
|
|
70479
70494
|
if (totalCount === 1)
|
|
70480
70495
|
return hasOld
|
|
70481
70496
|
? `${name} updated ${first} to ${newVal ?? '—'}`
|
|
@@ -70589,14 +70604,25 @@ function generateActorAction(row, config) {
|
|
|
70589
70604
|
return `performed ${row.action}`;
|
|
70590
70605
|
}
|
|
70591
70606
|
}
|
|
70607
|
+
/** "Customer Notes were updated" / "Description was added". */
|
|
70608
|
+
function richTextChangeText(pill) {
|
|
70609
|
+
const verb = /s$/i.test(pill.label) ? 'were' : 'was';
|
|
70610
|
+
return `${pill.label} ${verb} ${pill.changeNote}`;
|
|
70611
|
+
}
|
|
70612
|
+
function richTextChange(oldEntry, newEntry) {
|
|
70613
|
+
if (!oldEntry?.richText && !newEntry?.richText)
|
|
70614
|
+
return undefined;
|
|
70615
|
+
if (oldEntry && newEntry)
|
|
70616
|
+
return 'updated';
|
|
70617
|
+
return newEntry ? 'added' : 'removed';
|
|
70618
|
+
}
|
|
70592
70619
|
function getChangePills(row, config) {
|
|
70593
70620
|
const oldV = row.oldValue;
|
|
70594
70621
|
const newV = row.newValue;
|
|
70595
70622
|
if (row.action === 'CREATE') {
|
|
70596
|
-
return (newV ? flattenRecord(newV) : []).map((e) =>
|
|
70597
|
-
label: e.label,
|
|
70598
|
-
newVal: e.value
|
|
70599
|
-
}));
|
|
70623
|
+
return (newV ? flattenRecord(newV) : []).map((e) => e.richText
|
|
70624
|
+
? { label: e.label, changeNote: 'added' }
|
|
70625
|
+
: { label: e.label, newVal: e.value });
|
|
70600
70626
|
}
|
|
70601
70627
|
if (row.action === 'UPDATE') {
|
|
70602
70628
|
const pills = [];
|
|
@@ -70621,13 +70647,14 @@ function getChangePills(row, config) {
|
|
|
70621
70647
|
...newEntries.map((e) => e.label),
|
|
70622
70648
|
]),
|
|
70623
70649
|
];
|
|
70624
|
-
const oldMap = Object.fromEntries(oldEntries.map((e) => [e.label, e
|
|
70625
|
-
const newMap = Object.fromEntries(newEntries.map((e) => [e.label, e
|
|
70626
|
-
pills.push(...labels.map((label) =>
|
|
70627
|
-
label,
|
|
70628
|
-
|
|
70629
|
-
|
|
70630
|
-
|
|
70650
|
+
const oldMap = Object.fromEntries(oldEntries.map((e) => [e.label, e]));
|
|
70651
|
+
const newMap = Object.fromEntries(newEntries.map((e) => [e.label, e]));
|
|
70652
|
+
pills.push(...labels.map((label) => {
|
|
70653
|
+
const changeNote = richTextChange(oldMap[label], newMap[label]);
|
|
70654
|
+
return changeNote
|
|
70655
|
+
? { label, changeNote }
|
|
70656
|
+
: { label, oldVal: oldMap[label]?.value, newVal: newMap[label]?.value };
|
|
70657
|
+
}));
|
|
70631
70658
|
// Handle structured productItems: added / removed / updated
|
|
70632
70659
|
if (hasStructuredItems) {
|
|
70633
70660
|
const structured = newProductItems;
|
|
@@ -70771,10 +70798,13 @@ function getEntryNotes(row, config) {
|
|
|
70771
70798
|
row.oldValue?.notes ??
|
|
70772
70799
|
newV?.notes ??
|
|
70773
70800
|
mergeParent?.notes;
|
|
70774
|
-
return notes
|
|
70801
|
+
return notes && !isRichText(notes) ? notes : undefined;
|
|
70775
70802
|
}
|
|
70776
70803
|
// ─── ChangePill ───────────────────────────────────────────────────────────────
|
|
70777
70804
|
function ChangePill({ pill }) {
|
|
70805
|
+
if (pill.changeNote) {
|
|
70806
|
+
return (jsxRuntime.jsx("span", { className: "inline-flex items-center gap-1 px-2 py-0.5 rounded text-xs border border-border bg-muted text-foreground", children: richTextChangeText(pill) }));
|
|
70807
|
+
}
|
|
70778
70808
|
const isRemoved = pill.variant === 'removed';
|
|
70779
70809
|
const isAdded = pill.variant === 'added';
|
|
70780
70810
|
const isDiff = !isRemoved &&
|
|
@@ -70928,6 +70958,9 @@ const PillContent = ({ pill }) => {
|
|
|
70928
70958
|
const hasBreadcrumb = labelParts.length > 1;
|
|
70929
70959
|
const showArrow = pill.oldVal !== undefined && pill.newVal !== undefined;
|
|
70930
70960
|
const hasOnlyNew = pill.newVal !== undefined && pill.oldVal === undefined;
|
|
70961
|
+
if (pill.changeNote) {
|
|
70962
|
+
return jsxRuntime.jsx("span", { className: "text-foreground", children: richTextChangeText(pill) });
|
|
70963
|
+
}
|
|
70931
70964
|
if (pill.variant === 'added') {
|
|
70932
70965
|
return jsxRuntime.jsxs("span", { className: "font-semibold text-primary", children: ["+ ", pill.label] });
|
|
70933
70966
|
}
|
|
@@ -80109,6 +80142,7 @@ exports.renderBadge = renderBadge;
|
|
|
80109
80142
|
exports.resolveCountryCode = resolveCountryCode;
|
|
80110
80143
|
exports.resolveDatePreset = resolveDatePreset;
|
|
80111
80144
|
exports.resolveDateRange = resolveDateRange;
|
|
80145
|
+
exports.richTextChangeText = richTextChangeText;
|
|
80112
80146
|
exports.splitIdList = splitIdList;
|
|
80113
80147
|
exports.toAddressFormValues = toAddressFormValues;
|
|
80114
80148
|
exports.toBoolValue = toBoolValue;
|