bank20baht-ui 0.7.1 → 0.7.3
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/primitives/baht-radio.js +25 -18
- package/dist/core/types.d.ts +4 -0
- package/dist/css/components.css +29 -0
- package/dist/tokens.css +29 -0
- package/dist/web-types.json +1 -1
- package/package.json +1 -1
|
@@ -1,16 +1,22 @@
|
|
|
1
|
-
import { html as
|
|
2
|
-
import { customElement as
|
|
1
|
+
import { html as i, nothing as r } from "lit";
|
|
2
|
+
import { customElement as h } from "lit/decorators.js";
|
|
3
3
|
import { live as d } from "lit/directives/live.js";
|
|
4
|
-
import { BahtFieldBase as
|
|
4
|
+
import { BahtFieldBase as p } from "../base.js";
|
|
5
5
|
import { isIconName as b, renderIcon as $ } from "./icons.js";
|
|
6
|
-
var
|
|
7
|
-
for (var
|
|
8
|
-
(
|
|
9
|
-
return
|
|
6
|
+
var u = Object.getOwnPropertyDescriptor, m = (a, t, c, s) => {
|
|
7
|
+
for (var e = s > 1 ? void 0 : s ? u(t, c) : t, n = a.length - 1, o; n >= 0; n--)
|
|
8
|
+
(o = a[n]) && (e = o(e) || e);
|
|
9
|
+
return e;
|
|
10
10
|
};
|
|
11
|
-
|
|
11
|
+
const v = {
|
|
12
|
+
"1/4": "baht-option-card--w-1-4",
|
|
13
|
+
"1/2": "baht-option-card--w-1-2",
|
|
14
|
+
"3/4": "baht-option-card--w-3-4",
|
|
15
|
+
full: "baht-option-card--w-full"
|
|
16
|
+
};
|
|
17
|
+
let l = class extends p {
|
|
12
18
|
renderOption(a) {
|
|
13
|
-
return
|
|
19
|
+
return i`<label class="baht-option">
|
|
14
20
|
<input
|
|
15
21
|
type="radio"
|
|
16
22
|
name=${this.controlId}
|
|
@@ -23,7 +29,8 @@ let o = class extends h {
|
|
|
23
29
|
</label>`;
|
|
24
30
|
}
|
|
25
31
|
renderCardOption(a) {
|
|
26
|
-
|
|
32
|
+
const t = a.width ? ` ${v[a.width]}` : "";
|
|
33
|
+
return i`<label class="baht-option baht-option--card${t}">
|
|
27
34
|
<span class="baht-option-card-row">
|
|
28
35
|
<input
|
|
29
36
|
type="radio"
|
|
@@ -33,15 +40,15 @@ let o = class extends h {
|
|
|
33
40
|
?disabled=${this.disabled || this.readonly}
|
|
34
41
|
@change=${() => this.emitInput(a.key)}
|
|
35
42
|
/>
|
|
36
|
-
${a.icon && b(a.icon) ?
|
|
43
|
+
${a.icon && b(a.icon) ? i`<span class="baht-option-card-icon">${$(a.icon)}</span>` : r}
|
|
37
44
|
<span class="baht-option-card-title">${a.label}</span>
|
|
38
45
|
</span>
|
|
39
|
-
${a.description ?
|
|
46
|
+
${a.description ? i`<span class="baht-option-card-desc">${a.description}</span>` : r}
|
|
40
47
|
</label>`;
|
|
41
48
|
}
|
|
42
49
|
renderControl() {
|
|
43
50
|
const a = this.field.variant === "card";
|
|
44
|
-
return
|
|
51
|
+
return i`<div
|
|
45
52
|
class="baht-control baht-control--radio${a ? " baht-control--radio-card" : ""}"
|
|
46
53
|
role="radiogroup"
|
|
47
54
|
aria-labelledby=${this.field.label ? this.labelId : r}
|
|
@@ -50,14 +57,14 @@ let o = class extends h {
|
|
|
50
57
|
aria-describedby=${this.describedBy}
|
|
51
58
|
>
|
|
52
59
|
${(this.field.options ?? []).map(
|
|
53
|
-
(
|
|
60
|
+
(t) => a ? this.renderCardOption(t) : this.renderOption(t)
|
|
54
61
|
)}
|
|
55
62
|
</div>`;
|
|
56
63
|
}
|
|
57
64
|
};
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
],
|
|
65
|
+
l = m([
|
|
66
|
+
h("baht-radio")
|
|
67
|
+
], l);
|
|
61
68
|
export {
|
|
62
|
-
|
|
69
|
+
l as BahtRadio
|
|
63
70
|
};
|
package/dist/core/types.d.ts
CHANGED
|
@@ -10,6 +10,10 @@ export interface FieldOption {
|
|
|
10
10
|
description?: string;
|
|
11
11
|
/** radio (variant: 'card' only): icon name from the curated set (see icons.ts). */
|
|
12
12
|
icon?: string;
|
|
13
|
+
/** radio (variant: 'card' only): this option's own share of the row (same
|
|
14
|
+
* fractions as `FieldDescriptor.width`), instead of the default
|
|
15
|
+
* auto-wrapping ~200px card. Unset options keep the default. */
|
|
16
|
+
width?: FieldWidth;
|
|
13
17
|
}
|
|
14
18
|
/** Ordering/equality ops available to the `compare` validator. */
|
|
15
19
|
export type CompareOp = 'eq' | 'ne' | 'gt' | 'gte' | 'lt' | 'lte';
|
package/dist/css/components.css
CHANGED
|
@@ -367,6 +367,12 @@
|
|
|
367
367
|
flex-direction: column;
|
|
368
368
|
gap: var(--baht-space-1);
|
|
369
369
|
flex: 1 1 200px;
|
|
370
|
+
/* An `option.width` fraction (below) counts padding+border in that
|
|
371
|
+
percentage, like every other sized box in this file — without this,
|
|
372
|
+
the browser default (content-box) adds padding on top of the
|
|
373
|
+
flex-basis, inflating the rendered card past its intended share of
|
|
374
|
+
the row. */
|
|
375
|
+
box-sizing: border-box;
|
|
370
376
|
border: var(--baht-border-default);
|
|
371
377
|
border-radius: var(--baht-radius-md);
|
|
372
378
|
padding: var(--baht-space-3) var(--baht-space-4);
|
|
@@ -387,6 +393,29 @@
|
|
|
387
393
|
align-items: center;
|
|
388
394
|
gap: var(--baht-space-2);
|
|
389
395
|
}
|
|
396
|
+
/* `option.width` — same fractions as `field.width`, against the card row's
|
|
397
|
+
own gap (`--baht-space-3`) instead of the form grid's `--baht-field-gap`,
|
|
398
|
+
overriding the default `flex: 1 1 200px` auto-wrap. `min-width: 0`
|
|
399
|
+
overrides the flex item default of `auto` (= its content's min-content
|
|
400
|
+
width), which otherwise floors the card at its label's natural width and
|
|
401
|
+
silently defeats a basis smaller than that (e.g. long labels forcing 3
|
|
402
|
+
per row instead of the requested 4) — the label wraps instead. */
|
|
403
|
+
.baht-option-card--w-1-4 {
|
|
404
|
+
flex: 0 0 calc(25% - var(--baht-space-3) * 3 / 4);
|
|
405
|
+
min-width: 0;
|
|
406
|
+
}
|
|
407
|
+
.baht-option-card--w-1-2 {
|
|
408
|
+
flex: 0 0 calc(50% - var(--baht-space-3) / 2);
|
|
409
|
+
min-width: 0;
|
|
410
|
+
}
|
|
411
|
+
.baht-option-card--w-3-4 {
|
|
412
|
+
flex: 0 0 calc(75% - var(--baht-space-3) / 4);
|
|
413
|
+
min-width: 0;
|
|
414
|
+
}
|
|
415
|
+
.baht-option-card--w-full {
|
|
416
|
+
flex: 0 0 100%;
|
|
417
|
+
min-width: 0;
|
|
418
|
+
}
|
|
390
419
|
/* Selection reads from the card's own border/wash (above), not a radio
|
|
391
420
|
bullet — visually hidden rather than `display: none` so the input stays
|
|
392
421
|
in the tab order and keyboard-focusable (`:focus-visible` above). */
|
package/dist/tokens.css
CHANGED
|
@@ -813,6 +813,12 @@
|
|
|
813
813
|
flex-direction: column;
|
|
814
814
|
gap: var(--baht-space-1);
|
|
815
815
|
flex: 1 1 200px;
|
|
816
|
+
/* An `option.width` fraction (below) counts padding+border in that
|
|
817
|
+
percentage, like every other sized box in this file — without this,
|
|
818
|
+
the browser default (content-box) adds padding on top of the
|
|
819
|
+
flex-basis, inflating the rendered card past its intended share of
|
|
820
|
+
the row. */
|
|
821
|
+
box-sizing: border-box;
|
|
816
822
|
border: var(--baht-border-default);
|
|
817
823
|
border-radius: var(--baht-radius-md);
|
|
818
824
|
padding: var(--baht-space-3) var(--baht-space-4);
|
|
@@ -833,6 +839,29 @@
|
|
|
833
839
|
align-items: center;
|
|
834
840
|
gap: var(--baht-space-2);
|
|
835
841
|
}
|
|
842
|
+
/* `option.width` — same fractions as `field.width`, against the card row's
|
|
843
|
+
own gap (`--baht-space-3`) instead of the form grid's `--baht-field-gap`,
|
|
844
|
+
overriding the default `flex: 1 1 200px` auto-wrap. `min-width: 0`
|
|
845
|
+
overrides the flex item default of `auto` (= its content's min-content
|
|
846
|
+
width), which otherwise floors the card at its label's natural width and
|
|
847
|
+
silently defeats a basis smaller than that (e.g. long labels forcing 3
|
|
848
|
+
per row instead of the requested 4) — the label wraps instead. */
|
|
849
|
+
.baht-option-card--w-1-4 {
|
|
850
|
+
flex: 0 0 calc(25% - var(--baht-space-3) * 3 / 4);
|
|
851
|
+
min-width: 0;
|
|
852
|
+
}
|
|
853
|
+
.baht-option-card--w-1-2 {
|
|
854
|
+
flex: 0 0 calc(50% - var(--baht-space-3) / 2);
|
|
855
|
+
min-width: 0;
|
|
856
|
+
}
|
|
857
|
+
.baht-option-card--w-3-4 {
|
|
858
|
+
flex: 0 0 calc(75% - var(--baht-space-3) / 4);
|
|
859
|
+
min-width: 0;
|
|
860
|
+
}
|
|
861
|
+
.baht-option-card--w-full {
|
|
862
|
+
flex: 0 0 100%;
|
|
863
|
+
min-width: 0;
|
|
864
|
+
}
|
|
836
865
|
/* Selection reads from the card's own border/wash (above), not a radio
|
|
837
866
|
bullet — visually hidden rather than `display: none` so the input stays
|
|
838
867
|
in the tab order and keyboard-focusable (`:focus-visible` above). */
|
package/dist/web-types.json
CHANGED