1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | 'use strict';
|
11 |
|
12 | import {ref} from 'vue';
|
13 | import Baraja from 'baraja-js';
|
14 | import 'baraja-js/dist/baraja.min.css';
|
15 |
|
16 |
|
17 |
|
18 |
|
19 | export default {
|
20 | setup() {
|
21 | const elRef = ref(null);
|
22 |
|
23 | return {elRef};
|
24 | },
|
25 |
|
26 | mounted() {
|
27 | this.baraja = new Baraja(
|
28 | this.$el,
|
29 | this.options
|
30 | );
|
31 | },
|
32 |
|
33 | data() {
|
34 | return {
|
35 | baraja: null
|
36 | };
|
37 | },
|
38 |
|
39 | watch: {
|
40 | fan(newVal, oldVal) {
|
41 | if (!Object.is(newVal, oldVal)) {
|
42 | this.baraja.fan(newVal);
|
43 | }
|
44 | },
|
45 | add(newVal, oldVal) {
|
46 | if (newVal !== oldVal) {
|
47 | this.baraja.add(newVal);
|
48 | }
|
49 | },
|
50 | close(newVal, oldVal) {
|
51 | if (newVal !== oldVal) {
|
52 | this.baraja.close();
|
53 | }
|
54 | },
|
55 | last(newVal, oldVal) {
|
56 | if (newVal !== oldVal) {
|
57 | this.baraja.last();
|
58 | }
|
59 | },
|
60 | next(newVal, oldVal) {
|
61 | if (newVal !== oldVal) {
|
62 | this.baraja.next();
|
63 | }
|
64 | }
|
65 | },
|
66 |
|
67 | props: {
|
68 | id: {
|
69 | default: 'baraja-js',
|
70 | type: String
|
71 | },
|
72 | options: {
|
73 | default: () => ({}),
|
74 | type: Object
|
75 | },
|
76 | fan: {
|
77 | default: () => ({}),
|
78 | type: Object
|
79 | },
|
80 | add: {
|
81 | default: '',
|
82 | type: String
|
83 | },
|
84 | close: {
|
85 | default: false,
|
86 | type: Boolean
|
87 | },
|
88 | last: {
|
89 | default: false,
|
90 | type: Boolean
|
91 | },
|
92 | next: {
|
93 | default: false,
|
94 | type: Boolean
|
95 | }
|
96 | },
|
97 |
|
98 | template: `
|
99 | <ul v-bind:id="id" class="baraja-container" ref="wrapper">
|
100 | <slot :child="this.$slots.default" />
|
101 | </ul>
|
102 | `
|
103 | };
|