@plasmicpkgs/plasmic-rich-components 1.0.75 → 1.0.76

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.
@@ -1,10 +1,9 @@
1
- import React, { useState, useEffect, useRef } from 'react';
2
1
  import registerComponent from '@plasmicapp/host/registerComponent';
3
2
  import '@plasmicapp/host/registerGlobalContext';
3
+ import { ProDescriptions, ProLayout, ProTable, TableDropdown } from '@ant-design/pro-components';
4
+ import React, { useState, useEffect, useRef } from 'react';
5
+ import { Checkbox, Switch, Empty, Dropdown, Button } from 'antd';
4
6
  import { LogoutOutlined, PlusOutlined, EllipsisOutlined } from '@ant-design/icons';
5
- import { ProLayout, ProTable, TableDropdown } from '@ant-design/pro-components';
6
- import { Dropdown, Button } from 'antd';
7
- import { DataProvider } from '@plasmicapp/host';
8
7
  import { createObjectCsvStringifier } from 'csv-writer-browser';
9
8
  import fastStringify from 'fast-stringify';
10
9
 
@@ -94,6 +93,843 @@ function __spreadArray(to, from, pack) {
94
93
  return to.concat(ar || Array.prototype.slice.call(from));
95
94
  }
96
95
 
96
+ function registerComponentHelper(loader, component, meta) {
97
+ if (loader) {
98
+ loader.registerComponent(component, meta);
99
+ }
100
+ else {
101
+ registerComponent(component, meta);
102
+ }
103
+ }
104
+ function isOneOf(elem, arr) {
105
+ return arr.includes(elem);
106
+ }
107
+
108
+ var tuple = function () {
109
+ var args = [];
110
+ for (var _i = 0; _i < arguments.length; _i++) {
111
+ args[_i] = arguments[_i];
112
+ }
113
+ return args;
114
+ };
115
+ function mkIdMap(xs) {
116
+ return new Map(xs.map(function (x) { return tuple(x.id, x); }));
117
+ }
118
+ var mkShortId = function () { return "".concat(Math.random()); };
119
+ function withoutNils(xs) {
120
+ return xs.filter(function (x) { return x != null; });
121
+ }
122
+ var DEFAULT_CURRENCY_SETTINGS = {
123
+ dataType: "currency",
124
+ currency: "USD",
125
+ currencyDisplay: "narrowSymbol",
126
+ };
127
+ var NUMBER_TYPES = ["number", "percent", "currency"];
128
+ var DEFAULT_DATETIME_SETTINGS = {
129
+ dataType: "datetime",
130
+ locale: "en-US",
131
+ dateStyle: "short",
132
+ timeStyle: "short",
133
+ hour12: true,
134
+ };
135
+ var DEFAULT_RELATIVE_DATETIME_SETTINGS = {
136
+ dataType: "relative-datetime",
137
+ locale: "en-US",
138
+ numeric: "always",
139
+ style: "long",
140
+ unit: "day",
141
+ };
142
+ var DATETIME_TYPES = ["datetime", "relative-datetime"];
143
+ var DEFAULT_BOOLEAN_SETTINGS = {
144
+ dataType: "boolean",
145
+ showAs: "checkbox",
146
+ };
147
+ function deriveFieldConfigs(specifiedFieldsPartial, schema, makeDefaultConfig) {
148
+ var _a;
149
+ var schemaFields = (_a = schema === null || schema === void 0 ? void 0 : schema.fields) !== null && _a !== void 0 ? _a : [];
150
+ var fieldById = mkIdMap(schemaFields);
151
+ var specifiedFieldIds = new Set(withoutNils(specifiedFieldsPartial.map(function (f) { return f.fieldId; })));
152
+ var keptSpecifiedFields = specifiedFieldsPartial.flatMap(function (f, index) {
153
+ var fieldId = f.fieldId;
154
+ if (!fieldId) {
155
+ return [
156
+ __assign(__assign(__assign({}, makeDefaultConfig(undefined)), { key: index }), f),
157
+ ];
158
+ }
159
+ var field = fieldById.get(fieldId);
160
+ // Drop configs with fieldIds no longer in the data.
161
+ if (!field) {
162
+ return [];
163
+ }
164
+ return [
165
+ __assign(__assign({}, makeDefaultConfig(field)), f),
166
+ ];
167
+ });
168
+ var newVirtualFields = schemaFields
169
+ .filter(function (f) { return !specifiedFieldIds.has(f.id); })
170
+ .map(function (f) { return (__assign({}, makeDefaultConfig(f))); });
171
+ var mergedFields = __spreadArray(__spreadArray([], keptSpecifiedFields, true), newVirtualFields, true);
172
+ var minimalFullLengthFields = __spreadArray(__spreadArray([], specifiedFieldsPartial, true), newVirtualFields.map(function (f) { return ({ key: f.key, fieldId: f.fieldId }); }), true);
173
+ return { mergedFields: mergedFields, minimalFullLengthFields: minimalFullLengthFields };
174
+ }
175
+ function deriveValueType(cconfig) {
176
+ return cconfig.dataType === "auto"
177
+ ? undefined
178
+ : cconfig.dataType === "string"
179
+ ? "text"
180
+ : cconfig.dataType === "number"
181
+ ? "digit"
182
+ : cconfig.dataType === "boolean"
183
+ ? "switch"
184
+ : undefined;
185
+ }
186
+ function buildFieldsPropType(opts) {
187
+ function getDefaultValueHint(field) {
188
+ return function (_item, contextData) {
189
+ if (_item.fieldId) {
190
+ var fieldSetting = contextData === null || contextData === void 0 ? void 0 : contextData.mergedFields.find(function (f) { return f.fieldId === _item.fieldId; });
191
+ return fieldSetting === null || fieldSetting === void 0 ? void 0 : fieldSetting[field];
192
+ }
193
+ return undefined;
194
+ };
195
+ }
196
+ var rowDataType = function (displayName, control) {
197
+ return ({
198
+ type: "function",
199
+ displayName: displayName,
200
+ control: control,
201
+ argNames: ["currentItem", "currentValue"],
202
+ argValues: function (_props, ctx) {
203
+ var _a;
204
+ var row = (_a = ctx === null || ctx === void 0 ? void 0 : ctx.data) === null || _a === void 0 ? void 0 : _a[0];
205
+ var cell = _props.fieldId ? row === null || row === void 0 ? void 0 : row[_props.fieldId] : undefined;
206
+ return [row, cell];
207
+ },
208
+ });
209
+ };
210
+ return {
211
+ type: "array",
212
+ hidden: function (ps) { return !ps.data; },
213
+ unstable__keyFunc: function (x) { return x.key; },
214
+ unstable__minimalValue: function (_props, contextData) {
215
+ return contextData === null || contextData === void 0 ? void 0 : contextData.minimalFullLengthFields;
216
+ },
217
+ unstable__canDelete: function (ps, _props, ctx, _a) {
218
+ var item = _a.item;
219
+ if (!(ctx === null || ctx === void 0 ? void 0 : ctx.schema)) {
220
+ // still loading...
221
+ return false;
222
+ }
223
+ if (item.fieldId &&
224
+ ctx.schema.fields.some(function (f) { return f.id === item.fieldId; })) {
225
+ return false;
226
+ }
227
+ return true;
228
+ },
229
+ itemType: {
230
+ type: "object",
231
+ nameFunc: function (_item) {
232
+ var _a;
233
+ return (_a = _item.title) !== null && _a !== void 0 ? _a : _item.fieldId;
234
+ },
235
+ fields: __assign({ key: {
236
+ type: "string",
237
+ hidden: function () { return true; },
238
+ }, fieldId: {
239
+ type: "choice",
240
+ displayName: "Field name",
241
+ readOnly: true,
242
+ options: function (_props, ctx) { var _a, _b; return ((_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) { return f.id; }); },
243
+ hidden: function (_props, ctx, _a) {
244
+ var _b, _c;
245
+ var _controlPath = _a.path;
246
+ return !(_controlPath.slice(-1)[0] in ((_c = (_b = ctx === null || ctx === void 0 ? void 0 : ctx.schema) === null || _b === void 0 ? void 0 : _b.fields) !== null && _c !== void 0 ? _c : {}));
247
+ },
248
+ }, title: {
249
+ type: "string",
250
+ displayName: "Title",
251
+ defaultValueHint: getDefaultValueHint("title"),
252
+ }, expr: rowDataType("Customize data"), isHidden: {
253
+ type: "boolean",
254
+ displayName: "Is hidden",
255
+ defaultValueHint: getDefaultValueHint("isHidden"),
256
+ }, dataType: {
257
+ type: "choice",
258
+ displayName: "Data type",
259
+ options: [
260
+ {
261
+ value: "auto",
262
+ label: "Auto",
263
+ },
264
+ {
265
+ value: "number",
266
+ label: "Number",
267
+ },
268
+ {
269
+ value: "percent",
270
+ label: "Percentage",
271
+ },
272
+ {
273
+ value: "currency",
274
+ label: "Currency",
275
+ },
276
+ {
277
+ value: "string",
278
+ label: "String",
279
+ },
280
+ {
281
+ value: "boolean",
282
+ label: "Boolean",
283
+ },
284
+ {
285
+ value: "datetime",
286
+ label: "Date / Time",
287
+ },
288
+ {
289
+ value: "relative-datetime",
290
+ label: "Date / Time relative to now",
291
+ },
292
+ ],
293
+ defaultValueHint: getDefaultValueHint("dataType"),
294
+ }, currency: {
295
+ displayName: "Currency",
296
+ description: "Must be a valid currency code",
297
+ type: "string",
298
+ defaultValueHint: "USD",
299
+ hidden: function (ps, ctx, _a) {
300
+ var item = _a.item;
301
+ return item.dataType !== "currency";
302
+ },
303
+ }, locale: {
304
+ displayName: "Locale",
305
+ description: "Must be a valid locale code",
306
+ type: "string",
307
+ defaultValueHint: "en-US",
308
+ hidden: function (ps, ctx, _a) {
309
+ var item = _a.item;
310
+ return !isOneOf(item.dataType, NUMBER_TYPES) &&
311
+ !isOneOf(item.dataType, DATETIME_TYPES);
312
+ },
313
+ }, notation: {
314
+ displayName: "Notation",
315
+ type: "choice",
316
+ options: [
317
+ {
318
+ value: "standard",
319
+ label: "Standard",
320
+ },
321
+ {
322
+ value: "scientific",
323
+ label: "Scientific notation (like 1E3)",
324
+ },
325
+ {
326
+ value: "compact",
327
+ label: "Compact (like 10K)",
328
+ },
329
+ ],
330
+ defaultValueHint: "standard",
331
+ hidden: function (ps, ctx, _a) {
332
+ var item = _a.item;
333
+ return !isOneOf(item.dataType, NUMBER_TYPES);
334
+ },
335
+ }, signDisplay: {
336
+ type: "choice",
337
+ displayName: "Number sign",
338
+ options: [
339
+ {
340
+ value: "auto",
341
+ label: "Only for negative numbers (10, -10)",
342
+ },
343
+ {
344
+ value: "exceptZero",
345
+ label: "Positive or negative (+10, -10)",
346
+ },
347
+ ],
348
+ defaultValueHint: "auto",
349
+ hidden: function (ps, ctx, _a) {
350
+ var item = _a.item;
351
+ return !isOneOf(item.dataType, NUMBER_TYPES);
352
+ },
353
+ }, maximumFractionDigits: {
354
+ type: "number",
355
+ displayName: "Max decimal places",
356
+ defaultValueHint: 3,
357
+ min: 0,
358
+ max: 20,
359
+ hidden: function (ps, ctx, _a) {
360
+ var item = _a.item;
361
+ return !isOneOf(item.dataType, NUMBER_TYPES);
362
+ },
363
+ }, minimumFractionDigits: {
364
+ type: "number",
365
+ displayName: "Min decimal places",
366
+ defaultValueHint: 0,
367
+ min: 0,
368
+ max: 20,
369
+ hidden: function (ps, ctx, _a) {
370
+ var item = _a.item;
371
+ return !isOneOf(item.dataType, NUMBER_TYPES);
372
+ },
373
+ }, showAs: {
374
+ type: "choice",
375
+ options: [
376
+ {
377
+ value: "checkbox",
378
+ label: "Checkboxes",
379
+ },
380
+ {
381
+ value: "switch",
382
+ label: "Toggle switches",
383
+ },
384
+ {
385
+ value: "text",
386
+ label: "Text",
387
+ },
388
+ ],
389
+ displayName: "Show as",
390
+ defaultValueHint: "checkbox",
391
+ hidden: function (ps, ctx, _a) {
392
+ var item = _a.item;
393
+ return item.dataType !== "boolean";
394
+ },
395
+ }, dateStyle: {
396
+ displayName: "Date style",
397
+ type: "choice",
398
+ options: [
399
+ {
400
+ value: "none",
401
+ label: "None (don't display date)",
402
+ },
403
+ {
404
+ value: "short",
405
+ label: "Short (like 12/25/2023)",
406
+ },
407
+ {
408
+ value: "medium",
409
+ label: "Medium (like Dec 25, 2023)",
410
+ },
411
+ {
412
+ value: "long",
413
+ label: "Long (like December 25, 2023)",
414
+ },
415
+ {
416
+ value: "full",
417
+ label: "Full (like Monday, December 25, 2023)",
418
+ },
419
+ ],
420
+ defaultValueHint: DEFAULT_DATETIME_SETTINGS.dateStyle,
421
+ hidden: function (ps, ctx, _a) {
422
+ var item = _a.item;
423
+ return item.dataType !== "datetime";
424
+ },
425
+ }, timeStyle: {
426
+ displayName: "Time style",
427
+ type: "choice",
428
+ options: [
429
+ {
430
+ value: "none",
431
+ label: "None (don't display time)",
432
+ },
433
+ {
434
+ value: "short",
435
+ label: "Short (like 4:00 PM)",
436
+ },
437
+ {
438
+ value: "medium",
439
+ label: "Medium (like 4:00:00 PM)",
440
+ },
441
+ {
442
+ value: "long",
443
+ label: "Long (like 4:00:00 PM PST)",
444
+ },
445
+ {
446
+ value: "full",
447
+ label: "Full (like 4:00:00 PM Pacific Standard Time)",
448
+ },
449
+ ],
450
+ defaultValueHint: DEFAULT_DATETIME_SETTINGS.timeStyle,
451
+ hidden: function (ps, ctx, _a) {
452
+ var item = _a.item;
453
+ return item.dataType !== "datetime";
454
+ },
455
+ }, hour12: {
456
+ displayName: "Use AM/PM?",
457
+ description: "Whether to use AM/PM or 24-hour clock",
458
+ type: "boolean",
459
+ defaultValueHint: DEFAULT_DATETIME_SETTINGS.hour12,
460
+ hidden: function (ps, ctx, _a) {
461
+ var item = _a.item;
462
+ return item.dataType !== "datetime";
463
+ },
464
+ }, numeric: {
465
+ type: "choice",
466
+ displayName: "Use numbers?",
467
+ options: [
468
+ { value: "always", label: "Always use numbers" },
469
+ {
470
+ value: "auto",
471
+ label: "Use words like 'Yesterday' or 'Tomorrow'",
472
+ },
473
+ ],
474
+ defaultValueHint: DEFAULT_RELATIVE_DATETIME_SETTINGS.numeric,
475
+ hidden: function (ps, ctx, _a) {
476
+ var item = _a.item;
477
+ return item.dataType !== "relative-datetime";
478
+ },
479
+ }, unit: {
480
+ type: "choice",
481
+ displayName: "Time unit",
482
+ options: [
483
+ {
484
+ value: "second",
485
+ label: "Seconds",
486
+ },
487
+ {
488
+ value: "minute",
489
+ label: "Minutes",
490
+ },
491
+ {
492
+ value: "hour",
493
+ label: "Hours",
494
+ },
495
+ {
496
+ value: "day",
497
+ label: "Days",
498
+ },
499
+ {
500
+ value: "week",
501
+ label: "Weeks",
502
+ },
503
+ {
504
+ value: "month",
505
+ label: "Months",
506
+ },
507
+ {
508
+ value: "year",
509
+ label: "Years",
510
+ },
511
+ ],
512
+ defaultValueHint: DEFAULT_RELATIVE_DATETIME_SETTINGS.unit,
513
+ hidden: function (ps, ctx, _a) {
514
+ var item = _a.item;
515
+ return item.dataType !== "relative-datetime";
516
+ },
517
+ } }, opts.fieldTypes),
518
+ },
519
+ };
520
+ }
521
+
522
+ function normalizeData(rawData) {
523
+ var _a;
524
+ if (!rawData) {
525
+ return undefined;
526
+ }
527
+ var dataArray = tryGetDataArray(rawData);
528
+ if (!dataArray) {
529
+ return undefined;
530
+ }
531
+ var schema = (_a = rawData.schema) !== null && _a !== void 0 ? _a : tryGetSchema(dataArray);
532
+ if (!schema) {
533
+ return undefined;
534
+ }
535
+ return { data: dataArray, schema: schema };
536
+ }
537
+ function tryGetDataArray(rawData) {
538
+ if (!rawData || typeof rawData !== "object") {
539
+ return undefined;
540
+ }
541
+ if (Array.isArray(rawData)) {
542
+ if (isArrayOfObjects(rawData)) {
543
+ return rawData;
544
+ }
545
+ else {
546
+ // TODO: array of primitives? Maybe we can wrap this?
547
+ return undefined;
548
+ }
549
+ }
550
+ if ("data" in rawData && Array.isArray(rawData.data)) {
551
+ if (isArrayOfObjects(rawData.data)) {
552
+ return rawData.data;
553
+ }
554
+ else {
555
+ return undefined;
556
+ }
557
+ }
558
+ if ("isLoading" in rawData || "error" in rawData) {
559
+ return undefined;
560
+ }
561
+ // Maybe a singleton record?
562
+ return [rawData];
563
+ }
564
+ function isArrayOfObjects(arr) {
565
+ return arr.every(function (x) { return typeof x === "object" && !Array.isArray(x); });
566
+ }
567
+ function tryGetSchema(data) {
568
+ var fieldMap = {};
569
+ data.forEach(function (entry) {
570
+ if (entry && typeof entry === "object") {
571
+ Array.from(Object.entries(entry)).forEach(function (_a) {
572
+ var k = _a[0], v = _a[1];
573
+ var inferredType = typeof v === "string"
574
+ ? "string"
575
+ : typeof v === "boolean"
576
+ ? "boolean"
577
+ : typeof v === "number"
578
+ ? "number"
579
+ : "unknown";
580
+ if (fieldMap[k] && fieldMap[k] !== inferredType) {
581
+ fieldMap[k] = "unknown";
582
+ }
583
+ else {
584
+ fieldMap[k] = inferredType;
585
+ }
586
+ });
587
+ }
588
+ });
589
+ return {
590
+ id: "inferred",
591
+ fields: Object.entries(fieldMap).map(function (_a) {
592
+ var f = _a[0], t = _a[1];
593
+ return ({
594
+ id: f,
595
+ type: t,
596
+ readOnly: false,
597
+ });
598
+ }),
599
+ };
600
+ }
601
+
602
+ function renderValue(value, record, cconfig) {
603
+ if (cconfig.expr) {
604
+ value = cconfig.expr(record, value);
605
+ }
606
+ if (value == null) {
607
+ return "";
608
+ }
609
+ if (cconfig.dataType === "auto") {
610
+ return renderAuto(value);
611
+ }
612
+ else {
613
+ var coerced = coerceValue(value, cconfig.dataType);
614
+ if (isOneOf(cconfig.dataType, NUMBER_TYPES) &&
615
+ typeof coerced === "number") {
616
+ return renderNumber(coerced, cconfig);
617
+ }
618
+ else if (cconfig.dataType === "boolean" && typeof coerced === "boolean") {
619
+ return renderBoolean(coerced, cconfig);
620
+ }
621
+ else if (cconfig.dataType === "datetime" && coerced instanceof Date) {
622
+ return renderDate(coerced, cconfig);
623
+ }
624
+ else if (cconfig.dataType === "relative-datetime" &&
625
+ coerced instanceof Date) {
626
+ return renderRelativeDate(coerced, cconfig);
627
+ }
628
+ return asString(value);
629
+ }
630
+ }
631
+ function renderAuto(value) {
632
+ if (typeof value === "number") {
633
+ return renderNumber(value, { dataType: "number" });
634
+ }
635
+ else if (typeof value === "boolean") {
636
+ return renderBoolean(value, DEFAULT_BOOLEAN_SETTINGS);
637
+ }
638
+ else if (value instanceof Date) {
639
+ return renderDate(value, DEFAULT_DATETIME_SETTINGS);
640
+ }
641
+ else {
642
+ var coerced = tryCoerceAuto(value);
643
+ if (coerced === CANNOT_COERCE) {
644
+ return asString(value);
645
+ }
646
+ else {
647
+ return renderAuto(coerced);
648
+ }
649
+ }
650
+ }
651
+ function tryCoerceAuto(value) {
652
+ for (var _i = 0, _a = [
653
+ "number",
654
+ "datetime",
655
+ ]; _i < _a.length; _i++) {
656
+ var dataType = _a[_i];
657
+ var coerced = coerceValue(value, dataType);
658
+ if (coerced !== CANNOT_COERCE) {
659
+ return coerced;
660
+ }
661
+ }
662
+ return CANNOT_COERCE;
663
+ }
664
+ function renderNumber(value, cconfig) {
665
+ if (cconfig.dataType === "number") {
666
+ return new Intl.NumberFormat(cconfig.locale, cconfig).format(value);
667
+ }
668
+ else if (cconfig.dataType === "percent") {
669
+ return new Intl.NumberFormat(cconfig.locale, __assign(__assign({}, cconfig), { style: "percent" })).format(value);
670
+ }
671
+ else if (cconfig.dataType === "currency") {
672
+ return new Intl.NumberFormat(cconfig.locale, __assign(__assign(__assign({}, DEFAULT_CURRENCY_SETTINGS), cconfig), { style: "currency" })).format(value);
673
+ }
674
+ else {
675
+ throw new Error("Unexpected dataType ".concat(cconfig.dataType));
676
+ }
677
+ }
678
+ function renderDate(value, cconfig) {
679
+ var opts = __assign(__assign({}, DEFAULT_DATETIME_SETTINGS), cconfig);
680
+ if (opts.dateStyle === "none") {
681
+ delete opts["dateStyle"];
682
+ }
683
+ if (opts.timeStyle === "none") {
684
+ delete opts["timeStyle"];
685
+ }
686
+ return new Intl.DateTimeFormat(cconfig.locale, opts).format(value);
687
+ }
688
+ var SECOND_MS = 1000;
689
+ var MINUTE_MS = 60 * SECOND_MS;
690
+ var HOUR_MS = 60 * MINUTE_MS;
691
+ var DAY_MS = 24 * HOUR_MS;
692
+ var WEEK_MS = 7 * DAY_MS;
693
+ var UNIT_TO_MS = {
694
+ second: SECOND_MS,
695
+ minute: MINUTE_MS,
696
+ hour: HOUR_MS,
697
+ day: DAY_MS,
698
+ week: WEEK_MS,
699
+ };
700
+ var UNITS_BY_MS = Object.keys(UNIT_TO_MS);
701
+ function renderRelativeDate(value, cconfig) {
702
+ var _a;
703
+ var opts = __assign(__assign({}, DEFAULT_RELATIVE_DATETIME_SETTINGS), cconfig);
704
+ var unit = (_a = cconfig.unit) !== null && _a !== void 0 ? _a : "day";
705
+ var formatter = new Intl.RelativeTimeFormat(cconfig.locale, opts);
706
+ if (isOneOf(unit, UNITS_BY_MS)) {
707
+ // for "exact" units, we can do it by just calcluating the difference
708
+ // by ms
709
+ var diff = value.getTime() - new Date().getTime();
710
+ return formatter.format(Math.round(diff / UNIT_TO_MS[unit]), unit);
711
+ }
712
+ else {
713
+ // otherwise we need to calculate by the specific unit
714
+ if (unit === "year") {
715
+ var diff = value.getFullYear() - new Date().getFullYear();
716
+ return formatter.format(diff, unit);
717
+ }
718
+ else if (unit === "month") {
719
+ var months = function (d) { return d.getFullYear() * 12 + d.getMonth() + 1; };
720
+ var diff = months(value) - months(new Date());
721
+ return formatter.format(diff, unit);
722
+ }
723
+ else {
724
+ throw new Error("Unexpected relative time unit ".concat(unit));
725
+ }
726
+ }
727
+ }
728
+ function renderBoolean(value, cconfig) {
729
+ var _a;
730
+ var showAs = (_a = cconfig.showAs) !== null && _a !== void 0 ? _a : DEFAULT_BOOLEAN_SETTINGS.showAs;
731
+ if (showAs === "checkbox") {
732
+ return React.createElement(Checkbox, { checked: value });
733
+ }
734
+ else if (showAs === "switch") {
735
+ return React.createElement(Switch, { checked: value });
736
+ }
737
+ else {
738
+ return value ? "true" : "false";
739
+ }
740
+ }
741
+ var CANNOT_COERCE = Symbol("plasmic-cannot-coerce");
742
+ function coerceValue(value, dataType) {
743
+ if (value == null) {
744
+ return null;
745
+ }
746
+ try {
747
+ if (isOneOf(dataType, NUMBER_TYPES)) {
748
+ if (typeof value === "number") {
749
+ return value;
750
+ }
751
+ else if (typeof value === "string") {
752
+ var maybeNumber = +value;
753
+ if (!isNaN(maybeNumber)) {
754
+ return maybeNumber;
755
+ }
756
+ }
757
+ }
758
+ else if (isOneOf(dataType, DATETIME_TYPES)) {
759
+ if (value instanceof Date) {
760
+ return value;
761
+ }
762
+ else if (typeof value === "number") {
763
+ return new Date(value);
764
+ }
765
+ else if (typeof value === "string") {
766
+ var maybeDate = new Date(value);
767
+ if (!isNaN(maybeDate.getTime())) {
768
+ return maybeDate;
769
+ }
770
+ }
771
+ }
772
+ else if (dataType === "boolean") {
773
+ if (value === true || value === false) {
774
+ return value;
775
+ }
776
+ else if (typeof value === "number") {
777
+ return value !== 0;
778
+ }
779
+ else if (typeof value === "string") {
780
+ return value.toLowerCase() === "true";
781
+ }
782
+ }
783
+ else if (dataType === "string") {
784
+ return asString(value);
785
+ }
786
+ else if (dataType === "auto") {
787
+ return value;
788
+ }
789
+ }
790
+ catch (err) {
791
+ // Ignore error; just fail to coerce
792
+ }
793
+ return CANNOT_COERCE;
794
+ }
795
+ function asString(value) {
796
+ if (value == null) {
797
+ return "";
798
+ }
799
+ else if (typeof value === "string") {
800
+ return value;
801
+ }
802
+ else if (typeof value === "object") {
803
+ if ("toString" in value && typeof value.toString === "function") {
804
+ return value.toString();
805
+ }
806
+ else {
807
+ return JSON.stringify(value);
808
+ }
809
+ }
810
+ else {
811
+ return "".concat(value);
812
+ }
813
+ }
814
+
815
+ function RichDetails(props) {
816
+ var _a;
817
+ 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;
818
+ var data = normalizeData(rawData);
819
+ var columnDefinitions = useColumnDefinitions$1(data, props).columnDefinitions;
820
+ if (!data) {
821
+ return React.createElement(Empty, { className: className });
822
+ }
823
+ return (React.createElement(ProDescriptions, { className: className, dataSource: (_a = data === null || data === void 0 ? void 0 : data.data) === null || _a === void 0 ? void 0 : _a[0], columns: columnDefinitions, size: size, bordered: bordered, layout: layout, column: {
824
+ xs: 1,
825
+ sm: 1,
826
+ md: column,
827
+ } }));
828
+ }
829
+ function useColumnDefinitions$1(data, props) {
830
+ var fields = props.fields, setControlContextData = props.setControlContextData;
831
+ return React.useMemo(function () {
832
+ var schema = data === null || data === void 0 ? void 0 : data.schema;
833
+ if (!data || !schema) {
834
+ return { normalized: [], columnDefinitions: [] };
835
+ }
836
+ var _a = deriveFieldConfigs(fields !== null && fields !== void 0 ? fields : [], schema, function (field) { return (__assign({ key: mkShortId(), isHidden: false, dataType: "auto" }, (field && {
837
+ key: field.id,
838
+ fieldId: field.id,
839
+ title: field.label || field.id,
840
+ expr: function (currentItem) { return currentItem[field.id]; },
841
+ }))); }), mergedFields = _a.mergedFields, minimalFullLengthFields = _a.minimalFullLengthFields;
842
+ setControlContextData === null || setControlContextData === void 0 ? void 0 : setControlContextData(__assign(__assign({}, data), { mergedFields: mergedFields, minimalFullLengthFields: minimalFullLengthFields }));
843
+ var normalized = mergedFields;
844
+ var columnDefinitions = normalized
845
+ .filter(function (cconfig) { return !cconfig.isHidden; })
846
+ .map(function (cconfig, _columnIndex, _columnsArray) {
847
+ var columnDefinition = {
848
+ dataIndex: cconfig.fieldId,
849
+ title: cconfig.title,
850
+ key: cconfig.key,
851
+ valueType: deriveValueType(cconfig),
852
+ span: cconfig.span,
853
+ // To come later
854
+ copyable: false,
855
+ ellipsis: false,
856
+ tip: undefined,
857
+ formItemProps: {
858
+ rules: [],
859
+ },
860
+ valueEnum: undefined,
861
+ renderFormItem: function (_, _a) {
862
+ var defaultRender = _a.defaultRender;
863
+ return defaultRender(_);
864
+ },
865
+ render: function (value, record, rowIndex) {
866
+ return renderValue(value, record, cconfig);
867
+ },
868
+ };
869
+ return columnDefinition;
870
+ });
871
+ return { normalized: normalized, columnDefinitions: columnDefinitions };
872
+ }, [fields, data, setControlContextData]);
873
+ }
874
+
875
+ function registerRichDetails(loader) {
876
+ registerComponentHelper(loader, RichDetails, {
877
+ name: "hostless-rich-details",
878
+ displayName: "Data details",
879
+ defaultStyles: {
880
+ width: "stretch",
881
+ maxHeight: "100%",
882
+ },
883
+ props: {
884
+ data: {
885
+ type: "dataSourceOpData",
886
+ description: "The data to display",
887
+ },
888
+ fields: buildFieldsPropType({
889
+ fieldTypes: {
890
+ span: {
891
+ type: "number",
892
+ displayName: "Number of columns to span",
893
+ defaultValueHint: 1,
894
+ },
895
+ },
896
+ }),
897
+ layout: {
898
+ displayName: "Layout",
899
+ type: "choice",
900
+ options: [
901
+ { value: "horizontal", label: "Horizontal" },
902
+ { value: "vertical", label: "Vertical" },
903
+ ],
904
+ defaultValueHint: "horizontal",
905
+ },
906
+ column: {
907
+ displayName: "Items per row",
908
+ type: "number",
909
+ description: "Number of items to display per row",
910
+ defaultValueHint: 2,
911
+ },
912
+ size: {
913
+ displayName: "Spacing",
914
+ type: "choice",
915
+ options: [
916
+ { value: "small", label: "Small" },
917
+ { value: "middle", label: "Medium" },
918
+ { value: "default", label: "Large" },
919
+ ],
920
+ defaultValueHint: "default",
921
+ },
922
+ bordered: {
923
+ displayName: "Show borders?",
924
+ type: "boolean",
925
+ defaultValueHint: false,
926
+ },
927
+ },
928
+ importPath: "@plasmicpkgs/plasmic-rich-components",
929
+ importName: "RichDetails",
930
+ });
931
+ }
932
+
97
933
  function useIsClient() {
98
934
  var _a = useState(false), loaded = _a[0], setLoaded = _a[1];
99
935
  useEffect(function () {
@@ -105,15 +941,6 @@ function capitalize(text) {
105
941
  return text.slice(0, 1).toUpperCase() + text.slice(1);
106
942
  }
107
943
 
108
- function registerComponentHelper(loader, component, meta) {
109
- if (loader) {
110
- loader.registerComponent(component, meta);
111
- }
112
- else {
113
- registerComponent(component, meta);
114
- }
115
- }
116
-
117
944
  function RichLayout(_a) {
118
945
  var _b, _c, _d;
119
946
  var children = _a.children, navMenuItems = _a.navMenuItems, _e = _a.rootUrl, rootUrl = _e === void 0 ? "/" : _e, actionsChildren = _a.actionsChildren, footerChildren = _a.footerChildren, avatarLabel = _a.avatarLabel, avatarImage = _a.avatarImage, showAvatarMenu = _a.showAvatarMenu, className = _a.className, layoutProps = __rest(_a, ["children", "navMenuItems", "rootUrl", "actionsChildren", "footerChildren", "avatarLabel", "avatarImage", "showAvatarMenu", "className"]);
@@ -321,142 +1148,6 @@ function registerRichLayout(loader) {
321
1148
  registerComponentHelper(loader, RichLayout, richLayoutMeta);
322
1149
  }
323
1150
 
324
- var tuple = function () {
325
- var args = [];
326
- for (var _i = 0; _i < arguments.length; _i++) {
327
- args[_i] = arguments[_i];
328
- }
329
- return args;
330
- };
331
- function mkIdMap(xs) {
332
- return new Map(xs.map(function (x) { return tuple(x.id, x); }));
333
- }
334
- var mkShortId = function () { return "".concat(Math.random()); };
335
- var withoutNils = function (xs) {
336
- return xs.filter(function (x) { return x != null; });
337
- };
338
- var defaultColumnConfig = function () {
339
- return ({
340
- key: mkShortId(),
341
- isEditableExpr: function () { return false; },
342
- disableSorting: false,
343
- sortByExpr: undefined,
344
- isHidden: false,
345
- formatting: {
346
- styles: {},
347
- align: "left",
348
- freeze: "off",
349
- },
350
- dataType: "auto",
351
- });
352
- };
353
- function deriveFieldConfigs(specifiedFieldsPartial, schema) {
354
- var _a;
355
- var schemaFields = (_a = schema === null || schema === void 0 ? void 0 : schema.fields) !== null && _a !== void 0 ? _a : [];
356
- var fieldById = mkIdMap(schemaFields);
357
- var specifiedFieldIds = new Set(withoutNils(specifiedFieldsPartial.map(function (f) { return f.fieldId; })));
358
- function defaultColumnConfigForField(field) {
359
- return __assign(__assign({}, defaultColumnConfig()), { key: field.id, fieldId: field.id, title: field.label || field.id, expr: function (currentItem) { return currentItem[field.id]; } });
360
- }
361
- var keptSpecifiedFields = specifiedFieldsPartial.flatMap(function (f, index) {
362
- var fieldId = f.fieldId;
363
- if (!fieldId) {
364
- return [
365
- __assign(__assign(__assign({}, defaultColumnConfig()), { key: index }), f),
366
- ];
367
- }
368
- var field = fieldById.get(fieldId);
369
- // Drop configs with fieldIds no longer in the data.
370
- if (!field) {
371
- return [];
372
- }
373
- return [
374
- __assign(__assign({}, defaultColumnConfigForField(field)), f),
375
- ];
376
- });
377
- var newVirtualFields = schemaFields
378
- .filter(function (f) { return !specifiedFieldIds.has(f.id); })
379
- .map(function (f) { return (__assign({}, defaultColumnConfigForField(f))); });
380
- var mergedFields = __spreadArray(__spreadArray([], keptSpecifiedFields, true), newVirtualFields, true);
381
- var minimalFullLengthFields = __spreadArray(__spreadArray([], specifiedFieldsPartial, true), newVirtualFields.map(function (f) { return ({ key: f.key, fieldId: f.fieldId }); }), true);
382
- return { mergedFields: mergedFields, minimalFullLengthFields: minimalFullLengthFields };
383
- }
384
-
385
- function tryGetSchema(data) {
386
- if (data === null || data === void 0 ? void 0 : data.schema) {
387
- return data.schema;
388
- }
389
- if (Array.isArray(data)) {
390
- data = { data: data };
391
- }
392
- if (!(data === null || data === void 0 ? void 0 : data.data) || !Array.isArray(data.data) || data.data.length === 0) {
393
- return undefined;
394
- }
395
- var fieldMap = {};
396
- data.data.forEach(function (entry) {
397
- if (entry && typeof entry === "object") {
398
- Array.from(Object.entries(entry)).forEach(function (_a) {
399
- var k = _a[0], v = _a[1];
400
- var inferredType = typeof v === "string"
401
- ? "string"
402
- : typeof v === "boolean"
403
- ? "boolean"
404
- : typeof v === "number"
405
- ? "number"
406
- : "unknown";
407
- if (fieldMap[k] && fieldMap[k] !== inferredType) {
408
- fieldMap[k] = "unknown";
409
- }
410
- else {
411
- fieldMap[k] = inferredType;
412
- }
413
- });
414
- }
415
- });
416
- return {
417
- id: "inferred",
418
- fields: Object.entries(fieldMap).map(function (_a) {
419
- var f = _a[0], t = _a[1];
420
- return ({
421
- id: f,
422
- type: t,
423
- readOnly: false,
424
- });
425
- }),
426
- };
427
- }
428
- function normalizeData(rawData) {
429
- if (!rawData || typeof rawData !== "object") {
430
- return undefined;
431
- }
432
- var obj = Array.isArray(rawData) ? { data: rawData } : rawData;
433
- if (!("data" in obj)) {
434
- return undefined;
435
- }
436
- var objWithData = obj;
437
- if (!Array.isArray(objWithData.data) || objWithData.data.length === 0) {
438
- return undefined;
439
- }
440
- // Make TS happy.
441
- var normed = __assign(__assign({}, objWithData), { data: objWithData.data });
442
- var schema = tryGetSchema(rawData);
443
- if (!schema) {
444
- return undefined;
445
- }
446
- return __assign(__assign({}, normed), { schema: schema });
447
- }
448
- /**
449
- * Render booleans, objects, arrays, etc. as JSON repr.
450
- */
451
- function safeRender(x) {
452
- return x === undefined || x === null
453
- ? ""
454
- : typeof x === "string"
455
- ? x
456
- : typeof x === "number"
457
- ? x.toString()
458
- : JSON.stringify(x);
459
- }
460
1151
  function RichTable(props) {
461
1152
  var className = props.className, _a = props.data, rawData = _a === void 0 ? {
462
1153
  data: [],
@@ -474,7 +1165,7 @@ function RichTable(props) {
474
1165
  // children,
475
1166
  _b = props.pagination,
476
1167
  // children,
477
- 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; props.themeResetClassName;
1168
+ 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;
478
1169
  var data = normalizeData(rawData);
479
1170
  var _f = useColumnDefinitions(data, props), columnDefinitions = _f.columnDefinitions, normalized = _f.normalized;
480
1171
  var actionRef = useRef();
@@ -533,7 +1224,7 @@ function deriveRowKey(data, rowKey) {
533
1224
  if (rowKey) {
534
1225
  return rowKey;
535
1226
  }
536
- var schema = tryGetSchema(data);
1227
+ var schema = data === null || data === void 0 ? void 0 : data.schema;
537
1228
  if (schema) {
538
1229
  return (_a = schema.fields[0]) === null || _a === void 0 ? void 0 : _a.id;
539
1230
  }
@@ -550,14 +1241,34 @@ function deriveKeyOfRow(row, rowKey) {
550
1241
  return undefined;
551
1242
  }
552
1243
  }
1244
+ var defaultColumnConfig = function () {
1245
+ return ({
1246
+ key: mkShortId(),
1247
+ isEditableExpr: function () { return false; },
1248
+ disableSorting: false,
1249
+ sortByExpr: undefined,
1250
+ isHidden: false,
1251
+ formatting: {
1252
+ styles: {},
1253
+ align: "left",
1254
+ freeze: "off",
1255
+ },
1256
+ dataType: "auto",
1257
+ });
1258
+ };
553
1259
  function useColumnDefinitions(data, props) {
554
1260
  var fields = props.fields, setControlContextData = props.setControlContextData, rowActions = props.rowActions;
555
1261
  return React.useMemo(function () {
556
- var schema = tryGetSchema(data);
1262
+ var schema = data === null || data === void 0 ? void 0 : data.schema;
557
1263
  if (!data || !schema) {
558
1264
  return { normalized: [], columnDefinitions: [] };
559
1265
  }
560
- var _a = deriveFieldConfigs(fields !== null && fields !== void 0 ? fields : [], schema), mergedFields = _a.mergedFields, minimalFullLengthFields = _a.minimalFullLengthFields;
1266
+ var _a = deriveFieldConfigs(fields !== null && fields !== void 0 ? fields : [], schema, function (field) { return (__assign(__assign({}, defaultColumnConfig()), (field && {
1267
+ key: field.id,
1268
+ fieldId: field.id,
1269
+ title: field.label || field.id,
1270
+ expr: function (currentItem) { return currentItem[field.id]; },
1271
+ }))); }), mergedFields = _a.mergedFields, minimalFullLengthFields = _a.minimalFullLengthFields;
561
1272
  setControlContextData === null || setControlContextData === void 0 ? void 0 : setControlContextData(__assign(__assign({}, data), { mergedFields: mergedFields, minimalFullLengthFields: minimalFullLengthFields }));
562
1273
  var normalized = mergedFields;
563
1274
  var columnDefinitions = normalized
@@ -568,15 +1279,7 @@ function useColumnDefinitions(data, props) {
568
1279
  title: cconfig.title,
569
1280
  // dataIndex: cconfig,
570
1281
  key: cconfig.key,
571
- valueType: cconfig.dataType === "auto"
572
- ? undefined
573
- : cconfig.dataType === "string"
574
- ? "text"
575
- : cconfig.dataType === "number"
576
- ? "digit"
577
- : cconfig.dataType === "boolean"
578
- ? "switch"
579
- : undefined,
1282
+ valueType: deriveValueType(cconfig),
580
1283
  // To come later
581
1284
  readonly: false,
582
1285
  sorter: true,
@@ -595,9 +1298,7 @@ function useColumnDefinitions(data, props) {
595
1298
  return defaultRender(_);
596
1299
  },
597
1300
  render: function (value, record, rowIndex) {
598
- return (React.createElement(DataProvider, { name: "currentRow", data: record },
599
- React.createElement(DataProvider, { name: "currentRowIndex", data: rowIndex },
600
- React.createElement(DataProvider, { name: "currentColumn", data: value }, safeRender(cconfig.expr ? cconfig.expr(record) : value)))));
1301
+ return renderValue(value, record, cconfig);
601
1302
  },
602
1303
  };
603
1304
  return columnDefinition;
@@ -649,10 +1350,11 @@ function useSortedFilteredData(data, columns) {
649
1350
  ? // We use .sort() rather than sortBy to use localeCompare
650
1351
  (function () {
651
1352
  var _a;
652
- var expr = (_a = columns.find(function (cconfig) { var _a; return cconfig.key === ((_a = sortState === null || sortState === void 0 ? void 0 : sortState.sorter.column) === null || _a === void 0 ? void 0 : _a.key); }).expr) !== null && _a !== void 0 ? _a : (function (x) { return x; });
1353
+ 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); });
1354
+ var expr = (_a = cconfig.expr) !== null && _a !== void 0 ? _a : (function (x) { return x; });
653
1355
  return (filtered !== null && filtered !== void 0 ? filtered : []).sort(function (aa, bb) {
654
1356
  var _a, _b;
655
- var a = (_a = expr(aa)) !== null && _a !== void 0 ? _a : null, b = (_b = expr(bb)) !== null && _b !== void 0 ? _b : null;
1357
+ 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;
656
1358
  // Default nil to '' here because A < null < z which is weird.
657
1359
  return typeof a === "string"
658
1360
  ? a.localeCompare(b !== null && b !== void 0 ? b : "")
@@ -750,7 +1452,7 @@ function ExportMenu(props) {
750
1452
  var _a, _b;
751
1453
  return __generator(this, function (_c) {
752
1454
  writer = createObjectCsvStringifier({
753
- header: (_b = (_a = tryGetSchema(data)) === null || _a === void 0 ? void 0 : _a.fields.map(function (f) { return ({
1455
+ header: (_b = (_a = data === null || data === void 0 ? void 0 : data.schema) === null || _a === void 0 ? void 0 : _a.fields.map(function (f) { return ({
754
1456
  id: f.id,
755
1457
  title: f.id,
756
1458
  }); })) !== null && _b !== void 0 ? _b : [],
@@ -800,9 +1502,6 @@ function ExportMenu(props) {
800
1502
  React.createElement(EllipsisOutlined, null))));
801
1503
  }
802
1504
 
803
- function ensureNumber(x) {
804
- return x;
805
- }
806
1505
  var tableHelpers = {
807
1506
  states: {
808
1507
  selectedRow: {
@@ -822,21 +1521,6 @@ var tableHelpers = {
822
1521
  },
823
1522
  },
824
1523
  };
825
- var rowDataType = function (displayName, control) {
826
- return ({
827
- type: "function",
828
- displayName: displayName,
829
- control: control,
830
- argNames: ["currentItem"],
831
- 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]]; },
832
- });
833
- };
834
- function getDefaultValueHint(field) {
835
- return function (_props, contextData, _a) {
836
- var path = _a.path;
837
- return contextData === null || contextData === void 0 ? void 0 : contextData.mergedFields[ensureNumber(path.slice(-2)[0])][field];
838
- };
839
- }
840
1524
  var dataTableMeta = {
841
1525
  name: "hostless-rich-table",
842
1526
  displayName: "Table",
@@ -850,93 +1534,7 @@ var dataTableMeta = {
850
1534
  type: "dataSourceOpData",
851
1535
  description: "The data to display in the table",
852
1536
  },
853
- defaultSize: {
854
- displayName: "Density",
855
- type: "choice",
856
- options: [
857
- {
858
- value: "large",
859
- label: "Larger",
860
- },
861
- {
862
- value: "middle",
863
- label: "Medium",
864
- },
865
- {
866
- value: "small",
867
- label: "Compact",
868
- },
869
- ],
870
- defaultValueHint: "large",
871
- },
872
- pageSize: {
873
- type: "number",
874
- defaultValueHint: 10,
875
- },
876
- fields: {
877
- type: "array",
878
- hidden: function (ps) { return !ps.data; },
879
- unstable__keyFunc: function (x) { return x.key; },
880
- unstable__minimalValue: function (_props, contextData) {
881
- return contextData === null || contextData === void 0 ? void 0 : contextData.minimalFullLengthFields;
882
- },
883
- unstable__canDelete: function (_item, _props, ctx, _a) {
884
- var path = _a.path;
885
- return !(ctx === null || ctx === void 0 ? void 0 : ctx.mergedFields[ensureNumber(path.slice(-1)[0])].fieldId);
886
- },
887
- itemType: {
888
- type: "object",
889
- nameFunc: function (_item, _props, ctx, _a) {
890
- var path = _a.path;
891
- return ctx === null || ctx === void 0 ? void 0 : ctx.mergedFields[ensureNumber(path.slice(-1)[0])].title;
892
- },
893
- fields: {
894
- key: {
895
- type: "string",
896
- hidden: function () { return true; },
897
- },
898
- fieldId: {
899
- type: "choice",
900
- displayName: "Field name",
901
- readOnly: true,
902
- options: function (_props, ctx) { var _a, _b; return ((_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) { return f.id; }); },
903
- hidden: function (_props, ctx, _a) {
904
- var _b, _c;
905
- var _controlPath = _a.path;
906
- return !(_controlPath.slice(-1)[0] in ((_c = (_b = ctx === null || ctx === void 0 ? void 0 : ctx.schema) === null || _b === void 0 ? void 0 : _b.fields) !== null && _c !== void 0 ? _c : {}));
907
- },
908
- },
909
- title: {
910
- type: "string",
911
- displayName: "Title",
912
- defaultValueHint: getDefaultValueHint("title"),
913
- },
914
- dataType: {
915
- type: "choice",
916
- displayName: "Data type",
917
- options: ["auto", "number", "string", "boolean"],
918
- defaultValueHint: getDefaultValueHint("dataType"),
919
- },
920
- expr: rowDataType("Customize data"),
921
- // TODO
922
- // isEditableExpr: rowDataType("Is editable", {
923
- // type: "boolean",
924
- // defaultValueHint: false,
925
- // }),
926
- // disableSorting: {
927
- // type: "boolean",
928
- // displayName: "Disable sorting",
929
- // defaultValueHint: getDefaultValueHint("disableSorting"),
930
- // },
931
- // sortByExpr: rowDataType("Sort by"),
932
- isHidden: {
933
- type: "boolean",
934
- displayName: "Is hidden",
935
- defaultValueHint: getDefaultValueHint("isHidden"),
936
- },
937
- },
938
- },
939
- },
1537
+ fields: buildFieldsPropType({}),
940
1538
  canSelectRows: {
941
1539
  type: "choice",
942
1540
  displayName: "Select rows?",
@@ -991,7 +1589,7 @@ var dataTableMeta = {
991
1589
  advanced: true,
992
1590
  itemType: {
993
1591
  type: "object",
994
- nameFunc: function (ps) { return ps.label; },
1592
+ nameFunc: function (item) { return item.label; },
995
1593
  fields: {
996
1594
  type: {
997
1595
  type: "choice",
@@ -1021,7 +1619,10 @@ var dataTableMeta = {
1021
1619
  },
1022
1620
  },
1023
1621
  },
1024
- hidden: function (ps) { return ps.type !== "menu"; },
1622
+ hidden: function (ps, ctx, _a) {
1623
+ var item = _a.item;
1624
+ return item.type !== "menu";
1625
+ },
1025
1626
  },
1026
1627
  onClick: {
1027
1628
  type: "eventHandler",
@@ -1030,11 +1631,39 @@ var dataTableMeta = {
1030
1631
  { name: "rowKey", type: "string" },
1031
1632
  { name: "row", type: "object" },
1032
1633
  ],
1033
- hidden: function (ps) { return ps.type !== "item"; },
1634
+ hidden: function (ps, ctx, _a) {
1635
+ var item = _a.item;
1636
+ return item.type !== "item";
1637
+ },
1034
1638
  },
1035
1639
  },
1036
1640
  },
1037
1641
  },
1642
+ defaultSize: {
1643
+ displayName: "Density",
1644
+ type: "choice",
1645
+ options: [
1646
+ {
1647
+ value: "large",
1648
+ label: "Larger",
1649
+ },
1650
+ {
1651
+ value: "middle",
1652
+ label: "Medium",
1653
+ },
1654
+ {
1655
+ value: "small",
1656
+ label: "Compact",
1657
+ },
1658
+ ],
1659
+ defaultValueHint: "large",
1660
+ advanced: true,
1661
+ },
1662
+ pageSize: {
1663
+ type: "number",
1664
+ defaultValueHint: 10,
1665
+ advanced: true,
1666
+ },
1038
1667
  pagination: {
1039
1668
  type: "boolean",
1040
1669
  advanced: true,
@@ -1097,7 +1726,8 @@ function registerRichTable(loader) {
1097
1726
  function registerAll(loader) {
1098
1727
  registerRichLayout(loader);
1099
1728
  registerRichTable(loader);
1729
+ registerRichDetails(loader);
1100
1730
  }
1101
1731
 
1102
- export { RichLayout, RichTable, registerAll, tableHelpers };
1732
+ export { RichDetails, RichLayout, RichTable, registerAll, tableHelpers };
1103
1733
  //# sourceMappingURL=plasmic-rich-components.esm.js.map