@prismora/elements 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 +21 -2
- package/components.json +15600 -0
- package/custom-elements.json +56320 -0
- package/dist/base.d.ts +42 -0
- package/dist/base.js +62 -0
- package/dist/catalog.d.ts +33 -0
- package/dist/catalog.js +803 -0
- package/dist/components/accordion.d.ts +31 -0
- package/dist/components/accordion.js +63 -0
- package/dist/components/alert.d.ts +27 -0
- package/dist/components/alert.js +40 -0
- package/dist/components/avatar-group.d.ts +23 -0
- package/dist/components/avatar-group.js +43 -0
- package/dist/components/avatar.d.ts +24 -0
- package/dist/components/avatar.js +43 -0
- package/dist/components/back-to-top.d.ts +32 -0
- package/dist/components/back-to-top.js +50 -0
- package/dist/components/badge.d.ts +17 -0
- package/dist/components/badge.js +20 -0
- package/dist/components/banner.d.ts +34 -0
- package/dist/components/banner.js +54 -0
- package/dist/components/breadcrumb.d.ts +42 -0
- package/dist/components/breadcrumb.js +63 -0
- package/dist/components/button-group.d.ts +14 -0
- package/dist/components/button-group.js +28 -0
- package/dist/components/button.d.ts +59 -0
- package/dist/components/button.js +162 -0
- package/dist/components/calendar.d.ts +48 -0
- package/dist/components/calendar.js +296 -0
- package/dist/components/card.d.ts +23 -0
- package/dist/components/card.js +44 -0
- package/dist/components/carousel.d.ts +41 -0
- package/dist/components/carousel.js +156 -0
- package/dist/components/cascader.d.ts +70 -0
- package/dist/components/cascader.js +220 -0
- package/dist/components/chart.d.ts +59 -0
- package/dist/components/chart.js +267 -0
- package/dist/components/chat.d.ts +98 -0
- package/dist/components/chat.js +134 -0
- package/dist/components/checkbox-group.d.ts +48 -0
- package/dist/components/checkbox-group.js +111 -0
- package/dist/components/checkbox.d.ts +23 -0
- package/dist/components/checkbox.js +70 -0
- package/dist/components/code-block.d.ts +46 -0
- package/dist/components/code-block.js +86 -0
- package/dist/components/color-picker.d.ts +46 -0
- package/dist/components/color-picker.js +292 -0
- package/dist/components/combobox.d.ts +89 -0
- package/dist/components/combobox.js +384 -0
- package/dist/components/command.d.ts +96 -0
- package/dist/components/command.js +289 -0
- package/dist/components/context-menu.d.ts +23 -0
- package/dist/components/context-menu.js +110 -0
- package/dist/components/copy-button.d.ts +33 -0
- package/dist/components/copy-button.js +62 -0
- package/dist/components/countdown.d.ts +36 -0
- package/dist/components/countdown.js +56 -0
- package/dist/components/data-table.d.ts +180 -0
- package/dist/components/data-table.js +1060 -0
- package/dist/components/date-picker.d.ts +47 -0
- package/dist/components/date-picker.js +267 -0
- package/dist/components/description-list.d.ts +38 -0
- package/dist/components/description-list.js +41 -0
- package/dist/components/dialog.d.ts +47 -0
- package/dist/components/dialog.js +189 -0
- package/dist/components/divider.d.ts +16 -0
- package/dist/components/divider.js +23 -0
- package/dist/components/drawer.d.ts +19 -0
- package/dist/components/drawer.js +27 -0
- package/dist/components/editor.d.ts +50 -0
- package/dist/components/editor.js +474 -0
- package/dist/components/empty-state.d.ts +24 -0
- package/dist/components/empty-state.js +27 -0
- package/dist/components/file-upload.d.ts +56 -0
- package/dist/components/file-upload.js +176 -0
- package/dist/components/form-control.d.ts +69 -0
- package/dist/components/form-control.js +134 -0
- package/dist/components/form.d.ts +38 -0
- package/dist/components/form.js +161 -0
- package/dist/components/format-number.d.ts +37 -0
- package/dist/components/format-number.js +86 -0
- package/dist/components/icon.d.ts +34 -0
- package/dist/components/icon.js +47 -0
- package/dist/components/image.d.ts +44 -0
- package/dist/components/image.js +53 -0
- package/dist/components/indicator.d.ts +41 -0
- package/dist/components/indicator.js +65 -0
- package/dist/components/inline-edit.d.ts +45 -0
- package/dist/components/inline-edit.js +129 -0
- package/dist/components/input.d.ts +55 -0
- package/dist/components/input.js +186 -0
- package/dist/components/kbd.d.ts +15 -0
- package/dist/components/kbd.js +18 -0
- package/dist/components/list.d.ts +68 -0
- package/dist/components/list.js +180 -0
- package/dist/components/menu.d.ts +22 -0
- package/dist/components/menu.js +182 -0
- package/dist/components/menubar.d.ts +20 -0
- package/dist/components/menubar.js +120 -0
- package/dist/components/meter.d.ts +38 -0
- package/dist/components/meter.js +48 -0
- package/dist/components/nav.d.ts +91 -0
- package/dist/components/nav.js +228 -0
- package/dist/components/number-input.d.ts +26 -0
- package/dist/components/number-input.js +70 -0
- package/dist/components/pagination.d.ts +44 -0
- package/dist/components/pagination.js +94 -0
- package/dist/components/pin-input.d.ts +25 -0
- package/dist/components/pin-input.js +128 -0
- package/dist/components/popover.d.ts +23 -0
- package/dist/components/popover.js +140 -0
- package/dist/components/progress.d.ts +26 -0
- package/dist/components/progress.js +66 -0
- package/dist/components/pull-refresh.d.ts +41 -0
- package/dist/components/pull-refresh.js +101 -0
- package/dist/components/qr-code.d.ts +33 -0
- package/dist/components/qr-code.js +54 -0
- package/dist/components/radio-group.d.ts +37 -0
- package/dist/components/radio-group.js +82 -0
- package/dist/components/range-slider.d.ts +46 -0
- package/dist/components/range-slider.js +95 -0
- package/dist/components/rating.d.ts +38 -0
- package/dist/components/rating.js +80 -0
- package/dist/components/relative-time.d.ts +31 -0
- package/dist/components/relative-time.js +51 -0
- package/dist/components/scheduler.d.ts +84 -0
- package/dist/components/scheduler.js +187 -0
- package/dist/components/segmented.d.ts +58 -0
- package/dist/components/segmented.js +129 -0
- package/dist/components/select.d.ts +62 -0
- package/dist/components/select.js +140 -0
- package/dist/components/share-button.d.ts +37 -0
- package/dist/components/share-button.js +60 -0
- package/dist/components/signature.d.ts +54 -0
- package/dist/components/signature.js +152 -0
- package/dist/components/skeleton.d.ts +21 -0
- package/dist/components/skeleton.js +26 -0
- package/dist/components/slider.d.ts +31 -0
- package/dist/components/slider.js +80 -0
- package/dist/components/sortable.d.ts +22 -0
- package/dist/components/sortable.js +196 -0
- package/dist/components/sparkline.d.ts +28 -0
- package/dist/components/sparkline.js +46 -0
- package/dist/components/spinner.d.ts +16 -0
- package/dist/components/spinner.js +22 -0
- package/dist/components/splitter.d.ts +28 -0
- package/dist/components/splitter.js +89 -0
- package/dist/components/stat.d.ts +28 -0
- package/dist/components/stat.js +33 -0
- package/dist/components/steps.d.ts +53 -0
- package/dist/components/steps.js +91 -0
- package/dist/components/switch.d.ts +12 -0
- package/dist/components/switch.js +18 -0
- package/dist/components/table.d.ts +58 -0
- package/dist/components/table.js +96 -0
- package/dist/components/tabs.d.ts +62 -0
- package/dist/components/tabs.js +310 -0
- package/dist/components/tag.d.ts +32 -0
- package/dist/components/tag.js +58 -0
- package/dist/components/textarea.d.ts +25 -0
- package/dist/components/textarea.js +56 -0
- package/dist/components/theme-switch.d.ts +51 -0
- package/dist/components/theme-switch.js +85 -0
- package/dist/components/time-picker.d.ts +39 -0
- package/dist/components/time-picker.js +257 -0
- package/dist/components/timeline.d.ts +38 -0
- package/dist/components/timeline.js +56 -0
- package/dist/components/toaster.d.ts +25 -0
- package/dist/components/toaster.js +44 -0
- package/dist/components/toggle-group.d.ts +70 -0
- package/dist/components/toggle-group.js +172 -0
- package/dist/components/toolbar.d.ts +23 -0
- package/dist/components/toolbar.js +81 -0
- package/dist/components/tooltip.d.ts +18 -0
- package/dist/components/tooltip.js +92 -0
- package/dist/components/tour.d.ts +41 -0
- package/dist/components/tour.js +197 -0
- package/dist/components/transfer.d.ts +57 -0
- package/dist/components/transfer.js +161 -0
- package/dist/components/tree-select.d.ts +66 -0
- package/dist/components/tree-select.js +282 -0
- package/dist/components/tree.d.ts +129 -0
- package/dist/components/tree.js +427 -0
- package/dist/components/virtual-list.d.ts +41 -0
- package/dist/components/virtual-list.js +77 -0
- package/dist/confirm.d.ts +21 -0
- package/dist/confirm.js +69 -0
- package/dist/count.d.ts +5 -0
- package/dist/count.js +12 -0
- package/dist/data-table/icons.d.ts +8 -0
- package/dist/data-table/icons.js +10 -0
- package/dist/data-table/logic.d.ts +33 -0
- package/dist/data-table/logic.js +141 -0
- package/dist/data-table/strings.d.ts +37 -0
- package/dist/data-table/strings.js +36 -0
- package/dist/data-table/types.d.ts +76 -0
- package/dist/data-table/types.js +1 -0
- package/dist/define.d.ts +2 -0
- package/dist/define.js +2 -0
- package/dist/field-validity.d.ts +42 -0
- package/dist/field-validity.js +58 -0
- package/dist/floating.d.ts +13 -0
- package/dist/floating.js +65 -0
- package/dist/highlight.d.ts +11 -0
- package/dist/highlight.js +103 -0
- package/dist/id.d.ts +2 -0
- package/dist/id.js +3 -0
- package/dist/index.d.ts +102 -0
- package/dist/index.js +102 -0
- package/dist/manifest.d.ts +51 -0
- package/dist/manifest.js +11 -0
- package/dist/named-icon.d.ts +8 -0
- package/dist/named-icon.js +8 -0
- package/dist/patterns/account.d.ts +6 -0
- package/dist/patterns/account.js +137 -0
- package/dist/patterns/app.d.ts +7 -0
- package/dist/patterns/app.js +351 -0
- package/dist/patterns/commerce.d.ts +4 -0
- package/dist/patterns/commerce.js +200 -0
- package/dist/patterns/flows.d.ts +3 -0
- package/dist/patterns/flows.js +100 -0
- package/dist/patterns/index.d.ts +9 -0
- package/dist/patterns/index.js +29 -0
- package/dist/patterns/marketing.d.ts +4 -0
- package/dist/patterns/marketing.js +173 -0
- package/dist/patterns/more.d.ts +15 -0
- package/dist/patterns/more.js +581 -0
- package/dist/patterns/shell.d.ts +9 -0
- package/dist/patterns/shell.js +48 -0
- package/dist/patterns/types.d.ts +19 -0
- package/dist/patterns/types.js +1 -0
- package/dist/position.d.ts +2 -0
- package/dist/position.js +33 -0
- package/dist/prismora.standalone.js +5222 -0
- package/dist/prismora.standalone.js.map +199 -0
- package/dist/qr.d.ts +14 -0
- package/dist/qr.js +258 -0
- package/dist/register.d.ts +8 -0
- package/dist/register.js +21 -0
- package/dist/registry.d.ts +203 -0
- package/dist/registry.js +203 -0
- package/dist/remote.d.ts +58 -0
- package/dist/remote.js +130 -0
- package/dist/sheet.d.ts +34 -0
- package/dist/sheet.js +153 -0
- package/dist/styles/accordion.d.ts +2 -0
- package/dist/styles/accordion.js +3 -0
- package/dist/styles/alert.d.ts +2 -0
- package/dist/styles/alert.js +3 -0
- package/dist/styles/avatar.d.ts +2 -0
- package/dist/styles/avatar.js +3 -0
- package/dist/styles/badge.d.ts +2 -0
- package/dist/styles/badge.js +3 -0
- package/dist/styles/banner.d.ts +2 -0
- package/dist/styles/banner.js +3 -0
- package/dist/styles/breadcrumb.d.ts +2 -0
- package/dist/styles/breadcrumb.js +3 -0
- package/dist/styles/button.d.ts +2 -0
- package/dist/styles/button.js +3 -0
- package/dist/styles/calendar.d.ts +2 -0
- package/dist/styles/calendar.js +3 -0
- package/dist/styles/card.d.ts +2 -0
- package/dist/styles/card.js +3 -0
- package/dist/styles/carousel.d.ts +2 -0
- package/dist/styles/carousel.js +3 -0
- package/dist/styles/chart.d.ts +2 -0
- package/dist/styles/chart.js +3 -0
- package/dist/styles/chat.d.ts +2 -0
- package/dist/styles/chat.js +3 -0
- package/dist/styles/checkbox.d.ts +2 -0
- package/dist/styles/checkbox.js +3 -0
- package/dist/styles/color-picker.d.ts +2 -0
- package/dist/styles/color-picker.js +3 -0
- package/dist/styles/combobox.d.ts +2 -0
- package/dist/styles/combobox.js +3 -0
- package/dist/styles/command.d.ts +2 -0
- package/dist/styles/command.js +3 -0
- package/dist/styles/data-table.d.ts +2 -0
- package/dist/styles/data-table.js +3 -0
- package/dist/styles/description-list.d.ts +2 -0
- package/dist/styles/description-list.js +3 -0
- package/dist/styles/dialog.d.ts +2 -0
- package/dist/styles/dialog.js +3 -0
- package/dist/styles/drawer.d.ts +2 -0
- package/dist/styles/drawer.js +3 -0
- package/dist/styles/editor.d.ts +2 -0
- package/dist/styles/editor.js +3 -0
- package/dist/styles/empty-state.d.ts +2 -0
- package/dist/styles/empty-state.js +3 -0
- package/dist/styles/extras.d.ts +2 -0
- package/dist/styles/extras.js +3 -0
- package/dist/styles/field.d.ts +2 -0
- package/dist/styles/field.js +3 -0
- package/dist/styles/file-upload.d.ts +2 -0
- package/dist/styles/file-upload.js +3 -0
- package/dist/styles/foundation.d.ts +2 -0
- package/dist/styles/foundation.js +3 -0
- package/dist/styles/helpers.d.ts +2 -0
- package/dist/styles/helpers.js +3 -0
- package/dist/styles/icon.d.ts +2 -0
- package/dist/styles/icon.js +3 -0
- package/dist/styles/image.d.ts +2 -0
- package/dist/styles/image.js +3 -0
- package/dist/styles/indicator.d.ts +2 -0
- package/dist/styles/indicator.js +3 -0
- package/dist/styles/input.d.ts +2 -0
- package/dist/styles/input.js +3 -0
- package/dist/styles/kbd.d.ts +2 -0
- package/dist/styles/kbd.js +3 -0
- package/dist/styles/list.d.ts +2 -0
- package/dist/styles/list.js +3 -0
- package/dist/styles/listbox.d.ts +2 -0
- package/dist/styles/listbox.js +3 -0
- package/dist/styles/meter.d.ts +2 -0
- package/dist/styles/meter.js +3 -0
- package/dist/styles/nav.d.ts +2 -0
- package/dist/styles/nav.js +3 -0
- package/dist/styles/number-input.d.ts +2 -0
- package/dist/styles/number-input.js +3 -0
- package/dist/styles/overlay.d.ts +2 -0
- package/dist/styles/overlay.js +3 -0
- package/dist/styles/pagination.d.ts +2 -0
- package/dist/styles/pagination.js +3 -0
- package/dist/styles/pickers.d.ts +2 -0
- package/dist/styles/pickers.js +3 -0
- package/dist/styles/pin-input.d.ts +2 -0
- package/dist/styles/pin-input.js +3 -0
- package/dist/styles/popover.d.ts +2 -0
- package/dist/styles/popover.js +3 -0
- package/dist/styles/progress.d.ts +2 -0
- package/dist/styles/progress.js +3 -0
- package/dist/styles/pull-refresh.d.ts +2 -0
- package/dist/styles/pull-refresh.js +3 -0
- package/dist/styles/range-slider.d.ts +2 -0
- package/dist/styles/range-slider.js +3 -0
- package/dist/styles/rating.d.ts +2 -0
- package/dist/styles/rating.js +3 -0
- package/dist/styles/scheduler.d.ts +2 -0
- package/dist/styles/scheduler.js +3 -0
- package/dist/styles/segmented.d.ts +2 -0
- package/dist/styles/segmented.js +3 -0
- package/dist/styles/select.d.ts +2 -0
- package/dist/styles/select.js +3 -0
- package/dist/styles/separator.d.ts +2 -0
- package/dist/styles/separator.js +3 -0
- package/dist/styles/sheet.d.ts +2 -0
- package/dist/styles/sheet.js +3 -0
- package/dist/styles/skeleton.d.ts +2 -0
- package/dist/styles/skeleton.js +3 -0
- package/dist/styles/slider.d.ts +2 -0
- package/dist/styles/slider.js +3 -0
- package/dist/styles/sortable.d.ts +2 -0
- package/dist/styles/sortable.js +3 -0
- package/dist/styles/spinner.d.ts +2 -0
- package/dist/styles/spinner.js +3 -0
- package/dist/styles/splitter.d.ts +2 -0
- package/dist/styles/splitter.js +3 -0
- package/dist/styles/stat.d.ts +2 -0
- package/dist/styles/stat.js +3 -0
- package/dist/styles/steps.d.ts +2 -0
- package/dist/styles/steps.js +3 -0
- package/dist/styles/surface.d.ts +2 -0
- package/dist/styles/surface.js +3 -0
- package/dist/styles/switch.d.ts +2 -0
- package/dist/styles/switch.js +3 -0
- package/dist/styles/table.d.ts +2 -0
- package/dist/styles/table.js +3 -0
- package/dist/styles/tabs.d.ts +2 -0
- package/dist/styles/tabs.js +3 -0
- package/dist/styles/tag.d.ts +2 -0
- package/dist/styles/tag.js +3 -0
- package/dist/styles/time-picker.d.ts +2 -0
- package/dist/styles/time-picker.js +3 -0
- package/dist/styles/timeline.d.ts +2 -0
- package/dist/styles/timeline.js +3 -0
- package/dist/styles/toast.d.ts +2 -0
- package/dist/styles/toast.js +3 -0
- package/dist/styles/toggle.d.ts +2 -0
- package/dist/styles/toggle.js +3 -0
- package/dist/styles/toolbar.d.ts +2 -0
- package/dist/styles/toolbar.js +3 -0
- package/dist/styles/tooltip.d.ts +2 -0
- package/dist/styles/tooltip.js +3 -0
- package/dist/styles/tree.d.ts +2 -0
- package/dist/styles/tree.js +3 -0
- package/dist/table-core.d.ts +75 -0
- package/dist/table-core.js +205 -0
- package/dist/toast.d.ts +42 -0
- package/dist/toast.js +206 -0
- package/dist/top-layer.d.ts +4 -0
- package/dist/top-layer.js +33 -0
- package/package.json +101 -4
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type PropertyDeclarations } from 'lit';
|
|
2
|
+
import { PmElement } from '../base.js';
|
|
3
|
+
/**
|
|
4
|
+
* Carousel built on native scroll-snap (swipe, trackpad and keyboard scrolling just work).
|
|
5
|
+
* Optional autoplay pauses on hover/focus, offers a pause button (WCAG 2.2.2) and is off with reduced motion.
|
|
6
|
+
* @tag pm-carousel
|
|
7
|
+
* @slot - Slides (any elements).
|
|
8
|
+
* @fires pm-change - Active slide changed. detail: { index }
|
|
9
|
+
* @example <pm-carousel label="Featured" per-view="1"><img src="a.jpg" alt="…"><img src="b.jpg" alt="…"></pm-carousel>
|
|
10
|
+
*/
|
|
11
|
+
export declare class PmCarousel extends PmElement {
|
|
12
|
+
#private;
|
|
13
|
+
static componentName: string;
|
|
14
|
+
static styles: import("lit").CSSResult[];
|
|
15
|
+
static properties: PropertyDeclarations;
|
|
16
|
+
label: string;
|
|
17
|
+
/** Slides visible at once. */
|
|
18
|
+
perView: number;
|
|
19
|
+
/** CSS gap between slides. */
|
|
20
|
+
gap?: string;
|
|
21
|
+
/** Wrap around at the ends. */
|
|
22
|
+
loop: boolean;
|
|
23
|
+
/** Autoplay interval in ms (0 = off). */
|
|
24
|
+
autoplay: number;
|
|
25
|
+
/** Hide the previous/next buttons. */
|
|
26
|
+
hideControls: boolean;
|
|
27
|
+
/** Hide the slide position dots. */
|
|
28
|
+
hideDots: boolean;
|
|
29
|
+
_index: number;
|
|
30
|
+
_count: number;
|
|
31
|
+
_paused: boolean;
|
|
32
|
+
constructor();
|
|
33
|
+
connectedCallback(): void;
|
|
34
|
+
disconnectedCallback(): void;
|
|
35
|
+
render(): import("lit").TemplateResult<1>;
|
|
36
|
+
protected updated(changed: Map<string, unknown>): void;
|
|
37
|
+
/** Scroll to a page (0-based). */
|
|
38
|
+
goTo(index: number): void;
|
|
39
|
+
next(auto?: boolean): void;
|
|
40
|
+
prev(): void;
|
|
41
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { css, html, nothing } from 'lit';
|
|
2
|
+
import { PmElement, defineElement } from '../base.js';
|
|
3
|
+
import carouselCss from '../styles/carousel.js';
|
|
4
|
+
const chevron = (flip = false) => html `<svg viewBox="0 0 24 24" width="1.1em" height="1.1em" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" style=${flip ? 'scale: -1 1' : ''}><path d="M15 6l-6 6 6 6"/></svg>`;
|
|
5
|
+
/**
|
|
6
|
+
* Carousel built on native scroll-snap (swipe, trackpad and keyboard scrolling just work).
|
|
7
|
+
* Optional autoplay pauses on hover/focus, offers a pause button (WCAG 2.2.2) and is off with reduced motion.
|
|
8
|
+
* @tag pm-carousel
|
|
9
|
+
* @slot - Slides (any elements).
|
|
10
|
+
* @fires pm-change - Active slide changed. detail: { index }
|
|
11
|
+
* @example <pm-carousel label="Featured" per-view="1"><img src="a.jpg" alt="…"><img src="b.jpg" alt="…"></pm-carousel>
|
|
12
|
+
*/
|
|
13
|
+
export class PmCarousel extends PmElement {
|
|
14
|
+
static { this.componentName = 'carousel'; }
|
|
15
|
+
static { this.styles = [...PmElement.styles, carouselCss, css `
|
|
16
|
+
:host { display: block; }
|
|
17
|
+
.pm-carousel-track ::slotted(*) { scroll-snap-align: start; min-inline-size: 0; }
|
|
18
|
+
.pm-carousel-track { position: relative; }
|
|
19
|
+
.pm-carousel-track:focus-visible { outline: 2px solid var(--pm-color-ring); outline-offset: 2px; }
|
|
20
|
+
.pause { position: absolute; inset-block-start: var(--pm-space-2); inset-inline-end: var(--pm-space-2); z-index: 1; }
|
|
21
|
+
`]; }
|
|
22
|
+
static { this.properties = {
|
|
23
|
+
label: {}, perView: { type: Number, attribute: 'per-view' }, gap: {}, loop: { type: Boolean }, autoplay: { type: Number },
|
|
24
|
+
hideControls: { type: Boolean, attribute: 'hide-controls' }, hideDots: { type: Boolean, attribute: 'hide-dots' },
|
|
25
|
+
_index: { state: true }, _count: { state: true }, _paused: { state: true },
|
|
26
|
+
}; }
|
|
27
|
+
#timer;
|
|
28
|
+
#hovered = false;
|
|
29
|
+
#io;
|
|
30
|
+
constructor() {
|
|
31
|
+
super();
|
|
32
|
+
this.label = 'Carousel';
|
|
33
|
+
this.perView = 1;
|
|
34
|
+
this.loop = false;
|
|
35
|
+
this.autoplay = 0;
|
|
36
|
+
this.hideControls = false;
|
|
37
|
+
this.hideDots = false;
|
|
38
|
+
this._index = 0;
|
|
39
|
+
this._count = 0;
|
|
40
|
+
this._paused = false;
|
|
41
|
+
}
|
|
42
|
+
get #track() { return this.renderRoot.querySelector('.pm-carousel-track'); }
|
|
43
|
+
#slides() { return [...this.children]; }
|
|
44
|
+
get #pages() { return Math.max(1, this._count - Math.max(1, Math.floor(this.perView)) + 1); }
|
|
45
|
+
connectedCallback() {
|
|
46
|
+
super.connectedCallback();
|
|
47
|
+
this.addEventListener('pointerenter', () => { this.#hovered = true; });
|
|
48
|
+
this.addEventListener('pointerleave', () => { this.#hovered = false; });
|
|
49
|
+
}
|
|
50
|
+
disconnectedCallback() { super.disconnectedCallback(); clearInterval(this.#timer); this.#io?.disconnect(); }
|
|
51
|
+
render() {
|
|
52
|
+
const pages = this.#pages;
|
|
53
|
+
const canPrev = this.loop || this._index > 0;
|
|
54
|
+
const canNext = this.loop || this._index < pages - 1;
|
|
55
|
+
const style = `--pm-carousel-per-view: ${this.perView};${this.gap ? ` --pm-carousel-gap: ${this.gap};` : ''}`;
|
|
56
|
+
return html `<section class="pm-carousel" part="base" aria-roledescription="carousel" aria-label=${this.label} style=${style}
|
|
57
|
+
@focusin=${() => this.requestUpdate()} @keydown=${this.#onKey}>
|
|
58
|
+
${this.autoplay > 0 ? html `<button type="button" class="pm-carousel-nav pause" part="pause" aria-label=${this._paused ? 'Play slides' : 'Pause slides'}
|
|
59
|
+
@click=${() => { this._paused = !this._paused; this.#schedule(); }}>${this._paused ? '▶' : '❚❚'}</button>` : nothing}
|
|
60
|
+
${this.hideControls ? nothing : html `
|
|
61
|
+
<button type="button" class="pm-carousel-nav" data-dir="prev" part="prev" aria-label="Previous slide" ?disabled=${!canPrev} @click=${() => this.prev()}>${chevron()}</button>
|
|
62
|
+
<button type="button" class="pm-carousel-nav" data-dir="next" part="next" aria-label="Next slide" ?disabled=${!canNext} @click=${() => this.next()}>${chevron(true)}</button>`}
|
|
63
|
+
<div class="pm-carousel-track" part="track" tabindex="0" aria-live=${this.autoplay > 0 && !this._paused ? 'off' : 'polite'} @scrollend=${this.#onScroll} @scroll=${this.#onScrollThrottled}>
|
|
64
|
+
<slot @slotchange=${this.#setup}></slot>
|
|
65
|
+
</div>
|
|
66
|
+
${this.hideDots || pages < 2 ? nothing : html `<div class="pm-carousel-dots" part="dots" role="group" aria-label="Choose slide">
|
|
67
|
+
${Array.from({ length: pages }, (_, i) => html `<button type="button" class="pm-carousel-dot" aria-label=${`Slide ${i + 1} of ${pages}`}
|
|
68
|
+
aria-current=${i === this._index ? 'true' : 'false'} @click=${() => this.goTo(i)}></button>`)}
|
|
69
|
+
</div>`}
|
|
70
|
+
</section>`;
|
|
71
|
+
}
|
|
72
|
+
#setup = () => {
|
|
73
|
+
const slides = this.#slides();
|
|
74
|
+
this._count = slides.length;
|
|
75
|
+
slides.forEach((s, i) => {
|
|
76
|
+
s.setAttribute('role', 'group');
|
|
77
|
+
s.setAttribute('aria-roledescription', 'slide');
|
|
78
|
+
if (!s.hasAttribute('aria-label'))
|
|
79
|
+
s.setAttribute('aria-label', `${i + 1} of ${slides.length}`);
|
|
80
|
+
});
|
|
81
|
+
this.#schedule();
|
|
82
|
+
};
|
|
83
|
+
#schedule() {
|
|
84
|
+
clearInterval(this.#timer);
|
|
85
|
+
const reduce = globalThis.matchMedia?.('(prefers-reduced-motion: reduce)').matches;
|
|
86
|
+
if (this.autoplay > 0 && !this._paused && !reduce) {
|
|
87
|
+
this.#timer = setInterval(() => {
|
|
88
|
+
if (this.#hovered || this.matches(':focus-within') || document.hidden)
|
|
89
|
+
return;
|
|
90
|
+
this.next(true);
|
|
91
|
+
}, Math.max(1500, this.autoplay));
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
updated(changed) {
|
|
95
|
+
if (changed.has('autoplay'))
|
|
96
|
+
this.#schedule();
|
|
97
|
+
}
|
|
98
|
+
/** Scroll to a page (0-based). */
|
|
99
|
+
goTo(index) {
|
|
100
|
+
const pages = this.#pages;
|
|
101
|
+
const i = this.loop ? (index + pages) % pages : Math.min(pages - 1, Math.max(0, index));
|
|
102
|
+
const slide = this.#slides()[i];
|
|
103
|
+
const track = this.#track;
|
|
104
|
+
if (!slide || !track)
|
|
105
|
+
return;
|
|
106
|
+
const first = this.#slides()[0];
|
|
107
|
+
// Track is the offset parent: offsets are scroll-independent and share the sign of scrollLeft in RTL.
|
|
108
|
+
const reduce = globalThis.matchMedia?.('(prefers-reduced-motion: reduce)').matches;
|
|
109
|
+
track.scrollTo({ left: slide.offsetLeft - first.offsetLeft, behavior: reduce ? 'instant' : 'smooth' });
|
|
110
|
+
this.#setIndex(i);
|
|
111
|
+
}
|
|
112
|
+
next(auto = false) { this.goTo(this._index + 1 >= this.#pages && !this.loop && auto ? 0 : this._index + 1); }
|
|
113
|
+
prev() { this.goTo(this._index - 1); }
|
|
114
|
+
#setIndex(i) {
|
|
115
|
+
if (i === this._index)
|
|
116
|
+
return;
|
|
117
|
+
this._index = i;
|
|
118
|
+
this.emit('pm-change', { index: i });
|
|
119
|
+
}
|
|
120
|
+
#scrollRaf = 0;
|
|
121
|
+
#onScrollThrottled = () => {
|
|
122
|
+
cancelAnimationFrame(this.#scrollRaf);
|
|
123
|
+
this.#scrollRaf = requestAnimationFrame(() => this.#onScroll());
|
|
124
|
+
};
|
|
125
|
+
#onScroll = () => {
|
|
126
|
+
const track = this.#track;
|
|
127
|
+
if (!track)
|
|
128
|
+
return;
|
|
129
|
+
const slides = this.#slides();
|
|
130
|
+
const left = track.scrollLeft;
|
|
131
|
+
let best = 0;
|
|
132
|
+
let dist = Infinity;
|
|
133
|
+
slides.forEach((s, i) => {
|
|
134
|
+
const d = Math.abs(s.offsetLeft - slides[0].offsetLeft - left);
|
|
135
|
+
if (d < dist) {
|
|
136
|
+
dist = d;
|
|
137
|
+
best = i;
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
this.#setIndex(Math.min(best, this.#pages - 1));
|
|
141
|
+
};
|
|
142
|
+
#onKey = (e) => {
|
|
143
|
+
if (!e.composedPath()[0]?.classList?.contains('pm-carousel-track'))
|
|
144
|
+
return;
|
|
145
|
+
const rtl = getComputedStyle(this).direction === 'rtl';
|
|
146
|
+
if (e.key === 'ArrowRight') {
|
|
147
|
+
e.preventDefault();
|
|
148
|
+
rtl ? this.prev() : this.next();
|
|
149
|
+
}
|
|
150
|
+
else if (e.key === 'ArrowLeft') {
|
|
151
|
+
e.preventDefault();
|
|
152
|
+
rtl ? this.next() : this.prev();
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
defineElement('pm-carousel', PmCarousel);
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { type PropertyDeclarations, type PropertyValues } from 'lit';
|
|
2
|
+
import { PmElement } from '../base.js';
|
|
3
|
+
export interface CascaderOption {
|
|
4
|
+
value: string;
|
|
5
|
+
label: string;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
children?: CascaderOption[];
|
|
8
|
+
}
|
|
9
|
+
/** The chain of options from the top level down to `value`, or an empty list. */
|
|
10
|
+
export declare function optionPath<T extends {
|
|
11
|
+
value: string;
|
|
12
|
+
children?: T[];
|
|
13
|
+
}>(options: T[], value: string | undefined): T[];
|
|
14
|
+
/**
|
|
15
|
+
* Cascader: choose one item from nested lists, one column per level (country, region, city; category, subcategory).
|
|
16
|
+
*
|
|
17
|
+
* Up and Down move within a column, Right opens the next level, Left goes back, Enter chooses. By default only
|
|
18
|
+
* the last level can be chosen; `any-level` lets a parent be the answer. Form-associated: submits the chosen value.
|
|
19
|
+
* @tag pm-cascader
|
|
20
|
+
* @fires pm-change - A value was chosen or cleared. detail: { value, path }
|
|
21
|
+
* @example <pm-cascader label="Location" name="city" options='[{"value":"de","label":"Germany","children":[{"value":"ber","label":"Berlin"}]}]'></pm-cascader>
|
|
22
|
+
*/
|
|
23
|
+
export declare class PmCascader extends PmElement {
|
|
24
|
+
#private;
|
|
25
|
+
static componentName: string;
|
|
26
|
+
static formAssociated: boolean;
|
|
27
|
+
static shadowRootOptions: {
|
|
28
|
+
delegatesFocus: boolean;
|
|
29
|
+
clonable?: boolean;
|
|
30
|
+
customElementRegistry?: CustomElementRegistry;
|
|
31
|
+
mode: ShadowRootMode;
|
|
32
|
+
serializable?: boolean;
|
|
33
|
+
slotAssignment?: SlotAssignmentMode;
|
|
34
|
+
};
|
|
35
|
+
static styles: import("lit").CSSResult[];
|
|
36
|
+
static properties: PropertyDeclarations;
|
|
37
|
+
/** Nested options: `{ value, label, children? }`. Values must be unique across all levels. */
|
|
38
|
+
options: CascaderOption[];
|
|
39
|
+
/** Value of the chosen option. */
|
|
40
|
+
value: string;
|
|
41
|
+
name?: string;
|
|
42
|
+
label: string;
|
|
43
|
+
placeholder: string;
|
|
44
|
+
/** Help text under the field. */
|
|
45
|
+
hint?: string;
|
|
46
|
+
/** Custom error message. Setting it marks the field invalid. */
|
|
47
|
+
error?: string;
|
|
48
|
+
size?: 'sm' | 'md' | 'lg';
|
|
49
|
+
required: boolean;
|
|
50
|
+
disabled: boolean;
|
|
51
|
+
/** Let options that have children be chosen too (Enter or a second click). */
|
|
52
|
+
anyLevel: boolean;
|
|
53
|
+
/** Text between the levels in the field (default " / "). */
|
|
54
|
+
separator: string;
|
|
55
|
+
_open: boolean;
|
|
56
|
+
/** Highlighted option per column: values from the top level down. The last entry is the keyboard cursor. */
|
|
57
|
+
_trail: string[];
|
|
58
|
+
constructor();
|
|
59
|
+
connectedCallback(): void;
|
|
60
|
+
disconnectedCallback(): void;
|
|
61
|
+
formResetCallback(): void;
|
|
62
|
+
formStateRestoreCallback(v: string): void;
|
|
63
|
+
formDisabledCallback(d: boolean): void;
|
|
64
|
+
/** The chosen option and its parents, top level first. */
|
|
65
|
+
get path(): CascaderOption[];
|
|
66
|
+
/** Clear the value. */
|
|
67
|
+
clear(): void;
|
|
68
|
+
protected updated(changed: PropertyValues<this>): void;
|
|
69
|
+
render(): import("lit").TemplateResult<1>;
|
|
70
|
+
}
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import { css, html, nothing } from 'lit';
|
|
2
|
+
import { PmElement, defineElement } from '../base.js';
|
|
3
|
+
import { FieldValidity } from '../field-validity.js';
|
|
4
|
+
import { attachBelow, hidePopup, showPopup } from '../floating.js';
|
|
5
|
+
import fieldCss from '../styles/field.js';
|
|
6
|
+
import inputCss from '../styles/input.js';
|
|
7
|
+
import listboxCss from '../styles/listbox.js';
|
|
8
|
+
import pickersCss from '../styles/pickers.js';
|
|
9
|
+
import sheetCss from '../styles/sheet.js';
|
|
10
|
+
/** The chain of options from the top level down to `value`, or an empty list. */
|
|
11
|
+
export function optionPath(options, value) {
|
|
12
|
+
if (value === undefined || value === '')
|
|
13
|
+
return [];
|
|
14
|
+
for (const o of options) {
|
|
15
|
+
if (o.value === value)
|
|
16
|
+
return [o];
|
|
17
|
+
const rest = optionPath(o.children ?? [], value);
|
|
18
|
+
if (rest.length)
|
|
19
|
+
return [o, ...rest];
|
|
20
|
+
}
|
|
21
|
+
return [];
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Cascader: choose one item from nested lists, one column per level (country, region, city; category, subcategory).
|
|
25
|
+
*
|
|
26
|
+
* Up and Down move within a column, Right opens the next level, Left goes back, Enter chooses. By default only
|
|
27
|
+
* the last level can be chosen; `any-level` lets a parent be the answer. Form-associated: submits the chosen value.
|
|
28
|
+
* @tag pm-cascader
|
|
29
|
+
* @fires pm-change - A value was chosen or cleared. detail: { value, path }
|
|
30
|
+
* @example <pm-cascader label="Location" name="city" options='[{"value":"de","label":"Germany","children":[{"value":"ber","label":"Berlin"}]}]'></pm-cascader>
|
|
31
|
+
*/
|
|
32
|
+
export class PmCascader extends PmElement {
|
|
33
|
+
static { this.componentName = 'cascader'; }
|
|
34
|
+
static { this.formAssociated = true; }
|
|
35
|
+
static { this.shadowRootOptions = { ...PmElement.shadowRootOptions, delegatesFocus: true }; }
|
|
36
|
+
static { this.styles = [...PmElement.styles, fieldCss, inputCss, listboxCss, sheetCss, pickersCss, css `:host { display: block; } :host([hidden]) { display: none; }`]; }
|
|
37
|
+
static { this.properties = {
|
|
38
|
+
options: { type: Array }, value: {}, name: { reflect: true }, label: {}, placeholder: {}, hint: {}, error: {}, size: { reflect: true },
|
|
39
|
+
required: { type: Boolean, reflect: true }, disabled: { type: Boolean, reflect: true }, anyLevel: { type: Boolean, attribute: 'any-level' },
|
|
40
|
+
separator: {}, _open: { state: true }, _trail: { state: true },
|
|
41
|
+
}; }
|
|
42
|
+
#internals = this.attachInternals();
|
|
43
|
+
#field = new FieldValidity(this, this.#internals, {
|
|
44
|
+
hint: () => this.hint, error: () => this.error, missing: () => this.required && !this.value && !this.disabled,
|
|
45
|
+
missingMessage: 'Please choose an option.', anchor: () => this.renderRoot.querySelector('button'),
|
|
46
|
+
});
|
|
47
|
+
#default = '';
|
|
48
|
+
#detach;
|
|
49
|
+
constructor() {
|
|
50
|
+
super();
|
|
51
|
+
this.options = [];
|
|
52
|
+
this.value = '';
|
|
53
|
+
this.label = 'Choose';
|
|
54
|
+
this.placeholder = 'Select…';
|
|
55
|
+
this.required = false;
|
|
56
|
+
this.disabled = false;
|
|
57
|
+
this.anyLevel = false;
|
|
58
|
+
this.separator = ' / ';
|
|
59
|
+
this._open = false;
|
|
60
|
+
this._trail = [];
|
|
61
|
+
}
|
|
62
|
+
connectedCallback() { super.connectedCallback(); this.#default = this.value; this.addEventListener('focusout', this.#onFocusOut); }
|
|
63
|
+
disconnectedCallback() { super.disconnectedCallback(); this.removeEventListener('focusout', this.#onFocusOut); this.#detach?.(); this.#detach = undefined; }
|
|
64
|
+
formResetCallback() { this.value = this.#default; this.#field.reset(); }
|
|
65
|
+
formStateRestoreCallback(v) { this.value = v; }
|
|
66
|
+
formDisabledCallback(d) { this.disabled = d; }
|
|
67
|
+
/** The chosen option and its parents, top level first. */
|
|
68
|
+
get path() { return optionPath(this.options, this.value); }
|
|
69
|
+
#onFocusOut = (e) => { if (!e.relatedTarget || !this.contains(e.relatedTarget))
|
|
70
|
+
queueMicrotask(() => { if (!this.matches(':focus-within'))
|
|
71
|
+
this.#close(); }); };
|
|
72
|
+
#open() {
|
|
73
|
+
if (this._open || this.disabled)
|
|
74
|
+
return;
|
|
75
|
+
const path = this.path.map((o) => o.value);
|
|
76
|
+
this._trail = path.length ? path : this.options.length ? [this.#firstEnabled(this.options)] : [];
|
|
77
|
+
this._open = true;
|
|
78
|
+
}
|
|
79
|
+
#close(focus = false) {
|
|
80
|
+
if (!this._open)
|
|
81
|
+
return;
|
|
82
|
+
this._open = false;
|
|
83
|
+
if (focus)
|
|
84
|
+
this.renderRoot.querySelector('button')?.focus();
|
|
85
|
+
}
|
|
86
|
+
#firstEnabled(list) { return (list.find((o) => !o.disabled) ?? list[0])?.value ?? ''; }
|
|
87
|
+
/** Columns to show: the top level, then the children of each highlighted option. */
|
|
88
|
+
#columns() {
|
|
89
|
+
const cols = [this.options];
|
|
90
|
+
for (const v of this._trail) {
|
|
91
|
+
const o = cols[cols.length - 1].find((x) => x.value === v);
|
|
92
|
+
if (!o?.children?.length)
|
|
93
|
+
break;
|
|
94
|
+
cols.push(o.children);
|
|
95
|
+
}
|
|
96
|
+
return cols;
|
|
97
|
+
}
|
|
98
|
+
#choose(o) {
|
|
99
|
+
if (o.disabled)
|
|
100
|
+
return;
|
|
101
|
+
this.value = o.value;
|
|
102
|
+
this.#field.touch();
|
|
103
|
+
this.emit('pm-change', { value: o.value, path: this.path.map((p) => p.value) });
|
|
104
|
+
this.#close(true);
|
|
105
|
+
}
|
|
106
|
+
/** Clear the value. */
|
|
107
|
+
clear() { if (!this.value)
|
|
108
|
+
return; this.value = ''; this.emit('pm-change', { value: '', path: [] }); }
|
|
109
|
+
#onKey = (e) => {
|
|
110
|
+
if (!this._open) {
|
|
111
|
+
if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {
|
|
112
|
+
e.preventDefault();
|
|
113
|
+
this.#open();
|
|
114
|
+
}
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
const cols = this.#columns();
|
|
118
|
+
// The cursor is the last highlighted option; its column is the one that contains it.
|
|
119
|
+
const depth = Math.max(0, this._trail.length - 1);
|
|
120
|
+
const col = cols[depth] ?? [];
|
|
121
|
+
const i = col.findIndex((o) => o.value === this._trail[depth]);
|
|
122
|
+
const cur = col[i];
|
|
123
|
+
const rtl = getComputedStyle(this).direction === 'rtl';
|
|
124
|
+
const forward = rtl ? 'ArrowLeft' : 'ArrowRight';
|
|
125
|
+
const back = rtl ? 'ArrowRight' : 'ArrowLeft';
|
|
126
|
+
const move = (dir) => {
|
|
127
|
+
for (let k = i + dir; k >= 0 && k < col.length; k += dir)
|
|
128
|
+
if (!col[k].disabled) {
|
|
129
|
+
this._trail = [...this._trail.slice(0, depth), col[k].value];
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
if (e.key === 'ArrowDown') {
|
|
134
|
+
e.preventDefault();
|
|
135
|
+
move(1);
|
|
136
|
+
}
|
|
137
|
+
else if (e.key === 'ArrowUp') {
|
|
138
|
+
e.preventDefault();
|
|
139
|
+
move(-1);
|
|
140
|
+
}
|
|
141
|
+
else if (e.key === forward) {
|
|
142
|
+
e.preventDefault();
|
|
143
|
+
if (cur?.children?.length && !cur.disabled)
|
|
144
|
+
this._trail = [...this._trail, this.#firstEnabled(cur.children)];
|
|
145
|
+
}
|
|
146
|
+
else if (e.key === back) {
|
|
147
|
+
e.preventDefault();
|
|
148
|
+
if (depth > 0)
|
|
149
|
+
this._trail = this._trail.slice(0, depth);
|
|
150
|
+
}
|
|
151
|
+
else if (e.key === 'Enter' || e.key === ' ') {
|
|
152
|
+
e.preventDefault();
|
|
153
|
+
if (!cur || cur.disabled)
|
|
154
|
+
return;
|
|
155
|
+
if (cur.children?.length && !this.anyLevel)
|
|
156
|
+
this._trail = [...this._trail, this.#firstEnabled(cur.children)];
|
|
157
|
+
else
|
|
158
|
+
this.#choose(cur);
|
|
159
|
+
}
|
|
160
|
+
else if (e.key === 'Escape') {
|
|
161
|
+
e.preventDefault();
|
|
162
|
+
e.stopPropagation();
|
|
163
|
+
this.#close(true);
|
|
164
|
+
}
|
|
165
|
+
else if (e.key === 'Tab')
|
|
166
|
+
this.#close();
|
|
167
|
+
};
|
|
168
|
+
#click(o, depth) {
|
|
169
|
+
if (o.disabled)
|
|
170
|
+
return;
|
|
171
|
+
const already = this._trail[depth] === o.value;
|
|
172
|
+
this._trail = [...this._trail.slice(0, depth), o.value];
|
|
173
|
+
if (!o.children?.length || (this.anyLevel && already))
|
|
174
|
+
this.#choose(o);
|
|
175
|
+
}
|
|
176
|
+
updated(changed) {
|
|
177
|
+
super.updated(changed);
|
|
178
|
+
this.#internals.setFormValue(this.value || null);
|
|
179
|
+
const popup = this.renderRoot.querySelector('.pm-listbox-popup');
|
|
180
|
+
const trigger = this.renderRoot.querySelector('button');
|
|
181
|
+
if (!popup || !trigger)
|
|
182
|
+
return;
|
|
183
|
+
if (this._open) {
|
|
184
|
+
showPopup(popup);
|
|
185
|
+
this.#detach ??= attachBelow(popup, trigger, { matchWidth: false, sheet: true });
|
|
186
|
+
for (const el of this.renderRoot.querySelectorAll('[data-active], [data-open]'))
|
|
187
|
+
el.scrollIntoView({ block: 'nearest', inline: 'nearest' });
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
this.#detach?.();
|
|
191
|
+
this.#detach = undefined;
|
|
192
|
+
hidePopup(popup);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
render() {
|
|
196
|
+
const path = this.path;
|
|
197
|
+
const cols = this._open ? this.#columns() : [];
|
|
198
|
+
const cursor = this._trail[this._trail.length - 1];
|
|
199
|
+
const invalid = this.#field.invalid;
|
|
200
|
+
return html `<div class="pm-field" part="field">
|
|
201
|
+
<span class="pm-label" id="l" part="label" ?data-required=${this.required}>${this.label}</span>
|
|
202
|
+
<button type="button" class="pm-input pm-picker-trigger" part="base" data-size=${this.size ?? nothing} role="combobox" aria-haspopup="tree" aria-expanded=${String(this._open)} aria-controls="pop"
|
|
203
|
+
aria-labelledby="l v" aria-describedby=${this.#field.describedBy ?? nothing} aria-invalid=${invalid ? 'true' : nothing} ?disabled=${this.disabled}
|
|
204
|
+
aria-activedescendant=${this._open && cursor ? `o-${cursor}` : nothing}
|
|
205
|
+
@click=${() => (this._open ? this.#close() : this.#open())} @keydown=${this.#onKey}>
|
|
206
|
+
<span class="pm-picker-value" id="v" ?data-placeholder=${!path.length}>${path.length ? path.map((o) => o.label).join(this.separator) : this.placeholder}</span>
|
|
207
|
+
</button>
|
|
208
|
+
<div class="pm-listbox-popup pm-cascader-panel" id="pop" popover="manual" part="popup" role="tree" aria-labelledby="l" @pointerdown=${(e) => e.preventDefault()}>
|
|
209
|
+
${cols.map((col, depth) => html `<ul class="pm-listbox" role="group">
|
|
210
|
+
${col.map((o) => html `<li class="pm-option" role="treeitem" id="o-${o.value}" aria-selected=${String(o.value === this.value)} aria-disabled=${o.disabled ? 'true' : nothing}
|
|
211
|
+
aria-expanded=${o.children?.length ? String(this._trail[depth] === o.value && depth < this._trail.length - 1) : nothing}
|
|
212
|
+
?data-branch=${!!o.children?.length} ?data-open=${this._trail[depth] === o.value && o.value !== cursor} ?data-active=${o.value === cursor}
|
|
213
|
+
@click=${() => this.#click(o, depth)}><span class="pm-option-label">${o.label}</span></li>`)}
|
|
214
|
+
</ul>`)}
|
|
215
|
+
</div>
|
|
216
|
+
${this.#field.messages()}
|
|
217
|
+
</div>`;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
defineElement('pm-cascader', PmCascader);
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { type PropertyDeclarations, type TemplateResult } from 'lit';
|
|
2
|
+
import { PmElement, type Tone } from '../base.js';
|
|
3
|
+
export interface ChartSeries {
|
|
4
|
+
name: string;
|
|
5
|
+
values: number[];
|
|
6
|
+
/** Colour role; defaults cycle through accent, secondary, info, success, warning, danger. */
|
|
7
|
+
tone?: Tone;
|
|
8
|
+
}
|
|
9
|
+
/** Round axis steps: 1, 2 or 5 times a power of ten. */
|
|
10
|
+
export declare function niceTicks(min: number, max: number, count?: number): number[];
|
|
11
|
+
/**
|
|
12
|
+
* Chart: bar, line, area and donut charts drawn as SVG, with no dependencies. Colours come from the theme's roles,
|
|
13
|
+
* so charts follow every theme, mode and tone.
|
|
14
|
+
*
|
|
15
|
+
* Data: `labels` (categories) and `series` (`[{ name, values, tone? }]`), as properties or JSON attributes. For one
|
|
16
|
+
* series, `values="4,8,6"` is enough. A donut uses the first series: one slice per label.
|
|
17
|
+
*
|
|
18
|
+
* Reading values: hover or tap shows a tooltip; focus the chart and use the arrow keys to step through the data
|
|
19
|
+
* (Home/End jump, Escape clears). The same data is offered to screen readers as a table.
|
|
20
|
+
* @tag pm-chart
|
|
21
|
+
* @fires pm-select - A data point was clicked or chosen with Enter. detail: { index, label, values }
|
|
22
|
+
* @example <pm-chart type="bar" label="Orders per day" labels="Mon,Tue,Wed,Thu,Fri" values="32,45,38,51,60"></pm-chart>
|
|
23
|
+
*/
|
|
24
|
+
export declare class PmChart extends PmElement {
|
|
25
|
+
#private;
|
|
26
|
+
static componentName: string;
|
|
27
|
+
static styles: import("lit").CSSResult[];
|
|
28
|
+
static properties: PropertyDeclarations;
|
|
29
|
+
/** bar (default), line, area or donut. */
|
|
30
|
+
type?: 'bar' | 'line' | 'area' | 'donut';
|
|
31
|
+
/** Accessible name and table caption, e.g. "Revenue by month". */
|
|
32
|
+
label?: string;
|
|
33
|
+
/** Category names along the x axis (or donut slices): `labels="Jan,Feb,Mar"` or an array. */
|
|
34
|
+
labels: string[];
|
|
35
|
+
/** One or more data series: `[{ name, values, tone? }]`. */
|
|
36
|
+
series: ChartSeries[];
|
|
37
|
+
/** Shorthand for a single series. */
|
|
38
|
+
values?: number[];
|
|
39
|
+
/** Plot height in pixels (default 240; 200 for a donut). */
|
|
40
|
+
height?: number;
|
|
41
|
+
/** Stack bars or areas instead of placing them side by side. */
|
|
42
|
+
stacked?: boolean;
|
|
43
|
+
/** Hide the legend (shown by default for two or more series and for donuts). */
|
|
44
|
+
hideLegend?: boolean;
|
|
45
|
+
/** Text before each value, e.g. "$". */
|
|
46
|
+
valuePrefix?: string;
|
|
47
|
+
/** Text after each value, e.g. "%". */
|
|
48
|
+
valueSuffix?: string;
|
|
49
|
+
/** Show a placeholder while data loads. */
|
|
50
|
+
loading?: boolean;
|
|
51
|
+
/** Message when there is no data (default "No data"). */
|
|
52
|
+
emptyText?: string;
|
|
53
|
+
_w: number;
|
|
54
|
+
_active: number;
|
|
55
|
+
constructor();
|
|
56
|
+
connectedCallback(): void;
|
|
57
|
+
disconnectedCallback(): void;
|
|
58
|
+
render(): TemplateResult<1>;
|
|
59
|
+
}
|