@axinom/mosaic-ui 0.42.0 → 0.43.0-rc.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.
Files changed (88) hide show
  1. package/dist/components/FormStation/FormGrid/FormGrid.d.ts +7 -0
  2. package/dist/components/FormStation/FormGrid/FormGrid.d.ts.map +1 -0
  3. package/dist/components/FormStation/FormGrid/index.d.ts +2 -0
  4. package/dist/components/FormStation/FormGrid/index.d.ts.map +1 -0
  5. package/dist/components/FormStation/FormStation.d.ts +3 -12
  6. package/dist/components/FormStation/FormStation.d.ts.map +1 -1
  7. package/dist/components/FormStation/FormStation.models.d.ts +16 -2
  8. package/dist/components/FormStation/FormStation.models.d.ts.map +1 -1
  9. package/dist/components/FormStation/FormStationActions/FormStationActions.d.ts +21 -0
  10. package/dist/components/FormStation/FormStationActions/FormStationActions.d.ts.map +1 -0
  11. package/dist/components/FormStation/FormStationActions/index.d.ts +2 -0
  12. package/dist/components/FormStation/FormStationActions/index.d.ts.map +1 -0
  13. package/dist/components/FormStation/FormStationContentWrapper/FormStationContentWrapper.d.ts +11 -0
  14. package/dist/components/FormStation/FormStationContentWrapper/FormStationContentWrapper.d.ts.map +1 -0
  15. package/dist/components/FormStation/FormStationContentWrapper/index.d.ts +2 -0
  16. package/dist/components/FormStation/FormStationContentWrapper/index.d.ts.map +1 -0
  17. package/dist/components/FormStation/FormStationHeader/FormStationHeader.d.ts +11 -0
  18. package/dist/components/FormStation/FormStationHeader/FormStationHeader.d.ts.map +1 -0
  19. package/dist/components/FormStation/FormStationHeader/index.d.ts +2 -0
  20. package/dist/components/FormStation/FormStationHeader/index.d.ts.map +1 -0
  21. package/dist/components/FormStation/helpers/useDataProvider.d.ts +14 -0
  22. package/dist/components/FormStation/helpers/useDataProvider.d.ts.map +1 -0
  23. package/dist/components/FormStation/{useValidationError.d.ts → helpers/useValidationError.d.ts} +1 -1
  24. package/dist/components/FormStation/helpers/useValidationError.d.ts.map +1 -0
  25. package/dist/components/FormStation/index.d.ts +2 -1
  26. package/dist/components/FormStation/index.d.ts.map +1 -1
  27. package/dist/components/Tabs/Tab/CustomTab.d.ts +3 -0
  28. package/dist/components/Tabs/Tab/CustomTab.d.ts.map +1 -0
  29. package/dist/components/Tabs/Tab/index.d.ts +2 -0
  30. package/dist/components/Tabs/Tab/index.d.ts.map +1 -0
  31. package/dist/components/Tabs/TabList/CustomTabList.d.ts +3 -0
  32. package/dist/components/Tabs/TabList/CustomTabList.d.ts.map +1 -0
  33. package/dist/components/Tabs/TabList/ScrollContainer/ScrollContainer.d.ts +3 -0
  34. package/dist/components/Tabs/TabList/ScrollContainer/ScrollContainer.d.ts.map +1 -0
  35. package/dist/components/Tabs/TabList/ScrollContainer/index.d.ts +2 -0
  36. package/dist/components/Tabs/TabList/ScrollContainer/index.d.ts.map +1 -0
  37. package/dist/components/Tabs/TabList/ScrollContainer/useScroll.d.ts +10 -0
  38. package/dist/components/Tabs/TabList/ScrollContainer/useScroll.d.ts.map +1 -0
  39. package/dist/components/Tabs/TabList/index.d.ts +2 -0
  40. package/dist/components/Tabs/TabList/index.d.ts.map +1 -0
  41. package/dist/components/Tabs/TabPanel/CustomTabPanel.d.ts +3 -0
  42. package/dist/components/Tabs/TabPanel/CustomTabPanel.d.ts.map +1 -0
  43. package/dist/components/Tabs/TabPanel/index.d.ts +2 -0
  44. package/dist/components/Tabs/TabPanel/index.d.ts.map +1 -0
  45. package/dist/components/Tabs/index.d.ts +5 -0
  46. package/dist/components/Tabs/index.d.ts.map +1 -0
  47. package/dist/index.es.js +4 -4
  48. package/dist/index.es.js.map +1 -1
  49. package/dist/index.js +4 -4
  50. package/dist/index.js.map +1 -1
  51. package/package.json +4 -3
  52. package/src/components/FormStation/FormGrid/FormGrid.scss +10 -0
  53. package/src/components/FormStation/FormGrid/FormGrid.tsx +25 -0
  54. package/src/components/FormStation/FormGrid/index.ts +1 -0
  55. package/src/components/FormStation/FormStation.models.ts +28 -2
  56. package/src/components/FormStation/FormStation.scss +1 -117
  57. package/src/components/FormStation/FormStation.stories.tsx +166 -1
  58. package/src/components/FormStation/FormStation.tsx +39 -388
  59. package/src/components/FormStation/FormStationActions/FormStationActions.tsx +130 -0
  60. package/src/components/FormStation/FormStationActions/index.ts +1 -0
  61. package/src/components/FormStation/FormStationContentWrapper/FormStationContentWrapper.scss +66 -0
  62. package/src/components/FormStation/FormStationContentWrapper/FormStationContentWrapper.tsx +76 -0
  63. package/src/components/FormStation/FormStationContentWrapper/index.ts +1 -0
  64. package/src/components/FormStation/FormStationHeader/FormStationHeader.tsx +88 -0
  65. package/src/components/FormStation/FormStationHeader/index.ts +1 -0
  66. package/src/components/FormStation/helpers/useDataProvider.ts +124 -0
  67. package/src/components/FormStation/{useValidationError.tsx → helpers/useValidationError.tsx} +2 -1
  68. package/src/components/FormStation/index.ts +2 -5
  69. package/src/components/List/ListRow/Renderers/ExternalLinkRenderer/ExternalLinkRenderer.tsx +1 -1
  70. package/src/components/Tabs/Tab/CustomTab.scss +42 -0
  71. package/src/components/Tabs/Tab/CustomTab.tsx +34 -0
  72. package/src/components/Tabs/Tab/index.ts +1 -0
  73. package/src/components/Tabs/TabList/CustomTabList.scss +7 -0
  74. package/src/components/Tabs/TabList/CustomTabList.tsx +15 -0
  75. package/src/components/Tabs/TabList/ScrollContainer/ScrollContainer.scss +34 -0
  76. package/src/components/Tabs/TabList/ScrollContainer/ScrollContainer.tsx +39 -0
  77. package/src/components/Tabs/TabList/ScrollContainer/index.ts +1 -0
  78. package/src/components/Tabs/TabList/ScrollContainer/useScroll.ts +114 -0
  79. package/src/components/Tabs/TabList/index.ts +1 -0
  80. package/src/components/Tabs/TabPanel/CustomTabPanel.scss +10 -0
  81. package/src/components/Tabs/TabPanel/CustomTabPanel.tsx +26 -0
  82. package/src/components/Tabs/TabPanel/index.ts +1 -0
  83. package/src/components/Tabs/Tabs.stories.tsx +108 -0
  84. package/src/components/Tabs/index.ts +4 -0
  85. package/dist/components/FormStation/StationErrorStateType.d.ts +0 -5
  86. package/dist/components/FormStation/StationErrorStateType.d.ts.map +0 -1
  87. package/dist/components/FormStation/useValidationError.d.ts.map +0 -1
  88. package/src/components/FormStation/StationErrorStateType.tsx +0 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axinom/mosaic-ui",
3
- "version": "0.42.0",
3
+ "version": "0.43.0-rc.1",
4
4
  "description": "UI components for building Axinom Mosaic applications",
5
5
  "author": "Axinom",
6
6
  "license": "PROPRIETARY",
@@ -32,7 +32,7 @@
32
32
  "build-storybook": "storybook build"
33
33
  },
34
34
  "dependencies": {
35
- "@axinom/mosaic-core": "^0.4.15",
35
+ "@axinom/mosaic-core": "^0.4.16-rc.1",
36
36
  "@faker-js/faker": "^7.4.0",
37
37
  "@popperjs/core": "^2.11.8",
38
38
  "clsx": "^1.1.0",
@@ -43,6 +43,7 @@
43
43
  "react-content-loader": "^6.0.3",
44
44
  "react-imask": "^6.4.3",
45
45
  "react-popper": "^2.2.5",
46
+ "react-tabs": "4.3.0",
46
47
  "react-transition-group": "^4.3.0",
47
48
  "yup": "^0.32.11"
48
49
  },
@@ -104,5 +105,5 @@
104
105
  "publishConfig": {
105
106
  "access": "public"
106
107
  },
107
- "gitHead": "dcabfd315342d0d428c437a1e0915f080c38ea9f"
108
+ "gitHead": "efd204f4dc34b7717040a0105d2e148e8ad5ae17"
108
109
  }
@@ -0,0 +1,10 @@
1
+ .container {
2
+ padding: 30px;
3
+ }
4
+
5
+ .content {
6
+ display: grid;
7
+ grid-auto-rows: max-content;
8
+ grid-template-columns: 1fr;
9
+ row-gap: 20px;
10
+ }
@@ -0,0 +1,25 @@
1
+ import clsx from 'clsx';
2
+ import React from 'react';
3
+ import classes from './FormGrid.scss';
4
+
5
+ interface FormGridProps {
6
+ edgeToEdgeContent?: boolean;
7
+ }
8
+
9
+ export const FormGrid: React.FC<FormGridProps> = ({
10
+ children,
11
+ edgeToEdgeContent,
12
+ }) => {
13
+ return (
14
+ <div
15
+ className={clsx(
16
+ {
17
+ [classes.container]: !edgeToEdgeContent,
18
+ },
19
+ classes.content,
20
+ )}
21
+ >
22
+ {children}
23
+ </div>
24
+ );
25
+ };
@@ -0,0 +1 @@
1
+ export * from './FormGrid';
@@ -1,6 +1,7 @@
1
- import { FormikValues } from 'formik';
1
+ import { FormikHelpers, FormikValues } from 'formik';
2
+ import { Data } from '../../types';
2
3
  import { ActionData } from '../Actions';
3
- import { ErrorType } from '../models';
4
+ import { ErrorType, StationError } from '../models';
4
5
 
5
6
  export interface InitialFormData<T> {
6
7
  /** Indicates whether the data is still loading or not */
@@ -22,6 +23,15 @@ export interface InitialFormData<T> {
22
23
  error?: ErrorType;
23
24
  }
24
25
 
26
+ export type SaveDataFunction<TValues, TSubmitResponse> = (
27
+ /** The current values of the form */
28
+ values: TValues,
29
+ /** The initial values of the form */
30
+ initialData: InitialFormData<TValues>,
31
+ /** The Formik state helpers */
32
+ formikHelpers: FormikHelpers<TValues>,
33
+ ) => Promise<TSubmitResponse> | void;
34
+
25
35
  /**
26
36
  * A function to handle an action execution on a FormStation.
27
37
  * If action can not be performed, an error can be thrown which will then be displayed by the FormStation.
@@ -40,3 +50,19 @@ export type FormActionData<
40
50
  TValues = FormikValues,
41
51
  TSubmitResponse = unknown,
42
52
  > = ActionData<ActionHandler<TValues, TSubmitResponse>>;
53
+
54
+ export type ObjectSchemaDefinition<
55
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
56
+ T extends Data | null = any,
57
+ > = {
58
+ // TODO: Adding 'any' here since there are a couple of open issues regarding generics in the latest version of yup.
59
+ // https://github.com/jquense/yup/issues/1159
60
+ // https://github.com/jquense/yup/issues/1247
61
+ // Consider revisiting once 'yup' has addressed these issues.
62
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
63
+ [field in keyof T]: any;
64
+ };
65
+
66
+ export interface StationErrorStateType extends StationError {
67
+ type?: string;
68
+ }
@@ -13,85 +13,15 @@
13
13
  background-color: var(--details-background-color, $details-background-color);
14
14
 
15
15
  // Place PageHeader at the top
16
- > div:first-child {
16
+ .header {
17
17
  grid-column: 1 / -1;
18
18
  grid-row: 1 / 2;
19
19
  }
20
20
 
21
- // Extend all components, except PageHeader, to the bottom
22
- // Enable scrolling children
23
- .children {
24
- grid-row: 2 / -1;
25
- overflow-y: auto;
26
- display: grid;
27
- grid-template-columns: 1fr auto;
28
-
29
- overflow: hidden;
30
- overflow-x: auto;
31
-
32
- .main {
33
- display: grid;
34
- grid: 1fr / minmax(740px, 1fr) auto;
35
-
36
- overflow-y: auto;
37
- scrollbar-width: thin; //for Firefox only
38
-
39
- .formWrapper {
40
- display: grid;
41
- grid: 1fr / 1fr;
42
-
43
- &.hasMessage {
44
- grid: min-content 1fr / 1fr;
45
- }
46
- }
47
- }
48
-
49
- //Custom scrollbar for Chrome, Safari and Edge
50
- ::-webkit-scrollbar {
51
- width: var(--scrollbar-size, $scrollbar-size);
52
- height: var(--scrollbar-size, $scrollbar-size);
53
- }
54
- ::-webkit-scrollbar-track {
55
- background: var(--scrollbar-track-color, $scrollbar-track-color);
56
- }
57
-
58
- ::-webkit-scrollbar-thumb {
59
- background: var(--scrollbar-thumb-color, $scrollbar-thumb-color);
60
- }
61
-
62
- ::-webkit-scrollbar-thumb:hover {
63
- background: var(
64
- --scrollbar-thumb-hover-color,
65
- $scrollbar-thumb-hover-color
66
- );
67
- }
68
-
69
- ::-webkit-scrollbar-corner {
70
- background: var(--scrollbar-corner-color, $scrollbar-corner-color);
71
- }
72
-
73
- .formContainer {
74
- overflow-x: hidden;
75
- }
76
-
77
- .paddedContent {
78
- padding: 30px;
79
- }
80
-
81
- .loadingError {
82
- display: grid;
83
- grid: 1fr / 1fr;
84
- }
85
- }
86
21
  .actionsPanel {
87
22
  overflow: auto;
88
23
  }
89
24
 
90
- .children {
91
- grid-row: 2 / 3;
92
- grid-column: 1 / 2;
93
- }
94
-
95
25
  .actionsPanel {
96
26
  grid-row: 2 / 3;
97
27
  grid-column: 2 / 3;
@@ -104,55 +34,9 @@
104
34
  &.hasError {
105
35
  grid-template-rows: min-content min-content 1fr;
106
36
 
107
- .errorMessage {
108
- grid-row: 2 / 3;
109
- grid-column: 1 / -1;
110
- }
111
-
112
- .children {
113
- grid-row: 3 / 4;
114
- grid-column: 1 / 2;
115
- }
116
-
117
37
  .actionsPanel {
118
38
  grid-row: 3 / 4;
119
39
  grid-column: 2 / 3;
120
40
  }
121
41
  }
122
-
123
- form {
124
- display: grid;
125
- grid-auto-rows: max-content;
126
- grid-template-columns: 1fr;
127
- row-gap: 20px;
128
- }
129
- }
130
-
131
- .indicator {
132
- display: grid;
133
- grid-template-columns: auto 20px;
134
- font-weight: bold;
135
- color: var(--form-indicator-color, $form-indicator-color);
136
-
137
- &::after {
138
- overflow: hidden;
139
- display: inline-block;
140
- vertical-align: bottom;
141
- -webkit-animation: ellipsis steps(4, end) 900ms infinite;
142
- animation: ellipsis steps(4, end) 900ms infinite;
143
- content: '\2026'; /* ascii code for the ellipsis character */
144
- width: 0px;
145
- }
146
- }
147
-
148
- @keyframes ellipsis {
149
- to {
150
- width: 1.25em;
151
- }
152
- }
153
-
154
- @-webkit-keyframes ellipsis {
155
- to {
156
- width: 1.25em;
157
- }
158
42
  }
@@ -24,9 +24,11 @@ import { CheckboxField } from '../FormElements/Checkbox/CheckboxField';
24
24
  import { DynamicDataListField } from '../FormElements/DynamicDataListControl/DynamicDataListField';
25
25
  import { MaskedSingleLineTextField } from '../FormElements/MaskedSingleLineText/MaskedSingleLineTextField';
26
26
  import { InfoPanel, Paragraph, Section } from '../InfoPanel';
27
+ import { Tab, TabList, TabPanel, Tabs } from '../Tabs';
27
28
  import { ErrorType } from '../models';
28
29
  import { Details, DetailsProps } from './Details/Details';
29
- import { ObjectSchemaDefinition } from './FormStation';
30
+ import { FormGrid } from './FormGrid';
31
+ import { ObjectSchemaDefinition } from './FormStation.models';
30
32
 
31
33
  const groups = createGroups({
32
34
  Content: [
@@ -294,6 +296,169 @@ export const Extended: StoryObj<typeof Details> = (() => {
294
296
  };
295
297
  })();
296
298
 
299
+ export const TabbedContent: StoryObj<typeof Details> = (() => {
300
+ const listData = generateItemArray(4, (index) => ({
301
+ position: index + 1,
302
+ id: index,
303
+ locale: faker.random.locale(),
304
+ country: faker.address.country(),
305
+ }));
306
+ return {
307
+ args: {
308
+ titleProperty: 'title',
309
+ subtitle: 'Movies',
310
+ actions: generateActions(7),
311
+ validationSchema: Yup.object<ObjectSchemaDefinition<DetailsValues>>({
312
+ title: Yup.string().required().max(25).label('Title'),
313
+ genres: Yup.array<DetailsValues>()
314
+ .of(Yup.string())
315
+ .max(2)
316
+ .label('Genres'),
317
+ shortDescription: Yup.string().required().label('Short Description'),
318
+ cast: Yup.array<DetailsValues>().of(Yup.string()).min(1).label('Cast'),
319
+ }),
320
+ initialData: {
321
+ loading: false,
322
+ data: {
323
+ id: 12344567890,
324
+ title: 'My Movie',
325
+ publishState: 'PUBLISHED',
326
+ genres: [],
327
+ licenses: [],
328
+ ratings: 'PG-13',
329
+ shortDescription: 'Some short abstract...',
330
+ longDescription: '',
331
+ cast: ['Jane Doe', 'John Doe'],
332
+ released: '2020-04-03T00:00:00.000+00:00',
333
+ list: listData,
334
+ archived: false,
335
+ timestamp: '00:00:00.001',
336
+ },
337
+ },
338
+ children: (
339
+ <Tabs>
340
+ <TabList>
341
+ <Tab>Tab 1</Tab>
342
+ <Tab>Tab 2</Tab>
343
+ </TabList>
344
+ <TabPanel>
345
+ <FormGrid>
346
+ <Field name="id" label="Id" as={ReadOnlyField} />
347
+ <Field name="title" label="Title" as={SingleLineTextField} />
348
+ <Field
349
+ name="publishState"
350
+ label="Publish State"
351
+ as={ReadOnlyField}
352
+ />
353
+ <Field
354
+ name="genres"
355
+ label="Genre(s)"
356
+ tagsOptions={['Crime', 'Drama', 'Thriller']}
357
+ as={TagsField}
358
+ />
359
+
360
+ <Field
361
+ name="ratings"
362
+ label="Age Rating"
363
+ options={[
364
+ { value: 'PG', label: 'Parental Guidance Suggested (PG)' },
365
+ {
366
+ value: 'PG-13',
367
+ label: 'Parents Strongly Cautioned (PG-13)',
368
+ },
369
+ { value: 'R', label: 'Restricted (R)' },
370
+ ]}
371
+ as={SelectField}
372
+ />
373
+
374
+ <Field
375
+ name="shortDescription"
376
+ label="Short Description"
377
+ placeholder="Enter a short description..."
378
+ as={SingleLineTextField}
379
+ />
380
+ <Field
381
+ name="longDescription"
382
+ label="Long Description"
383
+ placeholder="Enter a description..."
384
+ as={SingleLineTextField}
385
+ />
386
+ <Field name="cast" label="Cast" as={CustomTagsField} />
387
+ <Field name="released" label="Released" as={DateTimeTextField} />
388
+ <Field
389
+ name="password"
390
+ label="Password"
391
+ as={SingleLineTextField}
392
+ type="password"
393
+ />
394
+
395
+ <Field
396
+ name="licenses"
397
+ label="License Countries"
398
+ tagsOptions={[
399
+ { value: 'DE', key: 'Germany' },
400
+ { value: 'EE', key: 'Estonia' },
401
+ { value: 'LK', key: 'Sri Lanka' },
402
+ ]}
403
+ as={TagsField}
404
+ displayKey="key"
405
+ valueKey="value"
406
+ />
407
+ <Field
408
+ name="list"
409
+ label="Subtitles"
410
+ columns={[
411
+ {
412
+ propertyName: 'id',
413
+ label: 'Id',
414
+ size: '50px',
415
+ },
416
+ {
417
+ propertyName: 'locale',
418
+ label: 'Locale',
419
+ dataEntryRender: createInputRenderer({
420
+ placeholder: 'Enter Locale',
421
+ }),
422
+ },
423
+ {
424
+ propertyName: 'country',
425
+ label: 'Country',
426
+ dataEntryRender: createSelectRenderer({
427
+ options: [
428
+ { value: 'Country 10', label: 'Country 10' },
429
+ { value: 'Country 11', label: 'Country 11' },
430
+ { value: 'Country 12', label: 'Country 12' },
431
+ ],
432
+ placeholder: 'Enter Country',
433
+ }),
434
+ },
435
+ ]}
436
+ data={listData}
437
+ positionPropertyName={'position'}
438
+ allowReordering={true}
439
+ allowRowDragging={true}
440
+ allowNewData={true}
441
+ as={DynamicDataListField}
442
+ />
443
+ <Field name="archived" label="Set Archived" as={CheckboxField} />
444
+ <Field
445
+ name="timestamp"
446
+ label="Timestamp"
447
+ mask="00:00:00.000"
448
+ as={MaskedSingleLineTextField}
449
+ />
450
+ </FormGrid>
451
+ </TabPanel>
452
+ <TabPanel>
453
+ <h2>Tab 2</h2>
454
+ <p>{faker.lorem.paragraph(20)}</p>
455
+ </TabPanel>
456
+ </Tabs>
457
+ ),
458
+ },
459
+ };
460
+ })();
461
+
297
462
  const errorGroups = createGroups({
298
463
  'Storybook (Loading Error)': [
299
464
  'loadingError',