Skip to content

Commit

Permalink
Merge branch '6874-fix-combobox-empty-list' of https://github.com/pub…
Browse files Browse the repository at this point in the history
…lic-ui/kolibri into 6874-fix-combobox-empty-list
  • Loading branch information
anicyne committed Oct 9, 2024
2 parents 0efa25a + 4d11335 commit 6aa4bc5
Show file tree
Hide file tree
Showing 30 changed files with 72 additions and 48 deletions.
2 changes: 1 addition & 1 deletion packages/adapters/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"@types/minimatch": "5.1.2",
"@types/minimist": "1.2.5",
"@types/normalize-package-data": "2.4.4",
"@types/react": "18.3.9",
"@types/react": "18.3.4",
"@types/react-dom": "18.3.0",
"react": "18.2.0",
"react-dom": "18.2.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@
}
}

tr.foot-spacer,
tr.head-spacer {
display: none;
}

.selection-header-cell {
width: 0;
}
Expand Down
94 changes: 51 additions & 43 deletions packages/components/src/components/table-stateless/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -657,19 +657,24 @@ export class KolTableStateless implements TableStatelessAPI {
</th>
);
}
/**
* Renders the table footer (`<tfoot>`) using the provided footer data.
* It maps over each row in the footer and renders it similarly to a body row.
*
* @returns {JSX.Element} - The rendered table footer or an empty string if no footer data is provided.
*/
private renderFoot(): JSX.Element {

private renderSpacer(variant: 'foot' | 'head', cellDefs: KoliBriTableHeaderCell[][] | KoliBriTableCell[][]): JSX.Element {
const colspan = cellDefs?.[0].reduce((acc, row) => acc + (row.colSpan || 1), 0);

return (
<tr class={`${variant}-spacer`} aria-hidden="true">
<td colSpan={colspan}></td>
</tr>
);
}

private renderFoot(): JSX.Element[] | null {
if (!this.state._dataFoot || this.state._dataFoot.length === 0) {
return '';
return null;
}

const rows: KoliBriTableCell[][] = this.createDataField(this.state._dataFoot, this.state._headerCells, true);
return <tfoot>{rows.map(this.renderTableRow)}</tfoot>;
return <tfoot>{[this.renderSpacer('foot', rows), rows.map(this.renderTableRow)]}</tfoot>;
}

public render(): JSX.Element {
Expand Down Expand Up @@ -702,40 +707,43 @@ export class KolTableStateless implements TableStatelessAPI {

{Array.isArray(this.state._headerCells.horizontal) && (
<thead>
{this.state._headerCells.horizontal.map((cols, rowIndex) => (
<tr key={`thead-${rowIndex}`}>
{this.state._selection && this.renderHeadingSelectionCell()}
{cols.map((cell, colIndex) => {
if (cell.asTd === true) {
return (
<td
key={`thead-${rowIndex}-${colIndex}-${cell.label}`}
class={{
[cell.textAlign as string]: typeof cell.textAlign === 'string' && cell.textAlign.length > 0,
}}
colSpan={cell.colSpan}
rowSpan={cell.rowSpan}
style={{
textAlign: cell.textAlign,
width: cell.width,
}}
ref={
typeof cell.render === 'function'
? (el) => {
this.cellRender(cell, el);
}
: undefined
}
>
{typeof cell.render !== 'function' ? cell.label : ''}
</td>
);
} else {
return this.renderHeadingCell(cell, rowIndex, colIndex);
}
})}
</tr>
))}
{[
this.state._headerCells.horizontal.map((cols, rowIndex) => (
<tr key={`thead-${rowIndex}`}>
{this.state._selection && this.renderHeadingSelectionCell()}
{cols.map((cell, colIndex) => {
if (cell.asTd === true) {
return (
<td
key={`thead-${rowIndex}-${colIndex}-${cell.label}`}
class={{
[cell.textAlign as string]: typeof cell.textAlign === 'string' && cell.textAlign.length > 0,
}}
colSpan={cell.colSpan}
rowSpan={cell.rowSpan}
style={{
textAlign: cell.textAlign,
width: cell.width,
}}
ref={
typeof cell.render === 'function'
? (el) => {
this.cellRender(cell, el);
}
: undefined
}
>
{typeof cell.render !== 'function' ? cell.label : ''}
</td>
);
} else {
return this.renderHeadingCell(cell, rowIndex, colIndex);
}
})}
</tr>
)),
this.renderSpacer('head', this.state._headerCells.horizontal),
]}
</thead>
)}
<tbody>{dataField.map(this.renderTableRow)}</tbody>
Expand Down
2 changes: 1 addition & 1 deletion packages/samples/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@public-ui/react": "workspace:*",
"@public-ui/themes": "workspace:*",
"@types/node": "ts5.6",
"@types/react": "18.3.9",
"@types/react": "18.3.4",
"@types/react-dom": "18.3.0",
"@unocss/preset-uno": "0.58.9",
"@unocss/webpack": "0.58.9",
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 14 additions & 3 deletions packages/themes/default/src/mixins/kol-table-stateless-wc.scss
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
}

table,
table thead tr:last-child th,
table thead tr:last-child td {
table thead tr:nth-last-child(2) th,
table thead tr:nth-last-child(2) td {
border-width: 0;
border-bottom-width: calc(var(--border-width) * 2);
border-style: solid;
Expand All @@ -75,7 +75,7 @@
align-items: center;
}

tr:nth-child(even) {
table tbody tr:nth-child(even) {
background-color: var(--color-mute);
}

Expand All @@ -89,6 +89,17 @@
font-weight: 700;
}

tr.foot-spacer,
tr.head-spacer {
display: inherit;
height: rem(24);

td {
border: none;
padding: 0;
}
}

.input {
input {
&:hover {
Expand Down

0 comments on commit 6aa4bc5

Please sign in to comment.