@oliasoft-open-source/react-ui-library 2.4.7 → 3.0.0
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 -617
- 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 -874
- 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,519 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
isMulti,
|
|
3
|
-
isSimpleOptions,
|
|
4
|
-
isSimpleSelectedOptions,
|
|
5
|
-
standardizeOptions,
|
|
6
|
-
standardizeSelectedOptions,
|
|
7
|
-
standardizeSelectedOption,
|
|
8
|
-
getFirstSelectedOptionIndex,
|
|
9
|
-
nonExistentValue,
|
|
10
|
-
} from './select.input';
|
|
11
|
-
|
|
12
|
-
describe('select (inputs)', () => {
|
|
13
|
-
test('is multi select', () => {
|
|
14
|
-
expect(isMulti([])).toBe(true);
|
|
15
|
-
expect(isMulti([{ label: 'Monkeys', value: 'bananas' }])).toBe(true);
|
|
16
|
-
expect(isMulti(null)).toBe(false);
|
|
17
|
-
expect(isMulti('Monkeys')).toBe(false);
|
|
18
|
-
expect(isMulti({ label: 'Monkeys', value: 'bananas' })).toBe(false);
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
test('is simple options', () => {
|
|
22
|
-
expect(isSimpleOptions(['Cat', 'Mouse'])).toBe(true);
|
|
23
|
-
expect(isSimpleOptions([1, 2])).toBe(true);
|
|
24
|
-
expect(
|
|
25
|
-
isSimpleOptions([
|
|
26
|
-
{ label: 'Cat', value: 'Cat' },
|
|
27
|
-
{ label: 'Mouse', value: 'Mouse' },
|
|
28
|
-
]),
|
|
29
|
-
).toBe(false);
|
|
30
|
-
expect(isSimpleOptions([{ label: 'Cat', value: 'Cat' }, 'Mouse', 4])).toBe(
|
|
31
|
-
true,
|
|
32
|
-
);
|
|
33
|
-
expect(isSimpleOptions([])).toBe(false);
|
|
34
|
-
expect(isSimpleOptions(undefined)).toBe(false);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
test('is simple selected options', () => {
|
|
38
|
-
expect(isSimpleSelectedOptions(['Cat', 'Mouse'])).toBe(true);
|
|
39
|
-
expect(isSimpleSelectedOptions([11, 12])).toBe(true);
|
|
40
|
-
expect(isSimpleSelectedOptions('Cat')).toBe(true);
|
|
41
|
-
expect(isSimpleSelectedOptions(6)).toBe(true);
|
|
42
|
-
expect(
|
|
43
|
-
isSimpleOptions([
|
|
44
|
-
{ label: 'Cat', value: 'Cat' },
|
|
45
|
-
{ label: 'Mouse', value: 'Mouse' },
|
|
46
|
-
]),
|
|
47
|
-
).toBe(false);
|
|
48
|
-
expect(isSimpleOptions([{ label: 'Cat', value: 'Cat' }, 'Mouse', 7])).toBe(
|
|
49
|
-
true,
|
|
50
|
-
);
|
|
51
|
-
expect(isSimpleOptions([])).toBe(false);
|
|
52
|
-
expect(isSimpleOptions(undefined)).toBe(false);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
test('standardize options', () => {
|
|
56
|
-
expect(
|
|
57
|
-
standardizeOptions(
|
|
58
|
-
[
|
|
59
|
-
{ label: 'Cat', value: 'cat' },
|
|
60
|
-
{ label: 'Mouse', value: 'mouse' },
|
|
61
|
-
],
|
|
62
|
-
false,
|
|
63
|
-
),
|
|
64
|
-
).toStrictEqual([
|
|
65
|
-
{ label: 'Cat', value: 'cat' },
|
|
66
|
-
{ label: 'Mouse', value: 'mouse' },
|
|
67
|
-
]);
|
|
68
|
-
expect(standardizeOptions(['Cat', 'Mouse'], true)).toStrictEqual([
|
|
69
|
-
{ label: 'Cat', value: 'Cat' },
|
|
70
|
-
{ label: 'Mouse', value: 'Mouse' },
|
|
71
|
-
]);
|
|
72
|
-
expect(standardizeOptions([5, 6], true)).toStrictEqual([
|
|
73
|
-
{ label: 5, value: 5 },
|
|
74
|
-
{ label: 6, value: 6 },
|
|
75
|
-
]);
|
|
76
|
-
expect(
|
|
77
|
-
standardizeOptions([{ label: 'Cat', value: 'cat' }, 'Mouse', 9], true),
|
|
78
|
-
).toStrictEqual([
|
|
79
|
-
{ label: 'Cat', value: 'cat' },
|
|
80
|
-
{ label: 'Mouse', value: 'Mouse' },
|
|
81
|
-
{ label: 9, value: 9 },
|
|
82
|
-
]);
|
|
83
|
-
expect(standardizeOptions([], true)).toStrictEqual([]);
|
|
84
|
-
expect(standardizeOptions(undefined, true)).toStrictEqual(undefined);
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
test('standardize selected options (single select)', () => {
|
|
88
|
-
expect(
|
|
89
|
-
standardizeSelectedOptions([{ label: 'Cat', value: 'cat' }], {
|
|
90
|
-
label: 'Cat',
|
|
91
|
-
value: 'cat',
|
|
92
|
-
}),
|
|
93
|
-
).toStrictEqual({ label: 'Cat', value: 'cat' });
|
|
94
|
-
expect(
|
|
95
|
-
standardizeSelectedOptions([{ label: 'Cat', value: 'cat' }], 'cat'),
|
|
96
|
-
).toStrictEqual({
|
|
97
|
-
label: 'Cat',
|
|
98
|
-
value: 'cat',
|
|
99
|
-
});
|
|
100
|
-
expect(
|
|
101
|
-
standardizeSelectedOptions([{ label: 'Cat', value: 'cat' }], {
|
|
102
|
-
value: 'cat',
|
|
103
|
-
monkeys: 'bananas',
|
|
104
|
-
}),
|
|
105
|
-
).toStrictEqual({
|
|
106
|
-
label: 'Cat',
|
|
107
|
-
value: 'cat',
|
|
108
|
-
});
|
|
109
|
-
expect(
|
|
110
|
-
standardizeSelectedOptions([{ label: 'Cat', value: 'cat' }], 'Foobar'),
|
|
111
|
-
).toStrictEqual({ label: 'Foobar', value: 'Foobar' });
|
|
112
|
-
expect(
|
|
113
|
-
standardizeSelectedOptions([{ label: 'Cat', value: 'cat' }], {
|
|
114
|
-
value: '',
|
|
115
|
-
}),
|
|
116
|
-
).toStrictEqual(undefined);
|
|
117
|
-
expect(
|
|
118
|
-
standardizeSelectedOptions([{ label: 'Cat', value: 'cat' }], null),
|
|
119
|
-
).toStrictEqual(undefined);
|
|
120
|
-
expect(
|
|
121
|
-
standardizeSelectedOptions([{ label: 8, value: 8 }], 8),
|
|
122
|
-
).toStrictEqual({
|
|
123
|
-
label: 8,
|
|
124
|
-
value: 8,
|
|
125
|
-
});
|
|
126
|
-
expect(
|
|
127
|
-
standardizeSelectedOptions([{ label: 8, value: 8 }], '8'), //allow coercion
|
|
128
|
-
).toStrictEqual({
|
|
129
|
-
label: 8,
|
|
130
|
-
value: 8,
|
|
131
|
-
});
|
|
132
|
-
expect(standardizeSelectedOptions([], null)).toStrictEqual(undefined);
|
|
133
|
-
expect(standardizeSelectedOptions([], undefined)).toStrictEqual(undefined);
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
test('standardize selected options (multi-select)', () => {
|
|
137
|
-
expect(
|
|
138
|
-
standardizeSelectedOptions(null, [
|
|
139
|
-
{ label: 'Cat', value: 'cat' },
|
|
140
|
-
{ label: 'Mouse', value: 'mouse' },
|
|
141
|
-
]),
|
|
142
|
-
).toStrictEqual([
|
|
143
|
-
{ label: 'Cat', value: 'cat' },
|
|
144
|
-
{ label: 'Mouse', value: 'mouse' },
|
|
145
|
-
]);
|
|
146
|
-
expect(
|
|
147
|
-
standardizeSelectedOptions(
|
|
148
|
-
[
|
|
149
|
-
{ label: 'Cat', value: 'cat' },
|
|
150
|
-
{ label: 'Mouse', value: 'mouse' },
|
|
151
|
-
],
|
|
152
|
-
['cat', 'mouse'],
|
|
153
|
-
),
|
|
154
|
-
).toStrictEqual([
|
|
155
|
-
{ label: 'Cat', value: 'cat' },
|
|
156
|
-
{ label: 'Mouse', value: 'mouse' },
|
|
157
|
-
]);
|
|
158
|
-
expect(
|
|
159
|
-
standardizeSelectedOptions(
|
|
160
|
-
[
|
|
161
|
-
{ label: 1, value: 1 },
|
|
162
|
-
{ label: 2, value: 2 },
|
|
163
|
-
],
|
|
164
|
-
[1, 2],
|
|
165
|
-
),
|
|
166
|
-
).toStrictEqual([
|
|
167
|
-
{ label: 1, value: 1 },
|
|
168
|
-
{ label: 2, value: 2 },
|
|
169
|
-
]);
|
|
170
|
-
expect(
|
|
171
|
-
standardizeSelectedOptions(
|
|
172
|
-
[
|
|
173
|
-
{ label: 1, value: 1 },
|
|
174
|
-
{ label: 2, value: 2 },
|
|
175
|
-
],
|
|
176
|
-
['1', '2'], //allow coercion
|
|
177
|
-
),
|
|
178
|
-
).toStrictEqual([
|
|
179
|
-
{ label: 1, value: 1 },
|
|
180
|
-
{ label: 2, value: 2 },
|
|
181
|
-
]);
|
|
182
|
-
expect(
|
|
183
|
-
standardizeSelectedOptions(
|
|
184
|
-
[
|
|
185
|
-
{ label: 'Cat', value: 'cat' },
|
|
186
|
-
{ label: 'Mouse', value: 'mouse' },
|
|
187
|
-
{ label: 5, value: 5 },
|
|
188
|
-
],
|
|
189
|
-
['cat', { label: 'Mouse', value: 'mouse' }, 5],
|
|
190
|
-
),
|
|
191
|
-
).toStrictEqual([
|
|
192
|
-
{ label: 'Cat', value: 'cat' },
|
|
193
|
-
{ label: 'Mouse', value: 'mouse' },
|
|
194
|
-
{ label: 5, value: 5 },
|
|
195
|
-
]);
|
|
196
|
-
expect(
|
|
197
|
-
standardizeSelectedOptions(
|
|
198
|
-
[
|
|
199
|
-
{ label: 'Cat', value: 'cat' },
|
|
200
|
-
{ label: 'Mouse', value: 'mouse' },
|
|
201
|
-
{ label: 5, value: 5 },
|
|
202
|
-
],
|
|
203
|
-
[
|
|
204
|
-
{ value: 'cat' },
|
|
205
|
-
{ label: 'Mouse', value: 'mouse' },
|
|
206
|
-
null,
|
|
207
|
-
undefined,
|
|
208
|
-
'',
|
|
209
|
-
],
|
|
210
|
-
),
|
|
211
|
-
).toStrictEqual([
|
|
212
|
-
{ label: 'Cat', value: 'cat' },
|
|
213
|
-
{ label: 'Mouse', value: 'mouse' },
|
|
214
|
-
]);
|
|
215
|
-
expect(standardizeSelectedOptions(null, [])).toStrictEqual([]);
|
|
216
|
-
});
|
|
217
|
-
|
|
218
|
-
test('standardize selected option', () => {
|
|
219
|
-
expect(
|
|
220
|
-
standardizeSelectedOption(
|
|
221
|
-
[
|
|
222
|
-
{ label: 'Cat', value: 'cat' },
|
|
223
|
-
{ label: 'Mouse', value: 'mouse' },
|
|
224
|
-
],
|
|
225
|
-
{ label: 'Mouse', value: 'mouse' },
|
|
226
|
-
),
|
|
227
|
-
).toStrictEqual({ label: 'Mouse', value: 'mouse' });
|
|
228
|
-
expect(
|
|
229
|
-
standardizeSelectedOption(
|
|
230
|
-
[
|
|
231
|
-
{ label: 'Cat', value: 'cat' },
|
|
232
|
-
{ label: 'Mouse', value: 'mouse' },
|
|
233
|
-
],
|
|
234
|
-
{ value: 'mouse' },
|
|
235
|
-
),
|
|
236
|
-
).toStrictEqual({ label: 'Mouse', value: 'mouse' });
|
|
237
|
-
expect(
|
|
238
|
-
standardizeSelectedOption(
|
|
239
|
-
[
|
|
240
|
-
{ label: 'Cat', value: 'cat' },
|
|
241
|
-
{ label: 'Mouse', value: 'mouse' },
|
|
242
|
-
],
|
|
243
|
-
'mouse',
|
|
244
|
-
),
|
|
245
|
-
).toStrictEqual({ label: 'Mouse', value: 'mouse' });
|
|
246
|
-
expect(
|
|
247
|
-
standardizeSelectedOption(
|
|
248
|
-
[
|
|
249
|
-
{ label: 'Cat', value: 1 },
|
|
250
|
-
{ label: 'Mouse', value: 2 },
|
|
251
|
-
],
|
|
252
|
-
{ value: 1 },
|
|
253
|
-
),
|
|
254
|
-
).toStrictEqual({ label: 'Cat', value: 1 });
|
|
255
|
-
expect(
|
|
256
|
-
standardizeSelectedOption(
|
|
257
|
-
[
|
|
258
|
-
{ label: 'Cat', value: 1 },
|
|
259
|
-
{ label: 'Mouse', value: 2 },
|
|
260
|
-
],
|
|
261
|
-
{ value: '1' }, //allow coercion
|
|
262
|
-
),
|
|
263
|
-
).toStrictEqual({ label: 'Cat', value: 1 });
|
|
264
|
-
expect(
|
|
265
|
-
standardizeSelectedOption(
|
|
266
|
-
[
|
|
267
|
-
{ label: 'Cat', value: 1 },
|
|
268
|
-
{ label: 'Mouse', value: 2 },
|
|
269
|
-
],
|
|
270
|
-
1,
|
|
271
|
-
),
|
|
272
|
-
).toStrictEqual({ label: 'Cat', value: 1 });
|
|
273
|
-
expect(
|
|
274
|
-
standardizeSelectedOption(
|
|
275
|
-
[
|
|
276
|
-
{ label: 'Cat', value: 1 },
|
|
277
|
-
{ label: 'Mouse', value: 2 },
|
|
278
|
-
],
|
|
279
|
-
'1', //allow coercion
|
|
280
|
-
),
|
|
281
|
-
).toStrictEqual({ label: 'Cat', value: 1 });
|
|
282
|
-
expect(
|
|
283
|
-
standardizeSelectedOption(
|
|
284
|
-
[
|
|
285
|
-
{ label: 'Cat', value: 'cat' },
|
|
286
|
-
{ label: 'Mouse', value: 'mouse' },
|
|
287
|
-
],
|
|
288
|
-
null,
|
|
289
|
-
),
|
|
290
|
-
).toStrictEqual(undefined);
|
|
291
|
-
expect(standardizeSelectedOption([], 'mouse')).toStrictEqual({
|
|
292
|
-
label: 'mouse',
|
|
293
|
-
value: 'mouse',
|
|
294
|
-
});
|
|
295
|
-
//non-existent values
|
|
296
|
-
expect(standardizeSelectedOption(undefined, 'mouse')).toStrictEqual({
|
|
297
|
-
label: 'mouse',
|
|
298
|
-
value: 'mouse',
|
|
299
|
-
});
|
|
300
|
-
expect(
|
|
301
|
-
standardizeSelectedOption(
|
|
302
|
-
[
|
|
303
|
-
{ label: 'Cat', value: 1 },
|
|
304
|
-
{ label: 'Mouse', value: 2 },
|
|
305
|
-
],
|
|
306
|
-
{ label: 'Vampire', value: 'vampire' },
|
|
307
|
-
),
|
|
308
|
-
).toStrictEqual({ label: 'Vampire', value: 'vampire' });
|
|
309
|
-
expect(
|
|
310
|
-
standardizeSelectedOption(['Cat', 'Mouse'], 'Vampire'),
|
|
311
|
-
).toStrictEqual({ label: 'Vampire', value: 'Vampire' });
|
|
312
|
-
});
|
|
313
|
-
|
|
314
|
-
test('get first selected option index', () => {
|
|
315
|
-
expect(
|
|
316
|
-
getFirstSelectedOptionIndex(
|
|
317
|
-
[
|
|
318
|
-
{ label: 'Cat', value: 'cat' },
|
|
319
|
-
{ label: 'Mouse', value: 'mouse' },
|
|
320
|
-
{ label: 'Dog', value: 'dog' },
|
|
321
|
-
],
|
|
322
|
-
{ label: 'Mouse', value: 'mouse' },
|
|
323
|
-
),
|
|
324
|
-
).toBe(1);
|
|
325
|
-
expect(
|
|
326
|
-
getFirstSelectedOptionIndex(
|
|
327
|
-
[
|
|
328
|
-
{ label: 'Cat', value: 'cat' },
|
|
329
|
-
{ label: 'Mouse', value: 'mouse' },
|
|
330
|
-
{ label: 'Dog', value: 'dog' },
|
|
331
|
-
],
|
|
332
|
-
[
|
|
333
|
-
{ label: 'Mouse', value: 'mouse' },
|
|
334
|
-
{ label: 'Dog', value: 'dog' },
|
|
335
|
-
],
|
|
336
|
-
),
|
|
337
|
-
).toBe(1);
|
|
338
|
-
expect(
|
|
339
|
-
getFirstSelectedOptionIndex(
|
|
340
|
-
[
|
|
341
|
-
{ label: 'Cat', value: 1 },
|
|
342
|
-
{ label: 'Mouse', value: 2 },
|
|
343
|
-
{ label: 'Dog', value: 3 },
|
|
344
|
-
],
|
|
345
|
-
{ label: 'Mouse', value: 2 },
|
|
346
|
-
),
|
|
347
|
-
).toBe(1);
|
|
348
|
-
expect(
|
|
349
|
-
getFirstSelectedOptionIndex(
|
|
350
|
-
[
|
|
351
|
-
{ label: 'Cat', value: 1 },
|
|
352
|
-
{ label: 'Mouse', value: 2 },
|
|
353
|
-
{ label: 'Dog', value: 3 },
|
|
354
|
-
],
|
|
355
|
-
{ label: 'Mouse', value: '2' }, //allow coercion
|
|
356
|
-
),
|
|
357
|
-
).toBe(1);
|
|
358
|
-
expect(
|
|
359
|
-
//with headings (should be omitted from index)
|
|
360
|
-
getFirstSelectedOptionIndex(
|
|
361
|
-
[
|
|
362
|
-
{ type: 'Heading', label: 'Enemies' },
|
|
363
|
-
{ label: 'Cat', value: 1 },
|
|
364
|
-
{ type: 'Heading', label: 'Friends' },
|
|
365
|
-
{ label: 'Mouse', value: 2 },
|
|
366
|
-
{ label: 'Dog', value: 3 },
|
|
367
|
-
],
|
|
368
|
-
{ label: 'Mouse', value: '2' }, //allow coercion
|
|
369
|
-
),
|
|
370
|
-
).toBe(1);
|
|
371
|
-
expect(getFirstSelectedOptionIndex(['Cat', 'Mouse', 'Dog'], 'Mouse')).toBe(
|
|
372
|
-
1,
|
|
373
|
-
);
|
|
374
|
-
expect(getFirstSelectedOptionIndex([1, 2, 3], 2)).toBe(1);
|
|
375
|
-
expect(getFirstSelectedOptionIndex([1, 2, 3], '2')).toBe(
|
|
376
|
-
//allow coercion
|
|
377
|
-
1,
|
|
378
|
-
);
|
|
379
|
-
expect(
|
|
380
|
-
getFirstSelectedOptionIndex(['Cat', 'Mouse', 'Dog'], ['Mouse', 'Dog']),
|
|
381
|
-
).toBe(1);
|
|
382
|
-
expect(
|
|
383
|
-
getFirstSelectedOptionIndex(
|
|
384
|
-
[
|
|
385
|
-
{ label: 'Cat', value: 'cat' },
|
|
386
|
-
{ label: 'Mouse', value: 'mouse' },
|
|
387
|
-
{ label: 'Dog', value: 'dog' },
|
|
388
|
-
],
|
|
389
|
-
{ label: 'Camel', value: 'camel' },
|
|
390
|
-
),
|
|
391
|
-
).toBe(null);
|
|
392
|
-
expect(
|
|
393
|
-
getFirstSelectedOptionIndex(
|
|
394
|
-
[
|
|
395
|
-
{ label: 'Cat', value: 'cat' },
|
|
396
|
-
{ label: 'Mouse', value: 'mouse' },
|
|
397
|
-
{ label: 'Dog', value: 'dog' },
|
|
398
|
-
],
|
|
399
|
-
[{ label: 'Camel', value: 'camel' }],
|
|
400
|
-
),
|
|
401
|
-
).toBe(null);
|
|
402
|
-
expect(getFirstSelectedOptionIndex(['Cat', 'Mouse', 'Dog'], 'Camel')).toBe(
|
|
403
|
-
null,
|
|
404
|
-
);
|
|
405
|
-
expect(
|
|
406
|
-
getFirstSelectedOptionIndex(['Cat', 'Mouse', 'Dog'], ['Camel', 'Sheep']),
|
|
407
|
-
).toBe(null);
|
|
408
|
-
expect(getFirstSelectedOptionIndex([], 'Camel')).toBe(null);
|
|
409
|
-
expect(
|
|
410
|
-
getFirstSelectedOptionIndex(
|
|
411
|
-
[
|
|
412
|
-
{ label: 'Cat', value: 'cat' },
|
|
413
|
-
{ label: 'Mouse', value: 'mouse' },
|
|
414
|
-
{ label: 'Dog', value: 'dog' },
|
|
415
|
-
],
|
|
416
|
-
null,
|
|
417
|
-
),
|
|
418
|
-
).toBe(null);
|
|
419
|
-
expect(
|
|
420
|
-
getFirstSelectedOptionIndex(
|
|
421
|
-
[
|
|
422
|
-
{ label: 'Cat', value: 'cat' },
|
|
423
|
-
{ label: 'Mouse', value: 'mouse' },
|
|
424
|
-
{ label: 'Dog', value: 'dog' },
|
|
425
|
-
],
|
|
426
|
-
[],
|
|
427
|
-
),
|
|
428
|
-
).toBe(null);
|
|
429
|
-
expect(
|
|
430
|
-
getFirstSelectedOptionIndex(
|
|
431
|
-
[
|
|
432
|
-
{ label: 'Cat', value: 'cat' },
|
|
433
|
-
{ label: 'Mouse', value: 'mouse' },
|
|
434
|
-
{ label: 'Dog', value: 'dog' },
|
|
435
|
-
],
|
|
436
|
-
undefined,
|
|
437
|
-
),
|
|
438
|
-
).toBe(null);
|
|
439
|
-
});
|
|
440
|
-
|
|
441
|
-
test('non-existent value', () => {
|
|
442
|
-
expect(
|
|
443
|
-
nonExistentValue(
|
|
444
|
-
[
|
|
445
|
-
{ label: 'Cat', value: 'cat' },
|
|
446
|
-
{ label: 'Mouse', value: 'mouse' },
|
|
447
|
-
{ label: 'Dog', value: 'dog' },
|
|
448
|
-
],
|
|
449
|
-
{ label: 'Cat', value: 'cat' },
|
|
450
|
-
),
|
|
451
|
-
).toBe(false);
|
|
452
|
-
expect(
|
|
453
|
-
nonExistentValue(
|
|
454
|
-
[
|
|
455
|
-
{ label: 'Cat', value: 'cat' },
|
|
456
|
-
{ label: 'Mouse', value: 'mouse' },
|
|
457
|
-
{ label: 'Dog', value: 'dog' },
|
|
458
|
-
],
|
|
459
|
-
{ label: 'Vampire', value: 'vampire' },
|
|
460
|
-
),
|
|
461
|
-
).toBe(true);
|
|
462
|
-
expect(
|
|
463
|
-
nonExistentValue(
|
|
464
|
-
[
|
|
465
|
-
{ label: 'Cat', value: 'cat' },
|
|
466
|
-
{ label: 'Mouse', value: 'mouse' },
|
|
467
|
-
{ label: 'Dog', value: 'dog' },
|
|
468
|
-
],
|
|
469
|
-
null,
|
|
470
|
-
),
|
|
471
|
-
).toBe(false);
|
|
472
|
-
expect(
|
|
473
|
-
nonExistentValue(
|
|
474
|
-
[
|
|
475
|
-
{ label: 'Cat', value: 'cat' },
|
|
476
|
-
{ label: 'Mouse', value: 'mouse' },
|
|
477
|
-
{ label: 'Dog', value: 'dog' },
|
|
478
|
-
],
|
|
479
|
-
undefined,
|
|
480
|
-
),
|
|
481
|
-
).toBe(false);
|
|
482
|
-
expect(
|
|
483
|
-
nonExistentValue(
|
|
484
|
-
[
|
|
485
|
-
{ label: 'Cat', value: 'cat' },
|
|
486
|
-
{ label: 'Mouse', value: 'mouse' },
|
|
487
|
-
{ label: 'Dog', value: 'dog' },
|
|
488
|
-
],
|
|
489
|
-
'',
|
|
490
|
-
),
|
|
491
|
-
).toBe(false);
|
|
492
|
-
expect(
|
|
493
|
-
nonExistentValue(
|
|
494
|
-
[
|
|
495
|
-
{ label: 'Cat', value: 'cat' },
|
|
496
|
-
{ label: 'Mouse', value: 'mouse' },
|
|
497
|
-
{ label: 'Dog', value: 'dog' },
|
|
498
|
-
],
|
|
499
|
-
[
|
|
500
|
-
{ label: 'Cat', value: 'cat' },
|
|
501
|
-
{ label: 'Mouse', value: 'mouse' },
|
|
502
|
-
],
|
|
503
|
-
),
|
|
504
|
-
).toBe(false);
|
|
505
|
-
expect(
|
|
506
|
-
nonExistentValue(
|
|
507
|
-
[
|
|
508
|
-
{ label: 'Cat', value: 'cat' },
|
|
509
|
-
{ label: 'Mouse', value: 'mouse' },
|
|
510
|
-
{ label: 'Dog', value: 'dog' },
|
|
511
|
-
],
|
|
512
|
-
[
|
|
513
|
-
{ label: 'Mouse', value: 'mouse' },
|
|
514
|
-
{ label: 'Vampire', value: 'vampire' },
|
|
515
|
-
],
|
|
516
|
-
),
|
|
517
|
-
).toBe(true);
|
|
518
|
-
});
|
|
519
|
-
});
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
@import '../../style/variables.less';
|
|
2
|
-
|
|
3
|
-
.oContent {
|
|
4
|
-
@media print {
|
|
5
|
-
position: absolute;
|
|
6
|
-
left: 0;
|
|
7
|
-
top: 0;
|
|
8
|
-
overflow: visible;
|
|
9
|
-
padding: 0 !important;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
background-color: var(--color-background);
|
|
13
|
-
position: fixed;
|
|
14
|
-
right: 0;
|
|
15
|
-
bottom: 0;
|
|
16
|
-
top: @topbar_height;
|
|
17
|
-
left: @sidebar_width_collapsed;
|
|
18
|
-
display: flex;
|
|
19
|
-
flex-direction: column;
|
|
20
|
-
overflow-y: auto;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
.oContentWithPadding {
|
|
24
|
-
padding: 1.5rem 1.5rem 0 1.5rem;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.oContentNoSideBar {
|
|
28
|
-
left: 0;
|
|
29
|
-
}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import React, { memo } from 'react';
|
|
2
|
-
import cx from 'classnames';
|
|
3
|
-
import isEqual from 'react-fast-compare';
|
|
4
|
-
import styles from './side-bar.module.less';
|
|
5
|
-
import { Tooltip } from '../tooltip/tooltip';
|
|
6
|
-
import { Icon } from '../icon/icon';
|
|
7
|
-
import { Badge } from '../badge/badge';
|
|
8
|
-
import { styleVariables } from '../../helpers/styles';
|
|
9
|
-
|
|
10
|
-
const TooltipIcon = memo(
|
|
11
|
-
({ isOpen, label, icon, invalid }) => {
|
|
12
|
-
const Unbadged = () => (
|
|
13
|
-
<Tooltip
|
|
14
|
-
text={label}
|
|
15
|
-
enabled={!isOpen}
|
|
16
|
-
placement="right-center"
|
|
17
|
-
possiblePlacements={['right-center']}
|
|
18
|
-
triggerOffset={30}
|
|
19
|
-
fontSize={16}
|
|
20
|
-
padding="10px 16px"
|
|
21
|
-
display="block"
|
|
22
|
-
>
|
|
23
|
-
<Icon icon={icon} size={30} color="white" />
|
|
24
|
-
</Tooltip>
|
|
25
|
-
);
|
|
26
|
-
|
|
27
|
-
const Badged = () => (
|
|
28
|
-
<Badge small margin="-2px" color={styleVariables.col_danger} title="!">
|
|
29
|
-
<Unbadged />
|
|
30
|
-
</Badge>
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
return (
|
|
34
|
-
<>
|
|
35
|
-
<span className={styles.icon}>
|
|
36
|
-
{invalid ? <Badged /> : <Unbadged />}
|
|
37
|
-
</span>
|
|
38
|
-
<span className={styles.label}>{label}</span>
|
|
39
|
-
</>
|
|
40
|
-
);
|
|
41
|
-
},
|
|
42
|
-
/*
|
|
43
|
-
Only re-render if props have changed
|
|
44
|
-
Re-rendering tooltips when not necessary causes 'ghost tooltip' issues,
|
|
45
|
-
because re-renders cause mouse events to get swallowed, which prevents
|
|
46
|
-
tooltips closing when the main thread is blocked
|
|
47
|
-
We use a deep equality check because the the label can theoretically be JSX
|
|
48
|
-
*/
|
|
49
|
-
(prevProps, nextProps) => isEqual(prevProps, nextProps),
|
|
50
|
-
);
|
|
51
|
-
|
|
52
|
-
export const Link = ({ isOpen, items, sectionIndex, onClick, testId }) => {
|
|
53
|
-
return (
|
|
54
|
-
<div className={styles.list}>
|
|
55
|
-
{items.map((link, i) => {
|
|
56
|
-
const key = `${sectionIndex}_${i}`;
|
|
57
|
-
return (
|
|
58
|
-
<a
|
|
59
|
-
href={link.value}
|
|
60
|
-
className={cx(
|
|
61
|
-
styles.item,
|
|
62
|
-
link.isActive ? styles.active : '',
|
|
63
|
-
link.isExperimental ? styles.experimental : '',
|
|
64
|
-
)}
|
|
65
|
-
key={key}
|
|
66
|
-
onClick={(evt) =>
|
|
67
|
-
onClick(evt, link.value, link.label, link.onClick)
|
|
68
|
-
}
|
|
69
|
-
data-testid={testId}
|
|
70
|
-
>
|
|
71
|
-
<TooltipIcon
|
|
72
|
-
key={key}
|
|
73
|
-
label={link.label}
|
|
74
|
-
icon={link.icon}
|
|
75
|
-
invalid={link.invalid}
|
|
76
|
-
isOpen={isOpen}
|
|
77
|
-
/>
|
|
78
|
-
</a>
|
|
79
|
-
);
|
|
80
|
-
})}
|
|
81
|
-
</div>
|
|
82
|
-
);
|
|
83
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Link } from './link';
|
|
3
|
-
import styles from './side-bar.module.less';
|
|
4
|
-
|
|
5
|
-
export const Sections = ({ isOpen, sections, onClick }) => {
|
|
6
|
-
return (
|
|
7
|
-
<>
|
|
8
|
-
{sections.map((section, i) => (
|
|
9
|
-
<React.Fragment key={i}>
|
|
10
|
-
<h5 className={styles.subtitle}>{section.heading.toUpperCase()}</h5>
|
|
11
|
-
{/* eslint-disable-next-line jsx-a11y/anchor-is-valid */}
|
|
12
|
-
<Link
|
|
13
|
-
isOpen={isOpen}
|
|
14
|
-
items={section.items}
|
|
15
|
-
sectionindex={i}
|
|
16
|
-
onClick={onClick}
|
|
17
|
-
testId={section.testId}
|
|
18
|
-
/>
|
|
19
|
-
</React.Fragment>
|
|
20
|
-
))}
|
|
21
|
-
</>
|
|
22
|
-
);
|
|
23
|
-
};
|