@codecademy/brand 5.9.0-alpha.f5dd739f8.0 → 5.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AppHeader/AppHeaderElements/AppHeaderLink/index.d.ts +5 -5
- package/dist/AppHeader/AppHeaderElements/AppHeaderLinkSections/elements.d.ts +5 -5
- package/dist/AppHeader/AppHeaderElements/AppHeaderListItem/index.d.ts +1 -1
- package/dist/AppHeader/AppHeaderElements/AppHeaderSection/elements.d.ts +10 -10
- package/dist/AppHeader/shared/elements.d.ts +9 -9
- package/dist/Carousel/elements.d.ts +2 -2
- package/dist/Coaching/coachingOfferings.d.ts +1 -1
- package/dist/Coaching/coachingOfferings.js +1 -1
- package/dist/DropdownButton/index.d.ts +2 -2
- package/dist/GlobalFooter/FooterHeading.d.ts +2 -2
- package/dist/GlobalFooter/FooterLinks.d.ts +1 -1
- package/dist/GlobalFooter/FooterSubHeading.d.ts +2 -2
- package/dist/LayoutMenu/AccordionMenu.js +3 -4
- package/dist/LayoutMenuVariant/AccordionMenu.js +4 -5
- package/dist/LearningOutcomeBadges/LearningOutcomeLowAssessmentBadge.d.ts +1 -1
- package/dist/LearningOutcomeTile/Tile.d.ts +1 -1
- package/dist/Notifications/elements.d.ts +2 -2
- package/dist/Testimonial/index.d.ts +1 -1
- package/dist/index.d.ts +0 -4
- package/dist/index.js +0 -4
- package/package.json +1 -5
- package/dist/Accordion/index.d.ts +0 -271
- package/dist/Accordion/index.js +0 -109
- package/dist/AccordionAreaDeprecated/index.d.ts +0 -20
- package/dist/AccordionAreaDeprecated/index.js +0 -60
- package/dist/AccordionButtonDeprecated/ButtonDeprecated/index.d.ts +0 -93
- package/dist/AccordionButtonDeprecated/ButtonDeprecated/index.js +0 -65
- package/dist/AccordionButtonDeprecated/ButtonDeprecated/styles/index.module.scss +0 -104
- package/dist/AccordionButtonDeprecated/ButtonDeprecated/styles/mixins.scss +0 -109
- package/dist/AccordionButtonDeprecated/ButtonDeprecated/styles/variables.scss +0 -54
- package/dist/AccordionButtonDeprecated/ButtonDeprecatedBase/index.d.ts +0 -43
- package/dist/AccordionButtonDeprecated/ButtonDeprecatedBase/index.js +0 -71
- package/dist/AccordionButtonDeprecated/ButtonDeprecatedBase/styles.module.scss +0 -74
- package/dist/AccordionButtonDeprecated/index.d.ts +0 -25
- package/dist/AccordionButtonDeprecated/index.js +0 -65
- package/dist/AccordionButtonDeprecated/styles.module.scss +0 -62
- package/dist/AccordionDeprecated/index.d.ts +0 -39
- package/dist/AccordionDeprecated/index.js +0 -39
- package/dist/stories/Molecules/Accordion.stories.js +0 -122
- package/dist/stories/Molecules/AccordionDeprecated.stories.js +0 -19
- package/dist/typings/react.d.ts +0 -7
- package/dist/utils/index.d.ts +0 -1
- package/dist/utils/index.js +0 -1
- package/dist/utils/omitProps.d.ts +0 -10
- package/dist/utils/omitProps.js +0 -18
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { ButtonDeprecatedBaseProps } from './ButtonDeprecatedBase';
|
|
3
|
-
export type AccordionButtonSize = 'normal' | 'large';
|
|
4
|
-
export type AccordionButtonTheme = 'blue' | 'plain' | 'yellow';
|
|
5
|
-
export type AccordionButtonDeprecatedProps = ButtonDeprecatedBaseProps & {
|
|
6
|
-
/**
|
|
7
|
-
* Whether the button should display as open or closed.
|
|
8
|
-
*/
|
|
9
|
-
expanded?: boolean;
|
|
10
|
-
/**
|
|
11
|
-
* Determines the size of the button.
|
|
12
|
-
*/
|
|
13
|
-
size?: 'normal' | 'large';
|
|
14
|
-
/**
|
|
15
|
-
* Visual theme for the clickable header button.
|
|
16
|
-
*/
|
|
17
|
-
theme?: 'blue' | 'plain' | 'yellow';
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
* @deprecated
|
|
21
|
-
* This component is in the old visual identity and will be updated soon.
|
|
22
|
-
*
|
|
23
|
-
* Check the [Gamut Board](https://www.notion.so/codecademy/Gamut-Status-Timeline-dd3c135d3848464ea6eb1b48e68fbb1d) for component status
|
|
24
|
-
*/
|
|
25
|
-
export declare const AccordionButtonDeprecated: React.FC<AccordionButtonDeprecatedProps>;
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { ArrowChevronDownIcon } from '@codecademy/gamut-icons';
|
|
2
|
-
import cx from 'classnames';
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
import { ButtonDeprecated } from './ButtonDeprecated';
|
|
5
|
-
import { ButtonDeprecatedBase } from './ButtonDeprecatedBase';
|
|
6
|
-
// eslint-disable-next-line gamut/no-css-standalone
|
|
7
|
-
import styles from './styles.module.scss';
|
|
8
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
|
-
const buttonThemes = {
|
|
10
|
-
blue: {
|
|
11
|
-
component: ButtonDeprecated,
|
|
12
|
-
props: {
|
|
13
|
-
flat: true,
|
|
14
|
-
theme: 'white'
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
|
-
plain: {
|
|
18
|
-
component: ButtonDeprecated,
|
|
19
|
-
props: {
|
|
20
|
-
flat: true,
|
|
21
|
-
theme: 'brand-dark-blue'
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
yellow: {
|
|
25
|
-
component: ButtonDeprecatedBase,
|
|
26
|
-
props: {}
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* @deprecated
|
|
32
|
-
* This component is in the old visual identity and will be updated soon.
|
|
33
|
-
*
|
|
34
|
-
* Check the [Gamut Board](https://www.notion.so/codecademy/Gamut-Status-Timeline-dd3c135d3848464ea6eb1b48e68fbb1d) for component status
|
|
35
|
-
*/
|
|
36
|
-
|
|
37
|
-
export const AccordionButtonDeprecated = ({
|
|
38
|
-
children,
|
|
39
|
-
className,
|
|
40
|
-
expanded,
|
|
41
|
-
size = 'normal',
|
|
42
|
-
theme = 'plain',
|
|
43
|
-
...baseProps
|
|
44
|
-
}) => {
|
|
45
|
-
const {
|
|
46
|
-
component: ButtonComponent,
|
|
47
|
-
props
|
|
48
|
-
} = buttonThemes[theme];
|
|
49
|
-
const iconSize = size === 'large' ? 30 : undefined;
|
|
50
|
-
return /*#__PURE__*/_jsxs(ButtonComponent, {
|
|
51
|
-
"aria-expanded": expanded,
|
|
52
|
-
className: cx(styles.accordionButton, styles[theme], styles[size], className),
|
|
53
|
-
...baseProps,
|
|
54
|
-
...props,
|
|
55
|
-
children: [/*#__PURE__*/_jsx("span", {
|
|
56
|
-
className: styles.children,
|
|
57
|
-
children: children
|
|
58
|
-
}), /*#__PURE__*/_jsx(ArrowChevronDownIcon, {
|
|
59
|
-
"aria-hidden": true,
|
|
60
|
-
className: cx(styles.expansionIcon, expanded && styles.expansionIconExpanded),
|
|
61
|
-
height: iconSize,
|
|
62
|
-
width: iconSize
|
|
63
|
-
})]
|
|
64
|
-
});
|
|
65
|
-
};
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
// button + class beats ButtonDeprecated .btn / .basicBtn center alignment
|
|
2
|
-
// when CSS module order varies across consuming apps.
|
|
3
|
-
button.accordionButton {
|
|
4
|
-
align-items: center;
|
|
5
|
-
display: flex;
|
|
6
|
-
font-weight: bold;
|
|
7
|
-
justify-content: space-between;
|
|
8
|
-
padding: 0.375rem 1rem;
|
|
9
|
-
text-align: left;
|
|
10
|
-
width: 100%;
|
|
11
|
-
|
|
12
|
-
.children {
|
|
13
|
-
font-weight: bold;
|
|
14
|
-
text-align: left;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
&.blue {
|
|
18
|
-
color: #a5befa;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
&.yellow {
|
|
22
|
-
background-color: #fff2b3;
|
|
23
|
-
border: solid #ffe359;
|
|
24
|
-
border-width: 1px 0;
|
|
25
|
-
transition: background-color 0.15s ease-in-out;
|
|
26
|
-
|
|
27
|
-
&:focus-visible {
|
|
28
|
-
border-color: #b37620;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
&:focus,
|
|
32
|
-
&:hover {
|
|
33
|
-
background-color: #ffec8c;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
&.large {
|
|
38
|
-
border-radius: 2px;
|
|
39
|
-
font-size: 1.5rem;
|
|
40
|
-
|
|
41
|
-
.children {
|
|
42
|
-
padding-top: 0.2rem;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
.expansionIcon {
|
|
46
|
-
margin-left: 1rem;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
@media only screen and (min-width: 64rem) {
|
|
50
|
-
font-size: 1.75rem;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
.expansionIcon {
|
|
56
|
-
margin-left: 0.75rem;
|
|
57
|
-
transition: transform 0.35s ease-out;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
.expansionIconExpanded {
|
|
61
|
-
transform: rotate(-180deg);
|
|
62
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { AccordionButtonSize, AccordionButtonTheme } from '../AccordionButtonDeprecated';
|
|
3
|
-
export type ChildrenOrExpandedRender = React.ReactNode | ((expanded: boolean) => React.ReactNode);
|
|
4
|
-
export type AccordionDeprecatedProps = {
|
|
5
|
-
children: ChildrenOrExpandedRender;
|
|
6
|
-
/**
|
|
7
|
-
* CSS class name added to the root area container.
|
|
8
|
-
*/
|
|
9
|
-
className?: string;
|
|
10
|
-
/**
|
|
11
|
-
* Whether the accordion should start off with expanded state.
|
|
12
|
-
*/
|
|
13
|
-
initiallyExpanded?: boolean;
|
|
14
|
-
/**
|
|
15
|
-
* Called when the top button is clicked.
|
|
16
|
-
*
|
|
17
|
-
* @param expanding - New expanded state the accordion will transition to.
|
|
18
|
-
*/
|
|
19
|
-
onClick?: (expanding: boolean) => void;
|
|
20
|
-
/**
|
|
21
|
-
* Visual size of the top button.
|
|
22
|
-
*/
|
|
23
|
-
size?: AccordionButtonSize;
|
|
24
|
-
/**
|
|
25
|
-
* Visual theme of the top button.
|
|
26
|
-
*/
|
|
27
|
-
theme?: AccordionButtonTheme;
|
|
28
|
-
/**
|
|
29
|
-
* Contents to place within the top button.
|
|
30
|
-
*/
|
|
31
|
-
top: ChildrenOrExpandedRender;
|
|
32
|
-
};
|
|
33
|
-
/**
|
|
34
|
-
* @deprecated
|
|
35
|
-
* This component is in the old visual identity and will be updated soon.
|
|
36
|
-
*
|
|
37
|
-
* Check the [Gamut Board](https://www.notion.so/codecademy/Gamut-Status-Timeline-dd3c135d3848464ea6eb1b48e68fbb1d) for component status
|
|
38
|
-
*/
|
|
39
|
-
export declare const AccordionDeprecated: React.FC<AccordionDeprecatedProps>;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { AccordionAreaDeprecated } from '../AccordionAreaDeprecated';
|
|
4
|
-
import { AccordionButtonDeprecated } from '../AccordionButtonDeprecated';
|
|
5
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
-
/**
|
|
7
|
-
* @deprecated
|
|
8
|
-
* This component is in the old visual identity and will be updated soon.
|
|
9
|
-
*
|
|
10
|
-
* Check the [Gamut Board](https://www.notion.so/codecademy/Gamut-Status-Timeline-dd3c135d3848464ea6eb1b48e68fbb1d) for component status
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
export const AccordionDeprecated = ({
|
|
14
|
-
children,
|
|
15
|
-
className,
|
|
16
|
-
initiallyExpanded,
|
|
17
|
-
onClick,
|
|
18
|
-
size,
|
|
19
|
-
theme,
|
|
20
|
-
top
|
|
21
|
-
}) => {
|
|
22
|
-
const [expanded, setExpanded] = useState(!!initiallyExpanded);
|
|
23
|
-
const expandRenderer = renderer => renderer instanceof Function ? renderer(expanded) : renderer;
|
|
24
|
-
return /*#__PURE__*/_jsx(AccordionAreaDeprecated, {
|
|
25
|
-
className: className,
|
|
26
|
-
expanded: expanded,
|
|
27
|
-
top: /*#__PURE__*/_jsx(AccordionButtonDeprecated, {
|
|
28
|
-
expanded: expanded,
|
|
29
|
-
size: size,
|
|
30
|
-
theme: theme,
|
|
31
|
-
onClick: () => {
|
|
32
|
-
setExpanded(!expanded);
|
|
33
|
-
onClick?.(!expanded);
|
|
34
|
-
},
|
|
35
|
-
children: expandRenderer(top)
|
|
36
|
-
}),
|
|
37
|
-
children: expandRenderer(children)
|
|
38
|
-
});
|
|
39
|
-
};
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import { Box, Text } from '@codecademy/gamut';
|
|
2
|
-
import { useState } from 'react';
|
|
3
|
-
import { Accordion, AccordionBody, AccordionTrigger } from '../../index';
|
|
4
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
5
|
-
const meta = {
|
|
6
|
-
component: Accordion,
|
|
7
|
-
title: 'Molecules/Accordion'
|
|
8
|
-
};
|
|
9
|
-
export default meta;
|
|
10
|
-
export const Default = {
|
|
11
|
-
render: () => /*#__PURE__*/_jsxs(Accordion, {
|
|
12
|
-
children: [/*#__PURE__*/_jsx(AccordionTrigger, {
|
|
13
|
-
children: "Click to expand"
|
|
14
|
-
}), /*#__PURE__*/_jsx(AccordionBody, {
|
|
15
|
-
children: /*#__PURE__*/_jsx(Box, {
|
|
16
|
-
children: /*#__PURE__*/_jsx(Text, {
|
|
17
|
-
children: "Accordion panel content."
|
|
18
|
-
})
|
|
19
|
-
})
|
|
20
|
-
})]
|
|
21
|
-
}),
|
|
22
|
-
name: 'Default (uncontrolled)'
|
|
23
|
-
};
|
|
24
|
-
export const InitiallyExpanded = {
|
|
25
|
-
render: () => /*#__PURE__*/_jsxs(Accordion, {
|
|
26
|
-
initiallyExpanded: true,
|
|
27
|
-
children: [/*#__PURE__*/_jsx(AccordionTrigger, {
|
|
28
|
-
children: "Expanded by default"
|
|
29
|
-
}), /*#__PURE__*/_jsx(AccordionBody, {
|
|
30
|
-
children: /*#__PURE__*/_jsx(Box, {
|
|
31
|
-
children: /*#__PURE__*/_jsx(Text, {
|
|
32
|
-
children: "This panel starts open."
|
|
33
|
-
})
|
|
34
|
-
})
|
|
35
|
-
})]
|
|
36
|
-
}),
|
|
37
|
-
name: 'Initially expanded'
|
|
38
|
-
};
|
|
39
|
-
export const Controlled = {
|
|
40
|
-
render: () => {
|
|
41
|
-
const [isOpen, setIsOpen] = useState(false);
|
|
42
|
-
return /*#__PURE__*/_jsxs(Box, {
|
|
43
|
-
children: [/*#__PURE__*/_jsxs(Text, {
|
|
44
|
-
mb: 8,
|
|
45
|
-
variant: "p-small",
|
|
46
|
-
children: ["Controlled externally \u2014 expanded: ", String(isOpen)]
|
|
47
|
-
}), /*#__PURE__*/_jsxs(Accordion, {
|
|
48
|
-
expanded: isOpen,
|
|
49
|
-
onClick: setIsOpen,
|
|
50
|
-
children: [/*#__PURE__*/_jsx(AccordionTrigger, {
|
|
51
|
-
children: "Controlled accordion"
|
|
52
|
-
}), /*#__PURE__*/_jsx(AccordionBody, {
|
|
53
|
-
children: /*#__PURE__*/_jsx(Box, {
|
|
54
|
-
children: /*#__PURE__*/_jsx(Text, {
|
|
55
|
-
children: "Caller manages expanded state via onToggle."
|
|
56
|
-
})
|
|
57
|
-
})
|
|
58
|
-
})]
|
|
59
|
-
})]
|
|
60
|
-
});
|
|
61
|
-
},
|
|
62
|
-
name: 'Controlled'
|
|
63
|
-
};
|
|
64
|
-
export const WithOnClickCallback = {
|
|
65
|
-
render: () => /*#__PURE__*/_jsxs(Accordion, {
|
|
66
|
-
onClick: next => {
|
|
67
|
-
// eslint-disable-next-line no-console
|
|
68
|
-
console.log('toggled:', next);
|
|
69
|
-
},
|
|
70
|
-
children: [/*#__PURE__*/_jsx(AccordionTrigger, {
|
|
71
|
-
children: "Section with callbacks"
|
|
72
|
-
}), /*#__PURE__*/_jsx(AccordionBody, {
|
|
73
|
-
children: /*#__PURE__*/_jsx(Box, {
|
|
74
|
-
children: /*#__PURE__*/_jsx(Text, {
|
|
75
|
-
children: "Check the console \u2014 onToggle and onClick fire on each toggle."
|
|
76
|
-
})
|
|
77
|
-
})
|
|
78
|
-
})]
|
|
79
|
-
}),
|
|
80
|
-
name: 'With callbacks'
|
|
81
|
-
};
|
|
82
|
-
export const MultipleAccordions = {
|
|
83
|
-
render: () => /*#__PURE__*/_jsx(Box, {
|
|
84
|
-
display: "flex",
|
|
85
|
-
flexDirection: "column",
|
|
86
|
-
gap: 8,
|
|
87
|
-
children: ['Section A', 'Section B', 'Section C'].map(label => /*#__PURE__*/_jsxs(Accordion, {
|
|
88
|
-
children: [/*#__PURE__*/_jsx(AccordionTrigger, {
|
|
89
|
-
children: label
|
|
90
|
-
}), /*#__PURE__*/_jsx(AccordionBody, {
|
|
91
|
-
children: /*#__PURE__*/_jsx(Box, {
|
|
92
|
-
children: /*#__PURE__*/_jsxs(Text, {
|
|
93
|
-
children: ["Content for ", label, ". Each accordion is independent."]
|
|
94
|
-
})
|
|
95
|
-
})
|
|
96
|
-
})]
|
|
97
|
-
}, label))
|
|
98
|
-
}),
|
|
99
|
-
name: 'Multiple independent accordions'
|
|
100
|
-
};
|
|
101
|
-
export const RichContent = {
|
|
102
|
-
render: () => /*#__PURE__*/_jsxs(Accordion, {
|
|
103
|
-
initiallyExpanded: true,
|
|
104
|
-
children: [/*#__PURE__*/_jsx(AccordionTrigger, {
|
|
105
|
-
children: "Frequently asked question"
|
|
106
|
-
}), /*#__PURE__*/_jsx(AccordionBody, {
|
|
107
|
-
children: /*#__PURE__*/_jsxs(Box, {
|
|
108
|
-
children: [/*#__PURE__*/_jsx(Text, {
|
|
109
|
-
variant: "title-xs",
|
|
110
|
-
children: "Answer heading"
|
|
111
|
-
}), /*#__PURE__*/_jsxs(Text, {
|
|
112
|
-
children: ["This body can hold any React content \u2014 text, links, forms, lists, or nested components. The height animates in and out using Gamut's", ' ', "ExpandInCollapseOut primitive."]
|
|
113
|
-
}), /*#__PURE__*/_jsx(Text, {
|
|
114
|
-
variant: "p-small",
|
|
115
|
-
color: "text-secondary",
|
|
116
|
-
children: "Supporting detail with secondary text color."
|
|
117
|
-
})]
|
|
118
|
-
})
|
|
119
|
-
})]
|
|
120
|
-
}),
|
|
121
|
-
name: 'Rich body content'
|
|
122
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { AccordionDeprecated } from '../../index';
|
|
2
|
-
const meta = {
|
|
3
|
-
component: AccordionDeprecated
|
|
4
|
-
};
|
|
5
|
-
export default meta;
|
|
6
|
-
export const Default = {
|
|
7
|
-
args: {
|
|
8
|
-
top: 'Click to expand',
|
|
9
|
-
children: 'Accordion panel content.'
|
|
10
|
-
},
|
|
11
|
-
name: 'AccordionDeprecated'
|
|
12
|
-
};
|
|
13
|
-
export const InitiallyExpanded = {
|
|
14
|
-
args: {
|
|
15
|
-
top: 'Expanded by default',
|
|
16
|
-
children: 'This panel starts open.',
|
|
17
|
-
initiallyExpanded: true
|
|
18
|
-
}
|
|
19
|
-
};
|
package/dist/typings/react.d.ts
DELETED
package/dist/utils/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './omitProps';
|
package/dist/utils/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './omitProps';
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export type RemoveFrom<TContainer, TRemoved> = {
|
|
2
|
-
[P in keyof TContainer]: P extends keyof TRemoved ? never : TContainer[P];
|
|
3
|
-
};
|
|
4
|
-
/**
|
|
5
|
-
* omitProps
|
|
6
|
-
*
|
|
7
|
-
* removes a provided array of props from a props object,
|
|
8
|
-
* leaving necessary props like children intact
|
|
9
|
-
*/
|
|
10
|
-
export declare function omitProps<TOmittedProps extends {}, TProps extends {}>(initialPropsToOmit: TOmittedProps | (keyof TOmittedProps)[], props: TProps): RemoveFrom<TOmittedProps, TProps>;
|
package/dist/utils/omitProps.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import invariant from 'invariant';
|
|
2
|
-
import isPlainObject from 'lodash/isPlainObject';
|
|
3
|
-
import omit from 'lodash/omit';
|
|
4
|
-
import without from 'lodash/without';
|
|
5
|
-
/**
|
|
6
|
-
* omitProps
|
|
7
|
-
*
|
|
8
|
-
* removes a provided array of props from a props object,
|
|
9
|
-
* leaving necessary props like children intact
|
|
10
|
-
*/
|
|
11
|
-
export function omitProps(initialPropsToOmit, props) {
|
|
12
|
-
const propsToOmit = isPlainObject(initialPropsToOmit) ? Object.keys(initialPropsToOmit) : initialPropsToOmit;
|
|
13
|
-
invariant(Array.isArray(propsToOmit), 'omitProps first argument should be an Array');
|
|
14
|
-
|
|
15
|
-
// allow all data-* props, mainly used for testing libraries
|
|
16
|
-
const dataProps = propsToOmit.filter(p => /^data-.*/.exec(p));
|
|
17
|
-
return omit(props, without(propsToOmit, 'children', 'className', ...dataProps));
|
|
18
|
-
}
|