@pushwoosh/dumb-components 4.7.0 → 4.7.1
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/Calendar/CalendarDropdown/CalendarDropdown.js +9 -4
- package/Calendar/CalendarSuperForm/components/CalendarRangePicker/CalendarRangePicker.js +5 -6
- package/hooks/useLayer.js +4 -2
- package/hooks/useThemeName.js +1 -1
- package/package.json +2 -2
- package/shared/dropdownField/useAsyncItems.js +4 -2
- package/shared/dropdownField/useFieldOpenEffects.js +3 -4
|
@@ -66,7 +66,12 @@ export const CalendarDropdown = props => {
|
|
|
66
66
|
setIsOpen(true);
|
|
67
67
|
};
|
|
68
68
|
const {
|
|
69
|
-
refs
|
|
69
|
+
refs: {
|
|
70
|
+
reference,
|
|
71
|
+
floating,
|
|
72
|
+
setReference,
|
|
73
|
+
setFloating
|
|
74
|
+
},
|
|
70
75
|
floatingStyles
|
|
71
76
|
} = useFloating({
|
|
72
77
|
open: isOpen,
|
|
@@ -84,7 +89,7 @@ export const CalendarDropdown = props => {
|
|
|
84
89
|
isOpen,
|
|
85
90
|
onClose: closePopover
|
|
86
91
|
});
|
|
87
|
-
useOnClickOutside([
|
|
92
|
+
useOnClickOutside([reference, floating], () => {
|
|
88
93
|
if (isOpen) closePopover();
|
|
89
94
|
});
|
|
90
95
|
const onChangeHandler = val => {
|
|
@@ -106,7 +111,7 @@ export const CalendarDropdown = props => {
|
|
|
106
111
|
return _jsxs(Horizontal, {
|
|
107
112
|
"$justifyContent": "start",
|
|
108
113
|
children: [_jsx(Button, {
|
|
109
|
-
boxRef:
|
|
114
|
+
boxRef: setReference,
|
|
110
115
|
type: "button",
|
|
111
116
|
view: buttonView,
|
|
112
117
|
size: buttonSize,
|
|
@@ -119,7 +124,7 @@ export const CalendarDropdown = props => {
|
|
|
119
124
|
isOpen: isOpen,
|
|
120
125
|
children: buttonTextCustom ?? buttonText
|
|
121
126
|
}), isOpen && createPortal(_jsx(PopoverContent, {
|
|
122
|
-
ref:
|
|
127
|
+
ref: setFloating,
|
|
123
128
|
style: {
|
|
124
129
|
...floatingStyles,
|
|
125
130
|
zIndex
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { useState } from 'react';
|
|
3
3
|
import { getDisabledRanges } from './getDisabledRanges';
|
|
4
4
|
import { CalendarMonthSlider } from '../../../CalendarMonthSlider/CalendarMonthSlider';
|
|
5
5
|
import { compareStructs } from '../../../helpers';
|
|
@@ -18,17 +18,16 @@ export const CalendarRangePicker = ({
|
|
|
18
18
|
firstDayOfWeek,
|
|
19
19
|
initialVisibleMonth
|
|
20
20
|
}) => {
|
|
21
|
-
const
|
|
22
|
-
if (!startMonthRef.current) {
|
|
21
|
+
const [startMonth] = useState(() => {
|
|
23
22
|
const d = new Date();
|
|
24
|
-
|
|
23
|
+
return initialVisibleMonth ?? value[0] ?? {
|
|
25
24
|
year: d.getFullYear(),
|
|
26
25
|
month: d.getMonth() + 1,
|
|
27
26
|
day: d.getDate()
|
|
28
27
|
};
|
|
29
|
-
}
|
|
28
|
+
});
|
|
30
29
|
return _jsx(CalendarMonthSlider, {
|
|
31
|
-
startMonth:
|
|
30
|
+
startMonth: startMonth,
|
|
32
31
|
visibleCount: visibleCount,
|
|
33
32
|
monthWidth: monthWidth,
|
|
34
33
|
gap: gap,
|
package/hooks/useLayer.js
CHANGED
|
@@ -100,9 +100,11 @@ export function useLayer({
|
|
|
100
100
|
}) {
|
|
101
101
|
const id = useId();
|
|
102
102
|
const onCloseRef = useRef(onClose);
|
|
103
|
-
onCloseRef.current = onClose;
|
|
104
103
|
const zIndexRef = useRef(zIndex);
|
|
105
|
-
|
|
104
|
+
useLayoutEffect(() => {
|
|
105
|
+
onCloseRef.current = onClose;
|
|
106
|
+
zIndexRef.current = zIndex;
|
|
107
|
+
});
|
|
106
108
|
useLayoutEffect(() => {
|
|
107
109
|
if (!isOpen) {
|
|
108
110
|
return undefined;
|
package/hooks/useThemeName.js
CHANGED
|
@@ -11,7 +11,7 @@ function readThemeName(element) {
|
|
|
11
11
|
* @param ref - element inside the theme scope, so a light island wins over the document theme
|
|
12
12
|
* @param isEnabled - pass `false` when the caller already knows the theme and needs no observer */
|
|
13
13
|
export function useThemeName(ref, isEnabled = true) {
|
|
14
|
-
const [themeName, setThemeName] = useState(() => readThemeName(
|
|
14
|
+
const [themeName, setThemeName] = useState(() => readThemeName(null));
|
|
15
15
|
useLayoutEffect(() => {
|
|
16
16
|
if (!isEnabled) {
|
|
17
17
|
return undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pushwoosh/dumb-components",
|
|
3
|
-
"version": "4.7.
|
|
3
|
+
"version": "4.7.1",
|
|
4
4
|
"description": "React components to build Pushwoosh products",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.js",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"@floating-ui/react-dom": "^2.1.2",
|
|
38
38
|
"@lezer/highlight": "^1.2.1",
|
|
39
39
|
"@pushwoosh/kit-constants": "^3.0.0",
|
|
40
|
-
"@pushwoosh/kit-helpers": "^4.16.
|
|
40
|
+
"@pushwoosh/kit-helpers": "^4.16.1",
|
|
41
41
|
"@pushwoosh/kit-icons": "^2.3.15",
|
|
42
42
|
"@pushwoosh/kit-typography": "^2.0.0",
|
|
43
43
|
"@tippyjs/react": "^4.2.6",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
1
|
+
import { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react';
|
|
2
2
|
import { DEFAULT_DEBOUNCE_MS } from './constants';
|
|
3
3
|
import { useDebouncedValue } from './useDebouncedValue';
|
|
4
4
|
/**
|
|
@@ -20,7 +20,9 @@ export function useAsyncItems({
|
|
|
20
20
|
});
|
|
21
21
|
const debouncedQuery = useDebouncedValue(query, debounceMs);
|
|
22
22
|
const loadItemsRef = useRef(loadItems);
|
|
23
|
-
|
|
23
|
+
useLayoutEffect(() => {
|
|
24
|
+
loadItemsRef.current = loadItems;
|
|
25
|
+
});
|
|
24
26
|
const sessionRef = useRef(0);
|
|
25
27
|
const pageRef = useRef(0);
|
|
26
28
|
const queryRef = useRef('');
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useEffect, useRef } from 'react';
|
|
1
|
+
import { useEffect, useEffectEvent, useRef } from 'react';
|
|
2
2
|
/**
|
|
3
3
|
* Side effects tied to a Combobox field's open state: optional autofocus on mount
|
|
4
4
|
* and firing `onClose` when the field closes.
|
|
@@ -11,11 +11,10 @@ export function useFieldOpenEffects({
|
|
|
11
11
|
disabled,
|
|
12
12
|
inputRef
|
|
13
13
|
}) {
|
|
14
|
-
const
|
|
15
|
-
onCloseRef.current = onClose;
|
|
14
|
+
const onCloseEvent = useEffectEvent(() => onClose?.());
|
|
16
15
|
const wasOpenRef = useRef(isOpen);
|
|
17
16
|
useEffect(() => {
|
|
18
|
-
if (wasOpenRef.current && !isOpen)
|
|
17
|
+
if (wasOpenRef.current && !isOpen) onCloseEvent();
|
|
19
18
|
wasOpenRef.current = isOpen;
|
|
20
19
|
}, [isOpen]);
|
|
21
20
|
const didAutoFocusRef = useRef(false);
|