vue-toggles 1.1.4 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,417 +0,0 @@
1
- //
2
- //
3
- //
4
- //
5
- //
6
- //
7
- //
8
- //
9
- //
10
- //
11
- //
12
- //
13
- //
14
- //
15
- //
16
- //
17
- //
18
- //
19
- //
20
- //
21
- //
22
- //
23
- //
24
- //
25
-
26
- var script = {
27
- name: 'VueToggles',
28
- props: {
29
- value: {
30
- type: Boolean,
31
- default: false,
32
- },
33
- disabled: {
34
- type: Boolean,
35
- default: false,
36
- },
37
- reverse: {
38
- type: Boolean,
39
- default: false,
40
- },
41
- checkedText: {
42
- type: String,
43
- default: null,
44
- },
45
- uncheckedText: {
46
- type: String,
47
- default: null,
48
- },
49
- width: {
50
- type: [Number, String],
51
- default: 75,
52
- },
53
- height: {
54
- type: [Number, String],
55
- default: 25,
56
- },
57
- uncheckedBg: {
58
- type: String,
59
- default: '#939393',
60
- },
61
- checkedBg: {
62
- type: String,
63
- default: '#5850ec',
64
- },
65
- dotColor: {
66
- type: String,
67
- default: '#fff',
68
- },
69
- fontSize: {
70
- type: [Number, String],
71
- default: '12',
72
- },
73
- checkedColor: {
74
- type: String,
75
- default: '#fff',
76
- },
77
- uncheckedColor: {
78
- type: String,
79
- default: '#fff',
80
- },
81
- fontWeight: {
82
- type: [Number, String],
83
- default: 'normal',
84
- },
85
- },
86
- computed: {
87
- bgStyle: function bgStyle() {
88
- var styles = {
89
- width: ((this.width) + "px"),
90
- height: ((this.height) + "px"),
91
- background: this.value ? this.checkedBg : this.uncheckedBg,
92
- opacity: this.disabled ? '0.5' : '1',
93
- cursor: !this.disabled ? 'pointer' : 'not-allowed',
94
- };
95
-
96
- return styles;
97
- },
98
- dotStyle: function dotStyle() {
99
- var styles = {
100
- background: this.dotColor,
101
- width: ((this.height - 8) + "px"),
102
- height: ((this.height - 8) + "px"),
103
- 'min-width': ((this.height - 8) + "px"),
104
- 'min-height': ((this.height - 8) + "px"),
105
- 'margin-left': this.value ? ((this.width - (this.height - 3)) + "px") : '5px',
106
- };
107
-
108
- if ((!this.value && this.reverse) || (this.value && !this.reverse)) {
109
- styles.marginLeft = (this.width - (this.height - 3)) + "px";
110
- } else if ((this.value && this.reverse) || (!this.value && !this.reverse)) {
111
- styles.marginLeft = '5px';
112
- }
113
-
114
- return styles;
115
- },
116
- textStyle: function textStyle() {
117
- var styles = {
118
- 'font-weight': this.fontWeight,
119
- 'font-size': ((this.fontSize) + "px"),
120
- color: this.value && !this.disabled ? this.checkedColor : this.uncheckedColor,
121
- right: this.value ? ((this.height - 3) + "px") : 'auto',
122
- left: this.value ? 'auto' : ((this.height - 3) + "px"),
123
- };
124
-
125
- if (!this.value && this.reverse) {
126
- styles.right = (this.height - 3) + "px";
127
- styles.left = 'auto';
128
- } else if (this.value && this.reverse) {
129
- styles.left = (this.height - 3) + "px";
130
- styles.right = 'auto';
131
- }
132
-
133
- return styles;
134
- },
135
- },
136
- };
137
-
138
- function normalizeComponent(template, style, script, scopeId, isFunctionalTemplate, moduleIdentifier /* server only */, shadowMode, createInjector, createInjectorSSR, createInjectorShadow) {
139
- if (typeof shadowMode !== 'boolean') {
140
- createInjectorSSR = createInjector;
141
- createInjector = shadowMode;
142
- shadowMode = false;
143
- }
144
- // Vue.extend constructor export interop.
145
- var options = typeof script === 'function' ? script.options : script;
146
- // render functions
147
- if (template && template.render) {
148
- options.render = template.render;
149
- options.staticRenderFns = template.staticRenderFns;
150
- options._compiled = true;
151
- // functional template
152
- if (isFunctionalTemplate) {
153
- options.functional = true;
154
- }
155
- }
156
- // scopedId
157
- if (scopeId) {
158
- options._scopeId = scopeId;
159
- }
160
- var hook;
161
- if (moduleIdentifier) {
162
- // server build
163
- hook = function (context) {
164
- // 2.3 injection
165
- context =
166
- context || // cached call
167
- (this.$vnode && this.$vnode.ssrContext) || // stateful
168
- (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext); // functional
169
- // 2.2 with runInNewContext: true
170
- if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
171
- context = __VUE_SSR_CONTEXT__;
172
- }
173
- // inject component styles
174
- if (style) {
175
- style.call(this, createInjectorSSR(context));
176
- }
177
- // register component module identifier for async chunk inference
178
- if (context && context._registeredComponents) {
179
- context._registeredComponents.add(moduleIdentifier);
180
- }
181
- };
182
- // used by ssr in case component is cached and beforeCreate
183
- // never gets called
184
- options._ssrRegister = hook;
185
- }
186
- else if (style) {
187
- hook = shadowMode
188
- ? function (context) {
189
- style.call(this, createInjectorShadow(context, this.$root.$options.shadowRoot));
190
- }
191
- : function (context) {
192
- style.call(this, createInjector(context));
193
- };
194
- }
195
- if (hook) {
196
- if (options.functional) {
197
- // register for functional component in vue file
198
- var originalRender = options.render;
199
- options.render = function renderWithStyleInjection(h, context) {
200
- hook.call(context);
201
- return originalRender(h, context);
202
- };
203
- }
204
- else {
205
- // inject component registration as beforeCreate hook
206
- var existing = options.beforeCreate;
207
- options.beforeCreate = existing ? [].concat(existing, hook) : [hook];
208
- }
209
- }
210
- return script;
211
- }
212
-
213
- var isOldIE = typeof navigator !== 'undefined' &&
214
- /msie [6-9]\\b/.test(navigator.userAgent.toLowerCase());
215
- function createInjector(context) {
216
- return function (id, style) { return addStyle(id, style); };
217
- }
218
- var HEAD;
219
- var styles = {};
220
- function addStyle(id, css) {
221
- var group = isOldIE ? css.media || 'default' : id;
222
- var style = styles[group] || (styles[group] = { ids: new Set(), styles: [] });
223
- if (!style.ids.has(id)) {
224
- style.ids.add(id);
225
- var code = css.source;
226
- if (css.map) {
227
- // https://developer.chrome.com/devtools/docs/javascript-debugging
228
- // this makes source maps inside style tags work properly in Chrome
229
- code += '\n/*# sourceURL=' + css.map.sources[0] + ' */';
230
- // http://stackoverflow.com/a/26603875
231
- code +=
232
- '\n/*# sourceMappingURL=data:application/json;base64,' +
233
- btoa(unescape(encodeURIComponent(JSON.stringify(css.map)))) +
234
- ' */';
235
- }
236
- if (!style.element) {
237
- style.element = document.createElement('style');
238
- style.element.type = 'text/css';
239
- if (css.media)
240
- { style.element.setAttribute('media', css.media); }
241
- if (HEAD === undefined) {
242
- HEAD = document.head || document.getElementsByTagName('head')[0];
243
- }
244
- HEAD.appendChild(style.element);
245
- }
246
- if ('styleSheet' in style.element) {
247
- style.styles.push(code);
248
- style.element.styleSheet.cssText = style.styles
249
- .filter(Boolean)
250
- .join('\n');
251
- }
252
- else {
253
- var index = style.ids.size - 1;
254
- var textNode = document.createTextNode(code);
255
- var nodes = style.element.childNodes;
256
- if (nodes[index])
257
- { style.element.removeChild(nodes[index]); }
258
- if (nodes.length)
259
- { style.element.insertBefore(textNode, nodes[index]); }
260
- else
261
- { style.element.appendChild(textNode); }
262
- }
263
- }
264
- }
265
-
266
- /* script */
267
- var __vue_script__ = script;
268
-
269
- /* template */
270
- var __vue_render__ = function() {
271
- var _vm = this;
272
- var _h = _vm.$createElement;
273
- var _c = _vm._self._c || _h;
274
- return _c(
275
- "span",
276
- {
277
- staticClass: "vue-toggles",
278
- style: _vm.bgStyle,
279
- attrs: {
280
- role: "switch",
281
- tabindex: "0",
282
- "aria-checked": _vm.value ? "true" : "false",
283
- "aria-readonly": _vm.disabled ? "true" : "false"
284
- },
285
- on: {
286
- click: function($event) {
287
- !_vm.disabled ? _vm.$emit("click", _vm.value) : null;
288
- },
289
- keyup: [
290
- function($event) {
291
- if (
292
- !$event.type.indexOf("key") &&
293
- _vm._k($event.keyCode, "enter", 13, $event.key, "Enter")
294
- ) {
295
- return null
296
- }
297
- $event.preventDefault();
298
- !_vm.disabled ? _vm.$emit("click", _vm.value) : null;
299
- },
300
- function($event) {
301
- if (
302
- !$event.type.indexOf("key") &&
303
- _vm._k($event.keyCode, "space", 32, $event.key, [" ", "Spacebar"])
304
- ) {
305
- return null
306
- }
307
- $event.preventDefault();
308
- !_vm.disabled ? _vm.$emit("click", _vm.value) : null;
309
- }
310
- ]
311
- }
312
- },
313
- [
314
- _c(
315
- "span",
316
- {
317
- staticClass: "dot",
318
- style: _vm.dotStyle,
319
- attrs: { "aria-hidden": "true" }
320
- },
321
- [
322
- _c(
323
- "span",
324
- {
325
- directives: [
326
- {
327
- name: "show",
328
- rawName: "v-show",
329
- value: _vm.checkedText && _vm.value,
330
- expression: "checkedText && value"
331
- }
332
- ],
333
- staticClass: "text",
334
- style: _vm.textStyle
335
- },
336
- [_vm._v("\n " + _vm._s(_vm.checkedText) + "\n ")]
337
- ),
338
- _vm._v(" "),
339
- _c(
340
- "span",
341
- {
342
- directives: [
343
- {
344
- name: "show",
345
- rawName: "v-show",
346
- value: _vm.uncheckedText && !_vm.value,
347
- expression: "uncheckedText && !value"
348
- }
349
- ],
350
- staticClass: "text",
351
- style: _vm.textStyle
352
- },
353
- [_vm._v("\n " + _vm._s(_vm.uncheckedText) + "\n ")]
354
- )
355
- ]
356
- )
357
- ]
358
- )
359
- };
360
- var __vue_staticRenderFns__ = [];
361
- __vue_render__._withStripped = true;
362
-
363
- /* style */
364
- var __vue_inject_styles__ = function (inject) {
365
- if (!inject) { return }
366
- inject("data-v-ce3b9412_0", { source: "\n.vue-toggles {\r\n display: flex;\r\n align-items: center;\r\n border-radius: 9999px;\r\n overflow: hidden;\r\n transition: background-color ease 0.2s, width ease 0.2s, height ease 0.2s;\n}\n.vue-toggles .dot {\r\n position: relative;\r\n display: flex;\r\n align-items: center;\r\n border-radius: 9999px;\r\n box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);\r\n transition: margin ease 0.2s;\n}\n.vue-toggles .text {\r\n position: absolute;\r\n font-family: inherit;\r\n user-select: none;\r\n white-space: nowrap;\n}\n@media all and (-ms-high-contrast: none) {\n.vue-toggles .text {\r\n /* IE11 fix */\r\n top: 50%;\r\n transform: translateY(-50%);\n}\n}\n@media (prefers-reduced-motion) {\r\n /* disable animations if user have a reduced motion setting */\n.vue-toggles,\r\n .vue-toggles *,\r\n .vue-toggles *::before,\r\n .vue-toggles *::after {\r\n animation: none !important;\r\n transition: none !important;\r\n transition-duration: none !important;\n}\n}\r\n", map: {"version":3,"sources":["D:\\Folder\\codetemp\\vue-toggles\\src\\VueToggles.vue"],"names":[],"mappings":";AA2IA;EACA,aAAA;EACA,mBAAA;EACA,qBAAA;EACA,gBAAA;EACA,yEAAA;AACA;AAEA;EACA,kBAAA;EACA,aAAA;EACA,mBAAA;EACA,qBAAA;EACA,2EAAA;EACA,4BAAA;AACA;AAEA;EACA,kBAAA;EACA,oBAAA;EACA,iBAAA;EACA,mBAAA;AACA;AAEA;AACA;IACA,aAAA;IACA,QAAA;IACA,2BAAA;AACA;AACA;AAEA;EACA,6DAAA;AACA;;;;IAIA,0BAAA;IACA,2BAAA;IACA,oCAAA;AACA;AACA","file":"VueToggles.vue","sourcesContent":["<template>\r\n <span\r\n class=\"vue-toggles\"\r\n :style=\"bgStyle\"\r\n role=\"switch\"\r\n tabindex=\"0\"\r\n :aria-checked=\"value ? 'true' : 'false'\"\r\n :aria-readonly=\"disabled ? 'true' : 'false'\"\r\n @click=\"!disabled ? $emit('click', value) : null\"\r\n @keyup.enter.prevent=\"!disabled ? $emit('click', value) : null\"\r\n @keyup.space.prevent=\"!disabled ? $emit('click', value) : null\"\r\n >\r\n <span aria-hidden=\"true\" :style=\"dotStyle\" class=\"dot\">\r\n <span v-show=\"checkedText && value\" :style=\"textStyle\" class=\"text\">\r\n {{ checkedText }}\r\n </span>\r\n\r\n <span v-show=\"uncheckedText && !value\" :style=\"textStyle\" class=\"text\">\r\n {{ uncheckedText }}\r\n </span>\r\n </span>\r\n </span>\r\n</template>\r\n\r\n<script>\r\nexport default {\r\n name: 'VueToggles',\r\n props: {\r\n value: {\r\n type: Boolean,\r\n default: false,\r\n },\r\n disabled: {\r\n type: Boolean,\r\n default: false,\r\n },\r\n reverse: {\r\n type: Boolean,\r\n default: false,\r\n },\r\n checkedText: {\r\n type: String,\r\n default: null,\r\n },\r\n uncheckedText: {\r\n type: String,\r\n default: null,\r\n },\r\n width: {\r\n type: [Number, String],\r\n default: 75,\r\n },\r\n height: {\r\n type: [Number, String],\r\n default: 25,\r\n },\r\n uncheckedBg: {\r\n type: String,\r\n default: '#939393',\r\n },\r\n checkedBg: {\r\n type: String,\r\n default: '#5850ec',\r\n },\r\n dotColor: {\r\n type: String,\r\n default: '#fff',\r\n },\r\n fontSize: {\r\n type: [Number, String],\r\n default: '12',\r\n },\r\n checkedColor: {\r\n type: String,\r\n default: '#fff',\r\n },\r\n uncheckedColor: {\r\n type: String,\r\n default: '#fff',\r\n },\r\n fontWeight: {\r\n type: [Number, String],\r\n default: 'normal',\r\n },\r\n },\r\n computed: {\r\n bgStyle() {\r\n const styles = {\r\n width: `${this.width}px`,\r\n height: `${this.height}px`,\r\n background: this.value ? this.checkedBg : this.uncheckedBg,\r\n opacity: this.disabled ? '0.5' : '1',\r\n cursor: !this.disabled ? 'pointer' : 'not-allowed',\r\n };\r\n\r\n return styles;\r\n },\r\n dotStyle() {\r\n const styles = {\r\n background: this.dotColor,\r\n width: `${this.height - 8}px`,\r\n height: `${this.height - 8}px`,\r\n 'min-width': `${this.height - 8}px`,\r\n 'min-height': `${this.height - 8}px`,\r\n 'margin-left': this.value ? `${this.width - (this.height - 3)}px` : '5px',\r\n };\r\n\r\n if ((!this.value && this.reverse) || (this.value && !this.reverse)) {\r\n styles.marginLeft = `${this.width - (this.height - 3)}px`;\r\n } else if ((this.value && this.reverse) || (!this.value && !this.reverse)) {\r\n styles.marginLeft = '5px';\r\n }\r\n\r\n return styles;\r\n },\r\n textStyle() {\r\n const styles = {\r\n 'font-weight': this.fontWeight,\r\n 'font-size': `${this.fontSize}px`,\r\n color: this.value && !this.disabled ? this.checkedColor : this.uncheckedColor,\r\n right: this.value ? `${this.height - 3}px` : 'auto',\r\n left: this.value ? 'auto' : `${this.height - 3}px`,\r\n };\r\n\r\n if (!this.value && this.reverse) {\r\n styles.right = `${this.height - 3}px`;\r\n styles.left = 'auto';\r\n } else if (this.value && this.reverse) {\r\n styles.left = `${this.height - 3}px`;\r\n styles.right = 'auto';\r\n }\r\n\r\n return styles;\r\n },\r\n },\r\n};\r\n</script>\r\n\r\n<style>\r\n.vue-toggles {\r\n display: flex;\r\n align-items: center;\r\n border-radius: 9999px;\r\n overflow: hidden;\r\n transition: background-color ease 0.2s, width ease 0.2s, height ease 0.2s;\r\n}\r\n\r\n.vue-toggles .dot {\r\n position: relative;\r\n display: flex;\r\n align-items: center;\r\n border-radius: 9999px;\r\n box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);\r\n transition: margin ease 0.2s;\r\n}\r\n\r\n.vue-toggles .text {\r\n position: absolute;\r\n font-family: inherit;\r\n user-select: none;\r\n white-space: nowrap;\r\n}\r\n\r\n@media all and (-ms-high-contrast: none) {\r\n .vue-toggles .text {\r\n /* IE11 fix */\r\n top: 50%;\r\n transform: translateY(-50%);\r\n }\r\n}\r\n\r\n@media (prefers-reduced-motion) {\r\n /* disable animations if user have a reduced motion setting */\r\n .vue-toggles,\r\n .vue-toggles *,\r\n .vue-toggles *::before,\r\n .vue-toggles *::after {\r\n animation: none !important;\r\n transition: none !important;\r\n transition-duration: none !important;\r\n }\r\n}\r\n</style>\r\n"]}, media: undefined });
367
-
368
- };
369
- /* scoped */
370
- var __vue_scope_id__ = undefined;
371
- /* module identifier */
372
- var __vue_module_identifier__ = undefined;
373
- /* functional template */
374
- var __vue_is_functional_template__ = false;
375
- /* style inject SSR */
376
-
377
- /* style inject shadow dom */
378
-
379
-
380
-
381
- var __vue_component__ = /*#__PURE__*/normalizeComponent(
382
- { render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
383
- __vue_inject_styles__,
384
- __vue_script__,
385
- __vue_scope_id__,
386
- __vue_is_functional_template__,
387
- __vue_module_identifier__,
388
- false,
389
- createInjector,
390
- undefined,
391
- undefined
392
- );
393
-
394
- // Declare install function executed by Vue.use()
395
- function install(Vue) {
396
- if (install.installed) { return; }
397
- install.installed = true;
398
- Vue.component('VueToggles', __vue_component__);
399
- }
400
-
401
- // Create module definition for Vue.use()
402
- var plugin = {
403
- install: install,
404
- };
405
-
406
- // Auto-install when vue is found (eg. in browser via <script> tag)
407
- var GlobalVue = null;
408
- if (typeof window !== 'undefined') {
409
- GlobalVue = window.Vue;
410
- } else if (typeof global !== 'undefined') {
411
- GlobalVue = global.Vue;
412
- }
413
- if (GlobalVue) {
414
- GlobalVue.use(plugin);
415
- }
416
-
417
- export { __vue_component__ as default, install };
@@ -1,40 +0,0 @@
1
-
2
- .vue-toggles {
3
- display: flex;
4
- align-items: center;
5
- border-radius: 9999px;
6
- overflow: hidden;
7
- transition: background-color ease 0.2s, width ease 0.2s, height ease 0.2s;
8
- }
9
- .vue-toggles .dot {
10
- position: relative;
11
- display: flex;
12
- align-items: center;
13
- border-radius: 9999px;
14
- box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
15
- transition: margin ease 0.2s;
16
- }
17
- .vue-toggles .text {
18
- position: absolute;
19
- font-family: inherit;
20
- user-select: none;
21
- white-space: nowrap;
22
- }
23
- @media all and (-ms-high-contrast: none) {
24
- .vue-toggles .text {
25
- /* IE11 fix */
26
- top: 50%;
27
- transform: translateY(-50%);
28
- }
29
- }
30
- @media (prefers-reduced-motion) {
31
- /* disable animations if user have a reduced motion setting */
32
- .vue-toggles,
33
- .vue-toggles *,
34
- .vue-toggles *::before,
35
- .vue-toggles *::after {
36
- animation: none !important;
37
- transition: none !important;
38
- transition-duration: none !important;
39
- }
40
- }