@alpaca-editor/core 1.0.4083 → 1.0.4085
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/ui/card.js +1 -1
- package/dist/components/ui/card.js.map +1 -1
- package/dist/editor/FieldListField.d.ts +3 -2
- package/dist/editor/FieldListField.js +8 -8
- package/dist/editor/FieldListField.js.map +1 -1
- package/dist/editor/FieldListFieldWithFallbacks.js +2 -2
- package/dist/editor/FieldListFieldWithFallbacks.js.map +1 -1
- package/dist/editor/LinkEditorDialog.d.ts +1 -0
- package/dist/editor/LinkEditorDialog.js +4 -2
- package/dist/editor/LinkEditorDialog.js.map +1 -1
- package/dist/editor/client/EditorShell.js +11 -3
- package/dist/editor/client/EditorShell.js.map +1 -1
- package/dist/editor/client/editContext.d.ts +1 -0
- package/dist/editor/client/editContext.js.map +1 -1
- package/dist/editor/client/hooks/useWorkbox.js +6 -7
- package/dist/editor/client/hooks/useWorkbox.js.map +1 -1
- package/dist/editor/client/ui/EditorChrome.js +2 -1
- package/dist/editor/client/ui/EditorChrome.js.map +1 -1
- package/dist/editor/component-designer/ComponentDesigner.d.ts +1 -1
- package/dist/editor/component-designer/ComponentDesigner.js +48 -53
- package/dist/editor/component-designer/ComponentDesigner.js.map +1 -1
- package/dist/editor/control-center/About.js +1 -1
- package/dist/editor/control-center/About.js.map +1 -1
- package/dist/editor/field-types/RichTextEditor.d.ts +2 -1
- package/dist/editor/field-types/RichTextEditor.js +4 -4
- package/dist/editor/field-types/RichTextEditor.js.map +1 -1
- package/dist/editor/field-types/RichTextEditorComponent.d.ts +2 -1
- package/dist/editor/field-types/RichTextEditorComponent.js +2 -2
- package/dist/editor/field-types/RichTextEditorComponent.js.map +1 -1
- package/dist/editor/field-types/richtext/components/ReactSlate.js +36 -25
- package/dist/editor/field-types/richtext/components/ReactSlate.js.map +1 -1
- package/dist/editor/field-types/richtext/components/ToolbarButton.d.ts +2 -2
- package/dist/editor/field-types/richtext/components/ToolbarButton.js +3 -10
- package/dist/editor/field-types/richtext/components/ToolbarButton.js.map +1 -1
- package/dist/editor/field-types/richtext/types.d.ts +1 -0
- package/dist/editor/field-types/richtext/types.js.map +1 -1
- package/dist/editor/field-types/richtext/utils/conversion.js +180 -21
- package/dist/editor/field-types/richtext/utils/conversion.js.map +1 -1
- package/dist/editor/field-types/richtext/utils/plugins.d.ts +1 -0
- package/dist/editor/field-types/richtext/utils/plugins.js +19 -4
- package/dist/editor/field-types/richtext/utils/plugins.js.map +1 -1
- package/dist/editor/page-editor-chrome/FieldActionIndicator.js +11 -2
- package/dist/editor/page-editor-chrome/FieldActionIndicator.js.map +1 -1
- package/dist/editor/page-editor-chrome/FieldActionIndicators.js +1 -1
- package/dist/editor/page-editor-chrome/FieldActionIndicators.js.map +1 -1
- package/dist/editor/page-viewer/EditorForm.js +1 -1
- package/dist/editor/page-viewer/PageViewerFrame.js +2 -1
- package/dist/editor/page-viewer/PageViewerFrame.js.map +1 -1
- package/dist/editor/utils/urlUtils.d.ts +9 -0
- package/dist/editor/utils/urlUtils.js +25 -0
- package/dist/editor/utils/urlUtils.js.map +1 -0
- package/dist/page-wizard/steps/SelectStep.js +28 -12
- package/dist/page-wizard/steps/SelectStep.js.map +1 -1
- package/dist/revision.d.ts +2 -2
- package/dist/revision.js +2 -2
- package/dist/styles.css +24 -0
- package/package.json +1 -2
- package/src/components/ui/card.tsx +1 -1
- package/src/editor/FieldListField.tsx +11 -4
- package/src/editor/FieldListFieldWithFallbacks.tsx +3 -1
- package/src/editor/LinkEditorDialog.tsx +6 -2
- package/src/editor/client/EditorShell.tsx +20 -4
- package/src/editor/client/editContext.ts +1 -0
- package/src/editor/client/hooks/useWorkbox.ts +6 -7
- package/src/editor/client/ui/EditorChrome.tsx +4 -1
- package/src/editor/component-designer/ComponentDesigner.tsx +49 -53
- package/src/editor/control-center/About.tsx +0 -15
- package/src/editor/field-types/RichTextEditor.tsx +13 -10
- package/src/editor/field-types/RichTextEditorComponent.tsx +3 -0
- package/src/editor/field-types/richtext/components/ReactSlate.tsx +503 -437
- package/src/editor/field-types/richtext/components/ToolbarButton.tsx +12 -14
- package/src/editor/field-types/richtext/types.ts +18 -10
- package/src/editor/field-types/richtext/utils/conversion.ts +204 -23
- package/src/editor/field-types/richtext/utils/plugins.ts +24 -4
- package/src/editor/page-editor-chrome/FieldActionIndicator.tsx +63 -7
- package/src/editor/page-editor-chrome/FieldActionIndicators.tsx +1 -1
- package/src/editor/page-viewer/EditorForm.tsx +2 -2
- package/src/editor/page-viewer/PageViewerFrame.tsx +2 -1
- package/src/editor/utils/urlUtils.ts +24 -0
- package/src/page-wizard/steps/SelectStep.tsx +47 -18
- package/src/revision.ts +2 -2
- package/dist/editor/ui/StackedPanels.d.ts +0 -5
- package/dist/editor/ui/StackedPanels.js +0 -67
- package/dist/editor/ui/StackedPanels.js.map +0 -1
- package/src/editor/ui/StackedPanels.tsx +0 -134
|
@@ -58,9 +58,8 @@ export function SelectStep({
|
|
|
58
58
|
);
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
if (existingValues
|
|
61
|
+
if (Array.isArray(existingValues) && existingValues.length) {
|
|
62
62
|
setStepCompleted(true);
|
|
63
|
-
setSelectedOptions(existingValues);
|
|
64
63
|
}
|
|
65
64
|
}, [data, inputProperties]);
|
|
66
65
|
|
|
@@ -123,17 +122,36 @@ Create ${step.fields.numberOfOptions || 5} relevant options.`,
|
|
|
123
122
|
try {
|
|
124
123
|
const lastMessage = result.messages[result.messages.length - 1];
|
|
125
124
|
if (lastMessage && lastMessage.content) {
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
125
|
+
const parsed: any = JSON.parse(lastMessage.content);
|
|
126
|
+
const optionsArray: any[] = Array.isArray(parsed)
|
|
127
|
+
? parsed
|
|
128
|
+
: Array.isArray(parsed?.options)
|
|
129
|
+
? parsed.options
|
|
130
|
+
: [];
|
|
131
|
+
|
|
132
|
+
if (!Array.isArray(optionsArray) || optionsArray.length === 0) {
|
|
133
|
+
throw new Error("Parsed response did not contain any options");
|
|
131
134
|
}
|
|
132
135
|
|
|
133
|
-
|
|
136
|
+
const normalizedOptions: Option[] = optionsArray.map(
|
|
137
|
+
(opt: any, index: number) => ({
|
|
138
|
+
id: String(opt?.id ?? opt?.value ?? index),
|
|
139
|
+
title: String(
|
|
140
|
+
opt?.title ??
|
|
141
|
+
opt?.label ??
|
|
142
|
+
opt?.name ??
|
|
143
|
+
`Option ${index + 1}`,
|
|
144
|
+
),
|
|
145
|
+
description: String(
|
|
146
|
+
opt?.description ?? opt?.details ?? opt?.summary ?? "",
|
|
147
|
+
),
|
|
148
|
+
}),
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
setOptions(normalizedOptions);
|
|
134
152
|
setInternalState((state: any) => ({
|
|
135
153
|
...state,
|
|
136
|
-
[step.id + "options"]:
|
|
154
|
+
[step.id + "options"]: normalizedOptions,
|
|
137
155
|
}));
|
|
138
156
|
}
|
|
139
157
|
} catch (parseError) {
|
|
@@ -168,8 +186,14 @@ Create ${step.fields.numberOfOptions || 5} relevant options.`,
|
|
|
168
186
|
inputProperties,
|
|
169
187
|
data,
|
|
170
188
|
);
|
|
171
|
-
const selectionsArray = currentSelections
|
|
172
|
-
|
|
189
|
+
const selectionsArray = Array.isArray(currentSelections)
|
|
190
|
+
? currentSelections
|
|
191
|
+
: [];
|
|
192
|
+
setSelectedOptions(
|
|
193
|
+
selectionsArray.map((option: any) =>
|
|
194
|
+
typeof option === "string" ? option : option.id,
|
|
195
|
+
),
|
|
196
|
+
);
|
|
173
197
|
}, [data, inputProperties]);
|
|
174
198
|
|
|
175
199
|
// Handle option selection
|
|
@@ -213,7 +237,7 @@ Create ${step.fields.numberOfOptions || 5} relevant options.`,
|
|
|
213
237
|
<div className="flex h-full flex-col md:flex-row">
|
|
214
238
|
<WizardBox
|
|
215
239
|
title={step.fields.configureTitle || "Configuration"}
|
|
216
|
-
icon={<Settings />}
|
|
240
|
+
icon={<Settings strokeWidth={1} />}
|
|
217
241
|
description={
|
|
218
242
|
step.fields.configureDescription ||
|
|
219
243
|
"Configure instructions and regenerate options"
|
|
@@ -248,7 +272,7 @@ Create ${step.fields.numberOfOptions || 5} relevant options.`,
|
|
|
248
272
|
<WizardBoxConnector />
|
|
249
273
|
<WizardBox
|
|
250
274
|
title={step.fields.selectOptionsTitle || "Select Options"}
|
|
251
|
-
icon={<CheckSquare />}
|
|
275
|
+
icon={<CheckSquare strokeWidth={1} />}
|
|
252
276
|
description={
|
|
253
277
|
step.fields.selectOptionsDescription ||
|
|
254
278
|
"Choose from the generated options below"
|
|
@@ -295,11 +319,16 @@ Create ${step.fields.numberOfOptions || 5} relevant options.`,
|
|
|
295
319
|
{option.description}
|
|
296
320
|
</div>
|
|
297
321
|
</div>
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
322
|
+
<div
|
|
323
|
+
className={classNames(
|
|
324
|
+
"ml-2 flex h-6 w-6 items-center justify-center rounded-full text-white",
|
|
325
|
+
isSelected
|
|
326
|
+
? "bg-theme-secondary opacity-100"
|
|
327
|
+
: "opacity-0",
|
|
328
|
+
)}
|
|
329
|
+
>
|
|
330
|
+
✓
|
|
331
|
+
</div>
|
|
303
332
|
</div>
|
|
304
333
|
);
|
|
305
334
|
})
|
package/src/revision.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const version = "1.0.
|
|
2
|
-
export const buildDate = "2025-09-11
|
|
1
|
+
export const version = "1.0.4085";
|
|
2
|
+
export const buildDate = "2025-09-11 13:12:15";
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import "allotment/dist/style.css";
|
|
3
|
-
import { Allotment } from "allotment";
|
|
4
|
-
import { useEffect, useRef, useState } from "react";
|
|
5
|
-
import { classNames } from "primereact/utils";
|
|
6
|
-
export function StackedPanels({ panels }) {
|
|
7
|
-
const splitter = useRef(null);
|
|
8
|
-
const [sizes, setSizes] = useState([]);
|
|
9
|
-
const [preferredSizes, setPreferredSizes] = useState(undefined);
|
|
10
|
-
const [panelsExpanded, setPanelsExpanded] = useState([]);
|
|
11
|
-
const [sizeToSet, setSizeToSet] = useState();
|
|
12
|
-
const panelHeaderSize = 30;
|
|
13
|
-
const toggle = (panelIndex) => {
|
|
14
|
-
const newSize = panelsExpanded[panelIndex]
|
|
15
|
-
? panelHeaderSize
|
|
16
|
-
: (preferredSizes || sizes)[panelIndex];
|
|
17
|
-
resizePanel(panelIndex, newSize);
|
|
18
|
-
setPanelsExpanded((x) => {
|
|
19
|
-
const newState = [...x];
|
|
20
|
-
newState[panelIndex] = !newState[panelIndex];
|
|
21
|
-
return newState;
|
|
22
|
-
});
|
|
23
|
-
};
|
|
24
|
-
useEffect(() => {
|
|
25
|
-
setPanelsExpanded(panels.map(() => true));
|
|
26
|
-
setPreferredSizes(() => panels.map((x) => x.initialSize));
|
|
27
|
-
}, [panels]);
|
|
28
|
-
const resizePanel = (panelIndex, newSize) => {
|
|
29
|
-
const totalSize = sizes.reduce((a, b) => a + b, 0);
|
|
30
|
-
const totalOther = totalSize - sizes[panelIndex];
|
|
31
|
-
const tmpSizes = [...sizes];
|
|
32
|
-
tmpSizes[panelIndex] = newSize;
|
|
33
|
-
const percentages = tmpSizes.map((x) => x / totalOther);
|
|
34
|
-
percentages[panelIndex] = 0;
|
|
35
|
-
const remaining = totalSize - newSize;
|
|
36
|
-
const newSizes = percentages.map((x) => x * remaining);
|
|
37
|
-
newSizes[panelIndex] = newSize;
|
|
38
|
-
setSizes(newSizes);
|
|
39
|
-
setSizeToSet(newSizes);
|
|
40
|
-
};
|
|
41
|
-
useEffect(() => {
|
|
42
|
-
if (sizeToSet)
|
|
43
|
-
splitter.current?.resize(sizeToSet);
|
|
44
|
-
}, [sizeToSet]);
|
|
45
|
-
const getHeader = (panel, index) => {
|
|
46
|
-
if (panel.header)
|
|
47
|
-
return panel.header({ panel, index });
|
|
48
|
-
return (_jsxs("div", { className: classNames("p-1.5 bg-gray-50 uppercase text-gray-500 text-xs flex justify items-center cursor-pointer", panelsExpanded[index] ? "border-b" : ""), onClick: () => toggle(index), children: [panel.icon &&
|
|
49
|
-
(typeof panel.icon === "string" ? (_jsx("i", { className: classNames(panel.icon, "pi mr-1.5") })) : (_jsx("div", { className: "w-4 h-4 mr-1.5", children: panel.icon }))), _jsx("div", { className: "mr-auto", children: panel.title }), _jsx("i", { className: classNames(panelsExpanded[index] ? "pi-chevron-up" : "pi-chevron-down", "pi text-sm") })] }));
|
|
50
|
-
};
|
|
51
|
-
const initalSizes = panels.map((x) => x.initialSize);
|
|
52
|
-
return (_jsx(Allotment, { vertical: true, snap: true, ref: splitter, defaultSizes: initalSizes, onChange: (s) => {
|
|
53
|
-
if (sizes.join(",") != s.join(","))
|
|
54
|
-
setSizes(s);
|
|
55
|
-
const newPreferred = [...(preferredSizes || s)];
|
|
56
|
-
s.forEach((x, i) => {
|
|
57
|
-
if (x > panelHeaderSize)
|
|
58
|
-
newPreferred[i] = x;
|
|
59
|
-
});
|
|
60
|
-
setPreferredSizes(newPreferred);
|
|
61
|
-
}, children: panels.map((panel, index) => (_jsx(Allotment.Pane, {
|
|
62
|
-
// preferredSize={(preferredSizes || initalSizes)[index] + "%"}
|
|
63
|
-
maxSize: panelsExpanded.length <= index || panelsExpanded[index]
|
|
64
|
-
? 10000
|
|
65
|
-
: panelHeaderSize, children: _jsxs("div", { className: "flex flex-col h-full", children: [getHeader(panel, index), panelsExpanded[index] && (_jsx("div", { className: "overflow-hidden relative flex-1", children: _jsx("div", { className: classNames("inset-0 absolute", panel.noOverflow ? "" : "overflow-y-auto"), children: panel.content }) }))] }) }, index))) }));
|
|
66
|
-
}
|
|
67
|
-
//# sourceMappingURL=StackedPanels.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"StackedPanels.js","sourceRoot":"","sources":["../../../src/edit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,QAAQ,CAAC,CAAC,CAAC,CAAC;YAEhD,MAAM,YAAY,GAAG,CAAC,GAAG,CAAC,cAAc,IAAI,CAAC,CAAC,CAAC,CAAC;YAChD,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;gBACjB,IAAI,CAAC,GAAG,eAAe;oBAAE,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;YAC/C,CAAC,CAAC,CAAC;YAEH,iBAAiB,CAAC,YAAY,CAAC,CAAC;QAClC,CAAC,YAEA,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,CAC5B,KAAC,SAAS,CAAC,IAAI;YAEb,gEAAgE;YAChE,OAAO,EACL,cAAc,CAAC,MAAM,IAAI,KAAK,IAAI,cAAc,CAAC,KAAK,CAAC;gBACrD,CAAC,CAAC,KAAK;gBACP,CAAC,CAAC,eAAe,YAGrB,eAAK,SAAS,EAAC,sBAAsB,aAClC,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC,EACvB,cAAc,CAAC,KAAK,CAAC,IAAI,CACxB,cAAK,SAAS,EAAC,iCAAiC,YAC9C,cACE,SAAS,EAAE,UAAU,CACnB,kBAAkB,EAClB,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,iBAAiB,CAC1C,YAEA,KAAK,CAAC,OAAO,GACV,GACF,CACP,IACG,IAtBD,KAAK,CAuBK,CAClB,CAAC,GACQ,CACb,CAAC;AACJ,CAAC"}
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import "allotment/dist/style.css";
|
|
2
|
-
import { Allotment, AllotmentHandle } from "allotment";
|
|
3
|
-
|
|
4
|
-
import { useEffect, useRef, useState } from "react";
|
|
5
|
-
|
|
6
|
-
import { classNames } from "primereact/utils";
|
|
7
|
-
import { Panel } from "../../config/types";
|
|
8
|
-
|
|
9
|
-
export function StackedPanels({ panels }: { panels: Panel[] }) {
|
|
10
|
-
const splitter = useRef<AllotmentHandle>(null);
|
|
11
|
-
|
|
12
|
-
const [sizes, setSizes] = useState<number[]>([]);
|
|
13
|
-
const [preferredSizes, setPreferredSizes] = useState<number[] | undefined>(
|
|
14
|
-
undefined
|
|
15
|
-
);
|
|
16
|
-
const [panelsExpanded, setPanelsExpanded] = useState<boolean[]>([]);
|
|
17
|
-
const [sizeToSet, setSizeToSet] = useState<number[] | undefined>();
|
|
18
|
-
|
|
19
|
-
const panelHeaderSize = 30;
|
|
20
|
-
const toggle = (panelIndex: number) => {
|
|
21
|
-
const newSize = panelsExpanded[panelIndex]
|
|
22
|
-
? panelHeaderSize
|
|
23
|
-
: (preferredSizes || sizes)[panelIndex];
|
|
24
|
-
|
|
25
|
-
resizePanel(panelIndex, newSize);
|
|
26
|
-
|
|
27
|
-
setPanelsExpanded((x) => {
|
|
28
|
-
const newState = [...x];
|
|
29
|
-
newState[panelIndex] = !newState[panelIndex];
|
|
30
|
-
return newState;
|
|
31
|
-
});
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
useEffect(() => {
|
|
35
|
-
setPanelsExpanded(panels.map(() => true));
|
|
36
|
-
setPreferredSizes(() => panels.map((x) => x.initialSize));
|
|
37
|
-
}, [panels]);
|
|
38
|
-
|
|
39
|
-
const resizePanel = (panelIndex: number, newSize: number) => {
|
|
40
|
-
const totalSize = sizes.reduce((a, b) => a + b, 0);
|
|
41
|
-
const totalOther = totalSize - sizes[panelIndex];
|
|
42
|
-
const tmpSizes = [...sizes];
|
|
43
|
-
tmpSizes[panelIndex] = newSize;
|
|
44
|
-
const percentages = tmpSizes.map((x) => x / totalOther);
|
|
45
|
-
percentages[panelIndex] = 0;
|
|
46
|
-
const remaining = totalSize - newSize;
|
|
47
|
-
const newSizes = percentages.map((x) => x * remaining);
|
|
48
|
-
newSizes[panelIndex] = newSize;
|
|
49
|
-
setSizes(newSizes);
|
|
50
|
-
|
|
51
|
-
setSizeToSet(newSizes);
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
useEffect(() => {
|
|
55
|
-
if (sizeToSet) splitter.current?.resize(sizeToSet);
|
|
56
|
-
}, [sizeToSet]);
|
|
57
|
-
|
|
58
|
-
const getHeader = (panel: any, index: number) => {
|
|
59
|
-
if (panel.header) return panel.header({ panel, index });
|
|
60
|
-
|
|
61
|
-
return (
|
|
62
|
-
<div
|
|
63
|
-
className={classNames(
|
|
64
|
-
"p-1.5 bg-gray-50 uppercase text-gray-500 text-xs flex justify items-center cursor-pointer",
|
|
65
|
-
panelsExpanded[index] ? "border-b" : ""
|
|
66
|
-
)}
|
|
67
|
-
onClick={() => toggle(index)}
|
|
68
|
-
>
|
|
69
|
-
{panel.icon &&
|
|
70
|
-
(typeof panel.icon === "string" ? (
|
|
71
|
-
<i className={classNames(panel.icon, "pi mr-1.5")}></i>
|
|
72
|
-
) : (
|
|
73
|
-
<div className="w-4 h-4 mr-1.5">{panel.icon}</div>
|
|
74
|
-
))}
|
|
75
|
-
<div className="mr-auto">{panel.title}</div>
|
|
76
|
-
<i
|
|
77
|
-
className={classNames(
|
|
78
|
-
panelsExpanded[index] ? "pi-chevron-up" : "pi-chevron-down",
|
|
79
|
-
"pi text-sm"
|
|
80
|
-
)}
|
|
81
|
-
></i>
|
|
82
|
-
</div>
|
|
83
|
-
);
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
const initalSizes = panels.map((x) => x.initialSize);
|
|
87
|
-
|
|
88
|
-
return (
|
|
89
|
-
<Allotment
|
|
90
|
-
vertical={true}
|
|
91
|
-
snap={true}
|
|
92
|
-
ref={splitter}
|
|
93
|
-
defaultSizes={initalSizes}
|
|
94
|
-
onChange={(s) => {
|
|
95
|
-
if (sizes.join(",") != s.join(",")) setSizes(s);
|
|
96
|
-
|
|
97
|
-
const newPreferred = [...(preferredSizes || s)];
|
|
98
|
-
s.forEach((x, i) => {
|
|
99
|
-
if (x > panelHeaderSize) newPreferred[i] = x;
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
setPreferredSizes(newPreferred);
|
|
103
|
-
}}
|
|
104
|
-
>
|
|
105
|
-
{panels.map((panel, index) => (
|
|
106
|
-
<Allotment.Pane
|
|
107
|
-
key={index}
|
|
108
|
-
// preferredSize={(preferredSizes || initalSizes)[index] + "%"}
|
|
109
|
-
maxSize={
|
|
110
|
-
panelsExpanded.length <= index || panelsExpanded[index]
|
|
111
|
-
? 10000
|
|
112
|
-
: panelHeaderSize
|
|
113
|
-
}
|
|
114
|
-
>
|
|
115
|
-
<div className="flex flex-col h-full">
|
|
116
|
-
{getHeader(panel, index)}
|
|
117
|
-
{panelsExpanded[index] && (
|
|
118
|
-
<div className="overflow-hidden relative flex-1">
|
|
119
|
-
<div
|
|
120
|
-
className={classNames(
|
|
121
|
-
"inset-0 absolute",
|
|
122
|
-
panel.noOverflow ? "" : "overflow-y-auto"
|
|
123
|
-
)}
|
|
124
|
-
>
|
|
125
|
-
{panel.content}
|
|
126
|
-
</div>
|
|
127
|
-
</div>
|
|
128
|
-
)}
|
|
129
|
-
</div>
|
|
130
|
-
</Allotment.Pane>
|
|
131
|
-
))}
|
|
132
|
-
</Allotment>
|
|
133
|
-
);
|
|
134
|
-
}
|