@20baht/ui 0.0.0-stage → 0.1.1
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/LICENSE +21 -0
- package/README.md +512 -2
- package/dist/components/baht-form.d.ts +206 -0
- package/dist/components/baht-form.js +630 -0
- package/dist/components/baht-workflow.d.ts +187 -0
- package/dist/components/baht-workflow.js +455 -0
- package/dist/components/base.d.ts +92 -0
- package/dist/components/base.js +138 -0
- package/dist/components/combobox-controller.d.ts +65 -0
- package/dist/components/combobox-controller.js +82 -0
- package/dist/components/define.d.ts +7 -0
- package/dist/components/define.js +16 -0
- package/dist/components/field-base.d.ts +84 -0
- package/dist/components/field-base.js +152 -0
- package/dist/components/floating.d.ts +84 -0
- package/dist/components/floating.js +182 -0
- package/dist/components/form-layout.d.ts +39 -0
- package/dist/components/form-layout.js +67 -0
- package/dist/components/form-options.d.ts +39 -0
- package/dist/components/form-options.js +65 -0
- package/dist/components/form-readonly.d.ts +20 -0
- package/dist/components/form-readonly.js +70 -0
- package/dist/components/layers.d.ts +4 -0
- package/dist/components/layers.js +15 -0
- package/dist/components/menu-controller.d.ts +65 -0
- package/dist/components/menu-controller.js +134 -0
- package/dist/components/motion.d.ts +9 -0
- package/dist/components/motion.js +16 -0
- package/dist/components/primitives/baht-accordion.d.ts +29 -0
- package/dist/components/primitives/baht-accordion.js +66 -0
- package/dist/components/primitives/baht-alert.d.ts +20 -0
- package/dist/components/primitives/baht-alert.js +62 -0
- package/dist/components/primitives/baht-app-shell.d.ts +81 -0
- package/dist/components/primitives/baht-app-shell.js +161 -0
- package/dist/components/primitives/baht-approval-chain.d.ts +59 -0
- package/dist/components/primitives/baht-approval-chain.js +80 -0
- package/dist/components/primitives/baht-avatar.d.ts +19 -0
- package/dist/components/primitives/baht-avatar.js +43 -0
- package/dist/components/primitives/baht-badge.d.ts +24 -0
- package/dist/components/primitives/baht-badge.js +41 -0
- package/dist/components/primitives/baht-bar-chart.d.ts +78 -0
- package/dist/components/primitives/baht-bar-chart.js +361 -0
- package/dist/components/primitives/baht-breadcrumbs.d.ts +23 -0
- package/dist/components/primitives/baht-breadcrumbs.js +45 -0
- package/dist/components/primitives/baht-button.d.ts +89 -0
- package/dist/components/primitives/baht-button.js +146 -0
- package/dist/components/primitives/baht-calendar.d.ts +96 -0
- package/dist/components/primitives/baht-calendar.js +398 -0
- package/dist/components/primitives/baht-card.d.ts +34 -0
- package/dist/components/primitives/baht-card.js +70 -0
- package/dist/components/primitives/baht-catalog-card.d.ts +52 -0
- package/dist/components/primitives/baht-catalog-card.js +90 -0
- package/dist/components/primitives/baht-checkbox.d.ts +7 -0
- package/dist/components/primitives/baht-checkbox.js +40 -0
- package/dist/components/primitives/baht-choice-group.d.ts +52 -0
- package/dist/components/primitives/baht-choice-group.js +71 -0
- package/dist/components/primitives/baht-code.d.ts +18 -0
- package/dist/components/primitives/baht-code.js +33 -0
- package/dist/components/primitives/baht-column-picker.d.ts +69 -0
- package/dist/components/primitives/baht-column-picker.js +234 -0
- package/dist/components/primitives/baht-comments.d.ts +38 -0
- package/dist/components/primitives/baht-comments.js +102 -0
- package/dist/components/primitives/baht-currency.d.ts +13 -0
- package/dist/components/primitives/baht-currency.js +69 -0
- package/dist/components/primitives/baht-datepicker.d.ts +77 -0
- package/dist/components/primitives/baht-datepicker.js +235 -0
- package/dist/components/primitives/baht-donut-chart.d.ts +24 -0
- package/dist/components/primitives/baht-donut-chart.js +88 -0
- package/dist/components/primitives/baht-edit-table.d.ts +45 -0
- package/dist/components/primitives/baht-edit-table.js +176 -0
- package/dist/components/primitives/baht-empty-state.d.ts +26 -0
- package/dist/components/primitives/baht-empty-state.js +51 -0
- package/dist/components/primitives/baht-error-state.d.ts +21 -0
- package/dist/components/primitives/baht-error-state.js +44 -0
- package/dist/components/primitives/baht-facts.d.ts +42 -0
- package/dist/components/primitives/baht-facts.js +49 -0
- package/dist/components/primitives/baht-fieldset.d.ts +19 -0
- package/dist/components/primitives/baht-fieldset.js +42 -0
- package/dist/components/primitives/baht-file.d.ts +27 -0
- package/dist/components/primitives/baht-file.js +158 -0
- package/dist/components/primitives/baht-filter-builder.d.ts +39 -0
- package/dist/components/primitives/baht-filter-builder.js +201 -0
- package/dist/components/primitives/baht-filter.d.ts +36 -0
- package/dist/components/primitives/baht-filter.js +64 -0
- package/dist/components/primitives/baht-heatmap.d.ts +49 -0
- package/dist/components/primitives/baht-heatmap.js +168 -0
- package/dist/components/primitives/baht-input.d.ts +10 -0
- package/dist/components/primitives/baht-input.js +44 -0
- package/dist/components/primitives/baht-keyvalue-editor.d.ts +28 -0
- package/dist/components/primitives/baht-keyvalue-editor.js +106 -0
- package/dist/components/primitives/baht-line-chart.d.ts +45 -0
- package/dist/components/primitives/baht-line-chart.js +183 -0
- package/dist/components/primitives/baht-link.d.ts +26 -0
- package/dist/components/primitives/baht-link.js +48 -0
- package/dist/components/primitives/baht-list.d.ts +29 -0
- package/dist/components/primitives/baht-list.js +79 -0
- package/dist/components/primitives/baht-loading-overlay.d.ts +15 -0
- package/dist/components/primitives/baht-loading-overlay.js +33 -0
- package/dist/components/primitives/baht-markdown-view.d.ts +17 -0
- package/dist/components/primitives/baht-markdown-view.js +39 -0
- package/dist/components/primitives/baht-markdown.d.ts +34 -0
- package/dist/components/primitives/baht-markdown.js +177 -0
- package/dist/components/primitives/baht-menu.d.ts +53 -0
- package/dist/components/primitives/baht-menu.js +100 -0
- package/dist/components/primitives/baht-meter.d.ts +67 -0
- package/dist/components/primitives/baht-meter.js +107 -0
- package/dist/components/primitives/baht-modal.d.ts +71 -0
- package/dist/components/primitives/baht-modal.js +164 -0
- package/dist/components/primitives/baht-multiselect.d.ts +8 -0
- package/dist/components/primitives/baht-multiselect.js +47 -0
- package/dist/components/primitives/baht-notification-bell.d.ts +54 -0
- package/dist/components/primitives/baht-notification-bell.js +143 -0
- package/dist/components/primitives/baht-number.d.ts +5 -0
- package/dist/components/primitives/baht-number.js +39 -0
- package/dist/components/primitives/baht-order-box.d.ts +24 -0
- package/dist/components/primitives/baht-order-box.js +50 -0
- package/dist/components/primitives/baht-otp.d.ts +49 -0
- package/dist/components/primitives/baht-otp.js +109 -0
- package/dist/components/primitives/baht-page-header.d.ts +43 -0
- package/dist/components/primitives/baht-page-header.js +78 -0
- package/dist/components/primitives/baht-pagination.d.ts +33 -0
- package/dist/components/primitives/baht-pagination.js +86 -0
- package/dist/components/primitives/baht-popover.d.ts +45 -0
- package/dist/components/primitives/baht-popover.js +112 -0
- package/dist/components/primitives/baht-progress-ring.d.ts +22 -0
- package/dist/components/primitives/baht-progress-ring.js +62 -0
- package/dist/components/primitives/baht-progress.d.ts +17 -0
- package/dist/components/primitives/baht-progress.js +48 -0
- package/dist/components/primitives/baht-radio.d.ts +7 -0
- package/dist/components/primitives/baht-radio.js +74 -0
- package/dist/components/primitives/baht-range.d.ts +38 -0
- package/dist/components/primitives/baht-range.js +88 -0
- package/dist/components/primitives/baht-rating.d.ts +40 -0
- package/dist/components/primitives/baht-rating.js +107 -0
- package/dist/components/primitives/baht-record-bar.d.ts +30 -0
- package/dist/components/primitives/baht-record-bar.js +60 -0
- package/dist/components/primitives/baht-reference-dialog.d.ts +87 -0
- package/dist/components/primitives/baht-reference-dialog.js +418 -0
- package/dist/components/primitives/baht-reference-picker.d.ts +110 -0
- package/dist/components/primitives/baht-reference-picker.js +321 -0
- package/dist/components/primitives/baht-repeater.d.ts +59 -0
- package/dist/components/primitives/baht-repeater.js +315 -0
- package/dist/components/primitives/baht-rule-builder.d.ts +24 -0
- package/dist/components/primitives/baht-rule-builder.js +177 -0
- package/dist/components/primitives/baht-saved-filters.d.ts +41 -0
- package/dist/components/primitives/baht-saved-filters.js +126 -0
- package/dist/components/primitives/baht-search.d.ts +34 -0
- package/dist/components/primitives/baht-search.js +71 -0
- package/dist/components/primitives/baht-section-header.d.ts +28 -0
- package/dist/components/primitives/baht-section-header.js +48 -0
- package/dist/components/primitives/baht-section.d.ts +23 -0
- package/dist/components/primitives/baht-section.js +49 -0
- package/dist/components/primitives/baht-select.d.ts +49 -0
- package/dist/components/primitives/baht-select.js +197 -0
- package/dist/components/primitives/baht-skeleton.d.ts +16 -0
- package/dist/components/primitives/baht-skeleton.js +37 -0
- package/dist/components/primitives/baht-sparkline.d.ts +23 -0
- package/dist/components/primitives/baht-sparkline.js +56 -0
- package/dist/components/primitives/baht-spinner.d.ts +13 -0
- package/dist/components/primitives/baht-spinner.js +30 -0
- package/dist/components/primitives/baht-split-button.d.ts +43 -0
- package/dist/components/primitives/baht-split-button.js +87 -0
- package/dist/components/primitives/baht-stat-chart.d.ts +14 -0
- package/dist/components/primitives/baht-stat-chart.js +38 -0
- package/dist/components/primitives/baht-stat.d.ts +56 -0
- package/dist/components/primitives/baht-stat.js +117 -0
- package/dist/components/primitives/baht-steps.d.ts +33 -0
- package/dist/components/primitives/baht-steps.js +60 -0
- package/dist/components/primitives/baht-swipe-row.d.ts +64 -0
- package/dist/components/primitives/baht-swipe-row.js +178 -0
- package/dist/components/primitives/baht-table.d.ts +315 -0
- package/dist/components/primitives/baht-table.js +640 -0
- package/dist/components/primitives/baht-tabs.d.ts +54 -0
- package/dist/components/primitives/baht-tabs.js +128 -0
- package/dist/components/primitives/baht-tags.d.ts +96 -0
- package/dist/components/primitives/baht-tags.js +323 -0
- package/dist/components/primitives/baht-text.d.ts +10 -0
- package/dist/components/primitives/baht-text.js +29 -0
- package/dist/components/primitives/baht-textarea.d.ts +5 -0
- package/dist/components/primitives/baht-textarea.js +40 -0
- package/dist/components/primitives/baht-theme-toggle.d.ts +44 -0
- package/dist/components/primitives/baht-theme-toggle.js +101 -0
- package/dist/components/primitives/baht-timeline.d.ts +21 -0
- package/dist/components/primitives/baht-timeline.js +42 -0
- package/dist/components/primitives/baht-toast.d.ts +29 -0
- package/dist/components/primitives/baht-toast.js +83 -0
- package/dist/components/primitives/baht-toggle.d.ts +6 -0
- package/dist/components/primitives/baht-toggle.js +42 -0
- package/dist/components/primitives/baht-tooltip.d.ts +34 -0
- package/dist/components/primitives/baht-tooltip.js +85 -0
- package/dist/components/primitives/baht-tree.d.ts +58 -0
- package/dist/components/primitives/baht-tree.js +159 -0
- package/dist/components/primitives/baht-typeahead.d.ts +92 -0
- package/dist/components/primitives/baht-typeahead.js +258 -0
- package/dist/components/primitives/baht-upload.d.ts +108 -0
- package/dist/components/primitives/baht-upload.js +325 -0
- package/dist/components/primitives/baht-wizard.d.ts +57 -0
- package/dist/components/primitives/baht-wizard.js +147 -0
- package/dist/components/primitives/charts.d.ts +134 -0
- package/dist/components/primitives/charts.js +184 -0
- package/dist/components/primitives/column-map.d.ts +56 -0
- package/dist/components/primitives/column-map.js +70 -0
- package/dist/components/primitives/control-icons.d.ts +2 -0
- package/dist/components/primitives/control-icons.js +40 -0
- package/dist/components/primitives/icons.d.ts +24 -0
- package/dist/components/primitives/icons.js +86 -0
- package/dist/components/primitives/illustrations.d.ts +21 -0
- package/dist/components/primitives/illustrations.js +78 -0
- package/dist/components/primitives/index.d.ts +89 -0
- package/dist/components/primitives/kbd.d.ts +6 -0
- package/dist/components/primitives/kbd.js +9 -0
- package/dist/components/primitives/listbox.d.ts +2 -0
- package/dist/components/primitives/listbox.js +7 -0
- package/dist/components/primitives/markdown-render.d.ts +9 -0
- package/dist/components/primitives/markdown-render.js +77 -0
- package/dist/components/primitives/rule-rows.d.ts +55 -0
- package/dist/components/primitives/rule-rows.js +75 -0
- package/dist/components/primitives/tag-map.d.ts +6 -0
- package/dist/components/primitives/tag-map.js +39 -0
- package/dist/components/reference-labels.d.ts +22 -0
- package/dist/components/reference-labels.js +29 -0
- package/dist/components/shortcuts.d.ts +7 -0
- package/dist/components/shortcuts.js +43 -0
- package/dist/css/components.css +7517 -0
- package/dist/css/datepicker.css +346 -0
- package/dist/css/tokens.css +679 -0
- package/dist/custom-elements.json +45172 -0
- package/dist/engine.d.ts +1 -0
- package/dist/engine.js +1 -0
- package/dist/hydrate.d.ts +9 -0
- package/dist/hydrate.js +46 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +210 -0
- package/dist/overlay.d.ts +50 -0
- package/dist/overlay.js +140 -0
- package/dist/react.d.ts +557 -0
- package/dist/react.js +1 -0
- package/dist/register.d.ts +106 -0
- package/dist/register.js +99 -0
- package/dist/ssr.d.ts +16 -0
- package/dist/ssr.js +125 -0
- package/dist/tokens.css +8197 -0
- package/dist/vscode.css-custom-data.json +6 -0
- package/dist/vscode.html-custom-data.json +2261 -0
- package/dist/web-types.json +6523 -0
- package/package.json +157 -4
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { html as i, nothing as r } from "lit";
|
|
2
|
+
import { live as d } from "lit/directives/live.js";
|
|
3
|
+
import { BahtFieldBase as h } from "../field-base.js";
|
|
4
|
+
import { isIconName as p, renderIcon as b } from "./icons.js";
|
|
5
|
+
import { customElement as $ } from "../define.js";
|
|
6
|
+
var u = Object.getOwnPropertyDescriptor, m = (t, a, c, s) => {
|
|
7
|
+
for (var e = s > 1 ? void 0 : s ? u(a, c) : a, n = t.length - 1, o; n >= 0; n--)
|
|
8
|
+
(o = t[n]) && (e = o(e) || e);
|
|
9
|
+
return e;
|
|
10
|
+
};
|
|
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 h {
|
|
18
|
+
renderOption(t) {
|
|
19
|
+
return i`<label class="baht-option">
|
|
20
|
+
<input
|
|
21
|
+
type="radio"
|
|
22
|
+
name=${this.controlId}
|
|
23
|
+
value=${t.key}
|
|
24
|
+
.checked=${d(this.value === t.key)}
|
|
25
|
+
?disabled=${this.disabled || this.readonly}
|
|
26
|
+
@change=${() => {
|
|
27
|
+
this.emitInput(t.key);
|
|
28
|
+
}}
|
|
29
|
+
/>
|
|
30
|
+
<span>${t.label}</span>
|
|
31
|
+
</label>`;
|
|
32
|
+
}
|
|
33
|
+
renderCardOption(t) {
|
|
34
|
+
const a = t.width ? ` ${v[t.width]}` : "";
|
|
35
|
+
return i`<label class="baht-option baht-option--card${a}">
|
|
36
|
+
<span class="baht-option-card-row">
|
|
37
|
+
<input
|
|
38
|
+
type="radio"
|
|
39
|
+
name=${this.controlId}
|
|
40
|
+
value=${t.key}
|
|
41
|
+
.checked=${d(this.value === t.key)}
|
|
42
|
+
?disabled=${this.disabled || this.readonly}
|
|
43
|
+
@change=${() => {
|
|
44
|
+
this.emitInput(t.key);
|
|
45
|
+
}}
|
|
46
|
+
/>
|
|
47
|
+
${t.icon && p(t.icon) ? i`<span class="baht-option-card-icon">${b(t.icon)}</span>` : r}
|
|
48
|
+
<span class="baht-option-card-title">${t.label}</span>
|
|
49
|
+
</span>
|
|
50
|
+
${t.description ? i`<span class="baht-option-card-desc">${t.description}</span>` : r}
|
|
51
|
+
</label>`;
|
|
52
|
+
}
|
|
53
|
+
renderControl() {
|
|
54
|
+
const t = this.field.variant === "card";
|
|
55
|
+
return i`<div
|
|
56
|
+
class="baht-control baht-control--radio${t ? " baht-control--radio-card" : ""}"
|
|
57
|
+
role="radiogroup"
|
|
58
|
+
aria-labelledby=${this.field.label ? this.labelId : r}
|
|
59
|
+
aria-required=${this.required ? "true" : r}
|
|
60
|
+
aria-invalid=${this.invalidAttr}
|
|
61
|
+
aria-describedby=${this.describedBy}
|
|
62
|
+
>
|
|
63
|
+
${(this.field.options ?? []).map(
|
|
64
|
+
(a) => t ? this.renderCardOption(a) : this.renderOption(a)
|
|
65
|
+
)}
|
|
66
|
+
</div>`;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
l = m([
|
|
70
|
+
$("baht-radio")
|
|
71
|
+
], l);
|
|
72
|
+
export {
|
|
73
|
+
l as BahtRadio
|
|
74
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { nothing, TemplateResult } from 'lit';
|
|
2
|
+
import { BahtFieldBase } from '../field-base.js';
|
|
3
|
+
/**
|
|
4
|
+
* Range slider. Two modes, one tag:
|
|
5
|
+
*
|
|
6
|
+
* - **Standalone** (no `field`): `value` / `min` / `max` / `step` / `label`; emits
|
|
7
|
+
* `baht-change { value }` (a number) on every input.
|
|
8
|
+
*
|
|
9
|
+
* <baht-range min="0" max="100" step="5" value="40" label="Retry limit"></baht-range>
|
|
10
|
+
*
|
|
11
|
+
* - **Form field** (`type: 'range'`, set by `<baht-form>`): bounds from `field.min` /
|
|
12
|
+
* `field.max` / `field.step` (default 0 / 100 / 1), field label / help / error; emits
|
|
13
|
+
* `baht-input { key, value }` debounced while sliding and at once on release. `null`
|
|
14
|
+
* (untouched) parks the thumb at `min` and reads "—".
|
|
15
|
+
*
|
|
16
|
+
* @fires {CustomEvent<{ value: number }>} baht-change - Standalone mode: the slider moved. `detail: { value }`.
|
|
17
|
+
* @fires {CustomEvent<{ key: string; value: number | null }>} baht-input - Field mode: the slider moved. `detail: { key, value }`.
|
|
18
|
+
*/
|
|
19
|
+
export declare class BahtRange extends BahtFieldBase {
|
|
20
|
+
/** Current value. Standalone: a number. Field mode: `number | null` (null = untouched). */
|
|
21
|
+
value: unknown;
|
|
22
|
+
/** Standalone lower bound; a field uses `field.min`. */
|
|
23
|
+
min: number;
|
|
24
|
+
/** Standalone upper bound; a field uses `field.max`. */
|
|
25
|
+
max: number;
|
|
26
|
+
/** Standalone step; a field uses `field.step`. */
|
|
27
|
+
step: number;
|
|
28
|
+
/** Standalone visible label; a field uses its label. */
|
|
29
|
+
label: string;
|
|
30
|
+
/** Show the current value next to the slider. */
|
|
31
|
+
showValue: boolean;
|
|
32
|
+
private get isField();
|
|
33
|
+
private get bounds();
|
|
34
|
+
private get inputId();
|
|
35
|
+
private onInput;
|
|
36
|
+
protected renderControl(): TemplateResult;
|
|
37
|
+
protected render(): TemplateResult | typeof nothing;
|
|
38
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { nothing as p, html as u } from "lit";
|
|
2
|
+
import { property as h } from "lit/decorators.js";
|
|
3
|
+
import { live as d } from "lit/directives/live.js";
|
|
4
|
+
import { boolOff as m } from "../base.js";
|
|
5
|
+
import { BahtFieldBase as b } from "../field-base.js";
|
|
6
|
+
import { customElement as v } from "../define.js";
|
|
7
|
+
import { rangeBounds as f } from "@20baht/engine";
|
|
8
|
+
var c = Object.defineProperty, g = Object.getOwnPropertyDescriptor, o = (a, i, s, e) => {
|
|
9
|
+
for (var t = e > 1 ? void 0 : e ? g(i, s) : i, l = a.length - 1, n; l >= 0; l--)
|
|
10
|
+
(n = a[l]) && (t = (e ? n(i, s, t) : n(t)) || t);
|
|
11
|
+
return e && t && c(i, s, t), t;
|
|
12
|
+
};
|
|
13
|
+
let r = class extends b {
|
|
14
|
+
constructor() {
|
|
15
|
+
super(...arguments), this.value = 0, this.min = 0, this.max = 100, this.step = 1, this.label = "", this.showValue = !0;
|
|
16
|
+
}
|
|
17
|
+
get isField() {
|
|
18
|
+
return this.assignedField !== void 0;
|
|
19
|
+
}
|
|
20
|
+
get bounds() {
|
|
21
|
+
return this.isField ? f(this.field) : { min: this.min, max: this.max, step: this.step };
|
|
22
|
+
}
|
|
23
|
+
get inputId() {
|
|
24
|
+
return this.isField ? this.controlId : `baht-range-${this.uid}`;
|
|
25
|
+
}
|
|
26
|
+
onInput(a, i) {
|
|
27
|
+
const s = Number(a.target.value);
|
|
28
|
+
if (!this.isField) {
|
|
29
|
+
i || this.emit("baht-change", { value: s });
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
this.emitTyped(s), i && this.flushTyped();
|
|
33
|
+
}
|
|
34
|
+
renderControl() {
|
|
35
|
+
const { min: a, max: i, step: s } = this.bounds, e = this.isField, t = e ? this.shownValue : this.value, l = typeof t == "number" && Number.isFinite(t);
|
|
36
|
+
return u`<div class="baht-range-row">
|
|
37
|
+
<input
|
|
38
|
+
type="range"
|
|
39
|
+
id=${this.inputId}
|
|
40
|
+
aria-label=${e || this.label ? p : "Value"}
|
|
41
|
+
aria-invalid=${e ? this.invalidAttr : p}
|
|
42
|
+
aria-describedby=${e ? this.describedBy : p}
|
|
43
|
+
min=${a}
|
|
44
|
+
max=${i}
|
|
45
|
+
step=${s}
|
|
46
|
+
.value=${d(String(l ? t : a))}
|
|
47
|
+
?disabled=${this.disabled || e && this.readonly}
|
|
48
|
+
@input=${(n) => {
|
|
49
|
+
this.onInput(n, !1);
|
|
50
|
+
}}
|
|
51
|
+
@change=${(n) => {
|
|
52
|
+
this.onInput(n, !0);
|
|
53
|
+
}}
|
|
54
|
+
/>
|
|
55
|
+
${this.showValue ? u`<span class="baht-range-value">${l ? String(t) : "—"}</span>` : p}
|
|
56
|
+
</div>`;
|
|
57
|
+
}
|
|
58
|
+
render() {
|
|
59
|
+
return this.isField ? u`<div class="baht-range">${super.render()}</div>` : u`<div class="baht-range">
|
|
60
|
+
${this.label ? u`<label class="baht-label" for=${this.inputId}>${this.label}</label>` : p}
|
|
61
|
+
${this.renderControl()}
|
|
62
|
+
</div>`;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
o([
|
|
66
|
+
h({ type: Number })
|
|
67
|
+
], r.prototype, "value", 2);
|
|
68
|
+
o([
|
|
69
|
+
h({ type: Number })
|
|
70
|
+
], r.prototype, "min", 2);
|
|
71
|
+
o([
|
|
72
|
+
h({ type: Number })
|
|
73
|
+
], r.prototype, "max", 2);
|
|
74
|
+
o([
|
|
75
|
+
h({ type: Number })
|
|
76
|
+
], r.prototype, "step", 2);
|
|
77
|
+
o([
|
|
78
|
+
h()
|
|
79
|
+
], r.prototype, "label", 2);
|
|
80
|
+
o([
|
|
81
|
+
h({ attribute: "show-value", converter: m })
|
|
82
|
+
], r.prototype, "showValue", 2);
|
|
83
|
+
r = o([
|
|
84
|
+
v("baht-range")
|
|
85
|
+
], r);
|
|
86
|
+
export {
|
|
87
|
+
r as BahtRange
|
|
88
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { nothing, TemplateResult } from 'lit';
|
|
2
|
+
import { BahtFieldBase } from '../field-base.js';
|
|
3
|
+
/**
|
|
4
|
+
* Star rating. Two modes, one tag:
|
|
5
|
+
*
|
|
6
|
+
* - **Standalone** (no `field`): controlled by `value` / `max` / `label`; emits
|
|
7
|
+
* `baht-change { value }`, where re-picking the current star clears to `0`.
|
|
8
|
+
*
|
|
9
|
+
* <baht-rating value="3" max="5"></baht-rating>
|
|
10
|
+
* <baht-rating value="4" readonly></baht-rating>
|
|
11
|
+
*
|
|
12
|
+
* - **Form field** (`type: 'rating'`, set by `<baht-form>`): `field.max` stars
|
|
13
|
+
* (1–10, default 5), field label / help / error, emits `baht-input { key, value }`
|
|
14
|
+
* with a whole number of stars, or `null` when re-picking the current star clears it.
|
|
15
|
+
*
|
|
16
|
+
* Keyboard (APG radio group): arrows move the value, Home / End jump the ends.
|
|
17
|
+
*
|
|
18
|
+
* @fires {CustomEvent<{ value: number }>} baht-change - Standalone mode: a star was picked. `detail: { value }` (0 = cleared).
|
|
19
|
+
* @fires {CustomEvent<{ key: string; value: number | null }>} baht-input - Field mode: a star was picked. `detail: { key, value }` (null = cleared).
|
|
20
|
+
*/
|
|
21
|
+
export declare class BahtRating extends BahtFieldBase {
|
|
22
|
+
/** Picked star count. Standalone: a number (`0` = none). Field mode: `number | null`. */
|
|
23
|
+
value: unknown;
|
|
24
|
+
/** Standalone star count; a field uses `field.max` instead. */
|
|
25
|
+
max: number;
|
|
26
|
+
/** Standalone accessible name for the radiogroup; a field uses its label. */
|
|
27
|
+
label: string;
|
|
28
|
+
private hover;
|
|
29
|
+
private get isField();
|
|
30
|
+
private get starCount();
|
|
31
|
+
private get stars();
|
|
32
|
+
private get locked();
|
|
33
|
+
private emitValue;
|
|
34
|
+
private pick;
|
|
35
|
+
/** APG radio-group keys: arrows move the value, Home/End jump the ends. */
|
|
36
|
+
private onKeydown;
|
|
37
|
+
private setHover;
|
|
38
|
+
protected renderControl(): TemplateResult;
|
|
39
|
+
protected render(): TemplateResult | typeof nothing;
|
|
40
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { nothing as h, html as u } from "lit";
|
|
2
|
+
import { property as d, state as b } from "lit/decorators.js";
|
|
3
|
+
import { BahtFieldBase as c } from "../field-base.js";
|
|
4
|
+
import { customElement as f } from "../define.js";
|
|
5
|
+
import { ratingMax as v, t as y } from "@20baht/engine";
|
|
6
|
+
var g = Object.defineProperty, $ = Object.getOwnPropertyDescriptor, n = (t, r, a, e) => {
|
|
7
|
+
for (var i = e > 1 ? void 0 : e ? $(r, a) : r, l = t.length - 1, s; l >= 0; l--)
|
|
8
|
+
(s = t[l]) && (i = (e ? s(r, a, i) : s(i)) || i);
|
|
9
|
+
return e && i && g(r, a, i), i;
|
|
10
|
+
};
|
|
11
|
+
let o = class extends c {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(...arguments), this.value = 0, this.max = 5, this.label = "Rating", this.hover = 0;
|
|
14
|
+
}
|
|
15
|
+
get isField() {
|
|
16
|
+
return this.assignedField !== void 0;
|
|
17
|
+
}
|
|
18
|
+
get starCount() {
|
|
19
|
+
return this.isField ? v(this.field) : Math.max(1, Math.floor(this.max));
|
|
20
|
+
}
|
|
21
|
+
get stars() {
|
|
22
|
+
return typeof this.value == "number" && this.value > 0 ? this.value : 0;
|
|
23
|
+
}
|
|
24
|
+
get locked() {
|
|
25
|
+
return this.readonly || this.disabled;
|
|
26
|
+
}
|
|
27
|
+
emitValue(t) {
|
|
28
|
+
this.isField ? this.emitInput(t > 0 ? t : null) : this.emit("baht-change", { value: t });
|
|
29
|
+
}
|
|
30
|
+
pick(t) {
|
|
31
|
+
this.locked || this.emitValue(t === this.stars ? 0 : t);
|
|
32
|
+
}
|
|
33
|
+
/** APG radio-group keys: arrows move the value, Home/End jump the ends. */
|
|
34
|
+
onKeydown(t, r) {
|
|
35
|
+
var i;
|
|
36
|
+
if (this.locked) return;
|
|
37
|
+
const a = this.starCount;
|
|
38
|
+
let e;
|
|
39
|
+
if (t.key === "ArrowRight" || t.key === "ArrowUp") e = Math.min(r + 1, a);
|
|
40
|
+
else if (t.key === "ArrowLeft" || t.key === "ArrowDown") e = Math.max(r - 1, 1);
|
|
41
|
+
else if (t.key === "Home") e = 1;
|
|
42
|
+
else if (t.key === "End") e = a;
|
|
43
|
+
else return;
|
|
44
|
+
t.preventDefault(), this.emitValue(e), (i = this.querySelectorAll("button")[e - 1]) == null || i.focus();
|
|
45
|
+
}
|
|
46
|
+
setHover(t) {
|
|
47
|
+
this.locked || (this.hover = t);
|
|
48
|
+
}
|
|
49
|
+
renderControl() {
|
|
50
|
+
const t = this.starCount, r = this.stars, a = this.hover || r, e = this.isField;
|
|
51
|
+
return u`<div
|
|
52
|
+
class="baht-rating${this.disabled ? " baht-rating--disabled" : ""}"
|
|
53
|
+
role="radiogroup"
|
|
54
|
+
aria-label=${e ? h : this.label}
|
|
55
|
+
aria-labelledby=${e && this.field.label ? this.labelId : h}
|
|
56
|
+
aria-required=${e && this.required ? "true" : h}
|
|
57
|
+
aria-invalid=${e ? this.invalidAttr : h}
|
|
58
|
+
aria-describedby=${e ? this.describedBy : h}
|
|
59
|
+
@mouseleave=${() => {
|
|
60
|
+
this.setHover(0);
|
|
61
|
+
}}
|
|
62
|
+
>
|
|
63
|
+
${Array.from({ length: t }, (i, l) => {
|
|
64
|
+
const s = l + 1, m = r || 1;
|
|
65
|
+
return u`<button
|
|
66
|
+
type="button"
|
|
67
|
+
class=${s <= a ? "baht-rating--on" : ""}
|
|
68
|
+
role="radio"
|
|
69
|
+
aria-checked=${s === r}
|
|
70
|
+
aria-label=${y("ratingValue", { n: s, max: t })}
|
|
71
|
+
tabindex=${s === m ? "0" : "-1"}
|
|
72
|
+
?disabled=${this.locked}
|
|
73
|
+
@mouseenter=${() => {
|
|
74
|
+
this.setHover(s);
|
|
75
|
+
}}
|
|
76
|
+
@click=${() => {
|
|
77
|
+
this.pick(s);
|
|
78
|
+
}}
|
|
79
|
+
@keydown=${(p) => {
|
|
80
|
+
this.onKeydown(p, s);
|
|
81
|
+
}}
|
|
82
|
+
>★</button>`;
|
|
83
|
+
})}
|
|
84
|
+
</div>`;
|
|
85
|
+
}
|
|
86
|
+
render() {
|
|
87
|
+
return this.isField ? super.render() : this.renderControl();
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
n([
|
|
91
|
+
d({ type: Number })
|
|
92
|
+
], o.prototype, "value", 2);
|
|
93
|
+
n([
|
|
94
|
+
d({ type: Number })
|
|
95
|
+
], o.prototype, "max", 2);
|
|
96
|
+
n([
|
|
97
|
+
d()
|
|
98
|
+
], o.prototype, "label", 2);
|
|
99
|
+
n([
|
|
100
|
+
b()
|
|
101
|
+
], o.prototype, "hover", 2);
|
|
102
|
+
o = n([
|
|
103
|
+
f("baht-rating")
|
|
104
|
+
], o);
|
|
105
|
+
export {
|
|
106
|
+
o as BahtRating
|
|
107
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { TemplateResult } from 'lit';
|
|
2
|
+
import { BahtElement } from '../base.js';
|
|
3
|
+
/**
|
|
4
|
+
* The bar over a record: what it is, and what can be done to it, kept in sight while the form below
|
|
5
|
+
* scrolls. Children are the actions.
|
|
6
|
+
*
|
|
7
|
+
* <baht-record-bar .lines=${['Change - CHG-12', 'Patch the gateway']}>
|
|
8
|
+
* <baht-button variant="primary">Request approval</baht-button>
|
|
9
|
+
* </baht-record-bar>
|
|
10
|
+
*
|
|
11
|
+
* `--baht-record-bar-top` sets where it sticks, under a fixed header for instance.
|
|
12
|
+
*
|
|
13
|
+
* @fires {CustomEvent<{ href: string }>} baht-back - The back link was pressed. Cancelable: `preventDefault()` to route yourself.
|
|
14
|
+
*/
|
|
15
|
+
export declare class BahtRecordBar extends BahtElement {
|
|
16
|
+
/** The lines naming the record, first one strongest. */
|
|
17
|
+
lines: string[];
|
|
18
|
+
backHref: string;
|
|
19
|
+
backLabel: string;
|
|
20
|
+
/** `false` lets it scroll away with the page. */
|
|
21
|
+
sticky: boolean;
|
|
22
|
+
private actionsEl;
|
|
23
|
+
protected adoptChildren(): void;
|
|
24
|
+
protected render(): TemplateResult;
|
|
25
|
+
}
|
|
26
|
+
declare global {
|
|
27
|
+
interface HTMLElementTagNameMap {
|
|
28
|
+
'baht-record-bar': BahtRecordBar;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { nothing as p, html as h } from "lit";
|
|
2
|
+
import { property as c, query as n } from "lit/decorators.js";
|
|
3
|
+
import { BahtElement as f, adoptSlotted as d, routeClick as m } from "../base.js";
|
|
4
|
+
import { isSafeUrl as k } from "@20baht/engine";
|
|
5
|
+
import { customElement as u } from "../define.js";
|
|
6
|
+
var y = Object.defineProperty, v = Object.getOwnPropertyDescriptor, s = (t, r, i, o) => {
|
|
7
|
+
for (var e = o > 1 ? void 0 : o ? v(r, i) : r, b = t.length - 1, l; b >= 0; b--)
|
|
8
|
+
(l = t[b]) && (e = (o ? l(r, i, e) : l(e)) || e);
|
|
9
|
+
return o && e && y(r, i, e), e;
|
|
10
|
+
};
|
|
11
|
+
let a = class extends f {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(...arguments), this.lines = [], this.backHref = "", this.backLabel = "Back", this.sticky = !0;
|
|
14
|
+
}
|
|
15
|
+
adoptChildren() {
|
|
16
|
+
d(this, this.actionsEl, {});
|
|
17
|
+
}
|
|
18
|
+
render() {
|
|
19
|
+
const t = this.backHref && k(this.backHref) ? this.backHref : "";
|
|
20
|
+
return h`<header class="baht-record-bar${this.sticky ? " baht-record-bar--sticky" : ""}">
|
|
21
|
+
${t ? h`<a
|
|
22
|
+
class="baht-record-bar-back"
|
|
23
|
+
href=${t}
|
|
24
|
+
aria-label=${this.backLabel}
|
|
25
|
+
@click=${(r) => {
|
|
26
|
+
m(this, "baht-back", r, { href: t });
|
|
27
|
+
}}
|
|
28
|
+
>‹</a
|
|
29
|
+
>` : p}
|
|
30
|
+
<div class="baht-record-bar-text">
|
|
31
|
+
${this.lines.map((r) => h`<span class="baht-record-bar-line">${r}</span>`)}
|
|
32
|
+
</div>
|
|
33
|
+
<div class="baht-record-bar-actions"></div>
|
|
34
|
+
</header>`;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
s([
|
|
38
|
+
c({ attribute: !1 })
|
|
39
|
+
], a.prototype, "lines", 2);
|
|
40
|
+
s([
|
|
41
|
+
c({ attribute: "back-href" })
|
|
42
|
+
], a.prototype, "backHref", 2);
|
|
43
|
+
s([
|
|
44
|
+
c({ attribute: "back-label" })
|
|
45
|
+
], a.prototype, "backLabel", 2);
|
|
46
|
+
s([
|
|
47
|
+
c({
|
|
48
|
+
type: Boolean,
|
|
49
|
+
converter: { fromAttribute: (t) => t !== "false" }
|
|
50
|
+
})
|
|
51
|
+
], a.prototype, "sticky", 2);
|
|
52
|
+
s([
|
|
53
|
+
n(".baht-record-bar-actions")
|
|
54
|
+
], a.prototype, "actionsEl", 2);
|
|
55
|
+
a = s([
|
|
56
|
+
u("baht-record-bar")
|
|
57
|
+
], a);
|
|
58
|
+
export {
|
|
59
|
+
a as BahtRecordBar
|
|
60
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { PropertyValues, TemplateResult } from 'lit';
|
|
2
|
+
import { BahtElement } from '../base.js';
|
|
3
|
+
import { ColumnMap } from './column-map.js';
|
|
4
|
+
import { FilterField, ReferencePage, ReferenceQuery, ReferenceRow, SavedFilter } from '@20baht/engine';
|
|
5
|
+
/** Answers a `ReferenceQuery` from rows already in memory: search, filter, sort, page. */
|
|
6
|
+
export declare const pageOfRows: (rows: ReferenceRow[], query: ReferenceQuery) => ReferencePage;
|
|
7
|
+
/**
|
|
8
|
+
* A reference's records as a table in a modal: search one column or every column, build a filter,
|
|
9
|
+
* sort by a header, add, remove and reorder columns, page through, and press a row's first cell to
|
|
10
|
+
* pick it. The host answers `lister`, on the server or with `pageOfRows`. `walk` is every column on
|
|
11
|
+
* offer, dot-walked ones included; `columns` is what shows until the person chooses.
|
|
12
|
+
*
|
|
13
|
+
* @fires {CustomEvent<{ key: string; label: string }>} baht-pick - A record was picked. `detail: { key, label }`.
|
|
14
|
+
* @fires {CustomEvent<void>} baht-close - The modal was dismissed.
|
|
15
|
+
* @fires {CustomEvent<ColumnsChangeDetail>} baht-columns-change - The columns were chosen. `detail: ColumnsChangeDetail`.
|
|
16
|
+
* @fires {CustomEvent<{ filters: SavedFilter[] }>} baht-saved-filters-change - A filter was saved or deleted. `detail: { filters }`.
|
|
17
|
+
*/
|
|
18
|
+
export declare class BahtReferenceDialog extends BahtElement {
|
|
19
|
+
open: boolean;
|
|
20
|
+
heading: string;
|
|
21
|
+
columns: FilterField[];
|
|
22
|
+
lister: ((query: ReferenceQuery) => ReferencePage | Promise<ReferencePage>) | null;
|
|
23
|
+
/** The record the field holds now, marked in the table. */
|
|
24
|
+
selected: string;
|
|
25
|
+
/** Every column on offer; without it, only `columns`. */
|
|
26
|
+
walk: ColumnMap | null;
|
|
27
|
+
/** The columns this person chose last time. Keys no longer on offer are dropped. */
|
|
28
|
+
savedColumns: string[] | null;
|
|
29
|
+
/** The filters this person saved; null hides saving. The host keeps them. */
|
|
30
|
+
savedFilters: SavedFilter[] | null;
|
|
31
|
+
private page;
|
|
32
|
+
private pageNo;
|
|
33
|
+
private loading;
|
|
34
|
+
private failed;
|
|
35
|
+
private searchField;
|
|
36
|
+
private searchTerm;
|
|
37
|
+
private columnTerms;
|
|
38
|
+
private showColumnSearch;
|
|
39
|
+
private showFilter;
|
|
40
|
+
private draftFilter;
|
|
41
|
+
private filter;
|
|
42
|
+
private sort;
|
|
43
|
+
private visible;
|
|
44
|
+
private pickerOpen;
|
|
45
|
+
/** The column map built from `columns`, kept until `columns` is replaced. */
|
|
46
|
+
private offeredFrom;
|
|
47
|
+
private shownFrom;
|
|
48
|
+
/** Read per row and handed to the column picker: one object per `columns`, not one per read. */
|
|
49
|
+
private get offered();
|
|
50
|
+
/** What the table shows now. */
|
|
51
|
+
private get shown();
|
|
52
|
+
private seq;
|
|
53
|
+
private timer;
|
|
54
|
+
disconnectedCallback(): void;
|
|
55
|
+
protected willUpdate(changed: PropertyValues<this>): void;
|
|
56
|
+
protected getUpdateComplete(): Promise<boolean>;
|
|
57
|
+
protected updated(changed: PropertyValues<this>): void;
|
|
58
|
+
private get lastPage();
|
|
59
|
+
private load;
|
|
60
|
+
/** A change to what matches starts again from the first page; typing waits for a pause. */
|
|
61
|
+
private reload;
|
|
62
|
+
private goTo;
|
|
63
|
+
private toggleSort;
|
|
64
|
+
private readonly onSearchField;
|
|
65
|
+
private readonly onSearchTerm;
|
|
66
|
+
private readonly onToggleColumns;
|
|
67
|
+
private readonly onToggleFilter;
|
|
68
|
+
private readonly onOpenPicker;
|
|
69
|
+
private readonly onClosePicker;
|
|
70
|
+
private readonly onColumnsChosen;
|
|
71
|
+
private readonly onSavedFilterPick;
|
|
72
|
+
private readonly onSavedFiltersChange;
|
|
73
|
+
private readonly onRunFilter;
|
|
74
|
+
private readonly onClearFilter;
|
|
75
|
+
private readonly onPageInput;
|
|
76
|
+
private renderPager;
|
|
77
|
+
private renderFilter;
|
|
78
|
+
private renderHead;
|
|
79
|
+
private renderCell;
|
|
80
|
+
private renderBody;
|
|
81
|
+
protected render(): TemplateResult;
|
|
82
|
+
}
|
|
83
|
+
declare global {
|
|
84
|
+
interface HTMLElementTagNameMap {
|
|
85
|
+
'baht-reference-dialog': BahtReferenceDialog;
|
|
86
|
+
}
|
|
87
|
+
}
|