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/esm/index.d.ts
CHANGED
package/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAE3B,OAAO,EACH,YAAY,EACZ,kBAAkB,EAClB,qBAAqB,EACrB,gBAAgB,GACnB,MAAM,YAAY,CAAA"}
|
package/esm/index.js
CHANGED
package/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAE3B,OAAO,EACH,YAAY,EAEZ,qBAAqB,EACrB,gBAAgB,GACnB,MAAM,YAAY,CAAA"}
|
package/esm/react.d.ts
CHANGED
|
@@ -17,4 +17,14 @@ export declare const WithFramerBreakpoints: import("react").ForwardRefExoticComp
|
|
|
17
17
|
variant?: any;
|
|
18
18
|
className?: string;
|
|
19
19
|
}, "variant"> & import("react").RefAttributes<unknown>>;
|
|
20
|
+
export declare function ContextProviders({ locale, children, framerSiteId, routes, routeId, pathVariables, collectionUtils, locales, }: {
|
|
21
|
+
locale: any;
|
|
22
|
+
children: any;
|
|
23
|
+
framerSiteId: any;
|
|
24
|
+
routes: any;
|
|
25
|
+
routeId: any;
|
|
26
|
+
pathVariables: any;
|
|
27
|
+
collectionUtils: any;
|
|
28
|
+
locales: any;
|
|
29
|
+
}): import("react/jsx-runtime.js").JSX.Element;
|
|
20
30
|
//# sourceMappingURL=react.d.ts.map
|
package/esm/react.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../src/react.tsx"],"names":[],"mappings":"AAGA,OAAO,EAEH,aAAa,EAKhB,MAAM,OAAO,CAAA;AACd,OAAO,EAEH,sBAAsB,EAEzB,MAAM,UAAU,CAAA;AAWjB,MAAM,MAAM,kBAAkB,GAAG,MAAM,OAAO,sBAAsB,CAAA;AA8BpE;;GAEG;AACH,wBAAgB,YAAY,CAAC,EAAE,UAAwB,EAAE;;CAAA,GAAG,GAAG,CAmD9D;AAED,eAAO,MAAM,qBAAqB;;kBACM,GAAG;oBAAc,MAAM;;;;cAAvB,GAAG;gBAAc,MAAM;
|
|
1
|
+
{"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../src/react.tsx"],"names":[],"mappings":"AAGA,OAAO,EAEH,aAAa,EAKhB,MAAM,OAAO,CAAA;AACd,OAAO,EAEH,sBAAsB,EAEzB,MAAM,UAAU,CAAA;AAWjB,MAAM,MAAM,kBAAkB,GAAG,MAAM,OAAO,sBAAsB,CAAA;AA8BpE;;GAEG;AACH,wBAAgB,YAAY,CAAC,EAAE,UAAwB,EAAE;;CAAA,GAAG,GAAG,CAmD9D;AAED,eAAO,MAAM,qBAAqB;;kBACM,GAAG;oBAAc,MAAM;;;;cAAvB,GAAG;gBAAc,MAAM;uDAuF7D,CAAA;AAiCF,wBAAgB,gBAAgB,CAAC,EAC7B,MAAM,EACN,QAAQ,EACR,YAAY,EACZ,MAAM,EACN,OAAO,EACP,aAAa,EACb,eAAe,EACf,OAAO,GACV;;;;;;;;;CAAA,8CAuBA"}
|
package/esm/react.js
CHANGED
|
@@ -12,7 +12,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
};
|
|
13
13
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
14
|
import { combinedCSSRules } from './framer.js';
|
|
15
|
-
import { forwardRef, useId,
|
|
15
|
+
import { forwardRef, useId, useSyncExternalStore, } from 'react';
|
|
16
16
|
import { breakpointsStyles, defaultBreakpointSizes, getFontsStyles, } from './css.js';
|
|
17
17
|
function classNames(...args) {
|
|
18
18
|
return args.filter(Boolean).join(' ');
|
|
@@ -73,31 +73,67 @@ export const WithFramerBreakpoints = forwardRef(function WithFramerBreakpoints(_
|
|
|
73
73
|
// on server and during hydration
|
|
74
74
|
return '';
|
|
75
75
|
});
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
if (!realVariant) {
|
|
83
|
-
continue;
|
|
84
|
-
}
|
|
85
|
-
if (currentBreakpoint && currentBreakpoint !== breakpointName) {
|
|
86
|
-
continue;
|
|
87
|
-
}
|
|
88
|
-
let className = classNames(((_a = variants[realVariant]) === null || _a === void 0 ? void 0 : _a.className) || 'unframer-hidden', `unframer-${breakpointName}`);
|
|
89
|
-
variants[realVariant] = { className, variant: realVariant };
|
|
76
|
+
const allBreakpoints = fillBreakpoints(_breakpointsMap);
|
|
77
|
+
const variants = new Map();
|
|
78
|
+
for (let breakpointName of Object.keys(allBreakpoints)) {
|
|
79
|
+
const realVariant = allBreakpoints[breakpointName];
|
|
80
|
+
if (!realVariant) {
|
|
81
|
+
continue;
|
|
90
82
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
96
|
-
|
|
83
|
+
const existingVariant = variants.get(realVariant);
|
|
84
|
+
if (existingVariant) {
|
|
85
|
+
existingVariant.breakpoints.push(breakpointName);
|
|
86
|
+
existingVariant.className = classNames(existingVariant.className, `unframer-${breakpointName}`);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
variants.set(realVariant, {
|
|
90
|
+
className: classNames('unframer-hidden', `unframer-${breakpointName}`),
|
|
91
|
+
variant: realVariant,
|
|
92
|
+
breakpoints: [breakpointName],
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
const parts = [...variants.values()].map(({ className, breakpoints, variant }) => {
|
|
97
|
+
const shouldShow = !currentBreakpoint || breakpoints.includes(currentBreakpoint);
|
|
98
|
+
if (!shouldShow) {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
return (_jsx("div", { className: className, children: _jsx(Component, Object.assign({ ref: ref,
|
|
102
|
+
// LayoutGroup is used internally
|
|
103
|
+
layoutId: id + variant }, rest, { variant: variant }), variant) }, variant));
|
|
104
|
+
});
|
|
97
105
|
return parts;
|
|
98
106
|
});
|
|
99
107
|
const onResize = (callback) => {
|
|
100
108
|
window.addEventListener('resize', callback);
|
|
101
109
|
return () => window.removeEventListener('resize', callback);
|
|
102
110
|
};
|
|
111
|
+
const onResizeWithDebounce = (callback) => {
|
|
112
|
+
let timeoutId;
|
|
113
|
+
const debouncedCallback = () => {
|
|
114
|
+
clearTimeout(timeoutId);
|
|
115
|
+
timeoutId = setTimeout(() => {
|
|
116
|
+
callback();
|
|
117
|
+
}, 16);
|
|
118
|
+
};
|
|
119
|
+
window.addEventListener('resize', debouncedCallback);
|
|
120
|
+
return () => {
|
|
121
|
+
clearTimeout(timeoutId);
|
|
122
|
+
window.removeEventListener('resize', debouncedCallback);
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
import {
|
|
126
|
+
// @ts-ignore
|
|
127
|
+
CustomCursorHost,
|
|
128
|
+
// @ts-ignore
|
|
129
|
+
FetchClientProvider,
|
|
130
|
+
// @ts-ignore
|
|
131
|
+
FormContext,
|
|
132
|
+
// @ts-ignore
|
|
133
|
+
Router, } from './framer.js';
|
|
134
|
+
export function ContextProviders({ locale, children, framerSiteId, routes, routeId, pathVariables, collectionUtils, locales, }) {
|
|
135
|
+
var _a;
|
|
136
|
+
const localeId = (_a = locales === null || locales === void 0 ? void 0 : locales.find((l) => l.slug === locale || l.code === locale || l.id === locale)) === null || _a === void 0 ? void 0 : _a.id;
|
|
137
|
+
return (_jsx(FetchClientProvider, { children: _jsx(CustomCursorHost, { children: _jsx(FormContext.Provider, { value: framerSiteId, children: _jsx(Router, { initialRoute: routeId, initialPathVariables: pathVariables, initialLocaleId: localeId, enableImproveInpDuringHydration: true, routes: routes, collectionUtils: collectionUtils, locales: locales, children: children }) }) }) }));
|
|
138
|
+
}
|
|
103
139
|
//# sourceMappingURL=react.js.map
|
package/esm/react.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.js","sourceRoot":"","sources":["../src/react.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;;;;;;;;;;;;AACZ,OAAO,EAAE,gBAAgB,
|
|
1
|
+
{"version":3,"file":"react.js","sourceRoot":"","sources":["../src/react.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;;;;;;;;;;;;AACZ,OAAO,EAAE,gBAAgB,EAA6B,MAAM,aAAa,CAAA;AAEzE,OAAO,EAGH,UAAU,EACV,KAAK,EAEL,oBAAoB,GACvB,MAAM,OAAO,CAAA;AACd,OAAO,EACH,iBAAiB,EACjB,sBAAsB,EACtB,cAAc,GACjB,MAAM,UAAU,CAAA;AAEjB,SAAS,UAAU,CAAC,GAAG,IAAI;IACvB,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AACzC,CAAC;AAED,2CAA2C;AAC3C,MAAM,kBAAkB,GAAG,MAAM,CAAC,IAAI,CAClC,sBAAsB,CACzB,CAAC,OAAO,EAA0B,CAAA;AAInC,SAAS,gCAAgC,CAAC,WAAmB;IACzD,OAAO,kBAAkB,CAAC,IAAI,CAC1B,CAAC,IAAI,EAAE,EAAE,CAAC,WAAW,IAAI,sBAAsB,CAAC,IAAI,CAAC,CACxD,CAAA;AACL,CAAC;AAID,SAAS,eAAe,CAAC,WAAwB;IAC7C,MAAM,gBAAgB,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAAA;IAChE,MAAM,iBAAiB,qBAAqB,WAAW,CAAE,CAAA;IAEzD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,gBAAgB,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC/C,MAAM,iBAAiB,GAAG,gBAAgB,CAAC,CAAC,CAA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AC,CAAA;IACpD,OAAO,GAAG,EAAE;QACR,YAAY,CAAC,SAAS,CAAC,CAAA;QACvB,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,iBAAiB,CAAC,CAAA;IAC3D,CAAC,CAAA;AACL,CAAC,CAAA;AAED,OAAO;AACH,aAAa;AACb,gBAAgB;AAChB,aAAa;AACb,mBAAmB;AACnB,aAAa;AACb,WAAW;AACX,aAAa;AACb,MAAM,GACT,MAAM,aAAa,CAAA;AAEpB,MAAM,UAAU,gBAAgB,CAAC,EAC7B,MAAM,EACN,QAAQ,EACR,YAAY,EACZ,MAAM,EACN,OAAO,EACP,aAAa,EACb,eAAe,EACf,OAAO,GACV;;IACG,MAAM,QAAQ,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,CAC1B,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,IAAI,CAAC,CAAC,IAAI,KAAK,MAAM,IAAI,CAAC,CAAC,EAAE,KAAK,MAAM,CACnE,0CAAE,EAAE,CAAA;IACL,OAAO,CACH,KAAC,mBAAmB,cAChB,KAAC,gBAAgB,cACb,KAAC,WAAW,CAAC,QAAQ,IAAC,KAAK,EAAE,YAAY,YACrC,KAAC,MAAM,IACH,YAAY,EAAE,OAAO,EACrB,oBAAoB,EAAE,aAAa,EACnC,eAAe,EAAE,QAAQ,EACzB,+BAA+B,EAAE,IAAI,EACrC,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,eAAe,EAChC,OAAO,EAAE,OAAO,YAEf,QAAQ,GACJ,GACU,GACR,GACD,CACzB,CAAA;AACL,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "unframer",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.9.1",
|
|
4
4
|
"description": "Import Framer components directly in your React app, type safe and customizable",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"repository": "https://github.com/remorses/unframer",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"@types/babel__traverse": "^7.20.6",
|
|
73
73
|
"@types/bun": "^1.1.6",
|
|
74
74
|
"@types/fs-extra": "^11.0.4",
|
|
75
|
-
"@types/node": "^22.
|
|
75
|
+
"@types/node": "^22.10.2",
|
|
76
76
|
"@types/react": "^18.3.12",
|
|
77
77
|
"@xmorse/deployment-utils": "^0.2.19",
|
|
78
78
|
"concurrently": "^8.2.2",
|
|
@@ -84,9 +84,9 @@
|
|
|
84
84
|
"typescript": "^5.6.2"
|
|
85
85
|
},
|
|
86
86
|
"scripts": {
|
|
87
|
-
"build": "rm -rf dist && concurrently 'pnpm tsc -m esnext --outDir esm' 'pnpm tsc' && echo copying && cp ../README.md ./README.md && cp ./src/framer.d.ts ./dist/framer.d.ts && cp ./src/framer.d.ts ./esm/framer.d.ts",
|
|
87
|
+
"build": "rm -rf dist && pnpm concurrently 'pnpm tsc -m esnext --outDir esm' 'pnpm tsc' && echo copying && cp ../README.md ./README.md && cp ./src/framer.d.ts ./dist/framer.d.ts && cp ./src/framer.d.ts ./esm/framer.d.ts",
|
|
88
88
|
"test": "vitest",
|
|
89
89
|
"download-framer": "tsx scripts/download.ts",
|
|
90
|
-
"watch": "rm -rf dist esm && concurrently 'pnpm tsc -w' 'pnpm tsc -m esnext -w --outDir esm'"
|
|
90
|
+
"watch": "rm -rf dist esm && pnpm concurrently 'pnpm tsc -w' 'pnpm tsc -m esnext -w --outDir esm'"
|
|
91
91
|
}
|
|
92
92
|
}
|
package/src/cli.tsx
CHANGED
|
@@ -44,6 +44,8 @@ cli.command('[projectId]', 'Run unframer with optional project ID')
|
|
|
44
44
|
outDir,
|
|
45
45
|
projectId: data?.project?.id,
|
|
46
46
|
projectName,
|
|
47
|
+
fullFramerProjectId: data?.project?.fullFramerProjectId,
|
|
48
|
+
locales: data?.locales,
|
|
47
49
|
components: Object.fromEntries(
|
|
48
50
|
data.components.map((c) => [
|
|
49
51
|
componentNameToPath(c.name),
|
|
@@ -85,7 +87,7 @@ cli.command('[projectId]', 'Run unframer with optional project ID')
|
|
|
85
87
|
config,
|
|
86
88
|
watch: false,
|
|
87
89
|
signal: controller.signal,
|
|
88
|
-
cwd: path.resolve(process.cwd(), outDir || 'framer'),
|
|
90
|
+
cwd: path.resolve(process.cwd(), config.outDir || 'framer'),
|
|
89
91
|
})
|
|
90
92
|
})
|
|
91
93
|
|
|
@@ -161,8 +163,19 @@ export type Config = {
|
|
|
161
163
|
[name: string]: string
|
|
162
164
|
}
|
|
163
165
|
projectId?: string
|
|
166
|
+
fullFramerProjectId?: string
|
|
164
167
|
projectName?: string
|
|
165
|
-
framerWebPages?: {
|
|
168
|
+
framerWebPages?: {
|
|
169
|
+
webPageId: string
|
|
170
|
+
components?: string[]
|
|
171
|
+
path: string
|
|
172
|
+
}[]
|
|
173
|
+
locales?: {
|
|
174
|
+
code: string
|
|
175
|
+
id: string
|
|
176
|
+
name: string
|
|
177
|
+
slug: string
|
|
178
|
+
}[]
|
|
166
179
|
breakpoints?: BreakpointSizes
|
|
167
180
|
tokens?: StyleToken[]
|
|
168
181
|
outDir?: string
|
package/src/exporter.ts
CHANGED
|
@@ -124,16 +124,62 @@ export async function bundle({
|
|
|
124
124
|
const url = components[name]
|
|
125
125
|
|
|
126
126
|
return {
|
|
127
|
-
contents: /** js
|
|
127
|
+
contents: /** js **/ `
|
|
128
|
+
'use client'
|
|
129
|
+
import { Fragment } from 'react'
|
|
130
|
+
import { ContextProviders } from 'unframer'
|
|
128
131
|
import Component from '${await resolveRedirect({
|
|
129
132
|
url,
|
|
130
133
|
signal,
|
|
131
134
|
})}'
|
|
132
135
|
import { WithFramerBreakpoints } from 'unframer'
|
|
133
|
-
|
|
134
|
-
|
|
136
|
+
const locales = ${
|
|
137
|
+
JSON.stringify(config.locales) || '[]'
|
|
135
138
|
}
|
|
136
|
-
|
|
139
|
+
|
|
140
|
+
Component.Responsive = ({ locale, ...props }) => {
|
|
141
|
+
return (
|
|
142
|
+
<ContextProviders
|
|
143
|
+
routeId="x"
|
|
144
|
+
routes={{
|
|
145
|
+
x: {
|
|
146
|
+
elements: {},
|
|
147
|
+
page: <WithFramerBreakpoints
|
|
148
|
+
Component={Component}
|
|
149
|
+
{...props}
|
|
150
|
+
/>,
|
|
151
|
+
path: '/',
|
|
152
|
+
},
|
|
153
|
+
}}
|
|
154
|
+
framerSiteId={${JSON.stringify(
|
|
155
|
+
config.fullFramerProjectId,
|
|
156
|
+
)}}
|
|
157
|
+
locale={locale}
|
|
158
|
+
locales={locales}
|
|
159
|
+
/>
|
|
160
|
+
)
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export default function ComponentWithRoot({ locale, ...rest }) {
|
|
164
|
+
return (
|
|
165
|
+
<ContextProviders
|
|
166
|
+
routeId="x"
|
|
167
|
+
routes={{
|
|
168
|
+
x: {
|
|
169
|
+
elements: {},
|
|
170
|
+
page: <Component {...rest} />,
|
|
171
|
+
path: '/',
|
|
172
|
+
},
|
|
173
|
+
}}
|
|
174
|
+
framerSiteId={${JSON.stringify(
|
|
175
|
+
config.fullFramerProjectId,
|
|
176
|
+
)}}
|
|
177
|
+
locale={locale}
|
|
178
|
+
locales={locales}
|
|
179
|
+
/>
|
|
180
|
+
)
|
|
181
|
+
}
|
|
182
|
+
Object.assign(ComponentWithRoot, Component)
|
|
137
183
|
`,
|
|
138
184
|
loader: 'jsx',
|
|
139
185
|
}
|
|
@@ -250,7 +296,11 @@ export async function bundle({
|
|
|
250
296
|
fileName: path.basename(file.path),
|
|
251
297
|
})),
|
|
252
298
|
)
|
|
253
|
-
const types = propControlsToType(
|
|
299
|
+
const types = propControlsToType({
|
|
300
|
+
controls: propertyControls!,
|
|
301
|
+
fileName: name,
|
|
302
|
+
config,
|
|
303
|
+
})
|
|
254
304
|
// name = 'framer-' + name
|
|
255
305
|
// logger.log('name', name)
|
|
256
306
|
fs.mkdirSync(out, { recursive: true })
|
|
@@ -528,7 +578,7 @@ export function getDarkModeSelector(opts: {
|
|
|
528
578
|
'}'
|
|
529
579
|
)
|
|
530
580
|
}
|
|
531
|
-
return '.dark
|
|
581
|
+
return '.dark {\n' + content + '\n' + '}'
|
|
532
582
|
}
|
|
533
583
|
|
|
534
584
|
export function getStyleTokensCss(
|
|
@@ -796,7 +846,15 @@ function safeJsonParse(text) {
|
|
|
796
846
|
}
|
|
797
847
|
}
|
|
798
848
|
|
|
799
|
-
export function propControlsToType(
|
|
849
|
+
export function propControlsToType({
|
|
850
|
+
config,
|
|
851
|
+
fileName,
|
|
852
|
+
controls,
|
|
853
|
+
}: {
|
|
854
|
+
controls: PropertyControls
|
|
855
|
+
fileName
|
|
856
|
+
config
|
|
857
|
+
}) {
|
|
800
858
|
try {
|
|
801
859
|
const types = Object.entries(controls || ({} as PropertyControls))
|
|
802
860
|
.map(([key, value]) => {
|
|
@@ -865,6 +923,7 @@ export function propControlsToType(controls: PropertyControls, fileName) {
|
|
|
865
923
|
const defaultPropsTypes =
|
|
866
924
|
[
|
|
867
925
|
'children?: React.ReactNode',
|
|
926
|
+
'locale?: Locale',
|
|
868
927
|
'style?: React.CSSProperties',
|
|
869
928
|
'className?: string',
|
|
870
929
|
'id?: string',
|
|
@@ -876,8 +935,14 @@ export function propControlsToType(controls: PropertyControls, fileName) {
|
|
|
876
935
|
.join('\n') + '\n'
|
|
877
936
|
let t = ''
|
|
878
937
|
t += '/* This file was generated by Unframer, do not edit manually */\n'
|
|
938
|
+
|
|
879
939
|
t += 'import * as React from "react"\n\n'
|
|
880
940
|
t += 'import { UnframerBreakpoint } from "unframer"\n\n'
|
|
941
|
+
t += `type Locale = ${
|
|
942
|
+
config.locales?.length
|
|
943
|
+
? config.locales.map((l) => `'${l.code}'`).join(' | ')
|
|
944
|
+
: 'string'
|
|
945
|
+
}\n`
|
|
881
946
|
t += `export interface Props {\n${defaultPropsTypes}${types}\n}\n\n`
|
|
882
947
|
t += `const ${componentName} = (props: Props) => any\n\n`
|
|
883
948
|
t += `type VariantsMap = Partial<Record<UnframerBreakpoint, Props['variant']>> & { base: Props['variant'] }\n\n`
|