nish-ui 3.2.0 → 3.3.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/README.md +7 -3
- package/dist/base-tailwind.css +30 -15
- package/dist/base.css +30 -15
- package/dist/elements-all.js +78 -78
- package/dist/elements-charts.js +39 -38
- package/dist/elements-data.d.ts +10 -0
- package/dist/elements-data.js +4 -5
- package/dist/elements-forms.js +5 -5
- package/dist/elements.d.ts +1 -0
- package/dist/elements.js +4 -4
- package/dist/esm/command-filter.js +55 -4
- package/dist/esm/components/accordion.js +3 -2
- package/dist/esm/components/app-shell.js +8 -4
- package/dist/esm/components/breadcrumbs.js +7 -3
- package/dist/esm/components/calendar-base.js +32 -5
- package/dist/esm/components/calendar-classes.js +14 -2
- package/dist/esm/components/canvas/follow-caption.js +31 -21
- package/dist/esm/components/canvas/follow.js +5 -6
- package/dist/esm/components/canvas/minimap.js +3 -3
- package/dist/esm/components/canvas/system-canvas.js +3 -1
- package/dist/esm/components/canvas/view.js +0 -2
- package/dist/esm/components/carousel.js +2 -3
- package/dist/esm/components/charts.js +18 -7
- package/dist/esm/components/combobox.js +18 -7
- package/dist/esm/components/command.js +23 -61
- package/dist/esm/components/context-menu.js +2 -1
- package/dist/esm/components/data-classes.js +5 -4
- package/dist/esm/components/data.js +19 -10
- package/dist/esm/components/display.js +20 -11
- package/dist/esm/components/drawer.js +17 -4
- package/dist/esm/components/error-boundary.js +3 -3
- package/dist/esm/components/feedback.js +3 -3
- package/dist/esm/components/file-dropzone.js +16 -6
- package/dist/esm/components/filters.js +42 -1
- package/dist/esm/components/flow.js +8 -5
- package/dist/esm/components/forms-classes.js +2 -0
- package/dist/esm/components/forms.js +2 -2
- package/dist/esm/components/hooks.js +47 -13
- package/dist/esm/components/hover-card.js +2 -1
- package/dist/esm/components/inbox.js +5 -1
- package/dist/esm/components/latest.js +4 -2
- package/dist/esm/components/layout.js +7 -4
- package/dist/esm/components/menu.js +10 -1
- package/dist/esm/components/modal.js +17 -4
- package/dist/esm/components/multi-select.js +5 -5
- package/dist/esm/components/nav.js +30 -11
- package/dist/esm/components/navigate.js +1 -1
- package/dist/esm/components/overlay-dialog.js +35 -1
- package/dist/esm/components/pagination.js +1 -1
- package/dist/esm/components/primitives.js +17 -4
- package/dist/esm/components/progress.js +2 -1
- package/dist/esm/components/resource.js +14 -4
- package/dist/esm/components/segmented.js +2 -0
- package/dist/esm/components/separator.js +6 -1
- package/dist/esm/components/service-tokens.js +18 -7
- package/dist/esm/components/settings.js +16 -0
- package/dist/esm/components/slider.js +5 -1
- package/dist/esm/components/split.js +4 -2
- package/dist/esm/components/strings.js +17 -4
- package/dist/esm/components/table.js +15 -3
- package/dist/esm/components/tag-input.js +5 -1
- package/dist/esm/components/time-field.js +15 -7
- package/dist/esm/components/toast-card.js +5 -3
- package/dist/esm/components/toast.js +4 -1
- package/dist/esm/components/tooltip.js +3 -2
- package/dist/esm/components/url-state.js +3 -1
- package/dist/esm/components/virtual-table.js +2 -2
- package/dist/esm/components/virtual.js +8 -4
- package/dist/esm/format.js +3 -2
- package/dist/esm/runtime.js +1 -1
- package/dist/esm/server/inbox/client.js +4 -0
- package/dist/esm/theme.js +38 -15
- package/dist/esm/tokens.mjs +1 -1
- package/dist/format.d.ts +5 -3
- package/dist/format.js +4 -3
- package/dist/inbox-client.d.ts +1 -1
- package/dist/inbox-client.js +4 -0
- package/dist/index.d.ts +61 -29
- package/dist/nish-components.css +59 -21
- package/dist/nish-components.min.css +1 -1
- package/dist/nish.css +30 -15
- package/dist/nish.min.css +1 -1
- package/dist/node/vite.js +1 -1
- package/dist/server/hono.d.ts +9 -2
- package/dist/server/hono.js +17 -4
- package/dist/server/index.d.ts +3 -3
- package/dist/server/index.js +7 -2
- package/dist/service-tokens.d.ts +4 -4
- package/dist/{spa-BfRDo38r.d.ts → spa-FwS7yZ8p.d.ts} +4 -3
- package/dist/system-canvas.d.ts +11 -10
- package/dist/theme.d.ts +30 -2
- package/dist/theme.global.js +45 -18
- package/dist/theme.js +45 -18
- package/package.json +3 -2
- package/dist/tokens.js +0 -425
package/dist/theme.global.js
CHANGED
|
@@ -314,7 +314,7 @@ var nishTheme = (() => {
|
|
|
314
314
|
var DEFAULT_THEME = "dark";
|
|
315
315
|
|
|
316
316
|
// src/runtime.ts
|
|
317
|
-
var version = true ? "3.
|
|
317
|
+
var version = true ? "3.3.0" : "dev";
|
|
318
318
|
var KEY = /* @__PURE__ */ Symbol.for("nish-ui.runtime.v1");
|
|
319
319
|
function runtime() {
|
|
320
320
|
var _a;
|
|
@@ -372,7 +372,8 @@ var nishTheme = (() => {
|
|
|
372
372
|
cancel: "Cancel",
|
|
373
373
|
menu: "Menu",
|
|
374
374
|
back: "Back: ",
|
|
375
|
-
contextMenu: "Actions"
|
|
375
|
+
contextMenu: "Actions",
|
|
376
|
+
opensInNewTab: "opens in a new tab"
|
|
376
377
|
};
|
|
377
378
|
var THEME_STRINGS = {
|
|
378
379
|
theme: "Theme",
|
|
@@ -388,9 +389,12 @@ var nishTheme = (() => {
|
|
|
388
389
|
moreCount: (count) => `${count} more`,
|
|
389
390
|
copy: "Copy",
|
|
390
391
|
copied: "Copied",
|
|
392
|
+
copyFailed: "Copy failed",
|
|
391
393
|
legend: "Legend",
|
|
392
394
|
noData: "No data",
|
|
393
|
-
noDataNamed: (label) => `${label}: no data
|
|
395
|
+
noDataNamed: (label) => `${label}: no data`,
|
|
396
|
+
rangeLabel: (low, high, current, min, max) => `Range ${low} to ${high}${current != null ? `, current ${current}` : ""}, within ${min} to ${max}`,
|
|
397
|
+
chartTruncated: (shown, total) => `First ${shown} of ${total} points`
|
|
394
398
|
};
|
|
395
399
|
|
|
396
400
|
// src/theme.ts
|
|
@@ -408,7 +412,10 @@ var nishTheme = (() => {
|
|
|
408
412
|
return k && /^[A-Za-z0-9_-]+$/.test(k) ? k : DEFAULT_KEY;
|
|
409
413
|
}
|
|
410
414
|
function registerThemes(themes) {
|
|
411
|
-
Object.
|
|
415
|
+
for (const [name, scheme] of Object.entries(themes)) {
|
|
416
|
+
if (/^[a-z0-9-]+$/.test(name)) state().extra[name] = scheme;
|
|
417
|
+
else console.warn(`[nish-ui] registerThemes: skipped "${name}" (use lowercase letters, digits and hyphens)`);
|
|
418
|
+
}
|
|
412
419
|
}
|
|
413
420
|
var has = (o, k) => Object.prototype.hasOwnProperty.call(o, k);
|
|
414
421
|
function isThemeName(v) {
|
|
@@ -417,7 +424,7 @@ var nishTheme = (() => {
|
|
|
417
424
|
function readCookie() {
|
|
418
425
|
if (typeof document === "undefined") return null;
|
|
419
426
|
try {
|
|
420
|
-
const m = document.cookie.match(new RegExp(`(?:^|;\\s*)${storageKey()}=([a-z0-9-]+)`));
|
|
427
|
+
const m = document.cookie.match(new RegExp(`(?:^|;\\s*)${storageKey()}=([a-z0-9-]+)(?:;|$)`));
|
|
421
428
|
return m ? m[1] : null;
|
|
422
429
|
} catch (e) {
|
|
423
430
|
return null;
|
|
@@ -623,7 +630,7 @@ var nishTheme = (() => {
|
|
|
623
630
|
if (svg.getAttribute("data-icon") === icon) svg.removeAttribute("display");
|
|
624
631
|
else svg.setAttribute("display", "none");
|
|
625
632
|
});
|
|
626
|
-
const elsewhere = TOGGLE_ORDER.includes(choice) ? "" : ` (${elsewhereWords})`;
|
|
633
|
+
const elsewhere = TOGGLE_ORDER.includes(choice) || has(state().extra, choice) ? "" : ` (${elsewhereWords})`;
|
|
627
634
|
const label = sentence(`${themeLabel(choice, words)}${elsewhere}`, themeLabel(nextChoice(choice), words));
|
|
628
635
|
button.setAttribute("aria-label", label);
|
|
629
636
|
button.setAttribute("title", label);
|
|
@@ -664,7 +671,8 @@ var nishTheme = (() => {
|
|
|
664
671
|
function showToast(content, opts = {}) {
|
|
665
672
|
var _a, _b, _c, _d, _e;
|
|
666
673
|
hideCurrent == null ? void 0 : hideCurrent();
|
|
667
|
-
if (!toastRegion || !toastRegion.isConnected)
|
|
674
|
+
if (!toastRegion || !toastRegion.isConnected) toastRegion = document.querySelector(".nish-toast-region");
|
|
675
|
+
if (!toastRegion) {
|
|
668
676
|
toastRegion = document.createElement("div");
|
|
669
677
|
toastRegion.setAttribute("role", "status");
|
|
670
678
|
toastRegion.setAttribute("aria-live", "polite");
|
|
@@ -687,10 +695,13 @@ var nishTheme = (() => {
|
|
|
687
695
|
let remaining = opts.duration === "sticky" ? Infinity : (_b = opts.duration) != null ? _b : TOAST_MS;
|
|
688
696
|
let started = 0;
|
|
689
697
|
let holds = 0;
|
|
698
|
+
let returnTo = null;
|
|
690
699
|
const hide = () => {
|
|
691
700
|
if (timer != null) clearTimeout(timer);
|
|
692
701
|
timer = null;
|
|
702
|
+
const hadFocus = box.contains(document.activeElement);
|
|
693
703
|
box.remove();
|
|
704
|
+
if (hadFocus && (returnTo == null ? void 0 : returnTo.isConnected)) returnTo.focus();
|
|
694
705
|
if (hideCurrent === hide) hideCurrent = null;
|
|
695
706
|
};
|
|
696
707
|
const run = (ms) => {
|
|
@@ -734,7 +745,11 @@ var nishTheme = (() => {
|
|
|
734
745
|
box.append(close);
|
|
735
746
|
box.addEventListener("pointerenter", (e) => e.pointerType === "mouse" && pause());
|
|
736
747
|
box.addEventListener("pointerleave", (e) => e.pointerType === "mouse" && resume());
|
|
737
|
-
box.addEventListener("focusin", (e) =>
|
|
748
|
+
box.addEventListener("focusin", (e) => {
|
|
749
|
+
if (box.contains(e.relatedTarget)) return;
|
|
750
|
+
if (e.relatedTarget instanceof HTMLElement) returnTo = e.relatedTarget;
|
|
751
|
+
pause();
|
|
752
|
+
});
|
|
738
753
|
box.addEventListener("focusout", (e) => !box.contains(e.relatedTarget) && resume());
|
|
739
754
|
box.addEventListener("keydown", (e) => {
|
|
740
755
|
if (e.key === "Escape") hide();
|
|
@@ -748,6 +763,11 @@ var nishTheme = (() => {
|
|
|
748
763
|
return hide;
|
|
749
764
|
}
|
|
750
765
|
var dialogSeq = 0;
|
|
766
|
+
function onBackdrop(dialog, e) {
|
|
767
|
+
if (e.target !== dialog) return false;
|
|
768
|
+
const r = dialog.getBoundingClientRect();
|
|
769
|
+
return !(e.clientX >= r.left && e.clientX <= r.right && e.clientY >= r.top && e.clientY <= r.bottom);
|
|
770
|
+
}
|
|
751
771
|
function confirmDialog(opts) {
|
|
752
772
|
var _a, _b, _c, _d;
|
|
753
773
|
if (typeof document === "undefined") return Promise.resolve(false);
|
|
@@ -804,11 +824,12 @@ var nishTheme = (() => {
|
|
|
804
824
|
finish(false);
|
|
805
825
|
});
|
|
806
826
|
dialog.addEventListener("close", () => finish(false));
|
|
827
|
+
let pressedOnBackdrop = null;
|
|
828
|
+
dialog.addEventListener("pointerdown", (e) => pressedOnBackdrop = onBackdrop(dialog, e));
|
|
807
829
|
dialog.addEventListener("click", (e) => {
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
if (!inside) finish(false);
|
|
830
|
+
const down = pressedOnBackdrop;
|
|
831
|
+
pressedOnBackdrop = null;
|
|
832
|
+
if (down !== false && onBackdrop(dialog, e)) finish(false);
|
|
812
833
|
});
|
|
813
834
|
document.body.append(dialog);
|
|
814
835
|
dialog.showModal();
|
|
@@ -886,11 +907,15 @@ var nishTheme = (() => {
|
|
|
886
907
|
const onKey = (e) => {
|
|
887
908
|
if (e.key === "Escape") e.stopPropagation();
|
|
888
909
|
};
|
|
910
|
+
let pressedOnBackdrop = null;
|
|
911
|
+
const onPress = (e) => {
|
|
912
|
+
pressedOnBackdrop = onBackdrop(dialog, e);
|
|
913
|
+
};
|
|
889
914
|
const onClick = (e) => {
|
|
890
915
|
if (e.target === dialog) {
|
|
891
|
-
const
|
|
892
|
-
|
|
893
|
-
if (
|
|
916
|
+
const down = pressedOnBackdrop;
|
|
917
|
+
pressedOnBackdrop = null;
|
|
918
|
+
if (down !== false && onBackdrop(dialog, e)) closeNow();
|
|
894
919
|
return;
|
|
895
920
|
}
|
|
896
921
|
if (e.target instanceof Element && e.target.closest("[data-sheet-close]")) closeNow();
|
|
@@ -906,7 +931,7 @@ var nishTheme = (() => {
|
|
|
906
931
|
if (typeof matchMedia !== "undefined" && matchMedia("(min-width: 640px)").matches) return;
|
|
907
932
|
const r = dialog.getBoundingClientRect();
|
|
908
933
|
const onHeader = e.target instanceof Element && e.target.closest(".nish-sheet-header") != null;
|
|
909
|
-
if (!onHeader && e.clientY - r.top >
|
|
934
|
+
if (!onHeader && e.clientY - r.top > 44) return;
|
|
910
935
|
dragging = true;
|
|
911
936
|
startY = lastY = e.clientY;
|
|
912
937
|
lastT = e.timeStamp;
|
|
@@ -944,6 +969,7 @@ var nishTheme = (() => {
|
|
|
944
969
|
dialog.removeEventListener("cancel", onCancel);
|
|
945
970
|
dialog.removeEventListener("keydown", onKey);
|
|
946
971
|
dialog.removeEventListener("click", onClick);
|
|
972
|
+
dialog.removeEventListener("pointerdown", onPress);
|
|
947
973
|
dialog.removeEventListener("pointerdown", onDown);
|
|
948
974
|
dialog.removeEventListener("pointermove", onMove);
|
|
949
975
|
dialog.removeEventListener("pointerup", onUp);
|
|
@@ -954,6 +980,7 @@ var nishTheme = (() => {
|
|
|
954
980
|
dialog.addEventListener("cancel", onCancel);
|
|
955
981
|
dialog.addEventListener("keydown", onKey);
|
|
956
982
|
dialog.addEventListener("click", onClick);
|
|
983
|
+
dialog.addEventListener("pointerdown", onPress);
|
|
957
984
|
dialog.addEventListener("pointerdown", onDown);
|
|
958
985
|
dialog.addEventListener("pointermove", onMove);
|
|
959
986
|
dialog.addEventListener("pointerup", onUp);
|
|
@@ -1184,7 +1211,7 @@ var nishTheme = (() => {
|
|
|
1184
1211
|
};
|
|
1185
1212
|
return Object.assign(stop, { lock });
|
|
1186
1213
|
}
|
|
1187
|
-
function mountChecklist(list) {
|
|
1214
|
+
function mountChecklist(list, opts = {}) {
|
|
1188
1215
|
var _a, _b, _c;
|
|
1189
1216
|
if (typeof document === "undefined") return () => void 0;
|
|
1190
1217
|
const key = list.dataset.store || null;
|
|
@@ -1212,7 +1239,7 @@ var nishTheme = (() => {
|
|
|
1212
1239
|
const all = boxes();
|
|
1213
1240
|
const done = all.filter((b) => b.checked).length;
|
|
1214
1241
|
if (progress) {
|
|
1215
|
-
progress.textContent = `${done} of ${all.length}`;
|
|
1242
|
+
progress.textContent = opts.format ? opts.format(done, all.length) : `${done} of ${all.length}`;
|
|
1216
1243
|
progress.style.setProperty("--p", `${all.length ? done / all.length * 100 : 0}%`);
|
|
1217
1244
|
}
|
|
1218
1245
|
};
|
package/dist/theme.js
CHANGED
|
@@ -264,7 +264,7 @@ var THEMES = /* @__PURE__ */ Object.fromEntries(
|
|
|
264
264
|
var DEFAULT_THEME = "dark";
|
|
265
265
|
|
|
266
266
|
// src/runtime.ts
|
|
267
|
-
var version = true ? "3.
|
|
267
|
+
var version = true ? "3.3.0" : "dev";
|
|
268
268
|
var KEY = /* @__PURE__ */ Symbol.for("nish-ui.runtime.v1");
|
|
269
269
|
function runtime() {
|
|
270
270
|
const g = globalThis;
|
|
@@ -321,7 +321,8 @@ var OVERLAY_STRINGS = {
|
|
|
321
321
|
cancel: "Cancel",
|
|
322
322
|
menu: "Menu",
|
|
323
323
|
back: "Back: ",
|
|
324
|
-
contextMenu: "Actions"
|
|
324
|
+
contextMenu: "Actions",
|
|
325
|
+
opensInNewTab: "opens in a new tab"
|
|
325
326
|
};
|
|
326
327
|
var THEME_STRINGS = {
|
|
327
328
|
theme: "Theme",
|
|
@@ -337,9 +338,12 @@ var DISPLAY_STRINGS = {
|
|
|
337
338
|
moreCount: (count) => `${count} more`,
|
|
338
339
|
copy: "Copy",
|
|
339
340
|
copied: "Copied",
|
|
341
|
+
copyFailed: "Copy failed",
|
|
340
342
|
legend: "Legend",
|
|
341
343
|
noData: "No data",
|
|
342
|
-
noDataNamed: (label) => `${label}: no data
|
|
344
|
+
noDataNamed: (label) => `${label}: no data`,
|
|
345
|
+
rangeLabel: (low, high, current, min, max) => `Range ${low} to ${high}${current != null ? `, current ${current}` : ""}, within ${min} to ${max}`,
|
|
346
|
+
chartTruncated: (shown, total) => `First ${shown} of ${total} points`
|
|
343
347
|
};
|
|
344
348
|
|
|
345
349
|
// src/theme.ts
|
|
@@ -365,7 +369,10 @@ function storageKey() {
|
|
|
365
369
|
return k && /^[A-Za-z0-9_-]+$/.test(k) ? k : DEFAULT_KEY;
|
|
366
370
|
}
|
|
367
371
|
function registerThemes(themes) {
|
|
368
|
-
Object.
|
|
372
|
+
for (const [name, scheme] of Object.entries(themes)) {
|
|
373
|
+
if (/^[a-z0-9-]+$/.test(name)) state().extra[name] = scheme;
|
|
374
|
+
else console.warn(`[nish-ui] registerThemes: skipped "${name}" (use lowercase letters, digits and hyphens)`);
|
|
375
|
+
}
|
|
369
376
|
}
|
|
370
377
|
var has = (o, k) => Object.prototype.hasOwnProperty.call(o, k);
|
|
371
378
|
function isThemeName(v) {
|
|
@@ -374,7 +381,7 @@ function isThemeName(v) {
|
|
|
374
381
|
function readCookie() {
|
|
375
382
|
if (typeof document === "undefined") return null;
|
|
376
383
|
try {
|
|
377
|
-
const m = document.cookie.match(new RegExp(`(?:^|;\\s*)${storageKey()}=([a-z0-9-]+)`));
|
|
384
|
+
const m = document.cookie.match(new RegExp(`(?:^|;\\s*)${storageKey()}=([a-z0-9-]+)(?:;|$)`));
|
|
378
385
|
return m ? m[1] : null;
|
|
379
386
|
} catch {
|
|
380
387
|
return null;
|
|
@@ -578,7 +585,7 @@ function mountThemeToggle(button, opts = {}) {
|
|
|
578
585
|
if (svg.getAttribute("data-icon") === icon) svg.removeAttribute("display");
|
|
579
586
|
else svg.setAttribute("display", "none");
|
|
580
587
|
});
|
|
581
|
-
const elsewhere = TOGGLE_ORDER.includes(choice) ? "" : ` (${elsewhereWords})`;
|
|
588
|
+
const elsewhere = TOGGLE_ORDER.includes(choice) || has(state().extra, choice) ? "" : ` (${elsewhereWords})`;
|
|
582
589
|
const label = sentence(`${themeLabel(choice, words)}${elsewhere}`, themeLabel(nextChoice(choice), words));
|
|
583
590
|
button.setAttribute("aria-label", label);
|
|
584
591
|
button.setAttribute("title", label);
|
|
@@ -618,7 +625,8 @@ var toastRegion = null;
|
|
|
618
625
|
var hideCurrent = null;
|
|
619
626
|
function showToast(content, opts = {}) {
|
|
620
627
|
hideCurrent?.();
|
|
621
|
-
if (!toastRegion || !toastRegion.isConnected)
|
|
628
|
+
if (!toastRegion || !toastRegion.isConnected) toastRegion = document.querySelector(".nish-toast-region");
|
|
629
|
+
if (!toastRegion) {
|
|
622
630
|
toastRegion = document.createElement("div");
|
|
623
631
|
toastRegion.setAttribute("role", "status");
|
|
624
632
|
toastRegion.setAttribute("aria-live", "polite");
|
|
@@ -641,10 +649,13 @@ function showToast(content, opts = {}) {
|
|
|
641
649
|
let remaining = opts.duration === "sticky" ? Infinity : opts.duration ?? TOAST_MS;
|
|
642
650
|
let started = 0;
|
|
643
651
|
let holds = 0;
|
|
652
|
+
let returnTo = null;
|
|
644
653
|
const hide = () => {
|
|
645
654
|
if (timer != null) clearTimeout(timer);
|
|
646
655
|
timer = null;
|
|
656
|
+
const hadFocus = box.contains(document.activeElement);
|
|
647
657
|
box.remove();
|
|
658
|
+
if (hadFocus && returnTo?.isConnected) returnTo.focus();
|
|
648
659
|
if (hideCurrent === hide) hideCurrent = null;
|
|
649
660
|
};
|
|
650
661
|
const run = (ms) => {
|
|
@@ -687,7 +698,11 @@ function showToast(content, opts = {}) {
|
|
|
687
698
|
box.append(close);
|
|
688
699
|
box.addEventListener("pointerenter", (e) => e.pointerType === "mouse" && pause());
|
|
689
700
|
box.addEventListener("pointerleave", (e) => e.pointerType === "mouse" && resume());
|
|
690
|
-
box.addEventListener("focusin", (e) =>
|
|
701
|
+
box.addEventListener("focusin", (e) => {
|
|
702
|
+
if (box.contains(e.relatedTarget)) return;
|
|
703
|
+
if (e.relatedTarget instanceof HTMLElement) returnTo = e.relatedTarget;
|
|
704
|
+
pause();
|
|
705
|
+
});
|
|
691
706
|
box.addEventListener("focusout", (e) => !box.contains(e.relatedTarget) && resume());
|
|
692
707
|
box.addEventListener("keydown", (e) => {
|
|
693
708
|
if (e.key === "Escape") hide();
|
|
@@ -701,6 +716,11 @@ function showToast(content, opts = {}) {
|
|
|
701
716
|
return hide;
|
|
702
717
|
}
|
|
703
718
|
var dialogSeq = 0;
|
|
719
|
+
function onBackdrop(dialog, e) {
|
|
720
|
+
if (e.target !== dialog) return false;
|
|
721
|
+
const r = dialog.getBoundingClientRect();
|
|
722
|
+
return !(e.clientX >= r.left && e.clientX <= r.right && e.clientY >= r.top && e.clientY <= r.bottom);
|
|
723
|
+
}
|
|
704
724
|
function confirmDialog(opts) {
|
|
705
725
|
if (typeof document === "undefined") return Promise.resolve(false);
|
|
706
726
|
const opener = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
@@ -756,11 +776,12 @@ function confirmDialog(opts) {
|
|
|
756
776
|
finish(false);
|
|
757
777
|
});
|
|
758
778
|
dialog.addEventListener("close", () => finish(false));
|
|
779
|
+
let pressedOnBackdrop = null;
|
|
780
|
+
dialog.addEventListener("pointerdown", (e) => pressedOnBackdrop = onBackdrop(dialog, e));
|
|
759
781
|
dialog.addEventListener("click", (e) => {
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
if (!inside) finish(false);
|
|
782
|
+
const down = pressedOnBackdrop;
|
|
783
|
+
pressedOnBackdrop = null;
|
|
784
|
+
if (down !== false && onBackdrop(dialog, e)) finish(false);
|
|
764
785
|
});
|
|
765
786
|
document.body.append(dialog);
|
|
766
787
|
dialog.showModal();
|
|
@@ -837,11 +858,15 @@ function openSheet(dialog) {
|
|
|
837
858
|
const onKey = (e) => {
|
|
838
859
|
if (e.key === "Escape") e.stopPropagation();
|
|
839
860
|
};
|
|
861
|
+
let pressedOnBackdrop = null;
|
|
862
|
+
const onPress = (e) => {
|
|
863
|
+
pressedOnBackdrop = onBackdrop(dialog, e);
|
|
864
|
+
};
|
|
840
865
|
const onClick = (e) => {
|
|
841
866
|
if (e.target === dialog) {
|
|
842
|
-
const
|
|
843
|
-
|
|
844
|
-
if (
|
|
867
|
+
const down = pressedOnBackdrop;
|
|
868
|
+
pressedOnBackdrop = null;
|
|
869
|
+
if (down !== false && onBackdrop(dialog, e)) closeNow();
|
|
845
870
|
return;
|
|
846
871
|
}
|
|
847
872
|
if (e.target instanceof Element && e.target.closest("[data-sheet-close]")) closeNow();
|
|
@@ -856,7 +881,7 @@ function openSheet(dialog) {
|
|
|
856
881
|
if (typeof matchMedia !== "undefined" && matchMedia("(min-width: 640px)").matches) return;
|
|
857
882
|
const r = dialog.getBoundingClientRect();
|
|
858
883
|
const onHeader = e.target instanceof Element && e.target.closest(".nish-sheet-header") != null;
|
|
859
|
-
if (!onHeader && e.clientY - r.top >
|
|
884
|
+
if (!onHeader && e.clientY - r.top > 44) return;
|
|
860
885
|
dragging = true;
|
|
861
886
|
startY = lastY = e.clientY;
|
|
862
887
|
lastT = e.timeStamp;
|
|
@@ -893,6 +918,7 @@ function openSheet(dialog) {
|
|
|
893
918
|
dialog.removeEventListener("cancel", onCancel);
|
|
894
919
|
dialog.removeEventListener("keydown", onKey);
|
|
895
920
|
dialog.removeEventListener("click", onClick);
|
|
921
|
+
dialog.removeEventListener("pointerdown", onPress);
|
|
896
922
|
dialog.removeEventListener("pointerdown", onDown);
|
|
897
923
|
dialog.removeEventListener("pointermove", onMove);
|
|
898
924
|
dialog.removeEventListener("pointerup", onUp);
|
|
@@ -903,6 +929,7 @@ function openSheet(dialog) {
|
|
|
903
929
|
dialog.addEventListener("cancel", onCancel);
|
|
904
930
|
dialog.addEventListener("keydown", onKey);
|
|
905
931
|
dialog.addEventListener("click", onClick);
|
|
932
|
+
dialog.addEventListener("pointerdown", onPress);
|
|
906
933
|
dialog.addEventListener("pointerdown", onDown);
|
|
907
934
|
dialog.addEventListener("pointermove", onMove);
|
|
908
935
|
dialog.addEventListener("pointerup", onUp);
|
|
@@ -1132,7 +1159,7 @@ function mountScrollspy(nav, o = {}) {
|
|
|
1132
1159
|
};
|
|
1133
1160
|
return Object.assign(stop, { lock });
|
|
1134
1161
|
}
|
|
1135
|
-
function mountChecklist(list) {
|
|
1162
|
+
function mountChecklist(list, opts = {}) {
|
|
1136
1163
|
if (typeof document === "undefined") return () => void 0;
|
|
1137
1164
|
const key = list.dataset.store || null;
|
|
1138
1165
|
const boxes = () => Array.from(list.querySelectorAll('li[data-id] input[type="checkbox"]'));
|
|
@@ -1156,7 +1183,7 @@ function mountChecklist(list) {
|
|
|
1156
1183
|
const all = boxes();
|
|
1157
1184
|
const done = all.filter((b) => b.checked).length;
|
|
1158
1185
|
if (progress) {
|
|
1159
|
-
progress.textContent = `${done} of ${all.length}`;
|
|
1186
|
+
progress.textContent = opts.format ? opts.format(done, all.length) : `${done} of ${all.length}`;
|
|
1160
1187
|
progress.style.setProperty("--p", `${all.length ? done / all.length * 100 : 0}%`);
|
|
1161
1188
|
}
|
|
1162
1189
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nish-ui",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"description": "Design tokens, seven themes, flash-free theme switching and accessible React 19 components for Tailwind 4, plain CSS and static HTML. Live docs: https://design.nish.software",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Nishant Arora",
|
|
@@ -40,7 +40,6 @@
|
|
|
40
40
|
],
|
|
41
41
|
"files": [
|
|
42
42
|
"dist",
|
|
43
|
-
"!dist/esm/**/*.map",
|
|
44
43
|
"!dist/**/*.map",
|
|
45
44
|
"tsconfig"
|
|
46
45
|
],
|
|
@@ -214,6 +213,8 @@
|
|
|
214
213
|
"./fonts.css": "./dist/fonts.css",
|
|
215
214
|
"./base.css": "./dist/base.css",
|
|
216
215
|
"./nish-components.css": "./dist/nish-components.css",
|
|
216
|
+
"./nish.min.css": "./dist/nish.min.css",
|
|
217
|
+
"./nish-components.min.css": "./dist/nish-components.min.css",
|
|
217
218
|
"./tokens.json": "./dist/tokens.json",
|
|
218
219
|
"./tokens.dtcg.json": "./dist/tokens.dtcg.json",
|
|
219
220
|
"./fonts/*": "./dist/fonts/*",
|