@gitlab/ui 80.20.1 → 81.1.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.1.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v81.0.0...v81.1.0) (2024-06-17)
2
+
3
+
4
+ ### Features
5
+
6
+ * **GlDaterangePicker:** Add valid prop to GlFormInput, GlDatepicker, GlDaterangePicker ([a872eef](https://gitlab.com/gitlab-org/gitlab-ui/commit/a872eefbe1923ec500c4e5fbb5a2fbdc0d33c9df))
7
+
8
+ # [81.0.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v80.20.1...v81.0.0) (2024-06-13)
9
+
10
+
11
+ ### Features
12
+
13
+ * Add `GlFormCharacterCount` component ([c3ccb44](https://gitlab.com/gitlab-org/gitlab-ui/commit/c3ccb44479939d380707b979bee6bcbbedf22d9d))
14
+
15
+
16
+ ### BREAKING CHANGES
17
+
18
+ * So you can add character count to standalone inputs
19
+ Also renames character count related props and slots in `GlFormTextarea`
20
+
1
21
  ## [80.20.1](https://gitlab.com/gitlab-org/gitlab-ui/compare/v80.20.0...v80.20.1) (2024-06-12)
2
22
 
3
23
 
@@ -181,6 +181,11 @@ var script = {
181
181
  required: false,
182
182
  default: null,
183
183
  validator: value => Object.keys(datepickerWidthOptionsMap).includes(value)
184
+ },
185
+ state: {
186
+ type: Boolean,
187
+ required: false,
188
+ default: null
184
189
  }
185
190
  },
186
191
  data() {
@@ -350,7 +355,7 @@ var script = {
350
355
  const __vue_script__ = script;
351
356
 
352
357
  /* template */
353
- var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{class:_vm.datepickerClasses},[(_vm.showDefaultField)?_c('div',{staticClass:"gl-display-flex gl-align-items-start gl-gap-3"},[_c('div',{staticClass:"gl-relative gl-display-flex gl-flex-grow-1"},[_vm._t("default",function(){return [_c('gl-form-input',{class:_vm.renderClearButton ? 'gl-pr-9!' : 'gl-pr-7!',attrs:{"id":_vm.inputId,"name":_vm.inputName,"data-testid":"gl-datepicker-input","value":_vm.formattedDate,"placeholder":_vm.placeholder,"autocomplete":_vm.inputAutocomplete,"disabled":_vm.disabled,"aria-label":_vm.inputLabel},on:{"keydown":function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"enter",13,$event.key,"Enter")){ return null; }return _vm.onKeydown.apply(null, arguments)}},model:{value:(_vm.textInput),callback:function ($$v) {_vm.textInput=$$v;},expression:"textInput"}})]},{"formattedDate":_vm.formattedDate}),_vm._v(" "),_c('div',{staticClass:"gl-datepicker-actions"},[(_vm.renderClearButton)?_c('gl-button',{staticClass:"gl-pointer-events-auto",attrs:{"data-testid":"clear-button","aria-label":"Clear date","category":"tertiary","size":"small","icon":"clear"},on:{"click":_vm.cleared}}):_vm._e(),_vm._v(" "),(_vm.triggerOnFocus || _vm.disabled)?_c('span',{staticClass:"gl-px-2",class:_vm.disabled ? 'gl-text-gray-400' : 'gl-text-gray-500',attrs:{"data-testid":"datepicker-calendar-icon"}},[_c('gl-icon',{staticClass:"gl-display-block",attrs:{"name":"calendar","size":16}})],1):_c('gl-button',{ref:"calendarTriggerBtn",staticClass:"gl-pointer-events-auto",attrs:{"aria-label":"Open datepicker","category":"tertiary","size":"small","icon":"calendar"}})],1)],2),_vm._v(" "),_vm._t("after")],2):_vm._t("default",null,{"formattedDate":_vm.formattedDate})],2)};
358
+ var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{class:_vm.datepickerClasses},[(_vm.showDefaultField)?_c('div',{staticClass:"gl-display-flex gl-align-items-start gl-gap-3"},[_c('div',{staticClass:"gl-relative gl-display-flex gl-flex-grow-1"},[_vm._t("default",function(){return [_c('gl-form-input',{class:_vm.renderClearButton ? 'gl-pr-9!' : 'gl-pr-7!',attrs:{"id":_vm.inputId,"name":_vm.inputName,"data-testid":"gl-datepicker-input","value":_vm.formattedDate,"placeholder":_vm.placeholder,"autocomplete":_vm.inputAutocomplete,"disabled":_vm.disabled,"aria-label":_vm.inputLabel,"state":_vm.state},on:{"keydown":function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"enter",13,$event.key,"Enter")){ return null; }return _vm.onKeydown.apply(null, arguments)}},model:{value:(_vm.textInput),callback:function ($$v) {_vm.textInput=$$v;},expression:"textInput"}})]},{"formattedDate":_vm.formattedDate}),_vm._v(" "),_c('div',{staticClass:"gl-datepicker-actions"},[(_vm.renderClearButton)?_c('gl-button',{staticClass:"gl-pointer-events-auto",attrs:{"data-testid":"clear-button","aria-label":"Clear date","category":"tertiary","size":"small","icon":"clear"},on:{"click":_vm.cleared}}):_vm._e(),_vm._v(" "),(_vm.triggerOnFocus || _vm.disabled)?_c('span',{staticClass:"gl-px-2",class:_vm.disabled ? 'gl-text-gray-400' : 'gl-text-gray-500',attrs:{"data-testid":"datepicker-calendar-icon"}},[_c('gl-icon',{staticClass:"gl-display-block",attrs:{"name":"calendar","size":16}})],1):_c('gl-button',{ref:"calendarTriggerBtn",staticClass:"gl-pointer-events-auto",attrs:{"aria-label":"Open datepicker","category":"tertiary","size":"small","icon":"calendar"}})],1)],2),_vm._v(" "),_vm._t("after")],2):_vm._t("default",null,{"formattedDate":_vm.formattedDate})],2)};
354
359
  var __vue_staticRenderFns__ = [];
355
360
 
356
361
  /* style */
@@ -76,6 +76,11 @@ var script = {
76
76
  required: false,
77
77
  default: ''
78
78
  },
79
+ startPickerState: {
80
+ type: Boolean,
81
+ required: false,
82
+ default: null
83
+ },
79
84
  endPickerClass: {
80
85
  type: String,
81
86
  required: false,
@@ -91,6 +96,11 @@ var script = {
91
96
  required: false,
92
97
  default: ''
93
98
  },
99
+ endPickerState: {
100
+ type: Boolean,
101
+ required: false,
102
+ default: null
103
+ },
94
104
  labelClass: {
95
105
  type: String,
96
106
  required: false,
@@ -263,7 +273,7 @@ var script = {
263
273
  const __vue_script__ = script;
264
274
 
265
275
  /* template */
266
- var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"gl-daterange-picker gl-gap-5 gl-display-flex"},[_c('div',{class:_vm.startContainerClasses,attrs:{"data-testid":"daterange-picker-start-container"}},[_c('label',{class:_vm.labelClass},[_vm._v(_vm._s(_vm.fromLabel))]),_vm._v(" "),_c('gl-datepicker',{attrs:{"min-date":_vm.defaultMinDate,"max-date":_vm.fromCalendarMaxDate,"start-range":_vm.defaultMinDate,"end-range":_vm.fromCalendarMaxDate,"theme":_vm.theme,"i18n":_vm.i18n,"target":_vm.startPickerTarget,"container":_vm.startPickerContainer,"start-opened":_vm.startOpened,"width":_vm.width},on:{"input":_vm.onStartDateSelected,"open":_vm.onStartPickerOpen,"close":_vm.onStartPickerClose},scopedSlots:_vm._u([{key:"after",fn:function(){return [_vm._t("after-start")]},proxy:true}],null,true),model:{value:(_vm.startDate),callback:function ($$v) {_vm.startDate=$$v;},expression:"startDate"}})],1),_vm._v(" "),_c('div',{class:_vm.endContainerClasses,attrs:{"data-testid":"daterange-picker-end-container"}},[_c('label',{class:_vm.labelClass},[_vm._v(_vm._s(_vm.toLabel))]),_vm._v(" "),_c('gl-datepicker',{key:_vm.numericStartTime,attrs:{"min-date":_vm.toCalendarMinDate,"max-date":_vm.toCalendarMaxDate,"start-range":_vm.toCalendarMinDate,"end-range":_vm.toCalendarMaxDate,"theme":_vm.theme,"i18n":_vm.i18n,"target":_vm.endPickerTarget,"container":_vm.endPickerContainer,"start-opened":_vm.openToCalendar,"default-date":_vm.toCalendarDefaultDate,"width":_vm.width},on:{"input":_vm.onEndDateSelected,"open":_vm.onEndPickerOpen,"close":_vm.onEndPickerClose},scopedSlots:_vm._u([{key:"after",fn:function(){return [_vm._t("after-end")]},proxy:true}],null,true),model:{value:(_vm.endDate),callback:function ($$v) {_vm.endDate=$$v;},expression:"endDate"}})],1),_vm._v(" "),(_vm.showIndicator)?_c('div',{staticClass:"gl-daterange-picker-indicator",class:_vm.dateRangeIndicatorClass,attrs:{"data-testid":"daterange-picker-indicator"}},[_vm._t("default",null,null,{ daysSelected: _vm.numberOfDays }),_vm._v(" "),(_vm.tooltip)?_c('gl-icon',{directives:[{name:"gl-tooltip",rawName:"v-gl-tooltip"}],attrs:{"name":"information-o","title":_vm.tooltip,"size":16}}):_vm._e()],2):_vm._e()])};
276
+ var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"gl-daterange-picker gl-gap-5 gl-display-flex"},[_c('div',{class:_vm.startContainerClasses,attrs:{"data-testid":"daterange-picker-start-container"}},[_c('label',{class:_vm.labelClass},[_vm._v(_vm._s(_vm.fromLabel))]),_vm._v(" "),_c('gl-datepicker',{attrs:{"min-date":_vm.defaultMinDate,"max-date":_vm.fromCalendarMaxDate,"start-range":_vm.defaultMinDate,"end-range":_vm.fromCalendarMaxDate,"theme":_vm.theme,"i18n":_vm.i18n,"target":_vm.startPickerTarget,"container":_vm.startPickerContainer,"start-opened":_vm.startOpened,"state":_vm.startPickerState,"width":_vm.width},on:{"input":_vm.onStartDateSelected,"open":_vm.onStartPickerOpen,"close":_vm.onStartPickerClose},scopedSlots:_vm._u([{key:"after",fn:function(){return [_vm._t("after-start")]},proxy:true}],null,true),model:{value:(_vm.startDate),callback:function ($$v) {_vm.startDate=$$v;},expression:"startDate"}})],1),_vm._v(" "),_c('div',{class:_vm.endContainerClasses,attrs:{"data-testid":"daterange-picker-end-container"}},[_c('label',{class:_vm.labelClass},[_vm._v(_vm._s(_vm.toLabel))]),_vm._v(" "),_c('gl-datepicker',{key:_vm.numericStartTime,attrs:{"min-date":_vm.toCalendarMinDate,"max-date":_vm.toCalendarMaxDate,"start-range":_vm.toCalendarMinDate,"end-range":_vm.toCalendarMaxDate,"theme":_vm.theme,"i18n":_vm.i18n,"target":_vm.endPickerTarget,"container":_vm.endPickerContainer,"start-opened":_vm.openToCalendar,"default-date":_vm.toCalendarDefaultDate,"width":_vm.width,"state":_vm.endPickerState},on:{"input":_vm.onEndDateSelected,"open":_vm.onEndPickerOpen,"close":_vm.onEndPickerClose},scopedSlots:_vm._u([{key:"after",fn:function(){return [_vm._t("after-end")]},proxy:true}],null,true),model:{value:(_vm.endDate),callback:function ($$v) {_vm.endDate=$$v;},expression:"endDate"}})],1),_vm._v(" "),(_vm.showIndicator)?_c('div',{staticClass:"gl-daterange-picker-indicator",class:_vm.dateRangeIndicatorClass,attrs:{"data-testid":"daterange-picker-indicator"}},[_vm._t("default",null,null,{ daysSelected: _vm.numberOfDays }),_vm._v(" "),(_vm.tooltip)?_c('gl-icon',{directives:[{name:"gl-tooltip",rawName:"v-gl-tooltip"}],attrs:{"name":"information-o","title":_vm.tooltip,"size":16}}):_vm._e()],2):_vm._e()])};
267
277
  var __vue_staticRenderFns__ = [];
268
278
 
269
279
  /* style */
@@ -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,8 +1,16 @@
1
1
  import { BFormText } from 'bootstrap-vue/esm/index.js';
2
2
  import __vue_normalize__ from 'vue-runtime-helpers/dist/normalize-component.js';
3
3
 
4
+ var script = {
5
+ ...BFormText.options,
6
+ name: 'GlFormText',
7
+ render(createElement, context) {
8
+ return BFormText.options.render(createElement, context);
9
+ }
10
+ };
11
+
4
12
  /* script */
5
- const __vue_script__ = BFormText;
13
+ const __vue_script__ = script;
6
14
 
7
15
  /* template */
8
16
 
@@ -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 */
package/dist/index.js CHANGED
@@ -29,6 +29,7 @@ export { default as GlToast } from './components/base/toast/toast';
29
29
  export { default as GlDashboardSkeleton } from './components/regions/dashboard_skeleton/dashboard_skeleton';
30
30
  export { default as GlEmptyState } from './components/regions/empty_state/empty_state';
31
31
  export { default as GlForm } from './components/base/form/form';
32
+ export { default as GlFormCharacterCount } from './components/base/form/form_character_count/form_character_count';
32
33
  export { default as GlFormInput } from './components/base/form/form_input/form_input';
33
34
  export { default as GlFormInputGroup } from './components/base/form/form_input_group/form_input_group';
34
35
  export { default as GlFormRadio } from './components/base/form/form_radio/form_radio';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitlab/ui",
3
- "version": "80.20.1",
3
+ "version": "81.1.0",
4
4
  "description": "GitLab UI Components",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -19,6 +19,7 @@
19
19
  "dist",
20
20
  "translations.json",
21
21
  "tailwind.defaults.js",
22
+ "!src/vendor",
22
23
  "!*.stories.js",
23
24
  "!*.snap",
24
25
  "!*.spec.{js,scss}"
@@ -63,7 +64,7 @@
63
64
  "stylelint": "stylelint 'src/**/*.scss'",
64
65
  "prestylelint": "yarn generate-utilities",
65
66
  "stylelint:fix": "yarn stylelint --fix",
66
- "markdownlint": "markdownlint '**/*.md' --ignore node_modules --ignore CHANGELOG.md",
67
+ "markdownlint": "markdownlint '**/*.md' --ignore node_modules --ignore CHANGELOG.md --ignore src/vendor",
67
68
  "markdownlint:fix": "yarn markdownlint --fix",
68
69
  "lint": "run-p prettier eslint stylelint markdownlint",
69
70
  "lint:fix": "run-s eslint:fix prettier:fix stylelint:fix markdownlint:fix",
@@ -132,6 +133,7 @@
132
133
  "@vue/test-utils-vue3": "npm:@vue/test-utils@2.2.0",
133
134
  "@vue/vue2-jest": "29.0.0",
134
135
  "@vue/vue3-jest": "^29.1.1",
136
+ "@yarnpkg/lockfile": "^1.1.0",
135
137
  "autoprefixer": "^9.7.6",
136
138
  "axe-core": "^4.2.3",
137
139
  "babel-jest": "29.0.1",
@@ -146,6 +148,7 @@
146
148
  "eslint-import-resolver-jest": "3.0.2",
147
149
  "eslint-plugin-cypress": "3.3.0",
148
150
  "eslint-plugin-storybook": "0.8.0",
151
+ "gitlab-api-async-iterator": "^1.3.1",
149
152
  "glob": "10.3.3",
150
153
  "identity-obj-proxy": "^3.0.0",
151
154
  "inquirer-select-directory": "^1.2.0",
@@ -181,6 +181,11 @@ export default {
181
181
  default: null,
182
182
  validator: (value) => Object.keys(datepickerWidthOptionsMap).includes(value),
183
183
  },
184
+ state: {
185
+ type: Boolean,
186
+ required: false,
187
+ default: null,
188
+ },
184
189
  },
185
190
  data() {
186
191
  return {
@@ -382,6 +387,7 @@ export default {
382
387
  :autocomplete="inputAutocomplete"
383
388
  :disabled="disabled"
384
389
  :aria-label="inputLabel"
390
+ :state="state"
385
391
  @keydown.enter="onKeydown"
386
392
  />
387
393
  </slot>
@@ -83,6 +83,11 @@ export default {
83
83
  required: false,
84
84
  default: '',
85
85
  },
86
+ startPickerState: {
87
+ type: Boolean,
88
+ required: false,
89
+ default: null,
90
+ },
86
91
  endPickerClass: {
87
92
  type: String,
88
93
  required: false,
@@ -98,6 +103,11 @@ export default {
98
103
  required: false,
99
104
  default: '',
100
105
  },
106
+ endPickerState: {
107
+ type: Boolean,
108
+ required: false,
109
+ default: null,
110
+ },
101
111
  labelClass: {
102
112
  type: String,
103
113
  required: false,
@@ -277,6 +287,7 @@ export default {
277
287
  :target="startPickerTarget"
278
288
  :container="startPickerContainer"
279
289
  :start-opened="startOpened"
290
+ :state="startPickerState"
280
291
  :width="width"
281
292
  @input="onStartDateSelected"
282
293
  @open="onStartPickerOpen"
@@ -303,6 +314,7 @@ export default {
303
314
  :start-opened="openToCalendar"
304
315
  :default-date="toCalendarDefaultDate"
305
316
  :width="width"
317
+ :state="endPickerState"
306
318
  @input="onEndDateSelected"
307
319
  @open="onEndPickerOpen"
308
320
  @close="onEndPickerClose"
@@ -0,0 +1,53 @@
1
+ ## Usage
2
+
3
+ `GlFormCharacterCount` can be used to add a character count to an input.
4
+ If you are using `GlFormTextarea` on its own see [with character count example](https://gitlab-org.gitlab.io/gitlab-ui/?path=/story/base-form-form-textarea--with-character-count).
5
+ If you are wrapping your input, such as in a markdown component, and need the character
6
+ count separate from the input, use `GlFormCharacterCount`.
7
+
8
+ ## Example
9
+
10
+ ```html
11
+ <script>
12
+ import { GlFormCharacterCount, GlFormInput, GlFormGroup } from '@gitlab/ui'
13
+
14
+ export default {
15
+ inputId: 'form-input-with-character-count',
16
+ countTextId: 'character-count-text',
17
+ limit: 100,
18
+ components: { GlFormCharacterCount, GlFormInput, GlFormGroup },
19
+ data() {
20
+ return {
21
+ value: '',
22
+ }
23
+ },
24
+ methods: {
25
+ remainingCountText(count) {
26
+ return n__('%d character remaining', '%d characters remaining', count)
27
+ },
28
+ overLimitText(count) {
29
+ return n__('%d character over limit', '%d characters over limit', count);
30
+ },
31
+ },
32
+ }
33
+ <script>
34
+
35
+ <template>
36
+ <gl-form-group label="Form input with character count" :label-for="$options.inputId">
37
+ <gl-form-input
38
+ v-model="value"
39
+ :id="$options.inputId"
40
+ :value="value"
41
+ :aria-describedby="$options.countTextId"
42
+ />
43
+ <gl-form-character-count
44
+ :value="value"
45
+ :limit="$options.limit"
46
+ :count-text-id="$options.countTextId"
47
+ >
48
+ <template #remaining-count-text="{ count }">{{ remainingCountText(count) }}</template>
49
+ <template #over-limit-text="{ count }">{{ overLimitText(count) }}</template>
50
+ </gl-form-character-count>
51
+ </gl-form-group>
52
+ <template>
53
+ ```
@@ -0,0 +1,97 @@
1
+ <script>
2
+ import debounce from 'lodash/debounce';
3
+
4
+ export default {
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?.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
+ </script>
71
+
72
+ <template>
73
+ <div>
74
+ <small :class="['form-text', countTextClass]" aria-hidden="true">
75
+ <!--
76
+ @slot Internationalized over limit text. Example: `<template #over-limit-text="{ count }">{{ n__('%d character over limit', '%d characters over limit', count) }}</template>`
77
+ @binding {number} count
78
+ -->
79
+ <slot v-if="isOverLimit" name="over-limit-text" :count="Math.abs(remainingCount)"></slot>
80
+ <!--
81
+ @slot Internationalized character count text. Example: `<template #remaining-count-text="{ count }">{{ n__('%d character remaining', '%d characters remaining', count) }}</template>`
82
+ @binding {number} count
83
+ -->
84
+
85
+ <slot v-else name="remaining-count-text" :count="remainingCount"></slot>
86
+ </small>
87
+ <div :id="countTextId" class="gl-sr-only" aria-live="polite" data-testid="count-text-sr-only">
88
+ <slot
89
+ v-if="isOverLimitSrOnly"
90
+ name="over-limit-text"
91
+ :count="Math.abs(remainingCountSrOnly)"
92
+ ></slot>
93
+
94
+ <slot v-else name="remaining-count-text" :count="remainingCountSrOnly"></slot>
95
+ </div>
96
+ </div>
97
+ </template>
@@ -1,5 +1,11 @@
1
1
  <script>
2
2
  import { BFormText } from 'bootstrap-vue';
3
3
 
4
- export default BFormText;
4
+ export default {
5
+ ...BFormText.options,
6
+ name: 'GlFormText',
7
+ render(createElement, context) {
8
+ return BFormText.options.render(createElement, context);
9
+ },
10
+ };
5
11
  </script>
@@ -1,7 +1,7 @@
1
1
  <script>
2
2
  import { BFormTextarea } from 'bootstrap-vue';
3
- import debounce from 'lodash/debounce';
4
3
  import uniqueId from 'lodash/uniqueId';
4
+ import GlFormCharacterCount from '../form_character_count/form_character_count.vue';
5
5
 
6
6
  const model = {
7
7
  prop: 'value',
@@ -12,6 +12,7 @@ export default {
12
12
  name: 'GlFormTextarea',
13
13
  components: {
14
14
  BFormTextarea,
15
+ GlFormCharacterCount,
15
16
  },
16
17
  inheritAttrs: false,
17
18
  model,
@@ -36,7 +37,7 @@ export default {
36
37
  /**
37
38
  * Max character count for the textarea.
38
39
  */
39
- characterCount: {
40
+ characterCountLimit: {
40
41
  type: Number,
41
42
  required: false,
42
43
  default: null,
@@ -49,9 +50,7 @@ export default {
49
50
  },
50
51
  data() {
51
52
  return {
52
- characterCountId: uniqueId('form-textarea-character-count-'),
53
- remainingCharacterCount: this.initialRemainingCharacterCount(),
54
- remainingCharacterCountSrOnly: this.initialRemainingCharacterCount(),
53
+ characterCountTextId: uniqueId('form-textarea-character-count-'),
55
54
  };
56
55
  },
57
56
  computed: {
@@ -79,14 +78,8 @@ export default {
79
78
  keypressEvent() {
80
79
  return this.submitOnEnter ? 'keyup' : null;
81
80
  },
82
- isCharacterCountOverLimit() {
83
- return this.remainingCharacterCount < 0;
84
- },
85
- characterCountTextClass() {
86
- return this.isCharacterCountOverLimit ? 'gl-text-danger' : 'gl-text-subtle';
87
- },
88
81
  showCharacterCount() {
89
- return this.characterCount !== null;
82
+ return this.characterCountLimit !== null;
90
83
  },
91
84
  bFormTextareaProps() {
92
85
  return {
@@ -98,39 +91,12 @@ export default {
98
91
  };
99
92
  },
100
93
  },
101
- watch: {
102
- value(newValue) {
103
- if (!this.showCharacterCount) {
104
- return;
105
- }
106
-
107
- this.remainingCharacterCount = this.characterCount - this.valueLength(newValue);
108
- this.debouncedUpdateRemainingCharacterCountSrOnly(newValue);
109
- },
110
- },
111
- created() {
112
- // Debounce updating the remaining character count for a second so
113
- // screen readers announce the remaining text after the text in the textarea.
114
- this.debouncedUpdateRemainingCharacterCountSrOnly = debounce(
115
- this.updateRemainingCharacterCountSrOnly,
116
- 1000
117
- );
118
- },
119
94
  methods: {
120
- valueLength(value) {
121
- return value?.length || 0;
122
- },
123
95
  handleKeyPress(e) {
124
96
  if (e.keyCode === 13 && (e.metaKey || e.ctrlKey)) {
125
97
  this.$emit('submit');
126
98
  }
127
99
  },
128
- updateRemainingCharacterCountSrOnly(newValue) {
129
- this.remainingCharacterCountSrOnly = this.characterCount - this.valueLength(newValue);
130
- },
131
- initialRemainingCharacterCount() {
132
- return this.characterCount - this.valueLength(this.value);
133
- },
134
100
  },
135
101
  };
136
102
  </script>
@@ -138,42 +104,33 @@ export default {
138
104
  <template>
139
105
  <div v-if="showCharacterCount">
140
106
  <b-form-textarea
141
- :aria-describedby="characterCountId"
107
+ :aria-describedby="characterCountTextId"
142
108
  v-bind="bFormTextareaProps"
143
109
  v-on="listeners"
144
110
  @[keypressEvent].native="handleKeyPress"
145
111
  />
146
- <small :class="['form-text', characterCountTextClass]" aria-hidden="true">
147
- <!--
148
- @slot Internationalized over character count text. Example: `<template #character-count-over-limit-text="{ count }">{{ n__('%d character over limit', '%d characters over limit', count) }}</template>`
149
- @binding {number} count
150
- -->
151
- <slot
152
- v-if="isCharacterCountOverLimit"
153
- name="character-count-over-limit-text"
154
- :count="Math.abs(remainingCharacterCount)"
155
- ></slot>
156
- <!--
157
- @slot Internationalized character count text. Example: `<template #character-count-text="{ count }">{{ n__('%d character remaining', '%d characters remaining', count) }}</template>`
158
- @binding {number} count
159
- -->
160
-
161
- <slot v-else name="character-count-text" :count="remainingCharacterCount"></slot>
162
- </small>
163
- <div
164
- :id="characterCountId"
165
- class="gl-sr-only"
166
- aria-live="polite"
167
- data-testid="character-count-text-sr-only"
112
+ <gl-form-character-count
113
+ :value="value"
114
+ :limit="characterCountLimit"
115
+ :count-text-id="characterCountTextId"
168
116
  >
169
- <slot
170
- v-if="isCharacterCountOverLimit"
171
- name="character-count-over-limit-text"
172
- :count="Math.abs(remainingCharacterCount)"
173
- ></slot>
117
+ <template #over-limit-text="{ count }">
118
+ <!--
119
+ @slot Internationalized over character count text. Example: `<template #character-count-over-limit-text="{ count }">{{ n__('%d character over limit', '%d characters over limit', count) }}</template>`
120
+ @binding {number} count
121
+ -->
122
+ <slot name="character-count-over-limit-text" :count="count"></slot>
123
+ </template>
124
+
125
+ <template #remaining-count-text="{ count }">
126
+ <!--
127
+ @slot Internationalized character count text. Example: `<template #remaining-character-count-text="{ count }">{{ n__('%d character remaining', '%d characters remaining', count) }}</template>`
128
+ @binding {number} count
129
+ -->
174
130
 
175
- <slot v-else name="character-count-text" :count="remainingCharacterCountSrOnly"></slot>
176
- </div>
131
+ <slot name="remaining-character-count-text" :count="count"></slot
132
+ ></template>
133
+ </gl-form-character-count>
177
134
  </div>
178
135
  <b-form-textarea
179
136
  v-else
package/src/index.js CHANGED
@@ -36,6 +36,7 @@ export { default as GlToast } from './components/base/toast/toast';
36
36
  export { default as GlDashboardSkeleton } from './components/regions/dashboard_skeleton/dashboard_skeleton.vue';
37
37
  export { default as GlEmptyState } from './components/regions/empty_state/empty_state.vue';
38
38
  export { default as GlForm } from './components/base/form/form.vue';
39
+ export { default as GlFormCharacterCount } from './components/base/form/form_character_count/form_character_count.vue';
39
40
  export { default as GlFormInput } from './components/base/form/form_input/form_input.vue';
40
41
  export { default as GlFormInputGroup } from './components/base/form/form_input_group/form_input_group.vue';
41
42
  export { default as GlFormRadio } from './components/base/form/form_radio/form_radio.vue';