@20baht/ui 0.1.1 → 0.1.2

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,9 +1,9 @@
1
- import { nothing as m, html as h } from "lit";
1
+ import { nothing as d, html as h } from "lit";
2
2
  import { property as u, state as b } from "lit/decorators.js";
3
3
  import { keyed as v } from "lit/directives/keyed.js";
4
4
  import { BahtFieldBase as w } from "./field-base.js";
5
5
  import { boolOff as f, BahtElement as g, obj as y, hasDom as k, stringOf as $ } from "./base.js";
6
- import { applyFlags as _, updateWorkflow as C, sameData as p, t as d, visibleForms as x, nextTarget as F, snapshotOf as S } from "@20baht/engine";
6
+ import { applyFlags as _, updateWorkflow as C, sameData as p, t as m, visibleForms as x, nextTarget as F, snapshotOf as S } from "@20baht/engine";
7
7
  import "./baht-form.js";
8
8
  import "./primitives/baht-steps.js";
9
9
  import { customElement as E } from "./define.js";
@@ -61,9 +61,7 @@ let a = class extends g {
61
61
  `[bahtui] workflow "${this.workflow.workflow_id}" rules: ` + t.detail.errors.map((e) => `${e.ref}: ${e.message}`).join("; ")
62
62
  ), t.name === "baht-nav-blocked") {
63
63
  const { form_name: e, target: r, reason: i } = t.detail;
64
- console.warn(
65
- `[bahtui] cannot advance from "${e}": target "${r}" is ` + (i === "self-transition" ? "the current form (self-transition)" : "not visible")
66
- );
64
+ console.warn(`[bahtui] cannot advance from "${e}": ${O(r, i)}`);
67
65
  }
68
66
  }
69
67
  willUpdate(t) {
@@ -84,7 +82,7 @@ let a = class extends g {
84
82
  /** Why the last decision was refused, in the current locale. */
85
83
  get approvalError() {
86
84
  var t;
87
- return (t = this.run) != null && t.approvalError ? d(this.run.approvalError) : null;
85
+ return (t = this.run) != null && t.approvalError ? m(this.run.approvalError) : null;
88
86
  }
89
87
  /** The run's data: `{ form_name: { key: value } }`, as the rules left it. */
90
88
  get data() {
@@ -117,7 +115,7 @@ let a = class extends g {
117
115
  for (const [n, c] of Object.entries(r.fields))
118
116
  n.startsWith(i) && (e[n.slice(i.length)] = c);
119
117
  const s = this.statesSeen.get(t);
120
- return s && O(s, e) ? s : (this.statesSeen.set(t, e), e);
118
+ return s && W(s, e) ? s : (this.statesSeen.set(t, e), e);
121
119
  }
122
120
  /** The step's own editable form: a data step's, or an approval step's fields (never the summary). */
123
121
  get formEl() {
@@ -248,7 +246,7 @@ let a = class extends g {
248
246
  const e = ((i = t.approval) == null ? void 0 : i.comment) ?? "optional", r = this.summary_forms(t);
249
247
  return h`<div class="baht-approval">
250
248
  <div class="baht-approval-summary">
251
- ${r.length === 0 ? h`<p class="baht-approval-empty">${d("nothingToReview")}</p>` : r.map(
249
+ ${r.length === 0 ? h`<p class="baht-approval-empty">${m("nothingToReview")}</p>` : r.map(
252
250
  (n) => h`<section class="baht-approval-group">
253
251
  <h4 class="baht-approval-group-title">${n.form_name}</h4>
254
252
  <baht-form
@@ -260,15 +258,15 @@ let a = class extends g {
260
258
  </section>`
261
259
  )}
262
260
  </div>
263
- ${t.fields.length > 0 ? this.renderStepForm(t) : m}
261
+ ${t.fields.length > 0 ? this.renderStepForm(t) : d}
264
262
  ${e !== "hidden" ? h`<label class="baht-approval-comment">
265
263
  <span class="baht-approval-comment-label">
266
- ${d("comment")}${e === "required" ? d("commentRequiredSuffix") : ""}
264
+ ${m("comment")}${e === "required" ? m("commentRequiredSuffix") : ""}
267
265
  </span>
268
266
  <textarea
269
267
  rows="3"
270
- aria-required=${e === "required" ? "true" : m}
271
- aria-invalid=${this.approvalError ? "true" : m}
268
+ aria-required=${e === "required" ? "true" : d}
269
+ aria-invalid=${this.approvalError ? "true" : d}
272
270
  .value=${((s = this.pendingComment) == null ? void 0 : s.form_name) === t.form_name ? this.pendingComment.value : $((o = this.data[t.form_name]) == null ? void 0 : o.comment)}
273
271
  @focusout=${() => {
274
272
  this.flushComment();
@@ -277,8 +275,8 @@ let a = class extends g {
277
275
  this.onCommentInput(t.form_name, n.target.value);
278
276
  }}
279
277
  ></textarea>
280
- </label>` : m}
281
- ${this.approvalError ? h`<p class="baht-error" role="alert">${this.approvalError}</p>` : m}
278
+ </label>` : d}
279
+ ${this.approvalError ? h`<p class="baht-error" role="alert">${this.approvalError}</p>` : d}
282
280
  </div>`;
283
281
  }
284
282
  /**
@@ -313,14 +311,14 @@ let a = class extends g {
313
311
  data-step=${t.form_name}
314
312
  data-testid="${this.workflow.workflow_id}.${t.form_name}"
315
313
  >
316
- ${this.chrome === "none" ? m : h`<div class="baht-visually-hidden" role="status">
317
- ${d("step", { current: i + 1, total: r.length })}
314
+ ${this.chrome === "none" ? d : h`<div class="baht-visually-hidden" role="status">
315
+ ${m("step", { current: i + 1, total: r.length })}
318
316
  </div>`}
319
317
  ${this.showSteps ? h`<baht-steps
320
318
  .steps=${r.map((s) => s.form_name)}
321
319
  .current=${i}
322
320
  .variant=${this.stepsVariant}
323
- ></baht-steps>` : m}
321
+ ></baht-steps>` : d}
324
322
  ${v(
325
323
  t.form_name,
326
324
  h`<div
@@ -329,13 +327,13 @@ let a = class extends g {
329
327
  ${e ? this.renderApproval(t) : this.renderStepForm(t)}
330
328
  </div>`
331
329
  )}
332
- ${this.chrome === "none" ? m : this.renderNav(t)}
330
+ ${this.chrome === "none" ? d : this.renderNav(t)}
333
331
  </div>`;
334
332
  }
335
333
  /** Back + Next/Submit (or Reject/Approve on an approval step). */
336
334
  renderNav(t) {
337
335
  var r;
338
- const e = this.busy ? "true" : m;
336
+ const e = this.busy ? "true" : d;
339
337
  return h`<div class="baht-workflow-nav">
340
338
  ${this.showBack && (((r = this.run) == null ? void 0 : r.history.length) ?? 0) > 0 ? h`<button type="button" class="baht-button baht-button--back"
341
339
  aria-disabled=${e}
@@ -344,14 +342,14 @@ let a = class extends g {
344
342
  this.back();
345
343
  }}
346
344
  >
347
- ${this.backLabel ?? d("back")}
348
- </button>` : m}
345
+ ${this.backLabel ?? m("back")}
346
+ </button>` : d}
349
347
  ${t.kind === "approval" ? this.renderDecision(t) : this.renderNext()}
350
348
  </div>`;
351
349
  }
352
350
  renderDecision(t) {
353
351
  var r, i;
354
- const e = this.busy ? "true" : m;
352
+ const e = this.busy ? "true" : d;
355
353
  return h`<button
356
354
  type="button"
357
355
  class="baht-button baht-button--reject"
@@ -361,7 +359,7 @@ let a = class extends g {
361
359
  this.decide("rejected");
362
360
  }}
363
361
  >
364
- ${((r = t.approval) == null ? void 0 : r.reject_label) ?? d("reject")}
362
+ ${((r = t.approval) == null ? void 0 : r.reject_label) ?? m("reject")}
365
363
  </button>
366
364
  <button
367
365
  type="button"
@@ -373,11 +371,11 @@ let a = class extends g {
373
371
  this.decide("approved");
374
372
  }}
375
373
  >
376
- ${((i = t.approval) == null ? void 0 : i.approve_label) ?? d("approve")}
374
+ ${((i = t.approval) == null ? void 0 : i.approve_label) ?? m("approve")}
377
375
  </button>`;
378
376
  }
379
377
  renderNext() {
380
- const t = this.busy ? "true" : m;
378
+ const t = this.busy ? "true" : d;
381
379
  return h`<button
382
380
  type="button"
383
381
  class="baht-button baht-button--next"
@@ -388,7 +386,7 @@ let a = class extends g {
388
386
  this.next();
389
387
  }}
390
388
  >
391
- ${this.isLast ? this.submitLabel ?? d("submit") : this.nextLabel ?? d("next")}
389
+ ${this.isLast ? this.submitLabel ?? m("submit") : this.nextLabel ?? m("next")}
392
390
  </button>`;
393
391
  }
394
392
  };
@@ -444,6 +442,9 @@ a = l([
444
442
  E("baht-workflow")
445
443
  ], a);
446
444
  function O(t, e) {
445
+ return e === "rule-error" ? "the rules never settled, so the data is not submitted" : e === "self-transition" ? `target "${t}" is the current form (self-transition)` : `target "${t}" is not visible`;
446
+ }
447
+ function W(t, e) {
447
448
  const r = Object.keys(t);
448
449
  return r.length === Object.keys(e).length && r.every((i) => {
449
450
  const s = t[i], o = e[i];
@@ -1,4 +1,4 @@
1
- const i = "0.1.1";
1
+ const i = "0.1.2";
2
2
  function o(e) {
3
3
  return (n) => {
4
4
  const t = customElements.get(e);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://raw.githubusercontent.com/JetBrains/web-types/master/schema/web-types.json",
3
3
  "name": "@20baht/ui",
4
- "version": "0.1.1",
4
+ "version": "0.1.2",
5
5
  "description-markup": "markdown",
6
6
  "contributions": {
7
7
  "html": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@20baht/ui",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "type": "module",
5
5
  "description": "JSON-driven form + workflow engine. Send JSON in, get an interactive form out.",
6
6
  "license": "MIT",