@digitaldefiance/express-suite-react-components 2.4.2 → 2.4.3
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/README.md +5 -0
- package/package.json +5 -3
- package/src/components/CurrencyInput.d.ts +1 -6
- package/src/components/CurrencyInput.d.ts.map +1 -1
- package/src/components/CurrencyInput.js +3 -11
- package/src/components/UserSettingsForm.d.ts +0 -5
- package/src/components/UserSettingsForm.d.ts.map +1 -1
- package/src/components/UserSettingsForm.js +9 -4
- package/src/wrappers/index.d.ts +0 -5
- package/src/wrappers/index.d.ts.map +1 -1
- package/src/wrappers/index.js +2 -2
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@digitaldefiance/express-suite-react-components",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.3",
|
|
4
4
|
"description": "React MUI components for Digital Defiance Express Suite",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "src/index.d.ts",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"react-router-dom": "6.29.0"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@digitaldefiance/i18n-lib": "3.6.
|
|
29
|
-
"@digitaldefiance/suite-core-lib": "^2.2.
|
|
28
|
+
"@digitaldefiance/i18n-lib": "3.6.1",
|
|
29
|
+
"@digitaldefiance/suite-core-lib": "^2.2.14",
|
|
30
30
|
"@emotion/react": "^11.14.0",
|
|
31
31
|
"@emotion/styled": "^11.14.0",
|
|
32
32
|
"@mui/icons-material": "^7.0.2",
|
|
@@ -34,7 +34,9 @@
|
|
|
34
34
|
"@mui/system": "^7.0.2",
|
|
35
35
|
"@mui/x-date-pickers": "^8.9.0",
|
|
36
36
|
"axios": "^1.9.0",
|
|
37
|
+
"currency-codes": "^2.2.0",
|
|
37
38
|
"formik": "^2.4.6",
|
|
39
|
+
"moment-timezone": "^0.6.0",
|
|
38
40
|
"react-number-format": "^5.4.4",
|
|
39
41
|
"yup": "^1.6.1"
|
|
40
42
|
},
|
|
@@ -2,17 +2,12 @@ export interface CurrencyInputProps {
|
|
|
2
2
|
value: number;
|
|
3
3
|
onChange: (value: number) => void;
|
|
4
4
|
currencyCode?: string;
|
|
5
|
+
locale?: string;
|
|
5
6
|
label: string;
|
|
6
7
|
error?: boolean;
|
|
7
8
|
helperText?: string;
|
|
8
9
|
name: string;
|
|
9
10
|
}
|
|
10
|
-
export declare function getCurrencyFormat(currencyCode?: string): {
|
|
11
|
-
symbol: string;
|
|
12
|
-
position: 'prefix' | 'postfix' | 'infix';
|
|
13
|
-
groupSeparator: string;
|
|
14
|
-
decimalSeparator: string;
|
|
15
|
-
};
|
|
16
11
|
export declare const CurrencyInput: React.FC<CurrencyInputProps>;
|
|
17
12
|
export default CurrencyInput;
|
|
18
13
|
//# sourceMappingURL=CurrencyInput.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CurrencyInput.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/CurrencyInput.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CurrencyInput.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/CurrencyInput.tsx"],"names":[],"mappings":"AAIA,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CA8DtD,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -1,20 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CurrencyInput = void 0;
|
|
4
|
-
exports.getCurrencyFormat = getCurrencyFormat;
|
|
5
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
5
|
const material_1 = require("@mui/material");
|
|
7
6
|
const react_number_format_1 = require("react-number-format");
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
position: 'prefix',
|
|
12
|
-
groupSeparator: ',',
|
|
13
|
-
decimalSeparator: '.',
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
const CurrencyInput = ({ value, onChange, currencyCode = 'USD', label, error, helperText, name, }) => {
|
|
17
|
-
const format = getCurrencyFormat(currencyCode);
|
|
7
|
+
const i18n_lib_1 = require("@digitaldefiance/i18n-lib");
|
|
8
|
+
const CurrencyInput = ({ value, onChange, currencyCode = 'USD', locale = 'en-US', label, error, helperText, name, }) => {
|
|
9
|
+
const format = (0, i18n_lib_1.getCurrencyFormat)(locale, currencyCode);
|
|
18
10
|
if (format.position === 'infix') {
|
|
19
11
|
const [whole, decimal] = value.toString().split('.');
|
|
20
12
|
const displayValue = `${whole}${format.symbol}${format.decimalSeparator}${decimal || '00'}`;
|
|
@@ -23,15 +23,10 @@ export interface UserSettingsFormProps {
|
|
|
23
23
|
msg: string;
|
|
24
24
|
}>;
|
|
25
25
|
}>;
|
|
26
|
-
timezones: string[];
|
|
27
26
|
languages: Array<{
|
|
28
27
|
code: string;
|
|
29
28
|
label: string;
|
|
30
29
|
}>;
|
|
31
|
-
currencies: Array<{
|
|
32
|
-
code: string;
|
|
33
|
-
label: string;
|
|
34
|
-
}>;
|
|
35
30
|
emailValidation?: Yup.StringSchema;
|
|
36
31
|
timezoneValidation?: Yup.StringSchema;
|
|
37
32
|
siteLanguageValidation?: Yup.StringSchema;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserSettingsForm.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/UserSettingsForm.tsx"],"names":[],"mappings":"AAeA,OAAO,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"UserSettingsForm.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/components/UserSettingsForm.tsx"],"names":[],"mappings":"AAeA,OAAO,EAAE,EAAE,EAAqB,MAAM,OAAO,CAAC;AAC9C,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAM3B,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,eAAe,EAAE,OAAO,CAAC;IACzB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,MAAM,WAAW,qBAAqB;IACpC,aAAa,EAAE,sBAAsB,CAAC;IACtC,QAAQ,EAAE,CAAC,MAAM,EAAE,sBAAsB,KAAK,OAAO,CACjD;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,GACrC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,GAAG,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KAAE,CACvG,CAAC;IACF,SAAS,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAClD,eAAe,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC;IACnC,kBAAkB,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC;IACtC,sBAAsB,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC;IAC1C,kBAAkB,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC;IACtC,kBAAkB,CAAC,EAAE,GAAG,CAAC,aAAa,CAAC;IACvC,yBAAyB,CAAC,EAAE,GAAG,CAAC,aAAa,CAAC;IAC9C,gBAAgB,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,KAAK,CAAC,SAAS,CAAC;IACpD,uBAAuB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC9C,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAClD,MAAM,CAAC,EAAE;QACP,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,qBAAqB,CAAC,EAAE,MAAM,CAAC;QAC/B,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB,CAAC;CACH;AAED,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC,qBAAqB,CAqQtD,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -7,24 +7,29 @@ const material_1 = require("@mui/material");
|
|
|
7
7
|
const formik_1 = require("formik");
|
|
8
8
|
const react_1 = require("react");
|
|
9
9
|
const Yup = tslib_1.__importStar(require("yup"));
|
|
10
|
+
const moment_timezone_1 = tslib_1.__importDefault(require("moment-timezone"));
|
|
11
|
+
const i18n_lib_1 = require("@digitaldefiance/i18n-lib");
|
|
10
12
|
const suite_core_lib_1 = require("@digitaldefiance/suite-core-lib");
|
|
11
13
|
const contexts_1 = require("../contexts");
|
|
12
|
-
const UserSettingsForm = ({ initialValues, onSubmit,
|
|
13
|
-
const {
|
|
14
|
+
const UserSettingsForm = ({ initialValues, onSubmit, languages, emailValidation, timezoneValidation, siteLanguageValidation, currencyValidation, darkModeValidation, directChallengeValidation, additionalFields, additionalInitialValues = {}, additionalValidation = {}, labels = {}, }) => {
|
|
15
|
+
const { tComponent } = (0, contexts_1.useI18n)();
|
|
14
16
|
const [apiErrors, setApiErrors] = (0, react_1.useState)({});
|
|
15
17
|
const [saving, setSaving] = (0, react_1.useState)(false);
|
|
16
18
|
const [successMessage, setSuccessMessage] = (0, react_1.useState)(null);
|
|
19
|
+
const timezones = (0, react_1.useMemo)(() => moment_timezone_1.default.tz.names(), []);
|
|
20
|
+
const currencies = (0, react_1.useMemo)(() => i18n_lib_1.CurrencyCode.getAllData().map(c => ({ code: c.code, label: `${c.code} - ${c.currency}` })), []);
|
|
17
21
|
const validation = {
|
|
18
22
|
email: emailValidation || Yup.string()
|
|
19
23
|
.email(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_InvalidEmail))
|
|
20
24
|
.required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required)),
|
|
21
25
|
timezone: timezoneValidation || Yup.string()
|
|
22
26
|
.required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_TimezoneRequired))
|
|
23
|
-
.
|
|
27
|
+
.test('valid-timezone', tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_TimezoneInvalid), (value) => !value || moment_timezone_1.default.tz.zone(value) !== null),
|
|
24
28
|
siteLanguage: siteLanguageValidation || Yup.string()
|
|
25
29
|
.required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required)),
|
|
26
30
|
currency: currencyValidation || Yup.string()
|
|
27
|
-
.required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required))
|
|
31
|
+
.required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required))
|
|
32
|
+
.test('valid-currency', tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required), (value) => !value || i18n_lib_1.CurrencyCode.isValid(value)),
|
|
28
33
|
darkMode: darkModeValidation || Yup.boolean()
|
|
29
34
|
.required(tComponent(suite_core_lib_1.SuiteCoreComponentId, suite_core_lib_1.SuiteCoreStringKey.Validation_Required)),
|
|
30
35
|
directChallenge: directChallengeValidation || Yup.boolean()
|
package/src/wrappers/index.d.ts
CHANGED
|
@@ -14,15 +14,10 @@ export interface VerifyEmailPageWrapperProps {
|
|
|
14
14
|
export declare const VerifyEmailPageWrapper: FC<VerifyEmailPageWrapperProps>;
|
|
15
15
|
export interface UserSettingsFormWrapperProps {
|
|
16
16
|
baseUrl: string;
|
|
17
|
-
timezones: string[];
|
|
18
17
|
languages: Array<{
|
|
19
18
|
code: string;
|
|
20
19
|
label: string;
|
|
21
20
|
}>;
|
|
22
|
-
currencies: Array<{
|
|
23
|
-
code: string;
|
|
24
|
-
label: string;
|
|
25
|
-
}>;
|
|
26
21
|
}
|
|
27
22
|
export declare const UserSettingsFormWrapper: FC<UserSettingsFormWrapperProps>;
|
|
28
23
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/wrappers/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAA+B,MAAM,OAAO,CAAC;AAexD,eAAO,MAAM,sBAAsB,EAAE,EAWpC,CAAC;AAEF,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,kBAAkB,EAAE,EAAE,CAAC,uBAAuB,CAoC1D,CAAC;AAEF,eAAO,MAAM,yBAAyB,EAAE,EAevC,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,EAkC9B,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,EAyBjC,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,EAK/B,CAAC;AAEF,MAAM,WAAW,2BAA2B;IAC1C,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,sBAAsB,EAAE,EAAE,CAAC,2BAA2B,CAelE,CAAC;AAEF,MAAM,WAAW,4BAA4B;IAC3C,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/digitaldefiance-express-suite-react-components/src/wrappers/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAA+B,MAAM,OAAO,CAAC;AAexD,eAAO,MAAM,sBAAsB,EAAE,EAWpC,CAAC;AAEF,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,kBAAkB,EAAE,EAAE,CAAC,uBAAuB,CAoC1D,CAAC;AAEF,eAAO,MAAM,yBAAyB,EAAE,EAevC,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,EAkC9B,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,EAyBjC,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,EAK/B,CAAC;AAEF,MAAM,WAAW,2BAA2B;IAC1C,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,sBAAsB,EAAE,EAAE,CAAC,2BAA2B,CAelE,CAAC;AAEF,MAAM,WAAW,4BAA4B;IAC3C,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACnD;AAED,eAAO,MAAM,uBAAuB,EAAE,EAAE,CAAC,4BAA4B,CAwCpE,CAAC"}
|
package/src/wrappers/index.js
CHANGED
|
@@ -130,7 +130,7 @@ const VerifyEmailPageWrapper = ({ baseUrl }) => {
|
|
|
130
130
|
return (0, jsx_runtime_1.jsx)(VerifyEmailPage_1.VerifyEmailPage, { token: token, onVerify: handleVerify });
|
|
131
131
|
};
|
|
132
132
|
exports.VerifyEmailPageWrapper = VerifyEmailPageWrapper;
|
|
133
|
-
const UserSettingsFormWrapper = ({ baseUrl,
|
|
133
|
+
const UserSettingsFormWrapper = ({ baseUrl, languages }) => {
|
|
134
134
|
const { userData, setCurrencyCode, setLanguage } = (0, contexts_1.useAuth)();
|
|
135
135
|
const api = (0, services_1.createAuthenticatedApiClient)(baseUrl);
|
|
136
136
|
const handleSubmit = async (values) => {
|
|
@@ -156,6 +156,6 @@ const UserSettingsFormWrapper = ({ baseUrl, timezones, languages, currencies })
|
|
|
156
156
|
darkMode: userData?.darkMode || false,
|
|
157
157
|
directChallenge: userData?.directChallenge || false,
|
|
158
158
|
};
|
|
159
|
-
return ((0, jsx_runtime_1.jsx)(UserSettingsForm_1.UserSettingsForm, { initialValues: initialValues, onSubmit: handleSubmit,
|
|
159
|
+
return ((0, jsx_runtime_1.jsx)(UserSettingsForm_1.UserSettingsForm, { initialValues: initialValues, onSubmit: handleSubmit, languages: languages }));
|
|
160
160
|
};
|
|
161
161
|
exports.UserSettingsFormWrapper = UserSettingsFormWrapper;
|