vira 28.19.6 → 28.19.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/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 +14 -0
- package/{src/elements/vira-collapsible-wrapper.element.ts → dist/elements/vira-collapsible-wrapper.element.js} +16 -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,28 +1,14 @@
|
|
|
1
|
-
import {check} from '@augment-vir/assert';
|
|
2
|
-
import {filterMap
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
testId,
|
|
13
|
-
} from 'element-vir';
|
|
14
|
-
import {type ViraIconSvg} from '../icons/icon-svg.js';
|
|
15
|
-
import {ChevronUp24Icon} from '../icons/index.js';
|
|
16
|
-
import {viraBorders} from '../styles/border.js';
|
|
17
|
-
import {viraFormCssVars} from '../styles/form-styles.js';
|
|
18
|
-
import {noUserSelect, viraAnimationDurations} from '../styles/index.js';
|
|
19
|
-
import {type ShowPopUpResult} from '../util/pop-up-manager.js';
|
|
20
|
-
import {defineViraElement} from './define-vira-element.js';
|
|
21
|
-
import {type MenuItem} from './pop-up/pop-up-menu-item.js';
|
|
22
|
-
import {ViraMenuTrigger} from './pop-up/vira-menu-trigger.element.js';
|
|
23
|
-
import {HorizontalAnchor, type PopUpTriggerPosition} from './pop-up/vira-pop-up-trigger.element.js';
|
|
24
|
-
import {ViraIcon} from './vira-icon.element.js';
|
|
25
|
-
|
|
1
|
+
import { check } from '@augment-vir/assert';
|
|
2
|
+
import { filterMap } from '@augment-vir/common';
|
|
3
|
+
import { classMap, css, defineElementEvent, html, ifDefined, listen, nothing, testId, } from 'element-vir';
|
|
4
|
+
import { ChevronUp24Icon } from '../icons/index.js';
|
|
5
|
+
import { viraBorders } from '../styles/border.js';
|
|
6
|
+
import { viraFormCssVars } from '../styles/form-styles.js';
|
|
7
|
+
import { noUserSelect, viraAnimationDurations } from '../styles/index.js';
|
|
8
|
+
import { defineViraElement } from './define-vira-element.js';
|
|
9
|
+
import { ViraMenuTrigger } from './pop-up/vira-menu-trigger.element.js';
|
|
10
|
+
import { HorizontalAnchor } from './pop-up/vira-pop-up-trigger.element.js';
|
|
11
|
+
import { ViraIcon } from './vira-icon.element.js';
|
|
26
12
|
/**
|
|
27
13
|
* Test ids for {@link ViraDropdown}.
|
|
28
14
|
*
|
|
@@ -33,7 +19,6 @@ export const viraDropdownTestIds = {
|
|
|
33
19
|
icon: 'dropdown-icon',
|
|
34
20
|
prefix: 'dropdown-prefix',
|
|
35
21
|
};
|
|
36
|
-
|
|
37
22
|
/**
|
|
38
23
|
* A dropdown element that uses pop-up menus.
|
|
39
24
|
*
|
|
@@ -41,30 +26,9 @@ export const viraDropdownTestIds = {
|
|
|
41
26
|
* @category Elements
|
|
42
27
|
* @see https://electrovir.github.io/vira/book/elements/dropdown/vira-dropdown
|
|
43
28
|
*/
|
|
44
|
-
export const ViraDropdown = defineViraElement
|
|
45
|
-
{
|
|
46
|
-
options: ReadonlyArray<Readonly<MenuItem>>;
|
|
47
|
-
/** The selected id from the given options. */
|
|
48
|
-
selected: ReadonlyArray<PropertyKey>;
|
|
49
|
-
} & PartialWithUndefined<
|
|
50
|
-
{
|
|
51
|
-
/** Text to show if nothing is selected. */
|
|
52
|
-
placeholder: string;
|
|
53
|
-
/**
|
|
54
|
-
* If false, this will behave like a single select dropdown, otherwise you can select
|
|
55
|
-
* multiple.
|
|
56
|
-
*/
|
|
57
|
-
isMultiSelect: boolean;
|
|
58
|
-
icon: ViraIconSvg;
|
|
59
|
-
selectionPrefix: string;
|
|
60
|
-
isDisabled: boolean;
|
|
61
|
-
/** For debugging purposes only. Very bad for actual production code use. */
|
|
62
|
-
z_debug_forceOpenState: boolean;
|
|
63
|
-
} & PopUpTriggerPosition
|
|
64
|
-
>
|
|
65
|
-
>()({
|
|
29
|
+
export const ViraDropdown = defineViraElement()({
|
|
66
30
|
tagName: 'vira-dropdown',
|
|
67
|
-
styles: css`
|
|
31
|
+
styles: css `
|
|
68
32
|
:host {
|
|
69
33
|
display: inline-flex;
|
|
70
34
|
vertical-align: middle;
|
|
@@ -133,86 +97,76 @@ export const ViraDropdown = defineViraElement<
|
|
|
133
97
|
}
|
|
134
98
|
`,
|
|
135
99
|
events: {
|
|
136
|
-
selectedChange: defineElementEvent
|
|
137
|
-
openChange: defineElementEvent
|
|
100
|
+
selectedChange: defineElementEvent(),
|
|
101
|
+
openChange: defineElementEvent(),
|
|
138
102
|
},
|
|
139
103
|
state() {
|
|
140
104
|
return {
|
|
141
105
|
/** `undefined` means the pop up is not currently showing. */
|
|
142
|
-
showPopUpResult: undefined
|
|
106
|
+
showPopUpResult: undefined,
|
|
143
107
|
};
|
|
144
108
|
},
|
|
145
|
-
render({state, inputs, dispatch, events, updateState}) {
|
|
146
|
-
const selectedOptions = filterMap(
|
|
147
|
-
inputs.selected,
|
|
148
|
-
(selectedId) => inputs.options.find((option) => option.id === selectedId),
|
|
149
|
-
check.isTruthy,
|
|
150
|
-
);
|
|
151
|
-
|
|
109
|
+
render({ state, inputs, dispatch, events, updateState }) {
|
|
110
|
+
const selectedOptions = filterMap(inputs.selected, (selectedId) => inputs.options.find((option) => option.id === selectedId), check.isTruthy);
|
|
152
111
|
const leadingIconTemplate = inputs.icon
|
|
153
|
-
? html`
|
|
112
|
+
? html `
|
|
154
113
|
<${ViraIcon.assign({
|
|
155
|
-
|
|
156
|
-
|
|
114
|
+
icon: inputs.icon,
|
|
115
|
+
})}
|
|
157
116
|
${testId(viraDropdownTestIds.icon)}
|
|
158
117
|
></${ViraIcon}>
|
|
159
118
|
`
|
|
160
119
|
: nothing;
|
|
161
|
-
|
|
162
|
-
const
|
|
163
|
-
|
|
164
|
-
const prefixTemplate =
|
|
165
|
-
inputs.selectionPrefix && !shouldUsePlaceholder
|
|
166
|
-
? html`
|
|
120
|
+
const shouldUsePlaceholder = !selectedOptions.length;
|
|
121
|
+
const prefixTemplate = inputs.selectionPrefix && !shouldUsePlaceholder
|
|
122
|
+
? html `
|
|
167
123
|
<span class="selected-label-prefix" ${testId(viraDropdownTestIds.prefix)}>
|
|
168
124
|
${inputs.selectionPrefix}
|
|
169
125
|
</span>
|
|
170
126
|
`
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
const selectionDisplay: string | HTMLTemplateResult = shouldUsePlaceholder
|
|
127
|
+
: nothing;
|
|
128
|
+
const selectionDisplay = shouldUsePlaceholder
|
|
174
129
|
? inputs.placeholder || ''
|
|
175
130
|
: inputs.isMultiSelect && selectedOptions.length > 1
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
return html`
|
|
131
|
+
? `${selectedOptions.length} Selected`
|
|
132
|
+
: selectedOptions[0]?.label || '';
|
|
133
|
+
return html `
|
|
180
134
|
<${ViraMenuTrigger.assign({
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
135
|
+
...inputs,
|
|
136
|
+
items: inputs.options,
|
|
137
|
+
popUpOffset: {
|
|
138
|
+
vertical: -1,
|
|
139
|
+
right: 24,
|
|
140
|
+
},
|
|
141
|
+
horizontalAnchor: inputs.horizontalAnchor || HorizontalAnchor.Both,
|
|
142
|
+
})}
|
|
189
143
|
${listen(ViraMenuTrigger.events.openChange, (event) => {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
144
|
+
updateState({ showPopUpResult: event.detail });
|
|
145
|
+
dispatch(new events.openChange(event.detail));
|
|
146
|
+
})}
|
|
193
147
|
${listen(ViraMenuTrigger.events.itemActivate, (event) => {
|
|
194
|
-
|
|
195
|
-
|
|
148
|
+
dispatch(new events.selectedChange(event.detail));
|
|
149
|
+
})}
|
|
196
150
|
>
|
|
197
151
|
<div
|
|
198
152
|
class="dropdown-trigger ${classMap({
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
153
|
+
open: !!state.showPopUpResult,
|
|
154
|
+
'open-upwards': !state.showPopUpResult?.popDown,
|
|
155
|
+
})}"
|
|
202
156
|
${testId(viraDropdownTestIds.trigger)}
|
|
203
157
|
>
|
|
204
158
|
${leadingIconTemplate}
|
|
205
159
|
<span
|
|
206
160
|
class="selection-display ${classMap({
|
|
207
|
-
|
|
208
|
-
|
|
161
|
+
'using-placeholder': shouldUsePlaceholder,
|
|
162
|
+
})}"
|
|
209
163
|
title=${ifDefined(shouldUsePlaceholder ? undefined : selectionDisplay)}
|
|
210
164
|
>
|
|
211
165
|
${prefixTemplate} ${selectionDisplay}
|
|
212
166
|
</span>
|
|
213
167
|
|
|
214
168
|
<span class="trigger-icon-wrapper">
|
|
215
|
-
<${ViraIcon.assign({icon: ChevronUp24Icon})}
|
|
169
|
+
<${ViraIcon.assign({ icon: ChevronUp24Icon })}
|
|
216
170
|
class="trigger-icon"
|
|
217
171
|
></${ViraIcon}>
|
|
218
172
|
</span>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An error wrapper that applies error coloring (red, by default).
|
|
3
|
+
*
|
|
4
|
+
* @category Elements
|
|
5
|
+
* @see https://electrovir.github.io/vira/book/elements/vira-error
|
|
6
|
+
*/
|
|
7
|
+
export declare const ViraError: import("element-vir").DeclarativeElementDefinition<"vira-error", {}, {}, {}, "vira-error-", "vira-error-font-weight", readonly [], readonly []>;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {css, html} from 'element-vir';
|
|
2
|
-
import {viraFormCssVars} from '../styles/form-styles.js';
|
|
3
|
-
import {defineViraElement} from './define-vira-element.js';
|
|
4
|
-
|
|
1
|
+
import { css, html } from 'element-vir';
|
|
2
|
+
import { viraFormCssVars } from '../styles/form-styles.js';
|
|
3
|
+
import { defineViraElement } from './define-vira-element.js';
|
|
5
4
|
/**
|
|
6
5
|
* An error wrapper that applies error coloring (red, by default).
|
|
7
6
|
*
|
|
@@ -13,14 +12,14 @@ export const ViraError = defineViraElement()({
|
|
|
13
12
|
cssVars: {
|
|
14
13
|
'vira-error-font-weight': 'bold',
|
|
15
14
|
},
|
|
16
|
-
styles: ({cssVars}) => css`
|
|
15
|
+
styles: ({ cssVars }) => css `
|
|
17
16
|
:host {
|
|
18
17
|
color: ${viraFormCssVars['vira-form-error-foreground-color'].value};
|
|
19
18
|
font-weight: ${cssVars['vira-error-font-weight'].value};
|
|
20
19
|
}
|
|
21
20
|
`,
|
|
22
21
|
render() {
|
|
23
|
-
return html`
|
|
22
|
+
return html `
|
|
24
23
|
<slot></slot>
|
|
25
24
|
`;
|
|
26
25
|
},
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type ViraIconSvg } from '../icons/icon-svg.js';
|
|
2
|
+
/**
|
|
3
|
+
* An element that renders a single {@link ViraIconSvg}.
|
|
4
|
+
*
|
|
5
|
+
* @category Icon
|
|
6
|
+
* @category Elements
|
|
7
|
+
* @see https://electrovir.github.io/vira/book/elements/vira-icon
|
|
8
|
+
*/
|
|
9
|
+
export declare const ViraIcon: import("element-vir").DeclarativeElementDefinition<"vira-icon", {
|
|
10
|
+
icon: Pick<ViraIconSvg, "svgTemplate"> | undefined;
|
|
11
|
+
/** Ignores the given icon's embedded size and causes the <svg> element to fill its parent. */
|
|
12
|
+
fitContainer?: boolean | undefined;
|
|
13
|
+
}, {}, {}, "vira-icon-fit-container", "vira-icon-", readonly [], readonly []>;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import {css} from 'element-vir';
|
|
2
|
-
import {
|
|
3
|
-
import {defineViraElement} from './define-vira-element.js';
|
|
4
|
-
|
|
1
|
+
import { css } from 'element-vir';
|
|
2
|
+
import { defineViraElement } from './define-vira-element.js';
|
|
5
3
|
/**
|
|
6
4
|
* An element that renders a single {@link ViraIconSvg}.
|
|
7
5
|
*
|
|
@@ -9,17 +7,13 @@ import {defineViraElement} from './define-vira-element.js';
|
|
|
9
7
|
* @category Elements
|
|
10
8
|
* @see https://electrovir.github.io/vira/book/elements/vira-icon
|
|
11
9
|
*/
|
|
12
|
-
export const ViraIcon = defineViraElement
|
|
13
|
-
icon: Pick<ViraIconSvg, 'svgTemplate'> | undefined;
|
|
14
|
-
/** Ignores the given icon's embedded size and causes the <svg> element to fill its parent. */
|
|
15
|
-
fitContainer?: boolean | undefined;
|
|
16
|
-
}>()({
|
|
10
|
+
export const ViraIcon = defineViraElement()({
|
|
17
11
|
tagName: 'vira-icon',
|
|
18
12
|
hostClasses: {
|
|
19
13
|
/** Ignores the given icon's embedded size and causes the <svg> element to fill its parent. */
|
|
20
|
-
'vira-icon-fit-container': ({inputs}) => !!inputs.fitContainer,
|
|
14
|
+
'vira-icon-fit-container': ({ inputs }) => !!inputs.fitContainer,
|
|
21
15
|
},
|
|
22
|
-
styles: ({hostClasses}) => css`
|
|
16
|
+
styles: ({ hostClasses }) => css `
|
|
23
17
|
:host {
|
|
24
18
|
display: inline-block;
|
|
25
19
|
}
|
|
@@ -37,11 +31,10 @@ export const ViraIcon = defineViraElement<{
|
|
|
37
31
|
width: 100%;
|
|
38
32
|
}
|
|
39
33
|
`,
|
|
40
|
-
render({inputs}) {
|
|
34
|
+
render({ inputs }) {
|
|
41
35
|
if (!inputs.icon) {
|
|
42
36
|
return '';
|
|
43
37
|
}
|
|
44
|
-
|
|
45
38
|
return inputs.icon.svgTemplate;
|
|
46
39
|
},
|
|
47
40
|
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type Dimensions } from '@augment-vir/common';
|
|
2
|
+
import { type Duration, type DurationUnit } from 'date-vir';
|
|
3
|
+
/**
|
|
4
|
+
* An `<img>` element wrapper that handles size constraints and includes slots for loading and error
|
|
5
|
+
* indicators.
|
|
6
|
+
*
|
|
7
|
+
* Use CSS properties to constrain the image. In particular, set `min-height` and `min-width` on
|
|
8
|
+
* this to control the size of the loader and error slots.
|
|
9
|
+
*
|
|
10
|
+
* @category Image
|
|
11
|
+
* @category Elements
|
|
12
|
+
* @see https://electrovir.github.io/vira/book/elements/vira-image
|
|
13
|
+
*/
|
|
14
|
+
export declare const ViraImage: import("element-vir").DeclarativeElementDefinition<"vira-image", {
|
|
15
|
+
/** The URL of the image to load. This is passed directly to the `<img>` element. */
|
|
16
|
+
imageUrl: string;
|
|
17
|
+
/**
|
|
18
|
+
* The dimension which should dominantly constrain the image size. Whichever dimension this is
|
|
19
|
+
* set to is the dimension that the image will grow to match. This is only relevant if you apply
|
|
20
|
+
* size constraints on ViraImage via CSS in its parent.
|
|
21
|
+
*
|
|
22
|
+
* @default 'width'
|
|
23
|
+
*/
|
|
24
|
+
dominantDimension?: keyof Dimensions | undefined;
|
|
25
|
+
/** For debugging only: artificially set a delay for the image loading so you can see the loader. */
|
|
26
|
+
_debugLoadDelay?: Duration<DurationUnit.Milliseconds> | undefined;
|
|
27
|
+
}, {
|
|
28
|
+
/**
|
|
29
|
+
* To avoid race conditions between `<img>` element events and potential input changing,
|
|
30
|
+
* save the loaded state of an URL's image by the image's URL.
|
|
31
|
+
*/
|
|
32
|
+
loadedUrls: Readonly<{
|
|
33
|
+
[url: string]: true;
|
|
34
|
+
}>;
|
|
35
|
+
/**
|
|
36
|
+
* To avoid race conditions between `<img>` element events and potential input changing,
|
|
37
|
+
* save the errored state of an URL's image by the image's URL.
|
|
38
|
+
*/
|
|
39
|
+
erroredUrls: Readonly<{
|
|
40
|
+
[url: string]: true;
|
|
41
|
+
}>;
|
|
42
|
+
}, {
|
|
43
|
+
imageLoad: import("element-vir").DefineEvent<void>;
|
|
44
|
+
imageError: import("element-vir").DefineEvent<unknown>;
|
|
45
|
+
}, "vira-image-height-constrained", "vira-image-", readonly ["loading", "error"], readonly []>;
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {ViraIcon} from './vira-icon.element.js';
|
|
7
|
-
|
|
1
|
+
import { wait } from '@augment-vir/common';
|
|
2
|
+
import { classMap, css, defineElementEvent, html, listen, renderIf } from 'element-vir';
|
|
3
|
+
import { LoaderAnimated24Icon, StatusFailure24Icon } from '../icons/index.js';
|
|
4
|
+
import { defineViraElement } from './define-vira-element.js';
|
|
5
|
+
import { ViraIcon } from './vira-icon.element.js';
|
|
8
6
|
/**
|
|
9
7
|
* An `<img>` element wrapper that handles size constraints and includes slots for loading and error
|
|
10
8
|
* indicators.
|
|
@@ -16,20 +14,7 @@ import {ViraIcon} from './vira-icon.element.js';
|
|
|
16
14
|
* @category Elements
|
|
17
15
|
* @see https://electrovir.github.io/vira/book/elements/vira-image
|
|
18
16
|
*/
|
|
19
|
-
export const ViraImage = defineViraElement
|
|
20
|
-
/** The URL of the image to load. This is passed directly to the `<img>` element. */
|
|
21
|
-
imageUrl: string;
|
|
22
|
-
/**
|
|
23
|
-
* The dimension which should dominantly constrain the image size. Whichever dimension this is
|
|
24
|
-
* set to is the dimension that the image will grow to match. This is only relevant if you apply
|
|
25
|
-
* size constraints on ViraImage via CSS in its parent.
|
|
26
|
-
*
|
|
27
|
-
* @default 'width'
|
|
28
|
-
*/
|
|
29
|
-
dominantDimension?: keyof Dimensions | undefined;
|
|
30
|
-
/** For debugging only: artificially set a delay for the image loading so you can see the loader. */
|
|
31
|
-
_debugLoadDelay?: Duration<DurationUnit.Milliseconds> | undefined;
|
|
32
|
-
}>()({
|
|
17
|
+
export const ViraImage = defineViraElement()({
|
|
33
18
|
tagName: 'vira-image',
|
|
34
19
|
state() {
|
|
35
20
|
return {
|
|
@@ -37,26 +22,26 @@ export const ViraImage = defineViraElement<{
|
|
|
37
22
|
* To avoid race conditions between `<img>` element events and potential input changing,
|
|
38
23
|
* save the loaded state of an URL's image by the image's URL.
|
|
39
24
|
*/
|
|
40
|
-
loadedUrls: {}
|
|
25
|
+
loadedUrls: {},
|
|
41
26
|
/**
|
|
42
27
|
* To avoid race conditions between `<img>` element events and potential input changing,
|
|
43
28
|
* save the errored state of an URL's image by the image's URL.
|
|
44
29
|
*/
|
|
45
|
-
erroredUrls: {}
|
|
30
|
+
erroredUrls: {},
|
|
46
31
|
};
|
|
47
32
|
},
|
|
48
33
|
hostClasses: {
|
|
49
|
-
'vira-image-height-constrained': ({inputs}) => inputs.dominantDimension === 'height',
|
|
34
|
+
'vira-image-height-constrained': ({ inputs }) => inputs.dominantDimension === 'height',
|
|
50
35
|
},
|
|
51
36
|
slotNames: [
|
|
52
37
|
'loading',
|
|
53
38
|
'error',
|
|
54
39
|
],
|
|
55
40
|
events: {
|
|
56
|
-
imageLoad: defineElementEvent
|
|
57
|
-
imageError: defineElementEvent
|
|
41
|
+
imageLoad: defineElementEvent(),
|
|
42
|
+
imageError: defineElementEvent(),
|
|
58
43
|
},
|
|
59
|
-
styles: ({hostClasses}) => css`
|
|
44
|
+
styles: ({ hostClasses }) => css `
|
|
60
45
|
:host {
|
|
61
46
|
display: inline-flex;
|
|
62
47
|
overflow: hidden;
|
|
@@ -103,60 +88,55 @@ export const ViraImage = defineViraElement<{
|
|
|
103
88
|
display: none;
|
|
104
89
|
}
|
|
105
90
|
`,
|
|
106
|
-
render({inputs, state, updateState, dispatch, events, slotNames}) {
|
|
91
|
+
render({ inputs, state, updateState, dispatch, events, slotNames }) {
|
|
107
92
|
/**
|
|
108
93
|
* Saved off for use in the image listeners. This is used to eliminate race conditions
|
|
109
94
|
* between image events and the input URL changing.
|
|
110
95
|
*/
|
|
111
96
|
const imageUrl = inputs.imageUrl;
|
|
112
|
-
|
|
113
97
|
const statusTemplate = state.erroredUrls[imageUrl]
|
|
114
|
-
? html`
|
|
98
|
+
? html `
|
|
115
99
|
<slot class="status-wrapper" name=${slotNames.error}>
|
|
116
|
-
<${ViraIcon.assign({icon: StatusFailure24Icon})} class="error"></${ViraIcon}>
|
|
100
|
+
<${ViraIcon.assign({ icon: StatusFailure24Icon })} class="error"></${ViraIcon}>
|
|
117
101
|
</slot>
|
|
118
102
|
`
|
|
119
103
|
: state.loadedUrls[imageUrl]
|
|
120
|
-
|
|
121
|
-
|
|
104
|
+
? undefined
|
|
105
|
+
: html `
|
|
122
106
|
<slot class="status-wrapper" name=${slotNames.loading}>
|
|
123
|
-
<${ViraIcon.assign({icon: LoaderAnimated24Icon})}></${ViraIcon}>
|
|
107
|
+
<${ViraIcon.assign({ icon: LoaderAnimated24Icon })}></${ViraIcon}>
|
|
124
108
|
</slot>
|
|
125
109
|
`;
|
|
126
|
-
|
|
127
|
-
return html`
|
|
110
|
+
return html `
|
|
128
111
|
${renderIf(!!statusTemplate, statusTemplate)}
|
|
129
112
|
<img
|
|
130
113
|
class=${classMap({
|
|
131
|
-
|
|
132
|
-
|
|
114
|
+
hidden: !!statusTemplate,
|
|
115
|
+
})}
|
|
133
116
|
${listen('load', async () => {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
dispatch(new events.imageLoad());
|
|
146
|
-
})}
|
|
117
|
+
if (inputs._debugLoadDelay) {
|
|
118
|
+
await wait(inputs._debugLoadDelay);
|
|
119
|
+
}
|
|
120
|
+
updateState({
|
|
121
|
+
loadedUrls: {
|
|
122
|
+
...state.loadedUrls,
|
|
123
|
+
[imageUrl]: true,
|
|
124
|
+
},
|
|
125
|
+
});
|
|
126
|
+
dispatch(new events.imageLoad());
|
|
127
|
+
})}
|
|
147
128
|
${listen('error', async (event) => {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
})}
|
|
129
|
+
if (inputs._debugLoadDelay) {
|
|
130
|
+
await wait(inputs._debugLoadDelay);
|
|
131
|
+
}
|
|
132
|
+
updateState({
|
|
133
|
+
erroredUrls: {
|
|
134
|
+
...state.erroredUrls,
|
|
135
|
+
[imageUrl]: true,
|
|
136
|
+
},
|
|
137
|
+
});
|
|
138
|
+
dispatch(new events.imageError(event.error));
|
|
139
|
+
})}
|
|
160
140
|
src=${imageUrl}
|
|
161
141
|
/>
|
|
162
142
|
`;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { type PartialWithUndefined } from '@augment-vir/common';
|
|
2
|
+
import { type ViraIconSvg } from '../icons/index.js';
|
|
3
|
+
export * from './shared-text-input-logic.js';
|
|
4
|
+
/**
|
|
5
|
+
* Input types for {@link ViraInput}.
|
|
6
|
+
*
|
|
7
|
+
* @category Internal
|
|
8
|
+
*/
|
|
9
|
+
export declare enum ViraInputType {
|
|
10
|
+
Default = "text",
|
|
11
|
+
Password = "password",
|
|
12
|
+
Email = "email"
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* A single line input element with all listeners properly attached. Multiple types are allowed with
|
|
16
|
+
* {@link ViraInputType}.
|
|
17
|
+
*
|
|
18
|
+
* @category Input
|
|
19
|
+
* @category Elements
|
|
20
|
+
* @see https://electrovir.github.io/vira/book/elements/vira-input
|
|
21
|
+
*/
|
|
22
|
+
export declare const ViraInput: import("element-vir").DeclarativeElementDefinition<"vira-input", Readonly<PartialWithUndefined<{
|
|
23
|
+
icon: Pick<ViraIconSvg, "svgTemplate">;
|
|
24
|
+
/** A suffix that, if provided, is shown following the input field. */
|
|
25
|
+
suffix: string;
|
|
26
|
+
/** A label that is shown above the input, if provided. */
|
|
27
|
+
label: string;
|
|
28
|
+
/** If true, applies error styling. */
|
|
29
|
+
hasError: boolean;
|
|
30
|
+
showClearButton: boolean;
|
|
31
|
+
type: ViraInputType;
|
|
32
|
+
}> & {
|
|
33
|
+
value: string;
|
|
34
|
+
} & PartialWithUndefined<{
|
|
35
|
+
placeholder: string;
|
|
36
|
+
disabled: boolean;
|
|
37
|
+
allowedInputs: string | RegExp;
|
|
38
|
+
blockedInputs: string | RegExp;
|
|
39
|
+
disableBrowserHelps: boolean;
|
|
40
|
+
fitText: boolean;
|
|
41
|
+
attributePassthrough: import("element-vir").AttributeValues;
|
|
42
|
+
}>>, {
|
|
43
|
+
forcedInputWidth: number;
|
|
44
|
+
showPassword: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Used to couple the label and input together. This is not applied if no label is
|
|
47
|
+
* provided.
|
|
48
|
+
*/
|
|
49
|
+
randomId: string;
|
|
50
|
+
}, {
|
|
51
|
+
/**
|
|
52
|
+
* Fires whenever a user input created a new value. Does not fire if all input letters are
|
|
53
|
+
* filtered out due to input restrictions.
|
|
54
|
+
*/
|
|
55
|
+
valueChange: import("element-vir").DefineEvent<string>;
|
|
56
|
+
/**
|
|
57
|
+
* Fires when inputs are blocked. Useful for showing warnings or error messages to inform
|
|
58
|
+
* the user why their input did not propagate if it was blocked. This does not fire for text
|
|
59
|
+
* that was blocked out of programmatic "value" property assignments.
|
|
60
|
+
*/
|
|
61
|
+
inputBlocked: import("element-vir").DefineEvent<string>;
|
|
62
|
+
}, "vira-input-disabled" | "vira-input-fit-text" | "vira-input-clear-button-shown" | "vira-input-error", "vira-input-action-button-color" | "vira-input-clear-button-hover-color" | "vira-input-clear-button-active-color" | "vira-input-show-password-button-hover-color" | "vira-input-show-password-button-active-color" | "vira-input-padding-horizontal" | "vira-input-padding-vertical", readonly [], readonly []>;
|