@protonradio/proton-ui 0.11.30-beta.2 → 0.11.30-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Table/BaseTable/Collection/CompoundComponents.cjs.js.map +1 -1
- package/dist/components/Table/BaseTable/Collection/CompoundComponents.es.js.map +1 -1
- package/dist/components/Table/BaseTable/Collection/collectionParser.cjs.js +1 -1
- package/dist/components/Table/BaseTable/Collection/collectionParser.cjs.js.map +1 -1
- package/dist/components/Table/BaseTable/Collection/collectionParser.es.js +28 -27
- package/dist/components/Table/BaseTable/Collection/collectionParser.es.js.map +1 -1
- package/dist/components/Table/BaseTable/Table.cjs.js +1 -1
- package/dist/components/Table/BaseTable/Table.cjs.js.map +1 -1
- package/dist/components/Table/BaseTable/Table.es.js +33 -32
- package/dist/components/Table/BaseTable/Table.es.js.map +1 -1
- package/dist/components/Table/BaseTable/elements/TableCell.cjs.js +1 -1
- package/dist/components/Table/BaseTable/elements/TableCell.cjs.js.map +1 -1
- package/dist/components/Table/BaseTable/elements/TableCell.es.js +15 -10
- package/dist/components/Table/BaseTable/elements/TableCell.es.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CompoundComponents.cjs.js","sources":["../../../../../src/components/Table/BaseTable/Collection/CompoundComponents.tsx"],"sourcesContent":["import { AriaAttributes, ReactElement, ReactNode } from \"react\";\n\n/*\n Compound reference components used to build the table collection.\n They are not rendered, but used to parse the table structure.\n*/\n\ntype TableColumnElement = ReactElement<\n TableColumnProps,\n typeof TableColumnCompound\n>;\ntype TableRowElement = ReactElement<TableRowProps, typeof TableRowCompound>;\ntype TableCellElement = ReactElement<TableCellProps, typeof TableCellCompound>;\n\nexport interface TableHeaderProps {\n children: TableColumnElement | TableColumnElement[];\n isHidden?: boolean;\n \"data-testid\"?: string;\n}\n\nexport interface TableColumnProps {\n id: string;\n children: ReactNode;\n \"aria-sort\"?: AriaAttributes[\"aria-sort\"];\n}\n\nexport interface TableBodyProps {\n children: TableRowElement | TableRowElement[] | ReactElement | ReactElement[];\n}\n\nexport interface TableRowProps {\n key?: string | number;\n children: TableCellElement | TableCellElement[];\n onClick?: () => void;\n \"data-testid\"?: string;\n}\n\nexport interface TableCellProps {\n columnKey?: string;\n children?: ReactNode;\n colSpan?: number;\n \"data-testid\"?: string;\n}\n\n// Type-safe component definitions that enforce proper children\nexport const TableHeaderCompound = (_: TableHeaderProps) => {\n return null; // This is just a marker component for parsing\n};\n\nexport const TableColumnCompound = (_: TableColumnProps) => {\n return null; // This is just a marker component for parsing\n};\n\nexport const TableBodyCompound = (_: TableBodyProps) => {\n return null; // This is just a marker component for parsing\n};\n\nexport const TableRowCompound = (_: TableRowProps) => {\n return null; // This is just a marker component for parsing\n};\n\nexport const TableCellCompound = (_: TableCellProps) => {\n return null; // This is just a marker component for parsing\n};\n"],"names":["TableHeaderCompound","_","TableColumnCompound","TableBodyCompound","TableRowCompound","TableCellCompound"],"mappings":"
|
|
1
|
+
{"version":3,"file":"CompoundComponents.cjs.js","sources":["../../../../../src/components/Table/BaseTable/Collection/CompoundComponents.tsx"],"sourcesContent":["import { AriaAttributes, ReactElement, ReactNode } from \"react\";\n\n/*\n Compound reference components used to build the table collection.\n They are not rendered, but used to parse the table structure.\n*/\n\ntype TableColumnElement = ReactElement<\n TableColumnProps,\n typeof TableColumnCompound\n>;\ntype TableRowElement = ReactElement<TableRowProps, typeof TableRowCompound>;\ntype TableCellElement = ReactElement<TableCellProps, typeof TableCellCompound>;\n\nexport interface TableHeaderProps {\n children: TableColumnElement | TableColumnElement[];\n isHidden?: boolean;\n \"data-testid\"?: string;\n}\n\nexport interface TableColumnProps {\n id: string;\n children: ReactNode;\n \"aria-sort\"?: AriaAttributes[\"aria-sort\"];\n}\n\nexport interface TableBodyProps {\n children: TableRowElement | TableRowElement[] | ReactElement | ReactElement[];\n}\n\nexport interface TableRowProps {\n key?: string | number;\n children: TableCellElement | TableCellElement[];\n onClick?: () => void;\n \"data-testid\"?: string;\n}\n\nexport interface TableCellProps {\n columnKey?: string;\n children?: ReactNode;\n colSpan?: number;\n \"data-testid\"?: string;\n textAlign?: \"left\" | \"center\" | \"right\";\n}\n\n// Type-safe component definitions that enforce proper children\nexport const TableHeaderCompound = (_: TableHeaderProps) => {\n return null; // This is just a marker component for parsing\n};\n\nexport const TableColumnCompound = (_: TableColumnProps) => {\n return null; // This is just a marker component for parsing\n};\n\nexport const TableBodyCompound = (_: TableBodyProps) => {\n return null; // This is just a marker component for parsing\n};\n\nexport const TableRowCompound = (_: TableRowProps) => {\n return null; // This is just a marker component for parsing\n};\n\nexport const TableCellCompound = (_: TableCellProps) => {\n return null; // This is just a marker component for parsing\n};\n"],"names":["TableHeaderCompound","_","TableColumnCompound","TableBodyCompound","TableRowCompound","TableCellCompound"],"mappings":"gFA8Ca,MAAAA,EAAuBC,GAC3B,KAGIC,EAAuBD,GAC3B,KAGIE,EAAqBF,GACzB,KAGIG,EAAoBH,GACxB,KAGII,EAAqBJ,GACzB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CompoundComponents.es.js","sources":["../../../../../src/components/Table/BaseTable/Collection/CompoundComponents.tsx"],"sourcesContent":["import { AriaAttributes, ReactElement, ReactNode } from \"react\";\n\n/*\n Compound reference components used to build the table collection.\n They are not rendered, but used to parse the table structure.\n*/\n\ntype TableColumnElement = ReactElement<\n TableColumnProps,\n typeof TableColumnCompound\n>;\ntype TableRowElement = ReactElement<TableRowProps, typeof TableRowCompound>;\ntype TableCellElement = ReactElement<TableCellProps, typeof TableCellCompound>;\n\nexport interface TableHeaderProps {\n children: TableColumnElement | TableColumnElement[];\n isHidden?: boolean;\n \"data-testid\"?: string;\n}\n\nexport interface TableColumnProps {\n id: string;\n children: ReactNode;\n \"aria-sort\"?: AriaAttributes[\"aria-sort\"];\n}\n\nexport interface TableBodyProps {\n children: TableRowElement | TableRowElement[] | ReactElement | ReactElement[];\n}\n\nexport interface TableRowProps {\n key?: string | number;\n children: TableCellElement | TableCellElement[];\n onClick?: () => void;\n \"data-testid\"?: string;\n}\n\nexport interface TableCellProps {\n columnKey?: string;\n children?: ReactNode;\n colSpan?: number;\n \"data-testid\"?: string;\n}\n\n// Type-safe component definitions that enforce proper children\nexport const TableHeaderCompound = (_: TableHeaderProps) => {\n return null; // This is just a marker component for parsing\n};\n\nexport const TableColumnCompound = (_: TableColumnProps) => {\n return null; // This is just a marker component for parsing\n};\n\nexport const TableBodyCompound = (_: TableBodyProps) => {\n return null; // This is just a marker component for parsing\n};\n\nexport const TableRowCompound = (_: TableRowProps) => {\n return null; // This is just a marker component for parsing\n};\n\nexport const TableCellCompound = (_: TableCellProps) => {\n return null; // This is just a marker component for parsing\n};\n"],"names":["TableHeaderCompound","_","TableColumnCompound","TableBodyCompound","TableRowCompound","TableCellCompound"],"mappings":"
|
|
1
|
+
{"version":3,"file":"CompoundComponents.es.js","sources":["../../../../../src/components/Table/BaseTable/Collection/CompoundComponents.tsx"],"sourcesContent":["import { AriaAttributes, ReactElement, ReactNode } from \"react\";\n\n/*\n Compound reference components used to build the table collection.\n They are not rendered, but used to parse the table structure.\n*/\n\ntype TableColumnElement = ReactElement<\n TableColumnProps,\n typeof TableColumnCompound\n>;\ntype TableRowElement = ReactElement<TableRowProps, typeof TableRowCompound>;\ntype TableCellElement = ReactElement<TableCellProps, typeof TableCellCompound>;\n\nexport interface TableHeaderProps {\n children: TableColumnElement | TableColumnElement[];\n isHidden?: boolean;\n \"data-testid\"?: string;\n}\n\nexport interface TableColumnProps {\n id: string;\n children: ReactNode;\n \"aria-sort\"?: AriaAttributes[\"aria-sort\"];\n}\n\nexport interface TableBodyProps {\n children: TableRowElement | TableRowElement[] | ReactElement | ReactElement[];\n}\n\nexport interface TableRowProps {\n key?: string | number;\n children: TableCellElement | TableCellElement[];\n onClick?: () => void;\n \"data-testid\"?: string;\n}\n\nexport interface TableCellProps {\n columnKey?: string;\n children?: ReactNode;\n colSpan?: number;\n \"data-testid\"?: string;\n textAlign?: \"left\" | \"center\" | \"right\";\n}\n\n// Type-safe component definitions that enforce proper children\nexport const TableHeaderCompound = (_: TableHeaderProps) => {\n return null; // This is just a marker component for parsing\n};\n\nexport const TableColumnCompound = (_: TableColumnProps) => {\n return null; // This is just a marker component for parsing\n};\n\nexport const TableBodyCompound = (_: TableBodyProps) => {\n return null; // This is just a marker component for parsing\n};\n\nexport const TableRowCompound = (_: TableRowProps) => {\n return null; // This is just a marker component for parsing\n};\n\nexport const TableCellCompound = (_: TableCellProps) => {\n return null; // This is just a marker component for parsing\n};\n"],"names":["TableHeaderCompound","_","TableColumnCompound","TableBodyCompound","TableRowCompound","TableCellCompound"],"mappings":"AA8Ca,MAAAA,IAAsB,CAACC,MAC3B,MAGIC,IAAsB,CAACD,MAC3B,MAGIE,IAAoB,CAACF,MACzB,MAGIG,IAAmB,CAACH,MACxB,MAGII,IAAoB,CAACJ,MACzB;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react"),a=require("./CompoundComponents.cjs.js"),p=(t,l)=>t.type===l,h=(t,l)=>{const r=[],d=s.Children.toArray(t);for(const o of d)if(s.isValidElement(o)&&p(o,a.TableColumnCompound)){const e=o.props;r.push({key:e.id,header:e.children,isHidden:l,ariaSort:e["aria-sort"]})}return r},C=(t,l)=>{var e;const r=[],d=s.Children.toArray(t);let o=0;for(const i of d)if(s.isValidElement(i)&&p(i,a.TableCellCompound)){const n=i.props,c=n.columnKey??((e=l[o])==null?void 0:e.key);c&&r.push({columnKey:c,value:n.children,colSpan:n.colSpan,dataTestId:n["data-testid"],textAlign:n.textAlign}),o++}return r},m=t=>{const l=[],r=[],d=s.Children.toArray(t);for(const o of d)if(s.isValidElement(o)){if(p(o,a.TableHeaderCompound)){const e=o.props,i=h(e.children,e.isHidden||!1);l.push(...i);continue}if(p(o,a.TableBodyCompound)){const e=o.props,i=s.Children.toArray(e.children);for(const n of i)if(s.isValidElement(n))if(p(n,a.TableRowCompound)){const c=n.props,u=C(c.children,l);r.push({key:n.key??c.key??String(r.length),cells:u,onClick:c.onClick,dataTestId:c["data-testid"]})}else r.push(n)}}return{columns:l,rows:r}};exports.parseTableChildren=m;
|
|
2
2
|
//# sourceMappingURL=collectionParser.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collectionParser.cjs.js","sources":["../../../../../src/components/Table/BaseTable/Collection/collectionParser.ts"],"sourcesContent":["import {\n Children,\n isValidElement,\n ReactElement,\n ReactNode,\n ComponentType,\n} from \"react\";\n\nimport {\n TableHeaderCompound,\n TableColumnCompound,\n TableBodyCompound,\n TableRowCompound,\n TableCellCompound,\n} from \"./CompoundComponents\";\nimport type {\n TableColumnData,\n TableData,\n TableRowData,\n TableCellData,\n} from \"../types\";\n\nconst isComponentType = (\n element: ReactElement,\n componentType: ComponentType<any>,\n): boolean => element.type === componentType;\n\n/**\n * Parses columns from Table.Header children\n */\nconst parseColumns = (\n headerChildren: ReactNode,\n isHeaderHidden: boolean,\n): TableColumnData[] => {\n const columns: TableColumnData[] = [];\n const childrenArray = Children.toArray(headerChildren);\n\n for (const columnChild of childrenArray) {\n if (\n isValidElement(columnChild) &&\n isComponentType(columnChild, TableColumnCompound)\n ) {\n const columnProps = columnChild.props;\n columns.push({\n key: columnProps.id,\n header: columnProps.children,\n isHidden: isHeaderHidden,\n ariaSort: columnProps[\"aria-sort\"],\n });\n }\n }\n\n return columns;\n};\n\n/**\n * Parses cells from Table.Row children\n */\nconst parseCells = (\n rowChildren: ReactNode,\n columns: TableColumnData[],\n): TableCellData[] => {\n const cells: TableCellData[] = [];\n const childrenArray = Children.toArray(rowChildren);\n let cellIndex = 0;\n\n for (const cellChild of childrenArray) {\n if (\n isValidElement(cellChild) &&\n isComponentType(cellChild, TableCellCompound)\n ) {\n const cellProps = cellChild.props;\n const columnKey = cellProps.columnKey ?? columns[cellIndex]?.key;\n\n if (columnKey) {\n cells.push({\n columnKey,\n value: cellProps.children,\n colSpan: cellProps.colSpan,\n dataTestId: cellProps[\"data-testid\"],\n });\n }\n cellIndex++;\n }\n }\n\n return cells;\n};\n\n/**\n * Parses JSX table structure into collection data format.\n *\n * @returns parsed table data\n * @see {@link TableData} for the parsed table data structure\n */\nexport const parseTableChildren = (children: ReactNode): TableData => {\n const columns: TableColumnData[] = [];\n const rows: (TableRowData | ReactElement)[] = [];\n const childrenArray = Children.toArray(children);\n\n for (const child of childrenArray) {\n if (!isValidElement(child)) continue;\n\n // Parse columns from header\n if (isComponentType(child, TableHeaderCompound)) {\n const headerProps = child.props;\n const parsedColumns = parseColumns(\n headerProps.children,\n headerProps.isHidden || false,\n );\n columns.push(...parsedColumns);\n continue;\n }\n\n // Parse rows from body\n if (isComponentType(child, TableBodyCompound)) {\n const bodyProps = child.props;\n const bodyChildren = Children.toArray(bodyProps.children);\n\n for (const rowChild of bodyChildren) {\n if (!isValidElement(rowChild)) continue;\n\n if (isComponentType(rowChild, TableRowCompound)) {\n const rowProps = rowChild.props;\n const cells = parseCells(rowProps.children, columns);\n\n rows.push({\n key: rowChild.key ?? rowProps.key ?? String(rows.length),\n cells,\n onClick: rowProps.onClick,\n dataTestId: rowProps[\"data-testid\"],\n });\n } else {\n rows.push(rowChild);\n }\n }\n }\n }\n\n return {\n columns,\n rows,\n };\n};\n"],"names":["isComponentType","element","componentType","parseColumns","headerChildren","isHeaderHidden","columns","childrenArray","Children","columnChild","isValidElement","TableColumnCompound","columnProps","parseCells","rowChildren","cells","cellIndex","cellChild","TableCellCompound","cellProps","columnKey","_a","parseTableChildren","children","rows","child","TableHeaderCompound","headerProps","parsedColumns","TableBodyCompound","bodyProps","bodyChildren","rowChild","TableRowCompound","rowProps"],"mappings":"kJAsBMA,EAAkB,CACtBC,EACAC,IACYD,EAAQ,OAASC,EAKzBC,EAAe,CACnBC,EACAC,IACsB,CACtB,MAAMC,EAA6B,CAAA,EAC7BC,EAAgBC,EAAAA,SAAS,QAAQJ,CAAc,EAErD,UAAWK,KAAeF,EACxB,GACEG,EAAAA,eAAeD,CAAW,GAC1BT,EAAgBS,EAAaE,EAAmB,mBAAA,EAChD,CACA,MAAMC,EAAcH,EAAY,MAChCH,EAAQ,KAAK,CACX,IAAKM,EAAY,GACjB,OAAQA,EAAY,SACpB,SAAUP,EACV,SAAUO,EAAY,WAAW,CAAA,CAClC,CACH,CAGK,OAAAN,CACT,EAKMO,EAAa,CACjBC,EACAR,IACoB,OACpB,MAAMS,EAAyB,CAAA,EACzBR,EAAgBC,EAAAA,SAAS,QAAQM,CAAW,EAClD,IAAIE,EAAY,EAEhB,UAAWC,KAAaV,EACtB,GACEG,EAAAA,eAAeO,CAAS,GACxBjB,EAAgBiB,EAAWC,EAAiB,iBAAA,EAC5C,CACA,MAAMC,EAAYF,EAAU,MACtBG,EAAYD,EAAU,aAAaE,EAAAf,EAAQU,CAAS,IAAjB,YAAAK,EAAoB,KAEzDD,GACFL,EAAM,KAAK,CACT,UAAAK,EACA,MAAOD,EAAU,SACjB,QAASA,EAAU,QACnB,WAAYA,EAAU,aAAa,
|
|
1
|
+
{"version":3,"file":"collectionParser.cjs.js","sources":["../../../../../src/components/Table/BaseTable/Collection/collectionParser.ts"],"sourcesContent":["import {\n Children,\n isValidElement,\n ReactElement,\n ReactNode,\n ComponentType,\n} from \"react\";\n\nimport {\n TableHeaderCompound,\n TableColumnCompound,\n TableBodyCompound,\n TableRowCompound,\n TableCellCompound,\n} from \"./CompoundComponents\";\nimport type {\n TableColumnData,\n TableData,\n TableRowData,\n TableCellData,\n} from \"../types\";\n\nconst isComponentType = (\n element: ReactElement,\n componentType: ComponentType<any>,\n): boolean => element.type === componentType;\n\n/**\n * Parses columns from Table.Header children\n */\nconst parseColumns = (\n headerChildren: ReactNode,\n isHeaderHidden: boolean,\n): TableColumnData[] => {\n const columns: TableColumnData[] = [];\n const childrenArray = Children.toArray(headerChildren);\n\n for (const columnChild of childrenArray) {\n if (\n isValidElement(columnChild) &&\n isComponentType(columnChild, TableColumnCompound)\n ) {\n const columnProps = columnChild.props;\n columns.push({\n key: columnProps.id,\n header: columnProps.children,\n isHidden: isHeaderHidden,\n ariaSort: columnProps[\"aria-sort\"],\n });\n }\n }\n\n return columns;\n};\n\n/**\n * Parses cells from Table.Row children\n */\nconst parseCells = (\n rowChildren: ReactNode,\n columns: TableColumnData[],\n): TableCellData[] => {\n const cells: TableCellData[] = [];\n const childrenArray = Children.toArray(rowChildren);\n let cellIndex = 0;\n\n for (const cellChild of childrenArray) {\n if (\n isValidElement(cellChild) &&\n isComponentType(cellChild, TableCellCompound)\n ) {\n const cellProps = cellChild.props;\n const columnKey = cellProps.columnKey ?? columns[cellIndex]?.key;\n\n if (columnKey) {\n cells.push({\n columnKey,\n value: cellProps.children,\n colSpan: cellProps.colSpan,\n dataTestId: cellProps[\"data-testid\"],\n textAlign: cellProps.textAlign,\n });\n }\n cellIndex++;\n }\n }\n\n return cells;\n};\n\n/**\n * Parses JSX table structure into collection data format.\n *\n * @returns parsed table data\n * @see {@link TableData} for the parsed table data structure\n */\nexport const parseTableChildren = (children: ReactNode): TableData => {\n const columns: TableColumnData[] = [];\n const rows: (TableRowData | ReactElement)[] = [];\n const childrenArray = Children.toArray(children);\n\n for (const child of childrenArray) {\n if (!isValidElement(child)) continue;\n\n // Parse columns from header\n if (isComponentType(child, TableHeaderCompound)) {\n const headerProps = child.props;\n const parsedColumns = parseColumns(\n headerProps.children,\n headerProps.isHidden || false,\n );\n columns.push(...parsedColumns);\n continue;\n }\n\n // Parse rows from body\n if (isComponentType(child, TableBodyCompound)) {\n const bodyProps = child.props;\n const bodyChildren = Children.toArray(bodyProps.children);\n\n for (const rowChild of bodyChildren) {\n if (!isValidElement(rowChild)) continue;\n\n if (isComponentType(rowChild, TableRowCompound)) {\n const rowProps = rowChild.props;\n const cells = parseCells(rowProps.children, columns);\n\n rows.push({\n key: rowChild.key ?? rowProps.key ?? String(rows.length),\n cells,\n onClick: rowProps.onClick,\n dataTestId: rowProps[\"data-testid\"],\n });\n } else {\n rows.push(rowChild);\n }\n }\n }\n }\n\n return {\n columns,\n rows,\n };\n};\n"],"names":["isComponentType","element","componentType","parseColumns","headerChildren","isHeaderHidden","columns","childrenArray","Children","columnChild","isValidElement","TableColumnCompound","columnProps","parseCells","rowChildren","cells","cellIndex","cellChild","TableCellCompound","cellProps","columnKey","_a","parseTableChildren","children","rows","child","TableHeaderCompound","headerProps","parsedColumns","TableBodyCompound","bodyProps","bodyChildren","rowChild","TableRowCompound","rowProps"],"mappings":"kJAsBMA,EAAkB,CACtBC,EACAC,IACYD,EAAQ,OAASC,EAKzBC,EAAe,CACnBC,EACAC,IACsB,CACtB,MAAMC,EAA6B,CAAA,EAC7BC,EAAgBC,EAAAA,SAAS,QAAQJ,CAAc,EAErD,UAAWK,KAAeF,EACxB,GACEG,EAAAA,eAAeD,CAAW,GAC1BT,EAAgBS,EAAaE,EAAmB,mBAAA,EAChD,CACA,MAAMC,EAAcH,EAAY,MAChCH,EAAQ,KAAK,CACX,IAAKM,EAAY,GACjB,OAAQA,EAAY,SACpB,SAAUP,EACV,SAAUO,EAAY,WAAW,CAAA,CAClC,CACH,CAGK,OAAAN,CACT,EAKMO,EAAa,CACjBC,EACAR,IACoB,OACpB,MAAMS,EAAyB,CAAA,EACzBR,EAAgBC,EAAAA,SAAS,QAAQM,CAAW,EAClD,IAAIE,EAAY,EAEhB,UAAWC,KAAaV,EACtB,GACEG,EAAAA,eAAeO,CAAS,GACxBjB,EAAgBiB,EAAWC,EAAiB,iBAAA,EAC5C,CACA,MAAMC,EAAYF,EAAU,MACtBG,EAAYD,EAAU,aAAaE,EAAAf,EAAQU,CAAS,IAAjB,YAAAK,EAAoB,KAEzDD,GACFL,EAAM,KAAK,CACT,UAAAK,EACA,MAAOD,EAAU,SACjB,QAASA,EAAU,QACnB,WAAYA,EAAU,aAAa,EACnC,UAAWA,EAAU,SAAA,CACtB,EAEHH,GACF,CAGK,OAAAD,CACT,EAQaO,EAAsBC,GAAmC,CACpE,MAAMjB,EAA6B,CAAA,EAC7BkB,EAAwC,CAAA,EACxCjB,EAAgBC,EAAAA,SAAS,QAAQe,CAAQ,EAE/C,UAAWE,KAASlB,EACd,GAACG,EAAAA,eAAee,CAAK,EAGrB,IAAAzB,EAAgByB,EAAOC,EAAAA,mBAAmB,EAAG,CAC/C,MAAMC,EAAcF,EAAM,MACpBG,EAAgBzB,EACpBwB,EAAY,SACZA,EAAY,UAAY,EAAA,EAElBrB,EAAA,KAAK,GAAGsB,CAAa,EAC7B,QACF,CAGI,GAAA5B,EAAgByB,EAAOI,EAAAA,iBAAiB,EAAG,CAC7C,MAAMC,EAAYL,EAAM,MAClBM,EAAevB,EAAA,SAAS,QAAQsB,EAAU,QAAQ,EAExD,UAAWE,KAAYD,EACjB,GAACrB,EAAAA,eAAesB,CAAQ,EAExB,GAAAhC,EAAgBgC,EAAUC,EAAAA,gBAAgB,EAAG,CAC/C,MAAMC,EAAWF,EAAS,MACpBjB,EAAQF,EAAWqB,EAAS,SAAU5B,CAAO,EAEnDkB,EAAK,KAAK,CACR,IAAKQ,EAAS,KAAOE,EAAS,KAAO,OAAOV,EAAK,MAAM,EACvD,MAAAT,EACA,QAASmB,EAAS,QAClB,WAAYA,EAAS,aAAa,CAAA,CACnC,CAAA,MAEDV,EAAK,KAAKQ,CAAQ,CAGxB,EAGK,MAAA,CACL,QAAA1B,EACA,KAAAkB,CAAA,CAEJ"}
|
|
@@ -1,64 +1,65 @@
|
|
|
1
1
|
import { Children as a, isValidElement as p } from "react";
|
|
2
2
|
import { TableColumnCompound as h, TableCellCompound as m, TableHeaderCompound as f, TableBodyCompound as y, TableRowCompound as C } from "./CompoundComponents.es.js";
|
|
3
|
-
const d = (
|
|
4
|
-
const
|
|
3
|
+
const d = (t, s) => t.type === s, A = (t, s) => {
|
|
4
|
+
const r = [], i = a.toArray(t);
|
|
5
5
|
for (const o of i)
|
|
6
6
|
if (p(o) && d(o, h)) {
|
|
7
7
|
const n = o.props;
|
|
8
|
-
|
|
8
|
+
r.push({
|
|
9
9
|
key: n.id,
|
|
10
10
|
header: n.children,
|
|
11
11
|
isHidden: s,
|
|
12
12
|
ariaSort: n["aria-sort"]
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
|
-
return
|
|
16
|
-
},
|
|
15
|
+
return r;
|
|
16
|
+
}, T = (t, s) => {
|
|
17
17
|
var n;
|
|
18
|
-
const
|
|
18
|
+
const r = [], i = a.toArray(t);
|
|
19
19
|
let o = 0;
|
|
20
|
-
for (const
|
|
21
|
-
if (p(
|
|
22
|
-
const
|
|
23
|
-
c &&
|
|
20
|
+
for (const l of i)
|
|
21
|
+
if (p(l) && d(l, m)) {
|
|
22
|
+
const e = l.props, c = e.columnKey ?? ((n = s[o]) == null ? void 0 : n.key);
|
|
23
|
+
c && r.push({
|
|
24
24
|
columnKey: c,
|
|
25
|
-
value:
|
|
26
|
-
colSpan:
|
|
27
|
-
dataTestId:
|
|
25
|
+
value: e.children,
|
|
26
|
+
colSpan: e.colSpan,
|
|
27
|
+
dataTestId: e["data-testid"],
|
|
28
|
+
textAlign: e.textAlign
|
|
28
29
|
}), o++;
|
|
29
30
|
}
|
|
30
|
-
return
|
|
31
|
-
}, P = (
|
|
32
|
-
const s = [],
|
|
31
|
+
return r;
|
|
32
|
+
}, P = (t) => {
|
|
33
|
+
const s = [], r = [], i = a.toArray(t);
|
|
33
34
|
for (const o of i)
|
|
34
35
|
if (p(o)) {
|
|
35
36
|
if (d(o, f)) {
|
|
36
|
-
const n = o.props,
|
|
37
|
+
const n = o.props, l = A(
|
|
37
38
|
n.children,
|
|
38
39
|
n.isHidden || !1
|
|
39
40
|
);
|
|
40
|
-
s.push(...
|
|
41
|
+
s.push(...l);
|
|
41
42
|
continue;
|
|
42
43
|
}
|
|
43
44
|
if (d(o, y)) {
|
|
44
|
-
const n = o.props,
|
|
45
|
-
for (const
|
|
46
|
-
if (p(
|
|
47
|
-
if (d(
|
|
48
|
-
const c =
|
|
49
|
-
|
|
50
|
-
key:
|
|
45
|
+
const n = o.props, l = a.toArray(n.children);
|
|
46
|
+
for (const e of l)
|
|
47
|
+
if (p(e))
|
|
48
|
+
if (d(e, C)) {
|
|
49
|
+
const c = e.props, u = T(c.children, s);
|
|
50
|
+
r.push({
|
|
51
|
+
key: e.key ?? c.key ?? String(r.length),
|
|
51
52
|
cells: u,
|
|
52
53
|
onClick: c.onClick,
|
|
53
54
|
dataTestId: c["data-testid"]
|
|
54
55
|
});
|
|
55
56
|
} else
|
|
56
|
-
|
|
57
|
+
r.push(e);
|
|
57
58
|
}
|
|
58
59
|
}
|
|
59
60
|
return {
|
|
60
61
|
columns: s,
|
|
61
|
-
rows:
|
|
62
|
+
rows: r
|
|
62
63
|
};
|
|
63
64
|
};
|
|
64
65
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collectionParser.es.js","sources":["../../../../../src/components/Table/BaseTable/Collection/collectionParser.ts"],"sourcesContent":["import {\n Children,\n isValidElement,\n ReactElement,\n ReactNode,\n ComponentType,\n} from \"react\";\n\nimport {\n TableHeaderCompound,\n TableColumnCompound,\n TableBodyCompound,\n TableRowCompound,\n TableCellCompound,\n} from \"./CompoundComponents\";\nimport type {\n TableColumnData,\n TableData,\n TableRowData,\n TableCellData,\n} from \"../types\";\n\nconst isComponentType = (\n element: ReactElement,\n componentType: ComponentType<any>,\n): boolean => element.type === componentType;\n\n/**\n * Parses columns from Table.Header children\n */\nconst parseColumns = (\n headerChildren: ReactNode,\n isHeaderHidden: boolean,\n): TableColumnData[] => {\n const columns: TableColumnData[] = [];\n const childrenArray = Children.toArray(headerChildren);\n\n for (const columnChild of childrenArray) {\n if (\n isValidElement(columnChild) &&\n isComponentType(columnChild, TableColumnCompound)\n ) {\n const columnProps = columnChild.props;\n columns.push({\n key: columnProps.id,\n header: columnProps.children,\n isHidden: isHeaderHidden,\n ariaSort: columnProps[\"aria-sort\"],\n });\n }\n }\n\n return columns;\n};\n\n/**\n * Parses cells from Table.Row children\n */\nconst parseCells = (\n rowChildren: ReactNode,\n columns: TableColumnData[],\n): TableCellData[] => {\n const cells: TableCellData[] = [];\n const childrenArray = Children.toArray(rowChildren);\n let cellIndex = 0;\n\n for (const cellChild of childrenArray) {\n if (\n isValidElement(cellChild) &&\n isComponentType(cellChild, TableCellCompound)\n ) {\n const cellProps = cellChild.props;\n const columnKey = cellProps.columnKey ?? columns[cellIndex]?.key;\n\n if (columnKey) {\n cells.push({\n columnKey,\n value: cellProps.children,\n colSpan: cellProps.colSpan,\n dataTestId: cellProps[\"data-testid\"],\n });\n }\n cellIndex++;\n }\n }\n\n return cells;\n};\n\n/**\n * Parses JSX table structure into collection data format.\n *\n * @returns parsed table data\n * @see {@link TableData} for the parsed table data structure\n */\nexport const parseTableChildren = (children: ReactNode): TableData => {\n const columns: TableColumnData[] = [];\n const rows: (TableRowData | ReactElement)[] = [];\n const childrenArray = Children.toArray(children);\n\n for (const child of childrenArray) {\n if (!isValidElement(child)) continue;\n\n // Parse columns from header\n if (isComponentType(child, TableHeaderCompound)) {\n const headerProps = child.props;\n const parsedColumns = parseColumns(\n headerProps.children,\n headerProps.isHidden || false,\n );\n columns.push(...parsedColumns);\n continue;\n }\n\n // Parse rows from body\n if (isComponentType(child, TableBodyCompound)) {\n const bodyProps = child.props;\n const bodyChildren = Children.toArray(bodyProps.children);\n\n for (const rowChild of bodyChildren) {\n if (!isValidElement(rowChild)) continue;\n\n if (isComponentType(rowChild, TableRowCompound)) {\n const rowProps = rowChild.props;\n const cells = parseCells(rowProps.children, columns);\n\n rows.push({\n key: rowChild.key ?? rowProps.key ?? String(rows.length),\n cells,\n onClick: rowProps.onClick,\n dataTestId: rowProps[\"data-testid\"],\n });\n } else {\n rows.push(rowChild);\n }\n }\n }\n }\n\n return {\n columns,\n rows,\n };\n};\n"],"names":["isComponentType","element","componentType","parseColumns","headerChildren","isHeaderHidden","columns","childrenArray","Children","columnChild","isValidElement","TableColumnCompound","columnProps","parseCells","rowChildren","cells","cellIndex","cellChild","TableCellCompound","cellProps","columnKey","_a","parseTableChildren","children","rows","child","TableHeaderCompound","headerProps","parsedColumns","TableBodyCompound","bodyProps","bodyChildren","rowChild","TableRowCompound","rowProps"],"mappings":";;AAsBA,MAAMA,IAAkB,CACtBC,GACAC,MACYD,EAAQ,SAASC,GAKzBC,IAAe,CACnBC,GACAC,MACsB;AACtB,QAAMC,IAA6B,CAAA,GAC7BC,IAAgBC,EAAS,QAAQJ,CAAc;AAErD,aAAWK,KAAeF;AACxB,QACEG,EAAeD,CAAW,KAC1BT,EAAgBS,GAAaE,CAAmB,GAChD;AACA,YAAMC,IAAcH,EAAY;AAChC,MAAAH,EAAQ,KAAK;AAAA,QACX,KAAKM,EAAY;AAAA,QACjB,QAAQA,EAAY;AAAA,QACpB,UAAUP;AAAA,QACV,UAAUO,EAAY,WAAW;AAAA,MAAA,CAClC;AAAA,IACH;AAGK,SAAAN;AACT,GAKMO,IAAa,CACjBC,GACAR,MACoB;;AACpB,QAAMS,IAAyB,CAAA,GACzBR,IAAgBC,EAAS,QAAQM,CAAW;AAClD,MAAIE,IAAY;AAEhB,aAAWC,KAAaV;AACtB,QACEG,EAAeO,CAAS,KACxBjB,EAAgBiB,GAAWC,CAAiB,GAC5C;AACA,YAAMC,IAAYF,EAAU,OACtBG,IAAYD,EAAU,eAAaE,IAAAf,EAAQU,CAAS,MAAjB,gBAAAK,EAAoB;AAE7D,MAAID,KACFL,EAAM,KAAK;AAAA,QACT,WAAAK;AAAA,QACA,OAAOD,EAAU;AAAA,QACjB,SAASA,EAAU;AAAA,QACnB,YAAYA,EAAU,aAAa;AAAA,MAAA,
|
|
1
|
+
{"version":3,"file":"collectionParser.es.js","sources":["../../../../../src/components/Table/BaseTable/Collection/collectionParser.ts"],"sourcesContent":["import {\n Children,\n isValidElement,\n ReactElement,\n ReactNode,\n ComponentType,\n} from \"react\";\n\nimport {\n TableHeaderCompound,\n TableColumnCompound,\n TableBodyCompound,\n TableRowCompound,\n TableCellCompound,\n} from \"./CompoundComponents\";\nimport type {\n TableColumnData,\n TableData,\n TableRowData,\n TableCellData,\n} from \"../types\";\n\nconst isComponentType = (\n element: ReactElement,\n componentType: ComponentType<any>,\n): boolean => element.type === componentType;\n\n/**\n * Parses columns from Table.Header children\n */\nconst parseColumns = (\n headerChildren: ReactNode,\n isHeaderHidden: boolean,\n): TableColumnData[] => {\n const columns: TableColumnData[] = [];\n const childrenArray = Children.toArray(headerChildren);\n\n for (const columnChild of childrenArray) {\n if (\n isValidElement(columnChild) &&\n isComponentType(columnChild, TableColumnCompound)\n ) {\n const columnProps = columnChild.props;\n columns.push({\n key: columnProps.id,\n header: columnProps.children,\n isHidden: isHeaderHidden,\n ariaSort: columnProps[\"aria-sort\"],\n });\n }\n }\n\n return columns;\n};\n\n/**\n * Parses cells from Table.Row children\n */\nconst parseCells = (\n rowChildren: ReactNode,\n columns: TableColumnData[],\n): TableCellData[] => {\n const cells: TableCellData[] = [];\n const childrenArray = Children.toArray(rowChildren);\n let cellIndex = 0;\n\n for (const cellChild of childrenArray) {\n if (\n isValidElement(cellChild) &&\n isComponentType(cellChild, TableCellCompound)\n ) {\n const cellProps = cellChild.props;\n const columnKey = cellProps.columnKey ?? columns[cellIndex]?.key;\n\n if (columnKey) {\n cells.push({\n columnKey,\n value: cellProps.children,\n colSpan: cellProps.colSpan,\n dataTestId: cellProps[\"data-testid\"],\n textAlign: cellProps.textAlign,\n });\n }\n cellIndex++;\n }\n }\n\n return cells;\n};\n\n/**\n * Parses JSX table structure into collection data format.\n *\n * @returns parsed table data\n * @see {@link TableData} for the parsed table data structure\n */\nexport const parseTableChildren = (children: ReactNode): TableData => {\n const columns: TableColumnData[] = [];\n const rows: (TableRowData | ReactElement)[] = [];\n const childrenArray = Children.toArray(children);\n\n for (const child of childrenArray) {\n if (!isValidElement(child)) continue;\n\n // Parse columns from header\n if (isComponentType(child, TableHeaderCompound)) {\n const headerProps = child.props;\n const parsedColumns = parseColumns(\n headerProps.children,\n headerProps.isHidden || false,\n );\n columns.push(...parsedColumns);\n continue;\n }\n\n // Parse rows from body\n if (isComponentType(child, TableBodyCompound)) {\n const bodyProps = child.props;\n const bodyChildren = Children.toArray(bodyProps.children);\n\n for (const rowChild of bodyChildren) {\n if (!isValidElement(rowChild)) continue;\n\n if (isComponentType(rowChild, TableRowCompound)) {\n const rowProps = rowChild.props;\n const cells = parseCells(rowProps.children, columns);\n\n rows.push({\n key: rowChild.key ?? rowProps.key ?? String(rows.length),\n cells,\n onClick: rowProps.onClick,\n dataTestId: rowProps[\"data-testid\"],\n });\n } else {\n rows.push(rowChild);\n }\n }\n }\n }\n\n return {\n columns,\n rows,\n };\n};\n"],"names":["isComponentType","element","componentType","parseColumns","headerChildren","isHeaderHidden","columns","childrenArray","Children","columnChild","isValidElement","TableColumnCompound","columnProps","parseCells","rowChildren","cells","cellIndex","cellChild","TableCellCompound","cellProps","columnKey","_a","parseTableChildren","children","rows","child","TableHeaderCompound","headerProps","parsedColumns","TableBodyCompound","bodyProps","bodyChildren","rowChild","TableRowCompound","rowProps"],"mappings":";;AAsBA,MAAMA,IAAkB,CACtBC,GACAC,MACYD,EAAQ,SAASC,GAKzBC,IAAe,CACnBC,GACAC,MACsB;AACtB,QAAMC,IAA6B,CAAA,GAC7BC,IAAgBC,EAAS,QAAQJ,CAAc;AAErD,aAAWK,KAAeF;AACxB,QACEG,EAAeD,CAAW,KAC1BT,EAAgBS,GAAaE,CAAmB,GAChD;AACA,YAAMC,IAAcH,EAAY;AAChC,MAAAH,EAAQ,KAAK;AAAA,QACX,KAAKM,EAAY;AAAA,QACjB,QAAQA,EAAY;AAAA,QACpB,UAAUP;AAAA,QACV,UAAUO,EAAY,WAAW;AAAA,MAAA,CAClC;AAAA,IACH;AAGK,SAAAN;AACT,GAKMO,IAAa,CACjBC,GACAR,MACoB;;AACpB,QAAMS,IAAyB,CAAA,GACzBR,IAAgBC,EAAS,QAAQM,CAAW;AAClD,MAAIE,IAAY;AAEhB,aAAWC,KAAaV;AACtB,QACEG,EAAeO,CAAS,KACxBjB,EAAgBiB,GAAWC,CAAiB,GAC5C;AACA,YAAMC,IAAYF,EAAU,OACtBG,IAAYD,EAAU,eAAaE,IAAAf,EAAQU,CAAS,MAAjB,gBAAAK,EAAoB;AAE7D,MAAID,KACFL,EAAM,KAAK;AAAA,QACT,WAAAK;AAAA,QACA,OAAOD,EAAU;AAAA,QACjB,SAASA,EAAU;AAAA,QACnB,YAAYA,EAAU,aAAa;AAAA,QACnC,WAAWA,EAAU;AAAA,MAAA,CACtB,GAEHH;AAAA,IACF;AAGK,SAAAD;AACT,GAQaO,IAAqB,CAACC,MAAmC;AACpE,QAAMjB,IAA6B,CAAA,GAC7BkB,IAAwC,CAAA,GACxCjB,IAAgBC,EAAS,QAAQe,CAAQ;AAE/C,aAAWE,KAASlB;AACd,QAACG,EAAee,CAAK,GAGrB;AAAA,UAAAzB,EAAgByB,GAAOC,CAAmB,GAAG;AAC/C,cAAMC,IAAcF,EAAM,OACpBG,IAAgBzB;AAAA,UACpBwB,EAAY;AAAA,UACZA,EAAY,YAAY;AAAA,QAAA;AAElB,QAAArB,EAAA,KAAK,GAAGsB,CAAa;AAC7B;AAAA,MACF;AAGI,UAAA5B,EAAgByB,GAAOI,CAAiB,GAAG;AAC7C,cAAMC,IAAYL,EAAM,OAClBM,IAAevB,EAAS,QAAQsB,EAAU,QAAQ;AAExD,mBAAWE,KAAYD;AACjB,cAACrB,EAAesB,CAAQ;AAExB,gBAAAhC,EAAgBgC,GAAUC,CAAgB,GAAG;AAC/C,oBAAMC,IAAWF,EAAS,OACpBjB,IAAQF,EAAWqB,EAAS,UAAU5B,CAAO;AAEnD,cAAAkB,EAAK,KAAK;AAAA,gBACR,KAAKQ,EAAS,OAAOE,EAAS,OAAO,OAAOV,EAAK,MAAM;AAAA,gBACvD,OAAAT;AAAA,gBACA,SAASmB,EAAS;AAAA,gBAClB,YAAYA,EAAS,aAAa;AAAA,cAAA,CACnC;AAAA,YAAA;AAED,cAAAV,EAAK,KAAKQ,CAAQ;AAAA,MAGxB;AAAA;AAGK,SAAA;AAAA,IACL,SAAA1B;AAAA,IACA,MAAAkB;AAAA,EAAA;AAEJ;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../../../node_modules/react/jsx-runtime.cjs.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../../../node_modules/react/jsx-runtime.cjs.js"),x=require("react"),m=require("./Collection/collectionParser.cjs.js"),r=require("./Collection/CompoundComponents.cjs.js"),C=require("./Collection/useTableCollection.cjs.js"),p=require("./elements/TableRoot.cjs.js"),R=require("./elements/TableHeader.cjs.js"),j=require("./elements/TableHeaderRow.cjs.js"),q=require("./elements/TableHeaderCell.cjs.js"),y=require("./elements/TableBody.cjs.js"),g=require("./elements/TableRow.cjs.js"),H=require("./elements/TableCell.cjs.js");;/* empty css */const i=({children:d,name:u})=>{const c=m.parseTableChildren(d),o=C.useTableCollection(c);return t.jsxRuntimeExports.jsxs(p.TableRoot,{name:u,rowCount:o.getTotalRowCount,colCount:o.columns.length,children:[t.jsxRuntimeExports.jsx(R.TableHeader,{isHidden:o.isHeaderHidden,children:t.jsxRuntimeExports.jsx(j.TableHeaderRow,{children:o.columns.map((n,l)=>t.jsxRuntimeExports.jsx(q.TableHeaderCell,{colIndex:o.getColumnAriaIndex(l),ariaSort:n.ariaSort,children:n.header},n.key))})}),t.jsxRuntimeExports.jsx(y.TableBody,{children:o.rows.map((n,l)=>{if(x.isValidElement(n))return n;const a=n;return t.jsxRuntimeExports.jsx(g.TableRow,{ariaRowIndex:o.getRowAriaIndex(l),onClick:a.onClick,dataTestId:a.dataTestId,children:o.columns.map((s,T)=>{const e=a.cells.find(b=>b.columnKey===s.key);return t.jsxRuntimeExports.jsx(H.TableCell,{columnIndex:o.getColumnAriaIndex(T),columnSpan:e==null?void 0:e.colSpan,dataTestId:e==null?void 0:e.dataTestId,textAlign:e==null?void 0:e.textAlign,children:(e==null?void 0:e.value)??""},s.key)})},a.key)})})]})};i.displayName="ProtonUITable";const I=Object.assign(i,{Header:r.TableHeaderCompound,Column:r.TableColumnCompound,Body:r.TableBodyCompound,Row:r.TableRowCompound,Cell:r.TableCellCompound});exports.Table=I;
|
|
2
2
|
//# sourceMappingURL=Table.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Table.cjs.js","sources":["../../../../src/components/Table/BaseTable/Table.tsx"],"sourcesContent":["import { ReactElement, isValidElement } from \"react\";\nimport { parseTableChildren } from \"./Collection/collectionParser\";\nimport {\n TableHeaderCompound,\n TableColumnCompound,\n TableBodyCompound,\n TableRowCompound,\n TableCellCompound,\n TableHeaderProps as CompoundHeaderProps,\n TableColumnProps as CompoundColumnProps,\n TableBodyProps as CompoundBodyProps,\n TableRowProps as CompoundRowProps,\n TableCellProps as CompoundCellProps,\n} from \"./Collection/CompoundComponents\";\nimport { useTableCollection } from \"./Collection/useTableCollection\";\nimport type {\n TableData,\n TableColumnData,\n TableRowData,\n TableCellData,\n} from \"./types\";\nimport { TableRoot } from \"./elements/TableRoot\";\nimport { TableHeader } from \"./elements/TableHeader\";\nimport { TableHeaderRow } from \"./elements/TableHeaderRow\";\nimport { TableHeaderCell } from \"./elements/TableHeaderCell\";\nimport { TableBody } from \"./elements/TableBody\";\nimport { TableRow } from \"./elements/TableRow\";\nimport { TableCell } from \"./elements/TableCell\";\nimport \"./Table.css\";\n\nexport type { TableColumnData, TableCellData, TableRowData, TableData };\n\nexport interface TableProps {\n children: [\n ReactElement<CompoundHeaderProps>,\n ReactElement<CompoundBodyProps>,\n ];\n /** Table name/caption for accessibility. Provides essential context for screen readers about table content. */\n name: string;\n}\n\nconst TableComponent = ({ children, name }: TableProps) => {\n const tableData: TableData = parseTableChildren(children);\n const collection = useTableCollection(tableData);\n\n return (\n <TableRoot\n name={name}\n rowCount={collection.getTotalRowCount}\n colCount={collection.columns.length}\n >\n {/* Header */}\n <TableHeader isHidden={collection.isHeaderHidden}>\n <TableHeaderRow>\n {collection.columns.map((column, index) => (\n <TableHeaderCell\n key={column.key}\n colIndex={collection.getColumnAriaIndex(index)}\n ariaSort={column.ariaSort}\n >\n {column.header}\n </TableHeaderCell>\n ))}\n </TableHeaderRow>\n </TableHeader>\n\n {/* Body */}\n <TableBody>\n {collection.rows.map((row, rowIndex) => {\n if (isValidElement(row)) return row;\n\n const tableRow = row as TableRowData;\n\n return (\n <TableRow\n key={tableRow.key}\n ariaRowIndex={collection.getRowAriaIndex(rowIndex)}\n onClick={tableRow.onClick}\n dataTestId={tableRow.dataTestId}\n >\n {collection.columns.map((column, colIndex) => {\n const cell = tableRow.cells.find(\n (c) => c.columnKey === column.key,\n );\n\n return (\n <TableCell\n key={column.key}\n columnIndex={collection.getColumnAriaIndex(colIndex)}\n columnSpan={cell?.colSpan}\n dataTestId={cell?.dataTestId}\n >\n {cell?.value ?? \"\"}\n </TableCell>\n );\n })}\n </TableRow>\n );\n })}\n </TableBody>\n </TableRoot>\n );\n};\n\nTableComponent.displayName = \"ProtonUITable\";\n\n/**\n * Base Table component that renders data in rows and columns using collections.\n *\n * ## Features\n * - Built-in keyboard navigation for interactive rows\n * - Full ARIA table semantics with proper roles, labels, and indices\n * - Support for both declarative and custom row rendering\n *\n * @see {@link TableProps} \n * @see {@link CompoundHeaderProps} \n * @see {@link CompoundColumnProps} \n * @see {@link CompoundBodyProps} \n * @see {@link CompoundRowProps} \n * @see {@link CompoundCellProps} \n * @see {@link parseTableChildren} for parser documentation\n *\n * ## Row APIs\n *\n * ### Declarative (Table.Row)\n * Use `Table.Row` with `Table.Cell` for automatic handling of rendering, accessibility, and keyboard navigation.\n *\n * @example\n * ```tsx\n <Table name=\"Employee Directory\">\n <Table.Header>\n <Table.Column id=\"name\">Name</Table.Column>\n </Table.Header>\n <Table.Body>\n <Table.Row key=\"1\">\n <Table.Cell>Joe</Table.Cell>\n </Table.Row>\n </Table.Body>\n </Table>\n * ```\n *\n * ### Imperative (ReactElement)\n * Pass custom components or `<tr>` elements directly to `Table.Body`. Powers advanced use cases like\n * row-level memoization, virtualization, drag-and-drop, or animations.\n *\n * **Consumer Responsibilities for Custom Rows:**\n * - Must directly render a `<tr>` element with `role=\"row\"`\n * - Set `aria-rowindex` (header is 1, data rows start at 2)\n * - Handle keyboard navigation if the row is interactive\n * - Apply styling as needed: `proton-Table__row`, `proton-Table__cell`, etc.\n *\n * @example custom row implementation\n * ```tsx\n const MemoizedRow = memo(({ data, rowIndex }) => (\n <tr\n className=\"proton-Table__row\"\n role=\"row\"\n aria-rowindex={calculateAriaRowIndex(rowIndex)}\n >\n <td className=\"proton-Table__cell\" role=\"cell\">\n {data.name}\n </td>\n </tr>\n ));\n\n <Table.Body>\n {data.map((item, i) => (\n <MemoizedRow key={item.id} data={item} rowIndex={i} />\n ))}\n </Table.Body>\n * ```\n *\n * @example reusable component implementation\n * ```tsx\n const MemoizedRow = memo(({ data, rowIndex }) => (\n <TableRow ariaRowIndex={calculateAriaRowIndex(rowIndex)}>\n <TableCell columnIndex={1}>\n {data.name}\n </TableCell>\n </TableRow>\n ));\n\n <Table.Body>\n {data.map((item, i) => (\n <MemoizedRow key={item.id} data={item} rowIndex={i} />\n ))}\n </Table.Body>\n * ```\n *\n * @see {@link DataTable} for a higher-level component that uses custom rows internally\n * @see {@link DataTableRow} for an example of a memoized custom row implementation\n */\nconst Table = Object.assign(TableComponent, {\n /** Table header: {@link CompoundHeaderProps} */\n Header: TableHeaderCompound,\n /** Table column: {@link CompoundColumnProps} */\n Column: TableColumnCompound,\n /** Table body: {@link CompoundBodyProps} */\n Body: TableBodyCompound,\n /** Table row: {@link CompoundRowProps} */\n Row: TableRowCompound,\n /** Table cell: {@link CompoundCellProps} */\n Cell: TableCellCompound,\n});\n\nexport { Table };\
|
|
1
|
+
{"version":3,"file":"Table.cjs.js","sources":["../../../../src/components/Table/BaseTable/Table.tsx"],"sourcesContent":["import { ReactElement, isValidElement } from \"react\";\nimport { parseTableChildren } from \"./Collection/collectionParser\";\nimport {\n TableHeaderCompound,\n TableColumnCompound,\n TableBodyCompound,\n TableRowCompound,\n TableCellCompound,\n TableHeaderProps as CompoundHeaderProps,\n TableColumnProps as CompoundColumnProps,\n TableBodyProps as CompoundBodyProps,\n TableRowProps as CompoundRowProps,\n TableCellProps as CompoundCellProps,\n} from \"./Collection/CompoundComponents\";\nimport { useTableCollection } from \"./Collection/useTableCollection\";\nimport type {\n TableData,\n TableColumnData,\n TableRowData,\n TableCellData,\n} from \"./types\";\nimport { TableRoot } from \"./elements/TableRoot\";\nimport { TableHeader } from \"./elements/TableHeader\";\nimport { TableHeaderRow } from \"./elements/TableHeaderRow\";\nimport { TableHeaderCell } from \"./elements/TableHeaderCell\";\nimport { TableBody } from \"./elements/TableBody\";\nimport { TableRow } from \"./elements/TableRow\";\nimport { TableCell } from \"./elements/TableCell\";\nimport \"./Table.css\";\n\nexport type { TableColumnData, TableCellData, TableRowData, TableData };\n\nexport interface TableProps {\n children: [\n ReactElement<CompoundHeaderProps>,\n ReactElement<CompoundBodyProps>,\n ];\n /** Table name/caption for accessibility. Provides essential context for screen readers about table content. */\n name: string;\n}\n\nconst TableComponent = ({ children, name }: TableProps) => {\n const tableData: TableData = parseTableChildren(children);\n const collection = useTableCollection(tableData);\n\n return (\n <TableRoot\n name={name}\n rowCount={collection.getTotalRowCount}\n colCount={collection.columns.length}\n >\n {/* Header */}\n <TableHeader isHidden={collection.isHeaderHidden}>\n <TableHeaderRow>\n {collection.columns.map((column, index) => (\n <TableHeaderCell\n key={column.key}\n colIndex={collection.getColumnAriaIndex(index)}\n ariaSort={column.ariaSort}\n >\n {column.header}\n </TableHeaderCell>\n ))}\n </TableHeaderRow>\n </TableHeader>\n\n {/* Body */}\n <TableBody>\n {collection.rows.map((row, rowIndex) => {\n if (isValidElement(row)) return row;\n\n const tableRow = row as TableRowData;\n\n return (\n <TableRow\n key={tableRow.key}\n ariaRowIndex={collection.getRowAriaIndex(rowIndex)}\n onClick={tableRow.onClick}\n dataTestId={tableRow.dataTestId}\n >\n {collection.columns.map((column, colIndex) => {\n const cell = tableRow.cells.find(\n (c) => c.columnKey === column.key,\n );\n\n return (\n <TableCell\n key={column.key}\n columnIndex={collection.getColumnAriaIndex(colIndex)}\n columnSpan={cell?.colSpan}\n dataTestId={cell?.dataTestId}\n textAlign={cell?.textAlign}\n >\n {cell?.value ?? \"\"}\n </TableCell>\n );\n })}\n </TableRow>\n );\n })}\n </TableBody>\n </TableRoot>\n );\n};\n\nTableComponent.displayName = \"ProtonUITable\";\n\n/**\n * Base Table component that renders data in rows and columns using collections.\n *\n * ## Features\n * - Built-in keyboard navigation for interactive rows\n * - Full ARIA table semantics with proper roles, labels, and indices\n * - Support for both declarative and custom row rendering\n *\n * @see {@link TableProps} \n * @see {@link CompoundHeaderProps} \n * @see {@link CompoundColumnProps} \n * @see {@link CompoundBodyProps} \n * @see {@link CompoundRowProps} \n * @see {@link CompoundCellProps} \n * @see {@link parseTableChildren} for parser documentation\n *\n * ## Row APIs\n *\n * ### Declarative (Table.Row)\n * Use `Table.Row` with `Table.Cell` for automatic handling of rendering, accessibility, and keyboard navigation.\n *\n * @example\n * ```tsx\n <Table name=\"Employee Directory\">\n <Table.Header>\n <Table.Column id=\"name\">Name</Table.Column>\n </Table.Header>\n <Table.Body>\n <Table.Row key=\"1\">\n <Table.Cell>Joe</Table.Cell>\n </Table.Row>\n </Table.Body>\n </Table>\n * ```\n *\n * ### Imperative (ReactElement)\n * Pass custom components or `<tr>` elements directly to `Table.Body`. Powers advanced use cases like\n * row-level memoization, virtualization, drag-and-drop, or animations.\n *\n * **Consumer Responsibilities for Custom Rows:**\n * - Must directly render a `<tr>` element with `role=\"row\"`\n * - Set `aria-rowindex` (header is 1, data rows start at 2)\n * - Handle keyboard navigation if the row is interactive\n * - Apply styling as needed: `proton-Table__row`, `proton-Table__cell`, etc.\n *\n * @example custom row implementation\n * ```tsx\n const MemoizedRow = memo(({ data, rowIndex }) => (\n <tr\n className=\"proton-Table__row\"\n role=\"row\"\n aria-rowindex={calculateAriaRowIndex(rowIndex)}\n >\n <td className=\"proton-Table__cell\" role=\"cell\">\n {data.name}\n </td>\n </tr>\n ));\n\n <Table.Body>\n {data.map((item, i) => (\n <MemoizedRow key={item.id} data={item} rowIndex={i} />\n ))}\n </Table.Body>\n * ```\n *\n * @example reusable component implementation\n * ```tsx\n const MemoizedRow = memo(({ data, rowIndex }) => (\n <TableRow ariaRowIndex={calculateAriaRowIndex(rowIndex)}>\n <TableCell columnIndex={1}>\n {data.name}\n </TableCell>\n </TableRow>\n ));\n\n <Table.Body>\n {data.map((item, i) => (\n <MemoizedRow key={item.id} data={item} rowIndex={i} />\n ))}\n </Table.Body>\n * ```\n *\n * @see {@link DataTable} for a higher-level component that uses custom rows internally\n * @see {@link DataTableRow} for an example of a memoized custom row implementation\n */\nconst Table = Object.assign(TableComponent, {\n /** Table header: {@link CompoundHeaderProps} */\n Header: TableHeaderCompound,\n /** Table column: {@link CompoundColumnProps} */\n Column: TableColumnCompound,\n /** Table body: {@link CompoundBodyProps} */\n Body: TableBodyCompound,\n /** Table row: {@link CompoundRowProps} */\n Row: TableRowCompound,\n /** Table cell: {@link CompoundCellProps} */\n Cell: TableCellCompound,\n});\n\nexport { Table };\n"],"names":["TableComponent","children","name","tableData","parseTableChildren","collection","useTableCollection","jsxs","TableRoot","jsx","TableHeader","TableHeaderRow","column","index","TableHeaderCell","TableBody","row","rowIndex","isValidElement","tableRow","TableRow","colIndex","cell","c","TableCell","Table","TableHeaderCompound","TableColumnCompound","TableBodyCompound","TableRowCompound","TableCellCompound"],"mappings":"woBAyCA,MAAMA,EAAiB,CAAC,CAAE,SAAAC,EAAU,KAAAC,KAAuB,CACnD,MAAAC,EAAuBC,qBAAmBH,CAAQ,EAClDI,EAAaC,qBAAmBH,CAAS,EAG7C,OAAAI,EAAA,kBAAA,KAACC,EAAA,UAAA,CACC,KAAAN,EACA,SAAUG,EAAW,iBACrB,SAAUA,EAAW,QAAQ,OAG7B,SAAA,CAACI,EAAA,kBAAA,IAAAC,EAAA,YAAA,CAAY,SAAUL,EAAW,eAChC,SAAAI,EAAA,kBAAA,IAACE,EACE,eAAA,CAAA,SAAAN,EAAW,QAAQ,IAAI,CAACO,EAAQC,IAC/BJ,EAAA,kBAAA,IAACK,EAAA,gBAAA,CAEC,SAAUT,EAAW,mBAAmBQ,CAAK,EAC7C,SAAUD,EAAO,SAEhB,SAAOA,EAAA,MAAA,EAJHA,EAAO,GAAA,CAMf,EACH,CACF,CAAA,0BAGCG,EAAAA,UACE,CAAA,SAAAV,EAAW,KAAK,IAAI,CAACW,EAAKC,IAAa,CAClC,GAAAC,iBAAeF,CAAG,EAAU,OAAAA,EAEhC,MAAMG,EAAWH,EAGf,OAAAP,EAAA,kBAAA,IAACW,EAAA,SAAA,CAEC,aAAcf,EAAW,gBAAgBY,CAAQ,EACjD,QAASE,EAAS,QAClB,WAAYA,EAAS,WAEpB,SAAWd,EAAA,QAAQ,IAAI,CAACO,EAAQS,IAAa,CACtC,MAAAC,EAAOH,EAAS,MAAM,KACzBI,GAAMA,EAAE,YAAcX,EAAO,GAAA,EAI9B,OAAAH,EAAA,kBAAA,IAACe,EAAA,UAAA,CAEC,YAAanB,EAAW,mBAAmBgB,CAAQ,EACnD,WAAYC,GAAA,YAAAA,EAAM,QAClB,WAAYA,GAAA,YAAAA,EAAM,WAClB,UAAWA,GAAA,YAAAA,EAAM,UAEhB,2BAAM,QAAS,EAAA,EANXV,EAAO,GAAA,CAOd,CAEH,CAAA,EArBIO,EAAS,GAAA,CAwBnB,CAAA,EACH,CAAA,CAAA,CAAA,CAGN,EAEAnB,EAAe,YAAc,gBAwFvB,MAAAyB,EAAQ,OAAO,OAAOzB,EAAgB,CAE1C,OAAQ0B,EAAA,oBAER,OAAQC,EAAA,oBAER,KAAMC,EAAA,kBAEN,IAAKC,EAAA,iBAEL,KAAMC,EAAA,iBACR,CAAC"}
|
|
@@ -1,60 +1,61 @@
|
|
|
1
|
-
import { j as
|
|
1
|
+
import { j as t } from "../../../node_modules/react/jsx-runtime.es.js";
|
|
2
2
|
import { isValidElement as T } from "react";
|
|
3
|
-
import { parseTableChildren as
|
|
4
|
-
import { TableHeaderCompound as
|
|
3
|
+
import { parseTableChildren as C } from "./Collection/collectionParser.es.js";
|
|
4
|
+
import { TableHeaderCompound as b, TableColumnCompound as c, TableBodyCompound as x, TableRowCompound as f, TableCellCompound as I } from "./Collection/CompoundComponents.es.js";
|
|
5
5
|
import { useTableCollection as h } from "./Collection/useTableCollection.es.js";
|
|
6
6
|
import { TableRoot as j } from "./elements/TableRoot.es.js";
|
|
7
7
|
import { TableHeader as R } from "./elements/TableHeader.es.js";
|
|
8
8
|
import { TableHeaderRow as y } from "./elements/TableHeaderRow.es.js";
|
|
9
|
-
import { TableHeaderCell as
|
|
10
|
-
import { TableBody as
|
|
11
|
-
import { TableRow as
|
|
9
|
+
import { TableHeaderCell as g } from "./elements/TableHeaderCell.es.js";
|
|
10
|
+
import { TableBody as w } from "./elements/TableBody.es.js";
|
|
11
|
+
import { TableRow as H } from "./elements/TableRow.es.js";
|
|
12
12
|
import { TableCell as k } from "./elements/TableCell.es.js";
|
|
13
13
|
/* empty css */
|
|
14
|
-
const d = ({ children:
|
|
15
|
-
const s =
|
|
16
|
-
return /* @__PURE__ */
|
|
14
|
+
const d = ({ children: i, name: m }) => {
|
|
15
|
+
const s = C(i), e = h(s);
|
|
16
|
+
return /* @__PURE__ */ t.jsxs(
|
|
17
17
|
j,
|
|
18
18
|
{
|
|
19
|
-
name:
|
|
20
|
-
rowCount:
|
|
21
|
-
colCount:
|
|
19
|
+
name: m,
|
|
20
|
+
rowCount: e.getTotalRowCount,
|
|
21
|
+
colCount: e.columns.length,
|
|
22
22
|
children: [
|
|
23
|
-
/* @__PURE__ */
|
|
24
|
-
|
|
23
|
+
/* @__PURE__ */ t.jsx(R, { isHidden: e.isHeaderHidden, children: /* @__PURE__ */ t.jsx(y, { children: e.columns.map((r, n) => /* @__PURE__ */ t.jsx(
|
|
24
|
+
g,
|
|
25
25
|
{
|
|
26
|
-
colIndex:
|
|
26
|
+
colIndex: e.getColumnAriaIndex(n),
|
|
27
27
|
ariaSort: r.ariaSort,
|
|
28
28
|
children: r.header
|
|
29
29
|
},
|
|
30
30
|
r.key
|
|
31
31
|
)) }) }),
|
|
32
|
-
/* @__PURE__ */
|
|
32
|
+
/* @__PURE__ */ t.jsx(w, { children: e.rows.map((r, n) => {
|
|
33
33
|
if (T(r)) return r;
|
|
34
|
-
const
|
|
35
|
-
return /* @__PURE__ */
|
|
36
|
-
|
|
34
|
+
const a = r;
|
|
35
|
+
return /* @__PURE__ */ t.jsx(
|
|
36
|
+
H,
|
|
37
37
|
{
|
|
38
|
-
ariaRowIndex:
|
|
39
|
-
onClick:
|
|
40
|
-
dataTestId:
|
|
41
|
-
children:
|
|
42
|
-
const
|
|
38
|
+
ariaRowIndex: e.getRowAriaIndex(n),
|
|
39
|
+
onClick: a.onClick,
|
|
40
|
+
dataTestId: a.dataTestId,
|
|
41
|
+
children: e.columns.map((l, p) => {
|
|
42
|
+
const o = a.cells.find(
|
|
43
43
|
(u) => u.columnKey === l.key
|
|
44
44
|
);
|
|
45
|
-
return /* @__PURE__ */
|
|
45
|
+
return /* @__PURE__ */ t.jsx(
|
|
46
46
|
k,
|
|
47
47
|
{
|
|
48
|
-
columnIndex:
|
|
49
|
-
columnSpan:
|
|
50
|
-
dataTestId:
|
|
51
|
-
|
|
48
|
+
columnIndex: e.getColumnAriaIndex(p),
|
|
49
|
+
columnSpan: o == null ? void 0 : o.colSpan,
|
|
50
|
+
dataTestId: o == null ? void 0 : o.dataTestId,
|
|
51
|
+
textAlign: o == null ? void 0 : o.textAlign,
|
|
52
|
+
children: (o == null ? void 0 : o.value) ?? ""
|
|
52
53
|
},
|
|
53
54
|
l.key
|
|
54
55
|
);
|
|
55
56
|
})
|
|
56
57
|
},
|
|
57
|
-
|
|
58
|
+
a.key
|
|
58
59
|
);
|
|
59
60
|
}) })
|
|
60
61
|
]
|
|
@@ -64,9 +65,9 @@ const d = ({ children: m, name: i }) => {
|
|
|
64
65
|
d.displayName = "ProtonUITable";
|
|
65
66
|
const z = Object.assign(d, {
|
|
66
67
|
/** Table header: {@link CompoundHeaderProps} */
|
|
67
|
-
Header:
|
|
68
|
+
Header: b,
|
|
68
69
|
/** Table column: {@link CompoundColumnProps} */
|
|
69
|
-
Column:
|
|
70
|
+
Column: c,
|
|
70
71
|
/** Table body: {@link CompoundBodyProps} */
|
|
71
72
|
Body: x,
|
|
72
73
|
/** Table row: {@link CompoundRowProps} */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Table.es.js","sources":["../../../../src/components/Table/BaseTable/Table.tsx"],"sourcesContent":["import { ReactElement, isValidElement } from \"react\";\nimport { parseTableChildren } from \"./Collection/collectionParser\";\nimport {\n TableHeaderCompound,\n TableColumnCompound,\n TableBodyCompound,\n TableRowCompound,\n TableCellCompound,\n TableHeaderProps as CompoundHeaderProps,\n TableColumnProps as CompoundColumnProps,\n TableBodyProps as CompoundBodyProps,\n TableRowProps as CompoundRowProps,\n TableCellProps as CompoundCellProps,\n} from \"./Collection/CompoundComponents\";\nimport { useTableCollection } from \"./Collection/useTableCollection\";\nimport type {\n TableData,\n TableColumnData,\n TableRowData,\n TableCellData,\n} from \"./types\";\nimport { TableRoot } from \"./elements/TableRoot\";\nimport { TableHeader } from \"./elements/TableHeader\";\nimport { TableHeaderRow } from \"./elements/TableHeaderRow\";\nimport { TableHeaderCell } from \"./elements/TableHeaderCell\";\nimport { TableBody } from \"./elements/TableBody\";\nimport { TableRow } from \"./elements/TableRow\";\nimport { TableCell } from \"./elements/TableCell\";\nimport \"./Table.css\";\n\nexport type { TableColumnData, TableCellData, TableRowData, TableData };\n\nexport interface TableProps {\n children: [\n ReactElement<CompoundHeaderProps>,\n ReactElement<CompoundBodyProps>,\n ];\n /** Table name/caption for accessibility. Provides essential context for screen readers about table content. */\n name: string;\n}\n\nconst TableComponent = ({ children, name }: TableProps) => {\n const tableData: TableData = parseTableChildren(children);\n const collection = useTableCollection(tableData);\n\n return (\n <TableRoot\n name={name}\n rowCount={collection.getTotalRowCount}\n colCount={collection.columns.length}\n >\n {/* Header */}\n <TableHeader isHidden={collection.isHeaderHidden}>\n <TableHeaderRow>\n {collection.columns.map((column, index) => (\n <TableHeaderCell\n key={column.key}\n colIndex={collection.getColumnAriaIndex(index)}\n ariaSort={column.ariaSort}\n >\n {column.header}\n </TableHeaderCell>\n ))}\n </TableHeaderRow>\n </TableHeader>\n\n {/* Body */}\n <TableBody>\n {collection.rows.map((row, rowIndex) => {\n if (isValidElement(row)) return row;\n\n const tableRow = row as TableRowData;\n\n return (\n <TableRow\n key={tableRow.key}\n ariaRowIndex={collection.getRowAriaIndex(rowIndex)}\n onClick={tableRow.onClick}\n dataTestId={tableRow.dataTestId}\n >\n {collection.columns.map((column, colIndex) => {\n const cell = tableRow.cells.find(\n (c) => c.columnKey === column.key,\n );\n\n return (\n <TableCell\n key={column.key}\n columnIndex={collection.getColumnAriaIndex(colIndex)}\n columnSpan={cell?.colSpan}\n dataTestId={cell?.dataTestId}\n >\n {cell?.value ?? \"\"}\n </TableCell>\n );\n })}\n </TableRow>\n );\n })}\n </TableBody>\n </TableRoot>\n );\n};\n\nTableComponent.displayName = \"ProtonUITable\";\n\n/**\n * Base Table component that renders data in rows and columns using collections.\n *\n * ## Features\n * - Built-in keyboard navigation for interactive rows\n * - Full ARIA table semantics with proper roles, labels, and indices\n * - Support for both declarative and custom row rendering\n *\n * @see {@link TableProps} \n * @see {@link CompoundHeaderProps} \n * @see {@link CompoundColumnProps} \n * @see {@link CompoundBodyProps} \n * @see {@link CompoundRowProps} \n * @see {@link CompoundCellProps} \n * @see {@link parseTableChildren} for parser documentation\n *\n * ## Row APIs\n *\n * ### Declarative (Table.Row)\n * Use `Table.Row` with `Table.Cell` for automatic handling of rendering, accessibility, and keyboard navigation.\n *\n * @example\n * ```tsx\n <Table name=\"Employee Directory\">\n <Table.Header>\n <Table.Column id=\"name\">Name</Table.Column>\n </Table.Header>\n <Table.Body>\n <Table.Row key=\"1\">\n <Table.Cell>Joe</Table.Cell>\n </Table.Row>\n </Table.Body>\n </Table>\n * ```\n *\n * ### Imperative (ReactElement)\n * Pass custom components or `<tr>` elements directly to `Table.Body`. Powers advanced use cases like\n * row-level memoization, virtualization, drag-and-drop, or animations.\n *\n * **Consumer Responsibilities for Custom Rows:**\n * - Must directly render a `<tr>` element with `role=\"row\"`\n * - Set `aria-rowindex` (header is 1, data rows start at 2)\n * - Handle keyboard navigation if the row is interactive\n * - Apply styling as needed: `proton-Table__row`, `proton-Table__cell`, etc.\n *\n * @example custom row implementation\n * ```tsx\n const MemoizedRow = memo(({ data, rowIndex }) => (\n <tr\n className=\"proton-Table__row\"\n role=\"row\"\n aria-rowindex={calculateAriaRowIndex(rowIndex)}\n >\n <td className=\"proton-Table__cell\" role=\"cell\">\n {data.name}\n </td>\n </tr>\n ));\n\n <Table.Body>\n {data.map((item, i) => (\n <MemoizedRow key={item.id} data={item} rowIndex={i} />\n ))}\n </Table.Body>\n * ```\n *\n * @example reusable component implementation\n * ```tsx\n const MemoizedRow = memo(({ data, rowIndex }) => (\n <TableRow ariaRowIndex={calculateAriaRowIndex(rowIndex)}>\n <TableCell columnIndex={1}>\n {data.name}\n </TableCell>\n </TableRow>\n ));\n\n <Table.Body>\n {data.map((item, i) => (\n <MemoizedRow key={item.id} data={item} rowIndex={i} />\n ))}\n </Table.Body>\n * ```\n *\n * @see {@link DataTable} for a higher-level component that uses custom rows internally\n * @see {@link DataTableRow} for an example of a memoized custom row implementation\n */\nconst Table = Object.assign(TableComponent, {\n /** Table header: {@link CompoundHeaderProps} */\n Header: TableHeaderCompound,\n /** Table column: {@link CompoundColumnProps} */\n Column: TableColumnCompound,\n /** Table body: {@link CompoundBodyProps} */\n Body: TableBodyCompound,\n /** Table row: {@link CompoundRowProps} */\n Row: TableRowCompound,\n /** Table cell: {@link CompoundCellProps} */\n Cell: TableCellCompound,\n});\n\nexport { Table };\
|
|
1
|
+
{"version":3,"file":"Table.es.js","sources":["../../../../src/components/Table/BaseTable/Table.tsx"],"sourcesContent":["import { ReactElement, isValidElement } from \"react\";\nimport { parseTableChildren } from \"./Collection/collectionParser\";\nimport {\n TableHeaderCompound,\n TableColumnCompound,\n TableBodyCompound,\n TableRowCompound,\n TableCellCompound,\n TableHeaderProps as CompoundHeaderProps,\n TableColumnProps as CompoundColumnProps,\n TableBodyProps as CompoundBodyProps,\n TableRowProps as CompoundRowProps,\n TableCellProps as CompoundCellProps,\n} from \"./Collection/CompoundComponents\";\nimport { useTableCollection } from \"./Collection/useTableCollection\";\nimport type {\n TableData,\n TableColumnData,\n TableRowData,\n TableCellData,\n} from \"./types\";\nimport { TableRoot } from \"./elements/TableRoot\";\nimport { TableHeader } from \"./elements/TableHeader\";\nimport { TableHeaderRow } from \"./elements/TableHeaderRow\";\nimport { TableHeaderCell } from \"./elements/TableHeaderCell\";\nimport { TableBody } from \"./elements/TableBody\";\nimport { TableRow } from \"./elements/TableRow\";\nimport { TableCell } from \"./elements/TableCell\";\nimport \"./Table.css\";\n\nexport type { TableColumnData, TableCellData, TableRowData, TableData };\n\nexport interface TableProps {\n children: [\n ReactElement<CompoundHeaderProps>,\n ReactElement<CompoundBodyProps>,\n ];\n /** Table name/caption for accessibility. Provides essential context for screen readers about table content. */\n name: string;\n}\n\nconst TableComponent = ({ children, name }: TableProps) => {\n const tableData: TableData = parseTableChildren(children);\n const collection = useTableCollection(tableData);\n\n return (\n <TableRoot\n name={name}\n rowCount={collection.getTotalRowCount}\n colCount={collection.columns.length}\n >\n {/* Header */}\n <TableHeader isHidden={collection.isHeaderHidden}>\n <TableHeaderRow>\n {collection.columns.map((column, index) => (\n <TableHeaderCell\n key={column.key}\n colIndex={collection.getColumnAriaIndex(index)}\n ariaSort={column.ariaSort}\n >\n {column.header}\n </TableHeaderCell>\n ))}\n </TableHeaderRow>\n </TableHeader>\n\n {/* Body */}\n <TableBody>\n {collection.rows.map((row, rowIndex) => {\n if (isValidElement(row)) return row;\n\n const tableRow = row as TableRowData;\n\n return (\n <TableRow\n key={tableRow.key}\n ariaRowIndex={collection.getRowAriaIndex(rowIndex)}\n onClick={tableRow.onClick}\n dataTestId={tableRow.dataTestId}\n >\n {collection.columns.map((column, colIndex) => {\n const cell = tableRow.cells.find(\n (c) => c.columnKey === column.key,\n );\n\n return (\n <TableCell\n key={column.key}\n columnIndex={collection.getColumnAriaIndex(colIndex)}\n columnSpan={cell?.colSpan}\n dataTestId={cell?.dataTestId}\n textAlign={cell?.textAlign}\n >\n {cell?.value ?? \"\"}\n </TableCell>\n );\n })}\n </TableRow>\n );\n })}\n </TableBody>\n </TableRoot>\n );\n};\n\nTableComponent.displayName = \"ProtonUITable\";\n\n/**\n * Base Table component that renders data in rows and columns using collections.\n *\n * ## Features\n * - Built-in keyboard navigation for interactive rows\n * - Full ARIA table semantics with proper roles, labels, and indices\n * - Support for both declarative and custom row rendering\n *\n * @see {@link TableProps} \n * @see {@link CompoundHeaderProps} \n * @see {@link CompoundColumnProps} \n * @see {@link CompoundBodyProps} \n * @see {@link CompoundRowProps} \n * @see {@link CompoundCellProps} \n * @see {@link parseTableChildren} for parser documentation\n *\n * ## Row APIs\n *\n * ### Declarative (Table.Row)\n * Use `Table.Row` with `Table.Cell` for automatic handling of rendering, accessibility, and keyboard navigation.\n *\n * @example\n * ```tsx\n <Table name=\"Employee Directory\">\n <Table.Header>\n <Table.Column id=\"name\">Name</Table.Column>\n </Table.Header>\n <Table.Body>\n <Table.Row key=\"1\">\n <Table.Cell>Joe</Table.Cell>\n </Table.Row>\n </Table.Body>\n </Table>\n * ```\n *\n * ### Imperative (ReactElement)\n * Pass custom components or `<tr>` elements directly to `Table.Body`. Powers advanced use cases like\n * row-level memoization, virtualization, drag-and-drop, or animations.\n *\n * **Consumer Responsibilities for Custom Rows:**\n * - Must directly render a `<tr>` element with `role=\"row\"`\n * - Set `aria-rowindex` (header is 1, data rows start at 2)\n * - Handle keyboard navigation if the row is interactive\n * - Apply styling as needed: `proton-Table__row`, `proton-Table__cell`, etc.\n *\n * @example custom row implementation\n * ```tsx\n const MemoizedRow = memo(({ data, rowIndex }) => (\n <tr\n className=\"proton-Table__row\"\n role=\"row\"\n aria-rowindex={calculateAriaRowIndex(rowIndex)}\n >\n <td className=\"proton-Table__cell\" role=\"cell\">\n {data.name}\n </td>\n </tr>\n ));\n\n <Table.Body>\n {data.map((item, i) => (\n <MemoizedRow key={item.id} data={item} rowIndex={i} />\n ))}\n </Table.Body>\n * ```\n *\n * @example reusable component implementation\n * ```tsx\n const MemoizedRow = memo(({ data, rowIndex }) => (\n <TableRow ariaRowIndex={calculateAriaRowIndex(rowIndex)}>\n <TableCell columnIndex={1}>\n {data.name}\n </TableCell>\n </TableRow>\n ));\n\n <Table.Body>\n {data.map((item, i) => (\n <MemoizedRow key={item.id} data={item} rowIndex={i} />\n ))}\n </Table.Body>\n * ```\n *\n * @see {@link DataTable} for a higher-level component that uses custom rows internally\n * @see {@link DataTableRow} for an example of a memoized custom row implementation\n */\nconst Table = Object.assign(TableComponent, {\n /** Table header: {@link CompoundHeaderProps} */\n Header: TableHeaderCompound,\n /** Table column: {@link CompoundColumnProps} */\n Column: TableColumnCompound,\n /** Table body: {@link CompoundBodyProps} */\n Body: TableBodyCompound,\n /** Table row: {@link CompoundRowProps} */\n Row: TableRowCompound,\n /** Table cell: {@link CompoundCellProps} */\n Cell: TableCellCompound,\n});\n\nexport { Table };\n"],"names":["TableComponent","children","name","tableData","parseTableChildren","collection","useTableCollection","jsxs","TableRoot","jsx","TableHeader","TableHeaderRow","column","index","TableHeaderCell","TableBody","row","rowIndex","isValidElement","tableRow","TableRow","colIndex","cell","c","TableCell","Table","TableHeaderCompound","TableColumnCompound","TableBodyCompound","TableRowCompound","TableCellCompound"],"mappings":";;;;;;;;;;;;;AAyCA,MAAMA,IAAiB,CAAC,EAAE,UAAAC,GAAU,MAAAC,QAAuB;AACnD,QAAAC,IAAuBC,EAAmBH,CAAQ,GAClDI,IAAaC,EAAmBH,CAAS;AAG7C,SAAAI,gBAAAA,EAAA;AAAA,IAACC;AAAA,IAAA;AAAA,MACC,MAAAN;AAAA,MACA,UAAUG,EAAW;AAAA,MACrB,UAAUA,EAAW,QAAQ;AAAA,MAG7B,UAAA;AAAA,QAACI,gBAAAA,EAAA,IAAAC,GAAA,EAAY,UAAUL,EAAW,gBAChC,UAAAI,gBAAAA,EAAA,IAACE,GACE,EAAA,UAAAN,EAAW,QAAQ,IAAI,CAACO,GAAQC,MAC/BJ,gBAAAA,EAAA;AAAA,UAACK;AAAA,UAAA;AAAA,YAEC,UAAUT,EAAW,mBAAmBQ,CAAK;AAAA,YAC7C,UAAUD,EAAO;AAAA,YAEhB,UAAOA,EAAA;AAAA,UAAA;AAAA,UAJHA,EAAO;AAAA,QAAA,CAMf,GACH,EACF,CAAA;AAAA,8BAGCG,GACE,EAAA,UAAAV,EAAW,KAAK,IAAI,CAACW,GAAKC,MAAa;AAClC,cAAAC,EAAeF,CAAG,EAAU,QAAAA;AAEhC,gBAAMG,IAAWH;AAGf,iBAAAP,gBAAAA,EAAA;AAAA,YAACW;AAAA,YAAA;AAAA,cAEC,cAAcf,EAAW,gBAAgBY,CAAQ;AAAA,cACjD,SAASE,EAAS;AAAA,cAClB,YAAYA,EAAS;AAAA,cAEpB,UAAWd,EAAA,QAAQ,IAAI,CAACO,GAAQS,MAAa;AACtC,sBAAAC,IAAOH,EAAS,MAAM;AAAA,kBAC1B,CAACI,MAAMA,EAAE,cAAcX,EAAO;AAAA,gBAAA;AAI9B,uBAAAH,gBAAAA,EAAA;AAAA,kBAACe;AAAA,kBAAA;AAAA,oBAEC,aAAanB,EAAW,mBAAmBgB,CAAQ;AAAA,oBACnD,YAAYC,KAAA,gBAAAA,EAAM;AAAA,oBAClB,YAAYA,KAAA,gBAAAA,EAAM;AAAA,oBAClB,WAAWA,KAAA,gBAAAA,EAAM;AAAA,oBAEhB,kCAAM,UAAS;AAAA,kBAAA;AAAA,kBANXV,EAAO;AAAA,gBAAA;AAAA,cAOd,CAEH;AAAA,YAAA;AAAA,YArBIO,EAAS;AAAA,UAAA;AAAA,QAwBnB,CAAA,GACH;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGN;AAEAnB,EAAe,cAAc;AAwFvB,MAAAyB,IAAQ,OAAO,OAAOzB,GAAgB;AAAA;AAAA,EAE1C,QAAQ0B;AAAA;AAAA,EAER,QAAQC;AAAA;AAAA,EAER,MAAMC;AAAA;AAAA,EAEN,KAAKC;AAAA;AAAA,EAEL,MAAMC;AACR,CAAC;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../../../../node_modules/react/jsx-runtime.cjs.js"),n=require("../../../../utils/string.cjs.js"),l=({columnIndex:t,children:o,columnSpan:r,dataTestId:a,textAlign:e})=>s.jsxRuntimeExports.jsx("td",{className:n.csx("proton-Table__cell",e&&`proton-Table__cell--${e}`),role:"cell","aria-colindex":t,colSpan:r,"data-testid":a,children:o});l.displayName="ProtonUITableCell";exports.TableCell=l;
|
|
2
2
|
//# sourceMappingURL=TableCell.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableCell.cjs.js","sources":["../../../../../src/components/Table/BaseTable/elements/TableCell.tsx"],"sourcesContent":["import { ReactNode } from \"react\";\n\nexport interface TableCellProps {\n /** 1-based column index for aria-colindex */\n columnIndex: number;\n /** Cell content */\n children: ReactNode;\n /** Number of columns this cell spans */\n columnSpan?: number;\n /** Test ID for testing purposes */\n dataTestId?: string;\n}\n\n/**\n * Table cell element (`<td>`) with styling and ARIA attributes.\n *\n * @see {@link TableCellProps}\n */\nexport const TableCell = ({\n columnIndex,\n children,\n columnSpan,\n dataTestId,\n}: TableCellProps) => {\n return (\n <td\n className
|
|
1
|
+
{"version":3,"file":"TableCell.cjs.js","sources":["../../../../../src/components/Table/BaseTable/elements/TableCell.tsx"],"sourcesContent":["import { ReactNode } from \"react\";\nimport { csx } from \"../../../../utils\";\n\nexport interface TableCellProps {\n /** 1-based column index for aria-colindex */\n columnIndex: number;\n /** Cell content */\n children: ReactNode;\n /** Number of columns this cell spans */\n columnSpan?: number;\n /** Test ID for testing purposes */\n dataTestId?: string;\n /** Text alignment */\n textAlign?: \"left\" | \"center\" | \"right\";\n}\n\n/**\n * Table cell element (`<td>`) with styling and ARIA attributes.\n *\n * @see {@link TableCellProps}\n */\nexport const TableCell = ({\n columnIndex,\n children,\n columnSpan,\n dataTestId,\n textAlign,\n}: TableCellProps) => {\n return (\n <td\n className={csx(\n \"proton-Table__cell\",\n textAlign && `proton-Table__cell--${textAlign}`,\n )}\n role=\"cell\"\n aria-colindex={columnIndex}\n colSpan={columnSpan}\n data-testid={dataTestId}\n >\n {children}\n </td>\n );\n};\n\nTableCell.displayName = \"ProtonUITableCell\";\n"],"names":["TableCell","columnIndex","children","columnSpan","dataTestId","textAlign","jsx","csx"],"mappings":"kMAqBaA,EAAY,CAAC,CACxB,YAAAC,EACA,SAAAC,EACA,WAAAC,EACA,WAAAC,EACA,UAAAC,CACF,IAEIC,EAAA,kBAAA,IAAC,KAAA,CACC,UAAWC,EAAA,IACT,qBACAF,GAAa,uBAAuBA,CAAS,EAC/C,EACA,KAAK,OACL,gBAAeJ,EACf,QAASE,EACT,cAAaC,EAEZ,SAAAF,CAAA,CAAA,EAKPF,EAAU,YAAc"}
|
|
@@ -1,22 +1,27 @@
|
|
|
1
1
|
import { j as t } from "../../../../node_modules/react/jsx-runtime.es.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import { csx as s } from "../../../../utils/string.es.js";
|
|
3
|
+
const c = ({
|
|
4
|
+
columnIndex: e,
|
|
5
|
+
children: o,
|
|
5
6
|
columnSpan: a,
|
|
6
|
-
dataTestId:
|
|
7
|
+
dataTestId: r,
|
|
8
|
+
textAlign: l
|
|
7
9
|
}) => /* @__PURE__ */ t.jsx(
|
|
8
10
|
"td",
|
|
9
11
|
{
|
|
10
|
-
className:
|
|
12
|
+
className: s(
|
|
13
|
+
"proton-Table__cell",
|
|
14
|
+
l && `proton-Table__cell--${l}`
|
|
15
|
+
),
|
|
11
16
|
role: "cell",
|
|
12
|
-
"aria-colindex":
|
|
17
|
+
"aria-colindex": e,
|
|
13
18
|
colSpan: a,
|
|
14
|
-
"data-testid":
|
|
15
|
-
children:
|
|
19
|
+
"data-testid": r,
|
|
20
|
+
children: o
|
|
16
21
|
}
|
|
17
22
|
);
|
|
18
|
-
|
|
23
|
+
c.displayName = "ProtonUITableCell";
|
|
19
24
|
export {
|
|
20
|
-
|
|
25
|
+
c as TableCell
|
|
21
26
|
};
|
|
22
27
|
//# sourceMappingURL=TableCell.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableCell.es.js","sources":["../../../../../src/components/Table/BaseTable/elements/TableCell.tsx"],"sourcesContent":["import { ReactNode } from \"react\";\n\nexport interface TableCellProps {\n /** 1-based column index for aria-colindex */\n columnIndex: number;\n /** Cell content */\n children: ReactNode;\n /** Number of columns this cell spans */\n columnSpan?: number;\n /** Test ID for testing purposes */\n dataTestId?: string;\n}\n\n/**\n * Table cell element (`<td>`) with styling and ARIA attributes.\n *\n * @see {@link TableCellProps}\n */\nexport const TableCell = ({\n columnIndex,\n children,\n columnSpan,\n dataTestId,\n}: TableCellProps) => {\n return (\n <td\n className
|
|
1
|
+
{"version":3,"file":"TableCell.es.js","sources":["../../../../../src/components/Table/BaseTable/elements/TableCell.tsx"],"sourcesContent":["import { ReactNode } from \"react\";\nimport { csx } from \"../../../../utils\";\n\nexport interface TableCellProps {\n /** 1-based column index for aria-colindex */\n columnIndex: number;\n /** Cell content */\n children: ReactNode;\n /** Number of columns this cell spans */\n columnSpan?: number;\n /** Test ID for testing purposes */\n dataTestId?: string;\n /** Text alignment */\n textAlign?: \"left\" | \"center\" | \"right\";\n}\n\n/**\n * Table cell element (`<td>`) with styling and ARIA attributes.\n *\n * @see {@link TableCellProps}\n */\nexport const TableCell = ({\n columnIndex,\n children,\n columnSpan,\n dataTestId,\n textAlign,\n}: TableCellProps) => {\n return (\n <td\n className={csx(\n \"proton-Table__cell\",\n textAlign && `proton-Table__cell--${textAlign}`,\n )}\n role=\"cell\"\n aria-colindex={columnIndex}\n colSpan={columnSpan}\n data-testid={dataTestId}\n >\n {children}\n </td>\n );\n};\n\nTableCell.displayName = \"ProtonUITableCell\";\n"],"names":["TableCell","columnIndex","children","columnSpan","dataTestId","textAlign","jsx","csx"],"mappings":";;AAqBO,MAAMA,IAAY,CAAC;AAAA,EACxB,aAAAC;AAAA,EACA,UAAAC;AAAA,EACA,YAAAC;AAAA,EACA,YAAAC;AAAA,EACA,WAAAC;AACF,MAEIC,gBAAAA,EAAA;AAAA,EAAC;AAAA,EAAA;AAAA,IACC,WAAWC;AAAA,MACT;AAAA,MACAF,KAAa,uBAAuBA,CAAS;AAAA,IAC/C;AAAA,IACA,MAAK;AAAA,IACL,iBAAeJ;AAAA,IACf,SAASE;AAAA,IACT,eAAaC;AAAA,IAEZ,UAAAF;AAAA,EAAA;AAAA;AAKPF,EAAU,cAAc;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1842,7 +1842,7 @@ declare interface TableBodyProps_2 {
|
|
|
1842
1842
|
* @see {@link TableCellProps}
|
|
1843
1843
|
*/
|
|
1844
1844
|
export declare const TableCell: {
|
|
1845
|
-
({ columnIndex, children, columnSpan, dataTestId, }: TableCellProps_2): JSX_2.Element;
|
|
1845
|
+
({ columnIndex, children, columnSpan, dataTestId, textAlign, }: TableCellProps_2): JSX_2.Element;
|
|
1846
1846
|
displayName: string;
|
|
1847
1847
|
};
|
|
1848
1848
|
|
|
@@ -1855,6 +1855,7 @@ declare interface TableCellProps {
|
|
|
1855
1855
|
children?: ReactNode;
|
|
1856
1856
|
colSpan?: number;
|
|
1857
1857
|
"data-testid"?: string;
|
|
1858
|
+
textAlign?: "left" | "center" | "right";
|
|
1858
1859
|
}
|
|
1859
1860
|
|
|
1860
1861
|
declare interface TableCellProps_2 {
|
|
@@ -1866,6 +1867,8 @@ declare interface TableCellProps_2 {
|
|
|
1866
1867
|
columnSpan?: number;
|
|
1867
1868
|
/** Test ID for testing purposes */
|
|
1868
1869
|
dataTestId?: string;
|
|
1870
|
+
/** Text alignment */
|
|
1871
|
+
textAlign?: "left" | "center" | "right";
|
|
1869
1872
|
}
|
|
1870
1873
|
|
|
1871
1874
|
declare const TableColumnCompound: (_: TableColumnProps) => any;
|