intable 0.0.29 → 0.0.31

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/README.md CHANGED
@@ -152,7 +152,7 @@ const App = () => {
152
152
 
153
153
  ## 插件
154
154
 
155
- 插件通过 `plugins` 属性传入,部分插件需从对应路径手动引入。
155
+ 其他插件通过 `plugins` 属性传入,需从对应路径手动引入。
156
156
 
157
157
  ---
158
158
 
@@ -330,7 +330,7 @@ import { DiffPlugin } from 'intable/plugins/DiffPlugin'
330
330
  added: true, // 高亮新增行,默认 true
331
331
  removed: true, // 高亮删除行,默认 true
332
332
  changed: true, // 高亮修改行,默认 true
333
- onCommit: (data, { added, removed, changed }) => save(data),
333
+ onCommit: ({ added, removed, changed }) => save(data),
334
334
  }}
335
335
  />
336
336
  ```
@@ -376,4 +376,89 @@ const columns = [
376
376
 
377
377
  ### CopyPastePlugin — 复制粘贴
378
378
 
379
- `Ctrl+C` 复制选中区域为 TSV 格式,`Ctrl+V` 粘贴。
379
+ `Ctrl+C` 复制选中区域为 TSV 格式,`Ctrl+V` 粘贴。
380
+
381
+ ---
382
+
383
+ ### FilterPlugin — 列筛选(**内置**)
384
+
385
+ 在 Column 上设置 `filterable: true` 开启筛选,点击表头图标弹出筛选面板。
386
+
387
+ ```jsx
388
+ const columns = [
389
+ { id: 'name', name: '姓名', type: 'text', filterable: true },
390
+ { id: 'dept', name: '部门', type: 'enum', filterable: true, enum: { eng: '工程', design: '设计' } },
391
+ { id: 'age', name: '年龄', type: 'number', filterable: true },
392
+ ]
393
+
394
+ // 客户端实时过滤
395
+ <Intable columns={columns} data={data} filter={{ autoMatch: true }} />
396
+
397
+ // 服务端过滤
398
+ <Intable
399
+ filter={{
400
+ autoMatch: false,
401
+ onChange: filters => fetchData(filters),
402
+ }}
403
+ />
404
+ ```
405
+
406
+ 每列 `type` 决定可用操作符:`text`、`number`、`date`、`enum`、`checkbox`。
407
+
408
+ ---
409
+
410
+ ### AggregatePlugin — 汇总行(**内置**)
411
+
412
+ 在列上设置 `aggregate` 字段,表格底部自动显示汇总行。
413
+
414
+ ```jsx
415
+ const columns = [
416
+ { id: 'name', name: '姓名', width: 140 },
417
+ { id: 'age', name: '年龄', width: 80, aggregate: 'avg' },
418
+ { id: 'salary', name: '薪资', width: 110, aggregate: 'sum' },
419
+ { id: 'bonus', name: '奖金', width: 100, aggregate: values => values.reduce((s, v) => s + v, 0) },
420
+ ]
421
+
422
+ <Intable
423
+ columns={columns} data={data}
424
+ aggregate={{
425
+ label: '合计',
426
+ formatter: (val, type) => type === 'sum' ? `$${Number(val).toLocaleString()}` : val,
427
+ }}
428
+ />
429
+ ```
430
+
431
+ `aggregate` 列字段:`'sum'` | `'avg'` | `'min'` | `'max'` | `'count'` | `(values, col, data) => any`。
432
+
433
+ ---
434
+
435
+ ### AutoFillPlugin — Excel 填充手柄(**内置,默认关闭**)
436
+
437
+ 选中单元格后,选区右下角出现小方块手柄,拖拽即可向四个方向填充。双击手柄可自动向下填充至相邻列最后一个非空行。
438
+
439
+ ```jsx
440
+ // 传入 autoFill={true} 开启,需要 onDataChange 接收写入操作
441
+ <Intable data={data} onDataChange={setData} columns={columns} autoFill={true} />
442
+ ```
443
+
444
+ 填充规则:数字等差、日期递增、其他循环复制;单个数字默认步长为 1。
445
+
446
+ ---
447
+
448
+ ### ImportExportPlugin — Excel 导入 / 导出(**内置**)
449
+
450
+ 需要安装依赖:`pnpm add xlsx`
451
+
452
+ ```jsx
453
+ let store
454
+
455
+ const handleExport = () => store.commands.exportExcel() // 下载 data.xlsx
456
+ const handleImport = async () => {
457
+ const rows = await store.commands.readExcel()
458
+ setData(rows)
459
+ }
460
+
461
+ <Intable store={s => store = s} columns={columns} data={data} />
462
+ ```
463
+
464
+ 导出自动过滤内部列(如序号、勾选列);导入通过列名自动匹配数据。
package/dist/__uno.css CHANGED
@@ -1 +1 @@
1
- @supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--un-bg-opacity:100%;--un-leading:initial;--un-content:"";--un-translate-x:initial;--un-translate-y:initial;--un-translate-z:initial;--un-text-opacity:100%;--un-border-opacity:100%;--un-space-y-reverse:initial;--un-space-x-reverse:initial;--un-outline-style:solid;--un-outline-opacity:100%}}@property --un-text-opacity{syntax:"<percentage>";inherits:false;initial-value:100%}@property --un-leading{syntax:"*";inherits:false}@property --un-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --un-outline-opacity{syntax:"<percentage>";inherits:false;initial-value:100%}@property --un-border-opacity{syntax:"<percentage>";inherits:false;initial-value:100%}@property --un-bg-opacity{syntax:"<percentage>";inherits:false;initial-value:100%}@property --un-inset-ring-color{syntax:"*";inherits:false}@property --un-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --un-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --un-inset-shadow-color{syntax:"*";inherits:false}@property --un-ring-color{syntax:"*";inherits:false}@property --un-ring-inset{syntax:"*";inherits:false}@property --un-ring-offset-color{syntax:"*";inherits:false}@property --un-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --un-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0}@property --un-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --un-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --un-shadow-color{syntax:"*";inherits:false}@property --un-translate-x{syntax:"*";inherits:false;initial-value:0}@property --un-translate-y{syntax:"*";inherits:false;initial-value:0}@property --un-translate-z{syntax:"*";inherits:false;initial-value:0}@property --un-space-y-reverse{syntax:"*";inherits:false;initial-value:0}:root,:host{--spacing:.25rem;--radius-DEFAULT:.25rem;--colors-gray-DEFAULT:#99a1af;--text-sm-fontSize:.875rem;--text-sm-lineHeight:1.25rem;--default-transition-timingFunction:cubic-bezier(.4,0,.2,1);--default-transition-duration:.15s;--radius-md:.375rem;--radius-xl:.75rem;--fontWeight-medium:500;--radius-sm:.25rem;--colors-blue-DEFAULT:#54a2ff;--colors-red-DEFAULT:#ff6568;--text-2xl-fontSize:1.5rem;--text-2xl-lineHeight:2rem;--text-xs-fontSize:.75rem;--text-xs-lineHeight:1rem;--colors-green-DEFAULT:#05df72;--colors-black:#000;--font-sans:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";--font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--default-font-family:var(--font-sans);--default-monoFont-family:var(--font-mono)}@supports (color:lab(0% 0 0)){:root,:host{--colors-gray-DEFAULT:lab(65.9269% -.832677 -8.17474);--colors-blue-DEFAULT:lab(65.0361% -1.42065 -56.9802);--colors-red-DEFAULT:lab(63.7053% 60.745 31.3109);--colors-green-DEFAULT:lab(78.503% -64.9264 39.7492)}}*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji");font-feature-settings:var(--default-font-featureSettings,normal);font-variation-settings:var(--default-font-variationSettings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-monoFont-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace);font-feature-settings:var(--default-monoFont-featureSettings,normal);font-variation-settings:var(--default-monoFont-variationSettings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden~=until-found])){display:none!important}.container{width:100%}.aic{align-items:center}@media (min-width:40rem){.container{max-width:40rem}}@media (min-width:48rem){.container{max-width:48rem}}@media (min-width:64rem){.container{max-width:64rem}}@media (min-width:80rem){.container{max-width:80rem}}@media (min-width:96rem){.container{max-width:96rem}}.text-2xl{font-size:var(--text-2xl-fontSize);line-height:var(--un-leading,var(--text-2xl-lineHeight))}.text-3{font-size:.75rem}.text-3\.5{font-size:.875rem}.text-4{font-size:1rem}.text-xs{font-size:var(--text-xs-fontSize);line-height:var(--un-leading,var(--text-xs-lineHeight))}.c-\#1e3a8a{color:color-mix(in oklab,#1e3a8a var(--un-text-opacity),transparent)}.c-\#7c2d12{color:color-mix(in oklab,#7c2d12 var(--un-text-opacity),transparent)}.c-blue{color:color-mix(in srgb,var(--colors-blue-DEFAULT)var(--un-text-opacity),transparent)}.c-gray\/70{color:color-mix(in srgb,var(--colors-gray-DEFAULT)70%,transparent)}.c-red\/75{color:color-mix(in srgb,var(--colors-red-DEFAULT)75%,transparent)}.leading-5{--un-leading:calc(4px*5);line-height:20px}.lh-\[1\]{--un-leading:1;line-height:1}.font-medium{--un-font-weight:var(--fontWeight-medium);font-weight:var(--fontWeight-medium)}.m9{margin:36px}.mx-1{margin-inline:4px}.mx-3\!{margin-inline:12px!important}.my-1{margin-block:4px}.ml{margin-left:16px}.ml-\.5{margin-left:2px}.ml-1{margin-left:4px}.mr--1{margin-right:-4px}.mr-1{margin-right:4px}.mr-2{margin-right:8px}.mr-2\.5{margin-right:10px}.mt-1{margin-top:4px}.p-1{padding:4px}.p-4\!{padding:16px!important}.px,.px-4{padding-inline:16px}.px-1\.5{padding-inline:6px}.px-2{padding-inline:8px}.py-1{padding-block:4px}.py-1\.5{padding-block:6px}.py-2{padding-block:8px}.pl-1{padding-left:4px}.pl-4{padding-left:16px}.pr-4{padding-right:16px}.ps{padding-inline-start:16px}.outline-0{outline-style:var(--un-outline-style);outline-width:0}.outline-2{outline-style:var(--un-outline-style);outline-width:2px}.outline-blue{outline-color:color-mix(in srgb,var(--colors-blue-DEFAULT)var(--un-outline-opacity),transparent)}.outline-none{--un-outline-style:none;outline-style:none}.b,.b-1,.border{border-width:1px}.b-r-0{border-right-width:0}.b-\#00000000\!{border-color:color-mix(in oklab,#0000 var(--un-border-opacity),transparent)!important}.b-\#4f7ff0{border-color:color-mix(in oklab,#4f7ff0 var(--un-border-opacity),transparent)}.b-\#f59e0b{border-color:color-mix(in oklab,#f59e0b var(--un-border-opacity),transparent)}.rd-2{border-radius:.5rem}.rd-sm{border-radius:var(--radius-sm)}.rounded-md{border-radius:var(--radius-md)}.rounded-xl{border-radius:var(--radius-xl)}.rd-l-4{border-top-left-radius:1rem;border-bottom-left-radius:1rem}.b-dashed{--un-border-style:dashed;border-style:dashed}.b-solid{--un-border-style:solid;border-style:solid}.bg-\#dbe6ff\/75{background-color:#dbe6ffbf;background-color:lab(91.0303% -.143617 -13.4803/.75)}.bg-\#fff{background-color:color-mix(in oklab,#fff var(--un-bg-opacity),transparent)}.bg-\#fff3d6\/85{background-color:#fff3d6d9;background-color:lab(96.236% .744313 15.5662/.85)}.bg-blue\/20\!{background-color:color-mix(in srgb,var(--colors-blue-DEFAULT)20%,transparent)!important}.bg-gray\/20{background-color:color-mix(in srgb,var(--colors-gray-DEFAULT)20%,transparent)}.bg-green\!{background-color:color-mix(in srgb,var(--colors-green-DEFAULT)var(--un-bg-opacity),transparent)!important}.bg-red\!{background-color:color-mix(in srgb,var(--colors-red-DEFAULT)var(--un-bg-opacity),transparent)!important}.bg-transparent{background-color:#0000}.hover\:bg-black\/8:hover{background-color:color-mix(in srgb,var(--colors-black)8%,transparent)}.op-0{opacity:0}.op-15{opacity:.15}.op-60{opacity:.6}.op-75{opacity:.75}.op40{opacity:.4}.group:hover .group-hover\:op-100{opacity:1}.flex{display:flex}.flex-1{flex:1}.flex-shrink{flex-shrink:1}.flex-shrink-0{flex-shrink:0}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.gap-1{gap:4px}.gap-1\.5{gap:6px}.gap-2{gap:8px}.grid{display:grid}.size-3\.5{width:14px;height:14px}.size-4\!{width:16px!important;height:16px!important}.size-full{width:100%;height:100%}.h-1\!{height:4px!important}.h-6{height:24px}.h-a\!{height:auto!important}.h-full{height:100%}.max-h-100{max-height:400px}.max-h-inherit{max-height:inherit}.min-h-16{min-height:64px}.min-h-40{min-height:160px}.min-h-a\!{min-height:auto!important}.min-w-24{min-width:96px}.min-w-52{min-width:208px}.w-10{width:40px}.w-10px\!{width:10px!important}.w-a\!{width:auto!important}.after\:h-1:after{height:4px}.after\:w-1:after{width:4px}.inline{display:inline}.block{display:block}.inline-block{display:inline-block}.contents{display:contents}.hidden{display:none}.visible{visibility:visible}.collapse{visibility:collapse}.cursor-s-resize{cursor:s-resize}.cursor-w-resize{cursor:w-resize}.pointer-events-none{pointer-events:none}.resize{resize:both}.resize-none{resize:none}.select-none{-webkit-user-select:none;user-select:none}.shadow-sm{--un-shadow:0 1px 3px 0 var(--un-shadow-color,#0000001a),0 1px 2px -1px var(--un-shadow-color,#0000001a);box-shadow:var(--un-inset-shadow),var(--un-inset-ring-shadow),var(--un-ring-offset-shadow),var(--un-ring-shadow),var(--un-shadow)}.translate-x--1\/2{--un-translate-x:-50%;translate:var(--un-translate-x)var(--un-translate-y)}.translate-x-1\/2{--un-translate-x:50%;translate:var(--un-translate-x)var(--un-translate-y)}.translate-y--1\/2{--un-translate-y:-50%;translate:var(--un-translate-x)var(--un-translate-y)}.transform{transform:var(--un-rotate-x)var(--un-rotate-y)var(--un-rotate-z)var(--un-skew-x)var(--un-skew-y)}.transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,--un-gradient-from,--un-gradient-via,--un-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter;transition-timing-function:var(--un-ease,var(--default-transition-timingFunction));transition-duration:var(--un-duration,var(--default-transition-duration))}.transition-opacity{transition-property:opacity;transition-timing-function:var(--un-ease,var(--default-transition-timingFunction));transition-duration:var(--un-duration,var(--default-transition-duration))}.items-start{align-items:flex-start}.items-center{align-items:center}.box-border{box-sizing:border-box}.inset-0{inset:0}.bottom-0{bottom:0}.left--0,.left-0{left:0}.right-0{right:0}.top-0{top:0}.top-1\/2{top:50%}.justify-end\!{justify-content:flex-end!important}.justify-center{justify-content:center}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.sticky{position:sticky}.z--1{z-index:-1}.z-1{z-index:1}.z-2{z-index:2}.z-9{z-index:9}.overflow-auto{overflow:auto}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.animate-spin{animation:1s linear infinite spin}.filter{filter:var(--un-blur,)var(--un-brightness,)var(--un-contrast,)var(--un-grayscale,)var(--un-hue-rotate,)var(--un-invert,)var(--un-saturate,)var(--un-sepia,)var(--un-drop-shadow,)}.table{display:table}.table-cell{display:table-cell}:where(.space-y-5>:not(:last-child)){--un-space-y-reverse:0;margin-block-start:calc(calc(4px*5)*var(--un-space-y-reverse));margin-block-end:calc(calc(4px*5)*calc(1 - var(--un-space-y-reverse)))}@supports (color:color-mix(in lab, red, red)){.c-blue{color:color-mix(in oklab,var(--colors-blue-DEFAULT)var(--un-text-opacity),transparent)}.c-gray\/70{color:color-mix(in oklab,var(--colors-gray-DEFAULT)70%,transparent)}.c-red\/75{color:color-mix(in oklab,var(--colors-red-DEFAULT)75%,transparent)}.outline-blue{outline-color:color-mix(in oklab,var(--colors-blue-DEFAULT)var(--un-outline-opacity),transparent)}.bg-blue\/20\!{background-color:color-mix(in oklab,var(--colors-blue-DEFAULT)20%,transparent)!important}.bg-gray\/20{background-color:color-mix(in oklab,var(--colors-gray-DEFAULT)20%,transparent)}.bg-green\!{background-color:color-mix(in oklab,var(--colors-green-DEFAULT)var(--un-bg-opacity),transparent)!important}.bg-red\!{background-color:color-mix(in oklab,var(--colors-red-DEFAULT)var(--un-bg-opacity),transparent)!important}.hover\:bg-black\/8:hover{background-color:color-mix(in oklab,var(--colors-black)8%,transparent)}}
1
+ @supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--un-bg-opacity:100%;--un-leading:initial;--un-content:"";--un-translate-x:initial;--un-translate-y:initial;--un-translate-z:initial;--un-text-opacity:100%;--un-border-opacity:100%;--un-space-y-reverse:initial;--un-space-x-reverse:initial;--un-outline-style:solid;--un-outline-opacity:100%}}@property --un-text-opacity{syntax:"<percentage>";inherits:false;initial-value:100%}@property --un-leading{syntax:"*";inherits:false}@property --un-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --un-outline-opacity{syntax:"<percentage>";inherits:false;initial-value:100%}@property --un-border-opacity{syntax:"<percentage>";inherits:false;initial-value:100%}@property --un-bg-opacity{syntax:"<percentage>";inherits:false;initial-value:100%}@property --un-inset-ring-color{syntax:"*";inherits:false}@property --un-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --un-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --un-inset-shadow-color{syntax:"*";inherits:false}@property --un-ring-color{syntax:"*";inherits:false}@property --un-ring-inset{syntax:"*";inherits:false}@property --un-ring-offset-color{syntax:"*";inherits:false}@property --un-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --un-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0}@property --un-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --un-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --un-shadow-color{syntax:"*";inherits:false}@property --un-translate-x{syntax:"*";inherits:false;initial-value:0}@property --un-translate-y{syntax:"*";inherits:false;initial-value:0}@property --un-translate-z{syntax:"*";inherits:false;initial-value:0}@property --un-numeric-figure{syntax:"*";inherits:false}@property --un-numeric-fraction{syntax:"*";inherits:false}@property --un-numeric-spacing{syntax:"*";inherits:false}@property --un-ordinal{syntax:"*";inherits:false}@property --un-slashed-zero{syntax:"*";inherits:false}@property --un-space-y-reverse{syntax:"*";inherits:false;initial-value:0}:root,:host{--spacing:.25rem;--radius-DEFAULT:.25rem;--colors-gray-DEFAULT:#99a1af;--text-sm-fontSize:.875rem;--text-sm-lineHeight:1.25rem;--default-transition-timingFunction:cubic-bezier(.4,0,.2,1);--default-transition-duration:.15s;--radius-md:.375rem;--radius-xl:.75rem;--fontWeight-medium:500;--fontWeight-semibold:600;--tracking-wide:.025em;--font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--radius-sm:.25rem;--colors-blue-DEFAULT:#54a2ff;--colors-red-DEFAULT:#ff6568;--text-2xl-fontSize:1.5rem;--text-2xl-lineHeight:2rem;--text-xs-fontSize:.75rem;--text-xs-lineHeight:1rem;--colors-green-DEFAULT:#05df72;--colors-black:#000;--font-sans:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";--default-font-family:var(--font-sans);--default-monoFont-family:var(--font-mono)}@supports (color:lab(0% 0 0)){:root,:host{--colors-gray-DEFAULT:lab(65.9269% -.832677 -8.17474);--colors-blue-DEFAULT:lab(65.0361% -1.42065 -56.9802);--colors-red-DEFAULT:lab(63.7053% 60.745 31.3109);--colors-green-DEFAULT:lab(78.503% -64.9264 39.7492)}}*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji");font-feature-settings:var(--default-font-featureSettings,normal);font-variation-settings:var(--default-font-variationSettings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-monoFont-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace);font-feature-settings:var(--default-monoFont-featureSettings,normal);font-variation-settings:var(--default-monoFont-variationSettings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden~=until-found])){display:none!important}.container{width:100%}.aic{align-items:center}@media (min-width:40rem){.container{max-width:40rem}}@media (min-width:48rem){.container{max-width:48rem}}@media (min-width:64rem){.container{max-width:64rem}}@media (min-width:80rem){.container{max-width:80rem}}@media (min-width:96rem){.container{max-width:96rem}}.text-2xl{font-size:var(--text-2xl-fontSize);line-height:var(--un-leading,var(--text-2xl-lineHeight))}.text-3{font-size:.75rem}.text-3\.5{font-size:.875rem}.text-4{font-size:1rem}.text-sm{font-size:var(--text-sm-fontSize);line-height:var(--un-leading,var(--text-sm-lineHeight))}.text-xs{font-size:var(--text-xs-fontSize);line-height:var(--un-leading,var(--text-xs-lineHeight))}.c-\[--c-primary\]{color:color-mix(in oklab,var(--c-primary)var(--un-text-opacity),transparent)}.c-\#1e3a8a{color:color-mix(in oklab,#1e3a8a var(--un-text-opacity),transparent)}.c-\#7c2d12{color:color-mix(in oklab,#7c2d12 var(--un-text-opacity),transparent)}.c-blue{color:color-mix(in srgb,var(--colors-blue-DEFAULT)var(--un-text-opacity),transparent)}.c-gray\/70{color:color-mix(in srgb,var(--colors-gray-DEFAULT)70%,transparent)}.c-red\/75{color:color-mix(in srgb,var(--colors-red-DEFAULT)75%,transparent)}.leading-5{--un-leading:calc(4px*5);line-height:20px}.lh-\[1\]{--un-leading:1;line-height:1}.tracking-wide{--un-tracking:var(--tracking-wide);letter-spacing:var(--tracking-wide)}.font-medium{--un-font-weight:var(--fontWeight-medium);font-weight:var(--fontWeight-medium)}.font-mono{font-family:var(--font-mono)}.font-semibold{--un-font-weight:var(--fontWeight-semibold);font-weight:var(--fontWeight-semibold)}.m9{margin:36px}.mx-1{margin-inline:4px}.mx-3\!{margin-inline:12px!important}.my-1{margin-block:4px}.ml{margin-left:16px}.ml-\.5{margin-left:2px}.ml-1{margin-left:4px}.mr--1{margin-right:-4px}.mr-1{margin-right:4px}.mr-2{margin-right:8px}.mr-2\.5{margin-right:10px}.mt-1{margin-top:4px}.p-1{padding:4px}.p-4\!{padding:16px!important}.px,.px-4{padding-inline:16px}.px-1\.5{padding-inline:6px}.px-2{padding-inline:8px}.px-3{padding-inline:12px}.py-1{padding-block:4px}.py-1\.5{padding-block:6px}.py-2{padding-block:8px}.pl-1{padding-left:4px}.pl-4{padding-left:16px}.pr-4{padding-right:16px}.ps{padding-inline-start:16px}.outline-0{outline-style:var(--un-outline-style);outline-width:0}.outline-2{outline-style:var(--un-outline-style);outline-width:2px}.outline-blue{outline-color:color-mix(in srgb,var(--colors-blue-DEFAULT)var(--un-outline-opacity),transparent)}.outline-none{--un-outline-style:none;outline-style:none}.b,.b-1,.border{border-width:1px}.b-r-0{border-right-width:0}.b-\#00000000\!{border-color:color-mix(in oklab,#0000 var(--un-border-opacity),transparent)!important}.b-\#4f7ff0{border-color:color-mix(in oklab,#4f7ff0 var(--un-border-opacity),transparent)}.b-\#f59e0b{border-color:color-mix(in oklab,#f59e0b var(--un-border-opacity),transparent)}.rd-1{border-radius:.25rem}.rd-1\.5{border-radius:.375rem}.rd-2{border-radius:.5rem}.rd-sm{border-radius:var(--radius-sm)}.rounded-md{border-radius:var(--radius-md)}.rounded-xl{border-radius:var(--radius-xl)}.rd-l-4{border-top-left-radius:1rem;border-bottom-left-radius:1rem}.b-dashed{--un-border-style:dashed;border-style:dashed}.b-solid{--un-border-style:solid;border-style:solid}.bg-\[--table-header-bg\]{background-color:color-mix(in oklab,var(--table-header-bg)var(--un-bg-opacity),transparent)}.bg-\#dbe6ff\/75{background-color:#dbe6ffbf;background-color:lab(91.0303% -.143617 -13.4803/.75)}.bg-\#fff{background-color:color-mix(in oklab,#fff var(--un-bg-opacity),transparent)}.bg-\#fff3d6\/85{background-color:#fff3d6d9;background-color:lab(96.236% .744313 15.5662/.85)}.bg-blue\/20\!{background-color:color-mix(in srgb,var(--colors-blue-DEFAULT)20%,transparent)!important}.bg-gray\/20{background-color:color-mix(in srgb,var(--colors-gray-DEFAULT)20%,transparent)}.bg-green\!{background-color:color-mix(in srgb,var(--colors-green-DEFAULT)var(--un-bg-opacity),transparent)!important}.bg-red\!{background-color:color-mix(in srgb,var(--colors-red-DEFAULT)var(--un-bg-opacity),transparent)!important}.bg-transparent{background-color:#0000}.hover\:bg-\[--li-hover-bg\]:hover{background-color:color-mix(in oklab,var(--li-hover-bg)var(--un-bg-opacity),transparent)}.hover\:bg-black\/8:hover{background-color:color-mix(in srgb,var(--colors-black)8%,transparent)}.op-0{opacity:0}.op-15{opacity:.15}.op-60{opacity:.6}.op-75{opacity:.75}.op40{opacity:.4}.opacity-50{opacity:.5}.group:hover .group-hover\:op-100{opacity:1}.hover\:underline:hover{text-decoration-line:underline}.flex{display:flex}.flex-1{flex:1}.flex-none{flex:none}.flex-shrink{flex-shrink:1}.flex-shrink-0,.shrink-0{flex-shrink:0}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.gap-1{gap:4px}.gap-1\.5{gap:6px}.gap-2{gap:8px}.grid{display:grid}.size-3\.5{width:14px;height:14px}.size-4\!{width:16px!important;height:16px!important}.size-full{width:100%;height:100%}.h-1\!{height:4px!important}.h-3\.5{height:14px}.h-6{height:24px}.h-6\.5{height:26px}.h-a\!{height:auto!important}.h-full{height:100%}.max-h-100{max-height:400px}.max-h-60{max-height:240px}.max-h-inherit{max-height:inherit}.min-h-16{min-height:64px}.min-h-40{min-height:160px}.min-h-a\!{min-height:auto!important}.min-w-24{min-width:96px}.min-w-44{min-width:176px}.min-w-52{min-width:208px}.w-10{width:40px}.w-10px\!{width:10px!important}.w-3\.5{width:14px}.w-6\.5{width:26px}.w-a\!{width:auto!important}.w-full{width:100%}.after\:h-1:after{height:4px}.after\:w-1:after{width:4px}.inline{display:inline}.block{display:block}.inline-block{display:inline-block}.contents{display:contents}.hidden{display:none}.visible{visibility:visible}.collapse{visibility:collapse}.cursor-pointer{cursor:pointer}.cursor-s-resize{cursor:s-resize}.cursor-w-resize{cursor:w-resize}.pointer-events-auto{pointer-events:auto}.pointer-events-none{pointer-events:none}.resize{resize:both}.resize-none{resize:none}.select-none{-webkit-user-select:none;user-select:none}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.uppercase{text-transform:uppercase}.shadow-inner{--un-shadow:inset 0 2px 4px 0 var(--un-shadow-color,#0000000d);box-shadow:var(--un-inset-shadow),var(--un-inset-ring-shadow),var(--un-ring-offset-shadow),var(--un-ring-shadow),var(--un-shadow)}.shadow-sm{--un-shadow:0 1px 3px 0 var(--un-shadow-color,#0000001a),0 1px 2px -1px var(--un-shadow-color,#0000001a);box-shadow:var(--un-inset-shadow),var(--un-inset-ring-shadow),var(--un-ring-offset-shadow),var(--un-ring-shadow),var(--un-shadow)}.shadow-xl{--un-shadow:0 20px 25px -5px var(--un-shadow-color,#0000001a),0 8px 10px -6px var(--un-shadow-color,#0000001a);box-shadow:var(--un-inset-shadow),var(--un-inset-ring-shadow),var(--un-ring-offset-shadow),var(--un-ring-shadow),var(--un-shadow)}.translate-x--1\/2{--un-translate-x:-50%;translate:var(--un-translate-x)var(--un-translate-y)}.translate-x-1\/2{--un-translate-x:50%;translate:var(--un-translate-x)var(--un-translate-y)}.translate-y--1\/2{--un-translate-y:-50%;translate:var(--un-translate-x)var(--un-translate-y)}.transform{transform:var(--un-rotate-x)var(--un-rotate-y)var(--un-rotate-z)var(--un-skew-x)var(--un-skew-y)}.transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,--un-gradient-from,--un-gradient-via,--un-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter;transition-timing-function:var(--un-ease,var(--default-transition-timingFunction));transition-duration:var(--un-duration,var(--default-transition-duration))}.transition-opacity{transition-property:opacity;transition-timing-function:var(--un-ease,var(--default-transition-timingFunction));transition-duration:var(--un-duration,var(--default-transition-duration))}.items-start{align-items:flex-start}.items-center{align-items:center}.box-border{box-sizing:border-box}.inset-0{inset:0}.bottom-0{bottom:0}.left--0,.left-0{left:0}.right-0{right:0}.top-0{top:0}.top-1\/2{top:50%}.justify-end\!{justify-content:flex-end!important}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.sticky{position:sticky}.z--1{z-index:-1}.z-1{z-index:1}.z-2{z-index:2}.z-9{z-index:9}.overflow-auto{overflow:auto}.of-y-auto{overflow-y:auto}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.animate-spin{animation:1s linear infinite spin}.filter{filter:var(--un-blur,)var(--un-brightness,)var(--un-contrast,)var(--un-grayscale,)var(--un-hue-rotate,)var(--un-invert,)var(--un-saturate,)var(--un-sepia,)var(--un-drop-shadow,)}.table{display:table}.table-cell{display:table-cell}.tabular-nums{--un-numeric-spacing:tabular-nums;font-variant-numeric:var(--un-ordinal,)var(--un-slashed-zero,)var(--un-numeric-figure,)var(--un-numeric-spacing,)var(--un-numeric-fraction,)}:where(.space-y-5>:not(:last-child)){--un-space-y-reverse:0;margin-block-start:calc(calc(4px*5)*var(--un-space-y-reverse));margin-block-end:calc(calc(4px*5)*calc(1 - var(--un-space-y-reverse)))}@supports (color:color-mix(in lab, red, red)){.c-blue{color:color-mix(in oklab,var(--colors-blue-DEFAULT)var(--un-text-opacity),transparent)}.c-gray\/70{color:color-mix(in oklab,var(--colors-gray-DEFAULT)70%,transparent)}.c-red\/75{color:color-mix(in oklab,var(--colors-red-DEFAULT)75%,transparent)}.outline-blue{outline-color:color-mix(in oklab,var(--colors-blue-DEFAULT)var(--un-outline-opacity),transparent)}.bg-blue\/20\!{background-color:color-mix(in oklab,var(--colors-blue-DEFAULT)20%,transparent)!important}.bg-gray\/20{background-color:color-mix(in oklab,var(--colors-gray-DEFAULT)20%,transparent)}.bg-green\!{background-color:color-mix(in oklab,var(--colors-green-DEFAULT)var(--un-bg-opacity),transparent)!important}.bg-red\!{background-color:color-mix(in oklab,var(--colors-red-DEFAULT)var(--un-bg-opacity),transparent)!important}.hover\:bg-black\/8:hover{background-color:color-mix(in oklab,var(--colors-black)8%,transparent)}}
@@ -3,7 +3,7 @@ import { type createFloatingProps, type ReferenceType } from 'floating-ui-solid'
3
3
  import type { AutoUpdateOptions } from '@floating-ui/dom';
4
4
  export declare function Popover(attrs: FloatingProps): JSX.Element;
5
5
  type FloatingProps = {
6
- reference: ReferenceType;
6
+ reference: ReferenceType | JSX.Element;
7
7
  floating?: JSX.Element | (() => JSX.Element);
8
8
  portal?: HTMLElement;
9
9
  trigger?: 'click' | 'hover';
package/dist/index.d.ts CHANGED
@@ -12,10 +12,14 @@ import './plugins/ResizePlugin';
12
12
  import './plugins/DragPlugin';
13
13
  import './plugins/RowGroupPlugin';
14
14
  import './plugins/ExpandPlugin';
15
+ import './plugins/SortPlugin';
15
16
  import './plugins/CellMergePlugin';
16
17
  import './plugins/TreePlugin';
17
18
  import './plugins/HeaderGroup';
18
19
  import './plugins/ValidatorPlugin';
20
+ import './plugins/AggregatePlugin';
21
+ import './plugins/AutoFillPlugin';
22
+ import './plugins/FilterPlugin';
19
23
  export declare const Ctx: import("solid-js").Context<{
20
24
  props: TableProps2;
21
25
  store: TableStore;
@@ -143,7 +147,7 @@ export interface TableStore extends Obj {
143
147
  height: number;
144
148
  }>[];
145
149
  internal: symbol;
146
- raw: symbol;
150
+ raw: any;
147
151
  props: TableProps2;
148
152
  rawProps: TableProps;
149
153
  ID: string;
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
+ import { renderComponent, solidComponent } from "./components/utils.js";
1
2
  import { unFn } from "./utils.js";
2
3
  import './style.css';;/* empty css */
3
4
  /* empty css */
4
5
  import { CellSelectionPlugin } from "./plugins/CellSelectionPlugin.js";
5
6
  import { ClipboardPlugin } from "./plugins/CopyPastePlugin.js";
6
7
  import { EditablePlugin } from "./plugins/EditablePlugin.js";
7
- import { renderComponent, solidComponent } from "./components/utils.js";
8
8
  import { RenderPlugin } from "./plugins/RenderPlugin/index.js";
9
9
  import { MenuPlugin } from "./plugins/MenuPlugin.js";
10
10
  import { CommandPlugin } from "./plugins/CommandPlugin.js";
@@ -13,10 +13,15 @@ import { ResizePlugin } from "./plugins/ResizePlugin.js";
13
13
  import { DragPlugin } from "./plugins/DragPlugin.js";
14
14
  import { RowGroupPlugin } from "./plugins/RowGroupPlugin.js";
15
15
  import { ExpandPlugin } from "./plugins/ExpandPlugin.js";
16
+ import { SortPlugin } from "./plugins/SortPlugin.js";
16
17
  import { CellMergePlugin } from "./plugins/CellMergePlugin.js";
17
18
  import { TreePlugin } from "./plugins/TreePlugin.js";
18
19
  import { HeaderGroupPlugin } from "./plugins/HeaderGroup.js";
19
20
  import { ValidatorPlugin } from "./plugins/ValidatorPlugin.js";
21
+ import { AggregatePlugin } from "./plugins/AggregatePlugin.js";
22
+ import { AutoFillPlugin } from "./plugins/AutoFillPlugin.js";
23
+ import { FilterPlugin } from "./plugins/FilterPlugin.js";
24
+ import { ImportExportPlugin } from "./plugins/ImportExportPlugin.js";
20
25
  import loading_bold_default from "./loading-bold.js";
21
26
  import { createComponent, insert, memo, mergeProps, spread, template, use } from "solid-js/web";
22
27
  import { $PROXY, For, batch, createContext, createEffect, createMemo, createSignal, getOwner, mapArray, mergeProps as mergeProps$1, on, onCleanup, onMount, runWithOwner, untrack, useContext } from "solid-js";
@@ -30,29 +35,29 @@ var _tmpl$ = /* @__PURE__ */ template("<div>"), _tmpl$2 = /* @__PURE__ */ templa
30
35
  const Ctx = createContext({
31
36
  props: {},
32
37
  store: {}
33
- }), Intable = (K) => {
34
- K = mergeProps$1({ rowKey: "id" }, K);
35
- let q = getOwner(), J = createMutable({
38
+ }), Intable = (_) => {
39
+ _ = mergeProps$1({ rowKey: "id" }, _);
40
+ let K = getOwner(), J = createMutable({
36
41
  get rawProps() {
37
- return K[$PROXY] ||= K;
42
+ return _[$PROXY] ||= _;
38
43
  },
39
44
  get plugins() {
40
45
  return X();
41
46
  }
42
- }), Y = memoize((K) => runWithOwner(q, () => unFn(K, J))), X = createMemo((_) => {
47
+ }), Y = memoize((_) => runWithOwner(K, () => unFn(_, J))), X = createMemo((q) => {
43
48
  let X = [
44
49
  ...defaultsPlugins,
45
- ...K.plugins || [],
50
+ ..._.plugins || [],
46
51
  RenderPlugin
47
- ].map(Y).sort((_, K) => (K.priority || 0) - (_.priority || 0)), Q = difference(X, _);
48
- return runWithOwner(q, () => {
52
+ ].map(Y).sort((_, K) => (K.priority || 0) - (_.priority || 0)), Q = difference(X, q);
53
+ return runWithOwner(K, () => {
49
54
  Q.forEach((_) => Object.assign(J, _.store?.(J)));
50
55
  }), X;
51
56
  }, []);
52
57
  J.props = (() => {
53
- let _ = getOwner(), q = {}, Y = (K) => q[K] ??= runWithOwner(_, () => createMemo(() => Z(K)));
54
- function Z(_) {
55
- return createMemo(() => X().map((K) => K.rewriteProps?.[_]).filter((_) => _), void 0, { equals: isEqual })().reduce((K, q) => q({ [_]: K }, { store: J }), K[_]);
58
+ let K = getOwner(), q = {}, Y = (_) => q[_] ??= runWithOwner(K, () => createMemo(() => Z(_)));
59
+ function Z(K) {
60
+ return createMemo(() => X().map((_) => _.rewriteProps?.[K]).filter((_) => _), void 0, { equals: isEqual })().reduce((_, q) => q({ [K]: _ }, { store: J }), _[K]);
56
61
  }
57
62
  return new Proxy({}, { get(_, K, q) {
58
63
  return K == $PROXY ? q : Y(K)();
@@ -79,22 +84,22 @@ const Ctx = createContext({
79
84
  });
80
85
  };
81
86
  var THead = () => {
82
- let { props: _, store: K } = useContext(Ctx);
83
- return createComponent(_.Thead, { get children() {
84
- return createComponent(_.Tr, { get children() {
85
- return createComponent(_.EachCells, {
87
+ let { props: K, store: q } = useContext(Ctx);
88
+ return createComponent(K.Thead, { get children() {
89
+ return createComponent(K.Tr, { get children() {
90
+ return createComponent(K.EachCells, {
86
91
  get each() {
87
- return _.columns || [];
92
+ return K.columns || [];
88
93
  },
89
- children: (q, J) => createComponent(_.Th, {
94
+ children: (J, Y) => createComponent(K.Th, {
90
95
  get col() {
91
- return q();
96
+ return J();
92
97
  },
93
98
  get x() {
94
- return J();
99
+ return Y();
95
100
  },
96
101
  get children() {
97
- return renderComponent(q().name, void 0, K);
102
+ return renderComponent(J().name, void 0, q);
98
103
  }
99
104
  })
100
105
  });
@@ -143,10 +148,10 @@ var THead = () => {
143
148
  } });
144
149
  }, src_default = Intable;
145
150
  function BasePlugin() {
146
- let K = {
151
+ let _ = {
147
152
  col: null,
148
153
  data: null
149
- }, q = (_) => (() => {
154
+ }, K = (_) => (() => {
150
155
  var K = _tmpl$();
151
156
  return spread(K, _, !1, !1), K;
152
157
  })(), J = (_) => (() => {
@@ -158,15 +163,15 @@ function BasePlugin() {
158
163
  })(), X = (_) => (() => {
159
164
  var K = _tmpl$4();
160
165
  return spread(K, _, !1, !1), K;
161
- })(), Z = (_) => (() => {
166
+ })(), Z = (K) => (() => {
162
167
  var q = _tmpl$5();
163
- return spread(q, mergeProps(_, K), !1, !1), q;
164
- })(), Q = (_) => (() => {
168
+ return spread(q, mergeProps(K, _), !1, !1), q;
169
+ })(), Q = (K) => (() => {
165
170
  var q = _tmpl$6();
166
- return spread(q, mergeProps(_, K), !1, !1), q;
167
- })(), $ = (_) => (() => {
171
+ return spread(q, mergeProps(K, _), !1, !1), q;
172
+ })(), $ = (K) => (() => {
168
173
  var q = _tmpl$7();
169
- return spread(q, mergeProps(_, K), !1, !1), q;
174
+ return spread(q, mergeProps(K, _), !1, !1), q;
170
175
  })();
171
176
  return {
172
177
  name: "base",
@@ -208,39 +213,41 @@ function BasePlugin() {
208
213
  rewriteProps: {
209
214
  data: ({ data: _ = [] }) => _,
210
215
  columns: ({ columns: _ = [] }) => _,
211
- newRow: ({ newRow: _ = () => ({}) }) => _,
212
- Scroll: ({ Scroll: _ = q }, { store: K }) => (q) => {
213
- let J = createScrollPosition(() => K.scroll_el), Y = createElementSize(() => K.scroll_el), X = createMemo(() => {
214
- let _ = K.scroll_el;
216
+ newRow: ({ newRow: _ }, { store: K }) => function() {
217
+ let q = _?.(...arguments) || {};
218
+ return q[K.props.rowKey] ??= Symbol(), q;
219
+ },
220
+ Scroll: ({ Scroll: _ = K }, { store: q }) => (K) => {
221
+ let J = createScrollPosition(() => q.scroll_el), Y = createElementSize(() => q.scroll_el), X = createMemo(() => {
222
+ let _ = q.scroll_el;
215
223
  if (!_) return;
216
- let q = J.x == 0, X = J.x >= _.scrollWidth - (Y.width || 0);
217
- return q && X ? "" : !q && !X ? "is-scroll-mid" : q ? "is-scroll-left" : X ? "is-scroll-right" : "";
224
+ let K = J.x == 0, X = J.x >= _.scrollWidth - (Y.width || 0);
225
+ return K && X ? "" : !K && !X ? "is-scroll-mid" : K ? "is-scroll-left" : X ? "is-scroll-right" : "";
218
226
  });
219
- q = combineProps(q, { get class() {
220
- return `data-table ${K.props.border && "data-table--border"} data-table--${K.props.size}`;
227
+ K = combineProps(K, { get class() {
228
+ return `data-table ${q.props.border && "data-table--border"} data-table--${q.props.size}`;
221
229
  } }, {
222
230
  get class() {
223
- return K.props.class;
231
+ return q.props.class;
224
232
  },
225
233
  get style() {
226
- return K.props.style;
234
+ return q.props.style;
227
235
  }
228
236
  }, { get class() {
229
237
  return X();
230
238
  } });
231
- let Z = mapArray(() => K.plugins.flatMap((_) => _.layers ?? []), (_) => createComponent(_, K));
232
- return createComponent(_, mergeProps({ tabindex: -1 }, q, { get children() {
233
- return [
234
- (() => {
235
- var _ = _tmpl$8();
236
- return insert(_, Z), _;
237
- })(),
238
- (() => {
239
- var _ = _tmpl$9();
240
- return use((_) => K.scroll_el = _, _), insert(_, () => q.children, null), insert(_, createComponent(K.props.Footer, {}), null), _;
241
- })(),
242
- memo(() => memo(() => !K.props.data.length)() && _tmpl$0())
243
- ];
239
+ let Z = mapArray(() => q.plugins.flatMap((_) => _.layers ?? []), (_) => createComponent(_, q));
240
+ return createComponent(_, mergeProps({ tabindex: -1 }, K, { get children() {
241
+ return [(() => {
242
+ var _ = _tmpl$8();
243
+ return insert(_, Z), _;
244
+ })(), (() => {
245
+ var _ = _tmpl$9();
246
+ return use((_) => q.scroll_el = _, _), insert(_, () => K.children, null), insert(_, createComponent(q.props.Footer, {}), null), insert(_, (() => {
247
+ var _ = memo(() => !q.props.data.length);
248
+ return () => _() && _tmpl$0();
249
+ })(), null), _;
250
+ })()];
244
251
  } }));
245
252
  },
246
253
  Footer: ({ Footer: _ }) => (_ ??= (_) => (() => {
@@ -258,11 +265,11 @@ function BasePlugin() {
258
265
  return q = combineProps({ ref: Y }, q), createEffect(() => {
259
266
  let { y: _ } = q;
260
267
  _ != null && (K.trs[_] = J(), K.trObs.observe(J()), onCleanup(() => {
261
- K.trSizes[_] = K.trs[_] = void 0, K.trObs.unobserve(J());
268
+ K.trObs.unobserve(J()), K.trs[_] = void 0, !(K.props.data.length > _) && (K.trSizes[_] = void 0);
262
269
  }));
263
270
  }), createComponent(_, q);
264
271
  },
265
- Th: ({ Th: K = Q }, { store: q }) => (J) => {
272
+ Th: ({ Th: _ = Q }, { store: K }) => (J) => {
266
273
  let [Y, X] = createSignal(), { props: Z } = useContext(Ctx), Q = combineProps(J, { ref: X }, {
267
274
  get class() {
268
275
  return unFn(Z.cellClass, J);
@@ -278,38 +285,38 @@ function BasePlugin() {
278
285
  return J.col.style;
279
286
  }
280
287
  }, { get style() {
281
- return J.col.width ? `width: ${J.col.width}px` : "";
288
+ return J.col.width ? `width: ${J.col.width}px; max-width: ${J.col.width}px` : "";
282
289
  } });
283
290
  return createEffect(() => {
284
291
  if (J.covered || (J.colspan ?? 1) != 1) return;
285
292
  let { x: _ } = J;
286
- q.ths[_] = Y(), q.thObs.observe(Y()), onCleanup(() => {
287
- q.thSizes[_] = q.ths[_] = void 0, q.thObs.unobserve(Y());
293
+ K.ths[_] = Y(), K.thObs.observe(Y()), onCleanup(() => {
294
+ K.thObs.unobserve(Y()), K.ths[_] = void 0, !(K.props.columns.length > _) && (K.thSizes[_] = void 0);
288
295
  });
289
- }), createComponent(K, mergeProps(Q, { get children() {
296
+ }), createComponent(_, mergeProps(Q, { get children() {
290
297
  return J.children;
291
298
  } }));
292
299
  },
293
- Td: ({ Td: K = $ }, { store: q }) => (q) => {
294
- let { props: J } = useContext(Ctx), Y = combineProps(q, {
300
+ Td: ({ Td: _ = $ }, { store: K }) => (K) => {
301
+ let { props: J } = useContext(Ctx), Y = combineProps(K, {
295
302
  get class() {
296
- return unFn(J.cellClass, q);
303
+ return unFn(J.cellClass, K);
297
304
  },
298
305
  get style() {
299
- return unFn(J.cellStyle, q);
306
+ return unFn(J.cellStyle, K);
300
307
  }
301
308
  }, {
302
309
  get class() {
303
- return q.col.class;
310
+ return K.col.class;
304
311
  },
305
312
  get style() {
306
- return q.col.style;
313
+ return K.col.style;
307
314
  }
308
315
  }, { get style() {
309
- return q.col.width ? `width: ${q.col.width}px` : "";
316
+ return K.col.width ? `width: ${K.col.width}px; max-width: ${K.col.width}px` : "";
310
317
  } });
311
- return createComponent(K, mergeProps(Y, { get children() {
312
- return q.children;
318
+ return createComponent(_, mergeProps(Y, { get children() {
319
+ return K.children;
313
320
  } }));
314
321
  },
315
322
  EachRows: ({ EachRows: _ }) => _ || ((_) => createComponent(For, {
@@ -327,10 +334,10 @@ function BasePlugin() {
327
334
  renderer: ({ renderer: _ = (_) => _ }) => _
328
335
  },
329
336
  layers: [function(_) {
330
- return _.props.loading ? (() => {
337
+ return memo(() => memo(() => !!_.props.loading)() ? (() => {
331
338
  var _ = _tmpl$1();
332
339
  return insert(_, createComponent(loading_bold_default, { class: "text-2xl animate-spin" })), _;
333
- })() : null;
340
+ })() : null);
334
341
  }]
335
342
  };
336
343
  }
@@ -349,12 +356,12 @@ const defaultsPlugins = [
349
356
  } }
350
357
  },
351
358
  HeaderGroupPlugin,
352
- (K) => {
353
- let q = createLazyMemo(() => {
354
- let _ = {};
355
- for (let [q, J] of K.props.columns.entries()) J.fixed === "left" && (_[q] = sumBy(K.thSizes.slice(0, q), (_) => _?.width || 0)), J.fixed === "right" && (_[q] = sumBy(K.thSizes.slice(q + 1), (_) => _?.width || 0));
356
- return _;
357
- }), J = createLazyMemo(() => K.props.columns.filter((_) => _.fixed == "left").length - 1), Y = createLazyMemo(() => K.props.columns.length - K.props.columns.filter((_) => _.fixed == "right").length);
359
+ (_) => {
360
+ let K = createLazyMemo(() => {
361
+ let K = {};
362
+ for (let [q, J] of _.props.columns.entries()) J.fixed === "left" && (K[q] = sumBy(_.thSizes.slice(0, q), (_) => _?.width || 0)), J.fixed === "right" && (K[q] = sumBy(_.thSizes.slice(q + 1), (_) => _?.width || 0));
363
+ return K;
364
+ }), J = createLazyMemo(() => _.props.columns.filter((_) => _.fixed == "left").length - 1), Y = createLazyMemo(() => _.props.columns.length - _.props.columns.filter((_) => _.fixed == "right").length);
358
365
  return {
359
366
  name: "fixed-column",
360
367
  rewriteProps: {
@@ -363,8 +370,8 @@ const defaultsPlugins = [
363
370
  ..._?.filter((_) => !_.fixed) || [],
364
371
  ..._?.filter((_) => _.fixed == "right") || []
365
372
  ],
366
- cellClass: ({ cellClass: K }) => (q) => (unFn(K, q) || "") + (q.col.fixed ? ` fixed-${q.col.fixed} ${q.x == J() ? "is-last" : ""} ${q.x == Y() ? "is-first" : ""}` : ""),
367
- cellStyle: ({ cellStyle: K }) => (J) => (unFn(K, J) || "") + (J.col.fixed ? `; ${J.col.fixed}: ${q()[J.x]}px` : "")
373
+ cellClass: ({ cellClass: _ }) => (K) => (unFn(_, K) || "") + (K.col.fixed ? ` fixed-${K.col.fixed} ${K.x == J() ? "is-last" : ""} ${K.x == Y() ? "is-first" : ""}` : ""),
374
+ cellStyle: ({ cellStyle: _ }) => (J) => (unFn(_, J) || "") + (J.col.fixed ? `; ${J.col.fixed}: ${K()[J.x]}px` : "")
368
375
  }
369
376
  };
370
377
  },
@@ -387,6 +394,7 @@ const defaultsPlugins = [
387
394
  } }),
388
395
  rewriteProps: { columns: ({ columns: _ }, { store: K }) => K.props?.index ? [K.$index, ..._ || []] : _ }
389
396
  },
397
+ SortPlugin,
390
398
  ValidatorPlugin,
391
399
  EditablePlugin,
392
400
  CellMergePlugin,
@@ -411,6 +419,10 @@ const defaultsPlugins = [
411
419
  };
412
420
  },
413
421
  RowGroupPlugin,
414
- ResizePlugin
422
+ ResizePlugin,
423
+ AggregatePlugin,
424
+ AutoFillPlugin,
425
+ FilterPlugin,
426
+ ImportExportPlugin
415
427
  ];
416
428
  export { Ctx, Intable, src_default as default, defaultsPlugins };
@@ -0,0 +1,28 @@
1
+ import { type Plugin, type TableColumn } from '..';
2
+ export type AggregateType = 'sum' | 'avg' | 'count' | 'min' | 'max' | ((values: any[], column: TableColumn, data: any[]) => any);
3
+ declare module '../index' {
4
+ interface TableProps {
5
+ aggregate?: {
6
+ /**
7
+ * Label shown in the first user column when that column itself
8
+ * has no `aggregate` setting. Defaults to `'Σ'`.
9
+ */
10
+ label?: string;
11
+ /**
12
+ * Format a computed aggregate value before display.
13
+ * Return a string/number or a JSX element.
14
+ */
15
+ formatter?: (value: any, type: AggregateType, col: TableColumn) => any;
16
+ };
17
+ }
18
+ interface TableColumn {
19
+ /**
20
+ * Aggregation for this column.
21
+ * - `'sum'` / `'avg'` / `'min'` / `'max'` — numeric operations (NaN values skipped)
22
+ * - `'count'` — counts non-null / non-empty values
23
+ * - function — `(values, col, allData) => displayValue`
24
+ */
25
+ aggregate?: AggregateType;
26
+ }
27
+ }
28
+ export declare const AggregatePlugin: Plugin;
@@ -0,0 +1,71 @@
1
+ import { className, createComponent, effect, insert, style, template } from "solid-js/web";
2
+ import { For, Show, createMemo } from "solid-js";
3
+ var _tmpl$ = /* @__PURE__ */ template("<tfoot class=\"sticky bottom-0 z-2 shadow-inner\"><tr style=font-weight:600>"), _tmpl$2 = /* @__PURE__ */ template("<span class=\"font-mono text-sm tabular-nums c-[--c-primary]\">"), _tmpl$3 = /* @__PURE__ */ template("<td>"), _tmpl$4 = /* @__PURE__ */ template("<span class=\"text-xs font-semibold tracking-wide select-none\">");
4
+ function computeAgg(e, o) {
5
+ let { aggregate: s } = e;
6
+ if (!s) return;
7
+ let c = o.map((o) => o[e.id]).filter((e) => e != null && e !== "");
8
+ if (typeof s == "function") return s(c, e, o);
9
+ if (s === "count") return c.length;
10
+ let l = c.map(Number).filter(isFinite);
11
+ if (!l.length) return "";
12
+ if (s === "sum") return l.reduce((e, o) => e + o, 0);
13
+ if (s === "avg") return +(l.reduce((e, o) => e + o, 0) / l.length).toFixed(2);
14
+ if (s === "min") return Math.min(...l);
15
+ if (s === "max") return Math.max(...l);
16
+ }
17
+ const AggregatePlugin = {
18
+ name: "aggregate",
19
+ rewriteProps: { Tbody: ({ Tbody: u }, { store: m }) => (h) => {
20
+ let g = () => m.props.columns ?? [], _ = createMemo(() => g().some((e) => !!e.aggregate)), v = createMemo(() => g().findIndex((e) => !e[m.internal])), y = () => m.props.aggregate?.label ?? "Σ", b = () => m.props.aggregate?.formatter;
21
+ return [createComponent(u, h), createComponent(Show, {
22
+ get when() {
23
+ return _();
24
+ },
25
+ get children() {
26
+ var u = _tmpl$(), h = u.firstChild;
27
+ return insert(h, createComponent(For, {
28
+ get each() {
29
+ return g();
30
+ },
31
+ children: (u, d) => {
32
+ let p = createMemo(() => {
33
+ let e = computeAgg(u, m.props.data);
34
+ return e != null && b() ? b()(e, u.aggregate, u) : e;
35
+ });
36
+ return (() => {
37
+ var f = _tmpl$3();
38
+ return insert(f, createComponent(Show, {
39
+ get when() {
40
+ return u.aggregate;
41
+ },
42
+ get fallback() {
43
+ return createComponent(Show, {
44
+ get when() {
45
+ return d() === v();
46
+ },
47
+ get children() {
48
+ var e = _tmpl$4();
49
+ return insert(e, y), e;
50
+ }
51
+ });
52
+ },
53
+ get children() {
54
+ var e = _tmpl$2();
55
+ return insert(e, p), e;
56
+ }
57
+ })), effect((o) => {
58
+ var s = `${u.width ? `width:${u.width}px;` : ""}padding:4px 8px;border-top:1px solid var(--table-b-c)`, c = u.class;
59
+ return o.e = style(f, s, o.e), c !== o.t && className(f, o.t = c), o;
60
+ }, {
61
+ e: void 0,
62
+ t: void 0
63
+ }), f;
64
+ })();
65
+ }
66
+ })), u;
67
+ }
68
+ })];
69
+ } }
70
+ };
71
+ export { AggregatePlugin };