@kne/table-page 0.1.5 → 0.1.7

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,31 +1,30 @@
1
+ import '@kne/table-view/dist/index.css';
1
2
  import { withFetch } from '@kne/react-fetch';
2
- import { Typography, Tooltip, Tag, Space, Badge, Checkbox, Row, Col, Input, List, Button, Collapse, Popover, Empty, Table as Table$1, Dropdown, Pagination } from 'antd';
3
+ import { Checkbox, Row, Col, Input, List, Tooltip, Button, Collapse, Popover, Empty, Table as Table$1, Dropdown, Pagination } from 'antd';
3
4
  import { FilterProvider, FilterLines, SearchInput, FilterValueDisplay, getFilterValue } from '@kne/react-filter';
4
- import { useState, useCallback, useMemo, useRef, useEffect, useLayoutEffect, forwardRef } from 'react';
5
+ import { useState, useMemo, useRef, useCallback, useEffect, useLayoutEffect, forwardRef } from 'react';
5
6
  import classnames from 'classnames';
6
7
  import get from 'lodash/get';
8
+ import { isOptionsColumn, parseColumnWidth, resolveColumns, useSelectedRow, useSort, wrapColumnHeaderTitle, renderColumnTitle, getColumnEllipsis, computeColumnsValue, renderCellContent, computeDisplay, TableView } from '@kne/table-view';
9
+ export { RENDER_TYPE_NAMES, SIZE_NAMES, TableView, calcArgs, computeColumnsDisplay, computeColumnsValue, computeDisplay, defaultFormat, formatView, getColumnEllipsis, getColumnLayout, getColumnRender, getGridTemplateColumns, getRenderTypeDimensions, getRenderTypeNames, getStatusType, getTagColor, globalParams, hasColumnSpan, hasColumnWidth, isOptionsColumn, parseColumnWidth, parseRenderType, preset, renderCellContent, renderStatusItem, renderTagItem, renderTagList, resolveColumn, resolveColumnDimensions, resolveColumns, resolveRenderType, sortDataSource, useSelectedRow, useSort, wrapColumnHeaderTitle } from '@kne/table-view';
7
10
  import { isEmpty } from '@kne/is-empty';
8
- import groupBy from 'lodash/groupBy';
9
- import transform from 'lodash/transform';
10
- import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
11
- import ButtonGroup from '@kne/button-group';
12
- import '@kne/button-group/dist/index.css';
13
- import { CaretUpOutlined, CaretDownOutlined, HolderOutlined, RedoOutlined, SettingOutlined, CheckOutlined, DownOutlined } from '@ant-design/icons';
14
- import clone from 'lodash/clone';
11
+ import viewStyle from '@kne/table-view/src/TableView/style.module.scss';
15
12
  import useRefCallback from '@kne/use-ref-callback';
13
+ import transform from 'lodash/transform';
16
14
  import pick from 'lodash/pick';
17
15
  import findLastIndex from 'lodash/findLastIndex';
18
16
  import isEqual from 'lodash/isEqual';
17
+ import { HolderOutlined, RedoOutlined, SettingOutlined, DownOutlined } from '@ant-design/icons';
19
18
  import { useDebouncedCallback } from 'use-debounce';
19
+ import groupBy from 'lodash/groupBy';
20
20
  import { ReactSortable } from 'react-sortablejs';
21
- import set from 'lodash/set';
22
21
  import cloneDeep from 'lodash/cloneDeep';
23
22
  import { createWithIntlProvider, useIntl } from '@kne/react-intl';
24
23
  import filterZhCN from '@kne/react-filter/dist/locale/zh-CN';
25
24
  import filterEnUS from '@kne/react-filter/dist/locale/en-US';
25
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
26
26
  import { createPortal } from 'react-dom';
27
27
  import '@kne/react-filter/dist/index.css';
28
- import merge from 'lodash/merge';
29
28
 
30
29
  function _extends() {
31
30
  return _extends = Object.assign ? Object.assign.bind() : function (n) {
@@ -46,1295 +45,21 @@ function _objectWithoutPropertiesLoose(r, e) {
46
45
  return t;
47
46
  }
48
47
 
49
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
50
-
51
- function createCommonjsModule(fn) {
52
- var module = { exports: {} };
53
- return fn(module, module.exports), module.exports;
54
- }
55
-
56
- var dayjs_min = createCommonjsModule(function (module, exports) {
57
- !function(t,e){module.exports=e();}(commonjsGlobal,(function(){var t=1e3,e=6e4,n=36e5,r="millisecond",i="second",s="minute",u="hour",a="day",o="week",c="month",f="quarter",h="year",d="date",l="Invalid Date",$=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,y=/\[([^\]]+)]|YYYY|YY|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,M={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(t){var e=["th","st","nd","rd"],n=t%100;return "["+t+(e[(n-20)%10]||e[n]||e[0])+"]"}},m=function(t,e,n){var r=String(t);return !r||r.length>=e?t:""+Array(e+1-r.length).join(n)+t},v={s:m,z:function(t){var e=-t.utcOffset(),n=Math.abs(e),r=Math.floor(n/60),i=n%60;return (e<=0?"+":"-")+m(r,2,"0")+":"+m(i,2,"0")},m:function t(e,n){if(e.date()<n.date())return -t(n,e);var r=12*(n.year()-e.year())+(n.month()-e.month()),i=e.clone().add(r,c),s=n-i<0,u=e.clone().add(r+(s?-1:1),c);return +(-(r+(n-i)/(s?i-u:u-i))||0)},a:function(t){return t<0?Math.ceil(t)||0:Math.floor(t)},p:function(t){return {M:c,y:h,w:o,d:a,D:d,h:u,m:s,s:i,ms:r,Q:f}[t]||String(t||"").toLowerCase().replace(/s$/,"")},u:function(t){return void 0===t}},g="en",D={};D[g]=M;var p="$isDayjsObject",S=function(t){return t instanceof _||!(!t||!t[p])},w=function t(e,n,r){var i;if(!e)return g;if("string"==typeof e){var s=e.toLowerCase();D[s]&&(i=s),n&&(D[s]=n,i=s);var u=e.split("-");if(!i&&u.length>1)return t(u[0])}else {var a=e.name;D[a]=e,i=a;}return !r&&i&&(g=i),i||!r&&g},O=function(t,e){if(S(t))return t.clone();var n="object"==typeof e?e:{};return n.date=t,n.args=arguments,new _(n)},b=v;b.l=w,b.i=S,b.w=function(t,e){return O(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var _=function(){function M(t){this.$L=w(t.locale,null,!0),this.parse(t),this.$x=this.$x||t.x||{},this[p]=!0;}var m=M.prototype;return m.parse=function(t){this.$d=function(t){var e=t.date,n=t.utc;if(null===e)return new Date(NaN);if(b.u(e))return new Date;if(e instanceof Date)return new Date(e);if("string"==typeof e&&!/Z$/i.test(e)){var r=e.match($);if(r){var i=r[2]-1||0,s=(r[7]||"0").substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)}}return new Date(e)}(t),this.init();},m.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds();},m.$utils=function(){return b},m.isValid=function(){return !(this.$d.toString()===l)},m.isSame=function(t,e){var n=O(t);return this.startOf(e)<=n&&n<=this.endOf(e)},m.isAfter=function(t,e){return O(t)<this.startOf(e)},m.isBefore=function(t,e){return this.endOf(e)<O(t)},m.$g=function(t,e,n){return b.u(t)?this[e]:this.set(n,t)},m.unix=function(){return Math.floor(this.valueOf()/1e3)},m.valueOf=function(){return this.$d.getTime()},m.startOf=function(t,e){var n=this,r=!!b.u(e)||e,f=b.p(t),l=function(t,e){var i=b.w(n.$u?Date.UTC(n.$y,e,t):new Date(n.$y,e,t),n);return r?i:i.endOf(a)},$=function(t,e){return b.w(n.toDate()[t].apply(n.toDate("s"),(r?[0,0,0,0]:[23,59,59,999]).slice(e)),n)},y=this.$W,M=this.$M,m=this.$D,v="set"+(this.$u?"UTC":"");switch(f){case h:return r?l(1,0):l(31,11);case c:return r?l(1,M):l(0,M+1);case o:var g=this.$locale().weekStart||0,D=(y<g?y+7:y)-g;return l(r?m-D:m+(6-D),M);case a:case d:return $(v+"Hours",0);case u:return $(v+"Minutes",1);case s:return $(v+"Seconds",2);case i:return $(v+"Milliseconds",3);default:return this.clone()}},m.endOf=function(t){return this.startOf(t,!1)},m.$set=function(t,e){var n,o=b.p(t),f="set"+(this.$u?"UTC":""),l=(n={},n[a]=f+"Date",n[d]=f+"Date",n[c]=f+"Month",n[h]=f+"FullYear",n[u]=f+"Hours",n[s]=f+"Minutes",n[i]=f+"Seconds",n[r]=f+"Milliseconds",n)[o],$=o===a?this.$D+(e-this.$W):e;if(o===c||o===h){var y=this.clone().set(d,1);y.$d[l]($),y.init(),this.$d=y.set(d,Math.min(this.$D,y.daysInMonth())).$d;}else l&&this.$d[l]($);return this.init(),this},m.set=function(t,e){return this.clone().$set(t,e)},m.get=function(t){return this[b.p(t)]()},m.add=function(r,f){var d,l=this;r=Number(r);var $=b.p(f),y=function(t){var e=O(l);return b.w(e.date(e.date()+Math.round(t*r)),l)};if($===c)return this.set(c,this.$M+r);if($===h)return this.set(h,this.$y+r);if($===a)return y(1);if($===o)return y(7);var M=(d={},d[s]=e,d[u]=n,d[i]=t,d)[$]||1,m=this.$d.getTime()+r*M;return b.w(m,this)},m.subtract=function(t,e){return this.add(-1*t,e)},m.format=function(t){var e=this,n=this.$locale();if(!this.isValid())return n.invalidDate||l;var r=t||"YYYY-MM-DDTHH:mm:ssZ",i=b.z(this),s=this.$H,u=this.$m,a=this.$M,o=n.weekdays,c=n.months,f=n.meridiem,h=function(t,n,i,s){return t&&(t[n]||t(e,r))||i[n].slice(0,s)},d=function(t){return b.s(s%12||12,t,"0")},$=f||function(t,e,n){var r=t<12?"AM":"PM";return n?r.toLowerCase():r};return r.replace(y,(function(t,r){return r||function(t){switch(t){case"YY":return String(e.$y).slice(-2);case"YYYY":return b.s(e.$y,4,"0");case"M":return a+1;case"MM":return b.s(a+1,2,"0");case"MMM":return h(n.monthsShort,a,c,3);case"MMMM":return h(c,a);case"D":return e.$D;case"DD":return b.s(e.$D,2,"0");case"d":return String(e.$W);case"dd":return h(n.weekdaysMin,e.$W,o,2);case"ddd":return h(n.weekdaysShort,e.$W,o,3);case"dddd":return o[e.$W];case"H":return String(s);case"HH":return b.s(s,2,"0");case"h":return d(1);case"hh":return d(2);case"a":return $(s,u,!0);case"A":return $(s,u,!1);case"m":return String(u);case"mm":return b.s(u,2,"0");case"s":return String(e.$s);case"ss":return b.s(e.$s,2,"0");case"SSS":return b.s(e.$ms,3,"0");case"Z":return i}return null}(t)||i.replace(":","")}))},m.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},m.diff=function(r,d,l){var $,y=this,M=b.p(d),m=O(r),v=(m.utcOffset()-this.utcOffset())*e,g=this-m,D=function(){return b.m(y,m)};switch(M){case h:$=D()/12;break;case c:$=D();break;case f:$=D()/3;break;case o:$=(g-v)/6048e5;break;case a:$=(g-v)/864e5;break;case u:$=g/n;break;case s:$=g/e;break;case i:$=g/t;break;default:$=g;}return l?$:b.a($)},m.daysInMonth=function(){return this.endOf(c).$D},m.$locale=function(){return D[this.$L]},m.locale=function(t,e){if(!t)return this.$L;var n=this.clone(),r=w(t,e,!0);return r&&(n.$L=r),n},m.clone=function(){return b.w(this.$d,this)},m.toDate=function(){return new Date(this.valueOf())},m.toJSON=function(){return this.isValid()?this.toISOString():null},m.toISOString=function(){return this.$d.toISOString()},m.toString=function(){return this.$d.toUTCString()},M}(),Y=_.prototype;return O.prototype=Y,[["$ms",r],["$s",i],["$m",s],["$H",u],["$W",a],["$M",c],["$y",h],["$D",d]].forEach((function(t){Y[t[1]]=function(e){return this.$g(e,t[0],t[1])};})),O.extend=function(t,e){return t.$i||(t(e,_,O),t.$i=!0),O},O.locale=w,O.isDayjs=S,O.unix=function(t){return O(1e3*t)},O.en=D[g],O.Ls=D,O.p={},O}));
58
- });
59
-
60
- const calcArgs = (args, template) => {
61
- const {
62
- attr,
63
- normal
64
- } = groupBy(args, item => /^.+:.+$/.test(item) ? 'attr' : 'normal');
65
- const output = {};
66
- const typeTransform = (value, type) => {
67
- if (type === 'string') {
68
- return String(value);
69
- }
70
- if (type === 'number') {
71
- return Number(value);
72
- }
73
- if (type === 'boolean') {
74
- return value === 'true';
75
- }
76
- return value;
77
- };
78
- (normal || []).forEach((target, index) => {
79
- const currentTemplate = Object.assign({}, {
80
- type: 'string',
81
- defaultValue: ''
82
- }, get(template, index));
83
- if (currentTemplate.name && target) {
84
- output[currentTemplate.name] = typeTransform(target, currentTemplate.type);
85
- }
86
- });
87
- (attr || []).forEach(target => {
88
- const [key, value] = target.split(':');
89
- const currentTemplate = template.find(item => item.name === key);
90
- if (!currentTemplate) {
91
- return;
92
- }
93
- const {
94
- name,
95
- type
96
- } = Object.assign({}, {
97
- type: 'string',
98
- defaultValue: ''
99
- }, currentTemplate);
100
- output[name] = typeTransform(value, type);
101
- });
102
- return Object.assign({}, transform(template, (result, value) => {
103
- if (value.name && value.hasOwnProperty('defaultValue')) {
104
- result[value.name] = value.defaultValue;
105
- }
106
- }, {}), output);
107
- };
108
- const defaultFormat = {
109
- date: (value, {
110
- args
111
- }) => {
112
- const template = args[0] || 'YYYY-MM-DD';
113
- return dayjs_min(value).format(template);
114
- },
115
- datetime: (value, {
116
- args
117
- }) => {
118
- const template = args[0] || 'YYYY-MM-DD HH:mm:ss';
119
- return dayjs_min(value).format(template);
120
- },
121
- dateRange: (value, {
122
- args
123
- }) => {
124
- const template = args[0] || 'YYYY-MM-DD',
125
- allowNull = args[1];
126
- if (!isEmpty(value[0]) && !isEmpty(value[1])) {
127
- return `${dayjs_min(value[0]).format(template)}~${dayjs_min(value[1]).format(template)}`;
128
- }
129
- if (allowNull === 'allow' && !isEmpty(value[0])) {
130
- return `${dayjs_min(value[0]).format(template)}以后`;
131
- }
132
- if (allowNull === 'allow' && !isEmpty(value[1])) {
133
- return `${dayjs_min(value[1]).format(template)}以前`;
134
- }
135
- return '';
136
- },
137
- boolean: (value, {
138
- args
139
- }) => {
140
- const trueValue = args[0] || 'true';
141
- if ((value || '').toString() === trueValue) {
142
- return '是';
143
- }
144
- return '否';
145
- },
146
- number: (value, {
147
- args
148
- }) => {
149
- const {
150
- style,
151
- unit,
152
- maximumFractionDigits,
153
- useGrouping,
154
- roundingMode,
155
- suffix
156
- } = calcArgs(args, [{
157
- name: 'style',
158
- type: 'string',
159
- defaultValue: 'decimal'
160
- }, {
161
- name: 'unit',
162
- type: 'number',
163
- defaultValue: 1
164
- }, {
165
- name: 'maximumFractionDigits',
166
- type: 'number',
167
- defaultValue: 2
168
- }, {
169
- name: 'useGrouping',
170
- type: 'boolean',
171
- defaultValue: true
172
- }, {
173
- name: 'roundingMode',
174
- type: 'string',
175
- defaultValue: 'halfExpand'
176
- }, {
177
- name: 'suffix',
178
- type: 'string',
179
- defaultValue: ''
180
- }]);
181
- return new Intl.NumberFormat({}, {
182
- style,
183
- maximumFractionDigits,
184
- roundingMode,
185
- useGrouping
186
- }).format(value / unit) + suffix;
187
- },
188
- money: (value, {
189
- args
190
- }) => {
191
- const unit = args[0] || '元';
192
- return `${value}${unit}`;
193
- }
194
- };
195
- const formatView = (value, format, context) => {
196
- if (!format) {
197
- return value;
198
- }
199
- const formatList = format.split(' ').filter(item => !!item);
200
- if (formatList.length > 0) {
201
- return formatList.reduce((value, format) => {
202
- const [name, ...args] = format.split('-');
203
- if (typeof defaultFormat[name] === 'function') {
204
- return defaultFormat[name](value, Object.assign({}, context, {
205
- args: args.map(item => {
206
- return item && item.replace(/\(\)/g, ' ').replace(/\(_\)/g, '-');
207
- })
208
- }));
209
- }
210
- return value;
211
- }, value);
212
- }
213
- };
214
-
215
- const globalParams = {
216
- renderType: null,
217
- renderTypeSize: {},
218
- tagTypeColors: {},
219
- statusTypeColors: {}
220
- };
221
-
222
- const defaultRender = value => value;
223
-
224
- var ellipsisStyle = {"ellipsis":"kne-table-page_mMMw1","tooltip":"kne-table-page_CkWQu","cell-content":"kne-table-page_OXmYu","cell-full-width":"kne-table-page_jN-vq"};
225
-
226
- const _excluded$8 = ["showTitle"];
227
- const Ellipsis = ({
228
- children,
229
- ellipsis
230
- }) => {
231
- if (!ellipsis) {
232
- return children;
233
- }
234
- const userConfig = typeof ellipsis === 'object' ? ellipsis : {};
235
- const {
236
- showTitle
237
- } = userConfig,
238
- rest = _objectWithoutPropertiesLoose(userConfig, _excluded$8);
239
- return /*#__PURE__*/jsx(Typography.Text, {
240
- className: ellipsisStyle['ellipsis'],
241
- ellipsis: Object.assign({}, {
242
- tooltip: showTitle === false ? false : {
243
- rootClassName: ellipsisStyle['tooltip']
244
- }
245
- }, rest),
246
- children: children
247
- });
248
- };
249
-
250
- var style$8 = {"text":"kne-table-page_5N2-a","ellipsis":"kne-table-page_Lkl3D","hover":"kne-table-page_RnF6d","primary":"kne-table-page_g-Sky","clickable":"kne-table-page_vPcDo","loading":"kne-table-page_FeQ09"};
251
-
252
- const MainCell = ({
253
- value,
254
- column,
255
- dataSource
256
- }) => {
257
- const {
258
- ellipsis = true,
259
- hover = true,
260
- primary = true,
261
- onClick
262
- } = column || {};
263
- const [loading, setLoading] = useState(false);
264
- const isClickable = Boolean(hover || primary || onClick);
265
- if (!isClickable) {
266
- return /*#__PURE__*/jsx(Ellipsis, {
267
- ellipsis: ellipsis,
268
- children: value
269
- });
270
- }
271
- const ellipsisConfig = typeof ellipsis === 'object' ? ellipsis : {};
272
- const showTooltip = ellipsis && ellipsisConfig.showTitle !== false;
273
- const handleClick = onClick ? e => {
274
- if (loading) {
275
- return;
276
- }
277
- setLoading(true);
278
- Promise.resolve(onClick({
279
- item: value,
280
- colItem: dataSource,
281
- event: e
282
- })).finally(() => {
283
- setLoading(false);
284
- });
285
- } : undefined;
286
- const text = /*#__PURE__*/jsx("span", {
287
- className: classnames(style$8['text'], ellipsis && style$8['ellipsis'], {
288
- [style$8['hover']]: hover,
289
- [style$8['primary']]: primary,
290
- [style$8['clickable']]: Boolean(onClick),
291
- [style$8['loading']]: loading
292
- }),
293
- onClick: handleClick,
294
- children: value
295
- });
296
- if (!showTooltip) {
297
- return text;
298
- }
299
- return /*#__PURE__*/jsx(Tooltip, {
300
- title: value,
301
- rootClassName: ellipsisStyle['tooltip'],
302
- children: text
303
- });
304
- };
305
- const main = (value, {
306
- column,
307
- dataSource
308
- } = {}) => /*#__PURE__*/jsx(MainCell, {
309
- value: value,
310
- column: column,
311
- dataSource: dataSource
312
- });
313
-
314
- var style$7 = {"amount":"kne-table-page_AH-3R"};
315
-
316
- const amount = (value, {
317
- column
318
- } = {}) => {
319
- const {
320
- ellipsis = true
321
- } = column || {};
322
- return /*#__PURE__*/jsx("span", {
323
- className: style$7['amount'],
324
- children: /*#__PURE__*/jsx(Ellipsis, {
325
- ellipsis: ellipsis,
326
- children: value
327
- })
328
- });
329
- };
330
-
331
- const _excluded$7 = ["text", "type", "color", "children"];
332
- const DEFAULT_TAG_TYPE_COLORS = {
333
- default: 'default',
334
- success: 'success',
335
- progress: 'processing',
336
- processing: 'processing',
337
- danger: 'error',
338
- error: 'error',
339
- warning: 'warning',
340
- info: 'blue',
341
- other: 'purple',
342
- skill: 'default',
343
- result: 'default',
344
- filterResult: 'cyan',
345
- completed: 'success',
346
- pending: 'warning',
347
- high: 'error',
348
- medium: 'warning',
349
- low: 'default'
350
- };
351
- const getTagColor = type => {
352
- if (!type) {
353
- return 'default';
354
- }
355
- const customColors = globalParams.tagTypeColors || {};
356
- return customColors[type] || DEFAULT_TAG_TYPE_COLORS[type] || type;
357
- };
358
- const normalizeTagItem = item => {
359
- if (item == null) {
360
- return null;
361
- }
362
- if (typeof item === 'string' || typeof item === 'number') {
363
- return {
364
- text: String(item)
365
- };
366
- }
367
- if (typeof item === 'object') {
368
- var _ref, _item$text;
369
- return Object.assign({}, item, {
370
- text: (_ref = (_item$text = item.text) != null ? _item$text : item.children) != null ? _ref : item.label
371
- });
372
- }
373
- return null;
374
- };
375
- const renderTagItem = (item, key) => {
376
- const tag = normalizeTagItem(item);
377
- if (!tag || tag.text == null && tag.children == null) {
378
- return null;
379
- }
380
- const {
381
- text,
382
- type,
383
- color,
384
- children
385
- } = tag,
386
- rest = _objectWithoutPropertiesLoose(tag, _excluded$7);
387
- return /*#__PURE__*/jsx(Tag, _extends({
388
- color: color != null ? color : getTagColor(type)
389
- }, rest, {
390
- children: children != null ? children : text
391
- }), key);
392
- };
393
- const renderTagList = value => {
394
- if (!Array.isArray(value) || value.length === 0) {
395
- return null;
396
- }
397
- return /*#__PURE__*/jsx(Space, {
398
- size: [4, 4],
399
- wrap: true,
400
- children: value.map((item, index) => renderTagItem(item, index))
401
- });
402
- };
403
-
404
- const tag = value => renderTagItem(value);
405
-
406
- const tagList = value => renderTagList(value);
407
-
408
- const _excluded$6 = ["text", "type", "status", "color", "children"];
409
- const DEFAULT_STATUS_TYPE_MAP = {
410
- default: 'default',
411
- success: 'success',
412
- progress: 'processing',
413
- processing: 'processing',
414
- danger: 'error',
415
- error: 'error',
416
- warning: 'warning',
417
- info: 'processing',
418
- other: 'default',
419
- active: 'success',
420
- vacation: 'warning',
421
- resigned: 'default',
422
- probation: 'processing',
423
- completed: 'success',
424
- pending: 'warning',
425
- shipped: 'processing',
426
- paid: 'success',
427
- cancelled: 'error'
428
- };
429
- const getStatusType = type => {
430
- if (!type) {
431
- return 'default';
432
- }
433
- const customTypes = globalParams.statusTypeColors || {};
434
- return customTypes[type] || DEFAULT_STATUS_TYPE_MAP[type] || type;
435
- };
436
- const normalizeStatusItem = item => {
437
- if (item == null) {
438
- return null;
439
- }
440
- if (typeof item === 'string' || typeof item === 'number') {
441
- return {
442
- text: String(item)
443
- };
444
- }
445
- if (typeof item === 'object') {
446
- var _ref, _item$text;
447
- return Object.assign({}, item, {
448
- text: (_ref = (_item$text = item.text) != null ? _item$text : item.children) != null ? _ref : item.label
449
- });
450
- }
451
- return null;
452
- };
453
- const renderStatusItem = item => {
454
- var _ref2;
455
- const statusItem = normalizeStatusItem(item);
456
- if (!statusItem || statusItem.text == null) {
457
- return null;
458
- }
459
- const {
460
- text,
461
- type,
462
- status,
463
- color,
464
- children
465
- } = statusItem,
466
- rest = _objectWithoutPropertiesLoose(statusItem, _excluded$6);
467
- return /*#__PURE__*/jsx(Badge, _extends({
468
- status: (_ref2 = status != null ? status : color) != null ? _ref2 : getStatusType(type),
469
- text: children != null ? children : text
470
- }, rest));
471
- };
472
-
473
- const status = value => renderStatusItem(value);
474
-
475
- const DEFAULT_SPLIT = ',';
476
- const normalizeListValue = value => {
477
- if (Array.isArray(value)) {
478
- return {
479
- items: value,
480
- split: undefined
481
- };
482
- }
483
- if (value && typeof value === 'object') {
484
- var _ref, _value$items;
485
- const items = (_ref = (_value$items = value.items) != null ? _value$items : value.list) != null ? _ref : value.value;
486
- if (Array.isArray(items)) {
487
- return {
488
- items,
489
- split: value.split
490
- };
491
- }
492
- }
493
- return null;
494
- };
495
- const getListItemText = item => {
496
- if (item == null) {
497
- return null;
498
- }
499
- if (typeof item === 'object') {
500
- var _ref2, _ref3, _item$text;
501
- return (_ref2 = (_ref3 = (_item$text = item.text) != null ? _item$text : item.label) != null ? _ref3 : item.children) != null ? _ref2 : item.value;
502
- }
503
- return item;
504
- };
505
- const list = (value, {
506
- column
507
- } = {}) => {
508
- var _ref4, _normalized$split;
509
- const normalized = normalizeListValue(value);
510
- if (!normalized) {
511
- return value == null ? null : value;
512
- }
513
- const split = (_ref4 = (_normalized$split = normalized.split) != null ? _normalized$split : column == null ? void 0 : column.split) != null ? _ref4 : DEFAULT_SPLIT;
514
- const text = normalized.items.map(getListItemText).filter(item => item != null && item !== '').join(split);
515
- return text || null;
516
- };
517
-
518
- const SELECTION_CHECKBOX_WIDTH = 48;
519
- const SELECTION_RADIO_WIDTH = 30;
520
- const DEFAULT_COLUMN_WIDTH = 300;
521
- const parseColumnWidth = width => {
522
- if (width == null) {
523
- return 0;
524
- }
525
- if (typeof width === 'number' && !Number.isNaN(width)) {
526
- return width;
527
- }
528
- if (typeof width === 'string') {
529
- const trimmed = width.trim();
530
- const pxMatch = trimmed.match(/^([\d.]+)px$/i);
531
- if (pxMatch) {
532
- return parseFloat(pxMatch[1]);
533
- }
534
- const num = parseFloat(trimmed);
535
- if (!Number.isNaN(num)) {
536
- return num;
537
- }
538
- }
539
- return 0;
540
- };
541
- const getResolvedColumnWidth = column => resolveColumnDimensions(column).width;
542
- const hasColumnSpan = column => column.span != null;
543
- const getConfiguredColumnWidthPx = column => parseColumnWidth(column.width != null ? column.width : getResolvedColumnWidth(column));
544
- const usesDefaultColumnWidth = (column, columns) => {
545
- if (hasColumnSpan(column)) {
546
- return false;
547
- }
548
- if (column.width != null) {
549
- return false;
550
- }
551
- if (getConfiguredColumnWidthPx(column) > 0) {
552
- return false;
553
- }
554
- return !columns.some(hasColumnSpan);
555
- };
556
- const hasColumnWidth = (column, columns) => {
557
- if (hasColumnSpan(column)) {
558
- return false;
559
- }
560
- if (getConfiguredColumnWidthPx(column) > 0) {
561
- return true;
562
- }
563
- return usesDefaultColumnWidth(column, columns);
564
- };
565
- const shouldLastColumnFillRemaining = columns => !columns.some(hasColumnSpan);
566
- const getColumnWidthPx = (column, colsSize = {}, columns = []) => {
567
- if (hasColumnSpan(column)) {
568
- return colsSize[column.name] || 0;
569
- }
570
- const configured = getConfiguredColumnWidthPx(column);
571
- if (configured > 0) {
572
- return configured;
573
- }
574
- if (usesDefaultColumnWidth(column, columns)) {
575
- const measured = colsSize[column.name] || 0;
576
- return Math.max(DEFAULT_COLUMN_WIDTH, measured);
577
- }
578
- return colsSize[column.name] || 0;
579
- };
580
- const formatColumnWidthPx = px => `${px}px`;
581
- const getColumnTrackSize = (column, {
582
- defaultSpan,
583
- colsSize,
584
- isLastColumn,
585
- columns
586
- } = {}) => {
587
- var _ref, _column$span;
588
- const widthPx = getColumnWidthPx(column, colsSize, columns);
589
- if (hasColumnWidth(column, columns)) {
590
- if (isLastColumn && shouldLastColumnFillRemaining(columns)) {
591
- return `minmax(${widthPx}px, 1fr)`;
592
- }
593
- return `${widthPx}px`;
594
- }
595
- if (widthPx > 0) {
596
- return `minmax(${widthPx}px, 1fr)`;
597
- }
598
- const span = (_ref = (_column$span = column.span) != null ? _column$span : defaultSpan) != null ? _ref : 1;
599
- return `minmax(0, ${span}fr)`;
600
- };
601
- const getGridTemplateColumns = (columns, {
602
- defaultSpan,
603
- colsSize,
604
- rowSelection
605
- } = {}) => {
606
- const tracks = [];
607
- const lastColumnIndex = columns.length - 1;
608
- if ((rowSelection == null ? void 0 : rowSelection.type) === 'checkbox') {
609
- tracks.push(`${SELECTION_CHECKBOX_WIDTH}px`);
610
- }
611
- columns.forEach((column, index) => {
612
- tracks.push(getColumnTrackSize(column, {
613
- defaultSpan,
614
- colsSize,
615
- isLastColumn: index === lastColumnIndex,
616
- columns
617
- }));
618
- });
619
- if ((rowSelection == null ? void 0 : rowSelection.type) === 'radio') {
620
- tracks.push(`${SELECTION_RADIO_WIDTH}px`);
621
- }
622
- return tracks.join(' ');
623
- };
624
- const getColumnLayout = (column, {
625
- defaultSpan,
626
- colsSize,
627
- isLastColumn,
628
- columns
629
- } = {}) => {
630
- const widthBased = hasColumnWidth(column, columns);
631
- const widthPx = getColumnWidthPx(column, colsSize, columns);
632
- const fillRemaining = isLastColumn && widthBased && shouldLastColumnFillRemaining(columns);
633
- return {
634
- widthBased,
635
- fillRemaining,
636
- style: {
637
- '--col-width': formatColumnWidthPx(widthPx),
638
- '--col-align': column.align || 'top',
639
- '--col-justify': column.justify || 'flex-start'
640
- }
641
- };
642
- };
643
-
644
- var style$6 = {"col-item":"kne-table-page_nL1tj","options":"kne-table-page_EwzO-","options-column":"kne-table-page_im2Lc","options-btn":"kne-table-page_SJxZl"};
645
-
646
- const _excluded$5 = ["children", "label", "text", "className"],
647
- _excluded2$3 = ["list"];
648
- const normalizeOptionItem = (item, buttonClassName) => {
649
- var _ref;
650
- if (item == null) {
651
- return null;
652
- }
653
- if (typeof item === 'function') {
654
- return item;
655
- }
656
- if (typeof item === 'string') {
657
- return {
658
- children: item,
659
- type: 'link',
660
- className: buttonClassName
661
- };
662
- }
663
- const {
664
- children,
665
- label,
666
- text,
667
- className
668
- } = item,
669
- rest = _objectWithoutPropertiesLoose(item, _excluded$5);
670
- return _extends({
671
- type: 'link'
672
- }, rest, {
673
- className: classnames(buttonClassName, className),
674
- children: (_ref = children != null ? children : label) != null ? _ref : text
675
- });
676
- };
677
- const options = (value, {
678
- column
679
- } = {}) => {
680
- let list = value;
681
- let buttonGroupProps = (column == null ? void 0 : column.buttonGroup) || {};
682
- if (value && typeof value === 'object' && !Array.isArray(value) && Array.isArray(value.list)) {
683
- const {
684
- list: valueList
685
- } = value,
686
- rest = _objectWithoutPropertiesLoose(value, _excluded2$3);
687
- list = valueList;
688
- buttonGroupProps = _extends({}, buttonGroupProps, rest);
689
- }
690
- if (!Array.isArray(list) || list.length === 0) {
691
- return null;
692
- }
693
- const wrapperClassName = classnames(style$6['col-item'], style$6['options']);
694
- const buttonClassName = classnames(wrapperClassName, style$6['options-btn']);
695
- const normalizedList = list.map(item => normalizeOptionItem(item, buttonClassName)).filter(item => item != null && !item.hidden);
696
- if (normalizedList.length === 0) {
697
- return null;
698
- }
699
- const width = parseColumnWidth(column == null ? void 0 : column.width);
700
- return /*#__PURE__*/jsx("div", {
701
- className: classnames(wrapperClassName, style$6['options-column']),
702
- style: width > 0 ? {
703
- '--max-width': `${width}px`
704
- } : undefined,
705
- children: /*#__PURE__*/jsx(ButtonGroup, _extends({
706
- moreType: "link",
707
- itemClassName: "btn-no-padding",
708
- list: normalizedList
709
- }, buttonGroupProps))
710
- });
711
- };
712
-
713
- const enumRender = value => tag(value);
714
-
715
- const description = value => value;
716
-
717
- const renderType = {
718
- default: defaultRender,
719
- main,
720
- amount,
721
- tag,
722
- tagList,
723
- status,
724
- list,
725
- options,
726
- enum: enumRender,
727
- description
728
- };
729
- globalParams.renderType = renderType;
730
-
731
- const _excluded$4 = ["default"];
732
- const SIZE_NAMES = ['short', 'small', 'large'];
733
- const typeSize = {
734
- main: {
735
- width: 300,
736
- min: 160,
737
- max: 500,
738
- ellipsis: true
739
- },
740
- amount: {
741
- width: 140,
742
- min: 100,
743
- max: 300,
744
- ellipsis: true
745
- },
746
- options: {
747
- width: 180,
748
- min: 120,
749
- max: 400
750
- },
751
- enum: {
752
- width: 140,
753
- min: 100,
754
- max: 400
755
- },
756
- tag: {
757
- width: 140,
758
- min: 100,
759
- max: 400
760
- },
761
- status: {
762
- width: 100,
763
- min: 80,
764
- max: 140
765
- },
766
- tagList: {
767
- width: 300,
768
- min: 160,
769
- max: 500
770
- },
771
- list: {
772
- width: 200,
773
- min: 120,
774
- max: 400,
775
- ellipsis: true
776
- },
777
- description: {
778
- width: 400,
779
- min: 160,
780
- max: 600,
781
- ellipsis: true
782
- }
783
- };
784
- const SIZE_CONFIG = {
785
- short: {
786
- width: 120,
787
- min: 100,
788
- max: 400
789
- },
790
- small: {
791
- width: 100,
792
- min: 70,
793
- max: 400
794
- },
795
- default: {
796
- width: 300,
797
- min: 160,
798
- max: 500
799
- },
800
- large: {
801
- width: 300,
802
- min: 120,
803
- max: 500
804
- }
805
- };
806
- const getRenderTypeRegistry = () => {
807
- const _ref = globalParams.renderType || {},
808
- {
809
- default: defaultRender
810
- } = _ref,
811
- renderers = _objectWithoutPropertiesLoose(_ref, _excluded$4);
812
- return {
813
- defaultRender,
814
- renderers
815
- };
816
- };
817
- const getRenderTypeNames = () => Object.keys(getRenderTypeRegistry().renderers);
818
- const RENDER_TYPE_NAMES = getRenderTypeNames();
819
- const getRender = type => {
820
- const {
821
- defaultRender,
822
- renderers
823
- } = getRenderTypeRegistry();
824
- return renderers[type] || defaultRender;
825
- };
826
- const getColumnRender = column => {
827
- if (typeof (column == null ? void 0 : column.render) === 'function') {
828
- return column.render;
829
- }
830
- const {
831
- type
832
- } = parseRenderType(column == null ? void 0 : column.renderType);
833
- if (!type) {
834
- return null;
835
- }
836
- return getRender(type);
837
- };
838
- const getTypeConfigMap = () => {
839
- const extraTypeSize = globalParams.renderTypeSize || {};
840
- return getRenderTypeNames().reduce((result, key) => {
841
- result[key] = Object.assign({}, typeSize[key], extraTypeSize[key], {
842
- render: getRender(key)
843
- });
844
- return result;
845
- }, {});
846
- };
847
- const pickDimension = (columnValue, typeValue, sizeValue) => {
848
- if (columnValue != null) {
849
- return columnValue;
850
- }
851
- if (sizeValue != null) {
852
- return sizeValue;
853
- }
854
- if (typeValue != null) {
855
- return typeValue;
856
- }
857
- return undefined;
858
- };
859
- const parseRenderType = renderTypeValue => {
860
- if (!renderTypeValue || typeof renderTypeValue !== 'string') {
861
- return {
862
- type: null,
863
- size: null
864
- };
865
- }
866
- const renderTypeNames = getRenderTypeNames();
867
- let type = null;
868
- let size = null;
869
- renderTypeValue.split('-').forEach(part => {
870
- if (!part) {
871
- return;
872
- }
873
- if (renderTypeNames.includes(part)) {
874
- type = part;
875
- return;
876
- }
877
- if (SIZE_NAMES.includes(part)) {
878
- size = part;
879
- }
880
- });
881
- return {
882
- type,
883
- size
884
- };
885
- };
886
- const getRenderTypeDimensions = renderTypeValue => {
887
- const {
888
- type,
889
- size
890
- } = parseRenderType(renderTypeValue);
891
- const typeConfigMap = getTypeConfigMap();
892
- const typeConfig = type ? typeConfigMap[type] : null;
893
- const sizeConfig = size ? SIZE_CONFIG[size] : null;
894
- if (!typeConfig && !sizeConfig) {
895
- return null;
896
- }
897
- return {
898
- type,
899
- size,
900
- typeConfig,
901
- sizeConfig,
902
- render: typeConfig == null ? void 0 : typeConfig.render,
903
- ellipsis: typeConfig == null ? void 0 : typeConfig.ellipsis
904
- };
905
- };
906
- const resolveColumnDimensions = column => {
907
- const renderTypeDimensions = column != null && column.renderType ? getRenderTypeDimensions(column.renderType) : null;
908
- const typeConfig = renderTypeDimensions == null ? void 0 : renderTypeDimensions.typeConfig;
909
- const sizeConfig = renderTypeDimensions == null ? void 0 : renderTypeDimensions.sizeConfig;
910
- return {
911
- width: pickDimension(column == null ? void 0 : column.width, typeConfig == null ? void 0 : typeConfig.width, sizeConfig == null ? void 0 : sizeConfig.width),
912
- min: pickDimension(column == null ? void 0 : column.min, typeConfig == null ? void 0 : typeConfig.min, sizeConfig == null ? void 0 : sizeConfig.min),
913
- max: pickDimension(column == null ? void 0 : column.max, typeConfig == null ? void 0 : typeConfig.max, sizeConfig == null ? void 0 : sizeConfig.max)
914
- };
915
- };
916
- const resolveRenderType = renderTypeValue => {
917
- var _sizeConfig$width, _sizeConfig$min, _sizeConfig$max;
918
- const renderTypeDimensions = getRenderTypeDimensions(renderTypeValue);
919
- if (!renderTypeDimensions) {
920
- return null;
921
- }
922
- const {
923
- type,
924
- size,
925
- render,
926
- ellipsis,
927
- typeConfig,
928
- sizeConfig
929
- } = renderTypeDimensions;
930
- return {
931
- type,
932
- size,
933
- render,
934
- ellipsis,
935
- width: (_sizeConfig$width = sizeConfig == null ? void 0 : sizeConfig.width) != null ? _sizeConfig$width : typeConfig == null ? void 0 : typeConfig.width,
936
- min: (_sizeConfig$min = sizeConfig == null ? void 0 : sizeConfig.min) != null ? _sizeConfig$min : typeConfig == null ? void 0 : typeConfig.min,
937
- max: (_sizeConfig$max = sizeConfig == null ? void 0 : sizeConfig.max) != null ? _sizeConfig$max : typeConfig == null ? void 0 : typeConfig.max
938
- };
939
- };
940
- const ELLIPSIS_HANDLED_TYPES = ['main', 'amount'];
941
- const FULL_WIDTH_CELL_TYPES = ['options'];
942
- const resolveColumn = column => {
943
- if (!column) {
944
- return column;
945
- }
946
- const renderTypeDimensions = column.renderType ? getRenderTypeDimensions(column.renderType) : null;
947
- const {
948
- width,
949
- min,
950
- max
951
- } = resolveColumnDimensions(column);
952
- const {
953
- ellipsis,
954
- type
955
- } = renderTypeDimensions || {};
956
- const renderFn = getColumnRender(column);
957
- return Object.assign({}, column, _extends({}, renderFn && typeof column.render !== 'function' ? {
958
- render: renderFn
959
- } : {}, column.width == null && width != null ? {
960
- width
961
- } : {}, column.min == null && min != null ? {
962
- min
963
- } : {}, column.max == null && max != null ? {
964
- max
965
- } : {}, column.ellipsis == null && ellipsis != null ? {
966
- ellipsis
967
- } : {}, type && ELLIPSIS_HANDLED_TYPES.includes(type) ? {
968
- ellipsisHandledByRender: true
969
- } : {}, type && FULL_WIDTH_CELL_TYPES.includes(type) ? {
970
- cellFullWidth: true
971
- } : {}, column.type === 'options' && !type ? {
972
- cellFullWidth: true
973
- } : {}, type === 'options' && column.type !== 'options' ? {
974
- type: 'options'
975
- } : {}));
976
- };
977
- const resolveColumns = columns => (columns || []).map(resolveColumn);
978
- const isOptionsColumn = column => {
979
- if ((column == null ? void 0 : column.type) === 'options') {
980
- return true;
981
- }
982
- return parseRenderType(column == null ? void 0 : column.renderType).type === 'options';
983
- };
984
-
985
- const computeColumnsValue = ({
986
- columns,
987
- emptyIsPlaceholder,
988
- valueIsEmpty,
989
- removeEmpty: _removeEmpty = true,
990
- dataSource,
991
- context
992
- }) => {
993
- return (output => _removeEmpty ? output.filter(item => !!item) : output)(columns.map(item => {
994
- const itemValue = typeof item.getValueOf === 'function' ? item.getValueOf(dataSource, {
995
- column: item,
996
- context
997
- }) : get(dataSource, item.name);
998
- const displayValue = (value => {
999
- if (typeof item.format === 'function') {
1000
- return item.format(value, {
1001
- dataSource,
1002
- column: item,
1003
- context
1004
- });
1005
- }
1006
- if (typeof item.format === 'string') {
1007
- const formatValue = formatView(value, item.format, {
1008
- dataSource,
1009
- column: item,
1010
- context
1011
- });
1012
- if (formatValue) {
1013
- return formatValue;
1014
- }
1015
- }
1016
- return value;
1017
- })(itemValue);
1018
- const itemIsEmpty = (item.valueIsEmpty || valueIsEmpty)(itemValue);
1019
- if (item.display === false || typeof item.display === 'function' && item.display(itemValue, {
1020
- dataSource,
1021
- column: item,
1022
- context
1023
- }) === false) {
1024
- return null;
1025
- }
1026
- if (!(item.hasOwnProperty('emptyIsPlaceholder') ? item.emptyIsPlaceholder : emptyIsPlaceholder) && itemIsEmpty) {
1027
- return null;
1028
- }
1029
- return Object.assign({}, item, {
1030
- isEmpty: itemIsEmpty,
1031
- value: displayValue
1032
- });
1033
- }));
1034
- };
1035
- const computeDisplay = ({
1036
- column,
1037
- dataSource,
1038
- placeholder,
1039
- context
1040
- }) => {
1041
- if (column.isEmpty) {
1042
- return typeof column.renderPlaceholder === 'function' ? column.renderPlaceholder({
1043
- column: column,
1044
- dataSource,
1045
- placeholder,
1046
- context
1047
- }) : column.placeholder || placeholder;
1048
- }
1049
- const render = getColumnRender(column);
1050
- return typeof render === 'function' ? render(column.value, {
1051
- column,
1052
- dataSource,
1053
- context
1054
- }) : column.value;
1055
- };
1056
- const computeColumnsDisplay = ({
1057
- columns,
1058
- emptyIsPlaceholder,
1059
- valueIsEmpty,
1060
- removeEmpty,
1061
- dataSource,
1062
- placeholder,
1063
- context
1064
- }) => {
1065
- return computeColumnsValue({
1066
- columns,
1067
- emptyIsPlaceholder,
1068
- valueIsEmpty,
1069
- removeEmpty,
1070
- dataSource,
1071
- context
1072
- }).map(column => {
1073
- return computeDisplay({
1074
- column,
1075
- placeholder,
1076
- dataSource,
1077
- context
1078
- });
1079
- });
1080
- };
1081
- computeColumnsValue.computeDisplay = computeDisplay;
1082
- computeColumnsValue.computeColumnsDisplay = computeColumnsDisplay;
1083
-
1084
- var style$5 = {"table":"kne-table-page_lZgIW","header":"kne-table-page_d1qN5","col":"kne-table-page_KNy4z","tableView":"kne-table-page_fUw6j","grid":"kne-table-page_JlDmf","header-cell":"kne-table-page_P-ebv","col-content":"kne-table-page_HT5Rr","body-row":"kne-table-page_Z6mVv","body-cell":"kne-table-page_BSOzz","body":"kne-table-page_9qon1","is-selected-all":"kne-table-page_f2i1e","is-selected":"kne-table-page_n3V6m","is-disabled":"kne-table-page_AfmkR","col-width-based":"kne-table-page_ZvnDi","col-width-fill":"kne-table-page_cV7PE","single-checked":"kne-table-page_9UAoL","col-fixed":"kne-table-page_aB-1c","empty":"kne-table-page_SRI8Q"};
1085
-
1086
- var style$4 = {"table":"kne-table-page_awa1L","is-selected-all":"kne-table-page_692q3","is-selected":"kne-table-page_IWgjl","is-disabled":"kne-table-page_YUG4k","has-summary":"kne-table-page_Cb-du","has-group-header":"kne-table-page_7qTC5","is-sticky":"kne-table-page_jGzIR","is-sticky-scroll-y":"kne-table-page_P6lxG","is-sticky-viewport":"kne-table-page_Kr-p6","table-cell":"kne-table-page_HPmr3","selection-col":"kne-table-page_D7YhS","radio-col":"kne-table-page_df9z3","is-computed":"kne-table-page_ZA1Je","is-resize":"kne-table-page_CA0uL","column-resize-guide":"kne-table-page_JARA2"};
1087
-
1088
- const useSelectedRow = options => {
1089
- const {
1090
- rowKey,
1091
- type = 'checkbox'
1092
- } = Object.assign({}, {
1093
- rowKey: 'id'
1094
- }, options);
1095
- const [selectedRows, setSelectedRows] = useState([]);
1096
- const getRowId = useCallback(item => get(item, typeof rowKey === 'function' ? rowKey(item) : rowKey), [rowKey]);
1097
- const selectedRowKeys = useMemo(() => selectedRows.map(getRowId), [getRowId, selectedRows]);
1098
- const setSelectedRowKeys = useCallback((keys, dataSource = []) => {
1099
- const keySet = new Set(keys || []);
1100
- setSelectedRows((dataSource || []).filter(item => keySet.has(getRowId(item))));
1101
- }, [getRowId]);
1102
- const clearSelectedRows = useCallback(() => {
1103
- setSelectedRows([]);
1104
- }, []);
1105
- const onSelectAll = useCallback((checked, _selected, items) => {
1106
- const ids = (items || []).map(getRowId);
1107
- if (checked) {
1108
- setSelectedRows(value => {
1109
- const existingKeys = value.map(getRowId);
1110
- return [...value, ...(items || []).filter(item => existingKeys.indexOf(getRowId(item)) === -1)];
1111
- });
1112
- } else {
1113
- setSelectedRows(value => {
1114
- return value.filter(item => ids.indexOf(getRowId(item)) === -1);
1115
- });
1116
- }
1117
- }, [getRowId]);
1118
- const onSelect = useCallback((item, checked) => {
1119
- if (checked) {
1120
- if (type === 'radio') {
1121
- setSelectedRows([item]);
1122
- return;
1123
- }
1124
- setSelectedRows(value => {
1125
- const newValue = value.slice(0);
1126
- newValue.push(item);
1127
- return newValue;
1128
- });
1129
- } else {
1130
- setSelectedRows(value => {
1131
- const newValue = value.slice(0);
1132
- const index = newValue.findIndex(row => getRowId(row) === getRowId(item));
1133
- if (index > -1) {
1134
- newValue.splice(index, 1);
1135
- }
1136
- return newValue;
1137
- });
1138
- }
1139
- }, [getRowId, type]);
1140
- const getRowSelection = useCallback((dataSource, extra = {}) => {
1141
- const onChange = (keys, id, meta) => {
1142
- setSelectedRowKeys(keys, dataSource);
1143
- extra.onChange && extra.onChange(keys, id, meta);
1144
- };
1145
- return Object.assign({
1146
- type,
1147
- selectedRowKeys,
1148
- allowSelectedAll: type === 'checkbox',
1149
- onChange
1150
- }, extra);
1151
- }, [selectedRowKeys, setSelectedRowKeys, type]);
1152
- return {
1153
- type,
1154
- selectedRowKeys,
1155
- selectedRows,
1156
- onSelectAll,
1157
- onSelect,
1158
- setSelectedRows,
1159
- setSelectedRowKeys,
1160
- clearSelectedRows,
1161
- getRowSelection
1162
- };
1163
- };
1164
-
1165
- var style$3 = {"title":"kne-table-page_Yn7Wc","title-text":"kne-table-page_QhSty","has-sort":"kne-table-page_YaVIX","sort-btn":"kne-table-page_XkYCi","sort-icon":"kne-table-page_SSGYi","active":"kne-table-page_VT0uN","sort-up":"kne-table-page_CIokw","sort-down":"kne-table-page_5xrlc"};
1166
-
1167
- var style$2 = {"ellipsis":"kne-table-page_QBxlu"};
1168
-
1169
- const isSimpleTitle = title => typeof title === 'string' || typeof title === 'number';
1170
- const wrapColumnHeaderTitle = title => {
1171
- if (title == null || title === '') {
1172
- return title;
1173
- }
1174
- if (isSimpleTitle(title)) {
1175
- return /*#__PURE__*/jsx(Ellipsis, {
1176
- ellipsis: true,
1177
- children: title
1178
- });
1179
- }
1180
- return /*#__PURE__*/jsx("span", {
1181
- className: style$2['ellipsis'],
1182
- children: title
1183
- });
1184
- };
48
+ var style$2 = {"table":"kne-table-page_awa1L","is-selected-all":"kne-table-page_692q3","is-selected":"kne-table-page_IWgjl","is-disabled":"kne-table-page_YUG4k","has-summary":"kne-table-page_Cb-du","has-group-header":"kne-table-page_7qTC5","is-sticky":"kne-table-page_jGzIR","is-sticky-scroll-y":"kne-table-page_P6lxG","is-sticky-viewport":"kne-table-page_Kr-p6","table-cell":"kne-table-page_HPmr3","selection-col":"kne-table-page_D7YhS","radio-col":"kne-table-page_df9z3","is-computed":"kne-table-page_ZA1Je","is-resize":"kne-table-page_CA0uL","column-resize-guide":"kne-table-page_JARA2"};
1185
49
 
1186
- const sortArrayToMap = sort => new Map((sort || []).map(item => {
1187
- return [item.name, item.sort];
1188
- }));
1189
- const useControlValue = ({
1190
- value,
1191
- defaultValue,
1192
- onChange
1193
- }) => {
1194
- const [internalValue, setInternalValue] = useState(defaultValue);
1195
- const isControlled = value !== undefined;
1196
- const currentValue = isControlled ? value : internalValue;
1197
- const setValue = useCallback(updater => {
1198
- const nextValue = typeof updater === 'function' ? updater(currentValue) : updater;
1199
- if (!isControlled) {
1200
- setInternalValue(nextValue);
1201
- }
1202
- onChange && onChange(nextValue);
1203
- }, [currentValue, isControlled, onChange]);
1204
- return [currentValue, setValue];
1205
- };
1206
- const compareValues = (a, b, direction) => {
1207
- const emptyA = a == null || a === '';
1208
- const emptyB = b == null || b === '';
1209
- if (emptyA && emptyB) {
1210
- return 0;
1211
- }
1212
- if (emptyA) {
1213
- return 1;
1214
- }
1215
- if (emptyB) {
1216
- return -1;
1217
- }
1218
- if (typeof a === 'number' && typeof b === 'number') {
1219
- return direction === 'ASC' ? a - b : b - a;
1220
- }
1221
- const strA = String(a);
1222
- const strB = String(b);
1223
- return direction === 'ASC' ? strA.localeCompare(strB, 'zh-CN') : strB.localeCompare(strA, 'zh-CN');
1224
- };
1225
- const sortDataSource = (dataSource, sort = [], columns = []) => {
1226
- if (!(sort != null && sort.length) || !(dataSource != null && dataSource.length)) {
1227
- return dataSource;
1228
- }
1229
- const columnMap = new Map(columns.map(column => [column.name, column]));
1230
- return [...dataSource].sort((a, b) => {
1231
- for (const {
1232
- name,
1233
- sort: direction
1234
- } of sort) {
1235
- const column = columnMap.get(name) || {
1236
- name
1237
- };
1238
- const aVal = typeof column.getValueOf === 'function' ? column.getValueOf(a, {
1239
- column
1240
- }) : get(a, name);
1241
- const bVal = typeof column.getValueOf === 'function' ? column.getValueOf(b, {
1242
- column
1243
- }) : get(b, name);
1244
- const result = compareValues(aVal, bVal, direction);
1245
- if (result !== 0) {
1246
- return result;
1247
- }
1248
- }
1249
- return 0;
1250
- });
1251
- };
1252
- const getSortSingle = sortOption => {
1253
- if (typeof sortOption === 'object') {
1254
- return sortOption.single !== false;
1255
- }
1256
- return true;
1257
- };
1258
- const renderColumnTitle = (title, column, sortRender) => {
1259
- const titleContent = wrapColumnHeaderTitle(title);
1260
- if (!column.sort || typeof sortRender !== 'function') {
1261
- return titleContent;
50
+ const getColumnConfig = (config, columnName, field, defaultValue) => {
51
+ const columnConfig = config == null ? void 0 : config[columnName];
52
+ if (columnConfig != null && columnConfig[field] !== undefined) {
53
+ return columnConfig[field];
1262
54
  }
1263
- return /*#__PURE__*/jsxs("span", {
1264
- className: classnames(style$3['title'], style$3['has-sort']),
1265
- children: [/*#__PURE__*/jsx("span", {
1266
- className: style$3['title-text'],
1267
- children: titleContent
1268
- }), sortRender({
1269
- name: column.name,
1270
- single: getSortSingle(column.sort)
1271
- })]
1272
- });
55
+ const legacyValue = get(config, `${columnName}.${field}`);
56
+ return legacyValue === undefined ? defaultValue : legacyValue;
1273
57
  };
1274
- const useSort = (props = {}) => {
1275
- const [sort, setSort] = useControlValue({
1276
- value: props.sort,
1277
- defaultValue: props.defaultSort || [],
1278
- onChange: props.onSortChange
58
+ const setColumnConfig = (config, columnName, updates) => {
59
+ return Object.assign({}, config, {
60
+ [columnName]: Object.assign({}, config == null ? void 0 : config[columnName], updates)
1279
61
  });
1280
- const mapSort = useMemo(() => {
1281
- return sortArrayToMap(sort);
1282
- }, [sort]);
1283
- const setMapSort = useCallback(callback => {
1284
- return setSort(currentSort => {
1285
- const newSort = callback(sortArrayToMap(currentSort));
1286
- return Array.from(newSort).map(([name, sortValue]) => ({
1287
- name,
1288
- sort: sortValue
1289
- }));
1290
- });
1291
- }, [setSort]);
1292
- const sortRender = useCallback(({
1293
- single,
1294
- name
1295
- }) => {
1296
- const direction = mapSort.get(name);
1297
- return /*#__PURE__*/jsxs("span", {
1298
- className: style$3['sort-btn'],
1299
- onClick: e => {
1300
- e.stopPropagation();
1301
- setMapSort(sortMap => {
1302
- const current = sortMap.get(name);
1303
- const targetValue = (() => {
1304
- if (current === 'DESC') {
1305
- return 'ASC';
1306
- }
1307
- if (current === 'ASC') {
1308
- return null;
1309
- }
1310
- return 'DESC';
1311
- })();
1312
- if (single) {
1313
- return new Map(targetValue ? [[name, targetValue]] : []);
1314
- }
1315
- const newSort = clone(sortMap);
1316
- targetValue ? newSort.set(name, targetValue) : newSort.delete(name);
1317
- return newSort;
1318
- });
1319
- },
1320
- children: [/*#__PURE__*/jsx(CaretUpOutlined, {
1321
- className: classnames(style$3['sort-icon'], style$3['sort-up'], {
1322
- [style$3['active']]: direction === 'ASC'
1323
- })
1324
- }), /*#__PURE__*/jsx(CaretDownOutlined, {
1325
- className: classnames(style$3['sort-icon'], style$3['sort-down'], {
1326
- [style$3['active']]: direction === 'DESC'
1327
- })
1328
- })]
1329
- });
1330
- }, [mapSort, setMapSort]);
1331
- return {
1332
- sort,
1333
- setSort,
1334
- sortRender
1335
- };
1336
62
  };
1337
- useSort.sortDataSource = sortDataSource;
1338
63
 
1339
64
  var configStyle = {"cell-resize-bar":"kne-table-page_PNaAP","table-changer-setting":"kne-table-page_B0U-O","is-active":"kne-table-page_vHrQo","table-config-header":"kne-table-page_Zp8MN","table-config-header-title":"kne-table-page_Pc6jR","columns-control-content":"kne-table-page_saJmr","columns-control-content-title":"kne-table-page_YmHni","columns-control-content-scroller":"kne-table-page_rgqWB","columns-control-sortable-list":"kne-table-page_JRcBW","columns-control-content-footer":"kne-table-page_nLwW1","columns-control-content-input":"kne-table-page_9qyJs","columns-control-content-list":"kne-table-page_Sslzr","columns-control-content-item":"kne-table-page_7CamD","is-drag":"kne-table-page_X18rq","columns-control-content-item-icon":"kne-table-page_Eab-e","columns-control-overlay":"kne-table-page_eT4HV","header-col":"kne-table-page_bjDly","header-cell-inner":"kne-table-page_9FKgD"};
1340
65
 
@@ -1408,9 +133,9 @@ const ColumnsControlContent = withLocale(({
1408
133
  if (item.fixed === true || item.fixed === 'left') {
1409
134
  return 'leftFixedColumns';
1410
135
  }
1411
- return get(config, `${item.name}.visible`) !== true && item.hidden || get(config, `${item.name}.visible`) === false ? 'hiddenColumns' : 'visibleColumns';
136
+ return getColumnConfig(config, item.name, 'visible') !== true && item.hidden || getColumnConfig(config, item.name, 'visible') === false ? 'hiddenColumns' : 'visibleColumns';
1412
137
  })), (result, value, key) => {
1413
- result[key] = value.sort((a, b) => get(config, `${a.name}.rank`, 0) - get(config, `${b.name}.rank`, 0));
138
+ result[key] = value.sort((a, b) => getColumnConfig(config, a.name, 'rank', 0) - getColumnConfig(config, b.name, 'rank', 0));
1414
139
  }, {});
1415
140
  }, [columns, config]);
1416
141
  const sortableVisibleColumns = useMemo(() => {
@@ -1422,10 +147,14 @@ const ColumnsControlContent = withLocale(({
1422
147
  const newConfig = cloneDeep(config);
1423
148
  const columnsList = [].concat(columnsState.leftFixedColumns, columnsState.visibleColumns, columnsState.rightFixedColumns);
1424
149
  (columnsState.hiddenColumns || []).forEach(col => {
1425
- set(newConfig, `${col.name}.visible`, false);
150
+ Object.assign(newConfig, setColumnConfig(newConfig, col.name, {
151
+ visible: false
152
+ }));
1426
153
  });
1427
154
  columnsList.forEach((col, index) => {
1428
- set(newConfig, `${col.name}.rank`, index + 1);
155
+ Object.assign(newConfig, setColumnConfig(newConfig, col.name, {
156
+ rank: index + 1
157
+ }));
1429
158
  });
1430
159
  onChange(newConfig);
1431
160
  };
@@ -1768,8 +497,8 @@ const useTableConfig = ({
1768
497
  }
1769
498
  }, [name, _controllerOpen, _tableServerApis]);
1770
499
  const visibleColumns = useMemo(() => {
1771
- return columns.filter(col => !(get(config, `${col.name}.visible`) === false || get(config, `${col.name}.visible`) !== true && col.hidden === true)).sort((a, b) => {
1772
- const computedIndex = item => get(config, `${item.name}.rank`, 0) + (item.fixed === 'left' || item.fixed === true ? -10000 : 0) + (item.fixed === 'right' ? 10000 : 0);
500
+ return columns.filter(col => !(getColumnConfig(config, col.name, 'visible') === false || getColumnConfig(config, col.name, 'visible') !== true && col.hidden === true)).sort((a, b) => {
501
+ const computedIndex = item => getColumnConfig(config, item.name, 'rank', 0) + (item.fixed === 'left' || item.fixed === true ? -10000 : 0) + (item.fixed === 'right' ? 10000 : 0);
1773
502
  return computedIndex(a) - computedIndex(b);
1774
503
  });
1775
504
  }, [columns, config]);
@@ -1783,7 +512,7 @@ const useTableConfig = ({
1783
512
  const {
1784
513
  width
1785
514
  } = getColumnSize(col);
1786
- const contentWidth = get(config, `${col.name}.width`) || width;
515
+ const contentWidth = getColumnConfig(config, col.name, 'width') || width;
1787
516
  return sum + withConfigColumnExtra(contentWidth, index, columnCount, _controllerOpen);
1788
517
  }, 0);
1789
518
  }, [visibleColumns, config, columnCount, _controllerOpen]);
@@ -1806,7 +535,7 @@ const useTableConfig = ({
1806
535
  min,
1807
536
  max
1808
537
  } = getColumnSize(column);
1809
- const currentWidth = Math.min(Math.max(get(config, `${column.name}.width`) || width, min), max);
538
+ const currentWidth = Math.min(Math.max(getColumnConfig(config, column.name, 'width') || width, min), max);
1810
539
  return {
1811
540
  currentWidth,
1812
541
  min,
@@ -2012,28 +741,6 @@ const useElementWidth = ref => {
2012
741
  return width;
2013
742
  };
2014
743
 
2015
- const renderCellContent = (content, column, contentClassName) => {
2016
- const wrapEllipsis = column.ellipsis && !column.ellipsisHandledByRender;
2017
- const needsWidthConstraint = Boolean(column.ellipsis || column.cellFullWidth);
2018
- const inner = wrapEllipsis ? /*#__PURE__*/jsx(Ellipsis, {
2019
- ellipsis: column.ellipsis,
2020
- children: content
2021
- }) : content;
2022
- return /*#__PURE__*/jsx("span", {
2023
- className: contentClassName,
2024
- children: needsWidthConstraint ? /*#__PURE__*/jsx("span", {
2025
- className: classnames(ellipsisStyle['cell-content'], column.cellFullWidth && ellipsisStyle['cell-full-width']),
2026
- children: inner
2027
- }) : inner
2028
- });
2029
- };
2030
- const getColumnEllipsis = column => {
2031
- if (!column.ellipsis) {
2032
- return undefined;
2033
- }
2034
- return typeof column.ellipsis === 'object' ? column.ellipsis : true;
2035
- };
2036
-
2037
744
  const parsePixelValue = value => {
2038
745
  const num = parseFloat(value);
2039
746
  return Number.isNaN(num) ? 0 : num;
@@ -2280,7 +987,7 @@ const observeViewportIntersection = (element, onChange) => {
2280
987
  };
2281
988
  };
2282
989
 
2283
- const _excluded$3 = ["className", "dataSource", "columns", "rowKey", "rowSelection", "valueIsEmpty", "emptyIsPlaceholder", "placeholder", "empty", "onRowSelect", "render", "context", "sticky", "scrollTopInset", "stickyOffset", "getStickyContainer", "headerStyle", "pagination", "sortRender", "name", "controllerOpen", "tableServerApis", "scroll", "summary"],
990
+ const _excluded$2 = ["className", "dataSource", "columns", "rowKey", "rowSelection", "valueIsEmpty", "emptyIsPlaceholder", "placeholder", "empty", "onRowSelect", "render", "context", "sticky", "scrollTopInset", "stickyOffset", "getStickyContainer", "headerStyle", "pagination", "sortRender", "name", "controllerOpen", "tableServerApis", "scroll", "summary"],
2284
991
  _excluded2$2 = ["getContainer"];
2285
992
  const mapJustifyToAlign = justify => {
2286
993
  if (justify === 'center') {
@@ -2315,9 +1022,9 @@ const getColCellStyle = column => ({
2315
1022
  textAlign: mapJustifyToAlign(column.justify),
2316
1023
  verticalAlign: column.align === 'middle' ? 'middle' : column.align === 'bottom' ? 'bottom' : 'top'
2317
1024
  });
2318
- const getAntCellClassName = (...extra) => classnames(style$4['table-cell'], 'info-page-table-col', ...extra);
1025
+ const getAntCellClassName = (...extra) => classnames(style$2['table-cell'], 'info-page-table-col', ...extra);
2319
1026
  const wrapColContent = node => /*#__PURE__*/jsx("span", {
2320
- className: style$5['col-content'],
1027
+ className: viewStyle['col-content'],
2321
1028
  children: node
2322
1029
  });
2323
1030
  const Table = p => {
@@ -2358,7 +1065,7 @@ const Table = p => {
2358
1065
  scroll,
2359
1066
  summary
2360
1067
  } = props,
2361
- others = _objectWithoutPropertiesLoose(props, _excluded$3);
1068
+ others = _objectWithoutPropertiesLoose(props, _excluded$2);
2362
1069
  const columns = useMemo(() => resolveColumns(columnsProp), [columnsProp]);
2363
1070
  useEffect(() => {
2364
1071
  if (tableWidth) {
@@ -2447,7 +1154,7 @@ const Table = p => {
2447
1154
  key: colName,
2448
1155
  dataIndex: colName,
2449
1156
  title: /*#__PURE__*/jsx("span", {
2450
- className: style$5['col-content'],
1157
+ className: viewStyle['col-content'],
2451
1158
  children: renderColumnTitle(title, column, sortRender)
2452
1159
  }),
2453
1160
  width: toAntdWidth(width),
@@ -2480,7 +1187,7 @@ const Table = p => {
2480
1187
  placeholder,
2481
1188
  dataSource: record,
2482
1189
  context
2483
- }), computedColumn, style$5['col-content']);
1190
+ }), computedColumn, viewStyle['col-content']);
2484
1191
  }
2485
1192
  };
2486
1193
  if (!controllerOpen) {
@@ -2488,7 +1195,7 @@ const Table = p => {
2488
1195
  }
2489
1196
  const configProps = computedColumnProps(column, index, {
2490
1197
  title: /*#__PURE__*/jsx("span", {
2491
- className: style$5['col-content'],
1198
+ className: viewStyle['col-content'],
2492
1199
  children: renderColumnTitle(title, column, sortRender)
2493
1200
  })
2494
1201
  });
@@ -2511,7 +1218,7 @@ const Table = p => {
2511
1218
  return {
2512
1219
  key: column.name,
2513
1220
  title: /*#__PURE__*/jsx("span", {
2514
- className: style$5['col-content'],
1221
+ className: viewStyle['col-content'],
2515
1222
  children: wrapColumnHeaderTitle(column.title)
2516
1223
  }),
2517
1224
  onHeaderCell: () => ({
@@ -2577,13 +1284,13 @@ const Table = p => {
2577
1284
  })),
2578
1285
  renderCell: (checked, record, index, originNode) => wrapColContent(originNode),
2579
1286
  onCell: () => ({
2580
- className: getAntCellClassName(style$4['selection-col'])
1287
+ className: getAntCellClassName(style$2['selection-col'])
2581
1288
  })
2582
1289
  } : {
2583
1290
  columnWidth: 30,
2584
1291
  renderCell: (checked, record, index, originNode) => wrapColContent(originNode),
2585
1292
  onCell: () => ({
2586
- className: getAntCellClassName(style$4['radio-col'])
1293
+ className: getAntCellClassName(style$2['radio-col'])
2587
1294
  })
2588
1295
  });
2589
1296
  }, [context, dataSource, rowKey, rowSelection, hasFixedColumn]);
@@ -2651,22 +1358,22 @@ const Table = p => {
2651
1358
  tableLayout: controllerOpen || hasFixedColumn ? 'fixed' : undefined,
2652
1359
  scroll: tableScroll,
2653
1360
  onHeaderRow: () => ({
2654
- className: classnames(style$5['header'], 'info-page-table-header'),
1361
+ className: classnames(viewStyle['header'], 'info-page-table-header'),
2655
1362
  style: headerStyle
2656
1363
  }),
2657
1364
  locale: {
2658
1365
  emptyText: /*#__PURE__*/jsx("div", {
2659
- className: style$5['empty'],
1366
+ className: viewStyle['empty'],
2660
1367
  children: empty
2661
1368
  })
2662
1369
  },
2663
1370
  rowClassName: record => {
2664
1371
  const id = resolveRowKey(rowKey, record);
2665
1372
  const isChecked = (rowSelection == null ? void 0 : rowSelection.selectedRowKeys) && rowSelection.selectedRowKeys.indexOf(id) > -1;
2666
- return classnames(style$5['body'], 'info-page-table-row', {
2667
- [style$5['is-selected-all']]: rowSelection == null ? void 0 : rowSelection.isSelectedAll,
2668
- [style$5['is-selected']]: isChecked,
2669
- [style$5['is-disabled']]: record.disabled
1373
+ return classnames(viewStyle['body'], 'info-page-table-row', {
1374
+ [viewStyle['is-selected-all']]: rowSelection == null ? void 0 : rowSelection.isSelectedAll,
1375
+ [viewStyle['is-selected']]: isChecked,
1376
+ [viewStyle['is-disabled']]: record.disabled
2670
1377
  });
2671
1378
  },
2672
1379
  onRow: onRowSelect ? record => ({
@@ -2683,21 +1390,21 @@ const Table = p => {
2683
1390
  }));
2684
1391
  const wrappedTable = /*#__PURE__*/jsxs("div", {
2685
1392
  ref: tableRef,
2686
- className: classnames(style$4['table'], 'info-page-table', className, {
2687
- [style$4['is-resize']]: currentMoveColumnIndex !== null,
2688
- [style$4['is-computed']]: isLayout,
2689
- [style$4['has-group-header']]: hasGroupHeader,
2690
- [style$4['has-summary']]: typeof summary === 'function',
2691
- [style$4['is-sticky']]: !!sticky,
2692
- [style$4['is-sticky-scroll-y']]: !!sticky && hasScrollY,
2693
- [style$4['is-sticky-viewport']]: isStickyViewport
1393
+ className: classnames(style$2['table'], 'info-page-table', className, {
1394
+ [style$2['is-resize']]: currentMoveColumnIndex !== null,
1395
+ [style$2['is-computed']]: isLayout,
1396
+ [style$2['has-group-header']]: hasGroupHeader,
1397
+ [style$2['has-summary']]: typeof summary === 'function',
1398
+ [style$2['is-sticky']]: !!sticky,
1399
+ [style$2['is-sticky-scroll-y']]: !!sticky && hasScrollY,
1400
+ [style$2['is-sticky-viewport']]: isStickyViewport
2694
1401
  }),
2695
1402
  style: tableWrapperStyle,
2696
1403
  children: [/*#__PURE__*/jsx("div", {
2697
1404
  className: "info-page-table-body",
2698
1405
  children: !isLayout && tableElement
2699
1406
  }), currentMoveColumnIndex !== null && resizeGuideStyle && /*#__PURE__*/jsx("span", {
2700
- className: style$4['column-resize-guide'],
1407
+ className: style$2['column-resize-guide'],
2701
1408
  style: resizeGuideStyle,
2702
1409
  "aria-hidden": true
2703
1410
  })]
@@ -2714,372 +1421,6 @@ Table.useSelectedRow = useSelectedRow;
2714
1421
  Table.useSort = useSort;
2715
1422
  Table.sortDataSource = useSort.sortDataSource;
2716
1423
 
2717
- const Label = ({
2718
- className,
2719
- children,
2720
- onChange
2721
- }) => {
2722
- const ref = useRef(null);
2723
- const handlerChange = useRefCallback(onChange);
2724
- useLayoutEffect(() => {
2725
- const computed = () => {
2726
- if (!ref.current) {
2727
- return;
2728
- }
2729
- handlerChange(ref.current.getBoundingClientRect());
2730
- };
2731
- const resizeObserver = new ResizeObserver(computed);
2732
- resizeObserver.observe(ref.current);
2733
- computed();
2734
- return () => {
2735
- resizeObserver.disconnect();
2736
- };
2737
- }, [handlerChange]);
2738
- return /*#__PURE__*/jsx("span", {
2739
- ref: ref,
2740
- className: className,
2741
- children: children
2742
- });
2743
- };
2744
-
2745
- const renderHeaderCellContent = (column, {
2746
- sortRender,
2747
- widthBased,
2748
- setColsSize,
2749
- defaultSpan,
2750
- colsSize
2751
- }) => {
2752
- const titleNode = renderColumnTitle(column.title, column, sortRender);
2753
- const contentClassName = style$5['col-content'];
2754
- if (widthBased) {
2755
- return /*#__PURE__*/jsx("span", {
2756
- className: contentClassName,
2757
- children: titleNode
2758
- });
2759
- }
2760
- return /*#__PURE__*/jsx(Label, {
2761
- className: contentClassName,
2762
- onChange: size => {
2763
- setColsSize(value => Object.assign({}, value, {
2764
- [column.name]: Math.max(size.width, parseColumnWidth(resolveColumnDimensions(column).width))
2765
- }));
2766
- },
2767
- children: titleNode
2768
- });
2769
- };
2770
- const renderHeaderGridCells = ({
2771
- dataSource,
2772
- columns,
2773
- rowKey,
2774
- rowSelection,
2775
- colsSize,
2776
- setColsSize,
2777
- sortRender,
2778
- defaultSpan
2779
- }) => {
2780
- const cells = [];
2781
- if ((rowSelection == null ? void 0 : rowSelection.type) === 'checkbox') {
2782
- cells.push(/*#__PURE__*/jsx("div", {
2783
- className: classnames(style$5['col'], style$5['col-fixed'], style$5['header-cell'], 'info-page-table-col'),
2784
- children: /*#__PURE__*/jsx("span", {
2785
- className: classnames(style$5['col-content'], 'info-page-table-col-content'),
2786
- children: rowSelection.allowSelectedAll ? (() => {
2787
- const checkedAll = rowSelection.isSelectedAll || dataSource && dataSource.every(item => rowSelection.selectedRowKeys && rowSelection.selectedRowKeys.indexOf(get(item, typeof rowKey === 'function' ? rowKey(item) : rowKey)) > -1);
2788
- return /*#__PURE__*/jsx(Checkbox, {
2789
- checked: checkedAll,
2790
- indeterminate: rowSelection.selectedRowKeys && rowSelection.selectedRowKeys.length > 0 && !checkedAll,
2791
- onChange: e => {
2792
- const checked = e.target.checked;
2793
- if (!checked) {
2794
- typeof rowSelection.onIsSelectAllChange === 'function' ? rowSelection.onIsSelectAllChange(false) : rowSelection.onChange([]);
2795
- } else {
2796
- typeof rowSelection.onIsSelectAllChange === 'function' ? rowSelection.onIsSelectAllChange(true) : dataSource && dataSource.length > 0 && rowSelection.onChange(dataSource.map(item => {
2797
- return get(item, typeof rowKey === 'function' ? rowKey(item) : rowKey);
2798
- }));
2799
- }
2800
- }
2801
- });
2802
- })() : /*#__PURE__*/jsx(Checkbox, {
2803
- style: {
2804
- visibility: 'hidden'
2805
- }
2806
- })
2807
- })
2808
- }, "__selection__"));
2809
- }
2810
- columns.forEach((column, index) => {
2811
- const {
2812
- widthBased,
2813
- fillRemaining,
2814
- style: columnStyle
2815
- } = getColumnLayout(column, {
2816
- defaultSpan,
2817
- colsSize,
2818
- isLastColumn: index === columns.length - 1,
2819
- columns
2820
- });
2821
- cells.push(/*#__PURE__*/jsx("div", {
2822
- style: columnStyle,
2823
- className: classnames(style$5['col'], fillRemaining ? style$5['col-width-fill'] : widthBased && style$5['col-width-based'], style$5['header-cell'], 'info-page-table-col'),
2824
- children: renderHeaderCellContent(column, {
2825
- sortRender,
2826
- widthBased,
2827
- setColsSize,
2828
- defaultSpan,
2829
- colsSize
2830
- })
2831
- }, column.name));
2832
- });
2833
- if ((rowSelection == null ? void 0 : rowSelection.type) === 'radio') {
2834
- cells.push(/*#__PURE__*/jsx("div", {
2835
- className: classnames(style$5['col'], style$5['single-checked'], style$5['header-cell'], 'info-page-table-col')
2836
- }, "__radio__"));
2837
- }
2838
- return cells;
2839
- };
2840
- const Header = p => {
2841
- const {
2842
- dataSource,
2843
- columns,
2844
- rowKey,
2845
- rowSelection,
2846
- colsSize,
2847
- setColsSize,
2848
- headerStyle,
2849
- sortRender,
2850
- defaultSpan
2851
- } = Object.assign({}, {
2852
- rowKey: 'id'
2853
- }, p);
2854
- return /*#__PURE__*/jsx("div", {
2855
- style: headerStyle,
2856
- className: classnames(style$5['header'], 'info-page-table-header'),
2857
- children: renderHeaderGridCells({
2858
- dataSource,
2859
- columns,
2860
- rowKey,
2861
- rowSelection,
2862
- colsSize,
2863
- setColsSize,
2864
- sortRender,
2865
- defaultSpan
2866
- })
2867
- });
2868
- };
2869
-
2870
- const _excluded$2 = ["className", "dataSource", "columns", "rowKey", "rowSelection", "valueIsEmpty", "emptyIsPlaceholder", "placeholder", "empty", "onRowSelect", "render", "context", "sticky", "headerStyle", "sortRender"];
2871
- const getLayoutColumns = columns => columns.filter(column => column.display !== false);
2872
- const TableView = p => {
2873
- const [colsSize, setColsSize] = useState({});
2874
- const props = Object.assign({}, {
2875
- rowKey: 'id',
2876
- valueIsEmpty: isEmpty,
2877
- placeholder: '-',
2878
- emptyIsPlaceholder: true,
2879
- empty: /*#__PURE__*/jsx(Empty, {})
2880
- }, p);
2881
- const {
2882
- className,
2883
- dataSource,
2884
- columns: columnsProp,
2885
- rowKey,
2886
- rowSelection,
2887
- valueIsEmpty,
2888
- emptyIsPlaceholder,
2889
- placeholder,
2890
- empty,
2891
- onRowSelect,
2892
- render,
2893
- context,
2894
- headerStyle,
2895
- sortRender
2896
- } = props,
2897
- others = _objectWithoutPropertiesLoose(props, _excluded$2);
2898
- const columns = useMemo(() => resolveColumns(columnsProp), [columnsProp]);
2899
- const layoutColumns = useMemo(() => getLayoutColumns(columns), [columns]);
2900
- const defaultSpan = useMemo(() => {
2901
- const assignedSpan = layoutColumns.reduce((a, b) => a + (b.span || 0), 0);
2902
- const undistributedColCount = layoutColumns.filter(item => !hasColumnSpan(item) && !hasColumnWidth(item, layoutColumns)).length;
2903
- return undistributedColCount > 0 ? Math.round(Math.max(24 - assignedSpan, 0) / undistributedColCount) : 1;
2904
- }, [layoutColumns]);
2905
- const gridTemplateColumns = useMemo(() => getGridTemplateColumns(layoutColumns, {
2906
- defaultSpan,
2907
- colsSize,
2908
- rowSelection
2909
- }), [layoutColumns, defaultSpan, colsSize, rowSelection]);
2910
- const headerCellProps = {
2911
- dataSource,
2912
- columns: layoutColumns,
2913
- rowKey,
2914
- rowSelection,
2915
- colsSize,
2916
- setColsSize,
2917
- sortRender,
2918
- defaultSpan
2919
- };
2920
- const header = /*#__PURE__*/jsx(Header, _extends({}, headerCellProps, {
2921
- headerStyle: headerStyle
2922
- }));
2923
- const handleRowClick = (item, {
2924
- dataSource,
2925
- context,
2926
- id,
2927
- isChecked
2928
- }) => {
2929
- if (item.disabled) {
2930
- return;
2931
- }
2932
- onRowSelect && onRowSelect(item, {
2933
- columns: layoutColumns,
2934
- dataSource
2935
- });
2936
- if (!rowSelection || rowSelection.isSelectedAll) {
2937
- return;
2938
- }
2939
- if (rowSelection.type === 'checkbox') {
2940
- const _selectedRowKeys = (rowSelection.selectedRowKeys || []).slice(0);
2941
- isChecked ? _selectedRowKeys.splice(rowSelection.selectedRowKeys.indexOf(id), 1) : _selectedRowKeys.push(id);
2942
- rowSelection.onChange(_selectedRowKeys, id, {
2943
- context,
2944
- checked: !isChecked
2945
- });
2946
- return;
2947
- }
2948
- const selectedRowKeys = rowSelection.selectedRowKeys.length && rowSelection.selectedRowKeys[0] === id ? [] : [id];
2949
- rowSelection.onChange(selectedRowKeys, id, {
2950
- context,
2951
- checked: !isChecked
2952
- });
2953
- };
2954
- const renderBodyGridCells = (dataSource, context) => {
2955
- const getId = item => get(item, typeof rowKey === 'function' ? rowKey(item) : rowKey);
2956
- if (!dataSource || dataSource.length === 0) {
2957
- return null;
2958
- }
2959
- return dataSource.map(item => {
2960
- const id = getId(item);
2961
- const isChecked = (rowSelection == null ? void 0 : rowSelection.selectedRowKeys) && rowSelection.selectedRowKeys.indexOf(id) > -1;
2962
- const columnsValue = computeColumnsValue({
2963
- columns: layoutColumns,
2964
- emptyIsPlaceholder,
2965
- valueIsEmpty,
2966
- removeEmpty: true,
2967
- dataSource: item,
2968
- placeholder,
2969
- context
2970
- });
2971
- const columnMap = columnsValue.reduce((result, column) => Object.assign(result, {
2972
- [column.name]: column
2973
- }), {});
2974
- const rowClassName = classnames(style$5['body'], style$5['body-cell'], style$5['body-row'], 'info-page-table-row', {
2975
- [style$5['is-selected-all']]: rowSelection == null ? void 0 : rowSelection.isSelectedAll,
2976
- [style$5['is-selected']]: isChecked,
2977
- [style$5['is-disabled']]: item.disabled
2978
- });
2979
- const onSelectionChange = () => handleRowClick(item, {
2980
- dataSource,
2981
- context,
2982
- id,
2983
- isChecked
2984
- });
2985
- const cells = [];
2986
- if ((rowSelection == null ? void 0 : rowSelection.type) === 'checkbox') {
2987
- cells.push(/*#__PURE__*/jsx("div", {
2988
- className: classnames(style$5['col'], style$5['col-fixed'], 'info-page-table-col'),
2989
- children: /*#__PURE__*/jsx("span", {
2990
- className: classnames(style$5['col-content'], 'info-page-table-col-content'),
2991
- children: /*#__PURE__*/jsx(Checkbox, {
2992
- disabled: item.disabled || rowSelection.isSelectedAll,
2993
- checked: rowSelection.isSelectedAll && !item.disabled || isChecked,
2994
- onChange: onSelectionChange
2995
- })
2996
- })
2997
- }, `${id}__selection__`));
2998
- }
2999
- layoutColumns.forEach((column, index) => {
3000
- const columnValue = columnMap[column.name];
3001
- const {
3002
- widthBased,
3003
- fillRemaining,
3004
- style: columnStyle
3005
- } = getColumnLayout(column, {
3006
- defaultSpan,
3007
- colsSize,
3008
- isLastColumn: index === layoutColumns.length - 1,
3009
- columns: layoutColumns
3010
- });
3011
- cells.push(/*#__PURE__*/jsx("div", {
3012
- style: columnStyle,
3013
- className: classnames(style$5['col'], fillRemaining ? style$5['col-width-fill'] : widthBased && style$5['col-width-based'], 'info-page-table-col'),
3014
- children: columnValue ? renderCellContent(computeDisplay({
3015
- column: columnValue,
3016
- placeholder,
3017
- dataSource: item,
3018
- context
3019
- }), columnValue, style$5['col-content']) : /*#__PURE__*/jsx("span", {
3020
- className: style$5['col-content']
3021
- })
3022
- }, `${id}-${column.name}`));
3023
- });
3024
- if ((rowSelection == null ? void 0 : rowSelection.type) === 'radio') {
3025
- cells.push(/*#__PURE__*/jsx("div", {
3026
- className: classnames(style$5['col'], style$5['single-checked'], 'info-page-table-col'),
3027
- onClick: onSelectionChange,
3028
- children: isChecked && /*#__PURE__*/jsx(CheckOutlined, {})
3029
- }, `${id}__radio__`));
3030
- }
3031
- return /*#__PURE__*/jsx("div", {
3032
- className: rowClassName,
3033
- children: cells
3034
- }, id);
3035
- });
3036
- };
3037
- const renderGrid = (dataSource, context) => /*#__PURE__*/jsxs("div", {
3038
- className: style$5['grid'],
3039
- style: {
3040
- gridTemplateColumns
3041
- },
3042
- children: [renderHeaderGridCells(headerCellProps), renderBodyGridCells(dataSource, context)]
3043
- });
3044
- const renderBody = (dataSource, context) => {
3045
- if (!dataSource || dataSource.length === 0) {
3046
- return /*#__PURE__*/jsx("div", {
3047
- className: style$5['empty'],
3048
- children: empty
3049
- });
3050
- }
3051
- return /*#__PURE__*/jsx("div", {
3052
- className: classnames('info-page-table-body'),
3053
- children: renderGrid(dataSource, context)
3054
- });
3055
- };
3056
- if (typeof render === 'function') {
3057
- return render(_extends({}, others, {
3058
- header,
3059
- renderBody
3060
- }));
3061
- }
3062
- return /*#__PURE__*/jsx("div", _extends({}, others, {
3063
- className: classnames(style$5['table'], style$5['tableView'], 'info-page-table', className),
3064
- children: dataSource && dataSource.length > 0 ? renderGrid(dataSource, context) : /*#__PURE__*/jsxs(Fragment, {
3065
- children: [/*#__PURE__*/jsx("div", {
3066
- className: style$5['grid'],
3067
- style: {
3068
- gridTemplateColumns
3069
- },
3070
- children: renderHeaderGridCells(headerCellProps)
3071
- }), /*#__PURE__*/jsx("div", {
3072
- className: style$5['empty'],
3073
- children: empty
3074
- })]
3075
- })
3076
- }));
3077
- };
3078
- TableView.Header = Header;
3079
- TableView.useSelectedRow = useSelectedRow;
3080
- TableView.useSort = useSort;
3081
- TableView.sortDataSource = useSort.sortDataSource;
3082
-
3083
1424
  var style$1 = {"table-page":"kne-table-page_ut9rJ","table-content":"kne-table-page_dxN6N","table-with-toolbar":"kne-table-page_sf06r","has-summary":"kne-table-page_IRdzb","table-in-toolbar":"kne-table-page_sawIT","pagination":"kne-table-page_DSTEf","total_text":"kne-table-page_pJhKr","floating-scrollbar":"kne-table-page_iu8E1","floating-scrollbar-embedded":"kne-table-page_PIv-C","floating-scrollbar-thumb":"kne-table-page_RjZsu","is-moving":"kne-table-page_y-4Ou"};
3084
1425
 
3085
1426
  const BAR_HEIGHT = 15;
@@ -3812,11 +2153,5 @@ const TablePage = /*#__PURE__*/forwardRef((_ref2, ref) => {
3812
2153
  }));
3813
2154
  });
3814
2155
 
3815
- const preset = props => {
3816
- const next = merge({}, globalParams, props);
3817
- merge(globalParams, props);
3818
- return next;
3819
- };
3820
-
3821
- export { RENDER_TYPE_NAMES, SIZE_NAMES, Table, TableView, TablePage as default, getColumnRender, getRenderTypeDimensions, getRenderTypeNames, getStatusType, getTagColor, globalParams, isOptionsColumn, parseRenderType, preset, renderStatusItem, renderTagItem, renderTagList, resolveColumn, resolveColumnDimensions, resolveColumns, resolveRenderType, sortDataSource, tableLocalApis, useSelectedRow, useSort, useTableConfig };
2156
+ export { Table, TablePage as default, tableLocalApis, useTableConfig };
3822
2157
  //# sourceMappingURL=index.modern.js.map