@lunit/design-system 1.0.0-a.1 → 1.0.0-a.2
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/cjs/components/Alert/index.js +2 -0
- package/dist/cjs/components/Alert/index.js.map +1 -0
- package/dist/cjs/components/Button/index.js +2 -0
- package/dist/cjs/components/Button/index.js.map +1 -0
- package/dist/cjs/components/Checkbox/index.js +2 -0
- package/dist/cjs/components/Checkbox/index.js.map +1 -0
- package/dist/cjs/components/Chip/index.js +2 -0
- package/dist/cjs/components/Chip/index.js.map +1 -0
- package/dist/cjs/components/DataTable/index.js +2 -0
- package/dist/cjs/components/DataTable/index.js.map +1 -0
- package/dist/cjs/components/DatePicker/index.js +2 -0
- package/dist/cjs/components/DatePicker/index.js.map +1 -0
- package/dist/cjs/components/Dropdown/index.js +2 -0
- package/dist/cjs/components/Dropdown/index.js.map +1 -0
- package/dist/cjs/components/FormLabel/index.js +2 -0
- package/dist/cjs/components/FormLabel/index.js.map +1 -0
- package/dist/cjs/components/Modal/index.js +2 -0
- package/dist/cjs/components/Modal/index.js.map +1 -0
- package/dist/cjs/components/Radio/index.js +2 -0
- package/dist/cjs/components/Radio/index.js.map +1 -0
- package/dist/cjs/components/RadioGroup/index.js +2 -0
- package/dist/cjs/components/RadioGroup/index.js.map +1 -0
- package/dist/cjs/components/TextField/index.js +2 -0
- package/dist/cjs/components/TextField/index.js.map +1 -0
- package/dist/cjs/components/Toggle/index.js +2 -0
- package/dist/cjs/components/Toggle/index.js.map +1 -0
- package/dist/cjs/components/ToggleButton/index.js +2 -0
- package/dist/cjs/components/ToggleButton/index.js.map +1 -0
- package/dist/cjs/components/Tooltip/index.js +2 -0
- package/dist/cjs/components/Tooltip/index.js.map +1 -0
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/components/Alert/Alert.js +7 -0
- package/dist/components/Alert/Alert.js.map +1 -0
- package/dist/components/Alert/index.js +1 -1
- package/dist/components/Alert/index.js.map +1 -1
- package/dist/components/Button/Button.js +9 -0
- package/dist/components/Button/Button.js.map +1 -0
- package/dist/components/Button/Button.styled.js +170 -0
- package/dist/components/Button/Button.styled.js.map +1 -0
- package/dist/components/Button/Button.types.js +2 -0
- package/dist/components/Button/Button.types.js.map +1 -0
- package/dist/components/Button/const.js +3 -0
- package/dist/components/Button/const.js.map +1 -0
- package/dist/components/Button/index.js +1 -1
- package/dist/components/Button/index.js.map +1 -1
- package/dist/components/Button/utils/getButtonPaddingBySizeAndKind.js +23 -0
- package/dist/components/Button/utils/getButtonPaddingBySizeAndKind.js.map +1 -0
- package/dist/components/Button/utils/getIconButtonPaddingBySizeAndKind.js +23 -0
- package/dist/components/Button/utils/getIconButtonPaddingBySizeAndKind.js.map +1 -0
- package/dist/components/Checkbox/Checkbox.js +49 -0
- package/dist/components/Checkbox/Checkbox.js.map +1 -0
- package/dist/components/Checkbox/index.js +1 -1
- package/dist/components/Checkbox/index.js.map +1 -1
- package/dist/components/Chip/Chip.js +70 -0
- package/dist/components/Chip/Chip.js.map +1 -0
- package/dist/components/Chip/Chip.styled.js +143 -0
- package/dist/components/Chip/Chip.styled.js.map +1 -0
- package/dist/components/Chip/Chip.types.js +2 -0
- package/dist/components/Chip/Chip.types.js.map +1 -0
- package/dist/components/Chip/consts.js +8 -0
- package/dist/components/Chip/consts.js.map +1 -0
- package/dist/components/Chip/index.js +1 -1
- package/dist/components/Chip/index.js.map +1 -1
- package/dist/components/DataTable/DataTable.js +7 -0
- package/dist/components/DataTable/DataTable.js.map +1 -0
- package/dist/components/DataTable/index.js +1 -1
- package/dist/components/DataTable/index.js.map +1 -1
- package/dist/components/DatePicker/DatePicker.js +7 -0
- package/dist/components/DatePicker/DatePicker.js.map +1 -0
- package/dist/components/DatePicker/index.js +1 -1
- package/dist/components/DatePicker/index.js.map +1 -1
- package/dist/components/Dropdown/Dropdown.js +7 -0
- package/dist/components/Dropdown/Dropdown.js.map +1 -0
- package/dist/components/Dropdown/index.js +1 -1
- package/dist/components/Dropdown/index.js.map +1 -1
- package/dist/components/FormLabel/FormLabel.js +7 -0
- package/dist/components/FormLabel/FormLabel.js.map +1 -0
- package/dist/components/FormLabel/FormLabel.styled.js +8 -0
- package/dist/components/FormLabel/FormLabel.styled.js.map +1 -0
- package/dist/components/FormLabel/index.js +1 -1
- package/dist/components/FormLabel/index.js.map +1 -1
- package/dist/components/Modal/Modal.js +7 -0
- package/dist/components/Modal/Modal.js.map +1 -0
- package/dist/components/Modal/index.js +1 -1
- package/dist/components/Modal/index.js.map +1 -1
- package/dist/components/Radio/Radio.js +43 -0
- package/dist/components/Radio/Radio.js.map +1 -0
- package/dist/components/Radio/index.js +1 -1
- package/dist/components/Radio/index.js.map +1 -1
- package/dist/components/RadioGroup/index.js +2 -1
- package/dist/components/RadioGroup/index.js.map +1 -1
- package/dist/components/TextField/TextField.js +7 -0
- package/dist/components/TextField/TextField.js.map +1 -0
- package/dist/components/TextField/index.js +1 -1
- package/dist/components/TextField/index.js.map +1 -1
- package/dist/components/Toggle/Toggle.js +13 -0
- package/dist/components/Toggle/Toggle.js.map +1 -0
- package/dist/components/Toggle/Toggle.styled.js +155 -0
- package/dist/components/Toggle/Toggle.styled.js.map +1 -0
- package/dist/components/Toggle/Toggle.types.js +2 -0
- package/dist/components/Toggle/Toggle.types.js.map +1 -0
- package/dist/components/Toggle/index.js +1 -1
- package/dist/components/Toggle/index.js.map +1 -1
- package/dist/components/ToggleButton/ToggleButton.js +12 -0
- package/dist/components/ToggleButton/ToggleButton.js.map +1 -0
- package/dist/components/ToggleButton/ToggleButton.styled.js +35 -0
- package/dist/components/ToggleButton/ToggleButton.styled.js.map +1 -0
- package/dist/components/ToggleButton/ToggleButton.types.js +2 -0
- package/dist/components/ToggleButton/ToggleButton.types.js.map +1 -0
- package/dist/components/ToggleButton/index.js +1 -1
- package/dist/components/ToggleButton/index.js.map +1 -1
- package/dist/components/ToggleButtonGroup/ToggleButtonGroup.js +7 -0
- package/dist/components/ToggleButtonGroup/ToggleButtonGroup.js.map +1 -0
- package/dist/components/ToggleButtonGroup/index.js +2 -0
- package/dist/components/ToggleButtonGroup/index.js.map +1 -0
- package/dist/components/Tooltip/Tooltip.js +7 -0
- package/dist/components/Tooltip/Tooltip.js.map +1 -0
- package/dist/components/Tooltip/index.js +1 -1
- package/dist/components/Tooltip/index.js.map +1 -1
- package/dist/components/index.js +7 -0
- package/dist/components/index.js.map +1 -0
- package/dist/foundation/Elevation/index.js +66 -0
- package/dist/foundation/Elevation/index.js.map +1 -0
- package/dist/foundation/Elevation/utils.js +9 -0
- package/dist/foundation/Elevation/utils.js.map +1 -0
- package/dist/foundation/Typography/index.js +62 -0
- package/dist/foundation/Typography/index.js.map +1 -0
- package/dist/foundation/Typography/tokens.js +155 -0
- package/dist/foundation/Typography/tokens.js.map +1 -0
- package/dist/foundation/colors/base/blue.js +26 -0
- package/dist/foundation/colors/base/blue.js.map +1 -0
- package/dist/foundation/colors/base/green.js +26 -0
- package/dist/foundation/colors/base/green.js.map +1 -0
- package/dist/foundation/colors/base/grey.js +36 -0
- package/dist/foundation/colors/base/grey.js.map +1 -0
- package/dist/foundation/colors/base/index.js +12 -0
- package/dist/foundation/colors/base/index.js.map +1 -0
- package/dist/foundation/colors/base/lunitGreen.js +26 -0
- package/dist/foundation/colors/base/lunitGreen.js.map +1 -0
- package/dist/foundation/colors/base/lunitTeal.js +26 -0
- package/dist/foundation/colors/base/lunitTeal.js.map +1 -0
- package/dist/foundation/colors/base/magenta.js +26 -0
- package/dist/foundation/colors/base/magenta.js.map +1 -0
- package/dist/foundation/colors/base/opacity.js +7 -0
- package/dist/foundation/colors/base/opacity.js.map +1 -0
- package/dist/foundation/colors/base/orange.js +26 -0
- package/dist/foundation/colors/base/orange.js.map +1 -0
- package/dist/foundation/colors/base/purple.js +26 -0
- package/dist/foundation/colors/base/purple.js.map +1 -0
- package/dist/foundation/colors/base/red.js +26 -0
- package/dist/foundation/colors/base/red.js.map +1 -0
- package/dist/foundation/colors/base/yellow.js +26 -0
- package/dist/foundation/colors/base/yellow.js.map +1 -0
- package/dist/foundation/colors/index.js +188 -0
- package/dist/foundation/colors/index.js.map +1 -0
- package/dist/foundation/colors/token/component.js +449 -0
- package/dist/foundation/colors/token/component.js.map +1 -0
- package/dist/foundation/colors/token/core.js +199 -0
- package/dist/foundation/colors/token/core.js.map +1 -0
- package/dist/foundation/colors/token/index.js +3 -0
- package/dist/foundation/colors/token/index.js.map +1 -0
- package/dist/foundation/colors/token/types.js +2 -0
- package/dist/foundation/colors/token/types.js.map +1 -0
- package/dist/foundation/colors/types.js +2 -0
- package/dist/foundation/colors/types.js.map +1 -0
- package/dist/foundation/index.js +13 -0
- package/dist/foundation/index.js.map +1 -0
- package/dist/foundation/spacing.js +2 -0
- package/dist/foundation/spacing.js.map +1 -0
- package/dist/index.js +16 -1
- package/dist/index.js.map +1 -1
- package/dist/theme.js +34 -0
- package/dist/theme.js.map +1 -0
- package/dist/types/components/Chip/Chip.styled.d.ts +79 -0
- package/package.json +19 -10
- package/src/components/Alert/Alert.tsx +9 -0
- package/src/components/Alert/index.ts +1 -0
- package/src/components/Button/Button.styled.ts +220 -0
- package/src/components/Button/Button.tsx +54 -0
- package/src/components/Button/Button.types.ts +25 -0
- package/src/components/Button/const.ts +2 -0
- package/src/components/Button/index.ts +1 -0
- package/src/components/Button/utils/getButtonPaddingBySizeAndKind.ts +35 -0
- package/src/components/Button/utils/getIconButtonPaddingBySizeAndKind.ts +38 -0
- package/src/components/Checkbox/Checkbox.tsx +67 -0
- package/src/components/Checkbox/index.ts +1 -0
- package/src/components/Chip/Chip.styled.ts +162 -0
- package/src/components/Chip/Chip.tsx +132 -0
- package/src/components/Chip/Chip.types.ts +56 -0
- package/src/components/Chip/consts.ts +7 -0
- package/src/components/Chip/index.ts +1 -0
- package/src/components/DataTable/DataTable.tsx +8 -0
- package/src/components/DataTable/index.ts +1 -0
- package/src/components/DatePicker/DatePicker.tsx +8 -0
- package/src/components/DatePicker/index.ts +1 -0
- package/src/components/Dropdown/Dropdown.tsx +11 -0
- package/src/components/Dropdown/index.ts +1 -0
- package/src/components/FormLabel/FormLabel.styled.ts +8 -0
- package/src/components/FormLabel/FormLabel.tsx +9 -0
- package/src/components/FormLabel/index.ts +1 -0
- package/src/components/Modal/Modal.tsx +8 -0
- package/src/components/Modal/index.ts +1 -0
- package/src/components/Radio/Radio.tsx +58 -0
- package/src/components/Radio/index.ts +1 -0
- package/src/components/RadioGroup/index.ts +2 -0
- package/src/components/TextField/TextField.tsx +8 -0
- package/src/components/TextField/index.ts +1 -0
- package/src/components/Toggle/Toggle.styled.ts +162 -0
- package/src/components/Toggle/Toggle.tsx +18 -0
- package/src/components/Toggle/Toggle.types.ts +14 -0
- package/src/components/Toggle/index.ts +1 -0
- package/src/components/ToggleButton/ToggleButton.styled.ts +58 -0
- package/src/components/ToggleButton/ToggleButton.tsx +89 -0
- package/src/components/ToggleButton/ToggleButton.types.ts +28 -0
- package/src/components/ToggleButton/index.ts +1 -0
- package/src/components/ToggleButtonGroup/ToggleButtonGroup.tsx +13 -0
- package/src/components/ToggleButtonGroup/index.tsx +1 -0
- package/src/components/Tooltip/Tooltip.tsx +9 -0
- package/src/components/Tooltip/index.ts +1 -0
- package/src/components/index.ts +9 -0
- package/src/foundation/Elevation/index.ts +72 -0
- package/src/foundation/Elevation/utils.ts +11 -0
- package/src/foundation/Typography/index.ts +96 -0
- package/src/foundation/Typography/tokens.ts +162 -0
- package/src/foundation/colors/base/blue.ts +27 -0
- package/src/foundation/colors/base/green.ts +27 -0
- package/src/foundation/colors/base/grey.ts +36 -0
- package/src/foundation/colors/base/index.ts +11 -0
- package/src/foundation/colors/base/lunitGreen.ts +27 -0
- package/src/foundation/colors/base/lunitTeal.ts +27 -0
- package/src/foundation/colors/base/magenta.ts +27 -0
- package/src/foundation/colors/base/opacity.ts +6 -0
- package/src/foundation/colors/base/orange.ts +27 -0
- package/src/foundation/colors/base/purple.ts +27 -0
- package/src/foundation/colors/base/red.ts +27 -0
- package/src/foundation/colors/base/yellow.ts +27 -0
- package/src/foundation/colors/index.ts +235 -0
- package/src/foundation/colors/token/component.ts +456 -0
- package/src/foundation/colors/token/core.ts +204 -0
- package/src/foundation/colors/token/index.ts +2 -0
- package/src/foundation/colors/token/types.ts +8 -0
- package/src/foundation/colors/types.ts +85 -0
- package/src/foundation/index.ts +25 -0
- package/src/foundation/spacing.ts +3 -0
- package/src/index.ts +17 -0
- package/src/stories/components/Alert/Alert.stories.tsx +13 -0
- package/src/stories/components/Button/BasicButton.stories.tsx +177 -0
- package/src/stories/components/Button/IconButton.stories.tsx +128 -0
- package/src/stories/components/Button/Kind.stories.tsx +514 -0
- package/src/stories/components/Chip/Chip.stories.tsx +196 -0
- package/src/stories/components/DataTable/DataTable.stories.tsx +13 -0
- package/src/stories/components/DatePicker/DatePicker.stories.tsx +13 -0
- package/src/stories/components/Dropdown/Dropdown.stories.tsx +15 -0
- package/src/stories/components/Modal/Modal.stories.tsx +13 -0
- package/src/stories/components/SelectControl/Checkbox.stories.tsx +248 -0
- package/src/stories/components/SelectControl/RadioGroup.stories.tsx +67 -0
- package/src/stories/components/SelectControl/RadioStatus.stories.tsx +91 -0
- package/src/stories/components/SelectControl/Toggle.stories.tsx +429 -0
- package/src/stories/components/TextField/TextField.stories.tsx +13 -0
- package/src/stories/components/ToggleButton/Basic.stories.tsx +342 -0
- package/src/stories/components/ToggleButton/Group.stories.tsx +221 -0
- package/src/stories/components/ToggleButton/ToggleButtonKind.stories.tsx +698 -0
- package/src/stories/components/ToggleButton/WithIcon.stories.tsx +293 -0
- package/src/stories/components/Tooltip/Tooltip.stories.tsx +13 -0
- package/src/stories/foundation/Elevation/Elevation.stories.tsx +264 -0
- package/src/stories/foundation/Elevation/styled.ts +12 -0
- package/src/stories/foundation/Typography/Typography.stories.mdx +71 -0
- package/src/stories/foundation/Typography/Typography.stories.tsx +91 -0
- package/src/stories/foundation/Typography/TypographyGroup.tsx +71 -0
- package/src/stories/foundation/Typography/const.ts +25 -0
- package/src/stories/foundation/colors/Colors.stories.tsx +64 -0
- package/src/stories/foundation/colors/Token.inComponent.stories.tsx +167 -0
- package/src/stories/foundation/colors/Token.stories.tsx +190 -0
- package/src/stories/foundation/colors/styled.ts +39 -0
- package/src/theme.ts +41 -0
- package/src/types.d.ts +4 -0
- package/tsconfig.build.json +2 -0
- package/dist/components/Chip/Chip.styled.d.ts +0 -41
- package/dist/components/HelloWorld/HelloWorld.d.ts +0 -28
- package/webpack.config.js +0 -51
- /package/dist/{components → types/components}/Alert/Alert.d.ts +0 -0
- /package/dist/{components → types/components}/Alert/index.d.ts +0 -0
- /package/dist/{components → types/components}/Button/Button.d.ts +0 -0
- /package/dist/{components → types/components}/Button/Button.styled.d.ts +0 -0
- /package/dist/{components → types/components}/Button/Button.types.d.ts +0 -0
- /package/dist/{components → types/components}/Button/const.d.ts +0 -0
- /package/dist/{components → types/components}/Button/index.d.ts +0 -0
- /package/dist/{components → types/components}/Button/utils/getButtonPaddingBySizeAndKind.d.ts +0 -0
- /package/dist/{components → types/components}/Button/utils/getIconButtonPaddingBySizeAndKind.d.ts +0 -0
- /package/dist/{components → types/components}/Checkbox/Checkbox.d.ts +0 -0
- /package/dist/{components → types/components}/Checkbox/index.d.ts +0 -0
- /package/dist/{components → types/components}/Chip/Chip.d.ts +0 -0
- /package/dist/{components → types/components}/Chip/Chip.types.d.ts +0 -0
- /package/dist/{components → types/components}/Chip/consts.d.ts +0 -0
- /package/dist/{components → types/components}/Chip/index.d.ts +0 -0
- /package/dist/{components → types/components}/DataTable/DataTable.d.ts +0 -0
- /package/dist/{components → types/components}/DataTable/index.d.ts +0 -0
- /package/dist/{components → types/components}/DatePicker/DatePicker.d.ts +0 -0
- /package/dist/{components → types/components}/DatePicker/index.d.ts +0 -0
- /package/dist/{components → types/components}/Dropdown/Dropdown.d.ts +0 -0
- /package/dist/{components → types/components}/Dropdown/index.d.ts +0 -0
- /package/dist/{components → types/components}/FormLabel/FormLabel.d.ts +0 -0
- /package/dist/{components → types/components}/FormLabel/FormLabel.styled.d.ts +0 -0
- /package/dist/{components → types/components}/FormLabel/index.d.ts +0 -0
- /package/dist/{components → types/components}/Modal/Modal.d.ts +0 -0
- /package/dist/{components → types/components}/Modal/index.d.ts +0 -0
- /package/dist/{components → types/components}/Radio/Radio.d.ts +0 -0
- /package/dist/{components → types/components}/Radio/index.d.ts +0 -0
- /package/dist/{components → types/components}/RadioGroup/index.d.ts +0 -0
- /package/dist/{components → types/components}/TextField/TextField.d.ts +0 -0
- /package/dist/{components → types/components}/TextField/index.d.ts +0 -0
- /package/dist/{components → types/components}/Toggle/Toggle.d.ts +0 -0
- /package/dist/{components → types/components}/Toggle/Toggle.styled.d.ts +0 -0
- /package/dist/{components → types/components}/Toggle/Toggle.types.d.ts +0 -0
- /package/dist/{components → types/components}/Toggle/index.d.ts +0 -0
- /package/dist/{components → types/components}/ToggleButton/ToggleButton.d.ts +0 -0
- /package/dist/{components → types/components}/ToggleButton/ToggleButton.styled.d.ts +0 -0
- /package/dist/{components → types/components}/ToggleButton/ToggleButton.types.d.ts +0 -0
- /package/dist/{components → types/components}/ToggleButton/index.d.ts +0 -0
- /package/dist/{components → types/components}/ToggleButtonGroup/ToggleButtonGroup.d.ts +0 -0
- /package/dist/{components → types/components}/ToggleButtonGroup/index.d.ts +0 -0
- /package/dist/{components → types/components}/Tooltip/Tooltip.d.ts +0 -0
- /package/dist/{components → types/components}/Tooltip/index.d.ts +0 -0
- /package/dist/{components → types/components}/index.d.ts +0 -0
- /package/dist/{foundation → types/foundation}/Elevation/index.d.ts +0 -0
- /package/dist/{foundation → types/foundation}/Elevation/utils.d.ts +0 -0
- /package/dist/{foundation → types/foundation}/Typography/index.d.ts +0 -0
- /package/dist/{foundation → types/foundation}/Typography/tokens.d.ts +0 -0
- /package/dist/{foundation → types/foundation}/colors/base/blue.d.ts +0 -0
- /package/dist/{foundation → types/foundation}/colors/base/green.d.ts +0 -0
- /package/dist/{foundation → types/foundation}/colors/base/grey.d.ts +0 -0
- /package/dist/{foundation → types/foundation}/colors/base/index.d.ts +0 -0
- /package/dist/{foundation → types/foundation}/colors/base/lunitGreen.d.ts +0 -0
- /package/dist/{foundation → types/foundation}/colors/base/lunitTeal.d.ts +0 -0
- /package/dist/{foundation → types/foundation}/colors/base/magenta.d.ts +0 -0
- /package/dist/{foundation → types/foundation}/colors/base/opacity.d.ts +0 -0
- /package/dist/{foundation → types/foundation}/colors/base/orange.d.ts +0 -0
- /package/dist/{foundation → types/foundation}/colors/base/purple.d.ts +0 -0
- /package/dist/{foundation → types/foundation}/colors/base/red.d.ts +0 -0
- /package/dist/{foundation → types/foundation}/colors/base/yellow.d.ts +0 -0
- /package/dist/{foundation → types/foundation}/colors/index.d.ts +0 -0
- /package/dist/{foundation → types/foundation}/colors/token/component.d.ts +0 -0
- /package/dist/{foundation → types/foundation}/colors/token/core.d.ts +0 -0
- /package/dist/{foundation → types/foundation}/colors/token/index.d.ts +0 -0
- /package/dist/{foundation → types/foundation}/colors/token/types.d.ts +0 -0
- /package/dist/{foundation → types/foundation}/colors/types.d.ts +0 -0
- /package/dist/{foundation → types/foundation}/index.d.ts +0 -0
- /package/dist/{foundation → types/foundation}/spacing.d.ts +0 -0
- /package/dist/{index.d.ts → types/index.d.ts} +0 -0
- /package/dist/{theme.d.ts → types/theme.d.ts} +0 -0
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { Chip as MuiChip, styled } from "@mui/material";
|
|
2
|
+
import { CHIP_COLORS } from "./consts";
|
|
3
|
+
|
|
4
|
+
import type { Theme } from "@mui/material/styles";
|
|
5
|
+
import type {
|
|
6
|
+
ChipColor,
|
|
7
|
+
OutlinedChipProps,
|
|
8
|
+
BaseContainedChipProps,
|
|
9
|
+
} from "./Chip.types";
|
|
10
|
+
|
|
11
|
+
const COMMON_STYLES = {
|
|
12
|
+
"&.MuiChip-root": {
|
|
13
|
+
height: "22px",
|
|
14
|
+
width: "auto",
|
|
15
|
+
minWidth: "22px",
|
|
16
|
+
},
|
|
17
|
+
"&.Mui-disabled": {
|
|
18
|
+
opacity: 1,
|
|
19
|
+
},
|
|
20
|
+
"& .MuiChip-label": {
|
|
21
|
+
display: "flex",
|
|
22
|
+
alignItems: "center",
|
|
23
|
+
textAlign: "center",
|
|
24
|
+
padding: 0,
|
|
25
|
+
marginInline: "8px",
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const getColorToken = (
|
|
30
|
+
token: "text" | "bg",
|
|
31
|
+
theme: Theme,
|
|
32
|
+
color?: ChipColor
|
|
33
|
+
) => {
|
|
34
|
+
if (token === "text") {
|
|
35
|
+
switch (color) {
|
|
36
|
+
case CHIP_COLORS.PRIMARY:
|
|
37
|
+
return theme.palette.token.component.chip_primary_text;
|
|
38
|
+
case CHIP_COLORS.SECONDARY:
|
|
39
|
+
return theme.palette.token.component.chip_secondary_text;
|
|
40
|
+
case CHIP_COLORS.ERROR:
|
|
41
|
+
return theme.palette.token.component.chip_error_text;
|
|
42
|
+
case CHIP_COLORS.WARNING:
|
|
43
|
+
return theme.palette.token.component.chip_warning_text;
|
|
44
|
+
case CHIP_COLORS.SUCCESS:
|
|
45
|
+
return theme.palette.token.component.chip_success_text;
|
|
46
|
+
default:
|
|
47
|
+
return theme.palette.token.component.chip_primary_text;
|
|
48
|
+
}
|
|
49
|
+
} else {
|
|
50
|
+
switch (color) {
|
|
51
|
+
case CHIP_COLORS.PRIMARY:
|
|
52
|
+
return theme.palette.token.component.chip_primary_bg;
|
|
53
|
+
case CHIP_COLORS.SECONDARY:
|
|
54
|
+
return theme.palette.token.component.chip_secondary_bg;
|
|
55
|
+
case CHIP_COLORS.ERROR:
|
|
56
|
+
return theme.palette.token.component.chip_error_bg;
|
|
57
|
+
case CHIP_COLORS.WARNING:
|
|
58
|
+
return theme.palette.token.component.chip_warning_bg;
|
|
59
|
+
case CHIP_COLORS.SUCCESS:
|
|
60
|
+
return theme.palette.token.component.chip_success_bg;
|
|
61
|
+
default:
|
|
62
|
+
return theme.palette.token.component.chip_primary_bg;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export const StyledOutlinedChip = styled(MuiChip, {
|
|
68
|
+
shouldForwardProp: (prop) => !["color"].includes(prop.toString()),
|
|
69
|
+
})<OutlinedChipProps>(({ theme, color }) => ({
|
|
70
|
+
...COMMON_STYLES,
|
|
71
|
+
...theme.typography.caption,
|
|
72
|
+
|
|
73
|
+
color: getColorToken("text", theme, color),
|
|
74
|
+
borderColor: getColorToken("text", theme, color),
|
|
75
|
+
}));
|
|
76
|
+
|
|
77
|
+
export const StyledContainedChipBase = styled(MuiChip, {
|
|
78
|
+
shouldForwardProp: (prop) => !["color"].includes(prop.toString()),
|
|
79
|
+
})<BaseContainedChipProps>(() => ({ theme, color }) => ({
|
|
80
|
+
...COMMON_STYLES,
|
|
81
|
+
...theme.typography.caption,
|
|
82
|
+
|
|
83
|
+
color: theme.palette.token.core.text_normal,
|
|
84
|
+
backgroundColor: getColorToken("bg", theme, color),
|
|
85
|
+
|
|
86
|
+
"& .MuiSvgIcon-root": {
|
|
87
|
+
marginBlock: "3px",
|
|
88
|
+
marginLeft: "3px",
|
|
89
|
+
marginRight: "4px",
|
|
90
|
+
height: "16px",
|
|
91
|
+
width: "16px",
|
|
92
|
+
color: getColorToken("text", theme, color),
|
|
93
|
+
},
|
|
94
|
+
"& .MuiChip-avatar": {
|
|
95
|
+
marginBlock: "3px",
|
|
96
|
+
marginLeft: "4px",
|
|
97
|
+
marginRight: "5px",
|
|
98
|
+
height: "14px",
|
|
99
|
+
width: "14px",
|
|
100
|
+
fontSize: "11px",
|
|
101
|
+
fontWeight: 500,
|
|
102
|
+
lineHeight: "16px",
|
|
103
|
+
display: "flex",
|
|
104
|
+
textAlign: "center",
|
|
105
|
+
alignItems: "center",
|
|
106
|
+
color: getColorToken("bg", theme, color),
|
|
107
|
+
backgroundColor: getColorToken("text", theme, color),
|
|
108
|
+
},
|
|
109
|
+
}));
|
|
110
|
+
|
|
111
|
+
export const StyledContainedChipEnable = styled(StyledContainedChipBase, {
|
|
112
|
+
shouldForwardProp: (prop) => !["color"].includes(prop.toString()),
|
|
113
|
+
})<BaseContainedChipProps>(() => ({ theme, color }) => ({
|
|
114
|
+
/**
|
|
115
|
+
* Setting the z-index of the chip to 0 and the z-index of the pseudo element to -1
|
|
116
|
+
* allows the pseudo element(hover layer) to be rendered between the chip and the chip's children.
|
|
117
|
+
*/
|
|
118
|
+
"&.MuiChip-root": {
|
|
119
|
+
position: "relative",
|
|
120
|
+
left: 0,
|
|
121
|
+
right: 0,
|
|
122
|
+
zIndex: 0,
|
|
123
|
+
},
|
|
124
|
+
"&:hover": {
|
|
125
|
+
backgroundColor: getColorToken("bg", theme, color),
|
|
126
|
+
},
|
|
127
|
+
"&.MuiChip-root:hover::before": {
|
|
128
|
+
position: "absolute",
|
|
129
|
+
zIndex: -1,
|
|
130
|
+
content: '""',
|
|
131
|
+
top: 0,
|
|
132
|
+
left: 0,
|
|
133
|
+
right: 0,
|
|
134
|
+
bottom: 0,
|
|
135
|
+
backgroundColor: theme.palette.token.core.hover,
|
|
136
|
+
borderRadius: "11px",
|
|
137
|
+
},
|
|
138
|
+
}));
|
|
139
|
+
|
|
140
|
+
export const StyledContainedChipDeletable = styled(StyledContainedChipBase, {
|
|
141
|
+
shouldForwardProp: (prop) => !["color"].includes(prop.toString()),
|
|
142
|
+
})<BaseContainedChipProps>(() => ({ theme, color }) => ({
|
|
143
|
+
"& .MuiChip-deleteIcon": {
|
|
144
|
+
marginLeft: "4px",
|
|
145
|
+
marginRight: "3px",
|
|
146
|
+
},
|
|
147
|
+
|
|
148
|
+
"& .delete-icon-hover-layer": {
|
|
149
|
+
position: "absolute",
|
|
150
|
+
zIndex: 1000,
|
|
151
|
+
top: 0,
|
|
152
|
+
left: "auto",
|
|
153
|
+
right: 0,
|
|
154
|
+
bottom: 0,
|
|
155
|
+
opacity: 0,
|
|
156
|
+
color: theme.palette.token.core.hover,
|
|
157
|
+
":hover": {
|
|
158
|
+
cursor: "pointer",
|
|
159
|
+
opacity: 1,
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
}));
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Avatar } from "@mui/material";
|
|
3
|
+
import { Close16 } from "@lunit/design-system-icons";
|
|
4
|
+
import {
|
|
5
|
+
StyledOutlinedChip,
|
|
6
|
+
StyledContainedChipBase,
|
|
7
|
+
StyledContainedChipEnable,
|
|
8
|
+
StyledContainedChipDeletable,
|
|
9
|
+
} from "./Chip.styled";
|
|
10
|
+
|
|
11
|
+
import type {
|
|
12
|
+
OutlinedChipProps,
|
|
13
|
+
ReadOnlyContainedChipProps,
|
|
14
|
+
EnableContainedChipProps,
|
|
15
|
+
DeletableContainedChipProps,
|
|
16
|
+
ChipProps,
|
|
17
|
+
ChipThumbnail,
|
|
18
|
+
} from "./Chip.types";
|
|
19
|
+
|
|
20
|
+
const Chip = (props: ChipProps) => {
|
|
21
|
+
const { kind, onDelete, onClick, ...restProps } = props;
|
|
22
|
+
if (kind === "outlined") return <OutlinedChip {...props} />;
|
|
23
|
+
else if (onClick) return <EnableContainedChip {...props} />;
|
|
24
|
+
else if (onDelete) return <DeletableContainedChip {...props} />;
|
|
25
|
+
|
|
26
|
+
return <ReadOnlyContainedChip {...restProps} />;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const OutlinedChip = (props: OutlinedChipProps) => {
|
|
30
|
+
const { color = "primary", ...restProps } = props;
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<StyledOutlinedChip
|
|
34
|
+
{...restProps}
|
|
35
|
+
variant="outlined"
|
|
36
|
+
disabled
|
|
37
|
+
color={color}
|
|
38
|
+
/>
|
|
39
|
+
);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Conditional styling for contained chip
|
|
44
|
+
*/
|
|
45
|
+
const getAvatar = (thumbnail: ChipThumbnail | undefined) => {
|
|
46
|
+
if (!thumbnail || typeof thumbnail !== "string") return;
|
|
47
|
+
if (thumbnail.length === 0) return <Avatar />;
|
|
48
|
+
return <Avatar>{thumbnail.slice(0, 1).toLocaleUpperCase()}</Avatar>;
|
|
49
|
+
};
|
|
50
|
+
const getIcon = (thumbnail: ChipThumbnail | undefined) => {
|
|
51
|
+
if (thumbnail && typeof thumbnail !== "string") return thumbnail;
|
|
52
|
+
return undefined;
|
|
53
|
+
};
|
|
54
|
+
const getLabelMargin = (
|
|
55
|
+
thumbnail: ChipThumbnail | undefined,
|
|
56
|
+
deletable?: boolean
|
|
57
|
+
) => {
|
|
58
|
+
return {
|
|
59
|
+
marginLeft: thumbnail ? "0px" : "8px",
|
|
60
|
+
marginRight: deletable ? "0px" : "8px",
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const ReadOnlyContainedChip = (props: ReadOnlyContainedChipProps) => {
|
|
65
|
+
const { color = "primary", thumbnail, sx, ...restProps } = props;
|
|
66
|
+
|
|
67
|
+
return (
|
|
68
|
+
<StyledContainedChipBase
|
|
69
|
+
{...restProps}
|
|
70
|
+
disabled
|
|
71
|
+
avatar={getAvatar(thumbnail)}
|
|
72
|
+
icon={getIcon(thumbnail)}
|
|
73
|
+
color={color}
|
|
74
|
+
sx={{
|
|
75
|
+
"& .MuiChip-label": {
|
|
76
|
+
...getLabelMargin(thumbnail),
|
|
77
|
+
},
|
|
78
|
+
...sx,
|
|
79
|
+
}}
|
|
80
|
+
/>
|
|
81
|
+
);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const EnableContainedChip = (props: EnableContainedChipProps) => {
|
|
85
|
+
const { color = "primary", thumbnail, onClick, sx, ...restProps } = props;
|
|
86
|
+
|
|
87
|
+
return (
|
|
88
|
+
<StyledContainedChipEnable
|
|
89
|
+
{...restProps}
|
|
90
|
+
onClick={onClick}
|
|
91
|
+
avatar={getAvatar(thumbnail)}
|
|
92
|
+
icon={getIcon(thumbnail)}
|
|
93
|
+
color={color}
|
|
94
|
+
sx={{
|
|
95
|
+
"& .MuiChip-label": {
|
|
96
|
+
...getLabelMargin(thumbnail),
|
|
97
|
+
},
|
|
98
|
+
}}
|
|
99
|
+
/>
|
|
100
|
+
);
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
const DeleteIconWithHoverLayer = ({ onClick }: { onClick: () => void }) => {
|
|
104
|
+
return (
|
|
105
|
+
<>
|
|
106
|
+
<Close16 />
|
|
107
|
+
<Close16 className="delete-icon-hover-layer" onClick={onClick} />
|
|
108
|
+
</>
|
|
109
|
+
);
|
|
110
|
+
};
|
|
111
|
+
const DeletableContainedChip = (props: DeletableContainedChipProps) => {
|
|
112
|
+
const { color = "primary", thumbnail, onDelete, sx, ...restProps } = props;
|
|
113
|
+
|
|
114
|
+
return (
|
|
115
|
+
<StyledContainedChipDeletable
|
|
116
|
+
{...restProps}
|
|
117
|
+
color={color}
|
|
118
|
+
onDelete={onDelete}
|
|
119
|
+
deleteIcon={<DeleteIconWithHoverLayer onClick={onDelete} />}
|
|
120
|
+
avatar={getAvatar(thumbnail)}
|
|
121
|
+
icon={getIcon(thumbnail)}
|
|
122
|
+
sx={{
|
|
123
|
+
"& .MuiChip-label": {
|
|
124
|
+
...getLabelMargin(thumbnail, Boolean(onDelete)),
|
|
125
|
+
},
|
|
126
|
+
...sx,
|
|
127
|
+
}}
|
|
128
|
+
/>
|
|
129
|
+
);
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
export default Chip;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { CHIP_COLORS } from "./consts";
|
|
2
|
+
|
|
3
|
+
import type { ChipProps as MuiChipProps, SxProps } from "@mui/material";
|
|
4
|
+
|
|
5
|
+
type ColorKeys = keyof typeof CHIP_COLORS;
|
|
6
|
+
export type ChipColor = typeof CHIP_COLORS[ColorKeys];
|
|
7
|
+
export type ChipThumbnail = string | JSX.Element;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Mui Chip's variant is 'kind' in our design system
|
|
11
|
+
*/
|
|
12
|
+
export interface BaseChipProps
|
|
13
|
+
extends Pick<
|
|
14
|
+
MuiChipProps,
|
|
15
|
+
"label" | "sx" | "style" | "classes" | "onDelete"
|
|
16
|
+
> {
|
|
17
|
+
kind?: "outlined" | "contained";
|
|
18
|
+
color?: ChipColor;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface OutlinedChipProps extends BaseChipProps {
|
|
22
|
+
kind?: "outlined";
|
|
23
|
+
onClick?: never;
|
|
24
|
+
onDelete?: never;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface BaseContainedChipProps
|
|
28
|
+
extends BaseChipProps,
|
|
29
|
+
Omit<
|
|
30
|
+
MuiChipProps,
|
|
31
|
+
"color" | "size" | "variant" | "avatar" | "deleteIcon" | "icon"
|
|
32
|
+
> {
|
|
33
|
+
kind?: "contained";
|
|
34
|
+
thumbnail?: ChipThumbnail;
|
|
35
|
+
onClick?: () => void;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface ReadOnlyContainedChipProps extends BaseContainedChipProps {
|
|
39
|
+
onClick?: never;
|
|
40
|
+
onDelete?: never;
|
|
41
|
+
}
|
|
42
|
+
export interface EnableContainedChipProps extends BaseContainedChipProps {
|
|
43
|
+
onClick: () => void;
|
|
44
|
+
onDelete?: never;
|
|
45
|
+
}
|
|
46
|
+
export interface DeletableContainedChipProps extends BaseContainedChipProps {
|
|
47
|
+
onClick?: never;
|
|
48
|
+
onDelete: () => void;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export type ContainedChipProps =
|
|
52
|
+
| EnableContainedChipProps
|
|
53
|
+
| ReadOnlyContainedChipProps
|
|
54
|
+
| DeletableContainedChipProps;
|
|
55
|
+
|
|
56
|
+
export type ChipProps = OutlinedChipProps | ContainedChipProps;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./Chip";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./DataTable";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./DatePicker";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./Dropdown";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { FormControlLabelProps } from "@mui/material";
|
|
3
|
+
import { StyledFormControlLabel } from "./FormLabel.styled";
|
|
4
|
+
|
|
5
|
+
const FormLabel = (props: FormControlLabelProps) => {
|
|
6
|
+
return <StyledFormControlLabel {...props} />;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export default FormLabel;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./FormLabel";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./Modal";
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { styled } from "@mui/material/styles";
|
|
3
|
+
import MuiRadio, { RadioProps } from "@mui/material/Radio";
|
|
4
|
+
|
|
5
|
+
const CustomRadio = styled(MuiRadio)(({ theme }) => ({
|
|
6
|
+
padding: 0,
|
|
7
|
+
"&.Mui-disabled": {
|
|
8
|
+
opacity: 0.38,
|
|
9
|
+
},
|
|
10
|
+
"&.Mui-focusVisible:after": {
|
|
11
|
+
content: '""',
|
|
12
|
+
position: "absolute",
|
|
13
|
+
display: "block",
|
|
14
|
+
width: 24,
|
|
15
|
+
height: 24,
|
|
16
|
+
backgroundColor: theme.palette.token.core.focused,
|
|
17
|
+
maskImage:
|
|
18
|
+
"url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath" +
|
|
19
|
+
" fill-rule='evenodd' clip-rule='evenodd' d='M12 23C18.0751 23 23 18.0751 23 12C23 5.92487 18.0751 1 12 1C5.92487 1 1 5.92487 1 12C1 18.0751 5.92487 23 12 23ZM12 24C18.6274 24 24 18.6274 24 12C24 5.37258 18.6274 0 12 0C5.37258 0 0 " +
|
|
20
|
+
"5.37258 0 12C0 18.6274 5.37258 24 12 24Z' /%3E%3C/svg%3E\")",
|
|
21
|
+
},
|
|
22
|
+
}));
|
|
23
|
+
|
|
24
|
+
const iconSize = {
|
|
25
|
+
width: 20,
|
|
26
|
+
height: 20,
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const DefaultIcon = styled("span")(({ theme }) => ({
|
|
30
|
+
...iconSize,
|
|
31
|
+
backgroundColor: theme.palette.token.component.selectcontrol_off,
|
|
32
|
+
maskImage:
|
|
33
|
+
"url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath" +
|
|
34
|
+
" fill-rule='evenodd' clip-rule='evenodd' d='M10 17.5C14.1421 17.5 17.5 14.1421 17.5 10C17.5 5.85786 14.1421 2.5 10 2.5C5.85786 2.5 2.5 5.85786 2.5 10C2.5 14.1421 5.85786 17.5 " +
|
|
35
|
+
"10 17.5ZM10 19C14.9706 19 19 14.9706 19 10C19 5.02944 14.9706 1 10 1C5.02944 1 1 5.02944 1 10C1 14.9706 5.02944 19 10 19Z' /%3E%3C/svg%3E\")",
|
|
36
|
+
}));
|
|
37
|
+
|
|
38
|
+
const CheckedIcon = styled("span")(({ theme }) => ({
|
|
39
|
+
...iconSize,
|
|
40
|
+
backgroundColor: theme.palette.token.component.selectcontrol_on,
|
|
41
|
+
maskImage:
|
|
42
|
+
"url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath" +
|
|
43
|
+
" fill-rule='evenodd' clip-rule='evenodd' d='M10 15C12.7614 15 15 12.7614 15 10C15 7.23858 12.7614 5 10 5C7.23858 5 5" +
|
|
44
|
+
" 7.23858 5 10C5 12.7614 7.23858 15 10 15ZM10 19C14.9706 19 19 14.9706 19 10C19 5.02944 14.9706 1 10 1C5.02944 1 1 5.02944 1 10C1 14.9706 5.02944 19 10 19Z' /%3E%3C/svg%3E\")",
|
|
45
|
+
}));
|
|
46
|
+
|
|
47
|
+
const Radio = (props: RadioProps) => {
|
|
48
|
+
return (
|
|
49
|
+
<CustomRadio
|
|
50
|
+
disableRipple
|
|
51
|
+
icon={<DefaultIcon />}
|
|
52
|
+
checkedIcon={<CheckedIcon />}
|
|
53
|
+
{...props}
|
|
54
|
+
/>
|
|
55
|
+
);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export default Radio;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./Radio";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./TextField";
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { styled, Switch as MuiSwitch, SwitchProps } from "@mui/material";
|
|
2
|
+
interface ToggleProps extends SwitchProps {
|
|
3
|
+
toggleSize: 'medium' | 'large'
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
const toggleStyles = {
|
|
7
|
+
medium: {
|
|
8
|
+
root: {
|
|
9
|
+
width: 28,
|
|
10
|
+
height: 18,
|
|
11
|
+
borderRadius: 9,
|
|
12
|
+
},
|
|
13
|
+
focus: {
|
|
14
|
+
width: 34,
|
|
15
|
+
height: 24,
|
|
16
|
+
borderRadius: 12,
|
|
17
|
+
},
|
|
18
|
+
switch: {
|
|
19
|
+
transition: "all 100ms ease-in-out",
|
|
20
|
+
},
|
|
21
|
+
switchChecked: {
|
|
22
|
+
transform: 'translateX(10px)',
|
|
23
|
+
},
|
|
24
|
+
thumb: {
|
|
25
|
+
width: 14,
|
|
26
|
+
height: 14,
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
large: {
|
|
30
|
+
root:{
|
|
31
|
+
width: 44,
|
|
32
|
+
height: 24,
|
|
33
|
+
borderRadius: 12,
|
|
34
|
+
},
|
|
35
|
+
focus: {
|
|
36
|
+
width: 50,
|
|
37
|
+
height: 30,
|
|
38
|
+
borderRadius: 14,
|
|
39
|
+
},
|
|
40
|
+
switch: {
|
|
41
|
+
transition: "all 150ms ease-in-out",
|
|
42
|
+
},
|
|
43
|
+
switchChecked: {
|
|
44
|
+
transform: 'translateX(20px)',
|
|
45
|
+
},
|
|
46
|
+
thumb: {
|
|
47
|
+
width: 20,
|
|
48
|
+
height: 20,
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const indeterminateStyles = {
|
|
54
|
+
large: {
|
|
55
|
+
switchChecked: {
|
|
56
|
+
top: 8,
|
|
57
|
+
left: -8,
|
|
58
|
+
},
|
|
59
|
+
track: {
|
|
60
|
+
borderRadius: 12,
|
|
61
|
+
},
|
|
62
|
+
thumb: {
|
|
63
|
+
height: 4,
|
|
64
|
+
width: 16,
|
|
65
|
+
borderRadius: 2,
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
medium: {
|
|
69
|
+
switchChecked: {
|
|
70
|
+
top: 6,
|
|
71
|
+
left: -4,
|
|
72
|
+
},
|
|
73
|
+
track: {
|
|
74
|
+
borderRadius: 12,
|
|
75
|
+
},
|
|
76
|
+
thumb: {
|
|
77
|
+
height: 2,
|
|
78
|
+
width: 12,
|
|
79
|
+
borderRadius: 2,
|
|
80
|
+
},
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export const CommonToggle = styled(MuiSwitch, {
|
|
85
|
+
shouldForwardProp: (props) => props !== 'toggleSize',
|
|
86
|
+
})<ToggleProps>(({ theme, toggleSize, disabled }) => {
|
|
87
|
+
const checkedColor = theme.palette.token.component.selectcontrol_on;
|
|
88
|
+
const uncheckedColor = theme.palette.token.component.selectcontrol_off;
|
|
89
|
+
const handlerColor = theme.palette.token.component.selectcontrol_handler;
|
|
90
|
+
|
|
91
|
+
const toggleStyle = toggleStyles[toggleSize];
|
|
92
|
+
const toggleOpacity = disabled ? 0.38 : 1;
|
|
93
|
+
|
|
94
|
+
return {
|
|
95
|
+
...toggleStyle.root,
|
|
96
|
+
display: 'flex',
|
|
97
|
+
padding: 0,
|
|
98
|
+
overflow: "visible",
|
|
99
|
+
backgroundColor: "transparent",
|
|
100
|
+
opacity: toggleOpacity,
|
|
101
|
+
"& .Mui-focusVisible": {
|
|
102
|
+
// clear default focus style
|
|
103
|
+
boxShadow: "none",
|
|
104
|
+
background: "transparent",
|
|
105
|
+
borderColor: "transparent",
|
|
106
|
+
outline: "none",
|
|
107
|
+
"& + .MuiSwitch-track::after": {
|
|
108
|
+
...toggleStyle.focus,
|
|
109
|
+
content: '""',
|
|
110
|
+
position: "absolute",
|
|
111
|
+
border: `1px solid ${checkedColor}`,
|
|
112
|
+
boxSizing: "border-box",
|
|
113
|
+
top: -3, // border 1px + offset 2px
|
|
114
|
+
left: -3, // border 1px + offset 2px
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
'& .MuiSwitch-track': {
|
|
118
|
+
opacity: 1,
|
|
119
|
+
borderRadius: 12,
|
|
120
|
+
backgroundColor: uncheckedColor,
|
|
121
|
+
},
|
|
122
|
+
'& .MuiSwitch-thumb': {
|
|
123
|
+
...toggleStyle.thumb,
|
|
124
|
+
boxShadow: "0px 0px 1px rgba(0, 0, 0, 0.4)",
|
|
125
|
+
},
|
|
126
|
+
'& .MuiSwitch-switchBase': {
|
|
127
|
+
...toggleStyle.switch,
|
|
128
|
+
padding: 2,
|
|
129
|
+
opacity: 1,
|
|
130
|
+
'&.Mui-checked': {
|
|
131
|
+
...toggleStyle.switchChecked,
|
|
132
|
+
color: handlerColor,
|
|
133
|
+
'& + .MuiSwitch-track': {
|
|
134
|
+
opacity: 1,
|
|
135
|
+
backgroundColor: checkedColor,
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
'& .Mui-disabled + .MuiSwitch-track': {
|
|
140
|
+
opacity: 1,
|
|
141
|
+
},
|
|
142
|
+
}});
|
|
143
|
+
|
|
144
|
+
export const CommonIndeterminateToggle = styled(CommonToggle, {
|
|
145
|
+
shouldForwardProp: (props) => props !== 'toggleSize',
|
|
146
|
+
})(({ toggleSize }) => {
|
|
147
|
+
const indeterminateStyle = indeterminateStyles[toggleSize];
|
|
148
|
+
|
|
149
|
+
return {
|
|
150
|
+
padding: 0,
|
|
151
|
+
cursor: "pointer",
|
|
152
|
+
'& .MuiSwitch-switchBase.Mui-checked': {
|
|
153
|
+
...indeterminateStyle.switchChecked,
|
|
154
|
+
'& + .MuiSwitch-track': {
|
|
155
|
+
...indeterminateStyle.track,
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
'& .MuiSwitch-thumb': {
|
|
159
|
+
...indeterminateStyle.thumb,
|
|
160
|
+
boxShadow: "none",
|
|
161
|
+
},
|
|
162
|
+
}});
|