@ndlib/component-library 1.0.44 → 1.0.46
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/composites/Card/Card.stories.js +7 -7
- package/dist/components/composites/Card/Card.test.js +1 -1
- package/dist/components/composites/Card/index.js +10 -10
- package/dist/components/composites/CardV2/CardV2.stories.js +14 -14
- package/dist/components/composites/CardV2/CardV2.test.js +1 -1
- package/dist/components/composites/CardV2/index.js +11 -11
- package/dist/components/composites/DragDropList/DragDrop.test.js +1 -1
- package/dist/components/composites/DragDropList/DragDropList.stories.d.ts +2 -3
- package/dist/components/composites/DragDropList/DragDropList.stories.js +2 -2
- package/dist/components/composites/DragDropList/index.d.ts +1 -2
- package/dist/components/composites/DragDropList/index.js +5 -5
- package/dist/components/composites/DropdownLinks/DropdownLinks.stories.js +3 -3
- package/dist/components/composites/DropdownLinks/DropdownLinks.test.js +1 -1
- package/dist/components/composites/DropdownLinks/index.js +2 -2
- package/dist/components/composites/DropdownLinksV2/DropdownLinksV2.stories.d.ts +8 -0
- package/dist/components/composites/DropdownLinksV2/DropdownLinksV2.stories.js +27 -0
- package/dist/components/composites/DropdownLinksV2/index.d.ts +15 -0
- package/dist/components/composites/DropdownLinksV2/index.js +27 -0
- package/dist/components/composites/EmptyState/EmptyState.stories.js +1 -1
- package/dist/components/composites/EmptyState/index.js +2 -2
- package/dist/components/composites/Modal/Modal.stories.js +2 -2
- package/dist/components/composites/Modal/Modal.test.js +4 -4
- package/dist/components/composites/Modal/index.js +5 -5
- package/dist/components/composites/ModalV2/ModalV2.stories.js +2 -2
- package/dist/components/composites/ModalV2/ModalV2.test.js +4 -4
- package/dist/components/composites/ModalV2/index.js +5 -5
- package/dist/components/composites/NavMenu/demo.js +1 -1
- package/dist/components/composites/NavMenu/index.js +6 -6
- package/dist/components/composites/NavMenuV2/demoV2.js +2 -2
- package/dist/components/composites/NavMenuV2/index.js +4 -4
- package/dist/components/composites/Seo/SeoDataDisplay/index.js +1 -1
- package/dist/components/composites/Seo/index.js +1 -1
- package/dist/components/composites/SnackBar/examples.js +7 -7
- package/dist/components/composites/SnackBar/index.js +4 -4
- package/dist/components/composites/StructuredData/index.d.ts +0 -1
- package/dist/components/composites/StructuredData/index.js +1 -1
- package/dist/components/elements/Alerts/Alerts.stories.js +2 -2
- package/dist/components/elements/Alerts/index.js +2 -2
- package/dist/components/elements/AlertsV2/AlertsV2.stories.js +2 -2
- package/dist/components/elements/AlertsV2/index.js +1 -1
- package/dist/components/elements/ArrowLink/ArrowLink.stories.js +1 -1
- package/dist/components/elements/ArrowLink/ArrowLink.test.js +5 -5
- package/dist/components/elements/ArrowLink/index.d.ts +0 -1
- package/dist/components/elements/ArrowLink/index.js +3 -3
- package/dist/components/elements/ArrowLinkV2/ArrowLinkV2.stories.js +1 -1
- package/dist/components/elements/ArrowLinkV2/index.d.ts +0 -1
- package/dist/components/elements/ArrowLinkV2/index.js +1 -1
- package/dist/components/elements/AutoComplete/AutoComplete.stories.js +1 -1
- package/dist/components/elements/BoxV2/BoxV2.stories.js +1 -1
- package/dist/components/elements/BoxV2/index.d.ts +2 -2
- package/dist/components/elements/BrandingBar/index.d.ts +0 -1
- package/dist/components/elements/BrandingBar/index.js +4 -4
- package/dist/components/elements/BrandingBarV2/index.js +1 -1
- package/dist/components/elements/Button/Button.stories.js +9 -9
- package/dist/components/elements/Button/Button.test.js +1 -1
- package/dist/components/elements/Button/index.d.ts +14 -14
- package/dist/components/elements/Button/index.js +4 -4
- package/dist/components/elements/ButtonV2/ButtonV2.stories.js +9 -9
- package/dist/components/elements/ButtonV2/ButtonV2.test.js +1 -1
- package/dist/components/elements/ButtonV2/index.d.ts +15 -15
- package/dist/components/elements/ButtonV2/index.js +2 -2
- package/dist/components/elements/CheckboxGroup/index.js +2 -2
- package/dist/components/elements/CheckboxGroupV2/index.js +2 -2
- package/dist/components/elements/ColumnV2/index.d.ts +2 -2
- package/dist/components/elements/ColumnV2/index.js +1 -1
- package/dist/components/elements/ConsentBanner/ConsentBanner.stories.js +1 -1
- package/dist/components/elements/ConsentBanner/index.js +4 -4
- package/dist/components/elements/DatePicker/DatePicker.stories.js +3 -3
- package/dist/components/elements/DatePicker/index.d.ts +3 -3
- package/dist/components/elements/DatePickerV2/DatePickerV2.stories.js +3 -3
- package/dist/components/elements/DatePickerV2/index.d.ts +3 -3
- package/dist/components/elements/Dropdown/Dropdown.stories.js +3 -3
- package/dist/components/elements/Dropdown/index.js +2 -2
- package/dist/components/elements/DropdownV2/DropdownV2.stories.js +3 -3
- package/dist/components/elements/DropdownV2/index.js +2 -2
- package/dist/components/elements/Group/index.js +1 -1
- package/dist/components/elements/GroupV2/index.js +1 -1
- package/dist/components/elements/Heading/Heading.stories.js +3 -3
- package/dist/components/elements/Heading/Heading.test.js +2 -2
- package/dist/components/elements/HeadingV2/HeadingV2.stories.js +3 -3
- package/dist/components/elements/HeadingV2/HeadingV2.test.js +2 -2
- package/dist/components/elements/Icon/Icon.stories.js +1 -1
- package/dist/components/elements/IconV2/IconV2.stories.js +1 -1
- package/dist/components/elements/Label/Label.stories.js +1 -1
- package/dist/components/elements/Label/Label.test.js +5 -5
- package/dist/components/elements/LabelV2/LabelV2.stories.js +1 -1
- package/dist/components/elements/LabelV2/LabelV2.test.js +5 -5
- package/dist/components/elements/Link/Link.stories.js +1 -1
- package/dist/components/elements/Link/Link.test.js +7 -7
- package/dist/components/elements/List/List.stories.js +5 -5
- package/dist/components/elements/List/List.test.js +2 -2
- package/dist/components/elements/List/index.js +5 -5
- package/dist/components/elements/ListBox/index.d.ts +2 -17
- package/dist/components/elements/ListBox/index.js +3 -3
- package/dist/components/elements/ListBoxV2/index.d.ts +2 -18
- package/dist/components/elements/ListBoxV2/index.js +2 -2
- package/dist/components/elements/ListV2/ListV2.stories.js +5 -5
- package/dist/components/elements/ListV2/index.js +5 -5
- package/dist/components/elements/Markdown/index.d.ts +0 -1
- package/dist/components/elements/Markdown/index.js +2 -2
- package/dist/components/elements/MarkdownV2/index.d.ts +0 -1
- package/dist/components/elements/MarkdownV2/index.js +2 -2
- package/dist/components/elements/MonthPicker/MonthPicker.stories.js +2 -2
- package/dist/components/elements/MonthPickerV2/MonthPickerV2.stories.js +2 -2
- package/dist/components/elements/Paragraph/Paragraph.stories.js +2 -2
- package/dist/components/elements/ParagraphV2/ParagraphV2.stories.js +2 -2
- package/dist/components/elements/Pill/Pill.stories.js +3 -3
- package/dist/components/elements/Pill/index.d.ts +6 -6
- package/dist/components/elements/Pill/index.js +2 -2
- package/dist/components/elements/PillV2/PillV2.stories.js +3 -3
- package/dist/components/elements/PillV2/index.d.ts +6 -6
- package/dist/components/elements/PillV2/index.js +1 -1
- package/dist/components/elements/RadioGroup/index.js +2 -2
- package/dist/components/elements/RadioGroupV2/index.js +2 -2
- package/dist/components/elements/RawHtml/index.d.ts +0 -1
- package/dist/components/elements/ReadMore/ReadMore.stories.js +4 -4
- package/dist/components/elements/ReadMore/index.js +3 -3
- package/dist/components/elements/ReadMoreV2/ReadMoreV2.stories.js +4 -4
- package/dist/components/elements/ReadMoreV2/index.js +3 -3
- package/dist/components/elements/RowV2/index.d.ts +4 -4
- package/dist/components/elements/RowV2/index.js +1 -1
- package/dist/components/elements/Select/Select.stories.js +3 -3
- package/dist/components/elements/Select/index.js +7 -7
- package/dist/components/elements/SelectV2/SelectV2.stories.js +3 -3
- package/dist/components/elements/SelectV2/index.js +4 -4
- package/dist/components/elements/Spinner/Spinner.stories.js +1 -1
- package/dist/components/elements/Spinner/index.d.ts +0 -1
- package/dist/components/elements/SpinnerV2/SpinnerV2.stories.js +1 -1
- package/dist/components/elements/SpinnerV2/index.d.ts +0 -1
- package/dist/components/elements/TabList/example.js +2 -2
- package/dist/components/elements/TabList/index.js +2 -2
- package/dist/components/elements/TabListV2/example.js +2 -2
- package/dist/components/elements/TabListV2/index.js +2 -2
- package/dist/components/elements/Table/Table.stories.js +18 -18
- package/dist/components/elements/Table/Table.test.js +1 -1
- package/dist/components/elements/Table/index.d.ts +0 -1
- package/dist/components/elements/Table/index.js +8 -8
- package/dist/components/elements/TextInput/TextInput.stories.js +4 -4
- package/dist/components/elements/TextInput/TextInput.test.js +2 -2
- package/dist/components/elements/TextInput/index.d.ts +10 -10
- package/dist/components/elements/TextInput/index.js +7 -7
- package/dist/components/elements/TextInputV2/TextInputV2.stories.js +4 -4
- package/dist/components/elements/TextInputV2/TextInputV2.test.js +1 -1
- package/dist/components/elements/TextInputV2/index.d.ts +11 -11
- package/dist/components/elements/TextInputV2/index.js +4 -4
- package/dist/components/elements/layout/Box.d.ts +2 -2
- package/dist/components/elements/layout/Box.stories.js +1 -1
- package/dist/components/elements/layout/Column.d.ts +2 -2
- package/dist/components/elements/layout/Column.js +1 -1
- package/dist/components/elements/layout/Flex.stories.js +4 -4
- package/dist/components/elements/layout/Flex.test.js +2 -2
- package/dist/components/elements/layout/Row.d.ts +3 -3
- package/dist/components/elements/layout/Row.js +1 -1
- package/dist/components/elements/option.d.ts +0 -1
- package/dist/components/providers/alerts.js +1 -1
- package/dist/components/providers/componentConfig.js +1 -1
- package/dist/components/providers/componentConfigV2.js +1 -1
- package/dist/components/providers/dialogs.js +2 -2
- package/dist/components/providers/env.js +2 -2
- package/dist/components/providers/media.js +2 -2
- package/dist/components/providers/mediaV2.js +2 -2
- package/dist/components/providers/menu.js +1 -1
- package/dist/components/providers/snackBar.d.ts +0 -1
- package/dist/components/providers/snackBar.js +2 -2
- package/dist/components/providers/ui.js +1 -1
- package/dist/components/providers/uiV2.js +1 -1
- package/dist/components/providers/uniqueIds.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/theme/Color.stories.js +1 -1
- package/dist/theme/Typography.stories.js +1 -1
- package/dist/theme/colors.d.ts +2 -2
- package/dist/theme/colors.js +4 -2
- package/dist/theme/css-variables.css +2 -2
- package/dist/theme/index.d.ts +7 -90
- package/dist/theme/index.js +2 -2
- package/dist/theme/typography.d.ts +1 -1
- package/dist/utils/test.js +2 -2
- package/package.json +5 -5
|
@@ -82,21 +82,21 @@ const horizontalCards = [
|
|
|
82
82
|
headline: 'Exhibit — Printing the Nation: A Century of Irish Book Arts',
|
|
83
83
|
image: 'https://images.ctfassets.net/cfblb1f7i85j/7aCd5Sm86JdtQepGBKDUfy/dcb4d97dd3a1d3ee810e8bcaa82dc715/Spring_Exhibit_2023-Rep.jpg?w=296',
|
|
84
84
|
size: CARD_SIZE.SM,
|
|
85
|
-
children: (_jsxs(_Fragment, { children: [_jsxs(Label,
|
|
85
|
+
children: (_jsxs(_Fragment, { children: [_jsxs(Label, { color: COLOR.PRIMARY, size: LABEL_SIZE.SM, sx: {
|
|
86
86
|
display: 'flex',
|
|
87
|
-
}
|
|
87
|
+
}, children: [_jsx(Icon, { icon: CalendarIcon, sx: { mr: 1 } }), "Monday, February 6 \u2013 Monday, July 31, 2023"] }), _jsxs(Label, { color: COLOR.PRIMARY, size: LABEL_SIZE.SM, sx: {
|
|
88
88
|
display: 'flex',
|
|
89
|
-
}
|
|
89
|
+
}, children: [_jsx(Icon, { icon: AccessTime, sx: { mr: 1 } }), "M-F: 9:30am \u2013 4:30pm"] }), _jsx(Paragraph, { children: "This exhibit demonstrates the art and craft of the Irish book since 1900." })] })),
|
|
90
90
|
},
|
|
91
91
|
{
|
|
92
92
|
headline: 'One Book, One Michiana Digital Exhibit — Papers Alight: Contextualizing Mike Curato’s Flamer',
|
|
93
93
|
image: 'https://images.ctfassets.net/cfblb1f7i85j/2sGpdDbNkl6MPnlem6wq1R/995c786624613b5ff07228e481996385/One.Book.2023-Rep.png?w=296',
|
|
94
94
|
size: CARD_SIZE.SM,
|
|
95
|
-
children: ({ activeBackground }) => (_jsxs(_Fragment, { children: [_jsxs(Label,
|
|
95
|
+
children: ({ activeBackground }) => (_jsxs(_Fragment, { children: [_jsxs(Label, { color: COLOR.PRIMARY, size: LABEL_SIZE.SM, sx: {
|
|
96
96
|
display: 'flex',
|
|
97
|
-
}
|
|
97
|
+
}, children: [_jsx(Icon, { icon: CalendarIcon, sx: { mr: 1 } }), "Monday, February 6 \u2013 Monday, July 31, 2023"] }), _jsxs(Label, { color: COLOR.PRIMARY, size: LABEL_SIZE.SM, sx: {
|
|
98
98
|
display: 'flex',
|
|
99
|
-
}
|
|
99
|
+
}, children: [_jsx(Icon, { icon: AccessTime, sx: { mr: 1 } }), "M-F: 9:30am \u2013 4:30pm"] }), _jsx(ReadMore, { typography: TYPOGRAPHY_TYPE.PARAGRAPH_MEDIUM, lines: 2, sx: { bg: activeBackground }, children: "This online exhibition displays rare materials from Hesburgh Libraries collections that place Mike Curato\u2019s teen graphic novel into a historical and social context." })] })),
|
|
100
100
|
},
|
|
101
101
|
];
|
|
102
102
|
export const Default = {
|
|
@@ -134,7 +134,7 @@ export const Raised = {
|
|
|
134
134
|
args: {},
|
|
135
135
|
};
|
|
136
136
|
export const Heading = {
|
|
137
|
-
render: () => (_jsx(Column, { children: basicCards.map((props, i) => (_createElement(Card, Object.assign({}, props, { key: i, heading: "Heading", headingIcon: BookmarkIcon, headingAction: _jsx(Button,
|
|
137
|
+
render: () => (_jsx(Column, { children: basicCards.map((props, i) => (_createElement(Card, Object.assign({}, props, { key: i, heading: "Heading", headingIcon: BookmarkIcon, headingAction: _jsx(Button, { type: BUTTON_TYPE.TEXT, color: COLOR.WHITE, onClick: () => { }, children: "Click Me" }) })))) })),
|
|
138
138
|
args: {},
|
|
139
139
|
};
|
|
140
140
|
export const CustomImageHeading = {
|
|
@@ -13,7 +13,7 @@ describe('Card', () => {
|
|
|
13
13
|
vi.resetAllMocks();
|
|
14
14
|
});
|
|
15
15
|
it('renders contents', () => {
|
|
16
|
-
const { getByText } = render(_jsx(Card,
|
|
16
|
+
const { getByText } = render(_jsx(Card, { headline: MOCK_HEADLINE, children: MOCK_BODY }));
|
|
17
17
|
expect(getByText(MOCK_HEADLINE)).toBeDefined();
|
|
18
18
|
expect(getByText(MOCK_BODY)).toBeDefined();
|
|
19
19
|
});
|
|
@@ -39,18 +39,18 @@ const DateDisplay = ({ date: dateString }) => {
|
|
|
39
39
|
const date = React.useMemo(() => {
|
|
40
40
|
return new Date(dateString);
|
|
41
41
|
}, [dateString]);
|
|
42
|
-
return (_jsxs(Column,
|
|
42
|
+
return (_jsxs(Column, { sx: {
|
|
43
43
|
alignItems: 'center',
|
|
44
44
|
justifyContent: 'center',
|
|
45
45
|
p: 3,
|
|
46
46
|
fontFamily: FONT.BRANDED2,
|
|
47
47
|
backgroundColor: COLOR.ND_GOLD_LIGHT,
|
|
48
|
-
}
|
|
48
|
+
}, children: [_jsx(Box, { sx: {
|
|
49
49
|
fontSize: FONT_SIZE.LG,
|
|
50
|
-
}
|
|
50
|
+
}, children: date.getDate() }), _jsx(Box, { sx: {
|
|
51
51
|
fontSize: FONT_SIZE.MD,
|
|
52
52
|
mt: 1,
|
|
53
|
-
}
|
|
53
|
+
}, children: MONTH_LABELS[date.getMonth()] })] }));
|
|
54
54
|
};
|
|
55
55
|
export const Card = ({ size, displayDate, headline, image, alt, layout, onClick, raised, truncateHeadlineAfter, heading, headlineStyles, headingStyles, headingIcon, headingAction, backgroundColor, sx, imageHeight: imageHeightProp, imageWidth: imageWidthProp, containImage, containerWidth, containerHeight, children, }) => {
|
|
56
56
|
var _a;
|
|
@@ -93,25 +93,25 @@ export const Card = ({ size, displayDate, headline, image, alt, layout, onClick,
|
|
|
93
93
|
borderColor: COLOR.ND_SKY_BLUE_DARK,
|
|
94
94
|
backgroundColor: COLOR.ND_SKY_BLUE,
|
|
95
95
|
}
|
|
96
|
-
: {} }, sx)
|
|
96
|
+
: {} }, sx), children: [image && !containImage && (_jsx("img", { src: image, alt: alt, style: {
|
|
97
97
|
width: imageWidth,
|
|
98
98
|
height: imageHeight,
|
|
99
|
-
} })), image && containImage && (_jsx(Box,
|
|
99
|
+
} })), image && containImage && (_jsx(Box, { sx: {
|
|
100
100
|
width: containerWidth || '500px',
|
|
101
101
|
height: containerHeight || '280px',
|
|
102
102
|
backgroundColor: COLOR.ND_SKY_BLUE,
|
|
103
103
|
display: 'flex',
|
|
104
104
|
justifyContent: 'center',
|
|
105
105
|
alignItems: 'center',
|
|
106
|
-
}
|
|
106
|
+
}, children: _jsx("img", { src: image, alt: alt, style: {
|
|
107
107
|
width: imageWidth,
|
|
108
108
|
height: imageHeight,
|
|
109
109
|
objectFit: objectFit,
|
|
110
|
-
} }) }))
|
|
110
|
+
} }) })), displayDate && _jsx(DateDisplay, { date: displayDate }), heading && (_jsxs(Row, { sx: Object.assign({ bg: COLOR.PRIMARY, color: COLOR.WHITE, width: '100%', px: contentPaddingX, py: 3, justifyContent: 'space-between', alignItems: 'center' }, headingStyles), children: [_jsxs(Row, { children: [headingIcon && (_jsx(Icon, { icon: headingIcon, size: FONT_SIZE.LG, color: COLOR.WHITE, sx: { mr: 2 } })), _jsx(Heading, { size: HEADING_SIZE.SM, sx: {
|
|
111
111
|
color: COLOR.WHITE,
|
|
112
112
|
mt: 0,
|
|
113
113
|
whiteSpace: 'nowrap',
|
|
114
|
-
}
|
|
114
|
+
}, children: heading })] }), _jsx(Row, { children: headingAction && headingAction })] })), _jsx(Row, { sx: { px: contentPaddingX, py: contentPaddingY }, children: _jsxs(Column, { justify: "center", children: [headline && (_jsx(Heading, { typography: typography, sx: Object.assign({ mt: 0 }, headlineStyles), children: truncateHeadlineAfter ? (_jsx(ReadMore, { lines: truncateHeadlineAfter, typography: typography, sx: { bg: activeBackground }, children: headline })) : (headline) })), children && (_jsx(Box, { sx: { mt: headline && !heading ? 2 : 0 }, children: typeof children === 'function'
|
|
115
115
|
? children({ isHovered, activeBackground })
|
|
116
|
-
: children }))
|
|
116
|
+
: children }))] }) })] })));
|
|
117
117
|
};
|
|
@@ -84,24 +84,24 @@ const horizontalCards = [
|
|
|
84
84
|
headline: 'Exhibit — Printing the Nation: A Century of Irish Book Arts',
|
|
85
85
|
image: 'https://images.ctfassets.net/cfblb1f7i85j/7aCd5Sm86JdtQepGBKDUfy/dcb4d97dd3a1d3ee810e8bcaa82dc715/Spring_Exhibit_2023-Rep.jpg?w=296',
|
|
86
86
|
size: CARDV2_SIZE.SM,
|
|
87
|
-
children: (_jsxs(_Fragment, { children: [_jsxs(LabelV2,
|
|
87
|
+
children: (_jsxs(_Fragment, { children: [_jsxs(LabelV2, { color: COLOR.PRIMARY, size: LABELV2_SIZE.SM, sx: {
|
|
88
88
|
display: 'flex',
|
|
89
|
-
}
|
|
89
|
+
}, children: [_jsx(IconV2, { icon: CalendarIcon, sx: { mr: 1 } }), "Monday, February 6 \u2013 Monday, July 31, 2023"] }), _jsxs(LabelV2, { color: COLOR.PRIMARY, size: LABELV2_SIZE.SM, sx: {
|
|
90
90
|
display: 'flex',
|
|
91
|
-
}
|
|
91
|
+
}, children: [_jsx(IconV2, { icon: AccessTime, sx: { mr: 1 } }), "M-F: 9:30am \u2013 4:30pm"] }), _jsx(ParagraphV2, { children: "This exhibit demonstrates the art and craft of the Irish book since 1900." })] })),
|
|
92
92
|
},
|
|
93
93
|
{
|
|
94
94
|
headline: 'One Book, One Michiana Digital Exhibit — Papers Alight: Contextualizing Mike Curato’s Flamer',
|
|
95
95
|
image: 'https://images.ctfassets.net/cfblb1f7i85j/2sGpdDbNkl6MPnlem6wq1R/995c786624613b5ff07228e481996385/One.Book.2023-Rep.png?w=296',
|
|
96
96
|
size: CARDV2_SIZE.SM,
|
|
97
|
-
children: (_jsxs(_Fragment, { children: [_jsxs(LabelV2,
|
|
97
|
+
children: (_jsxs(_Fragment, { children: [_jsxs(LabelV2, { color: COLOR.PRIMARY, size: LABELV2_SIZE.SM, sx: {
|
|
98
98
|
display: 'flex',
|
|
99
|
-
}
|
|
99
|
+
}, children: [_jsx(IconV2, { icon: CalendarIcon, sx: { mr: 1 } }), "Monday, February 6 \u2013 Monday, July 31, 2023"] }), _jsxs(LabelV2, { color: COLOR.PRIMARY, size: LABELV2_SIZE.SM, sx: {
|
|
100
100
|
display: 'flex',
|
|
101
|
-
}
|
|
101
|
+
}, children: [_jsx(IconV2, { icon: AccessTime, sx: { mr: 1 } }), "M-F: 9:30am \u2013 4:30pm"] }), _jsx(ReadMoreV2, { typography: TYPOGRAPHY_TYPE.PARAGRAPH_MEDIUM, lines: 2, children: "This online exhibition displays rare materials from Hesburgh Libraries collections that place Mike Curato\u2019s teen graphic novel into a historical and social context." })] })),
|
|
102
102
|
},
|
|
103
103
|
];
|
|
104
|
-
const leftBadge = (_jsx(BoxV2,
|
|
104
|
+
const leftBadge = (_jsx(BoxV2, { sx: {
|
|
105
105
|
width: '40px',
|
|
106
106
|
height: '40px',
|
|
107
107
|
borderRadius: '50%',
|
|
@@ -109,8 +109,8 @@ const leftBadge = (_jsx(BoxV2, Object.assign({ sx: {
|
|
|
109
109
|
alignItems: 'center',
|
|
110
110
|
justifyContent: 'center',
|
|
111
111
|
bg: COLOR.ND_BLUE,
|
|
112
|
-
}
|
|
113
|
-
const rightBadge = (_jsx(BoxV2,
|
|
112
|
+
}, children: _jsx(IconV2, { icon: CollectionsBookmark, size: FONT_SIZE.MD, color: COLOR.WHITE }) }));
|
|
113
|
+
const rightBadge = (_jsx(BoxV2, { sx: {
|
|
114
114
|
width: '40px',
|
|
115
115
|
height: '40px',
|
|
116
116
|
borderRadius: '4px',
|
|
@@ -121,7 +121,7 @@ const rightBadge = (_jsx(BoxV2, Object.assign({ sx: {
|
|
|
121
121
|
borderColor: COLOR.ND_BLUE,
|
|
122
122
|
borderWidth: '1px',
|
|
123
123
|
borderStyle: 'solid',
|
|
124
|
-
}
|
|
124
|
+
}, children: _jsx(IconV2, { icon: Bookmark, size: FONT_SIZE.MD, color: COLOR.ND_BLUE }) }));
|
|
125
125
|
export const Default = {
|
|
126
126
|
render: () => (_jsx(ColumnV2, { children: headlinedCards.map((props, i) => (_createElement(CardV2, Object.assign({}, props, { key: i })))) })),
|
|
127
127
|
args: {},
|
|
@@ -161,7 +161,7 @@ export const Raised = {
|
|
|
161
161
|
args: {},
|
|
162
162
|
};
|
|
163
163
|
export const Heading = {
|
|
164
|
-
render: () => (_jsx(ColumnV2, { children: basicCards.map((props, i) => (_createElement(CardV2, Object.assign({}, props, { key: i, heading: "Heading", headingIcon: BookmarkIcon, headingAction: _jsx(ButtonV2,
|
|
164
|
+
render: () => (_jsx(ColumnV2, { children: basicCards.map((props, i) => (_createElement(CardV2, Object.assign({}, props, { key: i, heading: "Heading", headingIcon: BookmarkIcon, headingAction: _jsx(ButtonV2, { type: BUTTONV2_TYPE.TEXT, color: COLOR.WHITE, onClick: () => { }, children: "Click Me" }) })))) })),
|
|
165
165
|
args: {},
|
|
166
166
|
};
|
|
167
167
|
export const CustomImageHeading = {
|
|
@@ -174,14 +174,14 @@ export const CustomImageHeading = {
|
|
|
174
174
|
args: {},
|
|
175
175
|
};
|
|
176
176
|
export const LeftBadge = {
|
|
177
|
-
render: () => (_jsx(ColumnV2,
|
|
177
|
+
render: () => (_jsx(ColumnV2, { sx: { ml: '1.5rem' }, children: headlinedCards.map((props, i) => (_createElement(CardV2, Object.assign({ containImage: true, containerHeight: '280px', leftBadge: leftBadge }, props, { key: i })))) })),
|
|
178
178
|
args: {},
|
|
179
179
|
};
|
|
180
180
|
export const RightBadge = {
|
|
181
|
-
render: () => (_jsx(ColumnV2,
|
|
181
|
+
render: () => (_jsx(ColumnV2, { sx: { ml: '1.5rem' }, children: headlinedCards.map((props, i) => (_createElement(CardV2, Object.assign({ containImage: true, containerHeight: '280px', rightBadge: rightBadge }, props, { key: i })))) })),
|
|
182
182
|
args: {},
|
|
183
183
|
};
|
|
184
184
|
export const LeftAndRightBadges = {
|
|
185
|
-
render: () => (_jsx(ColumnV2,
|
|
185
|
+
render: () => (_jsx(ColumnV2, { sx: { ml: '1.5rem' }, children: headlinedCards.map((props, i) => (_createElement(CardV2, Object.assign({ containImage: true, containerHeight: '280px', leftBadge: leftBadge, rightBadge: rightBadge }, props, { key: i })))) })),
|
|
186
186
|
args: {},
|
|
187
187
|
};
|
|
@@ -12,7 +12,7 @@ describe('CardV2', () => {
|
|
|
12
12
|
vi.resetAllMocks();
|
|
13
13
|
});
|
|
14
14
|
it('renders contents', () => {
|
|
15
|
-
const { getByText } = render(_jsx(CardV2,
|
|
15
|
+
const { getByText } = render(_jsx(CardV2, { headline: MOCK_HEADLINE, children: MOCK_BODY }));
|
|
16
16
|
expect(getByText(MOCK_HEADLINE)).toBeDefined();
|
|
17
17
|
expect(getByText(MOCK_BODY)).toBeDefined();
|
|
18
18
|
});
|
|
@@ -40,15 +40,15 @@ const DateDisplay = ({ date: dateString }) => {
|
|
|
40
40
|
const date = React.useMemo(() => {
|
|
41
41
|
return new Date(dateString);
|
|
42
42
|
}, [dateString]);
|
|
43
|
-
return (_jsxs(ColumnV2,
|
|
43
|
+
return (_jsxs(ColumnV2, { className: typeSafeStyles.dateWrapper, sx: {
|
|
44
44
|
fontFamily: FONT.BRANDED2,
|
|
45
45
|
boxShadow: BOX_SHADOW.EMPHASIZED,
|
|
46
|
-
}
|
|
46
|
+
}, children: [_jsx(BoxV2, { sx: {
|
|
47
47
|
fontSize: FONT_SIZE.LG,
|
|
48
|
-
}
|
|
48
|
+
}, children: date.getDate() }), _jsx(BoxV2, { sx: {
|
|
49
49
|
fontSize: FONT_SIZE.MD,
|
|
50
50
|
marginTop: '0.25rem',
|
|
51
|
-
}
|
|
51
|
+
}, children: MONTH_LABELS[date.getMonth()] })] }));
|
|
52
52
|
};
|
|
53
53
|
export const CardV2 = ({ size, displayDate, headline, image, alt, layout, onClick, raised, truncateHeadlineAfter, heading, headlineStyles, headingStyles, headingIcon, headingAction, backgroundColor, leftBadge, rightBadge, className, shouldShowHoverStyle, imageHeight: imageHeightProp, imageWidth: imageWidthProp, containImage, containerWidth, containerHeight, inlineStyles, children, }) => {
|
|
54
54
|
const contentPaddingX = size === CARDV2_SIZE.SM ? 3 : 4;
|
|
@@ -77,23 +77,23 @@ export const CardV2 = ({ size, displayDate, headline, image, alt, layout, onClic
|
|
|
77
77
|
const baseCardClass = onClick || shouldShowHoverStyle
|
|
78
78
|
? typeSafeStyles.groupCardWrapperWithHover
|
|
79
79
|
: typeSafeStyles.groupCardWrapper;
|
|
80
|
-
return (_jsxs(GroupV2,
|
|
80
|
+
return (_jsxs(GroupV2, { type: headline || heading ? GROUPV2_TYPE.REGION : GROUPV2_TYPE.GROUP, role: onClick ? 'button' : 'group', onClick: onClick, onKeyDown: (e) => {
|
|
81
81
|
if (onClick && e.key === KEY_CODES.ENTER) {
|
|
82
82
|
onClick();
|
|
83
83
|
}
|
|
84
|
-
}, tabIndex: onClick ? 0 : undefined, className: clsx(baseCardClass, className), sx: Object.assign({ boxShadow: raised || heading ? BOX_SHADOW.NORMAL : undefined, width: !isVertical && '100%', backgroundColor: backgroundColor ? backgroundColor : '', flexDirection: layout === CARDV2_LAYOUT.HORIZONTAL ? 'row' : 'column' }, inlineStyles)
|
|
84
|
+
}, tabIndex: onClick ? 0 : undefined, className: clsx(baseCardClass, className), sx: Object.assign({ boxShadow: raised || heading ? BOX_SHADOW.NORMAL : undefined, width: !isVertical && '100%', backgroundColor: backgroundColor ? backgroundColor : '', flexDirection: layout === CARDV2_LAYOUT.HORIZONTAL ? 'row' : 'column' }, inlineStyles), children: [leftBadge && (_jsx(BoxV2, { className: typeSafeStyles.leftBadge, children: leftBadge })), rightBadge && (_jsx(BoxV2, { className: typeSafeStyles.rightBadge, children: rightBadge })), image && !containImage && (_jsx("img", { src: image, alt: alt, style: {
|
|
85
85
|
width: imageWidth,
|
|
86
86
|
height: imageHeight,
|
|
87
|
-
} })), image && containImage && (_jsx(BoxV2,
|
|
87
|
+
} })), image && containImage && (_jsx(BoxV2, { className: typeSafeStyles.containImageContainer, sx: {
|
|
88
88
|
width: containerWidth ? containerWidth : '',
|
|
89
89
|
height: containerHeight ? containerHeight : '',
|
|
90
|
-
}
|
|
90
|
+
}, children: _jsx("img", { src: image, alt: alt, style: {
|
|
91
91
|
width: imageWidth,
|
|
92
92
|
height: imageHeight,
|
|
93
93
|
objectFit: objectFit,
|
|
94
|
-
} }) }))
|
|
94
|
+
} }) })), displayDate && _jsx(DateDisplay, { date: displayDate }), heading && (_jsxs(RowV2, { className: typeSafeStyles.headingOuterWrapper, sx: Object.assign({}, headingStyles), children: [_jsxs(RowV2, { align: "center", sx: { px: contentPaddingX }, children: [headingIcon && (_jsx(IconV2, { icon: headingIcon, size: FONT_SIZE.LG, color: COLOR.WHITE, className: typeSafeStyles.icon })), _jsx(HeadingV2, { size: HEADINGV2_SIZE.SM, className: typeSafeStyles.heading, sx: {
|
|
95
95
|
mt: 0,
|
|
96
|
-
}
|
|
96
|
+
}, children: heading })] }), _jsx(RowV2, { align: "center", sx: { px: contentPaddingX }, children: headingAction && headingAction })] })), _jsx(RowV2, { sx: { px: contentPaddingX, py: contentPaddingY }, children: _jsxs(ColumnV2, { justify: "center", children: [headline && (_jsx(HeadingV2, { typography: typography, sx: Object.assign({ mt: 0, display: '-webkit-box', WebkitBoxOrient: 'vertical', overflow: 'hidden', WebkitLineClamp: truncateHeadlineAfter
|
|
97
97
|
? truncateHeadlineAfter
|
|
98
|
-
: 0 }, headlineStyles)
|
|
98
|
+
: 0 }, headlineStyles), children: headline })), children && (_jsx(BoxV2, { sx: { mt: headline && !heading ? 2 : 0 }, children: children }))] }) })] }));
|
|
99
99
|
};
|
|
@@ -12,7 +12,7 @@ describe('DragDropList component', () => {
|
|
|
12
12
|
expect(container).toBeInTheDocument();
|
|
13
13
|
});
|
|
14
14
|
it('should render items correctly', () => {
|
|
15
|
-
const { getByText } = render(_jsx(DragDropList, { items: items, onReorder: () => { }, children: ({ item }) => _jsx("div", { children: item.accessibleLabel }) }));
|
|
15
|
+
const { getByText } = render(_jsx(DragDropList, { items: items, onReorder: () => { }, children: ({ item }) => (_jsx("div", { children: item.accessibleLabel })) }));
|
|
16
16
|
items.forEach((item) => {
|
|
17
17
|
expect(getByText(item.accessibleLabel)).toBeInTheDocument();
|
|
18
18
|
});
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
|
|
3
|
-
declare const meta: Meta<typeof DragDropList>;
|
|
2
|
+
declare const meta: Meta;
|
|
4
3
|
export default meta;
|
|
5
|
-
type Story = StoryObj
|
|
4
|
+
type Story = StoryObj;
|
|
6
5
|
export declare const Default: Story;
|
|
7
6
|
export declare const Disabled: Story;
|
|
@@ -27,8 +27,8 @@ const StateManager = ({ children }) => {
|
|
|
27
27
|
return _jsx(_Fragment, { children: children({ items, setItems }) });
|
|
28
28
|
};
|
|
29
29
|
export const Default = {
|
|
30
|
-
render: () => (_jsx(StateManager, { children: ({ items, setItems }) => (_jsx(DragDropList,
|
|
30
|
+
render: () => (_jsx(StateManager, { children: ({ items, setItems }) => (_jsx(DragDropList, { items: items, onReorder: ({ reorderedList }) => setItems(reorderedList), children: ({ item }) => (_jsx(_Fragment, { children: _jsx(Paragraph, { sx: { ml: 2 }, children: item.label }) })) })) })),
|
|
31
31
|
};
|
|
32
32
|
export const Disabled = {
|
|
33
|
-
render: () => (_jsx(DragDropList,
|
|
33
|
+
render: () => (_jsx(DragDropList, { disabled: true, items: _items, onReorder: () => { }, children: ({ item }) => (_jsxs(_Fragment, { children: [_jsx(DragHandle, {}), _jsx(Paragraph, { sx: { ml: 2 }, children: item.label })] })) })),
|
|
34
34
|
};
|
|
@@ -10,7 +10,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
-
import { DragDropContext, Droppable, Draggable, } from '
|
|
13
|
+
import { DragDropContext, Droppable, Draggable, } from '@hello-pangea/dnd';
|
|
14
14
|
import _DragIndicator from '@mui/icons-material/DragIndicator';
|
|
15
15
|
import { BUTTON_TYPE, Button } from '../../elements/Button';
|
|
16
16
|
import { Column } from '../../elements/layout/Column';
|
|
@@ -24,7 +24,7 @@ export const DragHandle = (_a) => {
|
|
|
24
24
|
};
|
|
25
25
|
export function DragDropList({ items, itemIdKey = 'id', wrapperStyles, itemStyles, children: renderChild, onReorder, disabled, }) {
|
|
26
26
|
const id = useUniqueId('dnd-list');
|
|
27
|
-
return (_jsx(DragDropContext,
|
|
27
|
+
return (_jsx(DragDropContext, { onDragStart: (start, provided) => {
|
|
28
28
|
const selectedItem = items.find((item) => String(item[itemIdKey]) === start.draggableId);
|
|
29
29
|
provided.announce(`Selected item: ${selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.accessibleLabel}`);
|
|
30
30
|
}, onDragEnd: (e) => {
|
|
@@ -39,10 +39,10 @@ export function DragDropList({ items, itemIdKey = 'id', wrapperStyles, itemStyle
|
|
|
39
39
|
dropEvent: e,
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
|
-
}
|
|
42
|
+
}, children: _jsx(Droppable, { droppableId: id, children: (droppable) => (_jsx(Column, Object.assign({}, droppable.droppableProps, { sx: wrapperStyles, ref: droppable.innerRef, children: _jsxs(_Fragment, { children: [items.map((item, index) => (_jsx(Draggable, { draggableId: String(item[itemIdKey]), isDragDisabled: disabled, index: index, children: (draggable) => {
|
|
43
43
|
return (_jsx(Row, Object.assign({ sx: {
|
|
44
44
|
alignItems: 'center',
|
|
45
45
|
itemStyles,
|
|
46
|
-
}, ref: draggable.innerRef }, draggable.draggableProps, draggable.dragHandleProps, { "aria-describedby": `item-${index}
|
|
47
|
-
} }
|
|
46
|
+
}, ref: draggable.innerRef }, draggable.draggableProps, draggable.dragHandleProps, { "aria-describedby": `item-${index}`, children: _jsx(Row, { sx: { mt: 1 }, id: `item-${index}`, children: renderChild({ item, index }) }) })));
|
|
47
|
+
} }, String(item[itemIdKey])))), droppable.placeholder] }) }))) }) }));
|
|
48
48
|
}
|
|
@@ -17,11 +17,11 @@ const options = [
|
|
|
17
17
|
{ value: 'https://facebook.com', label: 'This is intentionally long' },
|
|
18
18
|
];
|
|
19
19
|
export const Default = {
|
|
20
|
-
render: () => (_jsx(Box,
|
|
20
|
+
render: () => (_jsx(Box, { sx: { width: '200px', height: '200px' }, children: _jsx(DropdownLinks, { options: options, children: ({ anchorProps }) => (_jsx(Button, Object.assign({}, anchorProps, { rightIcon: ArrowDropDownIcon, children: "Links" }))) }) })),
|
|
21
21
|
};
|
|
22
22
|
export const Right = {
|
|
23
|
-
render: () => (_jsx(Row,
|
|
23
|
+
render: () => (_jsx(Row, { sx: { width: '90vw', height: '200px' }, justify: "flex-end", children: _jsx(DropdownLinks, { options: options, children: ({ anchorProps }) => (_jsx(Button, Object.assign({}, anchorProps, { rightIcon: ArrowDropDownIcon, children: "Links" }))) }) })),
|
|
24
24
|
};
|
|
25
25
|
export const OpenInNewTab = {
|
|
26
|
-
render: () => (_jsx(Box,
|
|
26
|
+
render: () => (_jsx(Box, { sx: { width: '200px', height: '200px' }, children: _jsx(DropdownLinks, { options: options, openNewTab: true, children: ({ anchorProps }) => _jsx(Button, Object.assign({}, anchorProps, { children: "Links" })) }) })),
|
|
27
27
|
};
|
|
@@ -7,7 +7,7 @@ const options = [
|
|
|
7
7
|
{ value: 'https://google.com', label: 'Google' },
|
|
8
8
|
{ value: 'https://facebook.com', label: 'Facebook' },
|
|
9
9
|
];
|
|
10
|
-
const DropdownExample = (_jsx(DropdownLinks,
|
|
10
|
+
const DropdownExample = (_jsx(DropdownLinks, { options: options, children: ({ anchorProps }) => _jsx(Button, Object.assign({}, anchorProps, { children: "Links" })) }));
|
|
11
11
|
describe('DropdownLinks', () => {
|
|
12
12
|
it('toggle links when button is clicked', () => {
|
|
13
13
|
const { getByRole, getAllByRole } = render(DropdownExample);
|
|
@@ -7,9 +7,9 @@ export const DropdownLinks = ({ children, options: optionsParam, renderOption: r
|
|
|
7
7
|
const { navigate } = useComponentConfig().link;
|
|
8
8
|
const renderOption = renderOptionParam
|
|
9
9
|
? renderOptionParam
|
|
10
|
-
: (params) => (_jsx(Link,
|
|
10
|
+
: (params) => (_jsx(Link, { to: params.option.value, target: openNewTab ? '_blank' : undefined, onClick: (e) => {
|
|
11
11
|
e.preventDefault();
|
|
12
|
-
}
|
|
12
|
+
}, children: params.option.label }));
|
|
13
13
|
return (_jsx(Dropdown, { shouldRenderDropdownContainer: false, renderAnchor: children, renderDropdown: ({ ref, styles, id, setIsOpen }) => {
|
|
14
14
|
const options = optionsParam.map((option) => (Object.assign(Object.assign({}, option), { onClick: () => {
|
|
15
15
|
if (option.onClick) {
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { DropdownLinksV2 } from '.';
|
|
3
|
+
declare const meta: Meta<typeof DropdownLinksV2>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof DropdownLinksV2>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const Right: Story;
|
|
8
|
+
export declare const OpenInNewTab: Story;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import ArrowDropDownIcon from '@mui/icons-material/ArrowDropDown';
|
|
3
|
+
import { DropdownLinksV2 } from '.';
|
|
4
|
+
import { ButtonV2 } from '../../elements/ButtonV2';
|
|
5
|
+
import { BoxV2 } from '../../elements/BoxV2';
|
|
6
|
+
import { RowV2 } from '../../elements/RowV2';
|
|
7
|
+
import { UIVersion2 } from '../../../utils/decorators/UIVersion2';
|
|
8
|
+
const meta = {
|
|
9
|
+
title: 'Composites/DropdownLinksV2',
|
|
10
|
+
component: DropdownLinksV2,
|
|
11
|
+
tags: ['autodocs'],
|
|
12
|
+
decorators: [UIVersion2],
|
|
13
|
+
};
|
|
14
|
+
export default meta;
|
|
15
|
+
const options = [
|
|
16
|
+
{ value: 'https://google.com', label: 'Google' },
|
|
17
|
+
{ value: 'https://facebook.com', label: 'This is intentionally long' },
|
|
18
|
+
];
|
|
19
|
+
export const Default = {
|
|
20
|
+
render: () => (_jsx(BoxV2, { sx: { width: '200px', height: '200px' }, children: _jsx(DropdownLinksV2, { options: options, children: ({ anchorProps }) => (_jsx(ButtonV2, Object.assign({}, anchorProps, { rightIcon: ArrowDropDownIcon, children: "Links" }))) }) })),
|
|
21
|
+
};
|
|
22
|
+
export const Right = {
|
|
23
|
+
render: () => (_jsx(RowV2, { sx: { width: '90vw', height: '200px' }, justify: "flex-end", children: _jsx(DropdownLinksV2, { options: options, children: ({ anchorProps }) => (_jsx(ButtonV2, Object.assign({}, anchorProps, { rightIcon: ArrowDropDownIcon, children: "Links" }))) }) })),
|
|
24
|
+
};
|
|
25
|
+
export const OpenInNewTab = {
|
|
26
|
+
render: () => (_jsx(BoxV2, { sx: { width: '200px', height: '200px' }, children: _jsx(DropdownLinksV2, { options: options, openNewTab: true, children: ({ anchorProps }) => _jsx(ButtonV2, Object.assign({}, anchorProps, { children: "Links" })) }) })),
|
|
27
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { BasicOption, RenderOption } from '../../elements/option';
|
|
3
|
+
import { StyledElementPropsV2 } from '../../../theme';
|
|
4
|
+
type AnchorProps = Omit<React.HTMLAttributes<HTMLButtonElement>, 'color'>;
|
|
5
|
+
type LinkOption = BasicOption<string>;
|
|
6
|
+
type DropdownChildrenFn = (params: {
|
|
7
|
+
anchorProps: AnchorProps;
|
|
8
|
+
}) => React.ReactNode;
|
|
9
|
+
type DropdownLinksV2Props = StyledElementPropsV2<HTMLDivElement, {
|
|
10
|
+
options: BasicOption<string>[];
|
|
11
|
+
renderOption?: RenderOption<string, LinkOption>;
|
|
12
|
+
openNewTab?: boolean;
|
|
13
|
+
}, DropdownChildrenFn>;
|
|
14
|
+
export declare const DropdownLinksV2: React.FC<DropdownLinksV2Props>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { ListBoxV2 } from '../../elements/ListBoxV2';
|
|
3
|
+
import { useComponentConfigV2 } from '../../providers/componentConfigV2';
|
|
4
|
+
import { DropdownV2 } from '../../elements/DropdownV2';
|
|
5
|
+
export const DropdownLinksV2 = ({ children, options: optionsParam, renderOption: renderOptionParam, openNewTab, role = 'navigation', }) => {
|
|
6
|
+
const { navigate } = useComponentConfigV2().link;
|
|
7
|
+
const renderOption = renderOptionParam
|
|
8
|
+
? renderOptionParam
|
|
9
|
+
: (params) => (_jsx("a", { href: params.option.value, target: openNewTab ? '_blank' : undefined, style: { textDecoration: 'none', fontWeight: 700 }, onClick: (e) => {
|
|
10
|
+
e.preventDefault();
|
|
11
|
+
}, children: params.option.label }));
|
|
12
|
+
return (_jsx(DropdownV2, { shouldRenderDropdownContainer: false, renderAnchor: children, renderDropdown: ({ ref, styles, id, setIsOpen }) => {
|
|
13
|
+
const options = optionsParam.map((option) => (Object.assign(Object.assign({}, option), { onClick: () => {
|
|
14
|
+
if (option.onClick) {
|
|
15
|
+
option.onClick();
|
|
16
|
+
}
|
|
17
|
+
else if (openNewTab) {
|
|
18
|
+
window.open(option.value, '_blank');
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
navigate(option.value);
|
|
22
|
+
}
|
|
23
|
+
setIsOpen(false);
|
|
24
|
+
} })));
|
|
25
|
+
return (_jsx(ListBoxV2, { role: role, id: id, options: options, ref: ref, renderOption: renderOption, style: styles }));
|
|
26
|
+
} }));
|
|
27
|
+
};
|
|
@@ -24,7 +24,7 @@ export const CustomMessage = {
|
|
|
24
24
|
args: {},
|
|
25
25
|
};
|
|
26
26
|
export const JsxMessage = {
|
|
27
|
-
render: () => (_jsxs(EmptyState, { children: ["Something is wrong.", ' ', _jsx(Link,
|
|
27
|
+
render: () => (_jsxs(EmptyState, { children: ["Something is wrong.", ' ', _jsx(Link, { to: "/", sx: { fontSize: FONT_SIZE.MD }, children: "Click here to fix." })] })),
|
|
28
28
|
args: {},
|
|
29
29
|
};
|
|
30
30
|
export const CustomIcon = {
|
|
@@ -28,8 +28,8 @@ export const DEFAULT_MESSAGE = 'No results found.';
|
|
|
28
28
|
export const EmptyState = (_a) => {
|
|
29
29
|
var { omitIcon, icon, children, size: sizeProp, sx } = _a, rest = __rest(_a, ["omitIcon", "icon", "children", "size", "sx"]);
|
|
30
30
|
const size = sizeProp || EMPTY_STATE_SIZE.LG;
|
|
31
|
-
return (_jsxs(Column, Object.assign({ sx: Object.assign({ width: '100%', alignItems: 'center', justifyContent: 'center', mt: size === EMPTY_STATE_SIZE.SM ? 3 : 5 }, sx) }, rest, { children: [_jsx(Row, { children: omitIcon ? null : (_jsx(Icon, { icon: icon || SearchOffIcon, size: size === EMPTY_STATE_SIZE.SM ? FONT_SIZE.ML : FONT_SIZE.XL, color: COLOR.GRAY })) }), _jsx(Row,
|
|
31
|
+
return (_jsxs(Column, Object.assign({ sx: Object.assign({ width: '100%', alignItems: 'center', justifyContent: 'center', mt: size === EMPTY_STATE_SIZE.SM ? 3 : 5 }, sx) }, rest, { children: [_jsx(Row, { children: omitIcon ? null : (_jsx(Icon, { icon: icon || SearchOffIcon, size: size === EMPTY_STATE_SIZE.SM ? FONT_SIZE.ML : FONT_SIZE.XL, color: COLOR.GRAY })) }), _jsx(Row, { sx: { mt: size === EMPTY_STATE_SIZE.SM ? 0 : 1 }, children: _jsx(Paragraph, { sx: {
|
|
32
32
|
color: COLOR.GRAY,
|
|
33
33
|
mt: 0,
|
|
34
|
-
}, size: size === EMPTY_STATE_SIZE.SM ? PARAGRAPH_SIZE.MD : PARAGRAPH_SIZE.LG
|
|
34
|
+
}, size: size === EMPTY_STATE_SIZE.SM ? PARAGRAPH_SIZE.MD : PARAGRAPH_SIZE.LG, children: children || DEFAULT_MESSAGE }) })] })));
|
|
35
35
|
};
|
|
@@ -17,7 +17,7 @@ const ModalExample = () => {
|
|
|
17
17
|
const modalId = 'modal-example';
|
|
18
18
|
const { open, close, state } = useDialog(modalId);
|
|
19
19
|
const theme = useTheme();
|
|
20
|
-
return (_jsxs(_Fragment, { children: [_jsx(Button,
|
|
20
|
+
return (_jsxs(_Fragment, { children: [_jsx(Button, { onClick: open, sx: { position: 'relative', zIndex: (_a = theme.zIndex) === null || _a === void 0 ? void 0 : _a.DIALOG }, children: "Open Modal" }), _jsx(Modal, { isOpen: state.isOpen, heading: "Heading", close: close, actions: [
|
|
21
21
|
{
|
|
22
22
|
label: 'Secondary',
|
|
23
23
|
isPrimary: false,
|
|
@@ -35,7 +35,7 @@ const ModalExample = () => {
|
|
|
35
35
|
isPrimary: true,
|
|
36
36
|
onClick: () => { },
|
|
37
37
|
},
|
|
38
|
-
]
|
|
38
|
+
], children: _jsx(Paragraph, { children: "Modal body goes here" }) })] }));
|
|
39
39
|
};
|
|
40
40
|
export const Default = {
|
|
41
41
|
render: () => _jsx(ModalExample, {}),
|
|
@@ -10,23 +10,23 @@ describe('Modal', () => {
|
|
|
10
10
|
{ label: 'Action 2', onClick: vi.fn() },
|
|
11
11
|
];
|
|
12
12
|
it('renders modal with heading and content', () => {
|
|
13
|
-
const { getByText } = render(_jsx(Modal,
|
|
13
|
+
const { getByText } = render(_jsx(Modal, { isOpen: true, close: handleClose, heading: "Test Heading", children: _jsx("div", { children: "Modal Content" }) }));
|
|
14
14
|
expect(getByText('Test Heading')).toBeInTheDocument();
|
|
15
15
|
expect(getByText('Modal Content')).toBeInTheDocument();
|
|
16
16
|
});
|
|
17
17
|
it('calls close handler when close button is clicked', () => {
|
|
18
|
-
const { getByText } = render(_jsx(Modal,
|
|
18
|
+
const { getByText } = render(_jsx(Modal, { isOpen: true, close: handleClose, heading: "Test Heading", children: _jsx("div", { children: "Modal Content" }) }));
|
|
19
19
|
const closeButton = getByText('Close');
|
|
20
20
|
fireEvent.click(closeButton);
|
|
21
21
|
expect(handleClose).toHaveBeenCalledTimes(1);
|
|
22
22
|
});
|
|
23
23
|
it('renders actions correctly', () => {
|
|
24
|
-
const { getByText } = render(_jsx(Modal,
|
|
24
|
+
const { getByText } = render(_jsx(Modal, { isOpen: true, close: handleClose, heading: "Test Heading", actions: mockActions, children: _jsx("div", { children: "Modal Content" }) }));
|
|
25
25
|
expect(getByText('Action 1')).toBeInTheDocument();
|
|
26
26
|
expect(getByText('Action 2')).toBeInTheDocument();
|
|
27
27
|
});
|
|
28
28
|
it('calls action handler when action button is clicked', () => {
|
|
29
|
-
const { getByText } = render(_jsx(Modal,
|
|
29
|
+
const { getByText } = render(_jsx(Modal, { isOpen: true, close: handleClose, heading: "Test Heading", actions: mockActions, children: _jsx("div", { children: "Modal Content" }) }));
|
|
30
30
|
const actionButton1 = getByText('Action 1');
|
|
31
31
|
fireEvent.click(actionButton1);
|
|
32
32
|
expect(mockActions[0].onClick).toHaveBeenCalledTimes(1);
|
|
@@ -29,19 +29,19 @@ export const Modal = (_a) => {
|
|
|
29
29
|
const { modal } = useComponentConfig();
|
|
30
30
|
const theme = useTheme();
|
|
31
31
|
const shouldShowFooter = footer !== undefined || (actions !== undefined && actions.length > 0);
|
|
32
|
-
const modalBody = (_jsxs(Group,
|
|
32
|
+
const modalBody = (_jsxs(Group, { type: GROUP_TYPE.REGION, sx: { my: 0 }, children: [!hideHeading && (_jsxs(Row, { justify: "space-between", align: "center", sx: {
|
|
33
33
|
p: 3,
|
|
34
34
|
borderBottom: 'solid 1px',
|
|
35
35
|
borderColor: COLOR.LIGHT_GRAY,
|
|
36
|
-
}
|
|
36
|
+
}, children: [_jsx(Heading, { size: HEADING_SIZE.SM, typography: TYPOGRAPHY_TYPE.CONTROL_MEDIUM, sx: { mt: 0 }, children: heading }), _jsx(Button, { type: BUTTON_TYPE.TEXT, onClick: (e) => {
|
|
37
37
|
e.preventDefault();
|
|
38
38
|
e.stopPropagation();
|
|
39
39
|
close(e);
|
|
40
|
-
}
|
|
40
|
+
}, children: "Close" })] })), _jsx(Row, { sx: Object.assign({ p: 3 }, bodyStyles), children: children }), shouldShowFooter && (_jsxs(Row, { sx: { borderTop: 'solid 1px', borderColor: COLOR.LIGHT_GRAY, p: 3 }, children: [footer, actions !== undefined && (_jsx(Row, { sx: { width: '100%', justifyContent: 'flex-end' }, children: actions.map((action, index) => (_jsx(Button, Object.assign({ type: action.isPrimary ? BUTTON_TYPE.DEFAULT : BUTTON_TYPE.OUTLINE, onClick: (e) => {
|
|
41
41
|
action.onClick(e);
|
|
42
42
|
}, sx: {
|
|
43
43
|
mr: index < actions.length - 1 ? 1 : 0,
|
|
44
|
-
} }, action.buttonProps, { children: action.label }), index))) }))
|
|
44
|
+
} }, action.buttonProps, { children: action.label }), index))) }))] }))] }));
|
|
45
45
|
return (_jsx(ReactModal, Object.assign({ isOpen: isOpen, shouldFocusAfterRender: true, appElement: modal.appElement, onRequestClose: (e) => {
|
|
46
46
|
e.preventDefault();
|
|
47
47
|
e.stopPropagation();
|
|
@@ -61,5 +61,5 @@ export const Modal = (_a) => {
|
|
|
61
61
|
marginRight: '-50%',
|
|
62
62
|
transform: 'translate(-50%, -50%)',
|
|
63
63
|
},
|
|
64
|
-
}
|
|
64
|
+
}, children: wrapWithTheme ? _jsx(ThemeProvider, { children: modalBody }) : modalBody })));
|
|
65
65
|
};
|
|
@@ -15,7 +15,7 @@ export default meta;
|
|
|
15
15
|
const ModalV2Example = () => {
|
|
16
16
|
const modalId = 'modal-example';
|
|
17
17
|
const { open, close, state } = useDialog(modalId);
|
|
18
|
-
return (_jsxs(_Fragment, { children: [_jsx(ButtonV2,
|
|
18
|
+
return (_jsxs(_Fragment, { children: [_jsx(ButtonV2, { onClick: open, sx: { position: 'relative', zIndex: Z_INDEX.DIALOG }, children: "Open Modal" }), _jsx(ModalV2, { isOpen: state.isOpen, heading: "Heading", close: close, actions: [
|
|
19
19
|
{
|
|
20
20
|
label: 'Secondary',
|
|
21
21
|
isPrimary: false,
|
|
@@ -33,7 +33,7 @@ const ModalV2Example = () => {
|
|
|
33
33
|
isPrimary: true,
|
|
34
34
|
onClick: () => { },
|
|
35
35
|
},
|
|
36
|
-
]
|
|
36
|
+
], children: _jsx(ParagraphV2, { children: "Modal body goes here" }) })] }));
|
|
37
37
|
};
|
|
38
38
|
export const Default = {
|
|
39
39
|
render: () => _jsx(ModalV2Example, {}),
|