@measured/puck 0.10.0-canary.e308381 → 0.10.1-canary.17fc4dc
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +14 -5
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
@@ -120,15 +120,24 @@ Each render function receives three props:
|
|
120
120
|
|
121
121
|
#### Example
|
122
122
|
|
123
|
-
Here's
|
123
|
+
Here's an example plugin that creates a button to toggle the left side-bar:
|
124
124
|
|
125
125
|
```jsx
|
126
126
|
const myPlugin = {
|
127
|
-
renderRootFields: (
|
127
|
+
renderRootFields: ({ children, dispatch, state }) => (
|
128
128
|
<div>
|
129
|
-
{
|
130
|
-
|
131
|
-
<
|
129
|
+
{children}
|
130
|
+
|
131
|
+
<button
|
132
|
+
onClick={() => {
|
133
|
+
dispatch({
|
134
|
+
type: "setUi",
|
135
|
+
ui: { leftSideBarVisible: !state.ui.leftSideBarVisible },
|
136
|
+
});
|
137
|
+
}}
|
138
|
+
>
|
139
|
+
Toggle side-bar
|
140
|
+
</button>
|
132
141
|
</div>
|
133
142
|
),
|
134
143
|
};
|
package/dist/index.js
CHANGED
@@ -3219,7 +3219,7 @@ var ArrayField = ({
|
|
3219
3219
|
const [arrayFieldId] = (0, import_react25.useState)(generateId("ArrayField"));
|
3220
3220
|
const { state, setUi } = useAppContext();
|
3221
3221
|
const arrayState = state.ui.arrayState[arrayFieldId] || {
|
3222
|
-
items: Array.from(value).map((v) => ({
|
3222
|
+
items: Array.from(value || []).map((v) => ({
|
3223
3223
|
_arrayId: generateId("ArrayItem"),
|
3224
3224
|
data: v
|
3225
3225
|
})),
|
@@ -3239,7 +3239,7 @@ var ArrayField = ({
|
|
3239
3239
|
[arrayState]
|
3240
3240
|
);
|
3241
3241
|
(0, import_react25.useEffect)(() => {
|
3242
|
-
const newItems = Array.from(value).map((item, idx) => {
|
3242
|
+
const newItems = Array.from(value || []).map((item, idx) => {
|
3243
3243
|
var _a;
|
3244
3244
|
return {
|
3245
3245
|
_arrayId: ((_a = arrayState.items[idx]) == null ? void 0 : _a._arrayId) || generateId("ArrayItem"),
|