@pixpilot/formily-shadcn 0.29.0 → 0.30.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.
@@ -3,6 +3,8 @@ const require_use_form_context = require('../hooks/use-form-context.cjs');
3
3
  require('../hooks/index.cjs');
4
4
  let __formily_react = require("@formily/react");
5
5
  __formily_react = require_rolldown_runtime.__toESM(__formily_react);
6
+ let react = require("react");
7
+ react = require_rolldown_runtime.__toESM(react);
6
8
  let __pixpilot_shadcn_ui = require("@pixpilot/shadcn-ui");
7
9
  __pixpilot_shadcn_ui = require_rolldown_runtime.__toESM(__pixpilot_shadcn_ui);
8
10
  let react_jsx_runtime = require("react/jsx-runtime");
@@ -10,20 +12,25 @@ react_jsx_runtime = require_rolldown_runtime.__toESM(react_jsx_runtime);
10
12
 
11
13
  //#region src/components/rich-text-editor.tsx
12
14
  const RichTextEditorBase = (props) => {
15
+ const configRichTextEditor = require_use_form_context.useFormContext()?.settings?.richTextEditor;
13
16
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__pixpilot_shadcn_ui.RichTextEditor, {
14
- ...require_use_form_context.useFormContext()?.settings?.richTextEditor,
15
- ...props,
17
+ ...(0, react.useMemo)(() => ({
18
+ ...configRichTextEditor,
19
+ ...props
20
+ }), [configRichTextEditor, props]),
16
21
  children: "RichTextEditor"
17
22
  });
18
23
  };
19
24
  const RichTextEditor = (0, __formily_react.connect)(RichTextEditorBase, (0, __formily_react.mapProps)((props, field) => {
25
+ const { onChange } = props;
26
+ const handleChange = (0, react.useCallback)((nextHtml) => {
27
+ field.onInput(nextHtml).catch(() => {});
28
+ onChange?.(nextHtml);
29
+ }, [field, onChange]);
20
30
  return {
21
31
  ...props,
22
32
  value: field.value ?? "",
23
- onChange: (nextHtml) => {
24
- field.onInput(nextHtml).catch(() => {});
25
- props.onChange?.(nextHtml);
26
- }
33
+ onChange: handleChange
27
34
  };
28
35
  }));
29
36
 
@@ -1,25 +1,31 @@
1
1
  import { useFormContext } from "../hooks/use-form-context.js";
2
2
  import "../hooks/index.js";
3
3
  import { connect, mapProps } from "@formily/react";
4
+ import { useCallback, useMemo } from "react";
4
5
  import { RichTextEditor } from "@pixpilot/shadcn-ui";
5
6
  import { jsx } from "react/jsx-runtime";
6
7
 
7
8
  //#region src/components/rich-text-editor.tsx
8
9
  const RichTextEditorBase = (props) => {
10
+ const configRichTextEditor = useFormContext()?.settings?.richTextEditor;
9
11
  return /* @__PURE__ */ jsx(RichTextEditor, {
10
- ...useFormContext()?.settings?.richTextEditor,
11
- ...props,
12
+ ...useMemo(() => ({
13
+ ...configRichTextEditor,
14
+ ...props
15
+ }), [configRichTextEditor, props]),
12
16
  children: "RichTextEditor"
13
17
  });
14
18
  };
15
19
  const RichTextEditor$1 = connect(RichTextEditorBase, mapProps((props, field) => {
20
+ const { onChange } = props;
21
+ const handleChange = useCallback((nextHtml) => {
22
+ field.onInput(nextHtml).catch(() => {});
23
+ onChange?.(nextHtml);
24
+ }, [field, onChange]);
16
25
  return {
17
26
  ...props,
18
27
  value: field.value ?? "",
19
- onChange: (nextHtml) => {
20
- field.onInput(nextHtml).catch(() => {});
21
- props.onChange?.(nextHtml);
22
- }
28
+ onChange: handleChange
23
29
  };
24
30
  }));
25
31