@gobolt/genesis 0.2.18 → 0.2.20
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/Avatar/Avatar.cjs +0 -1
- package/dist/components/Avatar/Avatar.js +0 -1
- package/dist/components/Badge/Badge.cjs +19 -6
- package/dist/components/Badge/Badge.d.ts +7 -2
- package/dist/components/Badge/Badge.js +19 -6
- package/dist/components/Badge/__stories__/Badge.stories.d.ts +2 -0
- package/dist/components/Badge/styles.cjs +21 -5
- package/dist/components/Badge/styles.d.ts +4 -1
- package/dist/components/Badge/styles.js +21 -5
- package/dist/components/Card/__stories__/Card.stories.d.ts +0 -1
- package/dist/components/Filters/Filter.d.ts +23 -0
- package/dist/components/Filters/FilterRow.d.ts +8 -0
- package/dist/components/Filters/Filters.d.ts +8 -0
- package/dist/components/Filters/__stories__/Filters.stories.d.ts +9 -0
- package/dist/components/Filters/__tests__/Filters.test.d.ts +1 -0
- package/dist/components/Filters/index.d.ts +2 -0
- package/dist/components/Filters/styles.d.ts +26 -0
- package/dist/components/Select/MultiSelectCount.cjs +8 -4
- package/dist/components/Select/MultiSelectCount.d.ts +3 -2
- package/dist/components/Select/MultiSelectCount.js +8 -4
- package/dist/components/Select/Select.cjs +47 -18
- package/dist/components/Select/Select.d.ts +4 -2
- package/dist/components/Select/Select.js +47 -18
- package/dist/components/Select/__stories__/MultiSelectCount.stories.d.ts +1 -0
- package/dist/components/Select/__stories__/Select.stories.d.ts +1 -1
- package/dist/components/Select/styles.cjs +7 -4
- package/dist/components/Select/styles.d.ts +1 -0
- package/dist/components/Select/styles.js +7 -4
- package/dist/components/Stories/position-checker.d.ts +6 -0
- package/dist/components/Table/TableWithControls/TableWithControls.cjs +0 -1
- package/dist/components/Table/TableWithControls/TableWithControls.js +0 -1
- package/dist/utils/icon-util.cjs +5 -2
- package/dist/utils/icon-util.d.ts +1 -1
- package/dist/utils/icon-util.js +5 -2
- package/package.json +1 -1
|
@@ -11,8 +11,14 @@ const Badge = ({
|
|
|
11
11
|
state = "info",
|
|
12
12
|
isDisabled,
|
|
13
13
|
hasClose = false,
|
|
14
|
-
onClick
|
|
14
|
+
onClick = () => {
|
|
15
|
+
},
|
|
15
16
|
size = "normal",
|
|
17
|
+
hasIcon = true,
|
|
18
|
+
customIcon = null,
|
|
19
|
+
backgroundColor = null,
|
|
20
|
+
textColor = null,
|
|
21
|
+
hasHover = true,
|
|
16
22
|
...rest
|
|
17
23
|
}) => {
|
|
18
24
|
const { theme } = useGenesis.useGenesis();
|
|
@@ -28,6 +34,7 @@ const Badge = ({
|
|
|
28
34
|
style: {
|
|
29
35
|
padding: "4px 4px"
|
|
30
36
|
},
|
|
37
|
+
hasHover,
|
|
31
38
|
...rest,
|
|
32
39
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
33
40
|
"div",
|
|
@@ -39,8 +46,10 @@ const Badge = ({
|
|
|
39
46
|
},
|
|
40
47
|
children: iconUtil.getBadgeStateIcon(
|
|
41
48
|
state,
|
|
42
|
-
theme.colors.status[state].onsurface,
|
|
43
|
-
isBadgeIconFilled
|
|
49
|
+
backgroundColor || theme.colors.status[state].onsurface,
|
|
50
|
+
isBadgeIconFilled,
|
|
51
|
+
hasIcon,
|
|
52
|
+
customIcon
|
|
44
53
|
)
|
|
45
54
|
}
|
|
46
55
|
)
|
|
@@ -56,18 +65,22 @@ const Badge = ({
|
|
|
56
65
|
state,
|
|
57
66
|
disabled: isDisabled,
|
|
58
67
|
style: { cursor: role === "button" ? "pointer" : "default" },
|
|
68
|
+
backgroundColor,
|
|
69
|
+
hasHover,
|
|
59
70
|
...rest,
|
|
60
71
|
children: [
|
|
61
72
|
iconUtil.getBadgeStateIcon(
|
|
62
73
|
state,
|
|
63
|
-
theme.colors.status[state].onsurface,
|
|
64
|
-
isBadgeIconFilled
|
|
74
|
+
backgroundColor || theme.colors.status[state].onsurface,
|
|
75
|
+
isBadgeIconFilled,
|
|
76
|
+
hasIcon,
|
|
77
|
+
customIcon
|
|
65
78
|
),
|
|
66
79
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
67
80
|
Typography,
|
|
68
81
|
{
|
|
69
82
|
variant: size === "small" ? "label3" : "label2",
|
|
70
|
-
color: isDisabled ? theme.colors.status.disabled.default : theme.colors.status[state].onsurface,
|
|
83
|
+
color: isDisabled ? theme.colors.status.disabled.default : textColor || theme.colors.status[state].onsurface,
|
|
71
84
|
isDisabled,
|
|
72
85
|
children: label
|
|
73
86
|
}
|
|
@@ -4,8 +4,13 @@ export interface BadgeProps {
|
|
|
4
4
|
isDisabled?: boolean;
|
|
5
5
|
state?: State;
|
|
6
6
|
hasClose?: boolean;
|
|
7
|
+
hasIcon?: boolean;
|
|
8
|
+
customIcon?: React.ReactNode | null;
|
|
7
9
|
size?: "small" | "normal" | "large";
|
|
8
|
-
|
|
10
|
+
backgroundColor?: string;
|
|
11
|
+
textColor?: string;
|
|
12
|
+
onClick?: () => void | null;
|
|
13
|
+
hasHover?: boolean;
|
|
9
14
|
}
|
|
10
|
-
declare const Badge: ({ label, state, isDisabled, hasClose, onClick, size, ...rest }: BadgeProps) => import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
declare const Badge: ({ label, state, isDisabled, hasClose, onClick, size, hasIcon, customIcon, backgroundColor, textColor, hasHover, ...rest }: BadgeProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
16
|
export default Badge;
|
|
@@ -10,8 +10,14 @@ const Badge = ({
|
|
|
10
10
|
state = "info",
|
|
11
11
|
isDisabled,
|
|
12
12
|
hasClose = false,
|
|
13
|
-
onClick
|
|
13
|
+
onClick = () => {
|
|
14
|
+
},
|
|
14
15
|
size = "normal",
|
|
16
|
+
hasIcon = true,
|
|
17
|
+
customIcon = null,
|
|
18
|
+
backgroundColor = null,
|
|
19
|
+
textColor = null,
|
|
20
|
+
hasHover = true,
|
|
15
21
|
...rest
|
|
16
22
|
}) => {
|
|
17
23
|
const { theme } = useGenesis();
|
|
@@ -27,6 +33,7 @@ const Badge = ({
|
|
|
27
33
|
style: {
|
|
28
34
|
padding: "4px 4px"
|
|
29
35
|
},
|
|
36
|
+
hasHover,
|
|
30
37
|
...rest,
|
|
31
38
|
children: /* @__PURE__ */ jsx(
|
|
32
39
|
"div",
|
|
@@ -38,8 +45,10 @@ const Badge = ({
|
|
|
38
45
|
},
|
|
39
46
|
children: getBadgeStateIcon(
|
|
40
47
|
state,
|
|
41
|
-
theme.colors.status[state].onsurface,
|
|
42
|
-
isBadgeIconFilled
|
|
48
|
+
backgroundColor || theme.colors.status[state].onsurface,
|
|
49
|
+
isBadgeIconFilled,
|
|
50
|
+
hasIcon,
|
|
51
|
+
customIcon
|
|
43
52
|
)
|
|
44
53
|
}
|
|
45
54
|
)
|
|
@@ -55,18 +64,22 @@ const Badge = ({
|
|
|
55
64
|
state,
|
|
56
65
|
disabled: isDisabled,
|
|
57
66
|
style: { cursor: role === "button" ? "pointer" : "default" },
|
|
67
|
+
backgroundColor,
|
|
68
|
+
hasHover,
|
|
58
69
|
...rest,
|
|
59
70
|
children: [
|
|
60
71
|
getBadgeStateIcon(
|
|
61
72
|
state,
|
|
62
|
-
theme.colors.status[state].onsurface,
|
|
63
|
-
isBadgeIconFilled
|
|
73
|
+
backgroundColor || theme.colors.status[state].onsurface,
|
|
74
|
+
isBadgeIconFilled,
|
|
75
|
+
hasIcon,
|
|
76
|
+
customIcon
|
|
64
77
|
),
|
|
65
78
|
/* @__PURE__ */ jsx(
|
|
66
79
|
Typography,
|
|
67
80
|
{
|
|
68
81
|
variant: size === "small" ? "label3" : "label2",
|
|
69
|
-
color: isDisabled ? theme.colors.status.disabled.default : theme.colors.status[state].onsurface,
|
|
82
|
+
color: isDisabled ? theme.colors.status.disabled.default : textColor || theme.colors.status[state].onsurface,
|
|
70
83
|
isDisabled,
|
|
71
84
|
children: label
|
|
72
85
|
}
|
|
@@ -6,7 +6,7 @@ const getBorderColor = (theme, state) => {
|
|
|
6
6
|
}
|
|
7
7
|
return theme.colors.status[state].surface;
|
|
8
8
|
};
|
|
9
|
-
const getGenesisClass = (theme, state, label, disabled) => `
|
|
9
|
+
const getGenesisClass = (theme, state, label, disabled, backgroundColor, textColor, hasHover) => `
|
|
10
10
|
display: flex;
|
|
11
11
|
gap: 4px;
|
|
12
12
|
justify-content: center;
|
|
@@ -18,10 +18,10 @@ const getGenesisClass = (theme, state, label, disabled) => `
|
|
|
18
18
|
padding-right: ${theme.components.badge["right-padding"]}px;
|
|
19
19
|
border-radius: ${theme.components.badge.radius}px;
|
|
20
20
|
border: 1px solid ${getBorderColor(theme, state)};
|
|
21
|
-
background-color: ${theme.colors.status[state].surface};
|
|
21
|
+
background-color: ${backgroundColor || theme.colors.status[state].surface};
|
|
22
22
|
|
|
23
23
|
&:not(:disabled):hover {
|
|
24
|
-
background-color: ${theme.colors.status[state]["surface-hover"]}
|
|
24
|
+
${hasHover ? `background-color: ${theme.colors.status[state]["surface-hover"]};` : ""}
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
${disabled ? `
|
|
@@ -36,8 +36,24 @@ const getGenesisClass = (theme, state, label, disabled) => `
|
|
|
36
36
|
` : ""}
|
|
37
37
|
`;
|
|
38
38
|
const Badge = styled.div`
|
|
39
|
-
${({
|
|
40
|
-
|
|
39
|
+
${({
|
|
40
|
+
theme,
|
|
41
|
+
state,
|
|
42
|
+
label,
|
|
43
|
+
disabled,
|
|
44
|
+
backgroundColor,
|
|
45
|
+
textColor,
|
|
46
|
+
hasHover
|
|
47
|
+
}) => {
|
|
48
|
+
return getGenesisClass(
|
|
49
|
+
theme,
|
|
50
|
+
state,
|
|
51
|
+
label,
|
|
52
|
+
disabled,
|
|
53
|
+
backgroundColor,
|
|
54
|
+
textColor,
|
|
55
|
+
hasHover
|
|
56
|
+
);
|
|
41
57
|
}}
|
|
42
58
|
`;
|
|
43
59
|
exports.Badge = Badge;
|
|
@@ -5,7 +5,10 @@ interface StyledBadgeProps {
|
|
|
5
5
|
state?: State;
|
|
6
6
|
label?: string;
|
|
7
7
|
disabled?: boolean;
|
|
8
|
+
backgroundColor?: string;
|
|
9
|
+
textColor?: string;
|
|
10
|
+
hasHover?: boolean;
|
|
8
11
|
}
|
|
9
|
-
export declare const getGenesisClass: (theme: GenesisTheme, state: State, label?: string, disabled?: boolean) => string;
|
|
12
|
+
export declare const getGenesisClass: (theme: GenesisTheme, state: State, label?: string, disabled?: boolean, backgroundColor?: string, textColor?: string, hasHover?: boolean) => string;
|
|
10
13
|
export declare const Badge: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components/dist/types').Substitute<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, StyledBadgeProps>> & string;
|
|
11
14
|
export {};
|
|
@@ -5,7 +5,7 @@ const getBorderColor = (theme, state) => {
|
|
|
5
5
|
}
|
|
6
6
|
return theme.colors.status[state].surface;
|
|
7
7
|
};
|
|
8
|
-
const getGenesisClass = (theme, state, label, disabled) => `
|
|
8
|
+
const getGenesisClass = (theme, state, label, disabled, backgroundColor, textColor, hasHover) => `
|
|
9
9
|
display: flex;
|
|
10
10
|
gap: 4px;
|
|
11
11
|
justify-content: center;
|
|
@@ -17,10 +17,10 @@ const getGenesisClass = (theme, state, label, disabled) => `
|
|
|
17
17
|
padding-right: ${theme.components.badge["right-padding"]}px;
|
|
18
18
|
border-radius: ${theme.components.badge.radius}px;
|
|
19
19
|
border: 1px solid ${getBorderColor(theme, state)};
|
|
20
|
-
background-color: ${theme.colors.status[state].surface};
|
|
20
|
+
background-color: ${backgroundColor || theme.colors.status[state].surface};
|
|
21
21
|
|
|
22
22
|
&:not(:disabled):hover {
|
|
23
|
-
background-color: ${theme.colors.status[state]["surface-hover"]}
|
|
23
|
+
${hasHover ? `background-color: ${theme.colors.status[state]["surface-hover"]};` : ""}
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
${disabled ? `
|
|
@@ -35,8 +35,24 @@ const getGenesisClass = (theme, state, label, disabled) => `
|
|
|
35
35
|
` : ""}
|
|
36
36
|
`;
|
|
37
37
|
const Badge = styled.div`
|
|
38
|
-
${({
|
|
39
|
-
|
|
38
|
+
${({
|
|
39
|
+
theme,
|
|
40
|
+
state,
|
|
41
|
+
label,
|
|
42
|
+
disabled,
|
|
43
|
+
backgroundColor,
|
|
44
|
+
textColor,
|
|
45
|
+
hasHover
|
|
46
|
+
}) => {
|
|
47
|
+
return getGenesisClass(
|
|
48
|
+
theme,
|
|
49
|
+
state,
|
|
50
|
+
label,
|
|
51
|
+
disabled,
|
|
52
|
+
backgroundColor,
|
|
53
|
+
textColor,
|
|
54
|
+
hasHover
|
|
55
|
+
);
|
|
40
56
|
}}
|
|
41
57
|
`;
|
|
42
58
|
export {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { RangePickerProps } from 'antd/lib/date-picker';
|
|
2
|
+
export declare const FILTER_TYPE: {
|
|
3
|
+
readonly input: "input";
|
|
4
|
+
readonly select: "select";
|
|
5
|
+
readonly dateRange: "date-range";
|
|
6
|
+
readonly multiSelectCount: "multi-select-count";
|
|
7
|
+
};
|
|
8
|
+
export type Option = {
|
|
9
|
+
value: string;
|
|
10
|
+
label: string;
|
|
11
|
+
};
|
|
12
|
+
export interface FilterProps {
|
|
13
|
+
id: string;
|
|
14
|
+
label: string;
|
|
15
|
+
type: "input" | "select" | "date-range" | "multi-select-count";
|
|
16
|
+
value: string | string[] | number | RangePickerProps["value"];
|
|
17
|
+
options?: Option[];
|
|
18
|
+
onChange: (updatedFilter: FilterProps) => void;
|
|
19
|
+
selectedValues?: string[];
|
|
20
|
+
colSpan?: number;
|
|
21
|
+
}
|
|
22
|
+
declare const Filter: ({ id, label, type, value, options, onChange, selectedValues, colSpan, }: FilterProps) => import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
export default Filter;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { FilterProps } from './Filter';
|
|
3
|
+
export interface FilterRowProps {
|
|
4
|
+
filters: FilterProps[];
|
|
5
|
+
onChange?: (filters: any) => void;
|
|
6
|
+
}
|
|
7
|
+
declare const FilterRow: React.FC<FilterRowProps>;
|
|
8
|
+
export default FilterRow;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FilterProps } from './Filter';
|
|
2
|
+
import { FilterRowProps } from './FilterRow';
|
|
3
|
+
export interface FiltersProps {
|
|
4
|
+
onChange?: (newFilter: FilterProps, newFilters: FilterRowProps[]) => void;
|
|
5
|
+
filterRows: FilterRowProps[];
|
|
6
|
+
}
|
|
7
|
+
declare const Filters: ({ filterRows, onChange }: FiltersProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export default Filters;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { default as Filters } from '../Filters';
|
|
3
|
+
import { FilterRowProps } from '../FilterRow';
|
|
4
|
+
declare const meta: Meta<typeof Filters>;
|
|
5
|
+
export default meta;
|
|
6
|
+
type Story = StoryObj<typeof Filters>;
|
|
7
|
+
export declare const oneFilterRow: FilterRowProps[];
|
|
8
|
+
export declare const OneFilterRowStory: Story;
|
|
9
|
+
export declare const ThreeFilterRowsStory: Story;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { GenesisTheme } from '../../styles/theme/genesis-theme.types';
|
|
2
|
+
interface StyledFiltersProps {
|
|
3
|
+
theme?: GenesisTheme;
|
|
4
|
+
type?: "primary" | "secondary";
|
|
5
|
+
state?: "active" | "disabled";
|
|
6
|
+
}
|
|
7
|
+
export declare const getGenesisClass: ({ colors, borderRadius, sizing }: {
|
|
8
|
+
colors: any;
|
|
9
|
+
borderRadius: any;
|
|
10
|
+
sizing: any;
|
|
11
|
+
}, type?: string, state?: string) => string;
|
|
12
|
+
export declare const StyledFilters: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components/dist/types').Substitute<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, StyledFiltersProps>> & string;
|
|
13
|
+
export declare const LinkButton: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components').FastOmit<import('react').DetailedHTMLProps<import('react').ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, never>> & string;
|
|
14
|
+
export declare const FilterRow: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components').FastOmit<Omit<import('antd').RowProps & import('react').RefAttributes<HTMLDivElement>, "ref"> & {
|
|
15
|
+
ref?: import('react').Ref<HTMLDivElement>;
|
|
16
|
+
}, never>> & string & Omit<import('react').ForwardRefExoticComponent<import('antd').RowProps & import('react').RefAttributes<HTMLDivElement>>, keyof import('react').Component<any, {}, any>>;
|
|
17
|
+
export declare const FilterRowNoDivider: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components').FastOmit<Omit<import('antd').RowProps & import('react').RefAttributes<HTMLDivElement>, "ref"> & {
|
|
18
|
+
ref?: import('react').Ref<HTMLDivElement>;
|
|
19
|
+
}, never>> & string & Omit<import('react').ForwardRefExoticComponent<import('antd').RowProps & import('react').RefAttributes<HTMLDivElement>>, keyof import('react').Component<any, {}, any>>;
|
|
20
|
+
export declare const StyledInput: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components').FastOmit<import('..').InputProps, never>> & string & Omit<({ state, size, ...rest }: import('..').InputProps) => import("react/jsx-runtime").JSX.Element, keyof import('react').Component<any, {}, any>>;
|
|
21
|
+
export declare const StyledSelect: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components').FastOmit<import('..').SelectProps, never>> & string & Omit<({ type, state, variant, defaultValue, onChange, size, width, value, ...rest }: import('..').SelectProps) => import("react/jsx-runtime").JSX.Element, keyof import('react').Component<any, {}, any>>;
|
|
22
|
+
export declare const StyledCol: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components').FastOmit<Omit<import('antd').ColProps & import('react').RefAttributes<HTMLDivElement>, "ref"> & {
|
|
23
|
+
ref?: import('react').Ref<HTMLDivElement>;
|
|
24
|
+
}, never>> & string & Omit<import('react').ForwardRefExoticComponent<import('antd').ColProps & import('react').RefAttributes<HTMLDivElement>>, keyof import('react').Component<any, {}, any>>;
|
|
25
|
+
export declare const HelperText: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components').FastOmit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
26
|
+
export {};
|
|
@@ -6,8 +6,9 @@ const MultiSelectCount = ({
|
|
|
6
6
|
options,
|
|
7
7
|
onChange,
|
|
8
8
|
width = 320,
|
|
9
|
-
selectedValues,
|
|
10
|
-
placeholder = "0 selected"
|
|
9
|
+
selectedValues = [],
|
|
10
|
+
placeholder = "0 selected",
|
|
11
|
+
variant = "multiSelectCount"
|
|
11
12
|
}) => {
|
|
12
13
|
const renderMultiSelectValue = () => {
|
|
13
14
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -19,7 +20,7 @@ const MultiSelectCount = ({
|
|
|
19
20
|
paddingTop: "2px"
|
|
20
21
|
},
|
|
21
22
|
children: [
|
|
22
|
-
selectedValues.length,
|
|
23
|
+
(selectedValues || []).length,
|
|
23
24
|
" selected"
|
|
24
25
|
]
|
|
25
26
|
}
|
|
@@ -31,13 +32,16 @@ const MultiSelectCount = ({
|
|
|
31
32
|
options,
|
|
32
33
|
mode: "multiple",
|
|
33
34
|
value: selectedValues,
|
|
35
|
+
defaultValue: selectedValues,
|
|
34
36
|
onChange,
|
|
35
37
|
maxTagCount: 0,
|
|
36
38
|
suffixIcon: /* @__PURE__ */ jsxRuntime.jsx(DropdownChevron, {}),
|
|
37
39
|
labelInValue: false,
|
|
38
40
|
showSearch: false,
|
|
39
41
|
maxTagPlaceholder: renderMultiSelectValue,
|
|
40
|
-
placeholder
|
|
42
|
+
placeholder,
|
|
43
|
+
variant,
|
|
44
|
+
style: { width }
|
|
41
45
|
}
|
|
42
46
|
) });
|
|
43
47
|
};
|
|
@@ -4,9 +4,10 @@ export interface MultiSelectCountProps {
|
|
|
4
4
|
label: string;
|
|
5
5
|
}[];
|
|
6
6
|
onChange: (values: string[]) => void;
|
|
7
|
-
width?: number;
|
|
7
|
+
width?: number | string;
|
|
8
8
|
selectedValues?: string[];
|
|
9
9
|
placeholder?: string;
|
|
10
|
+
variant?: "multiSelectCount" | "none";
|
|
10
11
|
}
|
|
11
|
-
declare const MultiSelectCount: ({ options, onChange, width, selectedValues, placeholder, }: MultiSelectCountProps) => import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
declare const MultiSelectCount: ({ options, onChange, width, selectedValues, placeholder, variant, }: MultiSelectCountProps) => import("react/jsx-runtime").JSX.Element;
|
|
12
13
|
export default MultiSelectCount;
|
|
@@ -5,8 +5,9 @@ const MultiSelectCount = ({
|
|
|
5
5
|
options,
|
|
6
6
|
onChange,
|
|
7
7
|
width = 320,
|
|
8
|
-
selectedValues,
|
|
9
|
-
placeholder = "0 selected"
|
|
8
|
+
selectedValues = [],
|
|
9
|
+
placeholder = "0 selected",
|
|
10
|
+
variant = "multiSelectCount"
|
|
10
11
|
}) => {
|
|
11
12
|
const renderMultiSelectValue = () => {
|
|
12
13
|
return /* @__PURE__ */ jsxs(
|
|
@@ -18,7 +19,7 @@ const MultiSelectCount = ({
|
|
|
18
19
|
paddingTop: "2px"
|
|
19
20
|
},
|
|
20
21
|
children: [
|
|
21
|
-
selectedValues.length,
|
|
22
|
+
(selectedValues || []).length,
|
|
22
23
|
" selected"
|
|
23
24
|
]
|
|
24
25
|
}
|
|
@@ -30,13 +31,16 @@ const MultiSelectCount = ({
|
|
|
30
31
|
options,
|
|
31
32
|
mode: "multiple",
|
|
32
33
|
value: selectedValues,
|
|
34
|
+
defaultValue: selectedValues,
|
|
33
35
|
onChange,
|
|
34
36
|
maxTagCount: 0,
|
|
35
37
|
suffixIcon: /* @__PURE__ */ jsx(DropdownChevron, {}),
|
|
36
38
|
labelInValue: false,
|
|
37
39
|
showSearch: false,
|
|
38
40
|
maxTagPlaceholder: renderMultiSelectValue,
|
|
39
|
-
placeholder
|
|
41
|
+
placeholder,
|
|
42
|
+
variant,
|
|
43
|
+
style: { width }
|
|
40
44
|
}
|
|
41
45
|
) });
|
|
42
46
|
};
|
|
@@ -12,39 +12,68 @@ const Select = ({
|
|
|
12
12
|
defaultValue,
|
|
13
13
|
onChange,
|
|
14
14
|
size = "normal",
|
|
15
|
+
width = 320,
|
|
16
|
+
value,
|
|
15
17
|
...rest
|
|
16
18
|
}) => {
|
|
17
19
|
const { breakpoint } = useGenesis.useGenesis();
|
|
18
20
|
const [isFocused, setIsFocused] = React.useState(false);
|
|
19
21
|
React.useEffect(() => {
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
+
const style2 = document.createElement("style");
|
|
23
|
+
style2.textContent = `
|
|
22
24
|
.ant-select-dropdown {
|
|
23
25
|
padding: 0px !important;
|
|
24
26
|
border-radius: 0px !important;
|
|
25
27
|
}
|
|
28
|
+
.ant-select-selection-placeholder {
|
|
29
|
+
inset-inline-start: 0px !important;
|
|
30
|
+
}
|
|
26
31
|
`;
|
|
27
|
-
document.head.appendChild(
|
|
32
|
+
document.head.appendChild(style2);
|
|
28
33
|
return () => {
|
|
29
|
-
document.head.removeChild(
|
|
34
|
+
document.head.removeChild(style2);
|
|
30
35
|
};
|
|
31
36
|
}, []);
|
|
32
37
|
const customDropdownRender = (menu) => /* @__PURE__ */ jsxRuntime.jsx(styles.SelectDropdown, { type, state, children: /* @__PURE__ */ jsxRuntime.jsx(styles.StyledMenuItem, { type, state, children: menu }) });
|
|
33
|
-
|
|
34
|
-
|
|
38
|
+
const isMultiSelectCountAtZero = variant === "multiSelectCount" && Array.isArray(value);
|
|
39
|
+
const totalSelected = Array.isArray(value) ? value == null ? void 0 : value.length : 0;
|
|
40
|
+
const shiftHackStyle = {
|
|
41
|
+
display: "block",
|
|
42
|
+
position: "absolute",
|
|
43
|
+
top: totalSelected === 0 ? 0 : 12,
|
|
44
|
+
left: 0,
|
|
45
|
+
width
|
|
46
|
+
};
|
|
47
|
+
const normalStyle = {
|
|
48
|
+
display: "block",
|
|
49
|
+
position: "relative",
|
|
50
|
+
width
|
|
51
|
+
};
|
|
52
|
+
const style = isMultiSelectCountAtZero ? shiftHackStyle : normalStyle;
|
|
53
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { style, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
54
|
+
styles.SelectWrapper,
|
|
35
55
|
{
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
56
|
+
$isFocused: isFocused,
|
|
57
|
+
type,
|
|
58
|
+
$isMultiSelectCountAtZero: isMultiSelectCountAtZero,
|
|
59
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
60
|
+
styles.Select,
|
|
61
|
+
{
|
|
62
|
+
...rest,
|
|
63
|
+
size,
|
|
64
|
+
defaultValue,
|
|
65
|
+
$variant: variant,
|
|
66
|
+
suffixIcon: /* @__PURE__ */ jsxRuntime.jsx(DropdownChevron, {}),
|
|
67
|
+
dropdownRender: customDropdownRender,
|
|
68
|
+
onFocus: () => setIsFocused(true),
|
|
69
|
+
onBlur: () => setIsFocused(false),
|
|
70
|
+
onChange: (value2) => {
|
|
71
|
+
setIsFocused(false);
|
|
72
|
+
onChange == null ? void 0 : onChange(value2);
|
|
73
|
+
},
|
|
74
|
+
style: { width }
|
|
75
|
+
}
|
|
76
|
+
)
|
|
48
77
|
}
|
|
49
78
|
) });
|
|
50
79
|
};
|
|
@@ -8,10 +8,12 @@ export interface SelectProps extends Omit<AntSelectProps, "variant" | "size"> {
|
|
|
8
8
|
value: string;
|
|
9
9
|
label: React.ReactNode;
|
|
10
10
|
}[];
|
|
11
|
-
variant?: "simple" | "none";
|
|
11
|
+
variant?: "simple" | "none" | "multiSelectCount";
|
|
12
12
|
defaultValue?: string | string[] | number | number[] | unknown;
|
|
13
13
|
onChange?: (value: string | string[]) => void;
|
|
14
14
|
size?: "normal" | "small" | "large";
|
|
15
|
+
value?: string[] | string | number[] | number;
|
|
16
|
+
width?: number;
|
|
15
17
|
}
|
|
16
|
-
declare const Select: ({ type, state, variant, defaultValue, onChange, size, ...rest }: SelectProps) => import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
declare const Select: ({ type, state, variant, defaultValue, onChange, size, width, value, ...rest }: SelectProps) => import("react/jsx-runtime").JSX.Element;
|
|
17
19
|
export default Select;
|
|
@@ -11,39 +11,68 @@ const Select = ({
|
|
|
11
11
|
defaultValue,
|
|
12
12
|
onChange,
|
|
13
13
|
size = "normal",
|
|
14
|
+
width = 320,
|
|
15
|
+
value,
|
|
14
16
|
...rest
|
|
15
17
|
}) => {
|
|
16
18
|
const { breakpoint } = useGenesis();
|
|
17
19
|
const [isFocused, setIsFocused] = React__default.useState(false);
|
|
18
20
|
useEffect(() => {
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
+
const style2 = document.createElement("style");
|
|
22
|
+
style2.textContent = `
|
|
21
23
|
.ant-select-dropdown {
|
|
22
24
|
padding: 0px !important;
|
|
23
25
|
border-radius: 0px !important;
|
|
24
26
|
}
|
|
27
|
+
.ant-select-selection-placeholder {
|
|
28
|
+
inset-inline-start: 0px !important;
|
|
29
|
+
}
|
|
25
30
|
`;
|
|
26
|
-
document.head.appendChild(
|
|
31
|
+
document.head.appendChild(style2);
|
|
27
32
|
return () => {
|
|
28
|
-
document.head.removeChild(
|
|
33
|
+
document.head.removeChild(style2);
|
|
29
34
|
};
|
|
30
35
|
}, []);
|
|
31
36
|
const customDropdownRender = (menu) => /* @__PURE__ */ jsx(SelectDropdown, { type, state, children: /* @__PURE__ */ jsx(StyledMenuItem, { type, state, children: menu }) });
|
|
32
|
-
|
|
33
|
-
|
|
37
|
+
const isMultiSelectCountAtZero = variant === "multiSelectCount" && Array.isArray(value);
|
|
38
|
+
const totalSelected = Array.isArray(value) ? value == null ? void 0 : value.length : 0;
|
|
39
|
+
const shiftHackStyle = {
|
|
40
|
+
display: "block",
|
|
41
|
+
position: "absolute",
|
|
42
|
+
top: totalSelected === 0 ? 0 : 12,
|
|
43
|
+
left: 0,
|
|
44
|
+
width
|
|
45
|
+
};
|
|
46
|
+
const normalStyle = {
|
|
47
|
+
display: "block",
|
|
48
|
+
position: "relative",
|
|
49
|
+
width
|
|
50
|
+
};
|
|
51
|
+
const style = isMultiSelectCountAtZero ? shiftHackStyle : normalStyle;
|
|
52
|
+
return /* @__PURE__ */ jsx("div", { style, children: /* @__PURE__ */ jsx(
|
|
53
|
+
SelectWrapper,
|
|
34
54
|
{
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
55
|
+
$isFocused: isFocused,
|
|
56
|
+
type,
|
|
57
|
+
$isMultiSelectCountAtZero: isMultiSelectCountAtZero,
|
|
58
|
+
children: /* @__PURE__ */ jsx(
|
|
59
|
+
Select$1,
|
|
60
|
+
{
|
|
61
|
+
...rest,
|
|
62
|
+
size,
|
|
63
|
+
defaultValue,
|
|
64
|
+
$variant: variant,
|
|
65
|
+
suffixIcon: /* @__PURE__ */ jsx(DropdownChevron, {}),
|
|
66
|
+
dropdownRender: customDropdownRender,
|
|
67
|
+
onFocus: () => setIsFocused(true),
|
|
68
|
+
onBlur: () => setIsFocused(false),
|
|
69
|
+
onChange: (value2) => {
|
|
70
|
+
setIsFocused(false);
|
|
71
|
+
onChange == null ? void 0 : onChange(value2);
|
|
72
|
+
},
|
|
73
|
+
style: { width }
|
|
74
|
+
}
|
|
75
|
+
)
|
|
47
76
|
}
|
|
48
77
|
) });
|
|
49
78
|
};
|
|
@@ -4,7 +4,7 @@ declare const meta: Meta<typeof Select>;
|
|
|
4
4
|
export default meta;
|
|
5
5
|
type Story = StoryObj<typeof Select>;
|
|
6
6
|
export declare const Default: Story;
|
|
7
|
-
export declare const
|
|
7
|
+
export declare const DefaultSelectedValue: Story;
|
|
8
8
|
export declare const Focussed: Story;
|
|
9
9
|
export declare const Disabled: Story;
|
|
10
10
|
export declare const Simple: Story;
|
|
@@ -3,17 +3,18 @@ var styled = require("styled-components");
|
|
|
3
3
|
var index = require("../../node_modules/antd/es/select/index.cjs");
|
|
4
4
|
const SelectWrapper = styled.div`
|
|
5
5
|
position: relative;
|
|
6
|
-
border: 2px solid transparent;
|
|
6
|
+
//border: 2px solid transparent;
|
|
7
7
|
background-color: transparent;
|
|
8
8
|
border-radius: 8px;
|
|
9
|
-
padding: 1px;
|
|
9
|
+
//padding: 1px;
|
|
10
10
|
width: auto;
|
|
11
|
+
margin-top: ${({ $isMultiSelectCountAtZero }) => $isMultiSelectCountAtZero ? "-12px" : "0px"};
|
|
11
12
|
|
|
12
13
|
${({ $isFocused, theme: theme2, type = "primary" }) => $isFocused && `
|
|
13
14
|
border: 2px solid ${theme2.colors[type].focussed.ringColor};
|
|
14
15
|
background-color: transparent;
|
|
15
16
|
border-radius: 8px;
|
|
16
|
-
padding: 1px;
|
|
17
|
+
//padding: 1px;
|
|
17
18
|
`}
|
|
18
19
|
|
|
19
20
|
.ant-select-dropdown {
|
|
@@ -57,7 +58,7 @@ const getGenesisClass = ({ colors, sizing: sizing2, typography, borderRadius },
|
|
|
57
58
|
min-width: 250px;
|
|
58
59
|
height: ${size === "normal" || size === "large" ? "40px" : "32px"};
|
|
59
60
|
|
|
60
|
-
|
|
61
|
+
background-color: ${colors[type][state].backgroundColor}
|
|
61
62
|
background-color: #fff;
|
|
62
63
|
|
|
63
64
|
border-radius: ${borderRadius.BorderRadiusMd}px;
|
|
@@ -107,6 +108,8 @@ const getGenesisClass = ({ colors, sizing: sizing2, typography, borderRadius },
|
|
|
107
108
|
|
|
108
109
|
&.ant-select-selection-placeholder {
|
|
109
110
|
padding-top: 6px;
|
|
111
|
+
inset-inline-end: 0px;
|
|
112
|
+
inset-inline-start: 0px;
|
|
110
113
|
}
|
|
111
114
|
}
|
|
112
115
|
|
|
@@ -12,6 +12,7 @@ interface SelectWrapperProps {
|
|
|
12
12
|
type: keyof typeof TYPE;
|
|
13
13
|
variant?: "simple" | "none";
|
|
14
14
|
size?: "normal" | "small" | "large";
|
|
15
|
+
$isMultiSelectCountAtZero?: boolean;
|
|
15
16
|
}
|
|
16
17
|
export declare const SelectWrapper: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components/dist/types').Substitute<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, SelectWrapperProps>> & string;
|
|
17
18
|
export declare const getGenesisClass: ({ colors, sizing, typography, borderRadius }: {
|
|
@@ -2,17 +2,18 @@ import styled from "styled-components";
|
|
|
2
2
|
import Select$1 from "../../node_modules/antd/es/select/index.js";
|
|
3
3
|
const SelectWrapper = styled.div`
|
|
4
4
|
position: relative;
|
|
5
|
-
border: 2px solid transparent;
|
|
5
|
+
//border: 2px solid transparent;
|
|
6
6
|
background-color: transparent;
|
|
7
7
|
border-radius: 8px;
|
|
8
|
-
padding: 1px;
|
|
8
|
+
//padding: 1px;
|
|
9
9
|
width: auto;
|
|
10
|
+
margin-top: ${({ $isMultiSelectCountAtZero }) => $isMultiSelectCountAtZero ? "-12px" : "0px"};
|
|
10
11
|
|
|
11
12
|
${({ $isFocused, theme: theme2, type = "primary" }) => $isFocused && `
|
|
12
13
|
border: 2px solid ${theme2.colors[type].focussed.ringColor};
|
|
13
14
|
background-color: transparent;
|
|
14
15
|
border-radius: 8px;
|
|
15
|
-
padding: 1px;
|
|
16
|
+
//padding: 1px;
|
|
16
17
|
`}
|
|
17
18
|
|
|
18
19
|
.ant-select-dropdown {
|
|
@@ -56,7 +57,7 @@ const getGenesisClass = ({ colors, sizing: sizing2, typography, borderRadius },
|
|
|
56
57
|
min-width: 250px;
|
|
57
58
|
height: ${size === "normal" || size === "large" ? "40px" : "32px"};
|
|
58
59
|
|
|
59
|
-
|
|
60
|
+
background-color: ${colors[type][state].backgroundColor}
|
|
60
61
|
background-color: #fff;
|
|
61
62
|
|
|
62
63
|
border-radius: ${borderRadius.BorderRadiusMd}px;
|
|
@@ -106,6 +107,8 @@ const getGenesisClass = ({ colors, sizing: sizing2, typography, borderRadius },
|
|
|
106
107
|
|
|
107
108
|
&.ant-select-selection-placeholder {
|
|
108
109
|
padding-top: 6px;
|
|
110
|
+
inset-inline-end: 0px;
|
|
111
|
+
inset-inline-start: 0px;
|
|
109
112
|
}
|
|
110
113
|
}
|
|
111
114
|
|
package/dist/utils/icon-util.cjs
CHANGED
|
@@ -44,10 +44,13 @@ const getIconColor = (state, theme) => {
|
|
|
44
44
|
return theme.colors.status.info.onsurface;
|
|
45
45
|
}
|
|
46
46
|
};
|
|
47
|
-
const getBadgeStateIcon = (state, color, isFilled = true) => {
|
|
48
|
-
if (!state) {
|
|
47
|
+
const getBadgeStateIcon = (state, color, isFilled = true, hasIcon = true, customIcon = null) => {
|
|
48
|
+
if (!state || !hasIcon) {
|
|
49
49
|
return null;
|
|
50
50
|
}
|
|
51
|
+
if (customIcon) {
|
|
52
|
+
return customIcon;
|
|
53
|
+
}
|
|
51
54
|
if (!isFilled) {
|
|
52
55
|
switch (state) {
|
|
53
56
|
// isFilled is false
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export declare const getIcon: (name: string) => import("react/jsx-runtime").JSX.Element;
|
|
2
2
|
export declare const getIconColor: (state: any, theme: any) => any;
|
|
3
|
-
export declare const getBadgeStateIcon: (state: any, color: any, isFilled?: boolean) =>
|
|
3
|
+
export declare const getBadgeStateIcon: (state: any, color: any, isFilled?: boolean, hasIcon?: boolean, customIcon?: any) => any;
|
package/dist/utils/icon-util.js
CHANGED
|
@@ -43,10 +43,13 @@ const getIconColor = (state, theme) => {
|
|
|
43
43
|
return theme.colors.status.info.onsurface;
|
|
44
44
|
}
|
|
45
45
|
};
|
|
46
|
-
const getBadgeStateIcon = (state, color, isFilled = true) => {
|
|
47
|
-
if (!state) {
|
|
46
|
+
const getBadgeStateIcon = (state, color, isFilled = true, hasIcon = true, customIcon = null) => {
|
|
47
|
+
if (!state || !hasIcon) {
|
|
48
48
|
return null;
|
|
49
49
|
}
|
|
50
|
+
if (customIcon) {
|
|
51
|
+
return customIcon;
|
|
52
|
+
}
|
|
50
53
|
if (!isFilled) {
|
|
51
54
|
switch (state) {
|
|
52
55
|
// isFilled is false
|