@plastic-js/tsumiki 0.1.40 → 0.1.42
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/Dialog.js +41 -46
- package/docs/api.md +10 -0
- package/package.json +1 -1
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import Portal_default from "./Portal.js";
|
|
2
|
+
import Button from "./Button.js";
|
|
2
3
|
import Icon from "./Icon.js";
|
|
3
4
|
import { insert, jsx, mergeProps, setProp, template } from "@plastic-js/plastic/jsx-runtime";
|
|
4
5
|
import { css, keyframes } from "@emotion/css";
|
|
5
6
|
import { Dialog } from "@plastic-js/ark";
|
|
6
7
|
import { mergeProps as mergeProps$2, splitProps } from "@plastic-js/plastic";
|
|
7
8
|
//#region src/components/Dialog.jsx
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var _tmpl3 = template("<button data-part=\"positive-trigger\" type=\"button\"></button>");
|
|
12
|
-
var _tmpl2 = template("<button data-part=\"negative-trigger\" type=\"button\"></button>");
|
|
9
|
+
var _tmpl4 = template("<div data-scope=\"dialog\" data-part=\"footer\"></div>");
|
|
10
|
+
var _tmpl3 = template("<div data-scope=\"dialog\" data-part=\"body\"></div>");
|
|
11
|
+
var _tmpl2 = template("<div data-scope=\"dialog\" data-part=\"header\"><div><!><!></div><!></div>");
|
|
13
12
|
var _tmpl = template("<div><!><!></div>");
|
|
14
13
|
var backdropModalClass = css({
|
|
15
14
|
position: "fixed",
|
|
@@ -138,35 +137,22 @@ var footerBtnClass = css({
|
|
|
138
137
|
justifyContent: "flex-end",
|
|
139
138
|
"&.tsu-dialog-footer--center": { justifyContent: "center" }
|
|
140
139
|
});
|
|
141
|
-
var
|
|
140
|
+
var negativeBtnClass = css({
|
|
142
141
|
flex: 1,
|
|
143
|
-
height: "var(--tsu-comp-height-xl)",
|
|
144
142
|
borderRadius: "var(--tsu-radius-l1-lg)",
|
|
145
143
|
border: "1px solid var(--tsu-neutral-7)",
|
|
146
144
|
background: "transparent",
|
|
147
145
|
color: "var(--tsu-fg)",
|
|
148
146
|
fontSize: "var(--tsu-comp-font-size-lg)",
|
|
149
147
|
fontWeight: "var(--tsu-font-weight-semibold)",
|
|
150
|
-
fontFamily: "inherit"
|
|
151
|
-
cursor: "pointer"
|
|
148
|
+
fontFamily: "inherit"
|
|
152
149
|
});
|
|
153
|
-
var
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
"
|
|
158
|
-
|
|
159
|
-
cursor: "not-allowed"
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
var btnDangerClass = css({
|
|
163
|
-
background: "var(--tsu-danger-9)",
|
|
164
|
-
borderColor: "var(--tsu-danger-9)",
|
|
165
|
-
color: "var(--tsu-bg)",
|
|
166
|
-
"&:disabled": {
|
|
167
|
-
opacity: .5,
|
|
168
|
-
cursor: "not-allowed"
|
|
169
|
-
}
|
|
150
|
+
var positiveBtnClass = css({
|
|
151
|
+
flex: 1,
|
|
152
|
+
borderRadius: "var(--tsu-radius-l1-lg)",
|
|
153
|
+
fontSize: "var(--tsu-comp-font-size-lg)",
|
|
154
|
+
fontWeight: "var(--tsu-font-weight-semibold)",
|
|
155
|
+
fontFamily: "inherit"
|
|
170
156
|
});
|
|
171
157
|
var read = (v) => typeof v === "function" ? v() : v;
|
|
172
158
|
var warnedSheetNoTitle = false;
|
|
@@ -221,7 +207,6 @@ var Dialog$1 = (props) => {
|
|
|
221
207
|
local.onOpenChange?.(open);
|
|
222
208
|
};
|
|
223
209
|
const handleCancel = () => {
|
|
224
|
-
if (read(local.loading)) return;
|
|
225
210
|
cancelRequested.current = true;
|
|
226
211
|
handleOpenChange(false);
|
|
227
212
|
};
|
|
@@ -234,22 +219,32 @@ var Dialog$1 = (props) => {
|
|
|
234
219
|
const _el0 = _tmpl.cloneNode(true);
|
|
235
220
|
const _el1 = _el0.firstChild;
|
|
236
221
|
const _el2 = _el0.firstChild.nextSibling;
|
|
237
|
-
insert(_el0, () => local.showCancel && ((
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
222
|
+
insert(_el0, () => local.showCancel && jsx(Button, mergeProps({
|
|
223
|
+
className: negativeBtnClass,
|
|
224
|
+
"data-part": "negative-trigger",
|
|
225
|
+
get disabled() {
|
|
226
|
+
return read(local.loading);
|
|
227
|
+
},
|
|
228
|
+
onClick: handleCancel,
|
|
229
|
+
size: "xl",
|
|
230
|
+
type: "button",
|
|
231
|
+
children: () => local.cancelText
|
|
232
|
+
})), _el1);
|
|
233
|
+
insert(_el0, () => local.showConfirm && jsx(Button, mergeProps({
|
|
234
|
+
className: positiveBtnClass,
|
|
235
|
+
"data-part": "positive-trigger",
|
|
236
|
+
get danger() {
|
|
237
|
+
return local.danger;
|
|
238
|
+
},
|
|
239
|
+
get loading() {
|
|
240
|
+
return read(local.loading);
|
|
241
|
+
},
|
|
242
|
+
onClick: handleConfirm,
|
|
243
|
+
size: "xl",
|
|
244
|
+
solid: true,
|
|
245
|
+
type: "button",
|
|
246
|
+
children: () => local.confirmText
|
|
247
|
+
})), _el2);
|
|
253
248
|
setProp(_el0, "className", () => onlyOneBtn ? `${footerBtnClass} tsu-dialog-footer--center` : footerBtnClass);
|
|
254
249
|
return _el0;
|
|
255
250
|
} : void 0;
|
|
@@ -286,7 +281,7 @@ var Dialog$1 = (props) => {
|
|
|
286
281
|
},
|
|
287
282
|
children: [
|
|
288
283
|
() => {
|
|
289
|
-
const _el0 =
|
|
284
|
+
const _el0 = _tmpl2.cloneNode(true);
|
|
290
285
|
const _el1 = _el0.firstChild;
|
|
291
286
|
const _el2 = _el1.firstChild;
|
|
292
287
|
const _el3 = _el1.firstChild.nextSibling;
|
|
@@ -315,13 +310,13 @@ var Dialog$1 = (props) => {
|
|
|
315
310
|
return _el0;
|
|
316
311
|
},
|
|
317
312
|
() => {
|
|
318
|
-
const _el0 =
|
|
313
|
+
const _el0 = _tmpl3.cloneNode(true);
|
|
319
314
|
insert(_el0, () => local.children);
|
|
320
315
|
setProp(_el0, "className", () => bodyClass);
|
|
321
316
|
return _el0;
|
|
322
317
|
},
|
|
323
318
|
() => {
|
|
324
|
-
const _el0 =
|
|
319
|
+
const _el0 = _tmpl4.cloneNode(true);
|
|
325
320
|
insert(_el0, () => footerContent);
|
|
326
321
|
setProp(_el0, "className", () => footerClass);
|
|
327
322
|
return _el0;
|
package/docs/api.md
CHANGED
|
@@ -668,6 +668,16 @@ Passthrough: Ark `Root` props (`value`, `min`, `max`, …).
|
|
|
668
668
|
| `class` | `string` | — | Content class. |
|
|
669
669
|
| `children` | `node` | — | Custom body content. |
|
|
670
670
|
|
|
671
|
+
**Callback hierarchy:**
|
|
672
|
+
|
|
673
|
+
`onOpenChange` → `onClose` → `onCancel` are **increasingly high-level**. Each is a refinement of the previous:
|
|
674
|
+
|
|
675
|
+
- `onOpenChange` — raw state sync, fired on every open/close.
|
|
676
|
+
- `onClose` — close cleanup, fired whenever the dialog closes for any reason.
|
|
677
|
+
- `onCancel` — cancel intent, fired only on an explicit cancel (Cancel button, ✕, Escape, outside pointer).
|
|
678
|
+
|
|
679
|
+
> **General rule: always use the highest-level callback you need.** Reach for `onCancel` (and `onConfirm`) first — they express intent. Only fall back to `onClose` when you need close cleanup for every path, and to `onOpenChange` only when you need raw open/close control. Passing a lower-level callback just because a higher-level one exists usually means you are bypassing the intent layer.
|
|
680
|
+
|
|
671
681
|
**Known issues:**
|
|
672
682
|
- Pressing <kbd>Escape</kbd> closes both the Dialog and any nested overlay (e.g. `DateInput`, `Select`) that is open inside it. There is currently no event coordination between the two — both react to the same key press.
|
|
673
683
|
|