vira 28.19.6 → 28.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/elements/define-vira-element.d.ts +18 -0
- package/dist/elements/define-vira-element.js +19 -0
- package/dist/elements/form/vira-form-fields.d.ts +100 -0
- package/dist/elements/form/vira-form-fields.js +60 -0
- package/dist/elements/form/vira-form.element.d.ts +35 -0
- package/dist/elements/form/vira-form.element.js +151 -0
- package/dist/elements/index.js +25 -0
- package/dist/elements/pop-up/pop-up-helpers.d.ts +33 -0
- package/dist/elements/pop-up/pop-up-helpers.js +58 -0
- package/{src/elements/pop-up/pop-up-menu-item.ts → dist/elements/pop-up/pop-up-menu-item.d.ts} +3 -4
- package/dist/elements/pop-up/pop-up-menu-item.js +1 -0
- package/dist/elements/pop-up/vira-menu-item.element.d.ts +19 -0
- package/{src/elements/pop-up/vira-menu-item.element.ts → dist/elements/pop-up/vira-menu-item.element.js} +11 -28
- package/dist/elements/pop-up/vira-menu-trigger.element.d.ts +41 -0
- package/dist/elements/pop-up/vira-menu-trigger.element.js +121 -0
- package/dist/elements/pop-up/vira-menu.element.d.ts +38 -0
- package/{src/elements/pop-up/vira-menu.element.ts → dist/elements/pop-up/vira-menu.element.js} +49 -76
- package/dist/elements/pop-up/vira-pop-up-menu.element.d.ts +35 -0
- package/{src/elements/pop-up/vira-pop-up-menu.element.ts → dist/elements/pop-up/vira-pop-up-menu.element.js} +22 -34
- package/dist/elements/pop-up/vira-pop-up-trigger.element.d.ts +105 -0
- package/{src/elements/pop-up/vira-pop-up-trigger.element.ts → dist/elements/pop-up/vira-pop-up-trigger.element.js} +104 -199
- package/dist/elements/shared-text-input-logic.d.ts +63 -0
- package/dist/elements/shared-text-input-logic.js +101 -0
- package/dist/elements/vira-bold-text.element.d.ts +9 -0
- package/{src/elements/vira-bold-text.element.ts → dist/elements/vira-bold-text.element.js} +7 -8
- package/dist/elements/vira-button.element.d.ts +31 -0
- package/{src/elements/vira-button.element.ts → dist/elements/vira-button.element.js} +35 -66
- package/dist/elements/vira-card.element.d.ts +18 -0
- package/{src/elements/vira-card.element.ts → dist/elements/vira-card.element.js} +13 -16
- package/dist/elements/vira-checkbox.element.d.ts +34 -0
- package/{src/elements/vira-checkbox.element.ts → dist/elements/vira-checkbox.element.js} +28 -71
- package/dist/elements/vira-collapsible-wrapper.element.d.ts +16 -0
- package/{src/elements/vira-collapsible-wrapper.element.ts → dist/elements/vira-collapsible-wrapper.element.js} +26 -18
- package/dist/elements/vira-dropdown.element.d.ts +46 -0
- package/{src/elements/vira-dropdown.element.ts → dist/elements/vira-dropdown.element.js} +48 -94
- package/dist/elements/vira-error.element.d.ts +7 -0
- package/{src/elements/vira-error.element.ts → dist/elements/vira-error.element.js} +5 -6
- package/dist/elements/vira-icon.element.d.ts +13 -0
- package/{src/elements/vira-icon.element.ts → dist/elements/vira-icon.element.js} +6 -13
- package/dist/elements/vira-image.element.d.ts +45 -0
- package/{src/elements/vira-image.element.ts → dist/elements/vira-image.element.js} +43 -63
- package/dist/elements/vira-input.element.d.ts +62 -0
- package/{src/elements/vira-input.element.ts → dist/elements/vira-input.element.js} +85 -151
- package/dist/elements/vira-link.element.d.ts +73 -0
- package/{src/elements/vira-link.element.ts → dist/elements/vira-link.element.js} +11 -62
- package/dist/elements/vira-modal.element.d.ts +39 -0
- package/{src/elements/vira-modal.element.ts → dist/elements/vira-modal.element.js} +50 -89
- package/dist/elements/vira-overflow-switch.element.d.ts +21 -0
- package/dist/elements/vira-overflow-switch.element.js +110 -0
- package/dist/elements/vira-progress.element.d.ts +18 -0
- package/{src/elements/vira-progress.element.ts → dist/elements/vira-progress.element.js} +11 -26
- package/dist/elements/vira-select.element.d.ts +48 -0
- package/{src/elements/vira-select.element.ts → dist/elements/vira-select.element.js} +41 -96
- package/dist/icons/icon-color.test-helper.d.ts +6 -0
- package/dist/icons/icon-color.test-helper.js +9 -0
- package/dist/icons/icon-css-vars.d.ts +14 -0
- package/{src/icons/icon-css-vars.ts → dist/icons/icon-css-vars.js} +1 -2
- package/dist/icons/icon-svg.d.ts +27 -0
- package/dist/icons/icon-svg.js +48 -0
- package/dist/icons/icon-svgs/bell-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/bell-24.icon.ts → dist/icons/icon-svgs/bell-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/chat-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/chat-24.icon.ts → dist/icons/icon-svgs/chat-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/check-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/check-24.icon.ts → dist/icons/icon-svgs/check-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/chevron-down-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/chevron-down-24.icon.ts → dist/icons/icon-svgs/chevron-down-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/chevron-up-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/chevron-up-24.icon.ts → dist/icons/icon-svgs/chevron-up-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/close-x-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/close-x-24.icon.ts → dist/icons/icon-svgs/close-x-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/commit-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/commit-24.icon.ts → dist/icons/icon-svgs/commit-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/copy-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/copy-24.icon.ts → dist/icons/icon-svgs/copy-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/document-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/document-24.icon.ts → dist/icons/icon-svgs/document-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/document-search-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/document-search-24.icon.ts → dist/icons/icon-svgs/document-search-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/double-chevron-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/double-chevron-24.icon.ts → dist/icons/icon-svgs/double-chevron-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/element-16.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/element-16.icon.ts → dist/icons/icon-svgs/element-16.icon.js} +4 -5
- package/dist/icons/icon-svgs/element-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/element-24.icon.ts → dist/icons/icon-svgs/element-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/external-link-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/external-link-24.icon.ts → dist/icons/icon-svgs/external-link-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/eye-closed-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/eye-closed-24.icon.ts → dist/icons/icon-svgs/eye-closed-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/eye-open-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/eye-open-24.icon.ts → dist/icons/icon-svgs/eye-open-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/filter-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/filter-24.icon.ts → dist/icons/icon-svgs/filter-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/link-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/link-24.icon.ts → dist/icons/icon-svgs/link-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/loader-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/loader-24.icon.ts → dist/icons/icon-svgs/loader-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/loader-animated-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/loader-animated-24.icon.ts → dist/icons/icon-svgs/loader-animated-24.icon.js} +6 -8
- package/dist/icons/icon-svgs/lock-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/lock-24.icon.ts → dist/icons/icon-svgs/lock-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/options-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/options-24.icon.ts → dist/icons/icon-svgs/options-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/pencil-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/pencil-24.icon.ts → dist/icons/icon-svgs/pencil-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/shield-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/shield-24.icon.ts → dist/icons/icon-svgs/shield-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/sort-ascending-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/sort-ascending-24.icon.ts → dist/icons/icon-svgs/sort-ascending-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/sort-descending-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/sort-descending-24.icon.ts → dist/icons/icon-svgs/sort-descending-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/speaker-loud-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/speaker-loud-24.icon.ts → dist/icons/icon-svgs/speaker-loud-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/speaker-medium-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/speaker-medium-24.icon.ts → dist/icons/icon-svgs/speaker-medium-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/speaker-muted-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/speaker-muted-24.icon.ts → dist/icons/icon-svgs/speaker-muted-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/speaker-quiet-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/speaker-quiet-24.icon.ts → dist/icons/icon-svgs/speaker-quiet-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/star-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/star-24.icon.ts → dist/icons/icon-svgs/star-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/status-failure-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/status-failure-24.icon.ts → dist/icons/icon-svgs/status-failure-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/status-in-progress-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/status-in-progress-24.icon.ts → dist/icons/icon-svgs/status-in-progress-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/status-success-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/status-success-24.icon.ts → dist/icons/icon-svgs/status-success-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/status-unknown-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/status-unknown-24.icon.ts → dist/icons/icon-svgs/status-unknown-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/status-warning-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/status-warning-24.icon.ts → dist/icons/icon-svgs/status-warning-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/upload-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/upload-24.icon.ts → dist/icons/icon-svgs/upload-24.icon.js} +4 -5
- package/dist/icons/icon-svgs/x-24.icon.d.ts +8 -0
- package/{src/icons/icon-svgs/x-24.icon.ts → dist/icons/icon-svgs/x-24.icon.js} +4 -5
- package/dist/icons/index.d.ts +86 -0
- package/{src/icons/index.ts → dist/icons/index.js} +39 -43
- package/dist/index.js +4 -0
- package/dist/styles/border.d.ts +9 -0
- package/{src/styles/border.ts → dist/styles/border.js} +1 -2
- package/dist/styles/disabled.d.ts +6 -0
- package/{src/styles/disabled.ts → dist/styles/disabled.js} +2 -3
- package/dist/styles/durations.d.ts +22 -0
- package/{src/styles/durations.ts → dist/styles/durations.js} +1 -2
- package/dist/styles/focus.d.ts +34 -0
- package/{src/styles/focus.ts → dist/styles/focus.js} +8 -29
- package/dist/styles/font.d.ts +9 -0
- package/{src/styles/font.ts → dist/styles/font.js} +1 -2
- package/dist/styles/form-styles.d.ts +20 -0
- package/{src/styles/form-styles.ts → dist/styles/form-styles.js} +1 -6
- package/{src/styles/index.ts → dist/styles/index.d.ts} +0 -1
- package/dist/styles/index.js +13 -0
- package/dist/styles/native-styles.d.ts +13 -0
- package/{src/styles/native-styles.ts → dist/styles/native-styles.js} +3 -5
- package/dist/styles/scrollbar.d.ts +6 -0
- package/{src/styles/scrollbar.ts → dist/styles/scrollbar.js} +3 -4
- package/dist/styles/shadows.d.ts +20 -0
- package/{src/styles/shadows.ts → dist/styles/shadows.js} +6 -8
- package/dist/styles/user-select.d.ts +6 -0
- package/{src/styles/user-select.ts → dist/styles/user-select.js} +2 -3
- package/dist/styles/vira-color-palette.d.ts +95 -0
- package/{src/styles/vira-color-palette.ts → dist/styles/vira-color-palette.js} +1 -11
- package/dist/styles/vira-color-theme.d.ts +1184 -0
- package/dist/styles/vira-color-theme.js +1138 -0
- package/dist/util/define-table.d.ts +110 -0
- package/dist/util/define-table.js +115 -0
- package/dist/util/dynamic-element.d.ts +63 -0
- package/dist/util/dynamic-element.js +61 -0
- package/dist/util/index.js +3 -0
- package/dist/util/pop-up-manager.d.ts +186 -0
- package/dist/util/pop-up-manager.js +214 -0
- package/package.json +6 -6
- package/src/elements/define-vira-element.ts +0 -29
- package/src/elements/form/vira-form-fields.ts +0 -140
- package/src/elements/form/vira-form.element.ts +0 -204
- package/src/elements/pop-up/pop-up-helpers.ts +0 -85
- package/src/elements/pop-up/vira-menu-trigger.element.ts +0 -158
- package/src/elements/shared-text-input-logic.ts +0 -173
- package/src/elements/vira-overflow-switch.element.ts +0 -137
- package/src/icons/icon-color.test-helper.ts +0 -9
- package/src/icons/icon-svg.ts +0 -71
- package/src/styles/vira-color-theme.ts +0 -1142
- package/src/util/define-table.ts +0 -279
- package/src/util/dynamic-element.ts +0 -129
- package/src/util/pop-up-manager.ts +0 -380
- /package/{src/elements/index.ts → dist/elements/index.d.ts} +0 -0
- /package/{src/index.ts → dist/index.d.ts} +0 -0
- /package/{src/util/index.ts → dist/util/index.d.ts} +0 -0
|
@@ -1,49 +1,28 @@
|
|
|
1
|
-
import {assertWrap} from '@augment-vir/assert';
|
|
2
|
-
import {
|
|
3
|
-
import {extractEventTarget} from '@augment-vir/web';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
} from 'element-vir';
|
|
15
|
-
import {CloseX24Icon} from '../icons/icon-svgs/close-x-24.icon.js';
|
|
16
|
-
import {EyeClosed24Icon, EyeOpen24Icon, type ViraIconSvg} from '../icons/index.js';
|
|
17
|
-
import {createFocusStyles} from '../styles/focus.js';
|
|
18
|
-
import {viraFormCssVars} from '../styles/form-styles.js';
|
|
19
|
-
import {
|
|
20
|
-
noUserSelect,
|
|
21
|
-
viraAnimationDurations,
|
|
22
|
-
viraBorders,
|
|
23
|
-
viraDisabledStyles,
|
|
24
|
-
} from '../styles/index.js';
|
|
25
|
-
import {noNativeFormStyles} from '../styles/native-styles.js';
|
|
26
|
-
import {defineViraElement} from './define-vira-element.js';
|
|
27
|
-
import {
|
|
28
|
-
type SharedTextInputElementInputs,
|
|
29
|
-
filterTextInputValue,
|
|
30
|
-
textInputListener,
|
|
31
|
-
} from './shared-text-input-logic.js';
|
|
32
|
-
import {ViraIcon} from './vira-icon.element.js';
|
|
33
|
-
|
|
1
|
+
import { assertWrap } from '@augment-vir/assert';
|
|
2
|
+
import { randomString } from '@augment-vir/common';
|
|
3
|
+
import { extractEventTarget } from '@augment-vir/web';
|
|
4
|
+
import { attributes, css, defineElementEvent, html, ifDefined, listen, nothing, onResize, renderIf, } from 'element-vir';
|
|
5
|
+
import { CloseX24Icon } from '../icons/icon-svgs/close-x-24.icon.js';
|
|
6
|
+
import { EyeClosed24Icon, EyeOpen24Icon } from '../icons/index.js';
|
|
7
|
+
import { createFocusStyles } from '../styles/focus.js';
|
|
8
|
+
import { viraFormCssVars } from '../styles/form-styles.js';
|
|
9
|
+
import { noUserSelect, viraAnimationDurations, viraBorders, viraDisabledStyles, } from '../styles/index.js';
|
|
10
|
+
import { noNativeFormStyles } from '../styles/native-styles.js';
|
|
11
|
+
import { defineViraElement } from './define-vira-element.js';
|
|
12
|
+
import { filterTextInputValue, textInputListener, } from './shared-text-input-logic.js';
|
|
13
|
+
import { ViraIcon } from './vira-icon.element.js';
|
|
34
14
|
export * from './shared-text-input-logic.js';
|
|
35
|
-
|
|
36
15
|
/**
|
|
37
16
|
* Input types for {@link ViraInput}.
|
|
38
17
|
*
|
|
39
18
|
* @category Internal
|
|
40
19
|
*/
|
|
41
|
-
export
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
20
|
+
export var ViraInputType;
|
|
21
|
+
(function (ViraInputType) {
|
|
22
|
+
ViraInputType["Default"] = "text";
|
|
23
|
+
ViraInputType["Password"] = "password";
|
|
24
|
+
ViraInputType["Email"] = "email";
|
|
25
|
+
})(ViraInputType || (ViraInputType = {}));
|
|
47
26
|
/**
|
|
48
27
|
* A single line input element with all listeners properly attached. Multiple types are allowed with
|
|
49
28
|
* {@link ViraInputType}.
|
|
@@ -52,39 +31,21 @@ export enum ViraInputType {
|
|
|
52
31
|
* @category Elements
|
|
53
32
|
* @see https://electrovir.github.io/vira/book/elements/vira-input
|
|
54
33
|
*/
|
|
55
|
-
export const ViraInput = defineViraElement
|
|
56
|
-
Readonly<
|
|
57
|
-
PartialWithUndefined<{
|
|
58
|
-
icon: Pick<ViraIconSvg, 'svgTemplate'>;
|
|
59
|
-
/** A suffix that, if provided, is shown following the input field. */
|
|
60
|
-
suffix: string;
|
|
61
|
-
/** A label that is shown above the input, if provided. */
|
|
62
|
-
label: string;
|
|
63
|
-
/** If true, applies error styling. */
|
|
64
|
-
hasError: boolean;
|
|
65
|
-
showClearButton: boolean;
|
|
66
|
-
type: ViraInputType;
|
|
67
|
-
}> &
|
|
68
|
-
SharedTextInputElementInputs
|
|
69
|
-
>
|
|
70
|
-
>()({
|
|
34
|
+
export const ViraInput = defineViraElement()({
|
|
71
35
|
tagName: 'vira-input',
|
|
72
36
|
cssVars: {
|
|
73
37
|
'vira-input-action-button-color': '#aaaaaa',
|
|
74
|
-
|
|
75
38
|
'vira-input-clear-button-hover-color': '#ff0000',
|
|
76
39
|
'vira-input-clear-button-active-color': '#b30000',
|
|
77
|
-
|
|
78
40
|
// eslint-disable-next-line sonarjs/no-hardcoded-passwords
|
|
79
41
|
'vira-input-show-password-button-hover-color': '#0a89ff',
|
|
80
42
|
// eslint-disable-next-line sonarjs/no-hardcoded-passwords
|
|
81
43
|
'vira-input-show-password-button-active-color': '#0261ba',
|
|
82
|
-
|
|
83
44
|
'vira-input-padding-horizontal': '10px',
|
|
84
45
|
'vira-input-padding-vertical': '6px',
|
|
85
46
|
},
|
|
86
|
-
styles: ({hostClasses, cssVars}) => {
|
|
87
|
-
return css`
|
|
47
|
+
styles: ({ hostClasses, cssVars }) => {
|
|
48
|
+
return css `
|
|
88
49
|
:host {
|
|
89
50
|
position: relative;
|
|
90
51
|
display: inline-flex;
|
|
@@ -217,19 +178,19 @@ export const ViraInput = defineViraElement<
|
|
|
217
178
|
|
|
218
179
|
&:focus:focus-visible:not([disabled]) ~ .focus-border {
|
|
219
180
|
${createFocusStyles({
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
181
|
+
elementBorderSize: 0,
|
|
182
|
+
noNesting: true,
|
|
183
|
+
})}
|
|
223
184
|
}
|
|
224
185
|
}
|
|
225
186
|
|
|
226
187
|
::selection {
|
|
227
188
|
background: ${viraFormCssVars['vira-form-text-selection-color']
|
|
228
|
-
|
|
189
|
+
.value}; /* WebKit/Blink Browsers */
|
|
229
190
|
}
|
|
230
191
|
::-moz-selection {
|
|
231
192
|
background: ${viraFormCssVars['vira-form-text-selection-color']
|
|
232
|
-
|
|
193
|
+
.value}; /* Gecko Browsers */
|
|
233
194
|
}
|
|
234
195
|
|
|
235
196
|
input:placeholder-shown {
|
|
@@ -307,13 +268,13 @@ export const ViraInput = defineViraElement<
|
|
|
307
268
|
* Fires whenever a user input created a new value. Does not fire if all input letters are
|
|
308
269
|
* filtered out due to input restrictions.
|
|
309
270
|
*/
|
|
310
|
-
valueChange: defineElementEvent
|
|
271
|
+
valueChange: defineElementEvent(),
|
|
311
272
|
/**
|
|
312
273
|
* Fires when inputs are blocked. Useful for showing warnings or error messages to inform
|
|
313
274
|
* the user why their input did not propagate if it was blocked. This does not fire for text
|
|
314
275
|
* that was blocked out of programmatic "value" property assignments.
|
|
315
276
|
*/
|
|
316
|
-
inputBlocked: defineElementEvent
|
|
277
|
+
inputBlocked: defineElementEvent(),
|
|
317
278
|
},
|
|
318
279
|
state() {
|
|
319
280
|
return {
|
|
@@ -327,69 +288,56 @@ export const ViraInput = defineViraElement<
|
|
|
327
288
|
};
|
|
328
289
|
},
|
|
329
290
|
hostClasses: {
|
|
330
|
-
'vira-input-disabled': ({inputs}) => !!inputs.disabled,
|
|
331
|
-
'vira-input-fit-text': ({inputs}) => !!inputs.fitText,
|
|
332
|
-
'vira-input-clear-button-shown': ({inputs}) => !!inputs.showClearButton,
|
|
333
|
-
'vira-input-error': ({inputs}) => !!inputs.hasError,
|
|
291
|
+
'vira-input-disabled': ({ inputs }) => !!inputs.disabled,
|
|
292
|
+
'vira-input-fit-text': ({ inputs }) => !!inputs.fitText,
|
|
293
|
+
'vira-input-clear-button-shown': ({ inputs }) => !!inputs.showClearButton,
|
|
294
|
+
'vira-input-error': ({ inputs }) => !!inputs.hasError,
|
|
334
295
|
},
|
|
335
|
-
render: ({inputs, dispatch, state, updateState, events, host}) => {
|
|
336
|
-
const {filtered: filteredValue} = filterTextInputValue({
|
|
296
|
+
render: ({ inputs, dispatch, state, updateState, events, host }) => {
|
|
297
|
+
const { filtered: filteredValue } = filterTextInputValue({
|
|
337
298
|
value: inputs.value,
|
|
338
299
|
allowed: inputs.allowedInputs,
|
|
339
300
|
blocked: inputs.blockedInputs,
|
|
340
301
|
});
|
|
341
|
-
|
|
342
302
|
const iconTemplate = inputs.icon
|
|
343
|
-
? html`
|
|
344
|
-
<${ViraIcon.assign({icon: inputs.icon})} class="left-side-icon"></${ViraIcon}>
|
|
303
|
+
? html `
|
|
304
|
+
<${ViraIcon.assign({ icon: inputs.icon })} class="left-side-icon"></${ViraIcon}>
|
|
345
305
|
`
|
|
346
306
|
: nothing;
|
|
347
|
-
|
|
348
307
|
const forcedInputWidthStyles = inputs.fitText
|
|
349
|
-
? css`
|
|
308
|
+
? css `
|
|
350
309
|
width: ${state.forcedInputWidth}px;
|
|
351
310
|
`
|
|
352
311
|
: nothing;
|
|
353
|
-
|
|
354
312
|
const mousedownListener = listen('mousedown', (event) => {
|
|
355
313
|
const eventTarget = extractEventTarget(event, HTMLElement, {
|
|
356
314
|
useOriginalTarget: true,
|
|
357
315
|
});
|
|
358
|
-
const inputElement = assertWrap.instanceOf(
|
|
359
|
-
host.shadowRoot.querySelector('input'),
|
|
360
|
-
HTMLInputElement,
|
|
361
|
-
);
|
|
362
|
-
|
|
316
|
+
const inputElement = assertWrap.instanceOf(host.shadowRoot.querySelector('input'), HTMLInputElement);
|
|
363
317
|
if (eventTarget !== inputElement) {
|
|
364
318
|
event.preventDefault();
|
|
365
319
|
inputElement.focus();
|
|
366
320
|
}
|
|
367
321
|
});
|
|
368
|
-
|
|
369
|
-
const shouldBlockBrowserHelps =
|
|
370
|
-
inputs.disableBrowserHelps ||
|
|
322
|
+
const shouldBlockBrowserHelps = inputs.disableBrowserHelps ||
|
|
371
323
|
/**
|
|
372
324
|
* Some browsers leaks passwords with their browser helps (like Chrome with
|
|
373
325
|
* spellchecking).
|
|
374
326
|
*/
|
|
375
327
|
inputs.type === ViraInputType.Password;
|
|
376
|
-
|
|
377
|
-
const inputTemplate = html`
|
|
328
|
+
const inputTemplate = html `
|
|
378
329
|
<span class="input-wrapper" ${inputs.label ? nothing : mousedownListener}>
|
|
379
330
|
${iconTemplate}
|
|
380
|
-
${renderIf(
|
|
381
|
-
!!inputs.fitText,
|
|
382
|
-
html`
|
|
331
|
+
${renderIf(!!inputs.fitText, html `
|
|
383
332
|
<span
|
|
384
333
|
class="size-span"
|
|
385
|
-
${onResize(({contentRect}) => {
|
|
386
|
-
|
|
387
|
-
|
|
334
|
+
${onResize(({ contentRect }) => {
|
|
335
|
+
updateState({ forcedInputWidth: contentRect.width });
|
|
336
|
+
})}
|
|
388
337
|
>
|
|
389
338
|
<pre>${filteredValue || inputs.placeholder || nothing}</pre>
|
|
390
339
|
</span>
|
|
391
|
-
|
|
392
|
-
)}
|
|
340
|
+
`)}
|
|
393
341
|
|
|
394
342
|
<input
|
|
395
343
|
id=${ifDefined(inputs.label ? state.randomId : undefined)}
|
|
@@ -404,70 +352,61 @@ export const ViraInput = defineViraElement<
|
|
|
404
352
|
?disabled=${inputs.disabled}
|
|
405
353
|
.value=${filteredValue}
|
|
406
354
|
${listen('input', (event) => {
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
355
|
+
textInputListener({
|
|
356
|
+
inputs,
|
|
357
|
+
previousValue: filteredValue,
|
|
358
|
+
event,
|
|
359
|
+
inputBlockedCallback(blockedInput) {
|
|
360
|
+
dispatch(new events.inputBlocked(blockedInput));
|
|
361
|
+
},
|
|
362
|
+
newValueCallback(newValue) {
|
|
363
|
+
dispatch(new events.valueChange(newValue));
|
|
364
|
+
},
|
|
365
|
+
});
|
|
366
|
+
})}
|
|
419
367
|
placeholder=${ifDefined(inputs.placeholder || undefined)}
|
|
420
368
|
${attributes(inputs.attributePassthrough)}
|
|
421
369
|
/>
|
|
422
370
|
|
|
423
|
-
${renderIf(
|
|
424
|
-
!!(inputs.showClearButton && inputs.value),
|
|
425
|
-
html`
|
|
371
|
+
${renderIf(!!(inputs.showClearButton && inputs.value), html `
|
|
426
372
|
<button
|
|
427
373
|
class="clear-x-button"
|
|
428
374
|
title="clear"
|
|
429
375
|
${listen('mousedown', (event) => {
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
376
|
+
event.stopImmediatePropagation();
|
|
377
|
+
event.preventDefault();
|
|
378
|
+
})}
|
|
433
379
|
${listen('click', () => {
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
380
|
+
if (inputs.disabled) {
|
|
381
|
+
return;
|
|
382
|
+
}
|
|
383
|
+
dispatch(new events.valueChange(''));
|
|
384
|
+
})}
|
|
439
385
|
>
|
|
440
|
-
<${ViraIcon.assign({icon: CloseX24Icon})}></${ViraIcon}>
|
|
386
|
+
<${ViraIcon.assign({ icon: CloseX24Icon })}></${ViraIcon}>
|
|
441
387
|
</button>
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
${renderIf(
|
|
445
|
-
inputs.type === ViraInputType.Password,
|
|
446
|
-
html`
|
|
388
|
+
`)}
|
|
389
|
+
${renderIf(inputs.type === ViraInputType.Password, html `
|
|
447
390
|
<button
|
|
448
391
|
class="show-password-button"
|
|
449
392
|
title="show password"
|
|
450
393
|
${listen('mousedown', (event) => {
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
394
|
+
/** Prevent focus of the input. */
|
|
395
|
+
event.stopImmediatePropagation();
|
|
396
|
+
event.preventDefault();
|
|
397
|
+
})}
|
|
455
398
|
${listen('click', () => {
|
|
456
|
-
|
|
457
|
-
|
|
399
|
+
updateState({ showPassword: !state.showPassword });
|
|
400
|
+
})}
|
|
458
401
|
>
|
|
459
402
|
<${ViraIcon.assign({
|
|
460
|
-
|
|
461
|
-
|
|
403
|
+
icon: state.showPassword ? EyeOpen24Icon : EyeClosed24Icon,
|
|
404
|
+
})}></${ViraIcon}>
|
|
462
405
|
</button>
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
${renderIf(
|
|
466
|
-
!!inputs.suffix,
|
|
467
|
-
html`
|
|
406
|
+
`)}
|
|
407
|
+
${renderIf(!!inputs.suffix, html `
|
|
468
408
|
<div class="suffix">${inputs.suffix}</div>
|
|
469
|
-
|
|
470
|
-
)}
|
|
409
|
+
`)}
|
|
471
410
|
|
|
472
411
|
<!--
|
|
473
412
|
These separate style elements are necessary so that we can select them as
|
|
@@ -479,27 +418,22 @@ export const ViraInput = defineViraElement<
|
|
|
479
418
|
<div class="border-style wrapper-border"></div>
|
|
480
419
|
</span>
|
|
481
420
|
`;
|
|
482
|
-
|
|
483
421
|
if (inputs.label) {
|
|
484
|
-
return html`
|
|
422
|
+
return html `
|
|
485
423
|
<label for=${state.randomId} ${mousedownListener}>
|
|
486
424
|
<span class="input-label">${inputs.label}</span>
|
|
487
425
|
${inputTemplate}
|
|
488
426
|
</label>
|
|
489
427
|
`;
|
|
490
|
-
}
|
|
428
|
+
}
|
|
429
|
+
else {
|
|
491
430
|
return inputTemplate;
|
|
492
431
|
}
|
|
493
432
|
},
|
|
494
433
|
});
|
|
495
|
-
|
|
496
|
-
function calculateEffectiveInputType(
|
|
497
|
-
type: ViraInputType | undefined,
|
|
498
|
-
showPassword: boolean,
|
|
499
|
-
): ViraInputType {
|
|
434
|
+
function calculateEffectiveInputType(type, showPassword) {
|
|
500
435
|
if (type === ViraInputType.Password && showPassword) {
|
|
501
436
|
return ViraInputType.Default;
|
|
502
437
|
}
|
|
503
|
-
|
|
504
438
|
return type || ViraInputType.Default;
|
|
505
439
|
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { type PartialWithUndefined } from '@augment-vir/common';
|
|
2
|
+
import { type AttributeValues, type CSSResult } from 'element-vir';
|
|
3
|
+
import { type SpaRoute, type SpaRouter } from 'spa-router-vir';
|
|
4
|
+
/**
|
|
5
|
+
* The route properties required for using {@link ViraLink} with a route.
|
|
6
|
+
*
|
|
7
|
+
* @category Internal
|
|
8
|
+
*/
|
|
9
|
+
export type ViraLinkRoute = Readonly<{
|
|
10
|
+
route: SpaRoute<any, any, any>;
|
|
11
|
+
router: Pick<SpaRouter<any, any, any>, 'createRouteUrl' | 'setRouteOnDirectNavigation'>;
|
|
12
|
+
scrollToTop?: boolean;
|
|
13
|
+
}>;
|
|
14
|
+
/**
|
|
15
|
+
* A hyperlink wrapper element that can be configured to emit route change events rather than just
|
|
16
|
+
* being a raw link.
|
|
17
|
+
*
|
|
18
|
+
* @category Link
|
|
19
|
+
* @category Elements
|
|
20
|
+
* @see https://electrovir.github.io/vira/book/elements/vira-link
|
|
21
|
+
*/
|
|
22
|
+
export declare const ViraLink: import("element-vir").DeclarativeElementDefinition<"vira-link", (((Required<Pick<{
|
|
23
|
+
/**
|
|
24
|
+
* A full raw URL link that will navigate the current window away or open a new tab. If this
|
|
25
|
+
* property is provided for the inputs, don't provide a route property.
|
|
26
|
+
*/
|
|
27
|
+
link: {
|
|
28
|
+
url: string;
|
|
29
|
+
newTab: boolean;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* A route that'll change that current page without navigating the window. If this property
|
|
33
|
+
* is provided for the inputs, don't provide a link property.
|
|
34
|
+
*/
|
|
35
|
+
route: ViraLinkRoute;
|
|
36
|
+
}, "link">> & Partial<Record<"route", never>>) | (Required<Pick<{
|
|
37
|
+
/**
|
|
38
|
+
* A full raw URL link that will navigate the current window away or open a new tab. If this
|
|
39
|
+
* property is provided for the inputs, don't provide a route property.
|
|
40
|
+
*/
|
|
41
|
+
link: {
|
|
42
|
+
url: string;
|
|
43
|
+
newTab: boolean;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* A route that'll change that current page without navigating the window. If this property
|
|
47
|
+
* is provided for the inputs, don't provide a link property.
|
|
48
|
+
*/
|
|
49
|
+
route: ViraLinkRoute;
|
|
50
|
+
}, "route">> & Partial<Record<"link", never>>)) & Omit<{
|
|
51
|
+
/**
|
|
52
|
+
* A full raw URL link that will navigate the current window away or open a new tab. If this
|
|
53
|
+
* property is provided for the inputs, don't provide a route property.
|
|
54
|
+
*/
|
|
55
|
+
link: {
|
|
56
|
+
url: string;
|
|
57
|
+
newTab: boolean;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* A route that'll change that current page without navigating the window. If this property
|
|
61
|
+
* is provided for the inputs, don't provide a link property.
|
|
62
|
+
*/
|
|
63
|
+
route: ViraLinkRoute;
|
|
64
|
+
}, "link" | "route">) & PartialWithUndefined<{
|
|
65
|
+
/** Styles that will be applied directly to the inner elements. */
|
|
66
|
+
stylePassthrough: Readonly<PartialWithUndefined<{
|
|
67
|
+
a: CSSResult;
|
|
68
|
+
}>>;
|
|
69
|
+
/** Attributes that will be applied directly to the inner elements. */
|
|
70
|
+
attributePassthrough: Readonly<PartialWithUndefined<{
|
|
71
|
+
a: AttributeValues;
|
|
72
|
+
}>>;
|
|
73
|
+
}>, {}, {}, "vira-link-", "vira-link-hover-color", readonly [], readonly []>;
|
|
@@ -1,28 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
attributes,
|
|
4
|
-
css,
|
|
5
|
-
html,
|
|
6
|
-
ifDefined,
|
|
7
|
-
listen,
|
|
8
|
-
type AttributeValues,
|
|
9
|
-
type CSSResult,
|
|
10
|
-
} from 'element-vir';
|
|
11
|
-
import {type SpaRoute, type SpaRouter} from 'spa-router-vir';
|
|
12
|
-
import {type RequireExactlyOne} from 'type-fest';
|
|
13
|
-
import {defineViraElement} from './define-vira-element.js';
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* The route properties required for using {@link ViraLink} with a route.
|
|
17
|
-
*
|
|
18
|
-
* @category Internal
|
|
19
|
-
*/
|
|
20
|
-
export type ViraLinkRoute = Readonly<{
|
|
21
|
-
route: SpaRoute<any, any, any>;
|
|
22
|
-
router: Pick<SpaRouter<any, any, any>, 'createRouteUrl' | 'setRouteOnDirectNavigation'>;
|
|
23
|
-
scrollToTop?: boolean;
|
|
24
|
-
}>;
|
|
25
|
-
|
|
1
|
+
import { attributes, css, html, ifDefined, listen, } from 'element-vir';
|
|
2
|
+
import { defineViraElement } from './define-vira-element.js';
|
|
26
3
|
/**
|
|
27
4
|
* A hyperlink wrapper element that can be configured to emit route change events rather than just
|
|
28
5
|
* being a raw link.
|
|
@@ -31,34 +8,12 @@ export type ViraLinkRoute = Readonly<{
|
|
|
31
8
|
* @category Elements
|
|
32
9
|
* @see https://electrovir.github.io/vira/book/elements/vira-link
|
|
33
10
|
*/
|
|
34
|
-
export const ViraLink = defineViraElement
|
|
35
|
-
RequireExactlyOne<{
|
|
36
|
-
/**
|
|
37
|
-
* A full raw URL link that will navigate the current window away or open a new tab. If this
|
|
38
|
-
* property is provided for the inputs, don't provide a route property.
|
|
39
|
-
*/
|
|
40
|
-
link: {
|
|
41
|
-
url: string;
|
|
42
|
-
newTab: boolean;
|
|
43
|
-
};
|
|
44
|
-
/**
|
|
45
|
-
* A route that'll change that current page without navigating the window. If this property
|
|
46
|
-
* is provided for the inputs, don't provide a link property.
|
|
47
|
-
*/
|
|
48
|
-
route: ViraLinkRoute;
|
|
49
|
-
}> &
|
|
50
|
-
PartialWithUndefined<{
|
|
51
|
-
/** Styles that will be applied directly to the inner elements. */
|
|
52
|
-
stylePassthrough: Readonly<PartialWithUndefined<{a: CSSResult}>>;
|
|
53
|
-
/** Attributes that will be applied directly to the inner elements. */
|
|
54
|
-
attributePassthrough: Readonly<PartialWithUndefined<{a: AttributeValues}>>;
|
|
55
|
-
}>
|
|
56
|
-
>()({
|
|
11
|
+
export const ViraLink = defineViraElement()({
|
|
57
12
|
tagName: 'vira-link',
|
|
58
13
|
cssVars: {
|
|
59
14
|
'vira-link-hover-color': 'currentColor',
|
|
60
15
|
},
|
|
61
|
-
styles: ({cssVars}) => css`
|
|
16
|
+
styles: ({ cssVars }) => css `
|
|
62
17
|
:host {
|
|
63
18
|
display: inline;
|
|
64
19
|
text-decoration: underline;
|
|
@@ -81,17 +36,12 @@ export const ViraLink = defineViraElement<
|
|
|
81
36
|
color: ${cssVars['vira-link-hover-color'].value};
|
|
82
37
|
}
|
|
83
38
|
`,
|
|
84
|
-
render({inputs}) {
|
|
85
|
-
function clickCallback(event
|
|
39
|
+
render({ inputs }) {
|
|
40
|
+
function clickCallback(event) {
|
|
86
41
|
if (!inputs.route) {
|
|
87
42
|
return;
|
|
88
43
|
}
|
|
89
|
-
|
|
90
|
-
const routed = inputs.route.router.setRouteOnDirectNavigation(
|
|
91
|
-
inputs.route.route,
|
|
92
|
-
event,
|
|
93
|
-
);
|
|
94
|
-
|
|
44
|
+
const routed = inputs.route.router.setRouteOnDirectNavigation(inputs.route.route, event);
|
|
95
45
|
if (routed && inputs.route.scrollToTop) {
|
|
96
46
|
window.scrollTo({
|
|
97
47
|
left: 0,
|
|
@@ -100,10 +50,9 @@ export const ViraLink = defineViraElement<
|
|
|
100
50
|
});
|
|
101
51
|
}
|
|
102
52
|
}
|
|
103
|
-
|
|
104
53
|
if (inputs.link?.newTab) {
|
|
105
54
|
/** Noopener and noreferrer are needed for security reasons, do not remove! */
|
|
106
|
-
return html`
|
|
55
|
+
return html `
|
|
107
56
|
<a
|
|
108
57
|
href=${inputs.link.url}
|
|
109
58
|
target="_blank"
|
|
@@ -114,13 +63,13 @@ export const ViraLink = defineViraElement<
|
|
|
114
63
|
<slot></slot>
|
|
115
64
|
</a>
|
|
116
65
|
`;
|
|
117
|
-
}
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
118
68
|
const linkUrl = inputs.link
|
|
119
69
|
? inputs.link.url
|
|
120
70
|
: inputs.route.router.createRouteUrl(inputs.route.route);
|
|
121
|
-
|
|
122
71
|
/** Noopener and noreferrer are needed for security reasons, do not remove! */
|
|
123
|
-
return html`
|
|
72
|
+
return html `
|
|
124
73
|
<a
|
|
125
74
|
href=${linkUrl}
|
|
126
75
|
rel="noopener noreferrer"
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type PartialWithUndefined } from '@augment-vir/common';
|
|
2
|
+
/**
|
|
3
|
+
* A modal element that uses the built-in `dialog` element.
|
|
4
|
+
*
|
|
5
|
+
* @category Elements
|
|
6
|
+
* @see https://electrovir.github.io/vira/book/elements/vira-modal
|
|
7
|
+
*/
|
|
8
|
+
export declare const ViraModal: import("element-vir").DeclarativeElementDefinition<"vira-modal", Readonly<{
|
|
9
|
+
open: boolean;
|
|
10
|
+
} & PartialWithUndefined<{
|
|
11
|
+
/** If this isn't set, make sure to use the modal title slot to fill it in. */
|
|
12
|
+
modalTitle: string;
|
|
13
|
+
/**
|
|
14
|
+
* If `true`, the following conditions trigger the modal to close:
|
|
15
|
+
*
|
|
16
|
+
* - The user clicks the "x" close button
|
|
17
|
+
* - The `open` input is set to `false`
|
|
18
|
+
*
|
|
19
|
+
* If set to `false` (the default), the following conditions trigger the modal to close:
|
|
20
|
+
*
|
|
21
|
+
* - The user clicks outside of the modal
|
|
22
|
+
* - The user presses the "Escape" key
|
|
23
|
+
* - The user clicks the "x" close button
|
|
24
|
+
* - The `open` input is set to `false`
|
|
25
|
+
*
|
|
26
|
+
* @default false
|
|
27
|
+
*/
|
|
28
|
+
blockLightDismissal: boolean;
|
|
29
|
+
modalSubtitle: string;
|
|
30
|
+
isMobileSize: boolean;
|
|
31
|
+
}>>, {
|
|
32
|
+
dialogElement: HTMLDialogElement | undefined;
|
|
33
|
+
contentElement: HTMLDivElement | undefined;
|
|
34
|
+
previousOpenValue: undefined | boolean;
|
|
35
|
+
/** Remove listeners. */
|
|
36
|
+
cleanup: undefined | (() => void);
|
|
37
|
+
}, {
|
|
38
|
+
modalClose: import("element-vir").DefineEvent<void>;
|
|
39
|
+
}, "vira-modal-phone-size", "vira-modal-backdrop-color" | "vira-modal-backdrop-filter" | "vira-modal-subtitle-color" | "vira-modal-close-button-hover-radius" | "vira-modal-close-button-hover-background-color", readonly ["modalTitle"], readonly []>;
|