@measured/puck 0.1.5 → 0.1.6
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 +79 -22
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -34,6 +34,9 @@ var __objRest = (source, exclude) => {
|
|
|
34
34
|
}
|
|
35
35
|
return target;
|
|
36
36
|
};
|
|
37
|
+
var __esm = (fn, res) => function __init() {
|
|
38
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
39
|
+
};
|
|
37
40
|
var __commonJS = (cb, mod) => function __require() {
|
|
38
41
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
39
42
|
};
|
|
@@ -79,9 +82,19 @@ var __async = (__this, __arguments, generator) => {
|
|
|
79
82
|
});
|
|
80
83
|
};
|
|
81
84
|
|
|
85
|
+
// ../tsup-config/react-import.js
|
|
86
|
+
var import_react;
|
|
87
|
+
var init_react_import = __esm({
|
|
88
|
+
"../tsup-config/react-import.js"() {
|
|
89
|
+
"use strict";
|
|
90
|
+
import_react = __toESM(require("react"));
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
|
|
82
94
|
// ../../node_modules/classnames/index.js
|
|
83
95
|
var require_classnames = __commonJS({
|
|
84
96
|
"../../node_modules/classnames/index.js"(exports, module2) {
|
|
97
|
+
init_react_import();
|
|
85
98
|
(function() {
|
|
86
99
|
"use strict";
|
|
87
100
|
var hasOwn = {}.hasOwnProperty;
|
|
@@ -137,19 +150,25 @@ __export(core_exports, {
|
|
|
137
150
|
Render: () => Render
|
|
138
151
|
});
|
|
139
152
|
module.exports = __toCommonJS(core_exports);
|
|
153
|
+
init_react_import();
|
|
154
|
+
|
|
155
|
+
// types/Config.tsx
|
|
156
|
+
init_react_import();
|
|
140
157
|
|
|
141
158
|
// components/Puck/index.tsx
|
|
142
|
-
|
|
159
|
+
init_react_import();
|
|
160
|
+
var import_react7 = require("react");
|
|
143
161
|
var import_react_beautiful_dnd4 = require("react-beautiful-dnd");
|
|
144
162
|
|
|
145
163
|
// components/DroppableStrictMode/index.tsx
|
|
146
|
-
|
|
164
|
+
init_react_import();
|
|
165
|
+
var import_react2 = require("react");
|
|
147
166
|
var import_react_beautiful_dnd = require("react-beautiful-dnd");
|
|
148
167
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
149
168
|
var DroppableStrictMode = (_a) => {
|
|
150
169
|
var _b = _a, { children } = _b, props = __objRest(_b, ["children"]);
|
|
151
|
-
const [enabled, setEnabled] = (0,
|
|
152
|
-
(0,
|
|
170
|
+
const [enabled, setEnabled] = (0, import_react2.useState)(false);
|
|
171
|
+
(0, import_react2.useEffect)(() => {
|
|
153
172
|
const animation = requestAnimationFrame(() => setEnabled(true));
|
|
154
173
|
return () => {
|
|
155
174
|
cancelAnimationFrame(animation);
|
|
@@ -164,12 +183,15 @@ var DroppableStrictMode = (_a) => {
|
|
|
164
183
|
var DroppableStrictMode_default = DroppableStrictMode;
|
|
165
184
|
|
|
166
185
|
// components/DraggableComponent/index.tsx
|
|
186
|
+
init_react_import();
|
|
167
187
|
var import_react_beautiful_dnd2 = require("react-beautiful-dnd");
|
|
168
188
|
|
|
169
189
|
// css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
|
|
190
|
+
init_react_import();
|
|
170
191
|
var styles_module_default = { "DraggableComponent": "_DraggableComponent_10y0g_1", "DraggableComponent-contents": "_DraggableComponent-contents_10y0g_5", "DraggableComponent-overlay": "_DraggableComponent-overlay_10y0g_9", "DraggableComponent--isModifierHeld": "_DraggableComponent--isModifierHeld_10y0g_25", "DraggableComponent--isSelected": "_DraggableComponent--isSelected_10y0g_29", "DraggableComponent-actions": "_DraggableComponent-actions_10y0g_34", "DraggableComponent-actionsLabel": "_DraggableComponent-actionsLabel_10y0g_49", "DraggableComponent-action": "_DraggableComponent-action_10y0g_34" };
|
|
171
192
|
|
|
172
193
|
// lib/get-class-name-factory.ts
|
|
194
|
+
init_react_import();
|
|
173
195
|
var import_classnames = __toESM(require_classnames());
|
|
174
196
|
var getClassNameFactory = (rootClass, styles, { baseClass = "" } = {}) => (options = {}) => {
|
|
175
197
|
let descendant = false;
|
|
@@ -200,9 +222,10 @@ var get_class_name_factory_default = getClassNameFactory;
|
|
|
200
222
|
var import_react_feather = require("react-feather");
|
|
201
223
|
|
|
202
224
|
// lib/use-modifier-held.ts
|
|
203
|
-
|
|
225
|
+
init_react_import();
|
|
226
|
+
var import_react3 = require("react");
|
|
204
227
|
var useModifierHeld = (modifier) => {
|
|
205
|
-
const [modifierHeld, setModifierHeld] = (0,
|
|
228
|
+
const [modifierHeld, setModifierHeld] = (0, import_react3.useState)(false);
|
|
206
229
|
function downHandler({ key }) {
|
|
207
230
|
if (key === modifier) {
|
|
208
231
|
setModifierHeld(true);
|
|
@@ -213,7 +236,7 @@ var useModifierHeld = (modifier) => {
|
|
|
213
236
|
setModifierHeld(false);
|
|
214
237
|
}
|
|
215
238
|
}
|
|
216
|
-
(0,
|
|
239
|
+
(0, import_react3.useEffect)(() => {
|
|
217
240
|
window.addEventListener("keydown", downHandler);
|
|
218
241
|
window.addEventListener("keyup", upHandler);
|
|
219
242
|
return () => {
|
|
@@ -261,10 +284,15 @@ var DraggableComponent = ({
|
|
|
261
284
|
) }, id);
|
|
262
285
|
};
|
|
263
286
|
|
|
287
|
+
// components/InputOrGroup/index.tsx
|
|
288
|
+
init_react_import();
|
|
289
|
+
|
|
264
290
|
// components/ExternalInput/index.tsx
|
|
265
|
-
|
|
291
|
+
init_react_import();
|
|
292
|
+
var import_react4 = require("react");
|
|
266
293
|
|
|
267
294
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ExternalInput/styles.module.css#css-module
|
|
295
|
+
init_react_import();
|
|
268
296
|
var styles_module_default2 = { "ExternalInput": "_ExternalInput_v316c_1", "ExternalInput-actions": "_ExternalInput-actions_v316c_5", "ExternalInput-button": "_ExternalInput-button_v316c_9", "ExternalInput-detachButton": "_ExternalInput-detachButton_v316c_23", "ExternalInput--hasData": "_ExternalInput--hasData_v316c_30", "ExternalInput-modal": "_ExternalInput-modal_v316c_45", "ExternalInput--modalVisible": "_ExternalInput--modalVisible_v316c_59", "ExternalInput-modalInner": "_ExternalInput-modalInner_v316c_63", "ExternalInput-modalHeading": "_ExternalInput-modalHeading_v316c_74", "ExternalInput-modalTableWrapper": "_ExternalInput-modalTableWrapper_v316c_79" };
|
|
269
297
|
|
|
270
298
|
// components/ExternalInput/index.tsx
|
|
@@ -275,10 +303,10 @@ var ExternalInput = ({
|
|
|
275
303
|
onChange,
|
|
276
304
|
value = null
|
|
277
305
|
}) => {
|
|
278
|
-
const [data, setData] = (0,
|
|
279
|
-
const [isOpen, setOpen] = (0,
|
|
280
|
-
const [selectedData, setSelectedData] = (0,
|
|
281
|
-
(0,
|
|
306
|
+
const [data, setData] = (0, import_react4.useState)([]);
|
|
307
|
+
const [isOpen, setOpen] = (0, import_react4.useState)(false);
|
|
308
|
+
const [selectedData, setSelectedData] = (0, import_react4.useState)(value);
|
|
309
|
+
(0, import_react4.useEffect)(() => {
|
|
282
310
|
(() => __async(void 0, null, function* () {
|
|
283
311
|
if (field.adaptor) {
|
|
284
312
|
const listData = yield field.adaptor.fetchList(field.adaptorParams);
|
|
@@ -354,9 +382,14 @@ var ExternalInput = ({
|
|
|
354
382
|
};
|
|
355
383
|
|
|
356
384
|
// css-module:/home/runner/work/puck/puck/packages/core/components/InputOrGroup/styles.module.css#css-module
|
|
385
|
+
init_react_import();
|
|
357
386
|
var styles_module_default3 = { "Input": "_Input_1vwgb_1", "Input-label": "_Input-label_1vwgb_14", "Input-input": "_Input-input_1vwgb_20", "Input--readOnly": "_Input--readOnly_1vwgb_41", "Input-group": "_Input-group_1vwgb_50", "Input-action": "_Input-action_1vwgb_72", "Input-addButton": "_Input-addButton_1vwgb_93", "Input-item": "_Input-item_1vwgb_107", "Input-radioGroup": "_Input-radioGroup_1vwgb_114", "Input-radioGroupItems": "_Input-radioGroupItems_1vwgb_119", "Input-radio": "_Input-radio_1vwgb_114" };
|
|
358
387
|
|
|
388
|
+
// lib/index.ts
|
|
389
|
+
init_react_import();
|
|
390
|
+
|
|
359
391
|
// lib/filter.ts
|
|
392
|
+
init_react_import();
|
|
360
393
|
var filter = (obj, validKeys) => {
|
|
361
394
|
return validKeys.reduce((acc, item) => {
|
|
362
395
|
if (typeof obj[item] !== "undefined") {
|
|
@@ -367,6 +400,7 @@ var filter = (obj, validKeys) => {
|
|
|
367
400
|
};
|
|
368
401
|
|
|
369
402
|
// lib/reorder.ts
|
|
403
|
+
init_react_import();
|
|
370
404
|
var reorder = (list, startIndex, endIndex) => {
|
|
371
405
|
const result = Array.from(list);
|
|
372
406
|
const [removed] = result.splice(startIndex, 1);
|
|
@@ -375,6 +409,7 @@ var reorder = (list, startIndex, endIndex) => {
|
|
|
375
409
|
};
|
|
376
410
|
|
|
377
411
|
// lib/replace.ts
|
|
412
|
+
init_react_import();
|
|
378
413
|
var replace = (list, index, newItem) => {
|
|
379
414
|
const result = Array.from(list);
|
|
380
415
|
result.splice(index, 1);
|
|
@@ -545,9 +580,11 @@ var InputOrGroup = ({
|
|
|
545
580
|
};
|
|
546
581
|
|
|
547
582
|
// components/ComponentList/index.tsx
|
|
583
|
+
init_react_import();
|
|
548
584
|
var import_react_beautiful_dnd3 = require("react-beautiful-dnd");
|
|
549
585
|
|
|
550
586
|
// css-module:/home/runner/work/puck/puck/packages/core/components/ComponentList/styles.module.css#css-module
|
|
587
|
+
init_react_import();
|
|
551
588
|
var styles_module_default4 = { "ComponentList": "_ComponentList_91nmt_1", "ComponentList-item": "_ComponentList-item_91nmt_9", "ComponentList-itemShadow": "_ComponentList-itemShadow_91nmt_10", "ComponentList-itemIcon": "_ComponentList-itemIcon_91nmt_24" };
|
|
552
589
|
|
|
553
590
|
// components/ComponentList/index.tsx
|
|
@@ -606,7 +643,11 @@ var ComponentList = ({ config }) => {
|
|
|
606
643
|
) });
|
|
607
644
|
};
|
|
608
645
|
|
|
646
|
+
// components/OutlineList/index.tsx
|
|
647
|
+
init_react_import();
|
|
648
|
+
|
|
609
649
|
// css-module:/home/runner/work/puck/puck/packages/core/components/OutlineList/styles.module.css#css-module
|
|
650
|
+
init_react_import();
|
|
610
651
|
var styles_module_default5 = { "OutlineList": "_OutlineList_gor6f_1", "OutlineList-clickableItem": "_OutlineList-clickableItem_gor6f_36" };
|
|
611
652
|
|
|
612
653
|
// components/OutlineList/index.tsx
|
|
@@ -630,10 +671,15 @@ OutlineList.Item = ({
|
|
|
630
671
|
);
|
|
631
672
|
};
|
|
632
673
|
|
|
674
|
+
// components/Button/index.ts
|
|
675
|
+
init_react_import();
|
|
676
|
+
|
|
633
677
|
// components/Button/Button.tsx
|
|
634
|
-
|
|
678
|
+
init_react_import();
|
|
679
|
+
var import_react5 = require("react");
|
|
635
680
|
|
|
636
681
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Button/Button.module.css#css-module
|
|
682
|
+
init_react_import();
|
|
637
683
|
var Button_module_default = { "Button": "_Button_1bqmn_1", "Button--primary": "_Button--primary_1bqmn_25", "Button--secondary": "_Button--secondary_1bqmn_34", "Button--flush": "_Button--flush_1bqmn_45", "Button--disabled": "_Button--disabled_1bqmn_49", "Button--fullWidth": "_Button--fullWidth_1bqmn_59" };
|
|
638
684
|
|
|
639
685
|
// components/Button/Button.tsx
|
|
@@ -651,7 +697,7 @@ var Button = ({
|
|
|
651
697
|
newTab,
|
|
652
698
|
fullWidth
|
|
653
699
|
}) => {
|
|
654
|
-
const [loading, setLoading] = (0,
|
|
700
|
+
const [loading, setLoading] = (0, import_react5.useState)(false);
|
|
655
701
|
const ElementType = href ? "a" : "button";
|
|
656
702
|
const el = /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
657
703
|
ElementType,
|
|
@@ -689,10 +735,11 @@ var Button = ({
|
|
|
689
735
|
};
|
|
690
736
|
|
|
691
737
|
// lib/use-placeholder-style.ts
|
|
692
|
-
|
|
738
|
+
init_react_import();
|
|
739
|
+
var import_react6 = require("react");
|
|
693
740
|
var usePlaceholderStyle = () => {
|
|
694
741
|
const queryAttr = "data-rbd-drag-handle-draggable-id";
|
|
695
|
-
const [placeholderStyle, setPlaceholderStyle] = (0,
|
|
742
|
+
const [placeholderStyle, setPlaceholderStyle] = (0, import_react6.useState)();
|
|
696
743
|
const onDragUpdate = (update) => {
|
|
697
744
|
if (!update.destination) {
|
|
698
745
|
return;
|
|
@@ -728,10 +775,18 @@ var usePlaceholderStyle = () => {
|
|
|
728
775
|
return { onDragUpdate, placeholderStyle };
|
|
729
776
|
};
|
|
730
777
|
|
|
778
|
+
// components/SidebarSection/index.tsx
|
|
779
|
+
init_react_import();
|
|
780
|
+
|
|
731
781
|
// css-module:/home/runner/work/puck/puck/packages/core/components/SidebarSection/styles.module.css#css-module
|
|
782
|
+
init_react_import();
|
|
732
783
|
var styles_module_default6 = { "SidebarSection": "_SidebarSection_jsf8x_1", "SidebarSection-content": "_SidebarSection-content_jsf8x_1", "SidebarSection-title": "_SidebarSection-title_jsf8x_6" };
|
|
733
784
|
|
|
785
|
+
// components/Heading/index.tsx
|
|
786
|
+
init_react_import();
|
|
787
|
+
|
|
734
788
|
// css-module:/home/runner/work/puck/puck/packages/core/components/Heading/styles.module.css#css-module
|
|
789
|
+
init_react_import();
|
|
735
790
|
var styles_module_default7 = { "Heading": "_Heading_1y35v_1", "Heading--xxxxl": "_Heading--xxxxl_1y35v_12", "Heading--xxxl": "_Heading--xxxl_1y35v_18", "Heading--xxl": "_Heading--xxl_1y35v_22", "Heading--xl": "_Heading--xl_1y35v_26", "Heading--l": "_Heading--l_1y35v_30", "Heading--m": "_Heading--m_1y35v_34", "Heading--s": "_Heading--s_1y35v_38", "Heading--xs": "_Heading--xs_1y35v_42" };
|
|
736
791
|
|
|
737
792
|
// components/Heading/index.tsx
|
|
@@ -764,6 +819,7 @@ var SidebarSection = ({
|
|
|
764
819
|
};
|
|
765
820
|
|
|
766
821
|
// lib/scroll-into-view.ts
|
|
822
|
+
init_react_import();
|
|
767
823
|
var scrollIntoView = (el) => {
|
|
768
824
|
const oldStyle = __spreadValues({}, el.style);
|
|
769
825
|
el.style.scrollMargin = "256px";
|
|
@@ -798,9 +854,9 @@ function Puck({
|
|
|
798
854
|
renderHeader
|
|
799
855
|
}) {
|
|
800
856
|
var _a, _b;
|
|
801
|
-
const [data, setData] = (0,
|
|
802
|
-
const [selectedIndex, setSelectedIndex] = (0,
|
|
803
|
-
const Page = (0,
|
|
857
|
+
const [data, setData] = (0, import_react7.useState)(initialData);
|
|
858
|
+
const [selectedIndex, setSelectedIndex] = (0, import_react7.useState)(null);
|
|
859
|
+
const Page = (0, import_react7.useCallback)(
|
|
804
860
|
(pageProps) => {
|
|
805
861
|
var _a2, _b2;
|
|
806
862
|
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
@@ -815,7 +871,7 @@ function Puck({
|
|
|
815
871
|
},
|
|
816
872
|
[config.page]
|
|
817
873
|
);
|
|
818
|
-
const PageFieldWrapper = (0,
|
|
874
|
+
const PageFieldWrapper = (0, import_react7.useCallback)(
|
|
819
875
|
(props) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
820
876
|
PluginRenderer,
|
|
821
877
|
{
|
|
@@ -827,7 +883,7 @@ function Puck({
|
|
|
827
883
|
),
|
|
828
884
|
[]
|
|
829
885
|
);
|
|
830
|
-
const ComponentFieldWrapper = (0,
|
|
886
|
+
const ComponentFieldWrapper = (0, import_react7.useCallback)(
|
|
831
887
|
(props) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
832
888
|
PluginRenderer,
|
|
833
889
|
{
|
|
@@ -842,7 +898,7 @@ function Puck({
|
|
|
842
898
|
const FieldWrapper = selectedIndex !== null ? ComponentFieldWrapper : PageFieldWrapper;
|
|
843
899
|
const pageFields = ((_a = config.page) == null ? void 0 : _a.fields) || defaultPageFields;
|
|
844
900
|
let fields = selectedIndex !== null ? ((_b = config.components[data.content[selectedIndex].type]) == null ? void 0 : _b.fields) || {} : pageFields;
|
|
845
|
-
(0,
|
|
901
|
+
(0, import_react7.useEffect)(() => {
|
|
846
902
|
if (onChange)
|
|
847
903
|
onChange(data);
|
|
848
904
|
}, [data]);
|
|
@@ -1161,6 +1217,7 @@ function Puck({
|
|
|
1161
1217
|
}
|
|
1162
1218
|
|
|
1163
1219
|
// components/Render/index.tsx
|
|
1220
|
+
init_react_import();
|
|
1164
1221
|
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1165
1222
|
function Render({ config, data }) {
|
|
1166
1223
|
const children = data.content.map((item) => {
|