eddev 0.1.40-beta-1 → 0.1.43

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.
@@ -16,8 +16,7 @@ declare type BlocksContext = {
16
16
  current: ContentBlock;
17
17
  };
18
18
  export declare const BlocksContext: import("react").Context<BlocksContext | undefined>;
19
- declare type Props = {
20
- blocks: ContentBlock[];
19
+ export declare type ContentBlocksSettings = {
21
20
  wrapBlock?: (child: ReactElement, ctx: BlocksContext) => ReactElement;
22
21
  spacer?: (ctx: {
23
22
  ancestors: ContentBlock[];
@@ -26,6 +25,9 @@ declare type Props = {
26
25
  next: ContentBlock | null;
27
26
  }) => ReactElement | null;
28
27
  };
28
+ declare type Props = {
29
+ blocks: ContentBlock[];
30
+ } & ContentBlocksSettings;
29
31
  export declare type GenericBlockProps = {
30
32
  innerHTML?: string;
31
33
  innerContent?: string[];
@@ -1,4 +1,5 @@
1
1
  import { ElementType } from "react";
2
+ import { ContentBlocksSettings } from ".";
2
3
  declare type PropTypes<T extends ElementType> = {
3
4
  /** The 'key' of this editable text value */
4
5
  id: string;
@@ -18,6 +19,6 @@ declare type InnerBlocksProps = {
18
19
  templateLock?: any;
19
20
  template?: any;
20
21
  renderAppender?: any;
21
- };
22
+ } & ContentBlocksSettings;
22
23
  export declare function InnerBlocks(props: InnerBlocksProps): JSX.Element;
23
24
  export {};
@@ -74,7 +74,7 @@ function InnerBlocks(props) {
74
74
  }
75
75
  else {
76
76
  var blocks = (0, blockAttributes_1.useInnerBlocks)();
77
- return (0, jsx_runtime_1.jsx)(ContentBlocks_1.ContentBlocks, { blocks: blocks }, void 0);
77
+ return (0, jsx_runtime_1.jsx)(ContentBlocks_1.ContentBlocks, { blocks: blocks, spacer: props.spacer, wrapBlock: props.wrapBlock }, void 0);
78
78
  }
79
79
  }
80
80
  exports.InnerBlocks = InnerBlocks;
@@ -219,10 +219,10 @@ module.exports = {
219
219
  // Drill down to the path type
220
220
  var finalResultTypeName_1 = resultTypeName;
221
221
  pageInfo_1.nodesPath.forEach(function (key) {
222
- finalResultTypeName_1 = "Exclude<".concat(finalResultTypeName_1, "[").concat(JSON.stringify(key), "], null>");
222
+ finalResultTypeName_1 = "Exclude<".concat(finalResultTypeName_1, "[").concat(JSON.stringify(key), "], undefined | null>");
223
223
  });
224
224
  importUtils["createUseInfiniteQuery"] = true;
225
- hooks[hookName] = "\n createUseInfiniteQuery<Exclude<".concat(finalResultTypeName_1, "[0], null>, Omit<").concat(variablesTypeName || "undefined", ", 'limit' | 'cursor'>>({\n name: ").concat(JSON.stringify(name), ",\n defaultLimit: ").concat(defaultLimit_1, ",\n paths: ").concat(JSON.stringify(pageInfo_1), "\n })\n ");
225
+ hooks[hookName] = "\n createUseInfiniteQuery<Exclude<".concat(finalResultTypeName_1, "[0], undefined | null>, Omit<").concat(variablesTypeName || "undefined", ", 'limit' | 'cursor'>>({\n name: ").concat(JSON.stringify(name), ",\n defaultLimit: ").concat(defaultLimit_1, ",\n paths: ").concat(JSON.stringify(pageInfo_1), "\n })\n ");
226
226
  }
227
227
  });
228
228
  }
@@ -293,12 +293,18 @@ function beginWork(opts) {
293
293
  },
294
294
  config: {
295
295
  // maybeValue: "T",
296
- avoidOptionals: true,
296
+ avoidOptionals: {
297
+ field: true,
298
+ inputValue: false,
299
+ object: true,
300
+ defaultValue: true,
301
+ },
297
302
  // exportFragmentSpreadSubTypes: true,
298
303
  inlineFragmentTypes: "combine",
299
304
  onlyOperationTypes: true,
300
305
  skipTypename: true,
301
306
  preResolveTypes: true,
307
+ maybeValue: "T | null",
302
308
  },
303
309
  },
304
310
  "types.views.ts": {
@@ -87,16 +87,6 @@ function BrowserRouter(props) {
87
87
  if (!pending.popped) {
88
88
  history.replaceState({ scrollPosition: (_b = document.scrollingElement) === null || _b === void 0 ? void 0 : _b.scrollTop }, "", document.location.href);
89
89
  history.pushState({}, "", pending.url);
90
- // if (document.scrollingElement) {
91
- // console.log("Scroll to top")
92
- // document.scrollingElement.scrollTop = 0
93
- // }
94
- }
95
- else {
96
- // if (document.scrollingElement) {
97
- // console.log("Scroll to", pending.scrollPosition)
98
- // document.scrollingElement.scrollTop = pending.scrollPosition || 0
99
- // }
100
90
  }
101
91
  };
102
92
  if (view && view.preload) {
@@ -112,11 +102,10 @@ function BrowserRouter(props) {
112
102
  cancelled = true;
113
103
  };
114
104
  }, [pending]);
115
- console.log("Passing", url, data);
116
- var _c = (0, react_1.useState)(null), scrollPosition = _c[0], setScrollPosition = _c[1];
105
+ var _c = (0, react_1.useState)({ value: null }), scrollPosition = _c[0], setScrollPosition = _c[1];
117
106
  (0, react_1.useEffect)(function () {
118
- if (document.scrollingElement && typeof scrollPosition === "number") {
119
- document.scrollingElement.scrollTop = scrollPosition;
107
+ if (document.scrollingElement && typeof scrollPosition.value === "number") {
108
+ document.scrollingElement.scrollTop = scrollPosition.value;
120
109
  }
121
110
  }, [scrollPosition]);
122
111
  return ((0, jsx_runtime_1.jsx)(routing_1.RouterRoot, __assign({ url: url, data: data, onNavigateRequest: function (url) {
@@ -127,10 +116,10 @@ function BrowserRouter(props) {
127
116
  }
128
117
  }, onNavigated: function () {
129
118
  if (pending && typeof pending.scrollPosition === "number") {
130
- setScrollPosition(pending.scrollPosition);
119
+ setScrollPosition({ value: pending.scrollPosition });
131
120
  }
132
121
  else {
133
- setScrollPosition(0);
122
+ setScrollPosition({ value: 0 });
134
123
  }
135
124
  } }, { children: props.children }), void 0));
136
125
  }
@@ -34,9 +34,9 @@ declare type InfiniteQueryHookReturn<TItem, TVars> = {
34
34
  loadingMore: boolean;
35
35
  errors?: GraphQLError[];
36
36
  items?: TItem[];
37
- hasMore?: boolean;
38
- canLoadMore?: boolean;
39
- refresh: (vars?: TVars) => void;
37
+ cursor?: string;
38
+ hasMore: boolean;
39
+ refresh: () => void;
40
40
  loadMore: () => void;
41
41
  };
42
42
  declare type InfiniteQueryHasAdditionalVars<TVars> = Exclude<keyof TVars, "limit" | "cursor"> extends never ? false : true;
@@ -112,17 +112,25 @@ function createUseInfiniteQuery(init) {
112
112
  var _d = (0, react_1.useState)(false), hasMore = _d[0], setHasMore = _d[1];
113
113
  var _e = (0, react_1.useState)(true), isLoadingMore = _e[0], setIsLoadingMore = _e[1];
114
114
  var _f = (0, react_1.useState)([]), items = _f[0], setItems = _f[1];
115
- var _g = (0, swr_1.default)([
115
+ var _g = (0, react_1.useState)(vars), varPayload = _g[0], setVarPayload = _g[1];
116
+ var _h = (0, swr_1.default)([
116
117
  init.name,
117
- JSON.stringify(__assign(__assign({}, (vars || {})), { cursor: activeCursor })),
118
+ JSON.stringify(__assign(__assign({}, (varPayload || {})), { cursor: activeCursor })),
118
119
  ], fetcherGET, {
119
120
  revalidateIfStale: false,
120
121
  revalidateOnFocus: false,
121
122
  revalidateOnReconnect: false,
122
- }), payload = _g.data, isValidating = _g.isValidating, error = _g.error, mutate = _g.mutate;
123
+ }), payload = _h.data, isValidating = _h.isValidating, error = _h.error, mutate = _h.mutate;
124
+ (0, react_1.useEffect)(function () {
125
+ setItems([]);
126
+ setIsLoadingMore(true);
127
+ setErrors(undefined);
128
+ setHasMore(false);
129
+ setActiveCursor(undefined);
130
+ setVarPayload(vars);
131
+ }, [JSON.stringify(vars)]);
123
132
  (0, react_1.useEffect)(function () {
124
133
  if (payload) {
125
- console.log("Got payload", payload);
126
134
  setIsLoadingMore(false);
127
135
  if (payload.errors) {
128
136
  setErrors(payload.errors);
@@ -135,6 +143,7 @@ function createUseInfiniteQuery(init) {
135
143
  setErrors(undefined);
136
144
  setNextCursor(nextCursor_1);
137
145
  setHasMore(hasMore_1);
146
+ setIsLoadingMore(false);
138
147
  setItems(function () { return __spreadArray(__spreadArray([], items, true), nodes_1, true); });
139
148
  }
140
149
  }
@@ -143,6 +152,7 @@ function createUseInfiniteQuery(init) {
143
152
  loading: isValidating && !items.length,
144
153
  loadingMore: isLoadingMore,
145
154
  items: items,
155
+ cursor: activeCursor,
146
156
  errors: error ? [error] : errors,
147
157
  refresh: function () {
148
158
  setErrors(undefined);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eddev",
3
- "version": "0.1.40-beta-1",
3
+ "version": "0.1.43",
4
4
  "main": "./index.js",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -213,15 +213,7 @@ function useForkedRouter(conf, opts) {
213
213
  var ctx = (0, react_1.useMemo)(function () {
214
214
  return parent.fork(conf, opts);
215
215
  }, [parent]);
216
- // useEffect(() => {
217
- // if (onChange) {
218
- // return ctx.subscribe(onChange);
219
- // }
220
- // }, [ctx, onChange]);
221
216
  Object.assign(ctx.config, conf);
222
- // ctx.config.match = conf.match;
223
- // ctx.config.beforeLeave = conf.beforeLeave;
224
- // ctx.config.beforeLeave = conf.beforeLeave;
225
217
  (0, react_1.useEffect)(function () {
226
218
  return function () { return ctx.dispose(); };
227
219
  }, [ctx]);