@linzjs/step-ag-grid 17.0.7 → 17.2.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/src/react-menu3/components/ControlledMenu.d.ts +1 -1
- package/dist/src/react-menu3/types.d.ts +0 -4
- package/dist/step-ag-grid.cjs.js +27 -8
- package/dist/step-ag-grid.cjs.js.map +1 -1
- package/dist/step-ag-grid.esm.js +28 -9
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/GridPopoverHook.tsx +0 -1
- package/src/components/gridForm/GridFormMultiSelect.tsx +46 -14
- package/src/react-menu3/components/ControlledMenu.tsx +2 -5
- package/src/react-menu3/types.ts +0 -5
- package/src/stories/grid/gridFormInteraction/GridFormMultiSelectInteraction.stories.tsx +1 -1
package/package.json
CHANGED
|
@@ -78,7 +78,6 @@ export const useGridPopoverHook = <RowType extends GridBaseRow>(props: GridPopov
|
|
|
78
78
|
viewScroll={"auto"}
|
|
79
79
|
dontShrinkIfDirectionIsTop={true}
|
|
80
80
|
className={props.className}
|
|
81
|
-
closeMenuExclusionClassName={"ReactModal__Content"}
|
|
82
81
|
>
|
|
83
82
|
{saving && ( // This is the overlay that prevents editing when the editor is saving
|
|
84
83
|
<div className={"ComponentLoadingWrapper-saveOverlay"} />
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { fromPairs, groupBy, isEmpty, pick, toPairs } from "lodash-es";
|
|
2
|
-
import {
|
|
1
|
+
import { defer, fromPairs, groupBy, isEmpty, pick, toPairs } from "lodash-es";
|
|
2
|
+
import React, {
|
|
3
3
|
Dispatch,
|
|
4
|
+
ForwardedRef,
|
|
4
5
|
Fragment,
|
|
5
6
|
KeyboardEvent,
|
|
6
7
|
ReactElement,
|
|
@@ -73,6 +74,7 @@ export const GridFormMultiSelect = <RowType extends GridBaseRow>(props: GridForm
|
|
|
73
74
|
|
|
74
75
|
const subComponentIsValidRef = useRef<Record<string, boolean>>({});
|
|
75
76
|
const optionsInitialising = useRef(false);
|
|
77
|
+
const firstInputSubComponent = useRef<HTMLInputElement | null>(null);
|
|
76
78
|
|
|
77
79
|
const [filter, setFilter] = useState("");
|
|
78
80
|
const [initialValues, setInitialValues] = useState("");
|
|
@@ -191,11 +193,21 @@ export const GridFormMultiSelect = <RowType extends GridBaseRow>(props: GridForm
|
|
|
191
193
|
<MenuDivider key={`div_${index}`} />
|
|
192
194
|
) : (
|
|
193
195
|
<Fragment key={`val_${item.value}`}>
|
|
194
|
-
<MenuRadioItem
|
|
195
|
-
|
|
196
|
+
<MenuRadioItem
|
|
197
|
+
item={item}
|
|
198
|
+
options={options}
|
|
199
|
+
setOptions={setOptions}
|
|
200
|
+
onChecked={() => {
|
|
201
|
+
// Default to focus on first input in subComponent
|
|
202
|
+
defer(() => {
|
|
203
|
+
firstInputSubComponent.current?.focus();
|
|
204
|
+
});
|
|
205
|
+
}}
|
|
206
|
+
/>
|
|
196
207
|
{item.checked && item.subComponent && (
|
|
197
208
|
<MenuSubComponent
|
|
198
209
|
{...{ item, options, setOptions, data, triggerSave }}
|
|
210
|
+
ref={firstInputSubComponent}
|
|
199
211
|
subComponentIsValid={subComponentIsValidRef.current}
|
|
200
212
|
/>
|
|
201
213
|
)}
|
|
@@ -350,6 +362,7 @@ const MenuRadioItem = (props: {
|
|
|
350
362
|
item: MultiSelectOption;
|
|
351
363
|
options: MultiSelectOption[];
|
|
352
364
|
setOptions: (options: MultiSelectOption[]) => void;
|
|
365
|
+
onChecked?: () => void;
|
|
353
366
|
}) => {
|
|
354
367
|
const { item, options, setOptions } = props;
|
|
355
368
|
|
|
@@ -369,6 +382,7 @@ const MenuRadioItem = (props: {
|
|
|
369
382
|
e.keepOpen = true;
|
|
370
383
|
toggleValue(item);
|
|
371
384
|
}
|
|
385
|
+
item.checked && props.onChecked && props.onChecked();
|
|
372
386
|
}}
|
|
373
387
|
>
|
|
374
388
|
<LuiCheckboxInput
|
|
@@ -395,17 +409,35 @@ const MenuRadioItem = (props: {
|
|
|
395
409
|
);
|
|
396
410
|
};
|
|
397
411
|
|
|
398
|
-
const MenuSubComponent = (
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
412
|
+
const MenuSubComponent = React.forwardRef(MenuSubComponentFr);
|
|
413
|
+
|
|
414
|
+
function MenuSubComponentFr(
|
|
415
|
+
props: {
|
|
416
|
+
data: any;
|
|
417
|
+
item: MultiSelectOption;
|
|
418
|
+
options: MultiSelectOption[];
|
|
419
|
+
setOptions: (options: MultiSelectOption[]) => void;
|
|
420
|
+
subComponentIsValid: Record<string, boolean>;
|
|
421
|
+
triggerSave: () => Promise<void>;
|
|
422
|
+
},
|
|
423
|
+
ref: ForwardedRef<HTMLInputElement>,
|
|
424
|
+
) {
|
|
406
425
|
const { data, item, options, setOptions, subComponentIsValid, triggerSave } = props;
|
|
426
|
+
const focusableRef = React.useRef<HTMLElement | null>(null);
|
|
427
|
+
|
|
428
|
+
useEffect(() => {
|
|
429
|
+
if (focusableRef.current) {
|
|
430
|
+
const firstInputElement = focusableRef.current.querySelectorAll("input")[0] ?? null;
|
|
431
|
+
if (typeof ref === "function") {
|
|
432
|
+
ref(firstInputElement);
|
|
433
|
+
} else if (ref) {
|
|
434
|
+
ref.current = firstInputElement;
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
}, [ref]);
|
|
438
|
+
|
|
407
439
|
return (
|
|
408
|
-
<FocusableItem className={"LuiDeprecatedForms"} key={`${item.value}_subcomponent`}>
|
|
440
|
+
<FocusableItem className={"LuiDeprecatedForms"} key={`${item.value}_subcomponent`} ref={focusableRef}>
|
|
409
441
|
{() => (
|
|
410
442
|
<GridSubComponentContext.Provider
|
|
411
443
|
value={{
|
|
@@ -427,4 +459,4 @@ const MenuSubComponent = (props: {
|
|
|
427
459
|
)}
|
|
428
460
|
</FocusableItem>
|
|
429
461
|
);
|
|
430
|
-
}
|
|
462
|
+
}
|
|
@@ -31,7 +31,6 @@ export const ControlledMenuFr = (
|
|
|
31
31
|
onItemClick,
|
|
32
32
|
onClose,
|
|
33
33
|
saveButtonRef,
|
|
34
|
-
closeMenuExclusionClassName,
|
|
35
34
|
...restProps
|
|
36
35
|
}: ControlledMenuProps & { saveButtonRef?: MutableRefObject<HTMLButtonElement | null> },
|
|
37
36
|
externalRef: ForwardedRef<HTMLUListElement>,
|
|
@@ -68,10 +67,8 @@ export const ControlledMenuFr = (
|
|
|
68
67
|
);
|
|
69
68
|
|
|
70
69
|
const isWithinMenu = useCallback(
|
|
71
|
-
(target: EventTarget | null) =>
|
|
72
|
-
|
|
73
|
-
(closeMenuExclusionClassName && hasParentClass(closeMenuExclusionClassName, target as Node)),
|
|
74
|
-
[closeMenuExclusionClassName],
|
|
70
|
+
(target: EventTarget | null) => hasParentClass("szh-menu--state-open", target as Node),
|
|
71
|
+
[],
|
|
75
72
|
);
|
|
76
73
|
|
|
77
74
|
const handleScreenEventForSave = useCallback(
|
package/src/react-menu3/types.ts
CHANGED
|
@@ -441,9 +441,4 @@ export interface ControlledMenuProps extends RootMenuProps, ExtraMenuProps {
|
|
|
441
441
|
* Event fired when menu is about to close.
|
|
442
442
|
*/
|
|
443
443
|
onClose?: EventHandler<MenuCloseEvent>;
|
|
444
|
-
|
|
445
|
-
/**
|
|
446
|
-
* When clicking outside the menu to close, anything with this class will not cause a close.
|
|
447
|
-
*/
|
|
448
|
-
closeMenuExclusionClassName?: string;
|
|
449
444
|
}
|
|
@@ -111,7 +111,7 @@ GridFormMultiSelectInteractions_.play = async ({ canvasElement }) => {
|
|
|
111
111
|
expect(textInput).toBeInTheDocument();
|
|
112
112
|
expect(await canvas.findByText("Must not be empty")).toBeInTheDocument();
|
|
113
113
|
|
|
114
|
-
|
|
114
|
+
// textInput should be autofocus
|
|
115
115
|
await userEvent.type(textInput, "Hello");
|
|
116
116
|
expect(await canvas.findByText("Press enter or tab to save")).toBeInTheDocument();
|
|
117
117
|
|