@weaverse/react 0.4.0 → 0.4.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 (3) hide show
  1. package/dist/index.js +106 -33
  2. package/dist/index.mjs +106 -33
  3. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -70,26 +70,23 @@ BaseElement.defaultProps = {
70
70
  style: {}
71
71
  };
72
72
  var schema = {
73
- type: "base"
73
+ type: "base",
74
+ title: "Base",
75
+ settings: []
74
76
  };
75
77
  var base_default = BaseElement;
76
78
 
77
79
  // src/elements/button.tsx
78
80
  var React2 = __toESM(require("react"));
79
81
  var Button = React2.forwardRef((props, ref) => {
80
- const _a = props, { style } = _a, rest = __objRest(_a, ["style"]);
82
+ const _a = props, { style, buttonType, css } = _a, rest = __objRest(_a, ["style", "buttonType", "css"]);
81
83
  return /* @__PURE__ */ React2.createElement("button", __spreadValues({
82
84
  ref,
83
85
  style
84
86
  }, rest), props.value);
85
87
  });
86
88
  Button.defaultProps = {
87
- value: "Click me",
88
- style: {
89
- borderRadius: "9999px",
90
- fontSize: "13px",
91
- padding: "10px 15px"
92
- }
89
+ value: "Click me"
93
90
  };
94
91
  var schema2 = {
95
92
  title: "Button",
@@ -105,6 +102,16 @@ var schema2 = {
105
102
  }
106
103
  ]
107
104
  },
105
+ {
106
+ tab: "Settings",
107
+ label: "Spacing",
108
+ inspectors: [
109
+ {
110
+ binding: "style",
111
+ type: "spacing"
112
+ }
113
+ ]
114
+ },
108
115
  {
109
116
  tab: "Settings",
110
117
  label: "Overlay",
@@ -114,6 +121,16 @@ var schema2 = {
114
121
  key: "applyOverlay",
115
122
  label: "Apply Overlay",
116
123
  type: "switch"
124
+ },
125
+ {
126
+ binding: "data",
127
+ key: "buttonType",
128
+ label: "Button Type",
129
+ type: "select",
130
+ options: [
131
+ { value: 1, label: "One" },
132
+ { value: 2, label: "Two" }
133
+ ]
117
134
  }
118
135
  ]
119
136
  },
@@ -147,15 +164,60 @@ var schema2 = {
147
164
  ]
148
165
  }
149
166
  ],
150
- toolbar: []
167
+ toolbar: [],
168
+ data: {
169
+ css: {
170
+ "@desktop": {
171
+ borderRadius: "9999px",
172
+ fontSize: "13px",
173
+ padding: "10px 15px"
174
+ }
175
+ }
176
+ }
151
177
  };
152
178
  var button_default = Button;
153
179
 
180
+ // src/elements/grid.tsx
181
+ var import_react2 = __toESM(require("react"));
182
+ var Grid = (0, import_react2.forwardRef)((props, ref) => {
183
+ return /* @__PURE__ */ import_react2.default.createElement("div", __spreadValues({
184
+ ref
185
+ }, props));
186
+ });
187
+ var schema3 = {
188
+ title: "Grid",
189
+ type: "grid",
190
+ data: {
191
+ css: {
192
+ "@desktop": {
193
+ display: "grid",
194
+ gridTemplateRows: "repeat(auto-fill, 48px)",
195
+ gridTemplateColumns: "repeat(24, 1fr)",
196
+ gridGap: "8px",
197
+ minHeight: "480px",
198
+ backgroundColor: "#c7c7c7"
199
+ }
200
+ }
201
+ },
202
+ settings: [
203
+ {
204
+ tab: "Layout",
205
+ label: "Grid",
206
+ inspectors: [
207
+ {
208
+ type: "grid"
209
+ }
210
+ ]
211
+ }
212
+ ]
213
+ };
214
+ var grid_default = Grid;
215
+
154
216
  // src/elements/text.tsx
155
- var React3 = __toESM(require("react"));
156
- var Text = React3.forwardRef((props, ref) => {
217
+ var React4 = __toESM(require("react"));
218
+ var Text = React4.forwardRef((props, ref) => {
157
219
  let _a = props, { children, value } = _a, rest = __objRest(_a, ["children", "value"]);
158
- return /* @__PURE__ */ React3.createElement("span", __spreadProps(__spreadValues({
220
+ return /* @__PURE__ */ React4.createElement("span", __spreadProps(__spreadValues({
159
221
  ref
160
222
  }, rest), {
161
223
  contentEditable: true,
@@ -166,18 +228,25 @@ Text.defaultProps = {
166
228
  value: "sample text",
167
229
  tag: "span"
168
230
  };
169
- var schema3 = {
231
+ var schema4 = {
170
232
  type: "text",
171
- inspectors: [
172
- {
173
- binding: "data",
174
- key: "value",
175
- componentType: "textarea"
176
- },
233
+ title: "Text Settings",
234
+ settings: [
177
235
  {
178
- binding: "style",
179
- key: "color",
180
- componentType: "color"
236
+ tab: "General",
237
+ label: "Text",
238
+ inspectors: [
239
+ {
240
+ binding: "data",
241
+ key: "value",
242
+ type: "textarea"
243
+ },
244
+ {
245
+ binding: "style",
246
+ key: "color",
247
+ type: "color"
248
+ }
249
+ ]
181
250
  }
182
251
  ]
183
252
  };
@@ -195,6 +264,10 @@ var elements = {
195
264
  },
196
265
  Text: {
197
266
  Component: text_default,
267
+ schema: schema4
268
+ },
269
+ Grid: {
270
+ Component: grid_default,
198
271
  schema: schema3
199
272
  }
200
273
  };
@@ -211,7 +284,7 @@ var shortCssObject = (css) => {
211
284
 
212
285
  // src/renderer.tsx
213
286
  var import_core = require("@weaverse/core");
214
- var React4 = __toESM(require("react"));
287
+ var React5 = __toESM(require("react"));
215
288
  var createRootContext = (configs) => {
216
289
  const rootContext = new import_core.Weaverse(configs);
217
290
  Object.keys(elements_default).forEach((key) => {
@@ -224,8 +297,8 @@ var WeaverseRoot = ({
224
297
  defaultData
225
298
  }) => {
226
299
  var _a, _b, _c;
227
- let [, setData] = React4.useState(context.projectData);
228
- React4.useEffect(() => {
300
+ let [, setData] = React5.useState(context.projectData);
301
+ React5.useEffect(() => {
229
302
  let handleUpdate = () => {
230
303
  setData(__spreadValues({}, context.projectData));
231
304
  };
@@ -240,18 +313,18 @@ var WeaverseRoot = ({
240
313
  context.initProjectItemData();
241
314
  }
242
315
  let handleProps = ((_c = context == null ? void 0 : context.studioBridge) == null ? void 0 : _c.handleProps) || {};
243
- return /* @__PURE__ */ React4.createElement("div", __spreadValues({
316
+ return /* @__PURE__ */ React5.createElement("div", __spreadValues({
244
317
  className: `weaverse-root`,
245
318
  id: "weaverse-root"
246
- }, handleProps), /* @__PURE__ */ React4.createElement(RenderItem, {
319
+ }, handleProps), /* @__PURE__ */ React5.createElement(RenderItem, {
247
320
  itemId: context.projectData.rootId || 0,
248
321
  context
249
322
  }));
250
323
  };
251
324
  var Item = ({ itemInstance, elementInstances, context }) => {
252
- let [data, setData] = React4.useState(itemInstance.data);
325
+ let [data, setData] = React5.useState(itemInstance.data);
253
326
  let _a = data, { id, type, childIds, css, className } = _a, rest = __objRest(_a, ["id", "type", "childIds", "css", "className"]);
254
- React4.useEffect(() => {
327
+ React5.useEffect(() => {
255
328
  let handleUpdate = (update) => {
256
329
  setData(__spreadValues({}, update));
257
330
  };
@@ -277,12 +350,12 @@ var Item = ({ itemInstance, elementInstances, context }) => {
277
350
  if (Component.$$typeof === Symbol.for("react.forward_ref")) {
278
351
  rest.ref = itemInstance.ref;
279
352
  }
280
- return /* @__PURE__ */ React4.createElement(Component, __spreadProps(__spreadValues({
353
+ return /* @__PURE__ */ React5.createElement(Component, __spreadProps(__spreadValues({
281
354
  key: id,
282
355
  "data-wv-id": id
283
356
  }, rest), {
284
357
  className: realClassName
285
- }), Array.isArray(childIds) && childIds.map((childId) => /* @__PURE__ */ React4.createElement(RenderItem, {
358
+ }), Array.isArray(childIds) && childIds.map((childId) => /* @__PURE__ */ React5.createElement(RenderItem, {
286
359
  key: childId,
287
360
  itemId: childId,
288
361
  context
@@ -297,13 +370,13 @@ var RenderItem = ({
297
370
  let { itemInstances, elementInstances } = context;
298
371
  let itemInstance = itemInstances.get(itemId);
299
372
  if (itemInstance) {
300
- return /* @__PURE__ */ React4.createElement(Item, {
373
+ return /* @__PURE__ */ React5.createElement(Item, {
301
374
  itemInstance,
302
375
  elementInstances,
303
376
  context
304
377
  });
305
378
  }
306
- return /* @__PURE__ */ React4.createElement(React4.Fragment, null);
379
+ return /* @__PURE__ */ React5.createElement(React5.Fragment, null);
307
380
  };
308
381
 
309
382
  // src/index.ts
package/dist/index.mjs CHANGED
@@ -43,26 +43,23 @@ BaseElement.defaultProps = {
43
43
  style: {}
44
44
  };
45
45
  var schema = {
46
- type: "base"
46
+ type: "base",
47
+ title: "Base",
48
+ settings: []
47
49
  };
48
50
  var base_default = BaseElement;
49
51
 
50
52
  // src/elements/button.tsx
51
53
  import * as React2 from "react";
52
54
  var Button = React2.forwardRef((props, ref) => {
53
- const _a = props, { style } = _a, rest = __objRest(_a, ["style"]);
55
+ const _a = props, { style, buttonType, css } = _a, rest = __objRest(_a, ["style", "buttonType", "css"]);
54
56
  return /* @__PURE__ */ React2.createElement("button", __spreadValues({
55
57
  ref,
56
58
  style
57
59
  }, rest), props.value);
58
60
  });
59
61
  Button.defaultProps = {
60
- value: "Click me",
61
- style: {
62
- borderRadius: "9999px",
63
- fontSize: "13px",
64
- padding: "10px 15px"
65
- }
62
+ value: "Click me"
66
63
  };
67
64
  var schema2 = {
68
65
  title: "Button",
@@ -78,6 +75,16 @@ var schema2 = {
78
75
  }
79
76
  ]
80
77
  },
78
+ {
79
+ tab: "Settings",
80
+ label: "Spacing",
81
+ inspectors: [
82
+ {
83
+ binding: "style",
84
+ type: "spacing"
85
+ }
86
+ ]
87
+ },
81
88
  {
82
89
  tab: "Settings",
83
90
  label: "Overlay",
@@ -87,6 +94,16 @@ var schema2 = {
87
94
  key: "applyOverlay",
88
95
  label: "Apply Overlay",
89
96
  type: "switch"
97
+ },
98
+ {
99
+ binding: "data",
100
+ key: "buttonType",
101
+ label: "Button Type",
102
+ type: "select",
103
+ options: [
104
+ { value: 1, label: "One" },
105
+ { value: 2, label: "Two" }
106
+ ]
90
107
  }
91
108
  ]
92
109
  },
@@ -120,15 +137,60 @@ var schema2 = {
120
137
  ]
121
138
  }
122
139
  ],
123
- toolbar: []
140
+ toolbar: [],
141
+ data: {
142
+ css: {
143
+ "@desktop": {
144
+ borderRadius: "9999px",
145
+ fontSize: "13px",
146
+ padding: "10px 15px"
147
+ }
148
+ }
149
+ }
124
150
  };
125
151
  var button_default = Button;
126
152
 
153
+ // src/elements/grid.tsx
154
+ import React3, { forwardRef as forwardRef2 } from "react";
155
+ var Grid = forwardRef2((props, ref) => {
156
+ return /* @__PURE__ */ React3.createElement("div", __spreadValues({
157
+ ref
158
+ }, props));
159
+ });
160
+ var schema3 = {
161
+ title: "Grid",
162
+ type: "grid",
163
+ data: {
164
+ css: {
165
+ "@desktop": {
166
+ display: "grid",
167
+ gridTemplateRows: "repeat(auto-fill, 48px)",
168
+ gridTemplateColumns: "repeat(24, 1fr)",
169
+ gridGap: "8px",
170
+ minHeight: "480px",
171
+ backgroundColor: "#c7c7c7"
172
+ }
173
+ }
174
+ },
175
+ settings: [
176
+ {
177
+ tab: "Layout",
178
+ label: "Grid",
179
+ inspectors: [
180
+ {
181
+ type: "grid"
182
+ }
183
+ ]
184
+ }
185
+ ]
186
+ };
187
+ var grid_default = Grid;
188
+
127
189
  // src/elements/text.tsx
128
- import * as React3 from "react";
129
- var Text = React3.forwardRef((props, ref) => {
190
+ import * as React4 from "react";
191
+ var Text = React4.forwardRef((props, ref) => {
130
192
  let _a = props, { children, value } = _a, rest = __objRest(_a, ["children", "value"]);
131
- return /* @__PURE__ */ React3.createElement("span", __spreadProps(__spreadValues({
193
+ return /* @__PURE__ */ React4.createElement("span", __spreadProps(__spreadValues({
132
194
  ref
133
195
  }, rest), {
134
196
  contentEditable: true,
@@ -139,18 +201,25 @@ Text.defaultProps = {
139
201
  value: "sample text",
140
202
  tag: "span"
141
203
  };
142
- var schema3 = {
204
+ var schema4 = {
143
205
  type: "text",
144
- inspectors: [
145
- {
146
- binding: "data",
147
- key: "value",
148
- componentType: "textarea"
149
- },
206
+ title: "Text Settings",
207
+ settings: [
150
208
  {
151
- binding: "style",
152
- key: "color",
153
- componentType: "color"
209
+ tab: "General",
210
+ label: "Text",
211
+ inspectors: [
212
+ {
213
+ binding: "data",
214
+ key: "value",
215
+ type: "textarea"
216
+ },
217
+ {
218
+ binding: "style",
219
+ key: "color",
220
+ type: "color"
221
+ }
222
+ ]
154
223
  }
155
224
  ]
156
225
  };
@@ -168,6 +237,10 @@ var elements = {
168
237
  },
169
238
  Text: {
170
239
  Component: text_default,
240
+ schema: schema4
241
+ },
242
+ Grid: {
243
+ Component: grid_default,
171
244
  schema: schema3
172
245
  }
173
246
  };
@@ -187,7 +260,7 @@ import {
187
260
  isBrowser,
188
261
  Weaverse
189
262
  } from "@weaverse/core";
190
- import * as React4 from "react";
263
+ import * as React5 from "react";
191
264
  var createRootContext = (configs) => {
192
265
  const rootContext = new Weaverse(configs);
193
266
  Object.keys(elements_default).forEach((key) => {
@@ -200,8 +273,8 @@ var WeaverseRoot = ({
200
273
  defaultData
201
274
  }) => {
202
275
  var _a, _b, _c;
203
- let [, setData] = React4.useState(context.projectData);
204
- React4.useEffect(() => {
276
+ let [, setData] = React5.useState(context.projectData);
277
+ React5.useEffect(() => {
205
278
  let handleUpdate = () => {
206
279
  setData(__spreadValues({}, context.projectData));
207
280
  };
@@ -216,18 +289,18 @@ var WeaverseRoot = ({
216
289
  context.initProjectItemData();
217
290
  }
218
291
  let handleProps = ((_c = context == null ? void 0 : context.studioBridge) == null ? void 0 : _c.handleProps) || {};
219
- return /* @__PURE__ */ React4.createElement("div", __spreadValues({
292
+ return /* @__PURE__ */ React5.createElement("div", __spreadValues({
220
293
  className: `weaverse-root`,
221
294
  id: "weaverse-root"
222
- }, handleProps), /* @__PURE__ */ React4.createElement(RenderItem, {
295
+ }, handleProps), /* @__PURE__ */ React5.createElement(RenderItem, {
223
296
  itemId: context.projectData.rootId || 0,
224
297
  context
225
298
  }));
226
299
  };
227
300
  var Item = ({ itemInstance, elementInstances, context }) => {
228
- let [data, setData] = React4.useState(itemInstance.data);
301
+ let [data, setData] = React5.useState(itemInstance.data);
229
302
  let _a = data, { id, type, childIds, css, className } = _a, rest = __objRest(_a, ["id", "type", "childIds", "css", "className"]);
230
- React4.useEffect(() => {
303
+ React5.useEffect(() => {
231
304
  let handleUpdate = (update) => {
232
305
  setData(__spreadValues({}, update));
233
306
  };
@@ -253,12 +326,12 @@ var Item = ({ itemInstance, elementInstances, context }) => {
253
326
  if (Component.$$typeof === Symbol.for("react.forward_ref")) {
254
327
  rest.ref = itemInstance.ref;
255
328
  }
256
- return /* @__PURE__ */ React4.createElement(Component, __spreadProps(__spreadValues({
329
+ return /* @__PURE__ */ React5.createElement(Component, __spreadProps(__spreadValues({
257
330
  key: id,
258
331
  "data-wv-id": id
259
332
  }, rest), {
260
333
  className: realClassName
261
- }), Array.isArray(childIds) && childIds.map((childId) => /* @__PURE__ */ React4.createElement(RenderItem, {
334
+ }), Array.isArray(childIds) && childIds.map((childId) => /* @__PURE__ */ React5.createElement(RenderItem, {
262
335
  key: childId,
263
336
  itemId: childId,
264
337
  context
@@ -273,13 +346,13 @@ var RenderItem = ({
273
346
  let { itemInstances, elementInstances } = context;
274
347
  let itemInstance = itemInstances.get(itemId);
275
348
  if (itemInstance) {
276
- return /* @__PURE__ */ React4.createElement(Item, {
349
+ return /* @__PURE__ */ React5.createElement(Item, {
277
350
  itemInstance,
278
351
  elementInstances,
279
352
  context
280
353
  });
281
354
  }
282
- return /* @__PURE__ */ React4.createElement(React4.Fragment, null);
355
+ return /* @__PURE__ */ React5.createElement(React5.Fragment, null);
283
356
  };
284
357
 
285
358
  // src/index.ts
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.4.0",
2
+ "version": "0.4.3",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -31,6 +31,6 @@
31
31
  "name": "@weaverse/react",
32
32
  "author": "Weaverse Team",
33
33
  "dependencies": {
34
- "@weaverse/core": "^0.4.0"
34
+ "@weaverse/core": "^0.4.2"
35
35
  }
36
36
  }