@plasmicpkgs/plasmic-rich-components 1.0.99 → 1.0.101
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/.tsbuildinfo +1 -0
- package/dist/index.js +2401 -1951
- package/dist/index.js.map +1 -1
- package/dist/plasmic-rich-components.esm.js +2402 -1952
- package/dist/plasmic-rich-components.esm.js.map +1 -1
- package/dist/rich-details/RichDetails.d.ts +0 -1
- package/package.json +11 -6
|
@@ -3,7 +3,7 @@ import '@plasmicapp/host/registerGlobalContext';
|
|
|
3
3
|
import 'lodash/get';
|
|
4
4
|
import React, { useState, useEffect, useRef } from 'react';
|
|
5
5
|
import { normalizeData, deriveFieldConfigs } from '@plasmicapp/data-sources';
|
|
6
|
-
import { Checkbox, Switch, Empty, Descriptions, theme, ConfigProvider, Dropdown, Button, Input, List,
|
|
6
|
+
import { Checkbox, Switch, Empty, Descriptions, theme, ConfigProvider, Dropdown, Button, Input, List, Tag, Card } from 'antd';
|
|
7
7
|
import { tinycolor } from '@ctrl/tinycolor';
|
|
8
8
|
import { LogoutOutlined, PlusOutlined, EllipsisOutlined } from '@ant-design/icons';
|
|
9
9
|
import { ProLayout, ProConfigProvider, ProTable } from '@ant-design/pro-components';
|
|
@@ -13,2122 +13,2572 @@ import fastStringify from 'fast-stringify';
|
|
|
13
13
|
import classNames from 'classnames';
|
|
14
14
|
import groupBy from 'lodash/groupBy';
|
|
15
15
|
|
|
16
|
-
/*! *****************************************************************************
|
|
17
|
-
Copyright (c) Microsoft Corporation.
|
|
18
|
-
|
|
19
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
20
|
-
purpose with or without fee is hereby granted.
|
|
21
|
-
|
|
22
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
23
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
24
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
25
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
26
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
27
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
28
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
29
|
-
***************************************************************************** */
|
|
30
|
-
|
|
31
|
-
var __assign = function() {
|
|
32
|
-
__assign = Object.assign || function __assign(t) {
|
|
33
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
34
|
-
s = arguments[i];
|
|
35
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
36
|
-
}
|
|
37
|
-
return t;
|
|
38
|
-
};
|
|
39
|
-
return __assign.apply(this, arguments);
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
function __rest(s, e) {
|
|
43
|
-
var t = {};
|
|
44
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
45
|
-
t[p] = s[p];
|
|
46
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
47
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
48
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
49
|
-
t[p[i]] = s[p[i]];
|
|
50
|
-
}
|
|
51
|
-
return t;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
55
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
56
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
57
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
58
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
59
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
60
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function __generator(thisArg, body) {
|
|
65
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
66
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
67
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
68
|
-
function step(op) {
|
|
69
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
70
|
-
while (_) try {
|
|
71
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
72
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
73
|
-
switch (op[0]) {
|
|
74
|
-
case 0: case 1: t = op; break;
|
|
75
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
76
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
77
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
78
|
-
default:
|
|
79
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
80
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
81
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
82
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
83
|
-
if (t[2]) _.ops.pop();
|
|
84
|
-
_.trys.pop(); continue;
|
|
85
|
-
}
|
|
86
|
-
op = body.call(thisArg, _);
|
|
87
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
88
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
function __spreadArray(to, from, pack) {
|
|
93
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
94
|
-
if (ar || !(i in from)) {
|
|
95
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
96
|
-
ar[i] = from[i];
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
100
|
-
}
|
|
101
|
-
|
|
102
16
|
function registerComponentHelper(loader, component, meta) {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
17
|
+
if (loader) {
|
|
18
|
+
loader.registerComponent(component, meta);
|
|
19
|
+
} else {
|
|
20
|
+
registerComponent(component, meta);
|
|
21
|
+
}
|
|
109
22
|
}
|
|
110
23
|
function ensure(x) {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
24
|
+
if (x === null || x === void 0) {
|
|
25
|
+
throw new Error("Expected non-null or non-undefined value");
|
|
26
|
+
}
|
|
27
|
+
return x;
|
|
115
28
|
}
|
|
116
29
|
function isOneOf(elem, arr) {
|
|
117
|
-
|
|
30
|
+
return arr.includes(elem);
|
|
118
31
|
}
|
|
119
32
|
function maybe(x, f) {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
33
|
+
if (x === void 0 || x === null)
|
|
34
|
+
return void 0;
|
|
35
|
+
return f(x);
|
|
123
36
|
}
|
|
124
37
|
function isLikeImage(value) {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
: false;
|
|
128
|
-
}
|
|
129
|
-
// Some heuristics to avoid selecting a row when
|
|
130
|
-
// the object clicked is interactable -- like button, anchor,
|
|
131
|
-
// input, etc. This won't be bulletproof, so just some
|
|
132
|
-
// heuristics!
|
|
38
|
+
return typeof value === "string" ? value.match(/\.(png|jpg|jpeg|gif|svg|webp|avif|ico|bmp|tiff)$/i) : false;
|
|
39
|
+
}
|
|
133
40
|
function isInteractable(target) {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
41
|
+
if (["A", "BUTTON", "INPUT", "TEXTAREA", "SELECT"].includes(target.tagName)) {
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
if (target.contentEditable === "true") {
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
return false;
|
|
141
48
|
}
|
|
142
49
|
function ensureArray(xs) {
|
|
143
|
-
|
|
50
|
+
return Array.isArray(xs) ? xs : [xs];
|
|
144
51
|
}
|
|
145
|
-
|
|
52
|
+
const mkShortId = () => `${Math.random()}`;
|
|
146
53
|
function withoutFalsey(xs) {
|
|
147
|
-
|
|
54
|
+
return xs.filter((x) => !!x);
|
|
148
55
|
}
|
|
149
56
|
|
|
150
|
-
var
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
57
|
+
var __defProp$9 = Object.defineProperty;
|
|
58
|
+
var __defProps$7 = Object.defineProperties;
|
|
59
|
+
var __getOwnPropDescs$7 = Object.getOwnPropertyDescriptors;
|
|
60
|
+
var __getOwnPropSymbols$9 = Object.getOwnPropertySymbols;
|
|
61
|
+
var __hasOwnProp$9 = Object.prototype.hasOwnProperty;
|
|
62
|
+
var __propIsEnum$9 = Object.prototype.propertyIsEnumerable;
|
|
63
|
+
var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
64
|
+
var __spreadValues$9 = (a, b) => {
|
|
65
|
+
for (var prop in b || (b = {}))
|
|
66
|
+
if (__hasOwnProp$9.call(b, prop))
|
|
67
|
+
__defNormalProp$9(a, prop, b[prop]);
|
|
68
|
+
if (__getOwnPropSymbols$9)
|
|
69
|
+
for (var prop of __getOwnPropSymbols$9(b)) {
|
|
70
|
+
if (__propIsEnum$9.call(b, prop))
|
|
71
|
+
__defNormalProp$9(a, prop, b[prop]);
|
|
72
|
+
}
|
|
73
|
+
return a;
|
|
154
74
|
};
|
|
155
|
-
var
|
|
156
|
-
var
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
75
|
+
var __spreadProps$7 = (a, b) => __defProps$7(a, __getOwnPropDescs$7(b));
|
|
76
|
+
var __objRest$2 = (source, exclude) => {
|
|
77
|
+
var target = {};
|
|
78
|
+
for (var prop in source)
|
|
79
|
+
if (__hasOwnProp$9.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
80
|
+
target[prop] = source[prop];
|
|
81
|
+
if (source != null && __getOwnPropSymbols$9)
|
|
82
|
+
for (var prop of __getOwnPropSymbols$9(source)) {
|
|
83
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$9.call(source, prop))
|
|
84
|
+
target[prop] = source[prop];
|
|
85
|
+
}
|
|
86
|
+
return target;
|
|
162
87
|
};
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
style: "long",
|
|
168
|
-
unit: "day",
|
|
88
|
+
const DEFAULT_CURRENCY_SETTINGS = {
|
|
89
|
+
dataType: "currency",
|
|
90
|
+
currency: "USD",
|
|
91
|
+
currencyDisplay: "narrowSymbol"
|
|
169
92
|
};
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
93
|
+
const NUMBER_TYPES = ["number", "percent", "currency"];
|
|
94
|
+
const DEFAULT_DATETIME_SETTINGS = {
|
|
95
|
+
dataType: "datetime",
|
|
96
|
+
locale: "en-US",
|
|
97
|
+
dateStyle: "short",
|
|
98
|
+
timeStyle: "short",
|
|
99
|
+
hour12: true
|
|
100
|
+
};
|
|
101
|
+
const DEFAULT_RELATIVE_DATETIME_SETTINGS = {
|
|
102
|
+
dataType: "relative-datetime",
|
|
103
|
+
locale: "en-US",
|
|
104
|
+
numeric: "always",
|
|
105
|
+
style: "long",
|
|
106
|
+
unit: "day"
|
|
107
|
+
};
|
|
108
|
+
const DATETIME_TYPES = ["datetime", "relative-datetime"];
|
|
109
|
+
const DEFAULT_BOOLEAN_SETTINGS = {
|
|
110
|
+
dataType: "boolean",
|
|
111
|
+
showAs: "checkbox"
|
|
174
112
|
};
|
|
175
113
|
function deriveValueType(cconfig) {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
: cconfig.dataType === "number"
|
|
181
|
-
? "digit"
|
|
182
|
-
: cconfig.dataType === "boolean"
|
|
183
|
-
? "switch"
|
|
184
|
-
: undefined;
|
|
185
|
-
}
|
|
186
|
-
// Hacky "unique" string values
|
|
187
|
-
var NoneField = "||NoneField||";
|
|
188
|
-
var CustomField = "";
|
|
114
|
+
return cconfig.dataType === "auto" ? void 0 : cconfig.dataType === "string" ? "text" : cconfig.dataType === "number" ? "digit" : cconfig.dataType === "boolean" ? "switch" : void 0;
|
|
115
|
+
}
|
|
116
|
+
const NoneField = "||NoneField||";
|
|
117
|
+
const CustomField = "";
|
|
189
118
|
function getFieldSubprops(opts) {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
}
|
|
217
|
-
return true;
|
|
218
|
-
},
|
|
219
|
-
}, title: {
|
|
220
|
-
type: "string",
|
|
221
|
-
displayName: "Title",
|
|
222
|
-
defaultValueHint: getDefaultValueHint("title"),
|
|
223
|
-
hidden: function () { return !!opts.noTitle; },
|
|
224
|
-
}, expr: __assign(__assign({}, rowDataType("Custom value")), { hidden: function (ps, ctx, _a) {
|
|
225
|
-
_a.item; _a.path;
|
|
226
|
-
return false;
|
|
227
|
-
} }), isHidden: {
|
|
228
|
-
type: "boolean",
|
|
229
|
-
displayName: "Is hidden",
|
|
230
|
-
defaultValueHint: getDefaultValueHint("isHidden"),
|
|
231
|
-
} }, (!opts.noDataType
|
|
232
|
-
? {
|
|
233
|
-
dataType: {
|
|
234
|
-
type: "choice",
|
|
235
|
-
displayName: "Data type",
|
|
236
|
-
options: [
|
|
237
|
-
{
|
|
238
|
-
value: "auto",
|
|
239
|
-
label: "Auto",
|
|
240
|
-
},
|
|
241
|
-
{
|
|
242
|
-
value: "number",
|
|
243
|
-
label: "Number",
|
|
244
|
-
},
|
|
245
|
-
{
|
|
246
|
-
value: "percent",
|
|
247
|
-
label: "Percentage",
|
|
248
|
-
},
|
|
249
|
-
{
|
|
250
|
-
value: "currency",
|
|
251
|
-
label: "Currency",
|
|
252
|
-
},
|
|
253
|
-
{
|
|
254
|
-
value: "string",
|
|
255
|
-
label: "String",
|
|
256
|
-
},
|
|
257
|
-
{
|
|
258
|
-
value: "boolean",
|
|
259
|
-
label: "Boolean",
|
|
260
|
-
},
|
|
261
|
-
{
|
|
262
|
-
value: "datetime",
|
|
263
|
-
label: "Date / Time",
|
|
264
|
-
},
|
|
265
|
-
{
|
|
266
|
-
value: "relative-datetime",
|
|
267
|
-
label: "Date / Time relative to now",
|
|
268
|
-
},
|
|
269
|
-
],
|
|
270
|
-
defaultValueHint: getDefaultValueHint("dataType"),
|
|
271
|
-
},
|
|
272
|
-
currency: {
|
|
273
|
-
displayName: "Currency",
|
|
274
|
-
description: "Must be a valid currency code",
|
|
275
|
-
type: "string",
|
|
276
|
-
defaultValueHint: "USD",
|
|
277
|
-
hidden: function (ps, ctx, _a) {
|
|
278
|
-
var item = _a.item;
|
|
279
|
-
return item.dataType !== "currency";
|
|
280
|
-
},
|
|
281
|
-
},
|
|
282
|
-
locale: {
|
|
283
|
-
displayName: "Locale",
|
|
284
|
-
description: "Must be a valid locale code",
|
|
285
|
-
type: "string",
|
|
286
|
-
defaultValueHint: "en-US",
|
|
287
|
-
hidden: function (ps, ctx, _a) {
|
|
288
|
-
var item = _a.item;
|
|
289
|
-
return !isOneOf(item.dataType, NUMBER_TYPES) &&
|
|
290
|
-
!isOneOf(item.dataType, DATETIME_TYPES);
|
|
291
|
-
},
|
|
292
|
-
},
|
|
293
|
-
notation: {
|
|
294
|
-
displayName: "Notation",
|
|
295
|
-
type: "choice",
|
|
296
|
-
options: [
|
|
297
|
-
{
|
|
298
|
-
value: "standard",
|
|
299
|
-
label: "Standard",
|
|
300
|
-
},
|
|
301
|
-
{
|
|
302
|
-
value: "scientific",
|
|
303
|
-
label: "Scientific notation (like 1E3)",
|
|
304
|
-
},
|
|
305
|
-
{
|
|
306
|
-
value: "compact",
|
|
307
|
-
label: "Compact (like 10K)",
|
|
308
|
-
},
|
|
309
|
-
],
|
|
310
|
-
defaultValueHint: "standard",
|
|
311
|
-
hidden: function (ps, ctx, _a) {
|
|
312
|
-
var item = _a.item;
|
|
313
|
-
return !isOneOf(item.dataType, NUMBER_TYPES);
|
|
314
|
-
},
|
|
315
|
-
},
|
|
316
|
-
signDisplay: {
|
|
317
|
-
type: "choice",
|
|
318
|
-
displayName: "Number sign",
|
|
319
|
-
options: [
|
|
320
|
-
{
|
|
321
|
-
value: "auto",
|
|
322
|
-
label: "Only for negative numbers (10, -10)",
|
|
323
|
-
},
|
|
324
|
-
{
|
|
325
|
-
value: "exceptZero",
|
|
326
|
-
label: "Positive or negative (+10, -10)",
|
|
327
|
-
},
|
|
328
|
-
],
|
|
329
|
-
defaultValueHint: "auto",
|
|
330
|
-
hidden: function (ps, ctx, _a) {
|
|
331
|
-
var item = _a.item;
|
|
332
|
-
return !isOneOf(item.dataType, NUMBER_TYPES);
|
|
333
|
-
},
|
|
334
|
-
},
|
|
335
|
-
maximumFractionDigits: {
|
|
336
|
-
type: "number",
|
|
337
|
-
displayName: "Max decimal places",
|
|
338
|
-
defaultValueHint: 3,
|
|
339
|
-
min: 0,
|
|
340
|
-
max: 20,
|
|
341
|
-
hidden: function (ps, ctx, _a) {
|
|
342
|
-
var item = _a.item;
|
|
343
|
-
return !isOneOf(item.dataType, NUMBER_TYPES);
|
|
344
|
-
},
|
|
345
|
-
},
|
|
346
|
-
minimumFractionDigits: {
|
|
347
|
-
type: "number",
|
|
348
|
-
displayName: "Min decimal places",
|
|
349
|
-
defaultValueHint: 0,
|
|
350
|
-
min: 0,
|
|
351
|
-
max: 20,
|
|
352
|
-
hidden: function (ps, ctx, _a) {
|
|
353
|
-
var item = _a.item;
|
|
354
|
-
return !isOneOf(item.dataType, NUMBER_TYPES);
|
|
355
|
-
},
|
|
356
|
-
},
|
|
357
|
-
showAs: {
|
|
358
|
-
type: "choice",
|
|
359
|
-
options: [
|
|
360
|
-
{
|
|
361
|
-
value: "checkbox",
|
|
362
|
-
label: "Checkboxes",
|
|
363
|
-
},
|
|
364
|
-
{
|
|
365
|
-
value: "switch",
|
|
366
|
-
label: "Toggle switches",
|
|
367
|
-
},
|
|
368
|
-
{
|
|
369
|
-
value: "text",
|
|
370
|
-
label: "Text",
|
|
371
|
-
},
|
|
372
|
-
],
|
|
373
|
-
displayName: "Show as",
|
|
374
|
-
defaultValueHint: "checkbox",
|
|
375
|
-
hidden: function (ps, ctx, _a) {
|
|
376
|
-
var item = _a.item;
|
|
377
|
-
return item.dataType !== "boolean";
|
|
378
|
-
},
|
|
379
|
-
},
|
|
380
|
-
dateStyle: {
|
|
381
|
-
displayName: "Date style",
|
|
382
|
-
type: "choice",
|
|
383
|
-
options: [
|
|
384
|
-
{
|
|
385
|
-
value: "none",
|
|
386
|
-
label: "None (don't display date)",
|
|
387
|
-
},
|
|
388
|
-
{
|
|
389
|
-
value: "short",
|
|
390
|
-
label: "Short (like 12/25/2023)",
|
|
391
|
-
},
|
|
392
|
-
{
|
|
393
|
-
value: "medium",
|
|
394
|
-
label: "Medium (like Dec 25, 2023)",
|
|
395
|
-
},
|
|
396
|
-
{
|
|
397
|
-
value: "long",
|
|
398
|
-
label: "Long (like December 25, 2023)",
|
|
399
|
-
},
|
|
400
|
-
{
|
|
401
|
-
value: "full",
|
|
402
|
-
label: "Full (like Monday, December 25, 2023)",
|
|
403
|
-
},
|
|
404
|
-
],
|
|
405
|
-
defaultValueHint: DEFAULT_DATETIME_SETTINGS.dateStyle,
|
|
406
|
-
hidden: function (ps, ctx, _a) {
|
|
407
|
-
var item = _a.item;
|
|
408
|
-
return item.dataType !== "datetime";
|
|
409
|
-
},
|
|
410
|
-
},
|
|
411
|
-
timeStyle: {
|
|
412
|
-
displayName: "Time style",
|
|
413
|
-
type: "choice",
|
|
414
|
-
options: [
|
|
415
|
-
{
|
|
416
|
-
value: "none",
|
|
417
|
-
label: "None (don't display time)",
|
|
418
|
-
},
|
|
419
|
-
{
|
|
420
|
-
value: "short",
|
|
421
|
-
label: "Short (like 4:00 PM)",
|
|
422
|
-
},
|
|
423
|
-
{
|
|
424
|
-
value: "medium",
|
|
425
|
-
label: "Medium (like 4:00:00 PM)",
|
|
426
|
-
},
|
|
427
|
-
{
|
|
428
|
-
value: "long",
|
|
429
|
-
label: "Long (like 4:00:00 PM PST)",
|
|
430
|
-
},
|
|
431
|
-
{
|
|
432
|
-
value: "full",
|
|
433
|
-
label: "Full (like 4:00:00 PM Pacific Standard Time)",
|
|
434
|
-
},
|
|
435
|
-
],
|
|
436
|
-
defaultValueHint: DEFAULT_DATETIME_SETTINGS.timeStyle,
|
|
437
|
-
hidden: function (ps, ctx, _a) {
|
|
438
|
-
var item = _a.item;
|
|
439
|
-
return item.dataType !== "datetime";
|
|
440
|
-
},
|
|
441
|
-
},
|
|
442
|
-
hour12: {
|
|
443
|
-
displayName: "Use AM/PM?",
|
|
444
|
-
description: "Whether to use AM/PM or 24-hour clock",
|
|
445
|
-
type: "boolean",
|
|
446
|
-
defaultValueHint: DEFAULT_DATETIME_SETTINGS.hour12,
|
|
447
|
-
hidden: function (ps, ctx, _a) {
|
|
448
|
-
var item = _a.item;
|
|
449
|
-
return item.dataType !== "datetime";
|
|
450
|
-
},
|
|
451
|
-
},
|
|
452
|
-
numeric: {
|
|
453
|
-
type: "choice",
|
|
454
|
-
displayName: "Use numbers?",
|
|
455
|
-
options: [
|
|
456
|
-
{ value: "always", label: "Always use numbers" },
|
|
457
|
-
{
|
|
458
|
-
value: "auto",
|
|
459
|
-
label: "Use words like 'Yesterday' or 'Tomorrow'",
|
|
460
|
-
},
|
|
461
|
-
],
|
|
462
|
-
defaultValueHint: DEFAULT_RELATIVE_DATETIME_SETTINGS.numeric,
|
|
463
|
-
hidden: function (ps, ctx, _a) {
|
|
464
|
-
var item = _a.item;
|
|
465
|
-
return item.dataType !== "relative-datetime";
|
|
466
|
-
},
|
|
467
|
-
},
|
|
468
|
-
unit: {
|
|
469
|
-
type: "choice",
|
|
470
|
-
displayName: "Time unit",
|
|
471
|
-
options: [
|
|
472
|
-
{
|
|
473
|
-
value: "second",
|
|
474
|
-
label: "Seconds",
|
|
475
|
-
},
|
|
476
|
-
{
|
|
477
|
-
value: "minute",
|
|
478
|
-
label: "Minutes",
|
|
479
|
-
},
|
|
480
|
-
{
|
|
481
|
-
value: "hour",
|
|
482
|
-
label: "Hours",
|
|
483
|
-
},
|
|
484
|
-
{
|
|
485
|
-
value: "day",
|
|
486
|
-
label: "Days",
|
|
487
|
-
},
|
|
488
|
-
{
|
|
489
|
-
value: "week",
|
|
490
|
-
label: "Weeks",
|
|
491
|
-
},
|
|
492
|
-
{
|
|
493
|
-
value: "month",
|
|
494
|
-
label: "Months",
|
|
495
|
-
},
|
|
496
|
-
{
|
|
497
|
-
value: "year",
|
|
498
|
-
label: "Years",
|
|
499
|
-
},
|
|
500
|
-
],
|
|
501
|
-
defaultValueHint: DEFAULT_RELATIVE_DATETIME_SETTINGS.unit,
|
|
502
|
-
hidden: function (ps, ctx, _a) {
|
|
503
|
-
var item = _a.item;
|
|
504
|
-
return item.dataType !== "relative-datetime";
|
|
505
|
-
},
|
|
506
|
-
},
|
|
119
|
+
return __spreadValues$9(__spreadValues$9({
|
|
120
|
+
key: {
|
|
121
|
+
type: "string",
|
|
122
|
+
hidden: () => true
|
|
123
|
+
},
|
|
124
|
+
fieldId: {
|
|
125
|
+
type: "choice",
|
|
126
|
+
displayName: "Field name",
|
|
127
|
+
readOnly: !opts.canChangeField,
|
|
128
|
+
options: (_props, ctx) => {
|
|
129
|
+
var _a, _b;
|
|
130
|
+
return withoutFalsey([
|
|
131
|
+
opts.canPickNoneField && { value: NoneField, label: "None" },
|
|
132
|
+
...((_b = (_a = ctx == null ? void 0 : ctx.schema) == null ? void 0 : _a.fields) != null ? _b : []).map((f) => {
|
|
133
|
+
var _a2;
|
|
134
|
+
return {
|
|
135
|
+
value: f.id,
|
|
136
|
+
label: (_a2 = f.label) != null ? _a2 : f.id
|
|
137
|
+
};
|
|
138
|
+
}),
|
|
139
|
+
{ value: CustomField, label: "Custom value" }
|
|
140
|
+
]);
|
|
141
|
+
},
|
|
142
|
+
hidden: (ps, ctx, { path: _controlPath }) => {
|
|
143
|
+
if (opts.canChangeField) {
|
|
144
|
+
return false;
|
|
507
145
|
}
|
|
508
|
-
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
146
|
+
return true;
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
title: {
|
|
150
|
+
type: "string",
|
|
151
|
+
displayName: "Title",
|
|
152
|
+
defaultValueHint: getDefaultValueHint("title"),
|
|
153
|
+
hidden: () => !!opts.noTitle
|
|
154
|
+
},
|
|
155
|
+
expr: __spreadProps$7(__spreadValues$9({}, rowDataType("Custom value")), {
|
|
156
|
+
hidden: (ps, ctx, { item, path: _controlPath }) => {
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
159
|
+
}),
|
|
160
|
+
isHidden: {
|
|
161
|
+
type: "boolean",
|
|
162
|
+
displayName: "Is hidden",
|
|
163
|
+
defaultValueHint: getDefaultValueHint("isHidden")
|
|
164
|
+
}
|
|
165
|
+
}, !opts.noDataType ? {
|
|
166
|
+
dataType: {
|
|
167
|
+
type: "choice",
|
|
168
|
+
displayName: "Data type",
|
|
169
|
+
options: [
|
|
170
|
+
{
|
|
171
|
+
value: "auto",
|
|
172
|
+
label: "Auto"
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
value: "number",
|
|
176
|
+
label: "Number"
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
value: "percent",
|
|
180
|
+
label: "Percentage"
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
value: "currency",
|
|
184
|
+
label: "Currency"
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
value: "string",
|
|
188
|
+
label: "String"
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
value: "boolean",
|
|
192
|
+
label: "Boolean"
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
value: "datetime",
|
|
196
|
+
label: "Date / Time"
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
value: "relative-datetime",
|
|
200
|
+
label: "Date / Time relative to now"
|
|
516
201
|
}
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
202
|
+
],
|
|
203
|
+
defaultValueHint: getDefaultValueHint("dataType")
|
|
204
|
+
},
|
|
205
|
+
currency: {
|
|
206
|
+
displayName: "Currency",
|
|
207
|
+
description: "Must be a valid currency code",
|
|
208
|
+
type: "string",
|
|
209
|
+
defaultValueHint: "USD",
|
|
210
|
+
hidden: (ps, ctx, { item }) => item.dataType !== "currency"
|
|
211
|
+
},
|
|
212
|
+
locale: {
|
|
213
|
+
displayName: "Locale",
|
|
214
|
+
description: "Must be a valid locale code",
|
|
215
|
+
type: "string",
|
|
216
|
+
defaultValueHint: "en-US",
|
|
217
|
+
hidden: (ps, ctx, { item }) => !isOneOf(item.dataType, NUMBER_TYPES) && !isOneOf(item.dataType, DATETIME_TYPES)
|
|
218
|
+
},
|
|
219
|
+
notation: {
|
|
220
|
+
displayName: "Notation",
|
|
221
|
+
type: "choice",
|
|
222
|
+
options: [
|
|
223
|
+
{
|
|
224
|
+
value: "standard",
|
|
225
|
+
label: "Standard"
|
|
532
226
|
},
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
var advanced = _a.advanced, displayName = _a.displayName, _b = _a.minimalValue, minimalValue = _b === void 0 ? function (_props, contextData) { return contextData === null || contextData === void 0 ? void 0 : contextData.minimalFullLengthFields; } : _b, opts = __rest(_a, ["advanced", "displayName", "minimalValue"]);
|
|
537
|
-
return {
|
|
538
|
-
type: "array",
|
|
539
|
-
advanced: advanced,
|
|
540
|
-
displayName: displayName,
|
|
541
|
-
hidden: function (ps) { return !ps.data; },
|
|
542
|
-
unstable__keyFunc: function (x) { return x.key; },
|
|
543
|
-
unstable__minimalValue: minimalValue,
|
|
544
|
-
unstable__canDelete: function (ps, _props, ctx, _a) {
|
|
545
|
-
var item = _a.item;
|
|
546
|
-
if (opts.canChangeField) {
|
|
547
|
-
return true;
|
|
548
|
-
}
|
|
549
|
-
if (!(ctx === null || ctx === void 0 ? void 0 : ctx.schema)) {
|
|
550
|
-
// still loading...
|
|
551
|
-
return false;
|
|
552
|
-
}
|
|
553
|
-
if (item.fieldId &&
|
|
554
|
-
ctx.schema.fields.some(function (f) { return f.id === item.fieldId; })) {
|
|
555
|
-
return false;
|
|
556
|
-
}
|
|
557
|
-
return true;
|
|
227
|
+
{
|
|
228
|
+
value: "scientific",
|
|
229
|
+
label: "Scientific notation (like 1E3)"
|
|
558
230
|
},
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
231
|
+
{
|
|
232
|
+
value: "compact",
|
|
233
|
+
label: "Compact (like 10K)"
|
|
234
|
+
}
|
|
235
|
+
],
|
|
236
|
+
defaultValueHint: "standard",
|
|
237
|
+
hidden: (ps, ctx, { item }) => !isOneOf(item.dataType, NUMBER_TYPES)
|
|
238
|
+
},
|
|
239
|
+
signDisplay: {
|
|
240
|
+
type: "choice",
|
|
241
|
+
displayName: "Number sign",
|
|
242
|
+
options: [
|
|
243
|
+
{
|
|
244
|
+
value: "auto",
|
|
245
|
+
label: "Only for negative numbers (10, -10)"
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
value: "exceptZero",
|
|
249
|
+
label: "Positive or negative (+10, -10)"
|
|
250
|
+
}
|
|
251
|
+
],
|
|
252
|
+
defaultValueHint: "auto",
|
|
253
|
+
hidden: (ps, ctx, { item }) => !isOneOf(item.dataType, NUMBER_TYPES)
|
|
254
|
+
},
|
|
255
|
+
maximumFractionDigits: {
|
|
256
|
+
type: "number",
|
|
257
|
+
displayName: "Max decimal places",
|
|
258
|
+
defaultValueHint: 3,
|
|
259
|
+
min: 0,
|
|
260
|
+
max: 20,
|
|
261
|
+
hidden: (ps, ctx, { item }) => !isOneOf(item.dataType, NUMBER_TYPES)
|
|
262
|
+
},
|
|
263
|
+
minimumFractionDigits: {
|
|
264
|
+
type: "number",
|
|
265
|
+
displayName: "Min decimal places",
|
|
266
|
+
defaultValueHint: 0,
|
|
267
|
+
min: 0,
|
|
268
|
+
max: 20,
|
|
269
|
+
hidden: (ps, ctx, { item }) => !isOneOf(item.dataType, NUMBER_TYPES)
|
|
270
|
+
},
|
|
271
|
+
showAs: {
|
|
272
|
+
type: "choice",
|
|
273
|
+
options: [
|
|
274
|
+
{
|
|
275
|
+
value: "checkbox",
|
|
276
|
+
label: "Checkboxes"
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
value: "switch",
|
|
280
|
+
label: "Toggle switches"
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
value: "text",
|
|
284
|
+
label: "Text"
|
|
285
|
+
}
|
|
286
|
+
],
|
|
287
|
+
displayName: "Show as",
|
|
288
|
+
defaultValueHint: "checkbox",
|
|
289
|
+
hidden: (ps, ctx, { item }) => item.dataType !== "boolean"
|
|
290
|
+
},
|
|
291
|
+
dateStyle: {
|
|
292
|
+
displayName: "Date style",
|
|
293
|
+
type: "choice",
|
|
294
|
+
options: [
|
|
295
|
+
{
|
|
296
|
+
value: "none",
|
|
297
|
+
label: "None (don't display date)"
|
|
566
298
|
},
|
|
567
|
-
|
|
299
|
+
{
|
|
300
|
+
value: "short",
|
|
301
|
+
label: "Short (like 12/25/2023)"
|
|
302
|
+
},
|
|
303
|
+
{
|
|
304
|
+
value: "medium",
|
|
305
|
+
label: "Medium (like Dec 25, 2023)"
|
|
306
|
+
},
|
|
307
|
+
{
|
|
308
|
+
value: "long",
|
|
309
|
+
label: "Long (like December 25, 2023)"
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
value: "full",
|
|
313
|
+
label: "Full (like Monday, December 25, 2023)"
|
|
314
|
+
}
|
|
315
|
+
],
|
|
316
|
+
defaultValueHint: DEFAULT_DATETIME_SETTINGS.dateStyle,
|
|
317
|
+
hidden: (ps, ctx, { item }) => item.dataType !== "datetime"
|
|
318
|
+
},
|
|
319
|
+
timeStyle: {
|
|
320
|
+
displayName: "Time style",
|
|
321
|
+
type: "choice",
|
|
322
|
+
options: [
|
|
323
|
+
{
|
|
324
|
+
value: "none",
|
|
325
|
+
label: "None (don't display time)"
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
value: "short",
|
|
329
|
+
label: "Short (like 4:00 PM)"
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
value: "medium",
|
|
333
|
+
label: "Medium (like 4:00:00 PM)"
|
|
334
|
+
},
|
|
335
|
+
{
|
|
336
|
+
value: "long",
|
|
337
|
+
label: "Long (like 4:00:00 PM PST)"
|
|
338
|
+
},
|
|
339
|
+
{
|
|
340
|
+
value: "full",
|
|
341
|
+
label: "Full (like 4:00:00 PM Pacific Standard Time)"
|
|
342
|
+
}
|
|
343
|
+
],
|
|
344
|
+
defaultValueHint: DEFAULT_DATETIME_SETTINGS.timeStyle,
|
|
345
|
+
hidden: (ps, ctx, { item }) => item.dataType !== "datetime"
|
|
346
|
+
},
|
|
347
|
+
hour12: {
|
|
348
|
+
displayName: "Use AM/PM?",
|
|
349
|
+
description: "Whether to use AM/PM or 24-hour clock",
|
|
350
|
+
type: "boolean",
|
|
351
|
+
defaultValueHint: DEFAULT_DATETIME_SETTINGS.hour12,
|
|
352
|
+
hidden: (ps, ctx, { item }) => item.dataType !== "datetime"
|
|
353
|
+
},
|
|
354
|
+
numeric: {
|
|
355
|
+
type: "choice",
|
|
356
|
+
displayName: "Use numbers?",
|
|
357
|
+
options: [
|
|
358
|
+
{ value: "always", label: "Always use numbers" },
|
|
359
|
+
{
|
|
360
|
+
value: "auto",
|
|
361
|
+
label: "Use words like 'Yesterday' or 'Tomorrow'"
|
|
362
|
+
}
|
|
363
|
+
],
|
|
364
|
+
defaultValueHint: DEFAULT_RELATIVE_DATETIME_SETTINGS.numeric,
|
|
365
|
+
hidden: (ps, ctx, { item }) => item.dataType !== "relative-datetime"
|
|
366
|
+
},
|
|
367
|
+
unit: {
|
|
368
|
+
type: "choice",
|
|
369
|
+
displayName: "Time unit",
|
|
370
|
+
options: [
|
|
371
|
+
{
|
|
372
|
+
value: "second",
|
|
373
|
+
label: "Seconds"
|
|
374
|
+
},
|
|
375
|
+
{
|
|
376
|
+
value: "minute",
|
|
377
|
+
label: "Minutes"
|
|
378
|
+
},
|
|
379
|
+
{
|
|
380
|
+
value: "hour",
|
|
381
|
+
label: "Hours"
|
|
382
|
+
},
|
|
383
|
+
{
|
|
384
|
+
value: "day",
|
|
385
|
+
label: "Days"
|
|
386
|
+
},
|
|
387
|
+
{
|
|
388
|
+
value: "week",
|
|
389
|
+
label: "Weeks"
|
|
390
|
+
},
|
|
391
|
+
{
|
|
392
|
+
value: "month",
|
|
393
|
+
label: "Months"
|
|
394
|
+
},
|
|
395
|
+
{
|
|
396
|
+
value: "year",
|
|
397
|
+
label: "Years"
|
|
398
|
+
}
|
|
399
|
+
],
|
|
400
|
+
defaultValueHint: DEFAULT_RELATIVE_DATETIME_SETTINGS.unit,
|
|
401
|
+
hidden: (ps, ctx, { item }) => item.dataType !== "relative-datetime"
|
|
402
|
+
}
|
|
403
|
+
} : {}), opts.fieldTypes);
|
|
404
|
+
}
|
|
405
|
+
function getDefaultValueHint(field) {
|
|
406
|
+
return (_props, contextData, { item }) => {
|
|
407
|
+
if (item == null ? void 0 : item.fieldId) {
|
|
408
|
+
const fieldSetting = contextData == null ? void 0 : contextData.mergedFields.find(
|
|
409
|
+
(f) => f.fieldId === item.fieldId
|
|
410
|
+
);
|
|
411
|
+
return fieldSetting == null ? void 0 : fieldSetting[field];
|
|
412
|
+
}
|
|
413
|
+
return void 0;
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
const rowDataType = (displayName, control) => ({
|
|
417
|
+
type: "function",
|
|
418
|
+
displayName,
|
|
419
|
+
control,
|
|
420
|
+
argNames: ["currentItem", "currentValue"],
|
|
421
|
+
argValues: (_props, ctx, { item }) => {
|
|
422
|
+
var _a;
|
|
423
|
+
const row = (_a = ctx == null ? void 0 : ctx.data) == null ? void 0 : _a[0];
|
|
424
|
+
const cell = item.fieldId ? row == null ? void 0 : row[item.fieldId] : void 0;
|
|
425
|
+
return [row, cell];
|
|
426
|
+
}
|
|
427
|
+
});
|
|
428
|
+
function buildFieldsPropType(_a) {
|
|
429
|
+
var _b = _a, {
|
|
430
|
+
advanced,
|
|
431
|
+
displayName,
|
|
432
|
+
minimalValue = (_props, contextData) => contextData == null ? void 0 : contextData.minimalFullLengthFields
|
|
433
|
+
} = _b, opts = __objRest$2(_b, [
|
|
434
|
+
"advanced",
|
|
435
|
+
"displayName",
|
|
436
|
+
"minimalValue"
|
|
437
|
+
]);
|
|
438
|
+
return {
|
|
439
|
+
type: "array",
|
|
440
|
+
advanced,
|
|
441
|
+
displayName,
|
|
442
|
+
hidden: (ps) => !ps.data,
|
|
443
|
+
unstable__keyFunc: (x) => x.key,
|
|
444
|
+
unstable__minimalValue: minimalValue,
|
|
445
|
+
unstable__canDelete: (ps, _props, ctx, { item }) => {
|
|
446
|
+
if (opts.canChangeField) {
|
|
447
|
+
return true;
|
|
448
|
+
}
|
|
449
|
+
if (!(ctx == null ? void 0 : ctx.schema)) {
|
|
450
|
+
return false;
|
|
451
|
+
}
|
|
452
|
+
if (item.fieldId && ctx.schema.fields.some((f) => f.id === item.fieldId)) {
|
|
453
|
+
return false;
|
|
454
|
+
}
|
|
455
|
+
return true;
|
|
456
|
+
},
|
|
457
|
+
itemType: {
|
|
458
|
+
type: "object",
|
|
459
|
+
nameFunc: (_item) => {
|
|
460
|
+
return _item.fieldId || _item.title || "Custom value";
|
|
461
|
+
},
|
|
462
|
+
fields: getFieldSubprops(opts)
|
|
463
|
+
}
|
|
464
|
+
};
|
|
568
465
|
}
|
|
569
466
|
|
|
467
|
+
var __defProp$8 = Object.defineProperty;
|
|
468
|
+
var __defProps$6 = Object.defineProperties;
|
|
469
|
+
var __getOwnPropDescs$6 = Object.getOwnPropertyDescriptors;
|
|
470
|
+
var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
|
|
471
|
+
var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
|
|
472
|
+
var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
|
|
473
|
+
var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
474
|
+
var __spreadValues$8 = (a, b) => {
|
|
475
|
+
for (var prop in b || (b = {}))
|
|
476
|
+
if (__hasOwnProp$8.call(b, prop))
|
|
477
|
+
__defNormalProp$8(a, prop, b[prop]);
|
|
478
|
+
if (__getOwnPropSymbols$8)
|
|
479
|
+
for (var prop of __getOwnPropSymbols$8(b)) {
|
|
480
|
+
if (__propIsEnum$8.call(b, prop))
|
|
481
|
+
__defNormalProp$8(a, prop, b[prop]);
|
|
482
|
+
}
|
|
483
|
+
return a;
|
|
484
|
+
};
|
|
485
|
+
var __spreadProps$6 = (a, b) => __defProps$6(a, __getOwnPropDescs$6(b));
|
|
570
486
|
function multiRenderValue(record, cconfigs) {
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
487
|
+
return cconfigs == null ? void 0 : cconfigs.flatMap(
|
|
488
|
+
(cc) => cc.isHidden ? [] : [` \u2022 `, /* @__PURE__ */ React.createElement(React.Fragment, null, renderValue(record, cc))]
|
|
489
|
+
).slice(1);
|
|
574
490
|
}
|
|
575
491
|
function maybeRenderString(record, cconfig) {
|
|
576
|
-
|
|
577
|
-
? maybe(getFieldValue(record, cconfig), asString)
|
|
578
|
-
: undefined;
|
|
492
|
+
return cconfig && !cconfig.isHidden ? maybe(getFieldValue(record, cconfig), asString) : void 0;
|
|
579
493
|
}
|
|
580
494
|
function getFieldValue(record, cconfig) {
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
495
|
+
let value = cconfig.fieldId ? record[cconfig.fieldId] : void 0;
|
|
496
|
+
if (cconfig.expr) {
|
|
497
|
+
value = cconfig.expr(record, value);
|
|
498
|
+
}
|
|
499
|
+
return value;
|
|
586
500
|
}
|
|
587
501
|
function renderValue(record, cconfig) {
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
else if (cconfig.dataType === "datetime" && coerced instanceof Date) {
|
|
605
|
-
return renderDate(coerced, cconfig);
|
|
606
|
-
}
|
|
607
|
-
else if (cconfig.dataType === "relative-datetime" &&
|
|
608
|
-
coerced instanceof Date) {
|
|
609
|
-
return renderRelativeDate(coerced, cconfig);
|
|
610
|
-
}
|
|
611
|
-
return asString(value);
|
|
502
|
+
const value = getFieldValue(record, cconfig);
|
|
503
|
+
if (value == null) {
|
|
504
|
+
return "";
|
|
505
|
+
}
|
|
506
|
+
if (cconfig.dataType === "auto") {
|
|
507
|
+
return renderAuto(value);
|
|
508
|
+
} else {
|
|
509
|
+
const coerced = coerceValue(value, cconfig.dataType);
|
|
510
|
+
if (isOneOf(cconfig.dataType, NUMBER_TYPES) && typeof coerced === "number") {
|
|
511
|
+
return renderNumber(coerced, cconfig);
|
|
512
|
+
} else if (cconfig.dataType === "boolean" && typeof coerced === "boolean") {
|
|
513
|
+
return renderBoolean(coerced, cconfig);
|
|
514
|
+
} else if (cconfig.dataType === "datetime" && coerced instanceof Date) {
|
|
515
|
+
return renderDate(coerced, cconfig);
|
|
516
|
+
} else if (cconfig.dataType === "relative-datetime" && coerced instanceof Date) {
|
|
517
|
+
return renderRelativeDate(coerced, cconfig);
|
|
612
518
|
}
|
|
519
|
+
return asString(value);
|
|
520
|
+
}
|
|
613
521
|
}
|
|
614
522
|
function renderAuto(value) {
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
return asString(value);
|
|
628
|
-
}
|
|
629
|
-
else {
|
|
630
|
-
return renderAuto(coerced);
|
|
631
|
-
}
|
|
523
|
+
if (typeof value === "number") {
|
|
524
|
+
return renderNumber(value, { dataType: "number" });
|
|
525
|
+
} else if (typeof value === "boolean") {
|
|
526
|
+
return renderBoolean(value, DEFAULT_BOOLEAN_SETTINGS);
|
|
527
|
+
} else if (value instanceof Date) {
|
|
528
|
+
return renderDate(value, DEFAULT_DATETIME_SETTINGS);
|
|
529
|
+
} else {
|
|
530
|
+
const coerced = tryCoerceAuto(value);
|
|
531
|
+
if (coerced === CANNOT_COERCE) {
|
|
532
|
+
return asString(value);
|
|
533
|
+
} else {
|
|
534
|
+
return renderAuto(coerced);
|
|
632
535
|
}
|
|
536
|
+
}
|
|
633
537
|
}
|
|
634
538
|
function tryCoerceAuto(value) {
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
return coerced;
|
|
643
|
-
}
|
|
539
|
+
for (const dataType of [
|
|
540
|
+
"number",
|
|
541
|
+
"datetime"
|
|
542
|
+
]) {
|
|
543
|
+
const coerced = coerceValue(value, dataType);
|
|
544
|
+
if (coerced !== CANNOT_COERCE) {
|
|
545
|
+
return coerced;
|
|
644
546
|
}
|
|
645
|
-
|
|
547
|
+
}
|
|
548
|
+
return CANNOT_COERCE;
|
|
646
549
|
}
|
|
647
550
|
function renderNumber(value, cconfig) {
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
}
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
}
|
|
551
|
+
if (cconfig.dataType === "number") {
|
|
552
|
+
return new Intl.NumberFormat(cconfig.locale, cconfig).format(value);
|
|
553
|
+
} else if (cconfig.dataType === "percent") {
|
|
554
|
+
return new Intl.NumberFormat(cconfig.locale, __spreadProps$6(__spreadValues$8({}, cconfig), {
|
|
555
|
+
style: "percent"
|
|
556
|
+
})).format(value);
|
|
557
|
+
} else if (cconfig.dataType === "currency") {
|
|
558
|
+
return new Intl.NumberFormat(cconfig.locale, __spreadProps$6(__spreadValues$8(__spreadValues$8({}, DEFAULT_CURRENCY_SETTINGS), cconfig), {
|
|
559
|
+
style: "currency"
|
|
560
|
+
})).format(value);
|
|
561
|
+
} else {
|
|
562
|
+
throw new Error(`Unexpected dataType ${cconfig.dataType}`);
|
|
563
|
+
}
|
|
660
564
|
}
|
|
661
565
|
function renderDate(value, cconfig) {
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
}
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
566
|
+
const opts = __spreadValues$8(__spreadValues$8({}, DEFAULT_DATETIME_SETTINGS), cconfig);
|
|
567
|
+
if (opts.dateStyle === "none") {
|
|
568
|
+
delete opts["dateStyle"];
|
|
569
|
+
}
|
|
570
|
+
if (opts.timeStyle === "none") {
|
|
571
|
+
delete opts["timeStyle"];
|
|
572
|
+
}
|
|
573
|
+
return new Intl.DateTimeFormat(cconfig.locale, opts).format(value);
|
|
574
|
+
}
|
|
575
|
+
const SECOND_MS = 1e3;
|
|
576
|
+
const MINUTE_MS = 60 * SECOND_MS;
|
|
577
|
+
const HOUR_MS = 60 * MINUTE_MS;
|
|
578
|
+
const DAY_MS = 24 * HOUR_MS;
|
|
579
|
+
const WEEK_MS = 7 * DAY_MS;
|
|
580
|
+
const UNIT_TO_MS = {
|
|
581
|
+
second: SECOND_MS,
|
|
582
|
+
minute: MINUTE_MS,
|
|
583
|
+
hour: HOUR_MS,
|
|
584
|
+
day: DAY_MS,
|
|
585
|
+
week: WEEK_MS
|
|
682
586
|
};
|
|
683
|
-
|
|
587
|
+
const UNITS_BY_MS = Object.keys(UNIT_TO_MS);
|
|
684
588
|
function renderRelativeDate(value, cconfig) {
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
var months = function (d) { return d.getFullYear() * 12 + d.getMonth() + 1; };
|
|
703
|
-
var diff = months(value) - months(new Date());
|
|
704
|
-
return formatter.format(diff, unit);
|
|
705
|
-
}
|
|
706
|
-
else {
|
|
707
|
-
throw new Error("Unexpected relative time unit ".concat(unit));
|
|
708
|
-
}
|
|
589
|
+
var _a;
|
|
590
|
+
const opts = __spreadValues$8(__spreadValues$8({}, DEFAULT_RELATIVE_DATETIME_SETTINGS), cconfig);
|
|
591
|
+
const unit = (_a = cconfig.unit) != null ? _a : "day";
|
|
592
|
+
const formatter = new Intl.RelativeTimeFormat(cconfig.locale, opts);
|
|
593
|
+
if (isOneOf(unit, UNITS_BY_MS)) {
|
|
594
|
+
const diff = value.getTime() - (/* @__PURE__ */ new Date()).getTime();
|
|
595
|
+
return formatter.format(Math.round(diff / UNIT_TO_MS[unit]), unit);
|
|
596
|
+
} else {
|
|
597
|
+
if (unit === "year") {
|
|
598
|
+
const diff = value.getFullYear() - (/* @__PURE__ */ new Date()).getFullYear();
|
|
599
|
+
return formatter.format(diff, unit);
|
|
600
|
+
} else if (unit === "month") {
|
|
601
|
+
const months = (d) => d.getFullYear() * 12 + d.getMonth() + 1;
|
|
602
|
+
const diff = months(value) - months(/* @__PURE__ */ new Date());
|
|
603
|
+
return formatter.format(diff, unit);
|
|
604
|
+
} else {
|
|
605
|
+
throw new Error(`Unexpected relative time unit ${unit}`);
|
|
709
606
|
}
|
|
607
|
+
}
|
|
710
608
|
}
|
|
711
609
|
function renderBoolean(value, cconfig) {
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
return value ? "true" : "false";
|
|
722
|
-
}
|
|
610
|
+
var _a;
|
|
611
|
+
const showAs = (_a = cconfig.showAs) != null ? _a : DEFAULT_BOOLEAN_SETTINGS.showAs;
|
|
612
|
+
if (showAs === "checkbox") {
|
|
613
|
+
return /* @__PURE__ */ React.createElement(Checkbox, { checked: value });
|
|
614
|
+
} else if (showAs === "switch") {
|
|
615
|
+
return /* @__PURE__ */ React.createElement(Switch, { checked: value });
|
|
616
|
+
} else {
|
|
617
|
+
return value ? "true" : "false";
|
|
618
|
+
}
|
|
723
619
|
}
|
|
724
|
-
|
|
620
|
+
const CANNOT_COERCE = Symbol("plasmic-cannot-coerce");
|
|
725
621
|
function coerceValue(value, dataType) {
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
return maybeNumber;
|
|
738
|
-
}
|
|
739
|
-
}
|
|
740
|
-
}
|
|
741
|
-
else if (isOneOf(dataType, DATETIME_TYPES)) {
|
|
742
|
-
if (value instanceof Date) {
|
|
743
|
-
return value;
|
|
744
|
-
}
|
|
745
|
-
else if (typeof value === "number") {
|
|
746
|
-
return new Date(value);
|
|
747
|
-
}
|
|
748
|
-
else if (typeof value === "string") {
|
|
749
|
-
var maybeDate = new Date(value);
|
|
750
|
-
if (!isNaN(maybeDate.getTime())) {
|
|
751
|
-
return maybeDate;
|
|
752
|
-
}
|
|
753
|
-
}
|
|
754
|
-
}
|
|
755
|
-
else if (dataType === "boolean") {
|
|
756
|
-
if (value === true || value === false) {
|
|
757
|
-
return value;
|
|
758
|
-
}
|
|
759
|
-
else if (typeof value === "number") {
|
|
760
|
-
return value !== 0;
|
|
761
|
-
}
|
|
762
|
-
else if (typeof value === "string") {
|
|
763
|
-
return value.toLowerCase() === "true";
|
|
764
|
-
}
|
|
765
|
-
}
|
|
766
|
-
else if (dataType === "string") {
|
|
767
|
-
return asString(value);
|
|
622
|
+
if (value == null) {
|
|
623
|
+
return null;
|
|
624
|
+
}
|
|
625
|
+
try {
|
|
626
|
+
if (isOneOf(dataType, NUMBER_TYPES)) {
|
|
627
|
+
if (typeof value === "number") {
|
|
628
|
+
return value;
|
|
629
|
+
} else if (typeof value === "string") {
|
|
630
|
+
const maybeNumber = +value;
|
|
631
|
+
if (!isNaN(maybeNumber)) {
|
|
632
|
+
return maybeNumber;
|
|
768
633
|
}
|
|
769
|
-
|
|
770
|
-
|
|
634
|
+
}
|
|
635
|
+
} else if (isOneOf(dataType, DATETIME_TYPES)) {
|
|
636
|
+
if (value instanceof Date) {
|
|
637
|
+
return value;
|
|
638
|
+
} else if (typeof value === "number") {
|
|
639
|
+
return new Date(value);
|
|
640
|
+
} else if (typeof value === "string") {
|
|
641
|
+
const maybeDate = new Date(value);
|
|
642
|
+
if (!isNaN(maybeDate.getTime())) {
|
|
643
|
+
return maybeDate;
|
|
771
644
|
}
|
|
645
|
+
}
|
|
646
|
+
} else if (dataType === "boolean") {
|
|
647
|
+
if (value === true || value === false) {
|
|
648
|
+
return value;
|
|
649
|
+
} else if (typeof value === "number") {
|
|
650
|
+
return value !== 0;
|
|
651
|
+
} else if (typeof value === "string") {
|
|
652
|
+
return value.toLowerCase() === "true";
|
|
653
|
+
}
|
|
654
|
+
} else if (dataType === "string") {
|
|
655
|
+
return asString(value);
|
|
656
|
+
} else if (dataType === "auto") {
|
|
657
|
+
return value;
|
|
772
658
|
}
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
return CANNOT_COERCE;
|
|
659
|
+
} catch (err) {
|
|
660
|
+
}
|
|
661
|
+
return CANNOT_COERCE;
|
|
777
662
|
}
|
|
778
663
|
function asString(value) {
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
}
|
|
789
|
-
else {
|
|
790
|
-
return JSON.stringify(value);
|
|
791
|
-
}
|
|
792
|
-
}
|
|
793
|
-
else {
|
|
794
|
-
return "".concat(value);
|
|
664
|
+
if (value == null) {
|
|
665
|
+
return "";
|
|
666
|
+
} else if (typeof value === "string") {
|
|
667
|
+
return value;
|
|
668
|
+
} else if (typeof value === "object") {
|
|
669
|
+
if ("toString" in value && typeof value.toString === "function") {
|
|
670
|
+
return value.toString();
|
|
671
|
+
} else {
|
|
672
|
+
return JSON.stringify(value);
|
|
795
673
|
}
|
|
674
|
+
} else {
|
|
675
|
+
return `${value}`;
|
|
676
|
+
}
|
|
796
677
|
}
|
|
797
678
|
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
679
|
+
var __defProp$7 = Object.defineProperty;
|
|
680
|
+
var __defProps$5 = Object.defineProperties;
|
|
681
|
+
var __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors;
|
|
682
|
+
var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
|
|
683
|
+
var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
|
|
684
|
+
var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
|
|
685
|
+
var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
686
|
+
var __spreadValues$7 = (a, b) => {
|
|
687
|
+
for (var prop in b || (b = {}))
|
|
688
|
+
if (__hasOwnProp$7.call(b, prop))
|
|
689
|
+
__defNormalProp$7(a, prop, b[prop]);
|
|
690
|
+
if (__getOwnPropSymbols$7)
|
|
691
|
+
for (var prop of __getOwnPropSymbols$7(b)) {
|
|
692
|
+
if (__propIsEnum$7.call(b, prop))
|
|
693
|
+
__defNormalProp$7(a, prop, b[prop]);
|
|
805
694
|
}
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
695
|
+
return a;
|
|
696
|
+
};
|
|
697
|
+
var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
|
|
698
|
+
function RichDetails(props) {
|
|
699
|
+
var _a;
|
|
700
|
+
const {
|
|
701
|
+
className,
|
|
702
|
+
data: rawData,
|
|
703
|
+
size,
|
|
704
|
+
bordered,
|
|
705
|
+
layout,
|
|
706
|
+
column = 2
|
|
707
|
+
} = props;
|
|
708
|
+
const data = normalizeData(rawData);
|
|
709
|
+
const { columnDefinitions } = useColumnDefinitions$1(data, props);
|
|
710
|
+
if (!data || !((_a = data.data) == null ? void 0 : _a[0])) {
|
|
711
|
+
return /* @__PURE__ */ React.createElement(Empty, { className, image: Empty.PRESENTED_IMAGE_SIMPLE });
|
|
712
|
+
}
|
|
713
|
+
const row = data.data[0];
|
|
714
|
+
return /* @__PURE__ */ React.createElement(
|
|
715
|
+
Descriptions,
|
|
716
|
+
{
|
|
717
|
+
className,
|
|
718
|
+
size,
|
|
719
|
+
bordered,
|
|
720
|
+
layout,
|
|
721
|
+
column: {
|
|
722
|
+
xs: 1,
|
|
723
|
+
sm: 1,
|
|
724
|
+
md: column
|
|
725
|
+
}
|
|
726
|
+
},
|
|
727
|
+
columnDefinitions.map((col) => /* @__PURE__ */ React.createElement(Descriptions.Item, { label: col.title, key: col.key, span: col.span }, col.render(row)))
|
|
728
|
+
);
|
|
812
729
|
}
|
|
813
730
|
function useColumnDefinitions$1(data, props) {
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
731
|
+
const { fields, setControlContextData } = props;
|
|
732
|
+
return React.useMemo(() => {
|
|
733
|
+
const schema = data == null ? void 0 : data.schema;
|
|
734
|
+
if (!data || !schema) {
|
|
735
|
+
return { normalized: [], columnDefinitions: [] };
|
|
736
|
+
}
|
|
737
|
+
const { mergedFields, minimalFullLengthFields } = deriveFieldConfigs(
|
|
738
|
+
fields != null ? fields : [],
|
|
739
|
+
schema,
|
|
740
|
+
(field) => __spreadValues$7({
|
|
741
|
+
key: mkShortId(),
|
|
742
|
+
isHidden: false,
|
|
743
|
+
dataType: "auto"
|
|
744
|
+
}, field && {
|
|
745
|
+
key: field.id,
|
|
746
|
+
fieldId: field.id,
|
|
747
|
+
title: field.label || field.id,
|
|
748
|
+
expr: (currentItem) => currentItem[field.id]
|
|
749
|
+
})
|
|
750
|
+
);
|
|
751
|
+
setControlContextData == null ? void 0 : setControlContextData(__spreadProps$5(__spreadValues$7({}, data), { mergedFields, minimalFullLengthFields }));
|
|
752
|
+
const normalized = mergedFields;
|
|
753
|
+
const columnDefinitions = normalized.filter((cconfig) => !cconfig.isHidden).map((cconfig, _columnIndex, _columnsArray) => {
|
|
754
|
+
const columnDefinition = {
|
|
755
|
+
dataIndex: cconfig.fieldId,
|
|
756
|
+
title: cconfig.title,
|
|
757
|
+
key: cconfig.key,
|
|
758
|
+
span: cconfig.span,
|
|
759
|
+
render: (record) => {
|
|
760
|
+
return renderValue(record, cconfig);
|
|
819
761
|
}
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
}))); }), mergedFields = _a.mergedFields, minimalFullLengthFields = _a.minimalFullLengthFields;
|
|
826
|
-
setControlContextData === null || setControlContextData === void 0 ? void 0 : setControlContextData(__assign(__assign({}, data), { mergedFields: mergedFields, minimalFullLengthFields: minimalFullLengthFields }));
|
|
827
|
-
var normalized = mergedFields;
|
|
828
|
-
var columnDefinitions = normalized
|
|
829
|
-
.filter(function (cconfig) { return !cconfig.isHidden; })
|
|
830
|
-
.map(function (cconfig, _columnIndex, _columnsArray) {
|
|
831
|
-
var columnDefinition = {
|
|
832
|
-
dataIndex: cconfig.fieldId,
|
|
833
|
-
title: cconfig.title,
|
|
834
|
-
key: cconfig.key,
|
|
835
|
-
span: cconfig.span,
|
|
836
|
-
render: function (record) {
|
|
837
|
-
return renderValue(record, cconfig);
|
|
838
|
-
},
|
|
839
|
-
};
|
|
840
|
-
return columnDefinition;
|
|
841
|
-
});
|
|
842
|
-
return { normalized: normalized, columnDefinitions: columnDefinitions };
|
|
843
|
-
}, [fields, data, setControlContextData]);
|
|
762
|
+
};
|
|
763
|
+
return columnDefinition;
|
|
764
|
+
});
|
|
765
|
+
return { normalized, columnDefinitions };
|
|
766
|
+
}, [fields, data, setControlContextData]);
|
|
844
767
|
}
|
|
845
768
|
|
|
846
769
|
function registerRichDetails(loader) {
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
770
|
+
registerComponentHelper(loader, RichDetails, {
|
|
771
|
+
name: "hostless-rich-details",
|
|
772
|
+
displayName: "Data details",
|
|
773
|
+
defaultStyles: {
|
|
774
|
+
width: "stretch",
|
|
775
|
+
maxHeight: "100%"
|
|
776
|
+
},
|
|
777
|
+
props: {
|
|
778
|
+
data: {
|
|
779
|
+
type: "dataSourceOpData",
|
|
780
|
+
description: "The data to display"
|
|
781
|
+
},
|
|
782
|
+
fields: buildFieldsPropType({
|
|
783
|
+
fieldTypes: {
|
|
784
|
+
span: {
|
|
785
|
+
type: "number",
|
|
786
|
+
displayName: "Number of columns to span",
|
|
787
|
+
defaultValueHint: 1
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
}),
|
|
791
|
+
layout: {
|
|
792
|
+
displayName: "Layout",
|
|
793
|
+
type: "choice",
|
|
794
|
+
options: [
|
|
795
|
+
{ value: "horizontal", label: "Horizontal" },
|
|
796
|
+
{ value: "vertical", label: "Vertical" }
|
|
797
|
+
],
|
|
798
|
+
defaultValueHint: "horizontal"
|
|
799
|
+
},
|
|
800
|
+
column: {
|
|
801
|
+
displayName: "Items per row",
|
|
802
|
+
type: "number",
|
|
803
|
+
description: "Number of items to display per row",
|
|
804
|
+
defaultValueHint: 2
|
|
805
|
+
},
|
|
806
|
+
size: {
|
|
807
|
+
displayName: "Spacing",
|
|
808
|
+
type: "choice",
|
|
809
|
+
options: [
|
|
810
|
+
{ value: "small", label: "Small" },
|
|
811
|
+
{ value: "middle", label: "Medium" },
|
|
812
|
+
{ value: "default", label: "Large" }
|
|
813
|
+
],
|
|
814
|
+
defaultValueHint: "default"
|
|
815
|
+
},
|
|
816
|
+
bordered: {
|
|
817
|
+
displayName: "Show borders?",
|
|
818
|
+
type: "boolean",
|
|
819
|
+
defaultValueHint: false
|
|
820
|
+
}
|
|
821
|
+
},
|
|
822
|
+
importPath: "@plasmicpkgs/plasmic-rich-components",
|
|
823
|
+
importName: "RichDetails"
|
|
824
|
+
});
|
|
902
825
|
}
|
|
903
826
|
|
|
904
827
|
function useIsClient() {
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
828
|
+
const [loaded, setLoaded] = React.useState(false);
|
|
829
|
+
useIsomorphicLayoutEffect(() => {
|
|
830
|
+
setLoaded(true);
|
|
831
|
+
});
|
|
832
|
+
return loaded;
|
|
910
833
|
}
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
? React.useLayoutEffect
|
|
914
|
-
: React.useEffect;
|
|
834
|
+
const isBrowser = typeof window !== "undefined";
|
|
835
|
+
const useIsomorphicLayoutEffect = isBrowser ? React.useLayoutEffect : React.useEffect;
|
|
915
836
|
function capitalize(text) {
|
|
916
|
-
|
|
837
|
+
return text.slice(0, 1).toUpperCase() + text.slice(1);
|
|
917
838
|
}
|
|
918
839
|
function isLight(color) {
|
|
919
|
-
|
|
920
|
-
|
|
840
|
+
const { r, g, b } = tinycolor(color).toRgb();
|
|
841
|
+
return r * 0.299 + g * 0.587 + b * 0.114 > 186;
|
|
921
842
|
}
|
|
922
843
|
|
|
923
|
-
var
|
|
924
|
-
|
|
844
|
+
var __defProp$6 = Object.defineProperty;
|
|
845
|
+
var __defProps$4 = Object.defineProperties;
|
|
846
|
+
var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
|
|
847
|
+
var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
|
|
848
|
+
var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
|
|
849
|
+
var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
|
|
850
|
+
var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
851
|
+
var __spreadValues$6 = (a, b) => {
|
|
852
|
+
for (var prop in b || (b = {}))
|
|
853
|
+
if (__hasOwnProp$6.call(b, prop))
|
|
854
|
+
__defNormalProp$6(a, prop, b[prop]);
|
|
855
|
+
if (__getOwnPropSymbols$6)
|
|
856
|
+
for (var prop of __getOwnPropSymbols$6(b)) {
|
|
857
|
+
if (__propIsEnum$6.call(b, prop))
|
|
858
|
+
__defNormalProp$6(a, prop, b[prop]);
|
|
859
|
+
}
|
|
860
|
+
return a;
|
|
861
|
+
};
|
|
862
|
+
var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
|
|
863
|
+
const AnchorLink = React.forwardRef(function AnchorLink2(props, ref) {
|
|
864
|
+
return /* @__PURE__ */ React.createElement("a", __spreadProps$4(__spreadValues$6({}, props), { ref }));
|
|
925
865
|
});
|
|
926
866
|
|
|
867
|
+
var __defProp$5 = Object.defineProperty;
|
|
868
|
+
var __defProps$3 = Object.defineProperties;
|
|
869
|
+
var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
|
|
870
|
+
var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
|
|
871
|
+
var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
|
|
872
|
+
var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
|
|
873
|
+
var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
874
|
+
var __spreadValues$5 = (a, b) => {
|
|
875
|
+
for (var prop in b || (b = {}))
|
|
876
|
+
if (__hasOwnProp$5.call(b, prop))
|
|
877
|
+
__defNormalProp$5(a, prop, b[prop]);
|
|
878
|
+
if (__getOwnPropSymbols$5)
|
|
879
|
+
for (var prop of __getOwnPropSymbols$5(b)) {
|
|
880
|
+
if (__propIsEnum$5.call(b, prop))
|
|
881
|
+
__defNormalProp$5(a, prop, b[prop]);
|
|
882
|
+
}
|
|
883
|
+
return a;
|
|
884
|
+
};
|
|
885
|
+
var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
|
|
886
|
+
var __objRest$1 = (source, exclude) => {
|
|
887
|
+
var target = {};
|
|
888
|
+
for (var prop in source)
|
|
889
|
+
if (__hasOwnProp$5.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
890
|
+
target[prop] = source[prop];
|
|
891
|
+
if (source != null && __getOwnPropSymbols$5)
|
|
892
|
+
for (var prop of __getOwnPropSymbols$5(source)) {
|
|
893
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$5.call(source, prop))
|
|
894
|
+
target[prop] = source[prop];
|
|
895
|
+
}
|
|
896
|
+
return target;
|
|
897
|
+
};
|
|
927
898
|
function omitUndefined(x) {
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
}));
|
|
899
|
+
return Object.fromEntries(
|
|
900
|
+
Object.entries(x).filter(([k, v]) => v !== void 0)
|
|
901
|
+
);
|
|
932
902
|
}
|
|
933
903
|
function filterNavMenuItemsByConditions(navMenuItems) {
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
904
|
+
return navMenuItems.filter((item) => item.condition === void 0 || item.condition).map((item) => __spreadProps$3(__spreadValues$5({}, item), {
|
|
905
|
+
routes: item.routes ? filterNavMenuItemsByConditions(item.routes) : void 0
|
|
906
|
+
}));
|
|
907
|
+
}
|
|
908
|
+
const baseStyles = `
|
|
909
|
+
.ant-pro-layout-bg-list {
|
|
910
|
+
display: none;
|
|
911
|
+
}
|
|
912
|
+
.ant-pro-layout {
|
|
913
|
+
display: flex;
|
|
914
|
+
width: 100%;
|
|
915
|
+
}
|
|
916
|
+
.ant-pro-layout .ant-pro-layout-content {
|
|
917
|
+
padding: 0;
|
|
918
|
+
}
|
|
919
|
+
`;
|
|
942
920
|
function RichLayout(_a) {
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
921
|
+
var _b = _a, {
|
|
922
|
+
children,
|
|
923
|
+
navMenuItems,
|
|
924
|
+
rootUrl = "/",
|
|
925
|
+
actionsChildren,
|
|
926
|
+
footerChildren,
|
|
927
|
+
avatarLabel,
|
|
928
|
+
avatarImage,
|
|
929
|
+
showAvatarMenu,
|
|
930
|
+
className,
|
|
931
|
+
simpleNavTheme,
|
|
932
|
+
logo,
|
|
933
|
+
logoElement
|
|
934
|
+
} = _b, layoutProps = __objRest$1(_b, [
|
|
935
|
+
"children",
|
|
936
|
+
"navMenuItems",
|
|
937
|
+
"rootUrl",
|
|
938
|
+
"actionsChildren",
|
|
939
|
+
"footerChildren",
|
|
940
|
+
"avatarLabel",
|
|
941
|
+
"avatarImage",
|
|
942
|
+
"showAvatarMenu",
|
|
943
|
+
"className",
|
|
944
|
+
"simpleNavTheme",
|
|
945
|
+
"logo",
|
|
946
|
+
"logoElement"
|
|
947
|
+
]);
|
|
948
|
+
var _a2, _b2, _c, _d, _e;
|
|
949
|
+
const isClient = useIsClient();
|
|
950
|
+
const [pathname, setPathname] = useState(void 0);
|
|
951
|
+
useEffect(() => {
|
|
952
|
+
if (typeof location !== "undefined") {
|
|
953
|
+
setPathname(location.pathname);
|
|
974
954
|
}
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
var
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
return
|
|
955
|
+
}, []);
|
|
956
|
+
const Link = (_b2 = (_a2 = usePlasmicLink) == null ? void 0 : _a2()) != null ? _b2 : AnchorLink;
|
|
957
|
+
const { token } = theme.useToken();
|
|
958
|
+
const origTextColor = token.colorTextBase;
|
|
959
|
+
function getNavBgColor() {
|
|
960
|
+
var _a3, _b3;
|
|
961
|
+
const scheme = (_a3 = simpleNavTheme == null ? void 0 : simpleNavTheme.scheme) != null ? _a3 : "default";
|
|
962
|
+
switch (scheme) {
|
|
963
|
+
case "primary":
|
|
964
|
+
return token.colorPrimary;
|
|
965
|
+
case "dark":
|
|
966
|
+
return "#011528";
|
|
967
|
+
case "custom":
|
|
968
|
+
return (_b3 = simpleNavTheme == null ? void 0 : simpleNavTheme.customBgColor) != null ? _b3 : token.colorBgBase;
|
|
969
|
+
case "light":
|
|
970
|
+
return "#fff";
|
|
971
|
+
case "default":
|
|
972
|
+
return token.colorBgBase || "#fff";
|
|
985
973
|
}
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
},
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
974
|
+
}
|
|
975
|
+
const navBgColor = getNavBgColor();
|
|
976
|
+
const isNavBgLight = isLight(navBgColor);
|
|
977
|
+
const isOrigTextLight = isLight(origTextColor);
|
|
978
|
+
const navTextColor = isNavBgLight !== isOrigTextLight ? void 0 : "";
|
|
979
|
+
if (!isClient) {
|
|
980
|
+
return null;
|
|
981
|
+
}
|
|
982
|
+
const layoutColorOverrides = isNavBgLight ? void 0 : {
|
|
983
|
+
colorBgCollapsedButton: navBgColor,
|
|
984
|
+
colorTextCollapsedButtonHover: "rgba(255,255,255,0.85)",
|
|
985
|
+
colorTextCollapsedButton: "rgba(255,255,255,0.65)",
|
|
986
|
+
colorMenuBackground: navBgColor,
|
|
987
|
+
colorBgMenuItemCollapsedHover: "rgba(0,0,0,0.06)",
|
|
988
|
+
colorBgMenuItemCollapsedSelected: "rgba(0,0,0,0.15)",
|
|
989
|
+
colorBgMenuItemCollapsedElevated: "rgba(0,0,0,0.85)",
|
|
990
|
+
colorMenuItemDivider: "rgba(255,255,255,0.15)",
|
|
991
|
+
colorBgMenuItemHover: "rgba(0,0,0,0.06)",
|
|
992
|
+
colorBgMenuItemSelected: "rgba(0,0,0,0.15)",
|
|
993
|
+
colorTextMenuSelected: "#fff",
|
|
994
|
+
colorTextMenuItemHover: "rgba(255,255,255,0.75)",
|
|
995
|
+
colorTextMenu: "rgba(255,255,255,0.75)",
|
|
996
|
+
colorTextMenuSecondary: "rgba(255,255,255,0.65)",
|
|
997
|
+
colorTextMenuTitle: "rgba(255,255,255,0.95)",
|
|
998
|
+
colorTextMenuActive: "rgba(255,255,255,0.95)",
|
|
999
|
+
colorTextSubMenuSelected: "#fff"
|
|
1000
|
+
};
|
|
1001
|
+
return /* @__PURE__ */ React.createElement("div", { className, style: { display: "flex" } }, /* @__PURE__ */ React.createElement("style", null, baseStyles), /* @__PURE__ */ React.createElement(
|
|
1002
|
+
ProLayout,
|
|
1003
|
+
__spreadProps$3(__spreadValues$5({}, layoutProps), {
|
|
1004
|
+
logo: logo != null ? logo : logoElement,
|
|
1005
|
+
headerRender: (_props, defaultDom) => /* @__PURE__ */ React.createElement(
|
|
1006
|
+
ConfigProvider,
|
|
1007
|
+
{
|
|
1008
|
+
theme: { token: omitUndefined({ colorTextBase: navTextColor }) }
|
|
1009
|
+
},
|
|
1010
|
+
/* @__PURE__ */ React.createElement(ProConfigProvider, { dark: !isNavBgLight }, defaultDom)
|
|
1011
|
+
),
|
|
1012
|
+
token: {
|
|
1013
|
+
header: omitUndefined(__spreadValues$5({
|
|
1014
|
+
colorBgHeader: navBgColor
|
|
1015
|
+
}, layoutColorOverrides)),
|
|
1016
|
+
// Ideally, we'd do something similar to headerRender above, and just specify general dark mode to specify
|
|
1017
|
+
// whether all components/text should be light.
|
|
1018
|
+
// But for some reason it doesn't work, causing the bg color to be ignored (just the default dark Menu color),
|
|
1019
|
+
// *and* the text is just dark as well.
|
|
1020
|
+
// Haven't yet been able to unravel the pro components code to figure out the proper way to do this, so just
|
|
1021
|
+
// bluntly specifying tokens here, as recommended in some GitHub issue.
|
|
1022
|
+
sider: layoutColorOverrides
|
|
1023
|
+
},
|
|
1024
|
+
layout: (_c = layoutProps.layout) != null ? _c : "top",
|
|
1025
|
+
fixedHeader: (_d = layoutProps.fixedHeader) != null ? _d : false,
|
|
1026
|
+
fixSiderbar: (
|
|
1027
|
+
// Doesn't stretch full height if you set this to false and you're in mix mode.
|
|
1028
|
+
layoutProps.layout === "mix" ? void 0 : (_e = layoutProps.fixSiderbar) != null ? _e : false
|
|
1029
|
+
),
|
|
1030
|
+
splitMenus: layoutProps.layout === "mix",
|
|
1031
|
+
route: {
|
|
1032
|
+
path: rootUrl,
|
|
1033
|
+
routes: navMenuItems ? filterNavMenuItemsByConditions(navMenuItems) : void 0
|
|
1034
|
+
},
|
|
1035
|
+
location: {
|
|
1036
|
+
pathname
|
|
1037
|
+
},
|
|
1038
|
+
menu: {
|
|
1039
|
+
// collapsedShowGroupTitle: true,
|
|
1040
|
+
defaultOpenAll: true
|
|
1041
|
+
// hideMenuWhenCollapsed: true,
|
|
1042
|
+
},
|
|
1043
|
+
avatarProps: showAvatarMenu ? {
|
|
1044
|
+
src: avatarImage,
|
|
1045
|
+
size: "small",
|
|
1046
|
+
title: avatarLabel,
|
|
1047
|
+
render: (_props, dom) => {
|
|
1048
|
+
return /* @__PURE__ */ React.createElement(
|
|
1049
|
+
Dropdown,
|
|
1050
|
+
{
|
|
1051
|
+
menu: {
|
|
1052
|
+
items: [
|
|
1053
|
+
{
|
|
1054
|
+
key: "logout",
|
|
1055
|
+
icon: /* @__PURE__ */ React.createElement(LogoutOutlined, null),
|
|
1056
|
+
label: "Sign out"
|
|
1057
|
+
}
|
|
1058
|
+
]
|
|
1059
|
+
}
|
|
1060
|
+
},
|
|
1061
|
+
dom
|
|
1062
|
+
);
|
|
1063
|
+
}
|
|
1064
|
+
} : void 0,
|
|
1065
|
+
actionsRender: (_props) => {
|
|
1066
|
+
return [actionsChildren];
|
|
1067
|
+
},
|
|
1068
|
+
menuFooterRender: (props) => {
|
|
1069
|
+
if (props == null ? void 0 : props.collapsed)
|
|
1070
|
+
return void 0;
|
|
1071
|
+
return footerChildren;
|
|
1072
|
+
},
|
|
1073
|
+
onMenuHeaderClick: (e) => console.log(e),
|
|
1074
|
+
menuItemRender: (item, dom) => /* @__PURE__ */ React.createElement(Link, { href: item.path }, dom),
|
|
1075
|
+
headerTitleRender: (logo2, title, _) => {
|
|
1076
|
+
return /* @__PURE__ */ React.createElement(Link, { href: rootUrl }, logo2, title);
|
|
1077
|
+
}
|
|
1078
|
+
}),
|
|
1079
|
+
children
|
|
1080
|
+
));
|
|
1081
1081
|
}
|
|
1082
1082
|
|
|
1083
|
+
var __defProp$4 = Object.defineProperty;
|
|
1084
|
+
var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
|
|
1085
|
+
var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
|
|
1086
|
+
var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
|
|
1087
|
+
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1088
|
+
var __spreadValues$4 = (a, b) => {
|
|
1089
|
+
for (var prop in b || (b = {}))
|
|
1090
|
+
if (__hasOwnProp$4.call(b, prop))
|
|
1091
|
+
__defNormalProp$4(a, prop, b[prop]);
|
|
1092
|
+
if (__getOwnPropSymbols$4)
|
|
1093
|
+
for (var prop of __getOwnPropSymbols$4(b)) {
|
|
1094
|
+
if (__propIsEnum$4.call(b, prop))
|
|
1095
|
+
__defNormalProp$4(a, prop, b[prop]);
|
|
1096
|
+
}
|
|
1097
|
+
return a;
|
|
1098
|
+
};
|
|
1083
1099
|
function generateNavMenuType(isNested, remainingDepth, displayName, defaultValue) {
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1100
|
+
return {
|
|
1101
|
+
displayName: displayName ? displayName : "Nested items",
|
|
1102
|
+
type: "array",
|
|
1103
|
+
defaultValue,
|
|
1104
|
+
advanced: isNested,
|
|
1105
|
+
itemType: {
|
|
1106
|
+
type: "object",
|
|
1107
|
+
nameFunc: (item) => item.name || (!displayName ? "Unnamed nested item" : "Unnamed item"),
|
|
1108
|
+
fields: __spreadValues$4({
|
|
1109
|
+
path: "href",
|
|
1110
|
+
name: "string",
|
|
1111
|
+
condition: {
|
|
1112
|
+
advanced: true,
|
|
1113
|
+
displayName: "Show only if",
|
|
1114
|
+
type: "exprEditor"
|
|
1115
|
+
}
|
|
1116
|
+
}, remainingDepth === 0 ? {} : {
|
|
1117
|
+
routes: generateNavMenuType(true, remainingDepth - 1)
|
|
1118
|
+
})
|
|
1119
|
+
}
|
|
1120
|
+
};
|
|
1105
1121
|
}
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
type: "choice",
|
|
1162
|
-
options: ["default", "primary", "light", "dark", "custom"].map(function (v) { return ({
|
|
1163
|
-
label: capitalize(v),
|
|
1164
|
-
value: v,
|
|
1165
|
-
}); }),
|
|
1166
|
-
defaultValueHint: "default",
|
|
1167
|
-
},
|
|
1168
|
-
customBgColor: {
|
|
1169
|
-
type: "color",
|
|
1170
|
-
displayName: "Custom color",
|
|
1171
|
-
hidden: function (props) { var _a; return !(((_a = props.simpleNavTheme) === null || _a === void 0 ? void 0 : _a.scheme) === "custom"); },
|
|
1172
|
-
defaultValue: "#D73B58",
|
|
1173
|
-
},
|
|
1174
|
-
},
|
|
1175
|
-
},
|
|
1176
|
-
// Advanced, show later
|
|
1177
|
-
/*
|
|
1178
|
-
siderMenuType: {
|
|
1179
|
-
displayName: "Sidebar mode",
|
|
1180
|
-
type: "choice",
|
|
1181
|
-
options: ["sub", "group"].map((value) => ({
|
|
1182
|
-
value,
|
|
1183
|
-
label: capitalize(value),
|
|
1184
|
-
})),
|
|
1185
|
-
defaultValue: "sub",
|
|
1186
|
-
},
|
|
1187
|
-
contentWidth: {
|
|
1188
|
-
displayName: "Content width",
|
|
1122
|
+
const richLayoutMeta = {
|
|
1123
|
+
name: "hostless-rich-layout",
|
|
1124
|
+
displayName: "Rich App Layout",
|
|
1125
|
+
props: {
|
|
1126
|
+
children: {
|
|
1127
|
+
type: "slot",
|
|
1128
|
+
unstable__isMainContentSlot: true
|
|
1129
|
+
},
|
|
1130
|
+
actionsChildren: {
|
|
1131
|
+
type: "slot",
|
|
1132
|
+
hidePlaceholder: true
|
|
1133
|
+
},
|
|
1134
|
+
title: {
|
|
1135
|
+
displayName: "Title",
|
|
1136
|
+
type: "string",
|
|
1137
|
+
defaultValue: "App title"
|
|
1138
|
+
},
|
|
1139
|
+
logo: {
|
|
1140
|
+
displayName: "Logo",
|
|
1141
|
+
type: "imageUrl",
|
|
1142
|
+
hidden: (ps) => !ps.logo
|
|
1143
|
+
},
|
|
1144
|
+
logoElement: {
|
|
1145
|
+
type: "slot",
|
|
1146
|
+
displayName: "Logo",
|
|
1147
|
+
defaultValue: {
|
|
1148
|
+
type: "img",
|
|
1149
|
+
src: "https://static1.plasmic.app/fake-logo.svg"
|
|
1150
|
+
},
|
|
1151
|
+
hidden: (ps) => !!ps.logo
|
|
1152
|
+
},
|
|
1153
|
+
navMenuItems: generateNavMenuType(false, 2, "Nav menu items", [
|
|
1154
|
+
{
|
|
1155
|
+
path: "/",
|
|
1156
|
+
name: "Link 1"
|
|
1157
|
+
},
|
|
1158
|
+
{
|
|
1159
|
+
path: "/",
|
|
1160
|
+
name: "Link 2"
|
|
1161
|
+
}
|
|
1162
|
+
]),
|
|
1163
|
+
layout: {
|
|
1164
|
+
displayName: "Layout",
|
|
1165
|
+
type: "choice",
|
|
1166
|
+
options: ["side", "top", "mix"].map((value) => ({
|
|
1167
|
+
value,
|
|
1168
|
+
label: capitalize(value)
|
|
1169
|
+
})),
|
|
1170
|
+
defaultValueHint: "top"
|
|
1171
|
+
},
|
|
1172
|
+
simpleNavTheme: {
|
|
1173
|
+
displayName: "Theme",
|
|
1174
|
+
type: "object",
|
|
1175
|
+
fields: {
|
|
1176
|
+
scheme: {
|
|
1189
1177
|
type: "choice",
|
|
1190
|
-
options: ["
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
hidden: function (ps) { var _a; return ((_a = ps.layout) !== null && _a !== void 0 ? _a : "top") !== "top"; },
|
|
1198
|
-
defaultValueHint: false,
|
|
1199
|
-
},
|
|
1200
|
-
fixSiderbar: {
|
|
1201
|
-
displayName: "Sticky sidebar",
|
|
1202
|
-
type: "boolean",
|
|
1203
|
-
hidden: function (ps) { var _a; return ((_a = ps.layout) !== null && _a !== void 0 ? _a : "top") !== "side"; },
|
|
1204
|
-
defaultValueHint: false,
|
|
1205
|
-
},
|
|
1206
|
-
/*
|
|
1207
|
-
showAvatarMenu: {
|
|
1208
|
-
displayName: "Show avatar",
|
|
1209
|
-
type: "boolean",
|
|
1210
|
-
defaultValue: true,
|
|
1211
|
-
},
|
|
1212
|
-
avatarLabel: {
|
|
1213
|
-
displayName: "Avatar label",
|
|
1214
|
-
type: "string",
|
|
1215
|
-
defaultValue: "User Name",
|
|
1216
|
-
},
|
|
1217
|
-
avatarImage: {
|
|
1218
|
-
displayName: "Avatar image",
|
|
1219
|
-
type: "imageUrl",
|
|
1220
|
-
defaultValue:
|
|
1221
|
-
"https://gw.alipayobjects.com/zos/antfincdn/efFD%24IOql2/weixintupian_20170331104822.jpg",
|
|
1222
|
-
},
|
|
1223
|
-
*/
|
|
1224
|
-
menu: {
|
|
1225
|
-
displayName: "Menu",
|
|
1226
|
-
type: "object",
|
|
1227
|
-
fields: {
|
|
1228
|
-
defaultOpenAll: {
|
|
1229
|
-
displayName: "Default open all",
|
|
1230
|
-
type: "boolean",
|
|
1231
|
-
},
|
|
1232
|
-
hideMenuWhenCollapsed: {
|
|
1233
|
-
// displayName: "",
|
|
1234
|
-
type: "boolean",
|
|
1235
|
-
},
|
|
1236
|
-
},
|
|
1178
|
+
options: ["default", "primary", "light", "dark", "custom"].map(
|
|
1179
|
+
(v) => ({
|
|
1180
|
+
label: capitalize(v),
|
|
1181
|
+
value: v
|
|
1182
|
+
})
|
|
1183
|
+
),
|
|
1184
|
+
defaultValueHint: "default"
|
|
1237
1185
|
},
|
|
1186
|
+
customBgColor: {
|
|
1187
|
+
type: "color",
|
|
1188
|
+
displayName: "Custom color",
|
|
1189
|
+
hidden: (props) => {
|
|
1190
|
+
var _a;
|
|
1191
|
+
return !(((_a = props.simpleNavTheme) == null ? void 0 : _a.scheme) === "custom");
|
|
1192
|
+
},
|
|
1193
|
+
defaultValue: "#D73B58"
|
|
1194
|
+
}
|
|
1195
|
+
}
|
|
1238
1196
|
},
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1197
|
+
// Advanced, show later
|
|
1198
|
+
/*
|
|
1199
|
+
siderMenuType: {
|
|
1200
|
+
displayName: "Sidebar mode",
|
|
1201
|
+
type: "choice",
|
|
1202
|
+
options: ["sub", "group"].map((value) => ({
|
|
1203
|
+
value,
|
|
1204
|
+
label: capitalize(value),
|
|
1205
|
+
})),
|
|
1206
|
+
defaultValue: "sub",
|
|
1243
1207
|
},
|
|
1244
|
-
|
|
1245
|
-
|
|
1208
|
+
contentWidth: {
|
|
1209
|
+
displayName: "Content width",
|
|
1210
|
+
type: "choice",
|
|
1211
|
+
options: ["Fluid", "Fixed"],
|
|
1212
|
+
defaultValueHint: "Fluid",
|
|
1213
|
+
},
|
|
1214
|
+
*/
|
|
1215
|
+
fixedHeader: {
|
|
1216
|
+
displayName: "Sticky header",
|
|
1217
|
+
type: "boolean",
|
|
1218
|
+
hidden: (ps) => {
|
|
1219
|
+
var _a;
|
|
1220
|
+
return ((_a = ps.layout) != null ? _a : "top") !== "top";
|
|
1221
|
+
},
|
|
1222
|
+
defaultValueHint: false
|
|
1223
|
+
},
|
|
1224
|
+
fixSiderbar: {
|
|
1225
|
+
displayName: "Sticky sidebar",
|
|
1226
|
+
type: "boolean",
|
|
1227
|
+
hidden: (ps) => {
|
|
1228
|
+
var _a;
|
|
1229
|
+
return ((_a = ps.layout) != null ? _a : "top") !== "side";
|
|
1230
|
+
},
|
|
1231
|
+
defaultValueHint: false
|
|
1232
|
+
},
|
|
1233
|
+
/*
|
|
1234
|
+
showAvatarMenu: {
|
|
1235
|
+
displayName: "Show avatar",
|
|
1236
|
+
type: "boolean",
|
|
1237
|
+
defaultValue: true,
|
|
1238
|
+
},
|
|
1239
|
+
avatarLabel: {
|
|
1240
|
+
displayName: "Avatar label",
|
|
1241
|
+
type: "string",
|
|
1242
|
+
defaultValue: "User Name",
|
|
1243
|
+
},
|
|
1244
|
+
avatarImage: {
|
|
1245
|
+
displayName: "Avatar image",
|
|
1246
|
+
type: "imageUrl",
|
|
1247
|
+
defaultValue:
|
|
1248
|
+
"https://gw.alipayobjects.com/zos/antfincdn/efFD%24IOql2/weixintupian_20170331104822.jpg",
|
|
1249
|
+
},
|
|
1250
|
+
*/
|
|
1251
|
+
menu: {
|
|
1252
|
+
displayName: "Menu",
|
|
1253
|
+
type: "object",
|
|
1254
|
+
fields: {
|
|
1255
|
+
defaultOpenAll: {
|
|
1256
|
+
displayName: "Default open all",
|
|
1257
|
+
type: "boolean"
|
|
1258
|
+
},
|
|
1259
|
+
hideMenuWhenCollapsed: {
|
|
1260
|
+
// displayName: "",
|
|
1261
|
+
type: "boolean"
|
|
1262
|
+
}
|
|
1263
|
+
}
|
|
1264
|
+
}
|
|
1265
|
+
},
|
|
1266
|
+
defaultStyles: {
|
|
1267
|
+
width: "full-bleed",
|
|
1268
|
+
height: "stretch",
|
|
1269
|
+
minHeight: "100vh"
|
|
1270
|
+
},
|
|
1271
|
+
importName: "RichLayout",
|
|
1272
|
+
importPath: "@plasmicpkgs/plasmic-rich-components"
|
|
1246
1273
|
};
|
|
1247
1274
|
function registerRichLayout(loader) {
|
|
1248
|
-
|
|
1275
|
+
registerComponentHelper(loader, RichLayout, richLayoutMeta);
|
|
1249
1276
|
}
|
|
1250
1277
|
|
|
1251
1278
|
function useSortedFilteredData(data, columns) {
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1279
|
+
const [search, setSearch] = useState("");
|
|
1280
|
+
const [sortState, setSortState] = useState(void 0);
|
|
1281
|
+
const finalData = React.useMemo(() => {
|
|
1282
|
+
var _a;
|
|
1283
|
+
const filtered = (_a = data == null ? void 0 : data.data) == null ? void 0 : _a.filter(
|
|
1284
|
+
(row) => fastStringify(Object.values(row)).toLowerCase().includes(search)
|
|
1285
|
+
);
|
|
1286
|
+
const sorted = (sortState == null ? void 0 : sortState.sorter.column) ? (
|
|
1287
|
+
// We use .sort() rather than sortBy to use localeCompare
|
|
1288
|
+
(() => {
|
|
1289
|
+
var _a2;
|
|
1290
|
+
const cconfig = columns.find(
|
|
1291
|
+
(cc) => {
|
|
1292
|
+
var _a3;
|
|
1293
|
+
return cc.key === ((_a3 = sortState == null ? void 0 : sortState.sorter.column) == null ? void 0 : _a3.key);
|
|
1294
|
+
}
|
|
1295
|
+
);
|
|
1296
|
+
const expr = (_a2 = cconfig.expr) != null ? _a2 : (x) => x;
|
|
1297
|
+
return (filtered != null ? filtered : []).sort((aa, bb) => {
|
|
1298
|
+
var _a3, _b;
|
|
1299
|
+
const a = (_a3 = expr(aa, cconfig.fieldId ? aa == null ? void 0 : aa[cconfig.fieldId] : null)) != null ? _a3 : null, b = (_b = expr(bb, cconfig.fieldId ? bb == null ? void 0 : bb[cconfig.fieldId] : null)) != null ? _b : null;
|
|
1300
|
+
return typeof a === "string" ? a.localeCompare(b != null ? b : "") : typeof b === "string" ? -b.localeCompare(a != null ? a : "") : a - b;
|
|
1258
1301
|
});
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
? a.localeCompare(b !== null && b !== void 0 ? b : "")
|
|
1271
|
-
: typeof b === "string"
|
|
1272
|
-
? -b.localeCompare(a !== null && a !== void 0 ? a : "")
|
|
1273
|
-
: a - b;
|
|
1274
|
-
});
|
|
1275
|
-
})()
|
|
1276
|
-
: filtered;
|
|
1277
|
-
var reversed = (sortState === null || sortState === void 0 ? void 0 : sortState.sorter.order) === "descend" ? sorted === null || sorted === void 0 ? void 0 : sorted.reverse() : sorted;
|
|
1278
|
-
return reversed;
|
|
1279
|
-
}, [data, columns, sortState, search]);
|
|
1280
|
-
return {
|
|
1281
|
-
finalData: finalData,
|
|
1282
|
-
search: search,
|
|
1283
|
-
setSearch: setSearch,
|
|
1284
|
-
setSortState: setSortState,
|
|
1285
|
-
};
|
|
1302
|
+
})()
|
|
1303
|
+
) : filtered;
|
|
1304
|
+
const reversed = (sortState == null ? void 0 : sortState.sorter.order) === "descend" ? sorted == null ? void 0 : sorted.reverse() : sorted;
|
|
1305
|
+
return reversed;
|
|
1306
|
+
}, [data, columns, sortState, search]);
|
|
1307
|
+
return {
|
|
1308
|
+
finalData,
|
|
1309
|
+
search,
|
|
1310
|
+
setSearch,
|
|
1311
|
+
setSortState
|
|
1312
|
+
};
|
|
1286
1313
|
}
|
|
1287
1314
|
function deriveRowKey(data, rowKey) {
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1315
|
+
var _a;
|
|
1316
|
+
if (rowKey) {
|
|
1317
|
+
return rowKey;
|
|
1318
|
+
}
|
|
1319
|
+
const schema = data == null ? void 0 : data.schema;
|
|
1320
|
+
if (schema) {
|
|
1321
|
+
return (_a = schema.fields[0]) == null ? void 0 : _a.id;
|
|
1322
|
+
}
|
|
1323
|
+
return void 0;
|
|
1297
1324
|
}
|
|
1298
1325
|
function deriveKeyOfRow(row, rowKey) {
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
return undefined;
|
|
1307
|
-
}
|
|
1326
|
+
if (typeof rowKey === "function") {
|
|
1327
|
+
return rowKey(row);
|
|
1328
|
+
} else if (typeof rowKey === "string") {
|
|
1329
|
+
return row[rowKey];
|
|
1330
|
+
} else {
|
|
1331
|
+
return void 0;
|
|
1332
|
+
}
|
|
1308
1333
|
}
|
|
1309
1334
|
function renderActions(rowActions, row, data, rowKey) {
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1335
|
+
return rowActions.map((_action) => {
|
|
1336
|
+
var _a;
|
|
1337
|
+
if (_action.type === "item") {
|
|
1338
|
+
return /* @__PURE__ */ React.createElement(
|
|
1339
|
+
"a",
|
|
1340
|
+
{
|
|
1341
|
+
key: _action.label,
|
|
1342
|
+
style: {
|
|
1343
|
+
whiteSpace: "nowrap"
|
|
1344
|
+
},
|
|
1345
|
+
onClick: () => {
|
|
1346
|
+
var _a2;
|
|
1347
|
+
return (_a2 = _action.onClick) == null ? void 0 : _a2.call(
|
|
1348
|
+
_action,
|
|
1349
|
+
deriveKeyOfRow(row, deriveRowKey(data, rowKey)),
|
|
1350
|
+
row
|
|
1351
|
+
);
|
|
1352
|
+
}
|
|
1353
|
+
},
|
|
1354
|
+
_action.label
|
|
1355
|
+
);
|
|
1356
|
+
} else {
|
|
1357
|
+
return /* @__PURE__ */ React.createElement(
|
|
1358
|
+
Dropdown,
|
|
1359
|
+
{
|
|
1360
|
+
key: _action.label,
|
|
1361
|
+
menu: {
|
|
1362
|
+
items: ((_a = _action.children) != null ? _a : []).map((child) => ({
|
|
1363
|
+
key: child.label,
|
|
1364
|
+
label: child.label,
|
|
1365
|
+
onClick: () => {
|
|
1366
|
+
var _a2;
|
|
1367
|
+
return (_a2 = child.onClick) == null ? void 0 : _a2.call(
|
|
1368
|
+
child,
|
|
1369
|
+
deriveKeyOfRow(row, deriveRowKey(data, rowKey)),
|
|
1370
|
+
row
|
|
1371
|
+
);
|
|
1372
|
+
}
|
|
1373
|
+
}))
|
|
1374
|
+
}
|
|
1375
|
+
},
|
|
1376
|
+
/* @__PURE__ */ React.createElement(
|
|
1377
|
+
"a",
|
|
1378
|
+
{
|
|
1379
|
+
href: "javascript: void 0",
|
|
1380
|
+
style: {
|
|
1381
|
+
whiteSpace: "nowrap"
|
|
1382
|
+
}
|
|
1383
|
+
},
|
|
1384
|
+
_action.label
|
|
1385
|
+
)
|
|
1386
|
+
);
|
|
1387
|
+
}
|
|
1388
|
+
});
|
|
1336
1389
|
}
|
|
1337
1390
|
|
|
1338
|
-
|
|
1391
|
+
var __defProp$3 = Object.defineProperty;
|
|
1392
|
+
var __defProps$2 = Object.defineProperties;
|
|
1393
|
+
var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
|
|
1394
|
+
var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
|
|
1395
|
+
var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
|
|
1396
|
+
var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
|
|
1397
|
+
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1398
|
+
var __spreadValues$3 = (a, b) => {
|
|
1399
|
+
for (var prop in b || (b = {}))
|
|
1400
|
+
if (__hasOwnProp$3.call(b, prop))
|
|
1401
|
+
__defNormalProp$3(a, prop, b[prop]);
|
|
1402
|
+
if (__getOwnPropSymbols$3)
|
|
1403
|
+
for (var prop of __getOwnPropSymbols$3(b)) {
|
|
1404
|
+
if (__propIsEnum$3.call(b, prop))
|
|
1405
|
+
__defNormalProp$3(a, prop, b[prop]);
|
|
1406
|
+
}
|
|
1407
|
+
return a;
|
|
1408
|
+
};
|
|
1409
|
+
var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
|
|
1339
1410
|
function RichTable(props) {
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1411
|
+
const {
|
|
1412
|
+
className,
|
|
1413
|
+
data: rawData = {
|
|
1414
|
+
data: [],
|
|
1415
|
+
schema: {
|
|
1416
|
+
id: "inferred",
|
|
1417
|
+
fields: [
|
|
1418
|
+
{
|
|
1419
|
+
id: "id",
|
|
1420
|
+
type: "string",
|
|
1421
|
+
readOnly: false
|
|
1422
|
+
}
|
|
1423
|
+
]
|
|
1424
|
+
}
|
|
1425
|
+
},
|
|
1355
1426
|
// children,
|
|
1356
|
-
pagination =
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
} })),
|
|
1406
|
-
React.createElement("style", { dangerouslySetInnerHTML: {
|
|
1407
|
-
__html: "\n :where(.css-dev-only-do-not-override-1p704s4).ant-pro-table-column-setting-overlay .ant-tree-treenode:hover .ant-pro-table-column-setting-list-item-option {\n display: none;\n }\n .plasmic-table-row-clickable {\n cursor: pointer;\n }\n .ant-pro-table-list-toolbar-right {\n flex-wrap: initial;\n flex-shrink: 0;\n }\n .ant-pro-table, .ant-pro-table > .ant-pro-card, .ant-pro-table .ant-table-wrapper, .ant-pro-table .ant-spin-nested-loading, .ant-pro-table .ant-table-container {\n height: 100%;\n }\n .ant-pro-table .ant-spin-container {\n height: 100%;\n display: flex;\n flex-direction: column;\n }\n .ant-pro-table .ant-table {\n flex-grow: 1;\n min-height: 0;\n }\n .ant-pro-table .ant-pagination {\n flex-shrink: 0;\n }\n .ant-pro-table .ant-table-content {\n overflow: auto !important;\n height: 100%;\n }\n .ant-pro-table > .ant-pro-card > .ant-pro-card-body {\n display: flex;\n flex-direction: column;\n }\n .ant-pro-table .ant-table-wrapper {\n flex-grow: 1;\n min-height: 0;\n }\n .ant-pro-table .ant-table-thead > tr > th, .ant-pro-table .ant-table-thead > tr > td.ant-table-selection-column {\n position: sticky;\n top: 0;\n z-index: 2;\n }\n .ant-pro-table .ant-table-thead > tr > th.ant-table-cell-fix-left, .ant-pro-table .ant-table-thead > tr > th.ant-table-cell-fix-right {\n z-index: 3;\n }\n .ant-pro-table .ant-table-tbody > tr > td {\n z-index: 0;\n }\n .ant-pro-table .ant-table-tbody > tr > td.ant-table-cell-fix-left,.ant-pro-table .ant-table-tbody > tr > td.ant-table-cell-fix-right {\n z-index: 1;\n }\n ".concat(scopeClassName && hideSelectionBar
|
|
1408
|
-
? "\n .".concat(scopeClassName, " .ant-pro-table-alert {\n display: none;\n }\n ")
|
|
1409
|
-
: "", "\n "),
|
|
1410
|
-
} })));
|
|
1411
|
-
}
|
|
1412
|
-
var defaultColumnConfig$1 = function () {
|
|
1413
|
-
return ({
|
|
1414
|
-
key: mkShortId(),
|
|
1415
|
-
isEditableExpr: function () { return false; },
|
|
1416
|
-
disableSorting: false,
|
|
1417
|
-
sortByExpr: undefined,
|
|
1418
|
-
isHidden: false,
|
|
1419
|
-
formatting: {
|
|
1420
|
-
styles: {},
|
|
1421
|
-
align: "left",
|
|
1422
|
-
freeze: "off",
|
|
1427
|
+
pagination = true,
|
|
1428
|
+
defaultSize,
|
|
1429
|
+
title,
|
|
1430
|
+
addHref,
|
|
1431
|
+
pageSize = 10,
|
|
1432
|
+
hideSearch,
|
|
1433
|
+
hideDensity = true,
|
|
1434
|
+
hideColumnPicker,
|
|
1435
|
+
hideExports,
|
|
1436
|
+
hideSelectionBar = true,
|
|
1437
|
+
rowKey,
|
|
1438
|
+
scopeClassName
|
|
1439
|
+
} = props;
|
|
1440
|
+
const data = normalizeData(rawData);
|
|
1441
|
+
const { columnDefinitions, normalized } = useColumnDefinitions(data, props);
|
|
1442
|
+
const actionRef = useRef();
|
|
1443
|
+
const { finalData, search, setSearch, setSortState } = useSortedFilteredData(
|
|
1444
|
+
data,
|
|
1445
|
+
normalized
|
|
1446
|
+
);
|
|
1447
|
+
const rowSelectionProps = useRowSelectionProps(data, props);
|
|
1448
|
+
const isClient = useIsClient();
|
|
1449
|
+
if (!isClient) {
|
|
1450
|
+
return null;
|
|
1451
|
+
}
|
|
1452
|
+
return /* @__PURE__ */ React.createElement("div", { className: `${className} ${scopeClassName != null ? scopeClassName : ""}` }, /* @__PURE__ */ React.createElement(
|
|
1453
|
+
ProTable,
|
|
1454
|
+
__spreadProps$2(__spreadValues$3({
|
|
1455
|
+
rowClassName: props.onRowClick || props.canSelectRows === "click" ? "plasmic-table-row-clickable" : void 0,
|
|
1456
|
+
actionRef,
|
|
1457
|
+
columns: columnDefinitions,
|
|
1458
|
+
onChange: (_pagination, _filters, sorter, _extra) => {
|
|
1459
|
+
setSortState({ sorter });
|
|
1460
|
+
},
|
|
1461
|
+
style: {
|
|
1462
|
+
width: "100%"
|
|
1463
|
+
},
|
|
1464
|
+
cardProps: {
|
|
1465
|
+
ghost: true
|
|
1466
|
+
}
|
|
1467
|
+
}, rowSelectionProps), {
|
|
1468
|
+
dataSource: finalData,
|
|
1469
|
+
rowKey: deriveRowKey(data, rowKey),
|
|
1470
|
+
defaultSize,
|
|
1471
|
+
editable: { type: "multiple" },
|
|
1472
|
+
search: false,
|
|
1473
|
+
options: {
|
|
1474
|
+
setting: hideColumnPicker ? false : {
|
|
1475
|
+
listsHeight: 400
|
|
1423
1476
|
},
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
}
|
|
1477
|
+
reload: false,
|
|
1478
|
+
density: !hideDensity
|
|
1479
|
+
},
|
|
1480
|
+
pagination: pagination ? {
|
|
1481
|
+
pageSize,
|
|
1482
|
+
onChange: (page) => console.log(page),
|
|
1483
|
+
showSizeChanger: false
|
|
1484
|
+
} : false,
|
|
1485
|
+
dateFormatter: "string",
|
|
1486
|
+
headerTitle: title,
|
|
1487
|
+
toolbar: {
|
|
1488
|
+
search: !hideSearch ? {
|
|
1489
|
+
value: search,
|
|
1490
|
+
onChange: (e) => setSearch(e.target.value),
|
|
1491
|
+
onSearch: () => {
|
|
1492
|
+
return;
|
|
1493
|
+
},
|
|
1494
|
+
placeholder: "Search"
|
|
1495
|
+
} : void 0
|
|
1496
|
+
},
|
|
1497
|
+
toolBarRender: () => [
|
|
1498
|
+
addHref && /* @__PURE__ */ React.createElement(
|
|
1499
|
+
Button,
|
|
1500
|
+
{
|
|
1501
|
+
key: "button",
|
|
1502
|
+
icon: /* @__PURE__ */ React.createElement(PlusOutlined, null),
|
|
1503
|
+
type: "primary",
|
|
1504
|
+
href: addHref
|
|
1505
|
+
},
|
|
1506
|
+
"Add"
|
|
1507
|
+
),
|
|
1508
|
+
!hideExports && /* @__PURE__ */ React.createElement(ExportMenu, { data })
|
|
1509
|
+
].filter((x) => !!x)
|
|
1510
|
+
})
|
|
1511
|
+
), /* @__PURE__ */ React.createElement(
|
|
1512
|
+
"style",
|
|
1513
|
+
{
|
|
1514
|
+
dangerouslySetInnerHTML: {
|
|
1515
|
+
__html: `
|
|
1516
|
+
:where(.css-dev-only-do-not-override-1p704s4).ant-pro-table-column-setting-overlay .ant-tree-treenode:hover .ant-pro-table-column-setting-list-item-option {
|
|
1517
|
+
display: none;
|
|
1518
|
+
}
|
|
1519
|
+
.plasmic-table-row-clickable {
|
|
1520
|
+
cursor: pointer;
|
|
1521
|
+
}
|
|
1522
|
+
.ant-pro-table-list-toolbar-right {
|
|
1523
|
+
flex-wrap: initial;
|
|
1524
|
+
flex-shrink: 0;
|
|
1525
|
+
}
|
|
1526
|
+
.ant-pro-table, .ant-pro-table > .ant-pro-card, .ant-pro-table .ant-table-wrapper, .ant-pro-table .ant-spin-nested-loading, .ant-pro-table .ant-table-container {
|
|
1527
|
+
height: 100%;
|
|
1528
|
+
}
|
|
1529
|
+
.ant-pro-table .ant-spin-container {
|
|
1530
|
+
height: 100%;
|
|
1531
|
+
display: flex;
|
|
1532
|
+
flex-direction: column;
|
|
1533
|
+
}
|
|
1534
|
+
.ant-pro-table .ant-table {
|
|
1535
|
+
flex-grow: 1;
|
|
1536
|
+
min-height: 0;
|
|
1537
|
+
}
|
|
1538
|
+
.ant-pro-table .ant-pagination {
|
|
1539
|
+
flex-shrink: 0;
|
|
1540
|
+
}
|
|
1541
|
+
.ant-pro-table .ant-table-content {
|
|
1542
|
+
overflow: auto !important;
|
|
1543
|
+
height: 100%;
|
|
1544
|
+
}
|
|
1545
|
+
.ant-pro-table > .ant-pro-card > .ant-pro-card-body {
|
|
1546
|
+
display: flex;
|
|
1547
|
+
flex-direction: column;
|
|
1548
|
+
}
|
|
1549
|
+
.ant-pro-table .ant-table-wrapper {
|
|
1550
|
+
flex-grow: 1;
|
|
1551
|
+
min-height: 0;
|
|
1552
|
+
}
|
|
1553
|
+
.ant-pro-table .ant-table-thead > tr > th, .ant-pro-table .ant-table-thead > tr > td.ant-table-selection-column {
|
|
1554
|
+
position: sticky;
|
|
1555
|
+
top: 0;
|
|
1556
|
+
z-index: 2;
|
|
1557
|
+
}
|
|
1558
|
+
.ant-pro-table .ant-table-thead > tr > th.ant-table-cell-fix-left, .ant-pro-table .ant-table-thead > tr > th.ant-table-cell-fix-right {
|
|
1559
|
+
z-index: 3;
|
|
1560
|
+
}
|
|
1561
|
+
.ant-pro-table .ant-table-tbody > tr > td {
|
|
1562
|
+
z-index: 0;
|
|
1563
|
+
}
|
|
1564
|
+
.ant-pro-table .ant-table-tbody > tr > td.ant-table-cell-fix-left,.ant-pro-table .ant-table-tbody > tr > td.ant-table-cell-fix-right {
|
|
1565
|
+
z-index: 1;
|
|
1566
|
+
}
|
|
1567
|
+
${scopeClassName && hideSelectionBar ? `
|
|
1568
|
+
.${scopeClassName} .ant-pro-table-alert {
|
|
1569
|
+
display: none;
|
|
1570
|
+
}
|
|
1571
|
+
` : ""}
|
|
1572
|
+
`
|
|
1573
|
+
}
|
|
1574
|
+
}
|
|
1575
|
+
));
|
|
1576
|
+
}
|
|
1577
|
+
const defaultColumnConfig$1 = () => ({
|
|
1578
|
+
key: mkShortId(),
|
|
1579
|
+
isEditableExpr: () => false,
|
|
1580
|
+
disableSorting: false,
|
|
1581
|
+
sortByExpr: void 0,
|
|
1582
|
+
isHidden: false,
|
|
1583
|
+
formatting: {
|
|
1584
|
+
styles: {},
|
|
1585
|
+
align: "left",
|
|
1586
|
+
freeze: "off"
|
|
1587
|
+
},
|
|
1588
|
+
dataType: "auto"
|
|
1589
|
+
});
|
|
1427
1590
|
function useColumnDefinitions(data, props) {
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
},
|
|
1468
|
-
render: function (value, record, rowIndex) {
|
|
1469
|
-
return renderValue(record, cconfig);
|
|
1470
|
-
},
|
|
1471
|
-
};
|
|
1472
|
-
return columnDefinition;
|
|
1473
|
-
});
|
|
1474
|
-
var rowKey = props.rowKey;
|
|
1475
|
-
if (rowActions && rowActions.length > 0) {
|
|
1476
|
-
columnDefinitions.push({
|
|
1477
|
-
title: "Actions",
|
|
1478
|
-
valueType: "option",
|
|
1479
|
-
key: "__plasmicActions",
|
|
1480
|
-
fixed: "right",
|
|
1481
|
-
className: props.themeResetClassName,
|
|
1482
|
-
render: function (_text, row) { return __spreadArray([], renderActions(rowActions, row, data, rowKey), true); },
|
|
1483
|
-
});
|
|
1591
|
+
const { fields, setControlContextData, rowActions } = props;
|
|
1592
|
+
return React.useMemo(() => {
|
|
1593
|
+
const schema = data == null ? void 0 : data.schema;
|
|
1594
|
+
if (!data || !schema) {
|
|
1595
|
+
return { normalized: [], columnDefinitions: [] };
|
|
1596
|
+
}
|
|
1597
|
+
const { mergedFields, minimalFullLengthFields } = deriveFieldConfigs(fields != null ? fields : [], schema, (field) => __spreadValues$3(__spreadValues$3({}, defaultColumnConfig$1()), field && {
|
|
1598
|
+
key: field.id,
|
|
1599
|
+
fieldId: field.id,
|
|
1600
|
+
title: field.label || field.id,
|
|
1601
|
+
expr: (currentItem) => currentItem[field.id]
|
|
1602
|
+
}));
|
|
1603
|
+
setControlContextData == null ? void 0 : setControlContextData(__spreadProps$2(__spreadValues$3({}, data), { mergedFields, minimalFullLengthFields }));
|
|
1604
|
+
const normalized = mergedFields;
|
|
1605
|
+
const columnDefinitions = normalized.filter((cconfig) => !cconfig.isHidden).map((cconfig, _columnIndex, _columnsArray) => {
|
|
1606
|
+
const columnDefinition = {
|
|
1607
|
+
dataIndex: cconfig.fieldId,
|
|
1608
|
+
title: cconfig.title,
|
|
1609
|
+
// dataIndex: cconfig,
|
|
1610
|
+
key: cconfig.key,
|
|
1611
|
+
valueType: deriveValueType(cconfig),
|
|
1612
|
+
// To come later
|
|
1613
|
+
readonly: false,
|
|
1614
|
+
sorter: true,
|
|
1615
|
+
copyable: false,
|
|
1616
|
+
ellipsis: false,
|
|
1617
|
+
tip: void 0,
|
|
1618
|
+
formItemProps: {
|
|
1619
|
+
rules: []
|
|
1620
|
+
},
|
|
1621
|
+
disable: false,
|
|
1622
|
+
valueEnum: void 0,
|
|
1623
|
+
search: void 0,
|
|
1624
|
+
hideInSearch: false,
|
|
1625
|
+
renderFormItem: (_, { defaultRender }) => {
|
|
1626
|
+
return defaultRender(_);
|
|
1627
|
+
},
|
|
1628
|
+
render: (value, record, rowIndex) => {
|
|
1629
|
+
return renderValue(record, cconfig);
|
|
1484
1630
|
}
|
|
1485
|
-
|
|
1486
|
-
|
|
1631
|
+
};
|
|
1632
|
+
return columnDefinition;
|
|
1633
|
+
});
|
|
1634
|
+
const rowKey = props.rowKey;
|
|
1635
|
+
if (rowActions && rowActions.length > 0) {
|
|
1636
|
+
columnDefinitions.push({
|
|
1637
|
+
title: "Actions",
|
|
1638
|
+
valueType: "option",
|
|
1639
|
+
key: "__plasmicActions",
|
|
1640
|
+
fixed: "right",
|
|
1641
|
+
className: props.themeResetClassName,
|
|
1642
|
+
render: (_text, row) => [
|
|
1643
|
+
...renderActions(rowActions, row, data, rowKey)
|
|
1644
|
+
]
|
|
1645
|
+
});
|
|
1646
|
+
}
|
|
1647
|
+
return { normalized, columnDefinitions };
|
|
1648
|
+
}, [fields, data, setControlContextData, rowActions]);
|
|
1487
1649
|
}
|
|
1488
1650
|
function useRowSelectionProps(data, props) {
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1651
|
+
const {
|
|
1652
|
+
canSelectRows,
|
|
1653
|
+
selectedRowKey,
|
|
1654
|
+
onRowSelectionChanged,
|
|
1655
|
+
rowKey,
|
|
1656
|
+
onRowClick
|
|
1657
|
+
} = props;
|
|
1658
|
+
const deriveSelectedRowKeys = () => {
|
|
1659
|
+
if (!canSelectRows || canSelectRows === "none" || !deriveRowKey(data, rowKey)) {
|
|
1660
|
+
return [];
|
|
1661
|
+
}
|
|
1662
|
+
if (typeof selectedRowKey === "string") {
|
|
1663
|
+
return [selectedRowKey];
|
|
1664
|
+
} else if (Array.isArray(selectedRowKey)) {
|
|
1665
|
+
if (canSelectRows === "single" || canSelectRows === "click") {
|
|
1666
|
+
return selectedRowKey.slice(0, 1);
|
|
1667
|
+
} else {
|
|
1668
|
+
return selectedRowKey;
|
|
1669
|
+
}
|
|
1670
|
+
} else {
|
|
1671
|
+
return [];
|
|
1672
|
+
}
|
|
1673
|
+
};
|
|
1674
|
+
const rowSelection = canSelectRows && canSelectRows !== "none" ? __spreadValues$3({
|
|
1675
|
+
type: canSelectRows === "single" || canSelectRows === "click" ? "radio" : "checkbox",
|
|
1676
|
+
selectedRowKeys: deriveSelectedRowKeys(),
|
|
1677
|
+
onChange: (rowKeys, rows) => {
|
|
1678
|
+
onRowSelectionChanged == null ? void 0 : onRowSelectionChanged(rowKeys, rows);
|
|
1679
|
+
},
|
|
1680
|
+
alwaysShowAlert: true
|
|
1681
|
+
}, canSelectRows === "click" && {
|
|
1682
|
+
renderCell: () => null,
|
|
1683
|
+
columnWidth: 0,
|
|
1684
|
+
columnTitle: null,
|
|
1685
|
+
hideSelectAll: true
|
|
1686
|
+
}) : void 0;
|
|
1687
|
+
return {
|
|
1688
|
+
rowSelection,
|
|
1689
|
+
onRow: (row) => ({
|
|
1690
|
+
onClick: (event) => {
|
|
1691
|
+
const key = deriveKeyOfRow(row, deriveRowKey(data, rowKey));
|
|
1692
|
+
if (key != null && !isInteractable(event.target)) {
|
|
1693
|
+
if (canSelectRows === "click") {
|
|
1694
|
+
onRowSelectionChanged == null ? void 0 : onRowSelectionChanged([key], [row]);
|
|
1695
|
+
}
|
|
1696
|
+
onRowClick == null ? void 0 : onRowClick(key, row, event);
|
|
1509
1697
|
}
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
? "radio"
|
|
1514
|
-
: "checkbox", selectedRowKeys: deriveSelectedRowKeys(), onChange: function (rowKeys, rows) {
|
|
1515
|
-
onRowSelectionChanged === null || onRowSelectionChanged === void 0 ? void 0 : onRowSelectionChanged(rowKeys, rows);
|
|
1516
|
-
}, alwaysShowAlert: true }, (canSelectRows === "click" && {
|
|
1517
|
-
renderCell: function () { return null; },
|
|
1518
|
-
columnWidth: 0,
|
|
1519
|
-
columnTitle: null,
|
|
1520
|
-
hideSelectAll: true,
|
|
1521
|
-
})) : undefined;
|
|
1522
|
-
return {
|
|
1523
|
-
rowSelection: rowSelection,
|
|
1524
|
-
onRow: function (row) { return ({
|
|
1525
|
-
onClick: function (event) {
|
|
1526
|
-
var key = deriveKeyOfRow(row, deriveRowKey(data, rowKey));
|
|
1527
|
-
if (key != null && !isInteractable(event.target)) {
|
|
1528
|
-
if (canSelectRows === "click") {
|
|
1529
|
-
onRowSelectionChanged === null || onRowSelectionChanged === void 0 ? void 0 : onRowSelectionChanged([key], [row]);
|
|
1530
|
-
}
|
|
1531
|
-
onRowClick === null || onRowClick === void 0 ? void 0 : onRowClick(key, row, event);
|
|
1532
|
-
}
|
|
1533
|
-
},
|
|
1534
|
-
}); },
|
|
1535
|
-
};
|
|
1698
|
+
}
|
|
1699
|
+
})
|
|
1700
|
+
};
|
|
1536
1701
|
}
|
|
1537
1702
|
function ExportMenu(props) {
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
React.createElement(EllipsisOutlined, null))));
|
|
1703
|
+
const { data } = props;
|
|
1704
|
+
return /* @__PURE__ */ React.createElement(
|
|
1705
|
+
Dropdown,
|
|
1706
|
+
{
|
|
1707
|
+
key: "menu",
|
|
1708
|
+
menu: {
|
|
1709
|
+
items: [
|
|
1710
|
+
{
|
|
1711
|
+
label: "Download as CSV",
|
|
1712
|
+
key: "csv",
|
|
1713
|
+
onClick: async () => {
|
|
1714
|
+
var _a, _b;
|
|
1715
|
+
const writer = createObjectCsvStringifier({
|
|
1716
|
+
header: (_b = (_a = data == null ? void 0 : data.schema) == null ? void 0 : _a.fields.map((f) => ({
|
|
1717
|
+
id: f.id,
|
|
1718
|
+
title: f.id
|
|
1719
|
+
}))) != null ? _b : []
|
|
1720
|
+
});
|
|
1721
|
+
const dataStr = writer.getHeaderString() + writer.stringifyRecords(data == null ? void 0 : data.data);
|
|
1722
|
+
const filename = "data.csv";
|
|
1723
|
+
const blob = new Blob([dataStr], {
|
|
1724
|
+
type: "text/csv;charset=utf-8;"
|
|
1725
|
+
});
|
|
1726
|
+
if (navigator.msSaveBlob) {
|
|
1727
|
+
navigator.msSaveBlob(blob, filename);
|
|
1728
|
+
} else {
|
|
1729
|
+
const link = document.createElement("a");
|
|
1730
|
+
if (link.download !== void 0) {
|
|
1731
|
+
const url = URL.createObjectURL(blob);
|
|
1732
|
+
link.setAttribute("href", url);
|
|
1733
|
+
link.setAttribute("download", filename);
|
|
1734
|
+
link.style.visibility = "hidden";
|
|
1735
|
+
document.body.appendChild(link);
|
|
1736
|
+
link.click();
|
|
1737
|
+
document.body.removeChild(link);
|
|
1738
|
+
}
|
|
1739
|
+
}
|
|
1740
|
+
}
|
|
1741
|
+
},
|
|
1742
|
+
{
|
|
1743
|
+
label: "Download as JSON",
|
|
1744
|
+
key: "json",
|
|
1745
|
+
onClick: () => {
|
|
1746
|
+
const dataStr = fastStringify(data == null ? void 0 : data.data);
|
|
1747
|
+
const dataUri = `data:application/json;charset=utf-8, ${encodeURIComponent(
|
|
1748
|
+
dataStr
|
|
1749
|
+
)}`;
|
|
1750
|
+
const exportFileDefaultName = "data.json";
|
|
1751
|
+
const linkElement = document.createElement("a");
|
|
1752
|
+
linkElement.setAttribute("href", dataUri);
|
|
1753
|
+
linkElement.setAttribute("download", exportFileDefaultName);
|
|
1754
|
+
linkElement.click();
|
|
1755
|
+
}
|
|
1756
|
+
}
|
|
1757
|
+
]
|
|
1758
|
+
}
|
|
1759
|
+
},
|
|
1760
|
+
/* @__PURE__ */ React.createElement(Button, null, /* @__PURE__ */ React.createElement(EllipsisOutlined, null))
|
|
1761
|
+
);
|
|
1598
1762
|
}
|
|
1599
1763
|
|
|
1600
1764
|
function dataProp() {
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1765
|
+
return {
|
|
1766
|
+
type: "dataSourceOpData",
|
|
1767
|
+
description: "The data to display"
|
|
1768
|
+
};
|
|
1605
1769
|
}
|
|
1606
1770
|
function commonProps() {
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1771
|
+
return {
|
|
1772
|
+
pagination: {
|
|
1773
|
+
type: "boolean",
|
|
1774
|
+
advanced: true,
|
|
1775
|
+
defaultValueHint: true
|
|
1776
|
+
},
|
|
1777
|
+
pageSize: {
|
|
1778
|
+
type: "number",
|
|
1779
|
+
defaultValueHint: 10,
|
|
1780
|
+
advanced: true
|
|
1781
|
+
},
|
|
1782
|
+
hideSearch: {
|
|
1783
|
+
type: "boolean",
|
|
1784
|
+
description: "Hides the search toolbar",
|
|
1785
|
+
advanced: true
|
|
1786
|
+
}
|
|
1787
|
+
};
|
|
1624
1788
|
}
|
|
1625
1789
|
function rowActionsProp() {
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1790
|
+
return {
|
|
1791
|
+
type: "array",
|
|
1792
|
+
displayName: "Row actions",
|
|
1793
|
+
advanced: true,
|
|
1794
|
+
itemType: {
|
|
1795
|
+
type: "object",
|
|
1796
|
+
nameFunc: (item) => item.label,
|
|
1797
|
+
fields: {
|
|
1798
|
+
type: {
|
|
1799
|
+
type: "choice",
|
|
1800
|
+
options: ["item", "menu"],
|
|
1801
|
+
defaultValue: "item"
|
|
1802
|
+
},
|
|
1803
|
+
label: {
|
|
1804
|
+
type: "string",
|
|
1805
|
+
displayName: "Action label"
|
|
1806
|
+
},
|
|
1807
|
+
children: {
|
|
1808
|
+
type: "array",
|
|
1809
|
+
displayName: "Menu items",
|
|
1810
|
+
itemType: {
|
|
1631
1811
|
type: "object",
|
|
1632
|
-
nameFunc: function (item) { return item.label; },
|
|
1633
1812
|
fields: {
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
fields: {
|
|
1649
|
-
label: {
|
|
1650
|
-
type: "string",
|
|
1651
|
-
displayName: "Action label",
|
|
1652
|
-
},
|
|
1653
|
-
onClick: {
|
|
1654
|
-
type: "eventHandler",
|
|
1655
|
-
argTypes: [
|
|
1656
|
-
{ name: "rowKey", type: "string" },
|
|
1657
|
-
{ name: "row", type: "object" },
|
|
1658
|
-
],
|
|
1659
|
-
},
|
|
1660
|
-
},
|
|
1661
|
-
},
|
|
1662
|
-
hidden: function (_ps, _ctx, _a) {
|
|
1663
|
-
var item = _a.item;
|
|
1664
|
-
return item.type !== "menu";
|
|
1665
|
-
},
|
|
1666
|
-
},
|
|
1667
|
-
onClick: {
|
|
1668
|
-
type: "eventHandler",
|
|
1669
|
-
displayName: "Action",
|
|
1670
|
-
argTypes: [
|
|
1671
|
-
{ name: "rowKey", type: "string" },
|
|
1672
|
-
{ name: "row", type: "object" },
|
|
1673
|
-
],
|
|
1674
|
-
hidden: function (_ps, _ctx, _a) {
|
|
1675
|
-
var item = _a.item;
|
|
1676
|
-
return item.type !== "item";
|
|
1677
|
-
},
|
|
1678
|
-
},
|
|
1679
|
-
},
|
|
1813
|
+
label: {
|
|
1814
|
+
type: "string",
|
|
1815
|
+
displayName: "Action label"
|
|
1816
|
+
},
|
|
1817
|
+
onClick: {
|
|
1818
|
+
type: "eventHandler",
|
|
1819
|
+
argTypes: [
|
|
1820
|
+
{ name: "rowKey", type: "string" },
|
|
1821
|
+
{ name: "row", type: "object" }
|
|
1822
|
+
]
|
|
1823
|
+
}
|
|
1824
|
+
}
|
|
1825
|
+
},
|
|
1826
|
+
hidden: (_ps, _ctx, { item }) => item.type !== "menu"
|
|
1680
1827
|
},
|
|
1681
|
-
|
|
1828
|
+
onClick: {
|
|
1829
|
+
type: "eventHandler",
|
|
1830
|
+
displayName: "Action",
|
|
1831
|
+
argTypes: [
|
|
1832
|
+
{ name: "rowKey", type: "string" },
|
|
1833
|
+
{ name: "row", type: "object" }
|
|
1834
|
+
],
|
|
1835
|
+
hidden: (_ps, _ctx, { item }) => item.type !== "item"
|
|
1836
|
+
}
|
|
1837
|
+
}
|
|
1838
|
+
}
|
|
1839
|
+
};
|
|
1682
1840
|
}
|
|
1683
1841
|
function onRowClickProp() {
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1842
|
+
return {
|
|
1843
|
+
type: "eventHandler",
|
|
1844
|
+
displayName: "On row clicked",
|
|
1845
|
+
argTypes: [
|
|
1846
|
+
{ name: "rowKey", type: "string" },
|
|
1847
|
+
{ name: "row", type: "object" },
|
|
1848
|
+
{ name: "event", type: "object" }
|
|
1849
|
+
]
|
|
1850
|
+
};
|
|
1693
1851
|
}
|
|
1694
1852
|
|
|
1695
|
-
var
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1853
|
+
var __defProp$2 = Object.defineProperty;
|
|
1854
|
+
var __defProps$1 = Object.defineProperties;
|
|
1855
|
+
var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
|
|
1856
|
+
var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
|
|
1857
|
+
var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
|
|
1858
|
+
var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
|
|
1859
|
+
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1860
|
+
var __spreadValues$2 = (a, b) => {
|
|
1861
|
+
for (var prop in b || (b = {}))
|
|
1862
|
+
if (__hasOwnProp$2.call(b, prop))
|
|
1863
|
+
__defNormalProp$2(a, prop, b[prop]);
|
|
1864
|
+
if (__getOwnPropSymbols$2)
|
|
1865
|
+
for (var prop of __getOwnPropSymbols$2(b)) {
|
|
1866
|
+
if (__propIsEnum$2.call(b, prop))
|
|
1867
|
+
__defNormalProp$2(a, prop, b[prop]);
|
|
1868
|
+
}
|
|
1869
|
+
return a;
|
|
1870
|
+
};
|
|
1871
|
+
var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
|
|
1872
|
+
const tableHelpers = {
|
|
1873
|
+
states: {
|
|
1874
|
+
selectedRow: {
|
|
1875
|
+
onChangeArgsToValue: (rowKeys, rows) => {
|
|
1876
|
+
return rows[0];
|
|
1877
|
+
}
|
|
1878
|
+
},
|
|
1879
|
+
selectedRows: {
|
|
1880
|
+
onChangeArgsToValue: (rowKeys, rows) => {
|
|
1881
|
+
return rows;
|
|
1882
|
+
}
|
|
1883
|
+
},
|
|
1884
|
+
selectedRowKey: {
|
|
1885
|
+
onChangeArgsToValue: (rowKeys, rows) => {
|
|
1886
|
+
return rowKeys;
|
|
1887
|
+
}
|
|
1888
|
+
}
|
|
1889
|
+
}
|
|
1890
|
+
};
|
|
1891
|
+
const dataTableMeta = {
|
|
1892
|
+
name: "hostless-rich-table",
|
|
1893
|
+
displayName: "Table",
|
|
1894
|
+
defaultStyles: {
|
|
1895
|
+
width: "stretch",
|
|
1896
|
+
padding: "16px",
|
|
1897
|
+
maxHeight: "100%"
|
|
1898
|
+
},
|
|
1899
|
+
props: __spreadProps$1(__spreadValues$2({
|
|
1900
|
+
data: dataProp(),
|
|
1901
|
+
fields: buildFieldsPropType({}),
|
|
1902
|
+
canSelectRows: {
|
|
1903
|
+
type: "choice",
|
|
1904
|
+
displayName: "Select rows?",
|
|
1905
|
+
options: [
|
|
1906
|
+
{ label: "No", value: "none" },
|
|
1907
|
+
{ label: "By clicking a row", value: "click" },
|
|
1908
|
+
{ label: "Using radio buttons", value: "single" },
|
|
1909
|
+
{ label: "Using checkboxes", value: "multiple" }
|
|
1910
|
+
],
|
|
1911
|
+
defaultValueHint: "none",
|
|
1912
|
+
description: "Lets user select table rows by clicking on a row, or using radio buttons, or checkboxes if multiple rows can be selected together. If you have interactive elements in your row and you don't want clicking on them to select the row, you may use radio buttons instead."
|
|
1913
|
+
},
|
|
1914
|
+
rowKey: {
|
|
1915
|
+
type: "string",
|
|
1916
|
+
displayName: "Row key",
|
|
1917
|
+
helpText: "Column key to use as row key; can also be a function that takes in a row and returns a key value",
|
|
1918
|
+
hidden: (ps) => !ps.canSelectRows || ps.canSelectRows === "none",
|
|
1919
|
+
defaultValueHint: (ps) => {
|
|
1920
|
+
const derivedRowKey = deriveRowKey(ps.data, ps.rowKey);
|
|
1921
|
+
return derivedRowKey !== void 0 ? `${derivedRowKey}` : void 0;
|
|
1922
|
+
}
|
|
1923
|
+
},
|
|
1924
|
+
selectedRowKey: {
|
|
1925
|
+
type: "string",
|
|
1926
|
+
displayName: "Selected Row Key",
|
|
1927
|
+
hidden: (ps) => ps.canSelectRows !== "single",
|
|
1928
|
+
advanced: true
|
|
1929
|
+
},
|
|
1930
|
+
selectedRowKeys: {
|
|
1931
|
+
type: "array",
|
|
1932
|
+
displayName: "Selected Row Keys",
|
|
1933
|
+
hidden: (ps) => ps.canSelectRows !== "multiple",
|
|
1934
|
+
advanced: true
|
|
1935
|
+
},
|
|
1936
|
+
onRowSelectionChanged: {
|
|
1937
|
+
type: "eventHandler",
|
|
1938
|
+
displayName: "On row selection changed",
|
|
1939
|
+
argTypes: [
|
|
1940
|
+
{ name: "rowKeys", type: "object" },
|
|
1941
|
+
{ name: "rows", type: "object" }
|
|
1942
|
+
]
|
|
1943
|
+
},
|
|
1944
|
+
onRowClick: onRowClickProp(),
|
|
1945
|
+
rowActions: rowActionsProp(),
|
|
1946
|
+
defaultSize: {
|
|
1947
|
+
displayName: "Density",
|
|
1948
|
+
type: "choice",
|
|
1949
|
+
options: [
|
|
1950
|
+
{
|
|
1951
|
+
value: "large",
|
|
1952
|
+
label: "Larger"
|
|
1706
1953
|
},
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
},
|
|
1954
|
+
{
|
|
1955
|
+
value: "middle",
|
|
1956
|
+
label: "Medium"
|
|
1711
1957
|
},
|
|
1958
|
+
{
|
|
1959
|
+
value: "small",
|
|
1960
|
+
label: "Compact"
|
|
1961
|
+
}
|
|
1962
|
+
],
|
|
1963
|
+
defaultValueHint: "large",
|
|
1964
|
+
advanced: true
|
|
1965
|
+
}
|
|
1966
|
+
}, commonProps()), {
|
|
1967
|
+
hideExports: {
|
|
1968
|
+
type: "boolean",
|
|
1969
|
+
description: "Hides the button for exporting table data to CSV",
|
|
1970
|
+
advanced: true
|
|
1712
1971
|
},
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
width: "stretch",
|
|
1719
|
-
padding: "16px",
|
|
1720
|
-
maxHeight: "100%",
|
|
1972
|
+
hideDensity: {
|
|
1973
|
+
type: "boolean",
|
|
1974
|
+
description: "Hides the control for changing the density of the table",
|
|
1975
|
+
advanced: true,
|
|
1976
|
+
defaultValueHint: true
|
|
1721
1977
|
},
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
{ label: "No", value: "none" },
|
|
1727
|
-
{ label: "By clicking a row", value: "click" },
|
|
1728
|
-
{ label: "Using radio buttons", value: "single" },
|
|
1729
|
-
{ label: "Using checkboxes", value: "multiple" },
|
|
1730
|
-
],
|
|
1731
|
-
defaultValueHint: "none",
|
|
1732
|
-
description: "Lets user select table rows by clicking on a row, or using radio buttons, or checkboxes if multiple rows can be selected together. If you have interactive elements in your row and you don't want clicking on them to select the row, you may use radio buttons instead.",
|
|
1733
|
-
}, rowKey: {
|
|
1734
|
-
type: "string",
|
|
1735
|
-
displayName: "Row key",
|
|
1736
|
-
helpText: "Column key to use as row key; can also be a function that takes in a row and returns a key value",
|
|
1737
|
-
hidden: function (ps) { return !ps.canSelectRows || ps.canSelectRows === "none"; },
|
|
1738
|
-
defaultValueHint: function (ps) {
|
|
1739
|
-
var derivedRowKey = deriveRowKey(ps.data, ps.rowKey);
|
|
1740
|
-
return derivedRowKey !== undefined ? "".concat(derivedRowKey) : undefined;
|
|
1741
|
-
},
|
|
1742
|
-
}, selectedRowKey: {
|
|
1743
|
-
type: "string",
|
|
1744
|
-
displayName: "Selected Row Key",
|
|
1745
|
-
hidden: function (ps) { return ps.canSelectRows !== "single"; },
|
|
1746
|
-
advanced: true,
|
|
1747
|
-
}, selectedRowKeys: {
|
|
1748
|
-
type: "array",
|
|
1749
|
-
displayName: "Selected Row Keys",
|
|
1750
|
-
hidden: function (ps) { return ps.canSelectRows !== "multiple"; },
|
|
1751
|
-
advanced: true,
|
|
1752
|
-
}, onRowSelectionChanged: {
|
|
1753
|
-
type: "eventHandler",
|
|
1754
|
-
displayName: "On row selection changed",
|
|
1755
|
-
argTypes: [
|
|
1756
|
-
{ name: "rowKeys", type: "object" },
|
|
1757
|
-
{ name: "rows", type: "object" },
|
|
1758
|
-
],
|
|
1759
|
-
}, onRowClick: onRowClickProp(), rowActions: rowActionsProp(), defaultSize: {
|
|
1760
|
-
displayName: "Density",
|
|
1761
|
-
type: "choice",
|
|
1762
|
-
options: [
|
|
1763
|
-
{
|
|
1764
|
-
value: "large",
|
|
1765
|
-
label: "Larger",
|
|
1766
|
-
},
|
|
1767
|
-
{
|
|
1768
|
-
value: "middle",
|
|
1769
|
-
label: "Medium",
|
|
1770
|
-
},
|
|
1771
|
-
{
|
|
1772
|
-
value: "small",
|
|
1773
|
-
label: "Compact",
|
|
1774
|
-
},
|
|
1775
|
-
],
|
|
1776
|
-
defaultValueHint: "large",
|
|
1777
|
-
advanced: true,
|
|
1778
|
-
} }, commonProps()), { hideExports: {
|
|
1779
|
-
type: "boolean",
|
|
1780
|
-
description: "Hides the button for exporting table data to CSV",
|
|
1781
|
-
advanced: true,
|
|
1782
|
-
}, hideDensity: {
|
|
1783
|
-
type: "boolean",
|
|
1784
|
-
description: "Hides the control for changing the density of the table",
|
|
1785
|
-
advanced: true,
|
|
1786
|
-
defaultValueHint: true,
|
|
1787
|
-
}, hideColumnPicker: {
|
|
1788
|
-
type: "boolean",
|
|
1789
|
-
description: "Hides the control for reordering and pinning columns",
|
|
1790
|
-
advanced: true,
|
|
1791
|
-
}, hideSelectionBar: {
|
|
1792
|
-
type: "boolean",
|
|
1793
|
-
description: "Hides the toolbar that allows the user to clear selection",
|
|
1794
|
-
advanced: true,
|
|
1795
|
-
hidden: function (ps) { return !ps.canSelectRows || ps.canSelectRows === "none"; },
|
|
1796
|
-
defaultValueHint: true,
|
|
1797
|
-
}, scopeClassName: {
|
|
1798
|
-
type: "styleScopeClass",
|
|
1799
|
-
scopeName: "instance",
|
|
1800
|
-
}, themeResetClassName: {
|
|
1801
|
-
type: "themeResetClass",
|
|
1802
|
-
targetAllTags: true,
|
|
1803
|
-
} }),
|
|
1804
|
-
states: {
|
|
1805
|
-
selectedRowKey: __assign({ type: "writable", valueProp: "selectedRowKey", onChangeProp: "onRowSelectionChanged", variableType: "text" }, tableHelpers.states.selectedRowKey),
|
|
1806
|
-
selectedRow: __assign({ type: "readonly", onChangeProp: "onRowSelectionChanged", variableType: "object" }, tableHelpers.states.selectedRow),
|
|
1807
|
-
selectedRows: __assign({ type: "readonly", onChangeProp: "onRowSelectionChanged", variableType: "array" }, tableHelpers.states.selectedRows),
|
|
1978
|
+
hideColumnPicker: {
|
|
1979
|
+
type: "boolean",
|
|
1980
|
+
description: "Hides the control for reordering and pinning columns",
|
|
1981
|
+
advanced: true
|
|
1808
1982
|
},
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1983
|
+
hideSelectionBar: {
|
|
1984
|
+
type: "boolean",
|
|
1985
|
+
description: "Hides the toolbar that allows the user to clear selection",
|
|
1986
|
+
advanced: true,
|
|
1987
|
+
hidden: (ps) => !ps.canSelectRows || ps.canSelectRows === "none",
|
|
1988
|
+
defaultValueHint: true
|
|
1813
1989
|
},
|
|
1814
|
-
|
|
1815
|
-
|
|
1990
|
+
scopeClassName: {
|
|
1991
|
+
type: "styleScopeClass",
|
|
1992
|
+
scopeName: "instance"
|
|
1993
|
+
},
|
|
1994
|
+
themeResetClassName: {
|
|
1995
|
+
type: "themeResetClass",
|
|
1996
|
+
targetAllTags: true
|
|
1997
|
+
}
|
|
1998
|
+
}),
|
|
1999
|
+
states: {
|
|
2000
|
+
selectedRowKey: __spreadValues$2({
|
|
2001
|
+
type: "writable",
|
|
2002
|
+
valueProp: "selectedRowKey",
|
|
2003
|
+
onChangeProp: "onRowSelectionChanged",
|
|
2004
|
+
variableType: "text"
|
|
2005
|
+
}, tableHelpers.states.selectedRowKey),
|
|
2006
|
+
selectedRow: __spreadValues$2({
|
|
2007
|
+
type: "readonly",
|
|
2008
|
+
onChangeProp: "onRowSelectionChanged",
|
|
2009
|
+
variableType: "object"
|
|
2010
|
+
}, tableHelpers.states.selectedRow),
|
|
2011
|
+
selectedRows: __spreadValues$2({
|
|
2012
|
+
type: "readonly",
|
|
2013
|
+
onChangeProp: "onRowSelectionChanged",
|
|
2014
|
+
variableType: "array"
|
|
2015
|
+
}, tableHelpers.states.selectedRows)
|
|
2016
|
+
},
|
|
2017
|
+
componentHelpers: {
|
|
2018
|
+
helpers: tableHelpers,
|
|
2019
|
+
importName: "tableHelpers",
|
|
2020
|
+
importPath: "@plasmicpkgs/plasmic-rich-components"
|
|
2021
|
+
},
|
|
2022
|
+
importName: "RichTable",
|
|
2023
|
+
importPath: "@plasmicpkgs/plasmic-rich-components"
|
|
1816
2024
|
};
|
|
1817
2025
|
function registerRichTable(loader) {
|
|
1818
|
-
|
|
2026
|
+
registerComponentHelper(loader, RichTable, dataTableMeta);
|
|
1819
2027
|
}
|
|
1820
2028
|
|
|
1821
|
-
|
|
1822
|
-
var
|
|
2029
|
+
var __defProp$1 = Object.defineProperty;
|
|
2030
|
+
var __defProps = Object.defineProperties;
|
|
2031
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
2032
|
+
var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
|
|
2033
|
+
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
|
|
2034
|
+
var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
|
|
2035
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2036
|
+
var __spreadValues$1 = (a, b) => {
|
|
2037
|
+
for (var prop in b || (b = {}))
|
|
2038
|
+
if (__hasOwnProp$1.call(b, prop))
|
|
2039
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
2040
|
+
if (__getOwnPropSymbols$1)
|
|
2041
|
+
for (var prop of __getOwnPropSymbols$1(b)) {
|
|
2042
|
+
if (__propIsEnum$1.call(b, prop))
|
|
2043
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
2044
|
+
}
|
|
2045
|
+
return a;
|
|
2046
|
+
};
|
|
2047
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
2048
|
+
var __objRest = (source, exclude) => {
|
|
2049
|
+
var target = {};
|
|
2050
|
+
for (var prop in source)
|
|
2051
|
+
if (__hasOwnProp$1.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
2052
|
+
target[prop] = source[prop];
|
|
2053
|
+
if (source != null && __getOwnPropSymbols$1)
|
|
2054
|
+
for (var prop of __getOwnPropSymbols$1(source)) {
|
|
2055
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$1.call(source, prop))
|
|
2056
|
+
target[prop] = source[prop];
|
|
2057
|
+
}
|
|
2058
|
+
return target;
|
|
2059
|
+
};
|
|
2060
|
+
const listCss = `
|
|
2061
|
+
.plasmic-list--grid .ant-list-items {
|
|
2062
|
+
display: grid;
|
|
2063
|
+
grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
|
|
2064
|
+
gap: 16px;
|
|
2065
|
+
}
|
|
2066
|
+
|
|
2067
|
+
.plasmic-list-search {
|
|
2068
|
+
/* Matches RichTable search. */
|
|
2069
|
+
max-width: 200px;
|
|
2070
|
+
margin-bottom: 8px;
|
|
2071
|
+
}
|
|
2072
|
+
|
|
2073
|
+
.plasmic-list-item-content--unbordered {
|
|
2074
|
+
padding-left: 8px;
|
|
2075
|
+
padding-right: 8px;
|
|
2076
|
+
}
|
|
2077
|
+
|
|
2078
|
+
.plasmic-list-item--clickable:hover {
|
|
2079
|
+
background-color: #8881;
|
|
2080
|
+
}
|
|
2081
|
+
|
|
2082
|
+
.plasmic-list-item-image {
|
|
2083
|
+
max-width: 80px;
|
|
2084
|
+
max-height: 80px;
|
|
2085
|
+
aspect-ratio: 1/1;
|
|
2086
|
+
object-fit: cover;
|
|
2087
|
+
border-radius: 8px;
|
|
2088
|
+
}
|
|
2089
|
+
|
|
2090
|
+
/* Unsure why needed, but cards otherwise can be much narrower. */
|
|
2091
|
+
.plasmic-list-item-card {
|
|
2092
|
+
width: 100%;
|
|
2093
|
+
}
|
|
2094
|
+
|
|
2095
|
+
.plasmic-list-item-card-cover {
|
|
2096
|
+
max-height: 300px;
|
|
2097
|
+
aspect-ratio: 1/1;
|
|
2098
|
+
object-fit: cover;
|
|
2099
|
+
}
|
|
2100
|
+
`;
|
|
1823
2101
|
function RichList(props) {
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
2102
|
+
const _a = props, {
|
|
2103
|
+
data: rawData = {
|
|
2104
|
+
data: [],
|
|
2105
|
+
schema: {
|
|
2106
|
+
id: "inferred",
|
|
2107
|
+
fields: [
|
|
2108
|
+
{
|
|
2109
|
+
id: "id",
|
|
2110
|
+
type: "string",
|
|
2111
|
+
readOnly: false
|
|
2112
|
+
}
|
|
2113
|
+
]
|
|
2114
|
+
}
|
|
2115
|
+
},
|
|
2116
|
+
type = "list",
|
|
2117
|
+
bordered = true,
|
|
2118
|
+
className,
|
|
2119
|
+
size,
|
|
2120
|
+
header,
|
|
2121
|
+
footer,
|
|
2122
|
+
rowActions = [],
|
|
2123
|
+
title,
|
|
2124
|
+
pageSize = 10,
|
|
2125
|
+
hideSearch,
|
|
2126
|
+
rowKey,
|
|
2127
|
+
pagination,
|
|
2128
|
+
onRowClick
|
|
2129
|
+
} = _a; __objRest(_a, [
|
|
2130
|
+
"data",
|
|
2131
|
+
"type",
|
|
2132
|
+
"bordered",
|
|
2133
|
+
"className",
|
|
2134
|
+
"size",
|
|
2135
|
+
"header",
|
|
2136
|
+
"footer",
|
|
2137
|
+
"rowActions",
|
|
2138
|
+
"title",
|
|
2139
|
+
"pageSize",
|
|
2140
|
+
"hideSearch",
|
|
2141
|
+
"rowKey",
|
|
2142
|
+
"pagination",
|
|
2143
|
+
"onRowClick"
|
|
2144
|
+
]);
|
|
2145
|
+
const data = normalizeData(rawData);
|
|
2146
|
+
const { normalized, finalRoles: roleConfigs } = useRoleDefinitions(
|
|
2147
|
+
data,
|
|
2148
|
+
props
|
|
2149
|
+
);
|
|
2150
|
+
useRef();
|
|
2151
|
+
const linkTo = typeof props.linkTo === "function" ? props.linkTo : void 0;
|
|
2152
|
+
const { finalData, search, setSearch, setSortState } = useSortedFilteredData(
|
|
2153
|
+
data,
|
|
2154
|
+
normalized
|
|
2155
|
+
);
|
|
2156
|
+
const actuallyBordered = type === "list" ? bordered : false;
|
|
2157
|
+
return /* @__PURE__ */ React.createElement("div", { className }, /* @__PURE__ */ React.createElement("style", null, listCss), !hideSearch && /* @__PURE__ */ React.createElement(
|
|
2158
|
+
Input.Search,
|
|
2159
|
+
{
|
|
2160
|
+
className: "plasmic-list-search",
|
|
2161
|
+
onChange: (e) => setSearch(e.target.value),
|
|
2162
|
+
value: search,
|
|
2163
|
+
placeholder: "Search"
|
|
2164
|
+
}
|
|
2165
|
+
), /* @__PURE__ */ React.createElement(
|
|
2166
|
+
List,
|
|
2167
|
+
{
|
|
2168
|
+
className: classNames({
|
|
2169
|
+
// We use CSS grid instead of the built-in Ant grid which can only define fixed # columns, and only at screen (and not container) breakpoints.
|
|
2170
|
+
"plasmic-list--grid": type === "grid"
|
|
2171
|
+
}),
|
|
2172
|
+
size,
|
|
2173
|
+
header,
|
|
2174
|
+
footer,
|
|
2175
|
+
dataSource: finalData,
|
|
2176
|
+
itemLayout: "horizontal",
|
|
2177
|
+
bordered: actuallyBordered,
|
|
2178
|
+
pagination: pagination ? {
|
|
2179
|
+
pageSize,
|
|
2180
|
+
showSizeChanger: false
|
|
2181
|
+
} : false,
|
|
2182
|
+
renderItem: (record, index) => {
|
|
2183
|
+
var _a2;
|
|
2184
|
+
const actions = renderActions(rowActions, record, data, rowKey);
|
|
2185
|
+
const image = maybe(
|
|
2186
|
+
maybeRenderString(record, (_a2 = roleConfigs.image) == null ? void 0 : _a2[0]),
|
|
2187
|
+
(src) => /* @__PURE__ */ React.createElement(
|
|
2188
|
+
"img",
|
|
2189
|
+
{
|
|
2190
|
+
src,
|
|
2191
|
+
className: type === "list" ? "plasmic-list-item-image" : "plasmic-list-item-card-cover"
|
|
2192
|
+
}
|
|
2193
|
+
)
|
|
2194
|
+
);
|
|
2195
|
+
const content = /* @__PURE__ */ React.createElement(
|
|
2196
|
+
ListItemContent,
|
|
2197
|
+
{
|
|
2198
|
+
bordered: actuallyBordered,
|
|
2199
|
+
image: type === "list" ? image : void 0,
|
|
2200
|
+
title: multiRenderValue(record, roleConfigs.title),
|
|
2201
|
+
subtitle: multiRenderValue(record, roleConfigs.subtitle),
|
|
2202
|
+
beforeTitle: multiRenderValue(record, roleConfigs.beforeTitle),
|
|
2203
|
+
afterTitle: multiRenderValue(record, roleConfigs.afterTitle),
|
|
2204
|
+
content: multiRenderValue(record, roleConfigs.content)
|
|
2205
|
+
}
|
|
2206
|
+
);
|
|
2207
|
+
function makeLinkWrapper() {
|
|
2208
|
+
if ((actions != null ? actions : []).length > 0)
|
|
2209
|
+
return void 0;
|
|
2210
|
+
const href = linkTo == null ? void 0 : linkTo(record);
|
|
2211
|
+
if (!href && !onRowClick)
|
|
2212
|
+
return void 0;
|
|
2213
|
+
const _linkWrapper = (x) => /* @__PURE__ */ React.createElement(
|
|
2214
|
+
"a",
|
|
2215
|
+
{
|
|
2216
|
+
href,
|
|
2217
|
+
onClick: (event) => {
|
|
2218
|
+
const key = deriveKeyOfRow(
|
|
2219
|
+
record,
|
|
2220
|
+
deriveRowKey(data, rowKey)
|
|
2221
|
+
);
|
|
2222
|
+
if (key != null && !isInteractable(event.target)) {
|
|
2223
|
+
onRowClick == null ? void 0 : onRowClick(key, record, event);
|
|
1889
2224
|
}
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
2225
|
+
}
|
|
2226
|
+
},
|
|
2227
|
+
x
|
|
2228
|
+
);
|
|
2229
|
+
return _linkWrapper;
|
|
2230
|
+
}
|
|
2231
|
+
const linkWrapper = makeLinkWrapper();
|
|
2232
|
+
const hasLink = !!linkWrapper;
|
|
2233
|
+
function maybeLink(x) {
|
|
2234
|
+
var _a3;
|
|
2235
|
+
return (_a3 = linkWrapper == null ? void 0 : linkWrapper(x)) != null ? _a3 : x;
|
|
2236
|
+
}
|
|
2237
|
+
return type === "grid" ? /* @__PURE__ */ React.createElement(List.Item, null, maybeLink(
|
|
2238
|
+
/* @__PURE__ */ React.createElement(
|
|
2239
|
+
Card,
|
|
2240
|
+
{
|
|
2241
|
+
className: "plasmic-list-item-card",
|
|
2242
|
+
size: "small",
|
|
2243
|
+
cover: image,
|
|
2244
|
+
hoverable: hasLink,
|
|
2245
|
+
actions
|
|
2246
|
+
},
|
|
2247
|
+
content
|
|
2248
|
+
)
|
|
2249
|
+
)) : maybeLink(
|
|
2250
|
+
/* @__PURE__ */ React.createElement(
|
|
2251
|
+
List.Item,
|
|
2252
|
+
{
|
|
2253
|
+
actions,
|
|
2254
|
+
className: classNames({
|
|
2255
|
+
"plasmic-list-item--clickable": hasLink
|
|
2256
|
+
})
|
|
2257
|
+
},
|
|
2258
|
+
content
|
|
2259
|
+
)
|
|
2260
|
+
);
|
|
2261
|
+
}
|
|
2262
|
+
}
|
|
2263
|
+
));
|
|
1894
2264
|
}
|
|
1895
2265
|
function ListItemContent(_a) {
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
title && (React.createElement("h4", { className: "".concat(prefixCls, "-item-meta-title"), style: { margin: 0 } }, title)),
|
|
1908
|
-
afterTitle && (React.createElement("div", { className: "".concat(prefixCls, "-item-meta-description") }, afterTitle))),
|
|
1909
|
-
subtitle && (React.createElement("div", { className: "".concat(prefixCls, "-item-meta-description") }, subtitle)),
|
|
1910
|
-
content && React.createElement("div", null, content))));
|
|
1911
|
-
}
|
|
1912
|
-
var defaultColumnConfig = function () {
|
|
1913
|
-
return ({
|
|
1914
|
-
key: mkShortId(),
|
|
1915
|
-
isEditableExpr: function () { return false; },
|
|
1916
|
-
disableSorting: false,
|
|
1917
|
-
sortByExpr: undefined,
|
|
1918
|
-
isHidden: false,
|
|
1919
|
-
formatting: {
|
|
1920
|
-
styles: {},
|
|
1921
|
-
align: "left",
|
|
1922
|
-
freeze: "off",
|
|
1923
|
-
},
|
|
1924
|
-
dataType: "auto",
|
|
1925
|
-
role: undefined,
|
|
1926
|
-
});
|
|
1927
|
-
};
|
|
1928
|
-
var roles = [
|
|
1929
|
-
"content",
|
|
2266
|
+
var _b = _a, {
|
|
2267
|
+
className,
|
|
2268
|
+
title,
|
|
2269
|
+
subtitle,
|
|
2270
|
+
image,
|
|
2271
|
+
beforeTitle,
|
|
2272
|
+
afterTitle,
|
|
2273
|
+
content,
|
|
2274
|
+
bordered
|
|
2275
|
+
} = _b, others = __objRest(_b, [
|
|
2276
|
+
"className",
|
|
1930
2277
|
"title",
|
|
1931
2278
|
"subtitle",
|
|
2279
|
+
"image",
|
|
1932
2280
|
"beforeTitle",
|
|
1933
2281
|
"afterTitle",
|
|
1934
|
-
"
|
|
1935
|
-
"
|
|
2282
|
+
"content",
|
|
2283
|
+
"bordered"
|
|
2284
|
+
]);
|
|
2285
|
+
const prefixCls = "ant-list";
|
|
2286
|
+
const classString = classNames(`${prefixCls}-item-meta`, className);
|
|
2287
|
+
return /* @__PURE__ */ React.createElement(
|
|
2288
|
+
"div",
|
|
2289
|
+
__spreadProps(__spreadValues$1({}, others), {
|
|
2290
|
+
className: classNames(
|
|
2291
|
+
{
|
|
2292
|
+
"plasmic-list-item-content--unbordered": !bordered
|
|
2293
|
+
},
|
|
2294
|
+
classString
|
|
2295
|
+
)
|
|
2296
|
+
}),
|
|
2297
|
+
image && /* @__PURE__ */ React.createElement("div", { className: `${prefixCls}-item-meta-avatar` }, image),
|
|
2298
|
+
/* @__PURE__ */ React.createElement(
|
|
2299
|
+
"div",
|
|
2300
|
+
{
|
|
2301
|
+
className: `${prefixCls}-item-meta-content`,
|
|
2302
|
+
style: { display: "flex", flexDirection: "column", gap: 4 }
|
|
2303
|
+
},
|
|
2304
|
+
beforeTitle && /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(Tag, null, beforeTitle)),
|
|
2305
|
+
/* @__PURE__ */ React.createElement("div", { style: { display: "flex", gap: 8 } }, title && /* @__PURE__ */ React.createElement(
|
|
2306
|
+
"h4",
|
|
2307
|
+
{
|
|
2308
|
+
className: `${prefixCls}-item-meta-title`,
|
|
2309
|
+
style: { margin: 0 }
|
|
2310
|
+
},
|
|
2311
|
+
title
|
|
2312
|
+
), afterTitle && /* @__PURE__ */ React.createElement("div", { className: `${prefixCls}-item-meta-description` }, afterTitle)),
|
|
2313
|
+
subtitle && /* @__PURE__ */ React.createElement("div", { className: `${prefixCls}-item-meta-description` }, subtitle),
|
|
2314
|
+
content && /* @__PURE__ */ React.createElement("div", null, content)
|
|
2315
|
+
)
|
|
2316
|
+
);
|
|
2317
|
+
}
|
|
2318
|
+
const defaultColumnConfig = () => ({
|
|
2319
|
+
key: mkShortId(),
|
|
2320
|
+
isEditableExpr: () => false,
|
|
2321
|
+
disableSorting: false,
|
|
2322
|
+
sortByExpr: void 0,
|
|
2323
|
+
isHidden: false,
|
|
2324
|
+
formatting: {
|
|
2325
|
+
styles: {},
|
|
2326
|
+
align: "left",
|
|
2327
|
+
freeze: "off"
|
|
2328
|
+
},
|
|
2329
|
+
dataType: "auto",
|
|
2330
|
+
role: void 0
|
|
2331
|
+
});
|
|
2332
|
+
const roles = [
|
|
2333
|
+
"content",
|
|
2334
|
+
"title",
|
|
2335
|
+
"subtitle",
|
|
2336
|
+
"beforeTitle",
|
|
2337
|
+
"afterTitle",
|
|
2338
|
+
"image",
|
|
2339
|
+
"unset"
|
|
1936
2340
|
];
|
|
1937
|
-
// This component is different from Table/Details since it has various different roles, so the UX is one of setting the choices for each role rather than a single list of fields.
|
|
1938
|
-
//
|
|
1939
|
-
// We first infer the defaults for each role.
|
|
1940
|
-
// This we always need to do because we want the choices to be 'stable'.
|
|
1941
|
-
// If the user sets one of the roles, without setting the others, we don't want to shift things around on the other roles as a result.
|
|
1942
|
-
// So the defaults need to always be there (they would only be irrelevant if all roles that would have had defaults were set/overridden by the user).
|
|
1943
|
-
//
|
|
1944
|
-
// Then, we layer on the user role choices.
|
|
1945
|
-
//
|
|
1946
|
-
// One UX wart is that unsetting a role will restore the default selection instead of clearing it.
|
|
1947
|
-
// User must know to actually set fieldId to none or (for arrays) remove the item.
|
|
1948
|
-
// Just another reason to fill in few roles by default.
|
|
1949
2341
|
function useRoleDefinitions(data, props) {
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
return !field.role &&
|
|
2010
|
-
((_a = field.fieldId) === null || _a === void 0 ? void 0 : _a.toLowerCase().match(/^(title|name|first[ _-]?name|full[ _-]?name)$/));
|
|
2011
|
-
});
|
|
2012
|
-
if (titleField) {
|
|
2013
|
-
titleField.role = "title";
|
|
2014
|
-
}
|
|
2342
|
+
const { fields, setControlContextData, rowActions } = props;
|
|
2343
|
+
return React.useMemo(() => {
|
|
2344
|
+
var _a, _b, _c, _d;
|
|
2345
|
+
const schema = data == null ? void 0 : data.schema;
|
|
2346
|
+
const schemaMap = new Map((_a = data == null ? void 0 : data.schema) == null ? void 0 : _a.fields.map((f) => [f.id, f]));
|
|
2347
|
+
if (!data || !schema) {
|
|
2348
|
+
return { normalized: [], roleConfigs: {}, finalRoles: {} };
|
|
2349
|
+
}
|
|
2350
|
+
function tagFieldConfigs(role) {
|
|
2351
|
+
var _a2;
|
|
2352
|
+
if (role !== "unset") {
|
|
2353
|
+
return ensureArray((_a2 = props[role]) != null ? _a2 : []).map((field) => {
|
|
2354
|
+
return __spreadProps(__spreadValues$1({}, field), {
|
|
2355
|
+
role
|
|
2356
|
+
});
|
|
2357
|
+
});
|
|
2358
|
+
} else {
|
|
2359
|
+
return [];
|
|
2360
|
+
}
|
|
2361
|
+
}
|
|
2362
|
+
const { mergedFields, minimalFullLengthFields } = deriveFieldConfigs(
|
|
2363
|
+
[
|
|
2364
|
+
...tagFieldConfigs("image"),
|
|
2365
|
+
...tagFieldConfigs("content"),
|
|
2366
|
+
...tagFieldConfigs("title"),
|
|
2367
|
+
...tagFieldConfigs("beforeTitle"),
|
|
2368
|
+
...tagFieldConfigs("afterTitle"),
|
|
2369
|
+
...tagFieldConfigs("subtitle")
|
|
2370
|
+
],
|
|
2371
|
+
schema,
|
|
2372
|
+
(field) => __spreadValues$1(__spreadValues$1({}, defaultColumnConfig()), field && {
|
|
2373
|
+
key: field.id,
|
|
2374
|
+
fieldId: field.id,
|
|
2375
|
+
title: field.label || field.id,
|
|
2376
|
+
// undefined means not yet determined in this routine, not 'unset'
|
|
2377
|
+
role: void 0,
|
|
2378
|
+
expr: (currentItem) => currentItem[field.id]
|
|
2379
|
+
})
|
|
2380
|
+
);
|
|
2381
|
+
const normalized = mergedFields;
|
|
2382
|
+
if (data.data.length > 0 && !mergedFields.some((field) => field.role === "image")) {
|
|
2383
|
+
const sampleRows = Array.from(
|
|
2384
|
+
new Set(
|
|
2385
|
+
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9].map(
|
|
2386
|
+
(i) => Math.round(i / 9 * (data.data.length - 1))
|
|
2387
|
+
)
|
|
2388
|
+
)
|
|
2389
|
+
).map((i) => data.data[i]);
|
|
2390
|
+
const imageFieldCandidates = mergedFields.filter(
|
|
2391
|
+
(field) => !field.role && sampleRows.filter(
|
|
2392
|
+
(row) => field.fieldId && isLikeImage(row[field.fieldId])
|
|
2393
|
+
).length >= sampleRows.length / 2
|
|
2394
|
+
);
|
|
2395
|
+
const imageField = (_c = (_b = imageFieldCandidates.find(
|
|
2396
|
+
(f) => {
|
|
2397
|
+
var _a2;
|
|
2398
|
+
return (_a2 = f.fieldId) == null ? void 0 : _a2.match(
|
|
2399
|
+
/^(image|picture|pic|img|avatar|profile|photo|icon)$/i
|
|
2400
|
+
);
|
|
2015
2401
|
}
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
((_a = schemaMap.get(field.fieldId)) === null || _a === void 0 ? void 0 : _a.type) === "string";
|
|
2023
|
-
});
|
|
2024
|
-
if (contentField) {
|
|
2025
|
-
contentField.role = "content";
|
|
2026
|
-
}
|
|
2402
|
+
)) != null ? _b : imageFieldCandidates.find(
|
|
2403
|
+
(f) => {
|
|
2404
|
+
var _a2;
|
|
2405
|
+
return (_a2 = f.fieldId) == null ? void 0 : _a2.match(
|
|
2406
|
+
/.*(image|picture|pic|img|avatar|profile|photo|icon).*/i
|
|
2407
|
+
);
|
|
2027
2408
|
}
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2409
|
+
)) != null ? _c : imageFieldCandidates[0];
|
|
2410
|
+
if (imageField) {
|
|
2411
|
+
imageField.role = "image";
|
|
2412
|
+
}
|
|
2413
|
+
}
|
|
2414
|
+
if (!mergedFields.some((field) => field.role === "title")) {
|
|
2415
|
+
const titleField = mergedFields.find(
|
|
2416
|
+
(field) => {
|
|
2417
|
+
var _a2;
|
|
2418
|
+
return !field.role && ((_a2 = field.fieldId) == null ? void 0 : _a2.toLowerCase().match(/^(title|name|first[ _-]?name|full[ _-]?name)$/));
|
|
2035
2419
|
}
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2420
|
+
);
|
|
2421
|
+
if (titleField) {
|
|
2422
|
+
titleField.role = "title";
|
|
2423
|
+
}
|
|
2424
|
+
}
|
|
2425
|
+
if (!mergedFields.some((field) => field.role === "content")) {
|
|
2426
|
+
const contentField = mergedFields.find(
|
|
2427
|
+
(field) => {
|
|
2428
|
+
var _a2;
|
|
2429
|
+
return !field.role && field.fieldId && ((_a2 = schemaMap.get(field.fieldId)) == null ? void 0 : _a2.type) === "string";
|
|
2040
2430
|
}
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2431
|
+
);
|
|
2432
|
+
if (contentField) {
|
|
2433
|
+
contentField.role = "content";
|
|
2434
|
+
}
|
|
2435
|
+
}
|
|
2436
|
+
const roleConfigs = ensure(groupBy(mergedFields, (f) => f.role));
|
|
2437
|
+
const finalRoles = {};
|
|
2438
|
+
for (const role of roles) {
|
|
2439
|
+
if (role !== "unset") {
|
|
2440
|
+
finalRoles[role] = (_d = maybe(props[role], ensureArray)) != null ? _d : roleConfigs[role];
|
|
2441
|
+
}
|
|
2442
|
+
}
|
|
2443
|
+
const fieldIdToRole = new Map(mergedFields.map((f) => [f.fieldId, f.role]));
|
|
2444
|
+
for (const f of minimalFullLengthFields) {
|
|
2445
|
+
f.role = fieldIdToRole.get(f.fieldId);
|
|
2446
|
+
}
|
|
2447
|
+
setControlContextData == null ? void 0 : setControlContextData(__spreadProps(__spreadValues$1({}, data), { mergedFields, minimalFullLengthFields }));
|
|
2448
|
+
return { normalized, roleConfigs, finalRoles };
|
|
2449
|
+
}, [fields, data, setControlContextData, rowActions]);
|
|
2044
2450
|
}
|
|
2045
2451
|
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2452
|
+
var __defProp = Object.defineProperty;
|
|
2453
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
2454
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
2455
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
2456
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2457
|
+
var __spreadValues = (a, b) => {
|
|
2458
|
+
for (var prop in b || (b = {}))
|
|
2459
|
+
if (__hasOwnProp.call(b, prop))
|
|
2460
|
+
__defNormalProp(a, prop, b[prop]);
|
|
2461
|
+
if (__getOwnPropSymbols)
|
|
2462
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
2463
|
+
if (__propIsEnum.call(b, prop))
|
|
2464
|
+
__defNormalProp(a, prop, b[prop]);
|
|
2465
|
+
}
|
|
2466
|
+
return a;
|
|
2467
|
+
};
|
|
2468
|
+
function roleProp({
|
|
2469
|
+
role,
|
|
2470
|
+
singular = false,
|
|
2471
|
+
advanced = false,
|
|
2472
|
+
displayName
|
|
2473
|
+
}) {
|
|
2474
|
+
return singular ? {
|
|
2475
|
+
type: "object",
|
|
2476
|
+
displayName,
|
|
2477
|
+
advanced,
|
|
2478
|
+
hidden: (ps) => !ps.data,
|
|
2479
|
+
nameFunc: (item) => maybe(
|
|
2480
|
+
item,
|
|
2481
|
+
(i) => i.isHidden ? "Hidden" : i.fieldId || "Custom value"
|
|
2482
|
+
),
|
|
2483
|
+
fields: getFieldSubprops({
|
|
2484
|
+
canChangeField: true,
|
|
2485
|
+
noTitle: true
|
|
2486
|
+
}),
|
|
2487
|
+
defaultValueHint: (_props, contextData) => {
|
|
2488
|
+
var _a;
|
|
2489
|
+
return ((_a = contextData == null ? void 0 : contextData.minimalFullLengthFields) != null ? _a : []).find(
|
|
2490
|
+
(f) => f.role === role
|
|
2491
|
+
);
|
|
2492
|
+
}
|
|
2493
|
+
} : buildFieldsPropType({
|
|
2494
|
+
displayName,
|
|
2495
|
+
advanced,
|
|
2496
|
+
noTitle: true,
|
|
2497
|
+
canChangeField: true,
|
|
2498
|
+
minimalValue: (_props, contextData) => {
|
|
2499
|
+
var _a;
|
|
2500
|
+
return ((_a = contextData == null ? void 0 : contextData.minimalFullLengthFields) != null ? _a : []).filter(
|
|
2501
|
+
(f) => f.role === role
|
|
2502
|
+
);
|
|
2503
|
+
}
|
|
2504
|
+
});
|
|
2078
2505
|
}
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2506
|
+
const richListMeta = {
|
|
2507
|
+
name: "hostless-rich-list",
|
|
2508
|
+
displayName: "Data List",
|
|
2509
|
+
defaultStyles: {
|
|
2510
|
+
width: "stretch",
|
|
2511
|
+
padding: "16px",
|
|
2512
|
+
maxHeight: "100%"
|
|
2513
|
+
},
|
|
2514
|
+
templates: {
|
|
2515
|
+
grid: {
|
|
2516
|
+
props: {}
|
|
2517
|
+
}
|
|
2518
|
+
},
|
|
2519
|
+
props: __spreadValues({
|
|
2520
|
+
data: dataProp(),
|
|
2521
|
+
type: {
|
|
2522
|
+
type: "choice",
|
|
2523
|
+
options: [
|
|
2524
|
+
{ value: "list", label: "List" },
|
|
2525
|
+
{ value: "grid", label: "Grid" }
|
|
2526
|
+
],
|
|
2527
|
+
defaultValueHint: "list"
|
|
2086
2528
|
},
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2529
|
+
header: {
|
|
2530
|
+
type: "slot",
|
|
2531
|
+
hidePlaceholder: true
|
|
2532
|
+
},
|
|
2533
|
+
footer: {
|
|
2534
|
+
type: "slot",
|
|
2535
|
+
hidePlaceholder: true
|
|
2536
|
+
},
|
|
2537
|
+
title: roleProp({ role: "title" }),
|
|
2538
|
+
content: roleProp({ role: "content" }),
|
|
2539
|
+
image: roleProp({ role: "image", singular: true }),
|
|
2540
|
+
subtitle: roleProp({
|
|
2541
|
+
role: "subtitle",
|
|
2542
|
+
displayName: "Subtitle",
|
|
2543
|
+
advanced: true
|
|
2544
|
+
}),
|
|
2545
|
+
// Haven't styled these yet!
|
|
2546
|
+
// beforeTitle: roleProp({ role: "beforeTitle", advanced: true }),
|
|
2547
|
+
// afterTitle: roleProp({ role: "afterTitle", advanced: true }),
|
|
2548
|
+
linkTo: {
|
|
2549
|
+
type: "function",
|
|
2550
|
+
control: {
|
|
2551
|
+
type: "href"
|
|
2552
|
+
},
|
|
2553
|
+
argNames: ["currentItem"],
|
|
2554
|
+
argValues: (_props, ctx) => {
|
|
2555
|
+
var _a;
|
|
2556
|
+
return [(_a = ctx == null ? void 0 : ctx.data) == null ? void 0 : _a[0]];
|
|
2557
|
+
}
|
|
2558
|
+
},
|
|
2559
|
+
onRowClick: onRowClickProp(),
|
|
2560
|
+
rowActions: rowActionsProp(),
|
|
2561
|
+
bordered: {
|
|
2562
|
+
type: "boolean",
|
|
2563
|
+
defaultValue: true,
|
|
2564
|
+
hidden: (ps) => {
|
|
2565
|
+
var _a;
|
|
2566
|
+
return ((_a = ps.type) != null ? _a : "list") !== "list";
|
|
2567
|
+
}
|
|
2568
|
+
}
|
|
2569
|
+
}, commonProps()),
|
|
2570
|
+
importName: "RichList",
|
|
2571
|
+
importPath: "@plasmicpkgs/plasmic-rich-components"
|
|
2122
2572
|
};
|
|
2123
2573
|
function registerRichList(loader) {
|
|
2124
|
-
|
|
2574
|
+
registerComponentHelper(loader, RichList, richListMeta);
|
|
2125
2575
|
}
|
|
2126
2576
|
|
|
2127
2577
|
function registerAll(loader) {
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2578
|
+
registerRichLayout(loader);
|
|
2579
|
+
registerRichList(loader);
|
|
2580
|
+
registerRichTable(loader);
|
|
2581
|
+
registerRichDetails(loader);
|
|
2132
2582
|
}
|
|
2133
2583
|
|
|
2134
2584
|
export { RichDetails, RichLayout, RichList, RichTable, commonProps, dataProp, deriveKeyOfRow, deriveRowKey, ensureArray, isInteractable, isLikeImage, onRowClickProp, registerAll, renderActions, rowActionsProp, tableHelpers, useSortedFilteredData };
|