@gitlab/ui 32.29.2 → 32.33.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 (29) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/components/base/icon/icon.js +2 -19
  3. package/dist/components/base/toggle/toggle.js +8 -8
  4. package/dist/components/utilities/truncate/truncate.documentation.js +3 -0
  5. package/dist/components/utilities/truncate/truncate.js +34 -2
  6. package/dist/directives/resize_observer/resize_observer.documentation.js +1 -1
  7. package/dist/directives/resize_observer/resize_observer.js +43 -23
  8. package/dist/index.css +1 -1
  9. package/dist/index.css.map +1 -1
  10. package/dist/utility_classes.css +1 -1
  11. package/dist/utility_classes.css.map +1 -1
  12. package/package.json +2 -2
  13. package/scss_to_js/scss_variables.js +0 -1
  14. package/scss_to_js/scss_variables.json +0 -5
  15. package/src/components/base/icon/icon.scss +1 -1
  16. package/src/components/base/icon/icon.spec.js +4 -24
  17. package/src/components/base/icon/icon.vue +1 -16
  18. package/src/components/base/toggle/toggle.spec.js +1 -3
  19. package/src/components/base/toggle/toggle.vue +7 -8
  20. package/src/components/utilities/truncate/truncate.documentation.js +3 -0
  21. package/src/components/utilities/truncate/truncate.spec.js +8 -0
  22. package/src/components/utilities/truncate/truncate.stories.js +6 -2
  23. package/src/components/utilities/truncate/truncate.vue +57 -7
  24. package/src/directives/resize_observer/resize_observer.js +34 -19
  25. package/src/directives/resize_observer/resize_observer.md +20 -0
  26. package/src/directives/resize_observer/resize_observer.spec.js +33 -1
  27. package/src/scss/utilities.scss +32 -0
  28. package/src/scss/utility-mixins/border.scss +8 -0
  29. package/src/scss/variables.scss +0 -5
package/CHANGELOG.md CHANGED
@@ -1,3 +1,31 @@
1
+ # [32.33.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v32.32.0...v32.33.0) (2021-11-04)
2
+
3
+
4
+ ### Features
5
+
6
+ * **GlTruncate:** show full text in a tooltip ([168c532](https://gitlab.com/gitlab-org/gitlab-ui/commit/168c5325c1fab5174cfa5ad092d829ad11c85363))
7
+
8
+ # [32.32.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v32.31.0...v32.32.0) (2021-11-03)
9
+
10
+
11
+ ### Features
12
+
13
+ * **GlIcon:** remove support for deprecated icons sizes ([5ea2461](https://gitlab.com/gitlab-org/gitlab-ui/commit/5ea2461cfc1d3e2fd5f5c7f51f5e351e6b79ce5d))
14
+
15
+ # [32.31.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v32.30.0...v32.31.0) (2021-11-02)
16
+
17
+
18
+ ### Features
19
+
20
+ * **GlToggle:** Use uniqueId for toggle labels ([2ba11fb](https://gitlab.com/gitlab-org/gitlab-ui/commit/2ba11fbd5023233e4581507f24660a9ffa874f86))
21
+
22
+ # [32.30.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v32.29.2...v32.30.0) (2021-11-01)
23
+
24
+
25
+ ### Features
26
+
27
+ * **css:** Add `dashed` & `dotted` border styles ([a44161c](https://gitlab.com/gitlab-org/gitlab-ui/commit/a44161c7fddf6388e6fba635da8b47e1079be0b6))
28
+
1
29
  ## [32.29.2](https://gitlab.com/gitlab-org/gitlab-ui/compare/v32.29.1...v32.29.2) (2021-11-01)
2
30
 
3
31
 
@@ -63,17 +63,8 @@ var script = {
63
63
  size: {
64
64
  type: Number,
65
65
  required: false,
66
- default: 16
67
- },
68
-
69
- /**
70
- * Is used to deprecate 10&18 icon sizes iteratively.
71
- * More info here https://gitlab.com/gitlab-org/gitlab-ui/-/issues/1232
72
- */
73
- useDeprecatedSizes: {
74
- type: Boolean,
75
- required: false,
76
- default: false
66
+ default: 16,
67
+ validator: value => iconSizeOptions.includes(value)
77
68
  }
78
69
  },
79
70
  computed: {
@@ -85,15 +76,7 @@ var script = {
85
76
  return this.size ? `s${this.size}` : '';
86
77
  }
87
78
 
88
- },
89
-
90
- created() {
91
- if (!iconSizeOptions.includes(this.size) && !this.useDeprecatedSizes) {
92
- // eslint-disable-next-line no-console
93
- console.warn(`[gitlab-ui] Unexpected value '${this.size}' was provided for the icon size`);
94
- }
95
79
  }
96
-
97
80
  };
98
81
 
99
82
  /* script */
@@ -1,3 +1,4 @@
1
+ import _uniqueId from 'lodash/uniqueId';
1
2
  import { toggleLabelPosition } from '../../../utils/constants';
2
3
  import GlIcon from '../icon/icon';
3
4
  import GlLoadingIcon from '../loading_icon/loading_icon';
@@ -65,14 +66,6 @@ var script = {
65
66
  default: undefined
66
67
  },
67
68
 
68
- /**
69
- * The id for the label. This id is used by the aria-labelledby attribute on the toggle button.
70
- */
71
- labelId: {
72
- type: String,
73
- required: true
74
- },
75
-
76
69
  /**
77
70
  * The label's position relative to the toggle. If 'hidden', the toggle will add the .gl-sr-only class so the label is still accessible to screen readers.
78
71
  */
@@ -87,6 +80,13 @@ var script = {
87
80
 
88
81
  }
89
82
  },
83
+
84
+ data() {
85
+ return {
86
+ labelId: _uniqueId('toggle-label-')
87
+ };
88
+ },
89
+
90
90
  computed: {
91
91
  icon() {
92
92
  return this.value ? 'mobile-issue-close' : 'close';
@@ -12,6 +12,9 @@ var truncate_documentation = {
12
12
  position: {
13
13
  additionalInfo: 'Ellipsis position',
14
14
  enum: 'truncateOptions'
15
+ },
16
+ withTooltip: {
17
+ additionalInfo: 'Display the full text in a tooltip only if it is being truncated'
15
18
  }
16
19
  }
17
20
  };
@@ -1,7 +1,14 @@
1
+ import { GlTooltipDirective } from '../../../directives/tooltip';
2
+ import { GlResizeObserverDirective } from '../../../directives/resize_observer/resize_observer';
1
3
  import { POSITION } from './constants';
2
4
  import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
3
5
 
4
6
  var script = {
7
+ POSITION,
8
+ directives: {
9
+ GlTooltip: GlTooltipDirective,
10
+ GlResizeObserver: GlResizeObserverDirective
11
+ },
5
12
  props: {
6
13
  text: {
7
14
  type: String,
@@ -12,12 +19,17 @@ var script = {
12
19
  required: false,
13
20
  default: POSITION.END,
14
21
  validator: value => Object.values(POSITION).includes(value)
22
+ },
23
+ withTooltip: {
24
+ type: Boolean,
25
+ required: false,
26
+ default: false
15
27
  }
16
28
  },
17
29
 
18
30
  data() {
19
31
  return {
20
- POSITION
32
+ isTruncated: false
21
33
  };
22
34
  },
23
35
 
@@ -32,6 +44,26 @@ var script = {
32
44
 
33
45
  last() {
34
46
  return this.text.slice(this.middleIndex);
47
+ },
48
+
49
+ isTooltipDisabled() {
50
+ return !this.withTooltip || !this.isTruncated;
51
+ }
52
+
53
+ },
54
+ watch: {
55
+ withTooltip(withTooltip) {
56
+ if (withTooltip) {
57
+ this.checkTruncationState();
58
+ }
59
+ }
60
+
61
+ },
62
+ methods: {
63
+ checkTruncationState() {
64
+ if (this.withTooltip) {
65
+ this.isTruncated = this.$refs.text.scrollWidth > this.$refs.text.offsetWidth;
66
+ }
35
67
  }
36
68
 
37
69
  }
@@ -41,7 +73,7 @@ var script = {
41
73
  const __vue_script__ = script;
42
74
 
43
75
  /* template */
44
- var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return (_vm.position === _vm.POSITION.START)?_c('span',{staticClass:"gl-truncate",attrs:{"title":_vm.text}},[_c('span',{staticClass:"gl-truncate-start gl-text-overflow-ellipsis!"},[_vm._v("‎"+_vm._s(_vm.text)+"‎")])]):(_vm.position === _vm.POSITION.MIDDLE)?_c('span',{staticClass:"gl-truncate",attrs:{"title":_vm.text}},[_c('span',{staticClass:"gl-truncate-end"},[_vm._v(_vm._s(_vm.first))]),_c('span',{staticClass:"gl-truncate-start"},[_vm._v("‎"+_vm._s(_vm.last)+"‎")])]):_c('span',{staticClass:"gl-truncate",attrs:{"title":_vm.text}},[_c('span',{staticClass:"gl-truncate-end"},[_vm._v(_vm._s(_vm.text))])])};
76
+ var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return (_vm.position === _vm.$options.POSITION.START)?_c('span',{directives:[{name:"gl-tooltip",rawName:"v-gl-tooltip",value:({ disabled: _vm.isTooltipDisabled }),expression:"{ disabled: isTooltipDisabled }"},{name:"gl-resize-observer",rawName:"v-gl-resize-observer:[withTooltip]",value:(_vm.checkTruncationState),expression:"checkTruncationState",arg:_vm.withTooltip}],staticClass:"gl-truncate",attrs:{"title":_vm.text}},[_c('span',{ref:"text",staticClass:"gl-truncate-start gl-text-overflow-ellipsis!"},[_vm._v("‎"+_vm._s(_vm.text)+"‎")])]):(_vm.position === _vm.$options.POSITION.MIDDLE)?_c('span',{directives:[{name:"gl-tooltip",rawName:"v-gl-tooltip",value:({ disabled: _vm.isTooltipDisabled }),expression:"{ disabled: isTooltipDisabled }"},{name:"gl-resize-observer",rawName:"v-gl-resize-observer:[withTooltip]",value:(_vm.checkTruncationState),expression:"checkTruncationState",arg:_vm.withTooltip}],staticClass:"gl-truncate",attrs:{"title":_vm.text}},[_c('span',{ref:"text",staticClass:"gl-truncate-end"},[_vm._v(_vm._s(_vm.first))]),_c('span',{staticClass:"gl-truncate-start"},[_vm._v("‎"+_vm._s(_vm.last)+"‎")])]):_c('span',{directives:[{name:"gl-tooltip",rawName:"v-gl-tooltip",value:({ disabled: _vm.isTooltipDisabled }),expression:"{ disabled: isTooltipDisabled }"},{name:"gl-resize-observer",rawName:"v-gl-resize-observer:[withTooltip]",value:(_vm.checkTruncationState),expression:"checkTruncationState",arg:_vm.withTooltip}],staticClass:"gl-truncate",attrs:{"data-testid":"truncate-end-container","title":_vm.text}},[_c('span',{ref:"text",staticClass:"gl-truncate-end"},[_vm._v(_vm._s(_vm.text))])])};
45
77
  var __vue_staticRenderFns__ = [];
46
78
 
47
79
  /* style */
@@ -1,6 +1,6 @@
1
1
  import examples from './examples';
2
2
 
3
- var description = "# Resize Observer\n\n<!-- STORY -->\n\n## Usage\n\nThis directive can be used to get notified whenever a given element's size (width or height) changes\nand to retrieve the updated dimensions.\n\nUnder the hood, it leverages the [Resize Observer API](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver).\nIf you use GitLab UI in an older browser which doesn't support the Resize Observer API,\nyou can use a [polyfill](https://github.com/que-etc/resize-observer-polyfill).\n\nThe directive accepts a callback as a value and passes on the received\n[contentRect](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserverEntry/contentRect)\nand the target element whenever a resize event gets triggered.\n\n```html\n<script>\nexport default {\n data() {\n return {\n width: 0,\n height: 0,\n };\n },\n methods: {\n handleResize({ contentRect: { width, height } }) {\n this.width = width;\n this.height = height;\n },\n },\n};\n</script>\n<template>\n <div v-gl-resize-observer-directive=\"handleResize\">\n <p>{{ width }} x {{ height }}</p>\n </div>\n</template>\n```\n";
3
+ var description = "# Resize Observer\n\n<!-- STORY -->\n\n## Usage\n\nThis directive can be used to get notified whenever a given element's size (width or height) changes\nand to retrieve the updated dimensions.\n\nUnder the hood, it leverages the [Resize Observer API](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver).\nIf you use GitLab UI in an older browser which doesn't support the Resize Observer API,\nyou can use a [polyfill](https://github.com/que-etc/resize-observer-polyfill).\n\nThe directive accepts a callback as a value and passes on the received\n[contentRect](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserverEntry/contentRect)\nand the target element whenever a resize event gets triggered.\n\n```html\n<script>\nexport default {\n data() {\n return {\n width: 0,\n height: 0,\n };\n },\n methods: {\n handleResize({ contentRect: { width, height } }) {\n this.width = width;\n this.height = height;\n },\n },\n};\n</script>\n<template>\n <div v-gl-resize-observer-directive=\"handleResize\">\n <p>{{ width }} x {{ height }}</p>\n </div>\n</template>\n```\n\nThe observer can be toggled on or off by passing a boolean argument to the directive:\n\n```html\n<script>\nexport default {\n data() {\n return {\n shouldObserve: true,\n };\n },\n methods: {\n handleResize() {},\n },\n};\n</script>\n<template>\n <div v-gl-resize-observer-directive[shouldObserve]=\"handleResize\"></div>\n</template>\n```\n";
4
4
 
5
5
  var resize_observer_documentation = {
6
6
  followsDesignSystem: false,
@@ -1,37 +1,57 @@
1
1
  import isFunction from 'lodash/isFunction';
2
2
 
3
3
  let observer = null;
4
+
5
+ const attachObserver = (el, resizeHandler) => {
6
+ if (!isFunction(resizeHandler)) {
7
+ throw TypeError('directive value must be a function');
8
+ }
9
+
10
+ if (!observer) {
11
+ // the observer instance is shared for performance reasons
12
+ // more information: https://github.com/WICG/ResizeObserver/issues/59
13
+ observer = new ResizeObserver(entries => {
14
+ entries.forEach(event => {
15
+ event.target.glResizeHandler(event);
16
+ });
17
+ });
18
+ }
19
+
20
+ el.glResizeHandler = resizeHandler;
21
+ observer.observe(el);
22
+ };
23
+
24
+ const detachObserver = el => {
25
+ if (el.glResizeHandler) {
26
+ var _observer;
27
+
28
+ delete el.glResizeHandler;
29
+ (_observer = observer) === null || _observer === void 0 ? void 0 : _observer.unobserve(el);
30
+ }
31
+ };
32
+
4
33
  const GlResizeObserverDirective = {
5
34
  bind(el, {
6
- value: resizeHandler
35
+ value: resizeHandler,
36
+ arg: enabled = true
7
37
  }) {
8
- if (!isFunction(resizeHandler)) {
9
- throw TypeError('directive value must be a function');
10
- }
11
-
12
- if (!observer) {
13
- // the observer instance is shared for performance reasons
14
- // more information: https://github.com/WICG/ResizeObserver/issues/59
15
- observer = new ResizeObserver(entries => {
16
- entries.forEach(event => {
17
- event.target.glResizeHandler(event);
18
- });
19
- });
38
+ if (enabled) {
39
+ attachObserver(el, resizeHandler);
20
40
  }
21
-
22
- el.glResizeHandler = resizeHandler;
23
- observer.observe(el);
24
41
  },
25
42
 
26
- unbind(el) {
27
- if (el.glResizeHandler) {
28
- var _observer;
29
-
30
- delete el.glResizeHandler;
31
- (_observer = observer) === null || _observer === void 0 ? void 0 : _observer.unobserve(el);
43
+ update(el, {
44
+ value: resizeHandler,
45
+ arg: enabled = true
46
+ }) {
47
+ if (enabled) {
48
+ attachObserver(el, resizeHandler);
49
+ } else {
50
+ detachObserver(el);
32
51
  }
33
- }
52
+ },
34
53
 
54
+ unbind: detachObserver
35
55
  };
36
56
 
37
57
  export { GlResizeObserverDirective };