@linzjs/step-ag-grid 6.1.0 → 7.0.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.
Files changed (44) hide show
  1. package/dist/index.css +12 -2
  2. package/dist/index.js +389 -213
  3. package/dist/index.js.map +1 -1
  4. package/dist/src/components/GridPopoverHook.d.ts +1 -1
  5. package/dist/src/components/gridForm/GridFormMultiSelect.d.ts +17 -12
  6. package/dist/src/components/gridPopoverEdit/GridPopoutEditMultiSelect.d.ts +1 -1
  7. package/dist/src/contexts/GridSubComponentContext.d.ts +1 -0
  8. package/dist/src/lui/ActionButton.d.ts +2 -1
  9. package/dist/src/lui/FormError.d.ts +2 -1
  10. package/dist/src/lui/TextAreaInput.d.ts +1 -1
  11. package/dist/src/lui/TextInputFormatted.d.ts +1 -1
  12. package/dist/src/react-menu3/utils/utils.d.ts +1 -0
  13. package/dist/src/utils/textMatcher.d.ts +13 -0
  14. package/dist/src/utils/textValidator.d.ts +3 -2
  15. package/dist/src/utils/util.d.ts +2 -1
  16. package/dist/step-ag-grid.esm.js +390 -215
  17. package/dist/step-ag-grid.esm.js.map +1 -1
  18. package/package.json +9 -8
  19. package/src/components/GridPopoverHook.tsx +7 -1
  20. package/src/components/gridForm/GridFormDropDown.tsx +15 -10
  21. package/src/components/gridForm/GridFormMultiSelect.tsx +290 -188
  22. package/src/components/gridForm/GridFormPopoverMenu.tsx +1 -0
  23. package/src/components/gridForm/GridFormSubComponentTextArea.tsx +2 -2
  24. package/src/components/gridForm/GridFormSubComponentTextInput.tsx +3 -5
  25. package/src/components/gridForm/GridFormTextArea.tsx +13 -13
  26. package/src/components/gridForm/GridFormTextInput.tsx +3 -8
  27. package/src/components/gridPopoverEdit/GridPopoutEditMultiSelect.ts +3 -3
  28. package/src/contexts/GridSubComponentContext.ts +2 -0
  29. package/src/lui/ActionButton.tsx +26 -8
  30. package/src/lui/FormError.scss +7 -0
  31. package/src/lui/FormError.tsx +4 -13
  32. package/src/lui/TextAreaInput.tsx +1 -1
  33. package/src/lui/TextInputFormatted.tsx +1 -1
  34. package/src/react-menu3/components/ControlledMenu.tsx +3 -2
  35. package/src/react-menu3/components/MenuList.tsx +2 -12
  36. package/src/react-menu3/hooks/useItems.ts +5 -2
  37. package/src/react-menu3/utils/utils.ts +15 -0
  38. package/src/stories/components/ActionButton.stories.tsx +9 -0
  39. package/src/stories/grid/GridPopoutEditMultiSelect.stories.tsx +93 -17
  40. package/src/styles/Grid.scss +12 -0
  41. package/src/styles/lui-overrides.scss +0 -2
  42. package/src/utils/textMatcher.ts +31 -0
  43. package/src/utils/textValidator.ts +6 -3
  44. 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 && new TextEncoder().encode(value).length > 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 as _isEmpty } from "lodash-es";
1
+ import { isEmpty, negate } from "lodash-es";
2
2
 
3
- // Typed version of lodash !isEmpty
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;