szld-libs 0.2.50 → 0.2.52

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.
@@ -18,6 +18,8 @@ interface BackHeaderProps {
18
18
  level?: 1 | 2 | 3 | 4 | 5;
19
19
  /** 自定义图标 */
20
20
  icon?: React.ReactNode;
21
+ /** 自定义返回事件 */
22
+ onBack?: () => void;
21
23
  }
22
24
  declare const BackHeader: (props: BackHeaderProps) => import("react/jsx-runtime").JSX.Element;
23
25
  export default BackHeader;
@@ -15,7 +15,7 @@ const styles = {
15
15
  };
16
16
  const { Title, Text } = Typography;
17
17
  const BackHeader = (props) => {
18
- const { isBack = true, title: title2, extra, subTitle = null, className, style, titleStyle, level = 2, icon } = props;
18
+ const { isBack = true, title: title2, extra, subTitle = null, className, style, titleStyle, level = 2, icon, onBack } = props;
19
19
  const navigate = useNavigate();
20
20
  const renderSubtitle = () => {
21
21
  if (typeof subTitle === "string") {
@@ -24,6 +24,10 @@ const BackHeader = (props) => {
24
24
  return subTitle;
25
25
  };
26
26
  const goBack = () => {
27
+ if (onBack) {
28
+ onBack == null ? void 0 : onBack();
29
+ return;
30
+ }
27
31
  navigate(-1);
28
32
  };
29
33
  return /* @__PURE__ */ jsxs("div", { className: classNames(styles.main, className), style, children: [
@@ -50,6 +50,7 @@ interface FormFieldsProps extends Pick<CreateFormItemProps<ValueType>, "valueTyp
50
50
  value?: any;
51
51
  onBtnClick?: (e: React.MouseEvent<HTMLElement, MouseEvent>, item: ValueBtnProps) => void;
52
52
  inputRef?: any;
53
+ formItemProps?: FormItemProps;
53
54
  }
54
55
  export declare const FormFields: (props: FormFieldsProps) => React.ReactElement<any, string | React.JSXElementConstructor<any>>;
55
56
  export default CreateForm;
@@ -100,7 +100,8 @@ const CreateForm = (props) => {
100
100
  },
101
101
  valueType: item.valueType,
102
102
  onBtnClick,
103
- valueProps: item.valueProps
103
+ valueProps: item.valueProps,
104
+ formItemProps: item.formItemProps
104
105
  }
105
106
  )
106
107
  }
@@ -112,7 +113,7 @@ const CreateForm = (props) => {
112
113
  );
113
114
  };
114
115
  const FormFields = (props) => {
115
- const { valueType, valueProps, value, onChange, onBtnClick, inputRef } = props;
116
+ const { valueType, valueProps, value, onChange, onBtnClick, inputRef, formItemProps } = props;
116
117
  const children = useMemo(() => {
117
118
  let result = /* @__PURE__ */ jsx(Input, { placeholder: "请输入", allowClear: true, ...valueProps });
118
119
  switch (valueType) {
@@ -226,7 +227,7 @@ const FormFields = (props) => {
226
227
  if (valueType === "custom") {
227
228
  const params = valueProps;
228
229
  return React.cloneElement(params.children, {
229
- [getValuePropName(valueType || "input")]: value,
230
+ [(formItemProps == null ? void 0 : formItemProps.valuePropName) || getValuePropName(valueType || "input")]: value,
230
231
  onChange,
231
232
  ref: inputRef
232
233
  });
package/es/index.js CHANGED
@@ -2,7 +2,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { useEffect, useState } from "react";
3
3
  import ReactDOM from "react-dom/client";
4
4
  import { BrowserRouter } from "react-router-dom";
5
- import { App, Form, Table, Flex, Button } from "antd";
5
+ import { App, Form, Table, Upload, Button, Flex, message } from "antd";
6
6
  import useConfig from "./hooks/useConfig";
7
7
  import { useRowSelection, useChangePwd, HmacSM3, BackHeader, SearchTable, CreateForm, CustomPagination } from "./main";
8
8
  let key = "U2FsdGVkX1/dG1NSXNR9hnp3Ech/v6Gh8CDDJxgBm1EPFQel12ySIf84ARXCPwTae7TzwgPvjOyE3S5rAEzl/wAZmId6pbezpFeFcJqxdmIl3FeluYHFxJzQHDETTvrr3G/REvv00kHptOVwg6ecjPH6yk7PNit0sWTBLorROxLxMD8lVDmOA66p7Zp4QnYzqScYJGFbutmfHYXfBRBe1Q2UKummJ798svNY5SIwEwl4spzgyWmhARtuyq4zhysFrj/xODuNDjtwitA6XfX566WcZkj3F+2P+mkYzDYOhXXaomnlybjrZ2hEHfcczQhUfJd89O8PNIuEWo24wjYRgMdKlw5CWSeocFCqV7ZJ/CV/7vNRcaO4awKlFNobLikkwDznxpcX+4UEej+ED+pgfmPQLsKedcfEscStkSAZXaD5pBRTiFU9xGLfDt6seUrEnMBeXkpMIY9j1SZDDK18/G7lSHjDQMZYZP6sfLdBdwY=";
@@ -66,6 +66,29 @@ const Demo = () => {
66
66
  ]
67
67
  }
68
68
  ];
69
+ const imgAccept = ".jpg,.png,.jpeg";
70
+ const imgUploadProps = {
71
+ maxCount: 1,
72
+ action: "uploadAction",
73
+ accept: imgAccept,
74
+ showUploadList: false,
75
+ beforeUpload(file) {
76
+ var _a;
77
+ const accepts = imgAccept.split(",");
78
+ const fileType = (_a = file.name.split(".").pop()) == null ? void 0 : _a.toLocaleLowerCase();
79
+ if (!accepts.includes(`.${fileType}`)) {
80
+ message.error(`只允许上传${accepts.join("、")}文件`);
81
+ return Upload.LIST_IGNORE;
82
+ }
83
+ return file;
84
+ }
85
+ };
86
+ const normFile = (e) => {
87
+ if (Array.isArray(e)) {
88
+ return e;
89
+ }
90
+ return e && e.fileList;
91
+ };
69
92
  const formItems = [
70
93
  {
71
94
  dataIndex: "asctypeid",
@@ -122,6 +145,24 @@ const Demo = () => {
122
145
  colProps: {
123
146
  span: 11
124
147
  }
148
+ },
149
+ {
150
+ dataIndex: "fileList",
151
+ title: "营业执照",
152
+ valueType: "custom",
153
+ valueProps: {
154
+ children: /* @__PURE__ */ jsx(Upload, { ...imgUploadProps, children: /* @__PURE__ */ jsx(Button, { children: "上传营业执照" }) }),
155
+ fileList: form.getFieldValue("fileList")
156
+ },
157
+ colProps: {
158
+ md: 24,
159
+ xl: 10
160
+ },
161
+ formItemProps: {
162
+ valuePropName: "fileList",
163
+ getValueFromEvent: normFile,
164
+ rules: [{ required: true, message: "请上传营业执照" }]
165
+ }
125
166
  }
126
167
  ];
127
168
  const totalText = "共@";
@@ -129,8 +170,8 @@ const Demo = () => {
129
170
  const jumpText = "跳至@";
130
171
  const pageText = "页@";
131
172
  const sm3key = "Aa123456#";
132
- const message = "username=admin&timestamp=1758782465&modelid=19955BC7B61A43B3A982F0B2053ABC34";
133
- HmacSM3.hmac(sm3key, message);
173
+ const msg = "username=admin&timestamp=1758782465&modelid=19955BC7B61A43B3A982F0B2053ABC34";
174
+ HmacSM3.hmac(sm3key, msg);
134
175
  return /* @__PURE__ */ jsxs("div", { style: { height: "100vh", display: "flex", flexDirection: "column", gap: 20 }, children: [
135
176
  /* @__PURE__ */ jsx(BackHeader, { title: "页头组件", isBack: true }),
136
177
  /* @__PURE__ */ jsxs(Flex, { gap: 20, align: "center", children: [
@@ -18,6 +18,8 @@ interface BackHeaderProps {
18
18
  level?: 1 | 2 | 3 | 4 | 5;
19
19
  /** 自定义图标 */
20
20
  icon?: React.ReactNode;
21
+ /** 自定义返回事件 */
22
+ onBack?: () => void;
21
23
  }
22
24
  declare const BackHeader: (props: BackHeaderProps) => import("react/jsx-runtime").JSX.Element;
23
25
  export default BackHeader;
@@ -16,7 +16,7 @@ const styles = {
16
16
  };
17
17
  const { Title, Text } = antd.Typography;
18
18
  const BackHeader = (props) => {
19
- const { isBack = true, title: title2, extra, subTitle = null, className, style, titleStyle, level = 2, icon } = props;
19
+ const { isBack = true, title: title2, extra, subTitle = null, className, style, titleStyle, level = 2, icon, onBack } = props;
20
20
  const navigate = reactRouterDom.useNavigate();
21
21
  const renderSubtitle = () => {
22
22
  if (typeof subTitle === "string") {
@@ -25,6 +25,10 @@ const BackHeader = (props) => {
25
25
  return subTitle;
26
26
  };
27
27
  const goBack = () => {
28
+ if (onBack) {
29
+ onBack == null ? void 0 : onBack();
30
+ return;
31
+ }
28
32
  navigate(-1);
29
33
  };
30
34
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: classNames(styles.main, className), style, children: [
@@ -50,6 +50,7 @@ interface FormFieldsProps extends Pick<CreateFormItemProps<ValueType>, "valueTyp
50
50
  value?: any;
51
51
  onBtnClick?: (e: React.MouseEvent<HTMLElement, MouseEvent>, item: ValueBtnProps) => void;
52
52
  inputRef?: any;
53
+ formItemProps?: FormItemProps;
53
54
  }
54
55
  export declare const FormFields: (props: FormFieldsProps) => React.ReactElement<any, string | React.JSXElementConstructor<any>>;
55
56
  export default CreateForm;
@@ -102,7 +102,8 @@ const CreateForm = (props) => {
102
102
  },
103
103
  valueType: item.valueType,
104
104
  onBtnClick,
105
- valueProps: item.valueProps
105
+ valueProps: item.valueProps,
106
+ formItemProps: item.formItemProps
106
107
  }
107
108
  )
108
109
  }
@@ -114,7 +115,7 @@ const CreateForm = (props) => {
114
115
  );
115
116
  };
116
117
  const FormFields = (props) => {
117
- const { valueType, valueProps, value, onChange, onBtnClick, inputRef } = props;
118
+ const { valueType, valueProps, value, onChange, onBtnClick, inputRef, formItemProps } = props;
118
119
  const children = React.useMemo(() => {
119
120
  let result = /* @__PURE__ */ jsxRuntime.jsx(antd.Input, { placeholder: "请输入", allowClear: true, ...valueProps });
120
121
  switch (valueType) {
@@ -228,7 +229,7 @@ const FormFields = (props) => {
228
229
  if (valueType === "custom") {
229
230
  const params = valueProps;
230
231
  return React.cloneElement(params.children, {
231
- [getValuePropName(valueType || "input")]: value,
232
+ [(formItemProps == null ? void 0 : formItemProps.valuePropName) || getValuePropName(valueType || "input")]: value,
232
233
  onChange,
233
234
  ref: inputRef
234
235
  });
package/lib/index.js CHANGED
@@ -67,6 +67,29 @@ const Demo = () => {
67
67
  ]
68
68
  }
69
69
  ];
70
+ const imgAccept = ".jpg,.png,.jpeg";
71
+ const imgUploadProps = {
72
+ maxCount: 1,
73
+ action: "uploadAction",
74
+ accept: imgAccept,
75
+ showUploadList: false,
76
+ beforeUpload(file) {
77
+ var _a;
78
+ const accepts = imgAccept.split(",");
79
+ const fileType = (_a = file.name.split(".").pop()) == null ? void 0 : _a.toLocaleLowerCase();
80
+ if (!accepts.includes(`.${fileType}`)) {
81
+ antd.message.error(`只允许上传${accepts.join("、")}文件`);
82
+ return antd.Upload.LIST_IGNORE;
83
+ }
84
+ return file;
85
+ }
86
+ };
87
+ const normFile = (e) => {
88
+ if (Array.isArray(e)) {
89
+ return e;
90
+ }
91
+ return e && e.fileList;
92
+ };
70
93
  const formItems = [
71
94
  {
72
95
  dataIndex: "asctypeid",
@@ -123,6 +146,24 @@ const Demo = () => {
123
146
  colProps: {
124
147
  span: 11
125
148
  }
149
+ },
150
+ {
151
+ dataIndex: "fileList",
152
+ title: "营业执照",
153
+ valueType: "custom",
154
+ valueProps: {
155
+ children: /* @__PURE__ */ jsxRuntime.jsx(antd.Upload, { ...imgUploadProps, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Button, { children: "上传营业执照" }) }),
156
+ fileList: form.getFieldValue("fileList")
157
+ },
158
+ colProps: {
159
+ md: 24,
160
+ xl: 10
161
+ },
162
+ formItemProps: {
163
+ valuePropName: "fileList",
164
+ getValueFromEvent: normFile,
165
+ rules: [{ required: true, message: "请上传营业执照" }]
166
+ }
126
167
  }
127
168
  ];
128
169
  const totalText = "共@";
@@ -130,8 +171,8 @@ const Demo = () => {
130
171
  const jumpText = "跳至@";
131
172
  const pageText = "页@";
132
173
  const sm3key = "Aa123456#";
133
- const message = "username=admin&timestamp=1758782465&modelid=19955BC7B61A43B3A982F0B2053ABC34";
134
- main.HmacSM3.hmac(sm3key, message);
174
+ const msg = "username=admin&timestamp=1758782465&modelid=19955BC7B61A43B3A982F0B2053ABC34";
175
+ main.HmacSM3.hmac(sm3key, msg);
135
176
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { height: "100vh", display: "flex", flexDirection: "column", gap: 20 }, children: [
136
177
  /* @__PURE__ */ jsxRuntime.jsx(main.BackHeader, { title: "页头组件", isBack: true }),
137
178
  /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { gap: 20, align: "center", children: [
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "szld-libs",
3
3
  "private": false,
4
- "version": "0.2.50",
4
+ "version": "0.2.52",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "dev": "vite",