@lango-project/lango-client 0.4.0 → 0.4.1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"tables.mjs","sources":["tables.lango"],"sourcesContent":["import js global document\nimport js global Number\nimport \"./control\"\n class Control\nimport \"./templates\"\n cloneMarkup(name, xml)\nimport \"./content\"\n appendContent(form, element, content, renderer)\n bindAction(control, element, url)\n decorate(control, props)\n\nexport spanValue(value)\n\nspanValue(value)\n if value == null\n return 1\n if !is_number(value) or !Number/isInteger(value) or value < 1 or value > 1000\n throw \"Table span must be an integer between 1 and 1000\"\n return value\n\nexport class Table(form, props, renderer) : Control\n\nTable(form, props, renderer)\n super(form, props, cloneMarkup(\"table\", <div class=\"table-responsive\"><table class=\"table\"><colgroup></colgroup><tbody></tbody></table></div>))\n table = @element.firstElementChild\n group = table.firstElementChild\n body = table.lastElementChild\n columns = []\n rows = []\n dividers = []\n width = 1\n header = null\n if props.stripedRows == true\n table.classList.add(\"table-striped\")\n if props.stripedColumns == true\n table.classList.add(\"table-striped-columns\")\n if props.hoverableRows == true\n table.classList.add(\"table-hover\")\n if props.small == true\n table.classList.add(\"table-sm\")\n if props.border != null and props.border != false\n table.classList.add(\"table-bordered\")\n if is_object(props.border)\n if props.border.color != null\n table.style.setProperty(\"--bs-table-border-color\", props.border.color)\n if props.border.width != null\n table.style.setProperty(\"--bs-border-width\", \"${props.border.width}px\")\n if props.caption != null\n caption = document/createElement(\"caption\")\n appendContent(form, caption, props.caption, renderer)\n table.prepend(caption)\n if props.aria != null\n for props.aria as name: value\n table.setAttribute(\"aria-${name}\", value)\n if props.controls != null\n for props.controls as definition\n switch definition.type\n case \"tableCol\"\n col = new TableCol(form, definition)\n form.register(definition.name, col)\n columns.add(col)\n group.appendChild(col.element)\n case \"tableHeader\"\n if header != null\n throw \"Table accepts one TableHeader\"\n header = new TableHeader(form, definition, renderer)\n form.register(definition.name, header)\n table.insertBefore(header.element, body)\n for header.rows as heading\n rows.add(heading)\n case \"tableRow\"\n row = new TableRow(form, definition, renderer, false)\n form.register(definition.name, row)\n rows.add(row)\n body.appendChild(row.element)\n case \"tableDivider\"\n divider = new TableDivider(form, definition)\n form.register(definition.name, divider)\n dividers.add(divider)\n body.appendChild(divider.element)\n else\n throw \"Unsupported Table child: ${definition.type}\"\n for rows as row\n if row.width > width\n width = row.width\n for dividers as divider\n divider.element.firstElementChild.colSpan = width\n if rows.length > 0\n first = rows[0]\n offset = 0\n for columns as col\n offset = offset + col.span\n if col.resize\n anchor = first.boundary(offset)\n if anchor == null\n throw \"Resizable column must end at a first-row cell boundary\"\n col.attach(anchor, table)\n\nexport class TableHeader(form, props, renderer) : Control\n properties\n rows\n\nTableHeader(form, props, renderer)\n super(form, props, cloneMarkup(\"table-header\", <thead></thead>))\n decorate(@this, props)\n @rows = []\n if props.controls != null\n for props.controls as definition\n if definition.type != \"tableRow\"\n throw \"TableHeader accepts TableRow definitions\"\n row = new TableRow(form, definition, renderer, true)\n form.register(definition.name, row)\n @rows.add(row)\n @element.appendChild(row.element)\n\nexport class TableRow(form, props, renderer, heading) : Control\n properties\n width\n methods\n boundary(column)\n\nTableRow(form, props, renderer, heading)\n super(form, props, cloneMarkup(\"table-row\", <tr></tr>))\n decorate(@this, props)\n @width = 0\n @cells = []\n if props.controls != null\n for props.controls as definition\n if definition.type != \"tableCell\"\n throw \"TableRow accepts TableCell definitions\"\n cell = new TableCell(form, definition, renderer, heading)\n form.register(definition.name, cell)\n @cells.add(cell)\n @width = @width + cell.element.colSpan\n @element.appendChild(cell.element)\n bindAction(@this, @element, props.url)\n\nTableRow:boundary(column)\n offset = 0\n for @cells as cell\n offset = offset + cell.element.colSpan\n if offset == column\n return cell.element\n return null\n\nexport class TableCell(form, props, renderer, heading) : Control\n\nTableCell(form, props, renderer, heading)\n super(form, props, cellElement(heading))\n @element.colSpan = spanValue(props.colSpan)\n @element.rowSpan = spanValue(props.rowSpan)\n if props.verticalAlignment != null\n @element.style.verticalAlign = props.verticalAlignment\n if props.horizontalAlignment != null\n @element.style.textAlign = props.horizontalAlignment\n appendContent(form, @element, props.controls, renderer)\n if props.style != null\n for props.style as name: value\n @element.style.setProperty(name, value)\n if props.aria != null\n for props.aria as name: value\n @element.setAttribute(\"aria-${name}\", value)\n bindAction(@this, @element, props.url)\n\ncellElement(heading)\n if heading\n return cloneMarkup(\"table-heading\", <th scope=\"col\"></th>)\n return cloneMarkup(\"table-cell\", <td></td>)\n\nexport class TableDivider(form, props) : Control\n\nTableDivider(form, props)\n super(form, props, cloneMarkup(\"table-divider\", <tr class=\"lango-table-divider\" aria-hidden=\"true\"><td><hr /></td></tr>))\n decorate(@this, props)\n\nexport class TableCol(form, props) : Control\n properties\n span\n resize\n methods\n attach(cell, table)\n size(width)\n\nTableCol(form, props)\n super(form, props, cloneMarkup(\"table-col\", <col />))\n decorate(@this, props)\n @span = spanValue(props.colSpan)\n @resize = props.resize == true\n @element.span = @span\n if props.width != null\n if is_number(props.width)\n @element.style.width = \"${props.width}px\"\n else\n @element.style.width = props.width\n\nTableCol:size(width)\n if width < 24\n width = 24\n @element.style.width = \"${width}px\"\n @handle.setAttribute(\"aria-valuenow\", \"${width}\")\n return null\n\nTableCol:attach(cell, table)\n handle = document/createElement(\"button\")\n handle.type = \"button\"\n handle.className = \"lango-col-resize\"\n handle.setAttribute(\"role\", \"separator\")\n handle.setAttribute(\"aria-orientation\", \"vertical\")\n handle.setAttribute(\"aria-label\", \"↔\")\n handle.setAttribute(\"aria-valuemin\", \"24\")\n handle.setAttribute(\"aria-valuenow\", \"24\")\n @handle = handle\n cell.classList.add(\"lango-resizable-cell\")\n cell.appendChild(handle)\n drag = {\n active: false\n x: 0\n width: 0\n }\n down = (event)\n capture drag\n capture handle\n capture table\n if event.button != 0 or drag.active\n return null\n event.preventDefault()\n drag.active = true\n drag.x = event.clientX\n drag.width = @element.getBoundingClientRect().width / @span\n style = table.style\n style.tableLayout = \"fixed\"\n handle.setPointerCapture(event.pointerId)\n move = (event)\n capture drag\n if drag.active\n size(drag.width + (event.clientX - drag.x) / @span)\n up = (event)\n capture drag\n if drag.active\n drag.active = false\n key = (event)\n capture table\n if event.key != \"ArrowLeft\" and event.key != \"ArrowRight\"\n return null\n event.preventDefault()\n style = table.style\n style.tableLayout = \"fixed\"\n step = 10\n if event.key == \"ArrowLeft\"\n step = -10\n size(@element.getBoundingClientRect().width / @span + step)\n handle.addEventListener(\"pointerdown\", down)\n handle.addEventListener(\"pointermove\", move)\n handle.addEventListener(\"lostpointercapture\", up)\n handle.addEventListener(\"pointerup\", up)\n handle.addEventListener(\"pointercancel\", up)\n handle.addEventListener(\"keydown\", key)\n release = ()\n capture handle\n capture down\n capture move\n capture up\n capture key\n handle.removeEventListener(\"pointerdown\", down)\n handle.removeEventListener(\"pointermove\", move)\n handle.removeEventListener(\"lostpointercapture\", up)\n handle.removeEventListener(\"pointerup\", up)\n handle.removeEventListener(\"pointercancel\", up)\n handle.removeEventListener(\"keydown\", key)\n handle.remove()\n @release.add(release)\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAoBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8EA;;;;;;;;;;;;;;;;;;;;;;;;AAiBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBA;;;;;;;;;;AAMA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAlKA;;;;;;;;;;;;;AAuJA;;;;;;;;;;"}
1
+ {"version":3,"file":"tables.mjs","sources":["tables.lango"],"sourcesContent":["import js global getComputedStyle\nimport \"./dimensions\"\n measure(value, unit)\nimport js global document\nimport js global Number\nimport js global Math\nimport js global Object\nimport js global Reflect\nimport js global JSON\nimport js global Promise\nimport js global structuredClone\nimport \"./table_scope\"\n class TableScope\nimport \"./control\"\n class Control\nimport \"./form\"\n class Form\nimport \"./templates\"\n cloneMarkup(name, xml)\nimport \"./content\"\n appendContent(form, element, content, renderer)\n bindAction(control, element, url)\n decorate(control, props)\n\nexport spanValue(value)\nexport columnWidth(value)\n\nspanValue(value)\n if value == null\n return 1\n if !is_number(value) or !Number/isInteger(value) or value < 1 or value > 1000\n throw \"Table span must be an integer between 1 and 1000\"\n return value\n\napplySpan(element, name, value)\n span = spanValue(value)\n if span == 1\n element.removeAttribute(name)\n else\n element.setAttribute(name, \"${span}\")\n return null\n\ncolumnWidth(value)\n return measure(value, \"ch\")\n\nexport class Table(form, props, renderer) : Control\n properties\n rows\n columns\n methods\n find(name)\n getValue()\n prepareValue()\n clearValidation()\n setValue(values)\n addRow(value = null)\n insertRow(beforeIndex, value = null)\n deleteRow(index)\n setRowValue(index, value)\n setRowData(index, value)\n setCellValue(index, column, value)\n createRow(value)\n names(rows, replace = false)\n publish(names)\n resize(rows)\n dispose()\n\nTable(form, props, renderer)\n super(form, props, cloneMarkup(\"table\", <div class=\"table-responsive\"><table class=\"table\"><colgroup></colgroup><tbody></tbody></table></div>))\n @renderer = renderer\n @props = props\n @building = true\n @mode = props.valueMode\n if @mode == null\n @mode = \"none\"\n modes = [\"none\", \"cells\", \"rows\", \"mixed\"]\n if !modes.includes(@mode)\n throw \"Table valueMode must be none, cells, rows or mixed\"\n @layout = new TableScope(form)\n @lookup = new TableScope(form)\n @rows = []\n @columns = []\n @header = null\n @aliases = Object/create(null)\n @table = @element.firstElementChild\n @body = @table.lastElementChild\n @template = props.rowTemplate\n if @template != null and @template.type != \"tableRowTemplate\"\n throw \"Table rowTemplate requires a TableRowTemplate\"\n table = @table\n group = table.firstElementChild\n headings = []\n hasCaptions = false\n try\n if props.stripedRows == true\n table.classList.add(\"table-striped\")\n if props.stripedColumns == true\n table.classList.add(\"table-striped-columns\")\n if props.hoverableRows == true\n table.classList.add(\"table-hover\")\n if props.small == true\n table.classList.add(\"table-sm\")\n if props.border != null and props.border != false\n table.classList.add(\"table-bordered\")\n if is_object(props.border)\n if props.border.color != null\n table.style.setProperty(\"--bs-table-border-color\", props.border.color)\n if props.border.width != null\n table.style.setProperty(\"--bs-border-width\", \"${props.border.width}px\")\n if props.caption != null\n caption = document/createElement(\"caption\")\n appendContent(@layout, caption, props.caption, renderer)\n table.prepend(caption)\n if props.aria != null\n for props.aria as name: value\n table.setAttribute(\"aria-${name}\", value)\n if props.controls != null\n for props.controls as definition\n switch definition.type\n case \"tableCol\"\n col = new TableCol(@layout, definition)\n @layout.register(null, col)\n col.name = definition.name\n if col.name != null\n for @columns as previous\n if previous.name == col.name\n throw \"Duplicate column name: ${col.name}\"\n @columns.add(col)\n headings.add({\n type: \"tableCell\"\n colSpan: definition.colSpan\n controls: definition.caption\n })\n if definition.caption != null\n hasCaptions = true\n group.appendChild(col.element)\n case \"tableHeader\"\n if @header != null\n throw \"Table accepts one TableHeader\"\n @header = new TableHeader(@layout, definition, renderer)\n @layout.register(definition.name, @header)\n table.insertBefore(@header.element, @body)\n case \"tableRow\"\n row = new TableRow(form, definition, renderer, false)\n @rows.add(row)\n @body.appendChild(row.element)\n case \"tableDivider\"\n divider = new TableDivider(@layout, definition)\n @layout.register(definition.name, divider)\n @body.appendChild(divider.element)\n else\n throw \"Unsupported Table child: ${definition.type}\"\n if @header == null and hasCaptions\n generated = {\n controls: [{\n type: \"tableRow\"\n controls: headings\n }]\n }\n @header = new TableHeader(@layout, generated, renderer)\n @layout.register(null, @header)\n table.insertBefore(@header.element, @body)\n width = 1\n for @rows as row\n width = Math/max(width, row.width)\n for @layout.owned as child\n if is_kindof(child, TableDivider)\n applySpan(child.element.firstElementChild, \"colspan\", width)\n if props.value != null\n setValue(props.value)\n else\n publish(names(@rows))\n resize(@rows)\n @building = false\n catch error\n dispose()\n throw error\n\nTable:find(name)\n return @lookup.find(name)\n\nTable:names(rows, replace = false)\n result = Object/create(null)\n for @layout.controls as name: control\n if !replace or !is_kindof(control, TableDivider)\n addName(result, name, control)\n sources = rows.slice()\n if @header != null\n for @header.rows as row\n sources.add(row)\n for sources as row\n addName(result, row.name, row)\n for row.cells as cell\n if cell.name != null\n addName(result, cell.name, cell)\n else\n if !row.generated\n for cell.scope.controls as name: control\n addName(result, name, control)\n return result\n\nTable:publish(names)\n if @props.name == null\n for names as name: control\n if name in @form.controls and @form.controls[name] != @aliases[name]\n throw \"Invalid or duplicate control name: ${name}\"\n for @aliases as name: control\n if @form.controls[name] == control\n Reflect/deleteProperty(@form.controls, name)\n for names as name: control\n @form.controls[name] = control\n @aliases = names\n @lookup.controls = names\n return null\n\nTable:getValue()\n if @mode == \"none\"\n return null\n if @mode == \"cells\"\n return @lookup.getValue()\n rows = []\n for @rows as row\n rows.add(row.getRowValue(@columns))\n if @mode == \"rows\"\n return rows\n return {\n cells: @lookup.getValue()\n rows: rows\n }\n\nTable:prepareValue()\n pending = []\n ready = @layout.prepareValue()\n if ready != null\n pending.add(ready)\n for @rows as row\n ready = row.prepareValue()\n if ready != null\n pending.add(ready)\n return allReady(pending)\n\nTable:clearValidation()\n super.clearValidation()\n if @layout != null\n @layout.clearValidation()\n if @rows != null\n for @rows as row\n row.clearValidation()\n return null\n\nTable:createRow(value)\n rowValue(value)\n definition = null\n if @template != null\n definition = structuredClone(@template)\n else\n cells = []\n for @columns as column\n cells.add({\n type: \"tableCell\"\n colSpan: column.span\n })\n definition = {\n controls: cells\n }\n row = new TableRow(@form, definition, @renderer, false)\n row.generated = true\n try\n row.setRowValue(value, @columns)\n catch error\n row.dispose()\n throw error\n return row\n\nTable:setValue(values)\n if values == null\n values = []\n if !is_array(values)\n throw \"Table value must be an array of row maps\"\n staged = []\n try\n for values as value\n staged.add(createRow(value))\n next = names(staged, true)\n validateBoundaries(@header, staged, @columns)\n publish(next)\n catch error\n for staged as row\n row.dispose()\n throw error\n if !@building\n @form.clearResources()\n for @rows as row\n row.dispose()\n @rows = staged\n @body.replaceChildren()\n for @layout.owned.slice() as child\n if is_kindof(child, TableDivider)\n @layout.unregister(child)\n child.dispose()\n for staged as row\n @body.appendChild(row.element)\n resize(staged)\n return @this\n\nTable:addRow(value = null)\n return insertRow(@rows.length, value)\n\nTable:insertRow(beforeIndex, value = null)\n tableIndex(beforeIndex, @rows.length, true)\n row = createRow(value)\n staged = @rows.slice()\n staged.splice(beforeIndex, 0, row)\n try\n next = names(staged)\n validateBoundaries(@header, staged, @columns)\n publish(next)\n catch error\n row.dispose()\n throw error\n @form.clearResources()\n anchor = null\n if beforeIndex < @rows.length\n anchor = @rows[beforeIndex].element\n @body.insertBefore(row.element, anchor)\n @rows = staged\n resize(staged)\n return @this\n\nTable:deleteRow(index)\n tableIndex(index, @rows.length)\n staged = @rows.slice()\n row = staged.splice(index, 1)[0]\n validateBoundaries(@header, staged, @columns)\n publish(names(staged))\n @form.clearResources()\n row.dispose()\n row.element.remove()\n @rows = staged\n resize(staged)\n return @this\n\nTable:setRowValue(index, value)\n tableIndex(index, @rows.length)\n @rows[index].setRowValue(value, @columns)\n return @this\n\nTable:setRowData(index, value)\n tableIndex(index, @rows.length)\n row = @rows[index]\n row.data = structuredClone(value)\n return @this\n\nTable:setCellValue(index, column, value)\n tableIndex(index, @rows.length)\n selected = columnIndex(column, @columns)\n row = @rows[index]\n tableIndex(selected, row.cells.length)\n row.cells[selected].setValue(value)\n return @this\n\nTable:resize(rows)\n width = 1\n for rows as row\n width = Math/max(width, row.width)\n if @header != null\n for @header.rows as row\n width = Math/max(width, row.width)\n for @layout.owned as child\n if is_kindof(child, TableDivider)\n applySpan(child.element.firstElementChild, \"colspan\", width)\n for @columns as col\n col.detach()\n first = validateBoundaries(@header, rows, @columns)\n if first != null\n offset = 0\n for @columns as col\n offset = offset + col.span\n if col.resize\n col.attach(first.boundary(offset), @table)\n return null\n\nTable:dispose()\n if @aliases != null\n for @aliases as name: control\n if @form.controls[name] == control\n Reflect/deleteProperty(@form.controls, name)\n @aliases = Object/create(null)\n if @rows != null\n for @rows as row\n row.dispose()\n @rows = []\n if @layout != null\n @layout.dispose()\n return super.dispose()\n\nexport class TableHeader(form, props, renderer) : Control\n properties\n rows\n methods\n prepareValue()\n clearValidation()\n dispose()\n\nTableHeader(form, props, renderer)\n super(form, props, cloneMarkup(\"table-header\", <thead></thead>))\n decorate(@this, props)\n @rows = []\n try\n if props.controls != null\n for props.controls as definition\n if definition.type != \"tableRow\"\n throw \"TableHeader accepts TableRow definitions\"\n row = new TableRow(form, definition, renderer, true)\n @rows.add(row)\n @element.appendChild(row.element)\n catch error\n dispose()\n throw error\n\nTableHeader:prepareValue()\n pending = []\n for @rows as row\n ready = row.prepareValue()\n if ready != null\n pending.add(ready)\n return allReady(pending)\n\nTableHeader:clearValidation()\n super.clearValidation()\n if @rows != null\n for @rows as row\n row.clearValidation()\n return null\n\nTableHeader:dispose()\n for @rows as row\n row.dispose()\n @rows = []\n return super.dispose()\n\nexport class TableRow(form, props, renderer, heading) : Control\n properties\n name\n data\n generated\n width\n cells\n methods\n boundary(column)\n setRowValue(value, columns)\n getRowValue(columns)\n getValue()\n prepareValue()\n clearValidation()\n dispose()\n\nTableRow(form, props, renderer, heading)\n super(form, props, cloneMarkup(\"table-row\", <tr></tr>))\n decorate(@this, props)\n @name = props.name\n @data = structuredClone(props.data)\n @generated = false\n @width = 0\n @cells = []\n @scope = new TableScope(form)\n try\n if props.controls != null\n for props.controls as definition\n if definition.type != \"tableCell\"\n throw \"TableRow accepts TableCell definitions\"\n cell = new TableCell(@scope, definition, renderer, heading)\n @scope.register(definition.name, cell)\n @cells.add(cell)\n @width = @width + cell.element.colSpan\n @element.appendChild(cell.element)\n bindAction(@this, @element, props.url)\n catch error\n dispose()\n throw error\n\nTableRow:boundary(column)\n offset = 0\n for @cells as cell\n offset = offset + cell.element.colSpan\n if offset == column\n return cell.element\n return null\n\nTableRow:setRowValue(value, columns)\n rowValue(value)\n for @cells as index: cell\n name = cell.name\n if index < columns.length\n name = columns[index].name\n field = null\n if value != null and name != null and Object/hasOwn(value, name)\n field = value[name]\n cell.setValue(field)\n return @this\n\nTableRow:getRowValue(columns)\n result = Object/create(null)\n for @cells as index: cell\n name = cell.name\n if index < columns.length\n name = columns[index].name\n if name != null\n if name in result\n throw \"Duplicate row value name: ${name}\"\n result[name] = cell.getValue()\n return result\n\nTableRow:getValue()\n return @scope.getValue()\n\nTableRow:prepareValue()\n return @scope.prepareValue()\n\nTableRow:clearValidation()\n super.clearValidation()\n if @scope != null\n @scope.clearValidation()\n return null\n\nTableRow:dispose()\n if @scope != null\n @scope.dispose()\n return super.dispose()\n\nexport class TableCell(form, props, renderer, heading) : Control\n properties\n name\n scope\n methods\n find(name)\n getValue()\n setValue(value)\n prepareValue()\n clearValidation()\n dispose()\n\nTableCell(form, props, renderer, heading)\n super(form, props, cellElement(heading))\n @name = props.name\n @scope = new TableScope(form)\n try\n applySpan(@element, \"colspan\", props.colSpan)\n applySpan(@element, \"rowspan\", props.rowSpan)\n if props.verticalAlignment != null\n @element.style.verticalAlign = props.verticalAlignment\n if props.horizontalAlignment != null\n @element.style.textAlign = props.horizontalAlignment\n appendContent(@scope, @element, props.controls, renderer)\n decorate(@this, props)\n bindAction(@this, @element, props.url)\n catch error\n dispose()\n throw error\n\nTableCell:find(name)\n return @scope.find(name)\n\nTableCell:getValue()\n if @scope.owned.length == 0\n return null\n if @scope.owned.length == 1\n return @scope.owned[0].getValue()\n return @scope.getValue()\n\nTableCell:setValue(value)\n if @scope.owned.length == 0\n text = \"\"\n if value != null\n if is_object(value) or is_array(value)\n text = JSON/stringify(value)\n else\n text = \"${value}\"\n handle = @element.querySelector(\":scope > .lango-col-resize\")\n @element.textContent = text\n if handle != null\n @element.appendChild(handle)\n else\n if value == null\n for @scope.owned as control\n clearValue(control)\n else\n if @scope.owned.length == 1\n @scope.owned[0].setValue(value)\n else\n @scope.setValue(value)\n return @this\n\nTableCell:prepareValue()\n return @scope.prepareValue()\n\nTableCell:clearValidation()\n super.clearValidation()\n if @scope != null\n @scope.clearValidation()\n return null\n\nTableCell:dispose()\n if @scope != null\n @scope.dispose()\n return super.dispose()\n\nclearValue(control)\n if is_kindof(control, Form)\n for control.owned as child\n clearValue(child)\n else\n control.setValue(null)\n return null\n\ncellElement(heading)\n if heading\n return cloneMarkup(\"table-heading\", <th scope=\"col\"></th>)\n return cloneMarkup(\"table-cell\", <td></td>)\n\nexport class TableDivider(form, props) : Control\n\nTableDivider(form, props)\n super(form, props, cloneMarkup(\"table-divider\", <tr class=\"lango-table-divider\" aria-hidden=\"true\"><td><hr /></td></tr>))\n decorate(@this, props)\n\naddName(names, name, control)\n if name == null\n return null\n if !is_string(name) or name == \"\" or name.includes(\"/\") or name in names\n throw \"Invalid or duplicate control name: ${name}\"\n names[name] = control\n return null\n\nrowValue(value)\n if value != null and (!is_object(value) or is_array(value))\n throw \"Table row value must be a map or null\"\n return value\n\ntableIndex(index, length, insertion = false)\n limit = length - 1\n if insertion\n limit = length\n if !is_number(index) or !Number/isInteger(index) or index < 0 or index > limit\n throw \"Table index out of range: ${index}\"\n return index\n\ncolumnIndex(column, columns)\n if is_string(column)\n for columns as index: col\n if col.name == column\n return index\n throw \"Unknown table column: ${column}\"\n return tableIndex(column, columns.length)\n\nvalidateBoundaries(header, rows, columns)\n first = null\n if header != null and header.rows.length > 0\n first = header.rows[0]\n else\n if rows.length > 0\n first = rows[0]\n if first != null\n offset = 0\n for columns as col\n offset = offset + col.span\n if col.resize and first.boundary(offset) == null\n throw \"Resizable column must end at a first-row cell boundary\"\n return first\n\nallReady(pending)\n if pending.length == 0\n return null\n return Promise/all(pending)\n\nexport class TableCol(form, props) : Control\n properties\n name\n span\n resize\n methods\n attach(cell, table)\n detach()\n size(width)\n\nTableCol(form, props)\n super(form, props, cloneMarkup(\"table-col\", <col />))\n decorate(@this, props)\n @span = spanValue(props.colSpan)\n @resize = props.resize == true\n applySpan(@element, \"span\", @span)\n width = columnWidth(props.width)\n if width != null\n @element.style.width = width\n\nTableCol:size(width)\n if width < 24\n width = 24\n ruler = document/createElement(\"span\")\n ruler.textContent = \"0\"\n font = getComputedStyle(@element)\n ruler.style.font = font.font\n ruler.style.position = \"absolute\"\n ruler.style.visibility = \"hidden\"\n document/body/appendChild(ruler)\n unit = ruler.getBoundingClientRect().width\n ruler.remove()\n @element.style.width = \"${width / unit}ch\"\n @handle.setAttribute(\"aria-valuenow\", \"${width}\")\n return null\n\nTableCol:attach(cell, table)\n handle = document/createElement(\"button\")\n handle.type = \"button\"\n handle.className = \"lango-col-resize\"\n handle.setAttribute(\"role\", \"separator\")\n handle.setAttribute(\"aria-orientation\", \"vertical\")\n handle.setAttribute(\"aria-label\", \"↔\")\n handle.setAttribute(\"aria-valuemin\", \"24\")\n handle.setAttribute(\"aria-valuenow\", \"24\")\n @handle = handle\n cell.classList.add(\"lango-resizable-cell\")\n cell.appendChild(handle)\n drag = {\n active: false\n x: 0\n width: 0\n }\n down = (event)\n capture drag\n capture handle\n capture table\n if event.button != 0 or drag.active\n return null\n event.preventDefault()\n drag.active = true\n drag.x = event.clientX\n drag.width = @element.getBoundingClientRect().width / @span\n style = table.style\n style.tableLayout = \"fixed\"\n handle.setPointerCapture(event.pointerId)\n move = (event)\n capture drag\n if drag.active\n size(drag.width + (event.clientX - drag.x) / @span)\n up = (event)\n capture drag\n if drag.active\n drag.active = false\n key = (event)\n capture table\n if event.key != \"ArrowLeft\" and event.key != \"ArrowRight\"\n return null\n event.preventDefault()\n style = table.style\n style.tableLayout = \"fixed\"\n step = 10\n if event.key == \"ArrowLeft\"\n step = -10\n size(@element.getBoundingClientRect().width / @span + step)\n handle.addEventListener(\"pointerdown\", down)\n handle.addEventListener(\"pointermove\", move)\n handle.addEventListener(\"lostpointercapture\", up)\n handle.addEventListener(\"pointerup\", up)\n handle.addEventListener(\"pointercancel\", up)\n handle.addEventListener(\"keydown\", key)\n release = ()\n capture handle\n capture down\n capture move\n capture up\n capture key\n handle.removeEventListener(\"pointerdown\", down)\n handle.removeEventListener(\"pointermove\", move)\n handle.removeEventListener(\"lostpointercapture\", up)\n handle.removeEventListener(\"pointerup\", up)\n handle.removeEventListener(\"pointercancel\", up)\n handle.removeEventListener(\"keydown\", key)\n handle.remove()\n @release.add(release)\n\nTableCol:detach()\n for @release as release\n release()\n @release = []\n return null\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+VA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyFA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0FA;;;;;;;;;;AAuDA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAxoBA;;;;;;;;;;;;;AAOA;;;;;;;;;;;;;;;AAQA;;;;;;;AAqjBA;;;;;;;;;;;;;;AAQA;;;;;;;;;;AAWA;;;;;;;;;;;;;;;;AAQA;;;;;;;;;;AAKA;;;;;;;;;;;;;;;;AAQA;;;;;;;;;;;;;;;;AAQA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeA;;;;;;;;;;"}