@multiplatform.one/components 9.7.0 → 9.8.0
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/cjs/actions/DestructiveAction.cjs +1 -0
- package/dist/cjs/actions/DestructiveAction.native.js +1 -0
- package/dist/cjs/actions/DestructiveAction.native.js.map +1 -1
- package/dist/cjs/feedback/ConfirmDialog.cjs +63 -28
- package/dist/cjs/feedback/ConfirmDialog.native.js +66 -31
- package/dist/cjs/feedback/ConfirmDialog.native.js.map +1 -1
- package/dist/esm/actions/DestructiveAction.mjs +1 -0
- package/dist/esm/actions/DestructiveAction.mjs.map +1 -1
- package/dist/esm/actions/DestructiveAction.native.js +1 -0
- package/dist/esm/actions/DestructiveAction.native.js.map +1 -1
- package/dist/esm/feedback/ConfirmDialog.mjs +67 -32
- package/dist/esm/feedback/ConfirmDialog.mjs.map +1 -1
- package/dist/esm/feedback/ConfirmDialog.native.js +70 -35
- package/dist/esm/feedback/ConfirmDialog.native.js.map +1 -1
- package/dist/jsx/actions/DestructiveAction.mjs +1 -0
- package/dist/jsx/actions/DestructiveAction.mjs.map +1 -1
- package/dist/jsx/actions/DestructiveAction.native.js +1 -0
- package/dist/jsx/actions/DestructiveAction.native.js.map +1 -1
- package/dist/jsx/feedback/ConfirmDialog.mjs +67 -32
- package/dist/jsx/feedback/ConfirmDialog.mjs.map +1 -1
- package/dist/jsx/feedback/ConfirmDialog.native.js +66 -31
- package/dist/jsx/feedback/ConfirmDialog.native.js.map +1 -1
- package/package.json +7 -7
- package/src/AlertDialogContent.stories.tsx +3 -5
- package/src/actions/DestructiveAction.spec.tsx +17 -0
- package/src/actions/DestructiveAction.tsx +1 -0
- package/src/feedback/ConfirmDialog.spec.tsx +67 -0
- package/src/feedback/ConfirmDialog.stories.tsx +11 -5
- package/src/feedback/ConfirmDialog.tsx +90 -35
- package/src/surfaces.spec.tsx +72 -0
- package/types/actions/DestructiveAction.d.ts.map +1 -1
- package/types/feedback/ConfirmDialog.d.ts +9 -1
- package/types/feedback/ConfirmDialog.d.ts.map +1 -1
|
@@ -38,6 +38,7 @@ var import_Dialog = require("../Dialog.native.js");
|
|
|
38
38
|
var import_actionScan = require("../shared/actionScan.native.js");
|
|
39
39
|
var import_useReturnFocusOnClose = require("../shared/useReturnFocusOnClose.native.js");
|
|
40
40
|
var import_useKeyboardInset = require("../shared/useKeyboardInset.native.js");
|
|
41
|
+
var import_StandardAction = require("../actions/StandardAction.native.js");
|
|
41
42
|
var import_surfaces = require("../surfaces.native.js");
|
|
42
43
|
function _instanceof(left, right) {
|
|
43
44
|
"@swc/helpers - instanceof";
|
|
@@ -122,6 +123,7 @@ function ConfirmDialog(param) {
|
|
|
122
123
|
children,
|
|
123
124
|
confirmLabel: confirmLabelProp,
|
|
124
125
|
cancelLabel: cancelLabelProp,
|
|
126
|
+
confirmKind,
|
|
125
127
|
onConfirm,
|
|
126
128
|
onCancel,
|
|
127
129
|
destructive = false,
|
|
@@ -169,6 +171,17 @@ function ConfirmDialog(param) {
|
|
|
169
171
|
}
|
|
170
172
|
onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(next);
|
|
171
173
|
};
|
|
174
|
+
var confirmId = (0, import_react.useId)();
|
|
175
|
+
var cancel = function cancel2() {
|
|
176
|
+
closeReason.current = "cancel";
|
|
177
|
+
handleOpenChange(false);
|
|
178
|
+
};
|
|
179
|
+
var confirm = function confirm2() {
|
|
180
|
+
if (confirmDisabled) return;
|
|
181
|
+
closeReason.current = "confirm";
|
|
182
|
+
onConfirm === null || onConfirm === void 0 ? void 0 : onConfirm();
|
|
183
|
+
handleOpenChange(false);
|
|
184
|
+
};
|
|
172
185
|
var handleOpenAutoFocus = (0, import_react.useCallback)(function (event) {
|
|
173
186
|
if (!import_tamagui.isWeb) return;
|
|
174
187
|
event.preventDefault();
|
|
@@ -248,41 +261,63 @@ function ConfirmDialog(param) {
|
|
|
248
261
|
...knobProps.gap,
|
|
249
262
|
children: description
|
|
250
263
|
})
|
|
251
|
-
}) : null, /* @__PURE__ */(0, import_jsx_runtime.
|
|
264
|
+
}) : null, /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_tamagui.XStack, {
|
|
252
265
|
...knobProps.gap,
|
|
253
266
|
justifyContent: "flex-end",
|
|
254
267
|
alignItems: "flex-start",
|
|
255
268
|
flexWrap: "wrap",
|
|
256
|
-
children:
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
|
|
269
|
+
children: confirmKind ? /* @__PURE__ */(0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {
|
|
270
|
+
children: [confirmDisabled && confirmDisabledReason ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_theme.SizableText, {
|
|
271
|
+
id: (0, import_forms.disabledReasonId)(confirmId),
|
|
272
|
+
size: "$2",
|
|
273
|
+
color: "$color11",
|
|
274
|
+
flexGrow: 1,
|
|
275
|
+
flexShrink: 1,
|
|
276
|
+
alignSelf: "center",
|
|
277
|
+
"data-mp-disabled-reason": "true",
|
|
278
|
+
children: confirmDisabledReason
|
|
279
|
+
}) : null, /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_StandardAction.ActionButton, {
|
|
280
|
+
kind: "cancel",
|
|
281
|
+
label: cancelLabel,
|
|
282
|
+
"data-mp-cancel-disabled-ignored": cancelDisabled ? "true" : void 0,
|
|
283
|
+
onPress: cancel
|
|
284
|
+
}), /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_StandardAction.ActionButton, {
|
|
285
|
+
kind: confirmKind,
|
|
286
|
+
label: confirmLabel,
|
|
287
|
+
error: destructive || void 0,
|
|
288
|
+
warning: !destructive && warning || void 0,
|
|
289
|
+
disabled: confirmDisabled || void 0,
|
|
290
|
+
id: confirmId,
|
|
291
|
+
disabledReason: confirmDisabled ? confirmDisabledReason : void 0,
|
|
292
|
+
disabledReasonPlacement: "external",
|
|
293
|
+
"aria-disabled": confirmDisabled || void 0,
|
|
294
|
+
"data-mp-confirm-disabled": confirmDisabled ? "true" : void 0,
|
|
295
|
+
onPress: confirm
|
|
296
|
+
})]
|
|
297
|
+
}) : /* @__PURE__ */(0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {
|
|
298
|
+
children: [/* @__PURE__ */(0, import_jsx_runtime.jsx)(import_forms.Button, {
|
|
299
|
+
chromeless: true,
|
|
300
|
+
size: "$3",
|
|
301
|
+
// DG-ACT-05: never disabled; `cancelDisabled` requests are ignored.
|
|
302
|
+
"data-mp-cancel-disabled-ignored": cancelDisabled ? "true" : void 0,
|
|
303
|
+
onPress: cancel,
|
|
304
|
+
children: cancelLabel
|
|
305
|
+
}), /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_forms.Button, {
|
|
306
|
+
size: "$3",
|
|
307
|
+
accent: !destructive && !warning,
|
|
308
|
+
error: destructive,
|
|
309
|
+
warning: !destructive && warning,
|
|
310
|
+
actionRole: "primary",
|
|
311
|
+
disabled: confirmDisabled || void 0,
|
|
312
|
+
// DG-ST-03: gated confirm explains itself (visible reason,
|
|
313
|
+
// no hover) instead of dangling as a bare-disabled dead end.
|
|
314
|
+
disabledReason: confirmDisabled ? confirmDisabledReason : void 0,
|
|
315
|
+
"aria-disabled": confirmDisabled || void 0,
|
|
316
|
+
"data-mp-confirm-disabled": confirmDisabled ? "true" : void 0,
|
|
317
|
+
onPress: confirm,
|
|
318
|
+
children: confirmLabel
|
|
319
|
+
})]
|
|
320
|
+
})
|
|
286
321
|
})]
|
|
287
322
|
}, "content")]
|
|
288
323
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__defProp","Object","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__hasOwnProp","prototype","hasOwnProperty","__export","target","all","name","get","enumerable","__copyProps","to","from","except","desc","key","call","__toCommonJS","mod","value","ConfirmDialog_exports","ConfirmDialog","confirmDialogPresentation","module","exports","import_jsx_runtime","require","import_forms","import_theme","import_react","import_i18n","import_tamagui","import_Dialog","import_actionScan","import_useReturnFocusOnClose","import_useKeyboardInset","import_surfaces","_instanceof","left","right","Symbol","hasInstance","TAB_STOPS","asHtml","node","HTMLElement","panelNode","ref","fromRef","document","querySelector","isTextEntry","el","tag","tagName","isContentEditable","role","getAttribute","Boolean","firstTabStop","root","nodes","querySelectorAll","_iteratorNormalCompletion","_didIteratorError","_iteratorError","_iterator","iterator","_step","next","done","closest","err","return","applyOpenFocus","panel","keyboard","wasKeyboardFocus","first","toControl","focus","preventScroll","focusVisible","param","body","children","open","onOpenChange","title","confirmLabel","confirmLabelProp","cancelLabel","cancelLabelProp","onConfirm","onCancel","destructive","warning","confirmDisabled","confirmDisabledReason","cancelDisabled","allowManyActions","phonePresentation","t","useTranslation","knobProps","useResolvedKnobs","keyboardInset","useKeyboardInset","description","contentRef","useRef","closeReason","ensureKeyboardModalityTracking","useReturnFocusOnClose","useEffect","warnCancelDisabled","disabled","component","warnDialogTooManyActions","count","countActionsInTree","handleOpenChange","handleOpenChange2","current","handleOpenAutoFocus","useCallback","event","isWeb","preventDefault","cancelled","frames","run","run1","requestAnimationFrame","jsx","Dialog","modal","jsxs","Portal","paddingBottom","DialogOverlay","DialogContent","width","maxWidth","tabIndex","outlineWidth","focusStyle","focusVisibleStyle","sizeToken","onPointerDownOutside","e","onInteractOutside","onOpenAutoFocus","Title","label","heading","color"],"sources":["../../../src/feedback/ConfirmDialog.tsx"],"sourcesContent":[null],"mappings":"AAmBA,YAAS;;AACT,IAAAA,SAAA,GAAAC,MAAA,CAAAC,cAAA;AAAA,IACEC,gBAAA,GAAAF,MAAA,CAAAG,wBAAA;AAAA,IACAC,iBAAA,GAAAJ,MAAA,CAAAK,mBAAA;AAAA,IACAC,YAAA,GAAAN,MAAA,CAAAO,SAAA,CAAAC,cAAA;AAAA,IACAC,QAAA,GAAAA,CAAAC,MAAA,EAAAC,GAAA;EACA,SAAAC,IAAA,IAAAD,GAAA,
|
|
1
|
+
{"version":3,"names":["__defProp","Object","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__hasOwnProp","prototype","hasOwnProperty","__export","target","all","name","get","enumerable","__copyProps","to","from","except","desc","key","call","__toCommonJS","mod","value","ConfirmDialog_exports","ConfirmDialog","confirmDialogPresentation","module","exports","import_jsx_runtime","require","import_forms","import_theme","import_react","import_i18n","import_tamagui","import_Dialog","import_actionScan","import_useReturnFocusOnClose","import_useKeyboardInset","import_StandardAction","import_surfaces","_instanceof","left","right","Symbol","hasInstance","TAB_STOPS","asHtml","node","HTMLElement","panelNode","ref","fromRef","document","querySelector","isTextEntry","el","tag","tagName","isContentEditable","role","getAttribute","Boolean","firstTabStop","root","nodes","querySelectorAll","_iteratorNormalCompletion","_didIteratorError","_iteratorError","_iterator","iterator","_step","next","done","closest","err","return","applyOpenFocus","panel","keyboard","wasKeyboardFocus","first","toControl","focus","preventScroll","focusVisible","param","body","children","open","onOpenChange","title","confirmLabel","confirmLabelProp","cancelLabel","cancelLabelProp","confirmKind","onConfirm","onCancel","destructive","warning","confirmDisabled","confirmDisabledReason","cancelDisabled","allowManyActions","phonePresentation","t","useTranslation","knobProps","useResolvedKnobs","keyboardInset","useKeyboardInset","description","contentRef","useRef","closeReason","ensureKeyboardModalityTracking","useReturnFocusOnClose","useEffect","warnCancelDisabled","disabled","component","warnDialogTooManyActions","count","countActionsInTree","handleOpenChange","handleOpenChange2","current","confirmId","useId","cancel","cancel2","confirm","confirm2","handleOpenAutoFocus","useCallback","event","isWeb","preventDefault","cancelled","frames","run","run1","requestAnimationFrame","jsx","Dialog","modal","jsxs","Portal","paddingBottom","DialogOverlay","DialogContent","width","maxWidth","tabIndex","outlineWidth","focusStyle","focusVisibleStyle","sizeToken","onPointerDownOutside","e","onInteractOutside","onOpenAutoFocus","Title","label","heading","color","Description","asChild","Paragraph","YStack","gap","XStack","justifyContent","alignItems","flexWrap","Fragment","SizableText","id","disabledReasonId","size","flexGrow","flexShrink","alignSelf","ActionButton","kind"],"sources":["../../../src/feedback/ConfirmDialog.tsx"],"sourcesContent":[null],"mappings":"AAmBA,YAAS;;AACT,IAAAA,SAAA,GAAAC,MAAA,CAAAC,cAAA;AAAA,IACEC,gBAAA,GAAAF,MAAA,CAAAG,wBAAA;AAAA,IACAC,iBAAA,GAAAJ,MAAA,CAAAK,mBAAA;AAAA,IACAC,YAAA,GAAAN,MAAA,CAAAO,SAAA,CAAAC,cAAA;AAAA,IACAC,QAAA,GAAAA,CAAAC,MAAA,EAAAC,GAAA;EACA,SAAAC,IAAA,IAAAD,GAAA,EACAZ,SAAA,CAAAW,MAAA,EAAAE,IAAA;IAAAC,GAAA,EAAAF,GAAA,CAAAC,IAAA;IAAAE,UAAA;EAAA;AAAA;AAEF,IAAAC,WAAS,GAAAA,CAAAC,EAAA,EAAaC,IAAA,EAAAC,MAAW,EAAAC,IAAO;EACxC,IAAAF,IAAS,WAAAA,IAAA,aAAsB,WAAAA,IAAA;IAC/B,KAAS,IAAAG,GAAA,IAAWhB,iBAAgB,CAAAa,IAAA,GACpC,IAAS,CAAAX,YAA4C,CAAAe,IAAA,CAAAL,EAAA,EAAAI,GAAA,KAAAA,GAAA,KAAAF,MAAA,EACrDnB,SAAS,CAAAiB,EAAA,EAAAI,GAAA;MAAAP,GAAA,EAAAA,CAAA,KAA0BI,IAAA,CAAAG,GAAA;MAAAN,UAAA,IAAAK,IAAA,GAAAjB,gBAAA,CAAAe,IAAA,EAAAG,GAAA,MAAAD,IAAA,CAAAL;IAAA;EAC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AAxH,kBAAA,CAAAqJ,QAAA;YAAAxF,QAAA,GAAAa,eACH,IAAAC,qBAAA,sBAAA3E,kBAAA,CAAAqH,GAAA,EAAAlH,YAAA,CAAAmJ,WAAA;cAAAC,EACF,MAAArJ,YAAA,CAAAsJ,gBAAA,EAAAnD,SAAA;cAAAoD,IAAA;cAEJd,KAAA;cAAAe,QAAA;cAAAC,UAAA;cAzGIC,SAAA;cA0GN;cACF/F,QAAA,EAAAc;YAAA,WACF,mBAAA3E,kBAAA,CAAAqH,GAAA,EAAA1G,qBAAA,CAAAkJ,YAAA;cAEJC,IAAA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@multiplatform.one/components",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.8.0",
|
|
4
4
|
"description": "multiplatform.one ui components",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"components",
|
|
@@ -70,9 +70,9 @@
|
|
|
70
70
|
},
|
|
71
71
|
"dependencies": {
|
|
72
72
|
"@floating-ui/react": "^0.27.20",
|
|
73
|
-
"@multiplatform.one/forms": "^9.
|
|
74
|
-
"@multiplatform.one/platform": "^9.
|
|
75
|
-
"@multiplatform.one/theme": "^9.
|
|
73
|
+
"@multiplatform.one/forms": "^9.8.0",
|
|
74
|
+
"@multiplatform.one/platform": "^9.8.0",
|
|
75
|
+
"@multiplatform.one/theme": "^9.8.0",
|
|
76
76
|
"@phosphor-icons/react": "^2.1.10",
|
|
77
77
|
"@shopify/flash-list": "^2.3.1",
|
|
78
78
|
"@tamagui/colors": "2.7.6",
|
|
@@ -99,9 +99,9 @@
|
|
|
99
99
|
"tamagui": "2.7.6"
|
|
100
100
|
},
|
|
101
101
|
"devDependencies": {
|
|
102
|
-
"@multiplatform.one/config": "9.
|
|
103
|
-
"@multiplatform.one/storybook": "9.
|
|
104
|
-
"@multiplatform.one/test-utils": "9.
|
|
102
|
+
"@multiplatform.one/config": "9.8.0",
|
|
103
|
+
"@multiplatform.one/storybook": "9.8.0",
|
|
104
|
+
"@multiplatform.one/test-utils": "9.8.0",
|
|
105
105
|
"@tamagui/build": "2.7.6",
|
|
106
106
|
"@testing-library/jest-dom": "^7.0.1",
|
|
107
107
|
"@testing-library/react": "^16.3.3",
|
|
@@ -16,17 +16,15 @@ function AlertDialogHarness({ startOpen = true }: { startOpen?: boolean }) {
|
|
|
16
16
|
</AlertDialog.Trigger>
|
|
17
17
|
<AlertDialog.Portal>
|
|
18
18
|
<AlertDialogOverlay key="overlay" />
|
|
19
|
-
<AlertDialogContent key="content"
|
|
19
|
+
<AlertDialogContent key="content" role="alertdialog">
|
|
20
20
|
<AlertDialog.Title>Delete customer?</AlertDialog.Title>
|
|
21
|
-
<AlertDialog.Description>
|
|
22
|
-
This removes the customer record. This cannot be undone.
|
|
23
|
-
</AlertDialog.Description>
|
|
21
|
+
<AlertDialog.Description>This cannot be undone.</AlertDialog.Description>
|
|
24
22
|
<XStack justifyContent="flex-end" alignItems="center" gap="$2">
|
|
25
23
|
<AlertDialog.Cancel asChild>
|
|
26
24
|
<ActionButton kind="cancel" />
|
|
27
25
|
</AlertDialog.Cancel>
|
|
28
26
|
<AlertDialog.Action asChild>
|
|
29
|
-
<
|
|
27
|
+
<ActionButton kind="delete" label="Delete customer" error />
|
|
30
28
|
</AlertDialog.Action>
|
|
31
29
|
</XStack>
|
|
32
30
|
</AlertDialogContent>
|
|
@@ -27,6 +27,8 @@ function alertdialog(): Element | null {
|
|
|
27
27
|
function dialogButtonByLabel(label: string): Element {
|
|
28
28
|
const scope = alertdialog() ?? root();
|
|
29
29
|
const buttons = Array.from(scope.querySelectorAll('[role="button"]'));
|
|
30
|
+
const named = buttons.find((b) => b.getAttribute("aria-label") === label);
|
|
31
|
+
if (named) return named;
|
|
30
32
|
const exact = buttons.find((b) => b.textContent?.trim() === label);
|
|
31
33
|
if (exact) return exact;
|
|
32
34
|
const match = buttons.find((b) => b.textContent?.includes(label));
|
|
@@ -223,6 +225,21 @@ describe("DestructiveAction", () => {
|
|
|
223
225
|
expect(onAction).not.toHaveBeenCalled();
|
|
224
226
|
});
|
|
225
227
|
|
|
228
|
+
it("confirms a delete with the trash glyph (LC-260, FZ-9338)", async () => {
|
|
229
|
+
renderWithProviders(<DestructiveAction verb="Delete" noun="customer" onAction={() => {}} />);
|
|
230
|
+
fireEvent.click(screen.getByText("Delete customer"));
|
|
231
|
+
await waitFor(() => expect(alertdialog()).toBeTruthy());
|
|
232
|
+
expect(dialogButtonByLabel("Delete").getAttribute("data-mp-action")).toBe("delete");
|
|
233
|
+
expect(dialogButtonByLabel("Cancel").getAttribute("data-mp-action")).toBe("cancel");
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
it("keeps words for a verb with no standard symbol", async () => {
|
|
237
|
+
renderWithProviders(<DestructiveAction verb="Uninstall" noun="stack" onAction={() => {}} />);
|
|
238
|
+
fireEvent.click(screen.getByText("Uninstall stack"));
|
|
239
|
+
await waitFor(() => expect(alertdialog()).toBeTruthy());
|
|
240
|
+
expect(alertdialog()?.querySelector("[data-mp-action]")).toBeNull();
|
|
241
|
+
});
|
|
242
|
+
|
|
226
243
|
it("typed-confirm gate explains the disabled confirm (DG-ST-03)", async () => {
|
|
227
244
|
const onAction = vi.fn();
|
|
228
245
|
renderWithProviders(
|
|
@@ -255,6 +255,7 @@ export function DestructiveAction({
|
|
|
255
255
|
body={dialogBody}
|
|
256
256
|
confirmLabel={dialogCtx.confirmLabel}
|
|
257
257
|
cancelLabel={t("Cancel")}
|
|
258
|
+
confirmKind={dialogCtx.verb.trim().toLowerCase() === "delete" ? "delete" : undefined}
|
|
258
259
|
destructive
|
|
259
260
|
confirmDisabled={Boolean(dialogCtx.expectedText) && !typedMatch}
|
|
260
261
|
// DG-ST-03: the typed-confirm gate explains itself — the expected
|
|
@@ -68,6 +68,73 @@ describe("ConfirmDialog", () => {
|
|
|
68
68
|
expect(buttonByLabel("Cancel")).toBeTruthy();
|
|
69
69
|
});
|
|
70
70
|
|
|
71
|
+
it("draws a delete confirm as a trash glyph and cancel as ✕ (LC-260, FZ-9338)", () => {
|
|
72
|
+
const onConfirm = vi.fn();
|
|
73
|
+
const onCancel = vi.fn();
|
|
74
|
+
renderWithProviders(
|
|
75
|
+
<ConfirmDialog
|
|
76
|
+
open
|
|
77
|
+
title="Delete customer?"
|
|
78
|
+
body="This cannot be undone."
|
|
79
|
+
confirmLabel="Delete"
|
|
80
|
+
cancelLabel="Cancel"
|
|
81
|
+
confirmKind="delete"
|
|
82
|
+
destructive
|
|
83
|
+
onConfirm={onConfirm}
|
|
84
|
+
onCancel={onCancel}
|
|
85
|
+
/>,
|
|
86
|
+
);
|
|
87
|
+
const dialog = alertdialog() as HTMLElement;
|
|
88
|
+
const trash = dialog.querySelector('[data-mp-action="delete"]') as HTMLElement;
|
|
89
|
+
const close = dialog.querySelector('[data-mp-action="cancel"]') as HTMLElement;
|
|
90
|
+
expect(trash.getAttribute("aria-label")).toBe("Delete");
|
|
91
|
+
expect(close.getAttribute("aria-label")).toBe("Cancel");
|
|
92
|
+
expect(trash.textContent ?? "").not.toContain("Delete");
|
|
93
|
+
expect(close.textContent ?? "").not.toContain("Cancel");
|
|
94
|
+
fireEvent.click(close);
|
|
95
|
+
expect(onCancel).toHaveBeenCalledTimes(1);
|
|
96
|
+
expect(onConfirm).not.toHaveBeenCalled();
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it("leads a gated glyph row with its reason, named by the trash (DG-ST-03)", () => {
|
|
100
|
+
renderWithProviders(
|
|
101
|
+
<ConfirmDialog
|
|
102
|
+
open
|
|
103
|
+
title="Delete project acme?"
|
|
104
|
+
confirmLabel="Delete"
|
|
105
|
+
confirmKind="delete"
|
|
106
|
+
destructive
|
|
107
|
+
confirmDisabled
|
|
108
|
+
confirmDisabledReason='Type "acme" to confirm.'
|
|
109
|
+
/>,
|
|
110
|
+
);
|
|
111
|
+
const dialog = alertdialog() as HTMLElement;
|
|
112
|
+
const reasons = dialog.querySelectorAll("[data-mp-disabled-reason]");
|
|
113
|
+
expect(reasons).toHaveLength(1);
|
|
114
|
+
const reason = reasons[0] as HTMLElement;
|
|
115
|
+
const trash = dialog.querySelector('[data-mp-action="delete"]') as HTMLElement;
|
|
116
|
+
expect(trash.getAttribute("aria-describedby")).toBe(reason.id);
|
|
117
|
+
expect(reason.textContent).toBe('Type "acme" to confirm.');
|
|
118
|
+
const row = Array.from(reason.parentElement?.children ?? []);
|
|
119
|
+
expect(row.indexOf(reason)).toBe(0);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it("runs onConfirm from the trash glyph", () => {
|
|
123
|
+
const onConfirm = vi.fn();
|
|
124
|
+
renderWithProviders(
|
|
125
|
+
<ConfirmDialog
|
|
126
|
+
open
|
|
127
|
+
title="Delete customer?"
|
|
128
|
+
confirmLabel="Delete"
|
|
129
|
+
confirmKind="delete"
|
|
130
|
+
destructive
|
|
131
|
+
onConfirm={onConfirm}
|
|
132
|
+
/>,
|
|
133
|
+
);
|
|
134
|
+
fireEvent.click(alertdialog()?.querySelector('[data-mp-action="delete"]') as HTMLElement);
|
|
135
|
+
expect(onConfirm).toHaveBeenCalledTimes(1);
|
|
136
|
+
});
|
|
137
|
+
|
|
71
138
|
it("calls onConfirm and closes on confirm press", () => {
|
|
72
139
|
const onConfirm = vi.fn();
|
|
73
140
|
const onCancel = vi.fn();
|
|
@@ -58,9 +58,10 @@ function ConfirmHarness({
|
|
|
58
58
|
startOpen = true,
|
|
59
59
|
confirmLabel = "Delete",
|
|
60
60
|
title = "Delete customer?",
|
|
61
|
-
body = "This
|
|
61
|
+
body = "This cannot be undone.",
|
|
62
62
|
confirmDisabled = false,
|
|
63
63
|
confirmDisabledReason,
|
|
64
|
+
confirmKind,
|
|
64
65
|
overPage = false,
|
|
65
66
|
}: {
|
|
66
67
|
destructive?: boolean;
|
|
@@ -71,6 +72,7 @@ function ConfirmHarness({
|
|
|
71
72
|
body?: string;
|
|
72
73
|
confirmDisabled?: boolean;
|
|
73
74
|
confirmDisabledReason?: string;
|
|
75
|
+
confirmKind?: "delete";
|
|
74
76
|
overPage?: boolean;
|
|
75
77
|
}) {
|
|
76
78
|
const [open, setOpen] = useState(startOpen);
|
|
@@ -94,6 +96,7 @@ function ConfirmHarness({
|
|
|
94
96
|
warning={warning}
|
|
95
97
|
confirmDisabled={confirmDisabled}
|
|
96
98
|
confirmDisabledReason={confirmDisabledReason}
|
|
99
|
+
confirmKind={confirmKind}
|
|
97
100
|
onConfirm={() => action("confirm")()}
|
|
98
101
|
onCancel={() => action("cancel")()}
|
|
99
102
|
/>
|
|
@@ -114,12 +117,14 @@ export const Default: Story = {
|
|
|
114
117
|
};
|
|
115
118
|
|
|
116
119
|
export const Destructive: Story = {
|
|
117
|
-
render: () => <ConfirmHarness destructive />,
|
|
120
|
+
render: () => <ConfirmHarness destructive confirmKind="delete" />,
|
|
118
121
|
};
|
|
119
122
|
|
|
120
123
|
export const OverPage: Story = {
|
|
121
124
|
name: "Over a page",
|
|
122
|
-
render: () =>
|
|
125
|
+
render: () => (
|
|
126
|
+
<ConfirmHarness destructive confirmKind="delete" overPage body="This cannot be undone." />
|
|
127
|
+
),
|
|
123
128
|
};
|
|
124
129
|
|
|
125
130
|
export const Warning: Story = {
|
|
@@ -139,9 +144,10 @@ export const Gated: Story = {
|
|
|
139
144
|
destructive
|
|
140
145
|
confirmLabel="Delete"
|
|
141
146
|
title="Delete project acme?"
|
|
142
|
-
body="
|
|
147
|
+
body="This cannot be undone."
|
|
143
148
|
confirmDisabled
|
|
144
149
|
confirmDisabledReason='Type "acme" to confirm.'
|
|
150
|
+
confirmKind="delete"
|
|
145
151
|
/>
|
|
146
152
|
),
|
|
147
153
|
};
|
|
@@ -151,7 +157,7 @@ function ConfirmInSheetDemo() {
|
|
|
151
157
|
const [confirming, setConfirming] = useState(false);
|
|
152
158
|
const [applied, setApplied] = useState(0);
|
|
153
159
|
return (
|
|
154
|
-
<YStack minHeight={360} gap="$3" padding=
|
|
160
|
+
<YStack minHeight={360} gap="$3" padding="$4" alignItems="flex-start">
|
|
155
161
|
<Button size="$3" onPress={() => setSheetOpen(true)}>
|
|
156
162
|
Open sheet
|
|
157
163
|
</Button>
|
|
@@ -17,21 +17,23 @@
|
|
|
17
17
|
* `dialog-too-many-actions` unless `allowManyActions` ejects (DG-OVL-04).
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
import { Button } from "@multiplatform.one/forms";
|
|
20
|
+
import { Button, disabledReasonId, type StandardActionKind } from "@multiplatform.one/forms";
|
|
21
21
|
import {
|
|
22
22
|
ensureKeyboardModalityTracking,
|
|
23
|
+
SizableText,
|
|
23
24
|
useResolvedKnobs,
|
|
24
25
|
warnCancelDisabled,
|
|
25
26
|
warnDialogTooManyActions,
|
|
26
27
|
wasKeyboardFocus,
|
|
27
28
|
} from "@multiplatform.one/theme";
|
|
28
|
-
import { useCallback, useEffect, useRef, type ReactNode } from "react";
|
|
29
|
+
import { useCallback, useEffect, useId, useRef, type ReactNode } from "react";
|
|
29
30
|
import { useTranslation } from "../shared/i18n";
|
|
30
31
|
import { Paragraph, XStack, YStack, isWeb, type TamaguiElement } from "tamagui";
|
|
31
32
|
import { Dialog, type DialogPhonePresentation } from "../Dialog";
|
|
32
33
|
import { countActionsInTree } from "../shared/actionScan";
|
|
33
34
|
import { useReturnFocusOnClose } from "../shared/useReturnFocusOnClose";
|
|
34
35
|
import { useKeyboardInset } from "../shared/useKeyboardInset";
|
|
36
|
+
import { ActionButton } from "../actions/StandardAction";
|
|
35
37
|
import { DialogContent, DialogOverlay } from "../surfaces";
|
|
36
38
|
|
|
37
39
|
const TAB_STOPS =
|
|
@@ -92,6 +94,13 @@ export interface ConfirmDialogProps {
|
|
|
92
94
|
confirmLabel?: string;
|
|
93
95
|
/** Cancel button label (default "Cancel"). */
|
|
94
96
|
cancelLabel?: string;
|
|
97
|
+
/**
|
|
98
|
+
* LC-260: the confirm's standard symbol. Set, the confirm draws that glyph
|
|
99
|
+
* (`delete` a trash in error ink when `destructive`) named by `confirmLabel`,
|
|
100
|
+
* and cancel draws ✕ named by `cancelLabel`. Unset, both stay words, for a
|
|
101
|
+
* verb with no unambiguous symbol ("Uninstall", "Leave anyway").
|
|
102
|
+
*/
|
|
103
|
+
confirmKind?: StandardActionKind;
|
|
95
104
|
/** Fired when the confirm button is pressed (dialog closes after). */
|
|
96
105
|
onConfirm?: () => void;
|
|
97
106
|
/** Fired when cancel / Escape closes the dialog. */
|
|
@@ -153,6 +162,7 @@ export function ConfirmDialog({
|
|
|
153
162
|
children,
|
|
154
163
|
confirmLabel: confirmLabelProp,
|
|
155
164
|
cancelLabel: cancelLabelProp,
|
|
165
|
+
confirmKind,
|
|
156
166
|
onConfirm,
|
|
157
167
|
onCancel,
|
|
158
168
|
destructive = false,
|
|
@@ -206,6 +216,20 @@ export function ConfirmDialog({
|
|
|
206
216
|
onOpenChange?.(next);
|
|
207
217
|
};
|
|
208
218
|
|
|
219
|
+
const confirmId = useId();
|
|
220
|
+
|
|
221
|
+
const cancel = () => {
|
|
222
|
+
closeReason.current = "cancel";
|
|
223
|
+
handleOpenChange(false);
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
const confirm = () => {
|
|
227
|
+
if (confirmDisabled) return;
|
|
228
|
+
closeReason.current = "confirm";
|
|
229
|
+
onConfirm?.();
|
|
230
|
+
handleOpenChange(false);
|
|
231
|
+
};
|
|
232
|
+
|
|
209
233
|
const handleOpenAutoFocus = useCallback((event: Event) => {
|
|
210
234
|
if (!isWeb) return;
|
|
211
235
|
event.preventDefault();
|
|
@@ -287,39 +311,70 @@ export function ConfirmDialog({
|
|
|
287
311
|
alignItems="flex-start"
|
|
288
312
|
flexWrap="wrap"
|
|
289
313
|
>
|
|
290
|
-
|
|
291
|
-
|
|
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
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
314
|
+
{confirmKind ? (
|
|
315
|
+
<>
|
|
316
|
+
{confirmDisabled && confirmDisabledReason ? (
|
|
317
|
+
<SizableText
|
|
318
|
+
id={disabledReasonId(confirmId)}
|
|
319
|
+
size="$2"
|
|
320
|
+
color="$color11"
|
|
321
|
+
flexGrow={1}
|
|
322
|
+
flexShrink={1}
|
|
323
|
+
alignSelf="center"
|
|
324
|
+
data-mp-disabled-reason="true"
|
|
325
|
+
>
|
|
326
|
+
{confirmDisabledReason}
|
|
327
|
+
</SizableText>
|
|
328
|
+
) : null}
|
|
329
|
+
<ActionButton
|
|
330
|
+
kind="cancel"
|
|
331
|
+
label={cancelLabel}
|
|
332
|
+
data-mp-cancel-disabled-ignored={cancelDisabled ? "true" : undefined}
|
|
333
|
+
onPress={cancel}
|
|
334
|
+
/>
|
|
335
|
+
<ActionButton
|
|
336
|
+
kind={confirmKind}
|
|
337
|
+
label={confirmLabel}
|
|
338
|
+
error={destructive || undefined}
|
|
339
|
+
warning={(!destructive && warning) || undefined}
|
|
340
|
+
disabled={confirmDisabled || undefined}
|
|
341
|
+
id={confirmId}
|
|
342
|
+
disabledReason={confirmDisabled ? confirmDisabledReason : undefined}
|
|
343
|
+
disabledReasonPlacement="external"
|
|
344
|
+
aria-disabled={confirmDisabled || undefined}
|
|
345
|
+
data-mp-confirm-disabled={confirmDisabled ? "true" : undefined}
|
|
346
|
+
onPress={confirm}
|
|
347
|
+
/>
|
|
348
|
+
</>
|
|
349
|
+
) : (
|
|
350
|
+
<>
|
|
351
|
+
<Button
|
|
352
|
+
chromeless
|
|
353
|
+
size="$3"
|
|
354
|
+
// DG-ACT-05: never disabled; `cancelDisabled` requests are ignored.
|
|
355
|
+
data-mp-cancel-disabled-ignored={cancelDisabled ? "true" : undefined}
|
|
356
|
+
onPress={cancel}
|
|
357
|
+
>
|
|
358
|
+
{cancelLabel}
|
|
359
|
+
</Button>
|
|
360
|
+
<Button
|
|
361
|
+
size="$3"
|
|
362
|
+
accent={!destructive && !warning}
|
|
363
|
+
error={destructive}
|
|
364
|
+
warning={!destructive && warning}
|
|
365
|
+
actionRole="primary"
|
|
366
|
+
disabled={confirmDisabled || undefined}
|
|
367
|
+
// DG-ST-03: gated confirm explains itself (visible reason,
|
|
368
|
+
// no hover) instead of dangling as a bare-disabled dead end.
|
|
369
|
+
disabledReason={confirmDisabled ? confirmDisabledReason : undefined}
|
|
370
|
+
aria-disabled={confirmDisabled || undefined}
|
|
371
|
+
data-mp-confirm-disabled={confirmDisabled ? "true" : undefined}
|
|
372
|
+
onPress={confirm}
|
|
373
|
+
>
|
|
374
|
+
{confirmLabel}
|
|
375
|
+
</Button>
|
|
376
|
+
</>
|
|
377
|
+
)}
|
|
323
378
|
</XStack>
|
|
324
379
|
</DialogContent>
|
|
325
380
|
</Dialog.Portal>
|