@operato/data-grist 10.29.69 → 10.29.70

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.
Files changed (38) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/src/data-card/data-card-gutter.js +3 -15
  3. package/dist/src/data-card/data-card-gutter.js.map +1 -1
  4. package/dist/src/data-grid/data-grid-accum-field.js +2 -0
  5. package/dist/src/data-grid/data-grid-accum-field.js.map +1 -1
  6. package/dist/src/data-grid/data-grid-body-style.js +2 -0
  7. package/dist/src/data-grid/data-grid-body-style.js.map +1 -1
  8. package/dist/src/data-grid/data-grid-field.js +5 -12
  9. package/dist/src/data-grid/data-grid-field.js.map +1 -1
  10. package/dist/src/data-grid/data-grid-header.js +7 -1
  11. package/dist/src/data-grid/data-grid-header.js.map +1 -1
  12. package/dist/src/data-grid/data-grid.d.ts +1 -1
  13. package/dist/src/data-grid/data-grid.js +44 -18
  14. package/dist/src/data-grid/data-grid.js.map +1 -1
  15. package/dist/src/data-list/data-list-gutter.js +3 -0
  16. package/dist/src/data-list/data-list-gutter.js.map +1 -1
  17. package/dist/src/data-report/data-report-header.js +10 -11
  18. package/dist/src/data-report/data-report-header.js.map +1 -1
  19. package/dist/src/editors/ox-grist-editor-select.js +8 -1
  20. package/dist/src/editors/ox-grist-editor-select.js.map +1 -1
  21. package/dist/test/destructive-actions.test.d.ts +11 -0
  22. package/dist/test/destructive-actions.test.js +147 -0
  23. package/dist/test/destructive-actions.test.js.map +1 -0
  24. package/dist/test/flexible-columns.test.d.ts +1 -0
  25. package/dist/test/flexible-columns.test.js +134 -0
  26. package/dist/test/flexible-columns.test.js.map +1 -0
  27. package/dist/test/select-empty-value.test.d.ts +1 -0
  28. package/dist/test/select-empty-value.test.js +61 -0
  29. package/dist/test/select-empty-value.test.js.map +1 -0
  30. package/dist/test/wheel-one-scroller.test.d.ts +2 -0
  31. package/dist/test/wheel-one-scroller.test.js +275 -0
  32. package/dist/test/wheel-one-scroller.test.js.map +1 -0
  33. package/dist/tsconfig.tsbuildinfo +1 -1
  34. package/package.json +7 -7
  35. package/test/destructive-actions.test.ts +137 -0
  36. package/test/flexible-columns.test.ts +181 -0
  37. package/test/select-empty-value.test.ts +71 -0
  38. package/test/wheel-one-scroller.test.ts +359 -0
@@ -1 +1 @@
1
- {"version":3,"file":"data-report-header.js","sourceRoot":"","sources":["../../../src/data-report/data-report-header.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAkB,MAAM,KAAK,CAAA;AAC3D,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,QAAQ,MAAM,uBAAuB,CAAA;AAE5C,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAA;AAEpE,sDAAsD;AAGtD,IAAM,gBAAgB,GAAtB,MAAM,gBAAiB,SAAQ,UAAU;IAAzC;;QA2D8B,WAAM,GAAgB,WAAW,CAAA;QAClC,YAAO,GAAmB,EAAE,CAAA;QAC3B,SAAI,GAAc,SAAS,CAAA;IA2KzD,CAAC;IAtKC,YAAY,CAAC,CAAa;QACxB,IAAI,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;YACxC,IAAI,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC,CAAA;YACpD,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,UAAU,GAAG,KAAK,GAAG,EAAE,CAAC,CAAA;YAE3D,IAAI,aAAa,GAAG,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAA;YAEvD,IAAI,OAAO,GAAG,IAAI,CAAC,UAAU,KAAK,CAAC,CAAA;YACnC,IAAI,KAAK,GA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AAC,MAAM,EAAE,WAAW,CAAC,CAAA;QAC5C,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,cAAc,CAAC,CAAA;IACpD,CAAC;;AAtOM,uBAAM,GAAG;IACd,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAsDF;CACF,AAxDY,CAwDZ;AAE2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gDAAkC;AAClC;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;iDAA6B;AAC3B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8CAA4B;AACpB;IAAlC,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;kDAAiC;AA9DvD,gBAAgB;IADrB,aAAa,CAAC,kBAAkB,CAAC;GAC5B,gBAAgB,CAwOrB","sourcesContent":["import { css, html, LitElement, PropertyValues } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\nimport throttle from 'lodash-es/throttle.js'\n\nimport { ZERO_CONFIG, ZERO_DATA } from '../configure/zero-config.js'\nimport { ColumnConfig, GristConfig, GristData, SortersConfig } from '../types.js'\n// import { supportsPassive } from '../utils/index.js'\n\n@customElement('ox-report-header')\nclass DataReportHeader extends LitElement {\n static styles = [\n css`\n :host {\n display: grid;\n grid-template-columns: var(--report-template-columns);\n\n overflow: hidden;\n }\n\n div {\n display: flex;\n\n white-space: nowrap;\n overflow: hidden;\n background-color: var(--report-header-background-color, gray);\n border: 1px solid var(--report-header-border-color);\n border-width: 1px 1px 1px 0;\n padding: var(--report-header-padding);\n\n text-overflow: ellipsis;\n text-align: center;\n font-size: var(--report-header-fontsize, 1em);\n color: var(--report-header-color);\n }\n\n span {\n white-space: nowrap;\n overflow: hidden;\n\n text-align: center;\n }\n\n span[titler] {\n flex: 1;\n text-overflow: ellipsis;\n font: var(--report-header-font);\n color: var(--report-header-color);\n text-transform: capitalize;\n }\n\n span[sorter] {\n padding: 0;\n border: 0;\n font-size: 10px;\n }\n\n span[splitter] {\n cursor: col-resize;\n }\n\n @media print {\n :host {\n grid-template-columns: var(--report-template-print-columns);\n }\n }\n `\n ]\n\n @property({ type: Object }) config: GristConfig = ZERO_CONFIG\n @property({ type: Array }) columns: ColumnConfig[] = []\n @property({ type: Object }) data: GristData = ZERO_DATA\n @property({ type: Array }) private _sorters?: SortersConfig\n\n private throttledNotifier?: (idx: number, width: number) => void\n\n onWheelEvent(e: WheelEvent) {\n if (this.scrollWidth > this.clientWidth) {\n var delta = Math.max(-1, Math.min(1, e.deltaY || 0))\n this.scrollLeft = Math.max(0, this.scrollLeft - delta * 40)\n\n var maxScrollLeft = this.scrollWidth - this.clientWidth\n\n var atStart = this.scrollLeft === 0\n var atEnd = this.scrollLeft === maxScrollLeft\n\n // 스크롤이 맨 앞으로 와 있는 상태에서 휠을 올리는 경우 또는\n // 스크롤이 맨 끝으로 가 있는 상태에서 휠을 내리는 경우에만 디폴트 동작 허용\n if ((atStart && delta > 0) || (atEnd && delta < 0)) {\n return true\n }\n\n e.preventDefault()\n }\n }\n\n firstUpdated() {\n this.addEventListener('wheel', this.onWheelEvent.bind(this))\n }\n\n async updated(changed: PropertyValues<this>) {\n if (changed.has('config')) {\n this._sorters = this.config.sorters || []\n }\n }\n\n render() {\n var columns = this.columns || []\n\n return html`\n ${columns.map((column, idx) =>\n !column.hidden\n ? html`\n <div @dragstart=${(e: MouseEvent) => this._dragStart(e, idx)}>\n <span titler @click=${(e: Event) => this._changeSort(column)}>${this._renderHeader(column)} </span>\n\n ${column.sortable\n ? html`\n <span sorter @click=${(e: Event) => this._changeSort(column)}>\n ${this._renderSortHeader(column)}\n </span>\n `\n : html``}\n ${column.resizable !== false ? html` <span splitter draggable=\"true\">&nbsp;</span> ` : html``}\n </div>\n `\n : html``\n )}\n\n <div></div>\n `\n }\n\n _renderHeader(column: ColumnConfig) {\n var { renderer } = column.header || {}\n var title = renderer.call(this, column)\n\n return html` ${title} `\n }\n\n _renderSortHeader(column: ColumnConfig) {\n if (column.hidden) {\n return html``\n }\n\n var sorters = this._sorters || []\n\n var sorter = sorters.find(sorter => column.type !== 'gutter' && column.name == sorter.name)\n if (!sorter) {\n return html``\n }\n\n if (sorters.length > 1) {\n var rank = sorters.indexOf(sorter) + 1\n return sorter.desc ? html` &#9660;<sub>${rank}</sub> ` : html` &#9650;<sub>${rank}</sub> `\n } else {\n return sorter.desc ? html` &#9660; ` : html` &#9650; `\n }\n }\n\n _changeSort(column: ColumnConfig) {\n if (!column.sortable) {\n return\n }\n\n var sorters = [...(this._sorters || [])]\n\n var idx = sorters.findIndex(sorter => sorter.name == column.name)\n if (idx !== -1) {\n let sorter = sorters[idx]\n if (sorter.desc) {\n sorters.splice(idx, 1)\n } else {\n sorter.desc = true\n }\n } else {\n var sorter = {\n name: column.name\n }\n\n sorters.push(sorter)\n }\n\n this._sorters = sorters\n\n this.dispatchEvent(\n new CustomEvent('fetch-params-change', {\n bubbles: true,\n composed: true,\n detail: {\n sorters: this._sorters,\n from: 'data-report-header'\n }\n })\n )\n }\n\n _notifyWidthChange(idx: number, width: number) {\n if (!this.throttledNotifier) {\n this.throttledNotifier = throttle((idx, width) => {\n this.dispatchEvent(\n new CustomEvent('column-width-change', {\n bubbles: true,\n composed: true,\n detail: {\n idx,\n width\n }\n })\n )\n }, 100)\n }\n\n this.throttledNotifier(idx, width)\n }\n\n _dragStart(e: MouseEvent, idx: number) {\n var target = e.currentTarget as HTMLElement\n var startX = e.offsetX\n\n var dragHandler = ((e: MouseEvent) => {\n let column = this.columns[idx]\n\n let width = Math.max(0, Number(column.width) + e.offsetX - startX)\n if (width == 0) {\n /* CLARIFY-ME 왜 마지막 이벤트의 offsetX로 음수 값이 오는가 */\n return\n }\n\n this._notifyWidthChange(idx, width)\n }).bind(this)\n\n var dragEndHandler = ((e: MouseEvent) => {\n target.removeEventListener('drag', dragHandler)\n target.removeEventListener('dragend', dragEndHandler)\n\n dragHandler(e)\n }).bind(this)\n\n target.addEventListener('drag', dragHandler)\n target.addEventListener('dragend', dragEndHandler)\n }\n}\n"]}
1
+ {"version":3,"file":"data-report-header.js","sourceRoot":"","sources":["../../../src/data-report/data-report-header.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAkB,MAAM,KAAK,CAAA;AAC3D,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,QAAQ,MAAM,uBAAuB,CAAA;AAE5C,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAA;AAEpE,sDAAsD;AAGtD,IAAM,gBAAgB,GAAtB,MAAM,gBAAiB,SAAQ,UAAU;IAAzC;;QA2D8B,WAAM,GAAgB,WAAW,CAAA;QAClC,YAAO,GAAmB,EAAE,CAAA;QAC3B,SAAI,GAAc,SAAS,CAAA;IAuKzD,CAAC;IAlKC;;;;;;OAMG;IACH,YAAY,CAAC,CAAa;QACxB,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAA;QAC5B,IAAI,CAAC,UAAU,GAAG,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,EAAE,CAAA;QAEjD,IAAI,IAAI,CAAC,UAAU,KAAK,IAAI,EAAE,CAAC;YAC7B,CAAC,CAAC,cAAc,EAAE,CAAA;QACpB,CAAC;IACH,CAAC;IAED,YAAY;QACV,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;IAC9D,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,OAA6B;QACzC,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC1B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,IAAI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AAC;GAC5B,gBAAgB,CAoOrB","sourcesContent":["import { css, html, LitElement, PropertyValues } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\nimport throttle from 'lodash-es/throttle.js'\n\nimport { ZERO_CONFIG, ZERO_DATA } from '../configure/zero-config.js'\nimport { ColumnConfig, GristConfig, GristData, SortersConfig } from '../types.js'\n// import { supportsPassive } from '../utils/index.js'\n\n@customElement('ox-report-header')\nclass DataReportHeader extends LitElement {\n static styles = [\n css`\n :host {\n display: grid;\n grid-template-columns: var(--report-template-columns);\n\n overflow: hidden;\n }\n\n div {\n display: flex;\n\n white-space: nowrap;\n overflow: hidden;\n background-color: var(--report-header-background-color, gray);\n border: 1px solid var(--report-header-border-color);\n border-width: 1px 1px 1px 0;\n padding: var(--report-header-padding);\n\n text-overflow: ellipsis;\n text-align: center;\n font-size: var(--report-header-fontsize, 1em);\n color: var(--report-header-color);\n }\n\n span {\n white-space: nowrap;\n overflow: hidden;\n\n text-align: center;\n }\n\n span[titler] {\n flex: 1;\n text-overflow: ellipsis;\n font: var(--report-header-font);\n color: var(--report-header-color);\n text-transform: capitalize;\n }\n\n span[sorter] {\n padding: 0;\n border: 0;\n font-size: 10px;\n }\n\n span[splitter] {\n cursor: col-resize;\n }\n\n @media print {\n :host {\n grid-template-columns: var(--report-template-print-columns);\n }\n }\n `\n ]\n\n @property({ type: Object }) config: GristConfig = ZERO_CONFIG\n @property({ type: Array }) columns: ColumnConfig[] = []\n @property({ type: Object }) data: GristData = ZERO_DATA\n @property({ type: Array }) private _sorters?: SortersConfig\n\n private throttledNotifier?: (idx: number, width: number) => void\n\n /*\n * 머리 위에서 굴린 세로 휠을 가로 스크롤로 바꾼다. 휠을 내리면 오른쪽, 올리면 왼쪽이다.\n *\n * 휠 하나는 통째로 맡거나 아예 손대지 않는다(ox-grid 의 onWheelEvent 와 같은 규칙). 열이 움직였으면\n * 기본 동작을 막고, 움직이지 않았으면(그 방향 끝에 이미 있었으면) 브라우저에 넘긴다. 끝은 옮겨 보고\n * 안다 — 옮긴 다음에 끝을 재면 끝에 닿는 그 휠이 열도 옮기고 바깥도 옮긴다.\n */\n onWheelEvent(e: WheelEvent) {\n const from = this.scrollLeft\n this.scrollLeft = from + Math.sign(e.deltaY) * 40\n\n if (this.scrollLeft !== from) {\n e.preventDefault()\n }\n }\n\n firstUpdated() {\n this.addEventListener('wheel', this.onWheelEvent.bind(this))\n }\n\n async updated(changed: PropertyValues<this>) {\n if (changed.has('config')) {\n this._sorters = this.config.sorters || []\n }\n }\n\n render() {\n var columns = this.columns || []\n\n return html`\n ${columns.map((column, idx) =>\n !column.hidden\n ? html`\n <div @dragstart=${(e: MouseEvent) => this._dragStart(e, idx)}>\n <span titler @click=${(e: Event) => this._changeSort(column)}>${this._renderHeader(column)} </span>\n\n ${column.sortable\n ? html`\n <span sorter @click=${(e: Event) => this._changeSort(column)}>\n ${this._renderSortHeader(column)}\n </span>\n `\n : html``}\n ${column.resizable !== false ? html` <span splitter draggable=\"true\">&nbsp;</span> ` : html``}\n </div>\n `\n : html``\n )}\n\n <div></div>\n `\n }\n\n _renderHeader(column: ColumnConfig) {\n var { renderer } = column.header || {}\n var title = renderer.call(this, column)\n\n return html` ${title} `\n }\n\n _renderSortHeader(column: ColumnConfig) {\n if (column.hidden) {\n return html``\n }\n\n var sorters = this._sorters || []\n\n var sorter = sorters.find(sorter => column.type !== 'gutter' && column.name == sorter.name)\n if (!sorter) {\n return html``\n }\n\n if (sorters.length > 1) {\n var rank = sorters.indexOf(sorter) + 1\n return sorter.desc ? html` &#9660;<sub>${rank}</sub> ` : html` &#9650;<sub>${rank}</sub> `\n } else {\n return sorter.desc ? html` &#9660; ` : html` &#9650; `\n }\n }\n\n _changeSort(column: ColumnConfig) {\n if (!column.sortable) {\n return\n }\n\n var sorters = [...(this._sorters || [])]\n\n var idx = sorters.findIndex(sorter => sorter.name == column.name)\n if (idx !== -1) {\n let sorter = sorters[idx]\n if (sorter.desc) {\n sorters.splice(idx, 1)\n } else {\n sorter.desc = true\n }\n } else {\n var sorter = {\n name: column.name\n }\n\n sorters.push(sorter)\n }\n\n this._sorters = sorters\n\n this.dispatchEvent(\n new CustomEvent('fetch-params-change', {\n bubbles: true,\n composed: true,\n detail: {\n sorters: this._sorters,\n from: 'data-report-header'\n }\n })\n )\n }\n\n _notifyWidthChange(idx: number, width: number) {\n if (!this.throttledNotifier) {\n this.throttledNotifier = throttle((idx, width) => {\n this.dispatchEvent(\n new CustomEvent('column-width-change', {\n bubbles: true,\n composed: true,\n detail: {\n idx,\n width\n }\n })\n )\n }, 100)\n }\n\n this.throttledNotifier(idx, width)\n }\n\n _dragStart(e: MouseEvent, idx: number) {\n var target = e.currentTarget as HTMLElement\n var startX = e.offsetX\n\n var dragHandler = ((e: MouseEvent) => {\n let column = this.columns[idx]\n\n let width = Math.max(0, Number(column.width) + e.offsetX - startX)\n if (width == 0) {\n /* CLARIFY-ME 왜 마지막 이벤트의 offsetX로 음수 값이 오는가 */\n return\n }\n\n this._notifyWidthChange(idx, width)\n }).bind(this)\n\n var dragEndHandler = ((e: MouseEvent) => {\n target.removeEventListener('drag', dragHandler)\n target.removeEventListener('dragend', dragEndHandler)\n\n dragHandler(e)\n }).bind(this)\n\n target.addEventListener('drag', dragHandler)\n target.addEventListener('dragend', dragEndHandler)\n }\n}\n"]}
@@ -23,10 +23,17 @@ function toOptionObjects(options) {
23
23
  }
24
24
  });
25
25
  }
26
+ /*
27
+ * A value that is none of the options (an empty new row) opens on a blank, hidden option. Without it the browser shows
28
+ * the first option as picked, and picking that option tells no change, so it could not be entered (2026-11-08).
29
+ */
26
30
  function buildOptions(options, value) {
31
+ const optionObjects = toOptionObjects(options);
32
+ const unmatched = !optionObjects.some(option => option.value == value);
27
33
  return html `
28
34
  <select>
29
- ${toOptionObjects(options).map((option) => html `
35
+ ${unmatched ? html `<option value="" selected hidden></option>` : ''}
36
+ ${optionObjects.map((option) => html `
30
37
  <option ?selected=${option.value == value} value=${option.value}>${option.display}</option>
31
38
  `)}
32
39
  </select>
@@ -1 +1 @@
1
- {"version":3,"file":"ox-grist-editor-select.js","sourceRoot":"","sources":["../../../src/editors/ox-grist-editor-select.ts"],"names":[],"mappings":";AAAA,OAAO,6BAA6B,CAAA;AACpC,OAAO,iCAAiC,CAAA;AAExC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAE/C,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAGpD,SAAS,eAAe,CAAC,OAAuB;IAC9C,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE;QAC1B,QAAQ,OAAO,MAAM,EAAE,CAAC;YACtB,KAAK,QAAQ;gBACX,OAAO;oBACL,OAAO,EAAE,MAAM;oBACf,KAAK,EAAE,MAAM;iBACd,CAAA;YACH,KAAK,QAAQ;gBACX,OAAO;oBACL,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,IAAI;oBACtC,KAAK,EAAE,MAAM,CAAC,KAAK;iBACpB,CAAA;YACH;gBACE,OAAO,MAAM,CAAA;QACjB,CAAC;IACH,CAAC,CAAyB,CAAA;AAC5B,CAAC;AAED,SAAS,YAAY,CAAC,OAAuB,EAAE,KAAU;IACvD,OAAO,IAAI,CAAA;;QAEL,eAAe,CAAC,OAAO,CAAC,CAAC,GAAG,CAC5B,CAAC,MAAW,EAAE,EAAE,CAAC,IAAI,CAAA;8BACC,MAAM,CAAC,KAAK,IAAI,KAAK,UAAU,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,OAAO;SAClF,CACF;;GAEJ,CAAA;AACH,CAAC;AAED;;;;GAIG;AAEI,IAAM,mBAAmB,GAAzB,MAAM,mBAAoB,SAAQ,aAAa;IAA/C;;QAcL,iIAAiI;QACzH,aAAQ,GAAyB,EAAE,CAAA;IA4D7C,CAA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AAA;;;;;;;;KAQF;CACF,AAXY,CAWZ;AAZU,mBAAmB;IAD/B,aAAa,CAAC,wBAAwB,CAAC;GAC3B,mBAAmB,CA2E/B","sourcesContent":["import '@operato/input/ox-select.js'\nimport '@operato/popup/ox-popup-list.js'\n\nimport { css, html } from 'lit'\nimport { customElement } from 'lit/decorators.js'\nimport { until } from 'lit/directives/until.js'\n\nimport { OxGristEditor } from './ox-grist-editor.js'\nimport { SelectOption, SelectOptionObject } from '../types.js'\n\nfunction toOptionObjects(options: SelectOption[]) {\n return options.map(option => {\n switch (typeof option) {\n case 'string':\n return {\n display: option,\n value: option\n }\n case 'object':\n return {\n display: option.display || option.name,\n value: option.value\n }\n default:\n return option\n }\n }) as SelectOptionObject[]\n}\n\nfunction buildOptions(options: SelectOption[], value: any) {\n return html`\n <select>\n ${toOptionObjects(options).map(\n (option: any) => html`\n <option ?selected=${option.value == value} value=${option.value}>${option.display}</option>\n `\n )}\n </select>\n `\n}\n\n/**\n * A select cell. With `record.searchable` it edits through the framework's popup list with a search box on top, as\n * select2 does: the list opens with the editor, typing narrows it, a click or Enter picks, and the pick is committed\n * at once. Without it, the browser's own `<select>`.\n */\n@customElement('ox-grist-editor-select')\nexport class OxGristEditorSelect extends OxGristEditor {\n static styles = [\n ...OxGristEditor.styles,\n css`\n :host([searchable]) {\n overflow: visible;\n }\n\n ox-select {\n width: 100%;\n }\n `\n ]\n\n /* The options as last drawn: a pick comes back as the text of its value attribute and is read back to the option's own value. */\n private _options: SelectOptionObject[] = []\n\n get searchable() {\n return !!this.column.record.searchable\n }\n\n connectedCallback() {\n super.connectedCallback()\n this.toggleAttribute('searchable', this.searchable)\n }\n\n get editorTemplate() {\n var rowOptionField = this.record[this.column.record.rowOptionField || '']\n var { options = [] } = rowOptionField ? rowOptionField : this.column.record\n\n if (typeof options == 'function') {\n options = options.call(null, this.value, this.column, this.record, this.rowIndex, this.field)\n }\n\n if (options instanceof Promise) {\n return html`${until(options.then(options => this.build((options || []) as SelectOption[])))}`\n }\n return this.build((options || []) as SelectOption[])\n }\n\n private build(options: SelectOption[]) {\n if (!this.searchable) {\n return buildOptions(options, this.value)\n }\n\n this._options = toOptionObjects(options)\n return html`<ox-select .value=${String(this.value ?? '')}>\n <ox-popup-list align-left nowrap with-search>\n ${this._options.map(option => html`<div option value=${option.value}>${option.display}</div>`)}\n </ox-popup-list>\n </ox-select>`\n }\n\n async firstUpdated() {\n await super.firstUpdated()\n\n /* Opening the cell opens the list, as a click on a select2 does. */\n if (this.searchable) {\n requestAnimationFrame(() => (this.editor as any)?.expand?.())\n }\n }\n\n /* The list tells a change each time it closes; what it holds then is committed, an unchanged value commits nothing. */\n _onchange(e: Event): void {\n if (!this.searchable) {\n return super._onchange(e)\n }\n\n e.stopPropagation()\n\n const picked = String((e.target as any)?.value ?? '')\n const option = this._options.find(option => String(option.value) === picked)\n this._dirtyValue = option ? option.value : picked\n this._onfocusout()\n }\n}\n"]}
1
+ {"version":3,"file":"ox-grist-editor-select.js","sourceRoot":"","sources":["../../../src/editors/ox-grist-editor-select.ts"],"names":[],"mappings":";AAAA,OAAO,6BAA6B,CAAA;AACpC,OAAO,iCAAiC,CAAA;AAExC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAE/C,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAGpD,SAAS,eAAe,CAAC,OAAuB;IAC9C,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE;QAC1B,QAAQ,OAAO,MAAM,EAAE,CAAC;YACtB,KAAK,QAAQ;gBACX,OAAO;oBACL,OAAO,EAAE,MAAM;oBACf,KAAK,EAAE,MAAM;iBACd,CAAA;YACH,KAAK,QAAQ;gBACX,OAAO;oBACL,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,MAAM,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C;YACpB,qBAAqB,CAAC,GAAG,EAAE,eAAC,OAAA,MAAA,MAAC,IAAI,CAAC,MAAc,0CAAE,MAAM,kDAAI,CAAA,EAAA,CAAC,CAAA;QAC/D,CAAC;IACH,CAAC;IAED,uHAAuH;IACvH,SAAS,CAAC,CAAQ;;QAChB,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;YACrB,OAAO,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA;QAC3B,CAAC;QAED,CAAC,CAAC,eAAe,EAAE,CAAA;QAEnB,MAAM,MAAM,GAAG,MAAM,CAAC,MAAA,MAAC,CAAC,CAAC,MAAc,0CAAE,KAAK,mCAAI,EAAE,CAAC,CAAA;QACrD,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,MAAM,CAAC,CAAA;QAC5E,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAA;QACjD,IAAI,CAAC,WAAW,EAAE,CAAA;IACpB,CAAC;;AAzEM,0BAAM,GAAG;IACd,GAAG,aAAa,CAAC,MAAM;IACvB,GAAG,CAAA;;;;;;;;KAQF;CACF,AAXY,CAWZ;AAZU,mBAAmB;IAD/B,aAAa,CAAC,wBAAwB,CAAC;GAC3B,mBAAmB,CA2E/B","sourcesContent":["import '@operato/input/ox-select.js'\nimport '@operato/popup/ox-popup-list.js'\n\nimport { css, html } from 'lit'\nimport { customElement } from 'lit/decorators.js'\nimport { until } from 'lit/directives/until.js'\n\nimport { OxGristEditor } from './ox-grist-editor.js'\nimport { SelectOption, SelectOptionObject } from '../types.js'\n\nfunction toOptionObjects(options: SelectOption[]) {\n return options.map(option => {\n switch (typeof option) {\n case 'string':\n return {\n display: option,\n value: option\n }\n case 'object':\n return {\n display: option.display || option.name,\n value: option.value\n }\n default:\n return option\n }\n }) as SelectOptionObject[]\n}\n\n/*\n * A value that is none of the options (an empty new row) opens on a blank, hidden option. Without it the browser shows\n * the first option as picked, and picking that option tells no change, so it could not be entered (2026-11-08).\n */\nfunction buildOptions(options: SelectOption[], value: any) {\n const optionObjects = toOptionObjects(options)\n const unmatched = !optionObjects.some(option => option.value == value)\n\n return html`\n <select>\n ${unmatched ? html`<option value=\"\" selected hidden></option>` : ''}\n ${optionObjects.map(\n (option: any) => html`\n <option ?selected=${option.value == value} value=${option.value}>${option.display}</option>\n `\n )}\n </select>\n `\n}\n\n/**\n * A select cell. With `record.searchable` it edits through the framework's popup list with a search box on top, as\n * select2 does: the list opens with the editor, typing narrows it, a click or Enter picks, and the pick is committed\n * at once. Without it, the browser's own `<select>`.\n */\n@customElement('ox-grist-editor-select')\nexport class OxGristEditorSelect extends OxGristEditor {\n static styles = [\n ...OxGristEditor.styles,\n css`\n :host([searchable]) {\n overflow: visible;\n }\n\n ox-select {\n width: 100%;\n }\n `\n ]\n\n /* The options as last drawn: a pick comes back as the text of its value attribute and is read back to the option's own value. */\n private _options: SelectOptionObject[] = []\n\n get searchable() {\n return !!this.column.record.searchable\n }\n\n connectedCallback() {\n super.connectedCallback()\n this.toggleAttribute('searchable', this.searchable)\n }\n\n get editorTemplate() {\n var rowOptionField = this.record[this.column.record.rowOptionField || '']\n var { options = [] } = rowOptionField ? rowOptionField : this.column.record\n\n if (typeof options == 'function') {\n options = options.call(null, this.value, this.column, this.record, this.rowIndex, this.field)\n }\n\n if (options instanceof Promise) {\n return html`${until(options.then(options => this.build((options || []) as SelectOption[])))}`\n }\n return this.build((options || []) as SelectOption[])\n }\n\n private build(options: SelectOption[]) {\n if (!this.searchable) {\n return buildOptions(options, this.value)\n }\n\n this._options = toOptionObjects(options)\n return html`<ox-select .value=${String(this.value ?? '')}>\n <ox-popup-list align-left nowrap with-search>\n ${this._options.map(option => html`<div option value=${option.value}>${option.display}</div>`)}\n </ox-popup-list>\n </ox-select>`\n }\n\n async firstUpdated() {\n await super.firstUpdated()\n\n /* Opening the cell opens the list, as a click on a select2 does. */\n if (this.searchable) {\n requestAnimationFrame(() => (this.editor as any)?.expand?.())\n }\n }\n\n /* The list tells a change each time it closes; what it holds then is committed, an unchanged value commits nothing. */\n _onchange(e: Event): void {\n if (!this.searchable) {\n return super._onchange(e)\n }\n\n e.stopPropagation()\n\n const picked = String((e.target as any)?.value ?? '')\n const option = this._options.find(option => String(option.value) === picked)\n this._dirtyValue = option ? option.value : picked\n this._onfocusout()\n }\n}\n"]}
@@ -0,0 +1,11 @@
1
+ import '@material/web/icon/icon.js';
2
+ import '@material/web/button/filled-button.js';
3
+ import '@material/web/button/filled-tonal-button.js';
4
+ import '@material/web/button/elevated-button.js';
5
+ import '@material/web/button/outlined-button.js';
6
+ import '@material/web/button/text-button.js';
7
+ import '@material/web/chips/assist-chip.js';
8
+ import '@operato/popup/ox-popup-actions.js';
9
+ import '../src/data-grid/data-grid-field.js';
10
+ import '../src/data-card/data-card-gutter.js';
11
+ import '../src/data-list/data-list-gutter.js';
@@ -0,0 +1,147 @@
1
+ import { expect, fixture } from '@open-wc/testing';
2
+ import { sendMouse } from '@web/test-runner-commands';
3
+ import { css, html, LitElement } from 'lit';
4
+ import { ButtonStyles, ButtonContainerStyles, CommonHeaderStyles } from '@operato/styles';
5
+ import '@material/web/icon/icon.js';
6
+ import '@material/web/button/filled-button.js';
7
+ import '@material/web/button/filled-tonal-button.js';
8
+ import '@material/web/button/elevated-button.js';
9
+ import '@material/web/button/outlined-button.js';
10
+ import '@material/web/button/text-button.js';
11
+ import '@material/web/chips/assist-chip.js';
12
+ import '@operato/popup/ox-popup-actions.js';
13
+ import '../src/data-grid/data-grid-field.js';
14
+ import '../src/data-card/data-card-gutter.js';
15
+ import '../src/data-list/data-list-gutter.js';
16
+ class BodyProbe extends LitElement {
17
+ render() { var _a; return (_a = this.content) !== null && _a !== void 0 ? _a : html `<button type="button" danger><md-icon>delete</md-icon>Delete</button>`; }
18
+ }
19
+ BodyProbe.properties = { content: { attribute: false } };
20
+ BodyProbe.styles = [ButtonStyles, css `:host { display: block }`];
21
+ class BarProbe extends BodyProbe {
22
+ }
23
+ BarProbe.styles = [ButtonContainerStyles];
24
+ class HeaderProbe extends BodyProbe {
25
+ render() { return html `<div class="header"><div class="actions"><button type="button" danger class="textbtn"><md-icon>delete</md-icon>Delete</button></div></div>`; }
26
+ }
27
+ HeaderProbe.styles = [CommonHeaderStyles];
28
+ customElements.define('danger-body-probe', BodyProbe);
29
+ customElements.define('danger-bar-probe', BarProbe);
30
+ customElements.define('danger-header-probe', HeaderProbe);
31
+ const column = { type: 'gutter', name: 'delete', danger: true, record: { renderer: () => html `<button type="button"><md-icon>delete</md-icon><span>Delete</span></button>` } };
32
+ const cases = [
33
+ ['form', html `<danger-body-probe></danger-body-probe>`],
34
+ ['quiet form', html `<danger-body-probe .content=${html `<button type="button" quiet danger><md-icon>delete</md-icon>Delete</button>`}></danger-body-probe>`],
35
+ ['raised form', html `<danger-body-probe .content=${html `<button type="button" raised danger><md-icon>delete</md-icon>Delete</button>`}></danger-body-probe>`],
36
+ ['toolbar', html `<danger-bar-probe></danger-bar-probe>`],
37
+ ['header', html `<danger-header-probe></danger-header-probe>`],
38
+ ['grid', html `<ox-grid-field danger .column=${column}></ox-grid-field>`],
39
+ ['card', html `<ox-card-gutter .column=${column}></ox-card-gutter>`],
40
+ ['mobile list', html `<ox-list-gutter .column=${column}></ox-list-gutter>`],
41
+ ['filled', html `<danger-body-probe .content=${html `<md-filled-button danger><md-icon slot="icon">delete</md-icon>Delete</md-filled-button>`}></danger-body-probe>`],
42
+ ['tonal', html `<danger-body-probe .content=${html `<md-filled-tonal-button danger><md-icon slot="icon">delete</md-icon>Delete</md-filled-tonal-button>`}></danger-body-probe>`],
43
+ ['elevated', html `<danger-body-probe .content=${html `<md-elevated-button danger><md-icon slot="icon">delete</md-icon>Delete</md-elevated-button>`}></danger-body-probe>`],
44
+ ['outlined', html `<danger-body-probe .content=${html `<md-outlined-button danger><md-icon slot="icon">delete</md-icon>Delete</md-outlined-button>`}></danger-body-probe>`],
45
+ ['text', html `<danger-body-probe .content=${html `<md-text-button danger><md-icon slot="icon">delete</md-icon>Delete</md-text-button>`}></danger-body-probe>`],
46
+ ['assist chip', html `<danger-bar-probe .content=${html `<md-assist-chip danger label="Delete"><md-icon slot="icon">delete</md-icon></md-assist-chip>`}></danger-bar-probe>`],
47
+ ['popup native', html `<ox-popup-actions><button type="button" slot="start" destructive><md-icon>delete</md-icon>Delete</button></ox-popup-actions>`],
48
+ ['popup filled', html `<ox-popup-actions><md-filled-button slot="confirm" destructive><md-icon slot="icon">delete</md-icon>Delete</md-filled-button></ox-popup-actions>`],
49
+ ['popup text', html `<ox-popup-actions><md-text-button slot="start" destructive><md-icon slot="icon">delete</md-icon>Delete</md-text-button></ox-popup-actions>`],
50
+ ['popup outlined', html `<ox-popup-actions><md-outlined-button slot="start" destructive><md-icon slot="icon">delete</md-icon>Delete</md-outlined-button></ox-popup-actions>`],
51
+ ];
52
+ const themes = {
53
+ light: { error: '#ba1a1a', onError: '#ffffff', container: '#ffdad6', onContainer: '#410002', surface: '#ffffff' },
54
+ dark: { error: '#ffb4ab', onError: '#690005', container: '#93000a', onContainer: '#ffdad6', surface: '#121212' },
55
+ boardDark: { error: '#fbafa9', onError: '#a3000c', container: '#a3000c', onContainer: '#fbafa9', surface: '#121318' },
56
+ custom: { error: '#a00000', onError: '#ffffff', container: '#ffdad6', onContainer: '#410002', surface: '#ffffff' }
57
+ };
58
+ const settle = () => new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve)));
59
+ function rgb(value) { const channels = value.match(/[\d.]+/g).slice(0, 3).map(Number); return value.startsWith('color(srgb') ? channels.map(n => n * 255) : channels; }
60
+ function contrast(a, b) {
61
+ const light = (color) => rgb(color).map(n => n / 255).map(n => n <= .04045 ? n / 12.92 : ((n + .055) / 1.055) ** 2.4).reduce((sum, n, i) => sum + n * [.2126, .7152, .0722][i], 0);
62
+ const x = light(a), y = light(b);
63
+ return (Math.max(x, y) + .05) / (Math.min(x, y) + .05);
64
+ }
65
+ function background(node) {
66
+ var _a, _b;
67
+ for (let current = node; current; current = (_b = (_a = current.parentElement) !== null && _a !== void 0 ? _a : current.getRootNode().host) !== null && _b !== void 0 ? _b : null) {
68
+ const color = getComputedStyle(current).backgroundColor;
69
+ if (color !== 'rgba(0, 0, 0, 0)' && color !== 'transparent')
70
+ return color;
71
+ }
72
+ return 'rgb(255, 255, 255)';
73
+ }
74
+ for (const [themeName, theme] of Object.entries(themes)) {
75
+ describe(`destructive action contrast: ${themeName}`, () => {
76
+ for (const [kind, template] of cases) {
77
+ it(`${kind}: icon follows the label before hover, on hover, focus, press and disabled`, async () => {
78
+ var _a, _b, _c, _d, _e, _f;
79
+ await sendMouse({ type: 'move', position: [0, 0] });
80
+ const root = await fixture(html `<div style="padding:30px; min-width:320px">${template}</div>`);
81
+ for (const [name, value] of Object.entries({
82
+ '--md-sys-color-error': theme.error, '--md-sys-color-on-error': theme.onError,
83
+ '--md-sys-color-error-container': theme.container, '--md-sys-color-on-error-container': theme.onContainer,
84
+ '--md-sys-color-surface-container-lowest': theme.surface, '--md-sys-color-on-surface': themeName === 'dark' || themeName === 'boardDark' ? '#ffffff' : '#111111',
85
+ '--md-sys-color-primary': '#005566', '--md-sys-color-secondary': '#006677', '--md-sys-color-secondary-container': '#aaffff', '--md-sys-color-on-secondary-container': '#001122'
86
+ }))
87
+ root.style.setProperty(name, value);
88
+ if (themeName === 'custom') {
89
+ root.style.setProperty('--danger-button-background', '#520000');
90
+ root.style.setProperty('--danger-button-color', '#fff0f0');
91
+ root.style.setProperty('--danger-button-hover-background', '#fff0f0');
92
+ root.style.setProperty('--danger-button-hover-color', '#520000');
93
+ }
94
+ if (themeName === 'boardDark') {
95
+ root.style.setProperty('--danger-button-background', 'var(--md-sys-color-error-container)');
96
+ root.style.setProperty('--danger-button-color', 'var(--md-sys-color-on-error-container)');
97
+ root.style.setProperty('--danger-button-hover-background', 'color-mix(in srgb, var(--md-sys-color-error-container) 88%, black)');
98
+ root.style.setProperty('--danger-button-hover-color', 'var(--md-sys-color-on-error-container)');
99
+ }
100
+ root.style.backgroundColor = theme.surface;
101
+ await settle();
102
+ const surface = root.firstElementChild;
103
+ await surface.updateComplete;
104
+ const slotted = surface.tagName.startsWith('OX-POPUP');
105
+ const control = (slotted ? surface.firstElementChild : surface.shadowRoot.querySelector('button, md-filled-button, md-filled-tonal-button, md-elevated-button, md-outlined-button, md-text-button, md-assist-chip'));
106
+ const icon = control.querySelector('md-icon');
107
+ const label = ((_d = (_b = (_a = control.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('.label')) !== null && _b !== void 0 ? _b : (_c = control.shadowRoot) === null || _c === void 0 ? void 0 : _c.querySelector('button')) !== null && _d !== void 0 ? _d : control);
108
+ const focusTarget = ((_f = (_e = control.shadowRoot) === null || _e === void 0 ? void 0 : _e.querySelector('button')) !== null && _f !== void 0 ? _f : control);
109
+ label.style.transition = 'none';
110
+ control.style.transition = 'none';
111
+ const check = (disabled = false) => {
112
+ const ink = getComputedStyle(label).color;
113
+ expect(getComputedStyle(icon).color, `${kind} icon/label`).to.equal(ink);
114
+ expect(icon.getBoundingClientRect().width).to.be.greaterThan(10);
115
+ if (!disabled)
116
+ expect(contrast(ink, background(control)), `${kind} contrast`).to.be.at.least(4.5);
117
+ };
118
+ check();
119
+ const box = control.getBoundingClientRect();
120
+ const position = [Math.round(box.x + box.width / 2), Math.round(box.y + box.height / 2)];
121
+ await sendMouse({ type: 'move', position });
122
+ await settle();
123
+ expect(control.matches(':hover')).to.equal(true);
124
+ check();
125
+ await sendMouse({ type: 'move', position: [0, 0] });
126
+ control.focus();
127
+ await settle();
128
+ check();
129
+ await sendMouse({ type: 'move', position });
130
+ await sendMouse({ type: 'down' });
131
+ try {
132
+ await settle();
133
+ check();
134
+ }
135
+ finally {
136
+ await sendMouse({ type: 'up' });
137
+ }
138
+ focusTarget.blur();
139
+ control.blur();
140
+ control.disabled = true;
141
+ await settle();
142
+ check(true);
143
+ });
144
+ }
145
+ });
146
+ }
147
+ //# sourceMappingURL=destructive-actions.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"destructive-actions.test.js","sourceRoot":"","sources":["../../test/destructive-actions.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AACrD,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAuB,MAAM,KAAK,CAAA;AAChE,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AACzF,OAAO,4BAA4B,CAAA;AACnC,OAAO,uCAAuC,CAAA;AAC9C,OAAO,6CAA6C,CAAA;AACpD,OAAO,yCAAyC,CAAA;AAChD,OAAO,yCAAyC,CAAA;AAChD,OAAO,qCAAqC,CAAA;AAC5C,OAAO,oCAAoC,CAAA;AAC3C,OAAO,oCAAoC,CAAA;AAC3C,OAAO,qCAAqC,CAAA;AAC5C,OAAO,sCAAsC,CAAA;AAC7C,OAAO,sCAAsC,CAAA;AAE7C,MAAM,SAAU,SAAQ,UAAU;IAIhC,MAAM,aAAK,OAAO,MAAA,IAAI,CAAC,OAAO,mCAAI,IAAI,CAAA,uEAAuE,CAAA,CAAC,CAAC;;AAHxG,oBAAU,GAAG,EAAE,OAAO,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,CAAA;AAE9C,gBAAM,GAAG,CAAC,YAAY,EAAE,GAAG,CAAA,0BAA0B,CAAC,CAAA;AAG/D,MAAM,QAAS,SAAQ,SAAS;;AAAU,eAAM,GAAG,CAAC,qBAAqB,CAAC,CAAA;AAC1E,MAAM,WAAY,SAAQ,SAAS;IAEjC,MAAM,KAAK,OAAO,IAAI,CAAA,4IAA4I,CAAA,CAAC,CAAC;;AAD7J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AK,CAAC,IAAI,CAAC,CAAA;YACb,CAAC,CAAC,CAAA;QACJ,CAAC;IACH,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import { expect, fixture } from '@open-wc/testing'\nimport { sendMouse } from '@web/test-runner-commands'\nimport { css, html, LitElement, type TemplateResult } from 'lit'\nimport { ButtonStyles, ButtonContainerStyles, CommonHeaderStyles } from '@operato/styles'\nimport '@material/web/icon/icon.js'\nimport '@material/web/button/filled-button.js'\nimport '@material/web/button/filled-tonal-button.js'\nimport '@material/web/button/elevated-button.js'\nimport '@material/web/button/outlined-button.js'\nimport '@material/web/button/text-button.js'\nimport '@material/web/chips/assist-chip.js'\nimport '@operato/popup/ox-popup-actions.js'\nimport '../src/data-grid/data-grid-field.js'\nimport '../src/data-card/data-card-gutter.js'\nimport '../src/data-list/data-list-gutter.js'\n\nclass BodyProbe extends LitElement {\n static properties = { content: { attribute: false } }\n content?: TemplateResult\n static styles = [ButtonStyles, css`:host { display: block }`]\n render() { return this.content ?? html`<button type=\"button\" danger><md-icon>delete</md-icon>Delete</button>` }\n}\nclass BarProbe extends BodyProbe { static styles = [ButtonContainerStyles] }\nclass HeaderProbe extends BodyProbe {\n static styles = [CommonHeaderStyles]\n render() { return html`<div class=\"header\"><div class=\"actions\"><button type=\"button\" danger class=\"textbtn\"><md-icon>delete</md-icon>Delete</button></div></div>` }\n}\ncustomElements.define('danger-body-probe', BodyProbe)\ncustomElements.define('danger-bar-probe', BarProbe)\ncustomElements.define('danger-header-probe', HeaderProbe)\n\nconst column = { type: 'gutter', name: 'delete', danger: true, record: { renderer: () => html`<button type=\"button\"><md-icon>delete</md-icon><span>Delete</span></button>` } }\nconst cases = [\n ['form', html`<danger-body-probe></danger-body-probe>`],\n ['quiet form', html`<danger-body-probe .content=${html`<button type=\"button\" quiet danger><md-icon>delete</md-icon>Delete</button>`}></danger-body-probe>`],\n ['raised form', html`<danger-body-probe .content=${html`<button type=\"button\" raised danger><md-icon>delete</md-icon>Delete</button>`}></danger-body-probe>`],\n ['toolbar', html`<danger-bar-probe></danger-bar-probe>`],\n ['header', html`<danger-header-probe></danger-header-probe>`],\n ['grid', html`<ox-grid-field danger .column=${column}></ox-grid-field>`],\n ['card', html`<ox-card-gutter .column=${column}></ox-card-gutter>`],\n ['mobile list', html`<ox-list-gutter .column=${column}></ox-list-gutter>`],\n ['filled', html`<danger-body-probe .content=${html`<md-filled-button danger><md-icon slot=\"icon\">delete</md-icon>Delete</md-filled-button>`}></danger-body-probe>`],\n ['tonal', html`<danger-body-probe .content=${html`<md-filled-tonal-button danger><md-icon slot=\"icon\">delete</md-icon>Delete</md-filled-tonal-button>`}></danger-body-probe>`],\n ['elevated', html`<danger-body-probe .content=${html`<md-elevated-button danger><md-icon slot=\"icon\">delete</md-icon>Delete</md-elevated-button>`}></danger-body-probe>`],\n ['outlined', html`<danger-body-probe .content=${html`<md-outlined-button danger><md-icon slot=\"icon\">delete</md-icon>Delete</md-outlined-button>`}></danger-body-probe>`],\n ['text', html`<danger-body-probe .content=${html`<md-text-button danger><md-icon slot=\"icon\">delete</md-icon>Delete</md-text-button>`}></danger-body-probe>`],\n ['assist chip', html`<danger-bar-probe .content=${html`<md-assist-chip danger label=\"Delete\"><md-icon slot=\"icon\">delete</md-icon></md-assist-chip>`}></danger-bar-probe>`],\n ['popup native', html`<ox-popup-actions><button type=\"button\" slot=\"start\" destructive><md-icon>delete</md-icon>Delete</button></ox-popup-actions>`],\n ['popup filled', html`<ox-popup-actions><md-filled-button slot=\"confirm\" destructive><md-icon slot=\"icon\">delete</md-icon>Delete</md-filled-button></ox-popup-actions>`],\n ['popup text', html`<ox-popup-actions><md-text-button slot=\"start\" destructive><md-icon slot=\"icon\">delete</md-icon>Delete</md-text-button></ox-popup-actions>`],\n ['popup outlined', html`<ox-popup-actions><md-outlined-button slot=\"start\" destructive><md-icon slot=\"icon\">delete</md-icon>Delete</md-outlined-button></ox-popup-actions>`],\n] as const\n\nconst themes = {\n light: { error: '#ba1a1a', onError: '#ffffff', container: '#ffdad6', onContainer: '#410002', surface: '#ffffff' },\n dark: { error: '#ffb4ab', onError: '#690005', container: '#93000a', onContainer: '#ffdad6', surface: '#121212' },\n boardDark: { error: '#fbafa9', onError: '#a3000c', container: '#a3000c', onContainer: '#fbafa9', surface: '#121318' },\n custom: { error: '#a00000', onError: '#ffffff', container: '#ffdad6', onContainer: '#410002', surface: '#ffffff' }\n}\nconst settle = () => new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve)))\nfunction rgb(value: string) { const channels = value.match(/[\\d.]+/g)!.slice(0, 3).map(Number); return value.startsWith('color(srgb') ? channels.map(n => n * 255) : channels }\nfunction contrast(a: string, b: string) {\n const light = (color: string) => rgb(color).map(n => n / 255).map(n => n <= .04045 ? n / 12.92 : ((n + .055) / 1.055) ** 2.4).reduce((sum, n, i) => sum + n * [.2126, .7152, .0722][i], 0)\n const x = light(a), y = light(b)\n return (Math.max(x, y) + .05) / (Math.min(x, y) + .05)\n}\nfunction background(node: Element): string {\n for (let current: Element | null = node; current; current = current.parentElement ?? (current.getRootNode() as ShadowRoot).host ?? null) {\n const color = getComputedStyle(current).backgroundColor\n if (color !== 'rgba(0, 0, 0, 0)' && color !== 'transparent') return color\n }\n return 'rgb(255, 255, 255)'\n}\n\nfor (const [themeName, theme] of Object.entries(themes)) {\n describe(`destructive action contrast: ${themeName}`, () => {\n for (const [kind, template] of cases) {\n it(`${kind}: icon follows the label before hover, on hover, focus, press and disabled`, async () => {\n await sendMouse({ type: 'move', position: [0, 0] })\n const root = await fixture<HTMLElement>(html`<div style=\"padding:30px; min-width:320px\">${template}</div>`)\n for (const [name, value] of Object.entries({\n '--md-sys-color-error': theme.error, '--md-sys-color-on-error': theme.onError,\n '--md-sys-color-error-container': theme.container, '--md-sys-color-on-error-container': theme.onContainer,\n '--md-sys-color-surface-container-lowest': theme.surface, '--md-sys-color-on-surface': themeName === 'dark' || themeName === 'boardDark' ? '#ffffff' : '#111111',\n '--md-sys-color-primary': '#005566', '--md-sys-color-secondary': '#006677', '--md-sys-color-secondary-container': '#aaffff', '--md-sys-color-on-secondary-container': '#001122'\n })) root.style.setProperty(name, value)\n if (themeName === 'custom') {\n root.style.setProperty('--danger-button-background', '#520000')\n root.style.setProperty('--danger-button-color', '#fff0f0')\n root.style.setProperty('--danger-button-hover-background', '#fff0f0')\n root.style.setProperty('--danger-button-hover-color', '#520000')\n }\n if (themeName === 'boardDark') {\n root.style.setProperty('--danger-button-background', 'var(--md-sys-color-error-container)')\n root.style.setProperty('--danger-button-color', 'var(--md-sys-color-on-error-container)')\n root.style.setProperty('--danger-button-hover-background', 'color-mix(in srgb, var(--md-sys-color-error-container) 88%, black)')\n root.style.setProperty('--danger-button-hover-color', 'var(--md-sys-color-on-error-container)')\n }\n root.style.backgroundColor = theme.surface\n await settle()\n const surface = root.firstElementChild as HTMLElement & { updateComplete?: Promise<unknown> }\n await surface.updateComplete\n const slotted = surface.tagName.startsWith('OX-POPUP')\n const control = (slotted ? surface.firstElementChild : surface.shadowRoot!.querySelector('button, md-filled-button, md-filled-tonal-button, md-elevated-button, md-outlined-button, md-text-button, md-assist-chip')) as HTMLElement & { disabled: boolean }\n const icon = control.querySelector('md-icon')!\n const label = (control.shadowRoot?.querySelector('.label') ?? control.shadowRoot?.querySelector('button') ?? control) as HTMLElement\n const focusTarget = (control.shadowRoot?.querySelector('button') ?? control) as HTMLElement\n label.style.transition = 'none'\n control.style.transition = 'none'\n const check = (disabled = false) => {\n const ink = getComputedStyle(label).color\n expect(getComputedStyle(icon).color, `${kind} icon/label`).to.equal(ink)\n expect(icon.getBoundingClientRect().width).to.be.greaterThan(10)\n if (!disabled) expect(contrast(ink, background(control)), `${kind} contrast`).to.be.at.least(4.5)\n }\n check()\n const box = control.getBoundingClientRect()\n const position: [number, number] = [Math.round(box.x + box.width / 2), Math.round(box.y + box.height / 2)]\n await sendMouse({ type: 'move', position })\n await settle()\n expect(control.matches(':hover')).to.equal(true)\n check()\n await sendMouse({ type: 'move', position: [0, 0] })\n control.focus()\n await settle()\n check()\n await sendMouse({ type: 'move', position })\n await sendMouse({ type: 'down' })\n try { await settle(); check() } finally { await sendMouse({ type: 'up' }) }\n focusTarget.blur(); control.blur()\n control.disabled = true\n await settle()\n check(true)\n })\n }\n })\n}\n"]}
@@ -0,0 +1 @@
1
+ import '../src/data-grist.js';
@@ -0,0 +1,134 @@
1
+ /* Elements are compared by presence, not by value: a failing element comparison makes chai render the DOM and hang the runner. */
2
+ import { expect, fixture } from '@open-wc/testing';
3
+ import { sendMouse } from '@web/test-runner-commands';
4
+ import { html } from 'lit';
5
+ import '../src/data-grist.js';
6
+ const settle = (ms = 150) => new Promise(resolve => setTimeout(resolve, ms));
7
+ const LONG = 'A very long account name that is far wider than any room the table has left for it';
8
+ async function grid(widths, width = 700, editable = false) {
9
+ var _a, _b;
10
+ const columns = [
11
+ { type: 'string', name: 'id', hidden: true },
12
+ { type: 'string', name: 'name', header: 'name', width: (_a = widths.name) !== null && _a !== void 0 ? _a : 150, record: { editable } },
13
+ { type: 'string', name: 'code', header: 'code', width: 100 },
14
+ { type: 'string', name: 'memo', header: 'memo', width: (_b = widths.memo) !== null && _b !== void 0 ? _b : 120 }
15
+ ];
16
+ const records = Array.from({ length: 5 }, (_, r) => ({ id: String(r), name: r % 2 ? LONG : 'short', code: 'C-' + r, memo: 'note ' + r }));
17
+ const el = (await fixture(html `
18
+ <ox-grist
19
+ style=${`width: ${width}px; height: 320px`}
20
+ mode="GRID"
21
+ .config=${{ columns, pagination: { infinite: true }, rows: { appendable: false, selectable: false } }}
22
+ .data=${{ records }}
23
+ ></ox-grist>
24
+ `));
25
+ await settle();
26
+ await el.updateComplete;
27
+ const ox = el.renderRoot.querySelector('#grist');
28
+ await ox.updateComplete;
29
+ const scroller = ox.renderRoot.querySelector('div[grid]');
30
+ const header = ox.renderRoot.querySelector('ox-grid-header');
31
+ const body = ox.renderRoot.querySelector('ox-grid-body');
32
+ await body.updateComplete;
33
+ await settle(50);
34
+ return { ox, scroller, header, body };
35
+ }
36
+ function heads(header) {
37
+ return Array.from(header.renderRoot.querySelectorAll('[role=columnheader]'));
38
+ }
39
+ function width(element) {
40
+ return Math.round(element.getBoundingClientRect().width);
41
+ }
42
+ /** The largest distance, in left or in width, between a header cell and a cell of its column, over every row. */
43
+ function misalignment(header, body) {
44
+ const hs = heads(header);
45
+ let worst = 0;
46
+ for (const row of Array.from(body.renderRoot.querySelectorAll('div[grid-row]'))) {
47
+ const cells = Array.from(row.querySelectorAll(':scope > ox-grid-field'));
48
+ hs.forEach((h, i) => {
49
+ const cell = cells[i];
50
+ if (!cell)
51
+ return;
52
+ const a = h.getBoundingClientRect();
53
+ const b = cell.getBoundingClientRect();
54
+ worst = Math.max(worst, Math.abs(a.left - b.left), Math.abs(a.width - b.width));
55
+ });
56
+ }
57
+ return Math.round(worst);
58
+ }
59
+ /** Whether the text of a column's cell is cut in any row. */
60
+ function cut(body, index) {
61
+ return Array.from(body.renderRoot.querySelectorAll('div[grid-row]')).some(row => {
62
+ const cell = row.querySelectorAll(':scope > ox-grid-field')[index];
63
+ return !!cell && [cell, ...Array.from(cell.renderRoot.querySelectorAll('*'))].some(e => e.scrollWidth > e.clientWidth + 1);
64
+ });
65
+ }
66
+ describe('a flexible column', () => {
67
+ /* Resizing the grid body inside a fixture trips Chrome's benign "ResizeObserver loop" error. */
68
+ const ignoreResizeLoop = (e) => {
69
+ if (String(e.message).includes('ResizeObserver loop')) {
70
+ e.stopImmediatePropagation();
71
+ e.preventDefault();
72
+ }
73
+ };
74
+ let previousOnError = null;
75
+ before(() => {
76
+ window.addEventListener('error', ignoreResizeLoop, true);
77
+ previousOnError = window.onerror;
78
+ window.onerror = (message, ...rest) => String(message).includes('ResizeObserver loop') ? true : previousOnError === null || previousOnError === void 0 ? void 0 : previousOnError.call(window, message, ...rest);
79
+ });
80
+ after(async () => {
81
+ window.removeEventListener('error', ignoreResizeLoop, true);
82
+ window.onerror = previousOnError;
83
+ await sendMouse({ type: 'move', position: [0, 0] });
84
+ });
85
+ it('with room, takes the room on the right and stays under its header', async () => {
86
+ const { scroller, header, body } = await grid({ name: 'minmax(150px, 1fr)' }, 1200);
87
+ const name = heads(header)[0];
88
+ expect(width(name), 'the column takes the room').to.be.greaterThan(500);
89
+ expect(scroller.scrollWidth, 'nothing overflows').to.be.at.most(scroller.clientWidth);
90
+ expect(misalignment(header, body)).to.equal(0);
91
+ });
92
+ it('without room, stays at its floor, cuts its text and stays under its header', async () => {
93
+ const { header, body } = await grid({ name: 'minmax(150px, 1fr)', memo: 600 }, 700);
94
+ expect(width(heads(header)[0])).to.equal(150);
95
+ expect(cut(body, 0), 'the long name is cut').to.equal(true);
96
+ expect(misalignment(header, body)).to.equal(0);
97
+ });
98
+ it('two flexible columns share the room one to two and stay under their headers', async () => {
99
+ const { header, body } = await grid({ name: 'minmax(100px, 1fr)', memo: 'minmax(100px, 2fr)' }, 900);
100
+ const [name, , memo] = heads(header);
101
+ /* fr shares the whole width of the tracks, not what is above their floors: 1fr and 2fr are x and 2x. */
102
+ const share = width(memo) / width(name);
103
+ expect(share).to.be.within(1.9, 2.1);
104
+ expect(misalignment(header, body)).to.equal(0);
105
+ });
106
+ it('leaves a table of fixed columns as it was', async () => {
107
+ const { body } = await grid({}, 700);
108
+ const cell = body.renderRoot.querySelector('ox-grid-field');
109
+ expect(getComputedStyle(cell).contain).to.equal('none');
110
+ });
111
+ it('prints with a valid template', async () => {
112
+ const { ox } = await grid({ name: 'minmax(150px, 1fr)' }, 700);
113
+ const print = ox.style.getPropertyValue('--grid-template-print-columns');
114
+ expect(CSS.supports('grid-template-columns', print), print).to.equal(true);
115
+ expect(print).to.contain('150fr');
116
+ });
117
+ it('dragging its edge gives it a width in px from where it stood', async () => {
118
+ const { header } = await grid({ name: 'minmax(150px, 1fr)' }, 1000, true);
119
+ const name = heads(header)[0];
120
+ const before = width(name);
121
+ const splitter = name.querySelector('span[splitter]');
122
+ expect(!!splitter, 'an editable column has a handle').to.equal(true);
123
+ const r = splitter.getBoundingClientRect();
124
+ const x = Math.round(r.left + r.width / 2);
125
+ const y = Math.round(r.top + r.height / 2);
126
+ await sendMouse({ type: 'move', position: [x, y] });
127
+ await sendMouse({ type: 'down' });
128
+ await sendMouse({ type: 'move', position: [x - 40, y] });
129
+ await sendMouse({ type: 'up' });
130
+ await settle(300);
131
+ expect(width(heads(header)[0])).to.be.within(before - 45, before - 35);
132
+ });
133
+ });
134
+ //# sourceMappingURL=flexible-columns.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flexible-columns.test.js","sourceRoot":"","sources":["../../test/flexible-columns.test.ts"],"names":[],"mappings":"AAAA,kIAAkI;AAClI,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AACrD,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAE1B,OAAO,sBAAsB,CAAA;AAuB7B,MAAM,MAAM,GAAG,CAAC,EAAE,GAAG,GAAG,EAAE,EAAE,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAA;AAE5E,MAAM,IAAI,GAAG,oFAAoF,CAAA;AAEjG,KAAK,UAAU,IAAI,CAAC,MAAkC,EAAE,KAAK,GAAG,GAAG,EAAE,QAAQ,GAAG,KAAK;;IACnF,MAAM,OAAO,GAAU;QACrB,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE;QAC5C,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAA,MAAM,CAAC,IAAI,mCAAI,GAAG,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,EAAE;QACjG,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM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B,CAAgB,CAAA;QACpE,MAAM,CAAC,CAAC,CAAC,QAAQ,EAAE,iCAAiC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QAEpE,MAAM,CAAC,GAAG,QAAQ,CAAC,qBAAqB,EAAE,CAAA;QAC1C,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAA;QAC1C,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;QAC1C,MAAM,SAAS,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAA;QACnD,MAAM,SAAS,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAA;QACjC,MAAM,SAAS,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,CAAA;QACxD,MAAM,SAAS,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAA;QAC/B,MAAM,MAAM,CAAC,GAAG,CAAC,CAAA;QAEjB,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,GAAG,EAAE,EAAE,MAAM,GAAG,EAAE,CAAC,CAAA;IACxE,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["/* Elements are compared by presence, not by value: a failing element comparison makes chai render the DOM and hang the runner. */\nimport { expect, fixture } from '@open-wc/testing'\nimport { sendMouse } from '@web/test-runner-commands'\nimport { html } from 'lit'\n\nimport '../src/data-grist.js'\n\n/**\n * A column that takes the room left over: `width: 'minmax(150px, 1fr)'`.\n *\n * A string width goes into grid-template-columns as it is, so fr was always accepted — and broke the\n * table. The header and the body are two CSS grids with the same template. A flexible track is sized\n * from what its cells hold, and the two grids hold different things: the body grew the column to its\n * longest text while the header kept it at its floor. Measured on the balance screen: 182px apart with\n * one fr column whose text was longer than the room, 251px with two fr columns.\n *\n * ```\n * aligned every cell sits under its header, room or no room\n * room a flexible column takes the room on the right; the filler after the last column gets none\n * no room it stays at its floor and its text is cut (\"…\"), as a fixed column's is\n * ratio 1fr and 2fr share the room one to two\n * print the print template is a valid template (px became fr letter by letter: minmax(150fr, 1fr))\n * resize dragging a flexible column's edge gives it a width in px from where it stood\n * ```\n */\n\ntype Root = HTMLElement & { renderRoot: ShadowRoot; updateComplete: Promise<unknown> }\n\nconst settle = (ms = 150) => new Promise(resolve => setTimeout(resolve, ms))\n\nconst LONG = 'A very long account name that is far wider than any room the table has left for it'\n\nasync function grid(widths: { name?: any; memo?: any }, width = 700, editable = false) {\n const columns: any[] = [\n { type: 'string', name: 'id', hidden: true },\n { type: 'string', name: 'name', header: 'name', width: widths.name ?? 150, record: { editable } },\n { type: 'string', name: 'code', header: 'code', width: 100 },\n { type: 'string', name: 'memo', header: 'memo', width: widths.memo ?? 120 }\n ]\n\n const records = Array.from({ length: 5 }, (_, r) => ({ id: String(r), name: r % 2 ? LONG : 'short', code: 'C-' + r, memo: 'note ' + r }))\n\n const el = (await fixture(html`\n <ox-grist\n style=${`width: ${width}px; height: 320px`}\n mode=\"GRID\"\n .config=${{ columns, pagination: { infinite: true }, rows: { appendable: false, selectable: false } }}\n .data=${{ records }}\n ></ox-grist>\n `)) as Root\n\n await settle()\n await el.updateComplete\n\n const ox = el.renderRoot.querySelector('#grist') as Root\n await ox.updateComplete\n const scroller = ox.renderRoot.querySelector('div[grid]') as HTMLElement\n const header = ox.renderRoot.querySelector('ox-grid-header') as Root\n const body = ox.renderRoot.querySelector('ox-grid-body') as Root\n await body.updateComplete\n await settle(50)\n\n return { ox, scroller, header, body }\n}\n\nfunction heads(header: Root) {\n return Array.from(header.renderRoot.querySelectorAll('[role=columnheader]')) as HTMLElement[]\n}\n\nfunction width(element: Element) {\n return Math.round(element.getBoundingClientRect().width)\n}\n\n/** The largest distance, in left or in width, between a header cell and a cell of its column, over every row. */\nfunction misalignment(header: Root, body: Root) {\n const hs = heads(header)\n let worst = 0\n for (const row of Array.from(body.renderRoot.querySelectorAll('div[grid-row]'))) {\n const cells = Array.from(row.querySelectorAll(':scope > ox-grid-field')) as HTMLElement[]\n hs.forEach((h, i) => {\n const cell = cells[i]\n if (!cell) return\n const a = h.getBoundingClientRect()\n const b = cell.getBoundingClientRect()\n worst = Math.max(worst, Math.abs(a.left - b.left), Math.abs(a.width - b.width))\n })\n }\n return Math.round(worst)\n}\n\n/** Whether the text of a column's cell is cut in any row. */\nfunction cut(body: Root, index: number) {\n return Array.from(body.renderRoot.querySelectorAll('div[grid-row]')).some(row => {\n const cell = row.querySelectorAll(':scope > ox-grid-field')[index] as Root | undefined\n return !!cell && [cell, ...Array.from(cell.renderRoot.querySelectorAll('*'))].some(e => e.scrollWidth > e.clientWidth + 1)\n })\n}\n\ndescribe('a flexible column', () => {\n /* Resizing the grid body inside a fixture trips Chrome's benign \"ResizeObserver loop\" error. */\n const ignoreResizeLoop = (e: ErrorEvent) => {\n if (String(e.message).includes('ResizeObserver loop')) {\n e.stopImmediatePropagation()\n e.preventDefault()\n }\n }\n let previousOnError: OnErrorEventHandler = null\n before(() => {\n window.addEventListener('error', ignoreResizeLoop, true)\n previousOnError = window.onerror\n window.onerror = (message, ...rest) =>\n String(message).includes('ResizeObserver loop') ? true : previousOnError?.call(window, message, ...rest)\n })\n after(async () => {\n window.removeEventListener('error', ignoreResizeLoop, true)\n window.onerror = previousOnError\n await sendMouse({ type: 'move', position: [0, 0] })\n })\n\n it('with room, takes the room on the right and stays under its header', async () => {\n const { scroller, header, body } = await grid({ name: 'minmax(150px, 1fr)' }, 1200)\n\n const name = heads(header)[0]\n expect(width(name), 'the column takes the room').to.be.greaterThan(500)\n expect(scroller.scrollWidth, 'nothing overflows').to.be.at.most(scroller.clientWidth)\n expect(misalignment(header, body)).to.equal(0)\n })\n\n it('without room, stays at its floor, cuts its text and stays under its header', async () => {\n const { header, body } = await grid({ name: 'minmax(150px, 1fr)', memo: 600 }, 700)\n\n expect(width(heads(header)[0])).to.equal(150)\n expect(cut(body, 0), 'the long name is cut').to.equal(true)\n expect(misalignment(header, body)).to.equal(0)\n })\n\n it('two flexible columns share the room one to two and stay under their headers', async () => {\n const { header, body } = await grid({ name: 'minmax(100px, 1fr)', memo: 'minmax(100px, 2fr)' }, 900)\n\n const [name, , memo] = heads(header)\n /* fr shares the whole width of the tracks, not what is above their floors: 1fr and 2fr are x and 2x. */\n const share = width(memo) / width(name)\n expect(share).to.be.within(1.9, 2.1)\n expect(misalignment(header, body)).to.equal(0)\n })\n\n it('leaves a table of fixed columns as it was', async () => {\n const { body } = await grid({}, 700)\n\n const cell = body.renderRoot.querySelector('ox-grid-field') as HTMLElement\n expect(getComputedStyle(cell).contain).to.equal('none')\n })\n\n it('prints with a valid template', async () => {\n const { ox } = await grid({ name: 'minmax(150px, 1fr)' }, 700)\n\n const print = ox.style.getPropertyValue('--grid-template-print-columns')\n expect(CSS.supports('grid-template-columns', print), print).to.equal(true)\n expect(print).to.contain('150fr')\n })\n\n it('dragging its edge gives it a width in px from where it stood', async () => {\n const { header } = await grid({ name: 'minmax(150px, 1fr)' }, 1000, true)\n\n const name = heads(header)[0]\n const before = width(name)\n const splitter = name.querySelector('span[splitter]') as HTMLElement\n expect(!!splitter, 'an editable column has a handle').to.equal(true)\n\n const r = splitter.getBoundingClientRect()\n const x = Math.round(r.left + r.width / 2)\n const y = Math.round(r.top + r.height / 2)\n await sendMouse({ type: 'move', position: [x, y] })\n await sendMouse({ type: 'down' })\n await sendMouse({ type: 'move', position: [x - 40, y] })\n await sendMouse({ type: 'up' })\n await settle(300)\n\n expect(width(heads(header)[0])).to.be.within(before - 45, before - 35)\n })\n})\n"]}
@@ -0,0 +1 @@
1
+ import '../src/editors/ox-grist-editor-select.js';
@@ -0,0 +1,61 @@
1
+ /* Elements are compared by presence, not by value: a failing element comparison makes chai render the DOM and hang the runner. */
2
+ import { expect, fixture } from '@open-wc/testing';
3
+ import { html } from 'lit';
4
+ import '../src/editors/ox-grist-editor-select.js';
5
+ import { buildColumn } from '../src/configure/column-builder.js';
6
+ /*
7
+ * An empty cell of a select column (the new row at the bottom of an appendable grid) must take its first option. The
8
+ * browser tells a change only when the picked option differs from the shown one, so the editor must not open showing
9
+ * the first option as picked (2026-11-08, 물품 대장 「종류」: 「처음에 "노트북.PC"를 선택해도 변화 이벤트가 발생하지 않아서」).
10
+ */
11
+ const KINDS = [
12
+ { display: '노트북.PC', value: 'COMPUTER' },
13
+ { display: '모니터', value: 'MONITOR' }
14
+ ];
15
+ const mount = async (record, mandatory = true) => {
16
+ const editor = (await fixture(html `${Object.assign(document.createElement('ox-grist-editor-select'), {
17
+ column: buildColumn({ type: 'select', name: 'kind', record: { editable: true, mandatory, options: KINDS } }),
18
+ record,
19
+ row: 0
20
+ })}`));
21
+ await editor.updateComplete;
22
+ const changes = [];
23
+ editor.addEventListener('field-change', event => changes.push(event.detail));
24
+ return { editor, changes, select: editor.renderRoot.querySelector('select') };
25
+ };
26
+ /* What the browser does on a pick: it tells input and change only when the picked option is not the shown one. */
27
+ const pick = (select, value) => {
28
+ if (select.value === value)
29
+ return;
30
+ select.value = value;
31
+ select.dispatchEvent(new Event('input', { bubbles: true, composed: true }));
32
+ select.dispatchEvent(new Event('change', { bubbles: true, composed: true }));
33
+ };
34
+ describe('a select cell with no value', () => {
35
+ for (const record of [{}, { kind: null }, { kind: '' }]) {
36
+ it(`takes the first option when it is picked (${JSON.stringify(record)})`, async () => {
37
+ const { editor, changes, select } = await mount(record);
38
+ pick(select, 'COMPUTER');
39
+ editor.flush();
40
+ expect(changes.length).to.equal(1);
41
+ expect(changes[0].after).to.equal('COMPUTER');
42
+ });
43
+ }
44
+ it('lists only the real options to pick from', async () => {
45
+ const { select } = await mount({});
46
+ const pickable = Array.from(select.options).filter(option => !option.hidden);
47
+ expect(pickable.map(option => option.value)).to.deep.equal(['COMPUTER', 'MONITOR']);
48
+ });
49
+ it('an untouched empty cell commits nothing', async () => {
50
+ const { editor, changes } = await mount({});
51
+ editor.flush();
52
+ editor._onfocusout();
53
+ expect(changes.length).to.equal(0);
54
+ });
55
+ it('a cell with a value opens on that value, with no blank option', async () => {
56
+ const { select } = await mount({ kind: 'MONITOR' });
57
+ expect(select.value).to.equal('MONITOR');
58
+ expect(select.options.length).to.equal(2);
59
+ });
60
+ });
61
+ //# sourceMappingURL=select-empty-value.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"select-empty-value.test.js","sourceRoot":"","sources":["../../test/select-empty-value.test.ts"],"names":[],"mappings":"AAAA,kIAAkI;AAClI,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAE1B,OAAO,0CAA0C,CAAA;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAA;AAGhE;;;;GAIG;AAEH,MAAM,KAAK,GAAG;IACZ,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE;IACxC,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE;CACrC,CAAA;AAED,MAAM,KAAK,GAAG,KAAK,EAAE,MAAW,EAAE,SAAS,GAAG,IAAI,EAAE,EAAE;IACpD,MAAM,MAAM,GAAG,CAAC,MAAM,OAAO,CAC3B,IAAI,CAAA,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,wBAAwB,CAAC,EAAE;QACrE,MAAM,EAAE,WAAW,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE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EAAE,KAAK,IAAI,EAAE;QAC7E,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,KAAK,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAA;QACnD,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,CAAA;QACxC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;IAC3C,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["/* Elements are compared by presence, not by value: a failing element comparison makes chai render the DOM and hang the runner. */\nimport { expect, fixture } from '@open-wc/testing'\nimport { html } from 'lit'\n\nimport '../src/editors/ox-grist-editor-select.js'\nimport { buildColumn } from '../src/configure/column-builder.js'\nimport { OxGristEditor } from '../src/editors/ox-grist-editor.js'\n\n/*\n * An empty cell of a select column (the new row at the bottom of an appendable grid) must take its first option. The\n * browser tells a change only when the picked option differs from the shown one, so the editor must not open showing\n * the first option as picked (2026-11-08, 물품 대장 「종류」: 「처음에 \"노트북.PC\"를 선택해도 변화 이벤트가 발생하지 않아서」).\n */\n\nconst KINDS = [\n { display: '노트북.PC', value: 'COMPUTER' },\n { display: '모니터', value: 'MONITOR' }\n]\n\nconst mount = async (record: any, mandatory = true) => {\n const editor = (await fixture(\n html`${Object.assign(document.createElement('ox-grist-editor-select'), {\n column: buildColumn({ type: 'select', name: 'kind', record: { editable: true, mandatory, options: KINDS } }),\n record,\n row: 0\n })}`\n )) as OxGristEditor\n await editor.updateComplete\n const changes: any[] = []\n editor.addEventListener('field-change', event => changes.push((event as CustomEvent).detail))\n return { editor, changes, select: editor.renderRoot.querySelector('select') as HTMLSelectElement }\n}\n\n/* What the browser does on a pick: it tells input and change only when the picked option is not the shown one. */\nconst pick = (select: HTMLSelectElement, value: string) => {\n if (select.value === value) return\n select.value = value\n select.dispatchEvent(new Event('input', { bubbles: true, composed: true }))\n select.dispatchEvent(new Event('change', { bubbles: true, composed: true }))\n}\n\ndescribe('a select cell with no value', () => {\n for (const record of [{}, { kind: null }, { kind: '' }]) {\n it(`takes the first option when it is picked (${JSON.stringify(record)})`, async () => {\n const { editor, changes, select } = await mount(record)\n pick(select, 'COMPUTER')\n editor.flush()\n expect(changes.length).to.equal(1)\n expect(changes[0].after).to.equal('COMPUTER')\n })\n }\n\n it('lists only the real options to pick from', async () => {\n const { select } = await mount({})\n const pickable = Array.from(select.options).filter(option => !option.hidden)\n expect(pickable.map(option => option.value)).to.deep.equal(['COMPUTER', 'MONITOR'])\n })\n\n it('an untouched empty cell commits nothing', async () => {\n const { editor, changes } = await mount({})\n editor.flush()\n editor._onfocusout()\n expect(changes.length).to.equal(0)\n })\n\n it('a cell with a value opens on that value, with no blank option', async () => {\n const { select } = await mount({ kind: 'MONITOR' })\n expect(select.value).to.equal('MONITOR')\n expect(select.options.length).to.equal(2)\n })\n})\n"]}
@@ -0,0 +1,2 @@
1
+ import '../src/data-grist.js';
2
+ import '../src/data-report.js';