@pixpilot/formily-shadcn 2.1.1 → 2.2.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 (29) hide show
  1. package/dist/components/array-toggle-group/ArrayToggleGroup.d.ts +2 -2
  2. package/dist/components/column/Column.d.ts +2 -2
  3. package/dist/components/date-picker/DatePicker.d.cts +3 -3
  4. package/dist/components/date-picker/DatePicker.d.ts +3 -3
  5. package/dist/components/dialog-item/ConnectedDialogItem.d.cts +4 -4
  6. package/dist/components/dialog-item/ConnectedDialogItem.d.ts +4 -4
  7. package/dist/components/drawer-item/ConnectedDrawerItem.d.cts +4 -4
  8. package/dist/components/drawer-item/ConnectedDrawerItem.d.ts +4 -4
  9. package/dist/components/form/Form.d.cts +2 -2
  10. package/dist/components/form/Form.d.ts +2 -2
  11. package/dist/components/form/mcp.js +38 -1
  12. package/dist/components/form-grid/FormGrid.d.cts +2 -2
  13. package/dist/components/form-grid/FormGrid.d.ts +2 -2
  14. package/dist/components/popover-item/ConnectedPopoverItem.d.cts +4 -4
  15. package/dist/components/popover-item/ConnectedPopoverItem.d.ts +4 -4
  16. package/dist/components/radio/Radio.d.cts +2 -2
  17. package/dist/components/radio/Radio.d.ts +2 -2
  18. package/dist/components/rich-text-editor/mcp.js +53 -8
  19. package/dist/components/row/Row.d.cts +2 -2
  20. package/dist/components/row/Row.d.ts +2 -2
  21. package/dist/components/schema-field/schema-field-basics.d.cts +380 -380
  22. package/dist/components/schema-field/schema-field-basics.d.ts +380 -380
  23. package/dist/components/schema-field/schema-field-extended.d.cts +533 -533
  24. package/dist/components/schema-field/schema-field-extended.d.ts +534 -534
  25. package/dist/components/schema-field/schema-field.d.cts +468 -468
  26. package/dist/components/schema-field/schema-field.d.ts +467 -467
  27. package/dist/utils/transform-schema.cjs +26 -6
  28. package/dist/utils/transform-schema.js +26 -6
  29. package/package.json +6 -5
@@ -26,13 +26,33 @@ const inputSchemaMap = {
26
26
  },
27
27
  object: { "x-component": "ObjectContainer" }
28
28
  };
29
- function transformSchema(schema, fieldsDecorators) {
30
- let normalizedSchema;
31
- try {
32
- normalizedSchema = JSON.parse(JSON.stringify(schema));
33
- } catch {
34
- normalizedSchema = JSON.parse(JSON.stringify(schema));
29
+ /**
30
+ * Deep-clone the plain-object/array structure of a schema while keeping any
31
+ * non-plain values (functions, class instances such as TipTap extensions,
32
+ * Dates, etc.) by reference.
33
+ *
34
+ * A plain `JSON.parse(JSON.stringify(...))` clone silently drops function
35
+ * values, which breaks `x-component-props` that carry callbacks (e.g. custom
36
+ * toolbar `onClick` handlers) or class instances (e.g. TipTap `extensions`,
37
+ * whose `parseHTML`/`renderHTML` methods would be stripped). This clone only
38
+ * copies plain objects and arrays — the parts `transformSchema` actually
39
+ * mutates — and leaves everything else untouched.
40
+ */
41
+ function cloneSchemaPreservingRefs(value) {
42
+ if (Array.isArray(value)) return value.map((item) => cloneSchemaPreservingRefs(item));
43
+ if (value !== null && typeof value === "object") {
44
+ const proto = Object.getPrototypeOf(value);
45
+ if (proto === Object.prototype || proto === null) {
46
+ const source = value;
47
+ const out = {};
48
+ for (const key of Object.keys(source)) out[key] = cloneSchemaPreservingRefs(source[key]);
49
+ return out;
50
+ }
35
51
  }
52
+ return value;
53
+ }
54
+ function transformSchema(schema, fieldsDecorators) {
55
+ const normalizedSchema = cloneSchemaPreservingRefs(schema);
36
56
  (0, json_schema_traverse.default)(normalizedSchema, { allKeys: true }, (currentSchema, _jsonPtr, _rootSchema, _parentJSONPtr, parentKeyword, _parentSchema, _keyIndex) => {
37
57
  const { type } = currentSchema;
38
58
  const xComponent = currentSchema["x-component"];
@@ -24,13 +24,33 @@ const inputSchemaMap = {
24
24
  },
25
25
  object: { "x-component": "ObjectContainer" }
26
26
  };
27
- function transformSchema(schema, fieldsDecorators) {
28
- let normalizedSchema;
29
- try {
30
- normalizedSchema = JSON.parse(JSON.stringify(schema));
31
- } catch {
32
- normalizedSchema = JSON.parse(JSON.stringify(schema));
27
+ /**
28
+ * Deep-clone the plain-object/array structure of a schema while keeping any
29
+ * non-plain values (functions, class instances such as TipTap extensions,
30
+ * Dates, etc.) by reference.
31
+ *
32
+ * A plain `JSON.parse(JSON.stringify(...))` clone silently drops function
33
+ * values, which breaks `x-component-props` that carry callbacks (e.g. custom
34
+ * toolbar `onClick` handlers) or class instances (e.g. TipTap `extensions`,
35
+ * whose `parseHTML`/`renderHTML` methods would be stripped). This clone only
36
+ * copies plain objects and arrays — the parts `transformSchema` actually
37
+ * mutates — and leaves everything else untouched.
38
+ */
39
+ function cloneSchemaPreservingRefs(value) {
40
+ if (Array.isArray(value)) return value.map((item) => cloneSchemaPreservingRefs(item));
41
+ if (value !== null && typeof value === "object") {
42
+ const proto = Object.getPrototypeOf(value);
43
+ if (proto === Object.prototype || proto === null) {
44
+ const source = value;
45
+ const out = {};
46
+ for (const key of Object.keys(source)) out[key] = cloneSchemaPreservingRefs(source[key]);
47
+ return out;
48
+ }
33
49
  }
50
+ return value;
51
+ }
52
+ function transformSchema(schema, fieldsDecorators) {
53
+ const normalizedSchema = cloneSchemaPreservingRefs(schema);
34
54
  traverse(normalizedSchema, { allKeys: true }, (currentSchema, _jsonPtr, _rootSchema, _parentJSONPtr, parentKeyword, _parentSchema, _keyIndex) => {
35
55
  const { type } = currentSchema;
36
56
  const xComponent = currentSchema["x-component"];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pixpilot/formily-shadcn",
3
3
  "type": "module",
4
- "version": "2.1.1",
4
+ "version": "2.2.0",
5
5
  "description": "Formily integration for shadcn/ui components",
6
6
  "author": "m.doaie <m.doaie@hotmail.com>",
7
7
  "license": "MIT",
@@ -51,11 +51,12 @@
51
51
  "pretty-bytes": "^7.1.0",
52
52
  "zod": "^4.3.6",
53
53
  "@pixpilot/shadcn": "2.1.0",
54
- "@pixpilot/shadcn-ui": "3.5.1"
54
+ "@pixpilot/shadcn-ui": "3.6.0"
55
55
  },
56
56
  "devDependencies": {
57
57
  "@storybook/react": "^8.6.18",
58
58
  "@testing-library/react": "^16.3.2",
59
+ "@tiptap/core": "^3.22.3",
59
60
  "@types/node": "^22.19.17",
60
61
  "@types/react": "^19.2.14",
61
62
  "@types/react-dom": "^19.2.3",
@@ -66,11 +67,11 @@
66
67
  "tsx": "^4.21.0",
67
68
  "typescript": "^5.9.3",
68
69
  "@internal/eslint-config": "0.3.0",
69
- "@internal/mcp": "0.0.0",
70
70
  "@internal/prettier-config": "0.0.1",
71
- "@internal/tsconfig": "0.1.0",
71
+ "@internal/mcp": "0.0.0",
72
+ "@internal/vitest-config": "0.1.0",
72
73
  "@internal/tsdown-config": "0.1.0",
73
- "@internal/vitest-config": "0.1.0"
74
+ "@internal/tsconfig": "0.1.0"
74
75
  },
75
76
  "prettier": "@internal/prettier-config",
76
77
  "scripts": {