listpage-next 0.0.231 → 0.0.233

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.
@@ -5,7 +5,25 @@ import { styled } from "styled-components";
5
5
  import { CloseOutlined } from "@ant-design/icons";
6
6
  import { AsyncButton } from "../../../AsyncButton/index.js";
7
7
  function useActions(props) {
8
- const { actionPosition = 'bottom', okText, cancelText, onOk, icon, title, onCancel, extraActions } = props;
8
+ const { actionPosition = 'bottom', okText, cancelText, onOk, icon, title, onCancel, extraActions, closable = true } = props;
9
+ const closeButton = useMemo(()=>{
10
+ if (true === closable) return /*#__PURE__*/ jsx(CloseButton, {
11
+ type: "text",
12
+ icon: /*#__PURE__*/ jsx(CloseOutlined, {}),
13
+ onClick: onCancel
14
+ });
15
+ if (false === closable) return null;
16
+ const { closeIcon, disabled } = closable;
17
+ return /*#__PURE__*/ jsx(CloseButton, {
18
+ type: "text",
19
+ disabled: disabled,
20
+ icon: closeIcon || /*#__PURE__*/ jsx(CloseOutlined, {}),
21
+ onClick: onCancel
22
+ });
23
+ }, [
24
+ closable,
25
+ onCancel
26
+ ]);
9
27
  const actions = 'none' === actionPosition ? null : /*#__PURE__*/ jsxs(Fragment, {
10
28
  children: [
11
29
  /*#__PURE__*/ jsx(Button, {
@@ -14,9 +32,6 @@ function useActions(props) {
14
32
  children: cancelText || '取消'
15
33
  }),
16
34
  /*#__PURE__*/ jsx(AsyncButton, {
17
- style: {
18
- marginLeft: '0.65rem'
19
- },
20
35
  type: "primary",
21
36
  onClick: onOk,
22
37
  children: okText || '确定'
@@ -24,9 +39,9 @@ function useActions(props) {
24
39
  ]
25
40
  });
26
41
  const footer = useMemo(()=>{
27
- if ('bottom' === actionPosition) return /*#__PURE__*/ jsxs(Fragment, {
42
+ if ('bottom' === actionPosition) return /*#__PURE__*/ jsxs(ExtraContainer, {
28
43
  children: [
29
- /*#__PURE__*/ jsx(FlexContainer, {
44
+ /*#__PURE__*/ jsx(Fragment, {
30
45
  children: extraActions
31
46
  }),
32
47
  /*#__PURE__*/ jsx(Fragment, {
@@ -49,7 +64,7 @@ function useActions(props) {
49
64
  title
50
65
  ]
51
66
  }),
52
- /*#__PURE__*/ jsxs(FlexContainer, {
67
+ /*#__PURE__*/ jsxs(ExtraContainer, {
53
68
  children: [
54
69
  extraActions,
55
70
  actions
@@ -65,14 +80,10 @@ function useActions(props) {
65
80
  title
66
81
  ]
67
82
  }),
68
- /*#__PURE__*/ jsxs(FlexContainer, {
83
+ /*#__PURE__*/ jsxs(ExtraContainer, {
69
84
  children: [
70
85
  extraActions,
71
- /*#__PURE__*/ jsx(Button, {
72
- type: "text",
73
- icon: /*#__PURE__*/ jsx(CloseOutlined, {}),
74
- onClick: onCancel
75
- })
86
+ closeButton
76
87
  ]
77
88
  })
78
89
  ]
@@ -84,10 +95,12 @@ function useActions(props) {
84
95
  ]
85
96
  });
86
97
  }, [
98
+ actionPosition,
87
99
  icon,
88
100
  title,
89
101
  actions,
90
- extraActions
102
+ extraActions,
103
+ closeButton
91
104
  ]);
92
105
  return {
93
106
  footer,
@@ -96,6 +109,7 @@ function useActions(props) {
96
109
  }
97
110
  const FlexContainer = styled.div`
98
111
  flex-grow: 1;
112
+ flex-shrink: 1;
99
113
  display: flex;
100
114
  align-items: center;
101
115
  gap: 4px;
@@ -104,4 +118,18 @@ const HeaderContainer = styled.div`
104
118
  display: flex;
105
119
  align-items: center;
106
120
  `;
121
+ const ExtraContainer = styled.div`
122
+ flex-grow: 0;
123
+ flex-shrink: 0;
124
+ display: flex;
125
+ align-items: center;
126
+ gap: 8px;
127
+ justify-content: flex-end;
128
+ `;
129
+ const CloseButton = styled(Button)`
130
+ color: rgba(0, 0, 0, 0.45);
131
+ :hover {
132
+ color: rgba(0, 0, 0, 0.88);
133
+ }
134
+ `;
107
135
  export { useActions };
@@ -6,7 +6,7 @@ export interface ListPageProps<FilterValue = any, RecordValue extends Record<str
6
6
  page?: React.CSSProperties;
7
7
  table?: React.CSSProperties;
8
8
  };
9
- pageRef?: React.RefObject<ListPageContext<FilterValue, RecordValue>>;
9
+ pageRef?: React.RefObject<ListPageContext<FilterValue, RecordValue> | null>;
10
10
  request: ListPageRequest<FilterValue, RecordValue>;
11
11
  storageKey?: string;
12
12
  initialValues?: StateValue<FilterValue>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "listpage-next",
3
- "version": "0.0.231",
3
+ "version": "0.0.233",
4
4
  "description": "A React component library for creating filter forms with Ant Design",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",