@soppiya/app-bridge 1.1.3 → 1.1.5

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.
@@ -1 +1 @@
1
- export { default as MetaData } from "./ui/MetaData";
1
+ export { default as MetaData, type MetaFieldData } from "./ui/MetaData";
@@ -1,22 +1,24 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
- import { Radio } from "@soppiya/elementus";
3
- const BooleanMetaField = ({ entry, value, children, onChange })=>/*#__PURE__*/ jsxs("div", {
2
+ import { BlockStack, InlineStack, Radio } from "@soppiya/elementus";
3
+ const BooleanMetaField = ({ entry, value, children, onChange })=>/*#__PURE__*/ jsxs(InlineStack, {
4
+ justifyContent: "space-between",
4
5
  children: [
5
- /*#__PURE__*/ jsxs("div", {
6
+ /*#__PURE__*/ jsxs(BlockStack, {
7
+ gapY: 60,
6
8
  children: [
7
9
  /*#__PURE__*/ jsx(Radio, {
8
10
  label: "True",
9
11
  name: "boolean",
10
12
  checked: "true" === value,
11
- value: value,
12
- onChange: (e)=>onChange(e.target.value)
13
+ labelPosition: "center",
14
+ onChange: (e)=>onChange("true")
13
15
  }),
14
16
  /*#__PURE__*/ jsx(Radio, {
15
17
  label: "False",
16
18
  name: "boolean",
17
19
  checked: "false" === value,
18
- value: value,
19
- onChange: (e)=>onChange(e.target.value)
20
+ labelPosition: "center",
21
+ onChange: (e)=>onChange("false")
20
22
  })
21
23
  ]
22
24
  }),
@@ -10,7 +10,6 @@ const DateAndTimeMetaField = ({ entry, value, children, onChange })=>{
10
10
  const transformValue = ()=>{
11
11
  if (!value) return "";
12
12
  const date = moment(Number(value)).format("YYYY-MM-DDThh:mm");
13
- console.log(date);
14
13
  return date ? date : "";
15
14
  };
16
15
  return /*#__PURE__*/ jsxs(InlineStack, {
@@ -1,14 +1,15 @@
1
+ export type MetaFieldData = {
2
+ metafield: string;
3
+ value: string[];
4
+ };
1
5
  interface Props {
2
6
  title?: string;
3
7
  scope: string;
4
- value?: {
5
- metafield: string;
6
- value: string[];
7
- }[];
8
+ metafieldsData?: MetaFieldData[];
8
9
  onChange?: (value: {
9
10
  metafield: string;
10
11
  value: string[];
11
12
  }) => void;
12
13
  }
13
- declare const MetaData: ({ title, scope, value, onChange }: Props) => import("react/jsx-runtime").JSX.Element;
14
+ declare const MetaData: ({ title, scope, metafieldsData, onChange }: Props) => import("react/jsx-runtime").JSX.Element;
14
15
  export default MetaData;
@@ -1,21 +1,20 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { Loading } from "../../../shared/loading/index.js";
3
3
  import { BlockStack, Card, Text } from "@soppiya/elementus";
4
- import { isFunction } from "lodash";
5
4
  import { useGetMetaFields } from "../model/useGetMetaFields.js";
6
5
  import MetaDataItem from "./MetaDataItem.js";
7
- const MetaData_MetaData = ({ title = "Meta fields", scope = "product", value = [], onChange })=>{
6
+ const MetaData_MetaData = ({ title = "Meta fields", scope = "product", metafieldsData = [], onChange })=>{
8
7
  const { metafields, loading } = useGetMetaFields([
9
8
  scope
10
9
  ]);
11
10
  const handleChange = (metaFieldID, value)=>{
12
- isFunction(onChange) && onChange({
11
+ onChange?.({
13
12
  metafield: metaFieldID,
14
13
  value
15
14
  });
16
15
  };
17
16
  const getMetaFieldValue = (_id)=>{
18
- const metaField = value.find((item)=>item.metafield === _id);
17
+ const metaField = metafieldsData.find((metafieldData)=>metafieldData.metafield === _id);
19
18
  return metaField?.value;
20
19
  };
21
20
  if (0 === metafields.length) return /*#__PURE__*/ jsxs(Card, {
@@ -23,7 +23,7 @@ const Product = ()=>{
23
23
  padding: 70,
24
24
  children: /*#__PURE__*/ jsx(MetaData, {
25
25
  scope: "product",
26
- value: product,
26
+ metafieldsData: product,
27
27
  onChange: handleChange
28
28
  })
29
29
  });
@@ -44,7 +44,7 @@ const Article = ()=>{
44
44
  padding: 70,
45
45
  children: /*#__PURE__*/ jsx(MetaData, {
46
46
  scope: "article",
47
- value: product,
47
+ metafieldsData: product,
48
48
  onChange: handleChange
49
49
  })
50
50
  });
@@ -65,13 +65,21 @@ const Variant = ()=>{
65
65
  padding: 70,
66
66
  children: /*#__PURE__*/ jsx(MetaData, {
67
67
  scope: "variant",
68
- value: product,
68
+ metafieldsData: product,
69
69
  onChange: handleChange
70
70
  })
71
71
  });
72
72
  };
73
73
  const Blog = ()=>{
74
- const [product, setProduct] = useState([]);
74
+ const [product, setProduct] = useState([
75
+ {
76
+ metafield: "6942410d5da4f9634de8a7a9",
77
+ value: [
78
+ "694287616791846093ad7887",
79
+ "6943a80e984d8813d65098b7"
80
+ ]
81
+ }
82
+ ]);
75
83
  const handleChange = (field)=>{
76
84
  setProduct((prev)=>{
77
85
  const exists = prev.find((f)=>f.metafield === field.metafield);
@@ -86,7 +94,7 @@ const Blog = ()=>{
86
94
  padding: 70,
87
95
  children: /*#__PURE__*/ jsx(MetaData, {
88
96
  scope: "blog",
89
- value: product,
97
+ metafieldsData: product,
90
98
  onChange: handleChange
91
99
  })
92
100
  });
@@ -107,7 +115,7 @@ const Page = ()=>{
107
115
  padding: 70,
108
116
  children: /*#__PURE__*/ jsx(MetaData, {
109
117
  scope: "page",
110
- value: product,
118
+ metafieldsData: product,
111
119
  onChange: handleChange
112
120
  })
113
121
  });
@@ -128,7 +136,7 @@ const Collection = ()=>{
128
136
  padding: 70,
129
137
  children: /*#__PURE__*/ jsx(MetaData, {
130
138
  scope: "collection",
131
- value: product,
139
+ metafieldsData: product,
132
140
  onChange: handleChange
133
141
  })
134
142
  });
@@ -168,7 +168,7 @@ const MetaDataItem_MetaDataItem = ({ metaField, value = [], onChange })=>{
168
168
  }),
169
169
  activeMetaField && /*#__PURE__*/ jsx(Card, {
170
170
  radius: 6,
171
- className: classnames('invisible absolute p-4! left-0 md:-left-5 top-0.5 md:w-[calc(100%+40px)]! z-20', {
171
+ className: classnames('invisible absolute p-4! left-0 md:-left-5! top-0.5 md:w-[calc(100%+40px)]! z-20', {
172
172
  visible: activeMetaField
173
173
  }),
174
174
  ref: metaFieldRef,
@@ -196,6 +196,7 @@ const MetaDataItem_MetaDataItem = ({ metaField, value = [], onChange })=>{
196
196
  ""
197
197
  ] : value).map((v, key)=>/*#__PURE__*/ jsx(MetaFieldJSX, {
198
198
  entry: metaField.entry,
199
+ value: v,
199
200
  onChange: (v)=>handleChange(v, key),
200
201
  children: /*#__PURE__*/ jsx(InlineStack, {
201
202
  alignItems: "center",
@@ -38,7 +38,7 @@ const MetaFieldTypePopup = ({ isMultiple, name, type, children, onAdd, onClear }
38
38
  md: children ? 70 : 0
39
39
  }
40
40
  },
41
- className: "border-b border-b-[#ebebeb] md:border-b-transparent pb-4 md:pb-0 ",
41
+ className: "border-b border-b-[#ebebeb] md:border-b-transparent pb-4 md:pb-0",
42
42
  children: children
43
43
  }),
44
44
  isMultiple && /*#__PURE__*/ jsx(BlockStack, {
File without changes
File without changes
File without changes
@@ -0,0 +1,2 @@
1
+ declare const MetafieldsPicker: () => import("react/jsx-runtime").JSX.Element;
2
+ export default MetafieldsPicker;
@@ -0,0 +1,7 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { Modal } from "@soppiya/elementus";
3
+ const MetafieldsPicker = ()=>/*#__PURE__*/ jsx(Modal, {
4
+ open: true
5
+ });
6
+ const ui_MetafieldsPicker = MetafieldsPicker;
7
+ export { ui_MetafieldsPicker as default };
@@ -0,0 +1,6 @@
1
+ declare const meta: {
2
+ title: string;
3
+ component: () => import("react/jsx-runtime").JSX.Element;
4
+ };
5
+ export default meta;
6
+ export declare const Default: () => void;
@@ -0,0 +1,8 @@
1
+ import MetafieldsPicker from "./MetafieldsPicker.js";
2
+ const meta = {
3
+ title: "Example/MetafieldsPicker",
4
+ component: MetafieldsPicker
5
+ };
6
+ const MetafieldsPicker_stories = meta;
7
+ const Default = ()=>{};
8
+ export { Default, MetafieldsPicker_stories as default };
@@ -75,6 +75,7 @@ export type AddArticle = {
75
75
  meta_description?: InputMaybe<Scalars['String']['input']>;
76
76
  meta_tags?: InputMaybe<Array<InputMaybe<Scalars['String']['input']>>>;
77
77
  meta_title?: InputMaybe<Scalars['String']['input']>;
78
+ metafields?: InputMaybe<Array<InputMaybe<MetafieldInput>>>;
78
79
  status?: InputMaybe<ArticleStatus>;
79
80
  template?: InputMaybe<Scalars['String']['input']>;
80
81
  title: Scalars['String']['input'];
package/dist/styles.css CHANGED
@@ -715,8 +715,8 @@
715
715
  top: calc(var(--spacing) * 0);
716
716
  }
717
717
 
718
- .md\:-left-5 {
719
- left: calc(var(--spacing) * -5);
718
+ .md\:-left-5\! {
719
+ left: calc(var(--spacing) * -5) !important;
720
720
  }
721
721
 
722
722
  .md\:mt-0 {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soppiya/app-bridge",
3
- "version": "1.1.3",
3
+ "version": "1.1.5",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {