@foormjs/atscript 0.2.0 → 0.2.2
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/README.md +34 -1
- package/dist/index.cjs +576 -88
- package/dist/index.d.ts +5 -2
- package/dist/index.mjs +576 -88
- package/dist/plugin.cjs +49 -0
- package/dist/plugin.mjs +49 -0
- package/package.json +4 -4
package/dist/plugin.cjs
CHANGED
|
@@ -155,6 +155,10 @@ const annotations = {
|
|
|
155
155
|
description: 'Statically mark this field as disabled',
|
|
156
156
|
nodeType: ['prop'],
|
|
157
157
|
}),
|
|
158
|
+
readonly: new core.AnnotationSpec({
|
|
159
|
+
description: 'Statically mark this field as readonly',
|
|
160
|
+
nodeType: ['prop'],
|
|
161
|
+
}),
|
|
158
162
|
// ── Options annotation ──────────────────────────────────
|
|
159
163
|
options: new core.AnnotationSpec({
|
|
160
164
|
description: 'Static option for select/radio fields. Repeat for each option. Label is the display text, value is the key (defaults to label).',
|
|
@@ -175,6 +179,25 @@ const annotations = {
|
|
|
175
179
|
},
|
|
176
180
|
],
|
|
177
181
|
}),
|
|
182
|
+
// ── Custom attributes/props annotation ──────────────────
|
|
183
|
+
attr: new core.AnnotationSpec({
|
|
184
|
+
description: 'Custom attribute or component prop. Repeat for each attr. Passed to rendered component via v-bind.',
|
|
185
|
+
nodeType: ['prop'],
|
|
186
|
+
multiple: true,
|
|
187
|
+
mergeStrategy: 'replace',
|
|
188
|
+
argument: [
|
|
189
|
+
{
|
|
190
|
+
name: 'name',
|
|
191
|
+
type: 'string',
|
|
192
|
+
description: 'Attribute/prop name (e.g., "data-testid", "variant", "size")',
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
name: 'value',
|
|
196
|
+
type: 'string',
|
|
197
|
+
description: 'Static value (string, number, boolean, or undefined)',
|
|
198
|
+
},
|
|
199
|
+
],
|
|
200
|
+
}),
|
|
178
201
|
// ── Validation annotation ────────────────────────────────
|
|
179
202
|
validate: new core.AnnotationSpec({
|
|
180
203
|
description: 'Custom JS validator function string. Returns true for pass, or an error message string.',
|
|
@@ -208,10 +231,36 @@ const annotations = {
|
|
|
208
231
|
placeholder: fnAnnotation('Computed placeholder: (value, data, context, entry) => string'),
|
|
209
232
|
disabled: fnAnnotation('Computed disabled state: (value, data, context, entry) => boolean'),
|
|
210
233
|
hidden: fnAnnotation('Computed hidden state: (value, data, context, entry) => boolean'),
|
|
234
|
+
readonly: fnAnnotation('Computed readonly state: (value, data, context, entry) => boolean'),
|
|
211
235
|
optional: fnAnnotation('Computed optional state: (value, data, context, entry) => boolean'),
|
|
236
|
+
value: fnAnnotation('Computed default value: (value, data, context, entry) => any'),
|
|
212
237
|
classes: fnAnnotation('Computed CSS classes: (value, data, context, entry) => string | Record<string, boolean>'),
|
|
213
238
|
styles: fnAnnotation('Computed inline styles: (value, data, context, entry) => string | Record<string, string>'),
|
|
214
239
|
options: fnAnnotation('Computed select/radio options: (value, data, context, entry) => Array'),
|
|
240
|
+
attr: new core.AnnotationSpec({
|
|
241
|
+
description: 'Computed custom attribute/prop. Name is the attribute/prop name, fn returns the value.',
|
|
242
|
+
nodeType: ['prop'],
|
|
243
|
+
multiple: true,
|
|
244
|
+
mergeStrategy: 'replace',
|
|
245
|
+
argument: [
|
|
246
|
+
{
|
|
247
|
+
name: 'name',
|
|
248
|
+
type: 'string',
|
|
249
|
+
description: 'Attribute/prop name (e.g., "data-testid", "variant", "size")',
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
name: 'fn',
|
|
253
|
+
type: 'string',
|
|
254
|
+
description: 'JS function string: (value, data, context, entry) => any',
|
|
255
|
+
},
|
|
256
|
+
],
|
|
257
|
+
validate(_token, args) {
|
|
258
|
+
if (args[1]) {
|
|
259
|
+
return validateFnString(args[1].text, args[1].range);
|
|
260
|
+
}
|
|
261
|
+
return undefined;
|
|
262
|
+
},
|
|
263
|
+
}),
|
|
215
264
|
},
|
|
216
265
|
},
|
|
217
266
|
};
|
package/dist/plugin.mjs
CHANGED
|
@@ -153,6 +153,10 @@ const annotations = {
|
|
|
153
153
|
description: 'Statically mark this field as disabled',
|
|
154
154
|
nodeType: ['prop'],
|
|
155
155
|
}),
|
|
156
|
+
readonly: new AnnotationSpec({
|
|
157
|
+
description: 'Statically mark this field as readonly',
|
|
158
|
+
nodeType: ['prop'],
|
|
159
|
+
}),
|
|
156
160
|
// ── Options annotation ──────────────────────────────────
|
|
157
161
|
options: new AnnotationSpec({
|
|
158
162
|
description: 'Static option for select/radio fields. Repeat for each option. Label is the display text, value is the key (defaults to label).',
|
|
@@ -173,6 +177,25 @@ const annotations = {
|
|
|
173
177
|
},
|
|
174
178
|
],
|
|
175
179
|
}),
|
|
180
|
+
// ── Custom attributes/props annotation ──────────────────
|
|
181
|
+
attr: new AnnotationSpec({
|
|
182
|
+
description: 'Custom attribute or component prop. Repeat for each attr. Passed to rendered component via v-bind.',
|
|
183
|
+
nodeType: ['prop'],
|
|
184
|
+
multiple: true,
|
|
185
|
+
mergeStrategy: 'replace',
|
|
186
|
+
argument: [
|
|
187
|
+
{
|
|
188
|
+
name: 'name',
|
|
189
|
+
type: 'string',
|
|
190
|
+
description: 'Attribute/prop name (e.g., "data-testid", "variant", "size")',
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
name: 'value',
|
|
194
|
+
type: 'string',
|
|
195
|
+
description: 'Static value (string, number, boolean, or undefined)',
|
|
196
|
+
},
|
|
197
|
+
],
|
|
198
|
+
}),
|
|
176
199
|
// ── Validation annotation ────────────────────────────────
|
|
177
200
|
validate: new AnnotationSpec({
|
|
178
201
|
description: 'Custom JS validator function string. Returns true for pass, or an error message string.',
|
|
@@ -206,10 +229,36 @@ const annotations = {
|
|
|
206
229
|
placeholder: fnAnnotation('Computed placeholder: (value, data, context, entry) => string'),
|
|
207
230
|
disabled: fnAnnotation('Computed disabled state: (value, data, context, entry) => boolean'),
|
|
208
231
|
hidden: fnAnnotation('Computed hidden state: (value, data, context, entry) => boolean'),
|
|
232
|
+
readonly: fnAnnotation('Computed readonly state: (value, data, context, entry) => boolean'),
|
|
209
233
|
optional: fnAnnotation('Computed optional state: (value, data, context, entry) => boolean'),
|
|
234
|
+
value: fnAnnotation('Computed default value: (value, data, context, entry) => any'),
|
|
210
235
|
classes: fnAnnotation('Computed CSS classes: (value, data, context, entry) => string | Record<string, boolean>'),
|
|
211
236
|
styles: fnAnnotation('Computed inline styles: (value, data, context, entry) => string | Record<string, string>'),
|
|
212
237
|
options: fnAnnotation('Computed select/radio options: (value, data, context, entry) => Array'),
|
|
238
|
+
attr: new AnnotationSpec({
|
|
239
|
+
description: 'Computed custom attribute/prop. Name is the attribute/prop name, fn returns the value.',
|
|
240
|
+
nodeType: ['prop'],
|
|
241
|
+
multiple: true,
|
|
242
|
+
mergeStrategy: 'replace',
|
|
243
|
+
argument: [
|
|
244
|
+
{
|
|
245
|
+
name: 'name',
|
|
246
|
+
type: 'string',
|
|
247
|
+
description: 'Attribute/prop name (e.g., "data-testid", "variant", "size")',
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
name: 'fn',
|
|
251
|
+
type: 'string',
|
|
252
|
+
description: 'JS function string: (value, data, context, entry) => any',
|
|
253
|
+
},
|
|
254
|
+
],
|
|
255
|
+
validate(_token, args) {
|
|
256
|
+
if (args[1]) {
|
|
257
|
+
return validateFnString(args[1].text, args[1].range);
|
|
258
|
+
}
|
|
259
|
+
return undefined;
|
|
260
|
+
},
|
|
261
|
+
}),
|
|
213
262
|
},
|
|
214
263
|
},
|
|
215
264
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@foormjs/atscript",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "ATScript plugin for foormjs — form annotations, primitives, and validation",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -60,12 +60,12 @@
|
|
|
60
60
|
},
|
|
61
61
|
"homepage": "https://github.com/foormjs/foormjs/tree/main/packages/atscript#readme",
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@atscript/core": "^0.1.
|
|
63
|
+
"@atscript/core": "^0.1.8",
|
|
64
64
|
"@prostojs/deserialize-fn": "^0.0.5",
|
|
65
|
-
"foorm": "^0.2.
|
|
65
|
+
"foorm": "^0.2.2"
|
|
66
66
|
},
|
|
67
67
|
"peerDependencies": {
|
|
68
|
-
"@atscript/typescript": "^0.1.
|
|
68
|
+
"@atscript/typescript": "^0.1.8"
|
|
69
69
|
},
|
|
70
70
|
"scripts": {
|
|
71
71
|
"pub": "pnpm publish --access public --no-git-checks"
|