unframer 2.8.0 → 2.9.1
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 +17 -0
- package/dist/cli.d.ts +8 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +4 -2
- package/dist/cli.js.map +1 -1
- package/dist/exporter.d.ts +5 -1
- package/dist/exporter.d.ts.map +1 -1
- package/dist/exporter.js +56 -7
- package/dist/exporter.js.map +1 -1
- package/dist/framer.d.ts.map +1 -1
- package/dist/framer.js +116 -92
- 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 +10 -0
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +49 -20
- package/dist/react.js.map +1 -1
- package/esm/cli.d.ts +8 -0
- package/esm/cli.d.ts.map +1 -1
- package/esm/cli.js +4 -2
- package/esm/cli.js.map +1 -1
- package/esm/exporter.d.ts +5 -1
- package/esm/exporter.d.ts.map +1 -1
- package/esm/exporter.js +56 -7
- package/esm/exporter.js.map +1 -1
- package/esm/framer.d.ts.map +1 -1
- package/esm/framer.js +113 -92
- 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 +10 -0
- package/esm/react.d.ts.map +1 -1
- package/esm/react.js +57 -21
- package/esm/react.js.map +1 -1
- package/package.json +4 -4
- package/src/cli.tsx +15 -2
- package/src/exporter.ts +72 -7
- package/src/framer.js +122 -93
- package/src/index.ts +1 -1
- package/src/react.tsx +95 -23
package/src/react.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
import { combinedCSSRules, LayoutGroup } from './framer.js'
|
|
2
|
+
import { combinedCSSRules, LayoutGroup, MotionConfig } from './framer.js'
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
ComponentPropsWithoutRef,
|
|
@@ -142,30 +142,42 @@ export const WithFramerBreakpoints = forwardRef(function WithFramerBreakpoints<
|
|
|
142
142
|
return ''
|
|
143
143
|
},
|
|
144
144
|
)
|
|
145
|
+
const allBreakpoints = fillBreakpoints(_breakpointsMap)
|
|
146
|
+
const variants = new Map<
|
|
147
|
+
string,
|
|
148
|
+
{ className: string; variant: string; breakpoints: string[] }
|
|
149
|
+
>()
|
|
150
|
+
for (let breakpointName of Object.keys(allBreakpoints)) {
|
|
151
|
+
const realVariant = allBreakpoints[breakpointName]
|
|
152
|
+
if (!realVariant) {
|
|
153
|
+
continue
|
|
154
|
+
}
|
|
145
155
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
>
|
|
152
|
-
for (let breakpointName of Object.keys(allBreakpoints)) {
|
|
153
|
-
const realVariant = allBreakpoints[breakpointName]
|
|
154
|
-
if (!realVariant) {
|
|
155
|
-
continue
|
|
156
|
-
}
|
|
157
|
-
if (currentBreakpoint && currentBreakpoint !== breakpointName) {
|
|
158
|
-
continue
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
let className = classNames(
|
|
162
|
-
variants[realVariant]?.className || 'unframer-hidden',
|
|
156
|
+
const existingVariant = variants.get(realVariant)
|
|
157
|
+
if (existingVariant) {
|
|
158
|
+
existingVariant.breakpoints.push(breakpointName)
|
|
159
|
+
existingVariant.className = classNames(
|
|
160
|
+
existingVariant.className,
|
|
163
161
|
`unframer-${breakpointName}`,
|
|
164
162
|
)
|
|
165
|
-
|
|
163
|
+
} else {
|
|
164
|
+
variants.set(realVariant, {
|
|
165
|
+
className: classNames(
|
|
166
|
+
'unframer-hidden',
|
|
167
|
+
`unframer-${breakpointName}`,
|
|
168
|
+
),
|
|
169
|
+
variant: realVariant,
|
|
170
|
+
breakpoints: [breakpointName],
|
|
171
|
+
})
|
|
166
172
|
}
|
|
167
|
-
|
|
168
|
-
|
|
173
|
+
}
|
|
174
|
+
const parts = [...variants.values()].map(
|
|
175
|
+
({ className, breakpoints, variant }) => {
|
|
176
|
+
const shouldShow =
|
|
177
|
+
!currentBreakpoint || breakpoints.includes(currentBreakpoint)
|
|
178
|
+
if (!shouldShow) {
|
|
179
|
+
return null
|
|
180
|
+
}
|
|
169
181
|
return (
|
|
170
182
|
<div key={variant} className={className}>
|
|
171
183
|
{/* @ts-ignore */}
|
|
@@ -182,8 +194,8 @@ export const WithFramerBreakpoints = forwardRef(function WithFramerBreakpoints<
|
|
|
182
194
|
/>
|
|
183
195
|
</div>
|
|
184
196
|
)
|
|
185
|
-
}
|
|
186
|
-
|
|
197
|
+
},
|
|
198
|
+
)
|
|
187
199
|
|
|
188
200
|
return parts
|
|
189
201
|
})
|
|
@@ -192,3 +204,63 @@ const onResize = (callback) => {
|
|
|
192
204
|
window.addEventListener('resize', callback)
|
|
193
205
|
return () => window.removeEventListener('resize', callback)
|
|
194
206
|
}
|
|
207
|
+
|
|
208
|
+
const onResizeWithDebounce = (callback) => {
|
|
209
|
+
let timeoutId
|
|
210
|
+
const debouncedCallback = () => {
|
|
211
|
+
clearTimeout(timeoutId)
|
|
212
|
+
timeoutId = setTimeout(() => {
|
|
213
|
+
callback()
|
|
214
|
+
}, 16)
|
|
215
|
+
}
|
|
216
|
+
window.addEventListener('resize', debouncedCallback)
|
|
217
|
+
return () => {
|
|
218
|
+
clearTimeout(timeoutId)
|
|
219
|
+
window.removeEventListener('resize', debouncedCallback)
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
import {
|
|
224
|
+
// @ts-ignore
|
|
225
|
+
CustomCursorHost,
|
|
226
|
+
// @ts-ignore
|
|
227
|
+
FetchClientProvider,
|
|
228
|
+
// @ts-ignore
|
|
229
|
+
FormContext,
|
|
230
|
+
// @ts-ignore
|
|
231
|
+
Router,
|
|
232
|
+
} from './framer.js'
|
|
233
|
+
|
|
234
|
+
export function ContextProviders({
|
|
235
|
+
locale,
|
|
236
|
+
children,
|
|
237
|
+
framerSiteId,
|
|
238
|
+
routes,
|
|
239
|
+
routeId,
|
|
240
|
+
pathVariables,
|
|
241
|
+
collectionUtils,
|
|
242
|
+
locales,
|
|
243
|
+
}) {
|
|
244
|
+
const localeId = locales?.find(
|
|
245
|
+
(l) => l.slug === locale || l.code === locale || l.id === locale,
|
|
246
|
+
)?.id
|
|
247
|
+
return (
|
|
248
|
+
<FetchClientProvider>
|
|
249
|
+
<CustomCursorHost>
|
|
250
|
+
<FormContext.Provider value={framerSiteId}>
|
|
251
|
+
<Router
|
|
252
|
+
initialRoute={routeId}
|
|
253
|
+
initialPathVariables={pathVariables}
|
|
254
|
+
initialLocaleId={localeId}
|
|
255
|
+
enableImproveInpDuringHydration={true}
|
|
256
|
+
routes={routes}
|
|
257
|
+
collectionUtils={collectionUtils}
|
|
258
|
+
locales={locales}
|
|
259
|
+
>
|
|
260
|
+
{children}
|
|
261
|
+
</Router>
|
|
262
|
+
</FormContext.Provider>
|
|
263
|
+
</CustomCursorHost>
|
|
264
|
+
</FetchClientProvider>
|
|
265
|
+
)
|
|
266
|
+
}
|