@d-mok/quasar-app-extension-quasar-axe 2.1.90 → 2.1.92

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.1.90",
3
+ "version": "2.1.92",
4
4
  "description": "A Quasar App Extension",
5
5
  "author": "d-mok <49301824+d-mok@users.noreply.github.com>",
6
6
  "license": "MIT",
@@ -27,7 +27,7 @@
27
27
  "lodash": "^4.17.21",
28
28
  "mime-types": "^2.1.35",
29
29
  "papaparse": "^5.4.1",
30
- "sapphire-js": "^2.1.6",
30
+ "sapphire-js": "^2.1.8",
31
31
  "sortablejs": "^1.15.0",
32
32
  "vuedraggable": "^4.1.0"
33
33
  },
@@ -0,0 +1,72 @@
1
+ <template>
2
+ <q-select
3
+ multiple
4
+ v-model="modelValue"
5
+ :options="options"
6
+ :option-label="getLabel"
7
+ :option-value="getValue"
8
+ emit-value
9
+ map-options
10
+ v-bind="$attrs"
11
+ >
12
+ <template v-slot:option="{ itemProps, opt, selected, toggleOption }">
13
+ <q-item
14
+ v-bind="itemProps"
15
+ dense
16
+ >
17
+ <q-item-section side>
18
+ <q-checkbox
19
+ :model-value="selected"
20
+ @update:model-value="toggleOption(opt)"
21
+ size="sm"
22
+ />
23
+ </q-item-section>
24
+ <q-item-section>
25
+ <q-item-label>{{ getLabel(opt) }}</q-item-label>
26
+ </q-item-section>
27
+ </q-item>
28
+ </template>
29
+ </q-select>
30
+ </template>
31
+
32
+ <script lang="ts" setup generic="T,R">
33
+ import { watch } from 'vue'
34
+ import _ from 'lodash'
35
+
36
+ const modelValue = defineModel<R[]>({ required: true })
37
+
38
+ let { options, optionLabel, optionValue } = defineProps<{
39
+ options: T[]
40
+ optionLabel?: (string & keyof T) | ((_: T) => string)
41
+ optionValue?: (string & keyof T) | ((_: T) => R)
42
+ }>()
43
+
44
+ function getLabel(opt: T): string {
45
+ if (optionLabel === undefined) {
46
+ return String(opt)
47
+ } else if (typeof optionLabel === 'string') {
48
+ return String(opt[optionLabel])
49
+ } else {
50
+ return optionLabel(opt)
51
+ }
52
+ }
53
+
54
+ function getValue(opt: T): R {
55
+ if (optionValue === undefined) {
56
+ return opt as any
57
+ } else if (typeof optionValue === 'string') {
58
+ return opt[optionValue] as R
59
+ } else {
60
+ return optionValue(opt)
61
+ }
62
+ }
63
+
64
+ watch(
65
+ () => options,
66
+ (now, old) => {
67
+ if (!_.isEqual(now, old)) {
68
+ modelValue.value = modelValue.value.match(now.map(getValue))
69
+ }
70
+ }
71
+ )
72
+ </script>