@aquera/nile-elements 1.5.5 → 1.5.7
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/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.js +569 -263
- package/dist/nile-auto-complete/nile-auto-complete.cjs.js +1 -1
- package/dist/nile-auto-complete/nile-auto-complete.cjs.js.map +1 -1
- 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 +15 -2
- package/dist/nile-auto-complete/nile-auto-complete.esm.js +1 -1
- 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 +96 -36
- 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 +66 -2
- package/dist/nile-calendar/nile-calendar.esm.js +22 -15
- 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 +38 -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 +10 -6
- package/dist/nile-code-editor/nile-code-editor.esm.js +2 -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-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 +28 -0
- package/dist/nile-filter-chip/nile-filter-chip.esm.js +2 -2
- package/dist/nile-icon/icons/svg/close.cjs.js +1 -1
- package/dist/nile-icon/icons/svg/close.cjs.js.map +1 -1
- package/dist/nile-icon/icons/svg/close.esm.js +1 -1
- 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-input/nile-input.cjs.js +1 -1
- package/dist/nile-input/nile-input.cjs.js.map +1 -1
- 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 +15 -5
- package/dist/nile-input/nile-input.esm.js +2 -0
- 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 -2
- package/dist/nile-link/nile-link.esm.js +2 -2
- 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.cjs.js +1 -1
- package/dist/nile-radio/nile-radio.cjs.js.map +1 -1
- 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 +3 -3
- package/dist/nile-radio/nile-radio.esm.js +2 -2
- package/dist/nile-radio-group/nile-radio-group.cjs.js +1 -1
- package/dist/nile-radio-group/nile-radio-group.cjs.js.map +1 -1
- package/dist/nile-radio-group/nile-radio-group.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 +31 -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.cjs.js +1 -1
- package/dist/nile-select/nile-select.cjs.js.map +1 -1
- 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 +27 -8
- package/dist/nile-select/nile-select.esm.js +6 -6
- package/dist/nile-slide-toggle/nile-slide-toggle.cjs.js +1 -1
- package/dist/nile-slide-toggle/nile-slide-toggle.cjs.js.map +1 -1
- 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-slide-toggle/nile-slide-toggle.esm.js +4 -3
- 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 +18 -6
- package/dist/nile-virtual-select/nile-virtual-select.cjs.js +3 -3
- package/dist/nile-virtual-select/nile-virtual-select.cjs.js.map +1 -1
- 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 +17 -5
- package/dist/nile-virtual-select/nile-virtual-select.esm.js +5 -5
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/nile-auto-complete/nile-auto-complete.css.js +13 -0
- package/dist/src/nile-auto-complete/nile-auto-complete.css.js.map +1 -1
- package/dist/src/nile-auto-complete/nile-auto-complete.js +1 -1
- package/dist/src/nile-auto-complete/nile-auto-complete.js.map +1 -1
- package/dist/src/nile-button/nile-button.css.js +96 -36
- 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 +64 -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 +30 -11
- 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 +36 -21
- package/dist/src/nile-chip/nile-chip.css.js.map +1 -1
- package/dist/src/nile-code-editor/nile-code-editor.css.js +10 -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 +8 -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/nile-detail.test.js +6 -6
- package/dist/src/nile-detail/nile-detail.test.js.map +1 -1
- 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 +28 -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-icon/icons/svg/close.d.ts +1 -1
- package/dist/src/nile-icon/icons/svg/close.js +1 -1
- package/dist/src/nile-icon/icons/svg/close.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-group/nile-inline-sidebar-group.test.js +1 -1
- package/dist/src/nile-inline-sidebar-group/nile-inline-sidebar-group.test.js.map +1 -1
- package/dist/src/nile-inline-sidebar-item/nile-inline-sidebar-item.test.js +5 -5
- package/dist/src/nile-inline-sidebar-item/nile-inline-sidebar-item.test.js.map +1 -1
- package/dist/src/nile-input/nile-input.css.js +15 -5
- package/dist/src/nile-input/nile-input.css.js.map +1 -1
- package/dist/src/nile-input/nile-input.js +2 -0
- package/dist/src/nile-input/nile-input.js.map +1 -1
- package/dist/src/nile-link/nile-link.css.js +3 -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-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 +3 -3
- package/dist/src/nile-radio/nile-radio.css.js.map +1 -1
- package/dist/src/nile-radio/nile-radio.js +15 -1
- package/dist/src/nile-radio/nile-radio.js.map +1 -1
- package/dist/src/nile-radio-group/nile-radio-group.js +8 -0
- package/dist/src/nile-radio-group/nile-radio-group.js.map +1 -1
- package/dist/src/nile-rich-text-editor/nile-rich-text-editor.css.js +31 -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 +23 -7
- 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 +27 -8
- package/dist/src/nile-select/nile-select.css.js.map +1 -1
- package/dist/src/nile-select/nile-select.js +2 -2
- package/dist/src/nile-select/nile-select.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-slide-toggle/nile-slide-toggle.js +1 -0
- package/dist/src/nile-slide-toggle/nile-slide-toggle.js.map +1 -1
- package/dist/src/nile-textarea/nile-textarea.css.js +18 -6
- package/dist/src/nile-textarea/nile-textarea.css.js.map +1 -1
- package/dist/src/nile-virtual-select/nile-virtual-select.css.js +17 -5
- package/dist/src/nile-virtual-select/nile-virtual-select.css.js.map +1 -1
- package/dist/src/nile-virtual-select/nile-virtual-select.js +2 -2
- package/dist/src/nile-virtual-select/nile-virtual-select.js.map +1 -1
- package/dist/src/version.js +2 -2
- package/dist/src/version.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -2
- package/src/index.ts +2 -1
- package/src/nile-auto-complete/nile-auto-complete.css.ts +13 -0
- package/src/nile-auto-complete/nile-auto-complete.ts +1 -1
- package/src/nile-button/nile-button.css.ts +96 -36
- package/src/nile-button/nile-button.ts +6 -5
- package/src/nile-calendar/nile-calendar.css.ts +64 -0
- package/src/nile-calendar/nile-calendar.ts +23 -11
- package/src/nile-checkbox/nile-checkbox.css.ts +4 -5
- package/src/nile-chip/nile-chip.css.ts +36 -21
- package/src/nile-code-editor/nile-code-editor.css.ts +10 -6
- package/src/nile-code-editor/nile-code-editor.ts +8 -1
- package/src/nile-date-picker/nile-date-picker.ts +22 -2
- package/src/nile-detail/nile-detail.test.ts +6 -6
- 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 +28 -0
- package/src/nile-filter-chip/nile-filter-chip.ts +2 -0
- package/src/nile-icon/icons/svg/close.ts +1 -1
- 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-group/nile-inline-sidebar-group.test.ts +1 -1
- package/src/nile-inline-sidebar-item/nile-inline-sidebar-item.test.ts +5 -5
- package/src/nile-input/nile-input.css.ts +15 -5
- package/src/nile-input/nile-input.ts +2 -0
- package/src/nile-link/nile-link.css.ts +3 -2
- package/src/nile-link/nile-link.ts +1 -0
- 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 +3 -3
- package/src/nile-radio/nile-radio.ts +17 -3
- package/src/nile-radio-group/nile-radio-group.ts +6 -0
- package/src/nile-rich-text-editor/nile-rich-text-editor.css.ts +31 -6
- package/src/nile-rich-text-editor/nile-rich-text-editor.ts +20 -7
- package/src/nile-rich-text-editor/nile-rte-select.ts +5 -2
- package/src/nile-select/nile-select.css.ts +27 -8
- package/src/nile-select/nile-select.ts +2 -2
- package/src/nile-slide-toggle/nile-slide-toggle.css.ts +5 -1
- package/src/nile-slide-toggle/nile-slide-toggle.ts +1 -0
- package/src/nile-textarea/nile-textarea.css.ts +18 -6
- package/src/nile-virtual-select/nile-virtual-select.css.ts +17 -5
- package/src/nile-virtual-select/nile-virtual-select.ts +2 -2
- package/vscode-html-custom-data.json +108 -6
- package/web-test-runner.config.mjs +7 -4
|
@@ -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
|
+
}
|
|
@@ -115,17 +115,17 @@ export const styles = css`
|
|
|
115
115
|
|
|
116
116
|
/* Disabled */
|
|
117
117
|
.radio--disabled {
|
|
118
|
-
|
|
118
|
+
|
|
119
119
|
cursor: not-allowed;
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
.radio--disabled .radio__checked-icon {
|
|
123
|
-
background-color:var(--nile-colors-
|
|
123
|
+
background-color:var(--nile-colors-dark-100, var(--ng-colors-fg-disabled-subtle)); // for v2
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
.radio--disabled .radio__control {
|
|
127
127
|
background-color:var(--nile-colors-neutral-100, var(--ng-colors-bg-disabled-subtle));
|
|
128
|
-
border: 1px solid var(--nile-colors-
|
|
128
|
+
border: 1px solid var(--nile-colors-dark-100, var(--ng-colors-border-disabled));
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
/* When the control isn't checked, hide the circle for Windows High Contrast mode a11y */
|
|
@@ -110,13 +110,27 @@ export class NileRadio extends NileElement {
|
|
|
110
110
|
@watch('checked')
|
|
111
111
|
handleCheckedChange() {
|
|
112
112
|
this.setAttribute('aria-checked', this.checked ? 'true' : 'false');
|
|
113
|
-
|
|
113
|
+
if (this.disabled) {
|
|
114
|
+
this.setAttribute('tabindex', '-1');
|
|
115
|
+
} else {
|
|
116
|
+
this.setAttribute('tabindex', this.checked ? '0' : '-1');
|
|
117
|
+
}
|
|
118
|
+
|
|
114
119
|
}
|
|
115
120
|
|
|
116
121
|
@watch('disabled', { waitUntilFirstUpdate: true })
|
|
117
|
-
|
|
118
|
-
|
|
122
|
+
handleDisabledChange() {
|
|
123
|
+
this.setAttribute('aria-disabled', this.disabled ? 'true' : 'false');
|
|
124
|
+
if (this.disabled) {
|
|
125
|
+
this.setAttribute('tabindex', '-1');
|
|
126
|
+
|
|
127
|
+
if (this.matches(':focus')) {
|
|
128
|
+
(this as HTMLElement).blur();
|
|
129
|
+
}
|
|
130
|
+
} else {
|
|
131
|
+
this.setAttribute('tabindex', this.checked ? '0' : '-1');
|
|
119
132
|
}
|
|
133
|
+
}
|
|
120
134
|
|
|
121
135
|
render() {
|
|
122
136
|
return html`
|
|
@@ -143,6 +143,7 @@ export class NileRadioGroup extends NileElement {
|
|
|
143
143
|
}
|
|
144
144
|
|
|
145
145
|
private handleKeyDown(event: KeyboardEvent) {
|
|
146
|
+
if (this.disabled) return;
|
|
146
147
|
if (!['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight', ' '].includes(event.key)) {
|
|
147
148
|
return;
|
|
148
149
|
}
|
|
@@ -188,6 +189,7 @@ export class NileRadioGroup extends NileElement {
|
|
|
188
189
|
}
|
|
189
190
|
|
|
190
191
|
private handleLabelClick() {
|
|
192
|
+
if (this.disabled) return;
|
|
191
193
|
const radios = this.getAllRadios();
|
|
192
194
|
const checked = radios.find(radio => radio.checked);
|
|
193
195
|
const radioToFocus = checked || radios[0];
|
|
@@ -207,6 +209,10 @@ export class NileRadioGroup extends NileElement {
|
|
|
207
209
|
radio.islabelborder=true;
|
|
208
210
|
}
|
|
209
211
|
});
|
|
212
|
+
if (this.disabled) {
|
|
213
|
+
radios.forEach(r => (r.tabIndex = -1));
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
210
216
|
const nile_radio_check='nile-radio-button';
|
|
211
217
|
this.hasButtonGroup = radios.some(radio => radio.tagName.toLowerCase() === nile_radio_check);
|
|
212
218
|
|
|
@@ -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,26 @@ 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
|
+
user-select: none;
|
|
64
|
+
-webkit-user-select: none;
|
|
65
|
+
border-color: var(--nile-colors-neutral-500, var(--ng-colors-border-disabled));
|
|
66
|
+
color: var(--nile-colors-dark-500, var(--ng-colors-text-disabled));
|
|
67
|
+
}
|
|
68
|
+
|
|
52
69
|
nile-rte-preview {
|
|
53
70
|
display: block;
|
|
54
71
|
width: 100%;
|
|
@@ -61,7 +78,14 @@ nile-rte-preview {
|
|
|
61
78
|
word-wrap: break-word;
|
|
62
79
|
}
|
|
63
80
|
|
|
64
|
-
|
|
81
|
+
nile-rich-text-editor[disabled] nile-rte-preview {
|
|
82
|
+
background: var(--nile-colors-dark-200, var(--ng-colors-bg-disabled-subtle));
|
|
83
|
+
cursor: not-allowed ;
|
|
84
|
+
border-color: var(--nile-colors-neutral-500, var(--ng-colors-border-disabled));
|
|
85
|
+
user-select: none;
|
|
86
|
+
-webkit-user-select: none;
|
|
87
|
+
color: var(--nile-colors-dark-500, var(--ng-colors-text-disabled));
|
|
88
|
+
}
|
|
65
89
|
|
|
66
90
|
nile-rte-toolbar-item nile-button::part(base) {
|
|
67
91
|
width: 32px;
|
|
@@ -85,7 +109,6 @@ nile-rte-preview {
|
|
|
85
109
|
background: var(--nile-colors-white-base);
|
|
86
110
|
}
|
|
87
111
|
|
|
88
|
-
|
|
89
112
|
.editor p { margin: 1em 0; }
|
|
90
113
|
.editor h1, .preview h1 {
|
|
91
114
|
font-size: 2em;
|
|
@@ -160,6 +183,8 @@ nile-rte-toolbar-item nile-button[data-active]::part(base):hover {
|
|
|
160
183
|
opacity: 0.7;
|
|
161
184
|
}
|
|
162
185
|
|
|
186
|
+
|
|
187
|
+
|
|
163
188
|
|
|
164
189
|
|
|
165
190
|
|
|
@@ -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,11 @@ export class NileRichTextEditor extends LitElement {
|
|
|
245
246
|
this.previewEl.classList.toggle('single-line', this.singleLineEditor);
|
|
246
247
|
}
|
|
247
248
|
}
|
|
249
|
+
if (changed.has('disabled') && this.editorEl) {
|
|
250
|
+
this.editorEl.setAttribute('contenteditable', this.disabled ? 'false' : 'true');
|
|
251
|
+
this.editorEl.tabIndex = this.disabled ? -1 : 0;
|
|
252
|
+
}
|
|
253
|
+
|
|
248
254
|
}
|
|
249
255
|
|
|
250
256
|
private ensureEditor() {
|
|
@@ -252,7 +258,8 @@ export class NileRichTextEditor extends LitElement {
|
|
|
252
258
|
if (!this.editorEl) {
|
|
253
259
|
const editor = document.createElement('article');
|
|
254
260
|
editor.className = 'editor';
|
|
255
|
-
editor.setAttribute('contenteditable', 'true');
|
|
261
|
+
editor.setAttribute('contenteditable', this.disabled ? 'false' : 'true');
|
|
262
|
+
editor.tabIndex = this.disabled ? -1 : 0;
|
|
256
263
|
this.editorEl = editor;
|
|
257
264
|
}
|
|
258
265
|
if (this.placeholder) {
|
|
@@ -407,6 +414,7 @@ export class NileRichTextEditor extends LitElement {
|
|
|
407
414
|
const tag = child.tagName.toLowerCase();
|
|
408
415
|
|
|
409
416
|
if (tag === 'nile-rte-select' && child.getAttribute('type') === 'align') {
|
|
417
|
+
(child as any).disabled = this.disabled;
|
|
410
418
|
child.addEventListener('change', (e: any) => {
|
|
411
419
|
this.focusAndRestore();
|
|
412
420
|
const alignment = e.detail as 'left' | 'center' | 'right' | 'justify';
|
|
@@ -440,14 +448,15 @@ export class NileRichTextEditor extends LitElement {
|
|
|
440
448
|
(btn as any).variant = 'tertiary';
|
|
441
449
|
(btn as any).size = 'small';
|
|
442
450
|
}
|
|
451
|
+
(btn as any).disabled = this.disabled;
|
|
443
452
|
|
|
444
453
|
if (iconAttr) {
|
|
445
|
-
btn.innerHTML = `<nile-icon name="${iconAttr}"
|
|
454
|
+
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))'}" ></nile-icon>`;
|
|
446
455
|
child.innerHTML = '';
|
|
447
456
|
} else if (!authoredHasContent) {
|
|
448
457
|
const defaultIcon = DEFAULT_ICONS[cmd];
|
|
449
458
|
if (defaultIcon) {
|
|
450
|
-
btn.innerHTML = `<nile-icon name="${defaultIcon}" size="20" color="
|
|
459
|
+
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))'}" ></nile-icon>`;
|
|
451
460
|
} else {
|
|
452
461
|
btn.textContent = label || cmd;
|
|
453
462
|
}
|
|
@@ -458,10 +467,14 @@ export class NileRichTextEditor extends LitElement {
|
|
|
458
467
|
}
|
|
459
468
|
|
|
460
469
|
if (!btn.isConnected) {
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
470
|
+
if (this.disabled) {
|
|
471
|
+
child.appendChild(btn);
|
|
472
|
+
} else {
|
|
473
|
+
const tooltip = document.createElement('nile-lite-tooltip');
|
|
474
|
+
tooltip.setAttribute('content', label);
|
|
475
|
+
tooltip.appendChild(btn);
|
|
476
|
+
child.appendChild(tooltip);
|
|
477
|
+
}
|
|
465
478
|
}
|
|
466
479
|
|
|
467
480
|
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>
|