@zywave/zui-table 4.4.1-pre.1 → 4.4.1-pre.2

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.
@@ -41,10 +41,11 @@ export class ZuiTableRowElement extends ZuiTableBaseElement {
41
41
  }
42
42
  firstUpdated() {
43
43
  if (this.header) {
44
- const firstCellWithDirection = this._slottedCells?.find((cell) => cell?.hasAttribute('sort'));
44
+ const firstCellWithDirection = this._slottedCells?.find((cell) => cell?.hasAttribute('sort') || cell?.sort !== null);
45
45
  this._slottedCells.forEach((cell) => {
46
- if (cell.sort && cell !== firstCellWithDirection) {
46
+ if ((cell?.hasAttribute('sort') || cell.sort) && cell !== firstCellWithDirection) {
47
47
  cell.sort = null;
48
+ cell.removeAttribute('sort');
48
49
  }
49
50
  });
50
51
  }
@@ -1 +1 @@
1
- {"version":3,"file":"zui-table-row.js","sourceRoot":"","sources":["../src/zui-table-row.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC3B,OAAO,EAAE,QAAQ,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAG/C;;;;;;;;;;GAUG;AACH,MAAM,OAAO,kBAAmB,SAAQ,mBAAmB;IAA3D;;QACE;;WAEG;QAEH,WAAM,GAAG,KAAK,CAAC;QAEf;;WAEG;QAEH,YAAO,GAAG,KAAK,CAAC;IA+ElB,CAAC;IA1EC,SAAS,CAAW;IAEpB,MAAM,KAAK,MAAM;QACf,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC/B,CAAC;IAED,iBAAiB;QACf,KAAK,CAAC,iBAAiB,EAAE,CAAC;QAC1B,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IACnC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,CAAC;YACnB,CAAC;QACH,CAAC,CAAC,CAAC;QACH,UAAU,CAAC,GAAG,EAAE;YACd,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;QACzB,CAAC,EAAE,CAAC,CAAC,CAAC;IACR,CAAC;IAED,gBAAgB;QACd,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;YACxB,OAAO;QACT,CAAC;QAED,uDAAuD;QAEvD,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;gBAClC,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;gBACzC,IAAY,CAAC,cAAc,GAAG,IAAI,CAAC;YACtC,CAAC,CAAC,CAAC;QACL,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;gBAClC,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;gBACjC,IAAY,CAAC,cAAc,GAAG,KAAK,CAAC;YACvC,CAAC,CAAC,CAAC;QACL,CAAC;QAED,sDAAsD;IACxD,CAAC;CACF;AArFC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;kDAC5B;AAMf;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;mDAC3B;AAGR;IADP,qBAAqB,CAAC,EAAE,QAAQ,EAAE,gBAAgB,EAAE,CAAC;yDACJ;AA8EpD,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,CAAC","sourcesContent":["import { ZuiTableBaseElement } from './base.js';\nimport { html } from 'lit';\nimport { property, queryAssignedElements } from 'lit/decorators.js';\nimport { style } from './zui-table-row-css.js';\nimport type { ZuiTableCellElement } from './zui-table-cell.js';\n\n/**\n * Insert into `<zui-table>`; `<zui-table-row>` holds a row of `<zui-table-cell>` elements.\n *\n * @element zui-table-row\n *\n * @slot - Default, unnamed slot; for inserting `<zui-table-cell>` elements into `<zui-table-row>`\n *\n * @cssprop [--zui-table-columns-template=repeat(auto-fit, minmax(0, 1fr))] - Override the table columns template. See https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-columns for more information on valid values.\n * @cssprop [--zui-table-summary-background-color=var(--zui-gray-600)] - Override the table summary background color\n * @cssprop [--zui-table-summary-text-color=#fff] - Override the table summary text color\n */\nexport class ZuiTableRowElement extends ZuiTableBaseElement {\n /**\n * Declare a table header; typically the first row in `<zui-table>`\n */\n @property({ type: Boolean, reflect: true })\n header = false;\n\n /**\n * Declare a table summary row; typically the last row in `<zui-table>` before `<zui-table-footer>`\n */\n @property({ type: Boolean, reflect: true })\n summary = false;\n\n @queryAssignedElements({ selector: 'zui-table-cell' })\n private _slottedCells: Array<ZuiTableCellElement>;\n\n #sortLock?: boolean;\n\n static get styles() {\n return [super.styles, style];\n }\n\n connectedCallback() {\n super.connectedCallback();\n this.setAttribute('role', 'row');\n }\n\n firstUpdated() {\n if (this.header) {\n const firstCellWithDirection = this._slottedCells?.find((cell) => cell?.hasAttribute('sort'));\n this._slottedCells.forEach((cell) => {\n if (cell.sort && cell !== firstCellWithDirection) {\n cell.sort = null;\n }\n });\n }\n }\n\n updated(changedProperties: Map<string | number | symbol, unknown>) {\n super.updated(changedProperties);\n if (changedProperties.has('header')) {\n this.#ensureCellState();\n if (this.header) {\n this._state?.channel.addEventListener('sort', (e: CustomEvent<{ cell: HTMLElement }>) => this.#onTableSort(e));\n }\n }\n }\n\n render() {\n return html`<div>\n <slot @slotchange=\"${this.#ensureCellState()}\"></slot>\n </div>`;\n }\n\n #onTableSort(event: CustomEvent<{ cell: HTMLElement }>) {\n if (this.#sortLock) {\n return;\n }\n this.#sortLock = true;\n this._slottedCells?.forEach((cell) => {\n if (cell !== event.detail.cell) {\n cell.sort = null;\n }\n });\n setTimeout(() => {\n this.#sortLock = false;\n }, 0);\n }\n\n #ensureCellState() {\n if (!this._slottedCells) {\n return;\n }\n\n /* eslint-disable @typescript-eslint/no-explicit-any */\n\n if (this.header) {\n this._slottedCells.forEach((cell) => {\n cell.setAttribute('role', 'columnheader');\n (cell as any)._isAllowedSort = true;\n });\n } else {\n this._slottedCells.forEach((cell) => {\n cell.setAttribute('role', 'cell');\n (cell as any)._isAllowedSort = false;\n });\n }\n\n /* eslint-enable @typescript-eslint/no-explicit-any */\n }\n}\n\nwindow.customElements.define('zui-table-row', ZuiTableRowElement);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'zui-table-row': ZuiTableRowElement;\n }\n}\n"]}
1
+ {"version":3,"file":"zui-table-row.js","sourceRoot":"","sources":["../src/zui-table-row.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC3B,OAAO,EAAE,QAAQ,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAG/C;;;;;;;;;;GAUG;AACH,MAAM,OAAO,kBAAmB,SAAQ,mBAAmB;IAA3D;;QACE;;WAEG;QAEH,WAAM,GAAG,KAAK,CAAC;QAEf;;WAEG;QAEH,YAAO,GAAG,KAAK,CAAC;IAkFlB,CAAC;IA7EC,SAAS,CAAW;IAEpB,MAAM,KAAK,MAAM;QACf,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC/B,CAAC;IAED,iBAAiB;QACf,KAAK,CAAC,iBAAiB,EAAE,CAAC;QAC1B,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IACnC,CAAC;IAED,YAAY;QACV,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,MAAM,sBAAsB,GAAG,I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AI,EAAE,CAAC;gBAC/B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;YACnB,CAAC;QACH,CAAC,CAAC,CAAC;QACH,UAAU,CAAC,GAAG,EAAE;YACd,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;QACzB,CAAC,EAAE,CAAC,CAAC,CAAC;IACR,CAAC;IAED,gBAAgB;QACd,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;YACxB,OAAO;QACT,CAAC;QAED,uDAAuD;QAEvD,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;gBAClC,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;gBACzC,IAAY,CAAC,cAAc,GAAG,IAAI,CAAC;YACtC,CAAC,CAAC,CAAC;QACL,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;gBAClC,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;gBACjC,IAAY,CAAC,cAAc,GAAG,KAAK,CAAC;YACvC,CAAC,CAAC,CAAC;QACL,CAAC;QAED,sDAAsD;IACxD,CAAC;CACF;AAxFC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;kDAC5B;AAMf;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;mDAC3B;AAGR;IADP,qBAAqB,CAAC,EAAE,QAAQ,EAAE,gBAAgB,EAAE,CAAC;yDACJ;AAiFpD,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,CAAC","sourcesContent":["import { ZuiTableBaseElement } from './base.js';\nimport { html } from 'lit';\nimport { property, queryAssignedElements } from 'lit/decorators.js';\nimport { style } from './zui-table-row-css.js';\nimport type { ZuiTableCellElement } from './zui-table-cell.js';\n\n/**\n * Insert into `<zui-table>`; `<zui-table-row>` holds a row of `<zui-table-cell>` elements.\n *\n * @element zui-table-row\n *\n * @slot - Default, unnamed slot; for inserting `<zui-table-cell>` elements into `<zui-table-row>`\n *\n * @cssprop [--zui-table-columns-template=repeat(auto-fit, minmax(0, 1fr))] - Override the table columns template. See https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-columns for more information on valid values.\n * @cssprop [--zui-table-summary-background-color=var(--zui-gray-600)] - Override the table summary background color\n * @cssprop [--zui-table-summary-text-color=#fff] - Override the table summary text color\n */\nexport class ZuiTableRowElement extends ZuiTableBaseElement {\n /**\n * Declare a table header; typically the first row in `<zui-table>`\n */\n @property({ type: Boolean, reflect: true })\n header = false;\n\n /**\n * Declare a table summary row; typically the last row in `<zui-table>` before `<zui-table-footer>`\n */\n @property({ type: Boolean, reflect: true })\n summary = false;\n\n @queryAssignedElements({ selector: 'zui-table-cell' })\n private _slottedCells: Array<ZuiTableCellElement>;\n\n #sortLock?: boolean;\n\n static get styles() {\n return [super.styles, style];\n }\n\n connectedCallback() {\n super.connectedCallback();\n this.setAttribute('role', 'row');\n }\n\n firstUpdated() {\n if (this.header) {\n const firstCellWithDirection = this._slottedCells?.find(\n (cell) => cell?.hasAttribute('sort') || cell?.sort !== null\n );\n this._slottedCells.forEach((cell) => {\n if ((cell?.hasAttribute('sort') || cell.sort) && cell !== firstCellWithDirection) {\n cell.sort = null;\n cell.removeAttribute('sort');\n }\n });\n }\n }\n\n updated(changedProperties: Map<string | number | symbol, unknown>) {\n super.updated(changedProperties);\n if (changedProperties.has('header')) {\n this.#ensureCellState();\n if (this.header) {\n this._state?.channel.addEventListener('sort', (e: CustomEvent<{ cell: HTMLElement }>) => this.#onTableSort(e));\n }\n }\n }\n\n render() {\n return html`<div>\n <slot @slotchange=\"${this.#ensureCellState()}\"></slot>\n </div>`;\n }\n\n #onTableSort(event: CustomEvent<{ cell: HTMLElement }>) {\n if (this.#sortLock) {\n return;\n }\n this.#sortLock = true;\n this._slottedCells?.forEach((cell) => {\n if (cell !== event.detail.cell) {\n cell.sort = null;\n }\n });\n setTimeout(() => {\n this.#sortLock = false;\n }, 0);\n }\n\n #ensureCellState() {\n if (!this._slottedCells) {\n return;\n }\n\n /* eslint-disable @typescript-eslint/no-explicit-any */\n\n if (this.header) {\n this._slottedCells.forEach((cell) => {\n cell.setAttribute('role', 'columnheader');\n (cell as any)._isAllowedSort = true;\n });\n } else {\n this._slottedCells.forEach((cell) => {\n cell.setAttribute('role', 'cell');\n (cell as any)._isAllowedSort = false;\n });\n }\n\n /* eslint-enable @typescript-eslint/no-explicit-any */\n }\n}\n\nwindow.customElements.define('zui-table-row', ZuiTableRowElement);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'zui-table-row': ZuiTableRowElement;\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zywave/zui-table",
3
- "version": "4.4.1-pre.1",
3
+ "version": "4.4.1-pre.2",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "license": "UNLICENSED",
@@ -29,5 +29,5 @@
29
29
  "devDependencies": {
30
30
  "@zywave/zui-button": "^4.1.10-pre.0"
31
31
  },
32
- "gitHead": "1f5ba52914630b9b136b0241794a10bd6d473b0c"
32
+ "gitHead": "cdf7b9622b4f662734912310f3582350ab1afd75"
33
33
  }
@@ -44,10 +44,13 @@ export class ZuiTableRowElement extends ZuiTableBaseElement {
44
44
 
45
45
  firstUpdated() {
46
46
  if (this.header) {
47
- const firstCellWithDirection = this._slottedCells?.find((cell) => cell?.hasAttribute('sort'));
47
+ const firstCellWithDirection = this._slottedCells?.find(
48
+ (cell) => cell?.hasAttribute('sort') || cell?.sort !== null
49
+ );
48
50
  this._slottedCells.forEach((cell) => {
49
- if (cell.sort && cell !== firstCellWithDirection) {
51
+ if ((cell?.hasAttribute('sort') || cell.sort) && cell !== firstCellWithDirection) {
50
52
  cell.sort = null;
53
+ cell.removeAttribute('sort');
51
54
  }
52
55
  });
53
56
  }