@livenetworks/ashlar 1.6.0 → 2.0.0
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 +641 -0
- package/README.md +202 -86
- package/{js → components}/COMPONENTS.md +1116 -1108
- package/{js → components}/index.js +81 -58
- package/{js → components}/ln-accordion/README.md +7 -6
- package/components/ln-accordion/ln-accordion-dev.scss +8 -0
- package/components/ln-accordion/ln-accordion.js +1 -0
- package/components/ln-accordion/ln-accordion.schema.json +30 -0
- package/components/ln-accordion/ln-accordion.scss +8 -0
- package/{js → components}/ln-accordion/src/ln-accordion.js +8 -2
- package/{js → components}/ln-ajax/README.md +171 -160
- package/components/ln-ajax/ln-ajax-dev.scss +8 -0
- package/components/ln-ajax/ln-ajax.js +1 -0
- package/components/ln-ajax/ln-ajax.schema.json +30 -0
- package/{js → components}/ln-ajax/src/ln-ajax.js +65 -30
- package/{js → components}/ln-api-connector/README.md +27 -5
- package/components/ln-api-connector/ln-api-connector.js +1 -0
- package/components/ln-api-connector/ln-api-connector.schema.json +96 -0
- package/components/ln-api-connector/src/connector-core.js +97 -0
- package/components/ln-api-connector/src/ln-api-connector.js +447 -0
- package/{js → components}/ln-api-queue/README.md +12 -9
- package/components/ln-api-queue/ln-api-queue.js +1 -0
- package/components/ln-api-queue/ln-api-queue.schema.json +34 -0
- package/{js → components}/ln-api-queue/src/ln-api-queue.js +33 -14
- package/{js → components}/ln-api-queue/src/queue-storage.js +7 -3
- package/{js → components}/ln-autoresize/README.md +129 -127
- package/components/ln-autoresize/ln-autoresize-dev.scss +8 -0
- package/components/ln-autoresize/ln-autoresize.js +1 -0
- package/components/ln-autoresize/ln-autoresize.schema.json +22 -0
- package/{js → components}/ln-autoresize/src/ln-autoresize.js +8 -1
- package/{js → components}/ln-autosave/README.md +127 -124
- package/components/ln-autosave/ln-autosave-dev.scss +13 -0
- package/components/ln-autosave/ln-autosave.js +1 -0
- package/components/ln-autosave/ln-autosave.schema.json +48 -0
- package/components/ln-autosave/src/autosave-model.js +34 -0
- package/{js → components}/ln-autosave/src/ln-autosave.js +65 -58
- package/components/ln-chart/README.md +145 -0
- package/components/ln-chart/ln-chart-dev.scss +20 -0
- package/components/ln-chart/ln-chart.js +1 -0
- package/components/ln-chart/ln-chart.schema.json +146 -0
- package/components/ln-chart/ln-chart.scss +8 -0
- package/components/ln-chart/src/chart-model.js +154 -0
- package/components/ln-chart/src/ln-chart.js +176 -0
- package/{js → components}/ln-circular-progress/README.md +15 -14
- package/components/ln-circular-progress/ln-circular-progress-dev.scss +8 -0
- package/components/ln-circular-progress/ln-circular-progress.js +1 -0
- package/components/ln-circular-progress/ln-circular-progress.schema.json +42 -0
- package/{js → components}/ln-circular-progress/src/ln-circular-progress.js +32 -50
- package/components/ln-confirm/README.md +216 -0
- package/components/ln-confirm/ln-confirm-dev.scss +24 -0
- package/components/ln-confirm/ln-confirm.js +1 -0
- package/components/ln-confirm/ln-confirm.schema.json +66 -0
- package/components/ln-confirm/ln-confirm.scss +24 -0
- package/{js → components}/ln-confirm/src/ln-confirm.js +180 -167
- package/{js → components}/ln-core/README.md +374 -149
- package/components/ln-core/attrs.js +273 -0
- package/components/ln-core/compare.js +40 -0
- package/components/ln-core/crypto.js +265 -0
- package/components/ln-core/date.js +50 -0
- package/components/ln-core/dom.js +115 -0
- package/components/ln-core/events.js +122 -0
- package/components/ln-core/form.js +136 -0
- package/{js → components}/ln-core/hash.js +149 -92
- package/components/ln-core/helpers.js +33 -0
- package/components/ln-core/http.js +48 -0
- package/components/ln-core/index.js +11 -0
- package/components/ln-core/lifecycle.js +403 -0
- package/components/ln-core/ln-core.schema.json +109 -0
- package/components/ln-core/locale.js +55 -0
- package/components/ln-core/matching.js +78 -0
- package/components/ln-core/number.js +125 -0
- package/components/ln-core/progress.js +30 -0
- package/components/ln-core/template.js +206 -0
- package/{js → components}/ln-core/window-cache.js +247 -213
- package/{js → components}/ln-couchdb-connector/README.md +7 -5
- package/components/ln-couchdb-connector/ln-couchdb-connector.js +1 -0
- package/components/ln-couchdb-connector/ln-couchdb-connector.schema.json +50 -0
- package/{js → components}/ln-couchdb-connector/src/ln-couchdb-connector.js +29 -43
- package/{js → components}/ln-data-coordinator/README.md +109 -73
- package/components/ln-data-coordinator/ln-data-coordinator-dev.scss +8 -0
- package/components/ln-data-coordinator/ln-data-coordinator.js +1 -0
- package/components/ln-data-coordinator/ln-data-coordinator.schema.json +196 -0
- package/components/ln-data-coordinator/src/data-read-policy.js +41 -0
- package/{js → components}/ln-data-coordinator/src/ln-data-coordinator.js +411 -154
- package/{js → components}/ln-data-coordinator/src/mutation-receipts.js +0 -5
- package/{js → components}/ln-data-store/README.md +42 -17
- package/components/ln-data-store/ln-data-store-dev.scss +13 -0
- package/components/ln-data-store/ln-data-store.js +1 -0
- package/components/ln-data-store/ln-data-store.schema.json +84 -0
- package/components/ln-data-store/src/data-store-model.js +155 -0
- package/{js → components}/ln-data-store/src/ln-data-store.js +407 -105
- package/components/ln-data-store/src/window-index.js +119 -0
- package/{js → components}/ln-date/README.md +17 -7
- package/{js → components}/ln-date/ln-date-dev.scss +14 -14
- package/components/ln-date/ln-date.js +1 -0
- package/components/ln-date/ln-date.schema.json +92 -0
- package/components/ln-date/src/date-model.js +186 -0
- package/components/ln-date/src/ln-date.js +486 -0
- package/components/ln-debug/README.md +132 -0
- package/components/ln-debug/ln-debug.js +1 -0
- package/components/ln-debug/ln-debug.schema.json +28 -0
- package/components/ln-debug/src/console-sink.js +19 -0
- package/components/ln-debug/src/debug-verifier.js +331 -0
- package/components/ln-debug/src/gate.js +95 -0
- package/components/ln-debug/src/generated-attributes.js +299 -0
- package/components/ln-debug/src/ln-debug.js +60 -0
- package/{js → components}/ln-dropdown/README.md +150 -140
- package/components/ln-dropdown/ln-dropdown-dev.scss +13 -0
- package/components/ln-dropdown/ln-dropdown.js +1 -0
- package/components/ln-dropdown/ln-dropdown.schema.json +90 -0
- package/components/ln-dropdown/ln-dropdown.scss +18 -0
- package/{js → components}/ln-dropdown/src/ln-dropdown.js +114 -11
- package/{js → components}/ln-editor/README.md +11 -9
- package/components/ln-editor/ln-editor-dev.scss +18 -0
- package/components/ln-editor/ln-editor.js +1 -0
- package/components/ln-editor/ln-editor.schema.json +58 -0
- package/components/ln-editor/ln-editor.scss +13 -0
- package/{js → components}/ln-editor/src/ln-editor.js +59 -11
- package/{js → components}/ln-external-links/README.md +10 -8
- package/components/ln-external-links/ln-external-links.js +1 -0
- package/components/ln-external-links/ln-external-links.schema.json +18 -0
- package/{js → components}/ln-external-links/src/ln-external-links.js +13 -11
- package/{js → components}/ln-fill/README.md +6 -8
- package/components/ln-fill/ln-fill.js +1 -0
- package/components/ln-fill/ln-fill.schema.json +23 -0
- package/{js → components}/ln-fill/src/ln-fill.js +7 -1
- package/components/ln-filter/README.md +131 -0
- package/components/ln-filter/ln-filter-dev.scss +13 -0
- package/components/ln-filter/ln-filter.js +1 -0
- package/components/ln-filter/ln-filter.schema.json +153 -0
- package/components/ln-filter/src/filter-model.js +185 -0
- package/components/ln-filter/src/ln-filter.js +435 -0
- package/{js → components}/ln-form/README.md +260 -264
- package/components/ln-form/ln-form-dev.scss +8 -0
- package/components/ln-form/ln-form.js +1 -0
- package/components/ln-form/ln-form.schema.json +45 -0
- package/{js → components}/ln-form/src/ln-form.js +107 -99
- package/{js → components}/ln-http/README.md +11 -6
- package/components/ln-http/ln-http.js +1 -0
- package/components/ln-http/ln-http.schema.json +6 -0
- package/components/ln-http/src/http-core.js +51 -0
- package/{js → components}/ln-http/src/ln-http.js +28 -33
- package/{js → components}/ln-icon/README.md +16 -9
- package/components/ln-icon/ln-icon.schema.json +6 -0
- package/components/ln-include/README.md +75 -0
- package/components/ln-include/ln-include-dev.scss +13 -0
- package/components/ln-include/ln-include.js +1 -0
- package/components/ln-include/ln-include.schema.json +23 -0
- package/components/ln-include/src/ln-include.js +111 -0
- package/components/ln-key/README.md +130 -0
- package/components/ln-key/ln-key-dev.scss +18 -0
- package/components/ln-key/ln-key.js +1 -0
- package/components/ln-key/ln-key.schema.json +56 -0
- package/components/ln-key/src/key-model.js +146 -0
- package/components/ln-key/src/ln-key.js +201 -0
- package/{js → components}/ln-link/README.md +7 -9
- package/components/ln-link/ln-link-dev.scss +8 -0
- package/components/ln-link/ln-link.js +1 -0
- package/components/ln-link/ln-link.schema.json +22 -0
- package/{js → components}/ln-link/src/ln-link.js +16 -11
- package/components/ln-list/README.md +152 -0
- package/components/ln-list/ln-list-dev.scss +8 -0
- package/components/ln-list/ln-list.js +1 -0
- package/components/ln-list/ln-list.schema.json +166 -0
- package/components/ln-list/ln-list.scss +25 -0
- package/{js → components}/ln-list/src/ln-list.js +1301 -1216
- package/{js → components}/ln-modal/README.md +13 -10
- package/components/ln-modal/ln-modal-dev.scss +18 -0
- package/components/ln-modal/ln-modal.js +1 -0
- package/components/ln-modal/ln-modal.schema.json +54 -0
- package/components/ln-modal/ln-modal.scss +51 -0
- package/{js → components}/ln-modal/src/ln-modal.js +164 -137
- package/{js → components}/ln-nav/README.md +11 -11
- package/components/ln-nav/ln-nav.js +1 -0
- package/components/ln-nav/ln-nav.schema.json +25 -0
- package/{js → components}/ln-nav/src/ln-nav.js +25 -14
- package/components/ln-number/README.md +205 -0
- package/{js → components}/ln-number/ln-number-dev.scss +13 -13
- package/components/ln-number/ln-number.js +1 -0
- package/components/ln-number/ln-number.schema.json +63 -0
- package/components/ln-number/src/ln-number.js +400 -0
- package/components/ln-number/src/number-model.js +31 -0
- package/components/ln-obfuscator/README.md +60 -0
- package/components/ln-obfuscator/ln-obfuscator.js +1 -0
- package/components/ln-obfuscator/ln-obfuscator.schema.json +49 -0
- package/components/ln-obfuscator/src/ln-obfuscator.js +159 -0
- package/components/ln-obfuscator/src/obfuscator-model.js +250 -0
- package/{js → components}/ln-options/README.md +3 -1
- package/components/ln-options/ln-options-dev.scss +13 -0
- package/components/ln-options/ln-options.js +1 -0
- package/components/ln-options/ln-options.schema.json +41 -0
- package/{js → components}/ln-options/src/ln-options.js +13 -5
- package/components/ln-persist/README.md +151 -0
- package/components/ln-persist/ln-persist.js +1 -0
- package/components/ln-persist/ln-persist.schema.json +28 -0
- package/components/ln-persist/src/ln-persist.js +83 -0
- package/components/ln-picklist/README.md +230 -0
- package/components/ln-picklist/ln-picklist-dev.scss +22 -0
- package/components/ln-picklist/ln-picklist.js +1 -0
- package/components/ln-picklist/ln-picklist.schema.json +49 -0
- package/components/ln-picklist/src/ln-picklist.js +228 -0
- package/{js → components}/ln-popover/README.md +164 -162
- package/components/ln-popover/ln-popover-dev.scss +13 -0
- package/components/ln-popover/ln-popover.js +1 -0
- package/components/ln-popover/ln-popover.schema.json +82 -0
- package/components/ln-popover/ln-popover.scss +18 -0
- package/{js → components}/ln-popover/src/ln-popover.js +42 -36
- package/{js → components}/ln-progress/README.md +410 -413
- package/components/ln-progress/ln-progress-dev.scss +8 -0
- package/components/ln-progress/ln-progress.js +1 -0
- package/components/ln-progress/ln-progress.schema.json +40 -0
- package/components/ln-progress/src/ln-progress.js +91 -0
- package/components/ln-progress/src/progress-model.js +20 -0
- package/{js → components}/ln-router/README.md +443 -432
- package/components/ln-router/ln-router-dev.scss +13 -0
- package/components/ln-router/ln-router.js +1 -0
- package/components/ln-router/ln-router.schema.json +68 -0
- package/{js → components}/ln-router/src/ln-router.js +585 -539
- package/components/ln-router/src/router-model.js +50 -0
- package/components/ln-scroll/README.md +45 -0
- package/components/ln-scroll/ln-scroll.js +1 -0
- package/components/ln-scroll/ln-scroll.schema.json +85 -0
- package/components/ln-scroll/src/ln-scroll.js +150 -0
- package/components/ln-search/README.md +188 -0
- package/components/ln-search/ln-search-dev.scss +13 -0
- package/components/ln-search/ln-search.js +1 -0
- package/components/ln-search/ln-search.schema.json +103 -0
- package/components/ln-search/src/ln-search.js +330 -0
- package/{js → components}/ln-slug/README.md +6 -3
- package/components/ln-slug/ln-slug-dev.scss +18 -0
- package/components/ln-slug/ln-slug.js +1 -0
- package/components/ln-slug/ln-slug.schema.json +23 -0
- package/{js → components}/ln-slug/src/ln-slug.js +20 -13
- package/components/ln-slug/src/slug-model.js +21 -0
- package/{js → components}/ln-sort/README.md +178 -170
- package/{js → components}/ln-sort/ln-sort-dev.scss +8 -8
- package/components/ln-sort/ln-sort.js +1 -0
- package/components/ln-sort/ln-sort.schema.json +104 -0
- package/components/ln-sort/src/ln-sort.js +321 -0
- package/components/ln-sort/src/sort-model.js +117 -0
- package/{js → components}/ln-sortable/README.md +7 -11
- package/components/ln-sortable/ln-sortable-dev.scss +13 -0
- package/components/ln-sortable/ln-sortable.js +1 -0
- package/components/ln-sortable/ln-sortable.schema.json +36 -0
- package/{js → components}/ln-sortable/src/ln-sortable.js +8 -13
- package/{js → components}/ln-stat/README.md +3 -1
- package/components/ln-stat/ln-stat-dev.scss +8 -0
- package/components/ln-stat/ln-stat.js +1 -0
- package/components/ln-stat/ln-stat.schema.json +32 -0
- package/{js → components}/ln-stat/src/ln-stat.js +14 -18
- package/components/ln-stat/src/stat-model.js +28 -0
- package/{js → components}/ln-table/README.md +37 -24
- package/{js → components}/ln-table/ln-table-dev.scss +17 -17
- package/components/ln-table/ln-table.js +1 -0
- package/components/ln-table/ln-table.schema.json +211 -0
- package/components/ln-table/ln-table.scss +15 -0
- package/{js → components}/ln-table/src/ln-table.js +1365 -1493
- package/components/ln-table/src/table-model.js +98 -0
- package/components/ln-table-coordinator/README.md +61 -0
- package/components/ln-table-coordinator/ln-table-coordinator.js +1 -0
- package/components/ln-table-coordinator/ln-table-coordinator.schema.json +93 -0
- package/components/ln-table-coordinator/src/ln-table-coordinator.js +193 -0
- package/{js → components}/ln-tabs/README.md +32 -14
- package/components/ln-tabs/ln-tabs-dev.scss +24 -0
- package/components/ln-tabs/ln-tabs.js +1 -0
- package/components/ln-tabs/ln-tabs.schema.json +75 -0
- package/components/ln-tabs/ln-tabs.scss +8 -0
- package/components/ln-tabs/src/ln-tabs.js +207 -0
- package/components/ln-tabs/src/tabs-model.js +82 -0
- package/{js → components}/ln-time/README.md +96 -95
- package/components/ln-time/ln-time-dev.scss +13 -0
- package/components/ln-time/ln-time.js +1 -0
- package/components/ln-time/ln-time.schema.json +38 -0
- package/{js → components}/ln-time/src/ln-time.js +206 -223
- package/components/ln-time/src/time-model.js +64 -0
- package/{js → components}/ln-toast/README.md +23 -5
- package/components/ln-toast/ln-toast-dev.scss +8 -0
- package/components/ln-toast/ln-toast.js +1 -0
- package/components/ln-toast/ln-toast.schema.json +65 -0
- package/components/ln-toast/ln-toast.scss +59 -0
- package/{js → components}/ln-toast/src/ln-toast.js +233 -232
- package/{js → components}/ln-toggle/README.md +198 -196
- package/{js → components}/ln-toggle/ln-toggle-dev.scss +13 -13
- package/components/ln-toggle/ln-toggle.js +1 -0
- package/components/ln-toggle/ln-toggle.schema.json +52 -0
- package/components/ln-toggle/ln-toggle.scss +37 -0
- package/{js → components}/ln-toggle/src/ln-toggle.js +61 -46
- package/{js → components}/ln-tooltip/README.md +6 -6
- package/{js → components}/ln-tooltip/ln-tooltip-dev.scss +9 -9
- package/components/ln-tooltip/ln-tooltip.js +1 -0
- package/components/ln-tooltip/ln-tooltip.schema.json +86 -0
- package/components/ln-tooltip/ln-tooltip.scss +9 -0
- package/{js → components}/ln-tooltip/src/ln-tooltip.js +14 -3
- package/{js → components}/ln-translations/README.md +3 -1
- package/components/ln-translations/ln-translations-dev.scss +13 -0
- package/components/ln-translations/ln-translations.js +1 -0
- package/components/ln-translations/ln-translations.schema.json +120 -0
- package/{js → components}/ln-translations/src/ln-translations.js +25 -10
- package/components/ln-ui-coordinator/README.md +101 -0
- package/components/ln-ui-coordinator/ln-ui-coordinator-dev.scss +8 -0
- package/components/ln-ui-coordinator/ln-ui-coordinator.js +1 -0
- package/components/ln-ui-coordinator/ln-ui-coordinator.schema.json +60 -0
- package/{js/ln-modal-coordinator/src/ln-modal-coordinator.js → components/ln-ui-coordinator/src/ln-ui-coordinator.js} +403 -345
- package/components/ln-upload/README.md +133 -0
- package/components/ln-upload/ln-upload-dev.scss +18 -0
- package/components/ln-upload/ln-upload.js +1 -0
- package/components/ln-upload/ln-upload.schema.json +193 -0
- package/components/ln-upload/ln-upload.scss +20 -0
- package/components/ln-upload/src/ln-upload.js +652 -0
- package/components/ln-upload/src/upload-model.js +78 -0
- package/{js → components}/ln-validate/README.md +182 -180
- package/{js → components}/ln-validate/ln-validate-dev.scss +15 -15
- package/components/ln-validate/ln-validate.js +1 -0
- package/components/ln-validate/ln-validate.schema.json +50 -0
- package/components/ln-validate/ln-validate.scss +7 -0
- package/{js → components}/ln-validate/src/ln-validate.js +23 -45
- package/components/ln-validate/src/validate-model.js +64 -0
- package/components/ln-websocket-connector/README.md +166 -0
- package/components/ln-websocket-connector/ln-websocket-connector.js +1 -0
- package/components/ln-websocket-connector/ln-websocket-connector.schema.json +29 -0
- package/components/ln-websocket-connector/src/ln-websocket-connector.js +279 -0
- package/ln-ashlar.html-data.json +1796 -0
- package/package.json +84 -61
- package/{scss → theme}/base/_global.scss +1 -2
- package/{scss → theme}/base/_reset.scss +1 -1
- package/{scss → theme}/base/_typography.scss +2 -0
- package/theme/brand.css +73 -0
- package/{scss → theme}/components/_app-shell.scss +8 -0
- package/theme/components/_button.scss +24 -0
- package/theme/components/_chart.scss +5 -0
- package/theme/components/_confirm.scss +6 -0
- package/{scss → theme}/components/_date.scss +30 -22
- package/{scss → theme}/components/_dropdown.scss +6 -1
- package/theme/components/_form.scss +140 -0
- package/{scss → theme}/components/_layout.scss +6 -0
- package/{scss → theme}/components/_ln-table.scss +1 -6
- package/theme/components/_picklist.scss +3 -0
- package/{scss → theme}/components/_sort.scss +10 -10
- package/theme/components/_status-badge.scss +6 -0
- package/{scss → theme}/components/_table.scss +16 -0
- package/{scss → theme}/components/_tabs.scss +0 -4
- package/theme/components/_toast.scss +48 -0
- package/{scss → theme}/components/_toggle.scss +1 -1
- package/theme/components/_upload.scss +45 -0
- package/{scss → theme}/config/_breakpoints.scss +1 -1
- package/theme/config/_contrast.scss +128 -0
- package/{scss → theme}/config/_density.scss +191 -205
- package/theme/config/_palette.scss +274 -0
- package/theme/config/_theme.scss +293 -0
- package/{scss → theme}/config/_tokens.scss +285 -441
- package/{scss → theme}/config/mixins/_accordion.scss +1 -1
- package/{scss → theme}/config/mixins/_alert.scss +1 -0
- package/{scss → theme}/config/mixins/_app-shell.scss +4 -2
- package/{scss → theme}/config/mixins/_borders.scss +2 -0
- package/theme/config/mixins/_btn.scss +175 -0
- package/{scss → theme}/config/mixins/_card.scss +55 -46
- package/theme/config/mixins/_chart.scss +82 -0
- package/{scss → theme}/config/mixins/_collapsible.scss +2 -1
- package/{scss → theme}/config/mixins/_colors.scss +8 -14
- package/{scss → theme}/config/mixins/_diagnostics.scss +48 -48
- package/theme/config/mixins/_dropdown.scss +169 -0
- package/{scss → theme}/config/mixins/_editor.scss +0 -7
- package/{scss → theme}/config/mixins/_filter.scss +47 -47
- package/{scss → theme}/config/mixins/_footer.scss +1 -1
- package/{scss → theme}/config/mixins/_form.scss +49 -18
- package/{scss → theme}/config/mixins/_index.scss +62 -61
- package/{scss → theme}/config/mixins/_layout.scss +6 -2
- package/{scss → theme}/config/mixins/_ln-table.scss +31 -10
- package/{scss → theme}/config/mixins/_loader.scss +1 -1
- package/{scss → theme}/config/mixins/_modal.scss +145 -149
- package/{scss → theme}/config/mixins/_motion.scss +13 -0
- package/{scss → theme}/config/mixins/_nav.scss +7 -7
- package/theme/config/mixins/_picklist.scss +66 -0
- package/theme/config/mixins/_popover.scss +96 -0
- package/{scss → theme}/config/mixins/_sidebar.scss +7 -4
- package/{scss → theme}/config/mixins/_sort.scss +43 -42
- package/{scss → theme}/config/mixins/_status-badge.scss +15 -2
- package/{scss → theme}/config/mixins/_table.scss +25 -14
- package/{scss → theme}/config/mixins/_tabs.scss +1 -1
- package/{scss → theme}/config/mixins/_toast.scss +174 -179
- package/{scss → theme}/config/mixins/_tooltip.scss +2 -2
- package/{scss → theme}/config/mixins/_typography.scss +16 -5
- package/{scss → theme}/config/mixins/_upload.scss +8 -6
- package/theme/ln-ashlar-core.scss +24 -0
- package/theme/ln-ashlar-dev.scss +66 -0
- package/theme/ln-ashlar-landing.scss +56 -0
- package/{scss/ln-ashlar.scss → theme/ln-ashlar-theme.scss} +63 -69
- package/theme/ln-ashlar.scss +8 -0
- package/theme/presentation/_bento.scss +151 -0
- package/theme/presentation/_cta.scss +111 -0
- package/theme/presentation/_effects.scss +216 -0
- package/theme/presentation/_features.scss +108 -0
- package/theme/presentation/_footer.scss +129 -0
- package/theme/presentation/_hero.scss +158 -0
- package/theme/presentation/_layout.scss +170 -0
- package/theme/presentation/_navbar.scss +140 -0
- package/theme/presentation/_pricing.scss +262 -0
- package/theme/presentation/_stats.scss +87 -0
- package/theme/presentation/_testimonials.scss +124 -0
- package/theme/presentation/_tokens.scss +39 -0
- package/theme/presentation/_typography.scss +163 -0
- package/{scss → theme}/utilities/_animations.scss +38 -0
- package/{scss → theme}/utilities/_utilities.scss +6 -0
- package/web-types.json +2312 -0
- package/js/ln-accordion/ln-accordion.js +0 -1
- package/js/ln-ajax/ln-ajax.js +0 -1
- package/js/ln-api-connector/ln-api-connector.js +0 -1
- package/js/ln-api-connector/src/ln-api-connector.js +0 -368
- package/js/ln-api-queue/ln-api-queue.js +0 -1
- package/js/ln-autoresize/ln-autoresize.js +0 -1
- package/js/ln-autosave/ln-autosave.js +0 -1
- package/js/ln-circular-progress/ln-circular-progress.js +0 -1
- package/js/ln-confirm/README.md +0 -162
- package/js/ln-confirm/_ln-confirm.scss +0 -24
- package/js/ln-confirm/ln-confirm.js +0 -1
- package/js/ln-core/crypto.js +0 -83
- package/js/ln-core/helpers.js +0 -788
- package/js/ln-core/index.js +0 -7
- package/js/ln-core/persist.js +0 -97
- package/js/ln-couchdb-connector/ln-couchdb-connector.js +0 -1
- package/js/ln-data-coordinator/ln-data-coordinator.js +0 -1
- package/js/ln-data-coordinator/src/data-read-policy.js +0 -18
- package/js/ln-data-store/ln-data-store.js +0 -1
- package/js/ln-date/ln-date.js +0 -1
- package/js/ln-date/src/ln-date.js +0 -603
- package/js/ln-debug/README.md +0 -58
- package/js/ln-debug/ln-debug.js +0 -1
- package/js/ln-debug/src/ln-debug.js +0 -19
- package/js/ln-dropdown/ln-dropdown.js +0 -1
- package/js/ln-dropdown/ln-dropdown.scss +0 -15
- package/js/ln-editor/ln-editor.js +0 -1
- package/js/ln-editor/ln-editor.scss +0 -43
- package/js/ln-external-links/ln-external-links.js +0 -1
- package/js/ln-fill/ln-fill.js +0 -1
- package/js/ln-filter/README.md +0 -189
- package/js/ln-filter/ln-filter-dev.scss +0 -8
- package/js/ln-filter/ln-filter.js +0 -1
- package/js/ln-filter/src/ln-filter.js +0 -419
- package/js/ln-form/ln-form.js +0 -1
- package/js/ln-http/ln-http.js +0 -1
- package/js/ln-link/ln-link.js +0 -1
- package/js/ln-list/README.md +0 -129
- package/js/ln-list/ln-list.js +0 -1
- package/js/ln-list/ln-list.scss +0 -28
- package/js/ln-modal/ln-modal-dev.scss +0 -13
- package/js/ln-modal/ln-modal.js +0 -1
- package/js/ln-modal/ln-modal.scss +0 -35
- package/js/ln-modal-coordinator/README.md +0 -99
- package/js/ln-modal-coordinator/ln-modal-coordinator-dev.scss +0 -8
- package/js/ln-modal-coordinator/ln-modal-coordinator.js +0 -1
- package/js/ln-nav/ln-nav.js +0 -1
- package/js/ln-number/README.md +0 -149
- package/js/ln-number/ln-number.js +0 -1
- package/js/ln-number/src/ln-number.js +0 -443
- package/js/ln-options/ln-options.js +0 -1
- package/js/ln-popover/ln-popover.js +0 -1
- package/js/ln-progress/ln-progress.js +0 -1
- package/js/ln-progress/src/ln-progress.js +0 -98
- package/js/ln-router/ln-router.js +0 -1
- package/js/ln-search/README.md +0 -158
- package/js/ln-search/ln-search-dev.scss +0 -8
- package/js/ln-search/ln-search.js +0 -1
- package/js/ln-search/src/ln-search.js +0 -117
- package/js/ln-slug/ln-slug.js +0 -1
- package/js/ln-sort/ln-sort.js +0 -1
- package/js/ln-sort/src/ln-sort.js +0 -178
- package/js/ln-sortable/ln-sortable.js +0 -1
- package/js/ln-stat/ln-stat.js +0 -1
- package/js/ln-table/ln-table.js +0 -1
- package/js/ln-table/ln-table.scss +0 -11
- package/js/ln-table-coordinator/README.md +0 -73
- package/js/ln-table-coordinator/ln-table-coordinator.js +0 -1
- package/js/ln-table-coordinator/src/ln-table-coordinator.js +0 -160
- package/js/ln-tabs/ln-tabs-dev.scss +0 -18
- package/js/ln-tabs/ln-tabs.js +0 -1
- package/js/ln-tabs/src/ln-tabs.js +0 -188
- package/js/ln-time/ln-time.js +0 -1
- package/js/ln-toast/ln-toast.js +0 -1
- package/js/ln-toggle/ln-toggle.js +0 -1
- package/js/ln-tooltip/ln-tooltip.js +0 -1
- package/js/ln-tooltip/ln-tooltip.scss +0 -9
- package/js/ln-translations/ln-translations.js +0 -1
- package/js/ln-upload/README.md +0 -255
- package/js/ln-upload/ln-upload.js +0 -1
- package/js/ln-upload/ln-upload.scss +0 -20
- package/js/ln-upload/src/ln-upload.js +0 -423
- package/js/ln-validate/ln-validate.js +0 -1
- package/scss/components/_button.scss +0 -20
- package/scss/components/_confirm.scss +0 -5
- package/scss/components/_form.scss +0 -107
- package/scss/components/_status-badge.scss +0 -4
- package/scss/components/_toast.scss +0 -68
- package/scss/components/_upload.scss +0 -51
- package/scss/config/_theme.scss +0 -216
- package/scss/config/mixins/_btn.scss +0 -179
- package/scss/config/mixins/_confirm.scss +0 -31
- package/scss/config/mixins/_dropdown.scss +0 -141
- package/scss/config/mixins/_popover.scss +0 -64
- package/scss/ln-ashlar-dev.scss +0 -39
- /package/{js → components}/ln-core/positioning.js +0 -0
- /package/{js → components}/ln-core/reactive.js +0 -0
- /package/{js → components}/ln-filter/ln-filter.scss +0 -0
- /package/{js → components}/ln-icon/ln-icon.js +0 -0
- /package/{js → components}/ln-icon/src/ln-icon.js +0 -0
- /package/{js → components}/ln-search/ln-search.scss +0 -0
- /package/{js → components}/ln-toast/template.html +0 -0
- /package/{scss → theme}/components/_accordion.scss +0 -0
- /package/{scss → theme}/components/_ajax.scss +0 -0
- /package/{scss → theme}/components/_alert.scss +0 -0
- /package/{scss → theme}/components/_avatar.scss +0 -0
- /package/{scss → theme}/components/_breadcrumbs.scss +0 -0
- /package/{scss → theme}/components/_card.scss +0 -0
- /package/{scss → theme}/components/_chip.scss +0 -0
- /package/{scss → theme}/components/_circular-progress.scss +0 -0
- /package/{scss → theme}/components/_editor.scss +0 -0
- /package/{scss → theme}/components/_empty-state.scss +0 -0
- /package/{scss → theme}/components/_filter.scss +0 -0
- /package/{scss → theme}/components/_link.scss +0 -0
- /package/{scss → theme}/components/_loader.scss +0 -0
- /package/{scss → theme}/components/_modal.scss +0 -0
- /package/{scss → theme}/components/_nav.scss +0 -0
- /package/{scss → theme}/components/_page-header.scss +0 -0
- /package/{scss → theme}/components/_popover.scss +0 -0
- /package/{scss → theme}/components/_progress.scss +0 -0
- /package/{scss → theme}/components/_prose.scss +0 -0
- /package/{scss → theme}/components/_scrollbar.scss +0 -0
- /package/{scss → theme}/components/_sections.scss +0 -0
- /package/{scss → theme}/components/_sidebar.scss +0 -0
- /package/{scss → theme}/components/_stat-card.scss +0 -0
- /package/{scss → theme}/components/_stepper.scss +0 -0
- /package/{scss → theme}/components/_timeline.scss +0 -0
- /package/{scss → theme}/components/_tooltip.scss +0 -0
- /package/{scss → theme}/components/_translations.scss +0 -0
- /package/{scss → theme}/config/_icons.scss +0 -0
- /package/{scss → theme}/config/_mixins.scss +0 -0
- /package/{scss → theme}/config/mixins/_ajax.scss +0 -0
- /package/{scss → theme}/config/mixins/_avatar.scss +0 -0
- /package/{scss → theme}/config/mixins/_breadcrumbs.scss +0 -0
- /package/{scss → theme}/config/mixins/_breakpoints.scss +0 -0
- /package/{scss → theme}/config/mixins/_chip.scss +0 -0
- /package/{scss → theme}/config/mixins/_circular-progress.scss +0 -0
- /package/{scss → theme}/config/mixins/_display.scss +0 -0
- /package/{scss → theme}/config/mixins/_empty-state.scss +0 -0
- /package/{scss → theme}/config/mixins/_focus.scss +0 -0
- /package/{scss → theme}/config/mixins/_interaction.scss +0 -0
- /package/{scss → theme}/config/mixins/_kbd.scss +0 -0
- /package/{scss → theme}/config/mixins/_link.scss +0 -0
- /package/{scss → theme}/config/mixins/_page-header.scss +0 -0
- /package/{scss → theme}/config/mixins/_position.scss +0 -0
- /package/{scss → theme}/config/mixins/_progress.scss +0 -0
- /package/{scss → theme}/config/mixins/_prose.scss +0 -0
- /package/{scss → theme}/config/mixins/_shadows.scss +0 -0
- /package/{scss → theme}/config/mixins/_sizing.scss +0 -0
- /package/{scss → theme}/config/mixins/_spacing.scss +0 -0
- /package/{scss → theme}/config/mixins/_stat-card.scss +0 -0
- /package/{scss → theme}/config/mixins/_stepper.scss +0 -0
- /package/{scss → theme}/config/mixins/_timeline.scss +0 -0
- /package/{scss → theme}/config/mixins/_transitions.scss +0 -0
- /package/{scss → theme}/config/mixins/_translations.scss +0 -0
- /package/{scss → theme}/tabler-icons.txt +0 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# ln-include
|
|
2
|
+
|
|
3
|
+
> Applied to a template element (`<template data-ln-include="/path.html">`). On initial page boot, it delays page-wide component sweeps, shares fetch promises across duplicate URLs, and injects the retrieved HTML into the template's `.content` fragment before dispatching `ln-include:loaded`. It acts solely as an asynchronous template loader without initializing child components or modifying router consumers.
|
|
4
|
+
|
|
5
|
+
External partial loader for `<template>` elements.
|
|
6
|
+
|
|
7
|
+
`ln-include` lets the *content* of an existing `<template>` be loaded from an external file asynchronously, while the template keeps its own identity. Because only the content moves, no consuming component changes: `cloneTemplate` and router view cloning continue to function seamlessly.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## 🧭 Philosophy
|
|
12
|
+
|
|
13
|
+
- **Zero JS View Logic:** Pages that don't need a build step can share templates, empty states, or route views across files without copy-pasting.
|
|
14
|
+
- **Boot Gating (No race conditions):** Automatically delays page-wide component initialization (e.g., `ln-table` data fetches) until the initial hosts' fetches have completed.
|
|
15
|
+
- **Deduplication:** Multiple host elements pointing to the same external URL share a single fetch promise, avoiding duplicate network requests.
|
|
16
|
+
- **Orthogonality:** The component only populates its host `<template>`. It does not parse or initialize nested components; the central MutationObserver handles subtree additions as they enter the document.
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## 📦 Minimal Blueprint
|
|
21
|
+
|
|
22
|
+
```html
|
|
23
|
+
<template data-ln-template="documents-row" data-ln-include="/tpl/documents-row.html"></template>
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
When compiled/loaded, the contents of `/tpl/documents-row.html` are fetched and injected into the template's `.content` fragment.
|
|
27
|
+
|
|
28
|
+
Route views can be loaded the same way, with zero changes to `ln-router` — it still finds `<template data-ln-route>` and clones `.content` as usual:
|
|
29
|
+
|
|
30
|
+
```html
|
|
31
|
+
<template data-ln-route="/users" data-ln-route-target="main" data-ln-include="/views/users.html"></template>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## 🛠️ Declarative API Contract
|
|
37
|
+
|
|
38
|
+
### Attributes
|
|
39
|
+
|
|
40
|
+
| Attribute | Value | Description |
|
|
41
|
+
|---|---|---|
|
|
42
|
+
| `data-ln-include` | `URL` | The external URL to fetch HTML content from. Only valid on `<template>` elements. |
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## ⚡ DOM Events
|
|
47
|
+
|
|
48
|
+
The component dispatches bubbling events from the host `<template>` element:
|
|
49
|
+
|
|
50
|
+
| Event | `detail` Object | Description |
|
|
51
|
+
|---|---|---|
|
|
52
|
+
| `ln-include:loaded` | `{ target, url }` | Dispatched when the HTML content is successfully fetched, parsed, and injected. |
|
|
53
|
+
| `ln-include:error` | `{ target, url, error }` | Dispatched when the fetch fails. |
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## ⚠️ Common Pitfalls
|
|
58
|
+
|
|
59
|
+
- **Content vs. Registry:** The partial file must contain the *content* of the template itself (e.g. `<tr>...</tr>`), NOT a registry of named `<template>` wrappers. (Nested templates at any depth inside the partial are supported, but wrapping the partial itself in `<template data-ln-template="...">` inside the file creates a dead registry: that outer wrapper is never cloned by anything, so its content never reaches the document.)
|
|
60
|
+
- **Template Hosts Only:** Placing `data-ln-include` on non-`<template>` elements (e.g. `<div>`) is not supported. Such hosts are never matched by the component's selector, so they are silently ignored and no fetch is attempted.
|
|
61
|
+
- **Late-entering Hosts are Ungated:** Hosts created and inserted into the DOM *after* the initial page boot are processed by the MutationObserver, but they do not gate the page (they load asynchronously while other components run).
|
|
62
|
+
- **Standalone Bundle Script Order:** If you load individual component files (e.g. `components/ln-table/ln-table.js`) instead of using the master bundle (`components/index.js`), you **must** ensure that `ln-include.js` executes before all other components. Use plain script tags or `defer` (never `async`), otherwise other components will run their DOMContentLoaded sweeps and bypass the gate.
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## 🔧 Internals
|
|
67
|
+
|
|
68
|
+
During page loading, `ln-include` hooks into `holdInit()` and `releaseInit()`. When the page boots:
|
|
69
|
+
1. `ln-include` discovers all initial `template[data-ln-include]` hosts.
|
|
70
|
+
2. It calls `holdInit()` for each valid host, raising the global pending boot counter.
|
|
71
|
+
3. Other components check the counter during their boot phase and queue their initialization functions if the counter is above zero.
|
|
72
|
+
4. Each fetch fetches and caches the request promise to deduplicate network requests. A rejected promise is evicted from the cache the moment it rejects, so a host created later (e.g. via the MutationObserver) retries the fetch rather than failing instantly against a stale rejection.
|
|
73
|
+
5. The HTML is parsed using a dummy `<template>` element (which preserves table-specific nodes like `<tr>`, `<td>`, `<option>`) and appended to `this.dom.content`.
|
|
74
|
+
6. Once a load succeeds or fails, the host calls `releaseInit()`.
|
|
75
|
+
7. Once the counter reaches zero, the boot queue is drained in push order.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
@use '../../theme/config/mixins' as *;
|
|
2
|
+
|
|
3
|
+
[data-ln-debug] {
|
|
4
|
+
// 1. Host Element Check: data-ln-include belongs only on <template>
|
|
5
|
+
[data-ln-include]:not(template) {
|
|
6
|
+
@include dev-inline-error("data-ln-include belongs only on <template> elements");
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// 2. URL Check: data-ln-include URL cannot be empty
|
|
10
|
+
template[data-ln-include=""] {
|
|
11
|
+
@include dev-inline-error("data-ln-include URL cannot be empty");
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(){"use strict";function E(){return typeof window>"u"?!1:window.lnDebug===!0||window.lnCore&&window.lnCore._debugSink?!0:typeof document<"u"&&document.body?document.body.hasAttribute("data-ln-debug")||document.body.querySelector("[data-ln-debug]")!==null:!1}function g(e){if(typeof window>"u")return!1;if(window.lnDebug===!0)return!0;if(window.lnCore&&window.lnCore._debugIsContained)return e?window.lnCore._debugIsContained(e):window.lnCore._debugSink!==null;if(e&&e.closest){const t=e.closest("[data-ln-debug]");return!(!t||typeof document<"u"&&t===document.documentElement)}return typeof document<"u"&&document.body?document.body.hasAttribute("data-ln-debug"):!1}if(typeof window<"u"&&(window.lnCore=window.lnCore||{},!window.lnCore._warnBound)){window.lnCore._warnBound=!0;const e=console.warn;console.warn=function(...t){if(typeof t[0]=="string"&&(t[0].startsWith("[ln-")||t[0].startsWith("[lnCore"))){let r=null;for(let o=1;o<t.length;o++)if(t[o]&&t[o].nodeType===1){r=t[o];break}if(!g(r))return}e.apply(console,t)}}function C(e,t,n){const r=n||{};window.lnCore._debugSink&&window.lnCore._debugSink("event",t,e,r),e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:r}))}function b(e,t){if(!document.body){document.addEventListener("DOMContentLoaded",function(){b(e,t)}),console.warn("["+t+'] Script loaded before <body> — add "defer" to your <script> tag');return}e()}const $={};function j(e,t){$[e]=t}function W(e){return $[e]||{ingress:t=>t,egress:t=>t}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerDataMapper=j,window.lnCore.getDataMapper=W);function V(){typeof window>"u"||(window.lnCore=window.lnCore||{},!window.lnCore._localeObserverBound&&(window.lnCore._localeObserverBound=!0,b(function(){new MutationObserver(function(){C(document,"ln-core:locale-change",{})}).observe(document.documentElement,{attributes:!0,attributeFilter:["lang"],subtree:!0})},"ln-core")))}const I={};function Q(e,t){if(!e||typeof t!="object")return;const n=e.toLowerCase().split("-")[0];I[n]=t}function U(e){if(!e)return null;const t=e.toLowerCase().split("-")[0];return I[t]||null}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerLocaleFallback=Q,window.lnCore.getLocaleFallback=U,window.lnCore.ensureLocaleObserver=V);const y={};function J(e,t){y[e]||(y[e]=document.querySelector('[data-ln-template="'+e+'"]'));const n=y[e];return n?n.content.cloneNode(!0):(console.warn("["+(t||"ln-core")+'] Template "'+e+'" not found'),null)}function D(e,t){if(!e||!t)return e;const n=e.querySelectorAll("[data-ln-field]");for(let l=0;l<n.length;l++){const s=n[l],c=s.getAttribute("data-ln-field");t[c]!=null&&(s.textContent=t[c])}const r=e.querySelectorAll("[data-ln-attr]");for(let l=0;l<r.length;l++){const s=r[l],c=s.getAttribute("data-ln-attr").split(",");for(let u=0;u<c.length;u++){const d=c[u].trim().split(":");if(d.length!==2)continue;const a=d[0].trim(),f=d[1].trim();t[f]!=null&&s.setAttribute(a,t[f])}}const o=e.querySelectorAll("[data-ln-show]");for(let l=0;l<o.length;l++){const s=o[l],c=s.getAttribute("data-ln-show");c in t&&s.classList.toggle("hidden",!t[c])}const i=e.querySelectorAll("[data-ln-class]");for(let l=0;l<i.length;l++){const s=i[l],c=s.getAttribute("data-ln-class").split(",");for(let u=0;u<c.length;u++){const d=c[u].trim().split(":");if(d.length!==2)continue;const a=d[0].trim(),f=d[1].trim();f in t&&s.classList.toggle(a,!!t[f])}}return e}function K(e,t){e.matches&&e.matches("[data-ln-form], [data-ln-fillable]")&&(window.lnCore._debugSink&&window.lnCore._debugSink("event","ln-fill",e,t??null),e.dispatchEvent(new CustomEvent("ln-fill",{detail:t??null,bubbles:!0})));const n=e.querySelectorAll("[data-ln-form], [data-ln-fillable]");for(let r=0;r<n.length;r++)window.lnCore._debugSink&&window.lnCore._debugSink("event","ln-fill",n[r],t??null),n[r].dispatchEvent(new CustomEvent("ln-fill",{detail:t??null,bubbles:!0}));return e}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore._fillBound||(window.lnCore._fillBound=!0,document.addEventListener("ln-fill",function(e){if(!(!e.target.matches||!e.target.matches("[data-ln-fillable]")))if(e.detail)D(e.target,e.detail);else{const t=e.target.querySelectorAll("[data-ln-field]");for(let n=0;n<t.length;n++)t[n].textContent=""}})));function M(e,t){if(!e||!t)return e;const n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(;n.nextNode();){const i=n.currentNode;i.textContent.indexOf("{{")!==-1&&(i.textContent=i.textContent.replace(/\{\{\s*(\w+)\s*\}\}/g,function(l,s){return t[s]!==void 0?t[s]:""}))}const r=function(i,l){return t[l]!==void 0?t[l]:""},o=Array.from(e.querySelectorAll("*"));e.nodeType===1&&o.push(e);for(let i=0;i<o.length;i++){const l=o[i],s=l.attributes;for(let c=0;c<s.length;c++){const u=s[c];u.value.indexOf("{{")!==-1&&l.setAttribute(u.name,u.value.replace(/\{\{\s*(\w+)\s*\}\}/g,r))}}return e}function P(e,t,n,r,o,i){const l={};for(let c=0;c<e.children.length;c++){const u=e.children[c],d=u.getAttribute("data-ln-render-key");d&&(l[d]=u)}const s=document.createDocumentFragment();for(let c=0;c<t.length;c++){const u=t[c],d=String(r(u));let a=l[d];if(a)o(a,u,c);else{const f=J(n,i);if(!f||(M(f,u),a=f.firstElementChild,!a))continue;a.setAttribute("data-ln-render-key",d),o(a,u,c)}s.appendChild(a)}e.textContent="",e.appendChild(s)}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.fillTemplate=M,window.lnCore.fill=D,window.lnCore.lnFill=K,window.lnCore.renderList=P);function m(e,t,n){const r=e.getAttribute(t);return r===null?n:r}function G(e,t,n){const r=parseInt(e.getAttribute(t),10);return isNaN(r)?n:r}function X(e,t,n=!1){const r=e.getAttribute(t);if(r===null)return!!n;const o=r.trim().toLowerCase();return!(o==="false"||o==="0")}function z(e,t){return(e.getAttribute(t)||"").split(",").map(n=>n.trim()).filter(Boolean)}const A=new Map;function Y(e,t){const n=(e?e.join("|"):"")+"::"+t;if(A.has(n))return A.get(n);const r=new Set(e||[]),o=function(i,l){const s=i.getAttribute(l);return s!==null&&r.has(s)?s:t};return A.set(n,o),o}function Z(e,t,n){const r=parseFloat(e.getAttribute(t));return isNaN(r)?n:r}function ee(e,t,n){const r=e.getAttribute(t);if(!r)return n;try{return JSON.parse(r)}catch{return n}}function R(e,t,n,r,o){if(!e||t===null)return!0;const i=r||"ln-component",l=e.type;if(l==="trigger"||l==="marker"||l==="string"||l==="list"||!l||t===""&&e.fallback!==void 0)return!0;const s=c=>{o?console.warn(c,o):console.warn(c)};if(l==="boolean"){const c=t.trim().toLowerCase();return c!==""&&c!=="true"&&c!=="false"&&c!=="1"&&c!=="0"?(s(`[${i}] Invalid value "${t}" for boolean attribute "${n}". Allowed: "true", "false", or presence-only.`),!1):!0}if(l==="enum"){const c=e.values||[];return c.includes(t)?!0:(s(`[${i}] Invalid value "${t}" for attribute "${n}". Allowed: ${c.join(", ")}. Fallback: "${e.fallback}".`),!1)}if(l==="integer"){if(!/^-?\d+$/.test(t))return s(`[${i}] Invalid integer "${t}" for attribute "${n}". Fallback: ${e.fallback}.`),!1;const c=parseInt(t,10);return e.min!==void 0&&c<e.min?(s(`[${i}] Value ${c} for attribute "${n}" is less than min (${e.min}).`),!1):e.max!==void 0&&c>e.max?(s(`[${i}] Value ${c} for attribute "${n}" is greater than max (${e.max}).`),!1):!0}if(l==="float")return isNaN(Number(t))?(s(`[${i}] Invalid float "${t}" for attribute "${n}". Fallback: ${e.fallback}.`),!1):!0;if(l==="json")try{return JSON.parse(t),!0}catch(c){return s(`[${i}] Invalid JSON for attribute "${n}": ${c.message}. Fallback: ${e.fallback}.`),!1}return!0}function te(e,t,n){for(const r in n){const[o,i,l]=n[r];Object.defineProperty(e,r,{get:function(){return o(t,i,l)},enumerable:!0,configurable:!0})}return e}function ne(e){const t={};for(const n in e){const r=e[n];if(!r||!r.prop)continue;let o=r.read;if(!o&&r.type)switch(r.type){case"enum":o=Y(r.values,r.fallback);break;case"integer":o=G;break;case"float":o=Z;break;case"boolean":o=X;break;case"list":o=z;break;case"json":o=ee;break;case"string":default:o=m;break}o||(o=m),t[r.prop]=[o,n,r.fallback]}return t}function re(e){const t={};for(const n in e){const r=e[n];r&&r.effect&&(t[n]=r.effect)}return Object.keys(t).length?t:null}function oe(e){if(e.onAttrChange&&!e.declared)return null;const t=new Set;if(e.effects)for(const n in e.effects)t.add(n);if(e.onAttrChange&&e.declared)for(const n of e.declared)t.add(n);return t}function _(e,t,n,r){if(e.nodeType!==1)return;const i=t.indexOf("[")!==-1||t.indexOf(".")!==-1||t.indexOf("#")!==-1?t:"["+t+"]",l=Array.from(e.querySelectorAll(i));e.matches&&e.matches(i)&&l.push(e);for(const s of l)if(!s[n]){window.lnCore._persistSink&&s.hasAttribute("data-ln-persist")&&window.lnCore._persistSink(s,t);try{s[n]=new r(s)}catch(c){console.error("["+n+"] init failed",s,c)}}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore._bootHolds=window.lnCore._bootHolds||0,window.lnCore._bootQueue=window.lnCore._bootQueue||[]);function ie(){typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore._bootHolds=(window.lnCore._bootHolds||0)+1)}function k(){if(typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore._bootHolds=Math.max(0,(window.lnCore._bootHolds||0)-1),window.lnCore._bootHolds===0&&window.lnCore._bootQueue)){const e=window.lnCore._bootQueue;window.lnCore._bootQueue=[];for(let t=0;t<e.length;t++)e[t]()}}function le(){return typeof window<"u"&&window.lnCore&&window.lnCore._bootHolds||0}function se(e){typeof window<"u"?(window.lnCore=window.lnCore||{},window.lnCore._bootHolds=window.lnCore._bootHolds||0,window.lnCore._bootQueue=window.lnCore._bootQueue||[],window.lnCore._bootHolds>0?window.lnCore._bootQueue.push(e):setTimeout(e,0)):e()}function q(){window.lnCore=window.lnCore||{};const e=window.lnCore._attrRegistry=window.lnCore._attrRegistry||{byAttr:new Map,reactive:[],persist:[]};return e.byReactive=e.byReactive||new Map,e.reactiveWildcard=e.reactiveWildcard||[],e}function ce(e){const t=q(),n=e.observed||[];for(let r=0;r<n.length;r++){const o=n[r];t.byAttr.has(o)||t.byAttr.set(o,[]),t.byAttr.get(o).push(e)}if(t.byDeclaredAttr=t.byDeclaredAttr||new Map,e.attributes)for(const r in e.attributes){t.byDeclaredAttr.has(r)||t.byDeclaredAttr.set(r,[]);const o=t.byDeclaredAttr.get(r);o.some(i=>i.componentTag===e.componentTag)||o.push({spec:e.attributes[r],componentTag:e.componentTag})}if(e.onAttrChange||e.effects){t.reactive.push(e);const r=oe(e);if(r===null)t.reactiveWildcard.push(e);else for(const o of r)t.byReactive.has(o)||t.byReactive.set(o,[]),t.byReactive.get(o).push(e)}e.persist&&t.persist.push(e)}function F(e,t,n,r){for(let o=0;o<e.length;o++){const i=e[o];if(!t[i.attribute])continue;const l=i.effects&&i.effects[n];l?l(t,n,r):i.onAttrChange&&(!i.declared||i.declared.has(n))&&i.onAttrChange(t,n,r)}}function ue(e){const t=e.target,n=e.attributeName;if(e.oldValue===t.getAttribute(n))return;const r=q(),o=r.byAttr.get(n);if(E()&&r.byDeclaredAttr&&r.byDeclaredAttr.has(n)&&g(t)){const i=r.byDeclaredAttr.get(n),l=t.getAttribute(n);for(let s=0;s<i.length;s++)R(i[s].spec,l,n,i[s].componentTag,t)}if(window.lnCore._debugSink&&(n.indexOf("data-ln-")===0||o)&&window.lnCore._debugSink("attr",n,t,{oldValue:e.oldValue,newValue:t.getAttribute(n)}),n.indexOf("data-ln-")===0){const i=r.byReactive.get(n);i&&F(i,t,n,e.oldValue),r.reactiveWildcard.length&&F(r.reactiveWildcard,t,n,e.oldValue)}if(o)for(let i=0;i<o.length;i++){const l=o[i];if(l.handler){l.handler(t,n,e.oldValue);continue}l.onAttributeChange&&t[l.attribute]?l.onAttributeChange(t,n):(_(t,l.selector,l.attribute,l.ComponentFn),l.onInit&&l.onInit(t))}}function de(){window.lnCore=window.lnCore||{},!window.lnCore._attrObserverBound&&(window.lnCore._attrObserverBound=!0,b(function(){new MutationObserver(function(t){for(let n=0;n<t.length;n++)try{ue(t[n])}catch(r){console.error("[ln-core] mutation handler failed",t[n].target,r)}}).observe(document.body,{attributes:!0,subtree:!0,attributeOldValue:!0})},"ln-core"))}function N(){return window.lnCore=window.lnCore||{},window.lnCore._lifecycleRegistry=window.lnCore._lifecycleRegistry||[]}function ae(e){const t=N();if(t.length){if(e.target)for(let n=0;n<t.length;n++){const r=t[n];if(r.onSubtreeChange){const o=r.query,i=e.target.nodeType===1?e.target.matches(o)?e.target:e.target.closest(o):e.target.parentElement?e.target.parentElement.closest(o):null;i&&r.onSubtreeChange(i,e)}}for(let n=0;n<e.addedNodes.length;n++){const r=e.addedNodes[n];if(r.nodeType===1)for(let o=0;o<t.length;o++){const i=t[o];_(r,i.selector,i.attribute,i.ComponentFn),i.onInit&&i.onInit(r)}}for(let n=0;n<e.removedNodes.length;n++){const r=e.removedNodes[n];if(r.nodeType===1)for(let o=0;o<t.length;o++){const i=t[o],l=i.query,s=Array.from(r.querySelectorAll(l));r.matches&&r.matches(l)&&s.push(r);for(let c=0;c<s.length;c++){const u=s[c];if(!document.contains(u)){const d=u[i.attribute];if(d&&typeof d.destroy=="function")try{d.destroy()}catch(a){console.error("["+i.attribute+"] destroy failed",u,a)}delete u[i.attribute]}}}}}}function fe(){window.lnCore=window.lnCore||{},!window.lnCore._lifecycleObserverBound&&(window.lnCore._lifecycleObserverBound=!0,b(function(){new MutationObserver(function(t){for(let n=0;n<t.length;n++){const r=t[n];if(r.type==="childList")try{ae(r)}catch(o){console.error("[ln-core] lifecycle handler failed",r.target,o)}}}).observe(document.body,{childList:!0,subtree:!0})},"ln-core"))}function we(e,t,n,r,o={}){const i=o.extraAttributes||[],l=o.onAttributeChange||null,s=o.onSubtreeChange||null,c=o.onInit||null,u=o.onAttrChange||null,d=o.effects||null,a=o.attributes||null,f=a?re(a):d,_e=a?new Set(Object.keys(a)):null,ke=o.persist||null;function p(O){const w=O||document.body;if(_(w,e,t,n),a&&E())for(const h in a){const Se=a[h],x=Array.from(w.querySelectorAll("["+h+"]"));w.matches&&w.matches("["+h+"]")&&x.push(w);for(let L=0;L<x.length;L++){const T=x[L];g(T)&&R(Se,T.getAttribute(h),h,r,T)}}c&&c(w)}const S=[];if(e.indexOf("[")!==-1){const O=/\[([\w-]+)/g;let w;for(;(w=O.exec(e))!==null;)S.push(w[1])}else S.push(e);ce({selector:e,attribute:t,componentTag:r,attributes:a,ComponentFn:n,onInit:c,observed:S.concat(i),onAttributeChange:l,onAttrChange:u,effects:f,declared:_e,persist:ke}),de();const ve=e.indexOf("[")!==-1||e.indexOf(".")!==-1||e.indexOf("#")!==-1?e:"["+e+"]";N().push({selector:e,attribute:t,ComponentFn:n,onInit:c,onSubtreeChange:s,query:ve}),fe(),window[t]=p;function H(){le()>0?se(function(){p(document.body)}):p(document.body)}return document.readyState==="loading"?document.addEventListener("DOMContentLoaded",H):H(),p}function B(e){return(e||"").replace(/^#/,"")}function v(e){const t=e===void 0?location.hash:e,n={},r=B(t);if(!r)return n;const o=r.split("&");for(let i=0;i<o.length;i++){const l=o[i];if(!l)continue;const s=l.indexOf(":"),c=s>-1?l.slice(0,s):l,u=s>-1?l.slice(s+1):"";if(c)try{n[c]=decodeURIComponent(u)}catch{n[c]=u}}return n}function he(e){if(!e)return null;const t=v();return e in t?t[e]:null}function be(e,t){if(!e)return;const n=v();t==null?delete n[e]:n[e]=String(t);const o=Object.keys(n).map(function(i){const l=n[i];return l===""?i:i+":"+encodeURIComponent(l)}).join("&");B(location.hash)!==o&&(location.hash=o)}function pe(e){return e.button===1||e.ctrlKey||e.metaKey||e.shiftKey?!1:(e.preventDefault(),!0)}function ge(e,t){if(!e||!e.hasAttribute("data-ln-hash"))return null;const n=e.getAttribute("data-ln-hash");if(n&&n.trim()!=="")return n.trim();const r=e.getAttribute("data-ln-sort")||e.getAttribute("data-ln-search-for")||e.getAttribute("data-ln-search")||e.getAttribute("data-ln-filter")||e.id;return r?t?r+"-"+t:r:t||null}function Ce(e,t){return!t||t==="none"||e===null||e===void 0?null:String(e)+"."+t}function ye(e){return!e||typeof e!="string"?null:e.endsWith(".asc")?{fieldOrColumn:e.slice(0,-4),direction:"asc"}:e.endsWith(".desc")?{fieldOrColumn:e.slice(0,-5),direction:"desc"}:null}function me(e,t){return!e||!Array.isArray(t)||t.length===0?null:e+":"+t.map(encodeURIComponent).join(",")}function Ae(e){if(!e||typeof e!="string")return null;const t=e.indexOf(":");if(t===-1)return null;const n=e.slice(0,t),r=e.slice(t+1),o=r?r.split(",").map(function(i){try{return decodeURIComponent(i)}catch{return i}}).filter(Boolean):[];return{key:n,values:o}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.hashParse=v,window.lnCore.hashGet=he,window.lnCore.hashSet=be,window.lnCore.hashLinkClick=pe,window.lnCore.resolveHashNamespace=ge,window.lnCore.hashSortEncode=Ce,window.lnCore.hashSortDecode=ye,window.lnCore.hashFilterEncode=me,window.lnCore.hashFilterDecode=Ae),(function(){const e="template[data-ln-include]",t="lnInclude";if(window[t]!==void 0)return;const n={"data-ln-include":{prop:"url",read:m,type:"string",fallback:"",description:"URL of external HTML template to fetch and include"}},r=ne(n),o=new Map;function i(l){if(this.dom=l,te(this,l,r),this._held=!1,this._destroyed=!1,!this.url)return this;ie(),this._held=!0;const s=this,c=this.url;let u=o.get(c);return u||(u=fetch(c).then(function(d){if(!d.ok)throw new Error("HTTP error! status: "+d.status);return d.text()}).catch(function(d){throw o.delete(c),d}),o.set(c,u)),u.then(function(d){if(s._destroyed)return;const a=document.createElement("template");a.innerHTML=d,s.dom.content.appendChild(a.content),C(s.dom,"ln-include:loaded",{target:s.dom,url:s.url}),s._held&&(s._held=!1,k())}).catch(function(d){s._destroyed||(console.error("[ln-include] Failed to fetch template from "+s.url+":",d),C(s.dom,"ln-include:error",{target:s.dom,url:s.url,error:d}),s._held&&(s._held=!1,k()))}),this}i.prototype.destroy=function(){this.dom[t]&&(this._destroyed=!0,this._held&&(this._held=!1,k()),delete this.dom[t])},we(e,t,i,"ln-include",{attributes:n})})()})();
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$comment": "This file is partly generated. The $comment, component, generator, and each attribute's direction, sources, type, values, fallback, and description keys are owned by the generator and synchronized from JS source code. All other keys are preserved and safe to hand-author. Regenerate with `npm run sync:ln-schemas`.",
|
|
3
|
+
"component": "ln-include",
|
|
4
|
+
"generator": "scripts/sync-ln-schemas.mjs",
|
|
5
|
+
"attributes": {
|
|
6
|
+
"data-ln-debug": {
|
|
7
|
+
"direction": null,
|
|
8
|
+
"sources": [
|
|
9
|
+
"ln-include-dev.scss"
|
|
10
|
+
]
|
|
11
|
+
},
|
|
12
|
+
"data-ln-include": {
|
|
13
|
+
"direction": null,
|
|
14
|
+
"sources": [
|
|
15
|
+
"ln-include-dev.scss",
|
|
16
|
+
"src/ln-include.js"
|
|
17
|
+
],
|
|
18
|
+
"type": "string",
|
|
19
|
+
"fallback": "",
|
|
20
|
+
"description": "URL of external HTML template to fetch and include"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { dispatch, registerComponent, holdInit, releaseInit, defineAttrs, attrSpec, attrStr } from '../../ln-core';
|
|
2
|
+
|
|
3
|
+
(function () {
|
|
4
|
+
const DOM_SELECTOR = 'template[data-ln-include]';
|
|
5
|
+
const DOM_ATTRIBUTE = 'lnInclude';
|
|
6
|
+
|
|
7
|
+
if (window[DOM_ATTRIBUTE] !== undefined) return;
|
|
8
|
+
|
|
9
|
+
// ─── Attribute Contract (SSOT) ──────────────────────────
|
|
10
|
+
const ATTRIBUTES = {
|
|
11
|
+
'data-ln-include': { prop: 'url', read: attrStr, type: 'string', fallback: '', description: 'URL of external HTML template to fetch and include' }
|
|
12
|
+
};
|
|
13
|
+
const ATTR_SPEC = attrSpec(ATTRIBUTES);
|
|
14
|
+
|
|
15
|
+
// Module-level deduplication Map for shared fetch requests
|
|
16
|
+
const _fetchCache = new Map();
|
|
17
|
+
|
|
18
|
+
// ─── Component ─────────────────────────────────────────────
|
|
19
|
+
|
|
20
|
+
function _component(dom) {
|
|
21
|
+
this.dom = dom;
|
|
22
|
+
defineAttrs(this, dom, ATTR_SPEC);
|
|
23
|
+
this._held = false;
|
|
24
|
+
this._destroyed = false;
|
|
25
|
+
|
|
26
|
+
// 1. Bail if empty URL
|
|
27
|
+
if (!this.url) {
|
|
28
|
+
return this;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// 2. Take hold ONLY after validation checks pass
|
|
32
|
+
holdInit();
|
|
33
|
+
this._held = true;
|
|
34
|
+
|
|
35
|
+
const self = this;
|
|
36
|
+
|
|
37
|
+
// Deduplicate: check cache for existing promise
|
|
38
|
+
const url = this.url;
|
|
39
|
+
let promise = _fetchCache.get(url);
|
|
40
|
+
if (!promise) {
|
|
41
|
+
promise = fetch(url)
|
|
42
|
+
.then(function (res) {
|
|
43
|
+
if (!res.ok) {
|
|
44
|
+
throw new Error('HTTP error! status: ' + res.status);
|
|
45
|
+
}
|
|
46
|
+
return res.text();
|
|
47
|
+
})
|
|
48
|
+
.catch(function (err) {
|
|
49
|
+
_fetchCache.delete(url); // allow a later host to retry
|
|
50
|
+
throw err;
|
|
51
|
+
});
|
|
52
|
+
_fetchCache.set(url, promise);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
promise.then(function (html) {
|
|
56
|
+
if (self._destroyed) return;
|
|
57
|
+
|
|
58
|
+
// Parse content using a throwaway <template> to retain table elements (tr/td/option)
|
|
59
|
+
const parser = document.createElement('template');
|
|
60
|
+
parser.innerHTML = html;
|
|
61
|
+
|
|
62
|
+
// Append DocumentFragment directly to dom.content
|
|
63
|
+
self.dom.content.appendChild(parser.content);
|
|
64
|
+
|
|
65
|
+
// Dispatch success event
|
|
66
|
+
dispatch(self.dom, 'ln-include:loaded', { target: self.dom, url: self.url });
|
|
67
|
+
|
|
68
|
+
// Release gate
|
|
69
|
+
if (self._held) {
|
|
70
|
+
self._held = false;
|
|
71
|
+
releaseInit();
|
|
72
|
+
}
|
|
73
|
+
}).catch(function (err) {
|
|
74
|
+
if (self._destroyed) return;
|
|
75
|
+
|
|
76
|
+
console.error('[ln-include] Failed to fetch template from ' + self.url + ':', err);
|
|
77
|
+
|
|
78
|
+
// Dispatch error event
|
|
79
|
+
dispatch(self.dom, 'ln-include:error', { target: self.dom, url: self.url, error: err });
|
|
80
|
+
|
|
81
|
+
// Always release gate on error
|
|
82
|
+
if (self._held) {
|
|
83
|
+
self._held = false;
|
|
84
|
+
releaseInit();
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
return this;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// ─── Destroy ───────────────────────────────────────────────
|
|
92
|
+
|
|
93
|
+
_component.prototype.destroy = function () {
|
|
94
|
+
if (!this.dom[DOM_ATTRIBUTE]) return;
|
|
95
|
+
|
|
96
|
+
this._destroyed = true;
|
|
97
|
+
|
|
98
|
+
if (this._held) {
|
|
99
|
+
this._held = false;
|
|
100
|
+
releaseInit();
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
delete this.dom[DOM_ATTRIBUTE];
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
// ─── Init ──────────────────────────────────────────────────
|
|
107
|
+
|
|
108
|
+
registerComponent(DOM_SELECTOR, DOM_ATTRIBUTE, _component, 'ln-include', {
|
|
109
|
+
attributes: ATTRIBUTES
|
|
110
|
+
});
|
|
111
|
+
})();
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# ln-key
|
|
2
|
+
|
|
3
|
+
> Applied directly to an interactive control (`<button data-ln-key="Ctrl+S">`, `<input data-ln-key="Ctrl+K">`) or via an external key map (`<ul data-ln-key-modifier="Ctrl">`). It listens for global `keydown` events, normalizes modifier combinations, and activates target elements by calling `.click()` on buttons/links or `.focus()` on inputs and editable surfaces. It remains completely decoupled from other components, relying strictly on native browser event dispatch without storing synthetic shortcut state.
|
|
4
|
+
|
|
5
|
+
`ln-key` binds one or more keyboard shortcuts to the natural DOM interaction of an existing target. It is a behavior primitive: it does not know about `ln-modal`, `ln-router`, `ln-toggle`, or any other Ashlar component.
|
|
6
|
+
|
|
7
|
+
## Basic usage
|
|
8
|
+
|
|
9
|
+
```html
|
|
10
|
+
<button type="button" data-ln-key="Ctrl+S">
|
|
11
|
+
Save
|
|
12
|
+
</button>
|
|
13
|
+
|
|
14
|
+
<input
|
|
15
|
+
type="search"
|
|
16
|
+
name="search"
|
|
17
|
+
data-ln-key="Ctrl+K Meta+K"
|
|
18
|
+
>
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
- A `<button>` or `<a href>` is activated with `click()`.
|
|
22
|
+
- An `<input>`, `<textarea>`, `<select>`, or editable element is activated with `focus()`.
|
|
23
|
+
- Other elements have no inferred action.
|
|
24
|
+
|
|
25
|
+
The target can be separate from the shortcut declaration:
|
|
26
|
+
|
|
27
|
+
```html
|
|
28
|
+
<span
|
|
29
|
+
hidden
|
|
30
|
+
data-ln-key="Ctrl+K, Meta+K"
|
|
31
|
+
data-ln-key-target="#global-search"
|
|
32
|
+
></span>
|
|
33
|
+
|
|
34
|
+
<input id="global-search" type="search" name="search">
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
`data-ln-key-target` accepts a document-level CSS selector. The first matching element is used each time the shortcut is pressed, so a dynamically replaced target is resolved correctly.
|
|
38
|
+
|
|
39
|
+
## Grouped external shortcut map
|
|
40
|
+
|
|
41
|
+
An external map can add shortcuts to an existing application without modifying its controls:
|
|
42
|
+
|
|
43
|
+
```html
|
|
44
|
+
<ul data-ln-key-modifier="Ctrl">
|
|
45
|
+
<li data-ln-key-for="#save">S</li>
|
|
46
|
+
<li data-ln-key-for="#search">K</li>
|
|
47
|
+
<li data-ln-key-for="#print">P</li>
|
|
48
|
+
</ul>
|
|
49
|
+
|
|
50
|
+
<ul data-ln-key-modifier="Alt">
|
|
51
|
+
<li data-ln-key-for="#home">H</li>
|
|
52
|
+
<li data-ln-key-for="#users">U</li>
|
|
53
|
+
</ul>
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
The nearest `data-ln-key-modifier` ancestor supplies the modifier context. Each `data-ln-key-for` item supplies exactly one key through its trimmed text content and points to the target with a document-level CSS selector.
|
|
57
|
+
|
|
58
|
+
For example, `Ctrl` + `S` becomes `Ctrl+S`, resolves `#save`, and then uses the same `click()`/`focus()` inference as host mode. A modifier-less map is also valid for keys such as `Escape` or `Enter`.
|
|
59
|
+
|
|
60
|
+
## Shortcut syntax
|
|
61
|
+
|
|
62
|
+
Shortcut names are case-insensitive and modifier order is normalized:
|
|
63
|
+
|
|
64
|
+
```html
|
|
65
|
+
<button type="button" data-ln-key="ctrl+s">Save</button>
|
|
66
|
+
<button type="button" data-ln-key="Shift+Ctrl+P">Commands</button>
|
|
67
|
+
<button type="button" data-ln-key="Escape Enter Space">Action</button>
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Multiple shortcuts may be separated by whitespace or commas. Supported modifiers are `Ctrl`, `Alt`, `Shift`, and `Meta`. `Ctrl` is not automatically mapped to `Meta`; cross-platform shortcuts must declare both explicitly.
|
|
71
|
+
|
|
72
|
+
Common aliases such as `Esc`, `Return`, `Command`, `Cmd`, `Option`, and `Spacebar` are normalized.
|
|
73
|
+
|
|
74
|
+
## Editing protection
|
|
75
|
+
|
|
76
|
+
Shortcuts are ignored when the keyboard event starts inside an `input`, `textarea`, `select`, or editable element. This protects normal text editing and browser behavior.
|
|
77
|
+
|
|
78
|
+
Use the presence attribute only when a shortcut must remain active while editing:
|
|
79
|
+
|
|
80
|
+
```html
|
|
81
|
+
<button
|
|
82
|
+
type="button"
|
|
83
|
+
data-ln-key="Ctrl+S Meta+S"
|
|
84
|
+
data-ln-key-allow-input
|
|
85
|
+
>
|
|
86
|
+
Save
|
|
87
|
+
</button>
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
For an external map, the override can be placed on one item or inherited from the modifier container:
|
|
91
|
+
|
|
92
|
+
```html
|
|
93
|
+
<ul data-ln-key-modifier="Ctrl" data-ln-key-allow-input>
|
|
94
|
+
<li data-ln-key-for="#save">S</li>
|
|
95
|
+
</ul>
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Attributes
|
|
99
|
+
|
|
100
|
+
| Attribute | Type | Description |
|
|
101
|
+
|---|---|---|
|
|
102
|
+
| `data-ln-key` | Shortcut list | Required. One or more keyboard combinations. |
|
|
103
|
+
| `data-ln-key-target` | CSS selector | Optional target; defaults to the declaration host. |
|
|
104
|
+
| `data-ln-key-modifier` | Modifier combination | Optional external-map context such as `Ctrl` or `Ctrl+Shift`. |
|
|
105
|
+
| `data-ln-key-for` | CSS selector | External-map item target; the item's text content supplies the key. |
|
|
106
|
+
| `data-ln-key-allow-input` | Presence | Allows the shortcut while the event originates in an editing control. |
|
|
107
|
+
|
|
108
|
+
## Events
|
|
109
|
+
|
|
110
|
+
| Event | Cancelable | Timing | Detail |
|
|
111
|
+
|---|---:|---|---|
|
|
112
|
+
| `ln-key:before-trigger` | Yes | After a usable target is resolved, before browser behavior is prevented | `{ source, target, action, key, event }` |
|
|
113
|
+
| `ln-key:trigger` | No | After `click()` or `focus()` | `{ source, target, action, key, event }` |
|
|
114
|
+
|
|
115
|
+
Canceling `ln-key:before-trigger` leaves the original keyboard event untouched.
|
|
116
|
+
|
|
117
|
+
## Runtime rules
|
|
118
|
+
|
|
119
|
+
- `preventDefault()` runs only after a usable shortcut wins and the before-event is not canceled.
|
|
120
|
+
- Already-prevented, composing, and repeated keyboard events are ignored.
|
|
121
|
+
- Hidden, disabled, `aria-disabled="true"`, inert, missing, and non-interactive targets are skipped.
|
|
122
|
+
- Host declarations and external-map items share one DOM-order collision queue and one event contract.
|
|
123
|
+
- External-map modifier attributes and item text are resolved live, so markup updates do not require reinitialization.
|
|
124
|
+
- If multiple usable declarations match, the first one in DOM order wins. Debug mode emits a duplicate warning.
|
|
125
|
+
- Native `Enter`/`Space` activation is left to the browser when the matching button or link is already the keyboard event target.
|
|
126
|
+
- One shared document listener serves all instances and is removed when the final instance is destroyed.
|
|
127
|
+
|
|
128
|
+
## Build
|
|
129
|
+
|
|
130
|
+
The source is `src/ln-key.js`. The standard Ashlar build produces the standalone `ln-key.js` bundle automatically and includes the component in the master bundle through `js/index.js`.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
@use '../../theme/config/mixins' as *;
|
|
2
|
+
|
|
3
|
+
[data-ln-debug] {
|
|
4
|
+
// 1. Shortcut String Check: shortcut combination string cannot be empty
|
|
5
|
+
[data-ln-key=""] {
|
|
6
|
+
@include dev-inline-error("data-ln-key shortcut combination cannot be empty");
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// 2. Map Target Check: map item target selector cannot be empty
|
|
10
|
+
[data-ln-key-for=""] {
|
|
11
|
+
@include dev-inline-error("data-ln-key-for target selector cannot be empty");
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// 3. Separate Declaration Target Check: data-ln-key-target selector cannot be empty
|
|
15
|
+
[data-ln-key-target=""] {
|
|
16
|
+
@include dev-inline-error("data-ln-key-target selector cannot be empty");
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(){"use strict";function q(){return typeof window>"u"?!1:window.lnDebug===!0||window.lnCore&&window.lnCore._debugSink?!0:typeof document<"u"&&document.body?document.body.hasAttribute("data-ln-debug")||document.body.querySelector("[data-ln-debug]")!==null:!1}function D(e){if(typeof window>"u")return!1;if(window.lnDebug===!0)return!0;if(window.lnCore&&window.lnCore._debugIsContained)return e?window.lnCore._debugIsContained(e):window.lnCore._debugSink!==null;if(e&&e.closest){const t=e.closest("[data-ln-debug]");return!(!t||typeof document<"u"&&t===document.documentElement)}return typeof document<"u"&&document.body?document.body.hasAttribute("data-ln-debug"):!1}if(typeof window<"u"&&(window.lnCore=window.lnCore||{},!window.lnCore._warnBound)){window.lnCore._warnBound=!0;const e=console.warn;console.warn=function(...t){if(typeof t[0]=="string"&&(t[0].startsWith("[ln-")||t[0].startsWith("[lnCore"))){let r=null;for(let o=1;o<t.length;o++)if(t[o]&&t[o].nodeType===1){r=t[o];break}if(!D(r))return}e.apply(console,t)}}function K(e,t,n){const r=n||{};window.lnCore._debugSink&&window.lnCore._debugSink("event",t,e,r),e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:r}))}function Y(e,t,n){const r=n||{};window.lnCore._debugSink&&window.lnCore._debugSink("event",t,e,r);const o=new CustomEvent(t,{bubbles:!0,cancelable:!0,detail:r});return e.dispatchEvent(o),o}function k(e,t){if(!document.body){document.addEventListener("DOMContentLoaded",function(){k(e,t)}),console.warn("["+t+'] Script loaded before <body> — add "defer" to your <script> tag');return}e()}function Z(e){return!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)}function ee(e){if(!e)return!1;if(typeof e.closest=="function")return!!e.closest('input, textarea, select, [contenteditable]:not([contenteditable="false"])');const t=String(e.tagName||"").toLowerCase();return t==="input"||t==="textarea"||t==="select"||!!e.isContentEditable}function te(e){return!!(!e||e.disabled||typeof e.getAttribute=="function"&&e.getAttribute("aria-disabled")==="true"||typeof e.closest=="function"&&e.closest("[inert]"))}function ne(e,t){return!e||!document.contains(e)||te(e)||t&&typeof e[t]!="function"?!1:Z(e)}const U={};function re(e,t){U[e]=t}function oe(e){return U[e]||{ingress:t=>t,egress:t=>t}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerDataMapper=re,window.lnCore.getDataMapper=oe);function ie(){typeof window>"u"||(window.lnCore=window.lnCore||{},!window.lnCore._localeObserverBound&&(window.lnCore._localeObserverBound=!0,k(function(){new MutationObserver(function(){K(document,"ln-core:locale-change",{})}).observe(document.documentElement,{attributes:!0,attributeFilter:["lang"],subtree:!0})},"ln-core")))}const N={};function se(e,t){if(!e||typeof t!="object")return;const n=e.toLowerCase().split("-")[0];N[n]=t}function le(e){if(!e)return null;const t=e.toLowerCase().split("-")[0];return N[t]||null}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.registerLocaleFallback=se,window.lnCore.getLocaleFallback=le,window.lnCore.ensureLocaleObserver=ie);const I={};function ce(e,t){I[e]||(I[e]=document.querySelector('[data-ln-template="'+e+'"]'));const n=I[e];return n?n.content.cloneNode(!0):(console.warn("["+(t||"ln-core")+'] Template "'+e+'" not found'),null)}function W(e,t){if(!e||!t)return e;const n=e.querySelectorAll("[data-ln-field]");for(let s=0;s<n.length;s++){const c=n[s],l=c.getAttribute("data-ln-field");t[l]!=null&&(c.textContent=t[l])}const r=e.querySelectorAll("[data-ln-attr]");for(let s=0;s<r.length;s++){const c=r[s],l=c.getAttribute("data-ln-attr").split(",");for(let a=0;a<l.length;a++){const d=l[a].trim().split(":");if(d.length!==2)continue;const f=d[0].trim(),h=d[1].trim();t[h]!=null&&c.setAttribute(f,t[h])}}const o=e.querySelectorAll("[data-ln-show]");for(let s=0;s<o.length;s++){const c=o[s],l=c.getAttribute("data-ln-show");l in t&&c.classList.toggle("hidden",!t[l])}const i=e.querySelectorAll("[data-ln-class]");for(let s=0;s<i.length;s++){const c=i[s],l=c.getAttribute("data-ln-class").split(",");for(let a=0;a<l.length;a++){const d=l[a].trim().split(":");if(d.length!==2)continue;const f=d[0].trim(),h=d[1].trim();h in t&&c.classList.toggle(f,!!t[h])}}return e}function ue(e,t){e.matches&&e.matches("[data-ln-form], [data-ln-fillable]")&&(window.lnCore._debugSink&&window.lnCore._debugSink("event","ln-fill",e,t??null),e.dispatchEvent(new CustomEvent("ln-fill",{detail:t??null,bubbles:!0})));const n=e.querySelectorAll("[data-ln-form], [data-ln-fillable]");for(let r=0;r<n.length;r++)window.lnCore._debugSink&&window.lnCore._debugSink("event","ln-fill",n[r],t??null),n[r].dispatchEvent(new CustomEvent("ln-fill",{detail:t??null,bubbles:!0}));return e}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore._fillBound||(window.lnCore._fillBound=!0,document.addEventListener("ln-fill",function(e){if(!(!e.target.matches||!e.target.matches("[data-ln-fillable]")))if(e.detail)W(e.target,e.detail);else{const t=e.target.querySelectorAll("[data-ln-field]");for(let n=0;n<t.length;n++)t[n].textContent=""}})));function j(e,t){if(!e||!t)return e;const n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(;n.nextNode();){const i=n.currentNode;i.textContent.indexOf("{{")!==-1&&(i.textContent=i.textContent.replace(/\{\{\s*(\w+)\s*\}\}/g,function(s,c){return t[c]!==void 0?t[c]:""}))}const r=function(i,s){return t[s]!==void 0?t[s]:""},o=Array.from(e.querySelectorAll("*"));e.nodeType===1&&o.push(e);for(let i=0;i<o.length;i++){const s=o[i],c=s.attributes;for(let l=0;l<c.length;l++){const a=c[l];a.value.indexOf("{{")!==-1&&s.setAttribute(a.name,a.value.replace(/\{\{\s*(\w+)\s*\}\}/g,r))}}return e}function ae(e,t,n,r,o,i){const s={};for(let l=0;l<e.children.length;l++){const a=e.children[l],d=a.getAttribute("data-ln-render-key");d&&(s[d]=a)}const c=document.createDocumentFragment();for(let l=0;l<t.length;l++){const a=t[l],d=String(r(a));let f=s[d];if(f)o(f,a,l);else{const h=ce(n,i);if(!h||(j(h,a),f=h.firstElementChild,!f))continue;f.setAttribute("data-ln-render-key",d),o(f,a,l)}c.appendChild(f)}e.textContent="",e.appendChild(c)}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.fillTemplate=j,window.lnCore.fill=W,window.lnCore.lnFill=ue,window.lnCore.renderList=ae);function V(e,t,n,r,o){if(!e||t===null)return!0;const i=r||"ln-component",s=e.type;if(s==="trigger"||s==="marker"||s==="string"||s==="list"||!s||t===""&&e.fallback!==void 0)return!0;const c=l=>{o?console.warn(l,o):console.warn(l)};if(s==="boolean"){const l=t.trim().toLowerCase();return l!==""&&l!=="true"&&l!=="false"&&l!=="1"&&l!=="0"?(c(`[${i}] Invalid value "${t}" for boolean attribute "${n}". Allowed: "true", "false", or presence-only.`),!1):!0}if(s==="enum"){const l=e.values||[];return l.includes(t)?!0:(c(`[${i}] Invalid value "${t}" for attribute "${n}". Allowed: ${l.join(", ")}. Fallback: "${e.fallback}".`),!1)}if(s==="integer"){if(!/^-?\d+$/.test(t))return c(`[${i}] Invalid integer "${t}" for attribute "${n}". Fallback: ${e.fallback}.`),!1;const l=parseInt(t,10);return e.min!==void 0&&l<e.min?(c(`[${i}] Value ${l} for attribute "${n}" is less than min (${e.min}).`),!1):e.max!==void 0&&l>e.max?(c(`[${i}] Value ${l} for attribute "${n}" is greater than max (${e.max}).`),!1):!0}if(s==="float")return isNaN(Number(t))?(c(`[${i}] Invalid float "${t}" for attribute "${n}". Fallback: ${e.fallback}.`),!1):!0;if(s==="json")try{return JSON.parse(t),!0}catch(l){return c(`[${i}] Invalid JSON for attribute "${n}": ${l.message}. Fallback: ${e.fallback}.`),!1}return!0}function fe(e){const t={};for(const n in e){const r=e[n];r&&r.effect&&(t[n]=r.effect)}return Object.keys(t).length?t:null}function de(e){if(e.onAttrChange&&!e.declared)return null;const t=new Set;if(e.effects)for(const n in e.effects)t.add(n);if(e.onAttrChange&&e.declared)for(const n of e.declared)t.add(n);return t}function R(e,t,n,r){if(e.nodeType!==1)return;const i=t.indexOf("[")!==-1||t.indexOf(".")!==-1||t.indexOf("#")!==-1?t:"["+t+"]",s=Array.from(e.querySelectorAll(i));e.matches&&e.matches(i)&&s.push(e);for(const c of s)if(!c[n]){window.lnCore._persistSink&&c.hasAttribute("data-ln-persist")&&window.lnCore._persistSink(c,t);try{c[n]=new r(c)}catch(l){console.error("["+n+"] init failed",c,l)}}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore._bootHolds=window.lnCore._bootHolds||0,window.lnCore._bootQueue=window.lnCore._bootQueue||[]);function we(){return typeof window<"u"&&window.lnCore&&window.lnCore._bootHolds||0}function he(e){typeof window<"u"?(window.lnCore=window.lnCore||{},window.lnCore._bootHolds=window.lnCore._bootHolds||0,window.lnCore._bootQueue=window.lnCore._bootQueue||[],window.lnCore._bootHolds>0?window.lnCore._bootQueue.push(e):setTimeout(e,0)):e()}function H(){window.lnCore=window.lnCore||{};const e=window.lnCore._attrRegistry=window.lnCore._attrRegistry||{byAttr:new Map,reactive:[],persist:[]};return e.byReactive=e.byReactive||new Map,e.reactiveWildcard=e.reactiveWildcard||[],e}function pe(e){const t=H(),n=e.observed||[];for(let r=0;r<n.length;r++){const o=n[r];t.byAttr.has(o)||t.byAttr.set(o,[]),t.byAttr.get(o).push(e)}if(t.byDeclaredAttr=t.byDeclaredAttr||new Map,e.attributes)for(const r in e.attributes){t.byDeclaredAttr.has(r)||t.byDeclaredAttr.set(r,[]);const o=t.byDeclaredAttr.get(r);o.some(i=>i.componentTag===e.componentTag)||o.push({spec:e.attributes[r],componentTag:e.componentTag})}if(e.onAttrChange||e.effects){t.reactive.push(e);const r=de(e);if(r===null)t.reactiveWildcard.push(e);else for(const o of r)t.byReactive.has(o)||t.byReactive.set(o,[]),t.byReactive.get(o).push(e)}e.persist&&t.persist.push(e)}function P(e,t,n,r){for(let o=0;o<e.length;o++){const i=e[o];if(!t[i.attribute])continue;const s=i.effects&&i.effects[n];s?s(t,n,r):i.onAttrChange&&(!i.declared||i.declared.has(n))&&i.onAttrChange(t,n,r)}}function be(e){const t=e.target,n=e.attributeName;if(e.oldValue===t.getAttribute(n))return;const r=H(),o=r.byAttr.get(n);if(q()&&r.byDeclaredAttr&&r.byDeclaredAttr.has(n)&&D(t)){const i=r.byDeclaredAttr.get(n),s=t.getAttribute(n);for(let c=0;c<i.length;c++)V(i[c].spec,s,n,i[c].componentTag,t)}if(window.lnCore._debugSink&&(n.indexOf("data-ln-")===0||o)&&window.lnCore._debugSink("attr",n,t,{oldValue:e.oldValue,newValue:t.getAttribute(n)}),n.indexOf("data-ln-")===0){const i=r.byReactive.get(n);i&&P(i,t,n,e.oldValue),r.reactiveWildcard.length&&P(r.reactiveWildcard,t,n,e.oldValue)}if(o)for(let i=0;i<o.length;i++){const s=o[i];if(s.handler){s.handler(t,n,e.oldValue);continue}s.onAttributeChange&&t[s.attribute]?s.onAttributeChange(t,n):(R(t,s.selector,s.attribute,s.ComponentFn),s.onInit&&s.onInit(t))}}function ge(){window.lnCore=window.lnCore||{},!window.lnCore._attrObserverBound&&(window.lnCore._attrObserverBound=!0,k(function(){new MutationObserver(function(t){for(let n=0;n<t.length;n++)try{be(t[n])}catch(r){console.error("[ln-core] mutation handler failed",t[n].target,r)}}).observe(document.body,{attributes:!0,subtree:!0,attributeOldValue:!0})},"ln-core"))}function Q(){return window.lnCore=window.lnCore||{},window.lnCore._lifecycleRegistry=window.lnCore._lifecycleRegistry||[]}function ye(e){const t=Q();if(t.length){if(e.target)for(let n=0;n<t.length;n++){const r=t[n];if(r.onSubtreeChange){const o=r.query,i=e.target.nodeType===1?e.target.matches(o)?e.target:e.target.closest(o):e.target.parentElement?e.target.parentElement.closest(o):null;i&&r.onSubtreeChange(i,e)}}for(let n=0;n<e.addedNodes.length;n++){const r=e.addedNodes[n];if(r.nodeType===1)for(let o=0;o<t.length;o++){const i=t[o];R(r,i.selector,i.attribute,i.ComponentFn),i.onInit&&i.onInit(r)}}for(let n=0;n<e.removedNodes.length;n++){const r=e.removedNodes[n];if(r.nodeType===1)for(let o=0;o<t.length;o++){const i=t[o],s=i.query,c=Array.from(r.querySelectorAll(s));r.matches&&r.matches(s)&&c.push(r);for(let l=0;l<c.length;l++){const a=c[l];if(!document.contains(a)){const d=a[i.attribute];if(d&&typeof d.destroy=="function")try{d.destroy()}catch(f){console.error("["+i.attribute+"] destroy failed",a,f)}delete a[i.attribute]}}}}}}function Ce(){window.lnCore=window.lnCore||{},!window.lnCore._lifecycleObserverBound&&(window.lnCore._lifecycleObserverBound=!0,k(function(){new MutationObserver(function(t){for(let n=0;n<t.length;n++){const r=t[n];if(r.type==="childList")try{ye(r)}catch(o){console.error("[ln-core] lifecycle handler failed",r.target,o)}}}).observe(document.body,{childList:!0,subtree:!0})},"ln-core"))}function z(e,t,n,r,o={}){const i=o.extraAttributes||[],s=o.onAttributeChange||null,c=o.onSubtreeChange||null,l=o.onInit||null,a=o.onAttrChange||null,d=o.effects||null,f=o.attributes||null,h=f?fe(f):d,S=f?new Set(Object.keys(f)):null,T=o.persist||null;function g(C){const b=C||document.body;if(R(b,e,t,n),f&&q())for(const p in f){const v=f[p],m=Array.from(b.querySelectorAll("["+p+"]"));b.matches&&b.matches("["+p+"]")&&m.push(b);for(let A=0;A<m.length;A++){const E=m[A];D(E)&&V(v,E.getAttribute(p),p,r,E)}}l&&l(b)}const y=[];if(e.indexOf("[")!==-1){const C=/\[([\w-]+)/g;let b;for(;(b=C.exec(e))!==null;)y.push(b[1])}else y.push(e);pe({selector:e,attribute:t,componentTag:r,attributes:f,ComponentFn:n,onInit:l,observed:y.concat(i),onAttributeChange:s,onAttrChange:a,effects:h,declared:S,persist:T}),ge();const u=e.indexOf("[")!==-1||e.indexOf(".")!==-1||e.indexOf("#")!==-1?e:"["+e+"]";Q().push({selector:e,attribute:t,ComponentFn:n,onInit:l,onSubtreeChange:c,query:u}),Ce(),window[t]=g;function w(){we()>0?he(function(){g(document.body)}):g(document.body)}return document.readyState==="loading"?document.addEventListener("DOMContentLoaded",w):w(),g}function G(e){return(e||"").replace(/^#/,"")}function $(e){const t=e===void 0?location.hash:e,n={},r=G(t);if(!r)return n;const o=r.split("&");for(let i=0;i<o.length;i++){const s=o[i];if(!s)continue;const c=s.indexOf(":"),l=c>-1?s.slice(0,c):s,a=c>-1?s.slice(c+1):"";if(l)try{n[l]=decodeURIComponent(a)}catch{n[l]=a}}return n}function me(e){if(!e)return null;const t=$();return e in t?t[e]:null}function Ae(e,t){if(!e)return;const n=$();t==null?delete n[e]:n[e]=String(t);const o=Object.keys(n).map(function(i){const s=n[i];return s===""?i:i+":"+encodeURIComponent(s)}).join("&");G(location.hash)!==o&&(location.hash=o)}function _e(e){return e.button===1||e.ctrlKey||e.metaKey||e.shiftKey?!1:(e.preventDefault(),!0)}function ke(e,t){if(!e||!e.hasAttribute("data-ln-hash"))return null;const n=e.getAttribute("data-ln-hash");if(n&&n.trim()!=="")return n.trim();const r=e.getAttribute("data-ln-sort")||e.getAttribute("data-ln-search-for")||e.getAttribute("data-ln-search")||e.getAttribute("data-ln-filter")||e.id;return r?t?r+"-"+t:r:t||null}function Se(e,t){return!t||t==="none"||e===null||e===void 0?null:String(e)+"."+t}function Te(e){return!e||typeof e!="string"?null:e.endsWith(".asc")?{fieldOrColumn:e.slice(0,-4),direction:"asc"}:e.endsWith(".desc")?{fieldOrColumn:e.slice(0,-5),direction:"desc"}:null}function ve(e,t){return!e||!Array.isArray(t)||t.length===0?null:e+":"+t.map(encodeURIComponent).join(",")}function Ee(e){if(!e||typeof e!="string")return null;const t=e.indexOf(":");if(t===-1)return null;const n=e.slice(0,t),r=e.slice(t+1),o=r?r.split(",").map(function(i){try{return decodeURIComponent(i)}catch{return i}}).filter(Boolean):[];return{key:n,values:o}}typeof window<"u"&&(window.lnCore=window.lnCore||{},window.lnCore.hashParse=$,window.lnCore.hashGet=me,window.lnCore.hashSet=Ae,window.lnCore.hashLinkClick=_e,window.lnCore.resolveHashNamespace=ke,window.lnCore.hashSortEncode=Se,window.lnCore.hashSortDecode=Te,window.lnCore.hashFilterEncode=ve,window.lnCore.hashFilterDecode=Ee);const _=["Ctrl","Alt","Shift","Meta"],Oe={alt:"Alt",control:"Ctrl",ctrl:"Ctrl",meta:"Meta",command:"Meta",cmd:"Meta",option:"Alt",shift:"Shift",esc:"Escape",escape:"Escape",space:"Space",spacebar:"Space",enter:"Enter",return:"Enter",tab:"Tab",backspace:"Backspace",delete:"Delete",del:"Delete",insert:"Insert",home:"Home",end:"End",pageup:"PageUp",pagedown:"PageDown",arrowup:"ArrowUp",up:"ArrowUp",arrowdown:"ArrowDown",down:"ArrowDown",arrowleft:"ArrowLeft",left:"ArrowLeft",arrowright:"ArrowRight",right:"ArrowRight"};function J(e){if(e===" ")return"Space";const t=String(e||"").trim();if(!t)return"";const n=Oe[t.toLowerCase()];return n||(t.length===1||/^f\d{1,2}$/i.test(t)?t.toUpperCase():t.charAt(0).toUpperCase()+t.slice(1))}function X(e){const t=String(e||"").replace(/\s*\+\s*/g,"+").trim();if(!t)return"";const n=t.split("+"),r=new Set;let o="";for(let s=0;s<n.length;s++){const c=J(n[s]);if(!c)return"";if(_.indexOf(c)!==-1){r.add(c);continue}if(o)return"";o=c}if(!o)return"";const i=[];for(let s=0;s<_.length;s++)r.has(_[s])&&i.push(_[s]);return i.push(o),i.join("+")}function xe(e){const t=String(e||"").replace(/\s*\+\s*/g,"+").trim();if(!t)return[];const n=t.split(/[\s,]+/),r=[];for(let o=0;o<n.length;o++){const i=X(n[o]);i&&r.indexOf(i)===-1&&r.push(i)}return r}function Le(e,t){const n=String(t||"").trim();if(!n||/[\s,]/.test(n))return"";const r=String(e||"").replace(/\s*\+\s*/g,"+").trim();return/[\s,]/.test(r)?"":X(r?r+"+"+n:n)}function De(e){if(!e)return"";const t=J(e.key);if(!t||_.indexOf(t)!==-1)return"";const n=[];return e.ctrlKey&&n.push("Ctrl"),e.altKey&&n.push("Alt"),e.shiftKey&&n.push("Shift"),e.metaKey&&n.push("Meta"),n.push(t),n.join("+")}function Ie(e){if(!e||!e.tagName)return null;const t=String(e.tagName).toLowerCase();if(t==="button"||t==="a"&&e.hasAttribute&&e.hasAttribute("href"))return"click";if(t==="input"||t==="textarea"||t==="select"||e.isContentEditable)return"focus";if(e.hasAttribute&&e.hasAttribute("contenteditable")){const n=e.getAttribute("contenteditable");if(n===""||String(n).toLowerCase()!=="false")return"focus"}return null}function Re(e,t,n,r){if(!e||!t||n!=="click"||e.target!==t||e.ctrlKey||e.altKey||e.shiftKey||e.metaKey)return!1;const o=String(t.tagName||"").toLowerCase();return o==="button"?r==="Enter"||r==="Space":o==="a"&&t.hasAttribute&&t.hasAttribute("href")&&r==="Enter"}(function(){const e="data-ln-key",t="lnKey",n="data-ln-key-target",r="data-ln-key-allow-input",o="data-ln-key-modifier",i="data-ln-key-for",s="lnKeyFor";if(window[t]!==void 0)return;function c(u){const w=u[t];if(w){if(!u.hasAttribute(e)){w.destroy();return}w.sync()}}function l(u){const w=u[s];w&&!u.hasAttribute(i)&&w.destroy()}const a={"data-ln-key":{type:"string",effect:c,description:"Keyboard shortcut combination (e.g. meta+k, ctrl+s)"},"data-ln-key-target":{type:"string",effect:c,description:"Target element selector or ID to receive synthetic click or focus"},"data-ln-key-allow-input":{type:"boolean",effect:c,description:"Permits shortcut execution even when focused inside an editable input"}},d={"data-ln-key-for":{type:"string",effect:l,description:"Target element ID that this shortcut badge is displayed for"},"data-ln-key-modifier":{type:"string",description:"Platform modifier text representation override"}},f=new Set;let h=null;function S(){h||(h=function(u){if(u.defaultPrevented||u.isComposing||u.repeat)return;const w=De(u);if(!w)return;const C=ee(u.target),b=document.querySelectorAll("["+e+"], ["+i+"]");let p=null,v=!1,m=!1;for(let B=0;B<b.length;B++){const F=b[B],O=F[t]||F[s];if(!O||!O.matches(w)||C&&!O.allowsInput())continue;const x=O.resolveTarget(),L=Ie(x);if(!(!L||!ne(x,L))){if(Re(u,x,L,w)){m=!0;continue}p?v=!0:p={host:F,target:x,action:L}}}if(m||!p)return;v&&console.warn('[ln-key] Duplicate active shortcut "'+w+'"; first DOM match wins.');const A={source:p.host,target:p.target,action:p.action,key:w,event:u};Y(p.host,"ln-key:before-trigger",A).defaultPrevented||(u.preventDefault(),p.target[p.action](),K(p.host,"ln-key:trigger",A))},document.addEventListener("keydown",h))}function T(){f.size>0||!h||(document.removeEventListener("keydown",h),h=null)}function g(u){return this.dom=u,this.shortcuts=[],f.add(this),this.sync(),S(),this}g.prototype.sync=function(){this.shortcuts=xe(this.dom.getAttribute(e))},g.prototype.matches=function(u){return this.shortcuts.indexOf(u)!==-1},g.prototype.allowsInput=function(){return this.dom.hasAttribute(r)},g.prototype.resolveTarget=function(){const u=this.dom.getAttribute(n);return u?M(u,n):this.dom},g.prototype.destroy=function(){this.dom[t]&&(f.delete(this),delete this.dom[t],T())};function y(u){return this.dom=u,f.add(this),S(),this}y.prototype._modifierContext=function(){return this.dom.closest("["+o+"]")},y.prototype.shortcut=function(){const u=this._modifierContext(),w=u?u.getAttribute(o):"";return Le(w,this.dom.textContent)},y.prototype.matches=function(u){return this.shortcut()===u},y.prototype.allowsInput=function(){if(this.dom.hasAttribute(r))return!0;const u=this._modifierContext();return!!(u&&u.hasAttribute(r))},y.prototype.resolveTarget=function(){return M(this.dom.getAttribute(i),i)},y.prototype.destroy=function(){this.dom[s]&&(f.delete(this),delete this.dom[s],T())};function M(u,w){if(!u)return null;try{const C=document.querySelector(u);return C||console.warn("[ln-key] Target not found for "+w+' selector "'+u+'".'),C}catch{return console.warn("[ln-key] Invalid "+w+' selector "'+u+'".'),null}}z(e,t,g,"ln-key",{attributes:a}),z(i,s,y,"ln-key-for",{attributes:d})})()})();
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$comment": "This file is partly generated. The $comment, component, generator, and each attribute's direction, sources, type, values, fallback, and description keys are owned by the generator and synchronized from JS source code. All other keys are preserved and safe to hand-author. Regenerate with `npm run sync:ln-schemas`.",
|
|
3
|
+
"component": "ln-key",
|
|
4
|
+
"generator": "scripts/sync-ln-schemas.mjs",
|
|
5
|
+
"attributes": {
|
|
6
|
+
"data-ln-debug": {
|
|
7
|
+
"direction": null,
|
|
8
|
+
"sources": [
|
|
9
|
+
"ln-key-dev.scss"
|
|
10
|
+
]
|
|
11
|
+
},
|
|
12
|
+
"data-ln-key": {
|
|
13
|
+
"direction": "author",
|
|
14
|
+
"sources": [
|
|
15
|
+
"ln-key-dev.scss",
|
|
16
|
+
"src/ln-key.js"
|
|
17
|
+
],
|
|
18
|
+
"type": "string",
|
|
19
|
+
"description": "Keyboard shortcut combination (e.g. meta+k, ctrl+s)"
|
|
20
|
+
},
|
|
21
|
+
"data-ln-key-allow-input": {
|
|
22
|
+
"direction": "author",
|
|
23
|
+
"sources": [
|
|
24
|
+
"src/ln-key.js"
|
|
25
|
+
],
|
|
26
|
+
"type": "boolean",
|
|
27
|
+
"description": "Permits shortcut execution even when focused inside an editable input"
|
|
28
|
+
},
|
|
29
|
+
"data-ln-key-for": {
|
|
30
|
+
"direction": "author",
|
|
31
|
+
"sources": [
|
|
32
|
+
"ln-key-dev.scss",
|
|
33
|
+
"src/ln-key.js"
|
|
34
|
+
],
|
|
35
|
+
"type": "string",
|
|
36
|
+
"description": "Target element ID that this shortcut badge is displayed for"
|
|
37
|
+
},
|
|
38
|
+
"data-ln-key-modifier": {
|
|
39
|
+
"direction": "author",
|
|
40
|
+
"sources": [
|
|
41
|
+
"src/ln-key.js"
|
|
42
|
+
],
|
|
43
|
+
"type": "string",
|
|
44
|
+
"description": "Platform modifier text representation override"
|
|
45
|
+
},
|
|
46
|
+
"data-ln-key-target": {
|
|
47
|
+
"direction": "author",
|
|
48
|
+
"sources": [
|
|
49
|
+
"ln-key-dev.scss",
|
|
50
|
+
"src/ln-key.js"
|
|
51
|
+
],
|
|
52
|
+
"type": "string",
|
|
53
|
+
"description": "Target element selector or ID to receive synthetic click or focus"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|