@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.
- package/README.md +7 -0
- package/dist/Breadcrumbs/Breadcrumbs.d.ts +1 -1
- package/dist/Button/Button.d.ts +0 -1
- package/dist/ContextMenu/ContextMenu.d.ts +4 -1
- package/dist/DataGrid/DataGridActions/DataGridColumnsToggle.d.ts +1 -1
- package/dist/DataGrid/datagrid.interfaces.d.ts +5 -4
- package/dist/Form/Checkbox/Checkbox.d.ts +1 -1
- package/dist/Form/FormControl/FormControl.d.ts +1 -1
- package/dist/Form/FormHelperText/FormHelperText.d.ts +1 -1
- package/dist/Form/FormSelectorWrapper/FormSelectorWrapper.d.ts +1 -1
- package/dist/Form/Input/Input.d.ts +2 -2
- package/dist/Form/Radio/Radio.d.ts +1 -1
- package/dist/Form/Select/Select.d.ts +2 -2
- package/dist/Form/Select/Select.interfaces.d.ts +1 -1
- package/dist/Form/Textarea/Textarea.d.ts +1 -6
- package/dist/Form/Toggle/Toggle.d.ts +1 -1
- package/dist/Form/Wrapper/CheckboxWrapper/CheckboxWrapper.d.ts +1 -1
- package/dist/Form/Wrapper/InputWrapper/InputWrapper.d.ts +1 -1
- package/dist/Form/Wrapper/RadioWrapper/RadioWrapper.d.ts +1 -1
- package/dist/Form/Wrapper/SelectWrapper/SelectWrapper.d.ts +1 -1
- package/dist/Form/Wrapper/TextareaWrapper/TextareaWrapper.d.ts +1 -1
- package/dist/Form/form.interfaces.d.ts +1 -0
- package/dist/Icon/Icon.d.ts +1 -1
- package/dist/Link/Link.d.ts +2 -3
- package/dist/Notifications/Banner/Banner.d.ts +11 -0
- package/dist/Notifications/Snackbar/interfaces.d.ts +2 -2
- package/dist/Pagination/Pagination.d.ts +3 -3
- package/dist/Popover/Popover.d.ts +3 -1
- package/dist/Tabs/TabButton.d.ts +0 -1
- package/dist/Typography/Typography.d.ts +2 -2
- package/dist/Wizard/Wizard.d.ts +1 -1
- package/dist/Wizard/wizardStateReducer.d.ts +2 -2
- package/dist/_BaseStyling_/BaseStyling.d.ts +4 -0
- package/dist/hooks/useDetermineStatusIcon.d.ts +3 -0
- package/dist/hooks/usePosition.d.ts +6 -5
- package/dist/hooks/useSpacing.d.ts +3 -3
- package/dist/index.d.ts +1 -0
- package/dist/interfaces.d.ts +1 -1
- package/dist/react-lib-components.cjs.development.js +483 -363
- package/dist/react-lib-components.cjs.development.js.map +1 -1
- package/dist/react-lib-components.cjs.production.min.js +1 -1
- package/dist/react-lib-components.cjs.production.min.js.map +1 -1
- package/dist/react-lib-components.esm.js +484 -365
- package/dist/react-lib-components.esm.js.map +1 -1
- package/dist/util/helper.d.ts +1 -1
- package/package.json +39 -38
- package/src/Button/BaseButton.module.scss +2 -2
- package/src/Button/Button.module.scss +4 -5
- package/src/Button/Button.tsx +0 -1
- package/src/Button/IconButton.module.scss +4 -5
- package/src/ContextMenu/ContextMenu.tsx +18 -7
- package/src/DataGrid/DataGrid.tsx +3 -2
- package/src/DataGrid/DataGridActions/DataGridActions.tsx +16 -9
- package/src/DataGrid/DataGridBody/DataGridCell.module.scss +2 -2
- package/src/DataGrid/DataGridHeader/DataGridHeader.test.tsx +8 -3
- package/src/DataGrid/DataGridHeader/DataGridHeader.tsx +3 -1
- package/src/DataGrid/datagrid.interfaces.ts +1 -0
- package/src/Form/Input/Input.module.scss +36 -25
- package/src/Form/Input/Input.test.tsx +22 -0
- package/src/Form/Input/Input.tsx +8 -5
- package/src/Form/Select/Select.module.scss +9 -6
- package/src/Form/Select/Select.test.tsx +11 -0
- package/src/Form/Select/Select.tsx +5 -9
- package/src/Form/Select/SelectService.ts +2 -2
- package/src/Form/Textarea/Textarea.module.scss +21 -13
- package/src/Form/Textarea/Textarea.test.tsx +8 -0
- package/src/Form/Textarea/Textarea.tsx +6 -12
- package/src/Form/Toggle/Toggle.module.scss +3 -3
- package/src/Form/Wrapper/InputWrapper/InputWrapper.module.scss +7 -3
- package/src/Form/Wrapper/InputWrapper/InputWrapper.tsx +2 -0
- package/src/Form/Wrapper/SelectWrapper/SelectWrapper.tsx +12 -1
- package/src/Form/Wrapper/TextareaWrapper/TextareaWrapper.module.scss +15 -14
- package/src/Form/Wrapper/TextareaWrapper/TextareaWrapper.tsx +2 -1
- package/src/Form/Wrapper/Wrapper/Wrapper.module.scss +2 -2
- package/src/Form/form.interfaces.ts +1 -0
- package/src/Link/Link.module.scss +5 -5
- package/src/Link/Link.tsx +14 -13
- package/src/Notifications/Banner/Banner.module.scss +76 -0
- package/src/Notifications/Banner/Banner.test.tsx +84 -0
- package/src/Notifications/Banner/Banner.tsx +78 -0
- package/src/Notifications/BaseModal/BaseModal.module.scss +2 -2
- package/src/Notifications/Snackbar/SnackbarContainer/SnackbarContainer.module.scss +2 -2
- package/src/Notifications/Snackbar/SnackbarItem/SnackbarItem.module.scss +4 -4
- package/src/Notifications/Snackbar/SnackbarItem/SnackbarItem.tsx +3 -2
- package/src/Popover/Popover.module.scss +2 -2
- package/src/Popover/Popover.test.tsx +4 -1
- package/src/Popover/Popover.tsx +40 -8
- package/src/Skeleton/Skeleton.module.scss +2 -2
- package/src/Tabs/TabButton.tsx +1 -2
- package/src/Tabs/Tabs.module.scss +2 -2
- package/src/Tabs/Tabs.tsx +13 -10
- package/src/Tiles/Tile.module.scss +4 -4
- package/src/Tooltip/Tooltip.module.scss +3 -3
- package/src/Tooltip/Tooltip.test.tsx +5 -5
- package/src/_BaseStyling_/BaseStyling.tsx +8 -0
- package/src/hooks/useDetermineStatusIcon.test.ts +28 -0
- package/src/hooks/useDetermineStatusIcon.tsx +35 -0
- package/src/hooks/usePosition.test.tsx +85 -85
- package/src/hooks/usePosition.ts +6 -3
- package/src/index.ts +1 -0
- package/src/mixins.module.scss +5 -5
package/dist/util/helper.d.ts
CHANGED
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
|
+
"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.
|
|
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": "^
|
|
58
|
-
"@storybook/addon-a11y": "^6.5.
|
|
59
|
-
"@storybook/addon-docs": "^6.5.
|
|
60
|
-
"@storybook/addon-essentials": "^6.5.
|
|
61
|
-
"@storybook/addon-links": "^6.5.
|
|
62
|
-
"@storybook/addons": "^6.5.
|
|
63
|
-
"@storybook/builder-webpack5": "^6.5.
|
|
64
|
-
"@storybook/manager-webpack5": "^6.5.
|
|
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.
|
|
67
|
-
"@storybook/theming": "^6.5.
|
|
68
|
-
"@testing-library/dom": "^8.
|
|
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": "^
|
|
72
|
+
"@testing-library/react-hooks": "^8.0.1",
|
|
72
73
|
"@testing-library/user-event": "^13.5.0",
|
|
73
|
-
"@tsconfig/create-react-app": "^1.0.
|
|
74
|
-
"@tsconfig/recommended": "^1.0.
|
|
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.
|
|
77
|
-
"@types/react": "^17.0.
|
|
78
|
-
"@types/react-dom": "^17.0.
|
|
79
|
-
"@types/react-router": "^5.1.
|
|
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.
|
|
82
|
-
"@typescript-eslint/parser": "^5.
|
|
83
|
-
"babel-loader": "^
|
|
84
|
-
"dts-cli": "^1.6.
|
|
85
|
-
"eslint": "^8.
|
|
86
|
-
"eslint-config-prettier": "^8.
|
|
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": "^
|
|
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": "^
|
|
93
|
+
"husky": "^8.0.3",
|
|
93
94
|
"identity-obj-proxy": "^3.0.0",
|
|
94
|
-
"jest-junit": "^
|
|
95
|
-
"lint-staged": "^13.0
|
|
95
|
+
"jest-junit": "^15.0.0",
|
|
96
|
+
"lint-staged": "^13.1.0",
|
|
96
97
|
"npm-run-all": "^4.1.5",
|
|
97
|
-
"prettier": "^2.
|
|
98
|
+
"prettier": "^2.8.3",
|
|
98
99
|
"react": "^17.0.2",
|
|
99
100
|
"react-dom": "^17.0.2",
|
|
100
|
-
"react-is": "^
|
|
101
|
-
"react-router": "^6.
|
|
102
|
-
"react-router-dom": "^6.
|
|
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.
|
|
106
|
-
"size-limit": "^
|
|
107
|
-
"tslib": "^2.4.
|
|
108
|
-
"typescript": "^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,19 +14,18 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
@
|
|
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 {
|
package/src/Button/Button.tsx
CHANGED
|
@@ -14,8 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
@
|
|
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
|
-
|
|
178
|
-
|
|
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
|
-
|
|
74
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
@
|
|
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;
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
@
|
|
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:
|
|
129
|
+
padding-right: 1.25rem;
|
|
104
130
|
|
|
105
131
|
&.remove-extra-indent {
|
|
106
132
|
padding-right: 0;
|
|
107
133
|
}
|
|
108
134
|
}
|
|
109
|
-
|
|
110
|
-
.
|
|
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
|
});
|
package/src/Form/Input/Input.tsx
CHANGED
|
@@ -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
|
);
|