@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,431 @@
|
|
|
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
|
+
|
|
8
|
+
import { html, CSSResultArray, TemplateResult, PropertyValues } from 'lit';
|
|
9
|
+
import { customElement, property, query } from 'lit/decorators.js';
|
|
10
|
+
import { styles } from './nile-qr-code.css.js';
|
|
11
|
+
import { generateQR, ErrorCorrectionLevel } from './nile-qr-code-utils.js';
|
|
12
|
+
import NileElement from '../internal/nile-element.js';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Nile QR Code component.
|
|
16
|
+
*
|
|
17
|
+
|
|
18
|
+
* @tag nile-qr-code
|
|
19
|
+
*
|
|
20
|
+
* @csspart base - The canvas element used to draw the QR code.
|
|
21
|
+
*
|
|
22
|
+
* @fires nile-qr-image-error - Emitted when the center image fails to load.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
|
|
26
|
+
*
|
|
27
|
+
|
|
28
|
+
*/
|
|
29
|
+
@customElement('nile-qr-code')
|
|
30
|
+
export class NileQrCode extends NileElement {
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* The styles for QR Code.
|
|
34
|
+
* @remarks If you are extending this class you can extend the base styles with super. Eg `return [super(), myCustomStyles]`
|
|
35
|
+
*/
|
|
36
|
+
public static get styles(): CSSResultArray {
|
|
37
|
+
return [styles];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// -------------------------------------------------------------------------
|
|
41
|
+
// Properties
|
|
42
|
+
// -------------------------------------------------------------------------
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* The QR code's value — the text or URL to encode.
|
|
46
|
+
*/
|
|
47
|
+
@property({ type: String, reflect: true })
|
|
48
|
+
value = '';
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* The size of the QR code, in pixels.
|
|
52
|
+
*/
|
|
53
|
+
@property({ type: Number, reflect: true })
|
|
54
|
+
size = 128;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* The fill color. This can be any valid CSS color, but not a CSS custom property.
|
|
58
|
+
*/
|
|
59
|
+
@property({ type: String, reflect: true })
|
|
60
|
+
fill = 'black';
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* The background color. This can be any valid CSS color or `'transparent'`.
|
|
64
|
+
* It cannot be a CSS custom property.
|
|
65
|
+
*/
|
|
66
|
+
@property({ type: String, reflect: true })
|
|
67
|
+
background = 'white';
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* The edge radius of each module. Must be between 0 and 0.5.
|
|
71
|
+
* Use this to create a rounded effect.
|
|
72
|
+
*/
|
|
73
|
+
@property({ type: Number, reflect: true })
|
|
74
|
+
radius = 0;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* The level of error correction to use.
|
|
78
|
+
* - `'L'` — Low (~7%)
|
|
79
|
+
* - `'M'` — Medium (~15%)
|
|
80
|
+
* - `'Q'` — Quartile (~25%)
|
|
81
|
+
* - `'H'` — High (~30%)
|
|
82
|
+
*
|
|
83
|
+
* When using an image overlay, `'H'` is recommended so the QR remains scannable.
|
|
84
|
+
*/
|
|
85
|
+
@property({ attribute: 'error-correction', reflect: true })
|
|
86
|
+
errorCorrection: ErrorCorrectionLevel = 'H';
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* The label for assistive devices to announce.
|
|
90
|
+
* If unspecified, the `value` will be used instead.
|
|
91
|
+
*/
|
|
92
|
+
@property({ type: String, reflect: true })
|
|
93
|
+
label = '';
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* URL of an image to overlay in the center of the QR code (e.g. a logo).
|
|
97
|
+
* The image is drawn on top of the QR modules, so use `error-correction="H"`
|
|
98
|
+
* to ensure the code remains scannable.
|
|
99
|
+
*/
|
|
100
|
+
@property({ type: String, reflect: true })
|
|
101
|
+
image = '';
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Size of the center image as a fraction of the overall QR code size
|
|
105
|
+
* (0.1 – 0.4). Defaults to 0.25 (25% of the QR code).
|
|
106
|
+
*/
|
|
107
|
+
@property({ attribute: 'image-size', type: Number, reflect: true })
|
|
108
|
+
imageSize = 0.25;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Padding around the center image in pixels. Creates a clear area
|
|
112
|
+
* between the image and the surrounding QR modules.
|
|
113
|
+
*/
|
|
114
|
+
@property({ attribute: 'image-padding', type: Number, reflect: true })
|
|
115
|
+
imagePadding = 4;
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Optional border radius for the center image in pixels.
|
|
119
|
+
* Set to a high value for a circular mask.
|
|
120
|
+
*/
|
|
121
|
+
@property({ attribute: 'image-radius', type: Number, reflect: true })
|
|
122
|
+
imageRadius = 4;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Apply a linear gradient to the QR modules instead of a flat color.
|
|
126
|
+
* Format: `"direction, color1, color2[, ...]"` where direction is an
|
|
127
|
+
* angle in degrees (e.g. `"135, #6366f1, #ec4899"`).
|
|
128
|
+
* When set, this overrides the `fill` property for module rendering.
|
|
129
|
+
*/
|
|
130
|
+
@property({ attribute: 'fill-gradient', type: String, reflect: true })
|
|
131
|
+
fillGradient = '';
|
|
132
|
+
|
|
133
|
+
// -------------------------------------------------------------------------
|
|
134
|
+
// Internal state
|
|
135
|
+
// -------------------------------------------------------------------------
|
|
136
|
+
|
|
137
|
+
private _loadedImage: HTMLImageElement | null = null;
|
|
138
|
+
|
|
139
|
+
private _imageLoadPromise: Promise<void> | null = null;
|
|
140
|
+
|
|
141
|
+
// -------------------------------------------------------------------------
|
|
142
|
+
// Refs
|
|
143
|
+
// -------------------------------------------------------------------------
|
|
144
|
+
|
|
145
|
+
@query('canvas')
|
|
146
|
+
private canvas!: HTMLCanvasElement;
|
|
147
|
+
|
|
148
|
+
// -------------------------------------------------------------------------
|
|
149
|
+
// Lifecycle
|
|
150
|
+
// -------------------------------------------------------------------------
|
|
151
|
+
|
|
152
|
+
protected override updated(changedProperties: PropertyValues): void {
|
|
153
|
+
super.updated(changedProperties);
|
|
154
|
+
|
|
155
|
+
if (changedProperties.has('image')) {
|
|
156
|
+
this._loadedImage = null;
|
|
157
|
+
this._imageLoadPromise = null;
|
|
158
|
+
if (this.image) {
|
|
159
|
+
this.loadImage(this.image);
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const relevantProps: (keyof NileQrCode)[] = [
|
|
165
|
+
'value', 'size', 'fill', 'background', 'radius', 'errorCorrection',
|
|
166
|
+
'imageSize', 'imagePadding', 'imageRadius', 'fillGradient',
|
|
167
|
+
];
|
|
168
|
+
|
|
169
|
+
const needsRedraw = relevantProps.some(p => changedProperties.has(p));
|
|
170
|
+
if (needsRedraw) {
|
|
171
|
+
this.drawQrCode();
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// -------------------------------------------------------------------------
|
|
176
|
+
// Rendering
|
|
177
|
+
// -------------------------------------------------------------------------
|
|
178
|
+
|
|
179
|
+
public render(): TemplateResult {
|
|
180
|
+
const ariaLabel = this.label || this.value || 'QR Code';
|
|
181
|
+
|
|
182
|
+
return html`
|
|
183
|
+
<canvas
|
|
184
|
+
part="base"
|
|
185
|
+
role="img"
|
|
186
|
+
aria-label=${ariaLabel}
|
|
187
|
+
width=${this.size}
|
|
188
|
+
height=${this.size}
|
|
189
|
+
></canvas>
|
|
190
|
+
`;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// -------------------------------------------------------------------------
|
|
194
|
+
// Public methods
|
|
195
|
+
// -------------------------------------------------------------------------
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Downloads the QR code as a PNG image.
|
|
199
|
+
* @param filename - The name of the downloaded file (defaults to `'qr-code.png'`).
|
|
200
|
+
*/
|
|
201
|
+
public download(filename = 'qr-code.png'): void {
|
|
202
|
+
if (!this.canvas) return;
|
|
203
|
+
const link = document.createElement('a');
|
|
204
|
+
link.download = filename;
|
|
205
|
+
link.href = this.canvas.toDataURL('image/png');
|
|
206
|
+
link.click();
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Returns the QR code canvas content as a data URL.
|
|
211
|
+
* @param type - MIME type (defaults to `'image/png'`).
|
|
212
|
+
*/
|
|
213
|
+
public toDataURL(type = 'image/png'): string {
|
|
214
|
+
if (!this.canvas) return '';
|
|
215
|
+
return this.canvas.toDataURL(type);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// -------------------------------------------------------------------------
|
|
219
|
+
// Private methods
|
|
220
|
+
// -------------------------------------------------------------------------
|
|
221
|
+
|
|
222
|
+
private loadImage(src: string): void {
|
|
223
|
+
const img = new Image();
|
|
224
|
+
img.crossOrigin = 'anonymous';
|
|
225
|
+
|
|
226
|
+
this._imageLoadPromise = new Promise<void>((resolve) => {
|
|
227
|
+
img.onload = () => {
|
|
228
|
+
this._loadedImage = img;
|
|
229
|
+
this._imageLoadPromise = null;
|
|
230
|
+
this.drawQrCode();
|
|
231
|
+
resolve();
|
|
232
|
+
};
|
|
233
|
+
img.onerror = () => {
|
|
234
|
+
this._loadedImage = null;
|
|
235
|
+
this._imageLoadPromise = null;
|
|
236
|
+
this.emit('nile-qr-image-error', { src });
|
|
237
|
+
this.drawQrCode();
|
|
238
|
+
resolve();
|
|
239
|
+
};
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
img.src = src;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
private drawQrCode(): void {
|
|
246
|
+
if (!this.canvas) return;
|
|
247
|
+
|
|
248
|
+
const ctx = this.canvas.getContext('2d');
|
|
249
|
+
if (!ctx) return;
|
|
250
|
+
|
|
251
|
+
const { size, fill, background, radius: rawRadius, errorCorrection, value } = this;
|
|
252
|
+
|
|
253
|
+
const clampedRadius = Math.max(0, Math.min(0.5, rawRadius));
|
|
254
|
+
|
|
255
|
+
const matrix = generateQR(value, errorCorrection);
|
|
256
|
+
const moduleCount = matrix.length;
|
|
257
|
+
const moduleSize = size / moduleCount;
|
|
258
|
+
|
|
259
|
+
ctx.clearRect(0, 0, size, size);
|
|
260
|
+
|
|
261
|
+
if (background && background !== 'transparent') {
|
|
262
|
+
ctx.fillStyle = background;
|
|
263
|
+
ctx.fillRect(0, 0, size, size);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
const imgFraction = Math.max(0.1, Math.min(0.4, this.imageSize));
|
|
267
|
+
const imgPixelSize = this._loadedImage ? size * imgFraction : 0;
|
|
268
|
+
const padTotal = this._loadedImage ? this.imagePadding * 2 : 0;
|
|
269
|
+
const exclusionSize = imgPixelSize + padTotal;
|
|
270
|
+
const exclusionStart = (size - exclusionSize) / 2;
|
|
271
|
+
const exclusionEnd = exclusionStart + exclusionSize;
|
|
272
|
+
|
|
273
|
+
const useFill = this.resolveModuleFill(ctx, size);
|
|
274
|
+
ctx.fillStyle = useFill;
|
|
275
|
+
|
|
276
|
+
for (let row = 0; row < moduleCount; row++) {
|
|
277
|
+
for (let col = 0; col < moduleCount; col++) {
|
|
278
|
+
if (matrix[row][col] !== 1) continue;
|
|
279
|
+
|
|
280
|
+
const x = col * moduleSize;
|
|
281
|
+
const y = row * moduleSize;
|
|
282
|
+
|
|
283
|
+
if (this._loadedImage) {
|
|
284
|
+
const modRight = x + moduleSize;
|
|
285
|
+
const modBottom = y + moduleSize;
|
|
286
|
+
if (x >= exclusionStart && modRight <= exclusionEnd &&
|
|
287
|
+
y >= exclusionStart && modBottom <= exclusionEnd) {
|
|
288
|
+
continue;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
if (clampedRadius > 0) {
|
|
293
|
+
this.drawRoundedModule(ctx, x, y, moduleSize, moduleSize, clampedRadius * moduleSize);
|
|
294
|
+
} else {
|
|
295
|
+
ctx.fillRect(x, y, moduleSize, moduleSize);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
if (this._loadedImage) {
|
|
301
|
+
this.drawCenterImage(ctx, size, imgPixelSize);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* Returns the fill style for QR modules — either a gradient or the flat fill color.
|
|
307
|
+
*/
|
|
308
|
+
private resolveModuleFill(ctx: CanvasRenderingContext2D, size: number): string | CanvasGradient {
|
|
309
|
+
if (!this.fillGradient) return this.fill;
|
|
310
|
+
|
|
311
|
+
const parts = this.fillGradient.split(',').map(s => s.trim());
|
|
312
|
+
if (parts.length < 3) return this.fill;
|
|
313
|
+
|
|
314
|
+
const angleDeg = parseFloat(parts[0]);
|
|
315
|
+
if (Number.isNaN(angleDeg)) return this.fill;
|
|
316
|
+
|
|
317
|
+
const angleRad = (angleDeg * Math.PI) / 180;
|
|
318
|
+
const cx = size / 2;
|
|
319
|
+
const cy = size / 2;
|
|
320
|
+
const len = size / 2;
|
|
321
|
+
const x0 = cx - Math.cos(angleRad) * len;
|
|
322
|
+
const y0 = cy - Math.sin(angleRad) * len;
|
|
323
|
+
const x1 = cx + Math.cos(angleRad) * len;
|
|
324
|
+
const y1 = cy + Math.sin(angleRad) * len;
|
|
325
|
+
|
|
326
|
+
const gradient = ctx.createLinearGradient(x0, y0, x1, y1);
|
|
327
|
+
const colors = parts.slice(1);
|
|
328
|
+
for (let i = 0; i < colors.length; i++) {
|
|
329
|
+
gradient.addColorStop(i / (colors.length - 1), colors[i]);
|
|
330
|
+
}
|
|
331
|
+
return gradient;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
private drawCenterImage(ctx: CanvasRenderingContext2D, size: number, imgPixelSize: number): void {
|
|
335
|
+
if (!this._loadedImage) return;
|
|
336
|
+
|
|
337
|
+
const x = (size - imgPixelSize) / 2;
|
|
338
|
+
const y = (size - imgPixelSize) / 2;
|
|
339
|
+
const r = Math.min(this.imageRadius, imgPixelSize / 2);
|
|
340
|
+
|
|
341
|
+
const pad = this.imagePadding;
|
|
342
|
+
if (pad > 0 && this.background && this.background !== 'transparent') {
|
|
343
|
+
ctx.fillStyle = this.background;
|
|
344
|
+
const bx = x - pad;
|
|
345
|
+
const by = y - pad;
|
|
346
|
+
const bw = imgPixelSize + pad * 2;
|
|
347
|
+
const bh = imgPixelSize + pad * 2;
|
|
348
|
+
const br = r + pad * 0.5;
|
|
349
|
+
this.drawRoundedRect(ctx, bx, by, bw, bh, br);
|
|
350
|
+
ctx.fill();
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
ctx.save();
|
|
354
|
+
this.clipRoundedRect(ctx, x, y, imgPixelSize, imgPixelSize, r);
|
|
355
|
+
ctx.drawImage(this._loadedImage, x, y, imgPixelSize, imgPixelSize);
|
|
356
|
+
ctx.restore();
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
private drawRoundedModule(
|
|
360
|
+
ctx: CanvasRenderingContext2D,
|
|
361
|
+
x: number,
|
|
362
|
+
y: number,
|
|
363
|
+
w: number,
|
|
364
|
+
h: number,
|
|
365
|
+
r: number
|
|
366
|
+
): void {
|
|
367
|
+
ctx.beginPath();
|
|
368
|
+
ctx.moveTo(x + r, y);
|
|
369
|
+
ctx.lineTo(x + w - r, y);
|
|
370
|
+
ctx.arcTo(x + w, y, x + w, y + r, r);
|
|
371
|
+
ctx.lineTo(x + w, y + h - r);
|
|
372
|
+
ctx.arcTo(x + w, y + h, x + w - r, y + h, r);
|
|
373
|
+
ctx.lineTo(x + r, y + h);
|
|
374
|
+
ctx.arcTo(x, y + h, x, y + h - r, r);
|
|
375
|
+
ctx.lineTo(x, y + r);
|
|
376
|
+
ctx.arcTo(x, y, x + r, y, r);
|
|
377
|
+
ctx.closePath();
|
|
378
|
+
ctx.fill();
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
private drawRoundedRect(
|
|
382
|
+
ctx: CanvasRenderingContext2D,
|
|
383
|
+
x: number,
|
|
384
|
+
y: number,
|
|
385
|
+
w: number,
|
|
386
|
+
h: number,
|
|
387
|
+
r: number
|
|
388
|
+
): void {
|
|
389
|
+
ctx.beginPath();
|
|
390
|
+
ctx.moveTo(x + r, y);
|
|
391
|
+
ctx.lineTo(x + w - r, y);
|
|
392
|
+
ctx.arcTo(x + w, y, x + w, y + r, r);
|
|
393
|
+
ctx.lineTo(x + w, y + h - r);
|
|
394
|
+
ctx.arcTo(x + w, y + h, x + w - r, y + h, r);
|
|
395
|
+
ctx.lineTo(x + r, y + h);
|
|
396
|
+
ctx.arcTo(x, y + h, x, y + h - r, r);
|
|
397
|
+
ctx.lineTo(x, y + r);
|
|
398
|
+
ctx.arcTo(x, y, x + r, y, r);
|
|
399
|
+
ctx.closePath();
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
private clipRoundedRect(
|
|
403
|
+
ctx: CanvasRenderingContext2D,
|
|
404
|
+
x: number,
|
|
405
|
+
y: number,
|
|
406
|
+
w: number,
|
|
407
|
+
h: number,
|
|
408
|
+
r: number
|
|
409
|
+
): void {
|
|
410
|
+
ctx.beginPath();
|
|
411
|
+
ctx.moveTo(x + r, y);
|
|
412
|
+
ctx.lineTo(x + w - r, y);
|
|
413
|
+
ctx.arcTo(x + w, y, x + w, y + r, r);
|
|
414
|
+
ctx.lineTo(x + w, y + h - r);
|
|
415
|
+
ctx.arcTo(x + w, y + h, x + w - r, y + h, r);
|
|
416
|
+
ctx.lineTo(x + r, y + h);
|
|
417
|
+
ctx.arcTo(x, y + h, x, y + h - r, r);
|
|
418
|
+
ctx.lineTo(x, y + r);
|
|
419
|
+
ctx.arcTo(x, y, x + r, y, r);
|
|
420
|
+
ctx.closePath();
|
|
421
|
+
ctx.clip();
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
export default NileQrCode;
|
|
426
|
+
|
|
427
|
+
declare global {
|
|
428
|
+
interface HTMLElementTagNameMap {
|
|
429
|
+
'nile-qr-code': NileQrCode;
|
|
430
|
+
}
|
|
431
|
+
}
|
|
@@ -20,7 +20,7 @@ export const styles = css`
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
.rte-container nile-rte-toolbar {
|
|
23
|
+
.rte-container nile-rte-toolbar {
|
|
24
24
|
display: flex;
|
|
25
25
|
align-items: center;
|
|
26
26
|
gap: 6px;
|
|
@@ -28,12 +28,10 @@ export const styles = css`
|
|
|
28
28
|
border-bottom: 1px solid var(--nile-colors-neutral-400, var(--ng-colors-border-neutral));
|
|
29
29
|
background: var(--nile-colors-white-base, var(--ng-colors-bg-primary));
|
|
30
30
|
border-radius: 8px 8px 0 0;
|
|
31
|
-
|
|
32
31
|
width: 100%;
|
|
33
32
|
box-sizing: border-box;
|
|
34
33
|
}
|
|
35
34
|
|
|
36
|
-
|
|
37
35
|
.rte-container .editor {
|
|
38
36
|
min-height: 160px;
|
|
39
37
|
width: 100%;
|
|
@@ -48,7 +46,23 @@ export const styles = css`
|
|
|
48
46
|
border-radius: var(--nile-radius-radius-xl, var(--ng-radius-md));
|
|
49
47
|
}
|
|
50
48
|
|
|
51
|
-
|
|
49
|
+
nile-rich-text-editor[disabled] .rte-container {
|
|
50
|
+
border-color: var(--nile-colors-neutral-500, var(--ng-colors-border-disabled));
|
|
51
|
+
cursor: not-allowed !important;
|
|
52
|
+
background: var(--nile-colors-dark-200, var(--ng-colors-bg-disabled-subtle));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
nile-rich-text-editor[disabled] .rte-container nile-rte-toolbar {
|
|
56
|
+
border-color: var(--nile-colors-neutral-500, var(--ng-colors-border-disabled));
|
|
57
|
+
cursor: not-allowed !important;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
nile-rich-text-editor[disabled] .rte-container .editor {
|
|
61
|
+
background: var(--nile-colors-dark-200, var(--ng-colors-bg-disabled-subtle));
|
|
62
|
+
pointer-events: none ;
|
|
63
|
+
border-color: var(--nile-colors-neutral-500, var(--ng-colors-border-disabled));
|
|
64
|
+
}
|
|
65
|
+
|
|
52
66
|
nile-rte-preview {
|
|
53
67
|
display: block;
|
|
54
68
|
width: 100%;
|
|
@@ -61,7 +75,11 @@ nile-rte-preview {
|
|
|
61
75
|
word-wrap: break-word;
|
|
62
76
|
}
|
|
63
77
|
|
|
64
|
-
|
|
78
|
+
nile-rich-text-editor[disabled] nile-rte-preview {
|
|
79
|
+
background: var(--nile-colors-dark-200, var(--ng-colors-bg-disabled-subtle));
|
|
80
|
+
cursor: not-allowed ;
|
|
81
|
+
border-color: var(--nile-colors-neutral-500, var(--ng-colors-border-disabled));
|
|
82
|
+
}
|
|
65
83
|
|
|
66
84
|
nile-rte-toolbar-item nile-button::part(base) {
|
|
67
85
|
width: 32px;
|
|
@@ -85,7 +103,6 @@ nile-rte-preview {
|
|
|
85
103
|
background: var(--nile-colors-white-base);
|
|
86
104
|
}
|
|
87
105
|
|
|
88
|
-
|
|
89
106
|
.editor p { margin: 1em 0; }
|
|
90
107
|
.editor h1, .preview h1 {
|
|
91
108
|
font-size: 2em;
|
|
@@ -160,6 +177,8 @@ nile-rte-toolbar-item nile-button[data-active]::part(base):hover {
|
|
|
160
177
|
opacity: 0.7;
|
|
161
178
|
}
|
|
162
179
|
|
|
180
|
+
|
|
181
|
+
|
|
163
182
|
|
|
164
183
|
|
|
165
184
|
|
|
@@ -66,6 +66,7 @@ export class NileRichTextEditor extends LitElement {
|
|
|
66
66
|
|
|
67
67
|
@property({ type: String, attribute: true, reflect: true }) value = '';
|
|
68
68
|
@property({ type: Boolean, attribute: true, reflect: true }) noStyles = false;
|
|
69
|
+
@property({ type: Boolean, attribute: true, reflect: true }) disabled = false;
|
|
69
70
|
@property({ type: Boolean, attribute: 'singlelineeditor', reflect: true }) singleLineEditor =
|
|
70
71
|
false;
|
|
71
72
|
@property({ type: String }) placeholder = '';
|
|
@@ -245,6 +246,7 @@ export class NileRichTextEditor extends LitElement {
|
|
|
245
246
|
this.previewEl.classList.toggle('single-line', this.singleLineEditor);
|
|
246
247
|
}
|
|
247
248
|
}
|
|
249
|
+
|
|
248
250
|
}
|
|
249
251
|
|
|
250
252
|
private ensureEditor() {
|
|
@@ -407,6 +409,7 @@ export class NileRichTextEditor extends LitElement {
|
|
|
407
409
|
const tag = child.tagName.toLowerCase();
|
|
408
410
|
|
|
409
411
|
if (tag === 'nile-rte-select' && child.getAttribute('type') === 'align') {
|
|
412
|
+
(child as any).disabled = this.disabled;
|
|
410
413
|
child.addEventListener('change', (e: any) => {
|
|
411
414
|
this.focusAndRestore();
|
|
412
415
|
const alignment = e.detail as 'left' | 'center' | 'right' | 'justify';
|
|
@@ -440,14 +443,15 @@ export class NileRichTextEditor extends LitElement {
|
|
|
440
443
|
(btn as any).variant = 'tertiary';
|
|
441
444
|
(btn as any).size = 'small';
|
|
442
445
|
}
|
|
446
|
+
(btn as any).disabled = this.disabled;
|
|
443
447
|
|
|
444
448
|
if (iconAttr) {
|
|
445
|
-
btn.innerHTML = `<nile-icon name="${iconAttr}" aria-label="${label}"></nile-icon>`;
|
|
449
|
+
btn.innerHTML = `<nile-icon name="${iconAttr}" color=${this.disabled ? 'var(--nile-colors-neutral-500, var(--ng-colors-fg-disabled-subtle))' : 'var(--nile-colors-dark-900, var(--ng-colors-text-primary-900))'} aria-label="${label}"></nile-icon>`;
|
|
446
450
|
child.innerHTML = '';
|
|
447
451
|
} else if (!authoredHasContent) {
|
|
448
452
|
const defaultIcon = DEFAULT_ICONS[cmd];
|
|
449
453
|
if (defaultIcon) {
|
|
450
|
-
btn.innerHTML = `<nile-icon name="${defaultIcon}" size="20" color
|
|
454
|
+
btn.innerHTML = `<nile-icon name="${defaultIcon}" size="20" color=${this.disabled ? 'var(--nile-colors-neutral-500, var(--ng-colors-fg-disabled-subtle))' : 'var(--nile-colors-dark-900, var(--ng-colors-text-primary-900))'} aria-label="${label}"></nile-icon>`;
|
|
451
455
|
} else {
|
|
452
456
|
btn.textContent = label || cmd;
|
|
453
457
|
}
|
|
@@ -458,10 +462,14 @@ export class NileRichTextEditor extends LitElement {
|
|
|
458
462
|
}
|
|
459
463
|
|
|
460
464
|
if (!btn.isConnected) {
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
+
if (this.disabled) {
|
|
466
|
+
child.appendChild(btn);
|
|
467
|
+
} else {
|
|
468
|
+
const tooltip = document.createElement('nile-lite-tooltip');
|
|
469
|
+
tooltip.setAttribute('content', label);
|
|
470
|
+
tooltip.appendChild(btn);
|
|
471
|
+
child.appendChild(tooltip);
|
|
472
|
+
}
|
|
465
473
|
}
|
|
466
474
|
|
|
467
475
|
btn.setAttribute('aria-label', label);
|
|
@@ -35,6 +35,8 @@ export class NileRteSelect extends LitElement {
|
|
|
35
35
|
|
|
36
36
|
@property({ type: String, attribute: true, reflect: true }) label = '';
|
|
37
37
|
|
|
38
|
+
@property({ type: Boolean, attribute: true, reflect: true }) disabled = false;
|
|
39
|
+
|
|
38
40
|
@state() private selectedValue = '';
|
|
39
41
|
|
|
40
42
|
private mapAlignIcon(v: string) {
|
|
@@ -155,15 +157,16 @@ export class NileRteSelect extends LitElement {
|
|
|
155
157
|
|
|
156
158
|
if (this.type === 'align') {
|
|
157
159
|
const trigger = current?.icon
|
|
158
|
-
? html`<nile-icon name="${current.icon}"></nile-icon>`
|
|
160
|
+
? html`<nile-icon name="${current.icon}" color=${this.disabled ? 'var(--nile-colors-neutral-500, var(--ng-colors-fg-disabled-subtle))' : 'var(--nile-colors-dark-900, var(--ng-colors-text-primary-900))'} size="20"></nile-icon>`
|
|
159
161
|
: this.label || 'Align';
|
|
160
162
|
|
|
161
163
|
return html`
|
|
162
|
-
<nile-dropdown class="rte-align-dd">
|
|
164
|
+
<nile-dropdown ?disabled=${this.disabled} class="rte-align-dd">
|
|
163
165
|
<nile-button
|
|
164
166
|
slot="trigger"
|
|
165
167
|
variant="tertiary"
|
|
166
168
|
class="rte-align-trigger"
|
|
169
|
+
?disabled=${this.disabled}
|
|
167
170
|
>
|
|
168
171
|
${trigger}
|
|
169
172
|
</nile-button>
|
|
@@ -126,7 +126,7 @@ export const styles = css`
|
|
|
126
126
|
.select__display-input {
|
|
127
127
|
position: relative;
|
|
128
128
|
width: 100%;
|
|
129
|
-
font: var(--nile-font-
|
|
129
|
+
font-weight: var(--nile-font-weight-regular, var(--ng-font-weight-regular));
|
|
130
130
|
border: none;
|
|
131
131
|
background: none;
|
|
132
132
|
color: var(--nile-colors-dark-900, var(--ng-colors-text-primary-900));
|
|
@@ -136,6 +136,7 @@ export const styles = css`
|
|
|
136
136
|
margin: var(--nile-spacing-none, var(--ng-spacing-none));
|
|
137
137
|
-webkit-appearance: none;
|
|
138
138
|
font-family: var(--nile-font-family-serif, var(--ng-font-family-body));
|
|
139
|
+
font-size: var(--nile-type-scale-3, var(--ng-font-size-text-md));
|
|
139
140
|
}
|
|
140
141
|
|
|
141
142
|
|
|
@@ -144,6 +145,9 @@ export const styles = css`
|
|
|
144
145
|
color: var(--nile-colors-text-placeholder, var(--ng-colors-text-placeholder));
|
|
145
146
|
font-size: var(--nile-type-scale-3, var(--ng-font-size-text-md));
|
|
146
147
|
}
|
|
148
|
+
.select--disabled.select--placeholder-visible .select__display-input::placeholder {
|
|
149
|
+
color: var(--nile-colors-dark-500,var(--ng-color-graylightmode-500));
|
|
150
|
+
}
|
|
147
151
|
|
|
148
152
|
.select:not(.select--disabled):hover .select__display-input {
|
|
149
153
|
color: var(--nile-colors-dark-900, var(--ng-colors-text-primary-900));
|
|
@@ -229,10 +233,9 @@ export const styles = css`
|
|
|
229
233
|
}
|
|
230
234
|
|
|
231
235
|
.select--standard.select--disabled .select__combobox {
|
|
232
|
-
background-color: var(--nile-colors-
|
|
236
|
+
background-color: var(--nile-colors-dark-200, var(--ng-colors-bg-disabled-subtle));
|
|
233
237
|
border-color: var(--nile-colors-neutral-500,var(--ng-colors-border-disabled) );
|
|
234
238
|
color: var(--nile-colors-dark-500, var(--ng-colors-text-disabled));
|
|
235
|
-
opacity: var(--nile-opacity-50, var(--ng-opacity-100));
|
|
236
239
|
cursor: not-allowed;
|
|
237
240
|
outline: none;
|
|
238
241
|
}
|
|
@@ -283,7 +286,7 @@ export const styles = css`
|
|
|
283
286
|
|
|
284
287
|
.select--medium .select__combobox {
|
|
285
288
|
border-radius: var(--nile-radius-sm, var(--ng-radius-md));
|
|
286
|
-
font-size: var(--nile-type-scale-3, var(--ng-font-size-text-
|
|
289
|
+
font-size: var(--nile-type-scale-3, var(--ng-font-size-text-md));
|
|
287
290
|
|
|
288
291
|
padding: var(--nile-spacing-lg, var(--ng-spacing-md)) var(--nile-spacing-lg, var(--ng-spacing-lg));
|
|
289
292
|
height: var(--nile-height-40px, var(--ng-height-40px));
|
|
@@ -146,6 +146,10 @@ export default css`
|
|
|
146
146
|
.nile-slide-toggle__switch
|
|
147
147
|
input:checked
|
|
148
148
|
+ .nile-slide-toggle__slider {
|
|
149
|
-
background-color: var(--nile-colors-
|
|
149
|
+
background-color: var(--nile-colors-neutral-400, var(--ng-colors-bg-disabled));
|
|
150
|
+
}
|
|
151
|
+
.nile-slide--disabled {
|
|
152
|
+
cursor: not-allowed;
|
|
150
153
|
}
|
|
154
|
+
|
|
151
155
|
`;
|