@commmerce/ui 1.2.0 → 1.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/dist/cdn.js +799 -549
- package/dist/components/board.d.ts +338 -0
- package/dist/components/board.js +1017 -0
- package/dist/components/card.d.ts +2 -1
- package/dist/components/card.js +16 -4
- package/dist/components/color-field.d.ts +153 -0
- package/dist/components/color-field.js +369 -0
- package/dist/components/combobox.d.ts +17 -4
- package/dist/components/combobox.js +55 -23
- package/dist/components/file-upload.d.ts +33 -0
- package/dist/components/file-upload.js +80 -9
- package/dist/components/global-search.js +2 -7
- package/dist/components/nested-list.d.ts +33 -1
- package/dist/components/nested-list.js +197 -18
- package/dist/components/option-group.d.ts +15 -6
- package/dist/components/option-group.js +25 -6
- package/dist/components/select.d.ts +20 -3
- package/dist/components/select.js +35 -11
- package/dist/custom-elements.json +3473 -781
- package/dist/index.d.ts +7 -0
- package/dist/index.js +3 -0
- package/dist/move-model.d.ts +93 -0
- package/dist/move-model.js +169 -0
- package/dist/popover.d.ts +24 -0
- package/dist/popover.js +59 -0
- package/package.json +3 -3
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
import { type PropertyValues } from 'lit';
|
|
2
|
+
import { CmLocalizedElement } from '../localize.js';
|
|
3
|
+
import './button.js';
|
|
4
|
+
import './skeleton.js';
|
|
5
|
+
import './spinner.js';
|
|
6
|
+
declare const cardStrings: {
|
|
7
|
+
/** What screen readers call a card, after its name: "Ravi Stores, movable card". */
|
|
8
|
+
roleDescription: string;
|
|
9
|
+
/** Read after the card's name and role (its description). */
|
|
10
|
+
instructions: string;
|
|
11
|
+
/** Added before `instructions` when the card opens a record (`href`, or a link or button in the `heading` slot). */
|
|
12
|
+
openHint: string;
|
|
13
|
+
/** Read while the move is being saved (`pending`). */
|
|
14
|
+
saving: string;
|
|
15
|
+
};
|
|
16
|
+
declare const columnStrings: {
|
|
17
|
+
/** Read after the column heading: "Contacted, 12 cards". `{count}` is `total`, or the number of cards loaded. */
|
|
18
|
+
count: {
|
|
19
|
+
one: string;
|
|
20
|
+
other: string;
|
|
21
|
+
};
|
|
22
|
+
/** The button at the end of a column that has more cards to load. */
|
|
23
|
+
loadMore: string;
|
|
24
|
+
/** Announced while `loading`. `{column}` is the heading. */
|
|
25
|
+
loading: string;
|
|
26
|
+
/** Shown in a column with no cards (when nothing is in the `empty` slot). */
|
|
27
|
+
empty: string;
|
|
28
|
+
};
|
|
29
|
+
declare const boardStrings: {
|
|
30
|
+
/** Accessible name of the board. */
|
|
31
|
+
label: string;
|
|
32
|
+
/** Announced on pick up. `{card}` card name, `{column}` heading, `{position}` and `{count}` the place in the column. */
|
|
33
|
+
pickedUp: string;
|
|
34
|
+
/** Announced as the arrow keys move the card. */
|
|
35
|
+
over: string;
|
|
36
|
+
/** Announced after a drop that moved the card. */
|
|
37
|
+
moved: string;
|
|
38
|
+
/** Announced after a drop where the card started. */
|
|
39
|
+
sameSpot: string;
|
|
40
|
+
/** Announced after Escape (or focus leaving the card) while it is picked up. */
|
|
41
|
+
cancelled: string;
|
|
42
|
+
/** Announced when the app cancels `cm-move` (`preventDefault()`). */
|
|
43
|
+
refused: string;
|
|
44
|
+
/** Announced when a move fails and the card goes back (`revert()`, or a rejected `waitUntil()` promise). `{column}` is where it went back to. */
|
|
45
|
+
reverted: string;
|
|
46
|
+
};
|
|
47
|
+
declare module '../localize.js' {
|
|
48
|
+
interface CmStrings {
|
|
49
|
+
board: typeof boardStrings;
|
|
50
|
+
boardColumn: typeof columnStrings;
|
|
51
|
+
boardCard: typeof cardStrings;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/** How a move was made: dragged with a pointer, moved with the keyboard, or by calling `moveCard()`. */
|
|
55
|
+
export type BoardMoveSource = 'pointer' | 'keyboard' | 'api';
|
|
56
|
+
/** `detail` of `cm-move`. */
|
|
57
|
+
export interface BoardMoveDetail {
|
|
58
|
+
/** The card's `value`. */
|
|
59
|
+
value: string;
|
|
60
|
+
/** The card element. */
|
|
61
|
+
card: CmBoardCard;
|
|
62
|
+
/** `value` of the column it leaves, and of the column it goes to (the same when reordering). */
|
|
63
|
+
from: string;
|
|
64
|
+
to: string;
|
|
65
|
+
/** The column elements. */
|
|
66
|
+
fromColumn: CmBoardColumn;
|
|
67
|
+
toColumn: CmBoardColumn;
|
|
68
|
+
/** Its position in the column it leaves, and its position in the column it goes to, once there (from 0). */
|
|
69
|
+
fromIndex: number;
|
|
70
|
+
toIndex: number;
|
|
71
|
+
/** How it was moved. */
|
|
72
|
+
source: BoardMoveSource;
|
|
73
|
+
/**
|
|
74
|
+
* Call with the promise that saves the move: the card shows as saving (`pending`) until it settles; if it rejects,
|
|
75
|
+
* the board puts the card back (`revert()`) and announces it. Call it during the event.
|
|
76
|
+
*/
|
|
77
|
+
waitUntil(promise: Promise<unknown>): void;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* One record on a `cm-board`: a title (`heading`, or a link in the `heading` slot), secondary lines, badges and an
|
|
81
|
+
* avatar. The whole card is the move handle: drag it, or focus it and press Space to move it with the keyboard.
|
|
82
|
+
* With `href` the title is a link and Enter on the card opens it.
|
|
83
|
+
* @element cm-board-card
|
|
84
|
+
* @slot - Secondary lines under the title (owner, phone, city), one element per line.
|
|
85
|
+
* @slot heading - Rich title instead of `heading`, e.g. a link. A link here is a second Tab stop; prefer `href`.
|
|
86
|
+
* @slot badges - `cm-badge`s (grade, tags) under the lines.
|
|
87
|
+
* @slot avatar - A `cm-avatar` for the owner, at the end of the title line.
|
|
88
|
+
* @slot actions - A small control at the end of the title line, e.g. a `cm-action-menu` with "Move to…". Pressing it never starts a drag.
|
|
89
|
+
* @csspart card - The card's box.
|
|
90
|
+
* @csspart handle - The focusable layer under the content that carries the card's name and instructions.
|
|
91
|
+
* @csspart title - The title.
|
|
92
|
+
*/
|
|
93
|
+
export declare class CmBoardCard extends CmLocalizedElement {
|
|
94
|
+
#private;
|
|
95
|
+
static shadowRootOptions: {
|
|
96
|
+
delegatesFocus: boolean;
|
|
97
|
+
mode: ShadowRootMode;
|
|
98
|
+
serializable?: boolean;
|
|
99
|
+
slotAssignment?: SlotAssignmentMode;
|
|
100
|
+
};
|
|
101
|
+
static properties: {
|
|
102
|
+
value: {
|
|
103
|
+
reflect: boolean;
|
|
104
|
+
};
|
|
105
|
+
label: {};
|
|
106
|
+
heading: {};
|
|
107
|
+
href: {};
|
|
108
|
+
locked: {
|
|
109
|
+
type: BooleanConstructor;
|
|
110
|
+
reflect: boolean;
|
|
111
|
+
};
|
|
112
|
+
pending: {
|
|
113
|
+
type: BooleanConstructor;
|
|
114
|
+
reflect: boolean;
|
|
115
|
+
};
|
|
116
|
+
moving: {
|
|
117
|
+
type: BooleanConstructor;
|
|
118
|
+
reflect: boolean;
|
|
119
|
+
};
|
|
120
|
+
_badges: {
|
|
121
|
+
state: boolean;
|
|
122
|
+
};
|
|
123
|
+
_slottedTitle: {
|
|
124
|
+
state: boolean;
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
/** Identifies the record in `cm-move` (e.g. its id). Defaults to the card's name. */
|
|
128
|
+
value: string;
|
|
129
|
+
/** The card's name, read by screen readers and in announcements ("Picked up Ravi Stores"). Defaults to `heading` or the `heading` slot's text. */
|
|
130
|
+
label: string;
|
|
131
|
+
/** The title: the record's name. */
|
|
132
|
+
heading: string;
|
|
133
|
+
/** Makes the title a link to the record. Enter on the focused card opens it too. */
|
|
134
|
+
href: string;
|
|
135
|
+
/** The card can't be moved (e.g. no permission). It can still be opened. */
|
|
136
|
+
locked: boolean;
|
|
137
|
+
/** The move is being saved: the card is greyed with a spinner and can't be moved again until it is cleared. Set by `waitUntil()` in `cm-move`, or by you. */
|
|
138
|
+
pending: boolean;
|
|
139
|
+
/** Set by the board while the card is picked up or dragged; it then marks where the card came from. Read it for styling; don't set it. */
|
|
140
|
+
moving: boolean;
|
|
141
|
+
_badges: boolean;
|
|
142
|
+
_slottedTitle: string;
|
|
143
|
+
static styles: import("lit").CSSResult[];
|
|
144
|
+
/** The card's name: `label`, `heading`, the `heading` slot's text, or its first line of text. */
|
|
145
|
+
get name(): string;
|
|
146
|
+
/** The value used in `cm-move`: `value`, or the name. */
|
|
147
|
+
get key(): string;
|
|
148
|
+
/** The link or button that opens the record: the `href` title, or the first link or button in the `heading` slot. */
|
|
149
|
+
get opener(): HTMLElement | null;
|
|
150
|
+
/** Focuses the card's handle (its single Tab stop), even when a control inside the card has focus. */
|
|
151
|
+
focusHandle(options?: FocusOptions): void;
|
|
152
|
+
/** Opens the record: clicks the `href` title or the link or button in the `heading` slot. Returns false when there is none. */
|
|
153
|
+
open(): boolean;
|
|
154
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* One column of a `cm-board`: a heading with its count, the cards as a list, and "Load more" when there are more
|
|
158
|
+
* cards than are loaded.
|
|
159
|
+
* @element cm-board-column
|
|
160
|
+
* @slot - `cm-board-card` elements, in order. Other children are not shown.
|
|
161
|
+
* @slot actions - A small control at the end of the heading row, e.g. an icon-only "Add" button.
|
|
162
|
+
* @slot empty - Shown in a column with no cards, instead of "No cards".
|
|
163
|
+
* @fires cm-load-more - When "Load more" is pressed. `detail: { column, value }`. Set `loading`, append the cards, then clear `loading` (and `has-more` on the last page).
|
|
164
|
+
* @csspart header - The heading row.
|
|
165
|
+
* @csspart count - The count.
|
|
166
|
+
* @csspart list - The `<ul>` of cards.
|
|
167
|
+
* @csspart more - The Load more button.
|
|
168
|
+
*/
|
|
169
|
+
export declare class CmBoardColumn extends CmLocalizedElement {
|
|
170
|
+
#private;
|
|
171
|
+
static shadowRootOptions: {
|
|
172
|
+
slotAssignment: SlotAssignmentMode;
|
|
173
|
+
delegatesFocus?: boolean;
|
|
174
|
+
mode: ShadowRootMode;
|
|
175
|
+
serializable?: boolean;
|
|
176
|
+
};
|
|
177
|
+
static properties: {
|
|
178
|
+
value: {
|
|
179
|
+
reflect: boolean;
|
|
180
|
+
};
|
|
181
|
+
heading: {};
|
|
182
|
+
total: {
|
|
183
|
+
type: NumberConstructor;
|
|
184
|
+
};
|
|
185
|
+
hasMore: {
|
|
186
|
+
type: BooleanConstructor;
|
|
187
|
+
attribute: string;
|
|
188
|
+
reflect: boolean;
|
|
189
|
+
};
|
|
190
|
+
loading: {
|
|
191
|
+
type: BooleanConstructor;
|
|
192
|
+
reflect: boolean;
|
|
193
|
+
};
|
|
194
|
+
headingLevel: {
|
|
195
|
+
type: NumberConstructor;
|
|
196
|
+
attribute: string;
|
|
197
|
+
};
|
|
198
|
+
_cards: {
|
|
199
|
+
state: boolean;
|
|
200
|
+
};
|
|
201
|
+
_drop: {
|
|
202
|
+
state: boolean;
|
|
203
|
+
};
|
|
204
|
+
};
|
|
205
|
+
/** Identifies the column in `cm-move` (e.g. the status id). Defaults to `heading`. */
|
|
206
|
+
value: string;
|
|
207
|
+
/** The column's name, e.g. the status "Contacted". */
|
|
208
|
+
heading: string;
|
|
209
|
+
/** How many cards the column has in all, when more than are loaded (shown as the count). Unset: the number of cards. The board keeps it in step when it moves cards. */
|
|
210
|
+
total?: number;
|
|
211
|
+
/** Shows "Load more", which fires `cm-load-more`. Also shown when `total` is more than the cards loaded. */
|
|
212
|
+
hasMore: boolean;
|
|
213
|
+
/** Cards are loading: Load more shows a spinner, or placeholder cards show in an empty column. Announced politely. */
|
|
214
|
+
loading: boolean;
|
|
215
|
+
/** Level of the heading for screen readers (2 to 6). */
|
|
216
|
+
headingLevel: number;
|
|
217
|
+
/** Whether the column is shown as a narrow rail: the board has `hide-empty` and the column is empty. Also the `collapsed` attribute, for styling. */
|
|
218
|
+
get collapsed(): boolean;
|
|
219
|
+
_cards: CmBoardCard[];
|
|
220
|
+
/** @internal The drop placeholder, set by the board while a card is moved. */
|
|
221
|
+
_drop: {
|
|
222
|
+
card: CmBoardCard;
|
|
223
|
+
index: number;
|
|
224
|
+
height: number;
|
|
225
|
+
} | null;
|
|
226
|
+
static styles: import("lit").CSSResult[];
|
|
227
|
+
connectedCallback(): void;
|
|
228
|
+
disconnectedCallback(): void;
|
|
229
|
+
/** The `cm-board-card` children, in order. */
|
|
230
|
+
get cards(): CmBoardCard[];
|
|
231
|
+
/** The column's `value`, or its heading. */
|
|
232
|
+
get key(): string;
|
|
233
|
+
/** The number shown in the heading: `total`, or the cards loaded. */
|
|
234
|
+
get count(): number;
|
|
235
|
+
/** @internal The element that scrolls the cards. */
|
|
236
|
+
get scrollElement(): HTMLElement | null;
|
|
237
|
+
/** @internal Reads the cards now (after the board moved one) and resolves once they are shown. */
|
|
238
|
+
_sync(): Promise<boolean>;
|
|
239
|
+
protected willUpdate(): void;
|
|
240
|
+
protected updated(): void;
|
|
241
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* A board of records by status (Kanban): one `cm-board-column` per status with its count, and `cm-board-card`s
|
|
245
|
+
* that move between columns, with a pointer (mouse, touch, pen) or with the keyboard.
|
|
246
|
+
*
|
|
247
|
+
* Moving: drag a card (on touch, press and hold first), or focus it and press Space, choose a column and position
|
|
248
|
+
* with the arrow keys, and drop with Space or Enter (Escape cancels). Every step is announced. Each move fires
|
|
249
|
+
* `cm-move`, which you can cancel. By default the board then moves the card element itself; with `controlled` it
|
|
250
|
+
* leaves the DOM to you (React, Vue, anything that renders from data).
|
|
251
|
+
*
|
|
252
|
+
* Columns are fixed-width side by side and the board scrolls sideways; when the board is 480px wide or less each
|
|
253
|
+
* column takes nearly the whole width and the board snaps from column to column. Give the board a height (CSS
|
|
254
|
+
* `height` or `block-size`) to make columns scroll on their own.
|
|
255
|
+
* @element cm-board
|
|
256
|
+
* @slot - `cm-board-column` elements, in order.
|
|
257
|
+
* @fires cm-move - Before a card moves. Cancelable: `preventDefault()` keeps it where it was. `detail: { value, card, from, to, fromColumn, toColumn, fromIndex, toIndex, source, waitUntil }` (see `BoardMoveDetail`). Pass the save request to `detail.waitUntil(promise)` to show the card as saving and put it back if the promise rejects.
|
|
258
|
+
* @fires cm-load-more - From a column's Load more button (bubbles from `cm-board-column`). `detail: { column, value }`.
|
|
259
|
+
* @csspart columns - The scrolling row of columns.
|
|
260
|
+
* @cssprop --cm-board-column-width - Width of each column on wide boards. Default 272px.
|
|
261
|
+
*/
|
|
262
|
+
export declare class CmBoard extends CmLocalizedElement {
|
|
263
|
+
#private;
|
|
264
|
+
static properties: {
|
|
265
|
+
label: {
|
|
266
|
+
string: string;
|
|
267
|
+
};
|
|
268
|
+
hideEmpty: {
|
|
269
|
+
type: BooleanConstructor;
|
|
270
|
+
attribute: string;
|
|
271
|
+
reflect: boolean;
|
|
272
|
+
};
|
|
273
|
+
controlled: {
|
|
274
|
+
type: BooleanConstructor;
|
|
275
|
+
reflect: boolean;
|
|
276
|
+
};
|
|
277
|
+
dragging: {
|
|
278
|
+
type: BooleanConstructor;
|
|
279
|
+
reflect: boolean;
|
|
280
|
+
};
|
|
281
|
+
};
|
|
282
|
+
/** Accessible name of the board, e.g. "Merchants by status". Default: the built-in string `label` ("Board"). */
|
|
283
|
+
label: string;
|
|
284
|
+
/** Empty columns shrink to a narrow rail (heading on its side and the count). Rails still take cards: drop on them or move to them with the keyboard. */
|
|
285
|
+
hideEmpty: boolean;
|
|
286
|
+
/**
|
|
287
|
+
* You move the cards: the board fires `cm-move` but never moves card elements or changes `total`. Re-render the
|
|
288
|
+
* card into its new column (and update totals) in your `cm-move` listener. Use it with React, Vue and other
|
|
289
|
+
* frameworks that render from data. `preventDefault()` still means the move was refused.
|
|
290
|
+
*/
|
|
291
|
+
controlled: boolean;
|
|
292
|
+
/** Set while a card is being dragged with a pointer. Read it for styling; don't set it. */
|
|
293
|
+
dragging: boolean;
|
|
294
|
+
constructor();
|
|
295
|
+
static styles: import("lit").CSSResult[];
|
|
296
|
+
/** The `cm-board-column` children, in order. */
|
|
297
|
+
get columns(): CmBoardColumn[];
|
|
298
|
+
/** The column with this `value` (or heading). */
|
|
299
|
+
column(value: string): CmBoardColumn | undefined;
|
|
300
|
+
/** The card with this `value` (or name), in any column. */
|
|
301
|
+
card(value: string): CmBoardCard | undefined;
|
|
302
|
+
/** The card picked up with the keyboard, if any. */
|
|
303
|
+
get heldCard(): CmBoardCard | null;
|
|
304
|
+
connectedCallback(): void;
|
|
305
|
+
disconnectedCallback(): void;
|
|
306
|
+
protected firstUpdated(): void;
|
|
307
|
+
protected updated(changed: PropertyValues): void;
|
|
308
|
+
/** The last message announced (for tests and logging). */
|
|
309
|
+
get announcement(): string;
|
|
310
|
+
/** Announces a message in the board's live region, e.g. after your own "Move to" menu. */
|
|
311
|
+
announce(text: string): void;
|
|
312
|
+
/** Picks up a card for moving with the arrow keys, as Space does: e.g. from a "Move" item in your own menu. Focuses the card. */
|
|
313
|
+
pickUp(card: CmBoardCard | string): boolean;
|
|
314
|
+
/** Cancels a keyboard move or a drag in progress: the card stays where it was. */
|
|
315
|
+
cancelMove(): void;
|
|
316
|
+
/**
|
|
317
|
+
* Moves a card to a column and position (default: the end), as a drop would: fires `cm-move`, and unless it is
|
|
318
|
+
* cancelled (or the board is `controlled`) moves the element. Use it for your own "Move to" menu. Returns false
|
|
319
|
+
* when the move was cancelled or the card or column was not found.
|
|
320
|
+
*/
|
|
321
|
+
moveCard(card: CmBoardCard | string, to: CmBoardColumn | string, index?: number): boolean;
|
|
322
|
+
/**
|
|
323
|
+
* Puts a card back where it was before its last move by the board, restores the two columns' `total`, clears
|
|
324
|
+
* `pending` and announces it. Call it when saving the move failed (a rejected `waitUntil()` promise does this
|
|
325
|
+
* for you). Does nothing with `controlled` (put it back in your data) or when the card has not moved. Returns
|
|
326
|
+
* whether the card went back.
|
|
327
|
+
*/
|
|
328
|
+
revert(card: CmBoardCard | string): boolean;
|
|
329
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
330
|
+
}
|
|
331
|
+
declare global {
|
|
332
|
+
interface HTMLElementTagNameMap {
|
|
333
|
+
'cm-board': CmBoard;
|
|
334
|
+
'cm-board-column': CmBoardColumn;
|
|
335
|
+
'cm-board-card': CmBoardCard;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
export {};
|