@d-mok/quasar-app-extension-quasar-axe 2.0.2 → 2.0.5

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@d-mok/quasar-app-extension-quasar-axe",
3
- "version": "2.0.2",
3
+ "version": "2.0.5",
4
4
  "description": "A Quasar App Extension",
5
5
  "author": "d-mok <49301824+d-mok@users.noreply.github.com>",
6
6
  "license": "MIT",
@@ -16,10 +16,13 @@
16
16
  "dependencies": {
17
17
  "@handsontable/vue3": "^12.1.0",
18
18
  "@supabase/supabase-js": "^1.35.4",
19
+ "@types/lodash": "^4.14.182",
19
20
  "@types/papaparse": "^5.3.2",
20
21
  "@types/webpack-env": "^1.17.0",
22
+ "@vueuse/core": "^9.1.0",
21
23
  "handsontable": "^12.1.0",
22
24
  "jszip": "^3.9.0",
25
+ "lodash": "^4.17.21",
23
26
  "papaparse": "^5.3.2",
24
27
  "sapphire-js": "^1.0.67",
25
28
  "vuedraggable": "^4.1.0"
@@ -0,0 +1,60 @@
1
+ <template>
2
+ <q-select
3
+ v-model="selected"
4
+ :options="options"
5
+ :option-label="optionLabel"
6
+ v-bind="$attrs"
7
+ />
8
+ </template>
9
+
10
+ <script
11
+ lang="ts"
12
+ setup
13
+ >
14
+ import { watch } from 'vue'
15
+ import { useVModel } from '@vueuse/core'
16
+ import _ from 'lodash'
17
+
18
+ const props = withDefaults(
19
+ defineProps<{
20
+ options: any[]
21
+ modelValue: any
22
+ optionLabel: string | ((_: any) => string)
23
+ ticker?: number
24
+ }>(),
25
+ {
26
+ ticker: 0,
27
+ optionLabel: $ => String($),
28
+ }
29
+ )
30
+ const emits = defineEmits(['update:modelValue'])
31
+
32
+ const selected = useVModel(props, 'modelValue', emits)
33
+
34
+ function select(i: number) {
35
+ i = _.clamp(i, 0, props.options.length - 1)
36
+ selected.value = props.options[i]
37
+ }
38
+
39
+ function rePick() {
40
+ if (props.options.length === 0) return
41
+ if (!props.options.includes(selected.value)) select(0)
42
+ }
43
+
44
+ rePick()
45
+ watch(() => props.options, rePick)
46
+
47
+ function getCurrentIndex(): number {
48
+ return props.options.findIndex($ => $ === selected.value)
49
+ }
50
+
51
+ watch(
52
+ () => props.ticker,
53
+ (now, old) => {
54
+ let i = getCurrentIndex()
55
+ if (i === -1) return
56
+ if (now > old) select(i + 1)
57
+ if (now < old) select(i - 1)
58
+ }
59
+ )
60
+ </script>
@@ -1,11 +1,9 @@
1
1
  <template>
2
2
  <q-select
3
- :model-value="modelValue"
4
- @update:model-value="e => emits('update:modelValue', e)"
3
+ v-model="selected"
5
4
  :options="options"
6
5
  v-bind="$attrs"
7
- >
8
- </q-select>
6
+ />
9
7
  </template>
10
8
 
11
9
  <script
@@ -13,6 +11,7 @@
13
11
  setup
14
12
  >
15
13
  import { watch } from 'vue'
14
+ import { useVModel } from '@vueuse/core'
16
15
 
17
16
  const props = defineProps<{
18
17
  options: string[]
@@ -21,18 +20,15 @@ const props = defineProps<{
21
20
 
22
21
  const emits = defineEmits(['update:modelValue'])
23
22
 
23
+ const selected = useVModel(props, 'modelValue', emits)
24
+
24
25
  function rePick() {
25
26
  if (props.options.length === 0) return
26
27
 
27
- if (!props.options.includes(props.modelValue))
28
- emits('update:modelValue', props.options[0])
28
+ if (!props.options.includes(selected.value))
29
+ selected.value = props.options[0]
29
30
  }
30
31
 
31
32
  rePick()
32
- watch(
33
- () => props.options,
34
- () => {
35
- rePick()
36
- }
37
- )
33
+ watch(() => props.options, rePick)
38
34
  </script>
@@ -1,63 +0,0 @@
1
- <template>
2
- <q-select
3
- :model-value="modelValue"
4
- @update:model-value="e => emits('update:modelValue', e)"
5
- :options="options"
6
- :option-label="optionLabel"
7
- v-bind="$attrs"
8
- >
9
- </q-select>
10
- </template>
11
-
12
- <script
13
- lang="ts"
14
- setup
15
- >
16
- import { watch } from 'vue'
17
-
18
- type Props = {
19
- options: any[]
20
- modelValue: any
21
- optionLabel: string
22
- ticker?: number
23
- }
24
-
25
- const props = withDefaults(defineProps<Props>(), { ticker: 0 })
26
-
27
- const emits = defineEmits(['update:modelValue'])
28
-
29
- function rePick() {
30
- if (props.options.length === 0) return
31
-
32
- if (!props.options.includes(props.modelValue))
33
- emits('update:modelValue', props.options[0])
34
- }
35
-
36
- rePick()
37
- watch(
38
- () => props.options,
39
- () => {
40
- rePick()
41
- }
42
- )
43
-
44
- function getCurrentIndex(): number {
45
- return props.options.findIndex($ => $ === props.modelValue)
46
- }
47
-
48
- watch(
49
- () => props.ticker,
50
- (now, old) => {
51
- let i = getCurrentIndex()
52
- if (i === -1) return
53
- if (now > old) {
54
- let j = Math.min(i + 1, props.options.length - 1)
55
- emits('update:modelValue', props.options[j])
56
- }
57
- if (now < old) {
58
- let j = Math.max(i - 1, 0)
59
- emits('update:modelValue', props.options[j])
60
- }
61
- }
62
- )
63
- </script>