@d-mok/quasar-app-extension-quasar-axe 3.1.25 → 3.1.26

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": "3.1.25",
3
+ "version": "3.1.26",
4
4
  "description": "A Quasar App Extension",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -23,7 +23,7 @@
23
23
  >
24
24
  <handson
25
25
  v-model="dummy"
26
- :spec="spec"
26
+ :sample="sample"
27
27
  :allowAddRow="allowAddRow"
28
28
  v-if="exist"
29
29
  ></handson>
@@ -106,20 +106,13 @@ setTimeout(() => {
106
106
 
107
107
  let dummy = ref(content.map($ => clone($, Object.keys(sample))))
108
108
 
109
- let spec = Object.mapValues(sample, v => {
110
- if (typeof v === 'string') return 'string'
111
- if (typeof v === 'number') return 'number'
112
- if (typeof v === 'boolean') return 'boolean'
113
- throw 'non-primitive type in sample'
114
- })
115
-
116
109
  function checkSpec(row: any): boolean {
117
110
  return v.is(
118
111
  v.object(
119
- Object.mapValues(spec, val => {
120
- if (val === 'string') return v.string()
121
- if (val === 'number') return v.number()
122
- if (val === 'boolean') return v.boolean()
112
+ Object.mapValues(sample, val => {
113
+ if (typeof val === 'string') return v.string()
114
+ if (typeof val === 'number') return v.number()
115
+ if (typeof val === 'boolean') return v.boolean()
123
116
  return v.never('Invalid type:' + val)
124
117
  })
125
118
  ),
@@ -130,7 +123,7 @@ function checkSpec(row: any): boolean {
130
123
  function err(): string | false {
131
124
  for (let i = 0; i < dummy.value.length; i++) {
132
125
  if (!checkSpec(dummy.value[i])) {
133
- return `row ${i + 1}: spec error<br>spec:${JSON.stringify(spec)}`
126
+ return `row ${i + 1}: spec error<br>spec:${JSON.stringify(sample)}`
134
127
  }
135
128
  }
136
129
  for (let i = 0; i < dummy.value.length; i++) {
@@ -7,7 +7,7 @@
7
7
  width="100%"
8
8
  stretchH="all"
9
9
  :data="content"
10
- :colHeaders="Object.keys(spec)"
10
+ :colHeaders="Object.keys(sample)"
11
11
  :columns="columns()"
12
12
  :rowHeaders="true"
13
13
  :afterChange="shake"
@@ -39,20 +39,20 @@ const content = defineModel<Record<string, string | number | boolean>[]>({
39
39
  required: true,
40
40
  })
41
41
 
42
- const { spec, allowAddRow } = defineProps<{
43
- spec: Record<string, 'string' | 'number' | 'boolean'>
42
+ const { sample, allowAddRow } = defineProps<{
43
+ sample: Record<string, string | number | boolean>
44
44
  allowAddRow: boolean
45
45
  }>()
46
46
 
47
47
  function columns() {
48
- return Object.entries(spec).map(([field, type]) => ({
48
+ return Object.entries(sample).map(([field, val]) => ({
49
49
  data: field,
50
50
  type:
51
- {
52
- number: 'numeric',
53
- string: 'text',
54
- boolean: 'checkbox',
55
- }[type] ?? 'text',
51
+ typeof val === 'boolean'
52
+ ? 'checkbox'
53
+ : typeof val === 'number'
54
+ ? 'numeric'
55
+ : 'text',
56
56
  allowEmpty: false,
57
57
  }))
58
58
  }
@@ -80,7 +80,7 @@ function coerceBoolean(x: any): boolean {
80
80
  function shake(): void {
81
81
  for (let row of content.value) {
82
82
  for (let [k, v] of Object.entries(row)) {
83
- let type = spec[k]
83
+ let type = typeof sample[k]
84
84
  if (type === 'string') row[k] = coerceString(v)
85
85
  if (type === 'number') row[k] = coerceNumber(v)
86
86
  if (type === 'boolean') row[k] = coerceBoolean(v)