@tak-ps/vue-tabler 3.78.2 → 3.79.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.
@@ -96,130 +96,131 @@
96
96
  </div>
97
97
  </template>
98
98
 
99
- <script>
100
- import TablerLabel from '../internal/Label.vue';
99
+ <script setup>
100
+ import { ref, computed, watch, onMounted } from 'vue'
101
+ import TablerLabel from '../internal/Label.vue'
101
102
  import {
102
103
  IconUser,
103
104
  IconLock,
104
105
  IconSearch
105
- } from '@tabler/icons-vue';
106
+ } from '@tabler/icons-vue'
106
107
 
107
- export default {
108
- name: 'TablerInput',
109
- components: {
110
- IconUser,
111
- IconLock,
112
- IconSearch,
113
- TablerLabel
108
+ const props = defineProps({
109
+ modelValue: {
110
+ type: [String, Number],
111
+ required: true
114
112
  },
115
- props: {
116
- modelValue: {
117
- type: [String, Number],
118
- required: true
119
- },
120
- autocomplete: {
121
- type: String,
122
- default: 'on'
123
- },
124
- autofocus: {
125
- type: Boolean,
126
- default: false
127
- },
128
- icon: {
129
- type: String,
130
- },
131
- loading: {
132
- type: Boolean,
133
- default: false
134
- },
135
- required: {
136
- type: Boolean,
137
- default: false,
138
- },
139
- disabled: {
140
- type: Boolean,
141
- default: false,
142
- },
143
- description: {
144
- type: String,
145
- default: '',
146
- },
147
- rows: {
148
- type: Number,
149
- default: 1
150
- },
151
- wrap: {
152
- type: String,
153
- default: 'soft'
154
- },
155
- type: {
156
- type: String,
157
- default: 'text'
158
- },
159
- label: String,
160
- placeholder: String,
161
- error: String,
113
+ autocomplete: {
114
+ type: String,
115
+ default: 'on'
162
116
  },
163
- emits: ['blur', 'focus', 'submit', 'update:modelValue'],
164
- data: function() {
165
- return {
166
- help: false,
167
- internal_error: '',
168
- current: this.modelValue === undefined ? '' : this.modelValue
169
- }
117
+ autofocus: {
118
+ type: Boolean,
119
+ default: false
170
120
  },
171
- computed: {
172
- errorstr: function() {
173
- if (this.error) return this.error;
174
- return this.internal_error;
175
- },
176
- computed_type: function() {
177
- if (this.type === 'integer') return 'number';
178
- return this.type;
179
- }
121
+ icon: {
122
+ type: String,
123
+ default: ''
124
+ },
125
+ loading: {
126
+ type: Boolean,
127
+ default: false
128
+ },
129
+ required: {
130
+ type: Boolean,
131
+ default: false,
132
+ },
133
+ disabled: {
134
+ type: Boolean,
135
+ default: false,
136
+ },
137
+ description: {
138
+ type: String,
139
+ default: '',
140
+ },
141
+ rows: {
142
+ type: Number,
143
+ default: 1
144
+ },
145
+ wrap: {
146
+ type: String,
147
+ default: 'soft'
148
+ },
149
+ type: {
150
+ type: String,
151
+ default: 'text'
152
+ },
153
+ label: {
154
+ type: String,
155
+ default: ''
156
+ },
157
+ placeholder: {
158
+ type: String,
159
+ default: ''
180
160
  },
181
- watch: {
182
- modelValue: function() {
183
- if (this.current !== String(this.modelValue)) {
184
- this.current = String(this.modelValue);
185
- }
186
- },
187
- current: function() {
188
- if (typeof this.modelValue === 'number' || this.type === 'number') {
189
- const current = Number(this.current);
161
+ error: {
162
+ type: String,
163
+ default: ''
164
+ },
165
+ })
166
+
167
+ const emit = defineEmits(['blur', 'focus', 'submit', 'update:modelValue'])
168
+
169
+ const textInput = ref(null)
170
+ const internal_error = ref('')
171
+ const current = ref(props.modelValue === undefined ? '' : props.modelValue)
190
172
 
191
- if (isNaN(current)) {
192
- this.internal_error = 'Must be a number!';
193
- } else if (current === this.modelValue) {
194
- this.internal_error = '';
195
- return;
196
- } else {
197
- this.internal_error = '';
198
- this.$emit('update:modelValue', current);
199
- }
200
- } else if (this.type === 'integer') {
201
- const current = parseInt(this.current);
173
+ const errorstr = computed(() => {
174
+ if (props.error) return props.error
175
+ return internal_error.value
176
+ })
177
+
178
+ const computed_type = computed(() => {
179
+ if (props.type === 'integer') return 'number'
180
+ return props.type
181
+ })
182
+
183
+ watch(() => props.modelValue, (newValue) => {
184
+ if (current.value !== String(newValue)) {
185
+ current.value = String(newValue)
186
+ }
187
+ })
202
188
 
203
- if (isNaN(current)) {
204
- this.internal_error = 'Must be an integer!';
205
- } else if (current === this.modelValue) {
206
- this.internal_error = '';
207
- return;
208
- } else {
209
- this.internal_error = '';
210
- this.$emit('update:modelValue', current);
211
- }
212
- } else {
213
- this.internal_error = '';
214
- if (this.current === this.modelValue) return;
215
- this.$emit('update:modelValue', this.current);
216
- }
189
+ watch(current, (newValue) => {
190
+ if (typeof props.modelValue === 'number' || props.type === 'number') {
191
+ const currentNum = Number(newValue)
192
+
193
+ if (isNaN(currentNum)) {
194
+ internal_error.value = 'Must be a number!'
195
+ } else if (currentNum === props.modelValue) {
196
+ internal_error.value = ''
197
+ return
198
+ } else {
199
+ internal_error.value = ''
200
+ emit('update:modelValue', currentNum)
217
201
  }
218
- },
219
- mounted: function() {
220
- if (this.autofocus) {
221
- this.$refs['text-input'].focus();
202
+ } else if (props.type === 'integer') {
203
+ const currentInt = parseInt(newValue)
204
+
205
+ if (isNaN(currentInt)) {
206
+ internal_error.value = 'Must be an integer!'
207
+ } else if (currentInt === props.modelValue) {
208
+ internal_error.value = ''
209
+ return
210
+ } else {
211
+ internal_error.value = ''
212
+ emit('update:modelValue', currentInt)
222
213
  }
214
+ } else {
215
+ internal_error.value = ''
216
+ if (newValue === props.modelValue) return
217
+ emit('update:modelValue', newValue)
218
+ }
219
+ })
220
+
221
+ onMounted(() => {
222
+ if (props.autofocus) {
223
+ textInput.value.focus()
223
224
  }
224
- }
225
+ })
225
226
  </script>
@@ -25,65 +25,59 @@
25
25
  </div>
26
26
  </template>
27
27
 
28
- <script>
29
- import TablerLabel from '../internal/Label.vue';
28
+ <script setup>
29
+ import { ref, watch } from 'vue'
30
+ import TablerLabel from '../internal/Label.vue'
30
31
 
31
- export default {
32
- name: 'TablerRange',
33
- components: {
34
- TablerLabel
32
+ const props = defineProps({
33
+ modelValue: {
34
+ type: Number,
35
+ required: true
35
36
  },
36
- props: {
37
- modelValue: {
38
- type: Number,
39
- required: true
40
- },
41
- autofocus: {
42
- type: Boolean,
43
- default: false
44
- },
45
- min: {
46
- type: Number,
47
- default: 0
48
- },
49
- max: {
50
- type: Number,
51
- default: 10
52
- },
53
- step: {
54
- type: Number,
55
- default: 1
56
- },
57
- required: {
58
- type: Boolean,
59
- default: false,
60
- },
61
- disabled: {
62
- type: Boolean,
63
- default: false,
64
- },
65
- description: {
66
- type: String,
67
- default: '',
68
- },
69
- label: String,
37
+ autofocus: {
38
+ type: Boolean,
39
+ default: false
70
40
  },
71
- emits: [
72
- 'blur',
73
- 'submit',
74
- 'update:modelValue'
75
- ],
76
- data: function() {
77
- return {
78
- help: false,
79
- current: this.modelValue
80
- }
41
+ min: {
42
+ type: Number,
43
+ default: 0
81
44
  },
82
- watch: {
83
- current: function() {
84
- if (this.current === this.modelValue) return;
85
- this.$emit('update:modelValue', Number(this.current));
86
- }
87
- }
88
- }
45
+ max: {
46
+ type: Number,
47
+ default: 10
48
+ },
49
+ step: {
50
+ type: Number,
51
+ default: 1
52
+ },
53
+ required: {
54
+ type: Boolean,
55
+ default: false,
56
+ },
57
+ disabled: {
58
+ type: Boolean,
59
+ default: false,
60
+ },
61
+ description: {
62
+ type: String,
63
+ default: '',
64
+ },
65
+ label: {
66
+ type: String,
67
+ default: ''
68
+ },
69
+ })
70
+
71
+ const emit = defineEmits([
72
+ 'blur',
73
+ 'submit',
74
+ 'update:modelValue'
75
+ ])
76
+
77
+ const current = ref(props.modelValue)
78
+
79
+ watch(current, (newValue) => {
80
+ if (newValue === props.modelValue) return
81
+ emit('update:modelValue', Number(newValue))
82
+ })
89
83
  </script>
@@ -23,41 +23,41 @@
23
23
  </div>
24
24
  </template>
25
25
 
26
- <script>
27
- export default {
28
- name: 'TablerSelect',
29
- props: {
30
- modelValue: {
31
- type: String,
32
- required: true,
33
- },
34
- default: {
35
- type: String,
36
- required: false
37
- },
38
- options: {
39
- type: Array,
40
- required: true
41
- },
42
- },
43
- emits: [
44
- 'update:modelValue'
45
- ],
46
- data: function() {
47
- return {
48
- current: ''
49
- }
26
+ <script setup>
27
+ import { ref, watch, onMounted } from 'vue'
28
+
29
+ const props = defineProps({
30
+ modelValue: {
31
+ type: String,
32
+ required: true,
50
33
  },
51
- watch: {
52
- current: function() {
53
- if (this.modelValue !== this.current) {
54
- this.$emit('update:modelValue', this.current);
55
- }
56
- }
34
+ default: {
35
+ type: String,
36
+ default: ''
57
37
  },
58
- mounted: function() {
59
- if (!this.modelValue && this.default) this.current = this.default
60
- else this.current = this.modelValue;
38
+ options: {
39
+ type: Array,
40
+ required: true
61
41
  },
62
- }
42
+ })
43
+
44
+ const emit = defineEmits([
45
+ 'update:modelValue'
46
+ ])
47
+
48
+ const current = ref('')
49
+
50
+ watch(current, (newValue) => {
51
+ if (props.modelValue !== newValue) {
52
+ emit('update:modelValue', newValue)
53
+ }
54
+ })
55
+
56
+ onMounted(() => {
57
+ if (!props.modelValue && props.default) {
58
+ current.value = props.default
59
+ } else {
60
+ current.value = props.modelValue
61
+ }
62
+ })
63
63
  </script>
@@ -7,13 +7,13 @@
7
7
  :disabled='disabled'
8
8
  :required='required'
9
9
  :default='inverse.has(modelValue) ? inverse.get(modelValue) : "No TimeZone"'
10
- @change='$emit("update:modelValue", map.get($event.target.value).tzCode)'
11
- @submit='$emit("submit")'
12
- @blur='$emit("blur")'
10
+ @update:model-value='emit("update:modelValue", map.get($event).tzCode)'
11
+ @submit='emit("submit")'
12
+ @blur='emit("blur")'
13
13
  />
14
14
  </template>
15
15
 
16
- <script>
16
+ <script setup>
17
17
  import TablerEnum from './Enum.vue'
18
18
 
19
19
  const tzs = [
@@ -443,57 +443,48 @@ const tzs = [
443
443
  { label:"Pacific/Kiritimati (GMT+14:00)", "tzCode":"Pacific/Kiritimati", }
444
444
  ]
445
445
 
446
- export default {
447
- name: 'TablerTimeZone',
448
- components: {
449
- TablerEnum
446
+ defineProps({
447
+ modelValue: {
448
+ type: String,
449
+ required: true
450
450
  },
451
- props: {
452
- modelValue: {
453
- type: String,
454
- required: true
455
- },
456
- autofocus: {
457
- type: Boolean,
458
- default: false
459
- },
460
- description: {
461
- type: String,
462
- default: ''
463
- },
464
- required: {
465
- type: Boolean
466
- },
467
- disabled: {
468
- type: Boolean,
469
- default: false
470
- },
471
- label: {
472
- type: String,
473
- default: 'Default Timezone'
474
- },
451
+ autofocus: {
452
+ type: Boolean,
453
+ default: false
475
454
  },
476
- emits: [
477
- 'submit',
478
- 'blur',
479
- 'update:modelValue'
480
- ],
481
- data: function() {
482
- const map = new Map();
483
- const inverse = new Map();
455
+ description: {
456
+ type: String,
457
+ default: ''
458
+ },
459
+ required: {
460
+ type: Boolean,
461
+ default: false
462
+ },
463
+ disabled: {
464
+ type: Boolean,
465
+ default: false
466
+ },
467
+ label: {
468
+ type: String,
469
+ default: 'Default Timezone'
470
+ },
471
+ })
472
+
473
+ const emit = defineEmits([
474
+ 'submit',
475
+ 'blur',
476
+ 'update:modelValue'
477
+ ])
484
478
 
485
- map.set('No TimeZone', { tzCode: '' });
486
- for (const tz of tzs) {
487
- map.set(tz.label, tz);
488
- inverse.set(tz.tzCode, tz.label);
489
- }
479
+ // Create maps for timezone conversion
480
+ const map = new Map()
481
+ const inverse = new Map()
490
482
 
491
- return {
492
- map,
493
- inverse,
494
- internal: this.modelValue,
495
- timezones: ['No TimeZone'].concat(tzs.map((tz) => tz.label))
496
- }
497
- }
483
+ map.set('No TimeZone', { tzCode: '' })
484
+ for (const tz of tzs) {
485
+ map.set(tz.label, tz)
486
+ inverse.set(tz.tzCode, tz.label)
498
487
  }
488
+
489
+ const timezones = ['No TimeZone'].concat(tzs.map((tz) => tz.label))
499
490
  </script>
@@ -20,61 +20,55 @@
20
20
  </div>
21
21
  </template>
22
22
 
23
- <script>
24
- import TablerLabel from '../internal/Label.vue';
23
+ <script setup>
24
+ import { ref, watch, onMounted } from 'vue'
25
+ import TablerLabel from '../internal/Label.vue'
25
26
 
26
- export default {
27
- name: 'TablerToggle',
28
- components: {
29
- TablerLabel
27
+ const props = defineProps({
28
+ modelValue: {
29
+ type: Boolean,
30
+ required: true
30
31
  },
31
- props: {
32
- modelValue: {
33
- type: Boolean,
34
- required: true
35
- },
36
- autofocus: {
37
- type: Boolean,
38
- default: false
39
- },
40
- disabled: {
41
- type: Boolean,
42
- default: false
43
- },
44
- required: {
45
- type: Boolean,
46
- default: false
47
- },
48
- description: {
49
- type: String,
50
- default: ''
51
- },
52
- label: {
53
- type: String,
54
- default: ''
55
- }
32
+ autofocus: {
33
+ type: Boolean,
34
+ default: false
56
35
  },
57
- emits: [
58
- 'blur',
59
- 'submit',
60
- 'update:modelValue'
61
- ],
62
- data: function() {
63
- return {
64
- current: this.modelValue
65
- }
36
+ disabled: {
37
+ type: Boolean,
38
+ default: false
66
39
  },
67
- watch: {
68
- modelValue: function() {
69
- this.current = this.modelValue;
70
- },
71
- current: function() {
72
- if (this.current === this.modelValue) return;
73
- this.$emit('update:modelValue', this.current);
74
- }
40
+ required: {
41
+ type: Boolean,
42
+ default: false
75
43
  },
76
- mounted: function() {
77
- this.current = this.modelValue;
44
+ description: {
45
+ type: String,
46
+ default: ''
47
+ },
48
+ label: {
49
+ type: String,
50
+ default: ''
78
51
  }
79
- }
52
+ })
53
+
54
+ const emit = defineEmits([
55
+ 'blur',
56
+ 'submit',
57
+ 'update:modelValue'
58
+ ])
59
+
60
+ const current = ref(props.modelValue)
61
+
62
+ watch(() => props.modelValue, (newValue) => {
63
+ current.value = newValue
64
+ })
65
+
66
+ watch(current, (newValue) => {
67
+ if (newValue === props.modelValue) return
68
+ emit('update:modelValue', newValue)
69
+ })
70
+
71
+ onMounted(() => {
72
+ current.value = props.modelValue
73
+ })
80
74
  </script>
package/lib.js CHANGED
@@ -14,6 +14,7 @@ export { default as TablerButton } from './components/Button.vue'
14
14
  export { default as TablerRefreshButton } from './components/RefreshButton.vue'
15
15
  export { default as TablerIconButton } from './components/IconButton.vue'
16
16
  export { default as TablerDropdown } from './components/Dropdown.vue'
17
+ export { default as TablerSlidedown } from './components/Slidedown.vue'
17
18
  export { default as TablerPager } from './components/Pager.vue'
18
19
  export { default as TablerNone } from './components/None.vue'
19
20
  export { default as TablerError } from './components/Err.vue'
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tak-ps/vue-tabler",
3
3
  "type": "module",
4
- "version": "3.78.2",
4
+ "version": "3.79.0",
5
5
  "lib": "lib.js",
6
6
  "module": "lib.js",
7
7
  "description": "Tabler UI components for Vue3",