@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,458 +0,0 @@
|
|
|
1
|
-
import React, { useReducer, useState } from 'react';
|
|
2
|
-
import produce from 'immer';
|
|
3
|
-
import { FaPlus, FaTrash } from 'react-icons/fa';
|
|
4
|
-
import { List, ListHeading, ListSubheading, Flex } from '../../..';
|
|
5
|
-
import * as storyData from './list.stories-data';
|
|
6
|
-
|
|
7
|
-
export default {
|
|
8
|
-
title: 'Basic/List',
|
|
9
|
-
component: List,
|
|
10
|
-
args: {
|
|
11
|
-
list: storyData.list,
|
|
12
|
-
noHeader: true,
|
|
13
|
-
},
|
|
14
|
-
parameters: {
|
|
15
|
-
layout: 'fullscreen',
|
|
16
|
-
},
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const Template = (args) => {
|
|
20
|
-
return (
|
|
21
|
-
<List
|
|
22
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
23
|
-
{...args}
|
|
24
|
-
/>
|
|
25
|
-
);
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export const Default = Template.bind({});
|
|
29
|
-
|
|
30
|
-
export const Actions = Template.bind({});
|
|
31
|
-
Actions.args = { list: storyData.listActions };
|
|
32
|
-
|
|
33
|
-
export const Menus = Template.bind({});
|
|
34
|
-
Menus.args = { list: storyData.listSubmenus };
|
|
35
|
-
|
|
36
|
-
export const Details = Template.bind({});
|
|
37
|
-
Details.args = { list: storyData.listDetails };
|
|
38
|
-
|
|
39
|
-
export const Expanding = Template.bind({});
|
|
40
|
-
Expanding.args = { list: storyData.listExpanding, expanding: true };
|
|
41
|
-
|
|
42
|
-
export const Header = Template.bind({});
|
|
43
|
-
Header.args = { list: storyData.listHeader, noHeader: false };
|
|
44
|
-
|
|
45
|
-
export const Badges = Template.bind({});
|
|
46
|
-
Badges.args = { list: storyData.listBadges };
|
|
47
|
-
|
|
48
|
-
export const Nested = Template.bind({});
|
|
49
|
-
Nested.args = { list: storyData.listNested };
|
|
50
|
-
|
|
51
|
-
export const InvalidItems = Template.bind({});
|
|
52
|
-
InvalidItems.args = { list: storyData.listInvalid };
|
|
53
|
-
|
|
54
|
-
export const Bordered = Template.bind({});
|
|
55
|
-
Bordered.args = { bordered: true };
|
|
56
|
-
|
|
57
|
-
export const IconWithTooltip = Template.bind({});
|
|
58
|
-
IconWithTooltip.args = { list: storyData.listIconTooltip };
|
|
59
|
-
|
|
60
|
-
export const Metacount = Template.bind({});
|
|
61
|
-
Metacount.args = { list: storyData.listCounts };
|
|
62
|
-
|
|
63
|
-
export const StickyHeader = Template.bind({});
|
|
64
|
-
StickyHeader.args = {
|
|
65
|
-
list: storyData.listLong,
|
|
66
|
-
noHeader: false,
|
|
67
|
-
stickyHeader: true,
|
|
68
|
-
};
|
|
69
|
-
StickyHeader.parameters = {
|
|
70
|
-
docs: {
|
|
71
|
-
inlineStories: false,
|
|
72
|
-
iframeHeight: 200,
|
|
73
|
-
},
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
export const Scrollable = Template.bind({});
|
|
77
|
-
Scrollable.args = {
|
|
78
|
-
list: storyData.listLong,
|
|
79
|
-
scrollDetails: {
|
|
80
|
-
scrollable: true,
|
|
81
|
-
},
|
|
82
|
-
};
|
|
83
|
-
Scrollable.parameters = {
|
|
84
|
-
docs: {
|
|
85
|
-
description: {
|
|
86
|
-
story:
|
|
87
|
-
'Adds an internal scrollbar to the `List`, which will fill its parent height unless a `height` is set. The scrollbar can be toggled using `hideScrollbar`.',
|
|
88
|
-
},
|
|
89
|
-
},
|
|
90
|
-
};
|
|
91
|
-
Scrollable.decorators = [
|
|
92
|
-
(story) => <div style={{ height: 200, overflow: 'hidden' }}>{story()}</div>,
|
|
93
|
-
];
|
|
94
|
-
|
|
95
|
-
// TODO: Fix this story in Docs (works in Canvas)
|
|
96
|
-
export const InfiniteScroll = Template.bind({});
|
|
97
|
-
InfiniteScroll.args = {
|
|
98
|
-
list: storyData.listLong,
|
|
99
|
-
scrollDetails: {
|
|
100
|
-
scrollable: true,
|
|
101
|
-
infiniteScroll: true,
|
|
102
|
-
limit: 10,
|
|
103
|
-
},
|
|
104
|
-
};
|
|
105
|
-
InfiniteScroll.decorators = [
|
|
106
|
-
(story) => <div style={{ height: 200, overflow: 'auto' }}>{story()}</div>,
|
|
107
|
-
];
|
|
108
|
-
|
|
109
|
-
export const ScrollToActiveItem = () => {
|
|
110
|
-
const reducer = (state, action) => {
|
|
111
|
-
switch (action.type) {
|
|
112
|
-
case 'headingClicked': {
|
|
113
|
-
const { headingKey } = action.payload;
|
|
114
|
-
return produce(state, (draft) => {
|
|
115
|
-
const heading = draft[headingKey];
|
|
116
|
-
heading.expanded = !heading.expanded;
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
case 'itemClicked': {
|
|
120
|
-
const { headingKey, itemIndex } = action.payload;
|
|
121
|
-
return produce(state, (draft) => {
|
|
122
|
-
Object.keys(draft).forEach((key) => {
|
|
123
|
-
draft[key].items.forEach((item, i) => {
|
|
124
|
-
item.active = key === headingKey && i === itemIndex;
|
|
125
|
-
});
|
|
126
|
-
});
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
case 'addClicked': {
|
|
130
|
-
const { headingKey } = action.payload;
|
|
131
|
-
return produce(state, (draft) => {
|
|
132
|
-
const heading = draft[headingKey];
|
|
133
|
-
heading.expanded = true;
|
|
134
|
-
heading.items.push({
|
|
135
|
-
name: `${heading.label} #${heading.items.length + 1}`,
|
|
136
|
-
});
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
case 'deleteClicked': {
|
|
140
|
-
const { headingKey, itemIndex } = action.payload;
|
|
141
|
-
return produce(state, (draft) => {
|
|
142
|
-
let { items } = draft[headingKey];
|
|
143
|
-
delete items[itemIndex];
|
|
144
|
-
draft[headingKey].items = items.filter((i) => i); //remove empty slots
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
default:
|
|
148
|
-
return state;
|
|
149
|
-
}
|
|
150
|
-
};
|
|
151
|
-
const initialState = () => ({
|
|
152
|
-
mammals: {
|
|
153
|
-
draggable: true,
|
|
154
|
-
name: 'Mammals',
|
|
155
|
-
key: 'mammals',
|
|
156
|
-
label: 'Mammals',
|
|
157
|
-
expanded: true,
|
|
158
|
-
items: [
|
|
159
|
-
{ name: 'Click item to scroll', type: 'Heading' },
|
|
160
|
-
{ name: 'Mammal #1', active: true },
|
|
161
|
-
{ name: 'Mammal #2' },
|
|
162
|
-
{ name: 'Mammal #3' },
|
|
163
|
-
{ name: 'Mammal #4' },
|
|
164
|
-
{ name: 'Mammal #5' },
|
|
165
|
-
{ name: 'Mammal #6' },
|
|
166
|
-
{ name: 'Mammal #7' },
|
|
167
|
-
{ name: 'Mammal #8' },
|
|
168
|
-
{ name: 'Mammal #9' },
|
|
169
|
-
{ name: 'Mammal #10' },
|
|
170
|
-
],
|
|
171
|
-
},
|
|
172
|
-
amphibians: {
|
|
173
|
-
name: 'Amphibians (sticky header)',
|
|
174
|
-
key: 'amphibians',
|
|
175
|
-
label: 'Amphibians',
|
|
176
|
-
expanded: true,
|
|
177
|
-
items: [
|
|
178
|
-
{ name: 'Click item to scroll', type: 'Heading' },
|
|
179
|
-
{ name: 'Amphibian #1', active: true },
|
|
180
|
-
{ name: 'Amphibian #2' },
|
|
181
|
-
{ name: 'Amphibian #3' },
|
|
182
|
-
{ name: 'Amphibian #4' },
|
|
183
|
-
{ name: 'Amphibian #5' },
|
|
184
|
-
{ name: 'Amphibian #6' },
|
|
185
|
-
{ name: 'Amphibian #7' },
|
|
186
|
-
{ name: 'Amphibian #8' },
|
|
187
|
-
{ name: 'Amphibian #9' },
|
|
188
|
-
{ name: 'Amphibian #10' },
|
|
189
|
-
],
|
|
190
|
-
},
|
|
191
|
-
});
|
|
192
|
-
const [state, dispatch] = useReducer(reducer, {}, () => initialState());
|
|
193
|
-
const [triggerScroll, setTriggerScroll] = useState(false);
|
|
194
|
-
const onClickItem = (headingKey, itemIndex) => {
|
|
195
|
-
setTriggerScroll(true);
|
|
196
|
-
dispatch({
|
|
197
|
-
type: 'itemClicked',
|
|
198
|
-
payload: { headingKey, itemIndex },
|
|
199
|
-
});
|
|
200
|
-
// will execute after stack is cleared
|
|
201
|
-
setTimeout(() => setTriggerScroll(false), 0);
|
|
202
|
-
};
|
|
203
|
-
const onAddItem = (headingKey) => {
|
|
204
|
-
dispatch({ type: 'addClicked', payload: { headingKey } });
|
|
205
|
-
};
|
|
206
|
-
const onDeleteItem = (headingKey, itemIndex) =>
|
|
207
|
-
dispatch({
|
|
208
|
-
type: 'deleteClicked',
|
|
209
|
-
payload: { headingKey, itemIndex },
|
|
210
|
-
});
|
|
211
|
-
const { mammals, amphibians } = state;
|
|
212
|
-
const hydrateList = (list) => ({
|
|
213
|
-
...list,
|
|
214
|
-
actions: [
|
|
215
|
-
{
|
|
216
|
-
label: 'Add',
|
|
217
|
-
primary: true,
|
|
218
|
-
icon: <FaPlus />,
|
|
219
|
-
onClick: () => onAddItem(list.key),
|
|
220
|
-
},
|
|
221
|
-
],
|
|
222
|
-
items: list.items.map((item, itemIndex) => {
|
|
223
|
-
if (item.type == 'Heading') {
|
|
224
|
-
return {
|
|
225
|
-
...item,
|
|
226
|
-
id: itemIndex,
|
|
227
|
-
};
|
|
228
|
-
}
|
|
229
|
-
return {
|
|
230
|
-
...item,
|
|
231
|
-
id: itemIndex,
|
|
232
|
-
onClick: () => onClickItem(list.key, itemIndex),
|
|
233
|
-
actions: [
|
|
234
|
-
{
|
|
235
|
-
label: 'Delete',
|
|
236
|
-
icon: <FaTrash />,
|
|
237
|
-
onClick: () => onDeleteItem(list.key, itemIndex),
|
|
238
|
-
},
|
|
239
|
-
],
|
|
240
|
-
};
|
|
241
|
-
}),
|
|
242
|
-
});
|
|
243
|
-
const height = 300;
|
|
244
|
-
return (
|
|
245
|
-
<Flex gap>
|
|
246
|
-
<List
|
|
247
|
-
list={hydrateList(mammals)}
|
|
248
|
-
bordered
|
|
249
|
-
height={height}
|
|
250
|
-
scrollDetails={{
|
|
251
|
-
scrollable: true,
|
|
252
|
-
hideScrollbar: false,
|
|
253
|
-
triggerScrollToActiveItem: triggerScroll,
|
|
254
|
-
}}
|
|
255
|
-
/>
|
|
256
|
-
<List
|
|
257
|
-
list={hydrateList(amphibians)}
|
|
258
|
-
bordered
|
|
259
|
-
stickyHeader
|
|
260
|
-
height={height}
|
|
261
|
-
scrollDetails={{
|
|
262
|
-
scrollable: true,
|
|
263
|
-
hideScrollbar: false,
|
|
264
|
-
triggerScrollToActiveItem: triggerScroll,
|
|
265
|
-
}}
|
|
266
|
-
/>
|
|
267
|
-
</Flex>
|
|
268
|
-
);
|
|
269
|
-
};
|
|
270
|
-
|
|
271
|
-
export const HeadingsManaged = () => {
|
|
272
|
-
const reducer = (state, action) => {
|
|
273
|
-
switch (action.type) {
|
|
274
|
-
case 'headingClicked': {
|
|
275
|
-
const { headingKey } = action.payload;
|
|
276
|
-
return produce(state, (draft) => {
|
|
277
|
-
const heading = draft[headingKey];
|
|
278
|
-
heading.expanded = !heading.expanded;
|
|
279
|
-
});
|
|
280
|
-
}
|
|
281
|
-
case 'itemClicked': {
|
|
282
|
-
const { headingKey, itemIndex } = action.payload;
|
|
283
|
-
return produce(state, (draft) => {
|
|
284
|
-
Object.keys(draft).forEach((key) => {
|
|
285
|
-
draft[key].items.forEach((item, i) => {
|
|
286
|
-
item.active = key === headingKey && i === itemIndex;
|
|
287
|
-
});
|
|
288
|
-
});
|
|
289
|
-
});
|
|
290
|
-
}
|
|
291
|
-
case 'addClicked': {
|
|
292
|
-
const { headingKey } = action.payload;
|
|
293
|
-
return produce(state, (draft) => {
|
|
294
|
-
const heading = draft[headingKey];
|
|
295
|
-
heading.expanded = true;
|
|
296
|
-
heading.items.push({
|
|
297
|
-
name: `${heading.label} #${heading.items.length + 1}`,
|
|
298
|
-
});
|
|
299
|
-
});
|
|
300
|
-
}
|
|
301
|
-
case 'deleteClicked': {
|
|
302
|
-
const { headingKey, itemIndex } = action.payload;
|
|
303
|
-
return produce(state, (draft) => {
|
|
304
|
-
let { items } = draft[headingKey];
|
|
305
|
-
delete items[itemIndex];
|
|
306
|
-
draft[headingKey].items = items.filter((i) => i); //remove empty slots
|
|
307
|
-
});
|
|
308
|
-
}
|
|
309
|
-
default:
|
|
310
|
-
return state;
|
|
311
|
-
}
|
|
312
|
-
};
|
|
313
|
-
const initialState = () => ({
|
|
314
|
-
mammals: {
|
|
315
|
-
key: 'mammals',
|
|
316
|
-
label: 'Mammals',
|
|
317
|
-
expanded: true,
|
|
318
|
-
items: [{ name: 'Aardvark', active: true }, { name: 'Kangaroo' }],
|
|
319
|
-
},
|
|
320
|
-
amphibians: {
|
|
321
|
-
key: 'amphibians',
|
|
322
|
-
label: 'Amphibians',
|
|
323
|
-
expanded: true,
|
|
324
|
-
items: [{ name: 'Frog' }],
|
|
325
|
-
},
|
|
326
|
-
});
|
|
327
|
-
const [state, dispatch] = useReducer(reducer, {}, () => initialState());
|
|
328
|
-
const onClickHeading = (headingKey) =>
|
|
329
|
-
dispatch({ type: 'headingClicked', payload: { headingKey } });
|
|
330
|
-
const onClickItem = (headingKey, itemIndex) =>
|
|
331
|
-
dispatch({
|
|
332
|
-
type: 'itemClicked',
|
|
333
|
-
payload: { headingKey, itemIndex },
|
|
334
|
-
});
|
|
335
|
-
const onAddItem = (headingKey) =>
|
|
336
|
-
dispatch({ type: 'addClicked', payload: { headingKey } });
|
|
337
|
-
const onDeleteItem = (headingKey, itemIndex) =>
|
|
338
|
-
dispatch({
|
|
339
|
-
type: 'deleteClicked',
|
|
340
|
-
payload: { headingKey, itemIndex },
|
|
341
|
-
});
|
|
342
|
-
const { mammals, amphibians } = state;
|
|
343
|
-
const hydrateHeading = (list) => ({
|
|
344
|
-
name: list.label,
|
|
345
|
-
metaCount: list.items.length,
|
|
346
|
-
expanded: list.expanded,
|
|
347
|
-
onClick: () => onClickHeading(list.key),
|
|
348
|
-
actions: [
|
|
349
|
-
{
|
|
350
|
-
label: 'Add',
|
|
351
|
-
primary: true,
|
|
352
|
-
icon: <FaPlus />,
|
|
353
|
-
onClick: () => onAddItem(list.key),
|
|
354
|
-
},
|
|
355
|
-
],
|
|
356
|
-
});
|
|
357
|
-
const hydrateList = (list) => ({
|
|
358
|
-
...list,
|
|
359
|
-
items: list.items.map((item, itemIndex) => ({
|
|
360
|
-
...item,
|
|
361
|
-
id: itemIndex,
|
|
362
|
-
onClick: () => onClickItem(list.key, itemIndex),
|
|
363
|
-
actions: [
|
|
364
|
-
{
|
|
365
|
-
label: 'Delete',
|
|
366
|
-
icon: <FaTrash />,
|
|
367
|
-
onClick: () => onDeleteItem(list.key, itemIndex),
|
|
368
|
-
},
|
|
369
|
-
],
|
|
370
|
-
})),
|
|
371
|
-
});
|
|
372
|
-
return (
|
|
373
|
-
<>
|
|
374
|
-
<ListHeading name="Animals" />
|
|
375
|
-
<ListSubheading item={hydrateHeading(mammals)} />
|
|
376
|
-
{mammals.expanded && <List noHeader list={hydrateList(mammals)} />}
|
|
377
|
-
<ListSubheading item={hydrateHeading(amphibians)} />
|
|
378
|
-
{amphibians.expanded && <List noHeader list={hydrateList(amphibians)} />}
|
|
379
|
-
</>
|
|
380
|
-
);
|
|
381
|
-
};
|
|
382
|
-
|
|
383
|
-
export const ManagedDragAndDrop = () => {
|
|
384
|
-
const arraymove = (arr, from, to) => {
|
|
385
|
-
if (isNaN(from) || isNaN(to) || from === to) {
|
|
386
|
-
return arr;
|
|
387
|
-
}
|
|
388
|
-
const copy = [...arr];
|
|
389
|
-
copy.splice(to, 0, copy.splice(from, 1)[0]);
|
|
390
|
-
return copy;
|
|
391
|
-
};
|
|
392
|
-
const beautifulDnD = {
|
|
393
|
-
name: 'List Name',
|
|
394
|
-
draggable: true,
|
|
395
|
-
items: [
|
|
396
|
-
{
|
|
397
|
-
id: 1,
|
|
398
|
-
name: 'element 1',
|
|
399
|
-
actions: [
|
|
400
|
-
{
|
|
401
|
-
label: 'Delete',
|
|
402
|
-
icon: <FaTrash />,
|
|
403
|
-
onClick: () => {},
|
|
404
|
-
},
|
|
405
|
-
],
|
|
406
|
-
},
|
|
407
|
-
{
|
|
408
|
-
id: 2,
|
|
409
|
-
name: 'element 2',
|
|
410
|
-
actions: [
|
|
411
|
-
{
|
|
412
|
-
label: 'Delete',
|
|
413
|
-
icon: <FaTrash />,
|
|
414
|
-
onClick: () => {},
|
|
415
|
-
},
|
|
416
|
-
],
|
|
417
|
-
},
|
|
418
|
-
{
|
|
419
|
-
id: 3,
|
|
420
|
-
name: 'element 3',
|
|
421
|
-
},
|
|
422
|
-
{
|
|
423
|
-
id: 4,
|
|
424
|
-
name: 'element 4',
|
|
425
|
-
actions: [
|
|
426
|
-
{
|
|
427
|
-
label: 'Delete',
|
|
428
|
-
icon: <FaTrash />,
|
|
429
|
-
onClick: () => {},
|
|
430
|
-
},
|
|
431
|
-
],
|
|
432
|
-
},
|
|
433
|
-
{
|
|
434
|
-
id: 5,
|
|
435
|
-
name: 'element 5',
|
|
436
|
-
actions: [
|
|
437
|
-
{
|
|
438
|
-
label: 'Delete',
|
|
439
|
-
icon: <FaTrash />,
|
|
440
|
-
onClick: () => {},
|
|
441
|
-
},
|
|
442
|
-
],
|
|
443
|
-
},
|
|
444
|
-
],
|
|
445
|
-
};
|
|
446
|
-
const [reorderedItems, setReorderedItems] = useState(beautifulDnD.items);
|
|
447
|
-
const onListReorder = (reorderData) => {
|
|
448
|
-
const { to, from } = reorderData;
|
|
449
|
-
setReorderedItems(arraymove(reorderedItems, from, to));
|
|
450
|
-
};
|
|
451
|
-
return (
|
|
452
|
-
<List
|
|
453
|
-
list={{ ...beautifulDnD, items: reorderedItems }}
|
|
454
|
-
draggable
|
|
455
|
-
onListReorder={onListReorder}
|
|
456
|
-
/>
|
|
457
|
-
);
|
|
458
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { FaChevronLeft } from 'react-icons/fa';
|
|
3
|
-
import { Icon } from '../icon/icon';
|
|
4
|
-
import styles from './list.module.less';
|
|
5
|
-
|
|
6
|
-
export const ToggleNarrow = ({ toggleNarrow, onClickToggleNarrow }) => {
|
|
7
|
-
return toggleNarrow ? (
|
|
8
|
-
// eslint-disable-next-line jsx-a11y/anchor-is-valid
|
|
9
|
-
<a className={styles.toggleNarrow} onClick={onClickToggleNarrow}>
|
|
10
|
-
<Icon icon={<FaChevronLeft />} />
|
|
11
|
-
</a>
|
|
12
|
-
) : null;
|
|
13
|
-
};
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import cx from 'classnames';
|
|
4
|
-
import styles from './loader.module.less';
|
|
5
|
-
|
|
6
|
-
export const Loader = ({
|
|
7
|
-
width,
|
|
8
|
-
height,
|
|
9
|
-
text,
|
|
10
|
-
details,
|
|
11
|
-
fullViewPortSize,
|
|
12
|
-
cover,
|
|
13
|
-
children,
|
|
14
|
-
theme,
|
|
15
|
-
}) => {
|
|
16
|
-
const color = theme === 'dark' ? 'white' : 'inherit';
|
|
17
|
-
|
|
18
|
-
const background =
|
|
19
|
-
theme === 'white'
|
|
20
|
-
? 'var(--color-background-raised)'
|
|
21
|
-
: theme === 'light'
|
|
22
|
-
? 'var(--color-background)'
|
|
23
|
-
: 'black';
|
|
24
|
-
|
|
25
|
-
return (
|
|
26
|
-
<div
|
|
27
|
-
className={cx(styles.loader, cover ? styles.cover : '', {
|
|
28
|
-
[styles.fullViewPortSize]: fullViewPortSize,
|
|
29
|
-
})}
|
|
30
|
-
style={{ width, height }}
|
|
31
|
-
>
|
|
32
|
-
<div className={styles.dimmer} style={{ background, color }}>
|
|
33
|
-
<div className={styles.content}>
|
|
34
|
-
{children}
|
|
35
|
-
{text !== '' && <div className={styles.text}>{text}</div>}
|
|
36
|
-
{details !== '' && <div className={styles.details}>{details}</div>}
|
|
37
|
-
</div>
|
|
38
|
-
</div>
|
|
39
|
-
</div>
|
|
40
|
-
);
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
Loader.defaultProps = {
|
|
44
|
-
fullViewPortSize: false,
|
|
45
|
-
cover: false,
|
|
46
|
-
width: null,
|
|
47
|
-
height: null,
|
|
48
|
-
text: '',
|
|
49
|
-
details: '',
|
|
50
|
-
children: null,
|
|
51
|
-
theme: 'dark',
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
Loader.propTypes = {
|
|
55
|
-
fullViewPortSize: PropTypes.bool,
|
|
56
|
-
cover: PropTypes.bool,
|
|
57
|
-
width: PropTypes.string,
|
|
58
|
-
height: PropTypes.string,
|
|
59
|
-
text: PropTypes.string,
|
|
60
|
-
details: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
|
61
|
-
children: PropTypes.node,
|
|
62
|
-
theme: PropTypes.string,
|
|
63
|
-
};
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
@import '../../style/variables.less';
|
|
2
|
-
|
|
3
|
-
.loader {
|
|
4
|
-
width: 100%;
|
|
5
|
-
height: 100%;
|
|
6
|
-
position: relative;
|
|
7
|
-
border-radius: inherit;
|
|
8
|
-
|
|
9
|
-
&.fullViewPortSize {
|
|
10
|
-
position: absolute;
|
|
11
|
-
top: 0;
|
|
12
|
-
left: 0;
|
|
13
|
-
width: 100vw;
|
|
14
|
-
height: 100vh;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
&.cover {
|
|
18
|
-
position: absolute;
|
|
19
|
-
top: 0;
|
|
20
|
-
left: 0;
|
|
21
|
-
bottom: 0;
|
|
22
|
-
right: 0;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
.dimmer {
|
|
27
|
-
position: absolute;
|
|
28
|
-
top: 0;
|
|
29
|
-
left: 0;
|
|
30
|
-
width: 100%;
|
|
31
|
-
height: 100%;
|
|
32
|
-
text-align: center;
|
|
33
|
-
vertical-align: middle;
|
|
34
|
-
padding: 1em;
|
|
35
|
-
opacity: 0;
|
|
36
|
-
line-height: 1;
|
|
37
|
-
animation-fill-mode: both;
|
|
38
|
-
animation-duration: 0.5s;
|
|
39
|
-
transition: background-color 0.5s linear;
|
|
40
|
-
flex-direction: column;
|
|
41
|
-
align-items: center;
|
|
42
|
-
justify-content: center;
|
|
43
|
-
user-select: none;
|
|
44
|
-
will-change: opacity;
|
|
45
|
-
z-index: @zindex_dimmer;
|
|
46
|
-
display: flex;
|
|
47
|
-
opacity: 0.95;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
.content {
|
|
51
|
-
display: flex;
|
|
52
|
-
flex-direction: column;
|
|
53
|
-
align-items: center;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
.text {
|
|
57
|
-
margin-top: 12px;
|
|
58
|
-
opacity: 0.6;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
.details {
|
|
62
|
-
margin-top: 8px;
|
|
63
|
-
}
|