@joralvmel/cosmos-elements 0.2.0 → 0.3.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/README.md +10 -0
- package/dist/components/icon-button/cosm-icon-button.d.ts +79 -0
- package/dist/components/icon-button/cosm-icon-button.d.ts.map +1 -0
- package/dist/components/icon-button/cosm-icon-button.js +206 -0
- package/dist/components/icon-button/cosm-icon-button.js.map +1 -0
- package/dist/components/listbox/cosm-listbox.d.ts +140 -0
- package/dist/components/listbox/cosm-listbox.d.ts.map +1 -0
- package/dist/components/listbox/cosm-listbox.js +580 -0
- package/dist/components/listbox/cosm-listbox.js.map +1 -0
- package/dist/components/popover/cosm-popover.d.ts +122 -0
- package/dist/components/popover/cosm-popover.d.ts.map +1 -0
- package/dist/components/popover/cosm-popover.js +809 -0
- package/dist/components/popover/cosm-popover.js.map +1 -0
- package/dist/components/text-field/cosm-text-field.d.ts +203 -0
- package/dist/components/text-field/cosm-text-field.d.ts.map +1 -0
- package/dist/components/text-field/cosm-text-field.js +679 -0
- package/dist/components/text-field/cosm-text-field.js.map +1 -0
- package/dist/custom-elements.json +2942 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/llms.md +162 -0
- package/package.json +18 -2
package/README.md
CHANGED
|
@@ -23,9 +23,19 @@ import '@joralvmel/cosmos-elements/button';
|
|
|
23
23
|
| Element | Import | Description |
|
|
24
24
|
| --------------- | ----------------------------------- | ---------------------------------- |
|
|
25
25
|
| `<cosm-button>` | `@joralvmel/cosmos-elements/button` | Action or form submit/reset button |
|
|
26
|
+
| `<cosm-text-field>` | `@joralvmel/cosmos-elements/text-field` | Labeled single-line entry with browser form validation |
|
|
26
27
|
|
|
27
28
|
The Custom Elements Manifest is published as `@joralvmel/cosmos-elements/custom-elements.json`.
|
|
28
29
|
|
|
30
|
+
Text-field start/end icons support independent `--cosm-text-field-start-icon-color` and
|
|
31
|
+
`--cosm-text-field-end-icon-color` hooks, with optional `-focus-color` equivalents replacing
|
|
32
|
+
`-color`. `icon-focus-scope="control"` (default) includes the input and action buttons;
|
|
33
|
+
`"input"` limits those focus colors to the editable input. Unset hooks preserve existing colors;
|
|
34
|
+
affixes and action icons are unaffected.
|
|
35
|
+
|
|
36
|
+
Text fields default to `20ch` wide, capped at the container width. Set CSS `width` to fit your
|
|
37
|
+
layout. Clear/reveal actions and decorations take space inside the field without changing its width.
|
|
38
|
+
|
|
29
39
|
## License
|
|
30
40
|
|
|
31
41
|
MIT
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { type ContractProps, type IconButtonPressedChangeDetail, iconButtonContract } from '@joralvmel/cosmos-core';
|
|
2
|
+
import { CosmElement } from '../../internal/cosm-element.js';
|
|
3
|
+
type Props = Required<ContractProps<typeof iconButtonContract, 'web'>>;
|
|
4
|
+
/**
|
|
5
|
+
* Labeled icon-only action or toggle.
|
|
6
|
+
* @tag cosm-icon-button
|
|
7
|
+
* @slot - Decorative icon.
|
|
8
|
+
* @csspart base - Native button.
|
|
9
|
+
* @fires {CustomEvent<IconButtonPressDetail>} cosm-press - Activation.
|
|
10
|
+
* @fires {CustomEvent<IconButtonPressedChangeDetail>} cosm-pressed-change - Proposed toggle state.
|
|
11
|
+
* @cssprop --cosm-icon-button-background - Background.
|
|
12
|
+
* @cssprop --cosm-icon-button-color - Icon color.
|
|
13
|
+
* @cssprop --cosm-icon-button-border - Border color.
|
|
14
|
+
* @cssprop --cosm-icon-button-radius - Corner radius.
|
|
15
|
+
* @cssprop --cosm-icon-button-focus - Focus indicator color.
|
|
16
|
+
*/
|
|
17
|
+
export declare class CosmIconButton extends CosmElement {
|
|
18
|
+
#private;
|
|
19
|
+
static formAssociated: boolean;
|
|
20
|
+
static shadowRootOptions: ShadowRootInit;
|
|
21
|
+
static properties: {
|
|
22
|
+
label: {};
|
|
23
|
+
mode: {
|
|
24
|
+
reflect: boolean;
|
|
25
|
+
};
|
|
26
|
+
variant: {
|
|
27
|
+
reflect: boolean;
|
|
28
|
+
};
|
|
29
|
+
tone: {
|
|
30
|
+
reflect: boolean;
|
|
31
|
+
};
|
|
32
|
+
size: {
|
|
33
|
+
reflect: boolean;
|
|
34
|
+
};
|
|
35
|
+
disabled: {
|
|
36
|
+
type: BooleanConstructor;
|
|
37
|
+
reflect: boolean;
|
|
38
|
+
};
|
|
39
|
+
type: {};
|
|
40
|
+
pressed: {
|
|
41
|
+
type: BooleanConstructor;
|
|
42
|
+
noAccessor: boolean;
|
|
43
|
+
};
|
|
44
|
+
defaultPressed: {
|
|
45
|
+
type: BooleanConstructor;
|
|
46
|
+
attribute: string;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
static styles: import("lit").CSSResult[];
|
|
50
|
+
label: string;
|
|
51
|
+
mode: Props['mode'];
|
|
52
|
+
variant: Props['variant'];
|
|
53
|
+
tone: Props['tone'];
|
|
54
|
+
size: Props['size'];
|
|
55
|
+
disabled: boolean;
|
|
56
|
+
type: Props['type'];
|
|
57
|
+
defaultPressed: boolean;
|
|
58
|
+
/** Adapters set ownership when a pressed binding is present. */
|
|
59
|
+
pressedControlled: boolean;
|
|
60
|
+
constructor();
|
|
61
|
+
get pressed(): boolean;
|
|
62
|
+
set pressed(value: boolean | undefined);
|
|
63
|
+
get form(): HTMLFormElement | null;
|
|
64
|
+
attributeChangedCallback(name: string, old: string | null, value: string | null): void;
|
|
65
|
+
formDisabledCallback(disabled: boolean): void;
|
|
66
|
+
protected willUpdate(changed: Map<PropertyKey, unknown>): void;
|
|
67
|
+
click(): void;
|
|
68
|
+
protected render(): import("lit-html").TemplateResult<1>;
|
|
69
|
+
}
|
|
70
|
+
declare global {
|
|
71
|
+
interface HTMLElementTagNameMap {
|
|
72
|
+
'cosm-icon-button': CosmIconButton;
|
|
73
|
+
}
|
|
74
|
+
interface HTMLElementEventMap {
|
|
75
|
+
'cosm-pressed-change': CustomEvent<IconButtonPressedChangeDetail>;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
export {};
|
|
79
|
+
//# sourceMappingURL=cosm-icon-button.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cosm-icon-button.d.ts","sourceRoot":"","sources":["../../../src/components/icon-button/cosm-icon-button.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAElB,KAAK,6BAA6B,EAClC,kBAAkB,EAEnB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAI7D,KAAK,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,kBAAkB,EAAE,KAAK,CAAC,CAAC,CAAC;AAwEvE;;;;;;;;;;;;GAYG;AACH,qBAAa,cAAe,SAAQ,WAAW;;IAC7C,MAAM,CAAC,cAAc,UAAQ;IAC7B,OAAgB,iBAAiB,EAAE,cAAc,CAG/C;IACF,OAAgB,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;MAUxB;IACF,OAAgB,MAAM,4BAAuB;IAErC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACpB,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;IAC1B,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACpB,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACpB,QAAQ,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACpB,cAAc,EAAE,OAAO,CAAC;IAEhC,gEAAgE;IAChE,iBAAiB,UAAS;;IAsB1B,IAAI,OAAO,IAAI,OAAO,CAErB;IACD,IAAI,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,EAGrC;IAMD,IAAI,IAAI,IAAI,eAAe,GAAG,IAAI,CAEjC;IACQ,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAI/F,oBAAoB,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI;cAI1B,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,WAAW,EAAE,OAAO,CAAC,GAAG,IAAI;IAK9D,KAAK,IAAI,IAAI;cA+BH,MAAM;CAU1B;AAID,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,kBAAkB,EAAE,cAAc,CAAC;KACpC;IACD,UAAU,mBAAmB;QAC3B,qBAAqB,EAAE,WAAW,CAAC,6BAA6B,CAAC,CAAC;KACnE;CACF"}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { iconButtonContract, } from '@joralvmel/cosmos-core';
|
|
2
|
+
import { css, html, LitElement, nothing } from 'lit';
|
|
3
|
+
import { CosmElement } from '../../internal/cosm-element.js';
|
|
4
|
+
import { define } from '../../internal/define.js';
|
|
5
|
+
import { boxSizing } from '../../internal/styles.js';
|
|
6
|
+
const styles = css `
|
|
7
|
+
:host {
|
|
8
|
+
--_solid: var(--cosm-primary, oklch(0.55 0.2 268));
|
|
9
|
+
--_on-solid: var(--cosm-primary-fg, oklch(1 0 0));
|
|
10
|
+
--_subtle: var(--cosm-primary-subtle, oklch(0.945 0.048 268));
|
|
11
|
+
--_text: var(--cosm-primary-text, oklch(0.44 0.18 268));
|
|
12
|
+
--_size: var(--cosm-control-md, 2.5rem);
|
|
13
|
+
display: inline-flex;
|
|
14
|
+
vertical-align: middle;
|
|
15
|
+
}
|
|
16
|
+
:host([tone='neutral']) {
|
|
17
|
+
--_solid: var(--cosm-fg, oklch(0.24 0.01 268));
|
|
18
|
+
--_on-solid: var(--cosm-bg, oklch(0.985 0.007 268));
|
|
19
|
+
--_subtle: var(--cosm-neutral-3, oklch(0.945 0.01 268));
|
|
20
|
+
--_text: var(--cosm-fg, oklch(0.24 0.01 268));
|
|
21
|
+
}
|
|
22
|
+
:host([tone='danger']) {
|
|
23
|
+
--_solid: var(--cosm-danger, oklch(0.55 0.16 19));
|
|
24
|
+
--_on-solid: var(--cosm-danger-fg, oklch(1 0 0));
|
|
25
|
+
--_subtle: var(--cosm-danger-subtle, oklch(0.945 0.038 19));
|
|
26
|
+
--_text: var(--cosm-danger-text, oklch(0.44 0.144 19));
|
|
27
|
+
}
|
|
28
|
+
:host([size='sm']) { --_size: var(--cosm-control-sm, 2rem); }
|
|
29
|
+
:host([size='lg']) { --_size: var(--cosm-control-lg, 3rem); }
|
|
30
|
+
.base {
|
|
31
|
+
--_bg: var(--_solid);
|
|
32
|
+
--_fg: var(--_on-solid);
|
|
33
|
+
--_border: transparent;
|
|
34
|
+
display: inline-flex;
|
|
35
|
+
align-items: center;
|
|
36
|
+
justify-content: center;
|
|
37
|
+
width: var(--_size);
|
|
38
|
+
height: var(--_size);
|
|
39
|
+
padding: 0;
|
|
40
|
+
border: 1px solid var(--cosm-icon-button-border, var(--_border));
|
|
41
|
+
border-radius: var(--cosm-icon-button-radius, var(--cosm-radius-md, 0.5rem));
|
|
42
|
+
background: var(--cosm-icon-button-background, var(--_bg));
|
|
43
|
+
color: var(--cosm-icon-button-color, var(--_fg));
|
|
44
|
+
font: inherit;
|
|
45
|
+
cursor: pointer;
|
|
46
|
+
transition: background-color var(--cosm-duration-fast, 120ms) var(--cosm-easing-standard, ease);
|
|
47
|
+
}
|
|
48
|
+
.icon {
|
|
49
|
+
display: flex;
|
|
50
|
+
align-items: center;
|
|
51
|
+
justify-content: center;
|
|
52
|
+
}
|
|
53
|
+
:host([variant='soft']) .base { --_bg: var(--_subtle); --_fg: var(--_text); }
|
|
54
|
+
:host([variant='outline']) .base {
|
|
55
|
+
--_bg: transparent;
|
|
56
|
+
--_fg: var(--_text);
|
|
57
|
+
--_border: var(--cosm-border-strong, oklch(0.64 0.01 268));
|
|
58
|
+
}
|
|
59
|
+
:host([variant='ghost']) .base { --_bg: transparent; --_fg: var(--_text); }
|
|
60
|
+
.base:hover { --_bg: color-mix(in oklab, var(--_solid), var(--_on-solid) 14%); }
|
|
61
|
+
:host([variant='soft']) .base:hover,
|
|
62
|
+
:host([variant='outline']) .base:hover,
|
|
63
|
+
:host([variant='ghost']) .base:hover { --_bg: var(--_subtle); }
|
|
64
|
+
.base:active { filter: brightness(0.9); }
|
|
65
|
+
.base[aria-pressed='true'] {
|
|
66
|
+
box-shadow: inset 0 0 0 2px currentColor;
|
|
67
|
+
}
|
|
68
|
+
.base:focus-visible {
|
|
69
|
+
outline: 2px solid var(--cosm-icon-button-focus, var(--cosm-focus-ring, oklch(0.55 0.2 268)));
|
|
70
|
+
outline-offset: 2px;
|
|
71
|
+
}
|
|
72
|
+
.base:disabled { cursor: not-allowed; opacity: 0.5; }
|
|
73
|
+
@media (prefers-reduced-motion: reduce) { .base { transition: none; } }
|
|
74
|
+
`;
|
|
75
|
+
/**
|
|
76
|
+
* Labeled icon-only action or toggle.
|
|
77
|
+
* @tag cosm-icon-button
|
|
78
|
+
* @slot - Decorative icon.
|
|
79
|
+
* @csspart base - Native button.
|
|
80
|
+
* @fires {CustomEvent<IconButtonPressDetail>} cosm-press - Activation.
|
|
81
|
+
* @fires {CustomEvent<IconButtonPressedChangeDetail>} cosm-pressed-change - Proposed toggle state.
|
|
82
|
+
* @cssprop --cosm-icon-button-background - Background.
|
|
83
|
+
* @cssprop --cosm-icon-button-color - Icon color.
|
|
84
|
+
* @cssprop --cosm-icon-button-border - Border color.
|
|
85
|
+
* @cssprop --cosm-icon-button-radius - Corner radius.
|
|
86
|
+
* @cssprop --cosm-icon-button-focus - Focus indicator color.
|
|
87
|
+
*/
|
|
88
|
+
export class CosmIconButton extends CosmElement {
|
|
89
|
+
static formAssociated = true;
|
|
90
|
+
static shadowRootOptions = {
|
|
91
|
+
...LitElement.shadowRootOptions,
|
|
92
|
+
delegatesFocus: true,
|
|
93
|
+
};
|
|
94
|
+
static properties = {
|
|
95
|
+
label: {},
|
|
96
|
+
mode: { reflect: true },
|
|
97
|
+
variant: { reflect: true },
|
|
98
|
+
tone: { reflect: true },
|
|
99
|
+
size: { reflect: true },
|
|
100
|
+
disabled: { type: Boolean, reflect: true },
|
|
101
|
+
type: {},
|
|
102
|
+
pressed: { type: Boolean, noAccessor: true },
|
|
103
|
+
defaultPressed: { type: Boolean, attribute: 'default-pressed' },
|
|
104
|
+
};
|
|
105
|
+
static styles = [boxSizing, styles];
|
|
106
|
+
/** Adapters set ownership when a pressed binding is present. */
|
|
107
|
+
pressedControlled = false;
|
|
108
|
+
#pressed = false;
|
|
109
|
+
#edited = false;
|
|
110
|
+
#formDisabled = false;
|
|
111
|
+
#nextSource;
|
|
112
|
+
#internals;
|
|
113
|
+
constructor() {
|
|
114
|
+
super();
|
|
115
|
+
const props = iconButtonContract.props;
|
|
116
|
+
this.label = '';
|
|
117
|
+
this.mode = props.mode.default;
|
|
118
|
+
this.variant = props.variant.default;
|
|
119
|
+
this.tone = props.tone.default;
|
|
120
|
+
this.size = props.size.default;
|
|
121
|
+
this.disabled = props.disabled.default;
|
|
122
|
+
this.type = props.type.default;
|
|
123
|
+
this.defaultPressed = props.defaultPressed.default;
|
|
124
|
+
this.#internals =
|
|
125
|
+
typeof this.attachInternals === 'function' ? this.attachInternals() : undefined;
|
|
126
|
+
}
|
|
127
|
+
get pressed() {
|
|
128
|
+
return this.#pressed;
|
|
129
|
+
}
|
|
130
|
+
set pressed(value) {
|
|
131
|
+
this.pressedControlled = value !== undefined;
|
|
132
|
+
if (value !== undefined)
|
|
133
|
+
this.#setPressed(value);
|
|
134
|
+
}
|
|
135
|
+
#setPressed(value) {
|
|
136
|
+
const old = this.#pressed;
|
|
137
|
+
this.#pressed = value;
|
|
138
|
+
this.requestUpdate('pressed', old);
|
|
139
|
+
}
|
|
140
|
+
get form() {
|
|
141
|
+
return this.#internals?.form ?? this.closest('form');
|
|
142
|
+
}
|
|
143
|
+
attributeChangedCallback(name, old, value) {
|
|
144
|
+
super.attributeChangedCallback(name, old, value);
|
|
145
|
+
if (name === 'pressed' && value === null)
|
|
146
|
+
this.pressedControlled = false;
|
|
147
|
+
}
|
|
148
|
+
formDisabledCallback(disabled) {
|
|
149
|
+
this.#formDisabled = disabled;
|
|
150
|
+
this.requestUpdate();
|
|
151
|
+
}
|
|
152
|
+
willUpdate(changed) {
|
|
153
|
+
if (changed.has('defaultPressed') && !this.pressedControlled && !this.#edited) {
|
|
154
|
+
this.#setPressed(this.defaultPressed);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
click() {
|
|
158
|
+
const button = this.renderRoot.querySelector('button');
|
|
159
|
+
if (!button || button.disabled)
|
|
160
|
+
return;
|
|
161
|
+
this.#nextSource = 'programmatic';
|
|
162
|
+
button.click();
|
|
163
|
+
}
|
|
164
|
+
#onPointerDown = () => {
|
|
165
|
+
this.#nextSource = 'pointer';
|
|
166
|
+
};
|
|
167
|
+
#onKeyDown = (event) => {
|
|
168
|
+
if (event.key === 'Enter' || event.key === ' ')
|
|
169
|
+
this.#nextSource = 'keyboard';
|
|
170
|
+
};
|
|
171
|
+
#onClick = (event) => {
|
|
172
|
+
const source = this.#nextSource ?? (event.detail === 0 ? 'keyboard' : 'pointer');
|
|
173
|
+
this.#nextSource = undefined;
|
|
174
|
+
if (this.disabled || this.#formDisabled) {
|
|
175
|
+
event.preventDefault();
|
|
176
|
+
event.stopPropagation();
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
if (this.mode === 'toggle') {
|
|
180
|
+
const pressed = !this.#pressed;
|
|
181
|
+
this.#edited = true;
|
|
182
|
+
if (!this.pressedControlled)
|
|
183
|
+
this.#setPressed(pressed);
|
|
184
|
+
this.emit('cosm-pressed-change', { pressed });
|
|
185
|
+
}
|
|
186
|
+
const form = this.form;
|
|
187
|
+
if (form && this.type === 'submit')
|
|
188
|
+
form.requestSubmit();
|
|
189
|
+
if (form && this.type === 'reset')
|
|
190
|
+
form.reset();
|
|
191
|
+
this.emit('cosm-press', { source });
|
|
192
|
+
};
|
|
193
|
+
render() {
|
|
194
|
+
if (!this.label?.trim())
|
|
195
|
+
throw new Error('cosm-icon-button requires a non-empty label.');
|
|
196
|
+
return html `<button
|
|
197
|
+
part="base" class="base" type="button"
|
|
198
|
+
?disabled=${this.disabled || this.#formDisabled}
|
|
199
|
+
aria-label=${this.label}
|
|
200
|
+
aria-pressed=${this.mode === 'toggle' ? String(this.#pressed) : nothing}
|
|
201
|
+
@pointerdown=${this.#onPointerDown} @keydown=${this.#onKeyDown} @click=${this.#onClick}
|
|
202
|
+
><span class="icon" aria-hidden="true"><slot></slot></span></button>`;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
define('cosm-icon-button', CosmIconButton);
|
|
206
|
+
//# sourceMappingURL=cosm-icon-button.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cosm-icon-button.js","sourceRoot":"","sources":["../../../src/components/icon-button/cosm-icon-button.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,kBAAkB,GAEnB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAIrD,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoEjB,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,cAAe,SAAQ,WAAW;IAC7C,MAAM,CAAC,cAAc,GAAG,IAAI,CAAC;IAC7B,MAAM,CAAU,iBAAiB,GAAmB;QAClD,GAAG,UAAU,CAAC,iBAAiB;QAC/B,cAAc,EAAE,IAAI;KACrB,CAAC;IACF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B,IAAI,CAAC,IAAI,CAAC,iBAAiB;gBAAE,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;YACvD,IAAI,CAAC,IAAI,CAAgC,qBAAqB,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;QAC/E,CAAC;QACD,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACvB,IAAI,IAAI,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ;YAAE,IAAI,CAAC,aAAa,EAAE,CAAC;QACzD,IAAI,IAAI,IAAI,IAAI,CAAC,IAAI,KAAK,OAAO;YAAE,IAAI,CAAC,KAAK,EAAE,CAAC;QAChD,IAAI,CAAC,IAAI,CAAwB,YAAY,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;IAC7D,CAAC,CAAC;IACiB,MAAM;QACvB,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE;YAAE,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;QACzF,OAAO,IAAI,CAAA;;kBAEG,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,aAAa;mBAClC,IAAI,CAAC,KAAK;qBACR,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,OAAO;qBACxD,IAAI,CAAC,cAAc,aAAa,IAAI,CAAC,UAAU,WAAW,IAAI,CAAC,QAAQ;yEACnB,CAAC;IACxE,CAAC;;AAGH,MAAM,CAAC,kBAAkB,EAAE,cAAc,CAAC,CAAC"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { type ContractProps, type ListboxItem, type ListboxSelectionChangeDetail, listboxContract } from '@joralvmel/cosmos-core';
|
|
2
|
+
import { type IconDefinition } from '@joralvmel/cosmos-icons';
|
|
3
|
+
import { CosmElement } from '../../internal/cosm-element.js';
|
|
4
|
+
import '../icon/cosm-icon.js';
|
|
5
|
+
type Props = ContractProps<typeof listboxContract, 'web', {
|
|
6
|
+
ListboxItems: readonly ListboxItem<IconDefinition>[];
|
|
7
|
+
ListboxValues: readonly string[];
|
|
8
|
+
}>;
|
|
9
|
+
export type ListboxSize = NonNullable<Props['size']>;
|
|
10
|
+
export type ListboxVariant = NonNullable<Props['variant']>;
|
|
11
|
+
/**
|
|
12
|
+
* Renders a named, keyboard-navigable single- or multiple-selection listbox.
|
|
13
|
+
*
|
|
14
|
+
* @tag cosm-listbox
|
|
15
|
+
* @slot - No content slot; options are supplied through the `items` property.
|
|
16
|
+
* @csspart base - Outer listbox container.
|
|
17
|
+
* @csspart label - Visible or visually hidden accessible label.
|
|
18
|
+
* @csspart list - Scrollable listbox element.
|
|
19
|
+
* @csspart group - Named, noninteractive option group.
|
|
20
|
+
* @csspart group-label - Noninteractive group heading.
|
|
21
|
+
* @csspart option - Selectable row with data-active, data-selected and data-disabled states.
|
|
22
|
+
* @csspart icon - Decorative option icon.
|
|
23
|
+
* @csspart content - Option text content wrapper.
|
|
24
|
+
* @csspart option-label - Primary option text.
|
|
25
|
+
* @csspart description - Supporting option text.
|
|
26
|
+
* @csspart indicator - Decorative selected-state indicator.
|
|
27
|
+
* @fires {CustomEvent<ListboxSelectionChangeDetail>} cosm-selection-change - Proposes a selection update.
|
|
28
|
+
* @cssprop --cosm-listbox-background - Container background.
|
|
29
|
+
* @cssprop --cosm-listbox-color - Primary foreground.
|
|
30
|
+
* @cssprop --cosm-listbox-border - Outlined container border color.
|
|
31
|
+
* @cssprop --cosm-listbox-radius - Container and option corner radius.
|
|
32
|
+
* @cssprop --cosm-listbox-option-height - Minimum option height.
|
|
33
|
+
* @cssprop --cosm-listbox-option-padding - Option padding.
|
|
34
|
+
* @cssprop --cosm-listbox-gap - Space between icon, content and selection indicator.
|
|
35
|
+
* @cssprop --cosm-listbox-font-size - Primary option text size.
|
|
36
|
+
* @cssprop --cosm-listbox-description-color - Supporting text color.
|
|
37
|
+
* @cssprop --cosm-listbox-selected-background - Selected option background.
|
|
38
|
+
* @cssprop --cosm-listbox-selected-color - Selected option foreground.
|
|
39
|
+
* @cssprop --cosm-listbox-focus - Visible keyboard focus outline color.
|
|
40
|
+
* @cssprop --cosm-listbox-max-height - Maximum scrollable list height.
|
|
41
|
+
*/
|
|
42
|
+
export declare class CosmListbox extends CosmElement {
|
|
43
|
+
#private;
|
|
44
|
+
static shadowRootOptions: ShadowRootInit;
|
|
45
|
+
static properties: {
|
|
46
|
+
label: {
|
|
47
|
+
type: StringConstructor;
|
|
48
|
+
};
|
|
49
|
+
labelHidden: {
|
|
50
|
+
type: BooleanConstructor;
|
|
51
|
+
reflect: boolean;
|
|
52
|
+
attribute: string;
|
|
53
|
+
};
|
|
54
|
+
items: {
|
|
55
|
+
attribute: boolean;
|
|
56
|
+
};
|
|
57
|
+
selectionMode: {
|
|
58
|
+
reflect: boolean;
|
|
59
|
+
attribute: string;
|
|
60
|
+
};
|
|
61
|
+
selectedValues: {
|
|
62
|
+
attribute: boolean;
|
|
63
|
+
noAccessor: boolean;
|
|
64
|
+
};
|
|
65
|
+
defaultSelectedValues: {
|
|
66
|
+
attribute: boolean;
|
|
67
|
+
};
|
|
68
|
+
variant: {
|
|
69
|
+
reflect: boolean;
|
|
70
|
+
};
|
|
71
|
+
size: {
|
|
72
|
+
reflect: boolean;
|
|
73
|
+
converter: {
|
|
74
|
+
fromAttribute(value: string | null): ListboxSize;
|
|
75
|
+
toAttribute(value: ListboxSize): string;
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
disabled: {
|
|
79
|
+
type: BooleanConstructor;
|
|
80
|
+
reflect: boolean;
|
|
81
|
+
};
|
|
82
|
+
readOnly: {
|
|
83
|
+
type: BooleanConstructor;
|
|
84
|
+
reflect: boolean;
|
|
85
|
+
attribute: string;
|
|
86
|
+
};
|
|
87
|
+
locale: {
|
|
88
|
+
type: StringConstructor;
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
static styles: import("lit").CSSResult[];
|
|
92
|
+
/** Required, nonempty accessible name for the listbox. */
|
|
93
|
+
label: Props['label'];
|
|
94
|
+
/** Visually hides the label while retaining it as the listbox accessible name. */
|
|
95
|
+
labelHidden: Props['labelHidden'];
|
|
96
|
+
/** Ordered readonly options and named groups to render. */
|
|
97
|
+
items: Props['items'];
|
|
98
|
+
/** Permits one selected value or toggling multiple values. */
|
|
99
|
+
selectionMode: Props['selectionMode'];
|
|
100
|
+
/** Values used for the initial autonomous selection; later changes do not reset it. */
|
|
101
|
+
defaultSelectedValues: Props['defaultSelectedValues'];
|
|
102
|
+
/** Plain or outlined container presentation. */
|
|
103
|
+
variant: Props['variant'];
|
|
104
|
+
/** Semantic size or a positive finite minimum option height in CSS pixels. */
|
|
105
|
+
size: ListboxSize;
|
|
106
|
+
/** Prevents focus and selection interaction for the whole list. */
|
|
107
|
+
disabled: Props['disabled'];
|
|
108
|
+
/** Allows exploration while preventing selection proposals. */
|
|
109
|
+
readOnly: Props['readOnly'];
|
|
110
|
+
/** Locale override for typeahead; otherwise inherits the nearest `lang`. */
|
|
111
|
+
locale: Props['locale'];
|
|
112
|
+
/** Set by adapters or imperative callers to override binding inference for `selectedValues`. */
|
|
113
|
+
get selectedValuesControlled(): boolean;
|
|
114
|
+
set selectedValuesControlled(value: boolean);
|
|
115
|
+
/** Controlled selected values; setting a defined array marks the state controlled. */
|
|
116
|
+
get selectedValues(): Props['selectedValues'];
|
|
117
|
+
set selectedValues(value: Props['selectedValues']);
|
|
118
|
+
/** The current committed selection, regardless of whether it is autonomous or controlled. */
|
|
119
|
+
get currentSelectedValues(): readonly string[];
|
|
120
|
+
/** The current roving option value, or `null` when every option is disabled or absent. */
|
|
121
|
+
get activeValue(): string | null;
|
|
122
|
+
constructor();
|
|
123
|
+
connectedCallback(): void;
|
|
124
|
+
disconnectedCallback(): void;
|
|
125
|
+
/** Focuses the active enabled option, or the initially selected enabled option. */
|
|
126
|
+
focus(options?: FocusOptions): void;
|
|
127
|
+
protected willUpdate(changed: Map<PropertyKey, unknown>): void;
|
|
128
|
+
protected updated(): void;
|
|
129
|
+
protected render(): import("lit-html").TemplateResult<1>;
|
|
130
|
+
}
|
|
131
|
+
declare global {
|
|
132
|
+
interface HTMLElementTagNameMap {
|
|
133
|
+
'cosm-listbox': CosmListbox;
|
|
134
|
+
}
|
|
135
|
+
interface HTMLElementEventMap {
|
|
136
|
+
'cosm-selection-change': CustomEvent<ListboxSelectionChangeDetail>;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
export {};
|
|
140
|
+
//# sourceMappingURL=cosm-listbox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cosm-listbox.d.ts","sourceRoot":"","sources":["../../../src/components/listbox/cosm-listbox.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAKlB,KAAK,WAAW,EAEhB,KAAK,4BAA4B,EACjC,eAAe,EAIhB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,KAAK,cAAc,EAAoB,MAAM,yBAAyB,CAAC;AAGhF,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAG7D,OAAO,sBAAsB,CAAC;AAE9B,KAAK,KAAK,GAAG,aAAa,CACxB,OAAO,eAAe,EACtB,KAAK,EACL;IAAE,YAAY,EAAE,SAAS,WAAW,CAAC,cAAc,CAAC,EAAE,CAAC;IAAC,aAAa,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAC3F,CAAC;AACF,MAAM,MAAM,WAAW,GAAG,WAAW,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;AACrD,MAAM,MAAM,cAAc,GAAG,WAAW,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC;AA+J3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,qBAAa,WAAY,SAAQ,WAAW;;IAC1C,OAAgB,iBAAiB,EAAE,cAAc,CAG/C;IAEF,OAAgB,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;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