@soppiya/app-bridge 1.0.8 → 1.0.9
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.
- package/dist/components/articles-picker/api/query.d.ts +8 -0
- package/dist/components/articles-picker/api/query.js +22 -0
- package/dist/components/articles-picker/model/useArticles.d.ts +30 -0
- package/dist/components/articles-picker/model/useArticles.js +46 -0
- package/dist/components/articles-picker/ui/ArticlesPicker.d.ts +9 -0
- package/dist/components/articles-picker/ui/ArticlesPicker.js +107 -0
- package/dist/components/articles-picker/ui/ProductPicker.stories.d.ts +17 -0
- package/dist/components/articles-picker/ui/ProductPicker.stories.js +13 -0
- package/dist/components/blogs-picker/api/query.d.ts +8 -0
- package/dist/components/blogs-picker/api/query.js +22 -0
- package/dist/components/blogs-picker/model/useBlogs.d.ts +30 -0
- package/dist/components/blogs-picker/model/useBlogs.js +46 -0
- package/dist/components/blogs-picker/ui/BlogsPicker.d.ts +9 -0
- package/dist/components/blogs-picker/ui/BlogsPicker.js +107 -0
- package/dist/components/blogs-picker/ui/BlogsPicker.stories.d.ts +17 -0
- package/dist/components/blogs-picker/ui/BlogsPicker.stories.js +13 -0
- package/dist/components/collections-pciker/api/query.d.ts +5 -0
- package/dist/components/collections-pciker/api/query.js +22 -0
- package/dist/components/collections-pciker/model/useCollections.d.ts +29 -0
- package/dist/components/collections-pciker/model/useCollections.js +32 -0
- package/dist/components/collections-pciker/ui/CollectionPicker.d.ts +9 -0
- package/dist/components/collections-pciker/ui/CollectionPicker.js +105 -0
- package/dist/components/collections-pciker/ui/CollectionPicker.stories.d.ts +17 -0
- package/dist/components/collections-pciker/ui/CollectionPicker.stories.js +13 -0
- package/dist/components/index.d.ts +4 -3
- package/dist/components/index.js +4 -4
- package/dist/components/meta-data/api/query.d.ts +4 -0
- package/dist/components/meta-data/api/query.js +14 -0
- package/dist/components/meta-data/index.d.ts +0 -0
- package/dist/components/meta-data/index.js +0 -0
- package/dist/components/meta-data/model/meta.types.d.ts +7 -0
- package/dist/components/meta-data/model/meta.types.js +33 -0
- package/dist/components/meta-data/model/schema.d.ts +0 -0
- package/dist/components/meta-data/model/schema.js +0 -0
- package/dist/components/meta-data/model/useGetMetaFields.d.ts +12 -0
- package/dist/components/meta-data/model/useGetMetaFields.js +18 -0
- package/dist/components/meta-data/ui/ArticleRefMetaField.d.ts +3 -0
- package/dist/components/meta-data/ui/ArticleRefMetaField.js +37 -0
- package/dist/components/meta-data/ui/BlogRefMetaField.d.ts +3 -0
- package/dist/components/meta-data/ui/BlogRefMetaField.js +37 -0
- package/dist/components/meta-data/ui/BooleanMetaField.d.ts +3 -0
- package/dist/components/meta-data/ui/BooleanMetaField.js +27 -0
- package/dist/components/meta-data/ui/CollectionRefMetaField.d.ts +3 -0
- package/dist/components/meta-data/ui/CollectionRefMetaField.js +36 -0
- package/dist/components/meta-data/ui/ColorMetaField.d.ts +3 -0
- package/dist/components/meta-data/ui/ColorMetaField.js +17 -0
- package/dist/components/meta-data/ui/DateAndTimeMetaField.d.ts +3 -0
- package/dist/components/meta-data/ui/DateAndTimeMetaField.js +34 -0
- package/dist/components/meta-data/ui/DateMetaField.d.ts +3 -0
- package/dist/components/meta-data/ui/DateMetaField.js +33 -0
- package/dist/components/meta-data/ui/FloatMetaField.d.ts +3 -0
- package/dist/components/meta-data/ui/FloatMetaField.js +23 -0
- package/dist/components/meta-data/ui/MetaData.d.ts +13 -0
- package/dist/components/meta-data/ui/MetaData.js +45 -0
- package/dist/components/meta-data/ui/MetaData.stories.d.ts +10 -0
- package/dist/components/meta-data/ui/MetaData.stories.js +136 -0
- package/dist/components/meta-data/ui/MetaDataItem.d.ts +16 -0
- package/dist/components/meta-data/ui/MetaDataItem.js +247 -0
- package/dist/components/meta-data/ui/MetaDataTypePopup.d.ts +11 -0
- package/dist/components/meta-data/ui/MetaDataTypePopup.js +62 -0
- package/dist/components/meta-data/ui/MultilineTextMetaField.d.ts +3 -0
- package/dist/components/meta-data/ui/MultilineTextMetaField.js +15 -0
- package/dist/components/meta-data/ui/NumberMetaField.d.ts +3 -0
- package/dist/components/meta-data/ui/NumberMetaField.js +19 -0
- package/dist/components/meta-data/ui/PageRefMetaField.d.ts +3 -0
- package/dist/components/meta-data/ui/PageRefMetaField.js +6 -0
- package/dist/components/meta-data/ui/ProductRefMetaField.d.ts +3 -0
- package/dist/components/meta-data/ui/ProductRefMetaField.js +37 -0
- package/dist/components/meta-data/ui/SingleLineTextMetaField.d.ts +3 -0
- package/dist/components/meta-data/ui/SingleLineTextMetaField.js +18 -0
- package/dist/components/meta-data/ui/VariantRefMetaField.d.ts +3 -0
- package/dist/components/meta-data/ui/VariantRefMetaField.js +45 -0
- package/dist/components/products-picker/api/query.d.ts +8 -0
- package/dist/components/products-picker/api/query.js +24 -0
- package/dist/components/products-picker/index.d.ts +1 -0
- package/dist/components/products-picker/index.js +2 -0
- package/dist/components/products-picker/model/useProducts.d.ts +30 -0
- package/dist/components/products-picker/model/useProducts.js +46 -0
- package/dist/components/products-picker/ui/ProductPicker.d.ts +9 -0
- package/dist/components/products-picker/ui/ProductPicker.js +107 -0
- package/dist/components/products-picker/ui/ProductsPicker.stories.d.ts +17 -0
- package/dist/components/products-picker/ui/ProductsPicker.stories.js +13 -0
- package/dist/components/variants-picker/api/query.d.ts +1 -0
- package/dist/components/variants-picker/api/query.js +2 -2
- package/dist/components/variants-picker/model/useVariants.d.ts +3 -0
- package/dist/components/variants-picker/model/useVariants.js +6 -3
- package/dist/components/variants-picker/ui/VariantsPicker.d.ts +2 -1
- package/dist/components/variants-picker/ui/VariantsPicker.js +3 -2
- package/dist/components/variants-picker/ui/VariantsPicker.stories.d.ts +2 -1
- package/dist/index.d.ts +2 -2
- package/dist/shared/graphql/gql.d.ts +27 -2
- package/dist/shared/graphql/gql.js +7 -2
- package/dist/shared/graphql/graphql.d.ts +2270 -108
- package/dist/shared/graphql/graphql.js +2058 -297
- package/dist/shared/loading/Loading.d.ts +2 -0
- package/dist/shared/loading/Loading.js +11 -0
- package/dist/shared/loading/index.d.ts +1 -0
- package/dist/shared/loading/index.js +2 -0
- package/dist/styles.css +85 -0
- package/package.json +4 -2
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Card } from "@soppiya/elementus";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import MetaData from "./MetaData.js";
|
|
5
|
+
const meta = {
|
|
6
|
+
title: "Example/MetaData",
|
|
7
|
+
component: MetaData
|
|
8
|
+
};
|
|
9
|
+
const MetaData_stories = meta;
|
|
10
|
+
const Product = ()=>{
|
|
11
|
+
const [product, setProduct] = useState([]);
|
|
12
|
+
const handleChange = (field)=>{
|
|
13
|
+
setProduct((prev)=>{
|
|
14
|
+
const exists = prev.find((f)=>f.metafield === field.metafield);
|
|
15
|
+
if (!exists) return [
|
|
16
|
+
...prev,
|
|
17
|
+
field
|
|
18
|
+
];
|
|
19
|
+
return prev.map((f)=>f.metafield === field.metafield ? field : f);
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
return /*#__PURE__*/ jsx(Card, {
|
|
23
|
+
padding: 70,
|
|
24
|
+
children: /*#__PURE__*/ jsx(MetaData, {
|
|
25
|
+
scope: "product",
|
|
26
|
+
value: product,
|
|
27
|
+
onChange: handleChange
|
|
28
|
+
})
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
const Article = ()=>{
|
|
32
|
+
const [product, setProduct] = useState([]);
|
|
33
|
+
const handleChange = (field)=>{
|
|
34
|
+
setProduct((prev)=>{
|
|
35
|
+
const exists = prev.find((f)=>f.metafield === field.metafield);
|
|
36
|
+
if (!exists) return [
|
|
37
|
+
...prev,
|
|
38
|
+
field
|
|
39
|
+
];
|
|
40
|
+
return prev.map((f)=>f.metafield === field.metafield ? field : f);
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
return /*#__PURE__*/ jsx(Card, {
|
|
44
|
+
padding: 70,
|
|
45
|
+
children: /*#__PURE__*/ jsx(MetaData, {
|
|
46
|
+
scope: "article",
|
|
47
|
+
value: product,
|
|
48
|
+
onChange: handleChange
|
|
49
|
+
})
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
const Variant = ()=>{
|
|
53
|
+
const [product, setProduct] = useState([]);
|
|
54
|
+
const handleChange = (field)=>{
|
|
55
|
+
setProduct((prev)=>{
|
|
56
|
+
const exists = prev.find((f)=>f.metafield === field.metafield);
|
|
57
|
+
if (!exists) return [
|
|
58
|
+
...prev,
|
|
59
|
+
field
|
|
60
|
+
];
|
|
61
|
+
return prev.map((f)=>f.metafield === field.metafield ? field : f);
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
return /*#__PURE__*/ jsx(Card, {
|
|
65
|
+
padding: 70,
|
|
66
|
+
children: /*#__PURE__*/ jsx(MetaData, {
|
|
67
|
+
scope: "variant",
|
|
68
|
+
value: product,
|
|
69
|
+
onChange: handleChange
|
|
70
|
+
})
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
const Blog = ()=>{
|
|
74
|
+
const [product, setProduct] = useState([]);
|
|
75
|
+
const handleChange = (field)=>{
|
|
76
|
+
setProduct((prev)=>{
|
|
77
|
+
const exists = prev.find((f)=>f.metafield === field.metafield);
|
|
78
|
+
if (!exists) return [
|
|
79
|
+
...prev,
|
|
80
|
+
field
|
|
81
|
+
];
|
|
82
|
+
return prev.map((f)=>f.metafield === field.metafield ? field : f);
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
return /*#__PURE__*/ jsx(Card, {
|
|
86
|
+
padding: 70,
|
|
87
|
+
children: /*#__PURE__*/ jsx(MetaData, {
|
|
88
|
+
scope: "blog",
|
|
89
|
+
value: product,
|
|
90
|
+
onChange: handleChange
|
|
91
|
+
})
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
const Page = ()=>{
|
|
95
|
+
const [product, setProduct] = useState([]);
|
|
96
|
+
const handleChange = (field)=>{
|
|
97
|
+
setProduct((prev)=>{
|
|
98
|
+
const exists = prev.find((f)=>f.metafield === field.metafield);
|
|
99
|
+
if (!exists) return [
|
|
100
|
+
...prev,
|
|
101
|
+
field
|
|
102
|
+
];
|
|
103
|
+
return prev.map((f)=>f.metafield === field.metafield ? field : f);
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
return /*#__PURE__*/ jsx(Card, {
|
|
107
|
+
padding: 70,
|
|
108
|
+
children: /*#__PURE__*/ jsx(MetaData, {
|
|
109
|
+
scope: "page",
|
|
110
|
+
value: product,
|
|
111
|
+
onChange: handleChange
|
|
112
|
+
})
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
const Collection = ()=>{
|
|
116
|
+
const [product, setProduct] = useState([]);
|
|
117
|
+
const handleChange = (field)=>{
|
|
118
|
+
setProduct((prev)=>{
|
|
119
|
+
const exists = prev.find((f)=>f.metafield === field.metafield);
|
|
120
|
+
if (!exists) return [
|
|
121
|
+
...prev,
|
|
122
|
+
field
|
|
123
|
+
];
|
|
124
|
+
return prev.map((f)=>f.metafield === field.metafield ? field : f);
|
|
125
|
+
});
|
|
126
|
+
};
|
|
127
|
+
return /*#__PURE__*/ jsx(Card, {
|
|
128
|
+
padding: 70,
|
|
129
|
+
children: /*#__PURE__*/ jsx(MetaData, {
|
|
130
|
+
scope: "collection",
|
|
131
|
+
value: product,
|
|
132
|
+
onChange: handleChange
|
|
133
|
+
})
|
|
134
|
+
});
|
|
135
|
+
};
|
|
136
|
+
export { Article, Blog, Collection, Page, Product, Variant, MetaData_stories as default };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Metafield } from "../../../shared/graphql/graphql";
|
|
2
|
+
import React from "react";
|
|
3
|
+
interface Props {
|
|
4
|
+
metaField: Metafield;
|
|
5
|
+
value?: string[];
|
|
6
|
+
onChange?: (value: string[]) => void;
|
|
7
|
+
}
|
|
8
|
+
export interface MetaDataProps {
|
|
9
|
+
entry?: string;
|
|
10
|
+
value?: string;
|
|
11
|
+
children?: React.ReactNode;
|
|
12
|
+
onChange: (value: string) => void;
|
|
13
|
+
onDelete?: () => void;
|
|
14
|
+
}
|
|
15
|
+
declare const MetaDataItem: ({ metaField, value, onChange }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
export default MetaDataItem;
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Button, Card, InlineStack, SoppiyaIcon, Text } from "@soppiya/elementus";
|
|
3
|
+
import ArticlesPicker from "../../articles-picker/ui/ArticlesPicker.js";
|
|
4
|
+
import BlogsPicker from "../../blogs-picker/ui/BlogsPicker.js";
|
|
5
|
+
import CollectionPicker from "../../collections-pciker/ui/CollectionPicker.js";
|
|
6
|
+
import { ProductsPicker } from "../../products-picker/index.js";
|
|
7
|
+
import { VariantsPicker } from "../../variants-picker/index.js";
|
|
8
|
+
import { useClickAway } from "@uidotdev/usehooks";
|
|
9
|
+
import classnames from "classnames";
|
|
10
|
+
import { isEmpty, isFunction, isNumber } from "lodash";
|
|
11
|
+
import react, { useCallback, useState } from "react";
|
|
12
|
+
import meta_types from "../model/meta.types.js";
|
|
13
|
+
import ArticleRefMetaField from "./ArticleRefMetaField.js";
|
|
14
|
+
import BlogRefMetaField from "./BlogRefMetaField.js";
|
|
15
|
+
import BooleanMetaField from "./BooleanMetaField.js";
|
|
16
|
+
import CollectionRefMetaField from "./CollectionRefMetaField.js";
|
|
17
|
+
import ColorMetaField from "./ColorMetaField.js";
|
|
18
|
+
import DateAndTimeMetaField from "./DateAndTimeMetaField.js";
|
|
19
|
+
import DateMetaField from "./DateMetaField.js";
|
|
20
|
+
import MetaDataTypePopup from "./MetaDataTypePopup.js";
|
|
21
|
+
import MultilineTextMetaField from "./MultilineTextMetaField.js";
|
|
22
|
+
import NumberMetaField from "./NumberMetaField.js";
|
|
23
|
+
import PageRefMetaField from "./PageRefMetaField.js";
|
|
24
|
+
import ProductRefMetaField from "./ProductRefMetaField.js";
|
|
25
|
+
import SingleLineTextMetaField from "./SingleLineTextMetaField.js";
|
|
26
|
+
import VariantRefMetaField from "./VariantRefMetaField.js";
|
|
27
|
+
const MetaDataItem_MetaDataItem = ({ metaField, value = [], onChange })=>{
|
|
28
|
+
const [activeMetaField, setActiveMetaField] = useState(null);
|
|
29
|
+
const [visibleExplorer, setVisibleExplorer] = useState("");
|
|
30
|
+
const metaFieldRef = useClickAway(()=>visibleExplorer ? null : setActiveMetaField(null));
|
|
31
|
+
const isRefType = meta_types.isRefType(metaField.type);
|
|
32
|
+
let MetaFieldJSX;
|
|
33
|
+
switch(metaField.type){
|
|
34
|
+
case "date_time":
|
|
35
|
+
MetaFieldJSX = DateAndTimeMetaField;
|
|
36
|
+
break;
|
|
37
|
+
case "date":
|
|
38
|
+
MetaFieldJSX = DateMetaField;
|
|
39
|
+
break;
|
|
40
|
+
case "number":
|
|
41
|
+
MetaFieldJSX = NumberMetaField;
|
|
42
|
+
break;
|
|
43
|
+
case "multiline_text":
|
|
44
|
+
MetaFieldJSX = MultilineTextMetaField;
|
|
45
|
+
break;
|
|
46
|
+
case "single_line_text":
|
|
47
|
+
MetaFieldJSX = SingleLineTextMetaField;
|
|
48
|
+
break;
|
|
49
|
+
case "product_ref":
|
|
50
|
+
MetaFieldJSX = ProductRefMetaField;
|
|
51
|
+
break;
|
|
52
|
+
case "collection_ref":
|
|
53
|
+
MetaFieldJSX = CollectionRefMetaField;
|
|
54
|
+
break;
|
|
55
|
+
case "variant_ref":
|
|
56
|
+
MetaFieldJSX = VariantRefMetaField;
|
|
57
|
+
break;
|
|
58
|
+
case "page_ref":
|
|
59
|
+
MetaFieldJSX = PageRefMetaField;
|
|
60
|
+
break;
|
|
61
|
+
case "article_ref":
|
|
62
|
+
MetaFieldJSX = ArticleRefMetaField;
|
|
63
|
+
break;
|
|
64
|
+
case "blog_ref":
|
|
65
|
+
MetaFieldJSX = BlogRefMetaField;
|
|
66
|
+
break;
|
|
67
|
+
case "boolean":
|
|
68
|
+
MetaFieldJSX = BooleanMetaField;
|
|
69
|
+
break;
|
|
70
|
+
case "color":
|
|
71
|
+
MetaFieldJSX = ColorMetaField;
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
const handleCheckIsMultiple = ()=>{
|
|
75
|
+
if (isRefType && "single" === metaField.entry) return !(value.length >= 1);
|
|
76
|
+
return "multiple" === metaField.entry;
|
|
77
|
+
};
|
|
78
|
+
const handleToggleMetaField = (value)=>{
|
|
79
|
+
setActiveMetaField((prev)=>prev ? null : value);
|
|
80
|
+
};
|
|
81
|
+
const handleAddMetaField = ()=>{
|
|
82
|
+
switch(metaField.type){
|
|
83
|
+
case "product_ref":
|
|
84
|
+
setVisibleExplorer("product");
|
|
85
|
+
break;
|
|
86
|
+
case "collection_ref":
|
|
87
|
+
setVisibleExplorer("collection");
|
|
88
|
+
break;
|
|
89
|
+
case "variant_ref":
|
|
90
|
+
setVisibleExplorer("variant");
|
|
91
|
+
break;
|
|
92
|
+
case "page_ref":
|
|
93
|
+
setVisibleExplorer("page");
|
|
94
|
+
break;
|
|
95
|
+
case "blog_ref":
|
|
96
|
+
setVisibleExplorer("blog");
|
|
97
|
+
break;
|
|
98
|
+
case "article_ref":
|
|
99
|
+
setVisibleExplorer("article");
|
|
100
|
+
break;
|
|
101
|
+
default:
|
|
102
|
+
isFunction(onChange) && onChange(value.concat(""));
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
const handleDeleteMetaField = (i)=>{
|
|
106
|
+
if (!isNumber(i)) return;
|
|
107
|
+
const filteredValue = value.filter((_, index)=>index !== i);
|
|
108
|
+
isFunction(onChange) && onChange(filteredValue);
|
|
109
|
+
};
|
|
110
|
+
const handleClearMetaField = ()=>{
|
|
111
|
+
isFunction(onChange) && onChange([]);
|
|
112
|
+
};
|
|
113
|
+
const handleChange = (newValue, i)=>{
|
|
114
|
+
if (i && "multiple" === metaField.entry) {
|
|
115
|
+
const mappedValue = value.map((item, index)=>index === i ? newValue : item);
|
|
116
|
+
isFunction(onChange) && onChange(mappedValue);
|
|
117
|
+
} else isFunction(onChange) && onChange([
|
|
118
|
+
newValue
|
|
119
|
+
]);
|
|
120
|
+
};
|
|
121
|
+
const handleSelectExplorerItems = useCallback((items)=>{
|
|
122
|
+
isFunction(onChange) && onChange(items);
|
|
123
|
+
setVisibleExplorer("");
|
|
124
|
+
}, [
|
|
125
|
+
visibleExplorer,
|
|
126
|
+
onChange
|
|
127
|
+
]);
|
|
128
|
+
return /*#__PURE__*/ jsxs(react.Fragment, {
|
|
129
|
+
children: [
|
|
130
|
+
/*#__PURE__*/ jsxs(InlineStack, {
|
|
131
|
+
padding: 70,
|
|
132
|
+
className: "border-t border-t-[#ebebeb] relative",
|
|
133
|
+
justifyContent: "space-between",
|
|
134
|
+
children: [
|
|
135
|
+
/*#__PURE__*/ jsx(InlineStack, {
|
|
136
|
+
className: "w-[calc(100%-188px)]! md:w-[calc(100%-256px)]! lg:w-[calc(100%-352px)]!",
|
|
137
|
+
alignItems: "center",
|
|
138
|
+
children: /*#__PURE__*/ jsx(Text, {
|
|
139
|
+
size: "md",
|
|
140
|
+
children: metaField.name
|
|
141
|
+
})
|
|
142
|
+
}),
|
|
143
|
+
/*#__PURE__*/ jsxs(InlineStack, {
|
|
144
|
+
className: "w-[188px]! md:w-[256px]! lg:w-[352px]! bg-[#f1f1f1] py-1.5 px-3 lg:cursor-pointer",
|
|
145
|
+
radius: 3,
|
|
146
|
+
justifyContent: "space-between",
|
|
147
|
+
onClick: ()=>handleToggleMetaField(metaField.type),
|
|
148
|
+
children: [
|
|
149
|
+
/*#__PURE__*/ jsxs(Text, {
|
|
150
|
+
size: "sm",
|
|
151
|
+
weight: "regular",
|
|
152
|
+
children: [
|
|
153
|
+
"[",
|
|
154
|
+
metaField.type,
|
|
155
|
+
"]"
|
|
156
|
+
]
|
|
157
|
+
}),
|
|
158
|
+
/*#__PURE__*/ jsxs(Text, {
|
|
159
|
+
size: "sm",
|
|
160
|
+
weight: "regular",
|
|
161
|
+
children: [
|
|
162
|
+
value.length,
|
|
163
|
+
" item"
|
|
164
|
+
]
|
|
165
|
+
})
|
|
166
|
+
]
|
|
167
|
+
}),
|
|
168
|
+
activeMetaField && /*#__PURE__*/ jsx(Card, {
|
|
169
|
+
radius: 6,
|
|
170
|
+
className: classnames('invisible absolute p-4! left-0 md:-left-5 top-0.5 md:w-[calc(100%+40px)]! z-20', {
|
|
171
|
+
visible: activeMetaField
|
|
172
|
+
}),
|
|
173
|
+
ref: metaFieldRef,
|
|
174
|
+
children: /*#__PURE__*/ jsx(MetaDataTypePopup, {
|
|
175
|
+
name: metaField.name,
|
|
176
|
+
type: metaField.type,
|
|
177
|
+
isMultiple: handleCheckIsMultiple(),
|
|
178
|
+
onAdd: handleAddMetaField,
|
|
179
|
+
onClear: handleClearMetaField,
|
|
180
|
+
children: MetaFieldJSX && ("multiple" !== metaField.entry || isRefType ? /*#__PURE__*/ jsx(MetaFieldJSX, {
|
|
181
|
+
value: isRefType ? value.join(",") : value[0],
|
|
182
|
+
onChange: (v)=>handleChange(v),
|
|
183
|
+
children: /*#__PURE__*/ jsx(Box, {
|
|
184
|
+
children: /*#__PURE__*/ jsx(Button, {
|
|
185
|
+
color: "white",
|
|
186
|
+
onClick: ()=>handleDeleteMetaField(0),
|
|
187
|
+
children: /*#__PURE__*/ jsx(SoppiyaIcon, {
|
|
188
|
+
icon: "minus.svg",
|
|
189
|
+
size: "md"
|
|
190
|
+
})
|
|
191
|
+
})
|
|
192
|
+
})
|
|
193
|
+
}) : (isEmpty(value) ? [
|
|
194
|
+
""
|
|
195
|
+
] : value).map((v, key)=>/*#__PURE__*/ jsx(MetaFieldJSX, {
|
|
196
|
+
entry: metaField.entry,
|
|
197
|
+
onChange: (v)=>handleChange(v, key),
|
|
198
|
+
children: /*#__PURE__*/ jsx(Box, {
|
|
199
|
+
children: /*#__PURE__*/ jsx(Button, {
|
|
200
|
+
color: "white",
|
|
201
|
+
onClick: ()=>handleDeleteMetaField(key),
|
|
202
|
+
children: /*#__PURE__*/ jsx(SoppiyaIcon, {
|
|
203
|
+
icon: "minus.svg",
|
|
204
|
+
size: "md"
|
|
205
|
+
})
|
|
206
|
+
})
|
|
207
|
+
})
|
|
208
|
+
}, key)))
|
|
209
|
+
})
|
|
210
|
+
})
|
|
211
|
+
]
|
|
212
|
+
}),
|
|
213
|
+
"product" === visibleExplorer && /*#__PURE__*/ jsx(ProductsPicker, {
|
|
214
|
+
limit: "multiple" === metaField.entry ? 1 / 0 : 1,
|
|
215
|
+
initialIds: value,
|
|
216
|
+
onClose: ()=>setVisibleExplorer(""),
|
|
217
|
+
onOk: handleSelectExplorerItems
|
|
218
|
+
}),
|
|
219
|
+
"variant" === visibleExplorer && /*#__PURE__*/ jsx(VariantsPicker, {
|
|
220
|
+
limit: "multiple" === metaField.entry ? 1 / 0 : 1,
|
|
221
|
+
initialIds: value,
|
|
222
|
+
onClose: ()=>setVisibleExplorer(""),
|
|
223
|
+
onOk: handleSelectExplorerItems
|
|
224
|
+
}),
|
|
225
|
+
"article" === visibleExplorer && /*#__PURE__*/ jsx(ArticlesPicker, {
|
|
226
|
+
initialIds: value,
|
|
227
|
+
limit: "multiple" === metaField.entry ? 1 / 0 : 1,
|
|
228
|
+
onClose: ()=>setVisibleExplorer(""),
|
|
229
|
+
onOk: handleSelectExplorerItems
|
|
230
|
+
}),
|
|
231
|
+
"collection" === visibleExplorer && /*#__PURE__*/ jsx(CollectionPicker, {
|
|
232
|
+
initialIds: value,
|
|
233
|
+
limit: "multiple" === metaField.entry ? 1 / 0 : 1,
|
|
234
|
+
onClose: ()=>setVisibleExplorer(""),
|
|
235
|
+
onOk: handleSelectExplorerItems
|
|
236
|
+
}),
|
|
237
|
+
"blog" === visibleExplorer && /*#__PURE__*/ jsx(BlogsPicker, {
|
|
238
|
+
initialIds: value,
|
|
239
|
+
limit: "multiple" === metaField.entry ? 1 / 0 : 1,
|
|
240
|
+
onClose: ()=>setVisibleExplorer(""),
|
|
241
|
+
onOk: handleSelectExplorerItems
|
|
242
|
+
})
|
|
243
|
+
]
|
|
244
|
+
});
|
|
245
|
+
};
|
|
246
|
+
const MetaDataItem = MetaDataItem_MetaDataItem;
|
|
247
|
+
export { MetaDataItem as default };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
interface Props {
|
|
3
|
+
isMultiple: boolean;
|
|
4
|
+
name: string;
|
|
5
|
+
type: string;
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
onAdd?: () => void;
|
|
8
|
+
onClear?: () => void;
|
|
9
|
+
}
|
|
10
|
+
declare const MetaFieldTypePopup: ({ isMultiple, name, type, children, onAdd, onClear }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export default MetaFieldTypePopup;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { BlockStack, Button, InlineStack, Text } from "@soppiya/elementus";
|
|
3
|
+
import react from "react";
|
|
4
|
+
import meta_types from "../model/meta.types.js";
|
|
5
|
+
const MetaFieldTypePopup = ({ isMultiple, name, type, children, onAdd, onClear })=>{
|
|
6
|
+
const isRefType = meta_types.isRefType(type);
|
|
7
|
+
const textCapitalize = (value)=>value.split("_").map((w)=>w.charAt(0).toUpperCase() + w.slice(1)).join(" ");
|
|
8
|
+
return /*#__PURE__*/ jsx(react.Fragment, {
|
|
9
|
+
children: /*#__PURE__*/ jsxs(InlineStack, {
|
|
10
|
+
children: [
|
|
11
|
+
/*#__PURE__*/ jsxs(BlockStack, {
|
|
12
|
+
className: "w-[170px]!",
|
|
13
|
+
children: [
|
|
14
|
+
/*#__PURE__*/ jsx(Text, {
|
|
15
|
+
size: "md",
|
|
16
|
+
decoration: "underline",
|
|
17
|
+
children: name
|
|
18
|
+
}),
|
|
19
|
+
/*#__PURE__*/ jsx(Text, {
|
|
20
|
+
size: "md",
|
|
21
|
+
color: "secondary",
|
|
22
|
+
children: textCapitalize(type)
|
|
23
|
+
})
|
|
24
|
+
]
|
|
25
|
+
}),
|
|
26
|
+
/*#__PURE__*/ jsxs(BlockStack, {
|
|
27
|
+
className: "grow",
|
|
28
|
+
children: [
|
|
29
|
+
isMultiple && /*#__PURE__*/ jsx(BlockStack, {
|
|
30
|
+
children: /*#__PURE__*/ jsxs(InlineStack, {
|
|
31
|
+
justifyContent: "space-between",
|
|
32
|
+
className: "border-b border-b-[#ebebeb] pb-2",
|
|
33
|
+
children: [
|
|
34
|
+
/*#__PURE__*/ jsx(Button, {
|
|
35
|
+
color: "white",
|
|
36
|
+
onClick: onAdd,
|
|
37
|
+
children: isRefType ? `Select ${type.split("_")[0]}` : "Add Item"
|
|
38
|
+
}),
|
|
39
|
+
/*#__PURE__*/ jsx(Button, {
|
|
40
|
+
variant: "plain",
|
|
41
|
+
color: "blue",
|
|
42
|
+
onClick: onClear,
|
|
43
|
+
children: "Clear all"
|
|
44
|
+
})
|
|
45
|
+
]
|
|
46
|
+
})
|
|
47
|
+
}),
|
|
48
|
+
/*#__PURE__*/ jsx(BlockStack, {
|
|
49
|
+
gap: 50,
|
|
50
|
+
padding: {
|
|
51
|
+
top: 70
|
|
52
|
+
},
|
|
53
|
+
children: children
|
|
54
|
+
})
|
|
55
|
+
]
|
|
56
|
+
})
|
|
57
|
+
]
|
|
58
|
+
})
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
const MetaDataTypePopup = MetaFieldTypePopup;
|
|
62
|
+
export { MetaDataTypePopup as default };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Textarea } from "@soppiya/elementus";
|
|
3
|
+
const MultilineTextMetaField_MultilineTextMetaField = ({ entry, value, children, onChange })=>/*#__PURE__*/ jsxs("div", {
|
|
4
|
+
children: [
|
|
5
|
+
/*#__PURE__*/ jsx("div", {
|
|
6
|
+
children: /*#__PURE__*/ jsx(Textarea, {
|
|
7
|
+
value: value,
|
|
8
|
+
onChange: (e)=>onChange(e.target.value)
|
|
9
|
+
})
|
|
10
|
+
}),
|
|
11
|
+
"multiple" === entry && children
|
|
12
|
+
]
|
|
13
|
+
});
|
|
14
|
+
const MultilineTextMetaField = MultilineTextMetaField_MultilineTextMetaField;
|
|
15
|
+
export { MultilineTextMetaField as default };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Input } from "@soppiya/elementus";
|
|
3
|
+
const NumberMetaField = ({ entry, value, children, onChange })=>/*#__PURE__*/ jsxs("div", {
|
|
4
|
+
children: [
|
|
5
|
+
/*#__PURE__*/ jsx("div", {
|
|
6
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
7
|
+
children: /*#__PURE__*/ jsx(Input, {
|
|
8
|
+
size: "sm",
|
|
9
|
+
type: "number",
|
|
10
|
+
value: value,
|
|
11
|
+
onChange: (e)=>onChange(e.target.value)
|
|
12
|
+
})
|
|
13
|
+
})
|
|
14
|
+
}),
|
|
15
|
+
"multiple" === entry && children
|
|
16
|
+
]
|
|
17
|
+
});
|
|
18
|
+
const ui_NumberMetaField = NumberMetaField;
|
|
19
|
+
export { ui_NumberMetaField as default };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useProducts } from "../../products-picker/model/useProducts.js";
|
|
3
|
+
import { Loading } from "../../../shared/loading/index.js";
|
|
4
|
+
import { Image, InlineStack, Text } from "@soppiya/elementus";
|
|
5
|
+
const ProductRefMetaField = ({ value, children })=>{
|
|
6
|
+
const { products, isLoadingProducts } = useProducts({
|
|
7
|
+
skip: !value,
|
|
8
|
+
filterKeys: {
|
|
9
|
+
cursors: value?.split(",")
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
if (isLoadingProducts) return /*#__PURE__*/ jsx(Loading, {});
|
|
13
|
+
return products?.map((product)=>/*#__PURE__*/ jsxs(InlineStack, {
|
|
14
|
+
justifyContent: "space-between",
|
|
15
|
+
children: [
|
|
16
|
+
/*#__PURE__*/ jsxs(InlineStack, {
|
|
17
|
+
alignItems: "center",
|
|
18
|
+
gapX: 70,
|
|
19
|
+
children: [
|
|
20
|
+
/*#__PURE__*/ jsx(Image, {
|
|
21
|
+
size: "xs",
|
|
22
|
+
url: product.image?.url ?? ""
|
|
23
|
+
}),
|
|
24
|
+
/*#__PURE__*/ jsx(Text, {
|
|
25
|
+
size: "md",
|
|
26
|
+
weight: "regular",
|
|
27
|
+
color: "blue",
|
|
28
|
+
children: product.title
|
|
29
|
+
})
|
|
30
|
+
]
|
|
31
|
+
}),
|
|
32
|
+
children
|
|
33
|
+
]
|
|
34
|
+
}, product._id));
|
|
35
|
+
};
|
|
36
|
+
const ui_ProductRefMetaField = ProductRefMetaField;
|
|
37
|
+
export { ui_ProductRefMetaField as default };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Input } from "@soppiya/elementus";
|
|
3
|
+
const SingleLineTextMetaField_SingleLineTextMetaField = ({ entry, value, children, onChange })=>/*#__PURE__*/ jsxs("div", {
|
|
4
|
+
children: [
|
|
5
|
+
/*#__PURE__*/ jsx("div", {
|
|
6
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
7
|
+
children: /*#__PURE__*/ jsx(Input, {
|
|
8
|
+
size: "sm",
|
|
9
|
+
value: value,
|
|
10
|
+
onChange: (e)=>onChange(e.target.value)
|
|
11
|
+
})
|
|
12
|
+
})
|
|
13
|
+
}),
|
|
14
|
+
"multiple" === entry && children
|
|
15
|
+
]
|
|
16
|
+
});
|
|
17
|
+
const SingleLineTextMetaField = SingleLineTextMetaField_SingleLineTextMetaField;
|
|
18
|
+
export { SingleLineTextMetaField as default };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useVariants } from "../../variants-picker/model/useVariants.js";
|
|
3
|
+
import { Loading } from "../../../shared/loading/index.js";
|
|
4
|
+
import { Image, InlineStack, Text } from "@soppiya/elementus";
|
|
5
|
+
const VariantRefMetaField_VariantRefMetaField = ({ value, children })=>{
|
|
6
|
+
const { variants, isLoadingVariants } = useVariants({
|
|
7
|
+
skip: !value,
|
|
8
|
+
filterKeys: {
|
|
9
|
+
cursors: value?.split(",")
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
if (isLoadingVariants) return /*#__PURE__*/ jsx(Loading, {});
|
|
13
|
+
return variants?.map((variant)=>/*#__PURE__*/ jsxs(InlineStack, {
|
|
14
|
+
justifyContent: "space-between",
|
|
15
|
+
children: [
|
|
16
|
+
/*#__PURE__*/ jsxs(InlineStack, {
|
|
17
|
+
gapX: 70,
|
|
18
|
+
alignItems: "center",
|
|
19
|
+
children: [
|
|
20
|
+
/*#__PURE__*/ jsx(Image, {
|
|
21
|
+
size: "xs",
|
|
22
|
+
url: variant.image?.url ?? ""
|
|
23
|
+
}),
|
|
24
|
+
/*#__PURE__*/ jsxs(Text, {
|
|
25
|
+
size: "md",
|
|
26
|
+
weight: "regular",
|
|
27
|
+
color: "blue",
|
|
28
|
+
children: [
|
|
29
|
+
variant.product?.title,
|
|
30
|
+
" ",
|
|
31
|
+
[
|
|
32
|
+
variant.option1,
|
|
33
|
+
variant.option2,
|
|
34
|
+
variant.option3
|
|
35
|
+
].filter(Boolean).join(", ")
|
|
36
|
+
]
|
|
37
|
+
})
|
|
38
|
+
]
|
|
39
|
+
}),
|
|
40
|
+
children
|
|
41
|
+
]
|
|
42
|
+
}, variant._id));
|
|
43
|
+
};
|
|
44
|
+
const VariantRefMetaField = VariantRefMetaField_VariantRefMetaField;
|
|
45
|
+
export { VariantRefMetaField as default };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const productsQuery: import("@graphql-typed-document-node/core").TypedDocumentNode<import("../../../shared/graphql/graphql").ProductsQuery, 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").ProductFilterKeys>;
|
|
8
|
+
}>>;
|