@weaverse/react 0.4.1 → 0.4.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.
- package/dist/index.js +84 -25
- package/dist/index.mjs +84 -25
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -70,7 +70,9 @@ 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
|
|
|
@@ -100,6 +102,16 @@ var schema2 = {
|
|
|
100
102
|
}
|
|
101
103
|
]
|
|
102
104
|
},
|
|
105
|
+
{
|
|
106
|
+
tab: "Settings",
|
|
107
|
+
label: "Spacing",
|
|
108
|
+
inspectors: [
|
|
109
|
+
{
|
|
110
|
+
binding: "style",
|
|
111
|
+
type: "spacing"
|
|
112
|
+
}
|
|
113
|
+
]
|
|
114
|
+
},
|
|
103
115
|
{
|
|
104
116
|
tab: "Settings",
|
|
105
117
|
label: "Overlay",
|
|
@@ -165,11 +177,47 @@ var schema2 = {
|
|
|
165
177
|
};
|
|
166
178
|
var button_default = Button;
|
|
167
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
|
+
|
|
168
216
|
// src/elements/text.tsx
|
|
169
|
-
var
|
|
170
|
-
var Text =
|
|
217
|
+
var React4 = __toESM(require("react"));
|
|
218
|
+
var Text = React4.forwardRef((props, ref) => {
|
|
171
219
|
let _a = props, { children, value } = _a, rest = __objRest(_a, ["children", "value"]);
|
|
172
|
-
return /* @__PURE__ */
|
|
220
|
+
return /* @__PURE__ */ React4.createElement("span", __spreadProps(__spreadValues({
|
|
173
221
|
ref
|
|
174
222
|
}, rest), {
|
|
175
223
|
contentEditable: true,
|
|
@@ -180,18 +228,25 @@ Text.defaultProps = {
|
|
|
180
228
|
value: "sample text",
|
|
181
229
|
tag: "span"
|
|
182
230
|
};
|
|
183
|
-
var
|
|
231
|
+
var schema4 = {
|
|
184
232
|
type: "text",
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
binding: "data",
|
|
188
|
-
key: "value",
|
|
189
|
-
componentType: "textarea"
|
|
190
|
-
},
|
|
233
|
+
title: "Text Settings",
|
|
234
|
+
settings: [
|
|
191
235
|
{
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
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
|
+
]
|
|
195
250
|
}
|
|
196
251
|
]
|
|
197
252
|
};
|
|
@@ -209,6 +264,10 @@ var elements = {
|
|
|
209
264
|
},
|
|
210
265
|
Text: {
|
|
211
266
|
Component: text_default,
|
|
267
|
+
schema: schema4
|
|
268
|
+
},
|
|
269
|
+
Grid: {
|
|
270
|
+
Component: grid_default,
|
|
212
271
|
schema: schema3
|
|
213
272
|
}
|
|
214
273
|
};
|
|
@@ -225,7 +284,7 @@ var shortCssObject = (css) => {
|
|
|
225
284
|
|
|
226
285
|
// src/renderer.tsx
|
|
227
286
|
var import_core = require("@weaverse/core");
|
|
228
|
-
var
|
|
287
|
+
var React5 = __toESM(require("react"));
|
|
229
288
|
var createRootContext = (configs) => {
|
|
230
289
|
const rootContext = new import_core.Weaverse(configs);
|
|
231
290
|
Object.keys(elements_default).forEach((key) => {
|
|
@@ -238,8 +297,8 @@ var WeaverseRoot = ({
|
|
|
238
297
|
defaultData
|
|
239
298
|
}) => {
|
|
240
299
|
var _a, _b, _c;
|
|
241
|
-
let [, setData] =
|
|
242
|
-
|
|
300
|
+
let [, setData] = React5.useState(context.projectData);
|
|
301
|
+
React5.useEffect(() => {
|
|
243
302
|
let handleUpdate = () => {
|
|
244
303
|
setData(__spreadValues({}, context.projectData));
|
|
245
304
|
};
|
|
@@ -254,18 +313,18 @@ var WeaverseRoot = ({
|
|
|
254
313
|
context.initProjectItemData();
|
|
255
314
|
}
|
|
256
315
|
let handleProps = ((_c = context == null ? void 0 : context.studioBridge) == null ? void 0 : _c.handleProps) || {};
|
|
257
|
-
return /* @__PURE__ */
|
|
316
|
+
return /* @__PURE__ */ React5.createElement("div", __spreadValues({
|
|
258
317
|
className: `weaverse-root`,
|
|
259
318
|
id: "weaverse-root"
|
|
260
|
-
}, handleProps), /* @__PURE__ */
|
|
319
|
+
}, handleProps), /* @__PURE__ */ React5.createElement(RenderItem, {
|
|
261
320
|
itemId: context.projectData.rootId || 0,
|
|
262
321
|
context
|
|
263
322
|
}));
|
|
264
323
|
};
|
|
265
324
|
var Item = ({ itemInstance, elementInstances, context }) => {
|
|
266
|
-
let [data, setData] =
|
|
325
|
+
let [data, setData] = React5.useState(itemInstance.data);
|
|
267
326
|
let _a = data, { id, type, childIds, css, className } = _a, rest = __objRest(_a, ["id", "type", "childIds", "css", "className"]);
|
|
268
|
-
|
|
327
|
+
React5.useEffect(() => {
|
|
269
328
|
let handleUpdate = (update) => {
|
|
270
329
|
setData(__spreadValues({}, update));
|
|
271
330
|
};
|
|
@@ -291,12 +350,12 @@ var Item = ({ itemInstance, elementInstances, context }) => {
|
|
|
291
350
|
if (Component.$$typeof === Symbol.for("react.forward_ref")) {
|
|
292
351
|
rest.ref = itemInstance.ref;
|
|
293
352
|
}
|
|
294
|
-
return /* @__PURE__ */
|
|
353
|
+
return /* @__PURE__ */ React5.createElement(Component, __spreadProps(__spreadValues({
|
|
295
354
|
key: id,
|
|
296
355
|
"data-wv-id": id
|
|
297
356
|
}, rest), {
|
|
298
357
|
className: realClassName
|
|
299
|
-
}), Array.isArray(childIds) && childIds.map((childId) => /* @__PURE__ */
|
|
358
|
+
}), Array.isArray(childIds) && childIds.map((childId) => /* @__PURE__ */ React5.createElement(RenderItem, {
|
|
300
359
|
key: childId,
|
|
301
360
|
itemId: childId,
|
|
302
361
|
context
|
|
@@ -311,13 +370,13 @@ var RenderItem = ({
|
|
|
311
370
|
let { itemInstances, elementInstances } = context;
|
|
312
371
|
let itemInstance = itemInstances.get(itemId);
|
|
313
372
|
if (itemInstance) {
|
|
314
|
-
return /* @__PURE__ */
|
|
373
|
+
return /* @__PURE__ */ React5.createElement(Item, {
|
|
315
374
|
itemInstance,
|
|
316
375
|
elementInstances,
|
|
317
376
|
context
|
|
318
377
|
});
|
|
319
378
|
}
|
|
320
|
-
return /* @__PURE__ */
|
|
379
|
+
return /* @__PURE__ */ React5.createElement(React5.Fragment, null);
|
|
321
380
|
};
|
|
322
381
|
|
|
323
382
|
// src/index.ts
|
package/dist/index.mjs
CHANGED
|
@@ -43,7 +43,9 @@ 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
|
|
|
@@ -73,6 +75,16 @@ var schema2 = {
|
|
|
73
75
|
}
|
|
74
76
|
]
|
|
75
77
|
},
|
|
78
|
+
{
|
|
79
|
+
tab: "Settings",
|
|
80
|
+
label: "Spacing",
|
|
81
|
+
inspectors: [
|
|
82
|
+
{
|
|
83
|
+
binding: "style",
|
|
84
|
+
type: "spacing"
|
|
85
|
+
}
|
|
86
|
+
]
|
|
87
|
+
},
|
|
76
88
|
{
|
|
77
89
|
tab: "Settings",
|
|
78
90
|
label: "Overlay",
|
|
@@ -138,11 +150,47 @@ var schema2 = {
|
|
|
138
150
|
};
|
|
139
151
|
var button_default = Button;
|
|
140
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
|
+
|
|
141
189
|
// src/elements/text.tsx
|
|
142
|
-
import * as
|
|
143
|
-
var Text =
|
|
190
|
+
import * as React4 from "react";
|
|
191
|
+
var Text = React4.forwardRef((props, ref) => {
|
|
144
192
|
let _a = props, { children, value } = _a, rest = __objRest(_a, ["children", "value"]);
|
|
145
|
-
return /* @__PURE__ */
|
|
193
|
+
return /* @__PURE__ */ React4.createElement("span", __spreadProps(__spreadValues({
|
|
146
194
|
ref
|
|
147
195
|
}, rest), {
|
|
148
196
|
contentEditable: true,
|
|
@@ -153,18 +201,25 @@ Text.defaultProps = {
|
|
|
153
201
|
value: "sample text",
|
|
154
202
|
tag: "span"
|
|
155
203
|
};
|
|
156
|
-
var
|
|
204
|
+
var schema4 = {
|
|
157
205
|
type: "text",
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
binding: "data",
|
|
161
|
-
key: "value",
|
|
162
|
-
componentType: "textarea"
|
|
163
|
-
},
|
|
206
|
+
title: "Text Settings",
|
|
207
|
+
settings: [
|
|
164
208
|
{
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
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
|
+
]
|
|
168
223
|
}
|
|
169
224
|
]
|
|
170
225
|
};
|
|
@@ -182,6 +237,10 @@ var elements = {
|
|
|
182
237
|
},
|
|
183
238
|
Text: {
|
|
184
239
|
Component: text_default,
|
|
240
|
+
schema: schema4
|
|
241
|
+
},
|
|
242
|
+
Grid: {
|
|
243
|
+
Component: grid_default,
|
|
185
244
|
schema: schema3
|
|
186
245
|
}
|
|
187
246
|
};
|
|
@@ -201,7 +260,7 @@ import {
|
|
|
201
260
|
isBrowser,
|
|
202
261
|
Weaverse
|
|
203
262
|
} from "@weaverse/core";
|
|
204
|
-
import * as
|
|
263
|
+
import * as React5 from "react";
|
|
205
264
|
var createRootContext = (configs) => {
|
|
206
265
|
const rootContext = new Weaverse(configs);
|
|
207
266
|
Object.keys(elements_default).forEach((key) => {
|
|
@@ -214,8 +273,8 @@ var WeaverseRoot = ({
|
|
|
214
273
|
defaultData
|
|
215
274
|
}) => {
|
|
216
275
|
var _a, _b, _c;
|
|
217
|
-
let [, setData] =
|
|
218
|
-
|
|
276
|
+
let [, setData] = React5.useState(context.projectData);
|
|
277
|
+
React5.useEffect(() => {
|
|
219
278
|
let handleUpdate = () => {
|
|
220
279
|
setData(__spreadValues({}, context.projectData));
|
|
221
280
|
};
|
|
@@ -230,18 +289,18 @@ var WeaverseRoot = ({
|
|
|
230
289
|
context.initProjectItemData();
|
|
231
290
|
}
|
|
232
291
|
let handleProps = ((_c = context == null ? void 0 : context.studioBridge) == null ? void 0 : _c.handleProps) || {};
|
|
233
|
-
return /* @__PURE__ */
|
|
292
|
+
return /* @__PURE__ */ React5.createElement("div", __spreadValues({
|
|
234
293
|
className: `weaverse-root`,
|
|
235
294
|
id: "weaverse-root"
|
|
236
|
-
}, handleProps), /* @__PURE__ */
|
|
295
|
+
}, handleProps), /* @__PURE__ */ React5.createElement(RenderItem, {
|
|
237
296
|
itemId: context.projectData.rootId || 0,
|
|
238
297
|
context
|
|
239
298
|
}));
|
|
240
299
|
};
|
|
241
300
|
var Item = ({ itemInstance, elementInstances, context }) => {
|
|
242
|
-
let [data, setData] =
|
|
301
|
+
let [data, setData] = React5.useState(itemInstance.data);
|
|
243
302
|
let _a = data, { id, type, childIds, css, className } = _a, rest = __objRest(_a, ["id", "type", "childIds", "css", "className"]);
|
|
244
|
-
|
|
303
|
+
React5.useEffect(() => {
|
|
245
304
|
let handleUpdate = (update) => {
|
|
246
305
|
setData(__spreadValues({}, update));
|
|
247
306
|
};
|
|
@@ -267,12 +326,12 @@ var Item = ({ itemInstance, elementInstances, context }) => {
|
|
|
267
326
|
if (Component.$$typeof === Symbol.for("react.forward_ref")) {
|
|
268
327
|
rest.ref = itemInstance.ref;
|
|
269
328
|
}
|
|
270
|
-
return /* @__PURE__ */
|
|
329
|
+
return /* @__PURE__ */ React5.createElement(Component, __spreadProps(__spreadValues({
|
|
271
330
|
key: id,
|
|
272
331
|
"data-wv-id": id
|
|
273
332
|
}, rest), {
|
|
274
333
|
className: realClassName
|
|
275
|
-
}), Array.isArray(childIds) && childIds.map((childId) => /* @__PURE__ */
|
|
334
|
+
}), Array.isArray(childIds) && childIds.map((childId) => /* @__PURE__ */ React5.createElement(RenderItem, {
|
|
276
335
|
key: childId,
|
|
277
336
|
itemId: childId,
|
|
278
337
|
context
|
|
@@ -287,13 +346,13 @@ var RenderItem = ({
|
|
|
287
346
|
let { itemInstances, elementInstances } = context;
|
|
288
347
|
let itemInstance = itemInstances.get(itemId);
|
|
289
348
|
if (itemInstance) {
|
|
290
|
-
return /* @__PURE__ */
|
|
349
|
+
return /* @__PURE__ */ React5.createElement(Item, {
|
|
291
350
|
itemInstance,
|
|
292
351
|
elementInstances,
|
|
293
352
|
context
|
|
294
353
|
});
|
|
295
354
|
}
|
|
296
|
-
return /* @__PURE__ */
|
|
355
|
+
return /* @__PURE__ */ React5.createElement(React5.Fragment, null);
|
|
297
356
|
};
|
|
298
357
|
|
|
299
358
|
// src/index.ts
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.4.
|
|
2
|
+
"version": "0.4.2",
|
|
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.
|
|
34
|
+
"@weaverse/core": "^0.4.2"
|
|
35
35
|
}
|
|
36
36
|
}
|