@ndlib/component-library 0.0.20 → 0.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/composites/NavMenu/index.js +4 -1
- package/dist/components/elements/Alerts/index.js +5 -2
- package/dist/components/elements/Fields/DatePicker/DatePicker.stories.d.ts +1 -0
- package/dist/components/elements/Fields/DatePicker/DatePicker.stories.js +12 -1
- package/dist/components/elements/Fields/DatePicker/index.d.ts +1 -0
- package/dist/components/elements/Fields/DatePicker/index.js +20 -4
- package/dist/components/elements/Fields/MonthPicker/index.js +3 -1
- package/dist/components/elements/Fields/Select/index.js +3 -2
- package/dist/components/elements/List/index.js +9 -4
- package/dist/components/providers/ui.d.ts +1 -0
- package/dist/components/providers/ui.js +3 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/theme/GlobalStyles.js +6 -0
- package/dist/utils/misc.d.ts +1 -0
- package/dist/utils/misc.js +12 -0
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
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
|
|
14
|
-
import
|
|
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);
|
|
@@ -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:
|
|
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
|
+
};
|
|
@@ -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
|
|
14
|
+
import _ReactDatePicker from 'react-datepicker';
|
|
15
15
|
import 'react-datepicker/dist/react-datepicker.css';
|
|
16
16
|
import { TextInput } from '../TextInput';
|
|
17
|
-
import
|
|
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
|
-
|
|
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
|
|
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
|
|
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,
|
|
@@ -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
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
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";
|
|
@@ -4,6 +4,7 @@ import { EnvironmentProvider } from './env';
|
|
|
4
4
|
import { ThemeProvider } from './theme';
|
|
5
5
|
import { AlertsProvider } from './alerts';
|
|
6
6
|
import { FontLoader } from '../../FontLoader';
|
|
7
|
-
|
|
8
|
-
|
|
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';
|
|
@@ -24,6 +25,7 @@ export { Radio } from './components/elements/Fields/Radio';
|
|
|
24
25
|
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';
|
|
28
|
+
export { Icon } from './components/elements/Icon';
|
|
27
29
|
export { Card, CARD_SIZE, CARD_LAYOUT } from './components/composites/Card';
|
|
28
30
|
export { UiProvider } from './components/providers/ui';
|
|
29
31
|
export { MenuProvider, useMenu } from './components/providers/menu';
|
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';
|
|
@@ -24,6 +25,7 @@ export { Radio } from './components/elements/Fields/Radio';
|
|
|
24
25
|
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';
|
|
28
|
+
export { Icon } from './components/elements/Icon';
|
|
27
29
|
export { Card, CARD_SIZE, CARD_LAYOUT } from './components/composites/Card';
|
|
28
30
|
export { UiProvider } from './components/providers/ui';
|
|
29
31
|
export { MenuProvider, useMenu } from './components/providers/menu';
|
|
@@ -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;
|
package/dist/utils/misc.d.ts
CHANGED
package/dist/utils/misc.js
CHANGED
|
@@ -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
|
+
}
|