@linzjs/step-ag-grid 6.1.1 → 7.0.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.css +12 -2
- package/dist/index.js +378 -203
- package/dist/index.js.map +1 -1
- package/dist/src/components/GridPopoverHook.d.ts +1 -1
- package/dist/src/components/gridForm/GridFormMultiSelect.d.ts +17 -12
- package/dist/src/components/gridPopoverEdit/GridPopoutEditMultiSelect.d.ts +1 -1
- package/dist/src/contexts/GridSubComponentContext.d.ts +1 -0
- package/dist/src/lui/ActionButton.d.ts +4 -2
- package/dist/src/lui/FormError.d.ts +2 -1
- package/dist/src/lui/TextAreaInput.d.ts +1 -1
- package/dist/src/lui/TextInputFormatted.d.ts +1 -1
- package/dist/src/react-menu3/utils/utils.d.ts +1 -0
- package/dist/src/utils/textMatcher.d.ts +13 -0
- package/dist/src/utils/textValidator.d.ts +3 -2
- package/dist/src/utils/util.d.ts +2 -1
- package/dist/step-ag-grid.esm.js +379 -205
- package/dist/step-ag-grid.esm.js.map +1 -1
- package/package.json +9 -8
- package/src/components/GridPopoverHook.tsx +7 -1
- package/src/components/gridForm/GridFormDropDown.tsx +1 -0
- package/src/components/gridForm/GridFormMultiSelect.tsx +290 -188
- package/src/components/gridForm/GridFormPopoverMenu.tsx +1 -0
- package/src/components/gridForm/GridFormSubComponentTextArea.tsx +2 -2
- package/src/components/gridForm/GridFormSubComponentTextInput.tsx +3 -5
- package/src/components/gridForm/GridFormTextArea.tsx +13 -13
- package/src/components/gridForm/GridFormTextInput.tsx +3 -8
- package/src/components/gridPopoverEdit/GridPopoutEditMultiSelect.ts +3 -3
- package/src/contexts/GridSubComponentContext.ts +2 -0
- package/src/lui/ActionButton.scss +10 -0
- package/src/lui/ActionButton.tsx +36 -10
- package/src/lui/FormError.scss +7 -0
- package/src/lui/FormError.tsx +4 -13
- package/src/lui/TextAreaInput.tsx +1 -1
- package/src/lui/TextInputFormatted.tsx +1 -1
- package/src/react-menu3/components/ControlledMenu.tsx +3 -2
- package/src/react-menu3/components/MenuList.tsx +2 -12
- package/src/react-menu3/hooks/useItems.ts +5 -2
- package/src/react-menu3/utils/utils.ts +15 -0
- package/src/stories/components/ActionButton.stories.tsx +11 -0
- package/src/stories/grid/FormTest.tsx +1 -1
- package/src/stories/grid/GridPopoutEditMultiSelect.stories.tsx +93 -17
- package/src/styles/Grid.scss +12 -0
- package/src/styles/lui-overrides.scss +0 -2
- package/src/utils/textMatcher.ts +31 -0
- package/src/utils/textValidator.ts +6 -3
- package/src/utils/util.ts +6 -7
|
@@ -1,22 +1,25 @@
|
|
|
1
1
|
import { GridBaseRow } from "../components/Grid";
|
|
2
|
+
import { stringByteLengthIsInvalid } from "./util";
|
|
2
3
|
|
|
3
4
|
export interface TextInputValidatorProps<RowType extends GridBaseRow> {
|
|
4
5
|
required?: boolean;
|
|
5
6
|
maxLength?: number;
|
|
6
7
|
maxBytes?: number;
|
|
7
|
-
invalid?: (value: string, data: RowType) => string | null;
|
|
8
|
+
invalid?: (value: string, data: RowType, context: any) => JSX.Element | string | null;
|
|
8
9
|
}
|
|
9
10
|
|
|
10
11
|
export const TextInputValidator = <RowType extends GridBaseRow>(
|
|
11
12
|
props: TextInputValidatorProps<RowType>,
|
|
12
13
|
value: string | null,
|
|
13
14
|
data: RowType,
|
|
15
|
+
context: any,
|
|
14
16
|
) => {
|
|
15
17
|
if (value == null) return null;
|
|
16
18
|
|
|
17
19
|
// This can happen because subcomponent is invoked without type safety
|
|
18
20
|
if (typeof value !== "string") {
|
|
19
21
|
console.error("Value is not a string", value);
|
|
22
|
+
return null;
|
|
20
23
|
}
|
|
21
24
|
if (props.required && value.length === 0) {
|
|
22
25
|
return `Some text is required`;
|
|
@@ -24,11 +27,11 @@ export const TextInputValidator = <RowType extends GridBaseRow>(
|
|
|
24
27
|
if (props.maxLength && value.length > props.maxLength) {
|
|
25
28
|
return `Text must be no longer than ${props.maxLength} characters`;
|
|
26
29
|
}
|
|
27
|
-
if (props.maxBytes &&
|
|
30
|
+
if (props.maxBytes && stringByteLengthIsInvalid(value, props.maxBytes)) {
|
|
28
31
|
return `Text must be no longer than ${props.maxLength} bytes`;
|
|
29
32
|
}
|
|
30
33
|
if (props.invalid) {
|
|
31
|
-
return props.invalid(value, data);
|
|
34
|
+
return props.invalid(value, data, context);
|
|
32
35
|
}
|
|
33
36
|
return null;
|
|
34
37
|
};
|
package/src/utils/util.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { isEmpty
|
|
1
|
+
import { isEmpty, negate } from "lodash-es";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
export const isNotEmpty = (obj: Set<any> | Map<any, any> | Record<any, any> | any[] | undefined): boolean =>
|
|
5
|
-
!_isEmpty(obj);
|
|
3
|
+
export const isNotEmpty = negate(isEmpty);
|
|
6
4
|
|
|
7
5
|
export const wait = (timeoutMs: number) =>
|
|
8
6
|
new Promise<(string | null)[]>((resolve) => {
|
|
@@ -15,13 +13,14 @@ export const isFloat = (value: string) => {
|
|
|
15
13
|
};
|
|
16
14
|
|
|
17
15
|
export const hasParentClass = function (className: string, child: Node) {
|
|
18
|
-
let node: Node | null = child;
|
|
19
|
-
while (node) {
|
|
16
|
+
for (let node: Node | null = child; node; node = node.parentNode) {
|
|
20
17
|
// When nodes are in portals they aren't type node anymore hence treating it as any here
|
|
21
18
|
if ((node as any).classList && (node as any).classList.contains(className)) {
|
|
22
19
|
return true;
|
|
23
20
|
}
|
|
24
|
-
node = node.parentNode;
|
|
25
21
|
}
|
|
26
22
|
return false;
|
|
27
23
|
};
|
|
24
|
+
|
|
25
|
+
export const stringByteLengthIsInvalid = (str: string, maxBytes: number) =>
|
|
26
|
+
new TextEncoder().encode(str).length > maxBytes;
|