@raketa-builder/menu-builder 0.9.0 → 1.0.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raketa-builder/menu-builder",
3
- "version": "0.9.0",
3
+ "version": "1.0.3",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "license": "MIT",
@@ -1,5 +1,6 @@
1
1
  import React from "react";
2
2
  import { Button } from "@raketa-builder/ui";
3
+ import { AdminForm } from "@raketa-builder/builder";
3
4
 
4
5
  function checkForChanges(hasChanges, onClose) {
5
6
  if (!hasChanges) {
@@ -18,24 +19,33 @@ function checkForChanges(hasChanges, onClose) {
18
19
  }
19
20
 
20
21
  const AdminWidget = ({
21
- Component,
22
+ widget,
22
23
  settings,
23
24
  onChange,
24
25
  handleChanges,
25
26
  onCancel,
26
27
  }) => {
27
28
  const [state, setState] = React.useState(settings);
28
- const Form = Component.admin;
29
29
 
30
30
  const areChanges = JSON.stringify(state) !== JSON.stringify(settings);
31
31
 
32
+ const schema = widget.admin;
33
+
34
+ if (typeof schema !== "object") {
35
+ console.warn(
36
+ `Legacy widget with React admin definition: "${widget.name}". Update to schema defined inputs!`
37
+ );
38
+ }
39
+
32
40
  return (
33
41
  <div>
34
- <Form
35
- settings={state}
36
- onChange={(key, value) => {
37
- setState({ ...state, ...{ [key]: value } });
38
- handleChanges({ ...state, ...{ [key]: value } });
42
+ <AdminForm
43
+ schema={schema}
44
+ value={state}
45
+ onChange={(newState) => {
46
+ console.log({ newState });
47
+ setState({ ...newState });
48
+ handleChanges({ ...newState });
39
49
  }}
40
50
  />
41
51
 
@@ -135,7 +135,7 @@ const ContentBuilder = ({ value, onChange }) => {
135
135
  onClose={closeWidget}
136
136
  >
137
137
  <AdminWidget
138
- Component={getWidget(WIDGETS, widget.current.component)}
138
+ widget={getWidget(WIDGETS, widget.current.component)}
139
139
  settings={widget.current.settings}
140
140
  onChange={(settings) => updateWidget(widget.current, settings)}
141
141
  handleChanges={handleChanges}
@@ -1,11 +0,0 @@
1
-
2
- > @raketa-builder/menu-builder@0.9.0 build
3
- > tsup src/index.js --format cjs --loader ".js=jsx"
4
-
5
- CLI Building entry: src/index.js
6
- CLI Using tsconfig: tsconfig.json
7
- CLI tsup v6.5.0
8
- CLI Target: es6
9
- CJS Build start
10
- CJS dist/index.js 63.18 KB
11
- CJS ⚡️ Build success in 41ms