bank20baht-ui 0.7.1 → 0.7.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.
- package/dist/components/primitives/baht-radio.js +25 -18
- package/dist/core/types.d.ts +4 -0
- package/dist/css/components.css +15 -0
- package/dist/tokens.css +15 -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
|
@@ -387,6 +387,21 @@
|
|
|
387
387
|
align-items: center;
|
|
388
388
|
gap: var(--baht-space-2);
|
|
389
389
|
}
|
|
390
|
+
/* `option.width` — same fractions as `field.width`, against the card row's
|
|
391
|
+
own gap (`--baht-space-3`) instead of the form grid's `--baht-field-gap`,
|
|
392
|
+
overriding the default `flex: 1 1 200px` auto-wrap. */
|
|
393
|
+
.baht-option-card--w-1-4 {
|
|
394
|
+
flex: 0 0 calc(25% - var(--baht-space-3) * 3 / 4);
|
|
395
|
+
}
|
|
396
|
+
.baht-option-card--w-1-2 {
|
|
397
|
+
flex: 0 0 calc(50% - var(--baht-space-3) / 2);
|
|
398
|
+
}
|
|
399
|
+
.baht-option-card--w-3-4 {
|
|
400
|
+
flex: 0 0 calc(75% - var(--baht-space-3) / 4);
|
|
401
|
+
}
|
|
402
|
+
.baht-option-card--w-full {
|
|
403
|
+
flex: 0 0 100%;
|
|
404
|
+
}
|
|
390
405
|
/* Selection reads from the card's own border/wash (above), not a radio
|
|
391
406
|
bullet — visually hidden rather than `display: none` so the input stays
|
|
392
407
|
in the tab order and keyboard-focusable (`:focus-visible` above). */
|
package/dist/tokens.css
CHANGED
|
@@ -833,6 +833,21 @@
|
|
|
833
833
|
align-items: center;
|
|
834
834
|
gap: var(--baht-space-2);
|
|
835
835
|
}
|
|
836
|
+
/* `option.width` — same fractions as `field.width`, against the card row's
|
|
837
|
+
own gap (`--baht-space-3`) instead of the form grid's `--baht-field-gap`,
|
|
838
|
+
overriding the default `flex: 1 1 200px` auto-wrap. */
|
|
839
|
+
.baht-option-card--w-1-4 {
|
|
840
|
+
flex: 0 0 calc(25% - var(--baht-space-3) * 3 / 4);
|
|
841
|
+
}
|
|
842
|
+
.baht-option-card--w-1-2 {
|
|
843
|
+
flex: 0 0 calc(50% - var(--baht-space-3) / 2);
|
|
844
|
+
}
|
|
845
|
+
.baht-option-card--w-3-4 {
|
|
846
|
+
flex: 0 0 calc(75% - var(--baht-space-3) / 4);
|
|
847
|
+
}
|
|
848
|
+
.baht-option-card--w-full {
|
|
849
|
+
flex: 0 0 100%;
|
|
850
|
+
}
|
|
836
851
|
/* Selection reads from the card's own border/wash (above), not a radio
|
|
837
852
|
bullet — visually hidden rather than `display: none` so the input stays
|
|
838
853
|
in the tab order and keyboard-focusable (`:focus-visible` above). */
|
package/dist/web-types.json
CHANGED