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