@plasmicpkgs/plasmic-rich-components 1.0.169 → 1.0.170
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.tsbuildinfo +1 -1
- package/dist/index.js +7 -7
- package/dist/index.js.map +1 -1
- package/dist/plasmic-rich-components.esm.js +7 -7
- package/dist/plasmic-rich-components.esm.js.map +1 -1
- package/dist/rich-calendar/index.d.ts +1 -1
- package/package.json +18 -4
- package/skinny/common-8cca2977.esm.js +22 -0
- package/skinny/common-8cca2977.esm.js.map +1 -0
- package/skinny/common-e1d76791.cjs.js +30 -0
- package/skinny/common-e1d76791.cjs.js.map +1 -0
- package/skinny/common-prop-types-5f1fd4b0.cjs.js +139 -0
- package/skinny/common-prop-types-5f1fd4b0.cjs.js.map +1 -0
- package/skinny/common-prop-types-686c49fe.esm.js +133 -0
- package/skinny/common-prop-types-686c49fe.esm.js.map +1 -0
- package/skinny/common-prop-types.d.ts +12 -0
- package/skinny/common.d.ts +5 -0
- package/skinny/field-mappings.d.ts +100 -0
- package/skinny/field-react-utils-26fba31e.esm.js +142 -0
- package/skinny/field-react-utils-26fba31e.esm.js.map +1 -0
- package/skinny/field-react-utils-c717ec94.cjs.js +153 -0
- package/skinny/field-react-utils-c717ec94.cjs.js.map +1 -0
- package/skinny/field-react-utils.d.ts +34 -0
- package/skinny/formatting-327e0658.cjs.js +645 -0
- package/skinny/formatting-327e0658.cjs.js.map +1 -0
- package/skinny/formatting-aff39488.esm.js +633 -0
- package/skinny/formatting-aff39488.esm.js.map +1 -0
- package/skinny/formatting.d.ts +7 -0
- package/skinny/rich-calendar/RichCalendar.d.ts +31 -0
- package/skinny/rich-calendar/index.cjs.js +501 -0
- package/skinny/rich-calendar/index.cjs.js.map +1 -0
- package/skinny/rich-calendar/index.d.ts +15 -0
- package/skinny/rich-calendar/index.esm.js +488 -0
- package/skinny/rich-calendar/index.esm.js.map +1 -0
- package/skinny/rich-details/RichDetails.d.ts +12 -0
- package/skinny/rich-details/index.cjs.js +169 -0
- package/skinny/rich-details/index.cjs.js.map +1 -0
- package/skinny/rich-details/index.d.ts +3 -0
- package/skinny/rich-details/index.esm.js +162 -0
- package/skinny/rich-details/index.esm.js.map +1 -0
- package/skinny/rich-layout/RichLayout.d.ts +22 -0
- package/skinny/rich-layout/index.cjs.js +486 -0
- package/skinny/rich-layout/index.cjs.js.map +1 -0
- package/skinny/rich-layout/index.d.ts +5 -0
- package/skinny/rich-layout/index.esm.js +476 -0
- package/skinny/rich-layout/index.esm.js.map +1 -0
- package/skinny/rich-list/RichList.d.ts +59 -0
- package/skinny/rich-list/index.cjs.js +583 -0
- package/skinny/rich-list/index.cjs.js.map +1 -0
- package/skinny/rich-list/index.d.ts +5 -0
- package/skinny/rich-list/index.esm.js +571 -0
- package/skinny/rich-list/index.esm.js.map +1 -0
- package/skinny/rich-table/RichTable.d.ts +46 -0
- package/skinny/rich-table/index.cjs.js +598 -0
- package/skinny/rich-table/index.cjs.js.map +1 -0
- package/skinny/rich-table/index.d.ts +21 -0
- package/skinny/rich-table/index.esm.js +586 -0
- package/skinny/rich-table/index.esm.js.map +1 -0
- package/skinny/utils-65c486f0.cjs.js +139 -0
- package/skinny/utils-65c486f0.cjs.js.map +1 -0
- package/skinny/utils-c32bd7ed.esm.js +118 -0
- package/skinny/utils-c32bd7ed.esm.js.map +1 -0
- package/skinny/utils.d.ts +72 -0
- package/skinny/widgets.d.ts +2 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { SizeType } from "antd/es/config-provider/SizeContext";
|
|
2
|
+
import type { GetRowKey } from "antd/es/table/interface";
|
|
3
|
+
import React, { ReactNode } from "react";
|
|
4
|
+
import { BaseColumnConfig, FieldfulProps, RowFunc } from "../field-mappings";
|
|
5
|
+
import { RowAction } from "../field-react-utils";
|
|
6
|
+
export interface Action {
|
|
7
|
+
type: "edit" | "view" | "delete" | "custom";
|
|
8
|
+
label?: string;
|
|
9
|
+
moreMenu?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface RichTableProps extends FieldfulProps<TableColumnConfig> {
|
|
12
|
+
defaultSize?: SizeType;
|
|
13
|
+
pagination?: boolean;
|
|
14
|
+
canSelectRows?: "none" | "click" | "single" | "multiple";
|
|
15
|
+
selectedRowKey?: string;
|
|
16
|
+
selectedRowKeys?: string[];
|
|
17
|
+
onRowSelectionChanged?: (rowKeys: string[], rows: any[]) => void;
|
|
18
|
+
onRowClick?: (rowKey: string, row: any, event: React.MouseEvent) => void;
|
|
19
|
+
rowKey?: string | GetRowKey<any>;
|
|
20
|
+
rowActions?: RowAction[];
|
|
21
|
+
title?: ReactNode;
|
|
22
|
+
addHref?: string;
|
|
23
|
+
actions?: Action[];
|
|
24
|
+
customActionChildren?: ReactNode;
|
|
25
|
+
pageSize?: number;
|
|
26
|
+
hideSearch?: boolean;
|
|
27
|
+
hideDensity?: boolean;
|
|
28
|
+
hideColumnPicker?: boolean;
|
|
29
|
+
hideExports?: boolean;
|
|
30
|
+
hideSelectionBar?: boolean;
|
|
31
|
+
scopeClassName?: string;
|
|
32
|
+
themeResetClassName?: string;
|
|
33
|
+
}
|
|
34
|
+
export declare function RichTable(props: RichTableProps): React.JSX.Element | null;
|
|
35
|
+
interface StyleConfig {
|
|
36
|
+
styles: Record<string, any>;
|
|
37
|
+
align: "left" | "center" | "right";
|
|
38
|
+
freeze: "off" | "left" | "right";
|
|
39
|
+
}
|
|
40
|
+
export type TableColumnConfig = BaseColumnConfig & {
|
|
41
|
+
isEditableExpr: RowFunc<boolean>;
|
|
42
|
+
disableSorting: boolean;
|
|
43
|
+
sortByExpr?: RowFunc<any>;
|
|
44
|
+
formatting: StyleConfig;
|
|
45
|
+
};
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,598 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var commonPropTypes = require('../common-prop-types-5f1fd4b0.cjs.js');
|
|
6
|
+
var formatting = require('../formatting-327e0658.cjs.js');
|
|
7
|
+
var utils = require('../utils-65c486f0.cjs.js');
|
|
8
|
+
var icons = require('@ant-design/icons');
|
|
9
|
+
var proComponents = require('@ant-design/pro-components');
|
|
10
|
+
var dataSources = require('@plasmicapp/data-sources');
|
|
11
|
+
var antd = require('antd');
|
|
12
|
+
var csvWriterBrowser = require('csv-writer-browser');
|
|
13
|
+
var fastStringify = require('fast-stringify');
|
|
14
|
+
var React = require('react');
|
|
15
|
+
var common = require('../common-e1d76791.cjs.js');
|
|
16
|
+
var fieldReactUtils = require('../field-react-utils-c717ec94.cjs.js');
|
|
17
|
+
require('@plasmicpkgs/luxon-parser');
|
|
18
|
+
require('lodash/get');
|
|
19
|
+
require('@plasmicapp/host/registerComponent');
|
|
20
|
+
require('@plasmicapp/host/registerGlobalContext');
|
|
21
|
+
require('dayjs');
|
|
22
|
+
require('dayjs/plugin/customParseFormat');
|
|
23
|
+
require('@ctrl/tinycolor');
|
|
24
|
+
|
|
25
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
26
|
+
|
|
27
|
+
var fastStringify__default = /*#__PURE__*/_interopDefault(fastStringify);
|
|
28
|
+
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
29
|
+
|
|
30
|
+
var __defProp$1 = Object.defineProperty;
|
|
31
|
+
var __defProps$1 = Object.defineProperties;
|
|
32
|
+
var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
|
|
33
|
+
var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
|
|
34
|
+
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
|
|
35
|
+
var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
|
|
36
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
37
|
+
var __spreadValues$1 = (a, b) => {
|
|
38
|
+
for (var prop in b || (b = {}))
|
|
39
|
+
if (__hasOwnProp$1.call(b, prop))
|
|
40
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
41
|
+
if (__getOwnPropSymbols$1)
|
|
42
|
+
for (var prop of __getOwnPropSymbols$1(b)) {
|
|
43
|
+
if (__propIsEnum$1.call(b, prop))
|
|
44
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
45
|
+
}
|
|
46
|
+
return a;
|
|
47
|
+
};
|
|
48
|
+
var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
|
|
49
|
+
function RichTable(props) {
|
|
50
|
+
const {
|
|
51
|
+
className,
|
|
52
|
+
data: rawData = {
|
|
53
|
+
data: [],
|
|
54
|
+
schema: {
|
|
55
|
+
id: "inferred",
|
|
56
|
+
fields: [
|
|
57
|
+
{
|
|
58
|
+
id: "id",
|
|
59
|
+
type: "string",
|
|
60
|
+
readOnly: false
|
|
61
|
+
}
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
// children,
|
|
66
|
+
pagination = true,
|
|
67
|
+
defaultSize,
|
|
68
|
+
title,
|
|
69
|
+
addHref,
|
|
70
|
+
pageSize = 10,
|
|
71
|
+
hideSearch,
|
|
72
|
+
hideDensity = true,
|
|
73
|
+
hideColumnPicker,
|
|
74
|
+
hideExports,
|
|
75
|
+
hideSelectionBar = true,
|
|
76
|
+
rowKey,
|
|
77
|
+
scopeClassName
|
|
78
|
+
} = props;
|
|
79
|
+
const normalizedData = dataSources.useNormalizedData(rawData);
|
|
80
|
+
const data = React.useMemo(() => {
|
|
81
|
+
if (!(normalizedData == null ? void 0 : normalizedData.data)) {
|
|
82
|
+
return normalizedData;
|
|
83
|
+
}
|
|
84
|
+
return __spreadProps$1(__spreadValues$1({}, normalizedData), { data: fieldReactUtils.tagDataArray(normalizedData.data) });
|
|
85
|
+
}, [normalizedData]);
|
|
86
|
+
const { columnDefinitions, normalized } = useColumnDefinitions(data, props);
|
|
87
|
+
const actionRef = React.useRef();
|
|
88
|
+
const { finalData, search, setSearch, setSortState } = fieldReactUtils.useSortedFilteredData(
|
|
89
|
+
data,
|
|
90
|
+
normalized
|
|
91
|
+
);
|
|
92
|
+
const rowSelectionProps = useRowSelectionProps(data, props);
|
|
93
|
+
const isClient = common.useIsClient();
|
|
94
|
+
if (!isClient) {
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
return /* @__PURE__ */ React__default.default.createElement("div", { className: `${className} ${scopeClassName != null ? scopeClassName : ""}` }, /* @__PURE__ */ React__default.default.createElement(utils.ErrorBoundary, { canvasEnvId: props["data-plasmic-canvas-envs"] }, /* @__PURE__ */ React__default.default.createElement(
|
|
98
|
+
proComponents.ProTable,
|
|
99
|
+
__spreadProps$1(__spreadValues$1({
|
|
100
|
+
ErrorBoundary: false,
|
|
101
|
+
rowClassName: props.onRowClick || props.canSelectRows === "click" ? "plasmic-table-row-clickable" : void 0,
|
|
102
|
+
actionRef,
|
|
103
|
+
columns: columnDefinitions,
|
|
104
|
+
onChange: (_pagination, _filters, sorter, _extra) => {
|
|
105
|
+
setSortState({ sorter });
|
|
106
|
+
},
|
|
107
|
+
style: {
|
|
108
|
+
width: "100%"
|
|
109
|
+
},
|
|
110
|
+
cardProps: {
|
|
111
|
+
ghost: true
|
|
112
|
+
}
|
|
113
|
+
}, rowSelectionProps), {
|
|
114
|
+
dataSource: finalData,
|
|
115
|
+
rowKey: fieldReactUtils.deriveRowKey(data, rowKey),
|
|
116
|
+
defaultSize,
|
|
117
|
+
editable: { type: "multiple" },
|
|
118
|
+
search: false,
|
|
119
|
+
options: {
|
|
120
|
+
setting: hideColumnPicker ? false : {
|
|
121
|
+
listsHeight: 400
|
|
122
|
+
},
|
|
123
|
+
reload: false,
|
|
124
|
+
density: !hideDensity
|
|
125
|
+
},
|
|
126
|
+
pagination: pagination ? {
|
|
127
|
+
pageSize,
|
|
128
|
+
onChange: (page) => console.log(page),
|
|
129
|
+
showSizeChanger: false
|
|
130
|
+
} : false,
|
|
131
|
+
dateFormatter: "string",
|
|
132
|
+
headerTitle: title,
|
|
133
|
+
toolbar: {
|
|
134
|
+
search: !hideSearch ? {
|
|
135
|
+
value: search,
|
|
136
|
+
onChange: (e) => setSearch(e.target.value),
|
|
137
|
+
onSearch: () => {
|
|
138
|
+
return;
|
|
139
|
+
},
|
|
140
|
+
placeholder: "Search"
|
|
141
|
+
} : void 0
|
|
142
|
+
},
|
|
143
|
+
toolBarRender: () => [
|
|
144
|
+
addHref && /* @__PURE__ */ React__default.default.createElement(
|
|
145
|
+
antd.Button,
|
|
146
|
+
{
|
|
147
|
+
key: "button",
|
|
148
|
+
icon: /* @__PURE__ */ React__default.default.createElement(icons.PlusOutlined, null),
|
|
149
|
+
type: "primary",
|
|
150
|
+
href: addHref
|
|
151
|
+
},
|
|
152
|
+
"Add"
|
|
153
|
+
),
|
|
154
|
+
!hideExports && /* @__PURE__ */ React__default.default.createElement(ExportMenu, { data })
|
|
155
|
+
].filter((x) => !!x)
|
|
156
|
+
})
|
|
157
|
+
)), /* @__PURE__ */ React__default.default.createElement(
|
|
158
|
+
"style",
|
|
159
|
+
{
|
|
160
|
+
dangerouslySetInnerHTML: {
|
|
161
|
+
__html: `
|
|
162
|
+
: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 {
|
|
163
|
+
display: none;
|
|
164
|
+
}
|
|
165
|
+
.plasmic-table-row-clickable {
|
|
166
|
+
cursor: pointer;
|
|
167
|
+
}
|
|
168
|
+
.ant-pro-table-list-toolbar-right {
|
|
169
|
+
flex-wrap: initial;
|
|
170
|
+
flex-shrink: 0;
|
|
171
|
+
}
|
|
172
|
+
.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 {
|
|
173
|
+
height: 100%;
|
|
174
|
+
}
|
|
175
|
+
.ant-pro-table .ant-spin-container {
|
|
176
|
+
height: 100%;
|
|
177
|
+
display: flex;
|
|
178
|
+
flex-direction: column;
|
|
179
|
+
}
|
|
180
|
+
.ant-pro-table .ant-table {
|
|
181
|
+
flex-grow: 1;
|
|
182
|
+
min-height: 0;
|
|
183
|
+
}
|
|
184
|
+
.ant-pro-table .ant-pagination {
|
|
185
|
+
flex-shrink: 0;
|
|
186
|
+
}
|
|
187
|
+
.ant-pro-table .ant-table-content {
|
|
188
|
+
overflow: auto !important;
|
|
189
|
+
height: 100%;
|
|
190
|
+
}
|
|
191
|
+
.ant-pro-table > .ant-pro-card > .ant-pro-card-body {
|
|
192
|
+
display: flex;
|
|
193
|
+
flex-direction: column;
|
|
194
|
+
}
|
|
195
|
+
.ant-pro-table .ant-table-wrapper {
|
|
196
|
+
flex-grow: 1;
|
|
197
|
+
min-height: 0;
|
|
198
|
+
}
|
|
199
|
+
.ant-pro-table .ant-table-thead > tr > th, .ant-pro-table .ant-table-thead > tr > td.ant-table-selection-column {
|
|
200
|
+
position: sticky;
|
|
201
|
+
top: 0;
|
|
202
|
+
z-index: 2;
|
|
203
|
+
}
|
|
204
|
+
.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 {
|
|
205
|
+
z-index: 3;
|
|
206
|
+
}
|
|
207
|
+
.ant-pro-table .ant-table-tbody > tr > td {
|
|
208
|
+
z-index: 0;
|
|
209
|
+
}
|
|
210
|
+
.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 {
|
|
211
|
+
z-index: 1;
|
|
212
|
+
}
|
|
213
|
+
${scopeClassName && hideSelectionBar ? `
|
|
214
|
+
.${scopeClassName} .ant-pro-table-alert {
|
|
215
|
+
display: none;
|
|
216
|
+
}
|
|
217
|
+
` : ""}
|
|
218
|
+
`
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
));
|
|
222
|
+
}
|
|
223
|
+
const defaultColumnConfig = () => ({
|
|
224
|
+
key: utils.mkShortId(),
|
|
225
|
+
isEditableExpr: () => false,
|
|
226
|
+
disableSorting: false,
|
|
227
|
+
sortByExpr: void 0,
|
|
228
|
+
isHidden: false,
|
|
229
|
+
formatting: {
|
|
230
|
+
styles: {},
|
|
231
|
+
align: "left",
|
|
232
|
+
freeze: "off"
|
|
233
|
+
},
|
|
234
|
+
dataType: "auto"
|
|
235
|
+
});
|
|
236
|
+
function useColumnDefinitions(data, props) {
|
|
237
|
+
const { fields, setControlContextData, rowActions } = props;
|
|
238
|
+
return React__default.default.useMemo(() => {
|
|
239
|
+
const schema = data == null ? void 0 : data.schema;
|
|
240
|
+
if (!data || !schema) {
|
|
241
|
+
return { normalized: [], columnDefinitions: [] };
|
|
242
|
+
}
|
|
243
|
+
const { mergedFields, minimalFullLengthFields } = dataSources.deriveFieldConfigs(fields != null ? fields : [], schema, (field) => __spreadValues$1(__spreadValues$1({}, defaultColumnConfig()), field && {
|
|
244
|
+
key: field.id,
|
|
245
|
+
fieldId: field.id,
|
|
246
|
+
title: field.label || field.id,
|
|
247
|
+
expr: (currentItem) => currentItem[field.id]
|
|
248
|
+
}));
|
|
249
|
+
setControlContextData == null ? void 0 : setControlContextData(__spreadProps$1(__spreadValues$1({}, data), { mergedFields, minimalFullLengthFields }));
|
|
250
|
+
const normalized = mergedFields;
|
|
251
|
+
const columnDefinitions = normalized.filter((cconfig) => !cconfig.isHidden).map((cconfig, _columnIndex, _columnsArray) => {
|
|
252
|
+
const columnDefinition = {
|
|
253
|
+
dataIndex: cconfig.fieldId,
|
|
254
|
+
title: cconfig.title,
|
|
255
|
+
// dataIndex: cconfig,
|
|
256
|
+
key: cconfig.key,
|
|
257
|
+
valueType: formatting.deriveValueType(cconfig),
|
|
258
|
+
// To come later
|
|
259
|
+
readonly: false,
|
|
260
|
+
sorter: true,
|
|
261
|
+
copyable: false,
|
|
262
|
+
ellipsis: false,
|
|
263
|
+
tip: void 0,
|
|
264
|
+
formItemProps: {
|
|
265
|
+
rules: []
|
|
266
|
+
},
|
|
267
|
+
disable: false,
|
|
268
|
+
valueEnum: void 0,
|
|
269
|
+
search: void 0,
|
|
270
|
+
hideInSearch: false,
|
|
271
|
+
renderFormItem: (_, { defaultRender }) => {
|
|
272
|
+
return defaultRender(_);
|
|
273
|
+
},
|
|
274
|
+
render: (value, record, rowIndex) => {
|
|
275
|
+
return formatting.renderValue(record, cconfig);
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
return columnDefinition;
|
|
279
|
+
});
|
|
280
|
+
const rowKey = props.rowKey;
|
|
281
|
+
if (rowActions && rowActions.length > 0) {
|
|
282
|
+
columnDefinitions.push({
|
|
283
|
+
title: "Actions",
|
|
284
|
+
valueType: "option",
|
|
285
|
+
key: "__plasmicActions",
|
|
286
|
+
fixed: "right",
|
|
287
|
+
className: props.themeResetClassName,
|
|
288
|
+
render: (_text, row) => [
|
|
289
|
+
...fieldReactUtils.renderActions(rowActions, row, data, rowKey)
|
|
290
|
+
]
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
return { normalized, columnDefinitions };
|
|
294
|
+
}, [fields, data, setControlContextData, rowActions]);
|
|
295
|
+
}
|
|
296
|
+
function useRowSelectionProps(data, props) {
|
|
297
|
+
const {
|
|
298
|
+
canSelectRows,
|
|
299
|
+
selectedRowKey,
|
|
300
|
+
selectedRowKeys,
|
|
301
|
+
onRowSelectionChanged,
|
|
302
|
+
rowKey,
|
|
303
|
+
onRowClick
|
|
304
|
+
} = props;
|
|
305
|
+
const deriveSelectedRowKeys = () => {
|
|
306
|
+
if (!canSelectRows || canSelectRows === "none" || !fieldReactUtils.deriveRowKey(data, rowKey)) {
|
|
307
|
+
return [];
|
|
308
|
+
}
|
|
309
|
+
if (canSelectRows === "multiple") {
|
|
310
|
+
return selectedRowKeys != null ? selectedRowKeys : [];
|
|
311
|
+
} else if (selectedRowKey) {
|
|
312
|
+
return [selectedRowKey];
|
|
313
|
+
} else {
|
|
314
|
+
return [];
|
|
315
|
+
}
|
|
316
|
+
};
|
|
317
|
+
const rowSelection = canSelectRows && canSelectRows !== "none" ? __spreadValues$1({
|
|
318
|
+
type: canSelectRows === "single" || canSelectRows === "click" ? "radio" : "checkbox",
|
|
319
|
+
selectedRowKeys: deriveSelectedRowKeys(),
|
|
320
|
+
onChange: (rowKeys, rows) => {
|
|
321
|
+
onRowSelectionChanged == null ? void 0 : onRowSelectionChanged(rowKeys, rows);
|
|
322
|
+
},
|
|
323
|
+
alwaysShowAlert: true
|
|
324
|
+
}, canSelectRows === "click" && {
|
|
325
|
+
renderCell: () => null,
|
|
326
|
+
columnWidth: 0,
|
|
327
|
+
columnTitle: null,
|
|
328
|
+
hideSelectAll: true
|
|
329
|
+
}) : void 0;
|
|
330
|
+
return {
|
|
331
|
+
rowSelection,
|
|
332
|
+
onRow: (row) => ({
|
|
333
|
+
onClick: (event) => {
|
|
334
|
+
const key = fieldReactUtils.deriveKeyOfRow(row, fieldReactUtils.deriveRowKey(data, rowKey));
|
|
335
|
+
if (key != null && !utils.isInteractable(event.target)) {
|
|
336
|
+
if (canSelectRows === "click") {
|
|
337
|
+
onRowSelectionChanged == null ? void 0 : onRowSelectionChanged([key], [row]);
|
|
338
|
+
}
|
|
339
|
+
onRowClick == null ? void 0 : onRowClick(key, row, event);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
})
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
function ExportMenu(props) {
|
|
346
|
+
const { data } = props;
|
|
347
|
+
return /* @__PURE__ */ React__default.default.createElement(
|
|
348
|
+
antd.Dropdown,
|
|
349
|
+
{
|
|
350
|
+
key: "menu",
|
|
351
|
+
menu: {
|
|
352
|
+
items: [
|
|
353
|
+
{
|
|
354
|
+
label: "Download as CSV",
|
|
355
|
+
key: "csv",
|
|
356
|
+
onClick: async () => {
|
|
357
|
+
var _a, _b;
|
|
358
|
+
const writer = csvWriterBrowser.createObjectCsvStringifier({
|
|
359
|
+
header: (_b = (_a = data == null ? void 0 : data.schema) == null ? void 0 : _a.fields.map((f) => ({
|
|
360
|
+
id: f.id,
|
|
361
|
+
title: f.id
|
|
362
|
+
}))) != null ? _b : []
|
|
363
|
+
});
|
|
364
|
+
const dataStr = writer.getHeaderString() + writer.stringifyRecords(data == null ? void 0 : data.data);
|
|
365
|
+
const filename = "data.csv";
|
|
366
|
+
const blob = new Blob([dataStr], {
|
|
367
|
+
type: "text/csv;charset=utf-8;"
|
|
368
|
+
});
|
|
369
|
+
if (navigator.msSaveBlob) {
|
|
370
|
+
navigator.msSaveBlob(blob, filename);
|
|
371
|
+
} else {
|
|
372
|
+
const link = document.createElement("a");
|
|
373
|
+
if (link.download !== void 0) {
|
|
374
|
+
const url = URL.createObjectURL(blob);
|
|
375
|
+
link.setAttribute("href", url);
|
|
376
|
+
link.setAttribute("download", filename);
|
|
377
|
+
link.style.visibility = "hidden";
|
|
378
|
+
document.body.appendChild(link);
|
|
379
|
+
link.click();
|
|
380
|
+
document.body.removeChild(link);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
},
|
|
385
|
+
{
|
|
386
|
+
label: "Download as JSON",
|
|
387
|
+
key: "json",
|
|
388
|
+
onClick: () => {
|
|
389
|
+
const dataStr = fastStringify__default.default(data == null ? void 0 : data.data);
|
|
390
|
+
const dataUri = `data:application/json;charset=utf-8, ${encodeURIComponent(
|
|
391
|
+
dataStr
|
|
392
|
+
)}`;
|
|
393
|
+
const exportFileDefaultName = "data.json";
|
|
394
|
+
const linkElement = document.createElement("a");
|
|
395
|
+
linkElement.setAttribute("href", dataUri);
|
|
396
|
+
linkElement.setAttribute("download", exportFileDefaultName);
|
|
397
|
+
linkElement.click();
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
]
|
|
401
|
+
}
|
|
402
|
+
},
|
|
403
|
+
/* @__PURE__ */ React__default.default.createElement(antd.Button, null, /* @__PURE__ */ React__default.default.createElement(icons.EllipsisOutlined, null))
|
|
404
|
+
);
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
var __defProp = Object.defineProperty;
|
|
408
|
+
var __defProps = Object.defineProperties;
|
|
409
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
410
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
411
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
412
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
413
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
414
|
+
var __spreadValues = (a, b) => {
|
|
415
|
+
for (var prop in b || (b = {}))
|
|
416
|
+
if (__hasOwnProp.call(b, prop))
|
|
417
|
+
__defNormalProp(a, prop, b[prop]);
|
|
418
|
+
if (__getOwnPropSymbols)
|
|
419
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
420
|
+
if (__propIsEnum.call(b, prop))
|
|
421
|
+
__defNormalProp(a, prop, b[prop]);
|
|
422
|
+
}
|
|
423
|
+
return a;
|
|
424
|
+
};
|
|
425
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
426
|
+
const tableHelpers = {
|
|
427
|
+
states: {
|
|
428
|
+
selectedRow: {
|
|
429
|
+
onChangeArgsToValue: (rowKeys, rows) => {
|
|
430
|
+
return rows[0];
|
|
431
|
+
}
|
|
432
|
+
},
|
|
433
|
+
selectedRows: {
|
|
434
|
+
onChangeArgsToValue: (rowKeys, rows) => {
|
|
435
|
+
return rows;
|
|
436
|
+
}
|
|
437
|
+
},
|
|
438
|
+
selectedRowKey: {
|
|
439
|
+
onChangeArgsToValue: (rowKeys, rows) => {
|
|
440
|
+
return rowKeys[0];
|
|
441
|
+
}
|
|
442
|
+
},
|
|
443
|
+
selectedRowKeys: {
|
|
444
|
+
onChangeArgsToValue: (rowKeys, rows) => {
|
|
445
|
+
return rowKeys;
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
};
|
|
450
|
+
const dataTableMeta = {
|
|
451
|
+
name: "hostless-rich-table",
|
|
452
|
+
displayName: "Table",
|
|
453
|
+
defaultStyles: {
|
|
454
|
+
width: "stretch",
|
|
455
|
+
padding: "16px",
|
|
456
|
+
maxHeight: "100%"
|
|
457
|
+
},
|
|
458
|
+
props: __spreadProps(__spreadValues({
|
|
459
|
+
data: commonPropTypes.dataProp(),
|
|
460
|
+
fields: formatting.buildFieldsPropType({}),
|
|
461
|
+
canSelectRows: {
|
|
462
|
+
type: "choice",
|
|
463
|
+
displayName: "Select rows?",
|
|
464
|
+
options: [
|
|
465
|
+
{ label: "No", value: "none" },
|
|
466
|
+
{ label: "By clicking a row", value: "click" },
|
|
467
|
+
{ label: "Using radio buttons", value: "single" },
|
|
468
|
+
{ label: "Using checkboxes", value: "multiple" }
|
|
469
|
+
],
|
|
470
|
+
defaultValueHint: "none",
|
|
471
|
+
description: "Lets user select table rows by clicking on a row, or using radio buttons, or checkboxes if multiple rows can be selected together. If you have interactive elements in your row and you don't want clicking on them to select the row, you may use radio buttons instead."
|
|
472
|
+
},
|
|
473
|
+
rowKey: {
|
|
474
|
+
type: "string",
|
|
475
|
+
displayName: "Row key",
|
|
476
|
+
helpText: "Column key to use as row key; can also be a function that takes in a row and returns a key value",
|
|
477
|
+
hidden: (ps) => !ps.canSelectRows || ps.canSelectRows === "none"
|
|
478
|
+
},
|
|
479
|
+
selectedRowKey: {
|
|
480
|
+
type: "string",
|
|
481
|
+
displayName: "Selected Row Key",
|
|
482
|
+
hidden: (ps) => ps.canSelectRows !== "single" && ps.canSelectRows !== "click",
|
|
483
|
+
advanced: true
|
|
484
|
+
},
|
|
485
|
+
selectedRowKeys: {
|
|
486
|
+
type: "array",
|
|
487
|
+
displayName: "Selected Row Keys",
|
|
488
|
+
hidden: (ps) => ps.canSelectRows !== "multiple",
|
|
489
|
+
advanced: true
|
|
490
|
+
},
|
|
491
|
+
onRowSelectionChanged: {
|
|
492
|
+
type: "eventHandler",
|
|
493
|
+
displayName: "On row selection changed",
|
|
494
|
+
argTypes: [
|
|
495
|
+
{ name: "rowKeys", type: "object" },
|
|
496
|
+
{ name: "rows", type: "object" }
|
|
497
|
+
]
|
|
498
|
+
},
|
|
499
|
+
onRowClick: commonPropTypes.onRowClickProp(),
|
|
500
|
+
rowActions: commonPropTypes.rowActionsProp(),
|
|
501
|
+
defaultSize: {
|
|
502
|
+
displayName: "Density",
|
|
503
|
+
type: "choice",
|
|
504
|
+
options: [
|
|
505
|
+
{
|
|
506
|
+
value: "large",
|
|
507
|
+
label: "Larger"
|
|
508
|
+
},
|
|
509
|
+
{
|
|
510
|
+
value: "middle",
|
|
511
|
+
label: "Medium"
|
|
512
|
+
},
|
|
513
|
+
{
|
|
514
|
+
value: "small",
|
|
515
|
+
label: "Compact"
|
|
516
|
+
}
|
|
517
|
+
],
|
|
518
|
+
defaultValueHint: "large",
|
|
519
|
+
advanced: true
|
|
520
|
+
}
|
|
521
|
+
}, commonPropTypes.commonProps()), {
|
|
522
|
+
hideExports: {
|
|
523
|
+
type: "boolean",
|
|
524
|
+
description: "Hides the button for exporting table data to CSV",
|
|
525
|
+
advanced: true
|
|
526
|
+
},
|
|
527
|
+
hideDensity: {
|
|
528
|
+
type: "boolean",
|
|
529
|
+
description: "Hides the control for changing the density of the table",
|
|
530
|
+
advanced: true,
|
|
531
|
+
defaultValueHint: true
|
|
532
|
+
},
|
|
533
|
+
hideColumnPicker: {
|
|
534
|
+
type: "boolean",
|
|
535
|
+
description: "Hides the control for reordering and pinning columns",
|
|
536
|
+
advanced: true
|
|
537
|
+
},
|
|
538
|
+
hideSelectionBar: {
|
|
539
|
+
type: "boolean",
|
|
540
|
+
description: "Hides the toolbar that allows the user to clear selection",
|
|
541
|
+
advanced: true,
|
|
542
|
+
hidden: (ps) => !ps.canSelectRows || ps.canSelectRows === "none",
|
|
543
|
+
defaultValueHint: true
|
|
544
|
+
},
|
|
545
|
+
scopeClassName: {
|
|
546
|
+
type: "styleScopeClass",
|
|
547
|
+
scopeName: "instance"
|
|
548
|
+
},
|
|
549
|
+
themeResetClassName: {
|
|
550
|
+
type: "themeResetClass",
|
|
551
|
+
targetAllTags: true
|
|
552
|
+
}
|
|
553
|
+
}),
|
|
554
|
+
states: {
|
|
555
|
+
selectedRowKey: __spreadValues({
|
|
556
|
+
type: "writable",
|
|
557
|
+
valueProp: "selectedRowKey",
|
|
558
|
+
onChangeProp: "onRowSelectionChanged",
|
|
559
|
+
variableType: "text",
|
|
560
|
+
hidden: (ps) => !(ps.canSelectRows === "click" || ps.canSelectRows === "single")
|
|
561
|
+
}, tableHelpers.states.selectedRowKey),
|
|
562
|
+
selectedRowKeys: __spreadValues({
|
|
563
|
+
type: "writable",
|
|
564
|
+
valueProp: "selectedRowKeys",
|
|
565
|
+
onChangeProp: "onRowSelectionChanged",
|
|
566
|
+
variableType: "array",
|
|
567
|
+
hidden: (ps) => !(ps.canSelectRows === "multiple")
|
|
568
|
+
}, tableHelpers.states.selectedRowKeys),
|
|
569
|
+
selectedRow: __spreadValues({
|
|
570
|
+
type: "readonly",
|
|
571
|
+
onChangeProp: "onRowSelectionChanged",
|
|
572
|
+
variableType: "object",
|
|
573
|
+
hidden: (ps) => !(ps.canSelectRows === "click" || ps.canSelectRows === "single")
|
|
574
|
+
}, tableHelpers.states.selectedRow),
|
|
575
|
+
selectedRows: __spreadValues({
|
|
576
|
+
type: "readonly",
|
|
577
|
+
onChangeProp: "onRowSelectionChanged",
|
|
578
|
+
variableType: "array",
|
|
579
|
+
hidden: (ps) => !(ps.canSelectRows === "multiple")
|
|
580
|
+
}, tableHelpers.states.selectedRows)
|
|
581
|
+
},
|
|
582
|
+
componentHelpers: {
|
|
583
|
+
helpers: tableHelpers,
|
|
584
|
+
importName: "tableHelpers",
|
|
585
|
+
importPath: "@plasmicpkgs/plasmic-rich-components/skinny/rich-table"
|
|
586
|
+
},
|
|
587
|
+
importName: "RichTable",
|
|
588
|
+
importPath: "@plasmicpkgs/plasmic-rich-components/skinny/rich-table"
|
|
589
|
+
};
|
|
590
|
+
function registerRichTable(loader) {
|
|
591
|
+
utils.registerComponentHelper(loader, RichTable, dataTableMeta);
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
exports.RichTable = RichTable;
|
|
595
|
+
exports.default = RichTable;
|
|
596
|
+
exports.registerRichTable = registerRichTable;
|
|
597
|
+
exports.tableHelpers = tableHelpers;
|
|
598
|
+
//# sourceMappingURL=index.cjs.js.map
|