@ndlib/component-library 0.0.93 → 0.0.95

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 (29) hide show
  1. package/dist/components/elements/Alerts/Alert.stories.d.ts +1 -0
  2. package/dist/components/elements/Alerts/Alert.stories.js +8 -0
  3. package/dist/components/elements/Alerts/index.js +9 -1
  4. package/dist/components/elements/BlockQuote/index.d.ts +5 -0
  5. package/dist/components/elements/BlockQuote/index.js +18 -0
  6. package/dist/components/elements/Fields/Checkbox/index.d.ts +1 -0
  7. package/dist/components/elements/Fields/Checkbox/index.js +3 -3
  8. package/dist/components/elements/Fields/CheckboxGroup/CheckboxGroup.stories.d.ts +1 -0
  9. package/dist/components/elements/Fields/CheckboxGroup/CheckboxGroup.stories.js +6 -3
  10. package/dist/components/elements/Fields/CheckboxGroup/index.d.ts +1 -0
  11. package/dist/components/elements/Fields/CheckboxGroup/index.js +3 -2
  12. package/dist/components/elements/Fields/Radio/index.d.ts +1 -0
  13. package/dist/components/elements/Fields/Radio/index.js +3 -3
  14. package/dist/components/elements/Fields/RadioGroup/RadioGroup.stories.d.ts +1 -0
  15. package/dist/components/elements/Fields/RadioGroup/RadioGroup.stories.js +4 -1
  16. package/dist/components/elements/Fields/RadioGroup/index.d.ts +1 -0
  17. package/dist/components/elements/Fields/RadioGroup/index.js +1 -1
  18. package/dist/components/elements/Markdown/Markdown.stories.js +7 -0
  19. package/dist/components/elements/Markdown/Markdown.test.js +17 -8
  20. package/dist/components/elements/Markdown/index.d.ts +1 -0
  21. package/dist/components/elements/Markdown/index.js +11 -16
  22. package/dist/components/elements/text/Heading/index.js +27 -1
  23. package/dist/components/elements/text/Paragraph/index.js +1 -1
  24. package/dist/components/providers/alerts.d.ts +2 -1
  25. package/dist/components/providers/alerts.js +1 -0
  26. package/dist/theme/colors.d.ts +4 -1
  27. package/dist/theme/colors.js +4 -0
  28. package/dist/theme/index.d.ts +4 -2
  29. package/package.json +1 -1
@@ -7,3 +7,4 @@ export declare const Default: Story;
7
7
  export declare const InformationalAlert: Story;
8
8
  export declare const YellowAlert: Story;
9
9
  export declare const WarningAlert: Story;
10
+ export declare const SuccessAlert: Story;
@@ -39,3 +39,11 @@ export const WarningAlert = {
39
39
  description: 'This is a warning alert',
40
40
  },
41
41
  };
42
+ export const SuccessAlert = {
43
+ render: (args) => _jsx(Alert, Object.assign({}, args)),
44
+ args: {
45
+ title: 'Success Alert',
46
+ type: ALERT_TYPE.SUCCESS,
47
+ description: 'This is a success alert',
48
+ },
49
+ };
@@ -12,6 +12,7 @@ var __rest = (this && this.__rest) || function (s, e) {
12
12
  import { jsx as _jsx, jsxs as _jsxs } from "theme-ui/jsx-runtime";
13
13
  import _WarningIcon from '@mui/icons-material/Warning';
14
14
  import _InfoIcon from '@mui/icons-material/Info';
15
+ import _SuccessIcon from '@mui/icons-material/CheckCircle';
15
16
  import { COLOR } from '../../../theme/colors';
16
17
  import { Markdown } from '../Markdown';
17
18
  import { Row } from '../layout/Row';
@@ -23,6 +24,7 @@ import { BUTTON_TYPE, Button } from '../Button';
23
24
  import { importedDefaultComponentShim } from '../../../utils/misc';
24
25
  const WarningIcon = importedDefaultComponentShim(_WarningIcon);
25
26
  const InfoIcon = importedDefaultComponentShim(_InfoIcon);
27
+ const SuccessIcon = importedDefaultComponentShim(_SuccessIcon);
26
28
  export const Alerts = (_a) => {
27
29
  var { pageAlerts } = _a, rest = __rest(_a, ["pageAlerts"]);
28
30
  const { alerts, dismiss } = useAlerts(pageAlerts);
@@ -55,19 +57,25 @@ export const Alert = (_a) => {
55
57
  style.backgroundColor = COLOR.ALERT_WARNING_BG;
56
58
  style.borderColor = COLOR.ALERT_WARNING_BORDER;
57
59
  }
60
+ else if (type === ALERT_TYPE.SUCCESS) {
61
+ style.backgroundColor = COLOR.ALERT_SUCCESS_BG;
62
+ style.borderColor = COLOR.ALERT_SUCCESS_BORDER;
63
+ }
58
64
  const icon = {
59
65
  [ALERT_TYPE.WARNING]: WarningIcon,
60
66
  [ALERT_TYPE.INFORMATIONAL_YELLOW]: InfoIcon,
61
67
  [ALERT_TYPE.INFORMATIONAL]: InfoIcon,
68
+ [ALERT_TYPE.SUCCESS]: SuccessIcon,
62
69
  }[type];
63
70
  return (_jsx(Row, Object.assign({ sx: Object.assign({}, style) }, rest, { centered: true }, { children: _jsxs(Row, Object.assign({ sx: {
64
71
  boxSizing: 'border-box',
65
72
  margin: '0 auto',
66
73
  pl: '.5rem',
67
74
  pr: '.5rem',
75
+ width: '100%',
68
76
  '@media screen and (min-width: 1212px)': {
69
77
  maxWidth: '1200px',
70
78
  padding: '0',
71
79
  },
72
- } }, { children: [icon && _jsx(Icon, { icon: icon, sx: { mr: 4 }, size: FONT_SIZE.LG }), _jsx(Markdown, { content: description, sx: { mt: 1, flexGrow: 1 } }), _jsx(Button, Object.assign({ type: BUTTON_TYPE.TEXT, onClick: dismiss, sx: { ml: 4 } }, { children: "Dismiss" }))] })) })));
80
+ } }, { children: [icon && _jsx(Icon, { icon: icon, sx: { mr: 4 }, size: FONT_SIZE.LG }), _jsx(Row, Object.assign({ sx: { flexGrow: 1, justifyContent: 'center' } }, { children: _jsx(Markdown, { content: description }) })), _jsx(Button, Object.assign({ type: BUTTON_TYPE.TEXT, onClick: dismiss, sx: { ml: 4 } }, { children: "Dismiss" }))] })) })));
73
81
  };
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import { StyledElementProps } from '../../../theme';
3
+ type BlockQuoteProps = StyledElementProps<HTMLQuoteElement>;
4
+ export declare const BlockQuote: React.FC<BlockQuoteProps>;
5
+ export {};
@@ -0,0 +1,18 @@
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 } from "theme-ui/jsx-runtime";
13
+ import { COLOR } from '../../../theme/colors';
14
+ import { TYPOGRAPHY_TYPE, getTypographyStyles } from '../../../theme/typography';
15
+ export const BlockQuote = (_a) => {
16
+ var { sx } = _a, props = __rest(_a, ["sx"]);
17
+ return (_jsx("blockquote", Object.assign({}, props, { sx: Object.assign(Object.assign({ ml: 5, borderLeft: '8px solid', borderColor: COLOR.ND_BLUE_BRIGHT, p: 4, color: COLOR.GRAY }, getTypographyStyles(TYPOGRAPHY_TYPE.PARAGRAPH_LARGE)), sx) })));
18
+ };
@@ -3,6 +3,7 @@ import { StyledElementProps } from '../../../../theme';
3
3
  type CheckboxProps = StyledElementProps<HTMLInputElement, {
4
4
  checked: boolean;
5
5
  onChange: (value: boolean) => void;
6
+ disabled?: boolean;
6
7
  }, string>;
7
8
  export declare const Checkbox: React.FC<CheckboxProps>;
8
9
  export {};
@@ -12,11 +12,11 @@ var __rest = (this && this.__rest) || function (s, e) {
12
12
  import { jsx as _jsx } from "theme-ui/jsx-runtime";
13
13
  import { useTheme } from '../../../../theme';
14
14
  export const Checkbox = (_a) => {
15
- var { checked, onChange, sx } = _a, rest = __rest(_a, ["checked", "onChange", "sx"]);
15
+ var { checked, onChange, disabled, sx } = _a, rest = __rest(_a, ["checked", "onChange", "disabled", "sx"]);
16
16
  const theme = useTheme();
17
17
  return (_jsx("input", Object.assign({ type: "checkbox", onChange: (e) => {
18
18
  onChange(e.target.checked);
19
- }, checked: checked, sx: Object.assign({ margin: '0px', height: '1.25rem', width: '1.25rem', cursor: 'pointer', ':hover': {
19
+ }, checked: checked, sx: Object.assign({ margin: '0px', height: '1.25rem', width: '1.25rem', cursor: disabled ? 'not-allowed' : 'pointer', ':hover': {
20
20
  boxShadow: theme.boxShadow,
21
- } }, sx) }, rest)));
21
+ } }, sx), disabled: disabled }, rest)));
22
22
  };
@@ -5,3 +5,4 @@ export default meta;
5
5
  type Story = StoryObj<typeof CheckboxGroup>;
6
6
  export declare const Default: Story;
7
7
  export declare const Columns: Story;
8
+ export declare const Disabled: Story;
@@ -9,14 +9,14 @@ const meta = {
9
9
  };
10
10
  export default meta;
11
11
  const options = [
12
- { value: 'orange', label: 'Orange' },
12
+ { value: 'orange', label: 'Orange', disabled: true },
13
13
  { value: 'apple', label: 'Apple' },
14
14
  { value: 'strawberry', label: 'Strawberry' },
15
15
  { value: 'pineapple', label: 'Pineapple' },
16
16
  ];
17
17
  const StatefulCheckboxGroup = (props) => {
18
- const [checked, setChecked] = useState(new Set());
19
- return (_jsx(CheckboxGroup, Object.assign({}, props, { checkedOptions: checked, options: options, onChange: setChecked })));
18
+ const [checked, setChecked] = useState(new Set(['orange']));
19
+ return (_jsx(CheckboxGroup, Object.assign({}, props, { checkedOptions: checked, options: props.options || options, onChange: setChecked })));
20
20
  };
21
21
  export const Default = {
22
22
  render: () => (_jsx(Row, { children: _jsx(StatefulCheckboxGroup, {}) })),
@@ -24,3 +24,6 @@ export const Default = {
24
24
  export const Columns = {
25
25
  render: () => (_jsx(Row, { children: _jsx(StatefulCheckboxGroup, { columns: 2 }) })),
26
26
  };
27
+ export const Disabled = {
28
+ render: () => (_jsx(Row, { children: _jsx(StatefulCheckboxGroup, { options: options.map((option, i) => (Object.assign(Object.assign({}, option), { disabled: i === 1 ? true : false }))) }) })),
29
+ };
@@ -3,6 +3,7 @@ import { Key } from '../option';
3
3
  type Option<K extends Key = string> = {
4
4
  value: K;
5
5
  label: string;
6
+ disabled?: boolean;
6
7
  };
7
8
  type CheckboxGroupProps<K extends Key = string> = StyledElementProps<HTMLDivElement, {
8
9
  onChange: (value: Set<K>) => void;
@@ -18,6 +18,7 @@ import { Group } from '../../Group';
18
18
  import { GROUP_TYPE } from '../../Group';
19
19
  import { Column } from '../../layout/Column';
20
20
  import { TYPOGRAPHY_TYPE, getTypographyStyles, } from '../../../../theme/typography';
21
+ import { COLOR } from '../../../../theme/colors';
21
22
  export function CheckboxGroup(_a) {
22
23
  var { options, checkedOptions, columns: columnsProp, columnStyles, rowStyles, onChange } = _a, rest = __rest(_a, ["options", "checkedOptions", "columns", "columnStyles", "rowStyles", "onChange"]);
23
24
  const columns = columnsProp || 1;
@@ -42,8 +43,8 @@ export function CheckboxGroup(_a) {
42
43
  updatedSet.delete(option.value);
43
44
  }
44
45
  onChange(updatedSet);
45
- }, checked: !!(checkedOptions === null || checkedOptions === void 0 ? void 0 : checkedOptions.has(option.value)), id: labelTargetId, sx: {
46
+ }, checked: !!(checkedOptions === null || checkedOptions === void 0 ? void 0 : checkedOptions.has(option.value)), id: labelTargetId, disabled: option.disabled, sx: {
46
47
  mr: 2,
47
48
  flexShrink: 0,
48
- } }), _jsx(Label, Object.assign({ sx: Object.assign({ cursor: 'pointer' }, getTypographyStyles(TYPOGRAPHY_TYPE.CONDENSED_TEXT_MEDIUM)) }, { children: option.label }))] }))) }), option.value))) }), index))) })));
49
+ } }), _jsx(Label, Object.assign({ sx: Object.assign(Object.assign({ cursor: option.disabled ? 'not-allowed' : 'pointer' }, getTypographyStyles(TYPOGRAPHY_TYPE.CONDENSED_TEXT_MEDIUM)), { color: option.disabled ? COLOR.GRAY : undefined }) }, { children: option.label }))] }))) }), option.value))) }), index))) })));
49
50
  }
@@ -3,6 +3,7 @@ import { StyledElementProps } from '../../../../theme';
3
3
  type RadioProps = StyledElementProps<HTMLInputElement, {
4
4
  checked: boolean;
5
5
  onChange: (value: boolean) => void;
6
+ disabled?: boolean;
6
7
  }, string>;
7
8
  export declare const Radio: React.FC<RadioProps>;
8
9
  export {};
@@ -12,11 +12,11 @@ var __rest = (this && this.__rest) || function (s, e) {
12
12
  import { jsx as _jsx } from "theme-ui/jsx-runtime";
13
13
  import { useTheme } from '../../../../theme';
14
14
  export const Radio = (_a) => {
15
- var { checked, onChange, sx } = _a, rest = __rest(_a, ["checked", "onChange", "sx"]);
15
+ var { checked, onChange, disabled, sx } = _a, rest = __rest(_a, ["checked", "onChange", "disabled", "sx"]);
16
16
  const theme = useTheme();
17
17
  return (_jsx("input", Object.assign({ type: "radio", onChange: (e) => {
18
18
  onChange(e.target.checked);
19
- }, checked: checked, sx: Object.assign({ margin: '0px', height: '1.25rem', width: '1.25rem', cursor: 'pointer', ':hover': {
19
+ }, checked: checked, sx: Object.assign({ margin: '0px', height: '1.25rem', width: '1.25rem', cursor: disabled ? 'not-allowed' : 'pointer', ':hover': {
20
20
  boxShadow: theme.boxShadow,
21
- } }, sx) }, rest)));
21
+ } }, sx), disabled: disabled }, rest)));
22
22
  };
@@ -4,3 +4,4 @@ declare const meta: Meta<typeof RadioGroup>;
4
4
  export default meta;
5
5
  type Story = StoryObj<typeof RadioGroup>;
6
6
  export declare const Default: Story;
7
+ export declare const Disabled: Story;
@@ -16,8 +16,11 @@ const options = [
16
16
  ];
17
17
  const StatefulRadioGroup = (props) => {
18
18
  const [checked, setChecked] = useState(new Set());
19
- return (_jsx(RadioGroup, Object.assign({}, props, { checked: checked, options: options, onChange: setChecked })));
19
+ return (_jsx(RadioGroup, Object.assign({}, props, { checked: checked, options: props.options || options, onChange: setChecked })));
20
20
  };
21
21
  export const Default = {
22
22
  render: () => (_jsx(Row, { children: _jsx(StatefulRadioGroup, {}) })),
23
23
  };
24
+ export const Disabled = {
25
+ render: () => (_jsx(Row, { children: _jsx(StatefulRadioGroup, { options: options.map((option, i) => (Object.assign(Object.assign({}, option), { disabled: i === 1 ? true : false }))) }) })),
26
+ };
@@ -3,6 +3,7 @@ import { Key } from '../option';
3
3
  type Option<K extends Key = string> = {
4
4
  value: K;
5
5
  label: string;
6
+ disabled?: boolean;
6
7
  };
7
8
  type RadioGroupProps<K extends Key = string> = StyledElementProps<HTMLDivElement, {
8
9
  onChange: (value: K) => void;
@@ -24,5 +24,5 @@ export function RadioGroup(_a) {
24
24
  }, checked: checked === option.value, id: labelTargetId, sx: {
25
25
  mr: 2,
26
26
  flexShrink: 0,
27
- } }), _jsx(Label, Object.assign({ sx: Object.assign({ cursor: 'pointer' }, getTypographyStyles(TYPOGRAPHY_TYPE.PARAGRAPH_MEDIUM)) }, { children: option.label }))] }))) }), option.value))) })));
27
+ }, disabled: option.disabled }), _jsx(Label, Object.assign({ sx: Object.assign({ cursor: option.disabled ? 'not-allowed' : 'pointer' }, getTypographyStyles(TYPOGRAPHY_TYPE.PARAGRAPH_MEDIUM)) }, { children: option.label }))] }))) }), option.value))) })));
28
28
  }
@@ -48,6 +48,13 @@ ${sampleParagraph}
48
48
  1. List item 1
49
49
  2. List item 2
50
50
  3. List item 3
51
+
52
+ > Lorem ipsum dolor sit amet, consectetur adipiscing elit,
53
+ sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
54
+ Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
55
+ nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in
56
+ reprehenderit in voluptate velit esse cillum dolore eu fugiat
57
+ nulla pariatur.
51
58
  `;
52
59
  export const Default = {
53
60
  render: (args) => _jsx(Markdown, Object.assign({}, args)),
@@ -28,6 +28,13 @@ This paragraph has __bold content__ and **more bold content** and _italic conten
28
28
  1. List item 1
29
29
  2. List item 2
30
30
  3. List item 3
31
+
32
+ > Lorem ipsum dolor sit amet, consectetur adipiscing elit,
33
+ sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
34
+ Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
35
+ nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in
36
+ reprehenderit in voluptate velit esse cillum dolore eu fugiat
37
+ nulla pariatur.
31
38
  `;
32
39
  const htmlMarkdown = `
33
40
  ## HTML Content
@@ -41,28 +48,30 @@ const htmlMarkdown = `
41
48
  describe('Markdown', () => {
42
49
  it('renders alert content', () => {
43
50
  const { getAllByRole, getByRole } = render(_jsx(Markdown, { content: testMarkdown }));
51
+ expect(() => {
52
+ getByRole('heading', {
53
+ name: 'Heading 1',
54
+ level: 1,
55
+ });
56
+ }).toThrow();
44
57
  expect(getByRole('heading', {
45
58
  name: 'Heading 1',
46
- level: 1,
47
- })).toBeInTheDocument();
48
- expect(getByRole('heading', {
49
- name: 'Heading 2',
50
59
  level: 2,
51
60
  })).toBeInTheDocument();
52
61
  expect(getByRole('heading', {
53
- name: 'Heading 3',
62
+ name: 'Heading 2',
54
63
  level: 3,
55
64
  })).toBeInTheDocument();
56
65
  expect(getByRole('heading', {
57
- name: 'Heading 4',
66
+ name: 'Heading 3',
58
67
  level: 4,
59
68
  })).toBeInTheDocument();
60
69
  expect(getByRole('heading', {
61
- name: 'Heading 5',
70
+ name: 'Heading 4',
62
71
  level: 5,
63
72
  })).toBeInTheDocument();
64
73
  expect(getByRole('heading', {
65
- name: 'Heading 6',
74
+ name: 'Heading 5',
66
75
  level: 6,
67
76
  })).toBeInTheDocument();
68
77
  expect(getAllByRole('list')).toHaveLength(3);
@@ -11,6 +11,7 @@ type MarkdownProps = StyledElementProps<HTMLDivElement, {
11
11
  content: string;
12
12
  enableHtml?: boolean;
13
13
  imageStyles?: React.CSSProperties;
14
+ headingLevelOffset?: number;
14
15
  sanitizeHtmlOptions?: {
15
16
  allowedTags?: string[];
16
17
  allowedIframeDomains?: string[];
@@ -18,6 +18,7 @@ import { HEADING_SIZE, Heading } from '../text/Heading';
18
18
  import { Bold, Italic } from '../text/Inline';
19
19
  import { firstChildAltSelector } from '../../../utils/misc';
20
20
  import sanitizeHtml from 'sanitize-html';
21
+ import { BlockQuote } from '../BlockQuote';
21
22
  export const DEFAULT_ALLOWED_TAGS = sanitizeHtml.defaults.allowedTags.concat([
22
23
  'iframe',
23
24
  ]);
@@ -31,20 +32,13 @@ export const DEFAULT_ALLOWED_IFRAME_DOMAINS = [
31
32
  'youtube.com',
32
33
  'nd.edu',
33
34
  ];
34
- const headingStyles = {
35
- mt: 4,
36
- [firstChildAltSelector]: {
37
- mt: 0,
38
- },
39
- };
40
- const paragraphStyles = {
41
- mt: 4,
35
+ const dynamicTopMarginStyles = {
42
36
  [firstChildAltSelector]: {
43
37
  mt: 0,
44
38
  },
45
39
  };
46
40
  export const Markdown = (_a) => {
47
- var { content, enableHtml, sanitizeHtmlOptions, imageStyles } = _a, rest = __rest(_a, ["content", "enableHtml", "sanitizeHtmlOptions", "imageStyles"]);
41
+ var { content, enableHtml, sanitizeHtmlOptions, imageStyles, headingLevelOffset = 1 } = _a, rest = __rest(_a, ["content", "enableHtml", "sanitizeHtmlOptions", "imageStyles", "headingLevelOffset"]);
48
42
  let sanitizedContent = content;
49
43
  if (enableHtml) {
50
44
  sanitizedContent = sanitizeHtml(content, {
@@ -55,21 +49,22 @@ export const Markdown = (_a) => {
55
49
  });
56
50
  }
57
51
  return (_jsx("div", Object.assign({}, rest, { children: _jsx(ReactMarkdown, Object.assign({ rehypePlugins: enableHtml ? [rehypeRaw] : [], components: {
58
- h1: (props) => (_jsx(Heading, Object.assign({ size: HEADING_SIZE.XL }, props, { standalone: true, sx: headingStyles, "aria-level": 1 }))),
59
- h2: (props) => (_jsx(Heading, Object.assign({ size: HEADING_SIZE.LG }, props, { standalone: true, sx: headingStyles, "aria-level": 2 }))),
60
- h3: (props) => (_jsx(Heading, Object.assign({ size: HEADING_SIZE.MD }, props, { standalone: true, sx: headingStyles, "aria-level": 3 }))),
61
- h4: (props) => (_jsx(Heading, Object.assign({ size: HEADING_SIZE.SM }, props, { standalone: true, sx: headingStyles, "aria-level": 4 }))),
62
- h5: (props) => (_jsx(Heading, Object.assign({ size: HEADING_SIZE.SM }, props, { standalone: true, sx: headingStyles, "aria-level": 5 }))),
63
- h6: (props) => (_jsx(Heading, Object.assign({ size: HEADING_SIZE.SM }, props, { standalone: true, sx: headingStyles, "aria-level": 6 }))),
52
+ h1: (props) => (_jsx(Heading, Object.assign({ size: HEADING_SIZE.XL }, props, { level: props.level + headingLevelOffset, standalone: true, sx: dynamicTopMarginStyles }))),
53
+ h2: (props) => (_jsx(Heading, Object.assign({ size: HEADING_SIZE.LG }, props, { level: props.level + headingLevelOffset, standalone: true, sx: dynamicTopMarginStyles }))),
54
+ h3: (props) => (_jsx(Heading, Object.assign({ size: HEADING_SIZE.MD }, props, { level: props.level + headingLevelOffset, standalone: true, sx: dynamicTopMarginStyles }))),
55
+ h4: (props) => (_jsx(Heading, Object.assign({ size: HEADING_SIZE.SM }, props, { level: props.level + headingLevelOffset, standalone: true, sx: dynamicTopMarginStyles }))),
56
+ h5: (props) => (_jsx(Heading, Object.assign({ size: HEADING_SIZE.SM }, props, { standalone: true, level: props.level + headingLevelOffset, sx: dynamicTopMarginStyles }))),
57
+ h6: (props) => (_jsx(Heading, Object.assign({ size: HEADING_SIZE.SM }, props, { standalone: true, level: props.level + headingLevelOffset, sx: dynamicTopMarginStyles }))),
64
58
  ol: (props) => _jsx(List, Object.assign({}, props, { ordered: true, sx: { mt: 4 } })),
65
59
  ul: (props) => _jsx(List, Object.assign({}, props, { sx: { mt: 4 } })),
66
60
  li: (_a) => {
67
61
  var { index, ordered } = _a, props = __rest(_a, ["index", "ordered"]);
68
62
  return (_jsx(ListItem, Object.assign({ index: index }, props)));
69
63
  },
70
- p: (props) => _jsx(Paragraph, Object.assign({}, props, { sx: paragraphStyles })),
64
+ p: (props) => (_jsx(Paragraph, Object.assign({}, props, { sx: Object.assign(Object.assign({}, dynamicTopMarginStyles), { fontSize: 'inherit' }) }))),
71
65
  strong: (props) => _jsx(Bold, Object.assign({}, props)),
72
66
  em: (props) => _jsx(Italic, Object.assign({}, props)),
73
67
  img: (props) => _jsx("img", Object.assign({}, props, { style: imageStyles })),
68
+ blockquote: (props) => (_jsx(BlockQuote, Object.assign({}, props, { sx: Object.assign(Object.assign({}, dynamicTopMarginStyles), { my: 5 }) }))),
74
69
  } }, { children: sanitizedContent })) })));
75
70
  };
@@ -12,9 +12,11 @@ var __rest = (this && this.__rest) || function (s, e) {
12
12
  import { jsx as _jsx } from "theme-ui/jsx-runtime";
13
13
  import { useEffect } from 'react';
14
14
  import { getTypographyStyles, TYPOGRAPHY_TYPE, } from '../../../../theme/typography';
15
+ import { useTheme } from '../../../../theme';
15
16
  import { GROUP_TYPE, useGroup } from '../../Group';
16
17
  import { COLOR } from '../../../../theme/colors';
17
18
  import { useEnvironment } from '../../../providers/env';
19
+ import { multiplyRemSize } from '../../../../utils/misc';
18
20
  export var HEADING_SIZE;
19
21
  (function (HEADING_SIZE) {
20
22
  HEADING_SIZE["SM"] = "sm";
@@ -40,6 +42,7 @@ export const Heading = (_a) => {
40
42
  var { sx, size, standalone, underline, underlineColor, typography: typographyProp, level: levelParam } = _a, rest = __rest(_a, ["sx", "size", "standalone", "underline", "underlineColor", "typography", "level"]);
41
43
  const { level: groupLevel, labelId, type, trackHeadingRendered } = useGroup();
42
44
  const { flagInDevelopment } = useEnvironment();
45
+ const theme = useTheme();
43
46
  const level = levelParam || groupLevel;
44
47
  useEffect(() => {
45
48
  trackHeadingRendered();
@@ -55,8 +58,31 @@ export const Heading = (_a) => {
55
58
  typography =
56
59
  LEVEL_TYPOGRAPHY_MAP[level];
57
60
  }
61
+ const typographyStyles = getTypographyStyles(typography);
62
+ const marginHeightMultiple = theme.lineHeights[typographyStyles.lineHeight] * 0.375;
63
+ const fontSize = theme.fontSizes[typographyStyles.fontSize];
64
+ const topMargin = multiplyRemSize({
65
+ size: fontSize,
66
+ multiple: marginHeightMultiple,
67
+ });
58
68
  if (type !== GROUP_TYPE.REGION && !standalone) {
59
69
  flagInDevelopment('Heading component should be used within a Group component with property type={GROUP_TYPE.REGION} or given the standalone flag');
60
70
  }
61
- return (_jsx("div", Object.assign({ id: labelId, role: "heading", "aria-level": level, sx: Object.assign(Object.assign({ py: 0, borderBottom: underline ? 'solid 2px' : undefined, borderBottomColor: underlineColor ? underlineColor : COLOR.SECONDARY, color: COLOR.PRIMARY }, getTypographyStyles(typography)), sx) }, rest)));
71
+ const headerProps = Object.assign({ id: labelId, role: 'heading', 'aria-level': level, sx: Object.assign(Object.assign({ py: 0, borderBottom: underline ? 'solid 2px' : undefined, borderBottomColor: underlineColor ? underlineColor : COLOR.SECONDARY, color: COLOR.PRIMARY, mt: topMargin }, getTypographyStyles(typography)), sx) }, rest);
72
+ switch (level) {
73
+ case 1:
74
+ return _jsx("h1", Object.assign({}, headerProps));
75
+ case 2:
76
+ return _jsx("h2", Object.assign({}, headerProps));
77
+ case 3:
78
+ return _jsx("h3", Object.assign({}, headerProps));
79
+ case 4:
80
+ return _jsx("h4", Object.assign({}, headerProps));
81
+ case 5:
82
+ return _jsx("h5", Object.assign({}, headerProps));
83
+ case 6:
84
+ return _jsx("h6", Object.assign({}, headerProps));
85
+ default:
86
+ return _jsx("h6", Object.assign({}, headerProps));
87
+ }
62
88
  };
@@ -35,5 +35,5 @@ export const Paragraph = (_a) => {
35
35
  size: fontSize,
36
36
  multiple: marginHeightMultiple,
37
37
  });
38
- return (_jsx("div", Object.assign({ sx: Object.assign(Object.assign(Object.assign({}, getTypographyStyles(typography)), { display: clampLines ? '-webkit-box' : undefined, '-webkit-line-clamp': clampLines ? String(clampLines) : undefined, '-webkit-box-orient': 'vertical', overflow: clampLines ? 'hidden' : undefined, my: topMargin }), sx) }, rest)));
38
+ return (_jsx("p", Object.assign({ sx: Object.assign(Object.assign(Object.assign({}, getTypographyStyles(typography)), { display: clampLines ? '-webkit-box' : undefined, '-webkit-line-clamp': clampLines ? String(clampLines) : undefined, '-webkit-box-orient': 'vertical', overflow: clampLines ? 'hidden' : undefined, mt: topMargin }), sx) }, rest)));
39
39
  };
@@ -2,7 +2,8 @@ import React from 'react';
2
2
  export declare enum ALERT_TYPE {
3
3
  INFORMATIONAL = "Informational",
4
4
  INFORMATIONAL_YELLOW = "Informational_Yellow",
5
- WARNING = "Warning"
5
+ WARNING = "Warning",
6
+ SUCCESS = "Success"
6
7
  }
7
8
  export declare enum ALERT_DOMAIN {
8
9
  LIBRARY = "library",
@@ -16,6 +16,7 @@ export var ALERT_TYPE;
16
16
  ALERT_TYPE["INFORMATIONAL"] = "Informational";
17
17
  ALERT_TYPE["INFORMATIONAL_YELLOW"] = "Informational_Yellow";
18
18
  ALERT_TYPE["WARNING"] = "Warning";
19
+ ALERT_TYPE["SUCCESS"] = "Success";
19
20
  })(ALERT_TYPE || (ALERT_TYPE = {}));
20
21
  export var ALERT_DOMAIN;
21
22
  (function (ALERT_DOMAIN) {
@@ -16,6 +16,7 @@ export declare enum COLOR {
16
16
  LIGHT_GRAY = "lightGray",
17
17
  EXTRA_LIGHT_GRAY = "extraLightGray",
18
18
  EXTRA_EXTRA_LIGHT_GRAY = "extraExtraLightGray",
19
+ SUCCESS = "ndTertiary1",
19
20
  ND_BLUE = "ndBlue",
20
21
  ND_BLUE_DARK = "ndBlueDark",
21
22
  ND_BLUE_LIGHT = "ndBlueLight",
@@ -44,7 +45,9 @@ export declare enum COLOR {
44
45
  ALERT_INFORMATIONAL_YELLOW_BG = "alertInformationalYellowBg",
45
46
  ALERT_INFORMATIONAL_YELLOW_BORDER = "alertInformationalYellowBorder",
46
47
  ALERT_WARNING_BG = "alertWarningBg",
47
- ALERT_WARNING_BORDER = "alertWarningBorder"
48
+ ALERT_WARNING_BORDER = "alertWarningBorder",
49
+ ALERT_SUCCESS_BG = "alertSuccessBg",
50
+ ALERT_SUCCESS_BORDER = "ndTertiary1"
48
51
  }
49
52
  export declare const colors: {
50
53
  [key in COLOR]: string;
@@ -17,6 +17,7 @@ export var COLOR;
17
17
  COLOR["LIGHT_GRAY"] = "lightGray";
18
18
  COLOR["EXTRA_LIGHT_GRAY"] = "extraLightGray";
19
19
  COLOR["EXTRA_EXTRA_LIGHT_GRAY"] = "extraExtraLightGray";
20
+ COLOR["SUCCESS"] = "ndTertiary1";
20
21
  COLOR["ND_BLUE"] = "ndBlue";
21
22
  COLOR["ND_BLUE_DARK"] = "ndBlueDark";
22
23
  COLOR["ND_BLUE_LIGHT"] = "ndBlueLight";
@@ -46,6 +47,8 @@ export var COLOR;
46
47
  COLOR["ALERT_INFORMATIONAL_YELLOW_BORDER"] = "alertInformationalYellowBorder";
47
48
  COLOR["ALERT_WARNING_BG"] = "alertWarningBg";
48
49
  COLOR["ALERT_WARNING_BORDER"] = "alertWarningBorder";
50
+ COLOR["ALERT_SUCCESS_BG"] = "alertSuccessBg";
51
+ COLOR["ALERT_SUCCESS_BORDER"] = "ndTertiary1";
49
52
  })(COLOR || (COLOR = {}));
50
53
  export const colors = {
51
54
  [COLOR.TEXT]: '#333333',
@@ -94,4 +97,5 @@ export const colors = {
94
97
  [COLOR.ALERT_INFORMATIONAL_YELLOW_BORDER]: '#b3a871',
95
98
  [COLOR.ALERT_WARNING_BG]: '#fc7279',
96
99
  [COLOR.ALERT_WARNING_BORDER]: '#ad5458',
100
+ [COLOR.ALERT_SUCCESS_BG]: '#edffea',
97
101
  };
@@ -24,6 +24,7 @@ export declare const theme: {
24
24
  lightGray: string;
25
25
  extraLightGray: string;
26
26
  extraExtraLightGray: string;
27
+ ndTertiary1: string;
27
28
  ndBlue: string;
28
29
  ndBlueDark: string;
29
30
  ndBlueLight: string;
@@ -41,7 +42,6 @@ export declare const theme: {
41
42
  ndSecondary4: string;
42
43
  ndSecondary5: string;
43
44
  ndSecondary6: string;
44
- ndTertiary1: string;
45
45
  ndTertiary2: string;
46
46
  ndTertiary3: string;
47
47
  ndTertiary4: string;
@@ -53,6 +53,7 @@ export declare const theme: {
53
53
  alertInformationalYellowBorder: string;
54
54
  alertWarningBg: string;
55
55
  alertWarningBorder: string;
56
+ alertSuccessBg: string;
56
57
  };
57
58
  space: string[];
58
59
  boxShadow: typeof BOX_SHADOW;
@@ -121,6 +122,7 @@ export declare const useTheme: () => {
121
122
  lightGray: string;
122
123
  extraLightGray: string;
123
124
  extraExtraLightGray: string;
125
+ ndTertiary1: string;
124
126
  ndBlue: string;
125
127
  ndBlueDark: string;
126
128
  ndBlueLight: string;
@@ -138,7 +140,6 @@ export declare const useTheme: () => {
138
140
  ndSecondary4: string;
139
141
  ndSecondary5: string;
140
142
  ndSecondary6: string;
141
- ndTertiary1: string;
142
143
  ndTertiary2: string;
143
144
  ndTertiary3: string;
144
145
  ndTertiary4: string;
@@ -150,6 +151,7 @@ export declare const useTheme: () => {
150
151
  alertInformationalYellowBorder: string;
151
152
  alertWarningBg: string;
152
153
  alertWarningBorder: string;
154
+ alertSuccessBg: string;
153
155
  };
154
156
  space: string[];
155
157
  boxShadow: typeof BOX_SHADOW;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ndlib/component-library",
3
- "version": "0.0.93",
3
+ "version": "0.0.95",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "files": [