@onewelcome/react-lib-components 1.5.0 → 1.6.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 (77) hide show
  1. package/dist/Button/Button.d.ts +0 -1
  2. package/dist/DataGrid/datagrid.interfaces.d.ts +1 -0
  3. package/dist/Form/Checkbox/Checkbox.d.ts +1 -1
  4. package/dist/Form/FormHelperText/FormHelperText.d.ts +1 -1
  5. package/dist/Form/FormSelectorWrapper/FormSelectorWrapper.d.ts +1 -1
  6. package/dist/Form/Input/Input.d.ts +2 -2
  7. package/dist/Form/Radio/Radio.d.ts +1 -1
  8. package/dist/Form/Select/Select.d.ts +1 -1
  9. package/dist/Form/Textarea/Textarea.d.ts +1 -6
  10. package/dist/Form/Toggle/Toggle.d.ts +1 -1
  11. package/dist/Form/Wrapper/CheckboxWrapper/CheckboxWrapper.d.ts +1 -1
  12. package/dist/Form/Wrapper/InputWrapper/InputWrapper.d.ts +1 -1
  13. package/dist/Form/Wrapper/RadioWrapper/RadioWrapper.d.ts +1 -1
  14. package/dist/Form/Wrapper/SelectWrapper/SelectWrapper.d.ts +1 -1
  15. package/dist/Form/Wrapper/TextareaWrapper/TextareaWrapper.d.ts +1 -1
  16. package/dist/Form/form.interfaces.d.ts +1 -0
  17. package/dist/Link/Link.d.ts +1 -2
  18. package/dist/Notifications/Banner/Banner.d.ts +11 -0
  19. package/dist/Tabs/TabButton.d.ts +0 -1
  20. package/dist/_BaseStyling_/BaseStyling.d.ts +2 -0
  21. package/dist/hooks/useDetermineStatusIcon.d.ts +3 -0
  22. package/dist/index.d.ts +1 -0
  23. package/dist/react-lib-components.cjs.development.js +416 -318
  24. package/dist/react-lib-components.cjs.development.js.map +1 -1
  25. package/dist/react-lib-components.cjs.production.min.js +1 -1
  26. package/dist/react-lib-components.cjs.production.min.js.map +1 -1
  27. package/dist/react-lib-components.esm.js +416 -319
  28. package/dist/react-lib-components.esm.js.map +1 -1
  29. package/package.json +11 -11
  30. package/src/Button/BaseButton.module.scss +2 -2
  31. package/src/Button/Button.module.scss +4 -5
  32. package/src/Button/Button.tsx +0 -1
  33. package/src/Button/IconButton.module.scss +4 -5
  34. package/src/DataGrid/DataGrid.tsx +3 -2
  35. package/src/DataGrid/DataGridActions/DataGridActions.tsx +16 -9
  36. package/src/DataGrid/DataGridBody/DataGridCell.module.scss +2 -2
  37. package/src/DataGrid/DataGridHeader/DataGridHeader.test.tsx +8 -3
  38. package/src/DataGrid/DataGridHeader/DataGridHeader.tsx +3 -1
  39. package/src/DataGrid/datagrid.interfaces.ts +1 -0
  40. package/src/Form/Input/Input.module.scss +36 -25
  41. package/src/Form/Input/Input.test.tsx +10 -0
  42. package/src/Form/Input/Input.tsx +7 -5
  43. package/src/Form/Select/Select.module.scss +9 -6
  44. package/src/Form/Select/Select.test.tsx +11 -0
  45. package/src/Form/Select/Select.tsx +5 -9
  46. package/src/Form/Select/SelectService.ts +2 -2
  47. package/src/Form/Textarea/Textarea.module.scss +21 -13
  48. package/src/Form/Textarea/Textarea.test.tsx +8 -0
  49. package/src/Form/Textarea/Textarea.tsx +6 -12
  50. package/src/Form/Toggle/Toggle.module.scss +3 -3
  51. package/src/Form/Wrapper/InputWrapper/InputWrapper.module.scss +7 -3
  52. package/src/Form/Wrapper/InputWrapper/InputWrapper.tsx +2 -0
  53. package/src/Form/Wrapper/SelectWrapper/SelectWrapper.tsx +12 -1
  54. package/src/Form/Wrapper/TextareaWrapper/TextareaWrapper.module.scss +15 -14
  55. package/src/Form/Wrapper/TextareaWrapper/TextareaWrapper.tsx +2 -1
  56. package/src/Form/Wrapper/Wrapper/Wrapper.module.scss +2 -2
  57. package/src/Form/form.interfaces.ts +1 -0
  58. package/src/Link/Link.module.scss +5 -5
  59. package/src/Link/Link.tsx +14 -13
  60. package/src/Notifications/Banner/Banner.module.scss +76 -0
  61. package/src/Notifications/Banner/Banner.test.tsx +84 -0
  62. package/src/Notifications/Banner/Banner.tsx +78 -0
  63. package/src/Notifications/BaseModal/BaseModal.module.scss +2 -2
  64. package/src/Notifications/Snackbar/SnackbarContainer/SnackbarContainer.module.scss +2 -2
  65. package/src/Notifications/Snackbar/SnackbarItem/SnackbarItem.module.scss +4 -4
  66. package/src/Notifications/Snackbar/SnackbarItem/SnackbarItem.tsx +3 -2
  67. package/src/Popover/Popover.module.scss +2 -2
  68. package/src/Skeleton/Skeleton.module.scss +2 -2
  69. package/src/Tabs/TabButton.tsx +1 -2
  70. package/src/Tabs/Tabs.module.scss +2 -2
  71. package/src/Tabs/Tabs.tsx +13 -10
  72. package/src/Tiles/Tile.module.scss +4 -4
  73. package/src/Tooltip/Tooltip.module.scss +3 -3
  74. package/src/_BaseStyling_/BaseStyling.tsx +4 -0
  75. package/src/hooks/useDetermineStatusIcon.test.ts +28 -0
  76. package/src/hooks/useDetermineStatusIcon.tsx +35 -0
  77. package/src/index.ts +1 -0
@@ -13,7 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- @import "../../../mixins.module.scss";
16
+ @use "../../../mixins.module.scss";
17
17
 
18
18
  .snackbars {
19
19
  position: fixed;
@@ -21,7 +21,7 @@
21
21
  width: 100%;
22
22
  display: flex;
23
23
  flex-direction: column;
24
- @include transition(height, 0.2s, ease-in-out);
24
+ @include mixins.transition(height, 0.2s, ease-in-out);
25
25
 
26
26
  &.bottom {
27
27
  bottom: 3.5rem;
@@ -14,8 +14,8 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- @import "../../../readyclasses.module.scss";
18
- @import "../../../mixins.module.scss";
17
+ @use "../../../readyclasses.module.scss";
18
+ @use "../../../mixins.module.scss";
19
19
 
20
20
  .snackbar {
21
21
  padding: 1rem 1.25rem;
@@ -23,7 +23,7 @@
23
23
  display: flex;
24
24
  width: 100%;
25
25
  box-sizing: border-box;
26
- @include transition(height, 0.2s, ease-in-out);
26
+ @include mixins.transition(height, 0.2s, ease-in-out);
27
27
  flex-grow: 0;
28
28
 
29
29
  &.info {
@@ -114,7 +114,7 @@
114
114
  cursor: not-allowed;
115
115
  }
116
116
 
117
- @include focusOutline(var(--snackbar-text-color));
117
+ @include readyclasses.focusOutline(var(--snackbar-text-color));
118
118
 
119
119
  &:not(:disabled):hover,
120
120
  &:not(:disabled):focus {
@@ -96,9 +96,10 @@ export const SnackbarItem = ({
96
96
  onClose(id);
97
97
  actionProp.onClick && actionProp.onClick(e);
98
98
  }}
99
- children={actionProp.label}
100
99
  className={classes["action-button"]}
101
- ></button>
100
+ >
101
+ {actionProp.label}
102
+ </button>
102
103
  ));
103
104
 
104
105
  return (
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- @import "../mixins.module.scss";
17
+ @use "../mixins.module.scss";
18
18
 
19
19
  .popover {
20
20
  $transition-property: transform, opacity;
@@ -28,7 +28,7 @@
28
28
  opacity: 0;
29
29
  transform: scale(0.5);
30
30
 
31
- @include transition($transition-property, 0.2s, ease-in-out);
31
+ @include mixins.transition($transition-property, 0.2s, ease-in-out);
32
32
 
33
33
  &.show {
34
34
  transform: scale(1);
@@ -14,12 +14,12 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- @import "../mixins.module.scss";
17
+ @use "../mixins.module.scss";
18
18
 
19
19
  .skeleton {
20
20
  display: block;
21
21
  height: auto;
22
- @include skeletonLoading();
22
+ @include mixins.skeletonLoading();
23
23
  }
24
24
 
25
25
  .no-height::before {
@@ -24,13 +24,12 @@ import React, {
24
24
  import classes from "./TabButton.module.scss";
25
25
 
26
26
  export interface Props extends ComponentPropsWithRef<"button"> {
27
- children?: string;
28
27
  tabActive?: boolean;
29
28
  focused?: boolean;
30
29
  }
31
30
 
32
31
  const TabButtonComponent: ForwardRefRenderFunction<HTMLButtonElement, Props> = (
33
- { children, tabActive, focused, ...rest }: Props,
32
+ { children, tabActive, focused, title, ...rest }: Props,
34
33
  ref
35
34
  ) => {
36
35
  let buttonRef = (ref as RefObject<HTMLButtonElement>) || createRef<HTMLButtonElement>();
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- @import "../mixins.module.scss";
17
+ @use "../mixins.module.scss";
18
18
 
19
19
  $focus-width: 5px;
20
20
 
@@ -45,7 +45,7 @@ $focus-width: 5px;
45
45
  height: var(--tab-active-border-height);
46
46
  background-color: var(--tab-active-border-color);
47
47
 
48
- @include transition($transition-property, 0.2s, ease-in-out);
48
+ @include mixins.transition($transition-property, 0.2s, ease-in-out);
49
49
  }
50
50
 
51
51
  .tabdivider {
package/src/Tabs/Tabs.tsx CHANGED
@@ -111,16 +111,19 @@ const TabsComponent: ForwardRefRenderFunction<HTMLDivElement, Props> = (
111
111
  useEffect(() => {
112
112
  const buttons = React.Children.map(children, (child, index) => {
113
113
  if (Object.prototype.hasOwnProperty.call(child.props, "title")) {
114
- return React.createElement(TabButton, {
115
- key: `${child.props.title.toLowerCase().replace(/\s/, "_")}_button`,
116
- tabIndex: activeTabIndex === index ? 0 : -1,
117
- "aria-selected": activeTabIndex === index,
118
- focused: usingKeyboardNavigation && activeTabIndex === index,
119
- tabActive: activeTabIndex === index,
120
- "aria-controls": `tab_${index}`,
121
- onClick: () => setActiveTabIndex(index),
122
- children: child.props.title
123
- });
114
+ return React.createElement(
115
+ TabButton,
116
+ {
117
+ key: `${child.props.title.toLowerCase().replace(/\s/, "_")}_button`,
118
+ tabIndex: activeTabIndex === index ? 0 : -1,
119
+ "aria-selected": activeTabIndex === index,
120
+ focused: usingKeyboardNavigation && activeTabIndex === index,
121
+ tabActive: activeTabIndex === index,
122
+ "aria-controls": `tab_${index}`,
123
+ onClick: () => setActiveTabIndex(index)
124
+ },
125
+ child.props.title
126
+ );
124
127
  }
125
128
  return null;
126
129
  });
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- @import "../mixins.module.scss";
17
+ @use "../mixins.module.scss";
18
18
 
19
19
  .tile {
20
20
  border: 1px solid var(--light-grey-border);
@@ -22,7 +22,7 @@
22
22
  box-sizing: border-box;
23
23
  padding: 0 0 2rem;
24
24
  background-color: var(--light);
25
- @include transition(box-shadow, 0.2s, ease-in-out);
25
+ @include mixins.transition(box-shadow, 0.2s, ease-in-out);
26
26
  font-family: var(--font-family);
27
27
 
28
28
  &:hover {
@@ -71,14 +71,14 @@
71
71
 
72
72
  .image {
73
73
  margin-top: 2.5rem;
74
- @include skeletonLoading();
74
+ @include mixins.skeletonLoading();
75
75
  border-radius: 0.5rem;
76
76
  width: 3rem;
77
77
  height: 3rem;
78
78
  }
79
79
 
80
80
  .title {
81
- @include skeletonLoading();
81
+ @include mixins.skeletonLoading();
82
82
  color: transparent;
83
83
  display: inline-block;
84
84
  width: 70%;
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- @import "../mixins.module.scss";
17
+ @use "../mixins.module.scss";
18
18
 
19
19
  .wrapper {
20
20
  display: flex;
@@ -24,7 +24,7 @@
24
24
  .tooltip-wrapper {
25
25
  .icon {
26
26
  margin-left: 0.5rem;
27
- @include transition(all, 0.2s, ease-in-out);
27
+ @include mixins.transition(all, 0.2s, ease-in-out);
28
28
  color: var(--greyed-out);
29
29
 
30
30
  &:hover {
@@ -46,7 +46,7 @@
46
46
  transform-origin: center left;
47
47
  pointer-events: none;
48
48
 
49
- @include transition($transition-property, 0.2s, ease-in-out);
49
+ @include mixins.transition($transition-property, 0.2s, ease-in-out);
50
50
 
51
51
  &.visible {
52
52
  opacity: 1;
@@ -49,6 +49,7 @@ interface CSSProperties {
49
49
  snackbarSuccessBackgroundColor?: string;
50
50
  snackbarErrorBackgroundColor?: string;
51
51
  snackbarBorderRadius?: string;
52
+ bannerBorderRadius?: string;
52
53
  dataGridRowBackgroundColor?: string;
53
54
  dataGridRowHoverBackgroundColor?: string;
54
55
  tabsBackgroundColor?: string;
@@ -61,6 +62,7 @@ interface CSSProperties {
61
62
  default?: string;
62
63
  success?: string;
63
64
  error?: string;
65
+ info?: string;
64
66
  disabled?: string;
65
67
  greyedOut?: string;
66
68
  lightGreyBorder?: string;
@@ -112,6 +114,7 @@ export const BaseStyling = ({ children, properties = {} }: Props) => {
112
114
  snackbarSuccessBackgroundColor: "#008a28",
113
115
  snackbarErrorBackgroundColor: "#d9291c",
114
116
  snackbarBorderRadius: "8px",
117
+ bannerBorderRadius: "8px",
115
118
  dataGridRowBackgroundColor: "transparent",
116
119
  dataGridRowHoverBackgroundColor: "#f5e6f0",
117
120
  tabsBackgroundColor: "var(--light)",
@@ -124,6 +127,7 @@ export const BaseStyling = ({ children, properties = {} }: Props) => {
124
127
  default: "#0f0f1e",
125
128
  success: "#008a28",
126
129
  error: "#d9291c",
130
+ info: "var(--color-secondary)",
127
131
  disabled: "#e9e9eb",
128
132
  greyedOut: "#6f6f76",
129
133
  lightGreyBorder: "#e9e9eb",
@@ -0,0 +1,28 @@
1
+ import { renderHook } from "@testing-library/react-hooks";
2
+ import { useDetermineStatusIcon } from "./useDetermineStatusIcon";
3
+
4
+ describe("it should return the correct icon", () => {
5
+ it("should return an icon of type success", () => {
6
+ const { result } = renderHook(useDetermineStatusIcon, {
7
+ initialProps: { success: true, error: false }
8
+ });
9
+
10
+ expect(result.current).toBeDefined();
11
+ expect(result.current?.props?.["data-icon-status"]).toEqual("success");
12
+ });
13
+
14
+ it("should return an icon of type error", () => {
15
+ const { result } = renderHook(useDetermineStatusIcon, {
16
+ initialProps: { success: true, error: true }
17
+ });
18
+
19
+ expect(result.current).toBeDefined();
20
+ expect(result.current?.props?.["data-icon-status"]).toEqual("error");
21
+ });
22
+
23
+ it("should return null", () => {
24
+ const { result } = renderHook(useDetermineStatusIcon);
25
+
26
+ expect(result.current).toBeNull();
27
+ });
28
+ });
@@ -0,0 +1,35 @@
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 { FormElement } from "../Form/form.interfaces";
18
+ import React, { ReactElement, useRef } from "react";
19
+ import { Icon, Icons } from "../Icon/Icon";
20
+ export const useDetermineStatusIcon = (params: Partial<FormElement>): ReactElement | null => {
21
+ const { error, success } = params || false;
22
+ let icon = null;
23
+ const errorRef = useRef(null);
24
+ const successRef = useRef(null);
25
+
26
+ if (error) {
27
+ icon = <Icon ref={errorRef} data-icon-status="error" icon={Icons.Error} />;
28
+ } else if (success) {
29
+ icon = (
30
+ <Icon ref={successRef} data-icon-status="success" icon={Icons.CheckmarkCircleBreakout} />
31
+ );
32
+ }
33
+
34
+ return icon;
35
+ };
package/src/index.ts CHANGED
@@ -123,3 +123,4 @@ export { HeaderCell } from "./DataGrid/datagrid.interfaces";
123
123
  export { DataGrid, Props as DataGridProps } from "./DataGrid/DataGrid";
124
124
  export { DataGridRow, Props as DataGridRowProps } from "./DataGrid/DataGridBody/DataGridRow";
125
125
  export { DataGridCell, Props as DataGridCellProps } from "./DataGrid/DataGridBody/DataGridCell";
126
+ export { Banner, Props as BannerProps } from "./Notifications/Banner/Banner";