@vue-interface/select-field 0.11.1 → 0.12.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.
File without changes
@@ -485,6 +485,24 @@ function paramCase(input, options) {
485
485
  delimiter: "-"
486
486
  }, options));
487
487
  }
488
+ const global = {};
489
+ function config(...args) {
490
+ if (!args.length) {
491
+ return global;
492
+ }
493
+ const [key, value] = args;
494
+ if (typeof key === "string") {
495
+ return typeof global[key] !== "undefined" ? global[key] : value;
496
+ }
497
+ if (Array.isArray(key)) {
498
+ return key.reduce((carry, key2) => {
499
+ return Object.assign(carry, {
500
+ [key2]: global[key2]
501
+ });
502
+ }, {});
503
+ }
504
+ return Object.assign(global, ...args);
505
+ }
488
506
  function prefix(key, value, delimeter = "-") {
489
507
  const string = value.toString().replace(new RegExp(`^${key}${delimeter}?`), "");
490
508
  return [paramCase(string), key].filter((value2) => !!value2).join(delimeter);
@@ -528,6 +546,10 @@ var FormControl = {
528
546
  type: Boolean,
529
547
  default: false
530
548
  },
549
+ animated: {
550
+ type: Boolean,
551
+ default: () => config("animated", false)
552
+ },
531
553
  bindEvents: {
532
554
  type: Array,
533
555
  default() {
@@ -542,10 +564,10 @@ var FormControl = {
542
564
  },
543
565
  defaultControlClass: {
544
566
  type: String,
545
- default: "form-control"
567
+ default: () => config("defaultControlClass", "form-control")
546
568
  },
547
569
  defaultValue: {
548
- default: null
570
+ default: () => config("defaultValue", null)
549
571
  },
550
572
  error: [String, Array, Boolean],
551
573
  errors: {
@@ -557,13 +579,13 @@ var FormControl = {
557
579
  feedback: [String, Array],
558
580
  group: {
559
581
  type: Boolean,
560
- default: true
582
+ default: () => config("group", true)
561
583
  },
562
584
  helpText: [Number, String],
563
585
  hideLabel: Boolean,
564
586
  indicator: {
565
587
  type: String,
566
- default: "spinner"
588
+ default: () => config("indicator", "spinner")
567
589
  },
568
590
  indicatorSize: String,
569
591
  inline: Boolean,
@@ -571,7 +593,7 @@ var FormControl = {
571
593
  label: [Number, String],
572
594
  labelClass: {
573
595
  type: [Object, String],
574
- default: "form-label"
596
+ default: () => config("labelClass", "form-label")
575
597
  },
576
598
  pill: Boolean,
577
599
  plaintext: Boolean,
@@ -615,6 +637,7 @@ var FormControl = {
615
637
  return {
616
638
  [paramCase(this.componentName)]: !!this.componentName,
617
639
  [this.size && prefix(this.size, this.componentName)]: !!this.size,
640
+ "animated": this.animated,
618
641
  "default-empty": this.defaultEmpty,
619
642
  "form-group": this.group,
620
643
  [this.size && prefix(this.size, "form-group")]: !!this.size,
@@ -701,7 +724,7 @@ var FormControl = {
701
724
  },
702
725
  getFieldErrors() {
703
726
  let errors = this.error || this.errors;
704
- if (isObject(this.errors)) {
727
+ if (this.errors && isObject(this.errors)) {
705
728
  errors = this.errors[this.$attrs.name || this.$attrs.id];
706
729
  }
707
730
  return !errors || Array.isArray(errors) || isObject(errors) ? errors : [errors];
@@ -1,5 +1,5 @@
1
- (function(_,h){typeof exports=="object"&&typeof module!="undefined"?h(exports):typeof define=="function"&&define.amd?define(["exports"],h):(_=typeof globalThis!="undefined"?globalThis:_||self,h(_.SelectField={}))})(this,function(_){"use strict";function h(e){return h=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},h(e)}function z(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function S(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function I(e,t,r){return t&&S(e.prototype,t),r&&S(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function b(e,t){return b=Object.setPrototypeOf||function(i,n){return i.__proto__=n,i},b(e,t)}function N(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function v(e,t,r){return N()?v=Reflect.construct:v=function(n,o,s){var c=[null];c.push.apply(c,o);var a=Function.bind.apply(n,c),u=new a;return s&&b(u,s.prototype),u},v.apply(null,arguments)}function x(e,t){return L(e)||B(e,t)||V(e,t)||H()}function L(e){if(Array.isArray(e))return e}function B(e,t){var r=e==null?null:typeof Symbol!="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var i=[],n=!0,o=!1,s,c;try{for(r=r.call(e);!(n=(s=r.next()).done)&&(i.push(s.value),!(t&&i.length===t));n=!0);}catch(a){o=!0,c=a}finally{try{!n&&r.return!=null&&r.return()}finally{if(o)throw c}}return i}}function V(e,t){if(!!e){if(typeof e=="string")return $(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return $(e,t)}}function $(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,i=new Array(t);r<t;r++)i[r]=e[r];return i}function H(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
2
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var y=function(){return y=Object.assign||function(r){for(var i,n=1,o=arguments.length;n<o;n++){i=arguments[n];for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(r[s]=i[s])}return r},y.apply(this,arguments)};function M(e){return e.toLowerCase()}var W=[/([a-z0-9])([A-Z])/g,/([A-Z])([A-Z][a-z])/g],Z=/[^A-Z0-9]+/gi;function q(e,t){t===void 0&&(t={});for(var r=t.splitRegexp,i=r===void 0?W:r,n=t.stripRegexp,o=n===void 0?Z:n,s=t.transform,c=s===void 0?M:s,a=t.delimiter,u=a===void 0?" ":a,d=w(w(e,i,"$1\0$2"),o,"\0"),f=0,l=d.length;d.charAt(f)==="\0";)f++;for(;d.charAt(l-1)==="\0";)l--;return d.slice(f,l).split("\0").map(c).join(u)}function w(e,t,r){return t instanceof RegExp?e.replace(t,r):t.reduce(function(i,n){return i.replace(n,r)},e)}function D(e,t){return t===void 0&&(t={}),q(e,y({delimiter:"."},t))}function m(e,t){return t===void 0&&(t={}),D(e,y({delimiter:"-"},t))}var A=function(){function e(){var t=this,r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};z(this,e),this.components={},Object.entries(r).forEach(function(i){var n=x(i,2),o=n[0],s=n[1];t.register(o,s)})}return I(e,[{key:"validate",value:function(r){if(h(r)==="object"||typeof r=="function")return r;throw new Error("Invalid data type `".concat(h(r),"`. Should be type `object` or `function`."))}},{key:"get",value:function(r){var i=this.components[r=m(r)];if(i)return i;throw new Error('"'.concat(r,'" has not been registered yet!'))}},{key:"register",value:function(r,i){var n=this;return h(r)==="object"?(Object.entries(r).forEach(function(o){var s=x(o,2),c=s[0],a=s[1];n.register(m(c),a)}),this):(this.components[m(r)]=this.validate(i),this)}},{key:"remove",value:function(r){return delete this.components[m(r)],this}},{key:"reset",value:function(){return this.components={},this}}]),e}();function G(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return v(A,t)}const E=G();var U=function(){var e=this,t=e.$createElement,r=e._self._c||t;return r("div",{staticClass:"activity-indicator",class:e.classes,style:e.style},[r("div",{staticClass:"activity-indicator-content"},[r(e.component,{tag:"component",staticClass:"mx-auto"}),e.label?r("div",{staticClass:"activity-indicator-label"},[e._v(" "+e._s(e.label)+" ")]):e._e()],1)])},X=[],_e="";function F(e,t,r,i,n,o,s,c){var a=typeof e=="function"?e.options:e;t&&(a.render=t,a.staticRenderFns=r,a._compiled=!0),i&&(a.functional=!0),o&&(a._scopeId="data-v-"+o);var u;if(s?(u=function(l){l=l||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,!l&&typeof __VUE_SSR_CONTEXT__!="undefined"&&(l=__VUE_SSR_CONTEXT__),n&&n.call(this,l),l&&l._registeredComponents&&l._registeredComponents.add(s)},a._ssrRegister=u):n&&(u=c?function(){n.call(this,(a.functional?this.parent:this).$root.$options.shadowRoot)}:n),u)if(a.functional){a._injectStyles=u;var d=a.render;a.render=function(he,j){return u.call(j),d(he,j)}}else{var f=a.beforeCreate;a.beforeCreate=f?[].concat(f,u):[u]}return{exports:e,options:a}}function p(e,t="px"){return e!=null&&e!==!1&&isFinite(e)?`${e}${t}`:e}const J={name:"ActivityIndicator",props:{absolute:Boolean,center:Boolean,label:String,size:{type:String,default:"md"},registry:{type:A,default(){return E}},type:{type:String,required:!0},height:[String,Number],maxHeight:[String,Number],minHeight:[String,Number],width:[String,Number],maxWidth:[String,Number],minWidth:[String,Number]},computed:{classes(){return{"activity-indicator-center":this.center,"activity-indicator-absolute":this.absolute,[this.size&&`activity-indicator-${this.size}`]:!!this.size}},style(){return{width:p(this.width),maxWidth:p(this.maxWidth),minWidth:p(this.minWidth),height:p(this.height),maxHeight:p(this.maxHeight),minHeight:p(this.minHeight)}},component(){return()=>{const e=E.get(this.type);return e instanceof Promise?e:typeof e=="function"?e():Promise.resolve(e)}}}},R={};var K=F(J,U,X,!1,Q,null,null,null);function Q(e){for(let t in R)this[t]=R[t]}var Y=function(){return K.exports}(),pe="",ve="",ye="",me="",ge="",be="",Ce="",Se="",xe="",$e="",we="",Ae="",Ee="",Fe="",ee={props:{dropShadow:[Boolean,String],dropShadowableClassPrefix:{type:String,default:"drop-shadow"},shadow:[Boolean,String],shadowableClassPrefix:{type:String,default:"shadow"}},computed:{shadowableClass(){const e=this.dropShadow===!0?"":this.dropShadow&&`-${this.dropShadow}`,t=this.shadow===!0?"":this.shadow&&`-${this.shadow}`;return{[`${this.dropShadowableClassPrefix}${e}`]:!!this.dropShadow,[`${this.shadowableClassPrefix}${t}`]:!!this.shadow}}}};/*! *****************************************************************************
1
+ (function(_,h){typeof exports=="object"&&typeof module!="undefined"?h(exports):typeof define=="function"&&define.amd?define(["exports"],h):(_=typeof globalThis!="undefined"?globalThis:_||self,h(_.SelectField={}))})(this,function(_){"use strict";function h(e){return h=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},h(e)}function N(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function $(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function L(e,t,r){return t&&$(e.prototype,t),r&&$(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function S(e,t){return S=Object.setPrototypeOf||function(n,i){return n.__proto__=i,n},S(e,t)}function B(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function m(e,t,r){return B()?m=Reflect.construct:m=function(i,o,s){var c=[null];c.push.apply(c,o);var a=Function.bind.apply(i,c),u=new a;return s&&S(u,s.prototype),u},m.apply(null,arguments)}function w(e,t){return V(e)||H(e,t)||M(e,t)||W()}function V(e){if(Array.isArray(e))return e}function H(e,t){var r=e==null?null:typeof Symbol!="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n=[],i=!0,o=!1,s,c;try{for(r=r.call(e);!(i=(s=r.next()).done)&&(n.push(s.value),!(t&&n.length===t));i=!0);}catch(a){o=!0,c=a}finally{try{!i&&r.return!=null&&r.return()}finally{if(o)throw c}}return n}}function M(e,t){if(!!e){if(typeof e=="string")return A(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return A(e,t)}}function A(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function W(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
2
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var g=function(){return g=Object.assign||function(r){for(var n,i=1,o=arguments.length;i<o;i++){n=arguments[i];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(r[s]=n[s])}return r},g.apply(this,arguments)};function Z(e){return e.toLowerCase()}var q=[/([a-z0-9])([A-Z])/g,/([A-Z])([A-Z][a-z])/g],D=/[^A-Z0-9]+/gi;function G(e,t){t===void 0&&(t={});for(var r=t.splitRegexp,n=r===void 0?q:r,i=t.stripRegexp,o=i===void 0?D:i,s=t.transform,c=s===void 0?Z:s,a=t.delimiter,u=a===void 0?" ":a,d=E(E(e,n,"$1\0$2"),o,"\0"),f=0,l=d.length;d.charAt(f)==="\0";)f++;for(;d.charAt(l-1)==="\0";)l--;return d.slice(f,l).split("\0").map(c).join(u)}function E(e,t,r){return t instanceof RegExp?e.replace(t,r):t.reduce(function(n,i){return n.replace(i,r)},e)}function U(e,t){return t===void 0&&(t={}),G(e,g({delimiter:"."},t))}function b(e,t){return t===void 0&&(t={}),U(e,g({delimiter:"-"},t))}var F=function(){function e(){var t=this,r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};N(this,e),this.components={},Object.entries(r).forEach(function(n){var i=w(n,2),o=i[0],s=i[1];t.register(o,s)})}return L(e,[{key:"validate",value:function(r){if(h(r)==="object"||typeof r=="function")return r;throw new Error("Invalid data type `".concat(h(r),"`. Should be type `object` or `function`."))}},{key:"get",value:function(r){var n=this.components[r=b(r)];if(n)return n;throw new Error('"'.concat(r,'" has not been registered yet!'))}},{key:"register",value:function(r,n){var i=this;return h(r)==="object"?(Object.entries(r).forEach(function(o){var s=w(o,2),c=s[0],a=s[1];i.register(b(c),a)}),this):(this.components[b(r)]=this.validate(n),this)}},{key:"remove",value:function(r){return delete this.components[b(r)],this}},{key:"reset",value:function(){return this.components={},this}}]),e}();function X(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return m(F,t)}const O=X();var J=function(){var e=this,t=e.$createElement,r=e._self._c||t;return r("div",{staticClass:"activity-indicator",class:e.classes,style:e.style},[r("div",{staticClass:"activity-indicator-content"},[r(e.component,{tag:"component",staticClass:"mx-auto"}),e.label?r("div",{staticClass:"activity-indicator-label"},[e._v(" "+e._s(e.label)+" ")]):e._e()],1)])},K=[],ve="";function R(e,t,r,n,i,o,s,c){var a=typeof e=="function"?e.options:e;t&&(a.render=t,a.staticRenderFns=r,a._compiled=!0),n&&(a.functional=!0),o&&(a._scopeId="data-v-"+o);var u;if(s?(u=function(l){l=l||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,!l&&typeof __VUE_SSR_CONTEXT__!="undefined"&&(l=__VUE_SSR_CONTEXT__),i&&i.call(this,l),l&&l._registeredComponents&&l._registeredComponents.add(s)},a._ssrRegister=u):i&&(u=c?function(){i.call(this,(a.functional?this.parent:this).$root.$options.shadowRoot)}:i),u)if(a.functional){a._injectStyles=u;var d=a.render;a.render=function(pe,I){return u.call(I),d(pe,I)}}else{var f=a.beforeCreate;a.beforeCreate=f?[].concat(f,u):[u]}return{exports:e,options:a}}function p(e,t="px"){return e!=null&&e!==!1&&isFinite(e)?`${e}${t}`:e}const Q={name:"ActivityIndicator",props:{absolute:Boolean,center:Boolean,label:String,size:{type:String,default:"md"},registry:{type:F,default(){return O}},type:{type:String,required:!0},height:[String,Number],maxHeight:[String,Number],minHeight:[String,Number],width:[String,Number],maxWidth:[String,Number],minWidth:[String,Number]},computed:{classes(){return{"activity-indicator-center":this.center,"activity-indicator-absolute":this.absolute,[this.size&&`activity-indicator-${this.size}`]:!!this.size}},style(){return{width:p(this.width),maxWidth:p(this.maxWidth),minWidth:p(this.minWidth),height:p(this.height),maxHeight:p(this.maxHeight),minHeight:p(this.minHeight)}},component(){return()=>{const e=O.get(this.type);return e instanceof Promise?e:typeof e=="function"?e():Promise.resolve(e)}}}},T={};var Y=R(Q,J,K,!1,ee,null,null,null);function ee(e){for(let t in T)this[t]=T[t]}var te=function(){return Y.exports}(),ye="",me="",ge="",be="",Ce="",Se="",xe="",$e="",we="",Ae="",Ee="",Fe="",Oe="",Re="",re={props:{dropShadow:[Boolean,String],dropShadowableClassPrefix:{type:String,default:"drop-shadow"},shadow:[Boolean,String],shadowableClassPrefix:{type:String,default:"shadow"}},computed:{shadowableClass(){const e=this.dropShadow===!0?"":this.dropShadow&&`-${this.dropShadow}`,t=this.shadow===!0?"":this.shadow&&`-${this.shadow}`;return{[`${this.dropShadowableClassPrefix}${e}`]:!!this.dropShadow,[`${this.shadowableClassPrefix}${t}`]:!!this.shadow}}}};/*! *****************************************************************************
3
3
  Copyright (c) Microsoft Corporation.
4
4
 
5
5
  Permission to use, copy, modify, and/or distribute this software for any
@@ -12,4 +12,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
12
12
  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
13
13
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14
14
  PERFORMANCE OF THIS SOFTWARE.
15
- ***************************************************************************** */var g=function(){return g=Object.assign||function(t){for(var r,i=1,n=arguments.length;i<n;i++){r=arguments[i];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(t[o]=r[o])}return t},g.apply(this,arguments)};function te(e){return e.toLowerCase()}var re=[/([a-z0-9])([A-Z])/g,/([A-Z])([A-Z][a-z])/g],ie=/[^A-Z0-9]+/gi;function ne(e,t){t===void 0&&(t={});for(var r=t.splitRegexp,i=r===void 0?re:r,n=t.stripRegexp,o=n===void 0?ie:n,s=t.transform,c=s===void 0?te:s,a=t.delimiter,u=a===void 0?" ":a,d=O(O(e,i,"$1\0$2"),o,"\0"),f=0,l=d.length;d.charAt(f)==="\0";)f++;for(;d.charAt(l-1)==="\0";)l--;return d.slice(f,l).split("\0").map(c).join(u)}function O(e,t,r){return t instanceof RegExp?e.replace(t,r):t.reduce(function(i,n){return i.replace(n,r)},e)}function ae(e,t){return t===void 0&&(t={}),ne(e,g({delimiter:"."},t))}function T(e,t){return t===void 0&&(t={}),ae(e,g({delimiter:"-"},t))}function C(e,t,r="-"){const i=t.toString().replace(new RegExp(`^${e}${r}?`),"");return[T(i),e].filter(n=>!!n).join(r)}function P(e){return!Array.isArray(e)&&typeof e=="object"}var se={directives:{bindEvents:{bind(e,t,r){if(e.addEventListener("focus",()=>{r.context.hasFocus=!0}),e.addEventListener("blur",()=>{r.context.hasFocus=!1}),e.addEventListener(e.tagName==="SELECT"?"change":"input",i=>{r.context.isEmpty=!e.value,r.context.currentValue=e.value}),r.context.hasChanged=!!e.value,r.context.bindEvents.forEach(i=>{e.addEventListener(i,n=>{r.context.$emit(i,n)})}),e.tagName==="SELECT"){const i=e.querySelector('[value=""]');i&&i.value===e.value&&(r.context.defaultEmpty=!0)}}}},mixins:[ee],inheritAttrs:!1,props:{activity:{type:Boolean,default:!1},bindEvents:{type:Array,default(){return["focus","blur","change","click","keypress","keyup","keydown","progress","paste"]}},componentName:{type:String,default(){return this.$options.name}},defaultControlClass:{type:String,default:"form-control"},defaultValue:{default:null},error:[String,Array,Boolean],errors:{type:[Array,Object,Boolean],default(){return{}}},feedback:[String,Array],group:{type:Boolean,default:!0},helpText:[Number,String],hideLabel:Boolean,indicator:{type:String,default:"spinner"},indicatorSize:String,inline:Boolean,invalid:Boolean,label:[Number,String],labelClass:{type:[Object,String],default:"form-label"},pill:Boolean,plaintext:Boolean,size:String,spacing:String,valid:Boolean,value:{default:null}},data(){return{currentValue:this.value||this.defaultValue,defaultEmpty:!1,hasChanged:!1,hasFocus:!1,isEmpty:!(this.value||this.defaultValue)}},computed:{id(){return this.$attrs.id||this.$attrs.name},controlAttributes(){return Object.keys(this.$attrs).concat([["id",this.id],["class",this.controlClasses]]).reduce((e,t)=>(Array.isArray(t)?e[t[0]]=t[1]:e[t]=this[t]||this.$attrs[t],e),{})},controlClass(){return this.defaultControlClass},controlSizeClass(){return C(this.size,this.controlClass)},formGroupClasses(){return{[T(this.componentName)]:!!this.componentName,[this.size&&C(this.size,this.componentName)]:!!this.size,"default-empty":this.defaultEmpty,"form-group":this.group,[this.size&&C(this.size,"form-group")]:!!this.size,"has-activity":this.activity,"has-changed":this.hasChanged,"has-focus":this.hasFocus,"has-icon":!!this.$slots.icon,"is-empty":this.isEmpty,"is-invalid":!!(this.invalid||this.invalidFeedback),"is-valid":!!(this.valid||this.validFeedback)}},controlClasses(){return Object.assign({[this.controlClass]:!!this.controlClass,[this.controlSizeClass]:!!this.controlSizeClass,"form-control-icon":!!this.$slots.icon,"is-valid":!!(this.valid||this.validFeedback),"is-invalid":!!(this.invalid||this.invalidFeedback),[this.pillClasses]:this.pill,[this.plaintextClass]:this.plaintext,[this.spacing]:!!this.spacing},this.shadowableClass)},hasDefaultSlot(){return!!this.$slots.default},invalidFeedback(){if(this.error==="")return null;if(this.error)return this.error;const e=this.getFieldErrors();return Array.isArray(e)?e.filter(t=>t&&typeof t=="string").join("<br>"):e},pillClasses(){return"rounded rounded-pill"},plaintextClass(){return"form-control-plaintext"},validFeedback(){return Array.isArray(this.feedback)?this.feedback.join("<br>"):this.feedback}},watch:{hasFocus(){this.shouldChangeOnFocus()&&(this.hasChanged=!0)},value(e){this.currentValue=e},currentValue(){this.hasChanged=!0},defaultEmpty(){this.hasChanged=!0}},mounted(){this.value===null&&this.defaultValue!==null&&this.$emit("input",this.defaultValue)},methods:{blur(){this.getInputField()&&this.getInputField().blur()},focus(){this.getInputField()&&this.getInputField().focus()},getInputField(){return this.$el.querySelector(".form-control, input, select, textarea")},getFieldErrors(){let e=this.error||this.errors;return P(this.errors)&&(e=this.errors[this.$attrs.name||this.$attrs.id]),!e||Array.isArray(e)||P(e)?e:[e]},shouldChangeOnFocus(){return!this.getInputField().readOnly},onInput(e){this.$emit("input",e.target.value),this.$emit("update:value",e.target.value)}}},oe=function(){var e=this,t=e.$createElement,r=e._self._c||t;return r("div",{class:e.formGroupClasses},[e._t("label",function(){return[e.label?r("label",{ref:"label",class:e.labelClass,attrs:{for:e.id},domProps:{innerHTML:e._s(e.label)},on:{click:e.focus}}):e._e()]}),r("div",{staticClass:"form-group-inner"},[e._t("control",function(){var i;return[e.$slots.icon?r("div",{staticClass:"form-group-inner-icon",on:{click:e.focus}},[e._t("icon")],2):e._e(),r("select",e._b({directives:[{name:"bind-events",rawName:"v-bind-events"}],ref:"field",domProps:{value:e.currentValue},on:{input:e.onInput}},"select",Object.assign((i={},i.disabled=e.$attrs.readonly,i),e.controlAttributes),!1),[e._t("default")],2)]}),e._t("activity",function(){return[r("transition",{attrs:{name:"select-field-fade"}},[e.activity?r("activity-indicator",{key:"activity",ref:"activity",attrs:{type:e.indicator,size:e.indicatorSize||e.size}}):e._e()],1)]})],2),e._t("feedback",function(){return[e.invalidFeedback?r("div",{staticClass:"invalid-feedback",attrs:{invalid:""},domProps:{innerHTML:e._s(e.invalidFeedback)}}):e.validFeedback?r("div",{staticClass:"valid-feedback",attrs:{valid:""},domProps:{innerHTML:e._s(e.validFeedback)}}):e._e()]}),e._t("help",function(){return[e.helpText?r("small",{ref:"help"},[e._v(" "+e._s(e.helpText)+" ")]):e._e()]})],2)},le=[],Re="";const ue={name:"SelectField",components:{ActivityIndicator:Y},mixins:[se],props:{defaultControlClass:{type:String,default:"form-select"}},computed:{controlClass(){return this.plaintext?`${this.defaultControlClass}-plaintext`:this.defaultControlClass}},mounted(){const e=this.$el.querySelector("[selected]");e&&(this.currentValue=e.value,this.$emit("input",this.currentValue),this.$emit("update:value",this.currentValue))},methods:{shouldChangeOnFocus(){return!1}}},k={};var ce=F(ue,oe,le,!1,de,null,null,null);function de(e){for(let t in k)this[t]=k[t]}var fe=function(){return ce.exports}();_.SelectField=fe,Object.defineProperty(_,"__esModule",{value:!0}),_[Symbol.toStringTag]="Module"});
15
+ ***************************************************************************** */var C=function(){return C=Object.assign||function(t){for(var r,n=1,i=arguments.length;n<i;n++){r=arguments[n];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(t[o]=r[o])}return t},C.apply(this,arguments)};function ne(e){return e.toLowerCase()}var ie=[/([a-z0-9])([A-Z])/g,/([A-Z])([A-Z][a-z])/g],ae=/[^A-Z0-9]+/gi;function se(e,t){t===void 0&&(t={});for(var r=t.splitRegexp,n=r===void 0?ie:r,i=t.stripRegexp,o=i===void 0?ae:i,s=t.transform,c=s===void 0?ne:s,a=t.delimiter,u=a===void 0?" ":a,d=P(P(e,n,"$1\0$2"),o,"\0"),f=0,l=d.length;d.charAt(f)==="\0";)f++;for(;d.charAt(l-1)==="\0";)l--;return d.slice(f,l).split("\0").map(c).join(u)}function P(e,t,r){return t instanceof RegExp?e.replace(t,r):t.reduce(function(n,i){return n.replace(i,r)},e)}function oe(e,t){return t===void 0&&(t={}),se(e,C({delimiter:"."},t))}function j(e,t){return t===void 0&&(t={}),oe(e,C({delimiter:"-"},t))}const y={};function v(...e){if(!e.length)return y;const[t,r]=e;return typeof t=="string"?typeof y[t]!="undefined"?y[t]:r:Array.isArray(t)?t.reduce((n,i)=>Object.assign(n,{[i]:y[i]}),{}):Object.assign(y,...e)}function x(e,t,r="-"){const n=t.toString().replace(new RegExp(`^${e}${r}?`),"");return[j(n),e].filter(i=>!!i).join(r)}function k(e){return!Array.isArray(e)&&typeof e=="object"}var le={directives:{bindEvents:{bind(e,t,r){if(e.addEventListener("focus",()=>{r.context.hasFocus=!0}),e.addEventListener("blur",()=>{r.context.hasFocus=!1}),e.addEventListener(e.tagName==="SELECT"?"change":"input",n=>{r.context.isEmpty=!e.value,r.context.currentValue=e.value}),r.context.hasChanged=!!e.value,r.context.bindEvents.forEach(n=>{e.addEventListener(n,i=>{r.context.$emit(n,i)})}),e.tagName==="SELECT"){const n=e.querySelector('[value=""]');n&&n.value===e.value&&(r.context.defaultEmpty=!0)}}}},mixins:[re],inheritAttrs:!1,props:{activity:{type:Boolean,default:!1},animated:{type:Boolean,default:()=>v("animated",!1)},bindEvents:{type:Array,default(){return["focus","blur","change","click","keypress","keyup","keydown","progress","paste"]}},componentName:{type:String,default(){return this.$options.name}},defaultControlClass:{type:String,default:()=>v("defaultControlClass","form-control")},defaultValue:{default:()=>v("defaultValue",null)},error:[String,Array,Boolean],errors:{type:[Array,Object,Boolean],default(){return{}}},feedback:[String,Array],group:{type:Boolean,default:()=>v("group",!0)},helpText:[Number,String],hideLabel:Boolean,indicator:{type:String,default:()=>v("indicator","spinner")},indicatorSize:String,inline:Boolean,invalid:Boolean,label:[Number,String],labelClass:{type:[Object,String],default:()=>v("labelClass","form-label")},pill:Boolean,plaintext:Boolean,size:String,spacing:String,valid:Boolean,value:{default:null}},data(){return{currentValue:this.value||this.defaultValue,defaultEmpty:!1,hasChanged:!1,hasFocus:!1,isEmpty:!(this.value||this.defaultValue)}},computed:{id(){return this.$attrs.id||this.$attrs.name},controlAttributes(){return Object.keys(this.$attrs).concat([["id",this.id],["class",this.controlClasses]]).reduce((e,t)=>(Array.isArray(t)?e[t[0]]=t[1]:e[t]=this[t]||this.$attrs[t],e),{})},controlClass(){return this.defaultControlClass},controlSizeClass(){return x(this.size,this.controlClass)},formGroupClasses(){return{[j(this.componentName)]:!!this.componentName,[this.size&&x(this.size,this.componentName)]:!!this.size,animated:this.animated,"default-empty":this.defaultEmpty,"form-group":this.group,[this.size&&x(this.size,"form-group")]:!!this.size,"has-activity":this.activity,"has-changed":this.hasChanged,"has-focus":this.hasFocus,"has-icon":!!this.$slots.icon,"is-empty":this.isEmpty,"is-invalid":!!(this.invalid||this.invalidFeedback),"is-valid":!!(this.valid||this.validFeedback)}},controlClasses(){return Object.assign({[this.controlClass]:!!this.controlClass,[this.controlSizeClass]:!!this.controlSizeClass,"form-control-icon":!!this.$slots.icon,"is-valid":!!(this.valid||this.validFeedback),"is-invalid":!!(this.invalid||this.invalidFeedback),[this.pillClasses]:this.pill,[this.plaintextClass]:this.plaintext,[this.spacing]:!!this.spacing},this.shadowableClass)},hasDefaultSlot(){return!!this.$slots.default},invalidFeedback(){if(this.error==="")return null;if(this.error)return this.error;const e=this.getFieldErrors();return Array.isArray(e)?e.filter(t=>t&&typeof t=="string").join("<br>"):e},pillClasses(){return"rounded rounded-pill"},plaintextClass(){return"form-control-plaintext"},validFeedback(){return Array.isArray(this.feedback)?this.feedback.join("<br>"):this.feedback}},watch:{hasFocus(){this.shouldChangeOnFocus()&&(this.hasChanged=!0)},value(e){this.currentValue=e},currentValue(){this.hasChanged=!0},defaultEmpty(){this.hasChanged=!0}},mounted(){this.value===null&&this.defaultValue!==null&&this.$emit("input",this.defaultValue)},methods:{blur(){this.getInputField()&&this.getInputField().blur()},focus(){this.getInputField()&&this.getInputField().focus()},getInputField(){return this.$el.querySelector(".form-control, input, select, textarea")},getFieldErrors(){let e=this.error||this.errors;return this.errors&&k(this.errors)&&(e=this.errors[this.$attrs.name||this.$attrs.id]),!e||Array.isArray(e)||k(e)?e:[e]},shouldChangeOnFocus(){return!this.getInputField().readOnly},onInput(e){this.$emit("input",e.target.value),this.$emit("update:value",e.target.value)}}},ue=function(){var e=this,t=e.$createElement,r=e._self._c||t;return r("div",{class:e.formGroupClasses},[e._t("label",function(){return[e.label?r("label",{ref:"label",class:e.labelClass,attrs:{for:e.id},domProps:{innerHTML:e._s(e.label)},on:{click:e.focus}}):e._e()]}),r("div",{staticClass:"form-group-inner"},[e._t("control",function(){var n;return[e.$slots.icon?r("div",{staticClass:"form-group-inner-icon",on:{click:e.focus}},[e._t("icon")],2):e._e(),r("select",e._b({directives:[{name:"bind-events",rawName:"v-bind-events"}],ref:"field",domProps:{value:e.currentValue},on:{input:e.onInput}},"select",Object.assign((n={},n.disabled=e.$attrs.readonly,n),e.controlAttributes),!1),[e._t("default")],2)]}),e._t("activity",function(){return[r("transition",{attrs:{name:"select-field-fade"}},[e.activity?r("activity-indicator",{key:"activity",ref:"activity",attrs:{type:e.indicator,size:e.indicatorSize||e.size}}):e._e()],1)]})],2),e._t("feedback",function(){return[e.invalidFeedback?r("div",{staticClass:"invalid-feedback",attrs:{invalid:""},domProps:{innerHTML:e._s(e.invalidFeedback)}}):e.validFeedback?r("div",{staticClass:"valid-feedback",attrs:{valid:""},domProps:{innerHTML:e._s(e.validFeedback)}}):e._e()]}),e._t("help",function(){return[e.helpText?r("small",{ref:"help"},[e._v(" "+e._s(e.helpText)+" ")]):e._e()]})],2)},ce=[],Te="";const de={name:"SelectField",components:{ActivityIndicator:te},mixins:[le],props:{defaultControlClass:{type:String,default:"form-select"}},computed:{controlClass(){return this.plaintext?`${this.defaultControlClass}-plaintext`:this.defaultControlClass}},mounted(){const e=this.$el.querySelector("[selected]");e&&(this.currentValue=e.value,this.$emit("input",this.currentValue),this.$emit("update:value",this.currentValue))},methods:{shouldChangeOnFocus(){return!1}}},z={};var fe=R(de,ue,ce,!1,he,null,null,null);function he(e){for(let t in z)this[t]=z[t]}var _e=function(){return fe.exports}();_.SelectField=_e,Object.defineProperty(_,"__esModule",{value:!0}),_[Symbol.toStringTag]="Module"});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue-interface/select-field",
3
- "version": "0.11.1",
3
+ "version": "0.12.0",
4
4
  "description": "A Vue select field component.",
5
5
  "files": [
6
6
  "index.js",
@@ -39,8 +39,8 @@
39
39
  },
40
40
  "homepage": "https://github.com/vue-interface/select-field/docs#readme",
41
41
  "dependencies": {
42
- "@vue-interface/activity-indicator": "^1.0.3",
43
- "@vue-interface/form-control": "^0.11.5",
42
+ "@vue-interface/activity-indicator": "^1.0.0",
43
+ "@vue-interface/form-control": "^0.12.0",
44
44
  "vue": "^2.6.14"
45
45
  },
46
46
  "devDependencies": {