@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.
- package/dist/components/array-toggle-group/ArrayToggleGroup.d.ts +2 -2
- package/dist/components/column/Column.d.ts +2 -2
- package/dist/components/date-picker/DatePicker.d.cts +3 -3
- package/dist/components/date-picker/DatePicker.d.ts +3 -3
- package/dist/components/dialog-item/ConnectedDialogItem.d.cts +4 -4
- package/dist/components/dialog-item/ConnectedDialogItem.d.ts +4 -4
- package/dist/components/drawer-item/ConnectedDrawerItem.d.cts +4 -4
- package/dist/components/drawer-item/ConnectedDrawerItem.d.ts +4 -4
- package/dist/components/form/Form.d.cts +2 -2
- package/dist/components/form/Form.d.ts +2 -2
- package/dist/components/form/mcp.js +38 -1
- package/dist/components/form-grid/FormGrid.d.cts +2 -2
- package/dist/components/form-grid/FormGrid.d.ts +2 -2
- package/dist/components/popover-item/ConnectedPopoverItem.d.cts +4 -4
- package/dist/components/popover-item/ConnectedPopoverItem.d.ts +4 -4
- package/dist/components/radio/Radio.d.cts +2 -2
- package/dist/components/radio/Radio.d.ts +2 -2
- package/dist/components/rich-text-editor/mcp.js +53 -8
- package/dist/components/row/Row.d.cts +2 -2
- package/dist/components/row/Row.d.ts +2 -2
- package/dist/components/schema-field/schema-field-basics.d.cts +380 -380
- package/dist/components/schema-field/schema-field-basics.d.ts +380 -380
- package/dist/components/schema-field/schema-field-extended.d.cts +533 -533
- package/dist/components/schema-field/schema-field-extended.d.ts +534 -534
- package/dist/components/schema-field/schema-field.d.cts +468 -468
- package/dist/components/schema-field/schema-field.d.ts +467 -467
- package/dist/utils/transform-schema.cjs +26 -6
- package/dist/utils/transform-schema.js +26 -6
- package/package.json +6 -5
|
@@ -26,13 +26,33 @@ const inputSchemaMap = {
|
|
|
26
26
|
},
|
|
27
27
|
object: { "x-component": "ObjectContainer" }
|
|
28
28
|
};
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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.
|
|
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.
|
|
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/
|
|
71
|
+
"@internal/mcp": "0.0.0",
|
|
72
|
+
"@internal/vitest-config": "0.1.0",
|
|
72
73
|
"@internal/tsdown-config": "0.1.0",
|
|
73
|
-
"@internal/
|
|
74
|
+
"@internal/tsconfig": "0.1.0"
|
|
74
75
|
},
|
|
75
76
|
"prettier": "@internal/prettier-config",
|
|
76
77
|
"scripts": {
|