bank20baht-ui 0.9.0 → 0.10.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.
@@ -16,6 +16,10 @@ export declare class BahtModal extends BahtElement {
16
16
  /** One muted line under the heading; also becomes the dialog's aria-describedby. */
17
17
  description: string;
18
18
  showClose: boolean;
19
+ /**
20
+ * Scrim click requests close. Off by default: a stray click outside the panel
21
+ * must not throw away what the user typed — close via ×, Escape or your buttons.
22
+ */
19
23
  closeOnScrim: boolean;
20
24
  private bodyEl;
21
25
  private get titleId();
@@ -1,17 +1,21 @@
1
1
  import { nothing as a, html as h } from "lit";
2
- import { property as c, query as f, state as b, customElement as y } from "lit/decorators.js";
3
- import { boolOff as m, BahtElement as v, hasDom as p, adoptLightChildren as u } from "../base.js";
2
+ import { property as c, query as f, state as m, customElement as b } from "lit/decorators.js";
3
+ import { boolOff as y, BahtElement as v, hasDom as p, adoptLightChildren as u } from "../base.js";
4
4
  import { afterExit as g } from "../motion.js";
5
5
  import { t as $ } from "../../core/i18n.js";
6
6
  import { renderIllustration as k } from "./illustrations.js";
7
- var C = Object.defineProperty, S = Object.getOwnPropertyDescriptor, l = (t, i, e, n) => {
8
- for (var o = n > 1 ? void 0 : n ? S(i, e) : i, r = t.length - 1, d; r >= 0; r--)
9
- (d = t[r]) && (o = (n ? d(i, e, o) : d(o)) || o);
7
+ var C = Object.defineProperty, S = Object.getOwnPropertyDescriptor, r = (t, i, e, n) => {
8
+ for (var o = n > 1 ? void 0 : n ? S(i, e) : i, l = t.length - 1, d; l >= 0; l--)
9
+ (d = t[l]) && (o = (n ? d(i, e, o) : d(o)) || o);
10
10
  return n && o && C(i, e, o), o;
11
11
  };
12
+ const E = {
13
+ fromAttribute: (t) => t !== null && t !== "false",
14
+ toAttribute: (t) => t ? "" : null
15
+ };
12
16
  let s = class extends v {
13
17
  constructor() {
14
- super(...arguments), this.open = !1, this.heading = "", this.description = "", this.showClose = !0, this.closeOnScrim = !0, this.closing = !1, this.closeToken = 0, this.previousFocus = null, this.onKeydown = (t) => {
18
+ super(...arguments), this.open = !1, this.heading = "", this.description = "", this.showClose = !0, this.closeOnScrim = !1, this.closing = !1, this.closeToken = 0, this.previousFocus = null, this.onKeydown = (t) => {
15
19
  !this.open || s.openStack.at(-1) !== this || (t.key === "Escape" ? this.requestClose("escape") : t.key === "Tab" && this.trapFocus(t));
16
20
  };
17
21
  }
@@ -36,12 +40,12 @@ let s = class extends v {
36
40
  e == null || e.focus(), t.preventDefault();
37
41
  return;
38
42
  }
39
- const n = i[0], o = i[i.length - 1], r = document.activeElement;
40
- if (!this.contains(r)) {
43
+ const n = i[0], o = i[i.length - 1], l = document.activeElement;
44
+ if (!this.contains(l)) {
41
45
  n.focus(), t.preventDefault();
42
46
  return;
43
47
  }
44
- t.shiftKey && (r === n || r === e) ? (o.focus(), t.preventDefault()) : !t.shiftKey && r === o && (n.focus(), t.preventDefault());
48
+ t.shiftKey && (l === n || l === e) ? (o.focus(), t.preventDefault()) : !t.shiftKey && l === o && (n.focus(), t.preventDefault());
45
49
  }
46
50
  connectedCallback() {
47
51
  super.connectedCallback(), p() && document.addEventListener("keydown", this.onKeydown);
@@ -110,29 +114,29 @@ let s = class extends v {
110
114
  }
111
115
  };
112
116
  s.openStack = [];
113
- l([
117
+ r([
114
118
  c({ type: Boolean, reflect: !0 })
115
119
  ], s.prototype, "open", 2);
116
- l([
120
+ r([
117
121
  c()
118
122
  ], s.prototype, "heading", 2);
119
- l([
123
+ r([
120
124
  c()
121
125
  ], s.prototype, "description", 2);
122
- l([
123
- c({ attribute: "show-close", converter: m })
126
+ r([
127
+ c({ attribute: "show-close", converter: y })
124
128
  ], s.prototype, "showClose", 2);
125
- l([
126
- c({ attribute: "close-on-scrim", converter: m })
129
+ r([
130
+ c({ attribute: "close-on-scrim", converter: E })
127
131
  ], s.prototype, "closeOnScrim", 2);
128
- l([
132
+ r([
129
133
  f(".baht-modal-body")
130
134
  ], s.prototype, "bodyEl", 2);
131
- l([
132
- b()
135
+ r([
136
+ m()
133
137
  ], s.prototype, "closing", 2);
134
- s = l([
135
- y("baht-modal")
138
+ s = r([
139
+ b("baht-modal")
136
140
  ], s);
137
141
  export {
138
142
  s as BahtModal
@@ -11577,7 +11577,8 @@
11577
11577
  "type": {
11578
11578
  "text": "boolean"
11579
11579
  },
11580
- "default": "true",
11580
+ "default": "false",
11581
+ "description": "Scrim click requests close. Off by default: a stray click outside the panel\nmust not throw away what the user typed — close via ×, Escape or your buttons.",
11581
11582
  "attribute": "close-on-scrim"
11582
11583
  },
11583
11584
  {
@@ -11780,7 +11781,8 @@
11780
11781
  "type": {
11781
11782
  "text": "boolean"
11782
11783
  },
11783
- "default": "true",
11784
+ "default": "false",
11785
+ "description": "Scrim click requests close. Off by default: a stray click outside the panel\nmust not throw away what the user typed — close via ×, Escape or your buttons.",
11784
11786
  "fieldName": "closeOnScrim"
11785
11787
  },
11786
11788
  {
package/dist/overlay.d.ts CHANGED
@@ -8,7 +8,7 @@ export interface DialogOptions {
8
8
  cancelText?: string;
9
9
  /** Secondary monospace block under the message (error detail, payload, …). */
10
10
  detail?: string;
11
- /** Allow Escape / scrim-click to cancel. Default true. */
11
+ /** Allow Escape to cancel. Default true. A scrim click never cancels. */
12
12
  dismissible?: boolean;
13
13
  }
14
14
  export interface PromptOptions extends DialogOptions {
package/dist/overlay.js CHANGED
@@ -12,8 +12,8 @@ function p(e) {
12
12
  return I(() => L(e));
13
13
  }
14
14
  async function L(e) {
15
- const t = document.activeElement, s = e.dismissible !== !1, E = e.tone === "danger" ? "danger" : "primary", n = document.createElement("baht-modal");
16
- n.heading = e.title ?? "", n.showClose = !1, n.closeOnScrim = s;
15
+ const t = document.activeElement, r = e.dismissible !== !1, E = e.tone === "danger" ? "danger" : "primary", n = document.createElement("baht-modal");
16
+ n.heading = e.title ?? "", n.showClose = !1, n.closeOnScrim = !1;
17
17
  const c = document.createElement("div");
18
18
  c.className = `baht-dialog${e.tone ? ` baht-dialog--${e.tone}` : ""}`;
19
19
  const b = document.createElement("p");
@@ -25,8 +25,8 @@ async function L(e) {
25
25
  e.showInput && (a = document.createElement("input"), a.className = "baht-control baht-dialog-input", a.type = "text", a.value = e.value ?? "", e.placeholder && (a.placeholder = e.placeholder), c.appendChild(a));
26
26
  const u = document.createElement("div");
27
27
  u.className = "baht-dialog-actions";
28
- let l = null;
29
- e.showCancel && (l = document.createElement("baht-button"), l.className = "baht-dialog-cancel", l.variant = "secondary", l.label = e.cancelText ?? "Cancel", u.appendChild(l));
28
+ let o = null;
29
+ e.showCancel && (o = document.createElement("baht-button"), o.className = "baht-dialog-cancel", o.variant = "secondary", o.label = e.cancelText ?? "Cancel", u.appendChild(o));
30
30
  const i = document.createElement("baht-button");
31
31
  i.className = "baht-dialog-confirm", i.variant = E, i.label = e.confirmText ?? "OK", u.appendChild(i), c.appendChild(u), n.appendChild(c), document.body.appendChild(n), n.open = !0;
32
32
  let h;
@@ -36,24 +36,24 @@ async function L(e) {
36
36
  v.observe(document.documentElement, { childList: !0, subtree: !0 });
37
37
  const g = await new Promise((d) => {
38
38
  let C = !1;
39
- const m = (o) => {
40
- C || (C = !0, d(o));
39
+ const m = (s) => {
40
+ C || (C = !0, d(s));
41
41
  };
42
42
  h = () => {
43
43
  m({ confirmed: !1, reason: "detached" });
44
44
  }, i.addEventListener("click", () => {
45
45
  m({ confirmed: !0, reason: "confirm", ...a ? { value: a.value } : {} });
46
- }), l == null || l.addEventListener("click", () => {
46
+ }), o == null || o.addEventListener("click", () => {
47
47
  m({ confirmed: !1, reason: "cancel" });
48
- }), n.addEventListener("baht-close", (o) => {
49
- if (!s) return;
50
- const x = o.detail.reason;
48
+ }), n.addEventListener("baht-close", (s) => {
49
+ if (!r) return;
50
+ const x = s.detail.reason;
51
51
  m({ confirmed: !1, reason: x === "scrim" ? "scrim" : "escape" });
52
- }), a == null || a.addEventListener("keydown", (o) => {
53
- o.key === "Enter" && !o.isComposing && m({ confirmed: !0, reason: "confirm", value: o.target.value });
52
+ }), a == null || a.addEventListener("keydown", (s) => {
53
+ s.key === "Enter" && !s.isComposing && m({ confirmed: !0, reason: "confirm", value: s.target.value });
54
54
  }), n.updateComplete.then(() => {
55
- var o;
56
- return (o = a ?? i.querySelector("button")) == null ? void 0 : o.focus();
55
+ var s;
56
+ return (s = a ?? i.querySelector("button")) == null ? void 0 : s.focus();
57
57
  });
58
58
  });
59
59
  v.disconnect(), n.open = !1;
@@ -97,7 +97,7 @@ const P = {
97
97
  },
98
98
  /** Single text input. Resolves the value, or null on cancel/dismiss. */
99
99
  async prompt(e, t = {}) {
100
- const s = await p({
100
+ const r = await p({
101
101
  title: "Input needed",
102
102
  confirmText: "OK",
103
103
  ...t,
@@ -105,14 +105,14 @@ const P = {
105
105
  showCancel: !0,
106
106
  showInput: !0
107
107
  });
108
- return s.confirmed ? s.value ?? "" : null;
108
+ return r.confirmed ? r.value ?? "" : null;
109
109
  }
110
110
  };
111
- let r = null;
111
+ let l = null;
112
112
  function S() {
113
- return r != null && r.isConnected || (r = document.querySelector("baht-toast") ?? document.body.appendChild(document.createElement("baht-toast"))), r;
113
+ return l != null && l.isConnected || (l = document.querySelector("baht-toast") ?? document.body.appendChild(document.createElement("baht-toast"))), l;
114
114
  }
115
- const f = (e) => (t, s = {}) => T.show(t, { ...s, tone: e }), T = {
115
+ const f = (e) => (t, r = {}) => T.show(t, { ...r, tone: e }), T = {
116
116
  show(e, t = {}) {
117
117
  return S().show({ message: e, ...t });
118
118
  },
@@ -121,7 +121,7 @@ const f = (e) => (t, s = {}) => T.show(t, { ...s, tone: e }), T = {
121
121
  warning: f("warning"),
122
122
  danger: f("danger"),
123
123
  dismiss(e) {
124
- r == null || r.dismiss(e);
124
+ l == null || l.dismiss(e);
125
125
  }
126
126
  };
127
127
  export {
@@ -710,7 +710,11 @@
710
710
  "values": []
711
711
  },
712
712
  { "name": "show-close", "values": [] },
713
- { "name": "close-on-scrim", "values": [] },
713
+ {
714
+ "name": "close-on-scrim",
715
+ "description": "Scrim click requests close. Off by default: a stray click outside the panel\nmust not throw away what the user typed — close via ×, Escape or your buttons.",
716
+ "values": []
717
+ },
714
718
  { "name": "defer-hydration", "values": [] }
715
719
  ],
716
720
  "references": []
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://raw.githubusercontent.com/JetBrains/web-types/master/schema/web-types.json",
3
3
  "name": "bank20baht-ui",
4
- "version": "0.9.0",
4
+ "version": "0.10.0",
5
5
  "description-markup": "markdown",
6
6
  "contributions": {
7
7
  "html": {
@@ -1645,7 +1645,8 @@
1645
1645
  },
1646
1646
  {
1647
1647
  "name": "close-on-scrim",
1648
- "value": { "type": "boolean", "default": "true" }
1648
+ "description": "Scrim click requests close. Off by default: a stray click outside the panel\nmust not throw away what the user typed — close via ×, Escape or your buttons.",
1649
+ "value": { "type": "boolean", "default": "false" }
1649
1650
  },
1650
1651
  { "name": "defer-hydration", "value": { "type": "string" } }
1651
1652
  ],
@@ -1660,7 +1661,11 @@
1660
1661
  "type": "string"
1661
1662
  },
1662
1663
  { "name": "showClose", "type": "boolean" },
1663
- { "name": "closeOnScrim", "type": "boolean" }
1664
+ {
1665
+ "name": "closeOnScrim",
1666
+ "description": "Scrim click requests close. Off by default: a stray click outside the panel\nmust not throw away what the user typed — close via ×, Escape or your buttons.",
1667
+ "type": "boolean"
1668
+ }
1664
1669
  ],
1665
1670
  "events": [{ "name": "name", "type": "CustomEvent" }]
1666
1671
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bank20baht-ui",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "type": "module",
5
5
  "description": "JSON-driven form + workflow engine. Send JSON in, get an interactive form out.",
6
6
  "license": "MIT",