@aquera/nile-elements 1.5.4 → 1.5.6
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/README.md +10 -0
- package/demo/index.css +9 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.js +871 -255
- package/dist/nile-auto-complete/nile-auto-complete.css.cjs.js +1 -1
- package/dist/nile-auto-complete/nile-auto-complete.css.cjs.js.map +1 -1
- package/dist/nile-auto-complete/nile-auto-complete.css.esm.js +13 -2
- package/dist/nile-button/nile-button.cjs.js +1 -1
- package/dist/nile-button/nile-button.cjs.js.map +1 -1
- package/dist/nile-button/nile-button.css.cjs.js +1 -1
- package/dist/nile-button/nile-button.css.cjs.js.map +1 -1
- package/dist/nile-button/nile-button.css.esm.js +89 -33
- package/dist/nile-button/nile-button.esm.js +2 -2
- package/dist/nile-calendar/nile-calendar.cjs.js +1 -1
- package/dist/nile-calendar/nile-calendar.cjs.js.map +1 -1
- package/dist/nile-calendar/nile-calendar.css.cjs.js +1 -1
- package/dist/nile-calendar/nile-calendar.css.cjs.js.map +1 -1
- package/dist/nile-calendar/nile-calendar.css.esm.js +59 -2
- package/dist/nile-calendar/nile-calendar.esm.js +16 -10
- package/dist/nile-checkbox/nile-checkbox.css.cjs.js +1 -1
- package/dist/nile-checkbox/nile-checkbox.css.cjs.js.map +1 -1
- package/dist/nile-checkbox/nile-checkbox.css.esm.js +4 -5
- package/dist/nile-chip/nile-chip.css.cjs.js +1 -1
- package/dist/nile-chip/nile-chip.css.cjs.js.map +1 -1
- package/dist/nile-chip/nile-chip.css.esm.js +37 -23
- package/dist/nile-code-editor/nile-code-editor.cjs.js +1 -1
- package/dist/nile-code-editor/nile-code-editor.cjs.js.map +1 -1
- package/dist/nile-code-editor/nile-code-editor.css.cjs.js +1 -1
- package/dist/nile-code-editor/nile-code-editor.css.cjs.js.map +1 -1
- package/dist/nile-code-editor/nile-code-editor.css.esm.js +7 -6
- package/dist/nile-code-editor/nile-code-editor.esm.js +1 -1
- package/dist/nile-date-picker/nile-date-picker.cjs.js +1 -1
- package/dist/nile-date-picker/nile-date-picker.cjs.js.map +1 -1
- package/dist/nile-date-picker/nile-date-picker.esm.js +4 -4
- package/dist/nile-detail/index.cjs.js +2 -0
- package/dist/nile-detail/index.cjs.js.map +1 -0
- package/dist/nile-detail/index.esm.js +1 -0
- package/dist/nile-detail/nile-detail.cjs.js +2 -0
- package/dist/nile-detail/nile-detail.cjs.js.map +1 -0
- package/dist/nile-detail/nile-detail.css.cjs.js +2 -0
- package/dist/nile-detail/nile-detail.css.cjs.js.map +1 -0
- package/dist/nile-detail/nile-detail.css.esm.js +149 -0
- package/dist/nile-detail/nile-detail.esm.js +45 -0
- package/dist/nile-detail/nile-detail.utils.cjs.js +2 -0
- package/dist/nile-detail/nile-detail.utils.cjs.js.map +1 -0
- package/dist/nile-detail/nile-detail.utils.esm.js +1 -0
- package/dist/nile-dropdown/nile-dropdown.cjs.js +1 -1
- package/dist/nile-dropdown/nile-dropdown.cjs.js.map +1 -1
- package/dist/nile-dropdown/nile-dropdown.esm.js +1 -1
- package/dist/nile-file-upload/utils/file-validation.util.cjs.js +2 -2
- package/dist/nile-file-upload/utils/file-validation.util.cjs.js.map +1 -1
- package/dist/nile-file-upload/utils/file-validation.util.esm.js +1 -1
- package/dist/nile-filter-chip/nile-filter-chip.cjs.js +1 -1
- package/dist/nile-filter-chip/nile-filter-chip.cjs.js.map +1 -1
- package/dist/nile-filter-chip/nile-filter-chip.css.cjs.js +1 -1
- package/dist/nile-filter-chip/nile-filter-chip.css.cjs.js.map +1 -1
- package/dist/nile-filter-chip/nile-filter-chip.css.esm.js +24 -2
- package/dist/nile-filter-chip/nile-filter-chip.esm.js +2 -2
- package/dist/nile-inline-edit/nile-inline-edit.cjs.js +1 -1
- package/dist/nile-inline-edit/nile-inline-edit.cjs.js.map +1 -1
- package/dist/nile-inline-edit/nile-inline-edit.css.cjs.js +1 -1
- package/dist/nile-inline-edit/nile-inline-edit.css.cjs.js.map +1 -1
- package/dist/nile-inline-edit/nile-inline-edit.css.esm.js +15 -6
- package/dist/nile-inline-edit/nile-inline-edit.esm.js +2 -2
- package/dist/nile-inline-sidebar/nile-inline-sidebar.cjs.js +1 -1
- package/dist/nile-inline-sidebar/nile-inline-sidebar.cjs.js.map +1 -1
- package/dist/nile-inline-sidebar/nile-inline-sidebar.css.cjs.js +1 -1
- package/dist/nile-inline-sidebar/nile-inline-sidebar.css.cjs.js.map +1 -1
- package/dist/nile-inline-sidebar/nile-inline-sidebar.css.esm.js +19 -0
- package/dist/nile-inline-sidebar/nile-inline-sidebar.esm.js +16 -14
- package/dist/nile-inline-sidebar-item/nile-inline-sidebar-item.cjs.js +1 -1
- package/dist/nile-inline-sidebar-item/nile-inline-sidebar-item.cjs.js.map +1 -1
- package/dist/nile-inline-sidebar-item/nile-inline-sidebar-item.esm.js +8 -3
- package/dist/nile-input/nile-input.css.cjs.js +1 -1
- package/dist/nile-input/nile-input.css.cjs.js.map +1 -1
- package/dist/nile-input/nile-input.css.esm.js +4 -4
- package/dist/nile-link/nile-link.cjs.js +1 -1
- package/dist/nile-link/nile-link.cjs.js.map +1 -1
- package/dist/nile-link/nile-link.css.cjs.js +1 -1
- package/dist/nile-link/nile-link.css.cjs.js.map +1 -1
- package/dist/nile-link/nile-link.css.esm.js +3 -4
- package/dist/nile-link/nile-link.esm.js +2 -2
- package/dist/nile-pagination/nile-pagination.cjs.js +1 -1
- package/dist/nile-pagination/nile-pagination.cjs.js.map +1 -1
- package/dist/nile-pagination/nile-pagination.css.cjs.js +1 -1
- package/dist/nile-pagination/nile-pagination.css.cjs.js.map +1 -1
- package/dist/nile-pagination/nile-pagination.css.esm.js +109 -5
- package/dist/nile-pagination/nile-pagination.esm.js +70 -3
- package/dist/nile-qr-code/index.cjs.js +2 -0
- package/dist/nile-qr-code/index.cjs.js.map +1 -0
- package/dist/nile-qr-code/index.esm.js +1 -0
- package/dist/nile-qr-code/nile-qr-code-utils.cjs.js +2 -0
- package/dist/nile-qr-code/nile-qr-code-utils.cjs.js.map +1 -0
- package/dist/nile-qr-code/nile-qr-code-utils.esm.js +1 -0
- package/dist/nile-qr-code/nile-qr-code.cjs.js +2 -0
- package/dist/nile-qr-code/nile-qr-code.cjs.js.map +1 -0
- package/dist/nile-qr-code/nile-qr-code.css.cjs.js +2 -0
- package/dist/nile-qr-code/nile-qr-code.css.cjs.js.map +1 -0
- package/dist/nile-qr-code/nile-qr-code.css.esm.js +12 -0
- package/dist/nile-qr-code/nile-qr-code.esm.js +9 -0
- package/dist/nile-radio/nile-radio.css.cjs.js +1 -1
- package/dist/nile-radio/nile-radio.css.cjs.js.map +1 -1
- package/dist/nile-radio/nile-radio.css.esm.js +1 -1
- package/dist/nile-rich-text-editor/nile-rich-text-editor.cjs.js +1 -1
- package/dist/nile-rich-text-editor/nile-rich-text-editor.cjs.js.map +1 -1
- package/dist/nile-rich-text-editor/nile-rich-text-editor.css.cjs.js +1 -1
- package/dist/nile-rich-text-editor/nile-rich-text-editor.css.cjs.js.map +1 -1
- package/dist/nile-rich-text-editor/nile-rich-text-editor.css.esm.js +25 -6
- package/dist/nile-rich-text-editor/nile-rich-text-editor.esm.js +1 -1
- package/dist/nile-rich-text-editor/nile-rte-select.cjs.js +1 -1
- package/dist/nile-rich-text-editor/nile-rte-select.cjs.js.map +1 -1
- package/dist/nile-rich-text-editor/nile-rte-select.esm.js +4 -3
- package/dist/nile-select/nile-select.css.cjs.js +1 -1
- package/dist/nile-select/nile-select.css.cjs.js.map +1 -1
- package/dist/nile-select/nile-select.css.esm.js +7 -4
- package/dist/nile-slide-toggle/nile-slide-toggle.css.cjs.js +1 -1
- package/dist/nile-slide-toggle/nile-slide-toggle.css.cjs.js.map +1 -1
- package/dist/nile-slide-toggle/nile-slide-toggle.css.esm.js +5 -1
- package/dist/nile-textarea/nile-textarea.css.cjs.js +1 -1
- package/dist/nile-textarea/nile-textarea.css.cjs.js.map +1 -1
- package/dist/nile-textarea/nile-textarea.css.esm.js +10 -5
- package/dist/nile-virtual-select/nile-virtual-select.css.cjs.js +1 -1
- package/dist/nile-virtual-select/nile-virtual-select.css.cjs.js.map +1 -1
- package/dist/nile-virtual-select/nile-virtual-select.css.esm.js +5 -3
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.js +2 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/nile-auto-complete/nile-auto-complete.css.js +11 -0
- package/dist/src/nile-auto-complete/nile-auto-complete.css.js.map +1 -1
- package/dist/src/nile-button/nile-button.css.js +89 -33
- package/dist/src/nile-button/nile-button.css.js.map +1 -1
- package/dist/src/nile-button/nile-button.js +5 -5
- package/dist/src/nile-button/nile-button.js.map +1 -1
- package/dist/src/nile-calendar/nile-calendar.css.js +57 -0
- package/dist/src/nile-calendar/nile-calendar.css.js.map +1 -1
- package/dist/src/nile-calendar/nile-calendar.d.ts +1 -0
- package/dist/src/nile-calendar/nile-calendar.js +24 -6
- package/dist/src/nile-calendar/nile-calendar.js.map +1 -1
- package/dist/src/nile-checkbox/nile-checkbox.css.js +4 -5
- package/dist/src/nile-checkbox/nile-checkbox.css.js.map +1 -1
- package/dist/src/nile-chip/nile-chip.css.js +35 -21
- package/dist/src/nile-chip/nile-chip.css.js.map +1 -1
- package/dist/src/nile-code-editor/nile-code-editor.css.js +7 -6
- package/dist/src/nile-code-editor/nile-code-editor.css.js.map +1 -1
- package/dist/src/nile-code-editor/nile-code-editor.d.ts +1 -1
- package/dist/src/nile-code-editor/nile-code-editor.js +7 -1
- package/dist/src/nile-code-editor/nile-code-editor.js.map +1 -1
- package/dist/src/nile-date-picker/nile-date-picker.d.ts +3 -0
- package/dist/src/nile-date-picker/nile-date-picker.js +22 -2
- package/dist/src/nile-date-picker/nile-date-picker.js.map +1 -1
- package/dist/src/nile-detail/index.d.ts +1 -0
- package/dist/src/nile-detail/index.js +2 -0
- package/dist/src/nile-detail/index.js.map +1 -0
- package/dist/src/nile-detail/nile-detail.css.d.ts +3 -0
- package/dist/src/nile-detail/nile-detail.css.js +152 -0
- package/dist/src/nile-detail/nile-detail.css.js.map +1 -0
- package/dist/src/nile-detail/nile-detail.d.ts +29 -0
- package/dist/src/nile-detail/nile-detail.js +143 -0
- package/dist/src/nile-detail/nile-detail.js.map +1 -0
- package/dist/src/nile-detail/nile-detail.test.d.ts +1 -0
- package/dist/src/nile-detail/nile-detail.test.js +168 -0
- package/dist/src/nile-detail/nile-detail.test.js.map +1 -0
- package/dist/src/nile-detail/nile-detail.utils.d.ts +8 -0
- package/dist/src/nile-detail/nile-detail.utils.js +117 -0
- package/dist/src/nile-detail/nile-detail.utils.js.map +1 -0
- package/dist/src/nile-dropdown/nile-dropdown.d.ts +1 -0
- package/dist/src/nile-dropdown/nile-dropdown.js +11 -0
- package/dist/src/nile-dropdown/nile-dropdown.js.map +1 -1
- package/dist/src/nile-file-upload/utils/file-validation.util.js +11 -6
- package/dist/src/nile-file-upload/utils/file-validation.util.js.map +1 -1
- package/dist/src/nile-filter-chip/nile-filter-chip.css.js +22 -0
- package/dist/src/nile-filter-chip/nile-filter-chip.css.js.map +1 -1
- package/dist/src/nile-filter-chip/nile-filter-chip.d.ts +1 -0
- package/dist/src/nile-filter-chip/nile-filter-chip.js +6 -0
- package/dist/src/nile-filter-chip/nile-filter-chip.js.map +1 -1
- package/dist/src/nile-inline-edit/nile-inline-edit.css.js +15 -6
- package/dist/src/nile-inline-edit/nile-inline-edit.css.js.map +1 -1
- package/dist/src/nile-inline-edit/nile-inline-edit.d.ts +2 -0
- package/dist/src/nile-inline-edit/nile-inline-edit.js +7 -0
- package/dist/src/nile-inline-edit/nile-inline-edit.js.map +1 -1
- package/dist/src/nile-inline-sidebar/nile-inline-sidebar.css.js +19 -0
- package/dist/src/nile-inline-sidebar/nile-inline-sidebar.css.js.map +1 -1
- package/dist/src/nile-inline-sidebar/nile-inline-sidebar.d.ts +6 -0
- package/dist/src/nile-inline-sidebar/nile-inline-sidebar.js +88 -4
- package/dist/src/nile-inline-sidebar/nile-inline-sidebar.js.map +1 -1
- package/dist/src/nile-inline-sidebar/nile-inline-sidebar.test.d.ts +3 -0
- package/dist/src/nile-inline-sidebar/nile-inline-sidebar.test.js +110 -0
- package/dist/src/nile-inline-sidebar/nile-inline-sidebar.test.js.map +1 -0
- package/dist/src/nile-inline-sidebar-group/nile-inline-sidebar-group.test.d.ts +2 -0
- package/dist/src/nile-inline-sidebar-group/nile-inline-sidebar-group.test.js +109 -0
- package/dist/src/nile-inline-sidebar-group/nile-inline-sidebar-group.test.js.map +1 -0
- package/dist/src/nile-inline-sidebar-item/nile-inline-sidebar-item.d.ts +4 -0
- package/dist/src/nile-inline-sidebar-item/nile-inline-sidebar-item.js +30 -2
- package/dist/src/nile-inline-sidebar-item/nile-inline-sidebar-item.js.map +1 -1
- package/dist/src/nile-inline-sidebar-item/nile-inline-sidebar-item.test.d.ts +2 -0
- package/dist/src/nile-inline-sidebar-item/nile-inline-sidebar-item.test.js +109 -0
- package/dist/src/nile-inline-sidebar-item/nile-inline-sidebar-item.test.js.map +1 -0
- package/dist/src/nile-input/nile-input.css.js +4 -4
- package/dist/src/nile-input/nile-input.css.js.map +1 -1
- package/dist/src/nile-link/nile-link.css.js +1 -2
- package/dist/src/nile-link/nile-link.css.js.map +1 -1
- package/dist/src/nile-link/nile-link.js +1 -0
- package/dist/src/nile-link/nile-link.js.map +1 -1
- package/dist/src/nile-pagination/nile-pagination.css.js +107 -3
- package/dist/src/nile-pagination/nile-pagination.css.js.map +1 -1
- package/dist/src/nile-pagination/nile-pagination.d.ts +5 -1
- package/dist/src/nile-pagination/nile-pagination.js +84 -1
- package/dist/src/nile-pagination/nile-pagination.js.map +1 -1
- package/dist/src/nile-pagination/nile-pagination.test.js +1187 -103
- package/dist/src/nile-pagination/nile-pagination.test.js.map +1 -1
- package/dist/src/nile-qr-code/index.d.ts +1 -0
- package/dist/src/nile-qr-code/index.js +2 -0
- package/dist/src/nile-qr-code/index.js.map +1 -0
- package/dist/src/nile-qr-code/nile-qr-code-utils.d.ts +15 -0
- package/dist/src/nile-qr-code/nile-qr-code-utils.js +678 -0
- package/dist/src/nile-qr-code/nile-qr-code-utils.js.map +1 -0
- package/dist/src/nile-qr-code/nile-qr-code.css.d.ts +12 -0
- package/dist/src/nile-qr-code/nile-qr-code.css.js +24 -0
- package/dist/src/nile-qr-code/nile-qr-code.css.js.map +1 -0
- package/dist/src/nile-qr-code/nile-qr-code.d.ts +127 -0
- package/dist/src/nile-qr-code/nile-qr-code.js +381 -0
- package/dist/src/nile-qr-code/nile-qr-code.js.map +1 -0
- package/dist/src/nile-qr-code/nile-qr-code.test.d.ts +1 -0
- package/dist/src/nile-qr-code/nile-qr-code.test.js +719 -0
- package/dist/src/nile-qr-code/nile-qr-code.test.js.map +1 -0
- package/dist/src/nile-radio/nile-radio.css.js +1 -1
- package/dist/src/nile-radio/nile-radio.css.js.map +1 -1
- package/dist/src/nile-rich-text-editor/nile-rich-text-editor.css.js +25 -6
- package/dist/src/nile-rich-text-editor/nile-rich-text-editor.css.js.map +1 -1
- package/dist/src/nile-rich-text-editor/nile-rich-text-editor.d.ts +1 -0
- package/dist/src/nile-rich-text-editor/nile-rich-text-editor.js +17 -6
- package/dist/src/nile-rich-text-editor/nile-rich-text-editor.js.map +1 -1
- package/dist/src/nile-rich-text-editor/nile-rte-select.d.ts +1 -0
- package/dist/src/nile-rich-text-editor/nile-rte-select.js +7 -2
- package/dist/src/nile-rich-text-editor/nile-rte-select.js.map +1 -1
- package/dist/src/nile-select/nile-select.css.js +7 -4
- package/dist/src/nile-select/nile-select.css.js.map +1 -1
- package/dist/src/nile-slide-toggle/nile-slide-toggle.css.js +5 -1
- package/dist/src/nile-slide-toggle/nile-slide-toggle.css.js.map +1 -1
- package/dist/src/nile-textarea/nile-textarea.css.js +10 -5
- package/dist/src/nile-textarea/nile-textarea.css.js.map +1 -1
- package/dist/src/nile-virtual-select/nile-virtual-select.css.js +5 -3
- package/dist/src/nile-virtual-select/nile-virtual-select.css.js.map +1 -1
- package/dist/src/version.js +1 -1
- package/dist/src/version.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -2
- package/src/index.ts +3 -2
- package/src/nile-auto-complete/nile-auto-complete.css.ts +11 -0
- package/src/nile-button/nile-button.css.ts +89 -33
- package/src/nile-button/nile-button.ts +6 -5
- package/src/nile-calendar/nile-calendar.css.ts +57 -0
- package/src/nile-calendar/nile-calendar.ts +17 -6
- package/src/nile-checkbox/nile-checkbox.css.ts +4 -5
- package/src/nile-chip/nile-chip.css.ts +35 -21
- package/src/nile-code-editor/nile-code-editor.css.ts +7 -6
- package/src/nile-code-editor/nile-code-editor.ts +7 -1
- package/src/nile-date-picker/nile-date-picker.ts +22 -2
- package/src/nile-detail/index.ts +1 -0
- package/src/nile-detail/nile-detail.css.ts +153 -0
- package/src/nile-detail/nile-detail.test.ts +215 -0
- package/src/nile-detail/nile-detail.ts +140 -0
- package/src/nile-detail/nile-detail.utils.ts +133 -0
- package/src/nile-dropdown/nile-dropdown.ts +11 -0
- package/src/nile-file-upload/utils/file-validation.util.ts +10 -5
- package/src/nile-filter-chip/nile-filter-chip.css.ts +22 -0
- package/src/nile-filter-chip/nile-filter-chip.ts +2 -0
- package/src/nile-inline-edit/nile-inline-edit.css.ts +15 -6
- package/src/nile-inline-edit/nile-inline-edit.ts +4 -0
- package/src/nile-inline-sidebar/nile-inline-sidebar.css.ts +19 -0
- package/src/nile-inline-sidebar/nile-inline-sidebar.test.ts +108 -0
- package/src/nile-inline-sidebar/nile-inline-sidebar.ts +108 -5
- package/src/nile-inline-sidebar-group/nile-inline-sidebar-group.test.ts +107 -0
- package/src/nile-inline-sidebar-item/nile-inline-sidebar-item.test.ts +107 -0
- package/src/nile-inline-sidebar-item/nile-inline-sidebar-item.ts +34 -3
- package/src/nile-input/nile-input.css.ts +4 -4
- package/src/nile-link/nile-link.css.ts +1 -2
- package/src/nile-link/nile-link.ts +1 -0
- package/src/nile-pagination/nile-pagination.css.ts +107 -3
- package/src/nile-pagination/nile-pagination.test.ts +1388 -101
- package/src/nile-pagination/nile-pagination.ts +87 -2
- package/src/nile-qr-code/index.ts +1 -0
- package/src/nile-qr-code/nile-qr-code-utils.ts +733 -0
- package/src/nile-qr-code/nile-qr-code.css.ts +26 -0
- package/src/nile-qr-code/nile-qr-code.test.ts +879 -0
- package/src/nile-qr-code/nile-qr-code.ts +431 -0
- package/src/nile-radio/nile-radio.css.ts +1 -1
- package/src/nile-rich-text-editor/nile-rich-text-editor.css.ts +25 -6
- package/src/nile-rich-text-editor/nile-rich-text-editor.ts +14 -6
- package/src/nile-rich-text-editor/nile-rte-select.ts +5 -2
- package/src/nile-select/nile-select.css.ts +7 -4
- package/src/nile-slide-toggle/nile-slide-toggle.css.ts +5 -1
- package/src/nile-textarea/nile-textarea.css.ts +10 -5
- package/src/nile-virtual-select/nile-virtual-select.css.ts +5 -3
- package/vscode-html-custom-data.json +163 -10
- package/web-test-runner.config.mjs +1 -1
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Aquera Inc 2023
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the BSD-3-Clause license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import { __decorate } from "tslib";
|
|
8
|
+
import { html } from 'lit';
|
|
9
|
+
import { customElement, property, query } from 'lit/decorators.js';
|
|
10
|
+
import { styles } from './nile-qr-code.css.js';
|
|
11
|
+
import { generateQR } from './nile-qr-code-utils.js';
|
|
12
|
+
import NileElement from '../internal/nile-element.js';
|
|
13
|
+
/**
|
|
14
|
+
* Nile QR Code component.
|
|
15
|
+
*
|
|
16
|
+
|
|
17
|
+
* @tag nile-qr-code
|
|
18
|
+
*
|
|
19
|
+
* @csspart base - The canvas element used to draw the QR code.
|
|
20
|
+
*
|
|
21
|
+
* @fires nile-qr-image-error - Emitted when the center image fails to load.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
|
|
25
|
+
*
|
|
26
|
+
|
|
27
|
+
*/
|
|
28
|
+
let NileQrCode = class NileQrCode extends NileElement {
|
|
29
|
+
constructor() {
|
|
30
|
+
super(...arguments);
|
|
31
|
+
// -------------------------------------------------------------------------
|
|
32
|
+
// Properties
|
|
33
|
+
// -------------------------------------------------------------------------
|
|
34
|
+
/**
|
|
35
|
+
* The QR code's value — the text or URL to encode.
|
|
36
|
+
*/
|
|
37
|
+
this.value = '';
|
|
38
|
+
/**
|
|
39
|
+
* The size of the QR code, in pixels.
|
|
40
|
+
*/
|
|
41
|
+
this.size = 128;
|
|
42
|
+
/**
|
|
43
|
+
* The fill color. This can be any valid CSS color, but not a CSS custom property.
|
|
44
|
+
*/
|
|
45
|
+
this.fill = 'black';
|
|
46
|
+
/**
|
|
47
|
+
* The background color. This can be any valid CSS color or `'transparent'`.
|
|
48
|
+
* It cannot be a CSS custom property.
|
|
49
|
+
*/
|
|
50
|
+
this.background = 'white';
|
|
51
|
+
/**
|
|
52
|
+
* The edge radius of each module. Must be between 0 and 0.5.
|
|
53
|
+
* Use this to create a rounded effect.
|
|
54
|
+
*/
|
|
55
|
+
this.radius = 0;
|
|
56
|
+
/**
|
|
57
|
+
* The level of error correction to use.
|
|
58
|
+
* - `'L'` — Low (~7%)
|
|
59
|
+
* - `'M'` — Medium (~15%)
|
|
60
|
+
* - `'Q'` — Quartile (~25%)
|
|
61
|
+
* - `'H'` — High (~30%)
|
|
62
|
+
*
|
|
63
|
+
* When using an image overlay, `'H'` is recommended so the QR remains scannable.
|
|
64
|
+
*/
|
|
65
|
+
this.errorCorrection = 'H';
|
|
66
|
+
/**
|
|
67
|
+
* The label for assistive devices to announce.
|
|
68
|
+
* If unspecified, the `value` will be used instead.
|
|
69
|
+
*/
|
|
70
|
+
this.label = '';
|
|
71
|
+
/**
|
|
72
|
+
* URL of an image to overlay in the center of the QR code (e.g. a logo).
|
|
73
|
+
* The image is drawn on top of the QR modules, so use `error-correction="H"`
|
|
74
|
+
* to ensure the code remains scannable.
|
|
75
|
+
*/
|
|
76
|
+
this.image = '';
|
|
77
|
+
/**
|
|
78
|
+
* Size of the center image as a fraction of the overall QR code size
|
|
79
|
+
* (0.1 – 0.4). Defaults to 0.25 (25% of the QR code).
|
|
80
|
+
*/
|
|
81
|
+
this.imageSize = 0.25;
|
|
82
|
+
/**
|
|
83
|
+
* Padding around the center image in pixels. Creates a clear area
|
|
84
|
+
* between the image and the surrounding QR modules.
|
|
85
|
+
*/
|
|
86
|
+
this.imagePadding = 4;
|
|
87
|
+
/**
|
|
88
|
+
* Optional border radius for the center image in pixels.
|
|
89
|
+
* Set to a high value for a circular mask.
|
|
90
|
+
*/
|
|
91
|
+
this.imageRadius = 4;
|
|
92
|
+
/**
|
|
93
|
+
* Apply a linear gradient to the QR modules instead of a flat color.
|
|
94
|
+
* Format: `"direction, color1, color2[, ...]"` where direction is an
|
|
95
|
+
* angle in degrees (e.g. `"135, #6366f1, #ec4899"`).
|
|
96
|
+
* When set, this overrides the `fill` property for module rendering.
|
|
97
|
+
*/
|
|
98
|
+
this.fillGradient = '';
|
|
99
|
+
// -------------------------------------------------------------------------
|
|
100
|
+
// Internal state
|
|
101
|
+
// -------------------------------------------------------------------------
|
|
102
|
+
this._loadedImage = null;
|
|
103
|
+
this._imageLoadPromise = null;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* The styles for QR Code.
|
|
107
|
+
* @remarks If you are extending this class you can extend the base styles with super. Eg `return [super(), myCustomStyles]`
|
|
108
|
+
*/
|
|
109
|
+
static get styles() {
|
|
110
|
+
return [styles];
|
|
111
|
+
}
|
|
112
|
+
// -------------------------------------------------------------------------
|
|
113
|
+
// Lifecycle
|
|
114
|
+
// -------------------------------------------------------------------------
|
|
115
|
+
updated(changedProperties) {
|
|
116
|
+
super.updated(changedProperties);
|
|
117
|
+
if (changedProperties.has('image')) {
|
|
118
|
+
this._loadedImage = null;
|
|
119
|
+
this._imageLoadPromise = null;
|
|
120
|
+
if (this.image) {
|
|
121
|
+
this.loadImage(this.image);
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
const relevantProps = [
|
|
126
|
+
'value', 'size', 'fill', 'background', 'radius', 'errorCorrection',
|
|
127
|
+
'imageSize', 'imagePadding', 'imageRadius', 'fillGradient',
|
|
128
|
+
];
|
|
129
|
+
const needsRedraw = relevantProps.some(p => changedProperties.has(p));
|
|
130
|
+
if (needsRedraw) {
|
|
131
|
+
this.drawQrCode();
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
// -------------------------------------------------------------------------
|
|
135
|
+
// Rendering
|
|
136
|
+
// -------------------------------------------------------------------------
|
|
137
|
+
render() {
|
|
138
|
+
const ariaLabel = this.label || this.value || 'QR Code';
|
|
139
|
+
return html `
|
|
140
|
+
<canvas
|
|
141
|
+
part="base"
|
|
142
|
+
role="img"
|
|
143
|
+
aria-label=${ariaLabel}
|
|
144
|
+
width=${this.size}
|
|
145
|
+
height=${this.size}
|
|
146
|
+
></canvas>
|
|
147
|
+
`;
|
|
148
|
+
}
|
|
149
|
+
// -------------------------------------------------------------------------
|
|
150
|
+
// Public methods
|
|
151
|
+
// -------------------------------------------------------------------------
|
|
152
|
+
/**
|
|
153
|
+
* Downloads the QR code as a PNG image.
|
|
154
|
+
* @param filename - The name of the downloaded file (defaults to `'qr-code.png'`).
|
|
155
|
+
*/
|
|
156
|
+
download(filename = 'qr-code.png') {
|
|
157
|
+
if (!this.canvas)
|
|
158
|
+
return;
|
|
159
|
+
const link = document.createElement('a');
|
|
160
|
+
link.download = filename;
|
|
161
|
+
link.href = this.canvas.toDataURL('image/png');
|
|
162
|
+
link.click();
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Returns the QR code canvas content as a data URL.
|
|
166
|
+
* @param type - MIME type (defaults to `'image/png'`).
|
|
167
|
+
*/
|
|
168
|
+
toDataURL(type = 'image/png') {
|
|
169
|
+
if (!this.canvas)
|
|
170
|
+
return '';
|
|
171
|
+
return this.canvas.toDataURL(type);
|
|
172
|
+
}
|
|
173
|
+
// -------------------------------------------------------------------------
|
|
174
|
+
// Private methods
|
|
175
|
+
// -------------------------------------------------------------------------
|
|
176
|
+
loadImage(src) {
|
|
177
|
+
const img = new Image();
|
|
178
|
+
img.crossOrigin = 'anonymous';
|
|
179
|
+
this._imageLoadPromise = new Promise((resolve) => {
|
|
180
|
+
img.onload = () => {
|
|
181
|
+
this._loadedImage = img;
|
|
182
|
+
this._imageLoadPromise = null;
|
|
183
|
+
this.drawQrCode();
|
|
184
|
+
resolve();
|
|
185
|
+
};
|
|
186
|
+
img.onerror = () => {
|
|
187
|
+
this._loadedImage = null;
|
|
188
|
+
this._imageLoadPromise = null;
|
|
189
|
+
this.emit('nile-qr-image-error', { src });
|
|
190
|
+
this.drawQrCode();
|
|
191
|
+
resolve();
|
|
192
|
+
};
|
|
193
|
+
});
|
|
194
|
+
img.src = src;
|
|
195
|
+
}
|
|
196
|
+
drawQrCode() {
|
|
197
|
+
if (!this.canvas)
|
|
198
|
+
return;
|
|
199
|
+
const ctx = this.canvas.getContext('2d');
|
|
200
|
+
if (!ctx)
|
|
201
|
+
return;
|
|
202
|
+
const { size, fill, background, radius: rawRadius, errorCorrection, value } = this;
|
|
203
|
+
const clampedRadius = Math.max(0, Math.min(0.5, rawRadius));
|
|
204
|
+
const matrix = generateQR(value, errorCorrection);
|
|
205
|
+
const moduleCount = matrix.length;
|
|
206
|
+
const moduleSize = size / moduleCount;
|
|
207
|
+
ctx.clearRect(0, 0, size, size);
|
|
208
|
+
if (background && background !== 'transparent') {
|
|
209
|
+
ctx.fillStyle = background;
|
|
210
|
+
ctx.fillRect(0, 0, size, size);
|
|
211
|
+
}
|
|
212
|
+
const imgFraction = Math.max(0.1, Math.min(0.4, this.imageSize));
|
|
213
|
+
const imgPixelSize = this._loadedImage ? size * imgFraction : 0;
|
|
214
|
+
const padTotal = this._loadedImage ? this.imagePadding * 2 : 0;
|
|
215
|
+
const exclusionSize = imgPixelSize + padTotal;
|
|
216
|
+
const exclusionStart = (size - exclusionSize) / 2;
|
|
217
|
+
const exclusionEnd = exclusionStart + exclusionSize;
|
|
218
|
+
const useFill = this.resolveModuleFill(ctx, size);
|
|
219
|
+
ctx.fillStyle = useFill;
|
|
220
|
+
for (let row = 0; row < moduleCount; row++) {
|
|
221
|
+
for (let col = 0; col < moduleCount; col++) {
|
|
222
|
+
if (matrix[row][col] !== 1)
|
|
223
|
+
continue;
|
|
224
|
+
const x = col * moduleSize;
|
|
225
|
+
const y = row * moduleSize;
|
|
226
|
+
if (this._loadedImage) {
|
|
227
|
+
const modRight = x + moduleSize;
|
|
228
|
+
const modBottom = y + moduleSize;
|
|
229
|
+
if (x >= exclusionStart && modRight <= exclusionEnd &&
|
|
230
|
+
y >= exclusionStart && modBottom <= exclusionEnd) {
|
|
231
|
+
continue;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
if (clampedRadius > 0) {
|
|
235
|
+
this.drawRoundedModule(ctx, x, y, moduleSize, moduleSize, clampedRadius * moduleSize);
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
ctx.fillRect(x, y, moduleSize, moduleSize);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
if (this._loadedImage) {
|
|
243
|
+
this.drawCenterImage(ctx, size, imgPixelSize);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Returns the fill style for QR modules — either a gradient or the flat fill color.
|
|
248
|
+
*/
|
|
249
|
+
resolveModuleFill(ctx, size) {
|
|
250
|
+
if (!this.fillGradient)
|
|
251
|
+
return this.fill;
|
|
252
|
+
const parts = this.fillGradient.split(',').map(s => s.trim());
|
|
253
|
+
if (parts.length < 3)
|
|
254
|
+
return this.fill;
|
|
255
|
+
const angleDeg = parseFloat(parts[0]);
|
|
256
|
+
if (Number.isNaN(angleDeg))
|
|
257
|
+
return this.fill;
|
|
258
|
+
const angleRad = (angleDeg * Math.PI) / 180;
|
|
259
|
+
const cx = size / 2;
|
|
260
|
+
const cy = size / 2;
|
|
261
|
+
const len = size / 2;
|
|
262
|
+
const x0 = cx - Math.cos(angleRad) * len;
|
|
263
|
+
const y0 = cy - Math.sin(angleRad) * len;
|
|
264
|
+
const x1 = cx + Math.cos(angleRad) * len;
|
|
265
|
+
const y1 = cy + Math.sin(angleRad) * len;
|
|
266
|
+
const gradient = ctx.createLinearGradient(x0, y0, x1, y1);
|
|
267
|
+
const colors = parts.slice(1);
|
|
268
|
+
for (let i = 0; i < colors.length; i++) {
|
|
269
|
+
gradient.addColorStop(i / (colors.length - 1), colors[i]);
|
|
270
|
+
}
|
|
271
|
+
return gradient;
|
|
272
|
+
}
|
|
273
|
+
drawCenterImage(ctx, size, imgPixelSize) {
|
|
274
|
+
if (!this._loadedImage)
|
|
275
|
+
return;
|
|
276
|
+
const x = (size - imgPixelSize) / 2;
|
|
277
|
+
const y = (size - imgPixelSize) / 2;
|
|
278
|
+
const r = Math.min(this.imageRadius, imgPixelSize / 2);
|
|
279
|
+
const pad = this.imagePadding;
|
|
280
|
+
if (pad > 0 && this.background && this.background !== 'transparent') {
|
|
281
|
+
ctx.fillStyle = this.background;
|
|
282
|
+
const bx = x - pad;
|
|
283
|
+
const by = y - pad;
|
|
284
|
+
const bw = imgPixelSize + pad * 2;
|
|
285
|
+
const bh = imgPixelSize + pad * 2;
|
|
286
|
+
const br = r + pad * 0.5;
|
|
287
|
+
this.drawRoundedRect(ctx, bx, by, bw, bh, br);
|
|
288
|
+
ctx.fill();
|
|
289
|
+
}
|
|
290
|
+
ctx.save();
|
|
291
|
+
this.clipRoundedRect(ctx, x, y, imgPixelSize, imgPixelSize, r);
|
|
292
|
+
ctx.drawImage(this._loadedImage, x, y, imgPixelSize, imgPixelSize);
|
|
293
|
+
ctx.restore();
|
|
294
|
+
}
|
|
295
|
+
drawRoundedModule(ctx, x, y, w, h, r) {
|
|
296
|
+
ctx.beginPath();
|
|
297
|
+
ctx.moveTo(x + r, y);
|
|
298
|
+
ctx.lineTo(x + w - r, y);
|
|
299
|
+
ctx.arcTo(x + w, y, x + w, y + r, r);
|
|
300
|
+
ctx.lineTo(x + w, y + h - r);
|
|
301
|
+
ctx.arcTo(x + w, y + h, x + w - r, y + h, r);
|
|
302
|
+
ctx.lineTo(x + r, y + h);
|
|
303
|
+
ctx.arcTo(x, y + h, x, y + h - r, r);
|
|
304
|
+
ctx.lineTo(x, y + r);
|
|
305
|
+
ctx.arcTo(x, y, x + r, y, r);
|
|
306
|
+
ctx.closePath();
|
|
307
|
+
ctx.fill();
|
|
308
|
+
}
|
|
309
|
+
drawRoundedRect(ctx, x, y, w, h, r) {
|
|
310
|
+
ctx.beginPath();
|
|
311
|
+
ctx.moveTo(x + r, y);
|
|
312
|
+
ctx.lineTo(x + w - r, y);
|
|
313
|
+
ctx.arcTo(x + w, y, x + w, y + r, r);
|
|
314
|
+
ctx.lineTo(x + w, y + h - r);
|
|
315
|
+
ctx.arcTo(x + w, y + h, x + w - r, y + h, r);
|
|
316
|
+
ctx.lineTo(x + r, y + h);
|
|
317
|
+
ctx.arcTo(x, y + h, x, y + h - r, r);
|
|
318
|
+
ctx.lineTo(x, y + r);
|
|
319
|
+
ctx.arcTo(x, y, x + r, y, r);
|
|
320
|
+
ctx.closePath();
|
|
321
|
+
}
|
|
322
|
+
clipRoundedRect(ctx, x, y, w, h, r) {
|
|
323
|
+
ctx.beginPath();
|
|
324
|
+
ctx.moveTo(x + r, y);
|
|
325
|
+
ctx.lineTo(x + w - r, y);
|
|
326
|
+
ctx.arcTo(x + w, y, x + w, y + r, r);
|
|
327
|
+
ctx.lineTo(x + w, y + h - r);
|
|
328
|
+
ctx.arcTo(x + w, y + h, x + w - r, y + h, r);
|
|
329
|
+
ctx.lineTo(x + r, y + h);
|
|
330
|
+
ctx.arcTo(x, y + h, x, y + h - r, r);
|
|
331
|
+
ctx.lineTo(x, y + r);
|
|
332
|
+
ctx.arcTo(x, y, x + r, y, r);
|
|
333
|
+
ctx.closePath();
|
|
334
|
+
ctx.clip();
|
|
335
|
+
}
|
|
336
|
+
};
|
|
337
|
+
__decorate([
|
|
338
|
+
property({ type: String, reflect: true })
|
|
339
|
+
], NileQrCode.prototype, "value", void 0);
|
|
340
|
+
__decorate([
|
|
341
|
+
property({ type: Number, reflect: true })
|
|
342
|
+
], NileQrCode.prototype, "size", void 0);
|
|
343
|
+
__decorate([
|
|
344
|
+
property({ type: String, reflect: true })
|
|
345
|
+
], NileQrCode.prototype, "fill", void 0);
|
|
346
|
+
__decorate([
|
|
347
|
+
property({ type: String, reflect: true })
|
|
348
|
+
], NileQrCode.prototype, "background", void 0);
|
|
349
|
+
__decorate([
|
|
350
|
+
property({ type: Number, reflect: true })
|
|
351
|
+
], NileQrCode.prototype, "radius", void 0);
|
|
352
|
+
__decorate([
|
|
353
|
+
property({ attribute: 'error-correction', reflect: true })
|
|
354
|
+
], NileQrCode.prototype, "errorCorrection", void 0);
|
|
355
|
+
__decorate([
|
|
356
|
+
property({ type: String, reflect: true })
|
|
357
|
+
], NileQrCode.prototype, "label", void 0);
|
|
358
|
+
__decorate([
|
|
359
|
+
property({ type: String, reflect: true })
|
|
360
|
+
], NileQrCode.prototype, "image", void 0);
|
|
361
|
+
__decorate([
|
|
362
|
+
property({ attribute: 'image-size', type: Number, reflect: true })
|
|
363
|
+
], NileQrCode.prototype, "imageSize", void 0);
|
|
364
|
+
__decorate([
|
|
365
|
+
property({ attribute: 'image-padding', type: Number, reflect: true })
|
|
366
|
+
], NileQrCode.prototype, "imagePadding", void 0);
|
|
367
|
+
__decorate([
|
|
368
|
+
property({ attribute: 'image-radius', type: Number, reflect: true })
|
|
369
|
+
], NileQrCode.prototype, "imageRadius", void 0);
|
|
370
|
+
__decorate([
|
|
371
|
+
property({ attribute: 'fill-gradient', type: String, reflect: true })
|
|
372
|
+
], NileQrCode.prototype, "fillGradient", void 0);
|
|
373
|
+
__decorate([
|
|
374
|
+
query('canvas')
|
|
375
|
+
], NileQrCode.prototype, "canvas", void 0);
|
|
376
|
+
NileQrCode = __decorate([
|
|
377
|
+
customElement('nile-qr-code')
|
|
378
|
+
], NileQrCode);
|
|
379
|
+
export { NileQrCode };
|
|
380
|
+
export default NileQrCode;
|
|
381
|
+
//# sourceMappingURL=nile-qr-code.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nile-qr-code.js","sourceRoot":"","sources":["../../../src/nile-qr-code/nile-qr-code.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;AAEH,OAAO,EAAE,IAAI,EAAkD,MAAM,KAAK,CAAC;AAC3E,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAwB,MAAM,yBAAyB,CAAC;AAC3E,OAAO,WAAW,MAAM,6BAA6B,CAAC;AAEtD;;;;;;;;;;;;;;GAcG;AAEI,IAAM,UAAU,GAAhB,MAAM,UAAW,SAAQ,WAAW;IAApC;;QAUL,4EAA4E;QAC5E,aAAa;QACb,4EAA4E;QAE5E;;WAEG;QAEH,UAAK,GAAG,EAAE,CAAC;QAEX;;WAEG;QAEH,SAAI,GAAG,GAAG,CAAC;QAEX;;WAEG;QAEH,SAAI,GAAG,OAAO,CAAC;QAEf;;;WAGG;QAEH,eAAU,GAAG,OAAO,CAAC;QAErB;;;WAGG;QAEH,WAAM,GAAG,CAAC,CAAC;QAEX;;;;;;;;WAQG;QAEH,oBAAe,GAAyB,GAAG,CAAC;QAE5C;;;WAGG;QAEH,UAAK,GAAG,EAAE,CAAC;QAEX;;;;WAIG;QAEH,UAAK,GAAG,EAAE,CAAC;QAEX;;;WAGG;QAEH,cAAS,GAAG,IAAI,CAAC;QAEjB;;;WAGG;QAEH,iBAAY,GAAG,CAAC,CAAC;QAEjB;;;WAGG;QAEH,gBAAW,GAAG,CAAC,CAAC;QA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CAC/B;AAOX;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;6CAClD;AAOjB;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;gDACrD;AAOjB;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;+CACrD;AAShB;IADC,QAAQ,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;gDACpD;AAeV;IADP,KAAK,CAAC,QAAQ,CAAC;0CACmB;AApHxB,UAAU;IADtB,aAAa,CAAC,cAAc,CAAC;GACjB,UAAU,CAyYtB;;AAED,eAAe,UAAU,CAAC","sourcesContent":["/**\n * Copyright Aquera Inc 2023\n *\n * This source code is licensed under the BSD-3-Clause license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { html, CSSResultArray, TemplateResult, PropertyValues } from 'lit';\nimport { customElement, property, query } from 'lit/decorators.js';\nimport { styles } from './nile-qr-code.css.js';\nimport { generateQR, ErrorCorrectionLevel } from './nile-qr-code-utils.js';\nimport NileElement from '../internal/nile-element.js';\n\n/**\n * Nile QR Code component.\n *\n \n * @tag nile-qr-code\n *\n * @csspart base - The canvas element used to draw the QR code.\n *\n * @fires nile-qr-image-error - Emitted when the center image fails to load.\n *\n * @example\n \n *\n \n */\n@customElement('nile-qr-code')\nexport class NileQrCode extends NileElement {\n\n /**\n * The styles for QR Code.\n * @remarks If you are extending this class you can extend the base styles with super. Eg `return [super(), myCustomStyles]`\n */\n public static get styles(): CSSResultArray {\n return [styles];\n }\n\n // -------------------------------------------------------------------------\n // Properties\n // -------------------------------------------------------------------------\n\n /**\n * The QR code's value — the text or URL to encode.\n */\n @property({ type: String, reflect: true })\n value = '';\n\n /**\n * The size of the QR code, in pixels.\n */\n @property({ type: Number, reflect: true })\n size = 128;\n\n /**\n * The fill color. This can be any valid CSS color, but not a CSS custom property.\n */\n @property({ type: String, reflect: true })\n fill = 'black';\n\n /**\n * The background color. This can be any valid CSS color or `'transparent'`.\n * It cannot be a CSS custom property.\n */\n @property({ type: String, reflect: true })\n background = 'white';\n\n /**\n * The edge radius of each module. Must be between 0 and 0.5.\n * Use this to create a rounded effect.\n */\n @property({ type: Number, reflect: true })\n radius = 0;\n\n /**\n * The level of error correction to use.\n * - `'L'` — Low (~7%)\n * - `'M'` — Medium (~15%)\n * - `'Q'` — Quartile (~25%)\n * - `'H'` — High (~30%)\n *\n * When using an image overlay, `'H'` is recommended so the QR remains scannable.\n */\n @property({ attribute: 'error-correction', reflect: true })\n errorCorrection: ErrorCorrectionLevel = 'H';\n\n /**\n * The label for assistive devices to announce.\n * If unspecified, the `value` will be used instead.\n */\n @property({ type: String, reflect: true })\n label = '';\n\n /**\n * URL of an image to overlay in the center of the QR code (e.g. a logo).\n * The image is drawn on top of the QR modules, so use `error-correction=\"H\"`\n * to ensure the code remains scannable.\n */\n @property({ type: String, reflect: true })\n image = '';\n\n /**\n * Size of the center image as a fraction of the overall QR code size\n * (0.1 – 0.4). Defaults to 0.25 (25% of the QR code).\n */\n @property({ attribute: 'image-size', type: Number, reflect: true })\n imageSize = 0.25;\n\n /**\n * Padding around the center image in pixels. Creates a clear area\n * between the image and the surrounding QR modules.\n */\n @property({ attribute: 'image-padding', type: Number, reflect: true })\n imagePadding = 4;\n\n /**\n * Optional border radius for the center image in pixels.\n * Set to a high value for a circular mask.\n */\n @property({ attribute: 'image-radius', type: Number, reflect: true })\n imageRadius = 4;\n\n /**\n * Apply a linear gradient to the QR modules instead of a flat color.\n * Format: `\"direction, color1, color2[, ...]\"` where direction is an\n * angle in degrees (e.g. `\"135, #6366f1, #ec4899\"`).\n * When set, this overrides the `fill` property for module rendering.\n */\n @property({ attribute: 'fill-gradient', type: String, reflect: true })\n fillGradient = '';\n\n // -------------------------------------------------------------------------\n // Internal state\n // -------------------------------------------------------------------------\n\n private _loadedImage: HTMLImageElement | null = null;\n\n private _imageLoadPromise: Promise<void> | null = null;\n\n // -------------------------------------------------------------------------\n // Refs\n // -------------------------------------------------------------------------\n\n @query('canvas')\n private canvas!: HTMLCanvasElement;\n\n // -------------------------------------------------------------------------\n // Lifecycle\n // -------------------------------------------------------------------------\n\n protected override updated(changedProperties: PropertyValues): void {\n super.updated(changedProperties);\n\n if (changedProperties.has('image')) {\n this._loadedImage = null;\n this._imageLoadPromise = null;\n if (this.image) {\n this.loadImage(this.image);\n return;\n }\n }\n\n const relevantProps: (keyof NileQrCode)[] = [\n 'value', 'size', 'fill', 'background', 'radius', 'errorCorrection',\n 'imageSize', 'imagePadding', 'imageRadius', 'fillGradient',\n ];\n\n const needsRedraw = relevantProps.some(p => changedProperties.has(p));\n if (needsRedraw) {\n this.drawQrCode();\n }\n }\n\n // -------------------------------------------------------------------------\n // Rendering\n // -------------------------------------------------------------------------\n\n public render(): TemplateResult {\n const ariaLabel = this.label || this.value || 'QR Code';\n\n return html`\n <canvas\n part=\"base\"\n role=\"img\"\n aria-label=${ariaLabel}\n width=${this.size}\n height=${this.size}\n ></canvas>\n `;\n }\n\n // -------------------------------------------------------------------------\n // Public methods\n // -------------------------------------------------------------------------\n\n /**\n * Downloads the QR code as a PNG image.\n * @param filename - The name of the downloaded file (defaults to `'qr-code.png'`).\n */\n public download(filename = 'qr-code.png'): void {\n if (!this.canvas) return;\n const link = document.createElement('a');\n link.download = filename;\n link.href = this.canvas.toDataURL('image/png');\n link.click();\n }\n\n /**\n * Returns the QR code canvas content as a data URL.\n * @param type - MIME type (defaults to `'image/png'`).\n */\n public toDataURL(type = 'image/png'): string {\n if (!this.canvas) return '';\n return this.canvas.toDataURL(type);\n }\n\n // -------------------------------------------------------------------------\n // Private methods\n // -------------------------------------------------------------------------\n\n private loadImage(src: string): void {\n const img = new Image();\n img.crossOrigin = 'anonymous';\n\n this._imageLoadPromise = new Promise<void>((resolve) => {\n img.onload = () => {\n this._loadedImage = img;\n this._imageLoadPromise = null;\n this.drawQrCode();\n resolve();\n };\n img.onerror = () => {\n this._loadedImage = null;\n this._imageLoadPromise = null;\n this.emit('nile-qr-image-error', { src });\n this.drawQrCode();\n resolve();\n };\n });\n\n img.src = src;\n }\n\n private drawQrCode(): void {\n if (!this.canvas) return;\n\n const ctx = this.canvas.getContext('2d');\n if (!ctx) return;\n\n const { size, fill, background, radius: rawRadius, errorCorrection, value } = this;\n\n const clampedRadius = Math.max(0, Math.min(0.5, rawRadius));\n\n const matrix = generateQR(value, errorCorrection);\n const moduleCount = matrix.length;\n const moduleSize = size / moduleCount;\n\n ctx.clearRect(0, 0, size, size);\n\n if (background && background !== 'transparent') {\n ctx.fillStyle = background;\n ctx.fillRect(0, 0, size, size);\n }\n\n const imgFraction = Math.max(0.1, Math.min(0.4, this.imageSize));\n const imgPixelSize = this._loadedImage ? size * imgFraction : 0;\n const padTotal = this._loadedImage ? this.imagePadding * 2 : 0;\n const exclusionSize = imgPixelSize + padTotal;\n const exclusionStart = (size - exclusionSize) / 2;\n const exclusionEnd = exclusionStart + exclusionSize;\n\n const useFill = this.resolveModuleFill(ctx, size);\n ctx.fillStyle = useFill;\n\n for (let row = 0; row < moduleCount; row++) {\n for (let col = 0; col < moduleCount; col++) {\n if (matrix[row][col] !== 1) continue;\n\n const x = col * moduleSize;\n const y = row * moduleSize;\n\n if (this._loadedImage) {\n const modRight = x + moduleSize;\n const modBottom = y + moduleSize;\n if (x >= exclusionStart && modRight <= exclusionEnd &&\n y >= exclusionStart && modBottom <= exclusionEnd) {\n continue;\n }\n }\n\n if (clampedRadius > 0) {\n this.drawRoundedModule(ctx, x, y, moduleSize, moduleSize, clampedRadius * moduleSize);\n } else {\n ctx.fillRect(x, y, moduleSize, moduleSize);\n }\n }\n }\n\n if (this._loadedImage) {\n this.drawCenterImage(ctx, size, imgPixelSize);\n }\n }\n\n /**\n * Returns the fill style for QR modules — either a gradient or the flat fill color.\n */\n private resolveModuleFill(ctx: CanvasRenderingContext2D, size: number): string | CanvasGradient {\n if (!this.fillGradient) return this.fill;\n\n const parts = this.fillGradient.split(',').map(s => s.trim());\n if (parts.length < 3) return this.fill;\n\n const angleDeg = parseFloat(parts[0]);\n if (Number.isNaN(angleDeg)) return this.fill;\n\n const angleRad = (angleDeg * Math.PI) / 180;\n const cx = size / 2;\n const cy = size / 2;\n const len = size / 2;\n const x0 = cx - Math.cos(angleRad) * len;\n const y0 = cy - Math.sin(angleRad) * len;\n const x1 = cx + Math.cos(angleRad) * len;\n const y1 = cy + Math.sin(angleRad) * len;\n\n const gradient = ctx.createLinearGradient(x0, y0, x1, y1);\n const colors = parts.slice(1);\n for (let i = 0; i < colors.length; i++) {\n gradient.addColorStop(i / (colors.length - 1), colors[i]);\n }\n return gradient;\n }\n\n private drawCenterImage(ctx: CanvasRenderingContext2D, size: number, imgPixelSize: number): void {\n if (!this._loadedImage) return;\n\n const x = (size - imgPixelSize) / 2;\n const y = (size - imgPixelSize) / 2;\n const r = Math.min(this.imageRadius, imgPixelSize / 2);\n\n const pad = this.imagePadding;\n if (pad > 0 && this.background && this.background !== 'transparent') {\n ctx.fillStyle = this.background;\n const bx = x - pad;\n const by = y - pad;\n const bw = imgPixelSize + pad * 2;\n const bh = imgPixelSize + pad * 2;\n const br = r + pad * 0.5;\n this.drawRoundedRect(ctx, bx, by, bw, bh, br);\n ctx.fill();\n }\n\n ctx.save();\n this.clipRoundedRect(ctx, x, y, imgPixelSize, imgPixelSize, r);\n ctx.drawImage(this._loadedImage, x, y, imgPixelSize, imgPixelSize);\n ctx.restore();\n }\n\n private drawRoundedModule(\n ctx: CanvasRenderingContext2D,\n x: number,\n y: number,\n w: number,\n h: number,\n r: number\n ): void {\n ctx.beginPath();\n ctx.moveTo(x + r, y);\n ctx.lineTo(x + w - r, y);\n ctx.arcTo(x + w, y, x + w, y + r, r);\n ctx.lineTo(x + w, y + h - r);\n ctx.arcTo(x + w, y + h, x + w - r, y + h, r);\n ctx.lineTo(x + r, y + h);\n ctx.arcTo(x, y + h, x, y + h - r, r);\n ctx.lineTo(x, y + r);\n ctx.arcTo(x, y, x + r, y, r);\n ctx.closePath();\n ctx.fill();\n }\n\n private drawRoundedRect(\n ctx: CanvasRenderingContext2D,\n x: number,\n y: number,\n w: number,\n h: number,\n r: number\n ): void {\n ctx.beginPath();\n ctx.moveTo(x + r, y);\n ctx.lineTo(x + w - r, y);\n ctx.arcTo(x + w, y, x + w, y + r, r);\n ctx.lineTo(x + w, y + h - r);\n ctx.arcTo(x + w, y + h, x + w - r, y + h, r);\n ctx.lineTo(x + r, y + h);\n ctx.arcTo(x, y + h, x, y + h - r, r);\n ctx.lineTo(x, y + r);\n ctx.arcTo(x, y, x + r, y, r);\n ctx.closePath();\n }\n\n private clipRoundedRect(\n ctx: CanvasRenderingContext2D,\n x: number,\n y: number,\n w: number,\n h: number,\n r: number\n ): void {\n ctx.beginPath();\n ctx.moveTo(x + r, y);\n ctx.lineTo(x + w - r, y);\n ctx.arcTo(x + w, y, x + w, y + r, r);\n ctx.lineTo(x + w, y + h - r);\n ctx.arcTo(x + w, y + h, x + w - r, y + h, r);\n ctx.lineTo(x + r, y + h);\n ctx.arcTo(x, y + h, x, y + h - r, r);\n ctx.lineTo(x, y + r);\n ctx.arcTo(x, y, x + r, y, r);\n ctx.closePath();\n ctx.clip();\n }\n}\n\nexport default NileQrCode;\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nile-qr-code': NileQrCode;\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './nile-qr-code';
|