@linzjs/step-ag-grid 2.3.1 → 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 +38 -13
- 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 +38 -13
- 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/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/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
|
@@ -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) {
|