attaform 0.30.0 → 0.31.0

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 (71) hide show
  1. package/dist/abstract.d.mts +15 -21
  2. package/dist/abstract.mjs +3 -3
  3. package/dist/dev/abstract.mjs +4 -4
  4. package/dist/dev/chunks/devtools.mjs +4 -4
  5. package/dist/dev/directive.mjs +1 -1
  6. package/dist/dev/history.mjs +2 -2
  7. package/dist/dev/index.mjs +5 -5
  8. package/dist/dev/runtime/plugins/attaform.mjs +1 -1
  9. package/dist/dev/shared/{attaform-dev.DUZckyV8.mjs → attaform-dev.B1q-x9R9.mjs} +4 -4
  10. package/dist/dev/shared/{attaform-dev.BcYT6tFh.mjs → attaform-dev.CZz4GYZ6.mjs} +21 -9
  11. package/dist/dev/shared/{attaform-dev.BisFstxh.mjs → attaform-dev.Caibt7sb.mjs} +16 -15
  12. package/dist/dev/shared/{attaform-dev.DTrHonpc.mjs → attaform-dev.CtyqGia7.mjs} +176 -260
  13. package/dist/dev/shared/{attaform-dev.BK6Ge2qR.mjs → attaform-dev.DJ3nsWw6.mjs} +86 -122
  14. package/dist/dev/shared/{attaform-dev.BcNtyOmf.mjs → attaform-dev.DlaT4xGd.mjs} +4 -4
  15. package/dist/dev/shared/{attaform-dev.D6CLvaQT.mjs → attaform-dev.k5X47GMD.mjs} +520 -395
  16. package/dist/dev/shared/{attaform-dev.CQ2rJiAX.mjs → attaform-dev.y9x9Vp9F.mjs} +324 -234
  17. package/dist/dev/shared/{attaform-dev.BQc5QV3Y.mjs → attaform-dev.zlvDr0WB.mjs} +2 -2
  18. package/dist/dev/zod-v3.mjs +6 -6
  19. package/dist/dev/zod-v4.mjs +6 -6
  20. package/dist/dev/zod.mjs +5 -5
  21. package/dist/directive.d.mts +4 -4
  22. package/dist/directive.mjs +1 -1
  23. package/dist/esbuild.d.mts +11 -0
  24. package/dist/esbuild.mjs +1 -1
  25. package/dist/history.d.mts +3 -32
  26. package/dist/history.mjs +2 -2
  27. package/dist/index.d.mts +67 -70
  28. package/dist/index.mjs +4 -4
  29. package/dist/nuxt.d.mts +4 -3
  30. package/dist/nuxt.mjs +3 -6
  31. package/dist/rollup.d.mts +11 -0
  32. package/dist/rollup.mjs +1 -1
  33. package/dist/rspack.d.mts +19 -11
  34. package/dist/rspack.mjs +1 -1
  35. package/dist/runtime/components/AttaformDevtoolsPanel.vue +15 -15
  36. package/dist/runtime/components/DevtoolsValueTree.vue +2 -2
  37. package/dist/runtime/plugins/attaform.mjs +1 -1
  38. package/dist/shared/{attaform.BRDDQeHV.mjs → attaform.8mfKZCwH.mjs} +2 -2
  39. package/dist/shared/{attaform.DRUT703x.d.mts → attaform.B-Tb62qV.d.mts} +12 -12
  40. package/dist/shared/{attaform.v0fQtWyA.mjs → attaform.B1rH9ht6.mjs} +1 -1
  41. package/dist/shared/{attaform.DhnPb6nK.mjs → attaform.BAf3UNn4.mjs} +1 -1
  42. package/dist/shared/{attaform.BXneBxEj.mjs → attaform.BWUn8Kjy.mjs} +85 -121
  43. package/dist/shared/{attaform.WiGdIqgx.mjs → attaform.C4shmwyJ.mjs} +2 -2
  44. package/dist/shared/{attaform.Rc9u4Vfw.d.mts → attaform.CRVe8s82.d.mts} +83 -95
  45. package/dist/shared/attaform.D9RqPgGu.d.mts +42 -0
  46. package/dist/shared/attaform.DAo0QBmS.d.mts +2173 -0
  47. package/dist/shared/{attaform.BK0cgu2K.mjs → attaform.DBCbxlyk.mjs} +62 -4
  48. package/dist/shared/{attaform.CUfrMK7t.mjs → attaform.DL2nl_QR.mjs} +15 -14
  49. package/dist/shared/{attaform.DNJOWjQw.mjs → attaform.DNPJPOO7.mjs} +299 -218
  50. package/dist/shared/attaform.DZnrDrNb.d.mts +4657 -0
  51. package/dist/shared/{attaform.B3resMQ1.mjs → attaform.DxKQsqFZ.mjs} +496 -371
  52. package/dist/shared/{attaform.ByWP6kSx.mjs → attaform.L011tHgJ.mjs} +3 -3
  53. package/dist/shared/{attaform.CJ8DpRGj.mjs → attaform.LUPC-2Qg.mjs} +175 -257
  54. package/dist/transforms.d.mts +153 -26
  55. package/dist/transforms.mjs +1 -1
  56. package/dist/vite.d.mts +29 -52
  57. package/dist/vite.mjs +3 -3
  58. package/dist/webpack.d.mts +20 -12
  59. package/dist/webpack.mjs +1 -1
  60. package/dist/zod-v3.d.mts +90 -96
  61. package/dist/zod-v3.mjs +5 -5
  62. package/dist/zod-v4.d.mts +120 -118
  63. package/dist/zod-v4.mjs +5 -5
  64. package/dist/zod.d.mts +5 -5
  65. package/dist/zod.mjs +4 -4
  66. package/package.json +7 -6
  67. package/skills/attaform/SKILL.md +1 -1
  68. package/skills/attaform/references/custom-components.md +4 -0
  69. package/dist/shared/attaform.Clz0ArIi.d.mts +0 -44
  70. package/dist/shared/attaform.UGyOK83T.d.mts +0 -2366
  71. package/dist/shared/attaform.bKLzMU0o.d.mts +0 -4761
@@ -119,6 +119,20 @@ const NATIVE_FORM_TAGS = /* @__PURE__ */ new Set([
119
119
  "label",
120
120
  "button"
121
121
  ]);
122
+ const HOST_MODIFIERS = ["lazy", "trim", "number"];
123
+ function hostModifiersLiteral(registerDirective) {
124
+ const present = HOST_MODIFIERS.filter(
125
+ (name) => registerDirective?.modifiers.some((m) => m.content === name) === true
126
+ );
127
+ return present.length === 0 ? "{}" : `{ ${present.map((name) => `${name}: true`).join(", ")} }`;
128
+ }
129
+ function isInputListenerSlot(prop) {
130
+ if (prop.type !== NodeTypes.DIRECTIVE || prop.name !== "on" && prop.name !== "bind") {
131
+ return false;
132
+ }
133
+ if (prop.arg === void 0) return true;
134
+ return prop.arg.type === NodeTypes.SIMPLE_EXPRESSION && prop.arg.content === (prop.name === "on" ? "input" : "onInput");
135
+ }
122
136
  function inferOptionValueFromChildren(node) {
123
137
  if (!("children" in node)) return null;
124
138
  const children = node.children;
@@ -275,6 +289,11 @@ const componentBridgeTransform = (node, context) => {
275
289
  node.props.push(valueProp);
276
290
  }
277
291
  if (isPlainComponentHost) {
292
+ const hostModifiers = hostModifiersLiteral(
293
+ node.props.find(
294
+ (p) => p.type === NodeTypes.DIRECTIVE && p.name === "register"
295
+ )
296
+ );
278
297
  removePropsByName(node.props, [
279
298
  "model",
280
299
  "modelValue",
@@ -317,7 +336,7 @@ const componentBridgeTransform = (node, context) => {
317
336
  const updateInitExpression = createCompoundExpression([
318
337
  "$event => (",
319
338
  ...modelValuePropExpArray,
320
- ")?.setValueFromHost?.($event)"
339
+ `)?.setValueFromHost?.($event, ${hostModifiers})`
321
340
  ]);
322
341
  const updateSimpleExpression = createSimpleExpression(
323
342
  flattenExpression(updateInitExpression),
@@ -346,6 +365,45 @@ const componentBridgeTransform = (node, context) => {
346
365
  loc: selectLoc
347
366
  };
348
367
  node.props.push(updateModelValueProp);
368
+ const inputAlreadyInjected = node.props.some(
369
+ (p) => p.type === NodeTypes.DIRECTIVE && p.name === "bind" && p.arg?.type === NodeTypes.SIMPLE_EXPRESSION && p.arg.content === "onInput" && p.exp !== void 0 && flattenExpression(p.exp).includes("setValueFromHostInput")
370
+ );
371
+ if (!inputAlreadyInjected) {
372
+ const inputInitExpression = createCompoundExpression([
373
+ "$event => (",
374
+ ...modelValuePropExpArray,
375
+ `)?.setValueFromHostInput?.($event, ${hostModifiers})`
376
+ ]);
377
+ const inputSimpleExpression = createSimpleExpression(
378
+ flattenExpression(inputInitExpression),
379
+ false
380
+ );
381
+ let inputOutputExp;
382
+ try {
383
+ inputOutputExp = processExpression(inputSimpleExpression, {
384
+ ...context,
385
+ prefixIdentifiers: false
386
+ });
387
+ } catch (err) {
388
+ console.error(
389
+ "[attaform] component-bridge transform: processExpression failed for onInput; falling back to the unprocessed expression.",
390
+ err
391
+ );
392
+ inputOutputExp = inputSimpleExpression;
393
+ }
394
+ const inputProp = {
395
+ rawName: "@input",
396
+ arg: createSimpleExpression("onInput", true),
397
+ exp: inputOutputExp,
398
+ name: "bind",
399
+ modifiers: [],
400
+ type: NodeTypes.DIRECTIVE,
401
+ loc: selectLoc
402
+ };
403
+ const authorListenerIndex = node.props.findIndex(isInputListenerSlot);
404
+ if (authorListenerIndex === -1) node.props.push(inputProp);
405
+ else node.props.splice(authorListenerIndex, 0, inputProp);
406
+ }
349
407
  }
350
408
  const registerExprArray = Array.isArray(registerSummarizedProp?.value) ? registerSummarizedProp.value : [registerSummarizedProp?.value ?? "undefined"];
351
409
  const hasAuthorDisabled = selectSummarizedProps.findIndex((p) => isExactKey(p.key, "disabled")) !== -1;
@@ -756,9 +814,9 @@ function injectPreamble(element, captured) {
756
814
  ),
757
815
  exp,
758
816
  modifiers: [],
759
- // Reuse the host element's source location so any runtime error
760
- // in the synthesized expression points at the consumer's template
761
- // line, not at the dummyLoc that pre-fix was line 0.
817
+ // The host element's source location, so a runtime error in the
818
+ // synthesized expression points at the consumer's template line
819
+ // rather than at line 0.
762
820
  loc: element.loc
763
821
  };
764
822
  element.props.unshift(directive);
@@ -1,6 +1,6 @@
1
- import { A as AttaformErrorCode, k as isPlainRecord, s as slimKindOf } from './attaform.DNJOWjQw.mjs';
1
+ import { A as AttaformErrorCode, k as isPlainRecord, s as slimKindOf } from './attaform.DNPJPOO7.mjs';
2
2
  import { e as canonicalizePath, h as SET_MEMBER_SEGMENT } from './attaform.CdZIEf7_.mjs';
3
- import { a as safeOwnRead, b as safeAssign } from './attaform.BRDDQeHV.mjs';
3
+ import { a as safeOwnRead, b as safeAssign } from './attaform.8mfKZCwH.mjs';
4
4
 
5
5
  const PATH_SEPARATOR = ".";
6
6
  function isOpaqueKind(kind) {
@@ -37,9 +37,6 @@ function createAbstractSchema(rootSchema, intro, services, options) {
37
37
  const discriminatorCache = /* @__PURE__ */ new Map();
38
38
  const entryKeyKindCache = /* @__PURE__ */ new Map();
39
39
  const slimKindsCache = /* @__PURE__ */ new Map();
40
- let asyncValidationFlag = null;
41
- let containerRefineFlag = null;
42
- let discriminatedUnionFlag = null;
43
40
  function mapKeySegmentKind(schema) {
44
41
  const keyType = intro.getMapKeyType(schema);
45
42
  if (keyType === void 0) return void 0;
@@ -92,20 +89,24 @@ function createAbstractSchema(rootSchema, intro, services, options) {
92
89
  }
93
90
  const abstractSchema = {
94
91
  needsAsyncValidation() {
95
- asyncValidationFlag ?? (asyncValidationFlag = intro.containsAsyncRefine(rootSchema) || intro.containsAsyncTransform(rootSchema));
96
- return asyncValidationFlag;
92
+ const { asyncRefine, asyncTransform } = intro.capabilitiesOf(rootSchema);
93
+ return asyncRefine || asyncTransform;
97
94
  },
98
95
  hasContainerOrRootRefine() {
99
- containerRefineFlag ?? (containerRefineFlag = intro.hasContainerOrRootRefine(rootSchema));
100
- return containerRefineFlag;
96
+ return intro.capabilitiesOf(rootSchema).containerOrRootRefine;
101
97
  },
102
98
  hasDiscriminatedUnions() {
103
- discriminatedUnionFlag ?? (discriminatedUnionFlag = intro.containsDiscriminatedUnion(rootSchema));
104
- return discriminatedUnionFlag;
99
+ return intro.capabilitiesOf(rootSchema).discriminatedUnion;
100
+ },
101
+ hasPreprocessOrCoerce() {
102
+ return intro.capabilitiesOf(rootSchema).preprocessOrCoerce;
105
103
  },
106
104
  getDefaultValues(config) {
107
105
  return services.runGetDefaults(rootSchema, config, maxRecursionDepth);
108
106
  },
107
+ validateSync(data) {
108
+ return services.validateSync(rootSchema, data);
109
+ },
109
110
  getDefaultAtPath(path) {
110
111
  if (path.length === 0) {
111
112
  return services.deriveDefault(rootSchema, true, maxRecursionDepth);
@@ -425,8 +426,8 @@ function walkPathSegments(schema, segments, intro, maxDepth, lazyDepth) {
425
426
  const rightResults = right === void 0 ? [] : walkPathSegments(right, segments, intro, maxDepth, lazyDepth);
426
427
  return [...leftResults, ...rightResults];
427
428
  }
428
- // Leaves — can't descend further. Opaque leaves (`any` /
429
- // `unknown` / `custom`) land here too and `[]` is the truthful
429
+ // Leaves, with nothing further to descend. An opaque leaf (`any` /
430
+ // `unknown` / `custom`) lands here too and `[]` is the truthful
430
431
  // answer: the schema declares no sub-paths under them, so none are
431
432
  // fabricated. `symbol` / `function` / `promise` hold a value
432
433
  // without declaring anything inside it and land here for the same
@@ -1017,7 +1018,7 @@ function slimPrimitivesWalk(schema, intro, maxDepth, lazyDepth = 0) {
1017
1018
  case "unknown":
1018
1019
  case "custom":
1019
1020
  return PERMISSIVE_SLIM_KINDS;
1020
- // A kind this walker has no case for — in practice a kind a newer
1021
+ // A kind this walker has no case for, in practice one a newer
1021
1022
  // Zod introduced. Be permissive rather than reject: the adapter
1022
1023
  // carries the value opaquely and the schema's own parse is what
1023
1024
  // decides whether it was legal.