@ndlib/component-library 0.0.10 → 0.0.14

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 (131) hide show
  1. package/dist/FontLoader.d.ts +1 -0
  2. package/dist/FontLoader.js +4 -0
  3. package/dist/components/composites/Card/Card.stories.d.ts +9 -0
  4. package/dist/components/composites/Card/Card.stories.js +77 -0
  5. package/dist/components/composites/Card/Card.test.d.ts +1 -0
  6. package/dist/components/composites/Card/Card.test.js +29 -0
  7. package/dist/components/composites/Card/index.d.ts +22 -0
  8. package/dist/components/composites/Card/index.js +71 -0
  9. package/dist/components/elements/Alerts/Alert.stories.d.ts +9 -0
  10. package/dist/components/elements/Alerts/Alert.stories.js +41 -0
  11. package/dist/components/elements/Alerts/Alerts.stories.d.ts +6 -0
  12. package/dist/components/elements/Alerts/Alerts.stories.js +12 -0
  13. package/dist/components/elements/Alerts/Alerts.test.d.ts +1 -0
  14. package/dist/components/elements/Alerts/Alerts.test.js +62 -0
  15. package/dist/components/elements/Alerts/index.d.ts +15 -0
  16. package/dist/components/elements/Alerts/index.js +63 -0
  17. package/dist/components/elements/BrandingBar/BrandingBar.stories.js +1 -1
  18. package/dist/components/elements/BrandingBar/index.js +5 -5
  19. package/dist/components/elements/Button/Button.stories.d.ts +4 -0
  20. package/dist/components/elements/Button/Button.stories.js +42 -9
  21. package/dist/components/elements/Button/Button.test.js +11 -2
  22. package/dist/components/elements/Button/index.d.ts +16 -11
  23. package/dist/components/elements/Button/index.js +84 -34
  24. package/dist/components/elements/Fields/Checkbox/Checkbox.stories.d.ts +6 -0
  25. package/dist/components/elements/Fields/Checkbox/Checkbox.stories.js +17 -0
  26. package/dist/components/elements/Fields/Checkbox/index.d.ts +9 -0
  27. package/dist/components/elements/Fields/Checkbox/index.js +22 -0
  28. package/dist/components/elements/Fields/CheckboxGroup/CheckboxGroup.stories.d.ts +6 -0
  29. package/dist/components/elements/Fields/CheckboxGroup/CheckboxGroup.stories.js +23 -0
  30. package/dist/components/elements/Fields/CheckboxGroup/index.d.ts +14 -0
  31. package/dist/components/elements/Fields/CheckboxGroup/index.js +35 -0
  32. package/dist/components/elements/Fields/Radio/Radio.stories.d.ts +6 -0
  33. package/dist/components/elements/Fields/Radio/Radio.stories.js +17 -0
  34. package/dist/components/elements/Fields/Radio/index.d.ts +9 -0
  35. package/dist/components/elements/Fields/Radio/index.js +22 -0
  36. package/dist/components/elements/Fields/RadioGroup/RadioGroup.stories.d.ts +6 -0
  37. package/dist/components/elements/Fields/RadioGroup/RadioGroup.stories.js +23 -0
  38. package/dist/components/elements/Fields/RadioGroup/index.d.ts +14 -0
  39. package/dist/components/elements/Fields/RadioGroup/index.js +28 -0
  40. package/dist/components/elements/Fields/Select/Select.stories.d.ts +6 -0
  41. package/dist/components/elements/Fields/Select/Select.stories.js +32 -0
  42. package/dist/components/elements/Fields/Select/index.d.ts +16 -0
  43. package/dist/components/elements/Fields/Select/index.js +136 -0
  44. package/dist/components/elements/Fields/TextInput/TextInput.stories.d.ts +6 -0
  45. package/dist/components/elements/Fields/TextInput/TextInput.stories.js +25 -0
  46. package/dist/components/elements/Fields/TextInput/index.d.ts +17 -0
  47. package/dist/components/elements/Fields/TextInput/index.js +60 -0
  48. package/dist/components/elements/Fields/option.d.ts +15 -0
  49. package/dist/components/elements/Fields/option.js +3 -0
  50. package/dist/components/elements/Group/index.js +3 -3
  51. package/dist/components/elements/Icon/Icon.stories.d.ts +7 -0
  52. package/dist/components/elements/Icon/Icon.stories.js +29 -0
  53. package/dist/components/elements/Icon/Icon.test.d.ts +1 -0
  54. package/dist/components/elements/Icon/Icon.test.js +26 -0
  55. package/dist/components/elements/Icon/index.d.ts +11 -0
  56. package/dist/components/elements/Icon/index.js +25 -0
  57. package/dist/components/elements/Link/Link.stories.js +3 -3
  58. package/dist/components/elements/Link/Link.test.js +13 -13
  59. package/dist/components/elements/Link/index.d.ts +2 -2
  60. package/dist/components/elements/Link/index.js +4 -4
  61. package/dist/components/elements/List/List.stories.d.ts +9 -0
  62. package/dist/components/elements/List/List.stories.js +31 -0
  63. package/dist/components/elements/List/List.test.d.ts +1 -0
  64. package/dist/components/elements/List/List.test.js +24 -0
  65. package/dist/components/elements/List/index.d.ts +21 -0
  66. package/dist/components/elements/List/index.js +75 -0
  67. package/dist/components/elements/ListBox/Listbox.stories.d.ts +6 -0
  68. package/dist/components/elements/ListBox/Listbox.stories.js +17 -0
  69. package/dist/components/elements/ListBox/index.d.ts +32 -0
  70. package/dist/components/elements/ListBox/index.js +50 -0
  71. package/dist/components/elements/Markdown/Markdown.stories.d.ts +6 -0
  72. package/dist/components/elements/Markdown/Markdown.stories.js +53 -0
  73. package/dist/components/elements/Markdown/Markdown.test.d.ts +1 -0
  74. package/dist/components/elements/Markdown/Markdown.test.js +58 -0
  75. package/dist/components/elements/Markdown/index.d.ts +7 -0
  76. package/dist/components/elements/Markdown/index.js +50 -0
  77. package/dist/components/elements/layout/Box.d.ts +1 -1
  78. package/dist/components/elements/layout/Box.stories.js +1 -1
  79. package/dist/components/elements/layout/Column.d.ts +2 -2
  80. package/dist/components/elements/layout/Column.js +2 -2
  81. package/dist/components/elements/layout/Flex.stories.js +2 -2
  82. package/dist/components/elements/layout/Flex.test.js +2 -2
  83. package/dist/components/elements/layout/Row.d.ts +2 -2
  84. package/dist/components/elements/layout/Row.js +1 -1
  85. package/dist/components/elements/text/Heading/Heading.stories.js +10 -11
  86. package/dist/components/elements/text/Heading/Heading.test.js +1 -1
  87. package/dist/components/elements/text/Heading/index.d.ts +6 -4
  88. package/dist/components/elements/text/Heading/index.js +19 -13
  89. package/dist/components/elements/text/Inline/Inline.stories.d.ts +6 -0
  90. package/dist/components/elements/text/Inline/Inline.stories.js +13 -0
  91. package/dist/components/elements/text/Inline/index.d.ts +7 -0
  92. package/dist/components/elements/text/Inline/index.js +21 -0
  93. package/dist/components/elements/text/Label/Label.stories.js +3 -3
  94. package/dist/components/elements/text/Label/Label.test.js +2 -2
  95. package/dist/components/elements/text/Label/index.d.ts +3 -3
  96. package/dist/components/elements/text/Label/index.js +4 -4
  97. package/dist/components/elements/text/Paragraph/Paragraph.stories.js +2 -2
  98. package/dist/components/elements/text/Paragraph/Paragraph.test.js +1 -1
  99. package/dist/components/elements/text/Paragraph/index.d.ts +2 -2
  100. package/dist/components/elements/text/Paragraph/index.js +2 -2
  101. package/dist/components/providers/alerts.d.ts +41 -0
  102. package/dist/components/providers/alerts.js +133 -0
  103. package/dist/components/providers/componentConfig.d.ts +3 -3
  104. package/dist/components/providers/componentConfig.js +5 -4
  105. package/dist/components/providers/env.d.ts +1 -1
  106. package/dist/components/providers/env.js +3 -3
  107. package/dist/components/providers/theme.js +1 -1
  108. package/dist/components/providers/ui.d.ts +7 -3
  109. package/dist/components/providers/ui.js +8 -6
  110. package/dist/index.d.ts +5 -1
  111. package/dist/index.js +5 -1
  112. package/dist/theme/Color.stories.js +17 -2
  113. package/dist/theme/Typography.stories.d.ts +6 -0
  114. package/dist/theme/Typography.stories.js +43 -0
  115. package/dist/theme/colors.d.ts +11 -1
  116. package/dist/theme/colors.js +20 -0
  117. package/dist/theme/custom.d.ts +3 -0
  118. package/dist/theme/custom.js +5 -0
  119. package/dist/theme/index.d.ts +139 -4
  120. package/dist/theme/index.js +18 -12
  121. package/dist/theme/typography.d.ts +47 -6
  122. package/dist/theme/typography.js +74 -36
  123. package/dist/utils/hooks/useStorage.d.ts +14 -0
  124. package/dist/utils/hooks/useStorage.js +31 -0
  125. package/dist/utils/hooks/useUniqueHtmlId.d.ts +1 -0
  126. package/dist/utils/hooks/useUniqueHtmlId.js +7 -0
  127. package/dist/utils/misc.d.ts +7 -0
  128. package/dist/utils/misc.js +13 -1
  129. package/dist/utils/test.js +3 -1
  130. package/global.css +4 -9
  131. package/package.json +19 -12
@@ -0,0 +1,21 @@
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 { FONT_WEIGHT } from '../../../../theme/typography';
14
+ export const Bold = (_a) => {
15
+ var { sx } = _a, rest = __rest(_a, ["sx"]);
16
+ return (_jsx("span", Object.assign({ sx: Object.assign(Object.assign({}, sx), { fontWeight: FONT_WEIGHT.BOLD }) }, rest)));
17
+ };
18
+ export const Italic = (_a) => {
19
+ var { sx } = _a, rest = __rest(_a, ["sx"]);
20
+ return (_jsx("span", Object.assign({ sx: Object.assign(Object.assign({}, sx), { fontStyle: 'italic' }) }, rest)));
21
+ };
@@ -13,8 +13,8 @@ const sizes = [
13
13
  { size: LABEL_SIZE.SM, label: 'Small' },
14
14
  ];
15
15
  export const Default = {
16
- render: () => (_jsx(Column, { children: sizes.map(size => (_jsx(Group, Object.assign({ type: GROUP_TYPE.GROUP }, { children: _jsx(Label, Object.assign({ size: size.size }, { children: size.label })) })))) })),
16
+ render: () => (_jsx(Column, { children: sizes.map((size) => (_jsx(Group, Object.assign({ type: GROUP_TYPE.GROUP }, { children: _jsx(Label, Object.assign({ size: size.size }, { children: size.label })) })))) })),
17
17
  args: {
18
- children: "Label"
19
- }
18
+ children: 'Label',
19
+ },
20
20
  };
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
11
11
  import { vi } from 'vitest';
12
12
  import { render as _render } from '../../../../utils/test';
13
- import { Label } from ".";
13
+ import { Label } from '.';
14
14
  import { GROUP_TYPE, Group } from '../../Group';
15
15
  import { ENVIRONMENT } from '../../../providers/env';
16
16
  import userEvent from '@testing-library/user-event';
@@ -47,7 +47,7 @@ describe('Label', () => {
47
47
  });
48
48
  it('can send focus to label target', () => __awaiter(void 0, void 0, void 0, function* () {
49
49
  const INPUT_TEST_ID = 'input-test-id';
50
- const { getByText, getByTestId } = render((_jsx(Group, Object.assign({ type: GROUP_TYPE.GROUP }, { children: ({ labelTargetId }) => (_jsxs(_Fragment, { children: [_jsx(Label, { children: "Foo" }), _jsx("input", { id: labelTargetId, "data-testid": INPUT_TEST_ID })] })) }))));
50
+ const { getByText, getByTestId } = render(_jsx(Group, Object.assign({ type: GROUP_TYPE.GROUP }, { children: ({ labelTargetId }) => (_jsxs(_Fragment, { children: [_jsx(Label, { children: "Foo" }), _jsx("input", { id: labelTargetId, "data-testid": INPUT_TEST_ID })] })) })));
51
51
  userEvent.click(getByText('Foo'));
52
52
  yield waitFor(() => {
53
53
  expect(getByTestId(INPUT_TEST_ID)).toHaveFocus();
@@ -1,7 +1,7 @@
1
1
  /** @jsxImportSource theme-ui */
2
- import React from "react";
3
- import { TYPOGRAPHY_TYPE } from "../../../../theme/typography";
4
- import { StyledElementProps } from "../../../../theme";
2
+ import React from 'react';
3
+ import { TYPOGRAPHY_TYPE } from '../../../../theme/typography';
4
+ import { StyledElementProps } from '../../../../theme';
5
5
  export declare enum LABEL_SIZE {
6
6
  SM = "sm",
7
7
  MD = "md",
@@ -10,9 +10,9 @@ 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 { getTypographyStyles, TYPOGRAPHY_TYPE } from "../../../../theme/typography";
14
- import { GROUP_TYPE, useGroup } from "../../Group";
15
- import { useEnvironment } from "../../../providers/env";
13
+ import { getTypographyStyles, TYPOGRAPHY_TYPE, } from '../../../../theme/typography';
14
+ import { GROUP_TYPE, useGroup } from '../../Group';
15
+ import { useEnvironment } from '../../../providers/env';
16
16
  export var LABEL_SIZE;
17
17
  (function (LABEL_SIZE) {
18
18
  LABEL_SIZE["SM"] = "sm";
@@ -22,7 +22,7 @@ export var LABEL_SIZE;
22
22
  export const SIZE_TYPOGRAPHY_MAP = {
23
23
  [LABEL_SIZE.SM]: TYPOGRAPHY_TYPE.CONTROL_SMALL,
24
24
  [LABEL_SIZE.MD]: TYPOGRAPHY_TYPE.CONTROL_MEDIUM,
25
- [LABEL_SIZE.LG]: TYPOGRAPHY_TYPE.CONTROL_LARGE
25
+ [LABEL_SIZE.LG]: TYPOGRAPHY_TYPE.CONTROL_LARGE,
26
26
  };
27
27
  export const Label = (_a) => {
28
28
  var { sx, size, standalone } = _a, rest = __rest(_a, ["sx", "size", "standalone"]);
@@ -21,6 +21,6 @@ const p2 = 'Sed non lobortis mi, vitae dapibus arcu. Aenean at euismod arcu. Ut
21
21
  export const Default = {
22
22
  render: (args) => (_jsx(Column, { children: sizes.map((size) => (_jsxs(Group, Object.assign({ type: GROUP_TYPE.REGION }, { children: [_jsx(Heading, Object.assign({ size: HEADING_SIZE.LG, underline: true, sx: { color: COLOR.PRIMARY } }, { children: size.label })), [p1, p2].map((content) => (_jsx(Paragraph, Object.assign({}, args, { size: size.size }, { children: content }))))] })))) })),
23
23
  args: {
24
- children: "Heading"
25
- }
24
+ children: 'Heading',
25
+ },
26
26
  };
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { render } from '../../../../utils/test';
3
- import { Paragraph } from ".";
3
+ import { Paragraph } from '.';
4
4
  describe('Paragraph', () => {
5
5
  it('renders without an error', () => {
6
6
  const { getByText } = render(_jsx(Paragraph, { children: "Foo" }));
@@ -1,6 +1,6 @@
1
1
  /** @jsxImportSource theme-ui */
2
- import React from "react";
3
- import { StyledElementProps } from "../../../../theme";
2
+ import React from 'react';
3
+ import { StyledElementProps } from '../../../../theme';
4
4
  type ParagraphProps = StyledElementProps<HTMLSpanElement, {
5
5
  size?: PARAGRAPH_SIZE;
6
6
  }>;
@@ -10,7 +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 { getTypographyStyles, TYPOGRAPHY_TYPE } from "../../../../theme/typography";
13
+ import { getTypographyStyles, TYPOGRAPHY_TYPE, } from '../../../../theme/typography';
14
14
  export var PARAGRAPH_SIZE;
15
15
  (function (PARAGRAPH_SIZE) {
16
16
  PARAGRAPH_SIZE["SM"] = "sm";
@@ -20,7 +20,7 @@ export var PARAGRAPH_SIZE;
20
20
  const SIZE_TYPOGRAPHY_MAP = {
21
21
  [PARAGRAPH_SIZE.SM]: TYPOGRAPHY_TYPE.PARAGRAPH_SMALL,
22
22
  [PARAGRAPH_SIZE.MD]: TYPOGRAPHY_TYPE.PARAGRAPH_MEDIUM,
23
- [PARAGRAPH_SIZE.LG]: TYPOGRAPHY_TYPE.PARAGRAPH_LARGE
23
+ [PARAGRAPH_SIZE.LG]: TYPOGRAPHY_TYPE.PARAGRAPH_LARGE,
24
24
  };
25
25
  export const Paragraph = (_a) => {
26
26
  var { size, sx } = _a, rest = __rest(_a, ["size", "sx"]);
@@ -0,0 +1,41 @@
1
+ import React from 'react';
2
+ export declare enum ALERT_TYPE {
3
+ INFORMATIONAL = "Informational",
4
+ INFORMATIONAL_YELLOW = "Informational_Yellow",
5
+ WARNING = "Warning"
6
+ }
7
+ export declare enum ALERT_DOMAIN {
8
+ LIBRARY = "library",
9
+ PRIMO = "primo",
10
+ PRIMO_NDU = "primoNDU",
11
+ PRIMO_HCC = "primoHCC",
12
+ ILLIAD = "illiad",
13
+ CATALOGUE_CLASSIC_NDU = "catalogueClassicNDU",
14
+ CATALOGUE_CLASSIC_HCC = "catalogueClassicHCC"
15
+ }
16
+ export type AlertProperties = {
17
+ uuid: string;
18
+ title: string;
19
+ type: ALERT_TYPE;
20
+ description: string;
21
+ domains: ALERT_DOMAIN[];
22
+ global?: boolean;
23
+ key?: number | null;
24
+ };
25
+ export type StrapiAlertAttributes = {
26
+ attributes: AlertProperties;
27
+ };
28
+ export type AlertQueryParams = {
29
+ domain?: ALERT_DOMAIN;
30
+ endpoint?: string;
31
+ startTime?: string;
32
+ endTime?: string;
33
+ disable?: boolean;
34
+ };
35
+ type AlertsProviderProps = React.PropsWithChildren<AlertQueryParams>;
36
+ export declare const AlertsProvider: React.FC<AlertsProviderProps>;
37
+ export declare const useAlerts: (pageAlerts?: string[]) => {
38
+ alerts: AlertProperties[];
39
+ dismiss: (id: string) => void;
40
+ };
41
+ export {};
@@ -0,0 +1,133 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { jsx as _jsx } from "react/jsx-runtime";
11
+ import React, { useEffect, useState } from 'react';
12
+ import { useStorage } from '../../utils/hooks/useStorage';
13
+ const DISMISSED_ALERTS_STORAGE_KEY = 'DISSMISSED_ALERTS_STORAGE_KEY';
14
+ export var ALERT_TYPE;
15
+ (function (ALERT_TYPE) {
16
+ ALERT_TYPE["INFORMATIONAL"] = "Informational";
17
+ ALERT_TYPE["INFORMATIONAL_YELLOW"] = "Informational_Yellow";
18
+ ALERT_TYPE["WARNING"] = "Warning";
19
+ })(ALERT_TYPE || (ALERT_TYPE = {}));
20
+ export var ALERT_DOMAIN;
21
+ (function (ALERT_DOMAIN) {
22
+ ALERT_DOMAIN["LIBRARY"] = "library";
23
+ ALERT_DOMAIN["PRIMO"] = "primo";
24
+ ALERT_DOMAIN["PRIMO_NDU"] = "primoNDU";
25
+ ALERT_DOMAIN["PRIMO_HCC"] = "primoHCC";
26
+ ALERT_DOMAIN["ILLIAD"] = "illiad";
27
+ ALERT_DOMAIN["CATALOGUE_CLASSIC_NDU"] = "catalogueClassicNDU";
28
+ ALERT_DOMAIN["CATALOGUE_CLASSIC_HCC"] = "catalogueClassicHCC";
29
+ })(ALERT_DOMAIN || (ALERT_DOMAIN = {}));
30
+ const composeGraphqlQuery = ({ startTime, endTime, }) => {
31
+ return JSON.stringify({
32
+ query: `
33
+ query AlertQuery($startTime: DateTime, $endTime: DateTime) {
34
+ alerts(
35
+ filters: {
36
+ startTime: { lte: $startTime }
37
+ endTime: { gte: $endTime }
38
+ }
39
+ pagination: { start: 0, limit: 100 }
40
+ sort: ["type:desc", "startTime:asc"]
41
+ ) {
42
+ data {
43
+ attributes {
44
+ uuid
45
+ title
46
+ description
47
+ type
48
+ global
49
+ domains
50
+ }
51
+ }
52
+ }
53
+ }
54
+ `,
55
+ variables: {
56
+ startTime: startTime,
57
+ endTime: endTime,
58
+ },
59
+ });
60
+ };
61
+ const useAlertsQuery = ({ domain = ALERT_DOMAIN.LIBRARY, endpoint = DEFAULT_ENDPOINT, startTime = new Date().toISOString(), endTime = new Date().toISOString(), disable = false, }) => {
62
+ const [alerts, setAlerts] = useState([]);
63
+ useEffect(() => {
64
+ const fetchData = () => __awaiter(void 0, void 0, void 0, function* () {
65
+ var _a, _b, _c;
66
+ try {
67
+ const myHeaders = new Headers();
68
+ myHeaders.append('Content-Type', 'application/json');
69
+ const response = yield fetch(endpoint, {
70
+ method: 'POST',
71
+ headers: myHeaders,
72
+ body: composeGraphqlQuery({
73
+ startTime,
74
+ endTime,
75
+ }),
76
+ redirect: 'follow',
77
+ });
78
+ const json = yield response.json();
79
+ const results = (_c = (_b = (_a = json === null || json === void 0 ? void 0 : json.data) === null || _a === void 0 ? void 0 : _a.alerts) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.map((a) => a === null || a === void 0 ? void 0 : a.attributes);
80
+ console.log('results', results, alerts);
81
+ setAlerts(results);
82
+ }
83
+ catch (error) {
84
+ console.log('error', error);
85
+ }
86
+ });
87
+ if (!disable) {
88
+ fetchData();
89
+ }
90
+ }, [endpoint, domain, startTime, endTime, disable]);
91
+ return alerts;
92
+ };
93
+ const AlertsContext = React.createContext({
94
+ alerts: [],
95
+ dismiss: () => { },
96
+ });
97
+ const DEFAULT_ENDPOINT = 'https://library-website-cms.library.nd.edu/graphql';
98
+ export const AlertsProvider = ({ domain = ALERT_DOMAIN.LIBRARY, endpoint, startTime, endTime, children, disable, }) => {
99
+ const alerts = useAlertsQuery({
100
+ domain,
101
+ endpoint,
102
+ startTime,
103
+ endTime,
104
+ disable,
105
+ });
106
+ const storage = useStorage(`alert-storage-${domain}`);
107
+ const storedDismissedAlerts = storage.getItem(DISMISSED_ALERTS_STORAGE_KEY);
108
+ const [dismissedAlerts, setDismissedAlerts] = useState(storedDismissedAlerts ? JSON.parse(storedDismissedAlerts) : []);
109
+ const dismiss = (id) => {
110
+ if (!dismissedAlerts.includes(id)) {
111
+ const newDismissed = dismissedAlerts.concat([id]);
112
+ storage.setItem(DISMISSED_ALERTS_STORAGE_KEY, JSON.stringify(newDismissed));
113
+ setDismissedAlerts(newDismissed);
114
+ }
115
+ };
116
+ const filteredAlerts = alerts
117
+ .filter((alert) => !dismissedAlerts.includes(alert.uuid))
118
+ .filter((alert) => alert.domains.includes(domain));
119
+ return (_jsx(AlertsContext.Provider, Object.assign({ value: {
120
+ alerts: filteredAlerts,
121
+ dismiss,
122
+ } }, { children: children })));
123
+ };
124
+ export const useAlerts = (pageAlerts) => {
125
+ const { alerts: allAlerts, dismiss } = React.useContext(AlertsContext);
126
+ const alerts = pageAlerts
127
+ ? allAlerts.filter((alert) => alert.global || pageAlerts.includes(alert.uuid))
128
+ : allAlerts.filter((alert) => alert.global);
129
+ return {
130
+ alerts,
131
+ dismiss,
132
+ };
133
+ };
@@ -1,6 +1,6 @@
1
- import { PropsWithChildren } from "react";
2
- import { DeepPartial } from "../../utils/misc";
3
- import { StyledElementProps } from "../../theme";
1
+ import { PropsWithChildren } from 'react';
2
+ import { DeepPartial } from '../../utils/misc';
3
+ import { StyledElementProps } from '../../theme';
4
4
  export type ComponentConfig = {
5
5
  link: {
6
6
  externalMatcher: RegExp;
@@ -10,7 +10,7 @@ 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 { createContext, useContext, useMemo } from "react";
13
+ import { createContext, useContext, useMemo } from 'react';
14
14
  const DEFAULT_EXTERNAL_LINK_MATCHER = /[a-zA-Z0-9]*:\/\/[^\s]*/g;
15
15
  export const DefaultLink = (_a) => {
16
16
  var { to } = _a, rest = __rest(_a, ["to"]);
@@ -20,12 +20,13 @@ const defaultComponentConfig = {
20
20
  link: {
21
21
  externalMatcher: DEFAULT_EXTERNAL_LINK_MATCHER,
22
22
  internalLinkComponent: DefaultLink,
23
- externalLinkComponent: DefaultLink
24
- }
23
+ externalLinkComponent: DefaultLink,
24
+ },
25
25
  };
26
26
  export const ComponentConfigContext = createContext(defaultComponentConfig);
27
27
  export const useComponentConfig = () => useContext(ComponentConfigContext);
28
28
  export const ComponentConfigProvider = ({ config: configParam, children }) => {
29
- const config = useMemo(() => (Object.assign(Object.assign(Object.assign({}, defaultComponentConfig), configParam), { link: Object.assign(Object.assign({}, defaultComponentConfig.link), configParam.link) })), []); // eslint-disable-line
29
+ const config = useMemo(() => (Object.assign(Object.assign(Object.assign({}, defaultComponentConfig), configParam), { link: Object.assign(Object.assign({}, defaultComponentConfig.link), configParam.link) })), [] // eslint-disable-line
30
+ );
30
31
  return (_jsx(ComponentConfigContext.Provider, Object.assign({ value: config }, { children: children })));
31
32
  };
@@ -1,4 +1,4 @@
1
- import { PropsWithChildren } from "react";
1
+ import { PropsWithChildren } from 'react';
2
2
  export declare enum ENVIRONMENT {
3
3
  DEV = "DEVELOPMENT",
4
4
  PROD = "PRODUCTION"
@@ -1,12 +1,12 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { createContext, useContext } from "react";
2
+ import { createContext, useContext } from 'react';
3
3
  export var ENVIRONMENT;
4
4
  (function (ENVIRONMENT) {
5
5
  ENVIRONMENT["DEV"] = "DEVELOPMENT";
6
6
  ENVIRONMENT["PROD"] = "PRODUCTION";
7
7
  })(ENVIRONMENT || (ENVIRONMENT = {}));
8
8
  const EnvironmentContext = createContext({
9
- flagInDevelopment: () => { }
9
+ flagInDevelopment: () => { },
10
10
  });
11
11
  export const useEnvironment = () => useContext(EnvironmentContext);
12
12
  export const EnvironmentProvider = ({ env, children }) => {
@@ -20,6 +20,6 @@ export const EnvironmentProvider = ({ env, children }) => {
20
20
  };
21
21
  return (_jsx(EnvironmentContext.Provider, Object.assign({ value: {
22
22
  env,
23
- flagInDevelopment
23
+ flagInDevelopment,
24
24
  } }, { children: children })));
25
25
  };
@@ -2,5 +2,5 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { ThemeProvider as ThemeUiProvider } from 'theme-ui';
3
3
  import { theme } from '../../theme';
4
4
  export const ThemeProvider = ({ children }) => {
5
- return (_jsx(ThemeUiProvider, Object.assign({ theme: theme }, { children: children })));
5
+ return _jsx(ThemeUiProvider, Object.assign({ theme: theme }, { children: children }));
6
6
  };
@@ -1,9 +1,13 @@
1
- import { PropsWithChildren } from "react";
2
- import { ComponentConfigParam } from "./componentConfig";
3
- import { ENVIRONMENT } from "./env";
1
+ import { PropsWithChildren } from 'react';
2
+ import { ComponentConfigParam } from './componentConfig';
3
+ import { ENVIRONMENT } from './env';
4
+ import { AlertQueryParams } from './alerts';
4
5
  export type UiConfig = {
5
6
  env?: ENVIRONMENT;
6
7
  components?: ComponentConfigParam;
8
+ alertsConfig?: AlertQueryParams;
9
+ disableAlerts?: boolean;
10
+ loadFonts?: boolean;
7
11
  };
8
12
  type UiProviderProps = PropsWithChildren<UiConfig>;
9
13
  export declare const UiProvider: React.FC<UiProviderProps>;
@@ -1,7 +1,9 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { ComponentConfigProvider } from "./componentConfig";
3
- import { EnvironmentProvider } from "./env";
4
- import { ThemeProvider } from "./theme";
5
- export const UiProvider = ({ env, components, children }) => {
6
- return (_jsx(EnvironmentProvider, Object.assign({ env: env }, { children: _jsx(ComponentConfigProvider, Object.assign({ config: components || {} }, { children: _jsx(ThemeProvider, { children: children }) })) })));
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { ComponentConfigProvider, } from './componentConfig';
3
+ import { EnvironmentProvider } from './env';
4
+ import { ThemeProvider } from './theme';
5
+ import { AlertsProvider } from './alerts';
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
9
  };
package/dist/index.d.ts CHANGED
@@ -1,14 +1,18 @@
1
1
  export { theme, ThemeProvider } from './theme';
2
2
  export { COLOR } from './theme/colors';
3
- export { TYPOGRAPHY_TYPE } from './theme/typography';
3
+ export { TYPOGRAPHY_TYPE, FONT, FONT_SIZE, FONT_WEIGHT, LINE_HEIGHT, } from './theme/typography';
4
+ export { Alert, Alerts } from './components/elements/Alerts';
4
5
  export { BrandingBar } from './components/elements/BrandingBar';
5
6
  export { Button, BUTTON_SIZE } from './components/elements/Button';
6
7
  export { Heading, HEADING_SIZE } from './components/elements/text/Heading';
7
8
  export { Label, LABEL_SIZE } from './components/elements/text/Label';
8
9
  export { Paragraph, PARAGRAPH_SIZE } from './components/elements/text/Paragraph';
9
10
  export { Group, useGroup } from './components/elements/Group';
11
+ export { Markdown } from './components/elements/Markdown';
10
12
  export { Box } from './components/elements/layout/Box';
11
13
  export { Column } from './components/elements/layout/Column';
12
14
  export { Row } from './components/elements/layout/Row';
13
15
  export { Link, LINK_SIZE } from './components/elements/Link';
16
+ export { Card, CARD_SIZE, CARD_LAYOUT } from './components/composites/Card';
14
17
  export { UiProvider } from './components/providers/ui';
18
+ export { useAlerts, AlertsProvider, ALERT_DOMAIN, } from './components/providers/alerts';
package/dist/index.js CHANGED
@@ -1,14 +1,18 @@
1
1
  export { theme, ThemeProvider } from './theme';
2
2
  export { COLOR } from './theme/colors';
3
- export { TYPOGRAPHY_TYPE } from './theme/typography';
3
+ export { TYPOGRAPHY_TYPE, FONT, FONT_SIZE, FONT_WEIGHT, LINE_HEIGHT, } from './theme/typography';
4
+ export { Alert, Alerts } from './components/elements/Alerts';
4
5
  export { BrandingBar } from './components/elements/BrandingBar';
5
6
  export { Button, BUTTON_SIZE } from './components/elements/Button';
6
7
  export { Heading, HEADING_SIZE } from './components/elements/text/Heading';
7
8
  export { Label, LABEL_SIZE } from './components/elements/text/Label';
8
9
  export { Paragraph, PARAGRAPH_SIZE } from './components/elements/text/Paragraph';
9
10
  export { Group, useGroup } from './components/elements/Group';
11
+ export { Markdown } from './components/elements/Markdown';
10
12
  export { Box } from './components/elements/layout/Box';
11
13
  export { Column } from './components/elements/layout/Column';
12
14
  export { Row } from './components/elements/layout/Row';
13
15
  export { Link, LINK_SIZE } from './components/elements/Link';
16
+ export { Card, CARD_SIZE, CARD_LAYOUT } from './components/composites/Card';
14
17
  export { UiProvider } from './components/providers/ui';
18
+ export { useAlerts, AlertsProvider, ALERT_DOMAIN, } from './components/providers/alerts';
@@ -8,7 +8,7 @@ const meta = {
8
8
  title: 'Theme/Colors',
9
9
  };
10
10
  const ColorSquare = ({ color }) => {
11
- return _jsx(Box, { sx: { p: 3, bg: color, boxShadow: '0px 0px 8px 1px #dddddd' } });
11
+ return _jsx(Box, { sx: { p: 3, bg: color } });
12
12
  };
13
13
  export default meta;
14
14
  const colors = [
@@ -36,7 +36,22 @@ const colors = [
36
36
  { color: COLOR.ND_TERTIARY_4, label: 'ND_TERTIARY_4' },
37
37
  { color: COLOR.ND_TERTIARY_5, label: 'ND_TERTIARY_5' },
38
38
  { color: COLOR.ND_TERTIARY_6, label: 'ND_TERTIARY_6' },
39
+ { color: COLOR.ALERT_INFORMATIONAL_BG, label: 'ALERT_INFORMATIONAL_BG' },
40
+ {
41
+ color: COLOR.ALERT_INFORMATIONAL_BORDER,
42
+ label: 'ALERT_INFORMATIONAL_BORDER',
43
+ },
44
+ {
45
+ color: COLOR.ALERT_INFORMATIONAL_YELLOW_BG,
46
+ label: 'ALERT_INFORMATIONAL_YELLOW_BG',
47
+ },
48
+ {
49
+ color: COLOR.ALERT_INFORMATIONAL_YELLOW_BORDER,
50
+ label: 'ALERT_INFORMATIONAL_YELLOW_BORDER',
51
+ },
52
+ { color: COLOR.ALERT_WARNING_BG, label: 'ALERT_WARNING_BG' },
53
+ { color: COLOR.ALERT_WARNING_BORDER, label: 'ALERT_WARNING_BORDER' },
39
54
  ];
40
55
  export const Default = {
41
- render: () => (_jsx(Row, Object.assign({ sx: { flexWrap: 'wrap' } }, { children: colors.map((color) => (_jsxs(Group, Object.assign({ type: GROUP_TYPE.GROUP, sx: { mr: 3, mt: 0, flexBasis: '100px' } }, { children: [_jsx(Label, Object.assign({ size: LABEL_SIZE.SM }, { children: color.label })), _jsx(ColorSquare, { color: color.color })] })))) }))),
56
+ render: () => (_jsx(Row, Object.assign({ sx: { flexWrap: 'wrap' } }, { children: colors.map((color) => (_jsxs(Group, Object.assign({ type: GROUP_TYPE.GROUP, sx: { mr: 3, mt: 0, flexBasis: '100px' } }, { children: [_jsx(Label, Object.assign({ size: LABEL_SIZE.SM }, { children: color.label })), _jsx(ColorSquare, { color: color.color })] }), color.label))) }))),
42
57
  };
@@ -0,0 +1,6 @@
1
+ /** @jsxImportSource theme-ui */
2
+ import type { Meta, StoryObj } from '@storybook/react';
3
+ declare const meta: Meta;
4
+ export default meta;
5
+ type Story = StoryObj<typeof meta>;
6
+ export declare const Default: Story;
@@ -0,0 +1,43 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "theme-ui/jsx-runtime";
2
+ import { getTypographyStyles, TYPOGRAPHY_TYPE } from './typography';
3
+ import { Group } from '../components/elements/Group';
4
+ import { Box } from '../components/elements/layout/Box';
5
+ import { LABEL_SIZE, Label } from '../components/elements/text/Label';
6
+ const meta = {
7
+ title: 'Theme/Typography',
8
+ tags: ['autodocs'],
9
+ };
10
+ export default meta;
11
+ const types = [
12
+ { type: TYPOGRAPHY_TYPE.PARAGRAPH_SMALL, label: 'Paragraph Small' },
13
+ { type: TYPOGRAPHY_TYPE.PARAGRAPH_MEDIUM, label: 'Paragraph Medium' },
14
+ { type: TYPOGRAPHY_TYPE.PARAGRAPH_LARGE, label: 'Paragraph Large' },
15
+ { type: TYPOGRAPHY_TYPE.HEADING_SMALL, label: 'Heading Small' },
16
+ { type: TYPOGRAPHY_TYPE.HEADING_MEDIUM, label: 'Heading Medium' },
17
+ { type: TYPOGRAPHY_TYPE.HEADING_LARGE, label: 'Heading Large' },
18
+ { type: TYPOGRAPHY_TYPE.HEADING_XLARGE, label: 'Heading X Large' },
19
+ { type: TYPOGRAPHY_TYPE.CONTROL_SMALL, label: 'Control Small' },
20
+ { type: TYPOGRAPHY_TYPE.CONTROL_MEDIUM, label: 'Control Medium' },
21
+ { type: TYPOGRAPHY_TYPE.CONTROL_LARGE, label: 'Control Large' },
22
+ { type: TYPOGRAPHY_TYPE.HEADLINE_SMALL, label: 'Headline Small' },
23
+ { type: TYPOGRAPHY_TYPE.HEADLINE_MEDIUM, label: 'Headline Medium' },
24
+ { type: TYPOGRAPHY_TYPE.HEADLINE_LARGE, label: 'Headline Large' },
25
+ ];
26
+ const pangrams = [
27
+ 'The quick brown fox jumps over the lazy dog.',
28
+ 'Waltz, bad nymph, for quick jigs vex.',
29
+ 'How vexingly quick daft zebras jump!',
30
+ 'Pack my box with five dozen liquor jugs.',
31
+ 'The five boxing wizards jump quickly.',
32
+ 'When zombies arrive, quickly fax Judge Pat.',
33
+ 'Amazingly few discotheques provide jukeboxes.',
34
+ ];
35
+ const randomElement = (arr) => {
36
+ return arr.length ? arr[Math.floor(Math.random() * arr.length)] : undefined;
37
+ };
38
+ export const Default = {
39
+ render: () => (_jsx(Group, { children: types.map((t) => {
40
+ const style = getTypographyStyles(t.type);
41
+ return (_jsxs(Group, Object.assign({ sx: { mb: '1rem' } }, { children: [_jsx(Label, Object.assign({ size: LABEL_SIZE.SM }, { children: t.label })), _jsx(Box, Object.assign({ sx: { p: 3, boxShadow: '0px 0px 8px 1px #dddddd' } }, { children: _jsx("div", Object.assign({ sx: style }, { children: randomElement(pangrams) })) }))] })));
42
+ }) })),
43
+ };
@@ -8,8 +8,12 @@ export declare enum COLOR {
8
8
  SECONDARY_HIGHLIGHT = "secondaryHighlight",
9
9
  TEXT_ON_PRIMARY = "textOnPrimary",
10
10
  TEXT_ON_SECONDARY = "textOnSecondary",
11
+ LIGHT_GRAY = "lightGray",
12
+ FAINT_GRAY = "faintGray",
11
13
  ND_BLUE = "ndBlue",
12
14
  ND_GOLD = "ndGold",
15
+ ND_SKY_BLUE = "ndSkyBlue",
16
+ ND_SKY_BLUE_DARK = "ndSkyBlueDark",
13
17
  ND_METALLIC_GOLD = "ndMetallicGold",
14
18
  ND_PROVOST_BLUE = "ndProvostBlue",
15
19
  ND_SECONDARY_1 = "ndSecondary1",
@@ -23,7 +27,13 @@ export declare enum COLOR {
23
27
  ND_TERTIARY_3 = "ndTertiary3",
24
28
  ND_TERTIARY_4 = "ndTertiary4",
25
29
  ND_TERTIARY_5 = "ndTertiary5",
26
- ND_TERTIARY_6 = "ndTertiary6"
30
+ ND_TERTIARY_6 = "ndTertiary6",
31
+ ALERT_INFORMATIONAL_BG = "alertInformationalBg",
32
+ ALERT_INFORMATIONAL_BORDER = "alertInformationalBorder",
33
+ ALERT_INFORMATIONAL_YELLOW_BG = "alertInformationalYellowBg",
34
+ ALERT_INFORMATIONAL_YELLOW_BORDER = "alertInformationalYellowBorder",
35
+ ALERT_WARNING_BG = "alertWarningBg",
36
+ ALERT_WARNING_BORDER = "alertWarningBorder"
27
37
  }
28
38
  export declare const colors: {
29
39
  [key in COLOR]: string;
@@ -9,8 +9,12 @@ export var COLOR;
9
9
  COLOR["SECONDARY_HIGHLIGHT"] = "secondaryHighlight";
10
10
  COLOR["TEXT_ON_PRIMARY"] = "textOnPrimary";
11
11
  COLOR["TEXT_ON_SECONDARY"] = "textOnSecondary";
12
+ COLOR["LIGHT_GRAY"] = "lightGray";
13
+ COLOR["FAINT_GRAY"] = "faintGray";
12
14
  COLOR["ND_BLUE"] = "ndBlue";
13
15
  COLOR["ND_GOLD"] = "ndGold";
16
+ COLOR["ND_SKY_BLUE"] = "ndSkyBlue";
17
+ COLOR["ND_SKY_BLUE_DARK"] = "ndSkyBlueDark";
14
18
  COLOR["ND_METALLIC_GOLD"] = "ndMetallicGold";
15
19
  COLOR["ND_PROVOST_BLUE"] = "ndProvostBlue";
16
20
  COLOR["ND_SECONDARY_1"] = "ndSecondary1";
@@ -25,6 +29,12 @@ export var COLOR;
25
29
  COLOR["ND_TERTIARY_4"] = "ndTertiary4";
26
30
  COLOR["ND_TERTIARY_5"] = "ndTertiary5";
27
31
  COLOR["ND_TERTIARY_6"] = "ndTertiary6";
32
+ COLOR["ALERT_INFORMATIONAL_BG"] = "alertInformationalBg";
33
+ COLOR["ALERT_INFORMATIONAL_BORDER"] = "alertInformationalBorder";
34
+ COLOR["ALERT_INFORMATIONAL_YELLOW_BG"] = "alertInformationalYellowBg";
35
+ COLOR["ALERT_INFORMATIONAL_YELLOW_BORDER"] = "alertInformationalYellowBorder";
36
+ COLOR["ALERT_WARNING_BG"] = "alertWarningBg";
37
+ COLOR["ALERT_WARNING_BORDER"] = "alertWarningBorder";
28
38
  })(COLOR || (COLOR = {}));
29
39
  export const colors = {
30
40
  [COLOR.TEXT]: '#222222',
@@ -36,8 +46,12 @@ export const colors = {
36
46
  [COLOR.SECONDARY]: '#f8e999',
37
47
  [COLOR.SECONDARY_HIGHLIGHT]: '#ddcc70',
38
48
  [COLOR.TEXT_ON_SECONDARY]: '#242111',
49
+ [COLOR.LIGHT_GRAY]: '#949494',
50
+ [COLOR.FAINT_GRAY]: '#eeeeee',
39
51
  [COLOR.ND_BLUE]: '#0c2340',
40
52
  [COLOR.ND_GOLD]: '#d39F10',
53
+ [COLOR.ND_SKY_BLUE]: '#e1e8f2',
54
+ [COLOR.ND_SKY_BLUE_DARK]: '#c1cddd',
41
55
  [COLOR.ND_METALLIC_GOLD]: '#ae9142',
42
56
  [COLOR.ND_PROVOST_BLUE]: '#002a5d',
43
57
  [COLOR.ND_SECONDARY_1]: '#5aabbc',
@@ -52,4 +66,10 @@ export const colors = {
52
66
  [COLOR.ND_TERTIARY_4]: '#aa272f',
53
67
  [COLOR.ND_TERTIARY_5]: '#5a412f',
54
68
  [COLOR.ND_TERTIARY_6]: '#ba6f2e',
69
+ [COLOR.ALERT_INFORMATIONAL_BG]: '#ffb073',
70
+ [COLOR.ALERT_INFORMATIONAL_BORDER]: '#ad7950',
71
+ [COLOR.ALERT_INFORMATIONAL_YELLOW_BG]: '#f8e999',
72
+ [COLOR.ALERT_INFORMATIONAL_YELLOW_BORDER]: '#b3a871',
73
+ [COLOR.ALERT_WARNING_BG]: '#fc7279',
74
+ [COLOR.ALERT_WARNING_BORDER]: '#ad5458',
55
75
  };
@@ -0,0 +1,3 @@
1
+ export declare enum BOX_SHADOW {
2
+ NORMAL = "0 0 8px #dfdfdf"
3
+ }
@@ -0,0 +1,5 @@
1
+ // Values in these files aren't part of theme-ui / sx spec and need to be pulled from theme directly
2
+ export var BOX_SHADOW;
3
+ (function (BOX_SHADOW) {
4
+ BOX_SHADOW["NORMAL"] = "0 0 8px #dfdfdf";
5
+ })(BOX_SHADOW || (BOX_SHADOW = {}));