@onewelcome/react-lib-components 1.4.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 (101) hide show
  1. package/README.md +7 -0
  2. package/dist/Breadcrumbs/Breadcrumbs.d.ts +1 -1
  3. package/dist/Button/Button.d.ts +0 -1
  4. package/dist/ContextMenu/ContextMenu.d.ts +4 -1
  5. package/dist/DataGrid/DataGridActions/DataGridColumnsToggle.d.ts +1 -1
  6. package/dist/DataGrid/datagrid.interfaces.d.ts +5 -4
  7. package/dist/Form/Checkbox/Checkbox.d.ts +1 -1
  8. package/dist/Form/FormControl/FormControl.d.ts +1 -1
  9. package/dist/Form/FormHelperText/FormHelperText.d.ts +1 -1
  10. package/dist/Form/FormSelectorWrapper/FormSelectorWrapper.d.ts +1 -1
  11. package/dist/Form/Input/Input.d.ts +2 -2
  12. package/dist/Form/Radio/Radio.d.ts +1 -1
  13. package/dist/Form/Select/Select.d.ts +2 -2
  14. package/dist/Form/Select/Select.interfaces.d.ts +1 -1
  15. package/dist/Form/Textarea/Textarea.d.ts +1 -6
  16. package/dist/Form/Toggle/Toggle.d.ts +1 -1
  17. package/dist/Form/Wrapper/CheckboxWrapper/CheckboxWrapper.d.ts +1 -1
  18. package/dist/Form/Wrapper/InputWrapper/InputWrapper.d.ts +1 -1
  19. package/dist/Form/Wrapper/RadioWrapper/RadioWrapper.d.ts +1 -1
  20. package/dist/Form/Wrapper/SelectWrapper/SelectWrapper.d.ts +1 -1
  21. package/dist/Form/Wrapper/TextareaWrapper/TextareaWrapper.d.ts +1 -1
  22. package/dist/Form/form.interfaces.d.ts +1 -0
  23. package/dist/Icon/Icon.d.ts +1 -1
  24. package/dist/Link/Link.d.ts +2 -3
  25. package/dist/Notifications/Banner/Banner.d.ts +11 -0
  26. package/dist/Notifications/Snackbar/interfaces.d.ts +2 -2
  27. package/dist/Pagination/Pagination.d.ts +3 -3
  28. package/dist/Popover/Popover.d.ts +3 -1
  29. package/dist/Tabs/TabButton.d.ts +0 -1
  30. package/dist/Typography/Typography.d.ts +2 -2
  31. package/dist/Wizard/Wizard.d.ts +1 -1
  32. package/dist/Wizard/wizardStateReducer.d.ts +2 -2
  33. package/dist/_BaseStyling_/BaseStyling.d.ts +4 -0
  34. package/dist/hooks/useDetermineStatusIcon.d.ts +3 -0
  35. package/dist/hooks/usePosition.d.ts +6 -5
  36. package/dist/hooks/useSpacing.d.ts +3 -3
  37. package/dist/index.d.ts +1 -0
  38. package/dist/interfaces.d.ts +1 -1
  39. package/dist/react-lib-components.cjs.development.js +483 -363
  40. package/dist/react-lib-components.cjs.development.js.map +1 -1
  41. package/dist/react-lib-components.cjs.production.min.js +1 -1
  42. package/dist/react-lib-components.cjs.production.min.js.map +1 -1
  43. package/dist/react-lib-components.esm.js +484 -365
  44. package/dist/react-lib-components.esm.js.map +1 -1
  45. package/dist/util/helper.d.ts +1 -1
  46. package/package.json +39 -38
  47. package/src/Button/BaseButton.module.scss +2 -2
  48. package/src/Button/Button.module.scss +4 -5
  49. package/src/Button/Button.tsx +0 -1
  50. package/src/Button/IconButton.module.scss +4 -5
  51. package/src/ContextMenu/ContextMenu.tsx +18 -7
  52. package/src/DataGrid/DataGrid.tsx +3 -2
  53. package/src/DataGrid/DataGridActions/DataGridActions.tsx +16 -9
  54. package/src/DataGrid/DataGridBody/DataGridCell.module.scss +2 -2
  55. package/src/DataGrid/DataGridHeader/DataGridHeader.test.tsx +8 -3
  56. package/src/DataGrid/DataGridHeader/DataGridHeader.tsx +3 -1
  57. package/src/DataGrid/datagrid.interfaces.ts +1 -0
  58. package/src/Form/Input/Input.module.scss +36 -25
  59. package/src/Form/Input/Input.test.tsx +22 -0
  60. package/src/Form/Input/Input.tsx +8 -5
  61. package/src/Form/Select/Select.module.scss +9 -6
  62. package/src/Form/Select/Select.test.tsx +11 -0
  63. package/src/Form/Select/Select.tsx +5 -9
  64. package/src/Form/Select/SelectService.ts +2 -2
  65. package/src/Form/Textarea/Textarea.module.scss +21 -13
  66. package/src/Form/Textarea/Textarea.test.tsx +8 -0
  67. package/src/Form/Textarea/Textarea.tsx +6 -12
  68. package/src/Form/Toggle/Toggle.module.scss +3 -3
  69. package/src/Form/Wrapper/InputWrapper/InputWrapper.module.scss +7 -3
  70. package/src/Form/Wrapper/InputWrapper/InputWrapper.tsx +2 -0
  71. package/src/Form/Wrapper/SelectWrapper/SelectWrapper.tsx +12 -1
  72. package/src/Form/Wrapper/TextareaWrapper/TextareaWrapper.module.scss +15 -14
  73. package/src/Form/Wrapper/TextareaWrapper/TextareaWrapper.tsx +2 -1
  74. package/src/Form/Wrapper/Wrapper/Wrapper.module.scss +2 -2
  75. package/src/Form/form.interfaces.ts +1 -0
  76. package/src/Link/Link.module.scss +5 -5
  77. package/src/Link/Link.tsx +14 -13
  78. package/src/Notifications/Banner/Banner.module.scss +76 -0
  79. package/src/Notifications/Banner/Banner.test.tsx +84 -0
  80. package/src/Notifications/Banner/Banner.tsx +78 -0
  81. package/src/Notifications/BaseModal/BaseModal.module.scss +2 -2
  82. package/src/Notifications/Snackbar/SnackbarContainer/SnackbarContainer.module.scss +2 -2
  83. package/src/Notifications/Snackbar/SnackbarItem/SnackbarItem.module.scss +4 -4
  84. package/src/Notifications/Snackbar/SnackbarItem/SnackbarItem.tsx +3 -2
  85. package/src/Popover/Popover.module.scss +2 -2
  86. package/src/Popover/Popover.test.tsx +4 -1
  87. package/src/Popover/Popover.tsx +40 -8
  88. package/src/Skeleton/Skeleton.module.scss +2 -2
  89. package/src/Tabs/TabButton.tsx +1 -2
  90. package/src/Tabs/Tabs.module.scss +2 -2
  91. package/src/Tabs/Tabs.tsx +13 -10
  92. package/src/Tiles/Tile.module.scss +4 -4
  93. package/src/Tooltip/Tooltip.module.scss +3 -3
  94. package/src/Tooltip/Tooltip.test.tsx +5 -5
  95. package/src/_BaseStyling_/BaseStyling.tsx +8 -0
  96. package/src/hooks/useDetermineStatusIcon.test.ts +28 -0
  97. package/src/hooks/useDetermineStatusIcon.tsx +35 -0
  98. package/src/hooks/usePosition.test.tsx +85 -85
  99. package/src/hooks/usePosition.ts +6 -3
  100. package/src/index.ts +1 -0
  101. package/src/mixins.module.scss +5 -5
@@ -1,4 +1,4 @@
1
- declare type KeyValuePair = {
1
+ type KeyValuePair = {
2
2
  [key: string]: unknown;
3
3
  };
4
4
  export declare const generateID: (length?: number, stringToWeaveIn?: string) => string;
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
+ "homepage": "http://onewelcome.github.io/react-lib-components",
2
3
  "name": "@onewelcome/react-lib-components",
3
- "version": "1.4.0",
4
+ "version": "1.6.0",
4
5
  "license": "Apache-2.0",
5
6
  "author": "OneWelcome B.V.",
6
7
  "main": "dist/index.js",
@@ -51,60 +52,60 @@
51
52
  }
52
53
  ],
53
54
  "devDependencies": {
54
- "@babel/core": "^7.19.3",
55
+ "@babel/core": "^7.20.12",
55
56
  "@mdx-js/react": "^1.6.22",
56
57
  "@onewelcome/eslint-config-shared-codestyle": "^9.0.3",
57
- "@size-limit/preset-small-lib": "^7.0.8",
58
- "@storybook/addon-a11y": "^6.5.12",
59
- "@storybook/addon-docs": "^6.5.12",
60
- "@storybook/addon-essentials": "^6.5.12",
61
- "@storybook/addon-links": "^6.5.12",
62
- "@storybook/addons": "^6.5.12",
63
- "@storybook/builder-webpack5": "^6.5.12",
64
- "@storybook/manager-webpack5": "^6.5.12",
58
+ "@size-limit/preset-small-lib": "^8.1.2",
59
+ "@storybook/addon-a11y": "^6.5.15",
60
+ "@storybook/addon-docs": "^6.5.15",
61
+ "@storybook/addon-essentials": "^6.5.15",
62
+ "@storybook/addon-links": "^6.5.15",
63
+ "@storybook/addons": "^6.5.15",
64
+ "@storybook/builder-webpack5": "^6.5.15",
65
+ "@storybook/manager-webpack5": "^6.5.15",
65
66
  "@storybook/preset-scss": "^1.0.3",
66
- "@storybook/react": "^6.5.12",
67
- "@storybook/theming": "^6.5.12",
68
- "@testing-library/dom": "^8.18.1",
67
+ "@storybook/react": "^6.5.15",
68
+ "@storybook/theming": "^6.5.15",
69
+ "@testing-library/dom": "^8.20.0",
69
70
  "@testing-library/jest-dom": "^5.16.5",
70
71
  "@testing-library/react": "^12.1.5",
71
- "@testing-library/react-hooks": "^7.0.2",
72
+ "@testing-library/react-hooks": "^8.0.1",
72
73
  "@testing-library/user-event": "^13.5.0",
73
- "@tsconfig/create-react-app": "^1.0.2",
74
- "@tsconfig/recommended": "^1.0.1",
74
+ "@tsconfig/create-react-app": "^1.0.3",
75
+ "@tsconfig/recommended": "^1.0.2",
75
76
  "@types/color-convert": "^2.0.0",
76
- "@types/mdx": "^2.0.2",
77
- "@types/react": "^17.0.50",
78
- "@types/react-dom": "^17.0.17",
79
- "@types/react-router": "^5.1.19",
77
+ "@types/mdx": "^2.0.3",
78
+ "@types/react": "^17.0.52",
79
+ "@types/react-dom": "^17.0.18",
80
+ "@types/react-router": "^5.1.20",
80
81
  "@types/react-router-dom": "^5.3.3",
81
- "@typescript-eslint/eslint-plugin": "^5.39.0",
82
- "@typescript-eslint/parser": "^5.39.0",
83
- "babel-loader": "^8.2.5",
84
- "dts-cli": "^1.6.0",
85
- "eslint": "^8.24.0",
86
- "eslint-config-prettier": "^8.5.0",
82
+ "@typescript-eslint/eslint-plugin": "^5.49.0",
83
+ "@typescript-eslint/parser": "^5.49.0",
84
+ "babel-loader": "^9.1.2",
85
+ "dts-cli": "^1.6.3",
86
+ "eslint": "^8.32.0",
87
+ "eslint-config-prettier": "^8.6.0",
87
88
  "eslint-plugin-cypress": "^2.12.1",
88
- "eslint-plugin-jest": "^26.9.0",
89
+ "eslint-plugin-jest": "^27.2.1",
89
90
  "eslint-plugin-license-header": "^0.6.0",
90
91
  "eslint-plugin-prettier": "^4.2.1",
91
92
  "html-webpack-plugin": "^5.5.0",
92
- "husky": "^7.0.4",
93
+ "husky": "^8.0.3",
93
94
  "identity-obj-proxy": "^3.0.0",
94
- "jest-junit": "^13.2.0",
95
- "lint-staged": "^13.0.3",
95
+ "jest-junit": "^15.0.0",
96
+ "lint-staged": "^13.1.0",
96
97
  "npm-run-all": "^4.1.5",
97
- "prettier": "^2.7.1",
98
+ "prettier": "^2.8.3",
98
99
  "react": "^17.0.2",
99
100
  "react-dom": "^17.0.2",
100
- "react-is": "^17.0.2",
101
- "react-router": "^6.4.2",
102
- "react-router-dom": "^6.4.2",
101
+ "react-is": "^18.2.0",
102
+ "react-router": "^6.6.2",
103
+ "react-router-dom": "^6.7.0",
103
104
  "rollup-plugin-cleanup": "^3.2.1",
104
105
  "rollup-plugin-styles": "^4.0.0",
105
- "sass": "^1.55.0",
106
- "size-limit": "^7.0.8",
107
- "tslib": "^2.4.0",
108
- "typescript": "^4.8.4"
106
+ "sass": "^1.57.1",
107
+ "size-limit": "^8.1.1",
108
+ "tslib": "^2.4.1",
109
+ "typescript": "^4.9.4"
109
110
  }
110
111
  }
@@ -14,8 +14,8 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- @import "../mixins.module.scss";
17
+ @use "../mixins.module.scss";
18
18
 
19
19
  .button {
20
- @include buttonBase();
20
+ @include mixins.buttonBase();
21
21
  }
@@ -14,19 +14,18 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- @import "../readyclasses.module.scss";
18
- @import "../mixins.module.scss";
17
+ @use "../mixins.module.scss";
19
18
 
20
19
  .fill {
21
- @include button("fill");
20
+ @include mixins.button("fill");
22
21
  }
23
22
 
24
23
  .outline {
25
- @include button("outline");
24
+ @include mixins.button("outline");
26
25
  }
27
26
 
28
27
  .text {
29
- @include button("text");
28
+ @include mixins.button("text");
30
29
  }
31
30
 
32
31
  .has-icon {
@@ -21,7 +21,6 @@ import classes from "./Button.module.scss";
21
21
  export interface Props extends BaseButtonProps {
22
22
  startIcon?: React.ReactNode | false;
23
23
  endIcon?: React.ReactNode | false;
24
- children?: React.ReactNode;
25
24
  variant?: "text" | "fill" | "outline";
26
25
  }
27
26
 
@@ -14,8 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- @import "../readyclasses.module.scss";
18
- @import "../mixins.module.scss";
17
+ @use "../mixins.module.scss";
19
18
 
20
19
  .icon-button {
21
20
  border: var(--button-border-width) var(--button-border-style) transparent;
@@ -57,14 +56,14 @@
57
56
  }
58
57
 
59
58
  &.fill {
60
- @include button("fill", "icon");
59
+ @include mixins.button("fill", "icon");
61
60
  }
62
61
 
63
62
  &.text {
64
- @include button("text", "icon");
63
+ @include mixins.button("text", "icon");
65
64
  }
66
65
 
67
66
  &.outline {
68
- @include button("outline", "icon");
67
+ @include mixins.button("outline", "icon");
69
68
  }
70
69
  }
@@ -19,13 +19,14 @@ import React, {
19
19
  ForwardRefRenderFunction,
20
20
  ReactElement,
21
21
  ReactNode,
22
+ useCallback,
22
23
  useEffect,
23
24
  useRef,
24
25
  useState
25
26
  } from "react";
26
27
  import { Props as ButtonProps } from "../Button/Button";
27
28
  import { Props as IconButtonProps } from "../Button/IconButton";
28
- import { Popover } from "../Popover/Popover";
29
+ import { Popover, Props as PopoverProps } from "../Popover/Popover";
29
30
  import { Placement, Offset } from "../hooks/usePosition";
30
31
  import classes from "./ContextMenu.module.scss";
31
32
  import { useBodyClick } from "../hooks/useBodyClick";
@@ -38,11 +39,13 @@ export interface Props extends ComponentPropsWithRef<"div"> {
38
39
  placement?: Placement;
39
40
  transformOrigin?: Placement;
40
41
  offset?: Offset;
42
+ debounceAmount?: number;
41
43
  id: string;
42
44
  show?: boolean;
43
45
  domRoot?: HTMLElement;
44
46
  onShow?: () => void;
45
47
  onClose?: () => void;
48
+ popoverProps?: PopoverProps;
46
49
  }
47
50
 
48
51
  const ContextMenuComponent: ForwardRefRenderFunction<HTMLDivElement, Props> = (
@@ -57,7 +60,9 @@ const ContextMenuComponent: ForwardRefRenderFunction<HTMLDivElement, Props> = (
57
60
  placement = { horizontal: "right", vertical: "top" },
58
61
  offset = { top: 0, bottom: 0, left: 0, right: 0 },
59
62
  transformOrigin = { horizontal: "left", vertical: "top" },
63
+ debounceAmount,
60
64
  domRoot = document.body,
65
+ popoverProps,
61
66
  ...rest
62
67
  }: Props,
63
68
  ref
@@ -173,9 +178,9 @@ const ContextMenuComponent: ForwardRefRenderFunction<HTMLDivElement, Props> = (
173
178
  ref: anchorEl
174
179
  });
175
180
 
176
- const renderChildren = () => {
177
- return React.Children.map(children, (child, index) => {
178
- return React.cloneElement(child as ReactElement, {
181
+ const renderChildren = () =>
182
+ React.Children.map(children, (child, index) =>
183
+ React.cloneElement(child as ReactElement, {
179
184
  onFocusChange: (childIndex: number) => setFocusedContextMenuItem(childIndex),
180
185
  onSelectedChange: (childIndex: number) => {
181
186
  setSelectedContextMenuItem(childIndex);
@@ -186,20 +191,26 @@ const ContextMenuComponent: ForwardRefRenderFunction<HTMLDivElement, Props> = (
186
191
  isSelected: selectedContextMenuItem === index,
187
192
  contextMenuOpened: showContextMenu,
188
193
  shouldClick: shouldClick
189
- });
190
- });
191
- };
194
+ })
195
+ );
196
+
197
+ const onOutOfViewHandler = useCallback(() => {
198
+ setShowContextMenu(false);
199
+ }, []);
192
200
 
193
201
  return (
194
202
  <div {...rest} ref={ref} onKeyDown={onArrowNavigation} className={classes["context-menu"]}>
195
203
  {renderTrigger()}
196
204
  {createPortal(
197
205
  <Popover
206
+ {...popoverProps}
198
207
  placement={placement}
199
208
  transformOrigin={transformOrigin}
200
209
  offset={offset}
201
210
  anchorEl={anchorEl}
211
+ debounceAmount={debounceAmount}
202
212
  show={showContextMenu}
213
+ onAnchorOutOfView={onOutOfViewHandler}
203
214
  >
204
215
  {decorativeElement && (
205
216
  <div className={classes["decorative-element"]}>{decorativeElement}</div>
@@ -144,14 +144,15 @@ const DataGridInner = <T extends {}>(
144
144
  spacing={styleWithSpacing}
145
145
  />
146
146
  <DataGridBody
147
- children={children}
148
147
  data={data}
149
148
  headers={internalHeaders}
150
149
  isLoading={isLoading}
151
150
  disableContextMenuColumn={disableContextMenuColumn}
152
151
  emptyLabel={emptyLabel}
153
152
  spacing={styleWithSpacing}
154
- />
153
+ >
154
+ {children}
155
+ </DataGridBody>
155
156
  </table>
156
157
  </div>
157
158
  {paginationProps && !isLoading && (
@@ -52,6 +52,7 @@ const DataGridActionsComponent: ForwardRefRenderFunction<HTMLDivElement, Props>
52
52
  searchIconBtnProps = {},
53
53
  headers,
54
54
  onColumnToggled,
55
+ children,
55
56
  ...rest
56
57
  }: Props,
57
58
  ref
@@ -59,6 +60,9 @@ const DataGridActionsComponent: ForwardRefRenderFunction<HTMLDivElement, Props>
59
60
  const isHidden = !(enableAddBtn || enableColumnsBtn || enableSearchBtn);
60
61
  const [showColsPopover, setShowColsPopover] = useState(false);
61
62
  const showColumnBtn = useRef<HTMLButtonElement>(null);
63
+ const { children: addBtnChildren, ...restAddBtnProps } = addBtnProps;
64
+ const { children: columnsBtnChildren, ...restColumnsBtnProps } = columnsBtnProps;
65
+ const { children: searchBtnChildren, ...restSearchBtnProps } = searchBtnProps;
62
66
 
63
67
  return isHidden ? null : (
64
68
  <div {...rest} ref={ref} className={`${classes["actions"]} ${className ?? ""}`}>
@@ -70,9 +74,10 @@ const DataGridActionsComponent: ForwardRefRenderFunction<HTMLDivElement, Props>
70
74
  title="Add item"
71
75
  type="button"
72
76
  variant="outline"
73
- children="Add item"
74
- {...addBtnProps}
75
- />
77
+ {...restAddBtnProps}
78
+ >
79
+ {addBtnChildren ?? "Add item"}
80
+ </Button>
76
81
  )}
77
82
  </div>
78
83
  <div className={classes["right-actions"]}>
@@ -82,12 +87,13 @@ const DataGridActionsComponent: ForwardRefRenderFunction<HTMLDivElement, Props>
82
87
  startIcon={<Icon icon={Icons.Change} />}
83
88
  title="Show/hide columns"
84
89
  variant="text"
85
- children="Columns"
86
- {...columnsBtnProps}
90
+ {...restColumnsBtnProps}
87
91
  className={`${classes["desktop"]} ${columnsBtnProps?.className ?? ""}`}
88
92
  ref={showColumnBtn}
89
93
  onClick={() => setShowColsPopover(true)}
90
- />
94
+ >
95
+ {columnsBtnChildren ?? "Columns"}
96
+ </Button>
91
97
  <IconButton
92
98
  title="Show/hide columns"
93
99
  {...columnsBtnProps}
@@ -112,10 +118,11 @@ const DataGridActionsComponent: ForwardRefRenderFunction<HTMLDivElement, Props>
112
118
  startIcon={<Icon icon={Icons.TableSearch} />}
113
119
  title="Search"
114
120
  variant="text"
115
- children="Search"
116
- {...searchBtnProps}
121
+ {...restSearchBtnProps}
117
122
  className={`${classes["desktop"]} ${searchBtnProps?.className ?? ""}`}
118
- />
123
+ >
124
+ {searchBtnChildren ?? "Search"}
125
+ </Button>
119
126
  <IconButton
120
127
  title="Search"
121
128
  {...searchIconBtnProps}
@@ -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
  .cell {
20
20
  min-height: 3.5rem;
@@ -29,7 +29,7 @@
29
29
  }
30
30
 
31
31
  .loading {
32
- @include skeletonLoading();
32
+ @include mixins.skeletonLoading();
33
33
  border-radius: 0.5rem;
34
34
  height: 1.25rem;
35
35
  margin: 0.625rem 0;
@@ -21,8 +21,8 @@ import userEvent from "@testing-library/user-event";
21
21
 
22
22
  const defaultParams: Props = {
23
23
  headers: [
24
- { name: "firstName", headline: "First name" },
25
- { name: "lastName", headline: "Last name" }
24
+ { name: "firstName", headline: "First name", align: "center" },
25
+ { name: "lastName", headline: "Last name", align: "right" }
26
26
  ]
27
27
  };
28
28
 
@@ -36,7 +36,6 @@ const createDataGridHeader = (params?: (defaultParams: Props) => Props) => {
36
36
  container
37
37
  });
38
38
  const dataGridHeader = queries.getByTestId("dataGridHeader");
39
-
40
39
  return {
41
40
  ...queries,
42
41
  dataGridHeader
@@ -51,6 +50,12 @@ describe("DataGridHeader should render", () => {
51
50
  expect(getAllByRole("columnheader")).toHaveLength(2);
52
51
  expect(getByRole("cell")).toBeDefined(); //context-menu empty cell
53
52
 
53
+ const headerCells = dataGridHeader.querySelectorAll("th");
54
+
55
+ expect(headerCells).toHaveLength(2);
56
+ expect(headerCells[0]).toHaveStyle({ textAlign: "center" });
57
+ expect(headerCells[1]).toHaveStyle({ textAlign: "right" });
58
+
54
59
  expect(dataGridHeader.querySelectorAll("[data-icon]")).toHaveLength(0);
55
60
  });
56
61
 
@@ -77,7 +77,9 @@ const DataGridHeaderComponent: ForwardRefRenderFunction<HTMLTableSectionElement,
77
77
  return null;
78
78
  }
79
79
 
80
- let headerStyle: React.CSSProperties = {};
80
+ let headerStyle: React.CSSProperties = {
81
+ textAlign: header.align || "left"
82
+ };
81
83
 
82
84
  if (index === 0) {
83
85
  headerStyle.paddingLeft = spacing?.paddingLeft;
@@ -27,4 +27,5 @@ export interface HeaderCell {
27
27
  headline: string;
28
28
  disableSorting?: boolean;
29
29
  hidden?: boolean;
30
+ align?: "left" | "right" | "center";
30
31
  }
@@ -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
  .input-wrapper {
20
20
  position: relative;
@@ -25,7 +25,7 @@
25
25
  border-radius: var(--input-border-radius);
26
26
  background-color: var(--input-background-color);
27
27
  padding: 0 1.25rem;
28
- @include transition(all, 0.2s, ease-in-out);
28
+ @include mixins.transition(all, 0.2s, ease-in-out);
29
29
 
30
30
  // General autofill styles
31
31
  input:-webkit-autofill,
@@ -64,7 +64,33 @@
64
64
  }
65
65
  }
66
66
 
67
- @include outlineStates;
67
+ @include mixins.outlineStates;
68
+
69
+ [data-icon-status="success"],
70
+ [data-icon-status="error"] {
71
+ height: 100%;
72
+ width: 1.25rem;
73
+ box-sizing: border-box;
74
+ padding-top: calc(1rem - (1.25rem - 1rem));
75
+ font-size: 1.25rem;
76
+ display: flex;
77
+ align-items: center;
78
+ justify-content: center;
79
+ z-index: 2;
80
+
81
+ &:before {
82
+ height: 1.25rem;
83
+ width: 1.25rem;
84
+ }
85
+ }
86
+
87
+ [data-icon-status="success"] {
88
+ color: var(--success);
89
+ }
90
+
91
+ [data-icon-status="error"] {
92
+ color: var(--error);
93
+ }
68
94
  }
69
95
 
70
96
  .input {
@@ -76,7 +102,7 @@
76
102
  box-sizing: border-box;
77
103
  border: 0;
78
104
  border-radius: var(--input-border-radius);
79
- @include transition(all, 0.2s, ease-in-out);
105
+ @include mixins.transition(all, 0.2s, ease-in-out);
80
106
  background-color: transparent;
81
107
  z-index: 1;
82
108
 
@@ -93,41 +119,26 @@
93
119
  width: auto;
94
120
  }
95
121
 
96
- @include browserOutlineDisabled;
122
+ @include mixins.browserOutlineDisabled;
97
123
  }
98
124
 
99
- @include outline;
125
+ @include mixins.outline;
100
126
 
101
127
  .error input {
102
128
  color: var(--error);
103
- padding-right: 3.5rem;
129
+ padding-right: 1.25rem;
104
130
 
105
131
  &.remove-extra-indent {
106
132
  padding-right: 0;
107
133
  }
108
134
  }
109
-
110
- .warning {
111
- color: var(--error);
112
- position: absolute;
113
- height: 100%;
114
- width: 1.25rem;
115
- right: 1.25rem;
116
- top: 0;
117
- font-size: 1.125rem;
118
- display: flex;
119
- align-items: center;
120
- justify-content: center;
121
- z-index: 2;
122
-
123
- &:before {
124
- height: 1.3125rem;
125
- }
135
+ .success input {
136
+ padding-right: 1.25rem;
126
137
  }
127
138
 
128
139
  .input-wrapper [data-prefix],
129
140
  .input-wrapper [data-suffix] {
130
- @include transition(all, 0.2s, ease-in-out);
141
+ @include mixins.transition(all, 0.2s, ease-in-out);
131
142
  display: block;
132
143
  z-index: 1;
133
144
  }
@@ -112,6 +112,18 @@ describe("Should have the appropriate attributes", () => {
112
112
  expect(input).toHaveAttribute("disabled");
113
113
  expect(input).toHaveClass("classname");
114
114
  });
115
+
116
+ it("should render an input with spellcheck enabled", () => {
117
+ const { input } = createInput(defaultParams => ({ ...defaultParams, spellCheck: true }));
118
+
119
+ expect(input).toHaveAttribute("spellcheck", "true");
120
+ });
121
+
122
+ it("should render an input with spellcheck disabled by default", () => {
123
+ const { input } = createInput(defaultParams => ({ ...defaultParams }));
124
+
125
+ expect(input).toHaveAttribute("spellcheck", "false");
126
+ });
115
127
  });
116
128
 
117
129
  describe("Should render all different types of inputs", () => {
@@ -222,4 +234,14 @@ describe("It should render prefix and suffix ", () => {
222
234
  expect(input.querySelector("icon-warning")).toBeDefined();
223
235
  expect(getByText(suffix)).toBeDefined();
224
236
  });
237
+
238
+ it("success icon should be visible", () => {
239
+ const { input } = createInput(defaultParams => ({
240
+ ...defaultParams,
241
+ success: true
242
+ }));
243
+ const icon = input.querySelector(".icon-checkmark-circle-breakout");
244
+ expect(input.querySelector(".success")).toBeDefined();
245
+ expect(icon).toBeDefined();
246
+ });
225
247
  });
@@ -24,8 +24,8 @@ import React, {
24
24
  } from "react";
25
25
  import classes from "./Input.module.scss";
26
26
  import readyclasses from "../../readyclasses.module.scss";
27
- import { Icon, Icons } from "../../Icon/Icon";
28
27
  import { FormElement } from "../form.interfaces";
28
+ import { useDetermineStatusIcon } from "../../hooks/useDetermineStatusIcon";
29
29
 
30
30
  export const dateTypes = ["date", "time", "datetime-local"] as const;
31
31
 
@@ -39,7 +39,7 @@ export type Type =
39
39
  | "tel"
40
40
  | "url"
41
41
  | "hidden"
42
- | typeof dateTypes[number];
42
+ | (typeof dateTypes)[number];
43
43
 
44
44
  export interface Props extends ComponentPropsWithRef<"input">, FormElement {
45
45
  wrapperProps?: ComponentPropsWithRef<"div">;
@@ -52,6 +52,7 @@ export interface Props extends ComponentPropsWithRef<"input">, FormElement {
52
52
  const InputComponent: ForwardRefRenderFunction<HTMLInputElement, Props> = (
53
53
  {
54
54
  error = false,
55
+ success = false,
55
56
  className,
56
57
  name,
57
58
  style,
@@ -69,7 +70,6 @@ const InputComponent: ForwardRefRenderFunction<HTMLInputElement, Props> = (
69
70
  ) => {
70
71
  const [focus, setFocus] = useState(false);
71
72
  const inputWrapperRef = useRef<HTMLDivElement>(null);
72
- const errorIconRef = useRef<HTMLDivElement>(null);
73
73
  const suffixRef = useRef<HTMLDivElement>(null);
74
74
 
75
75
  useEffect(() => {
@@ -84,7 +84,6 @@ const InputComponent: ForwardRefRenderFunction<HTMLInputElement, Props> = (
84
84
  inputClassNames.push(classes["shrink-width-for-date-icon"]);
85
85
  className && inputClassNames.push(className);
86
86
 
87
- const iconClassNames = [classes["warning"]];
88
87
  const wrapperClasses = [classes["input-wrapper"]];
89
88
  const outlineClasses = [classes["outline"]];
90
89
 
@@ -95,6 +94,9 @@ const InputComponent: ForwardRefRenderFunction<HTMLInputElement, Props> = (
95
94
  disabled && wrapperClasses.push(classes["disabled"]) && outlineClasses.push(classes["disabled"]);
96
95
  error && wrapperClasses.push(classes["error"]) && outlineClasses.push(classes["error"]);
97
96
  focus && wrapperClasses.push(classes["focus"]) && outlineClasses.push(classes["focus"]);
97
+ success && wrapperClasses.push(classes["success"]);
98
+
99
+ const icon = useDetermineStatusIcon({ success, error });
98
100
 
99
101
  return (
100
102
  <div
@@ -124,13 +126,14 @@ const InputComponent: ForwardRefRenderFunction<HTMLInputElement, Props> = (
124
126
  name={name}
125
127
  disabled={disabled}
126
128
  className={inputClassNames.join(" ")}
129
+ spellCheck={rest.spellCheck || false}
127
130
  />
131
+ {icon}
128
132
  {suffix && (
129
133
  <div ref={suffixRef} data-suffix className={classes["suffix"]}>
130
134
  <span>{suffix}</span>
131
135
  </div>
132
136
  )}
133
- {error && <Icon ref={errorIconRef} className={iconClassNames.join(" ")} icon={Icons.Error} />}
134
137
  <span className={outlineClasses.join(" ")}></span>
135
138
  </div>
136
139
  );