From e2eefc7c18875b25905c16a156aa3846b7cad925 Mon Sep 17 00:00:00 2001 From: brendanjbond Date: Thu, 10 Oct 2024 08:14:56 -0500 Subject: [PATCH] fix spelling error and minor linting --- src/process/clearHidden.ts | 2 +- src/process/conditions/index.ts | 5 ++--- src/process/hideChildren.ts | 6 +++--- src/process/processOne.ts | 10 +++++----- src/process/validation/index.ts | 2 +- src/process/validation/rules/validateRequired.ts | 2 +- src/types/BaseComponent.ts | 2 +- src/utils/formUtil/eachComponentData.ts | 1 - src/utils/formUtil/eachComponentDataAsync.ts | 1 - src/utils/logic.ts | 4 ++-- src/utils/utils.ts | 14 +++++++------- 11 files changed, 23 insertions(+), 26 deletions(-) diff --git a/src/process/clearHidden.ts b/src/process/clearHidden.ts index 7efb5275..39c22b33 100644 --- a/src/process/clearHidden.ts +++ b/src/process/clearHidden.ts @@ -35,7 +35,7 @@ export const clearHiddenProcess: ProcessorFnSync = (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; } diff --git a/src/process/conditions/index.ts b/src/process/conditions/index.ts index b3bad497..fd5337c4 100644 --- a/src/process/conditions/index.ts +++ b/src/process/conditions/index.ts @@ -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, @@ -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); } }; diff --git a/src/process/hideChildren.ts b/src/process/hideChildren.ts index 739bc951..d1ad4dbe 100644 --- a/src/process/hideChildren.ts +++ b/src/process/hideChildren.ts @@ -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. @@ -22,8 +22,8 @@ export const hideChildrenProcessor: ProcessorFnSync = (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); } } diff --git a/src/process/processOne.ts b/src/process/processOne.ts index 5448a612..59654851 100644 --- a/src/process/processOne.ts +++ b/src/process/processOne.ts @@ -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); @@ -22,8 +22,8 @@ export async function processOne(context: ProcessorsContext(context: ProcessorsContext { 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; diff --git a/src/types/BaseComponent.ts b/src/types/BaseComponent.ts index 18e995d3..c723cf79 100644 --- a/src/types/BaseComponent.ts +++ b/src/types/BaseComponent.ts @@ -23,7 +23,7 @@ export type BaseComponent = { unique?: boolean; persistent?: boolean | string; hidden?: boolean; - ephermalState?: { + ephemeralState?: { conditionallyHidden?: boolean; } clearOnHide?: boolean; diff --git a/src/utils/formUtil/eachComponentData.ts b/src/utils/formUtil/eachComponentData.ts index 0d0832f5..b2b8c979 100644 --- a/src/utils/formUtil/eachComponentData.ts +++ b/src/utils/formUtil/eachComponentData.ts @@ -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[], diff --git a/src/utils/formUtil/eachComponentDataAsync.ts b/src/utils/formUtil/eachComponentDataAsync.ts index d44a681a..ae114acc 100644 --- a/src/utils/formUtil/eachComponentDataAsync.ts +++ b/src/utils/formUtil/eachComponentDataAsync.ts @@ -17,7 +17,6 @@ import { componentFormPath } from './index'; import { eachComponentAsync } from './eachComponentAsync'; -import { resetEphermalState } from '../utils'; // Async each component data. export const eachComponentDataAsync = async ( diff --git a/src/utils/logic.ts b/src/utils/logic.ts index 946f876c..42f86f21 100644 --- a/src/utils/logic.ts +++ b/src/utils/logic.ts @@ -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; @@ -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({ diff --git a/src/utils/utils.ts b/src/utils/utils.ts index e09279f7..0161d206 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -45,16 +45,16 @@ export function unescapeHTML(str: string) { return doc.documentElement.textContent; } -export function registerEphermalState(component: Component, name: keyof NonNullable, value: any) { - if (!component.ephermalState) { - Object.defineProperty(component, 'ephermalState', { +export function registerEphemeralState(component: Component, name: keyof NonNullable, 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, @@ -62,8 +62,8 @@ export function registerEphermalState(component: Component, name: keyof NonNulla }); } -export function resetEphermalState(component: Component) { - if (component.ephermalState) { - delete component.ephermalState; +export function resetEphemeralState(component: Component) { + if (component.ephemeralState) { + delete component.ephemeralState; } }