unframer 2.22.0 → 2.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -0
- package/dist/framer.d.ts.map +1 -1
- package/dist/framer.js +371 -258
- package/dist/framer.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/react.d.ts +7 -0
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +23 -1
- package/dist/react.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/esm/framer.d.ts.map +1 -1
- package/esm/framer.js +369 -257
- package/esm/framer.js.map +1 -1
- package/esm/index.d.ts +1 -1
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +1 -1
- package/esm/index.js.map +1 -1
- package/esm/react.d.ts +7 -0
- package/esm/react.d.ts.map +1 -1
- package/esm/react.js +23 -2
- package/esm/react.js.map +1 -1
- package/esm/version.d.ts +1 -1
- package/esm/version.js +1 -1
- package/package.json +4 -4
- package/src/framer.js +332 -230
- package/src/index.ts +1 -0
- package/src/react.tsx +33 -1
- package/src/version.ts +1 -1
package/src/index.ts
CHANGED
package/src/react.tsx
CHANGED
|
@@ -4,7 +4,9 @@ import { combinedCSSRules, withCSS as originalWithCSS } from './framer.js'
|
|
|
4
4
|
import {
|
|
5
5
|
ComponentPropsWithoutRef,
|
|
6
6
|
ComponentType,
|
|
7
|
+
createContext,
|
|
7
8
|
forwardRef,
|
|
9
|
+
useContext,
|
|
8
10
|
useMemo,
|
|
9
11
|
useSyncExternalStore,
|
|
10
12
|
} from 'react'
|
|
@@ -275,6 +277,18 @@ export function AdaptedLink({
|
|
|
275
277
|
children,
|
|
276
278
|
...rest
|
|
277
279
|
}) {
|
|
280
|
+
const context = useContext(unframerContext)
|
|
281
|
+
let onClick =
|
|
282
|
+
context.navigate && !openInNewTab
|
|
283
|
+
? (e) => {
|
|
284
|
+
if (!context.navigate) return
|
|
285
|
+
const href = e.currentTarget?.getAttribute('href')
|
|
286
|
+
if (!href) return
|
|
287
|
+
e.preventDefault()
|
|
288
|
+
if (rest.onClick) rest.onClick(e)
|
|
289
|
+
context.navigate(href)
|
|
290
|
+
}
|
|
291
|
+
: null
|
|
278
292
|
const onlyForFramer = { children, nodeId, openInNewTab, smoothScroll }
|
|
279
293
|
const routes = React.useContext(routesContext)
|
|
280
294
|
const webPageId = href?.webPageId as string
|
|
@@ -283,7 +297,7 @@ export function AdaptedLink({
|
|
|
283
297
|
const target = openInNewTab ? '_blank' : undefined
|
|
284
298
|
// console.log({ href, pathVariables, path: route?.path, ...rest })
|
|
285
299
|
if (isRelativeLink(href)) {
|
|
286
|
-
return React.cloneElement(children, { ...rest, href, target })
|
|
300
|
+
return React.cloneElement(children, { ...rest, onClick, href, target })
|
|
287
301
|
}
|
|
288
302
|
if (!webPageId) {
|
|
289
303
|
return <Link href={href} {...rest} {...onlyForFramer} />
|
|
@@ -299,6 +313,7 @@ export function AdaptedLink({
|
|
|
299
313
|
if (isRelativeLink(path)) {
|
|
300
314
|
return React.cloneElement(children, {
|
|
301
315
|
...rest,
|
|
316
|
+
onClick,
|
|
302
317
|
href: path,
|
|
303
318
|
target,
|
|
304
319
|
})
|
|
@@ -382,3 +397,20 @@ function isEmpty(obj: Record<any, any>) {
|
|
|
382
397
|
}
|
|
383
398
|
return true
|
|
384
399
|
}
|
|
400
|
+
|
|
401
|
+
type UnframerProviderProps = {
|
|
402
|
+
navigate?: (url: string) => void
|
|
403
|
+
children: React.ReactNode
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
const unframerContext = createContext<Partial<UnframerProviderProps>>({
|
|
407
|
+
navigate: undefined,
|
|
408
|
+
})
|
|
409
|
+
|
|
410
|
+
export function UnframerProvider(props: UnframerProviderProps) {
|
|
411
|
+
return (
|
|
412
|
+
<unframerContext.Provider value={props}>
|
|
413
|
+
{props.children}
|
|
414
|
+
</unframerContext.Provider>
|
|
415
|
+
)
|
|
416
|
+
}
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '2.
|
|
1
|
+
export const version = '2.23.0'
|