@vue-interface/badge 1.1.0 → 2.0.0-beta.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/dist/badge.es.js CHANGED
@@ -1,87 +1,27 @@
1
- var Variant = {
1
+ import { openBlock as s, createBlock as o, resolveDynamicComponent as c, normalizeClass as f, withCtx as l, renderSlot as h } from "vue";
2
+ const p = {
2
3
  props: {
4
+ componentPrefix: String,
3
5
  variant: String,
4
- variantPrefix: {
5
- type: String,
6
- default() {
7
- return this.$options.name && this.$options.name.toLowerCase();
8
- }
9
- }
6
+ variantPrefix: String
10
7
  },
11
8
  computed: {
12
9
  variantClassPrefix() {
13
- return this.variantPrefix;
10
+ return this.variantPrefix || this.componentPrefix;
11
+ },
12
+ hasVariantPrefix() {
13
+ return this.variant && !!this.variant.match(
14
+ new RegExp(`^${this.variantClassPrefix}`)
15
+ );
14
16
  },
15
17
  variantClass() {
16
- if (!this.variant || !this.variantClassPrefix) {
17
- return "";
18
- }
19
- return `${this.variantClassPrefix}-${this.variant}`;
20
- }
21
- }
22
- };
23
- var render = function() {
24
- var _vm = this;
25
- var _h = _vm.$createElement;
26
- var _c = _vm._self._c || _h;
27
- return _c(_vm.component || _vm.type, { tag: "component", staticClass: "badge", class: _vm.classes, attrs: { "href": _vm.href, "to": _vm.to } }, [_vm._t("default")], 2);
28
- };
29
- var staticRenderFns = [];
30
- function normalizeComponent(scriptExports, render2, staticRenderFns2, functionalTemplate, injectStyles, scopeId, moduleIdentifier, shadowMode) {
31
- var options = typeof scriptExports === "function" ? scriptExports.options : scriptExports;
32
- if (render2) {
33
- options.render = render2;
34
- options.staticRenderFns = staticRenderFns2;
35
- options._compiled = true;
36
- }
37
- if (functionalTemplate) {
38
- options.functional = true;
39
- }
40
- if (scopeId) {
41
- options._scopeId = "data-v-" + scopeId;
42
- }
43
- var hook;
44
- if (moduleIdentifier) {
45
- hook = function(context) {
46
- context = context || this.$vnode && this.$vnode.ssrContext || this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext;
47
- if (!context && typeof __VUE_SSR_CONTEXT__ !== "undefined") {
48
- context = __VUE_SSR_CONTEXT__;
49
- }
50
- if (injectStyles) {
51
- injectStyles.call(this, context);
52
- }
53
- if (context && context._registeredComponents) {
54
- context._registeredComponents.add(moduleIdentifier);
55
- }
56
- };
57
- options._ssrRegister = hook;
58
- } else if (injectStyles) {
59
- hook = shadowMode ? function() {
60
- injectStyles.call(this, (options.functional ? this.parent : this).$root.$options.shadowRoot);
61
- } : injectStyles;
62
- }
63
- if (hook) {
64
- if (options.functional) {
65
- options._injectStyles = hook;
66
- var originalRender = options.render;
67
- options.render = function renderWithStyleInjection(h, context) {
68
- hook.call(context);
69
- return originalRender(h, context);
70
- };
71
- } else {
72
- var existing = options.beforeCreate;
73
- options.beforeCreate = existing ? [].concat(existing, hook) : [hook];
18
+ return this.variant ? !this.variantClassPrefix || this.hasVariantPrefix ? this.variant : `${this.variantClassPrefix}-${this.variant}` : "";
74
19
  }
75
20
  }
76
- return {
77
- exports: scriptExports,
78
- options
79
- };
80
- }
81
- const __vue2_script = {
21
+ }, u = {
82
22
  name: "Badge",
83
23
  mixins: [
84
- Variant
24
+ p
85
25
  ],
86
26
  props: {
87
27
  component: String,
@@ -94,35 +34,39 @@ const __vue2_script = {
94
34
  }
95
35
  },
96
36
  computed: {
37
+ classes() {
38
+ return [
39
+ "badge-pill",
40
+ "badge-secondary",
41
+ this.variantClass
42
+ ];
43
+ },
97
44
  type() {
98
- if (this.to) {
99
- return "router-link";
100
- }
101
- if (this.href) {
102
- return "a";
103
- }
104
- return "span";
45
+ return this.to ? "router-link" : this.href ? "a" : "span";
105
46
  },
106
47
  variantClass() {
107
48
  return `bg-${this.variant}`;
108
- },
109
- classes() {
110
- return {
111
- "badge-pill": this.pill,
112
- "badge-secondary": this.secondary,
113
- [this.variantClass]: !!this.variant
114
- };
115
49
  }
116
50
  }
51
+ }, v = (r, a) => {
52
+ const t = r.__vccOpts || r;
53
+ for (const [e, n] of a)
54
+ t[e] = n;
55
+ return t;
117
56
  };
118
- const __cssModules = {};
119
- var __component__ = /* @__PURE__ */ normalizeComponent(__vue2_script, render, staticRenderFns, false, __vue2_injectStyles, null, null, null);
120
- function __vue2_injectStyles(context) {
121
- for (let o in __cssModules) {
122
- this[o] = __cssModules[o];
123
- }
57
+ function m(r, a, t, e, n, i) {
58
+ return s(), o(c(t.component || i.type), {
59
+ href: t.href,
60
+ to: t.to,
61
+ class: f(["badge", i.classes])
62
+ }, {
63
+ default: l(() => [
64
+ h(r.$slots, "default")
65
+ ]),
66
+ _: 3
67
+ }, 8, ["href", "to", "class"]);
124
68
  }
125
- var Badge = /* @__PURE__ */ function() {
126
- return __component__.exports;
127
- }();
128
- export { Badge };
69
+ const g = /* @__PURE__ */ v(u, [["render", m]]);
70
+ export {
71
+ g as Badge
72
+ };
package/dist/badge.umd.js CHANGED
@@ -1 +1 @@
1
- (function(a,s){typeof exports=="object"&&typeof module!="undefined"?s(exports):typeof define=="function"&&define.amd?define(["exports"],s):(a=typeof globalThis!="undefined"?globalThis:a||self,s(a.Badge={}))})(this,function(a){"use strict";var s={props:{variant:String,variantPrefix:{type:String,default(){return this.$options.name&&this.$options.name.toLowerCase()}}},computed:{variantClassPrefix(){return this.variantPrefix},variantClass(){return!this.variant||!this.variantClassPrefix?"":`${this.variantClassPrefix}-${this.variant}`}}},h=function(){var e=this,i=e.$createElement,f=e._self._c||i;return f(e.component||e.type,{tag:"component",staticClass:"badge",class:e.classes,attrs:{href:e.href,to:e.to}},[e._t("default")],2)},v=[];function c(e,i,f,y,o,u,d,S){var t=typeof e=="function"?e.options:e;i&&(t.render=i,t.staticRenderFns=f,t._compiled=!0),y&&(t.functional=!0),u&&(t._scopeId="data-v-"+u);var r;if(d?(r=function(n){n=n||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,!n&&typeof __VUE_SSR_CONTEXT__!="undefined"&&(n=__VUE_SSR_CONTEXT__),o&&o.call(this,n),n&&n._registeredComponents&&n._registeredComponents.add(d)},t._ssrRegister=r):o&&(r=S?function(){o.call(this,(t.functional?this.parent:this).$root.$options.shadowRoot)}:o),r)if(t.functional){t._injectStyles=r;var b=t.render;t.render=function(T,_){return r.call(_),b(T,_)}}else{var p=t.beforeCreate;t.beforeCreate=p?[].concat(p,r):[r]}return{exports:e,options:t}}const m={name:"Badge",mixins:[s],props:{component:String,href:String,pill:Boolean,to:[Object,String],variant:{type:String,default:"primary"}},computed:{type(){return this.to?"router-link":this.href?"a":"span"},variantClass(){return`bg-${this.variant}`},classes(){return{"badge-pill":this.pill,"badge-secondary":this.secondary,[this.variantClass]:!!this.variant}}}},l={};var g=c(m,h,v,!1,C,null,null,null);function C(e){for(let i in l)this[i]=l[i]}var $=function(){return g.exports}();a.Badge=$,Object.defineProperties(a,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
1
+ (function(e,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(e=typeof globalThis<"u"?globalThis:e||self,t(e.Badge={},e.Vue))})(this,function(e,t){"use strict";const f={name:"Badge",mixins:[{props:{componentPrefix:String,variant:String,variantPrefix:String},computed:{variantClassPrefix(){return this.variantPrefix||this.componentPrefix},hasVariantPrefix(){return this.variant&&!!this.variant.match(new RegExp(`^${this.variantClassPrefix}`))},variantClass(){return this.variant?!this.variantClassPrefix||this.hasVariantPrefix?this.variant:`${this.variantClassPrefix}-${this.variant}`:""}}}],props:{component:String,href:String,pill:Boolean,to:[Object,String],variant:{type:String,default:"primary"}},computed:{classes(){return["badge-pill","badge-secondary",this.variantClass]},type(){return this.to?"router-link":this.href?"a":"span"},variantClass(){return`bg-${this.variant}`}}},c=(n,i)=>{const r=n.__vccOpts||n;for(const[a,s]of i)r[a]=s;return r};function l(n,i,r,a,s,o){return t.openBlock(),t.createBlock(t.resolveDynamicComponent(r.component||o.type),{href:r.href,to:r.to,class:t.normalizeClass(["badge",o.classes])},{default:t.withCtx(()=>[t.renderSlot(n.$slots,"default")]),_:3},8,["href","to","class"])}const u=c(f,[["render",l]]);e.Badge=u,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue-interface/badge",
3
- "version": "1.1.0",
3
+ "version": "2.0.0-beta.0",
4
4
  "description": "A Vue badge component.",
5
5
  "files": [
6
6
  "index.js",
@@ -37,24 +37,26 @@
37
37
  "bugs": {
38
38
  "url": "https://github.com/vue-interface/badge/issues"
39
39
  },
40
- "homepage": "https://github.com/vue-interface/badge/docs#readme",
40
+ "homepage": "https://github.com/vue-interface/badge",
41
41
  "dependencies": {
42
- "@vue-interface/variant": "^1.3.0",
43
- "vue": "^2.6.14"
42
+ "@vue-interface/variant": "^2.0.0-beta.0"
43
+ },
44
+ "peerDependencies": {
45
+ "vue": "^3.0.0"
44
46
  },
45
47
  "devDependencies": {
46
- "@rollup/plugin-babel": "^5.3.0",
47
- "autoprefixer": "^10.4.2",
48
+ "@rollup/plugin-babel": "^6.0.0",
49
+ "@vitejs/plugin-vue": "^3.0.3",
50
+ "autoprefixer": "^10.4.8",
48
51
  "babel-eslint": "^10.1.0",
49
52
  "babel-preset-vue": "^2.0.2",
50
53
  "change-case": "^4.1.2",
51
- "eslint": "^6.7.2",
52
- "eslint-plugin-vue": "^6.2.2",
54
+ "eslint": "^8.22.0",
55
+ "eslint-plugin-vue": "^9.4.0",
53
56
  "pascalcase": "^2.0.0",
54
- "postcss": "^8.4.6",
55
- "tailwindcss": "^3.0.0",
56
- "vite": "^2.7.2",
57
- "vite-plugin-vue2": "^1.9.3",
58
- "vue-router": "^3.5.3"
57
+ "postcss": "^8.4.16",
58
+ "tailwindcss": "^3.1.8",
59
+ "vite": "^3.0.9",
60
+ "vue": "^3.2.37"
59
61
  }
60
62
  }
package/src/Badge.vue CHANGED
@@ -9,7 +9,7 @@
9
9
  </component>
10
10
  </template>
11
11
 
12
- <script>
12
+ <script lang="ts">
13
13
  import { Variant } from '@vue-interface/variant';
14
14
 
15
15
  export default {
@@ -63,6 +63,19 @@ export default {
63
63
 
64
64
  computed: {
65
65
 
66
+ /**
67
+ * Get the button classes.
68
+ *
69
+ * @property {string}
70
+ */
71
+ classes(): Array<string> {
72
+ return [
73
+ 'badge-pill',
74
+ 'badge-secondary',
75
+ this.variantClass
76
+ ];
77
+ },
78
+
66
79
  type() {
67
80
  if(this.to) {
68
81
  return 'router-link';
@@ -78,14 +91,6 @@ export default {
78
91
  variantClass() {
79
92
  return `bg-${this.variant}`;
80
93
  },
81
-
82
- classes() {
83
- return {
84
- 'badge-pill': this.pill,
85
- 'badge-secondary': this.secondary,
86
- [this.variantClass]: !!this.variant,
87
- };
88
- }
89
94
  }
90
95
  };
91
96
  </script>