@plasmicpkgs/plasmic-rich-components 1.0.51 → 1.0.52
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/field-mappings.d.ts +1 -3
- package/dist/plasmic-rich-components.cjs.development.js +52 -63
- package/dist/plasmic-rich-components.cjs.development.js.map +1 -1
- package/dist/plasmic-rich-components.cjs.production.min.js +1 -1
- package/dist/plasmic-rich-components.cjs.production.min.js.map +1 -1
- package/dist/plasmic-rich-components.esm.js +53 -64
- package/dist/plasmic-rich-components.esm.js.map +1 -1
- package/package.json +4 -4
package/dist/field-mappings.d.ts
CHANGED
|
@@ -43,9 +43,7 @@ export declare type ColumnConfig = {
|
|
|
43
43
|
isHidden: boolean;
|
|
44
44
|
formatting: StyleConfig;
|
|
45
45
|
} & (AutoSettings | NumberSettings | StringSettings | BooleanSettings);
|
|
46
|
-
export declare type PartialColumnConfig =
|
|
47
|
-
key: string;
|
|
48
|
-
};
|
|
46
|
+
export declare type PartialColumnConfig = Partial<ColumnConfig>;
|
|
49
47
|
export declare function deriveFieldConfigs(specifiedFieldsPartial: PartialColumnConfig[], schema: TableSchema | undefined): {
|
|
50
48
|
mergedFields: ColumnConfig[];
|
|
51
49
|
minimalFullLengthFields: PartialColumnConfig[];
|
|
@@ -71,37 +71,6 @@ function _objectWithoutPropertiesLoose(source, excluded) {
|
|
|
71
71
|
}
|
|
72
72
|
return target;
|
|
73
73
|
}
|
|
74
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
75
|
-
if (!o) return;
|
|
76
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
77
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
78
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
79
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
80
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
81
|
-
}
|
|
82
|
-
function _arrayLikeToArray(arr, len) {
|
|
83
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
84
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
85
|
-
return arr2;
|
|
86
|
-
}
|
|
87
|
-
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
88
|
-
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
89
|
-
if (it) return (it = it.call(o)).next.bind(it);
|
|
90
|
-
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
91
|
-
if (it) o = it;
|
|
92
|
-
var i = 0;
|
|
93
|
-
return function () {
|
|
94
|
-
if (i >= o.length) return {
|
|
95
|
-
done: true
|
|
96
|
-
};
|
|
97
|
-
return {
|
|
98
|
-
done: false,
|
|
99
|
-
value: o[i++]
|
|
100
|
-
};
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
104
|
-
}
|
|
105
74
|
|
|
106
75
|
function useIsClient() {
|
|
107
76
|
var _useState = React.useState(false),
|
|
@@ -1097,14 +1066,6 @@ var defaultColumnConfig = function defaultColumnConfig() {
|
|
|
1097
1066
|
};
|
|
1098
1067
|
function deriveFieldConfigs(specifiedFieldsPartial, schema) {
|
|
1099
1068
|
var _schema$fields;
|
|
1100
|
-
// Ugly: when adding a new item to an array from Plasmic Studio UI, no way to specify default values for the new item,
|
|
1101
|
-
// so we have to do it here. The only one we need is the random key.
|
|
1102
|
-
for (var _iterator = _createForOfIteratorHelperLoose(specifiedFieldsPartial), _step; !(_step = _iterator()).done;) {
|
|
1103
|
-
var field = _step.value;
|
|
1104
|
-
if (!field.key) {
|
|
1105
|
-
field.key = mkShortId();
|
|
1106
|
-
}
|
|
1107
|
-
}
|
|
1108
1069
|
var schemaFields = (_schema$fields = schema == null ? void 0 : schema.fields) != null ? _schema$fields : [];
|
|
1109
1070
|
var fieldById = mkIdMap(schemaFields);
|
|
1110
1071
|
var specifiedFieldIds = new Set(withoutNils(specifiedFieldsPartial.map(function (f) {
|
|
@@ -1112,6 +1073,7 @@ function deriveFieldConfigs(specifiedFieldsPartial, schema) {
|
|
|
1112
1073
|
})));
|
|
1113
1074
|
function defaultColumnConfigForField(field) {
|
|
1114
1075
|
return _extends({}, defaultColumnConfig(), {
|
|
1076
|
+
key: field.id,
|
|
1115
1077
|
fieldId: field.id,
|
|
1116
1078
|
title: field.label || field.id,
|
|
1117
1079
|
expr: function expr(currentItem) {
|
|
@@ -1119,10 +1081,12 @@ function deriveFieldConfigs(specifiedFieldsPartial, schema) {
|
|
|
1119
1081
|
}
|
|
1120
1082
|
});
|
|
1121
1083
|
}
|
|
1122
|
-
var keptSpecifiedFields = specifiedFieldsPartial.flatMap(function (f) {
|
|
1084
|
+
var keptSpecifiedFields = specifiedFieldsPartial.flatMap(function (f, index) {
|
|
1123
1085
|
var fieldId = f.fieldId;
|
|
1124
1086
|
if (!fieldId) {
|
|
1125
|
-
return [_extends({}, defaultColumnConfig(),
|
|
1087
|
+
return [_extends({}, defaultColumnConfig(), {
|
|
1088
|
+
key: index
|
|
1089
|
+
}, f)];
|
|
1126
1090
|
}
|
|
1127
1091
|
var field = fieldById.get(fieldId);
|
|
1128
1092
|
// Drop configs with fieldIds no longer in the data.
|
|
@@ -1223,7 +1187,6 @@ function safeRender(x) {
|
|
|
1223
1187
|
return x === undefined || x === null ? "" : typeof x === "string" ? x : typeof x === "number" ? x.toString() : JSON.stringify(x);
|
|
1224
1188
|
}
|
|
1225
1189
|
function RichTable(props) {
|
|
1226
|
-
var _data$data;
|
|
1227
1190
|
var className = props.className,
|
|
1228
1191
|
_props$data = props.data,
|
|
1229
1192
|
rawData = _props$data === void 0 ? {
|
|
@@ -1237,6 +1200,8 @@ function RichTable(props) {
|
|
|
1237
1200
|
}]
|
|
1238
1201
|
}
|
|
1239
1202
|
} : _props$data,
|
|
1203
|
+
_props$pagination = props.pagination,
|
|
1204
|
+
pagination = _props$pagination === void 0 ? true : _props$pagination,
|
|
1240
1205
|
defaultSize = props.defaultSize,
|
|
1241
1206
|
fields = props.fields,
|
|
1242
1207
|
setControlContextData = props.setControlContextData,
|
|
@@ -1356,31 +1321,55 @@ function RichTable(props) {
|
|
|
1356
1321
|
normalized: normalized,
|
|
1357
1322
|
columnDefinitions: columnDefinitions
|
|
1358
1323
|
};
|
|
1359
|
-
}, [fields, data, setControlContextData
|
|
1360
|
-
columnDefinitions = _React$useMemo.columnDefinitions
|
|
1324
|
+
}, [fields, data, setControlContextData]),
|
|
1325
|
+
columnDefinitions = _React$useMemo.columnDefinitions,
|
|
1326
|
+
normalized = _React$useMemo.normalized;
|
|
1361
1327
|
var actionRef = React.useRef();
|
|
1328
|
+
var _useState2 = React.useState(undefined),
|
|
1329
|
+
state = _useState2[0],
|
|
1330
|
+
setState = _useState2[1];
|
|
1331
|
+
var finalData = React.useMemo(function () {
|
|
1332
|
+
var _data$data;
|
|
1333
|
+
var filtered = data == null ? void 0 : (_data$data = data.data) == null ? void 0 : _data$data.filter(function (row) {
|
|
1334
|
+
return fastStringify(Object.values(row)).toLowerCase().includes(search);
|
|
1335
|
+
});
|
|
1336
|
+
var sorted = state != null && state.sorter.column ?
|
|
1337
|
+
// We use .sort() rather than sortBy to use localeCompare
|
|
1338
|
+
function () {
|
|
1339
|
+
var _normalized$find$expr;
|
|
1340
|
+
var expr = (_normalized$find$expr = normalized.find(function (cconfig) {
|
|
1341
|
+
var _state$sorter$column;
|
|
1342
|
+
return cconfig.key === (state == null ? void 0 : (_state$sorter$column = state.sorter.column) == null ? void 0 : _state$sorter$column.key);
|
|
1343
|
+
}).expr) != null ? _normalized$find$expr : function (x) {
|
|
1344
|
+
return x;
|
|
1345
|
+
};
|
|
1346
|
+
return (filtered != null ? filtered : []).sort(function (aa, bb) {
|
|
1347
|
+
var _expr, _expr2;
|
|
1348
|
+
var a = (_expr = expr(aa)) != null ? _expr : null,
|
|
1349
|
+
b = (_expr2 = expr(bb)) != null ? _expr2 : null;
|
|
1350
|
+
// Default nil to '' here because A < null < z which is weird.
|
|
1351
|
+
return typeof a === "string" ? a.localeCompare(b != null ? b : "") : typeof b === "string" ? -b.localeCompare(a != null ? a : "") : a - b;
|
|
1352
|
+
});
|
|
1353
|
+
}() : filtered;
|
|
1354
|
+
var reversed = (state == null ? void 0 : state.sorter.order) === "descend" ? sorted == null ? void 0 : sorted.reverse() : sorted;
|
|
1355
|
+
return reversed;
|
|
1356
|
+
}, [data, normalized, state, search]);
|
|
1362
1357
|
var isClient = useIsClient();
|
|
1363
1358
|
if (!isClient) {
|
|
1364
1359
|
return null;
|
|
1365
1360
|
}
|
|
1366
|
-
// return <NestedTest {...{ fields }} />;
|
|
1367
1361
|
return React__default.createElement(React__default.Fragment, null, React__default.createElement(proComponents.ProTable, {
|
|
1368
1362
|
actionRef: actionRef,
|
|
1369
1363
|
className: className,
|
|
1370
1364
|
columns: columnDefinitions,
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1365
|
+
onChange: function onChange(_pagination, _filters, sorter, _extra) {
|
|
1366
|
+
setState({
|
|
1367
|
+
sorter: sorter
|
|
1368
|
+
});
|
|
1369
|
+
},
|
|
1370
|
+
dataSource: finalData,
|
|
1374
1371
|
rowKey: "id",
|
|
1375
1372
|
defaultSize: defaultSize,
|
|
1376
|
-
// request={() =>
|
|
1377
|
-
// Promise.resolve({
|
|
1378
|
-
// data: data?.data?.filter((row) =>
|
|
1379
|
-
// fastStringify(row).toLowerCase().includes(search)
|
|
1380
|
-
// ),
|
|
1381
|
-
// success: true,
|
|
1382
|
-
// })
|
|
1383
|
-
// }
|
|
1384
1373
|
editable: {
|
|
1385
1374
|
type: "multiple"
|
|
1386
1375
|
},
|
|
@@ -1392,12 +1381,12 @@ function RichTable(props) {
|
|
|
1392
1381
|
reload: false,
|
|
1393
1382
|
density: !hideDensity
|
|
1394
1383
|
},
|
|
1395
|
-
pagination: {
|
|
1384
|
+
pagination: pagination ? {
|
|
1396
1385
|
pageSize: pageSize,
|
|
1397
1386
|
onChange: function onChange(page) {
|
|
1398
1387
|
return console.log(page);
|
|
1399
1388
|
}
|
|
1400
|
-
},
|
|
1389
|
+
} : false,
|
|
1401
1390
|
dateFormatter: "string",
|
|
1402
1391
|
headerTitle: title,
|
|
1403
1392
|
toolbar: {
|
|
@@ -1531,11 +1520,6 @@ var dataTableMeta = {
|
|
|
1531
1520
|
options: ["large", "middle", "small"],
|
|
1532
1521
|
defaultValueHint: "large"
|
|
1533
1522
|
},
|
|
1534
|
-
// TODO
|
|
1535
|
-
// pagination: {
|
|
1536
|
-
// type: "boolean",
|
|
1537
|
-
// defaultValueHint: true,
|
|
1538
|
-
// },
|
|
1539
1523
|
pageSize: {
|
|
1540
1524
|
type: "number",
|
|
1541
1525
|
defaultValueHint: 20
|
|
@@ -1615,6 +1599,11 @@ var dataTableMeta = {
|
|
|
1615
1599
|
}
|
|
1616
1600
|
}
|
|
1617
1601
|
},
|
|
1602
|
+
pagination: {
|
|
1603
|
+
type: "boolean",
|
|
1604
|
+
advanced: true,
|
|
1605
|
+
defaultValueHint: true
|
|
1606
|
+
},
|
|
1618
1607
|
hideSearch: {
|
|
1619
1608
|
type: "boolean",
|
|
1620
1609
|
advanced: true
|