allaw-ui 0.1.26 → 0.1.28
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,14 +1,18 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import React, { ButtonHTMLAttributes } from "react";
|
|
2
2
|
import "./SecondaryButton.css";
|
|
3
3
|
import "../../../styles/global.css";
|
|
4
|
-
export interface SecondaryButtonProps {
|
|
4
|
+
export interface SecondaryButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
5
5
|
startIcon?: React.ReactNode;
|
|
6
6
|
endIcon?: React.ReactNode;
|
|
7
|
+
startIconName?: string;
|
|
8
|
+
endIconName?: string;
|
|
7
9
|
label: string;
|
|
8
10
|
disabled?: boolean;
|
|
9
11
|
mode?: "dark" | "light";
|
|
10
|
-
onClick?: () => void;
|
|
12
|
+
onClick?: () => Promise<void> | void;
|
|
11
13
|
fullWidth?: boolean;
|
|
14
|
+
type?: "button" | "submit" | "reset";
|
|
15
|
+
isLoading?: boolean;
|
|
12
16
|
}
|
|
13
|
-
declare const SecondaryButton: React.
|
|
17
|
+
declare const SecondaryButton: React.ForwardRefExoticComponent<SecondaryButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
14
18
|
export default SecondaryButton;
|
|
@@ -1,11 +1,117 @@
|
|
|
1
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
50
|
+
var t = {};
|
|
51
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
52
|
+
t[p] = s[p];
|
|
53
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
54
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
55
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
56
|
+
t[p[i]] = s[p[i]];
|
|
57
|
+
}
|
|
58
|
+
return t;
|
|
59
|
+
};
|
|
60
|
+
import React, { forwardRef, useImperativeHandle, useState, useEffect, } from "react";
|
|
2
61
|
import "./SecondaryButton.css";
|
|
3
62
|
import "../../../styles/global.css";
|
|
4
|
-
var SecondaryButton = function (_a) {
|
|
5
|
-
var startIcon = _a.startIcon, endIcon = _a.endIcon, label = _a.label, _b = _a.disabled, disabled = _b === void 0 ? false : _b, _c = _a.mode, mode = _c === void 0 ? "dark" : _c, onClick = _a.onClick, _d = _a.fullWidth, fullWidth = _d === void 0 ? false : _d;
|
|
6
|
-
|
|
7
|
-
|
|
63
|
+
var SecondaryButton = forwardRef(function (_a, ref) {
|
|
64
|
+
var startIcon = _a.startIcon, endIcon = _a.endIcon, startIconName = _a.startIconName, endIconName = _a.endIconName, label = _a.label, _b = _a.disabled, disabled = _b === void 0 ? false : _b, _c = _a.mode, mode = _c === void 0 ? "dark" : _c, onClick = _a.onClick, _d = _a.fullWidth, fullWidth = _d === void 0 ? false : _d, _e = _a.type, type = _e === void 0 ? "button" : _e, _f = _a.isLoading, isLoading = _f === void 0 ? false : _f, props = __rest(_a, ["startIcon", "endIcon", "startIconName", "endIconName", "label", "disabled", "mode", "onClick", "fullWidth", "type", "isLoading"]);
|
|
65
|
+
var buttonRef = React.useRef(null);
|
|
66
|
+
var _g = useState(false), internalIsLoading = _g[0], setInternalIsLoading = _g[1];
|
|
67
|
+
var _h = useState(""), loadingDots = _h[0], setLoadingDots = _h[1];
|
|
68
|
+
useImperativeHandle(ref, function () { return buttonRef.current; });
|
|
69
|
+
var isButtonLoading = isLoading || internalIsLoading;
|
|
70
|
+
useEffect(function () {
|
|
71
|
+
var interval = null;
|
|
72
|
+
if (isButtonLoading) {
|
|
73
|
+
interval = setInterval(function () {
|
|
74
|
+
setLoadingDots(function (prev) {
|
|
75
|
+
if (prev.length >= 3)
|
|
76
|
+
return "";
|
|
77
|
+
return prev + ".";
|
|
78
|
+
});
|
|
79
|
+
}, 500);
|
|
80
|
+
}
|
|
81
|
+
return function () {
|
|
82
|
+
if (interval) {
|
|
83
|
+
clearInterval(interval);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
}, [isButtonLoading]);
|
|
87
|
+
var handleClick = function (event) { return __awaiter(void 0, void 0, void 0, function () {
|
|
88
|
+
return __generator(this, function (_a) {
|
|
89
|
+
switch (_a.label) {
|
|
90
|
+
case 0:
|
|
91
|
+
if (isButtonLoading) {
|
|
92
|
+
event.preventDefault();
|
|
93
|
+
return [2 /*return*/];
|
|
94
|
+
}
|
|
95
|
+
if (!onClick) return [3 /*break*/, 4];
|
|
96
|
+
setInternalIsLoading(true);
|
|
97
|
+
_a.label = 1;
|
|
98
|
+
case 1:
|
|
99
|
+
_a.trys.push([1, , 3, 4]);
|
|
100
|
+
return [4 /*yield*/, onClick()];
|
|
101
|
+
case 2:
|
|
102
|
+
_a.sent();
|
|
103
|
+
return [3 /*break*/, 4];
|
|
104
|
+
case 3:
|
|
105
|
+
setInternalIsLoading(false);
|
|
106
|
+
return [7 /*endfinally*/];
|
|
107
|
+
case 4: return [2 /*return*/];
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
}); };
|
|
111
|
+
return (React.createElement("button", __assign({ ref: buttonRef, className: "secondary-button ".concat(disabled ? "secondary-button-disabled" : "secondary-button-enabled", " secondary-button-").concat(mode, " ").concat(fullWidth ? "secondary-button-full-width" : "", " ").concat(isButtonLoading ? "secondary-button-loading" : ""), disabled: disabled, onClick: handleClick, type: type }, props),
|
|
112
|
+
startIcon && (React.createElement("span", { className: "secondary-button-icon ".concat(startIconName) })),
|
|
8
113
|
React.createElement("span", { className: "secondary-button-label" }, label),
|
|
9
|
-
endIcon && React.createElement("span", { className: "secondary-button-icon ".concat(
|
|
10
|
-
};
|
|
114
|
+
isButtonLoading ? (React.createElement("span", { className: "secondary-button-loading-dots" }, loadingDots)) : (endIcon && React.createElement("span", { className: "secondary-button-icon ".concat(endIconName) }))));
|
|
115
|
+
});
|
|
116
|
+
SecondaryButton.displayName = "SecondaryButton";
|
|
11
117
|
export default SecondaryButton;
|
|
@@ -25,7 +25,7 @@ export interface StepperProps {
|
|
|
25
25
|
}[];
|
|
26
26
|
showProgressBar?: boolean[];
|
|
27
27
|
onClose?: () => void;
|
|
28
|
-
validateStep?: (step: number) => boolean
|
|
28
|
+
validateStep?: (step: number) => boolean | Promise<boolean>;
|
|
29
29
|
}
|
|
30
30
|
declare const Stepper: React.FC<StepperProps>;
|
|
31
31
|
export default Stepper;
|
|
@@ -1,4 +1,40 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
2
38
|
import React, { useState, useEffect, useCallback, useRef } from "react";
|
|
3
39
|
import ReactDOM from "react-dom";
|
|
4
40
|
import "./Stepper.css";
|
|
@@ -28,28 +64,34 @@ var Stepper = function (_a) {
|
|
|
28
64
|
useEffect(function () {
|
|
29
65
|
setStep(currentStep || 1);
|
|
30
66
|
}, [currentStep]);
|
|
31
|
-
var handleNext = useCallback(function () {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
67
|
+
var handleNext = useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
68
|
+
var currentPrimaryButton, isValid;
|
|
69
|
+
return __generator(this, function (_a) {
|
|
70
|
+
switch (_a.label) {
|
|
71
|
+
case 0:
|
|
72
|
+
currentPrimaryButton = primaryButton[step - 1];
|
|
73
|
+
if (currentPrimaryButton === null || currentPrimaryButton === void 0 ? void 0 : currentPrimaryButton.onPrimaryButtonClick) {
|
|
74
|
+
currentPrimaryButton.onPrimaryButtonClick(step);
|
|
75
|
+
}
|
|
76
|
+
if (!validateStep) return [3 /*break*/, 2];
|
|
77
|
+
return [4 /*yield*/, validateStep(step)];
|
|
78
|
+
case 1:
|
|
79
|
+
isValid = _a.sent();
|
|
80
|
+
if (!isValid) {
|
|
81
|
+
return [2 /*return*/];
|
|
82
|
+
}
|
|
83
|
+
_a.label = 2;
|
|
84
|
+
case 2:
|
|
85
|
+
if (step < steps) {
|
|
86
|
+
setStep(step + 1);
|
|
87
|
+
}
|
|
88
|
+
else if (step === steps && onClose) {
|
|
89
|
+
onClose();
|
|
90
|
+
}
|
|
91
|
+
return [2 /*return*/];
|
|
44
92
|
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
setStep(step + 1);
|
|
48
|
-
}
|
|
49
|
-
else if (step === steps && onClose) {
|
|
50
|
-
onClose();
|
|
51
|
-
}
|
|
52
|
-
}, [step, steps, validateStep, primaryButton, onClose]);
|
|
93
|
+
});
|
|
94
|
+
}); }, [step, steps, validateStep, primaryButton, onClose]);
|
|
53
95
|
var handlePrevious = useCallback(function () {
|
|
54
96
|
if (step > 1) {
|
|
55
97
|
setStep(step - 1);
|