@ndlib/component-library 0.0.7-9.1
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/README.md +101 -0
- package/dist/FontLoader.d.ts +1 -0
- package/dist/FontLoader.js +4 -0
- package/dist/components/composites/Card/Card.stories.d.ts +13 -0
- package/dist/components/composites/Card/Card.stories.js +122 -0
- package/dist/components/composites/Card/Card.test.d.ts +1 -0
- package/dist/components/composites/Card/Card.test.js +37 -0
- package/dist/components/composites/Card/index.d.ts +36 -0
- package/dist/components/composites/Card/index.js +89 -0
- package/dist/components/composites/DragDropList/DragDropList.stories.d.ts +7 -0
- package/dist/components/composites/DragDropList/DragDropList.stories.js +32 -0
- package/dist/components/composites/DragDropList/index.d.ts +25 -0
- package/dist/components/composites/DragDropList/index.js +48 -0
- package/dist/components/composites/DropdownLinks/DropdownLinks.stories.d.ts +8 -0
- package/dist/components/composites/DropdownLinks/DropdownLinks.stories.js +25 -0
- package/dist/components/composites/DropdownLinks/DropdownLinks.test.d.ts +1 -0
- package/dist/components/composites/DropdownLinks/DropdownLinks.test.js +27 -0
- package/dist/components/composites/DropdownLinks/index.d.ts +15 -0
- package/dist/components/composites/DropdownLinks/index.js +28 -0
- package/dist/components/composites/EmptyState/EmptyState.stories.d.ts +10 -0
- package/dist/components/composites/EmptyState/EmptyState.stories.js +31 -0
- package/dist/components/composites/EmptyState/EmptyState.test.d.ts +1 -0
- package/dist/components/composites/EmptyState/EmptyState.test.js +20 -0
- package/dist/components/composites/EmptyState/index.d.ts +15 -0
- package/dist/components/composites/EmptyState/index.js +32 -0
- package/dist/components/composites/Modal/Modal.stories.d.ts +6 -0
- package/dist/components/composites/Modal/Modal.stories.js +40 -0
- package/dist/components/composites/Modal/index.d.ts +21 -0
- package/dist/components/composites/Modal/index.js +64 -0
- package/dist/components/composites/NavMenu/NavMenu.stories.d.ts +6 -0
- package/dist/components/composites/NavMenu/NavMenu.stories.js +12 -0
- package/dist/components/composites/NavMenu/NavMenu.test.d.ts +1 -0
- package/dist/components/composites/NavMenu/NavMenu.test.js +96 -0
- package/dist/components/composites/NavMenu/demo.d.ts +1 -0
- package/dist/components/composites/NavMenu/demo.js +172 -0
- package/dist/components/composites/NavMenu/index.d.ts +5 -0
- package/dist/components/composites/NavMenu/index.js +52 -0
- package/dist/components/composites/Seo/SeoDataDisplay/index.d.ts +2 -0
- package/dist/components/composites/Seo/SeoDataDisplay/index.js +9 -0
- package/dist/components/composites/Seo/index.d.ts +11 -0
- package/dist/components/composites/Seo/index.js +16 -0
- package/dist/components/composites/Seo/seo.stories.d.ts +6 -0
- package/dist/components/composites/Seo/seo.stories.js +12 -0
- package/dist/components/composites/Seo/seo.test.d.ts +1 -0
- package/dist/components/composites/Seo/seo.test.js +56 -0
- package/dist/components/composites/Seo/siteMetadata.d.ts +9 -0
- package/dist/components/composites/Seo/siteMetadata.js +16 -0
- package/dist/components/composites/SnackBar/SnackBar.stories.d.ts +8 -0
- package/dist/components/composites/SnackBar/SnackBar.stories.js +20 -0
- package/dist/components/composites/SnackBar/SnackBar.test.d.ts +1 -0
- package/dist/components/composites/SnackBar/SnackBar.test.js +75 -0
- package/dist/components/composites/SnackBar/examples.d.ts +3 -0
- package/dist/components/composites/SnackBar/examples.js +35 -0
- package/dist/components/composites/SnackBar/index.d.ts +1 -0
- package/dist/components/composites/SnackBar/index.js +45 -0
- package/dist/components/composites/StructuredData/StructuredData.stories.d.ts +6 -0
- package/dist/components/composites/StructuredData/StructuredData.stories.js +12 -0
- package/dist/components/composites/StructuredData/StructuredData.test.d.ts +1 -0
- package/dist/components/composites/StructuredData/StructuredData.test.js +48 -0
- package/dist/components/composites/StructuredData/StructuredDataDisplay/index.d.ts +2 -0
- package/dist/components/composites/StructuredData/StructuredDataDisplay/index.js +37 -0
- package/dist/components/composites/StructuredData/index.d.ts +38 -0
- package/dist/components/composites/StructuredData/index.js +58 -0
- package/dist/components/composites/StructuredData/sdEvent/index.d.ts +13 -0
- package/dist/components/composites/StructuredData/sdEvent/index.js +16 -0
- package/dist/components/composites/StructuredData/sdEvent/makeEventSchema.d.ts +15 -0
- package/dist/components/composites/StructuredData/sdEvent/makeEventSchema.js +16 -0
- package/dist/components/composites/StructuredData/sdNews/index.d.ts +11 -0
- package/dist/components/composites/StructuredData/sdNews/index.js +14 -0
- package/dist/components/composites/StructuredData/sdNews/makeNewsSchema.d.ts +12 -0
- package/dist/components/composites/StructuredData/sdNews/makeNewsSchema.js +11 -0
- package/dist/components/composites/StructuredData/sdWebsite/index.d.ts +8 -0
- package/dist/components/composites/StructuredData/sdWebsite/index.js +11 -0
- package/dist/components/composites/StructuredData/sdWebsite/makeWebPageSchema.d.ts +9 -0
- package/dist/components/composites/StructuredData/sdWebsite/makeWebPageSchema.js +9 -0
- package/dist/components/composites/StructuredData/siteMetadata.d.ts +9 -0
- package/dist/components/composites/StructuredData/siteMetadata.js +12 -0
- package/dist/components/elements/Alerts/Alert.stories.d.ts +9 -0
- package/dist/components/elements/Alerts/Alert.stories.js +41 -0
- package/dist/components/elements/Alerts/Alerts.stories.d.ts +6 -0
- package/dist/components/elements/Alerts/Alerts.stories.js +12 -0
- package/dist/components/elements/Alerts/Alerts.test.d.ts +1 -0
- package/dist/components/elements/Alerts/Alerts.test.js +61 -0
- package/dist/components/elements/Alerts/index.d.ts +14 -0
- package/dist/components/elements/Alerts/index.js +64 -0
- package/dist/components/elements/ArrowLink/ArrowLink.stories.d.ts +6 -0
- package/dist/components/elements/ArrowLink/ArrowLink.stories.js +12 -0
- package/dist/components/elements/ArrowLink/ArrowLink.test.d.ts +1 -0
- package/dist/components/elements/ArrowLink/ArrowLink.test.js +34 -0
- package/dist/components/elements/ArrowLink/index.d.ts +7 -0
- package/dist/components/elements/ArrowLink/index.js +39 -0
- package/dist/components/elements/BrandingBar/BrandingBar.stories.d.ts +6 -0
- package/dist/components/elements/BrandingBar/BrandingBar.stories.js +11 -0
- package/dist/components/elements/BrandingBar/index.d.ts +2 -0
- package/dist/components/elements/BrandingBar/index.js +52 -0
- package/dist/components/elements/Button/Button.stories.d.ts +15 -0
- package/dist/components/elements/Button/Button.stories.js +88 -0
- package/dist/components/elements/Button/Button.test.d.ts +1 -0
- package/dist/components/elements/Button/Button.test.js +39 -0
- package/dist/components/elements/Button/index.d.ts +49 -0
- package/dist/components/elements/Button/index.js +138 -0
- package/dist/components/elements/Dropdown/Dropdown.stories.d.ts +7 -0
- package/dist/components/elements/Dropdown/Dropdown.stories.js +20 -0
- package/dist/components/elements/Dropdown/index.d.ts +24 -0
- package/dist/components/elements/Dropdown/index.js +87 -0
- package/dist/components/elements/Fields/AutoComplete/AutoComplete.stories.d.ts +6 -0
- package/dist/components/elements/Fields/AutoComplete/AutoComplete.stories.js +60 -0
- package/dist/components/elements/Fields/AutoComplete/index.d.ts +11 -0
- package/dist/components/elements/Fields/AutoComplete/index.js +26 -0
- package/dist/components/elements/Fields/Checkbox/Checkbox.stories.d.ts +6 -0
- package/dist/components/elements/Fields/Checkbox/Checkbox.stories.js +17 -0
- package/dist/components/elements/Fields/Checkbox/index.d.ts +8 -0
- package/dist/components/elements/Fields/Checkbox/index.js +22 -0
- package/dist/components/elements/Fields/CheckboxGroup/CheckboxGroup.stories.d.ts +7 -0
- package/dist/components/elements/Fields/CheckboxGroup/CheckboxGroup.stories.js +26 -0
- package/dist/components/elements/Fields/CheckboxGroup/index.d.ts +16 -0
- package/dist/components/elements/Fields/CheckboxGroup/index.js +49 -0
- package/dist/components/elements/Fields/DatePicker/DatePicker.stories.d.ts +8 -0
- package/dist/components/elements/Fields/DatePicker/DatePicker.stories.js +31 -0
- package/dist/components/elements/Fields/DatePicker/index.d.ts +20 -0
- package/dist/components/elements/Fields/DatePicker/index.js +48 -0
- package/dist/components/elements/Fields/MonthPicker/MonthPicker.stories.d.ts +7 -0
- package/dist/components/elements/Fields/MonthPicker/MonthPicker.stories.js +20 -0
- package/dist/components/elements/Fields/MonthPicker/index.d.ts +13 -0
- package/dist/components/elements/Fields/MonthPicker/index.js +24 -0
- package/dist/components/elements/Fields/Radio/Radio.stories.d.ts +6 -0
- package/dist/components/elements/Fields/Radio/Radio.stories.js +17 -0
- package/dist/components/elements/Fields/Radio/index.d.ts +8 -0
- package/dist/components/elements/Fields/Radio/index.js +22 -0
- package/dist/components/elements/Fields/RadioGroup/RadioGroup.stories.d.ts +6 -0
- package/dist/components/elements/Fields/RadioGroup/RadioGroup.stories.js +23 -0
- package/dist/components/elements/Fields/RadioGroup/index.d.ts +14 -0
- package/dist/components/elements/Fields/RadioGroup/index.js +28 -0
- package/dist/components/elements/Fields/Select/Select.stories.d.ts +8 -0
- package/dist/components/elements/Fields/Select/Select.stories.js +39 -0
- package/dist/components/elements/Fields/Select/index.d.ts +18 -0
- package/dist/components/elements/Fields/Select/index.js +178 -0
- package/dist/components/elements/Fields/TextInput/TextInput.stories.d.ts +9 -0
- package/dist/components/elements/Fields/TextInput/TextInput.stories.js +35 -0
- package/dist/components/elements/Fields/TextInput/index.d.ts +45 -0
- package/dist/components/elements/Fields/TextInput/index.js +119 -0
- package/dist/components/elements/Fields/option.d.ts +16 -0
- package/dist/components/elements/Fields/option.js +3 -0
- package/dist/components/elements/Group/index.d.ts +22 -0
- package/dist/components/elements/Group/index.js +69 -0
- package/dist/components/elements/Icon/Icon.stories.d.ts +7 -0
- package/dist/components/elements/Icon/Icon.stories.js +29 -0
- package/dist/components/elements/Icon/Icon.test.d.ts +1 -0
- package/dist/components/elements/Icon/Icon.test.js +26 -0
- package/dist/components/elements/Icon/index.d.ts +10 -0
- package/dist/components/elements/Icon/index.js +34 -0
- package/dist/components/elements/Link/Link.stories.d.ts +6 -0
- package/dist/components/elements/Link/Link.stories.js +21 -0
- package/dist/components/elements/Link/Link.test.d.ts +1 -0
- package/dist/components/elements/Link/Link.test.js +58 -0
- package/dist/components/elements/Link/index.d.ts +14 -0
- package/dist/components/elements/Link/index.js +41 -0
- package/dist/components/elements/List/List.stories.d.ts +10 -0
- package/dist/components/elements/List/List.stories.js +37 -0
- package/dist/components/elements/List/List.test.d.ts +1 -0
- package/dist/components/elements/List/List.test.js +24 -0
- package/dist/components/elements/List/index.d.ts +27 -0
- package/dist/components/elements/List/index.js +103 -0
- package/dist/components/elements/ListBox/Listbox.stories.d.ts +6 -0
- package/dist/components/elements/ListBox/Listbox.stories.js +17 -0
- package/dist/components/elements/ListBox/index.d.ts +33 -0
- package/dist/components/elements/ListBox/index.js +51 -0
- package/dist/components/elements/Markdown/Markdown.stories.d.ts +10 -0
- package/dist/components/elements/Markdown/Markdown.stories.js +97 -0
- package/dist/components/elements/Markdown/Markdown.test.d.ts +1 -0
- package/dist/components/elements/Markdown/Markdown.test.js +91 -0
- package/dist/components/elements/Markdown/index.d.ts +21 -0
- package/dist/components/elements/Markdown/index.js +75 -0
- package/dist/components/elements/Pill/Pill.stories.d.ts +8 -0
- package/dist/components/elements/Pill/Pill.stories.js +40 -0
- package/dist/components/elements/Pill/Pill.test.d.ts +1 -0
- package/dist/components/elements/Pill/Pill.test.js +18 -0
- package/dist/components/elements/Pill/index.d.ts +21 -0
- package/dist/components/elements/Pill/index.js +117 -0
- package/dist/components/elements/Spinner/Spinner.stories.d.ts +7 -0
- package/dist/components/elements/Spinner/Spinner.stories.js +26 -0
- package/dist/components/elements/Spinner/Spinner.test.d.ts +1 -0
- package/dist/components/elements/Spinner/Spinner.test.js +9 -0
- package/dist/components/elements/Spinner/index.d.ts +14 -0
- package/dist/components/elements/Spinner/index.js +49 -0
- package/dist/components/elements/TabList/TabList.stories.d.ts +6 -0
- package/dist/components/elements/TabList/TabList.stories.js +12 -0
- package/dist/components/elements/TabList/TabList.test.d.ts +1 -0
- package/dist/components/elements/TabList/TabList.test.js +19 -0
- package/dist/components/elements/TabList/example.d.ts +7 -0
- package/dist/components/elements/TabList/example.js +36 -0
- package/dist/components/elements/TabList/index.d.ts +10 -0
- package/dist/components/elements/TabList/index.js +30 -0
- package/dist/components/elements/Table/Table.stories.d.ts +10 -0
- package/dist/components/elements/Table/Table.stories.js +96 -0
- package/dist/components/elements/Table/Table.test.d.ts +1 -0
- package/dist/components/elements/Table/Table.test.js +36 -0
- package/dist/components/elements/Table/index.d.ts +30 -0
- package/dist/components/elements/Table/index.js +100 -0
- package/dist/components/elements/layout/Box.d.ts +9 -0
- package/dist/components/elements/layout/Box.js +3 -0
- package/dist/components/elements/layout/Box.stories.d.ts +6 -0
- package/dist/components/elements/layout/Box.stories.js +12 -0
- package/dist/components/elements/layout/Column.d.ts +8 -0
- package/dist/components/elements/layout/Column.js +19 -0
- package/dist/components/elements/layout/Flex.stories.d.ts +10 -0
- package/dist/components/elements/layout/Flex.stories.js +26 -0
- package/dist/components/elements/layout/Flex.test.d.ts +1 -0
- package/dist/components/elements/layout/Flex.test.js +34 -0
- package/dist/components/elements/layout/Row.d.ts +20 -0
- package/dist/components/elements/layout/Row.js +52 -0
- package/dist/components/elements/text/Heading/Heading.stories.d.ts +8 -0
- package/dist/components/elements/text/Heading/Heading.stories.js +35 -0
- package/dist/components/elements/text/Heading/Heading.test.d.ts +1 -0
- package/dist/components/elements/text/Heading/Heading.test.js +51 -0
- package/dist/components/elements/text/Heading/index.d.ts +20 -0
- package/dist/components/elements/text/Heading/index.js +62 -0
- package/dist/components/elements/text/Inline/Inline.stories.d.ts +6 -0
- package/dist/components/elements/text/Inline/Inline.stories.js +12 -0
- package/dist/components/elements/text/Inline/index.d.ts +6 -0
- package/dist/components/elements/text/Inline/index.js +21 -0
- package/dist/components/elements/text/Label/Label.stories.d.ts +6 -0
- package/dist/components/elements/text/Label/Label.stories.js +20 -0
- package/dist/components/elements/text/Label/Label.test.d.ts +1 -0
- package/dist/components/elements/text/Label/Label.test.js +56 -0
- package/dist/components/elements/text/Label/index.d.ts +20 -0
- package/dist/components/elements/text/Label/index.js +38 -0
- package/dist/components/elements/text/Paragraph/Paragraph.stories.d.ts +6 -0
- package/dist/components/elements/text/Paragraph/Paragraph.stories.js +25 -0
- package/dist/components/elements/text/Paragraph/Paragraph.test.d.ts +1 -0
- package/dist/components/elements/text/Paragraph/Paragraph.test.js +9 -0
- package/dist/components/elements/text/Paragraph/index.d.ts +14 -0
- package/dist/components/elements/text/Paragraph/index.js +29 -0
- package/dist/components/elements/text/ReadMore/ReadMore.stories.d.ts +8 -0
- package/dist/components/elements/text/ReadMore/ReadMore.stories.js +26 -0
- package/dist/components/elements/text/ReadMore/index.d.ts +12 -0
- package/dist/components/elements/text/ReadMore/index.js +71 -0
- package/dist/components/providers/alerts.d.ts +41 -0
- package/dist/components/providers/alerts.js +133 -0
- package/dist/components/providers/componentConfig.d.ts +25 -0
- package/dist/components/providers/componentConfig.js +37 -0
- package/dist/components/providers/dialogs.d.ts +9 -0
- package/dist/components/providers/dialogs.js +32 -0
- package/dist/components/providers/env.d.ts +14 -0
- package/dist/components/providers/env.js +25 -0
- package/dist/components/providers/media.d.ts +8 -0
- package/dist/components/providers/media.js +43 -0
- package/dist/components/providers/menu.d.ts +46 -0
- package/dist/components/providers/menu.js +304 -0
- package/dist/components/providers/snackBar.d.ts +23 -0
- package/dist/components/providers/snackBar.js +53 -0
- package/dist/components/providers/ui.d.ts +18 -0
- package/dist/components/providers/ui.js +16 -0
- package/dist/components/providers/uniqueIds.d.ts +3 -0
- package/dist/components/providers/uniqueIds.js +23 -0
- package/dist/components/providers/uniqueIds.test.d.ts +1 -0
- package/dist/components/providers/uniqueIds.test.js +26 -0
- package/dist/index.d.ts +53 -0
- package/dist/index.js +51 -0
- package/dist/theme/Color.stories.d.ts +5 -0
- package/dist/theme/Color.stories.js +63 -0
- package/dist/theme/GlobalStyles.d.ts +1 -0
- package/dist/theme/GlobalStyles.js +167 -0
- package/dist/theme/Typography.stories.d.ts +5 -0
- package/dist/theme/Typography.stories.js +44 -0
- package/dist/theme/colors.d.ts +51 -0
- package/dist/theme/colors.js +97 -0
- package/dist/theme/custom.d.ts +11 -0
- package/dist/theme/custom.js +13 -0
- package/dist/theme/index.d.ts +185 -0
- package/dist/theme/index.js +25 -0
- package/dist/theme/spacing.d.ts +0 -0
- package/dist/theme/spacing.js +1 -0
- package/dist/theme/typography.d.ts +100 -0
- package/dist/theme/typography.js +206 -0
- package/dist/utils/hooks/useCheckMidClick.d.ts +8 -0
- package/dist/utils/hooks/useCheckMidClick.js +17 -0
- package/dist/utils/hooks/useCheckMidKeyPress.d.ts +9 -0
- package/dist/utils/hooks/useCheckMidKeyPress.js +23 -0
- package/dist/utils/hooks/useHover.d.ts +7 -0
- package/dist/utils/hooks/useHover.js +12 -0
- package/dist/utils/hooks/useStorage.d.ts +14 -0
- package/dist/utils/hooks/useStorage.js +37 -0
- package/dist/utils/misc.d.ts +14 -0
- package/dist/utils/misc.js +19 -0
- package/dist/utils/sortByKey.d.ts +12 -0
- package/dist/utils/sortByKey.js +20 -0
- package/dist/utils/test.d.ts +2 -0
- package/dist/utils/test.js +9 -0
- package/package.json +98 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Box as BoxComponent } from './Box';
|
|
3
|
+
import { COLOR } from '../../../theme/colors';
|
|
4
|
+
const meta = {
|
|
5
|
+
title: 'Elements/Layout/Box',
|
|
6
|
+
component: BoxComponent,
|
|
7
|
+
tags: ['autodocs'],
|
|
8
|
+
};
|
|
9
|
+
export default meta;
|
|
10
|
+
export const Box = {
|
|
11
|
+
render: () => (_jsx(BoxComponent, Object.assign({ sx: { p: 1, bg: COLOR.PRIMARY } }, { children: _jsx(BoxComponent, { sx: { p: 1, bg: COLOR.SECONDARY } }) }))),
|
|
12
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { FlexHelperProps } from './Row';
|
|
3
|
+
export declare const Column: React.ForwardRefExoticComponent<{
|
|
4
|
+
sx?: import("../../../theme").StylesProp | undefined;
|
|
5
|
+
children?: React.ReactNode;
|
|
6
|
+
} & Omit<React.HTMLAttributes<HTMLDivElement>, "children" | "onChange"> & FlexHelperProps & {
|
|
7
|
+
htmlFor?: string | undefined;
|
|
8
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,19 @@
|
|
|
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 React from 'react';
|
|
14
|
+
import { convertFlexHelperProps } from './Row';
|
|
15
|
+
export const Column = React.forwardRef((_a, ref) => {
|
|
16
|
+
var { sx, children } = _a, rest = __rest(_a, ["sx", "children"]);
|
|
17
|
+
const flexStyles = convertFlexHelperProps(rest);
|
|
18
|
+
return (_jsx("div", Object.assign({ ref: ref }, rest, { sx: Object.assign(Object.assign(Object.assign({}, flexStyles), sx), { display: 'flex', flexDirection: 'column' }) }, { children: children })));
|
|
19
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { Row } from './Row';
|
|
3
|
+
declare const meta: Meta<typeof Row>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof Row>;
|
|
6
|
+
export declare const Columns: Story;
|
|
7
|
+
export declare const Rows: Story;
|
|
8
|
+
export declare const ResponsiveRow: Story;
|
|
9
|
+
export declare const FlexHelpers: Story;
|
|
10
|
+
export declare const Centered: Story;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Column } from './Column';
|
|
3
|
+
import { Row } from './Row';
|
|
4
|
+
import { Paragraph } from '../text/Paragraph';
|
|
5
|
+
import { COLOR } from '../../../theme/colors';
|
|
6
|
+
const meta = {
|
|
7
|
+
title: 'Elements/Layout/Flex',
|
|
8
|
+
component: Row,
|
|
9
|
+
tags: ['autodocs'],
|
|
10
|
+
};
|
|
11
|
+
export default meta;
|
|
12
|
+
export const Columns = {
|
|
13
|
+
render: () => (_jsxs(Row, Object.assign({ justify: "space-between" }, { 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" }) })] }))),
|
|
14
|
+
};
|
|
15
|
+
export const Rows = {
|
|
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
|
+
};
|
|
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
|
+
};
|
|
21
|
+
export const FlexHelpers = {
|
|
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" }) }))] }))),
|
|
23
|
+
};
|
|
24
|
+
export const Centered = {
|
|
25
|
+
render: () => (_jsx(Row, Object.assign({ centered: true, sx: { width: '100%', height: '100px', border: 'solid black 1px' } }, { children: _jsx(Paragraph, { children: "Hello World" }) }))),
|
|
26
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { render } from '../../../utils/test';
|
|
3
|
+
import { Row } from './Row';
|
|
4
|
+
import { Column } from './Column';
|
|
5
|
+
describe('Row', () => {
|
|
6
|
+
it('renders without throwing an error', () => {
|
|
7
|
+
const { getByText } = render(_jsx(Row, { children: "Foo" }));
|
|
8
|
+
expect(getByText('Foo')).toBeInTheDocument();
|
|
9
|
+
});
|
|
10
|
+
it('converts helper props to styles', () => {
|
|
11
|
+
const { getByText } = render(_jsx(Row, Object.assign({ grow: 1, shrink: 1, basis: "100px", align: "baseline", justify: "flex-start" }, { children: "Foo" })));
|
|
12
|
+
const rendered = getByText('Foo');
|
|
13
|
+
expect(rendered).toHaveStyle('flex-grow: 1');
|
|
14
|
+
expect(rendered).toHaveStyle('flex-shrink: 1');
|
|
15
|
+
expect(rendered).toHaveStyle('flex-basis: 100px');
|
|
16
|
+
expect(rendered).toHaveStyle('align-items: baseline');
|
|
17
|
+
expect(rendered).toHaveStyle('justify-content: flex-start');
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
describe('Column', () => {
|
|
21
|
+
it('renders without throwing an error', () => {
|
|
22
|
+
const { getByText } = render(_jsx(Column, { children: "Foo" }));
|
|
23
|
+
expect(getByText('Foo')).toBeInTheDocument();
|
|
24
|
+
});
|
|
25
|
+
it('converts helper props to styles', () => {
|
|
26
|
+
const { getByText } = render(_jsx(Column, Object.assign({ grow: 1, shrink: 1, basis: "100px", align: "baseline", justify: "flex-start" }, { children: "Foo" })));
|
|
27
|
+
const rendered = getByText('Foo');
|
|
28
|
+
expect(rendered).toHaveStyle('flex-grow: 1');
|
|
29
|
+
expect(rendered).toHaveStyle('flex-shrink: 1');
|
|
30
|
+
expect(rendered).toHaveStyle('flex-basis: 100px');
|
|
31
|
+
expect(rendered).toHaveStyle('align-items: baseline');
|
|
32
|
+
expect(rendered).toHaveStyle('justify-content: flex-start');
|
|
33
|
+
});
|
|
34
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { CSSProperties, ThemeUICSSProperties } from 'theme-ui';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export declare const convertFlexHelperProps: (props: FlexHelperProps) => ThemeUICSSProperties;
|
|
4
|
+
export type FlexHelperProps = {
|
|
5
|
+
grow?: number;
|
|
6
|
+
shrink?: number;
|
|
7
|
+
basis?: string;
|
|
8
|
+
flex?: string;
|
|
9
|
+
align?: CSSProperties['alignItems'];
|
|
10
|
+
justify?: CSSProperties['justifyContent'];
|
|
11
|
+
centered?: boolean;
|
|
12
|
+
};
|
|
13
|
+
export declare const Row: React.ForwardRefExoticComponent<{
|
|
14
|
+
sx?: import("../../../theme").StylesProp | undefined;
|
|
15
|
+
children?: React.ReactNode;
|
|
16
|
+
} & Omit<React.HTMLAttributes<HTMLDivElement>, "children" | "onChange"> & FlexHelperProps & {
|
|
17
|
+
breakpoint?: number | undefined;
|
|
18
|
+
} & {
|
|
19
|
+
htmlFor?: string | undefined;
|
|
20
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,52 @@
|
|
|
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 React from 'react';
|
|
14
|
+
export const convertFlexHelperProps = (props) => {
|
|
15
|
+
const styleObject = {};
|
|
16
|
+
if (props.grow) {
|
|
17
|
+
styleObject.flexGrow = props.grow;
|
|
18
|
+
}
|
|
19
|
+
if (props.shrink) {
|
|
20
|
+
styleObject.flexShrink = props.shrink;
|
|
21
|
+
}
|
|
22
|
+
if (props.flex) {
|
|
23
|
+
styleObject.flex = props.flex;
|
|
24
|
+
}
|
|
25
|
+
if (props.basis) {
|
|
26
|
+
styleObject.flexBasis = props.basis;
|
|
27
|
+
}
|
|
28
|
+
if (props.centered) {
|
|
29
|
+
styleObject.alignItems = 'center';
|
|
30
|
+
styleObject.justifyContent = 'center';
|
|
31
|
+
}
|
|
32
|
+
if (props.align) {
|
|
33
|
+
styleObject.alignItems = props.align;
|
|
34
|
+
}
|
|
35
|
+
if (props.justify) {
|
|
36
|
+
styleObject.justifyContent = props.justify;
|
|
37
|
+
}
|
|
38
|
+
return styleObject;
|
|
39
|
+
};
|
|
40
|
+
export const Row = React.forwardRef((_a, ref) => {
|
|
41
|
+
var { sx, children, breakpoint: breakpointParam } = _a, rest = __rest(_a, ["sx", "children", "breakpoint"]);
|
|
42
|
+
const flexStyles = convertFlexHelperProps(rest);
|
|
43
|
+
let flexDirection = 'row';
|
|
44
|
+
if (breakpointParam !== undefined) {
|
|
45
|
+
flexDirection = [];
|
|
46
|
+
for (let i = 0; i <= breakpointParam; i++) {
|
|
47
|
+
flexDirection.push('column');
|
|
48
|
+
}
|
|
49
|
+
flexDirection.push('row');
|
|
50
|
+
}
|
|
51
|
+
return (_jsx("div", Object.assign({}, rest, { ref: ref, sx: Object.assign(Object.assign(Object.assign({}, flexStyles), sx), { flexDirection, display: 'flex' }) }, { children: children })));
|
|
52
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { Heading } from '.';
|
|
3
|
+
declare const meta: Meta<typeof Heading>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof Heading>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const Color: Story;
|
|
8
|
+
export declare const Underline: Story;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { GROUP_TYPE, Group } from '../../Group';
|
|
3
|
+
import { HEADING_SIZE, Heading } from '.';
|
|
4
|
+
import { Column } from '../../layout/Column';
|
|
5
|
+
import { COLOR } from '../../../../theme/colors';
|
|
6
|
+
const meta = {
|
|
7
|
+
title: 'Elements/Heading',
|
|
8
|
+
component: Heading,
|
|
9
|
+
tags: ['autodocs'],
|
|
10
|
+
};
|
|
11
|
+
export default meta;
|
|
12
|
+
const sizes = [
|
|
13
|
+
{ size: HEADING_SIZE.XL, label: 'Extra Large (Default Level 1)' },
|
|
14
|
+
{ size: HEADING_SIZE.LG, label: 'Large (Default Level 2)' },
|
|
15
|
+
{ size: HEADING_SIZE.MD, label: 'Medium (Default Level 3)' },
|
|
16
|
+
{ size: HEADING_SIZE.SM, label: 'Small (Default Level 4-6)' },
|
|
17
|
+
];
|
|
18
|
+
export const Default = {
|
|
19
|
+
render: () => (_jsx(Column, { children: sizes.map((size) => (_jsx(Group, Object.assign({ type: GROUP_TYPE.REGION }, { children: _jsx(Heading, Object.assign({ size: size.size }, { children: size.label })) })))) })),
|
|
20
|
+
args: {
|
|
21
|
+
children: 'Heading',
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
export const Color = {
|
|
25
|
+
render: () => (_jsx(Column, { children: sizes.map((size) => (_jsx(Group, Object.assign({ type: GROUP_TYPE.REGION }, { children: _jsx(Heading, Object.assign({ size: size.size, sx: { color: COLOR.TEXT } }, { children: size.label })) })))) })),
|
|
26
|
+
args: {
|
|
27
|
+
children: 'Heading',
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
export const Underline = {
|
|
31
|
+
render: () => (_jsx(Column, { children: sizes.map((size) => (_jsx(Group, Object.assign({ type: GROUP_TYPE.REGION }, { children: _jsx(Heading, Object.assign({ size: size.size, underline: true }, { children: size.label })) })))) })),
|
|
32
|
+
args: {
|
|
33
|
+
children: 'Heading',
|
|
34
|
+
},
|
|
35
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,51 @@
|
|
|
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 { vi } from 'vitest';
|
|
12
|
+
import { render as _render } from '../../../../utils/test';
|
|
13
|
+
import { Heading } from '.';
|
|
14
|
+
import { GROUP_TYPE, Group } from '../../Group';
|
|
15
|
+
import { ENVIRONMENT } from '../../../providers/env';
|
|
16
|
+
const render = (component) => {
|
|
17
|
+
return _render(component, { env: ENVIRONMENT.DEV });
|
|
18
|
+
};
|
|
19
|
+
describe('Heading', () => {
|
|
20
|
+
const originalError = console.error;
|
|
21
|
+
beforeEach(() => {
|
|
22
|
+
console.error = vi.fn();
|
|
23
|
+
});
|
|
24
|
+
afterEach(() => {
|
|
25
|
+
console.error = originalError;
|
|
26
|
+
vi.useRealTimers();
|
|
27
|
+
});
|
|
28
|
+
it('renders without an error if passed standalone prop', () => {
|
|
29
|
+
const { getByText } = render(_jsx(Heading, Object.assign({ standalone: true }, { children: "Foo" })));
|
|
30
|
+
expect(getByText('Foo')).toBeInTheDocument();
|
|
31
|
+
});
|
|
32
|
+
it('renders without an error if used within region Group component', () => {
|
|
33
|
+
const { getByText } = render(_jsx(Group, { children: _jsx(Heading, { children: "Foo" }) }));
|
|
34
|
+
expect(getByText('Foo')).toBeInTheDocument();
|
|
35
|
+
});
|
|
36
|
+
it('throws if used outside a Group component', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
37
|
+
expect(() => render(_jsx(Heading, { children: "Foo" }))).toThrow();
|
|
38
|
+
}));
|
|
39
|
+
it('throws if used within non-region Group component', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
40
|
+
expect(() => render(_jsx(Group, Object.assign({ type: GROUP_TYPE.GROUP }, { children: _jsx(Heading, { children: "Foo" }) })))).toThrow();
|
|
41
|
+
}));
|
|
42
|
+
it('labels group target automatically', () => {
|
|
43
|
+
const { getByLabelText } = render(_jsx(Group, { children: _jsx(Heading, { children: "Foo" }) }));
|
|
44
|
+
expect(getByLabelText('Foo')).toBeDefined();
|
|
45
|
+
});
|
|
46
|
+
it('is required to render region Group component', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
47
|
+
vi.useFakeTimers();
|
|
48
|
+
render(_jsx(Group, { children: "Foo" }));
|
|
49
|
+
expect(() => vi.runAllTimers()).toThrow();
|
|
50
|
+
}));
|
|
51
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TYPOGRAPHY_TYPE } from '../../../../theme/typography';
|
|
3
|
+
import { StyledElementProps } from '../../../../theme';
|
|
4
|
+
import { COLOR } from '../../../../theme/colors';
|
|
5
|
+
type HeaderProps = StyledElementProps<HTMLSpanElement, {
|
|
6
|
+
size?: HEADING_SIZE;
|
|
7
|
+
standalone?: boolean;
|
|
8
|
+
underline?: boolean;
|
|
9
|
+
underlineColor?: COLOR;
|
|
10
|
+
typography?: TYPOGRAPHY_TYPE;
|
|
11
|
+
level?: number;
|
|
12
|
+
}>;
|
|
13
|
+
export declare enum HEADING_SIZE {
|
|
14
|
+
SM = "sm",
|
|
15
|
+
MD = "md",
|
|
16
|
+
LG = "lg",
|
|
17
|
+
XL = "xl"
|
|
18
|
+
}
|
|
19
|
+
export declare const Heading: React.FC<HeaderProps>;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,62 @@
|
|
|
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 { useEffect } from 'react';
|
|
14
|
+
import { getTypographyStyles, TYPOGRAPHY_TYPE, } from '../../../../theme/typography';
|
|
15
|
+
import { GROUP_TYPE, useGroup } from '../../Group';
|
|
16
|
+
import { COLOR } from '../../../../theme/colors';
|
|
17
|
+
import { useEnvironment } from '../../../providers/env';
|
|
18
|
+
export var HEADING_SIZE;
|
|
19
|
+
(function (HEADING_SIZE) {
|
|
20
|
+
HEADING_SIZE["SM"] = "sm";
|
|
21
|
+
HEADING_SIZE["MD"] = "md";
|
|
22
|
+
HEADING_SIZE["LG"] = "lg";
|
|
23
|
+
HEADING_SIZE["XL"] = "xl";
|
|
24
|
+
})(HEADING_SIZE || (HEADING_SIZE = {}));
|
|
25
|
+
const SIZE_TYPOGRAPHY_MAP = {
|
|
26
|
+
[HEADING_SIZE.SM]: TYPOGRAPHY_TYPE.HEADING_SMALL,
|
|
27
|
+
[HEADING_SIZE.MD]: TYPOGRAPHY_TYPE.HEADING_MEDIUM,
|
|
28
|
+
[HEADING_SIZE.LG]: TYPOGRAPHY_TYPE.HEADING_LARGE,
|
|
29
|
+
[HEADING_SIZE.XL]: TYPOGRAPHY_TYPE.HEADING_XLARGE,
|
|
30
|
+
};
|
|
31
|
+
const LEVEL_TYPOGRAPHY_MAP = {
|
|
32
|
+
1: TYPOGRAPHY_TYPE.HEADING_XLARGE,
|
|
33
|
+
2: TYPOGRAPHY_TYPE.HEADING_LARGE,
|
|
34
|
+
3: TYPOGRAPHY_TYPE.HEADING_MEDIUM,
|
|
35
|
+
4: TYPOGRAPHY_TYPE.HEADING_SMALL,
|
|
36
|
+
5: TYPOGRAPHY_TYPE.HEADING_SMALL,
|
|
37
|
+
6: TYPOGRAPHY_TYPE.HEADING_SMALL,
|
|
38
|
+
};
|
|
39
|
+
export const Heading = (_a) => {
|
|
40
|
+
var { sx, size, standalone, underline, underlineColor, typography: typographyProp, level: levelParam } = _a, rest = __rest(_a, ["sx", "size", "standalone", "underline", "underlineColor", "typography", "level"]);
|
|
41
|
+
const { level: groupLevel, labelId, type, trackHeadingRendered } = useGroup();
|
|
42
|
+
const { flagInDevelopment } = useEnvironment();
|
|
43
|
+
const level = levelParam || groupLevel;
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
trackHeadingRendered();
|
|
46
|
+
});
|
|
47
|
+
let typography = TYPOGRAPHY_TYPE.HEADING_MEDIUM;
|
|
48
|
+
if (typographyProp) {
|
|
49
|
+
typography = typographyProp;
|
|
50
|
+
}
|
|
51
|
+
else if (size) {
|
|
52
|
+
typography = SIZE_TYPOGRAPHY_MAP[size];
|
|
53
|
+
}
|
|
54
|
+
else if (level) {
|
|
55
|
+
typography =
|
|
56
|
+
LEVEL_TYPOGRAPHY_MAP[level];
|
|
57
|
+
}
|
|
58
|
+
if (type !== GROUP_TYPE.REGION && !standalone) {
|
|
59
|
+
flagInDevelopment('Heading component should be used within a Group component with property type={GROUP_TYPE.REGION} or given the standalone flag');
|
|
60
|
+
}
|
|
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)));
|
|
62
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Bold, Italic } from '.';
|
|
3
|
+
import { Paragraph } from '../Paragraph';
|
|
4
|
+
const meta = {
|
|
5
|
+
title: 'Elements/Inline',
|
|
6
|
+
component: Bold,
|
|
7
|
+
tags: ['autodocs'],
|
|
8
|
+
};
|
|
9
|
+
export default meta;
|
|
10
|
+
export const Default = {
|
|
11
|
+
render: () => (_jsxs(Paragraph, { children: ["Text with ", _jsx(Bold, { children: "bold content" }), " and ", _jsx(Italic, { children: "italic content" })] })),
|
|
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
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { GROUP_TYPE, Group } from '../../Group';
|
|
3
|
+
import { LABEL_SIZE, Label } from '.';
|
|
4
|
+
import { Column } from '../../layout/Column';
|
|
5
|
+
const meta = {
|
|
6
|
+
title: 'Elements/Label',
|
|
7
|
+
component: Label,
|
|
8
|
+
};
|
|
9
|
+
export default meta;
|
|
10
|
+
const sizes = [
|
|
11
|
+
{ size: LABEL_SIZE.LG, label: 'Large' },
|
|
12
|
+
{ size: LABEL_SIZE.MD, label: 'Medium' },
|
|
13
|
+
{ size: LABEL_SIZE.SM, label: 'Small' },
|
|
14
|
+
];
|
|
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 })) })))) })),
|
|
17
|
+
args: {
|
|
18
|
+
children: 'Label',
|
|
19
|
+
},
|
|
20
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
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, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
+
import { vi } from 'vitest';
|
|
12
|
+
import { render as _render } from '../../../../utils/test';
|
|
13
|
+
import { Label } from '.';
|
|
14
|
+
import { GROUP_TYPE, Group } from '../../Group';
|
|
15
|
+
import { ENVIRONMENT } from '../../../providers/env';
|
|
16
|
+
import userEvent from '@testing-library/user-event';
|
|
17
|
+
import { waitFor } from '@testing-library/react';
|
|
18
|
+
const render = (component) => {
|
|
19
|
+
return _render(component, { env: ENVIRONMENT.DEV });
|
|
20
|
+
};
|
|
21
|
+
describe('Label', () => {
|
|
22
|
+
const originalError = console.error;
|
|
23
|
+
beforeEach(() => {
|
|
24
|
+
console.error = vi.fn();
|
|
25
|
+
});
|
|
26
|
+
afterEach(() => {
|
|
27
|
+
console.error = originalError;
|
|
28
|
+
vi.useRealTimers();
|
|
29
|
+
});
|
|
30
|
+
it('renders without an error if passed standalone prop', () => {
|
|
31
|
+
const { getByText } = render(_jsx(Label, Object.assign({ standalone: true }, { children: "Foo" })));
|
|
32
|
+
expect(getByText('Foo')).toBeInTheDocument();
|
|
33
|
+
});
|
|
34
|
+
it('renders without an error if used within region Group component', () => {
|
|
35
|
+
const { getByText } = render(_jsx(Group, Object.assign({ type: GROUP_TYPE.GROUP }, { children: _jsx(Label, { children: "Foo" }) })));
|
|
36
|
+
expect(getByText('Foo')).toBeInTheDocument();
|
|
37
|
+
});
|
|
38
|
+
it('throws if used outside a Group component', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
39
|
+
expect(() => render(_jsx(Label, { children: "Foo" }))).toThrow();
|
|
40
|
+
}));
|
|
41
|
+
it('throws if used within non-group-type Group component', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
42
|
+
expect(() => render(_jsx(Group, Object.assign({ type: GROUP_TYPE.REGION }, { children: _jsx(Label, { children: "Foo" }) })))).toThrow();
|
|
43
|
+
}));
|
|
44
|
+
it('labels group target automatically', () => {
|
|
45
|
+
const { getByLabelText } = render(_jsx(Group, Object.assign({ type: GROUP_TYPE.GROUP }, { children: _jsx(Label, { children: "Foo" }) })));
|
|
46
|
+
expect(getByLabelText('Foo')).toBeDefined();
|
|
47
|
+
});
|
|
48
|
+
it('can send focus to label target', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
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 })] })) })));
|
|
51
|
+
userEvent.click(getByText('Foo'));
|
|
52
|
+
yield waitFor(() => {
|
|
53
|
+
expect(getByTestId(INPUT_TEST_ID)).toHaveFocus();
|
|
54
|
+
});
|
|
55
|
+
}));
|
|
56
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TYPOGRAPHY_TYPE } from '../../../../theme/typography';
|
|
3
|
+
import { StyledElementProps } from '../../../../theme';
|
|
4
|
+
export declare enum LABEL_SIZE {
|
|
5
|
+
SM = "sm",
|
|
6
|
+
MD = "md",
|
|
7
|
+
LG = "lg"
|
|
8
|
+
}
|
|
9
|
+
export declare const SIZE_TYPOGRAPHY_MAP: {
|
|
10
|
+
sm: TYPOGRAPHY_TYPE;
|
|
11
|
+
md: TYPOGRAPHY_TYPE;
|
|
12
|
+
lg: TYPOGRAPHY_TYPE;
|
|
13
|
+
};
|
|
14
|
+
type LabelProps = StyledElementProps<HTMLLabelElement, {
|
|
15
|
+
size?: LABEL_SIZE;
|
|
16
|
+
typography?: TYPOGRAPHY_TYPE;
|
|
17
|
+
standalone?: boolean;
|
|
18
|
+
}>;
|
|
19
|
+
export declare const Label: React.FC<LabelProps>;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
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 { getTypographyStyles, TYPOGRAPHY_TYPE, } from '../../../../theme/typography';
|
|
14
|
+
import { GROUP_TYPE, useGroup } from '../../Group';
|
|
15
|
+
import { useEnvironment } from '../../../providers/env';
|
|
16
|
+
export var LABEL_SIZE;
|
|
17
|
+
(function (LABEL_SIZE) {
|
|
18
|
+
LABEL_SIZE["SM"] = "sm";
|
|
19
|
+
LABEL_SIZE["MD"] = "md";
|
|
20
|
+
LABEL_SIZE["LG"] = "lg";
|
|
21
|
+
})(LABEL_SIZE || (LABEL_SIZE = {}));
|
|
22
|
+
export const SIZE_TYPOGRAPHY_MAP = {
|
|
23
|
+
[LABEL_SIZE.SM]: TYPOGRAPHY_TYPE.CONTROL_SMALL,
|
|
24
|
+
[LABEL_SIZE.MD]: TYPOGRAPHY_TYPE.CONTROL_MEDIUM,
|
|
25
|
+
[LABEL_SIZE.LG]: TYPOGRAPHY_TYPE.CONTROL_LARGE,
|
|
26
|
+
};
|
|
27
|
+
export const Label = (_a) => {
|
|
28
|
+
var { sx, size, standalone, typography: typographyParam } = _a, rest = __rest(_a, ["sx", "size", "standalone", "typography"]);
|
|
29
|
+
const { labelId, labelTargetId, type: groupType } = useGroup();
|
|
30
|
+
const { flagInDevelopment } = useEnvironment();
|
|
31
|
+
const typography = typographyParam || SIZE_TYPOGRAPHY_MAP[size || LABEL_SIZE.MD];
|
|
32
|
+
if (groupType !== GROUP_TYPE.GROUP &&
|
|
33
|
+
groupType !== GROUP_TYPE.RAW &&
|
|
34
|
+
!standalone) {
|
|
35
|
+
flagInDevelopment('Label component should be used within a Group component with property type={GROUP_TYPE.GROUP} or given the standalone flag');
|
|
36
|
+
}
|
|
37
|
+
return (_jsx("label", Object.assign({ id: labelId, htmlFor: labelTargetId, sx: Object.assign(Object.assign({}, getTypographyStyles(typography)), sx) }, rest)));
|
|
38
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { GROUP_TYPE, Group } from '../../Group';
|
|
3
|
+
import { PARAGRAPH_SIZE, Paragraph } from '.';
|
|
4
|
+
import { Column } from '../../layout/Column';
|
|
5
|
+
import { HEADING_SIZE, Heading } from '../Heading';
|
|
6
|
+
import { COLOR } from '../../../../theme/colors';
|
|
7
|
+
const meta = {
|
|
8
|
+
title: 'Elements/Paragraph',
|
|
9
|
+
component: Paragraph,
|
|
10
|
+
tags: ['autodocs'],
|
|
11
|
+
};
|
|
12
|
+
export default meta;
|
|
13
|
+
const sizes = [
|
|
14
|
+
{ size: PARAGRAPH_SIZE.LG, label: 'Large' },
|
|
15
|
+
{ size: PARAGRAPH_SIZE.MD, label: 'Medium' },
|
|
16
|
+
{ size: PARAGRAPH_SIZE.SM, label: 'Small' },
|
|
17
|
+
];
|
|
18
|
+
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.';
|
|
19
|
+
const p2 = 'Sed non lobortis mi, vitae dapibus arcu. Aenean at euismod arcu. Ut consectetur porttitor mattis. In eget vehicula augue. Ut at dolor posuere, tristique nisi finibus, posuere turpis. Etiam placerat, dui id lacinia volutpat, lorem turpis volutpat nisi, vel dapibus purus lorem at ante. Ut imperdiet enim nec arcu sagittis luctus.';
|
|
20
|
+
export const Default = {
|
|
21
|
+
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 }))))] })))) })),
|
|
22
|
+
args: {
|
|
23
|
+
children: 'Heading',
|
|
24
|
+
},
|
|
25
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|