@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,45 @@
|
|
|
1
|
+
import { html as n, nothing as i } from "lit";
|
|
2
|
+
import { property as b } from "lit/decorators.js";
|
|
3
|
+
import { BahtElement as c } from "../base.js";
|
|
4
|
+
import { customElement as m } from "../define.js";
|
|
5
|
+
import { isSafeUrl as u } from "@20baht/engine";
|
|
6
|
+
var f = Object.defineProperty, v = Object.getOwnPropertyDescriptor, h = (t, r, s, e) => {
|
|
7
|
+
for (var a = e > 1 ? void 0 : e ? v(r, s) : r, l = t.length - 1, o; l >= 0; l--)
|
|
8
|
+
(o = t[l]) && (a = (e ? o(r, s, a) : o(a)) || a);
|
|
9
|
+
return e && a && f(r, s, a), a;
|
|
10
|
+
};
|
|
11
|
+
let p = class extends c {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(...arguments), this.items = [], this.separator = "›";
|
|
14
|
+
}
|
|
15
|
+
navigate(t, r) {
|
|
16
|
+
this.emit("baht-navigate", { item: t, index: r });
|
|
17
|
+
}
|
|
18
|
+
render() {
|
|
19
|
+
const t = this.items.length - 1;
|
|
20
|
+
return n`<nav class="baht-breadcrumbs" aria-label="Breadcrumb">
|
|
21
|
+
${this.items.map((r, s) => {
|
|
22
|
+
const e = s < t ? n`<span class="baht-breadcrumbs-sep" aria-hidden="true">${this.separator}</span>` : i;
|
|
23
|
+
return s === t ? n`<span class="baht-breadcrumbs-current" aria-current="page">${r.label}</span>${e}` : r.href && u(r.href) ? n`<a class="baht-link" href=${r.href}>${r.label}</a>${e}` : n`<a
|
|
24
|
+
class="baht-link"
|
|
25
|
+
href="#"
|
|
26
|
+
@click=${(a) => {
|
|
27
|
+
a.preventDefault(), this.navigate(r, s);
|
|
28
|
+
}}
|
|
29
|
+
>${r.label}</a>${e}`;
|
|
30
|
+
})}
|
|
31
|
+
</nav>`;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
h([
|
|
35
|
+
b({ attribute: !1 })
|
|
36
|
+
], p.prototype, "items", 2);
|
|
37
|
+
h([
|
|
38
|
+
b()
|
|
39
|
+
], p.prototype, "separator", 2);
|
|
40
|
+
p = h([
|
|
41
|
+
m("baht-breadcrumbs")
|
|
42
|
+
], p);
|
|
43
|
+
export {
|
|
44
|
+
p as BahtBreadcrumbs
|
|
45
|
+
};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { TemplateResult } from 'lit';
|
|
2
|
+
import { BahtElement } from '../base.js';
|
|
3
|
+
import { IconName } from './icons.js';
|
|
4
|
+
export type ButtonVariant = 'primary' | 'secondary' | 'ghost' | 'danger';
|
|
5
|
+
export type ButtonSize = 'sm' | 'md' | 'lg';
|
|
6
|
+
/**
|
|
7
|
+
* Design-system button (20baht: no scale, no shadow change — color does the work).
|
|
8
|
+
* Standalone primitive: children become the label, listen for the native `click`.
|
|
9
|
+
* (Light DOM has no <slot>, so the initial children are moved into the button.)
|
|
10
|
+
*
|
|
11
|
+
* <baht-button variant="danger" size="sm">Delete</baht-button>
|
|
12
|
+
* <baht-button label="Save workflow"></baht-button>
|
|
13
|
+
* <baht-button icon="copy" variant="ghost" size="sm">Copy</baht-button>
|
|
14
|
+
* <baht-button icon="close" icon-only label="Close"></baht-button> <!-- label = a11y name -->
|
|
15
|
+
* <baht-button aria-label="Previous month">‹</baht-button> <!-- glyph child, host aria-label wins -->
|
|
16
|
+
* <baht-button variant="secondary" shortcut="alt+q">Close</baht-button> <!-- ⌥Q / Alt+Q -->
|
|
17
|
+
*
|
|
18
|
+
* `shortcut` binds a document-wide key combo that clicks the button (NOTES 2026-10-31):
|
|
19
|
+
* hover/focus shows a tooltip with the label and the keys (`⌥Q` on Mac, `Alt+Q`
|
|
20
|
+
* elsewhere) and the inner button gets `aria-keyshortcuts`. Disabled buttons, buttons
|
|
21
|
+
* outside the topmost open `<baht-modal>`, and modifier-less combos while typing in a
|
|
22
|
+
* field never fire.
|
|
23
|
+
*
|
|
24
|
+
* `loading` shows a spinner over the label while a request is in flight: the button keeps
|
|
25
|
+
* its width and its focus, swallows clicks (no submit, no shortcut) and tells assistive tech
|
|
26
|
+
* through `aria-busy`, `aria-disabled` and a status message (`loading-label`).
|
|
27
|
+
*
|
|
28
|
+
* <baht-button type="submit" loading>Save</baht-button>
|
|
29
|
+
*/
|
|
30
|
+
export declare class BahtButton extends BahtElement {
|
|
31
|
+
variant: ButtonVariant;
|
|
32
|
+
size: ButtonSize;
|
|
33
|
+
disabled: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* A request is in flight: a spinner covers the label (the width holds), clicks and the
|
|
36
|
+
* shortcut do nothing, and the button stays focusable with `aria-busy` / `aria-disabled`.
|
|
37
|
+
*/
|
|
38
|
+
loading: boolean;
|
|
39
|
+
/** Status message announced while `loading`. */
|
|
40
|
+
loadingLabel: string;
|
|
41
|
+
/** Forwarded to the native button — 'button' (default) or 'submit'. */
|
|
42
|
+
type: 'button' | 'submit';
|
|
43
|
+
/** Alternative to children for setting the label programmatically. */
|
|
44
|
+
label: string;
|
|
45
|
+
/** Optional leading icon from the curated set (copy/check/download/…). */
|
|
46
|
+
icon: IconName | '';
|
|
47
|
+
/** Square icon-only button. Requires `label` for the accessible name. */
|
|
48
|
+
iconOnly: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* A host `aria-label` never reaches assistive tech on its own — light DOM has no
|
|
51
|
+
* implicit ARIA relationship between a custom element and its rendered children, so an
|
|
52
|
+
* `aria-label` written on `<baht-button>` stays on the host and the inner native
|
|
53
|
+
* `<button>` keeps whatever text (or none) is inside it. Mirroring the attribute into
|
|
54
|
+
* this property forwards it to the inner button's `aria-label`, taking priority over
|
|
55
|
+
* `label`/icon-only fallback — this is how a glyph-only child (e.g. `‹`) gets a real
|
|
56
|
+
* accessible name without `icon-only`. Mapped to the plain `aria-label` attribute so
|
|
57
|
+
* hosts write it the way they naturally would; kept off the `ariaLabel` IDL accessor to
|
|
58
|
+
* avoid shadowing the platform's own ARIAMixin.
|
|
59
|
+
*/
|
|
60
|
+
hostAriaLabel: string;
|
|
61
|
+
/**
|
|
62
|
+
* Keyboard shortcut that clicks this button from anywhere on the page, e.g. `alt+q`,
|
|
63
|
+
* `shift+alt+s`, `mod+enter` (`mod` = ⌘ on Mac, Ctrl elsewhere). Also shown in a
|
|
64
|
+
* hover/focus tooltip and announced through `aria-keyshortcuts`.
|
|
65
|
+
*/
|
|
66
|
+
shortcut: string;
|
|
67
|
+
/** Where the shortcut tooltip sits. */
|
|
68
|
+
tooltipPosition: 'top' | 'bottom';
|
|
69
|
+
private buttonEl;
|
|
70
|
+
private labelEl;
|
|
71
|
+
private mac;
|
|
72
|
+
private childText;
|
|
73
|
+
private tipDismissed;
|
|
74
|
+
private unbind;
|
|
75
|
+
constructor();
|
|
76
|
+
connectedCallback(): void;
|
|
77
|
+
disconnectedCallback(): void;
|
|
78
|
+
private rebind;
|
|
79
|
+
protected adoptChildren(): void;
|
|
80
|
+
protected firstUpdated(): void;
|
|
81
|
+
protected updated(changed: Map<PropertyKey, unknown>): void;
|
|
82
|
+
private renderTip;
|
|
83
|
+
private readonly dismissTip;
|
|
84
|
+
private readonly rearmTip;
|
|
85
|
+
private readonly blockWhileLoading;
|
|
86
|
+
private renderLabel;
|
|
87
|
+
private renderLoading;
|
|
88
|
+
protected render(): TemplateResult;
|
|
89
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { nothing as a, html as b } from "lit";
|
|
2
|
+
import { property as e, query as d, state as u } from "lit/decorators.js";
|
|
3
|
+
import { BahtElement as m, adoptLightChildren as y } from "../base.js";
|
|
4
|
+
import { isIconName as f, renderIcon as $ } from "./icons.js";
|
|
5
|
+
import { customElement as g } from "../define.js";
|
|
6
|
+
import { ariaKeyshortcuts as L } from "@20baht/engine";
|
|
7
|
+
import { bindShortcut as v, isMacPlatform as C } from "../shortcuts.js";
|
|
8
|
+
import { renderKbd as T } from "./kbd.js";
|
|
9
|
+
import { floatTip as O } from "../floating.js";
|
|
10
|
+
var E = Object.defineProperty, P = Object.getOwnPropertyDescriptor, s = (t, n, l, r) => {
|
|
11
|
+
for (var o = r > 1 ? void 0 : r ? P(n, l) : n, h = t.length - 1, p; h >= 0; h--)
|
|
12
|
+
(p = t[h]) && (o = (r ? p(n, l, o) : p(o)) || o);
|
|
13
|
+
return r && o && E(n, l, o), o;
|
|
14
|
+
};
|
|
15
|
+
let i = class extends m {
|
|
16
|
+
constructor() {
|
|
17
|
+
super(), this.variant = "primary", this.size = "md", this.disabled = !1, this.loading = !1, this.loadingLabel = "Loading", this.type = "button", this.label = "", this.icon = "", this.iconOnly = !1, this.hostAriaLabel = "", this.shortcut = "", this.tooltipPosition = "bottom", this.mac = !1, this.childText = "", this.tipDismissed = !1, this.unbind = null, this.dismissTip = (t) => {
|
|
18
|
+
t.key === "Escape" && this.shortcut && (this.tipDismissed = !0);
|
|
19
|
+
}, this.rearmTip = () => {
|
|
20
|
+
this.tipDismissed = !1;
|
|
21
|
+
}, this.blockWhileLoading = (t) => {
|
|
22
|
+
this.loading && (t.preventDefault(), t.stopImmediatePropagation());
|
|
23
|
+
}, O(this, ".baht-button-tip");
|
|
24
|
+
}
|
|
25
|
+
connectedCallback() {
|
|
26
|
+
super.connectedCallback(), this.hasUpdated && this.rebind();
|
|
27
|
+
}
|
|
28
|
+
disconnectedCallback() {
|
|
29
|
+
var t;
|
|
30
|
+
(t = this.unbind) == null || t.call(this), this.unbind = null, super.disconnectedCallback();
|
|
31
|
+
}
|
|
32
|
+
rebind() {
|
|
33
|
+
var t;
|
|
34
|
+
(t = this.unbind) == null || t.call(this), this.unbind = this.shortcut ? v(
|
|
35
|
+
this,
|
|
36
|
+
this.shortcut,
|
|
37
|
+
() => {
|
|
38
|
+
this.buttonEl.click();
|
|
39
|
+
},
|
|
40
|
+
() => !this.disabled && !this.loading
|
|
41
|
+
) : null;
|
|
42
|
+
}
|
|
43
|
+
// Children go in their own span with no template part inside or after it, so a part that
|
|
44
|
+
// re-renders (the spinner when `loading` turns on) never clears them (konmek R2-14).
|
|
45
|
+
// Icon-only buttons render no span: their children are not swept, so the icon stays.
|
|
46
|
+
adoptChildren() {
|
|
47
|
+
this.labelEl && y(this, this.labelEl);
|
|
48
|
+
}
|
|
49
|
+
firstUpdated() {
|
|
50
|
+
var t;
|
|
51
|
+
this.mac = C(), this.childText = ((t = this.labelEl) == null ? void 0 : t.textContent.trim()) ?? "", this.shortcut && this.requestUpdate();
|
|
52
|
+
}
|
|
53
|
+
updated(t) {
|
|
54
|
+
t.has("shortcut") && this.rebind();
|
|
55
|
+
}
|
|
56
|
+
renderTip() {
|
|
57
|
+
if (!this.shortcut) return a;
|
|
58
|
+
const t = this.label || this.hostAriaLabel || this.childText;
|
|
59
|
+
return b`<span
|
|
60
|
+
class="baht-tooltip baht-tooltip--${this.tooltipPosition} baht-button-tip"
|
|
61
|
+
aria-hidden="true"
|
|
62
|
+
>${t ? b`<span class="baht-button-tip-label">${t}</span>` : a}${T(
|
|
63
|
+
this.shortcut,
|
|
64
|
+
this.mac
|
|
65
|
+
)}</span
|
|
66
|
+
>`;
|
|
67
|
+
}
|
|
68
|
+
// `label` text, then the span the children are adopted into (nothing for icon-only).
|
|
69
|
+
renderLabel() {
|
|
70
|
+
return this.iconOnly ? a : b`${this.label}<span class="baht-button-label"></span>`;
|
|
71
|
+
}
|
|
72
|
+
renderLoading() {
|
|
73
|
+
return this.loading ? b`<span class="baht-button-spinner" aria-hidden="true"></span><span
|
|
74
|
+
class="baht-button-status baht-visually-hidden"
|
|
75
|
+
role="status"
|
|
76
|
+
>${this.loadingLabel}</span
|
|
77
|
+
>` : a;
|
|
78
|
+
}
|
|
79
|
+
render() {
|
|
80
|
+
const t = this.variant === "primary" ? "" : ` baht-button--${this.variant}`, n = this.size === "md" ? "" : ` baht-button--${this.size}`, l = this.iconOnly ? " baht-button--icon" : "", r = this.loading ? " baht-button--loading" : "", o = this.icon && f(this.icon) ? $(this.icon) : a, h = this.hostAriaLabel || (this.iconOnly && this.label ? this.label : ""), p = this.shortcut ? L(this.shortcut, { mac: this.mac }) : "", c = this.shortcut ? ` baht-button--has-tip${this.tipDismissed ? " baht-button--tip-dismissed" : ""}` : "";
|
|
81
|
+
return b`<button
|
|
82
|
+
class="baht-button${t}${n}${l}${r}${c}"
|
|
83
|
+
type=${this.type}
|
|
84
|
+
aria-label=${h || a}
|
|
85
|
+
aria-keyshortcuts=${p || a}
|
|
86
|
+
aria-busy=${this.loading ? "true" : a}
|
|
87
|
+
aria-disabled=${this.loading ? "true" : a}
|
|
88
|
+
?disabled=${this.disabled}
|
|
89
|
+
@click=${this.blockWhileLoading}
|
|
90
|
+
@keydown=${this.dismissTip}
|
|
91
|
+
@mouseleave=${this.rearmTip}
|
|
92
|
+
@blur=${this.rearmTip}
|
|
93
|
+
>${o}${this.renderLabel()}${this.renderTip()}${this.renderLoading()}</button>`;
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
s([
|
|
97
|
+
e()
|
|
98
|
+
], i.prototype, "variant", 2);
|
|
99
|
+
s([
|
|
100
|
+
e()
|
|
101
|
+
], i.prototype, "size", 2);
|
|
102
|
+
s([
|
|
103
|
+
e({ type: Boolean })
|
|
104
|
+
], i.prototype, "disabled", 2);
|
|
105
|
+
s([
|
|
106
|
+
e({ type: Boolean, reflect: !0 })
|
|
107
|
+
], i.prototype, "loading", 2);
|
|
108
|
+
s([
|
|
109
|
+
e({ attribute: "loading-label" })
|
|
110
|
+
], i.prototype, "loadingLabel", 2);
|
|
111
|
+
s([
|
|
112
|
+
e()
|
|
113
|
+
], i.prototype, "type", 2);
|
|
114
|
+
s([
|
|
115
|
+
e()
|
|
116
|
+
], i.prototype, "label", 2);
|
|
117
|
+
s([
|
|
118
|
+
e()
|
|
119
|
+
], i.prototype, "icon", 2);
|
|
120
|
+
s([
|
|
121
|
+
e({ type: Boolean, attribute: "icon-only" })
|
|
122
|
+
], i.prototype, "iconOnly", 2);
|
|
123
|
+
s([
|
|
124
|
+
e({ attribute: "aria-label" })
|
|
125
|
+
], i.prototype, "hostAriaLabel", 2);
|
|
126
|
+
s([
|
|
127
|
+
e({ reflect: !0 })
|
|
128
|
+
], i.prototype, "shortcut", 2);
|
|
129
|
+
s([
|
|
130
|
+
e({ attribute: "tooltip-position" })
|
|
131
|
+
], i.prototype, "tooltipPosition", 2);
|
|
132
|
+
s([
|
|
133
|
+
d("button")
|
|
134
|
+
], i.prototype, "buttonEl", 2);
|
|
135
|
+
s([
|
|
136
|
+
d(".baht-button-label")
|
|
137
|
+
], i.prototype, "labelEl", 2);
|
|
138
|
+
s([
|
|
139
|
+
u()
|
|
140
|
+
], i.prototype, "tipDismissed", 2);
|
|
141
|
+
i = s([
|
|
142
|
+
g("baht-button")
|
|
143
|
+
], i);
|
|
144
|
+
export {
|
|
145
|
+
i as BahtButton
|
|
146
|
+
};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { PropertyValues, TemplateResult } from 'lit';
|
|
2
|
+
import { BahtElement } from '../base.js';
|
|
3
|
+
export type CalendarView = 'month' | 'week' | 'day';
|
|
4
|
+
/** The colour family of an event; the host gives each of its sources one. */
|
|
5
|
+
export type CalendarTone = 'primary' | 'carbon' | 'neutral' | 'warning' | 'danger' | 'success';
|
|
6
|
+
export interface CalendarEvent {
|
|
7
|
+
/** Unique among the events: what `baht-event-open` names. */
|
|
8
|
+
id: string;
|
|
9
|
+
title: string;
|
|
10
|
+
/** An ISO instant, or `YYYY-MM-DD` for an all-day event. */
|
|
11
|
+
start: string;
|
|
12
|
+
/** When it ends: an instant, or the last day (included) of an all-day event. Unset: a point. */
|
|
13
|
+
end?: string;
|
|
14
|
+
allDay?: boolean;
|
|
15
|
+
tone?: CalendarTone;
|
|
16
|
+
/** A second, quieter line: who it is for, which application. */
|
|
17
|
+
meta?: string;
|
|
18
|
+
/** Drawn as an outline: a deadline or a marker rather than a block of work. */
|
|
19
|
+
outline?: boolean;
|
|
20
|
+
/** Finished: faded and struck through. */
|
|
21
|
+
done?: boolean;
|
|
22
|
+
}
|
|
23
|
+
/** A day that is not an ordinary working day: a holiday (`off`) or a change freeze (`freeze`). */
|
|
24
|
+
export interface CalendarMark {
|
|
25
|
+
/** `YYYY-MM-DD`. */
|
|
26
|
+
date: string;
|
|
27
|
+
label: string;
|
|
28
|
+
kind?: 'off' | 'freeze';
|
|
29
|
+
}
|
|
30
|
+
/** Where the calendar is now, with the days it shows (both included). */
|
|
31
|
+
export interface CalendarNavigateDetail {
|
|
32
|
+
view: CalendarView;
|
|
33
|
+
date: string;
|
|
34
|
+
from: string;
|
|
35
|
+
to: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The first and last day (`YYYY-MM-DD`, both included) a view shows around `date`: what a host
|
|
39
|
+
* fetches events for. `baht-navigate` carries the same pair.
|
|
40
|
+
*/
|
|
41
|
+
export declare function calendarRange(view: CalendarView, date: string, weekStart?: number): {
|
|
42
|
+
from: string;
|
|
43
|
+
to: string;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* A read-only calendar: month, week and day views of `events`, with holidays and freezes
|
|
47
|
+
* (`marks`) shaded. The host fetches what to show for the days `calendarRange(view, date)`
|
|
48
|
+
* names, and again on every `baht-navigate`; a click on an event fires `baht-event-open`.
|
|
49
|
+
* The calendar never edits anything.
|
|
50
|
+
*
|
|
51
|
+
* el.events = [{ id: 't1', title: 'Approve CHG-6', start: '2026-11-20T03:00:00Z',
|
|
52
|
+
* end: '2026-11-20T04:00:00Z', tone: 'primary', meta: 'Core banking' }];
|
|
53
|
+
* el.marks = [{ date: '2026-12-10', label: 'Constitution Day', kind: 'off' }];
|
|
54
|
+
* el.addEventListener('baht-navigate', (e) => load(e.detail.from, e.detail.to));
|
|
55
|
+
* @fires {CustomEvent<{ id: string; event: CalendarEvent }>} baht-event-open - An event was clicked.
|
|
56
|
+
* @fires {CustomEvent<CalendarNavigateDetail>} baht-navigate - The view or the days shown changed.
|
|
57
|
+
*/
|
|
58
|
+
export declare class BahtCalendar extends BahtElement {
|
|
59
|
+
/** `month`, `week` or `day`. */
|
|
60
|
+
view: CalendarView;
|
|
61
|
+
/** A day the view shows, `YYYY-MM-DD`; empty for today. */
|
|
62
|
+
date: string;
|
|
63
|
+
/** What to draw (property). */
|
|
64
|
+
events: CalendarEvent[];
|
|
65
|
+
/** Holidays and freezes to shade (property). */
|
|
66
|
+
marks: CalendarMark[];
|
|
67
|
+
/** Accessible name of the calendar. */
|
|
68
|
+
label: string;
|
|
69
|
+
/** Today, `YYYY-MM-DD`; empty for the real today (set it for server rendering and tests). */
|
|
70
|
+
today: string;
|
|
71
|
+
/** First day of the week: 1 Monday (default), 0 Sunday. */
|
|
72
|
+
weekStart: number;
|
|
73
|
+
/** Locale for day and month names. */
|
|
74
|
+
locale: string;
|
|
75
|
+
/** Hour the time grid opens scrolled to (7.5 = 07:30). */
|
|
76
|
+
firstHour: number;
|
|
77
|
+
private scrolledFor;
|
|
78
|
+
private anchor;
|
|
79
|
+
private todayDate;
|
|
80
|
+
/** Moves to a view and day, as a person did; the host hears of it and fetches. */
|
|
81
|
+
private go;
|
|
82
|
+
private step;
|
|
83
|
+
private open;
|
|
84
|
+
private heading;
|
|
85
|
+
private time;
|
|
86
|
+
private eventLabel;
|
|
87
|
+
private eventClass;
|
|
88
|
+
protected updated(changed: PropertyValues): void;
|
|
89
|
+
protected willUpdate(changed: PropertyValues): void;
|
|
90
|
+
protected render(): TemplateResult;
|
|
91
|
+
private dayClasses;
|
|
92
|
+
private renderMark;
|
|
93
|
+
private renderMonth;
|
|
94
|
+
private renderWeek;
|
|
95
|
+
private renderBlock;
|
|
96
|
+
}
|