@tak-ps/vue-tabler 3.78.2 → 3.79.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.
@@ -28,42 +28,30 @@
28
28
  </Modal>
29
29
  </template>
30
30
 
31
- <script>
32
- import Modal from './Modal.vue';
33
- import Alert from './Alert.vue';
31
+ <script setup>
32
+ import Modal from './Modal.vue'
33
+ import Alert from './Alert.vue'
34
34
 
35
- export default {
36
- name: 'TablerErr',
37
- components: {
38
- Alert,
39
- Modal
35
+ defineProps({
36
+ err: {
37
+ type: Error,
38
+ required: true
40
39
  },
41
- props: {
42
- err: {
43
- type: Error,
44
- required: true
45
- },
46
- title: {
47
- type: String,
48
- default: 'Website Error'
49
- },
50
- trace: {
51
- type: Boolean,
52
- default: true
53
- }
40
+ title: {
41
+ type: String,
42
+ default: 'Website Error'
54
43
  },
55
- emits: [
56
- 'close'
57
- ],
58
- data: function() {
59
- return {
60
- open: false
61
- }
62
- },
63
- methods: {
64
- close: function() {
65
- this.$emit('close');
66
- },
44
+ trace: {
45
+ type: Boolean,
46
+ default: true
67
47
  }
48
+ })
49
+
50
+ const emit = defineEmits([
51
+ 'close'
52
+ ])
53
+
54
+ const close = () => {
55
+ emit('close')
68
56
  }
69
57
  </script>
@@ -34,32 +34,25 @@
34
34
  </Modal>
35
35
  </template>
36
36
 
37
- <script>
38
- import Modal from './Modal.vue';
37
+ <script setup>
38
+ import Modal from './Modal.vue'
39
39
 
40
- export default {
41
- name: 'TablerHelp',
42
- components: {
43
- Modal,
40
+ defineProps({
41
+ label: {
42
+ type: String,
43
+ default: 'Help'
44
44
  },
45
- props: {
46
- label: {
47
- type: String,
48
- require: false,
49
- default: 'Help'
50
- },
51
- description: {
52
- type: String,
53
- require: true
54
- }
55
- },
56
- emits: [
57
- 'close'
58
- ],
59
- methods: {
60
- close: function() {
61
- this.$emit('close');
62
- }
45
+ description: {
46
+ type: String,
47
+ required: true
63
48
  }
49
+ })
50
+
51
+ const emit = defineEmits([
52
+ 'close'
53
+ ])
54
+
55
+ const close = () => {
56
+ emit('close')
64
57
  }
65
58
  </script>
@@ -65,83 +65,76 @@
65
65
  </div>
66
66
  </template>
67
67
 
68
- <script>
68
+ <script setup>
69
+ import { ref, computed, watch, onMounted } from 'vue'
69
70
  import TablerInput from './input/Input.vue';
70
71
  import {
71
72
  IconSettings
72
73
  } from '@tabler/icons-vue';
73
74
 
74
- export default {
75
- name: 'TablerList',
76
- components: {
77
- IconSettings,
78
- TablerInput
75
+ const props = defineProps({
76
+ url: String,
77
+ listkey: String,
78
+ namekey: String,
79
+ initial: Object,
80
+ label: {
81
+ type: String,
82
+ default: ''
79
83
  },
80
- props: {
81
- url: String,
82
- listkey: String,
83
- namekey: String,
84
- initial: Object,
85
- label: {
86
- type: String,
87
- default: ''
88
- },
89
- required: {
90
- type: Boolean,
91
- default: false
92
- },
93
- disabled: {
94
- type: Boolean,
95
- default: false
96
- },
97
- limit: {
98
- type: Number,
99
- default: 10
100
- },
84
+ required: {
85
+ type: Boolean,
86
+ default: false
101
87
  },
102
- emits: [
103
- 'selected'
104
- ],
105
- data: function() {
106
- return {
107
- ele: null,
108
- isMounted: false,
109
- filter: '',
110
- list: {}
111
- }
88
+ disabled: {
89
+ type: Boolean,
90
+ default: false
112
91
  },
113
- computed: {
114
- buttonHeight() {
115
- if(!this.isMounted) return 100;
116
- const buttonDOM = this.$refs.button
117
- return buttonDOM ? buttonDOM.offsetWidth : 100;
118
- },
92
+ limit: {
93
+ type: Number,
94
+ default: 10
119
95
  },
120
- watch: {
121
- ele: function() {
122
- this.filter = '';
123
- },
124
- filter: async function() {
125
- await this.fetchList();
126
- }
127
- },
128
- mounted: async function() {
129
- if (this.initial && this.initial[this.namekey]) this.ele = this.initial;
130
- await this.fetchList();
131
- this.isMounted = true;
132
- },
133
- methods: {
134
- select: function(ele) {
135
- this.ele = ele;
136
- this.filter = ele[this.namekey];
137
- this.$emit("selected", ele)
138
- },
139
- fetchList: async function() {
140
- const url = window.stdurl(this.url);
141
- url.searchParams.append('filter', this.filter);
142
- url.searchParams.append('limit', this.limit);
143
- this.list = await window.std(url);
144
- }
145
- }
96
+ })
97
+
98
+ const emit = defineEmits(['selected'])
99
+
100
+ const ele = ref(null)
101
+ const isMounted = ref(false)
102
+ const filter = ref('')
103
+ const list = ref({})
104
+ const button = ref(null)
105
+
106
+ const buttonHeight = computed(() => {
107
+ if(!isMounted.value) return 100;
108
+ const buttonDOM = button.value
109
+ return buttonDOM ? buttonDOM.offsetWidth : 100;
110
+ })
111
+
112
+ const select = (selectedEle) => {
113
+ ele.value = selectedEle;
114
+ filter.value = selectedEle[props.namekey];
115
+ emit("selected", selectedEle)
146
116
  }
117
+
118
+ const fetchList = async () => {
119
+ const url = window.stdurl(props.url);
120
+ url.searchParams.append('filter', filter.value);
121
+ url.searchParams.append('limit', props.limit);
122
+ list.value = await window.std(url);
123
+ }
124
+
125
+ // Watchers
126
+ watch(ele, () => {
127
+ filter.value = '';
128
+ })
129
+
130
+ watch(filter, async () => {
131
+ await fetchList();
132
+ })
133
+
134
+ // Mounted lifecycle
135
+ onMounted(async () => {
136
+ if (props.initial && props.initial[props.namekey]) ele.value = props.initial;
137
+ await fetchList();
138
+ isMounted.value = true;
139
+ })
147
140
  </script>
@@ -38,18 +38,15 @@
38
38
  </div>
39
39
  </template>
40
40
 
41
- <script>
42
- export default {
43
- name: 'TablerLoading',
44
- props: {
45
- inline: {
46
- type: Boolean,
47
- default: false
48
- },
49
- desc: {
50
- type: String,
51
- default: 'Loading...'
52
- }
41
+ <script setup>
42
+ defineProps({
43
+ inline: {
44
+ type: Boolean,
45
+ default: false
46
+ },
47
+ desc: {
48
+ type: String,
49
+ default: 'Loading...'
53
50
  }
54
- }
51
+ })
55
52
  </script>
@@ -5,30 +5,27 @@
5
5
  />
6
6
  </template>
7
7
 
8
- <script>
9
- import showdown from 'showdown';
8
+ <script setup>
9
+ import { computed } from 'vue'
10
+ import showdown from 'showdown'
10
11
 
11
- export default {
12
- name: 'TablerMarkdown',
13
- props: {
14
- markdown: {
15
- type: String,
16
- required: true
17
- },
18
- autowrap: {
19
- type: Boolean,
20
- default: true
21
- }
12
+ const props = defineProps({
13
+ markdown: {
14
+ type: String,
15
+ required: true
22
16
  },
23
- computed: {
24
- html: function() {
25
- const converter = new showdown.Converter({
26
- tables: true,
27
- tasklists: true,
28
- emoji: true
29
- });
30
- return converter.makeHtml(this.markdown);
31
- }
17
+ autowrap: {
18
+ type: Boolean,
19
+ default: true
32
20
  }
33
- }
21
+ })
22
+
23
+ const html = computed(() => {
24
+ const converter = new showdown.Converter({
25
+ tables: true,
26
+ tasklists: true,
27
+ emoji: true
28
+ })
29
+ return converter.makeHtml(props.markdown)
30
+ })
34
31
  </script>
@@ -26,20 +26,22 @@
26
26
  </teleport>
27
27
  </template>
28
28
 
29
- <script>
30
- export default {
31
- name: 'TablerModal',
32
- props: {
33
- size: {
34
- // sm, md, lg, xl
35
- type: String,
36
- default: 'sm'
37
- }
38
- },
39
- mounted: function() {
40
- this.$nextTick(() => {
41
- this.$refs.modal.focus();
42
- })
29
+ <script setup>
30
+ import { ref, onMounted, nextTick } from 'vue'
31
+
32
+ defineProps({
33
+ size: {
34
+ // sm, md, lg, xl
35
+ type: String,
36
+ default: 'sm'
43
37
  }
44
- }
38
+ })
39
+
40
+ const modal = ref(null)
41
+
42
+ onMounted(() => {
43
+ nextTick(() => {
44
+ modal.value.focus()
45
+ })
46
+ })
45
47
  </script>
@@ -35,7 +35,7 @@
35
35
  :class='{
36
36
  "my-4": !compact
37
37
  }'
38
- @click='$emit("create")'
38
+ @click='emit("create")'
39
39
  >
40
40
  <div class='btn btn-primary'>
41
41
  <span>Create <span v-text='label' /></span>
@@ -44,32 +44,27 @@
44
44
  </div>
45
45
  </template>
46
46
 
47
- <script>
47
+ <script setup>
48
48
  import {
49
49
  IconNotesOff
50
50
  } from '@tabler/icons-vue'
51
51
 
52
- export default {
53
- name: 'TablerNone',
54
- components: {
55
- IconNotesOff
52
+ defineProps({
53
+ label: {
54
+ type: String,
55
+ default: 'Items'
56
56
  },
57
- props: {
58
- label: {
59
- type: String,
60
- default: 'Items'
61
- },
62
- compact: {
63
- type: Boolean,
64
- default: false
65
- },
66
- create: {
67
- type: Boolean,
68
- default: true
69
- },
57
+ compact: {
58
+ type: Boolean,
59
+ default: false
70
60
  },
71
- emits: [
72
- 'create'
73
- ]
74
- }
61
+ create: {
62
+ type: Boolean,
63
+ default: true
64
+ },
65
+ })
66
+
67
+ const emit = defineEmits([
68
+ 'create'
69
+ ])
75
70
  </script>
@@ -55,98 +55,105 @@
55
55
  </div>
56
56
  </template>
57
57
 
58
- <script>
58
+ <script setup>
59
+ import { ref, watch } from 'vue'
59
60
  import {
60
61
  IconHome
61
62
  } from '@tabler/icons-vue';
62
63
 
63
- export default {
64
- name: 'TablerPager',
65
- components: {
66
- IconHome
64
+ const props = defineProps({
65
+ total: {
66
+ type: Number
67
67
  },
68
- props: {
69
- total: {
70
- type: Number
71
- },
72
- page: {
73
- type: Number
74
- },
75
- limit: {
76
- type: Number
77
- }
68
+ page: {
69
+ type: Number
78
70
  },
79
- emits: [
80
- 'page'
81
- ],
82
- data: function() {
83
- return this.create();
84
- },
85
- watch: {
86
- page: function() {
87
- this.current = this.page;
88
- },
89
- total: function() {
90
- const set = this.create();
91
-
92
- this.spread = set.spread;
93
- this.middle = set.middle;
94
- this.current = set.current;
95
- this.end = set.end;
96
- },
97
- limit: function() {
98
- const set = this.create();
99
-
100
- this.spread = set.spread;
101
- this.middle = set.middle;
102
- this.current = set.current;
103
- this.end = set.end;
104
- },
105
- current: function() {
106
- if (this.end < 5) return; // All buttons are shown already
107
-
108
- let start;
109
- if (this.current <= 3) {
110
- start = 0;
111
- } else if (this.current >= this.end - 4) {
112
- start = this.end - this.spread - 2;
113
- } else {
114
- start = this.current - 3;
115
- }
116
-
117
- this.middle = this.middle.map((ele, i) => {
118
- return start + i + 1;
119
- });
120
- }
121
- },
122
- methods: {
123
- create: function() {
124
- const end = Math.ceil(parseInt(this.total) / parseInt(this.limit));
125
- let spread; //Number of pages in between home button and last page
126
- if (end <= 2) {
127
- spread = 0;
128
- } else if (end >= 7) {
129
- spread = 5;
130
- } else {
131
- spread = end - 2;
132
- }
133
-
134
- // Array containing middle page number
135
- let middleAr = new Array(spread).fill(1, 0, spread).map((ele, i) => {
136
- return 1 + i;
137
- });
138
-
139
- return {
140
- spread: spread,
141
- middle: middleAr,
142
- current: this.page || 0,
143
- end: end
144
- };
145
- },
146
- changePage: function(page) {
147
- this.current = page;
148
- this.$emit('page', this.current);
149
- }
71
+ limit: {
72
+ type: Number
150
73
  }
74
+ })
75
+
76
+ const emit = defineEmits(['page'])
77
+
78
+ const spread = ref(0)
79
+ const middle = ref([])
80
+ const current = ref(0)
81
+ const end = ref(0)
82
+
83
+ const create = () => {
84
+ const endValue = Math.ceil(parseInt(props.total) / parseInt(props.limit));
85
+ let spreadValue; //Number of pages in between home button and last page
86
+ if (endValue <= 2) {
87
+ spreadValue = 0;
88
+ } else if (endValue >= 7) {
89
+ spreadValue = 5;
90
+ } else {
91
+ spreadValue = endValue - 2;
92
+ }
93
+
94
+ // Array containing middle page number
95
+ let middleAr = new Array(spreadValue).fill(1, 0, spreadValue).map((ele, i) => {
96
+ return 1 + i;
97
+ });
98
+
99
+ return {
100
+ spread: spreadValue,
101
+ middle: middleAr,
102
+ current: props.page || 0,
103
+ end: endValue
104
+ };
105
+ }
106
+
107
+ const changePage = (page) => {
108
+ current.value = page;
109
+ emit('page', current.value);
151
110
  }
111
+
112
+ // Initialize values
113
+ const initialValues = create();
114
+ spread.value = initialValues.spread;
115
+ middle.value = initialValues.middle;
116
+ current.value = initialValues.current;
117
+ end.value = initialValues.end;
118
+
119
+ // Watch for page changes
120
+ watch(() => props.page, () => {
121
+ current.value = props.page;
122
+ })
123
+
124
+ // Watch for total changes
125
+ watch(() => props.total, () => {
126
+ const set = create();
127
+ spread.value = set.spread;
128
+ middle.value = set.middle;
129
+ current.value = set.current;
130
+ end.value = set.end;
131
+ })
132
+
133
+ // Watch for limit changes
134
+ watch(() => props.limit, () => {
135
+ const set = create();
136
+ spread.value = set.spread;
137
+ middle.value = set.middle;
138
+ current.value = set.current;
139
+ end.value = set.end;
140
+ })
141
+
142
+ // Watch for current changes
143
+ watch(current, () => {
144
+ if (end.value < 5) return; // All buttons are shown already
145
+
146
+ let start;
147
+ if (current.value <= 3) {
148
+ start = 0;
149
+ } else if (current.value >= end.value - 4) {
150
+ start = end.value - spread.value - 2;
151
+ } else {
152
+ start = current.value - 3;
153
+ }
154
+
155
+ middle.value = middle.value.map((ele, i) => {
156
+ return start + i + 1;
157
+ });
158
+ })
152
159
  </script>
@@ -7,14 +7,11 @@
7
7
  </div>
8
8
  </template>
9
9
 
10
- <script>
11
- export default {
12
- name: 'TablerProgress',
13
- props: {
14
- percent: {
15
- type: Number,
16
- default: 1
17
- }
10
+ <script setup>
11
+ defineProps({
12
+ percent: {
13
+ type: Number,
14
+ default: 1
18
15
  }
19
- }
16
+ })
20
17
  </script>