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.
Files changed (188) 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 -76
  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} +22 -34
  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 +31 -0
  27. package/{src/elements/vira-button.element.ts → dist/elements/vira-button.element.js} +35 -66
  28. package/dist/elements/vira-card.element.d.ts +18 -0
  29. package/{src/elements/vira-card.element.ts → dist/elements/vira-card.element.js} +13 -16
  30. package/dist/elements/vira-checkbox.element.d.ts +34 -0
  31. package/{src/elements/vira-checkbox.element.ts → dist/elements/vira-checkbox.element.js} +28 -71
  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 -94
  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} +5 -6
  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} +85 -151
  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} +11 -62
  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} +50 -89
  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} +11 -26
  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} +41 -96
  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/border.d.ts +9 -0
  140. package/{src/styles/border.ts → dist/styles/border.js} +1 -2
  141. package/dist/styles/disabled.d.ts +6 -0
  142. package/{src/styles/disabled.ts → dist/styles/disabled.js} +2 -3
  143. package/dist/styles/durations.d.ts +22 -0
  144. package/{src/styles/durations.ts → dist/styles/durations.js} +1 -2
  145. package/dist/styles/focus.d.ts +34 -0
  146. package/{src/styles/focus.ts → dist/styles/focus.js} +8 -29
  147. package/dist/styles/font.d.ts +9 -0
  148. package/{src/styles/font.ts → dist/styles/font.js} +1 -2
  149. package/dist/styles/form-styles.d.ts +20 -0
  150. package/{src/styles/form-styles.ts → dist/styles/form-styles.js} +1 -6
  151. package/{src/styles/index.ts → dist/styles/index.d.ts} +0 -1
  152. package/dist/styles/index.js +13 -0
  153. package/dist/styles/native-styles.d.ts +13 -0
  154. package/{src/styles/native-styles.ts → dist/styles/native-styles.js} +3 -5
  155. package/dist/styles/scrollbar.d.ts +6 -0
  156. package/{src/styles/scrollbar.ts → dist/styles/scrollbar.js} +3 -4
  157. package/dist/styles/shadows.d.ts +20 -0
  158. package/{src/styles/shadows.ts → dist/styles/shadows.js} +6 -8
  159. package/dist/styles/user-select.d.ts +6 -0
  160. package/{src/styles/user-select.ts → dist/styles/user-select.js} +2 -3
  161. package/dist/styles/vira-color-palette.d.ts +95 -0
  162. package/{src/styles/vira-color-palette.ts → dist/styles/vira-color-palette.js} +1 -11
  163. package/dist/styles/vira-color-theme.d.ts +1184 -0
  164. package/dist/styles/vira-color-theme.js +1138 -0
  165. package/dist/util/define-table.d.ts +110 -0
  166. package/dist/util/define-table.js +115 -0
  167. package/dist/util/dynamic-element.d.ts +63 -0
  168. package/dist/util/dynamic-element.js +61 -0
  169. package/dist/util/index.js +3 -0
  170. package/dist/util/pop-up-manager.d.ts +186 -0
  171. package/dist/util/pop-up-manager.js +214 -0
  172. package/package.json +6 -6
  173. package/src/elements/define-vira-element.ts +0 -29
  174. package/src/elements/form/vira-form-fields.ts +0 -140
  175. package/src/elements/form/vira-form.element.ts +0 -204
  176. package/src/elements/pop-up/pop-up-helpers.ts +0 -85
  177. package/src/elements/pop-up/vira-menu-trigger.element.ts +0 -158
  178. package/src/elements/shared-text-input-logic.ts +0 -173
  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/vira-color-theme.ts +0 -1142
  183. package/src/util/define-table.ts +0 -279
  184. package/src/util/dynamic-element.ts +0 -129
  185. package/src/util/pop-up-manager.ts +0 -380
  186. /package/{src/elements/index.ts → dist/elements/index.d.ts} +0 -0
  187. /package/{src/index.ts → dist/index.d.ts} +0 -0
  188. /package/{src/util/index.ts → dist/util/index.d.ts} +0 -0
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Required prefix for all vira elements.
3
+ *
4
+ * @category Internal
5
+ */
6
+ export declare const ViraTagNamePrefix = "vira-";
7
+ /**
8
+ * Required tag name for all vira elements. This includes {@link ViraTagNamePrefix} in it.
9
+ *
10
+ * @category Internal
11
+ */
12
+ export type ViraTagName = `${typeof ViraTagNamePrefix}${string}`;
13
+ /**
14
+ * Define a vira element with custom requirements (like the `vira-` element tag prefix).
15
+ *
16
+ * @category Internal
17
+ */
18
+ export declare const defineViraElement: <Inputs extends {}>(...errorParams: import("element-vir").DeclarativeElementInputErrorParams<Inputs>) => <const TagName extends `vira-${string}`, State extends {}, EventsInit extends {}, const HostClassKeys extends `${TagName}-${string}` = `${TagName}-`, const CssVarKeys extends `${TagName}-${string}` = `${TagName}-`, const SlotNames extends ReadonlyArray<string> = readonly [], const TestIds extends ReadonlyArray<string> = readonly []>(inputs: import("element-vir").DeclarativeElementInit<TagName, Inputs, State, EventsInit, HostClassKeys, CssVarKeys, SlotNames, TestIds>) => import("element-vir").DeclarativeElementDefinition<TagName, Inputs, State, EventsInit, HostClassKeys, CssVarKeys, SlotNames, TestIds>;
@@ -0,0 +1,19 @@
1
+ import { wrapDefineElement } from 'element-vir';
2
+ /**
3
+ * Required prefix for all vira elements.
4
+ *
5
+ * @category Internal
6
+ */
7
+ export const ViraTagNamePrefix = `vira-`;
8
+ /**
9
+ * Define a vira element with custom requirements (like the `vira-` element tag prefix).
10
+ *
11
+ * @category Internal
12
+ */
13
+ export const defineViraElement = wrapDefineElement({
14
+ assertInputs: (inputs) => {
15
+ if (!inputs.tagName.startsWith(ViraTagNamePrefix)) {
16
+ throw new Error(`Tag name should start with '${ViraTagNamePrefix}' but got '${inputs.tagName}'`);
17
+ }
18
+ },
19
+ });
@@ -0,0 +1,100 @@
1
+ import { type PartialWithUndefined } from '@augment-vir/common';
2
+ import { type ViraIconSvg } from '../../icons/icon-svg.js';
3
+ import { type ViraSelectOption } from '../vira-select.element.js';
4
+ /**
5
+ * Form field types for {@link ViraFormField}.
6
+ *
7
+ * @category Internal
8
+ */
9
+ export declare enum ViraFormFieldType {
10
+ Text = "text",
11
+ /** Allows auto complete for _existing_ passwords used on this website (for login). */
12
+ ExistingPassword = "existing-password",
13
+ /** Allows auto complete for _new_ passwords used on this website (for login). */
14
+ NewPassword = "new-password",
15
+ /** Uses a password input without any attributes applied for auto complete hints. */
16
+ PlainPassword = "plain-password",
17
+ Email = "email",
18
+ Select = "select",
19
+ Checkbox = "checkbox"
20
+ }
21
+ /**
22
+ * {@link ViraFormField} properties that are shared between all field types.
23
+ *
24
+ * @category Internal
25
+ */
26
+ export type CommonViraFormFields = {
27
+ label: string;
28
+ } & PartialWithUndefined<{
29
+ /** Applies a test id to the form field element. */
30
+ testId: string;
31
+ /**
32
+ * When `true`, visually indicates the form field as required and affects form validation.
33
+ *
34
+ * @default false
35
+ */
36
+ isRequired: boolean;
37
+ /**
38
+ * When `true`, marks this form field element with error styling.
39
+ *
40
+ * @default false
41
+ */
42
+ hasError: boolean;
43
+ /**
44
+ * When `true`, hides this form field entirely.
45
+ *
46
+ * @default false
47
+ */
48
+ isHidden: boolean;
49
+ /**
50
+ * When `true`, continues showing the form field but prevents edits.
51
+ *
52
+ * @default false
53
+ */
54
+ isDisabled: boolean;
55
+ }>;
56
+ /**
57
+ * An individual form field for {@link ViraFormFields}.
58
+ *
59
+ * @category Internal
60
+ */
61
+ export type ViraFormField = ({
62
+ type: ViraFormFieldType.Text | ViraFormFieldType.ExistingPassword | ViraFormFieldType.NewPassword | ViraFormFieldType.PlainPassword | ViraFormFieldType.Email;
63
+ value: string | undefined;
64
+ } & PartialWithUndefined<{
65
+ placeholder: string;
66
+ icon: ViraIconSvg;
67
+ isUsername: boolean;
68
+ }> & CommonViraFormFields) | ({
69
+ type: ViraFormFieldType.Select;
70
+ value: string | undefined;
71
+ options: ReadonlyArray<Readonly<ViraSelectOption>>;
72
+ } & PartialWithUndefined<{
73
+ placeholder: string;
74
+ icon: ViraIconSvg;
75
+ }> & CommonViraFormFields) | ({
76
+ type: ViraFormFieldType.Checkbox;
77
+ value: boolean | undefined;
78
+ } & CommonViraFormFields);
79
+ /**
80
+ * A collection of form fields for `ViraForm`.
81
+ *
82
+ * @category Internal
83
+ */
84
+ export type ViraFormFields = Record<string, ViraFormField>;
85
+ /**
86
+ * Appends a `'*'` to a label if it exist sand if it is required.
87
+ *
88
+ * @category Internal
89
+ */
90
+ export declare function applyRequiredLabel(label: string | undefined, isRequired: boolean): string | undefined;
91
+ /**
92
+ * Checks if all the {@link ViraFormField} entries in a given {@link ViraFormFields} are valid through
93
+ * the following checks:
94
+ *
95
+ * - Checks that required fields are provided (not `undefined`)
96
+ * - Ignores hidden fields
97
+ *
98
+ * @category Internal
99
+ */
100
+ export declare function areFormFieldsValid(formFields: Readonly<ViraFormFields>): boolean;
@@ -0,0 +1,60 @@
1
+ import { check } from '@augment-vir/assert';
2
+ import { addSuffix, getObjectTypedValues } from '@augment-vir/common';
3
+ /**
4
+ * Form field types for {@link ViraFormField}.
5
+ *
6
+ * @category Internal
7
+ */
8
+ export var ViraFormFieldType;
9
+ (function (ViraFormFieldType) {
10
+ ViraFormFieldType["Text"] = "text";
11
+ /** Allows auto complete for _existing_ passwords used on this website (for login). */
12
+ ViraFormFieldType["ExistingPassword"] = "existing-password";
13
+ /** Allows auto complete for _new_ passwords used on this website (for login). */
14
+ ViraFormFieldType["NewPassword"] = "new-password";
15
+ /** Uses a password input without any attributes applied for auto complete hints. */
16
+ ViraFormFieldType["PlainPassword"] = "plain-password";
17
+ ViraFormFieldType["Email"] = "email";
18
+ ViraFormFieldType["Select"] = "select";
19
+ ViraFormFieldType["Checkbox"] = "checkbox";
20
+ })(ViraFormFieldType || (ViraFormFieldType = {}));
21
+ /**
22
+ * Appends a `'*'` to a label if it exist sand if it is required.
23
+ *
24
+ * @category Internal
25
+ */
26
+ export function applyRequiredLabel(label, isRequired) {
27
+ if (label) {
28
+ if (isRequired) {
29
+ return addSuffix({ value: label, suffix: '*' });
30
+ }
31
+ else {
32
+ return label;
33
+ }
34
+ }
35
+ else {
36
+ return undefined;
37
+ }
38
+ }
39
+ /**
40
+ * Checks if all the {@link ViraFormField} entries in a given {@link ViraFormFields} are valid through
41
+ * the following checks:
42
+ *
43
+ * - Checks that required fields are provided (not `undefined`)
44
+ * - Ignores hidden fields
45
+ *
46
+ * @category Internal
47
+ */
48
+ export function areFormFieldsValid(formFields) {
49
+ return getObjectTypedValues(formFields).every((formField) => {
50
+ if (formField.isHidden || !formField.isRequired) {
51
+ return true;
52
+ }
53
+ else if (check.isString(formField.value)) {
54
+ return !!formField.value;
55
+ }
56
+ else {
57
+ return formField.value != undefined;
58
+ }
59
+ });
60
+ }
@@ -0,0 +1,35 @@
1
+ import { type PartialWithUndefined } from '@augment-vir/common';
2
+ import { type ViraFormField, type ViraFormFields } from './vira-form-fields.js';
3
+ /**
4
+ * A form element.
5
+ *
6
+ * @category Elements
7
+ * @see https://electrovir.github.io/vira/book/elements/vira-form
8
+ */
9
+ export declare const ViraForm: import("element-vir").DeclarativeElementDefinition<"vira-form", Readonly<{
10
+ fields: Readonly<ViraFormFields>;
11
+ } & PartialWithUndefined<{
12
+ showClearButtons: boolean;
13
+ /**
14
+ * When `true`, all fields in this form are disabled. Note that this will not (and can
15
+ * not) disable any child elements you've inserted via <slot>.
16
+ *
17
+ * @default false
18
+ */
19
+ isDisabled: boolean;
20
+ /**
21
+ * If true, no `'*'` is appended to required form field labels.
22
+ *
23
+ * @default false
24
+ */
25
+ hideRequiredMarkers: boolean;
26
+ }>>, {
27
+ lastIsValid: boolean;
28
+ }, {
29
+ valueChange: import("element-vir").DefineEvent<{
30
+ key: string;
31
+ } & ViraFormField>;
32
+ validChange: import("element-vir").DefineEvent<{
33
+ allFieldsAreValid: boolean;
34
+ }>;
35
+ }, "vira-form-", "vira-form-", readonly [], readonly []>;
@@ -0,0 +1,151 @@
1
+ import { getObjectTypedEntries } from '@augment-vir/common';
2
+ import { css, defineElementEvent, html, listen, nothing, testId } from 'element-vir';
3
+ import { defineViraElement } from '../define-vira-element.js';
4
+ import { ViraCheckbox } from '../vira-checkbox.element.js';
5
+ import { ViraInput, ViraInputType } from '../vira-input.element.js';
6
+ import { ViraSelect } from '../vira-select.element.js';
7
+ import { applyRequiredLabel, areFormFieldsValid, ViraFormFieldType, } from './vira-form-fields.js';
8
+ /**
9
+ * A form element.
10
+ *
11
+ * @category Elements
12
+ * @see https://electrovir.github.io/vira/book/elements/vira-form
13
+ */
14
+ export const ViraForm = defineViraElement()({
15
+ tagName: 'vira-form',
16
+ events: {
17
+ valueChange: defineElementEvent(),
18
+ validChange: defineElementEvent(),
19
+ },
20
+ styles: css `
21
+ :host {
22
+ display: flex;
23
+ }
24
+
25
+ form {
26
+ display: flex;
27
+ flex-grow: 1;
28
+ flex-direction: column;
29
+ align-items: stretch;
30
+ gap: 10px;
31
+
32
+ > * {
33
+ width: unset;
34
+ }
35
+ }
36
+ `,
37
+ state() {
38
+ return {
39
+ lastIsValid: false,
40
+ };
41
+ },
42
+ render({ inputs, dispatch, events, state, updateState }) {
43
+ const currentIsValid = areFormFieldsValid(inputs.fields);
44
+ if (currentIsValid !== state.lastIsValid) {
45
+ updateState({
46
+ lastIsValid: currentIsValid,
47
+ });
48
+ dispatch(new events.validChange({ allFieldsAreValid: currentIsValid }));
49
+ }
50
+ const formFieldTemplates = getObjectTypedEntries(inputs.fields).map(([key, field,]) => {
51
+ if (field.isHidden) {
52
+ return nothing;
53
+ }
54
+ else if (field.type === ViraFormFieldType.Checkbox) {
55
+ return html `
56
+ <${ViraCheckbox.assign({
57
+ value: field.value || false,
58
+ disabled: inputs.isDisabled || field.isDisabled,
59
+ hasError: field.hasError,
60
+ label: applyRequiredLabel(field.label, !!field.isRequired && !inputs.hideRequiredMarkers),
61
+ })}
62
+ ${field.testId ? testId(field.testId) : nothing}
63
+ ${listen(ViraCheckbox.events.valueChange, (event) => {
64
+ dispatch(new events.valueChange({
65
+ key,
66
+ ...field,
67
+ value: event.detail,
68
+ }));
69
+ })}
70
+ ></${ViraCheckbox}>
71
+ `;
72
+ }
73
+ else if (field.type === ViraFormFieldType.Select) {
74
+ return html `
75
+ <${ViraSelect.assign({
76
+ options: field.options,
77
+ value: field.value,
78
+ placeholder: field.placeholder,
79
+ disabled: inputs.isDisabled || field.isDisabled,
80
+ label: applyRequiredLabel(field.label, !!field.isRequired && !inputs.hideRequiredMarkers),
81
+ hasError: field.hasError,
82
+ icon: field.icon,
83
+ })}
84
+ ${field.testId ? testId(field.testId) : nothing}
85
+ ${listen(ViraSelect.events.valueChange, (event) => {
86
+ dispatch(new events.valueChange({
87
+ key,
88
+ ...field,
89
+ value: event.detail,
90
+ }));
91
+ })}
92
+ ></${ViraSelect}>
93
+ `;
94
+ }
95
+ else {
96
+ return html `
97
+ <${ViraInput.assign({
98
+ value: field.value || '',
99
+ disabled: inputs.isDisabled || field.isDisabled,
100
+ hasError: field.hasError,
101
+ icon: field.icon,
102
+ label: applyRequiredLabel(field.label, !!field.isRequired && !inputs.hideRequiredMarkers),
103
+ placeholder: field.placeholder,
104
+ showClearButton: inputs.showClearButtons,
105
+ attributePassthrough: field.isUsername
106
+ ? {
107
+ autocomplete: 'username',
108
+ }
109
+ : field.type === ViraFormFieldType.NewPassword
110
+ ? {
111
+ autocomplete: 'new-password',
112
+ }
113
+ : field.type === ViraFormFieldType.ExistingPassword
114
+ ? {
115
+ autocomplete: 'password',
116
+ }
117
+ : field.type === ViraFormFieldType.Email
118
+ ? {
119
+ autocomplete: 'email',
120
+ }
121
+ : {},
122
+ type: [
123
+ ViraFormFieldType.NewPassword,
124
+ ViraFormFieldType.ExistingPassword,
125
+ ViraFormFieldType.PlainPassword,
126
+ ].includes(field.type)
127
+ ? ViraInputType.Password
128
+ : field.type === ViraFormFieldType.Email
129
+ ? ViraInputType.Email
130
+ : ViraInputType.Default,
131
+ })}
132
+ ${field.testId ? testId(field.testId) : nothing}
133
+ ${listen(ViraInput.events.valueChange, (event) => {
134
+ dispatch(new events.valueChange({
135
+ key,
136
+ ...field,
137
+ value: event.detail,
138
+ }));
139
+ })}
140
+ ></${ViraInput}>
141
+ `;
142
+ }
143
+ });
144
+ return html `
145
+ <form ${listen('submit', (event) => event.preventDefault())}>
146
+ ${formFieldTemplates}
147
+ <slot></slot>
148
+ </form>
149
+ `;
150
+ },
151
+ });
@@ -0,0 +1,25 @@
1
+ export * from './define-vira-element.js';
2
+ export * from './form/vira-form-fields.js';
3
+ export * from './form/vira-form.element.js';
4
+ export * from './pop-up/pop-up-helpers.js';
5
+ export * from './pop-up/pop-up-menu-item.js';
6
+ export * from './pop-up/vira-menu-item.element.js';
7
+ export * from './pop-up/vira-menu-trigger.element.js';
8
+ export * from './pop-up/vira-menu.element.js';
9
+ export * from './pop-up/vira-pop-up-menu.element.js';
10
+ export * from './pop-up/vira-pop-up-trigger.element.js';
11
+ export * from './vira-bold-text.element.js';
12
+ export * from './vira-button.element.js';
13
+ export * from './vira-card.element.js';
14
+ export * from './vira-checkbox.element.js';
15
+ export * from './vira-collapsible-wrapper.element.js';
16
+ export * from './vira-dropdown.element.js';
17
+ export * from './vira-error.element.js';
18
+ export * from './vira-icon.element.js';
19
+ export * from './vira-image.element.js';
20
+ export * from './vira-input.element.js';
21
+ export * from './vira-link.element.js';
22
+ export * from './vira-modal.element.js';
23
+ export * from './vira-overflow-switch.element.js';
24
+ export * from './vira-progress.element.js';
25
+ export * from './vira-select.element.js';
@@ -0,0 +1,33 @@
1
+ import { type PartialWithUndefined } from '@augment-vir/common';
2
+ import { type PopUpManager, type PopUpManagerOptions, type ShowPopUpResult } from '../../util/pop-up-manager.js';
3
+ import { type MenuItem } from './pop-up-menu-item.js';
4
+ /**
5
+ * Verifies that all items have unique ids.
6
+ *
7
+ * @category Internal
8
+ */
9
+ export declare function assertUniqueIdProps(items: ReadonlyArray<Readonly<{
10
+ id: PropertyKey;
11
+ }>>): void;
12
+ /**
13
+ * Creates a new array of selections based on the current selection and new selection id. This
14
+ * behaves differently when multi select is enabled, hence this function.
15
+ *
16
+ * @category Internal
17
+ */
18
+ export declare function updateSelectedItems(
19
+ /** The item that should be newly toggled. */
20
+ newItem: Readonly<MenuItem>, currentSelection?: ReadonlyArray<PropertyKey>, isMultiSelect?: boolean): PropertyKey[];
21
+ /**
22
+ * Handles toggling pop up state for `ViraDropdown`.
23
+ *
24
+ * @category Internal
25
+ */
26
+ export declare function triggerPopUpState({ open, callback, popUpManager, host, options, }: Readonly<{
27
+ open: boolean;
28
+ popUpManager: PopUpManager;
29
+ host: HTMLElement;
30
+ } & PartialWithUndefined<{
31
+ callback?: ((showPopUpResult: ShowPopUpResult | undefined) => void) | undefined;
32
+ options?: Partial<PopUpManagerOptions> | undefined;
33
+ }>>): void;
@@ -0,0 +1,58 @@
1
+ import { joinWithFinalConjunction } from '@augment-vir/common';
2
+ /**
3
+ * Verifies that all items have unique ids.
4
+ *
5
+ * @category Internal
6
+ */
7
+ export function assertUniqueIdProps(items) {
8
+ const usedIds = new Set();
9
+ const duplicateIds = [];
10
+ items.forEach((option) => {
11
+ if (usedIds.has(option.id)) {
12
+ duplicateIds.push(option.id);
13
+ }
14
+ else {
15
+ usedIds.add(option.id);
16
+ }
17
+ });
18
+ if (duplicateIds.length) {
19
+ throw new Error(`Duplicate option ids were given: ${joinWithFinalConjunction(duplicateIds)}`);
20
+ }
21
+ }
22
+ /**
23
+ * Creates a new array of selections based on the current selection and new selection id. This
24
+ * behaves differently when multi select is enabled, hence this function.
25
+ *
26
+ * @category Internal
27
+ */
28
+ export function updateSelectedItems(
29
+ /** The item that should be newly toggled. */
30
+ newItem, currentSelection = [], isMultiSelect = false) {
31
+ if (isMultiSelect) {
32
+ return currentSelection.includes(newItem.id)
33
+ ? currentSelection.filter((entry) => entry !== newItem.id)
34
+ : [
35
+ ...currentSelection,
36
+ newItem.id,
37
+ ];
38
+ }
39
+ else {
40
+ /** In single select, only the toggled item is allowed. */
41
+ return [newItem.id];
42
+ }
43
+ }
44
+ /**
45
+ * Handles toggling pop up state for `ViraDropdown`.
46
+ *
47
+ * @category Internal
48
+ */
49
+ export function triggerPopUpState({ open, callback, popUpManager, host, options, }) {
50
+ if (open) {
51
+ const showPopUpResult = popUpManager.showPopUp(host, options);
52
+ callback?.(showPopUpResult);
53
+ }
54
+ else {
55
+ popUpManager.removePopUp();
56
+ callback?.(undefined);
57
+ }
58
+ }
@@ -1,7 +1,6 @@
1
- import {type PartialWithUndefined} from '@augment-vir/common';
2
- import {type HTMLTemplateResult} from 'element-vir';
3
- import {type ViraLinkRoute} from '../vira-link.element.js';
4
-
1
+ import { type PartialWithUndefined } from '@augment-vir/common';
2
+ import { type HTMLTemplateResult } from 'element-vir';
3
+ import { type ViraLinkRoute } from '../vira-link.element.js';
5
4
  /**
6
5
  * An individual menu item consumed partially by `ViraMenuItem` and used by `ViraMenu`.
7
6
  *
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,19 @@
1
+ import { type PartialWithUndefined } from '@augment-vir/common';
2
+ import { type MenuItem } from './pop-up-menu-item.js';
3
+ /**
4
+ * An element for an individual menu item.
5
+ *
6
+ * @category PopUp
7
+ * @category Elements
8
+ */
9
+ export declare const ViraMenuItem: import("element-vir").DeclarativeElementDefinition<"vira-menu-item", Readonly<{
10
+ selected: boolean;
11
+ } & PartialWithUndefined<{
12
+ /**
13
+ * The text to show in the menu item. If this is not provided, it is expected that you
14
+ * will instead utilize this element's `<slot>`.
15
+ */
16
+ label: MenuItem["label"];
17
+ /** If `true`, does not render the selected check icon. */
18
+ hideCheckIcon: boolean;
19
+ }>>, {}, {}, "vira-menu-item-selected", "vira-menu-item-", readonly [], readonly []>;
@@ -1,37 +1,20 @@
1
- import {type PartialWithUndefined} from '@augment-vir/common';
2
- import {css, html} from 'element-vir';
3
- import {Check24Icon} from '../../icons/icon-svgs/check-24.icon.js';
4
- import {noUserSelect} from '../../styles/index.js';
5
- import {defineViraElement} from '../define-vira-element.js';
6
- import {ViraIcon} from '../vira-icon.element.js';
7
- import {type MenuItem} from './pop-up-menu-item.js';
8
-
1
+ import { css, html } from 'element-vir';
2
+ import { Check24Icon } from '../../icons/icon-svgs/check-24.icon.js';
3
+ import { noUserSelect } from '../../styles/index.js';
4
+ import { defineViraElement } from '../define-vira-element.js';
5
+ import { ViraIcon } from '../vira-icon.element.js';
9
6
  /**
10
7
  * An element for an individual menu item.
11
8
  *
12
9
  * @category PopUp
13
10
  * @category Elements
14
11
  */
15
- export const ViraMenuItem = defineViraElement<
16
- Readonly<
17
- {
18
- selected: boolean;
19
- } & PartialWithUndefined<{
20
- /**
21
- * The text to show in the menu item. If this is not provided, it is expected that you
22
- * will instead utilize this element's `<slot>`.
23
- */
24
- label: MenuItem['label'];
25
- /** If `true`, does not render the selected check icon. */
26
- hideCheckIcon: boolean;
27
- }>
28
- >
29
- >()({
12
+ export const ViraMenuItem = defineViraElement()({
30
13
  tagName: 'vira-menu-item',
31
14
  hostClasses: {
32
- 'vira-menu-item-selected': ({inputs}) => !inputs.hideCheckIcon && inputs.selected,
15
+ 'vira-menu-item-selected': ({ inputs }) => !inputs.hideCheckIcon && inputs.selected,
33
16
  },
34
- styles: ({hostClasses}) => css`
17
+ styles: ({ hostClasses }) => css `
35
18
  :host {
36
19
  display: flex;
37
20
  ${noUserSelect};
@@ -70,10 +53,10 @@ export const ViraMenuItem = defineViraElement<
70
53
  visibility: hidden;
71
54
  }
72
55
  `,
73
- render({inputs}) {
74
- return html`
56
+ render({ inputs }) {
57
+ return html `
75
58
  <div class="item">
76
- <${ViraIcon.assign({icon: Check24Icon})}></${ViraIcon}>
59
+ <${ViraIcon.assign({ icon: Check24Icon })}></${ViraIcon}>
77
60
  <slot>${inputs.label}</slot>
78
61
  </div>
79
62
  `;
@@ -0,0 +1,41 @@
1
+ import { type PartialWithUndefined } from '@augment-vir/common';
2
+ import { type NavController } from 'device-navigation';
3
+ import { type PopUpManager, type ShowPopUpResult } from '../../util/pop-up-manager.js';
4
+ import { type MenuItem } from './pop-up-menu-item.js';
5
+ import { type PopUpMenuCornerStyle } from './vira-pop-up-menu.element.js';
6
+ import { type PopUpOffset, type PopUpTriggerPosition } from './vira-pop-up-trigger.element.js';
7
+ /**
8
+ * Test ids for {@link ViraMenuTrigger}.
9
+ *
10
+ * @category Internal
11
+ */
12
+ export declare const viraMenuTriggerTestIds: {
13
+ menu: string;
14
+ };
15
+ /**
16
+ * A more specific wrapper of `ViraPopUpTrigger` that always opens a menu.
17
+ *
18
+ * @category PopUp
19
+ * @category Elements
20
+ */
21
+ export declare const ViraMenuTrigger: import("element-vir").DeclarativeElementDefinition<"vira-menu-trigger", {
22
+ items: ReadonlyArray<Readonly<MenuItem>>;
23
+ } & PartialWithUndefined<{
24
+ /** The selected item ids from the given `items` object. */
25
+ selected: ReadonlyArray<PropertyKey>;
26
+ isDisabled: boolean;
27
+ isMultiSelect: boolean;
28
+ z_debug_forceOpenState: boolean;
29
+ popUpOffset: PopUpOffset;
30
+ /** Hide menu item check mark icons. */
31
+ hideCheckIcons: boolean;
32
+ menuCornerStyle: PopUpMenuCornerStyle;
33
+ } & PopUpTriggerPosition>, {
34
+ navController: undefined | NavController;
35
+ popUpManager: undefined | PopUpManager;
36
+ /** `undefined` means the pop up is not currently showing. */
37
+ showPopUpResult: ShowPopUpResult | undefined;
38
+ }, {
39
+ itemActivate: import("element-vir").DefineEvent<PropertyKey[]>;
40
+ openChange: import("element-vir").DefineEvent<ShowPopUpResult | undefined>;
41
+ }, "vira-menu-trigger-", "vira-menu-trigger-", readonly [], readonly []>;