vira 22.2.1 → 23.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 (95) hide show
  1. package/dist/elements/define-vira-element.d.ts +22 -1
  2. package/dist/elements/define-vira-element.js +18 -1
  3. package/dist/elements/dropdown/dropdown-helpers.d.ts +26 -3
  4. package/dist/elements/dropdown/dropdown-helpers.js +26 -3
  5. package/dist/elements/dropdown/vira-dropdown-item.element.d.ts +17 -6
  6. package/dist/elements/dropdown/vira-dropdown-item.element.js +12 -6
  7. package/dist/elements/dropdown/vira-dropdown-options.element.d.ts +14 -3
  8. package/dist/elements/dropdown/vira-dropdown-options.element.js +18 -7
  9. package/dist/elements/dropdown/vira-dropdown.element.d.ts +20 -8
  10. package/dist/elements/dropdown/vira-dropdown.element.js +28 -16
  11. package/dist/elements/index.d.ts +10 -10
  12. package/dist/elements/index.js +10 -10
  13. package/dist/elements/shared-text-input-logic.d.ts +20 -0
  14. package/dist/elements/shared-text-input-logic.js +13 -3
  15. package/dist/elements/vira-button.element.d.ts +17 -5
  16. package/dist/elements/vira-button.element.js +27 -15
  17. package/dist/elements/vira-collapsible-wrapper.element.d.ts +9 -2
  18. package/dist/elements/vira-collapsible-wrapper.element.js +10 -3
  19. package/dist/elements/vira-icon.element.d.ts +10 -3
  20. package/dist/elements/vira-icon.element.js +9 -2
  21. package/dist/elements/vira-image.element.d.ts +7 -7
  22. package/dist/elements/vira-image.element.js +20 -17
  23. package/dist/elements/vira-input.element.d.ts +20 -7
  24. package/dist/elements/vira-input.element.js +32 -16
  25. package/dist/elements/vira-link.element.d.ts +10 -2
  26. package/dist/elements/vira-link.element.js +11 -3
  27. package/dist/icons/icon-color.test-helper.d.ts +6 -0
  28. package/dist/icons/icon-color.test-helper.js +9 -0
  29. package/dist/icons/icon-css-vars.d.ts +10 -3
  30. package/dist/icons/icon-css-vars.js +7 -0
  31. package/dist/icons/icon-svg.d.ts +17 -1
  32. package/dist/icons/icon-svg.js +13 -2
  33. package/dist/icons/icon-svgs/check-24.icon.d.ts +8 -1
  34. package/dist/icons/icon-svgs/check-24.icon.js +9 -2
  35. package/dist/icons/icon-svgs/chevron-up-24.icon.d.ts +8 -1
  36. package/dist/icons/icon-svgs/chevron-up-24.icon.js +9 -2
  37. package/dist/icons/icon-svgs/close-x-24.icon.d.ts +8 -1
  38. package/dist/icons/icon-svgs/close-x-24.icon.js +9 -2
  39. package/dist/icons/icon-svgs/element-16.icon.d.ts +8 -1
  40. package/dist/icons/icon-svgs/element-16.icon.js +9 -2
  41. package/dist/icons/icon-svgs/element-24.icon.d.ts +8 -1
  42. package/dist/icons/icon-svgs/element-24.icon.js +9 -2
  43. package/dist/icons/icon-svgs/eye-closed-24.icon.d.ts +8 -1
  44. package/dist/icons/icon-svgs/eye-closed-24.icon.js +9 -2
  45. package/dist/icons/icon-svgs/eye-open-24.icon.d.ts +8 -1
  46. package/dist/icons/icon-svgs/eye-open-24.icon.js +9 -3
  47. package/dist/icons/icon-svgs/loader-24.icon.d.ts +8 -1
  48. package/dist/icons/icon-svgs/loader-24.icon.js +9 -2
  49. package/dist/icons/icon-svgs/loader-animated-24.icon.d.ts +8 -1
  50. package/dist/icons/icon-svgs/loader-animated-24.icon.js +10 -3
  51. package/dist/icons/icon-svgs/options-24.icon.d.ts +8 -1
  52. package/dist/icons/icon-svgs/options-24.icon.js +10 -3
  53. package/dist/icons/icon-svgs/status-failure-24.icon.d.ts +8 -1
  54. package/dist/icons/icon-svgs/status-failure-24.icon.js +9 -2
  55. package/dist/icons/icon-svgs/status-in-progress-24.icon.d.ts +8 -1
  56. package/dist/icons/icon-svgs/status-in-progress-24.icon.js +9 -2
  57. package/dist/icons/icon-svgs/status-success-24.icon.d.ts +8 -1
  58. package/dist/icons/icon-svgs/status-success-24.icon.js +9 -2
  59. package/dist/icons/index.d.ts +33 -28
  60. package/dist/icons/index.js +33 -28
  61. package/dist/index.d.ts +5 -5
  62. package/dist/index.js +5 -5
  63. package/dist/re-exports/colorjs-io.d.ts +12 -0
  64. package/dist/re-exports/colorjs-io.js +7 -0
  65. package/dist/re-exports/index.d.ts +1 -1
  66. package/dist/re-exports/index.js +1 -1
  67. package/dist/styles/border.d.ts +7 -1
  68. package/dist/styles/border.js +6 -0
  69. package/dist/styles/color.d.ts +12 -2
  70. package/dist/styles/color.js +12 -2
  71. package/dist/styles/disabled.d.ts +5 -0
  72. package/dist/styles/disabled.js +5 -0
  73. package/dist/styles/durations.d.ts +17 -7
  74. package/dist/styles/durations.js +14 -4
  75. package/dist/styles/focus.d.ts +12 -4
  76. package/dist/styles/focus.js +11 -3
  77. package/dist/styles/form-themes.d.ts +12 -6
  78. package/dist/styles/form-themes.js +7 -1
  79. package/dist/styles/index.d.ts +10 -10
  80. package/dist/styles/index.js +10 -10
  81. package/dist/styles/native-styles.d.ts +11 -0
  82. package/dist/styles/native-styles.js +11 -0
  83. package/dist/styles/scrollbar.d.ts +5 -0
  84. package/dist/styles/scrollbar.js +5 -0
  85. package/dist/styles/shadows.d.ts +5 -0
  86. package/dist/styles/shadows.js +5 -0
  87. package/dist/styles/user-select.d.ts +5 -0
  88. package/dist/styles/user-select.js +5 -0
  89. package/dist/util/index.d.ts +1 -1
  90. package/dist/util/index.js +1 -1
  91. package/dist/util/pop-up-manager.d.ts +61 -6
  92. package/dist/util/pop-up-manager.js +43 -33
  93. package/package.json +34 -30
  94. package/dist/elements/dropdown/dropdown.mock.d.ts +0 -13
  95. package/dist/elements/dropdown/dropdown.mock.js +0 -18
@@ -1,3 +1,24 @@
1
+ /**
2
+ * Required prefix for all vira elements.
3
+ *
4
+ * @category Internal
5
+ */
1
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
+ */
2
12
  export type ViraTagName = `${typeof ViraTagNamePrefix}${string}`;
3
- export declare const defineViraElement: <Inputs extends {}>() => <const TagName extends `vira-${string}`, StateInit extends {}, EventsInit extends {}, const HostClassKeys extends `${TagName}-${string}`, const CssVarKeys extends `${TagName}-${string}`, const SlotNames extends readonly string[]>(inputs: import("element-vir").VerifiedElementInit<TagName, Inputs, StateInit, EventsInit, HostClassKeys, CssVarKeys, SlotNames>) => import("element-vir").DeclarativeElementDefinition<TagName, Inputs, StateInit, EventsInit, HostClassKeys, CssVarKeys, SlotNames>, defineViraElementNoInputs: <const TagName_1 extends `vira-${string}`, Inputs_1 extends {}, StateInit_1 extends {}, EventsInit_1 extends {}, const HostClassKeys_1 extends `${TagName_1}-${string}`, const CssVarKeys_1 extends `${TagName_1}-${string}`, const SlotNames_1 extends readonly string[]>(inputs: import("element-vir").VerifiedElementNoInputsInit<TagName_1, Inputs_1, StateInit_1, EventsInit_1, HostClassKeys_1, CssVarKeys_1, SlotNames_1>) => import("element-vir").DeclarativeElementDefinition<TagName_1, Inputs_1, StateInit_1, EventsInit_1, HostClassKeys_1, CssVarKeys_1, SlotNames_1>;
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 {}>() => <const TagName extends `vira-${string}`, StateInit extends {}, EventsInit extends {}, const HostClassKeys extends `${TagName}-${string}` = `${TagName}-`, const CssVarKeys extends `${TagName}-${string}` = `${TagName}-`, const SlotNames extends ReadonlyArray<string> = readonly []>(inputs: import("element-vir").VerifiedElementInit<TagName, Inputs, StateInit, EventsInit, HostClassKeys, CssVarKeys, SlotNames>) => import("element-vir").DeclarativeElementDefinition<TagName, Inputs, StateInit, EventsInit, HostClassKeys, CssVarKeys, SlotNames>;
19
+ /**
20
+ * Define a vira element with custom requirements (like the `vira-` element tag prefix).
21
+ *
22
+ * @category Internal
23
+ */
24
+ export declare const defineViraElementNoInputs: <const TagName extends `vira-${string}`, Inputs extends {}, StateInit extends {}, EventsInit extends {}, const HostClassKeys extends `${TagName}-${string}` = `${TagName}-`, const CssVarKeys extends `${TagName}-${string}` = `${TagName}-`, const SlotNames extends ReadonlyArray<string> = readonly []>(inputs: import("element-vir").VerifiedElementNoInputsInit<TagName, Inputs, StateInit, EventsInit, HostClassKeys, CssVarKeys, SlotNames>) => import("element-vir").DeclarativeElementDefinition<TagName, Inputs, StateInit, EventsInit, HostClassKeys, CssVarKeys, SlotNames>;
@@ -1,9 +1,26 @@
1
1
  import { wrapDefineElement } from 'element-vir';
2
+ /**
3
+ * Required prefix for all vira elements.
4
+ *
5
+ * @category Internal
6
+ */
2
7
  export const ViraTagNamePrefix = `vira-`;
3
- export const { defineElement: defineViraElement, defineElementNoInputs: defineViraElementNoInputs } = wrapDefineElement({
8
+ const { defineElement, defineElementNoInputs } = wrapDefineElement({
4
9
  assertInputs: (inputs) => {
5
10
  if (!inputs.tagName.startsWith(ViraTagNamePrefix)) {
6
11
  throw new Error(`Tag name should start with '${ViraTagNamePrefix}' but got '${inputs.tagName}'`);
7
12
  }
8
13
  },
9
14
  });
15
+ /**
16
+ * Define a vira element with custom requirements (like the `vira-` element tag prefix).
17
+ *
18
+ * @category Internal
19
+ */
20
+ export const defineViraElement = defineElement;
21
+ /**
22
+ * Define a vira element with custom requirements (like the `vira-` element tag prefix).
23
+ *
24
+ * @category Internal
25
+ */
26
+ export const defineViraElementNoInputs = defineElementNoInputs;
@@ -1,14 +1,37 @@
1
- import { PopUpManager, ShowPopUpResult } from '../../util/pop-up-manager';
2
- import { ViraDropdownOption } from './vira-dropdown-item.element';
1
+ import { PopUpManager, ShowPopUpResult } from '../../util/pop-up-manager.js';
2
+ import { ViraDropdownOption } from './vira-dropdown-item.element.js';
3
+ /**
4
+ * Filters an array of {@link ViraDropdownOption} based on the given selection.
5
+ *
6
+ * @category Internal
7
+ */
3
8
  export declare function filterToSelectedOptions({ selected, options, isMultiSelect, }: Readonly<{
4
9
  selected: ReadonlyArray<PropertyKey>;
5
10
  isMultiSelect?: boolean | undefined;
6
11
  options: ReadonlyArray<Readonly<ViraDropdownOption>>;
7
12
  }>): ViraDropdownOption[];
13
+ /**
14
+ * Verifies that all options have unique ids.
15
+ *
16
+ * @category Internal
17
+ */
8
18
  export declare function assertUniqueIdProps(options: ReadonlyArray<Readonly<{
9
19
  id: PropertyKey;
10
20
  }>>): void;
11
- export declare function createNewSelection(id: PropertyKey, currentSelection: ReadonlyArray<PropertyKey>, isMultiSelect: boolean): PropertyKey[];
21
+ /**
22
+ * Creates a new array of selections based on the current selection and new selection id. This
23
+ * behaves differently when multi select is enabled, hence this function.
24
+ *
25
+ * @category Internal
26
+ */
27
+ export declare function createNewSelection(
28
+ /** The id of the option that should be newly selected. */
29
+ id: PropertyKey, currentSelection: ReadonlyArray<PropertyKey>, isMultiSelect: boolean): PropertyKey[];
30
+ /**
31
+ * Handles toggles pop up state for `ViraDropdown`.
32
+ *
33
+ * @category Internal
34
+ */
12
35
  export declare function triggerPopUpState({ open, emitEvent }: {
13
36
  open: boolean;
14
37
  emitEvent: boolean;
@@ -1,10 +1,14 @@
1
1
  import { joinWithFinalConjunction } from '@augment-vir/common';
2
- import { ViraDropdown } from './vira-dropdown.element';
2
+ /**
3
+ * Filters an array of {@link ViraDropdownOption} based on the given selection.
4
+ *
5
+ * @category Internal
6
+ */
3
7
  export function filterToSelectedOptions({ selected, options, isMultiSelect, }) {
4
8
  if (selected.length && options.length) {
5
9
  const selectedOptions = options.filter((option) => selected.includes(option.id));
6
10
  if (selectedOptions.length > 1 && !isMultiSelect) {
7
- console.error(`${ViraDropdown.tagName} has multiple selections but \`isMultiSelect\` is not \`true\`. Truncating to the first selection.`);
11
+ console.error(`vira-dropdown has multiple selections but \`isMultiSelect\` is not \`true\`. Truncating to the first selection.`);
8
12
  return selectedOptions.slice(0, 1);
9
13
  }
10
14
  else {
@@ -15,6 +19,11 @@ export function filterToSelectedOptions({ selected, options, isMultiSelect, }) {
15
19
  return [];
16
20
  }
17
21
  }
22
+ /**
23
+ * Verifies that all options have unique ids.
24
+ *
25
+ * @category Internal
26
+ */
18
27
  export function assertUniqueIdProps(options) {
19
28
  const usedIds = new Set();
20
29
  const duplicateIds = [];
@@ -30,7 +39,16 @@ export function assertUniqueIdProps(options) {
30
39
  throw new Error(`Duplicate option ids were given to ViraDropdown: ${joinWithFinalConjunction(duplicateIds)}`);
31
40
  }
32
41
  }
33
- export function createNewSelection(id, currentSelection, isMultiSelect) {
42
+ /**
43
+ * Creates a new array of selections based on the current selection and new selection id. This
44
+ * behaves differently when multi select is enabled, hence this function.
45
+ *
46
+ * @category Internal
47
+ */
48
+ export function createNewSelection(
49
+ /** The id of the option that should be newly selected. */
50
+ id, currentSelection, isMultiSelect) {
51
+ // eslint-disable-next-line sonarjs/no-selector-parameter
34
52
  if (isMultiSelect) {
35
53
  return currentSelection.includes(id)
36
54
  ? currentSelection.filter((entry) => entry !== id)
@@ -43,6 +61,11 @@ export function createNewSelection(id, currentSelection, isMultiSelect) {
43
61
  return [id];
44
62
  }
45
63
  }
64
+ /**
65
+ * Handles toggles pop up state for `ViraDropdown`.
66
+ *
67
+ * @category Internal
68
+ */
46
69
  export function triggerPopUpState({ open, emitEvent }, { updateState, popUpManager, dispatch, host, }) {
47
70
  if (open) {
48
71
  updateState({ showPopUpResult: popUpManager.showPopUp(host) });
@@ -1,16 +1,27 @@
1
- import { PartialAndUndefined } from '@augment-vir/common';
1
+ import { PartialWithUndefined } from '@augment-vir/common';
2
2
  import { HTMLTemplateResult } from 'element-vir';
3
+ /**
4
+ * An individual option for ViraDropdown.
5
+ *
6
+ * @category Dropdown
7
+ */
3
8
  export type ViraDropdownOption = {
4
9
  /** Each `id` must be unique across all options. */
5
10
  id: PropertyKey;
6
11
  label: string;
7
- } & PartialAndUndefined<{
8
- disabled?: boolean | undefined;
9
- hoverText?: string | undefined;
12
+ } & PartialWithUndefined<{
13
+ disabled: boolean;
14
+ hoverText: string;
10
15
  /** An optional custom template for this option. */
11
- template?: HTMLTemplateResult | undefined;
16
+ template: HTMLTemplateResult;
12
17
  }>;
18
+ /**
19
+ * An element for an individual item in the ViraDropdown menu.
20
+ *
21
+ * @category Dropdown
22
+ * @category Elements
23
+ */
13
24
  export declare const ViraDropdownItem: import("element-vir").DeclarativeElementDefinition<"vira-dropdown-item", {
14
25
  label: string;
15
26
  selected: boolean;
16
- }, {}, {}, "vira-dropdown-item-selected", `vira-dropdown-item-${string}`, readonly string[]>;
27
+ }, {}, {}, "vira-dropdown-item-selected", "vira-dropdown-item-", readonly []>;
@@ -1,9 +1,15 @@
1
1
  import { css, html } from 'element-vir';
2
- import { Check24Icon } from '../../icons/icon-svgs/check-24.icon';
3
- import { noUserSelect, viraAnimationDurations } from '../../styles';
4
- import { viraBorders } from '../../styles/border';
5
- import { defineViraElement } from '../define-vira-element';
6
- import { ViraIcon } from '../vira-icon.element';
2
+ import { Check24Icon } from '../../icons/icon-svgs/check-24.icon.js';
3
+ import { viraBorders } from '../../styles/border.js';
4
+ import { noUserSelect, viraAnimationDurations } from '../../styles/index.js';
5
+ import { defineViraElement } from '../define-vira-element.js';
6
+ import { ViraIcon } from '../vira-icon.element.js';
7
+ /**
8
+ * An element for an individual item in the ViraDropdown menu.
9
+ *
10
+ * @category Dropdown
11
+ * @category Elements
12
+ */
7
13
  export const ViraDropdownItem = defineViraElement()({
8
14
  tagName: 'vira-dropdown-item',
9
15
  hostClasses: {
@@ -52,7 +58,7 @@ export const ViraDropdownItem = defineViraElement()({
52
58
  ${viraBorders['vira-form-input-radius'].value} 0 0;
53
59
  }
54
60
  `,
55
- renderCallback({ inputs }) {
61
+ render({ inputs }) {
56
62
  return html `
57
63
  <div class="option">
58
64
  <${ViraIcon.assign({ icon: Check24Icon })}></${ViraIcon}>
@@ -1,7 +1,18 @@
1
- import { ViraDropdownOption } from './vira-dropdown-item.element';
1
+ import { ViraDropdownOption } from './vira-dropdown-item.element.js';
2
+ /**
3
+ * Test ids for {@link ViraDropdownOptions}.
4
+ *
5
+ * @category Internal
6
+ */
2
7
  export declare const viraDropdownOptionsTestIds: {
3
8
  option: string;
4
9
  };
10
+ /**
11
+ * The dropdown menu portion of `ViraDropdown`.
12
+ *
13
+ * @category Dropdown
14
+ * @category Elements
15
+ */
5
16
  export declare const ViraDropdownOptions: import("element-vir").DeclarativeElementDefinition<"vira-dropdown-options", Readonly<{
6
17
  /** All dropdown options to show to the user. */
7
18
  options: ReadonlyArray<Readonly<ViraDropdownOption>>;
@@ -12,5 +23,5 @@ export declare const ViraDropdownOptions: import("element-vir").DeclarativeEleme
12
23
  */
13
24
  selectedOptions: ReadonlyArray<Readonly<ViraDropdownOption>>;
14
25
  }>, {}, {
15
- selectionChange: import("element-vir").DefinedTypedEventNameDefinition<Readonly<ViraDropdownOption>>;
16
- }, `vira-dropdown-options-${string}`, `vira-dropdown-options-${string}`, readonly string[]>;
26
+ selectionChange: import("element-vir").DefineEvent<Readonly<ViraDropdownOption>>;
27
+ }, "vira-dropdown-options-", "vira-dropdown-options-", readonly []>;
@@ -1,14 +1,25 @@
1
1
  import { nav, navSelector } from 'device-navigation';
2
2
  import { classMap, css, defineElementEvent, html, ifDefined, listen, nothing, testId, } from 'element-vir';
3
- import { viraDisabledStyles } from '../../styles';
4
- import { viraBorders } from '../../styles/border';
5
- import { viraFormCssVars } from '../../styles/form-themes';
6
- import { viraShadows } from '../../styles/shadows';
7
- import { defineViraElement } from '../define-vira-element';
8
- import { ViraDropdownItem } from './vira-dropdown-item.element';
3
+ import { viraBorders } from '../../styles/border.js';
4
+ import { viraFormCssVars } from '../../styles/form-themes.js';
5
+ import { viraDisabledStyles } from '../../styles/index.js';
6
+ import { viraShadows } from '../../styles/shadows.js';
7
+ import { defineViraElement } from '../define-vira-element.js';
8
+ import { ViraDropdownItem } from './vira-dropdown-item.element.js';
9
+ /**
10
+ * Test ids for {@link ViraDropdownOptions}.
11
+ *
12
+ * @category Internal
13
+ */
9
14
  export const viraDropdownOptionsTestIds = {
10
15
  option: 'dropdown-option',
11
16
  };
17
+ /**
18
+ * The dropdown menu portion of `ViraDropdown`.
19
+ *
20
+ * @category Dropdown
21
+ * @category Elements
22
+ */
12
23
  export const ViraDropdownOptions = defineViraElement()({
13
24
  tagName: 'vira-dropdown-options',
14
25
  events: {
@@ -53,7 +64,7 @@ export const ViraDropdownOptions = defineViraElement()({
53
64
  pointer-events: auto;
54
65
  }
55
66
  `,
56
- renderCallback({ inputs, dispatch, events }) {
67
+ render({ inputs, dispatch, events }) {
57
68
  const optionTemplates = inputs.options.map((option) => {
58
69
  const innerTemplate = option.template ||
59
70
  html `
@@ -1,19 +1,31 @@
1
- import { PartialAndUndefined } from '@augment-vir/common';
1
+ import { PartialWithUndefined } from '@augment-vir/common';
2
2
  import { NavController } from 'device-navigation';
3
- import { ViraIconSvg } from '../../icons/icon-svg';
4
- import { PopUpManager, ShowPopUpResult } from '../../util/pop-up-manager';
5
- import { ViraDropdownOption } from './vira-dropdown-item.element';
3
+ import { ViraIconSvg } from '../../icons/icon-svg.js';
4
+ import { PopUpManager, ShowPopUpResult } from '../../util/pop-up-manager.js';
5
+ import { ViraDropdownOption } from './vira-dropdown-item.element.js';
6
+ /**
7
+ * Test ids for {@link ViraDropdown}.
8
+ *
9
+ * @category Internal
10
+ */
6
11
  export declare const viraDropdownTestIds: {
7
12
  trigger: string;
8
13
  icon: string;
9
14
  prefix: string;
10
15
  options: string;
11
16
  };
17
+ /**
18
+ * The main dropdown element that should be use directly.
19
+ *
20
+ * @category Dropdown
21
+ * @category Elements
22
+ * @see https://electrovir.github.io/element-vir/vira/book/elements/dropdown/vira-dropdown
23
+ */
12
24
  export declare const ViraDropdown: import("element-vir").DeclarativeElementDefinition<"vira-dropdown", {
13
25
  options: ReadonlyArray<Readonly<ViraDropdownOption>>;
14
26
  /** The selected id from the given options. */
15
27
  selected: ReadonlyArray<PropertyKey>;
16
- } & PartialAndUndefined<{
28
+ } & PartialWithUndefined<{
17
29
  /** Text to show if nothing is selected. */
18
30
  placeholder: string;
19
31
  /**
@@ -32,6 +44,6 @@ export declare const ViraDropdown: import("element-vir").DeclarativeElementDefin
32
44
  popUpManager: PopUpManager;
33
45
  navController: NavController | undefined;
34
46
  }, {
35
- selectedChange: import("element-vir").DefinedTypedEventNameDefinition<PropertyKey[]>;
36
- openChange: import("element-vir").DefinedTypedEventNameDefinition<boolean>;
37
- }, "vira-dropdown-disabled", `vira-dropdown-${string}`, readonly string[]>;
47
+ selectedChange: import("element-vir").DefineEvent<PropertyKey[]>;
48
+ openChange: import("element-vir").DefineEvent<boolean>;
49
+ }, "vira-dropdown-disabled", "vira-dropdown-", readonly []>;
@@ -1,23 +1,35 @@
1
+ import { assert } from '@augment-vir/assert';
1
2
  import { NavController } from 'device-navigation';
2
3
  import { classMap, css, defineElementEvent, html, ifDefined, listen, perInstance, renderIf, testId, } from 'element-vir';
3
- import { assertInstanceOf } from 'run-time-assertions';
4
- import { ChevronUp24Icon } from '../../icons/index';
5
- import { noNativeFormStyles, noUserSelect, viraAnimationDurations, viraDisabledStyles, } from '../../styles';
6
- import { viraBorders } from '../../styles/border';
7
- import { createFocusStyles, viraFocusCssVars } from '../../styles/focus';
8
- import { viraFormCssVars } from '../../styles/form-themes';
9
- import { viraShadows } from '../../styles/shadows';
10
- import { HidePopUpEvent, NavSelectEvent, PopUpManager, } from '../../util/pop-up-manager';
11
- import { defineViraElement } from '../define-vira-element';
12
- import { ViraIcon } from '../vira-icon.element';
13
- import { assertUniqueIdProps, createNewSelection, filterToSelectedOptions, triggerPopUpState, } from './dropdown-helpers';
14
- import { ViraDropdownOptions } from './vira-dropdown-options.element';
4
+ import { ChevronUp24Icon } from '../../icons/index.js';
5
+ import { viraBorders } from '../../styles/border.js';
6
+ import { createFocusStyles, viraFocusCssVars } from '../../styles/focus.js';
7
+ import { viraFormCssVars } from '../../styles/form-themes.js';
8
+ import { noNativeFormStyles, noUserSelect, viraAnimationDurations, viraDisabledStyles, } from '../../styles/index.js';
9
+ import { viraShadows } from '../../styles/shadows.js';
10
+ import { HidePopUpEvent, NavSelectEvent, PopUpManager, } from '../../util/pop-up-manager.js';
11
+ import { defineViraElement } from '../define-vira-element.js';
12
+ import { ViraIcon } from '../vira-icon.element.js';
13
+ import { assertUniqueIdProps, createNewSelection, filterToSelectedOptions, triggerPopUpState, } from './dropdown-helpers.js';
14
+ import { ViraDropdownOptions } from './vira-dropdown-options.element.js';
15
+ /**
16
+ * Test ids for {@link ViraDropdown}.
17
+ *
18
+ * @category Internal
19
+ */
15
20
  export const viraDropdownTestIds = {
16
21
  trigger: 'dropdown-trigger',
17
22
  icon: 'dropdown-icon',
18
23
  prefix: 'dropdown-prefix',
19
24
  options: 'dropdown-options',
20
25
  };
26
+ /**
27
+ * The main dropdown element that should be use directly.
28
+ *
29
+ * @category Dropdown
30
+ * @category Elements
31
+ * @see https://electrovir.github.io/element-vir/vira/book/elements/dropdown/vira-dropdown
32
+ */
21
33
  export const ViraDropdown = defineViraElement()({
22
34
  tagName: 'vira-dropdown',
23
35
  hostClasses: {
@@ -148,16 +160,16 @@ export const ViraDropdown = defineViraElement()({
148
160
  popUpManager: perInstance(() => new PopUpManager()),
149
161
  navController: undefined,
150
162
  },
151
- cleanupCallback({ state, updateState }) {
163
+ cleanup({ state, updateState }) {
152
164
  updateState({ showPopUpResult: undefined });
153
165
  state.popUpManager.destroy();
154
166
  },
155
- initCallback({ state, updateState, host, inputs, dispatch, events }) {
167
+ init({ state, updateState, host, inputs, dispatch, events }) {
156
168
  state.popUpManager.listen(HidePopUpEvent, () => {
157
169
  updateState({ showPopUpResult: undefined });
158
170
  if (!inputs.isDisabled) {
159
171
  const dropdownWrapper = host.shadowRoot.querySelector('.dropdown-wrapper');
160
- assertInstanceOf(dropdownWrapper, HTMLButtonElement, 'failed to find dropdown wrapper child');
172
+ assert.instanceOf(dropdownWrapper, HTMLButtonElement, 'failed to find dropdown wrapper child');
161
173
  dropdownWrapper.focus();
162
174
  }
163
175
  });
@@ -182,7 +194,7 @@ export const ViraDropdown = defineViraElement()({
182
194
  });
183
195
  updateState({ navController: new NavController(host) });
184
196
  },
185
- renderCallback({ dispatch, events, state, inputs, updateState, host }) {
197
+ render({ dispatch, events, state, inputs, updateState, host }) {
186
198
  assertUniqueIdProps(inputs.options);
187
199
  function triggerPopUp(param) {
188
200
  triggerPopUpState(param, {
@@ -1,11 +1,11 @@
1
1
  /** This file is automatically updated by update-index-exports.ts */
2
- export * from './define-vira-element';
3
- export * from './dropdown/vira-dropdown-item.element';
4
- export * from './dropdown/vira-dropdown-options.element';
5
- export * from './dropdown/vira-dropdown.element';
6
- export * from './vira-button.element';
7
- export * from './vira-collapsible-wrapper.element';
8
- export * from './vira-icon.element';
9
- export * from './vira-image.element';
10
- export * from './vira-input.element';
11
- export * from './vira-link.element';
2
+ export * from './define-vira-element.js';
3
+ export * from './dropdown/vira-dropdown-item.element.js';
4
+ export * from './dropdown/vira-dropdown-options.element.js';
5
+ export * from './dropdown/vira-dropdown.element.js';
6
+ export * from './vira-button.element.js';
7
+ export * from './vira-collapsible-wrapper.element.js';
8
+ export * from './vira-icon.element.js';
9
+ export * from './vira-image.element.js';
10
+ export * from './vira-input.element.js';
11
+ export * from './vira-link.element.js';
@@ -1,11 +1,11 @@
1
1
  /** This file is automatically updated by update-index-exports.ts */
2
- export * from './define-vira-element';
3
- export * from './dropdown/vira-dropdown-item.element';
4
- export * from './dropdown/vira-dropdown-options.element';
5
- export * from './dropdown/vira-dropdown.element';
6
- export * from './vira-button.element';
7
- export * from './vira-collapsible-wrapper.element';
8
- export * from './vira-icon.element';
9
- export * from './vira-image.element';
10
- export * from './vira-input.element';
11
- export * from './vira-link.element';
2
+ export * from './define-vira-element.js';
3
+ export * from './dropdown/vira-dropdown-item.element.js';
4
+ export * from './dropdown/vira-dropdown-options.element.js';
5
+ export * from './dropdown/vira-dropdown.element.js';
6
+ export * from './vira-button.element.js';
7
+ export * from './vira-collapsible-wrapper.element.js';
8
+ export * from './vira-icon.element.js';
9
+ export * from './vira-image.element.js';
10
+ export * from './vira-input.element.js';
11
+ export * from './vira-link.element.js';
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Inputs shared between the multiple input elements.
3
+ *
4
+ * @category Internal
5
+ */
1
6
  export type SharedTextInputElementInputs = {
2
7
  value: string;
3
8
  /** Shown when no other text is present. Input restrictions do not apply to this property. */
@@ -19,15 +24,30 @@ export type SharedTextInputElementInputs = {
19
24
  /** Set this to true to make the whole element size to only fit the input text. */
20
25
  fitText?: boolean;
21
26
  };
27
+ /**
28
+ * Inputs used to check if the current input element value is allowed.
29
+ *
30
+ * @category Internal
31
+ */
22
32
  export type IsAllowedInputs = {
23
33
  value: string;
24
34
  allowed: string | RegExp | undefined;
25
35
  blocked: string | RegExp | undefined;
26
36
  };
37
+ /**
38
+ * Filters out blocked text from an input element's value.
39
+ *
40
+ * @category Internal
41
+ */
27
42
  export declare function filterTextInputValue(inputs: IsAllowedInputs): {
28
43
  filtered: string;
29
44
  blocked: string;
30
45
  };
46
+ /**
47
+ * A function to be called when an input element's value changes.
48
+ *
49
+ * @category Internal
50
+ */
31
51
  export declare function textInputListener({ inputs, filteredValue, event, inputBlockedCallback, newValueCallback, }: {
32
52
  inputs: SharedTextInputElementInputs;
33
53
  filteredValue: string;
@@ -1,4 +1,4 @@
1
- import { extractEventTarget } from '@augment-vir/browser';
1
+ import { extractEventTarget } from '@augment-vir/web';
2
2
  function doesMatch({ input, matcher }) {
3
3
  if (!input || !matcher) {
4
4
  return true;
@@ -28,6 +28,11 @@ function isAllowed({ value, allowed, blocked }) {
28
28
  : false;
29
29
  return isAllowedCharacter && !isBlockedCharacter;
30
30
  }
31
+ /**
32
+ * Filters out blocked text from an input element's value.
33
+ *
34
+ * @category Internal
35
+ */
31
36
  export function filterTextInputValue(inputs) {
32
37
  if (!inputs.value) {
33
38
  return { filtered: inputs.value, blocked: '' };
@@ -50,9 +55,14 @@ export function filterTextInputValue(inputs) {
50
55
  blocked: blocked.join(''),
51
56
  };
52
57
  }
58
+ /**
59
+ * A function to be called when an input element's value changes.
60
+ *
61
+ * @category Internal
62
+ */
53
63
  export function textInputListener({ inputs, filteredValue, event, inputBlockedCallback, newValueCallback, }) {
54
64
  if (!(event instanceof InputEvent)) {
55
- throw new Error('Text input event was not an InputEvent.');
65
+ throw new TypeError('Text input event was not an InputEvent.');
56
66
  }
57
67
  const inputElement = extractEventTarget(event, HTMLInputElement);
58
68
  /**
@@ -62,7 +72,7 @@ export function textInputListener({ inputs, filteredValue, event, inputBlockedCa
62
72
  const changedText = event.data;
63
73
  const beforeChangeText = filteredValue;
64
74
  // this will be overwritten below if blocked characters are encountered
65
- let finalText = inputElement.value ?? '';
75
+ let finalText = inputElement.value;
66
76
  /**
67
77
  * When changedText is falsy, that means an operation other than inserting characters happened.
68
78
  * Such as: deleting, cutting the text, etc.
@@ -1,11 +1,23 @@
1
- import { ViraIconSvg } from '../icons';
2
- export declare enum ViraButtonStyleEnum {
1
+ import { ViraIconSvg } from '../icons/index.js';
2
+ /**
3
+ * Button styles available for {@link ViraButton}.
4
+ *
5
+ * @category Button
6
+ */
7
+ export declare enum ViraButtonStyle {
3
8
  Default = "vira-button-default",
4
9
  Outline = "vira-button-outline"
5
10
  }
11
+ /**
12
+ * A custom button with default styling.
13
+ *
14
+ * @category Button
15
+ * @category Elements
16
+ * @see https://electrovir.github.io/element-vir/vira/book/elements/vira-button
17
+ */
6
18
  export declare const ViraButton: import("element-vir").DeclarativeElementDefinition<"vira-button", {
7
19
  text?: string;
8
- icon?: undefined | Pick<ViraIconSvg, 'svgTemplate'>;
20
+ icon?: undefined | Pick<ViraIconSvg, "svgTemplate">;
9
21
  disabled?: boolean | undefined;
10
- buttonStyle?: ViraButtonStyleEnum | undefined;
11
- }, {}, {}, "vira-button-outline-style" | "vira-button-disabled", "vira-button-primary-color" | "vira-button-primary-hover-color" | "vira-button-primary-active-color" | "vira-button-secondary-color" | "vira-button-padding" | "vira-button-internal-foreground-color" | "vira-button-internal-background-color", readonly string[]>;
22
+ buttonStyle?: ViraButtonStyle | undefined;
23
+ }, {}, {}, "vira-button-outline-style" | "vira-button-disabled", "vira-button-primary-color" | "vira-button-primary-hover-color" | "vira-button-primary-active-color" | "vira-button-secondary-color" | "vira-button-padding" | "vira-button-internal-foreground-color" | "vira-button-internal-background-color", readonly []>;
@@ -1,21 +1,33 @@
1
1
  import { css, html } from 'element-vir';
2
- import { noUserSelect } from '../styles';
3
- import { viraBorders } from '../styles/border';
4
- import { viraDisabledStyles } from '../styles/disabled';
5
- import { viraAnimationDurations } from '../styles/durations';
6
- import { createFocusStyles, viraFocusCssVars } from '../styles/focus';
7
- import { noNativeFormStyles } from '../styles/native-styles';
8
- import { defineViraElement } from './define-vira-element';
9
- import { ViraIcon } from './vira-icon.element';
10
- export var ViraButtonStyleEnum;
11
- (function (ViraButtonStyleEnum) {
12
- ViraButtonStyleEnum["Default"] = "vira-button-default";
13
- ViraButtonStyleEnum["Outline"] = "vira-button-outline";
14
- })(ViraButtonStyleEnum || (ViraButtonStyleEnum = {}));
2
+ import { viraBorders } from '../styles/border.js';
3
+ import { viraDisabledStyles } from '../styles/disabled.js';
4
+ import { viraAnimationDurations } from '../styles/durations.js';
5
+ import { createFocusStyles, viraFocusCssVars } from '../styles/focus.js';
6
+ import { noUserSelect } from '../styles/index.js';
7
+ import { noNativeFormStyles } from '../styles/native-styles.js';
8
+ import { defineViraElement } from './define-vira-element.js';
9
+ import { ViraIcon } from './vira-icon.element.js';
10
+ /**
11
+ * Button styles available for {@link ViraButton}.
12
+ *
13
+ * @category Button
14
+ */
15
+ export var ViraButtonStyle;
16
+ (function (ViraButtonStyle) {
17
+ ViraButtonStyle["Default"] = "vira-button-default";
18
+ ViraButtonStyle["Outline"] = "vira-button-outline";
19
+ })(ViraButtonStyle || (ViraButtonStyle = {}));
20
+ /**
21
+ * A custom button with default styling.
22
+ *
23
+ * @category Button
24
+ * @category Elements
25
+ * @see https://electrovir.github.io/element-vir/vira/book/elements/vira-button
26
+ */
15
27
  export const ViraButton = defineViraElement()({
16
28
  tagName: 'vira-button',
17
29
  hostClasses: {
18
- 'vira-button-outline-style': ({ inputs }) => inputs.buttonStyle === ViraButtonStyleEnum.Outline,
30
+ 'vira-button-outline-style': ({ inputs }) => inputs.buttonStyle === ViraButtonStyle.Outline,
19
31
  'vira-button-disabled': ({ inputs }) => !!inputs.disabled,
20
32
  },
21
33
  cssVars: {
@@ -95,7 +107,7 @@ export const ViraButton = defineViraElement()({
95
107
  margin-left: 8px;
96
108
  }
97
109
  `,
98
- renderCallback: ({ inputs }) => {
110
+ render: ({ inputs }) => {
99
111
  const iconTemplate = inputs.icon
100
112
  ? html `
101
113
  <${ViraIcon.assign({