vira 28.19.6 → 29.0.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.
Files changed (192) hide show
  1. package/dist/elements/define-vira-element.d.ts +18 -0
  2. package/dist/elements/define-vira-element.js +19 -0
  3. package/dist/elements/form/vira-form-fields.d.ts +100 -0
  4. package/dist/elements/form/vira-form-fields.js +60 -0
  5. package/dist/elements/form/vira-form.element.d.ts +35 -0
  6. package/dist/elements/form/vira-form.element.js +151 -0
  7. package/dist/elements/index.js +25 -0
  8. package/dist/elements/pop-up/pop-up-helpers.d.ts +33 -0
  9. package/dist/elements/pop-up/pop-up-helpers.js +58 -0
  10. package/{src/elements/pop-up/pop-up-menu-item.ts → dist/elements/pop-up/pop-up-menu-item.d.ts} +3 -4
  11. package/dist/elements/pop-up/pop-up-menu-item.js +1 -0
  12. package/dist/elements/pop-up/vira-menu-item.element.d.ts +19 -0
  13. package/{src/elements/pop-up/vira-menu-item.element.ts → dist/elements/pop-up/vira-menu-item.element.js} +11 -28
  14. package/dist/elements/pop-up/vira-menu-trigger.element.d.ts +41 -0
  15. package/dist/elements/pop-up/vira-menu-trigger.element.js +121 -0
  16. package/dist/elements/pop-up/vira-menu.element.d.ts +38 -0
  17. package/{src/elements/pop-up/vira-menu.element.ts → dist/elements/pop-up/vira-menu.element.js} +49 -78
  18. package/dist/elements/pop-up/vira-pop-up-menu.element.d.ts +35 -0
  19. package/{src/elements/pop-up/vira-pop-up-menu.element.ts → dist/elements/pop-up/vira-pop-up-menu.element.js} +24 -37
  20. package/dist/elements/pop-up/vira-pop-up-trigger.element.d.ts +105 -0
  21. package/{src/elements/pop-up/vira-pop-up-trigger.element.ts → dist/elements/pop-up/vira-pop-up-trigger.element.js} +104 -199
  22. package/dist/elements/shared-text-input-logic.d.ts +63 -0
  23. package/dist/elements/shared-text-input-logic.js +101 -0
  24. package/dist/elements/vira-bold-text.element.d.ts +9 -0
  25. package/{src/elements/vira-bold-text.element.ts → dist/elements/vira-bold-text.element.js} +7 -8
  26. package/dist/elements/vira-button.element.d.ts +34 -0
  27. package/dist/elements/vira-button.element.js +176 -0
  28. package/dist/elements/vira-card.element.d.ts +18 -0
  29. package/dist/elements/vira-card.element.js +60 -0
  30. package/dist/elements/vira-checkbox.element.d.ts +38 -0
  31. package/{src/elements/vira-checkbox.element.ts → dist/elements/vira-checkbox.element.js} +70 -83
  32. package/dist/elements/vira-collapsible-wrapper.element.d.ts +14 -0
  33. package/{src/elements/vira-collapsible-wrapper.element.ts → dist/elements/vira-collapsible-wrapper.element.js} +16 -18
  34. package/dist/elements/vira-dropdown.element.d.ts +46 -0
  35. package/{src/elements/vira-dropdown.element.ts → dist/elements/vira-dropdown.element.js} +48 -95
  36. package/dist/elements/vira-error.element.d.ts +7 -0
  37. package/{src/elements/vira-error.element.ts → dist/elements/vira-error.element.js} +6 -7
  38. package/dist/elements/vira-icon.element.d.ts +13 -0
  39. package/{src/elements/vira-icon.element.ts → dist/elements/vira-icon.element.js} +6 -13
  40. package/dist/elements/vira-image.element.d.ts +45 -0
  41. package/{src/elements/vira-image.element.ts → dist/elements/vira-image.element.js} +43 -63
  42. package/dist/elements/vira-input.element.d.ts +62 -0
  43. package/{src/elements/vira-input.element.ts → dist/elements/vira-input.element.js} +93 -166
  44. package/dist/elements/vira-link.element.d.ts +73 -0
  45. package/{src/elements/vira-link.element.ts → dist/elements/vira-link.element.js} +17 -67
  46. package/dist/elements/vira-modal.element.d.ts +39 -0
  47. package/{src/elements/vira-modal.element.ts → dist/elements/vira-modal.element.js} +56 -97
  48. package/dist/elements/vira-overflow-switch.element.d.ts +21 -0
  49. package/dist/elements/vira-overflow-switch.element.js +110 -0
  50. package/dist/elements/vira-progress.element.d.ts +18 -0
  51. package/{src/elements/vira-progress.element.ts → dist/elements/vira-progress.element.js} +14 -30
  52. package/dist/elements/vira-select.element.d.ts +48 -0
  53. package/{src/elements/vira-select.element.ts → dist/elements/vira-select.element.js} +45 -99
  54. package/dist/icons/icon-color.test-helper.d.ts +6 -0
  55. package/dist/icons/icon-color.test-helper.js +9 -0
  56. package/dist/icons/icon-css-vars.d.ts +14 -0
  57. package/{src/icons/icon-css-vars.ts → dist/icons/icon-css-vars.js} +1 -2
  58. package/dist/icons/icon-svg.d.ts +27 -0
  59. package/dist/icons/icon-svg.js +48 -0
  60. package/dist/icons/icon-svgs/bell-24.icon.d.ts +8 -0
  61. package/{src/icons/icon-svgs/bell-24.icon.ts → dist/icons/icon-svgs/bell-24.icon.js} +4 -5
  62. package/dist/icons/icon-svgs/chat-24.icon.d.ts +8 -0
  63. package/{src/icons/icon-svgs/chat-24.icon.ts → dist/icons/icon-svgs/chat-24.icon.js} +4 -5
  64. package/dist/icons/icon-svgs/check-24.icon.d.ts +8 -0
  65. package/{src/icons/icon-svgs/check-24.icon.ts → dist/icons/icon-svgs/check-24.icon.js} +4 -5
  66. package/dist/icons/icon-svgs/chevron-down-24.icon.d.ts +8 -0
  67. package/{src/icons/icon-svgs/chevron-down-24.icon.ts → dist/icons/icon-svgs/chevron-down-24.icon.js} +4 -5
  68. package/dist/icons/icon-svgs/chevron-up-24.icon.d.ts +8 -0
  69. package/{src/icons/icon-svgs/chevron-up-24.icon.ts → dist/icons/icon-svgs/chevron-up-24.icon.js} +4 -5
  70. package/dist/icons/icon-svgs/close-x-24.icon.d.ts +8 -0
  71. package/{src/icons/icon-svgs/close-x-24.icon.ts → dist/icons/icon-svgs/close-x-24.icon.js} +4 -5
  72. package/dist/icons/icon-svgs/commit-24.icon.d.ts +8 -0
  73. package/{src/icons/icon-svgs/commit-24.icon.ts → dist/icons/icon-svgs/commit-24.icon.js} +4 -5
  74. package/dist/icons/icon-svgs/copy-24.icon.d.ts +8 -0
  75. package/{src/icons/icon-svgs/copy-24.icon.ts → dist/icons/icon-svgs/copy-24.icon.js} +4 -5
  76. package/dist/icons/icon-svgs/document-24.icon.d.ts +8 -0
  77. package/{src/icons/icon-svgs/document-24.icon.ts → dist/icons/icon-svgs/document-24.icon.js} +4 -5
  78. package/dist/icons/icon-svgs/document-search-24.icon.d.ts +8 -0
  79. package/{src/icons/icon-svgs/document-search-24.icon.ts → dist/icons/icon-svgs/document-search-24.icon.js} +4 -5
  80. package/dist/icons/icon-svgs/double-chevron-24.icon.d.ts +8 -0
  81. package/{src/icons/icon-svgs/double-chevron-24.icon.ts → dist/icons/icon-svgs/double-chevron-24.icon.js} +4 -5
  82. package/dist/icons/icon-svgs/element-16.icon.d.ts +8 -0
  83. package/{src/icons/icon-svgs/element-16.icon.ts → dist/icons/icon-svgs/element-16.icon.js} +4 -5
  84. package/dist/icons/icon-svgs/element-24.icon.d.ts +8 -0
  85. package/{src/icons/icon-svgs/element-24.icon.ts → dist/icons/icon-svgs/element-24.icon.js} +4 -5
  86. package/dist/icons/icon-svgs/external-link-24.icon.d.ts +8 -0
  87. package/{src/icons/icon-svgs/external-link-24.icon.ts → dist/icons/icon-svgs/external-link-24.icon.js} +4 -5
  88. package/dist/icons/icon-svgs/eye-closed-24.icon.d.ts +8 -0
  89. package/{src/icons/icon-svgs/eye-closed-24.icon.ts → dist/icons/icon-svgs/eye-closed-24.icon.js} +4 -5
  90. package/dist/icons/icon-svgs/eye-open-24.icon.d.ts +8 -0
  91. package/{src/icons/icon-svgs/eye-open-24.icon.ts → dist/icons/icon-svgs/eye-open-24.icon.js} +4 -5
  92. package/dist/icons/icon-svgs/filter-24.icon.d.ts +8 -0
  93. package/{src/icons/icon-svgs/filter-24.icon.ts → dist/icons/icon-svgs/filter-24.icon.js} +4 -5
  94. package/dist/icons/icon-svgs/link-24.icon.d.ts +8 -0
  95. package/{src/icons/icon-svgs/link-24.icon.ts → dist/icons/icon-svgs/link-24.icon.js} +4 -5
  96. package/dist/icons/icon-svgs/loader-24.icon.d.ts +8 -0
  97. package/{src/icons/icon-svgs/loader-24.icon.ts → dist/icons/icon-svgs/loader-24.icon.js} +4 -5
  98. package/dist/icons/icon-svgs/loader-animated-24.icon.d.ts +8 -0
  99. package/{src/icons/icon-svgs/loader-animated-24.icon.ts → dist/icons/icon-svgs/loader-animated-24.icon.js} +6 -8
  100. package/dist/icons/icon-svgs/lock-24.icon.d.ts +8 -0
  101. package/{src/icons/icon-svgs/lock-24.icon.ts → dist/icons/icon-svgs/lock-24.icon.js} +4 -5
  102. package/dist/icons/icon-svgs/options-24.icon.d.ts +8 -0
  103. package/{src/icons/icon-svgs/options-24.icon.ts → dist/icons/icon-svgs/options-24.icon.js} +4 -5
  104. package/dist/icons/icon-svgs/pencil-24.icon.d.ts +8 -0
  105. package/{src/icons/icon-svgs/pencil-24.icon.ts → dist/icons/icon-svgs/pencil-24.icon.js} +4 -5
  106. package/dist/icons/icon-svgs/shield-24.icon.d.ts +8 -0
  107. package/{src/icons/icon-svgs/shield-24.icon.ts → dist/icons/icon-svgs/shield-24.icon.js} +4 -5
  108. package/dist/icons/icon-svgs/sort-ascending-24.icon.d.ts +8 -0
  109. package/{src/icons/icon-svgs/sort-ascending-24.icon.ts → dist/icons/icon-svgs/sort-ascending-24.icon.js} +4 -5
  110. package/dist/icons/icon-svgs/sort-descending-24.icon.d.ts +8 -0
  111. package/{src/icons/icon-svgs/sort-descending-24.icon.ts → dist/icons/icon-svgs/sort-descending-24.icon.js} +4 -5
  112. package/dist/icons/icon-svgs/speaker-loud-24.icon.d.ts +8 -0
  113. package/{src/icons/icon-svgs/speaker-loud-24.icon.ts → dist/icons/icon-svgs/speaker-loud-24.icon.js} +4 -5
  114. package/dist/icons/icon-svgs/speaker-medium-24.icon.d.ts +8 -0
  115. package/{src/icons/icon-svgs/speaker-medium-24.icon.ts → dist/icons/icon-svgs/speaker-medium-24.icon.js} +4 -5
  116. package/dist/icons/icon-svgs/speaker-muted-24.icon.d.ts +8 -0
  117. package/{src/icons/icon-svgs/speaker-muted-24.icon.ts → dist/icons/icon-svgs/speaker-muted-24.icon.js} +4 -5
  118. package/dist/icons/icon-svgs/speaker-quiet-24.icon.d.ts +8 -0
  119. package/{src/icons/icon-svgs/speaker-quiet-24.icon.ts → dist/icons/icon-svgs/speaker-quiet-24.icon.js} +4 -5
  120. package/dist/icons/icon-svgs/star-24.icon.d.ts +8 -0
  121. package/{src/icons/icon-svgs/star-24.icon.ts → dist/icons/icon-svgs/star-24.icon.js} +4 -5
  122. package/dist/icons/icon-svgs/status-failure-24.icon.d.ts +8 -0
  123. package/{src/icons/icon-svgs/status-failure-24.icon.ts → dist/icons/icon-svgs/status-failure-24.icon.js} +4 -5
  124. package/dist/icons/icon-svgs/status-in-progress-24.icon.d.ts +8 -0
  125. package/{src/icons/icon-svgs/status-in-progress-24.icon.ts → dist/icons/icon-svgs/status-in-progress-24.icon.js} +4 -5
  126. package/dist/icons/icon-svgs/status-success-24.icon.d.ts +8 -0
  127. package/{src/icons/icon-svgs/status-success-24.icon.ts → dist/icons/icon-svgs/status-success-24.icon.js} +4 -5
  128. package/dist/icons/icon-svgs/status-unknown-24.icon.d.ts +8 -0
  129. package/{src/icons/icon-svgs/status-unknown-24.icon.ts → dist/icons/icon-svgs/status-unknown-24.icon.js} +4 -5
  130. package/dist/icons/icon-svgs/status-warning-24.icon.d.ts +8 -0
  131. package/{src/icons/icon-svgs/status-warning-24.icon.ts → dist/icons/icon-svgs/status-warning-24.icon.js} +4 -5
  132. package/dist/icons/icon-svgs/upload-24.icon.d.ts +8 -0
  133. package/{src/icons/icon-svgs/upload-24.icon.ts → dist/icons/icon-svgs/upload-24.icon.js} +4 -5
  134. package/dist/icons/icon-svgs/x-24.icon.d.ts +8 -0
  135. package/{src/icons/icon-svgs/x-24.icon.ts → dist/icons/icon-svgs/x-24.icon.js} +4 -5
  136. package/dist/icons/index.d.ts +86 -0
  137. package/{src/icons/index.ts → dist/icons/index.js} +39 -43
  138. package/dist/index.js +4 -0
  139. package/dist/styles/disabled.d.ts +6 -0
  140. package/{src/styles/disabled.ts → dist/styles/disabled.js} +2 -3
  141. package/dist/styles/durations.d.ts +22 -0
  142. package/{src/styles/durations.ts → dist/styles/durations.js} +1 -2
  143. package/dist/styles/focus.d.ts +21 -0
  144. package/dist/styles/focus.js +41 -0
  145. package/dist/styles/font.d.ts +9 -0
  146. package/{src/styles/font.ts → dist/styles/font.js} +1 -2
  147. package/dist/styles/form-styles.d.ts +123 -0
  148. package/dist/styles/form-styles.js +126 -0
  149. package/{src/styles/index.ts → dist/styles/index.d.ts} +0 -2
  150. package/dist/styles/index.js +12 -0
  151. package/dist/styles/native-styles.d.ts +13 -0
  152. package/{src/styles/native-styles.ts → dist/styles/native-styles.js} +3 -6
  153. package/dist/styles/scrollbar.d.ts +6 -0
  154. package/{src/styles/scrollbar.ts → dist/styles/scrollbar.js} +3 -4
  155. package/dist/styles/shadows.d.ts +20 -0
  156. package/{src/styles/shadows.ts → dist/styles/shadows.js} +6 -8
  157. package/dist/styles/user-select.d.ts +6 -0
  158. package/{src/styles/user-select.ts → dist/styles/user-select.js} +2 -3
  159. package/dist/styles/vira-color-palette.d.ts +97 -0
  160. package/dist/styles/vira-color-palette.js +98 -0
  161. package/dist/styles/vira-color-theme.d.ts +1580 -0
  162. package/dist/styles/vira-color-theme.js +1516 -0
  163. package/dist/util/define-table.d.ts +110 -0
  164. package/dist/util/define-table.js +115 -0
  165. package/dist/util/dynamic-element.d.ts +63 -0
  166. package/dist/util/dynamic-element.js +61 -0
  167. package/dist/util/index.js +3 -0
  168. package/dist/util/pop-up-manager.d.ts +186 -0
  169. package/dist/util/pop-up-manager.js +214 -0
  170. package/package.json +6 -6
  171. package/src/elements/define-vira-element.ts +0 -29
  172. package/src/elements/form/vira-form-fields.ts +0 -140
  173. package/src/elements/form/vira-form.element.ts +0 -204
  174. package/src/elements/pop-up/pop-up-helpers.ts +0 -85
  175. package/src/elements/pop-up/vira-menu-trigger.element.ts +0 -158
  176. package/src/elements/shared-text-input-logic.ts +0 -173
  177. package/src/elements/vira-button.element.ts +0 -171
  178. package/src/elements/vira-card.element.ts +0 -54
  179. package/src/elements/vira-overflow-switch.element.ts +0 -137
  180. package/src/icons/icon-color.test-helper.ts +0 -9
  181. package/src/icons/icon-svg.ts +0 -71
  182. package/src/styles/border.ts +0 -11
  183. package/src/styles/focus.ts +0 -76
  184. package/src/styles/form-styles.ts +0 -26
  185. package/src/styles/vira-color-palette.ts +0 -106
  186. package/src/styles/vira-color-theme.ts +0 -1142
  187. package/src/util/define-table.ts +0 -279
  188. package/src/util/dynamic-element.ts +0 -129
  189. package/src/util/pop-up-manager.ts +0 -380
  190. /package/{src/elements/index.ts → dist/elements/index.d.ts} +0 -0
  191. /package/{src/index.ts → dist/index.d.ts} +0 -0
  192. /package/{src/util/index.ts → dist/util/index.d.ts} +0 -0
@@ -1,85 +0,0 @@
1
- import {joinWithFinalConjunction, type PartialWithUndefined} from '@augment-vir/common';
2
- import {
3
- type PopUpManager,
4
- type PopUpManagerOptions,
5
- type ShowPopUpResult,
6
- } from '../../util/pop-up-manager.js';
7
- import {type MenuItem} from './pop-up-menu-item.js';
8
-
9
- /**
10
- * Verifies that all items have unique ids.
11
- *
12
- * @category Internal
13
- */
14
- export function assertUniqueIdProps(items: ReadonlyArray<Readonly<{id: PropertyKey}>>) {
15
- const usedIds = new Set<PropertyKey>();
16
- const duplicateIds: PropertyKey[] = [];
17
- items.forEach((option) => {
18
- if (usedIds.has(option.id)) {
19
- duplicateIds.push(option.id);
20
- } else {
21
- usedIds.add(option.id);
22
- }
23
- });
24
-
25
- if (duplicateIds.length) {
26
- throw new Error(
27
- `Duplicate option ids were given: ${joinWithFinalConjunction(duplicateIds)}`,
28
- );
29
- }
30
- }
31
-
32
- /**
33
- * Creates a new array of selections based on the current selection and new selection id. This
34
- * behaves differently when multi select is enabled, hence this function.
35
- *
36
- * @category Internal
37
- */
38
- export function updateSelectedItems(
39
- /** The item that should be newly toggled. */
40
- newItem: Readonly<MenuItem>,
41
- currentSelection: ReadonlyArray<PropertyKey> = [],
42
- isMultiSelect: boolean = false,
43
- ): PropertyKey[] {
44
- if (isMultiSelect) {
45
- return currentSelection.includes(newItem.id)
46
- ? currentSelection.filter((entry) => entry !== newItem.id)
47
- : [
48
- ...currentSelection,
49
- newItem.id,
50
- ];
51
- } else {
52
- /** In single select, only the toggled item is allowed. */
53
- return [newItem.id];
54
- }
55
- }
56
-
57
- /**
58
- * Handles toggling pop up state for `ViraDropdown`.
59
- *
60
- * @category Internal
61
- */
62
- export function triggerPopUpState({
63
- open,
64
- callback,
65
- popUpManager,
66
- host,
67
- options,
68
- }: Readonly<
69
- {
70
- open: boolean;
71
- popUpManager: PopUpManager;
72
- host: HTMLElement;
73
- } & PartialWithUndefined<{
74
- callback?: ((showPopUpResult: ShowPopUpResult | undefined) => void) | undefined;
75
- options?: Partial<PopUpManagerOptions> | undefined;
76
- }>
77
- >) {
78
- if (open) {
79
- const showPopUpResult = popUpManager.showPopUp(host, options);
80
- callback?.(showPopUpResult);
81
- } else {
82
- popUpManager.removePopUp();
83
- callback?.(undefined);
84
- }
85
- }
@@ -1,158 +0,0 @@
1
- import {type PartialWithUndefined} from '@augment-vir/common';
2
- import {type NavController} from 'device-navigation';
3
- import {classMap, css, defineElementEvent, html, listen, nothing, testId} from 'element-vir';
4
- import {type PopUpManager, type ShowPopUpResult} from '../../util/pop-up-manager.js';
5
- import {defineViraElement} from '../define-vira-element.js';
6
- import {updateSelectedItems} from './pop-up-helpers.js';
7
- import {type MenuItem} from './pop-up-menu-item.js';
8
- import {ViraMenu} from './vira-menu.element.js';
9
- import {
10
- PopUpMenuDirection,
11
- ViraPopUpMenu,
12
- type PopUpMenuCornerStyle,
13
- } from './vira-pop-up-menu.element.js';
14
- import {
15
- HorizontalAnchor,
16
- ViraPopUpTrigger,
17
- type PopUpOffset,
18
- type PopUpTriggerPosition,
19
- } from './vira-pop-up-trigger.element.js';
20
-
21
- /**
22
- * Test ids for {@link ViraMenuTrigger}.
23
- *
24
- * @category Internal
25
- */
26
- export const viraMenuTriggerTestIds = {
27
- menu: 'menu-trigger-menu',
28
- };
29
-
30
- /**
31
- * A more specific wrapper of `ViraPopUpTrigger` that always opens a menu.
32
- *
33
- * @category PopUp
34
- * @category Elements
35
- */
36
- export const ViraMenuTrigger = defineViraElement<
37
- {
38
- items: ReadonlyArray<Readonly<MenuItem>>;
39
- } & PartialWithUndefined<
40
- {
41
- /** The selected item ids from the given `items` object. */
42
- selected: ReadonlyArray<PropertyKey>;
43
- isDisabled: boolean;
44
- isMultiSelect: boolean;
45
- z_debug_forceOpenState: boolean;
46
- popUpOffset: PopUpOffset;
47
- /** Hide menu item check mark icons. */
48
- hideCheckIcons: boolean;
49
- menuCornerStyle: PopUpMenuCornerStyle;
50
- } & PopUpTriggerPosition
51
- >
52
- >()({
53
- tagName: 'vira-menu-trigger',
54
- styles: css`
55
- :host {
56
- display: inline-flex;
57
- box-sizing: border-box;
58
- vertical-align: middle;
59
- max-width: 100%;
60
- }
61
-
62
- ${ViraPopUpTrigger} {
63
- width: 100%;
64
- }
65
-
66
- .full-width-menu {
67
- width: 100%;
68
- }
69
- `,
70
- events: {
71
- itemActivate: defineElementEvent<PropertyKey[]>(),
72
- openChange: defineElementEvent<ShowPopUpResult | undefined>(),
73
- },
74
- state() {
75
- return {
76
- navController: undefined as undefined | NavController,
77
- popUpManager: undefined as undefined | PopUpManager,
78
- /** `undefined` means the pop up is not currently showing. */
79
- showPopUpResult: undefined as ShowPopUpResult | undefined,
80
- };
81
- },
82
- render({inputs, state, updateState, dispatch, events}) {
83
- return html`
84
- <${ViraPopUpTrigger.assign({
85
- ...inputs,
86
- keepOpenAfterInteraction: true,
87
- popUpOffset: inputs.popUpOffset,
88
- horizontalAnchor: inputs.horizontalAnchor || HorizontalAnchor.Left,
89
- })}
90
- class=${classMap({
91
- open: !!state.showPopUpResult,
92
- })}
93
- ${listen(ViraPopUpTrigger.events.init, (event) => {
94
- updateState({
95
- navController: event.detail.navController,
96
- popUpManager: event.detail.popUpManager,
97
- });
98
- })}
99
- ${listen(ViraPopUpTrigger.events.openChange, (event) => {
100
- if (!!state.showPopUpResult !== !!event.detail) {
101
- dispatch(new events.openChange(event.detail));
102
- }
103
- updateState({
104
- showPopUpResult: event.detail,
105
- });
106
- })}
107
- ${listen(ViraPopUpTrigger.events.navSelect, (event) => {
108
- const itemIndex = event.detail.x;
109
- const item = inputs.items[itemIndex];
110
- if (!item) {
111
- throw new Error(`Found no dropdown option at index '${itemIndex}'`);
112
- }
113
-
114
- dispatch(
115
- new events.itemActivate(
116
- updateSelectedItems(item, inputs.selected, inputs.isMultiSelect),
117
- ),
118
- );
119
- if (!inputs.isMultiSelect) {
120
- /**
121
- * Defer pop up removal to prevent race conditions with element-internal
122
- * click handlers.
123
- */
124
- globalThis.setTimeout(() => state.popUpManager?.removePopUp());
125
- }
126
- })}
127
- >
128
- <slot slot=${ViraPopUpTrigger.slotNames.trigger}></slot>
129
- ${state.navController && state.showPopUpResult
130
- ? html`
131
- <${ViraPopUpMenu.assign({
132
- direction: state.showPopUpResult.popDown
133
- ? PopUpMenuDirection.Downwards
134
- : PopUpMenuDirection.Upwards,
135
- cornerStyle: inputs.menuCornerStyle,
136
- })}
137
- slot=${ViraPopUpTrigger.slotNames.popUp}
138
- class=${classMap({
139
- 'full-width-menu':
140
- inputs.horizontalAnchor === HorizontalAnchor.Both,
141
- })}
142
- >
143
- <${ViraMenu.assign({
144
- items: inputs.items,
145
- selected: inputs.selected,
146
- navController: state.navController,
147
- isMultiSelect: !!inputs.isMultiSelect,
148
- hideCheckIcons: inputs.hideCheckIcons,
149
- })}
150
- ${testId(viraMenuTriggerTestIds.menu)}
151
- ></${ViraMenu}>
152
- </${ViraPopUpMenu}>
153
- `
154
- : nothing}
155
- </${ViraPopUpTrigger}>
156
- `;
157
- },
158
- });
@@ -1,173 +0,0 @@
1
- import {check, checkWrap} from '@augment-vir/assert';
2
- import {type PartialWithUndefined} from '@augment-vir/common';
3
- import {extractEventTarget} from '@augment-vir/web';
4
- import {type AttributeValues} from 'element-vir';
5
-
6
- /**
7
- * Inputs shared between the multiple input elements.
8
- *
9
- * @category Internal
10
- */
11
- export type SharedTextInputElementInputs = {
12
- value: string;
13
- } & PartialWithUndefined<{
14
- /** Shown when no other text is present. Input restrictions do not apply to this property. */
15
- placeholder: string;
16
- /** Set to true to trigger disabled styles and to block all user input. */
17
- disabled: boolean;
18
- /**
19
- * Only letters in the given string or matches to the given RegExp will be allowed.
20
- * blockedInputs takes precedence over this input.
21
- *
22
- * For example: if allowedInputs is set to "abcd" and blockedInputs is set to "d", only "a",
23
- * "b", or "c" letters will be allowed.
24
- */
25
- allowedInputs: string | RegExp;
26
- /** Any letters in the given string or matches to the given RegExp will be blocked. */
27
- blockedInputs: string | RegExp;
28
- /** Disable all browser helps like spellchecking, autocomplete, etc. */
29
- disableBrowserHelps: boolean;
30
- /** Set this to true to make the whole element size to only fit the input text. */
31
- fitText: boolean;
32
- /** A set of attributes that will be applied to the inner native text element. */
33
- attributePassthrough: AttributeValues;
34
- }>;
35
-
36
- function doesMatch({input, matcher}: {input: string; matcher: string | RegExp}): boolean {
37
- if (!input || !matcher) {
38
- return true;
39
- }
40
- if (input.length > 1) {
41
- return input.split('').every((singleInput) => doesMatch({input: singleInput, matcher}));
42
- }
43
-
44
- if (matcher instanceof RegExp) {
45
- return !!input.match(matcher);
46
- } else {
47
- return matcher.includes(input);
48
- }
49
- }
50
-
51
- /**
52
- * Inputs used to check if the current input element value is allowed.
53
- *
54
- * @category Internal
55
- */
56
- export type IsAllowedInputs = {
57
- value: string;
58
- allowed: string | RegExp | undefined;
59
- blocked: string | RegExp | undefined;
60
- };
61
-
62
- function isAllowed({value, allowed, blocked}: IsAllowedInputs) {
63
- const isAllowedCharacter = allowed
64
- ? doesMatch({
65
- input: value,
66
- matcher: allowed,
67
- })
68
- : true;
69
- const isBlockedCharacter = blocked
70
- ? doesMatch({
71
- input: value,
72
- matcher: blocked,
73
- })
74
- : false;
75
-
76
- return isAllowedCharacter && !isBlockedCharacter;
77
- }
78
-
79
- /**
80
- * Filters out blocked text from an input element's value.
81
- *
82
- * @category Internal
83
- */
84
- export function filterTextInputValue(inputs: IsAllowedInputs): {
85
- filtered: string;
86
- blocked: string;
87
- } {
88
- if (!inputs.value) {
89
- return {filtered: inputs.value, blocked: ''};
90
- }
91
- const {filtered, blocked} = inputs.value.split('').reduce(
92
- (accum, letter) => {
93
- const allowed = isAllowed({...inputs, value: letter});
94
-
95
- if (allowed) {
96
- accum.filtered.push(letter);
97
- } else {
98
- accum.blocked.push(letter);
99
- }
100
- return accum;
101
- },
102
- {
103
- filtered: [] as string[],
104
- blocked: [] as string[],
105
- },
106
- );
107
-
108
- return {
109
- filtered: filtered.join(''),
110
- blocked: blocked.join(''),
111
- };
112
- }
113
-
114
- /**
115
- * A function to be called when an input element's value changes.
116
- *
117
- * @category Internal
118
- */
119
- export function textInputListener({
120
- inputs,
121
- previousValue,
122
- event,
123
- inputBlockedCallback,
124
- newValueCallback,
125
- }: {
126
- inputs: SharedTextInputElementInputs;
127
- /** The value of the input element before this listener fired. */
128
- previousValue: string;
129
- event: Event;
130
- inputBlockedCallback: (blockedInput: string) => void;
131
- newValueCallback: (newValue: string) => void;
132
- }) {
133
- const inputElement = extractEventTarget(event, HTMLInputElement);
134
- /**
135
- * This is usually a single character, but can be a bunch of characters in some circumstances.
136
- * For example, when a bunch of characters are pasted, this will be the entire pasted contents.
137
- *
138
- * When a password manager auto fills the password, at least for Safari + iCloud Keychain, it'll
139
- * fire a `CustomEvent` (rather than the typical `InputEvent`) and `event.data` won't be
140
- * populated.
141
- */
142
- const changedText: string =
143
- (check.hasKey(event, 'data') && checkWrap.isString(event.data)) || '';
144
-
145
- /**
146
- * When changedText is falsy, that means an operation other than inserting characters happened.
147
- * Such as: deleting, cutting the text, etc.
148
- */
149
- if (changedText) {
150
- const {blocked} = filterTextInputValue({
151
- value: changedText,
152
- allowed: inputs.allowedInputs,
153
- blocked: inputs.blockedInputs,
154
- });
155
- if (blocked.length) {
156
- inputBlockedCallback(blocked);
157
- }
158
- }
159
-
160
- const finalValue = filterTextInputValue({
161
- value: inputElement.value,
162
- allowed: inputs.allowedInputs,
163
- blocked: inputs.blockedInputs,
164
- }).filtered;
165
-
166
- if (inputElement.value !== finalValue) {
167
- // this prevents blocked inputs by simply overwriting them
168
- inputElement.value = finalValue;
169
- }
170
- if (previousValue !== finalValue) {
171
- newValueCallback(finalValue);
172
- }
173
- }
@@ -1,171 +0,0 @@
1
- import {type PartialWithUndefined} from '@augment-vir/common';
2
- import {css, html, nothing} from 'element-vir';
3
- import {type ViraIconSvg} from '../icons/index.js';
4
- import {viraBorders} from '../styles/border.js';
5
- import {viraDisabledStyles} from '../styles/disabled.js';
6
- import {viraAnimationDurations} from '../styles/durations.js';
7
- import {createFocusStyles, viraFocusCssVars} from '../styles/focus.js';
8
- import {noUserSelect} from '../styles/index.js';
9
- import {noNativeFormStyles} from '../styles/native-styles.js';
10
- import {defineViraElement} from './define-vira-element.js';
11
- import {ViraIcon} from './vira-icon.element.js';
12
-
13
- /**
14
- * Button styles available for {@link ViraButton}.
15
- *
16
- * @category Button
17
- */
18
- export enum ViraButtonStyle {
19
- Default = 'vira-button-default',
20
- Outline = 'vira-button-outline',
21
- }
22
-
23
- /**
24
- * A custom button with default styling.
25
- *
26
- * @category Button
27
- * @category Elements
28
- * @see https://electrovir.github.io/vira/book/elements/vira-button
29
- */
30
- export const ViraButton = defineViraElement<
31
- PartialWithUndefined<{
32
- text: string;
33
- icon: Pick<ViraIconSvg, 'svgTemplate'>;
34
- disabled: boolean;
35
- buttonStyle: ViraButtonStyle;
36
- /**
37
- * When set to `true`, the given icon (if any) will take up its full dimensions, potentially
38
- * increasing the button's size.
39
- *
40
- * @default false
41
- */
42
- expandToFitIcon: boolean;
43
- }>
44
- >()({
45
- tagName: 'vira-button',
46
- hostClasses: {
47
- 'vira-button-outline-style': ({inputs}) => inputs.buttonStyle === ViraButtonStyle.Outline,
48
- 'vira-button-disabled': ({inputs}) => !!inputs.disabled,
49
- 'vira-button-expand-to-fit-icon': ({inputs}) => !!inputs.expandToFitIcon,
50
- },
51
- cssVars: {
52
- /** On the default button style this is the background color. */
53
- 'vira-button-primary-color': '#0a89ff',
54
- 'vira-button-primary-hover-color': '#59b1ff',
55
- 'vira-button-primary-active-color': '#007ff6',
56
-
57
- /** On the default button style this is the text color. */
58
- 'vira-button-secondary-color': '#ffffff',
59
-
60
- 'vira-button-padding': '5px 10px',
61
-
62
- 'vira-button-internal-foreground-color': '',
63
- 'vira-button-internal-background-color': '',
64
- },
65
- styles: ({hostClasses, cssVars}) => css`
66
- :host {
67
- font-weight: bold;
68
- display: inline-flex;
69
- position: relative;
70
- vertical-align: middle;
71
- align-items: center;
72
- box-sizing: border-box;
73
- ${noUserSelect};
74
- ${cssVars['vira-button-internal-background-color'].name}: ${cssVars[
75
- 'vira-button-primary-color'
76
- ].value};
77
- ${cssVars['vira-button-internal-foreground-color'].name}: ${cssVars[
78
- 'vira-button-secondary-color'
79
- ].value};
80
- ${viraFocusCssVars['vira-focus-outline-color'].name}: ${cssVars[
81
- 'vira-button-primary-hover-color'
82
- ].value}
83
- }
84
-
85
- :host(:hover) button,
86
- button:hover {
87
- ${cssVars['vira-button-internal-background-color'].name}: ${cssVars[
88
- 'vira-button-primary-hover-color'
89
- ].value};
90
- }
91
-
92
- :host(:active) button,
93
- button:active {
94
- ${cssVars['vira-button-internal-background-color'].name}: ${cssVars[
95
- 'vira-button-primary-active-color'
96
- ].value};
97
- }
98
-
99
- ${hostClasses['vira-button-disabled'].selector} {
100
- ${viraDisabledStyles};
101
- }
102
-
103
- ${hostClasses['vira-button-outline-style'].selector} button {
104
- color: ${cssVars['vira-button-internal-background-color'].value};
105
- background-color: transparent;
106
- border-color: currentColor;
107
- }
108
-
109
- button {
110
- ${noNativeFormStyles};
111
- cursor: pointer;
112
- position: relative;
113
- width: 100%;
114
- height: 100%;
115
- border: 2px solid transparent;
116
- box-sizing: border-box;
117
- display: inline-flex;
118
- justify-content: center;
119
- align-items: center;
120
- border-radius: ${viraBorders['vira-form-input-radius'].value};
121
- background-color: ${cssVars['vira-button-internal-background-color'].value};
122
- color: ${cssVars['vira-button-internal-foreground-color'].value};
123
- padding: ${cssVars['vira-button-padding'].value};
124
- transition:
125
- color ${viraAnimationDurations['vira-interaction-animation-duration'].value},
126
- background-color
127
- ${viraAnimationDurations['vira-interaction-animation-duration'].value},
128
- border-color ${viraAnimationDurations['vira-interaction-animation-duration'].value};
129
-
130
- ${createFocusStyles({
131
- elementBorderSize: 2,
132
- })}
133
- }
134
-
135
- .empty-text {
136
- width: 0;
137
- }
138
-
139
- button ${ViraIcon} + .text-template {
140
- margin-left: 8px;
141
- }
142
-
143
- :host(:not(.${hostClasses['vira-button-expand-to-fit-icon'].name})) {
144
- & ${ViraIcon} {
145
- height: 0;
146
- display: flex;
147
- align-items: center;
148
- }
149
- }
150
- `,
151
- render: ({inputs}) => {
152
- const iconTemplate = inputs.icon
153
- ? html`
154
- <${ViraIcon.assign({
155
- icon: inputs.icon,
156
- })}></${ViraIcon}>
157
- `
158
- : nothing;
159
- const textTemplate = inputs.text
160
- ? html`
161
- <span class="text-template">${inputs.text}</span>
162
- `
163
- : html`
164
- <span class="empty-text">&nbsp;</span>
165
- `;
166
-
167
- return html`
168
- <button ?disabled=${inputs.disabled}>${iconTemplate} ${textTemplate}</button>
169
- `;
170
- },
171
- });
@@ -1,54 +0,0 @@
1
- import {css, html} from 'element-vir';
2
- import {viraFormCssVars} from '../styles/form-styles.js';
3
- import {defineViraElement} from './define-vira-element.js';
4
-
5
- /**
6
- * State options for {@link ViraCard}.
7
- *
8
- * @category Internal
9
- */
10
- export enum ViraCardState {
11
- Error = 'error',
12
- Success = 'success',
13
- }
14
-
15
- /**
16
- * A simple wrapper "card" element that is just a `<slot>` with some styles.
17
- *
18
- * @category Elements
19
- * @see https://electrovir.github.io/vira/book/elements/vira-card
20
- */
21
- export const ViraCard = defineViraElement<{
22
- cardState?: ViraCardState | undefined;
23
- }>()({
24
- tagName: 'vira-card',
25
- hostClasses: {
26
- 'vira-card-error': ({inputs}) => inputs.cardState === ViraCardState.Error,
27
- 'vira-card-success': ({inputs}) => inputs.cardState === ViraCardState.Success,
28
- },
29
- cssVars: {
30
- 'vira-card-border': '1px solid #d3d3d3',
31
- 'vira-card-border-radius': '16px',
32
- 'vira-card-padding': '16px',
33
- },
34
- styles: ({hostClasses, cssVars}) => css`
35
- :host {
36
- display: block;
37
- border: ${cssVars['vira-card-border'].value};
38
- border-radius: ${cssVars['vira-card-border-radius'].value};
39
- padding: ${cssVars['vira-card-padding'].value};
40
- }
41
-
42
- ${hostClasses['vira-card-error'].selector} {
43
- border-color: ${viraFormCssVars['vira-form-error-foreground-color'].value};
44
- }
45
- ${hostClasses['vira-card-success'].selector} {
46
- border-color: ${viraFormCssVars['vira-form-success-foreground-color'].value};
47
- }
48
- `,
49
- render() {
50
- return html`
51
- <slot></slot>
52
- `;
53
- },
54
- });