listpage-next 0.0.230 → 0.0.232

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.
@@ -1,10 +1,29 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  import { Button } from "antd";
3
- import { AsyncButton } from "../../../AsyncButton/index.js";
4
3
  import { useMemo } from "react";
5
4
  import { styled } from "styled-components";
5
+ import { CloseOutlined } from "@ant-design/icons";
6
+ import { AsyncButton } from "../../../AsyncButton/index.js";
6
7
  function useActions(props) {
7
- 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(Button, {
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(Button, {
18
+ type: "text",
19
+ disabled: disabled,
20
+ icon: closeIcon || /*#__PURE__*/ jsx(CloseOutlined, {}),
21
+ onClick: onCancel
22
+ });
23
+ }, [
24
+ closable,
25
+ onCancel
26
+ ]);
8
27
  const actions = 'none' === actionPosition ? null : /*#__PURE__*/ jsxs(Fragment, {
9
28
  children: [
10
29
  /*#__PURE__*/ jsx(Button, {
@@ -23,12 +42,12 @@ function useActions(props) {
23
42
  ]
24
43
  });
25
44
  const footer = useMemo(()=>{
26
- if ('bottom' === actionPosition) return /*#__PURE__*/ jsxs(Fragment, {
45
+ if ('bottom' === actionPosition) return /*#__PURE__*/ jsxs(ExtraContainer, {
27
46
  children: [
28
- /*#__PURE__*/ jsx(FlexContainer, {
47
+ /*#__PURE__*/ jsx(Fragment, {
29
48
  children: extraActions
30
49
  }),
31
- /*#__PURE__*/ jsx("div", {
50
+ /*#__PURE__*/ jsx(Fragment, {
32
51
  children: actions
33
52
  })
34
53
  ]
@@ -48,7 +67,7 @@ function useActions(props) {
48
67
  title
49
68
  ]
50
69
  }),
51
- /*#__PURE__*/ jsxs("div", {
70
+ /*#__PURE__*/ jsxs(ExtraContainer, {
52
71
  children: [
53
72
  extraActions,
54
73
  actions
@@ -56,6 +75,22 @@ function useActions(props) {
56
75
  })
57
76
  ]
58
77
  });
78
+ if ('none' === actionPosition) return /*#__PURE__*/ jsxs(HeaderContainer, {
79
+ children: [
80
+ /*#__PURE__*/ jsxs(FlexContainer, {
81
+ children: [
82
+ icon,
83
+ title
84
+ ]
85
+ }),
86
+ /*#__PURE__*/ jsxs(ExtraContainer, {
87
+ children: [
88
+ extraActions,
89
+ closeButton
90
+ ]
91
+ })
92
+ ]
93
+ });
59
94
  return /*#__PURE__*/ jsxs(FlexContainer, {
60
95
  children: [
61
96
  icon,
@@ -63,10 +98,12 @@ function useActions(props) {
63
98
  ]
64
99
  });
65
100
  }, [
101
+ actionPosition,
66
102
  icon,
67
103
  title,
68
104
  actions,
69
- extraActions
105
+ extraActions,
106
+ closeButton
70
107
  ]);
71
108
  return {
72
109
  footer,
@@ -75,6 +112,7 @@ function useActions(props) {
75
112
  }
76
113
  const FlexContainer = styled.div`
77
114
  flex-grow: 1;
115
+ flex-shrink: 1;
78
116
  display: flex;
79
117
  align-items: center;
80
118
  gap: 4px;
@@ -83,4 +121,12 @@ const HeaderContainer = styled.div`
83
121
  display: flex;
84
122
  align-items: center;
85
123
  `;
124
+ const ExtraContainer = styled.div`
125
+ flex-grow: 0;
126
+ flex-shrink: 0;
127
+ display: flex;
128
+ align-items: center;
129
+ gap: 4px;
130
+ justify-content: flex-end;
131
+ `;
86
132
  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.230",
3
+ "version": "0.0.232",
4
4
  "description": "A React component library for creating filter forms with Ant Design",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",