@onewelcome/react-lib-components 8.6.0 → 8.7.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/dist/cjs/Button/BaseButton.cjs.js +1 -1
- package/dist/cjs/Button/BaseButton.cjs.js.map +1 -1
- package/dist/cjs/ContextMenu/ContextMenu.cjs.js +1 -1
- package/dist/cjs/ContextMenu/ContextMenu.cjs.js.map +1 -1
- package/dist/cjs/DataGrid/DataGridFilters/DataGridDateFilter.cjs.js +2 -0
- package/dist/cjs/DataGrid/DataGridFilters/DataGridDateFilter.cjs.js.map +1 -0
- package/dist/cjs/DataGrid/DataGridFilters/DataGridFilterTag.cjs.js +1 -1
- package/dist/cjs/DataGrid/DataGridFilters/DataGridFilterTag.cjs.js.map +1 -1
- package/dist/cjs/DataGrid/DataGridFilters/DataGridFilters.interfaces.cjs.js.map +1 -1
- package/dist/cjs/DataGrid/DataGridFilters/DataGridToolbar.cjs.js +1 -1
- package/dist/cjs/DataGrid/DataGridFilters/DataGridToolbar.cjs.js.map +1 -1
- package/dist/cjs/DataGrid/DataGridFilters/DateTimePicker/DateTimePicker.cjs.js +2 -0
- package/dist/cjs/DataGrid/DataGridFilters/DateTimePicker/DateTimePicker.cjs.js.map +1 -0
- package/dist/cjs/DataGrid/DataGridFilters/DateTimePicker/DateTimePicker.module.scss.cjs.js +2 -0
- package/dist/cjs/DataGrid/DataGridFilters/DateTimePicker/DateTimePicker.module.scss.cjs.js.map +1 -0
- package/dist/cjs/DataGrid/DataGridFilters/DateTimePicker/DateTimePickerCalendarSection.cjs.js +2 -0
- package/dist/cjs/DataGrid/DataGridFilters/DateTimePicker/DateTimePickerCalendarSection.cjs.js.map +1 -0
- package/dist/cjs/DataGrid/DataGridFilters/DateTimePicker/DateTimePickerInputSection.cjs.js +2 -0
- package/dist/cjs/DataGrid/DataGridFilters/DateTimePicker/DateTimePickerInputSection.cjs.js.map +1 -0
- package/dist/cjs/DataGrid/DataGridFilters/DateTimePicker/DateTimeService.cjs.js +2 -0
- package/dist/cjs/DataGrid/DataGridFilters/DateTimePicker/DateTimeService.cjs.js.map +1 -0
- package/dist/cjs/DataGrid/DataGridFilters/DateTimePicker/SideMenu.cjs.js +2 -0
- package/dist/cjs/DataGrid/DataGridFilters/DateTimePicker/SideMenu.cjs.js.map +1 -0
- package/dist/cjs/DatePicker/DatePicker.cjs.js +1 -1
- package/dist/cjs/DatePicker/DatePicker.cjs.js.map +1 -1
- package/dist/cjs/DatePicker/DatePicker.module.scss.cjs.js +1 -1
- package/dist/cjs/Form/FormGroup/FormGroup.cjs.js +1 -1
- package/dist/cjs/Form/FormGroup/FormGroup.cjs.js.map +1 -1
- package/dist/cjs/Form/FormSelectorWrapper/FormSelectorWrapper.cjs.js +1 -1
- package/dist/cjs/Form/FormSelectorWrapper/FormSelectorWrapper.cjs.js.map +1 -1
- package/dist/cjs/Form/Select/MultiSelect/MultiSelect.cjs.js +1 -1
- package/dist/cjs/Form/Select/MultiSelect/MultiSelect.cjs.js.map +1 -1
- package/dist/cjs/Form/Select/SingleSelect/Select.cjs.js +1 -1
- package/dist/cjs/Form/Select/SingleSelect/Select.cjs.js.map +1 -1
- package/dist/cjs/Form/Select/useSelectPositionList.cjs.js +1 -1
- package/dist/cjs/Form/Select/useSelectPositionList.cjs.js.map +1 -1
- package/dist/cjs/Form/Wrapper/InputWrapper/InputWrapper.cjs.js +1 -1
- package/dist/cjs/Form/Wrapper/InputWrapper/InputWrapper.cjs.js.map +1 -1
- package/dist/cjs/Form/Wrapper/Wrapper/Wrapper.cjs.js +1 -1
- package/dist/cjs/Form/Wrapper/Wrapper/Wrapper.cjs.js.map +1 -1
- package/dist/cjs/src/components/DataGrid/DataGridFilters/DataGridDateFilter.d.ts +9 -0
- package/dist/cjs/src/components/DataGrid/DataGridFilters/DataGridFilterTag.d.ts +2 -1
- package/dist/cjs/src/components/DataGrid/DataGridFilters/DataGridFilters.interfaces.d.ts +10 -1
- package/dist/cjs/src/components/DataGrid/DataGridFilters/DataGridToolbar.d.ts +5 -3
- package/dist/cjs/src/components/DataGrid/DataGridFilters/DateTimePicker/DateTimePicker.d.ts +31 -0
- package/dist/cjs/src/components/DataGrid/DataGridFilters/DateTimePicker/DateTimePickerCalendarSection.d.ts +15 -0
- package/dist/cjs/src/components/DataGrid/DataGridFilters/DateTimePicker/DateTimePickerInputSection.d.ts +18 -0
- package/dist/cjs/src/components/DataGrid/DataGridFilters/DateTimePicker/DateTimeService.d.ts +10 -0
- package/dist/cjs/src/components/DataGrid/DataGridFilters/DateTimePicker/SideMenu.d.ts +10 -0
- package/dist/cjs/src/components/DataGrid/testUtils.d.ts +7 -1
- package/dist/cjs/src/components/DatePicker/DatePicker.d.ts +4 -1
- package/dist/cjs/src/components/Form/FormGroup/FormGroup.d.ts +1 -0
- package/dist/cjs/src/components/Form/Wrapper/Wrapper/Wrapper.d.ts +1 -0
- package/dist/cjs/src/hooks/useClickOutside.cjs.js +2 -0
- package/dist/cjs/src/hooks/useClickOutside.cjs.js.map +1 -0
- package/dist/cjs/src/hooks/useClickOutside.d.ts +2 -0
- package/dist/cjs/src/index.cjs.js +1 -1
- package/dist/cjs/src/index.d.ts +1 -0
- package/dist/esm/Button/BaseButton.esm.js +5 -2
- package/dist/esm/Button/BaseButton.esm.js.map +1 -1
- package/dist/esm/ContextMenu/ContextMenu.esm.js +6 -8
- package/dist/esm/ContextMenu/ContextMenu.esm.js.map +1 -1
- package/dist/esm/ContextMenu/ContextMenuItem.esm.js +3 -3
- package/dist/esm/ContextMenu/ContextMenuItem.esm.js.map +1 -1
- package/dist/esm/ContextMenu/ContextMenuItem.module.scss.esm.js +2 -2
- package/dist/esm/DataGrid/DataGridFilters/DataGridDateFilter.esm.js +35 -0
- package/dist/esm/DataGrid/DataGridFilters/DataGridDateFilter.esm.js.map +1 -0
- package/dist/esm/DataGrid/DataGridFilters/DataGridFilterTag.esm.js +16 -7
- package/dist/esm/DataGrid/DataGridFilters/DataGridFilterTag.esm.js.map +1 -1
- package/dist/esm/DataGrid/DataGridFilters/DataGridFilters.interfaces.esm.js.map +1 -1
- package/dist/esm/DataGrid/DataGridFilters/DataGridToolbar.esm.js +15 -12
- package/dist/esm/DataGrid/DataGridFilters/DataGridToolbar.esm.js.map +1 -1
- package/dist/esm/DataGrid/DataGridFilters/DateTimePicker/DateTimePicker.esm.js +138 -0
- package/dist/esm/DataGrid/DataGridFilters/DateTimePicker/DateTimePicker.esm.js.map +1 -0
- package/dist/esm/DataGrid/DataGridFilters/DateTimePicker/DateTimePicker.module.scss.esm.js +8 -0
- package/dist/esm/DataGrid/DataGridFilters/DateTimePicker/DateTimePicker.module.scss.esm.js.map +1 -0
- package/dist/esm/DataGrid/DataGridFilters/DateTimePicker/DateTimePickerCalendarSection.esm.js +54 -0
- package/dist/esm/DataGrid/DataGridFilters/DateTimePicker/DateTimePickerCalendarSection.esm.js.map +1 -0
- package/dist/esm/DataGrid/DataGridFilters/DateTimePicker/DateTimePickerInputSection.esm.js +51 -0
- package/dist/esm/DataGrid/DataGridFilters/DateTimePicker/DateTimePickerInputSection.esm.js.map +1 -0
- package/dist/esm/DataGrid/DataGridFilters/DateTimePicker/DateTimeService.esm.js +29 -0
- package/dist/esm/DataGrid/DataGridFilters/DateTimePicker/DateTimeService.esm.js.map +1 -0
- package/dist/esm/DataGrid/DataGridFilters/DateTimePicker/SideMenu.esm.js +26 -0
- package/dist/esm/DataGrid/DataGridFilters/DateTimePicker/SideMenu.esm.js.map +1 -0
- package/dist/esm/DatePicker/DatePicker.esm.js +3 -1
- package/dist/esm/DatePicker/DatePicker.esm.js.map +1 -1
- package/dist/esm/DatePicker/DatePicker.module.scss.esm.js +2 -2
- package/dist/esm/Form/FormGroup/FormGroup.esm.js +2 -2
- package/dist/esm/Form/FormGroup/FormGroup.esm.js.map +1 -1
- package/dist/esm/Form/FormSelectorWrapper/FormSelectorWrapper.esm.js +1 -1
- package/dist/esm/Form/FormSelectorWrapper/FormSelectorWrapper.esm.js.map +1 -1
- package/dist/esm/Form/Select/MultiSelect/MultiSelect.esm.js +9 -5
- package/dist/esm/Form/Select/MultiSelect/MultiSelect.esm.js.map +1 -1
- package/dist/esm/Form/Select/SingleSelect/Select.esm.js +9 -5
- package/dist/esm/Form/Select/SingleSelect/Select.esm.js.map +1 -1
- package/dist/esm/Form/Select/useSelectPositionList.esm.js +8 -11
- package/dist/esm/Form/Select/useSelectPositionList.esm.js.map +1 -1
- package/dist/esm/Form/Wrapper/InputWrapper/InputWrapper.esm.js +2 -2
- package/dist/esm/Form/Wrapper/InputWrapper/InputWrapper.esm.js.map +1 -1
- package/dist/esm/Form/Wrapper/Wrapper/Wrapper.esm.js +2 -2
- package/dist/esm/Form/Wrapper/Wrapper/Wrapper.esm.js.map +1 -1
- package/dist/esm/src/components/DataGrid/DataGridFilters/DataGridDateFilter.d.ts +9 -0
- package/dist/esm/src/components/DataGrid/DataGridFilters/DataGridFilterTag.d.ts +2 -1
- package/dist/esm/src/components/DataGrid/DataGridFilters/DataGridFilters.interfaces.d.ts +10 -1
- package/dist/esm/src/components/DataGrid/DataGridFilters/DataGridToolbar.d.ts +5 -3
- package/dist/esm/src/components/DataGrid/DataGridFilters/DateTimePicker/DateTimePicker.d.ts +31 -0
- package/dist/esm/src/components/DataGrid/DataGridFilters/DateTimePicker/DateTimePickerCalendarSection.d.ts +15 -0
- package/dist/esm/src/components/DataGrid/DataGridFilters/DateTimePicker/DateTimePickerInputSection.d.ts +18 -0
- package/dist/esm/src/components/DataGrid/DataGridFilters/DateTimePicker/DateTimeService.d.ts +10 -0
- package/dist/esm/src/components/DataGrid/DataGridFilters/DateTimePicker/SideMenu.d.ts +10 -0
- package/dist/esm/src/components/DataGrid/testUtils.d.ts +7 -1
- package/dist/esm/src/components/DatePicker/DatePicker.d.ts +4 -1
- package/dist/esm/src/components/Form/FormGroup/FormGroup.d.ts +1 -0
- package/dist/esm/src/components/Form/Wrapper/Wrapper/Wrapper.d.ts +1 -0
- package/dist/esm/src/hooks/useClickOutside.d.ts +2 -0
- package/dist/esm/src/hooks/useClickOutside.esm.js +38 -0
- package/dist/esm/src/hooks/useClickOutside.esm.js.map +1 -0
- package/dist/esm/src/index.d.ts +1 -0
- package/dist/esm/src/index.esm.js +1 -0
- package/dist/esm/src/index.esm.js.map +1 -1
- package/package.json +7 -3
- package/src/components/Button/BaseButton.tsx +7 -4
- package/src/components/ContextMenu/ContextMenu.tsx +5 -13
- package/src/components/DataGrid/DataGridBody/__snapshots__/DataGridBody.test.tsx.snap +4 -4
- package/src/components/DataGrid/DataGridFilters/DataGridDateFilter.tsx +65 -0
- package/src/components/DataGrid/DataGridFilters/DataGridFilterTag.tsx +25 -5
- package/src/components/DataGrid/DataGridFilters/DataGridFilters.interfaces.ts +18 -1
- package/src/components/DataGrid/DataGridFilters/DataGridToolbar.tsx +53 -33
- package/src/components/DataGrid/DataGridFilters/DateTimePicker/DateTimePicker.module.scss +134 -0
- package/src/components/DataGrid/DataGridFilters/DateTimePicker/DateTimePicker.tsx +267 -0
- package/src/components/DataGrid/DataGridFilters/DateTimePicker/DateTimePickerCalendarSection.tsx +103 -0
- package/src/components/DataGrid/DataGridFilters/DateTimePicker/DateTimePickerInputSection.tsx +121 -0
- package/{dist/esm/src/hooks/useBodyClick.esm.js → src/components/DataGrid/DataGridFilters/DateTimePicker/DateTimeService.ts} +14 -17
- package/src/components/DataGrid/DataGridFilters/DateTimePicker/SideMenu.tsx +50 -0
- package/src/components/DataGrid/testUtils.ts +48 -15
- package/src/components/DatePicker/DatePicker.module.scss +32 -9
- package/src/components/DatePicker/DatePicker.tsx +15 -1
- package/src/components/Form/FormGroup/FormGroup.tsx +6 -1
- package/src/components/Form/FormSelectorWrapper/FormSelectorWrapper.tsx +2 -2
- package/src/components/Form/Select/MultiSelect/MultiSelect.tsx +13 -13
- package/src/components/Form/Select/SingleSelect/Select.tsx +13 -13
- package/src/components/Form/Select/useSelectPositionList.ts +8 -12
- package/src/components/Form/Wrapper/InputWrapper/InputWrapper.tsx +2 -0
- package/src/components/Form/Wrapper/Wrapper/Wrapper.tsx +3 -0
- package/src/hooks/{useBodyClick.ts → useClickOutside.ts} +17 -11
- package/src/index.ts +1 -0
- package/dist/cjs/src/hooks/useBodyClick.cjs.js +0 -2
- package/dist/cjs/src/hooks/useBodyClick.cjs.js.map +0 -1
- package/dist/cjs/src/hooks/useBodyClick.d.ts +0 -1
- package/dist/esm/src/hooks/useBodyClick.d.ts +0 -1
- package/dist/esm/src/hooks/useBodyClick.esm.js.map +0 -1
- /package/dist/cjs/src/hooks/{useBodyClick.test.d.ts → useClickOutside.test.d.ts} +0 -0
- /package/dist/esm/src/hooks/{useBodyClick.test.d.ts → useClickOutside.test.d.ts} +0 -0
|
@@ -38,16 +38,16 @@
|
|
|
38
38
|
--rdp-nav_button-width: 0.75rem;
|
|
39
39
|
--rdp-nav-height: 2.75rem;
|
|
40
40
|
|
|
41
|
-
--rdp-range_middle-background-color: var(--color-
|
|
41
|
+
--rdp-range_middle-background-color: var(--color-blue-grey100);
|
|
42
42
|
--rdp-range_middle-color: black;
|
|
43
43
|
|
|
44
|
-
--rdp-range_start-color:
|
|
45
|
-
--rdp-range_start-background: var(--color-
|
|
46
|
-
--rdp-range_start-date-background-color: var(--color-
|
|
44
|
+
--rdp-range_start-color: var(--color-blue-grey25);
|
|
45
|
+
--rdp-range_start-background: var(--color-blue-grey500);
|
|
46
|
+
--rdp-range_start-date-background-color: var(--color-blue-grey500);
|
|
47
47
|
|
|
48
|
-
--rdp-range_end-background: var(--color-
|
|
49
|
-
--rdp-range_end-color:
|
|
50
|
-
--rdp-range_end-date-background-color: var(--color-
|
|
48
|
+
--rdp-range_end-background: var(--color-blue-grey500);
|
|
49
|
+
--rdp-range_end-color: var(--color-blue-grey25);
|
|
50
|
+
--rdp-range_end-date-background-color: var(--color-blue-grey500);
|
|
51
51
|
|
|
52
52
|
--rdp-week_number-border-radius: var(--button-border-radius);
|
|
53
53
|
--rdp-week_number-border: var(--button-border-radius) solid transparent;
|
|
@@ -261,7 +261,30 @@
|
|
|
261
261
|
}
|
|
262
262
|
|
|
263
263
|
.rdp-today:not(.rdp-outside) {
|
|
264
|
-
|
|
264
|
+
position: relative;
|
|
265
|
+
|
|
266
|
+
&::after {
|
|
267
|
+
content: "";
|
|
268
|
+
position: absolute;
|
|
269
|
+
top: 67%;
|
|
270
|
+
left: calc(50% - 0.125rem);
|
|
271
|
+
width: 0.25rem;
|
|
272
|
+
height: 0.25rem;
|
|
273
|
+
border-radius: 0.5rem;
|
|
274
|
+
background-color: var(--color-blue-grey900);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
&.rdp-range_end {
|
|
278
|
+
&::after {
|
|
279
|
+
background-color: var(--color-blue-grey25);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
&.rdp-range_start {
|
|
284
|
+
&::after {
|
|
285
|
+
background-color: var(--color-blue-grey25);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
265
288
|
}
|
|
266
289
|
|
|
267
290
|
.rdp-selected {
|
|
@@ -275,7 +298,7 @@
|
|
|
275
298
|
}
|
|
276
299
|
|
|
277
300
|
.rdp-selected .rdp-day_button {
|
|
278
|
-
border: var(--button-border-radius) solid var(--color-
|
|
301
|
+
border: var(--button-border-radius) solid var(--color-blue-grey500);
|
|
279
302
|
}
|
|
280
303
|
|
|
281
304
|
.rdp-outside {
|
|
@@ -15,7 +15,14 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import React, { ComponentPropsWithoutRef, Fragment, useEffect, useState } from "react";
|
|
18
|
-
import {
|
|
18
|
+
import {
|
|
19
|
+
ClassNames,
|
|
20
|
+
DateRange,
|
|
21
|
+
DayPicker,
|
|
22
|
+
Locale,
|
|
23
|
+
PropsBase,
|
|
24
|
+
CustomComponents
|
|
25
|
+
} from "react-day-picker";
|
|
19
26
|
import classes from "./DatePicker.module.scss";
|
|
20
27
|
import * as locales from "date-fns/locale";
|
|
21
28
|
|
|
@@ -25,10 +32,15 @@ export interface Props extends ComponentPropsWithoutRef<any> {
|
|
|
25
32
|
value: Date | DateRange | undefined;
|
|
26
33
|
required?: boolean;
|
|
27
34
|
locale?: keyof typeof locales;
|
|
35
|
+
numberOfMonths?: number;
|
|
36
|
+
components?: Partial<CustomComponents>;
|
|
37
|
+
disabled?: boolean;
|
|
28
38
|
}
|
|
29
39
|
|
|
30
40
|
export const DatePicker = ({ onSelect, value, required, mode, locale, ...rest }: Props) => {
|
|
31
41
|
const [dayPickerLocale, setDayPickerLocale] = useState<Locale>(locales.enGB);
|
|
42
|
+
//we have to specify the endMonth value. Otherwise the date range picker doesn't let us to navigate between years
|
|
43
|
+
const endMonth = new Date(3000, 12);
|
|
32
44
|
|
|
33
45
|
useEffect(() => {
|
|
34
46
|
try {
|
|
@@ -66,6 +78,7 @@ export const DatePicker = ({ onSelect, value, required, mode, locale, ...rest }:
|
|
|
66
78
|
{...rest}
|
|
67
79
|
{...commonProps}
|
|
68
80
|
mode={mode}
|
|
81
|
+
endMonth={endMonth}
|
|
69
82
|
onSelect={onSelect}
|
|
70
83
|
selected={value as Date | undefined}
|
|
71
84
|
></DayPicker>
|
|
@@ -74,6 +87,7 @@ export const DatePicker = ({ onSelect, value, required, mode, locale, ...rest }:
|
|
|
74
87
|
{...rest}
|
|
75
88
|
{...commonProps}
|
|
76
89
|
mode={mode}
|
|
90
|
+
endMonth={endMonth}
|
|
77
91
|
onSelect={onSelect}
|
|
78
92
|
selected={value as DateRange | undefined}
|
|
79
93
|
/>
|
|
@@ -28,6 +28,7 @@ export interface Props extends ComponentPropsWithRef<"div"> {
|
|
|
28
28
|
errorMessageIconPosition?: "before" | "after";
|
|
29
29
|
errorMessage?: string;
|
|
30
30
|
errorId?: string;
|
|
31
|
+
errorMessageProps?: ComponentPropsWithRef<"span">;
|
|
31
32
|
helperText?: string;
|
|
32
33
|
helperId?: string;
|
|
33
34
|
helperProps?: HelperProps;
|
|
@@ -43,6 +44,7 @@ const FormGroupComponent: ForwardRefRenderFunction<HTMLDivElement, Props> = (
|
|
|
43
44
|
errorId,
|
|
44
45
|
errorMessageIcon,
|
|
45
46
|
errorMessageIconPosition = "before",
|
|
47
|
+
errorMessageProps,
|
|
46
48
|
helperText,
|
|
47
49
|
helperId,
|
|
48
50
|
helperProps,
|
|
@@ -74,7 +76,10 @@ const FormGroupComponent: ForwardRefRenderFunction<HTMLDivElement, Props> = (
|
|
|
74
76
|
</FormHelperText>
|
|
75
77
|
)}
|
|
76
78
|
{error && errorMessage && (
|
|
77
|
-
<span
|
|
79
|
+
<span
|
|
80
|
+
{...errorMessageProps}
|
|
81
|
+
className={`${classes["error-message"]} ${errorMessageProps?.className ? errorMessageProps.className : ""}`}
|
|
82
|
+
>
|
|
78
83
|
<span id={errorId} className={classes.message}>
|
|
79
84
|
{errorMessageIcon && errorMessageIconPosition === "before" && (
|
|
80
85
|
<Icon
|
|
@@ -64,7 +64,7 @@ const FormSelectorWrapperComponent: ForwardRefRenderFunction<HTMLDivElement, Pro
|
|
|
64
64
|
}`}
|
|
65
65
|
>
|
|
66
66
|
<div {...containerProps}>{children}</div>
|
|
67
|
-
{(helperText || helperProps?.children) && (
|
|
67
|
+
{(errorMessage || helperText || helperProps?.children) && (
|
|
68
68
|
<FormHelperText
|
|
69
69
|
{...helperProps}
|
|
70
70
|
ref={helperRef}
|
|
@@ -73,7 +73,7 @@ const FormSelectorWrapperComponent: ForwardRefRenderFunction<HTMLDivElement, Pro
|
|
|
73
73
|
error ? classes["error"] : ""
|
|
74
74
|
}`}
|
|
75
75
|
>
|
|
76
|
-
{error ? (
|
|
76
|
+
{error && errorMessage ? (
|
|
77
77
|
<span className={classes["error-message"]} id={errorId}>
|
|
78
78
|
{errorMessage}
|
|
79
79
|
</span>
|
|
@@ -18,14 +18,13 @@ import classes from "./MultiSelect.module.scss";
|
|
|
18
18
|
|
|
19
19
|
import React, {
|
|
20
20
|
ForwardRefRenderFunction,
|
|
21
|
-
Fragment,
|
|
22
21
|
ReactElement,
|
|
23
22
|
createRef,
|
|
24
23
|
useEffect,
|
|
25
24
|
useRef,
|
|
26
25
|
useState
|
|
27
26
|
} from "react";
|
|
28
|
-
import {
|
|
27
|
+
import { useClickOutside } from "../../../../hooks/useClickOutside";
|
|
29
28
|
import { useDetermineStatusIcon } from "../../../../hooks/useDetermineStatusIcon";
|
|
30
29
|
import readyclasses from "../../../../readyclasses.module.scss";
|
|
31
30
|
import { escapeRegExp, filterProps, generateID } from "../../../../util/helper";
|
|
@@ -274,15 +273,16 @@ const MultiSelectComponent: ForwardRefRenderFunction<HTMLSelectElement, MultiSel
|
|
|
274
273
|
syncSelectedOption(value);
|
|
275
274
|
}, [value]);
|
|
276
275
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
276
|
+
const myElementRef = useRef<HTMLDivElement>(null);
|
|
277
|
+
|
|
278
|
+
useClickOutside(myElementRef, () => {
|
|
279
|
+
if (!expanded) {
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
setExpanded(false);
|
|
283
|
+
setListPosition(Position.Below);
|
|
284
|
+
setOpacity(0);
|
|
285
|
+
}, [expanded]);
|
|
286
286
|
|
|
287
287
|
const additionalClasses = [];
|
|
288
288
|
expanded && additionalClasses.push(classes.expanded);
|
|
@@ -329,7 +329,7 @@ const MultiSelectComponent: ForwardRefRenderFunction<HTMLSelectElement, MultiSel
|
|
|
329
329
|
|
|
330
330
|
/** The native select is purely for external form libraries. We use it to emit an onChange with native select event object so they know exactly what's happening. */
|
|
331
331
|
return (
|
|
332
|
-
<
|
|
332
|
+
<div ref={myElementRef}>
|
|
333
333
|
<select
|
|
334
334
|
{...filterProps(rest, /^data-/, false)}
|
|
335
335
|
tabIndex={-1}
|
|
@@ -388,7 +388,7 @@ const MultiSelectComponent: ForwardRefRenderFunction<HTMLSelectElement, MultiSel
|
|
|
388
388
|
</div>
|
|
389
389
|
{listPosition === Position.Below ? optionsElement : undefined}
|
|
390
390
|
</div>
|
|
391
|
-
</
|
|
391
|
+
</div>
|
|
392
392
|
);
|
|
393
393
|
};
|
|
394
394
|
|
|
@@ -19,13 +19,12 @@ import classes from "./Select.module.scss";
|
|
|
19
19
|
import React, {
|
|
20
20
|
createRef,
|
|
21
21
|
ForwardRefRenderFunction,
|
|
22
|
-
Fragment,
|
|
23
22
|
ReactElement,
|
|
24
23
|
useEffect,
|
|
25
24
|
useRef,
|
|
26
25
|
useState
|
|
27
26
|
} from "react";
|
|
28
|
-
import {
|
|
27
|
+
import { useClickOutside } from "../../../../hooks/useClickOutside";
|
|
29
28
|
import { useDetermineStatusIcon } from "../../../../hooks/useDetermineStatusIcon";
|
|
30
29
|
import readyclasses from "../../../../readyclasses.module.scss";
|
|
31
30
|
import { filterProps } from "../../../../util/helper";
|
|
@@ -204,15 +203,16 @@ const SelectComponent: ForwardRefRenderFunction<HTMLSelectElement, SingleSelectP
|
|
|
204
203
|
syncDisplayValue(value);
|
|
205
204
|
}, [value]);
|
|
206
205
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
206
|
+
const myElementRef = useRef<HTMLDivElement>(null);
|
|
207
|
+
|
|
208
|
+
useClickOutside(myElementRef, () => {
|
|
209
|
+
if (!expanded) {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
setExpanded(false);
|
|
213
|
+
setListPosition(Position.Below);
|
|
214
|
+
setOpacity(0);
|
|
215
|
+
}, [expanded]);
|
|
216
216
|
|
|
217
217
|
const additionalClasses = [];
|
|
218
218
|
expanded && additionalClasses.push(classes.expanded);
|
|
@@ -223,7 +223,7 @@ const SelectComponent: ForwardRefRenderFunction<HTMLSelectElement, SingleSelectP
|
|
|
223
223
|
|
|
224
224
|
/** The native select is purely for external form libraries. We use it to emit an onChange with native select event object so they know exactly what's happening. */
|
|
225
225
|
return (
|
|
226
|
-
<
|
|
226
|
+
<div ref={myElementRef}>
|
|
227
227
|
<select
|
|
228
228
|
{...filterProps(rest, /^data-/, false)}
|
|
229
229
|
tabIndex={-1}
|
|
@@ -293,7 +293,7 @@ const SelectComponent: ForwardRefRenderFunction<HTMLSelectElement, SingleSelectP
|
|
|
293
293
|
</div>
|
|
294
294
|
</div>
|
|
295
295
|
</div>
|
|
296
|
-
</
|
|
296
|
+
</div>
|
|
297
297
|
);
|
|
298
298
|
};
|
|
299
299
|
export const Select = withReadOnly(React.forwardRef(SelectComponent));
|
|
@@ -43,21 +43,17 @@ export const useSelectPositionList = ({
|
|
|
43
43
|
return;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
// Check space between the bottom of select and top of viewport
|
|
48
|
-
const spaceOnTopOfSelect = containerReference.current.getBoundingClientRect().bottom;
|
|
46
|
+
const listHeight = optionListReference.current?.getBoundingClientRect().height;
|
|
49
47
|
|
|
50
|
-
|
|
51
|
-
const spaceOnBottomOfSelect =
|
|
52
|
-
window.innerHeight - containerReference.current.getBoundingClientRect().top;
|
|
48
|
+
const viewportRelativeRect = containerReference.current.getBoundingClientRect();
|
|
53
49
|
|
|
54
|
-
|
|
55
|
-
|
|
50
|
+
const spaceOnTopOfSelect = viewportRelativeRect.top;
|
|
51
|
+
const spaceOnBottomOfSelect = window.innerHeight - viewportRelativeRect.bottom;
|
|
56
52
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
53
|
+
const position =
|
|
54
|
+
listHeight > spaceOnBottomOfSelect && spaceOnTopOfSelect > spaceOnBottomOfSelect
|
|
55
|
+
? Position.Above
|
|
56
|
+
: Position.Below;
|
|
61
57
|
|
|
62
58
|
setListPosition(position);
|
|
63
59
|
|
|
@@ -45,6 +45,7 @@ const InputWrapperComponent: ForwardRefRenderFunction<HTMLDivElement, Props> = (
|
|
|
45
45
|
value,
|
|
46
46
|
className,
|
|
47
47
|
error,
|
|
48
|
+
errorMessageProps,
|
|
48
49
|
success,
|
|
49
50
|
onChange,
|
|
50
51
|
onBlur,
|
|
@@ -77,6 +78,7 @@ const InputWrapperComponent: ForwardRefRenderFunction<HTMLDivElement, Props> = (
|
|
|
77
78
|
}}
|
|
78
79
|
errorId={errorId}
|
|
79
80
|
error={error}
|
|
81
|
+
errorMessageProps={errorMessageProps}
|
|
80
82
|
helperId={helperId}
|
|
81
83
|
helperText={helperText}
|
|
82
84
|
helperProps={{
|
|
@@ -37,6 +37,7 @@ export interface WrapperProps extends Omit<FormElement, "success"> {
|
|
|
37
37
|
errorMessage?: string;
|
|
38
38
|
helperText?: string;
|
|
39
39
|
helperProps?: HelperProps;
|
|
40
|
+
errorMessageProps?: ComponentPropsWithRef<"span">;
|
|
40
41
|
label?: string;
|
|
41
42
|
name: string;
|
|
42
43
|
required?: boolean;
|
|
@@ -52,6 +53,7 @@ const WrapperComponent: ForwardRefRenderFunction<HTMLDivElement, Props> = (
|
|
|
52
53
|
errorId,
|
|
53
54
|
errorMessageIcon,
|
|
54
55
|
errorMessageIconPosition,
|
|
56
|
+
errorMessageProps,
|
|
55
57
|
helperText,
|
|
56
58
|
helperId,
|
|
57
59
|
required,
|
|
@@ -89,6 +91,7 @@ const WrapperComponent: ForwardRefRenderFunction<HTMLDivElement, Props> = (
|
|
|
89
91
|
errorId={errorId}
|
|
90
92
|
errorMessageIcon={errorMessageIcon}
|
|
91
93
|
errorMessageIconPosition={errorMessageIconPosition}
|
|
94
|
+
errorMessageProps={errorMessageProps}
|
|
92
95
|
helperText={helperText}
|
|
93
96
|
helperId={helperId}
|
|
94
97
|
helperProps={helperProps}
|
|
@@ -14,23 +14,29 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import { useEffect } from "react";
|
|
17
|
+
import { DependencyList, useEffect } from "react";
|
|
18
18
|
|
|
19
|
-
export const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
export const useClickOutside = (
|
|
20
|
+
myElementRef: React.RefObject<HTMLElement>,
|
|
21
|
+
onClickOutside: (event: MouseEvent) => void,
|
|
22
|
+
dependencies?: DependencyList
|
|
23
23
|
) => {
|
|
24
|
-
function
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
function eventListener(event: MouseEvent) {
|
|
25
|
+
const myElement = myElementRef?.current;
|
|
26
|
+
if (!myElement) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const clickedInsideMyElement = myElement.contains(event.target as Node);
|
|
30
|
+
|
|
31
|
+
if (!clickedInsideMyElement) {
|
|
32
|
+
onClickOutside(event);
|
|
27
33
|
}
|
|
28
34
|
}
|
|
29
35
|
useEffect(() => {
|
|
30
|
-
window.addEventListener("click",
|
|
36
|
+
setTimeout(() => window.addEventListener("click", eventListener));
|
|
31
37
|
|
|
32
38
|
return () => {
|
|
33
|
-
window.removeEventListener("click",
|
|
39
|
+
setTimeout(() => window.removeEventListener("click", eventListener));
|
|
34
40
|
};
|
|
35
|
-
},
|
|
41
|
+
}, dependencies);
|
|
36
42
|
};
|
package/src/index.ts
CHANGED
|
@@ -66,6 +66,7 @@ export type {
|
|
|
66
66
|
|
|
67
67
|
/* Utils */
|
|
68
68
|
export { useRepeater } from "./hooks/useRepeater";
|
|
69
|
+
export { useClickOutside } from "./hooks/useClickOutside";
|
|
69
70
|
export { useFullHeightCollapse } from "./hooks/useFullHeightCollapse";
|
|
70
71
|
export { usePosition } from "./hooks/usePosition";
|
|
71
72
|
export type { Placement } from "./hooks/usePosition";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useBodyClick.cjs.js","sources":["../../../../../../src/hooks/useBodyClick.ts"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useEffect } from \"react\";\n\nexport const useBodyClick = (\n checkFunction: (event: MouseEvent) => boolean,\n callbackFunction: (...args: unknown[]) => unknown,\n dependingStateVariable: React.ComponentState | React.ComponentState[]\n) => {\n function bodyClickListener(event: MouseEvent) {\n if (checkFunction(event)) {\n callbackFunction();\n }\n }\n useEffect(() => {\n window.addEventListener(\"click\", bodyClickListener);\n\n return () => {\n window.removeEventListener(\"click\", bodyClickListener);\n };\n }, [dependingStateVariable]);\n};\n"],"names":["checkFunction","callbackFunction","dependingStateVariable","bodyClickListener","event","useEffect","window","addEventListener","removeEventListener"],"mappings":"yDAkB4B,CAC1BA,EACAC,EACAC,KAEA,SAASC,EAAkBC,GACrBJ,EAAcI,IAChBH,GAEH,CACDI,EAAAA,WAAU,KACRC,OAAOC,iBAAiB,QAASJ,GAE1B,KACLG,OAAOE,oBAAoB,QAASL,EAAkB,IAEvD,CAACD,GAAwB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const useBodyClick: (checkFunction: (event: MouseEvent) => boolean, callbackFunction: (...args: unknown[]) => unknown, dependingStateVariable: React.ComponentState | React.ComponentState[]) => void;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const useBodyClick: (checkFunction: (event: MouseEvent) => boolean, callbackFunction: (...args: unknown[]) => unknown, dependingStateVariable: React.ComponentState | React.ComponentState[]) => void;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useBodyClick.esm.js","sources":["../../../../../../src/hooks/useBodyClick.ts"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useEffect } from \"react\";\n\nexport const useBodyClick = (\n checkFunction: (event: MouseEvent) => boolean,\n callbackFunction: (...args: unknown[]) => unknown,\n dependingStateVariable: React.ComponentState | React.ComponentState[]\n) => {\n function bodyClickListener(event: MouseEvent) {\n if (checkFunction(event)) {\n callbackFunction();\n }\n }\n useEffect(() => {\n window.addEventListener(\"click\", bodyClickListener);\n\n return () => {\n window.removeEventListener(\"click\", bodyClickListener);\n };\n }, [dependingStateVariable]);\n};\n"],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;;AAcG;AAIU,MAAA,YAAY,GAAG,CAC1B,aAA6C,EAC7C,gBAAiD,EACjD,sBAAqE,KACnE;IACF,SAAS,iBAAiB,CAAC,KAAiB,EAAA;AAC1C,QAAA,IAAI,aAAa,CAAC,KAAK,CAAC,EAAE;AACxB,YAAA,gBAAgB,EAAE,CAAC;SACpB;KACF;IACD,SAAS,CAAC,MAAK;AACb,QAAA,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC;AAEpD,QAAA,OAAO,MAAK;AACV,YAAA,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC;AACzD,SAAC,CAAC;AACJ,KAAC,EAAE,CAAC,sBAAsB,CAAC,CAAC,CAAC;AAC/B;;;;"}
|
|
File without changes
|
|
File without changes
|