@oliasoft-open-source/react-ui-library 2.4.8 → 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 -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,759 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useState } from 'react';
|
|
2
|
-
import { FaMinus, FaPlus } from 'react-icons/fa';
|
|
3
|
-
import {
|
|
4
|
-
Table,
|
|
5
|
-
Card,
|
|
6
|
-
Heading,
|
|
7
|
-
Field,
|
|
8
|
-
Button,
|
|
9
|
-
Input,
|
|
10
|
-
Text,
|
|
11
|
-
Flex,
|
|
12
|
-
} from '../../..';
|
|
13
|
-
import * as storyData from './table.stories-data';
|
|
14
|
-
|
|
15
|
-
export default {
|
|
16
|
-
title: 'Basic/Table',
|
|
17
|
-
component: Table,
|
|
18
|
-
args: {
|
|
19
|
-
table: {
|
|
20
|
-
...storyData.table,
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const Template = (args) => {
|
|
26
|
-
return (
|
|
27
|
-
<Table
|
|
28
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
29
|
-
{...args}
|
|
30
|
-
/>
|
|
31
|
-
);
|
|
32
|
-
};
|
|
33
|
-
export const Default = Template.bind({});
|
|
34
|
-
|
|
35
|
-
export const Units = Template.bind({});
|
|
36
|
-
Units.args = {
|
|
37
|
-
table: storyData.tableUnits,
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export const ActiveRow = Template.bind({});
|
|
41
|
-
ActiveRow.args = {
|
|
42
|
-
table: storyData.tableActiveRow,
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export const MinimumColumnWidths = Template.bind({});
|
|
46
|
-
MinimumColumnWidths.args = {
|
|
47
|
-
table: storyData.tableColumnWidths,
|
|
48
|
-
};
|
|
49
|
-
MinimumColumnWidths.parameters = {
|
|
50
|
-
docs: {
|
|
51
|
-
description: {
|
|
52
|
-
story:
|
|
53
|
-
'Use sparingly when certain columns cannot be below a certain width. Make sure at least one column is set to `auto` to use remaining space.',
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
export const Colspan = Template.bind({});
|
|
59
|
-
Colspan.args = {
|
|
60
|
-
table: storyData.tableColspan,
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
export const ColspanWithWidths = Template.bind({});
|
|
64
|
-
ColspanWithWidths.args = { table: storyData.tableColspanWidths };
|
|
65
|
-
|
|
66
|
-
export const ColumnAlignment = Template.bind({});
|
|
67
|
-
ColumnAlignment.args = {
|
|
68
|
-
table: storyData.tableAlignment,
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
export const Editable = Template.bind({});
|
|
72
|
-
Editable.args = {
|
|
73
|
-
table: storyData.tableEditable,
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
export const StickyHeaders = Template.bind({});
|
|
77
|
-
StickyHeaders.args = {
|
|
78
|
-
table: storyData.tableStickyHeaders,
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
export const InfiniteScrollFixedHeight = Template.bind({});
|
|
82
|
-
InfiniteScrollFixedHeight.args = {
|
|
83
|
-
table: storyData.tableInfiniteScroll,
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
export const InfiniteScrollFullHeight = Template.bind({});
|
|
87
|
-
InfiniteScrollFullHeight.args = {
|
|
88
|
-
table: storyData.tableInfiniteScrollFullHeight,
|
|
89
|
-
};
|
|
90
|
-
InfiniteScrollFullHeight.decorators = [
|
|
91
|
-
(Story) => (
|
|
92
|
-
<div style={{ height: 800 }}>
|
|
93
|
-
<Story />
|
|
94
|
-
</div>
|
|
95
|
-
),
|
|
96
|
-
];
|
|
97
|
-
|
|
98
|
-
export const InfiniteScrollShort = Template.bind({});
|
|
99
|
-
InfiniteScrollShort.args = {
|
|
100
|
-
table: storyData.tableInfiniteScrollShort,
|
|
101
|
-
};
|
|
102
|
-
InfiniteScrollShort.parameters = {
|
|
103
|
-
docs: {
|
|
104
|
-
description: {
|
|
105
|
-
story:
|
|
106
|
-
'If a `maxHeight` is set, the table should only fill that height if it needs to.',
|
|
107
|
-
},
|
|
108
|
-
},
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
export const InfiniteScrollWithDragAndDrop = Template.bind({});
|
|
112
|
-
InfiniteScrollWithDragAndDrop.args = {
|
|
113
|
-
table: storyData.tableInfiniteScrollDnD,
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
export const Title = Template.bind({});
|
|
117
|
-
Title.args = {
|
|
118
|
-
table: storyData.tableTitle,
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
export const Filter = Template.bind({});
|
|
122
|
-
Filter.args = {
|
|
123
|
-
table: storyData.tableFilters,
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
export const Sort = Template.bind({});
|
|
127
|
-
Sort.args = {
|
|
128
|
-
table: storyData.tableSort,
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
export const Icons = Template.bind({});
|
|
132
|
-
Icons.args = {
|
|
133
|
-
table: storyData.tableIcons,
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
export const Actions = Template.bind({});
|
|
137
|
-
Actions.args = {
|
|
138
|
-
table: storyData.tableActions,
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
export const Menus = Template.bind({});
|
|
142
|
-
Menus.args = {
|
|
143
|
-
table: storyData.tableWithSubActions,
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
export const RowFocusEvent = Template.bind({});
|
|
147
|
-
RowFocusEvent.args = {
|
|
148
|
-
table: storyData.tableRowFocus,
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
export const DragAndDrop = () => {
|
|
152
|
-
const withDragAndDrop = {
|
|
153
|
-
draggable: true,
|
|
154
|
-
headers: [
|
|
155
|
-
{
|
|
156
|
-
cells: [
|
|
157
|
-
{ value: 'Name' },
|
|
158
|
-
{ value: 'Weight (kg)' },
|
|
159
|
-
{ value: 'Energy (kcal / 100g)' },
|
|
160
|
-
{ value: 'Origin' },
|
|
161
|
-
],
|
|
162
|
-
},
|
|
163
|
-
],
|
|
164
|
-
rows: [
|
|
165
|
-
{
|
|
166
|
-
noDrag: true,
|
|
167
|
-
cells: [
|
|
168
|
-
{ value: 'Undraggable' },
|
|
169
|
-
{ value: 100 },
|
|
170
|
-
{ value: 361 },
|
|
171
|
-
{ value: 'Vietnam' },
|
|
172
|
-
],
|
|
173
|
-
},
|
|
174
|
-
{
|
|
175
|
-
cells: [
|
|
176
|
-
{ value: 'Buckwheat' },
|
|
177
|
-
{ value: 50 },
|
|
178
|
-
{ value: 358 },
|
|
179
|
-
{ value: 'Poland' },
|
|
180
|
-
],
|
|
181
|
-
},
|
|
182
|
-
{
|
|
183
|
-
cells: [
|
|
184
|
-
{ value: 'Couscous' },
|
|
185
|
-
{ value: 10 },
|
|
186
|
-
{ value: 368 },
|
|
187
|
-
{ value: 'France' },
|
|
188
|
-
],
|
|
189
|
-
},
|
|
190
|
-
],
|
|
191
|
-
};
|
|
192
|
-
const arraymove = (arr, from, to) => {
|
|
193
|
-
const copy = [...arr];
|
|
194
|
-
if (arr[to].noDrag) {
|
|
195
|
-
return arr;
|
|
196
|
-
}
|
|
197
|
-
copy.splice(to, 0, copy.splice(from, 1)[0]);
|
|
198
|
-
return copy;
|
|
199
|
-
};
|
|
200
|
-
const [rows, setRows] = useState(withDragAndDrop.rows);
|
|
201
|
-
const onListReorder = (reorderData) => {
|
|
202
|
-
const { to, from } = reorderData;
|
|
203
|
-
arraymove(rows, from, to);
|
|
204
|
-
setRows(arraymove(rows, from, to));
|
|
205
|
-
};
|
|
206
|
-
return (
|
|
207
|
-
<Table table={{ ...withDragAndDrop, rows }} onListReorder={onListReorder} />
|
|
208
|
-
);
|
|
209
|
-
};
|
|
210
|
-
|
|
211
|
-
export const ChildComponent = Template.bind({});
|
|
212
|
-
ChildComponent.args = {
|
|
213
|
-
table: storyData.tableChildComponent,
|
|
214
|
-
};
|
|
215
|
-
|
|
216
|
-
export const JSXContent = Template.bind({});
|
|
217
|
-
JSXContent.args = {
|
|
218
|
-
table: storyData.tableJsxContent,
|
|
219
|
-
};
|
|
220
|
-
|
|
221
|
-
export const Footer = Template.bind({});
|
|
222
|
-
Footer.args = {
|
|
223
|
-
table: storyData.tableFooter,
|
|
224
|
-
};
|
|
225
|
-
|
|
226
|
-
export const InCard = () => (
|
|
227
|
-
<Card heading={<Heading>Card heading</Heading>} padding={false}>
|
|
228
|
-
<Table table={{ ...storyData.table, bordered: false }} />
|
|
229
|
-
</Card>
|
|
230
|
-
);
|
|
231
|
-
InCard.parameters = {
|
|
232
|
-
docs: { source: { type: 'dynamic' } },
|
|
233
|
-
};
|
|
234
|
-
|
|
235
|
-
export const NotStriped = Template.bind({});
|
|
236
|
-
NotStriped.args = {
|
|
237
|
-
table: {
|
|
238
|
-
...storyData.table,
|
|
239
|
-
striped: false,
|
|
240
|
-
},
|
|
241
|
-
};
|
|
242
|
-
NotStriped.parameters = {
|
|
243
|
-
docs: {
|
|
244
|
-
description: {
|
|
245
|
-
story: '`striped: false` removes tinted background on alternative rows.',
|
|
246
|
-
},
|
|
247
|
-
},
|
|
248
|
-
};
|
|
249
|
-
|
|
250
|
-
export const StaticCellTooltips = Template.bind({});
|
|
251
|
-
StaticCellTooltips.args = {
|
|
252
|
-
table: storyData.tableStaticTooltips,
|
|
253
|
-
};
|
|
254
|
-
|
|
255
|
-
export const WordbreakLongContent = Template.bind({});
|
|
256
|
-
WordbreakLongContent.args = {
|
|
257
|
-
table: storyData.tableBreakLongContent,
|
|
258
|
-
};
|
|
259
|
-
WordbreakLongContent.parameters = {
|
|
260
|
-
docs: {
|
|
261
|
-
description: {
|
|
262
|
-
story:
|
|
263
|
-
'Setting `breakWord: true` on a cell will allow very long text strings to break',
|
|
264
|
-
},
|
|
265
|
-
},
|
|
266
|
-
};
|
|
267
|
-
|
|
268
|
-
export const HelpAndLibraryIcons = Template.bind({});
|
|
269
|
-
HelpAndLibraryIcons.args = {
|
|
270
|
-
table: storyData.tableHelpLibraryIcons,
|
|
271
|
-
};
|
|
272
|
-
|
|
273
|
-
export const Expandable = () => {
|
|
274
|
-
const [expandedRow, setExpandedRow] = useState(null);
|
|
275
|
-
const toggleExpandedRow = (rowIndex) =>
|
|
276
|
-
expandedRow === rowIndex ? setExpandedRow(null) : setExpandedRow(rowIndex);
|
|
277
|
-
return (
|
|
278
|
-
<Table
|
|
279
|
-
table={{
|
|
280
|
-
...storyData.table,
|
|
281
|
-
rows: storyData.table.rows.map((row, index) => ({
|
|
282
|
-
...row,
|
|
283
|
-
onRowClick: () => toggleExpandedRow(index),
|
|
284
|
-
expandedContent: {
|
|
285
|
-
content:
|
|
286
|
-
expandedRow === index ? (
|
|
287
|
-
<div>Example expanded content</div>
|
|
288
|
-
) : null,
|
|
289
|
-
},
|
|
290
|
-
})),
|
|
291
|
-
}}
|
|
292
|
-
/>
|
|
293
|
-
);
|
|
294
|
-
};
|
|
295
|
-
|
|
296
|
-
export const Popover = () => {
|
|
297
|
-
const headings = ['Section', 'Width', 'Height'];
|
|
298
|
-
let units = ['', 'm', 'm'];
|
|
299
|
-
let data = [...Array(10).keys()].map((c, i) => [i, i * 2, i * 2]);
|
|
300
|
-
/*
|
|
301
|
-
Mock table data store (real apps should use Redux or similar)
|
|
302
|
-
*/
|
|
303
|
-
const PopoverTable = () => {
|
|
304
|
-
const CellInputForm = ({ close, value }) => (
|
|
305
|
-
<>
|
|
306
|
-
<Field label="Input">
|
|
307
|
-
<Input value={value} width="100%" />
|
|
308
|
-
</Field>
|
|
309
|
-
<Flex gap>
|
|
310
|
-
<Button colored label="Save" onClick={() => {}} />
|
|
311
|
-
<Button label="Cancel" onClick={close} />
|
|
312
|
-
</Flex>
|
|
313
|
-
</>
|
|
314
|
-
);
|
|
315
|
-
const table = {
|
|
316
|
-
fixedWidth: '100%',
|
|
317
|
-
headers: [
|
|
318
|
-
{
|
|
319
|
-
cells: headings.map((h) => ({ value: h })),
|
|
320
|
-
},
|
|
321
|
-
{
|
|
322
|
-
cells: [
|
|
323
|
-
{},
|
|
324
|
-
{
|
|
325
|
-
menu: [
|
|
326
|
-
{ label: 'm', value: 'm' },
|
|
327
|
-
{ label: 'ft', value: 'ft' },
|
|
328
|
-
],
|
|
329
|
-
value: units[1],
|
|
330
|
-
type: 'Unit',
|
|
331
|
-
},
|
|
332
|
-
{
|
|
333
|
-
menu: [
|
|
334
|
-
{ label: 'm', value: 'm' },
|
|
335
|
-
{ label: 'ft', value: 'ft' },
|
|
336
|
-
],
|
|
337
|
-
value: units[2],
|
|
338
|
-
type: 'Unit',
|
|
339
|
-
},
|
|
340
|
-
],
|
|
341
|
-
},
|
|
342
|
-
],
|
|
343
|
-
rows: data.map((row, i) => {
|
|
344
|
-
return {
|
|
345
|
-
cells: [...Array(3).keys()].map((c, i) => ({
|
|
346
|
-
//https://stackoverflow.com/a/33352604
|
|
347
|
-
value: row[i],
|
|
348
|
-
type: 'Popover',
|
|
349
|
-
content: <CellInputForm value={row[i]} />,
|
|
350
|
-
})),
|
|
351
|
-
};
|
|
352
|
-
}),
|
|
353
|
-
};
|
|
354
|
-
return <Table table={table} />;
|
|
355
|
-
};
|
|
356
|
-
return <PopoverTable />;
|
|
357
|
-
};
|
|
358
|
-
|
|
359
|
-
export const SinglePopoverAtOnce = () => {
|
|
360
|
-
const headings = ['Section', 'Width', 'Height'];
|
|
361
|
-
let units = ['', 'm', 'm'];
|
|
362
|
-
let data = [...Array(10).keys()].map((c, i) => [i, i * 2, i * 2]);
|
|
363
|
-
/*
|
|
364
|
-
Mock table data store (real apps should use Redux or similar)
|
|
365
|
-
*/
|
|
366
|
-
const SinglePopoverOpenedTable = () => {
|
|
367
|
-
const [isPopOverCellOpened, setIsPopOverCellOpened] = useState(false);
|
|
368
|
-
const CellInputForm = ({ close, value }) => {
|
|
369
|
-
useEffect(() => {
|
|
370
|
-
if (!isPopOverCellOpened) {
|
|
371
|
-
setIsPopOverCellOpened(true);
|
|
372
|
-
}
|
|
373
|
-
}, []);
|
|
374
|
-
const onClosePopOver = () => {
|
|
375
|
-
setIsPopOverCellOpened(false);
|
|
376
|
-
close();
|
|
377
|
-
};
|
|
378
|
-
return (
|
|
379
|
-
<>
|
|
380
|
-
<Field label="Input">
|
|
381
|
-
<Input value={value} width="100%" />
|
|
382
|
-
</Field>
|
|
383
|
-
<Flex gap>
|
|
384
|
-
<Button colored label="Save" onClick={onClosePopOver} />
|
|
385
|
-
<Button label="Cancel" onClick={onClosePopOver} />
|
|
386
|
-
</Flex>
|
|
387
|
-
</>
|
|
388
|
-
);
|
|
389
|
-
};
|
|
390
|
-
const table = {
|
|
391
|
-
headers: [
|
|
392
|
-
{
|
|
393
|
-
cells: headings.map((h) => ({ value: h })),
|
|
394
|
-
},
|
|
395
|
-
{
|
|
396
|
-
cells: [
|
|
397
|
-
{},
|
|
398
|
-
{
|
|
399
|
-
menu: [
|
|
400
|
-
{ label: 'm', value: 'm' },
|
|
401
|
-
{ label: 'ft', value: 'ft' },
|
|
402
|
-
],
|
|
403
|
-
value: units[1],
|
|
404
|
-
type: 'Unit',
|
|
405
|
-
},
|
|
406
|
-
{
|
|
407
|
-
menu: [
|
|
408
|
-
{ label: 'm', value: 'm' },
|
|
409
|
-
{ label: 'ft', value: 'ft' },
|
|
410
|
-
],
|
|
411
|
-
value: units[2],
|
|
412
|
-
type: 'Unit',
|
|
413
|
-
},
|
|
414
|
-
],
|
|
415
|
-
},
|
|
416
|
-
],
|
|
417
|
-
rows: data.map((row, i) => {
|
|
418
|
-
return {
|
|
419
|
-
cells: [...Array(3).keys()].map((c, i) => ({
|
|
420
|
-
//https://stackoverflow.com/a/33352604
|
|
421
|
-
value: row[i],
|
|
422
|
-
type: 'Popover',
|
|
423
|
-
disabled: isPopOverCellOpened,
|
|
424
|
-
closeOnOutsideClick: false,
|
|
425
|
-
content: <CellInputForm value={row[i]} />,
|
|
426
|
-
})),
|
|
427
|
-
};
|
|
428
|
-
}),
|
|
429
|
-
};
|
|
430
|
-
return <Table table={table} />;
|
|
431
|
-
};
|
|
432
|
-
return <SinglePopoverOpenedTable />;
|
|
433
|
-
};
|
|
434
|
-
|
|
435
|
-
export const Managed = () => {
|
|
436
|
-
/*
|
|
437
|
-
Mock table data store (real apps should use Redux or similar)
|
|
438
|
-
*/
|
|
439
|
-
const headings = ['Section', 'Width', 'Height'];
|
|
440
|
-
let units = ['', 'm', 'm'];
|
|
441
|
-
let data = [...Array(175).keys()].map((c, i) => [i, i * 2, i * 2]);
|
|
442
|
-
/*
|
|
443
|
-
Mock table data actions (real apps should use Redux or similar)
|
|
444
|
-
*/
|
|
445
|
-
const convertUnit = (fromUnit, toUnit, value) => {
|
|
446
|
-
return fromUnit === 'm' && toUnit === 'ft'
|
|
447
|
-
? value * 3.28084
|
|
448
|
-
: fromUnit === 'ft' && toUnit === 'm'
|
|
449
|
-
? value / 3.28084
|
|
450
|
-
: value;
|
|
451
|
-
};
|
|
452
|
-
const onChangeValue = (evt, rowIndex, cellIndex, render) => {
|
|
453
|
-
data[rowIndex][cellIndex] = evt.target.value;
|
|
454
|
-
render();
|
|
455
|
-
};
|
|
456
|
-
const onAddRow = (render) => {
|
|
457
|
-
data = data.concat([['', '', '']]);
|
|
458
|
-
render();
|
|
459
|
-
};
|
|
460
|
-
const onDeleteRow = (rowIndex, render) => {
|
|
461
|
-
data = data.filter((r, i) => i !== rowIndex);
|
|
462
|
-
render();
|
|
463
|
-
};
|
|
464
|
-
const onChangeUnit = (evt, columnIndex, render) => {
|
|
465
|
-
const fromUnit = units[columnIndex];
|
|
466
|
-
const toUnit = evt.target.value;
|
|
467
|
-
units = units.map((u, i) => (i === columnIndex ? toUnit : u));
|
|
468
|
-
data = data.map((r) =>
|
|
469
|
-
r.map((c, i) =>
|
|
470
|
-
i === columnIndex ? convertUnit(fromUnit, toUnit, c) : c,
|
|
471
|
-
),
|
|
472
|
-
);
|
|
473
|
-
render();
|
|
474
|
-
};
|
|
475
|
-
/*
|
|
476
|
-
Container component manages state and configuration of table
|
|
477
|
-
*/
|
|
478
|
-
const ManagedTable = () => {
|
|
479
|
-
const rowsPerPageOptions = [
|
|
480
|
-
{ label: '10 / page', value: 10 },
|
|
481
|
-
{ label: '20 / page', value: 20 },
|
|
482
|
-
{ label: '50 / page', value: 50 },
|
|
483
|
-
{ label: 'Show all', value: 0 },
|
|
484
|
-
];
|
|
485
|
-
const [rowsPerPage, setRowsPerPage] = useState(10);
|
|
486
|
-
const [selectedPage, setSelectedPage] = useState(1);
|
|
487
|
-
//hack to make Storybook re-render after event handlers alter data
|
|
488
|
-
//only using this because example does not manage data with Redux / props
|
|
489
|
-
const [toggle, forceRender] = useState(false);
|
|
490
|
-
const render = () => {
|
|
491
|
-
forceRender(!toggle);
|
|
492
|
-
};
|
|
493
|
-
const goToLastPage = () => {
|
|
494
|
-
const lastPage = Math.ceil(data.length / rowsPerPage);
|
|
495
|
-
setSelectedPage(lastPage);
|
|
496
|
-
};
|
|
497
|
-
const firstVisibleRow = (selectedPage - 1) * rowsPerPage;
|
|
498
|
-
const lastVisibleRow =
|
|
499
|
-
rowsPerPage === 0 ? data.length - 1 : firstVisibleRow + rowsPerPage;
|
|
500
|
-
const table = {
|
|
501
|
-
headers: [
|
|
502
|
-
{
|
|
503
|
-
cells: headings.map((h) => ({ value: h })),
|
|
504
|
-
actions: [
|
|
505
|
-
{
|
|
506
|
-
primary: true,
|
|
507
|
-
label: 'Add',
|
|
508
|
-
icon: <FaPlus />,
|
|
509
|
-
onClick: () => {
|
|
510
|
-
onAddRow(render);
|
|
511
|
-
goToLastPage();
|
|
512
|
-
},
|
|
513
|
-
},
|
|
514
|
-
],
|
|
515
|
-
},
|
|
516
|
-
{
|
|
517
|
-
cells: [
|
|
518
|
-
{},
|
|
519
|
-
{
|
|
520
|
-
options: [
|
|
521
|
-
{ label: 'm', value: 'm' },
|
|
522
|
-
{ label: 'ft', value: 'ft' },
|
|
523
|
-
],
|
|
524
|
-
value: units[1],
|
|
525
|
-
type: 'Select',
|
|
526
|
-
native: true,
|
|
527
|
-
onChange: (evt) => onChangeUnit(evt, 1, render),
|
|
528
|
-
},
|
|
529
|
-
{
|
|
530
|
-
options: [
|
|
531
|
-
{ label: 'm', value: 'm' },
|
|
532
|
-
{ label: 'ft', value: 'ft' },
|
|
533
|
-
],
|
|
534
|
-
value: units[2],
|
|
535
|
-
type: 'Select',
|
|
536
|
-
native: true,
|
|
537
|
-
onChange: (evt) => onChangeUnit(evt, 2, render),
|
|
538
|
-
},
|
|
539
|
-
],
|
|
540
|
-
},
|
|
541
|
-
],
|
|
542
|
-
rows: data.slice(firstVisibleRow, lastVisibleRow).map((row, i) => {
|
|
543
|
-
const rowIndex = firstVisibleRow + i;
|
|
544
|
-
return {
|
|
545
|
-
cells: [...Array(3).keys()].map((c, i) => ({
|
|
546
|
-
//https://stackoverflow.com/a/33352604
|
|
547
|
-
value: row[i],
|
|
548
|
-
type: 'Input',
|
|
549
|
-
onChange: (evt) => onChangeValue(evt, rowIndex, i, render),
|
|
550
|
-
})),
|
|
551
|
-
actions: [
|
|
552
|
-
{
|
|
553
|
-
label: 'Delete',
|
|
554
|
-
icon: <FaMinus />,
|
|
555
|
-
onClick: () => onDeleteRow(rowIndex, render),
|
|
556
|
-
},
|
|
557
|
-
],
|
|
558
|
-
};
|
|
559
|
-
}),
|
|
560
|
-
footer: {
|
|
561
|
-
pagination: {
|
|
562
|
-
rowCount: data.length,
|
|
563
|
-
selectedPage,
|
|
564
|
-
rowsPerPage: {
|
|
565
|
-
onChange: (evt) => {
|
|
566
|
-
const { value } = evt.target;
|
|
567
|
-
setRowsPerPage(Number(value));
|
|
568
|
-
},
|
|
569
|
-
options: rowsPerPageOptions,
|
|
570
|
-
value: rowsPerPage,
|
|
571
|
-
},
|
|
572
|
-
onSelectPage: (evt) => setSelectedPage(evt),
|
|
573
|
-
small: true,
|
|
574
|
-
},
|
|
575
|
-
},
|
|
576
|
-
};
|
|
577
|
-
return <Table table={table} />;
|
|
578
|
-
};
|
|
579
|
-
return <ManagedTable />;
|
|
580
|
-
};
|
|
581
|
-
|
|
582
|
-
export const ManagedWithFilterAndSort = () => {
|
|
583
|
-
/*
|
|
584
|
-
Mock table data store (real apps should use Redux or similar)
|
|
585
|
-
*/
|
|
586
|
-
const headings = ['Section', 'Width', 'Height'];
|
|
587
|
-
let keyedData = [...Array(175).keys()].map((_c, i) => ({
|
|
588
|
-
Section: i,
|
|
589
|
-
Width: i * 2,
|
|
590
|
-
Height: i * 2,
|
|
591
|
-
}));
|
|
592
|
-
/*
|
|
593
|
-
Container component manages state and configuration of table
|
|
594
|
-
*/
|
|
595
|
-
const TableWithSortAndFilter = () => {
|
|
596
|
-
const rowsPerPageOptions = [
|
|
597
|
-
{ label: '10 / page', value: 10 },
|
|
598
|
-
{ label: '20 / page', value: 20 },
|
|
599
|
-
{ label: '50 / page', value: 50 },
|
|
600
|
-
{ label: 'Show all', value: 0 },
|
|
601
|
-
];
|
|
602
|
-
const [rowsPerPage, setRowsPerPage] = useState(10);
|
|
603
|
-
const [selectedPage, setSelectedPage] = useState(1);
|
|
604
|
-
const [filters, setFilters] = useState({});
|
|
605
|
-
const [sorts, setSorts] = useState({});
|
|
606
|
-
useEffect(() => {
|
|
607
|
-
setSelectedPage(1);
|
|
608
|
-
}, [filters, sorts]);
|
|
609
|
-
const firstVisibleRow = (selectedPage - 1) * rowsPerPage;
|
|
610
|
-
const lastVisibleRow =
|
|
611
|
-
rowsPerPage === 0 ? keyedData.length - 1 : firstVisibleRow + rowsPerPage;
|
|
612
|
-
const filterAndSortDataRows = (dataRows, filters, sorts) =>
|
|
613
|
-
dataRows
|
|
614
|
-
.filter((row) =>
|
|
615
|
-
Object.keys(filters).every((key) => {
|
|
616
|
-
return filters[key] === ''
|
|
617
|
-
? true
|
|
618
|
-
: row[key].toString().includes(filters[key]);
|
|
619
|
-
}),
|
|
620
|
-
)
|
|
621
|
-
.sort((a, b) =>
|
|
622
|
-
Object.entries(sorts)
|
|
623
|
-
.map(([key, value]) => {
|
|
624
|
-
switch (value) {
|
|
625
|
-
case 'up': {
|
|
626
|
-
return a[key] - b[key];
|
|
627
|
-
}
|
|
628
|
-
case 'down': {
|
|
629
|
-
return b[key] - a[key];
|
|
630
|
-
}
|
|
631
|
-
default:
|
|
632
|
-
return 0;
|
|
633
|
-
}
|
|
634
|
-
})
|
|
635
|
-
.reduce((a, acc) => a || acc, 0),
|
|
636
|
-
);
|
|
637
|
-
const dataHeaders = (
|
|
638
|
-
dataRowsKeys,
|
|
639
|
-
filters,
|
|
640
|
-
setFilters,
|
|
641
|
-
sorts,
|
|
642
|
-
setSorts,
|
|
643
|
-
) => {
|
|
644
|
-
const dataSortCells = dataRowsKeys.map((key) => {
|
|
645
|
-
const sort = Object.keys(sorts).includes(key) ? sorts[key] : '';
|
|
646
|
-
const prettifyHeaderValue = `${key[0].toUpperCase()}${key.slice(1)}`;
|
|
647
|
-
return {
|
|
648
|
-
key,
|
|
649
|
-
value: prettifyHeaderValue,
|
|
650
|
-
hasSort: true,
|
|
651
|
-
sort,
|
|
652
|
-
onSort: () => {
|
|
653
|
-
const newSort = sort === '' ? 'up' : sort === 'up' ? 'down' : '';
|
|
654
|
-
setSorts({ ...sorts, [key]: newSort });
|
|
655
|
-
},
|
|
656
|
-
};
|
|
657
|
-
});
|
|
658
|
-
const dataFilterCells = dataRowsKeys.map((key) => {
|
|
659
|
-
const filterValue = Object.keys(filters).includes(key)
|
|
660
|
-
? filters[key]
|
|
661
|
-
: '';
|
|
662
|
-
return {
|
|
663
|
-
key,
|
|
664
|
-
value: filterValue,
|
|
665
|
-
type: 'Input',
|
|
666
|
-
placeholder: 'Filter',
|
|
667
|
-
onChange: (ev) => setFilters({ ...filters, [key]: ev.target.value }),
|
|
668
|
-
};
|
|
669
|
-
});
|
|
670
|
-
return { dataSortCells, dataFilterCells };
|
|
671
|
-
};
|
|
672
|
-
const { dataSortCells, dataFilterCells } = dataHeaders(
|
|
673
|
-
headings,
|
|
674
|
-
filters,
|
|
675
|
-
setFilters,
|
|
676
|
-
sorts,
|
|
677
|
-
setSorts,
|
|
678
|
-
);
|
|
679
|
-
const filteredAndSortedData = filterAndSortDataRows(
|
|
680
|
-
keyedData,
|
|
681
|
-
filters,
|
|
682
|
-
sorts,
|
|
683
|
-
);
|
|
684
|
-
const dataRows = [
|
|
685
|
-
...filteredAndSortedData
|
|
686
|
-
.slice(firstVisibleRow, lastVisibleRow)
|
|
687
|
-
.map((dataRow) => {
|
|
688
|
-
const rowsCells = Object.entries(dataRow).map(([key, value]) => ({
|
|
689
|
-
key,
|
|
690
|
-
value,
|
|
691
|
-
type: 'Input',
|
|
692
|
-
disabled: true,
|
|
693
|
-
}));
|
|
694
|
-
return {
|
|
695
|
-
cells: rowsCells,
|
|
696
|
-
};
|
|
697
|
-
}),
|
|
698
|
-
];
|
|
699
|
-
const table = {
|
|
700
|
-
headers: [
|
|
701
|
-
{
|
|
702
|
-
cells: dataSortCells,
|
|
703
|
-
},
|
|
704
|
-
{
|
|
705
|
-
cells: dataFilterCells,
|
|
706
|
-
},
|
|
707
|
-
],
|
|
708
|
-
rows: dataRows,
|
|
709
|
-
footer: {
|
|
710
|
-
pagination: {
|
|
711
|
-
rowCount: filteredAndSortedData.length,
|
|
712
|
-
selectedPage,
|
|
713
|
-
rowsPerPage: {
|
|
714
|
-
onChange: (evt) => {
|
|
715
|
-
const { value } = evt.target;
|
|
716
|
-
setRowsPerPage(Number(value));
|
|
717
|
-
},
|
|
718
|
-
options: rowsPerPageOptions,
|
|
719
|
-
value: rowsPerPage,
|
|
720
|
-
},
|
|
721
|
-
onSelectPage: (evt) => setSelectedPage(evt),
|
|
722
|
-
small: true,
|
|
723
|
-
},
|
|
724
|
-
},
|
|
725
|
-
};
|
|
726
|
-
return <Table table={table} />;
|
|
727
|
-
};
|
|
728
|
-
return <TableWithSortAndFilter />;
|
|
729
|
-
};
|
|
730
|
-
|
|
731
|
-
export const OnRowEnter = () => {
|
|
732
|
-
const [displayText, setDisplayText] = useState('Hover any row!');
|
|
733
|
-
const rows = [1, 2, 3, 4, 5].map((val) => ({
|
|
734
|
-
cells: [{ value: `Row ${val}` }, { value: `${val ** 2}` }],
|
|
735
|
-
onRowMouseEnter: () => setDisplayText(`Hovering row ${val}`),
|
|
736
|
-
onRowMouseLeave: () => setDisplayText('Not hovering any row...'),
|
|
737
|
-
}));
|
|
738
|
-
return (
|
|
739
|
-
<>
|
|
740
|
-
<Text>{displayText}</Text>
|
|
741
|
-
<Table
|
|
742
|
-
table={{
|
|
743
|
-
fixedWidth: '100%',
|
|
744
|
-
headers: [
|
|
745
|
-
{
|
|
746
|
-
cells: [{ value: 'Description' }, { value: 'Value' }],
|
|
747
|
-
onRowMouseEnter: () => setDisplayText(`Hovering header row`),
|
|
748
|
-
onRowMouseLeave: () => setDisplayText('Not hovering any row...'),
|
|
749
|
-
},
|
|
750
|
-
],
|
|
751
|
-
rows,
|
|
752
|
-
}}
|
|
753
|
-
/>
|
|
754
|
-
</>
|
|
755
|
-
);
|
|
756
|
-
};
|
|
757
|
-
|
|
758
|
-
export const OverflowingCells = Template.bind({});
|
|
759
|
-
OverflowingCells.args = { table: storyData.tableOverflowing };
|