@am92/react-design-system 2.7.7 → 2.8.0
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/dist/Components/DsAppBar/DsAppBar.Component.d.ts +2 -5
- package/dist/Components/DsAppBar/DsAppBar.Component.js +19 -24
- package/dist/Components/DsBottomSheet/DsBottomSheet.Component.d.ts +2 -7
- package/dist/Components/DsBottomSheet/DsBottomSheet.Component.js +62 -65
- package/dist/Components/DsButton/DsButton.Component.d.ts +2 -4
- package/dist/Components/DsButton/DsButton.Component.js +4 -7
- package/dist/Components/DsButton/DsButton.Overrides.js +2 -2
- package/dist/Components/DsButtonGroup/DsButtonGroup.Component.d.ts +2 -6
- package/dist/Components/DsButtonGroup/DsButtonGroup.Component.js +16 -18
- package/dist/Components/DsCarousel/DsCarousel.Component/DsCarouselNavigation.d.ts +2 -3
- package/dist/Components/DsCarousel/DsCarousel.Component/DsCarouselNavigation.js +42 -44
- package/dist/Components/DsCarousel/DsCarousel.Component/DsCarouselPagination.d.ts +2 -6
- package/dist/Components/DsCarousel/DsCarousel.Component/DsCarouselPagination.js +109 -110
- package/dist/Components/DsCarousel/DsCarousel.Component/index.d.ts +3 -19
- package/dist/Components/DsCarousel/DsCarousel.Component/index.js +55 -57
- package/dist/Components/DsChip/DsChip.Component.d.ts +1 -6
- package/dist/Components/DsChip/DsChip.Component.js +1 -10
- package/dist/Components/DsChip/DsChip.Types.d.ts +1 -0
- package/dist/Components/DsChip/DsChip.Types.js +2 -1
- package/dist/Components/DsChipGroup/DsChipGroup.Component.d.ts +2 -5
- package/dist/Components/DsChipGroup/DsChipGroup.Component.js +5 -8
- package/dist/Components/DsContentSlider/DsContentSlider.Component.d.ts +3 -8
- package/dist/Components/DsContentSlider/DsContentSlider.Component.js +13 -20
- package/dist/Components/DsDialog/DsDialog.Component.d.ts +1 -6
- package/dist/Components/DsDialog/DsDialog.Component.js +71 -75
- package/dist/Components/DsDialog/DsDialog.Overrides.d.ts +1 -0
- package/dist/Components/DsDialog/DsDialog.Overrides.js +2 -0
- package/dist/Components/DsDivider/DsDivider.Overrides.js +6 -0
- package/dist/Components/DsFileUploader/DsFileUploader.Component.d.ts +3 -16
- package/dist/Components/DsFileUploader/DsFileUploader.Component.js +68 -71
- package/dist/Components/DsHeader/DsHeader.Component.d.ts +2 -5
- package/dist/Components/DsHeader/DsHeader.Component.js +29 -32
- package/dist/Components/DsHelperText/DsHelperText.Component.d.ts +2 -5
- package/dist/Components/DsHelperText/DsHelperText.Component.js +16 -21
- package/dist/Components/DsHelperText/DsHelperText.Overrides.d.ts +5 -1
- package/dist/Components/DsHelperText/DsHelperText.Overrides.js +6 -1
- package/dist/Components/DsImage/DsImage.Component.d.ts +3 -12
- package/dist/Components/DsImage/DsImage.Component.js +40 -45
- package/dist/Components/DsImage/DsImage.Types.d.ts +0 -1
- package/dist/Components/DsImage/DsImage.Types.js +0 -3
- package/dist/Components/DsInputLabel/DsInputLabel.Component.d.ts +2 -4
- package/dist/Components/DsInputLabel/DsInputLabel.Component.js +6 -9
- package/dist/Components/DsNotistack/AlertMessage.Component.js +7 -9
- package/dist/Components/DsNotistack/DsNotistack.Component.d.ts +2 -7
- package/dist/Components/DsNotistack/DsNotistack.Component.js +12 -16
- package/dist/Components/DsNotistack/DsNotistack.Types.d.ts +1 -0
- package/dist/Components/DsNotistack/DsNotistack.Types.js +3 -1
- package/dist/Components/DsOtp/DsOtp.Component.d.ts +3 -15
- package/dist/Components/DsOtp/DsOtp.Component.js +41 -51
- package/dist/Components/DsPopup/DsPopup.Types.d.ts +1 -1
- package/dist/Components/DsProgressIndicator/DsProgressIndicator.Component.d.ts +2 -6
- package/dist/Components/DsProgressIndicator/DsProgressIndicator.Component.js +18 -21
- package/dist/Components/DsProgressTracker/DsProgressStepper.Component.d.ts +3 -9
- package/dist/Components/DsProgressTracker/DsProgressStepper.Component.js +8 -11
- package/dist/Components/DsProgressTracker/DsProgressTracker.Component.d.ts +3 -21
- package/dist/Components/DsProgressTracker/DsProgressTracker.Component.js +17 -26
- package/dist/Components/DsRadio/DsRadio.Component.d.ts +2 -5
- package/dist/Components/DsRadio/DsRadio.Component.js +5 -8
- package/dist/Components/DsRadio/DsRadio.Overrides.d.ts +9 -1
- package/dist/Components/DsRadio/DsRadio.Overrides.js +9 -1
- package/dist/Components/DsRadioGroup/DsRadioGroup.Component.d.ts +3 -1
- package/dist/Components/DsRadioGroup/DsRadioGroup.Component.js +10 -1
- package/dist/Components/DsRemixIcon/DsRemixIcon.Component.d.ts +2 -4
- package/dist/Components/DsRemixIcon/DsRemixIcon.Component.js +5 -7
- package/dist/Components/DsSelect/DsSelect.Component.d.ts +2 -6
- package/dist/Components/DsSelect/DsSelect.Component.js +49 -53
- package/dist/Components/DsSelect/DsSelect.Overrides.d.ts +3 -0
- package/dist/Components/DsSelect/DsSelect.Overrides.js +4 -1
- package/dist/Components/DsSelect/DsSelect.Types.d.ts +8 -0
- package/dist/Components/DsSelect/DsSelect.Types.js +1 -1
- package/dist/Components/DsSlider/DsSlider.Component.d.ts +1 -5
- package/dist/Components/DsSlider/DsSlider.Component.js +1 -10
- package/dist/Components/DsSlider/DsSlider.Overrides.d.ts +1 -1
- package/dist/Components/DsSlider/DsSlider.Overrides.js +2 -2
- package/dist/Components/DsStepConnector/DsStepConnector.Overrides.d.ts +2 -1
- package/dist/Components/DsStepConnector/DsStepConnector.Overrides.js +9 -2
- package/dist/Components/DsStepLabel/DsStepLabel.Overrides.js +4 -4
- package/dist/Components/DsSwitch/DsSwitch.Component.d.ts +2 -6
- package/dist/Components/DsSwitch/DsSwitch.Component.js +7 -10
- package/dist/Components/DsTag/DsTag.Component.d.ts +2 -7
- package/dist/Components/DsTag/DsTag.Component.js +10 -13
- package/dist/Components/DsTagGroup/DsTagGroup.Component.d.ts +2 -7
- package/dist/Components/DsTagGroup/DsTagGroup.Component.js +25 -27
- package/dist/Components/DsTextArea/DsTextArea.Component.d.ts +3 -10
- package/dist/Components/DsTextArea/DsTextArea.Component.js +49 -54
- package/dist/Components/DsTextArea/DsTextArea.Types.d.ts +0 -1
- package/dist/Components/DsTextArea/DsTextArea.Types.js +1 -3
- package/dist/Components/DsTextField/DsTextField.Component.d.ts +2 -4
- package/dist/Components/DsTextField/DsTextField.Component.js +7 -8
- package/dist/Components/DsTextFieldPassword/DsTextFieldPassword.Component.d.ts +3 -10
- package/dist/Components/DsTextFieldPassword/DsTextFieldPassword.Component.js +15 -26
- package/dist/Components/DsTextFieldPassword/DsTextFieldPassword.Types.d.ts +0 -1
- package/dist/Components/DsTextFieldPassword/DsTextFieldPassword.Types.js +0 -3
- package/dist/Components/DsToast/DsToast.Component.d.ts +2 -4
- package/dist/Components/DsToast/DsToast.Component.js +9 -7
- package/dist/Components/DsToggle/DsToggle.Component.d.ts +2 -5
- package/dist/Components/DsToggle/DsToggle.Component.js +11 -9
- package/dist/Components/DsToggle/DsToggle.Types.js +1 -1
- package/dist/Components/DsTooltip/DsTooltip.Component.d.ts +2 -5
- package/dist/Components/DsTooltip/DsTooltip.Component.js +7 -9
- package/dist/Theme/componentOverrides.d.ts +15 -5
- package/dist/Theme/getColorScheme/dark.js +4 -4
- package/dist/Theme/getColorScheme/highContrast.js +1 -1
- package/dist/Theme/getColorScheme/light.js +1 -1
- package/package.json +1 -1
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
2
|
+
import { useState } from 'react';
|
|
3
3
|
import { DsBox } from '../DsBox';
|
|
4
4
|
import { DsFade } from '../DsFade';
|
|
5
5
|
import { DsRemixIcon } from '../DsRemixIcon';
|
|
6
6
|
import { DsSkeleton } from '../DsSkeleton';
|
|
7
|
-
import {
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
handleSetLoadedStage = () =>
|
|
11
|
-
handleSetErrorStage = () =>
|
|
12
|
-
|
|
13
|
-
const { srcSet = [] } =
|
|
7
|
+
import { DEFULT_ERROR_ICON_PROPS, INNER_COMPONENT_STYLE } from './DsImage.Types';
|
|
8
|
+
export const DsImage = (props) => {
|
|
9
|
+
const [stage, setStage] = useState('LOADING');
|
|
10
|
+
const handleSetLoadedStage = () => setStage('LOADED');
|
|
11
|
+
const handleSetErrorStage = () => setStage('ERROR');
|
|
12
|
+
const checkHasSource = () => {
|
|
13
|
+
const { srcSet = [] } = props;
|
|
14
14
|
return srcSet && srcSet.length > 0;
|
|
15
15
|
};
|
|
16
|
-
renderLoadingComponent = () => {
|
|
17
|
-
const {
|
|
18
|
-
const
|
|
19
|
-
const hasSource = this.hasSource();
|
|
16
|
+
const renderLoadingComponent = () => {
|
|
17
|
+
const { aspectRatio, LoaderProps } = props;
|
|
18
|
+
const hasSource = checkHasSource();
|
|
20
19
|
const isLoading = hasSource && stage === 'LOADING';
|
|
21
20
|
if (!isLoading) {
|
|
22
21
|
return false;
|
|
@@ -26,10 +25,9 @@ export class DsImage extends React.Component {
|
|
|
26
25
|
...LoaderProps?.sx
|
|
27
26
|
} }));
|
|
28
27
|
};
|
|
29
|
-
renderErrorComponent = () => {
|
|
30
|
-
const {
|
|
31
|
-
const
|
|
32
|
-
const hasSource = this.hasSource();
|
|
28
|
+
const renderErrorComponent = () => {
|
|
29
|
+
const { aspectRatio, ErrorIconProps } = props;
|
|
30
|
+
const hasSource = checkHasSource();
|
|
33
31
|
const isError = !hasSource || stage === 'ERROR';
|
|
34
32
|
if (!isError) {
|
|
35
33
|
return false;
|
|
@@ -39,13 +37,13 @@ export class DsImage extends React.Component {
|
|
|
39
37
|
...ErrorIconProps?.sx
|
|
40
38
|
} }));
|
|
41
39
|
};
|
|
42
|
-
renderPictureComponent = () => {
|
|
43
|
-
const { srcSet, aspectRatio, ErrorIconProps, WrapperProps, ...ImageProps } =
|
|
44
|
-
const hasSource =
|
|
40
|
+
const renderPictureComponent = () => {
|
|
41
|
+
const { srcSet, aspectRatio, ErrorIconProps, WrapperProps, ...ImageProps } = props;
|
|
42
|
+
const hasSource = checkHasSource();
|
|
45
43
|
if (!hasSource) {
|
|
46
44
|
return _jsx(_Fragment, {});
|
|
47
45
|
}
|
|
48
|
-
return (_jsx("picture", { onLoad:
|
|
46
|
+
return (_jsx("picture", { onLoad: handleSetLoadedStage, onError: handleSetErrorStage, children: srcSet?.map((src, index) => {
|
|
49
47
|
const { src: imageSrc, style, ...restProps } = src;
|
|
50
48
|
const isLast = index === srcSet.length - 1;
|
|
51
49
|
if (isLast) {
|
|
@@ -59,29 +57,26 @@ export class DsImage extends React.Component {
|
|
|
59
57
|
return _jsx("source", { srcSet: imageSrc, ...restProps }, index);
|
|
60
58
|
}) }));
|
|
61
59
|
};
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
60
|
+
const { srcSet, aspectRatio, WrapperProps } = props;
|
|
61
|
+
const hasSource = srcSet && srcSet.length > 0;
|
|
62
|
+
const isError = !hasSource || stage === 'ERROR';
|
|
63
|
+
const isLoading = !isError && stage === 'LOADING';
|
|
64
|
+
return (_jsxs(DsBox, { ...WrapperProps, sx: {
|
|
65
|
+
position: 'relative',
|
|
66
|
+
width: '100%',
|
|
67
|
+
height: '100%',
|
|
68
|
+
...((aspectRatio && {
|
|
69
|
+
aspectRatio: `${aspectRatio} auto`,
|
|
70
|
+
overflow: 'hidden',
|
|
70
71
|
width: '100%',
|
|
71
|
-
height: '
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}) ||
|
|
83
|
-
{}),
|
|
84
|
-
...WrapperProps?.sx
|
|
85
|
-
}, children: [this.renderLoadingComponent(), this.renderErrorComponent(), _jsx(DsFade, { in: !isLoading && !isError, children: this.renderPictureComponent() })] }));
|
|
86
|
-
}
|
|
87
|
-
}
|
|
72
|
+
height: 'auto',
|
|
73
|
+
maxWidth: '100%',
|
|
74
|
+
[`@supports not (aspect-ratio: ${aspectRatio})`]: {
|
|
75
|
+
paddingTop: `calc((1 / ${aspectRatio}) * 100%)`,
|
|
76
|
+
height: 0
|
|
77
|
+
}
|
|
78
|
+
}) ||
|
|
79
|
+
{}),
|
|
80
|
+
...WrapperProps?.sx
|
|
81
|
+
}, children: [renderLoadingComponent(), renderErrorComponent(), _jsx(DsFade, { in: !isLoading && !isError, children: renderPictureComponent() })] }));
|
|
82
|
+
};
|
|
@@ -17,7 +17,6 @@ export interface DsImageProps extends Omit<React.ImgHTMLAttributes<any>, 'srcSet
|
|
|
17
17
|
export interface DsImageState {
|
|
18
18
|
stage: 'LOADING' | 'LOADED' | 'ERROR';
|
|
19
19
|
}
|
|
20
|
-
export declare const DsImageDefaultState: DsImageState;
|
|
21
20
|
export declare const DEFULT_ERROR_ICON_PROPS: IErrorIconProps;
|
|
22
21
|
export declare const INNER_COMPONENT_STYLE: React.CSSProperties;
|
|
23
22
|
export {};
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FC } from 'react';
|
|
2
2
|
import { DsInputLabelProps } from './DsInputLabel.Types';
|
|
3
|
-
export declare
|
|
4
|
-
render(): import("react/jsx-runtime").JSX.Element | null;
|
|
5
|
-
}
|
|
3
|
+
export declare const DsInputLabel: FC<DsInputLabelProps>;
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { PureComponent } from 'react';
|
|
3
2
|
import InputLabel from '@mui/material/InputLabel';
|
|
4
3
|
import { DsTypography } from '../DsTypography';
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return null;
|
|
10
|
-
}
|
|
11
|
-
return (_jsxs(InputLabel, { error: error, ...inputLabelProps, children: [_jsx(DsTypography, { component: "span", variant: "bodyRegularMedium", sx: { float: 'left' }, children: label }), _jsx(DsTypography, { component: "span", variant: "bodyRegularSmall", color: "text.secondary", sx: { float: 'right', width: '100%' }, children: labelSupportText })] }));
|
|
4
|
+
export const DsInputLabel = (props) => {
|
|
5
|
+
const { label, labelSupportText, success, error, ...inputLabelProps } = props;
|
|
6
|
+
if (!label && !labelSupportText) {
|
|
7
|
+
return null;
|
|
12
8
|
}
|
|
13
|
-
}
|
|
9
|
+
return (_jsxs(InputLabel, { error: error, ...inputLabelProps, children: [_jsx(DsTypography, { component: "span", variant: "bodyRegularMedium", sx: { float: 'left' }, children: label }), _jsx(DsTypography, { component: "span", variant: "bodyRegularSmall", color: "text.secondary", sx: { float: 'right', width: '100%' }, children: labelSupportText })] }));
|
|
10
|
+
};
|
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import React
|
|
2
|
+
import React from 'react';
|
|
3
3
|
import { closeSnackbar } from 'notistack';
|
|
4
4
|
import { DsToast } from '../DsToast';
|
|
5
|
-
|
|
6
|
-
handleClose = () => {
|
|
7
|
-
const { id } =
|
|
5
|
+
const AlertMessage = (props) => {
|
|
6
|
+
const handleClose = () => {
|
|
7
|
+
const { id } = props;
|
|
8
8
|
closeSnackbar(id);
|
|
9
9
|
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
}
|
|
10
|
+
const { ref, toastVariant, variant, message, id, autoHideDuration, hideIconVariant, anchorOrigin, persist, iconVariant, ...restProps } = props;
|
|
11
|
+
return (_jsx(DsToast, { ...restProps, variant: toastVariant, color: variant, onClose: handleClose, children: message }));
|
|
12
|
+
};
|
|
15
13
|
export const DsNotistackAlertDefault = React.forwardRef((props, ref) => {
|
|
16
14
|
return _jsx(AlertMessage, { forwardedRef: ref, ...props, variant: "default" });
|
|
17
15
|
});
|
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FC } from 'react';
|
|
2
2
|
import { SnackbarProviderProps, useSnackbar } from 'notistack';
|
|
3
3
|
import { DsNotistackKey, EnqueNotistackProps } from './DsNotistack.Types';
|
|
4
4
|
declare const useNotistack: typeof useSnackbar;
|
|
5
5
|
export { closeNotistack, useNotistack, enqueueNotistack, generateKeyNotistack };
|
|
6
|
-
export declare
|
|
7
|
-
static defaultProps: {
|
|
8
|
-
hideIconVariant: boolean;
|
|
9
|
-
};
|
|
10
|
-
render(): import("react/jsx-runtime").JSX.Element;
|
|
11
|
-
}
|
|
6
|
+
export declare const DsNotistackProvider: FC<SnackbarProviderProps>;
|
|
12
7
|
declare function generateKeyNotistack(message?: string): string;
|
|
13
8
|
declare function enqueueNotistack(notistackOptions: EnqueNotistackProps): void;
|
|
14
9
|
declare function closeNotistack(key?: DsNotistackKey | undefined): void;
|
|
@@ -1,24 +1,20 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Component } from 'react';
|
|
3
2
|
import { SnackbarProvider, closeSnackbar, enqueueSnackbar, useSnackbar } from 'notistack';
|
|
4
3
|
import { DsNotistackAlertDefault, DsNotistackAlertSuccess, DsNotistackAlertError, DsNotistackAlertWarning, DsNotistackAlertInfo } from './AlertMessage.Component';
|
|
4
|
+
import { DsNotistackProviderDefaultProps } from './DsNotistack.Types';
|
|
5
5
|
const useNotistack = useSnackbar;
|
|
6
6
|
export { closeNotistack, useNotistack, enqueueNotistack, generateKeyNotistack };
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
...this.props.Components
|
|
19
|
-
} }));
|
|
20
|
-
}
|
|
21
|
-
}
|
|
7
|
+
export const DsNotistackProvider = (inProps) => {
|
|
8
|
+
const props = { ...DsNotistackProviderDefaultProps, ...inProps };
|
|
9
|
+
return (_jsx(SnackbarProvider, { preventDuplicate: true, anchorOrigin: { vertical: 'top', horizontal: 'center' }, ...props, Components: {
|
|
10
|
+
default: DsNotistackAlertDefault,
|
|
11
|
+
success: DsNotistackAlertSuccess,
|
|
12
|
+
error: DsNotistackAlertError,
|
|
13
|
+
warning: DsNotistackAlertWarning,
|
|
14
|
+
info: DsNotistackAlertInfo,
|
|
15
|
+
...props.Components
|
|
16
|
+
} }));
|
|
17
|
+
};
|
|
22
18
|
function generateKeyNotistack(message) {
|
|
23
19
|
const key = `${message || ''}-${new Date().getTime()}`;
|
|
24
20
|
return key;
|
|
@@ -8,3 +8,4 @@ export interface NotiStackMessage {
|
|
|
8
8
|
}
|
|
9
9
|
export interface EnqueNotistackProps extends OptionsObject, NotiStackMessage, Pick<DsToastProps, Exclude<keyof DsToastProps, keyof OptionsObject>> {
|
|
10
10
|
}
|
|
11
|
+
export declare const DsNotistackProviderDefaultProps: SnackbarProviderProps;
|
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { DsOtpProps
|
|
3
|
-
export declare
|
|
4
|
-
static defaultProps: DsOtpProps;
|
|
5
|
-
optInputRefs: Map<any, any>;
|
|
6
|
-
constructor(props: DsOtpProps);
|
|
7
|
-
handleFocus: (event: React.FocusEvent<HTMLInputElement, Element>) => void;
|
|
8
|
-
handleKeyDown: (event: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
9
|
-
handleChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
10
|
-
_handleNavigation: (index: number, isBackPressed?: boolean) => void;
|
|
11
|
-
handlePaste: (event: React.ClipboardEvent<HTMLInputElement>) => void;
|
|
12
|
-
resetOtpValues: () => void;
|
|
13
|
-
renderOtpBoxes: () => import("react/jsx-runtime").JSX.Element[];
|
|
14
|
-
render(): import("react/jsx-runtime").JSX.Element;
|
|
15
|
-
}
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { DsOtpProps } from './DsOtp.Types';
|
|
3
|
+
export declare const DsOtp: FC<DsOtpProps>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { useState } from 'react';
|
|
3
3
|
import { DsBox } from '../DsBox';
|
|
4
4
|
import { DsStack } from '../DsStack';
|
|
5
5
|
import { DsInputLabel } from '../DsInputLabel';
|
|
@@ -9,41 +9,35 @@ import { DsOtpDefaultProps } from './DsOtp.Types';
|
|
|
9
9
|
const KEY_CODES = {
|
|
10
10
|
BACK_SPACE: 'Backspace'
|
|
11
11
|
};
|
|
12
|
-
export
|
|
13
|
-
|
|
14
|
-
optInputRefs = new Map();
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
otp: initialOtp ? [...initialOtp].slice(0, length) : []
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
handleFocus = (event) => {
|
|
23
|
-
const { onFocus } = this.props;
|
|
12
|
+
export const DsOtp = (inProps) => {
|
|
13
|
+
const props = { ...DsOtpDefaultProps, ...inProps };
|
|
14
|
+
const optInputRefs = new Map();
|
|
15
|
+
const { initialOtp = '', length } = props;
|
|
16
|
+
const [otp, setOtp] = useState(initialOtp ? [...initialOtp].slice(0, length) : []);
|
|
17
|
+
const handleFocus = (event) => {
|
|
18
|
+
const { onFocus } = props;
|
|
24
19
|
const { target } = event;
|
|
25
20
|
target.select();
|
|
26
21
|
if (typeof onFocus === 'function') {
|
|
27
22
|
onFocus(event);
|
|
28
23
|
}
|
|
29
24
|
};
|
|
30
|
-
handleKeyDown = (event) => {
|
|
31
|
-
const { onKeyDown } =
|
|
25
|
+
const handleKeyDown = (event) => {
|
|
26
|
+
const { onKeyDown } = props;
|
|
32
27
|
const { key, currentTarget } = event;
|
|
33
28
|
const { name, value } = currentTarget;
|
|
34
29
|
const indexString = name.split('.').pop() || '';
|
|
35
30
|
const index = parseInt(indexString, 10);
|
|
36
31
|
// Call _handleNavigation on back button pressed
|
|
37
32
|
if (key === KEY_CODES.BACK_SPACE && !value) {
|
|
38
|
-
|
|
33
|
+
_handleNavigation(index, true);
|
|
39
34
|
}
|
|
40
35
|
if (typeof onKeyDown === 'function') {
|
|
41
36
|
onKeyDown(event);
|
|
42
37
|
}
|
|
43
38
|
};
|
|
44
|
-
handleChange = (event) => {
|
|
45
|
-
const { onChange, onComplete, length } =
|
|
46
|
-
const { otp } = this.state;
|
|
39
|
+
const handleChange = (event) => {
|
|
40
|
+
const { onChange, onComplete, length } = props;
|
|
47
41
|
const { target } = event;
|
|
48
42
|
const { name, value = '' } = target;
|
|
49
43
|
const indexString = name.split('.').pop() || '';
|
|
@@ -53,37 +47,36 @@ export class DsOtp extends Component {
|
|
|
53
47
|
otp[index] = filteredValue;
|
|
54
48
|
const shouldNavigate = filteredValue;
|
|
55
49
|
const _this = this;
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
});
|
|
50
|
+
setOtp([...otp]);
|
|
51
|
+
if (shouldNavigate) {
|
|
52
|
+
_handleNavigation(index, false);
|
|
53
|
+
}
|
|
54
|
+
if (typeof onChange === 'function') {
|
|
55
|
+
onChange(event);
|
|
56
|
+
}
|
|
57
|
+
const otpString = otp.join('');
|
|
58
|
+
if (otpString.length === length && typeof onComplete === 'function') {
|
|
59
|
+
onComplete(otpString);
|
|
60
|
+
}
|
|
68
61
|
};
|
|
69
|
-
_handleNavigation = (index, isBackPressed) => {
|
|
62
|
+
const _handleNavigation = (index, isBackPressed) => {
|
|
70
63
|
const nextFocussedIndex = isBackPressed ? --index : ++index;
|
|
71
|
-
const nextFocussedInput =
|
|
64
|
+
const nextFocussedInput = optInputRefs.get(nextFocussedIndex);
|
|
72
65
|
if (nextFocussedInput) {
|
|
73
66
|
nextFocussedInput.focus();
|
|
74
67
|
}
|
|
75
68
|
};
|
|
76
|
-
handlePaste = (event) => {
|
|
69
|
+
const handlePaste = (event) => {
|
|
77
70
|
event.preventDefault();
|
|
78
|
-
const { onPaste, onComplete, length } =
|
|
71
|
+
const { onPaste, onComplete, length } = props;
|
|
79
72
|
const { clipboardData, currentTarget } = event;
|
|
80
73
|
const pastedData = clipboardData.getData('text');
|
|
81
74
|
const filteredValue = pastedData.replace(/\D/g, '') || '';
|
|
82
75
|
const otp = filteredValue.split('').slice(0, length);
|
|
83
|
-
|
|
76
|
+
setOtp(otp);
|
|
84
77
|
currentTarget.blur();
|
|
85
78
|
const focusIndex = otp.length - 1;
|
|
86
|
-
|
|
79
|
+
_handleNavigation(focusIndex);
|
|
87
80
|
if (typeof onPaste === 'function') {
|
|
88
81
|
onPaste(event);
|
|
89
82
|
}
|
|
@@ -92,12 +85,11 @@ export class DsOtp extends Component {
|
|
|
92
85
|
onComplete(otpString);
|
|
93
86
|
}
|
|
94
87
|
};
|
|
95
|
-
resetOtpValues = () => {
|
|
96
|
-
|
|
88
|
+
const resetOtpValues = () => {
|
|
89
|
+
setOtp([]);
|
|
97
90
|
};
|
|
98
|
-
renderOtpBoxes = () => {
|
|
99
|
-
const {
|
|
100
|
-
const { label, labelSupportText, name, length, helperText, inputProps = {}, HelperTextProps, BoxProps, InputLabelProps, ...restProps } = this.props;
|
|
91
|
+
const renderOtpBoxes = () => {
|
|
92
|
+
const { label, labelSupportText, name, length, helperText, inputProps = {}, HelperTextProps, BoxProps, InputLabelProps, ...restProps } = props;
|
|
101
93
|
const lengthArray = Array(length).fill('');
|
|
102
94
|
const otpInputProps = {
|
|
103
95
|
...inputProps,
|
|
@@ -107,14 +99,12 @@ export class DsOtp extends Component {
|
|
|
107
99
|
textAlign: 'center'
|
|
108
100
|
}
|
|
109
101
|
};
|
|
110
|
-
return lengthArray.map((value, index) => (_jsx(DsTextField, { type: "tel", inputMode: "tel", ...restProps, name: `${name}.${index}`, "ds-variant": "otp", inputProps: otpInputProps, onPaste:
|
|
111
|
-
|
|
102
|
+
return lengthArray.map((value, index) => (_jsx(DsTextField, { type: "tel", inputMode: "tel", ...restProps, name: `${name}.${index}`, "ds-variant": "otp", inputProps: otpInputProps, onPaste: handlePaste, onFocus: handleFocus, onChange: handleChange, onKeyDown: handleKeyDown, value: otp[index] || '', inputRef: ref => {
|
|
103
|
+
optInputRefs.set(index, ref);
|
|
112
104
|
} }, index)));
|
|
113
105
|
};
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
}
|
|
106
|
+
const { id, name, label, labelSupportText, helperText, success, color, error, inputProps, disabled, InputLabelProps, HelperTextProps, BoxProps } = props;
|
|
107
|
+
return (_jsxs(DsBox, { ...BoxProps, children: [_jsx(DsInputLabel, { label: label, labelSupportText: labelSupportText,
|
|
108
|
+
// error={error}
|
|
109
|
+
success: success, htmlFor: id || name, disabled: disabled, ...InputLabelProps }), _jsx(DsStack, { direction: "row", spacing: "var(--ds-spacing-glacial)", style: {}, children: renderOtpBoxes() }), _jsx(DsHelperText, { helperText: helperText, color: color, success: success, error: error, ...HelperTextProps })] }));
|
|
110
|
+
};
|
|
@@ -14,7 +14,7 @@ interface DsBottomSheetPropsCustom extends Omit<DsBottomSheetProps, 'ref' | 'ope
|
|
|
14
14
|
open?: DsBottomSheetProps['open'];
|
|
15
15
|
}
|
|
16
16
|
export interface DsPopupProps extends Pick<DsDialogProps, 'onClose'> {
|
|
17
|
-
open
|
|
17
|
+
open: DsDialogProps['open'];
|
|
18
18
|
title?: string;
|
|
19
19
|
description?: string;
|
|
20
20
|
showClose?: boolean;
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FC } from 'react';
|
|
2
2
|
import { DsProgressIndicatorProps } from './DsProgressIndicator.Types';
|
|
3
|
-
export declare
|
|
4
|
-
static defaultProps: DsProgressIndicatorProps;
|
|
5
|
-
getFillText: () => string | import("react/jsx-runtime").JSX.Element;
|
|
6
|
-
render(): import("react/jsx-runtime").JSX.Element;
|
|
7
|
-
}
|
|
3
|
+
export declare const DsProgressIndicator: FC<DsProgressIndicatorProps>;
|
|
@@ -1,37 +1,34 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Component } from 'react';
|
|
3
2
|
import { DsProgressIndicatorDefaultProps } from './DsProgressIndicator.Types';
|
|
4
3
|
import { DsBox } from '../DsBox';
|
|
5
4
|
import { DsCircularProgress } from '../DsCircularProgress';
|
|
6
5
|
import { DsTypography } from '../DsTypography';
|
|
7
6
|
import { DsRemixIcon } from '../DsRemixIcon';
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
getFillText = () => {
|
|
11
|
-
const { activeStep, steps, isSuccess, isError } =
|
|
7
|
+
export const DsProgressIndicator = (inProps) => {
|
|
8
|
+
const props = { ...DsProgressIndicatorDefaultProps, ...inProps };
|
|
9
|
+
const getFillText = () => {
|
|
10
|
+
const { activeStep, steps, isSuccess, isError } = props;
|
|
12
11
|
if (isSuccess) {
|
|
13
12
|
return (_jsx(DsRemixIcon, { sx: { color: 'var(--ds-colour-iconPositive)' }, className: "ri-check-line" }));
|
|
14
13
|
}
|
|
15
14
|
if (isError) {
|
|
16
15
|
return (_jsx(DsRemixIcon, { sx: { color: 'var(--ds-colour-iconNegative)' }, className: "ri-error-warning-line" }));
|
|
17
16
|
}
|
|
18
|
-
if (
|
|
17
|
+
if (props['ds-variant'] === 'fraction') {
|
|
19
18
|
return `${activeStep}/${steps}`;
|
|
20
19
|
}
|
|
21
20
|
return `${Math.round((activeStep / steps) * 100)}%`;
|
|
22
21
|
};
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
}
|
|
22
|
+
const { activeStep, steps, isSuccess, isError } = props;
|
|
23
|
+
const squareSize = props['ds-variant'] === 'fraction' ? '48px' : '32px';
|
|
24
|
+
const fillPercentage = Math.round((activeStep / steps) * 100);
|
|
25
|
+
const fillColor = isSuccess ? 'success' : isError ? 'error' : 'secondary';
|
|
26
|
+
return (_jsxs(DsBox, { display: "flex", position: "relative", height: squareSize, width: squareSize, children: [_jsx(DsCircularProgress, { variant: "determinate", value: 100, sx: { color: 'var(--ds-colour-stateDisabledSurface)' }, size: squareSize, thickness: 4 }), _jsx(DsCircularProgress, { variant: "determinate", color: fillColor, value: fillPercentage, size: squareSize, thickness: 4, style: {
|
|
27
|
+
position: 'absolute'
|
|
28
|
+
} }), _jsx(DsTypography, { variant: "subheadingSemiboldDefault", sx: {
|
|
29
|
+
position: 'absolute',
|
|
30
|
+
left: '50%',
|
|
31
|
+
top: '50%',
|
|
32
|
+
transform: 'translate(-50%,-50%)'
|
|
33
|
+
}, children: getFillText() })] }));
|
|
34
|
+
};
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { DsProgressStepperProps
|
|
3
|
-
|
|
4
|
-
export declare class DsProgressStepper extends PureComponent<DsProgressStepperProps> {
|
|
5
|
-
static defaultProps: DsProgressStepperProps;
|
|
6
|
-
renderStepIcon: (stepProps: StepIconProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
-
renderStep: (step: DsProgressStepperStepProps, index: number) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
-
render(): import("react/jsx-runtime").JSX.Element;
|
|
9
|
-
}
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { DsProgressStepperProps } from './DsProgressStepper.Types';
|
|
3
|
+
export declare const DsProgressStepper: FC<DsProgressStepperProps>;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { PureComponent } from 'react';
|
|
3
2
|
import { DsProgressStepperDefaultProps } from './DsProgressStepper.Types';
|
|
4
3
|
import { DsStepper } from '../DsStepper';
|
|
5
4
|
import { DsStep } from '../DsStep';
|
|
6
5
|
import { DsStepLabel } from '../DsStepLabel';
|
|
7
6
|
import { DsRemixIcon } from '../DsRemixIcon';
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
renderStepIcon = (stepProps) => {
|
|
7
|
+
export const DsProgressStepper = (inProps) => {
|
|
8
|
+
const props = { ...DsProgressStepperDefaultProps, ...inProps };
|
|
9
|
+
const renderStepIcon = (stepProps) => {
|
|
11
10
|
const { active, error, completed, icon } = stepProps;
|
|
12
11
|
if (error) {
|
|
13
12
|
return (_jsx(DsRemixIcon, { className: "ri-close-circle-fill", sx: { color: 'var(--ds-colour-iconNegative)' } }));
|
|
@@ -20,7 +19,7 @@ export class DsProgressStepper extends PureComponent {
|
|
|
20
19
|
}
|
|
21
20
|
return _jsx(_Fragment, { children: icon });
|
|
22
21
|
};
|
|
23
|
-
renderStep = (step, index) => {
|
|
22
|
+
const renderStep = (step, index) => {
|
|
24
23
|
const { stepName, error, icon, optional, completed, disabled } = step;
|
|
25
24
|
const stepProps = { completed, disabled };
|
|
26
25
|
const stepLabelProps = { error, icon, optional };
|
|
@@ -31,10 +30,8 @@ export class DsProgressStepper extends PureComponent {
|
|
|
31
30
|
}
|
|
32
31
|
};
|
|
33
32
|
}
|
|
34
|
-
return (_jsx(DsStep, { ...stepProps, children: _jsx(DsStepLabel, { ...stepLabelProps, StepIconComponent:
|
|
33
|
+
return (_jsx(DsStep, { ...stepProps, children: _jsx(DsStepLabel, { ...stepLabelProps, StepIconComponent: renderStepIcon, children: stepName }) }, index));
|
|
35
34
|
};
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
}
|
|
35
|
+
const { steps, ...stepperProps } = props;
|
|
36
|
+
return (_jsx(DsStepper, { ...stepperProps, alternativeLabel: stepperProps.orientation === 'horizontal', children: steps.map(renderStep) }));
|
|
37
|
+
};
|
|
@@ -1,21 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { DsProgressTrackerProps
|
|
3
|
-
export declare
|
|
4
|
-
static defaultProps: DsProgressTrackerProps;
|
|
5
|
-
constructor(props: DsProgressTrackerProps);
|
|
6
|
-
getMergedProps: () => {
|
|
7
|
-
StepperProps: {
|
|
8
|
-
sx?: import("@mui/system").SxProps<import("@mui/material").Theme>;
|
|
9
|
-
orientation?: import("@mui/material").Orientation;
|
|
10
|
-
};
|
|
11
|
-
'ds-variant': "default" | "header" | "steps";
|
|
12
|
-
steps: import("./DsProgressStepper.Types").DsProgressStepperStepProps[];
|
|
13
|
-
activeStep: number;
|
|
14
|
-
sx?: import("../DsBox").DsBoxProps;
|
|
15
|
-
nextStepLabelPrefix: React.ReactNode;
|
|
16
|
-
};
|
|
17
|
-
handleToggleCollapse: () => void;
|
|
18
|
-
renderStepper: () => import("react/jsx-runtime").JSX.Element | null;
|
|
19
|
-
renderHeader: () => import("react/jsx-runtime").JSX.Element | null;
|
|
20
|
-
render(): import("react/jsx-runtime").JSX.Element;
|
|
21
|
-
}
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { DsProgressTrackerProps } from './DsProgressTracker.Types';
|
|
3
|
+
export declare const DsProgressTracker: FC<DsProgressTrackerProps>;
|