@plasmicpkgs/plasmic-rich-components 1.0.102 → 1.0.104
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.
|
@@ -2083,6 +2083,10 @@ const listCss = `
|
|
|
2083
2083
|
padding-right: 8px;
|
|
2084
2084
|
}
|
|
2085
2085
|
|
|
2086
|
+
.ant-list .plasmic-list-item {
|
|
2087
|
+
align-items: stretch;
|
|
2088
|
+
}
|
|
2089
|
+
|
|
2086
2090
|
.plasmic-list-item--clickable:hover {
|
|
2087
2091
|
background-color: #8881;
|
|
2088
2092
|
}
|
|
@@ -2132,7 +2136,7 @@ function RichList(props) {
|
|
|
2132
2136
|
pageSize = 10,
|
|
2133
2137
|
hideSearch,
|
|
2134
2138
|
rowKey,
|
|
2135
|
-
pagination,
|
|
2139
|
+
pagination = true,
|
|
2136
2140
|
onRowClick
|
|
2137
2141
|
} = _a; __objRest(_a, [
|
|
2138
2142
|
"data",
|
|
@@ -2242,7 +2246,7 @@ function RichList(props) {
|
|
|
2242
2246
|
var _a3;
|
|
2243
2247
|
return (_a3 = linkWrapper == null ? void 0 : linkWrapper(x)) != null ? _a3 : x;
|
|
2244
2248
|
}
|
|
2245
|
-
return type === "grid" ? /* @__PURE__ */ React.createElement(List.Item,
|
|
2249
|
+
return type === "grid" ? /* @__PURE__ */ React.createElement(List.Item, { className: "plasmic-list-item" }, maybeLink(
|
|
2246
2250
|
/* @__PURE__ */ React.createElement(
|
|
2247
2251
|
Card,
|
|
2248
2252
|
{
|
|
@@ -2260,6 +2264,7 @@ function RichList(props) {
|
|
|
2260
2264
|
{
|
|
2261
2265
|
actions,
|
|
2262
2266
|
className: classNames({
|
|
2267
|
+
"plasmic-list-item": true,
|
|
2263
2268
|
"plasmic-list-item--clickable": hasLink
|
|
2264
2269
|
})
|
|
2265
2270
|
},
|
|
@@ -2353,7 +2358,7 @@ function useRoleDefinitions(data, props) {
|
|
|
2353
2358
|
const schema = data == null ? void 0 : data.schema;
|
|
2354
2359
|
const schemaMap = new Map((_a = data == null ? void 0 : data.schema) == null ? void 0 : _a.fields.map((f) => [f.id, f]));
|
|
2355
2360
|
if (!data || !schema) {
|
|
2356
|
-
return { normalized: [],
|
|
2361
|
+
return { normalized: [], finalRoles: {} };
|
|
2357
2362
|
}
|
|
2358
2363
|
function tagFieldConfigs(role) {
|
|
2359
2364
|
var _a2;
|
|
@@ -2367,27 +2372,33 @@ function useRoleDefinitions(data, props) {
|
|
|
2367
2372
|
return [];
|
|
2368
2373
|
}
|
|
2369
2374
|
}
|
|
2370
|
-
const
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2375
|
+
const specifiedFieldsPartial = [
|
|
2376
|
+
...tagFieldConfigs("image"),
|
|
2377
|
+
...tagFieldConfigs("content"),
|
|
2378
|
+
...tagFieldConfigs("title"),
|
|
2379
|
+
...tagFieldConfigs("beforeTitle"),
|
|
2380
|
+
...tagFieldConfigs("afterTitle"),
|
|
2381
|
+
...tagFieldConfigs("subtitle")
|
|
2382
|
+
];
|
|
2383
|
+
function doDeriveFieldConfigs(mode) {
|
|
2384
|
+
return deriveFieldConfigs(
|
|
2385
|
+
mode === "defaults" ? [] : specifiedFieldsPartial,
|
|
2386
|
+
schema,
|
|
2387
|
+
(field) => __spreadValues$1(__spreadValues$1({}, defaultColumnConfig()), field && {
|
|
2388
|
+
key: field.id,
|
|
2389
|
+
fieldId: field.id,
|
|
2390
|
+
title: field.label || field.id,
|
|
2391
|
+
// undefined means not yet determined in this routine, not 'unset'
|
|
2392
|
+
role: void 0,
|
|
2393
|
+
expr: (currentItem) => currentItem[field.id]
|
|
2394
|
+
})
|
|
2395
|
+
);
|
|
2396
|
+
}
|
|
2397
|
+
const {
|
|
2398
|
+
mergedFields: defaultMergedFields,
|
|
2399
|
+
minimalFullLengthFields: defaultMinimalFullLengthFields
|
|
2400
|
+
} = doDeriveFieldConfigs("defaults");
|
|
2401
|
+
if (data.data.length > 0 && !defaultMergedFields.some((field) => field.role === "image")) {
|
|
2391
2402
|
const sampleRows = Array.from(
|
|
2392
2403
|
new Set(
|
|
2393
2404
|
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9].map(
|
|
@@ -2395,7 +2406,7 @@ function useRoleDefinitions(data, props) {
|
|
|
2395
2406
|
)
|
|
2396
2407
|
)
|
|
2397
2408
|
).map((i) => data.data[i]);
|
|
2398
|
-
const imageFieldCandidates =
|
|
2409
|
+
const imageFieldCandidates = defaultMergedFields.filter(
|
|
2399
2410
|
(field) => !field.role && sampleRows.filter(
|
|
2400
2411
|
(row) => field.fieldId && isLikeImage(row[field.fieldId])
|
|
2401
2412
|
).length >= sampleRows.length / 2
|
|
@@ -2419,8 +2430,8 @@ function useRoleDefinitions(data, props) {
|
|
|
2419
2430
|
imageField.role = "image";
|
|
2420
2431
|
}
|
|
2421
2432
|
}
|
|
2422
|
-
if (!
|
|
2423
|
-
const titleField =
|
|
2433
|
+
if (!defaultMergedFields.some((field) => field.role === "title")) {
|
|
2434
|
+
const titleField = defaultMergedFields.find(
|
|
2424
2435
|
(field) => {
|
|
2425
2436
|
var _a2;
|
|
2426
2437
|
return !field.role && ((_a2 = field.fieldId) == null ? void 0 : _a2.toLowerCase().match(/^(title|name|first[ _-]?name|full[ _-]?name)$/));
|
|
@@ -2430,8 +2441,8 @@ function useRoleDefinitions(data, props) {
|
|
|
2430
2441
|
titleField.role = "title";
|
|
2431
2442
|
}
|
|
2432
2443
|
}
|
|
2433
|
-
if (!
|
|
2434
|
-
const contentField =
|
|
2444
|
+
if (!defaultMergedFields.some((field) => field.role === "content")) {
|
|
2445
|
+
const contentField = defaultMergedFields.find(
|
|
2435
2446
|
(field) => {
|
|
2436
2447
|
var _a2;
|
|
2437
2448
|
return !field.role && field.fieldId && ((_a2 = schemaMap.get(field.fieldId)) == null ? void 0 : _a2.type) === "string";
|
|
@@ -2441,19 +2452,49 @@ function useRoleDefinitions(data, props) {
|
|
|
2441
2452
|
contentField.role = "content";
|
|
2442
2453
|
}
|
|
2443
2454
|
}
|
|
2444
|
-
const
|
|
2455
|
+
const fieldIdToDefaultRole = new Map(
|
|
2456
|
+
defaultMergedFields.map((f) => [f.fieldId, f.role])
|
|
2457
|
+
);
|
|
2458
|
+
for (const f of defaultMinimalFullLengthFields) {
|
|
2459
|
+
f.role = fieldIdToDefaultRole.get(f.fieldId);
|
|
2460
|
+
}
|
|
2461
|
+
const { mergedFields, minimalFullLengthFields } = doDeriveFieldConfigs("existing");
|
|
2462
|
+
const minimalFullLengthFieldsWithDefaults = [
|
|
2463
|
+
...minimalFullLengthFields.filter((f) => f.role && f.role !== "unset"),
|
|
2464
|
+
...defaultMinimalFullLengthFields.filter(
|
|
2465
|
+
(f) => f.role && f.role !== "unset" && !props[f.role]
|
|
2466
|
+
)
|
|
2467
|
+
];
|
|
2468
|
+
const mergedFieldsWithDefaults = [
|
|
2469
|
+
...mergedFields.filter((f) => f.role && f.role !== "unset"),
|
|
2470
|
+
...defaultMergedFields.filter(
|
|
2471
|
+
(f) => f.role && f.role !== "unset" && !props[f.role]
|
|
2472
|
+
)
|
|
2473
|
+
];
|
|
2474
|
+
console.log("!!derived", {
|
|
2475
|
+
minimalFullLengthFieldsWithDefaults,
|
|
2476
|
+
minimalFullLengthFields,
|
|
2477
|
+
defaultMinimalFullLengthFields,
|
|
2478
|
+
mergedFieldsWithDefaults,
|
|
2479
|
+
mergedFields,
|
|
2480
|
+
defaultMergedFields,
|
|
2481
|
+
props
|
|
2482
|
+
});
|
|
2483
|
+
const roleConfigs = ensure(
|
|
2484
|
+
groupBy(mergedFieldsWithDefaults, (f) => f.role)
|
|
2485
|
+
);
|
|
2445
2486
|
const finalRoles = {};
|
|
2446
2487
|
for (const role of roles) {
|
|
2447
2488
|
if (role !== "unset") {
|
|
2448
2489
|
finalRoles[role] = (_d = maybe(props[role], ensureArray)) != null ? _d : roleConfigs[role];
|
|
2449
2490
|
}
|
|
2450
2491
|
}
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
}
|
|
2455
|
-
|
|
2456
|
-
return { normalized,
|
|
2492
|
+
setControlContextData == null ? void 0 : setControlContextData(__spreadProps(__spreadValues$1({}, data), {
|
|
2493
|
+
mergedFields: mergedFieldsWithDefaults,
|
|
2494
|
+
minimalFullLengthFields: minimalFullLengthFieldsWithDefaults
|
|
2495
|
+
}));
|
|
2496
|
+
const normalized = mergedFieldsWithDefaults;
|
|
2497
|
+
return { normalized, finalRoles };
|
|
2457
2498
|
}, [fields, data, setControlContextData, rowActions]);
|
|
2458
2499
|
}
|
|
2459
2500
|
|
|
@@ -2519,11 +2560,6 @@ const richListMeta = {
|
|
|
2519
2560
|
padding: "16px",
|
|
2520
2561
|
maxHeight: "100%"
|
|
2521
2562
|
},
|
|
2522
|
-
templates: {
|
|
2523
|
-
grid: {
|
|
2524
|
-
props: {}
|
|
2525
|
-
}
|
|
2526
|
-
},
|
|
2527
2563
|
props: __spreadValues({
|
|
2528
2564
|
data: dataProp(),
|
|
2529
2565
|
type: {
|