@soppiya/app-bridge 1.1.1 → 1.1.3

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 (38) hide show
  1. package/dist/components/articles-picker/ui/ArticlesPicker.js +13 -7
  2. package/dist/components/blogs-picker/ui/BlogsPicker.js +13 -8
  3. package/dist/components/collections-pciker/ui/CollectionPicker.js +16 -10
  4. package/dist/components/collections-pciker/ui/CollectionPicker.stories.d.ts +1 -4
  5. package/dist/components/collections-pciker/ui/CollectionPicker.stories.js +1 -4
  6. package/dist/components/index.d.ts +1 -0
  7. package/dist/components/index.js +1 -0
  8. package/dist/components/link-list-picker/api/query.d.ts +8 -0
  9. package/dist/components/link-list-picker/api/query.js +22 -0
  10. package/dist/components/link-list-picker/index.d.ts +1 -0
  11. package/dist/components/link-list-picker/index.js +2 -0
  12. package/dist/components/link-list-picker/model/useLinkList.d.ts +30 -0
  13. package/dist/components/link-list-picker/model/useLinkList.js +46 -0
  14. package/dist/components/link-list-picker/ui/LinkListPicker.d.ts +9 -0
  15. package/dist/components/link-list-picker/ui/LinkListPicker.js +104 -0
  16. package/dist/components/link-list-picker/ui/LinkListPicker.stories.d.ts +14 -0
  17. package/dist/components/link-list-picker/ui/LinkListPicker.stories.js +10 -0
  18. package/dist/components/meta-data/ui/MetaData.d.ts +2 -1
  19. package/dist/components/meta-data/ui/MetaData.js +9 -13
  20. package/dist/components/metafield-entries/api/query.d.ts +8 -0
  21. package/dist/components/metafield-entries/api/query.js +18 -0
  22. package/dist/components/metafield-entries/index.d.ts +0 -0
  23. package/dist/components/metafield-entries/index.js +0 -0
  24. package/dist/components/metafield-entries/model/useMetaobjectEntries.d.ts +25 -0
  25. package/dist/components/metafield-entries/model/useMetaobjectEntries.js +46 -0
  26. package/dist/components/metafield-entries/ui/MetaobjectEntries.d.ts +10 -0
  27. package/dist/components/metafield-entries/ui/MetaobjectEntries.js +108 -0
  28. package/dist/components/metafield-entries/ui/MetaobjectEntries.stories.d.ts +15 -0
  29. package/dist/components/metafield-entries/ui/MetaobjectEntries.stories.js +10 -0
  30. package/dist/components/pages-picker/ui/PagesPicker.js +19 -11
  31. package/dist/components/products-picker/ui/ProductPicker.js +16 -10
  32. package/dist/components/variants-picker/ui/VariantsPicker.js +13 -7
  33. package/dist/shared/graphql/gql.d.ts +10 -0
  34. package/dist/shared/graphql/gql.js +3 -1
  35. package/dist/shared/graphql/graphql.d.ts +64 -0
  36. package/dist/shared/graphql/graphql.js +855 -233
  37. package/dist/styles.css +12 -4
  38. package/package.json +1 -1
@@ -2,19 +2,23 @@ import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { InfinityScroll } from "../../infinity-scroll/index.js";
3
3
  import { useFilterQuery } from "../../../shared/lib/index.js";
4
4
  import { BlockStack, Box, Button, Checkbox, Image, InlineStack, Input, Modal, Spinner, Text } from "@soppiya/elementus";
5
+ import classnames from "classnames";
5
6
  import lodash from "lodash";
6
7
  import { useState } from "react";
7
8
  import { userArticles } from "../model/useArticles.js";
8
- const ArticlesPicker = ({ title, initialIds = [], limit = 1 / 0, onClose, onOk })=>{
9
+ const ArticlesPicker = ({ title = "Articles", initialIds = [], limit = 1 / 0, onClose, onOk })=>{
9
10
  const [selectedVariant, setSelectedVariant] = useState(initialIds);
10
11
  const { query, debounceQuery, onChangeQuery } = useFilterQuery();
11
12
  const { articles, pageInfo, isLoadingArticles, fetchMoreArticles } = userArticles({
12
13
  first: 20,
13
14
  query: debounceQuery
14
15
  });
15
- const isSelected = limit === 1 / 0 ? true : 1 === limit ? 1 === selectedVariant.length : selectedVariant.length >= limit;
16
+ const isReached = limit !== 1 / 0 && selectedVariant.length >= limit;
17
+ const isDisabled = limit !== 1 / 0 && selectedVariant.length > limit;
16
18
  const handleSelectVariant = (articleId)=>{
17
- selectedVariant?.includes(articleId) ? setSelectedVariant((prev)=>prev?.filter((id)=>articleId !== id)) : setSelectedVariant((prev)=>[
19
+ if (selectedVariant?.includes(articleId)) return void setSelectedVariant((prev)=>prev?.filter((id)=>articleId !== id));
20
+ if (isReached) return;
21
+ setSelectedVariant((prev)=>[
18
22
  ...prev,
19
23
  articleId
20
24
  ]);
@@ -26,21 +30,20 @@ const ArticlesPicker = ({ title, initialIds = [], limit = 1 / 0, onClose, onOk }
26
30
  gap: 50,
27
31
  justifyContent: "end",
28
32
  children: /*#__PURE__*/ jsx(Button, {
29
- disabled: lodash.isEmpty(selectedVariant) || !isSelected,
33
+ disabled: lodash.isEmpty(selectedVariant) || isDisabled,
30
34
  onClick: handleOk,
31
35
  children: "Add"
32
36
  })
33
37
  });
34
38
  return /*#__PURE__*/ jsx(Modal, {
35
39
  open: true,
36
- title: title || "Artilces",
40
+ title: title,
37
41
  bodyPadding: 0,
38
42
  buttons: ButtonJSX,
39
43
  onClose: onClose,
40
44
  children: /*#__PURE__*/ jsxs(BlockStack, {
41
45
  children: [
42
46
  /*#__PURE__*/ jsx(Box, {
43
- className: "border-b border-b-[#ebebeb]! h",
44
47
  padding: 60,
45
48
  children: /*#__PURE__*/ jsx(Input, {
46
49
  size: "sm",
@@ -59,7 +62,9 @@ const ArticlesPicker = ({ title, initialIds = [], limit = 1 / 0, onClose, onOk }
59
62
  children: [
60
63
  articles?.map((article)=>/*#__PURE__*/ jsxs(InlineStack, {
61
64
  stack: "full",
62
- className: "lg:cursor-pointer border-b border-b-[#ebebeb]!",
65
+ className: classnames('lg:cursor-pointer border-t border-t-[#ebebeb]!', {
66
+ 'bg-[#f1f1f1ab] cursor-default!': !selectedVariant.includes(article._id) && isReached
67
+ }),
63
68
  gapX: 60,
64
69
  padding: 60,
65
70
  onClick: ()=>handleSelectVariant(String(article._id)),
@@ -70,6 +75,7 @@ const ArticlesPicker = ({ title, initialIds = [], limit = 1 / 0, onClose, onOk }
70
75
  children: [
71
76
  /*#__PURE__*/ jsx(Box, {
72
77
  children: /*#__PURE__*/ jsx(Checkbox, {
78
+ disabled: !selectedVariant.includes(article._id) && isReached,
73
79
  checked: selectedVariant.includes(String(article._id)),
74
80
  onChange: ()=>{}
75
81
  })
@@ -2,19 +2,23 @@ import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { InfinityScroll } from "../../infinity-scroll/index.js";
3
3
  import { useFilterQuery } from "../../../shared/lib/index.js";
4
4
  import { BlockStack, Box, Button, Checkbox, Image, InlineStack, Input, Modal, Spinner, Text } from "@soppiya/elementus";
5
+ import classnames from "classnames";
5
6
  import lodash from "lodash";
6
7
  import { useState } from "react";
7
8
  import { useBlogs } from "../model/useBlogs.js";
8
- const BlogsPicker = ({ title, initialIds = [], limit = 1 / 0, onClose, onOk })=>{
9
+ const BlogsPicker = ({ title = "Blogs", initialIds = [], limit = 1 / 0, onClose, onOk })=>{
9
10
  const [selectedBlog, setSelectedBlog] = useState(initialIds);
10
11
  const { query, debounceQuery, onChangeQuery } = useFilterQuery();
11
12
  const { blogs, isLoadingBlogs, fetchMoreBlogs, pageInfo } = useBlogs({
12
13
  first: 20,
13
14
  query: debounceQuery
14
15
  });
15
- const isSelected = limit === 1 / 0 ? true : 1 === limit ? 1 === selectedBlog.length : selectedBlog.length >= limit;
16
+ const isReached = limit !== 1 / 0 && selectedBlog.length >= limit;
17
+ const isDisabled = limit !== 1 / 0 && selectedBlog.length > limit;
16
18
  const handleSelectedBlog = (blogId)=>{
17
- selectedBlog.includes(blogId) ? setSelectedBlog((prev)=>prev.filter((id)=>id !== blogId)) : setSelectedBlog((prev)=>[
19
+ if (selectedBlog?.includes(blogId)) return void setSelectedBlog((prev)=>prev?.filter((id)=>blogId !== id));
20
+ if (isReached) return;
21
+ setSelectedBlog((prev)=>[
18
22
  ...prev,
19
23
  blogId
20
24
  ]);
@@ -22,25 +26,23 @@ const BlogsPicker = ({ title, initialIds = [], limit = 1 / 0, onClose, onOk })=>
22
26
  const handleOk = ()=>{
23
27
  if (lodash.isFunction(onOk)) onOk(selectedBlog);
24
28
  };
25
- console.log(selectedBlog);
26
29
  const ButtonJSX = /*#__PURE__*/ jsx(InlineStack, {
27
30
  justifyContent: "end",
28
31
  children: /*#__PURE__*/ jsx(Button, {
29
32
  onClick: handleOk,
30
- disabled: lodash.isEmpty(selectedBlog) || !isSelected,
33
+ disabled: lodash.isEmpty(selectedBlog) || isDisabled,
31
34
  children: "Add"
32
35
  })
33
36
  });
34
37
  return /*#__PURE__*/ jsx(Modal, {
35
38
  open: true,
36
- title: title || "Blogs",
39
+ title: title,
37
40
  buttons: ButtonJSX,
38
41
  bodyPadding: 0,
39
42
  onClose: onClose,
40
43
  children: /*#__PURE__*/ jsxs(BlockStack, {
41
44
  children: [
42
45
  /*#__PURE__*/ jsx(Box, {
43
- className: "border-b border-b-[#ebebeb]! h",
44
46
  padding: 60,
45
47
  children: /*#__PURE__*/ jsx(Input, {
46
48
  size: "sm",
@@ -59,7 +61,9 @@ const BlogsPicker = ({ title, initialIds = [], limit = 1 / 0, onClose, onOk })=>
59
61
  children: [
60
62
  blogs?.map((blog)=>/*#__PURE__*/ jsxs(InlineStack, {
61
63
  stack: "full",
62
- className: "lg:cursor-pointer border-b border-b-[#ebebeb]!",
64
+ className: classnames('lg:cursor-pointer border-t border-t-[#ebebeb]!', {
65
+ 'bg-[#f1f1f1ab] cursor-default!': !selectedBlog.includes(blog._id) && isReached
66
+ }),
63
67
  gapX: 60,
64
68
  padding: 60,
65
69
  onClick: ()=>handleSelectedBlog(String(blog._id)),
@@ -70,6 +74,7 @@ const BlogsPicker = ({ title, initialIds = [], limit = 1 / 0, onClose, onOk })=>
70
74
  children: [
71
75
  /*#__PURE__*/ jsx(Box, {
72
76
  children: /*#__PURE__*/ jsx(Checkbox, {
77
+ disabled: !selectedBlog.includes(blog._id) && isReached,
73
78
  checked: selectedBlog.includes(String(blog._id)),
74
79
  onChange: ()=>{}
75
80
  })
@@ -2,43 +2,46 @@ import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { InfinityScroll } from "../../infinity-scroll/index.js";
3
3
  import { useFilterQuery } from "../../../shared/lib/index.js";
4
4
  import { BlockStack, Box, Button, Checkbox, Image, InlineStack, Input, Modal, Spinner, Text } from "@soppiya/elementus";
5
+ import classnames from "classnames";
5
6
  import lodash from "lodash";
6
7
  import { useState } from "react";
7
8
  import { useCollections } from "../model/useCollections.js";
8
- const CollectionPicker = ({ title, initialIds = [], limit = 1 / 0, onClose, onOk })=>{
9
- const [selectedVariant, setSelectedVariant] = useState(initialIds);
9
+ const CollectionPicker = ({ title = "Collections", initialIds = [], limit = 1 / 0, onClose, onOk })=>{
10
+ const [selectedCollection, setSelectedCollection] = useState(initialIds);
10
11
  const { query, debounceQuery, onChangeQuery } = useFilterQuery();
11
12
  const { collections, isLoadingCollections, fetchMoreCollections, pageInfo } = useCollections({
12
13
  query: debounceQuery
13
14
  });
14
- const isSelected = limit === 1 / 0 ? true : 1 === limit ? 1 === selectedVariant.length : selectedVariant.length >= limit;
15
+ const isReached = limit !== 1 / 0 && selectedCollection.length >= limit;
16
+ const isDisabled = limit !== 1 / 0 && selectedCollection.length > limit;
15
17
  const handleSelectVariant = (productId)=>{
16
- selectedVariant.includes(productId) ? setSelectedVariant((prev)=>prev.filter((id)=>productId !== id)) : setSelectedVariant((prev)=>[
18
+ if (selectedCollection.includes(productId)) return void setSelectedCollection((prev)=>prev.filter((id)=>productId !== id));
19
+ if (isReached) return;
20
+ setSelectedCollection((prev)=>[
17
21
  ...prev,
18
22
  productId
19
23
  ]);
20
24
  };
21
25
  const handleOk = ()=>{
22
- if (lodash.isFunction(onOk)) onOk(selectedVariant);
26
+ if (lodash.isFunction(onOk)) onOk(selectedCollection);
23
27
  };
24
28
  const ButtonJSX = /*#__PURE__*/ jsx(InlineStack, {
25
29
  justifyContent: "end",
26
30
  children: /*#__PURE__*/ jsx(Button, {
27
- disabled: lodash.isEmpty(selectedVariant) || !isSelected,
31
+ disabled: lodash.isEmpty(selectedCollection) || isDisabled,
28
32
  onClick: handleOk,
29
33
  children: "Add"
30
34
  })
31
35
  });
32
36
  return /*#__PURE__*/ jsx(Modal, {
33
37
  open: true,
34
- title: title || "Collections",
38
+ title: title,
35
39
  bodyPadding: 0,
36
40
  buttons: ButtonJSX,
37
41
  onClose: onClose,
38
42
  children: /*#__PURE__*/ jsxs(BlockStack, {
39
43
  children: [
40
44
  /*#__PURE__*/ jsx(Box, {
41
- className: "border-b border-b-[#ebebeb]! h",
42
45
  padding: 60,
43
46
  children: /*#__PURE__*/ jsx(Input, {
44
47
  size: "sm",
@@ -57,7 +60,9 @@ const CollectionPicker = ({ title, initialIds = [], limit = 1 / 0, onClose, onOk
57
60
  children: [
58
61
  collections?.map((collection)=>/*#__PURE__*/ jsxs(InlineStack, {
59
62
  stack: "full",
60
- className: "lg:cursor-pointer border-b border-b-[#ebebeb]!",
63
+ className: classnames('lg:cursor-pointer border-t border-t-[#ebebeb]!', {
64
+ 'bg-[#f1f1f1ab] cursor-default!': !selectedCollection.includes(collection._id) && isReached
65
+ }),
61
66
  gapX: 60,
62
67
  padding: 60,
63
68
  onClick: ()=>handleSelectVariant(String(collection._id)),
@@ -68,7 +73,8 @@ const CollectionPicker = ({ title, initialIds = [], limit = 1 / 0, onClose, onOk
68
73
  children: [
69
74
  /*#__PURE__*/ jsx(Box, {
70
75
  children: /*#__PURE__*/ jsx(Checkbox, {
71
- checked: selectedVariant.includes(String(collection._id)),
76
+ disabled: !selectedCollection.includes(collection._id) && isReached,
77
+ checked: selectedCollection.includes(String(collection._id)),
72
78
  onChange: ()=>{}
73
79
  })
74
80
  }),
@@ -10,8 +10,5 @@ declare const meta: {
10
10
  };
11
11
  export default meta;
12
12
  export declare const Default: {
13
- args: {
14
- primary: boolean;
15
- label: string;
16
- };
13
+ args: {};
17
14
  };
@@ -5,9 +5,6 @@ const meta = {
5
5
  };
6
6
  const CollectionPicker_stories = meta;
7
7
  const Default = {
8
- args: {
9
- primary: true,
10
- label: "Button"
11
- }
8
+ args: {}
12
9
  };
13
10
  export { Default, CollectionPicker_stories as default };
@@ -1,6 +1,7 @@
1
1
  export * from "./articles-picker";
2
2
  export * from "./blogs-picker";
3
3
  export * from "./collections-pciker";
4
+ export * from "./link-list-picker";
4
5
  export * from "./media";
5
6
  export * from "./meta-data";
6
7
  export * from "./pages-picker";
@@ -1,6 +1,7 @@
1
1
  export * from "./articles-picker/index.js";
2
2
  export * from "./blogs-picker/index.js";
3
3
  export * from "./collections-pciker/index.js";
4
+ export * from "./link-list-picker/index.js";
4
5
  export * from "./media/index.js";
5
6
  export * from "./meta-data/index.js";
6
7
  export * from "./pages-picker/index.js";
@@ -0,0 +1,8 @@
1
+ export declare const linkListQuery: import("@graphql-typed-document-node/core").TypedDocumentNode<import("../../../shared/graphql/graphql").LinklistsQuery, import("../../../shared/graphql/graphql").Exact<{
2
+ after?: import("../../../shared/graphql/graphql").InputMaybe<import("../../../shared/graphql/graphql").Scalars["ID"]["input"]>;
3
+ before?: import("../../../shared/graphql/graphql").InputMaybe<import("../../../shared/graphql/graphql").Scalars["ID"]["input"]>;
4
+ first?: import("../../../shared/graphql/graphql").InputMaybe<import("../../../shared/graphql/graphql").Scalars["Int"]["input"]>;
5
+ last?: import("../../../shared/graphql/graphql").InputMaybe<import("../../../shared/graphql/graphql").Scalars["Int"]["input"]>;
6
+ query?: import("../../../shared/graphql/graphql").InputMaybe<import("../../../shared/graphql/graphql").Scalars["String"]["input"]>;
7
+ filterKeys?: import("../../../shared/graphql/graphql").InputMaybe<import("../../../shared/graphql/graphql").LinklistFilterKeys>;
8
+ }>>;
@@ -0,0 +1,22 @@
1
+ import { graphql } from "../../../shared/graphql/index.js";
2
+ const linkListQuery = graphql(`query Linklists($after: ID, $before: ID, $first: Int, $last: Int, $query: String, $filterKeys: LinklistFilterKeys) {
3
+ linklists(after: $after, before: $before, first: $first, last: $last, query: $query, filterKeys: $filterKeys) {
4
+ pageInfo {
5
+ endCursor
6
+ hasNextPage
7
+ hasPreviousPage
8
+ startCursor
9
+ }
10
+ edges {
11
+ node {
12
+ _id
13
+ title
14
+ links {
15
+ url
16
+ _id
17
+ }
18
+ }
19
+ }
20
+ }
21
+ }`);
22
+ export { linkListQuery };
@@ -0,0 +1 @@
1
+ export { default as LinkListPicker } from "./ui/LinkListPicker";
@@ -0,0 +1,2 @@
1
+ import LinkListPicker from "./ui/LinkListPicker.js";
2
+ export { LinkListPicker };
@@ -0,0 +1,30 @@
1
+ import { LinklistFilterKeys } from "../../../shared/graphql/graphql";
2
+ type Props = {
3
+ skip?: boolean;
4
+ first?: number;
5
+ query?: string | null;
6
+ filterKeys?: LinklistFilterKeys;
7
+ };
8
+ export declare const useLinklist: (props?: Props) => {
9
+ linklists: {
10
+ __typename: "Linklist";
11
+ _id?: string | null;
12
+ title?: string | null;
13
+ links?: Array<{
14
+ __typename: "LinklistLayer1";
15
+ url?: string | null;
16
+ _id?: string | null;
17
+ } | null> | null;
18
+ }[] | undefined;
19
+ pageInfo: {
20
+ __typename: "PageInfo";
21
+ endCursor?: string | null;
22
+ hasNextPage?: boolean | null;
23
+ hasPreviousPage?: boolean | null;
24
+ startCursor?: string | null;
25
+ } | null | undefined;
26
+ isLoadingLinklist: boolean;
27
+ error: import("@apollo/client").ErrorLike | undefined;
28
+ fetchMoreLinklists: () => void;
29
+ };
30
+ export {};
@@ -0,0 +1,46 @@
1
+ import { useQuery } from "@apollo/client/react";
2
+ import { linkListQuery } from "../api/query.js";
3
+ const useLinklist = (props = {})=>{
4
+ const { skip, first, query, filterKeys } = props;
5
+ const { data, loading: isLoadingLinklist, error, fetchMore } = useQuery(linkListQuery, {
6
+ skip,
7
+ variables: {
8
+ first,
9
+ query,
10
+ filterKeys
11
+ }
12
+ });
13
+ const linklists = data?.linklists?.edges?.map((edge)=>edge?.node).filter((node)=>null != node);
14
+ const pageInfo = data?.linklists?.pageInfo;
15
+ const fetchMoreLinklists = ()=>{
16
+ if (!pageInfo?.hasNextPage) return;
17
+ fetchMore({
18
+ variables: {
19
+ first,
20
+ query,
21
+ filterKeys,
22
+ after: pageInfo.endCursor
23
+ },
24
+ updateQuery (prev, { fetchMoreResult }) {
25
+ if (!fetchMoreResult.linklists?.edges || !prev.linklists?.edges) return prev;
26
+ return {
27
+ linklists: {
28
+ ...fetchMoreResult.linklists,
29
+ edges: [
30
+ ...prev.linklists.edges,
31
+ ...fetchMoreResult.linklists.edges
32
+ ]
33
+ }
34
+ };
35
+ }
36
+ });
37
+ };
38
+ return {
39
+ linklists,
40
+ pageInfo,
41
+ isLoadingLinklist,
42
+ error,
43
+ fetchMoreLinklists
44
+ };
45
+ };
46
+ export { useLinklist };
@@ -0,0 +1,9 @@
1
+ type Props = {
2
+ title?: string;
3
+ initialIds?: string[];
4
+ limit?: number;
5
+ onClose?: () => void;
6
+ onOk?: (linklist: string[]) => void;
7
+ };
8
+ declare const LinkListPicker: ({ title, initialIds, limit, onClose, onOk }: Props) => import("react/jsx-runtime").JSX.Element;
9
+ export default LinkListPicker;
@@ -0,0 +1,104 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { InfinityScroll } from "../../infinity-scroll/index.js";
3
+ import { useFilterQuery } from "../../../shared/lib/index.js";
4
+ import { BlockStack, Box, Button, Checkbox, InlineStack, Input, Modal, Spinner, Text } from "@soppiya/elementus";
5
+ import classnames from "classnames";
6
+ import lodash from "lodash";
7
+ import { useState } from "react";
8
+ import { useLinklist } from "../model/useLinkList.js";
9
+ const LinkListPicker = ({ title = "Linklist", initialIds = [], limit = 1 / 0, onClose, onOk })=>{
10
+ const [selectedLinklist, setSelectedLinklist] = useState(initialIds);
11
+ const { query, debounceQuery, onChangeQuery } = useFilterQuery();
12
+ const { linklists, isLoadingLinklist, fetchMoreLinklists, pageInfo } = useLinklist({
13
+ first: 20,
14
+ query: debounceQuery
15
+ });
16
+ const isReached = limit !== 1 / 0 && selectedLinklist.length >= limit;
17
+ const isDisabled = limit !== 1 / 0 && selectedLinklist.length > limit;
18
+ const handleSelectedLinklist = (linkListId)=>{
19
+ if (selectedLinklist.includes(linkListId)) return void setSelectedLinklist((prev)=>prev.filter((id)=>id !== linkListId));
20
+ if (isReached) return;
21
+ setSelectedLinklist((prev)=>[
22
+ ...prev,
23
+ linkListId
24
+ ]);
25
+ };
26
+ const handleOk = ()=>{
27
+ if (lodash.isFunction(onOk)) onOk(selectedLinklist);
28
+ };
29
+ const ButtonJSX = /*#__PURE__*/ jsx(InlineStack, {
30
+ justifyContent: "end",
31
+ children: /*#__PURE__*/ jsx(Button, {
32
+ disabled: lodash.isEmpty(selectedLinklist) || isDisabled,
33
+ onClick: handleOk,
34
+ children: "Add"
35
+ })
36
+ });
37
+ return /*#__PURE__*/ jsx(Modal, {
38
+ open: true,
39
+ title: title,
40
+ bodyPadding: 0,
41
+ buttons: ButtonJSX,
42
+ onClose: onClose,
43
+ children: /*#__PURE__*/ jsxs(BlockStack, {
44
+ children: [
45
+ /*#__PURE__*/ jsx(Box, {
46
+ padding: 60,
47
+ children: /*#__PURE__*/ jsx(Input, {
48
+ size: "sm",
49
+ type: "search",
50
+ value: query ?? "",
51
+ onChange: (event)=>onChangeQuery(event.target.value)
52
+ })
53
+ }),
54
+ isLoadingLinklist ? /*#__PURE__*/ jsx(InlineStack, {
55
+ justifyContent: "center",
56
+ padding: 80,
57
+ children: /*#__PURE__*/ jsx(Spinner, {
58
+ size: "md"
59
+ })
60
+ }) : /*#__PURE__*/ jsxs(BlockStack, {
61
+ children: [
62
+ linklists?.map((linklist)=>/*#__PURE__*/ jsxs(InlineStack, {
63
+ stack: "full",
64
+ className: classnames('lg:cursor-pointer border-t border-t-[#ebebeb]!', {
65
+ 'bg-[#f1f1f1ab] cursor-default!': !selectedLinklist.includes(linklist._id) && isReached
66
+ }),
67
+ gapX: 60,
68
+ padding: 60,
69
+ onClick: ()=>handleSelectedLinklist(String(linklist._id)),
70
+ children: [
71
+ /*#__PURE__*/ jsx(InlineStack, {
72
+ alignItems: "center",
73
+ gapX: 60,
74
+ children: /*#__PURE__*/ jsx(Box, {
75
+ children: /*#__PURE__*/ jsx(Checkbox, {
76
+ disabled: !selectedLinklist.includes(linklist._id) && isReached,
77
+ checked: selectedLinklist.includes(String(linklist._id)),
78
+ onChange: ()=>{}
79
+ })
80
+ })
81
+ }),
82
+ /*#__PURE__*/ jsx(BlockStack, {
83
+ gapY: 30,
84
+ justifyContent: "center",
85
+ children: /*#__PURE__*/ jsx(Text, {
86
+ size: "sm",
87
+ color: "secondary",
88
+ truncate: "truncate-1",
89
+ children: linklist.title
90
+ })
91
+ })
92
+ ]
93
+ }, linklist._id)),
94
+ pageInfo?.hasNextPage && /*#__PURE__*/ jsx(InfinityScroll, {
95
+ onFetch: fetchMoreLinklists
96
+ })
97
+ ]
98
+ })
99
+ ]
100
+ })
101
+ });
102
+ };
103
+ const ui_LinkListPicker = LinkListPicker;
104
+ export { ui_LinkListPicker as default };
@@ -0,0 +1,14 @@
1
+ declare const meta: {
2
+ title: string;
3
+ component: ({ title, initialIds, limit, onClose, onOk }: {
4
+ title?: string;
5
+ initialIds?: string[];
6
+ limit?: number;
7
+ onClose?: () => void;
8
+ onOk?: (linklist: string[]) => void;
9
+ }) => import("react/jsx-runtime").JSX.Element;
10
+ };
11
+ export default meta;
12
+ export declare const Default: {
13
+ args: {};
14
+ };
@@ -0,0 +1,10 @@
1
+ import LinkListPicker from "./LinkListPicker.js";
2
+ const meta = {
3
+ title: "Example/LinkListPicker",
4
+ component: LinkListPicker
5
+ };
6
+ const LinkListPicker_stories = meta;
7
+ const Default = {
8
+ args: {}
9
+ };
10
+ export { Default, LinkListPicker_stories as default };
@@ -1,4 +1,5 @@
1
1
  interface Props {
2
+ title?: string;
2
3
  scope: string;
3
4
  value?: {
4
5
  metafield: string;
@@ -9,5 +10,5 @@ interface Props {
9
10
  value: string[];
10
11
  }) => void;
11
12
  }
12
- declare const MetaData: ({ scope, value, onChange }: Props) => import("react/jsx-runtime").JSX.Element;
13
+ declare const MetaData: ({ title, scope, value, onChange }: Props) => import("react/jsx-runtime").JSX.Element;
13
14
  export default MetaData;
@@ -4,7 +4,7 @@ import { BlockStack, Card, Text } from "@soppiya/elementus";
4
4
  import { isFunction } from "lodash";
5
5
  import { useGetMetaFields } from "../model/useGetMetaFields.js";
6
6
  import MetaDataItem from "./MetaDataItem.js";
7
- const MetaData_MetaData = ({ scope = "product", value = [], onChange })=>{
7
+ const MetaData_MetaData = ({ title = "Meta fields", scope = "product", value = [], onChange })=>{
8
8
  const { metafields, loading } = useGetMetaFields([
9
9
  scope
10
10
  ]);
@@ -22,12 +22,10 @@ const MetaData_MetaData = ({ scope = "product", value = [], onChange })=>{
22
22
  children: [
23
23
  /*#__PURE__*/ jsx(BlockStack, {
24
24
  padding: 70,
25
- children: /*#__PURE__*/ jsx("div", {
26
- children: /*#__PURE__*/ jsx(Text, {
27
- size: "md",
28
- weight: "semibold",
29
- children: "Meta fields"
30
- })
25
+ children: /*#__PURE__*/ jsx(Text, {
26
+ size: "md",
27
+ weight: "semibold",
28
+ children: title
31
29
  })
32
30
  }),
33
31
  /*#__PURE__*/ jsx(BlockStack, {
@@ -46,12 +44,10 @@ const MetaData_MetaData = ({ scope = "product", value = [], onChange })=>{
46
44
  children: [
47
45
  /*#__PURE__*/ jsx(BlockStack, {
48
46
  padding: 70,
49
- children: /*#__PURE__*/ jsx("div", {
50
- children: /*#__PURE__*/ jsx(Text, {
51
- size: "md",
52
- weight: "semibold",
53
- children: "Meta fields"
54
- })
47
+ children: /*#__PURE__*/ jsx(Text, {
48
+ size: "md",
49
+ weight: "semibold",
50
+ children: title
55
51
  })
56
52
  }),
57
53
  loading && !metafields ? /*#__PURE__*/ jsx(Loading, {}) : metafields.map((metaField)=>/*#__PURE__*/ jsx(MetaDataItem, {
@@ -0,0 +1,8 @@
1
+ export declare const metaobjectEntriesQuery: import("@graphql-typed-document-node/core").TypedDocumentNode<import("../../../shared/graphql/graphql").MetaobjectEntriesQuery, import("../../../shared/graphql/graphql").Exact<{
2
+ after?: import("../../../shared/graphql/graphql").InputMaybe<import("../../../shared/graphql/graphql").Scalars["ID"]["input"]>;
3
+ before?: import("../../../shared/graphql/graphql").InputMaybe<import("../../../shared/graphql/graphql").Scalars["ID"]["input"]>;
4
+ first?: import("../../../shared/graphql/graphql").InputMaybe<import("../../../shared/graphql/graphql").Scalars["Int"]["input"]>;
5
+ last?: import("../../../shared/graphql/graphql").InputMaybe<import("../../../shared/graphql/graphql").Scalars["Int"]["input"]>;
6
+ query?: import("../../../shared/graphql/graphql").InputMaybe<import("../../../shared/graphql/graphql").Scalars["String"]["input"]>;
7
+ filterKeys?: import("../../../shared/graphql/graphql").InputMaybe<import("../../../shared/graphql/graphql").MetaobjectEntryFilterKeys>;
8
+ }>>;
@@ -0,0 +1,18 @@
1
+ import { graphql } from "../../../shared/graphql/index.js";
2
+ const metaobjectEntriesQuery = graphql(`query MetaobjectEntries($after: ID, $before: ID, $first: Int, $last: Int, $query: String, $filterKeys: MetaobjectEntryFilterKeys) {
3
+ metaobjectEntries(after: $after, before: $before, first: $first, last: $last, query: $query, filterKeys: $filterKeys) {
4
+ pageInfo {
5
+ endCursor
6
+ hasNextPage
7
+ hasPreviousPage
8
+ startCursor
9
+ }
10
+ edges {
11
+ node {
12
+ _id
13
+ title
14
+ }
15
+ }
16
+ }
17
+ }`);
18
+ export { metaobjectEntriesQuery };
File without changes
File without changes
@@ -0,0 +1,25 @@
1
+ import { MetaobjectEntryFilterKeys } from "../../../shared/graphql/graphql";
2
+ type Props = {
3
+ skip?: boolean;
4
+ first?: number;
5
+ query?: string | null;
6
+ filterKeys?: MetaobjectEntryFilterKeys;
7
+ };
8
+ export declare const useMetaobjectEntries: (props?: Props) => {
9
+ metaobjectEntries: {
10
+ __typename: "MetaobjectEntry";
11
+ _id?: string | null;
12
+ title?: string | null;
13
+ }[] | undefined;
14
+ isLoadingMetaobjectEntries: boolean;
15
+ error: import("@apollo/client").ErrorLike | undefined;
16
+ fetchMoreMetaobjectEntries: () => void;
17
+ pageInfo: {
18
+ __typename: "PageInfo";
19
+ endCursor?: string | null;
20
+ hasNextPage?: boolean | null;
21
+ hasPreviousPage?: boolean | null;
22
+ startCursor?: string | null;
23
+ } | null | undefined;
24
+ };
25
+ export {};