@gitlab/ui 72.11.0 → 72.12.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 (225) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/tokens/css/tokens.css +1 -1
  3. package/dist/tokens/css/tokens.dark.css +1 -1
  4. package/dist/tokens/js/tokens.dark.js +1 -1
  5. package/dist/tokens/js/tokens.js +1 -1
  6. package/dist/tokens/scss/_tokens.dark.scss +1 -1
  7. package/dist/tokens/scss/_tokens.scss +1 -1
  8. package/package.json +1 -1
  9. package/src/directives/safe_html/safe_html.js +5 -0
  10. package/src/directives/safe_html/safe_html.spec.js +17 -0
  11. package/src/internal/color_contrast/color_contrast.md +8 -0
  12. package/src/internal/color_contrast/color_contrast.spec.js +34 -0
  13. package/src/internal/color_contrast/color_contrast.stories.js +41 -0
  14. package/src/internal/color_contrast/color_contrast.vue +52 -0
  15. package/src/tokens/color.dark.tokens.stories.js +36 -22
  16. package/src/tokens/color.data_viz.dark.tokens.stories.js +13 -30
  17. package/src/tokens/color.data_viz.tokens.stories.js +13 -30
  18. package/src/tokens/color.theme.dark.tokens.stories.js +15 -30
  19. package/src/tokens/color.theme.tokens.stories.js +15 -30
  20. package/src/tokens/color.tokens.stories.js +36 -22
  21. package/src/tokens/color.transparency.tokens.stories.js +9 -12
  22. package/src/tokens/common_story_options.js +22 -80
  23. package/src/utils/constants.js +25 -0
  24. package/src/utils/utils.js +21 -1
  25. package/dist/charts.js +0 -14
  26. package/dist/components/base/accordion/accordion.js +0 -73
  27. package/dist/components/base/accordion/accordion_item.js +0 -133
  28. package/dist/components/base/alert/alert.js +0 -222
  29. package/dist/components/base/avatar/avatar.js +0 -160
  30. package/dist/components/base/avatar_labeled/avatar_labeled.js +0 -107
  31. package/dist/components/base/avatar_link/avatar_link.js +0 -47
  32. package/dist/components/base/avatars_inline/avatars_inline.js +0 -119
  33. package/dist/components/base/badge/badge.js +0 -105
  34. package/dist/components/base/banner/banner.js +0 -139
  35. package/dist/components/base/breadcrumb/breadcrumb.js +0 -122
  36. package/dist/components/base/breadcrumb/breadcrumb_item.js +0 -73
  37. package/dist/components/base/broadcast_message/broadcast_message.js +0 -112
  38. package/dist/components/base/broadcast_message/constants.js +0 -5
  39. package/dist/components/base/button/button.js +0 -151
  40. package/dist/components/base/button_group/button_group.js +0 -47
  41. package/dist/components/base/card/card.js +0 -71
  42. package/dist/components/base/carousel/carousel.js +0 -48
  43. package/dist/components/base/carousel/carousel_slide.js +0 -47
  44. package/dist/components/base/collapse/collapse.js +0 -59
  45. package/dist/components/base/datepicker/datepicker.js +0 -386
  46. package/dist/components/base/daterange_picker/daterange_picker.js +0 -288
  47. package/dist/components/base/drawer/drawer.js +0 -127
  48. package/dist/components/base/dropdown/dropdown.js +0 -261
  49. package/dist/components/base/dropdown/dropdown_divider.js +0 -48
  50. package/dist/components/base/dropdown/dropdown_form.js +0 -48
  51. package/dist/components/base/dropdown/dropdown_item.js +0 -131
  52. package/dist/components/base/dropdown/dropdown_section_header.js +0 -48
  53. package/dist/components/base/dropdown/dropdown_text.js +0 -48
  54. package/dist/components/base/filtered_search/common_story_options.js +0 -14
  55. package/dist/components/base/filtered_search/filtered_search.js +0 -388
  56. package/dist/components/base/filtered_search/filtered_search_suggestion.js +0 -89
  57. package/dist/components/base/filtered_search/filtered_search_suggestion_list.js +0 -138
  58. package/dist/components/base/filtered_search/filtered_search_term.js +0 -203
  59. package/dist/components/base/filtered_search/filtered_search_token.js +0 -384
  60. package/dist/components/base/filtered_search/filtered_search_token_segment.js +0 -420
  61. package/dist/components/base/filtered_search/filtered_search_utils.js +0 -242
  62. package/dist/components/base/form/form.js +0 -49
  63. package/dist/components/base/form/form_checkbox/form_checkbox.js +0 -78
  64. package/dist/components/base/form/form_checkbox/form_checkbox_group.js +0 -60
  65. package/dist/components/base/form/form_checkbox_tree/checkbox_tree_node.js +0 -79
  66. package/dist/components/base/form/form_checkbox_tree/form_checkbox_tree.js +0 -138
  67. package/dist/components/base/form/form_checkbox_tree/models/constants.js +0 -12
  68. package/dist/components/base/form/form_checkbox_tree/models/node.js +0 -51
  69. package/dist/components/base/form/form_checkbox_tree/models/tree.js +0 -199
  70. package/dist/components/base/form/form_combobox/constants.js +0 -55
  71. package/dist/components/base/form/form_combobox/form_combobox.js +0 -230
  72. package/dist/components/base/form/form_date/form_date.js +0 -143
  73. package/dist/components/base/form/form_fields/form_field_validator.js +0 -93
  74. package/dist/components/base/form/form_fields/form_fields.js +0 -214
  75. package/dist/components/base/form/form_fields/mappers.js +0 -13
  76. package/dist/components/base/form/form_fields/validators.js +0 -48
  77. package/dist/components/base/form/form_group/form_group.js +0 -97
  78. package/dist/components/base/form/form_input/form_input.js +0 -121
  79. package/dist/components/base/form/form_input_group/form_input_group.js +0 -108
  80. package/dist/components/base/form/form_input_group/form_input_group_mixin.js +0 -41
  81. package/dist/components/base/form/form_radio/form_radio.js +0 -65
  82. package/dist/components/base/form/form_radio_group/form_radio_group.js +0 -78
  83. package/dist/components/base/form/form_select/constants.js +0 -12
  84. package/dist/components/base/form/form_select/form_select.js +0 -82
  85. package/dist/components/base/form/form_text/form_text.js +0 -38
  86. package/dist/components/base/form/form_textarea/form_textarea.js +0 -112
  87. package/dist/components/base/form/input_group_text/input_group_text.js +0 -48
  88. package/dist/components/base/icon/icon.js +0 -111
  89. package/dist/components/base/infinite_scroll/infinite_scroll.js +0 -197
  90. package/dist/components/base/keyset_pagination/keyset_pagination.js +0 -151
  91. package/dist/components/base/label/label.js +0 -163
  92. package/dist/components/base/link/link.js +0 -50
  93. package/dist/components/base/loading_icon/loading_icon.js +0 -111
  94. package/dist/components/base/markdown/markdown.js +0 -52
  95. package/dist/components/base/modal/modal.js +0 -204
  96. package/dist/components/base/nav/nav.js +0 -48
  97. package/dist/components/base/nav/nav_item.js +0 -48
  98. package/dist/components/base/nav/nav_item_dropdown.js +0 -62
  99. package/dist/components/base/navbar/navbar.js +0 -48
  100. package/dist/components/base/new_dropdowns/base_dropdown/base_dropdown.js +0 -453
  101. package/dist/components/base/new_dropdowns/base_dropdown/constants.js +0 -4
  102. package/dist/components/base/new_dropdowns/constants.js +0 -21
  103. package/dist/components/base/new_dropdowns/disclosure/constants.js +0 -8
  104. package/dist/components/base/new_dropdowns/disclosure/disclosure_dropdown.js +0 -370
  105. package/dist/components/base/new_dropdowns/disclosure/disclosure_dropdown_group.js +0 -110
  106. package/dist/components/base/new_dropdowns/disclosure/disclosure_dropdown_item.js +0 -143
  107. package/dist/components/base/new_dropdowns/disclosure/mock_data.js +0 -147
  108. package/dist/components/base/new_dropdowns/disclosure/utils.js +0 -39
  109. package/dist/components/base/new_dropdowns/listbox/listbox.js +0 -767
  110. package/dist/components/base/new_dropdowns/listbox/listbox_group.js +0 -58
  111. package/dist/components/base/new_dropdowns/listbox/listbox_item.js +0 -91
  112. package/dist/components/base/new_dropdowns/listbox/listbox_search_input.js +0 -93
  113. package/dist/components/base/new_dropdowns/listbox/mock_data.js +0 -118
  114. package/dist/components/base/new_dropdowns/listbox/utils.js +0 -34
  115. package/dist/components/base/paginated_list/paginated_list.js +0 -180
  116. package/dist/components/base/pagination/pagination.js +0 -399
  117. package/dist/components/base/path/data.js +0 -34
  118. package/dist/components/base/path/path.js +0 -189
  119. package/dist/components/base/popover/popover.js +0 -110
  120. package/dist/components/base/progress_bar/progress_bar.js +0 -48
  121. package/dist/components/base/search_box_by_click/search_box_by_click.js +0 -235
  122. package/dist/components/base/search_box_by_type/search_box_by_type.js +0 -167
  123. package/dist/components/base/segmented_control/segmented_control.js +0 -109
  124. package/dist/components/base/skeleton_loader/skeleton_loader.js +0 -224
  125. package/dist/components/base/sorting/sorting.js +0 -171
  126. package/dist/components/base/sorting/sorting_item.js +0 -109
  127. package/dist/components/base/table/constants.js +0 -5
  128. package/dist/components/base/table/table.js +0 -89
  129. package/dist/components/base/table_lite/table_lite.js +0 -72
  130. package/dist/components/base/tabs/constants.js +0 -3
  131. package/dist/components/base/tabs/tab/tab.js +0 -83
  132. package/dist/components/base/tabs/tabs/scrollable_tabs.js +0 -143
  133. package/dist/components/base/tabs/tabs/tabs.js +0 -224
  134. package/dist/components/base/toast/toast.js +0 -82
  135. package/dist/components/base/toggle/toggle.js +0 -180
  136. package/dist/components/base/token/token.js +0 -85
  137. package/dist/components/base/token_selector/helpers.js +0 -5
  138. package/dist/components/base/token_selector/token_container.js +0 -165
  139. package/dist/components/base/token_selector/token_selector.js +0 -403
  140. package/dist/components/base/token_selector/token_selector_dropdown.js +0 -199
  141. package/dist/components/base/tooltip/tooltip.js +0 -55
  142. package/dist/components/charts/area/area.js +0 -311
  143. package/dist/components/charts/bar/bar.js +0 -253
  144. package/dist/components/charts/chart/chart.js +0 -215
  145. package/dist/components/charts/column/column.js +0 -226
  146. package/dist/components/charts/discrete_scatter/discrete_scatter.js +0 -203
  147. package/dist/components/charts/gauge/gauge.js +0 -208
  148. package/dist/components/charts/heatmap/heatmap.js +0 -295
  149. package/dist/components/charts/heatmap/index.js +0 -2
  150. package/dist/components/charts/legend/legend.js +0 -228
  151. package/dist/components/charts/line/line.js +0 -308
  152. package/dist/components/charts/series_label/series_label.js +0 -100
  153. package/dist/components/charts/single_stat/single_stat.js +0 -152
  154. package/dist/components/charts/sparkline/sparkline.js +0 -261
  155. package/dist/components/charts/stacked_column/stacked_column.js +0 -335
  156. package/dist/components/charts/tooltip/tooltip.js +0 -251
  157. package/dist/components/experimental/duo/chat/components/duo_chat_conversation/duo_chat_conversation.js +0 -83
  158. package/dist/components/experimental/duo/chat/components/duo_chat_loader/duo_chat_loader.js +0 -100
  159. package/dist/components/experimental/duo/chat/components/duo_chat_message/copy_code_element.js +0 -35
  160. package/dist/components/experimental/duo/chat/components/duo_chat_message/duo_chat_message.js +0 -115
  161. package/dist/components/experimental/duo/chat/components/duo_chat_message_sources/duo_chat_message_sources.js +0 -104
  162. package/dist/components/experimental/duo/chat/components/duo_chat_predefined_prompts/duo_chat_predefined_prompts.js +0 -64
  163. package/dist/components/experimental/duo/chat/constants.js +0 -23
  164. package/dist/components/experimental/duo/chat/duo_chat.js +0 -359
  165. package/dist/components/experimental/duo/chat/mock_data.js +0 -83
  166. package/dist/components/experimental/duo/user_feedback/user_feedback.js +0 -94
  167. package/dist/components/experimental/duo/user_feedback/user_feedback_modal.js +0 -124
  168. package/dist/components/experimental/experiment_badge/constants.js +0 -4
  169. package/dist/components/experimental/experiment_badge/experiment_badge.js +0 -107
  170. package/dist/components/mixins/button_mixin.js +0 -11
  171. package/dist/components/mixins/safe_link_mixin.js +0 -30
  172. package/dist/components/mixins/tooltip_mixin.js +0 -21
  173. package/dist/components/regions/dashboard_skeleton/dashboard_skeleton.js +0 -53
  174. package/dist/components/regions/empty_state/empty_state.js +0 -154
  175. package/dist/components/shared_components/charts/tooltip_default_format.js +0 -53
  176. package/dist/components/shared_components/clear_icon_button/clear_icon_button.js +0 -64
  177. package/dist/components/shared_components/close_button/close_button.js +0 -54
  178. package/dist/components/utilities/animated_number/animated_number.js +0 -131
  179. package/dist/components/utilities/friendly_wrap/friendly_wrap.js +0 -75
  180. package/dist/components/utilities/intersection_observer/intersection_observer.js +0 -88
  181. package/dist/components/utilities/intersperse/intersperse.js +0 -86
  182. package/dist/components/utilities/sprintf/sprintf.js +0 -172
  183. package/dist/components/utilities/truncate/constants.js +0 -7
  184. package/dist/components/utilities/truncate/truncate.js +0 -111
  185. package/dist/components/utilities/truncate_text/constants.js +0 -7
  186. package/dist/components/utilities/truncate_text/truncate_text.js +0 -146
  187. package/dist/config.js +0 -86
  188. package/dist/directives/collapse_toggle.js +0 -1
  189. package/dist/directives/hover_load/hover_load.js +0 -45
  190. package/dist/directives/modal.js +0 -1
  191. package/dist/directives/outside/get_event_like_time_stamp.js +0 -33
  192. package/dist/directives/outside/outside.js +0 -106
  193. package/dist/directives/resize_observer/resize_observer.js +0 -51
  194. package/dist/directives/safe_html/constants.js +0 -6
  195. package/dist/directives/safe_html/safe_html.js +0 -35
  196. package/dist/directives/safe_link/mock_data.js +0 -10
  197. package/dist/directives/safe_link/safe_link.js +0 -65
  198. package/dist/directives/tooltip.js +0 -1
  199. package/dist/index.css +0 -7
  200. package/dist/index.css.map +0 -1
  201. package/dist/index.js +0 -105
  202. package/dist/tokens/common_story_options.js +0 -109
  203. package/dist/utils/breakpoints.js +0 -20
  204. package/dist/utils/charts/config.js +0 -556
  205. package/dist/utils/charts/constants.js +0 -63
  206. package/dist/utils/charts/mock_data.js +0 -211
  207. package/dist/utils/charts/story_config.js +0 -42
  208. package/dist/utils/charts/theme.js +0 -192
  209. package/dist/utils/charts/utils.js +0 -54
  210. package/dist/utils/constants.js +0 -270
  211. package/dist/utils/data_utils.js +0 -21
  212. package/dist/utils/datetime_utility.js +0 -61
  213. package/dist/utils/i18n.js +0 -15
  214. package/dist/utils/is_slot_empty.js +0 -38
  215. package/dist/utils/number_utils.js +0 -124
  216. package/dist/utils/stories_constants.js +0 -29
  217. package/dist/utils/stories_utils.js +0 -13
  218. package/dist/utils/story_decorators/container.js +0 -16
  219. package/dist/utils/string_utils.js +0 -69
  220. package/dist/utils/svgs/svg_paths.js +0 -7
  221. package/dist/utils/test_utils.js +0 -33
  222. package/dist/utils/use_fake_date.js +0 -29
  223. package/dist/utils/use_mock_intersection_observer.js +0 -108
  224. package/dist/utils/utils.js +0 -177
  225. package/dist/utils.js +0 -5
@@ -1,203 +0,0 @@
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__;
@@ -1,384 +0,0 @@
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__;