@gitlab/ui 63.1.2 → 63.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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ # [63.2.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v63.1.3...v63.2.0) (2023-05-23)
2
+
3
+
4
+ ### Features
5
+
6
+ * Add TruncateText component ([5539662](https://gitlab.com/gitlab-org/gitlab-ui/commit/553966208df8fc23736080619b68f73a56e41a48))
7
+
8
+ ## [63.1.3](https://gitlab.com/gitlab-org/gitlab-ui/compare/v63.1.2...v63.1.3) (2023-05-22)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **GlFilteredSearch:** Prevent height change from scrollbar ([2f02df7](https://gitlab.com/gitlab-org/gitlab-ui/commit/2f02df7531c89d4eb533b077985469ca4d013490))
14
+
1
15
  ## [63.1.2](https://gitlab.com/gitlab-org/gitlab-ui/compare/v63.1.1...v63.1.2) (2023-05-22)
2
16
 
3
17
 
@@ -0,0 +1,7 @@
1
+ const STATES = {
2
+ INITIAL: 'initial',
3
+ TRUNCATED: 'truncated',
4
+ EXTENDED: 'extended'
5
+ };
6
+
7
+ export { STATES };
@@ -0,0 +1,136 @@
1
+ import { GlResizeObserverDirective } from '../../../directives/resize_observer/resize_observer';
2
+ import GlButton from '../../base/button/button';
3
+ import { STATES } from './constants';
4
+ import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
5
+
6
+ var script = {
7
+ name: 'GlTruncateText',
8
+ components: {
9
+ GlButton
10
+ },
11
+ directives: {
12
+ GlResizeObserver: GlResizeObserverDirective
13
+ },
14
+ props: {
15
+ /**
16
+ * The text for the 'Show more' button
17
+ */
18
+ showMoreText: {
19
+ type: String,
20
+ required: false,
21
+ default: 'Show more'
22
+ },
23
+ /**
24
+ * The text for the 'Show less' button
25
+ */
26
+ showLessText: {
27
+ type: String,
28
+ required: false,
29
+ default: 'Show less'
30
+ },
31
+ /**
32
+ * The number of lines that are initially visible on larger screens
33
+ */
34
+ lines: {
35
+ type: Number,
36
+ required: false,
37
+ default: 3
38
+ },
39
+ /**
40
+ * The number of lines that are initially visible on smaller screens
41
+ */
42
+ mobileLines: {
43
+ type: Number,
44
+ required: false,
45
+ default: 10
46
+ }
47
+ },
48
+ data() {
49
+ return {
50
+ state: STATES.INITIAL
51
+ };
52
+ },
53
+ computed: {
54
+ showTruncationToggle() {
55
+ return this.isTruncated || this.isExtended;
56
+ },
57
+ truncationToggleText() {
58
+ return this.isTruncated ? this.showMoreText : this.showLessText;
59
+ },
60
+ cssVariables() {
61
+ return {
62
+ '--lines': this.lines,
63
+ '--mobile-lines': this.mobileLines
64
+ };
65
+ },
66
+ truncationClasses() {
67
+ return this.isExtended ? null : 'gl-truncate-text gl-overflow-hidden';
68
+ },
69
+ ariaExpanded() {
70
+ return (!this.isTruncated).toString();
71
+ },
72
+ isTruncated() {
73
+ return this.state === STATES.TRUNCATED;
74
+ },
75
+ isExtended() {
76
+ return this.state === STATES.EXTENDED;
77
+ }
78
+ },
79
+ methods: {
80
+ onResize(_ref) {
81
+ let {
82
+ target
83
+ } = _ref;
84
+ if (target.scrollHeight > target.offsetHeight) {
85
+ this.state = STATES.TRUNCATED;
86
+ } else if (this.isTruncated) {
87
+ this.state = STATES.INITIAL;
88
+ }
89
+ },
90
+ toggleTruncation() {
91
+ if (this.isTruncated) {
92
+ this.state = STATES.EXTENDED;
93
+ } else if (this.isExtended) {
94
+ this.state = STATES.TRUNCATED;
95
+ }
96
+ }
97
+ }
98
+ };
99
+
100
+ /* script */
101
+ const __vue_script__ = script;
102
+
103
+ /* template */
104
+ var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('section',[_c('article',{directives:[{name:"gl-resize-observer",rawName:"v-gl-resize-observer",value:(_vm.onResize),expression:"onResize"}],class:_vm.truncationClasses,style:(_vm.cssVariables),attrs:{"aria-expanded":_vm.ariaExpanded}},[_vm._t("default")],2),_vm._v(" "),(_vm.showTruncationToggle)?_c('gl-button',{attrs:{"variant":"link"},on:{"click":_vm.toggleTruncation}},[_vm._v(_vm._s(_vm.truncationToggleText))]):_vm._e()],1)};
105
+ var __vue_staticRenderFns__ = [];
106
+
107
+ /* style */
108
+ const __vue_inject_styles__ = undefined;
109
+ /* scoped */
110
+ const __vue_scope_id__ = undefined;
111
+ /* module identifier */
112
+ const __vue_module_identifier__ = undefined;
113
+ /* functional template */
114
+ const __vue_is_functional_template__ = false;
115
+ /* style inject */
116
+
117
+ /* style inject SSR */
118
+
119
+ /* style inject shadow dom */
120
+
121
+
122
+
123
+ const __vue_component__ = __vue_normalize__(
124
+ { render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
125
+ __vue_inject_styles__,
126
+ __vue_script__,
127
+ __vue_scope_id__,
128
+ __vue_is_functional_template__,
129
+ __vue_module_identifier__,
130
+ false,
131
+ undefined,
132
+ undefined,
133
+ undefined
134
+ );
135
+
136
+ export default __vue_component__;