@gitlab/ui 80.20.0 → 81.0.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,23 @@
1
+ # [81.0.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v80.20.1...v81.0.0) (2024-06-13)
2
+
3
+
4
+ ### Features
5
+
6
+ * Add `GlFormCharacterCount` component ([c3ccb44](https://gitlab.com/gitlab-org/gitlab-ui/commit/c3ccb44479939d380707b979bee6bcbbedf22d9d))
7
+
8
+
9
+ ### BREAKING CHANGES
10
+
11
+ * So you can add character count to standalone inputs
12
+ Also renames character count related props and slots in `GlFormTextarea`
13
+
14
+ ## [80.20.1](https://gitlab.com/gitlab-org/gitlab-ui/compare/v80.20.0...v80.20.1) (2024-06-12)
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * **GlPopover:** properly align close button ([2e86876](https://gitlab.com/gitlab-org/gitlab-ui/commit/2e868768a36339219cdd554b8ef1a869b6475b57))
20
+
1
21
  # [80.20.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v80.19.1...v80.20.0) (2024-06-10)
2
22
 
3
23
 
@@ -0,0 +1,107 @@
1
+ import debounce from 'lodash/debounce';
2
+ import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
3
+
4
+ var script = {
5
+ name: 'GlFormCharacterCount',
6
+ props: {
7
+ /**
8
+ * Input value
9
+ */
10
+ value: {
11
+ type: String,
12
+ required: false,
13
+ default: ''
14
+ },
15
+ /**
16
+ * Character count limit for the input.
17
+ */
18
+ limit: {
19
+ type: Number,
20
+ required: true
21
+ },
22
+ /**
23
+ * id attribute for the character count text. Input should have `:aria-describedby="countTextId"`
24
+ */
25
+ countTextId: {
26
+ type: String,
27
+ required: true
28
+ }
29
+ },
30
+ data() {
31
+ return {
32
+ remainingCount: this.initialRemainingCount(),
33
+ remainingCountSrOnly: this.initialRemainingCount()
34
+ };
35
+ },
36
+ computed: {
37
+ isOverLimit() {
38
+ return this.remainingCount < 0;
39
+ },
40
+ isOverLimitSrOnly() {
41
+ return this.remainingCountSrOnly < 0;
42
+ },
43
+ countTextClass() {
44
+ return this.isOverLimit ? 'gl-text-danger' : 'gl-text-subtle';
45
+ }
46
+ },
47
+ watch: {
48
+ value(newValue) {
49
+ this.remainingCount = this.limit - this.valueLength(newValue);
50
+ this.debouncedUpdateRemainingCountSrOnly(newValue);
51
+ }
52
+ },
53
+ created() {
54
+ // Debounce updating the remaining character count for a second so
55
+ // screen readers announce the remaining text after the text in the textarea.
56
+ this.debouncedUpdateRemainingCountSrOnly = debounce(this.updateRemainingCountSrOnly, 1000);
57
+ },
58
+ methods: {
59
+ valueLength(value) {
60
+ return (value === null || value === void 0 ? void 0 : value.length) || 0;
61
+ },
62
+ updateRemainingCountSrOnly(newValue) {
63
+ this.remainingCountSrOnly = this.limit - this.valueLength(newValue);
64
+ },
65
+ initialRemainingCount() {
66
+ return this.limit - this.valueLength(this.value);
67
+ }
68
+ }
69
+ };
70
+
71
+ /* script */
72
+ const __vue_script__ = script;
73
+
74
+ /* template */
75
+ var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',[_c('small',{class:['form-text', _vm.countTextClass],attrs:{"aria-hidden":"true"}},[(_vm.isOverLimit)?_vm._t("over-limit-text",null,{"count":Math.abs(_vm.remainingCount)}):_vm._t("remaining-count-text",null,{"count":_vm.remainingCount})],2),_vm._v(" "),_c('div',{staticClass:"gl-sr-only",attrs:{"id":_vm.countTextId,"aria-live":"polite","data-testid":"count-text-sr-only"}},[(_vm.isOverLimitSrOnly)?_vm._t("over-limit-text",null,{"count":Math.abs(_vm.remainingCountSrOnly)}):_vm._t("remaining-count-text",null,{"count":_vm.remainingCountSrOnly})],2)])};
76
+ var __vue_staticRenderFns__ = [];
77
+
78
+ /* style */
79
+ const __vue_inject_styles__ = undefined;
80
+ /* scoped */
81
+ const __vue_scope_id__ = undefined;
82
+ /* module identifier */
83
+ const __vue_module_identifier__ = undefined;
84
+ /* functional template */
85
+ const __vue_is_functional_template__ = false;
86
+ /* style inject */
87
+
88
+ /* style inject SSR */
89
+
90
+ /* style inject shadow dom */
91
+
92
+
93
+
94
+ const __vue_component__ = __vue_normalize__(
95
+ { render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
96
+ __vue_inject_styles__,
97
+ __vue_script__,
98
+ __vue_scope_id__,
99
+ __vue_is_functional_template__,
100
+ __vue_module_identifier__,
101
+ false,
102
+ undefined,
103
+ undefined,
104
+ undefined
105
+ );
106
+
107
+ export default __vue_component__;
@@ -1,6 +1,6 @@
1
1
  import { BFormTextarea } from 'bootstrap-vue/esm/index.js';
2
- import debounce from 'lodash/debounce';
3
2
  import uniqueId from 'lodash/uniqueId';
3
+ import GlFormCharacterCount from '../form_character_count/form_character_count';
4
4
  import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
5
5
 
6
6
  const model = {
@@ -10,7 +10,8 @@ const model = {
10
10
  var script = {
11
11
  name: 'GlFormTextarea',
12
12
  components: {
13
- BFormTextarea
13
+ BFormTextarea,
14
+ GlFormCharacterCount
14
15
  },
15
16
  inheritAttrs: false,
16
17
  model,
@@ -35,7 +36,7 @@ var script = {
35
36
  /**
36
37
  * Max character count for the textarea.
37
38
  */
38
- characterCount: {
39
+ characterCountLimit: {
39
40
  type: Number,
40
41
  required: false,
41
42
  default: null
@@ -48,9 +49,7 @@ var script = {
48
49
  },
49
50
  data() {
50
51
  return {
51
- characterCountId: uniqueId('form-textarea-character-count-'),
52
- remainingCharacterCount: this.initialRemainingCharacterCount(),
53
- remainingCharacterCountSrOnly: this.initialRemainingCharacterCount()
52
+ characterCountTextId: uniqueId('form-textarea-character-count-')
54
53
  };
55
54
  },
56
55
  computed: {
@@ -85,14 +84,8 @@ var script = {
85
84
  keypressEvent() {
86
85
  return this.submitOnEnter ? 'keyup' : null;
87
86
  },
88
- isCharacterCountOverLimit() {
89
- return this.remainingCharacterCount < 0;
90
- },
91
- characterCountTextClass() {
92
- return this.isCharacterCountOverLimit ? 'gl-text-danger' : 'gl-text-subtle';
93
- },
94
87
  showCharacterCount() {
95
- return this.characterCount !== null;
88
+ return this.characterCountLimit !== null;
96
89
  },
97
90
  bFormTextareaProps() {
98
91
  return {
@@ -104,34 +97,11 @@ var script = {
104
97
  };
105
98
  }
106
99
  },
107
- watch: {
108
- value(newValue) {
109
- if (!this.showCharacterCount) {
110
- return;
111
- }
112
- this.remainingCharacterCount = this.characterCount - this.valueLength(newValue);
113
- this.debouncedUpdateRemainingCharacterCountSrOnly(newValue);
114
- }
115
- },
116
- created() {
117
- // Debounce updating the remaining character count for a second so
118
- // screen readers announce the remaining text after the text in the textarea.
119
- this.debouncedUpdateRemainingCharacterCountSrOnly = debounce(this.updateRemainingCharacterCountSrOnly, 1000);
120
- },
121
100
  methods: {
122
- valueLength(value) {
123
- return (value === null || value === void 0 ? void 0 : value.length) || 0;
124
- },
125
101
  handleKeyPress(e) {
126
102
  if (e.keyCode === 13 && (e.metaKey || e.ctrlKey)) {
127
103
  this.$emit('submit');
128
104
  }
129
- },
130
- updateRemainingCharacterCountSrOnly(newValue) {
131
- this.remainingCharacterCountSrOnly = this.characterCount - this.valueLength(newValue);
132
- },
133
- initialRemainingCharacterCount() {
134
- return this.characterCount - this.valueLength(this.value);
135
105
  }
136
106
  }
137
107
  };
@@ -140,7 +110,11 @@ var script = {
140
110
  const __vue_script__ = script;
141
111
 
142
112
  /* template */
143
- var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return (_vm.showCharacterCount)?_c('div',[_c('b-form-textarea',_vm._g(_vm._b({attrs:{"aria-describedby":_vm.characterCountId},nativeOn:_vm._d({},[_vm.keypressEvent,function($event){return _vm.handleKeyPress.apply(null, arguments)}])},'b-form-textarea',_vm.bFormTextareaProps,false),_vm.listeners)),_vm._v(" "),_c('small',{class:['form-text', _vm.characterCountTextClass],attrs:{"aria-hidden":"true"}},[(_vm.isCharacterCountOverLimit)?_vm._t("character-count-over-limit-text",null,{"count":Math.abs(_vm.remainingCharacterCount)}):_vm._t("character-count-text",null,{"count":_vm.remainingCharacterCount})],2),_vm._v(" "),_c('div',{staticClass:"gl-sr-only",attrs:{"id":_vm.characterCountId,"aria-live":"polite","data-testid":"character-count-text-sr-only"}},[(_vm.isCharacterCountOverLimit)?_vm._t("character-count-over-limit-text",null,{"count":Math.abs(_vm.remainingCharacterCount)}):_vm._t("character-count-text",null,{"count":_vm.remainingCharacterCountSrOnly})],2)],1):_c('b-form-textarea',_vm._g(_vm._b({nativeOn:_vm._d({},[_vm.keypressEvent,function($event){return _vm.handleKeyPress.apply(null, arguments)}])},'b-form-textarea',_vm.bFormTextareaProps,false),_vm.listeners))};
113
+ var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return (_vm.showCharacterCount)?_c('div',[_c('b-form-textarea',_vm._g(_vm._b({attrs:{"aria-describedby":_vm.characterCountTextId},nativeOn:_vm._d({},[_vm.keypressEvent,function($event){return _vm.handleKeyPress.apply(null, arguments)}])},'b-form-textarea',_vm.bFormTextareaProps,false),_vm.listeners)),_vm._v(" "),_c('gl-form-character-count',{attrs:{"value":_vm.value,"limit":_vm.characterCountLimit,"count-text-id":_vm.characterCountTextId},scopedSlots:_vm._u([{key:"over-limit-text",fn:function(ref){
114
+ var count = ref.count;
115
+ return [_vm._t("character-count-over-limit-text",null,{"count":count})]}},{key:"remaining-count-text",fn:function(ref){
116
+ var count = ref.count;
117
+ return [_vm._t("remaining-character-count-text",null,{"count":count})]}}],null,true)})],1):_c('b-form-textarea',_vm._g(_vm._b({nativeOn:_vm._d({},[_vm.keypressEvent,function($event){return _vm.handleKeyPress.apply(null, arguments)}])},'b-form-textarea',_vm.bFormTextareaProps,false),_vm.listeners))};
144
118
  var __vue_staticRenderFns__ = [];
145
119
 
146
120
  /* style */
@@ -75,7 +75,7 @@ var script = {
75
75
  const __vue_script__ = script;
76
76
 
77
77
  /* template */
78
- var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('b-popover',_vm._g(_vm._b({ref:_vm.$options.popoverRefName,attrs:{"custom-class":_vm.customClass,"triggers":_vm.triggers,"title":_vm.title,"placement":_vm.placement,"boundary-padding":_vm.boundaryPadding},scopedSlots:_vm._u([(_vm.shouldShowTitle)?{key:"title",fn:function(){return [_vm._t("title",function(){return [_vm._v("\n "+_vm._s(_vm.title)+"\n ")]}),_vm._v(" "),(_vm.showCloseButton)?_c('close-button',{staticClass:"gl-float-right gl-mt-n2 gl-mr-n3",attrs:{"data-testid":"close-button"},on:{"click":_vm.close}}):_vm._e()]},proxy:true}:null],null,true)},'b-popover',_vm.$attrs,false),_vm.$listeners),[_vm._v(" "),_vm._t("default")],2)};
78
+ var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('b-popover',_vm._g(_vm._b({ref:_vm.$options.popoverRefName,attrs:{"custom-class":_vm.customClass,"triggers":_vm.triggers,"title":_vm.title,"placement":_vm.placement,"boundary-padding":_vm.boundaryPadding},scopedSlots:_vm._u([(_vm.shouldShowTitle)?{key:"title",fn:function(){return [_vm._t("title",function(){return [_vm._v("\n "+_vm._s(_vm.title)+"\n ")]}),_vm._v(" "),(_vm.showCloseButton)?_c('div',{staticClass:"gl-mt-n2 gl-mr-n3 gl-ml-3 gl-h-0"},[_c('close-button',{attrs:{"data-testid":"close-button"},on:{"click":_vm.close}})],1):_vm._e()]},proxy:true}:null],null,true)},'b-popover',_vm.$attrs,false),_vm.$listeners),[_vm._v(" "),_vm._t("default")],2)};
79
79
  var __vue_staticRenderFns__ = [];
80
80
 
81
81
  /* style */