@am92/react-design-system 2.10.2 → 3.0.1-beta.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/dist/Components/DsAddItem/DsAddItem.Component.d.ts +2 -0
- package/dist/Components/DsAddItem/DsAddItem.Component.js +105 -0
- package/dist/Components/DsAddItem/DsAddItem.Overrides.d.ts +5 -0
- package/dist/Components/DsAddItem/DsAddItem.Overrides.js +6 -0
- package/dist/Components/DsAddItem/DsAddItem.Types.d.ts +78 -0
- package/dist/Components/DsAddItem/DsAddItem.Types.js +35 -0
- package/dist/Components/DsAddItem/Slots/DsAddItemActionIcon.Slot.d.ts +3 -0
- package/dist/Components/DsAddItem/Slots/DsAddItemActionIcon.Slot.js +9 -0
- package/dist/Components/DsAddItem/Slots/DsAddItemCounterText.Slot.d.ts +3 -0
- package/dist/Components/DsAddItem/Slots/DsAddItemCounterText.Slot.js +15 -0
- package/dist/Components/DsAddItem/index.d.ts +3 -0
- package/dist/Components/DsAddItem/index.js +3 -0
- package/dist/Components/DsAvatar/DsAvatar.Overrides.d.ts +54 -50
- package/dist/Components/DsAvatar/DsAvatar.Overrides.js +107 -103
- package/dist/Components/DsBadge/DsBadge.Component.d.ts +2 -1
- package/dist/Components/DsBadge/DsBadge.Component.js +11 -1
- package/dist/Components/DsBadge/DsBadge.Overrides.d.ts +23 -1
- package/dist/Components/DsBadge/DsBadge.Overrides.js +23 -0
- package/dist/Components/DsBadge/DsBadge.Types.d.ts +5 -1
- package/dist/Components/DsBottomSheet/DsBottomSheet.Component.js +16 -10
- package/dist/Components/DsButton/DsButton.Overrides.d.ts +8 -12
- package/dist/Components/DsButton/DsButton.Overrides.js +26 -26
- package/dist/Components/DsButtonBase/DsButtonBase.Overrides.d.ts +10 -1
- package/dist/Components/DsButtonBase/DsButtonBase.Overrides.js +11 -1
- package/dist/Components/DsChip/DsChip.Overrides.d.ts +9 -6
- package/dist/Components/DsChip/DsChip.Overrides.js +136 -133
- package/dist/Components/DsDialog/DsDialog.Component.js +22 -16
- package/dist/Components/DsDialog/DsDialog.Types.d.ts +3 -1
- package/dist/Components/DsDivider/DsDivider.Overrides.d.ts +5 -5
- package/dist/Components/DsDivider/DsDivider.Overrides.js +32 -32
- package/dist/Components/DsFab/DsFab.Overrides.js +1 -0
- package/dist/Components/DsInputBase/DsInputBase.Overrides.d.ts +3 -7
- package/dist/Components/DsInputBase/DsInputBase.Overrides.js +61 -61
- package/dist/Components/DsInputLabel/DsInputLabel.Component.js +5 -1
- package/dist/Components/DsProgressIndicator/DsProgressIndicator.Component.js +6 -1
- package/dist/Components/DsProgressTracker/Components/DsProgressStepper.Component.js +4 -1
- package/dist/Components/DsProgressTracker/Components/DsProgressTrackerHeader.Component.js +16 -3
- package/dist/Components/DsSearchbar/DsSearchbar.Component.js +4 -1
- package/dist/Components/DsSelect/DsSelect.Component.js +3 -1
- package/dist/Components/DsSelect/DsSelect.Types.d.ts +1 -0
- package/dist/Components/DsSlider/DsSlider.Overrides.d.ts +13 -13
- package/dist/Components/DsSlider/DsSlider.Overrides.js +16 -16
- package/dist/Components/DsTabs/DsTabs.Overrides.d.ts +3 -7
- package/dist/Components/DsTabs/DsTabs.Overrides.js +84 -44
- package/dist/Components/DsTabs/DsTabs.Types.d.ts +2 -2
- package/dist/Components/DsTabs/DsTabs.Types.js +2 -2
- package/dist/Components/DsTag/DsTag.Component.js +29 -9
- package/dist/Components/DsToggleButtonGroup/DsToggleButtonGroup.Overrides.d.ts +9 -5
- package/dist/Components/DsToggleButtonGroup/DsToggleButtonGroup.Overrides.js +47 -43
- package/dist/Components/index.d.ts +1 -0
- package/dist/Components/index.js +1 -0
- package/dist/Theme/componentOverrides.d.ts +165 -129
- package/dist/Theme/componentOverrides.js +2 -1
- package/dist/Theme/getColorScheme/dark.d.ts +28 -1
- package/dist/Theme/getColorScheme/getPalette.d.ts +2 -2
- package/dist/Theme/getColorScheme/getPalette.js +3 -1
- package/dist/Theme/getColorScheme/highContrast.d.ts +28 -1
- package/dist/Theme/getColorScheme/light.d.ts +28 -1
- package/dist/Theme/index.d.ts +5 -0
- package/dist/Theme/index.js +2 -1
- package/dist/Theme/radius.js +1 -0
- package/dist/Theme/spacing.js +1 -0
- package/dist/Types/DsRadius.d.ts +1 -1
- package/dist/Types/DsSpacing.d.ts +1 -1
- package/dist/material.d.ts +0 -2
- package/dist/material.js +0 -2
- package/dist/x-charts/Components/index.d.ts +2 -6
- package/dist/x-charts/Components/index.js +2 -6
- package/dist/x-charts/Hooks/index.d.ts +3 -0
- package/dist/x-charts/Hooks/index.js +5 -0
- package/dist/x-charts/Types/index.d.ts +0 -6
- package/dist/x-charts/index.d.ts +1 -0
- package/dist/x-charts/index.js +1 -0
- package/dist/x-datepicker/Components/DsDatePicker/DateCalenderHeader.d.ts +1 -1
- package/dist/x-datepicker/Components/DsDatePicker/DateCalenderHeader.js +17 -4
- package/dist/x-datepicker/Components/DsDatePicker/DatePickerTextField.d.ts +4 -4
- package/dist/x-datepicker/Components/DsDatePicker/DatePickerTextField.js +4 -3
- package/dist/x-datepicker/Components/DsDatePicker/DefaultActionBar.d.ts +4 -7
- package/dist/x-datepicker/Components/DsDatePicker/DefaultActionBar.js +8 -8
- package/dist/x-datepicker/Components/DsDatePicker/DefaultToolbar.d.ts +1 -3
- package/dist/x-datepicker/Components/DsDatePicker/DefaultToolbar.js +4 -7
- package/dist/x-datepicker/Components/DsDatePicker/DsDatePicker.Component.d.ts +1 -1
- package/dist/x-datepicker/Components/DsDatePicker/DsDatePicker.Component.js +6 -12
- package/dist/x-datepicker/Components/DsDatePicker/DsDatePicker.Overrides.d.ts +36 -31
- package/dist/x-datepicker/Components/DsDatePicker/DsDatePicker.Overrides.js +11 -22
- package/dist/x-datepicker/Components/DsDatePicker/DsDatePicker.Types.d.ts +3 -3
- package/dist/x-datepicker/Components/DsDatePicker/utils.d.ts +3 -3
- package/dist/x-datepicker/Locale/DsDatePickerLocaleBeBY.d.ts +24 -8
- package/dist/x-datepicker/Locale/DsDatePickerLocaleBeBY.js +1 -1
- package/dist/x-datepicker/Locale/DsDatePickerLocaleCaES.d.ts +24 -8
- package/dist/x-datepicker/Locale/DsDatePickerLocaleCaES.js +1 -1
- package/dist/x-datepicker/Locale/DsDatePickerLocaleCsCZ.d.ts +24 -8
- package/dist/x-datepicker/Locale/DsDatePickerLocaleCsCZ.js +1 -1
- package/dist/x-datepicker/Locale/DsDatePickerLocaleDaDK.d.ts +24 -8
- package/dist/x-datepicker/Locale/DsDatePickerLocaleDaDK.js +1 -1
- package/dist/x-datepicker/Locale/DsDatePickerLocaleDeDE.d.ts +24 -8
- package/dist/x-datepicker/Locale/DsDatePickerLocaleDeDE.js +1 -1
- package/dist/x-datepicker/Locale/DsDatePickerLocaleElGR.d.ts +24 -8
- package/dist/x-datepicker/Locale/DsDatePickerLocaleElGR.js +1 -1
- package/dist/x-datepicker/Locale/DsDatePickerLocaleEnUS.d.ts +24 -8
- package/dist/x-datepicker/Locale/DsDatePickerLocaleEnUS.js +1 -1
- package/dist/x-datepicker/Locale/DsDatePickerLocaleEsES.d.ts +24 -8
- package/dist/x-datepicker/Locale/DsDatePickerLocaleEsES.js +1 -1
- package/dist/x-datepicker/Locale/DsDatePickerLocaleEu.d.ts +24 -8
- package/dist/x-datepicker/Locale/DsDatePickerLocaleEu.js +1 -1
- package/dist/x-datepicker/Locale/DsDatePickerLocaleFaIR.d.ts +24 -8
- package/dist/x-datepicker/Locale/DsDatePickerLocaleFaIR.js +1 -1
- package/dist/x-datepicker/Locale/DsDatePickerLocaleFiFI.d.ts +24 -8
- package/dist/x-datepicker/Locale/DsDatePickerLocaleFiFI.js +1 -1
- package/dist/x-datepicker/Locale/DsDatePickerLocaleFrFR.d.ts +24 -8
- package/dist/x-datepicker/Locale/DsDatePickerLocaleFrFR.js +1 -1
- package/dist/x-datepicker/Locale/DsDatePickerLocaleHeIL.d.ts +24 -8
- package/dist/x-datepicker/Locale/DsDatePickerLocaleHeIL.js +1 -1
- package/dist/x-datepicker/Locale/DsDatePickerLocaleHuHU.d.ts +24 -8
- package/dist/x-datepicker/Locale/DsDatePickerLocaleHuHU.js +1 -1
- package/dist/x-datepicker/Locale/DsDatePickerLocaleIsIS.d.ts +24 -8
- package/dist/x-datepicker/Locale/DsDatePickerLocaleIsIS.js +1 -1
- package/dist/x-datepicker/Locale/DsDatePickerLocaleItIT.d.ts +24 -8
- package/dist/x-datepicker/Locale/DsDatePickerLocaleItIT.js +1 -1
- package/dist/x-datepicker/Locale/DsDatePickerLocaleJaJP.d.ts +24 -8
- package/dist/x-datepicker/Locale/DsDatePickerLocaleJaJP.js +1 -1
- package/dist/x-datepicker/Locale/DsDatePickerLocaleKoKR.d.ts +24 -8
- package/dist/x-datepicker/Locale/DsDatePickerLocaleKoKR.js +1 -1
- package/dist/x-datepicker/Locale/DsDatePickerLocaleKzKZ.d.ts +24 -8
- package/dist/x-datepicker/Locale/DsDatePickerLocaleKzKZ.js +1 -1
- package/dist/x-datepicker/Locale/DsDatePickerLocaleMk.d.ts +24 -8
- package/dist/x-datepicker/Locale/DsDatePickerLocaleMk.js +1 -1
- package/dist/x-datepicker/Locale/DsDatePickerLocaleNbNO.d.ts +24 -8
- package/dist/x-datepicker/Locale/DsDatePickerLocaleNbNO.js +1 -1
- package/dist/x-datepicker/Locale/DsDatePickerLocaleNlNL.d.ts +24 -8
- package/dist/x-datepicker/Locale/DsDatePickerLocaleNlNL.js +1 -1
- package/dist/x-datepicker/Locale/DsDatePickerLocalePlPL.d.ts +24 -8
- package/dist/x-datepicker/Locale/DsDatePickerLocalePlPL.js +1 -1
- package/dist/x-datepicker/Locale/DsDatePickerLocalePtBR.d.ts +24 -8
- package/dist/x-datepicker/Locale/DsDatePickerLocalePtBR.js +1 -1
- package/dist/x-datepicker/Locale/DsDatePickerLocaleRoRO.d.ts +24 -8
- package/dist/x-datepicker/Locale/DsDatePickerLocaleRoRO.js +1 -1
- package/dist/x-datepicker/Locale/DsDatePickerLocaleRuRU.d.ts +24 -8
- package/dist/x-datepicker/Locale/DsDatePickerLocaleRuRU.js +1 -1
- package/dist/x-datepicker/Locale/DsDatePickerLocaleSkSK.d.ts +24 -8
- package/dist/x-datepicker/Locale/DsDatePickerLocaleSkSK.js +1 -1
- package/dist/x-datepicker/Locale/DsDatePickerLocaleSvSE.d.ts +24 -8
- package/dist/x-datepicker/Locale/DsDatePickerLocaleSvSE.js +1 -1
- package/dist/x-datepicker/Locale/DsDatePickerLocaleTrTR.d.ts +24 -8
- package/dist/x-datepicker/Locale/DsDatePickerLocaleTrTR.js +1 -1
- package/dist/x-datepicker/Locale/DsDatePickerLocaleUkUA.d.ts +24 -8
- package/dist/x-datepicker/Locale/DsDatePickerLocaleUkUA.js +1 -1
- package/dist/x-datepicker/Locale/DsDatePickerLocaleUrPK.d.ts +23 -7
- package/dist/x-datepicker/Locale/DsDatePickerLocaleViVN.d.ts +24 -8
- package/dist/x-datepicker/Locale/DsDatePickerLocaleViVN.js +1 -1
- package/dist/x-datepicker/Locale/DsDatePickerLocaleZhCN.d.ts +24 -8
- package/dist/x-datepicker/Locale/DsDatePickerLocaleZhCN.js +1 -1
- package/dist/x-datepicker/Locale/DsDatePickerLocaleZhHK.d.ts +24 -8
- package/dist/x-datepicker/Locale/DsDatePickerLocaleZhHK.js +1 -1
- package/dist/x-datepicker/componentOverrides.d.ts +36 -31
- package/package.json +11 -11
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useMemo, useState } from "react";
|
|
3
|
+
import { DsAddItemDefaultProps, DEFAULT_STEP_VALUE, } from "./DsAddItem.Types";
|
|
4
|
+
import STATE_STYLES from "../../Theme/STATE_STYLES";
|
|
5
|
+
import { DsButtonBase } from "../DsButtonBase";
|
|
6
|
+
import { DsBox } from "../DsBox";
|
|
7
|
+
export const DsAddItem = (inProps) => {
|
|
8
|
+
const mergedSlots = {
|
|
9
|
+
...DsAddItemDefaultProps.slots,
|
|
10
|
+
...(inProps.slots || {}),
|
|
11
|
+
};
|
|
12
|
+
const mergedSlotProps = {
|
|
13
|
+
...DsAddItemDefaultProps.slotProps,
|
|
14
|
+
...(inProps.slotProps || {}),
|
|
15
|
+
};
|
|
16
|
+
const props = {
|
|
17
|
+
...DsAddItemDefaultProps,
|
|
18
|
+
...inProps,
|
|
19
|
+
slots: mergedSlots,
|
|
20
|
+
slotProps: mergedSlotProps,
|
|
21
|
+
};
|
|
22
|
+
const { value, label, maxValue, minValue, step, slots, slotProps, disabled, onChange, name, loading, ...restProps } = props;
|
|
23
|
+
const isControlled = typeof value === "number";
|
|
24
|
+
const { LeftIconButton, RightIconButton, CounterText } = slots;
|
|
25
|
+
// Internal state for count value, initialized based on control mode
|
|
26
|
+
const [countValue, setCountValue] = useState(isControlled ? value : 0);
|
|
27
|
+
// Component is in "empty" state when count is 0 (shows single Add button)
|
|
28
|
+
const isEmptyCount = countValue === 0;
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
if (isControlled && value !== countValue) {
|
|
31
|
+
setCountValue(value);
|
|
32
|
+
}
|
|
33
|
+
}, [value]);
|
|
34
|
+
const isAddDisabled = disabled || loading || (maxValue !== undefined && countValue >= maxValue);
|
|
35
|
+
const isSubtractDisabled = disabled || loading;
|
|
36
|
+
// Helper function to check if value is below minValue threshold
|
|
37
|
+
const isBelowMinValue = (value) => {
|
|
38
|
+
return minValue !== undefined && value < minValue;
|
|
39
|
+
};
|
|
40
|
+
// Helper function to calculate new value based on operation
|
|
41
|
+
const calculateNewValue = (operation) => {
|
|
42
|
+
const stepValue = step ?? DEFAULT_STEP_VALUE;
|
|
43
|
+
return operation === "add"
|
|
44
|
+
? countValue + stepValue
|
|
45
|
+
: countValue - stepValue;
|
|
46
|
+
};
|
|
47
|
+
const handleAdd = (e) => {
|
|
48
|
+
e.stopPropagation();
|
|
49
|
+
if (!isAddDisabled) {
|
|
50
|
+
let newValue = calculateNewValue("add");
|
|
51
|
+
// Jump to minValue if increment would result in a value below minimum threshold
|
|
52
|
+
if (isBelowMinValue(newValue)) {
|
|
53
|
+
newValue = minValue;
|
|
54
|
+
}
|
|
55
|
+
if (!isControlled) {
|
|
56
|
+
setCountValue(newValue);
|
|
57
|
+
}
|
|
58
|
+
if (typeof onChange === "function")
|
|
59
|
+
onChange(name, newValue, "increment");
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
const handleSubtract = (e) => {
|
|
63
|
+
e.stopPropagation();
|
|
64
|
+
if (!isSubtractDisabled) {
|
|
65
|
+
let newValue = calculateNewValue("subtract");
|
|
66
|
+
// Reset to 0 if would go negative or below minValue (back to "add" state)
|
|
67
|
+
if (newValue < 0 || isBelowMinValue(newValue)) {
|
|
68
|
+
newValue = 0;
|
|
69
|
+
}
|
|
70
|
+
if (!isControlled) {
|
|
71
|
+
setCountValue(newValue);
|
|
72
|
+
}
|
|
73
|
+
if (typeof onChange === "function")
|
|
74
|
+
onChange(name, newValue, "decrement");
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
const fabSx = useMemo(() => ({
|
|
78
|
+
px: "var(--ds-spacing-glacial)",
|
|
79
|
+
pt: isEmptyCount ? "var(--ds-spacing-quickFreeze)" : 0,
|
|
80
|
+
pb: isEmptyCount ? "var(--ds-spacing-quickFreeze)" : 0,
|
|
81
|
+
minWidth: "90px",
|
|
82
|
+
minHeight: "var(--ds-spacing-tepid)",
|
|
83
|
+
borderRadius: "var(--ds-radius-cool)",
|
|
84
|
+
boxShadow: "var(--ds-elevation-8)",
|
|
85
|
+
background: "var(--ds-colour-surfacePrimary)",
|
|
86
|
+
"&:hover": {
|
|
87
|
+
background: "var(--ds-colour-surfacePrimary) !important",
|
|
88
|
+
},
|
|
89
|
+
...STATE_STYLES.SURFACE_SECONDARY_STATE_PRIMARY,
|
|
90
|
+
pointerEvents: !isEmptyCount && disabled ? "none" : "auto",
|
|
91
|
+
"&.Mui-disabled": {
|
|
92
|
+
background: "var(--ds-colour-stateDisabledSurface) !important",
|
|
93
|
+
},
|
|
94
|
+
...restProps.sx,
|
|
95
|
+
}), [isEmptyCount, disabled, restProps.sx]);
|
|
96
|
+
const boxSx = useMemo(() => ({
|
|
97
|
+
...fabSx,
|
|
98
|
+
display: "flex",
|
|
99
|
+
justifyContent: "center",
|
|
100
|
+
alignItems: "center",
|
|
101
|
+
...restProps.sx,
|
|
102
|
+
}), [fabSx, restProps.sx]);
|
|
103
|
+
const counterTextElement = CounterText && (_jsx(CounterText, { value: countValue, label: label ?? "", disabled: disabled ?? false, ...slotProps?.CounterText }));
|
|
104
|
+
return isEmptyCount ? (_jsx(DsButtonBase, { "aria-label": label, "aria-disabled": disabled, color: "default", ...restProps, onClick: isEmptyCount ? handleAdd : undefined, sx: fabSx, disableRipple: !isEmptyCount || disabled, children: counterTextElement })) : (_jsxs(DsBox, { component: "div", "aria-label": label, "aria-disabled": disabled, color: "default", ...restProps, onClick: isEmptyCount ? handleAdd : undefined, sx: boxSx, children: [!isEmptyCount && LeftIconButton && (_jsx(LeftIconButton, { disabled: isSubtractDisabled, onClick: handleSubtract, "aria-label": "Decrease value", ...slotProps?.LeftIconButton })), counterTextElement, !isEmptyCount && RightIconButton && (_jsx(RightIconButton, { onClick: handleAdd, disabled: isAddDisabled, "aria-label": "Increase value", ...slotProps?.RightIconButton }))] }));
|
|
105
|
+
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { ComponentType } from "react";
|
|
2
|
+
import { DsButtonBaseProps } from "../DsButtonBase";
|
|
3
|
+
import { DsTypographyProps } from "../DsTypography";
|
|
4
|
+
import { DsIconButtonProps } from "../DsIconButton";
|
|
5
|
+
import { DsRemixIconProps } from "../DsRemixIcon";
|
|
6
|
+
/**
|
|
7
|
+
* Default step value for increment/decrement operations
|
|
8
|
+
*/
|
|
9
|
+
export declare const DEFAULT_STEP_VALUE = 1;
|
|
10
|
+
/**
|
|
11
|
+
* Props for action buttons (left/right) within the add item component
|
|
12
|
+
* Extends DsIconButtonProps with optional icon configuration
|
|
13
|
+
*/
|
|
14
|
+
export interface DsAddItemActionButtonProps extends DsIconButtonProps {
|
|
15
|
+
/** Props for the icon within the action button */
|
|
16
|
+
IconProps?: Omit<DsRemixIconProps, "ref">;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Props for the counter text display showing current count
|
|
20
|
+
*/
|
|
21
|
+
export interface DsAddItemCounterTextProps extends DsTypographyProps {
|
|
22
|
+
label: string;
|
|
23
|
+
value: number;
|
|
24
|
+
disabled: boolean;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Slots configuration for customizing components
|
|
28
|
+
*/
|
|
29
|
+
export interface DsAddItemSlots {
|
|
30
|
+
/** Component for the left (subtract) icon button */
|
|
31
|
+
LeftIconButton?: ComponentType<DsAddItemActionButtonProps>;
|
|
32
|
+
/** Component for the right (add) icon button */
|
|
33
|
+
RightIconButton?: ComponentType<DsAddItemActionButtonProps>;
|
|
34
|
+
/** Component for the counter text display */
|
|
35
|
+
CounterText?: ComponentType<DsAddItemCounterTextProps>;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Slot props configuration for customizing different parts of the add item component
|
|
39
|
+
*/
|
|
40
|
+
export interface DsAddItemSlotProps {
|
|
41
|
+
/** Props for the left (subtract) icon button */
|
|
42
|
+
LeftIconButton?: DsAddItemActionButtonProps;
|
|
43
|
+
/** Props for the right (add) icon button */
|
|
44
|
+
RightIconButton?: DsAddItemActionButtonProps;
|
|
45
|
+
/** Props for the counter text display */
|
|
46
|
+
CounterText?: DsAddItemCounterTextProps;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Main props interface for the DsAddItem component
|
|
50
|
+
* Extends DsFabProps while omitting the onChange prop to define custom signature
|
|
51
|
+
*/
|
|
52
|
+
export interface DsAddItemProps extends Omit<DsButtonBaseProps, "onChange" | "value"> {
|
|
53
|
+
/** The current count value */
|
|
54
|
+
value?: number;
|
|
55
|
+
/** The maximum allowed value */
|
|
56
|
+
maxValue?: number;
|
|
57
|
+
/** The minimum allowed value */
|
|
58
|
+
minValue?: number;
|
|
59
|
+
/** The step size for increment/decrement */
|
|
60
|
+
step?: number;
|
|
61
|
+
/** The label to show when count is 0 */
|
|
62
|
+
label?: string;
|
|
63
|
+
/** Handler called when count changes */
|
|
64
|
+
onChange: (name: string, value: number, reason: "increment" | "decrement") => void;
|
|
65
|
+
/** Custom components to use for slots */
|
|
66
|
+
slots?: DsAddItemSlots;
|
|
67
|
+
/** Props to pass to slot components */
|
|
68
|
+
slotProps?: DsAddItemSlotProps;
|
|
69
|
+
/** Name of the counter field */
|
|
70
|
+
name: string;
|
|
71
|
+
/** Whether the counter is in loading state */
|
|
72
|
+
loading?: boolean;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Default props configuration for DsAddItem component
|
|
76
|
+
* Provides sensible defaults for count, label, and slot styling
|
|
77
|
+
*/
|
|
78
|
+
export declare const DsAddItemDefaultProps: Partial<DsAddItemProps>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { DsAddItemIconButton } from "./Slots/DsAddItemActionIcon.Slot";
|
|
2
|
+
import { DsAddItemCounterText } from "./Slots/DsAddItemCounterText.Slot";
|
|
3
|
+
/**
|
|
4
|
+
* Default step value for increment/decrement operations
|
|
5
|
+
*/
|
|
6
|
+
export const DEFAULT_STEP_VALUE = 1;
|
|
7
|
+
/**
|
|
8
|
+
* Default props configuration for DsAddItem component
|
|
9
|
+
* Provides sensible defaults for count, label, and slot styling
|
|
10
|
+
*/
|
|
11
|
+
export const DsAddItemDefaultProps = {
|
|
12
|
+
label: "Add",
|
|
13
|
+
step: DEFAULT_STEP_VALUE,
|
|
14
|
+
minValue: 0,
|
|
15
|
+
onChange: () => { },
|
|
16
|
+
slots: {
|
|
17
|
+
LeftIconButton: DsAddItemIconButton,
|
|
18
|
+
RightIconButton: DsAddItemIconButton,
|
|
19
|
+
CounterText: DsAddItemCounterText,
|
|
20
|
+
},
|
|
21
|
+
slotProps: {
|
|
22
|
+
LeftIconButton: {
|
|
23
|
+
color: "secondary",
|
|
24
|
+
IconProps: {
|
|
25
|
+
className: "ri-subtract-line",
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
RightIconButton: {
|
|
29
|
+
color: "secondary",
|
|
30
|
+
IconProps: {
|
|
31
|
+
className: "ri-add-line",
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { DsIconButton } from "../../DsIconButton";
|
|
3
|
+
import { DsRemixIcon } from "../../DsRemixIcon";
|
|
4
|
+
export const DsAddItemIconButton = ({ onClick, disabled, IconProps, ...iconButtonProps }) => {
|
|
5
|
+
return (_jsx(DsIconButton, { disabled: disabled, onClick: onClick, ...iconButtonProps, children: _jsx(DsRemixIcon, { sx: {
|
|
6
|
+
fontSize: "20px",
|
|
7
|
+
...IconProps?.sx,
|
|
8
|
+
}, ...IconProps }) }));
|
|
9
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { DsTypography } from "../../DsTypography";
|
|
3
|
+
export const DsAddItemCounterText = ({ label, value, disabled, ...textProps }) => {
|
|
4
|
+
const isEmptyCount = value === 0;
|
|
5
|
+
return (_jsx(DsTypography, { variant: isEmptyCount ? "supportBoldTextButton" : "bodyBoldMedium", color: disabled
|
|
6
|
+
? "var(--ds-colour-typoDisabled)"
|
|
7
|
+
: isEmptyCount
|
|
8
|
+
? "var(--ds-colour-typoActionSecondary)"
|
|
9
|
+
: "var(--ds-colour-typoPrimary)", sx: {
|
|
10
|
+
mx: isEmptyCount
|
|
11
|
+
? "var(--ds-spacing-cool)"
|
|
12
|
+
: "var(--ds-spacing-glacial)",
|
|
13
|
+
...textProps.sx,
|
|
14
|
+
}, ...textProps, children: isEmptyCount ? label : value }));
|
|
15
|
+
};
|
|
@@ -2,56 +2,60 @@ import { DsAvatarProps } from './DsAvatar.Types';
|
|
|
2
2
|
export declare const DsAvatarOverrides: {
|
|
3
3
|
MuiAvatar: {
|
|
4
4
|
defaultProps: DsAvatarProps;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
5
|
+
styleOverrides: {
|
|
6
|
+
root: {
|
|
7
|
+
variants: ({
|
|
8
|
+
props: Partial<DsAvatarProps>;
|
|
9
|
+
style: {
|
|
10
|
+
borderWidth: string;
|
|
11
|
+
borderStyle: string;
|
|
12
|
+
borderColor: string;
|
|
13
|
+
color: string;
|
|
14
|
+
backgroundColor: string;
|
|
15
|
+
fontWeight?: undefined;
|
|
16
|
+
fontSize?: undefined;
|
|
17
|
+
lineHeight?: undefined;
|
|
18
|
+
letterSpacing?: undefined;
|
|
19
|
+
width?: undefined;
|
|
20
|
+
height?: undefined;
|
|
21
|
+
'> .MuiIcon-root'?: undefined;
|
|
22
|
+
};
|
|
23
|
+
} | {
|
|
24
|
+
props: Partial<DsAvatarProps>;
|
|
25
|
+
style: {
|
|
26
|
+
color: string;
|
|
27
|
+
backgroundColor: string;
|
|
28
|
+
borderWidth?: undefined;
|
|
29
|
+
borderStyle?: undefined;
|
|
30
|
+
borderColor?: undefined;
|
|
31
|
+
fontWeight?: undefined;
|
|
32
|
+
fontSize?: undefined;
|
|
33
|
+
lineHeight?: undefined;
|
|
34
|
+
letterSpacing?: undefined;
|
|
35
|
+
width?: undefined;
|
|
36
|
+
height?: undefined;
|
|
37
|
+
'> .MuiIcon-root'?: undefined;
|
|
38
|
+
};
|
|
39
|
+
} | {
|
|
40
|
+
props: Partial<DsAvatarProps>;
|
|
41
|
+
style: {
|
|
42
|
+
fontWeight: string;
|
|
43
|
+
fontSize: string;
|
|
44
|
+
lineHeight: string;
|
|
45
|
+
letterSpacing: string;
|
|
46
|
+
width: string;
|
|
47
|
+
height: string;
|
|
48
|
+
'> .MuiIcon-root': {
|
|
49
|
+
fontSize: string;
|
|
50
|
+
};
|
|
51
|
+
borderWidth?: undefined;
|
|
52
|
+
borderStyle?: undefined;
|
|
53
|
+
borderColor?: undefined;
|
|
54
|
+
color?: undefined;
|
|
55
|
+
backgroundColor?: undefined;
|
|
56
|
+
};
|
|
57
|
+
})[];
|
|
20
58
|
};
|
|
21
|
-
}
|
|
22
|
-
props: Partial<DsAvatarProps>;
|
|
23
|
-
style: {
|
|
24
|
-
color: string;
|
|
25
|
-
backgroundColor: string;
|
|
26
|
-
borderWidth?: undefined;
|
|
27
|
-
borderStyle?: undefined;
|
|
28
|
-
borderColor?: undefined;
|
|
29
|
-
fontWeight?: undefined;
|
|
30
|
-
fontSize?: undefined;
|
|
31
|
-
lineHeight?: undefined;
|
|
32
|
-
letterSpacing?: undefined;
|
|
33
|
-
width?: undefined;
|
|
34
|
-
height?: undefined;
|
|
35
|
-
'> .MuiIcon-root'?: undefined;
|
|
36
|
-
};
|
|
37
|
-
} | {
|
|
38
|
-
props: Partial<DsAvatarProps>;
|
|
39
|
-
style: {
|
|
40
|
-
fontWeight: string;
|
|
41
|
-
fontSize: string;
|
|
42
|
-
lineHeight: string;
|
|
43
|
-
letterSpacing: string;
|
|
44
|
-
width: string;
|
|
45
|
-
height: string;
|
|
46
|
-
'> .MuiIcon-root': {
|
|
47
|
-
fontSize: string;
|
|
48
|
-
};
|
|
49
|
-
borderWidth?: undefined;
|
|
50
|
-
borderStyle?: undefined;
|
|
51
|
-
borderColor?: undefined;
|
|
52
|
-
color?: undefined;
|
|
53
|
-
backgroundColor?: undefined;
|
|
54
|
-
};
|
|
55
|
-
})[];
|
|
59
|
+
};
|
|
56
60
|
};
|
|
57
61
|
};
|
|
@@ -2,110 +2,114 @@ import { DsAvatarDefaultProps } from './DsAvatar.Types';
|
|
|
2
2
|
export const DsAvatarOverrides = {
|
|
3
3
|
MuiAvatar: {
|
|
4
4
|
defaultProps: DsAvatarDefaultProps,
|
|
5
|
-
|
|
6
|
-
{
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
5
|
+
styleOverrides: {
|
|
6
|
+
root: {
|
|
7
|
+
variants: [
|
|
8
|
+
{
|
|
9
|
+
props: { 'ds-variant': 'text' },
|
|
10
|
+
style: {
|
|
11
|
+
borderWidth: '1px',
|
|
12
|
+
borderStyle: 'solid',
|
|
13
|
+
borderColor: 'var(--ds-colour-strokeDefault)',
|
|
14
|
+
color: 'var(--ds-colour-typoPrimary)',
|
|
15
|
+
backgroundColor: 'var(--ds-colour-surfaceSecondary)'
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
props: { 'ds-variant': 'icon' },
|
|
20
|
+
style: {
|
|
21
|
+
color: 'var(--ds-colour-iconDefault)',
|
|
22
|
+
backgroundColor: 'transparent'
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
props: { 'ds-size': 'S' },
|
|
27
|
+
style: {
|
|
28
|
+
fontWeight: 'var(--ds-typo-bodyRegularSmall-fontWeight)',
|
|
29
|
+
fontSize: 'var(--ds-typo-bodyRegularSmall-fontSize)',
|
|
30
|
+
lineHeight: 'var(--ds-typo-bodyRegularSmall-lineHeight)',
|
|
31
|
+
letterSpacing: 'var(--ds-typo-bodyRegularSmall-letterSpacing)',
|
|
32
|
+
width: 'var(--ds-rules-avatarSSize)',
|
|
33
|
+
height: 'var(--ds-rules-avatarSSize)',
|
|
34
|
+
'> .MuiIcon-root': {
|
|
35
|
+
fontSize: 'var(--ds-rules-avatarSSize)'
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
props: { 'ds-size': 'M' },
|
|
41
|
+
style: {
|
|
42
|
+
fontWeight: 'var(--ds-typo-bodyRegularMedium-fontWeight)',
|
|
43
|
+
fontSize: 'var(--ds-typo-bodyRegularMedium-fontSize)',
|
|
44
|
+
lineHeight: 'var(--ds-typo-bodyRegularMedium-lineHeight)',
|
|
45
|
+
letterSpacing: 'var(--ds-typo-bodyRegularMedium-letterSpacing)',
|
|
46
|
+
width: 'var(--ds-rules-avatarMSize)',
|
|
47
|
+
height: 'var(--ds-rules-avatarMSize)',
|
|
48
|
+
'> .MuiIcon-root': {
|
|
49
|
+
fontSize: 'var(--ds-rules-avatarMSize)'
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
props: { 'ds-size': 'L' },
|
|
55
|
+
style: {
|
|
56
|
+
fontWeight: 'var(--ds-typo-bodyRegularLarge-fontWeight)',
|
|
57
|
+
fontSize: 'var(--ds-typo-bodyRegularLarge-fontSize)',
|
|
58
|
+
lineHeight: 'var(--ds-typo-bodyRegularLarge-lineHeight)',
|
|
59
|
+
letterSpacing: 'var(--ds-typo-bodyRegularLarge-letterSpacing)',
|
|
60
|
+
width: 'var(--ds-rules-avatarLSize)',
|
|
61
|
+
height: 'var(--ds-rules-avatarLSize)',
|
|
62
|
+
'> .MuiIcon-root': {
|
|
63
|
+
fontSize: 'var(--ds-rules-avatarLSize)'
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
props: { 'ds-size': 'XL' },
|
|
69
|
+
style: {
|
|
70
|
+
fontWeight: 'var(--ds-typo-headingBoldMedium-fontWeight)',
|
|
71
|
+
fontSize: 'var(--ds-typo-headingBoldMedium-fontSize)',
|
|
72
|
+
lineHeight: 'var(--ds-typo-headingBoldMedium-lineHeight)',
|
|
73
|
+
letterSpacing: 'var(--ds-typo-headingBoldMedium-letterSpacing)',
|
|
74
|
+
width: 'var(--ds-rules-avatarXLSize)',
|
|
75
|
+
height: 'var(--ds-rules-avatarXLSize)',
|
|
76
|
+
'> .MuiIcon-root': {
|
|
77
|
+
fontSize: 'var(--ds-rules-avatarXLSize)'
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
props: { 'ds-size': 'XXL' },
|
|
83
|
+
style: {
|
|
84
|
+
fontWeight: 'var(--ds-typo-headingBoldLarge-fontWeight)',
|
|
85
|
+
fontSize: 'var(--ds-typo-headingBoldLarge-fontSize)',
|
|
86
|
+
lineHeight: 'var(--ds-typo-headingBoldLarge-lineHeight)',
|
|
87
|
+
letterSpacing: 'var(--ds-typo-headingBoldLarge-letterSpacing)',
|
|
88
|
+
width: 'var(--ds-rules-avatarXXLSize)',
|
|
89
|
+
height: 'var(--ds-rules-avatarXXLSize)',
|
|
90
|
+
'> .MuiIcon-root': {
|
|
91
|
+
fontSize: 'var(--ds-rules-avatarXXLSize)'
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
props: {
|
|
97
|
+
'ds-size': '3XL'
|
|
98
|
+
},
|
|
99
|
+
style: {
|
|
100
|
+
fontWeight: 'var(--ds-typo-headingBoldExtraLarge-fontWeight)',
|
|
101
|
+
fontSize: 'var(--ds-typo-headingBoldExtraLarge-fontSize)',
|
|
102
|
+
lineHeight: 'var(--ds-typo-headingBoldExtraLarge-lineHeight)',
|
|
103
|
+
letterSpacing: 'var(--ds-typo-headingBoldExtraLarge-letterSpacing)',
|
|
104
|
+
width: 'var(--ds-rules-avatar3XLSize)',
|
|
105
|
+
height: 'var(--ds-rules-avatar3XLSize)',
|
|
106
|
+
'> .MuiIcon-root': {
|
|
107
|
+
fontSize: 'var(--ds-rules-avatar3XLSize)'
|
|
108
|
+
}
|
|
109
|
+
}
|
|
34
110
|
}
|
|
35
|
-
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
props: { 'ds-size': 'M' },
|
|
39
|
-
style: {
|
|
40
|
-
fontWeight: 'var(--ds-typo-bodyRegularMedium-fontWeight)',
|
|
41
|
-
fontSize: 'var(--ds-typo-bodyRegularMedium-fontSize)',
|
|
42
|
-
lineHeight: 'var(--ds-typo-bodyRegularMedium-lineHeight)',
|
|
43
|
-
letterSpacing: 'var(--ds-typo-bodyRegularMedium-letterSpacing)',
|
|
44
|
-
width: 'var(--ds-rules-avatarMSize)',
|
|
45
|
-
height: 'var(--ds-rules-avatarMSize)',
|
|
46
|
-
'> .MuiIcon-root': {
|
|
47
|
-
fontSize: 'var(--ds-rules-avatarMSize)'
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
props: { 'ds-size': 'L' },
|
|
53
|
-
style: {
|
|
54
|
-
fontWeight: 'var(--ds-typo-bodyRegularLarge-fontWeight)',
|
|
55
|
-
fontSize: 'var(--ds-typo-bodyRegularLarge-fontSize)',
|
|
56
|
-
lineHeight: 'var(--ds-typo-bodyRegularLarge-lineHeight)',
|
|
57
|
-
letterSpacing: 'var(--ds-typo-bodyRegularLarge-letterSpacing)',
|
|
58
|
-
width: 'var(--ds-rules-avatarLSize)',
|
|
59
|
-
height: 'var(--ds-rules-avatarLSize)',
|
|
60
|
-
'> .MuiIcon-root': {
|
|
61
|
-
fontSize: 'var(--ds-rules-avatarLSize)'
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
props: { 'ds-size': 'XL' },
|
|
67
|
-
style: {
|
|
68
|
-
fontWeight: 'var(--ds-typo-headingBoldMedium-fontWeight)',
|
|
69
|
-
fontSize: 'var(--ds-typo-headingBoldMedium-fontSize)',
|
|
70
|
-
lineHeight: 'var(--ds-typo-headingBoldMedium-lineHeight)',
|
|
71
|
-
letterSpacing: 'var(--ds-typo-headingBoldMedium-letterSpacing)',
|
|
72
|
-
width: 'var(--ds-rules-avatarXLSize)',
|
|
73
|
-
height: 'var(--ds-rules-avatarXLSize)',
|
|
74
|
-
'> .MuiIcon-root': {
|
|
75
|
-
fontSize: 'var(--ds-rules-avatarXLSize)'
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
props: { 'ds-size': 'XXL' },
|
|
81
|
-
style: {
|
|
82
|
-
fontWeight: 'var(--ds-typo-headingBoldLarge-fontWeight)',
|
|
83
|
-
fontSize: 'var(--ds-typo-headingBoldLarge-fontSize)',
|
|
84
|
-
lineHeight: 'var(--ds-typo-headingBoldLarge-lineHeight)',
|
|
85
|
-
letterSpacing: 'var(--ds-typo-headingBoldLarge-letterSpacing)',
|
|
86
|
-
width: 'var(--ds-rules-avatarXXLSize)',
|
|
87
|
-
height: 'var(--ds-rules-avatarXXLSize)',
|
|
88
|
-
'> .MuiIcon-root': {
|
|
89
|
-
fontSize: 'var(--ds-rules-avatarXXLSize)'
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
props: {
|
|
95
|
-
'ds-size': '3XL'
|
|
96
|
-
},
|
|
97
|
-
style: {
|
|
98
|
-
fontWeight: 'var(--ds-typo-headingBoldExtraLarge-fontWeight)',
|
|
99
|
-
fontSize: 'var(--ds-typo-headingBoldExtraLarge-fontSize)',
|
|
100
|
-
lineHeight: 'var(--ds-typo-headingBoldExtraLarge-lineHeight)',
|
|
101
|
-
letterSpacing: 'var(--ds-typo-headingBoldExtraLarge-letterSpacing)',
|
|
102
|
-
width: 'var(--ds-rules-avatar3XLSize)',
|
|
103
|
-
height: 'var(--ds-rules-avatar3XLSize)',
|
|
104
|
-
'> .MuiIcon-root': {
|
|
105
|
-
fontSize: 'var(--ds-rules-avatar3XLSize)'
|
|
106
|
-
}
|
|
107
|
-
}
|
|
111
|
+
]
|
|
108
112
|
}
|
|
109
|
-
|
|
113
|
+
}
|
|
110
114
|
}
|
|
111
115
|
};
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { DsBadgeProps } from './DsBadge.Types';
|
|
2
|
+
export declare const DsBadge: import("react").ForwardRefExoticComponent<Omit<DsBadgeProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -1 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import Badge from '@mui/material/Badge';
|
|
4
|
+
import { useThemeProps } from '@mui/system';
|
|
5
|
+
export const DsBadge = forwardRef((inProps, ref) => {
|
|
6
|
+
const props = useThemeProps({
|
|
7
|
+
props: inProps,
|
|
8
|
+
name: 'MuiBadge'
|
|
9
|
+
});
|
|
10
|
+
return _jsx(Badge, { ref: ref, ...props });
|
|
11
|
+
});
|