Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIO-9002: fix spelling error and minor linting #168

Merged
merged 1 commit into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/process/clearHidden.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const clearHiddenProcess: ProcessorFnSync<ClearHiddenScope> = (context) =

const shouldClearValueWhenHidden = !component.hasOwnProperty('clearOnHide') || component.clearOnHide;

if (shouldClearValueWhenHidden && (isConditionallyHidden || component.hidden || component.ephermalState?.conditionallyHidden)) {
if (shouldClearValueWhenHidden && (isConditionallyHidden || component.hidden || component.ephemeralState?.conditionallyHidden)) {
unset(data, path);
scope.clearHidden[path] = true;
}
Expand Down
5 changes: 2 additions & 3 deletions src/process/conditions/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { reset } from 'fetch-mock';
import { ProcessorFn, ProcessorFnSync, ConditionsScope, ProcessorInfo, ConditionsContext, SimpleConditional, JSONConditional, LegacyConditional, SimpleConditionalConditions, Component, NestedComponent, FilterScope } from 'types';
import { registerEphermalState, resetEphermalState } from 'utils';
import { registerEphemeralState } from 'utils';
import {
checkCustomConditional,
checkJsonConditional,
Expand Down Expand Up @@ -95,7 +94,7 @@ export const conditionalProcess = (context: ConditionsContext, isHidden: Conditi

conditionalComp.conditionallyHidden = conditionalComp.conditionallyHidden || isHidden(context) === true;
if (conditionalComp.conditionallyHidden) {
registerEphermalState(context.component, 'conditionallyHidden', true);
registerEphemeralState(context.component, 'conditionallyHidden', true);
}
};

Expand Down
6 changes: 3 additions & 3 deletions src/process/hideChildren.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
ConditionsScope,
ProcessorFn,
} from "types";
import { registerEphermalState } from "utils";
import { registerEphemeralState } from "utils";

/**
* This processor function checks components for the `hidden` property and, if children are present, sets them to hidden as well.
Expand All @@ -22,8 +22,8 @@ export const hideChildrenProcessor: ProcessorFnSync<ConditionsScope> = (context)
scope.conditionals = [];
}

if (isConditionallyHidden || component.hidden || parent?.ephermalState?.conditionallyHidden) {
registerEphermalState(component, 'conditionallyHidden', true);
if (isConditionallyHidden || component.hidden || parent?.ephemeralState?.conditionallyHidden) {
registerEphemeralState(component, 'conditionallyHidden', true);
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/process/processOne.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { get, set } from "lodash";
import { Component, ProcessorsContext, ProcessorType } from "types";
import { getComponentKey } from "utils/formUtil";
import { resetEphermalState } from "utils";
import { resetEphemeralState } from "utils";

export function dataValue(component: Component, row: any) {
const key = getComponentKey(component);
Expand All @@ -22,8 +22,8 @@ export async function processOne<ProcessorScope>(context: ProcessorsContext<Proc
}
});
}
// If the component has ephermal state, then we need to reset the ephermal state in case this is e.g. a data grid, in which each row needs to be validated independently
resetEphermalState(component);
// If the component has ephemeral state, then we need to reset the ephemeral state in case this is e.g. a data grid, in which each row needs to be validated independently
resetEphemeralState(component);
if (!context.row) {
return;
}
Expand All @@ -49,8 +49,8 @@ export function processOneSync<ProcessorScope>(context: ProcessorsContext<Proces
}
});
}
// If the component has ephermal state, then we need to reset the ephermal state in case this is e.g. a data grid, in which each row needs to be validated independently
resetEphermalState(component);
// If the component has ephemeral state, then we need to reset the ephemeral state in case this is e.g. a data grid, in which each row needs to be validated independently
resetEphemeralState(component);
if (!context.row) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/process/validation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export const _shouldSkipValidation = (context: ValidationContext, isConditionall
(find((scope as ConditionsScope).conditionals, {
path: getComponentPath(component, path),
conditionallyHidden: true
}) || component.ephermalState?.conditionallyHidden === true)
}) || component.ephemeralState?.conditionallyHidden === true)
) {
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/process/validation/rules/validateRequired.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const valueIsPresent = (value: any, considerFalseTruthy: boolean, isNestedDataty

export const shouldValidate = (context: ValidationContext) => {
const { component } = context;
if (component.validate?.required && !(component.hidden || component.ephermalState?.conditionallyHidden)) {
if (component.validate?.required && !(component.hidden || component.ephemeralState?.conditionallyHidden)) {
return true;
}
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/types/BaseComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export type BaseComponent = {
unique?: boolean;
persistent?: boolean | string;
hidden?: boolean;
ephermalState?: {
ephemeralState?: {
conditionallyHidden?: boolean;
}
clearOnHide?: boolean;
Expand Down
1 change: 0 additions & 1 deletion src/utils/formUtil/eachComponentData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { isEmpty, get, set, has } from "lodash";
import { Component, DataObject, EachComponentDataCallback, HasChildComponents, HasColumns, HasRows } from "types";
import { getContextualRowData, isComponentNestedDataType, getModelType, componentDataPath, componentInfo, componentFormPath } from "./index";
import { eachComponent } from "./eachComponent";
import { resetEphermalState } from "../utils";

export const eachComponentData = (
components: Component[],
Expand Down
1 change: 0 additions & 1 deletion src/utils/formUtil/eachComponentDataAsync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
componentFormPath
} from './index';
import { eachComponentAsync } from './eachComponentAsync';
import { resetEphermalState } from '../utils';

// Async each component data.
export const eachComponentDataAsync = async (
Expand Down
4 changes: 2 additions & 2 deletions src/utils/logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { checkCustomConditional, checkJsonConditional, checkLegacyConditional, c
import { LogicActionCustomAction, LogicActionMergeComponentSchema, LogicActionProperty, LogicActionPropertyBoolean, LogicActionPropertyString, LogicActionValue } from "types/AdvancedLogic";
import { get, set, clone, isEqual, assign } from 'lodash';
import { evaluate, interpolate } from 'modules/jsonlogic';
import { registerEphermalState } from "./utils";
import { registerEphemeralState } from "./utils";

export const hasLogic = (context: LogicContext): boolean => {
const { component } = context;
Expand Down Expand Up @@ -63,7 +63,7 @@ export function setActionBooleanProperty(context: LogicContext, action: LogicAct
});
if (conditionallyHidden) {
conditionallyHidden.conditionallyHidden = !!component.hidden;
registerEphermalState(component, 'conditionallyHidden', !!component.hidden);
registerEphemeralState(component, 'conditionallyHidden', !!component.hidden);
}
else {
(scope as ConditionsScope).conditionals?.push({
Expand Down
14 changes: 7 additions & 7 deletions src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,25 +45,25 @@ export function unescapeHTML(str: string) {
return doc.documentElement.textContent;
}

export function registerEphermalState(component: Component, name: keyof NonNullable<BaseComponent['ephermalState']>, value: any) {
if (!component.ephermalState) {
Object.defineProperty(component, 'ephermalState', {
export function registerEphemeralState(component: Component, name: keyof NonNullable<BaseComponent['ephemeralState']>, value: any) {
if (!component.ephemeralState) {
Object.defineProperty(component, 'ephemeralState', {
enumerable: false,
configurable: true,
writable: true,
value: {}
});
}
Object.defineProperty(component.ephermalState, name, {
Object.defineProperty(component.ephemeralState, name, {
enumerable: false,
writable: false,
configurable: true,
value
});
}

export function resetEphermalState(component: Component) {
if (component.ephermalState) {
delete component.ephermalState;
export function resetEphemeralState(component: Component) {
if (component.ephemeralState) {
delete component.ephemeralState;
}
}
Loading