@shwfed/nuxt 0.7.7 → 0.7.9

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 (100) hide show
  1. package/dist/module.json +1 -1
  2. package/dist/module.mjs +22 -32
  3. package/dist/runtime/components/app.d.vue.ts +0 -2
  4. package/dist/runtime/components/app.vue +1 -7
  5. package/dist/runtime/components/app.vue.d.ts +0 -2
  6. package/dist/runtime/components/fields.d.vue.ts +155 -0
  7. package/dist/runtime/components/fields.vue +312 -0
  8. package/dist/runtime/components/fields.vue.d.ts +155 -0
  9. package/dist/runtime/components/ui/button-group/ButtonGroupSeparator.vue +1 -1
  10. package/dist/runtime/components/ui/button-group/ButtonGroupText.vue +1 -1
  11. package/dist/runtime/components/ui/calendar/Calendar.d.vue.ts +5 -12
  12. package/dist/runtime/components/ui/calendar/Calendar.vue +77 -92
  13. package/dist/runtime/components/ui/calendar/Calendar.vue.d.ts +5 -12
  14. package/dist/runtime/components/ui/calendar/CalendarCellTrigger.vue +1 -1
  15. package/dist/runtime/components/ui/calendar/index.d.ts +1 -1
  16. package/dist/runtime/components/ui/command/CommandGroup.vue +4 -0
  17. package/dist/runtime/components/ui/dialog/DialogOverlay.vue +1 -1
  18. package/dist/runtime/components/ui/dropdown-menu/DropdownMenuCheckboxItem.vue +1 -1
  19. package/dist/runtime/components/ui/dropdown-menu/DropdownMenuSubTrigger.vue +1 -1
  20. package/dist/runtime/components/ui/field/FieldDescription.vue +1 -1
  21. package/dist/runtime/components/ui/field/FieldError.vue +1 -1
  22. package/dist/runtime/components/ui/field/FieldLabel.vue +1 -1
  23. package/dist/runtime/components/ui/field/FieldSeparator.vue +1 -1
  24. package/dist/runtime/components/ui/field/index.js +7 -5
  25. package/dist/runtime/components/ui/input/Input.vue +1 -1
  26. package/dist/runtime/components/ui/input-group/InputGroup.vue +3 -0
  27. package/dist/runtime/components/ui/input-group/InputGroupCombobox.d.vue.ts +4 -1
  28. package/dist/runtime/components/ui/input-group/InputGroupCombobox.vue +10 -4
  29. package/dist/runtime/components/ui/input-group/InputGroupCombobox.vue.d.ts +4 -1
  30. package/dist/runtime/components/ui/input-group/InputGroupComboboxInput.vue +3 -1
  31. package/dist/runtime/components/ui/input-group/InputGroupInput.vue +1 -1
  32. package/dist/runtime/components/ui/input-group/InputGroupNumberField.vue +1 -1
  33. package/dist/runtime/components/ui/input-group/InputGroupText.vue +1 -1
  34. package/dist/runtime/components/ui/input-group/InputGroupTextarea.vue +1 -1
  35. package/dist/runtime/components/ui/input-group/index.js +1 -1
  36. package/dist/runtime/components/ui/label/Label.vue +1 -1
  37. package/dist/runtime/components/ui/native-select/NativeSelect.vue +3 -3
  38. package/dist/runtime/components/ui/navigation-menu/NavigationMenuLink.vue +1 -1
  39. package/dist/runtime/components/ui/navigation-menu/NavigationMenuViewport.vue +1 -1
  40. package/dist/runtime/components/ui/range-calendar/RangeCalendarCell.vue +1 -1
  41. package/dist/runtime/components/ui/range-calendar/RangeCalendarCellTrigger.vue +1 -1
  42. package/dist/runtime/components/ui/sheet/SheetOverlay.vue +1 -1
  43. package/dist/runtime/components/ui/switch/Switch.d.vue.ts +24 -0
  44. package/dist/runtime/components/ui/switch/Switch.vue +46 -0
  45. package/dist/runtime/components/ui/switch/Switch.vue.d.ts +24 -0
  46. package/dist/runtime/components/ui/switch/index.d.ts +1 -0
  47. package/dist/runtime/components/ui/switch/index.js +1 -0
  48. package/dist/runtime/components/ui/textarea/Textarea.vue +1 -1
  49. package/dist/runtime/plugins/cel/env.d.ts +2 -2
  50. package/dist/runtime/plugins/cel/env.js +5 -4
  51. package/dist/runtime/plugins/cel/index.d.ts +3 -3
  52. package/dist/runtime/plugins/cel/index.js +7 -3
  53. package/dist/runtime/plugins/markdown/index.d.ts +1 -1
  54. package/dist/runtime/utils/coders.d.ts +7 -0
  55. package/dist/runtime/utils/coders.js +39 -0
  56. package/dist/runtime/vendor/cel/index.d.ts +17 -0
  57. package/dist/runtime/vendor/cel/index.js +10 -0
  58. package/dist/runtime/vendor/cel-js/LICENSE +21 -0
  59. package/dist/runtime/vendor/cel-js/UPSTREAM.md +17 -0
  60. package/dist/runtime/vendor/cel-js/lib/errors.d.ts +21 -0
  61. package/dist/runtime/vendor/cel-js/lib/errors.js +97 -0
  62. package/dist/runtime/vendor/cel-js/lib/evaluator.d.ts +4 -0
  63. package/dist/runtime/vendor/cel-js/lib/evaluator.js +192 -0
  64. package/dist/runtime/vendor/cel-js/lib/functions.d.ts +53 -0
  65. package/dist/runtime/vendor/cel-js/lib/functions.js +513 -0
  66. package/dist/runtime/vendor/cel-js/lib/globals.d.ts +27 -0
  67. package/dist/runtime/vendor/cel-js/lib/globals.js +33 -0
  68. package/dist/runtime/vendor/cel-js/lib/index.d.ts +469 -0
  69. package/dist/runtime/vendor/cel-js/lib/index.js +18 -0
  70. package/dist/runtime/vendor/cel-js/lib/macros.d.ts +1 -0
  71. package/dist/runtime/vendor/cel-js/lib/macros.js +230 -0
  72. package/dist/runtime/vendor/cel-js/lib/operators.d.ts +117 -0
  73. package/dist/runtime/vendor/cel-js/lib/operators.js +739 -0
  74. package/dist/runtime/vendor/cel-js/lib/optional.d.ts +14 -0
  75. package/dist/runtime/vendor/cel-js/lib/optional.js +161 -0
  76. package/dist/runtime/vendor/cel-js/lib/options.d.ts +23 -0
  77. package/dist/runtime/vendor/cel-js/lib/options.js +47 -0
  78. package/dist/runtime/vendor/cel-js/lib/overloads.d.ts +1 -0
  79. package/dist/runtime/vendor/cel-js/lib/overloads.js +214 -0
  80. package/dist/runtime/vendor/cel-js/lib/parser.d.ts +56 -0
  81. package/dist/runtime/vendor/cel-js/lib/parser.js +827 -0
  82. package/dist/runtime/vendor/cel-js/lib/registry.d.ts +279 -0
  83. package/dist/runtime/vendor/cel-js/lib/registry.js +1596 -0
  84. package/dist/runtime/vendor/cel-js/lib/serialize.d.ts +1 -0
  85. package/dist/runtime/vendor/cel-js/lib/serialize.js +259 -0
  86. package/dist/runtime/vendor/cel-js/lib/type-checker.d.ts +26 -0
  87. package/dist/runtime/vendor/cel-js/lib/type-checker.js +81 -0
  88. package/package.json +7 -4
  89. package/dist/runtime/components/locale.d.vue.ts +0 -14
  90. package/dist/runtime/components/locale.vue +0 -89
  91. package/dist/runtime/components/locale.vue.d.ts +0 -14
  92. package/dist/runtime/components/query.d.vue.ts +0 -30
  93. package/dist/runtime/components/query.vue +0 -266
  94. package/dist/runtime/components/query.vue.d.ts +0 -30
  95. package/dist/runtime/utilities/query-config/global.d.ts +0 -4
  96. package/dist/runtime/utilities/query-config/global.js +0 -18
  97. package/dist/runtime/utilities/query-config/index.d.ts +0 -3
  98. package/dist/runtime/utilities/query-config/index.js +0 -14
  99. package/dist/runtime/utilities/query-config/schema.d.ts +0 -96
  100. package/dist/runtime/utilities/query-config/schema.js +0 -51
@@ -0,0 +1 @@
1
+ export {serialize, ASTNode} from './index'
@@ -0,0 +1,259 @@
1
+ import {UnsignedInt} from './functions.js'
2
+ import {Optional} from './optional.js'
3
+
4
+ /**
5
+ * Serialize a primitive value to CEL syntax
6
+ * @param {*} value - The value to serialize
7
+ * @returns {string} The CEL representation
8
+ */
9
+ function serializeValue(value) {
10
+ if (value === null) return 'null'
11
+ if (typeof value === 'boolean') return String(value)
12
+ if (typeof value === 'bigint') return String(value)
13
+ if (typeof value === 'string') return serializeString(value)
14
+ if (value instanceof Uint8Array) return serializeBytes(value)
15
+ if (value instanceof UnsignedInt) return `${value.value}u`
16
+ if (value instanceof Optional) {
17
+ if (value.hasValue()) return `optional.of(${serializeValue(value.value())})`
18
+ return 'optional.none()'
19
+ }
20
+
21
+ if (typeof value === 'number') {
22
+ return value % 1 === 0
23
+ ? `${value}.0`
24
+ : value.toLocaleString('en-US', {useGrouping: false, maximumFractionDigits: 9})
25
+ }
26
+
27
+ // Handle Uint8Array deserialized from JSON (becomes plain object with numeric keys)
28
+ if (typeof value === 'object') {
29
+ const keys = Object.keys(value)
30
+ if (keys.every((k) => /^\d+$/.test(k))) {
31
+ const bytes = new Uint8Array(keys.length)
32
+ for (let i = 0; i < keys.length; i++) bytes[i] = value[i]
33
+ return serializeBytes(bytes)
34
+ }
35
+ }
36
+
37
+ return String(value)
38
+ }
39
+
40
+ /**
41
+ * Convert an AST back to CEL expression string
42
+ * @param {import("./index.js").ASTNode} ast - The AST node to convert
43
+ * @returns {string} The CEL expression string
44
+ */
45
+ export function serialize(ast) {
46
+ const {op, args} = ast
47
+ switch (op) {
48
+ case 'value':
49
+ return serializeValue(args)
50
+ case 'id':
51
+ return args
52
+
53
+ case '||':
54
+ case '&&':
55
+ case '==':
56
+ case '!=':
57
+ case '<':
58
+ case '<=':
59
+ case '>':
60
+ case '>=':
61
+ case 'in':
62
+ case '+':
63
+ case '-':
64
+ case '*':
65
+ case '/':
66
+ case '%':
67
+ return `${wrap(args[0], op)} ${op} ${wrap(args[1], op)}`
68
+
69
+ case '!_':
70
+ return `!${wrap(args, op)}`
71
+ case '-_':
72
+ // Add parentheses when operand is a binary operation
73
+ return ['+', '-', '*', '/', '%'].includes(args.op)
74
+ ? `-(${serialize(args)})`
75
+ : `-${serialize(args)}`
76
+
77
+ case '.':
78
+ return `${wrap(args[0], op)}.${args[1]}`
79
+ case '.?':
80
+ return `${wrap(args[0], op)}.?${args[1]}`
81
+ case '[]':
82
+ return `${wrap(args[0], op)}[${serialize(args[1])}]`
83
+ case '[?]':
84
+ return `${wrap(args[0], op)}[?${serialize(args[1])}]`
85
+
86
+ case 'call':
87
+ return `${args[0]}(${args[1].map(serialize).join(', ')})`
88
+ case 'rcall':
89
+ return `${wrap(args[1], op)}.${args[0]}(${args[2].map(serialize).join(', ')})`
90
+
91
+ case 'list':
92
+ return `[${args.map(serialize).join(', ')}]`
93
+ case 'map':
94
+ return `{${args.map(([k, v]) => `${serialize(k)}: ${serialize(v)}`).join(', ')}}`
95
+
96
+ case '?:':
97
+ return `${wrap(args[0], op)} ? ${wrap(args[1], op)} : ${serialize(args[2])}`
98
+
99
+ default:
100
+ throw new Error(`Unknown AST operation: ${op}`)
101
+ }
102
+ }
103
+
104
+ /**
105
+ * Serialize a string value with proper escaping
106
+ * @param {string} str - The string to serialize
107
+ * @returns {string} The escaped string with quotes
108
+ */
109
+ function serializeString(str) {
110
+ const escaped = str
111
+ .replace(/\\/g, '\\\\')
112
+ .replace(/"/g, '\\"')
113
+ .replace(/\n/g, '\\n')
114
+ .replace(/\r/g, '\\r')
115
+ .replace(/\t/g, '\\t')
116
+ .replace(/\f/g, '\\f')
117
+ .replace(/[\b]/g, '\\b')
118
+ .replace(/\v/g, '\\v')
119
+
120
+ let result = ''
121
+ for (let i = 0; i < escaped.length; i++) {
122
+ const code = escaped.charCodeAt(i)
123
+ if (code < 32 || code > 126) {
124
+ result +=
125
+ code <= 0xffff
126
+ ? `\\u${code.toString(16).padStart(4, '0')}`
127
+ : `\\U${code.toString(16).padStart(8, '0')}`
128
+ } else {
129
+ result += escaped[i]
130
+ }
131
+ }
132
+
133
+ return `"${result}"`
134
+ }
135
+
136
+ /**
137
+ * Serialize a bytes value
138
+ * @param {Uint8Array} bytes - The bytes to serialize
139
+ * @returns {string} The bytes literal
140
+ */
141
+ function serializeBytes(bytes) {
142
+ let result = 'b"'
143
+ for (const byte of bytes) {
144
+ if (byte === 0x5c) result += '\\\\'
145
+ else if (byte === 0x22) result += '\\"'
146
+ else if (byte === 0x0a) result += '\\n'
147
+ else if (byte === 0x0d) result += '\\r'
148
+ else if (byte === 0x09) result += '\\t'
149
+ else if (byte >= 32 && byte <= 126) result += String.fromCharCode(byte)
150
+ else result += `\\x${byte.toString(16).padStart(2, '0')}`
151
+ }
152
+ return `${result}"`
153
+ }
154
+
155
+ /**
156
+ * Operator precedence (higher = tighter binding)
157
+ */
158
+ const PRECEDENCE = {
159
+ '?:': 1,
160
+ '||': 2,
161
+ '&&': 3,
162
+ '==': 4,
163
+ '!=': 4,
164
+ '<': 5,
165
+ '<=': 5,
166
+ '>': 5,
167
+ '>=': 5,
168
+ in: 5,
169
+ '+': 6,
170
+ '-': 6,
171
+ '-_': 6,
172
+ '*': 7,
173
+ '/': 7,
174
+ '%': 7,
175
+ '!_': 8,
176
+ '.': 9,
177
+ '.?': 9,
178
+ '[]': 9,
179
+ '[?]': 9,
180
+ call: 9,
181
+ rcall: 9
182
+ }
183
+
184
+ /**
185
+ * Check if parentheses are needed based on operator precedence
186
+ * @param {ASTNode} ast - The AST node to check
187
+ * @param {string} parentOp - The parent operator
188
+ * @returns {boolean} True if parentheses are needed
189
+ */
190
+ function needsParentheses(ast, parentOp) {
191
+ const childOp = ast.op
192
+ const parentPrec = PRECEDENCE[parentOp] || 0
193
+ const childPrec = PRECEDENCE[childOp] || 0
194
+
195
+ // Atomic operations never need parentheses
196
+ if (
197
+ childOp === 'value' ||
198
+ childOp === 'id' ||
199
+ childOp === 'call' ||
200
+ childOp === 'rcall' ||
201
+ childOp === 'list' ||
202
+ childOp === 'map'
203
+ ) {
204
+ return false
205
+ }
206
+
207
+ // Unary minus in multiplicative context: -x * y, -x * y * -z
208
+ if ((parentOp === '*' || parentOp === '/' || parentOp === '%') && childOp === '-_') return false
209
+ if (parentOp === '*' && childOp === '*' && ast.args[0].op === '-_') return false
210
+
211
+ // Member/index access chaining: a.b.c, a[0][1], a.?b.c
212
+ if (
213
+ (childOp === '.' || childOp === '[]' || childOp === '.?' || childOp === '[?]') &&
214
+ (parentOp === '.' ||
215
+ parentOp === '[]' ||
216
+ parentOp === '.?' ||
217
+ parentOp === '[?]' ||
218
+ parentOp === 'rcall')
219
+ )
220
+ return false
221
+
222
+ // Ternary: only wrap if child is also ternary
223
+ if (parentOp === '?:') return childOp === '?:'
224
+
225
+ // Unary operators: wrap if child has lower precedence
226
+ if (parentOp === '!_' || parentOp === '-_') return childPrec < parentPrec
227
+
228
+ // Division needs special handling
229
+ if (parentOp === '/' && (childOp === '*' || childOp === '+' || childOp === '-')) return true
230
+ if (childOp === '/' && parentOp !== undefined) return true
231
+ if ((parentOp === '*' || parentOp === '/') && ['+', '-', '*', '/'].includes(childOp)) {
232
+ return true
233
+ }
234
+
235
+ // Lower precedence needs parentheses
236
+ if (childPrec < parentPrec) return true
237
+
238
+ // Same precedence: non-associative operators need parentheses
239
+ if (
240
+ childPrec === parentPrec &&
241
+ (parentOp === '/' || parentOp === '%') &&
242
+ (childOp === '/' || childOp === '%')
243
+ )
244
+ return true
245
+
246
+ return false
247
+ }
248
+
249
+ /**
250
+ * Wrap expression in parentheses if needed
251
+ * @param {*} ast - The AST node
252
+ * @param {string} parentOp - The parent operator
253
+ * @returns {string} The serialized expression, possibly wrapped in parentheses
254
+ */
255
+ function wrap(ast, parentOp) {
256
+ return needsParentheses(ast, parentOp) ? `(${serialize(ast)})` : serialize(ast)
257
+ }
258
+
259
+ export default serialize
@@ -0,0 +1,26 @@
1
+ /**
2
+ * TypeChecker performs static type analysis on CEL expressions
3
+ * without executing them. It validates:
4
+ * - Variable existence and types
5
+ * - Function signatures and overloads
6
+ * - Operator compatibility using the actual overload registry
7
+ * - Property and index access validity
8
+ */
9
+ export class TypeChecker extends Base {
10
+ constructor(opts: any, isEvaluating: any);
11
+ isEvaluating: any;
12
+ Error: typeof EvaluationError | typeof TypeError;
13
+ /**
14
+ * Check an expression and return its inferred type
15
+ * @param {Array|any} ast - The AST node to check
16
+ * @returns {Object} The inferred type declaration
17
+ * @throws {TypeError} If type checking fails
18
+ */
19
+ check(ast: any[] | any, ctx: any): Object;
20
+ checkAccessOnType(ast: any, ctx: any, leftType: any, allowMissingField?: boolean): any;
21
+ formatType(type: any): any;
22
+ formatTypeList(types: any): any;
23
+ }
24
+ import { Base } from './operators.js.js';
25
+ import { EvaluationError } from './errors.js.js';
26
+ import { TypeError } from './errors.js.js';
@@ -0,0 +1,81 @@
1
+ import {TypeError, EvaluationError} from './errors.js'
2
+ import {Base} from './operators.js'
3
+ const toDynTypeBinding = new Map().set('A', 'dyn').set('T', 'dyn').set('K', 'dyn').set('V', 'dyn')
4
+
5
+ /**
6
+ * TypeChecker performs static type analysis on CEL expressions
7
+ * without executing them. It validates:
8
+ * - Variable existence and types
9
+ * - Function signatures and overloads
10
+ * - Operator compatibility using the actual overload registry
11
+ * - Property and index access validity
12
+ */
13
+ export class TypeChecker extends Base {
14
+ constructor(opts, isEvaluating) {
15
+ super(opts)
16
+ this.isEvaluating = isEvaluating
17
+ this.Error = isEvaluating ? EvaluationError : TypeError
18
+ }
19
+
20
+ /**
21
+ * Check an expression and return its inferred type
22
+ * @param {Array|any} ast - The AST node to check
23
+ * @returns {Object} The inferred type declaration
24
+ * @throws {TypeError} If type checking fails
25
+ */
26
+ check(ast, ctx) {
27
+ return (ast.checkedType ??= ast.check(this, ast, ctx))
28
+ }
29
+
30
+ checkAccessOnType(ast, ctx, leftType, allowMissingField = false) {
31
+ if (leftType === this.dynType) return leftType
32
+
33
+ const indexTypeName = (
34
+ ast.op === '[]' || ast.op === '[?]' ? this.check(ast.args[1], ctx) : this.stringType
35
+ ).type
36
+
37
+ if (leftType.kind === 'list') {
38
+ if (indexTypeName === 'int' || indexTypeName === 'dyn') return leftType.valueType
39
+ throw new this.Error(`List index must be int, got '${indexTypeName}'`, ast)
40
+ }
41
+
42
+ if (leftType.kind === 'map') return leftType.valueType
43
+
44
+ const customType = this.objectTypes.get(leftType.name)
45
+ if (customType) {
46
+ if (!(indexTypeName === 'string' || indexTypeName === 'dyn')) {
47
+ throw new this.Error(
48
+ `Cannot index type '${leftType.name}' with type '${indexTypeName}'`,
49
+ ast
50
+ )
51
+ }
52
+
53
+ if (customType.fields) {
54
+ let keyName
55
+ if (ast.op === '.' || ast.op === '.?') keyName = ast.args[1]
56
+ else if (ast.args[1].op === 'value') keyName = ast.args[1].args
57
+
58
+ if (typeof keyName === 'string') {
59
+ const fieldType = customType.fields[keyName]
60
+ if (fieldType) return fieldType
61
+ // For optional access, missing field returns dyn; for regular access, throw
62
+ if (allowMissingField) return this.dynType
63
+ throw new this.Error(`No such key: ${keyName}`, ast)
64
+ }
65
+ }
66
+ return this.dynType
67
+ }
68
+
69
+ // No other types support indexing/property access
70
+ throw new this.Error(`Cannot index type '${this.formatType(leftType)}'`, ast)
71
+ }
72
+
73
+ formatType(type) {
74
+ if (!type.hasPlaceholderType) return type.name
75
+ return type.templated(this.registry, toDynTypeBinding).name
76
+ }
77
+
78
+ formatTypeList(types) {
79
+ return types.map((t) => this.formatType(t)).join(', ')
80
+ }
81
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shwfed/nuxt",
3
- "version": "0.7.7",
3
+ "version": "0.7.9",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -27,10 +27,10 @@
27
27
  "dev": "npm run dev:prepare && nuxt dev playground",
28
28
  "dev:build": "nuxt build playground",
29
29
  "dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxt prepare playground",
30
+ "prepare": "simple-git-hooks",
30
31
  "release": "npm run lint && npm run test && npm run prepack && changelogen --release --push && npm publish",
31
32
  "release:major": "npm run lint && npm run test && npm run prepack && changelogen --major --release --push && npm publish",
32
33
  "lint": "eslint .",
33
- "postinstall": "husky",
34
34
  "test": "vitest run",
35
35
  "test:watch": "vitest watch",
36
36
  "test:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit"
@@ -42,7 +42,6 @@
42
42
  "@fontsource-variable/noto-sans-sc": "^5.2.10",
43
43
  "@iconify/vue": "^5.0.0",
44
44
  "@intlify/unplugin-vue-i18n": "^11.0.3",
45
- "@marcbachmann/cel-js": "^7.2.1",
46
45
  "@nuxt/fonts": "^0.14.0",
47
46
  "@nuxt/kit": "^4.3.0",
48
47
  "@tailwindcss/typography": "^0.5.19",
@@ -83,9 +82,9 @@
83
82
  "@vueuse/nuxt": "^14.2.1",
84
83
  "changelogen": "^0.6.2",
85
84
  "eslint": "^9.39.2",
86
- "husky": "^9.1.7",
87
85
  "lint-staged": "^16.2.7",
88
86
  "nuxt": "^4.3.0",
87
+ "simple-git-hooks": "^2.13.1",
89
88
  "typescript": "~5.9.3",
90
89
  "vitest": "^4.0.18",
91
90
  "vue-tsc": "^3.2.4"
@@ -95,6 +94,10 @@
95
94
  "@commitlint/config-conventional"
96
95
  ]
97
96
  },
97
+ "simple-git-hooks": {
98
+ "pre-commit": "bunx lint-staged",
99
+ "commit-msg": "bunx commitlint --edit \"$1\""
100
+ },
98
101
  "lint-staged": {
99
102
  "*.{js,jsx,ts,tsx,vue}": [
100
103
  "eslint --fix"
@@ -1,14 +0,0 @@
1
- interface LocaleItem {
2
- locale: string;
3
- message: string;
4
- }
5
- type __VLS_ModelProps = {
6
- modelValue?: Array<LocaleItem>;
7
- };
8
- declare const __VLS_export: import("vue").DefineComponent<__VLS_ModelProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
9
- "update:modelValue": (value: LocaleItem[] | undefined) => any;
10
- }, string, import("vue").PublicProps, Readonly<__VLS_ModelProps> & Readonly<{
11
- "onUpdate:modelValue"?: ((value: LocaleItem[] | undefined) => any) | undefined;
12
- }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
13
- declare const _default: typeof __VLS_export;
14
- export default _default;
@@ -1,89 +0,0 @@
1
- <script setup>
2
- import { Icon } from "@iconify/vue";
3
- import { useSortable } from "@vueuse/integrations/useSortable";
4
- import { useTemplateRef } from "vue";
5
- import { InputGroup, InputGroupAddon, InputGroupButton, InputGroupText } from "./ui/input-group";
6
- import {
7
- DropdownMenu,
8
- DropdownMenuContent,
9
- DropdownMenuItem,
10
- DropdownMenuTrigger
11
- } from "./ui/dropdown-menu";
12
- const list = defineModel({ type: Array });
13
- const ul = useTemplateRef("ul");
14
- useSortable(ul, list);
15
- const allLocales = ["zh", "ja", "en"];
16
- const localeNames = {
17
- zh: "\u4E2D\u6587",
18
- ja: "\u65E5\u672C\u8A9E",
19
- en: "English"
20
- };
21
- const getAvailableLocales = (currentItem) => {
22
- const selectedLocales = new Set(list.value?.map((i) => i.locale) ?? []);
23
- return allLocales.filter((locale) => !selectedLocales.has(locale) || locale === currentItem.locale);
24
- };
25
- const removeItem = (item) => {
26
- if (list.value === void 0) {
27
- return;
28
- }
29
- const index = list.value.indexOf(item);
30
- if (index > -1) {
31
- list.value.splice(index, 1);
32
- }
33
- };
34
- </script>
35
-
36
- <template>
37
- <div
38
- ref="ul"
39
- class="flex flex-col gap-2"
40
- >
41
- <InputGroup
42
- v-for="item in list"
43
- :key="item.locale"
44
- class="bg-white/90"
45
- >
46
- <InputGroupAddon
47
- align="inline-start"
48
- data-drag-handle
49
- >
50
- <Icon icon="fluent:re-order-dots-vertical-20-regular" />
51
- </InputGroupAddon>
52
- <InputGroupAddon align="inline-start">
53
- <DropdownMenu>
54
- <DropdownMenuTrigger as-child>
55
- <InputGroupAddon
56
- align="inline-start"
57
- class="cursor-pointer"
58
- >
59
- <Icon :icon="`circle-flags:lang-${item.locale}`" />
60
- </InputGroupAddon>
61
- </DropdownMenuTrigger>
62
- <DropdownMenuContent>
63
- <DropdownMenuItem
64
- v-for="locale in getAvailableLocales(item)"
65
- :key="locale"
66
- @select="item.locale = locale"
67
- >
68
- <Icon :icon="`circle-flags:lang-${locale}`" />
69
- {{ localeNames[locale] }}
70
- </DropdownMenuItem>
71
- </DropdownMenuContent>
72
- </DropdownMenu>
73
- </InputGroupAddon>
74
- <InputGroupAddon align="inline-end">
75
- <InputGroupButton
76
- align="inline-end"
77
- variant="destructive"
78
- @click="removeItem(item)"
79
- >
80
- <Icon icon="fluent:delete-20-regular" />
81
- </InputGroupButton>
82
- </InputGroupAddon>
83
- <InputGroupText
84
- v-model="item.message"
85
- class="flex-1"
86
- />
87
- </InputGroup>
88
- </div>
89
- </template>
@@ -1,14 +0,0 @@
1
- interface LocaleItem {
2
- locale: string;
3
- message: string;
4
- }
5
- type __VLS_ModelProps = {
6
- modelValue?: Array<LocaleItem>;
7
- };
8
- declare const __VLS_export: import("vue").DefineComponent<__VLS_ModelProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
9
- "update:modelValue": (value: LocaleItem[] | undefined) => any;
10
- }, string, import("vue").PublicProps, Readonly<__VLS_ModelProps> & Readonly<{
11
- "onUpdate:modelValue"?: ((value: LocaleItem[] | undefined) => any) | undefined;
12
- }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
13
- declare const _default: typeof __VLS_export;
14
- export default _default;
@@ -1,30 +0,0 @@
1
- declare const _default: typeof __VLS_export;
2
- export default _default;
3
- declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
4
- identifier: string;
5
- } & {
6
- modelValue?: Record<string, unknown>;
7
- }, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
8
- "update:modelValue": (value: Record<string, unknown>) => any;
9
- }, string, import("vue").PublicProps, Readonly<{
10
- identifier: string;
11
- } & {
12
- modelValue?: Record<string, unknown>;
13
- }> & Readonly<{
14
- "onUpdate:modelValue"?: ((value: Record<string, unknown>) => any) | undefined;
15
- }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
16
- option?: (props: {
17
- option: {
18
- readonly label: {
19
- readonly [x: string]: string;
20
- };
21
- readonly value: string | number;
22
- readonly icon?: string | undefined;
23
- };
24
- }) => any;
25
- }>;
26
- type __VLS_WithSlots<T, S> = T & {
27
- new (): {
28
- $slots: S;
29
- };
30
- };