@plastic-js/tsumiki 0.1.40 → 0.1.41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,13 +1,15 @@
1
1
  import Portal_default from "./Portal.js";
2
+ import Spinner from "./Spinner.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 _tmpl6 = template("<div data-scope=\"dialog\" data-part=\"footer\"></div>");
9
- var _tmpl5 = template("<div data-scope=\"dialog\" data-part=\"body\"></div>");
10
- var _tmpl4 = template("<div data-scope=\"dialog\" data-part=\"header\"><div><!><!></div><!></div>");
9
+ var _tmpl7 = template("<div data-scope=\"dialog\" data-part=\"footer\"></div>");
10
+ var _tmpl6 = template("<div data-scope=\"dialog\" data-part=\"body\"></div>");
11
+ var _tmpl5 = template("<div data-scope=\"dialog\" data-part=\"header\"><div><!><!></div><!></div>");
12
+ var _tmpl4 = template("<span><!><!></span>");
11
13
  var _tmpl3 = template("<button data-part=\"positive-trigger\" type=\"button\"></button>");
12
14
  var _tmpl2 = template("<button data-part=\"negative-trigger\" type=\"button\"></button>");
13
15
  var _tmpl = template("<div><!><!></div>");
@@ -168,6 +170,12 @@ var btnDangerClass = css({
168
170
  cursor: "not-allowed"
169
171
  }
170
172
  });
173
+ var positiveLoadingClass = css({
174
+ display: "inline-flex",
175
+ alignItems: "center",
176
+ justifyContent: "center",
177
+ gap: "8px"
178
+ });
171
179
  var read = (v) => typeof v === "function" ? v() : v;
172
180
  var warnedSheetNoTitle = false;
173
181
  var Dialog$1 = (props) => {
@@ -221,7 +229,6 @@ var Dialog$1 = (props) => {
221
229
  local.onOpenChange?.(open);
222
230
  };
223
231
  const handleCancel = () => {
224
- if (read(local.loading)) return;
225
232
  cancelRequested.current = true;
226
233
  handleOpenChange(false);
227
234
  };
@@ -244,7 +251,19 @@ var Dialog$1 = (props) => {
244
251
  }), _el1);
245
252
  insert(_el0, () => local.showConfirm && (() => {
246
253
  const _el0 = _tmpl3.cloneNode(true);
247
- insert(_el0, () => read(local.loading) ? "Loading…" : local.confirmText);
254
+ insert(_el0, () => read(local.loading) ? () => {
255
+ const _el0 = _tmpl4.cloneNode(true);
256
+ const _el1 = _el0.firstChild;
257
+ const _el2 = _el0.firstChild.nextSibling;
258
+ insert(_el0, () => jsx(Spinner, mergeProps({
259
+ size: 16,
260
+ strokeWidth: 3,
261
+ color: "currentColor"
262
+ })), _el1);
263
+ insert(_el0, () => local.confirmText, _el2);
264
+ setProp(_el0, "className", () => positiveLoadingClass);
265
+ return _el0;
266
+ } : local.confirmText);
248
267
  setProp(_el0, "className", () => `${btnClass} ${local.danger ? btnDangerClass : btnPrimaryClass}`);
249
268
  setProp(_el0, "disabled", () => read(local.loading));
250
269
  setProp(_el0, "onClick", () => handleConfirm);
@@ -286,7 +305,7 @@ var Dialog$1 = (props) => {
286
305
  },
287
306
  children: [
288
307
  () => {
289
- const _el0 = _tmpl4.cloneNode(true);
308
+ const _el0 = _tmpl5.cloneNode(true);
290
309
  const _el1 = _el0.firstChild;
291
310
  const _el2 = _el1.firstChild;
292
311
  const _el3 = _el1.firstChild.nextSibling;
@@ -315,13 +334,13 @@ var Dialog$1 = (props) => {
315
334
  return _el0;
316
335
  },
317
336
  () => {
318
- const _el0 = _tmpl5.cloneNode(true);
337
+ const _el0 = _tmpl6.cloneNode(true);
319
338
  insert(_el0, () => local.children);
320
339
  setProp(_el0, "className", () => bodyClass);
321
340
  return _el0;
322
341
  },
323
342
  () => {
324
- const _el0 = _tmpl6.cloneNode(true);
343
+ const _el0 = _tmpl7.cloneNode(true);
325
344
  insert(_el0, () => footerContent);
326
345
  setProp(_el0, "className", () => footerClass);
327
346
  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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plastic-js/tsumiki",
3
- "version": "0.1.40",
3
+ "version": "0.1.41",
4
4
  "description": "A UI component library for Plastic JS.",
5
5
  "license": "MIT",
6
6
  "author": "tigre",