@plasmicpkgs/plasmic-rich-components 1.0.103 → 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.
package/dist/index.js
CHANGED
|
@@ -2093,6 +2093,10 @@ const listCss = `
|
|
|
2093
2093
|
padding-right: 8px;
|
|
2094
2094
|
}
|
|
2095
2095
|
|
|
2096
|
+
.ant-list .plasmic-list-item {
|
|
2097
|
+
align-items: stretch;
|
|
2098
|
+
}
|
|
2099
|
+
|
|
2096
2100
|
.plasmic-list-item--clickable:hover {
|
|
2097
2101
|
background-color: #8881;
|
|
2098
2102
|
}
|
|
@@ -2142,7 +2146,7 @@ function RichList(props) {
|
|
|
2142
2146
|
pageSize = 10,
|
|
2143
2147
|
hideSearch,
|
|
2144
2148
|
rowKey,
|
|
2145
|
-
pagination,
|
|
2149
|
+
pagination = true,
|
|
2146
2150
|
onRowClick
|
|
2147
2151
|
} = _a; __objRest(_a, [
|
|
2148
2152
|
"data",
|
|
@@ -2252,7 +2256,7 @@ function RichList(props) {
|
|
|
2252
2256
|
var _a3;
|
|
2253
2257
|
return (_a3 = linkWrapper == null ? void 0 : linkWrapper(x)) != null ? _a3 : x;
|
|
2254
2258
|
}
|
|
2255
|
-
return type === "grid" ? /* @__PURE__ */ React__default.default.createElement(antd.List.Item,
|
|
2259
|
+
return type === "grid" ? /* @__PURE__ */ React__default.default.createElement(antd.List.Item, { className: "plasmic-list-item" }, maybeLink(
|
|
2256
2260
|
/* @__PURE__ */ React__default.default.createElement(
|
|
2257
2261
|
antd.Card,
|
|
2258
2262
|
{
|
|
@@ -2270,6 +2274,7 @@ function RichList(props) {
|
|
|
2270
2274
|
{
|
|
2271
2275
|
actions,
|
|
2272
2276
|
className: classNames__default.default({
|
|
2277
|
+
"plasmic-list-item": true,
|
|
2273
2278
|
"plasmic-list-item--clickable": hasLink
|
|
2274
2279
|
})
|
|
2275
2280
|
},
|
|
@@ -2363,7 +2368,7 @@ function useRoleDefinitions(data, props) {
|
|
|
2363
2368
|
const schema = data == null ? void 0 : data.schema;
|
|
2364
2369
|
const schemaMap = new Map((_a = data == null ? void 0 : data.schema) == null ? void 0 : _a.fields.map((f) => [f.id, f]));
|
|
2365
2370
|
if (!data || !schema) {
|
|
2366
|
-
return { normalized: [],
|
|
2371
|
+
return { normalized: [], finalRoles: {} };
|
|
2367
2372
|
}
|
|
2368
2373
|
function tagFieldConfigs(role) {
|
|
2369
2374
|
var _a2;
|
|
@@ -2377,27 +2382,33 @@ function useRoleDefinitions(data, props) {
|
|
|
2377
2382
|
return [];
|
|
2378
2383
|
}
|
|
2379
2384
|
}
|
|
2380
|
-
const
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2385
|
+
const specifiedFieldsPartial = [
|
|
2386
|
+
...tagFieldConfigs("image"),
|
|
2387
|
+
...tagFieldConfigs("content"),
|
|
2388
|
+
...tagFieldConfigs("title"),
|
|
2389
|
+
...tagFieldConfigs("beforeTitle"),
|
|
2390
|
+
...tagFieldConfigs("afterTitle"),
|
|
2391
|
+
...tagFieldConfigs("subtitle")
|
|
2392
|
+
];
|
|
2393
|
+
function doDeriveFieldConfigs(mode) {
|
|
2394
|
+
return dataSources.deriveFieldConfigs(
|
|
2395
|
+
mode === "defaults" ? [] : specifiedFieldsPartial,
|
|
2396
|
+
schema,
|
|
2397
|
+
(field) => __spreadValues$1(__spreadValues$1({}, defaultColumnConfig()), field && {
|
|
2398
|
+
key: field.id,
|
|
2399
|
+
fieldId: field.id,
|
|
2400
|
+
title: field.label || field.id,
|
|
2401
|
+
// undefined means not yet determined in this routine, not 'unset'
|
|
2402
|
+
role: void 0,
|
|
2403
|
+
expr: (currentItem) => currentItem[field.id]
|
|
2404
|
+
})
|
|
2405
|
+
);
|
|
2406
|
+
}
|
|
2407
|
+
const {
|
|
2408
|
+
mergedFields: defaultMergedFields,
|
|
2409
|
+
minimalFullLengthFields: defaultMinimalFullLengthFields
|
|
2410
|
+
} = doDeriveFieldConfigs("defaults");
|
|
2411
|
+
if (data.data.length > 0 && !defaultMergedFields.some((field) => field.role === "image")) {
|
|
2401
2412
|
const sampleRows = Array.from(
|
|
2402
2413
|
new Set(
|
|
2403
2414
|
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9].map(
|
|
@@ -2405,7 +2416,7 @@ function useRoleDefinitions(data, props) {
|
|
|
2405
2416
|
)
|
|
2406
2417
|
)
|
|
2407
2418
|
).map((i) => data.data[i]);
|
|
2408
|
-
const imageFieldCandidates =
|
|
2419
|
+
const imageFieldCandidates = defaultMergedFields.filter(
|
|
2409
2420
|
(field) => !field.role && sampleRows.filter(
|
|
2410
2421
|
(row) => field.fieldId && isLikeImage(row[field.fieldId])
|
|
2411
2422
|
).length >= sampleRows.length / 2
|
|
@@ -2429,8 +2440,8 @@ function useRoleDefinitions(data, props) {
|
|
|
2429
2440
|
imageField.role = "image";
|
|
2430
2441
|
}
|
|
2431
2442
|
}
|
|
2432
|
-
if (!
|
|
2433
|
-
const titleField =
|
|
2443
|
+
if (!defaultMergedFields.some((field) => field.role === "title")) {
|
|
2444
|
+
const titleField = defaultMergedFields.find(
|
|
2434
2445
|
(field) => {
|
|
2435
2446
|
var _a2;
|
|
2436
2447
|
return !field.role && ((_a2 = field.fieldId) == null ? void 0 : _a2.toLowerCase().match(/^(title|name|first[ _-]?name|full[ _-]?name)$/));
|
|
@@ -2440,8 +2451,8 @@ function useRoleDefinitions(data, props) {
|
|
|
2440
2451
|
titleField.role = "title";
|
|
2441
2452
|
}
|
|
2442
2453
|
}
|
|
2443
|
-
if (!
|
|
2444
|
-
const contentField =
|
|
2454
|
+
if (!defaultMergedFields.some((field) => field.role === "content")) {
|
|
2455
|
+
const contentField = defaultMergedFields.find(
|
|
2445
2456
|
(field) => {
|
|
2446
2457
|
var _a2;
|
|
2447
2458
|
return !field.role && field.fieldId && ((_a2 = schemaMap.get(field.fieldId)) == null ? void 0 : _a2.type) === "string";
|
|
@@ -2451,19 +2462,49 @@ function useRoleDefinitions(data, props) {
|
|
|
2451
2462
|
contentField.role = "content";
|
|
2452
2463
|
}
|
|
2453
2464
|
}
|
|
2454
|
-
const
|
|
2465
|
+
const fieldIdToDefaultRole = new Map(
|
|
2466
|
+
defaultMergedFields.map((f) => [f.fieldId, f.role])
|
|
2467
|
+
);
|
|
2468
|
+
for (const f of defaultMinimalFullLengthFields) {
|
|
2469
|
+
f.role = fieldIdToDefaultRole.get(f.fieldId);
|
|
2470
|
+
}
|
|
2471
|
+
const { mergedFields, minimalFullLengthFields } = doDeriveFieldConfigs("existing");
|
|
2472
|
+
const minimalFullLengthFieldsWithDefaults = [
|
|
2473
|
+
...minimalFullLengthFields.filter((f) => f.role && f.role !== "unset"),
|
|
2474
|
+
...defaultMinimalFullLengthFields.filter(
|
|
2475
|
+
(f) => f.role && f.role !== "unset" && !props[f.role]
|
|
2476
|
+
)
|
|
2477
|
+
];
|
|
2478
|
+
const mergedFieldsWithDefaults = [
|
|
2479
|
+
...mergedFields.filter((f) => f.role && f.role !== "unset"),
|
|
2480
|
+
...defaultMergedFields.filter(
|
|
2481
|
+
(f) => f.role && f.role !== "unset" && !props[f.role]
|
|
2482
|
+
)
|
|
2483
|
+
];
|
|
2484
|
+
console.log("!!derived", {
|
|
2485
|
+
minimalFullLengthFieldsWithDefaults,
|
|
2486
|
+
minimalFullLengthFields,
|
|
2487
|
+
defaultMinimalFullLengthFields,
|
|
2488
|
+
mergedFieldsWithDefaults,
|
|
2489
|
+
mergedFields,
|
|
2490
|
+
defaultMergedFields,
|
|
2491
|
+
props
|
|
2492
|
+
});
|
|
2493
|
+
const roleConfigs = ensure(
|
|
2494
|
+
groupBy__default.default(mergedFieldsWithDefaults, (f) => f.role)
|
|
2495
|
+
);
|
|
2455
2496
|
const finalRoles = {};
|
|
2456
2497
|
for (const role of roles) {
|
|
2457
2498
|
if (role !== "unset") {
|
|
2458
2499
|
finalRoles[role] = (_d = maybe(props[role], ensureArray)) != null ? _d : roleConfigs[role];
|
|
2459
2500
|
}
|
|
2460
2501
|
}
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
}
|
|
2465
|
-
|
|
2466
|
-
return { normalized,
|
|
2502
|
+
setControlContextData == null ? void 0 : setControlContextData(__spreadProps(__spreadValues$1({}, data), {
|
|
2503
|
+
mergedFields: mergedFieldsWithDefaults,
|
|
2504
|
+
minimalFullLengthFields: minimalFullLengthFieldsWithDefaults
|
|
2505
|
+
}));
|
|
2506
|
+
const normalized = mergedFieldsWithDefaults;
|
|
2507
|
+
return { normalized, finalRoles };
|
|
2467
2508
|
}, [fields, data, setControlContextData, rowActions]);
|
|
2468
2509
|
}
|
|
2469
2510
|
|
|
@@ -2529,11 +2570,6 @@ const richListMeta = {
|
|
|
2529
2570
|
padding: "16px",
|
|
2530
2571
|
maxHeight: "100%"
|
|
2531
2572
|
},
|
|
2532
|
-
templates: {
|
|
2533
|
-
grid: {
|
|
2534
|
-
props: {}
|
|
2535
|
-
}
|
|
2536
|
-
},
|
|
2537
2573
|
props: __spreadValues({
|
|
2538
2574
|
data: dataProp(),
|
|
2539
2575
|
type: {
|