@gitlab/ui 38.12.0 → 39.2.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.
@@ -251,9 +251,5 @@ const loadingIconSizes = {
251
251
  'lg (32x32)': 'lg',
252
252
  'xl (64x64)': 'xl'
253
253
  };
254
- const textareaCountOptions = {
255
- max: 'max',
256
- recommended: 'recommended'
257
- };
258
254
 
259
- export { COMMA, alertVariantIconMap, alertVariantOptions, alignOptions, avatarShapeOptions, avatarSizeOptions, avatarsInlineSizeOptions, badgeForButtonOptions, badgeSizeOptions, badgeVariantOptions, bannerVariants, buttonCategoryOptions, buttonSizeOptions, buttonSizeOptionsMap, buttonVariantOptions, colorThemes, columnOptions, defaultDateFormat, drawerVariants, dropdownVariantOptions, focusableTags, formInputSizes, formStateOptions, glThemes, iconSizeOptions, keyboard, labelColorOptions, labelSizeOptions, loadingIconSizes, maxZIndex, modalButtonDefaults, modalSizeOptions, popoverPlacements, resizeDebounceTime, sizeOptions, sizeOptionsWithNoDefault, tabsButtonDefaults, targetOptions, textareaCountOptions, toggleLabelPosition, tokenVariants, tooltipActionEvents, tooltipDelay, tooltipPlacements, triggerVariantOptions, truncateOptions, variantCssColorMap, variantOptions, variantOptionsWithNoDefault, viewModeOptions };
255
+ export { COMMA, alertVariantIconMap, alertVariantOptions, alignOptions, avatarShapeOptions, avatarSizeOptions, avatarsInlineSizeOptions, badgeForButtonOptions, badgeSizeOptions, badgeVariantOptions, bannerVariants, buttonCategoryOptions, buttonSizeOptions, buttonSizeOptionsMap, buttonVariantOptions, colorThemes, columnOptions, defaultDateFormat, drawerVariants, dropdownVariantOptions, focusableTags, formInputSizes, formStateOptions, glThemes, iconSizeOptions, keyboard, labelColorOptions, labelSizeOptions, loadingIconSizes, maxZIndex, modalButtonDefaults, modalSizeOptions, popoverPlacements, resizeDebounceTime, sizeOptions, sizeOptionsWithNoDefault, tabsButtonDefaults, targetOptions, toggleLabelPosition, tokenVariants, tooltipActionEvents, tooltipDelay, tooltipPlacements, triggerVariantOptions, truncateOptions, variantCssColorMap, variantOptions, variantOptionsWithNoDefault, viewModeOptions };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/ui",
3
- "version": "38.12.0",
3
+ "version": "39.2.0",
4
4
  "description": "GitLab UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -88,7 +88,7 @@
88
88
  "@babel/preset-env": "^7.10.2",
89
89
  "@gitlab/eslint-plugin": "12.0.1",
90
90
  "@gitlab/stylelint-config": "4.0.0",
91
- "@gitlab/svgs": "2.8.0",
91
+ "@gitlab/svgs": "2.10.0",
92
92
  "@rollup/plugin-commonjs": "^11.1.0",
93
93
  "@rollup/plugin-node-resolve": "^7.1.3",
94
94
  "@rollup/plugin-replace": "^2.3.2",
@@ -114,7 +114,7 @@
114
114
  "eslint": "7.32.0",
115
115
  "eslint-import-resolver-jest": "3.0.2",
116
116
  "eslint-plugin-cypress": "2.12.1",
117
- "eslint-plugin-storybook": "^0.5.7",
117
+ "eslint-plugin-storybook": "0.5.7",
118
118
  "file-loader": "^4.2.0",
119
119
  "glob": "^7.2.0",
120
120
  "identity-obj-proxy": "^3.0.0",
@@ -8,6 +8,10 @@
8
8
  @include gl-pr-5;
9
9
  }
10
10
 
11
+ &-no-icon {
12
+ @include gl-pl-5;
13
+ }
14
+
11
15
  .gl-link:not(.gl-label-link) {
12
16
  @include gl-text-blue-600;
13
17
  @include gl-text-decoration-underline;
@@ -20,6 +20,7 @@ describe('Alert component', () => {
20
20
  });
21
21
  };
22
22
 
23
+ const findIcon = () => wrapper.find('.gl-alert-icon');
23
24
  const findDismissButton = () => wrapper.findComponent({ ref: 'dismiss' });
24
25
  const findTitle = () => wrapper.find('.gl-alert-title');
25
26
  const findBodyContainer = () => wrapper.find('.gl-alert-body');
@@ -31,6 +32,10 @@ describe('Alert component', () => {
31
32
  createComponent({ slots: { default: DummyComponent } });
32
33
  });
33
34
 
35
+ it('renders a variant icon', () => {
36
+ expect(findIcon().exists()).toBe(true);
37
+ });
38
+
34
39
  it('renders a dismiss button', () => {
35
40
  expect(findDismissButton().exists()).toBe(true);
36
41
  });
@@ -54,6 +59,12 @@ describe('Alert component', () => {
54
59
  });
55
60
  });
56
61
 
62
+ it('does not render a variant icon when showIcon = false', () => {
63
+ createComponent({ propsData: { showIcon: false } });
64
+
65
+ expect(findIcon().exists()).toBe(false);
66
+ });
67
+
57
68
  it('does not render a dismiss button when dismissible = false', () => {
58
69
  createComponent({ propsData: { dismissible: false } });
59
70
 
@@ -6,6 +6,7 @@ const template = `
6
6
  <gl-alert
7
7
  :title="title"
8
8
  :dismissible="dismissible"
9
+ :show-icon="showIcon"
9
10
  :dismiss-label="dismissLabel"
10
11
  :variant="variant"
11
12
  :primary-button-text="primaryButtonText"
@@ -21,6 +22,7 @@ const generateProps = ({
21
22
  title = defaultValue('title'),
22
23
  variant = defaultValue('variant'),
23
24
  dismissible = defaultValue('dismissible'),
25
+ showIcon = defaultValue('showIcon'),
24
26
  dismissLabel = defaultValue('dismissLabel'),
25
27
  primaryButtonText = defaultValue('primaryButtonText'),
26
28
  primaryButtonLink = defaultValue('primaryButtonLink'),
@@ -32,6 +34,7 @@ const generateProps = ({
32
34
  message: 'Lorem ipsum dolor sit amet',
33
35
  variant,
34
36
  dismissible,
37
+ showIcon,
35
38
  dismissLabel,
36
39
  primaryButtonText,
37
40
  primaryButtonLink,
@@ -92,6 +95,17 @@ TextLinks.parameters = {
92
95
  storyshots: { disable: true },
93
96
  };
94
97
 
98
+ export const NoIcon = () => ({
99
+ components: { GlAlert },
100
+ template: `
101
+ <gl-alert :show-icon="false">
102
+ Lorem ipsum dolor sit amet
103
+ </gl-alert>`,
104
+ });
105
+ NoIcon.parameters = {
106
+ storyshots: { disable: true },
107
+ };
108
+
95
109
  export const Variants = () => ({
96
110
  components: { GlAlert },
97
111
  variants: alertVariantOptions,
@@ -28,6 +28,14 @@ export default {
28
28
  required: false,
29
29
  default: true,
30
30
  },
31
+ /**
32
+ * Shows icon based on variant.
33
+ */
34
+ showIcon: {
35
+ type: Boolean,
36
+ required: false,
37
+ default: true,
38
+ },
31
39
  /**
32
40
  * Dismiss button's aria-label.
33
41
  */
@@ -165,10 +173,12 @@ export default {
165
173
  'gl-alert',
166
174
  { 'gl-alert-sticky': sticky },
167
175
  { 'gl-alert-not-dismissible': !dismissible },
176
+ { 'gl-alert-no-icon': !showIcon },
168
177
  variantClass,
169
178
  ]"
170
179
  >
171
180
  <gl-icon
181
+ v-if="showIcon"
172
182
  :name="iconName"
173
183
  :class="{ 'gl-alert-icon': true, 'gl-alert-icon-no-title': !title }"
174
184
  />
@@ -1,5 +1,4 @@
1
1
  import { mount } from '@vue/test-utils';
2
- import { textareaCountOptions } from '../../../../utils/constants';
3
2
  import GlFormTextarea from './form_textarea.vue';
4
3
 
5
4
  const modelEvent = GlFormTextarea.model.event;
@@ -7,13 +6,11 @@ const newValue = 'foo';
7
6
 
8
7
  describe('GlFormTextArea', () => {
9
8
  let wrapper;
10
- let textarea;
11
9
 
12
10
  const createComponent = (propsData = {}) => {
13
11
  wrapper = mount(GlFormTextarea, {
14
12
  propsData,
15
13
  });
16
- textarea = wrapper.find('textarea');
17
14
  };
18
15
 
19
16
  describe('v-model', () => {
@@ -23,7 +20,7 @@ describe('GlFormTextArea', () => {
23
20
  });
24
21
 
25
22
  it(`sets the textarea's value`, () => {
26
- expect(textarea.element.value).toBe('initial');
23
+ expect(wrapper.element.value).toBe('initial');
27
24
  });
28
25
 
29
26
  describe('when the value prop changes', () => {
@@ -33,7 +30,7 @@ describe('GlFormTextArea', () => {
33
30
  });
34
31
 
35
32
  it(`updates the textarea's value`, () => {
36
- expect(textarea.element.value).toBe(newValue);
33
+ expect(wrapper.element.value).toBe(newValue);
37
34
  });
38
35
  });
39
36
  });
@@ -42,7 +39,7 @@ describe('GlFormTextArea', () => {
42
39
  beforeEach(() => {
43
40
  createComponent();
44
41
 
45
- textarea.setValue(newValue);
42
+ wrapper.setValue(newValue);
46
43
  });
47
44
 
48
45
  it('synchronously emits update event', () => {
@@ -62,7 +59,7 @@ describe('GlFormTextArea', () => {
62
59
 
63
60
  createComponent({ debounce });
64
61
 
65
- textarea.setValue(newValue);
62
+ wrapper.setValue(newValue);
66
63
  });
67
64
 
68
65
  it('synchronously emits an update event', () => {
@@ -85,7 +82,7 @@ describe('GlFormTextArea', () => {
85
82
  beforeEach(() => {
86
83
  createComponent({ lazy: true });
87
84
 
88
- textarea.setValue(newValue);
85
+ wrapper.setValue(newValue);
89
86
  });
90
87
 
91
88
  it('synchronously emits an update event', () => {
@@ -95,7 +92,7 @@ describe('GlFormTextArea', () => {
95
92
  it.each(['change', 'blur'])('updates model after %s event', (event) => {
96
93
  expect(wrapper.emitted(modelEvent)).toBe(undefined);
97
94
 
98
- textarea.trigger(event);
95
+ wrapper.trigger(event);
99
96
 
100
97
  expect(wrapper.emitted(modelEvent)).toEqual([[newValue]]);
101
98
  });
@@ -105,7 +102,7 @@ describe('GlFormTextArea', () => {
105
102
  it('should be false by default', () => {
106
103
  createComponent({});
107
104
 
108
- textarea.trigger('keyup.enter', {
105
+ wrapper.trigger('keyup.enter', {
109
106
  metaKey: true,
110
107
  });
111
108
 
@@ -115,115 +112,11 @@ describe('GlFormTextArea', () => {
115
112
  it('should emit submit when cmd+enter is pressed', async () => {
116
113
  createComponent({ submitOnEnter: true });
117
114
 
118
- textarea.trigger('keyup.enter', {
115
+ wrapper.trigger('keyup.enter', {
119
116
  metaKey: true,
120
117
  });
121
118
 
122
119
  expect(wrapper.emitted().submit).toEqual([[]]);
123
120
  });
124
121
  });
125
-
126
- describe('count', () => {
127
- it('should be 0 by default', () => {
128
- createComponent({
129
- characterCountText: '%{count} characters left',
130
- characterCountOverLimitText: '%{count} characters over limit',
131
- });
132
-
133
- expect(wrapper.text()).not.toContain('characters left');
134
- expect(wrapper.text()).not.toContain('characters over limit');
135
- });
136
-
137
- it('should display the remaining characters when a count is provided', () => {
138
- createComponent({
139
- count: 400,
140
- characterCountText: '%{count} characters left',
141
- characterCountOverLimitText: '%{count} characters over limit',
142
- });
143
-
144
- expect(wrapper.text()).toContain('400 characters left');
145
- });
146
-
147
- it('should display the difference between the limit and the length of the value', () => {
148
- const value = 'hello';
149
-
150
- createComponent({
151
- value,
152
- count: 400,
153
- characterCountText: '%{count} characters left',
154
- characterCountOverLimitText: '%{count} characters over limit',
155
- });
156
-
157
- const { length } = value;
158
-
159
- expect(wrapper.text()).toContain(`${400 - length} characters left`);
160
- });
161
-
162
- it('should display the over limit text once over the limit', () => {
163
- const value = 'hello';
164
- const count = 4;
165
-
166
- createComponent({
167
- value,
168
- count,
169
- characterCountText: '%{count} characters left',
170
- characterCountOverLimitText: '%{count} characters over limit',
171
- });
172
-
173
- const diff = Math.abs(count - value.length);
174
-
175
- expect(wrapper.text()).toContain(`${diff} characters over limit`);
176
- });
177
-
178
- describe('max', () => {
179
- it('should display the text as grey when up to the limit', () => {
180
- const value = 'hello';
181
- const count = 5;
182
-
183
- createComponent({
184
- value,
185
- count,
186
- characterCountText: '%{count} characters left',
187
- characterCountOverLimitText: '%{count} characters over limit',
188
- });
189
-
190
- const small = wrapper.find('small');
191
-
192
- expect(small.classes()).toContain('gl-text-gray-500');
193
- });
194
- it('should display the text as danger when over the limit', () => {
195
- const value = 'hello';
196
- const count = 4;
197
-
198
- createComponent({
199
- value,
200
- count,
201
- characterCountText: '%{count} characters left',
202
- characterCountOverLimitText: '%{count} characters over limit',
203
- });
204
-
205
- const small = wrapper.find('small');
206
-
207
- expect(small.classes()).toContain('gl-text-red-500');
208
- });
209
- });
210
- describe('recommended', () => {
211
- it('should display the text as gray when over the limit', () => {
212
- const value = 'hello';
213
- const count = 4;
214
-
215
- createComponent({
216
- value,
217
- count,
218
- countType: textareaCountOptions.recommended,
219
- characterCountText: '%{count} characters left',
220
- characterCountOverLimitText: '%{count} characters over limit',
221
- });
222
-
223
- const small = wrapper.find('small');
224
-
225
- expect(small.classes()).toContain('gl-text-gray-500');
226
- });
227
- });
228
- });
229
122
  });
@@ -1,5 +1,4 @@
1
1
  import { GlFormTextarea } from '../../../../index';
2
- import { textareaCountOptions } from '../../../../utils/constants';
3
2
  import readme from './form_textarea.md';
4
3
 
5
4
  const template = `
@@ -8,10 +7,6 @@ const template = `
8
7
  :placeholder="placeholder"
9
8
  :rows="5"
10
9
  :no-resize="noResize"
11
- :count="count"
12
- :countType="countType"
13
- :character-count-text="characterCountText"
14
- :character-count-over-limit-text="characterCountOverLimitText"
15
10
  />
16
11
  `;
17
12
 
@@ -19,18 +14,10 @@ const generateProps = ({
19
14
  model = 'We take inspiration from other companies, and we always go for the boring solutions. Just like the rest of our work, we continually adjust our values and strive always to make them better. We used to have more values, but it was difficult to remember them all, so we condensed them and gave sub-values and created an acronym. Everyone is welcome to suggest improvements.',
20
15
  placeholder = 'hello',
21
16
  noResize = GlFormTextarea.props.noResize.default,
22
- count = 400,
23
- countType = textareaCountOptions.max,
24
- characterCountText = '%{count} characters left',
25
- characterCountOverLimitText = '%{count} characters over limit',
26
17
  } = {}) => ({
27
18
  model,
28
19
  placeholder,
29
20
  noResize,
30
- count,
31
- countType,
32
- characterCountText,
33
- characterCountOverLimitText,
34
21
  });
35
22
 
36
23
  const Template = (args) => ({
@@ -54,12 +41,4 @@ export default {
54
41
  },
55
42
  },
56
43
  },
57
- argTypes: {
58
- countType: {
59
- control: {
60
- type: 'select',
61
- options: textareaCountOptions,
62
- },
63
- },
64
- },
65
44
  };
@@ -1,7 +1,5 @@
1
1
  <script>
2
2
  import { BFormTextarea } from 'bootstrap-vue';
3
- import GlSprintf from '../../../utilities/sprintf/sprintf.vue';
4
- import { textareaCountOptions } from '../../../../utils/constants';
5
3
 
6
4
  const model = {
7
5
  prop: 'value',
@@ -11,7 +9,6 @@ const model = {
11
9
  export default {
12
10
  components: {
13
11
  BFormTextarea,
14
- GlSprintf,
15
12
  },
16
13
  inheritAttrs: false,
17
14
  model,
@@ -33,27 +30,6 @@ export default {
33
30
  required: false,
34
31
  default: false,
35
32
  },
36
- count: {
37
- type: Number,
38
- required: false,
39
- default: 0,
40
- },
41
- countType: {
42
- required: false,
43
- type: String,
44
- default: textareaCountOptions.max,
45
- validator: (value) => Object.keys(textareaCountOptions).includes(value),
46
- },
47
- characterCountText: {
48
- required: false,
49
- type: String,
50
- default: '',
51
- },
52
- characterCountOverLimitText: {
53
- required: false,
54
- type: String,
55
- default: '',
56
- },
57
33
  },
58
34
  computed: {
59
35
  listeners() {
@@ -80,37 +56,6 @@ export default {
80
56
  keypressEvent() {
81
57
  return this.submitOnEnter ? 'keyup' : null;
82
58
  },
83
- characters() {
84
- return this.value.length;
85
- },
86
- remainingCharacters() {
87
- if (this.count) {
88
- return Math.abs(this.count - this.characters);
89
- }
90
-
91
- return null;
92
- },
93
- characterCountClasses() {
94
- switch (this.countType) {
95
- case textareaCountOptions.max:
96
- return {
97
- 'gl-text-red-500': this.value.length > this.count,
98
- 'gl-text-gray-500': this.value.length <= this.count,
99
- };
100
- case textareaCountOptions.recommended:
101
- return 'gl-text-gray-500';
102
- default:
103
- return {};
104
- }
105
- },
106
- hasCount() {
107
- return this.remainingCharacters != null;
108
- },
109
- characterCountMessage() {
110
- return this.characters > this.count
111
- ? this.characterCountOverLimitText
112
- : this.characterCountText;
113
- },
114
59
  },
115
60
  methods: {
116
61
  handleKeyPress(e) {
@@ -123,22 +68,12 @@ export default {
123
68
  </script>
124
69
 
125
70
  <template>
126
- <div>
127
- <b-form-textarea
128
- ref="textarea"
129
- class="gl-form-input gl-form-textarea"
130
- :no-resize="noResize"
131
- v-bind="$attrs"
132
- :value="value"
133
- v-on="listeners"
134
- @[keypressEvent].native="handleKeyPress"
135
- />
136
- <div v-if="hasCount">
137
- <small :class="characterCountClasses" aria-live="polite">
138
- <gl-sprintf :message="characterCountMessage">
139
- <template #count>{{ remainingCharacters }}</template>
140
- </gl-sprintf>
141
- </small>
142
- </div>
143
- </div>
71
+ <b-form-textarea
72
+ class="gl-form-input gl-form-textarea"
73
+ :no-resize="noResize"
74
+ v-bind="$attrs"
75
+ :value="value"
76
+ v-on="listeners"
77
+ @[keypressEvent].native="handleKeyPress"
78
+ />
144
79
  </template>
@@ -1,26 +1,26 @@
1
1
  table.gl-table {
2
- @include gl-text-gray-500;
3
2
  @include gl-bg-transparent;
4
3
 
5
4
  tr {
6
5
  th,
7
6
  td {
8
- @include gl-border-t-none;
9
7
  @include gl-border-b-solid;
10
8
  @include gl-border-b-1;
9
+ @include gl-border-gray-100;
11
10
  @include gl-p-5;
12
11
  @include gl-bg-transparent;
13
12
  @include gl-line-height-normal;
14
13
  @include gl-font-base;
14
+ @include gl-vertical-align-top;
15
15
  }
16
16
 
17
17
  th {
18
18
  @include gl-font-weight-bold;
19
- @include gl-border-gray-200;
19
+ @include gl-text-gray-900;
20
20
  }
21
21
 
22
22
  td {
23
- @include gl-border-gray-100;
23
+ @include gl-text-gray-700;
24
24
  }
25
25
  }
26
26
 
@@ -72,9 +72,9 @@ export const WithFilter = (args, { argTypes }) => ({
72
72
  template: `<div class="gl-line-height-normal">
73
73
  <gl-form-input v-model="filter" placeholder="Type to search" />
74
74
  <br />
75
- <gl-table
76
- :items="$options.items"
77
- :fields="$options.fields"
75
+ <gl-table
76
+ :items="$options.items"
77
+ :fields="$options.fields"
78
78
  :filter=filter
79
79
  :fixed="fixed"
80
80
  :stacked="stacked"
@@ -298,8 +298,3 @@ export const loadingIconSizes = {
298
298
  'lg (32x32)': 'lg',
299
299
  'xl (64x64)': 'xl',
300
300
  };
301
-
302
- export const textareaCountOptions = {
303
- max: 'max',
304
- recommended: 'recommended',
305
- };