Skip to content

Commit

Permalink
More fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
paales committed Nov 20, 2024
1 parent 0719582 commit e381d18
Show file tree
Hide file tree
Showing 88 changed files with 195 additions and 110 deletions.
2 changes: 1 addition & 1 deletion examples/magento-graphcms/pages/account/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { PageOptions } from '@graphcommerce/framer-next-pages'
import { cacheFirst, useQuery } from '@graphcommerce/graphql'
import { cacheFirst } from '@graphcommerce/graphql'
import {
AccountDashboardDocument,
AccountMenu,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ function CheckoutCustomerAddressesEdit() {
</div>
)}

{address && !loading && <EditAddressForm onCompleteRoute='/checkout' address={address} />}
{address && !loading && <EditAddressForm address={address} />}
</SectionContainer>
</Container>
</>
Expand Down
2 changes: 1 addition & 1 deletion examples/magento-graphcms/pages/checkout/success.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function OrderSuccessPage() {

<SignupNewsletter />

<InlineAccount accountHref='/account' />
<InlineAccount />

<Box textAlign='center' m={8}>
<Button href='/' color='primary' variant='pill' size='large' id='back-to-home'>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export function algoliaPricesToPricesAggregations(pricesList: {
return Object.values(pricesBucket)
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
function assertAlgoliaFacets(facets: any): facets is AlgoliaFacets {
return true
}
Expand Down
2 changes: 0 additions & 2 deletions packages/algolia-products/mesh/algoliaHitToMagentoProduct.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import type {
ResolversParentTypes,
ResolversTypes,
} from '@graphcommerce/graphql-mesh'
// eslint-disable-next-line import/no-extraneous-dependencies
import { GraphQLResolveInfo } from 'graphql'
import type { GetStoreConfigReturn } from './getStoreConfig'

export function assertAdditional(
Expand Down
2 changes: 1 addition & 1 deletion packages/algolia-recommend/mesh/getRecommendations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export async function getRecommendations<
)
} catch (e) {
if (isGraphQLError(e)) {
console.log(
console.info(
'There was an error retrieving Algolia Recommendations, make sure the recommendation models are created',
e,
)
Expand Down
1 change: 1 addition & 0 deletions packages/algolia-search/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"@lingui/react": "^4.2.1",
"@mui/material": "^5.10.16",
"next": "*",
"react": "^18.3.1",
"react-instantsearch-hooks-web": "^6.47.3"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const config: PluginConfig = {
}

export function RecentlyViewedProducts(props: PluginProps<RecentlyViewedProductsProps>) {
const { Prev, exclude, title, productListRenderer, loading = 'lazy', ...scrollerProps } = props
const { exclude, title, productListRenderer, loading = 'lazy' } = props

const ref = useRef<HTMLDivElement>(null)
const isInView = useInView(ref, { margin: '300px' })
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { ApolloError } from '@graphcommerce/graphql'
import { extendableComponent } from '@graphcommerce/next-ui/Styles/extendableComponent'
import { Trans } from '@lingui/react'
import type { AlertProps, SxProps, Theme } from '@mui/material'
import { Alert, Box } from '@mui/material'
import { maskNetworkError } from './maskNetworkError'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/no-restricted-imports */
import type { ControllerProps, FieldValues } from '@graphcommerce/react-hook-form'
import { Controller, useController } from '@graphcommerce/react-hook-form'
import { useController } from '@graphcommerce/react-hook-form'
import { i18n } from '@lingui/core'
import type { AutocompleteProps, TextFieldProps } from '@mui/material'
import { Autocomplete, Checkbox, TextField, CircularProgress } from '@mui/material'
Expand All @@ -19,6 +19,7 @@ export type AutocompleteElementProps<
label?: TextFieldProps['label']
showCheckbox?: boolean
autocompleteProps?: Omit<
// eslint-disable-next-line @typescript-eslint/no-explicit-any
AutocompleteProps<T, M, D, any>,
'name' | 'options' | 'loading' | 'renderInput'
>
Expand Down Expand Up @@ -48,6 +49,7 @@ export function AutocompleteElement<TFieldValues extends FieldValues>({
shouldUnregister,
}: AutocompleteElementProps<
TFieldValues,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
AutoDefault | string | any,
boolean | undefined,
boolean | undefined
Expand Down Expand Up @@ -75,7 +77,8 @@ export function AutocompleteElement<TFieldValues extends FieldValues>({
let currentValue = multiple ? value || [] : value || null
if (matchId) {
currentValue = multiple
? values.map((i: any) => options.find((j) => (j.id || j) === i))
? // eslint-disable-next-line @typescript-eslint/no-explicit-any
values.map((i: any) => options.find((j) => (j.id || j) === i))
: options.find((i) => (i.id || i) === value) || null
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ import {
} from '@mui/material'

export type CheckboxButtonGroupProps<T extends FieldValues> = {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
options: { id: string | number; label: string }[] | any[]
helperText?: string
required?: boolean
label?: string
labelKey?: string
valueKey?: string
// eslint-disable-next-line @typescript-eslint/ban-types
onChange?: Function
returnObject?: boolean
disabled?: boolean
Expand Down Expand Up @@ -63,13 +65,17 @@ export function CheckboxButtonGroup<TFieldValues extends FieldValues>(
const parsedHelperText = error ? error.message : helperText

const handleChange = (index: number | string) => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const newArray: (string | number)[] | any[] = [...value]
const exists =
// eslint-disable-next-line @typescript-eslint/no-explicit-any
value.findIndex((i: any) => (returnObject ? i[valueKey] === index : i === index)) === -1
if (exists) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
newArray.push(returnObject ? options.find((i) => i[valueKey] === index) : index)
} else {
newArray.splice(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
value.findIndex((i: any) => (returnObject ? i[valueKey] === index : i === index)),
1,
)
Expand All @@ -94,7 +100,7 @@ export function CheckboxButtonGroup<TFieldValues extends FieldValues>(
)
}
const isChecked =
value.findIndex((item: any) =>
value.findIndex((item) =>
returnObject ? item[valueKey] === optionKey : item === optionKey,
) !== -1
return (
Expand All @@ -108,6 +114,7 @@ export function CheckboxButtonGroup<TFieldValues extends FieldValues>(
value={optionKey}
checked={isChecked}
disabled={disabled}
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
onChange={() => handleChange(optionKey)}
/>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
} from '@mui/material'

export type MultiSelectElementProps<T extends FieldValues> = Omit<SelectProps, 'value'> & {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
options: { id: string | number; label: string }[] | any[]
label?: string
itemKey?: string
Expand Down Expand Up @@ -127,12 +128,14 @@ export function MultiSelectElement<TFieldValues extends FieldValues>(
: showChips
? (selected) => (
<div style={{ display: 'flex', flexWrap: 'wrap' }}>
{/* eslint-disable-next-line @typescript-eslint/no-explicit-any */}
{((selected as any[]) || []).map((selectedValue) => (
<Chip
key={selectedValue}
label={selectedValue}
style={{ display: 'flex', flexWrap: 'wrap' }}
onDelete={() => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
onChange(value.filter((i: any) => i !== selectedValue))
// setValue(name, formValue.filter((i: any) => i !== value), { shouldValidate: true })
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
import type { ChangeEvent } from 'react'

export type RadioButtonGroupProps<T extends FieldValues> = {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
options: { label: string; id: string | number }[] | any[]
helperText?: string
required?: boolean
Expand All @@ -21,6 +22,7 @@ export type RadioButtonGroupProps<T extends FieldValues> = {
valueKey?: string
type?: 'number' | 'string'
emptyOptionLabel?: 'string'
// eslint-disable-next-line @typescript-eslint/no-explicit-any
onChange?: (value: any) => void
returnObject?: boolean
row?: boolean
Expand Down Expand Up @@ -96,7 +98,7 @@ export function RadioButtonGroup<TFieldValues extends FieldValues>(
value=''
/>
)}
{options.map((option: any) => {
{options.map((option) => {
const optionKey = option[valueKey]
if (!optionKey) {
console.error(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export function SelectElement<TFieldValues extends FieldValues, O extends Option
),
}}
>
{/* eslint-disable-next-line jsx-a11y/control-has-associated-label */}
{isNativeSelect && <option />}
{options.map((item) => (
<ChildComponent key={item.id} value={item.id}>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ControllerProps, FieldValues } from '@graphcommerce/react-hook-form'
import { FieldError, useController } from '@graphcommerce/react-hook-form'
import { useController } from '@graphcommerce/react-hook-form'
import { i18n } from '@lingui/core'
import type { FormControlProps, SliderProps } from '@mui/material'
import { FormControl, FormHelperText, FormLabel, Slider } from '@mui/material'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ControllerProps, FieldValues } from '@graphcommerce/react-hook-form'
import { FieldError, useController } from '@graphcommerce/react-hook-form'
import { useController } from '@graphcommerce/react-hook-form'
import { i18n } from '@lingui/core'
import type { FormLabelProps, ToggleButtonGroupProps, ToggleButtonProps } from '@mui/material'
import {
Expand Down Expand Up @@ -81,9 +81,9 @@ export function ToggleButtonGroupElement<TFieldValues extends FieldValues = Fiel
}
}}
>
{options.map(({ label, id, ...toggleProps }) => (
{options.map(({ label: labelVal, id, ...toggleProps }) => (
<ToggleButton value={id} {...toggleProps} key={id}>
{label}
{labelVal}
</ToggleButton>
))}
</ToggleButtonGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ function PreviewModeEnabled() {
const revalidateHandler = form.handleSubmit((formValues) => {
const url = getPreviewUrl()
Object.entries(formValues).forEach(([key, value]) => {
// eslint-disable-next-line @typescript-eslint/no-base-to-string
url.searchParams.append(key, `${value}`)
})
url.searchParams.append('action', 'revalidate')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export type PreviewModeActionsProps = Record<string, unknown>

// eslint-disable-next-line @typescript-eslint/no-unused-vars
export function PreviewModeActions(props: PreviewModeActionsProps) {
const {} = props
return <></>
return null
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export type PreviewModeToolbarProps = Record<string, unknown>

// eslint-disable-next-line @typescript-eslint/no-unused-vars
export function PreviewModeToolbar(props: PreviewModeToolbarProps) {
const {} = props
return null
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@ import { useIsSSR } from '@graphcommerce/next-ui'
import React from 'react'

export type WaitForQueriesProps = {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
waitFor: QueryResult<any, any> | boolean | (QueryResult<any, any> | boolean)[] | undefined
/**
* @deprecated Will be automatically correct.
*/
noSsr?: boolean
children: React.ReactNode
fallback?: React.ReactNode
}
Expand Down
2 changes: 1 addition & 1 deletion packages/framer-next-pages/components/Page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { dvh } from '@graphcommerce/framer-utils'
import { m, useIsPresent } from 'framer-motion'
import React, { HTMLAttributes } from 'react'
import React from 'react'
import type { PageItem } from '../types'

export type PageProps = Pick<PageItem, 'routerKey'> & {
Expand Down
4 changes: 3 additions & 1 deletion packages/framer-next-pages/components/PageRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import React, { useMemo } from 'react'
import { pageRouterContext } from '../context/pageRouterContext'
import type { PageItem } from '../types'

const NoLayout: React.FC<{ children?: React.ReactNode }> = ({ children }) => <>{children}</>
function NoLayout({ children }: { children?: React.ReactNode }) {
return <>{children}</>
}

export type PageRendererProps = Omit<AppPropsType, 'router'> & {
Layout: React.ComponentType<AppPropsType>
Expand Down
9 changes: 9 additions & 0 deletions packages/framer-next-pages/example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@
}
},
"dependencies": {
"@emotion/cache": "^11.13.1",
"@emotion/react": "11.12.0",
"@emotion/server": "^11.11.0",
"@emotion/styled": "^11.13.0",
"@graphcommerce/framer-next-pages": "9.0.0-canary.102",
"@graphcommerce/framer-scroller": "9.0.0-canary.102",
"@graphcommerce/framer-utils": "9.0.0-canary.102",
"@graphcommerce/image": "9.0.0-canary.102",
"@graphcommerce/next-ui": "9.0.0-canary.102",
"@lingui/core": "4.11.4",
"@lingui/macro": "4.11.4",
"@lingui/react": "4.11.4",
Expand Down
1 change: 1 addition & 0 deletions packages/framer-next-pages/example/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import '../demo.css'
import type { PageComponent } from '@graphcommerce/framer-next-pages'
import { FramerNextPages } from '@graphcommerce/framer-next-pages'
// eslint-disable-next-line import/no-extraneous-dependencies
import { LinguiProvider } from '@graphcommerce/lingui-next'
import { responsiveVal } from '@graphcommerce/next-ui'
import { createTheme, CssBaseline, ThemeProvider } from '@mui/material'
Expand Down
2 changes: 1 addition & 1 deletion packages/framer-scroller/components/ScrollerBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export function ScrollerBar(props: ScrollerBarProps) {

const scrollProgress = scroll[`${direction}Progress`]

const thumbSize = useTransform(scrollProgress, (directionProgress) => {
const thumbSize = useTransform(scrollProgress, () => {
if (!scrollerRef.current) return 0
const trackWidth = scrollerRef.current[offsetSize]
return trackWidth * (trackWidth / scrollerRef.current[scrollSize])
Expand Down
12 changes: 12 additions & 0 deletions packages/framer-scroller/example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,18 @@
"start": "next start"
},
"dependencies": {
"@emotion/cache": "^11.13.1",
"@emotion/react": "11.12.0",
"@emotion/server": "^11.11.0",
"@emotion/styled": "^11.13.0",
"@graphcommerce/framer-next-pages": "9.0.0-canary.102",
"@graphcommerce/framer-scroller": "9.0.0-canary.102",
"@graphcommerce/framer-utils": "9.0.0-canary.102",
"@graphcommerce/image": "9.0.0-canary.102",
"@graphcommerce/lingui-next": "9.0.0-canary.102",
"@graphcommerce/next-config": "9.0.0-canary.102",
"@graphcommerce/next-ui": "9.0.0-canary.102",
"@lingui/conf": "4.11.4",
"@lingui/core": "4.11.4",
"@lingui/macro": "4.11.4",
"@lingui/react": "4.11.4",
Expand Down
2 changes: 2 additions & 0 deletions packages/framer-utils/hooks/useMotionSelector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ import { startTransition, useState } from 'react'
import { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect'

type UnwrapMotionValue<T> = T extends MotionValue<infer U> ? U : T
// eslint-disable-next-line @typescript-eslint/no-explicit-any
type UnwrapMotionValues<T extends [...any[]]> = T extends [infer Head, ...infer Tail]
? [UnwrapMotionValue<Head>, ...UnwrapMotionValues<Tail>]
: []

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function useMotionSelector<T extends [...any[]], R>(
motionValues: readonly [...T],
effect: (v: UnwrapMotionValues<T>) => R,
Expand Down
2 changes: 2 additions & 0 deletions packages/google-datalayer/api/sendEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ export type SendEvent = (
) => void

export function sendEvent<Event extends keyof GoogleEventTypes>(
// eslint-disable-next-line @typescript-eslint/no-unused-vars
eventName: Event,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
eventData: GoogleEventTypes[Event],
) {
// This is a generic event handler and is plugins from google-analytics and google datalayer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function useViewItemList() {
const context = useContext(DatalayerSelectItemContext)
if (!context) {
return (itemId: string) => {
console.log(`No DatalayerSelectItemContext provider found, trying to select item ${itemId}`)
console.warn(`No DatalayerSelectItemContext provider found, trying to select item ${itemId}`)
}
}
return context
Expand Down
1 change: 1 addition & 0 deletions packages/google-datalayer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"@graphcommerce/magento-product": "^9.0.0-canary.102",
"@graphcommerce/next-ui": "^9.0.0-canary.102",
"@graphcommerce/prettier-config-pwa": "^9.0.0-canary.102",
"@graphcommerce/react-hook-form": "^9.0.0-canary.102",
"@graphcommerce/typescript-config-pwa": "^9.0.0-canary.102",
"@mui/material": "^5.14.20",
"next": "^14",
Expand Down
Loading

0 comments on commit e381d18

Please sign in to comment.