@gitlab/ui 72.12.0 → 72.12.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 (209) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/charts.js +14 -0
  3. package/dist/components/base/accordion/accordion.js +73 -0
  4. package/dist/components/base/accordion/accordion_item.js +133 -0
  5. package/dist/components/base/alert/alert.js +222 -0
  6. package/dist/components/base/avatar/avatar.js +160 -0
  7. package/dist/components/base/avatar_labeled/avatar_labeled.js +107 -0
  8. package/dist/components/base/avatar_link/avatar_link.js +47 -0
  9. package/dist/components/base/avatars_inline/avatars_inline.js +119 -0
  10. package/dist/components/base/badge/badge.js +105 -0
  11. package/dist/components/base/banner/banner.js +139 -0
  12. package/dist/components/base/breadcrumb/breadcrumb.js +122 -0
  13. package/dist/components/base/breadcrumb/breadcrumb_item.js +73 -0
  14. package/dist/components/base/broadcast_message/broadcast_message.js +112 -0
  15. package/dist/components/base/broadcast_message/constants.js +5 -0
  16. package/dist/components/base/button/button.js +151 -0
  17. package/dist/components/base/button_group/button_group.js +47 -0
  18. package/dist/components/base/card/card.js +71 -0
  19. package/dist/components/base/carousel/carousel.js +48 -0
  20. package/dist/components/base/carousel/carousel_slide.js +47 -0
  21. package/dist/components/base/collapse/collapse.js +59 -0
  22. package/dist/components/base/datepicker/datepicker.js +386 -0
  23. package/dist/components/base/daterange_picker/daterange_picker.js +288 -0
  24. package/dist/components/base/drawer/drawer.js +127 -0
  25. package/dist/components/base/dropdown/dropdown.js +261 -0
  26. package/dist/components/base/dropdown/dropdown_divider.js +48 -0
  27. package/dist/components/base/dropdown/dropdown_form.js +48 -0
  28. package/dist/components/base/dropdown/dropdown_item.js +131 -0
  29. package/dist/components/base/dropdown/dropdown_section_header.js +48 -0
  30. package/dist/components/base/dropdown/dropdown_text.js +48 -0
  31. package/dist/components/base/filtered_search/common_story_options.js +14 -0
  32. package/dist/components/base/filtered_search/filtered_search.js +388 -0
  33. package/dist/components/base/filtered_search/filtered_search_suggestion.js +89 -0
  34. package/dist/components/base/filtered_search/filtered_search_suggestion_list.js +138 -0
  35. package/dist/components/base/filtered_search/filtered_search_term.js +203 -0
  36. package/dist/components/base/filtered_search/filtered_search_token.js +384 -0
  37. package/dist/components/base/filtered_search/filtered_search_token_segment.js +420 -0
  38. package/dist/components/base/filtered_search/filtered_search_utils.js +242 -0
  39. package/dist/components/base/form/form.js +49 -0
  40. package/dist/components/base/form/form_checkbox/form_checkbox.js +78 -0
  41. package/dist/components/base/form/form_checkbox/form_checkbox_group.js +60 -0
  42. package/dist/components/base/form/form_checkbox_tree/checkbox_tree_node.js +79 -0
  43. package/dist/components/base/form/form_checkbox_tree/form_checkbox_tree.js +138 -0
  44. package/dist/components/base/form/form_checkbox_tree/models/constants.js +12 -0
  45. package/dist/components/base/form/form_checkbox_tree/models/node.js +51 -0
  46. package/dist/components/base/form/form_checkbox_tree/models/tree.js +199 -0
  47. package/dist/components/base/form/form_combobox/constants.js +55 -0
  48. package/dist/components/base/form/form_combobox/form_combobox.js +230 -0
  49. package/dist/components/base/form/form_date/form_date.js +143 -0
  50. package/dist/components/base/form/form_fields/form_field_validator.js +93 -0
  51. package/dist/components/base/form/form_fields/form_fields.js +214 -0
  52. package/dist/components/base/form/form_fields/mappers.js +13 -0
  53. package/dist/components/base/form/form_fields/validators.js +48 -0
  54. package/dist/components/base/form/form_group/form_group.js +97 -0
  55. package/dist/components/base/form/form_input/form_input.js +121 -0
  56. package/dist/components/base/form/form_input_group/form_input_group.js +108 -0
  57. package/dist/components/base/form/form_input_group/form_input_group_mixin.js +41 -0
  58. package/dist/components/base/form/form_radio/form_radio.js +65 -0
  59. package/dist/components/base/form/form_radio_group/form_radio_group.js +78 -0
  60. package/dist/components/base/form/form_select/constants.js +12 -0
  61. package/dist/components/base/form/form_select/form_select.js +82 -0
  62. package/dist/components/base/form/form_text/form_text.js +38 -0
  63. package/dist/components/base/form/form_textarea/form_textarea.js +112 -0
  64. package/dist/components/base/form/input_group_text/input_group_text.js +48 -0
  65. package/dist/components/base/icon/icon.js +111 -0
  66. package/dist/components/base/infinite_scroll/infinite_scroll.js +197 -0
  67. package/dist/components/base/keyset_pagination/keyset_pagination.js +151 -0
  68. package/dist/components/base/label/label.js +163 -0
  69. package/dist/components/base/link/link.js +50 -0
  70. package/dist/components/base/loading_icon/loading_icon.js +111 -0
  71. package/dist/components/base/markdown/markdown.js +52 -0
  72. package/dist/components/base/modal/modal.js +204 -0
  73. package/dist/components/base/nav/nav.js +48 -0
  74. package/dist/components/base/nav/nav_item.js +48 -0
  75. package/dist/components/base/nav/nav_item_dropdown.js +62 -0
  76. package/dist/components/base/navbar/navbar.js +48 -0
  77. package/dist/components/base/new_dropdowns/base_dropdown/base_dropdown.js +453 -0
  78. package/dist/components/base/new_dropdowns/base_dropdown/constants.js +4 -0
  79. package/dist/components/base/new_dropdowns/constants.js +21 -0
  80. package/dist/components/base/new_dropdowns/disclosure/constants.js +8 -0
  81. package/dist/components/base/new_dropdowns/disclosure/disclosure_dropdown.js +370 -0
  82. package/dist/components/base/new_dropdowns/disclosure/disclosure_dropdown_group.js +110 -0
  83. package/dist/components/base/new_dropdowns/disclosure/disclosure_dropdown_item.js +143 -0
  84. package/dist/components/base/new_dropdowns/disclosure/mock_data.js +147 -0
  85. package/dist/components/base/new_dropdowns/disclosure/utils.js +39 -0
  86. package/dist/components/base/new_dropdowns/listbox/listbox.js +767 -0
  87. package/dist/components/base/new_dropdowns/listbox/listbox_group.js +58 -0
  88. package/dist/components/base/new_dropdowns/listbox/listbox_item.js +91 -0
  89. package/dist/components/base/new_dropdowns/listbox/listbox_search_input.js +93 -0
  90. package/dist/components/base/new_dropdowns/listbox/mock_data.js +118 -0
  91. package/dist/components/base/new_dropdowns/listbox/utils.js +34 -0
  92. package/dist/components/base/paginated_list/paginated_list.js +180 -0
  93. package/dist/components/base/pagination/pagination.js +399 -0
  94. package/dist/components/base/path/data.js +34 -0
  95. package/dist/components/base/path/path.js +189 -0
  96. package/dist/components/base/popover/popover.js +110 -0
  97. package/dist/components/base/progress_bar/progress_bar.js +48 -0
  98. package/dist/components/base/search_box_by_click/search_box_by_click.js +235 -0
  99. package/dist/components/base/search_box_by_type/search_box_by_type.js +167 -0
  100. package/dist/components/base/segmented_control/segmented_control.js +109 -0
  101. package/dist/components/base/skeleton_loader/skeleton_loader.js +224 -0
  102. package/dist/components/base/sorting/sorting.js +171 -0
  103. package/dist/components/base/sorting/sorting_item.js +109 -0
  104. package/dist/components/base/table/constants.js +5 -0
  105. package/dist/components/base/table/table.js +89 -0
  106. package/dist/components/base/table_lite/table_lite.js +72 -0
  107. package/dist/components/base/tabs/constants.js +3 -0
  108. package/dist/components/base/tabs/tab/tab.js +83 -0
  109. package/dist/components/base/tabs/tabs/scrollable_tabs.js +143 -0
  110. package/dist/components/base/tabs/tabs/tabs.js +224 -0
  111. package/dist/components/base/toast/toast.js +82 -0
  112. package/dist/components/base/toggle/toggle.js +180 -0
  113. package/dist/components/base/token/token.js +85 -0
  114. package/dist/components/base/token_selector/helpers.js +5 -0
  115. package/dist/components/base/token_selector/token_container.js +165 -0
  116. package/dist/components/base/token_selector/token_selector.js +403 -0
  117. package/dist/components/base/token_selector/token_selector_dropdown.js +199 -0
  118. package/dist/components/base/tooltip/tooltip.js +55 -0
  119. package/dist/components/charts/area/area.js +311 -0
  120. package/dist/components/charts/bar/bar.js +253 -0
  121. package/dist/components/charts/chart/chart.js +215 -0
  122. package/dist/components/charts/column/column.js +226 -0
  123. package/dist/components/charts/discrete_scatter/discrete_scatter.js +203 -0
  124. package/dist/components/charts/gauge/gauge.js +208 -0
  125. package/dist/components/charts/heatmap/heatmap.js +295 -0
  126. package/dist/components/charts/heatmap/index.js +2 -0
  127. package/dist/components/charts/legend/legend.js +228 -0
  128. package/dist/components/charts/line/line.js +308 -0
  129. package/dist/components/charts/series_label/series_label.js +100 -0
  130. package/dist/components/charts/single_stat/single_stat.js +152 -0
  131. package/dist/components/charts/sparkline/sparkline.js +261 -0
  132. package/dist/components/charts/stacked_column/stacked_column.js +335 -0
  133. package/dist/components/charts/tooltip/tooltip.js +251 -0
  134. package/dist/components/experimental/duo/chat/components/duo_chat_conversation/duo_chat_conversation.js +83 -0
  135. package/dist/components/experimental/duo/chat/components/duo_chat_loader/duo_chat_loader.js +100 -0
  136. package/dist/components/experimental/duo/chat/components/duo_chat_message/copy_code_element.js +35 -0
  137. package/dist/components/experimental/duo/chat/components/duo_chat_message/duo_chat_message.js +115 -0
  138. package/dist/components/experimental/duo/chat/components/duo_chat_message_sources/duo_chat_message_sources.js +104 -0
  139. package/dist/components/experimental/duo/chat/components/duo_chat_predefined_prompts/duo_chat_predefined_prompts.js +64 -0
  140. package/dist/components/experimental/duo/chat/constants.js +23 -0
  141. package/dist/components/experimental/duo/chat/duo_chat.js +359 -0
  142. package/dist/components/experimental/duo/chat/mock_data.js +83 -0
  143. package/dist/components/experimental/duo/user_feedback/user_feedback.js +94 -0
  144. package/dist/components/experimental/duo/user_feedback/user_feedback_modal.js +124 -0
  145. package/dist/components/experimental/experiment_badge/constants.js +4 -0
  146. package/dist/components/experimental/experiment_badge/experiment_badge.js +107 -0
  147. package/dist/components/mixins/button_mixin.js +11 -0
  148. package/dist/components/mixins/safe_link_mixin.js +30 -0
  149. package/dist/components/mixins/tooltip_mixin.js +21 -0
  150. package/dist/components/regions/dashboard_skeleton/dashboard_skeleton.js +53 -0
  151. package/dist/components/regions/empty_state/empty_state.js +154 -0
  152. package/dist/components/shared_components/charts/tooltip_default_format.js +53 -0
  153. package/dist/components/shared_components/clear_icon_button/clear_icon_button.js +64 -0
  154. package/dist/components/shared_components/close_button/close_button.js +54 -0
  155. package/dist/components/utilities/animated_number/animated_number.js +131 -0
  156. package/dist/components/utilities/friendly_wrap/friendly_wrap.js +75 -0
  157. package/dist/components/utilities/intersection_observer/intersection_observer.js +88 -0
  158. package/dist/components/utilities/intersperse/intersperse.js +86 -0
  159. package/dist/components/utilities/sprintf/sprintf.js +172 -0
  160. package/dist/components/utilities/truncate/constants.js +7 -0
  161. package/dist/components/utilities/truncate/truncate.js +111 -0
  162. package/dist/components/utilities/truncate_text/constants.js +7 -0
  163. package/dist/components/utilities/truncate_text/truncate_text.js +146 -0
  164. package/dist/config.js +86 -0
  165. package/dist/directives/collapse_toggle.js +1 -0
  166. package/dist/directives/hover_load/hover_load.js +45 -0
  167. package/dist/directives/modal.js +1 -0
  168. package/dist/directives/outside/get_event_like_time_stamp.js +33 -0
  169. package/dist/directives/outside/outside.js +106 -0
  170. package/dist/directives/resize_observer/resize_observer.js +51 -0
  171. package/dist/directives/safe_html/constants.js +6 -0
  172. package/dist/directives/safe_html/safe_html.js +39 -0
  173. package/dist/directives/safe_link/mock_data.js +10 -0
  174. package/dist/directives/safe_link/safe_link.js +65 -0
  175. package/dist/directives/tooltip.js +1 -0
  176. package/dist/index.css +7 -0
  177. package/dist/index.css.map +1 -0
  178. package/dist/index.js +105 -0
  179. package/dist/tokens/common_story_options.js +54 -0
  180. package/dist/tokens/css/tokens.css +1 -1
  181. package/dist/tokens/css/tokens.dark.css +1 -1
  182. package/dist/tokens/js/tokens.dark.js +1 -1
  183. package/dist/tokens/js/tokens.js +1 -1
  184. package/dist/tokens/scss/_tokens.dark.scss +1 -1
  185. package/dist/tokens/scss/_tokens.scss +1 -1
  186. package/dist/utils/breakpoints.js +20 -0
  187. package/dist/utils/charts/config.js +556 -0
  188. package/dist/utils/charts/constants.js +63 -0
  189. package/dist/utils/charts/mock_data.js +211 -0
  190. package/dist/utils/charts/story_config.js +42 -0
  191. package/dist/utils/charts/theme.js +192 -0
  192. package/dist/utils/charts/utils.js +54 -0
  193. package/dist/utils/constants.js +288 -0
  194. package/dist/utils/data_utils.js +21 -0
  195. package/dist/utils/datetime_utility.js +61 -0
  196. package/dist/utils/i18n.js +15 -0
  197. package/dist/utils/is_slot_empty.js +38 -0
  198. package/dist/utils/number_utils.js +124 -0
  199. package/dist/utils/stories_constants.js +29 -0
  200. package/dist/utils/stories_utils.js +13 -0
  201. package/dist/utils/story_decorators/container.js +16 -0
  202. package/dist/utils/string_utils.js +69 -0
  203. package/dist/utils/svgs/svg_paths.js +7 -0
  204. package/dist/utils/test_utils.js +33 -0
  205. package/dist/utils/use_fake_date.js +29 -0
  206. package/dist/utils/use_mock_intersection_observer.js +108 -0
  207. package/dist/utils/utils.js +197 -0
  208. package/dist/utils.js +5 -0
  209. package/package.json +1 -1
@@ -0,0 +1,203 @@
1
+ import GlToken from '../token/token';
2
+ import { stopEvent } from '../../../utils/utils';
3
+ import GlFilteredSearchTokenSegment from './filtered_search_token_segment';
4
+ import { termTokenDefinition, match, tokenToOption, INTENT_ACTIVATE_PREVIOUS, TOKEN_CLOSE_SELECTOR, TERM_TOKEN_TYPE } from './filtered_search_utils';
5
+ import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
6
+
7
+ var script = {
8
+ name: 'GlFilteredSearchTerm',
9
+ components: {
10
+ GlFilteredSearchTokenSegment,
11
+ GlToken
12
+ },
13
+ inject: ['termsAsTokens'],
14
+ inheritAttrs: false,
15
+ props: {
16
+ /**
17
+ * Tokens available for this filtered search instance.
18
+ */
19
+ availableTokens: {
20
+ type: Array,
21
+ required: true
22
+ },
23
+ /**
24
+ * Determines if the term is being edited or not.
25
+ */
26
+ active: {
27
+ type: Boolean,
28
+ required: false,
29
+ default: false
30
+ },
31
+ /**
32
+ * Current term value.
33
+ */
34
+ value: {
35
+ type: Object,
36
+ required: false,
37
+ default: () => ({
38
+ data: ''
39
+ })
40
+ },
41
+ placeholder: {
42
+ type: String,
43
+ required: false,
44
+ default: ''
45
+ },
46
+ /**
47
+ * HTML attributes to add to the search input.
48
+ */
49
+ searchInputAttributes: {
50
+ type: Object,
51
+ required: false,
52
+ default: () => ({})
53
+ },
54
+ /**
55
+ * If this is the last token.
56
+ */
57
+ isLastToken: {
58
+ type: Boolean,
59
+ required: false,
60
+ default: false
61
+ },
62
+ /**
63
+ * The current `value` (tokens) of the ancestor GlFilteredSearch component.
64
+ */
65
+ currentValue: {
66
+ type: Array,
67
+ required: false,
68
+ default: () => []
69
+ },
70
+ cursorPosition: {
71
+ type: String,
72
+ required: false,
73
+ default: 'end',
74
+ validator: value => ['start', 'end'].includes(value)
75
+ },
76
+ /**
77
+ * The title of the text search option. Ignored unless termsAsTokens is enabled.
78
+ */
79
+ searchTextOptionLabel: {
80
+ type: String,
81
+ required: false,
82
+ default: termTokenDefinition.title
83
+ },
84
+ viewOnly: {
85
+ type: Boolean,
86
+ required: false,
87
+ default: false
88
+ }
89
+ },
90
+ computed: {
91
+ showInput() {
92
+ return this.termsAsTokens() || Boolean(this.placeholder);
93
+ },
94
+ showToken() {
95
+ return this.termsAsTokens() && Boolean(this.value.data);
96
+ },
97
+ suggestedTokens() {
98
+ const tokens = this.availableTokens.filter(token => match(token.title, this.value.data));
99
+ if (this.termsAsTokens() && this.value.data) {
100
+ tokens.push({
101
+ ...termTokenDefinition,
102
+ title: this.searchTextOptionLabel
103
+ });
104
+ }
105
+
106
+ // eslint-disable-next-line unicorn/no-array-callback-reference
107
+ return tokens.map(tokenToOption);
108
+ },
109
+ internalValue: {
110
+ get() {
111
+ return this.value.data;
112
+ },
113
+ set(data) {
114
+ /**
115
+ * Emitted when the token changes its value.
116
+ *
117
+ * @event input
118
+ * @type {object} dataObj Object containing the update value.
119
+ */
120
+ this.$emit('input', {
121
+ data
122
+ });
123
+ }
124
+ },
125
+ eventListeners() {
126
+ return this.viewOnly ? {} : {
127
+ mousedown: this.stopMousedownOnCloseButton,
128
+ close: this.destroyByClose
129
+ };
130
+ }
131
+ },
132
+ methods: {
133
+ onBackspace() {
134
+ /**
135
+ * Emitted when token value is empty and backspace is pressed.
136
+ * Includes user intent to activate previous token.
137
+ *
138
+ * @event destroy
139
+ * @type {object} details The user intent
140
+ */
141
+ this.$emit('destroy', {
142
+ intent: INTENT_ACTIVATE_PREVIOUS
143
+ });
144
+ },
145
+ stopMousedownOnCloseButton(event) {
146
+ if (event.target.closest(TOKEN_CLOSE_SELECTOR)) {
147
+ stopEvent(event);
148
+ }
149
+ },
150
+ destroyByClose() {
151
+ this.$emit('destroy');
152
+ },
153
+ onComplete(type) {
154
+ if (type === TERM_TOKEN_TYPE) {
155
+ // We've completed this term token
156
+ this.$emit('complete');
157
+ } else {
158
+ // We're changing the current token type
159
+ this.$emit('replace', {
160
+ type
161
+ });
162
+ }
163
+ }
164
+ }
165
+ };
166
+
167
+ /* script */
168
+ const __vue_script__ = script;
169
+
170
+ /* template */
171
+ var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"gl-h-auto gl-filtered-search-term",attrs:{"data-testid":"filtered-search-term"}},[_c('gl-filtered-search-token-segment',{ref:"segment",staticClass:"gl-filtered-search-term-token",attrs:{"is-term":"","active":_vm.active,"cursor-position":_vm.cursorPosition,"search-input-attributes":_vm.searchInputAttributes,"is-last-token":_vm.isLastToken,"current-value":_vm.currentValue,"view-only":_vm.viewOnly,"options":_vm.suggestedTokens},on:{"activate":function($event){return _vm.$emit('activate')},"deactivate":function($event){return _vm.$emit('deactivate')},"complete":_vm.onComplete,"backspace":_vm.onBackspace,"submit":function($event){return _vm.$emit('submit')},"split":function($event){return _vm.$emit('split', $event)},"previous":function($event){return _vm.$emit('previous')},"next":function($event){return _vm.$emit('next')}},scopedSlots:_vm._u([{key:"view",fn:function(){return [(_vm.showToken)?_c('gl-token',_vm._g({class:{ 'gl-cursor-pointer': !_vm.viewOnly },attrs:{"view-only":_vm.viewOnly}},_vm.eventListeners),[_vm._v(_vm._s(_vm.value.data))]):(_vm.showInput)?_c('input',_vm._b({staticClass:"gl-filtered-search-term-input",class:{ 'gl-bg-gray-10': _vm.viewOnly },attrs:{"placeholder":_vm.placeholder,"aria-label":_vm.placeholder,"readonly":_vm.viewOnly,"data-testid":"filtered-search-term-input"},on:{"focusin":function($event){return _vm.$emit('activate')},"focusout":function($event){return _vm.$emit('deactivate')}}},'input',_vm.searchInputAttributes,false)):[_vm._v(_vm._s(_vm.value.data))]]},proxy:true}]),model:{value:(_vm.internalValue),callback:function ($$v) {_vm.internalValue=$$v;},expression:"internalValue"}})],1)};
172
+ var __vue_staticRenderFns__ = [];
173
+
174
+ /* style */
175
+ const __vue_inject_styles__ = undefined;
176
+ /* scoped */
177
+ const __vue_scope_id__ = undefined;
178
+ /* module identifier */
179
+ const __vue_module_identifier__ = undefined;
180
+ /* functional template */
181
+ const __vue_is_functional_template__ = false;
182
+ /* style inject */
183
+
184
+ /* style inject SSR */
185
+
186
+ /* style inject shadow dom */
187
+
188
+
189
+
190
+ const __vue_component__ = __vue_normalize__(
191
+ { render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
192
+ __vue_inject_styles__,
193
+ __vue_script__,
194
+ __vue_scope_id__,
195
+ __vue_is_functional_template__,
196
+ __vue_module_identifier__,
197
+ false,
198
+ undefined,
199
+ undefined,
200
+ undefined
201
+ );
202
+
203
+ export default __vue_component__;
@@ -0,0 +1,384 @@
1
+ import cloneDeep from 'lodash/cloneDeep';
2
+ import isEqual from 'lodash/isEqual';
3
+ import GlToken from '../token/token';
4
+ import { stopEvent } from '../../../utils/utils';
5
+ import GlFilteredSearchTokenSegment from './filtered_search_token_segment';
6
+ import { tokenToOption, createTerm, TOKEN_CLOSE_SELECTOR } from './filtered_search_utils';
7
+ import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
8
+
9
+ const SEGMENT_TITLE = 'TYPE';
10
+ const SEGMENT_OPERATOR = 'OPERATOR';
11
+ const SEGMENT_DATA = 'DATA';
12
+ const DEFAULT_OPERATORS = [{
13
+ value: '=',
14
+ description: 'is',
15
+ default: true
16
+ }, {
17
+ value: '!=',
18
+ description: 'is not'
19
+ }];
20
+ var script = {
21
+ name: 'GlFilteredSearchToken',
22
+ // FIXME: temporary workaround to ensure compatibility with @vue/compat
23
+ __v_skip: true,
24
+ components: {
25
+ GlToken,
26
+ GlFilteredSearchTokenSegment
27
+ },
28
+ inheritAttrs: false,
29
+ props: {
30
+ availableTokens: {
31
+ type: Array,
32
+ required: false,
33
+ default: () => []
34
+ },
35
+ /**
36
+ * Token configuration with available operators and options.
37
+ */
38
+ config: {
39
+ type: Object,
40
+ required: false,
41
+ default: () => ({})
42
+ },
43
+ /**
44
+ * Determines if the token is being edited or not.
45
+ */
46
+ active: {
47
+ type: Boolean,
48
+ required: false,
49
+ default: false
50
+ },
51
+ multiSelectValues: {
52
+ type: Array,
53
+ required: false,
54
+ default: () => []
55
+ },
56
+ /**
57
+ * Current token value.
58
+ */
59
+ value: {
60
+ type: Object,
61
+ required: false,
62
+ default: () => ({
63
+ operator: '',
64
+ data: ''
65
+ })
66
+ },
67
+ /**
68
+ * Display operators' descriptions instead of their values (e.g., "is" instead of "=").
69
+ */
70
+ showFriendlyText: {
71
+ type: Boolean,
72
+ required: false,
73
+ default: false
74
+ },
75
+ cursorPosition: {
76
+ type: String,
77
+ required: false,
78
+ default: 'end',
79
+ validator: value => ['start', 'end'].includes(value)
80
+ },
81
+ viewOnly: {
82
+ type: Boolean,
83
+ required: false,
84
+ default: false
85
+ },
86
+ dataSegmentInputAttributes: {
87
+ type: Object,
88
+ required: false,
89
+ default: () => ({})
90
+ }
91
+ },
92
+ data() {
93
+ return {
94
+ activeSegment: null,
95
+ tokenValue: cloneDeep(this.value),
96
+ intendedCursorPosition: this.cursorPosition
97
+ };
98
+ },
99
+ computed: {
100
+ operators() {
101
+ return this.config.operators || DEFAULT_OPERATORS;
102
+ },
103
+ tokenEmpty() {
104
+ var _this$tokenValue$data;
105
+ return ((_this$tokenValue$data = this.tokenValue.data) === null || _this$tokenValue$data === void 0 ? void 0 : _this$tokenValue$data.length) === 0;
106
+ },
107
+ hasDataOrDataSegmentIsCurrentlyActive() {
108
+ const hasData = !this.tokenEmpty;
109
+ return hasData || this.isSegmentActive(SEGMENT_DATA);
110
+ },
111
+ availableTokensWithSelf() {
112
+ return [this.config, ...this.availableTokens.filter(token => token !== this.config)].map(
113
+ // eslint-disable-next-line unicorn/no-array-callback-reference
114
+ tokenToOption);
115
+ },
116
+ operatorDescription() {
117
+ const operator = this.operators.find(op => op.value === this.tokenValue.operator);
118
+ return this.showFriendlyText ? operator === null || operator === void 0 ? void 0 : operator.description : operator === null || operator === void 0 ? void 0 : operator.value;
119
+ },
120
+ eventListeners() {
121
+ return this.viewOnly ? {} : {
122
+ mousedown: this.stopMousedownOnCloseButton,
123
+ close: this.destroyByClose
124
+ };
125
+ }
126
+ },
127
+ segments: {
128
+ SEGMENT_TITLE,
129
+ SEGMENT_DATA,
130
+ SEGMENT_OPERATOR
131
+ },
132
+ watch: {
133
+ tokenValue: {
134
+ deep: true,
135
+ handler(newValue) {
136
+ /**
137
+ * Emitted when the token changes its value.
138
+ *
139
+ * @event input
140
+ * @type {object} dataObj Object containing the update value.
141
+ */
142
+ this.$emit('input', newValue);
143
+ }
144
+ },
145
+ value: {
146
+ handler(newValue, oldValue) {
147
+ if (isEqual(newValue === null || newValue === void 0 ? void 0 : newValue.data, oldValue === null || oldValue === void 0 ? void 0 : oldValue.data) && (newValue === null || newValue === void 0 ? void 0 : newValue.operator) === (oldValue === null || oldValue === void 0 ? void 0 : oldValue.operator)) {
148
+ return;
149
+ }
150
+ this.tokenValue = cloneDeep(newValue);
151
+ }
152
+ },
153
+ active: {
154
+ immediate: true,
155
+ handler(tokenIsActive) {
156
+ if (tokenIsActive) {
157
+ this.intendedCursorPosition = this.cursorPosition;
158
+ if (!this.activeSegment) {
159
+ this.activateSegment(this.tokenEmpty ? SEGMENT_OPERATOR : SEGMENT_DATA);
160
+ }
161
+ } else {
162
+ this.activeSegment = null;
163
+
164
+ // restore multi select values if we have them
165
+ // otherwise destroy the token
166
+ if (this.config.multiSelect) {
167
+ this.$emit('input', {
168
+ ...this.tokenValue,
169
+ data: this.multiSelectValues || ''
170
+ });
171
+ }
172
+ if (this.tokenEmpty && this.multiSelectValues.length === 0) {
173
+ /**
174
+ * Emitted when token is about to be destroyed.
175
+ *
176
+ * @event destroy
177
+ */
178
+ this.$emit('destroy');
179
+ }
180
+ }
181
+ }
182
+ }
183
+ },
184
+ created() {
185
+ if (!('operator' in this.tokenValue)) {
186
+ if (this.operators.length === 1) {
187
+ const operator = this.operators[0].value;
188
+ this.$emit('input', {
189
+ ...this.tokenValue,
190
+ operator
191
+ });
192
+ this.activeSegment = SEGMENT_DATA;
193
+ } else {
194
+ this.$emit('input', {
195
+ ...this.tokenValue,
196
+ operator: ''
197
+ });
198
+ }
199
+ }
200
+ },
201
+ methods: {
202
+ activateSegment(segment) {
203
+ if (this.viewOnly) return;
204
+ this.activeSegment = segment;
205
+ if (!this.active) {
206
+ /**
207
+ * Emitted when this term token is clicked.
208
+ *
209
+ * @event activate
210
+ */
211
+ this.$emit('activate');
212
+ }
213
+ },
214
+ getAdditionalSegmentClasses(segment) {
215
+ if (this.viewOnly) {
216
+ return 'gl-cursor-text';
217
+ }
218
+ return {
219
+ 'gl-cursor-pointer': !this.isSegmentActive(segment)
220
+ };
221
+ },
222
+ isSegmentActive(segment) {
223
+ return this.active && this.activeSegment === segment;
224
+ },
225
+ replaceWithTermIfEmpty() {
226
+ if (this.tokenValue.operator === '' && this.tokenEmpty) {
227
+ /**
228
+ * Emitted when this token is converted to another type
229
+ * @property {object} token Replacement token configuration
230
+ */
231
+ this.$emit('replace', createTerm(this.config.title));
232
+ }
233
+ },
234
+ replaceToken(newType) {
235
+ const newTokenConfig = this.availableTokens.find(_ref => {
236
+ let {
237
+ type
238
+ } = _ref;
239
+ return type === newType;
240
+ });
241
+ if (newTokenConfig === this.config) {
242
+ this.$nextTick(() => {
243
+ /**
244
+ * Emitted when this term token will lose its focus.
245
+ *
246
+ * @event deactivate
247
+ */
248
+ this.$emit('deactivate');
249
+ });
250
+ return;
251
+ }
252
+ if (newTokenConfig) {
253
+ const isCompatible = this.config.dataType && this.config.dataType === newTokenConfig.dataType;
254
+ this.$emit('replace', {
255
+ type: newTokenConfig.type,
256
+ value: isCompatible ? this.tokenValue : {
257
+ data: ''
258
+ }
259
+ });
260
+ }
261
+ },
262
+ handleOperatorKeydown(evt, _ref2) {
263
+ let {
264
+ inputValue,
265
+ suggestedValue,
266
+ applySuggestion
267
+ } = _ref2;
268
+ const {
269
+ key
270
+ } = evt;
271
+ if (key === ' ' || key === 'Spacebar') {
272
+ applySuggestion(suggestedValue);
273
+ return;
274
+ }
275
+ const potentialValue = `${inputValue}${key}`;
276
+ if (key.length === 1 && !this.operators.find(_ref3 => {
277
+ let {
278
+ value
279
+ } = _ref3;
280
+ return value.startsWith(potentialValue);
281
+ })) {
282
+ if (this.tokenEmpty) {
283
+ applySuggestion(suggestedValue);
284
+ } else {
285
+ evt.preventDefault();
286
+ }
287
+ }
288
+ },
289
+ activateDataSegment() {
290
+ if (this.config.multiSelect) {
291
+ this.$emit('input', {
292
+ ...this.tokenValue,
293
+ data: ''
294
+ });
295
+ }
296
+ this.activateSegment(this.$options.segments.SEGMENT_DATA);
297
+ },
298
+ activatePreviousOperatorSegment() {
299
+ this.activateSegment(this.$options.segments.SEGMENT_OPERATOR);
300
+ this.intendedCursorPosition = 'end';
301
+ },
302
+ activatePreviousTitleSegment() {
303
+ this.activateSegment(this.$options.segments.SEGMENT_TITLE);
304
+ this.intendedCursorPosition = 'end';
305
+ },
306
+ activateNextDataSegment() {
307
+ this.activateDataSegment();
308
+ this.intendedCursorPosition = 'start';
309
+ },
310
+ activateNextOperatorSegment() {
311
+ this.activateSegment(this.$options.segments.SEGMENT_OPERATOR);
312
+ this.intendedCursorPosition = 'start';
313
+ },
314
+ handleComplete(value) {
315
+ /**
316
+ * Emitted when the token entry has been completed.
317
+ *
318
+ * @event complete
319
+ */
320
+ this.$emit('complete', value);
321
+ },
322
+ stopMousedownOnCloseButton(event) {
323
+ if (event.target.closest(TOKEN_CLOSE_SELECTOR)) {
324
+ stopEvent(event);
325
+ }
326
+ },
327
+ destroyByClose() {
328
+ this.$emit('destroy');
329
+ }
330
+ }
331
+ };
332
+
333
+ /* script */
334
+ const __vue_script__ = script;
335
+
336
+ /* template */
337
+ var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"gl-filtered-search-token",class:{
338
+ 'gl-filtered-search-token-active': _vm.active,
339
+ 'gl-filtered-search-token-hover': !_vm.viewOnly,
340
+ 'gl-cursor-default': _vm.viewOnly,
341
+ },attrs:{"data-testid":"filtered-search-token"}},[_c('gl-filtered-search-token-segment',{key:"title-segment",attrs:{"value":_vm.config.title,"active":_vm.isSegmentActive(_vm.$options.segments.SEGMENT_TITLE),"cursor-position":_vm.intendedCursorPosition,"options":_vm.availableTokensWithSelf,"view-only":_vm.viewOnly},on:{"activate":function($event){return _vm.activateSegment(_vm.$options.segments.SEGMENT_TITLE)},"deactivate":function($event){return _vm.$emit('deactivate')},"complete":_vm.replaceToken,"backspace":function($event){return _vm.$emit('destroy')},"submit":function($event){return _vm.$emit('submit')},"previous":function($event){return _vm.$emit('previous')},"next":_vm.activateNextOperatorSegment},scopedSlots:_vm._u([{key:"view",fn:function(ref){
342
+ var inputValue = ref.inputValue;
343
+ return [_c('gl-token',{staticClass:"gl-filtered-search-token-type",class:_vm.getAdditionalSegmentClasses(_vm.$options.segments.SEGMENT_TITLE),attrs:{"view-only":""}},[_vm._v("\n "+_vm._s(inputValue)+"\n ")])]}}])}),_vm._v(" "),_c('gl-filtered-search-token-segment',{key:"operator-segment",attrs:{"active":_vm.isSegmentActive(_vm.$options.segments.SEGMENT_OPERATOR),"cursor-position":_vm.intendedCursorPosition,"options":_vm.operators,"option-text-field":"value","custom-input-keydown-handler":_vm.handleOperatorKeydown,"view-only":_vm.viewOnly},on:{"activate":function($event){return _vm.activateSegment(_vm.$options.segments.SEGMENT_OPERATOR)},"backspace":_vm.replaceWithTermIfEmpty,"complete":function($event){return _vm.activateSegment(_vm.$options.segments.SEGMENT_DATA)},"deactivate":function($event){return _vm.$emit('deactivate')},"previous":_vm.activatePreviousTitleSegment,"next":_vm.activateNextDataSegment},scopedSlots:_vm._u([{key:"view",fn:function(){return [_c('gl-token',{staticClass:"gl-filtered-search-token-operator",class:_vm.getAdditionalSegmentClasses(_vm.$options.segments.SEGMENT_OPERATOR),attrs:{"variant":"search-value","view-only":""}},[_vm._v("\n "+_vm._s(_vm.operatorDescription)+"\n ")])]},proxy:true},{key:"option",fn:function(ref){
344
+ var option = ref.option;
345
+ return [_c('div',{staticClass:"gl-display-flex"},[_vm._v("\n "+_vm._s(_vm.showFriendlyText ? option.description : option.value)+"\n "),(option.description)?_c('span',{staticClass:"gl-filtered-search-token-operator-description"},[_vm._v("\n "+_vm._s(_vm.showFriendlyText ? option.value : option.description)+"\n ")]):_vm._e()])]}}]),model:{value:(_vm.tokenValue.operator),callback:function ($$v) {_vm.$set(_vm.tokenValue, "operator", $$v);},expression:"tokenValue.operator"}}),_vm._v(" "),(_vm.hasDataOrDataSegmentIsCurrentlyActive)?_c('gl-filtered-search-token-segment',{key:"data-segment",attrs:{"active":_vm.isSegmentActive(_vm.$options.segments.SEGMENT_DATA),"cursor-position":_vm.intendedCursorPosition,"multi-select":_vm.config.multiSelect,"options":_vm.config.options,"view-only":_vm.viewOnly,"search-input-attributes":_vm.dataSegmentInputAttributes},on:{"activate":_vm.activateDataSegment,"backspace":function($event){return _vm.activateSegment(_vm.$options.segments.SEGMENT_OPERATOR)},"complete":_vm.handleComplete,"select":function($event){return _vm.$emit('select', $event)},"submit":function($event){return _vm.$emit('submit')},"deactivate":function($event){return _vm.$emit('deactivate')},"split":function($event){return _vm.$emit('split', $event)},"previous":_vm.activatePreviousOperatorSegment,"next":function($event){return _vm.$emit('next')}},scopedSlots:_vm._u([{key:"before-input",fn:function(scope){return [_vm._t("before-data-segment-input",null,null,scope)]}},{key:"suggestions",fn:function(){return [_vm._t("suggestions")]},proxy:true},{key:"view",fn:function(ref){
346
+ var inputValue = ref.inputValue;
347
+ return [_vm._t("view-token",function(){return [_c('gl-token',_vm._g({staticClass:"gl-filtered-search-token-data",class:_vm.getAdditionalSegmentClasses(_vm.$options.segments.SEGMENT_DATA),attrs:{"variant":"search-value","view-only":_vm.viewOnly}},_vm.eventListeners),[_c('span',{staticClass:"gl-filtered-search-token-data-content"},[_vm._t("view",function(){return [_vm._v(_vm._s(inputValue))]},null,{ inputValue: inputValue })],2)])]},null,{
348
+ inputValue: inputValue,
349
+ listeners: _vm.eventListeners,
350
+ cssClasses: Object.assign({}, {'gl-filtered-search-token-data': true},
351
+ _vm.getAdditionalSegmentClasses(_vm.$options.segments.SEGMENT_DATA)),
352
+ })]}}],null,true),model:{value:(_vm.tokenValue.data),callback:function ($$v) {_vm.$set(_vm.tokenValue, "data", $$v);},expression:"tokenValue.data"}}):_vm._e()],1)};
353
+ var __vue_staticRenderFns__ = [];
354
+
355
+ /* style */
356
+ const __vue_inject_styles__ = undefined;
357
+ /* scoped */
358
+ const __vue_scope_id__ = undefined;
359
+ /* module identifier */
360
+ const __vue_module_identifier__ = undefined;
361
+ /* functional template */
362
+ const __vue_is_functional_template__ = false;
363
+ /* style inject */
364
+
365
+ /* style inject SSR */
366
+
367
+ /* style inject shadow dom */
368
+
369
+
370
+
371
+ const __vue_component__ = __vue_normalize__(
372
+ { render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
373
+ __vue_inject_styles__,
374
+ __vue_script__,
375
+ __vue_scope_id__,
376
+ __vue_is_functional_template__,
377
+ __vue_module_identifier__,
378
+ false,
379
+ undefined,
380
+ undefined,
381
+ undefined
382
+ );
383
+
384
+ export default __vue_component__;