@plasmicpkgs/plasmic-rich-components 1.0.98 → 1.0.101

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