@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,288 @@
1
+ import { POSITION } from '../components/utilities/truncate/constants';
2
+
3
+ function appendDefaultOption(options) {
4
+ return {
5
+ ...options,
6
+ default: ''
7
+ };
8
+ }
9
+ const COMMA = ',';
10
+ const CONTRAST_LEVELS = [{
11
+ grade: 'F',
12
+ min: 0,
13
+ max: 3
14
+ }, {
15
+ grade: 'AA+',
16
+ min: 3,
17
+ max: 4.5
18
+ }, {
19
+ grade: 'AA',
20
+ min: 4.5,
21
+ max: 7
22
+ }, {
23
+ grade: 'AAA',
24
+ min: 7,
25
+ max: 22
26
+ }];
27
+ const HEX_REGEX = /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;
28
+ const LEFT_MOUSE_BUTTON = 0;
29
+ const glThemes = ['indigo', 'blue', 'light-blue', 'green', 'red', 'light-red'];
30
+ const variantOptions = {
31
+ primary: 'primary',
32
+ secondary: 'secondary',
33
+ success: 'success',
34
+ warning: 'warning',
35
+ danger: 'danger',
36
+ info: 'info',
37
+ light: 'light',
38
+ dark: 'dark'
39
+ };
40
+ const badgeSizeOptions = {
41
+ sm: 'sm',
42
+ md: 'md',
43
+ lg: 'lg'
44
+ };
45
+ const badgeVariantOptions = {
46
+ muted: 'muted',
47
+ neutral: 'neutral',
48
+ info: 'info',
49
+ success: 'success',
50
+ warning: 'warning',
51
+ danger: 'danger',
52
+ tier: 'tier'
53
+ };
54
+ const badgeIconSizeOptions = {
55
+ sm: 12,
56
+ md: 16
57
+ };
58
+ const variantCssColorMap = {
59
+ muted: 'gl-text-gray-500',
60
+ neutral: 'gl-text-blue-100',
61
+ info: 'gl-text-blue-500',
62
+ success: 'gl-text-green-500',
63
+ warning: 'gl-text-orange-500',
64
+ danger: 'gl-text-red-500'
65
+ };
66
+ const targetOptions = ['_self', '_blank', '_parent', '_top', null];
67
+ const labelSizeOptions = {
68
+ default: null,
69
+ sm: 'sm'
70
+ };
71
+ const viewModeOptions = {
72
+ dark: 'dark',
73
+ light: 'light'
74
+ };
75
+ const labelColorOptions = {
76
+ ...viewModeOptions
77
+ };
78
+ const avatarSizeOptions = [96, 64, 48, 32, 24, 16];
79
+ const avatarsInlineSizeOptions = [32, 24, 16];
80
+ const avatarShapeOptions = {
81
+ circle: 'circle',
82
+ rect: 'rect'
83
+ };
84
+ const formStateOptions = {
85
+ default: null,
86
+ valid: true,
87
+ invalid: false
88
+ };
89
+ const buttonCategoryOptions = {
90
+ primary: 'primary',
91
+ secondary: 'secondary',
92
+ tertiary: 'tertiary'
93
+ };
94
+ const buttonVariantOptions = {
95
+ default: 'default',
96
+ confirm: 'confirm',
97
+ info: 'info (deprecated)',
98
+ success: 'success (deprecated)',
99
+ danger: 'danger',
100
+ dashed: 'dashed',
101
+ link: 'link',
102
+ /**
103
+ * The "reset" variant can be used when customization of GlButton styles is required
104
+ * (e.g. for the "close" button in GlLabel).
105
+ * It should be used sparingly and only when other approaches fail.
106
+ * Prefer supported variants where ever possible.
107
+ */
108
+ reset: 'gl-reset'
109
+ };
110
+ const badgeForButtonOptions = {
111
+ [buttonVariantOptions.default]: badgeVariantOptions.neutral,
112
+ [buttonVariantOptions.confirm]: badgeVariantOptions.info,
113
+ [buttonVariantOptions.danger]: badgeVariantOptions.danger
114
+ };
115
+ const dropdownVariantOptions = {
116
+ default: 'default',
117
+ confirm: 'confirm',
118
+ info: 'info (deprecated)',
119
+ success: 'success (deprecated)',
120
+ danger: 'danger',
121
+ link: 'link'
122
+ };
123
+ const dropdownPlacements = {
124
+ left: 'bottom-start',
125
+ center: 'bottom',
126
+ right: 'bottom-end'
127
+ };
128
+ const dropdownAnyCornerPlacement = [dropdownPlacements.left, 'top-start', dropdownPlacements.right, 'top-end'];
129
+ const dropdownAllowedAutoPlacements = {
130
+ left: dropdownAnyCornerPlacement,
131
+ center: [dropdownPlacements.center, 'top'],
132
+ right: dropdownAnyCornerPlacement
133
+ };
134
+ const buttonSizeOptions = {
135
+ small: 'sm',
136
+ medium: 'md'
137
+ };
138
+ const datepickerWidthOptionsMap = {
139
+ sm: 'sm',
140
+ md: 'md',
141
+ lg: 'lg',
142
+ xl: 'xl'
143
+ };
144
+
145
+ // size options all have corresponding styles (e.g. .s12 defined in icon.scss)
146
+ const iconSizeOptions = [8, 12, 14, 16, 24, 32, 48, 72];
147
+ const triggerVariantOptions = {
148
+ click: 'click',
149
+ hover: 'hover',
150
+ focus: 'focus'
151
+ };
152
+ const tooltipPlacements = {
153
+ top: 'top',
154
+ left: 'left',
155
+ right: 'right',
156
+ bottom: 'bottom'
157
+ };
158
+
159
+ // in milliseconds
160
+ const tooltipDelay = {
161
+ show: 500,
162
+ hide: 0
163
+ };
164
+ const popoverPlacements = {
165
+ top: 'top',
166
+ right: 'right',
167
+ bottom: 'bottom',
168
+ left: 'left'
169
+ };
170
+ const columnOptions = {
171
+ stacked: 'stacked',
172
+ tiled: 'tiled'
173
+ };
174
+ const alignOptions = {
175
+ left: 'left',
176
+ center: 'center',
177
+ right: 'right',
178
+ fill: 'fill'
179
+ };
180
+ const alertVariantOptions = {
181
+ success: 'success',
182
+ warning: 'warning',
183
+ danger: 'danger',
184
+ info: 'info',
185
+ tip: 'tip'
186
+ };
187
+ const alertVariantIconMap = {
188
+ success: 'check-circle',
189
+ warning: 'warning',
190
+ danger: 'error',
191
+ info: 'information-o',
192
+ tip: 'bulb'
193
+ };
194
+ const colorThemes = {
195
+ indigo: 'theme-indigo-900',
196
+ 'light-indigo': 'theme-indigo-700',
197
+ blue: 'theme-blue-900',
198
+ 'light-blue': 'theme-blue-700',
199
+ green: 'theme-green-900',
200
+ 'light-green': 'theme-green-700',
201
+ red: 'theme-red-900',
202
+ 'light-red': 'theme-red-700',
203
+ dark: 'gray-900',
204
+ light: 'gray-700'
205
+ };
206
+ const modalButtonDefaults = {
207
+ actionPrimary: {
208
+ variant: 'confirm',
209
+ category: 'primary'
210
+ },
211
+ actionSecondary: {
212
+ variant: 'confirm',
213
+ category: 'secondary'
214
+ },
215
+ actionCancel: {
216
+ variant: 'default'
217
+ }
218
+ };
219
+ const tabsButtonDefaults = {
220
+ actionPrimary: {
221
+ variant: 'success',
222
+ category: 'primary'
223
+ },
224
+ actionSecondary: {
225
+ variant: 'default',
226
+ category: 'secondary'
227
+ },
228
+ actionTertiary: {
229
+ variant: 'default'
230
+ }
231
+ };
232
+ const tokenVariants = ['default', 'search-type', 'search-value'];
233
+ const resizeDebounceTime = 200;
234
+ const variantOptionsWithNoDefault = appendDefaultOption(variantOptions);
235
+
236
+ // Datetime constants
237
+ const defaultDateFormat = 'YYYY-MM-DD';
238
+ const bannerVariants = ['promotion', 'introduction'];
239
+ const maxZIndex = 10;
240
+ const modalSizeOptions = {
241
+ sm: 'sm',
242
+ md: 'md',
243
+ lg: 'lg'
244
+ };
245
+ const focusableTags = ['INPUT', 'TEXTAREA', 'A', 'BUTTON', 'SELECT'];
246
+ const keyboard = {
247
+ escape: 'Escape',
248
+ backspace: 'Backspace',
249
+ delete: 'Delete',
250
+ left: 'Left',
251
+ arrowLeft: 'ArrowLeft',
252
+ right: 'Right',
253
+ arrowRight: 'ArrowRight',
254
+ home: 'Home',
255
+ end: 'End',
256
+ tab: 'Tab'
257
+ };
258
+ const truncateOptions = POSITION;
259
+ const formInputWidths = {
260
+ xs: 'xs',
261
+ sm: 'sm',
262
+ md: 'md',
263
+ lg: 'lg',
264
+ xl: 'xl',
265
+ '(unset or null)': null
266
+ };
267
+ const toggleLabelPosition = {
268
+ hidden: 'hidden',
269
+ left: 'left',
270
+ top: 'top'
271
+ };
272
+ const tooltipActionEvents = ['open', 'close', 'enable', 'disable'];
273
+ const drawerVariants = {
274
+ default: 'default',
275
+ sidebar: 'sidebar'
276
+ };
277
+ const loadingIconSizes = {
278
+ 'sm (16x16)': 'sm',
279
+ 'md (24x24)': 'md',
280
+ 'lg (32x32)': 'lg',
281
+ 'xl (64x64)': 'xl'
282
+ };
283
+ const loadingIconVariants = {
284
+ spinner: 'spinner',
285
+ dots: 'dots'
286
+ };
287
+
288
+ export { COMMA, CONTRAST_LEVELS, HEX_REGEX, LEFT_MOUSE_BUTTON, alertVariantIconMap, alertVariantOptions, alignOptions, avatarShapeOptions, avatarSizeOptions, avatarsInlineSizeOptions, badgeForButtonOptions, badgeIconSizeOptions, badgeSizeOptions, badgeVariantOptions, bannerVariants, buttonCategoryOptions, buttonSizeOptions, buttonVariantOptions, colorThemes, columnOptions, datepickerWidthOptionsMap, defaultDateFormat, drawerVariants, dropdownAllowedAutoPlacements, dropdownPlacements, dropdownVariantOptions, focusableTags, formInputWidths, formStateOptions, glThemes, iconSizeOptions, keyboard, labelColorOptions, labelSizeOptions, loadingIconSizes, loadingIconVariants, maxZIndex, modalButtonDefaults, modalSizeOptions, popoverPlacements, resizeDebounceTime, tabsButtonDefaults, targetOptions, toggleLabelPosition, tokenVariants, tooltipActionEvents, tooltipDelay, tooltipPlacements, triggerVariantOptions, truncateOptions, variantCssColorMap, variantOptions, variantOptionsWithNoDefault, viewModeOptions };
@@ -0,0 +1,21 @@
1
+ import curry from 'lodash/fp/curry';
2
+
3
+ const getRepeatingValue = index => {
4
+ const values = [100, 500, 400, 200, 100, 800, 400, 500, 600, 300, 800, 900, 110, 700, 400, 300, 500, 300, 400, 600, 700];
5
+ return index < values.length ? values[index] : values[index % values.length];
6
+ };
7
+ const generateTimeSeries = () => new Array(100).fill(0).map((el, i) => [new Date(2018, 0, i), getRepeatingValue(i)]);
8
+
9
+ // takes an element and a list and `intersperses' that element between the elements of the list.
10
+ // (',' ['a', 'b', 'c']) -> ['a', ',', 'b', ',', 'c']
11
+ const intersperse = curry((separator, items) => {
12
+ const [head, ...rest] = items;
13
+ const separatorFactory = typeof separator === 'function' ? separator : () => separator;
14
+ return [head, ...rest.flatMap(item => [separatorFactory(), item], rest)];
15
+ });
16
+
17
+ // inserts a value at a given index into an array
18
+ // (1, 2, [1, 3, 4]) -> [1, 2, 3, 4]
19
+ const insert = curry((index, newItem, items) => [...items.slice(0, index), newItem, ...items.slice(index)]);
20
+
21
+ export { generateTimeSeries, insert, intersperse };
@@ -0,0 +1,61 @@
1
+ // These utility methods come from the Gitlab repo; app/assets/javascripts/lib/utils/datetime_utility.js
2
+
3
+ /**
4
+ * This method allows you to create new Date instance from existing
5
+ * date instance without keeping the reference.
6
+ *
7
+ * @param {Date} date
8
+ */
9
+ const newDate = date => date instanceof Date ? new Date(date.getTime()) : new Date();
10
+
11
+ /**
12
+ * Computes the difference between 2 date objects.
13
+ *
14
+ * @param {Date} a the start date
15
+ * @param {Date} b the end date
16
+ * @example
17
+ * // returns 5
18
+ * getDayDifference(new Date('2020-08-10'), new Date('2020-08-15'));
19
+ * @returns {Number} Number of days between the 2 dates
20
+ */
21
+ const getDayDifference = (a, b) => {
22
+ const millisecondsPerDay = 1000 * 60 * 60 * 24;
23
+ const date1 = Date.UTC(a.getFullYear(), a.getMonth(), a.getDate());
24
+ const date2 = Date.UTC(b.getFullYear(), b.getMonth(), b.getDate());
25
+ return Math.floor((date2 - date1) / millisecondsPerDay);
26
+ };
27
+
28
+ /**
29
+ * Subtracts a given number of days from a given date and returns the new date.
30
+ *
31
+ * @param {Date} date the date that we will substract days from
32
+ * @param {Number} daysInPast number of days that are subtracted from a given date
33
+ * @example
34
+ * // returns Mon Aug 10 2020 00:00:00
35
+ * getDateInPast(new Date('2020-08-15'), 5);
36
+ * @returns {Date} Date in past as Date object
37
+ */
38
+ const getDateInPast = (date, daysInPast) => new Date(newDate(date).setDate(date.getDate() - daysInPast));
39
+
40
+ /**
41
+ * Adds a given number of days to a given date and returns the new date.
42
+ *
43
+ * @param {Date} date the date that we will add days to
44
+ * @param {Number} daysInFuture number of days that are added to a given date
45
+ * @example
46
+ * // returns Mon Aug 15 2020 00:00:00
47
+ * getDateInFuture(new Date('2020-08-10'), 5);
48
+ * @returns {Date} Date in future as Date object
49
+ */
50
+ const getDateInFuture = (date, daysInFuture) => new Date(newDate(date).setDate(date.getDate() + daysInFuture));
51
+
52
+ /**
53
+ * Are the given two dates equal
54
+ *
55
+ * @param {Date} date1
56
+ * @param {Date} date2
57
+ * @returns {Boolean}
58
+ */
59
+ const areDatesEqual = (date1, date2) => Boolean(date1 && date2 && new Date(date1).getTime() === new Date(date2).getTime());
60
+
61
+ export { areDatesEqual, getDateInFuture, getDateInPast, getDayDifference, newDate };
@@ -0,0 +1,15 @@
1
+ import { i18n } from '../config';
2
+
3
+ /**
4
+ * Mark a label as translatable.
5
+ *
6
+ * @param {string} key Translation key to be leveraged by the consumer to provide a generic translation at configuration time.
7
+ * @param {string} defaultValue A fallback value to be relied on if the consumer doesn't have translation capabilities.
8
+ * @returns {string} The translated label.
9
+ */
10
+ const translate = (key, defaultValue) => {
11
+ var _i18n$key;
12
+ return (_i18n$key = i18n[key]) !== null && _i18n$key !== void 0 ? _i18n$key : defaultValue;
13
+ };
14
+
15
+ export { translate };
@@ -0,0 +1,38 @@
1
+ import Vue from 'vue';
2
+
3
+ // Fragment will be available only in Vue.js 3
4
+ const {
5
+ Fragment,
6
+ Comment
7
+ } = Vue;
8
+ function callIfNeeded(fnOrResult, args) {
9
+ return fnOrResult instanceof Function ? fnOrResult(args) : fnOrResult;
10
+ }
11
+ function isEmpty(vnode) {
12
+ if (!vnode || Comment && vnode.type === Comment) {
13
+ return true;
14
+ }
15
+ if (Array.isArray(vnode)) {
16
+ // eslint-disable-next-line unicorn/no-array-callback-reference
17
+ return vnode.every(isEmpty);
18
+ }
19
+ if (Fragment && vnode.type === Fragment) {
20
+ // Vue.js 3 fragment, check children
21
+ // eslint-disable-next-line unicorn/no-array-callback-reference
22
+ return vnode.children.every(isEmpty);
23
+ }
24
+ return false;
25
+ }
26
+ function isSlotEmpty(vueInstance, slot, slotArgs) {
27
+ var _vueInstance$$scopedS, _vueInstance$$scopedS2;
28
+ const isVue3 = Boolean(Fragment);
29
+ const slotContent = isVue3 ?
30
+ // we need to check both $slots and $scopedSlots due to https://github.com/vuejs/core/issues/8869
31
+ // additionally, in @vue/compat $slot might be a function instead of array of vnodes (sigh)
32
+ callIfNeeded(vueInstance.$slots[slot] || vueInstance.$scopedSlots[slot], slotArgs) : (_vueInstance$$scopedS = (_vueInstance$$scopedS2 = vueInstance.$scopedSlots)[slot]) === null || _vueInstance$$scopedS === void 0 ? void 0 : _vueInstance$$scopedS.call(_vueInstance$$scopedS2, slotArgs);
33
+
34
+ // eslint-disable-next-line unicorn/no-array-callback-reference
35
+ return isEmpty(slotContent);
36
+ }
37
+
38
+ export { isSlotEmpty };
@@ -0,0 +1,124 @@
1
+ /**
2
+ * Adds two numbers together
3
+ * @param {Number} a
4
+ * @param {Number} b
5
+ */
6
+ const addition = (a, b) => a + b;
7
+
8
+ /**
9
+ * Returns the sum of all arguments
10
+ * @param {...Number} numbers
11
+ */
12
+ const sum = function () {
13
+ for (var _len = arguments.length, numbers = new Array(_len), _key = 0; _key < _len; _key++) {
14
+ numbers[_key] = arguments[_key];
15
+ }
16
+ return numbers.reduce(addition);
17
+ }; // eslint-disable-line unicorn/no-array-callback-reference
18
+
19
+ /**
20
+ * Returns the average of all arguments
21
+ * @param {...Number} numbers
22
+ */
23
+ const average = function () {
24
+ return sum(...arguments) / arguments.length;
25
+ };
26
+
27
+ /**
28
+ * Returns the modulo of n for a divisor.
29
+ *
30
+ * Maps the integer n into the range [0, divisor) when the divisor is positive,
31
+ * and (divisor, 0] when the divisor is negative.
32
+ *
33
+ * This is useful when indexing into an array, to ensure you always stay within
34
+ * the array bounds.
35
+ *
36
+ * See https://2ality.com/2019/08/remainder-vs-modulo.html.
37
+ *
38
+ * @param {number} n The number to mod.
39
+ * @param {number} divisor The divisor (e.g., the length of an array).
40
+ * @returns {number}
41
+ */
42
+ function modulo(n, divisor) {
43
+ const result = (n % divisor + divisor) % divisor;
44
+ // Never return -0.
45
+ return result === 0 ? 0 : result;
46
+ }
47
+
48
+ /**
49
+ * Convert number to engineering format, using SI suffix
50
+ * @param {Number|String} value - Number or Number-convertible String
51
+ * @param {Number} precision
52
+ * @return {String} number, possibly with a suffix
53
+ */
54
+ const engineeringNotation = function (value) {
55
+ let precision = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;
56
+ const invalidValues = [NaN, Infinity, -Infinity];
57
+ const num = Number(value);
58
+ if (invalidValues.includes(num) || invalidValues.includes(Number(precision))) {
59
+ return num.toString();
60
+ }
61
+ const allYourBase = {
62
+ '-24': 'y',
63
+ '-21': 'z',
64
+ '-18': 'a',
65
+ '-15': 'f',
66
+ '-12': 'p',
67
+ '-9': 'n',
68
+ '-6': 'μ',
69
+ '-3': 'm',
70
+ 0: '',
71
+ 3: 'k',
72
+ 6: 'M',
73
+ 9: 'G',
74
+ 12: 'T',
75
+ 15: 'P',
76
+ 18: 'E',
77
+ 21: 'Z',
78
+ 24: 'Y'
79
+ };
80
+ const exponentialNotation = num.toExponential(precision);
81
+ const power = exponentialNotation.split('e').map(Number)[1] || 0;
82
+ if (power < -24 || power > 24) {
83
+ return exponentialNotation;
84
+ }
85
+ const scaledPower = 3 * Math.floor(power / 3);
86
+ const scaledMantissa = (exponentialNotation / 10 ** scaledPower
87
+ // strip trailing decimals from floating point rounding errors
88
+ ).toFixed(precision)
89
+ // strip trailing 0s after a decimal point
90
+ .replace(/\.([1-9]*)0+$/, (_, fractionalDigits) => {
91
+ if (fractionalDigits) {
92
+ return `.${fractionalDigits}`;
93
+ }
94
+ return '';
95
+ });
96
+ return `${scaledMantissa}${allYourBase[scaledPower]}`;
97
+ };
98
+
99
+ /**
100
+ * Formats a number as a locale-based string using `Intl.NumberFormat`.
101
+ *
102
+ * 2333 -> 2,333
103
+ * 232324 -> 232,324
104
+ *
105
+ * @param {Number|string} value - number to be converted
106
+ * @param {{}?} options - options to be passed to
107
+ * `Intl.NumberFormat` such as `unit` and `style`.
108
+ * @param {String|String[]} locales - If set, forces a different
109
+ * language code from the one currently in the document.
110
+ *
111
+ * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat
112
+ *
113
+ * @returns {String}
114
+ */
115
+ const formatNumberToLocale = function (value) {
116
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
117
+ let locales = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
118
+ if (Number.isNaN(Number(value))) {
119
+ return value;
120
+ }
121
+ return new Intl.NumberFormat(locales, options).format(value);
122
+ };
123
+
124
+ export { addition, average, engineeringNotation, formatNumberToLocale, modulo, sum };
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Arg types subcategories to be used to organize props within arg tables
3
+ */
4
+
5
+ const ARG_TYPE_SUBCATEGORY_LOOK_AND_FEEL = 'Look & feel';
6
+ const ARG_TYPE_SUBCATEGORY_STATE = 'State';
7
+ const ARG_TYPE_SUBCATEGORY_SEARCH = 'Search';
8
+ const ARG_TYPE_SUBCATEGORY_ACCESSIBILITY = 'Accessibility';
9
+ const ARG_TYPE_SUBCATEGORY_INFINITE_SCROLL = 'Infinite scroll';
10
+
11
+ /**
12
+ * These are used to test varying lengths of series names
13
+ */
14
+ const SERIES_NAME_SHORT = 'SERIES_NAME_SHORT';
15
+ const SERIES_NAME_LONG = 'SERIES_NAME_LONG';
16
+ const SERIES_NAME_LONG_WITHOUT_SPACES = 'SERIES_NAME_LONG_WITHOUT_SPACES';
17
+ const SERIES_NAME = {
18
+ [SERIES_NAME_SHORT]: 'Series ',
19
+ [SERIES_NAME_LONG]: 'Series name long. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed tincidunt interdum sapien ut blandit. Nulla fermentum nisi id euismod vulputate. END',
20
+ [SERIES_NAME_LONG_WITHOUT_SPACES]: 'Series_name_long._Lorem_ipsum_dolor_sit_amet,_consectetur_adipiscing_elit._Sed_tincidunt_interdum_sapien_ut_blandit._Nulla_fermentum_nisi_id_euismod_vulputate._END'
21
+ };
22
+
23
+ /**
24
+ * Reused constants for ListBox
25
+ */
26
+
27
+ const LISTBOX_CONTAINER_HEIGHT = '370px';
28
+
29
+ export { ARG_TYPE_SUBCATEGORY_ACCESSIBILITY, ARG_TYPE_SUBCATEGORY_INFINITE_SCROLL, ARG_TYPE_SUBCATEGORY_LOOK_AND_FEEL, ARG_TYPE_SUBCATEGORY_SEARCH, ARG_TYPE_SUBCATEGORY_STATE, LISTBOX_CONTAINER_HEIGHT, SERIES_NAME, SERIES_NAME_LONG, SERIES_NAME_LONG_WITHOUT_SPACES, SERIES_NAME_SHORT };
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Builds the parameters object disable one or multiple controls.
3
+ */
4
+ const disableControls = function () {
5
+ let controls = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
6
+ return Object.fromEntries(controls.map(control => [control, {
7
+ control: {
8
+ disable: true
9
+ }
10
+ }]));
11
+ };
12
+
13
+ export { disableControls };
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Return a story decorator function, which wraps the given story in a `div`
3
+ * element with the given `style` attributes.
4
+ *
5
+ * @param {object} style The style attribute to apply to the container.
6
+ * @return {function} The story decorator.
7
+ */
8
+ const makeContainer = style => Story => ({
9
+ render(h) {
10
+ return h('div', {
11
+ style
12
+ }, [h(Story())]);
13
+ }
14
+ });
15
+
16
+ export { makeContainer };
@@ -0,0 +1,69 @@
1
+ import emojiRegexFactory from 'emoji-regex';
2
+
3
+ /**
4
+ * Split the given string after each occurrence of each of the given symbols.
5
+ *
6
+ * Symbols are strings, and can be of length one or more. Zero-length symbols
7
+ * are ignored.
8
+ *
9
+ * Unlike with `String::split`, the symbol is left in results, with
10
+ * the split occurring _after_ the symbol.
11
+ *
12
+ * For example:
13
+ *
14
+ * splitAfterSymbols(['/'], 'a/b/c') // ['a/', 'b/', 'c']
15
+ * splitAfterSymbols(['foo'], 'foobar') // ['foo', 'bar']
16
+ *
17
+ * @param {string[]} symbols The symbols to split the string by.
18
+ * @param {string} string The string to split.
19
+ * @returns {string[]} The resulting strings.
20
+ */
21
+ const splitAfterSymbols = (symbols, string) => {
22
+ const textParts = [];
23
+ let textPartStartIndex = 0;
24
+ if (string.length === 0) {
25
+ return [string];
26
+ }
27
+ for (let i = 0; i < string.length;) {
28
+ let symbolFound = false;
29
+ for (let j = 0; j < symbols.length; j += 1) {
30
+ const symbol = symbols[j];
31
+ if (!symbol) {
32
+ // eslint-disable-next-line no-continue
33
+ continue;
34
+ }
35
+ symbolFound = string.slice(i, i + symbol.length) === symbol;
36
+ if (symbolFound) {
37
+ const textPartEndIndex = i + symbol.length;
38
+ const textPart = string.slice(textPartStartIndex, textPartEndIndex);
39
+ textParts.push(textPart);
40
+ textPartStartIndex = textPartEndIndex;
41
+ i = textPartStartIndex;
42
+ break;
43
+ }
44
+ }
45
+ if (!symbolFound) {
46
+ i += 1;
47
+ }
48
+ }
49
+ const final = string.slice(textPartStartIndex);
50
+ if (final) {
51
+ textParts.push(final);
52
+ }
53
+ return textParts;
54
+ };
55
+ const startsWithEmojiRegex = `^(${emojiRegexFactory().source})`;
56
+ const getAvatarChar = name => {
57
+ if (name) {
58
+ // Check if string starts with an emoji (which could be multiple characters and zero-width joined)
59
+ const match = name.match(startsWithEmojiRegex);
60
+ if (match) {
61
+ // Return the first match
62
+ return match[0];
63
+ }
64
+ return name.charAt(0).toUpperCase();
65
+ }
66
+ return '';
67
+ };
68
+
69
+ export { getAvatarChar, splitAfterSymbols };
@@ -0,0 +1,7 @@
1
+ const scrollHandleSvgPath = 'path://M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zM6 4a1 1 0 0 0-1 1v6a1 1 0 0 0 2 0V5a1 1 0 0 0-1-1zm4 0a1 1 0 0 0-1 1v6a1 1 0 0 0 2 0V5a1 1 0 0 0-1-1z';
2
+ const marqueeSelectionSvgPath = 'path://M-6.251 -7L-7 -7L-7 -4.753A0.749 0.749 0 0 0 -5.502 -4.753L-5.502 -5.502L-4.753 -5.502A0.749 0.749 0 0 0 -4.753 -7L-6.251 -7ZM-6.251 -2.0067A0.749 0.749 0 0 1 -5.502 -1.2577L-5.502 1.239A0.749 0.749 0 1 1 -7 1.239L-7 -1.2577A0.749 0.749 0 0 1 -6.251 -2.0067ZM0.8455 0.8455L2.3505 4.3578L4.3578 2.3505L0.8455 0.8455ZM0.2883 -1.023L5.6251 1.264A0.9987 0.9987 0 0 1 5.9387 2.8888L4.943 3.8835L6.7616 5.703A0.749 0.749 0 1 1 5.703 6.7616L3.8835 4.943L2.8888 5.9387A0.9987 0.9987 0 0 1 1.264 5.6251L-1.023 0.2883C-1.3785 -0.5406 -0.5406 -1.3785 0.2883 -1.023ZM-6.251 6.9813L-7 6.9813L-7 4.7343A0.749 0.749 0 1 1 -5.502 4.7343L-5.502 5.4833L-4.753 5.4833A0.749 0.749 0 1 1 -4.753 6.9813L-6.251 6.9813ZM-2.0067 -6.251A0.749 0.749 0 0 1 -1.2577 -7L1.239 -7A0.749 0.749 0 1 1 1.239 -5.502L-1.2577 -5.502A0.749 0.749 0 0 1 -2.0067 -6.251ZM6.2323 -7L6.9813 -7L6.9813 -4.753A0.749 0.749 0 1 1 5.4833 -4.753L5.4833 -5.502L4.7343 -5.502A0.749 0.749 0 1 1 4.7343 -7L6.2323 -7Z';
3
+ const redoSvgPath = 'path://M1.8332 -6.7552A7.0001 7.0001 0 0 0 -5.6875 -4.082L-5.6875 -5.4689A0.6563 0.6563 0 0 0 -7 -5.4689L-7 -1.7501L-3.2812 -1.7501A0.6563 0.6563 0 0 0 -3.2812 -3.0626L-4.7923 -3.0626A5.6876 5.6876 0 1 1 -5.2526 2.1822A0.6563 0.6563 0 0 0 -6.4645 2.6853A7.0001 7.0001 0 1 0 1.8332 -6.7561Z';
4
+ const clearAllSvgPath = 'path://M-1.8332 -6.7552A7.0001 7.0001 0 0 1 5.6875 -4.082L5.6875 -5.4689A0.6563 0.6563 0 1 1 7 -5.4689L7 -1.7501L3.2812 -1.7501A0.6563 0.6563 0 1 1 3.2812 -3.0626L4.7923 -3.0626A5.6876 5.6876 0 1 0 5.2526 2.1822A0.6563 0.6563 0 1 1 6.4645 2.6853A7.0001 7.0001 0 1 1 -1.8332 -6.7561Z';
5
+ const downloadSvgPath = 'path://M3.78 -0.841A0.75 0.75 0 0 0 2.72 -0.841L0.75 1.129L0.75 -6.25A0.75 0.75 0 0 0 -0.75 -6.25L-0.75 1.129L-2.72 -0.841A0.75 0.75 0 0 0 -3.78 0.219L-0.53 3.469L0 4L0.53 3.47L3.78 0.22A0.75 0.75 0 0 0 3.78 -0.841ZM-5.5 1.75A0.75 0.75 0 0 0 -7 1.75L-7 5A2 2 0 0 0 -5 7L5 7A2 2 0 0 0 7 5L7 1.75A0.75 0.75 0 0 0 5.5 1.75L5.5 5A0.5 0.5 0 0 1 5 5.5L-5 5.5A0.5 0.5 0 0 1 -5.5 5L-5.5 1.75Z';
6
+
7
+ export { clearAllSvgPath, downloadSvgPath, marqueeSelectionSvgPath, redoSvgPath, scrollHandleSvgPath };