@d-mok/quasar-app-extension-quasar-axe 3.1.30 → 3.1.32

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,25 +1,23 @@
1
1
  {
2
2
  "name": "@d-mok/quasar-app-extension-quasar-axe",
3
- "version": "3.1.30",
3
+ "version": "3.1.32",
4
4
  "description": "A Quasar App Extension",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
7
7
  "publish-package": "npm version patch --no-git-tag-version && npm publish --access public"
8
8
  },
9
9
  "dependencies": {
10
- "@handsontable/vue3": "^14.0.0",
10
+ "@handsontable/vue3": "^15.2.0",
11
11
  "@supabase/supabase-js": "^2.39.1",
12
12
  "@types/lodash": "^4.14.195",
13
- "@types/papaparse": "^5.3.7",
14
13
  "@types/webpack-env": "^1.18.1",
15
14
  "@vueuse/core": "^10.7.0",
16
15
  "@vueuse/integrations": "^10.7.0",
17
16
  "@vueuse/router": "^10.7.0",
18
- "handsontable": "^14.0.0",
17
+ "handsontable": "^15.2.0",
19
18
  "jszip": "^3.10.1",
20
19
  "lodash": "^4.17.21",
21
- "papaparse": "^5.4.1",
22
- "sapphire-js": "^2.1.37",
20
+ "sapphire-js": "^2.1.39",
23
21
  "sortablejs": "^1.15.0",
24
22
  "valibot": "^1.0.0"
25
23
  },
@@ -162,8 +162,7 @@ type FormFlat<T extends FormPrefill> = {
162
162
  }
163
163
 
164
164
  /**
165
- * Ask for an array of objects by CSV.
166
- * Input object must have the same keys as sample.
165
+ * Ask for an objects.
167
166
  */
168
167
  export async function askForm<T extends FormPrefill>(
169
168
  title: string,
@@ -7,7 +7,7 @@
7
7
  <q-card
8
8
  :style="{
9
9
  'max-width': '100%',
10
- width: Object.keys(sample).length * 200 + 200 + 'px',
10
+ width: TOTAL_WIDTH + 'px',
11
11
  }"
12
12
  >
13
13
  <q-card-section>
@@ -17,7 +17,7 @@
17
17
  :style="{
18
18
  height: '50vh',
19
19
  'max-width': '100%',
20
- width: Object.keys(sample).length * 200 + 200 + 'px',
20
+ width: TOTAL_WIDTH + 'px',
21
21
  }"
22
22
  flat
23
23
  >
@@ -64,7 +64,6 @@ import handson from './handson.vue'
64
64
  import { useDialogPluginComponent } from 'quasar'
65
65
  import { ref } from 'vue'
66
66
  import { clone } from './schema'
67
- import { unparseCSV } from '../../csv'
68
67
  import { copyToClipboard } from 'quasar'
69
68
  import * as v from 'valibot'
70
69
 
@@ -105,43 +104,43 @@ setTimeout(() => {
105
104
 
106
105
  let dummy = ref(content.map($ => clone($, Object.keys(sample))))
107
106
 
107
+ const StandardSchema = v.object(
108
+ Object.mapValues(sample, val => {
109
+ if (typeof val === 'string') return v.string()
110
+ if (typeof val === 'number') return v.number() // not accept NaN
111
+ if (typeof val === 'boolean') return v.boolean()
112
+ return v.never('Invalid type:' + val)
113
+ })
114
+ )
115
+
116
+ const EmptySchema = v.object(
117
+ Object.mapValues(sample, val => {
118
+ if (typeof val === 'string') return v.literal('')
119
+ if (typeof val === 'number') return v.nan()
120
+ if (typeof val === 'boolean') return v.literal(false)
121
+ return v.never('Invalid type:' + val)
122
+ })
123
+ )
124
+
108
125
  function checkSpec(row: any): boolean {
109
- return v.is(
110
- v.union([
111
- v.object(
112
- Object.mapValues(sample, val => {
113
- if (typeof val === 'string') return v.string()
114
- if (typeof val === 'number') return v.number() // not accept NaN
115
- if (typeof val === 'boolean') return v.boolean()
116
- return v.never('Invalid type:' + val)
117
- })
118
- ),
119
- v.object(
120
- Object.mapValues(sample, val => {
121
- if (typeof val === 'string') return v.literal('')
122
- if (typeof val === 'number') return v.nan()
123
- if (typeof val === 'boolean') return v.literal(false)
124
- return v.never('Invalid type:' + val)
125
- })
126
- ),
127
- ]),
128
-
129
- row
130
- )
126
+ return v.is(v.union([StandardSchema, EmptySchema]), row)
131
127
  }
132
128
 
133
129
  function err(): string | false {
134
130
  for (let i = 0; i < dummy.value.length; i++) {
135
131
  if (!checkSpec(dummy.value[i])) {
136
- return `row ${
137
- i + 1
138
- }: spec error<br>spec sample:<br>${JSON.stringify(sample)}`
132
+ return [
133
+ `row ${i + 1}:`,
134
+ 'spec error!',
135
+ 'spec sample:',
136
+ JSON.stringify(sample),
137
+ ].join('<br>')
139
138
  }
140
139
  }
141
140
  for (let i = 0; i < dummy.value.length; i++) {
142
141
  for (let [f, msg] of validators) {
143
142
  if (!f(dummy.value[i])) {
144
- return `row ${i + 1}: ${msg}`
143
+ return [`row ${i + 1}:`, msg].join('<br>')
145
144
  }
146
145
  }
147
146
  }
@@ -155,13 +154,25 @@ function err(): string | false {
155
154
 
156
155
  function filterBlank(rows: row[]): row[] {
157
156
  if (!allowAddRow) return rows
158
- return rows.unmatch(r =>
159
- Object.values(r).every(v => Number.isNaN(v) || v === '' || v === false)
160
- )
157
+ return rows.unmatch(r => v.is(EmptySchema, r))
161
158
  }
162
159
 
163
160
  function copy() {
164
- let csv = unparseCSV(dummy.value, '\t')
161
+ let csv = dummy.value.toCSV()
165
162
  copyToClipboard(csv)
166
163
  }
164
+
165
+ const TOTAL_WIDTH =
166
+ 200 +
167
+ Object.values(
168
+ [...content, Object.mapValues(sample, (v, k) => k)]
169
+ .map(r => Object.mapValues(r, v => v.toString().length))
170
+ .reduce((acc, obj) => {
171
+ for (const key in acc) {
172
+ acc[key] += obj[key]
173
+ }
174
+ return acc
175
+ })
176
+ ).sum() *
177
+ 13
167
178
  </script>
@@ -17,7 +17,7 @@
17
17
  :contextMenu="
18
18
  allowAddRow ? ['row_above', 'row_below', 'remove_row'] : []
19
19
  "
20
- ></hot-table>
20
+ />
21
21
  </template>
22
22
 
23
23
  <script lang="ts" setup>
@@ -15,8 +15,6 @@ if (process.env.DEBUGGING) {
15
15
  globalThis.supabase = supabase
16
16
  }
17
17
 
18
- export { unparseCSV } from './csv'
19
-
20
18
  export { zipCreate, zipDownload } from './zip'
21
19
  export type { zipFolder } from './zip'
22
20
 
@@ -1,16 +0,0 @@
1
- import Papa from 'papaparse'
2
-
3
- export function unparseCSV(
4
- arr: Record<string, any>[],
5
- delimiter: string
6
- ): string {
7
- return Papa.unparse(arr, {
8
- quotes: false, //or array of booleans
9
- quoteChar: '"',
10
- escapeChar: '"',
11
- delimiter,
12
- header: true,
13
- newline: '\r\n',
14
- skipEmptyLines: false, //other option is 'greedy', meaning skip delimiters, quotes, and whitespace.
15
- })
16
- }