@digital-ai/dot-components 2.25.2 → 2.26.1
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/index.esm.js
CHANGED
|
@@ -1671,7 +1671,10 @@ const getAvatarColorForInputText = value => {
|
|
|
1671
1671
|
const colorOptions = [...Object.keys(avatarColors)];
|
|
1672
1672
|
if (!value || !colorOptions || colorOptions.length <= 0) return 'default';
|
|
1673
1673
|
const numberFromValue = calculateNumberFromText(value);
|
|
1674
|
-
|
|
1674
|
+
const index = numberFromValue % colorOptions.length;
|
|
1675
|
+
// if number is 9 (transparent), return default color
|
|
1676
|
+
if (index === 9) return 'default';
|
|
1677
|
+
return colorOptions[index];
|
|
1675
1678
|
};
|
|
1676
1679
|
const isString$1 = str => typeof str === 'string';
|
|
1677
1680
|
const isLowerCase = str => str === str.toLowerCase();
|
|
@@ -7042,6 +7045,20 @@ const StyledToggleButtonGroup = styled(ToggleButtonGroup)`
|
|
|
7042
7045
|
}
|
|
7043
7046
|
}
|
|
7044
7047
|
|
|
7048
|
+
.toggle-button-badge {
|
|
7049
|
+
align-items: center;
|
|
7050
|
+
gap: ${theme.spacing(1)};
|
|
7051
|
+
|
|
7052
|
+
.dot-typography {
|
|
7053
|
+
margin-left: 0;
|
|
7054
|
+
}
|
|
7055
|
+
|
|
7056
|
+
.MuiBadge-badge {
|
|
7057
|
+
position: static;
|
|
7058
|
+
transform: none;
|
|
7059
|
+
}
|
|
7060
|
+
}
|
|
7061
|
+
|
|
7045
7062
|
.dot-typography {
|
|
7046
7063
|
margin-bottom: 0;
|
|
7047
7064
|
}
|
|
@@ -7134,6 +7151,7 @@ const DotButtonToggle = ({
|
|
|
7134
7151
|
const rootClasses = useStylesWithRootClass(rootClassName$G, className);
|
|
7135
7152
|
const renderToggleButton = ({
|
|
7136
7153
|
ariaLabel: optionAriaLabel,
|
|
7154
|
+
badgeContent: optionBadgeContent,
|
|
7137
7155
|
className: optionClassName,
|
|
7138
7156
|
disabled: optionDisabled,
|
|
7139
7157
|
iconId: optionIconId,
|
|
@@ -7150,14 +7168,25 @@ const DotButtonToggle = ({
|
|
|
7150
7168
|
key,
|
|
7151
7169
|
value: optionValue
|
|
7152
7170
|
};
|
|
7153
|
-
const
|
|
7154
|
-
|
|
7155
|
-
|
|
7156
|
-
|
|
7157
|
-
|
|
7158
|
-
|
|
7159
|
-
|
|
7160
|
-
|
|
7171
|
+
const getChildren = () => {
|
|
7172
|
+
if (!optionIconId && !optionText) return;
|
|
7173
|
+
const optionTextTypography = jsxs(Fragment, {
|
|
7174
|
+
children: [optionIconId && jsx(DotIcon, {
|
|
7175
|
+
className: "dot-toggle-icon",
|
|
7176
|
+
iconId: optionIconId
|
|
7177
|
+
}), optionText && jsx(DotTypography, {
|
|
7178
|
+
children: optionText
|
|
7179
|
+
})]
|
|
7180
|
+
});
|
|
7181
|
+
return optionBadgeContent && !isNaN(optionBadgeContent) && optionBadgeContent > 0 && optionText ? jsx(DotBadge, {
|
|
7182
|
+
"data-testid": dataTestId && `${dataTestId}-badge`,
|
|
7183
|
+
className: "toggle-button-badge",
|
|
7184
|
+
badgeContent: optionBadgeContent,
|
|
7185
|
+
variant: "standard",
|
|
7186
|
+
children: optionTextTypography
|
|
7187
|
+
}) : optionTextTypography;
|
|
7188
|
+
};
|
|
7189
|
+
const children = getChildren();
|
|
7161
7190
|
return optionTooltip ? jsx(TooltipToggleButton, Object.assign({}, commonProps, {
|
|
7162
7191
|
CustomTooltipProps: {
|
|
7163
7192
|
title: optionTooltip
|
|
@@ -10126,6 +10155,7 @@ const StyledSnackbar = styled(Snackbar)`
|
|
|
10126
10155
|
}
|
|
10127
10156
|
.MuiAlert-message {
|
|
10128
10157
|
padding: 13px 0px;
|
|
10158
|
+
word-break: break-word;
|
|
10129
10159
|
}
|
|
10130
10160
|
&.MuiSnackbar-anchorOriginTopRight{
|
|
10131
10161
|
top: 0px;
|
|
@@ -10183,6 +10213,7 @@ const DotSnackbar = ({
|
|
|
10183
10213
|
action,
|
|
10184
10214
|
anchorOrigin = DEFAULT_ANCHOR_ORIGIN,
|
|
10185
10215
|
ariaLabel,
|
|
10216
|
+
autoHideDuration,
|
|
10186
10217
|
children,
|
|
10187
10218
|
className,
|
|
10188
10219
|
'data-testid': dataTestId,
|
|
@@ -10192,7 +10223,7 @@ const DotSnackbar = ({
|
|
|
10192
10223
|
severity,
|
|
10193
10224
|
width
|
|
10194
10225
|
}) => {
|
|
10195
|
-
const
|
|
10226
|
+
const calculatedAutoHideDuration = autoHideDuration === null || autoHideDuration > 0 ? autoHideDuration : addAutoHideDuration(severity);
|
|
10196
10227
|
checkForConflictingEventHandlers({
|
|
10197
10228
|
onClose,
|
|
10198
10229
|
action
|
|
@@ -10206,7 +10237,7 @@ const DotSnackbar = ({
|
|
|
10206
10237
|
return jsx(StyledSnackbar, {
|
|
10207
10238
|
anchorOrigin: anchorOrigin,
|
|
10208
10239
|
"aria-label": ariaLabel,
|
|
10209
|
-
autoHideDuration:
|
|
10240
|
+
autoHideDuration: calculatedAutoHideDuration,
|
|
10210
10241
|
classes: {
|
|
10211
10242
|
root: rootClasses
|
|
10212
10243
|
},
|
|
@@ -10247,7 +10278,7 @@ const StyledSnackbarContainer = styled.div`
|
|
|
10247
10278
|
|
|
10248
10279
|
const DotSnackbarContext = createContext({
|
|
10249
10280
|
alerts: [],
|
|
10250
|
-
enqueueMessage: (_message, _severity) => null,
|
|
10281
|
+
enqueueMessage: (_message, _severity, _autoHideDuration) => null,
|
|
10251
10282
|
removeMessage: _id => null
|
|
10252
10283
|
});
|
|
10253
10284
|
const DotSnackbarContainer = ({
|
|
@@ -10269,6 +10300,7 @@ const DotSnackbarContainer = ({
|
|
|
10269
10300
|
"data-testid": rootClassName$l,
|
|
10270
10301
|
children: alerts.slice().reverse().map(alert => {
|
|
10271
10302
|
return jsx(DotSnackbar, {
|
|
10303
|
+
autoHideDuration: alert.autoHideDuration,
|
|
10272
10304
|
hideOnClickAway: hideOnClickAway,
|
|
10273
10305
|
onClose: handleClose(alert.id),
|
|
10274
10306
|
open: alert.open,
|
|
@@ -10284,13 +10316,14 @@ const DotSnackbarProvider = ({
|
|
|
10284
10316
|
hideOnClickAway = true
|
|
10285
10317
|
}) => {
|
|
10286
10318
|
const [alerts, setAlerts] = useState([]);
|
|
10287
|
-
function enqueueMessage(message, severity) {
|
|
10319
|
+
function enqueueMessage(message, severity, autoHideDuration) {
|
|
10288
10320
|
const id = CreateUUID();
|
|
10289
10321
|
const queue = {
|
|
10290
10322
|
id,
|
|
10291
10323
|
message,
|
|
10292
10324
|
severity,
|
|
10293
|
-
open: true
|
|
10325
|
+
open: true,
|
|
10326
|
+
autoHideDuration
|
|
10294
10327
|
};
|
|
10295
10328
|
setAlerts(prevState => {
|
|
10296
10329
|
return [...prevState, Object.assign({}, queue)];
|
|
@@ -12485,6 +12518,7 @@ const DotTableActions = ({
|
|
|
12485
12518
|
return actions && actions.map((action, index) => index < 2 && jsx(DotTableAction, {
|
|
12486
12519
|
iconId: action.iconId,
|
|
12487
12520
|
label: action.label,
|
|
12521
|
+
disabled: action.disabled,
|
|
12488
12522
|
tooltip: action.tooltip || action.label,
|
|
12489
12523
|
onClick: e => handleTableActionClick(e, action)
|
|
12490
12524
|
}, `action-${index}`));
|
package/index.esm.mjs
CHANGED
|
@@ -1671,7 +1671,10 @@ const getAvatarColorForInputText = value => {
|
|
|
1671
1671
|
const colorOptions = [...Object.keys(avatarColors)];
|
|
1672
1672
|
if (!value || !colorOptions || colorOptions.length <= 0) return 'default';
|
|
1673
1673
|
const numberFromValue = calculateNumberFromText(value);
|
|
1674
|
-
|
|
1674
|
+
const index = numberFromValue % colorOptions.length;
|
|
1675
|
+
// if number is 9 (transparent), return default color
|
|
1676
|
+
if (index === 9) return 'default';
|
|
1677
|
+
return colorOptions[index];
|
|
1675
1678
|
};
|
|
1676
1679
|
const isString$1 = str => typeof str === 'string';
|
|
1677
1680
|
const isLowerCase = str => str === str.toLowerCase();
|
|
@@ -7042,6 +7045,20 @@ const StyledToggleButtonGroup = styled(ToggleButtonGroup)`
|
|
|
7042
7045
|
}
|
|
7043
7046
|
}
|
|
7044
7047
|
|
|
7048
|
+
.toggle-button-badge {
|
|
7049
|
+
align-items: center;
|
|
7050
|
+
gap: ${theme.spacing(1)};
|
|
7051
|
+
|
|
7052
|
+
.dot-typography {
|
|
7053
|
+
margin-left: 0;
|
|
7054
|
+
}
|
|
7055
|
+
|
|
7056
|
+
.MuiBadge-badge {
|
|
7057
|
+
position: static;
|
|
7058
|
+
transform: none;
|
|
7059
|
+
}
|
|
7060
|
+
}
|
|
7061
|
+
|
|
7045
7062
|
.dot-typography {
|
|
7046
7063
|
margin-bottom: 0;
|
|
7047
7064
|
}
|
|
@@ -7134,6 +7151,7 @@ const DotButtonToggle = ({
|
|
|
7134
7151
|
const rootClasses = useStylesWithRootClass(rootClassName$G, className);
|
|
7135
7152
|
const renderToggleButton = ({
|
|
7136
7153
|
ariaLabel: optionAriaLabel,
|
|
7154
|
+
badgeContent: optionBadgeContent,
|
|
7137
7155
|
className: optionClassName,
|
|
7138
7156
|
disabled: optionDisabled,
|
|
7139
7157
|
iconId: optionIconId,
|
|
@@ -7150,14 +7168,25 @@ const DotButtonToggle = ({
|
|
|
7150
7168
|
key,
|
|
7151
7169
|
value: optionValue
|
|
7152
7170
|
};
|
|
7153
|
-
const
|
|
7154
|
-
|
|
7155
|
-
|
|
7156
|
-
|
|
7157
|
-
|
|
7158
|
-
|
|
7159
|
-
|
|
7160
|
-
|
|
7171
|
+
const getChildren = () => {
|
|
7172
|
+
if (!optionIconId && !optionText) return;
|
|
7173
|
+
const optionTextTypography = jsxs(Fragment, {
|
|
7174
|
+
children: [optionIconId && jsx(DotIcon, {
|
|
7175
|
+
className: "dot-toggle-icon",
|
|
7176
|
+
iconId: optionIconId
|
|
7177
|
+
}), optionText && jsx(DotTypography, {
|
|
7178
|
+
children: optionText
|
|
7179
|
+
})]
|
|
7180
|
+
});
|
|
7181
|
+
return optionBadgeContent && !isNaN(optionBadgeContent) && optionBadgeContent > 0 && optionText ? jsx(DotBadge, {
|
|
7182
|
+
"data-testid": dataTestId && `${dataTestId}-badge`,
|
|
7183
|
+
className: "toggle-button-badge",
|
|
7184
|
+
badgeContent: optionBadgeContent,
|
|
7185
|
+
variant: "standard",
|
|
7186
|
+
children: optionTextTypography
|
|
7187
|
+
}) : optionTextTypography;
|
|
7188
|
+
};
|
|
7189
|
+
const children = getChildren();
|
|
7161
7190
|
return optionTooltip ? jsx(TooltipToggleButton, Object.assign({}, commonProps, {
|
|
7162
7191
|
CustomTooltipProps: {
|
|
7163
7192
|
title: optionTooltip
|
|
@@ -10126,6 +10155,7 @@ const StyledSnackbar = styled(Snackbar)`
|
|
|
10126
10155
|
}
|
|
10127
10156
|
.MuiAlert-message {
|
|
10128
10157
|
padding: 13px 0px;
|
|
10158
|
+
word-break: break-word;
|
|
10129
10159
|
}
|
|
10130
10160
|
&.MuiSnackbar-anchorOriginTopRight{
|
|
10131
10161
|
top: 0px;
|
|
@@ -10183,6 +10213,7 @@ const DotSnackbar = ({
|
|
|
10183
10213
|
action,
|
|
10184
10214
|
anchorOrigin = DEFAULT_ANCHOR_ORIGIN,
|
|
10185
10215
|
ariaLabel,
|
|
10216
|
+
autoHideDuration,
|
|
10186
10217
|
children,
|
|
10187
10218
|
className,
|
|
10188
10219
|
'data-testid': dataTestId,
|
|
@@ -10192,7 +10223,7 @@ const DotSnackbar = ({
|
|
|
10192
10223
|
severity,
|
|
10193
10224
|
width
|
|
10194
10225
|
}) => {
|
|
10195
|
-
const
|
|
10226
|
+
const calculatedAutoHideDuration = autoHideDuration === null || autoHideDuration > 0 ? autoHideDuration : addAutoHideDuration(severity);
|
|
10196
10227
|
checkForConflictingEventHandlers({
|
|
10197
10228
|
onClose,
|
|
10198
10229
|
action
|
|
@@ -10206,7 +10237,7 @@ const DotSnackbar = ({
|
|
|
10206
10237
|
return jsx(StyledSnackbar, {
|
|
10207
10238
|
anchorOrigin: anchorOrigin,
|
|
10208
10239
|
"aria-label": ariaLabel,
|
|
10209
|
-
autoHideDuration:
|
|
10240
|
+
autoHideDuration: calculatedAutoHideDuration,
|
|
10210
10241
|
classes: {
|
|
10211
10242
|
root: rootClasses
|
|
10212
10243
|
},
|
|
@@ -10247,7 +10278,7 @@ const StyledSnackbarContainer = styled.div`
|
|
|
10247
10278
|
|
|
10248
10279
|
const DotSnackbarContext = createContext({
|
|
10249
10280
|
alerts: [],
|
|
10250
|
-
enqueueMessage: (_message, _severity) => null,
|
|
10281
|
+
enqueueMessage: (_message, _severity, _autoHideDuration) => null,
|
|
10251
10282
|
removeMessage: _id => null
|
|
10252
10283
|
});
|
|
10253
10284
|
const DotSnackbarContainer = ({
|
|
@@ -10269,6 +10300,7 @@ const DotSnackbarContainer = ({
|
|
|
10269
10300
|
"data-testid": rootClassName$l,
|
|
10270
10301
|
children: alerts.slice().reverse().map(alert => {
|
|
10271
10302
|
return jsx(DotSnackbar, {
|
|
10303
|
+
autoHideDuration: alert.autoHideDuration,
|
|
10272
10304
|
hideOnClickAway: hideOnClickAway,
|
|
10273
10305
|
onClose: handleClose(alert.id),
|
|
10274
10306
|
open: alert.open,
|
|
@@ -10284,13 +10316,14 @@ const DotSnackbarProvider = ({
|
|
|
10284
10316
|
hideOnClickAway = true
|
|
10285
10317
|
}) => {
|
|
10286
10318
|
const [alerts, setAlerts] = useState([]);
|
|
10287
|
-
function enqueueMessage(message, severity) {
|
|
10319
|
+
function enqueueMessage(message, severity, autoHideDuration) {
|
|
10288
10320
|
const id = CreateUUID();
|
|
10289
10321
|
const queue = {
|
|
10290
10322
|
id,
|
|
10291
10323
|
message,
|
|
10292
10324
|
severity,
|
|
10293
|
-
open: true
|
|
10325
|
+
open: true,
|
|
10326
|
+
autoHideDuration
|
|
10294
10327
|
};
|
|
10295
10328
|
setAlerts(prevState => {
|
|
10296
10329
|
return [...prevState, Object.assign({}, queue)];
|
|
@@ -12485,6 +12518,7 @@ const DotTableActions = ({
|
|
|
12485
12518
|
return actions && actions.map((action, index) => index < 2 && jsx(DotTableAction, {
|
|
12486
12519
|
iconId: action.iconId,
|
|
12487
12520
|
label: action.label,
|
|
12521
|
+
disabled: action.disabled,
|
|
12488
12522
|
tooltip: action.tooltip || action.label,
|
|
12489
12523
|
onClick: e => handleTableActionClick(e, action)
|
|
12490
12524
|
}, `action-${index}`));
|
package/package.json
CHANGED
|
@@ -5,6 +5,7 @@ export type ButtonToggleOrientation = 'horizontal' | 'vertical';
|
|
|
5
5
|
export type ButtonToggleValue = ButtonToggleSingleValue | Array<ButtonToggleSingleValue>;
|
|
6
6
|
export interface ButtonToggleOption extends CommonProps {
|
|
7
7
|
ariaLabel: string;
|
|
8
|
+
badgeContent?: number;
|
|
8
9
|
disabled?: boolean;
|
|
9
10
|
iconId?: string;
|
|
10
11
|
text?: string;
|
|
@@ -7,6 +7,8 @@ export interface SnackbarProps extends CommonProps {
|
|
|
7
7
|
action?: ReactNode;
|
|
8
8
|
/** The anchor of the Snackbar. On smaller screens, the component grows to occupy all the available width, the horizontal alignment is ignored. */
|
|
9
9
|
anchorOrigin?: SnackbarOrigin;
|
|
10
|
+
/** The number of milliseconds to wait before automatically closing the snackbar. If null is passed, then the snackbar never automatically closes. If the prop is not passed at all, then snackbars close after 10 seconds (except error snackbar which never closes automatically). */
|
|
11
|
+
autoHideDuration?: number | null;
|
|
10
12
|
/** The message the user sees once the alert displays. */
|
|
11
13
|
children: ReactNode;
|
|
12
14
|
/** If false, then snackbar does not close when clicking away. True by default. */
|
|
@@ -20,4 +22,4 @@ export interface SnackbarProps extends CommonProps {
|
|
|
20
22
|
/** Width of the encapsulated Alert component. */
|
|
21
23
|
width?: string;
|
|
22
24
|
}
|
|
23
|
-
export declare const DotSnackbar: ({ action, anchorOrigin, ariaLabel, children, className, "data-testid": dataTestId, hideOnClickAway, onClose, open, severity, width, }: SnackbarProps) => import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
export declare const DotSnackbar: ({ action, anchorOrigin, ariaLabel, autoHideDuration, children, className, "data-testid": dataTestId, hideOnClickAway, onClose, open, severity, width, }: SnackbarProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -5,6 +5,7 @@ declare const initialState: {
|
|
|
5
5
|
open: boolean;
|
|
6
6
|
severity: string;
|
|
7
7
|
id: string;
|
|
8
|
+
autoHideDuration: number;
|
|
8
9
|
}[];
|
|
9
10
|
export interface SnackbarProviderProps {
|
|
10
11
|
/** The components or string that load inside the snackbar provider. */
|
|
@@ -16,9 +17,10 @@ interface SnackbarContainerProps {
|
|
|
16
17
|
}
|
|
17
18
|
interface DotSnackbarProps {
|
|
18
19
|
alerts: typeof initialState;
|
|
19
|
-
enqueueMessage: (message: ReactNode, severity: SnackbarSeverity) => string;
|
|
20
|
+
enqueueMessage: (message: ReactNode, severity: SnackbarSeverity, autoHideDuration?: number | null) => string;
|
|
20
21
|
removeMessage: (id: string) => void;
|
|
21
22
|
}
|
|
23
|
+
export declare const DotSnackbarContext: import("react").Context<DotSnackbarProps>;
|
|
22
24
|
export declare const DotSnackbarContainer: ({ hideOnClickAway, }: SnackbarContainerProps) => import("react/jsx-runtime").JSX.Element;
|
|
23
25
|
export declare const DotSnackbarProvider: ({ children, hideOnClickAway, }: SnackbarProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
24
26
|
export declare const useDotSnackbarContext: () => DotSnackbarProps;
|