@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,274 @@
|
|
|
1
|
+
import { createCheckbox } from '@chromvoid/headless-ui/checkbox';
|
|
2
|
+
import { css, html, nothing } from 'lit';
|
|
3
|
+
import { FormAssociatedReatomElement } from '../form-associated/FormAssociatedReatomElement.js';
|
|
4
|
+
let cvCheckboxNonce = 0;
|
|
5
|
+
export class CVCheckbox extends FormAssociatedReatomElement {
|
|
6
|
+
static elementName = 'cv-checkbox';
|
|
7
|
+
static forwardedHostAttributes = [
|
|
8
|
+
'tabindex',
|
|
9
|
+
'aria-label',
|
|
10
|
+
'aria-labelledby',
|
|
11
|
+
'aria-describedby',
|
|
12
|
+
];
|
|
13
|
+
static get properties() {
|
|
14
|
+
return {
|
|
15
|
+
name: { type: String },
|
|
16
|
+
value: { type: String },
|
|
17
|
+
checked: { type: Boolean, reflect: true },
|
|
18
|
+
indeterminate: { type: Boolean, reflect: true },
|
|
19
|
+
disabled: { type: Boolean, reflect: true },
|
|
20
|
+
readOnly: { type: Boolean, attribute: 'read-only', reflect: true },
|
|
21
|
+
required: { type: Boolean, reflect: true },
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
static get observedAttributes() {
|
|
25
|
+
return [...new Set([...super.observedAttributes, ...this.forwardedHostAttributes])];
|
|
26
|
+
}
|
|
27
|
+
idBase = `cv-checkbox-${++cvCheckboxNonce}`;
|
|
28
|
+
model;
|
|
29
|
+
defaultChecked = false;
|
|
30
|
+
defaultIndeterminate = false;
|
|
31
|
+
didCaptureDefaultState = false;
|
|
32
|
+
constructor() {
|
|
33
|
+
super();
|
|
34
|
+
this.name = '';
|
|
35
|
+
this.value = 'on';
|
|
36
|
+
this.checked = false;
|
|
37
|
+
this.indeterminate = false;
|
|
38
|
+
this.disabled = false;
|
|
39
|
+
this.readOnly = false;
|
|
40
|
+
this.required = false;
|
|
41
|
+
this.model = this.createModel();
|
|
42
|
+
}
|
|
43
|
+
get mixed() {
|
|
44
|
+
return this.indeterminate;
|
|
45
|
+
}
|
|
46
|
+
set mixed(value) {
|
|
47
|
+
this.indeterminate = value;
|
|
48
|
+
}
|
|
49
|
+
static styles = [
|
|
50
|
+
css `
|
|
51
|
+
:host {
|
|
52
|
+
display: inline-block;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
[part='base'] {
|
|
56
|
+
display: inline-flex;
|
|
57
|
+
align-items: center;
|
|
58
|
+
gap: var(--cv-space-2, 8px);
|
|
59
|
+
cursor: pointer;
|
|
60
|
+
user-select: none;
|
|
61
|
+
color: var(--cv-color-text, #e8ecf6);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
[part='indicator'] {
|
|
65
|
+
inline-size: 18px;
|
|
66
|
+
block-size: 18px;
|
|
67
|
+
display: inline-flex;
|
|
68
|
+
align-items: center;
|
|
69
|
+
justify-content: center;
|
|
70
|
+
border-radius: var(--cv-radius-sm, 6px);
|
|
71
|
+
border: 1px solid var(--cv-color-border, #2a3245);
|
|
72
|
+
background: var(--cv-color-surface, #141923);
|
|
73
|
+
transition:
|
|
74
|
+
border-color var(--cv-duration-fast, 120ms) var(--cv-easing-standard, ease),
|
|
75
|
+
background var(--cv-duration-fast, 120ms) var(--cv-easing-standard, ease);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
[part='checkmark'] {
|
|
79
|
+
inline-size: 10px;
|
|
80
|
+
block-size: 10px;
|
|
81
|
+
border-radius: 2px;
|
|
82
|
+
background: transparent;
|
|
83
|
+
transition: background var(--cv-duration-fast, 120ms) var(--cv-easing-standard, ease);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
:host([checked]) [part='indicator'] {
|
|
87
|
+
border-color: var(--cv-color-primary, #65d7ff);
|
|
88
|
+
background: color-mix(
|
|
89
|
+
in oklab,
|
|
90
|
+
var(--cv-color-primary, #65d7ff) 24%,
|
|
91
|
+
var(--cv-color-surface, #141923)
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
:host([checked]) [part='checkmark'] {
|
|
96
|
+
background: var(--cv-color-primary, #65d7ff);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
:host([indeterminate]) [part='checkmark'] {
|
|
100
|
+
inline-size: 10px;
|
|
101
|
+
block-size: 2px;
|
|
102
|
+
border-radius: 999px;
|
|
103
|
+
background: var(--cv-color-primary, #65d7ff);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
[part='base']:focus-visible {
|
|
107
|
+
outline: 2px solid var(--cv-color-primary, #65d7ff);
|
|
108
|
+
outline-offset: 2px;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
:host([disabled]) [part='base'] {
|
|
112
|
+
opacity: 0.55;
|
|
113
|
+
cursor: not-allowed;
|
|
114
|
+
}
|
|
115
|
+
`,
|
|
116
|
+
];
|
|
117
|
+
static define() {
|
|
118
|
+
if (!customElements.get(this.elementName)) {
|
|
119
|
+
customElements.define(this.elementName, this);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
connectedCallback() {
|
|
123
|
+
super.connectedCallback();
|
|
124
|
+
if (!this.didCaptureDefaultState) {
|
|
125
|
+
this.defaultChecked = this.checked;
|
|
126
|
+
this.defaultIndeterminate = this.indeterminate;
|
|
127
|
+
this.didCaptureDefaultState = true;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
131
|
+
super.attributeChangedCallback(name, oldValue, newValue);
|
|
132
|
+
if (oldValue === newValue)
|
|
133
|
+
return;
|
|
134
|
+
if (!CVCheckbox.forwardedHostAttributes.includes(name))
|
|
135
|
+
return;
|
|
136
|
+
this.requestUpdate();
|
|
137
|
+
}
|
|
138
|
+
willUpdate(changedProperties) {
|
|
139
|
+
super.willUpdate(changedProperties);
|
|
140
|
+
if (changedProperties.has('disabled')) {
|
|
141
|
+
this.model.actions.setDisabled(this.isEffectivelyDisabled());
|
|
142
|
+
}
|
|
143
|
+
if (changedProperties.has('readOnly')) {
|
|
144
|
+
this.model.actions.setReadOnly(this.readOnly);
|
|
145
|
+
}
|
|
146
|
+
if (changedProperties.has('checked') || changedProperties.has('indeterminate')) {
|
|
147
|
+
const nextValue = this.indeterminate ? 'mixed' : this.checked;
|
|
148
|
+
if (this.model.state.checked() !== nextValue) {
|
|
149
|
+
this.model.actions.setChecked(nextValue);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
if (changedProperties.has('checked') ||
|
|
153
|
+
changedProperties.has('indeterminate') ||
|
|
154
|
+
changedProperties.has('disabled') ||
|
|
155
|
+
changedProperties.has('required') ||
|
|
156
|
+
changedProperties.has('name') ||
|
|
157
|
+
changedProperties.has('value')) {
|
|
158
|
+
this.syncFormAssociatedState();
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
createModel() {
|
|
162
|
+
return createCheckbox({
|
|
163
|
+
idBase: this.idBase,
|
|
164
|
+
allowMixed: true,
|
|
165
|
+
checked: this.indeterminate ? 'mixed' : this.checked,
|
|
166
|
+
isDisabled: this.isEffectivelyDisabled(),
|
|
167
|
+
isReadOnly: this.readOnly,
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
onFormDisabledChanged(_disabled) {
|
|
171
|
+
this.model.actions.setDisabled(this.isEffectivelyDisabled());
|
|
172
|
+
}
|
|
173
|
+
onFormReset() {
|
|
174
|
+
const nextValue = this.defaultIndeterminate ? 'mixed' : this.defaultChecked;
|
|
175
|
+
this.checked = this.defaultChecked;
|
|
176
|
+
this.indeterminate = this.defaultIndeterminate;
|
|
177
|
+
this.model.actions.setChecked(nextValue);
|
|
178
|
+
}
|
|
179
|
+
onFormStateRestore(state) {
|
|
180
|
+
const isChecked = typeof state === 'string';
|
|
181
|
+
this.checked = isChecked;
|
|
182
|
+
this.indeterminate = false;
|
|
183
|
+
this.model.actions.setChecked(isChecked);
|
|
184
|
+
}
|
|
185
|
+
isFormAssociatedDisabled() {
|
|
186
|
+
return this.isEffectivelyDisabled();
|
|
187
|
+
}
|
|
188
|
+
getFormAssociatedValue() {
|
|
189
|
+
if (!this.checked || this.indeterminate) {
|
|
190
|
+
return null;
|
|
191
|
+
}
|
|
192
|
+
return this.value || 'on';
|
|
193
|
+
}
|
|
194
|
+
getFormAssociatedValidity() {
|
|
195
|
+
if (this.required && (!this.checked || this.indeterminate)) {
|
|
196
|
+
return {
|
|
197
|
+
flags: { valueMissing: true },
|
|
198
|
+
message: 'Please check this box.',
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
return { flags: {} };
|
|
202
|
+
}
|
|
203
|
+
isEffectivelyDisabled() {
|
|
204
|
+
return this.disabled || this.formDisabled;
|
|
205
|
+
}
|
|
206
|
+
dispatchCheckboxEvent(name, detail) {
|
|
207
|
+
this.dispatchEvent(new CustomEvent(name, {
|
|
208
|
+
detail,
|
|
209
|
+
bubbles: true,
|
|
210
|
+
composed: true,
|
|
211
|
+
}));
|
|
212
|
+
}
|
|
213
|
+
dispatchInput(detail) {
|
|
214
|
+
this.dispatchCheckboxEvent('cv-input', detail);
|
|
215
|
+
}
|
|
216
|
+
dispatchChange(detail) {
|
|
217
|
+
this.dispatchCheckboxEvent('cv-change', detail);
|
|
218
|
+
}
|
|
219
|
+
syncFromModelAndEmit(previousValue) {
|
|
220
|
+
const nextValue = this.model.state.checked();
|
|
221
|
+
this.checked = nextValue === true;
|
|
222
|
+
this.indeterminate = nextValue === 'mixed';
|
|
223
|
+
this.syncFormAssociatedState();
|
|
224
|
+
if (previousValue === nextValue)
|
|
225
|
+
return;
|
|
226
|
+
const detail = {
|
|
227
|
+
value: nextValue,
|
|
228
|
+
checked: nextValue === true,
|
|
229
|
+
indeterminate: nextValue === 'mixed',
|
|
230
|
+
};
|
|
231
|
+
this.dispatchInput(detail);
|
|
232
|
+
this.dispatchChange(detail);
|
|
233
|
+
}
|
|
234
|
+
handleClick() {
|
|
235
|
+
const previousValue = this.model.state.checked();
|
|
236
|
+
this.model.contracts.getCheckboxProps().onClick();
|
|
237
|
+
this.syncFromModelAndEmit(previousValue);
|
|
238
|
+
}
|
|
239
|
+
handleKeyDown(event) {
|
|
240
|
+
const previousValue = this.model.state.checked();
|
|
241
|
+
this.model.contracts.getCheckboxProps().onKeyDown(event);
|
|
242
|
+
this.syncFromModelAndEmit(previousValue);
|
|
243
|
+
}
|
|
244
|
+
render() {
|
|
245
|
+
const props = this.model.contracts.getCheckboxProps();
|
|
246
|
+
const hostTabIndex = this.getAttribute('tabindex');
|
|
247
|
+
const hostAriaLabel = this.getAttribute('aria-label');
|
|
248
|
+
const hostAriaLabelledBy = this.getAttribute('aria-labelledby');
|
|
249
|
+
const hostAriaDescribedBy = this.getAttribute('aria-describedby');
|
|
250
|
+
const tabIndex = this.isEffectivelyDisabled() ? '-1' : (hostTabIndex ?? props.tabindex);
|
|
251
|
+
return html `
|
|
252
|
+
<div
|
|
253
|
+
id=${props.id}
|
|
254
|
+
role=${props.role}
|
|
255
|
+
tabindex=${tabIndex}
|
|
256
|
+
aria-checked=${props['aria-checked']}
|
|
257
|
+
aria-label=${hostAriaLabel ?? nothing}
|
|
258
|
+
aria-disabled=${props['aria-disabled'] ?? nothing}
|
|
259
|
+
aria-readonly=${props['aria-readonly'] ?? nothing}
|
|
260
|
+
aria-required=${this.required ? 'true' : nothing}
|
|
261
|
+
aria-labelledby=${hostAriaLabelledBy ?? props['aria-labelledby'] ?? nothing}
|
|
262
|
+
aria-describedby=${hostAriaDescribedBy ?? props['aria-describedby'] ?? nothing}
|
|
263
|
+
part="base"
|
|
264
|
+
@click=${this.handleClick}
|
|
265
|
+
@keydown=${this.handleKeyDown}
|
|
266
|
+
>
|
|
267
|
+
<span part="indicator">
|
|
268
|
+
<span part="checkmark"></span>
|
|
269
|
+
</span>
|
|
270
|
+
<slot></slot>
|
|
271
|
+
</div>
|
|
272
|
+
`;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
export declare class CVComboboxGroup extends LitElement {
|
|
3
|
+
static elementName: string;
|
|
4
|
+
static get properties(): {
|
|
5
|
+
label: {
|
|
6
|
+
type: StringConstructor;
|
|
7
|
+
reflect: boolean;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
label: string;
|
|
11
|
+
constructor();
|
|
12
|
+
static styles: import("lit").CSSResult[];
|
|
13
|
+
static define(): void;
|
|
14
|
+
protected render(): import("lit").TemplateResult<1>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { LitElement, css, html } from 'lit';
|
|
2
|
+
export class CVComboboxGroup extends LitElement {
|
|
3
|
+
static elementName = 'cv-combobox-group';
|
|
4
|
+
static get properties() {
|
|
5
|
+
return {
|
|
6
|
+
label: { type: String, reflect: true },
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
constructor() {
|
|
10
|
+
super();
|
|
11
|
+
this.label = '';
|
|
12
|
+
}
|
|
13
|
+
static styles = [
|
|
14
|
+
css `
|
|
15
|
+
:host {
|
|
16
|
+
display: block;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
:host([hidden]) {
|
|
20
|
+
display: none;
|
|
21
|
+
}
|
|
22
|
+
`,
|
|
23
|
+
];
|
|
24
|
+
static define() {
|
|
25
|
+
if (!customElements.get(this.elementName)) {
|
|
26
|
+
customElements.define(this.elementName, this);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
render() {
|
|
30
|
+
return html `
|
|
31
|
+
<slot></slot>
|
|
32
|
+
`;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
export declare class CVComboboxOption extends LitElement {
|
|
3
|
+
static elementName: string;
|
|
4
|
+
static get properties(): {
|
|
5
|
+
value: {
|
|
6
|
+
type: StringConstructor;
|
|
7
|
+
reflect: boolean;
|
|
8
|
+
};
|
|
9
|
+
disabled: {
|
|
10
|
+
type: BooleanConstructor;
|
|
11
|
+
reflect: boolean;
|
|
12
|
+
};
|
|
13
|
+
selected: {
|
|
14
|
+
type: BooleanConstructor;
|
|
15
|
+
reflect: boolean;
|
|
16
|
+
};
|
|
17
|
+
active: {
|
|
18
|
+
type: BooleanConstructor;
|
|
19
|
+
reflect: boolean;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
value: string;
|
|
23
|
+
disabled: boolean;
|
|
24
|
+
selected: boolean;
|
|
25
|
+
active: boolean;
|
|
26
|
+
constructor();
|
|
27
|
+
static styles: import("lit").CSSResultOrNative[];
|
|
28
|
+
static define(): void;
|
|
29
|
+
protected render(): import("lit").TemplateResult<1>;
|
|
30
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { LitElement, css, html } from 'lit';
|
|
2
|
+
import { componentResetStyles, getComponentHostDisplayStyles } from '../styles/component-styles.js';
|
|
3
|
+
export class CVComboboxOption extends LitElement {
|
|
4
|
+
static elementName = 'cv-combobox-option';
|
|
5
|
+
static get properties() {
|
|
6
|
+
return {
|
|
7
|
+
value: { type: String, reflect: true },
|
|
8
|
+
disabled: { type: Boolean, reflect: true },
|
|
9
|
+
selected: { type: Boolean, reflect: true },
|
|
10
|
+
active: { type: Boolean, reflect: true },
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
constructor() {
|
|
14
|
+
super();
|
|
15
|
+
this.value = '';
|
|
16
|
+
this.disabled = false;
|
|
17
|
+
this.selected = false;
|
|
18
|
+
this.active = false;
|
|
19
|
+
}
|
|
20
|
+
static styles = [
|
|
21
|
+
componentResetStyles,
|
|
22
|
+
getComponentHostDisplayStyles('block'),
|
|
23
|
+
css `
|
|
24
|
+
:host {
|
|
25
|
+
outline: none;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.option {
|
|
29
|
+
padding: var(--cv-space-2, 8px) var(--cv-space-3, 12px);
|
|
30
|
+
border-radius: var(--cv-radius-sm, 6px);
|
|
31
|
+
color: var(--cv-color-text, #e8ecf6);
|
|
32
|
+
background: transparent;
|
|
33
|
+
transition:
|
|
34
|
+
background var(--cv-duration-fast, 120ms) var(--cv-easing-standard, ease),
|
|
35
|
+
color var(--cv-duration-fast, 120ms) var(--cv-easing-standard, ease);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
:host([active]) .option {
|
|
39
|
+
background: color-mix(in oklab, var(--cv-color-primary, #65d7ff) 24%, transparent);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
:host([selected]) .option {
|
|
43
|
+
background: color-mix(in oklab, var(--cv-color-primary, #65d7ff) 32%, transparent);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
:host([disabled]) .option {
|
|
47
|
+
opacity: 0.5;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
:host(:focus-visible) .option {
|
|
51
|
+
outline: 2px solid var(--cv-color-primary, #65d7ff);
|
|
52
|
+
outline-offset: 1px;
|
|
53
|
+
}
|
|
54
|
+
`,
|
|
55
|
+
];
|
|
56
|
+
static define() {
|
|
57
|
+
if (!customElements.get(this.elementName)) {
|
|
58
|
+
customElements.define(this.elementName, this);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
render() {
|
|
62
|
+
return html `
|
|
63
|
+
<div class="option cv-u-row" part="base"><slot></slot></div>
|
|
64
|
+
`;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { type ComboboxMatchMode, type ComboboxType } from '@chromvoid/headless-ui/combobox';
|
|
2
|
+
import type { PropertyValues } from 'lit';
|
|
3
|
+
import { ReatomLitElement } from '../reatom-lit/ReatomLitElement.js';
|
|
4
|
+
export interface CVComboboxEventDetail {
|
|
5
|
+
value: string | null;
|
|
6
|
+
inputValue: string;
|
|
7
|
+
activeId: string | null;
|
|
8
|
+
open: boolean;
|
|
9
|
+
selectedIds: string[];
|
|
10
|
+
}
|
|
11
|
+
export type CVComboboxInputEvent = CustomEvent<CVComboboxEventDetail>;
|
|
12
|
+
export type CVComboboxChangeEvent = CustomEvent<CVComboboxEventDetail>;
|
|
13
|
+
export type CVComboboxClearEvent = CustomEvent<Record<string, never>>;
|
|
14
|
+
export interface CVComboboxEventMap {
|
|
15
|
+
'cv-input': CVComboboxInputEvent;
|
|
16
|
+
'cv-change': CVComboboxChangeEvent;
|
|
17
|
+
'cv-clear': CVComboboxClearEvent;
|
|
18
|
+
}
|
|
19
|
+
export declare class CVCombobox extends ReatomLitElement {
|
|
20
|
+
static elementName: string;
|
|
21
|
+
static hostDisplay: "inline-block";
|
|
22
|
+
static get properties(): {
|
|
23
|
+
value: {
|
|
24
|
+
type: StringConstructor;
|
|
25
|
+
reflect: boolean;
|
|
26
|
+
};
|
|
27
|
+
inputValue: {
|
|
28
|
+
type: StringConstructor;
|
|
29
|
+
attribute: string;
|
|
30
|
+
};
|
|
31
|
+
open: {
|
|
32
|
+
type: BooleanConstructor;
|
|
33
|
+
reflect: boolean;
|
|
34
|
+
};
|
|
35
|
+
type: {
|
|
36
|
+
type: StringConstructor;
|
|
37
|
+
reflect: boolean;
|
|
38
|
+
};
|
|
39
|
+
multiple: {
|
|
40
|
+
type: BooleanConstructor;
|
|
41
|
+
reflect: boolean;
|
|
42
|
+
};
|
|
43
|
+
clearable: {
|
|
44
|
+
type: BooleanConstructor;
|
|
45
|
+
reflect: boolean;
|
|
46
|
+
};
|
|
47
|
+
maxTagsVisible: {
|
|
48
|
+
type: NumberConstructor;
|
|
49
|
+
attribute: string;
|
|
50
|
+
};
|
|
51
|
+
openOnFocus: {
|
|
52
|
+
type: BooleanConstructor;
|
|
53
|
+
attribute: string;
|
|
54
|
+
reflect: boolean;
|
|
55
|
+
};
|
|
56
|
+
openOnClick: {
|
|
57
|
+
type: BooleanConstructor;
|
|
58
|
+
attribute: string;
|
|
59
|
+
reflect: boolean;
|
|
60
|
+
};
|
|
61
|
+
closeOnSelect: {
|
|
62
|
+
type: BooleanConstructor;
|
|
63
|
+
attribute: string;
|
|
64
|
+
reflect: boolean;
|
|
65
|
+
};
|
|
66
|
+
matchMode: {
|
|
67
|
+
type: StringConstructor;
|
|
68
|
+
attribute: string;
|
|
69
|
+
reflect: boolean;
|
|
70
|
+
};
|
|
71
|
+
placeholder: {
|
|
72
|
+
type: StringConstructor;
|
|
73
|
+
};
|
|
74
|
+
ariaLabel: {
|
|
75
|
+
type: StringConstructor;
|
|
76
|
+
attribute: string;
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
value: string;
|
|
80
|
+
inputValue: string;
|
|
81
|
+
open: boolean;
|
|
82
|
+
type: ComboboxType;
|
|
83
|
+
multiple: boolean;
|
|
84
|
+
clearable: boolean;
|
|
85
|
+
maxTagsVisible: number;
|
|
86
|
+
openOnFocus: boolean;
|
|
87
|
+
openOnClick: boolean;
|
|
88
|
+
closeOnSelect: boolean;
|
|
89
|
+
matchMode: ComboboxMatchMode;
|
|
90
|
+
placeholder: string;
|
|
91
|
+
ariaLabel: string;
|
|
92
|
+
private readonly idBase;
|
|
93
|
+
private optionRecords;
|
|
94
|
+
private groupRecords;
|
|
95
|
+
private optionListeners;
|
|
96
|
+
private model?;
|
|
97
|
+
constructor();
|
|
98
|
+
static styles: import("lit").CSSResult[];
|
|
99
|
+
static define(): void;
|
|
100
|
+
connectedCallback(): void;
|
|
101
|
+
disconnectedCallback(): void;
|
|
102
|
+
willUpdate(changedProperties: PropertyValues): void;
|
|
103
|
+
updated(changedProperties: PropertyValues): void;
|
|
104
|
+
private getOptionElements;
|
|
105
|
+
private getGroupElements;
|
|
106
|
+
private ensureOptionValue;
|
|
107
|
+
private resolveInitialSelected;
|
|
108
|
+
private rebuildModelFromSlot;
|
|
109
|
+
private syncHostState;
|
|
110
|
+
private detachOptionListeners;
|
|
111
|
+
private attachOptionListeners;
|
|
112
|
+
private syncOptionElements;
|
|
113
|
+
private captureState;
|
|
114
|
+
private makeEventDetail;
|
|
115
|
+
private dispatchInput;
|
|
116
|
+
private dispatchChange;
|
|
117
|
+
private applyInteractionResult;
|
|
118
|
+
private syncOutsidePointerListener;
|
|
119
|
+
private handleDocumentPointerDown;
|
|
120
|
+
private handleInputChange;
|
|
121
|
+
private handleInputFocus;
|
|
122
|
+
private handleInputClick;
|
|
123
|
+
private handleKeyDown;
|
|
124
|
+
private handleOptionMouseEnter;
|
|
125
|
+
private handleOptionClick;
|
|
126
|
+
private handleClearClick;
|
|
127
|
+
private handleTagRemove;
|
|
128
|
+
private handleSlotChange;
|
|
129
|
+
private getSelectedOptionLabel;
|
|
130
|
+
private getSelectedRecords;
|
|
131
|
+
private renderTags;
|
|
132
|
+
private renderClearButton;
|
|
133
|
+
private renderListboxContent;
|
|
134
|
+
protected render(): import("lit").TemplateResult<1>;
|
|
135
|
+
}
|