eddev 0.2.2-beta.1 → 0.2.2-beta.10
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/blocks/ContentBlocks.js +4 -1
- package/blocks/blockAttributes.d.ts +4 -0
- package/blocks/blockAttributes.js +23 -7
- package/blocks/inlineEditing.d.ts +9 -3
- package/blocks/inlineEditing.js +28 -5
- package/blocks/installGutenbergHooks.js +15 -7
- package/build/graphql-codegen/graphql-codegen-blocks.js +0 -1
- package/build/serverless/create-next-app.js +0 -4
- package/build/workers/codegen-worker-script.js +3 -1
- package/cli/preinstall.js +11 -6
- package/dev-ui/components/ResponsiveScaleEditor.js +3 -3
- package/dev-ui/components/panels/TypographyEditor.js +10 -3
- package/hooks/useAppData.js +4 -0
- package/package.json +3 -3
- package/serverless-template/_utils/fetch-wp.ts +1 -0
- package/serverless-template/package.json +2 -2
- package/serverless-template/pages/_app.tsx +3 -1
- package/style/createStitches.js +30 -29
package/blocks/ContentBlocks.js
CHANGED
|
@@ -32,6 +32,9 @@ var react_1 = require("react");
|
|
|
32
32
|
var ErrorBoundaryFrontend_1 = require("./ErrorBoundaryFrontend");
|
|
33
33
|
exports.BlocksContext = (0, react_1.createContext)(undefined);
|
|
34
34
|
function ContentBlocks(props) {
|
|
35
|
+
if (process.admin) {
|
|
36
|
+
throw new Error("ContentBlocks should only be used on the frontend.");
|
|
37
|
+
}
|
|
35
38
|
if (!Array.isArray(props.blocks))
|
|
36
39
|
return null;
|
|
37
40
|
var parentContext = (0, react_1.useContext)(exports.BlocksContext);
|
|
@@ -45,7 +48,7 @@ function ContentBlocks(props) {
|
|
|
45
48
|
var Component = blocks_1.default[block.blockName];
|
|
46
49
|
if (!Component)
|
|
47
50
|
return (0, jsx_runtime_1.jsx)(react_1.Fragment, {}, void 0);
|
|
48
|
-
blockNode = ((0, jsx_runtime_1.jsx)(blockAttributes_1.InlineEditingContextProvider, __assign({ values: block.inline, innerBlocks: block.innerBlocks }, { children: (0, jsx_runtime_1.jsx)(Component, __assign({}, block.props, { innerHTML: block.innerHTML,
|
|
51
|
+
blockNode = ((0, jsx_runtime_1.jsx)(blockAttributes_1.InlineEditingContextProvider, __assign({ block: [block.blockName, block.props], values: block.inline, innerBlocks: block.innerBlocks }, { children: (0, jsx_runtime_1.jsx)(Component, __assign({}, block.props, { innerHTML: block.innerHTML,
|
|
49
52
|
// innerBlocks={block.innerBlocks}
|
|
50
53
|
children: Array.isArray(block.innerBlocks) && block.innerBlocks.length ? ((0, jsx_runtime_1.jsx)(ContentBlocks, { blocks: block.innerBlocks }, void 0)) : null }), void 0) }), void 0));
|
|
51
54
|
}
|
|
@@ -6,9 +6,13 @@ interface Attributes {
|
|
|
6
6
|
declare type ProviderProps = PropsWithChildren<{
|
|
7
7
|
values: Attributes;
|
|
8
8
|
innerBlocks: ContentBlock[];
|
|
9
|
+
block: [string, Attributes];
|
|
9
10
|
onChange?: (attrs: Attributes) => void;
|
|
11
|
+
insertBlocksAfter?: (block: any) => void;
|
|
10
12
|
}>;
|
|
11
13
|
export declare function InlineEditingContextProvider(props: ProviderProps): JSX.Element;
|
|
12
14
|
export declare function useInlineEditableValue<T>(key: string, defaultValue?: T): [T, (value: T) => void];
|
|
15
|
+
export declare function useBlockAppender(): ((block: any) => void) | undefined;
|
|
13
16
|
export declare function useInnerBlocks(): ContentBlock[];
|
|
17
|
+
export declare function useBlockParents(): [string, Attributes][];
|
|
14
18
|
export {};
|
|
@@ -10,15 +10,26 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
};
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
14
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
15
|
+
if (ar || !(i in from)) {
|
|
16
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
17
|
+
ar[i] = from[i];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
21
|
+
};
|
|
13
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.useInnerBlocks = exports.useInlineEditableValue = exports.InlineEditingContextProvider = void 0;
|
|
23
|
+
exports.useBlockParents = exports.useInnerBlocks = exports.useBlockAppender = exports.useInlineEditableValue = exports.InlineEditingContextProvider = void 0;
|
|
15
24
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
16
25
|
var react_1 = require("react");
|
|
17
26
|
var InlineEditingContext = (0, react_1.createContext)(undefined);
|
|
18
27
|
function InlineEditingContextProvider(props) {
|
|
28
|
+
var parentContext = (0, react_1.useContext)(InlineEditingContext);
|
|
19
29
|
return ((0, jsx_runtime_1.jsx)(InlineEditingContext.Provider, __assign({ value: {
|
|
20
30
|
values: props.values,
|
|
21
31
|
innerBlocks: props.innerBlocks,
|
|
32
|
+
parents: __spreadArray(__spreadArray([], ((parentContext === null || parentContext === void 0 ? void 0 : parentContext.parents) || []), true), [props.block], false).filter(Boolean),
|
|
22
33
|
getValue: function (key) {
|
|
23
34
|
var _a;
|
|
24
35
|
return (_a = props.values) === null || _a === void 0 ? void 0 : _a[key];
|
|
@@ -29,6 +40,7 @@ function InlineEditingContextProvider(props) {
|
|
|
29
40
|
props.onChange(__assign(__assign({}, (props.values || {})), (_a = {}, _a[key] = value, _a)));
|
|
30
41
|
}
|
|
31
42
|
},
|
|
43
|
+
insertBlocksAfter: props.insertBlocksAfter,
|
|
32
44
|
} }, { children: props.children }), void 0));
|
|
33
45
|
}
|
|
34
46
|
exports.InlineEditingContextProvider = InlineEditingContextProvider;
|
|
@@ -43,14 +55,18 @@ function useInlineEditableValue(key, defaultValue) {
|
|
|
43
55
|
];
|
|
44
56
|
}
|
|
45
57
|
exports.useInlineEditableValue = useInlineEditableValue;
|
|
58
|
+
function useBlockAppender() {
|
|
59
|
+
var ctx = (0, react_1.useContext)(InlineEditingContext);
|
|
60
|
+
return ctx === null || ctx === void 0 ? void 0 : ctx.insertBlocksAfter;
|
|
61
|
+
}
|
|
62
|
+
exports.useBlockAppender = useBlockAppender;
|
|
46
63
|
function useInnerBlocks() {
|
|
47
64
|
var ctx = (0, react_1.useContext)(InlineEditingContext);
|
|
48
65
|
return (ctx === null || ctx === void 0 ? void 0 : ctx.innerBlocks) || [];
|
|
49
|
-
// return [
|
|
50
|
-
// attrs?.getValue(key),
|
|
51
|
-
// (value: any) => {
|
|
52
|
-
// attrs?.setValue(key, value)
|
|
53
|
-
// },
|
|
54
|
-
// ] as [T, (value: T) => void]
|
|
55
66
|
}
|
|
56
67
|
exports.useInnerBlocks = useInnerBlocks;
|
|
68
|
+
function useBlockParents() {
|
|
69
|
+
var ctx = (0, react_1.useContext)(InlineEditingContext);
|
|
70
|
+
return (ctx === null || ctx === void 0 ? void 0 : ctx.parents) || [];
|
|
71
|
+
}
|
|
72
|
+
exports.useBlockParents = useBlockParents;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ElementType } from "react";
|
|
1
|
+
import { ElementType, FunctionComponent } from "react";
|
|
2
2
|
import { ContentBlocksSettings } from ".";
|
|
3
3
|
declare type PropTypes<T extends ElementType> = {
|
|
4
4
|
/** The 'key' of this editable text value */
|
|
@@ -11,14 +11,20 @@ declare type PropTypes<T extends ElementType> = {
|
|
|
11
11
|
inlineToolbar?: boolean;
|
|
12
12
|
/** Specify default content to use on the frontend if nothing has been entered */
|
|
13
13
|
defaultValue?: string;
|
|
14
|
+
/** Append a new block when the user hits 'Enter' */
|
|
15
|
+
appendOnEnter?: boolean;
|
|
14
16
|
} & React.ComponentPropsWithoutRef<T>;
|
|
15
|
-
export declare function EditableText<T extends ElementType>({ id, as, ...props }: PropTypes<T>): JSX.Element | null;
|
|
17
|
+
export declare function EditableText<T extends ElementType>({ id, as, appendOnEnter, ...props }: PropTypes<T>): JSX.Element | null;
|
|
18
|
+
declare type AppenderConfig = {
|
|
19
|
+
type: "default" | "button" | FunctionComponent<any>;
|
|
20
|
+
block?: boolean;
|
|
21
|
+
};
|
|
16
22
|
declare type InnerBlocksProps = {
|
|
17
23
|
allowedBlocks?: string[];
|
|
18
24
|
orientation?: "horizontal" | "vertical";
|
|
19
25
|
templateLock?: any;
|
|
20
26
|
template?: any;
|
|
21
|
-
|
|
27
|
+
appender?: AppenderConfig;
|
|
22
28
|
} & ContentBlocksSettings;
|
|
23
29
|
export declare function InnerBlocks(props: InnerBlocksProps): JSX.Element;
|
|
24
30
|
export {};
|
package/blocks/inlineEditing.js
CHANGED
|
@@ -24,8 +24,9 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
25
|
exports.InnerBlocks = exports.EditableText = void 0;
|
|
26
26
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
27
|
-
// @ts-ignore
|
|
28
27
|
var block_editor_1 = require("@wordpress/block-editor");
|
|
28
|
+
// @ts-ignore
|
|
29
|
+
var blocks_1 = require("@wordpress/blocks");
|
|
29
30
|
var ContentBlocks_1 = require("./ContentBlocks");
|
|
30
31
|
var react_1 = require("react");
|
|
31
32
|
var blockAttributes_1 = require("./blockAttributes");
|
|
@@ -33,10 +34,17 @@ var react_2 = require("@stitches/react");
|
|
|
33
34
|
var remoteProps_1 = require("../routing/remoteProps");
|
|
34
35
|
var __1 = require("..");
|
|
35
36
|
function EditableText(_a) {
|
|
36
|
-
var id = _a.id, as = _a.as, props = __rest(_a, ["id", "as"]);
|
|
37
|
+
var id = _a.id, as = _a.as, appendOnEnter = _a.appendOnEnter, props = __rest(_a, ["id", "as", "appendOnEnter"]);
|
|
37
38
|
if (process.admin) {
|
|
38
39
|
var _b = (0, blockAttributes_1.useInlineEditableValue)(id), value = _b[0], setValue = _b[1];
|
|
39
|
-
|
|
40
|
+
var appendBlocks_1 = (0, blockAttributes_1.useBlockAppender)();
|
|
41
|
+
return ((0, jsx_runtime_1.jsx)(block_editor_1.RichText, __assign({}, props, { tagName: as, value: value || "", onChange: setValue, disableLineBreaks: props.disableLineBreaks, onKeyDownCapture: function (e) {
|
|
42
|
+
if (e.key === "Enter" && appendOnEnter && appendBlocks_1) {
|
|
43
|
+
appendBlocks_1([(0, blocks_1.createBlock)("core/paragraph")]);
|
|
44
|
+
e.preventDefault();
|
|
45
|
+
e.stopPropagation();
|
|
46
|
+
}
|
|
47
|
+
} }), void 0));
|
|
40
48
|
}
|
|
41
49
|
else {
|
|
42
50
|
var value = (0, blockAttributes_1.useInlineEditableValue)(id)[0];
|
|
@@ -66,11 +74,23 @@ function EditableText(_a) {
|
|
|
66
74
|
}
|
|
67
75
|
}
|
|
68
76
|
exports.EditableText = EditableText;
|
|
77
|
+
var Appender = function (props) {
|
|
78
|
+
if (props.type === "button") {
|
|
79
|
+
return (0, jsx_runtime_1.jsx)(block_editor_1.ButtonBlockAppender, {}, void 0);
|
|
80
|
+
}
|
|
81
|
+
else if (typeof props.type === "function") {
|
|
82
|
+
return props.type({});
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
return (0, jsx_runtime_1.jsx)(block_editor_1.DefaultBlockAppender, {}, void 0);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
69
88
|
function InnerBlocks(props) {
|
|
70
89
|
if (process.admin) {
|
|
71
90
|
var allowedBlocks = props.allowedBlocks;
|
|
72
|
-
|
|
73
|
-
|
|
91
|
+
return ((0, jsx_runtime_1.jsx)(InnerBlocksAdminWrapper, __assign({ orientation: props.orientation || "vertical" }, { children: (0, jsx_runtime_1.jsx)(block_editor_1.InnerBlocks, { orientation: props.orientation, allowedBlocks: allowedBlocks,
|
|
92
|
+
// renderAppender={() => <Appender {...props.appender} />}
|
|
93
|
+
templateLock: props.templateLock, template: props.template }, void 0) }), void 0));
|
|
74
94
|
}
|
|
75
95
|
else {
|
|
76
96
|
var blocks = (0, blockAttributes_1.useInnerBlocks)();
|
|
@@ -87,6 +107,9 @@ var InnerBlocksAdminWrapper = (0, react_2.styled)("div", {
|
|
|
87
107
|
// marginRight: "auto",
|
|
88
108
|
maxWidth: "var(--grid-inner-width)",
|
|
89
109
|
},
|
|
110
|
+
".block-editor-block-list__block .block-list-appender:only-child": {
|
|
111
|
+
alignSelf: "auto !important",
|
|
112
|
+
},
|
|
90
113
|
variants: {
|
|
91
114
|
orientation: {
|
|
92
115
|
vertical: {
|
|
@@ -47,6 +47,11 @@ function installEDGutenbergHooks() {
|
|
|
47
47
|
if (!window.wp.blockEditor)
|
|
48
48
|
return;
|
|
49
49
|
(0, react_2.globalCss)({
|
|
50
|
+
".edit-post-visual-editor__post-title-wrapper": {
|
|
51
|
+
width: "var(--grid-inner-width)",
|
|
52
|
+
marginLeft: "auto",
|
|
53
|
+
marginRight: "auto",
|
|
54
|
+
},
|
|
50
55
|
".block-editor-block-list__block:hover": {
|
|
51
56
|
outline: "1px solid #e1e1e1",
|
|
52
57
|
},
|
|
@@ -84,19 +89,17 @@ function installEDGutenbergHooks() {
|
|
|
84
89
|
// @ts-ignore
|
|
85
90
|
window.wp.data.dispatch("core/block-editor").setTemplateValidity(true);
|
|
86
91
|
}, []);
|
|
87
|
-
console.log("PROPS", props);
|
|
88
|
-
// console.log(useBlockProps(), useBlockEditContext(), useInnerBlocksProps())
|
|
89
92
|
var children = (0, data_1.useSelect)(function (select) {
|
|
90
|
-
var _a = select(
|
|
93
|
+
var _a = select("core/block-editor"), getBlock = _a.getBlock, getBlockOrder = _a.getBlockOrder;
|
|
91
94
|
var innerBlockIDs = getBlockOrder(props.clientId);
|
|
92
95
|
var children = innerBlockIDs.map(function (id) {
|
|
93
96
|
return getBlock(id);
|
|
94
97
|
});
|
|
95
98
|
return children;
|
|
96
99
|
}, []);
|
|
97
|
-
return ((0, jsx_runtime_1.jsx)(BlockContext.Provider, __assign({ value: { name: name, props: props } }, { children: (0, jsx_runtime_1.jsx)(blockAttributes_1.InlineEditingContextProvider, __assign({ values: props.attributes.inline || {}, innerBlocks: children, onChange: function (attrs) {
|
|
100
|
+
return ((0, jsx_runtime_1.jsx)(BlockContext.Provider, __assign({ value: { name: name, props: props } }, { children: (0, jsx_runtime_1.jsx)(blockAttributes_1.InlineEditingContextProvider, __assign({ values: props.attributes.inline || {}, innerBlocks: children, block: [name, props], onChange: function (attrs) {
|
|
98
101
|
props.setAttributes(__assign(__assign({}, props.attributes), { inline: attrs }));
|
|
99
|
-
} }, { children: edit_1.call(self, props) }), void 0) }), void 0));
|
|
102
|
+
}, insertBlocksAfter: props.insertBlocksAfter }, { children: edit_1.call(self, props) }), void 0) }), void 0));
|
|
100
103
|
};
|
|
101
104
|
}
|
|
102
105
|
// Remember the block type name
|
|
@@ -166,8 +169,13 @@ function installEDGutenbergHooks() {
|
|
|
166
169
|
var parseJSX = acf.parseJSX;
|
|
167
170
|
// @ts-ignore
|
|
168
171
|
acf.parseJSX = function (html) {
|
|
169
|
-
|
|
170
|
-
|
|
172
|
+
var payload;
|
|
173
|
+
try {
|
|
174
|
+
payload = JSON.parse(html.replace(/(^[^>]+>|<[^>]+>$)/g, ""));
|
|
175
|
+
}
|
|
176
|
+
catch (err) {
|
|
177
|
+
throw new Error("eddev: Error parsing block data from: \n" + html);
|
|
178
|
+
}
|
|
171
179
|
return (0, jsx_runtime_1.jsx)(BlockRenderer, { payload: payload }, void 0);
|
|
172
180
|
};
|
|
173
181
|
}
|
|
@@ -185,10 +185,6 @@ function createNextApp(opts) {
|
|
|
185
185
|
// Write APIs proxy code
|
|
186
186
|
_b.sent();
|
|
187
187
|
// Remove pages/api/trpc directory if no _rpc is found
|
|
188
|
-
console.log({
|
|
189
|
-
index: (0, path_1.join)(opts.baseDirectory, "apis/_rpc/index.ts"),
|
|
190
|
-
rpc: (0, path_1.join)(opts.baseDirectory, "apis/_rpc.ts"),
|
|
191
|
-
});
|
|
192
188
|
if (!(0, fs_1.existsSync)((0, path_1.join)(opts.baseDirectory, "apis/_rpc/index.ts")) &&
|
|
193
189
|
!(0, fs_1.existsSync)((0, path_1.join)(opts.baseDirectory, "apis/_rpc.ts"))) {
|
|
194
190
|
// removeSync(join(serverlessDirectory, "pages/api/trpc"))
|
|
@@ -181,7 +181,9 @@ function beginWork(opts) {
|
|
|
181
181
|
if (!endpoint) {
|
|
182
182
|
sendSignal({
|
|
183
183
|
code: "error",
|
|
184
|
-
errors: [
|
|
184
|
+
errors: [
|
|
185
|
+
"Could not find DEBUG_GRAPHQL_URL value in .env. This will be automatically populated once you visit WP Admin first the first time!",
|
|
186
|
+
],
|
|
185
187
|
});
|
|
186
188
|
regenerating = false;
|
|
187
189
|
return [2 /*return*/];
|
package/cli/preinstall.js
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.main = void 0;
|
|
4
|
-
var
|
|
5
|
-
var path_1 = require("path");
|
|
4
|
+
var child_process_1 = require("child_process");
|
|
6
5
|
function main() {
|
|
6
|
+
var _a, _b;
|
|
7
7
|
if (process.env.VERCEL) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
pkg.devDependencies["next"] = "^12.1.0"
|
|
11
|
-
|
|
8
|
+
// const pkgFile = join(process.cwd(), "package.json")
|
|
9
|
+
// const pkg = JSON.parse(readFileSync(pkgFile).toString()) as any
|
|
10
|
+
// pkg.devDependencies["next"] = "^12.1.0"
|
|
11
|
+
// writeFile(pkgFile, JSON.stringify(pkg, null, " "), () => {})
|
|
12
|
+
var proc = (0, child_process_1.spawn)("yarn", ["add", "--dev", "next@^12.1.0"], {
|
|
13
|
+
cwd: process.cwd(),
|
|
14
|
+
});
|
|
15
|
+
(_a = proc.stdout) === null || _a === void 0 ? void 0 : _a.pipe(process.stdout);
|
|
16
|
+
(_b = proc.stderr) === null || _b === void 0 ? void 0 : _b.pipe(process.stderr);
|
|
12
17
|
}
|
|
13
18
|
}
|
|
14
19
|
exports.main = main;
|
|
@@ -69,7 +69,6 @@ function ResponsiveScaleEditor(props) {
|
|
|
69
69
|
var nextValue;
|
|
70
70
|
if (item.type === "px" && nextType === "multiplier") {
|
|
71
71
|
if (base) {
|
|
72
|
-
console.log(item.value, base.concreteValue);
|
|
73
72
|
nextValue = "x" + item.value / (base === null || base === void 0 ? void 0 : base.concreteValue);
|
|
74
73
|
}
|
|
75
74
|
}
|
|
@@ -112,8 +111,9 @@ function ResponsiveScaleEditor(props) {
|
|
|
112
111
|
}
|
|
113
112
|
else {
|
|
114
113
|
props.onChange((0, immer_1.default)(values, function (values) {
|
|
114
|
+
var _a;
|
|
115
115
|
for (var token in values) {
|
|
116
|
-
var original = _theme_1.originalConfig.responsive.space[token]["@" + breakpoint];
|
|
116
|
+
var original = (_a = _theme_1.originalConfig.responsive.space[token]) === null || _a === void 0 ? void 0 : _a["@" + breakpoint];
|
|
117
117
|
var value = original;
|
|
118
118
|
if (!value) {
|
|
119
119
|
value = values[token]["@" + item.baseBreakpoint];
|
|
@@ -125,7 +125,7 @@ function ResponsiveScaleEditor(props) {
|
|
|
125
125
|
}));
|
|
126
126
|
}
|
|
127
127
|
};
|
|
128
|
-
return ((0, jsx_runtime_1.jsxs)(Wrapper, __assign({ css: { $$total: props.
|
|
128
|
+
return ((0, jsx_runtime_1.jsxs)(Wrapper, __assign({ css: { $$total: props.breakpoints.length, $$labelWidth: props.labelWidth } }, { children: [props.showBreakpointName && ((0, jsx_runtime_1.jsx)(Row, __assign({ heading: true }, { children: rows[0].row.map(function (item, i) {
|
|
129
129
|
var bp = props.breakpoints[i];
|
|
130
130
|
return ((0, jsx_runtime_1.jsx)(Col, __assign({ css: { textAlign: "center" } }, { children: (0, jsx_runtime_1.jsx)(Tooltip_1.Tooltip, __assign({ label: "".concat(bp.min, " to ").concat(bp.max || "∞"), mono: true, nowrap: true }, { children: (0, jsx_runtime_1.jsx)(ToggleButton_1.ToggleButton, { checked: item.defined, onChange: function (checked) {
|
|
131
131
|
onToggleBreakpoint === null || onToggleBreakpoint === void 0 ? void 0 : onToggleBreakpoint(item, checked);
|
|
@@ -24,6 +24,7 @@ var Button_1 = require("../atoms/Button");
|
|
|
24
24
|
var Spacer_1 = require("../atoms/Spacer");
|
|
25
25
|
var Text_1 = require("../atoms/Text");
|
|
26
26
|
var PanelWrapper_1 = require("../PanelWrapper");
|
|
27
|
+
var ResponsiveScaleEditor_1 = require("../ResponsiveScaleEditor");
|
|
27
28
|
function TypographyEditor() {
|
|
28
29
|
var _a = (0, react_1.useState)(function () { return _theme_1.originalConfig.typography; }), values = _a[0], setValues = _a[1];
|
|
29
30
|
var parsedBreakpoints = (0, style_1.parseBreakpoints)(_theme_1.originalConfig.breakpoints, _theme_1.originalConfig.media);
|
|
@@ -49,9 +50,15 @@ function TypographyEditor() {
|
|
|
49
50
|
// })
|
|
50
51
|
} }, { children: [icons_1.paste, "Paste"] }), void 0), (0, jsx_runtime_1.jsx)(Spacer_1.Spacer, {}, void 0), (0, jsx_runtime_1.jsxs)(Button_1.Button, __assign({ small: true, onClick: reset }, { children: [icons_1.trash, " Reset"] }), void 0)] }, void 0) }, { children: (0, jsx_runtime_1.jsx)(Wrapper, { children: Object.entries(values).map(function (_a, index) {
|
|
51
52
|
var name = _a[0], settings = _a[1];
|
|
52
|
-
return ((0, jsx_runtime_1.jsxs)(TypographyItem, { children: [(0, jsx_runtime_1.jsx)(Meta, { children: (0, jsx_runtime_1.jsx)(Text_1.Text, __assign({ variant: "monoBold" }, { children: name }), void 0) }, void 0), (0, jsx_runtime_1.
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
return ((0, jsx_runtime_1.jsxs)(TypographyItem, { children: [(0, jsx_runtime_1.jsx)(Meta, { children: (0, jsx_runtime_1.jsx)(Text_1.Text, __assign({ variant: "monoBold" }, { children: name }), void 0) }, void 0), (0, jsx_runtime_1.jsxs)(Details, { children: [(0, jsx_runtime_1.jsx)(Preview, { css: { typography: name }, value: previewText, onChange: function (e) {
|
|
54
|
+
setPreviewText(e.currentTarget.value);
|
|
55
|
+
} }, void 0), (0, jsx_runtime_1.jsx)(ResponsiveScaleEditor_1.ResponsiveScaleEditor, { editableRange: true, editableValues: true, breakpoints: parsedBreakpoints, data: {
|
|
56
|
+
fontSize: settings.fontSize,
|
|
57
|
+
lineHeight: settings.lineHeight,
|
|
58
|
+
}, showBreakpointName: true, showRange: true, showValues: true, labelWidth: "80px", onChange: function (data) {
|
|
59
|
+
var _a;
|
|
60
|
+
setValues(__assign(__assign({}, values), (_a = {}, _a[name] = __assign(__assign({}, settings), { fontSize: data.fontSize, lineHeight: data.lineHeight }), _a)));
|
|
61
|
+
}, modes: ["px", "multiplier"] }, void 0)] }, void 0)] }, index));
|
|
55
62
|
}) }, void 0) }), void 0));
|
|
56
63
|
}
|
|
57
64
|
exports.TypographyEditor = TypographyEditor;
|
package/hooks/useAppData.js
CHANGED
|
@@ -22,6 +22,10 @@ function useAppData(selector) {
|
|
|
22
22
|
return selector(value);
|
|
23
23
|
return value;
|
|
24
24
|
}
|
|
25
|
+
else if (process.admin) {
|
|
26
|
+
// @ts-ignore
|
|
27
|
+
return selector ? selector(__ED_APP_DATA.data) : __ED_APP_DATA.data;
|
|
28
|
+
}
|
|
25
29
|
else {
|
|
26
30
|
return useAppDataStore(function (store) {
|
|
27
31
|
if (selector)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eddev",
|
|
3
|
-
"version": "0.2.2-beta.
|
|
3
|
+
"version": "0.2.2-beta.10",
|
|
4
4
|
"main": "./index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
@@ -48,8 +48,8 @@
|
|
|
48
48
|
"@loadable/webpack-plugin": "^5.15.2",
|
|
49
49
|
"@pmmmwh/react-refresh-webpack-plugin": "^0.4.3",
|
|
50
50
|
"@soda/friendly-errors-webpack-plugin": "^1.8.0",
|
|
51
|
-
"@stitches/core": "^1.2.
|
|
52
|
-
"@stitches/react": "^1.2.
|
|
51
|
+
"@stitches/core": "^1.2.7",
|
|
52
|
+
"@stitches/react": "^1.2.7",
|
|
53
53
|
"@trpc/client": "^9.19.0",
|
|
54
54
|
"@trpc/next": "^9.19.0",
|
|
55
55
|
"@trpc/react": "^9.19.0",
|
|
@@ -26,7 +26,9 @@ function Root({ Component, pageProps }: AppProps) {
|
|
|
26
26
|
|
|
27
27
|
if (!appData) return <div />
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
if (!View) {
|
|
30
|
+
console.log(`Could not load view named "${pageProps.view}"`)
|
|
31
|
+
}
|
|
30
32
|
|
|
31
33
|
return (
|
|
32
34
|
<ServerlessAppDataProvider value={appData}>
|
package/style/createStitches.js
CHANGED
|
@@ -78,11 +78,11 @@ function parseTypography(theme, breakpoints, typography) {
|
|
|
78
78
|
return value;
|
|
79
79
|
}
|
|
80
80
|
};
|
|
81
|
-
var
|
|
81
|
+
for (var name_1 in typography) {
|
|
82
82
|
var style = typography[name_1];
|
|
83
83
|
var variant = {};
|
|
84
84
|
typeVariants[name_1] = variant;
|
|
85
|
-
var
|
|
85
|
+
for (var key in style) {
|
|
86
86
|
var value = style[key];
|
|
87
87
|
var varName = "--type-".concat(name_1, "-").concat(key);
|
|
88
88
|
variant[key] = "var(".concat(varName, ")");
|
|
@@ -93,36 +93,37 @@ function parseTypography(theme, breakpoints, typography) {
|
|
|
93
93
|
}
|
|
94
94
|
else if (value && typeof value === "object") {
|
|
95
95
|
// A responsive object value
|
|
96
|
-
var
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
96
|
+
var unit = key === "lineHeight" ? "%" : "px";
|
|
97
|
+
var _a = getResponsiveObjectStyles(breakpoints, value, varName, unit), tokenGlobals = _a[0], initial = _a[1];
|
|
98
|
+
for (var key_1 in tokenGlobals) {
|
|
99
|
+
globals[key_1] = __assign(__assign({}, globals[key_1]), tokenGlobals[key_1]);
|
|
100
|
+
}
|
|
101
|
+
// const entries = Object.entries(value)
|
|
102
|
+
// entries.forEach(([bpName, responsiveValue], i) => {
|
|
103
|
+
// if (Array.isArray(responsiveValue)) {
|
|
104
|
+
// responsiveValue = responsiveValue[0]
|
|
105
|
+
// // An array in the format [value] signifies font locking between the current breakpoint and the next defined one
|
|
106
|
+
// const minSize = breakpoints.find((bp) => "@" + bp.key === bpName)?.min
|
|
107
|
+
// const nextBreakpoint = breakpoints.find((bp) => "@" + bp.key === entries[i + 1]?.[0])
|
|
108
|
+
// if (!nextBreakpoint)
|
|
109
|
+
// throw new Error(
|
|
110
|
+
// `Cannot create responsive '${key}' for '${name}' at breakpoint '${bpName}', since it is the last-defined breakpoint. Your last size should be a string/number/token.`
|
|
111
|
+
// )
|
|
112
|
+
// const maxSize = nextBreakpoint.min
|
|
113
|
+
// let responsiveValue2 = (value as any)["@" + nextBreakpoint.key]
|
|
114
|
+
// if (Array.isArray(responsiveValue2)) responsiveValue2 = responsiveValue2[0]
|
|
115
|
+
// let size1 = resolveValue(tokenPrefix, responsiveValue)
|
|
116
|
+
// let size2 = resolveValue(tokenPrefix, responsiveValue2)
|
|
117
|
+
// responsiveValue = `calc(${size1} + (100vw - ${minSize}) / (${unitless(maxSize)} - ${unitless(
|
|
118
|
+
// minSize
|
|
119
|
+
// )}) * (${unitless(size2)} - ${unitless(size1)}))`
|
|
120
|
+
// }
|
|
121
|
+
// globals[bpName][varName] = responsiveValue
|
|
122
|
+
// })
|
|
117
123
|
}
|
|
118
|
-
};
|
|
119
|
-
for (var key in style) {
|
|
120
|
-
_loop_2(key);
|
|
121
124
|
}
|
|
122
|
-
};
|
|
123
|
-
for (var name_1 in typography) {
|
|
124
|
-
_loop_1(name_1);
|
|
125
125
|
}
|
|
126
|
+
// debugger
|
|
126
127
|
return { globalTypography: globals, typeVariants: typeVariants };
|
|
127
128
|
}
|
|
128
129
|
function parseGrid(theme, media, grid) {
|