@commmerce/ui 1.5.1 → 1.6.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/dist/calendar.js +2 -0
- package/dist/cdn.js +1018 -659
- package/dist/components/action-menu.d.ts +28 -1
- package/dist/components/action-menu.js +86 -17
- package/dist/components/badge.d.ts +3 -2
- package/dist/components/badge.js +4 -3
- package/dist/components/bottom-sheet.js +1 -1
- package/dist/components/button.d.ts +5 -1
- package/dist/components/button.js +18 -6
- package/dist/components/calendar.d.ts +6 -1
- package/dist/components/calendar.js +15 -1
- package/dist/components/card.d.ts +38 -0
- package/dist/components/card.js +77 -12
- package/dist/components/checkbox.js +7 -2
- package/dist/components/color-field.js +2 -0
- package/dist/components/combobox.d.ts +27 -2
- package/dist/components/combobox.js +109 -15
- package/dist/components/data-table.d.ts +127 -9
- package/dist/components/data-table.js +577 -67
- package/dist/components/date-picker.d.ts +1 -1
- package/dist/components/date-picker.js +1 -1
- package/dist/components/date-range-picker.d.ts +1 -1
- package/dist/components/date-range-picker.js +2 -2
- package/dist/components/empty-state.d.ts +8 -6
- package/dist/components/empty-state.js +26 -17
- package/dist/components/file-upload.d.ts +49 -4
- package/dist/components/file-upload.js +136 -29
- package/dist/components/layout.d.ts +2 -2
- package/dist/components/layout.js +5 -5
- package/dist/components/menu-item.d.ts +18 -0
- package/dist/components/menu-item.js +8 -0
- package/dist/components/page-header.d.ts +6 -0
- package/dist/components/page-header.js +22 -5
- package/dist/components/pagination.d.ts +3 -2
- package/dist/components/pagination.js +13 -10
- package/dist/components/radio.js +4 -2
- package/dist/components/resource-list.d.ts +28 -3
- package/dist/components/resource-list.js +47 -15
- package/dist/components/search.d.ts +2 -2
- package/dist/components/search.js +4 -2
- package/dist/components/segmented-control.js +1 -1
- package/dist/components/select.d.ts +11 -1
- package/dist/components/select.js +17 -4
- package/dist/components/side-navigation.d.ts +1 -1
- package/dist/components/side-navigation.js +5 -3
- package/dist/components/signature-field.js +2 -2
- package/dist/components/status-tabs.d.ts +24 -4
- package/dist/components/status-tabs.js +82 -9
- package/dist/components/table-header.d.ts +1 -1
- package/dist/components/table-header.js +3 -3
- package/dist/components/tag.d.ts +7 -0
- package/dist/components/tag.js +6 -3
- package/dist/components/text-field.d.ts +1 -1
- package/dist/components/text-field.js +3 -1
- package/dist/components/toggle.js +3 -1
- package/dist/components/tooltip.d.ts +5 -2
- package/dist/components/tooltip.js +14 -9
- package/dist/custom-elements.json +1599 -129
- package/dist/density.d.ts +21 -0
- package/dist/density.js +46 -0
- package/dist/field.d.ts +9 -5
- package/dist/field.js +16 -10
- package/dist/index.d.ts +1 -1
- package/dist/popover.js +1 -1
- package/package.json +3 -3
package/dist/components/card.js
CHANGED
|
@@ -9,12 +9,21 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
|
|
|
9
9
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
10
10
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
11
11
|
};
|
|
12
|
-
var _CmCard_instances, _CmCard_adorned, _CmCard_bareActions, _CmCard_onAdornment, _CmCard_onBareActions;
|
|
12
|
+
var _CmCard_instances, _CmCard_adorned, _CmCard_bareActions, _CmCard_onAdornment, _CmCard_onBareActions, _CmCard_toggles, _CmCard_interactive_get, _CmCard_onControl, _CmCard_control;
|
|
13
13
|
import { LitElement, html, css, nothing } from 'lit';
|
|
14
14
|
import { base, define } from '../base.js';
|
|
15
15
|
/**
|
|
16
16
|
* White section card with optional title, description and header actions.
|
|
17
17
|
*
|
|
18
|
+
* Three variants (owner standard, 1.6): `standard` (the default: 24px padding, 16px between header and body, a subtle
|
|
19
|
+
* border), `compact` (16px padding: dashboards, task summaries, metrics) and `interactive` (the whole card opens
|
|
20
|
+
* something: hover, pressed, focus and `selected` states; set `href` for a link, or listen for `cm-action`).
|
|
21
|
+
* Combine them with a space: `variant="interactive compact"`. On phones (640px or less) every card has 16px padding.
|
|
22
|
+
*
|
|
23
|
+
* An interactive card is one control: its heading (or `label`) is a link or button stretched over the whole card, so
|
|
24
|
+
* keyboard users reach it with Tab and press it with Enter (and Space, for a button). Controls in the `actions` slot
|
|
25
|
+
* stay separately clickable above it; don't put other controls in the body of an interactive card.
|
|
26
|
+
*
|
|
18
27
|
* On narrow cards the header wraps instead of squeezing the heading: the title adornment moves under the heading
|
|
19
28
|
* when both don't fit on one line, and the actions move under the title when the title would be narrower than
|
|
20
29
|
* about 12 characters. Wide cards keep everything on one row.
|
|
@@ -23,6 +32,10 @@ import { base, define } from '../base.js';
|
|
|
23
32
|
* @slot actions - Header actions (buttons, links), at the end of the header. Since 1.3 they also show on a card with no
|
|
24
33
|
* `heading` or `description`, in a row of their own at the top of the card.
|
|
25
34
|
* @slot title-adornment - Badge or icon next to the title.
|
|
35
|
+
* @csspart card - The card's box.
|
|
36
|
+
* @csspart title - The heading.
|
|
37
|
+
* @csspart control - The link or button an interactive card is pressed through (stretched over the card).
|
|
38
|
+
* @fires cm-action - An interactive card without `href` was pressed (click, Enter or Space). Not fired by the header actions. Since 1.6.
|
|
26
39
|
*/
|
|
27
40
|
export class CmCard extends LitElement {
|
|
28
41
|
constructor() {
|
|
@@ -36,15 +49,39 @@ export class CmCard extends LitElement {
|
|
|
36
49
|
this.flush = false;
|
|
37
50
|
/** Heading level for the title, so pages keep a correct outline. Default 2. */
|
|
38
51
|
this.headingLevel = 2;
|
|
52
|
+
/**
|
|
53
|
+
* `standard` (default: 24px padding), `compact` (16px padding, for dashboards, task summaries and metrics) or
|
|
54
|
+
* `interactive` (the whole card is a link or button, with hover, pressed, focus and selected states). Combine
|
|
55
|
+
* with a space, e.g. `interactive compact`. Phones always get 16px padding. Since 1.6.
|
|
56
|
+
*/
|
|
57
|
+
this.variant = 'standard';
|
|
58
|
+
/** Interactive cards: the address the card opens. Without it the card is a button that fires `cm-action`. Since 1.6. */
|
|
59
|
+
this.href = '';
|
|
60
|
+
/** Link target when `href` is set. `_blank` adds `rel="noopener noreferrer"`. Since 1.6. */
|
|
61
|
+
this.target = '';
|
|
62
|
+
/** Interactive cards: shows the card as chosen (a 2px dark outline). A button card reports it as pressed, a link card as the current one. Since 1.6. */
|
|
63
|
+
this.selected = false;
|
|
64
|
+
/** Interactive cards without a `heading`: the accessible name of the card's link or button. Since 1.6. */
|
|
65
|
+
this.label = '';
|
|
39
66
|
_CmCard_adorned.set(this, false);
|
|
40
67
|
_CmCard_bareActions.set(this, false);
|
|
68
|
+
/** Set once the card has been `selected`: from then on a button card reports pressed or not pressed (a toggle). */
|
|
69
|
+
_CmCard_toggles.set(this, false);
|
|
70
|
+
_CmCard_onControl.set(this, () => {
|
|
71
|
+
if (!this.href)
|
|
72
|
+
this.dispatchEvent(new CustomEvent('cm-action', { bubbles: true, composed: true }));
|
|
73
|
+
});
|
|
41
74
|
}
|
|
75
|
+
willUpdate() { if (this.selected)
|
|
76
|
+
__classPrivateFieldSet(this, _CmCard_toggles, true, "f"); }
|
|
42
77
|
render() {
|
|
43
78
|
const level = Math.min(6, Math.max(2, this.headingLevel || 2));
|
|
79
|
+
const interactive = __classPrivateFieldGet(this, _CmCard_instances, "a", _CmCard_interactive_get);
|
|
80
|
+
const text = interactive ? __classPrivateFieldGet(this, _CmCard_instances, "m", _CmCard_control).call(this, this.heading) : this.heading;
|
|
44
81
|
const title = this.heading
|
|
45
|
-
? html `<div role="heading" aria-level=${level} class="title" part="title"><span class="text">${
|
|
82
|
+
? html `<div role="heading" aria-level=${level} class="title" part="title"><span class="text">${text}</span><span class="adornment" ?hidden=${!__classPrivateFieldGet(this, _CmCard_adorned, "f")}><slot name="title-adornment" @slotchange=${__classPrivateFieldGet(this, _CmCard_instances, "m", _CmCard_onAdornment)}></slot></span></div>`
|
|
46
83
|
: nothing;
|
|
47
|
-
return html `<section part="card" aria-label=${this.heading || nothing}
|
|
84
|
+
return html `<section part="card" aria-label=${(!interactive && this.heading) || nothing}>${interactive && !this.heading ? __classPrivateFieldGet(this, _CmCard_instances, "m", _CmCard_control).call(this, nothing) : nothing}
|
|
48
85
|
${this.heading || this.description
|
|
49
86
|
? html `<header><div class="main">${this.heading ? html `<span class="strut" aria-hidden="true">${this.heading}</span>` : nothing}${title}${this.description ? html `<p class="desc">${this.description}</p>` : nothing}</div>
|
|
50
87
|
<div class="actions"><slot name="actions"></slot></div></header>`
|
|
@@ -53,7 +90,7 @@ export class CmCard extends LitElement {
|
|
|
53
90
|
</section>`;
|
|
54
91
|
}
|
|
55
92
|
}
|
|
56
|
-
_CmCard_adorned = new WeakMap(), _CmCard_bareActions = new WeakMap(), _CmCard_instances = new WeakSet(), _CmCard_onAdornment = function _CmCard_onAdornment(e) {
|
|
93
|
+
_CmCard_adorned = new WeakMap(), _CmCard_bareActions = new WeakMap(), _CmCard_toggles = new WeakMap(), _CmCard_onControl = new WeakMap(), _CmCard_instances = new WeakSet(), _CmCard_onAdornment = function _CmCard_onAdornment(e) {
|
|
57
94
|
const adorned = e.target.assignedNodes().some((n) => n.nodeType === Node.ELEMENT_NODE || n.textContent?.trim());
|
|
58
95
|
if (adorned !== __classPrivateFieldGet(this, _CmCard_adorned, "f")) {
|
|
59
96
|
__classPrivateFieldSet(this, _CmCard_adorned, adorned, "f");
|
|
@@ -65,33 +102,61 @@ _CmCard_adorned = new WeakMap(), _CmCard_bareActions = new WeakMap(), _CmCard_in
|
|
|
65
102
|
__classPrivateFieldSet(this, _CmCard_bareActions, has, "f");
|
|
66
103
|
this.requestUpdate();
|
|
67
104
|
}
|
|
105
|
+
}, _CmCard_interactive_get = function _CmCard_interactive_get() { return String(this.variant || '').split(/\s+/).includes('interactive'); }, _CmCard_control = function _CmCard_control(text) {
|
|
106
|
+
const cls = text === nothing ? 'hit cover' : 'hit';
|
|
107
|
+
const name = text === nothing ? this.label || nothing : nothing;
|
|
108
|
+
return this.href
|
|
109
|
+
? html `<a class=${cls} part="control" href=${this.href} target=${this.target || nothing} rel=${this.target === '_blank' ? 'noopener noreferrer' : nothing}
|
|
110
|
+
aria-current=${this.selected ? 'true' : nothing} aria-label=${name}>${text}</a>`
|
|
111
|
+
: html `<button class=${cls} part="control" type="button" aria-pressed=${this.selected ? 'true' : __classPrivateFieldGet(this, _CmCard_toggles, "f") ? 'false' : nothing} aria-label=${name} @click=${__classPrivateFieldGet(this, _CmCard_onControl, "f")}>${text}</button>`;
|
|
68
112
|
};
|
|
69
113
|
CmCard.properties = {
|
|
70
114
|
heading: {},
|
|
71
115
|
description: {},
|
|
72
116
|
flush: { type: Boolean, reflect: true },
|
|
73
117
|
headingLevel: { type: Number, attribute: 'heading-level' },
|
|
118
|
+
variant: { reflect: true },
|
|
119
|
+
href: {},
|
|
120
|
+
target: {},
|
|
121
|
+
selected: { type: Boolean, reflect: true },
|
|
122
|
+
label: {},
|
|
74
123
|
};
|
|
75
124
|
CmCard.styles = [
|
|
76
125
|
base,
|
|
77
126
|
css `
|
|
78
|
-
|
|
79
|
-
|
|
127
|
+
/* Owner standard (1.6): 24px padding and a 16px gap under the header; compact 16px and 12px; 16px on phones. */
|
|
128
|
+
:host { display: block; --_pad: var(--cm-space-24); --_gap: var(--cm-space-16); }
|
|
129
|
+
:host([variant~='compact']) { --_pad: var(--cm-space-16); --_gap: var(--cm-space-12); }
|
|
130
|
+
@media (max-width: 640px) { :host { --_pad: var(--cm-space-16); } }
|
|
131
|
+
/* Flat: a 1px border-subtle and no shadow (shadows are for overlays). */
|
|
80
132
|
section {
|
|
81
|
-
background: var(--cm-bg-surface); border: var(--cm-border-1) solid var(--cm-border-subtle);
|
|
82
|
-
border-radius: var(--cm-radius-md); padding: var(--
|
|
133
|
+
position: relative; background: var(--cm-bg-surface); border: var(--cm-border-1) solid var(--cm-border-subtle);
|
|
134
|
+
border-radius: var(--cm-radius-md); padding: var(--_pad);
|
|
83
135
|
font-size: var(--cm-font-size-14); line-height: var(--cm-line-height-14);
|
|
84
136
|
}
|
|
85
137
|
:host([flush]) section { padding: 0; }
|
|
138
|
+
/* Interactive (1.6): hover darkens the outline and tints the card, pressing tints it a step more, focus draws the
|
|
139
|
+
2px ring outside the card, selected draws a 2px dark outline. The control's ::after covers the card. */
|
|
140
|
+
:host([variant~='interactive']) section { cursor: pointer; transition: background-color var(--cm-duration-fast) var(--cm-easing-standard), border-color var(--cm-duration-fast) var(--cm-easing-standard); }
|
|
141
|
+
:host([variant~='interactive']) section:hover { border-color: var(--cm-border-input); background: var(--cm-bg-hover); }
|
|
142
|
+
:host([variant~='interactive']) section:active { background: color-mix(in srgb, var(--cm-bg-hover), var(--cm-text-default) 6%); }
|
|
143
|
+
:host([variant~='interactive'][selected]) section { border-color: var(--cm-border-strong); box-shadow: inset 0 0 0 1px var(--cm-border-strong); }
|
|
144
|
+
@media (prefers-reduced-motion: reduce) { :host([variant~='interactive']) section { transition: none; } }
|
|
145
|
+
.hit { color: inherit; text-decoration: none; font: inherit; background: none; border: 0; padding: 0; margin: 0; text-align: inherit; cursor: pointer; outline: none; }
|
|
146
|
+
.hit::after { content: ''; position: absolute; inset: calc(-1 * var(--cm-border-1)); z-index: 0; border-radius: var(--cm-radius-md); }
|
|
147
|
+
.hit:focus-visible::after { outline: 2px solid var(--cm-border-strong); outline-offset: 2px; }
|
|
148
|
+
.hit:hover { text-decoration: underline; text-underline-offset: 3px; }
|
|
149
|
+
.cover { position: absolute; inset: 0; }
|
|
150
|
+
:host([variant~='interactive']) .actions, :host([variant~='interactive']) .bare { position: relative; z-index: 1; }
|
|
86
151
|
/* Wraps only on narrow cards. .main grows from a 0 basis (wide cards look exactly as before: its content stays
|
|
87
152
|
at the start), and its minimum width comes from .strut: the heading on one line, capped at 12 characters. So
|
|
88
153
|
the actions move under the title only when the heading would get less than that. */
|
|
89
154
|
header {
|
|
90
155
|
display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between;
|
|
91
|
-
gap: var(--cm-space-8) var(--cm-space-16); margin-bottom: var(--
|
|
156
|
+
gap: var(--cm-space-8) var(--cm-space-16); margin-bottom: var(--_gap);
|
|
92
157
|
}
|
|
93
158
|
/* Flush: the header keeps its padding and the body (a list, a table) starts right under it. */
|
|
94
|
-
:host([flush]) header { padding: var(--
|
|
159
|
+
:host([flush]) header { padding: var(--_pad) var(--_pad) 0; margin-bottom: var(--cm-space-8); }
|
|
95
160
|
.main { flex: 1 1 0%; max-inline-size: 100%; align-self: center; }
|
|
96
161
|
.strut {
|
|
97
162
|
display: block; block-size: 0; overflow: hidden; visibility: hidden; white-space: nowrap;
|
|
@@ -107,9 +172,9 @@ CmCard.styles = [
|
|
|
107
172
|
.desc { margin: var(--cm-space-4) 0 0; font-size: var(--cm-font-size-13); line-height: var(--cm-line-height-13); color: var(--cm-text-tertiary); }
|
|
108
173
|
.actions { display: flex; flex-wrap: wrap; gap: var(--cm-space-8); align-items: center; }
|
|
109
174
|
/* Actions on a card without a heading or description: a row of their own, at the end. */
|
|
110
|
-
.bare { display: flex; justify-content: flex-end; margin-bottom: var(--
|
|
175
|
+
.bare { display: flex; justify-content: flex-end; margin-bottom: var(--_gap); }
|
|
111
176
|
.bare[hidden] { display: none; }
|
|
112
|
-
:host([flush]) .bare { padding: var(--
|
|
177
|
+
:host([flush]) .bare { padding: var(--_pad) var(--_pad) 0; margin-bottom: var(--cm-space-8); }
|
|
113
178
|
`,
|
|
114
179
|
];
|
|
115
180
|
define('cm-card', CmCard);
|
|
@@ -100,7 +100,9 @@ CmCheckbox.styles = [
|
|
|
100
100
|
css `
|
|
101
101
|
:host { display: inline-flex; }
|
|
102
102
|
label { position: relative; display: inline-flex; align-items: flex-start; gap: var(--cm-space-8); padding-block: 2px; cursor: pointer; }
|
|
103
|
-
/* The 16px box sits on the label's first line (20px); the
|
|
103
|
+
/* The 16px box (18px on touch screens, owner standard 1.6) sits centred on the label's first line (20px); the
|
|
104
|
+
invisible input around it is a 24px target. Without a label the element is 24px tall with the box in the middle,
|
|
105
|
+
so it centres in a row with align-items: center. */
|
|
104
106
|
input { position: absolute; inset-block-start: 0; inset-inline-start: -4px; opacity: 0; width: 24px; height: 24px; margin: 0; cursor: inherit; }
|
|
105
107
|
.box {
|
|
106
108
|
flex: none; width: 16px; height: 16px; margin-block: 2px; display: inline-flex; align-items: center; justify-content: center;
|
|
@@ -108,10 +110,13 @@ CmCheckbox.styles = [
|
|
|
108
110
|
background: var(--cm-bg-surface); color: transparent;
|
|
109
111
|
}
|
|
110
112
|
input:checked + .box, input:indeterminate + .box { color: var(--cm-text-default); }
|
|
113
|
+
@media (pointer: coarse) { .box { width: 18px; height: 18px; margin-block: 1px; } } /* scale-exempt: owner standard (#33), checkbox mark 18px on touch screens */
|
|
114
|
+
label:hover input:not(:disabled) + .box { border-color: var(--cm-text-default); background: var(--cm-bg-hover); }
|
|
115
|
+
label:active input:not(:disabled) + .box { background: color-mix(in srgb, var(--cm-bg-hover), var(--cm-text-default) 8%); }
|
|
111
116
|
input:focus-visible + .box { outline: 2px solid var(--cm-border-strong); outline-offset: 2px; }
|
|
112
117
|
.text { display: flex; flex-direction: column; gap: 2px; }
|
|
113
118
|
.label { font-size: var(--cm-type-body-md-size); line-height: var(--cm-type-body-md-line-height); }
|
|
114
|
-
.desc { font-size: var(--cm-type-body-
|
|
119
|
+
.desc { font-size: var(--cm-type-body-xs-size); line-height: var(--cm-type-body-xs-line-height); color: var(--cm-text-tertiary); }
|
|
115
120
|
:host([disabled]) label { cursor: not-allowed; }
|
|
116
121
|
:host([disabled]) .box { background: var(--cm-bg-input-filled); border-color: var(--cm-border-subtle); }
|
|
117
122
|
:host([disabled]) .label { color: var(--cm-text-secondary); }
|
|
@@ -355,6 +355,8 @@ CmColorField.styles = [
|
|
|
355
355
|
border-radius: var(--cm-radius-sm); outline: none; box-sizing: content-box;
|
|
356
356
|
}
|
|
357
357
|
.input::placeholder { color: var(--cm-text-tertiary); }
|
|
358
|
+
/* Hover (1.6): the outline darkens; focus adds the 2px ring. */
|
|
359
|
+
.input:hover:not(:disabled):not(:focus) { border-color: var(--cm-border-strong); }
|
|
358
360
|
.input:focus { border-color: var(--cm-border-strong); box-shadow: 0 0 0 1px var(--cm-border-strong); }
|
|
359
361
|
.input[aria-invalid='true'] { border-color: var(--cm-border-critical); }
|
|
360
362
|
.input:disabled { background: var(--cm-bg-input-filled); color: var(--cm-text-secondary); border-color: var(--cm-border-subtle); cursor: not-allowed; }
|
|
@@ -22,6 +22,8 @@ declare const strings: {
|
|
|
22
22
|
requiredMultiple: string;
|
|
23
23
|
/** The chosen option in the box or its tag with `show-group`: "Lead: Company". */
|
|
24
24
|
grouped: string;
|
|
25
|
+
/** `multiple`: the tag that stands for the tags not shown while the box isn't focused (`max-tags`). */
|
|
26
|
+
more: string;
|
|
25
27
|
};
|
|
26
28
|
declare module '../localize.js' {
|
|
27
29
|
interface CmStrings {
|
|
@@ -44,6 +46,8 @@ declare module '../localize.js' {
|
|
|
44
46
|
* @fires cm-search - As the merchant types, with `detail: { query }`. Use it to load matches from the server.
|
|
45
47
|
* @fires cm-create - Before a custom value is added (`allow-custom`), with `detail: { value }`. Cancelable: call `preventDefault()` to refuse it.
|
|
46
48
|
* @csspart box - The bordered box around the tags and the text input.
|
|
49
|
+
* @csspart tag - Each chosen option's tag (`multiple`).
|
|
50
|
+
* @csspart more - The "+N more" tag (`multiple` with `max-tags`).
|
|
47
51
|
* @csspart input - The text input.
|
|
48
52
|
* @csspart listbox - The list of suggestions.
|
|
49
53
|
*/
|
|
@@ -115,9 +119,16 @@ export declare class CmCombobox extends CmLocalizedElement {
|
|
|
115
119
|
type: BooleanConstructor;
|
|
116
120
|
attribute: string;
|
|
117
121
|
};
|
|
122
|
+
maxTags: {
|
|
123
|
+
type: NumberConstructor;
|
|
124
|
+
attribute: string;
|
|
125
|
+
};
|
|
118
126
|
_query: {
|
|
119
127
|
state: boolean;
|
|
120
128
|
};
|
|
129
|
+
_focusIn: {
|
|
130
|
+
state: boolean;
|
|
131
|
+
};
|
|
121
132
|
_active: {
|
|
122
133
|
state: boolean;
|
|
123
134
|
};
|
|
@@ -144,10 +155,15 @@ export declare class CmCombobox extends CmLocalizedElement {
|
|
|
144
155
|
placeholder: string;
|
|
145
156
|
/** Options as strings or `{ value, label, disabled, group }`. Used instead of `<option>` children when set. */
|
|
146
157
|
options: Array<string | SelectOption>;
|
|
147
|
-
/**
|
|
158
|
+
/**
|
|
159
|
+
* Lets the merchant choose several options, shown as removable 24px tags (`cm-tag`) that wrap onto more rows as the box
|
|
160
|
+
* grows from its 40px minimum. Keyboard: Backspace in the empty box removes the last tag; ← (→ in right-to-left text)
|
|
161
|
+
* at the start of the box moves to the tags, ←/→ move between them, Backspace or Delete removes the focused tag, and
|
|
162
|
+
* → past the last tag (or Esc) goes back to the text box. The tags are not Tab stops.
|
|
163
|
+
*/
|
|
148
164
|
multiple: boolean;
|
|
149
165
|
/**
|
|
150
|
-
* `small`: a 32px box with a 13px label, for toolbars, filter rows and filter panels. Default: a
|
|
166
|
+
* `small`: a 32px box with a 13px label, for toolbars, filter rows and filter panels. Default: a 40px box (since 1.6, owner standard; was 36px). On touch
|
|
151
167
|
* screens both are 44px. Since 1.5.
|
|
152
168
|
*/
|
|
153
169
|
size: 'default' | 'small';
|
|
@@ -172,7 +188,14 @@ export declare class CmCombobox extends CmLocalizedElement {
|
|
|
172
188
|
* for grouped lists where labels repeat across groups. The list itself shows the bare label under its heading. Since 1.3.
|
|
173
189
|
*/
|
|
174
190
|
showGroup: boolean;
|
|
191
|
+
/**
|
|
192
|
+
* `multiple`: how many tags show while the box isn't focused; the rest become one "+N more" tag. Every tag shows
|
|
193
|
+
* while the merchant is in the box. `0` shows them all. Default 3 (since 1.6, owner standard).
|
|
194
|
+
*/
|
|
195
|
+
maxTags: number;
|
|
175
196
|
_query: string;
|
|
197
|
+
/** True while focus is inside the element (all tags show). */
|
|
198
|
+
_focusIn: boolean;
|
|
176
199
|
_active: number;
|
|
177
200
|
_slotted: SelectOption[];
|
|
178
201
|
/** True while the text box holds the merchant's own query rather than the chosen option's label. */
|
|
@@ -197,6 +220,8 @@ export declare class CmCombobox extends CmLocalizedElement {
|
|
|
197
220
|
updated(changed: PropertyValues): void;
|
|
198
221
|
/** Removes a chosen value (`multiple`). */
|
|
199
222
|
removeValue(value: string): void;
|
|
223
|
+
/** Focuses the text box (not the first tag). */
|
|
224
|
+
focus(options?: FocusOptions): void;
|
|
200
225
|
render(): import("lit-html").TemplateResult<1>;
|
|
201
226
|
}
|
|
202
227
|
declare global {
|
|
@@ -9,11 +9,11 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
|
|
|
9
9
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
10
10
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
11
11
|
};
|
|
12
|
-
var _CmCombobox_instances, _CmCombobox_internals, _CmCombobox_id, _CmCombobox_default, _CmCombobox_labels, _CmCombobox_groups, _CmCombobox_observer, _CmCombobox_stopOutside, _CmCombobox_readChildren, _CmCombobox_labelOf, _CmCombobox_displayOf, _CmCombobox_createText_get, _CmCombobox_rows, _CmCombobox_emit, _CmCombobox_show, _CmCombobox_hide, _CmCombobox_enabled, _CmCombobox_move, _CmCombobox_choose, _CmCombobox_create, _CmCombobox_focusInput, _CmCombobox_onInput, _CmCombobox_onKeyDown, _CmCombobox_onBlur, _CmCombobox_highlight;
|
|
12
|
+
var _CmCombobox_instances, _CmCombobox_internals, _CmCombobox_id, _CmCombobox_default, _CmCombobox_labels, _CmCombobox_groups, _CmCombobox_observer, _CmCombobox_stopOutside, _CmCombobox_readChildren, _CmCombobox_labelOf, _CmCombobox_displayOf, _CmCombobox_createText_get, _CmCombobox_rows, _CmCombobox_emit, _CmCombobox_show, _CmCombobox_hide, _CmCombobox_enabled, _CmCombobox_move, _CmCombobox_choose, _CmCombobox_create, _CmCombobox_focusInput, _CmCombobox_onFocusIn, _CmCombobox_onFocusOut, _CmCombobox_focusTag, _CmCombobox_onTagKey, _CmCombobox_onInput, _CmCombobox_onKeyDown, _CmCombobox_onBlur, _CmCombobox_highlight, _CmCombobox_tags;
|
|
13
13
|
import { LitElement, html, css, nothing } from 'lit';
|
|
14
14
|
import { live } from 'lit/directives/live.js';
|
|
15
15
|
import { fieldStyles, optionStyles } from '../field.js';
|
|
16
|
-
import { base, define, nextId } from '../base.js';
|
|
16
|
+
import { base, define, nextId, logicalKey } from '../base.js';
|
|
17
17
|
import { CmLocalizedElement, defineStrings } from '../localize.js';
|
|
18
18
|
import { popoverStyles, groupStyles, sortByGroup, groupRuns, closeOnOutsidePointer } from '../popover.js';
|
|
19
19
|
import './icon.js';
|
|
@@ -34,6 +34,8 @@ const strings = defineStrings('combobox', {
|
|
|
34
34
|
requiredMultiple: 'Choose at least one item.',
|
|
35
35
|
/** The chosen option in the box or its tag with `show-group`: "Lead: Company". */
|
|
36
36
|
grouped: '{group}: {label}',
|
|
37
|
+
/** `multiple`: the tag that stands for the tags not shown while the box isn't focused (`max-tags`). */
|
|
38
|
+
more: '+{count} more',
|
|
37
39
|
});
|
|
38
40
|
/**
|
|
39
41
|
* Editable combobox: a text box that suggests matching options as the merchant types (the WAI-ARIA APG
|
|
@@ -51,6 +53,8 @@ const strings = defineStrings('combobox', {
|
|
|
51
53
|
* @fires cm-search - As the merchant types, with `detail: { query }`. Use it to load matches from the server.
|
|
52
54
|
* @fires cm-create - Before a custom value is added (`allow-custom`), with `detail: { value }`. Cancelable: call `preventDefault()` to refuse it.
|
|
53
55
|
* @csspart box - The bordered box around the tags and the text input.
|
|
56
|
+
* @csspart tag - Each chosen option's tag (`multiple`).
|
|
57
|
+
* @csspart more - The "+N more" tag (`multiple` with `max-tags`).
|
|
54
58
|
* @csspart input - The text input.
|
|
55
59
|
* @csspart listbox - The list of suggestions.
|
|
56
60
|
*/
|
|
@@ -74,10 +78,15 @@ export class CmCombobox extends CmLocalizedElement {
|
|
|
74
78
|
this.placeholder = '';
|
|
75
79
|
/** Options as strings or `{ value, label, disabled, group }`. Used instead of `<option>` children when set. */
|
|
76
80
|
this.options = [];
|
|
77
|
-
/**
|
|
81
|
+
/**
|
|
82
|
+
* Lets the merchant choose several options, shown as removable 24px tags (`cm-tag`) that wrap onto more rows as the box
|
|
83
|
+
* grows from its 40px minimum. Keyboard: Backspace in the empty box removes the last tag; ← (→ in right-to-left text)
|
|
84
|
+
* at the start of the box moves to the tags, ←/→ move between them, Backspace or Delete removes the focused tag, and
|
|
85
|
+
* → past the last tag (or Esc) goes back to the text box. The tags are not Tab stops.
|
|
86
|
+
*/
|
|
78
87
|
this.multiple = false;
|
|
79
88
|
/**
|
|
80
|
-
* `small`: a 32px box with a 13px label, for toolbars, filter rows and filter panels. Default: a
|
|
89
|
+
* `small`: a 32px box with a 13px label, for toolbars, filter rows and filter panels. Default: a 40px box (since 1.6, owner standard; was 36px). On touch
|
|
81
90
|
* screens both are 44px. Since 1.5.
|
|
82
91
|
*/
|
|
83
92
|
this.size = 'default';
|
|
@@ -98,7 +107,14 @@ export class CmCombobox extends CmLocalizedElement {
|
|
|
98
107
|
* for grouped lists where labels repeat across groups. The list itself shows the bare label under its heading. Since 1.3.
|
|
99
108
|
*/
|
|
100
109
|
this.showGroup = false;
|
|
110
|
+
/**
|
|
111
|
+
* `multiple`: how many tags show while the box isn't focused; the rest become one "+N more" tag. Every tag shows
|
|
112
|
+
* while the merchant is in the box. `0` shows them all. Default 3 (since 1.6, owner standard).
|
|
113
|
+
*/
|
|
114
|
+
this.maxTags = 3;
|
|
101
115
|
this._query = '';
|
|
116
|
+
/** True while focus is inside the element (all tags show). */
|
|
117
|
+
this._focusIn = false;
|
|
102
118
|
this._active = -1;
|
|
103
119
|
this._slotted = [];
|
|
104
120
|
/** True while the text box holds the merchant's own query rather than the chosen option's label. */
|
|
@@ -112,6 +128,11 @@ export class CmCombobox extends CmLocalizedElement {
|
|
|
112
128
|
_CmCombobox_groups.set(this, new Map());
|
|
113
129
|
_CmCombobox_observer.set(this, new MutationObserver(() => __classPrivateFieldGet(this, _CmCombobox_instances, "m", _CmCombobox_readChildren).call(this)));
|
|
114
130
|
_CmCombobox_stopOutside.set(this, void 0);
|
|
131
|
+
_CmCombobox_onFocusIn.set(this, () => { this._focusIn = true; });
|
|
132
|
+
_CmCombobox_onFocusOut.set(this, () => {
|
|
133
|
+
// A tag removed from the keyboard drops focus for a moment before the next one takes it: decide afterwards.
|
|
134
|
+
setTimeout(() => { this._focusIn = this.matches(':focus-within'); });
|
|
135
|
+
});
|
|
115
136
|
_CmCombobox_onInput.set(this, (e) => {
|
|
116
137
|
e.stopPropagation(); // the native per-keystroke input event; `input` is fired when the value changes
|
|
117
138
|
this._query = e.target.value;
|
|
@@ -170,6 +191,16 @@ export class CmCombobox extends CmLocalizedElement {
|
|
|
170
191
|
}
|
|
171
192
|
}
|
|
172
193
|
break;
|
|
194
|
+
case 'ArrowLeft':
|
|
195
|
+
case 'ArrowRight': {
|
|
196
|
+
const input = e.target;
|
|
197
|
+
if (this.multiple && this.values.length && logicalKey(e, this) === 'ArrowLeft' && input.selectionStart === 0 && input.selectionEnd === 0) {
|
|
198
|
+
e.preventDefault();
|
|
199
|
+
__classPrivateFieldGet(this, _CmCombobox_instances, "m", _CmCombobox_hide).call(this);
|
|
200
|
+
__classPrivateFieldGet(this, _CmCombobox_instances, "m", _CmCombobox_focusTag).call(this, this.values.length - 1);
|
|
201
|
+
}
|
|
202
|
+
break;
|
|
203
|
+
}
|
|
173
204
|
case 'Backspace':
|
|
174
205
|
if (this.multiple && !this._query && this.values.length) {
|
|
175
206
|
e.preventDefault();
|
|
@@ -200,6 +231,8 @@ export class CmCombobox extends CmLocalizedElement {
|
|
|
200
231
|
__classPrivateFieldGet(this, _CmCombobox_instances, "m", _CmCombobox_readChildren).call(this);
|
|
201
232
|
__classPrivateFieldGet(this, _CmCombobox_observer, "f").observe(this, { childList: true, subtree: true, characterData: true, attributes: true, attributeFilter: ['value', 'label', 'disabled', 'selected'] });
|
|
202
233
|
__classPrivateFieldSet(this, _CmCombobox_stopOutside, closeOnOutsidePointer(this, () => this.open, () => __classPrivateFieldGet(this, _CmCombobox_instances, "m", _CmCombobox_hide).call(this)), "f");
|
|
234
|
+
this.addEventListener('focusin', __classPrivateFieldGet(this, _CmCombobox_onFocusIn, "f"));
|
|
235
|
+
this.addEventListener('focusout', __classPrivateFieldGet(this, _CmCombobox_onFocusOut, "f"));
|
|
203
236
|
}
|
|
204
237
|
disconnectedCallback() {
|
|
205
238
|
super.disconnectedCallback();
|
|
@@ -295,6 +328,8 @@ export class CmCombobox extends CmLocalizedElement {
|
|
|
295
328
|
this.values = this.values.filter((v) => v !== value);
|
|
296
329
|
__classPrivateFieldGet(this, _CmCombobox_instances, "m", _CmCombobox_emit).call(this);
|
|
297
330
|
}
|
|
331
|
+
/** Focuses the text box (not the first tag). */
|
|
332
|
+
focus(options) { this.renderRoot.querySelector('input')?.focus(options); }
|
|
298
333
|
render() {
|
|
299
334
|
const rows = __classPrivateFieldGet(this, _CmCombobox_instances, "m", _CmCombobox_rows).call(this);
|
|
300
335
|
const described = [this.error && `${__classPrivateFieldGet(this, _CmCombobox_id, "f")}-err`, this.helpText && `${__classPrivateFieldGet(this, _CmCombobox_id, "f")}-help`].filter(Boolean).join(' ');
|
|
@@ -315,10 +350,10 @@ export class CmCombobox extends CmLocalizedElement {
|
|
|
315
350
|
? html `<label class="label" id="${__classPrivateFieldGet(this, _CmCombobox_id, "f")}-l" for="${__classPrivateFieldGet(this, _CmCombobox_id, "f")}-in" part="label">${this.label}${this.required ? html `<span class="req" aria-hidden="true">*</span>` : nothing}</label>`
|
|
316
351
|
: nothing}
|
|
317
352
|
<div class="wrap">
|
|
318
|
-
<div class="box" part="box" @click=${(e) => { if (!e.target.closest('cm-tag'))
|
|
353
|
+
<div class="box" part="box" @click=${(e) => { if (!e.target.closest('cm-tag[removable]'))
|
|
319
354
|
__classPrivateFieldGet(this, _CmCombobox_instances, "m", _CmCombobox_focusInput).call(this); }}>
|
|
320
|
-
${this.multiple
|
|
321
|
-
|
|
355
|
+
<div class="chips ${this.multiple && this.values.length ? `has-tags${this._focusIn || this.open ? '' : ' idle'}` : ''}">
|
|
356
|
+
${this.multiple ? __classPrivateFieldGet(this, _CmCombobox_instances, "m", _CmCombobox_tags).call(this) : nothing}
|
|
322
357
|
<input id="${__classPrivateFieldGet(this, _CmCombobox_id, "f")}-in" part="input" type="text" role="combobox" autocomplete="off" spellcheck="false"
|
|
323
358
|
.value=${live(this._query)} placeholder=${this.multiple && this.values.length ? nothing : this.placeholder || nothing}
|
|
324
359
|
aria-label=${!this.label && hostLabel ? hostLabel : nothing}
|
|
@@ -329,6 +364,7 @@ export class CmCombobox extends CmLocalizedElement {
|
|
|
329
364
|
@input=${__classPrivateFieldGet(this, _CmCombobox_onInput, "f")} @keydown=${__classPrivateFieldGet(this, _CmCombobox_onKeyDown, "f")} @blur=${__classPrivateFieldGet(this, _CmCombobox_onBlur, "f")}
|
|
330
365
|
@click=${() => { if (!this.open)
|
|
331
366
|
__classPrivateFieldGet(this, _CmCombobox_instances, "m", _CmCombobox_show).call(this); }} @change=${(e) => e.stopPropagation()} />
|
|
367
|
+
</div>
|
|
332
368
|
<cm-icon class="chev" name="chevron-down" size="16" @click=${() => { if (this.open)
|
|
333
369
|
__classPrivateFieldGet(this, _CmCombobox_instances, "m", _CmCombobox_hide).call(this);
|
|
334
370
|
else {
|
|
@@ -357,7 +393,7 @@ export class CmCombobox extends CmLocalizedElement {
|
|
|
357
393
|
</div>`;
|
|
358
394
|
}
|
|
359
395
|
}
|
|
360
|
-
_CmCombobox_internals = new WeakMap(), _CmCombobox_id = new WeakMap(), _CmCombobox_default = new WeakMap(), _CmCombobox_labels = new WeakMap(), _CmCombobox_groups = new WeakMap(), _CmCombobox_observer = new WeakMap(), _CmCombobox_stopOutside = new WeakMap(), _CmCombobox_onInput = new WeakMap(), _CmCombobox_onKeyDown = new WeakMap(), _CmCombobox_onBlur = new WeakMap(), _CmCombobox_instances = new WeakSet(), _CmCombobox_readChildren = function _CmCombobox_readChildren() {
|
|
396
|
+
_CmCombobox_internals = new WeakMap(), _CmCombobox_id = new WeakMap(), _CmCombobox_default = new WeakMap(), _CmCombobox_labels = new WeakMap(), _CmCombobox_groups = new WeakMap(), _CmCombobox_observer = new WeakMap(), _CmCombobox_stopOutside = new WeakMap(), _CmCombobox_onFocusIn = new WeakMap(), _CmCombobox_onFocusOut = new WeakMap(), _CmCombobox_onInput = new WeakMap(), _CmCombobox_onKeyDown = new WeakMap(), _CmCombobox_onBlur = new WeakMap(), _CmCombobox_instances = new WeakSet(), _CmCombobox_readChildren = function _CmCombobox_readChildren() {
|
|
361
397
|
const opts = [...this.querySelectorAll('option')];
|
|
362
398
|
this._slotted = opts.map((o) => {
|
|
363
399
|
const g = o.parentElement?.localName === 'optgroup' ? o.parentElement : null;
|
|
@@ -461,7 +497,47 @@ _CmCombobox_internals = new WeakMap(), _CmCombobox_id = new WeakMap(), _CmCombob
|
|
|
461
497
|
this._query = text;
|
|
462
498
|
}
|
|
463
499
|
__classPrivateFieldGet(this, _CmCombobox_instances, "m", _CmCombobox_emit).call(this);
|
|
464
|
-
}, _CmCombobox_focusInput = function _CmCombobox_focusInput() { this.renderRoot.querySelector('input')?.focus(); },
|
|
500
|
+
}, _CmCombobox_focusInput = function _CmCombobox_focusInput() { this.renderRoot.querySelector('input')?.focus(); }, _CmCombobox_focusTag =
|
|
501
|
+
/** Focuses the tag at `i` (its remove button), or the text box when there is none. */
|
|
502
|
+
async function _CmCombobox_focusTag(i) {
|
|
503
|
+
await this.updateComplete;
|
|
504
|
+
const tags = this.renderRoot.querySelectorAll('cm-tag[data-i]');
|
|
505
|
+
if (i >= 0 && i < tags.length)
|
|
506
|
+
tags[i].focus();
|
|
507
|
+
else
|
|
508
|
+
__classPrivateFieldGet(this, _CmCombobox_instances, "m", _CmCombobox_focusInput).call(this);
|
|
509
|
+
}, _CmCombobox_onTagKey = function _CmCombobox_onTagKey(e, i) {
|
|
510
|
+
const k = logicalKey(e, this);
|
|
511
|
+
const last = this.values.length - 1;
|
|
512
|
+
if (k === 'ArrowLeft') {
|
|
513
|
+
e.preventDefault();
|
|
514
|
+
__classPrivateFieldGet(this, _CmCombobox_instances, "m", _CmCombobox_focusTag).call(this, Math.max(0, i - 1));
|
|
515
|
+
}
|
|
516
|
+
else if (k === 'ArrowRight') {
|
|
517
|
+
e.preventDefault();
|
|
518
|
+
__classPrivateFieldGet(this, _CmCombobox_instances, "m", _CmCombobox_focusTag).call(this, i < last ? i + 1 : -1);
|
|
519
|
+
}
|
|
520
|
+
else if (k === 'Home') {
|
|
521
|
+
e.preventDefault();
|
|
522
|
+
__classPrivateFieldGet(this, _CmCombobox_instances, "m", _CmCombobox_focusTag).call(this, 0);
|
|
523
|
+
}
|
|
524
|
+
else if (k === 'End') {
|
|
525
|
+
e.preventDefault();
|
|
526
|
+
__classPrivateFieldGet(this, _CmCombobox_instances, "m", _CmCombobox_focusTag).call(this, last);
|
|
527
|
+
}
|
|
528
|
+
else if (k === 'Escape') {
|
|
529
|
+
e.preventDefault();
|
|
530
|
+
e.stopPropagation();
|
|
531
|
+
__classPrivateFieldGet(this, _CmCombobox_instances, "m", _CmCombobox_focusInput).call(this);
|
|
532
|
+
}
|
|
533
|
+
else if ((k === 'Backspace' || k === 'Delete') && !this.disabled) {
|
|
534
|
+
e.preventDefault();
|
|
535
|
+
this.removeValue(this.values[i]);
|
|
536
|
+
// Backspace goes to the tag before (or the new first one); Delete to the one that moved into its place.
|
|
537
|
+
const left = this.values.length;
|
|
538
|
+
__classPrivateFieldGet(this, _CmCombobox_instances, "m", _CmCombobox_focusTag).call(this, k === 'Backspace' ? (i > 0 ? i - 1 : left ? 0 : -1) : i < left ? i : -1);
|
|
539
|
+
}
|
|
540
|
+
}, _CmCombobox_highlight = function _CmCombobox_highlight(label) {
|
|
465
541
|
const q = this._typing ? this._query.trim() : '';
|
|
466
542
|
if (!q || this.filter === 'none')
|
|
467
543
|
return label;
|
|
@@ -469,6 +545,14 @@ _CmCombobox_internals = new WeakMap(), _CmCombobox_id = new WeakMap(), _CmCombob
|
|
|
469
545
|
if (i < 0 || (this.filter === 'starts-with' && i !== 0))
|
|
470
546
|
return label;
|
|
471
547
|
return html `${label.slice(0, i)}<mark>${label.slice(i, i + q.length)}</mark>${label.slice(i + q.length)}`;
|
|
548
|
+
}, _CmCombobox_tags = function _CmCombobox_tags() {
|
|
549
|
+
const limit = this.maxTags > 0 && !this._focusIn && !this.open && this.values.length > this.maxTags ? this.maxTags : this.values.length;
|
|
550
|
+
const hidden = this.values.length - limit;
|
|
551
|
+
return html `${this.values.slice(0, limit).map((v, i) => html `<cm-tag removable tabindex="-1" data-i=${i} part="tag" ?disabled=${this.disabled}
|
|
552
|
+
remove-label=${this.t('remove', { label: __classPrivateFieldGet(this, _CmCombobox_instances, "m", _CmCombobox_displayOf).call(this, v) })}
|
|
553
|
+
@keydown=${(e) => __classPrivateFieldGet(this, _CmCombobox_instances, "m", _CmCombobox_onTagKey).call(this, e, i)}
|
|
554
|
+
@cm-remove=${() => { this.removeValue(v); __classPrivateFieldGet(this, _CmCombobox_instances, "m", _CmCombobox_focusInput).call(this); }}>${__classPrivateFieldGet(this, _CmCombobox_instances, "m", _CmCombobox_displayOf).call(this, v)}</cm-tag>`)}${hidden
|
|
555
|
+
? html `<cm-tag class="more" part="more">${this.t('more', { count: hidden })}</cm-tag>` : nothing}`;
|
|
472
556
|
};
|
|
473
557
|
CmCombobox.formAssociated = true;
|
|
474
558
|
CmCombobox.shadowRootOptions = { ...LitElement.shadowRootOptions, delegatesFocus: true };
|
|
@@ -492,7 +576,9 @@ CmCombobox.properties = {
|
|
|
492
576
|
disabled: { type: Boolean, reflect: true },
|
|
493
577
|
open: { type: Boolean, reflect: true },
|
|
494
578
|
showGroup: { type: Boolean, attribute: 'show-group' },
|
|
579
|
+
maxTags: { type: Number, attribute: 'max-tags' },
|
|
495
580
|
_query: { state: true },
|
|
581
|
+
_focusIn: { state: true },
|
|
496
582
|
_active: { state: true },
|
|
497
583
|
_slotted: { state: true },
|
|
498
584
|
_typing: { state: true },
|
|
@@ -507,19 +593,27 @@ CmCombobox.styles = [
|
|
|
507
593
|
:host { display: block; position: relative; }
|
|
508
594
|
.wrap { position: relative; }
|
|
509
595
|
.box {
|
|
510
|
-
display: flex;
|
|
511
|
-
|
|
596
|
+
display: flex; align-items: center; gap: var(--cm-space-8); width: 100%; min-height: var(--_cm-field-h);
|
|
597
|
+
/* One row of 24px tags sits centred in the 40px (32, 44) box; more rows grow it 28px each. */
|
|
598
|
+
padding-block: calc((var(--_cm-field-h) - var(--cm-space-24)) / 2 - var(--cm-border-1));
|
|
599
|
+
padding-inline: var(--_cm-field-pad) var(--cm-space-8);
|
|
512
600
|
background: var(--cm-bg-surface); border: var(--cm-border-1) solid var(--cm-border-input); border-radius: var(--cm-radius-sm); cursor: text;
|
|
513
601
|
}
|
|
514
|
-
|
|
602
|
+
/* Hover (1.6): the outline darkens; focus adds the 2px ring. */
|
|
603
|
+
:host(:not([disabled])) .box:hover { border-color: var(--cm-border-strong); }
|
|
515
604
|
.box:focus-within { border-color: var(--cm-border-strong); box-shadow: 0 0 0 1px var(--cm-border-strong); }
|
|
516
|
-
|
|
605
|
+
/* Tags and the text box wrap in rows; the chevron stays at the end, centred. */
|
|
606
|
+
.chips { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: var(--cm-space-4); }
|
|
607
|
+
.more::part(tag) { color: var(--cm-text-tertiary); background: var(--cm-bg-surface); border-style: dashed; }
|
|
517
608
|
input {
|
|
518
|
-
flex: 1 1 80px; min-width: 80px; height: 24px; padding: 0; border: 0; outline: none; background: none;
|
|
609
|
+
flex: 1 1 80px; min-width: 80px; width: 0; height: 24px; padding: 0; border: 0; outline: none; background: none;
|
|
519
610
|
font: inherit; font-size: var(--_cm-field-font); color: var(--cm-text-default);
|
|
520
611
|
}
|
|
612
|
+
.chips.has-tags input { flex-basis: 48px; min-width: 48px; }
|
|
613
|
+
/* Not focused: the empty text box takes no room of its own, so the tags keep to as few rows as they can. */
|
|
614
|
+
.chips.has-tags.idle input { flex-basis: 4px; min-width: 4px; }
|
|
521
615
|
input::placeholder { color: var(--cm-text-tertiary); }
|
|
522
|
-
.chev { flex: none;
|
|
616
|
+
.chev { flex: none; color: var(--cm-icon-selected); transition: transform var(--cm-duration-fast) var(--cm-easing-standard); }
|
|
523
617
|
:host([open]) .chev { transform: rotate(180deg); }
|
|
524
618
|
:host([error]:not([error=''])) .box { border-color: var(--cm-border-critical); }
|
|
525
619
|
:host([disabled]) .box { background: var(--cm-bg-input-filled); border-color: var(--cm-border-subtle); cursor: not-allowed; }
|