@oliasoft-open-source/react-ui-library 2.4.8 → 3.0.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 +0 -1
- package/dist/global.css +21840 -0
- package/dist/index.js +43567 -0
- package/package.json +37 -55
- package/.eslintignore +0 -2
- package/.eslintrc.js +0 -125
- package/.gitlab-ci.yml +0 -76
- package/.husky/pre-commit +0 -4
- package/.prettierignore +0 -3
- package/.prettierrc +0 -4
- package/.storybook/main.js +0 -36
- package/.storybook/preview.js +0 -40
- package/.storybook/storybook.less +0 -8
- package/babel.config.js +0 -31
- package/index.js +0 -76
- package/jest.config.js +0 -9
- package/scripts/send-mattermost-message.sh +0 -21
- package/src/components/accordion/accordion.jsx +0 -132
- package/src/components/accordion/accordion.module.less +0 -66
- package/src/components/accordion/accordion.stories.jsx +0 -171
- package/src/components/accordion/chevron/chevron.jsx +0 -12
- package/src/components/accordion/chevron/chevron.module.less +0 -12
- package/src/components/accordion/helpers/accordion-with-default-toggle.jsx +0 -106
- package/src/components/accordion/helpers/accordion-with-default-toggle.module.less +0 -24
- package/src/components/actions/actions.jsx +0 -129
- package/src/components/actions/actions.module.less +0 -44
- package/src/components/actions/actions.shape.js +0 -32
- package/src/components/actions/actions.stories.jsx +0 -79
- package/src/components/badge/badge.jsx +0 -58
- package/src/components/badge/badge.module.less +0 -55
- package/src/components/badge/badge.stories.jsx +0 -31
- package/src/components/breadcrumb/breadcrumb.jsx +0 -49
- package/src/components/breadcrumb/breadcrumb.module.less +0 -39
- package/src/components/breadcrumb/breadcrumb.stories.jsx +0 -45
- package/src/components/breadcrumb/link.jsx +0 -31
- package/src/components/button/button.jsx +0 -156
- package/src/components/button/button.module.less +0 -300
- package/src/components/button/button.stories.jsx +0 -74
- package/src/components/button-group/button-group.jsx +0 -140
- package/src/components/button-group/button-group.module.less +0 -24
- package/src/components/button-group/button-group.stories-data.jsx +0 -67
- package/src/components/button-group/button-group.stories.jsx +0 -63
- package/src/components/buttons-and-links.stories.mdx +0 -55
- package/src/components/card/card.jsx +0 -51
- package/src/components/card/card.module.less +0 -48
- package/src/components/card/card.stories.jsx +0 -39
- package/src/components/check-box/check-box.jsx +0 -92
- package/src/components/check-box/check-box.module.less +0 -101
- package/src/components/check-box/check-box.stories.jsx +0 -27
- package/src/components/color/color.stories-data.jsx +0 -71
- package/src/components/color/color.stories.mdx +0 -37
- package/src/components/dialog/dialog.jsx +0 -77
- package/src/components/dialog/dialog.module.less +0 -76
- package/src/components/divider/divider.jsx +0 -40
- package/src/components/divider/divider.module.less +0 -28
- package/src/components/divider/divider.stories.jsx +0 -50
- package/src/components/drawer/drawer-resize-wrapper.jsx +0 -76
- package/src/components/drawer/drawer-tabs.jsx +0 -44
- package/src/components/drawer/drawer.jsx +0 -161
- package/src/components/drawer/drawer.module.less +0 -217
- package/src/components/drawer/drawer.stories.jsx +0 -296
- package/src/components/empty/empty.jsx +0 -52
- package/src/components/empty/empty.module.less +0 -17
- package/src/components/empty/empty.stories.jsx +0 -26
- package/src/components/file-input/file-input.jsx +0 -101
- package/src/components/file-input/file-input.module.less +0 -3
- package/src/components/file-input/file-input.stories.jsx +0 -109
- package/src/components/form/field.jsx +0 -96
- package/src/components/form/field.stories.jsx +0 -101
- package/src/components/form/form.module.less +0 -30
- package/src/components/form/form.stories.jsx +0 -191
- package/src/components/heading/heading.jsx +0 -105
- package/src/components/heading/heading.module.less +0 -59
- package/src/components/heading/heading.stories.jsx +0 -60
- package/src/components/icon/deprecated-icon.jsx +0 -97
- package/src/components/icon/icon.jsx +0 -71
- package/src/components/icon/icon.module.less +0 -33
- package/src/components/icon/icon.stories.jsx +0 -37
- package/src/components/icon/icons.example.module.less +0 -4
- package/src/components/input/input.jsx +0 -167
- package/src/components/input/input.module.less +0 -94
- package/src/components/input/input.stories.jsx +0 -28
- package/src/components/input-group/input-group-addon/input-group-addon.jsx +0 -36
- package/src/components/input-group/input-group-addon/input-group-addon.module.less +0 -31
- package/src/components/input-group/input-group.jsx +0 -51
- package/src/components/input-group/input-group.module.less +0 -10
- package/src/components/input-group/input-group.stories.jsx +0 -77
- package/src/components/input-validation.stories.mdx +0 -61
- package/src/components/inputs.stories.mdx +0 -201
- package/src/components/label/label.jsx +0 -115
- package/src/components/label/label.module.less +0 -43
- package/src/components/label/label.stories.jsx +0 -60
- package/src/components/layout/column/column.jsx +0 -85
- package/src/components/layout/column/styles.js +0 -45
- package/src/components/layout/column.stories.jsx +0 -60
- package/src/components/layout/examples/afe.stories.jsx +0 -180
- package/src/components/layout/examples/blowout.stories.jsx +0 -68
- package/src/components/layout/examples/casing-loads.stories.jsx +0 -297
- package/src/components/layout/examples/formation.stories.jsx +0 -110
- package/src/components/layout/examples/projects.stories.jsx +0 -108
- package/src/components/layout/examples/reservoirs.stories.jsx +0 -211
- package/src/components/layout/examples/site.stories.jsx +0 -263
- package/src/components/layout/flex/flex.jsx +0 -48
- package/src/components/layout/flex/flex.stories.jsx +0 -59
- package/src/components/layout/form-row/form-row.jsx +0 -15
- package/src/components/layout/form-row/form-row.module.less +0 -11
- package/src/components/layout/grid/grid.jsx +0 -62
- package/src/components/layout/grid/grid.stories.jsx +0 -67
- package/src/components/layout/page/page.jsx +0 -42
- package/src/components/layout/page/page.module.less +0 -27
- package/src/components/layout/page.stories.jsx +0 -93
- package/src/components/layout/placeholder.jsx +0 -2
- package/src/components/layout/print-header/print-header.jsx +0 -22
- package/src/components/layout/print-header/print-header.module.less +0 -9
- package/src/components/layout/row/row.jsx +0 -75
- package/src/components/layout/row/row.module.less +0 -7
- package/src/components/layout/spacer/spacer.jsx +0 -26
- package/src/components/layout/spacer/spacer.stories.jsx +0 -50
- package/src/components/layout-forms.stories.mdx +0 -104
- package/src/components/layout-general.stories.mdx +0 -215
- package/src/components/list/list-row/item-content.jsx +0 -15
- package/src/components/list/list-row/label.jsx +0 -11
- package/src/components/list/list-row/list-heading.jsx +0 -52
- package/src/components/list/list-row/list-row.jsx +0 -128
- package/src/components/list/list-row/list-subheading.jsx +0 -72
- package/src/components/list/list-row/meta-content.jsx +0 -24
- package/src/components/list/list-row/meta-count.jsx +0 -10
- package/src/components/list/list-row/name.jsx +0 -45
- package/src/components/list/list.jsx +0 -276
- package/src/components/list/list.module.less +0 -256
- package/src/components/list/list.stories-data.jsx +0 -287
- package/src/components/list/list.stories.jsx +0 -458
- package/src/components/list/toggle-narrow.jsx +0 -13
- package/src/components/loader/loader.jsx +0 -63
- package/src/components/loader/loader.module.less +0 -63
- package/src/components/loader/loader.stories.jsx +0 -155
- package/src/components/menu/index.js +0 -7
- package/src/components/menu/layer/divider.jsx +0 -4
- package/src/components/menu/layer/heading.jsx +0 -15
- package/src/components/menu/layer/layer.jsx +0 -82
- package/src/components/menu/layer/option.jsx +0 -77
- package/src/components/menu/layer/path.js +0 -44
- package/src/components/menu/layer/placementOptions.js +0 -6
- package/src/components/menu/layer/section.jsx +0 -66
- package/src/components/menu/menu.jsx +0 -359
- package/src/components/menu/menu.module.less +0 -241
- package/src/components/menu/menu.stories-data.jsx +0 -168
- package/src/components/menu/menu.stories.jsx +0 -126
- package/src/components/menu/menu.test.js +0 -58
- package/src/components/menu/trigger/button.jsx +0 -50
- package/src/components/menu/trigger/component.jsx +0 -14
- package/src/components/menu/trigger/text.jsx +0 -25
- package/src/components/menu/trigger/trigger.jsx +0 -86
- package/src/components/message/dismiss.jsx +0 -26
- package/src/components/message/message.jsx +0 -137
- package/src/components/message/message.module.less +0 -114
- package/src/components/message/message.stories.jsx +0 -84
- package/src/components/modal/modal.jsx +0 -50
- package/src/components/modal/modal.module.less +0 -39
- package/src/components/modal/modal.stories.jsx +0 -162
- package/src/components/option-dropdown/heading.jsx +0 -6
- package/src/components/option-dropdown/layer.jsx +0 -81
- package/src/components/option-dropdown/option-dropdown.jsx +0 -53
- package/src/components/option-dropdown/option-dropdown.module.less +0 -50
- package/src/components/option-dropdown/option-dropdown.stories.jsx +0 -35
- package/src/components/option-dropdown/option.jsx +0 -13
- package/src/components/pagination/pagination.jsx +0 -139
- package/src/components/pagination/pagination.module.less +0 -11
- package/src/components/pagination/pagination.stories.jsx +0 -78
- package/src/components/pagination/pagination.test.js +0 -92
- package/src/components/pagination/pagination.viewdata.js +0 -66
- package/src/components/pop-confirm/content.jsx +0 -25
- package/src/components/pop-confirm/pop-confirm.jsx +0 -61
- package/src/components/pop-confirm/pop-confirm.module.less +0 -18
- package/src/components/pop-confirm/pop-confirm.stories.jsx +0 -53
- package/src/components/popover/popover.jsx +0 -112
- package/src/components/popover/popover.module.less +0 -22
- package/src/components/popover/popover.stories.jsx +0 -59
- package/src/components/portal/portal.jsx +0 -16
- package/src/components/portal/portal.stories.jsx +0 -69
- package/src/components/progress-bar/progress-bar.jsx +0 -64
- package/src/components/progress-bar/progress-bar.module.less +0 -64
- package/src/components/progress-bar/progress-bar.stories.jsx +0 -23
- package/src/components/radio-button/radio-button.jsx +0 -139
- package/src/components/radio-button/radio-button.module.less +0 -135
- package/src/components/radio-button/radio-button.stories.jsx +0 -37
- package/src/components/radio-button/radio-input.jsx +0 -52
- package/src/components/select/custom-select/custom-select.jsx +0 -440
- package/src/components/select/custom-select/custom-select.module.less +0 -123
- package/src/components/select/custom-select/custom-select.reducer.js +0 -157
- package/src/components/select/custom-select/layer/heading.jsx +0 -13
- package/src/components/select/custom-select/layer/layer.jsx +0 -73
- package/src/components/select/custom-select/layer/option.jsx +0 -54
- package/src/components/select/custom-select/layer/placementOptions.js +0 -7
- package/src/components/select/custom-select/layer/section.jsx +0 -35
- package/src/components/select/custom-select/trigger/input.jsx +0 -100
- package/src/components/select/custom-select/trigger/trigger.jsx +0 -155
- package/src/components/select/custom-select/trigger/trigger.module.less +0 -289
- package/src/components/select/native-select/native-select.jsx +0 -198
- package/src/components/select/native-select/native-select.module.less +0 -107
- package/src/components/select/select.input.js +0 -146
- package/src/components/select/select.jsx +0 -207
- package/src/components/select/select.stories-data.jsx +0 -92
- package/src/components/select/select.stories.jsx +0 -135
- package/src/components/select/select.test.js +0 -519
- package/src/components/side-bar/container.module.less +0 -29
- package/src/components/side-bar/link.jsx +0 -83
- package/src/components/side-bar/sections.jsx +0 -23
- package/src/components/side-bar/side-bar.jsx +0 -102
- package/src/components/side-bar/side-bar.module.less +0 -137
- package/src/components/side-bar/side-bar.stories.jsx +0 -101
- package/src/components/slider/rc-slider.less +0 -47
- package/src/components/slider/slider-tooltip.jsx +0 -20
- package/src/components/slider/slider.jsx +0 -233
- package/src/components/slider/slider.module.less +0 -40
- package/src/components/slider/slider.stories.jsx +0 -110
- package/src/components/spinner/spinner.jsx +0 -37
- package/src/components/spinner/spinner.module.less +0 -115
- package/src/components/spinner/spinner.stories.jsx +0 -24
- package/src/components/table/cell/cell.jsx +0 -621
- package/src/components/table/cell/cell.module.less +0 -164
- package/src/components/table/footer/footer.jsx +0 -66
- package/src/components/table/footer/footer.module.less +0 -14
- package/src/components/table/helper.js +0 -64
- package/src/components/table/helper.test.js +0 -166
- package/src/components/table/icon/icon.module.less +0 -31
- package/src/components/table/row/expanded-content-row.jsx +0 -16
- package/src/components/table/row/row.jsx +0 -253
- package/src/components/table/row/row.module.less +0 -62
- package/src/components/table/table-scroll-wrapper.jsx +0 -49
- package/src/components/table/table.jsx +0 -234
- package/src/components/table/table.module.less +0 -146
- package/src/components/table/table.stories-data.jsx +0 -875
- package/src/components/table/table.stories.jsx +0 -759
- package/src/components/table/table.test.js +0 -30
- package/src/components/table/table.variables.less +0 -11
- package/src/components/table/table.viewdata.js +0 -26
- package/src/components/table/title/title.jsx +0 -30
- package/src/components/table/title/title.module.less +0 -11
- package/src/components/tabs/content.jsx +0 -14
- package/src/components/tabs/label.jsx +0 -50
- package/src/components/tabs/tabs.jsx +0 -191
- package/src/components/tabs/tabs.module.less +0 -73
- package/src/components/tabs/tabs.stories.jsx +0 -110
- package/src/components/text/text.jsx +0 -64
- package/src/components/text/text.module.less +0 -45
- package/src/components/text/text.stories.jsx +0 -31
- package/src/components/text-link/text-link.jsx +0 -23
- package/src/components/text-link/text-link.stories.jsx +0 -20
- package/src/components/textarea/textarea.jsx +0 -126
- package/src/components/textarea/textarea.module.less +0 -55
- package/src/components/textarea/textarea.stories.jsx +0 -26
- package/src/components/toaster/toaster.jsx +0 -39
- package/src/components/toaster/toaster.less +0 -17
- package/src/components/toaster/toaster.stories.jsx +0 -116
- package/src/components/toggle/toggle.jsx +0 -65
- package/src/components/toggle/toggle.module.less +0 -139
- package/src/components/toggle/toggle.stories.jsx +0 -26
- package/src/components/tooltip/tooltip-layer.jsx +0 -72
- package/src/components/tooltip/tooltip.jsx +0 -108
- package/src/components/tooltip/tooltip.module.less +0 -28
- package/src/components/tooltip/tooltip.stories.jsx +0 -71
- package/src/components/top-bar/element/element.jsx +0 -72
- package/src/components/top-bar/element/link.jsx +0 -29
- package/src/components/top-bar/title.jsx +0 -24
- package/src/components/top-bar/top-bar.jsx +0 -79
- package/src/components/top-bar/top-bar.module.less +0 -190
- package/src/components/top-bar/top-bar.stories.jsx +0 -137
- package/src/components/top-bar/warning.jsx +0 -6
- package/src/components/tree/tree-item.jsx +0 -79
- package/src/components/tree/tree-placeholder.jsx +0 -6
- package/src/components/tree/tree.jsx +0 -129
- package/src/components/tree/tree.module.less +0 -33
- package/src/components/tree/tree.stories-data.jsx +0 -89
- package/src/components/tree/tree.stories.jsx +0 -106
- package/src/docs/components/page/page.jsx +0 -16
- package/src/docs/config/config.js +0 -1
- package/src/docs/html/favicon.png +0 -0
- package/src/docs/html/index.html +0 -11
- package/src/docs/navigation/footer/footer.jsx +0 -48
- package/src/docs/navigation/header/header.jsx +0 -39
- package/src/docs/navigation/header/header.module.less +0 -32
- package/src/docs/navigation/routes/routes.jsx +0 -16
- package/src/docs/start.jsx +0 -12
- package/src/docs/views/main/main.jsx +0 -209
- package/src/docs/views/main/main.module.less +0 -14
- package/src/docs/views/not-found/not-found.jsx +0 -5
- package/src/helpers/disabled-context.js +0 -8
- package/src/helpers/styles.js +0 -68
- package/src/helpers/text.js +0 -6
- package/src/helpers/types.js +0 -5
- package/src/hooks/index.js +0 -3
- package/src/hooks/use-focus.js +0 -11
- package/src/hooks/use-keyboard-event.js +0 -16
- package/src/hooks/use-window-width.js +0 -20
- package/src/images/icons/icon-drop.png +0 -0
- package/src/images/icons/icon-share.png +0 -0
- package/src/images/icons/icons8-junction.svg +0 -4
- package/src/images/logo.png +0 -0
- package/src/images/logo.svg +0 -13
- package/src/images/oliasoft-logo.svg +0 -1
- package/src/style/colors.less +0 -26
- package/src/style/external.less +0 -10
- package/src/style/fonts/lato/Lato-Bold.woff2 +0 -0
- package/src/style/fonts/lato/Lato-BoldItalic.woff2 +0 -0
- package/src/style/fonts/lato/Lato-Italic.woff2 +0 -0
- package/src/style/fonts/lato/Lato-Regular.woff2 +0 -0
- package/src/style/fonts.less +0 -27
- package/src/style/global.less +0 -51
- package/src/style/mixins.less +0 -68
- package/src/style/reset/reset.less +0 -34
- package/src/style/shared.less +0 -25
- package/src/style/theme.dark.less +0 -37
- package/src/style/theme.default.less +0 -74
- package/src/style/variables.less +0 -49
- package/webpack/webpack.common.js +0 -39
- package/webpack/webpack.common.rules.js +0 -102
- package/webpack/webpack.dev.js +0 -22
- package/webpack/webpack.prod.js +0 -23
- package/webpack/webpack.resolve.js +0 -22
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Popover, Input, Button, Flex, Select } from '../../..';
|
|
3
|
-
|
|
4
|
-
const options = [
|
|
5
|
-
{ label: 'Option 1', value: '1' },
|
|
6
|
-
{ label: 'Option 2', value: '2' },
|
|
7
|
-
];
|
|
8
|
-
|
|
9
|
-
const SelectForm = ({ close }) => (
|
|
10
|
-
<Flex gap="8px">
|
|
11
|
-
<Input value="Value" width="150px" small />
|
|
12
|
-
<Select options={options} value={options[0]} width="auto" small />
|
|
13
|
-
<Button colored label="Save" onClick={() => {}} small />
|
|
14
|
-
<Button label="Cancel" onClick={close} small />
|
|
15
|
-
</Flex>
|
|
16
|
-
);
|
|
17
|
-
|
|
18
|
-
export default {
|
|
19
|
-
title: 'Basic/Popover',
|
|
20
|
-
component: Popover,
|
|
21
|
-
args: {
|
|
22
|
-
overflowContainer: true,
|
|
23
|
-
content: <SelectForm />,
|
|
24
|
-
children: <Button label="Toggle me" />,
|
|
25
|
-
},
|
|
26
|
-
// TODO: Work out why the story requires this wrapper for the Popover to position correctly
|
|
27
|
-
decorators: [(story) => <div style={{ display: 'flex' }}>{story()}</div>],
|
|
28
|
-
parameters: {
|
|
29
|
-
docs: {
|
|
30
|
-
source: {
|
|
31
|
-
excludeDecorators: true,
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
const Template = (args) => (
|
|
38
|
-
<Popover
|
|
39
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
40
|
-
{...args}
|
|
41
|
-
/>
|
|
42
|
-
);
|
|
43
|
-
export const Default = Template.bind({});
|
|
44
|
-
|
|
45
|
-
export const InputTrigger = Template.bind({});
|
|
46
|
-
InputTrigger.args = {
|
|
47
|
-
children: <Input value="Value" width="100%" />,
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
export const CloseButton = Template.bind({});
|
|
51
|
-
CloseButton.args = {
|
|
52
|
-
closeOnOutsideClick: false,
|
|
53
|
-
showCloseButton: true,
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
export const Disabled = Template.bind({});
|
|
57
|
-
Disabled.args = {
|
|
58
|
-
disabled: true,
|
|
59
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { useLayoutEffect, useState } from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { createPortal } from 'react-dom';
|
|
4
|
-
|
|
5
|
-
export const Portal = ({ id, children }) => {
|
|
6
|
-
const parent = document.querySelector(`#${id}`);
|
|
7
|
-
const [mounted, setMounted] = useState(false);
|
|
8
|
-
useLayoutEffect(() => {
|
|
9
|
-
if (!mounted) setMounted(true);
|
|
10
|
-
}, [id]);
|
|
11
|
-
return parent ? createPortal(children, parent) : null;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
Portal.propTypes = {
|
|
15
|
-
id: PropTypes.string.isRequired,
|
|
16
|
-
};
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useState } from 'react';
|
|
2
|
-
import { createPortal } from 'react-dom';
|
|
3
|
-
import { Portal } from '../../..';
|
|
4
|
-
|
|
5
|
-
export default {
|
|
6
|
-
title: 'Modals/Portal',
|
|
7
|
-
component: Portal,
|
|
8
|
-
args: {
|
|
9
|
-
children: <div>Portal content</div>,
|
|
10
|
-
id: 'portalContainer',
|
|
11
|
-
},
|
|
12
|
-
parameters: {
|
|
13
|
-
docs: {
|
|
14
|
-
inlineStories: false,
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const Template = (args) => (
|
|
20
|
-
<>
|
|
21
|
-
<Portal
|
|
22
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
23
|
-
{...args}
|
|
24
|
-
/>
|
|
25
|
-
<div id={args.id} />
|
|
26
|
-
</>
|
|
27
|
-
);
|
|
28
|
-
export const Default = Template.bind({});
|
|
29
|
-
|
|
30
|
-
export const CreatePortal = () => {
|
|
31
|
-
const parent = document.querySelector('#root');
|
|
32
|
-
return (
|
|
33
|
-
<>
|
|
34
|
-
<div id="portalContainer" />
|
|
35
|
-
{parent && createPortal(<div>Portal content</div>, parent)}
|
|
36
|
-
</>
|
|
37
|
-
);
|
|
38
|
-
};
|
|
39
|
-
CreatePortal.parameters = {
|
|
40
|
-
docs: {
|
|
41
|
-
source: { type: 'code' },
|
|
42
|
-
description: {
|
|
43
|
-
story: 'How to use React `createPortal()` directly',
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
export const CreatePortalWithDynamicDOMNode = () => {
|
|
49
|
-
const parent = document.querySelector('#portalContainer');
|
|
50
|
-
const [visible, setVisible] = useState(false);
|
|
51
|
-
useEffect(() => {
|
|
52
|
-
if (!visible) setVisible(true);
|
|
53
|
-
}, []);
|
|
54
|
-
return (
|
|
55
|
-
<>
|
|
56
|
-
<div id="portalContainer" />
|
|
57
|
-
{visible && parent && createPortal(<div>Portal content</div>, parent)}
|
|
58
|
-
</>
|
|
59
|
-
);
|
|
60
|
-
};
|
|
61
|
-
CreatePortalWithDynamicDOMNode.parameters = {
|
|
62
|
-
docs: {
|
|
63
|
-
source: { type: 'code' },
|
|
64
|
-
description: {
|
|
65
|
-
story:
|
|
66
|
-
'This story shows how to use React `createPortal()` directly. The domNode for `createPortal()` must exist. For a dynamic container, this is not the case on the first render.',
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
};
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import cx from 'classnames';
|
|
4
|
-
import styles from './progress-bar.module.less';
|
|
5
|
-
|
|
6
|
-
const getColor = (perct) => {
|
|
7
|
-
if (perct < 5) return styles.grey;
|
|
8
|
-
if (perct < 20) return styles.red;
|
|
9
|
-
if (perct < 45) return styles.orange;
|
|
10
|
-
if (perct < 60) return styles.yellow;
|
|
11
|
-
if (perct < 80) return styles.olive;
|
|
12
|
-
if (perct < 100) return styles.green;
|
|
13
|
-
return 'green';
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export const ProgressBar = ({
|
|
17
|
-
width,
|
|
18
|
-
inverted,
|
|
19
|
-
colored,
|
|
20
|
-
showProgressColors,
|
|
21
|
-
percentage,
|
|
22
|
-
noLabel,
|
|
23
|
-
}) => {
|
|
24
|
-
return (
|
|
25
|
-
<div style={{ width }} data-percent={percentage}>
|
|
26
|
-
<div
|
|
27
|
-
className={cx(styles.progress, inverted ? styles.inverted : '')}
|
|
28
|
-
style={{ width }}
|
|
29
|
-
>
|
|
30
|
-
<div
|
|
31
|
-
className={cx(
|
|
32
|
-
styles.bar,
|
|
33
|
-
showProgressColors
|
|
34
|
-
? getColor(percentage)
|
|
35
|
-
: colored
|
|
36
|
-
? styles.colored
|
|
37
|
-
: '',
|
|
38
|
-
)}
|
|
39
|
-
style={{ width: `${percentage}%` }}
|
|
40
|
-
>
|
|
41
|
-
<div className={styles.label}>{!noLabel && `${percentage}%`}</div>
|
|
42
|
-
</div>
|
|
43
|
-
</div>
|
|
44
|
-
</div>
|
|
45
|
-
);
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
ProgressBar.defaultProps = {
|
|
49
|
-
width: 'auto',
|
|
50
|
-
inverted: false,
|
|
51
|
-
percentage: 0,
|
|
52
|
-
colored: true,
|
|
53
|
-
showProgressColors: false,
|
|
54
|
-
noLabel: false,
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
ProgressBar.propTypes = {
|
|
58
|
-
width: PropTypes.string,
|
|
59
|
-
colored: PropTypes.bool,
|
|
60
|
-
inverted: PropTypes.bool,
|
|
61
|
-
percentage: PropTypes.number,
|
|
62
|
-
showProgressColors: PropTypes.bool,
|
|
63
|
-
noLabel: PropTypes.bool,
|
|
64
|
-
};
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
.progress {
|
|
2
|
-
position: relative;
|
|
3
|
-
display: block;
|
|
4
|
-
max-width: 100%;
|
|
5
|
-
border: none;
|
|
6
|
-
margin: 0;
|
|
7
|
-
box-shadow: none;
|
|
8
|
-
background: rgba(0, 0, 0, 0.1);
|
|
9
|
-
padding: 0;
|
|
10
|
-
border-radius: 0.28571429rem;
|
|
11
|
-
font-size: 1rem;
|
|
12
|
-
|
|
13
|
-
&.inverted {
|
|
14
|
-
background: rgba(255, 255, 255, 0.08);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
.bar {
|
|
19
|
-
display: block;
|
|
20
|
-
line-height: 1;
|
|
21
|
-
position: relative;
|
|
22
|
-
width: 0%;
|
|
23
|
-
min-width: 2em;
|
|
24
|
-
background: #888;
|
|
25
|
-
border-radius: 0.28571429rem;
|
|
26
|
-
transition: width 0.1s ease, background-color 0.5s ease;
|
|
27
|
-
height: 1.75em;
|
|
28
|
-
|
|
29
|
-
&.grey {
|
|
30
|
-
background-color: #767676;
|
|
31
|
-
}
|
|
32
|
-
&.red {
|
|
33
|
-
background-color: #db2828;
|
|
34
|
-
}
|
|
35
|
-
&.colored,
|
|
36
|
-
&.orange {
|
|
37
|
-
background-color: #f2711c;
|
|
38
|
-
}
|
|
39
|
-
&.yellow {
|
|
40
|
-
background-color: #fbbd08;
|
|
41
|
-
}
|
|
42
|
-
&.olive {
|
|
43
|
-
background-color: #b5cc18;
|
|
44
|
-
}
|
|
45
|
-
&.green {
|
|
46
|
-
background-color: #21ba45;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
.label {
|
|
51
|
-
white-space: nowrap;
|
|
52
|
-
position: absolute;
|
|
53
|
-
width: auto;
|
|
54
|
-
font-size: 0.92857143em;
|
|
55
|
-
top: 50%;
|
|
56
|
-
right: 0.5em;
|
|
57
|
-
left: auto;
|
|
58
|
-
bottom: auto;
|
|
59
|
-
color: rgba(255, 255, 255, 0.7);
|
|
60
|
-
text-shadow: none;
|
|
61
|
-
margin-top: -0.5em;
|
|
62
|
-
font-weight: 700;
|
|
63
|
-
text-align: left;
|
|
64
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { ProgressBar } from '../../..';
|
|
3
|
-
|
|
4
|
-
export default {
|
|
5
|
-
title: 'Progress/ProgressBar',
|
|
6
|
-
component: ProgressBar,
|
|
7
|
-
args: {
|
|
8
|
-
colored: true,
|
|
9
|
-
inverted: false,
|
|
10
|
-
noLabel: false,
|
|
11
|
-
percentage: 30,
|
|
12
|
-
showProgressColors: false,
|
|
13
|
-
width: 'auto',
|
|
14
|
-
},
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
const Template = (args) => (
|
|
18
|
-
<ProgressBar
|
|
19
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
20
|
-
{...args}
|
|
21
|
-
/>
|
|
22
|
-
);
|
|
23
|
-
export const Default = Template.bind({});
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
import React, { useContext } from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import cx from 'classnames';
|
|
4
|
-
import { standardizeInputs } from '../select/select.input';
|
|
5
|
-
import { RadioInput } from './radio-input';
|
|
6
|
-
import styles from './radio-button.module.less';
|
|
7
|
-
import { DisabledContext } from '../../helpers/disabled-context';
|
|
8
|
-
|
|
9
|
-
export const RadioButton = ({
|
|
10
|
-
name,
|
|
11
|
-
label: rawLabel,
|
|
12
|
-
options: rawOptions,
|
|
13
|
-
value: rawValue,
|
|
14
|
-
onChange,
|
|
15
|
-
inline,
|
|
16
|
-
disabled,
|
|
17
|
-
small,
|
|
18
|
-
//deprecated props:
|
|
19
|
-
mainLabel,
|
|
20
|
-
onClick,
|
|
21
|
-
radioButtonsData,
|
|
22
|
-
classForContainer,
|
|
23
|
-
noMargin,
|
|
24
|
-
}) => {
|
|
25
|
-
const disabledContext = useContext(DisabledContext);
|
|
26
|
-
|
|
27
|
-
//----------------------------------------------------------------------------
|
|
28
|
-
// Deprecation / backwards-compatibility
|
|
29
|
-
const isDeprecated = radioButtonsData !== undefined;
|
|
30
|
-
const {
|
|
31
|
-
simpleInputs,
|
|
32
|
-
options,
|
|
33
|
-
selectedOptions: value,
|
|
34
|
-
} = isDeprecated
|
|
35
|
-
? {
|
|
36
|
-
simpleInputs: false,
|
|
37
|
-
options: radioButtonsData,
|
|
38
|
-
selectedOptions: undefined,
|
|
39
|
-
}
|
|
40
|
-
: standardizeInputs(rawOptions, rawValue);
|
|
41
|
-
const selectedValue =
|
|
42
|
-
isDeprecated || value === undefined || value === null
|
|
43
|
-
? undefined
|
|
44
|
-
: simpleInputs
|
|
45
|
-
? value
|
|
46
|
-
: value.value;
|
|
47
|
-
const label = isDeprecated ? mainLabel : rawLabel;
|
|
48
|
-
//----------------------------------------------------------------------------
|
|
49
|
-
|
|
50
|
-
return (
|
|
51
|
-
<div
|
|
52
|
-
className={cx(
|
|
53
|
-
styles.wrapper,
|
|
54
|
-
inline ? styles.inline : null,
|
|
55
|
-
classForContainer === 'inline fields' ? styles.inline : null, //deprecated
|
|
56
|
-
)}
|
|
57
|
-
>
|
|
58
|
-
{mainLabel && (
|
|
59
|
-
<label className={cx(inline && styles.labelMargin)}>{label}</label>
|
|
60
|
-
)}
|
|
61
|
-
{options.map((option, index) => {
|
|
62
|
-
const selected =
|
|
63
|
-
option.checked || option.value === selectedValue || false;
|
|
64
|
-
return (
|
|
65
|
-
<RadioInput
|
|
66
|
-
key={index}
|
|
67
|
-
name={option.name || option.value} //name must be unique
|
|
68
|
-
label={option.label}
|
|
69
|
-
value={option.value}
|
|
70
|
-
selected={selected}
|
|
71
|
-
disabled={disabled || option.disabled || disabledContext}
|
|
72
|
-
small={small}
|
|
73
|
-
noMargin={noMargin}
|
|
74
|
-
onChange={
|
|
75
|
-
!option.disabled
|
|
76
|
-
? (evt) => {
|
|
77
|
-
if (isDeprecated) {
|
|
78
|
-
onClick(evt.target);
|
|
79
|
-
} else {
|
|
80
|
-
evt.target.name = name;
|
|
81
|
-
evt.target.value = option.value;
|
|
82
|
-
evt.target.label = option.label;
|
|
83
|
-
onChange(evt);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
: null
|
|
87
|
-
}
|
|
88
|
-
testId={option.testId}
|
|
89
|
-
/>
|
|
90
|
-
);
|
|
91
|
-
})}
|
|
92
|
-
</div>
|
|
93
|
-
);
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
RadioButton.defaultProps = {
|
|
97
|
-
name: undefined,
|
|
98
|
-
noMargin: false,
|
|
99
|
-
inline: false,
|
|
100
|
-
mainLabel: '',
|
|
101
|
-
label: '',
|
|
102
|
-
disabled: false,
|
|
103
|
-
small: false,
|
|
104
|
-
onClick: () => {},
|
|
105
|
-
onChange: () => {},
|
|
106
|
-
classForContainer: 'grouped fields', // Deprecated
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
const RadioButtonShapeDeprecated = {
|
|
110
|
-
radioButtonsData: PropTypes.arrayOf(PropTypes.object).isRequired,
|
|
111
|
-
inline: PropTypes.bool,
|
|
112
|
-
mainLabel: PropTypes.string,
|
|
113
|
-
onClick: PropTypes.func,
|
|
114
|
-
disabled: PropTypes.bool,
|
|
115
|
-
classForContainer: PropTypes.string, // Deprecated
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
export const radioOptionShape = PropTypes.shape({
|
|
119
|
-
label: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
|
|
120
|
-
value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
|
|
121
|
-
testId: PropTypes.string,
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
const RadioButtonShape = {
|
|
125
|
-
name: PropTypes.string,
|
|
126
|
-
noMargin: PropTypes.bool,
|
|
127
|
-
label: PropTypes.string,
|
|
128
|
-
options: PropTypes.arrayOf(radioOptionShape).isRequired,
|
|
129
|
-
value: radioOptionShape,
|
|
130
|
-
inline: PropTypes.bool,
|
|
131
|
-
disabled: PropTypes.bool,
|
|
132
|
-
small: PropTypes.bool,
|
|
133
|
-
onChange: PropTypes.func,
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
RadioButton.propTypes = PropTypes.oneOfType([
|
|
137
|
-
PropTypes.shape(RadioButtonShape), //only use this for new usages
|
|
138
|
-
PropTypes.shape(RadioButtonShapeDeprecated), //deprecated Select interface
|
|
139
|
-
]).isRequired;
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
@import '../../style/variables.less';
|
|
2
|
-
|
|
3
|
-
.wrapper {
|
|
4
|
-
&.inline {
|
|
5
|
-
display: flex;
|
|
6
|
-
align-items: center;
|
|
7
|
-
|
|
8
|
-
.radio:not(:last-child) {
|
|
9
|
-
margin-right: 16px;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
.labelMargin {
|
|
14
|
-
margin-right: 10px;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
.radio {
|
|
19
|
-
margin: 10px 0 11px 0;
|
|
20
|
-
position: relative;
|
|
21
|
-
display: block;
|
|
22
|
-
backface-visibility: hidden;
|
|
23
|
-
vertical-align: baseline;
|
|
24
|
-
font-style: normal;
|
|
25
|
-
min-height: 17px;
|
|
26
|
-
font-size: 1rem;
|
|
27
|
-
line-height: 17px;
|
|
28
|
-
min-width: 17px;
|
|
29
|
-
outline: 0px;
|
|
30
|
-
|
|
31
|
-
&.small {
|
|
32
|
-
margin: 3px 0;
|
|
33
|
-
font-size: @input_font_size_small;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
&.noMargin {
|
|
37
|
-
margin-top: 0;
|
|
38
|
-
margin-bottom: 0;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
input {
|
|
42
|
-
cursor: pointer;
|
|
43
|
-
position: absolute;
|
|
44
|
-
top: 0;
|
|
45
|
-
left: 0;
|
|
46
|
-
opacity: 0 !important;
|
|
47
|
-
outline: 0;
|
|
48
|
-
width: 17px;
|
|
49
|
-
height: 17px;
|
|
50
|
-
z-index: -1;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
label {
|
|
54
|
-
cursor: pointer;
|
|
55
|
-
position: relative;
|
|
56
|
-
display: block;
|
|
57
|
-
padding-left: 1.85714em;
|
|
58
|
-
outline: 0;
|
|
59
|
-
font-size: 1em;
|
|
60
|
-
color: var(--color-text);
|
|
61
|
-
transition: color 0.1s ease;
|
|
62
|
-
|
|
63
|
-
&:before,
|
|
64
|
-
&:after {
|
|
65
|
-
content: '';
|
|
66
|
-
position: absolute;
|
|
67
|
-
top: 1px;
|
|
68
|
-
left: 0;
|
|
69
|
-
width: 15px;
|
|
70
|
-
height: 15px;
|
|
71
|
-
line-height: 15px;
|
|
72
|
-
border-radius: 500rem;
|
|
73
|
-
transition: border 0.1s ease, opacity 0.1s ease, transform 0.1s ease,
|
|
74
|
-
box-shadow 0.1s ease;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
&:before {
|
|
78
|
-
background: var(--color-background-input);
|
|
79
|
-
border: 1px solid var(--color-border);
|
|
80
|
-
transform: none;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
&:hover:before {
|
|
84
|
-
border-color: var(--color-border-hover);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
&:after {
|
|
88
|
-
border: none;
|
|
89
|
-
transform: scale(0.46666667);
|
|
90
|
-
background-color: white;
|
|
91
|
-
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
|
|
92
|
-
opacity: 0;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
input:checked ~ label {
|
|
97
|
-
&:before {
|
|
98
|
-
background-color: var(--color-background-primary);
|
|
99
|
-
border-color: transparent;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
&:after {
|
|
103
|
-
opacity: 1;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
&.disabled {
|
|
108
|
-
cursor: default;
|
|
109
|
-
pointer-events: none;
|
|
110
|
-
|
|
111
|
-
label {
|
|
112
|
-
color: var(--color-text-muted);
|
|
113
|
-
|
|
114
|
-
&:before {
|
|
115
|
-
background-color: var(--color-background-disabled) !important;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
input:checked ~ label {
|
|
120
|
-
&:before {
|
|
121
|
-
border-color: var(--color-border);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
&:after {
|
|
125
|
-
background-color: var(--color-text-faint);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
.isInTable {
|
|
132
|
-
margin: 0;
|
|
133
|
-
position: relative;
|
|
134
|
-
top: 1px;
|
|
135
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
2
|
-
import { RadioButton } from './radio-button';
|
|
3
|
-
|
|
4
|
-
const options = [
|
|
5
|
-
{ label: 'Aardvarks', value: 'termites' },
|
|
6
|
-
{ label: 'Kangaroos', value: 'grass' },
|
|
7
|
-
{ label: 'Monkeys', value: 'bananas', disabled: true },
|
|
8
|
-
];
|
|
9
|
-
|
|
10
|
-
export default {
|
|
11
|
-
title: 'Forms/RadioButton',
|
|
12
|
-
component: RadioButton,
|
|
13
|
-
args: {
|
|
14
|
-
options,
|
|
15
|
-
inline: false,
|
|
16
|
-
noMargin: false,
|
|
17
|
-
disabled: false,
|
|
18
|
-
small: false,
|
|
19
|
-
},
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const Template = (args) => {
|
|
23
|
-
const [value, setValue] = useState(options[0]);
|
|
24
|
-
const handleChange = (evt) => {
|
|
25
|
-
const { value } = evt.target;
|
|
26
|
-
setValue({ value });
|
|
27
|
-
};
|
|
28
|
-
return (
|
|
29
|
-
<RadioButton
|
|
30
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
31
|
-
{...args}
|
|
32
|
-
value={value}
|
|
33
|
-
onChange={handleChange}
|
|
34
|
-
/>
|
|
35
|
-
);
|
|
36
|
-
};
|
|
37
|
-
export const Default = Template.bind({});
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import cx from 'classnames';
|
|
3
|
-
import styles from './radio-button.module.less';
|
|
4
|
-
|
|
5
|
-
export const RadioInput = ({
|
|
6
|
-
name,
|
|
7
|
-
label,
|
|
8
|
-
value,
|
|
9
|
-
selected,
|
|
10
|
-
disabled,
|
|
11
|
-
small,
|
|
12
|
-
onChange,
|
|
13
|
-
noMargin,
|
|
14
|
-
testId,
|
|
15
|
-
}) => {
|
|
16
|
-
return (
|
|
17
|
-
<div
|
|
18
|
-
className={cx(
|
|
19
|
-
styles.radio,
|
|
20
|
-
disabled ? styles.disabled : null,
|
|
21
|
-
small ? styles.small : null,
|
|
22
|
-
noMargin ? styles.noMargin : null,
|
|
23
|
-
)}
|
|
24
|
-
onClick={onChange}
|
|
25
|
-
data-testid={testId}
|
|
26
|
-
>
|
|
27
|
-
<input
|
|
28
|
-
type="radio"
|
|
29
|
-
/*
|
|
30
|
-
Don't set the name property. In certain circumstances (including
|
|
31
|
-
duplicated names), it seems confuse React into behaving like an
|
|
32
|
-
uncontrolled input. We've seen a bug where sometimes the input state
|
|
33
|
-
wouldn't update visually upon click. If we change this decision, we
|
|
34
|
-
need to understand why this happens.
|
|
35
|
-
https://stackoverflow.com/questions/63032125
|
|
36
|
-
*/
|
|
37
|
-
//name={name} //name must be unique
|
|
38
|
-
value={value}
|
|
39
|
-
checked={selected}
|
|
40
|
-
onChange={() => {}}
|
|
41
|
-
disabled={disabled}
|
|
42
|
-
/>
|
|
43
|
-
<label
|
|
44
|
-
//data attributes are for deprecated variant
|
|
45
|
-
data-name={name}
|
|
46
|
-
data-value={value}
|
|
47
|
-
>
|
|
48
|
-
{label}
|
|
49
|
-
</label>
|
|
50
|
-
</div>
|
|
51
|
-
);
|
|
52
|
-
};
|