@livequery/react 1.0.30 → 1.0.33

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.
@@ -3,4 +3,4 @@ import { Transporter } from '@livequery/types';
3
3
  export declare type LiveQueryContextOption = {
4
4
  transporter: Transporter;
5
5
  };
6
- export declare const useLiveQuery: (props?: LiveQueryContextOption) => LiveQueryContextOption, useLiveQueryContext: () => LiveQueryContextOption, LiveQueryContextProvider: ({ children, ...value }: import("react").PropsWithChildren<LiveQueryContextOption>) => JSX.Element;
6
+ export declare const useLiveQueryContext: () => LiveQueryContextOption, LiveQueryContextProvider: ({ children, ...props }: import("react").PropsWithChildren<LiveQueryContextOption>) => JSX.Element;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  var _a;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.LiveQueryContextProvider = exports.useLiveQueryContext = exports.useLiveQuery = void 0;
4
+ exports.LiveQueryContextProvider = exports.useLiveQueryContext = void 0;
5
5
  const createContextFromHook_1 = require("./hooks/createContextFromHook");
6
- _a = createContextFromHook_1.createContextFromHook((props) => props), exports.useLiveQuery = _a[0], exports.useLiveQueryContext = _a[1], exports.LiveQueryContextProvider = _a[2];
6
+ _a = createContextFromHook_1.createContextFromHook((props) => props), exports.useLiveQueryContext = _a[0], exports.LiveQueryContextProvider = _a[1];
@@ -1,2 +1,2 @@
1
1
  import React, { PropsWithChildren } from 'react';
2
- export declare const createContextFromHook: <T, K>(fn: (props?: T) => K) => [(props?: T) => K, () => K, ({ children, ...value }: React.PropsWithChildren<K>) => JSX.Element];
2
+ export declare const createContextFromHook: <T, K>(fn: (props?: T) => K) => [() => K, ({ children, ...props }: React.PropsWithChildren<T>) => JSX.Element];
@@ -21,9 +21,10 @@ const createContextFromHook = (fn) => {
21
21
  const context = react_2.createContext({});
22
22
  const getContext = () => react_2.useContext(context);
23
23
  const Provider = (_a) => {
24
- var { children } = _a, value = __rest(_a, ["children"]);
24
+ var { children } = _a, props = __rest(_a, ["children"]);
25
+ const value = fn(props);
25
26
  return (react_1.default.createElement(context.Provider, { value: value }, children));
26
27
  };
27
- return [fn, getContext, Provider];
28
+ return [getContext, Provider];
28
29
  };
29
30
  exports.createContextFromHook = createContextFromHook;
@@ -1,4 +1,4 @@
1
- import { QueryOption } from "../../types/build";
1
+ import { QueryOption } from "@livequery/types";
2
2
  import { CollectionOption } from "@livequery/client";
3
3
  export declare type useCollectionDataOptions<T = any> = CollectionOption<T> & {
4
4
  lazy?: boolean;
@@ -6,10 +6,10 @@ export declare type useCollectionDataOptions<T = any> = CollectionOption<T> & {
6
6
  };
7
7
  export declare const useCollectionData: <T extends {
8
8
  id: string;
9
- }>(ref: string, collection_options?: Partial<useCollectionDataOptions<T>>) => {
9
+ }>(ref: string | undefined | '' | null | 0 | false, collection_options?: Partial<useCollectionDataOptions<T>>) => {
10
10
  items: import("@livequery/client").SmartQueryItem<T>[];
11
11
  loading: boolean;
12
- error: import("../../types/build").ErrorInfo;
12
+ error: import("@livequery/types").ErrorInfo;
13
13
  has_more: boolean;
14
14
  empty: boolean;
15
15
  filters: Partial<QueryOption<T>>;
@@ -20,7 +20,7 @@ const useCollectionData = (ref, collection_options = {}) => {
20
20
  loading,
21
21
  error,
22
22
  has_more,
23
- empty: ref && !error && Object.keys(items).length == 0 && !loading,
23
+ empty: ref && !error && Object.keys(items).length == 0 && loading === false,
24
24
  filters: (options || {}),
25
25
  add: assert(client === null || client === void 0 ? void 0 : client.add, client),
26
26
  fetch_more: assert(client === null || client === void 0 ? void 0 : client.fetch_more, client),
@@ -4,7 +4,7 @@ export declare type useDocumentDataOptions<T = any> = Omit<CollectionOption<T>,
4
4
  };
5
5
  export declare const useDocumentData: <T extends {
6
6
  id: string;
7
- }>(ref: string, options?: useDocumentDataOptions) => {
7
+ }>(ref: string | undefined | '' | null | 0 | false, options?: useDocumentDataOptions) => {
8
8
  item: import("@livequery/client").SmartQueryItem<T>;
9
9
  loading: boolean;
10
10
  error: import("@livequery/types").ErrorInfo;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "repository": {
4
4
  "url": "https://github.com/livequery/react"
5
5
  },
6
- "version": "1.0.30",
6
+ "version": "1.0.33",
7
7
  "description": "",
8
8
  "main": "build/index.js",
9
9
  "types": "build/index.d.ts",
@@ -11,11 +11,11 @@
11
11
  "build/**/*"
12
12
  ],
13
13
  "dependencies": {
14
- "@livequery/client": "^1.0.25"
14
+ "@livequery/client": "^1.0.26"
15
15
  },
16
16
  "devDependencies": {
17
17
  "react": "^17.0.2",
18
- "@livequery/types": "^1.0.31",
18
+ "@livequery/types": "^1.0.34",
19
19
  "@types/react": "^17.0.11"
20
20
  },
21
21
  "peerDependencies": {