@ironsource/shared-ui 1.4.3 → 2.0.0-rc.1

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 (179) hide show
  1. package/AddFilterButton.vue_vue_type_style_index_0_scoped_true_lang.css +1 -1
  2. package/AppTrigger.vue_vue_type_style_index_0_scoped_true_lang.css +1 -1
  3. package/AutocompleteDropdown.vue_vue_type_style_index_0_scoped_true_lang.css +1 -1
  4. package/AutocompleteInput.vue_vue_type_style_index_0_scoped_true_lang.css +1 -1
  5. package/Banner.vue_vue_type_style_index_0_scoped_true_lang.css +1 -1
  6. package/Button.vue_vue_type_style_index_0_scoped_true_lang.css +1 -1
  7. package/ButtonBase.vue_vue_type_style_index_0_scoped_true_lang.css +1 -1
  8. package/ButtonV4.vue_vue_type_style_index_0_scoped_true_lang.css +1 -0
  9. package/CalendarMonth.vue_vue_type_style_index_0_scoped_true_lang.css +1 -1
  10. package/Chip.vue_vue_type_style_index_0_scoped_true_lang.css +1 -1
  11. package/ChipV4.vue_vue_type_style_index_0_scoped_true_lang.css +1 -0
  12. package/DateRange.vue_vue_type_style_index_0_scoped_true_lang.css +1 -1
  13. package/Dialog.vue_vue_type_style_index_0_scoped_true_lang.css +1 -1
  14. package/Dropdown.vue_vue_type_style_index_0_scoped_true_lang.css +1 -1
  15. package/Dropdown.vue_vue_type_style_index_1_lang.css +1 -1
  16. package/DropdownV4.vue_vue_type_style_index_0_scoped_true_lang.css +1 -0
  17. package/DropdownV4.vue_vue_type_style_index_1_lang.css +1 -0
  18. package/Editable.vue_vue_type_style_index_0_scoped_true_lang.css +1 -1
  19. package/EmptyState.vue_vue_type_style_index_0_scoped_true_lang.css +1 -1
  20. package/FilterDropdown.vue_vue_type_style_index_0_scoped_true_lang.css +1 -1
  21. package/FilterSearchInput.vue_vue_type_style_index_0_scoped_true_lang.css +1 -1
  22. package/FloatingToolbar.vue_vue_type_style_index_0_scoped_true_lang.css +1 -1
  23. package/GroupOption.vue_vue_type_style_index_0_scoped_true_lang.css +1 -1
  24. package/IconButton.vue_vue_type_style_index_0_scoped_true_lang.css +1 -1
  25. package/IncludeExclude.vue_vue_type_style_index_0_scoped_true_lang.css +1 -1
  26. package/IncludeExcludeAppTrigger.vue_vue_type_style_index_0_scoped_true_lang.css +1 -1
  27. package/IncludeExcludeChipFilter.vue_vue_type_style_index_0_scoped_true_lang.css +1 -1
  28. package/IncludeExcludeDragDrop.vue_vue_type_style_index_0_scoped_true_lang.css +1 -1
  29. package/IncludeExcludeOptionDraggable.vue_vue_type_style_index_0_scoped_true_lang.css +1 -1
  30. package/Input.vue_vue_type_style_index_0_scoped_true_lang.css +1 -1
  31. package/Label.vue_vue_type_style_index_0_scoped_true_lang.css +1 -1
  32. package/Menu.vue_vue_type_style_index_1_lang.css +1 -1
  33. package/MenuItem.vue_vue_type_style_index_0_scoped_true_lang.css +1 -1
  34. package/Option.vue_vue_type_style_index_0_scoped_true_lang.css +1 -1
  35. package/Popover.vue_vue_type_style_index_0_lang.css +1 -1
  36. package/README.md +1 -1
  37. package/ScrollButton.vue_vue_type_style_index_0_scoped_true_lang.css +1 -1
  38. package/Search.vue_vue_type_style_index_0_scoped_true_lang.css +1 -1
  39. package/SearchInput.vue_vue_type_style_index_0_scoped_true_lang.css +1 -1
  40. package/SearchV4.vue_vue_type_style_index_0_scoped_true_lang.css +1 -0
  41. package/Snackbar.vue_vue_type_style_index_0_scoped_true_lang.css +1 -1
  42. package/Switch.vue_vue_type_style_index_0_scoped_true_lang.css +1 -1
  43. package/SwitchV4.vue_vue_type_style_index_0_scoped_true_lang.css +1 -0
  44. package/Table.vue_vue_type_style_index_0_scoped_true_lang.css +1 -1
  45. package/Table.vue_vue_type_style_index_1_lang.css +1 -1
  46. package/Tabs.vue_vue_type_style_index_0_scoped_true_lang.css +1 -1
  47. package/TextArea.vue_vue_type_style_index_0_scoped_true_lang.css +1 -1
  48. package/Toggle.vue_vue_type_style_index_0_scoped_true_lang.css +1 -1
  49. package/Typography.vue_vue_type_style_index_0_scoped_true_lang.css +1 -0
  50. package/commonCssVariables.scss +623 -0
  51. package/components/ThemeWrapper/ThemeStrore.d.ts +4 -0
  52. package/components/ThemeWrapper/ThemeWrapper.vue.d.ts +15 -0
  53. package/components/appTrigger/AppTrigger.vue.js +4 -4
  54. package/components/autocompleteDropdown/AutocompleteDropdown.vue.js +4 -3
  55. package/components/autocompleteDropdown/AutocompleteInput.vue.js +2 -2
  56. package/components/autocompleteDropdown/GroupOption.vue.js +2 -2
  57. package/components/button/common/ButtonBase.vue.d.ts +48 -0
  58. package/components/button/{ButtonBase.vue.js → common/ButtonBase.vue.js} +7 -7
  59. package/components/button/{Button.vue.d.ts → common/ButtonSuper.vue.d.ts} +3 -3
  60. package/components/button/{ButtonBase.vue.d.ts → v3/Button.vue.d.ts} +20 -4
  61. package/components/button/v3/Button.vue.js +102 -0
  62. package/components/button/{IconButton.vue.js → v3/IconButton.vue.js} +7 -7
  63. package/components/button/{ScrollButton.vue.js → v3/ScrollButton.vue.js} +6 -6
  64. package/components/button/v3/index.d.ts +79 -0
  65. package/components/button/v4/ButtonV4.vue.d.ts +57 -0
  66. package/components/button/v4/ButtonV4.vue.js +99 -0
  67. package/components/button/{index.d.ts → v4/index.d.ts} +33 -76
  68. package/components/button/v4/index.vue.js +6 -0
  69. package/components/checkbox/Checkbox.vue.d.ts +1 -1
  70. package/components/checkbox/index.d.ts +9 -9
  71. package/components/chip/{Chip.vue.js → v3/Chip.vue.js} +5 -5
  72. package/components/chip/v4/ChipV4.vue.d.ts +48 -0
  73. package/components/chip/v4/ChipV4.vue.js +76 -0
  74. package/components/chip/v4/index.d.ts +63 -0
  75. package/components/chip/v4/index.vue.js +6 -0
  76. package/components/dateRange/CalendarMonth.vue.js +3 -3
  77. package/components/dateRange/DateRange.vue.js +4 -4
  78. package/components/dialog/Dialog.vue.d.ts +1 -1
  79. package/components/dialog/Dialog.vue.js +8 -7
  80. package/components/dialog/index.d.ts +11 -11
  81. package/components/dropdown/common/Dropdown.common.d.ts +36 -0
  82. package/components/dropdown/common/Dropdown.common.vue.js +456 -0
  83. package/components/dropdown/{Label.vue.js → common/Label.vue.js} +5 -5
  84. package/components/dropdown/{Option.vue.js → common/Option.vue.js} +7 -7
  85. package/components/dropdown/{SearchInput.vue.js → common/SearchInput.vue.js} +8 -7
  86. package/components/dropdown/{Dropdown.vue.d.ts → v3/Dropdown.vue.d.ts} +15 -5
  87. package/components/dropdown/v3/Dropdown.vue.js +391 -0
  88. package/components/dropdown/{index.d.ts → v3/index.d.ts} +42 -20
  89. package/components/dropdown/v3/index.vue.js +12 -0
  90. package/components/dropdown/v4/DropdownV4.vue.d.ts +223 -0
  91. package/components/dropdown/v4/DropdownV4.vue.js +408 -0
  92. package/components/dropdown/v4/index.d.ts +433 -0
  93. package/components/dropdown/v4/index.vue.js +6 -0
  94. package/components/emptyState/EmptyState.vue.d.ts +1 -1
  95. package/components/emptyState/EmptyState.vue.js +4 -4
  96. package/components/emptyState/index.d.ts +11 -11
  97. package/components/filterDropdown/AddFilterButton.vue.js +2 -2
  98. package/components/filterDropdown/FilterDropdown.vue.js +5 -4
  99. package/components/filtersPanel/Filter.d.ts +1 -1
  100. package/components/filtersPanel/FilterSearchInput.vue.js +6 -6
  101. package/components/floatingToolbar/FloatingToolbar.vue.js +6 -5
  102. package/components/includeExclude/IncludeExclude.vue.d.ts +1 -1
  103. package/components/includeExclude/IncludeExclude.vue.js +4 -4
  104. package/components/includeExclude/IncludeExcludeAppHeader.vue.js +2 -2
  105. package/components/includeExclude/IncludeExcludeAppTrigger.vue.js +4 -4
  106. package/components/includeExclude/IncludeExcludeChipFilter.vue.js +3 -3
  107. package/components/includeExclude/IncludeExcludeDragDrop.vue.d.ts +1 -1
  108. package/components/includeExclude/IncludeExcludeDragDrop.vue.js +4 -4
  109. package/components/includeExclude/index.d.ts +22 -22
  110. package/components/input/Input.vue.d.ts +2 -2
  111. package/components/input/Input.vue.js +4 -4
  112. package/components/input/index.d.ts +16 -16
  113. package/components/menu/Menu.vue.d.ts +1 -1
  114. package/components/menu/index.d.ts +5 -5
  115. package/components/search/common/Search.common.d.ts +9 -0
  116. package/components/search/common/Search.common.vue.js +52 -0
  117. package/components/search/{Search.vue.js → v3/Search.vue.js} +19 -46
  118. package/components/search/{index.d.ts → v3/index.d.ts} +3 -3
  119. package/components/search/v4/SearchV4.vue.d.ts +51 -0
  120. package/components/search/v4/SearchV4.vue.js +70 -0
  121. package/components/search/v4/index.d.ts +72 -0
  122. package/components/search/v4/index.vue.js +6 -0
  123. package/components/snackbar/Snackbar.vue.d.ts +1 -1
  124. package/components/snackbar/Snackbar.vue.js +6 -5
  125. package/components/switch/{Switch.vue.js → v3/Switch.vue.js} +5 -5
  126. package/components/switch/v4/SwitchV4.vue.d.ts +37 -0
  127. package/components/switch/v4/SwitchV4.vue.js +87 -0
  128. package/components/switch/v4/index.d.ts +46 -0
  129. package/components/switch/v4/index.vue.js +6 -0
  130. package/components/table/Table.vue.js +3 -3
  131. package/components/table-cells/Editable.vue.js +1 -1
  132. package/components/tooltip/Tooltip.vue.d.ts +1 -1
  133. package/components/tooltip/index.d.ts +5 -5
  134. package/components/typography/index.d.ts +9 -9
  135. package/components/typography/v4/Typography.vue.d.ts +34 -0
  136. package/components/typography/v4/Typography.vue.js +68 -0
  137. package/components/typography/v4/index.d.ts +23 -0
  138. package/components/typography/v4/index.vue.js +6 -0
  139. package/design-foundation.stories/border-radius/BorderRadiusData.d.ts +5 -0
  140. package/design-foundation.stories/border-radius/BorderRadiusWrapper.vue.d.ts +4 -0
  141. package/design-foundation.stories/border-radius/index.d.ts +1 -0
  142. package/design-foundation.stories/colors/ColorsData.d.ts +114 -0
  143. package/design-foundation.stories/colors/ColorsStoryWrapper.vue.d.ts +3 -0
  144. package/design-foundation.stories/colors/index.d.ts +1 -0
  145. package/design-foundation.stories/elevations/ElevationStoryWrapper.vue.d.ts +4 -0
  146. package/design-foundation.stories/elevations/ElevationsData.d.ts +10 -0
  147. package/design-foundation.stories/elevations/index.d.ts +1 -0
  148. package/design-foundation.stories/typography/TypographyData.d.ts +7 -0
  149. package/design-foundation.stories/typography/TypographyStoryWrapper.vue.d.ts +3 -0
  150. package/design-foundation.stories/typography/index.d.ts +1 -0
  151. package/index.d.ts +1532 -5
  152. package/index.vue.js +28 -16
  153. package/package.json +39 -14
  154. package/styleguide.scss +77 -78
  155. package/styles/v4/border-radius.css +8 -0
  156. package/styles/v4/colors.css +100 -0
  157. package/styles/v4/elevations.css +10 -0
  158. package/styles/v4/fonts.css +1 -0
  159. package/styles/v4/fonts.css.map +1 -0
  160. package/styles/v4/fonts.scss +258 -0
  161. package/components/button/Button.vue.js +0 -65
  162. package/components/dropdown/Dropdown.vue.js +0 -785
  163. package/components/dropdown/index.vue.js +0 -12
  164. /package/components/button/{IconButton.vue.d.ts → v3/IconButton.vue.d.ts} +0 -0
  165. /package/components/button/{ScrollButton.vue.d.ts → v3/ScrollButton.vue.d.ts} +0 -0
  166. /package/components/button/{index.vue.js → v3/index.vue.js} +0 -0
  167. /package/components/chip/{Chip.vue.d.ts → v3/Chip.vue.d.ts} +0 -0
  168. /package/components/chip/{index.d.ts → v3/index.d.ts} +0 -0
  169. /package/components/chip/{index.vue.js → v3/index.vue.js} +0 -0
  170. /package/components/dropdown/{DropdownContext.d.ts → common/DropdownContext.d.ts} +0 -0
  171. /package/components/dropdown/{DropdownContext.vue.js → common/DropdownContext.vue.js} +0 -0
  172. /package/components/dropdown/{Label.vue.d.ts → common/Label.vue.d.ts} +0 -0
  173. /package/components/dropdown/{Option.vue.d.ts → common/Option.vue.d.ts} +0 -0
  174. /package/components/dropdown/{SearchInput.vue.d.ts → common/SearchInput.vue.d.ts} +0 -0
  175. /package/components/search/{Search.vue.d.ts → v3/Search.vue.d.ts} +0 -0
  176. /package/components/search/{index.vue.js → v3/index.vue.js} +0 -0
  177. /package/components/switch/{Switch.vue.d.ts → v3/Switch.vue.d.ts} +0 -0
  178. /package/components/switch/{index.d.ts → v3/index.d.ts} +0 -0
  179. /package/components/switch/{index.vue.js → v3/index.vue.js} +0 -0
@@ -1,785 +0,0 @@
1
- import { defineComponent, ref, computed, watch, useSlots, nextTick, toRaw, provide, onMounted, openBlock, createElementBlock, normalizeClass, unref, renderSlot, createVNode, withCtx, Transition, createElementVNode, createTextVNode, toDisplayString, createCommentVNode, createBlock, mergeProps, withModifiers, Fragment, renderList, pushScopeId, popScopeId } from 'vue';
2
- import Button from '../button/Button.vue.js';
3
- import Icon from '../icon/Icon.vue.js';
4
- import { DropdownTestIdModifiers } from '../../testids/index.vue.js';
5
- /* empty css */import _export_sfc from '../../_virtual/plugin-vue_export-helper.vue.js';
6
- import Text from '../typography/Text.vue.js';
7
- /* empty css *//* empty css *//* empty css */import { Dropdown as Dropdown$1 } from 'floating-vue';
8
- /* empty css *//* empty css */import Option from './Option.vue.js';
9
- import Search from '../search/Search.vue.js';
10
- import { useToggle } from '../../composables/useToggle.vue.js';
11
- import { isObjectInArray } from '../../utils/array.vue.js';
12
- import { objectsEqual } from '../../utils/object.vue.js';
13
- import { useClamp, useVirtualList, onClickOutside } from '@vueuse/core';
14
- import { Mode, Type, DropdownContext } from './DropdownContext.vue.js';
15
- import { pxToRem } from '../../utils/style.vue.js';
16
- /* empty css *//* empty css */
17
- import "../../Dropdown.vue_vue_type_style_index_0_scoped_true_lang.css";import "../../Dropdown.vue_vue_type_style_index_1_lang.css";
18
- const _withScopeId = (n) => (pushScopeId("data-v-6b0dd6db"), n = n(), popScopeId(), n);
19
- const _hoisted_1 = ["tabindex", "data-testid"];
20
- const _hoisted_2 = ["disabled", "aria-expanded", "aria-labelledby", "aria-disabled"];
21
- const _hoisted_3 = {
22
- key: 0,
23
- class: "image-slot"
24
- };
25
- const _hoisted_4 = { class: "angle-down" };
26
- const _hoisted_5 = {
27
- key: 0,
28
- class: "dropdown-title"
29
- };
30
- const _hoisted_6 = ["data-testid"];
31
- const _hoisted_7 = ["data-testid"];
32
- const _hoisted_8 = {
33
- key: 0,
34
- class: "no-result-container"
35
- };
36
- const _hoisted_9 = {
37
- key: 1,
38
- class: "loader"
39
- };
40
- const _hoisted_10 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createElementVNode("svg", {
41
- width: "100",
42
- height: "100",
43
- viewBox: "0 0 100 100"
44
- }, [
45
- /* @__PURE__ */ createElementVNode("circle", {
46
- cx: "50",
47
- cy: "50",
48
- fill: "none",
49
- stroke: "currentColor",
50
- "stroke-width": "6",
51
- r: "35",
52
- "stroke-dasharray": "164.93361431346415 56.97787143782138"
53
- }, [
54
- /* @__PURE__ */ createElementVNode("animateTransform", {
55
- attributeName: "transform",
56
- type: "rotate",
57
- repeatCount: "indefinite",
58
- dur: "1s",
59
- values: "0 50 50;360 50 50",
60
- keyTimes: "0;1"
61
- })
62
- ])
63
- ], -1));
64
- const _hoisted_11 = { key: 2 };
65
- const _hoisted_12 = ["aria-selected", "aria-disabled", "onClick"];
66
- const _hoisted_13 = {
67
- key: 0,
68
- class: "actions"
69
- };
70
- const _sfc_main = /* @__PURE__ */ defineComponent({
71
- __name: "Dropdown",
72
- props: {
73
- modelValue: { default: null },
74
- placeholder: { default: "" },
75
- disabled: { type: Boolean, default: false },
76
- mandatory: { type: Boolean, default: false },
77
- helperText: { default: "" },
78
- searchPlaceholder: { default: "" },
79
- isOnTop: { type: Boolean, default: false },
80
- multi: { type: Boolean, default: false },
81
- title: { default: "" },
82
- inlineSearch: { type: Boolean, default: false },
83
- popperClass: { default: "" },
84
- noResultsText: { default: "No results found" },
85
- loading: { type: Boolean },
86
- selected: { default: null },
87
- showSelectAll: { type: Boolean },
88
- defaultOpen: { type: Boolean, default: false },
89
- showButtonOnOpen: { type: Boolean, default: true },
90
- autoFocus: { type: Boolean, default: false },
91
- distance: { default: 0 },
92
- isOpen: { type: Boolean },
93
- skidding: { default: 0 },
94
- placement: { default: "bottom-start" },
95
- clearable: { type: Boolean, default: false },
96
- error: { default: "" },
97
- size: { default: "lg" },
98
- displayValue: null,
99
- options: null,
100
- onSearch: { type: Function, default: () => true },
101
- theme: { default: "is-dropdown" },
102
- container: { default: "body" },
103
- flip: { type: Boolean, default: true },
104
- keepOpen: { type: Boolean, default: false },
105
- autoSize: { type: Boolean, default: false },
106
- disableKeyboardEvents: { type: Boolean, default: false },
107
- multiOptionsPlaceholderPrefix: { default: "" },
108
- multiOptionsPlaceholderSuffix: { default: "" },
109
- testId: { default: "" }
110
- },
111
- emits: ["update:selected", "update:isOpen", "closed", "opened", "apply"],
112
- setup(__props, { expose, emit }) {
113
- const props = __props;
114
- const isSelected = (arr, element) => {
115
- if (props.multi) {
116
- return isObjectInArray(arr, element);
117
- }
118
- return toRaw(arr) === element;
119
- };
120
- const MULTILINE_LIST_HEIGHT = 48;
121
- const LIST_HEIGHT = 34;
122
- const selectedOptionRef = ref(props.selected);
123
- const selectedOption = computed({
124
- get() {
125
- return selectedOptionRef.value;
126
- },
127
- set(value) {
128
- emit("update:selected", value);
129
- }
130
- });
131
- watch(
132
- () => props.selected,
133
- () => {
134
- selectedOptionRef.value = props.selected;
135
- }
136
- );
137
- const slots = useSlots();
138
- const listRef = ref(null);
139
- const inputRef = ref(null);
140
- const el = ref(null);
141
- const activeOption = ref(null);
142
- const labelRef = ref(null);
143
- const buttonRef = ref(null);
144
- const apply = ref(null);
145
- const cancel = ref(null);
146
- const IS_ON_TOP_PADDING = 8;
147
- const location = computed(() => {
148
- return buttonRef.value?.getBoundingClientRect().height + IS_ON_TOP_PADDING + props.distance;
149
- });
150
- const optionsIds = ref([]);
151
- const selectedIndex = ref(-1);
152
- const query = ref("");
153
- const selectedOptionPrevious = ref([]);
154
- const focusButton = () => buttonRef.value?.focus();
155
- const [open, _toggle, disable] = useToggle({
156
- disabled: props.disabled,
157
- initialValue: props.defaultOpen
158
- });
159
- watch(
160
- () => props.disabled,
161
- (value) => {
162
- if (value !== void 0) {
163
- disable(value);
164
- }
165
- }
166
- );
167
- const toggle = (value) => {
168
- isOpen.value = _toggle(value);
169
- };
170
- const isOpen = computed({
171
- get() {
172
- return props.isOpen;
173
- },
174
- set(value) {
175
- emit("update:isOpen", value);
176
- }
177
- });
178
- const maxClamped = computed(() => {
179
- return filteredOptions.value.length - 1;
180
- });
181
- const activeIndex = useClamp(0, 0, maxClamped);
182
- const selectedValue = computed(() => {
183
- if (selectedOption.value) {
184
- return props.displayValue(selectedOption.value);
185
- }
186
- return "";
187
- });
188
- const getMultiselectValueToShow = (selectedOption2) => {
189
- if (!selectedOption2.value.length && !props.multiOptionsPlaceholderPrefix && !props.multiOptionsPlaceholderSuffix)
190
- return props.placeholder;
191
- const multipleOptionsPlaceholder = !props.multiOptionsPlaceholderPrefix && !props.multiOptionsPlaceholderSuffix ? `${selectedOption2.value.length} selected` : `${props.multiOptionsPlaceholderPrefix ?? ""}${selectedOption2.value.length ?? "0"}${props.multiOptionsPlaceholderSuffix ?? ""}`;
192
- return selectedOption2.value.length == 1 && !!props.displayValue ? props.displayValue(selectedOption2.value[0]) : multipleOptionsPlaceholder;
193
- };
194
- const displayedValue = computed(() => {
195
- if (!props.multi) {
196
- return selectedOption.value ? props.displayValue(selectedOption.value) : props.placeholder;
197
- }
198
- if (!Array.isArray(selectedOptionRef.value)) {
199
- return;
200
- }
201
- return getMultiselectValueToShow(selectedOptionRef);
202
- });
203
- const allSelected = computed(() => {
204
- if (!Array.isArray(selectedOptionRef.value)) {
205
- return;
206
- }
207
- return selectedOptionRef.value.length === filteredOptions.value.length;
208
- });
209
- const isIndeterminate = computed(() => {
210
- if (!props.multi) {
211
- return false;
212
- }
213
- if (!Array.isArray(selectedOptionRef.value)) {
214
- return false;
215
- }
216
- return selectedOptionRef.value.length > 0 && selectedOptionRef.value.length < filteredOptions.value.length;
217
- });
218
- const queryChanged = (value) => {
219
- query.value = value;
220
- };
221
- const filteredOptions = computed(
222
- () => props.options.filter((option) => props.onSearch(option, query.value))
223
- );
224
- const hasSubtitle = computed(() => optionsIds.value[0]?.hasSubtitle);
225
- const isMulti = computed(() => api.mode === Mode.Multi);
226
- const itemHeight = computed(
227
- () => hasSubtitle.value ? MULTILINE_LIST_HEIGHT : LIST_HEIGHT
228
- );
229
- const {
230
- list: virtualOptions,
231
- containerProps,
232
- wrapperProps,
233
- scrollTo
234
- } = useVirtualList(filteredOptions, {
235
- itemHeight: itemHeight.value
236
- });
237
- watch(
238
- () => props.isOpen,
239
- (value) => {
240
- toggle(value);
241
- }
242
- );
243
- watch([selectedIndex], async () => {
244
- await nextTick();
245
- });
246
- watch(
247
- [open, activeIndex, selectedIndex],
248
- async ([openNewValue], [openOldValue]) => {
249
- if (!open.value) {
250
- return;
251
- }
252
- await nextTick();
253
- if (selectedIndex.value !== -1 && openNewValue !== openOldValue) {
254
- setTimeout(() => {
255
- scrollTo(selectedIndex.value);
256
- });
257
- }
258
- if (activeIndex.value) {
259
- setTimeout(() => {
260
- scrollTo(activeIndex.value);
261
- });
262
- }
263
- }
264
- );
265
- const toggleMenu = (value, withFocus = false) => {
266
- if (props.disabled) {
267
- return;
268
- }
269
- toggle(value);
270
- nextTick(() => {
271
- if (open.value) {
272
- emit("opened");
273
- }
274
- if (!open.value) {
275
- emit("closed");
276
- }
277
- if (listRef.value && withFocus) {
278
- listRef.value.focus();
279
- }
280
- });
281
- };
282
- watch(open, (isOpen2) => {
283
- if (isOpen2) {
284
- if (isMulti.value && Array.isArray(selectedOption.value)) {
285
- selectedOptionPrevious.value = toRaw(selectedOption.value).slice();
286
- }
287
- return;
288
- }
289
- focusButton();
290
- });
291
- const onSelectAll = () => {
292
- selectAll();
293
- selectedOption.value = selectedOptionRef.value;
294
- };
295
- const selectAll = () => {
296
- if (allSelected.value) {
297
- selectedOptionRef.value = [];
298
- return;
299
- }
300
- if (!Array.isArray(selectedOptionRef.value)) {
301
- return;
302
- }
303
- if (selectedOptionRef.value.length === filteredOptions.value.length) {
304
- selectedOptionRef.value = [];
305
- return;
306
- }
307
- selectedOptionRef.value = filteredOptions.value;
308
- };
309
- const onSelect = (option, index) => {
310
- option = toRaw(option);
311
- const isDisabled = optionsIds.value[index]?.disabled;
312
- if (isDisabled) {
313
- return;
314
- }
315
- selectedIndex.value = index;
316
- if (api.mode !== Mode.Multi) {
317
- if (!props.keepOpen) {
318
- toggleMenu(false);
319
- }
320
- api.goToOption(0 /* None */);
321
- selectedOption.value = option;
322
- queryChanged("");
323
- focusButton();
324
- if (api.type === Type.Search && inputRef.value) {
325
- inputRef.value.value = props.displayValue(option);
326
- }
327
- return;
328
- }
329
- if (!Array.isArray(selectedOptionRef.value)) {
330
- return;
331
- }
332
- inputRef.value?.focus();
333
- const rawSelectedOption = toRaw(selectedOptionRef.value);
334
- if (isObjectInArray(rawSelectedOption, option)) {
335
- selectedOptionRef.value = rawSelectedOption.filter(
336
- (item) => !objectsEqual(item, option)
337
- );
338
- return;
339
- } else {
340
- selectedOptionRef.value = [...rawSelectedOption, option];
341
- return;
342
- }
343
- };
344
- const canFocus = (index) => {
345
- return optionsIds.value[index]?.disabled;
346
- };
347
- const api = {
348
- activeIndex,
349
- options: optionsIds,
350
- selectedOption,
351
- labelRef,
352
- activeOption,
353
- listRef,
354
- clearable: props.clearable,
355
- type: slots.input ? Type.Search : Type.Dropdown,
356
- mode: props.multi ? Mode.Multi : Mode.Single,
357
- query,
358
- selectedValue,
359
- toggle: toggleMenu,
360
- disabled: props.disabled,
361
- open,
362
- mandatory: props.mandatory,
363
- size: props.size,
364
- placeholder: props.placeholder,
365
- select: onSelect,
366
- clearSelection: () => {
367
- queryChanged("");
368
- selectedOption.value = api.mode === Mode.Single ? null : [];
369
- if (inputRef.value) {
370
- inputRef.value.value = "";
371
- }
372
- },
373
- search: queryChanged,
374
- goToOption: async (focus) => {
375
- if (!open.value) {
376
- return;
377
- }
378
- let index = activeIndex.value + focus;
379
- const totalDisabled = optionsIds.value.filter(
380
- (item) => item.disabled
381
- ).length;
382
- const total = filteredOptions.value.length - totalDisabled;
383
- if (index > total) {
384
- index = total + 1;
385
- }
386
- while (true) {
387
- if (!optionsIds.value[index]?.disabled) {
388
- activeOption.value = filteredOptions.value[index];
389
- activeIndex.value = index;
390
- return;
391
- }
392
- if (focus === 1 /* Next */ || focus === 10 /* NextPage */) {
393
- index = index + 1 /* Next */;
394
- }
395
- if (focus === -1 /* Previous */ || focus === -10 /* PrevPage */) {
396
- index = index + -1 /* Previous */;
397
- }
398
- if (!canFocus(activeIndex.value)) {
399
- continue;
400
- }
401
- activeOption.value = filteredOptions.value[index];
402
- activeIndex.value = index;
403
- return;
404
- }
405
- },
406
- registerInput: (ref2) => {
407
- inputRef.value = ref2.value;
408
- },
409
- registerOption: (id, disabled, hasSubtitle2) => {
410
- optionsIds.value = [...optionsIds.value, { id, disabled, hasSubtitle: hasSubtitle2 }];
411
- },
412
- unRegisterOption(id) {
413
- optionsIds.value = optionsIds.value.filter((item) => item.id !== id);
414
- }
415
- };
416
- provide(DropdownContext, api);
417
- onClickOutside(
418
- listRef,
419
- () => {
420
- if (open.value) {
421
- onCancel();
422
- }
423
- },
424
- {
425
- ignore: [buttonRef, apply, cancel, inputRef, containerProps.ref]
426
- }
427
- );
428
- const resetInput = () => {
429
- if (!inputRef.value) {
430
- return;
431
- }
432
- inputRef.value.value = api.query.value = "";
433
- };
434
- onMounted(async () => {
435
- if (props.autoFocus) {
436
- await nextTick();
437
- setTimeout(() => {
438
- el.value.focus();
439
- });
440
- }
441
- api.goToOption(0);
442
- });
443
- const onApply = () => {
444
- selectedOption.value = selectedOptionRef.value;
445
- emit("apply", selectedOption.value);
446
- toggleMenu(false);
447
- resetInput();
448
- };
449
- const onCancel = () => {
450
- if (isMulti.value && Array.isArray(selectedOptionPrevious.value)) {
451
- selectedOption.value = toRaw(selectedOptionPrevious.value).slice();
452
- }
453
- toggleMenu(false);
454
- };
455
- const onButtonKeydown = (event) => {
456
- if (props.disableKeyboardEvents)
457
- return;
458
- switch (event.key) {
459
- case "Space":
460
- case "Enter":
461
- case "ArrowUp":
462
- case "ArrowDown": {
463
- toggleMenu(true);
464
- event.preventDefault();
465
- }
466
- }
467
- };
468
- const onKeydown = (event) => {
469
- if (props.disableKeyboardEvents)
470
- return;
471
- switch (event.key) {
472
- case "ArrowUp": {
473
- api.goToOption(-1 /* Previous */);
474
- event.preventDefault();
475
- event.stopPropagation();
476
- break;
477
- }
478
- case "ArrowDown": {
479
- api.goToOption(1 /* Next */);
480
- event.preventDefault();
481
- event.stopPropagation();
482
- break;
483
- }
484
- case "Escape": {
485
- toggleMenu(false);
486
- event.preventDefault();
487
- break;
488
- }
489
- case "PageUp": {
490
- api.goToOption(10 /* NextPage */);
491
- event.preventDefault();
492
- break;
493
- }
494
- case "PageDown": {
495
- api.goToOption(-10 /* PrevPage */);
496
- event.preventDefault();
497
- break;
498
- }
499
- case "Enter": {
500
- if (!open.value) {
501
- toggleMenu(true);
502
- return;
503
- }
504
- onSelect(filteredOptions.value[activeIndex.value], activeIndex.value);
505
- if (api.mode === Mode.Single && !props.keepOpen) {
506
- toggleMenu(false);
507
- }
508
- event.preventDefault();
509
- break;
510
- }
511
- }
512
- };
513
- const calculateTableHeight = computed(() => {
514
- const MAX_NUMBER_OF_OPTIONS = 7;
515
- const PADDING_PX = 8;
516
- const optionsLength = virtualOptions.value.length;
517
- const showSelectAllAddition = props.showSelectAll ? 1 : 0;
518
- const isThereMoreOptionsThenMax = optionsLength > MAX_NUMBER_OF_OPTIONS;
519
- const numberOfRows = optionsLength + showSelectAllAddition;
520
- const numToCalculate = isThereMoreOptionsThenMax ? MAX_NUMBER_OF_OPTIONS + 0.5 : numberOfRows;
521
- return pxToRem(numToCalculate * itemHeight.value + PADDING_PX);
522
- });
523
- expose({
524
- selectItem: onSelect,
525
- scrollTo
526
- });
527
- return (_ctx, _cache) => {
528
- return openBlock(), createElementBlock("div", {
529
- ref_key: "el",
530
- ref: el,
531
- class: normalizeClass(["dropdown", { "dropdown--disabled": __props.disabled }]),
532
- tabindex: __props.disabled ? -1 : 0,
533
- "data-testid": `${__props.testId}-${unref(DropdownTestIdModifiers).WRAPPER}`,
534
- onKeydown
535
- }, [
536
- renderSlot(_ctx.$slots, "label", {}, void 0, true),
537
- createVNode(unref(Dropdown$1), {
538
- theme: __props.theme,
539
- "popper-class": [
540
- __props.popperClass,
541
- __props.autoSize ? "v-popper--theme-is-dropdown--auto-size" : null
542
- ],
543
- placement: __props.placement,
544
- skidding: __props.isOnTop ? 0 : __props.skidding,
545
- distance: __props.isOnTop ? -unref(location) : __props.distance,
546
- flip: __props.flip,
547
- triggers: [],
548
- shown: !!unref(open),
549
- "auto-hide": false,
550
- container: __props.container,
551
- "auto-size": __props.autoSize,
552
- "data-testid": `${__props.testId}-${unref(DropdownTestIdModifiers).TRIGGER}`
553
- }, {
554
- popper: withCtx(() => [
555
- createVNode(Transition, null, {
556
- default: withCtx(() => [
557
- createElementVNode("div", {
558
- ref_key: "listRef",
559
- ref: listRef
560
- }, [
561
- __props.inlineSearch || __props.title ? (openBlock(), createElementBlock("div", _hoisted_5, [
562
- __props.title ? (openBlock(), createElementBlock("div", {
563
- key: 0,
564
- class: "dropdown-title__text",
565
- "data-testid": `${__props.testId}-${unref(DropdownTestIdModifiers).TITLE}`
566
- }, [
567
- createVNode(unref(Text), { strong: "" }, {
568
- default: withCtx(() => [
569
- createTextVNode(toDisplayString(__props.title), 1)
570
- ]),
571
- _: 1
572
- })
573
- ], 8, _hoisted_6)) : createCommentVNode("", true),
574
- __props.inlineSearch ? (openBlock(), createBlock(unref(Search), {
575
- key: 1,
576
- modelValue: query.value,
577
- "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => query.value = $event),
578
- placeholder: __props.searchPlaceholder,
579
- class: "dropdown-title__search",
580
- variant: "transparent",
581
- size: "md",
582
- "test-id": `${__props.testId}-${unref(DropdownTestIdModifiers).SEARCH}`,
583
- onKeydown
584
- }, null, 8, ["modelValue", "placeholder", "test-id"])) : createCommentVNode("", true)
585
- ])) : createCommentVNode("", true),
586
- unref(open) ? (openBlock(), createElementBlock("div", {
587
- key: 1,
588
- class: "dropdown",
589
- onKeydown
590
- }, [
591
- renderSlot(_ctx.$slots, "input-list", { open: unref(open) }, void 0, true),
592
- createElementVNode("div", mergeProps(unref(containerProps), {
593
- class: ["list-container", { "list-container--multi": __props.multi }],
594
- style: { height: `${unref(calculateTableHeight)}rem` },
595
- "data-testid": `${__props.testId}-${unref(DropdownTestIdModifiers).LIST_CONTAINER}`
596
- }), [
597
- createElementVNode("ul", mergeProps(unref(wrapperProps), {
598
- role: "listbox",
599
- class: ["list", { "list--multi": __props.multi }]
600
- }), [
601
- !unref(filteredOptions).length && !__props.loading ? (openBlock(), createElementBlock("li", _hoisted_8, [
602
- createVNode(unref(Text), {
603
- size: "sm",
604
- class: "no-result"
605
- }, {
606
- default: withCtx(() => [
607
- createTextVNode(toDisplayString(__props.noResultsText), 1)
608
- ]),
609
- _: 1
610
- })
611
- ])) : createCommentVNode("", true),
612
- __props.loading ? (openBlock(), createElementBlock("li", _hoisted_9, [
613
- createVNode(unref(Icon), {
614
- "font-size": "md",
615
- class: "loader-icon"
616
- }, {
617
- default: withCtx(() => [
618
- _hoisted_10
619
- ]),
620
- _: 1
621
- }),
622
- createVNode(unref(Text), null, {
623
- default: withCtx(() => [
624
- createTextVNode("Loading...")
625
- ]),
626
- _: 1
627
- })
628
- ])) : createCommentVNode("", true),
629
- __props.showSelectAll ? (openBlock(), createElementBlock("li", _hoisted_11, [
630
- createVNode(Option, {
631
- "aria-selected": unref(allSelected),
632
- "aria-disabled": !!__props.disabled,
633
- "selected-prop": unref(allSelected),
634
- "is-indeterminate": unref(isIndeterminate),
635
- "select-all-option": "",
636
- onClick: _cache[3] || (_cache[3] = withModifiers(($event) => onSelectAll(), ["stop"]))
637
- }, {
638
- default: withCtx(() => [
639
- createTextVNode("Select all ")
640
- ]),
641
- _: 1
642
- }, 8, ["aria-selected", "aria-disabled", "selected-prop", "is-indeterminate"])
643
- ])) : createCommentVNode("", true),
644
- unref(virtualOptions).length && !__props.loading ? (openBlock(true), createElementBlock(Fragment, { key: 3 }, renderList(unref(virtualOptions), ({ data, index }) => {
645
- return openBlock(), createElementBlock("li", {
646
- key: index,
647
- "aria-selected": isSelected(toRaw(unref(selectedOption)), data),
648
- "aria-disabled": !!__props.disabled,
649
- onClick: withModifiers(() => onSelect(data, index), ["stop"])
650
- }, [
651
- renderSlot(_ctx.$slots, "default", {
652
- option: data,
653
- selected: isSelected(toRaw(unref(selectedOption)), data),
654
- active: toRaw(unref(activeIndex)) === index
655
- }, void 0, true)
656
- ], 8, _hoisted_12);
657
- }), 128)) : createCommentVNode("", true)
658
- ], 16)
659
- ], 16, _hoisted_7),
660
- __props.multi ? (openBlock(), createElementBlock("div", _hoisted_13, [
661
- createVNode(unref(Button), {
662
- ref_key: "cancel",
663
- ref: cancel,
664
- size: "sm",
665
- variant: "border",
666
- theme: "third",
667
- "test-id": `${__props.testId}-${unref(DropdownTestIdModifiers).ACTION_CANCEL}`,
668
- onClick: onCancel
669
- }, {
670
- default: withCtx(() => [
671
- createTextVNode(" Cancel ")
672
- ]),
673
- _: 1
674
- }, 8, ["test-id"]),
675
- createVNode(unref(Button), {
676
- ref_key: "apply",
677
- ref: apply,
678
- "data-testid": "mutli-apply",
679
- size: "sm",
680
- class: "apply-button",
681
- "test-id": `${__props.testId}-${unref(DropdownTestIdModifiers).ACTION_APPLY}`,
682
- onClick: onApply
683
- }, {
684
- default: withCtx(() => [
685
- createTextVNode("Apply ")
686
- ]),
687
- _: 1
688
- }, 8, ["test-id"])
689
- ])) : createCommentVNode("", true)
690
- ], 32)) : createCommentVNode("", true)
691
- ], 512)
692
- ]),
693
- _: 3
694
- })
695
- ]),
696
- default: withCtx(() => [
697
- createElementVNode("div", {
698
- class: normalizeClass(["button__container", {
699
- "button__container--open": !!unref(open),
700
- [`button__container--${__props.size}`]: true,
701
- "button__container--disabled": __props.disabled
702
- }])
703
- }, [
704
- _ctx.$slots.input ? (openBlock(), createElementBlock("div", {
705
- key: 0,
706
- ref_key: "buttonRef",
707
- ref: buttonRef,
708
- onClick: _cache[0] || (_cache[0] = ($event) => toggleMenu()),
709
- onKeydown: onButtonKeydown
710
- }, [
711
- renderSlot(_ctx.$slots, "input", {
712
- open: unref(open),
713
- value: unref(displayedValue),
714
- disabled: __props.disabled
715
- }, void 0, true)
716
- ], 544)) : createCommentVNode("", true),
717
- !_ctx.$slots.input ? (openBlock(), createElementBlock("button", {
718
- key: 1,
719
- ref_key: "buttonRef",
720
- ref: buttonRef,
721
- disabled: __props.disabled,
722
- "aria-haspopup": true,
723
- "aria-expanded": !!unref(open),
724
- "aria-labelledby": labelRef.value?.id,
725
- "aria-disabled": __props.disabled,
726
- class: normalizeClass([{
727
- "button--open": !!unref(open),
728
- [`button--${__props.size}`]: true,
729
- "button--disabled": __props.disabled
730
- }, "button"]),
731
- onKeydown: onButtonKeydown,
732
- onClick: _cache[1] || (_cache[1] = ($event) => toggleMenu())
733
- }, [
734
- _ctx.$slots.image ? (openBlock(), createElementBlock("div", _hoisted_3, [
735
- renderSlot(_ctx.$slots, "image", {}, void 0, true)
736
- ])) : createCommentVNode("", true),
737
- createVNode(unref(Text), {
738
- size: "sm",
739
- "is-truncated": ""
740
- }, {
741
- default: withCtx(() => [
742
- createTextVNode(toDisplayString(unref(displayedValue)), 1)
743
- ]),
744
- _: 1
745
- }),
746
- createElementVNode("div", _hoisted_4, [
747
- createVNode(unref(Icon), {
748
- name: "angle-down",
749
- "font-size": "sm"
750
- })
751
- ])
752
- ], 42, _hoisted_2)) : createCommentVNode("", true)
753
- ], 2)
754
- ]),
755
- _: 3
756
- }, 8, ["theme", "popper-class", "placement", "skidding", "distance", "flip", "shown", "container", "auto-size", "data-testid"]),
757
- !__props.error && __props.helperText ? (openBlock(), createBlock(unref(Text), {
758
- key: 0,
759
- size: "caption",
760
- class: "helper-text",
761
- "test-id": `${__props.testId}-${unref(DropdownTestIdModifiers).HELPER_TEXT}`
762
- }, {
763
- default: withCtx(() => [
764
- createTextVNode(toDisplayString(__props.helperText), 1)
765
- ]),
766
- _: 1
767
- }, 8, ["test-id"])) : createCommentVNode("", true),
768
- __props.error ? (openBlock(), createBlock(unref(Text), {
769
- key: 1,
770
- size: "caption",
771
- class: "helper-text helper-text--error",
772
- "test-id": `${__props.testId}-${unref(DropdownTestIdModifiers).HELPER_TEXT_ERROR}`
773
- }, {
774
- default: withCtx(() => [
775
- createTextVNode(toDisplayString(__props.error), 1)
776
- ]),
777
- _: 1
778
- }, 8, ["test-id"])) : createCommentVNode("", true)
779
- ], 42, _hoisted_1);
780
- };
781
- }
782
- });
783
- var Dropdown = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-6b0dd6db"]]);
784
-
785
- export { Dropdown as default };