@gemboss/ui 0.68.0 → 0.69.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/CHANGELOG.md +148 -5
- package/README.md +89 -9
- package/catalog/editor.html +10 -8
- package/catalog/index.html +617 -566
- package/gemboss-ui.css +3 -3
- package/package.json +5 -2
- package/parts/components.css +1 -1
- package/parts/core.css +1 -1
- package/parts/shell.css +1 -1
- package/src/assistant/attachments.tsx +486 -0
- package/src/assistant/chat-cards.tsx +343 -0
- package/src/assistant/chat.tsx +29 -6
- package/src/assistant/host.tsx +8 -11
- package/src/assistant/index.ts +8 -1
- package/src/assistant-chat.css +1 -1
- package/src/assistant-plain.js +1 -1
- package/src/assistant.css +1 -1
- package/src/auth-field.css +1 -1
- package/src/auth.tsx +4 -2
- package/src/chat-attachments.css +1 -0
- package/src/chat-cards.css +1 -0
- package/src/chat-plain.js +5 -5
- package/src/collections.tsx +8 -1
- package/src/editor/controls.tsx +51 -10
- package/src/editor/field-frame.tsx +4 -10
- package/src/editor/index.ts +2 -4
- package/src/editor/inspector-frame.tsx +143 -32
- package/src/editor/items-field.tsx +8 -3
- package/src/editor/items.ts +30 -6
- package/src/editor/panel.tsx +4 -5
- package/src/editor-inspector-frame.css +1 -1
- package/src/editor-media.css +1 -0
- package/src/editor-plain.js +1 -1
- package/src/editor-rail.css +1 -1
- package/src/editor.css +1 -1
- package/src/email-editor/editor.tsx +96 -69
- package/src/email-editor.css +1 -1
- package/src/gem-at-work.css +1 -1
- package/src/gem-at-work.ts +177 -33
- package/src/gem-holo.css +1 -1
- package/src/icons.tsx +42 -0
- package/src/index-table-extras.css +1 -0
- package/src/index-table.tsx +37 -16
- package/src/menu.tsx +7 -3
- package/src/narration.css +1 -1
- package/src/selection.tsx +22 -12
- package/src/editor/chips.tsx +0 -24
- package/src/editor-chips.css +0 -1
package/src/index-table.tsx
CHANGED
|
@@ -13,12 +13,15 @@
|
|
|
13
13
|
* has no header), and Escape clears the selection.
|
|
14
14
|
* - Below 768 of ITS container the table folds into a list (collections.css): the title line, then the other cells on
|
|
15
15
|
* one caption line (`label` prefixes a value; `condensed: "hide"` leaves a cell out), checkbox and actions kept.
|
|
16
|
+
* - Column `width`, `wrap` and `showFrom`, and the classes `ui-index__when-table`, `ui-index__when-folded`, `ui-index__until-848`,
|
|
17
|
+
* are for a table with more columns than its room holds at one line each (index-table-extras.css, README "Collections").
|
|
16
18
|
*
|
|
17
19
|
* Every prop that describes the table is plain data (rows of rendered cells, `sortHref` strings), so a server
|
|
18
20
|
* component can render it; the callbacks (`onSort`, `onSelectionChange`, bulk `onAction`) need a client parent.
|
|
19
|
-
* Its own module, "use client":
|
|
21
|
+
* Its own module, "use client": the admin's budgeted first-load routes (the shell, the dashboard) do not pull it in.
|
|
20
22
|
*/
|
|
21
23
|
import "./collections.css"; // its own stylesheet travels with it (0.23.0): a surface that never renders it never loads it
|
|
24
|
+
import "./index-table-extras.css"; // what the table gained after collections.css reached its ceiling, born an entry
|
|
22
25
|
import React, { useEffect, useRef } from "react";
|
|
23
26
|
import { ariaSort, SortHeader, CollectionSkeleton, type CollectionColumn, type CollectionSort, type SortDirection, type SortLinkProps } from "./collections";
|
|
24
27
|
import { BulkBar, useSelection, type BulkAction } from "./selection";
|
|
@@ -45,6 +48,9 @@ export type IndexTableRow = {
|
|
|
45
48
|
cells: Record<string, React.ReactNode>;
|
|
46
49
|
/** One button and/or a ⋯ menu, at the end of the row. Never more than one visible button. */
|
|
47
50
|
actions?: React.ReactNode;
|
|
51
|
+
/** False: this row has no checkbox, and select-all and a Shift range pass over it (a row nothing can be done to, as a
|
|
52
|
+
* product that exists only as a sample). Its cell stays, so the columns line up. Default true. */
|
|
53
|
+
selectable?: boolean;
|
|
48
54
|
};
|
|
49
55
|
|
|
50
56
|
export type IndexTableProps = {
|
|
@@ -69,6 +75,13 @@ export type IndexTableProps = {
|
|
|
69
75
|
selectAllLabel?: string;
|
|
70
76
|
/** The ⋯ menu that takes the bulk actions which do not fit in the bar's row (0.33.0). */
|
|
71
77
|
moreActionsLabel?: string;
|
|
78
|
+
/** A bulk action is running: every box and action is off, Escape does not clear, and the bar says `bulkBusyLabel`. Answers
|
|
79
|
+
* arrive per row, so a selection changed halfway would no longer be what was pressed. */
|
|
80
|
+
bulkBusy?: boolean;
|
|
81
|
+
bulkBusyLabel?: React.ReactNode;
|
|
82
|
+
/** Keep select-all reachable where the table folds: the folded list has no header, so without this the box only appears
|
|
83
|
+
* once a row is ticked. Shows the bar, the box and `selectAllLabel`, from the first moment. Off by default. */
|
|
84
|
+
selectAllFolded?: boolean;
|
|
72
85
|
/** The link element for titles AND sort links (header and chips, 0.16.0): a Next `Link` from a client module, so
|
|
73
86
|
* opening a row and sorting both stay in the app instead of reloading the page. Default `<a>`. */
|
|
74
87
|
linkAs?: React.ElementType;
|
|
@@ -109,12 +122,18 @@ export function followRow(e: React.MouseEvent<HTMLElement>): void {
|
|
|
109
122
|
a.click();
|
|
110
123
|
}
|
|
111
124
|
|
|
125
|
+
/** A column's `width`, on its header cell. Also its floor: a table shares out its room by what cells can shrink to, so a width
|
|
126
|
+
* alone would give way to a column that fills. */
|
|
127
|
+
const widthStyle = (c: CollectionColumn): React.CSSProperties | undefined => (c.width == null || c.width === "fill" ? undefined : { width: c.width, minWidth: c.width });
|
|
128
|
+
|
|
112
129
|
export function IndexTable({ columns, mediaColumn, rows, label, sort, onSort, bulkActions, selected: selectedProp, onSelectionChange, selectedLabel = (n) => `${n} selected`,
|
|
113
|
-
selectAllLabel = "Select all", moreActionsLabel, linkAs: Link = "a", sortLinkProps, sortLabel = "Sort", state = "ready", stateSlot, loadingRows = 5, actionsColumn, flush, className }: IndexTableProps) {
|
|
114
|
-
|
|
115
|
-
|
|
130
|
+
selectAllLabel = "Select all", moreActionsLabel, bulkBusy, bulkBusyLabel, selectAllFolded, linkAs: Link = "a", sortLinkProps, sortLabel = "Sort", state = "ready", stateSlot, loadingRows = 5, actionsColumn, flush, className }: IndexTableProps) {
|
|
131
|
+
// Only the rows that can be picked take part in the selection. With rows and none of them pickable there is no box to draw:
|
|
132
|
+
// a checkbox column that selects nothing is the inert column this table exists to prevent.
|
|
133
|
+
const ids = rows.filter((r) => r.selectable !== false).map((r) => r.id);
|
|
134
|
+
const selectable = !!(bulkActions && bulkActions.length) && (rows.length === 0 || ids.length > 0);
|
|
116
135
|
// Own or controlled ids, Shift range, select-all, Escape (./selection: the same rules as SelectableResourceList).
|
|
117
|
-
const { rootRef, selSet, chosen, all, some, toggle, toggleAll } = useSelection<HTMLDivElement>(ids, selectedProp, onSelectionChange, selectable);
|
|
136
|
+
const { rootRef, selSet, chosen, all, some, toggle, toggleAll } = useSelection<HTMLDivElement>(ids, selectedProp, onSelectionChange, selectable && !bulkBusy);
|
|
118
137
|
const hasActions = rows.some((r) => r.actions);
|
|
119
138
|
const headBox = useRef<HTMLInputElement>(null);
|
|
120
139
|
useEffect(() => { if (headBox.current) headBox.current.indeterminate = some; }, [some]);
|
|
@@ -138,22 +157,22 @@ export function IndexTable({ columns, mediaColumn, rows, label, sort, onSort, bu
|
|
|
138
157
|
})}
|
|
139
158
|
</div>
|
|
140
159
|
) : null}
|
|
141
|
-
{selectable ? <BulkBar actions={bulkActions!} chosen={chosen} all={all} some={some} onToggleAll={toggleAll} selectedLabel={selectedLabel} selectAllLabel={selectAllLabel} moreActionsLabel={moreActionsLabel} idle="hide" /> : null}
|
|
160
|
+
{selectable ? <BulkBar actions={bulkActions!} chosen={chosen} all={all} some={some} onToggleAll={toggleAll} selectedLabel={selectedLabel} selectAllLabel={selectAllLabel} moreActionsLabel={moreActionsLabel} idle={selectAllFolded ? "fold" : "hide"} busy={!!bulkBusy} busyLabel={bulkBusyLabel} /> : null}
|
|
142
161
|
<div className={cx("ui-table-wrap", flush && "ui-table-wrap--flush")}>
|
|
143
162
|
<table className="ui-table ui-table--index">
|
|
144
163
|
<caption className="ui-sr-only">{label}</caption>
|
|
145
164
|
<thead>
|
|
146
165
|
<tr>
|
|
147
|
-
{selectable ? <th className="ui-table__check" scope="col"><label className="ui-table__checkbox"><input ref={headBox} type="checkbox" checked={all} aria-label={selectAllLabel} onChange={(e) => toggleAll(e.target.checked)} disabled={!showRows || !rows.length} /></label></th> : null}
|
|
166
|
+
{selectable ? <th className="ui-table__check" scope="col"><label className="ui-table__checkbox"><input ref={headBox} type="checkbox" checked={all} aria-label={selectAllLabel} onChange={(e) => toggleAll(e.target.checked)} disabled={!showRows || !rows.length || !!bulkBusy} /></label></th> : null}
|
|
148
167
|
{mediaColumn ? <th scope="col">{mediaColumn.header}</th> : null}
|
|
149
|
-
<th className="ui-table__primary" scope="col" aria-sort={ariaSort(primary, sort)}><SortHeader col={primary} sort={sort} onSort={onSort} linkAs={Link} linkProps={sortLinkProps} /></th>
|
|
150
|
-
{rest.map((c) => <th key={c.key} scope="col" className={c.numeric ? "is-num" : undefined} aria-sort={ariaSort(c, sort)}><SortHeader col={c} sort={sort} onSort={onSort} linkAs={Link} linkProps={sortLinkProps} /></th>)}
|
|
168
|
+
<th className={cx("ui-table__primary", primary.width === "fill" && "ui-table__primary--fill")} scope="col" style={widthStyle(primary)} aria-sort={ariaSort(primary, sort)}><SortHeader col={primary} sort={sort} onSort={onSort} linkAs={Link} linkProps={sortLinkProps} /></th>
|
|
169
|
+
{rest.map((c) => <th key={c.key} scope="col" className={c.numeric ? "is-num" : undefined} style={widthStyle(c)} data-show-from={c.showFrom} aria-sort={ariaSort(c, sort)}><SortHeader col={c} sort={sort} onSort={onSort} linkAs={Link} linkProps={sortLinkProps} /></th>)}
|
|
151
170
|
{hasActions ? <th className="ui-table__actions" scope="col"><span className="ui-sr-only">Actions</span></th> : null}
|
|
152
171
|
</tr>
|
|
153
172
|
</thead>
|
|
154
173
|
{showRows ? (
|
|
155
174
|
<tbody>
|
|
156
|
-
{rows.map((r
|
|
175
|
+
{rows.map((r) => {
|
|
157
176
|
const isSel = selSet.has(r.id);
|
|
158
177
|
const title = r.href
|
|
159
178
|
? <Link className="ui-table__title" href={r.href} target={r.target} rel={r.target === "_blank" ? "noopener" : undefined} title={r.titleText}>{r.title}</Link>
|
|
@@ -162,19 +181,21 @@ export function IndexTable({ columns, mediaColumn, rows, label, sort, onSort, bu
|
|
|
162
181
|
<tr key={r.id} className={cx(r.href && "is-linked", isSel && "is-selected")} aria-selected={selectable ? isSel : undefined} onClick={r.href ? followRow : undefined} onAuxClick={r.href ? followRow : undefined}>
|
|
163
182
|
{selectable ? (
|
|
164
183
|
<td className="ui-table__check" onClick={(e) => { if (e.target === e.currentTarget) (e.currentTarget.querySelector("input") as HTMLInputElement | null)?.click(); }}>
|
|
165
|
-
|
|
166
|
-
<
|
|
167
|
-
|
|
168
|
-
|
|
184
|
+
{r.selectable === false ? null : (
|
|
185
|
+
<label className="ui-table__checkbox">
|
|
186
|
+
<input type="checkbox" checked={isSel} disabled={!!bulkBusy} aria-label={`Select ${r.titleText ?? (typeof r.title === "string" ? r.title : r.id)}`}
|
|
187
|
+
onChange={(e) => toggle(ids.indexOf(r.id), e.target.checked, (e.nativeEvent as MouseEvent).shiftKey)} />
|
|
188
|
+
</label>
|
|
189
|
+
)}
|
|
169
190
|
</td>
|
|
170
191
|
) : null}
|
|
171
192
|
{mediaColumn ? <td data-condensed="hide">{r.media}</td> : null}
|
|
172
|
-
<td className={cx("ui-table__primary", primary.wrap && "ui-table__primary--wrap")} style={primary.truncate != null ? ({ ["--ui-trunc" as string]: typeof primary.truncate === "number" ? `${primary.truncate}px` : primary.truncate } as React.CSSProperties) : undefined}>
|
|
193
|
+
<td className={cx("ui-table__primary", primary.wrap && "ui-table__primary--wrap", primary.width === "fill" && "ui-table__primary--fill")} style={primary.truncate != null ? ({ ["--ui-trunc" as string]: typeof primary.truncate === "number" ? `${primary.truncate}px` : primary.truncate } as React.CSSProperties) : undefined}>
|
|
173
194
|
{r.media && !mediaColumn ? <div className="ui-table__primary-inner">{r.media}<div className="ui-table__primary-text">{title}{r.sub ? <span className="ui-sub">{r.sub}</span> : null}</div></div>
|
|
174
195
|
: <>{title}{r.sub ? <span className="ui-sub">{r.sub}</span> : null}</>}
|
|
175
196
|
</td>
|
|
176
197
|
{rest.map((c) => (
|
|
177
|
-
<td key={c.key} className={c.numeric
|
|
198
|
+
<td key={c.key} className={cx(c.numeric && "is-num", c.wrap && "ui-table__cell--wrap") || undefined} data-label={c.label} data-condensed={c.condensed === "hide" ? "hide" : undefined} data-show-from={c.showFrom}>
|
|
178
199
|
{c.truncate != null ? <span className="ui-trunc" style={{ ["--ui-trunc" as string]: typeof c.truncate === "number" ? `${c.truncate}px` : c.truncate } as React.CSSProperties}>{r.cells[c.key]}</span> : r.cells[c.key]}
|
|
179
200
|
</td>
|
|
180
201
|
))}
|
package/src/menu.tsx
CHANGED
|
@@ -27,8 +27,11 @@ import { chooseRow, closeMenu, focusRow, menuKeyDown, menuRows, openMenu, regist
|
|
|
27
27
|
* its name, `label` still names the list.
|
|
28
28
|
* `select` (04/11/2026, GemX New moment ubm-PZ-4w / 4t): a FIELD trigger instead, as wide as its column, the current choice and a
|
|
29
29
|
* chevron: a choice whose rows say more than an `<option>` can (parts, a mark, a line under the words, a row off with "Later").
|
|
30
|
-
* Named "label: choice" when the choice is words.
|
|
31
|
-
|
|
30
|
+
* Named "label: choice" when the choice is words.
|
|
31
|
+
* `ghost` (10/11/2026): the ⋯ without its border and fill, as the buttons beside it on a toolbar of ghost buttons (the funnel
|
|
32
|
+
* board's step toolbar: Edit page, Remove step, then ⋯). The icon trigger only: a `text` trigger is already drawn as a link and
|
|
33
|
+
* a `select` one is a field, so neither takes it. */
|
|
34
|
+
export function Menu({ label, icon, text, select, end, children, className, disabled, loading, ghost }: {
|
|
32
35
|
label: string;
|
|
33
36
|
icon?: React.ReactNode;
|
|
34
37
|
text?: React.ReactNode;
|
|
@@ -38,6 +41,7 @@ export function Menu({ label, icon, text, select, end, children, className, disa
|
|
|
38
41
|
className?: string;
|
|
39
42
|
disabled?: boolean;
|
|
40
43
|
loading?: boolean;
|
|
44
|
+
ghost?: boolean;
|
|
41
45
|
}) {
|
|
42
46
|
const ref = useRef<HTMLDetailsElement>(null);
|
|
43
47
|
const off = Boolean(disabled || loading);
|
|
@@ -86,7 +90,7 @@ export function Menu({ label, icon, text, select, end, children, className, disa
|
|
|
86
90
|
<svg className="ui-menu__chevron" viewBox="0 0 20 20" width="16" height="16" aria-hidden="true"><path d="M6 8l4 4 4-4" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" /></svg>
|
|
87
91
|
</summary>
|
|
88
92
|
) : (
|
|
89
|
-
<summary className={text ? "ui-btn ui-menu__trigger" : "ui-btn ui-btn--icon"} aria-label={text ? undefined : label} title={text ? undefined : label}
|
|
93
|
+
<summary className={[text ? "ui-btn ui-menu__trigger" : "ui-btn ui-btn--icon", ghost && !text ? "ui-btn--ghost" : ""].filter(Boolean).join(" ")} aria-label={text ? undefined : label} title={text ? undefined : label}
|
|
90
94
|
aria-haspopup="menu" onClick={onSummary} aria-disabled={off || undefined} aria-busy={loading || undefined} tabIndex={off ? -1 : undefined}>
|
|
91
95
|
{loading ? <span className="ui-menu__busy" aria-hidden="true" />
|
|
92
96
|
: text ? <>{icon ? <span className="ui-menu__trigger-icon" aria-hidden="true">{icon}</span> : null}{text}</>
|
package/src/narration.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.gemboss-narr-link{font:inherit;color:inherit;background:none;border:0;padding:0 4px;margin:0 -4px;border-radius:4px;text-align:start;cursor:pointer;min-height:24px}.gemboss-narr-link:hover,.gemboss-narr-link:focus-visible{text-decoration:underline;text-underline-offset:2px}.gemboss-narr-link:active{background:var(--gemboss-active-bg)}.gemboss-narr-link:focus-visible{outline:2px solid var(--ui-focus, #5661f5);outline-offset:0}.gemboss-narr-undo{margin-inline-start:auto;flex:0 0 auto;font:inherit;font-size:var(--gemboss-fs-caption);color:var(--gemboss-text-muted);background:none;border:0;padding:0 4px;border-radius:4px;min-height:24px;cursor:pointer;opacity:0;pointer-events:none}.gemboss-narr-row:hover .gemboss-narr-undo,.gemboss-narr-row:focus-within .gemboss-narr-undo,.gemboss-narr-undo[aria-busy=true]{opacity:1;pointer-events:auto}.gemboss-narr-undo:hover{color:var(--gemboss-text);text-decoration:underline;text-underline-offset:2px}.gemboss-narr-undo:active{background:var(--gemboss-active-bg)}.gemboss-narr-undo:focus-visible{outline:2px solid var(--ui-focus, #5661f5);outline-offset:0}.gemboss-narr-undo:disabled{cursor:default}.gemboss-narr-row:has(>.gemboss-narr-undo-said){flex-wrap:wrap}.gemboss-narr-undo-said{flex:1 0 100%;padding-inline-start:24px;font-size:var(--gemboss-fs-caption);color:var(--gemboss-text-muted)}@media (pointer: coarse),(max-width:47.9975em){.gemboss-narr-undo{opacity:1;pointer-events:auto;min-height:44px}}.gemboss-narr-plan{list-style:none;margin:0;padding:8px 12px;border:1px solid var(--gemboss-divider);border-radius:8px;background:var(--gemboss-surface, #fff)}.gemboss-narr-plan-head{margin:0 0 4px;font-size:var(--gemboss-fs-caption);font-weight:600;color:var(--gemboss-text)}.gemboss-narr-plan-count{font-weight:400;color:var(--gemboss-text-muted)}.gemboss-narr-plan-steps{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:4px}.gemboss-narr-plan-step{display:flex;gap:8px;align-items:
|
|
1
|
+
.gemboss-narr-link{font:inherit;color:inherit;background:none;border:0;padding:0 4px;margin:0 -4px;border-radius:4px;text-align:start;cursor:pointer;min-height:24px}.gemboss-narr-link:hover,.gemboss-narr-link:focus-visible{text-decoration:underline;text-underline-offset:2px}.gemboss-narr-link:active{background:var(--gemboss-active-bg)}.gemboss-narr-link:focus-visible{outline:2px solid var(--ui-focus, #5661f5);outline-offset:0}.gemboss-narr-undo{margin-inline-start:auto;flex:0 0 auto;font:inherit;font-size:var(--gemboss-fs-caption);color:var(--gemboss-text-muted);background:none;border:0;padding:0 4px;border-radius:4px;min-height:24px;cursor:pointer;opacity:0;pointer-events:none}.gemboss-narr-row:hover .gemboss-narr-undo,.gemboss-narr-row:focus-within .gemboss-narr-undo,.gemboss-narr-undo[aria-busy=true]{opacity:1;pointer-events:auto}.gemboss-narr-undo:hover{color:var(--gemboss-text);text-decoration:underline;text-underline-offset:2px}.gemboss-narr-undo:active{background:var(--gemboss-active-bg)}.gemboss-narr-undo:focus-visible{outline:2px solid var(--ui-focus, #5661f5);outline-offset:0}.gemboss-narr-undo:disabled{cursor:default}.gemboss-narr-row:has(>.gemboss-narr-undo-said){flex-wrap:wrap}.gemboss-narr-undo-said{flex:1 0 100%;padding-inline-start:24px;font-size:var(--gemboss-fs-caption);color:var(--gemboss-text-muted)}@media (pointer: coarse),(max-width:47.9975em){.gemboss-narr-undo{opacity:1;pointer-events:auto;min-height:44px}}.gemboss-narr-plan{list-style:none;margin:0;padding:8px 12px;border:1px solid var(--gemboss-divider);border-radius:8px;background:var(--gemboss-surface, #fff)}.gemboss-narr-plan-head{margin:0 0 4px;font-size:var(--gemboss-fs-caption);font-weight:600;color:var(--gemboss-text)}.gemboss-narr-plan-count{font-weight:400;color:var(--gemboss-text-muted)}.gemboss-narr-plan-steps{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:4px}.gemboss-narr-plan-step{display:flex;gap:8px;align-items:flex-start;font-size:var(--gemboss-fs-caption);color:var(--gemboss-text-muted)}.gemboss-narr-plan-step.done{color:var(--gemboss-text)}.gemboss-narr-plan-step.current{color:var(--gemboss-text);font-weight:600}.gemboss-narr-plan-mark{flex:0 0 16px;margin-top:2px}.gemboss-narr-plan-wait,.gemboss-narr-steer-note{font-weight:400;color:var(--gemboss-text-muted)}.gemboss-narr-row.steer.failed .gemboss-narr-steer-note{color:var(--gemboss-danger)}
|
package/src/selection.tsx
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* No "use client" of its own: only the two client modules import it (a server graph never reaches its hooks).
|
|
9
9
|
*/
|
|
10
10
|
import "./collections.css"; // its own stylesheet travels with it (0.23.0): a surface that never renders it never loads it
|
|
11
|
-
import React, { useCallback, useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
11
|
+
import React, { useCallback, useEffect, useId, useLayoutEffect, useRef, useState } from "react";
|
|
12
12
|
import { Icon } from "./icons";
|
|
13
13
|
import { Menu, MenuItem } from "./menu";
|
|
14
14
|
|
|
@@ -83,11 +83,17 @@ const btnClass = (b: BulkAction) => (b.tone === "critical" ? "ui-btn ui-btn--sm
|
|
|
83
83
|
* short actions stay buttons at 320 and five long ones fold at 768. Before, the bar wrapped: talent-radar /pool's five
|
|
84
84
|
* actions made it three rows (~150px) at 390, every row of the list pushed down by it (10/10/2026). Until the first
|
|
85
85
|
* measure (a server render, before hydration) the row does not wrap either; what does not fit is clipped for that
|
|
86
|
-
* moment instead of pushing the list down and back up.
|
|
87
|
-
|
|
86
|
+
* moment instead of pushing the list down and back up.
|
|
87
|
+
*
|
|
88
|
+
* `idle="fold"`: as "hide" while the table has its header, but where it folds (and the header is gone) the bar stays, as the
|
|
89
|
+
* box and its words, so everything can be ticked before anything is. `busy`: a press is running, so the box and every action
|
|
90
|
+
* are off and the count says so. */
|
|
91
|
+
export function BulkBar({ actions, chosen, all, some, onToggleAll, selectedLabel, selectAllLabel, idle, boxDisabled, moreActionsLabel = "More actions", busy, busyLabel = "Working…" }: {
|
|
88
92
|
actions: BulkAction[]; chosen: string[]; all: boolean; some: boolean; onToggleAll: (on: boolean) => void;
|
|
89
|
-
selectedLabel: (n: number) => React.ReactNode; selectAllLabel: string; idle: "hide" | "disable"; boxDisabled?: boolean; moreActionsLabel?: string
|
|
93
|
+
selectedLabel: (n: number) => React.ReactNode; selectAllLabel: string; idle: "hide" | "disable" | "fold"; boxDisabled?: boolean; moreActionsLabel?: string;
|
|
94
|
+
busy?: boolean; busyLabel?: React.ReactNode }) {
|
|
90
95
|
const box = useRef<HTMLInputElement>(null);
|
|
96
|
+
const boxId = useId();
|
|
91
97
|
const bar = useRef<HTMLDivElement>(null), measure = useRef<HTMLSpanElement>(null);
|
|
92
98
|
// How many actions are buttons; null = not measured yet. One action never folds (a menu of one is a button in a box).
|
|
93
99
|
const [shown, setShown] = useState<number | null>(null);
|
|
@@ -113,25 +119,29 @@ export function BulkBar({ actions, chosen, all, some, onToggleAll, selectedLabel
|
|
|
113
119
|
ro.observe(el);
|
|
114
120
|
ro.observe(m);
|
|
115
121
|
return () => ro.disconnect();
|
|
116
|
-
}, [n, actions.length, folds]);
|
|
117
|
-
const off = idle === "disable" && n === 0;
|
|
122
|
+
}, [n, actions.length, folds, busy]);
|
|
123
|
+
const off = (idle === "disable" && n === 0) || !!busy;
|
|
124
|
+
// "fold" with nothing ticked is only the way to tick everything: there is nothing yet for an action to act on.
|
|
125
|
+
const onlyBox = idle === "fold" && n === 0;
|
|
118
126
|
const k = folds ? shown ?? actions.length : actions.length;
|
|
119
127
|
return (
|
|
120
|
-
<div className="ui-bulkbar" ref={bar} hidden={idle === "hide" && n === 0} data-fit={folds && shown === null ? "pending" : undefined}>
|
|
121
|
-
<label className="ui-table__checkbox"><input ref={box} type="checkbox" checked={all} aria-label={selectAllLabel} disabled={boxDisabled} onChange={(e) => onToggleAll(e.target.checked)} /></label>
|
|
122
|
-
|
|
123
|
-
<
|
|
128
|
+
<div className="ui-bulkbar" ref={bar} hidden={idle === "hide" && n === 0} data-idle={onlyBox ? "fold" : undefined} data-fit={folds && shown === null ? "pending" : undefined}>
|
|
129
|
+
<label className="ui-table__checkbox"><input ref={box} id={boxId} type="checkbox" checked={all} aria-label={selectAllLabel} disabled={boxDisabled || busy} onChange={(e) => onToggleAll(e.target.checked)} /></label>
|
|
130
|
+
{/* Alone in the bar these words are the box's label: pressing them does what they say. */}
|
|
131
|
+
{onlyBox ? <label className="ui-bulkbar__count" htmlFor={boxId}>{selectAllLabel}</label>
|
|
132
|
+
: <span className="ui-bulkbar__count" aria-live="polite">{selectedLabel(n)}{busy ? <> · {busyLabel}</> : null}</span>}
|
|
133
|
+
{onlyBox ? null : <span className="ui-bulkbar__actions">
|
|
124
134
|
{actions.slice(0, k).map((b, i) => (
|
|
125
135
|
<button key={i} type="button" className={btnClass(b)} disabled={off} onClick={() => b.onAction(chosen)}>{b.content}</button>
|
|
126
136
|
))}
|
|
127
137
|
{k < actions.length ? (
|
|
128
|
-
<Menu label={moreActionsLabel} end className="ui-bulkbar__more">
|
|
138
|
+
<Menu label={moreActionsLabel} end className="ui-bulkbar__more" disabled={busy}>
|
|
129
139
|
{actions.slice(k).map((b, i) => (
|
|
130
140
|
<MenuItem key={k + i} danger={b.tone === "critical"} disabled={off} onClick={() => b.onAction(chosen)}>{b.content}</MenuItem>
|
|
131
141
|
))}
|
|
132
142
|
</Menu>
|
|
133
143
|
) : null}
|
|
134
|
-
</span>
|
|
144
|
+
</span>}
|
|
135
145
|
{folds ? (
|
|
136
146
|
// The ruler: every action as a button plus the ⋯ trigger, invisible, out of the flow and of the tab order.
|
|
137
147
|
<span className="ui-bulkbar__measure" ref={measure} aria-hidden="true">
|
package/src/editor/chips.tsx
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
// GROUPS AS CHIPS (Control UI C32 slice 3, 31/10/2026; Chris chose "cả hai: gộp + lối tắt"). An element's settings are one long list
|
|
2
|
-
// (C32), and the shared groups that hold nothing (Size, Shape, Effects, Align folded; Background, Hover not added) stacked one 37px
|
|
3
|
-
// line each above Spacing. In a run of groups, a group the caller marks `data-chip` is drawn as a chip: its own first line (a folded
|
|
4
|
-
// group's header, a + line's button) as a pill, side by side with the others, wrapping; every other group keeps the full width.
|
|
5
|
-
//
|
|
6
|
-
// · `div.gemboss-ei-chips` › the groups, in their own order › `.gemboss-ei-grp[data-chip]` › its head as the pill (no chevron).
|
|
7
|
-
// · Pressed, a chip does what its line does (opens the group, adds it); the caller takes the mark off and the group draws whole
|
|
8
|
-
// IN ITS PLACE. The group stays the same element under the same parent, so it is not drawn again from nothing and the focus stays
|
|
9
|
-
// on it: a row of chips in a box of its own made every chip pressed a new element, and the focus fell to the page.
|
|
10
|
-
// · 28px under a mouse, 44px under a finger; 8px apart.
|
|
11
|
-
// Its own part (`editor-chips.css`): only a surface that draws chips loads it.
|
|
12
|
-
import "../editor-chips.css";
|
|
13
|
-
import type React from "react";
|
|
14
|
-
|
|
15
|
-
export interface InspectorChipsProps {
|
|
16
|
-
/** `data-*` attributes on the run itself: what a page finds it by. */
|
|
17
|
-
attrs?: Record<`data-${string}`, string>;
|
|
18
|
-
/** Inspector groups (`InspectorGroup`, or a line of the caller's that is a `.gemboss-ei-grp`); `data-chip` on one draws it as a chip. */
|
|
19
|
-
children?: React.ReactNode;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export function InspectorChips({ attrs, children }: InspectorChipsProps) {
|
|
23
|
-
return <div className="gemboss-ei-chips" {...attrs}>{children}</div>;
|
|
24
|
-
}
|
package/src/editor-chips.css
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
.gemboss-ei-chips{display:flex;flex-wrap:wrap;align-items:flex-start;column-gap:8px}.gemboss-ei-chips>*{flex:1 0 100%;min-width:0}.gemboss-ei-chips>.gemboss-ei-grp:last-child:not([data-chip]){border-bottom:1px solid var(--gemboss-divider-soft,#eceef2)}.gemboss-ei-chips>[data-chip]{flex:none;margin:8px 0 0;padding:0;border:0}.gemboss-ei-chips>[data-chip]:last-child{margin-bottom:8px}.gemboss-ei-chips>[data-chip]>:first-child{display:inline-flex;align-items:center;gap:4px;width:auto;min-height:28px;margin:0;padding:0 12px;border:1px solid var(--gemboss-divider,#e5e7ea);border-radius:999px;background:var(--gemboss-surface,#fff);color:var(--gemboss-text,#1b1c1e);font-size:13px;line-height:16px;font-weight:400}.gemboss-ei-chips>[data-chip]>:first-child:hover:not(:disabled){background:var(--gemboss-hover,#eceef2)}.gemboss-ei-chips>[data-chip] .gemboss-ei-chev{display:none}@media (pointer: coarse),(max-width:47.9975em){.gemboss-ei-chips>[data-chip]>:first-child{min-height:44px}}
|