@delmaredigital/payload-experiments 0.4.0-rc.5 → 0.4.0-rc.7
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/admin/blocks/BlockPanel.js +6 -4
- package/dist/admin/blocks/inject.js +1 -0
- package/dist/admin/blocks/model.d.ts +3 -2
- package/dist/admin/blocks/model.js +8 -4
- package/dist/admin/copy/blocks.d.ts +3 -2
- package/dist/admin/copy/blocks.js +7 -6
- package/dist/admin/copy/newTest.d.ts +1 -1
- package/dist/admin/copy/newTest.js +1 -1
- package/dist/admin/surface/ResultsRoute.js +2 -1
- package/dist/admin/surface/TestsHome.d.ts +2 -1
- package/dist/admin/surface/TestsHome.js +91 -37
- package/dist/admin/surface/TestsSurface.js +3 -0
- package/dist/admin/surface/home.model.d.ts +2 -0
- package/dist/admin/surface/newTest/NewTest.js +16 -18
- package/dist/admin/surface/newTest/PageWizard.js +1 -0
- package/dist/admin/surface/newTest/newTest.css +3 -1
- package/dist/admin/views/TestsSurfaceClient.d.ts +3 -0
- package/dist/admin/views/TestsSurfaceClient.js +11 -0
- package/dist/admin/views/buildSurfaceProps.js +10 -3
- package/dist/blocks/bindings.js +8 -14
- package/dist/blocks/placementLanguages.d.ts +7 -0
- package/dist/blocks/placementLanguages.js +27 -0
- package/dist/blocks/placementLocale.d.ts +23 -7
- package/dist/blocks/placementLocale.js +221 -66
- package/dist/db/appends.d.ts +13 -0
- package/dist/db/appends.js +49 -0
- package/dist/db/bulkPlacementRemoval.js +8 -4
- package/dist/endpoints/contentLocale.d.ts +6 -0
- package/dist/endpoints/contentLocale.js +15 -0
- package/dist/endpoints/deleteImpact.d.ts +6 -0
- package/dist/endpoints/deleteImpact.js +206 -0
- package/dist/endpoints/index.js +7 -0
- package/dist/endpoints/pages.js +7 -3
- package/dist/endpoints/placementStatus.js +6 -1
- package/dist/endpoints/preflight.d.ts +1 -1
- package/dist/endpoints/preflight.js +17 -2
- package/dist/exports/adminClient.d.ts +1 -1
- package/dist/exports/adminClient.js +1 -1
- package/dist/exports/index.d.ts +1 -1
- package/dist/goals/fairness.js +43 -34
- package/dist/hooks/blockRemovalRule.d.ts +4 -3
- package/dist/hooks/blockRemovalRule.js +33 -9
- package/dist/hooks/pageGuard.d.ts +3 -0
- package/dist/hooks/pageGuard.js +34 -24
- package/dist/hooks/puckNestedTests.d.ts +8 -0
- package/dist/hooks/puckNestedTests.js +36 -0
- package/dist/lib/placementPages.d.ts +2 -1
- package/dist/lib/placementPages.js +10 -2
- package/dist/manifest/compile.d.ts +2 -1
- package/dist/manifest/compile.js +5 -1
- package/dist/puck/ExperimentPicker.d.ts +2 -1
- package/dist/puck/ExperimentPicker.js +37 -30
- package/dist/puck/ExperimentSlot.js +3 -1
- package/dist/puck/copy.d.ts +1 -0
- package/dist/puck/copy.js +1 -0
- package/dist/puck/editor/ConfigureTestDrawer.d.ts +8 -4
- package/dist/puck/editor/ConfigureTestDrawer.js +4 -2
- package/dist/puck/editor/CreateExperimentDrawer.d.ts +2 -1
- package/dist/puck/editor/CreateExperimentDrawer.js +24 -20
- package/dist/puck/editor/EditorControls.d.ts +1 -1
- package/dist/puck/editor/EditorControls.js +1 -1
- package/dist/puck/editor/ExperimentSlotEditor.js +405 -394
- package/dist/puck/editor/LeftoverVersions.d.ts +4 -2
- package/dist/puck/editor/LeftoverVersions.js +23 -44
- package/dist/puck/editor/QuickTestActions.js +2 -2
- package/dist/puck/editor/VersionBuilder.d.ts +41 -13
- package/dist/puck/editor/VersionBuilder.js +461 -224
- package/dist/puck/editor/armWrites.d.ts +9 -2
- package/dist/puck/editor/armWrites.js +40 -2
- package/dist/puck/editor/armsCache.d.ts +1 -1
- package/dist/puck/editor/armsCache.js +2 -1
- package/dist/puck/editor/blockClipboard.d.ts +16 -0
- package/dist/puck/editor/blockClipboard.js +20 -0
- package/dist/puck/editor/copy.d.ts +27 -26
- package/dist/puck/editor/copy.js +28 -26
- package/dist/puck/editor/createTest.d.ts +3 -0
- package/dist/puck/editor/createTest.js +33 -0
- package/dist/puck/editor/editor.chrome.css +138 -17
- package/dist/puck/editor/editor.css +156 -22
- package/dist/puck/editor/editor.model.d.ts +2 -1
- package/dist/puck/editor/editor.model.js +3 -3
- package/dist/puck/editor/experimentOutlinePlugin.js +1 -1
- package/dist/puck/editor/localPlacements.d.ts +5 -2
- package/dist/puck/editor/localPlacements.js +32 -18
- package/dist/puck/editor/placementsCache.d.ts +18 -12
- package/dist/puck/editor/placementsCache.js +52 -47
- package/dist/puck/editor/sidebar.d.ts +2 -6
- package/dist/puck/editor/sidebar.js +3 -6
- package/dist/puck/editor/usePlacementNotice.d.ts +1 -1
- package/dist/puck/editor/usePlacementNotice.js +4 -3
- package/dist/puck/experimentSlug.d.ts +2 -0
- package/dist/puck/experimentSlug.js +3 -0
- package/dist/puck/nestedTestCopy.d.ts +8 -0
- package/dist/puck/nestedTestCopy.js +22 -0
- package/dist/puck/nestedTests.d.ts +17 -0
- package/dist/puck/nestedTests.js +30 -0
- package/dist/puck/slotConfig.d.ts +1 -1
- package/dist/puck/slotConfig.js +17 -4
- package/dist/puck/visibility.d.ts +20 -0
- package/dist/puck/visibility.js +81 -0
- package/dist/server/recordContentChange.js +37 -20
- package/dist/server/resolveExperimentData.js +6 -3
- package/dist/testSurface/PreviewLinks.js +6 -2
- package/dist/testSurface/api.d.ts +6 -3
- package/dist/testSurface/api.js +10 -6
- package/dist/testSurface/contentLocaleURL.d.ts +2 -0
- package/dist/testSurface/contentLocaleURL.js +3 -0
- package/dist/testSurface/copy/common.d.ts +4 -0
- package/dist/testSurface/copy/common.js +8 -4
- package/dist/testSurface/copy/languages.d.ts +11 -0
- package/dist/testSurface/copy/languages.js +7 -0
- package/dist/testSurface/copy/readiness.d.ts +2 -1
- package/dist/testSurface/copy/readiness.js +2 -1
- package/dist/testSurface/copy/testPage.d.ts +28 -6
- package/dist/testSurface/copy/testPage.js +28 -6
- package/dist/testSurface/placementLabel.d.ts +8 -0
- package/dist/testSurface/placementLabel.js +24 -0
- package/dist/testSurface/placements/placementLabels.d.ts +2 -0
- package/dist/testSurface/placements/placementLabels.js +2 -1
- package/dist/testSurface/results/results.css +1 -1
- package/dist/testSurface/results/results.model.d.ts +1 -1
- package/dist/testSurface/surface/contracts.d.ts +2 -0
- package/dist/testSurface/surface/editorPlacement.d.ts +5 -0
- package/dist/testSurface/surface/editorPlacement.js +18 -0
- package/dist/testSurface/surface/pageBlock/pageBlock.model.js +2 -1
- package/dist/testSurface/surface/pageBlock/parts.js +24 -6
- package/dist/testSurface/surface/readiness/ActionDialogs.js +28 -34
- package/dist/testSurface/surface/readiness/readiness.model.js +9 -2
- package/dist/testSurface/surface/results/useResults.d.ts +4 -1
- package/dist/testSurface/surface/test/DeleteTest.d.ts +15 -0
- package/dist/testSurface/surface/test/DeleteTest.js +171 -0
- package/dist/testSurface/surface/test/GoalSection.js +101 -74
- package/dist/testSurface/surface/test/TestSurface.js +29 -9
- package/dist/testSurface/surface/test/fields.d.ts +1 -3
- package/dist/testSurface/surface/test/fields.js +5 -35
- package/dist/testSurface/surface/useTestDocument.d.ts +2 -1
- package/dist/testSurface/surface/useTestDocument.js +20 -4
- package/dist/testSurface/useApi.d.ts +4 -1
- package/dist/transitions/checkStart.d.ts +4 -1
- package/dist/transitions/checkStart.js +117 -14
- package/dist/transitions/contentFields.js +9 -5
- package/dist/transitions/makeContent.js +29 -9
- package/dist/transitions/nestedPlacementNames.d.ts +5 -0
- package/dist/transitions/nestedPlacementNames.js +33 -0
- package/dist/transitions/pageVersions.js +3 -1
- package/dist/transitions/placementInteractions.js +7 -4
- package/dist/transitions/placements.d.ts +26 -1
- package/dist/transitions/placements.js +239 -87
- package/dist/transitions/preflightData.d.ts +2 -1
- package/dist/transitions/preflightData.js +66 -3
- package/dist/transitions/start.js +4 -1
- package/dist/types/endpoints.d.ts +35 -1
- package/dist/types/endpoints.js +1 -1
- package/dist/types/puck.d.ts +1 -0
- package/dist/types/surface.d.ts +2 -0
- package/dist/ui/Button.js +2 -2
- package/dist/ui/Inputs.d.ts +4 -3
- package/dist/ui/Inputs.js +7 -4
- package/dist/ui/SelectControl.d.ts +33 -0
- package/dist/ui/SelectControl.js +504 -0
- package/dist/ui/Tabs.d.ts +0 -1
- package/dist/ui/Tabs.js +28 -40
- package/dist/ui/ui.css +18 -5
- package/package.json +3 -2
|
@@ -1,49 +1,279 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs
|
|
3
|
-
import { useEffect, useId, useRef, useState } from 'react';
|
|
4
|
-
import {
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { createContext, useContext, useEffect, useId, useRef, useState } from 'react';
|
|
4
|
+
import { balanceWeight, splitEvenly, totalWeight, withSlotsFor } from '../../arms/model.js';
|
|
5
5
|
import { checkArms } from '../../collections/experiments/armInvariants.js';
|
|
6
6
|
import { issueMessage } from '../../arms/copy.js';
|
|
7
7
|
import { Button } from '../../ui/Button.js';
|
|
8
8
|
import { Dialog } from '../../ui/Dialog.js';
|
|
9
9
|
import { NumberInput, TextInput } from '../../ui/Inputs.js';
|
|
10
|
-
import { ArmWriteError, writeArms } from './armWrites.js';
|
|
10
|
+
import { addVersionArms, ArmWriteError, removeVersionArms, renameVersionArms, setVersionTraffic, writeArms } from './armWrites.js';
|
|
11
11
|
import { editorCopy as C } from './copy.js';
|
|
12
|
-
|
|
12
|
+
const VersionLockContext = /*#__PURE__*/ createContext(undefined);
|
|
13
|
+
/** A pointer shortcut supplements the explicit, keyboard-accessible open marker. */ export function VersionCard({ label, openLabel = label, active, dragging, interactive = true, onSelect, children }) {
|
|
14
|
+
return /*#__PURE__*/ _jsx("div", {
|
|
15
|
+
className: "xp-slot-version-group",
|
|
16
|
+
"data-active": active,
|
|
17
|
+
role: "group",
|
|
18
|
+
"aria-label": label,
|
|
19
|
+
"aria-current": active ? 'true' : undefined,
|
|
20
|
+
onClick: (event)=>{
|
|
21
|
+
if (interactive && !dragging && event.currentTarget.ownerDocument.getSelection()?.isCollapsed !== false && !event.target.closest('button, input, label, select, textarea, a, [role="button"], [contenteditable="true"]')) onSelect();
|
|
22
|
+
},
|
|
23
|
+
children: /*#__PURE__*/ _jsxs("div", {
|
|
24
|
+
className: "xp-slot-version-row",
|
|
25
|
+
children: [
|
|
26
|
+
interactive ? /*#__PURE__*/ _jsx("button", {
|
|
27
|
+
type: "button",
|
|
28
|
+
className: "xp-slot-version-open",
|
|
29
|
+
"aria-label": C.showVersion(openLabel),
|
|
30
|
+
"aria-pressed": active,
|
|
31
|
+
disabled: dragging,
|
|
32
|
+
onClick: onSelect
|
|
33
|
+
}) : /*#__PURE__*/ _jsx("span", {
|
|
34
|
+
className: "xp-slot-version-open",
|
|
35
|
+
"aria-hidden": "true",
|
|
36
|
+
style: {
|
|
37
|
+
cursor: 'default'
|
|
38
|
+
}
|
|
39
|
+
}),
|
|
40
|
+
children
|
|
41
|
+
]
|
|
42
|
+
})
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
/** Keep unavailable controls reachable, and explain an attempted edit in place. */ export function VersionLock({ message, children }) {
|
|
46
|
+
const id = useId();
|
|
47
|
+
const controls = useRef(null);
|
|
48
|
+
const notice = useRef(null);
|
|
49
|
+
const timer = useRef(undefined);
|
|
50
|
+
const [attention, setAttention] = useState(false);
|
|
51
|
+
useEffect(()=>{
|
|
52
|
+
setAttention(false);
|
|
53
|
+
return ()=>{
|
|
54
|
+
clearTimeout(timer.current);
|
|
55
|
+
timer.current = undefined;
|
|
56
|
+
};
|
|
57
|
+
}, [
|
|
58
|
+
message
|
|
59
|
+
]);
|
|
60
|
+
const explain = ()=>{
|
|
61
|
+
if (timer.current !== undefined) return;
|
|
62
|
+
setAttention(true);
|
|
63
|
+
notice.current?.scrollIntoView?.({
|
|
64
|
+
block: 'nearest'
|
|
65
|
+
});
|
|
66
|
+
timer.current = setTimeout(()=>{
|
|
67
|
+
timer.current = undefined;
|
|
68
|
+
setAttention(false);
|
|
69
|
+
}, 2000);
|
|
70
|
+
};
|
|
71
|
+
useEffect(()=>{
|
|
72
|
+
const node = controls.current;
|
|
73
|
+
if (!message || !node) return;
|
|
74
|
+
const edit = (event)=>{
|
|
75
|
+
if (event.target.closest('input[aria-disabled="true"], textarea[aria-disabled="true"]')) {
|
|
76
|
+
event.preventDefault();
|
|
77
|
+
event.stopPropagation();
|
|
78
|
+
explain();
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
node.addEventListener('beforeinput', edit, true);
|
|
82
|
+
return ()=>node.removeEventListener('beforeinput', edit, true);
|
|
83
|
+
}, [
|
|
84
|
+
message
|
|
85
|
+
]);
|
|
86
|
+
return /*#__PURE__*/ _jsx(VersionLockContext.Provider, {
|
|
87
|
+
value: message ? id : undefined,
|
|
88
|
+
children: /*#__PURE__*/ _jsxs("div", {
|
|
89
|
+
ref: controls,
|
|
90
|
+
className: "xp-slot-version-controls",
|
|
91
|
+
onPasteCapture: (event)=>{
|
|
92
|
+
if (message && event.target.closest('input[aria-disabled="true"], textarea[aria-disabled="true"]')) {
|
|
93
|
+
event.preventDefault();
|
|
94
|
+
event.stopPropagation();
|
|
95
|
+
explain();
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
onCutCapture: (event)=>{
|
|
99
|
+
if (message && event.target.closest('input[aria-disabled="true"], textarea[aria-disabled="true"]')) {
|
|
100
|
+
event.preventDefault();
|
|
101
|
+
event.stopPropagation();
|
|
102
|
+
explain();
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
onClickCapture: (event)=>{
|
|
106
|
+
if (message && event.target.closest('button[aria-disabled="true"], [role="button"][aria-disabled="true"]')) {
|
|
107
|
+
event.preventDefault();
|
|
108
|
+
event.stopPropagation();
|
|
109
|
+
explain();
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
onKeyDownCapture: (event)=>{
|
|
113
|
+
// Leave Tab, caret navigation and copying available on read-only values.
|
|
114
|
+
const control = event.target.closest('[aria-disabled="true"]');
|
|
115
|
+
const stepping = control?.matches('input[type="number"]') && [
|
|
116
|
+
'ArrowUp',
|
|
117
|
+
'ArrowDown'
|
|
118
|
+
].includes(event.key);
|
|
119
|
+
const shortcut = (event.ctrlKey || event.metaKey) && [
|
|
120
|
+
'v',
|
|
121
|
+
'x'
|
|
122
|
+
].includes(event.key.toLowerCase()) || event.shiftKey && [
|
|
123
|
+
'Insert',
|
|
124
|
+
'Delete'
|
|
125
|
+
].includes(event.key);
|
|
126
|
+
const typing = !event.ctrlKey && !event.metaKey && !event.altKey && event.key.length === 1;
|
|
127
|
+
const deletion = [
|
|
128
|
+
'Backspace',
|
|
129
|
+
'Delete'
|
|
130
|
+
].includes(event.key);
|
|
131
|
+
const activation = control?.matches('button, [role="button"]') && [
|
|
132
|
+
'Enter',
|
|
133
|
+
' '
|
|
134
|
+
].includes(event.key);
|
|
135
|
+
const input = control?.matches('input, textarea');
|
|
136
|
+
if (message && control && (input && (shortcut || typing || deletion || stepping) || activation)) {
|
|
137
|
+
event.preventDefault();
|
|
138
|
+
event.stopPropagation();
|
|
139
|
+
explain();
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
children: [
|
|
143
|
+
message ? /*#__PURE__*/ _jsx("div", {
|
|
144
|
+
ref: notice,
|
|
145
|
+
id: id,
|
|
146
|
+
className: "xp-slot-lock-notice",
|
|
147
|
+
"data-attention": attention,
|
|
148
|
+
children: attention ? /*#__PURE__*/ _jsx("span", {
|
|
149
|
+
role: "alert",
|
|
150
|
+
children: message
|
|
151
|
+
}, "attention") : /*#__PURE__*/ _jsx("span", {
|
|
152
|
+
children: message
|
|
153
|
+
}, "rest")
|
|
154
|
+
}) : null,
|
|
155
|
+
children(message ? id : undefined)
|
|
156
|
+
]
|
|
157
|
+
})
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
export function useArmWrites({ url, bindingKey, status, controlKeys, publish, isCurrent, onWrite, onSaved }) {
|
|
13
161
|
const guard = useRef(false);
|
|
162
|
+
const running = useRef(Promise.resolve());
|
|
14
163
|
const [busy, setBusy] = useState(false);
|
|
15
|
-
const [
|
|
164
|
+
const [errorState, setErrors] = useState({
|
|
165
|
+
bindingKey,
|
|
166
|
+
errors: {}
|
|
167
|
+
});
|
|
168
|
+
const errors = errorState.bindingKey === bindingKey ? errorState.errors : {};
|
|
169
|
+
const controls = controlKeys.join(',');
|
|
170
|
+
const scope = useRef({
|
|
171
|
+
bindingKey,
|
|
172
|
+
status,
|
|
173
|
+
keys: new Set(controlKeys)
|
|
174
|
+
});
|
|
175
|
+
scope.current = {
|
|
176
|
+
bindingKey,
|
|
177
|
+
status,
|
|
178
|
+
keys: new Set(controlKeys)
|
|
179
|
+
};
|
|
180
|
+
useEffect(()=>{
|
|
181
|
+
const keys = new Set(controls.split(','));
|
|
182
|
+
setErrors((current)=>({
|
|
183
|
+
bindingKey,
|
|
184
|
+
errors: current.bindingKey === bindingKey ? Object.fromEntries(Object.entries(current.errors).filter(([key, refusal])=>keys.has(key) && (key !== 'split' && key !== 'add' || refusal.status === status))) : {}
|
|
185
|
+
}));
|
|
186
|
+
}, [
|
|
187
|
+
bindingKey,
|
|
188
|
+
controls,
|
|
189
|
+
status
|
|
190
|
+
]);
|
|
191
|
+
const clearError = (key)=>setErrors((current)=>{
|
|
192
|
+
if (current.bindingKey !== bindingKey) return current;
|
|
193
|
+
const next = {
|
|
194
|
+
...current.errors
|
|
195
|
+
};
|
|
196
|
+
delete next[key];
|
|
197
|
+
return {
|
|
198
|
+
bindingKey,
|
|
199
|
+
errors: next
|
|
200
|
+
};
|
|
201
|
+
});
|
|
16
202
|
async function write(transform, options) {
|
|
17
|
-
if (
|
|
203
|
+
if (options?.queue) {
|
|
204
|
+
while(guard.current)await running.current;
|
|
205
|
+
if (options.cancelled?.()) return;
|
|
206
|
+
if (!isCurrent()) {
|
|
207
|
+
options.onError?.(C.staleEdit);
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
} else if (guard.current) return;
|
|
211
|
+
let release;
|
|
212
|
+
running.current = new Promise((resolve)=>{
|
|
213
|
+
release = resolve;
|
|
214
|
+
});
|
|
18
215
|
guard.current = true;
|
|
216
|
+
options?.onStart?.();
|
|
19
217
|
onWrite();
|
|
20
218
|
setBusy(true);
|
|
21
|
-
|
|
219
|
+
const errorKey = options?.errorKey ?? 'add';
|
|
220
|
+
if (!options?.onError) clearError(errorKey);
|
|
22
221
|
try {
|
|
23
|
-
const saved = await writeArms(url, transform,
|
|
222
|
+
const saved = await writeArms(url, transform, (doc)=>{
|
|
223
|
+
// Publishing and refusing can finish in one React batch. Remember the fresh
|
|
224
|
+
// status now so the lock change that caused this refusal does not erase it.
|
|
225
|
+
const accepted = publish(doc) ?? doc;
|
|
226
|
+
if (scope.current.bindingKey === bindingKey) scope.current.status = accepted.status;
|
|
227
|
+
return accepted;
|
|
228
|
+
}, options);
|
|
229
|
+
if (isCurrent()) setErrors({
|
|
230
|
+
bindingKey,
|
|
231
|
+
errors: {}
|
|
232
|
+
});
|
|
24
233
|
onSaved?.();
|
|
25
234
|
return saved;
|
|
26
235
|
} catch (error) {
|
|
27
|
-
if (isCurrent())
|
|
236
|
+
if (isCurrent()) {
|
|
237
|
+
const message = error instanceof ArmWriteError ? error.message : C.writeNetwork;
|
|
238
|
+
if (options?.onError) options.onError(message);
|
|
239
|
+
else if (scope.current.bindingKey === bindingKey && scope.current.keys.has(errorKey)) {
|
|
240
|
+
const refusal = {
|
|
241
|
+
message,
|
|
242
|
+
status: scope.current.status
|
|
243
|
+
};
|
|
244
|
+
setErrors((current)=>({
|
|
245
|
+
bindingKey,
|
|
246
|
+
errors: {
|
|
247
|
+
...current.bindingKey === bindingKey ? current.errors : {},
|
|
248
|
+
[errorKey]: refusal
|
|
249
|
+
}
|
|
250
|
+
}));
|
|
251
|
+
}
|
|
252
|
+
}
|
|
28
253
|
} finally{
|
|
29
254
|
guard.current = false;
|
|
30
255
|
setBusy(false);
|
|
256
|
+
release();
|
|
31
257
|
}
|
|
32
258
|
}
|
|
33
259
|
return {
|
|
34
260
|
write,
|
|
35
261
|
busy,
|
|
36
|
-
error
|
|
262
|
+
error: Object.entries(errors).filter(([key])=>!key.startsWith('remove:')).map(([, refusal])=>refusal.message).join(' '),
|
|
263
|
+
errorFor: (key)=>errors[key]?.message,
|
|
264
|
+
clearError
|
|
37
265
|
};
|
|
38
266
|
}
|
|
39
267
|
export function AddVariant({ experiment, writes, onSelect }) {
|
|
40
268
|
if (experiment.arms.filter((arm)=>arm.kind === 'variant').length >= 3) return null;
|
|
41
269
|
return /*#__PURE__*/ _jsx(Button, {
|
|
42
|
-
|
|
270
|
+
size: "sm",
|
|
271
|
+
"aria-disabled": writes.busy || undefined,
|
|
43
272
|
onClick: async ()=>{
|
|
273
|
+
if (writes.busy) return;
|
|
44
274
|
let added;
|
|
45
275
|
const saved = await writes.write((arms)=>{
|
|
46
|
-
const next =
|
|
276
|
+
const next = addVersionArms(arms);
|
|
47
277
|
added = next.find((arm)=>!arms.some((existing)=>existing.key === arm.key))?.key;
|
|
48
278
|
return next;
|
|
49
279
|
});
|
|
@@ -52,179 +282,120 @@ export function AddVariant({ experiment, writes, onSelect }) {
|
|
|
52
282
|
children: C.add
|
|
53
283
|
});
|
|
54
284
|
}
|
|
55
|
-
|
|
285
|
+
/** Always-visible editor for the saved version name. */ export function VersionName({ arm, writes, editable }) {
|
|
56
286
|
const id = useId();
|
|
57
|
-
const
|
|
287
|
+
const lockId = useContext(VersionLockContext);
|
|
288
|
+
const [name, setName] = useState(arm.label);
|
|
289
|
+
const draft = useRef(arm.label);
|
|
290
|
+
const pending = useRef(null);
|
|
291
|
+
const [error, setError] = useState();
|
|
58
292
|
const [invalid, setInvalid] = useState(false);
|
|
59
|
-
const
|
|
60
|
-
const focusTrigger = ()=>trigger.current?.querySelector('button')?.focus();
|
|
61
|
-
const restoreFocus = useRef(false);
|
|
293
|
+
const [saved, setSaved] = useState(false);
|
|
62
294
|
useEffect(()=>{
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
focusTrigger();
|
|
66
|
-
}
|
|
295
|
+
draft.current = arm.label;
|
|
296
|
+
setName(arm.label);
|
|
67
297
|
}, [
|
|
68
|
-
|
|
69
|
-
name
|
|
298
|
+
arm.label
|
|
70
299
|
]);
|
|
71
300
|
useEffect(()=>{
|
|
72
|
-
if (!
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
const outside = (event)=>{
|
|
76
|
-
if (node && !event.composedPath().includes(node)) onOpenChange(false);
|
|
77
|
-
};
|
|
78
|
-
// Focus leaving the canvas iframe (Puck's own panels) or the window fires window blur, not a document pointerdown.
|
|
79
|
-
const leave = ()=>onOpenChange(false);
|
|
80
|
-
const view = doc?.defaultView;
|
|
81
|
-
doc?.addEventListener('pointerdown', outside, true);
|
|
82
|
-
view?.addEventListener('blur', leave);
|
|
83
|
-
return ()=>{
|
|
84
|
-
doc?.removeEventListener('pointerdown', outside, true);
|
|
85
|
-
view?.removeEventListener('blur', leave);
|
|
86
|
-
};
|
|
301
|
+
if (!saved) return;
|
|
302
|
+
const timer = setTimeout(()=>setSaved(false), 2000);
|
|
303
|
+
return ()=>clearTimeout(timer);
|
|
87
304
|
}, [
|
|
88
|
-
|
|
89
|
-
onOpenChange
|
|
305
|
+
saved
|
|
90
306
|
]);
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
};
|
|
95
|
-
const slot = arm.key;
|
|
96
|
-
async function rename() {
|
|
97
|
-
if (!name?.trim()) {
|
|
307
|
+
async function commit() {
|
|
308
|
+
if (!editable || pending.current || draft.current === arm.label) return;
|
|
309
|
+
if (!draft.current.trim()) {
|
|
98
310
|
setInvalid(true);
|
|
99
311
|
return;
|
|
100
312
|
}
|
|
101
|
-
const label =
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
313
|
+
const label = draft.current.trim();
|
|
314
|
+
const attempt = {
|
|
315
|
+
started: false,
|
|
316
|
+
cancelled: false
|
|
317
|
+
};
|
|
318
|
+
pending.current = attempt;
|
|
319
|
+
setError(undefined);
|
|
320
|
+
setSaved(false);
|
|
321
|
+
try {
|
|
322
|
+
const result = await writes.write((arms)=>renameVersionArms(arms, arm.key, label), {
|
|
323
|
+
onError: setError,
|
|
324
|
+
queue: true,
|
|
325
|
+
cancelled: ()=>attempt.cancelled,
|
|
326
|
+
onStart: ()=>{
|
|
327
|
+
attempt.started = true;
|
|
328
|
+
}
|
|
329
|
+
});
|
|
330
|
+
if (result) setSaved(true);
|
|
331
|
+
} finally{
|
|
332
|
+
pending.current = null;
|
|
109
333
|
}
|
|
110
334
|
}
|
|
335
|
+
const message = invalid ? C.emptyLabel : error;
|
|
111
336
|
return /*#__PURE__*/ _jsxs("div", {
|
|
112
|
-
|
|
113
|
-
className: "xp-slot-version-actions",
|
|
114
|
-
onBlur: (event)=>{
|
|
115
|
-
// Safari/Firefox may blur a keyboard-focused trigger without focusing the clicked item.
|
|
116
|
-
// Outside pointerdown handles real outside clicks, including non-focusable targets.
|
|
117
|
-
if (event.relatedTarget !== null && !event.currentTarget.contains(event.relatedTarget)) onOpenChange(false);
|
|
118
|
-
},
|
|
119
|
-
onKeyDown: (event)=>{
|
|
120
|
-
if (event.key === 'Escape' && !writes.busy) {
|
|
121
|
-
event.preventDefault();
|
|
122
|
-
closeMenu();
|
|
123
|
-
setName(null);
|
|
124
|
-
}
|
|
125
|
-
},
|
|
337
|
+
className: "xp-slot-version-name",
|
|
126
338
|
children: [
|
|
127
|
-
/*#__PURE__*/
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
arm.kind === 'variant' ? /*#__PURE__*/ _jsxs(_Fragment, {
|
|
161
|
-
children: [
|
|
162
|
-
/*#__PURE__*/ _jsx(Button, {
|
|
163
|
-
variant: "quiet",
|
|
164
|
-
size: "sm",
|
|
165
|
-
disabled: !canCopy,
|
|
166
|
-
onClick: ()=>{
|
|
167
|
-
closeMenu();
|
|
168
|
-
onCopy(slot);
|
|
169
|
-
},
|
|
170
|
-
children: C.copy
|
|
171
|
-
}),
|
|
172
|
-
!canCopy ? /*#__PURE__*/ _jsx("p", {
|
|
173
|
-
className: "xp-ui-help",
|
|
174
|
-
children: C.copyEmpty
|
|
175
|
-
}) : null
|
|
176
|
-
]
|
|
177
|
-
}) : null,
|
|
178
|
-
arm.kind !== 'control' && editable ? /*#__PURE__*/ _jsx(Button, {
|
|
179
|
-
variant: "quiet",
|
|
180
|
-
size: "sm",
|
|
181
|
-
onClick: ()=>{
|
|
182
|
-
closeMenu();
|
|
183
|
-
onRequestRemove();
|
|
184
|
-
},
|
|
185
|
-
children: C.removeVersion
|
|
186
|
-
}) : null,
|
|
187
|
-
running ? /*#__PURE__*/ _jsx("p", {
|
|
188
|
-
className: "xp-ui-help",
|
|
189
|
-
children: C.runningVersions
|
|
190
|
-
}) : null
|
|
191
|
-
]
|
|
192
|
-
}) : null
|
|
193
|
-
]
|
|
194
|
-
}),
|
|
195
|
-
name !== null ? /*#__PURE__*/ _jsx("div", {
|
|
196
|
-
className: "xp-slot-version-rename",
|
|
197
|
-
children: /*#__PURE__*/ _jsx(TextInput, {
|
|
198
|
-
id: `${id}-name`,
|
|
199
|
-
label: C.renameLabel,
|
|
200
|
-
autoFocus: true,
|
|
201
|
-
value: name,
|
|
202
|
-
disabled: writes.busy,
|
|
203
|
-
error: invalid ? C.emptyLabel : undefined,
|
|
204
|
-
onChange: (event)=>{
|
|
205
|
-
setName(event.target.value);
|
|
339
|
+
/*#__PURE__*/ _jsx(TextInput, {
|
|
340
|
+
id: id,
|
|
341
|
+
label: C.name,
|
|
342
|
+
"aria-label": `${arm.label} ${C.name}`,
|
|
343
|
+
value: name,
|
|
344
|
+
readOnly: !editable || writes.busy,
|
|
345
|
+
"aria-disabled": !editable || writes.busy || undefined,
|
|
346
|
+
"aria-describedby": [
|
|
347
|
+
lockId,
|
|
348
|
+
saved ? `${id}-saved` : undefined
|
|
349
|
+
].filter(Boolean).join(' ') || undefined,
|
|
350
|
+
"aria-errormessage": message ? `${id}-error` : undefined,
|
|
351
|
+
error: message,
|
|
352
|
+
onChange: (event)=>{
|
|
353
|
+
if (!editable || writes.busy) return;
|
|
354
|
+
draft.current = event.target.value;
|
|
355
|
+
setName(event.target.value);
|
|
356
|
+
setInvalid(false);
|
|
357
|
+
setError(undefined);
|
|
358
|
+
setSaved(false);
|
|
359
|
+
},
|
|
360
|
+
onBlur: ()=>void commit(),
|
|
361
|
+
onKeyDown: (event)=>{
|
|
362
|
+
if (event.key === 'Enter') {
|
|
363
|
+
event.preventDefault();
|
|
364
|
+
void commit();
|
|
365
|
+
}
|
|
366
|
+
if (event.key === 'Escape') {
|
|
367
|
+
event.preventDefault();
|
|
368
|
+
if (pending.current?.started) return;
|
|
369
|
+
if (pending.current) pending.current.cancelled = true;
|
|
370
|
+
draft.current = arm.label;
|
|
371
|
+
setName(arm.label);
|
|
206
372
|
setInvalid(false);
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
if (event.key === 'Enter') {
|
|
210
|
-
event.preventDefault();
|
|
211
|
-
void rename();
|
|
212
|
-
}
|
|
373
|
+
setError(undefined);
|
|
374
|
+
setSaved(false);
|
|
213
375
|
}
|
|
214
|
-
}
|
|
215
|
-
})
|
|
376
|
+
}
|
|
377
|
+
}),
|
|
378
|
+
/*#__PURE__*/ _jsx("span", {
|
|
379
|
+
id: `${id}-saved`,
|
|
380
|
+
role: "status",
|
|
381
|
+
className: "xp-ui-help xp-slot-version-saved",
|
|
382
|
+
children: saved ? C.saved : ''
|
|
383
|
+
})
|
|
216
384
|
]
|
|
217
385
|
});
|
|
218
386
|
}
|
|
219
387
|
export function RemoveVersion({ arm, writes, count, shared, onRemove, onClose }) {
|
|
220
388
|
const slot = arm.key === 'holdout' ? undefined : arm.key;
|
|
221
|
-
const
|
|
389
|
+
const close = ()=>{
|
|
390
|
+
writes.clearError(`remove:${arm.key}`);
|
|
391
|
+
onClose();
|
|
392
|
+
};
|
|
222
393
|
return /*#__PURE__*/ _jsx(Dialog, {
|
|
223
394
|
open: true,
|
|
224
395
|
title: C.removeTitle(arm.label),
|
|
225
396
|
initialFocus: "cancel",
|
|
226
397
|
dismissible: !writes.busy,
|
|
227
|
-
onClose:
|
|
398
|
+
onClose: close,
|
|
228
399
|
children: /*#__PURE__*/ _jsxs("div", {
|
|
229
400
|
className: "xp-slot-drawer",
|
|
230
401
|
children: [
|
|
@@ -236,29 +407,34 @@ export function RemoveVersion({ arm, writes, count, shared, onRemove, onClose })
|
|
|
236
407
|
}) : shared ? /*#__PURE__*/ _jsx("p", {
|
|
237
408
|
children: C.removeShared
|
|
238
409
|
}) : null,
|
|
239
|
-
|
|
410
|
+
writes.errorFor(`remove:${arm.key}`) ? /*#__PURE__*/ _jsx("p", {
|
|
240
411
|
role: "alert",
|
|
241
412
|
className: "xp-ui-error",
|
|
242
|
-
children: writes.
|
|
413
|
+
children: writes.errorFor(`remove:${arm.key}`)
|
|
243
414
|
}) : null,
|
|
244
415
|
/*#__PURE__*/ _jsxs("div", {
|
|
245
416
|
className: "xp-ui-button-group",
|
|
246
417
|
children: [
|
|
247
418
|
/*#__PURE__*/ _jsx(Button, {
|
|
248
419
|
"data-dialog-cancel": true,
|
|
249
|
-
disabled: writes.busy,
|
|
250
|
-
onClick: ()=>
|
|
420
|
+
"aria-disabled": writes.busy || undefined,
|
|
421
|
+
onClick: ()=>{
|
|
422
|
+
if (!writes.busy) close();
|
|
423
|
+
},
|
|
251
424
|
children: C.cancel
|
|
252
425
|
}),
|
|
253
426
|
/*#__PURE__*/ _jsx(Button, {
|
|
254
427
|
variant: "danger",
|
|
255
|
-
busy: writes.busy,
|
|
428
|
+
"aria-busy": writes.busy || undefined,
|
|
429
|
+
"aria-disabled": writes.busy || undefined,
|
|
256
430
|
onClick: async ()=>{
|
|
257
|
-
|
|
258
|
-
const saved = await writes.write((arms)=>
|
|
431
|
+
if (writes.busy) return;
|
|
432
|
+
const saved = await writes.write((arms)=>removeVersionArms(arms, arm.key), {
|
|
433
|
+
errorKey: `remove:${arm.key}`
|
|
434
|
+
});
|
|
259
435
|
if (saved) {
|
|
260
436
|
if (slot) onRemove(slot);
|
|
261
|
-
|
|
437
|
+
close();
|
|
262
438
|
}
|
|
263
439
|
},
|
|
264
440
|
children: C.remove
|
|
@@ -269,78 +445,139 @@ export function RemoveVersion({ arm, writes, count, shared, onRemove, onClose })
|
|
|
269
445
|
})
|
|
270
446
|
});
|
|
271
447
|
}
|
|
272
|
-
export function VersionWeights({ experiment, writes, edits, setEdits, groupId, splitIntent, editable = true, beforeSplit,
|
|
448
|
+
export function VersionWeights({ experiment, writes, edits, setEdits, groupId, splitIntent, editable = true, showSplit = editable, beforeSplit, beforeActions, renderRow }) {
|
|
273
449
|
const id = useId();
|
|
274
|
-
const
|
|
450
|
+
const lockId = useContext(VersionLockContext);
|
|
451
|
+
const [errors, setErrors] = useState({});
|
|
452
|
+
const armKeys = experiment.arms.map((arm)=>arm.key).join(',');
|
|
453
|
+
useEffect(()=>{
|
|
454
|
+
const keys = new Set(armKeys.split(','));
|
|
455
|
+
setErrors((current)=>Object.fromEntries(Object.entries(current).filter(([key])=>keys.has(key))));
|
|
456
|
+
}, [
|
|
457
|
+
armKeys
|
|
458
|
+
]);
|
|
459
|
+
const clearErrors = (keys)=>setErrors((current)=>Object.fromEntries(Object.entries(current).filter(([key])=>!keys.includes(key))));
|
|
275
460
|
const invalidKeys = new Set(Object.entries(edits).filter(([, raw])=>raw.trim() === '' || !Number.isInteger(Number(raw)) || Number(raw) < 0 || Number(raw) > 100).map(([key])=>key));
|
|
276
|
-
const apply = (arms)=>arms
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
const live = withSlotsFor(apply(experiment.arms), 'block');
|
|
461
|
+
const apply = (arms, key)=>balanceWeight(arms, key, Number(edits[key]));
|
|
462
|
+
const keys = Object.keys(edits);
|
|
463
|
+
const clearDraft = (key)=>setEdits((current)=>Object.fromEntries(Object.entries(current).filter(([candidate])=>candidate !== key)));
|
|
464
|
+
const live = withSlotsFor(keys.length === 1 && !invalidKeys.has(keys[0]) && !errors[keys[0]] ? apply(experiment.arms, keys[0]) : experiment.arms, 'block');
|
|
281
465
|
const issues = checkArms(live, 'block');
|
|
282
|
-
async function commit() {
|
|
283
|
-
if (!
|
|
284
|
-
|
|
466
|
+
async function commit(key) {
|
|
467
|
+
if (!editable || writes.busy || edits[key] === undefined || invalidKeys.has(key)) return;
|
|
468
|
+
clearErrors([
|
|
469
|
+
key
|
|
470
|
+
]);
|
|
471
|
+
const saved = await writes.write((arms)=>setVersionTraffic(arms, key, Number(edits[key])), {
|
|
472
|
+
onError: (message)=>setErrors((current)=>({
|
|
473
|
+
...current,
|
|
474
|
+
[key]: message
|
|
475
|
+
}))
|
|
476
|
+
});
|
|
477
|
+
if (saved) clearDraft(key);
|
|
285
478
|
}
|
|
286
479
|
return /*#__PURE__*/ _jsxs("div", {
|
|
287
480
|
className: "xp-slot-weights",
|
|
288
481
|
children: [
|
|
289
482
|
/*#__PURE__*/ _jsx("div", {
|
|
290
483
|
className: "xp-slot-weight-inputs",
|
|
291
|
-
children: experiment.arms.map((arm)
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
484
|
+
children: experiment.arms.map((arm)=>{
|
|
485
|
+
const input = /*#__PURE__*/ _jsx(NumberInput, {
|
|
486
|
+
id: `${id}-${arm.key}`,
|
|
487
|
+
label: C.traffic,
|
|
488
|
+
"aria-label": C.weight(arm.label),
|
|
489
|
+
min: 0,
|
|
490
|
+
max: 100,
|
|
491
|
+
step: 1,
|
|
492
|
+
value: edits[arm.key] ?? live.find((current)=>current.key === arm.key)?.weight ?? '',
|
|
493
|
+
readOnly: !editable || writes.busy,
|
|
494
|
+
"aria-disabled": !editable || writes.busy || undefined,
|
|
495
|
+
"aria-describedby": lockId,
|
|
496
|
+
error: invalidKeys.has(arm.key) ? C.invalidShare : errors[arm.key],
|
|
497
|
+
"aria-errormessage": invalidKeys.has(arm.key) || errors[arm.key] ? `${id}-${arm.key}-error` : undefined,
|
|
498
|
+
onChange: (event)=>{
|
|
499
|
+
if (!editable || writes.busy) return;
|
|
500
|
+
clearErrors([
|
|
501
|
+
arm.key
|
|
502
|
+
]);
|
|
503
|
+
const value = event.target.value;
|
|
504
|
+
setEdits((current)=>({
|
|
505
|
+
...current,
|
|
506
|
+
[arm.key]: value
|
|
507
|
+
}));
|
|
508
|
+
},
|
|
509
|
+
onBlur: (event)=>{
|
|
510
|
+
const target = event.relatedTarget;
|
|
511
|
+
if (!splitIntent.current && !(typeof target?.closest === 'function' && target.closest('[data-xp-split]')?.getAttribute('data-xp-split') === groupId)) void commit(arm.key);
|
|
512
|
+
},
|
|
513
|
+
onKeyDown: (event)=>{
|
|
514
|
+
if (event.key === 'Enter') {
|
|
515
|
+
event.preventDefault();
|
|
516
|
+
void commit(arm.key);
|
|
517
|
+
}
|
|
518
|
+
if (event.key === 'Escape' && !writes.busy) {
|
|
519
|
+
event.preventDefault();
|
|
520
|
+
clearErrors([
|
|
521
|
+
arm.key
|
|
522
|
+
]);
|
|
523
|
+
clearDraft(arm.key);
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
});
|
|
527
|
+
return /*#__PURE__*/ _jsx("div", {
|
|
528
|
+
className: "xp-slot-version-item",
|
|
529
|
+
children: renderRow ? renderRow(arm, /*#__PURE__*/ _jsxs("div", {
|
|
530
|
+
className: "xp-slot-version-traffic",
|
|
531
|
+
children: [
|
|
532
|
+
input,
|
|
533
|
+
/*#__PURE__*/ _jsx("span", {
|
|
534
|
+
className: "xp-slot-percent",
|
|
535
|
+
"aria-hidden": "true",
|
|
536
|
+
children: C.percent
|
|
537
|
+
})
|
|
538
|
+
]
|
|
539
|
+
})) : input
|
|
540
|
+
}, arm.key);
|
|
541
|
+
})
|
|
320
542
|
}),
|
|
321
543
|
Object.keys(edits).length && !invalidKeys.size ? issues.map((issue, i)=>/*#__PURE__*/ _jsx("p", {
|
|
322
544
|
role: "alert",
|
|
323
545
|
className: "xp-ui-error",
|
|
324
546
|
children: issueMessage(issue, totalWeight(live))
|
|
325
547
|
}, i)) : null,
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
548
|
+
beforeActions,
|
|
549
|
+
beforeSplit || showSplit ? /*#__PURE__*/ _jsxs("div", {
|
|
550
|
+
className: "xp-slot-version-actions",
|
|
551
|
+
children: [
|
|
552
|
+
beforeSplit,
|
|
553
|
+
showSplit ? /*#__PURE__*/ _jsx("div", {
|
|
554
|
+
"data-xp-split": groupId,
|
|
555
|
+
onPointerDownCapture: ()=>{
|
|
556
|
+
// Pointer intent reaches the destination before the source iframe loses focus.
|
|
557
|
+
if (!editable) return;
|
|
558
|
+
splitIntent.current = true;
|
|
559
|
+
setTimeout(()=>{
|
|
560
|
+
splitIntent.current = false;
|
|
561
|
+
}, 0);
|
|
562
|
+
},
|
|
563
|
+
children: /*#__PURE__*/ _jsx(Button, {
|
|
564
|
+
size: "sm",
|
|
565
|
+
"aria-describedby": lockId,
|
|
566
|
+
"aria-disabled": !editable || writes.busy || undefined,
|
|
567
|
+
onClick: async ()=>{
|
|
568
|
+
if (!editable || writes.busy) return;
|
|
569
|
+
const saved = await writes.write(splitEvenly, {
|
|
570
|
+
errorKey: 'split'
|
|
571
|
+
});
|
|
572
|
+
if (saved) {
|
|
573
|
+
setEdits(()=>({}));
|
|
574
|
+
setErrors({});
|
|
575
|
+
}
|
|
576
|
+
},
|
|
577
|
+
children: C.split
|
|
578
|
+
})
|
|
579
|
+
}) : null
|
|
580
|
+
]
|
|
344
581
|
}) : null
|
|
345
582
|
]
|
|
346
583
|
});
|