@d-mok/quasar-app-extension-quasar-axe 2.1.95 → 2.1.97

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.95",
3
+ "version": "2.1.97",
4
4
  "description": "A Quasar App Extension",
5
5
  "author": "d-mok <49301824+d-mok@users.noreply.github.com>",
6
6
  "license": "MIT",
@@ -18,9 +18,14 @@ import { ref } from 'vue'
18
18
 
19
19
  let modelValue = defineModel<string>({ required: true })
20
20
 
21
- const { autocomplete, immediate = false } = defineProps<{
21
+ const {
22
+ autocomplete,
23
+ immediate = false,
24
+ noFilter = false,
25
+ } = defineProps<{
22
26
  autocomplete: string[]
23
27
  immediate?: boolean
28
+ noFilter?: boolean
24
29
  }>()
25
30
 
26
31
  let options = ref<string[]>([])
@@ -28,6 +33,10 @@ let options = ref<string[]>([])
28
33
  function filterFn(val: any, update: any) {
29
34
  if (!val) val = modelValue.value
30
35
  update(() => {
36
+ if (noFilter) {
37
+ options.value = autocomplete
38
+ return
39
+ }
31
40
  if (!immediate && !val) {
32
41
  options.value = []
33
42
  return
@@ -24,7 +24,10 @@ async function base(options: QDialogOptions): Promise<string> {
24
24
 
25
25
  return new Promise<string>((resolve, reject) =>
26
26
  Dialog.create(opt)
27
- .onOk((data: unknown) => resolve(String(data)))
27
+ .onOk((data: unknown) => {
28
+ if (Array.isArray(data)) resolve(JSON.stringify(data))
29
+ resolve(String(data))
30
+ })
28
31
  .onCancel(() => reject('dialog cancelled by user.'))
29
32
  )
30
33
  }
@@ -141,7 +144,8 @@ export async function askRadio<T>(
141
144
  title: string,
142
145
  message: string = '',
143
146
  items: T[],
144
- label: (string & keyof T) | Mapper<T, string> = $ => String($)
147
+ prefill: T = items[0],
148
+ label?: (string & keyof T) | Mapper<T, string>
145
149
  ): Promise<T> {
146
150
  let labelFunc = ($: any) => getLabelFunc(label)($)
147
151
  let values = items.map(labelFunc)
@@ -150,7 +154,7 @@ export async function askRadio<T>(
150
154
  title,
151
155
  message,
152
156
  options: {
153
- model: '',
157
+ model: labelFunc(prefill),
154
158
  type: 'radio',
155
159
  items: values.map($ => ({ label: $, value: $ })),
156
160
  isValid: $ => typeof $ === 'string' && values.includes($),
@@ -159,3 +163,31 @@ export async function askRadio<T>(
159
163
 
160
164
  return items.find($ => labelFunc($) === value)!
161
165
  }
166
+
167
+ /**
168
+ * Ask to select multiple object by a checkbox button group.
169
+ */
170
+ export async function askCheckbox<T>(
171
+ title: string,
172
+ message: string = '',
173
+ items: T[],
174
+ prefill: T[] = [],
175
+ label?: (string & keyof T) | Mapper<T, string>
176
+ ): Promise<T[]> {
177
+ let labelFunc = ($: any) => getLabelFunc(label)($)
178
+ let values = items.map(labelFunc)
179
+
180
+ let value = await base({
181
+ title,
182
+ message,
183
+ options: {
184
+ model: prefill.map(labelFunc),
185
+ type: 'checkbox',
186
+ items: values.map($ => ({ label: $, value: $ })),
187
+ // isValid: $ => typeof $ === 'string' && values.includes($),
188
+ },
189
+ })
190
+
191
+ let selected: string[] = JSON.parse(value)
192
+ return items.filter($ => selected.includes(labelFunc($)))
193
+ }
@@ -66,7 +66,6 @@ import { ref } from 'vue'
66
66
  import { toSchema, isMatchSchema, isPrimitive, clone } from './schema'
67
67
  import { unparseCSV } from '../../csv'
68
68
  import { copyToClipboard } from 'quasar'
69
- import { validate } from 'json-schema'
70
69
 
71
70
  defineEmits([...useDialogPluginComponent.emits])
72
71