@livenetworks/ashlar 1.6.1 → 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/{js → components}/ln-confirm/README.md +69 -18
- 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 -171
- 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/_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,652 @@
|
|
|
1
|
+
import { buildDict, cloneTemplateScoped, dispatch, dispatchCancelable, fill, getLocale, registerComponent, defineAttrs, attrSpec, attrStr, attrInt } from '../../ln-core';
|
|
2
|
+
import { formatFileSize, getFileExtension, isFileTypeAllowed, parseAcceptExtensions } from './upload-model.js';
|
|
3
|
+
|
|
4
|
+
(function () {
|
|
5
|
+
const DOM_SELECTOR = 'data-ln-upload';
|
|
6
|
+
const DOM_ATTRIBUTE = 'lnUpload';
|
|
7
|
+
const DEFAULT_FILE_FIELD = 'file';
|
|
8
|
+
const DEFAULT_IDS_FIELD = 'file_ids[]';
|
|
9
|
+
|
|
10
|
+
if (window[DOM_ATTRIBUTE] !== undefined) return;
|
|
11
|
+
|
|
12
|
+
// ─── Attribute Contract (SSOT) ──────────────────────────
|
|
13
|
+
const ATTRIBUTES = {
|
|
14
|
+
'data-ln-upload': { prop: 'uploadUrl', read: attrStr, type: 'string', fallback: '', description: 'Endpoint URL for file uploads' },
|
|
15
|
+
'data-ln-upload-accept': { type: 'string', description: 'Comma-separated list of allowed file extensions or MIME types' },
|
|
16
|
+
'data-ln-upload-delete': { prop: 'deleteUrlPattern', read: attrStr, type: 'string', fallback: '', description: 'Endpoint URL pattern for deleting uploaded files' },
|
|
17
|
+
'data-ln-upload-max-size': { prop: 'maxSize', read: attrInt, type: 'integer', fallback: 0, min: 0, description: 'Maximum allowed file size in bytes (0 for unlimited)' },
|
|
18
|
+
'data-ln-upload-max-files': { prop: 'maxFiles', read: attrInt, type: 'integer', fallback: 0, min: 0, description: 'Maximum number of files allowed in upload queue (0 for unlimited)' },
|
|
19
|
+
'data-ln-upload-file-field': { prop: 'fileFieldName', read: attrStr, type: 'string', fallback: DEFAULT_FILE_FIELD, description: 'Form data field name used for file payloads' },
|
|
20
|
+
'data-ln-upload-ids-field': { prop: 'idsFieldName', read: attrStr, type: 'string', fallback: DEFAULT_IDS_FIELD, description: 'Form field name for submitting uploaded file IDs' },
|
|
21
|
+
'data-ln-upload-dict': { type: 'string', description: 'Dictionary key prefix mapping for translatable upload messages' },
|
|
22
|
+
'data-ln-upload-zone': { type: 'marker', description: 'Designates container as dropzone for drag-and-drop file uploads' },
|
|
23
|
+
'data-ln-upload-list': { type: 'marker', description: 'Container element holding rendered upload items' },
|
|
24
|
+
'data-ln-upload-item': { type: 'marker', description: 'Container element for an individual file upload item' },
|
|
25
|
+
'data-ln-upload-action': { type: 'enum', values: ['remove', 'retry'], description: 'Action button within upload item' },
|
|
26
|
+
'data-ln-upload-state': { type: 'enum', values: ['ready', 'dragover', 'pending', 'uploading', 'success', 'error'], description: 'Runtime status of dropzone or individual upload item' },
|
|
27
|
+
'data-ln-upload-id': { type: 'string', description: 'Server-assigned file identifier for completed upload' },
|
|
28
|
+
'data-ln-upload-local-id': { type: 'string', description: 'Client-generated unique ID for tracking file item in DOM' },
|
|
29
|
+
'data-ln-upload-size': { type: 'integer', min: 0, description: 'File size in bytes' },
|
|
30
|
+
'data-ln-upload-ext': { type: 'string', description: 'Normalized file extension' }
|
|
31
|
+
};
|
|
32
|
+
const ATTR_SPEC = attrSpec(ATTRIBUTES);
|
|
33
|
+
|
|
34
|
+
function _formatSize(bytes, locale, dict) {
|
|
35
|
+
return formatFileSize(bytes, locale, dict);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function _getCsrfToken() {
|
|
39
|
+
const meta = document.querySelector('meta[name="csrf-token"]');
|
|
40
|
+
return meta ? meta.getAttribute('content') : '';
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// ─── Component Constructor ─────────────────────────────
|
|
44
|
+
|
|
45
|
+
function _component(dom) {
|
|
46
|
+
this.dom = dom;
|
|
47
|
+
defineAttrs(this, dom, ATTR_SPEC);
|
|
48
|
+
this.dict = buildDict(dom, 'data-ln-upload-dict');
|
|
49
|
+
this.locale = getLocale(dom);
|
|
50
|
+
|
|
51
|
+
this.zone = dom.querySelector('[data-ln-upload-zone]') || dom;
|
|
52
|
+
this.list = dom.querySelector('[data-ln-upload-list]');
|
|
53
|
+
this.input = dom.querySelector('input[type="file"]');
|
|
54
|
+
|
|
55
|
+
if (!this.input) {
|
|
56
|
+
console.warn('[ln-upload] Missing <input type="file"> in container:', dom);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const acceptStr = dom.getAttribute('data-ln-upload-accept') || (this.input ? this.input.getAttribute('accept') : '');
|
|
60
|
+
this.allowedExts = parseAcceptExtensions(acceptStr);
|
|
61
|
+
|
|
62
|
+
this.uploadedFiles = new Map();
|
|
63
|
+
this.fileIdCounter = 0;
|
|
64
|
+
this._dragDepth = 0;
|
|
65
|
+
|
|
66
|
+
this._hydrate();
|
|
67
|
+
this._bindEvents();
|
|
68
|
+
|
|
69
|
+
return this;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// ─── Hydration of Pre-rendered SSR Files ────────────────
|
|
73
|
+
|
|
74
|
+
_component.prototype._hydrate = function () {
|
|
75
|
+
const self = this;
|
|
76
|
+
if (!this.list) return;
|
|
77
|
+
|
|
78
|
+
const items = this.list.querySelectorAll('[data-ln-upload-item]');
|
|
79
|
+
for (let i = 0; i < items.length; i++) {
|
|
80
|
+
const item = items[i];
|
|
81
|
+
const serverId = item.getAttribute('data-ln-upload-id');
|
|
82
|
+
const localId = 'file-' + (++self.fileIdCounter);
|
|
83
|
+
|
|
84
|
+
item.setAttribute('data-ln-upload-local-id', localId);
|
|
85
|
+
|
|
86
|
+
const nameEl = item.querySelector('[data-ln-field="name"]');
|
|
87
|
+
const sizeEl = item.querySelector('[data-ln-field="sizeText"]');
|
|
88
|
+
const rawSize = item.getAttribute('data-ln-upload-size');
|
|
89
|
+
const parsedSize = rawSize ? parseInt(rawSize, 10) : null;
|
|
90
|
+
|
|
91
|
+
self.uploadedFiles.set(localId, {
|
|
92
|
+
serverId: serverId || null,
|
|
93
|
+
name: nameEl ? nameEl.textContent.trim() : '',
|
|
94
|
+
size: (parsedSize !== null && !isNaN(parsedSize)) ? parsedSize : (sizeEl ? sizeEl.textContent.trim() : '')
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Also discover any pre-existing hidden inputs that might not have matching list items
|
|
99
|
+
const hiddenInputs = this.dom.querySelectorAll('input[type="hidden"]');
|
|
100
|
+
for (let i = 0; i < hiddenInputs.length; i++) {
|
|
101
|
+
const input = hiddenInputs[i];
|
|
102
|
+
if (input.name === self.idsFieldName && input.value) {
|
|
103
|
+
const existing = Array.from(self.uploadedFiles.values()).some(function (f) {
|
|
104
|
+
return String(f.serverId) === String(input.value);
|
|
105
|
+
});
|
|
106
|
+
if (!existing) {
|
|
107
|
+
const localId = 'file-' + (++self.fileIdCounter);
|
|
108
|
+
self.uploadedFiles.set(localId, {
|
|
109
|
+
serverId: input.value,
|
|
110
|
+
name: '',
|
|
111
|
+
size: ''
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
this._syncHiddenInputs();
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
// ─── Hidden Inputs Sync ────────────────────────────────
|
|
121
|
+
|
|
122
|
+
_component.prototype._syncHiddenInputs = function () {
|
|
123
|
+
const self = this;
|
|
124
|
+
const currentHidden = this.dom.querySelectorAll('input[type="hidden"]');
|
|
125
|
+
for (let i = 0; i < currentHidden.length; i++) {
|
|
126
|
+
if (currentHidden[i].name === self.idsFieldName) {
|
|
127
|
+
currentHidden[i].remove();
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
for (const [, fileData] of this.uploadedFiles) {
|
|
132
|
+
if (fileData.serverId) {
|
|
133
|
+
const input = document.createElement('input');
|
|
134
|
+
input.type = 'hidden';
|
|
135
|
+
input.name = self.idsFieldName;
|
|
136
|
+
input.value = fileData.serverId;
|
|
137
|
+
self.dom.appendChild(input);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
// ─── Event Binding ─────────────────────────────────────
|
|
143
|
+
|
|
144
|
+
_component.prototype._bindEvents = function () {
|
|
145
|
+
const self = this;
|
|
146
|
+
|
|
147
|
+
this._onZoneClick = function (e) {
|
|
148
|
+
if (self.zone === self.dom) {
|
|
149
|
+
if (e.target.closest('[data-ln-upload-list], [data-ln-upload-action], input, button, a')) return;
|
|
150
|
+
}
|
|
151
|
+
if (self.input && e.target !== self.input) {
|
|
152
|
+
self.input.click();
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
this._onInputChange = function () {
|
|
157
|
+
if (self.input && self.input.files) {
|
|
158
|
+
self.upload(self.input.files);
|
|
159
|
+
self.input.value = '';
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
this._onDragEnter = function (e) {
|
|
164
|
+
e.preventDefault();
|
|
165
|
+
e.stopPropagation();
|
|
166
|
+
self._dragDepth++;
|
|
167
|
+
self.zone.setAttribute('data-ln-upload-state', 'dragover');
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
this._onDragOver = function (e) {
|
|
171
|
+
e.preventDefault();
|
|
172
|
+
e.stopPropagation();
|
|
173
|
+
self.zone.setAttribute('data-ln-upload-state', 'dragover');
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
this._onDragLeave = function (e) {
|
|
177
|
+
e.preventDefault();
|
|
178
|
+
e.stopPropagation();
|
|
179
|
+
self._dragDepth--;
|
|
180
|
+
if (self._dragDepth <= 0) {
|
|
181
|
+
self._dragDepth = 0;
|
|
182
|
+
self.zone.removeAttribute('data-ln-upload-state');
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
this._onDrop = function (e) {
|
|
187
|
+
e.preventDefault();
|
|
188
|
+
e.stopPropagation();
|
|
189
|
+
self._dragDepth = 0;
|
|
190
|
+
self.zone.removeAttribute('data-ln-upload-state');
|
|
191
|
+
if (e.dataTransfer && e.dataTransfer.files) {
|
|
192
|
+
self.upload(e.dataTransfer.files);
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
this._onListClick = function (e) {
|
|
197
|
+
const removeBtn = e.target.closest('[data-ln-upload-action="remove"]');
|
|
198
|
+
if (!removeBtn || !self.list || !self.list.contains(removeBtn)) return;
|
|
199
|
+
if (removeBtn.disabled) return;
|
|
200
|
+
const item = removeBtn.closest('[data-ln-upload-item]');
|
|
201
|
+
if (item) {
|
|
202
|
+
const localId = item.getAttribute('data-ln-upload-local-id');
|
|
203
|
+
if (localId) self.remove(localId);
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
// Inbound Request Command listeners (CQS)
|
|
208
|
+
this._onRequestUpload = function (e) {
|
|
209
|
+
if (e.detail && e.detail.files) {
|
|
210
|
+
self.upload(e.detail.files);
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
this._onRequestRemove = function (e) {
|
|
215
|
+
if (e.detail) {
|
|
216
|
+
const id = e.detail.localId !== undefined ? e.detail.localId : e.detail.serverId;
|
|
217
|
+
if (id !== undefined) self.remove(id);
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
this._onRequestClear = function () {
|
|
222
|
+
self.clear();
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
this.zone.addEventListener('click', this._onZoneClick);
|
|
226
|
+
if (this.input) {
|
|
227
|
+
this.input.addEventListener('change', this._onInputChange);
|
|
228
|
+
}
|
|
229
|
+
this.zone.addEventListener('dragenter', this._onDragEnter);
|
|
230
|
+
this.zone.addEventListener('dragover', this._onDragOver);
|
|
231
|
+
this.zone.addEventListener('dragleave', this._onDragLeave);
|
|
232
|
+
this.zone.addEventListener('drop', this._onDrop);
|
|
233
|
+
|
|
234
|
+
if (this.list) {
|
|
235
|
+
this.list.addEventListener('click', this._onListClick);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
this.dom.addEventListener('ln-upload:request-upload', this._onRequestUpload);
|
|
239
|
+
this.dom.addEventListener('ln-upload:request-remove', this._onRequestRemove);
|
|
240
|
+
this.dom.addEventListener('ln-upload:request-clear', this._onRequestClear);
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
// ─── File Upload Mechanics ─────────────────────────────
|
|
244
|
+
|
|
245
|
+
_component.prototype.upload = function (files) {
|
|
246
|
+
const self = this;
|
|
247
|
+
const fileList = Array.from(files);
|
|
248
|
+
|
|
249
|
+
for (let i = 0; i < fileList.length; i++) {
|
|
250
|
+
const file = fileList[i];
|
|
251
|
+
|
|
252
|
+
// Validate maximum files constraint
|
|
253
|
+
if (self.maxFiles > 0 && self.uploadedFiles.size >= self.maxFiles) {
|
|
254
|
+
dispatch(self.dom, 'ln-upload:invalid', {
|
|
255
|
+
file: file,
|
|
256
|
+
reason: 'max-files'
|
|
257
|
+
});
|
|
258
|
+
continue;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// Validate file extension / MIME type
|
|
262
|
+
if (!isFileTypeAllowed(file, self.allowedExts)) {
|
|
263
|
+
dispatch(self.dom, 'ln-upload:invalid', {
|
|
264
|
+
file: file,
|
|
265
|
+
reason: 'accept'
|
|
266
|
+
});
|
|
267
|
+
continue;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
// Validate file max size in bytes
|
|
271
|
+
if (self.maxSize > 0 && file.size > self.maxSize) {
|
|
272
|
+
dispatch(self.dom, 'ln-upload:invalid', {
|
|
273
|
+
file: file,
|
|
274
|
+
reason: 'max-size'
|
|
275
|
+
});
|
|
276
|
+
continue;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// Cancelable before event
|
|
280
|
+
const before = dispatchCancelable(self.dom, 'ln-upload:before-upload', { file: file });
|
|
281
|
+
if (before.defaultPrevented) continue;
|
|
282
|
+
|
|
283
|
+
self._uploadSingleFile(file);
|
|
284
|
+
}
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
_component.prototype._uploadSingleFile = function (file) {
|
|
288
|
+
const self = this;
|
|
289
|
+
const localId = 'file-' + (++self.fileIdCounter);
|
|
290
|
+
const ext = getFileExtension(file.name);
|
|
291
|
+
|
|
292
|
+
let item = null;
|
|
293
|
+
if (this.list) {
|
|
294
|
+
const fragment = cloneTemplateScoped(this.dom, 'ln-upload-item', 'ln-upload');
|
|
295
|
+
if (fragment) {
|
|
296
|
+
item = fragment.firstElementChild;
|
|
297
|
+
if (item) {
|
|
298
|
+
item.setAttribute('data-ln-upload-item', '');
|
|
299
|
+
item.setAttribute('data-ln-upload-local-id', localId);
|
|
300
|
+
item.setAttribute('data-ln-upload-ext', ext);
|
|
301
|
+
item.setAttribute('data-ln-upload-state', 'uploading');
|
|
302
|
+
|
|
303
|
+
fill(item, {
|
|
304
|
+
name: file.name,
|
|
305
|
+
sizeText: '0%',
|
|
306
|
+
removeLabel: self.dict['remove'] || 'Remove',
|
|
307
|
+
uploading: true,
|
|
308
|
+
error: false,
|
|
309
|
+
deleting: false
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
const removeBtn = item.querySelector('[data-ln-upload-action="remove"]');
|
|
313
|
+
if (removeBtn) removeBtn.disabled = true;
|
|
314
|
+
|
|
315
|
+
const progressEl = item.querySelector('[data-ln-progress]');
|
|
316
|
+
if (progressEl) progressEl.setAttribute('data-ln-progress', '0');
|
|
317
|
+
|
|
318
|
+
self.list.appendChild(item);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
// Prepare multipart FormData
|
|
324
|
+
const formData = new FormData();
|
|
325
|
+
formData.append(self.fileFieldName, file);
|
|
326
|
+
|
|
327
|
+
// Gather nested inputs, excluding file fields, unchecked inputs, and the hidden idsField
|
|
328
|
+
const nestedInputs = this.dom.querySelectorAll('input, select, textarea');
|
|
329
|
+
for (let i = 0; i < nestedInputs.length; i++) {
|
|
330
|
+
const el = nestedInputs[i];
|
|
331
|
+
if (!el.name || el.name === self.idsFieldName || el.type === 'file') continue;
|
|
332
|
+
if ((el.type === 'checkbox' || el.type === 'radio') && !el.checked) continue;
|
|
333
|
+
formData.append(el.name, el.value);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
const xhr = new XMLHttpRequest();
|
|
337
|
+
self.uploadedFiles.set(localId, {
|
|
338
|
+
serverId: null,
|
|
339
|
+
name: file.name,
|
|
340
|
+
size: file.size,
|
|
341
|
+
xhr: xhr
|
|
342
|
+
});
|
|
343
|
+
|
|
344
|
+
xhr.upload.addEventListener('progress', function (e) {
|
|
345
|
+
if (e.lengthComputable) {
|
|
346
|
+
const percent = Math.round((e.loaded / e.total) * 100);
|
|
347
|
+
if (item) {
|
|
348
|
+
const progressEl = item.querySelector('[data-ln-progress]');
|
|
349
|
+
if (progressEl) progressEl.setAttribute('data-ln-progress', String(percent));
|
|
350
|
+
fill(item, { sizeText: percent + '%' });
|
|
351
|
+
}
|
|
352
|
+
dispatch(self.dom, 'ln-upload:progress', {
|
|
353
|
+
localId: localId,
|
|
354
|
+
file: file,
|
|
355
|
+
percent: percent,
|
|
356
|
+
loaded: e.loaded,
|
|
357
|
+
total: e.total
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
xhr.addEventListener('load', function () {
|
|
363
|
+
const entry = self.uploadedFiles.get(localId);
|
|
364
|
+
if (entry) delete entry.xhr;
|
|
365
|
+
|
|
366
|
+
if (xhr.status >= 200 && xhr.status < 300) {
|
|
367
|
+
let data;
|
|
368
|
+
try {
|
|
369
|
+
data = JSON.parse(xhr.responseText);
|
|
370
|
+
} catch (e) {
|
|
371
|
+
handleError(self.dict['error'] || 'Error', xhr.status, e);
|
|
372
|
+
return;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
const serverId = data.id || data.serverId;
|
|
376
|
+
if (item) {
|
|
377
|
+
item.removeAttribute('data-ln-upload-state');
|
|
378
|
+
if (serverId) item.setAttribute('data-ln-upload-id', String(serverId));
|
|
379
|
+
fill(item, {
|
|
380
|
+
sizeText: _formatSize(data.size || file.size, self.locale, self.dict),
|
|
381
|
+
uploading: false
|
|
382
|
+
});
|
|
383
|
+
const removeBtn = item.querySelector('[data-ln-upload-action="remove"]');
|
|
384
|
+
if (removeBtn) removeBtn.disabled = false;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
if (entry) {
|
|
388
|
+
entry.serverId = serverId;
|
|
389
|
+
entry.size = data.size || file.size;
|
|
390
|
+
entry.name = data.name || file.name;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
self._syncHiddenInputs();
|
|
394
|
+
|
|
395
|
+
dispatch(self.dom, 'ln-upload:uploaded', {
|
|
396
|
+
localId: localId,
|
|
397
|
+
serverId: serverId,
|
|
398
|
+
name: data.name || file.name,
|
|
399
|
+
size: data.size || file.size,
|
|
400
|
+
response: data
|
|
401
|
+
});
|
|
402
|
+
} else {
|
|
403
|
+
let message = '';
|
|
404
|
+
try {
|
|
405
|
+
const errData = JSON.parse(xhr.responseText);
|
|
406
|
+
message = errData.message || '';
|
|
407
|
+
} catch (e) {}
|
|
408
|
+
handleError(message, xhr.status, null);
|
|
409
|
+
}
|
|
410
|
+
});
|
|
411
|
+
|
|
412
|
+
xhr.addEventListener('error', function () {
|
|
413
|
+
const entry = self.uploadedFiles.get(localId);
|
|
414
|
+
if (entry) delete entry.xhr;
|
|
415
|
+
handleError('', 0, null);
|
|
416
|
+
});
|
|
417
|
+
|
|
418
|
+
function handleError(message, status, err) {
|
|
419
|
+
if (item) {
|
|
420
|
+
item.setAttribute('data-ln-upload-state', 'error');
|
|
421
|
+
fill(item, {
|
|
422
|
+
sizeText: self.dict['error'] || 'Error',
|
|
423
|
+
uploading: false,
|
|
424
|
+
error: true
|
|
425
|
+
});
|
|
426
|
+
const removeBtn = item.querySelector('[data-ln-upload-action="remove"]');
|
|
427
|
+
if (removeBtn) removeBtn.disabled = false;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
dispatch(self.dom, 'ln-upload:error', {
|
|
431
|
+
file: file,
|
|
432
|
+
message: message,
|
|
433
|
+
status: status,
|
|
434
|
+
error: err
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
if (self.uploadUrl) {
|
|
439
|
+
xhr.open('POST', self.uploadUrl);
|
|
440
|
+
xhr.setRequestHeader('X-CSRF-TOKEN', _getCsrfToken());
|
|
441
|
+
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
|
|
442
|
+
xhr.setRequestHeader('Accept', 'application/json');
|
|
443
|
+
xhr.send(formData);
|
|
444
|
+
} else {
|
|
445
|
+
console.warn('[ln-upload] No upload URL configured (missing data-ln-upload)');
|
|
446
|
+
}
|
|
447
|
+
};
|
|
448
|
+
|
|
449
|
+
// ─── File Removal & Deletion Mechanics ─────────────────
|
|
450
|
+
|
|
451
|
+
_component.prototype.remove = function (id) {
|
|
452
|
+
const self = this;
|
|
453
|
+
|
|
454
|
+
// Resolve by localId or serverId
|
|
455
|
+
let targetLocalId = null;
|
|
456
|
+
let fileData = null;
|
|
457
|
+
|
|
458
|
+
if (self.uploadedFiles.has(id)) {
|
|
459
|
+
targetLocalId = id;
|
|
460
|
+
fileData = self.uploadedFiles.get(id);
|
|
461
|
+
} else {
|
|
462
|
+
for (const [locId, data] of self.uploadedFiles) {
|
|
463
|
+
if (String(data.serverId) === String(id)) {
|
|
464
|
+
targetLocalId = locId;
|
|
465
|
+
fileData = data;
|
|
466
|
+
break;
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
if (!targetLocalId || !fileData) return;
|
|
472
|
+
|
|
473
|
+
// Cancelable before event
|
|
474
|
+
const before = dispatchCancelable(self.dom, 'ln-upload:before-remove', {
|
|
475
|
+
localId: targetLocalId,
|
|
476
|
+
serverId: fileData.serverId
|
|
477
|
+
});
|
|
478
|
+
if (before.defaultPrevented) return;
|
|
479
|
+
|
|
480
|
+
const item = self.list ? self.list.querySelector('[data-ln-upload-local-id="' + targetLocalId + '"]') : null;
|
|
481
|
+
|
|
482
|
+
// If upload was active and in-flight, abort it
|
|
483
|
+
if (fileData.xhr && typeof fileData.xhr.abort === 'function') {
|
|
484
|
+
fileData.xhr.abort();
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
// If the file has no serverId, simply remove from DOM and state
|
|
488
|
+
if (!fileData.serverId) {
|
|
489
|
+
if (item) item.remove();
|
|
490
|
+
self.uploadedFiles.delete(targetLocalId);
|
|
491
|
+
self._syncHiddenInputs();
|
|
492
|
+
dispatch(self.dom, 'ln-upload:removed', { localId: targetLocalId, serverId: null });
|
|
493
|
+
return;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
// Resolve delete URL
|
|
497
|
+
let deleteUrl = null;
|
|
498
|
+
if (self.deleteUrlPattern) {
|
|
499
|
+
deleteUrl = self.deleteUrlPattern.replace('{id}', encodeURIComponent(fileData.serverId));
|
|
500
|
+
} else if (self.uploadUrl && self.uploadUrl.includes('{id}')) {
|
|
501
|
+
deleteUrl = self.uploadUrl.replace('{id}', encodeURIComponent(fileData.serverId));
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
if (!deleteUrl) {
|
|
505
|
+
// No delete endpoint configured — clean up locally and emit removed event
|
|
506
|
+
if (item) item.remove();
|
|
507
|
+
self.uploadedFiles.delete(targetLocalId);
|
|
508
|
+
self._syncHiddenInputs();
|
|
509
|
+
dispatch(self.dom, 'ln-upload:removed', { localId: targetLocalId, serverId: fileData.serverId });
|
|
510
|
+
return;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
if (item) {
|
|
514
|
+
item.setAttribute('data-ln-upload-state', 'deleting');
|
|
515
|
+
fill(item, { deleting: true });
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
fetch(deleteUrl, {
|
|
519
|
+
method: 'DELETE',
|
|
520
|
+
headers: {
|
|
521
|
+
'X-CSRF-TOKEN': _getCsrfToken(),
|
|
522
|
+
'X-Requested-With': 'XMLHttpRequest',
|
|
523
|
+
'Accept': 'application/json'
|
|
524
|
+
}
|
|
525
|
+
})
|
|
526
|
+
.then(function (response) {
|
|
527
|
+
if (response.ok) {
|
|
528
|
+
if (item) item.remove();
|
|
529
|
+
self.uploadedFiles.delete(targetLocalId);
|
|
530
|
+
self._syncHiddenInputs();
|
|
531
|
+
dispatch(self.dom, 'ln-upload:removed', {
|
|
532
|
+
localId: targetLocalId,
|
|
533
|
+
serverId: fileData.serverId
|
|
534
|
+
});
|
|
535
|
+
} else {
|
|
536
|
+
if (item) {
|
|
537
|
+
item.removeAttribute('data-ln-upload-state');
|
|
538
|
+
fill(item, { deleting: false });
|
|
539
|
+
}
|
|
540
|
+
dispatch(self.dom, 'ln-upload:error', {
|
|
541
|
+
file: fileData,
|
|
542
|
+
message: '',
|
|
543
|
+
status: response.status
|
|
544
|
+
});
|
|
545
|
+
}
|
|
546
|
+
})
|
|
547
|
+
.catch(function (error) {
|
|
548
|
+
if (item) {
|
|
549
|
+
item.removeAttribute('data-ln-upload-state');
|
|
550
|
+
fill(item, { deleting: false });
|
|
551
|
+
}
|
|
552
|
+
dispatch(self.dom, 'ln-upload:error', {
|
|
553
|
+
file: fileData,
|
|
554
|
+
message: '',
|
|
555
|
+
status: 0,
|
|
556
|
+
error: error
|
|
557
|
+
});
|
|
558
|
+
});
|
|
559
|
+
};
|
|
560
|
+
|
|
561
|
+
_component.prototype.clear = function () {
|
|
562
|
+
const self = this;
|
|
563
|
+
const before = dispatchCancelable(self.dom, 'ln-upload:before-clear', {});
|
|
564
|
+
if (before.defaultPrevented) return;
|
|
565
|
+
|
|
566
|
+
for (const [, fileData] of this.uploadedFiles) {
|
|
567
|
+
if (fileData.xhr && typeof fileData.xhr.abort === 'function') {
|
|
568
|
+
fileData.xhr.abort();
|
|
569
|
+
}
|
|
570
|
+
if (fileData.serverId) {
|
|
571
|
+
let deleteUrl = null;
|
|
572
|
+
if (self.deleteUrlPattern) {
|
|
573
|
+
deleteUrl = self.deleteUrlPattern.replace('{id}', encodeURIComponent(fileData.serverId));
|
|
574
|
+
} else if (self.uploadUrl && self.uploadUrl.includes('{id}')) {
|
|
575
|
+
deleteUrl = self.uploadUrl.replace('{id}', encodeURIComponent(fileData.serverId));
|
|
576
|
+
}
|
|
577
|
+
if (deleteUrl) {
|
|
578
|
+
fetch(deleteUrl, {
|
|
579
|
+
method: 'DELETE',
|
|
580
|
+
headers: {
|
|
581
|
+
'X-CSRF-TOKEN': _getCsrfToken(),
|
|
582
|
+
'X-Requested-With': 'XMLHttpRequest',
|
|
583
|
+
'Accept': 'application/json'
|
|
584
|
+
}
|
|
585
|
+
}).catch(function () {});
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
self.uploadedFiles.clear();
|
|
591
|
+
if (self.list) self.list.innerHTML = '';
|
|
592
|
+
self._syncHiddenInputs();
|
|
593
|
+
dispatch(self.dom, 'ln-upload:cleared', {});
|
|
594
|
+
};
|
|
595
|
+
|
|
596
|
+
_component.prototype.getFileIds = function () {
|
|
597
|
+
return Array.from(this.uploadedFiles.values())
|
|
598
|
+
.map(function (f) { return f.serverId; })
|
|
599
|
+
.filter(Boolean);
|
|
600
|
+
};
|
|
601
|
+
|
|
602
|
+
_component.prototype.getFiles = function () {
|
|
603
|
+
return Array.from(this.uploadedFiles.values()).map(function (f) {
|
|
604
|
+
return {
|
|
605
|
+
serverId: f.serverId,
|
|
606
|
+
name: f.name,
|
|
607
|
+
size: f.size
|
|
608
|
+
};
|
|
609
|
+
});
|
|
610
|
+
};
|
|
611
|
+
|
|
612
|
+
// ─── Destroy Lifecycle ─────────────────────────────────
|
|
613
|
+
|
|
614
|
+
_component.prototype.destroy = function () {
|
|
615
|
+
if (!this.dom[DOM_ATTRIBUTE]) return;
|
|
616
|
+
|
|
617
|
+
// Abort in-flight XHRs
|
|
618
|
+
for (const [, fileData] of this.uploadedFiles) {
|
|
619
|
+
if (fileData.xhr && typeof fileData.xhr.abort === 'function') {
|
|
620
|
+
fileData.xhr.abort();
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
this.zone.removeEventListener('click', this._onZoneClick);
|
|
625
|
+
if (this.input) {
|
|
626
|
+
this.input.removeEventListener('change', this._onInputChange);
|
|
627
|
+
}
|
|
628
|
+
this.zone.removeEventListener('dragenter', this._onDragEnter);
|
|
629
|
+
this.zone.removeEventListener('dragover', this._onDragOver);
|
|
630
|
+
this.zone.removeEventListener('dragleave', this._onDragLeave);
|
|
631
|
+
this.zone.removeEventListener('drop', this._onDrop);
|
|
632
|
+
|
|
633
|
+
if (this.list) {
|
|
634
|
+
this.list.removeEventListener('click', this._onListClick);
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
this.dom.removeEventListener('ln-upload:request-upload', this._onRequestUpload);
|
|
638
|
+
this.dom.removeEventListener('ln-upload:request-remove', this._onRequestRemove);
|
|
639
|
+
this.dom.removeEventListener('ln-upload:request-clear', this._onRequestClear);
|
|
640
|
+
|
|
641
|
+
this.uploadedFiles.clear();
|
|
642
|
+
this.dict = {};
|
|
643
|
+
|
|
644
|
+
delete this.dom[DOM_ATTRIBUTE];
|
|
645
|
+
};
|
|
646
|
+
|
|
647
|
+
// ─── Registration ──────────────────────────────────────
|
|
648
|
+
|
|
649
|
+
registerComponent(DOM_SELECTOR, DOM_ATTRIBUTE, _component, 'ln-upload', {
|
|
650
|
+
attributes: ATTRIBUTES
|
|
651
|
+
});
|
|
652
|
+
})();
|