@gitlab/ui 32.37.0 → 32.38.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.
- package/CHANGELOG.md +7 -0
- package/dist/components/base/filtered_search/filtered_search_token_segment.js +5 -0
- package/dist/components/base/table/constants.js +5 -0
- package/dist/components/base/table/table.js +19 -1
- package/dist/utils/utils.js +12 -2
- package/package.json +2 -2
- package/src/components/base/filtered_search/filtered_search_token_segment.spec.js +17 -1
- package/src/components/base/filtered_search/filtered_search_token_segment.vue +5 -0
- package/src/components/base/table/constants.js +49 -0
- package/src/components/base/table/table.spec.js +49 -0
- package/src/components/base/table/table.vue +16 -0
- package/src/utils/utils.js +11 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [32.38.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v32.37.0...v32.38.0) (2021-11-17)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **GlFilteredSearchTokenSegment:** Colon support ([abf3856](https://gitlab.com/gitlab-org/gitlab-ui/commit/abf3856396080e6699ddfbcd526991dcea2dc5f3))
|
|
7
|
+
|
|
1
8
|
# [32.37.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v32.36.0...v32.37.0) (2021-11-10)
|
|
2
9
|
|
|
3
10
|
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
const tableFullSlots = ['bottom-row', 'empty', 'emptyfiltered', 'table-busy', 'thead-top', 'top-row'];
|
|
2
|
+
const tableFullProps = ['api-url', 'busy', 'current-page', 'empty-filtered-html', 'empty-filtered-text', 'empty-html', 'empty-text', 'filter', 'filter-debounce', 'filter-function', 'filter-ignored-fields', 'filter-included-fields', 'label-sort-asc', 'label-sort-clear', 'label-sort-desc', 'no-footer-sorting', 'no-local-sorting', 'no-provider-filtering', 'no-provider-paging', 'no-provider-sorting', 'no-select-on-click', 'no-sort-reset', 'per-page', 'select-mode', 'selectable', 'selected-variant', 'show-empty', 'sort-by', 'sort-compare', 'sort-compare-locale', 'sort-compare-options', 'sort-desc', 'sort-direction', 'sort-icon-left', 'sort-null-last'];
|
|
3
|
+
const glTableLiteWarning = 'This GlTable could be a GlTableLite component, please consider using GlTableLite instead of GlTable to reduce the page bundlesize more about this here: https://gitlab-org.gitlab.io/gitlab-ui/?path=/docs/base-table-table-lite--default';
|
|
4
|
+
|
|
5
|
+
export { glTableLiteWarning, tableFullProps, tableFullSlots };
|
|
@@ -1,11 +1,29 @@
|
|
|
1
1
|
import { BTable } from 'bootstrap-vue/esm/index.js';
|
|
2
|
+
import { isDev, logWarning } from '../../../utils/utils';
|
|
3
|
+
import { tableFullProps, tableFullSlots, glTableLiteWarning } from './constants';
|
|
2
4
|
import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
|
|
3
5
|
|
|
6
|
+
const shouldUseFullTable = ({
|
|
7
|
+
$attrs,
|
|
8
|
+
$scopedSlots
|
|
9
|
+
}) => {
|
|
10
|
+
return tableFullProps.some(prop => $attrs[prop] !== undefined) || tableFullSlots.some(slot => $scopedSlots[slot] !== undefined);
|
|
11
|
+
};
|
|
12
|
+
|
|
4
13
|
var script = {
|
|
5
14
|
components: {
|
|
6
15
|
BTable
|
|
7
16
|
},
|
|
8
|
-
inheritAttrs: false
|
|
17
|
+
inheritAttrs: false,
|
|
18
|
+
|
|
19
|
+
mounted() {
|
|
20
|
+
// logWarning will call isDev before logging any message
|
|
21
|
+
// this additional call to isDev is being made to exit the condition early when run in production
|
|
22
|
+
if (isDev() && !shouldUseFullTable(this)) {
|
|
23
|
+
logWarning(glTableLiteWarning);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
9
27
|
};
|
|
10
28
|
|
|
11
29
|
/* script */
|
package/dist/utils/utils.js
CHANGED
|
@@ -88,15 +88,25 @@ function focusFirstFocusableElement(elts) {
|
|
|
88
88
|
const focusableElt = elts.find(el => isElementFocusable(el));
|
|
89
89
|
if (focusableElt) focusableElt.focus();
|
|
90
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* Returns true if the current environment is considered a development environment (it's not
|
|
93
|
+
* production or test).
|
|
94
|
+
*
|
|
95
|
+
* @returns {boolean}
|
|
96
|
+
*/
|
|
97
|
+
|
|
98
|
+
function isDev() {
|
|
99
|
+
return !['test', 'production'].includes(process.env.NODE_ENV);
|
|
100
|
+
}
|
|
91
101
|
/**
|
|
92
102
|
* Prints a warning message to the console in non-test and non-production environments.
|
|
93
103
|
* @param {string} message message to print to the console
|
|
94
104
|
*/
|
|
95
105
|
|
|
96
106
|
function logWarning(message = '') {
|
|
97
|
-
if (message.length &&
|
|
107
|
+
if (message.length && isDev()) {
|
|
98
108
|
console.warn(message); // eslint-disable-line no-console
|
|
99
109
|
}
|
|
100
110
|
}
|
|
101
111
|
|
|
102
|
-
export { colorFromBackground, debounceByAnimationFrame, focusFirstFocusableElement, hexToRgba, isElementFocusable, logWarning, rgbFromHex, rgbFromString, throttle, uid };
|
|
112
|
+
export { colorFromBackground, debounceByAnimationFrame, focusFirstFocusableElement, hexToRgba, isDev, isElementFocusable, logWarning, rgbFromHex, rgbFromString, throttle, uid };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gitlab/ui",
|
|
3
|
-
"version": "32.
|
|
3
|
+
"version": "32.38.0",
|
|
4
4
|
"description": "GitLab UI Components",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -129,7 +129,7 @@
|
|
|
129
129
|
"postcss-scss": "^2.1.1",
|
|
130
130
|
"prettier": "2.2.1",
|
|
131
131
|
"pug": "^2.0.3",
|
|
132
|
-
"puppeteer": "^
|
|
132
|
+
"puppeteer": "^10.4.0",
|
|
133
133
|
"raw-loader": "^0.5.1",
|
|
134
134
|
"rollup": "^2.53.1",
|
|
135
135
|
"rollup-plugin-babel": "^4.4.0",
|
|
@@ -27,7 +27,7 @@ describe('Filtered search token segment', () => {
|
|
|
27
27
|
methods: {
|
|
28
28
|
nextItem: jest.fn(),
|
|
29
29
|
prevItem: jest.fn(),
|
|
30
|
-
getValue:
|
|
30
|
+
getValue: () => 'notnull',
|
|
31
31
|
},
|
|
32
32
|
template: `<div class="ololosha"><slot></slot></div>`,
|
|
33
33
|
};
|
|
@@ -195,6 +195,22 @@ describe('Filtered search token segment', () => {
|
|
|
195
195
|
expect(wrapper.emitted().select[0][0]).toBe(formattedToken);
|
|
196
196
|
expect(wrapper.emitted().complete[0][0]).toBe(formattedToken);
|
|
197
197
|
});
|
|
198
|
+
|
|
199
|
+
it('selects suggestion on press Enter', () => {
|
|
200
|
+
createComponent({ active: true, options: OPTIONS, value: false });
|
|
201
|
+
wrapper.find('input').trigger('keydown', { key: 'ArrowDown' });
|
|
202
|
+
|
|
203
|
+
wrapper.find('input').trigger('keydown', { key: 'Enter' });
|
|
204
|
+
expect(wrapper.emitted('select')).toHaveLength(1);
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
it('selects suggestion on press Colon', () => {
|
|
208
|
+
createComponent({ active: true, options: OPTIONS, value: false });
|
|
209
|
+
wrapper.find('input').trigger('keydown', { key: 'ArrowDown' });
|
|
210
|
+
|
|
211
|
+
wrapper.find('input').trigger('keydown', { key: ':' });
|
|
212
|
+
expect(wrapper.emitted('select')).toHaveLength(1);
|
|
213
|
+
});
|
|
198
214
|
});
|
|
199
215
|
|
|
200
216
|
describe('when multi select', () => {
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export const tableFullSlots = [
|
|
2
|
+
'bottom-row',
|
|
3
|
+
'empty',
|
|
4
|
+
'emptyfiltered',
|
|
5
|
+
'table-busy',
|
|
6
|
+
'thead-top',
|
|
7
|
+
'top-row',
|
|
8
|
+
];
|
|
9
|
+
|
|
10
|
+
export const tableFullProps = [
|
|
11
|
+
'api-url',
|
|
12
|
+
'busy',
|
|
13
|
+
'current-page',
|
|
14
|
+
'empty-filtered-html',
|
|
15
|
+
'empty-filtered-text',
|
|
16
|
+
'empty-html',
|
|
17
|
+
'empty-text',
|
|
18
|
+
'filter',
|
|
19
|
+
'filter-debounce',
|
|
20
|
+
'filter-function',
|
|
21
|
+
'filter-ignored-fields',
|
|
22
|
+
'filter-included-fields',
|
|
23
|
+
'label-sort-asc',
|
|
24
|
+
'label-sort-clear',
|
|
25
|
+
'label-sort-desc',
|
|
26
|
+
'no-footer-sorting',
|
|
27
|
+
'no-local-sorting',
|
|
28
|
+
'no-provider-filtering',
|
|
29
|
+
'no-provider-paging',
|
|
30
|
+
'no-provider-sorting',
|
|
31
|
+
'no-select-on-click',
|
|
32
|
+
'no-sort-reset',
|
|
33
|
+
'per-page',
|
|
34
|
+
'select-mode',
|
|
35
|
+
'selectable',
|
|
36
|
+
'selected-variant',
|
|
37
|
+
'show-empty',
|
|
38
|
+
'sort-by',
|
|
39
|
+
'sort-compare',
|
|
40
|
+
'sort-compare-locale',
|
|
41
|
+
'sort-compare-options',
|
|
42
|
+
'sort-desc',
|
|
43
|
+
'sort-direction',
|
|
44
|
+
'sort-icon-left',
|
|
45
|
+
'sort-null-last',
|
|
46
|
+
];
|
|
47
|
+
|
|
48
|
+
export const glTableLiteWarning =
|
|
49
|
+
'This GlTable could be a GlTableLite component, please consider using GlTableLite instead of GlTable to reduce the page bundlesize more about this here: https://gitlab-org.gitlab.io/gitlab-ui/?path=/docs/base-table-table-lite--default';
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { shallowMount } from '@vue/test-utils';
|
|
2
|
+
import { logWarning } from '../../../utils/utils';
|
|
3
|
+
import { waitForAnimationFrame } from '../../../utils/test_utils';
|
|
4
|
+
import { glTableLiteWarning } from './constants';
|
|
5
|
+
import Table from './table.vue';
|
|
6
|
+
|
|
7
|
+
jest.mock('../../../utils/utils', () => ({
|
|
8
|
+
isDev: () => true,
|
|
9
|
+
logWarning: jest.fn(),
|
|
10
|
+
}));
|
|
11
|
+
|
|
12
|
+
describe('GlTable', () => {
|
|
13
|
+
const slotsTemplate = {
|
|
14
|
+
empty: `
|
|
15
|
+
<p>Placeholder empty text</p>`,
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const factory = ({ props = {}, scopedSlots = {} } = {}) => {
|
|
19
|
+
shallowMount(Table, {
|
|
20
|
+
scopedSlots,
|
|
21
|
+
propsData: props,
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
afterEach(() => {
|
|
26
|
+
logWarning.mockClear();
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('should log a warning when not given any props or slots which qualifies for the usage of GlTable', async () => {
|
|
30
|
+
factory();
|
|
31
|
+
await waitForAnimationFrame();
|
|
32
|
+
|
|
33
|
+
expect(logWarning).toHaveBeenCalledWith(glTableLiteWarning);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('should not log a warning when given a prop which qualifies for the usage of GlTable', async () => {
|
|
37
|
+
factory({ props: { busy: true } });
|
|
38
|
+
await waitForAnimationFrame();
|
|
39
|
+
|
|
40
|
+
expect(logWarning).not.toHaveBeenCalled();
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('should not log a warning when given a slot which qualifies for the usage of GlTable', async () => {
|
|
44
|
+
factory({ scopedSlots: slotsTemplate });
|
|
45
|
+
await waitForAnimationFrame();
|
|
46
|
+
|
|
47
|
+
expect(logWarning).not.toHaveBeenCalled();
|
|
48
|
+
});
|
|
49
|
+
});
|
|
@@ -1,11 +1,27 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import { BTable } from 'bootstrap-vue';
|
|
3
|
+
import { logWarning, isDev } from '../../../utils/utils';
|
|
4
|
+
import { tableFullSlots, tableFullProps, glTableLiteWarning } from './constants';
|
|
5
|
+
|
|
6
|
+
const shouldUseFullTable = ({ $attrs, $scopedSlots }) => {
|
|
7
|
+
return (
|
|
8
|
+
tableFullProps.some((prop) => $attrs[prop] !== undefined) ||
|
|
9
|
+
tableFullSlots.some((slot) => $scopedSlots[slot] !== undefined)
|
|
10
|
+
);
|
|
11
|
+
};
|
|
3
12
|
|
|
4
13
|
export default {
|
|
5
14
|
components: {
|
|
6
15
|
BTable,
|
|
7
16
|
},
|
|
8
17
|
inheritAttrs: false,
|
|
18
|
+
mounted() {
|
|
19
|
+
// logWarning will call isDev before logging any message
|
|
20
|
+
// this additional call to isDev is being made to exit the condition early when run in production
|
|
21
|
+
if (isDev() && !shouldUseFullTable(this)) {
|
|
22
|
+
logWarning(glTableLiteWarning);
|
|
23
|
+
}
|
|
24
|
+
},
|
|
9
25
|
};
|
|
10
26
|
</script>
|
|
11
27
|
|
package/src/utils/utils.js
CHANGED
|
@@ -103,12 +103,22 @@ export function focusFirstFocusableElement(elts) {
|
|
|
103
103
|
if (focusableElt) focusableElt.focus();
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
+
/**
|
|
107
|
+
* Returns true if the current environment is considered a development environment (it's not
|
|
108
|
+
* production or test).
|
|
109
|
+
*
|
|
110
|
+
* @returns {boolean}
|
|
111
|
+
*/
|
|
112
|
+
export function isDev() {
|
|
113
|
+
return !['test', 'production'].includes(process.env.NODE_ENV);
|
|
114
|
+
}
|
|
115
|
+
|
|
106
116
|
/**
|
|
107
117
|
* Prints a warning message to the console in non-test and non-production environments.
|
|
108
118
|
* @param {string} message message to print to the console
|
|
109
119
|
*/
|
|
110
120
|
export function logWarning(message = '') {
|
|
111
|
-
if (message.length &&
|
|
121
|
+
if (message.length && isDev()) {
|
|
112
122
|
console.warn(message); // eslint-disable-line no-console
|
|
113
123
|
}
|
|
114
124
|
}
|