eddev 0.2.2-beta.5 → 0.2.2-beta.8

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.
@@ -48,7 +48,7 @@ function ContentBlocks(props) {
48
48
  var Component = blocks_1.default[block.blockName];
49
49
  if (!Component)
50
50
  return (0, jsx_runtime_1.jsx)(react_1.Fragment, {}, void 0);
51
- 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,
52
52
  // innerBlocks={block.innerBlocks}
53
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));
54
54
  }
@@ -6,6 +6,7 @@ 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;
10
11
  insertBlocksAfter?: (block: any) => void;
11
12
  }>;
@@ -13,4 +14,5 @@ export declare function InlineEditingContextProvider(props: ProviderProps): JSX.
13
14
  export declare function useInlineEditableValue<T>(key: string, defaultValue?: T): [T, (value: T) => void];
14
15
  export declare function useBlockAppender(): ((block: any) => void) | undefined;
15
16
  export declare function useInnerBlocks(): ContentBlock[];
17
+ export declare function useBlockParents(): [string, Attributes][];
16
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.useBlockAppender = 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];
@@ -52,11 +63,10 @@ exports.useBlockAppender = useBlockAppender;
52
63
  function useInnerBlocks() {
53
64
  var ctx = (0, react_1.useContext)(InlineEditingContext);
54
65
  return (ctx === null || ctx === void 0 ? void 0 : ctx.innerBlocks) || [];
55
- // return [
56
- // attrs?.getValue(key),
57
- // (value: any) => {
58
- // attrs?.setValue(key, value)
59
- // },
60
- // ] as [T, (value: T) => void]
61
66
  }
62
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 */
@@ -16,7 +16,8 @@ declare type PropTypes<T extends ElementType> = {
16
16
  } & React.ComponentPropsWithoutRef<T>;
17
17
  export declare function EditableText<T extends ElementType>({ id, as, appendOnEnter, ...props }: PropTypes<T>): JSX.Element | null;
18
18
  declare type AppenderConfig = {
19
- button?: boolean;
19
+ type: "default" | "button" | FunctionComponent<any>;
20
+ block?: boolean;
20
21
  };
21
22
  declare type InnerBlocksProps = {
22
23
  allowedBlocks?: string[];
@@ -24,7 +24,6 @@ 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");
29
28
  // @ts-ignore
30
29
  var blocks_1 = require("@wordpress/blocks");
@@ -75,11 +74,22 @@ function EditableText(_a) {
75
74
  }
76
75
  }
77
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
+ };
78
88
  function InnerBlocks(props) {
79
89
  if (process.admin) {
80
90
  var allowedBlocks = props.allowedBlocks;
81
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,
82
- // renderAppender={ButtonBlockAppender}
92
+ // renderAppender={() => <Appender {...props.appender} />}
83
93
  templateLock: props.templateLock, template: props.template }, void 0) }), void 0));
84
94
  }
85
95
  else {
@@ -97,6 +107,9 @@ var InnerBlocksAdminWrapper = (0, react_2.styled)("div", {
97
107
  // marginRight: "auto",
98
108
  maxWidth: "var(--grid-inner-width)",
99
109
  },
110
+ ".block-editor-block-list__block .block-list-appender:only-child": {
111
+ alignSelf: "auto !important",
112
+ },
100
113
  variants: {
101
114
  orientation: {
102
115
  vertical: {
@@ -97,7 +97,7 @@ function installEDGutenbergHooks() {
97
97
  });
98
98
  return children;
99
99
  }, []);
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, 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) {
101
101
  props.setAttributes(__assign(__assign({}, props.attributes), { inline: attrs }));
102
102
  }, insertBlocksAfter: props.insertBlocksAfter }, { children: edit_1.call(self, props) }), void 0) }), void 0));
103
103
  };
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 fs_1 = require("fs");
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
- var pkgFile = (0, path_1.join)(process.cwd(), "package.json");
9
- var pkg = JSON.parse((0, fs_1.readFileSync)(pkgFile).toString());
10
- pkg.devDependencies["next"] = "^12.1.0";
11
- (0, fs_1.writeFile)(pkgFile, JSON.stringify(pkg, null, " "), function () { });
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.data.length, $$labelWidth: props.labelWidth } }, { children: [props.showBreakpointName && ((0, jsx_runtime_1.jsx)(Row, __assign({ heading: true }, { children: rows[0].row.map(function (item, i) {
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.jsx)(Details, { children: (0, jsx_runtime_1.jsx)(Preview, { css: { typography: name }, value: previewText, onChange: function (e) {
53
- setPreviewText(e.currentTarget.value);
54
- } }, void 0) }, void 0)] }, index));
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eddev",
3
- "version": "0.2.2-beta.5",
3
+ "version": "0.2.2-beta.8",
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.6",
52
- "@stitches/react": "^1.2.6",
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",
@@ -78,11 +78,11 @@ function parseTypography(theme, breakpoints, typography) {
78
78
  return value;
79
79
  }
80
80
  };
81
- var _loop_1 = function (name_1) {
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 _loop_2 = function (key) {
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 entries_1 = Object.entries(value);
97
- entries_1.forEach(function (_a, i) {
98
- var _b;
99
- var bpName = _a[0], responsiveValue = _a[1];
100
- if (Array.isArray(responsiveValue)) {
101
- responsiveValue = responsiveValue[0];
102
- // An array in the format [value] signifies font locking between the current breakpoint and the next defined one
103
- var minSize = (_b = breakpoints.find(function (bp) { return "@" + bp.key === bpName; })) === null || _b === void 0 ? void 0 : _b.min;
104
- var nextBreakpoint = breakpoints.find(function (bp) { var _a; return "@" + bp.key === ((_a = entries_1[i + 1]) === null || _a === void 0 ? void 0 : _a[0]); });
105
- if (!nextBreakpoint)
106
- throw new Error("Cannot create responsive '".concat(key, "' for '").concat(name_1, "' at breakpoint '").concat(bpName, "', since it is the last-defined breakpoint. Your last size should be a string/number/token."));
107
- var maxSize = nextBreakpoint.min;
108
- var responsiveValue2 = value["@" + nextBreakpoint.key];
109
- if (Array.isArray(responsiveValue2))
110
- responsiveValue2 = responsiveValue2[0];
111
- var size1 = resolveValue(tokenPrefix, responsiveValue);
112
- var size2 = resolveValue(tokenPrefix, responsiveValue2);
113
- responsiveValue = "calc(".concat(size1, " + (100vw - ").concat(minSize, ") / (").concat(unitless(maxSize), " - ").concat(unitless(minSize), ") * (").concat(unitless(size2), " - ").concat(unitless(size1), "))");
114
- }
115
- globals[bpName][varName] = responsiveValue;
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) {