@carbon/vue 2.20.1-canary.0 → 2.20.1

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.
@@ -261,15 +261,15 @@ var component = Object(componentNormalizer["a" /* default */])(
261
261
  "use strict";
262
262
  __webpack_require__.r(__webpack_exports__);
263
263
 
264
- // CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"0f4df6f3-vue-loader-template"}!./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/cv-date-picker/cv-date-picker.vue?vue&type=template&id=4e069846&
265
- var cv_date_pickervue_type_template_id_4e069846_render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('cv-wrapper',{staticClass:"cv-date-picker bx--form-item",attrs:{"tag-type":_vm.formItem ? 'div' : ''}},[_c('div',{ref:"date-picker",staticClass:"bx--date-picker",class:[_vm.kindClasses, { 'bx--date-picker--light': _vm.theme === 'light', 'cv-date-pciker': !_vm.formItem }],attrs:{"data-date-picker":['single', 'range'].includes(_vm.kind),"data-date-picker-type":_vm.kind}},[_c('div',{class:{
264
+ // CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"0f4df6f3-vue-loader-template"}!./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/cv-date-picker/cv-date-picker.vue?vue&type=template&id=71bd2208&
265
+ var cv_date_pickervue_type_template_id_71bd2208_render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('cv-wrapper',{staticClass:"cv-date-picker bx--form-item",attrs:{"tag-type":_vm.formItem ? 'div' : ''}},[_c('div',{ref:"date-picker",staticClass:"bx--date-picker",class:[_vm.kindClasses, { 'bx--date-picker--light': _vm.theme === 'light', 'cv-date-pciker': !_vm.formItem }],attrs:{"data-date-picker":['single', 'range'].includes(_vm.kind),"data-date-picker-type":_vm.kind}},[_c('div',{class:{
266
266
  'bx--date-picker-container': ['single', 'range'].includes(_vm.kind),
267
267
  'bx--date-picker--nolabel': _vm.getDateLabel !== undefined,
268
268
  },on:{"change":_vm.onChange}},[(_vm.getDateLabel.length > 0)?_c('label',{staticClass:"bx--label",attrs:{"for":(_vm.uid + "-input-1")}},[_vm._v(_vm._s(_vm.getDateLabel))]):_vm._e(),_c('div',{staticClass:"bx--date-picker-input__wrapper"},[_c('input',{ref:"date",staticClass:"bx--date-picker__input",attrs:{"data-invalid":_vm.isInvalid,"type":"text","id":(_vm.uid + "-input-1"),"pattern":_vm.pattern,"placeholder":_vm.placeholder,"data-date-picker-input":"","data-date-picker-input-from":_vm.kind === 'range'}}),(['single', 'range'].includes(_vm.kind))?_c('Calendar16',{staticClass:"bx--date-picker__icon",attrs:{"data-date-picker-icon":""},on:{"click":function($event){return _vm.cal.open()}}}):_vm._e()],1),(_vm.isInvalid)?_c('div',{staticClass:"bx--form-requirement"},[_vm._t("invalid-message",[_vm._v(_vm._s(_vm.invalidMessage || _vm.invalidDateMessage))])],2):_vm._e()]),(_vm.kind === 'range')?_c('div',{class:{ 'bx--date-picker-container': _vm.kind === 'range' }},[(_vm.getDateEndLabel.length > 0)?_c('label',{staticClass:"bx--label",attrs:{"for":(_vm.uid + "-input-2")}},[_vm._v(_vm._s(_vm.getDateEndLabel))]):_vm._e(),_c('div',{staticClass:"bx--date-picker-input__wrapper"},[_c('input',{ref:"todate",staticClass:"bx--date-picker__input",attrs:{"type":"text","id":(_vm.uid + "-input-2"),"pattern":_vm.pattern,"placeholder":_vm.placeholder,"data-date-picker-input":"","data-date-picker-input-to":_vm.kind === 'range'}}),_c('Calendar16',{staticClass:"bx--date-picker__icon",attrs:{"data-date-picker-icon":""},on:{"click":function($event){return _vm.openTodateCal()}}})],1)]):_vm._e()])])}
269
269
  var staticRenderFns = []
270
270
 
271
271
 
272
- // CONCATENATED MODULE: ./src/components/cv-date-picker/cv-date-picker.vue?vue&type=template&id=4e069846&
272
+ // CONCATENATED MODULE: ./src/components/cv-date-picker/cv-date-picker.vue?vue&type=template&id=71bd2208&
273
273
 
274
274
  // EXTERNAL MODULE: ./node_modules/flatpickr/dist/flatpickr.js
275
275
  var flatpickr = __webpack_require__("cf06");
@@ -478,7 +478,7 @@ l10n_default.a.en.weekdays.shorthand.forEach((day, index) => {
478
478
  },
479
479
  data() {
480
480
  return {
481
- dataValue: '',
481
+ dataValue: this.value,
482
482
  dataOptions: {},
483
483
  isInvalid: false,
484
484
  };
@@ -692,7 +692,7 @@ var componentNormalizer = __webpack_require__("2877");
692
692
 
693
693
  var component = Object(componentNormalizer["a" /* default */])(
694
694
  cv_date_picker_cv_date_pickervue_type_script_lang_js_,
695
- cv_date_pickervue_type_template_id_4e069846_render,
695
+ cv_date_pickervue_type_template_id_71bd2208_render,
696
696
  staticRenderFns,
697
697
  false,
698
698
  null,
@@ -21561,16 +21561,16 @@ var virtual_CheckmarkFilled16 = {
21561
21561
  "use strict";
21562
21562
  __webpack_require__.r(__webpack_exports__);
21563
21563
 
21564
- // CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"0f4df6f3-vue-loader-template"}!./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/cv-number-input/cv-number-input.vue?vue&type=template&id=09bfad20&
21565
- var cv_number_inputvue_type_template_id_09bfad20_render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('cv-wrapper',{staticClass:"cv-number-input bx--form-item",attrs:{"tag-type":_vm.formItem ? 'div' : ''}},[_c('div',{staticClass:"bx--number",class:{
21564
+ // CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"0f4df6f3-vue-loader-template"}!./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/cv-number-input/cv-number-input.vue?vue&type=template&id=5e4d985e&
21565
+ var cv_number_inputvue_type_template_id_5e4d985e_render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('cv-wrapper',{staticClass:"cv-number-input bx--form-item",attrs:{"tag-type":_vm.formItem ? 'div' : ''}},[_c('div',{staticClass:"bx--number",class:{
21566
21566
  'bx--number--light': _vm.theme === 'light',
21567
21567
  'bx--number--helpertext': _vm.isHelper,
21568
21568
  'cv-number-input': !_vm.formItem,
21569
- },attrs:{"data-numberinput":"","data-invalid":_vm.isInvalid}},[_c('label',{staticClass:"bx--label",attrs:{"for":_vm.uid}},[_vm._v(_vm._s(_vm.label))]),(_vm.isHelper)?_c('div',{staticClass:"bx--form__helper-text"},[_vm._t("helper-text",[_vm._v(_vm._s(_vm.helperText))])],2):_vm._e(),_c('div',{staticClass:"bx--number__input-wrapper"},[_c('input',_vm._g(_vm._b({directives:[{name:"model",rawName:"v-model",value:(_vm.internalValue),expression:"internalValue"}],attrs:{"id":_vm.uid,"type":"number","step":_vm.step,"min":_vm.min,"max":_vm.max},domProps:{"value":(_vm.internalValue)},on:{"input":function($event){if($event.target.composing){ return; }_vm.internalValue=$event.target.value}}},'input',_vm.$attrs,false),_vm.inputListeners)),(_vm.isInvalid)?_c('WarningFilled16',{staticClass:"bx--number__invalid"}):_vm._e(),_c('div',{staticClass:"bx--number__controls"},[_c('button',{staticClass:"bx--number__control-btn up-icon",attrs:{"type":"button","aria-label":_vm.ariaLabelForUpButton},on:{"click":_vm.doUp}},[_c('CaretUpGlyph')],1),_c('button',{staticClass:"bx--number__control-btn down-icon",attrs:{"type":"button","aria-label":_vm.ariaLabelForDownButton},on:{"click":_vm.doDown}},[_c('CaretDownGlyph')],1)])],1),(_vm.isInvalid)?_c('div',{staticClass:"bx--form-requirement"},[_vm._t("invalid-message",[_vm._v(_vm._s(_vm.invalidMessage))])],2):_vm._e()])])}
21569
+ },attrs:{"data-numberinput":"","data-invalid":_vm.isInvalid}},[_c('label',{staticClass:"bx--label",attrs:{"for":_vm.uid}},[_vm._v(_vm._s(_vm.label))]),(_vm.isHelper)?_c('div',{staticClass:"bx--form__helper-text"},[_vm._t("helper-text",[_vm._v(_vm._s(_vm.helperText))])],2):_vm._e(),_c('div',{staticClass:"bx--number__input-wrapper"},[_c('input',_vm._g(_vm._b({ref:"input",attrs:{"id":_vm.uid,"type":"number","disabled":_vm.disabled,"step":_vm.step,"min":_vm.min,"max":_vm.max},domProps:{"value":_vm.internalValue}},'input',_vm.$attrs,false),_vm.inputListeners)),(_vm.isInvalid)?_c('WarningFilled16',{staticClass:"bx--number__invalid"}):_vm._e(),_c('div',{staticClass:"bx--number__controls"},[_c('button',{staticClass:"bx--number__control-btn up-icon",attrs:{"type":"button","aria-label":_vm.ariaLabelForUpButton,"disabled":_vm.disabled},on:{"click":_vm.doUp}},[_c('CaretUpGlyph')],1),_c('button',{staticClass:"bx--number__control-btn down-icon",attrs:{"type":"button","aria-label":_vm.ariaLabelForDownButton,"disabled":_vm.disabled},on:{"click":_vm.doDown}},[_c('CaretDownGlyph')],1)])],1),(_vm.isInvalid)?_c('div',{staticClass:"bx--form-requirement"},[_vm._t("invalid-message",[_vm._v(_vm._s(_vm.invalidMessage))])],2):_vm._e()])])}
21570
21570
  var staticRenderFns = []
21571
21571
 
21572
21572
 
21573
- // CONCATENATED MODULE: ./src/components/cv-number-input/cv-number-input.vue?vue&type=template&id=09bfad20&
21573
+ // CONCATENATED MODULE: ./src/components/cv-number-input/cv-number-input.vue?vue&type=template&id=5e4d985e&
21574
21574
 
21575
21575
  // EXTERNAL MODULE: ./src/mixins/uid-mixin.js
21576
21576
  var uid_mixin = __webpack_require__("fceb");
@@ -21741,6 +21741,10 @@ var _cv_wrapper = __webpack_require__("5d36");
21741
21741
  //
21742
21742
  //
21743
21743
  //
21744
+ //
21745
+ //
21746
+ //
21747
+ //
21744
21748
 
21745
21749
 
21746
21750
 
@@ -21757,6 +21761,7 @@ const maxDecimalPlaces = 10; // Stanard floating point accuracy goes at 14 cauti
21757
21761
  components: { CaretDownGlyph: caret_down, CaretUpGlyph: caret_up, WarningFilled16: _16["a" /* default */], CvWrapper: _cv_wrapper["a" /* default */] },
21758
21762
  inheritAttrs: false,
21759
21763
  props: {
21764
+ disabled: Boolean,
21760
21765
  formItem: { type: Boolean, default: true },
21761
21766
  helperText: { type: String, default: undefined },
21762
21767
  invalidMessage: { type: String, default: undefined },
@@ -21794,7 +21799,13 @@ const maxDecimalPlaces = 10; // Stanard floating point accuracy goes at 14 cauti
21794
21799
  },
21795
21800
  watch: {
21796
21801
  value() {
21797
- this.internalValue = this.valueAsString(this.value);
21802
+ // NOTE: DELIBERATE USE OF != TO COMPARE this.interanlValue and this.value
21803
+ if (typeof this.value !== 'number' || this.internalValue != this.value) {
21804
+ // prevents this.value of 1 updating this.internalValue of 1.0
21805
+ // which improves the typing experience
21806
+ // does not matter if this.value is string or number
21807
+ this.internalValue = this.value.toString();
21808
+ }
21798
21809
  },
21799
21810
  },
21800
21811
  computed: {
@@ -21803,108 +21814,40 @@ const maxDecimalPlaces = 10; // Stanard floating point accuracy goes at 14 cauti
21803
21814
  // https://vuejs.org/v2/guide/components-custom-events.html#Customizing-Component-v-model
21804
21815
  inputListeners() {
21805
21816
  return Object.assign({}, this.$listeners, {
21806
- input: () => this.emitValue(),
21817
+ input: ev => this.onInput(ev.target.value),
21807
21818
  });
21808
21819
  },
21809
- internalNumberValue() {
21810
- let numVal = parseFloat(this.internalValue, 10);
21811
-
21812
- if (isNaN(numVal)) {
21813
- numVal = parseFloat(this.min, 10) || 0;
21814
- }
21815
- return this.roundToPrecision(numVal);
21816
- },
21817
- internalMinValue() {
21818
- let numVal = parseFloat(this.min, 10);
21819
-
21820
- if (isNaN(numVal)) {
21821
- return undefined;
21822
- }
21823
- return this.roundToPrecision(numVal);
21824
- },
21825
- internalMaxValue() {
21826
- let numVal = parseFloat(this.max, 10);
21827
-
21828
- if (isNaN(numVal)) {
21829
- return undefined;
21830
- }
21831
- return this.roundToPrecision((this.internalStepValue * numVal) / this.internalStepValue);
21832
- },
21833
- internalStepValue() {
21834
- let numVal = parseFloat(this.step, 10);
21835
-
21836
- if (isNaN(numVal) || numVal <= 0) {
21837
- numVal = 1;
21838
- }
21839
- return numVal;
21840
- },
21841
- stepDecimalPlaces() {
21842
- if (Math.floor(this.internalStepValue) === this.internalStepValue) return 0;
21843
- return Math.min(maxDecimalPlaces, this.internalStepValue.toString().split('.')[1].length || 0);
21844
- },
21845
- // stepPrecision() {
21846
- // return Math.pow(10, -1 * this.stepDecimalPlaces);
21847
- // },
21848
21820
  },
21849
21821
  methods: {
21822
+ onInput(val) {
21823
+ this.internalValue = val;
21824
+ this.emitValue();
21825
+ },
21850
21826
  checkSlots() {
21851
21827
  // NOTE: this.$slots is not reactive so needs to be managed on beforeUpdate
21852
21828
  this.isInvalid = !!(this.$slots['invalid-message'] || (this.invalidMessage && this.invalidMessage.length));
21853
21829
  this.isHelper = !!(this.$slots['helper-text'] || (this.helperText && this.helperText.length));
21854
21830
  },
21855
- _doUpDown(up) {
21856
- let value;
21857
- let min = this.internalMinValue;
21858
- let min0 = min || 0;
21859
- let max = this.internalMaxValue;
21860
- let step = this.internalStepValue;
21861
- // be wary of floating point error
21862
- // steps should be from min value to less than or equal to max
21863
- let steps = Math.round((this.internalNumberValue - min0) / step);
21864
-
21865
- if (up) {
21866
- value = this.roundToPrecision(min0 + step * (steps + 1));
21867
-
21868
- if (max !== undefined && value > max) {
21869
- steps = Math.round((max - min0) / step);
21870
- value = min0 + step * steps;
21871
- if (value > max) {
21872
- value = value - step;
21873
- }
21874
- value = this.roundToPrecision(value);
21875
- }
21876
-
21877
- if (this.roundToPrecision(value - this.internalNumberValue - step, maxDecimalPlaces) > 0) {
21878
- // this is simpler than trying to prevent rounding errors
21879
- value = value - step;
21880
- }
21881
-
21882
- this.internalValue = this.valueAsString(value);
21883
- } else {
21884
- value = this.roundToPrecision(min0 + step * (steps - 1));
21885
-
21886
- if (min !== undefined && value < min) {
21887
- value = min;
21888
- }
21889
21831
 
21890
- if (this.roundToPrecision(value - this.internalNumberValue + step, maxDecimalPlaces) < 0) {
21891
- // this is simpler than trying to prevent rounding errors
21892
- value = value + step;
21893
- }
21894
-
21895
- this.internalValue = this.valueAsString(value);
21896
- }
21897
- this.emitValue();
21898
- },
21899
21832
  doUp() {
21900
- this._doUpDown(true);
21833
+ this.$refs.input.stepUp();
21901
21834
  },
21902
21835
  doDown() {
21903
- this._doUpDown(false);
21836
+ this.$refs.input.stepDown();
21904
21837
  },
21905
21838
  emitValue() {
21906
21839
  if (typeof this.value === 'number') {
21907
- this.$emit('input', this.internalNumberValue);
21840
+ // this.$emit('input', this.internalNumberValue);
21841
+
21842
+ if (this.internalValue != this.value) {
21843
+ const ePos = this.internalValue.indexOf('e-');
21844
+ const dotPos = this.internalValue.indexOf('.');
21845
+ if (ePos > -1 || dotPos > -1) {
21846
+ this.$emit('input', parseFloat(this.internalValue));
21847
+ } else {
21848
+ this.$emit('input', parseInt(this.internalValue));
21849
+ }
21850
+ }
21908
21851
  } else {
21909
21852
  this.$emit('input', this.internalValue);
21910
21853
  }
@@ -21912,20 +21855,12 @@ const maxDecimalPlaces = 10; // Stanard floating point accuracy goes at 14 cauti
21912
21855
  valueAsString(val) {
21913
21856
  let strVal;
21914
21857
  if (typeof val === 'number') {
21915
- strVal = val.toFixed(this.stepDecimalPlaces);
21858
+ strVal = val.toString();
21916
21859
  } else {
21917
21860
  strVal = val;
21918
21861
  }
21919
-
21920
21862
  return strVal;
21921
21863
  },
21922
- roundToPrecision(x, optDecimalPlaces) {
21923
- // let sign = x >= 0 ? 1 : -1;
21924
- // let y = x + sign * (this.stepPrecision === undefined ? 0.5 : this.stepPrecision / 2);
21925
- // return y - (y % (this.stepPrecision === undefined ? 1 : this.stepPrecision));
21926
- let decimalPlaces = optDecimalPlaces || this.stepDecimalPlaces;
21927
- return parseFloat(x.toFixed(decimalPlaces));
21928
- },
21929
21864
  },
21930
21865
  });
21931
21866
 
@@ -21944,7 +21879,7 @@ var componentNormalizer = __webpack_require__("2877");
21944
21879
 
21945
21880
  var component = Object(componentNormalizer["a" /* default */])(
21946
21881
  cv_number_input_cv_number_inputvue_type_script_lang_js_,
21947
- cv_number_inputvue_type_template_id_09bfad20_render,
21882
+ cv_number_inputvue_type_template_id_5e4d985e_render,
21948
21883
  staticRenderFns,
21949
21884
  false,
21950
21885
  null,