@tak-ps/vue-tabler 3.87.4 → 4.1.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.
@@ -27,52 +27,37 @@
27
27
  </div>
28
28
  </template>
29
29
 
30
- <script setup>
30
+ <script setup lang="ts">
31
31
  import { ref, watch } from 'vue'
32
32
  import TablerLabel from '../internal/Label.vue'
33
33
 
34
- const props = defineProps({
35
- modelValue: {
36
- type: String,
37
- required: true
38
- },
39
- autofocus: {
40
- type: Boolean,
41
- default: false
42
- },
43
- default: {
44
- type: String,
45
- default: ''
46
- },
47
- required: {
48
- type: Boolean,
49
- default: false
50
- },
51
- description: {
52
- type: String,
53
- default: ''
54
- },
55
- options: {
56
- type: Array,
57
- required: true
58
- },
59
- disabled: {
60
- type: Boolean,
61
- default: false,
62
- },
63
- label: {
64
- type: String,
65
- default: ''
66
- },
67
- })
34
+ export interface EnumProps {
35
+ modelValue: string;
36
+ autofocus?: boolean;
37
+ default?: string;
38
+ required?: boolean;
39
+ description?: string;
40
+ options: string[];
41
+ disabled?: boolean;
42
+ label?: string;
43
+ }
44
+
45
+ const props = withDefaults(defineProps<EnumProps>(), {
46
+ autofocus: false,
47
+ default: '',
48
+ required: false,
49
+ description: '',
50
+ disabled: false,
51
+ label: ''
52
+ });
68
53
 
69
- const emit = defineEmits([
70
- 'blur',
71
- 'update:modelValue'
72
- ])
54
+ const emit = defineEmits<{
55
+ (e: 'blur'): void;
56
+ (e: 'update:modelValue', value: string): void;
57
+ }>();
73
58
 
74
59
  // Initialize current value
75
- const current = ref('')
60
+ const current = ref<string>('')
76
61
  if (!props.modelValue && props.default) {
77
62
  current.value = props.default
78
63
  } else {
@@ -41,56 +41,41 @@
41
41
  </div>
42
42
  </template>
43
43
 
44
- <script setup>
44
+ <script setup lang="ts">
45
45
  import { ref, computed, onMounted } from 'vue'
46
46
  import TablerLabel from '../internal/Label.vue'
47
47
 
48
- const props = defineProps({
49
- modelValue: {
50
- type: [String, Number],
51
- required: true
52
- },
53
- autofocus: {
54
- type: Boolean,
55
- default: false
56
- },
57
- loading: {
58
- type: Boolean,
59
- default: false
60
- },
61
- required: {
62
- type: Boolean,
63
- default: false,
64
- },
65
- disabled: {
66
- type: Boolean,
67
- default: false,
68
- },
69
- accept: {
70
- type: String,
71
- default: ''
72
- },
73
- description: {
74
- type: String,
75
- default: '',
76
- },
77
- label: {
78
- type: String,
79
- default: ''
80
- },
81
- placeholder: {
82
- type: String,
83
- default: ''
84
- },
85
- error: {
86
- type: String,
87
- default: ''
88
- },
89
- })
48
+ export interface FileInputProps {
49
+ modelValue: string | number;
50
+ autofocus?: boolean;
51
+ loading?: boolean;
52
+ required?: boolean;
53
+ disabled?: boolean;
54
+ accept?: string;
55
+ description?: string;
56
+ label?: string;
57
+ placeholder?: string;
58
+ error?: string;
59
+ }
60
+
61
+ const props = withDefaults(defineProps<FileInputProps>(), {
62
+ autofocus: false,
63
+ loading: false,
64
+ required: false,
65
+ disabled: false,
66
+ accept: '',
67
+ description: '',
68
+ label: '',
69
+ placeholder: '',
70
+ error: ''
71
+ });
90
72
 
91
- defineEmits(['blur', 'change'])
73
+ defineEmits<{
74
+ (e: 'blur'): void;
75
+ (e: 'change', event: Event): void;
76
+ }>();
92
77
 
93
- const textInput = ref(null)
78
+ const textInput = ref<HTMLInputElement | null>(null)
94
79
  const internal_error = ref('')
95
80
 
96
81
  const errorstr = computed(() => {
@@ -99,7 +84,7 @@ const errorstr = computed(() => {
99
84
  })
100
85
 
101
86
  onMounted(() => {
102
- if (props.autofocus) {
87
+ if (props.autofocus && textInput.value) {
103
88
  textInput.value.focus()
104
89
  }
105
90
  })
@@ -18,17 +18,17 @@
18
18
  <IconSearch
19
19
  v-if='icon === "search"'
20
20
  :size='20'
21
- :stroke='1'
21
+ stroke='1'
22
22
  />
23
23
  <IconLock
24
24
  v-else-if='icon === "lock"'
25
25
  :size='20'
26
- :stroke='1'
26
+ stroke='1'
27
27
  />
28
28
  <IconUser
29
29
  v-else-if='icon === "user"'
30
30
  :size='20'
31
- :stroke='1'
31
+ stroke='1'
32
32
  />
33
33
  <slot
34
34
  v-else-if='$slots.icon'
@@ -75,7 +75,7 @@
75
75
  >
76
76
  <IconEye
77
77
  :size='20'
78
- :stroke='1'
78
+ stroke='1'
79
79
  />
80
80
  </a>
81
81
  <a
@@ -88,7 +88,7 @@
88
88
  >
89
89
  <IconEyeOff
90
90
  :size='20'
91
- :stroke='1'
91
+ stroke='1'
92
92
  />
93
93
  </a>
94
94
  </span>
@@ -147,82 +147,60 @@
147
147
  </div>
148
148
  </template>
149
149
 
150
- <script setup>
150
+ <script setup lang="ts">
151
151
  import { ref, computed, watch, onMounted } from 'vue'
152
152
  import TablerLabel from '../internal/Label.vue'
153
153
  import {
154
- IconUser,
155
- IconCircleXFilled,
156
- IconLock,
157
- IconSearch,
158
154
  IconEye,
159
- IconEyeOff
160
- } from '@tabler/icons-vue'
155
+ IconEyeOff,
156
+ IconSearch,
157
+ IconLock,
158
+ IconUser
159
+ } from '@tabler/icons-vue';
161
160
 
162
- const props = defineProps({
163
- modelValue: {
164
- type: [String, Number],
165
- required: true
166
- },
167
- autocomplete: {
168
- type: String,
169
- default: 'on'
170
- },
171
- autofocus: {
172
- type: Boolean,
173
- default: false
174
- },
175
- icon: {
176
- type: String,
177
- default: ''
178
- },
179
- loading: {
180
- type: Boolean,
181
- default: false
182
- },
183
- required: {
184
- type: Boolean,
185
- default: false,
186
- },
187
- disabled: {
188
- type: Boolean,
189
- default: false,
190
- },
191
- description: {
192
- type: String,
193
- default: '',
194
- },
195
- rows: {
196
- type: Number,
197
- default: 1
198
- },
199
- wrap: {
200
- type: String,
201
- default: 'soft'
202
- },
203
- type: {
204
- type: String,
205
- default: 'text'
206
- },
207
- label: {
208
- type: String,
209
- default: ''
210
- },
211
- placeholder: {
212
- type: String,
213
- default: ''
214
- },
215
- error: {
216
- type: String,
217
- default: ''
218
- },
219
- })
161
+ export interface InputProps {
162
+ modelValue?: string | number;
163
+ autofocus?: boolean;
164
+ loading?: boolean;
165
+ required?: boolean;
166
+ disabled?: boolean;
167
+ autocomplete?: string;
168
+ description?: string;
169
+ icon?: string;
170
+ rows?: number;
171
+ wrap?: string;
172
+ type?: string;
173
+ label?: string;
174
+ placeholder?: string;
175
+ error?: string;
176
+ }
177
+
178
+ const props = withDefaults(defineProps<InputProps>(), {
179
+ autofocus: false,
180
+ loading: false,
181
+ required: false,
182
+ disabled: false,
183
+ autocomplete: 'off',
184
+ description: '',
185
+ icon: '',
186
+ rows: 1,
187
+ wrap: 'soft',
188
+ type: 'text',
189
+ label: '',
190
+ placeholder: '',
191
+ error: ''
192
+ });
220
193
 
221
- const emit = defineEmits(['blur', 'focus', 'submit', 'update:modelValue'])
194
+ const emit = defineEmits<{
195
+ (e: 'blur'): void;
196
+ (e: 'focus'): void;
197
+ (e: 'submit'): void;
198
+ (e: 'update:modelValue', value: string | number): void;
199
+ }>();
222
200
 
223
- const textInput = ref(null)
201
+ const textInput = ref<HTMLInputElement | HTMLTextAreaElement | null>(null)
224
202
  const internal_error = ref('')
225
- const current = ref(props.modelValue === undefined ? '' : props.modelValue)
203
+ const current = ref<string>(props.modelValue === undefined ? '' : String(props.modelValue))
226
204
 
227
205
  const passwordVisible = ref(false);
228
206
 
@@ -261,7 +239,7 @@ watch(current, (newValue) => {
261
239
 
262
240
  if (isNaN(currentInt)) {
263
241
  internal_error.value = 'Must be an integer!'
264
- } else if (currentInt === props.modelValue) {
242
+ } else if (currentInt === Number(props.modelValue)) {
265
243
  internal_error.value = ''
266
244
  return
267
245
  } else {
@@ -17,7 +17,7 @@
17
17
  :min='min'
18
18
  :max='max'
19
19
  :step='step'
20
- @input='event => current = event.target.value'
20
+ @input='event => current = Number((event.target as HTMLInputElement).value)'
21
21
  @keyup.enter='$emit("submit")'
22
22
  @blur='$emit("blur")'
23
23
  >
@@ -25,54 +25,38 @@
25
25
  </div>
26
26
  </template>
27
27
 
28
- <script setup>
28
+ <script setup lang="ts">
29
29
  import { ref, watch } from 'vue'
30
30
  import TablerLabel from '../internal/Label.vue'
31
31
 
32
- const props = defineProps({
33
- modelValue: {
34
- type: Number,
35
- required: true
36
- },
37
- autofocus: {
38
- type: Boolean,
39
- default: false
40
- },
41
- min: {
42
- type: Number,
43
- default: 0
44
- },
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
- })
32
+ export interface RangeProps {
33
+ modelValue: number;
34
+ autofocus?: boolean;
35
+ min?: number;
36
+ max?: number;
37
+ step?: number;
38
+ required?: boolean;
39
+ disabled?: boolean;
40
+ description?: string;
41
+ label?: string;
42
+ }
43
+
44
+ const props = withDefaults(defineProps<RangeProps>(), {
45
+ autofocus: false,
46
+ min: 0,
47
+ max: 10,
48
+ step: 1,
49
+ required: false,
50
+ disabled: false,
51
+ description: '',
52
+ label: ''
53
+ });
70
54
 
71
- const emit = defineEmits([
72
- 'blur',
73
- 'submit',
74
- 'update:modelValue'
75
- ])
55
+ const emit = defineEmits<{
56
+ (e: 'blur'): void;
57
+ (e: 'submit'): void;
58
+ (e: 'update:modelValue', value: number): void;
59
+ }>();
76
60
 
77
61
  const current = ref(props.modelValue)
78
62
 
@@ -23,27 +23,22 @@
23
23
  </div>
24
24
  </template>
25
25
 
26
- <script setup>
26
+ <script setup lang="ts">
27
27
  import { ref, watch, onMounted } from 'vue'
28
28
 
29
- const props = defineProps({
30
- modelValue: {
31
- type: String,
32
- required: true,
33
- },
34
- default: {
35
- type: String,
36
- default: ''
37
- },
38
- options: {
39
- type: Array,
40
- required: true
41
- },
42
- })
29
+ export interface SelectProps {
30
+ modelValue: string;
31
+ default?: string;
32
+ options: string[];
33
+ }
34
+
35
+ const props = withDefaults(defineProps<SelectProps>(), {
36
+ default: ''
37
+ });
43
38
 
44
- const emit = defineEmits([
45
- 'update:modelValue'
46
- ])
39
+ const emit = defineEmits<{
40
+ (e: 'update:modelValue', value: string): void;
41
+ }>();
47
42
 
48
43
  const current = ref('')
49
44
 
@@ -6,16 +6,25 @@
6
6
  :autofocus='autofocus'
7
7
  :disabled='disabled'
8
8
  :required='required'
9
- :default='inverse.has(modelValue) ? inverse.get(modelValue) : "No TimeZone"'
9
+ :model-value='inverse.has(modelValue) ? inverse.get(modelValue) : "No TimeZone"'
10
10
  @update:model-value='emit("update:modelValue", map.get($event).tzCode)'
11
11
  @submit='emit("submit")'
12
12
  @blur='emit("blur")'
13
13
  />
14
14
  </template>
15
15
 
16
- <script setup>
16
+ <script setup lang="ts">
17
17
  import TablerEnum from './Enum.vue'
18
18
 
19
+ export interface TimeZoneProps {
20
+ modelValue: string;
21
+ autofocus?: boolean;
22
+ description?: string;
23
+ required?: boolean;
24
+ disabled?: boolean;
25
+ label?: string;
26
+ }
27
+
19
28
  const tzs = [
20
29
  { label:"Pacific/Midway (GMT-11:00)", "tzCode":"Pacific/Midway", },
21
30
  { label:"Pacific/Niue (GMT-11:00)", "tzCode":"Pacific/Niue", },
@@ -443,38 +452,19 @@ const tzs = [
443
452
  { label:"Pacific/Kiritimati (GMT+14:00)", "tzCode":"Pacific/Kiritimati", }
444
453
  ]
445
454
 
446
- defineProps({
447
- modelValue: {
448
- type: String,
449
- required: true
450
- },
451
- autofocus: {
452
- type: Boolean,
453
- default: false
454
- },
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
- })
455
+ withDefaults(defineProps<TimeZoneProps>(), {
456
+ autofocus: false,
457
+ description: '',
458
+ required: false,
459
+ disabled: false,
460
+ label: 'Default Timezone'
461
+ });
472
462
 
473
- const emit = defineEmits([
474
- 'submit',
475
- 'blur',
476
- 'update:modelValue'
477
- ])
463
+ const emit = defineEmits<{
464
+ (e: 'submit'): void;
465
+ (e: 'blur'): void;
466
+ (e: 'update:modelValue', value: string): void;
467
+ }>();
478
468
 
479
469
  // Create maps for timezone conversion
480
470
  const map = new Map()
@@ -20,42 +20,32 @@
20
20
  </div>
21
21
  </template>
22
22
 
23
- <script setup>
23
+ <script setup lang="ts">
24
24
  import { ref, watch, onMounted } from 'vue'
25
25
  import TablerLabel from '../internal/Label.vue'
26
26
 
27
- const props = defineProps({
28
- modelValue: {
29
- type: Boolean,
30
- required: true
31
- },
32
- autofocus: {
33
- type: Boolean,
34
- default: false
35
- },
36
- disabled: {
37
- type: Boolean,
38
- default: false
39
- },
40
- required: {
41
- type: Boolean,
42
- default: false
43
- },
44
- description: {
45
- type: String,
46
- default: ''
47
- },
48
- label: {
49
- type: String,
50
- default: ''
51
- }
52
- })
27
+ export interface ToggleProps {
28
+ modelValue: boolean;
29
+ autofocus?: boolean;
30
+ disabled?: boolean;
31
+ required?: boolean;
32
+ description?: string;
33
+ label?: string;
34
+ }
35
+
36
+ const props = withDefaults(defineProps<ToggleProps>(), {
37
+ autofocus: false,
38
+ disabled: false,
39
+ required: false,
40
+ description: '',
41
+ label: ''
42
+ });
53
43
 
54
- const emit = defineEmits([
55
- 'blur',
56
- 'submit',
57
- 'update:modelValue'
58
- ])
44
+ const emit = defineEmits<{
45
+ (e: 'blur'): void;
46
+ (e: 'submit'): void;
47
+ (e: 'update:modelValue', value: boolean): void;
48
+ }>();
59
49
 
60
50
  const current = ref(props.modelValue)
61
51
 
@@ -8,9 +8,8 @@
8
8
  <template #default>
9
9
  <IconInfoSquare
10
10
  :size='20'
11
- :stroke='1'
11
+ stroke='1'
12
12
  class='cursor-pointer'
13
- @click='help = true'
14
13
  />
15
14
  </template>
16
15
  <template #dropdown>
@@ -50,25 +49,21 @@
50
49
  </div>
51
50
  </template>
52
51
 
53
- <script setup>
52
+ <script setup lang="ts">
54
53
  import {
55
54
  IconInfoSquare
56
55
  } from '@tabler/icons-vue';
57
56
 
58
57
  import Dropdown from '../Dropdown.vue';
59
58
 
60
- const props = defineProps({
61
- required: {
62
- type: Boolean,
63
- default: false,
64
- },
65
- description: {
66
- type: String,
67
- default: '',
68
- },
69
- label: {
70
- type: String,
71
- required: true
72
- }
59
+ export interface LabelProps {
60
+ required?: boolean;
61
+ description?: string;
62
+ label: string;
63
+ }
64
+
65
+ const props = withDefaults(defineProps<LabelProps>(), {
66
+ required: false,
67
+ description: '',
73
68
  });
74
69
  </script>