@symply.io/basic-components 1.3.11-alpha.5 → 1.3.11-alpha.6
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.
- package/AlertDialog/index.js +8 -30
- package/Autocomplete/index.js +10 -32
- package/Autocomplete/useInteractions.js +3 -3
- package/AutocompleteWithFilter/index.js +12 -35
- package/BasicModal/Content.js +5 -16
- package/BasicModal/index.js +9 -31
- package/BreadCrumbs/index.js +8 -19
- package/CheckBox/CheckBox.js +4 -26
- package/CheckBox/CheckBoxGroup.js +2 -24
- package/Copyright/index.js +3 -14
- package/DataTable/TableBody.js +2 -24
- package/DataTable/TableBodyRow.js +41 -52
- package/DataTable/TableFooter.js +30 -41
- package/DataTable/TableHeader.js +36 -47
- package/DataTable/index.js +17 -28
- package/DataTable/useTable.js +46 -54
- package/DateInput/FullDateInput/index.js +20 -42
- package/DateInput/FullDateInput/useInteractions.js +10 -10
- package/DateInput/MonthDayInput/index.js +14 -36
- package/DateInput/MonthDayInput/useInteractions.js +9 -9
- package/DateInput/MonthYearInput/index.js +14 -36
- package/DateInput/MonthYearInput/useInteractions.js +9 -9
- package/DigitInput/index.js +6 -28
- package/DigitInput/useInteractions.js +9 -9
- package/DynamicHeaderBar/HeaderBar.js +6 -17
- package/DynamicHeaderBar/HeaderButtons.js +13 -24
- package/DynamicHeaderBar/HeaderLine.js +2 -2
- package/DynamicHeaderBar/index.js +15 -26
- package/FeinInput/index.js +16 -38
- package/FeinInput/useInteractions.js +9 -9
- package/FileUploader/index.js +11 -33
- package/FileUploader/useInteractions.js +29 -44
- package/FormRadioGroup/index.js +4 -29
- package/FormSelector/MultipleSelector.js +9 -32
- package/FormSelector/SimpleSelector.js +9 -32
- package/FormSelector/useInteractions.js +7 -7
- package/HelpCaption/index.js +6 -17
- package/HelpCaption/useInteractions.js +2 -2
- package/LoadingModal/Modal.js +4 -15
- package/LoadingModal/useLoadingModal.js +15 -33
- package/MenuButtonGroup/MenuItem.js +3 -14
- package/MenuButtonGroup/index.js +14 -82
- package/NumberInput/index.js +5 -27
- package/NumberInput/useInteractions.js +17 -17
- package/PasswordInput/ConfirmPassword.js +6 -28
- package/PasswordInput/Password.js +15 -37
- package/PhoneNumberInput/index.js +17 -39
- package/PhoneNumberInput/useInteractions.js +10 -10
- package/Sidebar/SidebarItem.js +6 -17
- package/Sidebar/SidebarItemsGroup.js +10 -21
- package/Sidebar/SidebarLink.js +5 -27
- package/Sidebar/index.js +6 -17
- package/SocialInput/index.js +18 -40
- package/SocialInput/useInteractions.js +14 -14
- package/TabGroup/index.js +14 -25
- package/TablePagination/Actions.js +4 -15
- package/TablePagination/index.js +3 -14
- package/TablePagination/useInteractions.js +9 -9
- package/TextInput/index.js +8 -30
- package/TextInput/useInteractions.js +4 -4
- package/ToastPrompt/Prompt.d.ts +1 -1
- package/ToastPrompt/Prompt.js +20 -29
- package/ToastPrompt/index.d.ts +1 -1
- package/ToastPrompt/index.js +6 -17
- package/ToastPrompt/useInteractions.js +9 -20
- package/VideoPlayerModal/index.js +5 -27
- package/package.json +1 -1
- package/useCustomTheme.js +11 -16
- package/utils/uuid.js +10 -11
@@ -1,25 +1,3 @@
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
2
|
-
__assign = Object.assign || function(t) {
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
4
|
-
s = arguments[i];
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
6
|
-
t[p] = s[p];
|
7
|
-
}
|
8
|
-
return t;
|
9
|
-
};
|
10
|
-
return __assign.apply(this, arguments);
|
11
|
-
};
|
12
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
13
|
-
var t = {};
|
14
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
15
|
-
t[p] = s[p];
|
16
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
17
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
18
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
19
|
-
t[p[i]] = s[p[i]];
|
20
|
-
}
|
21
|
-
return t;
|
22
|
-
};
|
23
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
24
2
|
import { useRifm } from "rifm";
|
25
3
|
import TextField from "@mui/material/TextField";
|
@@ -27,28 +5,28 @@ import ThemeProvider from "@mui/material/styles/ThemeProvider";
|
|
27
5
|
import useInteractions from "./useInteractions";
|
28
6
|
import useCustomTheme from "../../useCustomTheme";
|
29
7
|
export function MonthDayYearFormat(str) {
|
30
|
-
|
31
|
-
|
32
|
-
return chars.reduce(
|
8
|
+
const digits = (str.match(/\d+/g) || []).join("");
|
9
|
+
const chars = digits.split("");
|
10
|
+
return chars.reduce((prev, curr, index) => {
|
33
11
|
if (index === 2) {
|
34
|
-
return
|
12
|
+
return `${prev} / ${curr}`;
|
35
13
|
}
|
36
14
|
else if (index === 4) {
|
37
|
-
return
|
15
|
+
return `${prev} / ${curr}`;
|
38
16
|
}
|
39
17
|
else {
|
40
|
-
return
|
18
|
+
return `${prev}${curr}`;
|
41
19
|
}
|
42
|
-
},
|
20
|
+
}, ``);
|
43
21
|
}
|
44
22
|
export function onValidateDate(dateString) {
|
45
|
-
|
23
|
+
const reg = /^((((0[1,3,5,7,8]{1})|(1[0,2]{1}))\s?\/\s?((0[1-9]{1})|([1-2]{1}\d{1})|(3[0-1]{1})))|(((0[4,6,9]{1})|(11))\s?\/\s?((0[1-9]{1})|([1-2]{1}\d{1})|(30)))|((02)\s?\/\s?(0[1-9]{1}|[1-2]{1}\d{1})))\s?\/\s?\d{4}$/g;
|
46
24
|
if (reg.test(dateString)) {
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
25
|
+
const tmpArr = dateString.split("/");
|
26
|
+
const month = parseInt(tmpArr[0].trim(), 10);
|
27
|
+
const day = parseInt(tmpArr[1].trim(), 10);
|
28
|
+
const year = parseInt(tmpArr[2].trim(), 10);
|
29
|
+
const verifyLeapYear = (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
|
52
30
|
if (month === 2 && !verifyLeapYear) {
|
53
31
|
return day < 29;
|
54
32
|
}
|
@@ -57,23 +35,23 @@ export function onValidateDate(dateString) {
|
|
57
35
|
return false;
|
58
36
|
}
|
59
37
|
function FullDateInput(props) {
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
38
|
+
const { onChange, value, margin = "normal", error, helperText = "Please enter a valid date", onValidate, primaryColor, secondaryColor, ...rest } = props;
|
39
|
+
const theme = useCustomTheme({ primaryColor, secondaryColor });
|
40
|
+
const { valLength, addMask } = useInteractions({ value });
|
41
|
+
const rifm = useRifm({
|
64
42
|
mask: true,
|
65
43
|
value: String(value),
|
66
|
-
onChange
|
44
|
+
onChange,
|
67
45
|
replace: addMask,
|
68
46
|
format: MonthDayYearFormat
|
69
47
|
});
|
70
|
-
return (_jsx(ThemeProvider,
|
48
|
+
return (_jsx(ThemeProvider, { theme: theme, children: _jsx(TextField, { placeholder: "MM / DD / YYYY", error: error ||
|
71
49
|
(valLength > 0 &&
|
72
50
|
(onValidate ? !onValidate(value) : !onValidateDate(value))), margin: margin, value: rifm.value, onChange: rifm.onChange, helperText: valLength > 0 &&
|
73
51
|
(onValidate ? !onValidate(value) : !onValidateDate(value))
|
74
52
|
? helperText
|
75
53
|
: "", InputLabelProps: {
|
76
54
|
shrink: true
|
77
|
-
}
|
55
|
+
}, ...rest }) }));
|
78
56
|
}
|
79
57
|
export default FullDateInput;
|
@@ -1,20 +1,20 @@
|
|
1
1
|
import { useCallback, useMemo } from "react";
|
2
2
|
function useInteractions(props) {
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
3
|
+
const { value } = props;
|
4
|
+
const addMask = useCallback((str) => {
|
5
|
+
const digits = (str.match(/\d+/g) || []).join("");
|
6
|
+
const month = digits.slice(0, 2).padEnd(2, "_");
|
7
|
+
const day = digits.slice(2, 4).padEnd(2, "_");
|
8
|
+
const Year = digits.slice(4, 8).padEnd(4, "_");
|
9
9
|
if (digits) {
|
10
|
-
return
|
10
|
+
return `${month} / ${day} / ${Year}`;
|
11
11
|
}
|
12
12
|
return "";
|
13
13
|
}, []);
|
14
|
-
|
15
|
-
|
14
|
+
const valLength = useMemo(() => {
|
15
|
+
const digitsArr = String(value).match(/\d/g);
|
16
16
|
return digitsArr ? digitsArr.length : 0;
|
17
17
|
}, [value]);
|
18
|
-
return { valLength
|
18
|
+
return { valLength, addMask };
|
19
19
|
}
|
20
20
|
export default useInteractions;
|
@@ -1,25 +1,3 @@
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
2
|
-
__assign = Object.assign || function(t) {
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
4
|
-
s = arguments[i];
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
6
|
-
t[p] = s[p];
|
7
|
-
}
|
8
|
-
return t;
|
9
|
-
};
|
10
|
-
return __assign.apply(this, arguments);
|
11
|
-
};
|
12
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
13
|
-
var t = {};
|
14
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
15
|
-
t[p] = s[p];
|
16
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
17
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
18
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
19
|
-
t[p[i]] = s[p[i]];
|
20
|
-
}
|
21
|
-
return t;
|
22
|
-
};
|
23
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
24
2
|
import { useRifm } from "rifm";
|
25
3
|
import TextField from "@mui/material/TextField";
|
@@ -27,39 +5,39 @@ import ThemeProvider from "@mui/material/styles/ThemeProvider";
|
|
27
5
|
import useInteractions from "./useInteractions";
|
28
6
|
import useCustomTheme from "../../useCustomTheme";
|
29
7
|
export function MonthDayFormat(str) {
|
30
|
-
|
31
|
-
|
32
|
-
return chars.reduce(
|
8
|
+
const digits = (str.match(/\d+/g) || []).join("");
|
9
|
+
const chars = digits.split("");
|
10
|
+
return chars.reduce((prev, curr, index) => {
|
33
11
|
if (index === 2) {
|
34
|
-
return
|
12
|
+
return `${prev} / ${curr}`;
|
35
13
|
}
|
36
14
|
else {
|
37
|
-
return
|
15
|
+
return `${prev}${curr}`;
|
38
16
|
}
|
39
|
-
},
|
17
|
+
}, ``);
|
40
18
|
}
|
41
19
|
export function onValidateMonthDay(monthDayString) {
|
42
|
-
|
20
|
+
const reg = /^((((0[1,3,5,7,8]{1})|(1[0,2]{1}))\s?\/\s?((0[1-9]{1})|([1-2]{1}\d{1})|(3[0-1]{1})))|(((0[4,6,9]{1})|(11))\s?\/\s?((0[1-9]{1})|([1-2]{1}\d{1})|(30)))|((02)\s?\/\s?(0[1-9]{1})|([1-2]{1}\d{1})))$/g;
|
43
21
|
return reg.test(monthDayString);
|
44
22
|
}
|
45
23
|
function MonthDayInput(props) {
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
24
|
+
const { onChange, value, margin = "normal", error, helperText = "Please enter a valid date", onValidate, primaryColor, secondaryColor, ...rest } = props;
|
25
|
+
const theme = useCustomTheme({ primaryColor, secondaryColor });
|
26
|
+
const { valLength, addMask } = useInteractions({ value });
|
27
|
+
const rifm = useRifm({
|
50
28
|
mask: true,
|
51
29
|
value: String(value),
|
52
|
-
onChange
|
30
|
+
onChange,
|
53
31
|
replace: addMask,
|
54
32
|
format: MonthDayFormat
|
55
33
|
});
|
56
|
-
return (_jsx(ThemeProvider,
|
34
|
+
return (_jsx(ThemeProvider, { theme: theme, children: _jsx(TextField, { placeholder: "MM / DD", error: error ||
|
57
35
|
(valLength > 0 &&
|
58
36
|
(onValidate ? !onValidate(value) : !onValidateMonthDay(value))), margin: margin, value: rifm.value, onChange: rifm.onChange, helperText: valLength > 0 &&
|
59
37
|
(onValidate ? !onValidate(value) : !onValidateMonthDay(value))
|
60
38
|
? helperText
|
61
39
|
: "", InputLabelProps: {
|
62
40
|
shrink: true
|
63
|
-
}
|
41
|
+
}, ...rest }) }));
|
64
42
|
}
|
65
43
|
export default MonthDayInput;
|
@@ -1,19 +1,19 @@
|
|
1
1
|
import { useCallback, useMemo } from "react";
|
2
2
|
function useInteractions(props) {
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
const { value } = props;
|
4
|
+
const addMask = useCallback((str) => {
|
5
|
+
const digits = (str.match(/\d+/g) || []).join("");
|
6
|
+
const month = digits.slice(0, 2).padEnd(2, "_");
|
7
|
+
const day = digits.slice(2, 4).padEnd(2, "_");
|
8
8
|
if (digits) {
|
9
|
-
return
|
9
|
+
return `${month} / ${day}`;
|
10
10
|
}
|
11
11
|
return "";
|
12
12
|
}, []);
|
13
|
-
|
14
|
-
|
13
|
+
const valLength = useMemo(() => {
|
14
|
+
const digitsArr = String(value).match(/\d/g);
|
15
15
|
return digitsArr ? digitsArr.length : 0;
|
16
16
|
}, [value]);
|
17
|
-
return { valLength
|
17
|
+
return { valLength, addMask };
|
18
18
|
}
|
19
19
|
export default useInteractions;
|
@@ -1,25 +1,3 @@
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
2
|
-
__assign = Object.assign || function(t) {
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
4
|
-
s = arguments[i];
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
6
|
-
t[p] = s[p];
|
7
|
-
}
|
8
|
-
return t;
|
9
|
-
};
|
10
|
-
return __assign.apply(this, arguments);
|
11
|
-
};
|
12
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
13
|
-
var t = {};
|
14
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
15
|
-
t[p] = s[p];
|
16
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
17
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
18
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
19
|
-
t[p[i]] = s[p[i]];
|
20
|
-
}
|
21
|
-
return t;
|
22
|
-
};
|
23
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
24
2
|
import { useRifm } from "rifm";
|
25
3
|
import TextField from "@mui/material/TextField";
|
@@ -27,40 +5,40 @@ import ThemeProvider from "@mui/material/styles/ThemeProvider";
|
|
27
5
|
import useInteractions from "./useInteractions";
|
28
6
|
import useCustomTheme from "../../useCustomTheme";
|
29
7
|
export function MonthYearFormat(str) {
|
30
|
-
|
31
|
-
|
32
|
-
return chars.reduce(
|
8
|
+
const digits = (str.match(/\d+/g) || []).join("");
|
9
|
+
const chars = digits.split("");
|
10
|
+
return chars.reduce((prev, curr, index) => {
|
33
11
|
if (index === 2) {
|
34
|
-
return
|
12
|
+
return `${prev} / ${curr}`;
|
35
13
|
}
|
36
14
|
else {
|
37
|
-
return
|
15
|
+
return `${prev}${curr}`;
|
38
16
|
}
|
39
|
-
},
|
17
|
+
}, ``);
|
40
18
|
}
|
41
19
|
export function onValidateMonthYear(monthYearString) {
|
42
|
-
|
20
|
+
const reg = /^(((0[1-9]{1})|(1[0-2]{1}))\s?\/\s?([1-2]{1}\d{3}))$/g;
|
43
21
|
reg.lastIndex = 0;
|
44
22
|
return reg.test(monthYearString);
|
45
23
|
}
|
46
24
|
function MonthYearInput(props) {
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
25
|
+
const { onChange, value, margin = "normal", error, helperText = "Please enter a valid date", onValidate, primaryColor, secondaryColor, ...rest } = props;
|
26
|
+
const theme = useCustomTheme({ primaryColor, secondaryColor });
|
27
|
+
const { valLength, addMask } = useInteractions({ value });
|
28
|
+
const rifm = useRifm({
|
51
29
|
mask: true,
|
52
30
|
value: String(value),
|
53
|
-
onChange
|
31
|
+
onChange,
|
54
32
|
replace: addMask,
|
55
33
|
format: MonthYearFormat
|
56
34
|
});
|
57
|
-
return (_jsx(ThemeProvider,
|
35
|
+
return (_jsx(ThemeProvider, { theme: theme, children: _jsx(TextField, { placeholder: "MM / YYYY", error: error ||
|
58
36
|
(valLength > 0 &&
|
59
37
|
(onValidate ? !onValidate(value) : !onValidateMonthYear(value))), margin: margin, value: rifm.value, onChange: rifm.onChange, helperText: valLength > 0 &&
|
60
38
|
(onValidate ? !onValidate(value) : !onValidateMonthYear(value))
|
61
39
|
? helperText
|
62
40
|
: "", InputLabelProps: {
|
63
41
|
shrink: true
|
64
|
-
}
|
42
|
+
}, ...rest }) }));
|
65
43
|
}
|
66
44
|
export default MonthYearInput;
|
@@ -1,19 +1,19 @@
|
|
1
1
|
import { useCallback, useMemo } from "react";
|
2
2
|
function useInteractions(props) {
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
const { value } = props;
|
4
|
+
const addMask = useCallback((str) => {
|
5
|
+
const digits = (str.match(/\d+/g) || []).join("");
|
6
|
+
const month = digits.slice(0, 2).padEnd(2, "_");
|
7
|
+
const Year = digits.slice(2, 6).padEnd(4, "_");
|
8
8
|
if (digits) {
|
9
|
-
return
|
9
|
+
return `${month} / ${Year}`;
|
10
10
|
}
|
11
11
|
return "";
|
12
12
|
}, []);
|
13
|
-
|
14
|
-
|
13
|
+
const valLength = useMemo(() => {
|
14
|
+
const digitsArr = String(value).match(/\d/g);
|
15
15
|
return digitsArr ? digitsArr.length : 0;
|
16
16
|
}, [value]);
|
17
|
-
return { valLength
|
17
|
+
return { valLength, addMask };
|
18
18
|
}
|
19
19
|
export default useInteractions;
|
package/DigitInput/index.js
CHANGED
@@ -1,25 +1,3 @@
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
2
|
-
__assign = Object.assign || function(t) {
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
4
|
-
s = arguments[i];
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
6
|
-
t[p] = s[p];
|
7
|
-
}
|
8
|
-
return t;
|
9
|
-
};
|
10
|
-
return __assign.apply(this, arguments);
|
11
|
-
};
|
12
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
13
|
-
var t = {};
|
14
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
15
|
-
t[p] = s[p];
|
16
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
17
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
18
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
19
|
-
t[p[i]] = s[p[i]];
|
20
|
-
}
|
21
|
-
return t;
|
22
|
-
};
|
23
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
24
2
|
import Tooltip from "@mui/material/Tooltip";
|
25
3
|
import Field from "@mui/material/TextField";
|
@@ -27,12 +5,12 @@ import ThemeProvider from "@mui/material/styles/ThemeProvider";
|
|
27
5
|
import useInteractions from "./useInteractions";
|
28
6
|
import useCustomTheme from "../useCustomTheme";
|
29
7
|
function DigitInput(props) {
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
return (_jsx(ThemeProvider,
|
34
|
-
endAdornment
|
35
|
-
}, onChange: handleChange
|
8
|
+
const { onChange, value, size = "small", tooltip, maxLength = 999, minLength = 0, endAdornment, primaryColor, secondaryColor, ...rest } = props;
|
9
|
+
const { tooltipOpen, handleChange, onOpenTooltip, onCloseTooltip } = useInteractions({ onChange });
|
10
|
+
const theme = useCustomTheme({ primaryColor, secondaryColor });
|
11
|
+
return (_jsx(ThemeProvider, { theme: theme, children: _jsx(Tooltip, { arrow: true, placement: "top", title: tooltip ?? "", open: !!tooltip && tooltipOpen, children: _jsx(Field, { size: size, margin: "dense", type: "text", value: value === undefined || value === null ? "" : value, onMouseEnter: onOpenTooltip, onMouseLeave: onCloseTooltip, inputProps: { maxLength, minLength }, InputProps: {
|
12
|
+
endAdornment
|
13
|
+
}, onChange: handleChange, ...rest }) }) }));
|
36
14
|
}
|
37
15
|
export default DigitInput;
|
38
16
|
export * from "./types";
|
@@ -1,24 +1,24 @@
|
|
1
1
|
import { useState, useCallback } from "react";
|
2
2
|
function useInteractions(props) {
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
const { onChange } = props;
|
4
|
+
const [tooltipOpen, setTooltipOpen] = useState(false);
|
5
|
+
const handleChange = useCallback((event) => {
|
6
6
|
event.preventDefault();
|
7
7
|
if (!event.target.value || /^\d+$/g.test(event.target.value)) {
|
8
8
|
onChange(event.target.value);
|
9
9
|
}
|
10
10
|
}, [onChange]);
|
11
|
-
|
11
|
+
const onOpenTooltip = useCallback(() => {
|
12
12
|
setTooltipOpen(true);
|
13
13
|
}, []);
|
14
|
-
|
14
|
+
const onCloseTooltip = useCallback(() => {
|
15
15
|
setTooltipOpen(false);
|
16
16
|
}, []);
|
17
17
|
return {
|
18
|
-
tooltipOpen
|
19
|
-
handleChange
|
20
|
-
onOpenTooltip
|
21
|
-
onCloseTooltip
|
18
|
+
tooltipOpen,
|
19
|
+
handleChange,
|
20
|
+
onOpenTooltip,
|
21
|
+
onCloseTooltip
|
22
22
|
};
|
23
23
|
}
|
24
24
|
export default useInteractions;
|
@@ -1,14 +1,3 @@
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
2
|
-
__assign = Object.assign || function(t) {
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
4
|
-
s = arguments[i];
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
6
|
-
t[p] = s[p];
|
7
|
-
}
|
8
|
-
return t;
|
9
|
-
};
|
10
|
-
return __assign.apply(this, arguments);
|
11
|
-
};
|
12
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
13
2
|
import { cloneElement, useMemo } from "react";
|
14
3
|
import ThemeProvider from "@mui/material/styles/ThemeProvider";
|
@@ -21,12 +10,12 @@ import HeaderLine from "./HeaderLine";
|
|
21
10
|
import HeaderButtons from "./HeaderButtons";
|
22
11
|
import useCustomTheme from "../useCustomTheme";
|
23
12
|
function HeaderBar(props) {
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
return (_jsx(ThemeProvider,
|
13
|
+
const { title, color, subtitle, bottomEl, buttons = [], showBackButton, primaryColor, secondaryColor, onBack } = props;
|
14
|
+
const theme = useCustomTheme({ primaryColor, secondaryColor });
|
15
|
+
const isLessThanSm = useMediaQuery(theme.breakpoints.down("sm"));
|
16
|
+
const hasButtons = useMemo(() => buttons.length > 0, [buttons.length]);
|
17
|
+
return (_jsx(ThemeProvider, { theme: theme, children: _jsxs(Grid, { sx: { mb: 1 }, children: [_jsxs(Grid, { container: true, direction: "row", justifyContent: "flex-start", alignItems: "center", children: [_jsx(Grid, { item: true, xs: 12, sm: hasButtons ? 6 : 12, md: hasButtons ? 5 : 12, lg: hasButtons ? 4 : 12, xl: hasButtons ? 3 : 12, children: _jsxs(Grid, { container: true, direction: "row", justifyContent: "flex-start", alignItems: "center", children: [showBackButton && (_jsx(IconButton, { onClick: () => {
|
29
18
|
onBack ? onBack() : window.history.back();
|
30
|
-
}
|
19
|
+
}, children: _jsx(ArrowBackIcon, { fontSize: "small" }) })), typeof title === "string" ? (_jsx(Typography, { align: "left", sx: { fontWeight: 600, fontSize: isLessThanSm ? 21 : 24 }, children: title })) : (cloneElement(title))] }) }), hasButtons ? (_jsx(Grid, { item: true, xs: 12, sm: 6, md: 7, lg: 8, xl: 9, children: _jsx(HeaderButtons, { buttons: buttons, primaryColor: primaryColor, secondaryColor: secondaryColor }) })) : (_jsx(_Fragment, {}))] }), _jsx(Grid, { container: true, direction: "row", children: _jsx(Grid, { item: true, xs: 12, sx: { mt: 1 }, children: _jsx(HeaderLine, { color: color, primaryColor: primaryColor, secondaryColor: secondaryColor }) }) }), subtitle && (_jsx(Grid, { container: true, direction: "row", children: _jsx(Grid, { item: true, xs: 12, sx: { mt: 1 }, children: typeof subtitle === "string" ? (_jsx(Typography, { children: subtitle })) : (cloneElement(subtitle)) }) })), bottomEl && (_jsx(Grid, { container: true, direction: "row", children: _jsx(Grid, { item: true, xs: 12, sx: { mt: 1 }, children: cloneElement(bottomEl) }) }))] }) }));
|
31
20
|
}
|
32
21
|
export default HeaderBar;
|
@@ -1,14 +1,3 @@
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
2
|
-
__assign = Object.assign || function(t) {
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
4
|
-
s = arguments[i];
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
6
|
-
t[p] = s[p];
|
7
|
-
}
|
8
|
-
return t;
|
9
|
-
};
|
10
|
-
return __assign.apply(this, arguments);
|
11
|
-
};
|
12
1
|
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
13
2
|
import Fab from "@mui/material/Fab";
|
14
3
|
import Grid from "@mui/material/Grid";
|
@@ -20,30 +9,30 @@ import MenuButtonGroup from "../MenuButtonGroup";
|
|
20
9
|
import { HeaderButtonCategory } from "./types";
|
21
10
|
import useCustomTheme from "../useCustomTheme";
|
22
11
|
function HeaderButtons(props) {
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
return (_jsx(ThemeProvider,
|
12
|
+
const { buttons, primaryColor, secondaryColor } = props;
|
13
|
+
const theme = useCustomTheme({ primaryColor, secondaryColor });
|
14
|
+
const isLessThanSm = useMediaQuery(theme.breakpoints.down("sm"));
|
15
|
+
return (_jsx(ThemeProvider, { theme: theme, children: _jsx(Grid, { container: true, spacing: 1, direction: "row", justifyContent: "flex-end", alignItems: "center", children: buttons.map((button) => {
|
27
16
|
switch (button.type) {
|
28
17
|
case HeaderButtonCategory.TextButton: {
|
29
|
-
|
30
|
-
return (_jsx(Grid,
|
18
|
+
const { variant = "contained", text, onClick, color, size, startIcon, endIcon, disabled } = button;
|
19
|
+
return (_jsx(Grid, { item: true, xs: isLessThanSm ? 12 : undefined, style: { textAlign: "end" }, children: _jsx(Button, { fullWidth: isLessThanSm, variant: variant, onClick: onClick, color: color, size: isLessThanSm ? "small" : size, startIcon: startIcon, endIcon: endIcon, disabled: disabled, children: text }) }, text));
|
31
20
|
}
|
32
21
|
case HeaderButtonCategory.FabButton: {
|
33
|
-
|
34
|
-
return (_jsx(Grid,
|
22
|
+
const { title, onClick, color, size = "medium", icon, disabled, variant } = button;
|
23
|
+
return (_jsx(Grid, { item: true, style: { textAlign: "end" }, children: _jsx(Fab, { onClick: onClick, color: color, title: title, size: isLessThanSm ? "small" : size, disabled: disabled, variant: variant, children: icon }) }, title));
|
35
24
|
}
|
36
25
|
case HeaderButtonCategory.IconButton: {
|
37
|
-
|
38
|
-
return (_jsx(Grid,
|
26
|
+
const { title, onClick, color, size = "medium", icon, disabled } = button;
|
27
|
+
return (_jsx(Grid, { item: true, style: { textAlign: "end" }, children: _jsx(IconButton, { onClick: onClick, color: color, title: title, size: isLessThanSm ? "small" : size, disabled: disabled, children: icon }) }, title));
|
39
28
|
}
|
40
29
|
case HeaderButtonCategory.MenuButton: {
|
41
|
-
|
42
|
-
return (_jsx(Grid,
|
30
|
+
const { buttons: btns, buttonText, disabled, variant, size, color } = button;
|
31
|
+
return (_jsx(Grid, { item: true, xs: isLessThanSm ? 12 : undefined, style: { textAlign: "end" }, children: _jsx(MenuButtonGroup, { size: isLessThanSm ? "small" : size, variant: variant, buttons: btns, color: color, buttonText: buttonText, disabled: disabled, primaryColor: primaryColor, secondaryColor: secondaryColor }) }, buttonText));
|
43
32
|
}
|
44
33
|
default:
|
45
34
|
return _jsx(_Fragment, {});
|
46
35
|
}
|
47
|
-
}) })
|
36
|
+
}) }) }));
|
48
37
|
}
|
49
38
|
export default HeaderButtons;
|
@@ -2,8 +2,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import Divider from "@mui/material/Divider";
|
3
3
|
import useCustomTheme from "../useCustomTheme";
|
4
4
|
function HeaderLine(props) {
|
5
|
-
|
6
|
-
|
5
|
+
const { color, primaryColor, secondaryColor } = props;
|
6
|
+
const theme = useCustomTheme({ primaryColor, secondaryColor });
|
7
7
|
return (_jsx(Divider, { sx: {
|
8
8
|
height: "3px",
|
9
9
|
backgroundColor: color || theme.palette.primary.main
|
@@ -1,49 +1,38 @@
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
2
|
-
__assign = Object.assign || function(t) {
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
4
|
-
s = arguments[i];
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
6
|
-
t[p] = s[p];
|
7
|
-
}
|
8
|
-
return t;
|
9
|
-
};
|
10
|
-
return __assign.apply(this, arguments);
|
11
|
-
};
|
12
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
13
2
|
import { cloneElement, createContext, useContext, useState, useCallback } from "react";
|
14
3
|
import Grid from "@mui/material/Grid";
|
15
4
|
import HeaderBar from "./HeaderBar";
|
16
|
-
|
17
|
-
onInit:
|
18
|
-
onShow:
|
19
|
-
onHide:
|
5
|
+
const HeaderContext = createContext({
|
6
|
+
onInit: () => { },
|
7
|
+
onShow: () => { },
|
8
|
+
onHide: () => { }
|
20
9
|
});
|
21
10
|
export function HeaderProvider(props) {
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
11
|
+
const { children, primaryColor, secondaryColor, sx = {} } = props;
|
12
|
+
const [visible, setVisible] = useState(false);
|
13
|
+
const [headerProps, setHeaderProps] = useState({ title: "" });
|
14
|
+
const [height, setHeight] = useState(0);
|
15
|
+
const onInit = useCallback((args) => {
|
27
16
|
setHeaderProps(args);
|
28
17
|
}, []);
|
29
|
-
|
18
|
+
const onShow = useCallback(() => {
|
30
19
|
setVisible(true);
|
31
20
|
}, []);
|
32
|
-
|
21
|
+
const onHide = useCallback(() => {
|
33
22
|
setVisible(false);
|
34
23
|
}, []);
|
35
|
-
|
24
|
+
const measureRef = useCallback(node => {
|
36
25
|
if (node && headerProps) {
|
37
26
|
setHeight(node.getBoundingClientRect().height);
|
38
27
|
}
|
39
28
|
}, [headerProps]);
|
40
|
-
return (_jsx(HeaderContext.Provider,
|
29
|
+
return (_jsx(HeaderContext.Provider, { value: { onInit, onHide, onShow }, children: _jsxs(_Fragment, { children: [visible ? (_jsx(Grid, { container: true, direction: "row", sx: { ...sx }, ref: measureRef, children: _jsx(Grid, { item: true, xs: 12, children: _jsx(HeaderBar, { ...headerProps, primaryColor: primaryColor, secondaryColor: secondaryColor }) }) })) : (_jsx(_Fragment, {})), cloneElement(children, {
|
41
30
|
sx: {
|
42
31
|
p: 3,
|
43
32
|
py: 1,
|
44
|
-
pt: visible && height ?
|
33
|
+
pt: visible && height ? `calc(${height}px)` : undefined
|
45
34
|
}
|
46
|
-
})] }) }))
|
35
|
+
})] }) }));
|
47
36
|
}
|
48
37
|
export function useHeaderBar() {
|
49
38
|
return useContext(HeaderContext);
|