@onewelcome/react-lib-components 8.3.0 → 8.4.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.
Files changed (156) hide show
  1. package/dist/cjs/DataGrid/DataGridBody/DataGridCell/DataGridCell.module.scss.cjs.js +1 -1
  2. package/dist/cjs/DataGrid/DataGridBody/DataGridRow/DataGridRow.module.scss.cjs.js +1 -1
  3. package/dist/cjs/DataGrid/DataGridFilters/DataGridFilters.interfaces.cjs.js.map +1 -1
  4. package/dist/cjs/DataGrid/DataGridFilters/DataGridSearchbar.cjs.js.map +1 -1
  5. package/dist/cjs/DataGrid/DataGridFilters/FilterKeyMapper.cjs.js +2 -0
  6. package/dist/cjs/DataGrid/DataGridFilters/FilterKeyMapper.cjs.js.map +1 -0
  7. package/dist/cjs/DataGrid/DataGridHeader/DataGridHeader.module.scss.cjs.js +1 -1
  8. package/dist/cjs/Form/FileUpload/FileItem/FileItem.cjs.js +1 -1
  9. package/dist/cjs/Form/FileUpload/FileItem/FileItem.cjs.js.map +1 -1
  10. package/dist/cjs/Form/FileUpload/FileItem/FileItem.module.scss.cjs.js +1 -1
  11. package/dist/cjs/Form/FileUpload/FileUpload.cjs.js +1 -1
  12. package/dist/cjs/Form/FileUpload/FileUpload.cjs.js.map +1 -1
  13. package/dist/cjs/Form/FileUpload/FileUpload.module.scss.cjs.js +1 -1
  14. package/dist/cjs/Icon/Icon.cjs.js +1 -1
  15. package/dist/cjs/Icon/Icon.cjs.js.map +1 -1
  16. package/dist/cjs/Icon/Icon.module.scss.cjs.js +1 -1
  17. package/dist/cjs/Notifications/BaseModal/BaseModal.cjs.js +1 -1
  18. package/dist/cjs/Notifications/BaseModal/BaseModal.cjs.js.map +1 -1
  19. package/dist/cjs/Notifications/BaseModal/BaseModalHeader/BaseModalHeader.cjs.js +1 -1
  20. package/dist/cjs/Notifications/BaseModal/BaseModalHeader/BaseModalHeader.cjs.js.map +1 -1
  21. package/dist/cjs/Notifications/SideSheet/SideSheet.cjs.js +2 -0
  22. package/dist/cjs/Notifications/SideSheet/SideSheet.cjs.js.map +1 -0
  23. package/dist/cjs/Notifications/SideSheet/SideSheet.module.scss.cjs.js +2 -0
  24. package/dist/cjs/Notifications/SideSheet/SideSheet.module.scss.cjs.js.map +1 -0
  25. package/dist/cjs/Notifications/SideSheet/SideSheetContent/SideSheetContent.cjs.js +2 -0
  26. package/dist/cjs/Notifications/SideSheet/SideSheetContent/SideSheetContent.cjs.js.map +1 -0
  27. package/dist/cjs/Notifications/SideSheet/SideSheetContent/SideSheetContent.module.scss.cjs.js +2 -0
  28. package/dist/cjs/Notifications/SideSheet/SideSheetContent/SideSheetContent.module.scss.cjs.js.map +1 -0
  29. package/dist/cjs/Notifications/SideSheet/SideSheetHeader/SideSheetHeader.cjs.js +2 -0
  30. package/dist/cjs/Notifications/SideSheet/SideSheetHeader/SideSheetHeader.cjs.js.map +1 -0
  31. package/dist/cjs/Notifications/SideSheet/SideSheetHeader/SideSheetHeader.module.scss.cjs.js +2 -0
  32. package/dist/cjs/Notifications/SideSheet/SideSheetHeader/SideSheetHeader.module.scss.cjs.js.map +1 -0
  33. package/dist/cjs/Notifications/SlideInModal/SlideInModal.cjs.js.map +1 -1
  34. package/dist/cjs/_BaseStyling_/BaseStyling.cjs.js +1 -1
  35. package/dist/cjs/_BaseStyling_/BaseStyling.cjs.js.map +1 -1
  36. package/dist/cjs/src/components/DataGrid/DataGridFilters/DataGridFilters.interfaces.d.ts +4 -0
  37. package/dist/cjs/src/components/DataGrid/DataGridFilters/DataGridSearchbar.d.ts +1 -1
  38. package/dist/cjs/src/components/DataGrid/DataGridFilters/FilterKeyMapper.d.ts +14 -0
  39. package/dist/cjs/src/components/DataGrid/DataGridFilters/FilterKeyMapper.test.d.ts +1 -0
  40. package/dist/cjs/src/components/DataGrid/testUtils.d.ts +3 -1
  41. package/dist/cjs/src/components/Form/Select/MultiSelect/MultiSelect.test.d.ts +1 -2
  42. package/dist/cjs/src/components/Form/Select/SingleSelect/Select.test.d.ts +1 -2
  43. package/dist/cjs/src/components/Icon/Icon.d.ts +2 -1
  44. package/dist/cjs/src/components/Notifications/BaseModal/BaseModal.d.ts +1 -0
  45. package/dist/cjs/src/components/Notifications/BaseModal/BaseModalHeader/BaseModalHeader.d.ts +1 -0
  46. package/dist/cjs/src/components/Notifications/SideSheet/SideSheet.d.ts +10 -0
  47. package/dist/cjs/src/components/Notifications/SideSheet/SideSheet.test.d.ts +1 -0
  48. package/dist/cjs/src/components/Notifications/SideSheet/SideSheetActions/SideSheetActions.d.ts +2 -0
  49. package/dist/cjs/src/components/Notifications/SideSheet/SideSheetContent/SideSheetContent.d.ts +4 -0
  50. package/dist/cjs/src/components/Notifications/SideSheet/SideSheetHeader/SideSheetHeader.d.ts +4 -0
  51. package/dist/cjs/src/components/Typography/Typography.d.ts +1 -1
  52. package/dist/cjs/src/components/_BaseStyling_/BaseStyling.d.ts +2 -0
  53. package/dist/cjs/src/hooks/useUploadFile.cjs.js +2 -0
  54. package/dist/cjs/src/hooks/useUploadFile.cjs.js.map +1 -0
  55. package/dist/cjs/src/hooks/useUploadFile.d.ts +10 -4
  56. package/dist/cjs/src/index.cjs.js +1 -1
  57. package/dist/cjs/src/index.d.ts +17 -2
  58. package/dist/cjs/src/util/helper.cjs.js +1 -1
  59. package/dist/cjs/src/util/helper.cjs.js.map +1 -1
  60. package/dist/cjs/src/util/helper.d.ts +0 -3
  61. package/dist/esm/DataGrid/DataGridBody/DataGridCell/DataGridCell.module.scss.esm.js +1 -1
  62. package/dist/esm/DataGrid/DataGridBody/DataGridRow/DataGridRow.module.scss.esm.js +1 -1
  63. package/dist/esm/DataGrid/DataGridFilters/DataGridFilters.interfaces.esm.js.map +1 -1
  64. package/dist/esm/DataGrid/DataGridFilters/DataGridSearchbar.esm.js.map +1 -1
  65. package/dist/esm/DataGrid/DataGridFilters/FilterKeyMapper.esm.js +46 -0
  66. package/dist/esm/DataGrid/DataGridFilters/FilterKeyMapper.esm.js.map +1 -0
  67. package/dist/esm/DataGrid/DataGridHeader/DataGridHeader.module.scss.esm.js +2 -2
  68. package/dist/esm/Form/FileUpload/FileItem/FileItem.esm.js +4 -3
  69. package/dist/esm/Form/FileUpload/FileItem/FileItem.esm.js.map +1 -1
  70. package/dist/esm/Form/FileUpload/FileItem/FileItem.module.scss.esm.js +1 -1
  71. package/dist/esm/Form/FileUpload/FileUpload.esm.js +8 -7
  72. package/dist/esm/Form/FileUpload/FileUpload.esm.js.map +1 -1
  73. package/dist/esm/Form/FileUpload/FileUpload.module.scss.esm.js +2 -2
  74. package/dist/esm/Icon/Icon.esm.js +1 -0
  75. package/dist/esm/Icon/Icon.esm.js.map +1 -1
  76. package/dist/esm/Icon/Icon.module.scss.esm.js +2 -2
  77. package/dist/esm/Notifications/BaseModal/BaseModal.esm.js +2 -2
  78. package/dist/esm/Notifications/BaseModal/BaseModal.esm.js.map +1 -1
  79. package/dist/esm/Notifications/BaseModal/BaseModalHeader/BaseModalHeader.esm.js +4 -3
  80. package/dist/esm/Notifications/BaseModal/BaseModalHeader/BaseModalHeader.esm.js.map +1 -1
  81. package/dist/esm/Notifications/SideSheet/SideSheet.esm.js +59 -0
  82. package/dist/esm/Notifications/SideSheet/SideSheet.esm.js.map +1 -0
  83. package/dist/esm/Notifications/SideSheet/SideSheet.module.scss.esm.js +8 -0
  84. package/dist/esm/Notifications/SideSheet/SideSheet.module.scss.esm.js.map +1 -0
  85. package/dist/esm/Notifications/SideSheet/SideSheetContent/SideSheetContent.esm.js +23 -0
  86. package/dist/esm/Notifications/SideSheet/SideSheetContent/SideSheetContent.esm.js.map +1 -0
  87. package/dist/esm/Notifications/SideSheet/SideSheetContent/SideSheetContent.module.scss.esm.js +8 -0
  88. package/dist/esm/Notifications/SideSheet/SideSheetContent/SideSheetContent.module.scss.esm.js.map +1 -0
  89. package/dist/esm/Notifications/SideSheet/SideSheetHeader/SideSheetHeader.esm.js +23 -0
  90. package/dist/esm/Notifications/SideSheet/SideSheetHeader/SideSheetHeader.esm.js.map +1 -0
  91. package/dist/esm/Notifications/SideSheet/SideSheetHeader/SideSheetHeader.module.scss.esm.js +8 -0
  92. package/dist/esm/Notifications/SideSheet/SideSheetHeader/SideSheetHeader.module.scss.esm.js.map +1 -0
  93. package/dist/esm/Notifications/SlideInModal/SlideInModal.esm.js +3 -0
  94. package/dist/esm/Notifications/SlideInModal/SlideInModal.esm.js.map +1 -1
  95. package/dist/esm/_BaseStyling_/BaseStyling.esm.js +2 -0
  96. package/dist/esm/_BaseStyling_/BaseStyling.esm.js.map +1 -1
  97. package/dist/esm/src/components/DataGrid/DataGridFilters/DataGridFilters.interfaces.d.ts +4 -0
  98. package/dist/esm/src/components/DataGrid/DataGridFilters/DataGridSearchbar.d.ts +1 -1
  99. package/dist/esm/src/components/DataGrid/DataGridFilters/FilterKeyMapper.d.ts +14 -0
  100. package/dist/esm/src/components/DataGrid/DataGridFilters/FilterKeyMapper.test.d.ts +1 -0
  101. package/dist/esm/src/components/DataGrid/testUtils.d.ts +3 -1
  102. package/dist/esm/src/components/Form/Select/MultiSelect/MultiSelect.test.d.ts +1 -2
  103. package/dist/esm/src/components/Form/Select/SingleSelect/Select.test.d.ts +1 -2
  104. package/dist/esm/src/components/Icon/Icon.d.ts +2 -1
  105. package/dist/esm/src/components/Notifications/BaseModal/BaseModal.d.ts +1 -0
  106. package/dist/esm/src/components/Notifications/BaseModal/BaseModalHeader/BaseModalHeader.d.ts +1 -0
  107. package/dist/esm/src/components/Notifications/SideSheet/SideSheet.d.ts +10 -0
  108. package/dist/esm/src/components/Notifications/SideSheet/SideSheet.test.d.ts +1 -0
  109. package/dist/esm/src/components/Notifications/SideSheet/SideSheetActions/SideSheetActions.d.ts +2 -0
  110. package/dist/esm/src/components/Notifications/SideSheet/SideSheetContent/SideSheetContent.d.ts +4 -0
  111. package/dist/esm/src/components/Notifications/SideSheet/SideSheetHeader/SideSheetHeader.d.ts +4 -0
  112. package/dist/esm/src/components/Typography/Typography.d.ts +1 -1
  113. package/dist/esm/src/components/_BaseStyling_/BaseStyling.d.ts +2 -0
  114. package/dist/esm/src/hooks/useUploadFile.d.ts +10 -4
  115. package/dist/esm/src/hooks/useUploadFile.esm.js +101 -0
  116. package/dist/esm/src/hooks/useUploadFile.esm.js.map +1 -0
  117. package/dist/esm/src/index.d.ts +17 -2
  118. package/dist/esm/src/index.esm.js +7 -1
  119. package/dist/esm/src/index.esm.js.map +1 -1
  120. package/dist/esm/src/util/helper.d.ts +0 -3
  121. package/dist/esm/src/util/helper.esm.js +10 -1
  122. package/dist/esm/src/util/helper.esm.js.map +1 -1
  123. package/package.json +22 -22
  124. package/src/components/DataGrid/DataGridBody/DataGridCell/DataGridCell.module.scss +1 -1
  125. package/src/components/DataGrid/DataGridBody/DataGridRow/DataGridRow.module.scss +8 -24
  126. package/src/components/DataGrid/DataGridFilters/DataGridFilters.interfaces.ts +5 -0
  127. package/src/components/DataGrid/DataGridFilters/DataGridSearchbar.tsx +5 -2
  128. package/src/components/DataGrid/DataGridFilters/FilterKeyMapper.ts +48 -0
  129. package/src/components/DataGrid/DataGridHeader/DataGridHeader.module.scss +9 -8
  130. package/src/components/DataGrid/dataGridMixins.module.scss +33 -0
  131. package/src/components/DataGrid/testUtils.ts +39 -32
  132. package/src/components/Form/FileUpload/FileItem/FileItem.module.scss +6 -3
  133. package/src/components/Form/FileUpload/FileItem/FileItem.tsx +3 -1
  134. package/src/components/Form/FileUpload/FileUpload.module.scss +12 -5
  135. package/src/components/Form/FileUpload/FileUpload.tsx +10 -7
  136. package/src/components/Icon/Icon.module.scss +5 -0
  137. package/src/components/Icon/Icon.tsx +2 -1
  138. package/src/components/Notifications/BaseModal/BaseModal.tsx +10 -6
  139. package/src/components/Notifications/BaseModal/BaseModalHeader/BaseModalHeader.tsx +14 -2
  140. package/src/components/Notifications/SideSheet/SideSheet.module.scss +96 -0
  141. package/src/components/Notifications/SideSheet/SideSheet.tsx +114 -0
  142. package/src/components/Notifications/SideSheet/SideSheetActions/SideSheetActions.tsx +18 -0
  143. package/src/components/Notifications/SideSheet/SideSheetContent/SideSheetContent.module.scss +19 -0
  144. package/src/components/Notifications/SideSheet/SideSheetContent/SideSheetContent.tsx +25 -0
  145. package/src/components/Notifications/SideSheet/SideSheetHeader/SideSheetHeader.module.scss +19 -0
  146. package/src/components/Notifications/SideSheet/SideSheetHeader/SideSheetHeader.tsx +25 -0
  147. package/src/components/Notifications/SlideInModal/SlideInModal.tsx +3 -0
  148. package/src/components/_BaseStyling_/BaseStyling.tsx +4 -0
  149. package/src/font/icomoon.eot +0 -0
  150. package/src/font/icomoon.svg +1 -0
  151. package/src/font/icomoon.ttf +0 -0
  152. package/src/font/icomoon.woff +0 -0
  153. package/src/font/selection.json +1 -1
  154. package/src/hooks/useUploadFile.tsx +27 -25
  155. package/src/index.ts +27 -2
  156. package/src/util/helper.tsx +0 -6
@@ -0,0 +1,48 @@
1
+ /*
2
+ * Copyright 2022 OneWelcome B.V.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { KeyValuePair } from "./DataGridFilters.interfaces";
18
+
19
+ export class FilterKeyMapper {
20
+ columnKvPairs = new Map<string, { key: string; value: string }[]>();
21
+
22
+ setColumnKvPairs(columnName: string, kvPairs: { key: string; value: string }[]) {
23
+ this.columnKvPairs.set(columnName, kvPairs);
24
+ }
25
+
26
+ getValues(columnName: string): string[] {
27
+ return this.getKvPairs(columnName).map(kv => kv.value);
28
+ }
29
+
30
+ getKeysForValues(columnName: string, values: string[]): string[] {
31
+ const kvPairs = this.getKvPairs(columnName);
32
+ return values.map(v => {
33
+ const kv = kvPairs?.find(kv => kv.value === v);
34
+ if (kv == undefined) {
35
+ throw new Error(`Column '${columnName}' in FilterKeyMapper does not contain value '${v}'`);
36
+ }
37
+ return kv.key;
38
+ });
39
+ }
40
+
41
+ getKvPairs(columnName: string): KeyValuePair[] {
42
+ const kvPairs = this.columnKvPairs.get(columnName);
43
+ if (kvPairs == undefined) {
44
+ throw new Error(`Column '${columnName}' not found in ${FilterKeyMapper.name}`);
45
+ }
46
+ return kvPairs;
47
+ }
48
+ }
@@ -13,19 +13,20 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
+ @use "../dataGridMixins.module";
16
17
 
17
18
  .row {
18
- height: 2.5rem;
19
+ height: 3.25rem;
20
+ background-color: var(--color-blue-grey25);
21
+ position: relative;
22
+ border-top: 2px solid var(--light-grey-border);
23
+
24
+ &::after {
25
+ @include dataGridMixins.borderAfter(0, true);
26
+ }
19
27
  }
20
28
 
21
29
  .context-menu {
22
30
  width: 4.125rem;
23
31
  box-sizing: border-box;
24
32
  }
25
-
26
- @media only screen and (min-width: 50em) {
27
- .thead::after {
28
- width: calc(100% - 2.5rem);
29
- left: 1.25rem;
30
- }
31
- }
@@ -0,0 +1,33 @@
1
+ /*!
2
+ * Copyright 2022 OneWelcome B.V.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ @mixin borderAfter($i, $no-offset: false) {
18
+ content: "";
19
+ position: absolute;
20
+
21
+ @if $no-offset {
22
+ width: 100%;
23
+ left: 0;
24
+ } @else if $i > 0 {
25
+ width: calc(100% - calc(3.0625rem + $i * 4.125rem));
26
+ left: calc(3.0625rem + $i * 4.125rem);
27
+ } @else {
28
+ width: calc(100% - 3.0625rem);
29
+ left: 3.0625rem;
30
+ }
31
+ bottom: 0;
32
+ border-bottom: 2px solid var(--light-grey-border);
33
+ }
@@ -18,48 +18,39 @@ import { useEffect, useState } from "react";
18
18
  import { Filter } from "./DataGridFilters/DataGridFilters.interfaces";
19
19
  import { useFiltersReducer } from "./DataGridFilters/useFiltersReducer";
20
20
 
21
+ type OperatorPredicateMap<TOperator extends string> = {
22
+ [op in TOperator]: (v1: string, v2: string) => boolean;
23
+ };
24
+
25
+ const operatorPredicateMap: OperatorPredicateMap<string> = {
26
+ is: (v1, v2) => v1 === v2,
27
+ "is not": (v1, v2) => v1 !== v2
28
+ };
29
+
30
+ function reduceConjunction<T>(arr: T[], fn: (v: T) => boolean) {
31
+ return arr.reduce((acc, val) => fn(val) && acc, true);
32
+ }
33
+ function reduceDisjunction<T>(arr: T[], fn: (v: T) => boolean) {
34
+ return arr.reduce((acc, val) => fn(val) || acc, false);
35
+ }
36
+
21
37
  /**
22
38
  * @scope .
23
39
  * @scopeException stories/DataGrid/DataGrid.stories.tsx
24
40
  */
25
- export const useMockFilteringLogic = <T>(data: T[], filterValues: Filter[] | undefined) => {
41
+ export const useMockFilteringLogic = <T extends { [k: string]: string }>(
42
+ data: T[],
43
+ filterValues: Filter[] | undefined
44
+ ) => {
26
45
  const { state, addFilter, editFilter, deleteFilter, clearFilters } =
27
46
  useFiltersReducer(filterValues);
28
47
 
29
48
  const [gridData, setGridData] = useState(data);
30
49
 
31
- const operatorPredicateMap = {
32
- is: (v1: string, v2: string) => v1 === v2,
33
- "is not": (v1: string, v2: string) => v1 !== v2
34
- };
35
-
36
50
  useEffect(() => {
37
- const filteredData = data
38
- .map((row: T) => {
39
- let shouldBeDiscarded: boolean[] = [];
40
- state.filters.forEach(filter => {
41
- shouldBeDiscarded = [
42
- ...shouldBeDiscarded,
43
- !filter.value.reduce((acc, val) => {
44
- return (
45
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
46
- (operatorPredicateMap[filter.operator as keyof typeof operatorPredicateMap] as any)(
47
- row[filter.column as keyof typeof row],
48
- val
49
- ) && acc
50
- );
51
- }, true)
52
- ];
53
- });
54
-
55
- return shouldBeDiscarded.length > 0 &&
56
- shouldBeDiscarded.reduce((acc, val) => acc || val, false)
57
- ? undefined
58
- : row;
59
- })
60
- .filter(val => {
61
- return val !== undefined;
62
- }) as T[];
51
+ const filteredData = data.map(filterRow).filter(val => {
52
+ return val !== undefined;
53
+ });
63
54
  setGridData(filteredData);
64
55
  }, [state.filters]);
65
56
 
@@ -72,4 +63,20 @@ export const useMockFilteringLogic = <T>(data: T[], filterValues: Filter[] | und
72
63
  setGridData,
73
64
  filters: state.filters
74
65
  };
66
+
67
+ function filterRow(row: T) {
68
+ let shouldBeDiscarded: boolean[] = [];
69
+ state.filters.forEach(filter => {
70
+ const reduce = filter.operator == "is" ? reduceDisjunction : reduceConjunction;
71
+ const operatorPredicate = operatorPredicateMap[filter.operator];
72
+ shouldBeDiscarded = [
73
+ ...shouldBeDiscarded,
74
+ !reduce(filter.value, val => operatorPredicate(row[filter.column], val))
75
+ ];
76
+ });
77
+
78
+ return shouldBeDiscarded.length > 0 && shouldBeDiscarded.reduce((acc, val) => acc || val, false)
79
+ ? undefined
80
+ : row;
81
+ }
75
82
  };
@@ -87,7 +87,7 @@
87
87
  align-items: center;
88
88
 
89
89
  .progress-bar {
90
- height: 3rem;
90
+ min-height: 3rem;
91
91
  width: 100%;
92
92
  background: transparent;
93
93
 
@@ -119,9 +119,9 @@
119
119
  font-size: 0.875rem;
120
120
 
121
121
  .friendly-name {
122
- overflow: hidden;
122
+ overflow-wrap: anywhere;
123
123
  text-overflow: ellipsis;
124
- white-space: nowrap;
124
+ text-wrap: wrap;
125
125
  }
126
126
 
127
127
  &.error {
@@ -169,6 +169,9 @@
169
169
  display: block;
170
170
  margin: 0.3125rem 1.75rem;
171
171
  padding: 0;
172
+ overflow-wrap: anywhere;
173
+ text-overflow: ellipsis;
174
+ text-wrap: wrap;
172
175
  }
173
176
 
174
177
  .error,
@@ -195,7 +195,9 @@ const FileItemComponent: ForwardRefRenderFunction<HTMLDivElement, Props> = (
195
195
  />
196
196
  )}
197
197
  <Icon icon={icons.fileIcon} className={classes["file-icon"]} />
198
- <span className={classes["friendly-name"]}>{friendlyName}</span>.<span>{extension}</span>
198
+ <span className={classes["friendly-name"]}>
199
+ {friendlyName}.{extension}
200
+ </span>
199
201
  </Typography>
200
202
  );
201
203
  };
@@ -28,8 +28,19 @@
28
28
 
29
29
  .file-upload-title {
30
30
  margin: 0 0 0.25rem 0;
31
- font-size: 0.875rem;
31
+ font-family: var(--font-family);
32
+ font-size: var(--form-control-font-size);
33
+ line-height: var(--default-line-height);
34
+ color: var(--color-blue-grey900);
32
35
  font-weight: 400;
36
+ display: block;
37
+
38
+ &.required {
39
+ &:after {
40
+ content: " *";
41
+ color: var(--error);
42
+ }
43
+ }
33
44
  }
34
45
 
35
46
  &.error {
@@ -66,10 +77,6 @@
66
77
  right: 2rem;
67
78
  }
68
79
 
69
- .file-upload-title-mandatory {
70
- color: var(--color-red500);
71
- }
72
-
73
80
  & {
74
81
  @include transition(all, 0.2s, ease-in-out);
75
82
  }
@@ -28,6 +28,7 @@ import { Props as InputProps } from "../Input/Input";
28
28
  import { Typography } from "../../Typography/Typography";
29
29
  import classes from "./FileUpload.module.scss";
30
30
  import { useDetermineStatusIcon } from "../../../hooks/useDetermineStatusIcon";
31
+ import { Label } from "../Label/Label";
31
32
 
32
33
  type FileUploadType = Omit<InputProps, "onDrop" | "type" | "onChange" | "suffix" | "prefix">;
33
34
  export type FileType = Omit<FileConfig, "onRequestedFileAction"> &
@@ -105,6 +106,9 @@ const FileUploadComponent: ForwardRefRenderFunction<HTMLInputElement, Props> = (
105
106
  }
106
107
  disabled && dropzoneContainerClassNames.push(classes["disabled"]);
107
108
  success && !error && dropzoneClassNames.push(classes["success"]);
109
+ const inputId = `input-${name}`;
110
+ const labelClasses = [classes["file-upload-title"]];
111
+ isRequired && labelClasses.push(classes["required"]);
108
112
 
109
113
  const getFileList = (files: FileList | null): FileType[] => {
110
114
  let savedFiles = fileList ? [...fileList] : [];
@@ -160,9 +164,9 @@ const FileUploadComponent: ForwardRefRenderFunction<HTMLInputElement, Props> = (
160
164
  const isAtLeastOneMb = maxFileSizeInBytes >= 1024 * 1024;
161
165
 
162
166
  if (isAtLeastOneMb) {
163
- sizeMessage = `${(maxFileSizeInBytes / (1024 * 1024)).toFixed(2)}MB`;
167
+ sizeMessage = `${parseFloat((maxFileSizeInBytes / (1024 * 1024)).toFixed(2))}MB`;
164
168
  } else {
165
- sizeMessage = `${(maxFileSizeInBytes / 1024).toFixed(2)}KB`;
169
+ sizeMessage = `${parseFloat((maxFileSizeInBytes / 1024).toFixed(2))}KB`;
166
170
  }
167
171
 
168
172
  result.error =
@@ -228,11 +232,9 @@ const FileUploadComponent: ForwardRefRenderFunction<HTMLInputElement, Props> = (
228
232
  <div className={classes["file-upload-wrapper"]} {...wrapperProps}>
229
233
  <div className={classes["dropzone-wrapper"]}>
230
234
  <div className={dropzoneClassNames.join(" ")}>
231
- <Typography variant="body-bold" className={classes["file-upload-title"]} ref={labelRef}>
232
- {title}{" "}
233
- {isRequired && <span className={classes["file-upload-title-mandatory"]}>*</span>}
234
- </Typography>
235
-
235
+ <Label ref={labelRef} className={`${labelClasses.join(" ")}`} htmlFor={inputId}>
236
+ {title}
237
+ </Label>
236
238
  {fileList?.length > 0 && (
237
239
  <ul className={classes["file-list"]}>
238
240
  {fileList.map(({ name, status, progress, error }) => (
@@ -271,6 +273,7 @@ const FileUploadComponent: ForwardRefRenderFunction<HTMLInputElement, Props> = (
271
273
  ref={ref}
272
274
  aria-labelledby={labeledBy}
273
275
  type="file"
276
+ id={inputId}
274
277
  name={name}
275
278
  multiple={multiple}
276
279
  disabled={disabled}
@@ -377,3 +377,8 @@
377
377
  content: "\e950";
378
378
  @include fontProperties();
379
379
  }
380
+
381
+ .icon-sidesheet-handle:before {
382
+ content: "\e951";
383
+ @include fontProperties();
384
+ }
@@ -100,7 +100,8 @@ export enum Icons {
100
100
  ZoomIn = "zoom-in",
101
101
  ZoomOut = "zoom-out",
102
102
  ArrowUp = "arrow-up",
103
- ExternalLink = "external-link"
103
+ ExternalLink = "external-link",
104
+ SideSheetHandle = "sidesheet-handle"
104
105
  }
105
106
 
106
107
  type Tag = "span" | "div" | "i";
@@ -44,6 +44,7 @@ export interface Props extends ComponentPropsWithRef<"div"> {
44
44
  describedby?: string;
45
45
  disableEscapeKeyDown?: boolean;
46
46
  disableBackdrop?: boolean;
47
+ hideBackdrop?: boolean;
47
48
  forceContainerOpen?: boolean;
48
49
  zIndex?: number;
49
50
  domRoot?: HTMLElement;
@@ -84,6 +85,7 @@ const BaseModalComponent: ForwardRefRenderFunction<HTMLDivElement, Props> = (
84
85
  describedby,
85
86
  disableEscapeKeyDown = false,
86
87
  disableBackdrop = false,
88
+ hideBackdrop = false,
87
89
  forceContainerOpen = false,
88
90
  zIndex,
89
91
  domRoot,
@@ -141,12 +143,14 @@ const BaseModalComponent: ForwardRefRenderFunction<HTMLDivElement, Props> = (
141
143
  onKeyDown={handleEscKeyPress}
142
144
  style={{ zIndex }}
143
145
  >
144
- <div
145
- {...backdropProps}
146
- aria-hidden={true}
147
- className={`${classes["backdrop"]} ${backdropProps?.className ?? ""}`}
148
- onClick={handleBackdropClick}
149
- ></div>
146
+ {!hideBackdrop ? (
147
+ <div
148
+ {...backdropProps}
149
+ aria-hidden={true}
150
+ className={`${classes["backdrop"]} ${backdropProps?.className ?? ""}`}
151
+ onClick={handleBackdropClick}
152
+ ></div>
153
+ ) : null}
150
154
  {forceContainerOpen ? (
151
155
  <div
152
156
  {...containerProps}
@@ -23,16 +23,17 @@ import { Typography } from "../../../Typography/Typography";
23
23
  export interface Props extends ComponentPropsWithRef<"div"> {
24
24
  id: string;
25
25
  title: string;
26
+ description?: string;
26
27
  children?: React.ReactNode;
27
28
  onClose?: (event: React.MouseEvent<HTMLButtonElement>) => void;
28
29
  }
29
30
 
30
31
  const BaseModalHeaderComponent: ForwardRefRenderFunction<HTMLDivElement, Props> = (
31
- { id, title, children, onClose, ...rest }: Props,
32
+ { id, title, children, onClose, description, className, ...rest }: Props,
32
33
  ref
33
34
  ) => {
34
35
  return (
35
- <div {...rest} ref={ref} className={classes["header"]}>
36
+ <div {...rest} ref={ref} className={`${classes["header"]} ${className}`}>
36
37
  <div className={classes["headline"]}>
37
38
  <div className={classes["title-wrapper"]}>
38
39
  <Typography
@@ -44,6 +45,17 @@ const BaseModalHeaderComponent: ForwardRefRenderFunction<HTMLDivElement, Props>
44
45
  >
45
46
  {title}
46
47
  </Typography>
48
+ {description && (
49
+ <Typography
50
+ id={id}
51
+ className={classes["title"]}
52
+ tag="span"
53
+ spacing={{ marginBottom: 0 }}
54
+ variant="body"
55
+ >
56
+ {description}
57
+ </Typography>
58
+ )}
47
59
  </div>
48
60
  <IconButton onClick={onClose} className={classes["closeBtn"]} title="close modal">
49
61
  <Icon icon={Icons.Times} />
@@ -0,0 +1,96 @@
1
+ /*!
2
+ * Copyright 2022 OneWelcome B.V.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ @use "../../../mixins.module.scss";
18
+
19
+ .slide-in-modal {
20
+ right: 0;
21
+ left: auto;
22
+
23
+ justify-content: flex-end;
24
+
25
+ min-width: 25rem;
26
+ width: 33vw;
27
+ max-width: 40rem;
28
+
29
+ visibility: visible;
30
+
31
+ transform: translate(calc(100% - 0.5rem));
32
+ @include mixins.transition(transform, 0.5s, ease-in-out);
33
+
34
+ &.hide {
35
+ visibility: hidden;
36
+ }
37
+
38
+ &.visible {
39
+ visibility: visible;
40
+ transform: translate(0%);
41
+
42
+ #backdrop-slide {
43
+ background-color: transparent;
44
+ }
45
+ }
46
+ }
47
+
48
+ .handle {
49
+ position: absolute;
50
+ top: 13.25rem;
51
+ left: -1.5rem;
52
+
53
+ display: flex;
54
+ align-items: center;
55
+ justify-content: center;
56
+
57
+ width: 1.5rem;
58
+ height: 2.5rem;
59
+ padding: 0.5rem 0;
60
+ border-top-left-radius: 4px;
61
+ border-bottom-left-radius: 4px;
62
+ background-color: var(--modal-background-color);
63
+ box-shadow:
64
+ -4px 4px 5px 0px var(--side-sheet-shadow-color-one),
65
+ -4px 3px 14px 0px var(--side-sheet-shadow-color-two),
66
+ -4px 8px 10px 0px var(--side-sheet-shadow-color-two);
67
+ }
68
+
69
+ .handle-button {
70
+ transform: rotateY(180deg);
71
+ }
72
+
73
+ .collapsed-sheet {
74
+ position: absolute;
75
+ top: 0;
76
+ right: 0;
77
+ width: 0.5rem;
78
+ height: 100vh;
79
+ background-color: var(--modal-background-color);
80
+ box-shadow:
81
+ 0px 4px 5px 0px var(--side-sheet-shadow-color-one),
82
+ 0px 3px 14px 0px var(--side-sheet-shadow-color-two),
83
+ 0px 8px 10px 0px var(--side-sheet-shadow-color-two);
84
+ }
85
+
86
+ .container {
87
+ margin-top: 0;
88
+ width: 50rem;
89
+ height: 100%;
90
+ max-height: unset;
91
+ border-radius: 0;
92
+ box-shadow:
93
+ 0px 4px 5px 0px var(--side-sheet-shadow-color-one),
94
+ 0px 3px 14px 0px var(--side-sheet-shadow-color-two),
95
+ 0px 8px 10px 0px var(--side-sheet-shadow-color-two);
96
+ }
@@ -0,0 +1,114 @@
1
+ /*
2
+ * Copyright 2022 OneWelcome B.V.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import React, {
18
+ ForwardRefRenderFunction,
19
+ TransitionEventHandler,
20
+ useState,
21
+ useRef,
22
+ useCallback,
23
+ useEffect
24
+ } from "react";
25
+ import { Props as ModalProps, Modal } from "../Modal/Modal";
26
+ import classes from "./SideSheet.module.scss";
27
+ import { IconButton } from "../../Button/IconButton";
28
+ import { Icon, Icons } from "../../Icon/Icon";
29
+
30
+ export interface Props extends Omit<ModalProps, "hideBackdrop" | "disableBackdrop"> {
31
+ handleButtonProps?: {
32
+ onOpen: () => void;
33
+ onClose: () => void;
34
+ title?: string;
35
+ };
36
+ }
37
+
38
+ const SideSheetComponent: ForwardRefRenderFunction<HTMLDivElement, Props> = (
39
+ { children, id, open, handleButtonProps, ...rest }: Props,
40
+ ref
41
+ ) => {
42
+ const [classHideOnTransition, setClassHideOnTransition] = useState<string>("hide");
43
+ const [controlledOpen, setControlledOpen] = useState(false);
44
+ const containerRef = useRef(null);
45
+ const handleTitle = handleButtonProps?.title ?? "Side sheet handle";
46
+ const handleButtonStyle = {
47
+ width: "1.5rem",
48
+ height: "3.5rem",
49
+ borderTopLeftRadius: "4px",
50
+ borderBottomLeftRadius: "4px"
51
+ };
52
+
53
+ const onTransitionEnd: TransitionEventHandler<HTMLDivElement> = useCallback(
54
+ e => {
55
+ if (e.target === containerRef.current) {
56
+ setClassHideOnTransition(prev => (prev ? "" : "hide"));
57
+ if (!open && controlledOpen) {
58
+ setControlledOpen(false);
59
+ }
60
+ }
61
+ },
62
+ [open]
63
+ );
64
+
65
+ useEffect(() => {
66
+ open && setControlledOpen(open);
67
+ }, [open]);
68
+
69
+ return (
70
+ <>
71
+ {handleButtonProps && !open && (
72
+ <div className={classes["collapsed-sheet"]}>
73
+ <div className={classes["handle"]}>
74
+ <IconButton
75
+ style={handleButtonStyle}
76
+ className={classes["handle-button"]}
77
+ onClick={handleButtonProps.onOpen}
78
+ title={handleTitle}
79
+ >
80
+ <Icon size="0.9rem" icon={Icons.SideSheetHandle} />
81
+ </IconButton>
82
+ </div>
83
+ </div>
84
+ )}
85
+ <Modal
86
+ {...rest}
87
+ id={id}
88
+ open={controlledOpen}
89
+ className={`${classes["slide-in-modal"]} ${open ? classes["visible"] : ""} ${
90
+ !open ? classes[classHideOnTransition] : ""
91
+ }`}
92
+ containerProps={{ className: classes["container"] }}
93
+ hideBackdrop={true}
94
+ onTransitionEnd={onTransitionEnd}
95
+ ref={ref ?? containerRef}
96
+ >
97
+ {handleButtonProps && (
98
+ <div className={classes["handle"]}>
99
+ <IconButton
100
+ style={handleButtonStyle}
101
+ title={handleTitle}
102
+ onClick={handleButtonProps.onClose}
103
+ >
104
+ <Icon size="0.9rem" icon={Icons.SideSheetHandle} />
105
+ </IconButton>
106
+ </div>
107
+ )}
108
+ {children}
109
+ </Modal>
110
+ </>
111
+ );
112
+ };
113
+
114
+ export const SideSheet = React.forwardRef(SideSheetComponent);
@@ -0,0 +1,18 @@
1
+ /*
2
+ * Copyright 2022 OneWelcome B.V.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ export { BaseModalActions as SideSheetActions } from "../../BaseModal/BaseModalActions/BaseModalActions";
18
+ export type { Props } from "../../BaseModal/BaseModalActions/BaseModalActions";
@@ -0,0 +1,19 @@
1
+ /*
2
+ * Copyright 2022 OneWelcome B.V.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ .side-sheet-content {
18
+ padding: 1.5rem;
19
+ }