@faasjs/ant-design 0.0.3-beta.102 → 0.0.3-beta.104

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/index.d.mts CHANGED
@@ -448,6 +448,7 @@ interface LinkProps {
448
448
  block?: boolean;
449
449
  /** only use for text without button */
450
450
  copyable?: boolean;
451
+ onClick?: (event: React.MouseEvent<HTMLElement, MouseEvent>) => void;
451
452
  }
452
453
  /**
453
454
  * Link component with button.
package/dist/index.d.ts CHANGED
@@ -448,6 +448,7 @@ interface LinkProps {
448
448
  block?: boolean;
449
449
  /** only use for text without button */
450
450
  copyable?: boolean;
451
+ onClick?: (event: React.MouseEvent<HTMLElement, MouseEvent>) => void;
451
452
  }
452
453
  /**
453
454
  * Link component with button.
package/dist/index.js CHANGED
@@ -865,26 +865,16 @@ function Link(props) {
865
865
  var _a, _b;
866
866
  const { Link: Config } = useConfigContext();
867
867
  const navigate = reactRouterDom.useNavigate();
868
- const [style, setStyle] = react$1.useState();
869
- react$1.useEffect(() => {
870
- let computedStyle = {
871
- ...Config.style || {},
872
- cursor: "pointer",
873
- ...props.style
874
- };
875
- if (props.block)
876
- computedStyle = Object.assign({
877
- display: "block",
878
- width: "100%"
879
- }, computedStyle);
880
- setStyle(computedStyle);
881
- }, [
882
- props.style,
883
- props.block,
884
- Config.style
885
- ]);
886
- if (!style)
887
- return null;
868
+ let computedStyle = {
869
+ ...Config.style || {},
870
+ cursor: "pointer",
871
+ ...props.style
872
+ };
873
+ if (props.block)
874
+ computedStyle = Object.assign({
875
+ display: "block",
876
+ width: "100%"
877
+ }, computedStyle);
888
878
  if (props.href.startsWith("http")) {
889
879
  if (props.button)
890
880
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -892,8 +882,9 @@ function Link(props) {
892
882
  {
893
883
  ...props.button,
894
884
  target: props.target || (Config == null ? void 0 : Config.target) || "_blank",
895
- style,
885
+ style: computedStyle,
896
886
  href: props.href,
887
+ onClick: props.onClick,
897
888
  children: (_a = props.text) != null ? _a : props.children
898
889
  }
899
890
  );
@@ -903,7 +894,8 @@ function Link(props) {
903
894
  {
904
895
  href: props.href,
905
896
  target: props.target || (Config == null ? void 0 : Config.target),
906
- style,
897
+ style: computedStyle,
898
+ onClick: props.onClick,
907
899
  children: props.children
908
900
  }
909
901
  );
@@ -912,8 +904,9 @@ function Link(props) {
912
904
  {
913
905
  href: props.href,
914
906
  target: props.target || (Config == null ? void 0 : Config.target) || "_blank",
915
- style,
907
+ style: computedStyle,
916
908
  copyable: props.copyable,
909
+ onClick: props.onClick,
917
910
  children: props.text
918
911
  }
919
912
  );
@@ -923,8 +916,8 @@ function Link(props) {
923
916
  antd.Button,
924
917
  {
925
918
  ...props.button,
926
- style,
927
- onClick: () => (props.target || (Config == null ? void 0 : Config.target)) === "_blank" ? window.open(props.href) : navigate(props.href),
919
+ style: computedStyle,
920
+ onClick: (e) => props.onClick ? props.onClick(e) : (props.target || (Config == null ? void 0 : Config.target)) === "_blank" ? window.open(props.href) : navigate(props.href),
928
921
  children: (_b = props.text) != null ? _b : props.children
929
922
  }
930
923
  );
@@ -934,7 +927,8 @@ function Link(props) {
934
927
  {
935
928
  to: props.href,
936
929
  target: props.target || (Config == null ? void 0 : Config.target),
937
- style,
930
+ style: computedStyle,
931
+ onClick: props.onClick,
938
932
  children: props.children
939
933
  }
940
934
  );
@@ -943,9 +937,13 @@ function Link(props) {
943
937
  {
944
938
  href: props.href,
945
939
  target: props.target || (Config == null ? void 0 : Config.target),
946
- style,
940
+ style: computedStyle,
947
941
  copyable: props.copyable,
948
942
  onClick: (e) => {
943
+ if (props.onClick) {
944
+ props.onClick(e);
945
+ return;
946
+ }
949
947
  if ((props.target || (Config == null ? void 0 : Config.target)) !== "_blank") {
950
948
  e.preventDefault();
951
949
  navigate(props.href);
package/dist/index.mjs CHANGED
@@ -862,26 +862,16 @@ function Link(props) {
862
862
  var _a, _b;
863
863
  const { Link: Config } = useConfigContext();
864
864
  const navigate = useNavigate();
865
- const [style, setStyle] = useState();
866
- useEffect(() => {
867
- let computedStyle = {
868
- ...Config.style || {},
869
- cursor: "pointer",
870
- ...props.style
871
- };
872
- if (props.block)
873
- computedStyle = Object.assign({
874
- display: "block",
875
- width: "100%"
876
- }, computedStyle);
877
- setStyle(computedStyle);
878
- }, [
879
- props.style,
880
- props.block,
881
- Config.style
882
- ]);
883
- if (!style)
884
- return null;
865
+ let computedStyle = {
866
+ ...Config.style || {},
867
+ cursor: "pointer",
868
+ ...props.style
869
+ };
870
+ if (props.block)
871
+ computedStyle = Object.assign({
872
+ display: "block",
873
+ width: "100%"
874
+ }, computedStyle);
885
875
  if (props.href.startsWith("http")) {
886
876
  if (props.button)
887
877
  return /* @__PURE__ */ jsx(
@@ -889,8 +879,9 @@ function Link(props) {
889
879
  {
890
880
  ...props.button,
891
881
  target: props.target || (Config == null ? void 0 : Config.target) || "_blank",
892
- style,
882
+ style: computedStyle,
893
883
  href: props.href,
884
+ onClick: props.onClick,
894
885
  children: (_a = props.text) != null ? _a : props.children
895
886
  }
896
887
  );
@@ -900,7 +891,8 @@ function Link(props) {
900
891
  {
901
892
  href: props.href,
902
893
  target: props.target || (Config == null ? void 0 : Config.target),
903
- style,
894
+ style: computedStyle,
895
+ onClick: props.onClick,
904
896
  children: props.children
905
897
  }
906
898
  );
@@ -909,8 +901,9 @@ function Link(props) {
909
901
  {
910
902
  href: props.href,
911
903
  target: props.target || (Config == null ? void 0 : Config.target) || "_blank",
912
- style,
904
+ style: computedStyle,
913
905
  copyable: props.copyable,
906
+ onClick: props.onClick,
914
907
  children: props.text
915
908
  }
916
909
  );
@@ -920,8 +913,8 @@ function Link(props) {
920
913
  Button,
921
914
  {
922
915
  ...props.button,
923
- style,
924
- onClick: () => (props.target || (Config == null ? void 0 : Config.target)) === "_blank" ? window.open(props.href) : navigate(props.href),
916
+ style: computedStyle,
917
+ onClick: (e) => props.onClick ? props.onClick(e) : (props.target || (Config == null ? void 0 : Config.target)) === "_blank" ? window.open(props.href) : navigate(props.href),
925
918
  children: (_b = props.text) != null ? _b : props.children
926
919
  }
927
920
  );
@@ -931,7 +924,8 @@ function Link(props) {
931
924
  {
932
925
  to: props.href,
933
926
  target: props.target || (Config == null ? void 0 : Config.target),
934
- style,
927
+ style: computedStyle,
928
+ onClick: props.onClick,
935
929
  children: props.children
936
930
  }
937
931
  );
@@ -940,9 +934,13 @@ function Link(props) {
940
934
  {
941
935
  href: props.href,
942
936
  target: props.target || (Config == null ? void 0 : Config.target),
943
- style,
937
+ style: computedStyle,
944
938
  copyable: props.copyable,
945
939
  onClick: (e) => {
940
+ if (props.onClick) {
941
+ props.onClick(e);
942
+ return;
943
+ }
946
944
  if ((props.target || (Config == null ? void 0 : Config.target)) !== "_blank") {
947
945
  e.preventDefault();
948
946
  navigate(props.href);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faasjs/ant-design",
3
- "version": "0.0.3-beta.102",
3
+ "version": "0.0.3-beta.104",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -22,7 +22,7 @@
22
22
  "dist"
23
23
  ],
24
24
  "dependencies": {
25
- "@faasjs/react": "0.0.3-beta.102",
25
+ "@faasjs/react": "0.0.3-beta.104",
26
26
  "@ant-design/icons": "*",
27
27
  "lodash-es": "*",
28
28
  "dayjs": "*"