@linzjs/step-ag-grid 2.3.0 → 2.4.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/index.js +48 -23
- package/dist/index.js.map +1 -1
- package/dist/src/components/GridSubComponentTextArea.d.ts +4 -4
- package/dist/src/components/gridForm/GridFormTextArea.d.ts +1 -1
- package/dist/src/components/gridForm/GridFormTextInput.d.ts +1 -1
- package/dist/src/contexts/GridSubComponentContext.d.ts +8 -0
- package/dist/step-ag-grid.esm.js +48 -23
- 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/GridSubComponentTextArea.tsx +22 -10
- package/src/components/gridForm/GridFormMultiSelect.tsx +19 -15
- package/src/components/gridForm/GridFormTextArea.tsx +3 -3
- package/src/components/gridForm/GridFormTextInput.tsx +3 -3
- package/src/contexts/GridSubComponentContext.ts +21 -0
- package/src/react-menu3/components/ControlledMenu.tsx +13 -9
- package/src/stories/components/ActionButton.stories.tsx +1 -1
- package/src/stories/grid/FormTest.tsx +5 -6
- package/src/stories/grid/GridPopoutBearing.stories.tsx +1 -1
- package/src/stories/grid/GridPopoutEditDropDown.stories.tsx +1 -1
- package/src/stories/grid/GridPopoutEditGeneric.stories.tsx +1 -1
- package/src/stories/grid/GridPopoutEditGenericTextArea.stories.tsx +3 -3
- package/src/stories/grid/GridPopoutEditMultiSelect.stories.tsx +2 -2
- package/src/stories/grid/GridReadOnly.stories.tsx +1 -1
- package/dist/src/components/gridForm/GridSubComponentProps.d.ts +0 -6
- package/src/components/gridForm/GridSubComponentProps.ts +0 -6
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
|
|
3
|
-
export interface GridSubComponentTextAreaProps extends GridSubComponentProps {
|
|
2
|
+
export interface GridSubComponentTextAreaProps {
|
|
4
3
|
placeholder?: string;
|
|
5
4
|
required?: boolean;
|
|
6
|
-
|
|
5
|
+
maxLength?: number;
|
|
7
6
|
width?: string | number;
|
|
8
|
-
validate
|
|
7
|
+
validate?: (value: string) => string | null;
|
|
8
|
+
defaultValue: string;
|
|
9
9
|
}
|
|
10
10
|
export declare const GridSubComponentTextArea: (props: GridSubComponentTextAreaProps) => JSX.Element;
|
|
@@ -4,7 +4,7 @@ import { CellEditorCommon } from "../GridCell";
|
|
|
4
4
|
export interface GridFormTextAreaProps<RowType extends GridBaseRow> extends CellEditorCommon {
|
|
5
5
|
placeholder?: string;
|
|
6
6
|
required?: boolean;
|
|
7
|
-
|
|
7
|
+
maxLength?: number;
|
|
8
8
|
width?: string | number;
|
|
9
9
|
validate?: (value: string) => string | null;
|
|
10
10
|
onSave?: (selectedRows: RowType[], value: string) => Promise<boolean>;
|
|
@@ -5,7 +5,7 @@ export interface GridFormTextInputProps<RowType extends GridBaseRow> extends Cel
|
|
|
5
5
|
placeholder?: string;
|
|
6
6
|
units?: string;
|
|
7
7
|
required?: boolean;
|
|
8
|
-
|
|
8
|
+
maxLength?: number;
|
|
9
9
|
width?: string | number;
|
|
10
10
|
validate?: (value: string, data: RowType) => string | null;
|
|
11
11
|
onSave?: (selectedRows: RowType[], value: string) => Promise<boolean>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export interface GridSubComponentContextType {
|
|
3
|
+
value: any;
|
|
4
|
+
setValue: (value: string) => void;
|
|
5
|
+
setValid: (valid: boolean) => void;
|
|
6
|
+
triggerSave: () => Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
export declare const GridSubComponentContext: import("react").Context<GridSubComponentContextType>;
|
package/dist/step-ag-grid.esm.js
CHANGED
|
@@ -1303,12 +1303,12 @@ var ControlledMenuFr = function (_a, externalRef) {
|
|
|
1303
1303
|
reposition,
|
|
1304
1304
|
viewScroll,
|
|
1305
1305
|
]);
|
|
1306
|
-
var
|
|
1307
|
-
return hasParentClass("szh-menu--state-open",
|
|
1308
|
-
(closeMenuExclusionClassName && hasParentClass(closeMenuExclusionClassName,
|
|
1306
|
+
var isWithinMenu = useCallback(function (target) {
|
|
1307
|
+
return hasParentClass("szh-menu--state-open", target) ||
|
|
1308
|
+
(closeMenuExclusionClassName && hasParentClass(closeMenuExclusionClassName, target));
|
|
1309
1309
|
}, [closeMenuExclusionClassName]);
|
|
1310
1310
|
var handleScreenEventForSave = useCallback(function (ev) {
|
|
1311
|
-
if (!
|
|
1311
|
+
if (!isWithinMenu(ev.target)) {
|
|
1312
1312
|
ev.preventDefault();
|
|
1313
1313
|
ev.stopPropagation();
|
|
1314
1314
|
// FIXME There's an issue in React17
|
|
@@ -1330,13 +1330,13 @@ var ControlledMenuFr = function (_a, externalRef) {
|
|
|
1330
1330
|
setTimeout(function () { return (skipOpen.current = false); }, 300);
|
|
1331
1331
|
}
|
|
1332
1332
|
}
|
|
1333
|
-
}, [
|
|
1333
|
+
}, [isWithinMenu, onClose, saveButtonRef, skipOpen]);
|
|
1334
1334
|
var handleScreenEventForCancel = useCallback(function (ev) {
|
|
1335
|
-
if (!
|
|
1335
|
+
if (!isWithinMenu(ev.target)) {
|
|
1336
1336
|
ev.preventDefault();
|
|
1337
1337
|
ev.stopPropagation();
|
|
1338
1338
|
}
|
|
1339
|
-
}, [
|
|
1339
|
+
}, [isWithinMenu]);
|
|
1340
1340
|
useEffect(function () {
|
|
1341
1341
|
if (isMenuOpen(state)) {
|
|
1342
1342
|
var thisDocument_1 = (anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current) ? anchorRef === null || anchorRef === void 0 ? void 0 : anchorRef.current.ownerDocument : document;
|
|
@@ -1389,7 +1389,9 @@ var ControlledMenuFr = function (_a, externalRef) {
|
|
|
1389
1389
|
}
|
|
1390
1390
|
};
|
|
1391
1391
|
var onBlur = function (e) {
|
|
1392
|
-
if (isMenuOpen(state) &&
|
|
1392
|
+
if (isMenuOpen(state) &&
|
|
1393
|
+
!e.currentTarget.contains(e.relatedTarget || document.activeElement) &&
|
|
1394
|
+
!isWithinMenu(e.relatedTarget)) {
|
|
1393
1395
|
safeCall(onClose, { reason: CloseReason.BLUR });
|
|
1394
1396
|
// If a user clicks on the menu button when a menu is open, we need to close the menu.
|
|
1395
1397
|
// However, a blur event will be fired prior to the click event on menu button,
|
|
@@ -2709,8 +2711,6 @@ var useGridPopoverHook = function (props) {
|
|
|
2709
2711
|
}); }, [props, stopEditing, propsRef]);
|
|
2710
2712
|
var popoverWrapper = useCallback(function (children) {
|
|
2711
2713
|
return (jsx(Fragment$1, { children: anchorRef.current && (jsxs(ControlledMenu, __assign({ state: isOpen ? "open" : "closed", portal: true, unmountOnClose: true, anchorRef: anchorRef, saveButtonRef: saveButtonRef, menuClassName: "step-ag-grid-react-menu", onClose: function (event) {
|
|
2712
|
-
if (event.reason === "blur")
|
|
2713
|
-
return;
|
|
2714
2714
|
triggerSave(event.reason).then();
|
|
2715
2715
|
}, viewScroll: "auto", dontShrinkIfDirectionIsTop: true, className: props.className, closeMenuExclusionClassName: "ReactModal__Content" }, { children: [saving && ( // This is the overlay that prevents editing when the editor is saving
|
|
2716
2716
|
jsx("div", { style: {
|
|
@@ -2998,6 +2998,22 @@ var GridFormDropDown = function (_props) {
|
|
|
2998
2998
|
})] }) }))] }));
|
|
2999
2999
|
};
|
|
3000
3000
|
|
|
3001
|
+
var GridSubComponentContext = createContext({
|
|
3002
|
+
value: "GridSubComponentContext value no context",
|
|
3003
|
+
setValue: function () {
|
|
3004
|
+
console.error("GridSubComponentContext setValue no context");
|
|
3005
|
+
},
|
|
3006
|
+
setValid: function () {
|
|
3007
|
+
console.error("GridSubComponentContext setValid no context");
|
|
3008
|
+
},
|
|
3009
|
+
triggerSave: function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
3010
|
+
return __generator(this, function (_a) {
|
|
3011
|
+
console.error("GridSubComponentContext triggerSave no context");
|
|
3012
|
+
return [2 /*return*/];
|
|
3013
|
+
});
|
|
3014
|
+
}); }
|
|
3015
|
+
});
|
|
3016
|
+
|
|
3001
3017
|
var GridFormMultiSelect = function (props) {
|
|
3002
3018
|
var selectedRows = props.selectedRows;
|
|
3003
3019
|
var initialiseValues = useMemo(function () { return props.initialSelectedValues && props.initialSelectedValues(selectedRows); }, [props, selectedRows]);
|
|
@@ -3124,10 +3140,8 @@ var GridFormMultiSelect = function (props) {
|
|
|
3124
3140
|
}
|
|
3125
3141
|
}, onChange: function () {
|
|
3126
3142
|
/*Do nothing, change handled by menuItem*/
|
|
3127
|
-
} }) }), "".concat(index)), selectedValues.includes(item.value) && item.subComponent && (jsx(FocusableItem, __assign({ className: "LuiDeprecatedForms" }, { children: function (
|
|
3128
|
-
return item.subComponent &&
|
|
3129
|
-
item.subComponent({
|
|
3130
|
-
ref: ref,
|
|
3143
|
+
} }) }), "".concat(index)), selectedValues.includes(item.value) && item.subComponent && (jsx(FocusableItem, __assign({ className: "LuiDeprecatedForms" }, { children: function (_) {
|
|
3144
|
+
return item.subComponent && (jsx(GridSubComponentContext.Provider, __assign({ value: {
|
|
3131
3145
|
value: subSelectedValues["".concat(item.value)],
|
|
3132
3146
|
setValue: function (value) {
|
|
3133
3147
|
subSelectedValues["".concat(item.value)] = value;
|
|
@@ -3137,7 +3151,7 @@ var GridFormMultiSelect = function (props) {
|
|
|
3137
3151
|
subComponentIsValid.current["".concat(item.value)] = valid;
|
|
3138
3152
|
},
|
|
3139
3153
|
triggerSave: triggerSave
|
|
3140
|
-
});
|
|
3154
|
+
} }, { children: jsx(item.subComponent, {}) })));
|
|
3141
3155
|
} }), "".concat(item.value, "_subcomponent")))] }, "".concat(index)));
|
|
3142
3156
|
}) }))] }) })));
|
|
3143
3157
|
};
|
|
@@ -3513,8 +3527,8 @@ var GridFormTextArea = function (_props) {
|
|
|
3513
3527
|
if (props.required && value.length == 0) {
|
|
3514
3528
|
return "Some text is required";
|
|
3515
3529
|
}
|
|
3516
|
-
if (props.
|
|
3517
|
-
return "Text must be no longer than ".concat(props.
|
|
3530
|
+
if (props.maxLength && value.length > props.maxLength) {
|
|
3531
|
+
return "Text must be no longer than ".concat(props.maxLength, " characters");
|
|
3518
3532
|
}
|
|
3519
3533
|
if (props.validate) {
|
|
3520
3534
|
return props.validate(value);
|
|
@@ -3560,8 +3574,8 @@ var GridFormTextInput = function (_props) {
|
|
|
3560
3574
|
if (props.required && trimmedValue.length == 0) {
|
|
3561
3575
|
return "Some text is required";
|
|
3562
3576
|
}
|
|
3563
|
-
if (props.
|
|
3564
|
-
return "Text must be no longer than ".concat(props.
|
|
3577
|
+
if (props.maxLength && trimmedValue.length > props.maxLength) {
|
|
3578
|
+
return "Text must be no longer than ".concat(props.maxLength, " characters");
|
|
3565
3579
|
}
|
|
3566
3580
|
if (props.validate) {
|
|
3567
3581
|
return props.validate(trimmedValue, props.data);
|
|
@@ -3612,13 +3626,24 @@ var GridPopoverTextInput = function (colDef, params) {
|
|
|
3612
3626
|
};
|
|
3613
3627
|
|
|
3614
3628
|
var GridSubComponentTextArea = function (props) {
|
|
3615
|
-
var value =
|
|
3629
|
+
var _a = useContext(GridSubComponentContext), value = _a.value, setValue = _a.setValue, setValid = _a.setValid, triggerSave = _a.triggerSave;
|
|
3630
|
+
// If is not initialised yet as it's just been created then set the default value
|
|
3631
|
+
useEffect(function () {
|
|
3632
|
+
if (value == null)
|
|
3633
|
+
setValue(props.defaultValue);
|
|
3634
|
+
}, [props.defaultValue, setValue, value]);
|
|
3616
3635
|
var validate = useCallback(function (value) {
|
|
3636
|
+
if (value == null)
|
|
3637
|
+
return null;
|
|
3638
|
+
// This can happen because subcomponent is invoked without type safety
|
|
3639
|
+
if (typeof value !== "string") {
|
|
3640
|
+
console.error("Value is not a string", value);
|
|
3641
|
+
}
|
|
3617
3642
|
if (props.required && value.length === 0) {
|
|
3618
3643
|
return "Some text is required";
|
|
3619
3644
|
}
|
|
3620
|
-
if (props.
|
|
3621
|
-
return "Text must be no longer than ".concat(props.
|
|
3645
|
+
if (props.maxLength && value.length > props.maxLength) {
|
|
3646
|
+
return "Text must be no longer than ".concat(props.maxLength, " characters");
|
|
3622
3647
|
}
|
|
3623
3648
|
if (props.validate) {
|
|
3624
3649
|
return props.validate(value);
|
|
@@ -3626,7 +3651,7 @@ var GridSubComponentTextArea = function (props) {
|
|
|
3626
3651
|
return null;
|
|
3627
3652
|
}, [props]);
|
|
3628
3653
|
useEffect(function () {
|
|
3629
|
-
setValid(validate(value) == null);
|
|
3654
|
+
setValid(value != null && validate(value) == null);
|
|
3630
3655
|
}, [setValid, validate, value]);
|
|
3631
3656
|
return (jsx("div", __assign({ className: "FreeTextInput LuiDeprecatedForms" }, { children: jsx(TextInputFormatted, { className: "free-text-input", value: value, onMouseEnter: function (e) {
|
|
3632
3657
|
if (document.activeElement != e.currentTarget) {
|