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,94 +1,39 @@
|
|
|
1
|
-
import {assert} from '@augment-vir/assert';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
isInputLikeElement,
|
|
11
|
-
NavSelectEvent,
|
|
12
|
-
PopUpManager,
|
|
13
|
-
type ShowPopUpResult,
|
|
14
|
-
} from '../../util/pop-up-manager.js';
|
|
15
|
-
import {defineViraElement} from '../define-vira-element.js';
|
|
16
|
-
import {triggerPopUpState} from './pop-up-helpers.js';
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Offsets applied to any menu opened by {@link ViraPopUpTrigger}.
|
|
20
|
-
*
|
|
21
|
-
* @category Internal
|
|
22
|
-
*/
|
|
23
|
-
export type PopUpOffset = PartialWithUndefined<{
|
|
24
|
-
vertical: number;
|
|
25
|
-
right: number;
|
|
26
|
-
left: number;
|
|
27
|
-
}>;
|
|
28
|
-
|
|
1
|
+
import { assert } from '@augment-vir/assert';
|
|
2
|
+
import { walkActiveElement } from '@augment-vir/web';
|
|
3
|
+
import { NavController } from 'device-navigation';
|
|
4
|
+
import { classMap, css, defineElementEvent, html, listen, renderIf } from 'element-vir';
|
|
5
|
+
import { createFocusStyles } from '../../styles/focus.js';
|
|
6
|
+
import { noNativeFormStyles, noUserSelect, viraDisabledStyles } from '../../styles/index.js';
|
|
7
|
+
import { HidePopUpEvent, isInputLikeElement, NavSelectEvent, PopUpManager, } from '../../util/pop-up-manager.js';
|
|
8
|
+
import { defineViraElement } from '../define-vira-element.js';
|
|
9
|
+
import { triggerPopUpState } from './pop-up-helpers.js';
|
|
29
10
|
/**
|
|
30
11
|
* Anchor options for pop-ups.
|
|
31
12
|
*
|
|
32
13
|
* @category Internal
|
|
33
14
|
*/
|
|
34
|
-
export
|
|
15
|
+
export var HorizontalAnchor;
|
|
16
|
+
(function (HorizontalAnchor) {
|
|
35
17
|
/**
|
|
36
18
|
* The left side of the pop-up will be anchored to the left side of the trigger, allowing the
|
|
37
19
|
* pop-up to grow on the right side of the trigger.
|
|
38
20
|
*/
|
|
39
|
-
Left =
|
|
21
|
+
HorizontalAnchor["Left"] = "left";
|
|
40
22
|
/**
|
|
41
23
|
* The Right side of the pop-up will be anchored to the right side of the trigger, allowing the
|
|
42
24
|
* pop-up to grow on the left side of the trigger.
|
|
43
25
|
*/
|
|
44
|
-
Right =
|
|
26
|
+
HorizontalAnchor["Right"] = "right";
|
|
45
27
|
/** Restrict the pop-up on both sides. */
|
|
46
|
-
Both =
|
|
28
|
+
HorizontalAnchor["Both"] = "both";
|
|
47
29
|
/**
|
|
48
30
|
* Automatically choose left or right based on available space, defaulting to anchoring on the
|
|
49
31
|
* left side.
|
|
50
32
|
*
|
|
51
33
|
* This is the default anchor for {@link ViraPopUpTrigger}.
|
|
52
34
|
*/
|
|
53
|
-
Auto =
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Configs for {@link ViraPopUpTrigger} pop-up positioning and sizing.
|
|
58
|
-
*
|
|
59
|
-
* @category Internal
|
|
60
|
-
*/
|
|
61
|
-
export type PopUpTriggerPosition = {
|
|
62
|
-
/**
|
|
63
|
-
* - `HorizontalAnchor.Left`: pop-up is anchored to the left side of the trigger and the pop-up
|
|
64
|
-
* can grow to the right.
|
|
65
|
-
* - `HorizontalAnchor.Right`: pop-up is anchored to the right side of the trigger and the pop-up
|
|
66
|
-
* can grow to the left.
|
|
67
|
-
* - `HorizontalAnchor.Both`: pop-up is anchored on both sides of the trigger and cannot grow
|
|
68
|
-
* beyond it.
|
|
69
|
-
* - `HorizontalAnchor.Auto`: automatically choose left or right anchor based on available space,
|
|
70
|
-
* defaulting to left anchor. (This is the default experience.)
|
|
71
|
-
*
|
|
72
|
-
* Note that when `HorizontalAnchor.Both` is _not_ used, this anchor will cancel out any
|
|
73
|
-
* `popUpOffset` for the direction _opposite_ of the chosen anchor.
|
|
74
|
-
*/
|
|
75
|
-
horizontalAnchor: HorizontalAnchor;
|
|
76
|
-
/**
|
|
77
|
-
* When `true`, the pop-up will not have its maximum width constrained to fit within the
|
|
78
|
-
* overflow container. The positioning logic (left/right) will still be applied.
|
|
79
|
-
*
|
|
80
|
-
* @default false
|
|
81
|
-
*/
|
|
82
|
-
ignoreMaxWidth: boolean;
|
|
83
|
-
/**
|
|
84
|
-
* When `true`, the pop-up will not have its maximum height constrained to fit within the
|
|
85
|
-
* overflow container. The positioning logic (up/down) will still be applied.
|
|
86
|
-
*
|
|
87
|
-
* @default false
|
|
88
|
-
*/
|
|
89
|
-
ignoreMaxHeight: boolean;
|
|
90
|
-
};
|
|
91
|
-
|
|
35
|
+
HorizontalAnchor["Auto"] = "auto";
|
|
36
|
+
})(HorizontalAnchor || (HorizontalAnchor = {}));
|
|
92
37
|
/**
|
|
93
38
|
* An element with slots for a pop-up trigger and pop-up contents.
|
|
94
39
|
*
|
|
@@ -96,25 +41,13 @@ export type PopUpTriggerPosition = {
|
|
|
96
41
|
* @category Elements
|
|
97
42
|
* @see https://electrovir.github.io/vira/book/elements/vira-pop-up-trigger
|
|
98
43
|
*/
|
|
99
|
-
export const ViraPopUpTrigger = defineViraElement
|
|
100
|
-
PartialWithUndefined<
|
|
101
|
-
PopUpTriggerPosition & {
|
|
102
|
-
isDisabled: boolean;
|
|
103
|
-
/** For debugging purposes only. Very bad for actual production code use. */
|
|
104
|
-
z_debug_forceOpenState: boolean;
|
|
105
|
-
/** Set to `true` to keep the pop-up open if it is interacted with. */
|
|
106
|
-
keepOpenAfterInteraction: boolean;
|
|
107
|
-
/** All values in px. */
|
|
108
|
-
popUpOffset: PopUpOffset;
|
|
109
|
-
}
|
|
110
|
-
>
|
|
111
|
-
>()({
|
|
44
|
+
export const ViraPopUpTrigger = defineViraElement()({
|
|
112
45
|
tagName: 'vira-pop-up-trigger',
|
|
113
|
-
state({host}) {
|
|
46
|
+
state({ host }) {
|
|
114
47
|
return {
|
|
115
48
|
/** `undefined` means the pop up is not currently showing. */
|
|
116
|
-
showPopUpResult: undefined
|
|
117
|
-
popUpManager: new PopUpManager(new NavController(host, {activateOnMouseUp: true})),
|
|
49
|
+
showPopUpResult: undefined,
|
|
50
|
+
popUpManager: new PopUpManager(new NavController(host, { activateOnMouseUp: true })),
|
|
118
51
|
};
|
|
119
52
|
},
|
|
120
53
|
slotNames: [
|
|
@@ -122,9 +55,9 @@ export const ViraPopUpTrigger = defineViraElement<
|
|
|
122
55
|
'popUp',
|
|
123
56
|
],
|
|
124
57
|
hostClasses: {
|
|
125
|
-
'vira-pop-up-trigger-disabled': ({inputs}) => !!inputs.isDisabled,
|
|
58
|
+
'vira-pop-up-trigger-disabled': ({ inputs }) => !!inputs.isDisabled,
|
|
126
59
|
},
|
|
127
|
-
styles: ({hostClasses}) => css`
|
|
60
|
+
styles: ({ hostClasses }) => css `
|
|
128
61
|
:host {
|
|
129
62
|
display: inline-flex;
|
|
130
63
|
box-sizing: border-box;
|
|
@@ -142,8 +75,8 @@ export const ViraPopUpTrigger = defineViraElement<
|
|
|
142
75
|
box-sizing: border-box;
|
|
143
76
|
|
|
144
77
|
${createFocusStyles({
|
|
145
|
-
|
|
146
|
-
|
|
78
|
+
elementBorderSize: 1,
|
|
79
|
+
})}
|
|
147
80
|
}
|
|
148
81
|
|
|
149
82
|
.dropdown-trigger {
|
|
@@ -186,35 +119,26 @@ export const ViraPopUpTrigger = defineViraElement<
|
|
|
186
119
|
}
|
|
187
120
|
`,
|
|
188
121
|
events: {
|
|
189
|
-
navSelect: defineElementEvent
|
|
122
|
+
navSelect: defineElementEvent(),
|
|
190
123
|
/**
|
|
191
124
|
* - `undefined` indicates that the pop-up just closed.
|
|
192
125
|
* - {@link ShowPopUpResult} indicates that the pop-up just opened.
|
|
193
126
|
*/
|
|
194
|
-
openChange: defineElementEvent
|
|
195
|
-
init: defineElementEvent
|
|
196
|
-
navController: NavController;
|
|
197
|
-
popUpManager: PopUpManager;
|
|
198
|
-
}>(),
|
|
127
|
+
openChange: defineElementEvent(),
|
|
128
|
+
init: defineElementEvent(),
|
|
199
129
|
},
|
|
200
|
-
cleanup({state, updateState}) {
|
|
201
|
-
updateState({showPopUpResult: undefined});
|
|
130
|
+
cleanup({ state, updateState }) {
|
|
131
|
+
updateState({ showPopUpResult: undefined });
|
|
202
132
|
state.popUpManager.destroy();
|
|
203
133
|
},
|
|
204
|
-
init({state, updateState, host, inputs, dispatch, events}) {
|
|
134
|
+
init({ state, updateState, host, inputs, dispatch, events }) {
|
|
205
135
|
/** Refocus the trigger and set the result to `undefined` when the pop up closes. */
|
|
206
136
|
state.popUpManager.listen(HidePopUpEvent, () => {
|
|
207
|
-
updateState({showPopUpResult: undefined});
|
|
137
|
+
updateState({ showPopUpResult: undefined });
|
|
208
138
|
dispatch(new events.openChange(undefined));
|
|
209
139
|
if (!inputs.isDisabled) {
|
|
210
140
|
const dropdownWrapper = host.shadowRoot.querySelector('.dropdown-wrapper');
|
|
211
|
-
|
|
212
|
-
assert.instanceOf(
|
|
213
|
-
dropdownWrapper,
|
|
214
|
-
HTMLButtonElement,
|
|
215
|
-
'failed to find dropdown wrapper child',
|
|
216
|
-
);
|
|
217
|
-
|
|
141
|
+
assert.instanceOf(dropdownWrapper, HTMLButtonElement, 'failed to find dropdown wrapper child');
|
|
218
142
|
dropdownWrapper.focus();
|
|
219
143
|
}
|
|
220
144
|
});
|
|
@@ -233,19 +157,13 @@ export const ViraPopUpTrigger = defineViraElement<
|
|
|
233
157
|
}
|
|
234
158
|
dispatch(new events.navSelect(event.detail));
|
|
235
159
|
});
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
popUpManager: state.popUpManager,
|
|
241
|
-
}),
|
|
242
|
-
);
|
|
160
|
+
dispatch(new events.init({
|
|
161
|
+
navController: state.popUpManager.navController,
|
|
162
|
+
popUpManager: state.popUpManager,
|
|
163
|
+
}));
|
|
243
164
|
},
|
|
244
|
-
render({dispatch, events, state, inputs, updateState, host, slotNames}) {
|
|
245
|
-
function triggerPopUp(
|
|
246
|
-
{emitEvent, open}: {emitEvent: boolean; open: boolean},
|
|
247
|
-
event: Event | undefined,
|
|
248
|
-
) {
|
|
165
|
+
render({ dispatch, events, state, inputs, updateState, host, slotNames }) {
|
|
166
|
+
function triggerPopUp({ emitEvent, open }, event) {
|
|
249
167
|
if (state.showPopUpResult && inputs.keepOpenAfterInteraction && event) {
|
|
250
168
|
const dropdownTrigger = host.shadowRoot.querySelector('.dropdown-trigger');
|
|
251
169
|
if (dropdownTrigger && !event.composedPath().includes(dropdownTrigger)) {
|
|
@@ -259,7 +177,7 @@ export const ViraPopUpTrigger = defineViraElement<
|
|
|
259
177
|
triggerPopUpState({
|
|
260
178
|
open,
|
|
261
179
|
callback(showPopUpResult) {
|
|
262
|
-
updateState({showPopUpResult});
|
|
180
|
+
updateState({ showPopUpResult });
|
|
263
181
|
if (emitEvent) {
|
|
264
182
|
dispatch(new events.openChange(showPopUpResult));
|
|
265
183
|
}
|
|
@@ -268,60 +186,53 @@ export const ViraPopUpTrigger = defineViraElement<
|
|
|
268
186
|
popUpManager: state.popUpManager,
|
|
269
187
|
});
|
|
270
188
|
}
|
|
271
|
-
|
|
272
189
|
if (inputs.isDisabled) {
|
|
273
|
-
triggerPopUp({open: false, emitEvent: false}, undefined);
|
|
274
|
-
}
|
|
190
|
+
triggerPopUp({ open: false, emitEvent: false }, undefined);
|
|
191
|
+
}
|
|
192
|
+
else if (inputs.z_debug_forceOpenState != undefined) {
|
|
275
193
|
if (!inputs.z_debug_forceOpenState && state.showPopUpResult) {
|
|
276
|
-
triggerPopUp({emitEvent: false, open: false}, undefined);
|
|
277
|
-
}
|
|
278
|
-
|
|
194
|
+
triggerPopUp({ emitEvent: false, open: false }, undefined);
|
|
195
|
+
}
|
|
196
|
+
else if (inputs.z_debug_forceOpenState && !state.showPopUpResult) {
|
|
197
|
+
triggerPopUp({ emitEvent: false, open: true }, undefined);
|
|
279
198
|
}
|
|
280
199
|
}
|
|
281
|
-
|
|
282
200
|
/**
|
|
283
201
|
* Resolve the effective horizontal anchor. For Auto, use the popRight calculation from
|
|
284
202
|
* showPopUpResult to determine whether to anchor left or right.
|
|
285
203
|
*/
|
|
286
|
-
const effectiveHorizontalAnchor
|
|
287
|
-
inputs.horizontalAnchor === HorizontalAnchor.Auto ||
|
|
204
|
+
const effectiveHorizontalAnchor = inputs.horizontalAnchor === HorizontalAnchor.Auto ||
|
|
288
205
|
inputs.horizontalAnchor === undefined
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
? inputs.ignoreMaxWidth
|
|
297
|
-
? css`
|
|
206
|
+
? state.showPopUpResult?.popRight
|
|
207
|
+
? HorizontalAnchor.Left
|
|
208
|
+
: HorizontalAnchor.Right
|
|
209
|
+
: inputs.horizontalAnchor;
|
|
210
|
+
const leftCss = effectiveHorizontalAnchor === HorizontalAnchor.Right && state.showPopUpResult
|
|
211
|
+
? inputs.ignoreMaxWidth
|
|
212
|
+
? css `
|
|
298
213
|
left: unset;
|
|
299
214
|
`
|
|
300
|
-
|
|
215
|
+
: css `
|
|
301
216
|
left: -${state.showPopUpResult.positions.diff.left}px;
|
|
302
217
|
`
|
|
303
|
-
|
|
218
|
+
: css `
|
|
304
219
|
left: ${inputs.popUpOffset?.left || 0}px;
|
|
305
220
|
`;
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
? inputs.ignoreMaxWidth
|
|
310
|
-
? css`
|
|
221
|
+
const rightCss = state.showPopUpResult && effectiveHorizontalAnchor === HorizontalAnchor.Left
|
|
222
|
+
? inputs.ignoreMaxWidth
|
|
223
|
+
? css `
|
|
311
224
|
right: unset;
|
|
312
225
|
`
|
|
313
|
-
|
|
226
|
+
: css `
|
|
314
227
|
right: -${state.showPopUpResult.positions.diff.right}px;
|
|
315
228
|
`
|
|
316
|
-
|
|
229
|
+
: css `
|
|
317
230
|
right: ${inputs.popUpOffset?.right || 0}px;
|
|
318
231
|
`;
|
|
319
|
-
|
|
320
|
-
const horizontalPositionStyle = css`
|
|
232
|
+
const horizontalPositionStyle = css `
|
|
321
233
|
${leftCss}
|
|
322
234
|
${rightCss}
|
|
323
235
|
`;
|
|
324
|
-
|
|
325
236
|
/**
|
|
326
237
|
* These styles do _not_ account for window resizing while the menu is open. I decided this
|
|
327
238
|
* was not a major enough problem to tackle. If it becomes major enough in the future,
|
|
@@ -331,75 +242,72 @@ export const ViraPopUpTrigger = defineViraElement<
|
|
|
331
242
|
const positionerStyles = state.showPopUpResult
|
|
332
243
|
? state.showPopUpResult.popDown
|
|
333
244
|
? /** Dropdown going down position. */
|
|
334
|
-
|
|
335
|
-
|
|
245
|
+
inputs.ignoreMaxHeight
|
|
246
|
+
? css `
|
|
336
247
|
bottom: unset;
|
|
337
248
|
top: calc(100% + ${inputs.popUpOffset?.vertical || 0}px);
|
|
338
249
|
${horizontalPositionStyle}
|
|
339
250
|
`
|
|
340
|
-
|
|
251
|
+
: css `
|
|
341
252
|
bottom: -${state.showPopUpResult.positions.diff.bottom}px;
|
|
342
253
|
top: calc(100% + ${inputs.popUpOffset?.vertical || 0}px);
|
|
343
254
|
${horizontalPositionStyle}
|
|
344
255
|
`
|
|
345
256
|
: /** Dropdown going up position. */
|
|
346
|
-
|
|
347
|
-
|
|
257
|
+
inputs.ignoreMaxHeight
|
|
258
|
+
? css `
|
|
348
259
|
top: unset;
|
|
349
260
|
bottom: calc(100% + ${inputs.popUpOffset?.vertical || 0}px);
|
|
350
261
|
${horizontalPositionStyle}
|
|
351
262
|
`
|
|
352
|
-
|
|
263
|
+
: css `
|
|
353
264
|
top: -${state.showPopUpResult.positions.diff.top}px;
|
|
354
265
|
bottom: calc(100% + ${inputs.popUpOffset?.vertical || 0}px);
|
|
355
266
|
${horizontalPositionStyle}
|
|
356
267
|
`
|
|
357
268
|
: undefined;
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
triggerPopUp({emitEvent: true, open: !state.showPopUpResult}, event);
|
|
269
|
+
function respondToClick(event) {
|
|
270
|
+
triggerPopUp({ emitEvent: true, open: !state.showPopUpResult }, event);
|
|
361
271
|
}
|
|
362
|
-
|
|
363
|
-
return html`
|
|
272
|
+
return html `
|
|
364
273
|
<button
|
|
365
274
|
?disabled=${!!inputs.isDisabled}
|
|
366
275
|
class="dropdown-wrapper ${classMap({
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
276
|
+
open: !!state.showPopUpResult,
|
|
277
|
+
'open-upwards': !state.showPopUpResult?.popDown,
|
|
278
|
+
})}"
|
|
370
279
|
role="listbox"
|
|
371
280
|
aria-expanded=${!!state.showPopUpResult}
|
|
372
281
|
${listen('keydown', (event) => {
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
282
|
+
if (!state.showPopUpResult && event.code.startsWith('Arrow')) {
|
|
283
|
+
triggerPopUp({ emitEvent: true, open: true }, event);
|
|
284
|
+
}
|
|
285
|
+
})}
|
|
377
286
|
${listen('click', (event) => {
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
return true;
|
|
386
|
-
} else {
|
|
387
|
-
return false;
|
|
388
|
-
}
|
|
389
|
-
});
|
|
390
|
-
if (isTextActiveElement) {
|
|
391
|
-
return;
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
respondToClick(event);
|
|
287
|
+
/** Detail is 0 if it was a keyboard key (like Enter) that triggered this click. */
|
|
288
|
+
if (event.detail === 0) {
|
|
289
|
+
let isTextActiveElement = false;
|
|
290
|
+
walkActiveElement(({ element }) => {
|
|
291
|
+
if (isInputLikeElement(element)) {
|
|
292
|
+
isTextActiveElement = true;
|
|
293
|
+
return true;
|
|
395
294
|
}
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
/** Ignore any clicks that aren't the main button. */
|
|
399
|
-
if (event.button === 0) {
|
|
400
|
-
respondToClick(event);
|
|
295
|
+
else {
|
|
296
|
+
return false;
|
|
401
297
|
}
|
|
402
|
-
})
|
|
298
|
+
});
|
|
299
|
+
if (isTextActiveElement) {
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
respondToClick(event);
|
|
303
|
+
}
|
|
304
|
+
})}
|
|
305
|
+
${listen('mousedown', (event) => {
|
|
306
|
+
/** Ignore any clicks that aren't the main button. */
|
|
307
|
+
if (event.button === 0) {
|
|
308
|
+
respondToClick(event);
|
|
309
|
+
}
|
|
310
|
+
})}
|
|
403
311
|
>
|
|
404
312
|
<div class="dropdown-trigger">
|
|
405
313
|
<slot name=${slotNames.trigger}></slot>
|
|
@@ -407,16 +315,13 @@ export const ViraPopUpTrigger = defineViraElement<
|
|
|
407
315
|
|
|
408
316
|
<div
|
|
409
317
|
class="pop-up-positioner ${classMap({
|
|
410
|
-
|
|
411
|
-
|
|
318
|
+
'right-aligned': effectiveHorizontalAnchor === HorizontalAnchor.Right,
|
|
319
|
+
})}"
|
|
412
320
|
style=${positionerStyles}
|
|
413
321
|
>
|
|
414
|
-
${renderIf(
|
|
415
|
-
!!state.showPopUpResult,
|
|
416
|
-
html`
|
|
322
|
+
${renderIf(!!state.showPopUpResult, html `
|
|
417
323
|
<slot name=${slotNames.popUp}></slot>
|
|
418
|
-
|
|
419
|
-
)}
|
|
324
|
+
`)}
|
|
420
325
|
</div>
|
|
421
326
|
</button>
|
|
422
327
|
`;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { type PartialWithUndefined } from '@augment-vir/common';
|
|
2
|
+
import { type AttributeValues } from 'element-vir';
|
|
3
|
+
/**
|
|
4
|
+
* Inputs shared between the multiple input elements.
|
|
5
|
+
*
|
|
6
|
+
* @category Internal
|
|
7
|
+
*/
|
|
8
|
+
export type SharedTextInputElementInputs = {
|
|
9
|
+
value: string;
|
|
10
|
+
} & PartialWithUndefined<{
|
|
11
|
+
/** Shown when no other text is present. Input restrictions do not apply to this property. */
|
|
12
|
+
placeholder: string;
|
|
13
|
+
/** Set to true to trigger disabled styles and to block all user input. */
|
|
14
|
+
disabled: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Only letters in the given string or matches to the given RegExp will be allowed.
|
|
17
|
+
* blockedInputs takes precedence over this input.
|
|
18
|
+
*
|
|
19
|
+
* For example: if allowedInputs is set to "abcd" and blockedInputs is set to "d", only "a",
|
|
20
|
+
* "b", or "c" letters will be allowed.
|
|
21
|
+
*/
|
|
22
|
+
allowedInputs: string | RegExp;
|
|
23
|
+
/** Any letters in the given string or matches to the given RegExp will be blocked. */
|
|
24
|
+
blockedInputs: string | RegExp;
|
|
25
|
+
/** Disable all browser helps like spellchecking, autocomplete, etc. */
|
|
26
|
+
disableBrowserHelps: boolean;
|
|
27
|
+
/** Set this to true to make the whole element size to only fit the input text. */
|
|
28
|
+
fitText: boolean;
|
|
29
|
+
/** A set of attributes that will be applied to the inner native text element. */
|
|
30
|
+
attributePassthrough: AttributeValues;
|
|
31
|
+
}>;
|
|
32
|
+
/**
|
|
33
|
+
* Inputs used to check if the current input element value is allowed.
|
|
34
|
+
*
|
|
35
|
+
* @category Internal
|
|
36
|
+
*/
|
|
37
|
+
export type IsAllowedInputs = {
|
|
38
|
+
value: string;
|
|
39
|
+
allowed: string | RegExp | undefined;
|
|
40
|
+
blocked: string | RegExp | undefined;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Filters out blocked text from an input element's value.
|
|
44
|
+
*
|
|
45
|
+
* @category Internal
|
|
46
|
+
*/
|
|
47
|
+
export declare function filterTextInputValue(inputs: IsAllowedInputs): {
|
|
48
|
+
filtered: string;
|
|
49
|
+
blocked: string;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* A function to be called when an input element's value changes.
|
|
53
|
+
*
|
|
54
|
+
* @category Internal
|
|
55
|
+
*/
|
|
56
|
+
export declare function textInputListener({ inputs, previousValue, event, inputBlockedCallback, newValueCallback, }: {
|
|
57
|
+
inputs: SharedTextInputElementInputs;
|
|
58
|
+
/** The value of the input element before this listener fired. */
|
|
59
|
+
previousValue: string;
|
|
60
|
+
event: Event;
|
|
61
|
+
inputBlockedCallback: (blockedInput: string) => void;
|
|
62
|
+
newValueCallback: (newValue: string) => void;
|
|
63
|
+
}): void;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { check, checkWrap } from '@augment-vir/assert';
|
|
2
|
+
import { extractEventTarget } from '@augment-vir/web';
|
|
3
|
+
function doesMatch({ input, matcher }) {
|
|
4
|
+
if (!input || !matcher) {
|
|
5
|
+
return true;
|
|
6
|
+
}
|
|
7
|
+
if (input.length > 1) {
|
|
8
|
+
return input.split('').every((singleInput) => doesMatch({ input: singleInput, matcher }));
|
|
9
|
+
}
|
|
10
|
+
if (matcher instanceof RegExp) {
|
|
11
|
+
return !!input.match(matcher);
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
return matcher.includes(input);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function isAllowed({ value, allowed, blocked }) {
|
|
18
|
+
const isAllowedCharacter = allowed
|
|
19
|
+
? doesMatch({
|
|
20
|
+
input: value,
|
|
21
|
+
matcher: allowed,
|
|
22
|
+
})
|
|
23
|
+
: true;
|
|
24
|
+
const isBlockedCharacter = blocked
|
|
25
|
+
? doesMatch({
|
|
26
|
+
input: value,
|
|
27
|
+
matcher: blocked,
|
|
28
|
+
})
|
|
29
|
+
: false;
|
|
30
|
+
return isAllowedCharacter && !isBlockedCharacter;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Filters out blocked text from an input element's value.
|
|
34
|
+
*
|
|
35
|
+
* @category Internal
|
|
36
|
+
*/
|
|
37
|
+
export function filterTextInputValue(inputs) {
|
|
38
|
+
if (!inputs.value) {
|
|
39
|
+
return { filtered: inputs.value, blocked: '' };
|
|
40
|
+
}
|
|
41
|
+
const { filtered, blocked } = inputs.value.split('').reduce((accum, letter) => {
|
|
42
|
+
const allowed = isAllowed({ ...inputs, value: letter });
|
|
43
|
+
if (allowed) {
|
|
44
|
+
accum.filtered.push(letter);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
accum.blocked.push(letter);
|
|
48
|
+
}
|
|
49
|
+
return accum;
|
|
50
|
+
}, {
|
|
51
|
+
filtered: [],
|
|
52
|
+
blocked: [],
|
|
53
|
+
});
|
|
54
|
+
return {
|
|
55
|
+
filtered: filtered.join(''),
|
|
56
|
+
blocked: blocked.join(''),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* A function to be called when an input element's value changes.
|
|
61
|
+
*
|
|
62
|
+
* @category Internal
|
|
63
|
+
*/
|
|
64
|
+
export function textInputListener({ inputs, previousValue, event, inputBlockedCallback, newValueCallback, }) {
|
|
65
|
+
const inputElement = extractEventTarget(event, HTMLInputElement);
|
|
66
|
+
/**
|
|
67
|
+
* This is usually a single character, but can be a bunch of characters in some circumstances.
|
|
68
|
+
* For example, when a bunch of characters are pasted, this will be the entire pasted contents.
|
|
69
|
+
*
|
|
70
|
+
* When a password manager auto fills the password, at least for Safari + iCloud Keychain, it'll
|
|
71
|
+
* fire a `CustomEvent` (rather than the typical `InputEvent`) and `event.data` won't be
|
|
72
|
+
* populated.
|
|
73
|
+
*/
|
|
74
|
+
const changedText = (check.hasKey(event, 'data') && checkWrap.isString(event.data)) || '';
|
|
75
|
+
/**
|
|
76
|
+
* When changedText is falsy, that means an operation other than inserting characters happened.
|
|
77
|
+
* Such as: deleting, cutting the text, etc.
|
|
78
|
+
*/
|
|
79
|
+
if (changedText) {
|
|
80
|
+
const { blocked } = filterTextInputValue({
|
|
81
|
+
value: changedText,
|
|
82
|
+
allowed: inputs.allowedInputs,
|
|
83
|
+
blocked: inputs.blockedInputs,
|
|
84
|
+
});
|
|
85
|
+
if (blocked.length) {
|
|
86
|
+
inputBlockedCallback(blocked);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
const finalValue = filterTextInputValue({
|
|
90
|
+
value: inputElement.value,
|
|
91
|
+
allowed: inputs.allowedInputs,
|
|
92
|
+
blocked: inputs.blockedInputs,
|
|
93
|
+
}).filtered;
|
|
94
|
+
if (inputElement.value !== finalValue) {
|
|
95
|
+
// this prevents blocked inputs by simply overwriting them
|
|
96
|
+
inputElement.value = finalValue;
|
|
97
|
+
}
|
|
98
|
+
if (previousValue !== finalValue) {
|
|
99
|
+
newValueCallback(finalValue);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Use this element to reserve space for bolded text, even if it isn't bold yet.
|
|
3
|
+
*
|
|
4
|
+
* @category Elements
|
|
5
|
+
*/
|
|
6
|
+
export declare const ViraBoldText: import("element-vir").DeclarativeElementDefinition<"vira-bold", {
|
|
7
|
+
bold: boolean;
|
|
8
|
+
text: string;
|
|
9
|
+
}, {}, {}, "vira-bold-bold", "vira-bold-bold-weight", readonly [], readonly []>;
|
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
import {css, html} from 'element-vir';
|
|
2
|
-
import {defineViraElement} from './define-vira-element.js';
|
|
3
|
-
|
|
1
|
+
import { css, html } from 'element-vir';
|
|
2
|
+
import { defineViraElement } from './define-vira-element.js';
|
|
4
3
|
/**
|
|
5
4
|
* Use this element to reserve space for bolded text, even if it isn't bold yet.
|
|
6
5
|
*
|
|
7
6
|
* @category Elements
|
|
8
7
|
*/
|
|
9
|
-
export const ViraBoldText = defineViraElement
|
|
8
|
+
export const ViraBoldText = defineViraElement()({
|
|
10
9
|
tagName: 'vira-bold',
|
|
11
10
|
cssVars: {
|
|
12
11
|
'vira-bold-bold-weight': 'bold',
|
|
13
12
|
},
|
|
14
13
|
hostClasses: {
|
|
15
|
-
'vira-bold-bold': ({inputs}) => inputs.bold,
|
|
14
|
+
'vira-bold-bold': ({ inputs }) => inputs.bold,
|
|
16
15
|
},
|
|
17
|
-
styles: ({hostClasses, cssVars}) => css`
|
|
16
|
+
styles: ({ hostClasses, cssVars }) => css `
|
|
18
17
|
span {
|
|
19
18
|
text-decoration: inherit;
|
|
20
19
|
white-space: inherit;
|
|
@@ -52,8 +51,8 @@ export const ViraBoldText = defineViraElement<{bold: boolean; text: string}>()({
|
|
|
52
51
|
z-index: unset;
|
|
53
52
|
}
|
|
54
53
|
`,
|
|
55
|
-
render({inputs}) {
|
|
56
|
-
return html`
|
|
54
|
+
render({ inputs }) {
|
|
55
|
+
return html `
|
|
57
56
|
<span class="everything-wrapper">
|
|
58
57
|
<span class="bold-wrapper">
|
|
59
58
|
<span class="bold">${inputs.text}</span>
|