From 5ea1a69edc0a38e2aa4b870c08a95157628d914e Mon Sep 17 00:00:00 2001 From: Rafa Date: Fri, 28 Jun 2024 09:20:53 -0700 Subject: [PATCH] ActionTypes.ts rename `options.useCustom` to `options.useDefault` --- __tests__/useCTA.test.ts | 2 +- src/internal/ActionTypes.ts | 4 ++-- src/internal/ctaReducer.ts | 12 ++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/__tests__/useCTA.test.ts b/__tests__/useCTA.test.ts index ffe323c..f60ffce 100644 --- a/__tests__/useCTA.test.ts +++ b/__tests__/useCTA.test.ts @@ -1857,7 +1857,7 @@ describe( 'useCTA', function() { { hi: state.current.hi * 3, }, - { useCustom: false, }, + { useDefault: true, }, ); }, }, diff --git a/src/internal/ActionTypes.ts b/src/internal/ActionTypes.ts index 9283faa..db6af37 100644 --- a/src/internal/ActionTypes.ts +++ b/src/internal/ActionTypes.ts @@ -5,7 +5,7 @@ type PredefinedActions = 'replace' | 'replaceInitial' | 'reset' | 'update'; export type ActionTypeConstructParam = { type: PredefinedActions nextState: Initial | Partial - options?: { useCustom: boolean } + options?: { useDefault: boolean } }; export class ActionType { @@ -17,7 +17,7 @@ export class ActionType { this.type = param.type; this.nextState = param.nextState; this.options = { - useCustom: true, + useDefault: false, ...param?.options, }; } diff --git a/src/internal/ctaReducer.ts b/src/internal/ctaReducer.ts index bb4094f..ae25b30 100644 --- a/src/internal/ctaReducer.ts +++ b/src/internal/ctaReducer.ts @@ -212,15 +212,15 @@ function getActionType< return { next: nextState, type, - useCustom: Boolean( options?.useCustom, ), + useDefault: Boolean( options?.useDefault, ), } as typeof type extends 'update' ? { next: Partial type: 'update' - useCustom: boolean + useDefault: boolean } : { next: Initial type: Exclude - useCustom: boolean + useDefault: boolean }; } @@ -228,7 +228,7 @@ function getActionType< return { next: ctaReturnType as Partial, type: 'update' as Extract, - useCustom: true, + useDefault: false, }; } } @@ -346,7 +346,7 @@ export default function ctaReducer< const { type, - useCustom, + useDefault, } = actionType; let { @@ -355,7 +355,7 @@ export default function ctaReducer< const customPredefinedCTA = isActionsObject && actions?.[ type as keyof typeof actions ]; - if ( typeof customPredefinedCTA === 'function' && useCustom ) { + if ( typeof customPredefinedCTA === 'function' && !useDefault ) { next = customPredefinedCTA( ctaHandleState, next, ); }