unframer 2.25.0 → 2.25.2
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/dist/exporter.js +2 -8
- package/dist/exporter.js.map +1 -1
- package/dist/framer.d.ts.map +1 -1
- package/dist/framer.js +13361 -12505
- package/dist/framer.js.map +1 -1
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +16 -11
- package/dist/react.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/esm/exporter.js +2 -8
- package/esm/exporter.js.map +1 -1
- package/esm/framer.d.ts.map +1 -1
- package/esm/framer.js +13529 -12794
- package/esm/framer.js.map +1 -1
- package/esm/react.d.ts.map +1 -1
- package/esm/react.js +16 -11
- package/esm/react.js.map +1 -1
- package/esm/version.d.ts +1 -1
- package/esm/version.js +1 -1
- package/package.json +3 -3
- package/src/exporter.ts +2 -8
- package/src/framer.js +12655 -11841
- package/src/react.tsx +17 -11
- package/src/version.ts +1 -1
package/src/react.tsx
CHANGED
|
@@ -269,6 +269,13 @@ function isRelativeLink(url) {
|
|
|
269
269
|
}
|
|
270
270
|
return url?.startsWith?.('/') || url?.startsWith?.('#')
|
|
271
271
|
}
|
|
272
|
+
|
|
273
|
+
function isMailto(url) {
|
|
274
|
+
if (!url) {
|
|
275
|
+
return false
|
|
276
|
+
}
|
|
277
|
+
return url?.startsWith?.('mailto:')
|
|
278
|
+
}
|
|
272
279
|
export function AdaptedLink({
|
|
273
280
|
href,
|
|
274
281
|
nodeId,
|
|
@@ -278,12 +285,12 @@ export function AdaptedLink({
|
|
|
278
285
|
...rest
|
|
279
286
|
}) {
|
|
280
287
|
const context = useContext(unframerContext)
|
|
281
|
-
let
|
|
288
|
+
let navigateClientSide =
|
|
282
289
|
context.navigate && !openInNewTab
|
|
283
290
|
? (e) => {
|
|
284
291
|
if (!context.navigate) return
|
|
285
292
|
const href = e.currentTarget?.getAttribute('href')
|
|
286
|
-
if (!href) return
|
|
293
|
+
if (!href || !isRelativeLink(href)) return
|
|
287
294
|
e.preventDefault()
|
|
288
295
|
if (rest.onClick) rest.onClick(e)
|
|
289
296
|
context.navigate(href)
|
|
@@ -295,9 +302,8 @@ export function AdaptedLink({
|
|
|
295
302
|
const pathVariables = href?.pathVariables as Record<string, string>
|
|
296
303
|
const route = routes?.[webPageId]
|
|
297
304
|
const target = openInNewTab ? '_blank' : undefined
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
return React.cloneElement(children, { ...rest, onClick, href, target })
|
|
305
|
+
if (isRelativeLink(href) || isMailto(href)) {
|
|
306
|
+
return React.cloneElement(children, { ...rest, onClick: navigateClientSide, href, target })
|
|
301
307
|
}
|
|
302
308
|
if (!webPageId) {
|
|
303
309
|
return <Link href={href} {...rest} {...onlyForFramer} />
|
|
@@ -306,20 +312,20 @@ export function AdaptedLink({
|
|
|
306
312
|
if (!route || !route.path) {
|
|
307
313
|
return <Link href={href} {...rest} {...onlyForFramer} />
|
|
308
314
|
}
|
|
309
|
-
let
|
|
315
|
+
let resolvedPath = route.path
|
|
310
316
|
if (pathVariables) {
|
|
311
|
-
|
|
317
|
+
resolvedPath = replacePathParams(resolvedPath, pathVariables)
|
|
312
318
|
}
|
|
313
|
-
if (isRelativeLink(
|
|
319
|
+
if (isRelativeLink(resolvedPath) || isMailto(href)) {
|
|
314
320
|
return React.cloneElement(children, {
|
|
315
321
|
...rest,
|
|
316
|
-
onClick,
|
|
317
|
-
href:
|
|
322
|
+
onClick: navigateClientSide,
|
|
323
|
+
href: resolvedPath,
|
|
318
324
|
target,
|
|
319
325
|
})
|
|
320
326
|
}
|
|
321
327
|
|
|
322
|
-
return <Link href={
|
|
328
|
+
return <Link href={resolvedPath} {...rest} {...onlyForFramer} />
|
|
323
329
|
}
|
|
324
330
|
|
|
325
331
|
export function ContextProviders({
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '2.25.
|
|
1
|
+
export const version = '2.25.2'
|