@lango-project/lango-client 0.2.1 → 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.
- package/LICENSE +1 -0
- package/NOTICE +5 -1
- package/README.md +603 -906
- package/cli/.lango/localization.mjs +108 -0
- package/{dist/node → cli}/.lango/runtime.mjs +120 -20
- package/cli/.lango/vendor/i18next.LICENSE +21 -0
- package/cli/.lango/vendor/i18next.mjs +2434 -0
- package/cli/create.mjs +62 -0
- package/cli/create.mjs.map +1 -0
- package/dist/.lango/localization.mjs +108 -0
- package/dist/.lango/runtime.mjs +120 -20
- package/dist/.lango/vendor/i18next.LICENSE +21 -0
- package/dist/.lango/vendor/i18next.mjs +2434 -0
- package/dist/accordion.mjs +277 -0
- package/dist/accordion.mjs.map +1 -0
- package/dist/activities.mjs +185 -0
- package/dist/activities.mjs.map +1 -0
- package/dist/app.mjs +671 -0
- package/dist/app.mjs.map +1 -0
- package/dist/boot.mjs +24 -0
- package/dist/boot.mjs.map +1 -0
- package/dist/bootstrap-LICENSE +21 -0
- package/dist/bootstrap.min.css +6 -0
- package/dist/bootstrap.min.css.map +1 -0
- package/dist/button.mjs +77 -0
- package/dist/button.mjs.map +1 -0
- package/dist/chip.mjs +134 -0
- package/dist/chip.mjs.map +1 -0
- package/dist/client.css +102 -0
- package/dist/collections.mjs +77 -0
- package/dist/collections.mjs.map +1 -0
- package/dist/combo_box.mjs +408 -0
- package/dist/combo_box.mjs.map +1 -0
- package/dist/content.mjs +123 -0
- package/dist/content.mjs.map +1 -0
- package/dist/control.mjs +141 -0
- package/dist/control.mjs.map +1 -0
- package/dist/date_input.mjs +242 -0
- package/dist/date_input.mjs.map +1 -0
- package/dist/dimensions.mjs +102 -0
- package/dist/dimensions.mjs.map +1 -0
- package/dist/error_reporter.mjs +136 -0
- package/dist/error_reporter.mjs.map +1 -0
- package/dist/fields.mjs +454 -0
- package/dist/fields.mjs.map +1 -0
- package/dist/file_input.mjs +227 -0
- package/dist/file_input.mjs.map +1 -0
- package/dist/form.mjs +272 -0
- package/dist/form.mjs.map +1 -0
- package/dist/heartbeat.mjs +167 -254
- package/dist/heartbeat.mjs.map +1 -1
- package/dist/index.html +18 -0
- package/dist/indicators.mjs +127 -0
- package/dist/indicators.mjs.map +1 -0
- package/dist/input_changes.mjs +58 -0
- package/dist/input_changes.mjs.map +1 -0
- package/dist/input_group.mjs +38 -0
- package/dist/input_group.mjs.map +1 -0
- package/dist/layouts.mjs +195 -0
- package/dist/layouts.mjs.map +1 -0
- package/dist/library.mjs +130 -807
- package/dist/library.mjs.map +1 -1
- package/dist/longpoll.mjs +254 -0
- package/dist/longpoll.mjs.map +1 -0
- package/dist/main.mjs +147 -0
- package/dist/main.mjs.map +1 -0
- package/dist/markdown.mjs +61 -0
- package/dist/markdown.mjs.map +1 -0
- package/dist/menus.mjs +468 -0
- package/dist/menus.mjs.map +1 -0
- package/dist/navigation.mjs +260 -410
- package/dist/navigation.mjs.map +1 -1
- package/dist/numeric_input.mjs +181 -0
- package/dist/numeric_input.mjs.map +1 -0
- package/dist/otp_input.mjs +113 -0
- package/dist/otp_input.mjs.map +1 -0
- package/dist/presentations.mjs +852 -0
- package/dist/presentations.mjs.map +1 -0
- package/dist/renderer.mjs +295 -0
- package/dist/renderer.mjs.map +1 -0
- package/dist/rich_content.mjs +99 -0
- package/dist/rich_content.mjs.map +1 -0
- package/dist/table_scope.mjs +166 -0
- package/dist/table_scope.mjs.map +1 -0
- package/dist/tables.mjs +1052 -0
- package/dist/tables.mjs.map +1 -0
- package/dist/tabs.mjs +205 -0
- package/dist/tabs.mjs.map +1 -0
- package/dist/templates.mjs +46 -0
- package/dist/templates.mjs.map +1 -0
- package/dist/vendor/DOMPurify-LICENSE +202 -0
- package/dist/vendor/dompurify.mjs +2454 -0
- package/dist/vendor/flatpickr-LICENSE.md +21 -0
- package/dist/vendor/flatpickr.min.css +13 -0
- package/dist/vendor/flatpickr.mjs +2340 -0
- package/dist/vendor/flatpickr.mjs.map +7 -0
- package/dist/vendor/marked-LICENSE.md +44 -0
- package/dist/vendor/marked.esm.js.map +7 -0
- package/dist/vendor/marked.mjs +85 -0
- package/dist/vendor/purify.es.mjs.map +1 -0
- package/dist/widgets.mjs +197 -0
- package/dist/widgets.mjs.map +1 -0
- package/docs/implementation.md +93 -0
- package/package.json +25 -43
- package/src/accordion.lango +198 -0
- package/src/activities.lango +132 -0
- package/src/app.lango +540 -0
- package/src/boot.lango +12 -0
- package/src/button.lango +49 -0
- package/src/chip.lango +94 -0
- package/src/collections.lango +46 -0
- package/src/combo_box.lango +298 -0
- package/src/content.lango +75 -0
- package/src/control.lango +103 -0
- package/src/create.lango +42 -0
- package/src/date_input.lango +215 -0
- package/src/dimensions.lango +65 -0
- package/src/error_reporter.lango +95 -0
- package/src/fields.lango +327 -0
- package/src/file_input.lango +175 -0
- package/src/form.lango +195 -0
- package/src/heartbeat.lango +136 -199
- package/src/indicators.lango +94 -0
- package/src/input_changes.lango +33 -0
- package/src/input_group.lango +22 -0
- package/src/layouts.lango +137 -0
- package/src/library.lango +194 -599
- package/src/longpoll.lango +187 -0
- package/src/main.lango +118 -0
- package/src/markdown.lango +48 -0
- package/src/menus.lango +336 -0
- package/src/navigation.lango +209 -299
- package/src/numeric_input.lango +131 -0
- package/src/otp_input.lango +83 -0
- package/src/presentations.lango +617 -0
- package/src/renderer.lango +296 -0
- package/src/rich_content.lango +66 -0
- package/src/table_scope.lango +119 -0
- package/src/tables.lango +786 -0
- package/src/tabs.lango +144 -0
- package/src/templates.lango +29 -0
- package/src/widgets.lango +141 -0
- package/web/client.css +102 -0
- package/web/index.html +18 -0
- package/dist/application.mjs +0 -429
- package/dist/application.mjs.map +0 -1
- package/dist/coordinator.mjs +0 -91
- package/dist/coordinator.mjs.map +0 -1
- package/dist/demo.mjs +0 -110
- package/dist/demo.mjs.map +0 -1
- package/dist/demo_controls.mjs +0 -59
- package/dist/demo_controls.mjs.map +0 -1
- package/dist/errors.mjs +0 -201
- package/dist/errors.mjs.map +0 -1
- package/dist/form_state.mjs +0 -266
- package/dist/form_state.mjs.map +0 -1
- package/dist/inheritance.mjs +0 -240
- package/dist/inheritance.mjs.map +0 -1
- package/dist/input_values.mjs +0 -65
- package/dist/input_values.mjs.map +0 -1
- package/dist/node/.lango/xmldom/conventions.js +0 -429
- package/dist/node/.lango/xmldom/dom-parser.js +0 -591
- package/dist/node/.lango/xmldom/dom.js +0 -3759
- package/dist/node/.lango/xmldom/entities.js +0 -2171
- package/dist/node/.lango/xmldom/errors.js +0 -205
- package/dist/node/.lango/xmldom/grammar.js +0 -559
- package/dist/node/.lango/xmldom/index.js +0 -41
- package/dist/node/.lango/xmldom/package.json +0 -1
- package/dist/node/.lango/xmldom/sax.js +0 -983
- package/dist/node/.lango/xmldom.LICENSE.md +0 -8
- package/dist/node/browser_host.mjs +0 -351
- package/dist/node/browser_host.mjs.map +0 -1
- package/dist/node/create_app.mjs +0 -118
- package/dist/node/create_app.mjs.map +0 -1
- package/dist/presentation.mjs +0 -89
- package/dist/presentation.mjs.map +0 -1
- package/dist/protocol.mjs +0 -706
- package/dist/protocol.mjs.map +0 -1
- package/dist/session.mjs +0 -471
- package/dist/session.mjs.map +0 -1
- package/dist/tokens.mjs +0 -298
- package/dist/tokens.mjs.map +0 -1
- package/examples/contacts.lango +0 -293
- package/examples/contacts_flow.lango +0 -174
- package/examples/contacts_store.lango +0 -109
- package/examples/contacts_store_test.lango +0 -65
- package/examples/demo.css +0 -87
- package/examples/demo_test.lango +0 -356
- package/examples/index.html +0 -32
- package/examples/pages.lango +0 -174
- package/examples/server.lango +0 -189
- package/examples/worker.lango +0 -142
- package/src/application.lango +0 -327
- package/src/browser_host.lango +0 -276
- package/src/coordinator.lango +0 -57
- package/src/demo.lango +0 -110
- package/src/demo_controls.lango +0 -53
- package/src/errors.lango +0 -149
- package/src/errors_test.lango +0 -157
- package/src/form_state.lango +0 -168
- package/src/heartbeat_test.lango +0 -479
- package/src/inheritance.lango +0 -167
- package/src/input_values.lango +0 -37
- package/src/logout_test.lango +0 -564
- package/src/navigation_test.lango +0 -556
- package/src/presentation.lango +0 -55
- package/src/protocol.lango +0 -787
- package/src/renderer_test.lango +0 -2047
- package/src/session.lango +0 -343
- package/src/session_test.lango +0 -455
- package/src/tabs_test.lango +0 -216
- package/src/tokens.lango +0 -215
- package/template/.vscode/extensions.json +0 -3
- package/template/.vscode/settings.json +0 -9
- package/template/README.md +0 -44
- package/template/gitignore +0 -4
- package/template/package.json +0 -22
- package/template/public/app.css +0 -10
- package/template/public/index.html +0 -24
- package/template/src/client.lango +0 -78
- package/template/src/pages.lango +0 -55
- package/template/src/server.lango +0 -24
- package/template/src/worker.lango +0 -77
- package/template/test/app.lango +0 -9
- package/tools/browser_runner.lango +0 -32
- package/tools/browser_test.lango +0 -343
- package/tools/create_app.lango +0 -88
- package/tools/create_app_test.lango +0 -43
- package/tools/starter_test.lango +0 -227
- /package/{dist/node → cli}/.lango/bignumber.mjs +0 -0
- /package/{dist → cli}/.lango/xmldom/conventions.js +0 -0
- /package/{dist → cli}/.lango/xmldom/dom-parser.js +0 -0
- /package/{dist → cli}/.lango/xmldom/dom.js +0 -0
- /package/{dist → cli}/.lango/xmldom/entities.js +0 -0
- /package/{dist → cli}/.lango/xmldom/errors.js +0 -0
- /package/{dist → cli}/.lango/xmldom/grammar.js +0 -0
- /package/{dist → cli}/.lango/xmldom/index.js +0 -0
- /package/{dist → cli}/.lango/xmldom/package.json +0 -0
- /package/{dist → cli}/.lango/xmldom/sax.js +0 -0
- /package/{dist → cli}/.lango/xmldom.LICENSE.md +0 -0
|
@@ -0,0 +1 @@
|
|
|
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;;;;;;;;;;"}
|
package/dist/tabs.mjs
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { Control } from "./control.mjs";
|
|
2
|
+
import { cloneMarkup, controlId } from "./templates.mjs";
|
|
3
|
+
import { appendContent, decorate } from "./content.mjs";
|
|
4
|
+
import {
|
|
5
|
+
hostGlobal as __hostGlobal,
|
|
6
|
+
xmlEscape as __xmlEscape,
|
|
7
|
+
isNumber as __isNumber,
|
|
8
|
+
isString as __isString,
|
|
9
|
+
isBool as __isBool,
|
|
10
|
+
isObject as __isObject,
|
|
11
|
+
isArray as __isArray,
|
|
12
|
+
add as __add,
|
|
13
|
+
requireBoolean as __requireBoolean,
|
|
14
|
+
normalize as __normalize,
|
|
15
|
+
finite as __finite,
|
|
16
|
+
numericAdd as __numericAdd,
|
|
17
|
+
boundary as __boundary,
|
|
18
|
+
requireArity as __requireArity,
|
|
19
|
+
withArity as __withArity,
|
|
20
|
+
} from "./.lango/runtime.mjs";
|
|
21
|
+
|
|
22
|
+
export class Tab extends Control {
|
|
23
|
+
#items;
|
|
24
|
+
#vertical;
|
|
25
|
+
#nav;
|
|
26
|
+
#panels;
|
|
27
|
+
constructor(form, props, renderer) {
|
|
28
|
+
super(form, props, cloneMarkup("tab", ["<div class=\"lango-tab\"><div role=\"tablist\"></div><div class=\"tab-content\"></div></div>"].join("")));
|
|
29
|
+
__requireArity(arguments.length, [0, 1, 2], "constructor");
|
|
30
|
+
form = __boundary(form);
|
|
31
|
+
props = __boundary(props);
|
|
32
|
+
renderer = __boundary(renderer);
|
|
33
|
+
this.#items = [];
|
|
34
|
+
this.#vertical = __normalize(props.vertical) === true;
|
|
35
|
+
this.#nav = __normalize(this.element.firstElementChild);
|
|
36
|
+
this.#panels = __normalize(this.element.lastElementChild);
|
|
37
|
+
let variant = __normalize(props.variant);
|
|
38
|
+
if (__requireBoolean(variant === null)) {
|
|
39
|
+
variant = "default";
|
|
40
|
+
}
|
|
41
|
+
if (variant === "default") {
|
|
42
|
+
this.#nav.className = "nav nav-tabs";
|
|
43
|
+
} else if (variant === "pills") {
|
|
44
|
+
this.#nav.className = "nav nav-pills";
|
|
45
|
+
} else if (variant === "listGroup") {
|
|
46
|
+
this.#nav.className = "list-group";
|
|
47
|
+
} else {
|
|
48
|
+
throw `Unknown Tab variant: ${variant}`;
|
|
49
|
+
}
|
|
50
|
+
if (__requireBoolean(__normalize(this.#vertical))) {
|
|
51
|
+
__add(this.element.classList, "lango-tab-vertical");
|
|
52
|
+
__add(this.#nav.classList, "flex-column");
|
|
53
|
+
__normalize(this.#nav.setAttribute("aria-orientation", "vertical"));
|
|
54
|
+
}
|
|
55
|
+
if (__requireBoolean(__requireBoolean(__normalize(props.aria) !== null) && __requireBoolean(props.aria.label !== null))) {
|
|
56
|
+
__normalize(this.#nav.setAttribute("aria-label", props.aria.label));
|
|
57
|
+
}
|
|
58
|
+
if (__requireBoolean(__normalize(props.items) !== null)) {
|
|
59
|
+
for (const definition of __normalize(props.items)) {
|
|
60
|
+
if (__requireBoolean(__requireBoolean(!__requireBoolean(__isObject(definition))) || __requireBoolean(__normalize(definition.type) !== "tabItem"))) {
|
|
61
|
+
throw "Tab accepts TabItem definitions";
|
|
62
|
+
}
|
|
63
|
+
let item = new TabItem(form, definition, renderer, this, variant);
|
|
64
|
+
__normalize(form.register(__normalize(definition.name), item));
|
|
65
|
+
this.#items.push(item);
|
|
66
|
+
__normalize(this.#nav.appendChild(__normalize(item.button)));
|
|
67
|
+
__normalize(this.#panels.appendChild(__normalize(item.element)));
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
let initial = null;
|
|
71
|
+
if (__requireBoolean(__normalize(this.#items.length) > 0)) {
|
|
72
|
+
initial = __normalize(this.#items[0]);
|
|
73
|
+
}
|
|
74
|
+
if (__requireBoolean(__normalize(props.active) !== null)) {
|
|
75
|
+
initial = null;
|
|
76
|
+
for (const candidate of __normalize(this.#items)) {
|
|
77
|
+
if (__requireBoolean(__normalize(candidate.name) === __normalize(props.active))) {
|
|
78
|
+
initial = candidate;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
if (__requireBoolean(initial === null)) {
|
|
82
|
+
throw `Unknown active TabItem: ${__normalize(props.active)}`;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (__requireBoolean(initial !== null)) {
|
|
86
|
+
this.select(initial);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
select(item, focus = false) {
|
|
90
|
+
__requireArity(arguments.length, [0], "select");
|
|
91
|
+
item = __boundary(item);
|
|
92
|
+
focus = __boundary(focus);
|
|
93
|
+
for (const candidate of __normalize(this.#items)) {
|
|
94
|
+
let active = candidate === item;
|
|
95
|
+
candidate.element.hidden = !__requireBoolean(active);
|
|
96
|
+
__normalize(candidate.element.classList.toggle("active", active));
|
|
97
|
+
__normalize(candidate.button.classList.toggle("active", active));
|
|
98
|
+
__normalize(candidate.button.setAttribute("aria-selected", `${active}`));
|
|
99
|
+
candidate.button.tabIndex = __finite(-1);
|
|
100
|
+
if (__requireBoolean(active)) {
|
|
101
|
+
candidate.button.tabIndex = 0;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (__requireBoolean(focus)) {
|
|
105
|
+
__normalize(item.button.focus());
|
|
106
|
+
}
|
|
107
|
+
return this;
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
move(item, key) {
|
|
111
|
+
__requireArity(arguments.length, [0, 1], "move");
|
|
112
|
+
item = __boundary(item);
|
|
113
|
+
key = __boundary(key);
|
|
114
|
+
let index = __normalize(this.#items.indexOf(item));
|
|
115
|
+
let next = index;
|
|
116
|
+
if (__requireBoolean(key === "Home")) {
|
|
117
|
+
next = 0;
|
|
118
|
+
} else {
|
|
119
|
+
if (__requireBoolean(key === "End")) {
|
|
120
|
+
next = __finite(__normalize(this.#items.length) - 1);
|
|
121
|
+
} else {
|
|
122
|
+
let forward = "ArrowRight";
|
|
123
|
+
let backward = "ArrowLeft";
|
|
124
|
+
if (__requireBoolean(__normalize(this.#vertical))) {
|
|
125
|
+
forward = "ArrowDown";
|
|
126
|
+
backward = "ArrowUp";
|
|
127
|
+
}
|
|
128
|
+
if (__requireBoolean(key === forward)) {
|
|
129
|
+
next = __finite(__numericAdd(index, 1) % __normalize(this.#items.length));
|
|
130
|
+
} else {
|
|
131
|
+
if (__requireBoolean(key !== backward)) {
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
next = __finite(__finite(__numericAdd(index, __normalize(this.#items.length)) - 1) % __normalize(this.#items.length));
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
this.select(__normalize(this.#items[next]), true);
|
|
139
|
+
return true;
|
|
140
|
+
return null;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export class TabItem extends Control {
|
|
145
|
+
button;
|
|
146
|
+
name;
|
|
147
|
+
#owner;
|
|
148
|
+
constructor(form, props, renderer, owner, variant) {
|
|
149
|
+
super(form, props, cloneMarkup("tab-panel", ["<div class=\"tab-pane\" role=\"tabpanel\" tabindex=\"0\" hidden=\"hidden\"></div>"].join("")));
|
|
150
|
+
__requireArity(arguments.length, [0, 1, 2, 3, 4], "constructor");
|
|
151
|
+
form = __boundary(form);
|
|
152
|
+
props = __boundary(props);
|
|
153
|
+
renderer = __boundary(renderer);
|
|
154
|
+
owner = __boundary(owner);
|
|
155
|
+
variant = __boundary(variant);
|
|
156
|
+
this.#owner = owner;
|
|
157
|
+
this.name = __normalize(props.name);
|
|
158
|
+
this.button = __normalize(__hostGlobal(["document"]).createElement("button"));
|
|
159
|
+
this.button.type = "button";
|
|
160
|
+
this.button.className = "nav-link";
|
|
161
|
+
if (__requireBoolean(variant === "listGroup")) {
|
|
162
|
+
this.button.className = "list-group-item list-group-item-action";
|
|
163
|
+
}
|
|
164
|
+
__normalize(this.button.setAttribute("role", "tab"));
|
|
165
|
+
this.button.id = controlId();
|
|
166
|
+
this.element.id = controlId();
|
|
167
|
+
__normalize(this.button.setAttribute("aria-controls", __normalize(this.element.id)));
|
|
168
|
+
__normalize(this.element.setAttribute("aria-labelledby", __normalize(this.button.id)));
|
|
169
|
+
this.button.textContent = __normalize(props.label);
|
|
170
|
+
decorate(this, props);
|
|
171
|
+
appendContent(form, __normalize(this.element), __normalize(props.content), renderer);
|
|
172
|
+
let click = () => {
|
|
173
|
+
this.activate();
|
|
174
|
+
return null;
|
|
175
|
+
};
|
|
176
|
+
let key = __withArity((event) => {
|
|
177
|
+
event = __boundary(event);
|
|
178
|
+
if (__requireBoolean(__normalize(this.#owner.move(this, __normalize(event.key))))) {
|
|
179
|
+
__normalize(event.preventDefault());
|
|
180
|
+
}
|
|
181
|
+
return null;
|
|
182
|
+
}, [0], "closure");
|
|
183
|
+
__normalize(this.button.addEventListener("click", click));
|
|
184
|
+
__normalize(this.button.addEventListener("keydown", key));
|
|
185
|
+
let release = () => {
|
|
186
|
+
__normalize(this.button.removeEventListener("click", click));
|
|
187
|
+
__normalize(this.button.removeEventListener("keydown", key));
|
|
188
|
+
return null;
|
|
189
|
+
};
|
|
190
|
+
__add(this.release, release);
|
|
191
|
+
}
|
|
192
|
+
activate() {
|
|
193
|
+
__normalize(this.#owner.select(this));
|
|
194
|
+
return this;
|
|
195
|
+
return null;
|
|
196
|
+
}
|
|
197
|
+
setCaption(value) {
|
|
198
|
+
__requireArity(arguments.length, [0], "setCaption");
|
|
199
|
+
value = __boundary(value);
|
|
200
|
+
this.button.textContent = value;
|
|
201
|
+
return this;
|
|
202
|
+
return null;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
//# sourceMappingURL=tabs.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tabs.mjs","sources":["tabs.lango"],"sourcesContent":["import js global document\nimport \"./control\"\n class Control\nimport \"./templates\"\n cloneMarkup(name, xml)\n controlId()\nimport \"./content\"\n appendContent(form, element, content, renderer)\n decorate(control, props)\n\nexport class Tab(form, props, renderer) : Control\n methods\n select(item, focus = false)\n move(item, key)\n\nTab(form, props, renderer)\n super(form, props, cloneMarkup(\"tab\", <div class=\"lango-tab\"><div role=\"tablist\"></div><div class=\"tab-content\"></div></div>))\n @items = []\n @vertical = props.vertical == true\n @nav = @element.firstElementChild\n @panels = @element.lastElementChild\n variant = props.variant\n if variant == null\n variant = \"default\"\n switch variant\n case \"default\"\n @nav.className = \"nav nav-tabs\"\n case \"pills\"\n @nav.className = \"nav nav-pills\"\n case \"listGroup\"\n @nav.className = \"list-group\"\n else\n throw \"Unknown Tab variant: ${variant}\"\n if @vertical\n @element.classList.add(\"lango-tab-vertical\")\n @nav.classList.add(\"flex-column\")\n @nav.setAttribute(\"aria-orientation\", \"vertical\")\n if props.aria != null and props.aria.label != null\n @nav.setAttribute(\"aria-label\", props.aria.label)\n if props.items != null\n for props.items as definition\n if !is_object(definition) or definition.type != \"tabItem\"\n throw \"Tab accepts TabItem definitions\"\n item = new TabItem(form, definition, renderer, @this, variant)\n form.register(definition.name, item)\n @items.add(item)\n @nav.appendChild(item.button)\n @panels.appendChild(item.element)\n initial = null\n if @items.length > 0\n initial = @items[0]\n if props.active != null\n initial = null\n for @items as candidate\n if candidate.name == props.active\n initial = candidate\n if initial == null\n throw \"Unknown active TabItem: ${props.active}\"\n if initial != null\n select(initial)\n\nTab:select(item, focus = false)\n for @items as candidate\n active = candidate == item\n candidate.element.hidden = !active\n candidate.element.classList.toggle(\"active\", active)\n candidate.button.classList.toggle(\"active\", active)\n candidate.button.setAttribute(\"aria-selected\", \"${active}\")\n candidate.button.tabIndex = -1\n if active\n candidate.button.tabIndex = 0\n if focus\n item.button.focus()\n return @this\n\nTab:move(item, key)\n index = @items.indexOf(item)\n next = index\n if key == \"Home\"\n next = 0\n else\n if key == \"End\"\n next = @items.length - 1\n else\n forward = \"ArrowRight\"\n backward = \"ArrowLeft\"\n if @vertical\n forward = \"ArrowDown\"\n backward = \"ArrowUp\"\n if key == forward\n next = (index + 1) % @items.length\n else\n if key != backward\n return false\n next = (index + @items.length - 1) % @items.length\n select(@items[next], true)\n return true\n\nexport class TabItem(form, props, renderer, owner, variant) : Control\n properties\n button\n name\n methods\n activate()\n setCaption(value)\n\nTabItem(form, props, renderer, owner, variant)\n super(form, props, cloneMarkup(\"tab-panel\", <div class=\"tab-pane\" role=\"tabpanel\" tabindex=\"0\" hidden=\"hidden\"></div>))\n @owner = owner\n @name = props.name\n @button = document/createElement(\"button\")\n @button.type = \"button\"\n @button.className = \"nav-link\"\n if variant == \"listGroup\"\n @button.className = \"list-group-item list-group-item-action\"\n @button.setAttribute(\"role\", \"tab\")\n @button.id = controlId()\n @element.id = controlId()\n @button.setAttribute(\"aria-controls\", @element.id)\n @element.setAttribute(\"aria-labelledby\", @button.id)\n @button.textContent = props.label\n decorate(@this, props)\n appendContent(form, @element, props.content, renderer)\n click = ()\n activate()\n key = (event)\n if @owner.move(@this, event.key)\n event.preventDefault()\n @button.addEventListener(\"click\", click)\n @button.addEventListener(\"keydown\", key)\n release = ()\n capture click\n capture key\n @button.removeEventListener(\"click\", click)\n @button.removeEventListener(\"keydown\", key)\n @release.add(release)\n\nTabItem:activate()\n @owner.select(@this)\n return @this\n\nTabItem:setCaption(value)\n @button.textContent = value\n return @this\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAUA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwFA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import {
|
|
2
|
+
hostGlobal as __hostGlobal,
|
|
3
|
+
includes as __includes,
|
|
4
|
+
requireBoolean as __requireBoolean,
|
|
5
|
+
normalize as __normalize,
|
|
6
|
+
numericAdd as __numericAdd,
|
|
7
|
+
boundary as __boundary,
|
|
8
|
+
requireArity as __requireArity,
|
|
9
|
+
} from "./.lango/runtime.mjs";
|
|
10
|
+
|
|
11
|
+
let templates = __normalize(__hostGlobal(["Object"]).create(null));
|
|
12
|
+
|
|
13
|
+
let sequence = 0;
|
|
14
|
+
export function createTemplate(xml) {
|
|
15
|
+
__requireArity(arguments.length, [0], "createTemplate");
|
|
16
|
+
xml = __boundary(xml);
|
|
17
|
+
let template = __normalize(__hostGlobal(["document"]).createElement("template"));
|
|
18
|
+
template.innerHTML = `${xml}`;
|
|
19
|
+
return template;
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function cloneTemplate(template) {
|
|
24
|
+
__requireArity(arguments.length, [0], "cloneTemplate");
|
|
25
|
+
template = __boundary(template);
|
|
26
|
+
return __normalize(template.content.firstElementChild.cloneNode(true));
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function cloneMarkup(name, xml) {
|
|
31
|
+
__requireArity(arguments.length, [0, 1], "cloneMarkup");
|
|
32
|
+
name = __boundary(name);
|
|
33
|
+
xml = __boundary(xml);
|
|
34
|
+
if (__requireBoolean(!__requireBoolean(__includes(name, templates)))) {
|
|
35
|
+
templates[name] = createTemplate(xml);
|
|
36
|
+
}
|
|
37
|
+
return cloneTemplate(__normalize(templates[name]));
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function controlId() {
|
|
42
|
+
sequence = __numericAdd(sequence, 1);
|
|
43
|
+
return `lango-control-${sequence}`;
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=templates.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templates.mjs","sources":["templates.lango"],"sourcesContent":["import js global document\nimport js global Object\n\nexport createTemplate(xml)\nexport cloneTemplate(template)\nexport cloneMarkup(name, xml)\nexport controlId()\n\nglobal templates = Object/create(null)\nglobal sequence = 0\n\ncreateTemplate(xml)\n template = document/createElement(\"template\")\n template.innerHTML = \"${xml}\"\n return template\n\ncloneTemplate(template)\n return template.content.firstElementChild.cloneNode(true)\n\ncloneMarkup(name, xml)\n global templates\n if !(name in templates)\n templates[name] = createTemplate(xml)\n return cloneTemplate(templates[name])\n\ncontrolId()\n global sequence\n sequence = sequence + 1\n return \"lango-control-${sequence}\"\n"],"names":[],"mappings":";;;;;;;;;;AAQA;;AACA;AAEA;;;;;;;;;AAKA;;;;;;;AAGA;;;;;;;;;;;AAMA;;;;;;"}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|