@soppiya/app-bridge 1.2.0 → 1.2.2

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.
Files changed (53) hide show
  1. package/dist/components/articles-picker/model/useArticles.js +5 -2
  2. package/dist/components/blogs-picker/model/useBlogs.js +5 -2
  3. package/dist/components/collections-pciker/model/useCollections.js +5 -2
  4. package/dist/components/country-picker/model/{useContry.d.ts → useCountries.d.ts} +2 -2
  5. package/dist/components/country-picker/model/{useContry.js → useCountries.js} +8 -7
  6. package/dist/components/country-picker/ui/CountryPicker.d.ts +1 -1
  7. package/dist/components/country-picker/ui/CountryPicker.js +5 -5
  8. package/dist/components/country-picker/ui/CountryPicker.stories.d.ts +1 -1
  9. package/dist/components/customers-picker/model/useCustomers.d.ts +1 -1
  10. package/dist/components/customers-picker/model/useCustomers.js +6 -5
  11. package/dist/components/customers-picker/ui/CustomersPicker.d.ts +1 -1
  12. package/dist/components/customers-picker/ui/CustomersPicker.js +3 -3
  13. package/dist/components/customers-picker/ui/CustomersPicker.stories.d.ts +1 -1
  14. package/dist/components/link-list-picker/model/useLinkList.js +5 -2
  15. package/dist/components/link-list-picker/ui/LinkListPicker.d.ts +1 -1
  16. package/dist/components/link-list-picker/ui/LinkListPicker.js +2 -2
  17. package/dist/components/link-list-picker/ui/LinkListPicker.stories.d.ts +1 -1
  18. package/dist/components/meta-data/ui/VariantRefMetaField.d.ts +1 -1
  19. package/dist/components/metaobjects-entries-picker/model/useMetaobjectEntries.js +5 -2
  20. package/dist/components/metaobjects-entries-picker/ui/MetaobjectEntriesPicker.d.ts +1 -1
  21. package/dist/components/metaobjects-entries-picker/ui/MetaobjectEntriesPicker.js +2 -2
  22. package/dist/components/metaobjects-entries-picker/ui/MetaobjectEntriesPicker.stories.d.ts +1 -1
  23. package/dist/components/metaobjects-picker/model/useMetaobjects.js +5 -2
  24. package/dist/components/pages-picker/model/usePages.js +5 -2
  25. package/dist/components/pages-picker/ui/PagesPicker.js +2 -2
  26. package/dist/components/products-picker/model/useProducts.js +5 -2
  27. package/dist/components/products-picker/ui/ProductPicker.d.ts +1 -1
  28. package/dist/components/products-picker/ui/ProductPicker.js +2 -2
  29. package/dist/components/products-picker/ui/ProductsPicker.stories.d.ts +1 -1
  30. package/dist/components/region-picker/api/query.d.ts +8 -0
  31. package/dist/components/region-picker/api/query.js +18 -0
  32. package/dist/components/region-picker/index.d.ts +0 -0
  33. package/dist/components/region-picker/index.js +0 -0
  34. package/dist/components/region-picker/model/useRegion.d.ts +25 -0
  35. package/dist/components/region-picker/model/useRegion.js +50 -0
  36. package/dist/components/region-picker/ui/RegionPicker.d.ts +11 -0
  37. package/dist/components/region-picker/ui/RegionPicker.js +110 -0
  38. package/dist/components/region-picker/ui/RegionPicker.stories.d.ts +19 -0
  39. package/dist/components/region-picker/ui/RegionPicker.stories.js +13 -0
  40. package/dist/components/segments-picker/api/query.js +29 -13
  41. package/dist/components/segments-picker/model/useSegments.d.ts +1 -1
  42. package/dist/components/segments-picker/model/useSegments.js +6 -5
  43. package/dist/components/segments-picker/ui/SegmentsPicker.d.ts +1 -1
  44. package/dist/components/segments-picker/ui/SegmentsPicker.js +3 -3
  45. package/dist/components/segments-picker/ui/SegmentsPicker.stories.d.ts +1 -1
  46. package/dist/components/variants-picker/model/useVariants.d.ts +1 -1
  47. package/dist/components/variants-picker/model/useVariants.js +6 -5
  48. package/dist/components/variants-picker/ui/VariantsPicker.js +1 -1
  49. package/dist/shared/graphql/gql.d.ts +7 -2
  50. package/dist/shared/graphql/gql.js +3 -2
  51. package/dist/shared/graphql/graphql.d.ts +790 -67
  52. package/dist/shared/graphql/graphql.js +482 -27
  53. package/package.json +1 -1
@@ -1,17 +1,20 @@
1
+ import { NetworkStatus } from "@apollo/client";
1
2
  import { useQuery } from "@apollo/client/react";
2
3
  import { articlesQuery } from "../api/query.js";
3
4
  const userArticles = (props = {})=>{
4
5
  const { first, query, filterKeys, skip } = props;
5
- const { data, loading: isLoadingArticles, error, fetchMore } = useQuery(articlesQuery, {
6
+ const { data, error, networkStatus, fetchMore } = useQuery(articlesQuery, {
6
7
  skip,
7
8
  variables: {
8
9
  first,
9
10
  query,
10
11
  filterKeys
11
- }
12
+ },
13
+ notifyOnNetworkStatusChange: true
12
14
  });
13
15
  const articles = data?.articles?.edges?.map((edge)=>edge?.node).filter((node)=>null != node);
14
16
  const pageInfo = data?.articles?.pageInfo;
17
+ const isLoadingArticles = networkStatus === NetworkStatus.loading;
15
18
  const fetchMoreArticles = ()=>{
16
19
  if (!pageInfo?.hasNextPage) return;
17
20
  fetchMore({
@@ -1,17 +1,20 @@
1
+ import { NetworkStatus } from "@apollo/client";
1
2
  import { useQuery } from "@apollo/client/react";
2
3
  import { blogsQuery } from "../api/query.js";
3
4
  const useBlogs = (props = {})=>{
4
5
  const { first, skip, query, filterKeys } = props;
5
- const { data, loading: isLoadingBlogs, error, fetchMore } = useQuery(blogsQuery, {
6
+ const { data, error, networkStatus, fetchMore } = useQuery(blogsQuery, {
6
7
  skip,
7
8
  variables: {
8
9
  first,
9
10
  query,
10
11
  filterKeys
11
- }
12
+ },
13
+ notifyOnNetworkStatusChange: true
12
14
  });
13
15
  const blogs = data?.blogs?.edges?.map((edge)=>edge?.node).filter((node)=>null != node);
14
16
  const pageInfo = data?.blogs?.pageInfo;
17
+ const isLoadingBlogs = networkStatus === NetworkStatus.loading;
15
18
  const fetchMoreBlogs = ()=>{
16
19
  if (!pageInfo?.hasNextPage) return;
17
20
  fetchMore({
@@ -1,16 +1,19 @@
1
+ import { NetworkStatus } from "@apollo/client";
1
2
  import { useQuery } from "@apollo/client/react";
2
3
  import { collectionQuery } from "../api/query.js";
3
4
  const useCollections = (props = {})=>{
4
5
  const { skip, query, filterKeys } = props;
5
- const { data, loading: isLoadingCollections, error, fetchMore } = useQuery(collectionQuery, {
6
+ const { data, error, networkStatus, fetchMore } = useQuery(collectionQuery, {
6
7
  skip,
7
8
  variables: {
8
9
  filterKeys,
9
10
  query
10
- }
11
+ },
12
+ notifyOnNetworkStatusChange: true
11
13
  });
12
14
  const collections = data?.collections?.edges?.map((edge)=>edge?.node)?.filter((node)=>null != node);
13
15
  const pageInfo = data?.collections?.pageInfo;
16
+ const isLoadingCollections = networkStatus === NetworkStatus.loading;
14
17
  const fetchMoreCollections = ()=>{
15
18
  if (!pageInfo?.hasNextPage) return;
16
19
  fetchMore({
@@ -5,13 +5,13 @@ type Props = {
5
5
  query?: string | null;
6
6
  filterKeys?: _CountryFilterKeys | null;
7
7
  };
8
- export declare const useCountry: (props?: Props) => {
8
+ export declare const useCountries: (props?: Props) => {
9
9
  countries: {
10
10
  __typename: "_Country";
11
11
  _id?: string | null;
12
12
  name?: string | null;
13
13
  flag?: string | null;
14
- }[];
14
+ }[] | undefined;
15
15
  pageInfo: {
16
16
  __typename: "PageInfo";
17
17
  endCursor?: string | null;
@@ -1,19 +1,20 @@
1
+ import { NetworkStatus } from "@apollo/client";
1
2
  import { useQuery } from "@apollo/client/react";
2
- import { useRef } from "react";
3
3
  import { countryQuery } from "../api/query.js";
4
- const useCountry = (props = {})=>{
4
+ const useCountries = (props = {})=>{
5
5
  const { skip, first, query, filterKeys } = props;
6
- const refArray = useRef([]);
7
- const { data, loading: isLoadingCountry, error, fetchMore } = useQuery(countryQuery, {
6
+ const { data, error, networkStatus, fetchMore } = useQuery(countryQuery, {
8
7
  skip,
9
8
  variables: {
10
9
  first,
11
10
  query,
12
11
  filterKeys
13
- }
12
+ },
13
+ notifyOnNetworkStatusChange: true
14
14
  });
15
- const countries = data?._countries?.edges?.map((edge)=>edge?.node).filter((node)=>null != node) ?? refArray.current;
15
+ const countries = data?._countries?.edges?.map((edge)=>edge?.node).filter((node)=>null != node);
16
16
  const pageInfo = data?._countries?.pageInfo;
17
+ const isLoadingCountry = networkStatus === NetworkStatus.loading;
17
18
  const fetchMoreCountries = ()=>{
18
19
  if (!pageInfo?.hasNextPage) return;
19
20
  fetchMore({
@@ -45,4 +46,4 @@ const useCountry = (props = {})=>{
45
46
  fetchMoreCountries
46
47
  };
47
48
  };
48
- export { useCountry };
49
+ export { useCountries };
@@ -6,5 +6,5 @@ type Props = {
6
6
  onClose?: () => void;
7
7
  onOk?: (countries: string[]) => void;
8
8
  };
9
- declare const CountryPicker: ({ title, initialIds, limit, okButtonLoading, onClose, onOk }: Props) => import("react/jsx-runtime").JSX.Element;
9
+ declare const CountryPicker: ({ title, initialIds, limit, okButtonLoading, onClose, onOk, }: Props) => import("react/jsx-runtime").JSX.Element;
10
10
  export default CountryPicker;
@@ -5,11 +5,11 @@ import { BlockStack, Box, Button, Checkbox, Image, InlineStack, Input, Modal, Sp
5
5
  import classnames from "classnames";
6
6
  import lodash from "lodash";
7
7
  import { useState } from "react";
8
- import { useCountry } from "../model/useContry.js";
8
+ import { useCountries } from "../model/useCountries.js";
9
9
  const CountryPicker = ({ title = "Countries", initialIds = [], limit = 1 / 0, okButtonLoading, onClose, onOk })=>{
10
10
  const [selectedCustomer, setSelectedCustomer] = useState(initialIds);
11
11
  const { query, debounceQuery, onChangeQuery } = useFilterQuery();
12
- const { countries, pageInfo, isLoadingCountry, fetchMoreCountries } = useCountry({
12
+ const { countries, pageInfo, isLoadingCountry, fetchMoreCountries } = useCountries({
13
13
  first: 20,
14
14
  query: debounceQuery
15
15
  });
@@ -61,10 +61,10 @@ const CountryPicker = ({ title = "Countries", initialIds = [], limit = 1 / 0, ok
61
61
  })
62
62
  }) : /*#__PURE__*/ jsxs(BlockStack, {
63
63
  children: [
64
- countries.map((country)=>/*#__PURE__*/ jsx(InlineStack, {
64
+ countries?.map((country)=>/*#__PURE__*/ jsx(InlineStack, {
65
65
  stack: "full",
66
- className: classnames('lg:cursor-pointer border-t border-t-[#ebebeb]!', {
67
- 'bg-[#f1f1f1ab] cursor-default!': !selectedCustomer.includes(country._id) && isReached
66
+ className: classnames("lg:cursor-pointer border-t border-t-[#ebebeb]!", {
67
+ "bg-[#f1f1f1ab] cursor-default!": !selectedCustomer.includes(country._id) && isReached
68
68
  }),
69
69
  gapX: 60,
70
70
  padding: 60,
@@ -1,6 +1,6 @@
1
1
  declare const meta: {
2
2
  title: string;
3
- component: ({ title, initialIds, limit, okButtonLoading, onClose, onOk }: {
3
+ component: ({ title, initialIds, limit, okButtonLoading, onClose, onOk, }: {
4
4
  title?: string;
5
5
  initialIds?: string[];
6
6
  limit?: number;
@@ -15,7 +15,7 @@ export declare const useCustomers: (props?: Props) => {
15
15
  __typename: "CustomerEmail";
16
16
  address?: string | null;
17
17
  } | null;
18
- }[];
18
+ }[] | undefined;
19
19
  pageInfo: {
20
20
  __typename: "PageInfo";
21
21
  endCursor?: string | null;
@@ -1,19 +1,20 @@
1
+ import { NetworkStatus } from "@apollo/client";
1
2
  import { useQuery } from "@apollo/client/react";
2
- import { useRef } from "react";
3
3
  import { customersQuery } from "../api/query.js";
4
4
  const useCustomers = (props = {})=>{
5
5
  const { skip, first, query, filterKeys } = props;
6
- const refArray = useRef([]);
7
- const { data, loading: isLoadingCustomers, error, fetchMore } = useQuery(customersQuery, {
6
+ const { data, error, networkStatus, fetchMore } = useQuery(customersQuery, {
8
7
  skip,
9
8
  variables: {
10
9
  first,
11
10
  query,
12
11
  filterKeys
13
- }
12
+ },
13
+ notifyOnNetworkStatusChange: true
14
14
  });
15
15
  const pageInfo = data?.customers?.pageInfo;
16
- const customers = data?.customers?.edges?.map((edge)=>edge?.node).filter((node)=>null != node) ?? refArray.current;
16
+ const isLoadingCustomers = networkStatus === NetworkStatus.loading;
17
+ const customers = data?.customers?.edges?.map((edge)=>edge?.node).filter((node)=>null != node);
17
18
  const fetchMoreCustomers = ()=>{
18
19
  if (!pageInfo?.hasNextPage) return;
19
20
  fetchMore({
@@ -6,5 +6,5 @@ type Props = {
6
6
  onClose?: () => void;
7
7
  onOk?: (customers: string[]) => void;
8
8
  };
9
- declare const CustomersPicker: ({ title, initialIds, limit, okButtonLoading, onClose, onOk }: Props) => import("react/jsx-runtime").JSX.Element;
9
+ declare const CustomersPicker: ({ title, initialIds, limit, okButtonLoading, onClose, onOk, }: Props) => import("react/jsx-runtime").JSX.Element;
10
10
  export default CustomersPicker;
@@ -61,10 +61,10 @@ const CustomersPicker = ({ title = "Customers", initialIds = [], limit = 1 / 0,
61
61
  })
62
62
  }) : /*#__PURE__*/ jsxs(BlockStack, {
63
63
  children: [
64
- customers.map((customer)=>/*#__PURE__*/ jsx(InlineStack, {
64
+ customers?.map((customer)=>/*#__PURE__*/ jsx(InlineStack, {
65
65
  stack: "full",
66
- className: classnames('lg:cursor-pointer border-t border-t-[#ebebeb]!', {
67
- 'bg-[#f1f1f1ab] cursor-default!': !selectedCustomer.includes(customer._id) && isReached
66
+ className: classnames("lg:cursor-pointer border-t border-t-[#ebebeb]!", {
67
+ "bg-[#f1f1f1ab] cursor-default!": !selectedCustomer.includes(customer._id) && isReached
68
68
  }),
69
69
  gapX: 60,
70
70
  padding: 60,
@@ -1,6 +1,6 @@
1
1
  declare const meta: {
2
2
  title: string;
3
- component: ({ title, initialIds, limit, okButtonLoading, onClose, onOk }: {
3
+ component: ({ title, initialIds, limit, okButtonLoading, onClose, onOk, }: {
4
4
  title?: string;
5
5
  initialIds?: string[];
6
6
  limit?: number;
@@ -1,17 +1,20 @@
1
+ import { NetworkStatus } from "@apollo/client";
1
2
  import { useQuery } from "@apollo/client/react";
2
3
  import { linkListQuery } from "../api/query.js";
3
4
  const useLinklist = (props = {})=>{
4
5
  const { skip, first, query, filterKeys } = props;
5
- const { data, loading: isLoadingLinklist, error, fetchMore } = useQuery(linkListQuery, {
6
+ const { data, error, networkStatus, fetchMore } = useQuery(linkListQuery, {
6
7
  skip,
7
8
  variables: {
8
9
  first,
9
10
  query,
10
11
  filterKeys
11
- }
12
+ },
13
+ notifyOnNetworkStatusChange: true
12
14
  });
13
15
  const linklists = data?.linklists?.edges?.map((edge)=>edge?.node).filter((node)=>null != node);
14
16
  const pageInfo = data?.linklists?.pageInfo;
17
+ const isLoadingLinklist = networkStatus === NetworkStatus.loading;
15
18
  const fetchMoreLinklists = ()=>{
16
19
  if (!pageInfo?.hasNextPage) return;
17
20
  fetchMore({
@@ -6,5 +6,5 @@ type Props = {
6
6
  onClose?: () => void;
7
7
  onOk?: (linklist: string[]) => void;
8
8
  };
9
- declare const LinkListPicker: ({ title, initialIds, limit, okButtonLoading, onClose, onOk }: Props) => import("react/jsx-runtime").JSX.Element;
9
+ declare const LinkListPicker: ({ title, initialIds, limit, okButtonLoading, onClose, onOk, }: Props) => import("react/jsx-runtime").JSX.Element;
10
10
  export default LinkListPicker;
@@ -62,8 +62,8 @@ const LinkListPicker = ({ title = "Linklist", initialIds = [], limit = 1 / 0, ok
62
62
  children: [
63
63
  linklists?.map((linklist)=>/*#__PURE__*/ jsxs(InlineStack, {
64
64
  stack: "full",
65
- className: classnames('lg:cursor-pointer border-t border-t-[#ebebeb]!', {
66
- 'bg-[#f1f1f1ab] cursor-default!': !selectedLinklist.includes(linklist._id) && isReached
65
+ className: classnames("lg:cursor-pointer border-t border-t-[#ebebeb]!", {
66
+ "bg-[#f1f1f1ab] cursor-default!": !selectedLinklist.includes(linklist._id) && isReached
67
67
  }),
68
68
  gapX: 60,
69
69
  padding: 60,
@@ -1,6 +1,6 @@
1
1
  declare const meta: {
2
2
  title: string;
3
- component: ({ title, initialIds, limit, okButtonLoading, onClose, onOk }: {
3
+ component: ({ title, initialIds, limit, okButtonLoading, onClose, onOk, }: {
4
4
  title?: string;
5
5
  initialIds?: string[];
6
6
  limit?: number;
@@ -1,3 +1,3 @@
1
1
  import { MetaDataProps } from "./MetaDataItem";
2
- declare const VariantRefMetaField: ({ value, children }: MetaDataProps) => import("react/jsx-runtime").JSX.Element | import("react/jsx-runtime").JSX.Element[];
2
+ declare const VariantRefMetaField: ({ value, children }: MetaDataProps) => import("react/jsx-runtime").JSX.Element | import("react/jsx-runtime").JSX.Element[] | undefined;
3
3
  export default VariantRefMetaField;
@@ -1,17 +1,20 @@
1
+ import { NetworkStatus } from "@apollo/client";
1
2
  import { useQuery } from "@apollo/client/react";
2
3
  import { metaobjectEntriesQuery } from "../api/query.js";
3
4
  const useMetaobjectEntries = (props = {})=>{
4
5
  const { skip, first, query, filterKeys } = props;
5
- const { data, loading: isLoadingMetaobjectEntries, error, fetchMore } = useQuery(metaobjectEntriesQuery, {
6
+ const { data, error, networkStatus, fetchMore } = useQuery(metaobjectEntriesQuery, {
6
7
  skip,
7
8
  variables: {
8
9
  first,
9
10
  query,
10
11
  filterKeys
11
- }
12
+ },
13
+ notifyOnNetworkStatusChange: true
12
14
  });
13
15
  const metaobjectEntries = data?.metaobjectEntries?.edges?.map((edge)=>edge?.node).filter((node)=>null != node);
14
16
  const pageInfo = data?.metaobjectEntries?.pageInfo;
17
+ const isLoadingMetaobjectEntries = networkStatus === NetworkStatus.loading;
15
18
  const fetchMoreMetaobjectEntries = ()=>{
16
19
  if (!pageInfo?.hasNextPage) return;
17
20
  fetchMore({
@@ -7,5 +7,5 @@ type Props = {
7
7
  onClose?: () => void;
8
8
  onOk?: (metaobjectEntries: string[]) => void;
9
9
  };
10
- declare const MetaobjectEntriesPicker: ({ title, initialIds, limit, metaobjects, okButtonLoading, onClose, onOk }: Props) => import("react/jsx-runtime").JSX.Element;
10
+ declare const MetaobjectEntriesPicker: ({ title, initialIds, limit, metaobjects, okButtonLoading, onClose, onOk, }: Props) => import("react/jsx-runtime").JSX.Element;
11
11
  export default MetaobjectEntriesPicker;
@@ -65,8 +65,8 @@ const MetaobjectEntriesPicker = ({ title = "Metaobject entries", initialIds = []
65
65
  children: [
66
66
  metaobjectEntries?.map((metaobjectEntry)=>/*#__PURE__*/ jsxs(InlineStack, {
67
67
  stack: "full",
68
- className: classnames('lg:cursor-pointer border-t border-t-[#ebebeb]!', {
69
- 'bg-[#f1f1f1ab] cursor-default!': !selectedMetaobjectEntries.includes(metaobjectEntry._id) && isReached
68
+ className: classnames("lg:cursor-pointer border-t border-t-[#ebebeb]!", {
69
+ "bg-[#f1f1f1ab] cursor-default!": !selectedMetaobjectEntries.includes(metaobjectEntry._id) && isReached
70
70
  }),
71
71
  gapX: 60,
72
72
  padding: 60,
@@ -1,6 +1,6 @@
1
1
  declare const meta: {
2
2
  title: string;
3
- component: ({ title, initialIds, limit, metaobjects, okButtonLoading, onClose, onOk }: {
3
+ component: ({ title, initialIds, limit, metaobjects, okButtonLoading, onClose, onOk, }: {
4
4
  title?: string;
5
5
  initialIds?: string[];
6
6
  limit?: number;
@@ -1,17 +1,20 @@
1
+ import { NetworkStatus } from "@apollo/client";
1
2
  import { useQuery } from "@apollo/client/react";
2
3
  import { metaobjectQuery } from "../api/query.js";
3
4
  const useMetaobjects = (props = {})=>{
4
5
  const { skip, first, query, filterKeys } = props;
5
- const { data, loading: isMetaobjectsLoading, error, fetchMore } = useQuery(metaobjectQuery, {
6
+ const { data, networkStatus, fetchMore } = useQuery(metaobjectQuery, {
6
7
  skip,
7
8
  variables: {
8
9
  first,
9
10
  query,
10
11
  filterKeys
11
- }
12
+ },
13
+ notifyOnNetworkStatusChange: true
12
14
  });
13
15
  const metaobjects = data?.metaobjects?.edges?.map((edge)=>edge?.node).filter((node)=>null != node);
14
16
  const pageInfo = data?.metaobjects?.pageInfo;
17
+ const isMetaobjectsLoading = networkStatus === NetworkStatus.loading;
15
18
  const fetchMoreMetaobjects = ()=>{
16
19
  if (!pageInfo?.hasNextPage) return;
17
20
  fetchMore({
@@ -1,17 +1,20 @@
1
+ import { NetworkStatus } from "@apollo/client";
1
2
  import { useQuery } from "@apollo/client/react";
2
3
  import { pagesQuery } from "../api/query.js";
3
4
  const usePages = (props = {})=>{
4
5
  const { skip, first, query, filterKeys } = props;
5
- const { data, loading: isLoadingPages, error, fetchMore } = useQuery(pagesQuery, {
6
+ const { data, error, networkStatus, fetchMore } = useQuery(pagesQuery, {
6
7
  skip,
7
8
  variables: {
8
9
  first,
9
10
  query,
10
11
  filterKeys
11
- }
12
+ },
13
+ notifyOnNetworkStatusChange: true
12
14
  });
13
15
  const pages = data?.pages?.edges?.map((edge)=>edge?.node).filter((node)=>null != node);
14
16
  const pageInfo = data?.pages?.pageInfo;
17
+ const isLoadingPages = networkStatus === NetworkStatus.loading;
15
18
  const fetchMorePages = ()=>{
16
19
  if (!pageInfo?.hasNextPage) return;
17
20
  fetchMore({
@@ -62,8 +62,8 @@ const PagesPicker = ({ title = "Pages", initialIds = [], limit = 1 / 0, okButton
62
62
  children: [
63
63
  pages?.map((page)=>/*#__PURE__*/ jsxs(InlineStack, {
64
64
  stack: "full",
65
- className: classnames('lg:cursor-pointer border-t border-t-[#ebebeb]!', {
66
- 'bg-[#f1f1f1ab] cursor-default!': !selectedPage.includes(page._id) && isReached
65
+ className: classnames("lg:cursor-pointer border-t border-t-[#ebebeb]!", {
66
+ "bg-[#f1f1f1ab] cursor-default!": !selectedPage.includes(page._id) && isReached
67
67
  }),
68
68
  gapX: 60,
69
69
  padding: 60,
@@ -1,17 +1,20 @@
1
+ import { NetworkStatus } from "@apollo/client";
1
2
  import { useQuery } from "@apollo/client/react";
2
3
  import { productsQuery } from "../api/query.js";
3
4
  const useProducts = (props = {})=>{
4
5
  const { first, query, filterKeys, skip } = props;
5
- const { data, loading: isLoadingProducts, error, fetchMore } = useQuery(productsQuery, {
6
+ const { data, error, networkStatus, fetchMore } = useQuery(productsQuery, {
6
7
  skip,
7
8
  variables: {
8
9
  first,
9
10
  query,
10
11
  filterKeys
11
- }
12
+ },
13
+ notifyOnNetworkStatusChange: true
12
14
  });
13
15
  const products = data?.products?.edges?.map((edge)=>edge?.node).filter((node)=>null != node);
14
16
  const pageInfo = data?.products?.pageInfo;
17
+ const isLoadingProducts = networkStatus === NetworkStatus.loading;
15
18
  const fetchMoreProducts = ()=>{
16
19
  if (!pageInfo?.hasNextPage) return;
17
20
  fetchMore({
@@ -6,5 +6,5 @@ type Props = {
6
6
  onClose?: () => void;
7
7
  onOk?: (products: string[]) => void;
8
8
  };
9
- declare const ProductsPicker: ({ title, initialIds, limit, okButtonLoading, onClose, onOk }: Props) => import("react/jsx-runtime").JSX.Element;
9
+ declare const ProductsPicker: ({ title, initialIds, limit, okButtonLoading, onClose, onOk, }: Props) => import("react/jsx-runtime").JSX.Element;
10
10
  export default ProductsPicker;
@@ -63,8 +63,8 @@ const ProductsPicker = ({ title = "Products", initialIds = [], limit = 1 / 0, ok
63
63
  children: [
64
64
  products?.map((product)=>/*#__PURE__*/ jsxs(InlineStack, {
65
65
  stack: "full",
66
- className: classnames('lg:cursor-pointer border-t border-t-[#ebebeb]!', {
67
- 'bg-[#f1f1f1ab] cursor-default!': !selectedProduct.includes(product._id) && isReached
66
+ className: classnames("lg:cursor-pointer border-t border-t-[#ebebeb]!", {
67
+ "bg-[#f1f1f1ab] cursor-default!": !selectedProduct.includes(product._id) && isReached
68
68
  }),
69
69
  gapX: 60,
70
70
  padding: 60,
@@ -1,6 +1,6 @@
1
1
  declare const meta: {
2
2
  title: string;
3
- component: ({ title, initialIds, limit, okButtonLoading, onClose, onOk }: {
3
+ component: ({ title, initialIds, limit, okButtonLoading, onClose, onOk, }: {
4
4
  title?: string;
5
5
  initialIds?: string[];
6
6
  limit?: number;
@@ -0,0 +1,8 @@
1
+ export declare const regionQuery: import("@graphql-typed-document-node/core").TypedDocumentNode<import("../../../shared/graphql/graphql")._RegionsQuery, import("../../../shared/graphql/graphql").Exact<{
2
+ filterKeys?: import("../../../shared/graphql/graphql").InputMaybe<import("../../../shared/graphql/graphql")._RegionFilterKeys>;
3
+ query?: import("../../../shared/graphql/graphql").InputMaybe<import("../../../shared/graphql/graphql").Scalars["String"]["input"]>;
4
+ after?: import("../../../shared/graphql/graphql").InputMaybe<import("../../../shared/graphql/graphql").Scalars["ID"]["input"]>;
5
+ before?: import("../../../shared/graphql/graphql").InputMaybe<import("../../../shared/graphql/graphql").Scalars["ID"]["input"]>;
6
+ first?: import("../../../shared/graphql/graphql").InputMaybe<import("../../../shared/graphql/graphql").Scalars["Int"]["input"]>;
7
+ last?: import("../../../shared/graphql/graphql").InputMaybe<import("../../../shared/graphql/graphql").Scalars["Int"]["input"]>;
8
+ }>>;
@@ -0,0 +1,18 @@
1
+ import { graphql } from "../../../shared/graphql/index.js";
2
+ const regionQuery = graphql(`query _regions($filterKeys: _RegionFilterKeys, $query: String, $after: ID, $before: ID, $first: Int, $last: Int) {
3
+ _regions(filterKeys: $filterKeys, query: $query, after: $after, before: $before, first: $first, last: $last) {
4
+ pageInfo {
5
+ endCursor
6
+ hasNextPage
7
+ hasPreviousPage
8
+ startCursor
9
+ }
10
+ edges {
11
+ node {
12
+ _id
13
+ name
14
+ }
15
+ }
16
+ }
17
+ }`);
18
+ export { regionQuery };
File without changes
File without changes
@@ -0,0 +1,25 @@
1
+ import { _RegionFilterKeys } from "../../../shared/graphql/graphql";
2
+ type Props = {
3
+ skip?: boolean;
4
+ first?: number;
5
+ query?: string | null;
6
+ filterKeys?: _RegionFilterKeys;
7
+ };
8
+ export declare const useRegion: (props?: Props) => {
9
+ regions: {
10
+ __typename: "_Region";
11
+ _id?: string | null;
12
+ name?: string | null;
13
+ }[] | undefined;
14
+ pageInfo: {
15
+ __typename: "PageInfo";
16
+ endCursor?: string | null;
17
+ hasNextPage?: boolean | null;
18
+ hasPreviousPage?: boolean | null;
19
+ startCursor?: string | null;
20
+ } | null | undefined;
21
+ isLoadingRegion: boolean;
22
+ error: import("@apollo/client").ErrorLike | undefined;
23
+ fetchMoreRegions: () => void;
24
+ };
25
+ export {};
@@ -0,0 +1,50 @@
1
+ import { NetworkStatus } from "@apollo/client";
2
+ import { useQuery } from "@apollo/client/react";
3
+ import { regionQuery } from "../api/query.js";
4
+ const useRegion = (props = {})=>{
5
+ const { skip, first, query, filterKeys } = props;
6
+ const { data, error, networkStatus, fetchMore } = useQuery(regionQuery, {
7
+ skip,
8
+ variables: {
9
+ first,
10
+ query,
11
+ filterKeys
12
+ },
13
+ notifyOnNetworkStatusChange: true
14
+ });
15
+ const regions = data?._regions?.edges?.map((edge)=>edge?.node).filter((node)=>null != node);
16
+ const pageInfo = data?._regions?.pageInfo;
17
+ const isLoadingRegion = networkStatus === NetworkStatus.loading;
18
+ const fetchMoreRegions = ()=>{
19
+ if (!pageInfo?.hasNextPage) return;
20
+ fetchMore({
21
+ variables: {
22
+ first,
23
+ query,
24
+ after: pageInfo.endCursor,
25
+ filterKeys
26
+ },
27
+ updateQuery (prev, { fetchMoreResult }) {
28
+ if (!fetchMoreResult._regions?.edges || !prev._regions?.edges) return prev;
29
+ console.log(fetchMoreResult._regions);
30
+ return {
31
+ _regions: {
32
+ ...fetchMoreResult._regions,
33
+ edges: [
34
+ ...prev._regions.edges,
35
+ ...fetchMoreResult._regions.edges
36
+ ]
37
+ }
38
+ };
39
+ }
40
+ });
41
+ };
42
+ return {
43
+ regions,
44
+ pageInfo,
45
+ isLoadingRegion,
46
+ error,
47
+ fetchMoreRegions
48
+ };
49
+ };
50
+ export { useRegion };
@@ -0,0 +1,11 @@
1
+ type Props = {
2
+ title?: string;
3
+ initialIds?: string[];
4
+ countries?: string[];
5
+ limit?: number;
6
+ okButtonLoading?: boolean;
7
+ onClose?: () => void;
8
+ onOk?: (countries: string[]) => void;
9
+ };
10
+ declare const RegionPicker: ({ title, initialIds, countries, limit, okButtonLoading, onClose, onOk }: Props) => import("react/jsx-runtime").JSX.Element;
11
+ export default RegionPicker;