@chromvoid/uikit 0.1.0
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 +8 -0
- package/README.md +96 -0
- package/dist/components/cv-accordion-item.d.ts +69 -0
- package/dist/components/cv-accordion-item.js +176 -0
- package/dist/components/cv-accordion.d.ts +79 -0
- package/dist/components/cv-accordion.js +310 -0
- package/dist/components/cv-alert-dialog.d.ts +86 -0
- package/dist/components/cv-alert-dialog.js +393 -0
- package/dist/components/cv-alert.d.ts +48 -0
- package/dist/components/cv-alert.js +156 -0
- package/dist/components/cv-badge.d.ts +56 -0
- package/dist/components/cv-badge.js +280 -0
- package/dist/components/cv-breadcrumb-item.d.ts +35 -0
- package/dist/components/cv-breadcrumb-item.js +64 -0
- package/dist/components/cv-breadcrumb.d.ts +39 -0
- package/dist/components/cv-breadcrumb.js +160 -0
- package/dist/components/cv-button.d.ts +83 -0
- package/dist/components/cv-button.js +541 -0
- package/dist/components/cv-callout.d.ts +32 -0
- package/dist/components/cv-callout.js +221 -0
- package/dist/components/cv-card.d.ts +48 -0
- package/dist/components/cv-card.js +269 -0
- package/dist/components/cv-carousel-slide.d.ts +25 -0
- package/dist/components/cv-carousel-slide.js +51 -0
- package/dist/components/cv-carousel.d.ts +96 -0
- package/dist/components/cv-carousel.js +457 -0
- package/dist/components/cv-checkbox.d.ts +84 -0
- package/dist/components/cv-checkbox.js +274 -0
- package/dist/components/cv-combobox-group.d.ts +15 -0
- package/dist/components/cv-combobox-group.js +34 -0
- package/dist/components/cv-combobox-option.d.ts +30 -0
- package/dist/components/cv-combobox-option.js +66 -0
- package/dist/components/cv-combobox.d.ts +135 -0
- package/dist/components/cv-combobox.js +834 -0
- package/dist/components/cv-command-item.d.ts +30 -0
- package/dist/components/cv-command-item.js +68 -0
- package/dist/components/cv-command-palette.d.ts +105 -0
- package/dist/components/cv-command-palette.js +578 -0
- package/dist/components/cv-context-menu.d.ts +98 -0
- package/dist/components/cv-context-menu.js +515 -0
- package/dist/components/cv-copy-button.d.ts +61 -0
- package/dist/components/cv-copy-button.js +318 -0
- package/dist/components/cv-date-picker.d.ts +161 -0
- package/dist/components/cv-date-picker.js +803 -0
- package/dist/components/cv-dialog.d.ts +89 -0
- package/dist/components/cv-dialog.js +459 -0
- package/dist/components/cv-disclosure.d.ts +57 -0
- package/dist/components/cv-disclosure.js +241 -0
- package/dist/components/cv-drawer.d.ts +102 -0
- package/dist/components/cv-drawer.js +595 -0
- package/dist/components/cv-feed-article.d.ts +26 -0
- package/dist/components/cv-feed-article.js +52 -0
- package/dist/components/cv-feed.d.ts +62 -0
- package/dist/components/cv-feed.js +310 -0
- package/dist/components/cv-grid-cell.d.ts +30 -0
- package/dist/components/cv-grid-cell.js +57 -0
- package/dist/components/cv-grid-column.d.ts +30 -0
- package/dist/components/cv-grid-column.js +43 -0
- package/dist/components/cv-grid-row.d.ts +30 -0
- package/dist/components/cv-grid-row.js +42 -0
- package/dist/components/cv-grid.d.ts +119 -0
- package/dist/components/cv-grid.js +567 -0
- package/dist/components/cv-icon.d.ts +57 -0
- package/dist/components/cv-icon.js +352 -0
- package/dist/components/cv-input.d.ts +127 -0
- package/dist/components/cv-input.js +482 -0
- package/dist/components/cv-landmark.d.ts +32 -0
- package/dist/components/cv-landmark.js +62 -0
- package/dist/components/cv-link.d.ts +22 -0
- package/dist/components/cv-link.js +99 -0
- package/dist/components/cv-listbox-group.d.ts +15 -0
- package/dist/components/cv-listbox-group.js +42 -0
- package/dist/components/cv-listbox.d.ts +81 -0
- package/dist/components/cv-listbox.js +388 -0
- package/dist/components/cv-menu-button.d.ts +118 -0
- package/dist/components/cv-menu-button.js +822 -0
- package/dist/components/cv-menu-group.d.ts +20 -0
- package/dist/components/cv-menu-group.js +48 -0
- package/dist/components/cv-menu-item.d.ts +52 -0
- package/dist/components/cv-menu-item.js +105 -0
- package/dist/components/cv-menu.d.ts +62 -0
- package/dist/components/cv-menu.js +414 -0
- package/dist/components/cv-meter.d.ts +66 -0
- package/dist/components/cv-meter.js +154 -0
- package/dist/components/cv-number.d.ts +139 -0
- package/dist/components/cv-number.js +553 -0
- package/dist/components/cv-option.d.ts +30 -0
- package/dist/components/cv-option.js +84 -0
- package/dist/components/cv-popover.d.ts +87 -0
- package/dist/components/cv-popover.js +373 -0
- package/dist/components/cv-progress-ring.d.ts +45 -0
- package/dist/components/cv-progress-ring.js +169 -0
- package/dist/components/cv-progress.d.ts +45 -0
- package/dist/components/cv-progress.js +148 -0
- package/dist/components/cv-radio-group.d.ts +79 -0
- package/dist/components/cv-radio-group.js +398 -0
- package/dist/components/cv-radio.d.ts +36 -0
- package/dist/components/cv-radio.js +123 -0
- package/dist/components/cv-select-group.d.ts +15 -0
- package/dist/components/cv-select-group.js +44 -0
- package/dist/components/cv-select-option.d.ts +30 -0
- package/dist/components/cv-select-option.js +66 -0
- package/dist/components/cv-select.d.ts +128 -0
- package/dist/components/cv-select.js +666 -0
- package/dist/components/cv-sidebar-item.d.ts +26 -0
- package/dist/components/cv-sidebar-item.js +142 -0
- package/dist/components/cv-sidebar.d.ts +171 -0
- package/dist/components/cv-sidebar.js +767 -0
- package/dist/components/cv-slider-multi-thumb.d.ts +73 -0
- package/dist/components/cv-slider-multi-thumb.js +374 -0
- package/dist/components/cv-slider.d.ts +84 -0
- package/dist/components/cv-slider.js +328 -0
- package/dist/components/cv-spinbutton.d.ts +121 -0
- package/dist/components/cv-spinbutton.js +486 -0
- package/dist/components/cv-spinner.d.ts +18 -0
- package/dist/components/cv-spinner.js +95 -0
- package/dist/components/cv-switch.d.ts +81 -0
- package/dist/components/cv-switch.js +285 -0
- package/dist/components/cv-tab-panel.d.ts +20 -0
- package/dist/components/cv-tab-panel.js +37 -0
- package/dist/components/cv-tab.d.ts +40 -0
- package/dist/components/cv-tab.js +132 -0
- package/dist/components/cv-table-cell.d.ts +31 -0
- package/dist/components/cv-table-cell.js +49 -0
- package/dist/components/cv-table-column.d.ts +37 -0
- package/dist/components/cv-table-column.js +63 -0
- package/dist/components/cv-table-row.d.ts +30 -0
- package/dist/components/cv-table-row.js +45 -0
- package/dist/components/cv-table.d.ts +147 -0
- package/dist/components/cv-table.js +607 -0
- package/dist/components/cv-tabs.d.ts +70 -0
- package/dist/components/cv-tabs.js +524 -0
- package/dist/components/cv-textarea.d.ts +108 -0
- package/dist/components/cv-textarea.js +328 -0
- package/dist/components/cv-toast-region.d.ts +39 -0
- package/dist/components/cv-toast-region.js +162 -0
- package/dist/components/cv-toast.d.ts +67 -0
- package/dist/components/cv-toast.js +315 -0
- package/dist/components/cv-toolbar-item.d.ts +25 -0
- package/dist/components/cv-toolbar-item.js +72 -0
- package/dist/components/cv-toolbar-separator.d.ts +25 -0
- package/dist/components/cv-toolbar-separator.js +45 -0
- package/dist/components/cv-toolbar.d.ts +63 -0
- package/dist/components/cv-toolbar.js +295 -0
- package/dist/components/cv-tooltip.d.ts +83 -0
- package/dist/components/cv-tooltip.js +455 -0
- package/dist/components/cv-treegrid-cell.d.ts +30 -0
- package/dist/components/cv-treegrid-cell.js +57 -0
- package/dist/components/cv-treegrid-column.d.ts +37 -0
- package/dist/components/cv-treegrid-column.js +53 -0
- package/dist/components/cv-treegrid-row.d.ts +55 -0
- package/dist/components/cv-treegrid-row.js +90 -0
- package/dist/components/cv-treegrid.d.ts +96 -0
- package/dist/components/cv-treegrid.js +632 -0
- package/dist/components/cv-treeitem.d.ts +58 -0
- package/dist/components/cv-treeitem.js +144 -0
- package/dist/components/cv-treeview.d.ts +70 -0
- package/dist/components/cv-treeview.js +396 -0
- package/dist/components/cv-window-splitter.d.ts +79 -0
- package/dist/components/cv-window-splitter.js +316 -0
- package/dist/components/index.d.ts +94 -0
- package/dist/components/index.js +79 -0
- package/dist/dialog/create-dialog-controller.d.ts +31 -0
- package/dist/dialog/create-dialog-controller.js +320 -0
- package/dist/dialog/index.d.ts +2 -0
- package/dist/dialog/index.js +1 -0
- package/dist/form-associated/FormAssociatedReatomElement.d.ts +25 -0
- package/dist/form-associated/FormAssociatedReatomElement.js +70 -0
- package/dist/form-associated/withFormAssociated.d.ts +5 -0
- package/dist/form-associated/withFormAssociated.js +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +9 -0
- package/dist/reatom-lit/ReatomLitElement.d.ts +27 -0
- package/dist/reatom-lit/ReatomLitElement.js +118 -0
- package/dist/reatom-lit/html.d.ts +4 -0
- package/dist/reatom-lit/html.js +10 -0
- package/dist/reatom-lit/index.d.ts +4 -0
- package/dist/reatom-lit/index.js +4 -0
- package/dist/reatom-lit/watch.d.ts +15 -0
- package/dist/reatom-lit/watch.js +40 -0
- package/dist/reatom-lit/withReatomElement.d.ts +4 -0
- package/dist/reatom-lit/withReatomElement.js +57 -0
- package/dist/register.d.ts +1 -0
- package/dist/register.js +84 -0
- package/dist/styles/component-styles.d.ts +4 -0
- package/dist/styles/component-styles.js +78 -0
- package/dist/theme/cv-theme-provider.d.ts +32 -0
- package/dist/theme/cv-theme-provider.js +110 -0
- package/dist/theme/index.d.ts +4 -0
- package/dist/theme/index.js +2 -0
- package/dist/theme/theme-engine.d.ts +4 -0
- package/dist/theme/theme-engine.js +67 -0
- package/dist/theme/tokens.css +265 -0
- package/dist/theme/types.d.ts +7 -0
- package/dist/theme/types.js +1 -0
- package/dist/toast/create-toast-controller.d.ts +12 -0
- package/dist/toast/create-toast-controller.js +12 -0
- package/dist/toast/index.d.ts +2 -0
- package/dist/toast/index.js +1 -0
- package/package.json +146 -0
- package/specs/_template.md +110 -0
- package/specs/components/accordion.md +207 -0
- package/specs/components/alert.md +83 -0
- package/specs/components/badge.md +183 -0
- package/specs/components/breadcrumb.md +152 -0
- package/specs/components/button.md +227 -0
- package/specs/components/callout.md +153 -0
- package/specs/components/card.md +192 -0
- package/specs/components/carousel.md +232 -0
- package/specs/components/checkbox.md +141 -0
- package/specs/components/combobox.md +427 -0
- package/specs/components/context-menu.md +375 -0
- package/specs/components/copy-button.md +236 -0
- package/specs/components/date-picker.md +290 -0
- package/specs/components/dialog.md +184 -0
- package/specs/components/disclosure.md +151 -0
- package/specs/components/drawer.md +216 -0
- package/specs/components/feed.md +266 -0
- package/specs/components/grid.md +423 -0
- package/specs/components/input.md +237 -0
- package/specs/components/landmark.md +92 -0
- package/specs/components/link.md +117 -0
- package/specs/components/listbox.md +327 -0
- package/specs/components/menu.md +508 -0
- package/specs/components/meter.md +148 -0
- package/specs/components/number.md +268 -0
- package/specs/components/option.md +167 -0
- package/specs/components/popover.md +207 -0
- package/specs/components/progress-ring.md +134 -0
- package/specs/components/progress.md +110 -0
- package/specs/components/radio.md +208 -0
- package/specs/components/select.md +305 -0
- package/specs/components/sidebar.md +204 -0
- package/specs/components/spinbutton.md +157 -0
- package/specs/components/spinner.md +83 -0
- package/specs/components/switch.md +145 -0
- package/specs/components/table.md +372 -0
- package/specs/components/tabs.md +242 -0
- package/specs/components/textarea.md +166 -0
- package/specs/components/theme.md +364 -0
- package/specs/components/toast.md +198 -0
- package/specs/components/toolbar.md +258 -0
- package/specs/components/tooltip.md +152 -0
- package/specs/components/treegrid.md +363 -0
- package/specs/components/treeview.md +263 -0
- package/specs/components/window-splitter.md +225 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { ReatomLitElement } from '../reatom-lit/ReatomLitElement.js';
|
|
2
|
+
export declare function setIconBasePath(path: string): void;
|
|
3
|
+
export declare function getIconBasePath(): string;
|
|
4
|
+
export declare function registerIconCollection(name: string, path: string): void;
|
|
5
|
+
export declare function unregisterIconCollection(name: string): void;
|
|
6
|
+
export type CVIconSize = 'xs' | 's' | 'm' | 'md' | 'l' | 'lg';
|
|
7
|
+
export type CVIconColor = 'default' | 'muted' | 'primary' | 'success' | 'warning' | 'danger';
|
|
8
|
+
export declare class CVIcon extends ReatomLitElement {
|
|
9
|
+
static elementName: string;
|
|
10
|
+
private static svgCache;
|
|
11
|
+
private static inFlight;
|
|
12
|
+
static get properties(): {
|
|
13
|
+
name: {
|
|
14
|
+
type: StringConstructor;
|
|
15
|
+
};
|
|
16
|
+
src: {
|
|
17
|
+
type: StringConstructor;
|
|
18
|
+
};
|
|
19
|
+
size: {
|
|
20
|
+
type: StringConstructor;
|
|
21
|
+
reflect: boolean;
|
|
22
|
+
};
|
|
23
|
+
color: {
|
|
24
|
+
type: StringConstructor;
|
|
25
|
+
reflect: boolean;
|
|
26
|
+
};
|
|
27
|
+
label: {
|
|
28
|
+
type: StringConstructor;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
name: string;
|
|
32
|
+
src: string | undefined;
|
|
33
|
+
size: CVIconSize;
|
|
34
|
+
color: CVIconColor;
|
|
35
|
+
label?: string;
|
|
36
|
+
private svgMarkup;
|
|
37
|
+
private hasSlottedContent;
|
|
38
|
+
constructor();
|
|
39
|
+
static styles: import("lit").CSSResult[];
|
|
40
|
+
static define(): void;
|
|
41
|
+
/**
|
|
42
|
+
* Eagerly fetch and cache SVG for the given icon name(s) so that
|
|
43
|
+
* later renders are instant (no network wait).
|
|
44
|
+
*/
|
|
45
|
+
static prefetch(names: string | string[]): void;
|
|
46
|
+
willUpdate(changedProperties: Map<string, unknown>): void;
|
|
47
|
+
private static resolveIconName;
|
|
48
|
+
private static getCollectionBasePath;
|
|
49
|
+
private static getIconUrls;
|
|
50
|
+
private loadSvg;
|
|
51
|
+
private static fetchSvg;
|
|
52
|
+
private static fetchSingleSvg;
|
|
53
|
+
private handleSlotChange;
|
|
54
|
+
protected render(): import("lit").TemplateResult<1>;
|
|
55
|
+
}
|
|
56
|
+
export type LucideIconName = string;
|
|
57
|
+
export type IconName = LucideIconName;
|
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
import { css, html } from 'lit';
|
|
2
|
+
import { unsafeHTML } from 'lit/directives/unsafe-html.js';
|
|
3
|
+
import { ReatomLitElement } from '../reatom-lit/ReatomLitElement.js';
|
|
4
|
+
let iconBasePath = '/assets/icons/lucide';
|
|
5
|
+
const iconCollections = new Map();
|
|
6
|
+
function normalizeBasePath(path) {
|
|
7
|
+
return path.endsWith('/') ? path.slice(0, -1) : path;
|
|
8
|
+
}
|
|
9
|
+
function normalizeCollectionName(name) {
|
|
10
|
+
return name.trim().toLowerCase();
|
|
11
|
+
}
|
|
12
|
+
export function setIconBasePath(path) {
|
|
13
|
+
iconBasePath = normalizeBasePath(path);
|
|
14
|
+
}
|
|
15
|
+
export function getIconBasePath() {
|
|
16
|
+
return iconBasePath;
|
|
17
|
+
}
|
|
18
|
+
export function registerIconCollection(name, path) {
|
|
19
|
+
iconCollections.set(normalizeCollectionName(name), normalizeBasePath(path));
|
|
20
|
+
}
|
|
21
|
+
export function unregisterIconCollection(name) {
|
|
22
|
+
iconCollections.delete(normalizeCollectionName(name));
|
|
23
|
+
}
|
|
24
|
+
const BOOTSTRAP_TO_LUCIDE = {
|
|
25
|
+
folder: 'folder',
|
|
26
|
+
'folder-fill': 'folder',
|
|
27
|
+
'folder-plus': 'folder-plus',
|
|
28
|
+
'folder2-open': 'folder-open',
|
|
29
|
+
'folder-open': 'folder-open',
|
|
30
|
+
'folder-x': 'folder-x',
|
|
31
|
+
'file-earmark-text': 'file-text',
|
|
32
|
+
'file-earmark': 'file',
|
|
33
|
+
'file-earmark-image': 'file-image',
|
|
34
|
+
'file-earmark-pdf': 'file-text',
|
|
35
|
+
'file-earmark-word': 'file-text',
|
|
36
|
+
'file-earmark-excel': 'file-spreadsheet',
|
|
37
|
+
'file-earmark-ppt': 'file-text',
|
|
38
|
+
'file-earmark-zip': 'file-archive',
|
|
39
|
+
'file-earmark-music': 'file-music',
|
|
40
|
+
'file-earmark-play': 'file-play',
|
|
41
|
+
'file-earmark-code': 'file-code',
|
|
42
|
+
file: 'file',
|
|
43
|
+
'chevron-down': 'chevron-down',
|
|
44
|
+
'chevron-up': 'chevron-up',
|
|
45
|
+
'chevron-right': 'chevron-right',
|
|
46
|
+
'chevron-left': 'chevron-left',
|
|
47
|
+
'arrow-up': 'arrow-up',
|
|
48
|
+
'arrow-down': 'arrow-down',
|
|
49
|
+
'arrow-left': 'arrow-left',
|
|
50
|
+
'arrow-right': 'arrow-right',
|
|
51
|
+
'arrow-clockwise': 'refresh-cw',
|
|
52
|
+
'arrow-repeat': 'refresh-cw',
|
|
53
|
+
'arrows-move': 'move',
|
|
54
|
+
upload: 'upload',
|
|
55
|
+
download: 'download',
|
|
56
|
+
'cloud-upload': 'cloud-upload',
|
|
57
|
+
'cloud-download': 'cloud-download',
|
|
58
|
+
trash: 'trash-2',
|
|
59
|
+
pencil: 'pencil',
|
|
60
|
+
'pencil-square': 'square-pen',
|
|
61
|
+
copy: 'copy',
|
|
62
|
+
clipboard: 'clipboard',
|
|
63
|
+
clipboard2: 'clipboard',
|
|
64
|
+
eye: 'eye',
|
|
65
|
+
search: 'search',
|
|
66
|
+
x: 'x',
|
|
67
|
+
'x-lg': 'x',
|
|
68
|
+
'plus-lg': 'plus',
|
|
69
|
+
check: 'check',
|
|
70
|
+
justify: 'align-justify',
|
|
71
|
+
bars: 'menu',
|
|
72
|
+
menu: 'menu',
|
|
73
|
+
list: 'list',
|
|
74
|
+
'list-check': 'list-checks',
|
|
75
|
+
grid: 'grid-2x2',
|
|
76
|
+
table: 'table',
|
|
77
|
+
funnel: 'funnel',
|
|
78
|
+
'three-dots': 'ellipsis',
|
|
79
|
+
'three-dots-vertical': 'ellipsis-vertical',
|
|
80
|
+
'dots-vertical': 'ellipsis-vertical',
|
|
81
|
+
'ellipsis-vertical': 'ellipsis-vertical',
|
|
82
|
+
'more-vertical': 'ellipsis-vertical',
|
|
83
|
+
kebab: 'ellipsis-vertical',
|
|
84
|
+
ellipsis: 'ellipsis',
|
|
85
|
+
more: 'ellipsis',
|
|
86
|
+
'info-circle': 'info',
|
|
87
|
+
'info-circle-fill': 'info',
|
|
88
|
+
info: 'info',
|
|
89
|
+
'check-circle-fill': 'check-circle',
|
|
90
|
+
'x-circle-fill': 'x-circle',
|
|
91
|
+
'exclamation-triangle': 'triangle-alert',
|
|
92
|
+
'exclamation-triangle-fill': 'triangle-alert',
|
|
93
|
+
'pause-circle-fill': 'pause-circle',
|
|
94
|
+
house: 'home',
|
|
95
|
+
'house-fill': 'home',
|
|
96
|
+
home: 'home',
|
|
97
|
+
key: 'key',
|
|
98
|
+
lock: 'lock',
|
|
99
|
+
database: 'database',
|
|
100
|
+
activity: 'activity',
|
|
101
|
+
settings: 'settings',
|
|
102
|
+
gear: 'settings',
|
|
103
|
+
tags: 'tags',
|
|
104
|
+
tag: 'tag',
|
|
105
|
+
star: 'star',
|
|
106
|
+
clock: 'clock',
|
|
107
|
+
'wifi-off': 'wifi-off',
|
|
108
|
+
wifi: 'wifi',
|
|
109
|
+
globe: 'globe',
|
|
110
|
+
'person-circle': 'user-circle',
|
|
111
|
+
user: 'user',
|
|
112
|
+
'shield-lock': 'shield',
|
|
113
|
+
'shield-check': 'shield-check',
|
|
114
|
+
sun: 'sun',
|
|
115
|
+
moon: 'moon',
|
|
116
|
+
eyeglasses: 'glasses',
|
|
117
|
+
'calendar-plus': 'calendar-plus',
|
|
118
|
+
paperclip: 'paperclip',
|
|
119
|
+
'box-arrow-up-right': 'external-link',
|
|
120
|
+
'layout-three-columns': 'columns-3',
|
|
121
|
+
columns: 'columns-2',
|
|
122
|
+
'sort-alpha-down': 'arrow-down-a-z',
|
|
123
|
+
'sort-alpha-up': 'arrow-up-a-z',
|
|
124
|
+
hdd: 'hard-drive',
|
|
125
|
+
'disc-fill': 'disc',
|
|
126
|
+
sticky: 'sticky-note',
|
|
127
|
+
'sticky-note': 'sticky-note',
|
|
128
|
+
'clock-history': 'history',
|
|
129
|
+
history: 'history',
|
|
130
|
+
};
|
|
131
|
+
export class CVIcon extends ReatomLitElement {
|
|
132
|
+
static elementName = 'cv-icon';
|
|
133
|
+
static svgCache = new Map();
|
|
134
|
+
static inFlight = new Map();
|
|
135
|
+
static get properties() {
|
|
136
|
+
return {
|
|
137
|
+
name: { type: String },
|
|
138
|
+
src: { type: String },
|
|
139
|
+
size: { type: String, reflect: true },
|
|
140
|
+
color: { type: String, reflect: true },
|
|
141
|
+
label: { type: String },
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
svgMarkup = '';
|
|
145
|
+
hasSlottedContent = false;
|
|
146
|
+
constructor() {
|
|
147
|
+
super();
|
|
148
|
+
this.name = '';
|
|
149
|
+
this.size = 'm';
|
|
150
|
+
this.color = 'default';
|
|
151
|
+
}
|
|
152
|
+
static styles = [
|
|
153
|
+
css `
|
|
154
|
+
:host {
|
|
155
|
+
display: inline-flex;
|
|
156
|
+
align-items: center;
|
|
157
|
+
justify-content: center;
|
|
158
|
+
vertical-align: middle;
|
|
159
|
+
line-height: 0;
|
|
160
|
+
color: inherit;
|
|
161
|
+
inline-size: var(--cv-icon-size, 1em);
|
|
162
|
+
block-size: var(--cv-icon-size, 1em);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
:host([size='xs']) {
|
|
166
|
+
--cv-icon-size: 12px;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
:host([size='s']) {
|
|
170
|
+
--cv-icon-size: 16px;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
:host([size='m']),
|
|
174
|
+
:host([size='md']) {
|
|
175
|
+
--cv-icon-size: 20px;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
:host([size='l']),
|
|
179
|
+
:host([size='lg']) {
|
|
180
|
+
--cv-icon-size: 24px;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
:host([color='muted']) {
|
|
184
|
+
color: var(--cv-color-text-muted, #9aa6bf);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
:host([color='primary']) {
|
|
188
|
+
color: var(--cv-color-primary, #65d7ff);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
:host([color='success']) {
|
|
192
|
+
color: var(--cv-color-success, #6ef7c8);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
:host([color='warning']) {
|
|
196
|
+
color: var(--cv-color-warning, #ffd36e);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
:host([color='danger']) {
|
|
200
|
+
color: var(--cv-color-danger, #ff7d86);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
.icon {
|
|
204
|
+
display: contents;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
.icon svg,
|
|
208
|
+
::slotted(svg) {
|
|
209
|
+
inline-size: 100%;
|
|
210
|
+
block-size: 100%;
|
|
211
|
+
display: block;
|
|
212
|
+
stroke: currentColor;
|
|
213
|
+
fill: none;
|
|
214
|
+
stroke-width: 2;
|
|
215
|
+
stroke-linecap: round;
|
|
216
|
+
stroke-linejoin: round;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
:host([fill]) .icon svg,
|
|
220
|
+
:host([fill]) ::slotted(svg) {
|
|
221
|
+
fill: currentColor;
|
|
222
|
+
stroke: none;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
:host(:not([data-slotted])) slot {
|
|
226
|
+
display: none;
|
|
227
|
+
}
|
|
228
|
+
`,
|
|
229
|
+
];
|
|
230
|
+
static define() {
|
|
231
|
+
if (!customElements.get(this.elementName)) {
|
|
232
|
+
customElements.define(this.elementName, this);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Eagerly fetch and cache SVG for the given icon name(s) so that
|
|
237
|
+
* later renders are instant (no network wait).
|
|
238
|
+
*/
|
|
239
|
+
static prefetch(names) {
|
|
240
|
+
const list = Array.isArray(names) ? names : [names];
|
|
241
|
+
for (const name of list) {
|
|
242
|
+
const urls = CVIcon.getIconUrls(name);
|
|
243
|
+
void CVIcon.fetchSvg(urls);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
willUpdate(changedProperties) {
|
|
247
|
+
super.willUpdate(changedProperties);
|
|
248
|
+
if (changedProperties.has('src') && this.src) {
|
|
249
|
+
void this.loadSvg(this.src);
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
if (changedProperties.has('name') && this.name && !this.src) {
|
|
253
|
+
void this.loadSvg(CVIcon.getIconUrls(this.name));
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
static resolveIconName(name) {
|
|
257
|
+
return BOOTSTRAP_TO_LUCIDE[name] ?? name;
|
|
258
|
+
}
|
|
259
|
+
static getCollectionBasePath(name) {
|
|
260
|
+
const normalizedName = normalizeCollectionName(name);
|
|
261
|
+
if (normalizedName === 'lucide') {
|
|
262
|
+
return iconBasePath;
|
|
263
|
+
}
|
|
264
|
+
return iconCollections.get(normalizedName) ?? null;
|
|
265
|
+
}
|
|
266
|
+
static getIconUrls(name) {
|
|
267
|
+
const separatorIndex = name.indexOf(':');
|
|
268
|
+
if (separatorIndex <= 0 || separatorIndex === name.length - 1) {
|
|
269
|
+
return [`${iconBasePath}/${CVIcon.resolveIconName(name)}.svg`];
|
|
270
|
+
}
|
|
271
|
+
const collectionName = name.slice(0, separatorIndex);
|
|
272
|
+
const iconName = name.slice(separatorIndex + 1);
|
|
273
|
+
const collectionBasePath = CVIcon.getCollectionBasePath(collectionName);
|
|
274
|
+
const urls = [];
|
|
275
|
+
if (collectionBasePath) {
|
|
276
|
+
urls.push(`${collectionBasePath}/${iconName}.svg`);
|
|
277
|
+
}
|
|
278
|
+
const fallbackUrl = `${iconBasePath}/${CVIcon.resolveIconName(iconName)}.svg`;
|
|
279
|
+
if (!urls.includes(fallbackUrl)) {
|
|
280
|
+
urls.push(fallbackUrl);
|
|
281
|
+
}
|
|
282
|
+
return urls;
|
|
283
|
+
}
|
|
284
|
+
async loadSvg(urls) {
|
|
285
|
+
this.svgMarkup = await CVIcon.fetchSvg(urls);
|
|
286
|
+
this.requestUpdate();
|
|
287
|
+
}
|
|
288
|
+
static async fetchSvg(urls) {
|
|
289
|
+
const candidates = Array.isArray(urls) ? urls : [urls];
|
|
290
|
+
for (const url of candidates) {
|
|
291
|
+
const svg = await CVIcon.fetchSingleSvg(url);
|
|
292
|
+
if (svg) {
|
|
293
|
+
return svg;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
return '';
|
|
297
|
+
}
|
|
298
|
+
static async fetchSingleSvg(url) {
|
|
299
|
+
const cached = CVIcon.svgCache.get(url);
|
|
300
|
+
if (cached)
|
|
301
|
+
return cached;
|
|
302
|
+
const inFlight = CVIcon.inFlight.get(url);
|
|
303
|
+
if (inFlight)
|
|
304
|
+
return inFlight;
|
|
305
|
+
const promise = (async () => {
|
|
306
|
+
try {
|
|
307
|
+
const response = await fetch(url);
|
|
308
|
+
if (!response.ok) {
|
|
309
|
+
CVIcon.inFlight.delete(url);
|
|
310
|
+
return '';
|
|
311
|
+
}
|
|
312
|
+
const svg = await response.text();
|
|
313
|
+
CVIcon.svgCache.set(url, svg);
|
|
314
|
+
CVIcon.inFlight.delete(url);
|
|
315
|
+
return svg;
|
|
316
|
+
}
|
|
317
|
+
catch {
|
|
318
|
+
CVIcon.inFlight.delete(url);
|
|
319
|
+
return '';
|
|
320
|
+
}
|
|
321
|
+
})();
|
|
322
|
+
CVIcon.inFlight.set(url, promise);
|
|
323
|
+
return promise;
|
|
324
|
+
}
|
|
325
|
+
handleSlotChange(event) {
|
|
326
|
+
const slot = event.target;
|
|
327
|
+
const nodes = slot.assignedNodes({ flatten: true });
|
|
328
|
+
this.hasSlottedContent = nodes.some((node) => node.nodeType === Node.ELEMENT_NODE && node.tagName === 'SVG');
|
|
329
|
+
if (this.hasSlottedContent) {
|
|
330
|
+
this.setAttribute('data-slotted', '');
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
this.removeAttribute('data-slotted');
|
|
334
|
+
}
|
|
335
|
+
render() {
|
|
336
|
+
const ariaHidden = this.label ? 'false' : 'true';
|
|
337
|
+
const ariaLabel = this.label ?? '';
|
|
338
|
+
if (this.svgMarkup && !this.hasSlottedContent) {
|
|
339
|
+
return html `
|
|
340
|
+
<span class="icon" role="img" aria-hidden=${ariaHidden} aria-label=${ariaLabel}>
|
|
341
|
+
${unsafeHTML(this.svgMarkup)}
|
|
342
|
+
</span>
|
|
343
|
+
`;
|
|
344
|
+
}
|
|
345
|
+
return html `
|
|
346
|
+
<span class="icon" role="img" aria-hidden=${ariaHidden} aria-label=${ariaLabel}>
|
|
347
|
+
<slot @slotchange=${this.handleSlotChange}></slot>
|
|
348
|
+
${this.svgMarkup ? unsafeHTML(this.svgMarkup) : ''}
|
|
349
|
+
</span>
|
|
350
|
+
`;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { type InputType } from '@chromvoid/headless-ui/input';
|
|
2
|
+
import type { PropertyValues } from 'lit';
|
|
3
|
+
import { FormAssociatedReatomElement } from '../form-associated/FormAssociatedReatomElement.js';
|
|
4
|
+
import type { FormAssociatedValidity } from '../form-associated/withFormAssociated.js';
|
|
5
|
+
type CVInputSize = 'small' | 'medium' | 'large';
|
|
6
|
+
type CVInputVariant = 'outlined' | 'filled';
|
|
7
|
+
export interface CVInputValueDetail {
|
|
8
|
+
value: string;
|
|
9
|
+
}
|
|
10
|
+
export type CVInputInputEvent = CustomEvent<CVInputValueDetail>;
|
|
11
|
+
export type CVInputChangeEvent = CustomEvent<CVInputValueDetail>;
|
|
12
|
+
export type CVInputClearEvent = CustomEvent<Record<string, never>>;
|
|
13
|
+
export type CVInputFocusEvent = CustomEvent<Record<string, never>>;
|
|
14
|
+
export type CVInputBlurEvent = CustomEvent<Record<string, never>>;
|
|
15
|
+
export interface CVInputEventMap {
|
|
16
|
+
'cv-input': CVInputInputEvent;
|
|
17
|
+
'cv-change': CVInputChangeEvent;
|
|
18
|
+
'cv-clear': CVInputClearEvent;
|
|
19
|
+
'cv-focus': CVInputFocusEvent;
|
|
20
|
+
'cv-blur': CVInputBlurEvent;
|
|
21
|
+
}
|
|
22
|
+
export declare class CVInput extends FormAssociatedReatomElement {
|
|
23
|
+
static elementName: string;
|
|
24
|
+
static hostDisplay: "inline-block";
|
|
25
|
+
static get properties(): {
|
|
26
|
+
value: {
|
|
27
|
+
type: StringConstructor;
|
|
28
|
+
};
|
|
29
|
+
type: {
|
|
30
|
+
type: StringConstructor;
|
|
31
|
+
};
|
|
32
|
+
placeholder: {
|
|
33
|
+
type: StringConstructor;
|
|
34
|
+
};
|
|
35
|
+
disabled: {
|
|
36
|
+
type: BooleanConstructor;
|
|
37
|
+
reflect: boolean;
|
|
38
|
+
};
|
|
39
|
+
readonly: {
|
|
40
|
+
type: BooleanConstructor;
|
|
41
|
+
reflect: boolean;
|
|
42
|
+
};
|
|
43
|
+
required: {
|
|
44
|
+
type: BooleanConstructor;
|
|
45
|
+
reflect: boolean;
|
|
46
|
+
};
|
|
47
|
+
clearable: {
|
|
48
|
+
type: BooleanConstructor;
|
|
49
|
+
reflect: boolean;
|
|
50
|
+
};
|
|
51
|
+
passwordToggle: {
|
|
52
|
+
type: BooleanConstructor;
|
|
53
|
+
reflect: boolean;
|
|
54
|
+
attribute: string;
|
|
55
|
+
};
|
|
56
|
+
size: {
|
|
57
|
+
type: StringConstructor;
|
|
58
|
+
reflect: boolean;
|
|
59
|
+
};
|
|
60
|
+
variant: {
|
|
61
|
+
type: StringConstructor;
|
|
62
|
+
reflect: boolean;
|
|
63
|
+
};
|
|
64
|
+
name: {
|
|
65
|
+
type: StringConstructor;
|
|
66
|
+
};
|
|
67
|
+
autofocus: {
|
|
68
|
+
type: BooleanConstructor;
|
|
69
|
+
reflect: boolean;
|
|
70
|
+
};
|
|
71
|
+
autocomplete: {
|
|
72
|
+
type: StringConstructor;
|
|
73
|
+
};
|
|
74
|
+
maxlength: {
|
|
75
|
+
type: NumberConstructor;
|
|
76
|
+
};
|
|
77
|
+
invalid: {
|
|
78
|
+
type: BooleanConstructor;
|
|
79
|
+
reflect: boolean;
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
value: string;
|
|
83
|
+
type: InputType;
|
|
84
|
+
placeholder: string;
|
|
85
|
+
disabled: boolean;
|
|
86
|
+
readonly: boolean;
|
|
87
|
+
required: boolean;
|
|
88
|
+
clearable: boolean;
|
|
89
|
+
passwordToggle: boolean;
|
|
90
|
+
size: CVInputSize;
|
|
91
|
+
variant: CVInputVariant;
|
|
92
|
+
name: string;
|
|
93
|
+
autofocus: boolean;
|
|
94
|
+
autocomplete: string;
|
|
95
|
+
maxlength: number | undefined;
|
|
96
|
+
invalid: boolean;
|
|
97
|
+
private model;
|
|
98
|
+
private _valueOnFocus;
|
|
99
|
+
private defaultValue;
|
|
100
|
+
private didCaptureDefaultValue;
|
|
101
|
+
private didAutoFocus;
|
|
102
|
+
constructor();
|
|
103
|
+
static styles: import("lit").CSSResult[];
|
|
104
|
+
static define(): void;
|
|
105
|
+
connectedCallback(): void;
|
|
106
|
+
updated(changedProperties: PropertyValues): void;
|
|
107
|
+
willUpdate(changedProperties: PropertyValues): void;
|
|
108
|
+
protected onFormDisabledChanged(_disabled: boolean): void;
|
|
109
|
+
protected onFormReset(): void;
|
|
110
|
+
protected onFormStateRestore(state: string | File | FormData | null): void;
|
|
111
|
+
focus(options?: FocusOptions): void;
|
|
112
|
+
select(): void;
|
|
113
|
+
private createModel;
|
|
114
|
+
private isEffectivelyDisabled;
|
|
115
|
+
protected isFormAssociatedDisabled(): boolean;
|
|
116
|
+
protected getFormAssociatedValue(): string | File | FormData | null;
|
|
117
|
+
protected getFormAssociatedValidity(): FormAssociatedValidity;
|
|
118
|
+
private scheduleAutofocus;
|
|
119
|
+
private handleNativeInput;
|
|
120
|
+
private handleNativeFocus;
|
|
121
|
+
private handleNativeBlur;
|
|
122
|
+
private handleNativeKeyDown;
|
|
123
|
+
private handleClearClick;
|
|
124
|
+
private handlePasswordToggleClick;
|
|
125
|
+
protected render(): import("lit").TemplateResult<1>;
|
|
126
|
+
}
|
|
127
|
+
export {};
|