@plasmicpkgs/plasmic-rich-components 1.0.61 → 1.0.63

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,4 +1,4 @@
1
- import React, { useState, useEffect, useRef, useMemo } from 'react';
1
+ import React, { useState, useEffect, useRef } from 'react';
2
2
  import registerComponent from '@plasmicapp/host/registerComponent';
3
3
  import '@plasmicapp/host/registerGlobalContext';
4
4
  import { LogoutOutlined, PlusOutlined, EllipsisOutlined } from '@ant-design/icons';
@@ -8,1598 +8,950 @@ import { DataProvider } from '@plasmicapp/host';
8
8
  import { createObjectCsvStringifier } from 'csv-writer-browser';
9
9
  import fastStringify from 'fast-stringify';
10
10
 
11
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
12
- try {
13
- var info = gen[key](arg);
14
- var value = info.value;
15
- } catch (error) {
16
- reject(error);
17
- return;
18
- }
19
- if (info.done) {
20
- resolve(value);
21
- } else {
22
- Promise.resolve(value).then(_next, _throw);
23
- }
24
- }
25
- function _asyncToGenerator(fn) {
26
- return function () {
27
- var self = this,
28
- args = arguments;
29
- return new Promise(function (resolve, reject) {
30
- var gen = fn.apply(self, args);
31
- function _next(value) {
32
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
33
- }
34
- function _throw(err) {
35
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
36
- }
37
- _next(undefined);
38
- });
39
- };
40
- }
41
- function _extends() {
42
- _extends = Object.assign ? Object.assign.bind() : function (target) {
43
- for (var i = 1; i < arguments.length; i++) {
44
- var source = arguments[i];
45
- for (var key in source) {
46
- if (Object.prototype.hasOwnProperty.call(source, key)) {
47
- target[key] = source[key];
48
- }
49
- }
50
- }
51
- return target;
52
- };
53
- return _extends.apply(this, arguments);
54
- }
55
- function _objectWithoutPropertiesLoose(source, excluded) {
56
- if (source == null) return {};
57
- var target = {};
58
- var sourceKeys = Object.keys(source);
59
- var key, i;
60
- for (i = 0; i < sourceKeys.length; i++) {
61
- key = sourceKeys[i];
62
- if (excluded.indexOf(key) >= 0) continue;
63
- target[key] = source[key];
64
- }
65
- return target;
11
+ /*! *****************************************************************************
12
+ Copyright (c) Microsoft Corporation.
13
+
14
+ Permission to use, copy, modify, and/or distribute this software for any
15
+ purpose with or without fee is hereby granted.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
18
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
19
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
20
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
21
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
22
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
23
+ PERFORMANCE OF THIS SOFTWARE.
24
+ ***************************************************************************** */
25
+
26
+ var __assign = function() {
27
+ __assign = Object.assign || function __assign(t) {
28
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
29
+ s = arguments[i];
30
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
31
+ }
32
+ return t;
33
+ };
34
+ return __assign.apply(this, arguments);
35
+ };
36
+
37
+ function __rest(s, e) {
38
+ var t = {};
39
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
40
+ t[p] = s[p];
41
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
42
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
43
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
44
+ t[p[i]] = s[p[i]];
45
+ }
46
+ return t;
47
+ }
48
+
49
+ function __awaiter(thisArg, _arguments, P, generator) {
50
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
51
+ return new (P || (P = Promise))(function (resolve, reject) {
52
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
53
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
54
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
55
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
56
+ });
57
+ }
58
+
59
+ function __generator(thisArg, body) {
60
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
61
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
62
+ function verb(n) { return function (v) { return step([n, v]); }; }
63
+ function step(op) {
64
+ if (f) throw new TypeError("Generator is already executing.");
65
+ while (_) try {
66
+ 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;
67
+ if (y = 0, t) op = [op[0] & 2, t.value];
68
+ switch (op[0]) {
69
+ case 0: case 1: t = op; break;
70
+ case 4: _.label++; return { value: op[1], done: false };
71
+ case 5: _.label++; y = op[1]; op = [0]; continue;
72
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
73
+ default:
74
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
75
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
76
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
77
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
78
+ if (t[2]) _.ops.pop();
79
+ _.trys.pop(); continue;
80
+ }
81
+ op = body.call(thisArg, _);
82
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
83
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
84
+ }
85
+ }
86
+
87
+ function __spreadArray(to, from, pack) {
88
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
89
+ if (ar || !(i in from)) {
90
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
91
+ ar[i] = from[i];
92
+ }
93
+ }
94
+ return to.concat(ar || Array.prototype.slice.call(from));
66
95
  }
67
96
 
68
97
  function useIsClient() {
69
- var _useState = useState(false),
70
- loaded = _useState[0],
71
- setLoaded = _useState[1];
72
- useEffect(function () {
73
- setLoaded(true);
74
- });
75
- return loaded;
98
+ var _a = useState(false), loaded = _a[0], setLoaded = _a[1];
99
+ useEffect(function () {
100
+ setLoaded(true);
101
+ });
102
+ return loaded;
76
103
  }
77
104
  function capitalize(text) {
78
- return text.slice(0, 1).toUpperCase() + text.slice(1);
105
+ return text.slice(0, 1).toUpperCase() + text.slice(1);
79
106
  }
80
107
 
81
108
  function registerComponentHelper(loader, component, meta) {
82
- if (loader) {
83
- loader.registerComponent(component, meta);
84
- } else {
85
- registerComponent(component, meta);
86
- }
109
+ if (loader) {
110
+ loader.registerComponent(component, meta);
111
+ }
112
+ else {
113
+ registerComponent(component, meta);
114
+ }
87
115
  }
88
116
 
89
- var _excluded = ["children", "navMenuItems", "rootUrl", "actionsChildren", "footerChildren", "avatarLabel", "avatarImage", "showAvatarMenu", "className"];
90
- function RichLayout(_ref) {
91
- var _layoutProps$layout, _layoutProps$fixedHea, _layoutProps$fixSider;
92
- var children = _ref.children,
93
- navMenuItems = _ref.navMenuItems,
94
- _ref$rootUrl = _ref.rootUrl,
95
- rootUrl = _ref$rootUrl === void 0 ? "/" : _ref$rootUrl,
96
- actionsChildren = _ref.actionsChildren,
97
- footerChildren = _ref.footerChildren,
98
- avatarLabel = _ref.avatarLabel,
99
- avatarImage = _ref.avatarImage,
100
- showAvatarMenu = _ref.showAvatarMenu,
101
- className = _ref.className,
102
- layoutProps = _objectWithoutPropertiesLoose(_ref, _excluded);
103
- var isClient = useIsClient();
104
- var _useState = useState(undefined),
105
- pathname = _useState[0],
106
- setPathname = _useState[1];
107
- useEffect(function () {
108
- if (typeof location !== "undefined") {
109
- setPathname(location.pathname);
110
- }
111
- }, []);
112
- if (!isClient) {
113
- return null;
114
- }
115
- return React.createElement("div", {
116
- className: className
117
- }, React.createElement("style", null, ".ant-pro-layout-bg-list {\n display: none;\n }"), React.createElement(ProLayout, Object.assign({}, layoutProps, {
118
- // Tweak defaults. ProLayout is janky and has terrible docs!
119
- layout: (_layoutProps$layout = layoutProps.layout) != null ? _layoutProps$layout : "top",
120
- fixedHeader: (_layoutProps$fixedHea = layoutProps.fixedHeader) != null ? _layoutProps$fixedHea : false,
121
- fixSiderbar:
122
- // Doesn't stretch full height if you set this to false and you're in mix mode.
123
- layoutProps.layout === "mix" ? undefined : (_layoutProps$fixSider = layoutProps.fixSiderbar) != null ? _layoutProps$fixSider : false,
124
- // 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.
125
- splitMenus: layoutProps.layout === "mix",
126
- route: {
127
- path: rootUrl,
128
- routes: navMenuItems
129
- },
130
- location: {
131
- pathname: pathname
132
- },
133
- menu: {
134
- // collapsedShowGroupTitle: true,
135
- defaultOpenAll: true
136
- },
137
- avatarProps: showAvatarMenu && false ? {
138
- src: avatarImage,
139
- size: "small",
140
- title: avatarLabel,
141
- render: function render(_props, dom) {
142
- return React.createElement(Dropdown, {
143
- menu: {
144
- items: [{
145
- key: "logout",
146
- icon: React.createElement(LogoutOutlined, null),
147
- label: "Sign out"
148
- }]
149
- }
150
- }, dom);
151
- }
152
- } : undefined,
153
- actionsRender: function actionsRender(_props) {
154
- return [actionsChildren];
155
- },
156
- menuFooterRender: function menuFooterRender(props) {
157
- if (props != null && props.collapsed) return undefined;
158
- return footerChildren;
159
- },
160
- onMenuHeaderClick: function onMenuHeaderClick(e) {
161
- return console.log(e);
162
- },
163
- menuItemRender: function menuItemRender(item, dom) {
164
- return React.createElement("a", {
165
- href: item.path
166
- }, dom);
167
- },
168
- headerTitleRender: function headerTitleRender(logo, title, _) {
169
- return React.createElement("a", {
170
- href: rootUrl
171
- }, logo, title);
117
+ function RichLayout(_a) {
118
+ var _b, _c, _d;
119
+ 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"]);
120
+ var isClient = useIsClient();
121
+ var _f = useState(undefined), pathname = _f[0], setPathname = _f[1];
122
+ useEffect(function () {
123
+ if (typeof location !== "undefined") {
124
+ setPathname(location.pathname);
125
+ }
126
+ }, []);
127
+ if (!isClient) {
128
+ return null;
172
129
  }
173
- }), children));
130
+ return (React.createElement("div", { className: className },
131
+ React.createElement("style", null, ".ant-pro-layout-bg-list {\n display: none;\n }"),
132
+ React.createElement(ProLayout, __assign({}, layoutProps, {
133
+ // Tweak defaults. ProLayout is janky and has terrible docs!
134
+ layout: (_b = layoutProps.layout) !== null && _b !== void 0 ? _b : "top", fixedHeader: (_c = layoutProps.fixedHeader) !== null && _c !== void 0 ? _c : false, fixSiderbar:
135
+ // Doesn't stretch full height if you set this to false and you're in mix mode.
136
+ layoutProps.layout === "mix"
137
+ ? undefined
138
+ : (_d = layoutProps.fixSiderbar) !== null && _d !== void 0 ? _d : false,
139
+ // 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.
140
+ splitMenus: layoutProps.layout === "mix", route: {
141
+ path: rootUrl,
142
+ routes: navMenuItems,
143
+ }, location: {
144
+ pathname: pathname,
145
+ }, menu: {
146
+ // collapsedShowGroupTitle: true,
147
+ defaultOpenAll: true,
148
+ // hideMenuWhenCollapsed: true,
149
+ }, avatarProps: showAvatarMenu && false
150
+ ? {
151
+ src: avatarImage,
152
+ size: "small",
153
+ title: avatarLabel,
154
+ render: function (_props, dom) {
155
+ return (React.createElement(Dropdown, { menu: {
156
+ items: [
157
+ {
158
+ key: "logout",
159
+ icon: React.createElement(LogoutOutlined, null),
160
+ label: "Sign out",
161
+ },
162
+ ],
163
+ } }, dom));
164
+ },
165
+ }
166
+ : undefined, actionsRender: function (_props) {
167
+ return [actionsChildren];
168
+ }, menuFooterRender: function (props) {
169
+ if (props === null || props === void 0 ? void 0 : props.collapsed)
170
+ return undefined;
171
+ return footerChildren;
172
+ }, onMenuHeaderClick: function (e) { return console.log(e); }, menuItemRender: function (item, dom) { return React.createElement("a", { href: item.path }, dom); }, headerTitleRender: function (logo, title, _) {
173
+ return (React.createElement("a", { href: rootUrl },
174
+ logo,
175
+ title));
176
+ } }), children)));
174
177
  }
175
178
 
176
179
  function generateNavMenuType(remainingDepth, displayName, defaultValue) {
177
- return {
178
- displayName: displayName ? displayName : "Nested items",
179
- type: "array",
180
- defaultValue: defaultValue,
181
- itemType: {
182
- type: "object",
183
- nameFunc: function nameFunc(item) {
184
- return item.name || (!displayName ? "Unnamed nested item" : "Unnamed item");
185
- },
186
- fields: _extends({
187
- path: "string",
188
- name: "string"
189
- }, remainingDepth === 0 ? {} : {
190
- routes: generateNavMenuType(remainingDepth - 1)
191
- })
192
- }
193
- };
180
+ return {
181
+ displayName: displayName ? displayName : "Nested items",
182
+ type: "array",
183
+ defaultValue: defaultValue,
184
+ itemType: {
185
+ type: "object",
186
+ nameFunc: function (item) {
187
+ return item.name || (!displayName ? "Unnamed nested item" : "Unnamed item");
188
+ },
189
+ fields: __assign({ path: "string", name: "string" }, (remainingDepth === 0
190
+ ? {}
191
+ : {
192
+ routes: generateNavMenuType(remainingDepth - 1),
193
+ })),
194
+ },
195
+ };
194
196
  }
195
197
  var richLayoutMeta = {
196
- name: "hostless-rich-layout",
197
- displayName: "Rich Page Layout",
198
- props: {
199
- children: "slot",
200
- actionsChildren: {
201
- type: "slot",
202
- hidePlaceholder: true
203
- },
204
- title: {
205
- displayName: "Title",
206
- type: "string",
207
- defaultValue: "App title"
208
- },
209
- logo: {
210
- displayName: "Logo",
211
- type: "imageUrl",
212
- defaultValue: "https://www.plasmic.app/favicon.ico"
213
- },
214
- navMenuItems: /*#__PURE__*/generateNavMenuType(2, "Nav menu items", [{
215
- path: "/",
216
- name: "Link 1"
217
- }, {
218
- path: "/",
219
- name: "Link 2"
220
- }]),
221
- layout: {
222
- displayName: "Layout",
223
- type: "choice",
224
- options: /*#__PURE__*/["side", "top", "mix"].map(function (value) {
225
- return {
226
- value: value,
227
- label: capitalize(value)
228
- };
229
- }),
230
- defaultValueHint: "top"
231
- },
232
- // Advanced, show later
233
- /*
234
- siderMenuType: {
235
- displayName: "Sidebar mode",
236
- type: "choice",
237
- options: ["sub", "group"].map((value) => ({
238
- value,
239
- label: capitalize(value),
240
- })),
241
- defaultValue: "sub",
242
- },
243
- contentWidth: {
244
- displayName: "Content width",
245
- type: "choice",
246
- options: ["Fluid", "Fixed"],
247
- defaultValueHint: "Fluid",
248
- },
249
- navTheme: {
250
- displayName: "Theme",
251
- type: "choice",
252
- options: [
253
- { value: "realDark", label: "Dark" },
254
- { value: "light", label: "Light" },
255
- ],
256
- },
257
- colorPrimary: {
258
- displayName: "Primary color",
259
- type: "color",
260
- },
261
- */
262
- fixedHeader: {
263
- displayName: "Sticky header",
264
- type: "boolean",
265
- hidden: function hidden(ps) {
266
- var _ps$layout;
267
- return ((_ps$layout = ps.layout) != null ? _ps$layout : "top") !== "top";
268
- },
269
- defaultValueHint: false
198
+ name: "hostless-rich-layout",
199
+ displayName: "Rich Page Layout",
200
+ props: {
201
+ children: "slot",
202
+ actionsChildren: {
203
+ type: "slot",
204
+ hidePlaceholder: true,
205
+ },
206
+ title: {
207
+ displayName: "Title",
208
+ type: "string",
209
+ defaultValue: "App title",
210
+ },
211
+ logo: {
212
+ displayName: "Logo",
213
+ type: "imageUrl",
214
+ defaultValue: "https://www.plasmic.app/favicon.ico",
215
+ },
216
+ navMenuItems: generateNavMenuType(2, "Nav menu items", [
217
+ {
218
+ path: "/",
219
+ name: "Link 1",
220
+ },
221
+ {
222
+ path: "/",
223
+ name: "Link 2",
224
+ },
225
+ ]),
226
+ layout: {
227
+ displayName: "Layout",
228
+ type: "choice",
229
+ options: ["side", "top", "mix"].map(function (value) { return ({
230
+ value: value,
231
+ label: capitalize(value),
232
+ }); }),
233
+ defaultValueHint: "top",
234
+ },
235
+ // Advanced, show later
236
+ /*
237
+ siderMenuType: {
238
+ displayName: "Sidebar mode",
239
+ type: "choice",
240
+ options: ["sub", "group"].map((value) => ({
241
+ value,
242
+ label: capitalize(value),
243
+ })),
244
+ defaultValue: "sub",
245
+ },
246
+ contentWidth: {
247
+ displayName: "Content width",
248
+ type: "choice",
249
+ options: ["Fluid", "Fixed"],
250
+ defaultValueHint: "Fluid",
251
+ },
252
+ navTheme: {
253
+ displayName: "Theme",
254
+ type: "choice",
255
+ options: [
256
+ { value: "realDark", label: "Dark" },
257
+ { value: "light", label: "Light" },
258
+ ],
259
+ },
260
+ colorPrimary: {
261
+ displayName: "Primary color",
262
+ type: "color",
263
+ },
264
+ */
265
+ fixedHeader: {
266
+ displayName: "Sticky header",
267
+ type: "boolean",
268
+ hidden: function (ps) { var _a; return ((_a = ps.layout) !== null && _a !== void 0 ? _a : "top") !== "top"; },
269
+ defaultValueHint: false,
270
+ },
271
+ fixSiderbar: {
272
+ displayName: "Sticky sidebar",
273
+ type: "boolean",
274
+ hidden: function (ps) { var _a; return ((_a = ps.layout) !== null && _a !== void 0 ? _a : "top") !== "side"; },
275
+ defaultValueHint: false,
276
+ },
277
+ /*
278
+ showAvatarMenu: {
279
+ displayName: "Show avatar",
280
+ type: "boolean",
281
+ defaultValue: true,
282
+ },
283
+ avatarLabel: {
284
+ displayName: "Avatar label",
285
+ type: "string",
286
+ defaultValue: "User Name",
287
+ },
288
+ avatarImage: {
289
+ displayName: "Avatar image",
290
+ type: "imageUrl",
291
+ defaultValue:
292
+ "https://gw.alipayobjects.com/zos/antfincdn/efFD%24IOql2/weixintupian_20170331104822.jpg",
293
+ },
294
+ */
295
+ menu: {
296
+ displayName: "Menu",
297
+ type: "object",
298
+ fields: {
299
+ defaultOpenAll: {
300
+ displayName: "Default open all",
301
+ type: "boolean",
302
+ },
303
+ hideMenuWhenCollapsed: {
304
+ // displayName: "",
305
+ type: "boolean",
306
+ },
307
+ },
308
+ },
270
309
  },
271
- fixSiderbar: {
272
- displayName: "Sticky sidebar",
273
- type: "boolean",
274
- hidden: function hidden(ps) {
275
- var _ps$layout2;
276
- return ((_ps$layout2 = ps.layout) != null ? _ps$layout2 : "top") !== "side";
277
- },
278
- defaultValueHint: false
310
+ defaultStyles: {
311
+ width: "stretch",
312
+ height: "stretch",
279
313
  },
280
- /*
281
- showAvatarMenu: {
282
- displayName: "Show avatar",
283
- type: "boolean",
284
- defaultValue: true,
285
- },
286
- avatarLabel: {
287
- displayName: "Avatar label",
288
- type: "string",
289
- defaultValue: "User Name",
290
- },
291
- avatarImage: {
292
- displayName: "Avatar image",
293
- type: "imageUrl",
294
- defaultValue:
295
- "https://gw.alipayobjects.com/zos/antfincdn/efFD%24IOql2/weixintupian_20170331104822.jpg",
296
- },
297
- */
298
- menu: {
299
- displayName: "Menu",
300
- type: "object",
301
- fields: {
302
- defaultOpenAll: {
303
- displayName: "Default open all",
304
- type: "boolean"
305
- },
306
- hideMenuWhenCollapsed: {
307
- // displayName: "",
308
- type: "boolean"
309
- }
310
- }
311
- }
312
- },
313
- defaultStyles: {
314
- width: "stretch",
315
- height: "stretch"
316
- },
317
- importName: "RichLayout",
318
- importPath: "@plasmicpkgs/plasmic-rich-components"
314
+ importName: "RichLayout",
315
+ importPath: "@plasmicpkgs/plasmic-rich-components",
319
316
  };
320
317
  function registerRichLayout(loader) {
321
- registerComponentHelper(loader, RichLayout, richLayoutMeta);
318
+ registerComponentHelper(loader, RichLayout, richLayoutMeta);
322
319
  }
323
320
 
324
- function createCommonjsModule(fn, module) {
325
- return module = { exports: {} }, fn(module, module.exports), module.exports;
326
- }
327
-
328
- var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
329
- /**
330
- * Copyright (c) 2014-present, Facebook, Inc.
331
- *
332
- * This source code is licensed under the MIT license found in the
333
- * LICENSE file in the root directory of this source tree.
334
- */
335
-
336
- var runtime = function (exports) {
337
-
338
- var Op = Object.prototype;
339
- var hasOwn = Op.hasOwnProperty;
340
- var undefined$1; // More compressible than void 0.
341
- var $Symbol = typeof Symbol === "function" ? Symbol : {};
342
- var iteratorSymbol = $Symbol.iterator || "@@iterator";
343
- var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
344
- var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
345
- function define(obj, key, value) {
346
- Object.defineProperty(obj, key, {
347
- value: value,
348
- enumerable: true,
349
- configurable: true,
350
- writable: true
351
- });
352
- return obj[key];
353
- }
354
- try {
355
- // IE 8 has a broken Object.defineProperty that only works on DOM objects.
356
- define({}, "");
357
- } catch (err) {
358
- define = function define(obj, key, value) {
359
- return obj[key] = value;
360
- };
321
+ var tuple = function () {
322
+ var args = [];
323
+ for (var _i = 0; _i < arguments.length; _i++) {
324
+ args[_i] = arguments[_i];
361
325
  }
362
- function wrap(innerFn, outerFn, self, tryLocsList) {
363
- // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
364
- var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
365
- var generator = Object.create(protoGenerator.prototype);
366
- var context = new Context(tryLocsList || []);
367
-
368
- // The ._invoke method unifies the implementations of the .next,
369
- // .throw, and .return methods.
370
- generator._invoke = makeInvokeMethod(innerFn, self, context);
371
- return generator;
326
+ return args;
327
+ };
328
+ function mkIdMap(xs) {
329
+ return new Map(xs.map(function (x) { return tuple(x.id, x); }));
330
+ }
331
+ var mkShortId = function () { return "".concat(Math.random()); };
332
+ var withoutNils = function (xs) {
333
+ return xs.filter(function (x) { return x != null; });
334
+ };
335
+ var defaultColumnConfig = function () {
336
+ return ({
337
+ key: mkShortId(),
338
+ isEditableExpr: function () { return false; },
339
+ disableSorting: false,
340
+ sortByExpr: undefined,
341
+ isHidden: false,
342
+ formatting: {
343
+ styles: {},
344
+ align: "left",
345
+ freeze: "off",
346
+ },
347
+ dataType: "auto",
348
+ });
349
+ };
350
+ function deriveFieldConfigs(specifiedFieldsPartial, schema) {
351
+ var _a;
352
+ var schemaFields = (_a = schema === null || schema === void 0 ? void 0 : schema.fields) !== null && _a !== void 0 ? _a : [];
353
+ var fieldById = mkIdMap(schemaFields);
354
+ var specifiedFieldIds = new Set(withoutNils(specifiedFieldsPartial.map(function (f) { return f.fieldId; })));
355
+ function defaultColumnConfigForField(field) {
356
+ return __assign(__assign({}, defaultColumnConfig()), { key: field.id, fieldId: field.id, title: field.label || field.id, expr: function (currentItem) { return currentItem[field.id]; } });
372
357
  }
373
- exports.wrap = wrap;
358
+ var keptSpecifiedFields = specifiedFieldsPartial.flatMap(function (f, index) {
359
+ var fieldId = f.fieldId;
360
+ if (!fieldId) {
361
+ return [
362
+ __assign(__assign(__assign({}, defaultColumnConfig()), { key: index }), f),
363
+ ];
364
+ }
365
+ var field = fieldById.get(fieldId);
366
+ // Drop configs with fieldIds no longer in the data.
367
+ if (!field) {
368
+ return [];
369
+ }
370
+ return [
371
+ __assign(__assign({}, defaultColumnConfigForField(field)), f),
372
+ ];
373
+ });
374
+ var newVirtualFields = schemaFields
375
+ .filter(function (f) { return !specifiedFieldIds.has(f.id); })
376
+ .map(function (f) { return (__assign({}, defaultColumnConfigForField(f))); });
377
+ var mergedFields = __spreadArray(__spreadArray([], keptSpecifiedFields, true), newVirtualFields, true);
378
+ var minimalFullLengthFields = __spreadArray(__spreadArray([], specifiedFieldsPartial, true), newVirtualFields.map(function (f) { return ({ key: f.key, fieldId: f.fieldId }); }), true);
379
+ return { mergedFields: mergedFields, minimalFullLengthFields: minimalFullLengthFields };
380
+ }
374
381
 
375
- // Try/catch helper to minimize deoptimizations. Returns a completion
376
- // record like context.tryEntries[i].completion. This interface could
377
- // have been (and was previously) designed to take a closure to be
378
- // invoked without arguments, but in all the cases we care about we
379
- // already have an existing method we want to call, so there's no need
380
- // to create a new function object. We can even get away with assuming
381
- // the method takes exactly one argument, since that happens to be true
382
- // in every case, so we don't have to touch the arguments object. The
383
- // only additional allocation required is the completion record, which
384
- // has a stable shape and so hopefully should be cheap to allocate.
385
- function tryCatch(fn, obj, arg) {
386
- try {
387
- return {
388
- type: "normal",
389
- arg: fn.call(obj, arg)
390
- };
391
- } catch (err) {
392
- return {
393
- type: "throw",
394
- arg: err
395
- };
396
- }
382
+ function tryGetSchema(data) {
383
+ if (data === null || data === void 0 ? void 0 : data.schema) {
384
+ return data.schema;
397
385
  }
398
- var GenStateSuspendedStart = "suspendedStart";
399
- var GenStateSuspendedYield = "suspendedYield";
400
- var GenStateExecuting = "executing";
401
- var GenStateCompleted = "completed";
402
-
403
- // Returning this object from the innerFn has the same effect as
404
- // breaking out of the dispatch switch statement.
405
- var ContinueSentinel = {};
406
-
407
- // Dummy constructor functions that we use as the .constructor and
408
- // .constructor.prototype properties for functions that return Generator
409
- // objects. For full spec compliance, you may wish to configure your
410
- // minifier not to mangle the names of these two functions.
411
- function Generator() {}
412
- function GeneratorFunction() {}
413
- function GeneratorFunctionPrototype() {}
414
-
415
- // This is a polyfill for %IteratorPrototype% for environments that
416
- // don't natively support it.
417
- var IteratorPrototype = {};
418
- define(IteratorPrototype, iteratorSymbol, function () {
419
- return this;
420
- });
421
- var getProto = Object.getPrototypeOf;
422
- var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
423
- if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
424
- // This environment has a native %IteratorPrototype%; use it instead
425
- // of the polyfill.
426
- IteratorPrototype = NativeIteratorPrototype;
386
+ if (Array.isArray(data)) {
387
+ data = { data: data };
427
388
  }
428
- var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
429
- GeneratorFunction.prototype = GeneratorFunctionPrototype;
430
- define(Gp, "constructor", GeneratorFunctionPrototype);
431
- define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
432
- GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction");
433
-
434
- // Helper for defining the .next, .throw, and .return methods of the
435
- // Iterator interface in terms of a single ._invoke method.
436
- function defineIteratorMethods(prototype) {
437
- ["next", "throw", "return"].forEach(function (method) {
438
- define(prototype, method, function (arg) {
439
- return this._invoke(method, arg);
440
- });
441
- });
389
+ if (!(data === null || data === void 0 ? void 0 : data.data) || !Array.isArray(data.data) || data.data.length === 0) {
390
+ return undefined;
442
391
  }
443
- exports.isGeneratorFunction = function (genFun) {
444
- var ctor = typeof genFun === "function" && genFun.constructor;
445
- return ctor ? ctor === GeneratorFunction ||
446
- // For the native GeneratorFunction constructor, the best we can
447
- // do is to check its .name property.
448
- (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
449
- };
450
- exports.mark = function (genFun) {
451
- if (Object.setPrototypeOf) {
452
- Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
453
- } else {
454
- genFun.__proto__ = GeneratorFunctionPrototype;
455
- define(genFun, toStringTagSymbol, "GeneratorFunction");
456
- }
457
- genFun.prototype = Object.create(Gp);
458
- return genFun;
459
- };
460
-
461
- // Within the body of any async function, `await x` is transformed to
462
- // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
463
- // `hasOwn.call(value, "__await")` to determine if the yielded value is
464
- // meant to be awaited.
465
- exports.awrap = function (arg) {
466
- return {
467
- __await: arg
468
- };
469
- };
470
- function AsyncIterator(generator, PromiseImpl) {
471
- function invoke(method, arg, resolve, reject) {
472
- var record = tryCatch(generator[method], generator, arg);
473
- if (record.type === "throw") {
474
- reject(record.arg);
475
- } else {
476
- var result = record.arg;
477
- var value = result.value;
478
- if (value && typeof value === "object" && hasOwn.call(value, "__await")) {
479
- return PromiseImpl.resolve(value.__await).then(function (value) {
480
- invoke("next", value, resolve, reject);
481
- }, function (err) {
482
- invoke("throw", err, resolve, reject);
392
+ var fieldMap = {};
393
+ data.data.forEach(function (entry) {
394
+ if (entry && typeof entry === "object") {
395
+ Array.from(Object.entries(entry)).forEach(function (_a) {
396
+ var k = _a[0], v = _a[1];
397
+ var inferredType = typeof v === "string"
398
+ ? "string"
399
+ : typeof v === "boolean"
400
+ ? "boolean"
401
+ : typeof v === "number"
402
+ ? "number"
403
+ : "unknown";
404
+ if (fieldMap[k] && fieldMap[k] !== inferredType) {
405
+ fieldMap[k] = "unknown";
406
+ }
407
+ else {
408
+ fieldMap[k] = inferredType;
409
+ }
483
410
  });
484
- }
485
- return PromiseImpl.resolve(value).then(function (unwrapped) {
486
- // When a yielded Promise is resolved, its final value becomes
487
- // the .value of the Promise<{value,done}> result for the
488
- // current iteration.
489
- result.value = unwrapped;
490
- resolve(result);
491
- }, function (error) {
492
- // If a rejected Promise was yielded, throw the rejection back
493
- // into the async generator function so it can be handled there.
494
- return invoke("throw", error, resolve, reject);
495
- });
496
- }
497
- }
498
- var previousPromise;
499
- function enqueue(method, arg) {
500
- function callInvokeWithMethodAndArg() {
501
- return new PromiseImpl(function (resolve, reject) {
502
- invoke(method, arg, resolve, reject);
503
- });
504
411
  }
505
- return previousPromise =
506
- // If enqueue has been called before, then we want to wait until
507
- // all previous Promises have been resolved before calling invoke,
508
- // so that results are always delivered in the correct order. If
509
- // enqueue has not been called before, then it is important to
510
- // call invoke immediately, without waiting on a callback to fire,
511
- // so that the async generator function has the opportunity to do
512
- // any necessary setup in a predictable way. This predictability
513
- // is why the Promise constructor synchronously invokes its
514
- // executor callback, and why async functions synchronously
515
- // execute code before the first await. Since we implement simple
516
- // async functions in terms of async generators, it is especially
517
- // important to get this right, even though it requires care.
518
- previousPromise ? previousPromise.then(callInvokeWithMethodAndArg,
519
- // Avoid propagating failures to Promises returned by later
520
- // invocations of the iterator.
521
- callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
522
- }
523
-
524
- // Define the unified helper method that is used to implement .next,
525
- // .throw, and .return (see defineIteratorMethods).
526
- this._invoke = enqueue;
527
- }
528
- defineIteratorMethods(AsyncIterator.prototype);
529
- define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
530
- return this;
531
412
  });
532
- exports.AsyncIterator = AsyncIterator;
533
-
534
- // Note that simple async functions are implemented on top of
535
- // AsyncIterator objects; they just return a Promise for the value of
536
- // the final result produced by the iterator.
537
- exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
538
- if (PromiseImpl === void 0) PromiseImpl = Promise;
539
- var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
540
- return exports.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator.
541
- : iter.next().then(function (result) {
542
- return result.done ? result.value : iter.next();
543
- });
413
+ return {
414
+ id: "inferred",
415
+ fields: Object.entries(fieldMap).map(function (_a) {
416
+ var f = _a[0], t = _a[1];
417
+ return ({
418
+ id: f,
419
+ type: t,
420
+ readOnly: false,
421
+ });
422
+ }),
544
423
  };
545
- function makeInvokeMethod(innerFn, self, context) {
546
- var state = GenStateSuspendedStart;
547
- return function invoke(method, arg) {
548
- if (state === GenStateExecuting) {
549
- throw new Error("Generator is already running");
550
- }
551
- if (state === GenStateCompleted) {
552
- if (method === "throw") {
553
- throw arg;
554
- }
555
-
556
- // Be forgiving, per 25.3.3.3.3 of the spec:
557
- // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
558
- return doneResult();
559
- }
560
- context.method = method;
561
- context.arg = arg;
562
- while (true) {
563
- var delegate = context.delegate;
564
- if (delegate) {
565
- var delegateResult = maybeInvokeDelegate(delegate, context);
566
- if (delegateResult) {
567
- if (delegateResult === ContinueSentinel) continue;
568
- return delegateResult;
569
- }
570
- }
571
- if (context.method === "next") {
572
- // Setting context._sent for legacy support of Babel's
573
- // function.sent implementation.
574
- context.sent = context._sent = context.arg;
575
- } else if (context.method === "throw") {
576
- if (state === GenStateSuspendedStart) {
577
- state = GenStateCompleted;
578
- throw context.arg;
579
- }
580
- context.dispatchException(context.arg);
581
- } else if (context.method === "return") {
582
- context.abrupt("return", context.arg);
583
- }
584
- state = GenStateExecuting;
585
- var record = tryCatch(innerFn, self, context);
586
- if (record.type === "normal") {
587
- // If an exception is thrown from innerFn, we leave state ===
588
- // GenStateExecuting and loop back for another invocation.
589
- state = context.done ? GenStateCompleted : GenStateSuspendedYield;
590
- if (record.arg === ContinueSentinel) {
591
- continue;
592
- }
593
- return {
594
- value: record.arg,
595
- done: context.done
596
- };
597
- } else if (record.type === "throw") {
598
- state = GenStateCompleted;
599
- // Dispatch the exception by looping back around to the
600
- // context.dispatchException(context.arg) call above.
601
- context.method = "throw";
602
- context.arg = record.arg;
603
- }
604
- }
605
- };
424
+ }
425
+ function normalizeData(rawData) {
426
+ if (!rawData || typeof rawData !== "object") {
427
+ return undefined;
606
428
  }
607
-
608
- // Call delegate.iterator[context.method](context.arg) and handle the
609
- // result, either by returning a { value, done } result from the
610
- // delegate iterator, or by modifying context.method and context.arg,
611
- // setting context.delegate to null, and returning the ContinueSentinel.
612
- function maybeInvokeDelegate(delegate, context) {
613
- var method = delegate.iterator[context.method];
614
- if (method === undefined$1) {
615
- // A .throw or .return when the delegate iterator has no .throw
616
- // method always terminates the yield* loop.
617
- context.delegate = null;
618
- if (context.method === "throw") {
619
- // Note: ["return"] must be used for ES3 parsing compatibility.
620
- if (delegate.iterator["return"]) {
621
- // If the delegate iterator has a return method, give it a
622
- // chance to clean up.
623
- context.method = "return";
624
- context.arg = undefined$1;
625
- maybeInvokeDelegate(delegate, context);
626
- if (context.method === "throw") {
627
- // If maybeInvokeDelegate(context) changed context.method from
628
- // "return" to "throw", let that override the TypeError below.
629
- return ContinueSentinel;
630
- }
631
- }
632
- context.method = "throw";
633
- context.arg = new TypeError("The iterator does not provide a 'throw' method");
634
- }
635
- return ContinueSentinel;
636
- }
637
- var record = tryCatch(method, delegate.iterator, context.arg);
638
- if (record.type === "throw") {
639
- context.method = "throw";
640
- context.arg = record.arg;
641
- context.delegate = null;
642
- return ContinueSentinel;
643
- }
644
- var info = record.arg;
645
- if (!info) {
646
- context.method = "throw";
647
- context.arg = new TypeError("iterator result is not an object");
648
- context.delegate = null;
649
- return ContinueSentinel;
650
- }
651
- if (info.done) {
652
- // Assign the result of the finished delegate to the temporary
653
- // variable specified by delegate.resultName (see delegateYield).
654
- context[delegate.resultName] = info.value;
655
-
656
- // Resume execution at the desired location (see delegateYield).
657
- context.next = delegate.nextLoc;
658
-
659
- // If context.method was "throw" but the delegate handled the
660
- // exception, let the outer generator proceed normally. If
661
- // context.method was "next", forget context.arg since it has been
662
- // "consumed" by the delegate iterator. If context.method was
663
- // "return", allow the original .return call to continue in the
664
- // outer generator.
665
- if (context.method !== "return") {
666
- context.method = "next";
667
- context.arg = undefined$1;
668
- }
669
- } else {
670
- // Re-yield the result returned by the delegate method.
671
- return info;
672
- }
673
-
674
- // The delegate iterator is finished, so forget it and continue with
675
- // the outer generator.
676
- context.delegate = null;
677
- return ContinueSentinel;
429
+ var obj = Array.isArray(rawData) ? { data: rawData } : rawData;
430
+ if (!("data" in obj)) {
431
+ return undefined;
678
432
  }
679
-
680
- // Define Generator.prototype.{next,throw,return} in terms of the
681
- // unified ._invoke helper method.
682
- defineIteratorMethods(Gp);
683
- define(Gp, toStringTagSymbol, "Generator");
684
-
685
- // A Generator should always return itself as the iterator object when the
686
- // @@iterator function is called on it. Some browsers' implementations of the
687
- // iterator prototype chain incorrectly implement this, causing the Generator
688
- // object to not be returned from this call. This ensures that doesn't happen.
689
- // See https://github.com/facebook/regenerator/issues/274 for more details.
690
- define(Gp, iteratorSymbol, function () {
691
- return this;
692
- });
693
- define(Gp, "toString", function () {
694
- return "[object Generator]";
695
- });
696
- function pushTryEntry(locs) {
697
- var entry = {
698
- tryLoc: locs[0]
699
- };
700
- if (1 in locs) {
701
- entry.catchLoc = locs[1];
702
- }
703
- if (2 in locs) {
704
- entry.finallyLoc = locs[2];
705
- entry.afterLoc = locs[3];
706
- }
707
- this.tryEntries.push(entry);
433
+ var objWithData = obj;
434
+ if (!Array.isArray(objWithData.data) || objWithData.data.length === 0) {
435
+ return undefined;
708
436
  }
709
- function resetTryEntry(entry) {
710
- var record = entry.completion || {};
711
- record.type = "normal";
712
- delete record.arg;
713
- entry.completion = record;
437
+ // Make TS happy.
438
+ var normed = __assign(__assign({}, objWithData), { data: objWithData.data });
439
+ var schema = tryGetSchema(rawData);
440
+ if (!schema) {
441
+ return undefined;
714
442
  }
715
- function Context(tryLocsList) {
716
- // The root entry object (effectively a try statement without a catch
717
- // or a finally block) gives us a place to store values thrown from
718
- // locations where there is no enclosing try statement.
719
- this.tryEntries = [{
720
- tryLoc: "root"
721
- }];
722
- tryLocsList.forEach(pushTryEntry, this);
723
- this.reset(true);
443
+ return __assign(__assign({}, normed), { schema: schema });
444
+ }
445
+ /**
446
+ * Render booleans, objects, arrays, etc. as JSON repr.
447
+ */
448
+ function safeRender(x) {
449
+ return x === undefined || x === null
450
+ ? ""
451
+ : typeof x === "string"
452
+ ? x
453
+ : typeof x === "number"
454
+ ? x.toString()
455
+ : JSON.stringify(x);
456
+ }
457
+ function RichTable(props) {
458
+ var className = props.className, _a = props.data, rawData = _a === void 0 ? {
459
+ data: [],
460
+ schema: {
461
+ id: "inferred",
462
+ fields: [
463
+ {
464
+ id: "id",
465
+ type: "string",
466
+ readOnly: false,
467
+ },
468
+ ],
469
+ },
470
+ } : _a,
471
+ // children,
472
+ _b = props.pagination,
473
+ // children,
474
+ 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, hideDensity = props.hideDensity, hideColumnPicker = props.hideColumnPicker, hideExports = props.hideExports, rowKey = props.rowKey;
475
+ var data = normalizeData(rawData);
476
+ var _d = useColumnDefinitions(data, props), columnDefinitions = _d.columnDefinitions, normalized = _d.normalized;
477
+ var actionRef = useRef();
478
+ var _e = useSortedFilteredData(data, normalized), finalData = _e.finalData, search = _e.search, setSearch = _e.setSearch, setSortState = _e.setSortState;
479
+ var rowSelection = useRowSelection(data, props);
480
+ // const { containerRef, tableHeight } = useScrollHeight(data, props);
481
+ var isClient = useIsClient();
482
+ if (!isClient) {
483
+ return null;
724
484
  }
725
- exports.keys = function (object) {
726
- var keys = [];
727
- for (var key in object) {
728
- keys.push(key);
729
- }
730
- keys.reverse();
731
-
732
- // Rather than returning an object with a next method, we keep
733
- // things simple and return the next function itself.
734
- return function next() {
735
- while (keys.length) {
736
- var key = keys.pop();
737
- if (key in object) {
738
- next.value = key;
739
- next.done = false;
740
- return next;
741
- }
742
- }
743
-
744
- // To avoid creating an additional object, we just hang the .value
745
- // and .done properties off the next function object itself. This
746
- // also ensures that the minifier will not anonymize the function.
747
- next.done = true;
748
- return next;
749
- };
750
- };
751
- function values(iterable) {
752
- if (iterable) {
753
- var iteratorMethod = iterable[iteratorSymbol];
754
- if (iteratorMethod) {
755
- return iteratorMethod.call(iterable);
756
- }
757
- if (typeof iterable.next === "function") {
758
- return iterable;
759
- }
760
- if (!isNaN(iterable.length)) {
761
- var i = -1,
762
- next = function next() {
763
- while (++i < iterable.length) {
764
- if (hasOwn.call(iterable, i)) {
765
- next.value = iterable[i];
766
- next.done = false;
767
- return next;
485
+ return (React.createElement("div", { className: className },
486
+ React.createElement(ProTable, { actionRef: actionRef, columns: columnDefinitions, onChange: function (_pagination, _filters, sorter, _extra) {
487
+ setSortState({ sorter: sorter });
488
+ }, style: {
489
+ width: "100%",
490
+ }, cardProps: {
491
+ ghost: true,
492
+ }, rowSelection: rowSelection, dataSource: finalData, rowKey: deriveRowKey(data, rowKey), defaultSize: defaultSize, editable: { type: "multiple" }, search: false, options: {
493
+ setting: hideColumnPicker
494
+ ? false
495
+ : {
496
+ listsHeight: 400,
497
+ },
498
+ reload: false,
499
+ density: !hideDensity,
500
+ }, pagination: pagination
501
+ ? {
502
+ pageSize: pageSize,
503
+ onChange: function (page) { return console.log(page); },
768
504
  }
769
- }
770
- next.value = undefined$1;
771
- next.done = true;
772
- return next;
773
- };
774
- return next.next = next;
775
- }
776
- }
777
-
778
- // Return an iterator with no values.
779
- return {
780
- next: doneResult
781
- };
505
+ : false, dateFormatter: "string", headerTitle: title,
506
+ // TODO in the future, figure out how to make this responsive to the CSS height
507
+ // scroll={{ x: scrollX || undefined, y: scrollHeight }}
508
+ toolbar: {
509
+ search: !hideSearch
510
+ ? {
511
+ value: search,
512
+ onChange: function (e) { return setSearch(e.target.value); },
513
+ onSearch: function () {
514
+ return;
515
+ },
516
+ placeholder: "Search",
517
+ }
518
+ : undefined,
519
+ }, toolBarRender: function () { return [
520
+ addHref && (React.createElement(Button, { key: "button", icon: React.createElement(PlusOutlined, null), type: "primary", href: addHref }, "Add")),
521
+ !hideExports && React.createElement(ExportMenu, { data: data }),
522
+ ]; } }),
523
+ React.createElement("style", { dangerouslySetInnerHTML: {
524
+ __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 .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 {\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 ",
525
+ } })));
526
+ }
527
+ function deriveRowKey(data, rowKey) {
528
+ var _a;
529
+ if (rowKey) {
530
+ return rowKey;
782
531
  }
783
- exports.values = values;
784
- function doneResult() {
785
- return {
786
- value: undefined$1,
787
- done: true
788
- };
532
+ var schema = tryGetSchema(data);
533
+ if (schema) {
534
+ return (_a = schema.fields[0]) === null || _a === void 0 ? void 0 : _a.id;
789
535
  }
790
- Context.prototype = {
791
- constructor: Context,
792
- reset: function reset(skipTempReset) {
793
- this.prev = 0;
794
- this.next = 0;
795
- // Resetting context._sent for legacy support of Babel's
796
- // function.sent implementation.
797
- this.sent = this._sent = undefined$1;
798
- this.done = false;
799
- this.delegate = null;
800
- this.method = "next";
801
- this.arg = undefined$1;
802
- this.tryEntries.forEach(resetTryEntry);
803
- if (!skipTempReset) {
804
- for (var name in this) {
805
- // Not sure about the optimal order of these conditions:
806
- if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
807
- this[name] = undefined$1;
808
- }
809
- }
536
+ return undefined;
537
+ }
538
+ function useColumnDefinitions(data, props) {
539
+ var fields = props.fields, setControlContextData = props.setControlContextData, actions = props.actions, customActionChildren = props.customActionChildren;
540
+ return React.useMemo(function () {
541
+ var schema = tryGetSchema(data);
542
+ if (!data || !schema) {
543
+ return { normalized: [], columnDefinitions: [] };
810
544
  }
811
- },
812
- stop: function stop() {
813
- this.done = true;
814
- var rootEntry = this.tryEntries[0];
815
- var rootRecord = rootEntry.completion;
816
- if (rootRecord.type === "throw") {
817
- throw rootRecord.arg;
545
+ var _a = deriveFieldConfigs(fields !== null && fields !== void 0 ? fields : [], schema), mergedFields = _a.mergedFields, minimalFullLengthFields = _a.minimalFullLengthFields;
546
+ setControlContextData === null || setControlContextData === void 0 ? void 0 : setControlContextData(__assign(__assign({}, data), { mergedFields: mergedFields, minimalFullLengthFields: minimalFullLengthFields }));
547
+ var normalized = mergedFields;
548
+ var columnDefinitions = normalized
549
+ .filter(function (cconfig) { return !cconfig.isHidden; })
550
+ .map(function (cconfig, _columnIndex, _columnsArray) {
551
+ var columnDefinition = {
552
+ dataIndex: cconfig.fieldId,
553
+ title: cconfig.title,
554
+ // dataIndex: cconfig,
555
+ key: cconfig.key,
556
+ valueType: cconfig.dataType === "auto"
557
+ ? undefined
558
+ : cconfig.dataType === "string"
559
+ ? "text"
560
+ : cconfig.dataType === "number"
561
+ ? "digit"
562
+ : cconfig.dataType === "boolean"
563
+ ? "switch"
564
+ : undefined,
565
+ // To come later
566
+ readonly: false,
567
+ sorter: true,
568
+ copyable: false,
569
+ ellipsis: false,
570
+ tip: undefined,
571
+ formItemProps: {
572
+ rules: [],
573
+ },
574
+ disable: false,
575
+ valueEnum: undefined,
576
+ search: undefined,
577
+ hideInSearch: false,
578
+ renderFormItem: function (_, _a) {
579
+ var defaultRender = _a.defaultRender;
580
+ return defaultRender(_);
581
+ },
582
+ render: function (value, record, rowIndex) {
583
+ return (React.createElement(DataProvider, { name: "currentRow", data: record },
584
+ React.createElement(DataProvider, { name: "currentRowIndex", data: rowIndex },
585
+ React.createElement(DataProvider, { name: "currentColumn", data: value }, safeRender(cconfig.expr ? cconfig.expr(record) : value)))));
586
+ },
587
+ };
588
+ return columnDefinition;
589
+ });
590
+ if (actions && actions.length > 0) {
591
+ columnDefinitions.push({
592
+ title: "Actions",
593
+ valueType: "option",
594
+ key: "__plasmicActions",
595
+ render: function (_text, record, _, action) { return __spreadArray(__spreadArray([], actions
596
+ .filter(function (_action) { return !_action.moreMenu; })
597
+ .map(function (_action, aindex) {
598
+ return _action.type === "edit" ? (React.createElement("a", { key: aindex, onClick: function () {
599
+ var _a;
600
+ (_a = action === null || action === void 0 ? void 0 : action.startEditable) === null || _a === void 0 ? void 0 : _a.call(action, record.id);
601
+ } }, "Edit")) : _action.type === "view" ? (React.createElement("a", { key: aindex, href: record.url }, "View")) : _action.type === "delete" ? (React.createElement("a", { key: aindex, onClick: function () {
602
+ // TODO delete
603
+ } }, "Delete")) : (customActionChildren);
604
+ }), true), [
605
+ React.createElement(TableDropdown, { key: "actionGroup", onSelect: function () { return action === null || action === void 0 ? void 0 : action.reload(); }, menus: actions
606
+ .filter(function (_action) { return !!_action.moreMenu; })
607
+ .map(function (_action, aindex) {
608
+ var _a;
609
+ return ({
610
+ key: "" + aindex,
611
+ name: (_a = _action.label) !== null && _a !== void 0 ? _a : _action.type,
612
+ });
613
+ }) }),
614
+ ], false); },
615
+ });
818
616
  }
819
- return this.rval;
820
- },
821
- dispatchException: function dispatchException(exception) {
822
- if (this.done) {
823
- throw exception;
617
+ return { normalized: normalized, columnDefinitions: columnDefinitions };
618
+ }, [fields, data, setControlContextData, actions, customActionChildren]);
619
+ }
620
+ function useSortedFilteredData(data, columns) {
621
+ var _a = useState(""), search = _a[0], setSearch = _a[1];
622
+ var _b = useState(undefined), sortState = _b[0], setSortState = _b[1];
623
+ var finalData = React.useMemo(function () {
624
+ var _a;
625
+ var filtered = (_a = data === null || data === void 0 ? void 0 : data.data) === null || _a === void 0 ? void 0 : _a.filter(function (row) {
626
+ return fastStringify(Object.values(row)).toLowerCase().includes(search);
627
+ });
628
+ var sorted = (sortState === null || sortState === void 0 ? void 0 : sortState.sorter.column)
629
+ ? // We use .sort() rather than sortBy to use localeCompare
630
+ (function () {
631
+ var _a;
632
+ 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; });
633
+ return (filtered !== null && filtered !== void 0 ? filtered : []).sort(function (aa, bb) {
634
+ var _a, _b;
635
+ var a = (_a = expr(aa)) !== null && _a !== void 0 ? _a : null, b = (_b = expr(bb)) !== null && _b !== void 0 ? _b : null;
636
+ // Default nil to '' here because A < null < z which is weird.
637
+ return typeof a === "string"
638
+ ? a.localeCompare(b !== null && b !== void 0 ? b : "")
639
+ : typeof b === "string"
640
+ ? -b.localeCompare(a !== null && a !== void 0 ? a : "")
641
+ : a - b;
642
+ });
643
+ })()
644
+ : filtered;
645
+ var reversed = (sortState === null || sortState === void 0 ? void 0 : sortState.sorter.order) === "descend" ? sorted === null || sorted === void 0 ? void 0 : sorted.reverse() : sorted;
646
+ return reversed;
647
+ }, [data, columns, sortState, search]);
648
+ return {
649
+ finalData: finalData,
650
+ search: search,
651
+ setSearch: setSearch,
652
+ setSortState: setSortState,
653
+ };
654
+ }
655
+ function useRowSelection(data, props) {
656
+ var canSelectRows = props.canSelectRows, selectedRowKey = props.selectedRowKey, onRowSelectionChanged = props.onRowSelectionChanged, rowKey = props.rowKey;
657
+ var deriveSelectedRowKeys = function () {
658
+ if (!canSelectRows ||
659
+ canSelectRows === "none" ||
660
+ !deriveRowKey(data, rowKey)) {
661
+ return [];
824
662
  }
825
- var context = this;
826
- function handle(loc, caught) {
827
- record.type = "throw";
828
- record.arg = exception;
829
- context.next = loc;
830
- if (caught) {
831
- // If the dispatched exception was caught by a catch block,
832
- // then let that catch block handle the exception normally.
833
- context.method = "next";
834
- context.arg = undefined$1;
835
- }
836
- return !!caught;
663
+ if (typeof selectedRowKey === "string") {
664
+ return [selectedRowKey];
837
665
  }
838
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
839
- var entry = this.tryEntries[i];
840
- var record = entry.completion;
841
- if (entry.tryLoc === "root") {
842
- // Exception thrown outside of any try block that could handle
843
- // it, so set the completion value of the entire function to
844
- // throw the exception.
845
- return handle("end");
846
- }
847
- if (entry.tryLoc <= this.prev) {
848
- var hasCatch = hasOwn.call(entry, "catchLoc");
849
- var hasFinally = hasOwn.call(entry, "finallyLoc");
850
- if (hasCatch && hasFinally) {
851
- if (this.prev < entry.catchLoc) {
852
- return handle(entry.catchLoc, true);
853
- } else if (this.prev < entry.finallyLoc) {
854
- return handle(entry.finallyLoc);
855
- }
856
- } else if (hasCatch) {
857
- if (this.prev < entry.catchLoc) {
858
- return handle(entry.catchLoc, true);
859
- }
860
- } else if (hasFinally) {
861
- if (this.prev < entry.finallyLoc) {
862
- return handle(entry.finallyLoc);
863
- }
864
- } else {
865
- throw new Error("try statement without catch or finally");
666
+ else if (Array.isArray(selectedRowKey)) {
667
+ if (canSelectRows === "single") {
668
+ return selectedRowKey.slice(0, 1);
866
669
  }
867
- }
868
- }
869
- },
870
- abrupt: function abrupt(type, arg) {
871
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
872
- var entry = this.tryEntries[i];
873
- if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
874
- var finallyEntry = entry;
875
- break;
876
- }
877
- }
878
- if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
879
- // Ignore the finally entry if control is not jumping to a
880
- // location outside the try/catch block.
881
- finallyEntry = null;
882
- }
883
- var record = finallyEntry ? finallyEntry.completion : {};
884
- record.type = type;
885
- record.arg = arg;
886
- if (finallyEntry) {
887
- this.method = "next";
888
- this.next = finallyEntry.finallyLoc;
889
- return ContinueSentinel;
890
- }
891
- return this.complete(record);
892
- },
893
- complete: function complete(record, afterLoc) {
894
- if (record.type === "throw") {
895
- throw record.arg;
896
- }
897
- if (record.type === "break" || record.type === "continue") {
898
- this.next = record.arg;
899
- } else if (record.type === "return") {
900
- this.rval = this.arg = record.arg;
901
- this.method = "return";
902
- this.next = "end";
903
- } else if (record.type === "normal" && afterLoc) {
904
- this.next = afterLoc;
905
- }
906
- return ContinueSentinel;
907
- },
908
- finish: function finish(finallyLoc) {
909
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
910
- var entry = this.tryEntries[i];
911
- if (entry.finallyLoc === finallyLoc) {
912
- this.complete(entry.completion, entry.afterLoc);
913
- resetTryEntry(entry);
914
- return ContinueSentinel;
915
- }
916
- }
917
- },
918
- "catch": function _catch(tryLoc) {
919
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
920
- var entry = this.tryEntries[i];
921
- if (entry.tryLoc === tryLoc) {
922
- var record = entry.completion;
923
- if (record.type === "throw") {
924
- var thrown = record.arg;
925
- resetTryEntry(entry);
670
+ else {
671
+ return selectedRowKey;
926
672
  }
927
- return thrown;
928
- }
929
673
  }
930
-
931
- // The context.catch method must only be called with a location
932
- // argument that corresponds to a known catch block.
933
- throw new Error("illegal catch attempt");
934
- },
935
- delegateYield: function delegateYield(iterable, resultName, nextLoc) {
936
- this.delegate = {
937
- iterator: values(iterable),
938
- resultName: resultName,
939
- nextLoc: nextLoc
940
- };
941
- if (this.method === "next") {
942
- // Deliberately forget the last sent value so that we don't
943
- // accidentally pass it on to the delegate.
944
- this.arg = undefined$1;
674
+ else {
675
+ return [];
945
676
  }
946
- return ContinueSentinel;
947
- }
948
- };
949
-
950
- // Regardless of whether this script is executing as a CommonJS module
951
- // or not, return the runtime object so that we can declare the variable
952
- // regeneratorRuntime in the outer scope, which allows this module to be
953
- // injected easily by `bin/regenerator --include-runtime script.js`.
954
- return exports;
955
- }(
956
- // If this script is executing as a CommonJS module, use module.exports
957
- // as the regeneratorRuntime namespace. Otherwise create a new empty
958
- // object. Either way, the resulting object will be used to initialize
959
- // the regeneratorRuntime variable at the top of this file.
960
- module.exports );
961
- try {
962
- regeneratorRuntime = runtime;
963
- } catch (accidentalStrictMode) {
964
- // This module should not be running in strict mode, so the above
965
- // assignment should always work unless something is misconfigured. Just
966
- // in case runtime.js accidentally runs in strict mode, in modern engines
967
- // we can explicitly access globalThis. In older engines we can escape
968
- // strict mode using a global Function call. This could conceivably fail
969
- // if a Content Security Policy forbids using Function, but in that case
970
- // the proper solution is to fix the accidental strict mode problem. If
971
- // you've misconfigured your bundler to force strict mode and applied a
972
- // CSP to forbid Function, and you're not willing to fix either of those
973
- // problems, please detail your unique predicament in a GitHub issue.
974
- if (typeof globalThis === "object") {
975
- globalThis.regeneratorRuntime = runtime;
976
- } else {
977
- Function("r", "regeneratorRuntime = r")(runtime);
978
- }
979
- }
980
- });
981
-
982
- var tuple = function tuple() {
983
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
984
- args[_key] = arguments[_key];
985
- }
986
- return args;
987
- };
988
- function mkIdMap(xs) {
989
- return new Map(xs.map(function (x) {
990
- return tuple(x.id, x);
991
- }));
992
- }
993
- var mkShortId = function mkShortId() {
994
- return "" + Math.random();
995
- };
996
- var withoutNils = function withoutNils(xs) {
997
- return xs.filter(function (x) {
998
- return x != null;
999
- });
1000
- };
1001
- var defaultColumnConfig = function defaultColumnConfig() {
1002
- return {
1003
- key: mkShortId(),
1004
- isEditableExpr: function isEditableExpr() {
1005
- return false;
1006
- },
1007
- disableSorting: false,
1008
- sortByExpr: undefined,
1009
- isHidden: false,
1010
- formatting: {
1011
- styles: {},
1012
- align: "left",
1013
- freeze: "off"
1014
- },
1015
- dataType: "auto"
1016
- };
1017
- };
1018
- function deriveFieldConfigs(specifiedFieldsPartial, schema) {
1019
- var _schema$fields;
1020
- var schemaFields = (_schema$fields = schema == null ? void 0 : schema.fields) != null ? _schema$fields : [];
1021
- var fieldById = mkIdMap(schemaFields);
1022
- var specifiedFieldIds = new Set(withoutNils(specifiedFieldsPartial.map(function (f) {
1023
- return f.fieldId;
1024
- })));
1025
- function defaultColumnConfigForField(field) {
1026
- return _extends({}, defaultColumnConfig(), {
1027
- key: field.id,
1028
- fieldId: field.id,
1029
- title: field.label || field.id,
1030
- expr: function expr(currentItem) {
1031
- return currentItem[field.id];
1032
- }
1033
- });
1034
- }
1035
- var keptSpecifiedFields = specifiedFieldsPartial.flatMap(function (f, index) {
1036
- var fieldId = f.fieldId;
1037
- if (!fieldId) {
1038
- return [_extends({}, defaultColumnConfig(), {
1039
- key: index
1040
- }, f)];
1041
- }
1042
- var field = fieldById.get(fieldId);
1043
- // Drop configs with fieldIds no longer in the data.
1044
- if (!field) {
1045
- return [];
1046
- }
1047
- return [_extends({}, defaultColumnConfigForField(field), f)];
1048
- });
1049
- var newVirtualFields = schemaFields.filter(function (f) {
1050
- return !specifiedFieldIds.has(f.id);
1051
- }).map(function (f) {
1052
- return _extends({}, defaultColumnConfigForField(f));
1053
- });
1054
- var mergedFields = [].concat(keptSpecifiedFields, newVirtualFields);
1055
- var minimalFullLengthFields = [].concat(specifiedFieldsPartial, newVirtualFields.map(function (f) {
1056
- return {
1057
- key: f.key,
1058
- fieldId: f.fieldId
1059
- };
1060
- }));
1061
- return {
1062
- mergedFields: mergedFields,
1063
- minimalFullLengthFields: minimalFullLengthFields
1064
- };
1065
- }
1066
-
1067
- function tryGetSchema(data) {
1068
- var _data, _data2;
1069
- if ((_data = data) != null && _data.schema) {
1070
- return data.schema;
1071
- }
1072
- if (Array.isArray(data)) {
1073
- data = {
1074
- data: data
1075
677
  };
1076
- }
1077
- if (!((_data2 = data) != null && _data2.data) || !Array.isArray(data.data) || data.data.length === 0) {
1078
- return undefined;
1079
- }
1080
- var fieldMap = {};
1081
- data.data.forEach(function (entry) {
1082
- if (entry && typeof entry === "object") {
1083
- Array.from(Object.entries(entry)).forEach(function (_ref) {
1084
- var k = _ref[0],
1085
- v = _ref[1];
1086
- var inferredType = typeof v === "string" ? "string" : typeof v === "boolean" ? "boolean" : typeof v === "number" ? "number" : "unknown";
1087
- if (fieldMap[k] && fieldMap[k] !== inferredType) {
1088
- fieldMap[k] = "unknown";
1089
- } else {
1090
- fieldMap[k] = inferredType;
678
+ var rowSelection = canSelectRows && canSelectRows !== "none"
679
+ ? {
680
+ type: canSelectRows === "single" ? "radio" : "checkbox",
681
+ selectedRowKeys: deriveSelectedRowKeys(),
682
+ onChange: function (rowKeys, rows) {
683
+ onRowSelectionChanged === null || onRowSelectionChanged === void 0 ? void 0 : onRowSelectionChanged(rowKeys, rows);
684
+ },
685
+ alwaysShowAlert: true,
1091
686
  }
1092
- });
1093
- }
1094
- });
1095
- return {
1096
- id: "inferred",
1097
- fields: Object.entries(fieldMap).map(function (_ref2) {
1098
- var f = _ref2[0],
1099
- t = _ref2[1];
1100
- return {
1101
- id: f,
1102
- type: t,
1103
- readOnly: false
1104
- };
1105
- })
1106
- };
1107
- }
1108
- function normalizeData(rawData) {
1109
- if (!rawData || typeof rawData !== "object") {
1110
- return undefined;
1111
- }
1112
- var obj = Array.isArray(rawData) ? {
1113
- data: rawData
1114
- } : rawData;
1115
- if (!("data" in obj)) {
1116
- return undefined;
1117
- }
1118
- var objWithData = obj;
1119
- if (!Array.isArray(objWithData.data) || objWithData.data.length === 0) {
1120
- return undefined;
1121
- }
1122
- // Make TS happy.
1123
- var normed = _extends({}, objWithData, {
1124
- data: objWithData.data
1125
- });
1126
- var schema = tryGetSchema(rawData);
1127
- if (!schema) {
1128
- return undefined;
1129
- }
1130
- return _extends({}, normed, {
1131
- schema: schema
1132
- });
687
+ : undefined;
688
+ return rowSelection;
1133
689
  }
1134
- /**
1135
- * Render booleans, objects, arrays, etc. as JSON repr.
1136
- */
1137
- function safeRender(x) {
1138
- return x === undefined || x === null ? "" : typeof x === "string" ? x : typeof x === "number" ? x.toString() : JSON.stringify(x);
1139
- }
1140
- function RichTable(props) {
1141
- var className = props.className,
1142
- _props$data = props.data,
1143
- rawData = _props$data === void 0 ? {
1144
- data: [],
1145
- schema: {
1146
- id: "inferred",
1147
- fields: [{
1148
- id: "id",
1149
- type: "string",
1150
- readOnly: false
1151
- }]
1152
- }
1153
- } : _props$data,
1154
- _props$pagination = props.pagination,
1155
- pagination = _props$pagination === void 0 ? true : _props$pagination,
1156
- defaultSize = props.defaultSize,
1157
- fields = props.fields,
1158
- setControlContextData = props.setControlContextData,
1159
- title = props.title,
1160
- addHref = props.addHref,
1161
- actions = props.actions,
1162
- customActionChildren = props.customActionChildren,
1163
- _props$pageSize = props.pageSize,
1164
- pageSize = _props$pageSize === void 0 ? 10 : _props$pageSize,
1165
- _props$scrollX = props.scrollX,
1166
- scrollX = _props$scrollX === void 0 ? true : _props$scrollX,
1167
- scrollHeight = props.scrollHeight,
1168
- hideSearch = props.hideSearch,
1169
- hideDensity = props.hideDensity,
1170
- hideColumnPicker = props.hideColumnPicker,
1171
- hideExports = props.hideExports;
1172
- var data = normalizeData(rawData);
1173
- var _useState = useState(""),
1174
- search = _useState[0],
1175
- setSearch = _useState[1];
1176
- var _React$useMemo = React.useMemo(function () {
1177
- var schema = tryGetSchema(data);
1178
- if (!data || !schema) {
1179
- return {
1180
- normalized: [],
1181
- columnDefinitions: []
1182
- };
1183
- }
1184
- var _deriveFieldConfigs = deriveFieldConfigs(fields != null ? fields : [], schema),
1185
- mergedFields = _deriveFieldConfigs.mergedFields,
1186
- minimalFullLengthFields = _deriveFieldConfigs.minimalFullLengthFields;
1187
- setControlContextData == null ? void 0 : setControlContextData(_extends({}, data, {
1188
- mergedFields: mergedFields,
1189
- minimalFullLengthFields: minimalFullLengthFields
1190
- }));
1191
- var normalized = mergedFields;
1192
- var columnDefinitions = normalized.filter(function (cconfig) {
1193
- return !cconfig.isHidden;
1194
- }).map(function (cconfig, _columnIndex, _columnsArray) {
1195
- var columnDefinition = {
1196
- dataIndex: cconfig.fieldId,
1197
- title: cconfig.title,
1198
- // dataIndex: cconfig,
1199
- key: cconfig.key,
1200
- valueType: cconfig.dataType === "auto" ? undefined : cconfig.dataType === "string" ? "text" : cconfig.dataType === "number" ? "digit" : cconfig.dataType === "boolean" ? "switch" : undefined,
1201
- // To come later
1202
- readonly: false,
1203
- sorter: true,
1204
- copyable: false,
1205
- ellipsis: false,
1206
- tip: undefined,
1207
- formItemProps: {
1208
- rules: []
1209
- },
1210
- disable: false,
1211
- valueEnum: undefined,
1212
- search: undefined,
1213
- hideInSearch: false,
1214
- renderFormItem: function renderFormItem(_, _ref3) {
1215
- var defaultRender = _ref3.defaultRender;
1216
- return defaultRender(_);
1217
- },
1218
- render: function render(value, record, rowIndex) {
1219
- return React.createElement(DataProvider, {
1220
- name: "currentRow",
1221
- data: record
1222
- }, React.createElement(DataProvider, {
1223
- name: "currentRowIndex",
1224
- data: rowIndex
1225
- }, React.createElement(DataProvider, {
1226
- name: "currentColumn",
1227
- data: value
1228
- }, safeRender(cconfig.expr ? cconfig.expr(record) : value))));
1229
- }
1230
- };
1231
- return columnDefinition;
1232
- });
1233
- if (actions && actions.length > 0) {
1234
- columnDefinitions.push({
1235
- title: "Actions",
1236
- valueType: "option",
1237
- key: "__plasmicActions",
1238
- render: function render(_text, record, _, action) {
1239
- return [].concat(actions.filter(function (_action) {
1240
- return !_action.moreMenu;
1241
- }).map(function (_action, aindex) {
1242
- return _action.type === "edit" ? React.createElement("a", {
1243
- key: aindex,
1244
- onClick: function onClick() {
1245
- action == null ? void 0 : action.startEditable == null ? void 0 : action.startEditable(record.id);
1246
- }
1247
- }, "Edit") : _action.type === "view" ? React.createElement("a", {
1248
- key: aindex,
1249
- href: record.url
1250
- }, "View") : _action.type === "delete" ? React.createElement("a", {
1251
- key: aindex,
1252
- onClick: function onClick() {
1253
- // TODO delete
1254
- }
1255
- }, "Delete") : customActionChildren;
1256
- }), [React.createElement(TableDropdown, {
1257
- key: "actionGroup",
1258
- onSelect: function onSelect() {
1259
- return action == null ? void 0 : action.reload();
1260
- },
1261
- menus: actions.filter(function (_action) {
1262
- return !!_action.moreMenu;
1263
- }).map(function (_action, aindex) {
1264
- var _action$label;
1265
- return {
1266
- key: "" + aindex,
1267
- name: (_action$label = _action.label) != null ? _action$label : _action.type
1268
- };
1269
- })
1270
- })]);
1271
- }
1272
- });
1273
- }
1274
- return {
1275
- normalized: normalized,
1276
- columnDefinitions: columnDefinitions
1277
- };
1278
- }, [fields, data, setControlContextData]),
1279
- columnDefinitions = _React$useMemo.columnDefinitions,
1280
- normalized = _React$useMemo.normalized;
1281
- var actionRef = useRef();
1282
- var _useState2 = useState(undefined),
1283
- state = _useState2[0],
1284
- setState = _useState2[1];
1285
- var finalData = useMemo(function () {
1286
- var _data$data;
1287
- var filtered = data == null ? void 0 : (_data$data = data.data) == null ? void 0 : _data$data.filter(function (row) {
1288
- return fastStringify(Object.values(row)).toLowerCase().includes(search);
1289
- });
1290
- var sorted = state != null && state.sorter.column ?
1291
- // We use .sort() rather than sortBy to use localeCompare
1292
- function () {
1293
- var _normalized$find$expr;
1294
- var expr = (_normalized$find$expr = normalized.find(function (cconfig) {
1295
- var _state$sorter$column;
1296
- return cconfig.key === (state == null ? void 0 : (_state$sorter$column = state.sorter.column) == null ? void 0 : _state$sorter$column.key);
1297
- }).expr) != null ? _normalized$find$expr : function (x) {
1298
- return x;
1299
- };
1300
- return (filtered != null ? filtered : []).sort(function (aa, bb) {
1301
- var _expr, _expr2;
1302
- var a = (_expr = expr(aa)) != null ? _expr : null,
1303
- b = (_expr2 = expr(bb)) != null ? _expr2 : null;
1304
- // Default nil to '' here because A < null < z which is weird.
1305
- return typeof a === "string" ? a.localeCompare(b != null ? b : "") : typeof b === "string" ? -b.localeCompare(a != null ? a : "") : a - b;
1306
- });
1307
- }() : filtered;
1308
- var reversed = (state == null ? void 0 : state.sorter.order) === "descend" ? sorted == null ? void 0 : sorted.reverse() : sorted;
1309
- return reversed;
1310
- }, [data, normalized, state, search]);
1311
- var isClient = useIsClient();
1312
- if (!isClient) {
1313
- return null;
1314
- }
1315
- return React.createElement(React.Fragment, null, React.createElement(ProTable, {
1316
- actionRef: actionRef,
1317
- className: className,
1318
- columns: columnDefinitions,
1319
- onChange: function onChange(_pagination, _filters, sorter, _extra) {
1320
- setState({
1321
- sorter: sorter
1322
- });
1323
- },
1324
- dataSource: finalData,
1325
- rowKey: "id",
1326
- defaultSize: defaultSize,
1327
- editable: {
1328
- type: "multiple"
1329
- },
1330
- search: false,
1331
- options: {
1332
- setting: hideColumnPicker ? false : {
1333
- listsHeight: 400
1334
- },
1335
- reload: false,
1336
- density: !hideDensity
1337
- },
1338
- pagination: pagination ? {
1339
- pageSize: pageSize,
1340
- onChange: function onChange(page) {
1341
- return console.log(page);
1342
- }
1343
- } : false,
1344
- dateFormatter: "string",
1345
- headerTitle: title,
1346
- // TODO in the future, figure out how to make this responsive to the CSS height
1347
- scroll: {
1348
- x: scrollX || undefined,
1349
- y: scrollHeight
1350
- },
1351
- toolbar: {
1352
- search: !hideSearch ? {
1353
- value: search,
1354
- onChange: function onChange(e) {
1355
- return setSearch(e.target.value);
1356
- },
1357
- onSearch: function onSearch() {},
1358
- placeholder: "Search"
1359
- } : undefined
1360
- },
1361
- toolBarRender: function toolBarRender() {
1362
- return [addHref && React.createElement(Button, {
1363
- key: "button",
1364
- icon: React.createElement(PlusOutlined, null),
1365
- type: "primary",
1366
- href: addHref
1367
- }, "Add"), !hideExports && React.createElement(Dropdown, {
1368
- key: "menu",
1369
- menu: {
1370
- items: [{
1371
- label: "Download as CSV",
1372
- key: "csv",
1373
- onClick: function () {
1374
- var _onClick = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
1375
- var _tryGetSchema$fields$, _tryGetSchema;
1376
- var writer, dataStr, filename, blob, link, url;
1377
- return runtime_1.wrap(function _callee$(_context) {
1378
- while (1) {
1379
- switch (_context.prev = _context.next) {
1380
- case 0:
1381
- writer = createObjectCsvStringifier({
1382
- header: (_tryGetSchema$fields$ = (_tryGetSchema = tryGetSchema(data)) == null ? void 0 : _tryGetSchema.fields.map(function (f) {
1383
- return {
1384
- id: f.id,
1385
- title: f.id
1386
- };
1387
- })) != null ? _tryGetSchema$fields$ : []
690
+ function ExportMenu(props) {
691
+ var _this = this;
692
+ var data = props.data;
693
+ return (React.createElement(Dropdown, { key: "menu", menu: {
694
+ items: [
695
+ {
696
+ label: "Download as CSV",
697
+ key: "csv",
698
+ onClick: function () { return __awaiter(_this, void 0, void 0, function () {
699
+ var writer, dataStr, filename, blob, link, url;
700
+ var _a, _b;
701
+ return __generator(this, function (_c) {
702
+ writer = createObjectCsvStringifier({
703
+ header: (_b = (_a = tryGetSchema(data)) === null || _a === void 0 ? void 0 : _a.fields.map(function (f) { return ({
704
+ id: f.id,
705
+ title: f.id,
706
+ }); })) !== null && _b !== void 0 ? _b : [],
707
+ });
708
+ dataStr = writer.getHeaderString() +
709
+ writer.stringifyRecords(data === null || data === void 0 ? void 0 : data.data);
710
+ filename = "data.csv";
711
+ blob = new Blob([dataStr], {
712
+ type: "text/csv;charset=utf-8;",
713
+ });
714
+ if (navigator.msSaveBlob) {
715
+ // In case of IE 10+
716
+ navigator.msSaveBlob(blob, filename);
717
+ }
718
+ else {
719
+ link = document.createElement("a");
720
+ if (link.download !== undefined) {
721
+ url = URL.createObjectURL(blob);
722
+ link.setAttribute("href", url);
723
+ link.setAttribute("download", filename);
724
+ link.style.visibility = "hidden";
725
+ document.body.appendChild(link);
726
+ link.click();
727
+ document.body.removeChild(link);
728
+ }
729
+ }
730
+ return [2 /*return*/];
1388
731
  });
1389
- dataStr = writer.getHeaderString() + writer.stringifyRecords(data == null ? void 0 : data.data); // const dataStr = stringify(data?.data as any, {
1390
- // columns:
1391
- // tryGetSchema(data)?.fields.map((f) => f.id) ?? [],
1392
- // header: true,
1393
- // });
1394
- filename = "data.csv"; // Adapted from https://stackoverflow.com/a/68771795
1395
- blob = new Blob([dataStr], {
1396
- type: "text/csv;charset=utf-8;"
1397
- });
1398
- if (navigator.msSaveBlob) {
1399
- // In case of IE 10+
1400
- navigator.msSaveBlob(blob, filename);
1401
- } else {
1402
- link = document.createElement("a");
1403
- if (link.download !== undefined) {
1404
- // Browsers that support HTML5 download attribute
1405
- url = URL.createObjectURL(blob);
1406
- link.setAttribute("href", url);
1407
- link.setAttribute("download", filename);
1408
- link.style.visibility = "hidden";
1409
- document.body.appendChild(link);
1410
- link.click();
1411
- document.body.removeChild(link);
1412
- }
1413
- }
1414
- case 5:
1415
- case "end":
1416
- return _context.stop();
1417
- }
1418
- }
1419
- }, _callee);
1420
- }));
1421
- function onClick() {
1422
- return _onClick.apply(this, arguments);
1423
- }
1424
- return onClick;
1425
- }()
1426
- }, {
1427
- label: "Download as JSON",
1428
- key: "json",
1429
- onClick: function onClick() {
1430
- var dataStr = fastStringify(data == null ? void 0 : data.data);
1431
- var dataUri = "data:application/json;charset=utf-8, " + encodeURIComponent(dataStr);
1432
- var exportFileDefaultName = "data.json";
1433
- var linkElement = document.createElement("a");
1434
- linkElement.setAttribute("href", dataUri);
1435
- linkElement.setAttribute("download", exportFileDefaultName);
1436
- linkElement.click();
1437
- }
1438
- }]
1439
- }
1440
- }, React.createElement(Button, null, React.createElement(EllipsisOutlined, null)))];
1441
- }
1442
- }), React.createElement("style", null, "\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 .ant-pro-table-list-toolbar-right {\n flex-wrap: initial;\n flex-shrink: 0;\n }\n "));
732
+ }); },
733
+ },
734
+ {
735
+ label: "Download as JSON",
736
+ key: "json",
737
+ onClick: function () {
738
+ var dataStr = fastStringify(data === null || data === void 0 ? void 0 : data.data);
739
+ var dataUri = "data:application/json;charset=utf-8, ".concat(encodeURIComponent(dataStr));
740
+ var exportFileDefaultName = "data.json";
741
+ var linkElement = document.createElement("a");
742
+ linkElement.setAttribute("href", dataUri);
743
+ linkElement.setAttribute("download", exportFileDefaultName);
744
+ linkElement.click();
745
+ },
746
+ },
747
+ ],
748
+ } },
749
+ React.createElement(Button, null,
750
+ React.createElement(EllipsisOutlined, null))));
1443
751
  }
1444
752
 
1445
753
  function ensureNumber(x) {
1446
- return x;
754
+ return x;
1447
755
  }
1448
- var rowDataType = function rowDataType(displayName, control) {
1449
- return {
1450
- type: "function",
1451
- displayName: displayName,
1452
- control: control,
1453
- argNames: ["currentItem"],
1454
- argValues: function argValues(_props, ctx) {
1455
- var _ctx$data;
1456
- return [ctx == null ? void 0 : (_ctx$data = ctx.data) == null ? void 0 : _ctx$data[0]];
1457
- }
1458
- };
756
+ var tableHelpers = {
757
+ states: {
758
+ selectedRow: {
759
+ onChangeArgsToValue: function (rowKeys, rows) {
760
+ return rows[0];
761
+ },
762
+ },
763
+ selectedRows: {
764
+ onChangeArgsToValue: function (rowKeys, rows) {
765
+ return rows;
766
+ },
767
+ },
768
+ selectedRowKey: {
769
+ onChangeArgsToValue: function (rowKeys, rows) {
770
+ return rowKeys;
771
+ },
772
+ },
773
+ },
774
+ };
775
+ var rowDataType = function (displayName, control) {
776
+ return ({
777
+ type: "function",
778
+ displayName: displayName,
779
+ control: control,
780
+ argNames: ["currentItem"],
781
+ 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]]; },
782
+ });
1459
783
  };
1460
784
  function getDefaultValueHint(field) {
1461
- return function (_props, contextData, _ref) {
1462
- var path = _ref.path;
1463
- return contextData == null ? void 0 : contextData.mergedFields[ensureNumber(path.slice(-2)[0])][field];
1464
- };
785
+ return function (_props, contextData, _a) {
786
+ var path = _a.path;
787
+ return contextData === null || contextData === void 0 ? void 0 : contextData.mergedFields[ensureNumber(path.slice(-2)[0])][field];
788
+ };
1465
789
  }
1466
790
  var dataTableMeta = {
1467
- name: "hostless-rich-table",
1468
- displayName: "Table",
1469
- defaultStyles: {
1470
- width: "stretch"
1471
- },
1472
- props: {
1473
- data: {
1474
- type: "dataSourceOpData",
1475
- description: "The data to display in the table"
1476
- },
1477
- defaultSize: {
1478
- type: "choice",
1479
- options: ["large", "middle", "small"],
1480
- defaultValueHint: "large"
1481
- },
1482
- pageSize: {
1483
- type: "number",
1484
- defaultValueHint: 10
791
+ name: "hostless-rich-table",
792
+ displayName: "Table",
793
+ defaultStyles: {
794
+ width: "stretch",
795
+ padding: "16px",
1485
796
  },
1486
- fields: {
1487
- type: "array",
1488
- hidden: function hidden(ps) {
1489
- return !ps.data;
1490
- },
1491
- unstable__keyFunc: function unstable__keyFunc(x) {
1492
- return x.key;
1493
- },
1494
- unstable__minimalValue: function unstable__minimalValue(_props, contextData) {
1495
- return contextData == null ? void 0 : contextData.minimalFullLengthFields;
1496
- },
1497
- unstable__canDelete: function unstable__canDelete(_item, _props, ctx, _ref2) {
1498
- var path = _ref2.path;
1499
- return !(ctx != null && ctx.mergedFields[ensureNumber(path.slice(-1)[0])].fieldId);
1500
- },
1501
- itemType: {
1502
- type: "object",
1503
- nameFunc: function nameFunc(_item, _props, ctx, _ref3) {
1504
- var path = _ref3.path;
1505
- return ctx == null ? void 0 : ctx.mergedFields[ensureNumber(path.slice(-1)[0])].title;
797
+ props: {
798
+ data: {
799
+ type: "dataSourceOpData",
800
+ description: "The data to display in the table",
1506
801
  },
1507
- fields: {
1508
- key: {
1509
- type: "string",
1510
- hidden: function hidden() {
1511
- return true;
1512
- }
1513
- },
1514
- fieldId: {
802
+ defaultSize: {
1515
803
  type: "choice",
1516
- displayName: "Field name",
1517
- readOnly: true,
1518
- options: function options(_props, ctx) {
1519
- var _ctx$schema$fields, _ctx$schema;
1520
- return ((_ctx$schema$fields = ctx == null ? void 0 : (_ctx$schema = ctx.schema) == null ? void 0 : _ctx$schema.fields) != null ? _ctx$schema$fields : []).map(function (f) {
1521
- return f.id;
1522
- });
804
+ options: ["large", "middle", "small"],
805
+ defaultValueHint: "large",
806
+ },
807
+ pageSize: {
808
+ type: "number",
809
+ defaultValueHint: 10,
810
+ },
811
+ fields: {
812
+ type: "array",
813
+ hidden: function (ps) { return !ps.data; },
814
+ unstable__keyFunc: function (x) { return x.key; },
815
+ unstable__minimalValue: function (_props, contextData) {
816
+ return contextData === null || contextData === void 0 ? void 0 : contextData.minimalFullLengthFields;
1523
817
  },
1524
- hidden: function hidden(_props, ctx, _ref4) {
1525
- var _ctx$schema$fields2, _ctx$schema2;
1526
- var _controlPath = _ref4.path;
1527
- return !(_controlPath.slice(-1)[0] in ((_ctx$schema$fields2 = ctx == null ? void 0 : (_ctx$schema2 = ctx.schema) == null ? void 0 : _ctx$schema2.fields) != null ? _ctx$schema$fields2 : {}));
1528
- }
1529
- },
1530
- title: {
1531
- type: "string",
1532
- displayName: "Title",
1533
- defaultValueHint: /*#__PURE__*/getDefaultValueHint("title")
1534
- },
1535
- dataType: {
818
+ unstable__canDelete: function (_item, _props, ctx, _a) {
819
+ var path = _a.path;
820
+ return !(ctx === null || ctx === void 0 ? void 0 : ctx.mergedFields[ensureNumber(path.slice(-1)[0])].fieldId);
821
+ },
822
+ itemType: {
823
+ type: "object",
824
+ nameFunc: function (_item, _props, ctx, _a) {
825
+ var path = _a.path;
826
+ return ctx === null || ctx === void 0 ? void 0 : ctx.mergedFields[ensureNumber(path.slice(-1)[0])].title;
827
+ },
828
+ fields: {
829
+ key: {
830
+ type: "string",
831
+ hidden: function () { return true; },
832
+ },
833
+ fieldId: {
834
+ type: "choice",
835
+ displayName: "Field name",
836
+ readOnly: true,
837
+ 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; }); },
838
+ hidden: function (_props, ctx, _a) {
839
+ var _b, _c;
840
+ var _controlPath = _a.path;
841
+ 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 : {}));
842
+ },
843
+ },
844
+ title: {
845
+ type: "string",
846
+ displayName: "Title",
847
+ defaultValueHint: getDefaultValueHint("title"),
848
+ },
849
+ dataType: {
850
+ type: "choice",
851
+ displayName: "Data type",
852
+ options: ["auto", "number", "string", "boolean"],
853
+ defaultValueHint: getDefaultValueHint("dataType"),
854
+ },
855
+ expr: rowDataType("Customize data"),
856
+ // TODO
857
+ // isEditableExpr: rowDataType("Is editable", {
858
+ // type: "boolean",
859
+ // defaultValueHint: false,
860
+ // }),
861
+ // disableSorting: {
862
+ // type: "boolean",
863
+ // displayName: "Disable sorting",
864
+ // defaultValueHint: getDefaultValueHint("disableSorting"),
865
+ // },
866
+ // sortByExpr: rowDataType("Sort by"),
867
+ isHidden: {
868
+ type: "boolean",
869
+ displayName: "Is hidden",
870
+ defaultValueHint: getDefaultValueHint("isHidden"),
871
+ },
872
+ },
873
+ },
874
+ },
875
+ canSelectRows: {
1536
876
  type: "choice",
1537
- displayName: "Data type",
1538
- options: ["auto", "number", "string", "boolean"],
1539
- defaultValueHint: /*#__PURE__*/getDefaultValueHint("dataType")
1540
- },
1541
- expr: /*#__PURE__*/rowDataType("Customize data"),
1542
- // TODO
1543
- // isEditableExpr: rowDataType("Is editable", {
1544
- // type: "boolean",
1545
- // defaultValueHint: false,
1546
- // }),
1547
- // disableSorting: {
1548
- // type: "boolean",
1549
- // displayName: "Disable sorting",
1550
- // defaultValueHint: getDefaultValueHint("disableSorting"),
1551
- // },
1552
- // sortByExpr: rowDataType("Sort by"),
1553
- isHidden: {
877
+ displayName: "Select rows?",
878
+ options: [
879
+ { label: "No", value: "none" },
880
+ { label: "Single", value: "single" },
881
+ { label: "Multiple", value: "multiple" },
882
+ ],
883
+ defaultValueHint: "none",
884
+ },
885
+ rowKey: {
886
+ type: "string",
887
+ displayName: "Row key",
888
+ helpText: "Column key to use as row key; can also be a function that takes in a row and returns a key value",
889
+ hidden: function (ps) { return !ps.canSelectRows || ps.canSelectRows === "none"; },
890
+ defaultValueHint: function (ps) { return deriveRowKey(ps.data, ps.rowKey); },
891
+ },
892
+ selectedRowKey: {
893
+ type: "string",
894
+ displayName: "Selected Row Key",
895
+ hidden: function (ps) { return ps.canSelectRows !== "single"; },
896
+ advanced: true,
897
+ },
898
+ selectedRowKeys: {
899
+ type: "array",
900
+ displayName: "Selected Row Keys",
901
+ hidden: function (ps) { return ps.canSelectRows !== "multiple"; },
902
+ advanced: true,
903
+ },
904
+ onRowSelectionChanged: {
905
+ type: "eventHandler",
906
+ displayName: "On row selection changed",
907
+ argTypes: [
908
+ { name: "rowKeys", type: "object" },
909
+ { name: "rows", type: "object" },
910
+ ],
911
+ },
912
+ pagination: {
1554
913
  type: "boolean",
1555
- displayName: "Is hidden",
1556
- defaultValueHint: /*#__PURE__*/getDefaultValueHint("isHidden")
1557
- }
1558
- }
1559
- }
1560
- },
1561
- pagination: {
1562
- type: "boolean",
1563
- advanced: true,
1564
- defaultValueHint: true
1565
- },
1566
- scrollX: {
1567
- type: "boolean",
1568
- advanced: true,
1569
- defaultValueHint: true
1570
- },
1571
- scrollHeight: {
1572
- type: "number",
1573
- advanced: true
1574
- },
1575
- hideSearch: {
1576
- type: "boolean",
1577
- advanced: true
914
+ advanced: true,
915
+ defaultValueHint: true,
916
+ },
917
+ hideSearch: {
918
+ type: "boolean",
919
+ advanced: true,
920
+ },
921
+ hideExports: {
922
+ type: "boolean",
923
+ advanced: true,
924
+ },
925
+ hideDensity: {
926
+ type: "boolean",
927
+ advanced: true,
928
+ },
929
+ hideColumnPicker: {
930
+ type: "boolean",
931
+ advanced: true,
932
+ },
1578
933
  },
1579
- hideExports: {
1580
- type: "boolean",
1581
- advanced: true
934
+ states: {
935
+ selectedRowKey: __assign({ type: "writable", valueProp: "selectedRowKey", onChangeProp: "onRowSelectionChanged", variableType: "text" }, tableHelpers.states.selectedRowKey),
936
+ selectedRow: __assign({ type: "readonly", onChangeProp: "onRowSelectionChanged", variableType: "object" }, tableHelpers.states.selectedRow),
937
+ selectedRows: __assign({ type: "readonly", onChangeProp: "onRowSelectionChanged", variableType: "array" }, tableHelpers.states.selectedRows),
1582
938
  },
1583
- hideDensity: {
1584
- type: "boolean",
1585
- advanced: true
939
+ componentHelpers: {
940
+ helpers: tableHelpers,
941
+ importName: "tableHelpers",
942
+ importPath: "@plasmicpkgs/plasmic-rich-components",
1586
943
  },
1587
- hideColumnPicker: {
1588
- type: "boolean",
1589
- advanced: true
1590
- }
1591
- },
1592
- importName: "RichTable",
1593
- importPath: "@plasmicpkgs/plasmic-rich-components"
944
+ importName: "RichTable",
945
+ importPath: "@plasmicpkgs/plasmic-rich-components",
1594
946
  };
1595
947
  function registerRichTable(loader) {
1596
- registerComponentHelper(loader, RichTable, dataTableMeta);
948
+ registerComponentHelper(loader, RichTable, dataTableMeta);
1597
949
  }
1598
950
 
1599
951
  function registerAll(loader) {
1600
- registerRichLayout(loader);
1601
- registerRichTable(loader);
952
+ registerRichLayout(loader);
953
+ registerRichTable(loader);
1602
954
  }
1603
955
 
1604
- export { RichLayout, RichTable, registerAll };
956
+ export { RichLayout, RichTable, registerAll, tableHelpers };
1605
957
  //# sourceMappingURL=plasmic-rich-components.esm.js.map