@oliasoft-open-source/react-ui-library 2.4.4 → 2.4.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oliasoft-open-source/react-ui-library",
3
- "version": "2.4.4",
3
+ "version": "2.4.6",
4
4
  "description": "Reusable UI components for React projects",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -2,9 +2,21 @@ import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { FaTimes } from 'react-icons/fa';
4
4
  import cx from 'classnames';
5
+ import { isArray } from 'lodash';
5
6
  import { Heading } from '../heading/heading';
6
7
  import styles from './dialog.module.less';
7
8
 
9
+ const convertStringToJsx = (children) => {
10
+ if (isArray(children)) {
11
+ return children.map((text) => (
12
+ <>
13
+ {text} <br />
14
+ </>
15
+ ));
16
+ }
17
+ return children;
18
+ };
19
+
8
20
  export const Dialog = ({ dialog }) => {
9
21
  const {
10
22
  heading,
@@ -36,7 +48,7 @@ export const Dialog = ({ dialog }) => {
36
48
  ) : null}
37
49
  </div>
38
50
  <div className={styles.content} style={{ padding: contentPadding }}>
39
- {content}
51
+ {convertStringToJsx(content)}
40
52
  </div>
41
53
  {footer && <div className={styles.footer}>{footer}</div>}
42
54
  </div>
@@ -49,6 +61,7 @@ const dialogShape = PropTypes.shape({
49
61
  PropTypes.string,
50
62
  PropTypes.number,
51
63
  PropTypes.node,
64
+ PropTypes.arrayOf(PropTypes.string),
52
65
  ]).isRequired,
53
66
  contentPadding: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
54
67
  footer: PropTypes.node,
@@ -33,3 +33,7 @@
33
33
  margin-top: auto;
34
34
  margin-bottom: auto;
35
35
  }
36
+
37
+ .newLine {
38
+ white-space: 'pre-wrap';
39
+ }
@@ -64,6 +64,9 @@ export const Default = Template.bind({});
64
64
  export const Centered = Template.bind({});
65
65
  Centered.args = { centered: true };
66
66
 
67
+ export const LineBreak = Template.bind({});
68
+ LineBreak.args = { content: ['This is a', 'new line!'] };
69
+
67
70
  export const Scroll = Template.bind({});
68
71
  Scroll.args = {
69
72
  scroll: true,
@@ -23,20 +23,21 @@ export const TableScrollWrapper = ({ table, children }) => {
23
23
 
24
24
  return (
25
25
  <div
26
+ id="scrollWrapper"
26
27
  className={cx(
27
28
  styles.scrollWrapper,
28
29
  bordered ? styles.bordered : '',
29
30
  maxHeight ? styles.maxHeight : '',
30
31
  )}
31
- style={{ maxHeight: !infiniteScroll ? maxHeight : 'none' }}
32
+ style={{ maxHeight }}
32
33
  >
33
34
  {infiniteScroll ? (
34
35
  <InfiniteScroll
35
36
  dataLength={Math.min(rows.length, visibleRows + pageSize)} // Doesn't work with rows.length for some reason
36
37
  next={loadMoreItems}
37
38
  hasMore={hasMore}
38
- height={maxHeight}
39
- style={{ overflowX: 'hidden' }}
39
+ scrollableTarget="scrollWrapper"
40
+ style={{ overflow: 'initial' }}
40
41
  >
41
42
  {children({ visibleRows })}
42
43
  </InfiniteScroll>
@@ -20,6 +20,7 @@ html[data-theme='dark'] {
20
20
  &.maxHeight {
21
21
  display: block;
22
22
  overflow-y: auto;
23
+ overflow-x: hidden;
23
24
 
24
25
  tfoot td {
25
26
  position: sticky;
@@ -170,6 +170,23 @@ export const tableInfiniteScroll = {
170
170
  },
171
171
  };
172
172
 
173
+ export const tableInfiniteScrollFullHeight = {
174
+ ...tableInfiniteScroll,
175
+ maxHeight: '100%',
176
+ };
177
+
178
+ export const tableInfiniteScrollShort = {
179
+ ...tableInfiniteScroll,
180
+ rows: Array.from({ length: 1 }, (_, index) => ({
181
+ cells: [
182
+ { type: 'Input', value: `Strawberry Letter ${index + 1}` },
183
+ { type: 'Input', value: 100 },
184
+ { type: 'Input', value: 361 },
185
+ { type: 'Input', value: 'Vietnam' },
186
+ ],
187
+ })),
188
+ };
189
+
173
190
  export const tableInfiniteScrollDnD = {
174
191
  ...tableInfiniteScroll,
175
192
  draggable: true,
@@ -454,7 +471,6 @@ export const tableStickyHeaders = {
454
471
  };
455
472
 
456
473
  export const tableSort = {
457
- fixedWidth: '100%',
458
474
  headers: [
459
475
  {
460
476
  cells: [
@@ -78,11 +78,36 @@ StickyHeaders.args = {
78
78
  table: storyData.tableStickyHeaders,
79
79
  };
80
80
 
81
- export const InfiniteScroll = Template.bind({});
82
- InfiniteScroll.args = {
81
+ export const InfiniteScrollFixedHeight = Template.bind({});
82
+ InfiniteScrollFixedHeight.args = {
83
83
  table: storyData.tableInfiniteScroll,
84
84
  };
85
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
+
86
111
  export const InfiniteScrollWithDragAndDrop = Template.bind({});
87
112
  InfiniteScrollWithDragAndDrop.args = {
88
113
  table: storyData.tableInfiniteScrollDnD,