@measured/puck 0.21.0-canary.eb8ea5ce → 0.21.0-canary.ed10e2a4

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.
@@ -1,3140 +0,0 @@
1
- import {
2
- defaultAppState,
3
- defaultViewports,
4
- getChanged,
5
- resolveComponentData,
6
- rootDroppableId,
7
- setupZone,
8
- walkAppState,
9
- walkTree
10
- } from "./chunk-YZQENDBP.mjs";
11
- import {
12
- __async,
13
- __objRest,
14
- __spreadProps,
15
- __spreadValues,
16
- get_class_name_factory_default,
17
- init_react_import,
18
- styles_module_default
19
- } from "./chunk-GQ457KMA.mjs";
20
-
21
- // components/ActionBar/index.tsx
22
- init_react_import();
23
-
24
- // css-module:/home/runner/work/puck/puck/packages/core/components/ActionBar/styles.module.css#css-module
25
- init_react_import();
26
- var styles_module_default2 = { "ActionBar": "_ActionBar_1nmyk_1", "ActionBar-label": "_ActionBar-label_1nmyk_18", "ActionBarAction": "_ActionBarAction_1nmyk_30", "ActionBar-group": "_ActionBar-group_1nmyk_38", "ActionBarAction--disabled": "_ActionBarAction--disabled_1nmyk_71", "ActionBarAction--active": "_ActionBarAction--active_1nmyk_93", "ActionBar-separator": "_ActionBar-separator_1nmyk_102" };
27
-
28
- // components/ActionBar/index.tsx
29
- import { jsx, jsxs } from "react/jsx-runtime";
30
- var getClassName = get_class_name_factory_default("ActionBar", styles_module_default2);
31
- var getActionClassName = get_class_name_factory_default("ActionBarAction", styles_module_default2);
32
- var ActionBar = ({
33
- label,
34
- children
35
- }) => /* @__PURE__ */ jsxs(
36
- "div",
37
- {
38
- className: getClassName(),
39
- onClick: (e) => {
40
- e.stopPropagation();
41
- },
42
- children: [
43
- label && /* @__PURE__ */ jsx(ActionBar.Group, { children: /* @__PURE__ */ jsx("div", { className: getClassName("label"), children: label }) }),
44
- children
45
- ]
46
- }
47
- );
48
- var Action = ({
49
- children,
50
- label,
51
- onClick,
52
- active = false,
53
- disabled
54
- }) => /* @__PURE__ */ jsx(
55
- "button",
56
- {
57
- type: "button",
58
- className: getActionClassName({ active, disabled }),
59
- onClick,
60
- title: label,
61
- tabIndex: 0,
62
- disabled,
63
- children
64
- }
65
- );
66
- var Group = ({ children }) => /* @__PURE__ */ jsx("div", { className: getClassName("group"), children });
67
- var Label = ({ label }) => /* @__PURE__ */ jsx("div", { className: getClassName("label"), children: label });
68
- var Separator = () => /* @__PURE__ */ jsx("div", { className: getClassName("separator") });
69
- ActionBar.Action = Action;
70
- ActionBar.Label = Label;
71
- ActionBar.Group = Group;
72
- ActionBar.Separator = Separator;
73
-
74
- // store/index.ts
75
- init_react_import();
76
-
77
- // reducer/index.ts
78
- init_react_import();
79
-
80
- // reducer/actions/set.ts
81
- init_react_import();
82
- var setAction = (state, action, appStore) => {
83
- if (typeof action.state === "object") {
84
- const newState = __spreadValues(__spreadValues({}, state), action.state);
85
- if (action.state.indexes) {
86
- return newState;
87
- }
88
- console.warn(
89
- "`set` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
90
- );
91
- return walkAppState(newState, appStore.config);
92
- }
93
- return __spreadValues(__spreadValues({}, state), action.state(state));
94
- };
95
-
96
- // reducer/actions/insert.ts
97
- init_react_import();
98
-
99
- // lib/data/insert.ts
100
- init_react_import();
101
- var insert = (list, index, item) => {
102
- const result = Array.from(list || []);
103
- result.splice(index, 0, item);
104
- return result;
105
- };
106
-
107
- // lib/generate-id.ts
108
- init_react_import();
109
- import { v4 as uuidv4 } from "uuid";
110
- var generateId = (type) => type ? `${type}-${uuidv4()}` : uuidv4();
111
-
112
- // lib/data/get-ids-for-parent.ts
113
- init_react_import();
114
- var getIdsForParent = (zoneCompound, state) => {
115
- const [parentId] = zoneCompound.split(":");
116
- const node = state.indexes.nodes[parentId];
117
- return ((node == null ? void 0 : node.path) || []).map((p) => p.split(":")[0]);
118
- };
119
-
120
- // lib/data/populate-ids.ts
121
- init_react_import();
122
- var populateIds = (data, config, override = false) => {
123
- const id = generateId(data.type);
124
- return walkTree(
125
- __spreadProps(__spreadValues({}, data), {
126
- props: override ? __spreadProps(__spreadValues({}, data.props), { id }) : __spreadValues({}, data.props)
127
- }),
128
- config,
129
- (contents) => contents.map((item) => {
130
- const id2 = generateId(item.type);
131
- return __spreadProps(__spreadValues({}, item), {
132
- props: override ? __spreadProps(__spreadValues({}, item.props), { id: id2 }) : __spreadValues({ id: id2 }, item.props)
133
- });
134
- })
135
- );
136
- };
137
-
138
- // reducer/actions/insert.ts
139
- function insertAction(state, action, appStore) {
140
- const id = action.id || generateId(action.componentType);
141
- const emptyComponentData = populateIds(
142
- {
143
- type: action.componentType,
144
- props: __spreadProps(__spreadValues({}, appStore.config.components[action.componentType].defaultProps || {}), {
145
- id
146
- })
147
- },
148
- appStore.config
149
- );
150
- const [parentId] = action.destinationZone.split(":");
151
- const idsInPath = getIdsForParent(action.destinationZone, state);
152
- return walkAppState(
153
- state,
154
- appStore.config,
155
- (content, zoneCompound) => {
156
- if (zoneCompound === action.destinationZone) {
157
- return insert(
158
- content || [],
159
- action.destinationIndex,
160
- emptyComponentData
161
- );
162
- }
163
- return content;
164
- },
165
- (childItem, path) => {
166
- if (childItem.props.id === id || childItem.props.id === parentId) {
167
- return childItem;
168
- } else if (idsInPath.includes(childItem.props.id)) {
169
- return childItem;
170
- } else if (path.includes(action.destinationZone)) {
171
- return childItem;
172
- }
173
- return null;
174
- }
175
- );
176
- }
177
-
178
- // reducer/actions/replace.ts
179
- init_react_import();
180
- var replaceAction = (state, action, appStore) => {
181
- const [parentId] = action.destinationZone.split(":");
182
- const idsInPath = getIdsForParent(action.destinationZone, state);
183
- const originalId = state.indexes.zones[action.destinationZone].contentIds[action.destinationIndex];
184
- const idChanged = originalId !== action.data.props.id;
185
- if (idChanged) {
186
- throw new Error(
187
- `Can't change the id during a replace action. Please us "remove" and "insert" to define a new node.`
188
- );
189
- }
190
- const newSlotIds = [];
191
- const data = walkTree(action.data, appStore.config, (contents, opts) => {
192
- newSlotIds.push(`${opts.parentId}:${opts.propName}`);
193
- return contents.map((item) => {
194
- const id = generateId(item.type);
195
- return __spreadProps(__spreadValues({}, item), {
196
- props: __spreadValues({ id }, item.props)
197
- });
198
- });
199
- });
200
- const stateWithDeepSlotsRemoved = __spreadProps(__spreadValues({}, state), {
201
- ui: __spreadValues(__spreadValues({}, state.ui), action.ui)
202
- });
203
- Object.keys(state.indexes.zones).forEach((zoneCompound) => {
204
- const id = zoneCompound.split(":")[0];
205
- if (id === originalId) {
206
- if (!newSlotIds.includes(zoneCompound)) {
207
- delete stateWithDeepSlotsRemoved.indexes.zones[zoneCompound];
208
- }
209
- }
210
- });
211
- return walkAppState(
212
- stateWithDeepSlotsRemoved,
213
- appStore.config,
214
- (content, zoneCompound) => {
215
- const newContent = [...content];
216
- if (zoneCompound === action.destinationZone) {
217
- newContent[action.destinationIndex] = data;
218
- }
219
- return newContent;
220
- },
221
- (childItem, path) => {
222
- const pathIds = path.map((p) => p.split(":")[0]);
223
- if (childItem.props.id === data.props.id) {
224
- return data;
225
- } else if (childItem.props.id === parentId) {
226
- return childItem;
227
- } else if (idsInPath.indexOf(childItem.props.id) > -1) {
228
- return childItem;
229
- } else if (pathIds.indexOf(data.props.id) > -1) {
230
- return childItem;
231
- }
232
- return null;
233
- }
234
- );
235
- };
236
-
237
- // reducer/actions/replace-root.ts
238
- init_react_import();
239
- var replaceRootAction = (state, action, appStore) => {
240
- return walkAppState(
241
- state,
242
- appStore.config,
243
- (content) => content,
244
- (childItem) => {
245
- if (childItem.props.id === "root") {
246
- return __spreadProps(__spreadValues({}, childItem), {
247
- props: __spreadValues(__spreadValues({}, childItem.props), action.root.props),
248
- readOnly: action.root.readOnly
249
- });
250
- }
251
- return childItem;
252
- }
253
- );
254
- };
255
-
256
- // reducer/actions/duplicate.ts
257
- init_react_import();
258
-
259
- // lib/data/get-item.ts
260
- init_react_import();
261
- function getItem(selector, state) {
262
- var _a, _b;
263
- const zone = (_a = state.indexes.zones) == null ? void 0 : _a[selector.zone || rootDroppableId];
264
- return zone ? (_b = state.indexes.nodes[zone.contentIds[selector.index]]) == null ? void 0 : _b.data : void 0;
265
- }
266
-
267
- // reducer/actions/duplicate.ts
268
- function duplicateAction(state, action, appStore) {
269
- const item = getItem(
270
- { index: action.sourceIndex, zone: action.sourceZone },
271
- state
272
- );
273
- const idsInPath = getIdsForParent(action.sourceZone, state);
274
- const newItem = __spreadProps(__spreadValues({}, item), {
275
- props: __spreadProps(__spreadValues({}, item.props), {
276
- id: generateId(item.type)
277
- })
278
- });
279
- const modified = walkAppState(
280
- state,
281
- appStore.config,
282
- (content, zoneCompound) => {
283
- if (zoneCompound === action.sourceZone) {
284
- return insert(content, action.sourceIndex + 1, item);
285
- }
286
- return content;
287
- },
288
- (childItem, path, index) => {
289
- const zoneCompound = path[path.length - 1];
290
- const parents = path.map((p) => p.split(":")[0]);
291
- if (parents.indexOf(newItem.props.id) > -1) {
292
- return __spreadProps(__spreadValues({}, childItem), {
293
- props: __spreadProps(__spreadValues({}, childItem.props), {
294
- id: generateId(childItem.type)
295
- })
296
- });
297
- }
298
- if (zoneCompound === action.sourceZone && index === action.sourceIndex + 1) {
299
- return newItem;
300
- }
301
- const [sourceZoneParent] = action.sourceZone.split(":");
302
- if (sourceZoneParent === childItem.props.id || idsInPath.indexOf(childItem.props.id) > -1) {
303
- return childItem;
304
- }
305
- return null;
306
- }
307
- );
308
- return __spreadProps(__spreadValues({}, modified), {
309
- ui: __spreadProps(__spreadValues({}, modified.ui), {
310
- itemSelector: {
311
- index: action.sourceIndex + 1,
312
- zone: action.sourceZone
313
- }
314
- })
315
- });
316
- }
317
-
318
- // reducer/actions/reorder.ts
319
- init_react_import();
320
-
321
- // reducer/actions/move.ts
322
- init_react_import();
323
-
324
- // lib/data/remove.ts
325
- init_react_import();
326
- var remove = (list, index) => {
327
- const result = Array.from(list);
328
- result.splice(index, 1);
329
- return result;
330
- };
331
-
332
- // reducer/actions/move.ts
333
- var moveAction = (state, action, appStore) => {
334
- if (action.sourceZone === action.destinationZone && action.sourceIndex === action.destinationIndex) {
335
- return state;
336
- }
337
- const item = getItem(
338
- { zone: action.sourceZone, index: action.sourceIndex },
339
- state
340
- );
341
- if (!item) return state;
342
- const idsInSourcePath = getIdsForParent(action.sourceZone, state);
343
- const idsInDestinationPath = getIdsForParent(action.destinationZone, state);
344
- return walkAppState(
345
- state,
346
- appStore.config,
347
- (content, zoneCompound) => {
348
- if (zoneCompound === action.sourceZone && zoneCompound === action.destinationZone) {
349
- return insert(
350
- remove(content, action.sourceIndex),
351
- action.destinationIndex,
352
- item
353
- );
354
- } else if (zoneCompound === action.sourceZone) {
355
- return remove(content, action.sourceIndex);
356
- } else if (zoneCompound === action.destinationZone) {
357
- return insert(content, action.destinationIndex, item);
358
- }
359
- return content;
360
- },
361
- (childItem, path) => {
362
- const [sourceZoneParent] = action.sourceZone.split(":");
363
- const [destinationZoneParent] = action.destinationZone.split(":");
364
- const childId = childItem.props.id;
365
- if (sourceZoneParent === childId || destinationZoneParent === childId || item.props.id === childId || idsInSourcePath.indexOf(childId) > -1 || idsInDestinationPath.indexOf(childId) > -1 || path.includes(action.destinationZone)) {
366
- return childItem;
367
- }
368
- return null;
369
- }
370
- );
371
- };
372
-
373
- // reducer/actions/reorder.ts
374
- var reorderAction = (state, action, appStore) => {
375
- return moveAction(
376
- state,
377
- {
378
- type: "move",
379
- sourceIndex: action.sourceIndex,
380
- sourceZone: action.destinationZone,
381
- destinationIndex: action.destinationIndex,
382
- destinationZone: action.destinationZone
383
- },
384
- appStore
385
- );
386
- };
387
-
388
- // reducer/actions/remove.ts
389
- init_react_import();
390
- var removeAction = (state, action, appStore) => {
391
- const item = getItem({ index: action.index, zone: action.zone }, state);
392
- const nodesToDelete = Object.entries(state.indexes.nodes).reduce(
393
- (acc, [nodeId, nodeData]) => {
394
- const pathIds = nodeData.path.map((p) => p.split(":")[0]);
395
- if (pathIds.includes(item.props.id)) {
396
- return [...acc, nodeId];
397
- }
398
- return acc;
399
- },
400
- [item.props.id]
401
- );
402
- const newState = walkAppState(
403
- state,
404
- appStore.config,
405
- (content, zoneCompound) => {
406
- if (zoneCompound === action.zone) {
407
- return remove(content, action.index);
408
- }
409
- return content;
410
- }
411
- );
412
- Object.keys(newState.data.zones || {}).forEach((zoneCompound) => {
413
- const parentId = zoneCompound.split(":")[0];
414
- if (nodesToDelete.includes(parentId) && newState.data.zones) {
415
- delete newState.data.zones[zoneCompound];
416
- }
417
- });
418
- Object.keys(newState.indexes.zones).forEach((zoneCompound) => {
419
- const parentId = zoneCompound.split(":")[0];
420
- if (nodesToDelete.includes(parentId)) {
421
- delete newState.indexes.zones[zoneCompound];
422
- }
423
- });
424
- nodesToDelete.forEach((id) => {
425
- delete newState.indexes.nodes[id];
426
- });
427
- return newState;
428
- };
429
-
430
- // reducer/actions/register-zone.ts
431
- init_react_import();
432
- var zoneCache = {};
433
- function registerZoneAction(state, action) {
434
- if (zoneCache[action.zone]) {
435
- return __spreadProps(__spreadValues({}, state), {
436
- data: __spreadProps(__spreadValues({}, state.data), {
437
- zones: __spreadProps(__spreadValues({}, state.data.zones), {
438
- [action.zone]: zoneCache[action.zone]
439
- })
440
- }),
441
- indexes: __spreadProps(__spreadValues({}, state.indexes), {
442
- zones: __spreadProps(__spreadValues({}, state.indexes.zones), {
443
- [action.zone]: __spreadProps(__spreadValues({}, state.indexes.zones[action.zone]), {
444
- contentIds: zoneCache[action.zone].map((item) => item.props.id),
445
- type: "dropzone"
446
- })
447
- })
448
- })
449
- });
450
- }
451
- return __spreadProps(__spreadValues({}, state), { data: setupZone(state.data, action.zone) });
452
- }
453
- function unregisterZoneAction(state, action) {
454
- const _zones = __spreadValues({}, state.data.zones || {});
455
- const zoneIndex = __spreadValues({}, state.indexes.zones || {});
456
- if (_zones[action.zone]) {
457
- zoneCache[action.zone] = _zones[action.zone];
458
- delete _zones[action.zone];
459
- }
460
- delete zoneIndex[action.zone];
461
- return __spreadProps(__spreadValues({}, state), {
462
- data: __spreadProps(__spreadValues({}, state.data), {
463
- zones: _zones
464
- }),
465
- indexes: __spreadProps(__spreadValues({}, state.indexes), {
466
- zones: zoneIndex
467
- })
468
- });
469
- }
470
-
471
- // reducer/actions/set-data.ts
472
- init_react_import();
473
- var setDataAction = (state, action, appStore) => {
474
- if (typeof action.data === "object") {
475
- console.warn(
476
- "`setData` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
477
- );
478
- return walkAppState(
479
- __spreadProps(__spreadValues({}, state), {
480
- data: __spreadValues(__spreadValues({}, state.data), action.data)
481
- }),
482
- appStore.config
483
- );
484
- }
485
- return walkAppState(
486
- __spreadProps(__spreadValues({}, state), {
487
- data: __spreadValues(__spreadValues({}, state.data), action.data(state.data))
488
- }),
489
- appStore.config
490
- );
491
- };
492
-
493
- // reducer/actions/set-ui.ts
494
- init_react_import();
495
- var setUiAction = (state, action) => {
496
- if (typeof action.ui === "object") {
497
- return __spreadProps(__spreadValues({}, state), {
498
- ui: __spreadValues(__spreadValues({}, state.ui), action.ui)
499
- });
500
- }
501
- return __spreadProps(__spreadValues({}, state), {
502
- ui: __spreadValues(__spreadValues({}, state.ui), action.ui(state.ui))
503
- });
504
- };
505
-
506
- // lib/data/make-state-public.ts
507
- init_react_import();
508
- var makeStatePublic = (state) => {
509
- const { data, ui } = state;
510
- return { data, ui };
511
- };
512
-
513
- // reducer/actions.tsx
514
- init_react_import();
515
-
516
- // reducer/index.ts
517
- function storeInterceptor(reducer, record, onAction) {
518
- return (state, action) => {
519
- const newAppState = reducer(state, action);
520
- const isValidType = ![
521
- "registerZone",
522
- "unregisterZone",
523
- "setData",
524
- "setUi",
525
- "set"
526
- ].includes(action.type);
527
- if (typeof action.recordHistory !== "undefined" ? action.recordHistory : isValidType) {
528
- if (record) record(newAppState);
529
- }
530
- onAction == null ? void 0 : onAction(action, makeStatePublic(newAppState), makeStatePublic(state));
531
- return newAppState;
532
- };
533
- }
534
- function createReducer({
535
- record,
536
- onAction,
537
- appStore
538
- }) {
539
- return storeInterceptor(
540
- (state, action) => {
541
- if (action.type === "set") {
542
- return setAction(state, action, appStore);
543
- }
544
- if (action.type === "insert") {
545
- return insertAction(state, action, appStore);
546
- }
547
- if (action.type === "replace") {
548
- return replaceAction(state, action, appStore);
549
- }
550
- if (action.type === "replaceRoot") {
551
- return replaceRootAction(state, action, appStore);
552
- }
553
- if (action.type === "duplicate") {
554
- return duplicateAction(state, action, appStore);
555
- }
556
- if (action.type === "reorder") {
557
- return reorderAction(state, action, appStore);
558
- }
559
- if (action.type === "move") {
560
- return moveAction(state, action, appStore);
561
- }
562
- if (action.type === "remove") {
563
- return removeAction(state, action, appStore);
564
- }
565
- if (action.type === "registerZone") {
566
- return registerZoneAction(state, action);
567
- }
568
- if (action.type === "unregisterZone") {
569
- return unregisterZoneAction(state, action);
570
- }
571
- if (action.type === "setData") {
572
- return setDataAction(state, action, appStore);
573
- }
574
- if (action.type === "setUi") {
575
- return setUiAction(state, action);
576
- }
577
- return state;
578
- },
579
- record,
580
- onAction
581
- );
582
- }
583
-
584
- // store/index.ts
585
- import { create as create2, useStore } from "zustand";
586
- import { subscribeWithSelector as subscribeWithSelector2 } from "zustand/middleware";
587
- import { createContext, useContext } from "react";
588
-
589
- // store/slices/history.ts
590
- init_react_import();
591
- import { useEffect as useEffect2 } from "react";
592
-
593
- // lib/use-hotkey.ts
594
- init_react_import();
595
- import { useEffect } from "react";
596
- import { create } from "zustand";
597
- import { subscribeWithSelector } from "zustand/middleware";
598
- var keyCodeMap = {
599
- ControlLeft: "ctrl",
600
- ControlRight: "ctrl",
601
- MetaLeft: "meta",
602
- MetaRight: "meta",
603
- ShiftLeft: "shift",
604
- ShiftRight: "shift",
605
- KeyA: "a",
606
- KeyB: "b",
607
- KeyC: "c",
608
- KeyD: "d",
609
- KeyE: "e",
610
- KeyF: "f",
611
- KeyG: "g",
612
- KeyH: "h",
613
- KeyI: "i",
614
- KeyJ: "j",
615
- KeyK: "k",
616
- KeyL: "l",
617
- KeyM: "m",
618
- KeyN: "n",
619
- KeyO: "o",
620
- KeyP: "p",
621
- KeyQ: "q",
622
- KeyR: "r",
623
- KeyS: "s",
624
- KeyT: "t",
625
- KeyU: "u",
626
- KeyV: "v",
627
- KeyW: "w",
628
- KeyX: "x",
629
- KeyY: "y",
630
- KeyZ: "z",
631
- Delete: "delete",
632
- Backspace: "backspace"
633
- };
634
- var useHotkeyStore = create()(
635
- subscribeWithSelector((set) => ({
636
- held: {},
637
- hold: (key) => set((s) => s.held[key] ? s : { held: __spreadProps(__spreadValues({}, s.held), { [key]: true }) }),
638
- release: (key) => set((s) => s.held[key] ? { held: __spreadProps(__spreadValues({}, s.held), { [key]: false }) } : s),
639
- reset: (held = {}) => set(() => ({ held })),
640
- triggers: {}
641
- }))
642
- );
643
- var monitorHotkeys = (doc) => {
644
- const onKeyDown = (e) => {
645
- const key = keyCodeMap[e.code];
646
- if (key) {
647
- useHotkeyStore.getState().hold(key);
648
- const { held, triggers } = useHotkeyStore.getState();
649
- Object.values(triggers).forEach(({ combo, cb }) => {
650
- const conditionMet = Object.entries(combo).every(
651
- ([key2, value]) => value === !!held[key2]
652
- ) && Object.entries(held).every(
653
- ([key2, value]) => value === !!combo[key2]
654
- );
655
- if (conditionMet) {
656
- const handled = cb(e);
657
- if (handled !== false) {
658
- e.preventDefault();
659
- }
660
- }
661
- });
662
- if (key !== "meta" && key !== "ctrl" && key !== "shift") {
663
- useHotkeyStore.getState().release(key);
664
- }
665
- }
666
- };
667
- const onKeyUp = (e) => {
668
- const key = keyCodeMap[e.code];
669
- if (key) {
670
- if (key === "meta") {
671
- useHotkeyStore.getState().reset();
672
- } else {
673
- useHotkeyStore.getState().release(key);
674
- }
675
- }
676
- };
677
- const onVisibilityChanged = (e) => {
678
- if (document.visibilityState === "hidden") {
679
- useHotkeyStore.getState().reset();
680
- }
681
- };
682
- const onBlur = () => {
683
- useHotkeyStore.getState().reset();
684
- };
685
- window.addEventListener("blur", onBlur);
686
- doc.addEventListener("keydown", onKeyDown);
687
- doc.addEventListener("keyup", onKeyUp);
688
- doc.addEventListener("visibilitychange", onVisibilityChanged);
689
- return () => {
690
- doc.removeEventListener("keydown", onKeyDown);
691
- doc.removeEventListener("keyup", onKeyUp);
692
- doc.removeEventListener("visibilitychange", onVisibilityChanged);
693
- window.removeEventListener("blur", onBlur);
694
- };
695
- };
696
- var useMonitorHotkeys = () => {
697
- useEffect(() => monitorHotkeys(document), []);
698
- };
699
- var useHotkey = (combo, cb) => {
700
- useEffect(
701
- () => useHotkeyStore.setState((s) => ({
702
- triggers: __spreadProps(__spreadValues({}, s.triggers), {
703
- [`${Object.keys(combo).join("+")}`]: { combo, cb }
704
- })
705
- })),
706
- []
707
- );
708
- };
709
-
710
- // store/slices/history.ts
711
- var EMPTY_HISTORY_INDEX = 0;
712
- function debounce(func, timeout = 300) {
713
- let timer;
714
- return (...args) => {
715
- clearTimeout(timer);
716
- timer = setTimeout(() => {
717
- func(...args);
718
- }, timeout);
719
- };
720
- }
721
- var tidyState = (state) => {
722
- return __spreadProps(__spreadValues({}, state), {
723
- ui: __spreadProps(__spreadValues({}, state.ui), {
724
- field: __spreadProps(__spreadValues({}, state.ui.field), {
725
- focus: null
726
- })
727
- })
728
- });
729
- };
730
- var createHistorySlice = (set, get) => {
731
- const record = debounce((state) => {
732
- const { histories, index } = get().history;
733
- const history = {
734
- state,
735
- id: generateId("history")
736
- };
737
- const newHistories = [...histories.slice(0, index + 1), history];
738
- set({
739
- history: __spreadProps(__spreadValues({}, get().history), {
740
- histories: newHistories,
741
- index: newHistories.length - 1
742
- })
743
- });
744
- }, 250);
745
- return {
746
- initialAppState: {},
747
- index: EMPTY_HISTORY_INDEX,
748
- histories: [],
749
- hasPast: () => get().history.index > EMPTY_HISTORY_INDEX,
750
- hasFuture: () => get().history.index < get().history.histories.length - 1,
751
- prevHistory: () => {
752
- const { history } = get();
753
- return history.hasPast() ? history.histories[history.index - 1] : null;
754
- },
755
- nextHistory: () => {
756
- const s = get().history;
757
- return s.hasFuture() ? s.histories[s.index + 1] : null;
758
- },
759
- currentHistory: () => get().history.histories[get().history.index],
760
- back: () => {
761
- var _a;
762
- const { history, dispatch } = get();
763
- if (history.hasPast()) {
764
- const state = tidyState(
765
- ((_a = history.prevHistory()) == null ? void 0 : _a.state) || history.initialAppState
766
- );
767
- dispatch({
768
- type: "set",
769
- state
770
- });
771
- set({ history: __spreadProps(__spreadValues({}, history), { index: history.index - 1 }) });
772
- }
773
- },
774
- forward: () => {
775
- var _a;
776
- const { history, dispatch } = get();
777
- if (history.hasFuture()) {
778
- const state = (_a = history.nextHistory()) == null ? void 0 : _a.state;
779
- dispatch({ type: "set", state: state ? tidyState(state) : {} });
780
- set({ history: __spreadProps(__spreadValues({}, history), { index: history.index + 1 }) });
781
- }
782
- },
783
- setHistories: (histories) => {
784
- var _a;
785
- const { dispatch, history } = get();
786
- dispatch({
787
- type: "set",
788
- state: ((_a = histories[histories.length - 1]) == null ? void 0 : _a.state) || history.initialAppState
789
- });
790
- set({ history: __spreadProps(__spreadValues({}, history), { histories, index: histories.length - 1 }) });
791
- },
792
- setHistoryIndex: (index) => {
793
- var _a;
794
- const { dispatch, history } = get();
795
- dispatch({
796
- type: "set",
797
- state: ((_a = history.histories[index]) == null ? void 0 : _a.state) || history.initialAppState
798
- });
799
- set({ history: __spreadProps(__spreadValues({}, history), { index }) });
800
- },
801
- record
802
- };
803
- };
804
- function useRegisterHistorySlice(appStore, {
805
- histories,
806
- index,
807
- initialAppState
808
- }) {
809
- useEffect2(
810
- () => appStore.setState({
811
- history: __spreadProps(__spreadValues({}, appStore.getState().history), {
812
- histories,
813
- index,
814
- initialAppState
815
- })
816
- }),
817
- [histories, index, initialAppState]
818
- );
819
- const back = () => {
820
- appStore.getState().history.back();
821
- };
822
- const forward = () => {
823
- appStore.getState().history.forward();
824
- };
825
- useHotkey({ meta: true, z: true }, back);
826
- useHotkey({ meta: true, shift: true, z: true }, forward);
827
- useHotkey({ meta: true, y: true }, forward);
828
- useHotkey({ ctrl: true, z: true }, back);
829
- useHotkey({ ctrl: true, shift: true, z: true }, forward);
830
- useHotkey({ ctrl: true, y: true }, forward);
831
- }
832
-
833
- // store/slices/nodes.ts
834
- init_react_import();
835
- var createNodesSlice = (set, get) => ({
836
- nodes: {},
837
- registerNode: (id, node) => {
838
- const s = get().nodes;
839
- const emptyNode = {
840
- id,
841
- methods: {
842
- sync: () => null,
843
- hideOverlay: () => null,
844
- showOverlay: () => null
845
- },
846
- element: null
847
- };
848
- const existingNode = s.nodes[id];
849
- set({
850
- nodes: __spreadProps(__spreadValues({}, s), {
851
- nodes: __spreadProps(__spreadValues({}, s.nodes), {
852
- [id]: __spreadProps(__spreadValues(__spreadValues(__spreadValues({}, emptyNode), existingNode), node), {
853
- id
854
- })
855
- })
856
- })
857
- });
858
- },
859
- unregisterNode: (id) => {
860
- const s = get().nodes;
861
- const existingNode = s.nodes[id];
862
- if (existingNode) {
863
- const newNodes = __spreadValues({}, s.nodes);
864
- delete newNodes[id];
865
- set({
866
- nodes: __spreadProps(__spreadValues({}, s), {
867
- nodes: newNodes
868
- })
869
- });
870
- }
871
- }
872
- });
873
-
874
- // store/slices/permissions.ts
875
- init_react_import();
876
- import { useEffect as useEffect3 } from "react";
877
-
878
- // lib/data/flatten-data.ts
879
- init_react_import();
880
- var flattenData = (state, config) => {
881
- const data = [];
882
- walkAppState(
883
- state,
884
- config,
885
- (content) => content,
886
- (item) => {
887
- data.push(item);
888
- return item;
889
- }
890
- );
891
- return data;
892
- };
893
-
894
- // store/slices/permissions.ts
895
- var createPermissionsSlice = (set, get) => {
896
- const resolvePermissions = (..._0) => __async(null, [..._0], function* (params = {}, force) {
897
- const { state, permissions, config } = get();
898
- const { cache, globalPermissions } = permissions;
899
- const resolvePermissionsForItem = (item2, force2 = false) => __async(null, null, function* () {
900
- var _a, _b;
901
- const { config: config2, state: appState, setComponentLoading } = get();
902
- const itemCache = cache[item2.props.id];
903
- const nodes = appState.indexes.nodes;
904
- const parentId = (_a = nodes[item2.props.id]) == null ? void 0 : _a.parentId;
905
- const parentNode = parentId ? nodes[parentId] : null;
906
- const parentData = (_b = parentNode == null ? void 0 : parentNode.data) != null ? _b : null;
907
- const componentConfig = item2.type === "root" ? config2.root : config2.components[item2.type];
908
- if (!componentConfig) {
909
- return;
910
- }
911
- const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), componentConfig.permissions);
912
- if (componentConfig.resolvePermissions) {
913
- const changed = getChanged(item2, itemCache == null ? void 0 : itemCache.lastData);
914
- const propsChanged = Object.values(changed).some((el) => el === true);
915
- const parentChanged = (itemCache == null ? void 0 : itemCache.lastParentId) !== parentId;
916
- if (propsChanged || parentChanged || force2) {
917
- const clearTimeout2 = setComponentLoading(item2.props.id, true, 50);
918
- const resolvedPermissions = yield componentConfig.resolvePermissions(
919
- item2,
920
- {
921
- changed,
922
- lastPermissions: (itemCache == null ? void 0 : itemCache.lastPermissions) || null,
923
- permissions: initialPermissions,
924
- appState: makeStatePublic(appState),
925
- lastData: (itemCache == null ? void 0 : itemCache.lastData) || null,
926
- parent: parentData
927
- }
928
- );
929
- const latest = get().permissions;
930
- set({
931
- permissions: __spreadProps(__spreadValues({}, latest), {
932
- cache: __spreadProps(__spreadValues({}, latest.cache), {
933
- [item2.props.id]: {
934
- lastParentId: parentId,
935
- lastData: item2,
936
- lastPermissions: resolvedPermissions
937
- }
938
- }),
939
- resolvedPermissions: __spreadProps(__spreadValues({}, latest.resolvedPermissions), {
940
- [item2.props.id]: resolvedPermissions
941
- })
942
- })
943
- });
944
- clearTimeout2();
945
- }
946
- }
947
- });
948
- const resolvePermissionsForRoot = (force2 = false) => {
949
- const { state: appState } = get();
950
- resolvePermissionsForItem(
951
- // Shim the root data in by conforming to component data shape
952
- {
953
- type: "root",
954
- props: __spreadProps(__spreadValues({}, appState.data.root.props), { id: "root" })
955
- },
956
- force2
957
- );
958
- };
959
- const { item, type, root } = params;
960
- if (item) {
961
- yield resolvePermissionsForItem(item, force);
962
- } else if (type) {
963
- flattenData(state, config).filter((item2) => item2.type === type).map((item2) => __async(null, null, function* () {
964
- yield resolvePermissionsForItem(item2, force);
965
- }));
966
- } else if (root) {
967
- resolvePermissionsForRoot(force);
968
- } else {
969
- flattenData(state, config).map((item2) => __async(null, null, function* () {
970
- yield resolvePermissionsForItem(item2, force);
971
- }));
972
- }
973
- });
974
- const refreshPermissions = (params) => resolvePermissions(params, true);
975
- return {
976
- cache: {},
977
- globalPermissions: {
978
- drag: true,
979
- edit: true,
980
- delete: true,
981
- duplicate: true,
982
- insert: true
983
- },
984
- resolvedPermissions: {},
985
- getPermissions: ({ item, type, root } = {}) => {
986
- const { config, permissions } = get();
987
- const { globalPermissions, resolvedPermissions } = permissions;
988
- if (item) {
989
- const componentConfig = config.components[item.type];
990
- const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), componentConfig == null ? void 0 : componentConfig.permissions);
991
- const resolvedForItem = resolvedPermissions[item.props.id];
992
- return resolvedForItem ? __spreadValues(__spreadValues({}, globalPermissions), resolvedForItem) : initialPermissions;
993
- } else if (type) {
994
- const componentConfig = config.components[type];
995
- return __spreadValues(__spreadValues({}, globalPermissions), componentConfig == null ? void 0 : componentConfig.permissions);
996
- } else if (root) {
997
- const rootConfig = config.root;
998
- const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), rootConfig == null ? void 0 : rootConfig.permissions);
999
- const resolvedForItem = resolvedPermissions["root"];
1000
- return resolvedForItem ? __spreadValues(__spreadValues({}, globalPermissions), resolvedForItem) : initialPermissions;
1001
- }
1002
- return globalPermissions;
1003
- },
1004
- resolvePermissions,
1005
- refreshPermissions
1006
- };
1007
- };
1008
- var useRegisterPermissionsSlice = (appStore, globalPermissions) => {
1009
- useEffect3(() => {
1010
- const { permissions } = appStore.getState();
1011
- const { globalPermissions: existingGlobalPermissions } = permissions;
1012
- appStore.setState({
1013
- permissions: __spreadProps(__spreadValues({}, permissions), {
1014
- globalPermissions: __spreadValues(__spreadValues({}, existingGlobalPermissions), globalPermissions)
1015
- })
1016
- });
1017
- permissions.resolvePermissions();
1018
- }, [globalPermissions]);
1019
- useEffect3(() => {
1020
- return appStore.subscribe(
1021
- (s) => s.state.data,
1022
- () => {
1023
- appStore.getState().permissions.resolvePermissions();
1024
- }
1025
- );
1026
- }, []);
1027
- useEffect3(() => {
1028
- return appStore.subscribe(
1029
- (s) => s.config,
1030
- () => {
1031
- appStore.getState().permissions.resolvePermissions();
1032
- }
1033
- );
1034
- }, []);
1035
- };
1036
-
1037
- // store/slices/fields.ts
1038
- init_react_import();
1039
- import { useCallback, useEffect as useEffect4 } from "react";
1040
- var createFieldsSlice = (_set, _get) => {
1041
- return {
1042
- fields: {},
1043
- loading: false,
1044
- lastResolvedData: {},
1045
- id: void 0
1046
- };
1047
- };
1048
- var useRegisterFieldsSlice = (appStore, id) => {
1049
- const resolveFields = useCallback(
1050
- (reset) => __async(null, null, function* () {
1051
- var _a, _b;
1052
- const { fields, lastResolvedData } = appStore.getState().fields;
1053
- const metadata = appStore.getState().metadata;
1054
- const nodes = appStore.getState().state.indexes.nodes;
1055
- const node = nodes[id || "root"];
1056
- const componentData = node == null ? void 0 : node.data;
1057
- const parentNode = (node == null ? void 0 : node.parentId) ? nodes[node.parentId] : null;
1058
- const parent = (parentNode == null ? void 0 : parentNode.data) || null;
1059
- const { getComponentConfig, state } = appStore.getState();
1060
- const componentConfig = getComponentConfig(componentData == null ? void 0 : componentData.type);
1061
- if (!componentData || !componentConfig) return;
1062
- const defaultFields = componentConfig.fields || {};
1063
- const resolver = componentConfig.resolveFields;
1064
- let lastFields = fields;
1065
- if (reset) {
1066
- appStore.setState((s) => ({
1067
- fields: __spreadProps(__spreadValues({}, s.fields), { fields: defaultFields, id })
1068
- }));
1069
- lastFields = defaultFields;
1070
- }
1071
- if (resolver) {
1072
- const timeout = setTimeout(() => {
1073
- appStore.setState((s) => ({
1074
- fields: __spreadProps(__spreadValues({}, s.fields), { loading: true })
1075
- }));
1076
- }, 50);
1077
- const lastData = ((_a = lastResolvedData.props) == null ? void 0 : _a.id) === id ? lastResolvedData : null;
1078
- const changed = getChanged(componentData, lastData);
1079
- const newFields = yield resolver(componentData, {
1080
- changed,
1081
- fields: defaultFields,
1082
- lastFields,
1083
- metadata: __spreadValues(__spreadValues({}, metadata), componentConfig.metadata),
1084
- lastData,
1085
- appState: makeStatePublic(state),
1086
- parent
1087
- });
1088
- clearTimeout(timeout);
1089
- if (((_b = appStore.getState().selectedItem) == null ? void 0 : _b.props.id) !== id) {
1090
- return;
1091
- }
1092
- appStore.setState({
1093
- fields: {
1094
- fields: newFields,
1095
- loading: false,
1096
- lastResolvedData: componentData,
1097
- id
1098
- }
1099
- });
1100
- } else {
1101
- appStore.setState((s) => ({
1102
- fields: __spreadProps(__spreadValues({}, s.fields), { fields: defaultFields, id })
1103
- }));
1104
- }
1105
- }),
1106
- [id]
1107
- );
1108
- useEffect4(() => {
1109
- resolveFields(true);
1110
- return appStore.subscribe(
1111
- (s) => s.state.indexes.nodes[id || "root"],
1112
- () => resolveFields()
1113
- );
1114
- }, [id]);
1115
- };
1116
-
1117
- // lib/data/to-root.ts
1118
- init_react_import();
1119
- var toRoot = (item) => {
1120
- if ("type" in item && item.type !== "root") {
1121
- throw new Error("Converting non-root item to root.");
1122
- }
1123
- const { readOnly } = item;
1124
- if (item.props) {
1125
- if ("id" in item.props) {
1126
- const _a = item.props, { id } = _a, props = __objRest(_a, ["id"]);
1127
- return { props, readOnly };
1128
- }
1129
- return { props: item.props, readOnly };
1130
- }
1131
- return { props: {}, readOnly };
1132
- };
1133
-
1134
- // store/index.ts
1135
- var defaultPageFields = {
1136
- title: { type: "text" }
1137
- };
1138
- var createAppStore = (initialAppStore) => create2()(
1139
- subscribeWithSelector2((set, get) => {
1140
- var _a, _b;
1141
- return __spreadProps(__spreadValues({
1142
- state: defaultAppState,
1143
- config: { components: {} },
1144
- componentState: {},
1145
- plugins: [],
1146
- overrides: {},
1147
- viewports: defaultViewports,
1148
- zoomConfig: {
1149
- autoZoom: 1,
1150
- rootHeight: 0,
1151
- zoom: 1
1152
- },
1153
- status: "LOADING",
1154
- iframe: {},
1155
- metadata: {},
1156
- fieldTransforms: {}
1157
- }, initialAppStore), {
1158
- fields: createFieldsSlice(set, get),
1159
- history: createHistorySlice(set, get),
1160
- nodes: createNodesSlice(set, get),
1161
- permissions: createPermissionsSlice(set, get),
1162
- getComponentConfig: (type) => {
1163
- var _a2;
1164
- const { config, selectedItem } = get();
1165
- const rootFields = ((_a2 = config.root) == null ? void 0 : _a2.fields) || defaultPageFields;
1166
- return type && type !== "root" ? config.components[type] : selectedItem ? config.components[selectedItem.type] : __spreadProps(__spreadValues({}, config.root), { fields: rootFields });
1167
- },
1168
- selectedItem: ((_a = initialAppStore == null ? void 0 : initialAppStore.state) == null ? void 0 : _a.ui.itemSelector) ? getItem(
1169
- (_b = initialAppStore == null ? void 0 : initialAppStore.state) == null ? void 0 : _b.ui.itemSelector,
1170
- initialAppStore.state
1171
- ) : null,
1172
- dispatch: (action) => set((s) => {
1173
- var _a2, _b2;
1174
- const { record } = get().history;
1175
- const dispatch = createReducer({
1176
- record,
1177
- appStore: s
1178
- });
1179
- const state = dispatch(s.state, action);
1180
- const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state) : null;
1181
- (_b2 = (_a2 = get()).onAction) == null ? void 0 : _b2.call(_a2, action, state, get().state);
1182
- return __spreadProps(__spreadValues({}, s), { state, selectedItem });
1183
- }),
1184
- setZoomConfig: (zoomConfig) => set({ zoomConfig }),
1185
- setStatus: (status) => set({ status }),
1186
- setComponentState: (componentState) => set({ componentState }),
1187
- pendingLoadTimeouts: {},
1188
- setComponentLoading: (id, loading = true, defer = 0) => {
1189
- const { setComponentState, pendingLoadTimeouts } = get();
1190
- const loadId = generateId();
1191
- const setLoading = () => {
1192
- var _a2;
1193
- const { componentState } = get();
1194
- setComponentState(__spreadProps(__spreadValues({}, componentState), {
1195
- [id]: __spreadProps(__spreadValues({}, componentState[id]), {
1196
- loadingCount: (((_a2 = componentState[id]) == null ? void 0 : _a2.loadingCount) || 0) + 1
1197
- })
1198
- }));
1199
- };
1200
- const unsetLoading = () => {
1201
- var _a2;
1202
- const { componentState } = get();
1203
- clearTimeout(timeout);
1204
- delete pendingLoadTimeouts[loadId];
1205
- set({ pendingLoadTimeouts });
1206
- setComponentState(__spreadProps(__spreadValues({}, componentState), {
1207
- [id]: __spreadProps(__spreadValues({}, componentState[id]), {
1208
- loadingCount: Math.max(
1209
- (((_a2 = componentState[id]) == null ? void 0 : _a2.loadingCount) || 0) - 1,
1210
- 0
1211
- )
1212
- })
1213
- }));
1214
- };
1215
- const timeout = setTimeout(() => {
1216
- if (loading) {
1217
- setLoading();
1218
- } else {
1219
- unsetLoading();
1220
- }
1221
- delete pendingLoadTimeouts[loadId];
1222
- set({ pendingLoadTimeouts });
1223
- }, defer);
1224
- set({
1225
- pendingLoadTimeouts: __spreadProps(__spreadValues({}, pendingLoadTimeouts), {
1226
- [id]: timeout
1227
- })
1228
- });
1229
- return unsetLoading;
1230
- },
1231
- unsetComponentLoading: (id) => {
1232
- const { setComponentLoading } = get();
1233
- setComponentLoading(id, false);
1234
- },
1235
- // Helper
1236
- setUi: (ui, recordHistory) => set((s) => {
1237
- const dispatch = createReducer({
1238
- record: () => {
1239
- },
1240
- appStore: s
1241
- });
1242
- const state = dispatch(s.state, {
1243
- type: "setUi",
1244
- ui,
1245
- recordHistory
1246
- });
1247
- const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state) : null;
1248
- return __spreadProps(__spreadValues({}, s), { state, selectedItem });
1249
- }),
1250
- resolveComponentData: (componentData, trigger) => __async(null, null, function* () {
1251
- const { config, metadata, setComponentLoading, permissions } = get();
1252
- const timeouts = {};
1253
- return yield resolveComponentData(
1254
- componentData,
1255
- config,
1256
- metadata,
1257
- (item) => {
1258
- const id = "id" in item.props ? item.props.id : "root";
1259
- timeouts[id] = setComponentLoading(id, true, 50);
1260
- },
1261
- (item) => __async(null, null, function* () {
1262
- const id = "id" in item.props ? item.props.id : "root";
1263
- if ("type" in item) {
1264
- yield permissions.refreshPermissions({ item });
1265
- } else {
1266
- yield permissions.refreshPermissions({ root: true });
1267
- }
1268
- timeouts[id]();
1269
- }),
1270
- trigger
1271
- );
1272
- }),
1273
- resolveAndCommitData: () => __async(null, null, function* () {
1274
- const { config, state, dispatch, resolveComponentData: resolveComponentData2 } = get();
1275
- walkAppState(
1276
- state,
1277
- config,
1278
- (content) => content,
1279
- (childItem) => {
1280
- resolveComponentData2(childItem, "load").then((resolved) => {
1281
- const { state: state2 } = get();
1282
- const node = state2.indexes.nodes[resolved.node.props.id];
1283
- if (node && resolved.didChange) {
1284
- if (resolved.node.props.id === "root") {
1285
- dispatch({
1286
- type: "replaceRoot",
1287
- root: toRoot(resolved.node)
1288
- });
1289
- } else {
1290
- const zoneCompound = `${node.parentId}:${node.zone}`;
1291
- const parentZone = state2.indexes.zones[zoneCompound];
1292
- const index = parentZone.contentIds.indexOf(
1293
- resolved.node.props.id
1294
- );
1295
- dispatch({
1296
- type: "replace",
1297
- data: resolved.node,
1298
- destinationIndex: index,
1299
- destinationZone: zoneCompound
1300
- });
1301
- }
1302
- }
1303
- });
1304
- return childItem;
1305
- }
1306
- );
1307
- })
1308
- });
1309
- })
1310
- );
1311
- var appStoreContext = createContext(createAppStore());
1312
- function useAppStore(selector) {
1313
- const context = useContext(appStoreContext);
1314
- return useStore(context, selector);
1315
- }
1316
- function useAppStoreApi() {
1317
- return useContext(appStoreContext);
1318
- }
1319
-
1320
- // components/IconButton/IconButton.tsx
1321
- init_react_import();
1322
- import { useState } from "react";
1323
-
1324
- // css-module:/home/runner/work/puck/puck/packages/core/components/IconButton/IconButton.module.css#css-module
1325
- init_react_import();
1326
- var IconButton_module_default = { "IconButton": "_IconButton_ffob9_1", "IconButton--active": "_IconButton--active_ffob9_14", "IconButton--disabled": "_IconButton--disabled_ffob9_24", "IconButton-title": "_IconButton-title_ffob9_37" };
1327
-
1328
- // components/Loader/index.tsx
1329
- init_react_import();
1330
-
1331
- // lib/index.ts
1332
- init_react_import();
1333
-
1334
- // lib/filter.ts
1335
- init_react_import();
1336
-
1337
- // lib/data/reorder.ts
1338
- init_react_import();
1339
- var reorder = (list, startIndex, endIndex) => {
1340
- const result = Array.from(list);
1341
- const [removed] = result.splice(startIndex, 1);
1342
- result.splice(endIndex, 0, removed);
1343
- return result;
1344
- };
1345
-
1346
- // lib/data/replace.ts
1347
- init_react_import();
1348
- var replace = (list, index, newItem) => {
1349
- const result = Array.from(list);
1350
- result.splice(index, 1);
1351
- result.splice(index, 0, newItem);
1352
- return result;
1353
- };
1354
-
1355
- // lib/use-reset-auto-zoom.ts
1356
- init_react_import();
1357
-
1358
- // lib/get-zoom-config.ts
1359
- init_react_import();
1360
-
1361
- // ../../node_modules/css-box-model/dist/css-box-model.esm.js
1362
- init_react_import();
1363
-
1364
- // ../../node_modules/tiny-invariant/dist/esm/tiny-invariant.js
1365
- init_react_import();
1366
- var isProduction = process.env.NODE_ENV === "production";
1367
- var prefix = "Invariant failed";
1368
- function invariant(condition, message) {
1369
- if (condition) {
1370
- return;
1371
- }
1372
- if (isProduction) {
1373
- throw new Error(prefix);
1374
- }
1375
- var provided = typeof message === "function" ? message() : message;
1376
- var value = provided ? "".concat(prefix, ": ").concat(provided) : prefix;
1377
- throw new Error(value);
1378
- }
1379
-
1380
- // ../../node_modules/css-box-model/dist/css-box-model.esm.js
1381
- var getRect = function getRect2(_ref) {
1382
- var top = _ref.top, right = _ref.right, bottom = _ref.bottom, left = _ref.left;
1383
- var width = right - left;
1384
- var height = bottom - top;
1385
- var rect = {
1386
- top,
1387
- right,
1388
- bottom,
1389
- left,
1390
- width,
1391
- height,
1392
- x: left,
1393
- y: top,
1394
- center: {
1395
- x: (right + left) / 2,
1396
- y: (bottom + top) / 2
1397
- }
1398
- };
1399
- return rect;
1400
- };
1401
- var expand = function expand2(target, expandBy) {
1402
- return {
1403
- top: target.top - expandBy.top,
1404
- left: target.left - expandBy.left,
1405
- bottom: target.bottom + expandBy.bottom,
1406
- right: target.right + expandBy.right
1407
- };
1408
- };
1409
- var shrink = function shrink2(target, shrinkBy) {
1410
- return {
1411
- top: target.top + shrinkBy.top,
1412
- left: target.left + shrinkBy.left,
1413
- bottom: target.bottom - shrinkBy.bottom,
1414
- right: target.right - shrinkBy.right
1415
- };
1416
- };
1417
- var noSpacing = {
1418
- top: 0,
1419
- right: 0,
1420
- bottom: 0,
1421
- left: 0
1422
- };
1423
- var createBox = function createBox2(_ref2) {
1424
- var borderBox = _ref2.borderBox, _ref2$margin = _ref2.margin, margin = _ref2$margin === void 0 ? noSpacing : _ref2$margin, _ref2$border = _ref2.border, border = _ref2$border === void 0 ? noSpacing : _ref2$border, _ref2$padding = _ref2.padding, padding = _ref2$padding === void 0 ? noSpacing : _ref2$padding;
1425
- var marginBox = getRect(expand(borderBox, margin));
1426
- var paddingBox = getRect(shrink(borderBox, border));
1427
- var contentBox = getRect(shrink(paddingBox, padding));
1428
- return {
1429
- marginBox,
1430
- borderBox: getRect(borderBox),
1431
- paddingBox,
1432
- contentBox,
1433
- margin,
1434
- border,
1435
- padding
1436
- };
1437
- };
1438
- var parse = function parse2(raw) {
1439
- var value = raw.slice(0, -2);
1440
- var suffix = raw.slice(-2);
1441
- if (suffix !== "px") {
1442
- return 0;
1443
- }
1444
- var result = Number(value);
1445
- !!isNaN(result) ? process.env.NODE_ENV !== "production" ? invariant(false, "Could not parse value [raw: " + raw + ", without suffix: " + value + "]") : invariant(false) : void 0;
1446
- return result;
1447
- };
1448
- var calculateBox = function calculateBox2(borderBox, styles) {
1449
- var margin = {
1450
- top: parse(styles.marginTop),
1451
- right: parse(styles.marginRight),
1452
- bottom: parse(styles.marginBottom),
1453
- left: parse(styles.marginLeft)
1454
- };
1455
- var padding = {
1456
- top: parse(styles.paddingTop),
1457
- right: parse(styles.paddingRight),
1458
- bottom: parse(styles.paddingBottom),
1459
- left: parse(styles.paddingLeft)
1460
- };
1461
- var border = {
1462
- top: parse(styles.borderTopWidth),
1463
- right: parse(styles.borderRightWidth),
1464
- bottom: parse(styles.borderBottomWidth),
1465
- left: parse(styles.borderLeftWidth)
1466
- };
1467
- return createBox({
1468
- borderBox,
1469
- margin,
1470
- padding,
1471
- border
1472
- });
1473
- };
1474
- var getBox = function getBox2(el) {
1475
- var borderBox = el.getBoundingClientRect();
1476
- var styles = window.getComputedStyle(el);
1477
- return calculateBox(borderBox, styles);
1478
- };
1479
-
1480
- // lib/get-zoom-config.ts
1481
- var RESET_ZOOM_SMALLER_THAN_FRAME = true;
1482
- var getZoomConfig = (uiViewport, frame, zoom) => {
1483
- const box = getBox(frame);
1484
- const { width: frameWidth, height: frameHeight } = box.contentBox;
1485
- const viewportHeight = uiViewport.height === "auto" ? frameHeight : uiViewport.height;
1486
- let rootHeight = 0;
1487
- let autoZoom = 1;
1488
- if (uiViewport.width > frameWidth || viewportHeight > frameHeight) {
1489
- const widthZoom = Math.min(frameWidth / uiViewport.width, 1);
1490
- const heightZoom = Math.min(frameHeight / viewportHeight, 1);
1491
- zoom = widthZoom;
1492
- if (widthZoom < heightZoom) {
1493
- rootHeight = viewportHeight / zoom;
1494
- } else {
1495
- rootHeight = viewportHeight;
1496
- zoom = heightZoom;
1497
- }
1498
- autoZoom = zoom;
1499
- } else {
1500
- if (RESET_ZOOM_SMALLER_THAN_FRAME) {
1501
- autoZoom = 1;
1502
- zoom = 1;
1503
- rootHeight = viewportHeight;
1504
- }
1505
- }
1506
- return { autoZoom, rootHeight, zoom };
1507
- };
1508
-
1509
- // lib/use-reset-auto-zoom.ts
1510
- var useResetAutoZoom = (frameRef) => {
1511
- const appStoreApi = useAppStoreApi();
1512
- const resetAutoZoom = (options) => {
1513
- const { state, zoomConfig, setZoomConfig } = appStoreApi.getState();
1514
- const { viewports } = state.ui;
1515
- const newViewports = (options == null ? void 0 : options.viewports) || viewports;
1516
- if (frameRef.current) {
1517
- setZoomConfig(
1518
- getZoomConfig(newViewports == null ? void 0 : newViewports.current, frameRef.current, zoomConfig.zoom)
1519
- );
1520
- }
1521
- };
1522
- return resetAutoZoom;
1523
- };
1524
-
1525
- // css-module:/home/runner/work/puck/puck/packages/core/components/Loader/styles.module.css#css-module
1526
- init_react_import();
1527
- var styles_module_default3 = { "Loader": "_Loader_nacdm_13", "loader-animation": "_loader-animation_nacdm_1" };
1528
-
1529
- // components/Loader/index.tsx
1530
- import { jsx as jsx2 } from "react/jsx-runtime";
1531
- var getClassName2 = get_class_name_factory_default("Loader", styles_module_default3);
1532
- var Loader = (_a) => {
1533
- var _b = _a, {
1534
- color,
1535
- size = 16
1536
- } = _b, props = __objRest(_b, [
1537
- "color",
1538
- "size"
1539
- ]);
1540
- return /* @__PURE__ */ jsx2(
1541
- "span",
1542
- __spreadValues({
1543
- className: getClassName2(),
1544
- style: {
1545
- width: size,
1546
- height: size,
1547
- color
1548
- },
1549
- "aria-label": "loading"
1550
- }, props)
1551
- );
1552
- };
1553
-
1554
- // components/IconButton/IconButton.tsx
1555
- import { Fragment, jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
1556
- var getClassName3 = get_class_name_factory_default("IconButton", IconButton_module_default);
1557
- var IconButton = ({
1558
- active = false,
1559
- children,
1560
- href,
1561
- onClick,
1562
- type,
1563
- disabled,
1564
- tabIndex,
1565
- newTab,
1566
- fullWidth,
1567
- title
1568
- }) => {
1569
- const [loading, setLoading] = useState(false);
1570
- const ElementType = href ? "a" : "button";
1571
- const el = /* @__PURE__ */ jsxs2(
1572
- ElementType,
1573
- {
1574
- className: getClassName3({
1575
- active,
1576
- disabled,
1577
- fullWidth
1578
- }),
1579
- onClick: (e) => {
1580
- if (!onClick) return;
1581
- setLoading(true);
1582
- Promise.resolve(onClick(e)).then(() => {
1583
- setLoading(false);
1584
- });
1585
- },
1586
- type,
1587
- disabled: disabled || loading,
1588
- tabIndex,
1589
- target: newTab ? "_blank" : void 0,
1590
- rel: newTab ? "noreferrer" : void 0,
1591
- href,
1592
- title,
1593
- children: [
1594
- /* @__PURE__ */ jsx3("span", { className: getClassName3("title"), children: title }),
1595
- children,
1596
- loading && /* @__PURE__ */ jsxs2(Fragment, { children: [
1597
- "\xA0\xA0",
1598
- /* @__PURE__ */ jsx3(Loader, { size: 14 })
1599
- ] })
1600
- ]
1601
- }
1602
- );
1603
- return el;
1604
- };
1605
-
1606
- // components/RichTextMenu/inner.tsx
1607
- init_react_import();
1608
-
1609
- // css-module:/home/runner/work/puck/puck/packages/core/components/RichTextMenu/styles.module.css#css-module
1610
- init_react_import();
1611
- var styles_module_default4 = { "RichTextMenu": "_RichTextMenu_k97eh_1", "RichTextMenu--form": "_RichTextMenu--form_k97eh_7", "RichTextMenu-group": "_RichTextMenu-group_k97eh_17", "RichTextMenu--inline": "_RichTextMenu--inline_k97eh_35" };
1612
-
1613
- // components/RichTextMenu/inner.tsx
1614
- import { useMemo as useMemo5 } from "react";
1615
-
1616
- // components/RichTextMenu/controls/index.ts
1617
- init_react_import();
1618
-
1619
- // components/RichTextMenu/controls/AlignLeft.tsx
1620
- init_react_import();
1621
-
1622
- // ../../node_modules/lucide-react/dist/esm/lucide-react.js
1623
- init_react_import();
1624
-
1625
- // ../../node_modules/lucide-react/dist/esm/createLucideIcon.js
1626
- init_react_import();
1627
- import { forwardRef as forwardRef2, createElement as createElement2 } from "react";
1628
-
1629
- // ../../node_modules/lucide-react/dist/esm/shared/src/utils.js
1630
- init_react_import();
1631
- var toKebabCase = (string) => string.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
1632
- var mergeClasses = (...classes) => classes.filter((className, index, array) => {
1633
- return Boolean(className) && className.trim() !== "" && array.indexOf(className) === index;
1634
- }).join(" ").trim();
1635
-
1636
- // ../../node_modules/lucide-react/dist/esm/Icon.js
1637
- init_react_import();
1638
- import { forwardRef, createElement } from "react";
1639
-
1640
- // ../../node_modules/lucide-react/dist/esm/defaultAttributes.js
1641
- init_react_import();
1642
- var defaultAttributes = {
1643
- xmlns: "http://www.w3.org/2000/svg",
1644
- width: 24,
1645
- height: 24,
1646
- viewBox: "0 0 24 24",
1647
- fill: "none",
1648
- stroke: "currentColor",
1649
- strokeWidth: 2,
1650
- strokeLinecap: "round",
1651
- strokeLinejoin: "round"
1652
- };
1653
-
1654
- // ../../node_modules/lucide-react/dist/esm/Icon.js
1655
- var Icon = forwardRef(
1656
- (_a, ref) => {
1657
- var _b = _a, {
1658
- color = "currentColor",
1659
- size = 24,
1660
- strokeWidth = 2,
1661
- absoluteStrokeWidth,
1662
- className = "",
1663
- children,
1664
- iconNode
1665
- } = _b, rest = __objRest(_b, [
1666
- "color",
1667
- "size",
1668
- "strokeWidth",
1669
- "absoluteStrokeWidth",
1670
- "className",
1671
- "children",
1672
- "iconNode"
1673
- ]);
1674
- return createElement(
1675
- "svg",
1676
- __spreadValues(__spreadProps(__spreadValues({
1677
- ref
1678
- }, defaultAttributes), {
1679
- width: size,
1680
- height: size,
1681
- stroke: color,
1682
- strokeWidth: absoluteStrokeWidth ? Number(strokeWidth) * 24 / Number(size) : strokeWidth,
1683
- className: mergeClasses("lucide", className)
1684
- }), rest),
1685
- [
1686
- ...iconNode.map(([tag, attrs]) => createElement(tag, attrs)),
1687
- ...Array.isArray(children) ? children : [children]
1688
- ]
1689
- );
1690
- }
1691
- );
1692
-
1693
- // ../../node_modules/lucide-react/dist/esm/createLucideIcon.js
1694
- var createLucideIcon = (iconName, iconNode) => {
1695
- const Component = forwardRef2(
1696
- (_a, ref) => {
1697
- var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
1698
- return createElement2(Icon, __spreadValues({
1699
- ref,
1700
- iconNode,
1701
- className: mergeClasses(`lucide-${toKebabCase(iconName)}`, className)
1702
- }, props));
1703
- }
1704
- );
1705
- Component.displayName = `${iconName}`;
1706
- return Component;
1707
- };
1708
-
1709
- // ../../node_modules/lucide-react/dist/esm/icons/align-center.js
1710
- init_react_import();
1711
- var AlignCenter = createLucideIcon("AlignCenter", [
1712
- ["path", { d: "M17 12H7", key: "16if0g" }],
1713
- ["path", { d: "M19 18H5", key: "18s9l3" }],
1714
- ["path", { d: "M21 6H3", key: "1jwq7v" }]
1715
- ]);
1716
-
1717
- // ../../node_modules/lucide-react/dist/esm/icons/align-justify.js
1718
- init_react_import();
1719
- var AlignJustify = createLucideIcon("AlignJustify", [
1720
- ["path", { d: "M3 12h18", key: "1i2n21" }],
1721
- ["path", { d: "M3 18h18", key: "1h113x" }],
1722
- ["path", { d: "M3 6h18", key: "d0wm0j" }]
1723
- ]);
1724
-
1725
- // ../../node_modules/lucide-react/dist/esm/icons/align-left.js
1726
- init_react_import();
1727
- var AlignLeft = createLucideIcon("AlignLeft", [
1728
- ["path", { d: "M15 12H3", key: "6jk70r" }],
1729
- ["path", { d: "M17 18H3", key: "1amg6g" }],
1730
- ["path", { d: "M21 6H3", key: "1jwq7v" }]
1731
- ]);
1732
-
1733
- // ../../node_modules/lucide-react/dist/esm/icons/align-right.js
1734
- init_react_import();
1735
- var AlignRight = createLucideIcon("AlignRight", [
1736
- ["path", { d: "M21 12H9", key: "dn1m92" }],
1737
- ["path", { d: "M21 18H7", key: "1ygte8" }],
1738
- ["path", { d: "M21 6H3", key: "1jwq7v" }]
1739
- ]);
1740
-
1741
- // ../../node_modules/lucide-react/dist/esm/icons/bold.js
1742
- init_react_import();
1743
- var Bold = createLucideIcon("Bold", [
1744
- [
1745
- "path",
1746
- { d: "M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8", key: "mg9rjx" }
1747
- ]
1748
- ]);
1749
-
1750
- // ../../node_modules/lucide-react/dist/esm/icons/chevron-down.js
1751
- init_react_import();
1752
- var ChevronDown = createLucideIcon("ChevronDown", [
1753
- ["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]
1754
- ]);
1755
-
1756
- // ../../node_modules/lucide-react/dist/esm/icons/chevron-right.js
1757
- init_react_import();
1758
- var ChevronRight = createLucideIcon("ChevronRight", [
1759
- ["path", { d: "m9 18 6-6-6-6", key: "mthhwq" }]
1760
- ]);
1761
-
1762
- // ../../node_modules/lucide-react/dist/esm/icons/chevron-up.js
1763
- init_react_import();
1764
- var ChevronUp = createLucideIcon("ChevronUp", [["path", { d: "m18 15-6-6-6 6", key: "153udz" }]]);
1765
-
1766
- // ../../node_modules/lucide-react/dist/esm/icons/circle-check-big.js
1767
- init_react_import();
1768
- var CircleCheckBig = createLucideIcon("CircleCheckBig", [
1769
- ["path", { d: "M21.801 10A10 10 0 1 1 17 3.335", key: "yps3ct" }],
1770
- ["path", { d: "m9 11 3 3L22 4", key: "1pflzl" }]
1771
- ]);
1772
-
1773
- // ../../node_modules/lucide-react/dist/esm/icons/code.js
1774
- init_react_import();
1775
- var Code = createLucideIcon("Code", [
1776
- ["polyline", { points: "16 18 22 12 16 6", key: "z7tu5w" }],
1777
- ["polyline", { points: "8 6 2 12 8 18", key: "1eg1df" }]
1778
- ]);
1779
-
1780
- // ../../node_modules/lucide-react/dist/esm/icons/copy.js
1781
- init_react_import();
1782
- var Copy = createLucideIcon("Copy", [
1783
- ["rect", { width: "14", height: "14", x: "8", y: "8", rx: "2", ry: "2", key: "17jyea" }],
1784
- ["path", { d: "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2", key: "zix9uf" }]
1785
- ]);
1786
-
1787
- // ../../node_modules/lucide-react/dist/esm/icons/corner-left-up.js
1788
- init_react_import();
1789
- var CornerLeftUp = createLucideIcon("CornerLeftUp", [
1790
- ["polyline", { points: "14 9 9 4 4 9", key: "m9oyvo" }],
1791
- ["path", { d: "M20 20h-7a4 4 0 0 1-4-4V4", key: "1blwi3" }]
1792
- ]);
1793
-
1794
- // ../../node_modules/lucide-react/dist/esm/icons/ellipsis-vertical.js
1795
- init_react_import();
1796
- var EllipsisVertical = createLucideIcon("EllipsisVertical", [
1797
- ["circle", { cx: "12", cy: "12", r: "1", key: "41hilf" }],
1798
- ["circle", { cx: "12", cy: "5", r: "1", key: "gxeob9" }],
1799
- ["circle", { cx: "12", cy: "19", r: "1", key: "lyex9k" }]
1800
- ]);
1801
-
1802
- // ../../node_modules/lucide-react/dist/esm/icons/globe.js
1803
- init_react_import();
1804
- var Globe = createLucideIcon("Globe", [
1805
- ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
1806
- ["path", { d: "M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20", key: "13o1zl" }],
1807
- ["path", { d: "M2 12h20", key: "9i4pu4" }]
1808
- ]);
1809
-
1810
- // ../../node_modules/lucide-react/dist/esm/icons/hash.js
1811
- init_react_import();
1812
- var Hash = createLucideIcon("Hash", [
1813
- ["line", { x1: "4", x2: "20", y1: "9", y2: "9", key: "4lhtct" }],
1814
- ["line", { x1: "4", x2: "20", y1: "15", y2: "15", key: "vyu0kd" }],
1815
- ["line", { x1: "10", x2: "8", y1: "3", y2: "21", key: "1ggp8o" }],
1816
- ["line", { x1: "16", x2: "14", y1: "3", y2: "21", key: "weycgp" }]
1817
- ]);
1818
-
1819
- // ../../node_modules/lucide-react/dist/esm/icons/heading-1.js
1820
- init_react_import();
1821
- var Heading1 = createLucideIcon("Heading1", [
1822
- ["path", { d: "M4 12h8", key: "17cfdx" }],
1823
- ["path", { d: "M4 18V6", key: "1rz3zl" }],
1824
- ["path", { d: "M12 18V6", key: "zqpxq5" }],
1825
- ["path", { d: "m17 12 3-2v8", key: "1hhhft" }]
1826
- ]);
1827
-
1828
- // ../../node_modules/lucide-react/dist/esm/icons/heading-2.js
1829
- init_react_import();
1830
- var Heading2 = createLucideIcon("Heading2", [
1831
- ["path", { d: "M4 12h8", key: "17cfdx" }],
1832
- ["path", { d: "M4 18V6", key: "1rz3zl" }],
1833
- ["path", { d: "M12 18V6", key: "zqpxq5" }],
1834
- ["path", { d: "M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1", key: "9jr5yi" }]
1835
- ]);
1836
-
1837
- // ../../node_modules/lucide-react/dist/esm/icons/heading-3.js
1838
- init_react_import();
1839
- var Heading3 = createLucideIcon("Heading3", [
1840
- ["path", { d: "M4 12h8", key: "17cfdx" }],
1841
- ["path", { d: "M4 18V6", key: "1rz3zl" }],
1842
- ["path", { d: "M12 18V6", key: "zqpxq5" }],
1843
- ["path", { d: "M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2", key: "68ncm8" }],
1844
- ["path", { d: "M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2", key: "1ejuhz" }]
1845
- ]);
1846
-
1847
- // ../../node_modules/lucide-react/dist/esm/icons/heading-4.js
1848
- init_react_import();
1849
- var Heading4 = createLucideIcon("Heading4", [
1850
- ["path", { d: "M12 18V6", key: "zqpxq5" }],
1851
- ["path", { d: "M17 10v3a1 1 0 0 0 1 1h3", key: "tj5zdr" }],
1852
- ["path", { d: "M21 10v8", key: "1kdml4" }],
1853
- ["path", { d: "M4 12h8", key: "17cfdx" }],
1854
- ["path", { d: "M4 18V6", key: "1rz3zl" }]
1855
- ]);
1856
-
1857
- // ../../node_modules/lucide-react/dist/esm/icons/heading-5.js
1858
- init_react_import();
1859
- var Heading5 = createLucideIcon("Heading5", [
1860
- ["path", { d: "M4 12h8", key: "17cfdx" }],
1861
- ["path", { d: "M4 18V6", key: "1rz3zl" }],
1862
- ["path", { d: "M12 18V6", key: "zqpxq5" }],
1863
- ["path", { d: "M17 13v-3h4", key: "1nvgqp" }],
1864
- [
1865
- "path",
1866
- { d: "M17 17.7c.4.2.8.3 1.3.3 1.5 0 2.7-1.1 2.7-2.5S19.8 13 18.3 13H17", key: "2nebdn" }
1867
- ]
1868
- ]);
1869
-
1870
- // ../../node_modules/lucide-react/dist/esm/icons/heading-6.js
1871
- init_react_import();
1872
- var Heading6 = createLucideIcon("Heading6", [
1873
- ["path", { d: "M4 12h8", key: "17cfdx" }],
1874
- ["path", { d: "M4 18V6", key: "1rz3zl" }],
1875
- ["path", { d: "M12 18V6", key: "zqpxq5" }],
1876
- ["circle", { cx: "19", cy: "16", r: "2", key: "15mx69" }],
1877
- ["path", { d: "M20 10c-2 2-3 3.5-3 6", key: "f35dl0" }]
1878
- ]);
1879
-
1880
- // ../../node_modules/lucide-react/dist/esm/icons/heading.js
1881
- init_react_import();
1882
- var Heading = createLucideIcon("Heading", [
1883
- ["path", { d: "M6 12h12", key: "8npq4p" }],
1884
- ["path", { d: "M6 20V4", key: "1w1bmo" }],
1885
- ["path", { d: "M18 20V4", key: "o2hl4u" }]
1886
- ]);
1887
-
1888
- // ../../node_modules/lucide-react/dist/esm/icons/italic.js
1889
- init_react_import();
1890
- var Italic = createLucideIcon("Italic", [
1891
- ["line", { x1: "19", x2: "10", y1: "4", y2: "4", key: "15jd3p" }],
1892
- ["line", { x1: "14", x2: "5", y1: "20", y2: "20", key: "bu0au3" }],
1893
- ["line", { x1: "15", x2: "9", y1: "4", y2: "20", key: "uljnxc" }]
1894
- ]);
1895
-
1896
- // ../../node_modules/lucide-react/dist/esm/icons/layers.js
1897
- init_react_import();
1898
- var Layers = createLucideIcon("Layers", [
1899
- [
1900
- "path",
1901
- {
1902
- d: "M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",
1903
- key: "zw3jo"
1904
- }
1905
- ],
1906
- [
1907
- "path",
1908
- {
1909
- d: "M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",
1910
- key: "1wduqc"
1911
- }
1912
- ],
1913
- [
1914
- "path",
1915
- {
1916
- d: "M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",
1917
- key: "kqbvx6"
1918
- }
1919
- ]
1920
- ]);
1921
-
1922
- // ../../node_modules/lucide-react/dist/esm/icons/layout-grid.js
1923
- init_react_import();
1924
- var LayoutGrid = createLucideIcon("LayoutGrid", [
1925
- ["rect", { width: "7", height: "7", x: "3", y: "3", rx: "1", key: "1g98yp" }],
1926
- ["rect", { width: "7", height: "7", x: "14", y: "3", rx: "1", key: "6d4xhi" }],
1927
- ["rect", { width: "7", height: "7", x: "14", y: "14", rx: "1", key: "nxv5o0" }],
1928
- ["rect", { width: "7", height: "7", x: "3", y: "14", rx: "1", key: "1bb6yr" }]
1929
- ]);
1930
-
1931
- // ../../node_modules/lucide-react/dist/esm/icons/link.js
1932
- init_react_import();
1933
- var Link = createLucideIcon("Link", [
1934
- ["path", { d: "M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71", key: "1cjeqo" }],
1935
- ["path", { d: "M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71", key: "19qd67" }]
1936
- ]);
1937
-
1938
- // ../../node_modules/lucide-react/dist/esm/icons/list-ordered.js
1939
- init_react_import();
1940
- var ListOrdered = createLucideIcon("ListOrdered", [
1941
- ["path", { d: "M10 12h11", key: "6m4ad9" }],
1942
- ["path", { d: "M10 18h11", key: "11hvi2" }],
1943
- ["path", { d: "M10 6h11", key: "c7qv1k" }],
1944
- ["path", { d: "M4 10h2", key: "16xx2s" }],
1945
- ["path", { d: "M4 6h1v4", key: "cnovpq" }],
1946
- ["path", { d: "M6 18H4c0-1 2-2 2-3s-1-1.5-2-1", key: "m9a95d" }]
1947
- ]);
1948
-
1949
- // ../../node_modules/lucide-react/dist/esm/icons/list.js
1950
- init_react_import();
1951
- var List = createLucideIcon("List", [
1952
- ["path", { d: "M3 12h.01", key: "nlz23k" }],
1953
- ["path", { d: "M3 18h.01", key: "1tta3j" }],
1954
- ["path", { d: "M3 6h.01", key: "1rqtza" }],
1955
- ["path", { d: "M8 12h13", key: "1za7za" }],
1956
- ["path", { d: "M8 18h13", key: "1lx6n3" }],
1957
- ["path", { d: "M8 6h13", key: "ik3vkj" }]
1958
- ]);
1959
-
1960
- // ../../node_modules/lucide-react/dist/esm/icons/lock-open.js
1961
- init_react_import();
1962
- var LockOpen = createLucideIcon("LockOpen", [
1963
- ["rect", { width: "18", height: "11", x: "3", y: "11", rx: "2", ry: "2", key: "1w4ew1" }],
1964
- ["path", { d: "M7 11V7a5 5 0 0 1 9.9-1", key: "1mm8w8" }]
1965
- ]);
1966
-
1967
- // ../../node_modules/lucide-react/dist/esm/icons/lock.js
1968
- init_react_import();
1969
- var Lock = createLucideIcon("Lock", [
1970
- ["rect", { width: "18", height: "11", x: "3", y: "11", rx: "2", ry: "2", key: "1w4ew1" }],
1971
- ["path", { d: "M7 11V7a5 5 0 0 1 10 0v4", key: "fwvmzm" }]
1972
- ]);
1973
-
1974
- // ../../node_modules/lucide-react/dist/esm/icons/minus.js
1975
- init_react_import();
1976
- var Minus = createLucideIcon("Minus", [["path", { d: "M5 12h14", key: "1ays0h" }]]);
1977
-
1978
- // ../../node_modules/lucide-react/dist/esm/icons/monitor.js
1979
- init_react_import();
1980
- var Monitor = createLucideIcon("Monitor", [
1981
- ["rect", { width: "20", height: "14", x: "2", y: "3", rx: "2", key: "48i651" }],
1982
- ["line", { x1: "8", x2: "16", y1: "21", y2: "21", key: "1svkeh" }],
1983
- ["line", { x1: "12", x2: "12", y1: "17", y2: "21", key: "vw1qmm" }]
1984
- ]);
1985
-
1986
- // ../../node_modules/lucide-react/dist/esm/icons/panel-left.js
1987
- init_react_import();
1988
- var PanelLeft = createLucideIcon("PanelLeft", [
1989
- ["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", key: "afitv7" }],
1990
- ["path", { d: "M9 3v18", key: "fh3hqa" }]
1991
- ]);
1992
-
1993
- // ../../node_modules/lucide-react/dist/esm/icons/panel-right.js
1994
- init_react_import();
1995
- var PanelRight = createLucideIcon("PanelRight", [
1996
- ["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", key: "afitv7" }],
1997
- ["path", { d: "M15 3v18", key: "14nvp0" }]
1998
- ]);
1999
-
2000
- // ../../node_modules/lucide-react/dist/esm/icons/plus.js
2001
- init_react_import();
2002
- var Plus = createLucideIcon("Plus", [
2003
- ["path", { d: "M5 12h14", key: "1ays0h" }],
2004
- ["path", { d: "M12 5v14", key: "s699le" }]
2005
- ]);
2006
-
2007
- // ../../node_modules/lucide-react/dist/esm/icons/quote.js
2008
- init_react_import();
2009
- var Quote = createLucideIcon("Quote", [
2010
- [
2011
- "path",
2012
- {
2013
- d: "M16 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",
2014
- key: "rib7q0"
2015
- }
2016
- ],
2017
- [
2018
- "path",
2019
- {
2020
- d: "M5 3a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2 1 1 0 0 1 1 1v1a2 2 0 0 1-2 2 1 1 0 0 0-1 1v2a1 1 0 0 0 1 1 6 6 0 0 0 6-6V5a2 2 0 0 0-2-2z",
2021
- key: "1ymkrd"
2022
- }
2023
- ]
2024
- ]);
2025
-
2026
- // ../../node_modules/lucide-react/dist/esm/icons/redo-2.js
2027
- init_react_import();
2028
- var Redo2 = createLucideIcon("Redo2", [
2029
- ["path", { d: "m15 14 5-5-5-5", key: "12vg1m" }],
2030
- ["path", { d: "M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13", key: "6uklza" }]
2031
- ]);
2032
-
2033
- // ../../node_modules/lucide-react/dist/esm/icons/search.js
2034
- init_react_import();
2035
- var Search = createLucideIcon("Search", [
2036
- ["circle", { cx: "11", cy: "11", r: "8", key: "4ej97u" }],
2037
- ["path", { d: "m21 21-4.3-4.3", key: "1qie3q" }]
2038
- ]);
2039
-
2040
- // ../../node_modules/lucide-react/dist/esm/icons/sliders-horizontal.js
2041
- init_react_import();
2042
- var SlidersHorizontal = createLucideIcon("SlidersHorizontal", [
2043
- ["line", { x1: "21", x2: "14", y1: "4", y2: "4", key: "obuewd" }],
2044
- ["line", { x1: "10", x2: "3", y1: "4", y2: "4", key: "1q6298" }],
2045
- ["line", { x1: "21", x2: "12", y1: "12", y2: "12", key: "1iu8h1" }],
2046
- ["line", { x1: "8", x2: "3", y1: "12", y2: "12", key: "ntss68" }],
2047
- ["line", { x1: "21", x2: "16", y1: "20", y2: "20", key: "14d8ph" }],
2048
- ["line", { x1: "12", x2: "3", y1: "20", y2: "20", key: "m0wm8r" }],
2049
- ["line", { x1: "14", x2: "14", y1: "2", y2: "6", key: "14e1ph" }],
2050
- ["line", { x1: "8", x2: "8", y1: "10", y2: "14", key: "1i6ji0" }],
2051
- ["line", { x1: "16", x2: "16", y1: "18", y2: "22", key: "1lctlv" }]
2052
- ]);
2053
-
2054
- // ../../node_modules/lucide-react/dist/esm/icons/smartphone.js
2055
- init_react_import();
2056
- var Smartphone = createLucideIcon("Smartphone", [
2057
- ["rect", { width: "14", height: "20", x: "5", y: "2", rx: "2", ry: "2", key: "1yt0o3" }],
2058
- ["path", { d: "M12 18h.01", key: "mhygvu" }]
2059
- ]);
2060
-
2061
- // ../../node_modules/lucide-react/dist/esm/icons/square-code.js
2062
- init_react_import();
2063
- var SquareCode = createLucideIcon("SquareCode", [
2064
- ["path", { d: "M10 9.5 8 12l2 2.5", key: "3mjy60" }],
2065
- ["path", { d: "m14 9.5 2 2.5-2 2.5", key: "1bir2l" }],
2066
- ["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", key: "afitv7" }]
2067
- ]);
2068
-
2069
- // ../../node_modules/lucide-react/dist/esm/icons/strikethrough.js
2070
- init_react_import();
2071
- var Strikethrough = createLucideIcon("Strikethrough", [
2072
- ["path", { d: "M16 4H9a3 3 0 0 0-2.83 4", key: "43sutm" }],
2073
- ["path", { d: "M14 12a4 4 0 0 1 0 8H6", key: "nlfj13" }],
2074
- ["line", { x1: "4", x2: "20", y1: "12", y2: "12", key: "1e0a9i" }]
2075
- ]);
2076
-
2077
- // ../../node_modules/lucide-react/dist/esm/icons/tablet.js
2078
- init_react_import();
2079
- var Tablet = createLucideIcon("Tablet", [
2080
- ["rect", { width: "16", height: "20", x: "4", y: "2", rx: "2", ry: "2", key: "76otgf" }],
2081
- ["line", { x1: "12", x2: "12.01", y1: "18", y2: "18", key: "1dp563" }]
2082
- ]);
2083
-
2084
- // ../../node_modules/lucide-react/dist/esm/icons/trash.js
2085
- init_react_import();
2086
- var Trash = createLucideIcon("Trash", [
2087
- ["path", { d: "M3 6h18", key: "d0wm0j" }],
2088
- ["path", { d: "M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6", key: "4alrt4" }],
2089
- ["path", { d: "M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2", key: "v07s0e" }]
2090
- ]);
2091
-
2092
- // ../../node_modules/lucide-react/dist/esm/icons/type.js
2093
- init_react_import();
2094
- var Type = createLucideIcon("Type", [
2095
- ["polyline", { points: "4 7 4 4 20 4 20 7", key: "1nosan" }],
2096
- ["line", { x1: "9", x2: "15", y1: "20", y2: "20", key: "swin9y" }],
2097
- ["line", { x1: "12", x2: "12", y1: "4", y2: "20", key: "1tx1rr" }]
2098
- ]);
2099
-
2100
- // ../../node_modules/lucide-react/dist/esm/icons/underline.js
2101
- init_react_import();
2102
- var Underline = createLucideIcon("Underline", [
2103
- ["path", { d: "M6 4v6a6 6 0 0 0 12 0V4", key: "9kb039" }],
2104
- ["line", { x1: "4", x2: "20", y1: "20", y2: "20", key: "nun2al" }]
2105
- ]);
2106
-
2107
- // ../../node_modules/lucide-react/dist/esm/icons/undo-2.js
2108
- init_react_import();
2109
- var Undo2 = createLucideIcon("Undo2", [
2110
- ["path", { d: "M9 14 4 9l5-5", key: "102s5s" }],
2111
- ["path", { d: "M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11", key: "f3b9sd" }]
2112
- ]);
2113
-
2114
- // ../../node_modules/lucide-react/dist/esm/icons/zoom-in.js
2115
- init_react_import();
2116
- var ZoomIn = createLucideIcon("ZoomIn", [
2117
- ["circle", { cx: "11", cy: "11", r: "8", key: "4ej97u" }],
2118
- ["line", { x1: "21", x2: "16.65", y1: "21", y2: "16.65", key: "13gj7c" }],
2119
- ["line", { x1: "11", x2: "11", y1: "8", y2: "14", key: "1vmskp" }],
2120
- ["line", { x1: "8", x2: "14", y1: "11", y2: "11", key: "durymu" }]
2121
- ]);
2122
-
2123
- // ../../node_modules/lucide-react/dist/esm/icons/zoom-out.js
2124
- init_react_import();
2125
- var ZoomOut = createLucideIcon("ZoomOut", [
2126
- ["circle", { cx: "11", cy: "11", r: "8", key: "4ej97u" }],
2127
- ["line", { x1: "21", x2: "16.65", y1: "21", y2: "16.65", key: "13gj7c" }],
2128
- ["line", { x1: "8", x2: "14", y1: "11", y2: "11", key: "durymu" }]
2129
- ]);
2130
-
2131
- // components/RichTextMenu/components/Control/index.tsx
2132
- init_react_import();
2133
-
2134
- // components/IconButton/index.ts
2135
- init_react_import();
2136
-
2137
- // css-module:/home/runner/work/puck/puck/packages/core/components/RichTextMenu/components/Control/styles.module.css#css-module
2138
- init_react_import();
2139
- var styles_module_default5 = { "Control": "_Control_1aveu_1", "Control--inline": "_Control--inline_1aveu_6" };
2140
-
2141
- // components/RichTextMenu/lib/use-control-context.ts
2142
- init_react_import();
2143
- import { createContext as createContext2, useContext as useContext2 } from "react";
2144
- var ControlContext = createContext2({});
2145
- var useControlContext = () => {
2146
- return useContext2(ControlContext);
2147
- };
2148
-
2149
- // components/RichTextMenu/components/Control/index.tsx
2150
- import { jsx as jsx4 } from "react/jsx-runtime";
2151
- var getClassName4 = get_class_name_factory_default("Control", styles_module_default5);
2152
- function Control({
2153
- icon,
2154
- disabled,
2155
- active,
2156
- onClick,
2157
- title
2158
- }) {
2159
- const { inline } = useControlContext();
2160
- if (inline) {
2161
- return /* @__PURE__ */ jsx4("span", { className: getClassName4({ inline: true }), children: /* @__PURE__ */ jsx4(
2162
- Action,
2163
- {
2164
- onClick,
2165
- disabled,
2166
- active,
2167
- label: title,
2168
- children: icon
2169
- }
2170
- ) });
2171
- }
2172
- return /* @__PURE__ */ jsx4("span", { className: getClassName4(), children: /* @__PURE__ */ jsx4(
2173
- IconButton,
2174
- {
2175
- onClick,
2176
- disabled,
2177
- active,
2178
- title,
2179
- children: icon
2180
- }
2181
- ) });
2182
- }
2183
-
2184
- // components/RichTextMenu/controls/AlignLeft.tsx
2185
- import { jsx as jsx5 } from "react/jsx-runtime";
2186
- function AlignLeft2() {
2187
- const { editor, editorState } = useControlContext();
2188
- return /* @__PURE__ */ jsx5(
2189
- Control,
2190
- {
2191
- icon: /* @__PURE__ */ jsx5(AlignLeft, {}),
2192
- onClick: (e) => {
2193
- e.stopPropagation();
2194
- editor == null ? void 0 : editor.chain().focus().setTextAlign("left").run();
2195
- },
2196
- disabled: !(editorState == null ? void 0 : editorState.canAlignLeft),
2197
- active: editorState == null ? void 0 : editorState.isAlignLeft,
2198
- title: "Align left"
2199
- }
2200
- );
2201
- }
2202
-
2203
- // components/RichTextMenu/controls/AlignCenter.tsx
2204
- init_react_import();
2205
- import { jsx as jsx6 } from "react/jsx-runtime";
2206
- function AlignCenter2() {
2207
- const { editor, editorState } = useControlContext();
2208
- return /* @__PURE__ */ jsx6(
2209
- Control,
2210
- {
2211
- icon: /* @__PURE__ */ jsx6(AlignCenter, {}),
2212
- onClick: (e) => {
2213
- e.stopPropagation();
2214
- editor == null ? void 0 : editor.chain().focus().setTextAlign("center").run();
2215
- },
2216
- disabled: !(editorState == null ? void 0 : editorState.canAlignCenter),
2217
- active: editorState == null ? void 0 : editorState.isAlignCenter,
2218
- title: "Align center"
2219
- }
2220
- );
2221
- }
2222
-
2223
- // components/RichTextMenu/controls/AlignRight.tsx
2224
- init_react_import();
2225
- import { jsx as jsx7 } from "react/jsx-runtime";
2226
- function AlignRight2() {
2227
- const { editor, editorState } = useControlContext();
2228
- return /* @__PURE__ */ jsx7(
2229
- Control,
2230
- {
2231
- icon: /* @__PURE__ */ jsx7(AlignRight, {}),
2232
- onClick: (e) => {
2233
- e.stopPropagation();
2234
- editor == null ? void 0 : editor.chain().focus().setTextAlign("right").run();
2235
- },
2236
- disabled: !(editorState == null ? void 0 : editorState.canAlignRight),
2237
- active: editorState == null ? void 0 : editorState.isAlignRight,
2238
- title: "Align right"
2239
- }
2240
- );
2241
- }
2242
-
2243
- // components/RichTextMenu/controls/AlignJustify.tsx
2244
- init_react_import();
2245
- import { jsx as jsx8 } from "react/jsx-runtime";
2246
- function AlignJustify2() {
2247
- const { editor, editorState } = useControlContext();
2248
- return /* @__PURE__ */ jsx8(
2249
- Control,
2250
- {
2251
- icon: /* @__PURE__ */ jsx8(AlignJustify, {}),
2252
- onClick: (e) => {
2253
- e.stopPropagation();
2254
- editor == null ? void 0 : editor.chain().focus().setTextAlign("justify").run();
2255
- },
2256
- disabled: !(editorState == null ? void 0 : editorState.canAlignJustify),
2257
- active: editorState == null ? void 0 : editorState.isAlignJustify,
2258
- title: "Justify"
2259
- }
2260
- );
2261
- }
2262
-
2263
- // components/RichTextMenu/controls/AlignSelect.tsx
2264
- init_react_import();
2265
- import { useEditorState } from "@tiptap/react";
2266
- import { useMemo as useMemo2 } from "react";
2267
-
2268
- // components/RichTextMenu/components/SelectControl/index.tsx
2269
- init_react_import();
2270
- import { useMemo } from "react";
2271
-
2272
- // components/Select/index.tsx
2273
- init_react_import();
2274
-
2275
- // css-module:/home/runner/work/puck/puck/packages/core/components/Select/styles.module.css#css-module
2276
- init_react_import();
2277
- var styles_module_default6 = { "Select": "_Select_xjbef_1", "Select-button": "_Select-button_xjbef_6", "Select--hasOptions": "_Select--hasOptions_xjbef_19", "Select--disabled": "_Select--disabled_xjbef_23", "Select-buttonIcon": "_Select-buttonIcon_xjbef_27", "Select--standalone": "_Select--standalone_xjbef_33", "Select--actionBar": "_Select--actionBar_xjbef_38", "Select--hasValue": "_Select--hasValue_xjbef_44", "Select-items": "_Select-items_xjbef_61", "SelectItem": "_SelectItem_xjbef_72", "SelectItem--isSelected": "_SelectItem--isSelected_xjbef_87", "SelectItem-icon": "_SelectItem-icon_xjbef_93" };
2278
-
2279
- // components/Select/index.tsx
2280
- import { useState as useState2 } from "react";
2281
- import {
2282
- Popover,
2283
- PopoverContent,
2284
- PopoverPortal,
2285
- PopoverTrigger
2286
- } from "@radix-ui/react-popover";
2287
- import { jsx as jsx9, jsxs as jsxs3 } from "react/jsx-runtime";
2288
- var getClassName5 = get_class_name_factory_default("Select", styles_module_default6);
2289
- var getItemClassName = get_class_name_factory_default("SelectItem", styles_module_default6);
2290
- var Item = ({
2291
- children,
2292
- isSelected,
2293
- onClick
2294
- }) => {
2295
- return /* @__PURE__ */ jsx9("button", { className: getItemClassName({ isSelected }), onClick, children });
2296
- };
2297
- var Select = ({
2298
- children,
2299
- options,
2300
- onChange,
2301
- value,
2302
- defaultValue,
2303
- mode,
2304
- disabled = false
2305
- }) => {
2306
- const [open, setOpen] = useState2(false);
2307
- const hasOptions = options.length > 0;
2308
- return /* @__PURE__ */ jsx9(
2309
- "div",
2310
- {
2311
- className: getClassName5({
2312
- hasValue: value !== defaultValue,
2313
- hasOptions,
2314
- actionBar: mode === "actionBar",
2315
- standalone: mode === "standalone",
2316
- disabled
2317
- }),
2318
- children: /* @__PURE__ */ jsxs3(Popover, { open, onOpenChange: setOpen, children: [
2319
- hasOptions ? /* @__PURE__ */ jsx9(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs3("button", { className: getClassName5("button"), children: [
2320
- /* @__PURE__ */ jsx9("span", { className: getClassName5("buttonIcon"), children }),
2321
- /* @__PURE__ */ jsx9(ChevronDown, { size: 12 })
2322
- ] }) }) : /* @__PURE__ */ jsx9("div", { children: /* @__PURE__ */ jsxs3("div", { className: getClassName5("button"), children: [
2323
- /* @__PURE__ */ jsx9("span", { className: getClassName5("buttonIcon"), children }),
2324
- /* @__PURE__ */ jsx9(ChevronDown, { size: 12 })
2325
- ] }) }),
2326
- options.length > 0 && /* @__PURE__ */ jsx9(PopoverPortal, { children: /* @__PURE__ */ jsx9(PopoverContent, { align: "start", children: /* @__PURE__ */ jsx9("ul", { className: getClassName5("items"), "data-puck-rte-menu": true, children: options.map((option) => {
2327
- const Icon2 = option.icon;
2328
- return /* @__PURE__ */ jsx9("li", { children: /* @__PURE__ */ jsxs3(
2329
- Item,
2330
- {
2331
- isSelected: value === option.value,
2332
- onClick: () => {
2333
- onChange(option.value);
2334
- setOpen(false);
2335
- },
2336
- children: [
2337
- Icon2 && /* @__PURE__ */ jsx9("div", { className: getItemClassName("icon"), children: /* @__PURE__ */ jsx9(Icon2, { size: 16 }) }),
2338
- option.label
2339
- ]
2340
- }
2341
- ) }, option.value);
2342
- }) }) }) })
2343
- ] })
2344
- }
2345
- );
2346
- };
2347
-
2348
- // components/RichTextMenu/components/SelectControl/index.tsx
2349
- import { jsx as jsx10 } from "react/jsx-runtime";
2350
- function SelectControl({
2351
- renderDefaultIcon,
2352
- onChange,
2353
- options,
2354
- value,
2355
- defaultValue
2356
- }) {
2357
- var _a, _b;
2358
- const { inline, readOnly } = useControlContext();
2359
- const optionsByValue = useMemo(
2360
- () => options.reduce(
2361
- (acc, option) => __spreadProps(__spreadValues({}, acc), { [option.value]: option }),
2362
- {}
2363
- ),
2364
- [options]
2365
- );
2366
- const Node = (_b = value && ((_a = optionsByValue[value]) == null ? void 0 : _a.icon)) != null ? _b : renderDefaultIcon;
2367
- return /* @__PURE__ */ jsx10(
2368
- Select,
2369
- {
2370
- options,
2371
- onChange,
2372
- value,
2373
- defaultValue,
2374
- mode: inline ? "actionBar" : "standalone",
2375
- disabled: readOnly,
2376
- children: /* @__PURE__ */ jsx10(Node, {})
2377
- }
2378
- );
2379
- }
2380
-
2381
- // components/RichTextMenu/controls/AlignSelect.tsx
2382
- import { jsx as jsx11 } from "react/jsx-runtime";
2383
- var optionNodes = {
2384
- left: { label: "Left", icon: AlignLeft },
2385
- center: { label: "Center", icon: AlignCenter },
2386
- right: { label: "Right", icon: AlignRight },
2387
- justify: { label: "Justify", icon: AlignJustify }
2388
- };
2389
- function AlignSelect() {
2390
- var _a, _b;
2391
- const { options } = useControlContext();
2392
- let blockOptions = [];
2393
- if ((options == null ? void 0 : options.textAlign) !== false) {
2394
- if (!((_a = options == null ? void 0 : options.textAlign) == null ? void 0 : _a.alignments)) {
2395
- blockOptions = ["left", "center", "right", "justify"];
2396
- } else {
2397
- if (options == null ? void 0 : options.textAlign.alignments.includes("left")) {
2398
- blockOptions.push("left");
2399
- }
2400
- if (options == null ? void 0 : options.textAlign.alignments.includes("center")) {
2401
- blockOptions.push("center");
2402
- }
2403
- if (options == null ? void 0 : options.textAlign.alignments.includes("right")) {
2404
- blockOptions.push("right");
2405
- }
2406
- if (options == null ? void 0 : options.textAlign.alignments.includes("justify")) {
2407
- blockOptions.push("justify");
2408
- }
2409
- }
2410
- }
2411
- const { editor } = useControlContext();
2412
- const currentValue = (_b = useEditorState({
2413
- editor,
2414
- selector: (ctx) => {
2415
- var _a2, _b2, _c, _d;
2416
- if ((_a2 = ctx.editor) == null ? void 0 : _a2.isActive({ textAlign: "center" })) {
2417
- return "center";
2418
- } else if ((_b2 = ctx.editor) == null ? void 0 : _b2.isActive({ textAlign: "right" })) {
2419
- return "right";
2420
- } else if ((_c = ctx.editor) == null ? void 0 : _c.isActive({ textAlign: "justify" })) {
2421
- return "justify";
2422
- }
2423
- return (options == null ? void 0 : options.textAlign) ? (_d = options.textAlign.defaultAlignment) != null ? _d : "left" : "left";
2424
- }
2425
- })) != null ? _b : "left";
2426
- const handleChange = (val) => {
2427
- const chain = editor == null ? void 0 : editor.chain();
2428
- chain == null ? void 0 : chain.focus().setTextAlign(val).run();
2429
- };
2430
- const loadedOptions = useMemo2(
2431
- () => blockOptions.map((item) => ({
2432
- value: item,
2433
- label: optionNodes[item].label,
2434
- icon: optionNodes[item].icon
2435
- })),
2436
- [blockOptions]
2437
- );
2438
- return /* @__PURE__ */ jsx11(
2439
- SelectControl,
2440
- {
2441
- options: loadedOptions,
2442
- onChange: handleChange,
2443
- value: currentValue,
2444
- defaultValue: "left",
2445
- renderDefaultIcon: AlignLeft
2446
- }
2447
- );
2448
- }
2449
-
2450
- // components/RichTextMenu/controls/Bold.tsx
2451
- init_react_import();
2452
- import { jsx as jsx12 } from "react/jsx-runtime";
2453
- function Bold2() {
2454
- const { editor, editorState } = useControlContext();
2455
- return /* @__PURE__ */ jsx12(
2456
- Control,
2457
- {
2458
- icon: /* @__PURE__ */ jsx12(Bold, {}),
2459
- onClick: (e) => {
2460
- e.stopPropagation();
2461
- editor == null ? void 0 : editor.chain().focus().toggleBold().run();
2462
- },
2463
- disabled: !(editorState == null ? void 0 : editorState.canBold),
2464
- active: editorState == null ? void 0 : editorState.isBold,
2465
- title: "Bold"
2466
- }
2467
- );
2468
- }
2469
-
2470
- // components/RichTextMenu/controls/Italic.tsx
2471
- init_react_import();
2472
- import { jsx as jsx13 } from "react/jsx-runtime";
2473
- function Italic2() {
2474
- const { editor, editorState } = useControlContext();
2475
- return /* @__PURE__ */ jsx13(
2476
- Control,
2477
- {
2478
- icon: /* @__PURE__ */ jsx13(Italic, {}),
2479
- onClick: (e) => {
2480
- e.stopPropagation();
2481
- editor == null ? void 0 : editor.chain().focus().toggleItalic().run();
2482
- },
2483
- disabled: !(editorState == null ? void 0 : editorState.canItalic),
2484
- active: editorState == null ? void 0 : editorState.isItalic,
2485
- title: "Italic"
2486
- }
2487
- );
2488
- }
2489
-
2490
- // components/RichTextMenu/controls/Underline.tsx
2491
- init_react_import();
2492
- import { jsx as jsx14 } from "react/jsx-runtime";
2493
- function Underline2() {
2494
- const { editor, editorState } = useControlContext();
2495
- return /* @__PURE__ */ jsx14(
2496
- Control,
2497
- {
2498
- icon: /* @__PURE__ */ jsx14(Underline, {}),
2499
- onClick: (e) => {
2500
- e.stopPropagation();
2501
- editor == null ? void 0 : editor.chain().focus().toggleUnderline().run();
2502
- },
2503
- disabled: !(editorState == null ? void 0 : editorState.canUnderline),
2504
- active: editorState == null ? void 0 : editorState.isUnderline,
2505
- title: "Underline"
2506
- }
2507
- );
2508
- }
2509
-
2510
- // components/RichTextMenu/controls/Strikethrough.tsx
2511
- init_react_import();
2512
- import { jsx as jsx15 } from "react/jsx-runtime";
2513
- function Strikethrough2() {
2514
- const { editor, editorState } = useControlContext();
2515
- return /* @__PURE__ */ jsx15(
2516
- Control,
2517
- {
2518
- icon: /* @__PURE__ */ jsx15(Strikethrough, {}),
2519
- onClick: (e) => {
2520
- e.stopPropagation();
2521
- editor == null ? void 0 : editor.chain().focus().toggleStrike().run();
2522
- },
2523
- disabled: !(editorState == null ? void 0 : editorState.canStrike),
2524
- active: editorState == null ? void 0 : editorState.isStrike,
2525
- title: "Strikethrough"
2526
- }
2527
- );
2528
- }
2529
-
2530
- // components/RichTextMenu/controls/InlineCode.tsx
2531
- init_react_import();
2532
- import { jsx as jsx16 } from "react/jsx-runtime";
2533
- function InlineCode() {
2534
- const { editor, editorState } = useControlContext();
2535
- return /* @__PURE__ */ jsx16(
2536
- Control,
2537
- {
2538
- icon: /* @__PURE__ */ jsx16(Code, {}),
2539
- onClick: (e) => {
2540
- e.stopPropagation();
2541
- editor == null ? void 0 : editor.chain().focus().toggleCode().run();
2542
- },
2543
- disabled: !(editorState == null ? void 0 : editorState.canInlineCode),
2544
- active: editorState == null ? void 0 : editorState.isInlineCode,
2545
- title: "Inline code"
2546
- }
2547
- );
2548
- }
2549
-
2550
- // components/RichTextMenu/controls/BulletList.tsx
2551
- init_react_import();
2552
- import { jsx as jsx17 } from "react/jsx-runtime";
2553
- function BulletList() {
2554
- const { editor, editorState } = useControlContext();
2555
- return /* @__PURE__ */ jsx17(
2556
- Control,
2557
- {
2558
- icon: /* @__PURE__ */ jsx17(List, {}),
2559
- onClick: (e) => {
2560
- e.stopPropagation();
2561
- editor == null ? void 0 : editor.chain().focus().toggleBulletList().run();
2562
- },
2563
- disabled: !(editorState == null ? void 0 : editorState.canBulletList),
2564
- active: editorState == null ? void 0 : editorState.isBulletList,
2565
- title: "Bullet list"
2566
- }
2567
- );
2568
- }
2569
-
2570
- // components/RichTextMenu/controls/OrderedList.tsx
2571
- init_react_import();
2572
- import { jsx as jsx18 } from "react/jsx-runtime";
2573
- function OrderedList() {
2574
- const { editor, editorState } = useControlContext();
2575
- return /* @__PURE__ */ jsx18(
2576
- Control,
2577
- {
2578
- icon: /* @__PURE__ */ jsx18(ListOrdered, {}),
2579
- onClick: (e) => {
2580
- e.stopPropagation();
2581
- editor == null ? void 0 : editor.chain().focus().toggleOrderedList().run();
2582
- },
2583
- disabled: !(editorState == null ? void 0 : editorState.canOrderedList),
2584
- active: editorState == null ? void 0 : editorState.isOrderedList,
2585
- title: "Ordered list"
2586
- }
2587
- );
2588
- }
2589
-
2590
- // components/RichTextMenu/controls/CodeBlock.tsx
2591
- init_react_import();
2592
- import { jsx as jsx19 } from "react/jsx-runtime";
2593
- function CodeBlock() {
2594
- const { editor, editorState } = useControlContext();
2595
- return /* @__PURE__ */ jsx19(
2596
- Control,
2597
- {
2598
- icon: /* @__PURE__ */ jsx19(SquareCode, {}),
2599
- onClick: (e) => {
2600
- e.stopPropagation();
2601
- editor == null ? void 0 : editor.chain().focus().toggleCodeBlock().run();
2602
- },
2603
- disabled: !(editorState == null ? void 0 : editorState.canCodeBlock),
2604
- active: editorState == null ? void 0 : editorState.isCodeBlock,
2605
- title: "Code block"
2606
- }
2607
- );
2608
- }
2609
-
2610
- // components/RichTextMenu/controls/Blockquote.tsx
2611
- init_react_import();
2612
- import { jsx as jsx20 } from "react/jsx-runtime";
2613
- function Blockquote() {
2614
- const { editor, editorState } = useControlContext();
2615
- return /* @__PURE__ */ jsx20(
2616
- Control,
2617
- {
2618
- icon: /* @__PURE__ */ jsx20(Quote, {}),
2619
- onClick: (e) => {
2620
- e.stopPropagation();
2621
- editor == null ? void 0 : editor.chain().focus().toggleBlockquote().run();
2622
- },
2623
- disabled: !(editorState == null ? void 0 : editorState.canBlockquote),
2624
- active: editorState == null ? void 0 : editorState.isBlockquote,
2625
- title: "Blockquote"
2626
- }
2627
- );
2628
- }
2629
-
2630
- // components/RichTextMenu/controls/HorizontalRule.tsx
2631
- init_react_import();
2632
- import { jsx as jsx21 } from "react/jsx-runtime";
2633
- function HorizontalRule() {
2634
- const { editor, editorState } = useControlContext();
2635
- return /* @__PURE__ */ jsx21(
2636
- Control,
2637
- {
2638
- icon: /* @__PURE__ */ jsx21(Minus, {}),
2639
- onClick: (e) => {
2640
- e.stopPropagation();
2641
- editor == null ? void 0 : editor.chain().focus().setHorizontalRule().run();
2642
- },
2643
- disabled: !(editorState == null ? void 0 : editorState.canHorizontalRule),
2644
- title: "Horizontal rule"
2645
- }
2646
- );
2647
- }
2648
-
2649
- // components/RichTextMenu/controls/HeadingSelect.tsx
2650
- init_react_import();
2651
- import { useEditorState as useEditorState2 } from "@tiptap/react";
2652
- import { useMemo as useMemo3 } from "react";
2653
- import { jsx as jsx22 } from "react/jsx-runtime";
2654
- var optionNodes2 = {
2655
- h1: { label: "Heading 1", icon: Heading1 },
2656
- h2: { label: "Heading 2", icon: Heading2 },
2657
- h3: { label: "Heading 3", icon: Heading3 },
2658
- h4: { label: "Heading 4", icon: Heading4 },
2659
- h5: { label: "Heading 5", icon: Heading5 },
2660
- h6: { label: "Heading 6", icon: Heading6 }
2661
- };
2662
- function HeadingSelect() {
2663
- var _a;
2664
- const { options } = useControlContext();
2665
- let blockOptions = [];
2666
- if ((options == null ? void 0 : options.heading) !== false) {
2667
- if (!((_a = options == null ? void 0 : options.heading) == null ? void 0 : _a.levels)) {
2668
- blockOptions = ["h1", "h2", "h3", "h4", "h5", "h6"];
2669
- } else {
2670
- if (options == null ? void 0 : options.heading.levels.includes(1)) {
2671
- blockOptions.push("h1");
2672
- }
2673
- if (options == null ? void 0 : options.heading.levels.includes(2)) {
2674
- blockOptions.push("h2");
2675
- }
2676
- if (options == null ? void 0 : options.heading.levels.includes(3)) {
2677
- blockOptions.push("h3");
2678
- }
2679
- if (options == null ? void 0 : options.heading.levels.includes(4)) {
2680
- blockOptions.push("h4");
2681
- }
2682
- if (options == null ? void 0 : options.heading.levels.includes(5)) {
2683
- blockOptions.push("h5");
2684
- }
2685
- if (options == null ? void 0 : options.heading.levels.includes(6)) {
2686
- blockOptions.push("h6");
2687
- }
2688
- }
2689
- }
2690
- const { editor } = useControlContext();
2691
- const currentValue = useEditorState2({
2692
- editor,
2693
- selector: (ctx) => {
2694
- var _a2, _b;
2695
- if ((_a2 = ctx.editor) == null ? void 0 : _a2.isActive("paragraph")) return "p";
2696
- for (let level = 1; level <= 6; level++) {
2697
- if ((_b = ctx.editor) == null ? void 0 : _b.isActive("heading", { level })) {
2698
- return `h${level}`;
2699
- }
2700
- }
2701
- return "p";
2702
- }
2703
- });
2704
- const handleChange = (val) => {
2705
- const chain = editor == null ? void 0 : editor.chain();
2706
- if (val === "p") {
2707
- chain == null ? void 0 : chain.focus().setParagraph().run();
2708
- } else {
2709
- const level = parseInt(val.replace("h", ""), 10);
2710
- chain == null ? void 0 : chain.focus().toggleHeading({ level }).run();
2711
- }
2712
- };
2713
- const loadedOptions = useMemo3(
2714
- () => blockOptions.map((item) => ({
2715
- value: item,
2716
- label: optionNodes2[item].label,
2717
- icon: optionNodes2[item].icon
2718
- })),
2719
- [blockOptions]
2720
- );
2721
- return /* @__PURE__ */ jsx22(
2722
- SelectControl,
2723
- {
2724
- options: loadedOptions,
2725
- onChange: handleChange,
2726
- value: currentValue != null ? currentValue : "p",
2727
- defaultValue: "p",
2728
- renderDefaultIcon: Heading
2729
- }
2730
- );
2731
- }
2732
-
2733
- // components/RichTextMenu/controls/ListSelect.tsx
2734
- init_react_import();
2735
- import { useEditorState as useEditorState3 } from "@tiptap/react";
2736
- import { useMemo as useMemo4 } from "react";
2737
- import { jsx as jsx23 } from "react/jsx-runtime";
2738
- var optionNodes3 = {
2739
- ul: { label: "Bullet list", icon: List },
2740
- ol: { label: "Numbered list", icon: ListOrdered }
2741
- };
2742
- function ListSelect() {
2743
- const { options } = useControlContext();
2744
- let blockOptions = [];
2745
- if ((options == null ? void 0 : options.listItem) !== false) {
2746
- blockOptions = ["ul", "ol"];
2747
- }
2748
- const { editor } = useControlContext();
2749
- const currentValue = useEditorState3({
2750
- editor,
2751
- selector: (ctx) => {
2752
- var _a, _b;
2753
- if ((_a = ctx.editor) == null ? void 0 : _a.isActive("bulletList")) return "ul";
2754
- if ((_b = ctx.editor) == null ? void 0 : _b.isActive("orderedList")) return "ol";
2755
- return "p";
2756
- }
2757
- });
2758
- const handleChange = (val) => {
2759
- const chain = editor == null ? void 0 : editor.chain();
2760
- if (val === "p") {
2761
- chain == null ? void 0 : chain.focus().setParagraph().run();
2762
- } else if (val === "ol") {
2763
- chain == null ? void 0 : chain.focus().toggleOrderedList().run();
2764
- } else if (val === "ul") {
2765
- chain == null ? void 0 : chain.focus().toggleBulletList().run();
2766
- }
2767
- };
2768
- const loadedOptions = useMemo4(
2769
- () => blockOptions.map((item) => ({
2770
- value: item,
2771
- label: optionNodes3[item].label,
2772
- icon: optionNodes3[item].icon
2773
- })),
2774
- [blockOptions]
2775
- );
2776
- return /* @__PURE__ */ jsx23(
2777
- SelectControl,
2778
- {
2779
- options: loadedOptions,
2780
- onChange: handleChange,
2781
- value: currentValue != null ? currentValue : "p",
2782
- defaultValue: "p",
2783
- renderDefaultIcon: List
2784
- }
2785
- );
2786
- }
2787
-
2788
- // components/RichTextMenu/inner.tsx
2789
- import { jsx as jsx24, jsxs as jsxs4 } from "react/jsx-runtime";
2790
- var getClassName6 = get_class_name_factory_default("RichTextMenu", styles_module_default4);
2791
- var DefaultMenu = ({ children }) => {
2792
- return /* @__PURE__ */ jsx24(RichTextMenu, { children });
2793
- };
2794
- var RichTextMenu = ({ children }) => {
2795
- const { inline } = useControlContext();
2796
- return /* @__PURE__ */ jsx24("div", { className: getClassName6({ inline, form: !inline }), "data-puck-rte-menu": true, children });
2797
- };
2798
- var Group2 = ({ children }) => {
2799
- return /* @__PURE__ */ jsx24("div", { className: getClassName6("group"), children });
2800
- };
2801
- RichTextMenu.Group = Group2;
2802
- RichTextMenu.Control = Control;
2803
- RichTextMenu.AlignCenter = AlignCenter2;
2804
- RichTextMenu.AlignJustify = AlignJustify2;
2805
- RichTextMenu.AlignLeft = AlignLeft2;
2806
- RichTextMenu.AlignRight = AlignRight2;
2807
- RichTextMenu.AlignSelect = AlignSelect;
2808
- RichTextMenu.Blockquote = Blockquote;
2809
- RichTextMenu.Bold = Bold2;
2810
- RichTextMenu.BulletList = BulletList;
2811
- RichTextMenu.CodeBlock = CodeBlock;
2812
- RichTextMenu.HeadingSelect = HeadingSelect;
2813
- RichTextMenu.HorizontalRule = HorizontalRule;
2814
- RichTextMenu.InlineCode = InlineCode;
2815
- RichTextMenu.Italic = Italic2;
2816
- RichTextMenu.ListSelect = ListSelect;
2817
- RichTextMenu.OrderedList = OrderedList;
2818
- RichTextMenu.Strikethrough = Strikethrough2;
2819
- RichTextMenu.Underline = Underline2;
2820
- var LoadedRichTextMenuInner = ({
2821
- editor,
2822
- editorState,
2823
- field,
2824
- readOnly,
2825
- inline
2826
- }) => {
2827
- const { renderMenu, renderInlineMenu } = field;
2828
- const InlineMenu = useMemo5(
2829
- () => renderInlineMenu || DefaultMenu,
2830
- [renderInlineMenu]
2831
- );
2832
- const Menu = useMemo5(() => renderMenu || DefaultMenu, [renderMenu]);
2833
- return /* @__PURE__ */ jsx24(
2834
- ControlContext.Provider,
2835
- {
2836
- value: { editor, editorState, inline, options: field.options, readOnly },
2837
- children: inline ? /* @__PURE__ */ jsx24(
2838
- InlineMenu,
2839
- {
2840
- editor,
2841
- editorState,
2842
- readOnly,
2843
- children: /* @__PURE__ */ jsxs4(Group2, { children: [
2844
- /* @__PURE__ */ jsx24(Bold2, {}),
2845
- /* @__PURE__ */ jsx24(Italic2, {}),
2846
- /* @__PURE__ */ jsx24(Underline2, {})
2847
- ] })
2848
- }
2849
- ) : /* @__PURE__ */ jsxs4(Menu, { editor, editorState, readOnly, children: [
2850
- /* @__PURE__ */ jsxs4(Group2, { children: [
2851
- /* @__PURE__ */ jsx24(HeadingSelect, {}),
2852
- /* @__PURE__ */ jsx24(ListSelect, {})
2853
- ] }),
2854
- /* @__PURE__ */ jsxs4(Group2, { children: [
2855
- /* @__PURE__ */ jsx24(Bold2, {}),
2856
- /* @__PURE__ */ jsx24(Italic2, {}),
2857
- /* @__PURE__ */ jsx24(Underline2, {})
2858
- ] }),
2859
- /* @__PURE__ */ jsx24(Group2, { children: /* @__PURE__ */ jsx24(AlignSelect, {}) })
2860
- ] })
2861
- }
2862
- );
2863
- };
2864
-
2865
- // components/RichTextEditor/components/EditorInner.tsx
2866
- init_react_import();
2867
- import {
2868
- memo,
2869
- useCallback as useCallback2
2870
- } from "react";
2871
- import { jsx as jsx25, jsxs as jsxs5 } from "react/jsx-runtime";
2872
- var getClassName7 = get_class_name_factory_default("RichTextEditor", styles_module_default);
2873
- var EditorInner = memo(
2874
- ({
2875
- children,
2876
- menu,
2877
- readOnly = false,
2878
- field,
2879
- inline = false,
2880
- editor,
2881
- id
2882
- }) => {
2883
- const { initialHeight } = field;
2884
- const isActive = useAppStore(
2885
- (s) => {
2886
- var _a;
2887
- return ((_a = s.currentRichText) == null ? void 0 : _a.id) === id && inline === s.currentRichText.inline;
2888
- }
2889
- );
2890
- const appStoreApi = useAppStoreApi();
2891
- const handleHotkeyCapture = useCallback2(
2892
- (event) => {
2893
- var _a, _b;
2894
- if ((event.metaKey || event.ctrlKey) && event.key.toLowerCase() === "i") {
2895
- event.stopPropagation();
2896
- event.preventDefault();
2897
- (_b = editor == null ? void 0 : (_a = editor.commands).toggleItalic) == null ? void 0 : _b.call(_a);
2898
- }
2899
- },
2900
- [editor]
2901
- );
2902
- const handleBlur = useCallback2(
2903
- (e) => {
2904
- var _a, _b;
2905
- const targetInMenu = !!((_b = (_a = e.relatedTarget) == null ? void 0 : _a.closest) == null ? void 0 : _b.call(
2906
- _a,
2907
- "[data-puck-rte-menu]"
2908
- ));
2909
- if (e.relatedTarget && !targetInMenu) {
2910
- appStoreApi.setState({
2911
- currentRichText: null
2912
- });
2913
- } else {
2914
- e.stopPropagation();
2915
- }
2916
- },
2917
- [appStoreApi]
2918
- );
2919
- return /* @__PURE__ */ jsxs5(
2920
- "div",
2921
- {
2922
- className: getClassName7({
2923
- editor: !inline,
2924
- inline,
2925
- isActive,
2926
- disabled: readOnly
2927
- }),
2928
- style: inline ? {} : { height: initialHeight != null ? initialHeight : 256, overflowY: "auto" },
2929
- onKeyDownCapture: handleHotkeyCapture,
2930
- onBlur: handleBlur,
2931
- children: [
2932
- !inline && /* @__PURE__ */ jsx25("div", { className: getClassName7("menu"), children: menu }),
2933
- children
2934
- ]
2935
- }
2936
- );
2937
- }
2938
- );
2939
- EditorInner.displayName = "EditorInner";
2940
-
2941
- // components/RichTextMenu/index.tsx
2942
- init_react_import();
2943
- import { useEditorState as useEditorState4 } from "@tiptap/react";
2944
- import { useMemo as useMemo6 } from "react";
2945
-
2946
- // components/RichTextEditor/selector.ts
2947
- init_react_import();
2948
- var defaultEditorState = (ctx, readOnly) => {
2949
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B;
2950
- const editor = ctx.editor;
2951
- if (!editor) return {};
2952
- const canChain = () => editor.can().chain();
2953
- return {
2954
- isAlignLeft: editor.isActive({ textAlign: "left" }),
2955
- canAlignLeft: !readOnly && ((_b = (_a = canChain()).setTextAlign) == null ? void 0 : _b.call(_a, "left").run()),
2956
- isAlignCenter: editor.isActive({ textAlign: "center" }),
2957
- canAlignCenter: !readOnly && ((_d = (_c = canChain()).setTextAlign) == null ? void 0 : _d.call(_c, "center").run()),
2958
- isAlignRight: editor.isActive({ textAlign: "right" }),
2959
- canAlignRight: !readOnly && ((_f = (_e = canChain()).setTextAlign) == null ? void 0 : _f.call(_e, "right").run()),
2960
- isAlignJustify: editor.isActive({ textAlign: "justify" }),
2961
- canAlignJustify: !readOnly && ((_h = (_g = canChain()).setTextAlign) == null ? void 0 : _h.call(_g, "justify").run()),
2962
- isBold: editor.isActive("bold"),
2963
- canBold: !readOnly && ((_j = (_i = canChain()).toggleBold) == null ? void 0 : _j.call(_i).run()),
2964
- isItalic: editor.isActive("italic"),
2965
- canItalic: !readOnly && ((_l = (_k = canChain()).toggleItalic) == null ? void 0 : _l.call(_k).run()),
2966
- isUnderline: editor.isActive("underline"),
2967
- canUnderline: !readOnly && ((_n = (_m = canChain()).toggleUnderline) == null ? void 0 : _n.call(_m).run()),
2968
- isStrike: editor.isActive("strike"),
2969
- canStrike: !readOnly && ((_p = (_o = canChain()).toggleStrike) == null ? void 0 : _p.call(_o).run()),
2970
- isInlineCode: editor.isActive("code"),
2971
- canInlineCode: !readOnly && ((_r = (_q = canChain()).toggleCode) == null ? void 0 : _r.call(_q).run()),
2972
- isBulletList: editor.isActive("bulletList"),
2973
- canBulletList: !readOnly && ((_t = (_s = canChain()).toggleBulletList) == null ? void 0 : _t.call(_s).run()),
2974
- isOrderedList: editor.isActive("orderedList"),
2975
- canOrderedList: !readOnly && ((_v = (_u = canChain()).toggleOrderedList) == null ? void 0 : _v.call(_u).run()),
2976
- isCodeBlock: editor.isActive("codeBlock"),
2977
- canCodeBlock: !readOnly && ((_x = (_w = canChain()).toggleCodeBlock) == null ? void 0 : _x.call(_w).run()),
2978
- isBlockquote: editor.isActive("blockquote"),
2979
- canBlockquote: !readOnly && ((_z = (_y = canChain()).toggleBlockquote) == null ? void 0 : _z.call(_y).run()),
2980
- canHorizontalRule: !readOnly && ((_B = (_A = canChain()).setHorizontalRule) == null ? void 0 : _B.call(_A).run())
2981
- };
2982
- };
2983
-
2984
- // components/RichTextMenu/index.tsx
2985
- import { jsx as jsx26 } from "react/jsx-runtime";
2986
- var LoadedRichTextMenu = ({
2987
- editor,
2988
- field,
2989
- readOnly,
2990
- inline
2991
- }) => {
2992
- const { tiptap = {} } = field;
2993
- const { selector } = tiptap;
2994
- const resolvedSelector = useMemo6(() => {
2995
- return (ctx) => __spreadValues(__spreadValues({}, defaultEditorState(ctx, readOnly)), selector ? selector(ctx, readOnly) : {});
2996
- }, [selector, readOnly]);
2997
- const editorState = useEditorState4({
2998
- editor,
2999
- selector: resolvedSelector
3000
- });
3001
- if (!editor || !editorState) {
3002
- return null;
3003
- }
3004
- return /* @__PURE__ */ jsx26(
3005
- LoadedRichTextMenuInner,
3006
- {
3007
- editor,
3008
- editorState,
3009
- field,
3010
- readOnly,
3011
- inline
3012
- }
3013
- );
3014
- };
3015
-
3016
- export {
3017
- ActionBar,
3018
- Action,
3019
- Group,
3020
- Label,
3021
- Separator,
3022
- ChevronDown,
3023
- ChevronRight,
3024
- ChevronUp,
3025
- CircleCheckBig,
3026
- Copy,
3027
- CornerLeftUp,
3028
- EllipsisVertical,
3029
- Globe,
3030
- Hash,
3031
- Layers,
3032
- LayoutGrid,
3033
- Link,
3034
- List,
3035
- LockOpen,
3036
- Lock,
3037
- Monitor,
3038
- PanelLeft,
3039
- PanelRight,
3040
- Plus,
3041
- Redo2,
3042
- Search,
3043
- SlidersHorizontal,
3044
- Smartphone,
3045
- Tablet,
3046
- Trash,
3047
- Type,
3048
- Undo2,
3049
- ZoomIn,
3050
- ZoomOut,
3051
- reorder,
3052
- replace,
3053
- insert,
3054
- generateId,
3055
- populateIds,
3056
- insertAction,
3057
- getItem,
3058
- makeStatePublic,
3059
- monitorHotkeys,
3060
- useMonitorHotkeys,
3061
- useHotkey,
3062
- useRegisterHistorySlice,
3063
- useRegisterPermissionsSlice,
3064
- useRegisterFieldsSlice,
3065
- createAppStore,
3066
- appStoreContext,
3067
- useAppStore,
3068
- useAppStoreApi,
3069
- getBox,
3070
- useResetAutoZoom,
3071
- Loader,
3072
- IconButton,
3073
- RichTextMenu,
3074
- LoadedRichTextMenuInner,
3075
- EditorInner,
3076
- LoadedRichTextMenu
3077
- };
3078
- /*! Bundled license information:
3079
-
3080
- lucide-react/dist/esm/shared/src/utils.js:
3081
- lucide-react/dist/esm/defaultAttributes.js:
3082
- lucide-react/dist/esm/Icon.js:
3083
- lucide-react/dist/esm/createLucideIcon.js:
3084
- lucide-react/dist/esm/icons/align-center.js:
3085
- lucide-react/dist/esm/icons/align-justify.js:
3086
- lucide-react/dist/esm/icons/align-left.js:
3087
- lucide-react/dist/esm/icons/align-right.js:
3088
- lucide-react/dist/esm/icons/bold.js:
3089
- lucide-react/dist/esm/icons/chevron-down.js:
3090
- lucide-react/dist/esm/icons/chevron-right.js:
3091
- lucide-react/dist/esm/icons/chevron-up.js:
3092
- lucide-react/dist/esm/icons/circle-check-big.js:
3093
- lucide-react/dist/esm/icons/code.js:
3094
- lucide-react/dist/esm/icons/copy.js:
3095
- lucide-react/dist/esm/icons/corner-left-up.js:
3096
- lucide-react/dist/esm/icons/ellipsis-vertical.js:
3097
- lucide-react/dist/esm/icons/globe.js:
3098
- lucide-react/dist/esm/icons/hash.js:
3099
- lucide-react/dist/esm/icons/heading-1.js:
3100
- lucide-react/dist/esm/icons/heading-2.js:
3101
- lucide-react/dist/esm/icons/heading-3.js:
3102
- lucide-react/dist/esm/icons/heading-4.js:
3103
- lucide-react/dist/esm/icons/heading-5.js:
3104
- lucide-react/dist/esm/icons/heading-6.js:
3105
- lucide-react/dist/esm/icons/heading.js:
3106
- lucide-react/dist/esm/icons/italic.js:
3107
- lucide-react/dist/esm/icons/layers.js:
3108
- lucide-react/dist/esm/icons/layout-grid.js:
3109
- lucide-react/dist/esm/icons/link.js:
3110
- lucide-react/dist/esm/icons/list-ordered.js:
3111
- lucide-react/dist/esm/icons/list.js:
3112
- lucide-react/dist/esm/icons/lock-open.js:
3113
- lucide-react/dist/esm/icons/lock.js:
3114
- lucide-react/dist/esm/icons/minus.js:
3115
- lucide-react/dist/esm/icons/monitor.js:
3116
- lucide-react/dist/esm/icons/panel-left.js:
3117
- lucide-react/dist/esm/icons/panel-right.js:
3118
- lucide-react/dist/esm/icons/plus.js:
3119
- lucide-react/dist/esm/icons/quote.js:
3120
- lucide-react/dist/esm/icons/redo-2.js:
3121
- lucide-react/dist/esm/icons/search.js:
3122
- lucide-react/dist/esm/icons/sliders-horizontal.js:
3123
- lucide-react/dist/esm/icons/smartphone.js:
3124
- lucide-react/dist/esm/icons/square-code.js:
3125
- lucide-react/dist/esm/icons/strikethrough.js:
3126
- lucide-react/dist/esm/icons/tablet.js:
3127
- lucide-react/dist/esm/icons/trash.js:
3128
- lucide-react/dist/esm/icons/type.js:
3129
- lucide-react/dist/esm/icons/underline.js:
3130
- lucide-react/dist/esm/icons/undo-2.js:
3131
- lucide-react/dist/esm/icons/zoom-in.js:
3132
- lucide-react/dist/esm/icons/zoom-out.js:
3133
- lucide-react/dist/esm/lucide-react.js:
3134
- (**
3135
- * @license lucide-react v0.468.0 - ISC
3136
- *
3137
- * This source code is licensed under the ISC license.
3138
- * See the LICENSE file in the root directory of this source tree.
3139
- *)
3140
- */