@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,33 +0,0 @@
|
|
|
1
|
-
@import '../../style/variables.less';
|
|
2
|
-
|
|
3
|
-
.wrapper {
|
|
4
|
-
color: inherit;
|
|
5
|
-
fill: inherit;
|
|
6
|
-
display: inline-flex;
|
|
7
|
-
align-items: center;
|
|
8
|
-
justify-content: center;
|
|
9
|
-
|
|
10
|
-
.customSvg {
|
|
11
|
-
line-height: 0; // Strips unneccessary whitespace
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.customPng {
|
|
15
|
-
max-width: 100%;
|
|
16
|
-
max-height: 100%;
|
|
17
|
-
object-fit: contain;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
.clickable {
|
|
22
|
-
cursor: pointer;
|
|
23
|
-
|
|
24
|
-
&:hover {
|
|
25
|
-
color: var(--color-text-primary-hover) !important;
|
|
26
|
-
fill: var(--color-text-primary-hover) !important;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
&:active {
|
|
30
|
-
color: var(--color-text-primary-active) !important;
|
|
31
|
-
fill: var(--color-text-primary-active) !important;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { FaAngleDoubleRight } from 'react-icons/fa';
|
|
3
|
-
import { Icon } from '../../..';
|
|
4
|
-
import svgIcon from '../../images/icons/icons8-junction.svg';
|
|
5
|
-
|
|
6
|
-
export default {
|
|
7
|
-
title: 'Basic/Icon',
|
|
8
|
-
component: Icon,
|
|
9
|
-
argTypes: {
|
|
10
|
-
color: { control: 'text' },
|
|
11
|
-
size: { control: 'text' },
|
|
12
|
-
},
|
|
13
|
-
args: {
|
|
14
|
-
icon: <FaAngleDoubleRight />,
|
|
15
|
-
},
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const Template = (args) => (
|
|
19
|
-
<Icon
|
|
20
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
21
|
-
{...args}
|
|
22
|
-
/>
|
|
23
|
-
);
|
|
24
|
-
|
|
25
|
-
export const Default = Template.bind({});
|
|
26
|
-
|
|
27
|
-
export const Size = Template.bind({});
|
|
28
|
-
Size.args = { size: '100px' };
|
|
29
|
-
|
|
30
|
-
export const Color = Template.bind({});
|
|
31
|
-
Color.args = { color: 'var(--color-text-primary)' };
|
|
32
|
-
|
|
33
|
-
export const CustomSVG = Template.bind({});
|
|
34
|
-
CustomSVG.args = { icon: svgIcon, size: '14px' };
|
|
35
|
-
|
|
36
|
-
export const Clickable = Template.bind({});
|
|
37
|
-
Clickable.args = { onClick: () => {} };
|
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
import React, { forwardRef, useContext } from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import cx from 'classnames';
|
|
4
|
-
import styles from './input.module.less';
|
|
5
|
-
import { Tooltip } from '../tooltip/tooltip';
|
|
6
|
-
import { isStringNumberOrNode } from '../../helpers/types';
|
|
7
|
-
import { DisabledContext } from '../../helpers/disabled-context';
|
|
8
|
-
|
|
9
|
-
/*
|
|
10
|
-
Gets the width when you want to set it based on the number of characters
|
|
11
|
-
Replacement for input size property which is hard to style
|
|
12
|
-
*/
|
|
13
|
-
export const widthOfCharacters = (characterCount) => {
|
|
14
|
-
const padding = '15px';
|
|
15
|
-
const multiplier = '0.675em';
|
|
16
|
-
return `calc((${characterCount} * ${multiplier}) + (2 * ${padding}))`;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export const Input = forwardRef(
|
|
20
|
-
(
|
|
21
|
-
{
|
|
22
|
-
error,
|
|
23
|
-
tooltip,
|
|
24
|
-
isInTable,
|
|
25
|
-
width: propWidth,
|
|
26
|
-
small,
|
|
27
|
-
onChange,
|
|
28
|
-
size,
|
|
29
|
-
placeholder,
|
|
30
|
-
value,
|
|
31
|
-
onKeyPress,
|
|
32
|
-
onFocus,
|
|
33
|
-
onBlur,
|
|
34
|
-
name,
|
|
35
|
-
type,
|
|
36
|
-
tabIndex,
|
|
37
|
-
disabled,
|
|
38
|
-
right,
|
|
39
|
-
warning,
|
|
40
|
-
groupOrder,
|
|
41
|
-
maxTooltipWidth,
|
|
42
|
-
testId,
|
|
43
|
-
},
|
|
44
|
-
ref,
|
|
45
|
-
) => {
|
|
46
|
-
const disabledContext = useContext(DisabledContext);
|
|
47
|
-
const order = (() => {
|
|
48
|
-
if (groupOrder) {
|
|
49
|
-
switch (groupOrder) {
|
|
50
|
-
case 'first':
|
|
51
|
-
return styles.groupOrderFirst;
|
|
52
|
-
case 'last':
|
|
53
|
-
return styles.groupOrderLast;
|
|
54
|
-
default:
|
|
55
|
-
return styles.groupOrderMiddle;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
return '';
|
|
59
|
-
})();
|
|
60
|
-
|
|
61
|
-
const width = propWidth || (size ? 'auto' : '100%');
|
|
62
|
-
|
|
63
|
-
return (
|
|
64
|
-
<div style={{ width }} className={order}>
|
|
65
|
-
<Tooltip
|
|
66
|
-
error={!!error}
|
|
67
|
-
warning={!!warning}
|
|
68
|
-
text={tooltip || error || warning}
|
|
69
|
-
enabled={
|
|
70
|
-
(tooltip && isStringNumberOrNode(tooltip)) ||
|
|
71
|
-
(error && isStringNumberOrNode(error)) ||
|
|
72
|
-
(warning && isStringNumberOrNode(warning)) ||
|
|
73
|
-
false
|
|
74
|
-
}
|
|
75
|
-
maxWidth={maxTooltipWidth}
|
|
76
|
-
display="block"
|
|
77
|
-
placement="bottom-center"
|
|
78
|
-
>
|
|
79
|
-
<input
|
|
80
|
-
type={type}
|
|
81
|
-
size={size || 20}
|
|
82
|
-
placeholder={placeholder}
|
|
83
|
-
value={value}
|
|
84
|
-
onChange={onChange}
|
|
85
|
-
onKeyPress={onKeyPress}
|
|
86
|
-
onFocus={onFocus}
|
|
87
|
-
onBlur={onBlur}
|
|
88
|
-
name={name}
|
|
89
|
-
tabIndex={tabIndex}
|
|
90
|
-
autoComplete="off"
|
|
91
|
-
disabled={disabled || disabledContext}
|
|
92
|
-
className={cx(
|
|
93
|
-
styles.input,
|
|
94
|
-
error ? styles.error : warning ? styles.warning : '',
|
|
95
|
-
right ? styles.right : '',
|
|
96
|
-
small ? styles.small : '',
|
|
97
|
-
isInTable ? styles.isInTable : '',
|
|
98
|
-
)}
|
|
99
|
-
style={{ width }}
|
|
100
|
-
ref={ref}
|
|
101
|
-
data-testid={testId}
|
|
102
|
-
/>
|
|
103
|
-
</Tooltip>
|
|
104
|
-
</div>
|
|
105
|
-
);
|
|
106
|
-
},
|
|
107
|
-
);
|
|
108
|
-
|
|
109
|
-
Input.defaultProps = {
|
|
110
|
-
error: null,
|
|
111
|
-
warning: null,
|
|
112
|
-
tooltip: null,
|
|
113
|
-
name: undefined,
|
|
114
|
-
type: 'text',
|
|
115
|
-
onChange: () => {},
|
|
116
|
-
onKeyPress: () => {},
|
|
117
|
-
onFocus: () => {},
|
|
118
|
-
onBlur: () => {},
|
|
119
|
-
placeholder: '',
|
|
120
|
-
small: false,
|
|
121
|
-
tabIndex: 0,
|
|
122
|
-
value: '',
|
|
123
|
-
disabled: false,
|
|
124
|
-
right: false,
|
|
125
|
-
groupOrder: null,
|
|
126
|
-
maxTooltipWidth: undefined,
|
|
127
|
-
width: undefined,
|
|
128
|
-
testId: undefined,
|
|
129
|
-
//deprecated props
|
|
130
|
-
size: null, //use width instead
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
Input.propTypes = {
|
|
134
|
-
error: PropTypes.oneOfType([
|
|
135
|
-
PropTypes.string,
|
|
136
|
-
PropTypes.number,
|
|
137
|
-
PropTypes.node,
|
|
138
|
-
]),
|
|
139
|
-
warning: PropTypes.oneOfType([
|
|
140
|
-
PropTypes.string,
|
|
141
|
-
PropTypes.number,
|
|
142
|
-
PropTypes.node,
|
|
143
|
-
]),
|
|
144
|
-
tooltip: PropTypes.oneOfType([
|
|
145
|
-
PropTypes.string,
|
|
146
|
-
PropTypes.number,
|
|
147
|
-
PropTypes.node,
|
|
148
|
-
]),
|
|
149
|
-
name: PropTypes.string,
|
|
150
|
-
type: PropTypes.string,
|
|
151
|
-
onChange: PropTypes.func,
|
|
152
|
-
onKeyPress: PropTypes.func,
|
|
153
|
-
onFocus: PropTypes.func,
|
|
154
|
-
onBlur: PropTypes.func,
|
|
155
|
-
small: PropTypes.bool,
|
|
156
|
-
placeholder: PropTypes.string,
|
|
157
|
-
tabIndex: PropTypes.number,
|
|
158
|
-
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
159
|
-
disabled: PropTypes.bool,
|
|
160
|
-
right: PropTypes.bool,
|
|
161
|
-
groupOrder: PropTypes.string,
|
|
162
|
-
maxTooltipWidth: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
163
|
-
width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
164
|
-
testId: PropTypes.string,
|
|
165
|
-
//deprecated props:
|
|
166
|
-
size: PropTypes.number, //use width instead
|
|
167
|
-
};
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
@import '../../style/variables.less';
|
|
2
|
-
@import '../../style/mixins.less';
|
|
3
|
-
|
|
4
|
-
.input {
|
|
5
|
-
margin: 0;
|
|
6
|
-
outline: 0;
|
|
7
|
-
text-align: left;
|
|
8
|
-
font-family: @default_font;
|
|
9
|
-
padding: @input_padding_y @input_padding_x;
|
|
10
|
-
background: var(--color-background-input);
|
|
11
|
-
border: 1px solid var(--color-border);
|
|
12
|
-
color: var(--color-text);
|
|
13
|
-
border-radius: @input_border_radius;
|
|
14
|
-
transition: box-shadow 0.1s ease, border-color 0.1s ease;
|
|
15
|
-
box-shadow: none;
|
|
16
|
-
height: @input_height;
|
|
17
|
-
width: 100%;
|
|
18
|
-
font-weight: 400;
|
|
19
|
-
font-style: normal;
|
|
20
|
-
position: relative;
|
|
21
|
-
|
|
22
|
-
&::placeholder {
|
|
23
|
-
color: var(--color-text-faint);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
&.isInTable {
|
|
27
|
-
.inputInTable();
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
&:hover,
|
|
31
|
-
&:focus {
|
|
32
|
-
z-index: 1;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
&:hover {
|
|
36
|
-
border-color: var(--color-border-hover);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
&:focus {
|
|
40
|
-
.inputFocus();
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
&.small {
|
|
44
|
-
font-size: @input_font_size_small;
|
|
45
|
-
height: @input_height_small;
|
|
46
|
-
padding: 0 @input_padding_small_x;
|
|
47
|
-
line-height: @input_height_small;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
&.error {
|
|
51
|
-
.inputError();
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
&.warning {
|
|
55
|
-
.inputWarning();
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
&[disabled] {
|
|
59
|
-
.inputDisabled();
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
&.right {
|
|
63
|
-
text-align: right;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
.groupOrderFirst,
|
|
68
|
-
.groupOrderMiddle,
|
|
69
|
-
.groupOrderLast {
|
|
70
|
-
flex: 1;
|
|
71
|
-
|
|
72
|
-
.input:hover,
|
|
73
|
-
.input:focus {
|
|
74
|
-
z-index: 2;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
.groupOrderFirst,
|
|
79
|
-
.groupOrderMiddle {
|
|
80
|
-
margin-right: -1px;
|
|
81
|
-
|
|
82
|
-
.input {
|
|
83
|
-
border-top-right-radius: 0 !important;
|
|
84
|
-
border-bottom-right-radius: 0 !important;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
.groupOrderLast,
|
|
89
|
-
.groupOrderMiddle {
|
|
90
|
-
.input {
|
|
91
|
-
border-top-left-radius: 0 !important;
|
|
92
|
-
border-bottom-left-radius: 0 !important;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { useArgs } from '@storybook/addons';
|
|
3
|
-
import { Input } from '../../..';
|
|
4
|
-
|
|
5
|
-
export default {
|
|
6
|
-
title: 'Forms/Input',
|
|
7
|
-
component: Input,
|
|
8
|
-
args: {
|
|
9
|
-
disabled: false,
|
|
10
|
-
small: false,
|
|
11
|
-
placeholder: 'Placeholder',
|
|
12
|
-
},
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
const Template = (args) => {
|
|
16
|
-
const [_, updateArgs] = useArgs();
|
|
17
|
-
const handleChange = (evt) => {
|
|
18
|
-
updateArgs({ value: evt.target.value });
|
|
19
|
-
};
|
|
20
|
-
return (
|
|
21
|
-
<Input
|
|
22
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
23
|
-
{...args}
|
|
24
|
-
onChange={handleChange}
|
|
25
|
-
/>
|
|
26
|
-
);
|
|
27
|
-
};
|
|
28
|
-
export const Default = Template.bind({});
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import cx from 'classnames';
|
|
4
|
-
import styles from './input-group-addon.module.less';
|
|
5
|
-
|
|
6
|
-
export const InputGroupAddon = ({ children, groupOrder, small }) => {
|
|
7
|
-
const order = (() => {
|
|
8
|
-
if (groupOrder) {
|
|
9
|
-
switch (groupOrder) {
|
|
10
|
-
case 'first':
|
|
11
|
-
return styles.groupOrderFirst;
|
|
12
|
-
case 'last':
|
|
13
|
-
return styles.groupOrderLast;
|
|
14
|
-
default:
|
|
15
|
-
return styles.groupOrderMiddle;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
return '';
|
|
19
|
-
})();
|
|
20
|
-
return (
|
|
21
|
-
<span className={cx(styles.addon, order, small ? styles.small : '')}>
|
|
22
|
-
{children}
|
|
23
|
-
</span>
|
|
24
|
-
);
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
InputGroupAddon.defaultProps = {
|
|
28
|
-
groupOrder: null,
|
|
29
|
-
small: false,
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
InputGroupAddon.propTypes = {
|
|
33
|
-
children: PropTypes.node.isRequired,
|
|
34
|
-
groupOrder: PropTypes.string,
|
|
35
|
-
small: PropTypes.bool,
|
|
36
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
@import '../../../style/variables.less';
|
|
2
|
-
|
|
3
|
-
.addon {
|
|
4
|
-
flex-shrink: 0;
|
|
5
|
-
border-radius: @input_border_radius;
|
|
6
|
-
border: 1px solid var(--color-border);
|
|
7
|
-
background: var(--color-background-disabled);
|
|
8
|
-
display: inline-flex;
|
|
9
|
-
align-items: center;
|
|
10
|
-
padding: 0 @input_padding_x;
|
|
11
|
-
color: var(--color-text-muted);
|
|
12
|
-
line-height: 1;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
.small {
|
|
16
|
-
font-size: @input_font_size_small;
|
|
17
|
-
padding: 0 @input_padding_small_x;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
.groupOrderFirst,
|
|
21
|
-
.groupOrderMiddle {
|
|
22
|
-
border-top-right-radius: 0 !important;
|
|
23
|
-
border-bottom-right-radius: 0 !important;
|
|
24
|
-
margin-right: -1px;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.groupOrderLast,
|
|
28
|
-
.groupOrderMiddle {
|
|
29
|
-
border-top-left-radius: 0 !important;
|
|
30
|
-
border-bottom-left-radius: 0 !important;
|
|
31
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import React, { Fragment, isValidElement } from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import cx from 'classnames';
|
|
4
|
-
import styles from './input-group.module.less';
|
|
5
|
-
|
|
6
|
-
const isDOMTypeElement = (element) => {
|
|
7
|
-
return isValidElement(element) && typeof element.type === 'string';
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export const InputGroup = ({ children, small, width }) => {
|
|
11
|
-
const childElements =
|
|
12
|
-
children instanceof Array
|
|
13
|
-
? children.filter((c) => isValidElement(c))
|
|
14
|
-
: [children];
|
|
15
|
-
const elements = childElements.map((item, index) => {
|
|
16
|
-
const isDOMType = isDOMTypeElement(item);
|
|
17
|
-
const { groupOrder: groupOrderProp } = !isDOMType
|
|
18
|
-
? item.props
|
|
19
|
-
: { groupOrder: null };
|
|
20
|
-
const count = childElements.length;
|
|
21
|
-
const isFirst = index === 0;
|
|
22
|
-
const isLast = index === count - 1;
|
|
23
|
-
const isOnly = !count || count === 1;
|
|
24
|
-
const groupOrder =
|
|
25
|
-
groupOrderProp ||
|
|
26
|
-
(isOnly ? null : isFirst ? 'first' : isLast ? 'last' : 'middle');
|
|
27
|
-
return isDOMType ? (
|
|
28
|
-
item
|
|
29
|
-
) : (
|
|
30
|
-
<Fragment key={index}>
|
|
31
|
-
{React.cloneElement(item, { groupOrder, small })}
|
|
32
|
-
</Fragment>
|
|
33
|
-
);
|
|
34
|
-
});
|
|
35
|
-
return (
|
|
36
|
-
<div className={cx(styles.inputGroup)} style={{ width }}>
|
|
37
|
-
{elements}
|
|
38
|
-
</div>
|
|
39
|
-
);
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
InputGroup.defaultProps = {
|
|
43
|
-
small: false,
|
|
44
|
-
width: '100%',
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
InputGroup.propTypes = {
|
|
48
|
-
children: PropTypes.node.isRequired,
|
|
49
|
-
small: PropTypes.bool,
|
|
50
|
-
width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
51
|
-
};
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
InputGroup,
|
|
4
|
-
InputGroupAddon,
|
|
5
|
-
Input,
|
|
6
|
-
Button,
|
|
7
|
-
Menu,
|
|
8
|
-
Select,
|
|
9
|
-
} from '../../..';
|
|
10
|
-
|
|
11
|
-
export default {
|
|
12
|
-
title: 'Forms/InputGroup',
|
|
13
|
-
component: InputGroup,
|
|
14
|
-
args: {},
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
const Template = (args) => {
|
|
18
|
-
return (
|
|
19
|
-
<InputGroup
|
|
20
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
21
|
-
{...args}
|
|
22
|
-
>
|
|
23
|
-
<InputGroupAddon>$</InputGroupAddon>
|
|
24
|
-
<Input width="100%" name="example" value="123" onChange={() => {}} />
|
|
25
|
-
<Select
|
|
26
|
-
options={[
|
|
27
|
-
{ label: 'Aardvarks', value: 'termites' },
|
|
28
|
-
{ label: 'Kangaroos', value: 'grass' },
|
|
29
|
-
{ label: 'Monkeys', value: 'bananas' },
|
|
30
|
-
{ label: 'Possums', value: 'slugs' },
|
|
31
|
-
]}
|
|
32
|
-
onChange={() => {}}
|
|
33
|
-
value={{ label: 'Monkeys', value: 'bananas' }}
|
|
34
|
-
width="auto"
|
|
35
|
-
native
|
|
36
|
-
/>
|
|
37
|
-
<Menu
|
|
38
|
-
menu={{
|
|
39
|
-
label: 'E-06/degC',
|
|
40
|
-
trigger: 'DropDownButton',
|
|
41
|
-
small: args.small,
|
|
42
|
-
sections: [
|
|
43
|
-
{
|
|
44
|
-
type: 'Option',
|
|
45
|
-
label: '403.5433',
|
|
46
|
-
description: 'ft',
|
|
47
|
-
inline: true,
|
|
48
|
-
onClick: () => {},
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
type: 'Option',
|
|
52
|
-
label: '0.123',
|
|
53
|
-
description: 'km',
|
|
54
|
-
inline: true,
|
|
55
|
-
onClick: () => {},
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
type: 'Option',
|
|
59
|
-
label: '4842.4608',
|
|
60
|
-
description: 'in',
|
|
61
|
-
inline: true,
|
|
62
|
-
onClick: () => {},
|
|
63
|
-
},
|
|
64
|
-
],
|
|
65
|
-
}}
|
|
66
|
-
/>
|
|
67
|
-
<Button name="example" label="Confirm" colored onClick={() => {}} />
|
|
68
|
-
</InputGroup>
|
|
69
|
-
);
|
|
70
|
-
};
|
|
71
|
-
export const Default = Template.bind({});
|
|
72
|
-
|
|
73
|
-
export const FixedWidth = Template.bind({});
|
|
74
|
-
FixedWidth.args = { width: '480px' };
|
|
75
|
-
|
|
76
|
-
export const Small = Template.bind({});
|
|
77
|
-
Small.args = { small: true };
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { Canvas, Meta, Story } from '@storybook/addon-docs';
|
|
2
|
-
import { Input, TextArea, Select, RadioButton, FormRow, Field } from '../..';
|
|
3
|
-
|
|
4
|
-
<Meta title="Input Validation" />
|
|
5
|
-
|
|
6
|
-
# Input Validation
|
|
7
|
-
|
|
8
|
-
## Select
|
|
9
|
-
|
|
10
|
-
### Invalid states
|
|
11
|
-
|
|
12
|
-
It's possible for a `Select` input to be in an invalid state, where a value is explicitly set via the `value` prop,
|
|
13
|
-
but the option is not available for re-selection in the dropdown (i.e. not in the `options` prop). Some guidelines are
|
|
14
|
-
provided here to help.
|
|
15
|
-
|
|
16
|
-
**Avoid invalid values via the business logic**
|
|
17
|
-
|
|
18
|
-
It's best to prevent invalid values from happening, via the application business logic.
|
|
19
|
-
|
|
20
|
-
If they can happen, handling them is a concern of the business layer. The UI framework is generally only responsible
|
|
21
|
-
for presentation.
|
|
22
|
-
|
|
23
|
-
**Select will always display the value if it is explicitly set**
|
|
24
|
-
|
|
25
|
-
If the `value` prop is set, it will be displayed, even if it is not available for re-selection from the `options` prop.
|
|
26
|
-
The library does not hide or mask set values.
|
|
27
|
-
|
|
28
|
-
**"Soft invalid" values**
|
|
29
|
-
|
|
30
|
-
For a 'soft invalid' state, where the value is usable, but not available for re-reselection, the UI library automatically
|
|
31
|
-
adds a warning state with a tooltip message: "Value no longer available for re-selection". Technically, this should be
|
|
32
|
-
handled by the business logic, not the UI framework, but the behaviour exists for historical reasons.
|
|
33
|
-
In the future it may be optional (via a prop), or deprecated/removed, so it's better to handle it properly in the
|
|
34
|
-
application layer.
|
|
35
|
-
|
|
36
|
-
<Canvas>
|
|
37
|
-
<FormRow>
|
|
38
|
-
<Select
|
|
39
|
-
width="200px"
|
|
40
|
-
options={['Rare', 'Medium', 'Well Done']}
|
|
41
|
-
value="Blue"
|
|
42
|
-
/>
|
|
43
|
-
</FormRow>
|
|
44
|
-
</Canvas>
|
|
45
|
-
|
|
46
|
-
**"Hard invalid" value**
|
|
47
|
-
|
|
48
|
-
For a 'hard invalid' state (where the value is unusable, but required), it is recommended for the business logic to not
|
|
49
|
-
set a value (use `null` or `undefined`), and to set the `error` prop with an appropriate message
|
|
50
|
-
(e.g. "Value is required").
|
|
51
|
-
|
|
52
|
-
<Canvas>
|
|
53
|
-
<FormRow>
|
|
54
|
-
<Select
|
|
55
|
-
width="200px"
|
|
56
|
-
options={['Rare', 'Medium', 'Well Done']}
|
|
57
|
-
value={undefined}
|
|
58
|
-
error="Value is required"
|
|
59
|
-
/>
|
|
60
|
-
</FormRow>
|
|
61
|
-
</Canvas>
|