@d-mok/quasar-app-extension-quasar-axe 2.1.5 → 3.0.1

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.
Files changed (51) hide show
  1. package/.gitattributes +2 -2
  2. package/package.json +46 -46
  3. package/shims-vue.d.ts +5 -5
  4. package/src/index.js +31 -31
  5. package/src/install.js +6 -6
  6. package/src/prompts.js +3 -3
  7. package/src/templates/src/boot/axe/AutoReg.ts +18 -18
  8. package/src/templates/src/boot/axe/AutoRoute.ts +40 -40
  9. package/src/templates/src/boot/axe/Interceptor.ts +86 -86
  10. package/src/templates/src/boot/axe/components/QxBtn.vue +30 -30
  11. package/src/templates/src/boot/axe/components/QxBtnIcon.vue +11 -11
  12. package/src/templates/src/boot/axe/components/QxBtnToggle.vue +42 -42
  13. package/src/templates/src/boot/axe/components/QxFloatBtn.vue +46 -46
  14. package/src/templates/src/boot/axe/components/QxImg.vue +22 -22
  15. package/src/templates/src/boot/axe/components/QxInputAutocomplete.vue +51 -51
  16. package/src/templates/src/boot/axe/components/QxLayout.vue +123 -123
  17. package/src/templates/src/boot/axe/components/QxMenuItem.vue +36 -36
  18. package/src/templates/src/boot/axe/components/QxPlate.vue +151 -151
  19. package/src/templates/src/boot/axe/components/QxRadio.vue +42 -42
  20. package/src/templates/src/boot/axe/components/QxSelect.vue +57 -57
  21. package/src/templates/src/boot/axe/components/QxSignoutBtn.vue +16 -16
  22. package/src/templates/src/boot/axe/components/QxSortable.vue +65 -65
  23. package/src/templates/src/boot/axe/components/QxText.vue +37 -37
  24. package/src/templates/src/boot/axe/components/QxWidget.vue +67 -67
  25. package/src/templates/src/utils/csv.ts +16 -16
  26. package/src/templates/src/utils/dialog/advanced.ts +213 -213
  27. package/src/templates/src/utils/dialog/basic.ts +164 -164
  28. package/src/templates/src/utils/dialog/custom/dialogBtn.vue +49 -49
  29. package/src/templates/src/utils/dialog/custom/dialogForm.vue +128 -128
  30. package/src/templates/src/utils/dialog/custom/dialogTable.vue +123 -123
  31. package/src/templates/src/utils/dialog/custom/dialogTextarea.vue +54 -54
  32. package/src/templates/src/utils/dialog/custom/handson.vue +133 -133
  33. package/src/templates/src/utils/dialog/custom/schema.ts +96 -96
  34. package/src/templates/src/utils/dialog/index.ts +4 -4
  35. package/src/templates/src/utils/dialog/tool.ts +11 -11
  36. package/src/templates/src/utils/index.ts +20 -21
  37. package/src/templates/src/utils/notify.ts +35 -35
  38. package/src/templates/src/utils/puppets/builder/index.ts +226 -226
  39. package/src/templates/src/utils/puppets/builder/ui.ts +31 -31
  40. package/src/templates/src/utils/puppets/core/db.ts +157 -157
  41. package/src/templates/src/utils/puppets/core/index.ts +47 -47
  42. package/src/templates/src/utils/puppets/entity.ts +45 -45
  43. package/src/templates/src/utils/puppets/index.ts +2 -2
  44. package/src/templates/src/utils/puppets/table.ts +229 -229
  45. package/src/templates/src/utils/puppets/type.ts +13 -13
  46. package/src/templates/src/utils/settings.ts +20 -20
  47. package/src/templates/src/utils/supabase.ts +130 -130
  48. package/src/templates/src/utils/supabase2.ts +128 -123
  49. package/src/templates/src/utils/zip.ts +43 -43
  50. package/src/uninstall.js +5 -5
  51. package/tsconfig.json +76 -76
package/.gitattributes CHANGED
@@ -1,2 +1,2 @@
1
- # Auto detect text files and perform LF normalization
2
- * text=auto
1
+ # Auto detect text files and perform LF normalization
2
+ * text=auto
package/package.json CHANGED
@@ -1,46 +1,46 @@
1
- {
2
- "name": "@d-mok/quasar-app-extension-quasar-axe",
3
- "version": "2.1.5",
4
- "description": "A Quasar App Extension",
5
- "author": "d-mok <49301824+d-mok@users.noreply.github.com>",
6
- "license": "MIT",
7
- "main": "src/index.js",
8
- "scripts": {
9
- "publish-package": "npm version patch --no-git-tag-version && npm publish --access public"
10
- },
11
- "engines": {
12
- "node": ">= 8.9.0",
13
- "npm": ">= 5.6.0",
14
- "yarn": ">= 1.6.0"
15
- },
16
- "dependencies": {
17
- "@handsontable/vue3": "^12.1.0",
18
- "@supabase/supabase-js": "^1.35.4",
19
- "@types/lodash": "^4.14.182",
20
- "@types/papaparse": "^5.3.2",
21
- "@types/webpack-env": "^1.17.0",
22
- "@vueuse/core": "^9.1.0",
23
- "handsontable": "^12.1.0",
24
- "jszip": "^3.9.0",
25
- "lodash": "^4.17.21",
26
- "papaparse": "^5.3.2",
27
- "sapphire-js": "^2.0.4",
28
- "vuedraggable": "^4.1.0"
29
- },
30
- "devDependencies": {
31
- "@quasar/app": "^3.3.3",
32
- "@quasar/extras": "^1.14.2",
33
- "@types/node": "^17.0.45",
34
- "core-js": "^3.23.3",
35
- "quasar": "^2.7.3",
36
- "typescript": "^4.7.4",
37
- "vite": "^2.9.12"
38
- },
39
- "prettier": {
40
- "tabWidth": 4,
41
- "semi": false,
42
- "singleQuote": true,
43
- "arrowParens": "avoid",
44
- "singleAttributePerLine": true
45
- }
46
- }
1
+ {
2
+ "name": "@d-mok/quasar-app-extension-quasar-axe",
3
+ "version": "3.0.1",
4
+ "description": "A Quasar App Extension",
5
+ "author": "d-mok <49301824+d-mok@users.noreply.github.com>",
6
+ "license": "MIT",
7
+ "main": "src/index.js",
8
+ "scripts": {
9
+ "publish-package": "npm version patch --no-git-tag-version && npm publish --access public"
10
+ },
11
+ "engines": {
12
+ "node": ">= 8.9.0",
13
+ "npm": ">= 5.6.0",
14
+ "yarn": ">= 1.6.0"
15
+ },
16
+ "dependencies": {
17
+ "@handsontable/vue3": "^12.1.0",
18
+ "@supabase/supabase-js": "^2.24.0",
19
+ "@types/lodash": "^4.14.182",
20
+ "@types/papaparse": "^5.3.2",
21
+ "@types/webpack-env": "^1.17.0",
22
+ "@vueuse/core": "^9.1.0",
23
+ "handsontable": "^12.1.0",
24
+ "jszip": "^3.9.0",
25
+ "lodash": "^4.17.21",
26
+ "papaparse": "^5.3.2",
27
+ "sapphire-js": "^2.0.4",
28
+ "vuedraggable": "^4.1.0"
29
+ },
30
+ "devDependencies": {
31
+ "@quasar/app": "^3.3.3",
32
+ "@quasar/extras": "^1.14.2",
33
+ "@types/node": "^17.0.45",
34
+ "core-js": "^3.23.3",
35
+ "quasar": "^2.7.3",
36
+ "typescript": "^4.7.4",
37
+ "vite": "^2.9.12"
38
+ },
39
+ "prettier": {
40
+ "tabWidth": 4,
41
+ "semi": false,
42
+ "singleQuote": true,
43
+ "arrowParens": "avoid",
44
+ "singleAttributePerLine": true
45
+ }
46
+ }
package/shims-vue.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- declare module '*.vue' {
2
- import { ComponentOptions } from 'vue'
3
- const component: ComponentOptions
4
- export default component
5
- }
1
+ declare module '*.vue' {
2
+ import { ComponentOptions } from 'vue'
3
+ const component: ComponentOptions
4
+ export default component
5
+ }
package/src/index.js CHANGED
@@ -1,31 +1,31 @@
1
- function extendQuasarConf(conf, prompts) {
2
- for (let b of ['AutoRoute', 'AutoReg', 'Interceptor'])
3
- conf.boot.unshift(`axe/${b}`)
4
- console.log('[QuasarAxe] Config pushed Boots')
5
-
6
- conf.framework.plugins.push(
7
- 'AppVisibility',
8
- 'Notify',
9
- 'Dialog',
10
- 'LoadingBar'
11
- )
12
- console.log('[QuasarAxe] Config pushed framework.plugins')
13
-
14
- conf.framework.config.loadingBar = {
15
- position: 'top',
16
- color: 'white',
17
- size: '5px',
18
- skipHijack: true,
19
- }
20
- conf.framework.config.notify = {}
21
- console.log('[QuasarAxe] Config pushed framework.config')
22
-
23
- conf.animations.push('fadeIn', 'fadeOut', 'zoomIn', 'zoomOut')
24
- console.log('[QuasarAxe] Config pushed animations')
25
- }
26
-
27
- module.exports = function (api) {
28
- api.compatibleWith('quasar', '^2.0.0')
29
- api.compatibleWith('@quasar/app-vite', '^1.0.0')
30
- api.extendQuasarConf(conf => extendQuasarConf(conf, api.prompts))
31
- }
1
+ function extendQuasarConf(conf, prompts) {
2
+ for (let b of ['AutoRoute', 'AutoReg', 'Interceptor'])
3
+ conf.boot.unshift(`axe/${b}`)
4
+ console.log('[QuasarAxe] Config pushed Boots')
5
+
6
+ conf.framework.plugins.push(
7
+ 'AppVisibility',
8
+ 'Notify',
9
+ 'Dialog',
10
+ 'LoadingBar'
11
+ )
12
+ console.log('[QuasarAxe] Config pushed framework.plugins')
13
+
14
+ conf.framework.config.loadingBar = {
15
+ position: 'top',
16
+ color: 'white',
17
+ size: '5px',
18
+ skipHijack: true,
19
+ }
20
+ conf.framework.config.notify = {}
21
+ console.log('[QuasarAxe] Config pushed framework.config')
22
+
23
+ conf.animations.push('fadeIn', 'fadeOut', 'zoomIn', 'zoomOut')
24
+ console.log('[QuasarAxe] Config pushed animations')
25
+ }
26
+
27
+ module.exports = function (api) {
28
+ api.compatibleWith('quasar', '^2.0.0')
29
+ api.compatibleWith('@quasar/app-vite', '^1.0.0')
30
+ api.extendQuasarConf(conf => extendQuasarConf(conf, api.prompts))
31
+ }
package/src/install.js CHANGED
@@ -1,6 +1,6 @@
1
- module.exports = function (api) {
2
- api.compatibleWith('quasar', '^2.0.0')
3
- api.compatibleWith('@quasar/app-vite', '^1.0.0')
4
- api.render('./templates')
5
- api.onExitLog('Thanks for installing quasar-axe!')
6
- }
1
+ module.exports = function (api) {
2
+ api.compatibleWith('quasar', '^2.0.0')
3
+ api.compatibleWith('@quasar/app-vite', '^1.0.0')
4
+ api.render('./templates')
5
+ api.onExitLog('Thanks for installing quasar-axe!')
6
+ }
package/src/prompts.js CHANGED
@@ -1,3 +1,3 @@
1
- module.exports = function () {
2
- return [];
3
- };
1
+ module.exports = function () {
2
+ return [];
3
+ };
@@ -1,18 +1,18 @@
1
- import { boot } from 'quasar/wrappers'
2
-
3
- function pascal(s: string): string {
4
- return s
5
- .split('/')
6
- .pop()!
7
- .replace(/\.\w+$/, '')
8
- }
9
-
10
- console.log('[QuasarAxe] Run Boot AutoReg')
11
-
12
- const components = import.meta.globEager('src/**/*.vue')
13
-
14
- export default boot(({ app }) => {
15
- for (let path in components) {
16
- app.component(pascal(path), components[path].default)
17
- }
18
- })
1
+ import { boot } from 'quasar/wrappers'
2
+
3
+ function pascal(s: string): string {
4
+ return s
5
+ .split('/')
6
+ .pop()!
7
+ .replace(/\.\w+$/, '')
8
+ }
9
+
10
+ console.log('[QuasarAxe] Run Boot AutoReg')
11
+
12
+ const components = import.meta.globEager('src/**/*.vue')
13
+
14
+ export default boot(({ app }) => {
15
+ for (let path in components) {
16
+ app.component(pascal(path), components[path].default)
17
+ }
18
+ })
@@ -1,40 +1,40 @@
1
- import { boot } from 'quasar/wrappers'
2
-
3
- function pascal(s: string): string {
4
- return s
5
- .split('/')
6
- .pop()!
7
- .replace(/\.\w+$/, '')
8
- }
9
-
10
- if (!process.env.HOME_ROUTE) throw 'Missing HOME_ROUTE in process.env!'
11
-
12
- const HOME_ROUTE = process.env.HOME_ROUTE ?? '/'
13
-
14
- console.log('[QuasarAxe] Run Boot AutoRoute')
15
-
16
- const pages = import.meta.globEager('src/**/pages/**/*.vue')
17
-
18
- const routes = Object.keys(pages).map(path => ({
19
- path: pascal(path).toLowerCase(),
20
- component: pages[path].default,
21
- }))
22
-
23
- const _pages = import.meta.globEager('src/**/_*.vue')
24
-
25
- const _routes = Object.keys(_pages).map(path => ({
26
- path: pascal(path).toLowerCase().replace('_', ''),
27
- component: _pages[path].default,
28
- }))
29
-
30
- export default boot(({ app, router }) => {
31
- router.addRoute({
32
- path: '/',
33
- component: () => import('src/layouts/Layout.vue'),
34
- children: [...routes, ..._routes, { path: '/', redirect: HOME_ROUTE }],
35
- })
36
- router.addRoute({
37
- path: '/:catchAll(.*)*',
38
- redirect: HOME_ROUTE,
39
- })
40
- })
1
+ import { boot } from 'quasar/wrappers'
2
+
3
+ function pascal(s: string): string {
4
+ return s
5
+ .split('/')
6
+ .pop()!
7
+ .replace(/\.\w+$/, '')
8
+ }
9
+
10
+ if (!process.env.HOME_ROUTE) throw 'Missing HOME_ROUTE in process.env!'
11
+
12
+ const HOME_ROUTE = process.env.HOME_ROUTE ?? '/'
13
+
14
+ console.log('[QuasarAxe] Run Boot AutoRoute')
15
+
16
+ const pages = import.meta.globEager('src/**/pages/**/*.vue')
17
+
18
+ const routes = Object.keys(pages).map(path => ({
19
+ path: pascal(path).toLowerCase(),
20
+ component: pages[path].default,
21
+ }))
22
+
23
+ const _pages = import.meta.globEager('src/**/_*.vue')
24
+
25
+ const _routes = Object.keys(_pages).map(path => ({
26
+ path: pascal(path).toLowerCase().replace('_', ''),
27
+ component: _pages[path].default,
28
+ }))
29
+
30
+ export default boot(({ app, router }) => {
31
+ router.addRoute({
32
+ path: '/',
33
+ component: () => import('src/layouts/Layout.vue'),
34
+ children: [...routes, ..._routes, { path: '/', redirect: HOME_ROUTE }],
35
+ })
36
+ router.addRoute({
37
+ path: '/:catchAll(.*)*',
38
+ redirect: HOME_ROUTE,
39
+ })
40
+ })
@@ -1,86 +1,86 @@
1
- import { boot } from 'quasar/wrappers'
2
- import { LoadingBar } from 'quasar'
3
-
4
- console.log('[QuasarAxe] Run Boot Interceptor')
5
-
6
- declare global {
7
- interface XMLHttpRequest {
8
- _url: string
9
- }
10
- }
11
-
12
- export function setAjaxInterceptor(
13
- onStart: (_: XMLHttpRequest) => void,
14
- onEnd: (_: XMLHttpRequest) => void
15
- ) {
16
- var open = window.XMLHttpRequest.prototype.open
17
- var send = window.XMLHttpRequest.prototype.send
18
-
19
- window.XMLHttpRequest.prototype.open = function (...args: any) {
20
- this._url = args[1] ?? ''
21
- open.apply(this, args)
22
- }
23
-
24
- window.XMLHttpRequest.prototype.send = function (...args: any) {
25
- var request = this
26
- onStart(request)
27
-
28
- var intervalId = window.setInterval(function () {
29
- if (request.readyState != 4) return
30
- onEnd(request)
31
- clearInterval(intervalId)
32
- }, 10)
33
-
34
- return send.apply(this, args)
35
- }
36
- }
37
-
38
- export function setFetchInterceptor(
39
- onStart: (..._: Parameters<typeof window.fetch>) => void,
40
- onEnd: (..._: Parameters<typeof window.fetch>) => void
41
- ) {
42
- const oldFetch = window.fetch
43
-
44
- window.fetch = async (...args) => {
45
- onStart(...args)
46
-
47
- const response = await oldFetch(...args)
48
-
49
- onEnd(...args)
50
-
51
- // /* work with the cloned response in a separate promise
52
- // chain -- could use the same chain with `await`. */
53
- // response
54
- // .clone()
55
- // .json()
56
- // .then(body => console.log("intercepted response:", body))
57
- // .catch(err => console.error(err))
58
-
59
- /* the original response can be resolved unmodified: */
60
- return response
61
- }
62
- }
63
-
64
- function isLogRocket(request: XMLHttpRequest): boolean {
65
- return request._url.startsWith('https://r.lr-ingest.io')
66
- }
67
-
68
- setAjaxInterceptor(
69
- request => {
70
- if (!isLogRocket(request)) {
71
- LoadingBar.start()
72
- }
73
- },
74
- request => {
75
- if (!isLogRocket(request)) {
76
- LoadingBar.stop()
77
- }
78
- }
79
- )
80
-
81
- setFetchInterceptor(
82
- () => LoadingBar.start(),
83
- () => LoadingBar.stop()
84
- )
85
-
86
- export default boot(({ app, router }) => {})
1
+ import { boot } from 'quasar/wrappers'
2
+ import { LoadingBar } from 'quasar'
3
+
4
+ console.log('[QuasarAxe] Run Boot Interceptor')
5
+
6
+ declare global {
7
+ interface XMLHttpRequest {
8
+ _url: string
9
+ }
10
+ }
11
+
12
+ export function setAjaxInterceptor(
13
+ onStart: (_: XMLHttpRequest) => void,
14
+ onEnd: (_: XMLHttpRequest) => void
15
+ ) {
16
+ var open = window.XMLHttpRequest.prototype.open
17
+ var send = window.XMLHttpRequest.prototype.send
18
+
19
+ window.XMLHttpRequest.prototype.open = function (...args: any) {
20
+ this._url = args[1] ?? ''
21
+ open.apply(this, args)
22
+ }
23
+
24
+ window.XMLHttpRequest.prototype.send = function (...args: any) {
25
+ var request = this
26
+ onStart(request)
27
+
28
+ var intervalId = window.setInterval(function () {
29
+ if (request.readyState != 4) return
30
+ onEnd(request)
31
+ clearInterval(intervalId)
32
+ }, 10)
33
+
34
+ return send.apply(this, args)
35
+ }
36
+ }
37
+
38
+ export function setFetchInterceptor(
39
+ onStart: (..._: Parameters<typeof window.fetch>) => void,
40
+ onEnd: (..._: Parameters<typeof window.fetch>) => void
41
+ ) {
42
+ const oldFetch = window.fetch
43
+
44
+ window.fetch = async (...args) => {
45
+ onStart(...args)
46
+
47
+ const response = await oldFetch(...args)
48
+
49
+ onEnd(...args)
50
+
51
+ // /* work with the cloned response in a separate promise
52
+ // chain -- could use the same chain with `await`. */
53
+ // response
54
+ // .clone()
55
+ // .json()
56
+ // .then(body => console.log("intercepted response:", body))
57
+ // .catch(err => console.error(err))
58
+
59
+ /* the original response can be resolved unmodified: */
60
+ return response
61
+ }
62
+ }
63
+
64
+ function isLogRocket(request: XMLHttpRequest): boolean {
65
+ return request._url.startsWith('https://r.lr-ingest.io')
66
+ }
67
+
68
+ setAjaxInterceptor(
69
+ request => {
70
+ if (!isLogRocket(request)) {
71
+ LoadingBar.start()
72
+ }
73
+ },
74
+ request => {
75
+ if (!isLogRocket(request)) {
76
+ LoadingBar.stop()
77
+ }
78
+ }
79
+ )
80
+
81
+ setFetchInterceptor(
82
+ () => LoadingBar.start(),
83
+ () => LoadingBar.stop()
84
+ )
85
+
86
+ export default boot(({ app, router }) => {})
@@ -1,30 +1,30 @@
1
- <template>
2
- <q-btn v-bind="$attrs">
3
- <q-tooltip
4
- class="text-body1"
5
- v-if="tooltip"
6
- :delay="150"
7
- >{{ tooltip }}</q-tooltip
8
- >
9
- <q-badge
10
- v-if="badge !== undefined"
11
- floating
12
- rounded
13
- :color="badgeColor"
14
- >{{ badge }}</q-badge
15
- >
16
- </q-btn>
17
- </template>
18
-
19
- <script lang="ts" setup>
20
- const props = withDefaults(
21
- defineProps<{
22
- tooltip?: string
23
- badge?: string | number
24
- badgeColor?: string
25
- }>(),
26
- {
27
- badgeColor: 'red',
28
- }
29
- )
30
- </script>
1
+ <template>
2
+ <q-btn v-bind="$attrs">
3
+ <q-tooltip
4
+ class="text-body1"
5
+ v-if="tooltip"
6
+ :delay="150"
7
+ >{{ tooltip }}</q-tooltip
8
+ >
9
+ <q-badge
10
+ v-if="badge !== undefined"
11
+ floating
12
+ rounded
13
+ :color="badgeColor"
14
+ >{{ badge }}</q-badge
15
+ >
16
+ </q-btn>
17
+ </template>
18
+
19
+ <script lang="ts" setup>
20
+ const props = withDefaults(
21
+ defineProps<{
22
+ tooltip?: string
23
+ badge?: string | number
24
+ badgeColor?: string
25
+ }>(),
26
+ {
27
+ badgeColor: 'red',
28
+ }
29
+ )
30
+ </script>
@@ -1,11 +1,11 @@
1
- <template>
2
- <qx-btn
3
- v-bind="$attrs"
4
- flat
5
- dense
6
- />
7
- </template>
8
-
9
- <script lang="ts" setup>
10
- // this component follow qx-btn, with default flat and dense
11
- </script>
1
+ <template>
2
+ <qx-btn
3
+ v-bind="$attrs"
4
+ flat
5
+ dense
6
+ />
7
+ </template>
8
+
9
+ <script lang="ts" setup>
10
+ // this component follow qx-btn, with default flat and dense
11
+ </script>
@@ -1,42 +1,42 @@
1
- <template>
2
- <q-btn-toggle
3
- v-model="selected"
4
- :options="opts"
5
- v-bind="$attrs"
6
- />
7
- </template>
8
-
9
- <script lang="ts" setup>
10
- import { computed } from 'vue'
11
- import { useVModel } from '@vueuse/core'
12
-
13
- const props = withDefaults(
14
- defineProps<{
15
- modelValue: any
16
- options: any[]
17
- optionLabel?: string | ((_: any) => string)
18
- }>(),
19
- {}
20
- )
21
- const emits = defineEmits(['update:modelValue'])
22
-
23
- const selected = useVModel(props, 'modelValue', emits)
24
-
25
- function getLabelFunc(labeler?: string | ((_: any) => string)) {
26
- if (typeof labeler === 'string') {
27
- return ($: any) => String($[labeler])
28
- }
29
- if (typeof labeler === 'function') {
30
- return labeler
31
- }
32
- return ($: any) => String($)
33
- }
34
-
35
- let opts = computed(() => {
36
- let f = getLabelFunc(props.optionLabel)
37
- return props.options.map($ => {
38
- let str = f($)
39
- return { label: str, value: str }
40
- })
41
- })
42
- </script>
1
+ <template>
2
+ <q-btn-toggle
3
+ v-model="selected"
4
+ :options="opts"
5
+ v-bind="$attrs"
6
+ />
7
+ </template>
8
+
9
+ <script lang="ts" setup>
10
+ import { computed } from 'vue'
11
+ import { useVModel } from '@vueuse/core'
12
+
13
+ const props = withDefaults(
14
+ defineProps<{
15
+ modelValue: any
16
+ options: any[]
17
+ optionLabel?: string | ((_: any) => string)
18
+ }>(),
19
+ {}
20
+ )
21
+ const emits = defineEmits(['update:modelValue'])
22
+
23
+ const selected = useVModel(props, 'modelValue', emits)
24
+
25
+ function getLabelFunc(labeler?: string | ((_: any) => string)) {
26
+ if (typeof labeler === 'string') {
27
+ return ($: any) => String($[labeler])
28
+ }
29
+ if (typeof labeler === 'function') {
30
+ return labeler
31
+ }
32
+ return ($: any) => String($)
33
+ }
34
+
35
+ let opts = computed(() => {
36
+ let f = getLabelFunc(props.optionLabel)
37
+ return props.options.map($ => {
38
+ let str = f($)
39
+ return { label: str, value: str }
40
+ })
41
+ })
42
+ </script>