@guiexpert/demo-table-models 1.0.23 → 1.0.24
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/index.cjs +1 -1
- package/index.js +259 -1
- package/lib/createTimeTableModel.d.ts +1 -0
- package/lib/treepeople/generateTreePeopleModel.d.ts +1 -0
- package/package.json +2 -2
package/index.cjs
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
data-col-index="${a}"
|
|
11
11
|
data-input-type="text"
|
|
12
12
|
style="width:calc(100% - 8px);height:100%;border:0;padding:0 0 0 8px;"
|
|
13
|
-
class="ge-table-cell-editor-input">`}}}class q{constructor(e="none",r="single"){this.selectionType=e,this.selectionMode=r,this.ranges=[],this.negativeRanges=[],this.allSelected=!1,this.silent=!1,this.listenerArr=[]}getEventSelectionChangedListeners(){return this.listenerArr}addEventSelectionChangedListener(e){this.listenerArr.includes(e)||this.listenerArr.push(e)}removeEventSelectionChangedListener(e){const r=this.listenerArr.indexOf(e,0);r>-1&&this.listenerArr.splice(r,1)}fireChangeEvent(){this.silent||this.listenerArr.forEach(e=>e.onSelectionChanged(this))}firstClick(e,r){this.selectionType==="row"?this.addRange(o.singleRow(e)):this.selectionType==="column"&&this.addRange(o.singleColumn(r))}getSelectionCount(e,r){let a=0;for(const t of this.ranges)t.isInRange(e,r)&&a++;return this.allSelected&&a++,this.isInNegativeRange(e,r)&&(a=0),a}isInNegativeRange(e,r){for(const a of this.negativeRanges)if(a.isInRange(e,r))return!0;return!1}getRanges(){return this.ranges}clear(){this.ranges=[],this.negativeRanges=[],this.allSelected=!1,this.fireChangeEvent()}hasSelection(){return this.allSelected||!!this.ranges.length}hasNoSelection(){return!this.hasSelection()}getMergedRowIndices(){const e=new Set;for(const r of this.ranges)for(let a=r.r1;a<=r.r2;a++)!e.has(a)&&!this.isInNegativeRange(a,0)&&e.add(a);return Array.from(e)}selectAll(){this.allSelected=!0,this.fireChangeEvent()}isAllSelected(){return this.allSelected}addSelection(e){this.addRange(e),this.fireChangeEvent()}removeSelection(e){if(this.selectionType==="none")return;let r=e;this.selectionType==="row"?r=o.singleRow(e.r1):this.selectionType==="column"&&(r=o.singleColumn(e.c1)),this.negativeRanges.push(r),this.fireChangeEvent()}togglePoint(e,r){this.getSelectionCount(e,r)>0?this.removeSelection(o.singleCell(e,r)):this.addSelection(o.singleCell(e,r))}isSelected(e,r){return this.getSelectionCount(e,r)>0}addRange(e){this.selectionType!=="none"&&(this.allSelected=!1,this.selectionMode==="single"&&(this.ranges=[]),this.selectionType==="row"?(e.c1=0,e.c2=Number.MAX_SAFE_INTEGER):this.selectionType==="column"?(e.r1=0,e.r2=Number.MAX_SAFE_INTEGER):this.selectionType==="cell"?(e.r2=e.r1,e.c2=e.c1):this.selectionType,this.ranges.push(e),this.fireChangeEvent())}}class Xe{constructor(e="none"){this.selectionType=e,this.rowIndex=-1,this.columnIndex=-1,this.changed=!1,this.listenerArr=[]}getEventFocusChangedListeners(){return this.listenerArr}addEventFocusChangedListener(e){this.listenerArr.includes(e)||this.listenerArr.push(e)}removeEventFocusChangedListener(e){const r=this.listenerArr.indexOf(e,0);r>-1&&this.listenerArr.splice(r,1)}fireChangeEvent(){this.listenerArr.forEach(e=>e.onFocusChanged(this))}clearChanged(){this.changed=!1}hasChanged(){return this.changed}clear(){this.rowIndex=-1,this.columnIndex=-1,this.fireChangeEvent()}setFocus(e,r){(this.rowIndex!==e||this.columnIndex!==r)&&(this.rowIndex=e,this.columnIndex=r,this.changed=!0,this.fireChangeEvent())}hasFocus(e,r){return this.rowIndex===e&&this.columnIndex===r}getFocus(){return[this.rowIndex,this.columnIndex]}}class ee{constructor(e=new w("❯","",["gt-table-icon-expanded"]),r=new w("❯","transform: rotate(180deg) translate(-100%, -100%); transform-origin: 0 0;",["ge-table-icon-collapsed"])){this.iconExpanded=e,this.iconCollapsed=r}}const Ye=new q,Je=new Xe("cell");class z{constructor(){this.overflowX="auto",this.overflowY="auto",this.horizontalBorderVisible=!0,this.verticalBorderVisible=!0,this.footerSeparatorBorderVisible=!0,this.headerSeparatorBorderVisible=!0,this.fixedEastSeparatorBorderVisible=!0,this.fixedWestSeparatorBorderVisible=!0,this.tableTopBorderVisible=!0,this.tableBottomBorderVisible=!0,this.hoverRowVisible=!0,this.hoverColumnVisible=!0,this.columnsResizable=!0,this.columnsDraggable=!0,this.columnResizeHandleWidthInPx=4,this.defaultRowHeights={header:34,body:34,footer:34},this.footerVerticalSeparator=!1,this.headerToggleExpandCollapseIcons=!1,this.headerVerticalSeparator=!1,this.treeOptions=new We,this.headerGroupOptions=new ee,this.showCheckboxWihoutExtraColumn=!1,this.externalFilterFunction=void 0,this.sortedOptions=new Ke,this.sortOrder=["asc","desc"],this.getEditRenderer=(e,r)=>new je,this.getSelectionModel=()=>Ye,this.getFocusModel=()=>Je}}const D=class D{createContent(e,r,a){return new Promise((t,n)=>{if(r!=null&&r.hasSelection()){const m=this.mergeRanges(r.getRanges());if(m){m.c2=Math.min(m.c2,e.getColumnCount()-1),m.r2=Math.min(m.r2,e.getBodyModel().getRowCount()-1);const d=[];for(let i=m.r1;i<=m.r2;i++){const u=[];for(let p=m.c1;p<=m.c2;p++){const c=r.isSelected(i,p)?e.getBodyModel().getTextValueAt(i,p):"";u.push(c)}d.push(u.join(D.columnSeparatorChar))}return t(d.join(D.rowSeparatorChar))}}if(a){const[m,d]=a.getFocus(),i=e.getBodyModel().getTextValueAt(m,d);return t(i)}n("Cannot copy, neither selection nor focus defined.")})}copyContent(e){return navigator.clipboard.writeText(e)}copyToClipboard(e,r,a){return new Promise((t,n)=>{this.createContent(e,r,a).then(m=>{m&&this.copyContent(m).then(d=>{t(m)}).catch(d=>{n()})}).catch(m=>{n()})})}mergeRanges(e){let r;for(const a of e)r?(r.r1=Math.min(r.r1,a.r1),r.c1=Math.min(r.c1,a.c1),r.r2=Math.max(r.r2,a.r2),r.c2=Math.max(r.c2,a.c2)):r=new o(a.r1,a.c1,a.r2,a.c2);return r}};D.columnSeparatorChar=" ",D.rowSeparatorChar=`
|
|
13
|
+
class="ge-table-cell-editor-input">`}}}class q{constructor(e="none",r="single"){this.selectionType=e,this.selectionMode=r,this.ranges=[],this.negativeRanges=[],this.allSelected=!1,this.silent=!1,this.listenerArr=[]}getEventSelectionChangedListeners(){return this.listenerArr}addEventSelectionChangedListener(e){this.listenerArr.includes(e)||this.listenerArr.push(e)}removeEventSelectionChangedListener(e){const r=this.listenerArr.indexOf(e,0);r>-1&&this.listenerArr.splice(r,1)}fireChangeEvent(){this.silent||this.listenerArr.forEach(e=>e.onSelectionChanged(this))}firstClick(e,r){this.selectionType==="row"?this.addRange(o.singleRow(e)):this.selectionType==="column"&&this.addRange(o.singleColumn(r))}getSelectionCount(e,r){let a=0;for(const t of this.ranges)t.isInRange(e,r)&&a++;return this.allSelected&&a++,this.isInNegativeRange(e,r)&&(a=0),a}isInNegativeRange(e,r){for(const a of this.negativeRanges)if(a.isInRange(e,r))return!0;return!1}getRanges(){return this.ranges}clear(){this.ranges=[],this.negativeRanges=[],this.allSelected=!1,this.fireChangeEvent()}hasSelection(){return this.allSelected||!!this.ranges.length}hasNoSelection(){return!this.hasSelection()}getMergedRowIndices(){const e=new Set;for(const r of this.ranges)for(let a=r.r1;a<=r.r2;a++)!e.has(a)&&!this.isInNegativeRange(a,0)&&e.add(a);return Array.from(e)}selectAll(){this.allSelected=!0,this.fireChangeEvent()}isAllSelected(){return this.allSelected}addSelection(e){this.addRange(e),this.fireChangeEvent()}removeSelection(e){if(this.selectionType==="none")return;let r=e;this.selectionType==="row"?r=o.singleRow(e.r1):this.selectionType==="column"&&(r=o.singleColumn(e.c1)),this.negativeRanges.push(r),this.fireChangeEvent()}togglePoint(e,r){this.getSelectionCount(e,r)>0?this.removeSelection(o.singleCell(e,r)):this.addSelection(o.singleCell(e,r))}isSelected(e,r){return this.getSelectionCount(e,r)>0}addRange(e){this.selectionType!=="none"&&(this.allSelected=!1,this.selectionMode==="single"&&(this.ranges=[]),this.selectionType==="row"?(e.c1=0,e.c2=Number.MAX_SAFE_INTEGER):this.selectionType==="column"?(e.r1=0,e.r2=Number.MAX_SAFE_INTEGER):this.selectionType==="cell"?(e.r2=e.r1,e.c2=e.c1):this.selectionType,this.ranges.push(e),this.fireChangeEvent())}}class Xe{constructor(e="none"){this.selectionType=e,this.rowIndex=-1,this.columnIndex=-1,this.changed=!1,this.listenerArr=[]}getEventFocusChangedListeners(){return this.listenerArr}addEventFocusChangedListener(e){this.listenerArr.includes(e)||this.listenerArr.push(e)}removeEventFocusChangedListener(e){const r=this.listenerArr.indexOf(e,0);r>-1&&this.listenerArr.splice(r,1)}fireChangeEvent(){this.listenerArr.forEach(e=>e.onFocusChanged(this))}clearChanged(){this.changed=!1}hasChanged(){return this.changed}clear(){this.rowIndex=-1,this.columnIndex=-1,this.fireChangeEvent()}setFocus(e,r){(this.rowIndex!==e||this.columnIndex!==r)&&(this.rowIndex=e,this.columnIndex=r,this.changed=!0,this.fireChangeEvent())}hasFocus(e,r){return this.rowIndex===e&&this.columnIndex===r}getFocus(){return[this.rowIndex,this.columnIndex]}}class ee{constructor(e=new w("❯","",["gt-table-icon-expanded"]),r=new w("❯","transform: rotate(180deg) translate(-100%, -100%); transform-origin: 0 0;",["ge-table-icon-collapsed"])){this.iconExpanded=e,this.iconCollapsed=r}}const Ye=new q,Je=new Xe("cell");class z{constructor(){this.overflowX="auto",this.overflowY="auto",this.horizontalBorderVisible=!0,this.verticalBorderVisible=!0,this.footerSeparatorBorderVisible=!0,this.headerSeparatorBorderVisible=!0,this.fixedEastSeparatorBorderVisible=!0,this.fixedWestSeparatorBorderVisible=!0,this.tableTopBorderVisible=!0,this.tableBottomBorderVisible=!0,this.hoverRowVisible=!0,this.hoverColumnVisible=!0,this.columnsResizable=!0,this.columnsDraggable=!0,this.columnResizeHandleWidthInPx=4,this.defaultRowHeights={header:34,body:34,footer:34},this.footerVerticalSeparator=!1,this.headerToggleExpandCollapseIcons=!1,this.headerVerticalSeparator=!1,this.treeOptions=new We,this.headerGroupOptions=new ee,this.showCheckboxWihoutExtraColumn=!1,this.externalFilterFunction=void 0,this.sortedOptions=new Ke,this.sortOrder=["asc","desc"],this.resizeEventDebounceDelay=500,this.getEditRenderer=(e,r)=>new je,this.getSelectionModel=()=>Ye,this.getFocusModel=()=>Je}}const D=class D{createContent(e,r,a){return new Promise((t,n)=>{if(r!=null&&r.hasSelection()){const m=this.mergeRanges(r.getRanges());if(m){m.c2=Math.min(m.c2,e.getColumnCount()-1),m.r2=Math.min(m.r2,e.getBodyModel().getRowCount()-1);const d=[];for(let i=m.r1;i<=m.r2;i++){const u=[];for(let p=m.c1;p<=m.c2;p++){const c=r.isSelected(i,p)?e.getBodyModel().getTextValueAt(i,p):"";u.push(c)}d.push(u.join(D.columnSeparatorChar))}return t(d.join(D.rowSeparatorChar))}}if(a){const[m,d]=a.getFocus(),i=e.getBodyModel().getTextValueAt(m,d);return t(i)}n("Cannot copy, neither selection nor focus defined.")})}copyContent(e){return navigator.clipboard.writeText(e)}copyToClipboard(e,r,a){return new Promise((t,n)=>{this.createContent(e,r,a).then(m=>{m&&this.copyContent(m).then(d=>{t(m)}).catch(d=>{n()})}).catch(m=>{n()})})}mergeRanges(e){let r;for(const a of e)r?(r.r1=Math.min(r.r1,a.r1),r.c1=Math.min(r.c1,a.c1),r.r2=Math.max(r.r2,a.r2),r.c2=Math.max(r.c2,a.c2)):r=new o(a.r1,a.c1,a.r2,a.c2);return r}};D.columnSeparatorChar=" ",D.rowSeparatorChar=`
|
|
14
14
|
`;let me=D;const $=class ${};$.themes=["light","combat","paper","blackboard"],$.vars={light:`html[data-theme="light"] {
|
|
15
15
|
--ge-table-bg: rgba(255,255,255, 0.5);
|
|
16
16
|
--ge-table-header-west-bg: rgba(233, 233, 233, 0.5);
|
package/index.js
CHANGED
|
@@ -236,7 +236,7 @@ class z {
|
|
|
236
236
|
header: 34,
|
|
237
237
|
body: 34,
|
|
238
238
|
footer: 34
|
|
239
|
-
}, this.footerVerticalSeparator = !1, this.headerToggleExpandCollapseIcons = !1, this.headerVerticalSeparator = !1, this.treeOptions = new ke(), this.headerGroupOptions = new ee(), this.showCheckboxWihoutExtraColumn = !1, this.externalFilterFunction = void 0, this.sortedOptions = new Re(), this.sortOrder = ["asc", "desc"], this.getEditRenderer = (e, r) => new De(), this.getSelectionModel = () => Ue, this.getFocusModel = () => Me;
|
|
239
|
+
}, this.footerVerticalSeparator = !1, this.headerToggleExpandCollapseIcons = !1, this.headerVerticalSeparator = !1, this.treeOptions = new ke(), this.headerGroupOptions = new ee(), this.showCheckboxWihoutExtraColumn = !1, this.externalFilterFunction = void 0, this.sortedOptions = new Re(), this.sortOrder = ["asc", "desc"], this.resizeEventDebounceDelay = 500, this.getEditRenderer = (e, r) => new De(), this.getSelectionModel = () => Ue, this.getFocusModel = () => Me;
|
|
240
240
|
}
|
|
241
241
|
}
|
|
242
242
|
const D = class D {
|
|
@@ -1520,6 +1520,42 @@ class I extends Ee {
|
|
|
1520
1520
|
}
|
|
1521
1521
|
}
|
|
1522
1522
|
class f {
|
|
1523
|
+
/**
|
|
1524
|
+
* TableFactory
|
|
1525
|
+
*
|
|
1526
|
+
* This class is responsible for creating table models based on various
|
|
1527
|
+
* parameters and configurations. TableFactory provides different methods
|
|
1528
|
+
* to create these models that must comply with TableModelIf interface.
|
|
1529
|
+
*
|
|
1530
|
+
* Methods:
|
|
1531
|
+
*
|
|
1532
|
+
* createTableModel(p: Partial<{...}>): TableModelIf
|
|
1533
|
+
* Receives a set of parameters as a Partial object with a number of properties
|
|
1534
|
+
* and returns an instance of an object that complies to TableModelIf interface.
|
|
1535
|
+
* Refer to the method's documentation for details.
|
|
1536
|
+
*
|
|
1537
|
+
* buildByTypedRowsParam(param: {rows: T[]; columnDefs: ColumnDefIf[]; tableOptions?: TableOptionsIf; fixedLeftColumnCount?: number; fixedRightColumnCount?: number}): TableModelIf
|
|
1538
|
+
* Receives a parameter object with essential properties needed to build the table model,
|
|
1539
|
+
* including rows (type T array), column definitions (ColumnDefIf array),
|
|
1540
|
+
* optional table options (TableOptionsIf object), and optional fixed column counts,
|
|
1541
|
+
* and returns an instance of TableModelIf.
|
|
1542
|
+
*
|
|
1543
|
+
* buildByTypedRows(rows: T[], columnDefs: ColumnDefIf[], tableOptions?: TableOptionsIf, fixedLeftColumnCount?: number, fixedRightColumnCount?: number): TableModelIf
|
|
1544
|
+
* Similar to `buildByTypedRowsParam` but accepts separate parameters instead of a single parameter object.
|
|
1545
|
+
*
|
|
1546
|
+
* createByObjectArrayParam(param: {rows: T[]; header?: string[][]; footer?: string[][]; fixedLeftColumnCount?: number; fixedRightColumnCount?: number; rowCheckboxVisible?: boolean; defaultRowHeights?: DefaultRowHeightsIf; columnDefs?: ColumnDefIf[]; columnSizes?: number[]}): TableModelIf
|
|
1547
|
+
* Similar to `createTableModel` but accepts an object parameter with properties required to create a table, including row data, header and footer multi-line data, fixed column counts, visibility of row checkbox, default row heights, column definitions, and column sizes, and returns a TableModelIf instance.
|
|
1548
|
+
*
|
|
1549
|
+
* createByAreaModels(headerAreaModel: AreaModelIf, bodyAreaModel: AreaModelIf, footerAreaModel: AreaModelIf, fixedLeftColumnCount: number, fixedRightColumnCount: number, rowCheckboxVisible: boolean, defaultRowHeights: DefaultRowHeightsIf): TableModelIf
|
|
1550
|
+
* Accepts area models for header, body, and footer, along with fixed column counts, visibility of row checkbox, and default row heights, to create a table model.
|
|
1551
|
+
*
|
|
1552
|
+
* createByAreaModelsParam(param: {headerAreaModel?: AreaModelIf; bodyAreaModel: AreaModelIf; footerAreaModel?: AreaModelIf; fixedLeftColumnCount?: number; fixedRightColumnCount?: number; rowCheckboxVisible?: boolean; defaultRowHeights?: DefaultRowHeightsIf; columnDefs?: ColumnDefIf[]; columnSizes?: number[]; overridingColumnWidth?: number; columnCount?: number}): TableModelIf
|
|
1553
|
+
* Similar to `createByAreaModels` but accepts an object parameter with the required and optional properties to create the table model.
|
|
1554
|
+
*
|
|
1555
|
+
* createByObjectArray(rows: T[], header: string[][], footer: string[][], fixedLeftColumnCount: number, fixedRightColumnCount: number, rowCheckboxVisible: boolean, defaultRowHeights: DefaultRowHeightsIf): TableModelIf
|
|
1556
|
+
* Allows to create a table model utilizing object array data for rows, header, and footer along with the specified configurations.
|
|
1557
|
+
* Please consult each method's documentation for detailed explanation of their functionality.
|
|
1558
|
+
*/
|
|
1523
1559
|
static createTableModel(e) {
|
|
1524
1560
|
var r, a, t, n, m, d, i, u, p, c, N, G, v, k;
|
|
1525
1561
|
if (e.defaultRowHeights === void 0)
|
|
@@ -1593,6 +1629,23 @@ class f {
|
|
|
1593
1629
|
e.getSelectionModel
|
|
1594
1630
|
);
|
|
1595
1631
|
}
|
|
1632
|
+
/**
|
|
1633
|
+
* Constructs a table model (an instance of `TableModelIf`) by using provided parameters.
|
|
1634
|
+
*
|
|
1635
|
+
* @template T The generic parameter that represents the datatype of rows.
|
|
1636
|
+
*
|
|
1637
|
+
* @param {Object} param The parameter object.
|
|
1638
|
+
* @param {T[]} param.rows The rows data to be used in the table model.
|
|
1639
|
+
* @param {ColumnDefIf[]} param.columnDefs The definition of columns that are to be used in the table model.
|
|
1640
|
+
* @param {TableOptionsIf} [param.tableOptions=new TableOptions()] Optional table options that may override default table settings. Defaults to `new TableOptions()`.
|
|
1641
|
+
* @param {number} [param.fixedLeftColumnCount=0] Optional parameter that specifies the count of fixed (non-scrollable) columns from the left. Defaults to `0`.
|
|
1642
|
+
* @param {number} [param.fixedRightColumnCount=0] Optional parameter that specifies the count of fixed (non-scrollable) columns from the right. Defaults to `0`.
|
|
1643
|
+
*
|
|
1644
|
+
* @returns {TableModelIf} The newly constructed table model.
|
|
1645
|
+
*
|
|
1646
|
+
* @static
|
|
1647
|
+
* @method
|
|
1648
|
+
*/
|
|
1596
1649
|
static buildByTypedRowsParam(e) {
|
|
1597
1650
|
return f.buildByTypedRows(
|
|
1598
1651
|
e.rows ?? [],
|
|
@@ -1602,6 +1655,42 @@ class f {
|
|
|
1602
1655
|
e.fixedRightColumnCount ?? 0
|
|
1603
1656
|
);
|
|
1604
1657
|
}
|
|
1658
|
+
/**
|
|
1659
|
+
* Static method that helps to build a table model object. It takes in tabular data and options and constructs a suitable
|
|
1660
|
+
* model for rendering as a table. This method is capable of handling both 'Flat' and 'Tree' data structures.
|
|
1661
|
+
*
|
|
1662
|
+
* @typeparam T - The type of the data in the rows.
|
|
1663
|
+
*
|
|
1664
|
+
* @param rows - An array of the data rows. The type of these rows could be anything which is defined by the generic type parameter T.
|
|
1665
|
+
*
|
|
1666
|
+
* @param columnDefs - An array of objects that define the columns of the table. Each object represents one column.
|
|
1667
|
+
*
|
|
1668
|
+
* @param tableOptions - A configuration object that allows you to customize how the table is displayed and behaves.
|
|
1669
|
+
* This is optional, and if not provided it defaults to a new instance of TableOptions.
|
|
1670
|
+
*
|
|
1671
|
+
* @param fixedLeftColumnCount - Optional parameter that specifies the number of columns that should remain fixed from the left
|
|
1672
|
+
* side of the table while scrolling horizontally. It defaults to 0 if not provided.
|
|
1673
|
+
*
|
|
1674
|
+
* @param fixedRightColumnCount - Optional parameter that specifies the number of columns that should remain fixed from the right
|
|
1675
|
+
* side of the table while scrolling horizontally. It defaults to 0 if not provided.
|
|
1676
|
+
*
|
|
1677
|
+
* @returns A TableModelIf object which can be used to render the table. The TableModelIf defines the structure of the table and
|
|
1678
|
+
* contains all its data and state.
|
|
1679
|
+
*
|
|
1680
|
+
* @usageNotes
|
|
1681
|
+
*
|
|
1682
|
+
* Here is an example of using this static method to build a table model:
|
|
1683
|
+
*
|
|
1684
|
+
* ```typescript
|
|
1685
|
+
* const tableModel = TableFactory.buildByTypedRows<User>(users, [{ property: 'name', headerLabel: 'Name' }, { property: 'email', headerLabel: 'Email' }]);
|
|
1686
|
+
* ```
|
|
1687
|
+
*
|
|
1688
|
+
* This will build a table with two columns 'Name' and 'Email', each row representing a 'User' object from the 'users' array.
|
|
1689
|
+
*
|
|
1690
|
+
* **Warning:** This function assumes that the first columnDef provided represents a checkbox column if the property of the first
|
|
1691
|
+
* columnDef is "CheckboxColumn". If the first column is not a checkbox column, ensure that the first columnDef does not have "CheckboxColumn"
|
|
1692
|
+
* as its property.
|
|
1693
|
+
*/
|
|
1605
1694
|
static buildByTypedRows(e, r, a = new z(), t = 0, n = 0) {
|
|
1606
1695
|
const m = a.defaultRowHeights, d = r[0].property === "CheckboxColumn";
|
|
1607
1696
|
if (e != null && e.length && X(e[0])) {
|
|
@@ -1633,6 +1722,50 @@ class f {
|
|
|
1633
1722
|
defaultRowHeights: a.defaultRowHeights
|
|
1634
1723
|
});
|
|
1635
1724
|
}
|
|
1725
|
+
/**
|
|
1726
|
+
* The `createByObjectArrayParam` static method is used to create a `TableFactory` object with the data contained in the `param` object.
|
|
1727
|
+
* This method would call the `createByObjectArray` static method, which actually constructs the `TableModel` object with the provided data.
|
|
1728
|
+
*
|
|
1729
|
+
* @template T - Defines the type of the items contained in the rows.
|
|
1730
|
+
*
|
|
1731
|
+
* @param {Object} param - Method parameter as an object that carries several properties described below:
|
|
1732
|
+
* @param {T[]} param.rows - Array of table row data that can be of any type.
|
|
1733
|
+
* @param {string[][]} [param.header] - Optional array of arrays with the table header data.
|
|
1734
|
+
* @param {string[][]} [param.footer] - Optional array of arrays with the table footer data.
|
|
1735
|
+
* @param {number} [param.fixedLeftColumnCount] - Optional number detailing how many of the beginning columns are sticky to the left.
|
|
1736
|
+
* @param {number} [param.fixedRightColumnCount] - Optional number detailing how many of the ending columns are sticky to the right.
|
|
1737
|
+
* @param {boolean} [param.rowCheckboxVisible] - Optional flag that indicates whether checkboxes are visible in the rows.
|
|
1738
|
+
* @param {DefaultRowHeightsIf} [param.defaultRowHeights] - Optional object defining default heights of rows in different sections of the table. Defaults to new `DefaultRowHeights()`.
|
|
1739
|
+
* @param {ColumnDefIf[]} [param.columnDefs] - Optional array of column definitions, each is an object conforming to `ColumnDefIf` interface.
|
|
1740
|
+
* @param {number[]} [param.columnSizes] - Optional array of numbers providing the specific sizes for columns.
|
|
1741
|
+
*
|
|
1742
|
+
* @returns A `TableFactory` object created by the `createByObjectArray` method.
|
|
1743
|
+
*
|
|
1744
|
+
* @example
|
|
1745
|
+
* let param = {
|
|
1746
|
+
* rows: [{name: 'John', age: 30}, {name: 'Doe', age: 40}],
|
|
1747
|
+
* header: [['Name', 'Age']],
|
|
1748
|
+
* footer: [['Avg', '35']],
|
|
1749
|
+
* fixedLeftColumnCount: 1,
|
|
1750
|
+
* fixedRightColumnCount: 0,
|
|
1751
|
+
* rowCheckboxVisible: true,
|
|
1752
|
+
* defaultRowHeights: new DefaultRowHeights(40, 50, 40),
|
|
1753
|
+
* columnDefs: [
|
|
1754
|
+
* {
|
|
1755
|
+
* property: 'name',
|
|
1756
|
+
* headerLabel: 'Name',
|
|
1757
|
+
* width: 100
|
|
1758
|
+
* },
|
|
1759
|
+
* {
|
|
1760
|
+
* property: 'age',
|
|
1761
|
+
* headerLabel: 'Age',
|
|
1762
|
+
* width: 50
|
|
1763
|
+
* }
|
|
1764
|
+
* ],
|
|
1765
|
+
* columnSizes: [100, 50]
|
|
1766
|
+
* };
|
|
1767
|
+
* const tableModel = TableFactory.createByObjectArrayParam(param);
|
|
1768
|
+
*/
|
|
1636
1769
|
static createByObjectArrayParam(e) {
|
|
1637
1770
|
const r = e.rowCheckboxVisible !== void 0 ? e.rowCheckboxVisible : !1;
|
|
1638
1771
|
return f.createByObjectArray(
|
|
@@ -1647,6 +1780,47 @@ class f {
|
|
|
1647
1780
|
e.columnSizes ?? []
|
|
1648
1781
|
);
|
|
1649
1782
|
}
|
|
1783
|
+
/**
|
|
1784
|
+
* This public static factory method creates a `TableModel` instance using the provided parameters.
|
|
1785
|
+
* Each parameter has a default value allowing for great flexibility in creating table models.
|
|
1786
|
+
* The main parameters are the AreaModel instances for different table sections:
|
|
1787
|
+
*
|
|
1788
|
+
* @param headerAreaModel - This parameter of type `AreaModelIf` represents the header area of the table.
|
|
1789
|
+
* The default value is a new instance of `AreaModelHidden`, indicating an invisible header.
|
|
1790
|
+
*
|
|
1791
|
+
* @param bodyAreaModel - This parameter of type `AreaModelIf` represents the body area of the table and is required.
|
|
1792
|
+
* It needs to be passed as it contains all the row data that will be displayed in the table.
|
|
1793
|
+
*
|
|
1794
|
+
* @param footerAreaModel - This `AreaModelIf` type parameter represents the footer area of the table.
|
|
1795
|
+
* Similar to `headerAreaModel`, the default value is a new instance of `AreaModelHidden`, indicating an invisible footer.
|
|
1796
|
+
*
|
|
1797
|
+
* Also, the method receives parameters for fixed columns, row checkbox visibility, default row heights, column definitions, column sizes, overriding column width, and column count:
|
|
1798
|
+
*
|
|
1799
|
+
* @param fixedLeftColumnCount - This value indicates the number of fixed columns on the left side of the table.
|
|
1800
|
+
* The default value is `0`, no fixed column by default.
|
|
1801
|
+
*
|
|
1802
|
+
* @param fixedRightColumnCount - This value indicates the number of fixed columns on the right side of the table.
|
|
1803
|
+
* Similarly to `fixedLeftColumnCount`, its default value is `0`.
|
|
1804
|
+
*
|
|
1805
|
+
* @param rowCheckboxVisible - This is a boolean that determines whether a checkbox will be visible for each row.
|
|
1806
|
+
* The default value is `false`, indicating that checkboxes will not be displayed unless otherwise specified.
|
|
1807
|
+
*
|
|
1808
|
+
* @param defaultRowHeights - This object of type `DefaultRowHeightsIf` allows setting of the default row heights for the table sections.
|
|
1809
|
+
* By default, it creates a new `DefaultRowHeights` instance with values of `34` for header, body and footer.
|
|
1810
|
+
*
|
|
1811
|
+
* @param columnDefs - Here, an array of `ColumnDefIf[]` needs to be passed to specify the column definitions.
|
|
1812
|
+
*
|
|
1813
|
+
* @param columnSizes - This is an array of `number[]` providing custom column sizes.
|
|
1814
|
+
* If not defined, an empty array `[]` is used.
|
|
1815
|
+
*
|
|
1816
|
+
* @param overridingColumnWidth - This number sets a uniform width for all columns, overriding individual column sizes.
|
|
1817
|
+
* Default value is `-1`, indicating that this feature is disabled by default.
|
|
1818
|
+
*
|
|
1819
|
+
* @param columnCount - This is the total column count.
|
|
1820
|
+
*
|
|
1821
|
+
* @return A new instance of `TableModel` is created using the provided parameters.
|
|
1822
|
+
* If a parameter isn't provided, the default value is used.
|
|
1823
|
+
*/
|
|
1650
1824
|
static createByAreaModels(e = new Z(), r, a = new Z(), t = 0, n = 0, m = !1, d = new R(), i, u = [], p = -1, c) {
|
|
1651
1825
|
return new W(
|
|
1652
1826
|
e,
|
|
@@ -1662,6 +1836,42 @@ class f {
|
|
|
1662
1836
|
c
|
|
1663
1837
|
);
|
|
1664
1838
|
}
|
|
1839
|
+
/**
|
|
1840
|
+
* `TableFactory.createByAreaModelsParam` is a static method in the `TableFactory` class that creates a table model by area models and other optional parameters.
|
|
1841
|
+
* This method allows more flexibility and control over table building by providing the option to decide the visibility and nature of the header, body, footer, columns, and rows in the table.
|
|
1842
|
+
*
|
|
1843
|
+
* @param `param` is an object that holds the configuration settings for creating the table model. Below are the properties that this object can have:
|
|
1844
|
+
* - `headerAreaModel`: Optional. An instance of `AreaModelIf` class to be used for creating the header of the table. If not provided, a new `AreaModelHidden` is created by default.
|
|
1845
|
+
* - `bodyAreaModel`: Mandatory. An instance of `AreaModelIf` class for body of the table.
|
|
1846
|
+
* - `footerAreaModel`: Optional. An instance of `AreaModelIf` class for table footer. If not provided, a new `AreaModelHidden` is created by default.
|
|
1847
|
+
* - `fixedLeftColumnCount`: Optional. Number of fixed columns on the left side of the table. Default is 0.
|
|
1848
|
+
* - `fixedRightColumnCount`: Optional. Number of fixed columns on the right side of the table. Default is 0.
|
|
1849
|
+
* - `rowCheckboxVisible`: Optional. Boolean that decides if the row checkboxes are visible or not. Defaults to `false`.
|
|
1850
|
+
* - `defaultRowHeights`: Optional. An instance of `DefaultRowHeightsIf` interface that specifies default row heights. No default value.
|
|
1851
|
+
* - `columnDefs`: Optional. Array of instance(s) of `ColumnDefIf` interface to define column properties. Defaults to an empty array.
|
|
1852
|
+
* - `columnSizes`: Optional. Array of numbers setting the sizes of the columns. Defaults to an empty array.
|
|
1853
|
+
* - `overridingColumnWidth`: Optional. Overrides the width of all columns with this value. Defaults to `-1` which means no width override.
|
|
1854
|
+
* - `columnCount`: Optional. Number setting the total count of columns. Defaults to 0.
|
|
1855
|
+
*
|
|
1856
|
+
* @returns a new instance of `TableModelIf` created by the `createByAreaModels` method of `TableFactory` using the provided parameters.
|
|
1857
|
+
*
|
|
1858
|
+
* Note: The area models (`headerAreaModel`, `bodyAreaModel`, `footerAreaModel`) should be initialized before being passed to this method. If not initialized, they might need to call their `init` method to ensure proper functioning.
|
|
1859
|
+
*
|
|
1860
|
+
* @example
|
|
1861
|
+
* const tableModel = TableFactory.createByAreaModelsParam({
|
|
1862
|
+
* headerAreaModel: myHeaderModel,
|
|
1863
|
+
* bodyAreaModel: myBodyModel,
|
|
1864
|
+
* footerAreaModel: myFooterModel,
|
|
1865
|
+
* fixedLeftColumnCount: 2,
|
|
1866
|
+
* fixedRightColumnCount: 1,
|
|
1867
|
+
* rowCheckboxVisible: true,
|
|
1868
|
+
* defaultRowHeights: myDefaultHeights,
|
|
1869
|
+
* columnDefs: myColumnDefs,
|
|
1870
|
+
* columnSizes: [100, 100, 200],
|
|
1871
|
+
* overridingColumnWidth: 150,
|
|
1872
|
+
* columnCount: 3
|
|
1873
|
+
* });
|
|
1874
|
+
*/
|
|
1665
1875
|
static createByAreaModelsParam(e) {
|
|
1666
1876
|
return f.createByAreaModels(
|
|
1667
1877
|
e.headerAreaModel ?? new Z(),
|
|
@@ -1677,6 +1887,54 @@ class f {
|
|
|
1677
1887
|
e.columnCount ?? 0
|
|
1678
1888
|
);
|
|
1679
1889
|
}
|
|
1890
|
+
/**
|
|
1891
|
+
* Class method `createByObjectArray` of the `TableFactory` class.
|
|
1892
|
+
*
|
|
1893
|
+
* This public, static method is intended to create a table model by an array of objects.
|
|
1894
|
+
* This method is particularly useful when you are aiming to build a table from a set of data rows, header and footer information.
|
|
1895
|
+
* The table can include both fixed and flexible columns and optional checkboxes for each row.
|
|
1896
|
+
* The table layout can further be customized using the default row heights, column definitions, and column sizes parameters.
|
|
1897
|
+
*
|
|
1898
|
+
* @generic `T` - The generic type parameter for data rows.
|
|
1899
|
+
*
|
|
1900
|
+
* @param `rows` - This parameter is an array of typed data rows (type `T`) for the table body.
|
|
1901
|
+
*
|
|
1902
|
+
* @param `header` - This optional parameter is a two-dimensional string array. It defines the table header data. The default value is an empty array.
|
|
1903
|
+
*
|
|
1904
|
+
* @param `footer` - This optional parameter is a two-dimensional string array. It defines the table footer data. The default value is an empty array.
|
|
1905
|
+
*
|
|
1906
|
+
* @param `fixedLeftColumnCount` - This optional parameter specifies the count of fixed (non-scrollable) columns on the left side of the table. The default value is 0.
|
|
1907
|
+
*
|
|
1908
|
+
* @param `fixedRightColumnCount` - This optional parameter specifies the count of fixed (non-scrollable) columns on the right side of the table. The default value is 0.
|
|
1909
|
+
*
|
|
1910
|
+
* @param `rowCheckboxVisible` - This optional boolean parameter tells whether to display checkboxes for each row in the table. The default value is false.
|
|
1911
|
+
*
|
|
1912
|
+
* @param `defaultRowHeights` - This optional parameter is an instance of `DefaultRowHeightsIf` interface. It sets the default row heights for the header, body, and footer areas of the table.
|
|
1913
|
+
*
|
|
1914
|
+
* @param `columnDefs` - This optional parameter is an array of column definitions (`ColumnDefIf[]`). It helps to define the settings and properties of individual columns.
|
|
1915
|
+
*
|
|
1916
|
+
* @param `columnSizes` - This optional parameter is a number array. It helps to define the column widths. The default value is an empty array.
|
|
1917
|
+
*
|
|
1918
|
+
* The method further processes the header, footer, and body data to create respective models (`AreaModelIf`), and ultimately it creates and returns a new instance of `TableModel` containing all those prepared models, options, and properties.
|
|
1919
|
+
*
|
|
1920
|
+
* @returns It returns an instance of `TableModel` with all the provided/processed parameters.
|
|
1921
|
+
*
|
|
1922
|
+
* Note: You need to import the `AreaModelArrayOfArrays` and `AreaModelHidden` classes from the respective package/module before using this method.
|
|
1923
|
+
*
|
|
1924
|
+
* @example
|
|
1925
|
+
* ```typescript
|
|
1926
|
+
* // Given the following array of objects:
|
|
1927
|
+
* const rows = [{field1: 'data11', field2: 'data12'}, {field1: 'data21', field2: 'data22'}];
|
|
1928
|
+
*
|
|
1929
|
+
* // And a set of column definitions:
|
|
1930
|
+
* const columnDefs: ColumnDefIf[] = [{headerLabel: 'Field 1', property: 'field1'}, {headerLabel: 'Field 2', property: 'field2'}];
|
|
1931
|
+
*
|
|
1932
|
+
* // You can create a TableModel like following:
|
|
1933
|
+
* let tableModel = TableFactory.createByObjectArray(rows, undefined, undefined, 0, 0, false, new DefaultRowHeights(), columnDefs);
|
|
1934
|
+
* ```
|
|
1935
|
+
*
|
|
1936
|
+
* Reference: For more details regarding the `DefaultRowHeightsIf`, `ColumnDefIf`, `AreaModelIf`, and `AreaModelArrayOfArrays` classes/interfaces, please refer to the respective API documents.
|
|
1937
|
+
*/
|
|
1680
1938
|
static createByObjectArray(e, r = [], a = [], t = 0, n = 0, m = !1, d = new R(), i, u = []) {
|
|
1681
1939
|
let p;
|
|
1682
1940
|
r != null && r.length ? p = new S("header", r, d.header, i) : i != null && i.length ? p = new S("header", [i.map((G) => G.headerLabel)], d.header, i) : p = new Z();
|
|
@@ -44,6 +44,7 @@ export declare const tableOptions: {
|
|
|
44
44
|
sortedOptions: import('../../../table/src').SortedOptions;
|
|
45
45
|
sortOrder: import('../../../table/src').SortState[];
|
|
46
46
|
shortcutActionIdMapping?: import('../../../table/src').ShortcutActionIdMapping | undefined;
|
|
47
|
+
resizeEventDebounceDelay: number;
|
|
47
48
|
getEditRenderer?: import('../../../table/src').GetEditRenderer | undefined;
|
|
48
49
|
getSelectionModel?: import('../../../table/src').GetT<import('../../../table/src').SelectionModelIf> | undefined;
|
|
49
50
|
getFocusModel?: import('../../../table/src').GetT<import('../../../table/src').FocusModelIf> | undefined;
|
|
@@ -42,6 +42,7 @@ export declare function createTreePeopleTableOptions(addDemoSelection?: boolean)
|
|
|
42
42
|
sortedOptions: import('../../../../table/src').SortedOptions;
|
|
43
43
|
sortOrder: import('../../../../table/src').SortState[];
|
|
44
44
|
shortcutActionIdMapping?: import('../../../../table/src').ShortcutActionIdMapping | undefined;
|
|
45
|
+
resizeEventDebounceDelay: number;
|
|
45
46
|
getEditRenderer?: import('../../../../table/src').GetEditRenderer | undefined;
|
|
46
47
|
getFocusModel?: import('../../../../table/src').GetT<import('../../../../table/src').FocusModelIf> | undefined;
|
|
47
48
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@guiexpert/demo-table-models",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.24",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"types": "./index.d.ts",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"tslib": "^2.3.0",
|
|
21
|
-
"@guiexpert/table": "^1.1.
|
|
21
|
+
"@guiexpert/table": "^1.1.31"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@types/node": "^20.11.17",
|