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