chore: prettier files
This commit is contained in:
@@ -1,9 +1,6 @@
|
||||
import { useCallback, useEffect } from 'preact/hooks'
|
||||
|
||||
export function useCloseOnClickOutside(
|
||||
container: { current: HTMLDivElement | null },
|
||||
callback: () => void,
|
||||
): void {
|
||||
export function useCloseOnClickOutside(container: { current: HTMLDivElement | null }, callback: () => void): void {
|
||||
const closeOnClickOutside = useCallback(
|
||||
(event: { target: EventTarget | null }) => {
|
||||
if (!container.current) {
|
||||
|
||||
@@ -34,11 +34,7 @@ export const useListKeyboardNavigation = (container: Ref<HTMLElement | null>, in
|
||||
}
|
||||
|
||||
if (!listItems?.length) {
|
||||
setListItems(
|
||||
Array.from(
|
||||
container.current?.querySelectorAll('button') as NodeListOf<HTMLButtonElement>,
|
||||
),
|
||||
)
|
||||
setListItems(Array.from(container.current?.querySelectorAll('button') as NodeListOf<HTMLButtonElement>))
|
||||
}
|
||||
|
||||
if (listItems) {
|
||||
@@ -67,15 +63,11 @@ export const useListKeyboardNavigation = (container: Ref<HTMLElement | null>, in
|
||||
const containerFocusHandler = useCallback(() => {
|
||||
let temporaryItems = listItems && listItems?.length > 0 ? listItems : []
|
||||
if (!temporaryItems.length) {
|
||||
temporaryItems = Array.from(
|
||||
container.current?.querySelectorAll('button') as NodeListOf<HTMLButtonElement>,
|
||||
)
|
||||
temporaryItems = Array.from(container.current?.querySelectorAll('button') as NodeListOf<HTMLButtonElement>)
|
||||
setListItems(temporaryItems)
|
||||
}
|
||||
if (temporaryItems.length > 0) {
|
||||
const selectedItemIndex = Array.from(temporaryItems).findIndex(
|
||||
(item) => item.dataset.selected,
|
||||
)
|
||||
const selectedItemIndex = Array.from(temporaryItems).findIndex((item) => item.dataset.selected)
|
||||
const indexToFocus = selectedItemIndex > -1 ? selectedItemIndex : initialFocus
|
||||
setTimeout(() => {
|
||||
focusItemWithIndex(indexToFocus, temporaryItems)
|
||||
|
||||
@@ -29,33 +29,31 @@ interface Props {
|
||||
appState: AppState
|
||||
}
|
||||
|
||||
export const PremiumModalProvider: FunctionalComponent<Props> = observer(
|
||||
({ application, appState, children }) => {
|
||||
const featureName = appState.features.premiumAlertFeatureName
|
||||
const activate = appState.features.showPremiumAlert
|
||||
const close = appState.features.closePremiumAlert
|
||||
export const PremiumModalProvider: FunctionalComponent<Props> = observer(({ application, appState, children }) => {
|
||||
const featureName = appState.features.premiumAlertFeatureName
|
||||
const activate = appState.features.showPremiumAlert
|
||||
const close = appState.features.closePremiumAlert
|
||||
|
||||
const showModal = !!featureName
|
||||
const showModal = !!featureName
|
||||
|
||||
const hasSubscription = Boolean(
|
||||
appState.subscription.userSubscription &&
|
||||
!appState.subscription.isUserSubscriptionExpired &&
|
||||
!appState.subscription.isUserSubscriptionCanceled,
|
||||
)
|
||||
const hasSubscription = Boolean(
|
||||
appState.subscription.userSubscription &&
|
||||
!appState.subscription.isUserSubscriptionExpired &&
|
||||
!appState.subscription.isUserSubscriptionCanceled,
|
||||
)
|
||||
|
||||
return (
|
||||
<>
|
||||
{showModal && (
|
||||
<PremiumFeaturesModal
|
||||
application={application}
|
||||
featureName={featureName}
|
||||
hasSubscription={hasSubscription}
|
||||
onClose={close}
|
||||
showModal={!!featureName}
|
||||
/>
|
||||
)}
|
||||
<PremiumModalProvider_ value={{ activate }}>{children}</PremiumModalProvider_>
|
||||
</>
|
||||
)
|
||||
},
|
||||
)
|
||||
return (
|
||||
<>
|
||||
{showModal && (
|
||||
<PremiumFeaturesModal
|
||||
application={application}
|
||||
featureName={featureName}
|
||||
hasSubscription={hasSubscription}
|
||||
onClose={close}
|
||||
showModal={!!featureName}
|
||||
/>
|
||||
)}
|
||||
<PremiumModalProvider_ value={{ activate }}>{children}</PremiumModalProvider_>
|
||||
</>
|
||||
)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user