@axinom/mosaic-ui 0.35.0-rc.1 → 0.35.0-rc.11

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.
Files changed (73) hide show
  1. package/dist/components/DynamicDataList/DynamicDataList.d.ts +5 -14
  2. package/dist/components/DynamicDataList/DynamicDataList.d.ts.map +1 -1
  3. package/dist/components/DynamicDataList/DynamicListDataEntry/DynamicListDataEntry.d.ts +3 -1
  4. package/dist/components/DynamicDataList/DynamicListDataEntry/DynamicListDataEntry.d.ts.map +1 -1
  5. package/dist/components/DynamicDataList/DynamicListHeader/DynamicListHeader.d.ts +5 -1
  6. package/dist/components/DynamicDataList/DynamicListHeader/DynamicListHeader.d.ts.map +1 -1
  7. package/dist/components/DynamicDataList/DynamicListRow/DynamicListRow.d.ts +9 -10
  8. package/dist/components/DynamicDataList/DynamicListRow/DynamicListRow.d.ts.map +1 -1
  9. package/dist/components/DynamicDataList/helpers/DynamicListReducer/DynamicListReducer.actions.d.ts +5 -0
  10. package/dist/components/DynamicDataList/helpers/DynamicListReducer/DynamicListReducer.actions.d.ts.map +1 -0
  11. package/dist/components/DynamicDataList/helpers/DynamicListReducer/DynamicListReducer.d.ts +4 -0
  12. package/dist/components/DynamicDataList/helpers/DynamicListReducer/DynamicListReducer.d.ts.map +1 -0
  13. package/dist/components/DynamicDataList/helpers/DynamicListReducer/DynamicListReducer.init.d.ts +4 -0
  14. package/dist/components/DynamicDataList/helpers/DynamicListReducer/DynamicListReducer.init.d.ts.map +1 -0
  15. package/dist/components/DynamicDataList/helpers/DynamicListReducer/DynamicListReducer.types.d.ts +38 -0
  16. package/dist/components/DynamicDataList/helpers/DynamicListReducer/DynamicListReducer.types.d.ts.map +1 -0
  17. package/dist/components/DynamicDataList/helpers/DynamicListReducer/index.d.ts +4 -0
  18. package/dist/components/DynamicDataList/helpers/DynamicListReducer/index.d.ts.map +1 -0
  19. package/dist/components/DynamicDataList/helpers/generateId.d.ts +6 -0
  20. package/dist/components/DynamicDataList/helpers/generateId.d.ts.map +1 -0
  21. package/dist/components/DynamicDataList/helpers/useColumnDefs.d.ts +14 -0
  22. package/dist/components/DynamicDataList/helpers/useColumnDefs.d.ts.map +1 -0
  23. package/dist/components/DynamicDataList/helpers/useDataHandler.d.ts +9 -0
  24. package/dist/components/DynamicDataList/helpers/useDataHandler.d.ts.map +1 -0
  25. package/dist/components/DynamicDataList/helpers/useRowAnimation.d.ts +12 -0
  26. package/dist/components/DynamicDataList/helpers/useRowAnimation.d.ts.map +1 -0
  27. package/dist/components/DynamicDataList/index.d.ts +1 -1
  28. package/dist/components/DynamicDataList/index.d.ts.map +1 -1
  29. package/dist/components/List/ListRow/ListRow.d.ts.map +1 -1
  30. package/dist/components/List/useColumnsSize.d.ts +1 -0
  31. package/dist/components/List/useColumnsSize.d.ts.map +1 -1
  32. package/dist/index.es.js +11 -3
  33. package/dist/index.es.js.map +1 -1
  34. package/dist/index.js +11 -3
  35. package/dist/index.js.map +1 -1
  36. package/package.json +5 -3
  37. package/src/components/DynamicDataList/DynamicDataList.scss +0 -61
  38. package/src/components/DynamicDataList/DynamicDataList.spec.tsx +126 -393
  39. package/src/components/DynamicDataList/DynamicDataList.stories.tsx +0 -5
  40. package/src/components/DynamicDataList/DynamicDataList.tsx +133 -600
  41. package/src/components/DynamicDataList/DynamicListDataEntry/DynamicListDataEntry.scss +4 -2
  42. package/src/components/DynamicDataList/DynamicListDataEntry/DynamicListDataEntry.spec.tsx +17 -44
  43. package/src/components/DynamicDataList/DynamicListDataEntry/DynamicListDataEntry.tsx +15 -22
  44. package/src/components/DynamicDataList/DynamicListHeader/DynamicListHeader.scss +15 -10
  45. package/src/components/DynamicDataList/DynamicListHeader/DynamicListHeader.spec.tsx +4 -1
  46. package/src/components/DynamicDataList/DynamicListHeader/DynamicListHeader.tsx +16 -14
  47. package/src/components/DynamicDataList/DynamicListRow/DynamicListRow.scss +16 -24
  48. package/src/components/DynamicDataList/DynamicListRow/DynamicListRow.spec.tsx +26 -253
  49. package/src/components/DynamicDataList/DynamicListRow/DynamicListRow.tsx +45 -139
  50. package/src/components/DynamicDataList/helpers/DynamicListReducer/DynamicListReducer.actions.spec.ts +276 -0
  51. package/src/components/DynamicDataList/helpers/DynamicListReducer/DynamicListReducer.actions.ts +86 -0
  52. package/src/components/DynamicDataList/helpers/DynamicListReducer/DynamicListReducer.init.spec.ts +118 -0
  53. package/src/components/DynamicDataList/helpers/DynamicListReducer/DynamicListReducer.init.ts +40 -0
  54. package/src/components/DynamicDataList/helpers/DynamicListReducer/DynamicListReducer.spec.ts +89 -0
  55. package/src/components/DynamicDataList/helpers/DynamicListReducer/DynamicListReducer.ts +42 -0
  56. package/src/components/DynamicDataList/helpers/DynamicListReducer/DynamicListReducer.types.ts +46 -0
  57. package/src/components/DynamicDataList/helpers/DynamicListReducer/index.ts +3 -0
  58. package/src/components/DynamicDataList/helpers/generateId.ts +10 -0
  59. package/src/components/DynamicDataList/helpers/useColumnDefs.ts +56 -0
  60. package/src/components/DynamicDataList/helpers/useDataHandler.ts +77 -0
  61. package/src/components/DynamicDataList/helpers/useRowAnimation.tsx +38 -0
  62. package/src/components/DynamicDataList/index.ts +2 -2
  63. package/src/components/FormElements/BooleanView/BooleanViewField.scss +2 -2
  64. package/src/components/FormStation/FormStation.scss +4 -0
  65. package/src/components/FormStation/FormStation.tsx +2 -2
  66. package/src/components/List/List.tsx +1 -1
  67. package/src/components/List/ListRow/ListRow.tsx +56 -50
  68. package/src/components/List/ListRow/Renderers/BooleanDotRenderer/BooleanDotRenderer.scss +6 -9
  69. package/src/components/List/ListRow/Renderers/BooleanDotRenderer/BooleanDotRenderer.spec.tsx +2 -2
  70. package/src/components/List/ListRow/Renderers/BooleanDotRenderer/BooleanDotRenderer.tsx +1 -1
  71. package/src/components/List/useColumnsSize.ts +20 -3
  72. package/src/styles/variables.scss +0 -5
  73. package/src/components/DynamicDataList/DynamicDataList.reposition.spec.tsx +0 -816
@@ -22,6 +22,10 @@
22
22
 
23
23
  z-index: 1;
24
24
 
25
+ column-gap: var(--dynamic-list-column-gap, $dynamic-list-column-gap);
26
+
27
+ padding: 1px 0px 1px 0px;
28
+
25
29
  .column {
26
30
  width: 100%;
27
31
  height: 100%;
@@ -60,8 +64,6 @@
60
64
  justify-items: start;
61
65
  align-items: center;
62
66
 
63
- //opacity: 0.5;
64
-
65
67
  svg {
66
68
  stroke: var(--input-disabled-border-color, $input-disabled-border-color);
67
69
  rect {
@@ -87,11 +87,12 @@ describe('DynamicListDataEntry', () => {
87
87
  expect(wrapper).toBeTruthy();
88
88
  });
89
89
 
90
- it('most styling props, except gridTemplateColumns, should be undefined by default', () => {
90
+ it('most styling props, except gridTemplateColumns and gridAutoRows, should be undefined by default', () => {
91
91
  const wrapper = shallow(
92
92
  <DynamicListDataEntry
93
93
  columns={defaultColumns}
94
94
  columnSizes={defaultProps.columnSizes}
95
+ rowHeight={defaultProps.rowHeight}
95
96
  />,
96
97
  );
97
98
 
@@ -99,7 +100,10 @@ describe('DynamicListDataEntry', () => {
99
100
 
100
101
  expect(row.prop('style')).toHaveProperty('gridColumnGap', undefined);
101
102
  expect(row.prop('style')).toHaveProperty('alignItems', undefined);
102
- expect(row.prop('style')).toHaveProperty('gridAutoRows', undefined);
103
+ expect(row.prop('style')).toHaveProperty(
104
+ 'gridAutoRows',
105
+ `minmax(50px, ${defaultProps.rowHeight})`,
106
+ );
103
107
  expect(row.prop('style')).toHaveProperty(
104
108
  'gridTemplateColumns',
105
109
  defaultProps.columnSizes,
@@ -122,7 +126,7 @@ describe('DynamicListDataEntry', () => {
122
126
  );
123
127
  expect(row.prop('style')).toHaveProperty(
124
128
  'gridAutoRows',
125
- defaultProps.rowHeight,
129
+ `minmax(50px, ${defaultProps.rowHeight})`,
126
130
  );
127
131
  expect(row.prop('style')).toHaveProperty(
128
132
  'gridTemplateColumns',
@@ -153,13 +157,12 @@ describe('DynamicListDataEntry', () => {
153
157
  expect(columns).toHaveLength(defaultColumnsLength);
154
158
  });
155
159
 
156
- it(`renders the position column if a 'positionKey' prop is set and 'allowReordering' is set to true`, () => {
160
+ it(`renders the position column if 'showPositionColumn' is set to true`, () => {
157
161
  const wrapper = shallow(
158
162
  <DynamicListDataEntry
159
163
  columnSizes={''}
160
164
  columns={defaultColumns}
161
- positionKey={'position'}
162
- allowReordering={true}
165
+ showPositionColumn={true}
163
166
  />,
164
167
  );
165
168
 
@@ -168,27 +171,13 @@ describe('DynamicListDataEntry', () => {
168
171
  expect(position.exists()).toBe(true);
169
172
  });
170
173
 
171
- it(`doesn't render the position column if a 'positionKey' isn't set`, () => {
174
+ it(`doesn't render the position column if a 'showPositionColumn' is set to false`, () => {
172
175
  const wrapper = shallow(
173
176
  <DynamicListDataEntry
174
177
  columnSizes={''}
175
178
  columns={defaultColumns}
176
179
  allowReordering={true}
177
- />,
178
- );
179
-
180
- const position = wrapper.find('.position');
181
-
182
- expect(position.exists()).toBe(false);
183
- });
184
-
185
- it(`doesn't render the position column if 'allowReordering' is false`, () => {
186
- const wrapper = shallow(
187
- <DynamicListDataEntry
188
- columnSizes={''}
189
- columns={defaultColumns}
190
- positionKey={'position'}
191
- allowReordering={false}
180
+ showPositionColumn={false}
192
181
  />,
193
182
  );
194
183
 
@@ -205,6 +194,7 @@ describe('DynamicListDataEntry', () => {
205
194
  positionKey={'position'}
206
195
  allowReordering={true}
207
196
  allowDragging={true}
197
+ showPositionColumn={true}
208
198
  />,
209
199
  );
210
200
 
@@ -221,6 +211,7 @@ describe('DynamicListDataEntry', () => {
221
211
  positionKey={'position'}
222
212
  allowReordering={true}
223
213
  allowDragging={false}
214
+ showPositionColumn={true}
224
215
  />,
225
216
  );
226
217
 
@@ -229,8 +220,6 @@ describe('DynamicListDataEntry', () => {
229
220
  expect(dragIcon.exists()).toBe(false);
230
221
  });
231
222
 
232
- it.todo(`onDrop removes 'draggedAbove' or 'draggedBelow'`);
233
-
234
223
  it(`doesn't display an action button by default`, () => {
235
224
  const wrapper = shallow(
236
225
  <DynamicListDataEntry
@@ -272,26 +261,6 @@ describe('DynamicListDataEntry', () => {
272
261
  expect(button.prop('disabled')).toBe(true);
273
262
  });
274
263
 
275
- it(`input width and height should be the same as the 'rowHeight' prop if its set`, () => {
276
- const mockHeight = '70px';
277
- const wrapper = mount(
278
- <DynamicListDataEntry
279
- columns={defaultColumns}
280
- columnSizes={defaultProps.columnSizes}
281
- allowReordering={true}
282
- positionKey={'position'}
283
- rowHeight={mockHeight}
284
- />,
285
- );
286
-
287
- const inputStyles = wrapper
288
- .find('input')
289
- .prop('style') as React.CSSProperties;
290
-
291
- expect(inputStyles.height).toBe(mockHeight);
292
- expect(inputStyles.width).toBe(mockHeight);
293
- });
294
-
295
264
  it(`input value should be 'newDataPosition' prop`, () => {
296
265
  const mockPosition = 56;
297
266
  const wrapper = shallow(
@@ -301,6 +270,7 @@ describe('DynamicListDataEntry', () => {
301
270
  positionKey={'position'}
302
271
  allowReordering={true}
303
272
  newDataPosition={mockPosition}
273
+ showPositionColumn={true}
304
274
  />,
305
275
  );
306
276
 
@@ -316,6 +286,7 @@ describe('DynamicListDataEntry', () => {
316
286
  columnSizes={defaultProps.columnSizes}
317
287
  positionKey={'position'}
318
288
  allowReordering={true}
289
+ showPositionColumn={true}
319
290
  />,
320
291
  );
321
292
 
@@ -435,6 +406,7 @@ describe('DynamicListDataEntry', () => {
435
406
  positionKey={mockPosKey}
436
407
  allowReordering={true}
437
408
  newDataPosition={mockNewPos}
409
+ showPositionColumn={true}
438
410
  />,
439
411
  );
440
412
 
@@ -519,6 +491,7 @@ describe('DynamicListDataEntry', () => {
519
491
  positionKey={mockPosKey}
520
492
  allowReordering={true}
521
493
  newDataPosition={undefined}
494
+ showPositionColumn={true}
522
495
  />,
523
496
  );
524
497
 
@@ -56,6 +56,8 @@ export interface DynamicListDataEntryProps<T extends Data> {
56
56
  sticky?: boolean;
57
57
  /** If header is shown */
58
58
  showHeader?: boolean;
59
+ /** If set to true, the position column will be shown (default: false) */
60
+ showPositionColumn?: boolean;
59
61
  /** Emits when the action button is clicked. Data is supplied as a parameter */
60
62
  onActionClicked?: (data: T) => void;
61
63
  /** override default add button (+) */
@@ -82,11 +84,12 @@ export const DynamicListDataEntry = <T extends Data>({
82
84
  className = '',
83
85
  sticky = true,
84
86
  showHeader,
87
+ showPositionColumn = false,
85
88
  onActionClicked = noop,
86
89
  customAddButton,
87
90
  }: PropsWithChildren<DynamicListDataEntryProps<T>>): JSX.Element => {
88
91
  const customStyles = {
89
- gridAutoRows: rowHeight,
92
+ gridAutoRows: `minmax(50px, ${rowHeight})`,
90
93
  gridTemplateColumns: columnSizes,
91
94
  gridColumnGap: columnGap,
92
95
  justifyItems: horizontalTextAlign,
@@ -188,29 +191,19 @@ export const DynamicListDataEntry = <T extends Data>({
188
191
  style={customStyles}
189
192
  data-test-id="dynamic-list-data-entry"
190
193
  >
191
- {allowReordering === true &&
192
- // only show position column if allowReordering is true and the positionKey exists
193
- positionKey !== undefined && (
194
- <div className={clsx(classes.position)}>
195
- {allowDragging && (
196
- <div className={classes.draggable}>
197
- <Icons
198
- icon={IconName.Drag}
199
- className={clsx(classes.dragIcon)}
200
- />
201
- </div>
202
- )}
203
-
204
- <div className={clsx(classes.input)}>
205
- <input
206
- disabled={true}
207
- type="text"
208
- value={newDataPosition}
209
- style={{ height: rowHeight, width: rowHeight }}
210
- />
194
+ {showPositionColumn && (
195
+ <div className={clsx(classes.position)}>
196
+ {allowDragging && (
197
+ <div className={classes.draggable}>
198
+ <Icons icon={IconName.Drag} className={clsx(classes.dragIcon)} />
211
199
  </div>
200
+ )}
201
+
202
+ <div className={clsx(classes.input)}>
203
+ <input disabled={true} type="text" value={newDataPosition} />
212
204
  </div>
213
- )}
205
+ </div>
206
+ )}
214
207
  {columns.map((column) => (
215
208
  <div
216
209
  key={column.propertyName as string}
@@ -8,6 +8,20 @@
8
8
 
9
9
  z-index: 1;
10
10
 
11
+ display: grid;
12
+ padding: 1px 0px 1px 0px;
13
+ grid-auto-rows: var(--dynamic-list-row-height, $dynamic-list-row-height);
14
+ column-gap: var(--dynamic-list-column-gap, $dynamic-list-column-gap);
15
+
16
+ border-bottom: solid 1px $light-gray;
17
+
18
+ justify-items: left;
19
+ align-items: center;
20
+
21
+ &:first-child {
22
+ padding-left: var(--dynamic-list-column-gap, $dynamic-list-column-gap);
23
+ }
24
+
11
25
  .column {
12
26
  width: 100%;
13
27
  height: 100%;
@@ -22,8 +36,7 @@
22
36
  }
23
37
  }
24
38
 
25
- .position,
26
- .actionButton {
39
+ .position {
27
40
  height: 100%;
28
41
  width: 100%;
29
42
  display: grid;
@@ -33,14 +46,6 @@
33
46
  align-items: center;
34
47
  }
35
48
 
36
- .position {
37
- padding-left: 5px;
38
- }
39
-
40
- .actionButton {
41
- justify-items: end;
42
- }
43
-
44
49
  p {
45
50
  color: var(--input-color, $input-color);
46
51
  font-size: var(--label-font-size, $label-font-size);
@@ -114,13 +114,15 @@ describe('DynamicListHeader', () => {
114
114
  });
115
115
  });
116
116
 
117
- it(`renders the position column if a 'positionKey' prop is set and 'allowReordering' is set to true`, () => {
117
+ it(`renders the position column if 'showPositionColumn' is set to true`, () => {
118
118
  const wrapper = shallow(
119
119
  <DynamicListHeader
120
120
  columnSizes={''}
121
121
  columns={defaultColumns}
122
122
  positionKey={'position'}
123
123
  allowReordering={true}
124
+ showPositionColumn={true}
125
+ allowDragging={true}
124
126
  />,
125
127
  );
126
128
 
@@ -140,6 +142,7 @@ describe('DynamicListHeader', () => {
140
142
  positionKey={'position'}
141
143
  allowReordering={true}
142
144
  positionLabel={mockLabel}
145
+ showPositionColumn={true}
143
146
  />,
144
147
  );
145
148
 
@@ -28,6 +28,10 @@ export interface DynamicListHeaderProps<T extends Data> {
28
28
  className?: string;
29
29
  /** Whether header should stick to the top (default: true) */
30
30
  sticky?: boolean;
31
+ /** If set to true, the position column will be shown (default: false) */
32
+ showPositionColumn?: boolean;
33
+ /** This will be used to determine the label for the position column if a positionLabel is not defined (default: false) */
34
+ allowDragging?: boolean;
31
35
  }
32
36
 
33
37
  export const DynamicListHeader = <T extends Data>({
@@ -37,11 +41,11 @@ export const DynamicListHeader = <T extends Data>({
37
41
  rowHeight,
38
42
  horizontalTextAlign,
39
43
  verticalTextAlign,
40
- allowReordering,
41
- positionKey,
42
44
  positionLabel,
43
45
  className = '',
44
46
  sticky = true,
47
+ showPositionColumn = false,
48
+ allowDragging = false,
45
49
  }: PropsWithChildren<DynamicListHeaderProps<T>>): JSX.Element => {
46
50
  const customStyles = {
47
51
  gridAutoRows: rowHeight,
@@ -66,18 +70,16 @@ export const DynamicListHeader = <T extends Data>({
66
70
  style={customStyles}
67
71
  data-test-id="dynamic-list-header"
68
72
  >
69
- {allowReordering === true &&
70
- // only show position column if allowReordering is true and the positionKey exists
71
- positionKey !== undefined && (
72
- <div
73
- className={clsx(classes.column)}
74
- data-test-id="dynamic-list-header-cell"
75
- >
76
- <p className={clsx(classes.position)}>
77
- {positionLabel ?? 'Position'}
78
- </p>
79
- </div>
80
- )}
73
+ {showPositionColumn && (
74
+ <div
75
+ className={clsx(classes.column)}
76
+ data-test-id="dynamic-list-header-cell"
77
+ >
78
+ <p className={clsx(classes.position)}>
79
+ {positionLabel ?? (allowDragging ? 'Position' : 'Pos')}
80
+ </p>
81
+ </div>
82
+ )}
81
83
  {columns.map((column) => (
82
84
  <div
83
85
  key={column.propertyName as string}
@@ -4,6 +4,22 @@
4
4
  box-sizing: border-box;
5
5
 
6
6
  position: relative;
7
+ display: grid;
8
+ width: 100%;
9
+
10
+ display: grid;
11
+ padding: 1px 0px 1px 0px;
12
+ grid-auto-rows: var(--dynamic-list-row-height, $dynamic-list-row-height);
13
+ column-gap: var(--dynamic-list-column-gap, $dynamic-list-column-gap);
14
+
15
+ border-bottom: var(--dynamic-list-row-border, $dynamic-list-row-border);
16
+
17
+ &.dragging {
18
+ border-bottom: 0;
19
+ }
20
+
21
+ justify-items: left;
22
+ align-items: center;
7
23
 
8
24
  .column {
9
25
  max-width: 100%;
@@ -133,30 +149,6 @@
133
149
  justify-self: end;
134
150
  }
135
151
 
136
- &.draggedAbove {
137
- &:before {
138
- content: '';
139
- position: absolute;
140
- top: -3px;
141
- left: 0px;
142
- bottom: 0px;
143
- right: 0px;
144
- border-top: 3px dashed $blue;
145
- }
146
- }
147
-
148
- &.draggedBelow {
149
- &:after {
150
- content: '';
151
- position: absolute;
152
- top: 0px;
153
- left: 0px;
154
- bottom: -3px;
155
- right: 0px;
156
- border-bottom: 3px dashed $blue;
157
- }
158
- }
159
-
160
152
  .dragIcon {
161
153
  height: 40px;
162
154