@rufous/ui 0.1.43 → 0.1.46

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.
@@ -85,37 +85,51 @@ var SubmitButton = ({
85
85
  ...props
86
86
  }) => {
87
87
  const [loading, setLoading] = React3.useState(false);
88
- const handleClick = async (e) => {
88
+ const clickTimeout = React3.useRef(null);
89
+ const handleClick = async () => {
89
90
  if (loading) return;
90
- if (onClick) {
91
- setLoading(true);
92
- try {
93
- await onClick(e);
94
- } finally {
95
- setLoading(false);
96
- }
91
+ if (clickTimeout.current) {
92
+ clearTimeout(clickTimeout.current);
93
+ clickTimeout.current = null;
97
94
  }
95
+ clickTimeout.current = setTimeout(async () => {
96
+ if (onClick) {
97
+ setLoading(true);
98
+ try {
99
+ await onClick();
100
+ } finally {
101
+ setLoading(false);
102
+ }
103
+ }
104
+ }, 250);
98
105
  };
99
- const handleDoubleClick = async (e) => {
106
+ const handleDoubleClick = async () => {
100
107
  if (loading) return;
108
+ if (clickTimeout.current) {
109
+ clearTimeout(clickTimeout.current);
110
+ clickTimeout.current = null;
111
+ }
101
112
  if (onDoubleClick) {
102
113
  setLoading(true);
103
114
  try {
104
- await onDoubleClick(e);
115
+ await onDoubleClick();
105
116
  } finally {
106
117
  setLoading(false);
107
118
  }
108
119
  }
109
120
  };
110
- const buttonProps = {
111
- ...props,
112
- className: `btn submit-btn ${bgGradiant ? "submit-btn-gradiant" : ""} ${props.className ?? ""}`,
113
- disabled: props.disabled || loading || isLoading,
114
- ...onClick ? {} : { type },
115
- onClick: handleClick,
116
- onDoubleClick: handleDoubleClick
117
- };
118
- return /* @__PURE__ */ React3.createElement("button", { ...buttonProps }, /* @__PURE__ */ React3.createElement("span", { className: "btn-content" }, children, (loading || isLoading) && /* @__PURE__ */ React3.createElement("span", { className: "btn-loader" }, /* @__PURE__ */ React3.createElement(circularProgress_default, { size: 18 }))));
121
+ return /* @__PURE__ */ React3.createElement(
122
+ "button",
123
+ {
124
+ ...props,
125
+ type: onClick ? void 0 : type,
126
+ className: `submit-btn ${bgGradiant ? "submit-btn-gradiant" : ""} ${props.className ?? ""}`,
127
+ disabled: props.disabled || loading || isLoading,
128
+ onClick: handleClick,
129
+ onDoubleClick: handleDoubleClick
130
+ },
131
+ /* @__PURE__ */ React3.createElement("span", { className: "btn-content" }, children, (loading || isLoading) && /* @__PURE__ */ React3.createElement("span", { className: "btn-loader" }, /* @__PURE__ */ React3.createElement(circularProgress_default, { size: 18, color: props.disabled || loading || isLoading ? "#00000042" : void 0 })))
132
+ );
119
133
  };
120
134
  var submitButton_default = SubmitButton;
121
135
 
@@ -10,7 +10,7 @@ import {
10
10
  } from "../chunk-R3GARAVJ.js";
11
11
  import {
12
12
  submitButton_default
13
- } from "../chunk-VJUSHVAE.js";
13
+ } from "../chunk-N4DJIU6C.js";
14
14
  import "../chunk-YRFUVQDN.js";
15
15
  export {
16
16
  addButton_default as AddButton,
@@ -73,36 +73,50 @@ var SubmitButton = ({
73
73
  ...props
74
74
  }) => {
75
75
  const [loading, setLoading] = React2.useState(false);
76
- const handleClick = async (e) => {
76
+ const clickTimeout = React2.useRef(null);
77
+ const handleClick = async () => {
77
78
  if (loading) return;
78
- if (onClick) {
79
- setLoading(true);
80
- try {
81
- await onClick(e);
82
- } finally {
83
- setLoading(false);
84
- }
79
+ if (clickTimeout.current) {
80
+ clearTimeout(clickTimeout.current);
81
+ clickTimeout.current = null;
85
82
  }
83
+ clickTimeout.current = setTimeout(async () => {
84
+ if (onClick) {
85
+ setLoading(true);
86
+ try {
87
+ await onClick();
88
+ } finally {
89
+ setLoading(false);
90
+ }
91
+ }
92
+ }, 250);
86
93
  };
87
- const handleDoubleClick = async (e) => {
94
+ const handleDoubleClick = async () => {
88
95
  if (loading) return;
96
+ if (clickTimeout.current) {
97
+ clearTimeout(clickTimeout.current);
98
+ clickTimeout.current = null;
99
+ }
89
100
  if (onDoubleClick) {
90
101
  setLoading(true);
91
102
  try {
92
- await onDoubleClick(e);
103
+ await onDoubleClick();
93
104
  } finally {
94
105
  setLoading(false);
95
106
  }
96
107
  }
97
108
  };
98
- const buttonProps = {
99
- ...props,
100
- className: `btn submit-btn ${bgGradiant ? "submit-btn-gradiant" : ""} ${props.className ?? ""}`,
101
- disabled: props.disabled || loading || isLoading,
102
- ...onClick ? {} : { type },
103
- onClick: handleClick,
104
- onDoubleClick: handleDoubleClick
105
- };
106
- return /* @__PURE__ */ React2.createElement("button", { ...buttonProps }, /* @__PURE__ */ React2.createElement("span", { className: "btn-content" }, children, (loading || isLoading) && /* @__PURE__ */ React2.createElement("span", { className: "btn-loader" }, /* @__PURE__ */ React2.createElement(circularProgress_default, { size: 18 }))));
109
+ return /* @__PURE__ */ React2.createElement(
110
+ "button",
111
+ {
112
+ ...props,
113
+ type: onClick ? void 0 : type,
114
+ className: `submit-btn ${bgGradiant ? "submit-btn-gradiant" : ""} ${props.className ?? ""}`,
115
+ disabled: props.disabled || loading || isLoading,
116
+ onClick: handleClick,
117
+ onDoubleClick: handleDoubleClick
118
+ },
119
+ /* @__PURE__ */ React2.createElement("span", { className: "btn-content" }, children, (loading || isLoading) && /* @__PURE__ */ React2.createElement("span", { className: "btn-loader" }, /* @__PURE__ */ React2.createElement(circularProgress_default, { size: 18, color: props.disabled || loading || isLoading ? "#00000042" : void 0 })))
120
+ );
107
121
  };
108
122
  var submitButton_default = SubmitButton;
@@ -4,8 +4,8 @@ interface SubmitButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement
4
4
  children: React.ReactNode;
5
5
  type?: "button" | "submit" | "reset";
6
6
  bgGradiant?: boolean;
7
- onClick?: React.MouseEventHandler<HTMLButtonElement>;
8
- onDoubleClick?: React.MouseEventHandler<HTMLButtonElement>;
7
+ onClick?: () => Promise<void> | void;
8
+ onDoubleClick?: () => Promise<void> | void;
9
9
  isLoading?: boolean;
10
10
  }
11
11
  declare const SubmitButton: React.FC<SubmitButtonProps>;
@@ -4,8 +4,8 @@ interface SubmitButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement
4
4
  children: React.ReactNode;
5
5
  type?: "button" | "submit" | "reset";
6
6
  bgGradiant?: boolean;
7
- onClick?: React.MouseEventHandler<HTMLButtonElement>;
8
- onDoubleClick?: React.MouseEventHandler<HTMLButtonElement>;
7
+ onClick?: () => Promise<void> | void;
8
+ onDoubleClick?: () => Promise<void> | void;
9
9
  isLoading?: boolean;
10
10
  }
11
11
  declare const SubmitButton: React.FC<SubmitButtonProps>;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  submitButton_default
3
- } from "../chunk-VJUSHVAE.js";
3
+ } from "../chunk-N4DJIU6C.js";
4
4
  import "../chunk-YRFUVQDN.js";
5
5
  export {
6
6
  submitButton_default as default
@@ -75,7 +75,7 @@
75
75
  }
76
76
  .submit-btn:disabled {
77
77
  background-color: #e0e0e0;
78
- color: #9e9e9e;
78
+ color: #00000042;
79
79
  cursor: not-allowed;
80
80
  }
81
81
  .btn-content {
@@ -61,7 +61,7 @@ import "../chunk-QPGJCRBS.js";
61
61
  import "../chunk-U7SARO5B.js";
62
62
  import "../chunk-BMMDUQDJ.js";
63
63
  import "../chunk-R3GARAVJ.js";
64
- import "../chunk-VJUSHVAE.js";
64
+ import "../chunk-N4DJIU6C.js";
65
65
  import "../chunk-YRFUVQDN.js";
66
66
  export {
67
67
  BaseDialog_default as default
@@ -75,7 +75,7 @@
75
75
  }
76
76
  .submit-btn:disabled {
77
77
  background-color: #e0e0e0;
78
- color: #9e9e9e;
78
+ color: #00000042;
79
79
  cursor: not-allowed;
80
80
  }
81
81
  .btn-content {
@@ -61,7 +61,7 @@ import "../chunk-QPGJCRBS.js";
61
61
  import "../chunk-U7SARO5B.js";
62
62
  import "../chunk-BMMDUQDJ.js";
63
63
  import "../chunk-R3GARAVJ.js";
64
- import "../chunk-VJUSHVAE.js";
64
+ import "../chunk-N4DJIU6C.js";
65
65
  import "../chunk-YRFUVQDN.js";
66
66
  export {
67
67
  BaseDialog_default as BaseDialog
@@ -0,0 +1,67 @@
1
+ import {
2
+ circularProgress_default
3
+ } from "./chunk-YRFUVQDN.js";
4
+
5
+ // lib/Buttons/submitButton.tsx
6
+ import * as React from "react";
7
+ var SubmitButton = ({
8
+ children,
9
+ type = "submit",
10
+ onClick,
11
+ onDoubleClick,
12
+ isLoading = false,
13
+ bgGradiant = false,
14
+ ...props
15
+ }) => {
16
+ const [loading, setLoading] = React.useState(false);
17
+ const clickTimeout = React.useRef(null);
18
+ const handleClick = async () => {
19
+ if (loading) return;
20
+ if (clickTimeout.current) {
21
+ clearTimeout(clickTimeout.current);
22
+ clickTimeout.current = null;
23
+ }
24
+ clickTimeout.current = setTimeout(async () => {
25
+ if (onClick) {
26
+ setLoading(true);
27
+ try {
28
+ await onClick();
29
+ } finally {
30
+ setLoading(false);
31
+ }
32
+ }
33
+ }, 250);
34
+ };
35
+ const handleDoubleClick = async () => {
36
+ if (loading) return;
37
+ if (clickTimeout.current) {
38
+ clearTimeout(clickTimeout.current);
39
+ clickTimeout.current = null;
40
+ }
41
+ if (onDoubleClick) {
42
+ setLoading(true);
43
+ try {
44
+ await onDoubleClick();
45
+ } finally {
46
+ setLoading(false);
47
+ }
48
+ }
49
+ };
50
+ return /* @__PURE__ */ React.createElement(
51
+ "button",
52
+ {
53
+ ...props,
54
+ type: onClick ? void 0 : type,
55
+ className: `submit-btn ${bgGradiant ? "submit-btn-gradiant" : ""} ${props.className ?? ""}`,
56
+ disabled: props.disabled || loading || isLoading,
57
+ onClick: handleClick,
58
+ onDoubleClick: handleDoubleClick
59
+ },
60
+ /* @__PURE__ */ React.createElement("span", { className: "btn-content" }, children, (loading || isLoading) && /* @__PURE__ */ React.createElement("span", { className: "btn-loader" }, /* @__PURE__ */ React.createElement(circularProgress_default, { size: 18, color: props.disabled || loading || isLoading ? "#00000042" : void 0 })))
61
+ );
62
+ };
63
+ var submitButton_default = SubmitButton;
64
+
65
+ export {
66
+ submitButton_default
67
+ };
package/dist/main.cjs CHANGED
@@ -1135,37 +1135,51 @@ var SubmitButton = ({
1135
1135
  ...props
1136
1136
  }) => {
1137
1137
  const [loading, setLoading] = React56.useState(false);
1138
- const handleClick = async (e) => {
1138
+ const clickTimeout = React56.useRef(null);
1139
+ const handleClick = async () => {
1139
1140
  if (loading) return;
1140
- if (onClick) {
1141
- setLoading(true);
1142
- try {
1143
- await onClick(e);
1144
- } finally {
1145
- setLoading(false);
1146
- }
1141
+ if (clickTimeout.current) {
1142
+ clearTimeout(clickTimeout.current);
1143
+ clickTimeout.current = null;
1147
1144
  }
1145
+ clickTimeout.current = setTimeout(async () => {
1146
+ if (onClick) {
1147
+ setLoading(true);
1148
+ try {
1149
+ await onClick();
1150
+ } finally {
1151
+ setLoading(false);
1152
+ }
1153
+ }
1154
+ }, 250);
1148
1155
  };
1149
- const handleDoubleClick = async (e) => {
1156
+ const handleDoubleClick = async () => {
1150
1157
  if (loading) return;
1158
+ if (clickTimeout.current) {
1159
+ clearTimeout(clickTimeout.current);
1160
+ clickTimeout.current = null;
1161
+ }
1151
1162
  if (onDoubleClick) {
1152
1163
  setLoading(true);
1153
1164
  try {
1154
- await onDoubleClick(e);
1165
+ await onDoubleClick();
1155
1166
  } finally {
1156
1167
  setLoading(false);
1157
1168
  }
1158
1169
  }
1159
1170
  };
1160
- const buttonProps = {
1161
- ...props,
1162
- className: `btn submit-btn ${bgGradiant ? "submit-btn-gradiant" : ""} ${props.className ?? ""}`,
1163
- disabled: props.disabled || loading || isLoading,
1164
- ...onClick ? {} : { type },
1165
- onClick: handleClick,
1166
- onDoubleClick: handleDoubleClick
1167
- };
1168
- return /* @__PURE__ */ React56.createElement("button", { ...buttonProps }, /* @__PURE__ */ React56.createElement("span", { className: "btn-content" }, children, (loading || isLoading) && /* @__PURE__ */ React56.createElement("span", { className: "btn-loader" }, /* @__PURE__ */ React56.createElement(circularProgress_default, { size: 18 }))));
1171
+ return /* @__PURE__ */ React56.createElement(
1172
+ "button",
1173
+ {
1174
+ ...props,
1175
+ type: onClick ? void 0 : type,
1176
+ className: `submit-btn ${bgGradiant ? "submit-btn-gradiant" : ""} ${props.className ?? ""}`,
1177
+ disabled: props.disabled || loading || isLoading,
1178
+ onClick: handleClick,
1179
+ onDoubleClick: handleDoubleClick
1180
+ },
1181
+ /* @__PURE__ */ React56.createElement("span", { className: "btn-content" }, children, (loading || isLoading) && /* @__PURE__ */ React56.createElement("span", { className: "btn-loader" }, /* @__PURE__ */ React56.createElement(circularProgress_default, { size: 18, color: props.disabled || loading || isLoading ? "#00000042" : void 0 })))
1182
+ );
1169
1183
  };
1170
1184
  var submitButton_default = SubmitButton;
1171
1185
 
package/dist/main.css CHANGED
@@ -75,7 +75,7 @@
75
75
  }
76
76
  .submit-btn:disabled {
77
77
  background-color: #e0e0e0;
78
- color: #9e9e9e;
78
+ color: #00000042;
79
79
  cursor: not-allowed;
80
80
  }
81
81
  .btn-content {
package/dist/main.js CHANGED
@@ -180,7 +180,7 @@ import {
180
180
  } from "./chunk-R3GARAVJ.js";
181
181
  import {
182
182
  submitButton_default
183
- } from "./chunk-VJUSHVAE.js";
183
+ } from "./chunk-N4DJIU6C.js";
184
184
  import "./chunk-YRFUVQDN.js";
185
185
  export {
186
186
  APP_THEMES,
package/dist/style.css CHANGED
@@ -75,7 +75,7 @@
75
75
  }
76
76
  .submit-btn:disabled {
77
77
  background-color: #e0e0e0;
78
- color: #9e9e9e;
78
+ color: #00000042;
79
79
  cursor: not-allowed;
80
80
  }
81
81
  .btn-content {
@@ -75,7 +75,7 @@
75
75
  }
76
76
  .submit-btn:disabled {
77
77
  background-color: #e0e0e0;
78
- color: #9e9e9e;
78
+ color: #00000042;
79
79
  cursor: not-allowed;
80
80
  }
81
81
  .btn-content {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rufous/ui",
3
3
  "private": false,
4
- "version": "0.1.43",
4
+ "version": "0.1.46",
5
5
  "type": "module",
6
6
  "style": "./dist/style.css",
7
7
  "files": [
@@ -1,53 +0,0 @@
1
- import {
2
- circularProgress_default
3
- } from "./chunk-YRFUVQDN.js";
4
-
5
- // lib/Buttons/submitButton.tsx
6
- import * as React from "react";
7
- var SubmitButton = ({
8
- children,
9
- type = "submit",
10
- onClick,
11
- onDoubleClick,
12
- isLoading = false,
13
- bgGradiant = false,
14
- ...props
15
- }) => {
16
- const [loading, setLoading] = React.useState(false);
17
- const handleClick = async (e) => {
18
- if (loading) return;
19
- if (onClick) {
20
- setLoading(true);
21
- try {
22
- await onClick(e);
23
- } finally {
24
- setLoading(false);
25
- }
26
- }
27
- };
28
- const handleDoubleClick = async (e) => {
29
- if (loading) return;
30
- if (onDoubleClick) {
31
- setLoading(true);
32
- try {
33
- await onDoubleClick(e);
34
- } finally {
35
- setLoading(false);
36
- }
37
- }
38
- };
39
- const buttonProps = {
40
- ...props,
41
- className: `btn submit-btn ${bgGradiant ? "submit-btn-gradiant" : ""} ${props.className ?? ""}`,
42
- disabled: props.disabled || loading || isLoading,
43
- ...onClick ? {} : { type },
44
- onClick: handleClick,
45
- onDoubleClick: handleDoubleClick
46
- };
47
- return /* @__PURE__ */ React.createElement("button", { ...buttonProps }, /* @__PURE__ */ React.createElement("span", { className: "btn-content" }, children, (loading || isLoading) && /* @__PURE__ */ React.createElement("span", { className: "btn-loader" }, /* @__PURE__ */ React.createElement(circularProgress_default, { size: 18 }))));
48
- };
49
- var submitButton_default = SubmitButton;
50
-
51
- export {
52
- submitButton_default
53
- };