@linzjs/step-ag-grid 2.3.1 → 2.4.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/dist/index.js +95 -16
- package/dist/index.js.map +1 -1
- package/dist/src/components/GridSubComponentTextArea.d.ts +4 -4
- package/dist/src/components/gridForm/GridFormDropDown.d.ts +2 -0
- package/dist/src/components/gridForm/GridFormSubComponentTextInput.d.ts +7 -0
- 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/src/index.d.ts +1 -0
- package/dist/step-ag-grid.esm.js +95 -17
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/GridSubComponentTextArea.tsx +22 -10
- package/src/components/gridForm/GridFormDropDown.tsx +55 -11
- package/src/components/gridForm/GridFormMultiSelect.tsx +19 -15
- package/src/components/gridForm/GridFormSubComponentTextInput.tsx +34 -0
- 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/index.ts +1 -0
- 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 +42 -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;
|
|
@@ -5,11 +5,13 @@ import { CellEditorCommon } from "../GridCell";
|
|
|
5
5
|
export interface GridPopoutEditDropDownSelectedItem<RowType, ValueType> {
|
|
6
6
|
selectedRows: RowType[];
|
|
7
7
|
value: ValueType;
|
|
8
|
+
subComponentValue?: ValueType;
|
|
8
9
|
}
|
|
9
10
|
interface FinalSelectOption<ValueType> {
|
|
10
11
|
value: ValueType;
|
|
11
12
|
label?: JSX.Element | string;
|
|
12
13
|
disabled?: boolean | string;
|
|
14
|
+
subComponent?: (props: any, ref: any) => any;
|
|
13
15
|
}
|
|
14
16
|
export declare const MenuSeparatorString = "_____MENU_SEPARATOR_____";
|
|
15
17
|
export declare const MenuSeparator: Readonly<{
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export interface GridFormSubComponentTextInput {
|
|
3
|
+
setValue: (value: string) => void;
|
|
4
|
+
keyDown: (key: string) => void;
|
|
5
|
+
placeholder?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const GridFormSubComponentTextInput: ({ keyDown, placeholder, setValue }: GridFormSubComponentTextInput) => 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/src/index.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ export { GridPopoverEditDropDown } from "./components/gridPopoverEdit/GridPopove
|
|
|
23
23
|
export { GridPopoverMessage } from "./components/gridPopoverEdit/GridPopoverMessage";
|
|
24
24
|
export { GridPopoverTextArea } from "./components/gridPopoverEdit/GridPopoverTextArea";
|
|
25
25
|
export { GridPopoverTextInput } from "./components/gridPopoverEdit/GridPopoverTextInput";
|
|
26
|
+
export { GridFormSubComponentTextInput } from "./components/gridForm/GridFormSubComponentTextInput";
|
|
26
27
|
export * from "./components/gridForm/GridFormDropDown";
|
|
27
28
|
export * from "./components/gridForm/GridFormMultiSelect";
|
|
28
29
|
export * from "./components/gridForm/GridFormPopoutMenu";
|
package/dist/step-ag-grid.esm.js
CHANGED
|
@@ -2838,7 +2838,8 @@ var GridFormDropDown = function (_props) {
|
|
|
2838
2838
|
var _c = useState([]), filteredValues = _c[0], setFilteredValues = _c[1];
|
|
2839
2839
|
var optionsInitialising = useRef(false);
|
|
2840
2840
|
var _d = useState(null), options = _d[0], setOptions = _d[1];
|
|
2841
|
-
var
|
|
2841
|
+
var _e = useState([]), subComponentValues = _e[0], setSubComponentValues = _e[1];
|
|
2842
|
+
var selectItemHandler = useCallback(function (value, subComponentValue) { return __awaiter(void 0, void 0, void 0, function () {
|
|
2842
2843
|
var field;
|
|
2843
2844
|
return __generator(this, function (_a) {
|
|
2844
2845
|
switch (_a.label) {
|
|
@@ -2852,7 +2853,7 @@ var GridFormDropDown = function (_props) {
|
|
|
2852
2853
|
hasChanged = selectedRows.some(function (row) { return row[field] !== value; });
|
|
2853
2854
|
if (!hasChanged) return [3 /*break*/, 3];
|
|
2854
2855
|
if (!props.onSelectedItem) return [3 /*break*/, 2];
|
|
2855
|
-
return [4 /*yield*/, props.onSelectedItem({ selectedRows: selectedRows, value: value })];
|
|
2856
|
+
return [4 /*yield*/, props.onSelectedItem({ selectedRows: selectedRows, value: value, subComponentValue: subComponentValue })];
|
|
2856
2857
|
case 1:
|
|
2857
2858
|
_a.sent();
|
|
2858
2859
|
return [3 /*break*/, 3];
|
|
@@ -2994,10 +2995,59 @@ var GridFormDropDown = function (_props) {
|
|
|
2994
2995
|
return (jsx("div", __assign({ style: { display: "flex", width: "100%" } }, { children: jsx("input", { autoFocus: true, className: "free-text-input", style: { border: "0px" }, ref: ref, type: "text", placeholder: (_b = props.filterPlaceholder) !== null && _b !== void 0 ? _b : "Placeholder", "data-testid": "filteredMenu-free-text-input", defaultValue: filter, onChange: function (e) { return setFilter(e.target.value.toLowerCase()); }, onKeyDown: function (e) { return onFilterKeyDown(e); } }) })));
|
|
2995
2996
|
} })), jsx(MenuDivider, {}, "$$divider_filter")] }))), jsx(ComponentLoadingWrapper, __assign({ loading: !options, className: "GridFormDropDown-options" }, { children: jsxs(Fragment$1, { children: [options && options.length == (filteredValues === null || filteredValues === void 0 ? void 0 : filteredValues.length) && jsx(MenuItem, { children: "[Empty]" }), options === null || options === void 0 ? void 0 : options.map(function (item, index) {
|
|
2996
2997
|
var _a;
|
|
2997
|
-
return item.value === MenuSeparatorString ? (jsx(MenuDivider, {}, "$$divider_".concat(index))) : item.value === MenuHeaderString ? (jsx(MenuHeader, { children: item.label })) : filteredValues.includes(item.value) ? null : (jsx(MenuItem, __assign({ disabled: !!item.disabled, title: item.disabled && typeof item.disabled !== "boolean" ? item.disabled : "", value: item.value, onClick: function () {
|
|
2998
|
+
return item.value === MenuSeparatorString ? (jsx(MenuDivider, {}, "$$divider_".concat(index))) : item.value === MenuHeaderString ? (jsx(MenuHeader, { children: item.label })) : filteredValues.includes(item.value) ? null : (jsx(Fragment$1, { children: !item.subComponent ? (jsx(MenuItem, __assign({ disabled: !!item.disabled, title: item.disabled && typeof item.disabled !== "boolean" ? item.disabled : "", value: item.value, onClick: function () {
|
|
2999
|
+
selectItemHandler(item.value);
|
|
3000
|
+
} }, { children: (_a = item.label) !== null && _a !== void 0 ? _a : (item.value == null ? "<".concat(item.value, ">") : "".concat(item.value)) }), "".concat(props.field, "-").concat(index))) : (jsx(FocusableItem, __assign({ className: "LuiDeprecatedForms" }, { children: function (ref) {
|
|
3001
|
+
return item.subComponent &&
|
|
3002
|
+
item.subComponent({
|
|
3003
|
+
setValue: function (value) {
|
|
3004
|
+
var localSubComponentValues = __spreadArray([], subComponentValues, true);
|
|
3005
|
+
var subComponentValueIndex = localSubComponentValues.findIndex(function (_a) {
|
|
3006
|
+
var optionValue = _a.optionValue;
|
|
3007
|
+
return optionValue === item.value;
|
|
3008
|
+
});
|
|
3009
|
+
if (subComponentValueIndex !== -1) {
|
|
3010
|
+
localSubComponentValues[subComponentValueIndex].subComponentValue = value;
|
|
3011
|
+
}
|
|
3012
|
+
else {
|
|
3013
|
+
localSubComponentValues.push({
|
|
3014
|
+
subComponentValue: value,
|
|
3015
|
+
optionValue: item.value
|
|
3016
|
+
});
|
|
3017
|
+
}
|
|
3018
|
+
setSubComponentValues(localSubComponentValues);
|
|
3019
|
+
},
|
|
3020
|
+
keyDown: function (key) {
|
|
3021
|
+
var subComponentItem = subComponentValues.find(function (_a) {
|
|
3022
|
+
var optionValue = _a.optionValue;
|
|
3023
|
+
return optionValue === item.value;
|
|
3024
|
+
});
|
|
3025
|
+
if (key === "Enter" && subComponentItem) {
|
|
3026
|
+
selectItemHandler(item.value, subComponentItem.subComponentValue);
|
|
3027
|
+
ref.closeMenu();
|
|
3028
|
+
}
|
|
3029
|
+
}
|
|
3030
|
+
}, ref);
|
|
3031
|
+
} }), "".concat(props.field, "-").concat(index, "_subcomponent"))) }));
|
|
2998
3032
|
})] }) }))] }));
|
|
2999
3033
|
};
|
|
3000
3034
|
|
|
3035
|
+
var GridSubComponentContext = createContext({
|
|
3036
|
+
value: "GridSubComponentContext value no context",
|
|
3037
|
+
setValue: function () {
|
|
3038
|
+
console.error("GridSubComponentContext setValue no context");
|
|
3039
|
+
},
|
|
3040
|
+
setValid: function () {
|
|
3041
|
+
console.error("GridSubComponentContext setValid no context");
|
|
3042
|
+
},
|
|
3043
|
+
triggerSave: function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
3044
|
+
return __generator(this, function (_a) {
|
|
3045
|
+
console.error("GridSubComponentContext triggerSave no context");
|
|
3046
|
+
return [2 /*return*/];
|
|
3047
|
+
});
|
|
3048
|
+
}); }
|
|
3049
|
+
});
|
|
3050
|
+
|
|
3001
3051
|
var GridFormMultiSelect = function (props) {
|
|
3002
3052
|
var selectedRows = props.selectedRows;
|
|
3003
3053
|
var initialiseValues = useMemo(function () { return props.initialSelectedValues && props.initialSelectedValues(selectedRows); }, [props, selectedRows]);
|
|
@@ -3124,10 +3174,8 @@ var GridFormMultiSelect = function (props) {
|
|
|
3124
3174
|
}
|
|
3125
3175
|
}, onChange: function () {
|
|
3126
3176
|
/*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,
|
|
3177
|
+
} }) }), "".concat(index)), selectedValues.includes(item.value) && item.subComponent && (jsx(FocusableItem, __assign({ className: "LuiDeprecatedForms" }, { children: function (_) {
|
|
3178
|
+
return item.subComponent && (jsx(GridSubComponentContext.Provider, __assign({ value: {
|
|
3131
3179
|
value: subSelectedValues["".concat(item.value)],
|
|
3132
3180
|
setValue: function (value) {
|
|
3133
3181
|
subSelectedValues["".concat(item.value)] = value;
|
|
@@ -3137,7 +3185,7 @@ var GridFormMultiSelect = function (props) {
|
|
|
3137
3185
|
subComponentIsValid.current["".concat(item.value)] = valid;
|
|
3138
3186
|
},
|
|
3139
3187
|
triggerSave: triggerSave
|
|
3140
|
-
});
|
|
3188
|
+
} }, { children: jsx(item.subComponent, {}) })));
|
|
3141
3189
|
} }), "".concat(item.value, "_subcomponent")))] }, "".concat(index)));
|
|
3142
3190
|
}) }))] }) })));
|
|
3143
3191
|
};
|
|
@@ -3513,8 +3561,8 @@ var GridFormTextArea = function (_props) {
|
|
|
3513
3561
|
if (props.required && value.length == 0) {
|
|
3514
3562
|
return "Some text is required";
|
|
3515
3563
|
}
|
|
3516
|
-
if (props.
|
|
3517
|
-
return "Text must be no longer than ".concat(props.
|
|
3564
|
+
if (props.maxLength && value.length > props.maxLength) {
|
|
3565
|
+
return "Text must be no longer than ".concat(props.maxLength, " characters");
|
|
3518
3566
|
}
|
|
3519
3567
|
if (props.validate) {
|
|
3520
3568
|
return props.validate(value);
|
|
@@ -3560,8 +3608,8 @@ var GridFormTextInput = function (_props) {
|
|
|
3560
3608
|
if (props.required && trimmedValue.length == 0) {
|
|
3561
3609
|
return "Some text is required";
|
|
3562
3610
|
}
|
|
3563
|
-
if (props.
|
|
3564
|
-
return "Text must be no longer than ".concat(props.
|
|
3611
|
+
if (props.maxLength && trimmedValue.length > props.maxLength) {
|
|
3612
|
+
return "Text must be no longer than ".concat(props.maxLength, " characters");
|
|
3565
3613
|
}
|
|
3566
3614
|
if (props.validate) {
|
|
3567
3615
|
return props.validate(trimmedValue, props.data);
|
|
@@ -3611,14 +3659,44 @@ var GridPopoverTextInput = function (colDef, params) {
|
|
|
3611
3659
|
return GridCell(colDef, __assign({ editor: GridFormTextInput }, params));
|
|
3612
3660
|
};
|
|
3613
3661
|
|
|
3662
|
+
var GridFormSubComponentTextInput = function (_a) {
|
|
3663
|
+
var keyDown = _a.keyDown, placeholder = _a.placeholder, setValue = _a.setValue;
|
|
3664
|
+
var placeholderText = placeholder || "Other...";
|
|
3665
|
+
var _b = useState(""), inputValue = _b[0], setInputValue = _b[1];
|
|
3666
|
+
return (jsx(Fragment$1, { children: jsx(TextInputFormatted, { value: inputValue, onChange: function (e) {
|
|
3667
|
+
var value = e.target.value;
|
|
3668
|
+
setValue(value);
|
|
3669
|
+
setInputValue(value);
|
|
3670
|
+
}, inputProps: {
|
|
3671
|
+
onKeyDown: function (k) { return keyDown(k.key); },
|
|
3672
|
+
placeholder: placeholderText,
|
|
3673
|
+
onMouseEnter: function (e) {
|
|
3674
|
+
if (document.activeElement != e.currentTarget) {
|
|
3675
|
+
e.currentTarget.focus();
|
|
3676
|
+
}
|
|
3677
|
+
}
|
|
3678
|
+
} }) }));
|
|
3679
|
+
};
|
|
3680
|
+
|
|
3614
3681
|
var GridSubComponentTextArea = function (props) {
|
|
3615
|
-
var value =
|
|
3682
|
+
var _a = useContext(GridSubComponentContext), value = _a.value, setValue = _a.setValue, setValid = _a.setValid, triggerSave = _a.triggerSave;
|
|
3683
|
+
// If is not initialised yet as it's just been created then set the default value
|
|
3684
|
+
useEffect(function () {
|
|
3685
|
+
if (value == null)
|
|
3686
|
+
setValue(props.defaultValue);
|
|
3687
|
+
}, [props.defaultValue, setValue, value]);
|
|
3616
3688
|
var validate = useCallback(function (value) {
|
|
3689
|
+
if (value == null)
|
|
3690
|
+
return null;
|
|
3691
|
+
// This can happen because subcomponent is invoked without type safety
|
|
3692
|
+
if (typeof value !== "string") {
|
|
3693
|
+
console.error("Value is not a string", value);
|
|
3694
|
+
}
|
|
3617
3695
|
if (props.required && value.length === 0) {
|
|
3618
3696
|
return "Some text is required";
|
|
3619
3697
|
}
|
|
3620
|
-
if (props.
|
|
3621
|
-
return "Text must be no longer than ".concat(props.
|
|
3698
|
+
if (props.maxLength && value.length > props.maxLength) {
|
|
3699
|
+
return "Text must be no longer than ".concat(props.maxLength, " characters");
|
|
3622
3700
|
}
|
|
3623
3701
|
if (props.validate) {
|
|
3624
3702
|
return props.validate(value);
|
|
@@ -3626,7 +3704,7 @@ var GridSubComponentTextArea = function (props) {
|
|
|
3626
3704
|
return null;
|
|
3627
3705
|
}, [props]);
|
|
3628
3706
|
useEffect(function () {
|
|
3629
|
-
setValid(validate(value) == null);
|
|
3707
|
+
setValid(value != null && validate(value) == null);
|
|
3630
3708
|
}, [setValid, validate, value]);
|
|
3631
3709
|
return (jsx("div", __assign({ className: "FreeTextInput LuiDeprecatedForms" }, { children: jsx(TextInputFormatted, { className: "free-text-input", value: value, onMouseEnter: function (e) {
|
|
3632
3710
|
if (document.activeElement != e.currentTarget) {
|
|
@@ -3733,5 +3811,5 @@ var ActionButton = function (_a) {
|
|
|
3733
3811
|
_b) })) : (jsx(LuiIcon, { name: icon, alt: name, size: size })), jsxs("span", __assign({ className: "ActionButton-minimalArea" }, { children: [jsx("span", __assign({ className: "ActionButton-minimalAreaDisplay" }, { children: (_c = (localInProgress ? inProgressName : name)) !== null && _c !== void 0 ? _c : name })), jsx("span", __assign({ className: "ActionButton-minimalAreaExpand" }, { children: name }))] }))] })));
|
|
3734
3812
|
};
|
|
3735
3813
|
|
|
3736
|
-
export { ActionButton, ComponentLoadingWrapper, ControlledMenu, FocusableItem, GenericCellEditorComponent, GenericMultiEditCellClass, Grid, GridCell, GridCellRenderer, GridContext, GridContextProvider, GridFormDropDown, GridFormMultiSelect, GridFormPopoutMenu, GridHeaderSelect, GridIcon, GridLoadableCell, GridPopoutEditMultiSelect, GridPopoverEditBearing, GridPopoverEditBearingCorrection, GridPopoverEditDropDown, GridPopoverMenu, GridPopoverMessage, GridPopoverTextArea, GridPopoverTextInput, GridRenderPopoutMenuCell, GridRendererGenericCell, GridSubComponentTextArea, GridUpdatingContext, GridUpdatingContextProvider, Menu, MenuButton, MenuDivider, MenuGroup, MenuHeader, MenuHeaderItem, MenuHeaderString, MenuItem, MenuRadioGroup, MenuSeparator, MenuSeparatorString, PopoutMenuSeparator, SubMenu, TextAreaInput, TextInputFormatted, bearingCorrectionValueFormatter, bearingNumberParser, bearingStringValidator, bearingValueFormatter, convertDDToDMS, hasParentClass, isFloat, isNotEmpty, useGridPopoverHook, useMenuState, usePostSortRowsHook, wait };
|
|
3814
|
+
export { ActionButton, ComponentLoadingWrapper, ControlledMenu, FocusableItem, GenericCellEditorComponent, GenericMultiEditCellClass, Grid, GridCell, GridCellRenderer, GridContext, GridContextProvider, GridFormDropDown, GridFormMultiSelect, GridFormPopoutMenu, GridFormSubComponentTextInput, GridHeaderSelect, GridIcon, GridLoadableCell, GridPopoutEditMultiSelect, GridPopoverEditBearing, GridPopoverEditBearingCorrection, GridPopoverEditDropDown, GridPopoverMenu, GridPopoverMessage, GridPopoverTextArea, GridPopoverTextInput, GridRenderPopoutMenuCell, GridRendererGenericCell, GridSubComponentTextArea, GridUpdatingContext, GridUpdatingContextProvider, Menu, MenuButton, MenuDivider, MenuGroup, MenuHeader, MenuHeaderItem, MenuHeaderString, MenuItem, MenuRadioGroup, MenuSeparator, MenuSeparatorString, PopoutMenuSeparator, SubMenu, TextAreaInput, TextInputFormatted, bearingCorrectionValueFormatter, bearingNumberParser, bearingStringValidator, bearingValueFormatter, convertDDToDMS, hasParentClass, isFloat, isNotEmpty, useGridPopoverHook, useMenuState, usePostSortRowsHook, wait };
|
|
3737
3815
|
//# sourceMappingURL=step-ag-grid.esm.js.map
|