govuk_publishing_components 58.1.1 → 59.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 (165) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/images/select-with-search/cross-icon.svg +6 -0
  3. data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-search-tracker.js +4 -0
  4. data/app/assets/javascripts/govuk_publishing_components/components/select-with-search.js +57 -0
  5. data/app/assets/stylesheets/govuk_publishing_components/_all_components.scss +2 -0
  6. data/app/assets/stylesheets/govuk_publishing_components/components/_action-link.scss +14 -136
  7. data/app/assets/stylesheets/govuk_publishing_components/components/_heading.scss +0 -5
  8. data/app/assets/stylesheets/govuk_publishing_components/components/_layout-header.scss +6 -48
  9. data/app/assets/stylesheets/govuk_publishing_components/components/_select-with-search.scss +168 -0
  10. data/app/assets/stylesheets/govuk_publishing_components/components/_select.scss +6 -0
  11. data/app/assets/stylesheets/govuk_publishing_components/components/_tag.scss +14 -0
  12. data/app/assets/stylesheets/govuk_publishing_components/components/helpers/_markdown-typography.scss +1 -1
  13. data/app/views/govuk_publishing_components/components/_action_link.html.erb +4 -37
  14. data/app/views/govuk_publishing_components/components/_layout_header.html.erb +0 -2
  15. data/app/views/govuk_publishing_components/components/_select.html.erb +22 -23
  16. data/app/views/govuk_publishing_components/components/_select_with_search.html.erb +14 -0
  17. data/app/views/govuk_publishing_components/components/_share_links.html.erb +17 -9
  18. data/app/views/govuk_publishing_components/components/_tag.html.erb +20 -0
  19. data/app/views/govuk_publishing_components/components/docs/action_link.yml +0 -62
  20. data/app/views/govuk_publishing_components/components/docs/layout_header.yml +13 -0
  21. data/app/views/govuk_publishing_components/components/docs/select.yml +11 -0
  22. data/app/views/govuk_publishing_components/components/docs/select_with_search.yml +196 -0
  23. data/app/views/govuk_publishing_components/components/docs/share_links.yml +10 -0
  24. data/app/views/govuk_publishing_components/components/docs/signup_link.yml +0 -7
  25. data/app/views/govuk_publishing_components/components/docs/single_page_notification_button.yml +1 -7
  26. data/app/views/govuk_publishing_components/components/docs/subscription_links.yml +1 -7
  27. data/app/views/govuk_publishing_components/components/docs/tag.yml +57 -0
  28. data/app/views/govuk_publishing_components/components/layout_header/_header_logo.html.erb +16 -5
  29. data/lib/govuk_publishing_components/presenters/heading_helper.rb +1 -2
  30. data/lib/govuk_publishing_components/presenters/select_helper.rb +8 -5
  31. data/lib/govuk_publishing_components/presenters/select_with_search_helper.rb +92 -0
  32. data/lib/govuk_publishing_components/presenters/single_page_notification_button_helper.rb +1 -1
  33. data/lib/govuk_publishing_components/version.rb +1 -1
  34. data/lib/govuk_publishing_components.rb +1 -0
  35. data/node_modules/choices.js/LICENSE +21 -0
  36. data/node_modules/choices.js/README.md +1360 -0
  37. data/node_modules/choices.js/package.json +173 -0
  38. data/node_modules/choices.js/public/assets/scripts/choices.js +5230 -0
  39. data/node_modules/choices.js/public/assets/scripts/choices.min.js +2 -0
  40. data/node_modules/choices.js/public/assets/scripts/choices.mjs +5222 -0
  41. data/node_modules/choices.js/public/assets/scripts/choices.search-basic.js +4748 -0
  42. data/node_modules/choices.js/public/assets/scripts/choices.search-basic.min.js +2 -0
  43. data/node_modules/choices.js/public/assets/scripts/choices.search-basic.mjs +4740 -0
  44. data/node_modules/choices.js/public/assets/scripts/choices.search-kmp.js +3631 -0
  45. data/node_modules/choices.js/public/assets/scripts/choices.search-kmp.min.js +2 -0
  46. data/node_modules/choices.js/public/assets/scripts/choices.search-kmp.mjs +3623 -0
  47. data/node_modules/choices.js/public/assets/scripts/choices.search-prefix.js +3590 -0
  48. data/node_modules/choices.js/public/assets/scripts/choices.search-prefix.min.js +2 -0
  49. data/node_modules/choices.js/public/assets/scripts/choices.search-prefix.mjs +3582 -0
  50. data/node_modules/choices.js/public/assets/styles/base.css +180 -0
  51. data/node_modules/choices.js/public/assets/styles/base.css.map +1 -0
  52. data/node_modules/choices.js/public/assets/styles/base.min.css +1 -0
  53. data/node_modules/choices.js/public/assets/styles/choices.css +338 -0
  54. data/node_modules/choices.js/public/assets/styles/choices.css.map +1 -0
  55. data/node_modules/choices.js/public/assets/styles/choices.min.css +1 -0
  56. data/node_modules/choices.js/public/types/src/index.d.ts +6 -0
  57. data/node_modules/choices.js/public/types/src/scripts/actions/choices.d.ts +30 -0
  58. data/node_modules/choices.js/public/types/src/scripts/actions/groups.d.ts +8 -0
  59. data/node_modules/choices.js/public/types/src/scripts/actions/items.d.ts +17 -0
  60. data/node_modules/choices.js/public/types/src/scripts/choices.d.ts +210 -0
  61. data/node_modules/choices.js/public/types/src/scripts/components/container.d.ts +36 -0
  62. data/node_modules/choices.js/public/types/src/scripts/components/dropdown.d.ts +21 -0
  63. data/node_modules/choices.js/public/types/src/scripts/components/index.d.ts +7 -0
  64. data/node_modules/choices.js/public/types/src/scripts/components/input.d.ts +37 -0
  65. data/node_modules/choices.js/public/types/src/scripts/components/list.d.ts +14 -0
  66. data/node_modules/choices.js/public/types/src/scripts/components/wrapped-element.d.ts +21 -0
  67. data/node_modules/choices.js/public/types/src/scripts/components/wrapped-input.d.ts +3 -0
  68. data/node_modules/choices.js/public/types/src/scripts/components/wrapped-select.d.ts +20 -0
  69. data/node_modules/choices.js/public/types/src/scripts/constants.d.ts +1 -0
  70. data/node_modules/choices.js/public/types/src/scripts/defaults.d.ts +4 -0
  71. data/node_modules/choices.js/public/types/src/scripts/interfaces/action-type.d.ts +13 -0
  72. data/node_modules/choices.js/public/types/src/scripts/interfaces/build-flags.d.ts +11 -0
  73. data/node_modules/choices.js/public/types/src/scripts/interfaces/choice-full.d.ts +23 -0
  74. data/node_modules/choices.js/public/types/src/scripts/interfaces/class-names.d.ts +61 -0
  75. data/node_modules/choices.js/public/types/src/scripts/interfaces/event-choice.d.ts +7 -0
  76. data/node_modules/choices.js/public/types/src/scripts/interfaces/event-type.d.ts +14 -0
  77. data/node_modules/choices.js/public/types/src/scripts/interfaces/group-full.d.ts +10 -0
  78. data/node_modules/choices.js/public/types/src/scripts/interfaces/index.d.ts +14 -0
  79. data/node_modules/choices.js/public/types/src/scripts/interfaces/input-choice.d.ts +15 -0
  80. data/node_modules/choices.js/public/types/src/scripts/interfaces/input-group.d.ts +10 -0
  81. data/node_modules/choices.js/public/types/src/scripts/interfaces/item.d.ts +17 -0
  82. data/node_modules/choices.js/public/types/src/scripts/interfaces/keycode-map.d.ts +13 -0
  83. data/node_modules/choices.js/public/types/src/scripts/interfaces/options.d.ts +566 -0
  84. data/node_modules/choices.js/public/types/src/scripts/interfaces/passed-element-type.d.ts +7 -0
  85. data/node_modules/choices.js/public/types/src/scripts/interfaces/passed-element.d.ts +95 -0
  86. data/node_modules/choices.js/public/types/src/scripts/interfaces/position-options-type.d.ts +1 -0
  87. data/node_modules/choices.js/public/types/src/scripts/interfaces/search.d.ts +11 -0
  88. data/node_modules/choices.js/public/types/src/scripts/interfaces/state.d.ts +10 -0
  89. data/node_modules/choices.js/public/types/src/scripts/interfaces/store.d.ts +64 -0
  90. data/node_modules/choices.js/public/types/src/scripts/interfaces/string-pre-escaped.d.ts +3 -0
  91. data/node_modules/choices.js/public/types/src/scripts/interfaces/string-untrusted.d.ts +4 -0
  92. data/node_modules/choices.js/public/types/src/scripts/interfaces/templates.d.ts +29 -0
  93. data/node_modules/choices.js/public/types/src/scripts/interfaces/types.d.ts +18 -0
  94. data/node_modules/choices.js/public/types/src/scripts/lib/choice-input.d.ts +9 -0
  95. data/node_modules/choices.js/public/types/src/scripts/lib/html-guard-statements.d.ts +4 -0
  96. data/node_modules/choices.js/public/types/src/scripts/lib/utils.d.ts +31 -0
  97. data/node_modules/choices.js/public/types/src/scripts/reducers/choices.d.ts +8 -0
  98. data/node_modules/choices.js/public/types/src/scripts/reducers/groups.d.ts +8 -0
  99. data/node_modules/choices.js/public/types/src/scripts/reducers/items.d.ts +9 -0
  100. data/node_modules/choices.js/public/types/src/scripts/search/fuse.d.ts +14 -0
  101. data/node_modules/choices.js/public/types/src/scripts/search/index.d.ts +3 -0
  102. data/node_modules/choices.js/public/types/src/scripts/search/kmp.d.ts +11 -0
  103. data/node_modules/choices.js/public/types/src/scripts/search/prefix-filter.d.ts +11 -0
  104. data/node_modules/choices.js/public/types/src/scripts/store/store.d.ts +59 -0
  105. data/node_modules/choices.js/public/types/src/scripts/templates.d.ts +8 -0
  106. data/node_modules/choices.js/src/entry.js +3 -0
  107. data/node_modules/choices.js/src/icons/cross-inverse.svg +1 -0
  108. data/node_modules/choices.js/src/icons/cross.svg +1 -0
  109. data/node_modules/choices.js/src/index.ts +8 -0
  110. data/node_modules/choices.js/src/scripts/actions/choices.ts +59 -0
  111. data/node_modules/choices.js/src/scripts/actions/groups.ts +14 -0
  112. data/node_modules/choices.js/src/scripts/actions/items.ts +34 -0
  113. data/node_modules/choices.js/src/scripts/choices.ts +2364 -0
  114. data/node_modules/choices.js/src/scripts/components/container.ts +157 -0
  115. data/node_modules/choices.js/src/scripts/components/dropdown.ts +50 -0
  116. data/node_modules/choices.js/src/scripts/components/index.ts +8 -0
  117. data/node_modules/choices.js/src/scripts/components/input.ts +146 -0
  118. data/node_modules/choices.js/src/scripts/components/list.ts +89 -0
  119. data/node_modules/choices.js/src/scripts/components/wrapped-element.ts +89 -0
  120. data/node_modules/choices.js/src/scripts/components/wrapped-input.ts +3 -0
  121. data/node_modules/choices.js/src/scripts/components/wrapped-select.ts +115 -0
  122. data/node_modules/choices.js/src/scripts/constants.ts +1 -0
  123. data/node_modules/choices.js/src/scripts/defaults.ts +93 -0
  124. data/node_modules/choices.js/src/scripts/interfaces/action-type.ts +15 -0
  125. data/node_modules/choices.js/src/scripts/interfaces/build-flags.ts +17 -0
  126. data/node_modules/choices.js/src/scripts/interfaces/choice-full.ts +30 -0
  127. data/node_modules/choices.js/src/scripts/interfaces/class-names.ts +61 -0
  128. data/node_modules/choices.js/src/scripts/interfaces/event-choice.ts +9 -0
  129. data/node_modules/choices.js/src/scripts/interfaces/event-type.ts +16 -0
  130. data/node_modules/choices.js/src/scripts/interfaces/group-full.ts +12 -0
  131. data/node_modules/choices.js/src/scripts/interfaces/index.ts +14 -0
  132. data/node_modules/choices.js/src/scripts/interfaces/input-choice.ts +17 -0
  133. data/node_modules/choices.js/src/scripts/interfaces/input-group.ts +11 -0
  134. data/node_modules/choices.js/src/scripts/interfaces/item.ts +17 -0
  135. data/node_modules/choices.js/src/scripts/interfaces/keycode-map.ts +13 -0
  136. data/node_modules/choices.js/src/scripts/interfaces/options.ts +619 -0
  137. data/node_modules/choices.js/src/scripts/interfaces/passed-element-type.ts +9 -0
  138. data/node_modules/choices.js/src/scripts/interfaces/passed-element.ts +96 -0
  139. data/node_modules/choices.js/src/scripts/interfaces/position-options-type.ts +1 -0
  140. data/node_modules/choices.js/src/scripts/interfaces/search.ts +12 -0
  141. data/node_modules/choices.js/src/scripts/interfaces/state.ts +12 -0
  142. data/node_modules/choices.js/src/scripts/interfaces/store.ts +84 -0
  143. data/node_modules/choices.js/src/scripts/interfaces/string-pre-escaped.ts +3 -0
  144. data/node_modules/choices.js/src/scripts/interfaces/string-untrusted.ts +5 -0
  145. data/node_modules/choices.js/src/scripts/interfaces/templates.ts +66 -0
  146. data/node_modules/choices.js/src/scripts/interfaces/types.ts +21 -0
  147. data/node_modules/choices.js/src/scripts/lib/choice-input.ts +88 -0
  148. data/node_modules/choices.js/src/scripts/lib/html-guard-statements.ts +7 -0
  149. data/node_modules/choices.js/src/scripts/lib/utils.ts +230 -0
  150. data/node_modules/choices.js/src/scripts/reducers/choices.ts +86 -0
  151. data/node_modules/choices.js/src/scripts/reducers/groups.ts +32 -0
  152. data/node_modules/choices.js/src/scripts/reducers/items.ts +86 -0
  153. data/node_modules/choices.js/src/scripts/search/fuse.ts +59 -0
  154. data/node_modules/choices.js/src/scripts/search/index.ts +17 -0
  155. data/node_modules/choices.js/src/scripts/search/kmp.ts +87 -0
  156. data/node_modules/choices.js/src/scripts/search/prefix-filter.ts +42 -0
  157. data/node_modules/choices.js/src/scripts/store/store.ts +184 -0
  158. data/node_modules/choices.js/src/scripts/templates.ts +409 -0
  159. data/node_modules/choices.js/src/styles/base.scss +189 -0
  160. data/node_modules/choices.js/src/styles/choices.scss +414 -0
  161. data/node_modules/choices.js/src/tsconfig.json +22 -0
  162. metadata +137 -4
  163. data/app/assets/images/govuk_publishing_components/action-link-arrow--dark.svg +0 -5
  164. data/app/assets/images/govuk_publishing_components/action-link-arrow--simple-light.svg +0 -4
  165. data/app/assets/images/govuk_publishing_components/action-link-arrow.svg +0 -5
@@ -0,0 +1,93 @@
1
+ import { ClassNames } from './interfaces/class-names';
2
+ import { Options } from './interfaces/options';
3
+ import { sortByAlpha } from './lib/utils';
4
+
5
+ export const DEFAULT_CLASSNAMES: ClassNames = {
6
+ containerOuter: ['choices'],
7
+ containerInner: ['choices__inner'],
8
+ input: ['choices__input'],
9
+ inputCloned: ['choices__input--cloned'],
10
+ list: ['choices__list'],
11
+ listItems: ['choices__list--multiple'],
12
+ listSingle: ['choices__list--single'],
13
+ listDropdown: ['choices__list--dropdown'],
14
+ item: ['choices__item'],
15
+ itemSelectable: ['choices__item--selectable'],
16
+ itemDisabled: ['choices__item--disabled'],
17
+ itemChoice: ['choices__item--choice'],
18
+ description: ['choices__description'],
19
+ placeholder: ['choices__placeholder'],
20
+ group: ['choices__group'],
21
+ groupHeading: ['choices__heading'],
22
+ button: ['choices__button'],
23
+ activeState: ['is-active'],
24
+ focusState: ['is-focused'],
25
+ openState: ['is-open'],
26
+ disabledState: ['is-disabled'],
27
+ highlightedState: ['is-highlighted'],
28
+ selectedState: ['is-selected'],
29
+ flippedState: ['is-flipped'],
30
+ loadingState: ['is-loading'],
31
+ notice: ['choices__notice'],
32
+ addChoice: ['choices__item--selectable', 'add-choice'],
33
+ noResults: ['has-no-results'],
34
+ noChoices: ['has-no-choices'],
35
+ } as const;
36
+
37
+ export const DEFAULT_CONFIG: Options = {
38
+ items: [],
39
+ choices: [],
40
+ silent: false,
41
+ renderChoiceLimit: -1,
42
+ maxItemCount: -1,
43
+ closeDropdownOnSelect: 'auto',
44
+ singleModeForMultiSelect: false,
45
+ addChoices: false,
46
+ addItems: true,
47
+ addItemFilter: (value) => !!value && value !== '',
48
+ removeItems: true,
49
+ removeItemButton: false,
50
+ removeItemButtonAlignLeft: false,
51
+ editItems: false,
52
+ allowHTML: false,
53
+ allowHtmlUserInput: false,
54
+ duplicateItemsAllowed: true,
55
+ delimiter: ',',
56
+ paste: true,
57
+ searchEnabled: true,
58
+ searchChoices: true,
59
+ searchFloor: 1,
60
+ searchResultLimit: 4,
61
+ searchFields: ['label', 'value'],
62
+ position: 'auto',
63
+ resetScrollPosition: true,
64
+ shouldSort: true,
65
+ shouldSortItems: false,
66
+ sorter: sortByAlpha,
67
+ shadowRoot: null,
68
+ placeholder: true,
69
+ placeholderValue: null,
70
+ searchPlaceholderValue: null,
71
+ prependValue: null,
72
+ appendValue: null,
73
+ renderSelectedChoices: 'auto',
74
+ loadingText: 'Loading...',
75
+ noResultsText: 'No results found',
76
+ noChoicesText: 'No choices to choose from',
77
+ itemSelectText: 'Press to select',
78
+ uniqueItemText: 'Only unique values can be added',
79
+ customAddItemText: 'Only values matching specific conditions can be added',
80
+ addItemText: (value) => `Press Enter to add <b>"${value}"</b>`,
81
+ removeItemIconText: () => `Remove item`,
82
+ removeItemLabelText: (value) => `Remove item: ${value}`,
83
+ maxItemText: (maxItemCount) => `Only ${maxItemCount} values can be added`,
84
+ valueComparer: (value1, value2) => value1 === value2,
85
+ fuseOptions: {
86
+ includeScore: true,
87
+ },
88
+ labelId: '',
89
+ callbackOnInit: null,
90
+ callbackOnCreateTemplates: null,
91
+ classNames: DEFAULT_CLASSNAMES,
92
+ appendGroupInSearch: false,
93
+ } as const;
@@ -0,0 +1,15 @@
1
+ import { Types } from './types';
2
+
3
+ export const ActionType = {
4
+ ADD_CHOICE: 'ADD_CHOICE',
5
+ REMOVE_CHOICE: 'REMOVE_CHOICE',
6
+ FILTER_CHOICES: 'FILTER_CHOICES',
7
+ ACTIVATE_CHOICES: 'ACTIVATE_CHOICES',
8
+ CLEAR_CHOICES: 'CLEAR_CHOICES',
9
+ ADD_GROUP: 'ADD_GROUP',
10
+ ADD_ITEM: 'ADD_ITEM',
11
+ REMOVE_ITEM: 'REMOVE_ITEM',
12
+ HIGHLIGHT_ITEM: 'HIGHLIGHT_ITEM',
13
+ } as const;
14
+
15
+ export type ActionTypes = Types.ValueOf<typeof ActionType>;
@@ -0,0 +1,17 @@
1
+ export const canUseDom: boolean =
2
+ process.env.CHOICES_CAN_USE_DOM !== undefined
3
+ ? process.env.CHOICES_CAN_USE_DOM === '1'
4
+ : !!(typeof document !== 'undefined' && document.createElement);
5
+
6
+ export const searchFuse: string | undefined = process.env.CHOICES_SEARCH_FUSE;
7
+ export const searchKMP: boolean = process.env.CHOICES_SEARCH_KMP === '1';
8
+
9
+ /**
10
+ * These are not directly used, as an exported object (even as const) will prevent tree-shake away code paths
11
+ */
12
+
13
+ export const BuildFlags = {
14
+ searchFuse,
15
+ searchKMP,
16
+ canUseDom,
17
+ } as const;
@@ -0,0 +1,30 @@
1
+ import { StringUntrusted } from './string-untrusted';
2
+ import { Types } from './types';
3
+ // eslint-disable-next-line import/no-cycle
4
+ import { GroupFull } from './group-full';
5
+
6
+ /*
7
+ A disabled choice appears in the choice dropdown but cannot be selected
8
+ A selected choice has been added to the passed input's value (added as an item)
9
+ An active choice appears within the choice dropdown (ie search sets active to false if it doesn't match)
10
+ */
11
+ export interface ChoiceFull {
12
+ id: number;
13
+ highlighted: boolean;
14
+ element?: HTMLOptionElement | HTMLOptGroupElement;
15
+ itemEl?: HTMLElement;
16
+ choiceEl?: HTMLElement;
17
+ labelClass?: Array<string>;
18
+ labelDescription?: string;
19
+ customProperties?: Types.CustomProperties;
20
+ disabled: boolean;
21
+ active: boolean;
22
+ elementId?: string;
23
+ group: GroupFull | null;
24
+ label: StringUntrusted | string;
25
+ placeholder: boolean;
26
+ selected: boolean;
27
+ value: string;
28
+ score: number;
29
+ rank: number;
30
+ }
@@ -0,0 +1,61 @@
1
+ /** Classes added to HTML generated by By default classnames follow the BEM notation. */
2
+ export interface ClassNames {
3
+ /** @default ['choices'] */
4
+ containerOuter: string | Array<string>;
5
+ /** @default ['choices__inner'] */
6
+ containerInner: string | Array<string>;
7
+ /** @default ['choices__input'] */
8
+ input: string | Array<string>;
9
+ /** @default ['choices__input--cloned'] */
10
+ inputCloned: string | Array<string>;
11
+ /** @default ['choices__list'] */
12
+ list: string | Array<string>;
13
+ /** @default ['choices__list--multiple'] */
14
+ listItems: string | Array<string>;
15
+ /** @default ['choices__list--single'] */
16
+ listSingle: string | Array<string>;
17
+ /** @default ['choices__list--dropdown'] */
18
+ listDropdown: string | Array<string>;
19
+ /** @default ['choices__item'] */
20
+ item: string | Array<string>;
21
+ /** @default ['choices__item--selectable'] */
22
+ itemSelectable: string | Array<string>;
23
+ /** @default ['choices__item--disabled'] */
24
+ itemDisabled: string | Array<string>;
25
+ /** @default ['choices__item--choice'] */
26
+ itemChoice: string | Array<string>;
27
+ /** @default ['choices__description'] */
28
+ description: string | Array<string>;
29
+ /** @default ['choices__placeholder'] */
30
+ placeholder: string | Array<string>;
31
+ /** @default ['choices__group'] */
32
+ group: string | Array<string>;
33
+ /** @default ['choices__heading'] */
34
+ groupHeading: string | Array<string>;
35
+ /** @default ['choices__button'] */
36
+ button: string | Array<string>;
37
+ /** @default ['is-active'] */
38
+ activeState: string | Array<string>;
39
+ /** @default ['is-focused'] */
40
+ focusState: string | Array<string>;
41
+ /** @default ['is-open'] */
42
+ openState: string | Array<string>;
43
+ /** @default ['is-disabled'] */
44
+ disabledState: string | Array<string>;
45
+ /** @default ['is-highlighted'] */
46
+ highlightedState: string | Array<string>;
47
+ /** @default ['is-selected'] */
48
+ selectedState: string | Array<string>;
49
+ /** @default ['is-flipped'] */
50
+ flippedState: string | Array<string>;
51
+ /** @default ['is-loading'] */
52
+ loadingState: string | Array<string>;
53
+ /** @default ['choices__notice'] */
54
+ notice: string | Array<string>;
55
+ /** @default ['choices__item--selectable', 'add-choice'] */
56
+ addChoice: string | Array<string>;
57
+ /** @default ['has-no-results'] */
58
+ noResults: string | Array<string>;
59
+ /** @default ['has-no-choices'] */
60
+ noChoices: string | Array<string>;
61
+ }
@@ -0,0 +1,9 @@
1
+ import { InputChoice } from './input-choice';
2
+
3
+ export type EventChoiceValueType<B extends boolean> = B extends true ? string : EventChoice;
4
+
5
+ export interface EventChoice extends InputChoice {
6
+ element?: HTMLOptionElement | HTMLOptGroupElement;
7
+ groupValue?: string;
8
+ keyCode?: number;
9
+ }
@@ -0,0 +1,16 @@
1
+ import { Types } from './types';
2
+
3
+ export const EventType = {
4
+ showDropdown: 'showDropdown',
5
+ hideDropdown: 'hideDropdown',
6
+ change: 'change',
7
+ choice: 'choice',
8
+ search: 'search',
9
+ addItem: 'addItem',
10
+ removeItem: 'removeItem',
11
+ highlightItem: 'highlightItem',
12
+ highlightChoice: 'highlightChoice',
13
+ unhighlightItem: 'unhighlightItem',
14
+ } as const;
15
+
16
+ export type EventTypes = Types.ValueOf<typeof EventType>;
@@ -0,0 +1,12 @@
1
+ // eslint-disable-next-line import/no-cycle
2
+ import { ChoiceFull } from './choice-full';
3
+
4
+ export interface GroupFull {
5
+ id: number;
6
+ active: boolean;
7
+ disabled: boolean;
8
+ label?: string;
9
+ element?: HTMLOptGroupElement;
10
+ groupEl?: HTMLElement;
11
+ choices: ChoiceFull[];
12
+ }
@@ -0,0 +1,14 @@
1
+ export * from './action-type';
2
+ export * from './input-choice';
3
+ export * from './input-group';
4
+ export * from './event-choice';
5
+ export * from './class-names';
6
+ export * from './event-type';
7
+ export * from './item';
8
+ export * from './keycode-map';
9
+ export * from './options';
10
+ export * from './passed-element';
11
+ export * from './passed-element-type';
12
+ export * from './position-options-type';
13
+ export * from './state';
14
+ export * from './types';
@@ -0,0 +1,17 @@
1
+ import { StringUntrusted } from './string-untrusted';
2
+ import { Types } from './types';
3
+
4
+ export interface InputChoice {
5
+ id?: number;
6
+ highlighted?: boolean;
7
+ labelClass?: string | Array<string>;
8
+ labelDescription?: string;
9
+ customProperties?: Types.CustomProperties;
10
+ disabled?: boolean;
11
+ active?: boolean;
12
+ label: StringUntrusted | string;
13
+ placeholder?: boolean;
14
+ selected?: boolean;
15
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
+ value: any;
17
+ }
@@ -0,0 +1,11 @@
1
+ import { InputChoice } from './input-choice';
2
+ import { StringUntrusted } from './string-untrusted';
3
+
4
+ export interface InputGroup {
5
+ id?: number;
6
+ active?: boolean;
7
+ disabled?: boolean;
8
+ label?: StringUntrusted | string;
9
+ value: string;
10
+ choices: InputChoice[];
11
+ }
@@ -0,0 +1,17 @@
1
+ import { InputChoice } from './input-choice';
2
+ import { InputGroup } from './input-group';
3
+
4
+ /**
5
+ * @deprecated Use InputChoice instead
6
+ */
7
+ export interface Item extends InputChoice {}
8
+
9
+ /**
10
+ * @deprecated Use InputChoice instead
11
+ */
12
+ export interface Choice extends InputChoice {}
13
+
14
+ /**
15
+ * @deprecated Use InputGroup instead
16
+ */
17
+ export interface Group extends InputGroup {}
@@ -0,0 +1,13 @@
1
+ export const KeyCodeMap = {
2
+ TAB_KEY: 9,
3
+ SHIFT_KEY: 16,
4
+ BACK_KEY: 46,
5
+ DELETE_KEY: 8,
6
+ ENTER_KEY: 13,
7
+ A_KEY: 65,
8
+ ESC_KEY: 27,
9
+ UP_KEY: 38,
10
+ DOWN_KEY: 40,
11
+ PAGE_UP_KEY: 33,
12
+ PAGE_DOWN_KEY: 34,
13
+ } as const;