vira 28.19.5 → 28.19.6

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 (188) hide show
  1. package/package.json +12 -12
  2. package/src/elements/define-vira-element.ts +29 -0
  3. package/src/elements/form/vira-form-fields.ts +140 -0
  4. package/src/elements/form/vira-form.element.ts +204 -0
  5. package/src/elements/pop-up/pop-up-helpers.ts +85 -0
  6. package/{dist/elements/pop-up/pop-up-menu-item.d.ts → src/elements/pop-up/pop-up-menu-item.ts} +4 -3
  7. package/{dist/elements/pop-up/vira-menu-item.element.js → src/elements/pop-up/vira-menu-item.element.ts} +28 -11
  8. package/src/elements/pop-up/vira-menu-trigger.element.ts +158 -0
  9. package/{dist/elements/pop-up/vira-menu.element.js → src/elements/pop-up/vira-menu.element.ts} +76 -49
  10. package/{dist/elements/pop-up/vira-pop-up-menu.element.js → src/elements/pop-up/vira-pop-up-menu.element.ts} +34 -22
  11. package/{dist/elements/pop-up/vira-pop-up-trigger.element.js → src/elements/pop-up/vira-pop-up-trigger.element.ts} +199 -104
  12. package/src/elements/shared-text-input-logic.ts +173 -0
  13. package/{dist/elements/vira-bold-text.element.js → src/elements/vira-bold-text.element.ts} +8 -7
  14. package/{dist/elements/vira-button.element.js → src/elements/vira-button.element.ts} +64 -33
  15. package/{dist/elements/vira-card.element.js → src/elements/vira-card.element.ts} +16 -13
  16. package/{dist/elements/vira-checkbox.element.js → src/elements/vira-checkbox.element.ts} +71 -28
  17. package/{dist/elements/vira-collapsible-wrapper.element.js → src/elements/vira-collapsible-wrapper.element.ts} +18 -16
  18. package/{dist/elements/vira-dropdown.element.js → src/elements/vira-dropdown.element.ts} +94 -48
  19. package/{dist/elements/vira-error.element.js → src/elements/vira-error.element.ts} +6 -5
  20. package/{dist/elements/vira-icon.element.js → src/elements/vira-icon.element.ts} +13 -6
  21. package/{dist/elements/vira-image.element.js → src/elements/vira-image.element.ts} +63 -43
  22. package/{dist/elements/vira-input.element.js → src/elements/vira-input.element.ts} +151 -85
  23. package/{dist/elements/vira-link.element.js → src/elements/vira-link.element.ts} +62 -11
  24. package/{dist/elements/vira-modal.element.js → src/elements/vira-modal.element.ts} +89 -50
  25. package/src/elements/vira-overflow-switch.element.ts +137 -0
  26. package/{dist/elements/vira-progress.element.js → src/elements/vira-progress.element.ts} +26 -11
  27. package/{dist/elements/vira-select.element.js → src/elements/vira-select.element.ts} +96 -41
  28. package/src/icons/icon-color.test-helper.ts +9 -0
  29. package/{dist/icons/icon-css-vars.js → src/icons/icon-css-vars.ts} +2 -1
  30. package/src/icons/icon-svg.ts +71 -0
  31. package/{dist/icons/icon-svgs/bell-24.icon.js → src/icons/icon-svgs/bell-24.icon.ts} +5 -4
  32. package/{dist/icons/icon-svgs/chat-24.icon.js → src/icons/icon-svgs/chat-24.icon.ts} +5 -4
  33. package/{dist/icons/icon-svgs/check-24.icon.js → src/icons/icon-svgs/check-24.icon.ts} +5 -4
  34. package/{dist/icons/icon-svgs/chevron-down-24.icon.js → src/icons/icon-svgs/chevron-down-24.icon.ts} +5 -4
  35. package/{dist/icons/icon-svgs/chevron-up-24.icon.js → src/icons/icon-svgs/chevron-up-24.icon.ts} +5 -4
  36. package/{dist/icons/icon-svgs/close-x-24.icon.js → src/icons/icon-svgs/close-x-24.icon.ts} +5 -4
  37. package/{dist/icons/icon-svgs/commit-24.icon.js → src/icons/icon-svgs/commit-24.icon.ts} +5 -4
  38. package/{dist/icons/icon-svgs/copy-24.icon.js → src/icons/icon-svgs/copy-24.icon.ts} +5 -4
  39. package/{dist/icons/icon-svgs/document-24.icon.js → src/icons/icon-svgs/document-24.icon.ts} +5 -4
  40. package/{dist/icons/icon-svgs/document-search-24.icon.js → src/icons/icon-svgs/document-search-24.icon.ts} +5 -4
  41. package/{dist/icons/icon-svgs/double-chevron-24.icon.js → src/icons/icon-svgs/double-chevron-24.icon.ts} +5 -4
  42. package/{dist/icons/icon-svgs/element-16.icon.js → src/icons/icon-svgs/element-16.icon.ts} +5 -4
  43. package/{dist/icons/icon-svgs/element-24.icon.js → src/icons/icon-svgs/element-24.icon.ts} +5 -4
  44. package/{dist/icons/icon-svgs/external-link-24.icon.js → src/icons/icon-svgs/external-link-24.icon.ts} +5 -4
  45. package/{dist/icons/icon-svgs/eye-closed-24.icon.js → src/icons/icon-svgs/eye-closed-24.icon.ts} +5 -4
  46. package/{dist/icons/icon-svgs/eye-open-24.icon.js → src/icons/icon-svgs/eye-open-24.icon.ts} +5 -4
  47. package/{dist/icons/icon-svgs/filter-24.icon.js → src/icons/icon-svgs/filter-24.icon.ts} +5 -4
  48. package/{dist/icons/icon-svgs/link-24.icon.js → src/icons/icon-svgs/link-24.icon.ts} +5 -4
  49. package/{dist/icons/icon-svgs/loader-24.icon.js → src/icons/icon-svgs/loader-24.icon.ts} +5 -4
  50. package/{dist/icons/icon-svgs/loader-animated-24.icon.js → src/icons/icon-svgs/loader-animated-24.icon.ts} +8 -6
  51. package/{dist/icons/icon-svgs/lock-24.icon.js → src/icons/icon-svgs/lock-24.icon.ts} +5 -4
  52. package/{dist/icons/icon-svgs/options-24.icon.js → src/icons/icon-svgs/options-24.icon.ts} +5 -4
  53. package/{dist/icons/icon-svgs/pencil-24.icon.js → src/icons/icon-svgs/pencil-24.icon.ts} +5 -4
  54. package/{dist/icons/icon-svgs/shield-24.icon.js → src/icons/icon-svgs/shield-24.icon.ts} +5 -4
  55. package/{dist/icons/icon-svgs/sort-ascending-24.icon.js → src/icons/icon-svgs/sort-ascending-24.icon.ts} +5 -4
  56. package/{dist/icons/icon-svgs/sort-descending-24.icon.js → src/icons/icon-svgs/sort-descending-24.icon.ts} +5 -4
  57. package/{dist/icons/icon-svgs/speaker-loud-24.icon.js → src/icons/icon-svgs/speaker-loud-24.icon.ts} +5 -4
  58. package/{dist/icons/icon-svgs/speaker-medium-24.icon.js → src/icons/icon-svgs/speaker-medium-24.icon.ts} +5 -4
  59. package/{dist/icons/icon-svgs/speaker-muted-24.icon.js → src/icons/icon-svgs/speaker-muted-24.icon.ts} +5 -4
  60. package/{dist/icons/icon-svgs/speaker-quiet-24.icon.js → src/icons/icon-svgs/speaker-quiet-24.icon.ts} +5 -4
  61. package/{dist/icons/icon-svgs/star-24.icon.js → src/icons/icon-svgs/star-24.icon.ts} +5 -4
  62. package/{dist/icons/icon-svgs/status-failure-24.icon.js → src/icons/icon-svgs/status-failure-24.icon.ts} +5 -4
  63. package/{dist/icons/icon-svgs/status-in-progress-24.icon.js → src/icons/icon-svgs/status-in-progress-24.icon.ts} +5 -4
  64. package/{dist/icons/icon-svgs/status-success-24.icon.js → src/icons/icon-svgs/status-success-24.icon.ts} +5 -4
  65. package/{dist/icons/icon-svgs/status-unknown-24.icon.js → src/icons/icon-svgs/status-unknown-24.icon.ts} +5 -4
  66. package/{dist/icons/icon-svgs/status-warning-24.icon.js → src/icons/icon-svgs/status-warning-24.icon.ts} +5 -4
  67. package/{dist/icons/icon-svgs/upload-24.icon.js → src/icons/icon-svgs/upload-24.icon.ts} +5 -4
  68. package/{dist/icons/icon-svgs/x-24.icon.js → src/icons/icon-svgs/x-24.icon.ts} +5 -4
  69. package/{dist/icons/index.js → src/icons/index.ts} +43 -39
  70. package/{dist/styles/border.js → src/styles/border.ts} +2 -1
  71. package/{dist/styles/disabled.js → src/styles/disabled.ts} +3 -2
  72. package/{dist/styles/durations.js → src/styles/durations.ts} +2 -1
  73. package/{dist/styles/focus.js → src/styles/focus.ts} +32 -8
  74. package/{dist/styles/font.js → src/styles/font.ts} +2 -1
  75. package/{dist/styles/form-styles.js → src/styles/form-styles.ts} +6 -1
  76. package/{dist/styles/index.js → src/styles/index.ts} +1 -0
  77. package/{dist/styles/native-styles.js → src/styles/native-styles.ts} +5 -3
  78. package/{dist/styles/scrollbar.js → src/styles/scrollbar.ts} +4 -3
  79. package/{dist/styles/shadows.js → src/styles/shadows.ts} +8 -6
  80. package/{dist/styles/user-select.js → src/styles/user-select.ts} +3 -2
  81. package/{dist/styles/vira-color-palette.js → src/styles/vira-color-palette.ts} +11 -1
  82. package/src/styles/vira-color-theme.ts +1142 -0
  83. package/src/util/define-table.ts +279 -0
  84. package/src/util/dynamic-element.ts +129 -0
  85. package/src/util/pop-up-manager.ts +380 -0
  86. package/dist/elements/define-vira-element.d.ts +0 -18
  87. package/dist/elements/define-vira-element.js +0 -19
  88. package/dist/elements/form/vira-form-fields.d.ts +0 -100
  89. package/dist/elements/form/vira-form-fields.js +0 -60
  90. package/dist/elements/form/vira-form.element.d.ts +0 -35
  91. package/dist/elements/form/vira-form.element.js +0 -151
  92. package/dist/elements/index.js +0 -25
  93. package/dist/elements/pop-up/pop-up-helpers.d.ts +0 -33
  94. package/dist/elements/pop-up/pop-up-helpers.js +0 -58
  95. package/dist/elements/pop-up/pop-up-menu-item.js +0 -1
  96. package/dist/elements/pop-up/vira-menu-item.element.d.ts +0 -19
  97. package/dist/elements/pop-up/vira-menu-trigger.element.d.ts +0 -41
  98. package/dist/elements/pop-up/vira-menu-trigger.element.js +0 -121
  99. package/dist/elements/pop-up/vira-menu.element.d.ts +0 -38
  100. package/dist/elements/pop-up/vira-pop-up-menu.element.d.ts +0 -35
  101. package/dist/elements/pop-up/vira-pop-up-trigger.element.d.ts +0 -105
  102. package/dist/elements/shared-text-input-logic.d.ts +0 -63
  103. package/dist/elements/shared-text-input-logic.js +0 -101
  104. package/dist/elements/vira-bold-text.element.d.ts +0 -9
  105. package/dist/elements/vira-button.element.d.ts +0 -31
  106. package/dist/elements/vira-card.element.d.ts +0 -18
  107. package/dist/elements/vira-checkbox.element.d.ts +0 -34
  108. package/dist/elements/vira-collapsible-wrapper.element.d.ts +0 -14
  109. package/dist/elements/vira-dropdown.element.d.ts +0 -46
  110. package/dist/elements/vira-error.element.d.ts +0 -7
  111. package/dist/elements/vira-icon.element.d.ts +0 -13
  112. package/dist/elements/vira-image.element.d.ts +0 -45
  113. package/dist/elements/vira-input.element.d.ts +0 -62
  114. package/dist/elements/vira-link.element.d.ts +0 -73
  115. package/dist/elements/vira-modal.element.d.ts +0 -39
  116. package/dist/elements/vira-overflow-switch.element.d.ts +0 -21
  117. package/dist/elements/vira-overflow-switch.element.js +0 -110
  118. package/dist/elements/vira-progress.element.d.ts +0 -18
  119. package/dist/elements/vira-select.element.d.ts +0 -48
  120. package/dist/icons/icon-color.test-helper.d.ts +0 -6
  121. package/dist/icons/icon-color.test-helper.js +0 -9
  122. package/dist/icons/icon-css-vars.d.ts +0 -14
  123. package/dist/icons/icon-svg.d.ts +0 -27
  124. package/dist/icons/icon-svg.js +0 -48
  125. package/dist/icons/icon-svgs/bell-24.icon.d.ts +0 -8
  126. package/dist/icons/icon-svgs/chat-24.icon.d.ts +0 -8
  127. package/dist/icons/icon-svgs/check-24.icon.d.ts +0 -8
  128. package/dist/icons/icon-svgs/chevron-down-24.icon.d.ts +0 -8
  129. package/dist/icons/icon-svgs/chevron-up-24.icon.d.ts +0 -8
  130. package/dist/icons/icon-svgs/close-x-24.icon.d.ts +0 -8
  131. package/dist/icons/icon-svgs/commit-24.icon.d.ts +0 -8
  132. package/dist/icons/icon-svgs/copy-24.icon.d.ts +0 -8
  133. package/dist/icons/icon-svgs/document-24.icon.d.ts +0 -8
  134. package/dist/icons/icon-svgs/document-search-24.icon.d.ts +0 -8
  135. package/dist/icons/icon-svgs/double-chevron-24.icon.d.ts +0 -8
  136. package/dist/icons/icon-svgs/element-16.icon.d.ts +0 -8
  137. package/dist/icons/icon-svgs/element-24.icon.d.ts +0 -8
  138. package/dist/icons/icon-svgs/external-link-24.icon.d.ts +0 -8
  139. package/dist/icons/icon-svgs/eye-closed-24.icon.d.ts +0 -8
  140. package/dist/icons/icon-svgs/eye-open-24.icon.d.ts +0 -8
  141. package/dist/icons/icon-svgs/filter-24.icon.d.ts +0 -8
  142. package/dist/icons/icon-svgs/link-24.icon.d.ts +0 -8
  143. package/dist/icons/icon-svgs/loader-24.icon.d.ts +0 -8
  144. package/dist/icons/icon-svgs/loader-animated-24.icon.d.ts +0 -8
  145. package/dist/icons/icon-svgs/lock-24.icon.d.ts +0 -8
  146. package/dist/icons/icon-svgs/options-24.icon.d.ts +0 -8
  147. package/dist/icons/icon-svgs/pencil-24.icon.d.ts +0 -8
  148. package/dist/icons/icon-svgs/shield-24.icon.d.ts +0 -8
  149. package/dist/icons/icon-svgs/sort-ascending-24.icon.d.ts +0 -8
  150. package/dist/icons/icon-svgs/sort-descending-24.icon.d.ts +0 -8
  151. package/dist/icons/icon-svgs/speaker-loud-24.icon.d.ts +0 -8
  152. package/dist/icons/icon-svgs/speaker-medium-24.icon.d.ts +0 -8
  153. package/dist/icons/icon-svgs/speaker-muted-24.icon.d.ts +0 -8
  154. package/dist/icons/icon-svgs/speaker-quiet-24.icon.d.ts +0 -8
  155. package/dist/icons/icon-svgs/star-24.icon.d.ts +0 -8
  156. package/dist/icons/icon-svgs/status-failure-24.icon.d.ts +0 -8
  157. package/dist/icons/icon-svgs/status-in-progress-24.icon.d.ts +0 -8
  158. package/dist/icons/icon-svgs/status-success-24.icon.d.ts +0 -8
  159. package/dist/icons/icon-svgs/status-unknown-24.icon.d.ts +0 -8
  160. package/dist/icons/icon-svgs/status-warning-24.icon.d.ts +0 -8
  161. package/dist/icons/icon-svgs/upload-24.icon.d.ts +0 -8
  162. package/dist/icons/icon-svgs/x-24.icon.d.ts +0 -8
  163. package/dist/icons/index.d.ts +0 -86
  164. package/dist/index.js +0 -4
  165. package/dist/styles/border.d.ts +0 -9
  166. package/dist/styles/disabled.d.ts +0 -6
  167. package/dist/styles/durations.d.ts +0 -22
  168. package/dist/styles/focus.d.ts +0 -31
  169. package/dist/styles/font.d.ts +0 -9
  170. package/dist/styles/form-styles.d.ts +0 -20
  171. package/dist/styles/index.d.ts +0 -13
  172. package/dist/styles/native-styles.d.ts +0 -13
  173. package/dist/styles/scrollbar.d.ts +0 -6
  174. package/dist/styles/shadows.d.ts +0 -20
  175. package/dist/styles/user-select.d.ts +0 -6
  176. package/dist/styles/vira-color-palette.d.ts +0 -95
  177. package/dist/styles/vira-color-theme.d.ts +0 -1184
  178. package/dist/styles/vira-color-theme.js +0 -1137
  179. package/dist/util/define-table.d.ts +0 -110
  180. package/dist/util/define-table.js +0 -115
  181. package/dist/util/dynamic-element.d.ts +0 -63
  182. package/dist/util/dynamic-element.js +0 -61
  183. package/dist/util/index.js +0 -3
  184. package/dist/util/pop-up-manager.d.ts +0 -186
  185. package/dist/util/pop-up-manager.js +0 -214
  186. /package/{dist/elements/index.d.ts → src/elements/index.ts} +0 -0
  187. /package/{dist/index.d.ts → src/index.ts} +0 -0
  188. /package/{dist/util/index.d.ts → src/util/index.ts} +0 -0
@@ -1,14 +1,41 @@
1
- import { randomString } from '@augment-vir/common';
2
- import { extractEventTarget } from '@augment-vir/web';
3
- import { attributes, classMap, css, defineElementEvent, html, ifDefined, listen, nothing, } from 'element-vir';
4
- import { ChevronUp24Icon } from '../icons/index.js';
5
- import { viraDisabledStyles } from '../styles/disabled.js';
6
- import { createFocusStyles } from '../styles/focus.js';
7
- import { viraFormCssVars } from '../styles/form-styles.js';
8
- import { viraAnimationDurations, viraBorders } 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';
1
+ import {randomString, type PartialWithUndefined} from '@augment-vir/common';
2
+ import {extractEventTarget} from '@augment-vir/web';
3
+ import {
4
+ attributes,
5
+ classMap,
6
+ css,
7
+ defineElementEvent,
8
+ html,
9
+ ifDefined,
10
+ listen,
11
+ nothing,
12
+ type AttributeValues,
13
+ } from 'element-vir';
14
+ import {ChevronUp24Icon, type ViraIconSvg} from '../icons/index.js';
15
+ import {viraDisabledStyles} from '../styles/disabled.js';
16
+ import {createFocusStyles} from '../styles/focus.js';
17
+ import {viraFormCssVars} from '../styles/form-styles.js';
18
+ import {viraAnimationDurations, viraBorders} from '../styles/index.js';
19
+ import {noNativeFormStyles} from '../styles/native-styles.js';
20
+ import {defineViraElement} from './define-vira-element.js';
21
+ import {ViraDropdown} from './vira-dropdown.element.js';
22
+ import {ViraIcon} from './vira-icon.element.js';
23
+
24
+ /**
25
+ * Options for {@link ViraSelect}.
26
+ *
27
+ * @category Dropdown
28
+ * @category Elements
29
+ * @see https://electrovir.github.io/vira/book/elements/vira-select
30
+ */
31
+ export type ViraSelectOption = {
32
+ /** A value or id, used to keep track of which option is selected. */
33
+ value: string;
34
+ label: string;
35
+ } & PartialWithUndefined<{
36
+ disabled: boolean;
37
+ }>;
38
+
12
39
  /**
13
40
  * Similar to {@link ViraDropdown} but is, instead, simply a wrapper for `<select>` and nothing more.
14
41
  *
@@ -16,7 +43,28 @@ import { ViraIcon } from './vira-icon.element.js';
16
43
  * @category Elements
17
44
  * @see https://electrovir.github.io/vira/book/elements/vira-select
18
45
  */
19
- export const ViraSelect = defineViraElement()({
46
+ export const ViraSelect = defineViraElement<
47
+ Readonly<
48
+ {
49
+ options: ReadonlyArray<Readonly<ViraSelectOption>>;
50
+ /** The currently selected option value. */
51
+ value: undefined | string;
52
+ } & PartialWithUndefined<{
53
+ icon: Readonly<ViraIconSvg>;
54
+ placeholder: string;
55
+ label: string;
56
+ disabled: boolean;
57
+ attributePassthrough: Readonly<
58
+ PartialWithUndefined<{
59
+ label: AttributeValues;
60
+ select: AttributeValues;
61
+ option: AttributeValues;
62
+ }>
63
+ >;
64
+ hasError: boolean;
65
+ }>
66
+ >
67
+ >()({
20
68
  tagName: 'vira-select',
21
69
  state() {
22
70
  return {
@@ -28,7 +76,7 @@ export const ViraSelect = defineViraElement()({
28
76
  };
29
77
  },
30
78
  events: {
31
- valueChange: defineElementEvent(),
79
+ valueChange: defineElementEvent<string>(),
32
80
  },
33
81
  cssVars: {
34
82
  'vira-select-padding-horizontal': '10px',
@@ -36,10 +84,10 @@ export const ViraSelect = defineViraElement()({
36
84
  'vira-select-icon-padding': '44px',
37
85
  },
38
86
  hostClasses: {
39
- 'vira-select-disabled': ({ inputs }) => !!inputs.disabled,
40
- 'vira-select-error': ({ inputs }) => !!inputs.hasError,
87
+ 'vira-select-disabled': ({inputs}) => !!inputs.disabled,
88
+ 'vira-select-error': ({inputs}) => !!inputs.hasError,
41
89
  },
42
- styles: ({ hostClasses, cssVars }) => css `
90
+ styles: ({hostClasses, cssVars}) => css`
43
91
  :host {
44
92
  position: relative;
45
93
  display: inline-flex;
@@ -84,9 +132,9 @@ export const ViraSelect = defineViraElement()({
84
132
 
85
133
  &:focus:focus-visible:not([aria-disabled='true']) ~ .focus-border {
86
134
  ${createFocusStyles({
87
- elementBorderSize: 0,
88
- noNesting: true,
89
- })}
135
+ elementBorderSize: 0,
136
+ noNesting: true,
137
+ })}
90
138
  }
91
139
 
92
140
  &.placeholder {
@@ -169,40 +217,47 @@ export const ViraSelect = defineViraElement()({
169
217
  }
170
218
  }
171
219
  `,
172
- render({ inputs, state, dispatch, events }) {
220
+ render({inputs, state, dispatch, events}) {
173
221
  const value = inputs.value || undefined;
174
- const placeholderOptionTemplate = inputs.placeholder || value == undefined
175
- ? html `
222
+
223
+ const placeholderOptionTemplate =
224
+ inputs.placeholder || value == undefined
225
+ ? html`
176
226
  <option value="" disabled ?selected=${value == undefined}>
177
227
  ${inputs.placeholder}
178
228
  </option>
179
229
  `
180
- : nothing;
181
- const selectTemplate = html `
230
+ : nothing;
231
+
232
+ const selectTemplate = html`
182
233
  <span class="select-wrapper">
183
234
  <select
184
235
  .value=${ifDefined(value)}
185
236
  class=${classMap({
186
- placeholder: !value && !!inputs.placeholder,
187
- 'with-icon': !!inputs.icon,
188
- })}
237
+ placeholder: !value && !!inputs.placeholder,
238
+ 'with-icon': !!inputs.icon,
239
+ })}
189
240
  tabindex=${inputs.disabled ? -1 : 0}
190
241
  id=${ifDefined(inputs.label ? state.randomId : undefined)}
191
242
  aria-label=${ifDefined(inputs.label || undefined)}
192
243
  aria-disabled=${ifDefined(inputs.disabled ? 'true' : undefined)}
193
244
  ${listen('input', (event) => {
194
- const selectElement = extractEventTarget(event, HTMLSelectElement);
195
- const newValue = selectElement.value;
196
- if (selectElement.value !== value) {
197
- selectElement.selectedIndex = inputs.options.findIndex((option) => option.value === value);
198
- }
199
- dispatch(new events.valueChange(newValue));
200
- })}
245
+ const selectElement = extractEventTarget(event, HTMLSelectElement);
246
+ const newValue = selectElement.value;
247
+
248
+ if (selectElement.value !== value) {
249
+ selectElement.selectedIndex = inputs.options.findIndex(
250
+ (option) => option.value === value,
251
+ );
252
+ }
253
+
254
+ dispatch(new events.valueChange(newValue));
255
+ })}
201
256
  ${attributes(inputs.attributePassthrough?.select)}
202
257
  >
203
258
  ${placeholderOptionTemplate}
204
259
  ${inputs.options.map((option) => {
205
- return html `
260
+ return html`
206
261
  <option
207
262
  ?selected=${option.value === value}
208
263
  aria-label=${option.label}
@@ -212,7 +267,7 @@ export const ViraSelect = defineViraElement()({
212
267
  ${option.label}
213
268
  </option>
214
269
  `;
215
- })}
270
+ })}
216
271
  </select>
217
272
  <!--
218
273
  These separate style elements are necessary so that we can select them as
@@ -223,19 +278,19 @@ export const ViraSelect = defineViraElement()({
223
278
 
224
279
  <div class="border-style wrapper-border"></div>
225
280
 
226
- <${ViraIcon.assign({ icon: inputs.icon })} class="input-icon"></${ViraIcon}>
227
- <${ViraIcon.assign({ icon: ChevronUp24Icon })} class="trigger-icon"></${ViraIcon}>
281
+ <${ViraIcon.assign({icon: inputs.icon})} class="input-icon"></${ViraIcon}>
282
+ <${ViraIcon.assign({icon: ChevronUp24Icon})} class="trigger-icon"></${ViraIcon}>
228
283
  </span>
229
284
  `;
285
+
230
286
  if (inputs.label) {
231
- return html `
287
+ return html`
232
288
  <label for=${state.randomId} ${attributes(inputs.attributePassthrough?.label)}>
233
289
  <span class="select-label">${inputs.label}</span>
234
290
  ${selectTemplate}
235
291
  </label>
236
292
  `;
237
- }
238
- else {
293
+ } else {
239
294
  return selectTemplate;
240
295
  }
241
296
  },
@@ -0,0 +1,9 @@
1
+ export enum ColorType {
2
+ Color = 'color',
3
+ Fill = 'fill',
4
+ Stroke = 'stroke',
5
+ }
6
+
7
+ export function extractIconColor(element: Element, colorType: ColorType) {
8
+ return window.getComputedStyle(element).getPropertyValue(colorType);
9
+ }
@@ -1,4 +1,5 @@
1
- import { defineCssVars } from 'lit-css-vars';
1
+ import {defineCssVars} from 'lit-css-vars';
2
+
2
3
  /**
3
4
  * CSS vars that are supported by all Vira SVG icons.
4
5
  *
@@ -0,0 +1,71 @@
1
+ import {getObjectTypedKeys, stringify} from '@augment-vir/common';
2
+ import Color, {type ColorTypes} from 'colorjs.io';
3
+ import {type TemplateResult, html} from 'element-vir';
4
+ import {viraIconCssVars} from './icon-css-vars.js';
5
+
6
+ /**
7
+ * An individual Vira icon SVG definition.
8
+ *
9
+ * @category Icon
10
+ */
11
+ export type ViraIconSvg = {
12
+ name: string;
13
+ svgTemplate: TemplateResult;
14
+ };
15
+
16
+ /**
17
+ * A function used to define an individual Vira icon SVG.
18
+ *
19
+ * @category Icon
20
+ */
21
+ export function defineIcon({
22
+ name,
23
+ svgTemplate,
24
+ }: {
25
+ name: string;
26
+ svgTemplate: TemplateResult;
27
+ }): ViraIconSvg {
28
+ const iconSvg: ViraIconSvg = {
29
+ name,
30
+ svgTemplate,
31
+ };
32
+
33
+ return iconSvg;
34
+ }
35
+
36
+ function getAssertedValidColor(input: ColorTypes | undefined) {
37
+ try {
38
+ if (!input) {
39
+ throw new Error('invalid empty color');
40
+ }
41
+ return new Color(input);
42
+ } catch {
43
+ throw new Error(`Invalid color: ${stringify(input)}`);
44
+ }
45
+ }
46
+
47
+ /**
48
+ * Wraps an existing icon with a specific color and outputs another icon that can be used anywhere
49
+ * the original icon can be used.
50
+ *
51
+ * @category Icon
52
+ */
53
+ export function createColoredIcon(
54
+ icon: ViraIconSvg,
55
+ colors: Partial<Record<keyof typeof viraIconCssVars, string>>,
56
+ ): ViraIconSvg {
57
+ const colorStyles = getObjectTypedKeys(colors)
58
+ .map((cssVarName) => {
59
+ const colorValue = colors[cssVarName];
60
+ const color = getAssertedValidColor(colorValue);
61
+ return `${viraIconCssVars[cssVarName].name}: ${color.toString()};`;
62
+ })
63
+ .join(' ');
64
+
65
+ return defineIcon({
66
+ name: icon.name,
67
+ svgTemplate: html`
68
+ <div style=${colorStyles}>${icon.svgTemplate}</div>
69
+ `,
70
+ });
71
+ }
@@ -1,6 +1,7 @@
1
- import { html } from 'element-vir';
2
- import { viraIconCssVars } from '../icon-css-vars.js';
3
- import { defineIcon } from '../icon-svg.js';
1
+ import {html} from 'element-vir';
2
+ import {viraIconCssVars} from '../icon-css-vars.js';
3
+ import {defineIcon} from '../icon-svg.js';
4
+
4
5
  /**
5
6
  * A bell icon.
6
7
  *
@@ -10,7 +11,7 @@ import { defineIcon } from '../icon-svg.js';
10
11
  */
11
12
  export const Bell24Icon = defineIcon({
12
13
  name: 'Bell24Icon',
13
- svgTemplate: html `
14
+ svgTemplate: html`
14
15
  <svg
15
16
  xmlns="http://www.w3.org/2000/svg"
16
17
  xml:space="preserve"
@@ -1,6 +1,7 @@
1
- import { html } from 'element-vir';
2
- import { viraIconCssVars } from '../icon-css-vars.js';
3
- import { defineIcon } from '../icon-svg.js';
1
+ import {html} from 'element-vir';
2
+ import {viraIconCssVars} from '../icon-css-vars.js';
3
+ import {defineIcon} from '../icon-svg.js';
4
+
4
5
  /**
5
6
  * A chat bubble icon.
6
7
  *
@@ -10,7 +11,7 @@ import { defineIcon } from '../icon-svg.js';
10
11
  */
11
12
  export const Chat24Icon = defineIcon({
12
13
  name: 'Chat24Icon',
13
- svgTemplate: html `
14
+ svgTemplate: html`
14
15
  <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
15
16
  <path
16
17
  d="M5 15.4c-1.6-1.2-2.6-2.7-2.6-4.4 0-3.5 4.3-6.3 9.6-6.3s9.6 2.8 9.6 6.3-4.3 6.4-9.6 6.4L9 17l-5 3.8 1-5.5Z"
@@ -1,6 +1,7 @@
1
- import { html } from 'element-vir';
2
- import { viraIconCssVars } from '../icon-css-vars.js';
3
- import { defineIcon } from '../icon-svg.js';
1
+ import {html} from 'element-vir';
2
+ import {viraIconCssVars} from '../icon-css-vars.js';
3
+ import {defineIcon} from '../icon-svg.js';
4
+
4
5
  /**
5
6
  * A checkmark.
6
7
  *
@@ -10,7 +11,7 @@ import { defineIcon } from '../icon-svg.js';
10
11
  */
11
12
  export const Check24Icon = defineIcon({
12
13
  name: 'Check24Icon',
13
- svgTemplate: html `
14
+ svgTemplate: html`
14
15
  <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
15
16
  <path
16
17
  d="m17 8.5-7 8-3-3"
@@ -1,6 +1,7 @@
1
- import { html } from 'element-vir';
2
- import { viraIconCssVars } from '../icon-css-vars.js';
3
- import { defineIcon } from '../icon-svg.js';
1
+ import {html} from 'element-vir';
2
+ import {viraIconCssVars} from '../icon-css-vars.js';
3
+ import {defineIcon} from '../icon-svg.js';
4
+
4
5
  /**
5
6
  * A chevron that points upwards. See ChevronUp24Icon or one pointing upwards.
6
7
  *
@@ -10,7 +11,7 @@ import { defineIcon } from '../icon-svg.js';
10
11
  */
11
12
  export const ChevronDown24Icon = defineIcon({
12
13
  name: 'ChevronDown24Icon',
13
- svgTemplate: html `
14
+ svgTemplate: html`
14
15
  <svg
15
16
  xmlns="http://www.w3.org/2000/svg"
16
17
  stroke=${viraIconCssVars['vira-icon-stroke-color'].value}
@@ -1,6 +1,7 @@
1
- import { html } from 'element-vir';
2
- import { viraIconCssVars } from '../icon-css-vars.js';
3
- import { defineIcon } from '../icon-svg.js';
1
+ import {html} from 'element-vir';
2
+ import {viraIconCssVars} from '../icon-css-vars.js';
3
+ import {defineIcon} from '../icon-svg.js';
4
+
4
5
  /**
5
6
  * A chevron that points upwards. See ChevronDown24Icon for one pointing downloads.
6
7
  *
@@ -10,7 +11,7 @@ import { defineIcon } from '../icon-svg.js';
10
11
  */
11
12
  export const ChevronUp24Icon = defineIcon({
12
13
  name: 'ChevronUp24Icon',
13
- svgTemplate: html `
14
+ svgTemplate: html`
14
15
  <svg
15
16
  xmlns="http://www.w3.org/2000/svg"
16
17
  stroke=${viraIconCssVars['vira-icon-stroke-color'].value}
@@ -1,6 +1,7 @@
1
- import { html } from 'element-vir';
2
- import { viraIconCssVars } from '../icon-css-vars.js';
3
- import { defineIcon } from '../icon-svg.js';
1
+ import {html} from 'element-vir';
2
+ import {viraIconCssVars} from '../icon-css-vars.js';
3
+ import {defineIcon} from '../icon-svg.js';
4
+
4
5
  /**
5
6
  * An x icon meant to be used as a "close" button.
6
7
  *
@@ -10,7 +11,7 @@ import { defineIcon } from '../icon-svg.js';
10
11
  */
11
12
  export const CloseX24Icon = defineIcon({
12
13
  name: 'CloseX24Icon',
13
- svgTemplate: html `
14
+ svgTemplate: html`
14
15
  <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
15
16
  <circle
16
17
  cx="12"
@@ -1,6 +1,7 @@
1
- import { html } from 'element-vir';
2
- import { viraIconCssVars } from '../icon-css-vars.js';
3
- import { defineIcon } from '../icon-svg.js';
1
+ import {html} from 'element-vir';
2
+ import {viraIconCssVars} from '../icon-css-vars.js';
3
+ import {defineIcon} from '../icon-svg.js';
4
+
4
5
  /**
5
6
  * An icon that represents a single commit in git.
6
7
  *
@@ -10,7 +11,7 @@ import { defineIcon } from '../icon-svg.js';
10
11
  */
11
12
  export const Commit24Icon = defineIcon({
12
13
  name: 'Commit24Icon',
13
- svgTemplate: html `
14
+ svgTemplate: html`
14
15
  <svg
15
16
  xmlns="http://www.w3.org/2000/svg"
16
17
  xml:space="preserve"
@@ -1,6 +1,7 @@
1
- import { html } from 'element-vir';
2
- import { viraIconCssVars } from '../icon-css-vars.js';
3
- import { defineIcon } from '../icon-svg.js';
1
+ import {html} from 'element-vir';
2
+ import {viraIconCssVars} from '../icon-css-vars.js';
3
+ import {defineIcon} from '../icon-svg.js';
4
+
4
5
  /**
5
6
  * An icon that represents copying something.
6
7
  *
@@ -10,7 +11,7 @@ import { defineIcon } from '../icon-svg.js';
10
11
  */
11
12
  export const Copy24Icon = defineIcon({
12
13
  name: 'Copy24Icon',
13
- svgTemplate: html `
14
+ svgTemplate: html`
14
15
  <svg
15
16
  xmlns="http://www.w3.org/2000/svg"
16
17
  xml:space="preserve"
@@ -1,6 +1,7 @@
1
- import { html } from 'element-vir';
2
- import { viraIconCssVars } from '../icon-css-vars.js';
3
- import { defineIcon } from '../icon-svg.js';
1
+ import {html} from 'element-vir';
2
+ import {viraIconCssVars} from '../icon-css-vars.js';
3
+ import {defineIcon} from '../icon-svg.js';
4
+
4
5
  /**
5
6
  * An icon that represents a single document file on a computer file system.
6
7
  *
@@ -10,7 +11,7 @@ import { defineIcon } from '../icon-svg.js';
10
11
  */
11
12
  export const Document24Icon = defineIcon({
12
13
  name: 'Document24Icon',
13
- svgTemplate: html `
14
+ svgTemplate: html`
14
15
  <svg
15
16
  xmlns="http://www.w3.org/2000/svg"
16
17
  xml:space="preserve"
@@ -1,6 +1,7 @@
1
- import { html } from 'element-vir';
2
- import { viraIconCssVars } from '../icon-css-vars.js';
3
- import { defineIcon } from '../icon-svg.js';
1
+ import {html} from 'element-vir';
2
+ import {viraIconCssVars} from '../icon-css-vars.js';
3
+ import {defineIcon} from '../icon-svg.js';
4
+
4
5
  /**
5
6
  * An icon that represents searching on a document or searching for a document.
6
7
  *
@@ -10,7 +11,7 @@ import { defineIcon } from '../icon-svg.js';
10
11
  */
11
12
  export const DocumentSearch24Icon = defineIcon({
12
13
  name: 'DocumentSearch24Icon',
13
- svgTemplate: html `
14
+ svgTemplate: html`
14
15
  <svg
15
16
  xmlns="http://www.w3.org/2000/svg"
16
17
  xml:space="preserve"
@@ -1,6 +1,7 @@
1
- import { html } from 'element-vir';
2
- import { viraIconCssVars } from '../icon-css-vars.js';
3
- import { defineIcon } from '../icon-svg.js';
1
+ import {html} from 'element-vir';
2
+ import {viraIconCssVars} from '../icon-css-vars.js';
3
+ import {defineIcon} from '../icon-svg.js';
4
+
4
5
  /**
5
6
  * A icon with two opposing chevrons.
6
7
  *
@@ -10,7 +11,7 @@ import { defineIcon } from '../icon-svg.js';
10
11
  */
11
12
  export const DoubleChevron24Icon = defineIcon({
12
13
  name: 'DoubleChevron24Icon',
13
- svgTemplate: html `
14
+ svgTemplate: html`
14
15
  <svg
15
16
  xmlns="http://www.w3.org/2000/svg"
16
17
  xml:space="preserve"
@@ -1,6 +1,7 @@
1
- import { html } from 'element-vir';
2
- import { viraIconCssVars } from '../icon-css-vars.js';
3
- import { defineIcon } from '../icon-svg.js';
1
+ import {html} from 'element-vir';
2
+ import {viraIconCssVars} from '../icon-css-vars.js';
3
+ import {defineIcon} from '../icon-svg.js';
4
+
4
5
  /**
5
6
  * An icon symbol that represents an HTML element.
6
7
  *
@@ -10,7 +11,7 @@ import { defineIcon } from '../icon-svg.js';
10
11
  */
11
12
  export const Element16Icon = defineIcon({
12
13
  name: 'Element16Icon',
13
- svgTemplate: html `
14
+ svgTemplate: html`
14
15
  <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
15
16
  <path
16
17
  d="M4 5 1 8l3 3m8-6 3 3-3 3m-5 0 2-6"
@@ -1,6 +1,7 @@
1
- import { html } from 'element-vir';
2
- import { viraIconCssVars } from '../icon-css-vars.js';
3
- import { defineIcon } from '../icon-svg.js';
1
+ import {html} from 'element-vir';
2
+ import {viraIconCssVars} from '../icon-css-vars.js';
3
+ import {defineIcon} from '../icon-svg.js';
4
+
4
5
  /**
5
6
  * An icon symbol that represents an HTML element.
6
7
  *
@@ -10,7 +11,7 @@ import { defineIcon } from '../icon-svg.js';
10
11
  */
11
12
  export const Element24Icon = defineIcon({
12
13
  name: 'Element24Icon',
13
- svgTemplate: html `
14
+ svgTemplate: html`
14
15
  <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
15
16
  <path
16
17
  d="m7 7-5 5 5 5M17 7l5 5-5 5m-6 0 2-10"
@@ -1,6 +1,7 @@
1
- import { html } from 'element-vir';
2
- import { viraIconCssVars } from '../icon-css-vars.js';
3
- import { defineIcon } from '../icon-svg.js';
1
+ import {html} from 'element-vir';
2
+ import {viraIconCssVars} from '../icon-css-vars.js';
3
+ import {defineIcon} from '../icon-svg.js';
4
+
4
5
  /**
5
6
  * An external link icon.
6
7
  *
@@ -10,7 +11,7 @@ import { defineIcon } from '../icon-svg.js';
10
11
  */
11
12
  export const ExternalLink24Icon = defineIcon({
12
13
  name: 'ExternalLink24Icon',
13
- svgTemplate: html `
14
+ svgTemplate: html`
14
15
  <svg
15
16
  xmlns="http://www.w3.org/2000/svg"
16
17
  xml:space="preserve"
@@ -1,6 +1,7 @@
1
- import { html } from 'element-vir';
2
- import { viraIconCssVars } from '../icon-css-vars.js';
3
- import { defineIcon } from '../icon-svg.js';
1
+ import {html} from 'element-vir';
2
+ import {viraIconCssVars} from '../icon-css-vars.js';
3
+ import {defineIcon} from '../icon-svg.js';
4
+
4
5
  /**
5
6
  * A closed or disable eye icon.
6
7
  *
@@ -10,7 +11,7 @@ import { defineIcon } from '../icon-svg.js';
10
11
  */
11
12
  export const EyeClosed24Icon = defineIcon({
12
13
  name: 'EyeClosed24Icon',
13
- svgTemplate: html `
14
+ svgTemplate: html`
14
15
  <svg
15
16
  xmlns="http://www.w3.org/2000/svg"
16
17
  fill=${viraIconCssVars['vira-icon-fill-color'].value}
@@ -1,6 +1,7 @@
1
- import { html } from 'element-vir';
2
- import { viraIconCssVars } from '../icon-css-vars.js';
3
- import { defineIcon } from '../icon-svg.js';
1
+ import {html} from 'element-vir';
2
+ import {viraIconCssVars} from '../icon-css-vars.js';
3
+ import {defineIcon} from '../icon-svg.js';
4
+
4
5
  /**
5
6
  * An open eye icon.
6
7
  *
@@ -10,7 +11,7 @@ import { defineIcon } from '../icon-svg.js';
10
11
  */
11
12
  export const EyeOpen24Icon = defineIcon({
12
13
  name: 'EyeOpen24Icon',
13
- svgTemplate: html `
14
+ svgTemplate: html`
14
15
  <svg
15
16
  xmlns="http://www.w3.org/2000/svg"
16
17
  fill=${viraIconCssVars['vira-icon-fill-color'].value}
@@ -1,6 +1,7 @@
1
- import { html } from 'element-vir';
2
- import { viraIconCssVars } from '../icon-css-vars.js';
3
- import { defineIcon } from '../icon-svg.js';
1
+ import {html} from 'element-vir';
2
+ import {viraIconCssVars} from '../icon-css-vars.js';
3
+ import {defineIcon} from '../icon-svg.js';
4
+
4
5
  /**
5
6
  * An icon symbol that represents filtering.
6
7
  *
@@ -10,7 +11,7 @@ import { defineIcon } from '../icon-svg.js';
10
11
  */
11
12
  export const Filter24Icon = defineIcon({
12
13
  name: 'Filter24Icon',
13
- svgTemplate: html `
14
+ svgTemplate: html`
14
15
  <svg
15
16
  xmlns="http://www.w3.org/2000/svg"
16
17
  xml:space="preserve"