@geotab/zenith 3.1.1-beta.2 → 3.1.1-beta.4

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.
@@ -7,6 +7,7 @@ export type TLabelAlign = "left" | "top";
7
7
  interface IFormFieldBase extends PropsWithChildren {
8
8
  className?: string;
9
9
  inputClassName?: string;
10
+ wrapperClassName?: string;
10
11
  error?: string;
11
12
  assistive?: string;
12
13
  counter?: string;
@@ -33,6 +33,7 @@ const useLoading_1 = require("./hooks/useLoading");
33
33
  const useReadonly_1 = require("./hooks/useReadonly");
34
34
  const formFieldWithLabel_1 = require("./components/formFieldWithLabel");
35
35
  const formFieldWithoutLabel_1 = require("./components/formFieldWithoutLabel");
36
+ const useClasses_1 = require("./hooks/useClasses");
36
37
  // eslint-disable-next-line @typescript-eslint/naming-convention
37
38
  const FormField = function FormFieldInner(WrappedComponent) {
38
39
  // eslint-disable-next-line complexity
@@ -51,11 +52,12 @@ const FormField = function FormFieldInner(WrappedComponent) {
51
52
  // TODO: add tests
52
53
  const banner = errorBanner || bannerComp;
53
54
  const isInputContainerHidden = isReadonly && props.isError;
54
- const { className, inputClassName, counter } = props, rest = __rest(props, ["className", "inputClassName", "counter"]);
55
+ const { inputClassName, counter } = props, rest = __rest(props, ["inputClassName", "counter"]);
55
56
  const driveTextClass = (0, useDriveClassName_1.useDriveClassName)("zen-form-field__text");
57
+ const { componentClasses, wrapperClasses } = (0, useClasses_1.useClasses)(props, WrappedComponent);
56
58
  // TODO: Banner? Only it or assistive text?
57
59
  const showAdditionalInfo = (error || assistive || counter) && !isReadonly;
58
- const componentClassName = (0, classNames_1.classNames)(["zen-form-field__input", inputClassName || ""]);
60
+ const componentClassName = (0, classNames_1.classNames)(["zen-form-field__input", componentClasses || ""]);
59
61
  const ariaDescribedBy = `${assistiveId} ${trailingId} ${errorId} ${bannerId}`.trim();
60
62
  const localId = (0, react_1.useId)();
61
63
  const id = props.id || localId;
@@ -73,7 +75,7 @@ const FormField = function FormFieldInner(WrappedComponent) {
73
75
  isMobile ? "zen-form-field--mobile" : "",
74
76
  banner ? "zen-form-field--with-banner" : "",
75
77
  !props.label ? "" : props.labelAlign ? `zen-form-field--label-${props.labelAlign}` : "zen-form-field--label-left",
76
- className || ""
78
+ wrapperClasses || ""
77
79
  ]);
78
80
  if (isLoading) {
79
81
  const height = WrappedComponent.displayName === textareaRaw_1.TextareaRaw.displayName ? 110 : 32;
@@ -0,0 +1,8 @@
1
+ import React from "react";
2
+ import { TFormFieldComponentProps } from "../formField";
3
+ interface IUseClasses {
4
+ wrapperClasses?: string;
5
+ componentClasses?: string;
6
+ }
7
+ export declare const useClasses: <T>(props: TFormFieldComponentProps<T>, wrapperComponent: React.FC<T>) => IUseClasses;
8
+ export {};
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useClasses = void 0;
4
+ const oldFormFieldComponents = [
5
+ "SearchInputRaw",
6
+ "SelectRaw",
7
+ "StepperRaw",
8
+ "TextAreaInput",
9
+ "TextInputRaw"
10
+ ];
11
+ // eslint-disable-next-line @typescript-eslint/comma-dangle
12
+ const useClasses = (props, wrapperComponent) => {
13
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
14
+ if (oldFormFieldComponents.includes((wrapperComponent === null || wrapperComponent === void 0 ? void 0 : wrapperComponent.displayName) || "") || oldFormFieldComponents.includes((wrapperComponent === null || wrapperComponent === void 0 ? void 0 : wrapperComponent.name) || "")) {
15
+ return {
16
+ wrapperClasses: props.wrapperClassName || props.className || "",
17
+ componentClasses: props.inputClassName || ""
18
+ };
19
+ }
20
+ return {
21
+ wrapperClasses: props.wrapperClassName || "",
22
+ componentClasses: props.inputClassName || props.className || ""
23
+ };
24
+ };
25
+ exports.useClasses = useClasses;
@@ -1,7 +1,8 @@
1
+ import { IEntityWithId } from "../commonHelpers/entity";
1
2
  import { IFilterState as IFilterStateRaw, TFilterVal as TFilterValRaw, ITypedHash as ITypedHashRaw, IAdvancedEntitiesNavigatorDialog as IAdvancedEntitiesNavigatorDialogRaw, IGroupItem as IGroupItemRaw, IGroupsFilterTotalState as IGroupsFilterTotalStateRaw, FilterMenuStep, IGroupsFilterOptions as IGroupsFilterOptionsRaw, IGroupTree as IGroupTreeRaw, IColor as IColorRaw, IGroupsColorTree as IGroupsColorTreeRaw, INamedEntity as INamedEntityRaw, IGroup as IGroupRaw, ILinkedGroup as ILinkedGroupRaw, ILeafStateItem as ILeafStateItemRaw, RelationOperatorLocal as RelationOperator } from "../groupsFilterRaw/groupsFilterInterfaces";
2
- export interface IFilterState<T> extends IFilterStateRaw<T> {
3
+ export interface IFilterState<T = IEntityWithId> extends IFilterStateRaw<T> {
3
4
  }
4
- export type TFilterVal<T> = TFilterValRaw<T>;
5
+ export type TFilterVal<T = IEntityWithId> = TFilterValRaw<T>;
5
6
  export interface ITypedHash<T> extends ITypedHashRaw<T> {
6
7
  }
7
8
  export interface IAdvancedEntitiesNavigatorDialog extends IAdvancedEntitiesNavigatorDialogRaw {
@@ -25,5 +26,5 @@ export interface IGroup extends IGroupRaw {
25
26
  }
26
27
  export interface ILinkedGroup extends ILinkedGroupRaw {
27
28
  }
28
- export interface ILeafStateItem<T> extends ILeafStateItemRaw<T> {
29
+ export interface ILeafStateItem<T = IEntityWithId> extends ILeafStateItemRaw<T> {
29
30
  }
@@ -7,6 +7,7 @@ export type TLabelAlign = "left" | "top";
7
7
  interface IFormFieldBase extends PropsWithChildren {
8
8
  className?: string;
9
9
  inputClassName?: string;
10
+ wrapperClassName?: string;
10
11
  error?: string;
11
12
  assistive?: string;
12
13
  counter?: string;
@@ -30,6 +30,7 @@ import { useLoading } from "./hooks/useLoading";
30
30
  import { useReadonly } from "./hooks/useReadonly";
31
31
  import { FormFieldWithLabel } from "./components/formFieldWithLabel";
32
32
  import { FormFieldWithoutLabel } from "./components/formFieldWithoutLabel";
33
+ import { useClasses } from "./hooks/useClasses";
33
34
  // eslint-disable-next-line @typescript-eslint/naming-convention
34
35
  export const FormField = function FormFieldInner(WrappedComponent) {
35
36
  // eslint-disable-next-line complexity
@@ -48,11 +49,12 @@ export const FormField = function FormFieldInner(WrappedComponent) {
48
49
  // TODO: add tests
49
50
  const banner = errorBanner || bannerComp;
50
51
  const isInputContainerHidden = isReadonly && props.isError;
51
- const { className, inputClassName, counter } = props, rest = __rest(props, ["className", "inputClassName", "counter"]);
52
+ const { inputClassName, counter } = props, rest = __rest(props, ["inputClassName", "counter"]);
52
53
  const driveTextClass = useDriveClassName("zen-form-field__text");
54
+ const { componentClasses, wrapperClasses } = useClasses(props, WrappedComponent);
53
55
  // TODO: Banner? Only it or assistive text?
54
56
  const showAdditionalInfo = (error || assistive || counter) && !isReadonly;
55
- const componentClassName = classNames(["zen-form-field__input", inputClassName || ""]);
57
+ const componentClassName = classNames(["zen-form-field__input", componentClasses || ""]);
56
58
  const ariaDescribedBy = `${assistiveId} ${trailingId} ${errorId} ${bannerId}`.trim();
57
59
  const localId = useId();
58
60
  const id = props.id || localId;
@@ -70,7 +72,7 @@ export const FormField = function FormFieldInner(WrappedComponent) {
70
72
  isMobile ? "zen-form-field--mobile" : "",
71
73
  banner ? "zen-form-field--with-banner" : "",
72
74
  !props.label ? "" : props.labelAlign ? `zen-form-field--label-${props.labelAlign}` : "zen-form-field--label-left",
73
- className || ""
75
+ wrapperClasses || ""
74
76
  ]);
75
77
  if (isLoading) {
76
78
  const height = WrappedComponent.displayName === TextareaRaw.displayName ? 110 : 32;
@@ -0,0 +1,8 @@
1
+ import React from "react";
2
+ import { TFormFieldComponentProps } from "../formField";
3
+ interface IUseClasses {
4
+ wrapperClasses?: string;
5
+ componentClasses?: string;
6
+ }
7
+ export declare const useClasses: <T>(props: TFormFieldComponentProps<T>, wrapperComponent: React.FC<T>) => IUseClasses;
8
+ export {};
@@ -0,0 +1,21 @@
1
+ const oldFormFieldComponents = [
2
+ "SearchInputRaw",
3
+ "SelectRaw",
4
+ "StepperRaw",
5
+ "TextAreaInput",
6
+ "TextInputRaw"
7
+ ];
8
+ // eslint-disable-next-line @typescript-eslint/comma-dangle
9
+ export const useClasses = (props, wrapperComponent) => {
10
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
11
+ if (oldFormFieldComponents.includes((wrapperComponent === null || wrapperComponent === void 0 ? void 0 : wrapperComponent.displayName) || "") || oldFormFieldComponents.includes((wrapperComponent === null || wrapperComponent === void 0 ? void 0 : wrapperComponent.name) || "")) {
12
+ return {
13
+ wrapperClasses: props.wrapperClassName || props.className || "",
14
+ componentClasses: props.inputClassName || ""
15
+ };
16
+ }
17
+ return {
18
+ wrapperClasses: props.wrapperClassName || "",
19
+ componentClasses: props.inputClassName || props.className || ""
20
+ };
21
+ };
@@ -1,7 +1,8 @@
1
+ import { IEntityWithId } from "../commonHelpers/entity";
1
2
  import { IFilterState as IFilterStateRaw, TFilterVal as TFilterValRaw, ITypedHash as ITypedHashRaw, IAdvancedEntitiesNavigatorDialog as IAdvancedEntitiesNavigatorDialogRaw, IGroupItem as IGroupItemRaw, IGroupsFilterTotalState as IGroupsFilterTotalStateRaw, FilterMenuStep, IGroupsFilterOptions as IGroupsFilterOptionsRaw, IGroupTree as IGroupTreeRaw, IColor as IColorRaw, IGroupsColorTree as IGroupsColorTreeRaw, INamedEntity as INamedEntityRaw, IGroup as IGroupRaw, ILinkedGroup as ILinkedGroupRaw, ILeafStateItem as ILeafStateItemRaw, RelationOperatorLocal as RelationOperator } from "../groupsFilterRaw/groupsFilterInterfaces";
2
- export interface IFilterState<T> extends IFilterStateRaw<T> {
3
+ export interface IFilterState<T = IEntityWithId> extends IFilterStateRaw<T> {
3
4
  }
4
- export type TFilterVal<T> = TFilterValRaw<T>;
5
+ export type TFilterVal<T = IEntityWithId> = TFilterValRaw<T>;
5
6
  export interface ITypedHash<T> extends ITypedHashRaw<T> {
6
7
  }
7
8
  export interface IAdvancedEntitiesNavigatorDialog extends IAdvancedEntitiesNavigatorDialogRaw {
@@ -25,5 +26,5 @@ export interface IGroup extends IGroupRaw {
25
26
  }
26
27
  export interface ILinkedGroup extends ILinkedGroupRaw {
27
28
  }
28
- export interface ILeafStateItem<T> extends ILeafStateItemRaw<T> {
29
+ export interface ILeafStateItem<T = IEntityWithId> extends ILeafStateItemRaw<T> {
29
30
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geotab/zenith",
3
- "version": "3.1.1-beta.2",
3
+ "version": "3.1.1-beta.4",
4
4
  "description": "Zenith components library on React",
5
5
  "main": "dist/index.js",
6
6
  "types": "esm/index.d.ts",
@@ -99,6 +99,6 @@
99
99
  ]
100
100
  },
101
101
  "publishConfig": {
102
- "access": "public"
103
- }
102
+ "access": "public"
103
+ }
104
104
  }