@ndlib/component-library 1.0.21 → 1.0.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -8
- package/dist/assets/index-3cfb730f.js +1 -0
- package/dist/components/composites/Card/Card.stories.js +2 -0
- package/dist/components/composites/Card/index.js +4 -3
- package/dist/components/composites/CardV2/CardV2.module.css +74 -0
- package/dist/components/composites/CardV2/CardV2.stories.d.ts +19 -0
- package/dist/components/composites/CardV2/CardV2.stories.js +187 -0
- package/dist/components/composites/CardV2/CardV2.test.js +67 -0
- package/dist/components/composites/CardV2/index.d.ts +43 -0
- package/dist/components/composites/CardV2/index.js +99 -0
- package/dist/components/composites/DragDropList/DragDropList.stories.js +3 -1
- package/dist/components/composites/DropdownLinks/DropdownLinks.stories.js +2 -0
- package/dist/components/composites/DropdownLinks/index.d.ts +1 -1
- package/dist/components/composites/EmptyState/EmptyState.stories.js +2 -0
- package/dist/components/composites/EmptyState/index.js +1 -1
- package/dist/components/composites/Modal/Modal.stories.js +5 -2
- package/dist/components/composites/Modal/index.js +3 -2
- package/dist/components/composites/ModalV2/ModalV2.stories.d.ts +6 -0
- package/dist/components/composites/ModalV2/ModalV2.stories.js +41 -0
- package/dist/components/composites/ModalV2/ModalV2.test.js +37 -0
- package/dist/components/composites/ModalV2/index.d.ts +20 -0
- package/dist/components/composites/ModalV2/index.js +65 -0
- package/dist/components/composites/NavMenu/NavMenu.stories.js +2 -0
- package/dist/components/composites/NavMenu/index.js +1 -1
- package/dist/components/composites/Seo/seo.stories.js +2 -0
- package/dist/components/composites/SnackBar/SnackBar.stories.js +2 -0
- package/dist/components/composites/StructuredData/StructuredData.stories.js +2 -0
- package/dist/components/elements/Alerts/Alert.stories.js +2 -0
- package/dist/components/elements/Alerts/Alerts.stories.js +2 -0
- package/dist/components/elements/Alerts/index.js +2 -1
- package/dist/components/elements/ArrowLink/ArrowLink.stories.js +2 -0
- package/dist/components/elements/{Fields/AutoComplete → AutoComplete}/AutoComplete.stories.js +6 -4
- package/dist/components/elements/{Fields/AutoComplete → AutoComplete}/AutoComplete.test.js +1 -1
- package/dist/components/elements/{Fields/AutoComplete → AutoComplete}/index.js +3 -3
- package/dist/components/elements/BrandingBar/BrandingBar.stories.js +2 -0
- package/dist/components/elements/Button/Button.stories.js +4 -2
- package/dist/components/elements/ButtonV2/ButtonV2.module.css +25 -0
- package/dist/components/elements/ButtonV2/ButtonV2.stories.d.ts +15 -0
- package/dist/components/elements/ButtonV2/ButtonV2.stories.js +90 -0
- package/dist/components/elements/ButtonV2/ButtonV2.test.js +45 -0
- package/dist/components/elements/ButtonV2/index.d.ts +51 -0
- package/dist/components/elements/ButtonV2/index.js +137 -0
- package/dist/components/elements/{Fields/Checkbox → Checkbox}/Checkbox.stories.js +3 -1
- package/dist/components/elements/{Fields/Checkbox → Checkbox}/Checkbox.test.js +1 -1
- package/dist/components/elements/{Fields/Checkbox → Checkbox}/index.d.ts +1 -1
- package/dist/components/elements/{Fields/Checkbox → Checkbox}/index.js +2 -2
- package/dist/components/elements/{Fields/CheckboxGroup → CheckboxGroup}/CheckboxGroup.stories.js +3 -1
- package/dist/components/elements/{Fields/CheckboxGroup → CheckboxGroup}/CheckboxGroup.test.js +1 -1
- package/dist/components/elements/{Fields/CheckboxGroup → CheckboxGroup}/index.d.ts +1 -1
- package/dist/components/elements/{Fields/CheckboxGroup → CheckboxGroup}/index.js +7 -7
- package/dist/components/elements/CheckboxGroupV2/CheckboxGroupV2.stories.d.ts +8 -0
- package/dist/components/elements/CheckboxGroupV2/CheckboxGroupV2.stories.js +31 -0
- package/dist/components/elements/CheckboxGroupV2/CheckboxGroupV2.test.js +34 -0
- package/dist/components/elements/CheckboxGroupV2/index.d.ts +17 -0
- package/dist/components/elements/CheckboxGroupV2/index.js +50 -0
- package/dist/components/elements/CheckboxV2/CheckboxV2.module.css +5 -0
- package/dist/components/elements/CheckboxV2/CheckboxV2.stories.d.ts +6 -0
- package/dist/components/elements/CheckboxV2/CheckboxV2.stories.js +19 -0
- package/dist/components/elements/CheckboxV2/CheckboxV2.test.js +35 -0
- package/dist/components/elements/CheckboxV2/index.d.ts +10 -0
- package/dist/components/elements/CheckboxV2/index.js +23 -0
- package/dist/components/elements/{Fields/DatePicker → DatePicker}/DatePicker.stories.js +3 -1
- package/dist/components/elements/{Fields/DatePicker → DatePicker}/DatePicker.test.js +1 -1
- package/dist/components/elements/{Fields/DatePicker → DatePicker}/index.d.ts +1 -1
- package/dist/components/elements/{Fields/DatePicker → DatePicker}/index.js +2 -2
- package/dist/components/elements/Dropdown/Dropdown.stories.js +3 -1
- package/dist/components/elements/Dropdown/index.js +1 -1
- package/dist/components/elements/GroupV2/index.d.ts +22 -0
- package/dist/components/elements/GroupV2/index.js +71 -0
- package/dist/components/elements/{text/Heading → Heading}/Heading.stories.js +5 -3
- package/dist/components/elements/{text/Heading → Heading}/Heading.test.js +3 -3
- package/dist/components/elements/{text/Heading → Heading}/index.d.ts +3 -3
- package/dist/components/elements/{text/Heading → Heading}/index.js +10 -9
- package/dist/components/elements/HeadingV2/HeadingV2.module.css +8 -0
- package/dist/components/elements/HeadingV2/HeadingV2.stories.d.ts +8 -0
- package/dist/components/elements/HeadingV2/HeadingV2.stories.js +37 -0
- package/dist/components/elements/HeadingV2/HeadingV2.test.js +51 -0
- package/dist/components/elements/HeadingV2/index.d.ts +23 -0
- package/dist/components/elements/HeadingV2/index.js +101 -0
- package/dist/components/elements/Icon/Icon.stories.js +3 -1
- package/dist/components/elements/IconV2/IconV2.module.css +10 -0
- package/dist/components/elements/IconV2/IconV2.stories.d.ts +7 -0
- package/dist/components/elements/IconV2/IconV2.stories.js +31 -0
- package/dist/components/elements/IconV2/IconV2.test.js +62 -0
- package/dist/components/elements/IconV2/index.d.ts +11 -0
- package/dist/components/elements/IconV2/index.js +34 -0
- package/dist/components/elements/{text/Inline → Inline}/Inline.stories.js +2 -0
- package/dist/components/elements/{text/Inline → Inline}/index.d.ts +1 -1
- package/dist/components/elements/{text/Inline → Inline}/index.js +1 -1
- package/dist/components/elements/{text/Label → Label}/Label.stories.js +4 -2
- package/dist/components/elements/Label/Label.test.d.ts +1 -0
- package/dist/components/elements/{text/Label → Label}/Label.test.js +3 -3
- package/dist/components/elements/{text/Label → Label}/index.d.ts +2 -2
- package/dist/components/elements/{text/Label → Label}/index.js +3 -3
- package/dist/components/elements/LabelV2/LabelV2.stories.d.ts +6 -0
- package/dist/components/elements/LabelV2/LabelV2.stories.js +22 -0
- package/dist/components/elements/LabelV2/LabelV2.test.d.ts +1 -0
- package/dist/components/elements/LabelV2/LabelV2.test.js +56 -0
- package/dist/components/elements/LabelV2/index.d.ts +20 -0
- package/dist/components/elements/LabelV2/index.js +41 -0
- package/dist/components/elements/Link/Link.stories.js +3 -1
- package/dist/components/elements/List/List.stories.js +3 -1
- package/dist/components/elements/List/index.js +1 -1
- package/dist/components/elements/ListBox/Listbox.stories.js +2 -0
- package/dist/components/elements/ListBox/index.d.ts +1 -1
- package/dist/components/elements/ListBox/index.js +1 -1
- package/dist/components/elements/ListBoxV2/ListBoxV2.module.css +33 -0
- package/dist/components/elements/ListBoxV2/ListBoxV2.stories.d.ts +6 -0
- package/dist/components/elements/ListBoxV2/ListBoxV2.stories.js +19 -0
- package/dist/components/elements/ListBoxV2/index.d.ts +35 -0
- package/dist/components/elements/ListBoxV2/index.js +36 -0
- package/dist/components/elements/Markdown/Markdown.stories.js +2 -0
- package/dist/components/elements/Markdown/index.js +4 -4
- package/dist/components/elements/{Fields/MonthPicker → MonthPicker}/MonthPicker.stories.js +3 -1
- package/dist/components/elements/MonthPicker/MonthPicker.test.d.ts +1 -0
- package/dist/components/elements/{Fields/MonthPicker → MonthPicker}/MonthPicker.test.js +1 -1
- package/dist/components/elements/{Fields/MonthPicker → MonthPicker}/index.d.ts +1 -1
- package/dist/components/elements/{Fields/MonthPicker → MonthPicker}/index.js +2 -2
- package/dist/components/elements/{text/Paragraph → Paragraph}/Paragraph.stories.js +5 -3
- package/dist/components/elements/Paragraph/Paragraph.test.d.ts +1 -0
- package/dist/components/elements/{text/Paragraph → Paragraph}/Paragraph.test.js +1 -1
- package/dist/components/elements/{text/Paragraph → Paragraph}/index.d.ts +2 -2
- package/dist/components/elements/{text/Paragraph → Paragraph}/index.js +6 -5
- package/dist/components/elements/ParagraphV2/ParagraphV2.stories.d.ts +7 -0
- package/dist/components/elements/ParagraphV2/ParagraphV2.stories.js +33 -0
- package/dist/components/elements/ParagraphV2/ParagraphV2.test.d.ts +1 -0
- package/dist/components/elements/ParagraphV2/ParagraphV2.test.js +9 -0
- package/dist/components/elements/ParagraphV2/index.d.ts +15 -0
- package/dist/components/elements/ParagraphV2/index.js +39 -0
- package/dist/components/elements/Pill/Pill.stories.js +3 -1
- package/dist/components/elements/Pill/index.js +2 -1
- package/dist/components/elements/{Fields/Radio → Radio}/Radio.stories.js +3 -1
- package/dist/components/elements/Radio/Radio.test.d.ts +1 -0
- package/dist/components/elements/{Fields/Radio → Radio}/Radio.test.js +3 -3
- package/dist/components/elements/{Fields/Radio → Radio}/index.d.ts +1 -1
- package/dist/components/elements/{Fields/Radio → Radio}/index.js +1 -1
- package/dist/components/elements/{Fields/RadioGroup → RadioGroup}/RadioGroup.stories.js +3 -1
- package/dist/components/elements/{Fields/RadioGroup → RadioGroup}/RadioGroup.test.js +1 -1
- package/dist/components/elements/{Fields/RadioGroup → RadioGroup}/index.d.ts +1 -1
- package/dist/components/elements/{Fields/RadioGroup → RadioGroup}/index.js +6 -6
- package/dist/components/elements/{text/ReadMore → ReadMore}/ReadMore.stories.js +5 -3
- package/dist/components/elements/ReadMore/ReadMore.test.d.ts +1 -0
- package/dist/components/elements/{text/ReadMore → ReadMore}/ReadMore.test.js +4 -9
- package/dist/components/elements/{text/ReadMore → ReadMore}/index.d.ts +2 -2
- package/dist/components/elements/{text/ReadMore → ReadMore}/index.js +10 -9
- package/dist/components/elements/ReadMoreV2/ReadMoreV2.module.css +19 -0
- package/dist/components/elements/ReadMoreV2/ReadMoreV2.stories.d.ts +8 -0
- package/dist/components/elements/ReadMoreV2/ReadMoreV2.stories.js +28 -0
- package/dist/components/elements/ReadMoreV2/ReadMoreV2.test.d.ts +1 -0
- package/dist/components/elements/ReadMoreV2/ReadMoreV2.test.js +30 -0
- package/dist/components/elements/ReadMoreV2/index.d.ts +13 -0
- package/dist/components/elements/ReadMoreV2/index.js +82 -0
- package/dist/components/elements/{Fields/Select → Select}/Select.stories.js +6 -4
- package/dist/components/elements/Select/Select.test.d.ts +1 -0
- package/dist/components/elements/{Fields/Select → Select}/Select.test.js +1 -1
- package/dist/components/elements/{Fields/Select → Select}/index.d.ts +1 -1
- package/dist/components/elements/{Fields/Select → Select}/index.js +9 -9
- package/dist/components/elements/SelectV2/SelectV2.module.css +27 -0
- package/dist/components/elements/SelectV2/SelectV2.stories.d.ts +8 -0
- package/dist/components/elements/SelectV2/SelectV2.stories.js +41 -0
- package/dist/components/elements/SelectV2/SelectV2.test.d.ts +1 -0
- package/dist/components/elements/SelectV2/SelectV2.test.js +52 -0
- package/dist/components/elements/SelectV2/index.d.ts +19 -0
- package/dist/components/elements/SelectV2/index.js +164 -0
- package/dist/components/elements/Spinner/Spinner.stories.js +2 -0
- package/dist/components/elements/Spinner/index.js +1 -1
- package/dist/components/elements/SpinnerV2/SpinnerV2.module.css +12 -0
- package/dist/components/elements/SpinnerV2/SpinnerV2.stories.d.ts +7 -0
- package/dist/components/elements/SpinnerV2/SpinnerV2.stories.js +29 -0
- package/dist/components/elements/SpinnerV2/SpinnerV2.test.d.ts +1 -0
- package/dist/components/elements/SpinnerV2/SpinnerV2.test.js +9 -0
- package/dist/components/elements/SpinnerV2/index.d.ts +15 -0
- package/dist/components/elements/SpinnerV2/index.js +36 -0
- package/dist/components/elements/TabList/TabList.stories.js +2 -0
- package/dist/components/elements/Table/Table.stories.js +2 -0
- package/dist/components/elements/{Fields/TextInput → TextInput}/TextInput.stories.js +6 -4
- package/dist/components/elements/TextInput/TextInput.test.d.ts +1 -0
- package/dist/components/elements/{Fields/TextInput → TextInput}/TextInput.test.js +2 -2
- package/dist/components/elements/{Fields/TextInput → TextInput}/index.d.ts +3 -3
- package/dist/components/elements/{Fields/TextInput → TextInput}/index.js +9 -8
- package/dist/components/elements/TextInputV2/TextInputV2.module.css +71 -0
- package/dist/components/elements/TextInputV2/TextInputV2.stories.d.ts +9 -0
- package/dist/components/elements/TextInputV2/TextInputV2.stories.js +37 -0
- package/dist/components/elements/TextInputV2/TextInputV2.test.d.ts +1 -0
- package/dist/components/elements/TextInputV2/TextInputV2.test.js +59 -0
- package/dist/components/elements/TextInputV2/index.d.ts +47 -0
- package/dist/components/elements/TextInputV2/index.js +98 -0
- package/dist/components/elements/layout/Box.stories.js +2 -0
- package/dist/components/elements/layout/Flex.stories.js +3 -1
- package/dist/components/elements/layoutV2/BoxV2.d.ts +9 -0
- package/dist/components/elements/layoutV2/BoxV2.js +19 -0
- package/dist/components/elements/layoutV2/BoxV2.stories.d.ts +6 -0
- package/dist/components/elements/layoutV2/BoxV2.stories.js +14 -0
- package/dist/components/elements/layoutV2/ColumnV2.d.ts +8 -0
- package/dist/components/elements/layoutV2/ColumnV2.js +21 -0
- package/dist/components/elements/layoutV2/RowV2.d.ts +19 -0
- package/dist/components/elements/layoutV2/RowV2.js +54 -0
- package/dist/components/providers/alerts.js +0 -1
- package/dist/components/providers/alerts.test.d.ts +1 -0
- package/dist/components/providers/alerts.test.js +115 -0
- package/dist/components/providers/componentConfigV2.d.ts +25 -0
- package/dist/components/providers/componentConfigV2.js +37 -0
- package/dist/components/providers/media.js +1 -1
- package/dist/components/providers/mediaV2.d.ts +11 -0
- package/dist/components/providers/mediaV2.js +48 -0
- package/dist/components/providers/uiV2.d.ts +20 -0
- package/dist/components/providers/uiV2.js +16 -0
- package/dist/index.d.ts +34 -14
- package/dist/index.html +14 -0
- package/dist/index.js +33 -13
- package/dist/theme/Color.stories.js +3 -1
- package/dist/theme/GlobalStylesV2.d.ts +2 -0
- package/dist/theme/GlobalStylesV2.js +212 -0
- package/dist/theme/Typography.stories.js +3 -1
- package/dist/theme/css-variables.css +57 -0
- package/dist/theme/index.d.ts +127 -1
- package/dist/theme/index.js +14 -0
- package/dist/theme/typography.js +2 -2
- package/dist/utils/decorators/UIVersion1.d.ts +2 -0
- package/dist/utils/decorators/UIVersion1.js +7 -0
- package/dist/utils/decorators/UIVersion2.d.ts +2 -0
- package/dist/utils/decorators/UIVersion2.js +7 -0
- package/dist/utils/hooks/useFocus.d.ts +7 -0
- package/dist/utils/hooks/useFocus.js +12 -0
- package/dist/utils/processSx.d.ts +3 -0
- package/dist/utils/processSx.js +135 -0
- package/package.json +8 -4
- /package/dist/components/{elements/Fields/Checkbox/Checkbox.test.d.ts → composites/CardV2/CardV2.test.d.ts} +0 -0
- /package/dist/components/{elements/Fields/CheckboxGroup/CheckboxGroup.test.d.ts → composites/ModalV2/ModalV2.test.d.ts} +0 -0
- /package/dist/components/elements/{Fields/AutoComplete → AutoComplete}/AutoComplete.stories.d.ts +0 -0
- /package/dist/components/elements/{Fields/AutoComplete → AutoComplete}/AutoComplete.test.d.ts +0 -0
- /package/dist/components/elements/{Fields/AutoComplete → AutoComplete}/index.d.ts +0 -0
- /package/dist/components/elements/{Fields/DatePicker/DatePicker.test.d.ts → ButtonV2/ButtonV2.test.d.ts} +0 -0
- /package/dist/components/elements/{text/Caption → Caption}/index.d.ts +0 -0
- /package/dist/components/elements/{text/Caption → Caption}/index.js +0 -0
- /package/dist/components/elements/{Fields/Checkbox → Checkbox}/Checkbox.stories.d.ts +0 -0
- /package/dist/components/elements/{Fields/MonthPicker/MonthPicker.test.d.ts → Checkbox/Checkbox.test.d.ts} +0 -0
- /package/dist/components/elements/{Fields/CheckboxGroup → CheckboxGroup}/CheckboxGroup.stories.d.ts +0 -0
- /package/dist/components/elements/{Fields/Radio/Radio.test.d.ts → CheckboxGroup/CheckboxGroup.test.d.ts} +0 -0
- /package/dist/components/elements/{Fields/Select/Select.test.d.ts → CheckboxGroupV2/CheckboxGroupV2.test.d.ts} +0 -0
- /package/dist/components/elements/{text/Heading/Heading.test.d.ts → CheckboxV2/CheckboxV2.test.d.ts} +0 -0
- /package/dist/components/elements/{Fields/DatePicker → DatePicker}/DatePicker.stories.d.ts +0 -0
- /package/dist/components/elements/{text/Label/Label.test.d.ts → DatePicker/DatePicker.test.d.ts} +0 -0
- /package/dist/components/elements/{text/Heading → Heading}/Heading.stories.d.ts +0 -0
- /package/dist/components/elements/{text/Paragraph/Paragraph.test.d.ts → Heading/Heading.test.d.ts} +0 -0
- /package/dist/components/elements/{text/ReadMore/ReadMore.test.d.ts → HeadingV2/HeadingV2.test.d.ts} +0 -0
- /package/dist/components/elements/{Fields/RadioGroup/RadioGroup.test.d.ts → IconV2/IconV2.test.d.ts} +0 -0
- /package/dist/components/elements/{text/Inline → Inline}/Inline.stories.d.ts +0 -0
- /package/dist/components/elements/{text/Label → Label}/Label.stories.d.ts +0 -0
- /package/dist/components/elements/{Fields/MonthPicker → MonthPicker}/MonthPicker.stories.d.ts +0 -0
- /package/dist/components/elements/{text/Paragraph → Paragraph}/Paragraph.stories.d.ts +0 -0
- /package/dist/components/elements/{Fields/Radio → Radio}/Radio.stories.d.ts +0 -0
- /package/dist/components/elements/{Fields/RadioGroup → RadioGroup}/RadioGroup.stories.d.ts +0 -0
- /package/dist/components/elements/{Fields/TextInput/TextInput.test.d.ts → RadioGroup/RadioGroup.test.d.ts} +0 -0
- /package/dist/components/elements/{text/ReadMore → ReadMore}/ReadMore.stories.d.ts +0 -0
- /package/dist/components/elements/{Fields/Select → Select}/Select.stories.d.ts +0 -0
- /package/dist/components/elements/{Fields/TextInput → TextInput}/TextInput.stories.d.ts +0 -0
- /package/dist/components/elements/{Fields/option.d.ts → option.d.ts} +0 -0
- /package/dist/components/elements/{Fields/option.js → option.js} +0 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
.fieldset {
|
|
2
|
+
text-align: left;
|
|
3
|
+
position: absolute;
|
|
4
|
+
inset: -4px 0 0 0;
|
|
5
|
+
margin: 0;
|
|
6
|
+
padding: 0 0.5rem;
|
|
7
|
+
pointer-events: none;
|
|
8
|
+
border-radius: inherit;
|
|
9
|
+
border-style: solid;
|
|
10
|
+
border-width: 1px;
|
|
11
|
+
overflow: hidden;
|
|
12
|
+
min-width: 0%;
|
|
13
|
+
z-index: 2;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.legend {
|
|
17
|
+
width: auto;
|
|
18
|
+
float: unset;
|
|
19
|
+
overflow: hidden;
|
|
20
|
+
position: relative;
|
|
21
|
+
display: block;
|
|
22
|
+
padding: 0;
|
|
23
|
+
height: 8px;
|
|
24
|
+
font-size: 0.75em;
|
|
25
|
+
visibility: hidden;
|
|
26
|
+
white-space: nowrap;
|
|
27
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { SelectV2 } from '.';
|
|
3
|
+
declare const meta: Meta<typeof SelectV2>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof SelectV2>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const WithLabel: Story;
|
|
8
|
+
export declare const InvertedColors: Story;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import AppleIcon from '@mui/icons-material/Apple';
|
|
3
|
+
import { INPUTV2_SIZE } from '../TextInputV2';
|
|
4
|
+
import { SelectV2 } from '.';
|
|
5
|
+
import { useState } from 'react';
|
|
6
|
+
import { ColumnV2 } from '../layoutV2/ColumnV2';
|
|
7
|
+
import { GroupV2 } from '../GroupV2';
|
|
8
|
+
import { HeadingV2, HEADINGV2_SIZE } from '../HeadingV2';
|
|
9
|
+
import { COLOR } from '../../../theme/colors';
|
|
10
|
+
import { UIVersion2 } from '../../../utils/decorators/UIVersion2';
|
|
11
|
+
const meta = {
|
|
12
|
+
title: 'Elements/Fields/SelectV2',
|
|
13
|
+
component: SelectV2,
|
|
14
|
+
tags: ['autodocs'],
|
|
15
|
+
decorators: [UIVersion2],
|
|
16
|
+
};
|
|
17
|
+
export default meta;
|
|
18
|
+
const sizes = [
|
|
19
|
+
{ label: 'Large', size: INPUTV2_SIZE.LG },
|
|
20
|
+
{ label: 'Medium', size: INPUTV2_SIZE.MD },
|
|
21
|
+
{ label: 'Small', size: INPUTV2_SIZE.SM },
|
|
22
|
+
];
|
|
23
|
+
const options = [
|
|
24
|
+
{ value: 'orange', label: 'Orange' },
|
|
25
|
+
{ value: 'apple', label: 'Apple' },
|
|
26
|
+
{ value: 'strawberry', label: 'Strawberry' },
|
|
27
|
+
{ value: 'pineapple', label: 'Pineapple' },
|
|
28
|
+
];
|
|
29
|
+
const StatefulSelect = (props) => {
|
|
30
|
+
const [value, setValue] = useState('');
|
|
31
|
+
return (_jsx(SelectV2, Object.assign({ options: options }, props, { value: value, onSelectOption: setValue, placeholder: "Select A Fruit..." })));
|
|
32
|
+
};
|
|
33
|
+
export const Default = {
|
|
34
|
+
render: () => (_jsx(ColumnV2, { children: sizes.map((size) => (_jsxs(GroupV2, { children: [_jsx(HeadingV2, Object.assign({ size: HEADINGV2_SIZE.MD }, { children: size.label })), _jsx(StatefulSelect, { size: size.size, leftIcon: AppleIcon, sx: { mt: 2 } })] }))) })),
|
|
35
|
+
};
|
|
36
|
+
export const WithLabel = {
|
|
37
|
+
render: () => (_jsx(ColumnV2, { children: sizes.map((size) => (_jsxs(GroupV2, { children: [_jsx(HeadingV2, Object.assign({ size: HEADINGV2_SIZE.MD }, { children: size.label })), _jsx(StatefulSelect, { size: size.size, leftIcon: AppleIcon, sx: { mt: 2 }, label: "Fruit" })] }))) })),
|
|
38
|
+
};
|
|
39
|
+
export const InvertedColors = {
|
|
40
|
+
render: () => (_jsx(ColumnV2, Object.assign({ sx: { backgroundColor: COLOR.BLACK, p: 4 } }, { children: sizes.map((size) => (_jsxs(GroupV2, { children: [_jsx(HeadingV2, Object.assign({ size: HEADINGV2_SIZE.MD, sx: { color: COLOR.WHITE } }, { children: size.label })), _jsx(StatefulSelect, { inverted: true, size: size.size, leftIcon: AppleIcon, sx: { mt: 2 }, label: "Fruit" })] }))) }))),
|
|
41
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { render, screen, fireEvent } from '@testing-library/react';
|
|
3
|
+
import { describe, it, expect, vi } from 'vitest';
|
|
4
|
+
import { SelectV2 } from '.';
|
|
5
|
+
describe('SelectV2', () => {
|
|
6
|
+
const options = [
|
|
7
|
+
{ value: 'option1', label: 'Option 1' },
|
|
8
|
+
{ value: 'option2', label: 'Option 2' },
|
|
9
|
+
{ value: 'option3', label: 'Option 3' },
|
|
10
|
+
];
|
|
11
|
+
const onSelectOption = vi.fn();
|
|
12
|
+
it('renders placeholder when no value is selected', () => {
|
|
13
|
+
render(_jsx(SelectV2, { options: options, value: "", placeholder: "Select an option", onSelectOption: onSelectOption }));
|
|
14
|
+
expect(screen.getByRole('combobox')).toHaveTextContent('Select an option');
|
|
15
|
+
});
|
|
16
|
+
it('renders the selected value', () => {
|
|
17
|
+
render(_jsx(SelectV2, { options: options, value: "option2", onSelectOption: onSelectOption }));
|
|
18
|
+
expect(screen.getByRole('combobox')).toHaveTextContent('Option 2');
|
|
19
|
+
});
|
|
20
|
+
it('opens the dropdown on click and displays options', () => {
|
|
21
|
+
render(_jsx(SelectV2, { options: options, value: "", onSelectOption: onSelectOption }));
|
|
22
|
+
const combobox = screen.getByRole('combobox');
|
|
23
|
+
fireEvent.mouseDown(combobox);
|
|
24
|
+
options.forEach((option) => {
|
|
25
|
+
expect(screen.getByText(option.label)).toBeInTheDocument();
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
it('calls onSelectOption with correct value on option click', () => {
|
|
29
|
+
render(_jsx(SelectV2, { options: options, value: "", onSelectOption: onSelectOption }));
|
|
30
|
+
const combobox = screen.getByRole('combobox');
|
|
31
|
+
fireEvent.mouseDown(combobox);
|
|
32
|
+
const option = screen.getByText('Option 1');
|
|
33
|
+
fireEvent.mouseDown(option);
|
|
34
|
+
expect(onSelectOption).toHaveBeenCalledWith('option1');
|
|
35
|
+
});
|
|
36
|
+
it('handles keyboard navigation and selection', () => {
|
|
37
|
+
render(_jsx(SelectV2, { options: options, value: "", onSelectOption: onSelectOption }));
|
|
38
|
+
const combobox = screen.getByRole('combobox');
|
|
39
|
+
fireEvent.focus(combobox);
|
|
40
|
+
fireEvent.keyDown(combobox, { key: 'ArrowDown' });
|
|
41
|
+
fireEvent.keyDown(combobox, { key: 'Enter' });
|
|
42
|
+
expect(onSelectOption).toHaveBeenCalledWith('option2');
|
|
43
|
+
});
|
|
44
|
+
it('closes the dropdown on blur', () => {
|
|
45
|
+
render(_jsx(SelectV2, { options: options, value: "", onSelectOption: onSelectOption }));
|
|
46
|
+
const combobox = screen.getByRole('combobox');
|
|
47
|
+
fireEvent.mouseDown(combobox);
|
|
48
|
+
expect(screen.getByText('Option 1')).toBeInTheDocument();
|
|
49
|
+
fireEvent.blur(combobox);
|
|
50
|
+
expect(screen.queryByText('Option 1')).not.toBeInTheDocument();
|
|
51
|
+
});
|
|
52
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StyledElementPropsV2 } from '../../../theme';
|
|
3
|
+
import { INPUTV2_SIZE } from '../TextInputV2';
|
|
4
|
+
import { BasicOption, Key, RenderOption, RenderOptionLabel } from '../option';
|
|
5
|
+
type SelectV2Props<Value extends Key, Option extends BasicOption<Value>> = StyledElementPropsV2<HTMLSelectElement, {
|
|
6
|
+
placeholder?: string;
|
|
7
|
+
size?: INPUTV2_SIZE;
|
|
8
|
+
leftIcon?: React.FC<any>;
|
|
9
|
+
value: Value;
|
|
10
|
+
label?: string;
|
|
11
|
+
inverted?: boolean;
|
|
12
|
+
onSelectOption: (value: Value) => void;
|
|
13
|
+
options: Option[];
|
|
14
|
+
renderOption?: RenderOption<Value, Option>;
|
|
15
|
+
renderOptionLabel?: RenderOptionLabel<Option>;
|
|
16
|
+
className?: string;
|
|
17
|
+
}, string>;
|
|
18
|
+
export declare function SelectV2<Value extends Key, Option extends BasicOption<Value>>({ size: sizeParam, placeholder, leftIcon, value, label, onSelectOption, options, renderOption, inverted, renderOptionLabel: renderOptionLabelParam, className, sx, }: SelectV2Props<Value, Option>): import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo, useState } from 'react';
|
|
3
|
+
import _ArrowDropDownIcon from '@mui/icons-material/ArrowDropDown';
|
|
4
|
+
import { useFloating, size as sizeMiddleware, offset, autoPlacement, } from '@floating-ui/react';
|
|
5
|
+
import { TYPOGRAPHY_TYPE, getTypographyStyles } from '../../../theme/typography';
|
|
6
|
+
import { INPUTV2_SIZE, labelOffsetMapV2, labelTypographyMapV2, } from '../TextInputV2';
|
|
7
|
+
import { ListBoxV2 } from '../ListBoxV2';
|
|
8
|
+
import { BUTTONV2_SIZE, BUTTONV2_TYPE, ButtonV2 } from '../ButtonV2';
|
|
9
|
+
import { defaultRenderOptionLabel, getOptionId, } from '../option';
|
|
10
|
+
import { KEY_CODES, importedDefaultComponentShim } from '../../../utils/misc';
|
|
11
|
+
import { COLOR } from '../../../theme/colors';
|
|
12
|
+
import { BoxV2 } from '../layoutV2/BoxV2';
|
|
13
|
+
import { LabelV2 } from '../LabelV2';
|
|
14
|
+
import { useUniqueId } from '../../providers/uniqueIds';
|
|
15
|
+
import { BOX_SHADOW, Z_INDEX } from '../../../theme/custom';
|
|
16
|
+
import { useHover } from '../../../utils/hooks/useHover';
|
|
17
|
+
import { useFocus } from '../../../utils/hooks/useFocus';
|
|
18
|
+
import { processSx } from '../../../utils/processSx';
|
|
19
|
+
import * as styles from './SelectV2.module.css';
|
|
20
|
+
const ArrowDropDownIcon = importedDefaultComponentShim(_ArrowDropDownIcon);
|
|
21
|
+
const typographyMap = {
|
|
22
|
+
[INPUTV2_SIZE.SM]: TYPOGRAPHY_TYPE.PARAGRAPH_SMALL,
|
|
23
|
+
[INPUTV2_SIZE.MD]: TYPOGRAPHY_TYPE.PARAGRAPH_MEDIUM,
|
|
24
|
+
[INPUTV2_SIZE.LG]: TYPOGRAPHY_TYPE.PARAGRAPH_LARGE,
|
|
25
|
+
};
|
|
26
|
+
const defaultHeight = {
|
|
27
|
+
[INPUTV2_SIZE.SM]: '2.25rem',
|
|
28
|
+
[INPUTV2_SIZE.MD]: '2.5rem',
|
|
29
|
+
[INPUTV2_SIZE.LG]: '3rem',
|
|
30
|
+
};
|
|
31
|
+
const buttonSizeMap = {
|
|
32
|
+
[INPUTV2_SIZE.SM]: BUTTONV2_SIZE.SM,
|
|
33
|
+
[INPUTV2_SIZE.MD]: BUTTONV2_SIZE.MD,
|
|
34
|
+
[INPUTV2_SIZE.LG]: BUTTONV2_SIZE.LG,
|
|
35
|
+
};
|
|
36
|
+
const DEFAULT_WIDTH = '16rem';
|
|
37
|
+
const typeSafeStyles = styles;
|
|
38
|
+
export function SelectV2({ size: sizeParam, placeholder, leftIcon, value, label, onSelectOption, options, renderOption, inverted, renderOptionLabel: renderOptionLabelParam, className, sx, }) {
|
|
39
|
+
const listboxId = useUniqueId('select-list-box');
|
|
40
|
+
const inputId = useUniqueId('select-input');
|
|
41
|
+
const { isHovered, anchorElementProps } = useHover();
|
|
42
|
+
const { isFocused } = useFocus();
|
|
43
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
44
|
+
const [stagedOptionValue, setStagedOptionValue] = useState();
|
|
45
|
+
const currentOption = useMemo(() => {
|
|
46
|
+
return options.find((option) => option.value === value);
|
|
47
|
+
}, [options, value]);
|
|
48
|
+
const getNextOptionValue = () => {
|
|
49
|
+
if (stagedOptionValue) {
|
|
50
|
+
const currentIndex = options
|
|
51
|
+
.map((option) => option.value)
|
|
52
|
+
.indexOf(stagedOptionValue);
|
|
53
|
+
const nextIndex = Math.min(currentIndex + 1, options.length - 1);
|
|
54
|
+
return options[nextIndex].value;
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
setIsOpen(true);
|
|
58
|
+
return options[0].value;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
const getPrevOptionValue = () => {
|
|
62
|
+
if (stagedOptionValue) {
|
|
63
|
+
const currentIndex = options
|
|
64
|
+
.map((option) => option.value)
|
|
65
|
+
.indexOf(stagedOptionValue);
|
|
66
|
+
const nextIndex = Math.max(currentIndex - 1, 0);
|
|
67
|
+
return options[nextIndex].value;
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
setIsOpen(true);
|
|
71
|
+
return options[options.length - 1].value;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
const [dropdownMinWidth, setDropdownMinWidth] = useState('0px');
|
|
75
|
+
const { refs, floatingStyles } = useFloating({
|
|
76
|
+
placement: 'bottom-start',
|
|
77
|
+
middleware: [
|
|
78
|
+
offset(2),
|
|
79
|
+
sizeMiddleware({
|
|
80
|
+
apply({ rects }) {
|
|
81
|
+
setDropdownMinWidth(`${rects.reference.width}px`);
|
|
82
|
+
},
|
|
83
|
+
}),
|
|
84
|
+
autoPlacement({
|
|
85
|
+
allowedPlacements: ['top-start', 'bottom-start'],
|
|
86
|
+
}),
|
|
87
|
+
],
|
|
88
|
+
});
|
|
89
|
+
const close = () => {
|
|
90
|
+
setStagedOptionValue(undefined);
|
|
91
|
+
setIsOpen(false);
|
|
92
|
+
};
|
|
93
|
+
const open = () => {
|
|
94
|
+
setStagedOptionValue(stagedOptionValue || value || options[0].value);
|
|
95
|
+
setIsOpen(true);
|
|
96
|
+
};
|
|
97
|
+
const onKeyDown = (e) => {
|
|
98
|
+
if (e.key === KEY_CODES.ARROW_DOWN) {
|
|
99
|
+
const nextValue = getNextOptionValue();
|
|
100
|
+
setStagedOptionValue(nextValue);
|
|
101
|
+
}
|
|
102
|
+
if (e.key === KEY_CODES.ARROW_UP) {
|
|
103
|
+
const prevValue = getPrevOptionValue();
|
|
104
|
+
setStagedOptionValue(prevValue);
|
|
105
|
+
}
|
|
106
|
+
if (e.key === KEY_CODES.ENTER) {
|
|
107
|
+
if (!isOpen) {
|
|
108
|
+
open();
|
|
109
|
+
}
|
|
110
|
+
if (isOpen && stagedOptionValue && onSelectOption) {
|
|
111
|
+
onSelectOption(stagedOptionValue);
|
|
112
|
+
close();
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
if (e.key === KEY_CODES.ESCAPE) {
|
|
116
|
+
close();
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
const size = sizeParam || INPUTV2_SIZE.MD;
|
|
120
|
+
const buttonSize = buttonSizeMap[size];
|
|
121
|
+
const height = defaultHeight[size];
|
|
122
|
+
const typography = typographyMap[size];
|
|
123
|
+
const typographyStyles = getTypographyStyles(typography);
|
|
124
|
+
const renderOptionLabel = renderOptionLabelParam || defaultRenderOptionLabel;
|
|
125
|
+
const focusStyles = {
|
|
126
|
+
boxShadow: inverted ? BOX_SHADOW.INVERTED : BOX_SHADOW.NORMAL,
|
|
127
|
+
};
|
|
128
|
+
const appliedHoverStyles = isHovered ? focusStyles : {};
|
|
129
|
+
const appliedFocusStyles = isFocused ? focusStyles : {};
|
|
130
|
+
const fieldsetBorderColor = processSx({
|
|
131
|
+
borderColor: inverted ? COLOR.WHITE : COLOR.LIGHT_GRAY,
|
|
132
|
+
});
|
|
133
|
+
return (_jsxs(BoxV2, Object.assign({}, anchorElementProps, { className: className, sx: Object.assign(Object.assign(Object.assign({ width: DEFAULT_WIDTH, position: 'relative', borderRadius: '4px', backgroundColor: inverted ? COLOR.DARK_GRAY : COLOR.WHITE }, appliedHoverStyles), appliedFocusStyles), sx) }, { children: [_jsx("fieldset", Object.assign({ className: typeSafeStyles.fieldset, style: Object.assign({}, fieldsetBorderColor) }, { children: _jsx("legend", Object.assign({ className: typeSafeStyles.legend }, { children: label && (_jsx(LabelV2, Object.assign({ standalone: true, sx: {
|
|
134
|
+
px: 1,
|
|
135
|
+
position: 'relative',
|
|
136
|
+
display: 'inline-flex',
|
|
137
|
+
opacity: '0',
|
|
138
|
+
visibility: 'hidden',
|
|
139
|
+
}, typography: labelTypographyMapV2[size] }, { children: label }))) })) })), _jsx(LabelV2, Object.assign({ id: inputId, typography: labelTypographyMapV2[size], sx: {
|
|
140
|
+
position: 'absolute',
|
|
141
|
+
left: '0.5rem',
|
|
142
|
+
lineHeight: 1,
|
|
143
|
+
zIndex: Z_INDEX.ELEVATED,
|
|
144
|
+
color: inverted ? COLOR.WHITE : COLOR.PRIMARY,
|
|
145
|
+
px: 1,
|
|
146
|
+
top: labelOffsetMapV2[size],
|
|
147
|
+
} }, { children: label })), _jsx(ButtonV2, Object.assign({ ref: refs.setReference, disableFocusStyles: true, role: "combobox", "aria-controls": listboxId, "aria-expanded": isOpen, "aria-labelledby": inputId, "aria-autocomplete": "none", "aria-activedescendant": isOpen && stagedOptionValue
|
|
148
|
+
? getOptionId(stagedOptionValue)
|
|
149
|
+
: undefined, type: BUTTONV2_TYPE.OUTLINE, size: buttonSize, onBlur: () => close(), onFocus: () => open(), onKeyDown: onKeyDown, onMouseDown: () => {
|
|
150
|
+
if (!isOpen) {
|
|
151
|
+
open();
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
close();
|
|
155
|
+
}
|
|
156
|
+
}, color: inverted ? COLOR.WHITE : COLOR.TEXT, sx: Object.assign({ height, width: '100%', border: 'solid 0px', flexDirection: 'row', alignItems: 'center', position: 'relative', zIndex: Z_INDEX.NORMAL, background: 'none' }, typographyStyles), leftIcon: leftIcon, rightIcon: ArrowDropDownIcon }, { children: currentOption ? renderOptionLabel(currentOption) : placeholder })), isOpen && (_jsx(ListBoxV2, { id: listboxId, options: options, selected: value, focused: stagedOptionValue, selectOption: (option) => {
|
|
157
|
+
onSelectOption && onSelectOption(option.value);
|
|
158
|
+
close();
|
|
159
|
+
}, ref: refs.setFloating, renderOption: renderOption, sx: {
|
|
160
|
+
zIndex: Z_INDEX.DIALOG,
|
|
161
|
+
minWidth: dropdownMinWidth,
|
|
162
|
+
boxShadow: inverted ? BOX_SHADOW.INVERTED : BOX_SHADOW.NORMAL,
|
|
163
|
+
}, style: Object.assign({}, floatingStyles) }))] })));
|
|
164
|
+
}
|
|
@@ -3,10 +3,12 @@ import { Column, Group, HEADING_SIZE, Heading } from '../../..';
|
|
|
3
3
|
import { SPINNER_SIZE, Spinner } from '.';
|
|
4
4
|
import { GROUP_TYPE } from '../Group';
|
|
5
5
|
import { COLOR } from '../../../theme/colors';
|
|
6
|
+
import { UIVersion1 } from '../../../utils/decorators/UIVersion1';
|
|
6
7
|
const meta = {
|
|
7
8
|
title: 'Elements/Spinner',
|
|
8
9
|
component: Spinner,
|
|
9
10
|
tags: ['autodocs'],
|
|
11
|
+
decorators: [UIVersion1],
|
|
10
12
|
};
|
|
11
13
|
export default meta;
|
|
12
14
|
const sizes = [
|
|
@@ -37,7 +37,7 @@ export const Spinner = (_a) => {
|
|
|
37
37
|
var { size: sizeParam, color: colorParam } = _a, rest = __rest(_a, ["size", "color"]);
|
|
38
38
|
const { colors } = useTheme();
|
|
39
39
|
const size = sizeParam || SPINNER_SIZE.MD;
|
|
40
|
-
const color = colors[colorParam || COLOR.PRIMARY];
|
|
40
|
+
const color = colors === null || colors === void 0 ? void 0 : colors[colorParam || COLOR.PRIMARY];
|
|
41
41
|
return (_jsx("div", Object.assign({ "aria-label": SPINNER_LABEL, sx: {
|
|
42
42
|
animation: `${spin} 1.4s linear 0s infinite normal none running;`,
|
|
43
43
|
borderRadius: '50%',
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { SpinnerV2 } from '.';
|
|
3
|
+
declare const meta: Meta<typeof SpinnerV2>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof SpinnerV2>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const CustomColor: Story;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ColumnV2 } from '../layoutV2/ColumnV2';
|
|
3
|
+
import { GROUPV2_TYPE, GroupV2 } from '../GroupV2';
|
|
4
|
+
import { HEADINGV2_SIZE, HeadingV2 } from '../HeadingV2';
|
|
5
|
+
import { SPINNERV2_SIZE, SpinnerV2 } from '.';
|
|
6
|
+
import { COLOR } from '../../../theme/colors';
|
|
7
|
+
import { UIVersion2 } from '../../../utils/decorators/UIVersion2';
|
|
8
|
+
const meta = {
|
|
9
|
+
title: 'Elements/SpinnerV2',
|
|
10
|
+
component: SpinnerV2,
|
|
11
|
+
tags: ['autodocs'],
|
|
12
|
+
decorators: [UIVersion2],
|
|
13
|
+
};
|
|
14
|
+
export default meta;
|
|
15
|
+
const sizes = [
|
|
16
|
+
{ size: SPINNERV2_SIZE.LG, label: 'Large' },
|
|
17
|
+
{ size: SPINNERV2_SIZE.MD, label: 'Medium' },
|
|
18
|
+
{ size: SPINNERV2_SIZE.SM, label: 'Small' },
|
|
19
|
+
];
|
|
20
|
+
export const Default = {
|
|
21
|
+
render: () => (_jsx(ColumnV2, { children: sizes.map((size) => (_jsxs(GroupV2, Object.assign({ type: GROUPV2_TYPE.REGION }, { children: [_jsx(HeadingV2, Object.assign({ size: HEADINGV2_SIZE.SM }, { children: size.label })), _jsx(SpinnerV2, { size: size.size })] })))) })),
|
|
22
|
+
args: {},
|
|
23
|
+
};
|
|
24
|
+
export const CustomColor = {
|
|
25
|
+
render: () => (_jsx(ColumnV2, { children: _jsx(SpinnerV2, { color: COLOR.SECONDARY }) })),
|
|
26
|
+
args: {
|
|
27
|
+
children: 'Heading',
|
|
28
|
+
},
|
|
29
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { render } from '../../../utils/test';
|
|
3
|
+
import { SPINNERV2_LABEL, SpinnerV2 } from '.';
|
|
4
|
+
describe('Button', () => {
|
|
5
|
+
it('renders without throwing an error', () => {
|
|
6
|
+
const { getByLabelText } = render(_jsx(SpinnerV2, {}));
|
|
7
|
+
expect(getByLabelText(SPINNERV2_LABEL)).toBeInTheDocument();
|
|
8
|
+
});
|
|
9
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { StyledElementPropsV2 } from '../../../theme';
|
|
3
|
+
import { COLOR } from '../../../theme/colors';
|
|
4
|
+
export declare enum SPINNERV2_SIZE {
|
|
5
|
+
SM = "sm",
|
|
6
|
+
MD = "md",
|
|
7
|
+
LG = "lg"
|
|
8
|
+
}
|
|
9
|
+
export type SpinnerV2Props = StyledElementPropsV2<HTMLDivElement, {
|
|
10
|
+
size?: SPINNERV2_SIZE;
|
|
11
|
+
color?: COLOR;
|
|
12
|
+
className?: string;
|
|
13
|
+
}>;
|
|
14
|
+
export declare const SPINNERV2_LABEL = "Loading";
|
|
15
|
+
export declare const SpinnerV2: React.FC<SpinnerV2Props>;
|
|
@@ -0,0 +1,36 @@
|
|
|
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 "react/jsx-runtime";
|
|
13
|
+
import { COLOR, colors } from '../../../theme/colors';
|
|
14
|
+
import { processSx } from '../../../utils/processSx';
|
|
15
|
+
import * as styles from './SpinnerV2.module.css';
|
|
16
|
+
import clsx from 'clsx';
|
|
17
|
+
export var SPINNERV2_SIZE;
|
|
18
|
+
(function (SPINNERV2_SIZE) {
|
|
19
|
+
SPINNERV2_SIZE["SM"] = "sm";
|
|
20
|
+
SPINNERV2_SIZE["MD"] = "md";
|
|
21
|
+
SPINNERV2_SIZE["LG"] = "lg";
|
|
22
|
+
})(SPINNERV2_SIZE || (SPINNERV2_SIZE = {}));
|
|
23
|
+
const sizeLengthMap = {
|
|
24
|
+
[SPINNERV2_SIZE.SM]: '0.75rem',
|
|
25
|
+
[SPINNERV2_SIZE.MD]: '1.5rem',
|
|
26
|
+
[SPINNERV2_SIZE.LG]: '2.25rem',
|
|
27
|
+
};
|
|
28
|
+
export const SPINNERV2_LABEL = 'Loading';
|
|
29
|
+
const typeSafeStyles = styles;
|
|
30
|
+
export const SpinnerV2 = (_a) => {
|
|
31
|
+
var { size: sizeParam, color: colorParam, className, sx } = _a, rest = __rest(_a, ["size", "color", "className", "sx"]);
|
|
32
|
+
const size = sizeParam || SPINNERV2_SIZE.MD;
|
|
33
|
+
const color = colors[colorParam || COLOR.PRIMARY];
|
|
34
|
+
const processedStyles = processSx(sx);
|
|
35
|
+
return (_jsx("div", Object.assign({ "aria-label": SPINNERV2_LABEL, className: clsx(typeSafeStyles.spinner, className), style: Object.assign(Object.assign({}, processedStyles), { height: `${sizeLengthMap[size]}`, width: `${sizeLengthMap[size]}`, borderWidth: `${size === SPINNERV2_SIZE.LG ? '6px' : '4px'}`, borderStyle: 'solid', borderRadius: '50%', borderColor: `${color} ${color} transparent` }) }, rest)));
|
|
36
|
+
};
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { TabList } from './index';
|
|
3
3
|
import { ExampleTabs } from './example';
|
|
4
|
+
import { UIVersion1 } from '../../../utils/decorators/UIVersion1';
|
|
4
5
|
const meta = {
|
|
5
6
|
title: 'Elements/TabList',
|
|
6
7
|
component: TabList,
|
|
7
8
|
tags: ['autodocs'],
|
|
9
|
+
decorators: [UIVersion1],
|
|
8
10
|
};
|
|
9
11
|
export default meta;
|
|
10
12
|
export const Default = {
|
|
@@ -2,10 +2,12 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { Table, TableColumn } from '.';
|
|
3
3
|
import { SORT_DIRECTION, sortByKey } from '../../../utils/sortByKey';
|
|
4
4
|
import { useState } from 'react';
|
|
5
|
+
import { UIVersion1 } from '../../../utils/decorators/UIVersion1';
|
|
5
6
|
const meta = {
|
|
6
7
|
title: 'Elements/Table',
|
|
7
8
|
component: Table,
|
|
8
9
|
tags: ['autodocs'],
|
|
10
|
+
decorators: [UIVersion1],
|
|
9
11
|
};
|
|
10
12
|
export default meta;
|
|
11
13
|
const data = [
|
|
@@ -2,14 +2,16 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import SearchIcon from '@mui/icons-material/Search';
|
|
3
3
|
import { INPUT_SIZE, TextInput } from '.';
|
|
4
4
|
import { useState } from 'react';
|
|
5
|
-
import { Column } from '
|
|
6
|
-
import { Group } from '
|
|
7
|
-
import { Heading, HEADING_SIZE } from '
|
|
8
|
-
import { COLOR } from '
|
|
5
|
+
import { Column } from '../layout/Column';
|
|
6
|
+
import { Group } from '../Group';
|
|
7
|
+
import { Heading, HEADING_SIZE } from '../Heading';
|
|
8
|
+
import { COLOR } from '../../../theme/colors';
|
|
9
|
+
import { UIVersion1 } from '../../../utils/decorators/UIVersion1';
|
|
9
10
|
const meta = {
|
|
10
11
|
title: 'Elements/Fields/TextInput',
|
|
11
12
|
component: TextInput,
|
|
12
13
|
tags: ['autodocs'],
|
|
14
|
+
decorators: [UIVersion1],
|
|
13
15
|
};
|
|
14
16
|
export default meta;
|
|
15
17
|
const sizes = [
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx } from "theme-ui/jsx-runtime";
|
|
2
2
|
import { render, screen, fireEvent } from '@testing-library/react';
|
|
3
3
|
import { describe, it, expect, vi } from 'vitest';
|
|
4
|
-
import { TextInput, INPUT_SIZE } from '
|
|
4
|
+
import { TextInput, INPUT_SIZE } from '.';
|
|
5
5
|
import { ThemeProvider } from 'theme-ui';
|
|
6
|
-
import { theme } from '
|
|
6
|
+
import { theme } from '../../../theme';
|
|
7
7
|
import '@testing-library/jest-dom';
|
|
8
8
|
vi.mock('../../../providers/uniqueIds', () => ({
|
|
9
9
|
useUniqueId: (prefix) => `${prefix}-mock-id`,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { TYPOGRAPHY_TYPE } from '
|
|
3
|
-
import { StyledElementProps } from '
|
|
2
|
+
import { TYPOGRAPHY_TYPE } from '../../../theme/typography';
|
|
3
|
+
import { StyledElementProps } from '../../../theme';
|
|
4
4
|
export declare enum INPUT_SIZE {
|
|
5
5
|
SM = "sm",
|
|
6
6
|
MD = "md",
|
|
@@ -28,7 +28,7 @@ export type TextInputProps = StyledElementProps<HTMLInputElement, {
|
|
|
28
28
|
onChangeRaw?: (e: string | React.ChangeEvent) => void;
|
|
29
29
|
}, string>;
|
|
30
30
|
export declare const TextInput: React.ForwardRefExoticComponent<{
|
|
31
|
-
sx?: import("
|
|
31
|
+
sx?: import("../../../theme").StylesProp | undefined;
|
|
32
32
|
children?: string | undefined;
|
|
33
33
|
} & Omit<React.HTMLAttributes<HTMLInputElement>, "children" | "onChange"> & {
|
|
34
34
|
size?: INPUT_SIZE | undefined;
|
|
@@ -11,13 +11,13 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "theme-ui/jsx-runtime";
|
|
13
13
|
import React from 'react';
|
|
14
|
-
import { TYPOGRAPHY_TYPE, getIconSize, getTypographyStyles, } from '
|
|
15
|
-
import { useTheme } from '
|
|
16
|
-
import { Icon } from '
|
|
17
|
-
import { COLOR } from '
|
|
18
|
-
import { Label } from '
|
|
19
|
-
import { useUniqueId } from '
|
|
20
|
-
import { BOX_SHADOW, Z_INDEX } from '
|
|
14
|
+
import { TYPOGRAPHY_TYPE, getIconSize, getTypographyStyles, } from '../../../theme/typography';
|
|
15
|
+
import { useTheme } from '../../../theme';
|
|
16
|
+
import { Icon } from '../Icon';
|
|
17
|
+
import { COLOR } from '../../../theme/colors';
|
|
18
|
+
import { Label } from '../Label';
|
|
19
|
+
import { useUniqueId } from '../../providers/uniqueIds';
|
|
20
|
+
import { BOX_SHADOW, Z_INDEX } from '../../../theme/custom';
|
|
21
21
|
export var INPUT_SIZE;
|
|
22
22
|
(function (INPUT_SIZE) {
|
|
23
23
|
INPUT_SIZE["SM"] = "sm";
|
|
@@ -50,6 +50,7 @@ const defaultHeight = {
|
|
|
50
50
|
[INPUT_SIZE.LG]: '3rem',
|
|
51
51
|
};
|
|
52
52
|
export const TextInput = React.forwardRef((_a, ref) => {
|
|
53
|
+
var _b;
|
|
53
54
|
var { value, label, onChange, onChangeRaw, onClick, inline, inverted, size: sizeParam, leftIcon, sx, disabled } = _a, rest = __rest(_a, ["value", "label", "onChange", "onChangeRaw", "onClick", "inline", "inverted", "size", "leftIcon", "sx", "disabled"]);
|
|
54
55
|
const id = useUniqueId('text-input');
|
|
55
56
|
const theme = useTheme();
|
|
@@ -111,7 +112,7 @@ export const TextInput = React.forwardRef((_a, ref) => {
|
|
|
111
112
|
color: inverted ? COLOR.EXTRA_LIGHT_GRAY : COLOR.ND_PROVOST_BLUE,
|
|
112
113
|
left: '0.5rem',
|
|
113
114
|
lineHeight: 1,
|
|
114
|
-
zIndex: theme.zIndex.ELEVATED,
|
|
115
|
+
zIndex: (_b = theme.zIndex) === null || _b === void 0 ? void 0 : _b.ELEVATED,
|
|
115
116
|
px: 1,
|
|
116
117
|
top: labelOffsetMap[size],
|
|
117
118
|
} }, { children: label })))] })));
|