@ndlib/component-library 0.0.21 → 0.0.23

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.
Files changed (51) hide show
  1. package/dist/components/composites/Card/Card.stories.d.ts +1 -0
  2. package/dist/components/composites/Card/Card.stories.js +9 -5
  3. package/dist/components/composites/Card/Card.test.js +1 -1
  4. package/dist/components/composites/Card/index.d.ts +9 -2
  5. package/dist/components/composites/Card/index.js +13 -4
  6. package/dist/components/composites/NavMenu/index.js +4 -1
  7. package/dist/components/elements/Alerts/index.js +5 -2
  8. package/dist/components/elements/Button/index.d.ts +1 -1
  9. package/dist/components/elements/Fields/DatePicker/DatePicker.stories.d.ts +1 -0
  10. package/dist/components/elements/Fields/DatePicker/DatePicker.stories.js +12 -1
  11. package/dist/components/elements/Fields/DatePicker/index.d.ts +1 -0
  12. package/dist/components/elements/Fields/DatePicker/index.js +20 -4
  13. package/dist/components/elements/Fields/MonthPicker/index.js +3 -1
  14. package/dist/components/elements/Fields/Select/index.js +3 -2
  15. package/dist/components/elements/Fields/TextInput/index.d.ts +1 -1
  16. package/dist/components/elements/Icon/index.js +1 -1
  17. package/dist/components/elements/List/index.js +9 -4
  18. package/dist/components/elements/ListBox/index.d.ts +1 -1
  19. package/dist/components/elements/Pill/Pill.stories.d.ts +8 -0
  20. package/dist/components/elements/Pill/Pill.stories.js +40 -0
  21. package/dist/components/elements/Pill/Pill.test.d.ts +1 -0
  22. package/dist/components/elements/Pill/Pill.test.js +18 -0
  23. package/dist/components/elements/Pill/index.d.ts +20 -0
  24. package/dist/components/elements/Pill/index.js +118 -0
  25. package/dist/components/elements/layout/Flex.stories.d.ts +1 -0
  26. package/dist/components/elements/layout/Flex.stories.js +3 -0
  27. package/dist/components/elements/layout/Row.d.ts +3 -1
  28. package/dist/components/elements/layout/Row.js +5 -2
  29. package/dist/components/elements/text/ReadMore/ReadMore.stories.d.ts +1 -0
  30. package/dist/components/elements/text/ReadMore/ReadMore.stories.js +10 -2
  31. package/dist/components/elements/text/ReadMore/index.d.ts +1 -2
  32. package/dist/components/elements/text/ReadMore/index.js +13 -7
  33. package/dist/components/providers/ui.d.ts +1 -0
  34. package/dist/components/providers/ui.js +4 -3
  35. package/dist/index.d.ts +4 -0
  36. package/dist/index.js +4 -0
  37. package/dist/theme/GlobalStyles.js +6 -0
  38. package/dist/theme/Typography.stories.js +1 -0
  39. package/dist/theme/index.d.ts +4 -1
  40. package/dist/theme/index.js +4 -3
  41. package/dist/theme/typography.d.ts +1 -0
  42. package/dist/theme/typography.js +7 -0
  43. package/dist/utils/hooks/useHover.d.ts +7 -0
  44. package/dist/utils/hooks/useHover.js +12 -0
  45. package/dist/utils/hooks/useMediaQuery.d.ts +4 -0
  46. package/dist/utils/hooks/useMediaQuery.js +28 -0
  47. package/dist/utils/misc.d.ts +1 -0
  48. package/dist/utils/misc.js +12 -0
  49. package/package.json +1 -1
  50. package/dist/components/providers/theme.d.ts +0 -2
  51. package/dist/components/providers/theme.js +0 -6
@@ -4,6 +4,7 @@ declare const meta: Meta<typeof Card>;
4
4
  export default meta;
5
5
  type Story = StoryObj<typeof Card>;
6
6
  export declare const Default: Story;
7
+ export declare const TruncateHeadline: Story;
7
8
  export declare const Horizontal: Story;
8
9
  export declare const DateCards: Story;
9
10
  export declare const Clickable: Story;
@@ -3,7 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
3
3
  import AccessTime from '@mui/icons-material/AccessTimeFilled';
4
4
  import CalendarIcon from '@mui/icons-material/CalendarMonth';
5
5
  import { CARD_LAYOUT, CARD_SIZE, Card } from '.';
6
- import { COLOR, Column, LABEL_SIZE, Label, Paragraph } from '../../..';
6
+ import { COLOR, Column, LABEL_SIZE, Label, Paragraph, ReadMore, TYPOGRAPHY_TYPE, } from '../../..';
7
7
  import { Icon } from '../../elements/Icon';
8
8
  const meta = {
9
9
  title: 'Composites/Card',
@@ -18,7 +18,7 @@ const basicCards = [
18
18
  size: CARD_SIZE.SM,
19
19
  },
20
20
  {
21
- headline: 'One Book, One Michiana Digital Exhibit — Papers Alight: Contextualizing Mike Curato’s Flamer',
21
+ headline: 'One Book, One Michiana Digital Exhibit — Papers Alight: Contextualizing Mike Curato’s Flamer. Other text to make this longer than the other card.',
22
22
  image: 'https://images.ctfassets.net/cfblb1f7i85j/2sGpdDbNkl6MPnlem6wq1R/995c786624613b5ff07228e481996385/One.Book.2023-Rep.png?w=296',
23
23
  size: CARD_SIZE.SM,
24
24
  },
@@ -40,7 +40,7 @@ const horizontalCards = [
40
40
  headline: 'Exhibit — Printing the Nation: A Century of Irish Book Arts',
41
41
  image: 'https://images.ctfassets.net/cfblb1f7i85j/7aCd5Sm86JdtQepGBKDUfy/dcb4d97dd3a1d3ee810e8bcaa82dc715/Spring_Exhibit_2023-Rep.jpg?w=296',
42
42
  size: CARD_SIZE.SM,
43
- body: (_jsxs(_Fragment, { children: [_jsxs(Label, Object.assign({ color: COLOR.PRIMARY, size: LABEL_SIZE.SM, sx: {
43
+ children: (_jsxs(_Fragment, { children: [_jsxs(Label, Object.assign({ color: COLOR.PRIMARY, size: LABEL_SIZE.SM, sx: {
44
44
  display: 'flex',
45
45
  } }, { children: [_jsx(Icon, { icon: CalendarIcon, sx: { mr: 1 } }), "Monday, February 6 \u2013 Monday, July 31, 2023"] })), _jsxs(Label, Object.assign({ color: COLOR.PRIMARY, size: LABEL_SIZE.SM, sx: {
46
46
  display: 'flex',
@@ -50,17 +50,21 @@ const horizontalCards = [
50
50
  headline: 'One Book, One Michiana Digital Exhibit — Papers Alight: Contextualizing Mike Curato’s Flamer',
51
51
  image: 'https://images.ctfassets.net/cfblb1f7i85j/2sGpdDbNkl6MPnlem6wq1R/995c786624613b5ff07228e481996385/One.Book.2023-Rep.png?w=296',
52
52
  size: CARD_SIZE.SM,
53
- body: (_jsxs(_Fragment, { children: [_jsxs(Label, Object.assign({ color: COLOR.PRIMARY, size: LABEL_SIZE.SM, sx: {
53
+ children: ({ activeBackground }) => (_jsxs(_Fragment, { children: [_jsxs(Label, Object.assign({ color: COLOR.PRIMARY, size: LABEL_SIZE.SM, sx: {
54
54
  display: 'flex',
55
55
  } }, { children: [_jsx(Icon, { icon: CalendarIcon, sx: { mr: 1 } }), "Monday, February 6 \u2013 Monday, July 31, 2023"] })), _jsxs(Label, Object.assign({ color: COLOR.PRIMARY, size: LABEL_SIZE.SM, sx: {
56
56
  display: 'flex',
57
- } }, { children: [_jsx(Icon, { icon: AccessTime, sx: { mr: 1 } }), "M-F: 9:30am \u2013 4:30pm"] })), _jsx(Paragraph, { 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." })] })),
57
+ } }, { children: [_jsx(Icon, { icon: AccessTime, sx: { mr: 1 } }), "M-F: 9:30am \u2013 4:30pm"] })), _jsx(ReadMore, Object.assign({ 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." }))] })),
58
58
  },
59
59
  ];
60
60
  export const Default = {
61
61
  render: () => (_jsx(Column, { children: basicCards.map((props, i) => (_createElement(Card, Object.assign({}, props, { key: i })))) })),
62
62
  args: {},
63
63
  };
64
+ export const TruncateHeadline = {
65
+ render: () => (_jsx(Column, { children: basicCards.map((props, i) => (_createElement(Card, Object.assign({}, props, { key: i, truncateHeadlineAfter: 2 })))) })),
66
+ args: {},
67
+ };
64
68
  export const Horizontal = {
65
69
  render: () => (_jsx(Column, { children: horizontalCards.map((props, i) => (_createElement(Card, Object.assign({}, props, { key: i, layout: CARD_LAYOUT.HORIZONTAL })))) })),
66
70
  args: {},
@@ -12,7 +12,7 @@ describe('Card', () => {
12
12
  vi.resetAllMocks();
13
13
  });
14
14
  it('renders contents', () => {
15
- const { getByText } = render(_jsx(Card, { headline: MOCK_HEADLINE, body: MOCK_BODY }));
15
+ const { getByText } = render(_jsx(Card, Object.assign({ headline: MOCK_HEADLINE }, { children: MOCK_BODY })));
16
16
  expect(getByText(MOCK_HEADLINE)).toBeDefined();
17
17
  expect(getByText(MOCK_BODY)).toBeDefined();
18
18
  });
@@ -1,4 +1,5 @@
1
1
  import { StyledElementProps } from '../../../theme';
2
+ import { COLOR } from '../../../theme/colors';
2
3
  import React from 'react';
3
4
  export declare enum CARD_LAYOUT {
4
5
  VERTICAL = "vertical",
@@ -9,14 +10,20 @@ export declare enum CARD_SIZE {
9
10
  MD = "MD",
10
11
  LG = "LG"
11
12
  }
12
- type CardProps = StyledElementProps<HTMLDivElement, {
13
+ type CardState = {
14
+ isHovered: boolean;
15
+ activeBackground: COLOR;
16
+ };
17
+ type CardChildren = React.ReactNode | ((state: CardState) => React.ReactNode);
18
+ export type CardProps = StyledElementProps<HTMLDivElement, {
13
19
  headline: string;
20
+ truncateHeadlineAfter?: number;
14
21
  body?: React.ReactNode;
15
22
  image?: string;
16
23
  layout?: CARD_LAYOUT;
17
24
  size?: CARD_SIZE;
18
25
  displayDate?: string;
19
26
  onClick?: () => void;
20
- }>;
27
+ }, CardChildren>;
21
28
  export declare const Card: React.FC<CardProps>;
22
29
  export {};
@@ -1,11 +1,13 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Heading } from '../../elements/text/Heading';
3
+ import { ReadMore } from '../../elements/text/ReadMore';
3
4
  import { GROUP_TYPE, Group } from '../../elements/Group';
4
5
  import { Box } from '../../elements/layout/Box';
5
6
  import { Column, FONT, FONT_SIZE, Row, TYPOGRAPHY_TYPE } from '../../..';
6
7
  import { COLOR } from '../../../theme/colors';
7
- import React from 'react';
8
+ import React, { useEffect, useState } from 'react';
8
9
  import { KEY_CODES } from '../../../utils/misc';
10
+ import { useHover } from '../../../utils/hooks/useHover';
9
11
  export var CARD_LAYOUT;
10
12
  (function (CARD_LAYOUT) {
11
13
  CARD_LAYOUT["VERTICAL"] = "vertical";
@@ -48,15 +50,20 @@ const DateDisplay = ({ date: dateString }) => {
48
50
  mt: 1,
49
51
  } }, { children: MONTH_LABELS[date.getMonth()] }))] })));
50
52
  };
51
- export const Card = ({ size, displayDate, headline, body, image, layout, onClick, sx, }) => {
53
+ export const Card = ({ size, displayDate, headline, image, layout, onClick, truncateHeadlineAfter, sx, children, }) => {
52
54
  const contentPaddingX = size === CARD_SIZE.SM ? 4 : 5;
53
55
  const bodyTopMargin = size === CARD_SIZE.SM ? 2 : 3;
54
56
  const isVertical = !layout || layout === CARD_LAYOUT.VERTICAL;
57
+ const { isHovered, anchorElementProps } = useHover();
58
+ const [activeBackground, setActiveBackground] = useState(isHovered ? COLOR.ND_SKY_BLUE : COLOR.BACKGROUND);
59
+ useEffect(() => {
60
+ setActiveBackground(isHovered ? COLOR.ND_SKY_BLUE : COLOR.BACKGROUND);
61
+ }, [isHovered]);
55
62
  const contentPaddingY = isVertical ? contentPaddingX : 2;
56
63
  const typography = size === CARD_SIZE.SM
57
64
  ? TYPOGRAPHY_TYPE.HEADLINE_SMALL
58
65
  : TYPOGRAPHY_TYPE.HEADLINE_MEDIUM;
59
- return (_jsxs(Group, Object.assign({ type: GROUP_TYPE.GROUP, role: onClick ? 'button' : 'group', onClick: onClick, onKeyDown: (e) => {
66
+ return (_jsxs(Group, Object.assign({}, anchorElementProps, { type: GROUP_TYPE.GROUP, role: onClick ? 'button' : 'group', onClick: onClick, onKeyDown: (e) => {
60
67
  if (onClick && e.key === KEY_CODES.ENTER) {
61
68
  onClick();
62
69
  }
@@ -67,5 +74,7 @@ export const Card = ({ size, displayDate, headline, body, image, layout, onClick
67
74
  } }, sx) }, { children: [image && (_jsx("img", { src: image, style: {
68
75
  width: isVertical ? '100%' : 'auto',
69
76
  height: isVertical ? 'auto' : '100%',
70
- } })), displayDate && _jsx(DateDisplay, { date: displayDate }), _jsx(Row, Object.assign({ sx: { px: contentPaddingX, py: contentPaddingY } }, { children: _jsxs(Column, Object.assign({ justify: "center" }, { children: [_jsx(Heading, Object.assign({ typography: typography, sx: { textAlign: 'justify' } }, { children: headline })), body && _jsx(Box, Object.assign({ sx: { mt: bodyTopMargin } }, { children: body }))] })) }))] })));
77
+ } })), displayDate && _jsx(DateDisplay, { date: displayDate }), _jsx(Row, Object.assign({ sx: { px: contentPaddingX, py: contentPaddingY } }, { children: _jsxs(Column, Object.assign({ justify: "center" }, { children: [_jsx(Heading, Object.assign({ typography: typography, sx: { textAlign: 'justify' } }, { children: truncateHeadlineAfter ? (_jsx(ReadMore, Object.assign({ lines: truncateHeadlineAfter, typography: typography, sx: { bg: activeBackground } }, { children: headline }))) : (headline) })), children && (_jsx(Box, Object.assign({ sx: { mt: bodyTopMargin } }, { children: typeof children === 'function'
78
+ ? children({ isHovered, activeBackground })
79
+ : children })))] })) }))] })));
71
80
  };
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import ChevronRightIcon from '@mui/icons-material/ChevronRight';
2
+ import _ChevronRightIcon from '@mui/icons-material/ChevronRight';
3
3
  import { List, ListItem } from '../../elements/List';
4
4
  import { MENU_ACTION_TYPE, useMenu } from '../../providers/menu';
5
5
  import { Row } from '../../elements/layout/Row';
@@ -8,6 +8,9 @@ import { HEADING_SIZE, Heading } from '../../elements/text/Heading';
8
8
  import { Link } from '../../elements/Link';
9
9
  import { LINE_HEIGHT } from '../../../theme/typography';
10
10
  import { COLOR } from '../../../theme/colors';
11
+ import { importedDefaultComponentShim } from '../../../utils/misc';
12
+ // import { Column, HEADING_SIZE, Heading, LINE_HEIGHT, Link, Row } from "../../.."
13
+ const ChevronRightIcon = importedDefaultComponentShim(_ChevronRightIcon);
11
14
  export const NavMenu = (props) => {
12
15
  const { isOpen, activePath, getMenuItem, getMenuItemProps, getMenuProps } = useMenu();
13
16
  if (!isOpen) {
@@ -10,8 +10,8 @@ var __rest = (this && this.__rest) || function (s, e) {
10
10
  return t;
11
11
  };
12
12
  import { jsx as _jsx, jsxs as _jsxs } from "theme-ui/jsx-runtime";
13
- import WarningIcon from '@mui/icons-material/Warning';
14
- import InfoIcon from '@mui/icons-material/Info';
13
+ import _WarningIcon from '@mui/icons-material/Warning';
14
+ import _InfoIcon from '@mui/icons-material/Info';
15
15
  import { COLOR } from '../../../theme/colors';
16
16
  import { Markdown } from '../Markdown';
17
17
  import { Row } from '../layout/Row';
@@ -20,6 +20,9 @@ import { FONT_SIZE } from '../../../theme/typography';
20
20
  import { useAlerts, ALERT_TYPE } from '../../providers/alerts';
21
21
  import { useTheme } from '../../../theme';
22
22
  import { BUTTON_TYPE, Button } from '../Button';
23
+ import { importedDefaultComponentShim } from '../../../utils/misc';
24
+ const WarningIcon = importedDefaultComponentShim(_WarningIcon);
25
+ const InfoIcon = importedDefaultComponentShim(_InfoIcon);
23
26
  export const Alerts = (_a) => {
24
27
  var { pageAlerts } = _a, rest = __rest(_a, ["pageAlerts"]);
25
28
  const { alerts, dismiss } = useAlerts(pageAlerts);
@@ -14,7 +14,7 @@ export declare enum BUTTON_TYPE {
14
14
  export declare const Button: React.ForwardRefExoticComponent<{
15
15
  sx?: import("../../../theme").StylesProp | undefined;
16
16
  children?: React.ReactNode;
17
- } & React.HTMLAttributes<HTMLButtonElement> & {
17
+ } & Omit<React.HTMLAttributes<HTMLButtonElement>, "children"> & {
18
18
  size?: BUTTON_SIZE | undefined;
19
19
  type?: BUTTON_TYPE | undefined;
20
20
  color?: COLOR | undefined;
@@ -5,3 +5,4 @@ export default meta;
5
5
  type Story = StoryObj<typeof DatePicker>;
6
6
  export declare const Default: Story;
7
7
  export declare const Inline: Story;
8
+ export declare const HighlightedDates: Story;
@@ -10,7 +10,9 @@ const meta = {
10
10
  export default meta;
11
11
  const StatefulDatePicker = (props) => {
12
12
  const [date, setDate] = useState(new Date());
13
- return _jsx(DatePicker, Object.assign({}, props, { value: date, onChange: setDate }));
13
+ return (_jsx(DatePicker, Object.assign({}, props, { value: date, onChange: (d) => {
14
+ setDate(d);
15
+ } })));
14
16
  };
15
17
  export const Default = {
16
18
  render: () => (_jsx(Box, Object.assign({ sx: { height: '500px' } }, { children: _jsx(StatefulDatePicker, { placeholder: "test" }) }))),
@@ -18,3 +20,12 @@ export const Default = {
18
20
  export const Inline = {
19
21
  render: () => (_jsx(Box, Object.assign({ sx: { height: '500px' } }, { children: _jsx(StatefulDatePicker, { inline: true }) }))),
20
22
  };
23
+ export const HighlightedDates = {
24
+ render: () => {
25
+ const highlightedDate1 = new Date();
26
+ highlightedDate1.setDate(highlightedDate1.getDate() + 1);
27
+ const highlightedDate2 = new Date();
28
+ highlightedDate2.setDate(highlightedDate2.getDate() - 1);
29
+ return (_jsx(Box, Object.assign({ sx: { height: '500px' } }, { children: _jsx(StatefulDatePicker, { inline: true, highlightDates: [highlightedDate1, highlightedDate2] }) })));
30
+ },
31
+ };
@@ -14,6 +14,7 @@ export declare const DatePicker: React.FC<{
14
14
  minDate?: Date;
15
15
  maxDate?: Date;
16
16
  inline?: boolean;
17
+ highlightDates?: Date[];
17
18
  wrapperProps?: BoxProps;
18
19
  inputProps?: Partial<TextInputProps>;
19
20
  }>;
@@ -11,11 +11,14 @@ var __rest = (this && this.__rest) || function (s, e) {
11
11
  };
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
13
  import React from 'react';
14
- import ReactDatePicker from 'react-datepicker';
14
+ import _ReactDatePicker from 'react-datepicker';
15
15
  import 'react-datepicker/dist/react-datepicker.css';
16
16
  import { TextInput } from '../TextInput';
17
- import CalendarIcon from '@mui/icons-material/CalendarMonth';
17
+ import _CalendarIcon from '@mui/icons-material/CalendarMonth';
18
18
  import { Box } from '../../layout/Box';
19
+ import { importedDefaultComponentShim } from '../../../../utils/misc';
20
+ const CalendarIcon = importedDefaultComponentShim(_CalendarIcon);
21
+ const ReactDatePicker = importedDefaultComponentShim(_ReactDatePicker);
19
22
  // Need to do this to allow passing props to TextInput
20
23
  // react-datepicker will overwrite all props passed to customInput
21
24
  export const InputWrapper = React.forwardRef(({ onChange, value, children, onClick }, ref) => {
@@ -28,7 +31,20 @@ export const InputWrapper = React.forwardRef(({ onChange, value, children, onCli
28
31
  });
29
32
  });
30
33
  const PermissiveTextInput = TextInput;
34
+ const areDatesEqual = (d1, d2) => {
35
+ const serializeDate = (d) => `${d.getFullYear()} ${d.getMonth()} ${d.getDate()}`;
36
+ return serializeDate(d1) === serializeDate(d2);
37
+ };
31
38
  export const DatePicker = (_a) => {
32
- var { value, wrapperProps, inputProps } = _a, rest = __rest(_a, ["value", "wrapperProps", "inputProps"]);
33
- return (_jsx(Box, Object.assign({}, wrapperProps, { children: _jsx(ReactDatePicker, Object.assign({ calendarClassName: "ndlib-date-picker", selected: value, customInput: _jsx(InputWrapper, { children: _jsx(PermissiveTextInput, Object.assign({}, inputProps)) }) }, rest)) })));
39
+ var { value, wrapperProps, inputProps, highlightDates } = _a, rest = __rest(_a, ["value", "wrapperProps", "inputProps", "highlightDates"]);
40
+ const highlightDateSet = new Set(highlightDates === null || highlightDates === void 0 ? void 0 : highlightDates.map((d) => d.toDateString()));
41
+ return (_jsx(Box, Object.assign({}, wrapperProps, { children: _jsx(ReactDatePicker, Object.assign({ calendarClassName: "ndlib-date-picker", selected: value, dayClassName: (date) => {
42
+ if (areDatesEqual(date, value)) {
43
+ return '';
44
+ }
45
+ if (highlightDateSet.has(date.toDateString())) {
46
+ return 'ndlib-date-picker-highlight';
47
+ }
48
+ return '';
49
+ }, customInput: _jsx(InputWrapper, { children: _jsx(PermissiveTextInput, Object.assign({}, inputProps)) }) }, rest)) })));
34
50
  };
@@ -10,11 +10,13 @@ var __rest = (this && this.__rest) || function (s, e) {
10
10
  return t;
11
11
  };
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
- import ReactDatePicker from 'react-datepicker';
13
+ import _ReactDatePicker from 'react-datepicker';
14
14
  import 'react-datepicker/dist/react-datepicker.css';
15
15
  import { TextInput } from '../TextInput';
16
16
  import { InputWrapper } from '../DatePicker';
17
17
  import { Box } from '../../layout/Box';
18
+ import { importedDefaultComponentShim } from '../../../../utils/misc';
19
+ const ReactDatePicker = importedDefaultComponentShim(_ReactDatePicker);
18
20
  const PermissiveTextInput = TextInput;
19
21
  export const MonthPicker = (_a) => {
20
22
  var { value, inputProps, wrapperProps } = _a, rest = __rest(_a, ["value", "inputProps", "wrapperProps"]);
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useMemo, useState } from 'react';
3
- import ArrowDropDownIcon from '@mui/icons-material/ArrowDropDown';
3
+ import _ArrowDropDownIcon from '@mui/icons-material/ArrowDropDown';
4
4
  import { useFloating, size as sizeMiddleware, offset, autoPlacement, } from '@floating-ui/react';
5
5
  import { TYPOGRAPHY_TYPE, getTypographyStyles, } from '../../../../theme/typography';
6
6
  import { useTheme } from '../../../../theme';
@@ -9,8 +9,9 @@ import { ListBox } from '../../ListBox';
9
9
  import { BUTTON_SIZE, BUTTON_TYPE, Button } from '../../Button';
10
10
  import { defaultRenderOptionLabel, getOptionId, } from '../option';
11
11
  import { useUniqueHtmlId } from '../../../../utils/hooks/useUniqueHtmlId';
12
- import { KEY_CODES } from '../../../../utils/misc';
12
+ import { KEY_CODES, importedDefaultComponentShim } from '../../../../utils/misc';
13
13
  import { COLOR } from '../../../../theme/colors';
14
+ const ArrowDropDownIcon = importedDefaultComponentShim(_ArrowDropDownIcon);
14
15
  const typographyMap = {
15
16
  [INPUT_SIZE.SM]: TYPOGRAPHY_TYPE.PARAGRAPH_SMALL,
16
17
  [INPUT_SIZE.MD]: TYPOGRAPHY_TYPE.PARAGRAPH_MEDIUM,
@@ -17,7 +17,7 @@ export type TextInputProps = StyledElementProps<HTMLInputElement, {
17
17
  export declare const TextInput: React.ForwardRefExoticComponent<{
18
18
  sx?: import("../../../../theme").StylesProp | undefined;
19
19
  children?: string | undefined;
20
- } & React.HTMLAttributes<HTMLInputElement> & {
20
+ } & Omit<React.HTMLAttributes<HTMLInputElement>, "children"> & {
21
21
  size?: INPUT_SIZE | undefined;
22
22
  leftIcon?: React.FC<any> | undefined;
23
23
  inline?: boolean | undefined;
@@ -18,7 +18,7 @@ export const Icon = (_a) => {
18
18
  const InnerComponent = icon;
19
19
  return (_jsx("div", Object.assign({}, rest, { sx: Object.assign(Object.assign({}, sx), { fontSize: size, display: 'flex', alignItems: 'center', justifyContent: 'center' }) }, { children: React.createElement(InnerComponent, {
20
20
  fontSize: 'inherit',
21
- sx: {
21
+ style: {
22
22
  color: colors[color || COLOR.PRIMARY],
23
23
  },
24
24
  }) })));
@@ -12,13 +12,18 @@ var __rest = (this && this.__rest) || function (s, e) {
12
12
  import { jsx as _jsx, jsxs as _jsxs } from "theme-ui/jsx-runtime";
13
13
  /** @jsxImportSource theme-ui */
14
14
  import React from 'react';
15
- import CircleIcon from '@mui/icons-material/Circle';
16
- import CircleOutlinedIcon from '@mui/icons-material/CircleOutlined';
17
- import SquareIcon from '@mui/icons-material/Square';
18
- import SquareOutlinedIcon from '@mui/icons-material/SquareOutlined';
15
+ import _CircleIcon from '@mui/icons-material/Circle';
16
+ import _CircleOutlinedIcon from '@mui/icons-material/CircleOutlined';
17
+ import _SquareIcon from '@mui/icons-material/Square';
18
+ import _SquareOutlinedIcon from '@mui/icons-material/SquareOutlined';
19
19
  import { COLOR, Label, TYPOGRAPHY_TYPE } from '../../..';
20
20
  import { FONT_SIZE, getTypographyStyles } from '../../../theme/typography';
21
21
  import { Icon } from '../Icon';
22
+ import { importedDefaultComponentShim } from '../../../utils/misc';
23
+ const CircleIcon = importedDefaultComponentShim(_CircleIcon);
24
+ const CircleOutlinedIcon = importedDefaultComponentShim(_CircleOutlinedIcon);
25
+ const SquareIcon = importedDefaultComponentShim(_SquareIcon);
26
+ const SquareOutlinedIcon = importedDefaultComponentShim(_SquareOutlinedIcon);
22
27
  export var LIST_SIZE;
23
28
  (function (LIST_SIZE) {
24
29
  LIST_SIZE["SM"] = "sm";
@@ -16,7 +16,7 @@ type ListBoxProps<Value extends Key, Option extends BasicOption<Value>> = Styled
16
16
  export declare const ListBox: <Value extends React.Key = string, Option extends BasicOption<Value> = any>(props: {
17
17
  sx?: import("../../../theme").StylesProp | undefined;
18
18
  children?: React.ReactNode;
19
- } & React.HTMLAttributes<HTMLDivElement> & {
19
+ } & Omit<React.HTMLAttributes<HTMLDivElement>, "children"> & {
20
20
  options: Option[];
21
21
  renderOption?: RenderOption<Value, Option> | undefined;
22
22
  selected?: Value | undefined;
@@ -0,0 +1,8 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import { Pill } from '.';
3
+ declare const meta: Meta<typeof Pill>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof Pill>;
6
+ export declare const Default: Story;
7
+ export declare const Icon: Story;
8
+ export declare const NoAction: Story;
@@ -0,0 +1,40 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import SearchIcon from '@mui/icons-material/Search';
3
+ import { PILL_SIZE, PILL_TYPE, Pill } from '.';
4
+ import { GROUP_TYPE, Group } from '../Group';
5
+ import { HEADING_SIZE, Heading } from '../text/Heading';
6
+ import { Column } from '../layout/Column';
7
+ import { Row } from '../layout/Row';
8
+ const meta = {
9
+ title: 'Elements/Pill',
10
+ component: Pill,
11
+ tags: ['autodocs'],
12
+ };
13
+ export default meta;
14
+ const sizes = [
15
+ { size: PILL_SIZE.LG, label: 'Large' },
16
+ { size: PILL_SIZE.SM, label: 'Small' },
17
+ ];
18
+ export const Default = {
19
+ render: (args) => (_jsx(Column, { children: sizes.map((size) => (_jsxs(Group, Object.assign({ type: GROUP_TYPE.REGION }, { children: [_jsx(Heading, Object.assign({ size: HEADING_SIZE.MD }, { children: size.label })), _jsxs(Row, Object.assign({ sx: { mt: 2 } }, { children: [_jsx(Pill, Object.assign({}, args, { size: size.size, sx: { mr: 1 } })), _jsx(Pill, Object.assign({}, args, { size: size.size, type: PILL_TYPE.OUTLINE }))] }))] })))) })),
20
+ args: {
21
+ type: PILL_TYPE.DEFAULT,
22
+ children: 'Virtual Event',
23
+ onClick: () => console.log('clicked'),
24
+ },
25
+ };
26
+ export const Icon = {
27
+ render: (args) => (_jsx(Column, { children: sizes.map((size) => (_jsxs(Group, Object.assign({ type: GROUP_TYPE.REGION }, { children: [_jsx(Heading, Object.assign({ size: HEADING_SIZE.MD }, { children: size.label })), _jsxs(Row, Object.assign({ sx: { mt: 2 } }, { children: [_jsx(Pill, Object.assign({}, args, { size: size.size, sx: { mr: 1 }, icon: SearchIcon })), _jsx(Pill, Object.assign({}, args, { size: size.size, type: PILL_TYPE.OUTLINE, icon: SearchIcon }))] }))] })))) })),
28
+ args: {
29
+ type: PILL_TYPE.DEFAULT,
30
+ children: 'Virtual Event',
31
+ onClick: () => console.log('clicked'),
32
+ },
33
+ };
34
+ export const NoAction = {
35
+ render: (args) => (_jsx(Column, { children: sizes.map((size) => (_jsxs(Group, Object.assign({ type: GROUP_TYPE.REGION }, { children: [_jsx(Heading, Object.assign({ size: HEADING_SIZE.MD }, { children: size.label })), _jsxs(Row, Object.assign({ sx: { mt: 2 } }, { children: [_jsx(Pill, Object.assign({}, args, { size: size.size, sx: { mr: 1 } })), _jsx(Pill, Object.assign({}, args, { size: size.size, type: PILL_TYPE.OUTLINE }))] }))] })))) })),
36
+ args: {
37
+ type: PILL_TYPE.DEFAULT,
38
+ children: 'Virtual Event',
39
+ },
40
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,18 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { render } from '../../../utils/test';
3
+ import { Pill } from '.';
4
+ import { fireEvent } from '@testing-library/react';
5
+ import { vitest } from 'vitest';
6
+ describe('Pill', () => {
7
+ it('renders children', () => {
8
+ const { getByText } = render(_jsx(Pill, { children: "Test" }));
9
+ expect(getByText('Test')).toBeInTheDocument();
10
+ });
11
+ it('responds to onClick handler', () => {
12
+ const onClick = vitest.fn();
13
+ const { getByRole } = render(_jsx(Pill, { onClick: onClick }));
14
+ const button = getByRole('button');
15
+ fireEvent.click(button);
16
+ expect(onClick).toHaveBeenCalled();
17
+ });
18
+ });
@@ -0,0 +1,20 @@
1
+ /** @jsxImportSource theme-ui */
2
+ import React from 'react';
3
+ import { COLOR } from '../../../theme/colors';
4
+ export declare enum PILL_SIZE {
5
+ SM = "sm",
6
+ LG = "lg"
7
+ }
8
+ export declare enum PILL_TYPE {
9
+ DEFAULT = "default",
10
+ OUTLINE = "outline"
11
+ }
12
+ export declare const Pill: React.ForwardRefExoticComponent<{
13
+ sx?: import("../../../theme").StylesProp | undefined;
14
+ children?: React.ReactNode;
15
+ } & Omit<React.HTMLAttributes<HTMLButtonElement>, "children"> & {
16
+ size?: PILL_SIZE | undefined;
17
+ type?: PILL_TYPE | undefined;
18
+ color?: COLOR | undefined;
19
+ icon?: React.FC<any> | undefined;
20
+ } & React.RefAttributes<HTMLButtonElement>>;
@@ -0,0 +1,118 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx, jsxs as _jsxs } from "theme-ui/jsx-runtime";
13
+ /** @jsxImportSource theme-ui */
14
+ import React, { useState } from 'react';
15
+ import { useTheme } from '../../../theme';
16
+ import { COLOR, colors } from '../../../theme/colors';
17
+ import { TYPOGRAPHY_TYPE, getTypographyStyles } from '../../../theme/typography';
18
+ import { Icon } from '../Icon';
19
+ export var PILL_SIZE;
20
+ (function (PILL_SIZE) {
21
+ PILL_SIZE["SM"] = "sm";
22
+ PILL_SIZE["LG"] = "lg";
23
+ })(PILL_SIZE || (PILL_SIZE = {}));
24
+ const typographyMap = {
25
+ [PILL_SIZE.SM]: TYPOGRAPHY_TYPE.PARAGRAPH_XSMALL,
26
+ [PILL_SIZE.LG]: TYPOGRAPHY_TYPE.PARAGRAPH_SMALL,
27
+ };
28
+ const defaultPaddingX = {
29
+ [PILL_SIZE.SM]: 2,
30
+ [PILL_SIZE.LG]: 3,
31
+ };
32
+ const defaultHeight = {
33
+ [PILL_SIZE.SM]: '1.75rem',
34
+ [PILL_SIZE.LG]: '2rem',
35
+ };
36
+ const iconMargin = {
37
+ [PILL_SIZE.SM]: 1,
38
+ [PILL_SIZE.LG]: 1,
39
+ };
40
+ export var PILL_TYPE;
41
+ (function (PILL_TYPE) {
42
+ PILL_TYPE["DEFAULT"] = "default";
43
+ PILL_TYPE["OUTLINE"] = "outline";
44
+ })(PILL_TYPE || (PILL_TYPE = {}));
45
+ export const Pill = React.forwardRef((_a, ref) => {
46
+ var { size: sizeParam, type: typeParam, color, icon, children, sx, onClick } = _a, rest = __rest(_a, ["size", "type", "color", "icon", "children", "sx", "onClick"]);
47
+ const theme = useTheme();
48
+ const [hover, setHover] = useState(false);
49
+ const clickable = onClick !== undefined;
50
+ let bg = COLOR.PRIMARY;
51
+ let hoverBg = COLOR.PRIMARY_HIGHLIGHT;
52
+ let textColor = COLOR.TEXT;
53
+ let hoverTextColor = undefined;
54
+ let borderColor = COLOR.TRANSPARENT;
55
+ const cursor = clickable ? 'pointer' : 'default';
56
+ const hoverShadow = theme.boxShadow.NORMAL;
57
+ const hoverDecoration = undefined;
58
+ const hoverTransform = 'scale(1.03)';
59
+ const type = typeParam || PILL_TYPE.DEFAULT;
60
+ const size = sizeParam || PILL_SIZE.SM;
61
+ const paddingX = defaultPaddingX[size];
62
+ const height = defaultHeight[size];
63
+ if (type === PILL_TYPE.DEFAULT) {
64
+ bg = color || COLOR.PRIMARY;
65
+ hoverBg =
66
+ bg === COLOR.PRIMARY
67
+ ? COLOR.PRIMARY_HIGHLIGHT
68
+ : bg === COLOR.SECONDARY
69
+ ? COLOR.SECONDARY_HIGHLIGHT
70
+ : bg;
71
+ textColor =
72
+ bg === COLOR.PRIMARY
73
+ ? COLOR.TEXT_ON_PRIMARY
74
+ : bg === COLOR.SECONDARY
75
+ ? COLOR.TEXT_ON_SECONDARY
76
+ : COLOR.TEXT;
77
+ hoverTextColor = textColor;
78
+ }
79
+ if (type === PILL_TYPE.OUTLINE) {
80
+ bg = COLOR.BACKGROUND;
81
+ hoverBg = COLOR.BACKGROUND;
82
+ textColor = color || COLOR.PRIMARY;
83
+ hoverTextColor = textColor;
84
+ borderColor = textColor;
85
+ }
86
+ const typography = typographyMap[size];
87
+ const typographyStyles = getTypographyStyles(typography);
88
+ const body = children;
89
+ return (_jsxs("button", Object.assign({ ref: ref, tabIndex: onClick ? -1 : 0, onClick: onClick, onMouseEnter: () => {
90
+ setHover(true);
91
+ }, onMouseLeave: () => {
92
+ setHover(false);
93
+ }, sx: Object.assign(Object.assign(Object.assign({}, typographyStyles), { cursor, borderRadius: '1000px', bg: bg || colors.primary, color: textColor, px: paddingX, height: height, border: 'solid 1px', borderColor, display: 'flex', flexDirection: 'row', alignItems: 'center', justifyContent: 'center', ':hover': clickable
94
+ ? {
95
+ bg: hoverBg,
96
+ color: hoverTextColor,
97
+ boxShadow: hoverShadow,
98
+ transform: hoverTransform,
99
+ textDecoration: hoverDecoration,
100
+ }
101
+ : undefined, ':focus': clickable
102
+ ? {
103
+ bg: hoverBg,
104
+ color: hoverTextColor,
105
+ boxShadow: hoverShadow,
106
+ cursor: 'pointer',
107
+ transform: hoverTransform,
108
+ textDecoration: hoverDecoration,
109
+ }
110
+ : undefined }), sx) }, rest, { children: [icon && (_jsx(Icon, { icon: icon, size: typographyStyles.fontSize, sx: { mr: iconMargin[size] }, color: hover ? hoverTextColor : textColor })), _jsx("div", Object.assign({ css: {
111
+ flexGrow: 1,
112
+ justifyContent: 'flex-start',
113
+ textOverflow: 'ellipsis',
114
+ whiteSpace: 'nowrap',
115
+ overflow: 'hidden',
116
+ textAlign: 'start',
117
+ } }, { children: body }))] })));
118
+ });
@@ -5,5 +5,6 @@ export default meta;
5
5
  type Story = StoryObj<typeof Row>;
6
6
  export declare const Columns: Story;
7
7
  export declare const Rows: Story;
8
+ export declare const ResponsiveRow: Story;
8
9
  export declare const FlexHelpers: Story;
9
10
  export declare const Centered: Story;
@@ -15,6 +15,9 @@ export const Columns = {
15
15
  export const Rows = {
16
16
  render: () => (_jsxs(Column, { children: [_jsx(Row, { children: _jsx(Paragraph, { children: "Row 1" }) }), _jsx(Row, { children: _jsx(Paragraph, { children: "Row 2" }) }), _jsx(Row, { children: _jsx(Paragraph, { children: "Row 3" }) })] })),
17
17
  };
18
+ export const ResponsiveRow = {
19
+ render: () => (_jsxs(Row, Object.assign({ justify: "space-between", breakpoint: 0 }, { children: [_jsx(Column, { children: _jsx(Paragraph, { children: "Column 1" }) }), _jsx(Column, { children: _jsx(Paragraph, { children: "Column 2" }) }), _jsx(Column, { children: _jsx(Paragraph, { children: "Column 3" }) })] }))),
20
+ };
18
21
  export const FlexHelpers = {
19
22
  render: () => (_jsxs(Row, Object.assign({ justify: "space-between" }, { children: [_jsx(Column, Object.assign({ align: "flex-end", grow: 1, sx: { bg: COLOR.PRIMARY, color: COLOR.TEXT_ON_PRIMARY } }, { children: _jsx(Row, { children: _jsx(Paragraph, { children: "Right-aligned" }) }) })), _jsx(Column, Object.assign({ grow: 1 }, { children: _jsx(Paragraph, { children: "Growing Column...................................................." }) })), _jsx(Column, Object.assign({ shrink: 1, sx: { bg: COLOR.PRIMARY, color: COLOR.TEXT_ON_PRIMARY } }, { children: _jsx(Paragraph, { children: "Shrinking Column" }) }))] }))),
20
23
  };
@@ -12,6 +12,8 @@ export type FlexHelperProps = {
12
12
  justify?: CSSProperties['justifyContent'];
13
13
  centered?: boolean;
14
14
  };
15
- type RowProps = StyledElementProps<HTMLDivElement, FlexHelperProps>;
15
+ type RowProps = StyledElementProps<HTMLDivElement, FlexHelperProps & {
16
+ breakpoint?: number;
17
+ }>;
16
18
  export declare const Row: React.FC<RowProps>;
17
19
  export {};
@@ -10,6 +10,7 @@ var __rest = (this && this.__rest) || function (s, e) {
10
10
  return t;
11
11
  };
12
12
  import { jsx as _jsx } from "theme-ui/jsx-runtime";
13
+ import { useMediaQuery } from '../../../utils/hooks/useMediaQuery';
13
14
  // Putting shared utils and types here so autodocs can pick them up
14
15
  export const convertFlexHelperProps = (props) => {
15
16
  const styleObject = {};
@@ -38,7 +39,9 @@ export const convertFlexHelperProps = (props) => {
38
39
  return styleObject;
39
40
  };
40
41
  export const Row = (_a) => {
41
- var { sx, children } = _a, rest = __rest(_a, ["sx", "children"]);
42
+ var { sx, children, breakpoint: breakpointParam } = _a, rest = __rest(_a, ["sx", "children", "breakpoint"]);
43
+ const { breakpoint } = useMediaQuery();
44
+ const shouldRenderAsRow = breakpointParam !== undefined ? breakpoint > breakpointParam : true;
42
45
  const flexStyles = convertFlexHelperProps(rest);
43
- return (_jsx("div", Object.assign({}, rest, { sx: Object.assign(Object.assign(Object.assign({}, flexStyles), sx), { display: 'flex', flexDirection: 'row' }) }, { children: children })));
46
+ return (_jsx("div", Object.assign({}, rest, { sx: Object.assign(Object.assign(Object.assign({}, flexStyles), sx), { display: 'flex', flexDirection: shouldRenderAsRow ? 'row' : 'column' }) }, { children: children })));
44
47
  };
@@ -5,3 +5,4 @@ export default meta;
5
5
  type Story = StoryObj<typeof ReadMore>;
6
6
  export declare const Default: Story;
7
7
  export declare const NotTruncated: Story;
8
+ export declare const CustomColor: Story;
@@ -2,6 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { ReadMore } from '.';
3
3
  import { Column } from '../../layout/Column';
4
4
  import { TYPOGRAPHY_TYPE } from '../../../../theme/typography';
5
+ import { COLOR } from '../../../../theme/colors';
5
6
  const meta = {
6
7
  title: 'Elements/ReadMore',
7
8
  component: ReadMore,
@@ -12,8 +13,15 @@ export default meta;
12
13
  const p1 = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris ultrices venenatis purus at porta. Etiam congue sapien leo, sed malesuada justo commodo in. Nunc consequat, massa non cursus posuere, magna eros lacinia lectus, eget lobortis mi erat ut justo. Maecenas nisi mi, mollis sed ornare vitae, pharetra sed augue. Curabitur mollis orci risus, sed imperdiet nisi aliquet et. Ut non elit nec magna rhoncus maximus sit amet ut dui. Mauris sit amet eleifend lectus. Aliquam consectetur posuere libero eu ultricies. Etiam rutrum non orci nec vulputate. Sed vel accumsan diam. Cras aliquet eros eros, sit amet pharetra eros tincidunt ut. Vestibulum est erat, eleifend dapibus eros vel, elementum vehicula risus. Etiam blandit condimentum sodales. Donec non libero in orci aliquam egestas fringilla eget purus. Suspendisse pellentesque at ligula ut accumsan.';
13
14
  const p2 = 'Lorem ipsum dolor sit';
14
15
  export const Default = {
15
- render: () => (_jsx(Column, { children: _jsx(ReadMore, { text: p1, sx: { width: '250px' }, lines: 2, typography: TYPOGRAPHY_TYPE.PARAGRAPH_MEDIUM }) })),
16
+ render: () => (_jsx(Column, { children: _jsx(ReadMore, Object.assign({ sx: { width: '250px' }, lines: 2, typography: TYPOGRAPHY_TYPE.PARAGRAPH_MEDIUM }, { children: p1 })) })),
16
17
  };
17
18
  export const NotTruncated = {
18
- render: () => (_jsx(Column, { children: _jsx(ReadMore, { text: p2, sx: { width: '250px' }, lines: 2, typography: TYPOGRAPHY_TYPE.PARAGRAPH_MEDIUM }) })),
19
+ render: () => (_jsx(Column, { children: _jsx(ReadMore, Object.assign({ sx: { width: '250px' }, lines: 2, typography: TYPOGRAPHY_TYPE.PARAGRAPH_MEDIUM }, { children: p2 })) })),
20
+ };
21
+ export const CustomColor = {
22
+ render: () => (_jsx(Column, { children: _jsx(ReadMore, Object.assign({ lines: 2, typography: TYPOGRAPHY_TYPE.PARAGRAPH_MEDIUM, sx: {
23
+ color: COLOR.BACKGROUND,
24
+ bg: COLOR.PRIMARY,
25
+ width: '250px',
26
+ } }, { children: p1 })) })),
19
27
  };
@@ -3,8 +3,7 @@ import React from 'react';
3
3
  import { StyledElementProps } from '../../../../theme';
4
4
  import { TYPOGRAPHY_TYPE } from '../../../../theme/typography';
5
5
  export declare const ReadMore: React.FC<StyledElementProps<HTMLDivElement, {
6
- text: string;
7
6
  typography: TYPOGRAPHY_TYPE;
8
7
  lines: number;
9
8
  fixedHeight?: boolean;
10
- }>>;
9
+ }, string>>;
@@ -13,19 +13,23 @@ import { jsx as _jsx, jsxs as _jsxs } from "theme-ui/jsx-runtime";
13
13
  /** @jsxImportSource theme-ui */
14
14
  import React, { useState } from 'react';
15
15
  import { useTheme } from '../../../../theme';
16
- import { COLOR } from '../../../../theme/colors';
16
+ import { COLOR, colors } from '../../../../theme/colors';
17
17
  import { getTypographyStyles, } from '../../../../theme/typography';
18
- const ReadMoreLink = () => {
18
+ import { useMediaQuery } from '../../../../utils/hooks/useMediaQuery';
19
+ const ReadMoreLink = (props) => {
20
+ // const theme = useTheme()
21
+ const bg = colors[props.bg || COLOR.BACKGROUND];
22
+ const color = colors[props.color || COLOR.ND_BLUE_LIGHT];
19
23
  return (_jsx("div", Object.assign({ css: {
20
24
  whiteSpace: 'nowrap',
21
25
  position: 'absolute',
22
26
  right: 0,
23
27
  bottom: 0,
24
28
  paddingLeft: '3rem',
25
- background: 'linear-gradient(to right, rgba(255, 255, 255, 0), rgb(255, 255, 255) 30%, rgb(255, 255, 255))',
29
+ background: `linear-gradient(to right, ${bg}00, ${bg} 30%, ${bg} 100%)`,
26
30
  } }, { children: _jsx("div", Object.assign({ "aria-hidden": "true", sx: {
31
+ color,
27
32
  transform: 'scale(0.9)',
28
- color: COLOR.ND_BLUE_LIGHT,
29
33
  cursor: 'pointer',
30
34
  } }, { children: "Read More..." })) })));
31
35
  };
@@ -45,10 +49,12 @@ const useLinesHeight = (args) => {
45
49
  // This component does not use the css property `text-overflow: ellipsis`
46
50
  // because it does not work with multiple lines of text.
47
51
  export const ReadMore = (_a) => {
48
- var { text, typography, sx, role, lines, fixedHeight } = _a, rest = __rest(_a, ["text", "typography", "sx", "role", "lines", "fixedHeight"]);
52
+ var { typography, sx, role, lines, fixedHeight, children } = _a, rest = __rest(_a, ["typography", "sx", "role", "lines", "fixedHeight", "children"]);
49
53
  const ref = React.useRef(null);
50
54
  const [showEllipsis, setShowEllipsis] = useState(true);
51
55
  const wrapperHeight = useLinesHeight({ typography, lines });
56
+ const { screenSize } = useMediaQuery();
57
+ const { color, bg } = sx || {};
52
58
  React.useEffect(() => {
53
59
  if (ref.current) {
54
60
  // Check if the content exceeds the alloted space
@@ -66,9 +72,9 @@ export const ReadMore = (_a) => {
66
72
  setShowEllipsis(false);
67
73
  }
68
74
  }
69
- }, [text, wrapperHeight, fixedHeight]);
75
+ }, [children, wrapperHeight, fixedHeight, screenSize]);
70
76
  return (_jsxs("div", Object.assign({ role: role || 'paragraph', ref: ref, style: {
71
77
  overflow: 'hidden',
72
78
  position: 'relative',
73
- }, sx: Object.assign(Object.assign({}, getTypographyStyles(typography)), sx) }, rest, { children: [text, showEllipsis && _jsx(ReadMoreLink, {})] })));
79
+ }, sx: Object.assign(Object.assign({}, getTypographyStyles(typography)), sx) }, rest, { children: [children, showEllipsis && _jsx(ReadMoreLink, { bg: bg, color: color })] })));
74
80
  };
@@ -8,6 +8,7 @@ export type UiConfig = {
8
8
  alertsConfig?: AlertQueryParams;
9
9
  disableAlerts?: boolean;
10
10
  loadFonts?: boolean;
11
+ loadGlobalStyles?: boolean;
11
12
  };
12
13
  type UiProviderProps = PropsWithChildren<UiConfig>;
13
14
  export declare const UiProvider: React.FC<UiProviderProps>;
@@ -1,9 +1,10 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { ComponentConfigProvider, } from './componentConfig';
3
3
  import { EnvironmentProvider } from './env';
4
- import { ThemeProvider } from './theme';
4
+ import { ThemeProvider } from '../../theme/';
5
5
  import { AlertsProvider } from './alerts';
6
6
  import { FontLoader } from '../../FontLoader';
7
- export const UiProvider = ({ env, components, alertsConfig, children, loadFonts, }) => {
8
- return (_jsxs(EnvironmentProvider, Object.assign({ env: env }, { children: [_jsx(ComponentConfigProvider, Object.assign({ config: components || {} }, { children: _jsx(ThemeProvider, { children: _jsx(AlertsProvider, Object.assign({}, alertsConfig, { children: children })) }) })), loadFonts && _jsx(FontLoader, {})] })));
7
+ import { GlobalStyles } from '../../theme/GlobalStyles';
8
+ export const UiProvider = ({ env, components, alertsConfig, children, loadFonts, loadGlobalStyles, }) => {
9
+ return (_jsxs(EnvironmentProvider, Object.assign({ env: env }, { children: [_jsx(ComponentConfigProvider, Object.assign({ config: components || {} }, { children: _jsx(ThemeProvider, { children: _jsx(AlertsProvider, Object.assign({}, alertsConfig, { children: children })) }) })), loadGlobalStyles && _jsx(GlobalStyles, {}), loadFonts && _jsx(FontLoader, {})] })));
9
10
  };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export { theme, ThemeProvider, useTheme } from './theme';
2
2
  export { COLOR } from './theme/colors';
3
3
  export { TYPOGRAPHY_TYPE, FONT, FONT_SIZE, FONT_WEIGHT, LINE_HEIGHT, } from './theme/typography';
4
+ export { GlobalStyles } from './theme/GlobalStyles';
4
5
  export { Alert, Alerts } from './components/elements/Alerts';
5
6
  export { BrandingBar } from './components/elements/BrandingBar';
6
7
  export { Button, BUTTON_SIZE, BUTTON_TYPE } from './components/elements/Button';
@@ -25,7 +26,10 @@ export { RadioGroup } from './components/elements/Fields/RadioGroup';
25
26
  export { List, ListItem, LIST_SIZE } from './components/elements/List';
26
27
  export { ReadMore } from './components/elements/text/ReadMore';
27
28
  export { Icon } from './components/elements/Icon';
29
+ export { Spinner, SPINNER_SIZE } from './components/elements/Spinner';
28
30
  export { Card, CARD_SIZE, CARD_LAYOUT } from './components/composites/Card';
29
31
  export { UiProvider } from './components/providers/ui';
30
32
  export { MenuProvider, useMenu } from './components/providers/menu';
31
33
  export { useAlerts, AlertsProvider, ALERT_DOMAIN, } from './components/providers/alerts';
34
+ export { useHover } from './utils/hooks/useHover';
35
+ export { useMediaQuery } from './utils/hooks/useMediaQuery';
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  export { theme, ThemeProvider, useTheme } from './theme';
2
2
  export { COLOR } from './theme/colors';
3
3
  export { TYPOGRAPHY_TYPE, FONT, FONT_SIZE, FONT_WEIGHT, LINE_HEIGHT, } from './theme/typography';
4
+ export { GlobalStyles } from './theme/GlobalStyles';
4
5
  export { Alert, Alerts } from './components/elements/Alerts';
5
6
  export { BrandingBar } from './components/elements/BrandingBar';
6
7
  export { Button, BUTTON_SIZE, BUTTON_TYPE } from './components/elements/Button';
@@ -25,7 +26,10 @@ export { RadioGroup } from './components/elements/Fields/RadioGroup';
25
26
  export { List, ListItem, LIST_SIZE } from './components/elements/List';
26
27
  export { ReadMore } from './components/elements/text/ReadMore';
27
28
  export { Icon } from './components/elements/Icon';
29
+ export { Spinner, SPINNER_SIZE } from './components/elements/Spinner';
28
30
  export { Card, CARD_SIZE, CARD_LAYOUT } from './components/composites/Card';
29
31
  export { UiProvider } from './components/providers/ui';
30
32
  export { MenuProvider, useMenu } from './components/providers/menu';
31
33
  export { useAlerts, AlertsProvider, ALERT_DOMAIN, } from './components/providers/alerts';
34
+ export { useHover } from './utils/hooks/useHover';
35
+ export { useMediaQuery } from './utils/hooks/useMediaQuery';
@@ -147,6 +147,12 @@ const globalStyles = css `
147
147
  padding: 4px;
148
148
  }
149
149
 
150
+ .ndlib-date-picker .ndlib-date-picker-highlight {
151
+ background-color: ${colors.ndTertiary1};
152
+ border-radius: 0.3rem;
153
+ color: ${colors.background};
154
+ }
155
+
150
156
  @font-face {
151
157
  font-family: GPCMed;
152
158
  font-display: swap;
@@ -9,6 +9,7 @@ const meta = {
9
9
  };
10
10
  export default meta;
11
11
  const types = [
12
+ { type: TYPOGRAPHY_TYPE.PARAGRAPH_XSMALL, label: 'Paragraph X Small' },
12
13
  { type: TYPOGRAPHY_TYPE.PARAGRAPH_SMALL, label: 'Paragraph Small' },
13
14
  { type: TYPOGRAPHY_TYPE.PARAGRAPH_MEDIUM, label: 'Paragraph Medium' },
14
15
  { type: TYPOGRAPHY_TYPE.PARAGRAPH_LARGE, label: 'Paragraph Large' },
@@ -3,6 +3,7 @@ import { ThemeUICSSObject } from 'theme-ui';
3
3
  import { FONT, FONT_SIZE, FONT_WEIGHT, LINE_HEIGHT } from './typography';
4
4
  import { COLOR } from './colors';
5
5
  import { BOX_SHADOW } from './custom';
6
+ export declare const BREAKPOINTS: string[];
6
7
  export declare const SPACING: string[];
7
8
  export declare const theme: {
8
9
  colors: {
@@ -45,6 +46,7 @@ export declare const theme: {
45
46
  };
46
47
  space: string[];
47
48
  boxShadow: typeof BOX_SHADOW;
49
+ breakpoints: string[];
48
50
  fonts: {
49
51
  branded: string;
50
52
  branded2: string;
@@ -85,7 +87,7 @@ export type StylesProp = ThemeUICSSObject & {
85
87
  export type StyledElementProps<E extends Element, CustomProps = object, Children = React.ReactNode> = {
86
88
  sx?: StylesProp;
87
89
  children?: Children;
88
- } & React.HTMLAttributes<E> & CustomProps;
90
+ } & Omit<React.HTMLAttributes<E>, 'children'> & CustomProps;
89
91
  export declare const useTheme: () => {
90
92
  colors: {
91
93
  text: string;
@@ -127,6 +129,7 @@ export declare const useTheme: () => {
127
129
  };
128
130
  space: string[];
129
131
  boxShadow: typeof BOX_SHADOW;
132
+ breakpoints: string[];
130
133
  fonts: {
131
134
  branded: string;
132
135
  branded2: string;
@@ -1,8 +1,9 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { ThemeProvider as ThemeUiProvider, useThemeUI, } from 'theme-ui';
2
+ import { ThemeUIProvider, useThemeUI } from 'theme-ui';
3
3
  import { fontStyles, } from './typography';
4
4
  import { colors } from './colors';
5
5
  import { BOX_SHADOW } from './custom';
6
+ export const BREAKPOINTS = ['576px', '768px', '992px', '1200px', '1400px'];
6
7
  export const SPACING = [
7
8
  '0rem',
8
9
  '0.25rem',
@@ -14,11 +15,11 @@ export const SPACING = [
14
15
  '3rem',
15
16
  '4rem',
16
17
  ];
17
- export const theme = Object.assign(Object.assign({}, fontStyles), { colors, space: SPACING, boxShadow: BOX_SHADOW });
18
+ export const theme = Object.assign(Object.assign({}, fontStyles), { colors, space: SPACING, boxShadow: BOX_SHADOW, breakpoints: BREAKPOINTS });
18
19
  export const useTheme = () => {
19
20
  const { theme } = useThemeUI();
20
21
  return theme;
21
22
  };
22
23
  export const ThemeProvider = ({ children }) => {
23
- return _jsx(ThemeUiProvider, Object.assign({ theme: theme }, { children: children }));
24
+ return _jsx(ThemeUIProvider, Object.assign({ theme: theme }, { children: children }));
24
25
  };
@@ -63,6 +63,7 @@ export declare const fontStyles: {
63
63
  };
64
64
  };
65
65
  export declare enum TYPOGRAPHY_TYPE {
66
+ PARAGRAPH_XSMALL = "paragraphXSmall",
66
67
  PARAGRAPH_SMALL = "paragraphSmall",
67
68
  PARAGRAPH_MEDIUM = "paragraphMedium",
68
69
  PARAGRAPH_LARGE = "paragraphLarge",
@@ -74,6 +74,7 @@ export const fontStyles = {
74
74
  };
75
75
  export var TYPOGRAPHY_TYPE;
76
76
  (function (TYPOGRAPHY_TYPE) {
77
+ TYPOGRAPHY_TYPE["PARAGRAPH_XSMALL"] = "paragraphXSmall";
77
78
  TYPOGRAPHY_TYPE["PARAGRAPH_SMALL"] = "paragraphSmall";
78
79
  TYPOGRAPHY_TYPE["PARAGRAPH_MEDIUM"] = "paragraphMedium";
79
80
  TYPOGRAPHY_TYPE["PARAGRAPH_LARGE"] = "paragraphLarge";
@@ -89,6 +90,12 @@ export var TYPOGRAPHY_TYPE;
89
90
  TYPOGRAPHY_TYPE["HEADLINE_LARGE"] = "headlineLarge";
90
91
  })(TYPOGRAPHY_TYPE || (TYPOGRAPHY_TYPE = {}));
91
92
  export const typographyStyleMap = {
93
+ [TYPOGRAPHY_TYPE.PARAGRAPH_XSMALL]: {
94
+ fontFamily: FONT.NORMAL,
95
+ fontSize: FONT_SIZE.XS,
96
+ lineHeight: LINE_HEIGHT.NORMAL,
97
+ fontWeight: FONT_WEIGHT.NORMAL,
98
+ },
92
99
  [TYPOGRAPHY_TYPE.PARAGRAPH_SMALL]: {
93
100
  fontFamily: FONT.NORMAL,
94
101
  fontSize: FONT_SIZE.SM,
@@ -0,0 +1,7 @@
1
+ export declare const useHover: () => {
2
+ isHovered: boolean;
3
+ anchorElementProps: {
4
+ onMouseEnter: () => void;
5
+ onMouseLeave: () => void;
6
+ };
7
+ };
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ export const useHover = () => {
3
+ const [isHovered, setIsHovered] = React.useState(false);
4
+ const anchorElementProps = {
5
+ onMouseEnter: () => setIsHovered(true),
6
+ onMouseLeave: () => setIsHovered(false),
7
+ };
8
+ return {
9
+ isHovered,
10
+ anchorElementProps,
11
+ };
12
+ };
@@ -0,0 +1,4 @@
1
+ export declare const useMediaQuery: () => {
2
+ screenSize: number;
3
+ breakpoint: number;
4
+ };
@@ -0,0 +1,28 @@
1
+ import { useEffect, useState } from 'react';
2
+ import { useTheme } from '../../theme';
3
+ export const useMediaQuery = () => {
4
+ const [screenSize, setScreenSize] = useState(typeof window !== 'undefined' ? window.innerWidth : 0);
5
+ const [breakpoint, setBreakpoint] = useState(5);
6
+ const theme = useTheme();
7
+ const breakpoints = theme.breakpoints.map((bp) => parseInt(bp.slice(0, -2)), [theme]);
8
+ useEffect(() => {
9
+ if (typeof window === 'undefined')
10
+ return;
11
+ const handleResize = () => {
12
+ const screenSize = window.innerWidth;
13
+ let closestBreakpoint = breakpoints.findIndex((bp) => screenSize < bp);
14
+ closestBreakpoint =
15
+ closestBreakpoint === -1 ? breakpoints.length : closestBreakpoint;
16
+ setBreakpoint(closestBreakpoint);
17
+ setScreenSize(screenSize);
18
+ };
19
+ window.addEventListener('resize', handleResize);
20
+ return () => {
21
+ window.removeEventListener('resize', handleResize);
22
+ };
23
+ }, []); // eslint-disable-line react-hooks/exhaustive-deps
24
+ return {
25
+ screenSize,
26
+ breakpoint,
27
+ };
28
+ };
@@ -11,3 +11,4 @@ export declare enum KEY_CODES {
11
11
  ESCAPE = "Escape"
12
12
  }
13
13
  export declare const equals: (a: any, b: any) => boolean;
14
+ export declare function importedDefaultComponentShim<T>(component: T): T;
@@ -14,3 +14,15 @@ export var KEY_CODES;
14
14
  KEY_CODES["ESCAPE"] = "Escape";
15
15
  })(KEY_CODES || (KEY_CODES = {}));
16
16
  export const equals = (a, b) => JSON.stringify(a) === JSON.stringify(b);
17
+ // @mui/material-icons and react-datepicker dependencies exports
18
+ // their modules as { default: Component } with is causing problems
19
+ // when included in downstream apps. This shim prevents issues by
20
+ // resolving ambiguity on how to handle the imports explicitly
21
+ export function importedDefaultComponentShim(component) {
22
+ if (component && typeof component === 'object' && 'default' in component) {
23
+ return component.default;
24
+ }
25
+ else {
26
+ return component;
27
+ }
28
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ndlib/component-library",
3
- "version": "0.0.21",
3
+ "version": "0.0.23",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "files": [
@@ -1,2 +0,0 @@
1
- import { PropsWithChildren } from 'react';
2
- export declare const ThemeProvider: React.FC<PropsWithChildren>;
@@ -1,6 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { ThemeProvider as ThemeUiProvider } from 'theme-ui';
3
- import { theme } from '../../theme';
4
- export const ThemeProvider = ({ children }) => {
5
- return _jsx(ThemeUiProvider, Object.assign({ theme: theme }, { children: children }));
6
- };