@gemboss/ui 0.52.0 → 0.55.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 +78 -0
- package/README.md +74 -55
- package/catalog/editor.html +1 -1
- package/catalog/index.html +711 -315
- package/gemboss-ui.css +2 -2
- package/package.json +1 -1
- package/parts/components.css +1 -1
- package/parts/core.css +1 -1
- package/parts/shell.css +1 -1
- package/src/assistant/engine-settings.tsx +11 -8
- package/src/assistant/engine.tsx +129 -394
- package/src/assistant/index.ts +3 -2
- package/src/assistant-engine.css +1 -1
- package/src/auth.tsx +41 -13
- package/src/dialog.tsx +34 -5
- package/src/editor/picker-grid.tsx +5 -2
- package/src/editor/picker.tsx +40 -26
- package/src/editor/popover.tsx +2 -1
- package/src/editor-insert.css +1 -1
- package/src/editor-picker.css +1 -1
- package/src/engine-plain.js +1 -1
- package/src/escape.ts +16 -0
package/src/assistant/index.ts
CHANGED
|
@@ -4,8 +4,9 @@ export { AssistantHost, AssistantMenuItem, type AssistantHostLabels, type Assist
|
|
|
4
4
|
export { AssistantProvider, SIDE_WIDTH_VAR, useAssistant, useAssistantPageFacts, type AssistantDockApi, type AssistantOptions } from "./provider";
|
|
5
5
|
export * from "./dock";
|
|
6
6
|
export { AssistantWorkspaceLayout, OpenChatTabs, SessionRail, SESSION_RAIL_EN, groupSessions, normalizeForSearch, relativeTime, type AssistantSession, type SessionGroup, type SessionRailIcons, type SessionRailLabels } from "./sessions";
|
|
7
|
-
export { BRIDGE_TONE, BridgeNotice, ENGINE_PICKER_EN,
|
|
8
|
-
//
|
|
7
|
+
export { BRIDGE_TONE, BridgeNotice, ENGINE_PICKER_EN, EnginePicker, engineChipName, engineMarkOf, useEnginePicker, type BridgeSetup, type BridgeState, type BridgeStatus, type Choice, type EngineChoice, type EnginePickerLabels, type EnginePickerProps, type EnginePickerTab } from "./engine";
|
|
8
|
+
// The engine in the surface's Settings ("AI & engines", 0.52.0; the only place since 0.53.0): the chip opens it
|
|
9
|
+
// (`onOpenSettings`), the section draws it.
|
|
9
10
|
export { EngineSettings, EngineSettingsSection, type EngineSettingsProps } from "./engine-settings";
|
|
10
11
|
// 0.29.0: the chat BODY as components (the surface hands in messages and actions), its markdown, and each engine's mark.
|
|
11
12
|
export { AssistantChat, ChatAttach, ChatBubble, ChatComposer, ChatError, ChatLabelsProvider, ChatMarkdown, ChatMessage, ChatMeta, ChatNote, ChatPending, ChatStarters, ChatSteps, ChatThread, CHAT_EN, PaperclipIcon, firstBlank, selectBlank, useComposerDensity, useFullChromeRoom, type AssistantChatProps, type ChatComposerProps, type ChatFix, type ChatLabels, type ChatMarkdownProps, type ChatMessageData, type ChatStarter, type ChatStep, type ComposerDensity } from "./chat";
|
package/src/assistant-engine.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.gb-engine{display:inline-flex;min-width:0;max-width:100%}.gb-engine-chip{display:inline-flex;align-items:center;gap:6px;min-width:0;max-width:100%;box-sizing:border-box;height:var(--ui-btn-h, 28px);padding:0 24px 0 8px;font:inherit;font-size:var(--ui-fs-caption, 12px);font-weight:500;line-height:20px;white-space:nowrap;color:var(--ui-text-muted);background-color:transparent;border:1px solid transparent;border-radius:var(--ui-radius-md, 8px);cursor:pointer;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23686b71' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");background-repeat:no-repeat;background-position:right 8px center}@media (hover: hover){.gb-engine-chip:hover{color:var(--ui-text);background-color:var(--gemboss-hover, rgba(0,0,0,.05))}}@media (hover: none){.gb-engine-chip{color:var(--ui-text)}}.gb-engine-chip[aria-expanded=true]{color:var(--ui-text);background-color:var(--gemboss-hover, rgba(0,0,0,.05))}.gb-engine-chip:focus-visible{color:var(--ui-text);outline:2px solid var(--ui-focus);outline-offset:2px}.gb-engine-chiplabel{min-width:0;overflow:hidden;text-overflow:ellipsis}.gb-engine-chipsub{font-weight:450}.gb-engine-chip:disabled{cursor:default;opacity:.55}.gemboss-engine-mark{display:block;width:14px;height:14px;flex:0 0 auto}.gb-engine-chipmark{display:none}.gb-engine-chipmark .gemboss-engine-mark{width:16px;height:16px}.gemboss-ec-input:not([data-density=full]) .gb-engine-chipsub{display:none}.gemboss-ec-input:is([data-density=icon],[data-density=tight]) .gb-engine-chip.has-mark .gb-engine-chiplabel{display:none}.gemboss-ec-input:is([data-density=icon],[data-density=tight]) .gb-engine-chip.has-mark .gb-engine-chipmark{display:block}.gemboss-ec-input:is([data-density=icon],[data-density=tight]) .gb-engine:has(.has-mark){flex-shrink:0}.gb-engine-dot{flex:none;display:inline-block;width:8px;height:8px;border-radius:50%;background:var(--ui-text-muted);vertical-align:middle}.gb-engine-dot--ok{background:var(--gemboss-success, #007f5f)}.gb-engine-dot--warn{background:#e8a10a;box-shadow:0 0 0 1px var(--gemboss-warning, #9a6700) inset}.gb-engine-dot--down{background:var(--gemboss-danger, #d72c0d)}.gb-engine-dot--idle{background:transparent;box-shadow:0 0 0 1.5px var(--ui-text-muted) inset}.gb-engine-panel{position:fixed;z-index:1000;inset:auto;margin:0;width:min(360px,calc(100vw - 16px));box-sizing:border-box;overflow:auto;overscroll-behavior:contain;padding:0 0 var(--ui-space-3, 12px);color:var(--ui-text);font-size:var(--ui-fs-caption, 12px);line-height:16px}.gb-engine-panel[hidden],.gb-engine-panel[popover]:not(:popover-open):not([data-open]){display:none}:where(.gb-engine-panel[popover]){border:0;background:none;color:inherit}.gb-engine-panel--inline{position:static;z-index:auto;overflow:visible}.gb-engine-tabs{padding:0 var(--ui-space-2, 8px)}.gb-engine-tabs>button{gap:6px}.gb-engine-pane{display:grid;gap:var(--ui-space-3, 12px);padding:var(--ui-space-3, 12px) var(--ui-space-3, 12px) 0}.gb-engine-pane p{margin:0}.gb-engine-field{display:grid;gap:6px}.gb-engine-label{font-weight:550;color:var(--ui-text-strong, var(--ui-text))}.gb-engine-note{color:var(--ui-text-muted)}.gb-engine-list{display:grid;border:1px solid var(--ui-border);border-radius:var(--ui-radius-md, 8px);overflow:hidden}.gb-engine-row{display:grid;gap:2px;min-height:44px;padding:6px 10px 6px 32px;box-sizing:border-box;position:relative;font:inherit;text-align:left;color:inherit;background:transparent;border:0;cursor:pointer}.gb-engine-row+.gb-engine-row{border-top:1px solid var(--ui-border)}.gb-engine-row:before{content:"";position:absolute;left:10px;top:50%;width:14px;height:14px;margin-top:-7px;box-sizing:border-box;border:1.5px solid var(--ui-text-muted);border-radius:50%}.gb-engine-row[aria-checked=true]{background:var(--gemboss-active-bg, #f0f1f4)}.gb-engine-row[aria-checked=true]:before{border:4.5px solid var(--ui-accent)}.gb-engine-row[aria-checked=true] .gb-engine-rowname{font-weight:600}@media (hover: hover){.gb-engine-row:hover:not(:disabled){background:var(--ui-surface-2)}}.gb-engine-row:focus-visible{outline:2px solid var(--ui-focus);outline-offset:-2px}.gb-engine-row:disabled{cursor:not-allowed}.gb-engine-row:disabled .gb-engine-rowname{color:var(--ui-text-muted)}.gb-engine-rowhead{display:flex;align-items:center;gap:var(--ui-space-2, 8px);min-width:0}.gb-engine-rowname{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:450}.gb-engine-opts{display:flex;flex-wrap:wrap;gap:var(--ui-space-2, 8px)}.gb-engine-opt{height:var(--ui-btn-h, 28px);padding:0 10px;box-sizing:border-box;font:inherit;font-weight:500;color:var(--ui-text);background:transparent;border:1px solid var(--ui-border);border-radius:var(--ui-radius-md, 8px);cursor:pointer}@media (hover: hover){.gb-engine-opt:hover:not(:disabled){background:var(--ui-surface-2)}}.gb-engine-opt[aria-pressed=true]{background:var(--gemboss-active-bg, #f0f1f4);border-color:var(--ui-text);font-weight:600}.gb-engine-opt:focus-visible{outline:2px solid var(--ui-focus);outline-offset:2px}.gb-engine-opt:disabled{opacity:.5;cursor:not-allowed}.gb-engine-select{width:100%}.gb-engine-groups{display:grid;gap:var(--ui-space-3, 12px)}.gb-engine-group{display:grid;gap:6px}.gb-engine-group+.gb-engine-group{padding-top:var(--ui-space-3, 12px);border-top:1px solid var(--ui-border)}.gb-engine-group[data-current] .gb-engine-rowname{font-weight:600}.gb-engine-problem{color:var(--gemboss-danger-strong, #b42318)}.gb-engine-notes{display:grid;gap:4px;color:var(--ui-text-muted)}.gb-engine-notes p{margin:0}.gb-engine-callout{padding:8px 10px;border-radius:var(--ui-radius-md, 8px);border:1px solid}.gb-engine-callout--warn{background:var(--gemboss-warning-soft, #fff8e0);border-color:var(--gemboss-warning-border, #f5d569);color:var(--gemboss-warning, #9a6700)}.gb-engine-callout--down{background:var(--gemboss-danger-soft, #fff0e9);border-color:var(--gemboss-danger-border, #f5c9bc);color:var(--gemboss-danger-strong, #b42318)}.gb-engine-steps ol,.gb-engine-steps ul{margin:0;padding-left:18px;display:grid;gap:4px}.gb-engine-cmd{margin:0;padding:8px 10px;border-radius:var(--ui-radius-md, 8px);background:var(--ui-surface-2);border:1px solid var(--ui-border);font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:11.5px;line-height:16px;white-space:pre-wrap;word-break:break-all;user-select:all;max-height:96px;overflow:auto}.gb-engine-cmd code{padding:0;border:0;background:none;font:inherit;color:inherit}.gb-engine-actions{display:flex;flex-wrap:wrap;align-items:center;gap:var(--ui-space-2, 8px)}.gb-engine-said{color:var(--ui-text-muted)}.gb-engine-said:empty{display:none}.gb-engine-code code{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-weight:600;letter-spacing:.04em;user-select:all}.gb-engine-rows{display:grid;grid-template-columns:auto 1fr;gap:6px 12px;margin:0}.gb-engine-rows dt{color:var(--ui-text-muted)}.gb-engine-rows dd{margin:0;display:flex;align-items:center;gap:6px;min-width:0;overflow-wrap:anywhere}.gb-engine-settings{display:grid;gap:var(--ui-space-4, 16px);max-width:662px;font-size:var(--ui-fs-body, 13px);line-height:20px}.gb-engine-sect{display:grid;gap:var(--ui-space-3, 12px)}.gb-engine-sect>.ui-card__title{margin:0}.gb-engine-sect p{margin:0}.gb-engine-sect:focus,.gb-engine-sub:focus{outline:none}.gb-engine-sub{display:grid;gap:var(--ui-space-3, 12px);padding-top:var(--ui-space-3, 12px);border-top:1px solid var(--ui-border);scroll-margin-top:var(--ui-space-4, 16px)}.gb-engine-subtitle{margin:0;font-size:inherit;line-height:inherit;font-weight:650}.gb-engine-settings .gb-engine-cmd{max-height:none}.gb-engine-notice{display:grid;grid-template-columns:auto minmax(0,1fr);align-items:start;gap:4px 6px;margin:0;padding:4px 0;font-size:var(--ui-fs-caption, 12px);line-height:16px;color:var(--ui-text-muted)}.gb-engine-notice>.gb-engine-dot{margin-top:4px}.gb-engine-notice>.gb-engine-notice-link{grid-column:2;justify-self:start}.gb-engine-notice--down .gb-engine-notice-text,.gb-engine-notice--warn .gb-engine-notice-text{color:var(--ui-text)}.gb-engine-notice-text{min-width:0;overflow-wrap:anywhere}.gb-engine-notice-link{flex:none;display:inline-flex;align-items:center;min-height:24px;margin:-4px 0 -4px -4px;padding:0 4px;border:0;border-radius:4px;background:none;font:inherit;font-weight:550;color:var(--ui-accent);text-decoration:underline;text-underline-offset:2px;cursor:pointer}.gb-engine-notice-link:focus-visible{outline:2px solid var(--ui-focus);outline-offset:0}@media (pointer: coarse),(max-width: 47.9975em){.gb-engine-chip{min-height:44px}.gb-engine-opt{min-height:44px;min-width:44px}.gb-engine-notice-link{min-height:44px;margin:-14px 0 -14px -8px;padding:0 8px}}@media (prefers-reduced-motion: no-preference){.gb-engine-chip,.gb-engine-opt,.gb-engine-row{transition:background-color .12s ease,color .12s ease}}
|
|
1
|
+
.gb-engine{display:inline-flex;min-width:0;max-width:100%}.gb-engine-chip{display:inline-flex;align-items:center;gap:6px;min-width:0;max-width:100%;box-sizing:border-box;height:var(--ui-btn-h, 28px);padding:0 24px 0 8px;font:inherit;font-size:var(--ui-fs-caption, 12px);font-weight:500;line-height:20px;white-space:nowrap;color:var(--ui-text-muted);background-color:transparent;border:1px solid transparent;border-radius:var(--ui-radius-md, 8px);cursor:pointer;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23686b71' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");background-repeat:no-repeat;background-position:right 8px center}@media (hover: hover){.gb-engine-chip:hover{color:var(--ui-text);background-color:var(--gemboss-hover, rgba(0,0,0,.05))}}@media (hover: none){.gb-engine-chip{color:var(--ui-text)}}.gb-engine-chip:focus-visible{color:var(--ui-text);outline:2px solid var(--ui-focus);outline-offset:2px}.gb-engine-chiplabel{min-width:0;overflow:hidden;text-overflow:ellipsis}.gb-engine-chipsub{font-weight:450}.gb-engine-chip:disabled{cursor:default;opacity:.55}.gemboss-engine-mark{display:block;width:14px;height:14px;flex:0 0 auto}.gb-engine-chipmark{display:none}.gb-engine-chipmark .gemboss-engine-mark{width:16px;height:16px}.gemboss-ec-input:not([data-density=full]) .gb-engine-chipsub{display:none}.gemboss-ec-input:is([data-density=icon],[data-density=tight]) .gb-engine-chip.has-mark .gb-engine-chiplabel{display:none}.gemboss-ec-input:is([data-density=icon],[data-density=tight]) .gb-engine-chip.has-mark .gb-engine-chipmark{display:block}.gemboss-ec-input:is([data-density=icon],[data-density=tight]) .gb-engine:has(.has-mark){flex-shrink:0}.gb-engine-dot{flex:none;display:inline-block;width:8px;height:8px;border-radius:50%;background:var(--ui-text-muted);vertical-align:middle}.gb-engine-dot--ok{background:var(--gemboss-success, #007f5f)}.gb-engine-dot--warn{background:#e8a10a;box-shadow:0 0 0 1px var(--gemboss-warning, #9a6700) inset}.gb-engine-dot--down{background:var(--gemboss-danger, #d72c0d)}.gb-engine-dot--idle{background:transparent;box-shadow:0 0 0 1.5px var(--ui-text-muted) inset}.gb-engine-field{display:grid;gap:6px}.gb-engine-label{font-weight:550;color:var(--ui-text-strong, var(--ui-text))}.gb-engine-note{color:var(--ui-text-muted)}.gb-engine-list{display:grid;border:1px solid var(--ui-border);border-radius:var(--ui-radius-md, 8px);overflow:hidden}.gb-engine-row{display:grid;grid-template-columns:28px minmax(0,1fr);gap:2px 10px;align-items:center;min-height:44px;padding:8px 12px 8px 34px;box-sizing:border-box;position:relative;font:inherit;text-align:left;color:inherit;background:transparent;border:0;cursor:pointer}.gb-engine-row+.gb-engine-row{border-top:1px solid var(--ui-border)}.gb-engine-row:before{content:"";position:absolute;left:10px;top:50%;width:14px;height:14px;margin-top:-7px;box-sizing:border-box;border:1.5px solid var(--ui-text-muted);border-radius:50%}.gb-engine-row[aria-checked=true]{background:var(--gemboss-active-bg, #f0f1f4)}.gb-engine-row[aria-checked=true]:before{border:4.5px solid var(--ui-accent)}.gb-engine-row[aria-checked=true] .gb-engine-rowname{font-weight:600}@media (hover: hover){.gb-engine-row:hover:not(:disabled){background:var(--ui-surface-2)}}.gb-engine-row:focus-visible{outline:2px solid var(--ui-focus);outline-offset:-2px}.gb-engine-row:disabled{cursor:not-allowed}.gb-engine-row:disabled .gb-engine-rowname{color:var(--ui-text-muted)}.gb-engine-rowhead{display:flex;align-items:center;gap:var(--ui-space-2, 8px);min-width:0}.gb-engine-rowname{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:450}.gb-engine-row>.gb-engine-rowhead,.gb-engine-row>.gb-engine-note{grid-column:2}.gb-engine-rowmark{grid-row:1;display:inline-grid;place-items:center;flex:none;width:28px;height:28px;border-radius:var(--ui-radius-md, 8px);background:var(--ui-surface-2);color:var(--ui-text);font-size:12px;font-weight:650;line-height:1}.gb-engine-row:has(>.gb-engine-note)>.gb-engine-rowmark{grid-row:1 / span 2}.gb-engine-rowmark .gemboss-engine-mark{width:16px;height:16px}.gb-engine-row[aria-checked=true] .gb-engine-rowmark{background:var(--ui-surface);box-shadow:inset 0 0 0 1px var(--ui-border)}.gb-engine-row:disabled .gb-engine-rowmark{opacity:.55}.gb-engine-group .gb-engine-rowmark{width:22px;height:22px;border-radius:6px;font-size:11px}.gb-engine-group .gb-engine-rowmark .gemboss-engine-mark{width:14px;height:14px}.gb-engine-opts{display:flex;flex-wrap:wrap;gap:var(--ui-space-2, 8px)}.gb-engine-opt{height:var(--ui-btn-h, 28px);padding:0 10px;box-sizing:border-box;font:inherit;font-weight:500;color:var(--ui-text);background:transparent;border:1px solid var(--ui-border);border-radius:var(--ui-radius-md, 8px);cursor:pointer}@media (hover: hover){.gb-engine-opt:hover:not(:disabled){background:var(--ui-surface-2)}}.gb-engine-opt[aria-pressed=true]{background:var(--gemboss-active-bg, #f0f1f4);border-color:var(--ui-text);font-weight:600}.gb-engine-opt:focus-visible{outline:2px solid var(--ui-focus);outline-offset:2px}.gb-engine-opt:disabled{opacity:.5;cursor:not-allowed}.gb-engine-select{width:100%}.gb-engine-groups{display:grid;gap:var(--ui-space-3, 12px)}.gb-engine-group{display:grid;gap:6px}.gb-engine-group+.gb-engine-group{padding-top:var(--ui-space-3, 12px);border-top:1px solid var(--ui-border)}.gb-engine-group[data-current] .gb-engine-rowname{font-weight:600}.gb-engine-problem{color:var(--gemboss-danger-strong, #b42318)}.gb-engine-notes{display:grid;gap:4px;color:var(--ui-text-muted)}.gb-engine-notes p{margin:0}.gb-engine-callout{padding:8px 10px;border-radius:var(--ui-radius-md, 8px);border:1px solid}.gb-engine-callout--warn{background:var(--gemboss-warning-soft, #fff8e0);border-color:var(--gemboss-warning-border, #f5d569);color:var(--gemboss-warning, #9a6700)}.gb-engine-callout--down{background:var(--gemboss-danger-soft, #fff0e9);border-color:var(--gemboss-danger-border, #f5c9bc);color:var(--gemboss-danger-strong, #b42318)}.gb-engine-steps ol,.gb-engine-steps ul{margin:0;padding-left:18px;display:grid;gap:4px}.gb-engine-cmd{margin:0;padding:8px 10px;border-radius:var(--ui-radius-md, 8px);background:var(--ui-surface-2);border:1px solid var(--ui-border);font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:11.5px;line-height:16px;white-space:pre-wrap;word-break:break-all;user-select:all}.gb-engine-cmd code{padding:0;border:0;background:none;font:inherit;color:inherit}.gb-engine-actions{display:flex;flex-wrap:wrap;align-items:center;gap:var(--ui-space-2, 8px)}.gb-engine-said{color:var(--ui-text-muted)}.gb-engine-said:empty{display:none}.gb-engine-code code{padding:0;border:0;background:none;color:inherit;font-size:inherit;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-weight:600;letter-spacing:.04em;user-select:all}.gb-engine-rows{display:grid;grid-template-columns:auto 1fr;gap:6px 12px;margin:0}.gb-engine-rows dt{color:var(--ui-text-muted)}.gb-engine-rows dd{margin:0;display:flex;align-items:center;gap:6px;min-width:0;overflow-wrap:anywhere}.gb-engine-settings{display:grid;align-content:start;gap:var(--ui-space-4, 16px);max-width:662px;font-size:var(--ui-fs-body, 13px);line-height:20px}.gb-engine-sect{display:grid;gap:var(--ui-space-3, 12px)}.gb-engine-settings>.gb-engine-sect{margin:0}.gb-engine-sect>.ui-card__title{margin:0}.gb-engine-secthead{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:var(--ui-space-2, 8px)}.gb-engine-secthead>.ui-card__title{margin:0}.gb-engine-state{display:inline-flex;align-items:center;gap:6px;height:20px;padding:0 8px;border-radius:999px;white-space:nowrap;font-size:12px;font-weight:550;line-height:16px;background:var(--ui-surface-2);color:var(--ui-text)}.gb-engine-state:before{content:"";flex:none;width:6px;height:6px;border-radius:50%;background:currentColor}.gb-engine-state--ok{background:var(--gemboss-success-soft, #e3f8ec);color:var(--gemboss-success-strong, #0c5132)}.gb-engine-state--warn{background:var(--gemboss-warning-soft, #fff8e0);color:var(--gemboss-warning, #9a6700)}.gb-engine-state--down{background:var(--gemboss-danger-soft, #fff0e9);color:var(--gemboss-danger-strong, #b42318)}.gb-engine-state--idle:before{background:transparent;box-shadow:0 0 0 1.5px currentColor inset}.gb-engine-settings .gb-engine-sect p{margin:0}.gb-engine-sect:focus,.gb-engine-sub:focus{outline:none}.gb-engine-sub{display:grid;gap:var(--ui-space-3, 12px);padding-top:var(--ui-space-3, 12px);border-top:1px solid var(--ui-border);scroll-margin-top:var(--ui-space-4, 16px)}.gb-engine-subtitle{margin:0;font-size:inherit;line-height:inherit;font-weight:650}.gb-engine-notice{display:grid;grid-template-columns:auto minmax(0,1fr);align-items:start;gap:4px 6px;margin:0;padding:4px 0;font-size:var(--ui-fs-caption, 12px);line-height:16px;color:var(--ui-text-muted)}.gb-engine-notice>.gb-engine-dot{margin-top:4px}.gb-engine-notice>.gb-engine-notice-link{grid-column:2;justify-self:start}.gb-engine-notice--down .gb-engine-notice-text,.gb-engine-notice--warn .gb-engine-notice-text{color:var(--ui-text)}.gb-engine-notice-text{min-width:0;overflow-wrap:anywhere}.gb-engine-notice-link{flex:none;display:inline-flex;align-items:center;min-height:24px;margin:-4px 0 -4px -4px;padding:0 4px;border:0;border-radius:4px;background:none;font:inherit;font-weight:550;color:var(--ui-accent);text-decoration:underline;text-underline-offset:2px;cursor:pointer}.gb-engine-notice-link:focus-visible{outline:2px solid var(--ui-focus);outline-offset:0}@media (pointer: coarse),(max-width: 47.9975em){.gb-engine-chip{min-height:44px}.gb-engine-opt{min-height:44px;min-width:44px}.gb-engine-notice-link{min-height:44px;margin:-14px 0 -14px -8px;padding:0 8px}}@media (prefers-reduced-motion: no-preference){.gb-engine-chip,.gb-engine-opt,.gb-engine-row{transition:background-color .12s ease,color .12s ease}}
|
package/src/auth.tsx
CHANGED
|
@@ -179,6 +179,9 @@ export function AuthLayout({ brand, tagline, mark, panel, backdrop = "facet", ar
|
|
|
179
179
|
* Once a browser has come in through GemBoss the tool sets `gb_sso=1`, and from then on this page continues by itself,
|
|
180
180
|
* so a person still signed in to GemBoss never sees a form. It does not when the tool sent a reason back (`?sso=…`:
|
|
181
181
|
* that sign-in did not work, so the page stays and says why) or `?password=1` (the person asked for the form).
|
|
182
|
+
*
|
|
183
|
+
* A product's own GemBoss door (GemCommunity's, 25/10/2026) is the same button with `href` instead of `service`, and its
|
|
184
|
+
* own words: `label`, `goingLabel`, and `or` (null when the page says "or" itself, above several doors).
|
|
182
185
|
*/
|
|
183
186
|
export const GEMBOSS_ISSUER = "https://admin.gemboss.ai";
|
|
184
187
|
const SSO_REASONS: Record<string, string> = {
|
|
@@ -204,21 +207,46 @@ export function continuesByItself(cookie: string, search: string): boolean {
|
|
|
204
207
|
return /(?:^|;\s*)gb_sso=1(?:;|$)/.test(cookie);
|
|
205
208
|
}
|
|
206
209
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
210
|
+
/** Where AuthContinueWithGemBoss goes: GemBoss's fleet door for one tool (`service`), or a door the product runs itself
|
|
211
|
+
* (`href`). */
|
|
212
|
+
type GemBossDoor =
|
|
213
|
+
| {
|
|
214
|
+
/** This tool's id in GemBoss's list of tools that redeem (FLEET_SSO_SERVICES). */
|
|
215
|
+
service: string;
|
|
216
|
+
/** Where on this tool to land afterwards: a path. */
|
|
217
|
+
next?: string;
|
|
218
|
+
issuer?: string;
|
|
219
|
+
/** The name this page is served on (the request's Host). A server-rendered page passes it, so a click made before
|
|
220
|
+
* React has loaded already carries it; without it the link gains it once mounted. */
|
|
221
|
+
host?: string;
|
|
222
|
+
href?: undefined;
|
|
223
|
+
}
|
|
224
|
+
| {
|
|
225
|
+
/** A door the product runs itself (25/10/2026): GemCommunity's handoff (admin.gemboss.ai/api/community/sso), not the
|
|
226
|
+
* fleet's. The link goes there as given. Nothing of the fleet door applies: the browser never continues by itself
|
|
227
|
+
* (gb_sso is the fleet's cookie), and a `?sso=` reason is the product's to say, in its own words. */
|
|
228
|
+
href: string;
|
|
229
|
+
service?: undefined;
|
|
230
|
+
next?: undefined;
|
|
231
|
+
issuer?: undefined;
|
|
232
|
+
host?: undefined;
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
export function AuthContinueWithGemBoss({ service, next = "/", issuer = GEMBOSS_ISSUER, host: givenHost, href: door,
|
|
236
|
+
label = "Continue with GemBoss", goingLabel = "Continuing with GemBoss…", or = "or use the password" }: GemBossDoor & {
|
|
237
|
+
/** The button's words, in the page's language. */
|
|
238
|
+
label?: React.ReactNode;
|
|
239
|
+
/** Its words once pressed, while the browser goes. */
|
|
240
|
+
goingLabel?: React.ReactNode;
|
|
241
|
+
/** The line under the button; null for none (a page that says "or" itself, above several doors). */
|
|
242
|
+
or?: React.ReactNode | null;
|
|
216
243
|
}) {
|
|
217
244
|
const [host, setHost] = useState<string | undefined>(givenHost);
|
|
218
|
-
const href = gemBossSignInUrl(service, next, issuer, host);
|
|
245
|
+
const href = door ?? gemBossSignInUrl(service, next, issuer, host);
|
|
219
246
|
const [going, setGoing] = useState(false);
|
|
220
247
|
const [reason, setReason] = useState<string | null>(null);
|
|
221
248
|
useEffect(() => {
|
|
249
|
+
if (door !== undefined) return;
|
|
222
250
|
setHost(window.location.host);
|
|
223
251
|
const r = new URLSearchParams(window.location.search).get("sso");
|
|
224
252
|
if (r) setReason(SSO_REASONS[r] ?? SSO_REASONS.invalid);
|
|
@@ -226,7 +254,7 @@ export function AuthContinueWithGemBoss({ service, next = "/", issuer = GEMBOSS_
|
|
|
226
254
|
setGoing(true);
|
|
227
255
|
window.location.replace(gemBossSignInUrl(service, next, issuer, window.location.host));
|
|
228
256
|
}
|
|
229
|
-
}, [service, next, issuer]);
|
|
257
|
+
}, [door, service, next, issuer]);
|
|
230
258
|
// Back from GemBoss into a page the browser kept in memory: the door is not still "Continuing with GemBoss…".
|
|
231
259
|
useEffect(() => {
|
|
232
260
|
const back = (e: PageTransitionEvent) => { if (e.persisted) setGoing(false); };
|
|
@@ -237,10 +265,10 @@ export function AuthContinueWithGemBoss({ service, next = "/", issuer = GEMBOSS_
|
|
|
237
265
|
<div className="gb-auth-sso">
|
|
238
266
|
<a className="gb-auth-sso-btn" href={href} onClick={() => setGoing(true)}>
|
|
239
267
|
<GemMark size={18} tile="var(--gb-mark-bg)" />
|
|
240
|
-
{going ?
|
|
268
|
+
{going ? goingLabel : label}
|
|
241
269
|
</a>
|
|
242
270
|
{reason ? <p className="gb-auth-sso-why" role="status">{reason}</p> : null}
|
|
243
|
-
<p className="gb-auth-or">or
|
|
271
|
+
{or !== null ? <p className="gb-auth-or">{or}</p> : null}
|
|
244
272
|
</div>
|
|
245
273
|
);
|
|
246
274
|
}
|
package/src/dialog.tsx
CHANGED
|
@@ -14,7 +14,9 @@
|
|
|
14
14
|
* to the right edge: it renders `Dialog` and brings sheet.css, so the markup and the behaviour each have one owner.
|
|
15
15
|
*/
|
|
16
16
|
import React, { useEffect, useId, useRef } from "react";
|
|
17
|
+
import { flushSync } from "react-dom";
|
|
17
18
|
import { Icon } from "./icons";
|
|
19
|
+
import { consumeEscape } from "./escape";
|
|
18
20
|
|
|
19
21
|
const cx = (...p: Array<string | false | null | undefined>) => p.filter(Boolean).join(" ");
|
|
20
22
|
|
|
@@ -34,6 +36,24 @@ const cx = (...p: Array<string | false | null | undefined>) => p.filter(Boolean)
|
|
|
34
36
|
* leave the screen as they act, and focusing them does nothing). SettingsDialog's default is `[data-settings-trigger]`.
|
|
35
37
|
* - The page behind holds still while any kit popup is modal: `html:has(dialog.ui-modal:modal)` (kit-plain.css).
|
|
36
38
|
*/
|
|
39
|
+
// The control a press last landed on (24/10/2026). Polaris' buttons blur themselves on mouseup (UnstyledButton's
|
|
40
|
+
// handleMouseUpByBlurring), so a popup opened by a click on one found <body> focused and gave the focus back to <body> on Escape:
|
|
41
|
+
// the catalogue picker's Change, and any Polaris button that opens a kit popup. Read only when the focus is on <body> as it opens,
|
|
42
|
+
// and only a press of the last 2 s still in the page; an opener that kept its focus (a key press, a kit button) is unchanged.
|
|
43
|
+
let lastPressed: { el: Element; at: number } | null = null;
|
|
44
|
+
if (typeof document !== "undefined") {
|
|
45
|
+
document.addEventListener("pointerdown", (e) => {
|
|
46
|
+
const el = (e.target as Element | null)?.closest?.("button, a[href], [role=button], input, select, textarea, [tabindex]");
|
|
47
|
+
// A press on something that takes no focus (a row with a click handler) forgets the last one: it opened what opens next.
|
|
48
|
+
lastPressed = el ? { el, at: Date.now() } : null;
|
|
49
|
+
}, true);
|
|
50
|
+
}
|
|
51
|
+
const openerNow = (): Element | null => {
|
|
52
|
+
const a = document.activeElement;
|
|
53
|
+
if (a && a !== document.body) return a;
|
|
54
|
+
return lastPressed && lastPressed.el.isConnected && Date.now() - lastPressed.at < 2000 ? lastPressed.el : a;
|
|
55
|
+
};
|
|
56
|
+
|
|
37
57
|
export function useModalDialog(open: boolean, onClose: () => void, { focusPanel = false, returnFocusTo }: { focusPanel?: boolean; returnFocusTo?: string } = {}) {
|
|
38
58
|
const ref = useRef<HTMLDialogElement>(null);
|
|
39
59
|
const opener = useRef<Element | null>(null);
|
|
@@ -52,7 +72,7 @@ export function useModalDialog(open: boolean, onClose: () => void, { focusPanel
|
|
|
52
72
|
const d = ref.current;
|
|
53
73
|
if (!d) return;
|
|
54
74
|
if (open && !d.open) {
|
|
55
|
-
opener.current =
|
|
75
|
+
opener.current = openerNow();
|
|
56
76
|
d.showModal();
|
|
57
77
|
shown.current = true;
|
|
58
78
|
if (focusPanel) d.focus({ preventScroll: true });
|
|
@@ -65,7 +85,9 @@ export function useModalDialog(open: boolean, onClose: () => void, { focusPanel
|
|
|
65
85
|
if (!d) return undefined;
|
|
66
86
|
const onNativeClose = () => {
|
|
67
87
|
shown.current = false;
|
|
68
|
-
|
|
88
|
+
// What closing changes is on the page before the focus goes back: a picker's typed handle, saved as it closes, replaces its
|
|
89
|
+
// "Choose a product" with the chosen row, and the focus went to that button an instant before it left (measured, 24/10/2026).
|
|
90
|
+
flushSync(() => close.current());
|
|
69
91
|
giveFocusBack();
|
|
70
92
|
};
|
|
71
93
|
d.addEventListener("close", onNativeClose);
|
|
@@ -99,15 +121,22 @@ export interface DialogProps {
|
|
|
99
121
|
className?: string;
|
|
100
122
|
/** On open, focus the popup itself rather than its first control (Sheet does). */
|
|
101
123
|
focusPanel?: boolean;
|
|
124
|
+
/** A selector focused on close when what opened it is gone by then (useModalDialog's `returnFocusTo`): a picker's first pick
|
|
125
|
+
* replaces its "Choose" with the chosen row's Change. */
|
|
126
|
+
returnFocusTo?: string;
|
|
102
127
|
}
|
|
103
128
|
|
|
104
|
-
export function Dialog({ open, onClose, title, subtitle, actions, children, footer, wide = false, closeLabel = "Close", className, focusPanel = false }: DialogProps) {
|
|
105
|
-
const { ref, onClick, onPointerDown } = useModalDialog(open, onClose, { focusPanel });
|
|
129
|
+
export function Dialog({ open, onClose, title, subtitle, actions, children, footer, wide = false, closeLabel = "Close", className, focusPanel = false, returnFocusTo }: DialogProps) {
|
|
130
|
+
const { ref, onClick, onPointerDown } = useModalDialog(open, onClose, { focusPanel, returnFocusTo });
|
|
106
131
|
const titleId = useId();
|
|
107
132
|
const subId = useId();
|
|
108
133
|
return (
|
|
109
134
|
<dialog ref={ref} className={cx("ui-modal", wide && "ui-modal--wide", className)} aria-labelledby={titleId}
|
|
110
|
-
aria-describedby={subtitle ? subId : undefined} tabIndex={focusPanel ? -1 : undefined} onClick={onClick} onPointerDown={onPointerDown}
|
|
135
|
+
aria-describedby={subtitle ? subId : undefined} tabIndex={focusPanel ? -1 : undefined} onClick={onClick} onPointerDown={onPointerDown}
|
|
136
|
+
// Its Escape closes it and only it, as the kit's Popover: the browser closes the <dialog>, and neither the keydown nor the keyup
|
|
137
|
+
// goes further out, where a Polaris Modal it was opened from closed as well (on the keyup; escape.ts). A box that clears its
|
|
138
|
+
// words on Escape (PickerList's) consumes the key before it gets here.
|
|
139
|
+
onKeyDown={(e) => { if (e.key === "Escape" && !e.nativeEvent.isComposing) consumeEscape(e); }}>
|
|
111
140
|
<div className="ui-modal__head">
|
|
112
141
|
{subtitle
|
|
113
142
|
? <div className="ui-modal__title"><span id={titleId}>{title}</span><span className="ui-modal__subtitle" id={subId}>{subtitle}</span></div>
|
|
@@ -13,6 +13,7 @@ import "../editor-picker-grid.css";
|
|
|
13
13
|
import React, { useEffect, useId, useRef, useState } from "react";
|
|
14
14
|
import { Icon } from "../icons";
|
|
15
15
|
import { PickNothing, PickSearch, typesFirst, usePickHighlight, type PickerSearch } from "./picker";
|
|
16
|
+
import { consumeEscape } from "../escape";
|
|
16
17
|
|
|
17
18
|
export interface PickerTile {
|
|
18
19
|
/** What `onSelect` / `onActivate` get, and what `selected` is compared with. */
|
|
@@ -97,6 +98,8 @@ export function PickerGrid({ label, tiles, selected = null, onSelect, onActivate
|
|
|
97
98
|
if (use && onActivate) onActivate(t!.key); else onSelect(t!.key);
|
|
98
99
|
};
|
|
99
100
|
const clear = () => { search?.onChange(""); boxRef.current?.focus(); };
|
|
101
|
+
// Try again leaves with the error it sat in: the focus goes back to the box, not to <body> (24/10/2026, the placement picker).
|
|
102
|
+
const retry = error?.onRetry ? { ...error, onRetry: () => { error.onRetry!(); boxRef.current?.focus(); } } : error;
|
|
100
103
|
// As PickerList: `search.autoFocus`, the box takes the focus once, as the grid appears.
|
|
101
104
|
useEffect(() => { if (typesFirst(search)) boxRef.current?.focus(); }, []); // eslint-disable-line react-hooks/exhaustive-deps
|
|
102
105
|
const keyDown = (e: React.KeyboardEvent, fromBox: boolean) => {
|
|
@@ -113,7 +116,7 @@ export function PickerGrid({ label, tiles, selected = null, onSelect, onActivate
|
|
|
113
116
|
else if (grid && e.key === "End") go("last");
|
|
114
117
|
else if (e.key === "Enter") { if (shown.length) e.preventDefault(); choose(shown[active], true); }
|
|
115
118
|
else if (!fromBox && e.key === " ") { e.preventDefault(); choose(shown[active], false); }
|
|
116
|
-
else if (fromBox && e.key === "Escape" && query) { e.preventDefault(); e
|
|
119
|
+
else if (fromBox && e.key === "Escape" && query) { e.preventDefault(); consumeEscape(e); clear(); }
|
|
117
120
|
};
|
|
118
121
|
// The uploads in flight, said aloud from outside the grid (below).
|
|
119
122
|
const sending = tiles.filter((t) => t.status?.busy).map((t) => t.title);
|
|
@@ -126,7 +129,7 @@ export function PickerGrid({ label, tiles, selected = null, onSelect, onActivate
|
|
|
126
129
|
<div className="gemboss-ei-pick">
|
|
127
130
|
{search ? <PickSearch search={search} boxRef={boxRef} listId={listId} hasList={hasTiles} activeId={activeId} onKeyDown={(e) => keyDown(e, true)} onClear={clear} /> : null}
|
|
128
131
|
{phase === "loading" || phase === "error" || !hasTiles ? (
|
|
129
|
-
<PickNothing phase={phase === "loading" ? "loading" : phase === "error" ? "error" : "empty"} error={
|
|
132
|
+
<PickNothing phase={phase === "loading" ? "loading" : phase === "error" ? "error" : "empty"} error={retry} empty={empty} query={query} onClear={clear}
|
|
130
133
|
skeleton={
|
|
131
134
|
<div className={`gemboss-ei-pickgrid${size === "icon" ? " is-icon" : ""}`} role="status" aria-label="Loading">
|
|
132
135
|
{Array.from({ length: loadingTiles }, (_, i) => (
|
package/src/editor/picker.tsx
CHANGED
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
import "../editor-picker.css";
|
|
25
25
|
import React, { useEffect, useId, useMemo, useRef, useState } from "react";
|
|
26
26
|
import { Icon, type IconName } from "../icons";
|
|
27
|
+
import { consumeEscape } from "../escape";
|
|
27
28
|
|
|
28
29
|
export type PickerTone = "neutral" | "info" | "success" | "warning" | "critical";
|
|
29
30
|
|
|
@@ -56,6 +57,11 @@ export interface PickerListProps {
|
|
|
56
57
|
/** The list's accessible name ("Sections", "Products"). */
|
|
57
58
|
label: string;
|
|
58
59
|
items: readonly PickerItem[];
|
|
60
|
+
/** Rows that do not come from the source (an empty value that is a choice: "This page's product"): first, pickable in every
|
|
61
|
+
* state, with the source's own state said under them (its skeleton, its error with Try again, its empty or no-results words).
|
|
62
|
+
* Without them an empty source behind such a row never said it was empty, and a failed read hid the row (review of #5415).
|
|
63
|
+
* The caller leaves them out while words are typed, if they are no match for words. */
|
|
64
|
+
pinned?: readonly PickerItem[];
|
|
59
65
|
/** The key now chosen: its row has the check (a drill row: the tint), and is the one highlighted first. */
|
|
60
66
|
current?: string | null;
|
|
61
67
|
onPick: (key: string) => void;
|
|
@@ -168,19 +174,24 @@ const DRILL = <Icon name="chevronRight" size={16} className="gemboss-ei-pick-dri
|
|
|
168
174
|
|
|
169
175
|
const TONE: Record<PickerTone, string> = { neutral: "ui-tag", info: "ui-tag ui-tag--accent", success: "ui-tag ui-tag--success", warning: "ui-tag ui-tag--warning", critical: "ui-tag ui-tag--danger" };
|
|
170
176
|
|
|
171
|
-
|
|
177
|
+
const NO_ROWS: readonly PickerItem[] = [];
|
|
178
|
+
|
|
179
|
+
export function PickerList({ label, items, pinned = NO_ROWS, current = null, onPick, search, state = "ready", error, empty, more, loadingRows = 4 }: PickerListProps) {
|
|
172
180
|
const base = useId();
|
|
173
181
|
const boxRef = useRef<HTMLInputElement>(null);
|
|
174
182
|
// Reloading with nothing to keep is a first read: skeletons, not "nothing here".
|
|
175
183
|
const phase = state === "reloading" && items.length === 0 ? "loading" : state;
|
|
176
|
-
const
|
|
184
|
+
const fromSource = phase === "ready" || phase === "reloading" ? items : NO_ROWS;
|
|
185
|
+
const shown = pinned.length ? [...pinned, ...fromSource] : fromSource;
|
|
177
186
|
const live = phase === "ready";
|
|
187
|
+
// A pinned row answers no read: pickable whatever the source is doing.
|
|
188
|
+
const rowLive = (i: number) => i < pinned.length || live;
|
|
178
189
|
const pickable = useMemo(() => shown.map((it, i) => (it.disabledReason ? -1 : i)).filter((i) => i >= 0), [shown]);
|
|
179
190
|
const query = search?.value ?? "";
|
|
180
191
|
const optionId = (i: number) => `${base}-o${i}`;
|
|
181
192
|
const { active, highlight } = usePickHighlight(shown, (it) => !it.disabledReason, current, query, optionId);
|
|
182
193
|
|
|
183
|
-
const pick = (
|
|
194
|
+
const pick = (i: number) => { const it = shown[i]; if (it && rowLive(i) && !it.disabledReason) onPick(it.key); };
|
|
184
195
|
const move = (by: 1 | -1 | "first" | "last") => {
|
|
185
196
|
if (!pickable.length) return;
|
|
186
197
|
const at = pickable.indexOf(active);
|
|
@@ -188,6 +199,8 @@ export function PickerList({ label, items, current = null, onPick, search, state
|
|
|
188
199
|
highlight(shown[pickable[next]!]!.key, "keys");
|
|
189
200
|
};
|
|
190
201
|
const clear = () => { search?.onChange(""); boxRef.current?.focus(); };
|
|
202
|
+
// Try again leaves with the error it sat in: the focus goes back to the box, not to <body> (24/10/2026, the placement picker).
|
|
203
|
+
const retry = error?.onRetry ? { ...error, onRetry: () => { error.onRetry!(); boxRef.current?.focus(); } } : error;
|
|
191
204
|
// The box carries `data-autofocus`, which the kit's Dialog and Popover focus as they open; this covers a list that appears in a
|
|
192
205
|
// container already open (a drill-down's new list). Once, as the list appears.
|
|
193
206
|
useEffect(() => { if (typesFirst(search)) boxRef.current?.focus(); }, []); // eslint-disable-line react-hooks/exhaustive-deps
|
|
@@ -200,43 +213,32 @@ export function PickerList({ label, items, current = null, onPick, search, state
|
|
|
200
213
|
else if (e.key === "Enter" || (!fromBox && e.key === " ")) {
|
|
201
214
|
// Reloading: the rows answer another search; Enter waits for this one (nothing is written).
|
|
202
215
|
if (shown.length) e.preventDefault();
|
|
203
|
-
pick(
|
|
204
|
-
} else if (fromBox && e.key === "Escape" && query) { e.preventDefault(); e
|
|
216
|
+
pick(active);
|
|
217
|
+
} else if (fromBox && e.key === "Escape" && query) { e.preventDefault(); consumeEscape(e); clear(); }
|
|
205
218
|
};
|
|
206
219
|
|
|
207
220
|
const listId = `${base}-list`;
|
|
208
221
|
const hasList = shown.length > 0;
|
|
209
|
-
|
|
222
|
+
// The source's state is said where its rows would be: under the pinned rows, or in the list's place.
|
|
223
|
+
const nothing = phase === "loading" || phase === "error" || fromSource.length === 0;
|
|
224
|
+
const activeId = active >= 0 && shown[active] && rowLive(active) ? optionId(active) : undefined;
|
|
210
225
|
|
|
211
226
|
return (
|
|
212
227
|
<div className="gemboss-ei-pick">
|
|
213
228
|
{search ? <PickSearch search={search} boxRef={boxRef} listId={listId} hasList={hasList} activeId={activeId} onKeyDown={(e) => keyDown(e, true)} onClear={clear} /> : null}
|
|
214
229
|
|
|
215
|
-
{
|
|
216
|
-
|
|
217
|
-
skeleton={
|
|
218
|
-
<div className="gemboss-ei-pick-skeleton" role="status" aria-label="Loading">
|
|
219
|
-
{Array.from({ length: loadingRows }, (_, i) => (
|
|
220
|
-
<div key={i} className="gemboss-ei-pick-skeleton-row" aria-hidden>
|
|
221
|
-
<span className="gemboss-ei-pick-media ui-skeleton__line" />
|
|
222
|
-
<span className="gemboss-ei-pick-skeleton-text"><span className="ui-skeleton__line" /><span className="ui-skeleton__line" /></span>
|
|
223
|
-
</div>
|
|
224
|
-
))}
|
|
225
|
-
</div>
|
|
226
|
-
} />
|
|
227
|
-
) : (
|
|
228
|
-
<>
|
|
229
|
-
<ul id={listId} className={`gemboss-ei-pick-list${live ? "" : " is-reloading"}`} role="listbox" aria-label={label} aria-busy={live ? undefined : true}
|
|
230
|
+
{hasList ? (
|
|
231
|
+
<ul id={listId} className={`gemboss-ei-pick-list${live || pinned.length ? "" : " is-reloading"}`} role="listbox" aria-label={label} aria-busy={live ? undefined : true}
|
|
230
232
|
tabIndex={search ? -1 : 0} aria-activedescendant={search ? undefined : activeId} onKeyDown={search ? undefined : (e) => keyDown(e, false)}>
|
|
231
233
|
{shown.map((it, i) => {
|
|
232
234
|
const chosen = it.key === current;
|
|
233
235
|
const note = it.disabledReason ?? it.note;
|
|
234
236
|
return (
|
|
235
|
-
<li key={it.key} id={optionId(i)} role="option" aria-selected={chosen} aria-disabled={it.disabledReason || !
|
|
236
|
-
className={`gemboss-ei-pick-row${i === active ? " is-active" : ""}`} data-key={it.key}
|
|
237
|
+
<li key={it.key} id={optionId(i)} role="option" aria-selected={chosen} aria-disabled={it.disabledReason || !rowLive(i) ? true : undefined}
|
|
238
|
+
className={`gemboss-ei-pick-row${i === active ? " is-active" : ""}${rowLive(i) ? "" : " is-stale"}`} data-key={it.key}
|
|
237
239
|
onMouseDown={(e) => e.preventDefault() /* the search box keeps the focus */}
|
|
238
240
|
onMouseMove={() => { if (!it.disabledReason && i !== active) highlight(it.key, "pointer"); }}
|
|
239
|
-
onClick={() => pick(
|
|
241
|
+
onClick={() => pick(i)}>
|
|
240
242
|
{it.image !== undefined ? (
|
|
241
243
|
it.image ? <img className="gemboss-ei-pick-media" src={it.image} alt="" loading="lazy" /> : <span className="gemboss-ei-pick-media" aria-hidden />
|
|
242
244
|
) : it.icon ? (
|
|
@@ -261,8 +263,20 @@ export function PickerList({ label, items, current = null, onPick, search, state
|
|
|
261
263
|
);
|
|
262
264
|
})}
|
|
263
265
|
</ul>
|
|
264
|
-
|
|
265
|
-
|
|
266
|
+
) : null}
|
|
267
|
+
{nothing ? (
|
|
268
|
+
<PickNothing phase={phase === "loading" ? "loading" : phase === "error" ? "error" : "empty"} error={retry} empty={empty} query={query} onClear={clear}
|
|
269
|
+
skeleton={
|
|
270
|
+
<div className="gemboss-ei-pick-skeleton" role="status" aria-label="Loading">
|
|
271
|
+
{Array.from({ length: loadingRows }, (_, i) => (
|
|
272
|
+
<div key={i} className="gemboss-ei-pick-skeleton-row" aria-hidden>
|
|
273
|
+
<span className="gemboss-ei-pick-media ui-skeleton__line" />
|
|
274
|
+
<span className="gemboss-ei-pick-skeleton-text"><span className="ui-skeleton__line" /><span className="ui-skeleton__line" /></span>
|
|
275
|
+
</div>
|
|
276
|
+
))}
|
|
277
|
+
</div>
|
|
278
|
+
} />
|
|
279
|
+
) : null}
|
|
266
280
|
{/* After the list, or after "no results" / an empty list: the next page may hold what this one did not (the first page of a
|
|
267
281
|
store's Shopify files, all held already or none matching, kept Load more out of reach: review of #5325). */}
|
|
268
282
|
{more && (phase === "ready" || phase === "reloading") ? (
|
package/src/editor/popover.tsx
CHANGED
|
@@ -20,6 +20,7 @@ import React, { useEffect, useId, useLayoutEffect, useRef } from "react";
|
|
|
20
20
|
import { createPortal } from "react-dom";
|
|
21
21
|
import { Icon } from "../icons";
|
|
22
22
|
import { canFloatMenus, placeFloating } from "../menu-layer";
|
|
23
|
+
import { consumeEscape } from "../escape";
|
|
23
24
|
|
|
24
25
|
export interface PopoverProps {
|
|
25
26
|
open: boolean;
|
|
@@ -147,7 +148,7 @@ export function Popover({ open, anchor, returnTo, onClose, title, onBack, childr
|
|
|
147
148
|
if (!open) return null;
|
|
148
149
|
const layer = (
|
|
149
150
|
<div ref={ref} className={`gemboss-ei-pop gemboss-popover-surface${floating ? "" : " gemboss-ei-pop--inline"}`} role="dialog" aria-labelledby={titleId}
|
|
150
|
-
tabIndex={-1} onKeyDown={(e) => { if (e.key === "Escape" && !e.nativeEvent.isComposing) { e.preventDefault(); e
|
|
151
|
+
tabIndex={-1} onKeyDown={(e) => { if (e.key === "Escape" && !e.nativeEvent.isComposing) { e.preventDefault(); consumeEscape(e); if (onBack) back(); else shut(); } }}>
|
|
151
152
|
<div className="gemboss-ei-pop-head">
|
|
152
153
|
{onBack ? <button type="button" className="gemboss-ei-pop-btn" aria-label="Back" onClick={back}><Icon name="chevronLeft" size={16} /></button> : null}
|
|
153
154
|
<span className="gemboss-ei-pop-title" id={titleId}>{title}</span>
|
package/src/editor-insert.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.gemboss-editor-insert{position:fixed;z-index:500;display:flex;gap:8px;align-items:flex-start}.gemboss-editor-insert--flip{flex-direction:row-reverse}.gemboss-editor-insert-main{width:300px;padding:8px;display:flex;flex-direction:column;gap:6px;max-height:min(440px,calc(100vh - 32px))}input.gemboss-editor-insert-search{width:100%}.gemboss-editor-insert-main>:not(.gemboss-editor-insert-list){flex:none}.gemboss-editor-insert-place{margin:0;padding:0 4px;font-size:var(--gemboss-fs-caption);color:var(--gemboss-text-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.gemboss-editor-insert-list{flex:1;min-height:0;overflow-y:auto;display:flex;flex-direction:column;gap:1px;scrollbar-width:thin;scrollbar-color:rgba(31,30,29,.22) transparent}.gemboss-editor-insert-group{margin:0;padding:8px 8px 4px;font-size:var(--gemboss-fs-caption);font-weight:600;color:var(--gemboss-text-muted);text-transform:uppercase;letter-spacing:.04em}.gemboss-editor-insert-row{display:flex;flex-direction:column;gap:0;box-sizing:border-box;min-height:32px;justify-content:center;padding:6px 8px;border-radius:var(--gemboss-radius-md);cursor:pointer}.gemboss-editor-insert-row[aria-selected=true]{background:var(--gemboss-hover, rgba(0,0,0,.05))}.gemboss-editor-insert-row[aria-disabled=true]{cursor:not-allowed;color:var(--gemboss-text-muted)}.gemboss-editor-insert-name{font-size:var(--gemboss-fs-body);color:inherit}.gemboss-editor-insert-ask .gemboss-editor-insert-name{color:var(--gemboss-accent);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.gemboss-editor-insert-ask[aria-selected=true]{background:var(--gemboss-accent-wash, var(--gemboss-hover))}.gemboss-editor-insert-about{display:none;font-size:var(--gemboss-fs-caption);color:var(--gemboss-text-muted)}.gemboss-editor-insert-row[aria-disabled=true] .gemboss-editor-insert-about{display:block}.gemboss-editor-insert-empty{margin:0;padding:12px 8px;font-size:var(--gemboss-fs-body);color:var(--gemboss-text-muted)}.gemboss-editor-insert-section{flex:none;width:100%;min-height:32px;box-sizing:border-box;padding:6px 8px;border:0;border-top:1px solid var(--gemboss-divider);border-radius:0;background:transparent;text-align:left;cursor:pointer;font:inherit;font-size:var(--gemboss-fs-body);color:var(--gemboss-text)}.gemboss-editor-insert-section:hover,.gemboss-editor-insert-section:focus-visible{background:var(--gemboss-hover, rgba(0,0,0,.05));outline:none}@media (pointer: coarse),(max-width: 47.9975em){.gemboss-editor-insert-section{min-height:44px}}.gemboss-editor-insert-keys{margin:0;padding:4px 4px 0;border-top:1px solid var(--gemboss-divider);font-size:var(--gemboss-fs-caption);color:var(--gemboss-text-muted)}.gemboss-editor-insert-peek{width:220px;padding:12px;display:flex;flex-direction:column;gap:4px}.gemboss-editor-insert-peek p{margin:0}.gemboss-editor-insert-peek-pic{display:block;width:100%;height:auto;max-height:150px;object-fit:contain;object-position:top center;border:1px solid var(--gemboss-divider);border-radius:var(--gemboss-radius-md);background:var(--gemboss-surface, #fff)}.gemboss-editor-insert-peek-name{font-size:var(--gemboss-fs-body);font-weight:600;color:var(--gemboss-text)}.gemboss-editor-insert-peek-about,.gemboss-editor-insert-peek-place{font-size:var(--gemboss-fs-caption);color:var(--gemboss-text-muted)}.gemboss-editor-insert-peek-why{font-size:var(--gemboss-fs-caption);color:var(--gemboss-warning)}@media (pointer: coarse),(max-width: 47.9975em){.gemboss-editor-insert-row{min-height:44px}.gemboss-editor-insert-about{display:block}.gemboss-editor-insert-peek{display:none}}.gemboss-editor-insert--sheet{inset:auto 16px 16px}.gemboss-editor-insert--sheet .gemboss-editor-insert-main{width:100%;max-height:70vh}
|
|
1
|
+
.gemboss-editor-insert{position:fixed;z-index:500;display:flex;gap:8px;align-items:flex-start}.gemboss-editor-insert--flip{flex-direction:row-reverse}.gemboss-editor-insert-main{width:300px;padding:8px;display:flex;flex-direction:column;gap:6px;max-height:min(440px,calc(100vh - 32px))}input.gemboss-editor-insert-search{width:100%}.gemboss-editor-insert-main>:not(.gemboss-editor-insert-list){flex:none}.gemboss-editor-insert-place{margin:0;padding:0 4px;font-size:var(--gemboss-fs-caption);color:var(--gemboss-text-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.gemboss-editor-insert-list{flex:1;min-height:0;overflow-y:auto;display:flex;flex-direction:column;gap:1px;scrollbar-width:thin;scrollbar-color:rgba(31,30,29,.22) transparent}.gemboss-editor-insert-group{margin:0;padding:8px 8px 4px;font-size:var(--gemboss-fs-caption);font-weight:600;color:var(--gemboss-text-muted);text-transform:uppercase;letter-spacing:.04em}.gemboss-editor-insert-row{flex:none;display:flex;flex-direction:column;gap:0;box-sizing:border-box;min-height:32px;justify-content:center;padding:6px 8px;border-radius:var(--gemboss-radius-md);cursor:pointer}.gemboss-editor-insert-row[aria-selected=true]{background:var(--gemboss-hover, rgba(0,0,0,.05))}.gemboss-editor-insert-row[aria-disabled=true]{cursor:not-allowed;color:var(--gemboss-text-muted)}.gemboss-editor-insert-name{font-size:var(--gemboss-fs-body);color:inherit}.gemboss-editor-insert-ask .gemboss-editor-insert-name{color:var(--gemboss-accent);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.gemboss-editor-insert-ask[aria-selected=true]{background:var(--gemboss-accent-wash, var(--gemboss-hover))}.gemboss-editor-insert-about{display:none;font-size:var(--gemboss-fs-caption);color:var(--gemboss-text-muted)}.gemboss-editor-insert-row[aria-disabled=true] .gemboss-editor-insert-about{display:block}.gemboss-editor-insert-empty{margin:0;padding:12px 8px;font-size:var(--gemboss-fs-body);color:var(--gemboss-text-muted)}.gemboss-editor-insert-section{flex:none;width:100%;min-height:32px;box-sizing:border-box;padding:6px 8px;border:0;border-top:1px solid var(--gemboss-divider);border-radius:0;background:transparent;text-align:left;cursor:pointer;font:inherit;font-size:var(--gemboss-fs-body);color:var(--gemboss-text)}.gemboss-editor-insert-section:hover,.gemboss-editor-insert-section:focus-visible{background:var(--gemboss-hover, rgba(0,0,0,.05));outline:none}@media (pointer: coarse),(max-width: 47.9975em){.gemboss-editor-insert-section{min-height:44px}}.gemboss-editor-insert-keys{margin:0;padding:4px 4px 0;border-top:1px solid var(--gemboss-divider);font-size:var(--gemboss-fs-caption);color:var(--gemboss-text-muted)}.gemboss-editor-insert-back{align-self:flex-start;min-height:24px;padding:2px 4px;border:0;border-radius:var(--gemboss-radius-md);background:transparent;font:inherit;font-size:var(--gemboss-fs-caption);color:var(--gemboss-text-muted);cursor:pointer}.gemboss-editor-insert-back:hover,.gemboss-editor-insert-back:focus-visible{background:var(--gemboss-hover, rgba(0,0,0,.05));outline:none}.gemboss-editor-insert-row--item{flex-direction:row;align-items:center;justify-content:flex-start;gap:8px}.gemboss-editor-insert-text{display:flex;flex-direction:column;min-width:0}.gemboss-editor-insert-list[aria-busy=true] .gemboss-editor-insert-row--item{opacity:.6}.gemboss-editor-insert-row--item .gemboss-editor-insert-name{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.gemboss-editor-insert-thumb{flex:none;width:24px;height:24px;border-radius:4px;object-fit:cover;background:var(--gemboss-divider)}.gemboss-editor-insert-peek-photo{display:block;width:100%;height:120px;object-fit:contain;border-radius:var(--gemboss-radius-md);background:var(--gemboss-hover, rgba(0,0,0,.04))}.gemboss-editor-insert-peek{width:220px;padding:12px;display:flex;flex-direction:column;gap:4px}.gemboss-editor-insert-peek p{margin:0}.gemboss-editor-insert-peek-pic{display:block;width:100%;height:auto;max-height:150px;object-fit:contain;object-position:top center;border:1px solid var(--gemboss-divider);border-radius:var(--gemboss-radius-md);background:var(--gemboss-surface, #fff)}.gemboss-editor-insert-peek-name{font-size:var(--gemboss-fs-body);font-weight:600;color:var(--gemboss-text)}.gemboss-editor-insert-peek-about,.gemboss-editor-insert-peek-place{font-size:var(--gemboss-fs-caption);color:var(--gemboss-text-muted)}.gemboss-editor-insert-peek-why{font-size:var(--gemboss-fs-caption);color:var(--gemboss-warning)}@media (pointer: coarse),(max-width: 47.9975em){.gemboss-editor-insert-row,.gemboss-editor-insert-back{min-height:44px}.gemboss-editor-insert-about{display:block}.gemboss-editor-insert-peek{display:none}}.gemboss-editor-insert--sheet{inset:auto 16px 16px}.gemboss-editor-insert--sheet .gemboss-editor-insert-main{width:100%;max-height:70vh}
|
package/src/editor-picker.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.gemboss-ei-pick{display:flex;flex-direction:column;gap:var(--ui-space-3,12px);min-width:0}.gemboss-ei-pick-search{flex:none}.gemboss-ei-pick-search-icon{flex:none;color:var(--ui-text-muted,#686b71)}.gemboss-ei-pick-clear{flex:none;display:grid;place-items:center;width:24px;height:24px;margin-right:var(--ui-space-1,4px);padding:0;border:0;border-radius:var(--ui-radius-sm,6px);background:none;color:var(--ui-text-muted,#686b71);cursor:pointer}.gemboss-ei-pick-clear:hover{background:var(--ui-surface-2,#eceef2);color:var(--ui-text-strong,#1b1c1e)}.gemboss-ei-pick-clear:focus-visible{outline:2px solid var(--ui-focus,#5661f5);outline-offset:0}.gemboss-ei-pick-list{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;max-height:min(50vh,420px);overflow-y:auto;outline:none}.gemboss-ei-pick-row{flex:none;display:flex;align-items:center;gap:var(--ui-space-3,12px);min-height:44px;padding:var(--ui-space-2,8px);border-radius:var(--ui-radius-md,8px);cursor:pointer;color:inherit}.gemboss-ei-pick-row:hover:not([aria-disabled=true]),.gemboss-ei-pick:focus-within .gemboss-ei-pick-row.is-active:not([aria-disabled=true]){background:var(--ui-surface-2,#eceef2)}.gemboss-ei-pick-row[aria-selected=true]{background:var(--gemboss-accent-soft,#eef0fe)}.gemboss-ei-pick-row[aria-selected=true]:hover:not([aria-disabled=true]),.gemboss-ei-pick:focus-within .gemboss-ei-pick-row[aria-selected=true].is-active:not([aria-disabled=true]){background:color-mix(in srgb,var(--ui-focus,#5661f5) 6%,var(--gemboss-accent-soft,#eef0fe))}.gemboss-ei-pick-list:focus-visible>.gemboss-ei-pick-row.is-active{outline:2px solid var(--ui-focus,#5661f5);outline-offset:-2px}.gemboss-ei-pick-row[aria-disabled=true]{cursor:default}.gemboss-ei-pick-list:not(.is-reloading) .gemboss-ei-pick-row[aria-disabled=true] :is(.gemboss-ei-pick-title,.gemboss-ei-pick-media){opacity:.55}.gemboss-ei-pick-list.is-reloading{opacity:.55}.gemboss-ei-pick-media{flex:none;display:grid;place-items:center;width:40px;height:40px;box-sizing:border-box;border:1px solid var(--ui-border,#e5e7ea);border-radius:var(--ui-radius-md,8px);background:var(--ui-surface-2,#eceef2);object-fit:cover;color:var(--ui-text-muted,#686b71)}.gemboss-ei-pick-text{flex:1 1 auto;min-width:0;display:flex;flex-direction:column}.gemboss-ei-pick-head{display:flex;align-items:center;gap:var(--ui-space-2,8px);min-width:0}.gemboss-ei-pick-title{flex:0 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:var(--ui-fs-body,13px);line-height:20px;font-weight:650;color:var(--ui-text-strong,#1b1c1e)}.gemboss-ei-pick-head>.ui-tag{flex:none}.gemboss-ei-pick-sub{display:flex;min-width:0;font-size:var(--ui-fs-body,13px);line-height:20px;color:var(--ui-text-muted,#686b71);white-space:nowrap}.gemboss-ei-pick-note{flex:0 0 auto;max-width:100%;overflow:hidden;text-overflow:ellipsis}.gemboss-ei-pick-note.is-blocked{color:var(--gemboss-danger-strong,var(--gemboss-danger,#c4291c))}.gemboss-ei-pick-rest{flex:1 1 0;min-width:0;overflow:hidden;text-overflow:ellipsis}.gemboss-ei-pick-note+.gemboss-ei-pick-rest{margin-left:.25em}.gemboss-ei-pick-check{flex:none;color:var(--ui-focus,#5661f5)}.gemboss-ei-pick-drill{flex:none;color:var(--ui-text-muted,#686b71)}.gemboss-ei-pick-error{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:var(--ui-space-3,12px)}.gemboss-ei-pick-more>.ui-btn{width:100%}.gemboss-ei-pick-skeleton{display:flex;flex-direction:column}.gemboss-ei-pick-skeleton-row{display:flex;align-items:center;gap:var(--ui-space-3,12px);padding:var(--ui-space-2,8px)}.gemboss-ei-pick-skeleton-row>.gemboss-ei-pick-media{height:40px;border:0}.gemboss-ei-pick-skeleton-text{flex:1;display:flex;flex-direction:column;gap:var(--ui-space-2,8px)}.gemboss-ei-pick-skeleton-text>:first-child{width:40%}.gemboss-ei-pick-skeleton-text>:last-child{width:70%}@media (pointer:coarse),(max-width:47.9975em){.gemboss-ei-pick-clear{width:44px;height:44px;margin-right:0}}
|
|
1
|
+
.gemboss-ei-pick{display:flex;flex-direction:column;gap:var(--ui-space-3,12px);min-width:0}.gemboss-ei-pick-search{flex:none}.gemboss-ei-pick-search-icon{flex:none;color:var(--ui-text-muted,#686b71)}.gemboss-ei-pick-clear{flex:none;display:grid;place-items:center;width:24px;height:24px;margin-right:var(--ui-space-1,4px);padding:0;border:0;border-radius:var(--ui-radius-sm,6px);background:none;color:var(--ui-text-muted,#686b71);cursor:pointer}.gemboss-ei-pick-clear:hover{background:var(--ui-surface-2,#eceef2);color:var(--ui-text-strong,#1b1c1e)}.gemboss-ei-pick-clear:focus-visible{outline:2px solid var(--ui-focus,#5661f5);outline-offset:0}.gemboss-ei-pick-list{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;max-height:min(50vh,420px);overflow-y:auto;outline:none}.gemboss-ei-pick-row{flex:none;display:flex;align-items:center;gap:var(--ui-space-3,12px);min-height:44px;padding:var(--ui-space-2,8px);border-radius:var(--ui-radius-md,8px);cursor:pointer;color:inherit}.gemboss-ei-pick-row:hover:not([aria-disabled=true]),.gemboss-ei-pick:focus-within .gemboss-ei-pick-row.is-active:not([aria-disabled=true]){background:var(--ui-surface-2,#eceef2)}.gemboss-ei-pick-row[aria-selected=true]{background:var(--gemboss-accent-soft,#eef0fe)}.gemboss-ei-pick-row[aria-selected=true]:hover:not([aria-disabled=true]),.gemboss-ei-pick:focus-within .gemboss-ei-pick-row[aria-selected=true].is-active:not([aria-disabled=true]){background:color-mix(in srgb,var(--ui-focus,#5661f5) 6%,var(--gemboss-accent-soft,#eef0fe))}.gemboss-ei-pick-list:focus-visible>.gemboss-ei-pick-row.is-active{outline:2px solid var(--ui-focus,#5661f5);outline-offset:-2px}.gemboss-ei-pick-row[aria-disabled=true]{cursor:default}.gemboss-ei-pick-list:not(.is-reloading) .gemboss-ei-pick-row[aria-disabled=true]:not(.is-stale) :is(.gemboss-ei-pick-title,.gemboss-ei-pick-media){opacity:.55}.gemboss-ei-pick-list.is-reloading,.gemboss-ei-pick-row.is-stale{opacity:.55}.gemboss-ei-pick-media{flex:none;display:grid;place-items:center;width:40px;height:40px;box-sizing:border-box;border:1px solid var(--ui-border,#e5e7ea);border-radius:var(--ui-radius-md,8px);background:var(--ui-surface-2,#eceef2);object-fit:cover;color:var(--ui-text-muted,#686b71)}.gemboss-ei-pick-text{flex:1 1 auto;min-width:0;display:flex;flex-direction:column}.gemboss-ei-pick-head{display:flex;align-items:center;gap:var(--ui-space-2,8px);min-width:0}.gemboss-ei-pick-title{flex:0 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:var(--ui-fs-body,13px);line-height:20px;font-weight:650;color:var(--ui-text-strong,#1b1c1e)}.gemboss-ei-pick-head>.ui-tag{flex:none}.gemboss-ei-pick-sub{display:flex;min-width:0;font-size:var(--ui-fs-body,13px);line-height:20px;color:var(--ui-text-muted,#686b71);white-space:nowrap}.gemboss-ei-pick-note{flex:0 0 auto;max-width:100%;overflow:hidden;text-overflow:ellipsis}.gemboss-ei-pick-note.is-blocked{color:var(--gemboss-danger-strong,var(--gemboss-danger,#c4291c))}.gemboss-ei-pick-rest{flex:1 1 0;min-width:0;overflow:hidden;text-overflow:ellipsis}.gemboss-ei-pick-note+.gemboss-ei-pick-rest{margin-left:.25em}.gemboss-ei-pick-check{flex:none;color:var(--ui-focus,#5661f5)}.gemboss-ei-pick-drill{flex:none;color:var(--ui-text-muted,#686b71)}.gemboss-ei-pick-error{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:var(--ui-space-3,12px)}.gemboss-ei-pick-more>.ui-btn{width:100%}.gemboss-ei-pick-skeleton{display:flex;flex-direction:column}.gemboss-ei-pick-skeleton-row{display:flex;align-items:center;gap:var(--ui-space-3,12px);padding:var(--ui-space-2,8px)}.gemboss-ei-pick-skeleton-row>.gemboss-ei-pick-media{height:40px;border:0}.gemboss-ei-pick-skeleton-text{flex:1;display:flex;flex-direction:column;gap:var(--ui-space-2,8px)}.gemboss-ei-pick-skeleton-text>:first-child{width:40%}.gemboss-ei-pick-skeleton-text>:last-child{width:70%}@media (pointer:coarse),(max-width:47.9975em){.gemboss-ei-pick-clear{width:44px;height:44px;margin-right:0}}
|
package/src/engine-plain.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(j){"use strict";var A=j.gembossUI;if(!A){j.console&&j.console.error("@gemboss/ui engine-plain.js: load kit-plain.js first (it defines gembossUI)");return}if(A.enginePicker)return;var ce={chip:"Engine",dialog:"Assistant engine",tabs:"Engine, setup and status",engineTab:"Engine",setupTab:"Setup",statusTab:"Status",engine:"Engine",model:"Model",effort:"Effort",defaultChoice:"Default",copy:"Copy command",copied:"Copied",copyFailed:"Select the command and copy it",pairingCode:"Pairing code",steps:"Paste the command into Terminal, then press Enter.",bridge:"Bridge on your machine",version:"Version",latest:"Latest",startsAtSignIn:"Starts at sign-in",machine:"Machine",lastSeen:"Last seen",yes:"Yes",no:"No",unknown:"Not known",running:"Running",outdated:"Outdated",offline:"Not connected",unpaired:"Not set up",checking:"Checking",updateDue:"Update available",close:"Close",state:"State",setupTitle:"Install or update"},J={running:"ok",outdated:"warn",offline:"down",unpaired:"down",checking:"idle"},M={ok:"gb-engine-dot gb-engine-dot--ok",warn:"gb-engine-dot gb-engine-dot--warn",down:"gb-engine-dot gb-engine-dot--down",idle:"gb-engine-dot gb-engine-dot--idle"},ge={success:"ui-badge ui-badge--success",warning:"ui-badge ui-badge--warning",critical:"ui-badge ui-badge--critical",info:"ui-badge ui-badge--info"},fe={warn:"gb-engine-notice gb-engine-notice--warn",down:"gb-engine-notice gb-engine-notice--down"},be=["notes","modelControl","statusActions"],Q=function(o){return o&&A.engineMark?A.engineMark(o,{decorative:!0}):null},H=typeof HTMLElement<"u"&&Object.prototype.hasOwnProperty.call(HTMLElement.prototype,"popover"),q=function(o){return typeof Node<"u"&&o instanceof Node},pe=0;function r(o,c,t){var u=document.createElement(o);if(c)for(var s in c){var g=c[s];g==null||g===!1||(s==="text"?u.textContent=String(g):s==="className"?u.className=g:u.setAttribute(s,g===!0?"":String(g)))}return W(u,t),u}function W(o,c){return c==null||c===!1?o:Array.isArray(c)?(c.forEach(function(t){W(o,t)}),o):(o.appendChild(q(c)?c:document.createTextNode(String(c))),o)}function O(o){return typeof DocumentFragment<"u"&&o instanceof DocumentFragment?Array.prototype.slice.call(o.childNodes):o}var me=function(o){return q(o)||Array.isArray(o)&&o.some(q)};function k(o,c){for(var t=Array.prototype.slice.call(c.childNodes),u=0;u<t.length;u++){var s=t[u],g=o.childNodes[u];g?g.nodeType===s.nodeType&&(g.nodeType!==1||g.tagName===s.tagName&&g.getAttribute("data-gb-key")===s.getAttribute("data-gb-key"))?he(g,s):o.replaceChild(s,g):o.appendChild(s)}for(;o.childNodes.length>t.length;)o.removeChild(o.lastChild)}function he(o,c){if(o.nodeType!==1){o.nodeValue!==c.nodeValue&&(o.nodeValue=c.nodeValue);return}var t,u;for(t=o.attributes.length-1;t>=0;t--)u=o.attributes[t].name,u!=="style"&&!c.hasAttribute(u)&&o.removeAttribute(u);for(t=0;t<c.attributes.length;t++)u=c.attributes[t],o.getAttribute(u.name)!==u.value&&o.setAttribute(u.name,u.value);o.hasAttribute("data-gb-slot")||(k(o,c),o.tagName==="SELECT"&&o.value!==c.getAttribute("data-value")&&(o.value=c.getAttribute("data-value")||""))}function ve(o){var c=function(){try{var t=document.createElement("textarea");t.value=o,t.setAttribute("readonly",""),t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();var u=document.execCommand("copy");return t.remove(),u}catch{return!1}};try{if(navigator.clipboard&&navigator.clipboard.writeText)return navigator.clipboard.writeText(o).then(function(){return!0},c)}catch{}return Promise.resolve(c())}function ye(o,c){var t={},u="gb-engine-"+ ++pe,s={open:!1,tab:"engine",said:"",saidTimer:0,focus:null},g=null,l=Object.assign({},ce),V={};function X(n){Object.keys(n||{}).forEach(function(e){var a=n[e];if((e==="bridge"||e==="setup")&&a&&typeof a=="object"&&t[e]&&typeof t[e]=="object"&&(a=Object.assign({},t[e],a)),e==="labels"){l=Object.assign({},l,a||{});return}be.indexOf(e)>=0&&(a=O(a)),e==="engines"&&Array.isArray(a)&&(a=a.map(function(i){return i&&i.note?Object.assign({},i,{note:O(i.note)}):i})),e==="setup"&&a&&a.steps&&(a=Object.assign({},a,{steps:O(a.steps)})),e==="bridge"&&a&&a.detail&&(a=Object.assign({},a,{detail:O(a.detail)})),t[e]=a})}X(c);var S=document.createElement("span");S.className="gb-engine"+(t.className?" "+t.className:"");var m=r("button",{type:"button",className:"gb-engine-chip","aria-haspopup":"dialog","aria-expanded":t.onOpenSettings?null:"false","aria-controls":t.onOpenSettings?null:u+"-panel"}),d=r("div",{id:u+"-panel",className:"gb-engine-panel gemboss-popover-surface",role:"dialog","aria-label":l.dialog,hidden:!0});H&&d.setAttribute("popover","manual"),S.appendChild(m),H?S.appendChild(d):document.body.appendChild(d),o.appendChild(S);function R(){return["engine"].concat(t.setup?["setup"]:[],t.bridge?["status"]:[])}function U(){return R().indexOf(s.tab)>=0?s.tab:"engine"}function w(n,e){return me(e)?(V[n]=Array.isArray(e)?e.filter(q):[e],r("span",{"data-gb-slot":n,"data-gb-key":"slot-"+n,style:"display:contents"})):e}function Z(n){n.querySelectorAll("[data-gb-slot]").forEach(function(e){var a=V[e.getAttribute("data-gb-slot")]||[],i=Array.prototype.slice.call(e.childNodes);i.length===a.length&&i.every(function(b,f){return b===a[f]})||e.replaceChildren.apply(e,a)})}function Ce(){var n=t.bridge&&t.showBridgeDot!==!1?J[t.bridge.state]:null,e=(t.engines||[]).filter(function(b){return b.id===t.engine})[0],a=t.model?(t.models||[]).filter(function(b){return b.id===t.model})[0]:null,i=e?Q(e.mark):null;return r("span",null,[n?r("span",{className:M[n],"aria-hidden":"true"}):null,r("span",{className:"gb-engine-chiplabel"},[e?e.label:t.engine||"",a?r("span",{className:"gb-engine-chipsub",text:" \xB7 "+a.label}):null]),i?r("span",{className:"gb-engine-chipmark"},i):null])}function Ae(){var n=(t.engines||[]).filter(function(i){return i.id===t.engine})[0],e=t.model?(t.models||[]).filter(function(i){return i.id===t.model})[0]:null,a=t.bridge&&t.showBridgeDot!==!1&&t.bridge.state!=="running"?". "+l.bridge+": "+l[t.bridge.state]:"";return l.chip+": "+(n?n.label:t.engine)+(e?" \xB7 "+e.label:"")+a}function $(n,e,a,i,b,f){var h=t.locked||!b||!!f,y=typeof f=="string"?f:void 0;if(a.length>6||a.some(function(p){return p.group})){var P=r("select",{className:"ui-select ui-select--slim gb-engine-select",disabled:h,title:y,"data-kind":n,"data-value":i||""}),C=null,E;return a.forEach(function(p){var de=r("option",{value:p.id,title:p.title,text:p.label,selected:(i||"")===p.id});p.group?((!C||E!==p.group)&&(C=r("optgroup",{label:p.group}),E=p.group,P.appendChild(C)),C.appendChild(de)):(C=null,E=void 0,P.appendChild(de))}),r("label",{className:"gb-engine-field","data-gb-key":n},[r("span",{className:"gb-engine-label",text:e}),P])}var B=u+"-lbl-"+n;return r("div",{className:"gb-engine-field","data-gb-key":n},[r("span",{className:"gb-engine-label",id:B,text:e}),r("div",{className:"gb-engine-opts",role:"group","aria-labelledby":B},a.map(function(p){return r("button",{type:"button",className:"gb-engine-opt","aria-pressed":String((i||"")===p.id),disabled:h,title:y||p.title,text:p.label,"data-kind":n,"data-choice":p.id})}))])}function F(n){return!(t.locked||n.disabled||!t.onEngineChange)}function ee(n){var e=n||u+"-lbl-engine",a=t.engines||[],i=(a.filter(function(f){return f.id===t.engine&&F(f)})[0]||a.filter(F)[0]||{}).id,b=[r("div",{className:"gb-engine-field","data-gb-key":"engine"},[n?null:r("span",{className:"gb-engine-label",id:e,text:l.engine}),r("div",{className:"gb-engine-list",role:"radiogroup","aria-labelledby":e},a.map(function(f){return r("button",{type:"button",role:"radio","aria-checked":String(f.id===t.engine),"data-engine":f.id,"data-gb-key":"engine-"+f.id,tabindex:f.id===i?"0":"-1",className:"gb-engine-row",disabled:!F(f)},[r("span",{className:"gb-engine-rowhead"},[r("span",{className:"gb-engine-rowname",text:f.label}),f.badge?r("span",{className:f.badgeTone?ge[f.badgeTone]:"ui-badge",text:f.badge}):null]),f.note?r("span",{className:"gb-engine-note"},w("note-"+f.id,f.note)):null])}))])];return t.modelControl?b.push(r("div",{className:"gb-engine-field","data-gb-key":"model"},[r("span",{className:"gb-engine-label",text:l.model}),w("modelControl",t.modelControl)])):t.models&&t.models.length&&b.push($("model",l.model,t.models,t.model,t.onModelChange)),t.efforts&&t.efforts.length&&b.push($("effort",l.effort,t.efforts,t.effort,t.onEffortChange,t.effortDisabled)),t.notes&&b.push(r("div",{className:"gb-engine-notes"},w("notes",t.notes))),b}function ne(){var n=t.bridge;return!!n&&(n.state==="outdated"||n.state==="offline"||n.state==="unpaired")}function te(){var n=t.bridge;return ne()?r("p",{className:"gb-engine-callout "+(n.state==="outdated"?"gb-engine-callout--warn":"gb-engine-callout--down"),"data-gb-key":"callout"},[r("strong",{text:l.bridge+": "+l[n.state].toLowerCase()+"."}),n.detail?" ":null,n.detail?w("detail",n.detail):null]):null}function ae(n){var e=t.setup||{},a=[],i=n?null:te();return i&&a.push(i),(e.steps||e.command)&&a.push(r("div",{className:"gb-engine-steps"},e.steps?w("steps",e.steps):r("p",{text:l.steps}))),e.command&&(a.push(r("pre",{className:"gb-engine-cmd"},r("code",{text:e.command}))),a.push(r("div",{className:"gb-engine-actions"},[r("button",{type:"button",className:"ui-btn ui-btn--primary","data-gb-copy":"",text:s.said==="copied"?l.copied:l.copy}),r("span",{className:"gb-engine-said",role:"status",text:s.said==="failed"?l.copyFailed:s.said==="copied"?l.copied:""})]))),e.pairingCode&&a.push(r("p",{className:"gb-engine-code"},[l.pairingCode+": ",r("code",{text:e.pairingCode})])),e.note&&a.push(r("p",{className:"gb-engine-note"},e.note)),a}function ie(n){var e=t.bridge,a=r("dl",{className:"gb-engine-rows"}),i=function(h,y){a.appendChild(r("dt",{text:h})),a.appendChild(r("dd",null,y))},b=function(h){return h==null?l.unknown:h?l.yes:l.no};i(n?l.state:l.bridge,[r("span",{className:M[J[e.state]],"aria-hidden":"true"})," "+l[e.state]]),e.version&&i(l.version,e.version+(e.latest&&e.latest!==e.version?" \xB7 "+l.latest+" "+e.latest:"")),i(l.startsAtSignIn,b(e.autostart)),e.machine&&i(l.machine,e.machine),e.lastSeen&&i(l.lastSeen,e.lastSeen);var f=[a];return e.detail&&e.state!=="running"&&!(n&&ne())&&f.push(r("p",{className:"gb-engine-note"},w("detail",e.detail))),t.statusActions&&f.push(r("div",{className:"gb-engine-actions"},w("statusActions",t.statusActions))),f}function we(){var n=R(),e=U(),a=document.createElement("div");return n.length>1&&a.appendChild(r("div",{className:"ui-tabs gb-engine-tabs",role:"tablist","aria-label":l.tabs,"data-gb-key":"tabs"},n.map(function(i){return r("button",{type:"button",role:"tab",id:u+"-tab-"+i,"aria-controls":u+"-pane-"+i,"aria-selected":String(e===i),tabindex:e===i?"0":"-1","data-tab":i,"data-gb-key":"tab-"+i},[{engine:l.engineTab,setup:l.setupTab,status:l.statusTab}[i],i==="setup"&&t.bridge&&t.bridge.state==="outdated"?r("span",{className:"gb-engine-dot gb-engine-dot--warn",role:"img","aria-label":l.updateDue}):null])}))),a.appendChild(r("div",{className:"gb-engine-pane",role:n.length>1?"tabpanel":null,id:u+"-pane-"+e,"aria-labelledby":n.length>1?u+"-tab-"+e:null,"data-gb-key":"pane-"+e},e==="engine"?ee():e==="setup"?ae():ie())),a}function Te(){var n=document.createElement("div"),e=u+"-s-engine",a=u+"-s-bridge",i=u+"-s-setup";if(n.appendChild(r("section",{className:"ui-card gb-engine-sect","data-gb-part":"engine","aria-labelledby":e,"data-gb-key":"s-engine"},[r("h3",{className:"ui-card__title",id:e,text:l.engine})].concat(ee(e)))),t.bridge||t.setup){var b=[r("h3",{className:"ui-card__title",id:a,text:l.bridge}),te()];t.bridge&&(b=b.concat(ie(!0))),t.setup&&b.push(r("div",{className:"gb-engine-sub","data-gb-part":"setup",role:"group","aria-labelledby":i,tabindex:"-1","data-gb-key":"s-setup"},[r("h4",{className:"gb-engine-subtitle",id:i,text:l.setupTitle})].concat(ae(!0)))),n.appendChild(r("section",{className:"ui-card gb-engine-sect","data-gb-part":"bridge","aria-labelledby":a,tabindex:"-1","data-gb-key":"s-bridge"},b))}return n}var D=null;function v(){var n=Ae();m.setAttribute("aria-label",n),m.title=n,t.onOpenSettings||m.setAttribute("aria-expanded",s.open?"true":"false");var e=(t.engines||[]).filter(function(i){return i.id===t.engine})[0];if(m.className=e&&Q(e.mark)?"gb-engine-chip has-mark":"gb-engine-chip",k(m,Ce()),d.setAttribute("aria-label",l.dialog),V={},g&&(k(g,Te()),Z(g)),!s.open){k(d,document.createElement("div"));return}k(d,we()),Z(d);var a=d.querySelector(".gb-engine-pane");T&&a!==D&&(D&&T.unobserve(D),a&&T.observe(a),D=a)}function x(){s.open&&A.placeFloating(d,m,t.end)}function re(n){n!==t.engine&&(t.engine=n,t.onEngineChange&&t.onEngineChange(n),v())}function oe(n,e,a){var i=n==="model"?t.model:t.effort,b=n==="model"?t.onModelChange:t.onEffortChange;!b||t.locked||((i||"")!==e&&(n==="model"?t.model=e:t.effort=e,b(e)),a?le():v())}function se(n,e){if(n!==U()&&(s.tab=n,t.onTabChange&&t.onTabChange(n),v(),x()),e){var a=d.querySelector('[role="tab"][data-tab="'+n+'"]');a&&a.focus()}}function Se(n){var e=n.currentTarget,a=n.target.closest?n.target:n.target.parentElement,i=a&&a.closest("button");!i||!e.contains(i)||i.disabled||(i.hasAttribute("data-tab")?se(i.getAttribute("data-tab")):i.hasAttribute("data-engine")?re(i.getAttribute("data-engine")):i.hasAttribute("data-choice")?oe(i.getAttribute("data-kind"),i.getAttribute("data-choice"),e===d):i.hasAttribute("data-gb-copy")&&Oe())}function xe(n){var e=n.target;e&&e.tagName==="SELECT"&&e.hasAttribute("data-kind")&&n.currentTarget.contains(e)&&oe(e.getAttribute("data-kind"),e.value,!1)}function Ee(n){var e=n.currentTarget,a=n.target;if(!(!a||!a.getAttribute)){if(a.getAttribute("role")==="tab"){var i=R(),b=i.indexOf(U()),f=n.key==="ArrowRight"?i[(b+1)%i.length]:n.key==="ArrowLeft"?i[(b-1+i.length)%i.length]:n.key==="Home"?i[0]:n.key==="End"?i[i.length-1]:null;if(!f)return;n.preventDefault(),se(f,!0)}else if(a.hasAttribute("data-engine")){var h=n.key==="ArrowDown"||n.key==="ArrowRight"?1:n.key==="ArrowUp"||n.key==="ArrowLeft"?-1:0,y=(t.engines||[]).filter(F);if(!h||!y.length)return;n.preventDefault();var P=y.map(function(B){return B.id}).indexOf(a.getAttribute("data-engine")),C=y[(P+h+y.length)%y.length];re(C.id);var E=e.querySelector('[data-engine="'+(j.CSS&&CSS.escape?CSS.escape(C.id):C.id)+'"]');E&&E.focus()}}}function _(n,e){var a=e?"addEventListener":"removeEventListener";n[a]("click",Se),n[a]("change",xe),n[a]("keydown",Ee)}_(d,!0);function Oe(){var n=t.setup||{};n.command&&ve(n.command).then(function(e){s.said=e?"copied":"failed",v(),clearTimeout(s.saidTimer),s.saidTimer=setTimeout(function(){s.said="",v()},2e3)})}var z=-1,L=0,T=typeof ResizeObserver>"u"?null:new ResizeObserver(function(){d.scrollHeight!==z&&(z=d.scrollHeight,x())});function ke(n){if(!(n.key!=="Escape"||n.defaultPrevented||!s.open)&&!(n.isComposing||n.keyCode===229)){var e=document.activeElement,a=e&&e.closest?e.closest('dialog[open], [aria-modal="true"]'):null;a&&!d.contains(a)||(n.preventDefault(),e&&(d.contains(e)||m.contains(e))?(n.stopPropagation(),le()):N(!1))}}function De(n){var e=n.target,a=e&&e.closest?e.closest('dialog[open], [aria-modal="true"]'):null;a&&!d.contains(a)&&N(!1)}function Le(n){var e=n.target;d.contains(e)||m.contains(e)||e&&e.closest&&e.closest('dialog[open], [aria-modal="true"], .ui-overlay')||N(!1)}function Ie(n){var e=n.target;!e||d.contains(e)||e!==document&&e.nodeType!==9&&!e.contains(m)||L||(L=requestAnimationFrame(function(){L=0,x()}))}function Pe(n){var e=n?"addEventListener":"removeEventListener";document[e]("keydown",ke,!0),document[e]("pointerdown",Le,!0),document[e]("focusin",De,!0),document[e]("scroll",Ie,!0),window[e]("resize",x),n?T&&T.observe(d):(cancelAnimationFrame(L),L=0,T&&T.disconnect(),D=null,z=-1)}function N(n){if(n!==s.open){if(s.open=n,n||(s.tab="engine"),d.hidden=!n,n?d.setAttribute("data-open",""):d.removeAttribute("data-open"),H&&(n&&!d.matches(":popover-open")&&d.showPopover(),!n&&d.matches(":popover-open")&&d.hidePopover()),Pe(n),v(),x(),n){var e=d.querySelector('[role="tab"][aria-selected="true"]')||d.querySelector("button:not([disabled])");e&&e.focus()}t.onOpenChange&&t.onOpenChange(n)}}function le(){N(!1),m.focus()}m.addEventListener("click",function(){if(t.onOpenSettings){s.focus="engine",t.onOpenSettings("engine");return}N(!s.open)});function ue(){var n=s.focus;if(s.focus=null,!(!g||!n||n==="engine")){var e=g.querySelector('[data-gb-part="'+(n==="status"?"bridge":n)+'"]');e&&requestAnimationFrame(function(){e.scrollIntoView({block:"start"});var a=e.querySelector("button:not([disabled]), select:not([disabled]), input:not([disabled])");(a||e).focus({preventScroll:!0})})}}var K=!1,I=null;function G(n){n!==K&&(K=n,t.onOpenChange&&t.onOpenChange(n))}function je(n){g&&Y(),g=r("div",{className:"gb-engine-settings"}),_(g,!0),n.appendChild(g),v(),ue(),typeof IntersectionObserver>"u"?G(!0):(I=new IntersectionObserver(function(e){G(e[e.length-1].isIntersecting)}),I.observe(g))}function Y(){g&&(I&&(I.disconnect(),I=null),_(g,!1),g.remove(),g=null,G(!1))}return v(),{element:S,panel:d,update:function(n){X(n),v()},openTab:function(n){if(t.onOpenSettings){s.focus=n,t.onOpenSettings(n),g&&ue();return}var e=s.open;if(n!==s.tab&&(s.tab=n,t.onTabChange&&t.onTabChange(n)),!e)N(!0);else{v(),x();var a=d.querySelector('[role="tab"][aria-selected="true"]');a&&a.focus()}},open:function(){N(!0)},close:function(){t.onOpenSettings||N(!1)},isOpen:function(){return t.onOpenSettings?K:s.open},mountSettings:je,unmountSettings:Y,destroy:function(){N(!1),Y(),clearTimeout(s.saidTimer),S.remove(),d.remove()}}}function Ne(o){o=o||{};var c=o.tone==="warn"?"warn":"down",t=r("p",{className:fe[c]+(o.className?" "+o.className:""),role:"status"},[r("span",{className:M[c],"aria-hidden":"true"}),r("span",{className:"gb-engine-notice-text"},O(o.node)||o.text||"")]);if(o.onOpenSetup){var u=r("button",{type:"button",className:"gb-engine-notice-link",text:o.action||"Open setup"});u.addEventListener("click",o.onOpenSetup),t.appendChild(u)}return t}A.enginePicker=ye,A.bridgeNotice=Ne})(typeof globalThis<"u"?globalThis:this);
|
|
1
|
+
(function(v){"use strict";var y=v.gembossUI;if(!y){v.console&&v.console.error("@gemboss/ui engine-plain.js: load kit-plain.js first (it defines gembossUI)");return}if(y.enginePicker)return;var $={chip:"Engine",engine:"Engine",model:"Model",effort:"Effort",defaultChoice:"Default",copy:"Copy command",copied:"Copied",copyFailed:"Select the command and copy it",pairingCode:"Pairing code",steps:"Paste the command into Terminal, then press Enter.",bridge:"Bridge on your machine",version:"Version",latest:"Latest",startsAtSignIn:"Starts at sign-in",machine:"Machine",lastSeen:"Last seen",yes:"Yes",no:"No",unknown:"Not known",running:"Running",outdated:"Outdated",offline:"Not connected",unpaired:"Not set up",checking:"Checking",state:"State",setupTitle:"Install or update"},F={running:"ok",outdated:"warn",offline:"down",unpaired:"down",checking:"idle"},V={ok:"gb-engine-dot gb-engine-dot--ok",warn:"gb-engine-dot gb-engine-dot--warn",down:"gb-engine-dot gb-engine-dot--down",idle:"gb-engine-dot gb-engine-dot--idle"},ee={success:"ui-badge ui-badge--success",warning:"ui-badge ui-badge--warning",critical:"ui-badge ui-badge--critical",info:"ui-badge ui-badge--info"},ne={ok:"gb-engine-state gb-engine-state--ok",warn:"gb-engine-state gb-engine-state--warn",down:"gb-engine-state gb-engine-state--down",idle:"gb-engine-state gb-engine-state--idle"},te={warn:"gb-engine-notice gb-engine-notice--warn",down:"gb-engine-notice gb-engine-notice--down"},ie=["notes","modelControl","statusActions"],_=function(i){return i&&y.engineMark?y.engineMark(i,{decorative:!0}):null},I=function(i){if(!i)return null;var s=_(i.mark);return s?{id:i.mark,svg:s}:(s=_(i.id),s?{id:i.id,svg:s}:null)},E=function(i){return typeof Node<"u"&&i instanceof Node},ae=0;function r(i,s,n){var l=document.createElement(i);if(s)for(var b in s){var c=s[b];c==null||c===!1||(b==="text"?l.textContent=String(c):b==="className"?l.className=c:l.setAttribute(b,c===!0?"":String(c)))}return U(l,n),l}function U(i,s){return s==null||s===!1?i:Array.isArray(s)?(s.forEach(function(n){U(i,n)}),i):(i.appendChild(E(s)?s:document.createTextNode(String(s))),i)}function A(i){return typeof DocumentFragment<"u"&&i instanceof DocumentFragment?Array.prototype.slice.call(i.childNodes):i}var re=function(i){return E(i)||Array.isArray(i)&&i.some(E)},B=function(i,s){return i.nodeType===s.nodeType&&(i.nodeType!==1||i.tagName===s.tagName&&i.getAttribute("data-gb-key")===s.getAttribute("data-gb-key"))},G=function(i){return i.nodeType===1?i.getAttribute("data-gb-key"):null};function D(i,s){for(var n=Array.prototype.slice.call(s.childNodes),l=0;l<n.length;l++){var b=n[l],c=i.childNodes[l],u;if(!c){i.appendChild(b);continue}if(B(c,b)){R(c,b);continue}if(G(c)&&n.slice(l+1).some(function(C){return B(c,C)})){i.insertBefore(b,c);continue}if(G(b)){for(u=l+1;u<i.childNodes.length&&!B(i.childNodes[u],b);u++);if(u<i.childNodes.length){for(;u-- >l;)i.removeChild(i.childNodes[l]);R(i.childNodes[l],b);continue}}i.replaceChild(b,c)}for(;i.childNodes.length>n.length;)i.removeChild(i.lastChild)}function R(i,s){if(i.nodeType!==1){i.nodeValue!==s.nodeValue&&(i.nodeValue=s.nodeValue);return}var n,l;for(n=i.attributes.length-1;n>=0;n--)l=i.attributes[n].name,l!=="style"&&!s.hasAttribute(l)&&i.removeAttribute(l);for(n=0;n<s.attributes.length;n++)l=s.attributes[n],i.getAttribute(l.name)!==l.value&&i.setAttribute(l.name,l.value);i.hasAttribute("data-gb-slot")||(D(i,s),i.tagName==="SELECT"&&i.value!==s.getAttribute("data-value")&&(i.value=s.getAttribute("data-value")||""))}function oe(i){var s=function(){try{var n=document.createElement("textarea");n.value=i,n.setAttribute("readonly",""),n.style.position="fixed",n.style.opacity="0",document.body.appendChild(n),n.select();var l=document.execCommand("copy");return n.remove(),l}catch{return!1}};try{if(navigator.clipboard&&navigator.clipboard.writeText)return navigator.clipboard.writeText(i).then(function(){return!0},s)}catch{}return Promise.resolve(s())}function se(i,s){var n={},l="gb-engine-"+ ++ae,b={said:"",saidTimer:0,focus:null},c=null,u=Object.assign({},$),C={};function H(e){Object.keys(e||{}).forEach(function(t){var a=e[t];if((t==="bridge"||t==="setup")&&a&&typeof a=="object"&&n[t]&&typeof n[t]=="object"&&(a=Object.assign({},n[t],a)),t==="labels"){u=Object.assign({},u,a||{});return}ie.indexOf(t)>=0&&(a=A(a)),t==="engines"&&Array.isArray(a)&&(a=a.map(function(o){return o&&o.note?Object.assign({},o,{note:A(o.note)}):o})),t==="setup"&&a&&a.steps&&(a=Object.assign({},a,{steps:A(a.steps)})),t==="bridge"&&a&&a.detail&&(a=Object.assign({},a,{detail:A(a.detail)})),n[t]=a})}H(s),typeof n.onOpenSettings!="function"&&v.console&&v.console.error("@gemboss/ui engine-plain.js: enginePicker needs onOpenSettings (the chip opens your Settings \u203A AI & engines)");var w=document.createElement("span");w.className="gb-engine"+(n.className?" "+n.className:"");var N=r("button",{type:"button",className:"gb-engine-chip","aria-haspopup":"dialog"});w.appendChild(N),i.appendChild(w);function m(e,t){return re(t)?(C[e]=Array.isArray(t)?t.filter(E):[t],r("span",{"data-gb-slot":e,"data-gb-key":"slot-"+e,style:"display:contents"})):t}function de(e){e.querySelectorAll("[data-gb-slot]").forEach(function(t){var a=C[t.getAttribute("data-gb-slot")]||[],o=Array.prototype.slice.call(t.childNodes);o.length===a.length&&o.every(function(g,d){return g===a[d]})||t.replaceChildren.apply(t,a)})}function ue(){var e=n.bridge&&n.showBridgeDot!==!1?F[n.bridge.state]:null,t=(n.engines||[]).filter(function(d){return d.id===n.engine})[0],a=n.model?(n.models||[]).filter(function(d){return d.id===n.model})[0]:null,o=I(t),g=o?o.svg:null;return r("span",null,[e?r("span",{className:V[e],"aria-hidden":"true"}):null,r("span",{className:"gb-engine-chiplabel"},[t?t.label:n.engine||"",a?r("span",{className:"gb-engine-chipsub",text:" \xB7 "+a.label}):null]),g?r("span",{className:"gb-engine-chipmark"},g):null])}function ce(){var e=(n.engines||[]).filter(function(o){return o.id===n.engine})[0],t=n.model?(n.models||[]).filter(function(o){return o.id===n.model})[0]:null,a=n.bridge&&n.showBridgeDot!==!1&&n.bridge.state!=="running"?". "+u.bridge+": "+u[n.bridge.state]:"";return u.chip+": "+(e?e.label:n.engine)+(t?" \xB7 "+t.label:"")+a}function K(e,t,a,o,g,d){var p=n.locked||!g||!!d,x=typeof d=="string"?d:void 0;if(a.length>6||a.some(function(f){return f.group})){var T=r("select",{className:"ui-select ui-select--slim gb-engine-select",disabled:p,title:x,"data-kind":e,"data-value":o||""}),k=null,q;return a.forEach(function(f){var Z=r("option",{value:f.id,title:f.title,text:f.label,selected:(o||"")===f.id});f.group?((!k||q!==f.group)&&(k=r("optgroup",{label:f.group}),q=f.group,T.appendChild(k)),k.appendChild(Z)):(k=null,q=void 0,T.appendChild(Z))}),r("label",{className:"gb-engine-field","data-gb-key":e},[r("span",{className:"gb-engine-label",text:t}),T])}var X=l+"-lbl-"+e;return r("div",{className:"gb-engine-field","data-gb-key":e},[r("span",{className:"gb-engine-label",id:X,text:t}),r("div",{className:"gb-engine-opts",role:"group","aria-labelledby":X},a.map(function(f){return r("button",{type:"button",className:"gb-engine-opt","aria-pressed":String((o||"")===f.id),disabled:p,title:x||f.title,text:f.label,"data-kind":e,"data-choice":f.id})}))])}function O(e){return!(n.locked||e.disabled||!n.onEngineChange)}function ge(e){var t=e,a=n.engines||[],o=(a.filter(function(d){return d.id===n.engine&&O(d)})[0]||a.filter(O)[0]||{}).id,g=[r("div",{className:"gb-engine-field","data-gb-key":"engine"},[r("div",{className:"gb-engine-list",role:"radiogroup","aria-labelledby":t},a.map(function(d){return r("button",{type:"button",role:"radio","aria-checked":String(d.id===n.engine),"data-engine":d.id,"data-gb-key":"engine-"+d.id,tabindex:d.id===o?"0":"-1",className:"gb-engine-row",disabled:!O(d)},[be(d),r("span",{className:"gb-engine-rowhead"},[r("span",{className:"gb-engine-rowname",text:d.label}),d.badge?r("span",{className:d.badgeTone?ee[d.badgeTone]:"ui-badge",text:d.badge}):null]),d.note?r("span",{className:"gb-engine-note"},m("note-"+d.id,d.note)):null])}))])];return n.modelControl?g.push(r("div",{className:"gb-engine-field","data-gb-key":"model"},[r("span",{className:"gb-engine-label",text:u.model}),m("modelControl",n.modelControl)])):n.models&&n.models.length&&g.push(K("model",u.model,n.models,n.model,n.onModelChange)),n.efforts&&n.efforts.length&&g.push(K("effort",u.effort,n.efforts,n.effort,n.onEffortChange,n.effortDisabled)),n.notes&&g.push(r("div",{className:"gb-engine-notes"},m("notes",n.notes))),g}function be(e){var t=I(e);return r("span",{className:"gb-engine-rowmark","data-mark":t?t.id:null,"aria-hidden":"true"},t?t.svg:(Array.from(String(e.label||"").trim())[0]||"?").toUpperCase())}function Y(){var e=n.bridge;return!!e&&(e.state==="outdated"||e.state==="offline"||e.state==="unpaired")}function fe(){var e=n.bridge;return!Y()||!e.detail?null:r("p",{className:"gb-engine-callout "+(e.state==="outdated"?"gb-engine-callout--warn":"gb-engine-callout--down"),"data-gb-key":"callout"},m("detail",e.detail))}function pe(){var e=n.setup||{},t=[];return(e.steps||e.command)&&t.push(r("div",{className:"gb-engine-steps"},e.steps?m("steps",e.steps):r("p",{text:u.steps}))),e.command&&(t.push(r("pre",{className:"gb-engine-cmd"},r("code",{text:e.command}))),t.push(r("div",{className:"gb-engine-actions"},[r("button",{type:"button",className:"ui-btn ui-btn--primary","data-gb-copy":"",text:b.said==="copied"?u.copied:u.copy}),r("span",{className:"gb-engine-said",role:"status",text:b.said==="failed"?u.copyFailed:b.said==="copied"?u.copied:""})]))),e.pairingCode&&t.push(r("p",{className:"gb-engine-code"},[u.pairingCode+": ",r("code",{text:e.pairingCode})])),e.note&&t.push(r("p",{className:"gb-engine-note"},e.note)),t}function me(){var e=n.bridge,t=r("dl",{className:"gb-engine-rows"}),a=function(d,p){t.appendChild(r("dt",{text:d})),t.appendChild(r("dd",null,p))},o=function(d){return d==null?u.unknown:d?u.yes:u.no};e.version&&a(u.version,e.version+(e.latest&&e.latest!==e.version?" \xB7 "+u.latest+" "+e.latest:"")),a(u.startsAtSignIn,o(e.autostart)),e.machine&&a(u.machine,e.machine),e.lastSeen&&a(u.lastSeen,e.lastSeen);var g=[t];return e.detail&&e.state!=="running"&&!Y()&&g.push(r("p",{className:"gb-engine-note"},m("detail",e.detail))),n.statusActions&&g.push(r("div",{className:"gb-engine-actions"},m("statusActions",n.statusActions))),g}function he(){var e=document.createElement("div"),t=l+"-s-engine",a=l+"-s-bridge",o=l+"-s-setup";if(e.appendChild(r("section",{className:"ui-card gb-engine-sect","data-gb-part":"engine","aria-labelledby":t,"data-gb-key":"s-engine"},[r("h3",{className:"ui-card__title",id:t,text:u.engine})].concat(ge(t)))),n.bridge||n.setup){var g=[r("div",{className:"gb-engine-secthead","data-gb-key":"bridge-head"},[r("h3",{className:"ui-card__title",id:a,text:u.bridge}),n.bridge?r("span",{className:ne[F[n.bridge.state]],text:u[n.bridge.state]}):null]),fe()];n.bridge&&(g=g.concat(me())),n.setup&&g.push(r("div",{className:"gb-engine-sub","data-gb-part":"setup",role:"group","aria-labelledby":o,tabindex:"-1","data-gb-key":"s-setup"},[r("h4",{className:"gb-engine-subtitle",id:o,text:u.setupTitle})].concat(pe()))),e.appendChild(r("section",{className:"ui-card gb-engine-sect","data-gb-part":"bridge","aria-labelledby":a,tabindex:"-1","data-gb-key":"s-bridge"},g))}return e}function h(){var e=ce();N.setAttribute("aria-label",e),N.title=e;var t=(n.engines||[]).filter(function(a){return a.id===n.engine})[0];N.className=I(t)?"gb-engine-chip has-mark":"gb-engine-chip",D(N,ue()),C={},c&&(D(c,he()),de(c))}function z(e){e!==n.engine&&(n.engine=e,n.onEngineChange&&n.onEngineChange(e),h())}function J(e,t){var a=e==="model"?n.model:n.effort,o=e==="model"?n.onModelChange:n.onEffortChange;!o||n.locked||((a||"")!==t&&(e==="model"?n.model=t:n.effort=t,o(t)),h())}function ve(e){var t=e.currentTarget,a=e.target.closest?e.target:e.target.parentElement,o=a&&a.closest("button");!o||!t.contains(o)||o.disabled||(o.hasAttribute("data-engine")?z(o.getAttribute("data-engine")):o.hasAttribute("data-choice")?J(o.getAttribute("data-kind"),o.getAttribute("data-choice")):o.hasAttribute("data-gb-copy")&&Ae())}function ye(e){var t=e.target;t&&t.tagName==="SELECT"&&t.hasAttribute("data-kind")&&e.currentTarget.contains(t)&&J(t.getAttribute("data-kind"),t.value)}function Ne(e){var t=e.currentTarget,a=e.target;if(!(!a||!a.getAttribute||!a.hasAttribute("data-engine"))){var o=e.key==="ArrowDown"||e.key==="ArrowRight"?1:e.key==="ArrowUp"||e.key==="ArrowLeft"?-1:0,g=(n.engines||[]).filter(O);if(!(!o||!g.length)){e.preventDefault();var d=g.map(function(T){return T.id}).indexOf(a.getAttribute("data-engine")),p=g[(d+o+g.length)%g.length];z(p.id);var x=t.querySelector('[data-engine="'+(v.CSS&&CSS.escape?CSS.escape(p.id):p.id)+'"]');x&&x.focus()}}}function Q(e,t){var a=t?"addEventListener":"removeEventListener";e[a]("click",ve),e[a]("change",ye),e[a]("keydown",Ne)}function Ae(){var e=n.setup||{};e.command&&oe(e.command).then(function(t){b.said=t?"copied":"failed",h(),clearTimeout(b.saidTimer),b.saidTimer=setTimeout(function(){b.said="",h()},2e3)})}function L(e){b.focus=e,typeof n.onOpenSettings=="function"&&n.onOpenSettings(e),c&&W()}N.addEventListener("click",function(){L("engine")});function W(){var e=b.focus;if(b.focus=null,!(!c||!e||e==="engine")){var t=c.querySelector('[data-gb-part="'+(e==="status"?"bridge":e)+'"]');t&&requestAnimationFrame(function(){t.scrollIntoView({block:"start"});var a=t.querySelector("button:not([disabled]), select:not([disabled]), input:not([disabled])");(a||t).focus({preventScroll:!0})})}}var P=!1,S=null;function M(e){e!==P&&(P=e,n.onOpenChange&&n.onOpenChange(e))}function Ce(e){c&&j(),c=r("div",{className:"gb-engine-settings"}),Q(c,!0),e.appendChild(c),h(),W(),typeof IntersectionObserver>"u"?M(!0):(S=new IntersectionObserver(function(t){M(t[t.length-1].isIntersecting)}),S.observe(c))}function j(){c&&(S&&(S.disconnect(),S=null),Q(c,!1),c.remove(),c=null,M(!1))}return h(),{element:w,update:function(e){H(e),h()},openTab:L,open:function(){L("engine")},close:function(){},isOpen:function(){return P},mountSettings:Ce,unmountSettings:j,destroy:function(){j(),clearTimeout(b.saidTimer),w.remove()}}}function le(i){i=i||{};var s=i.tone==="warn"?"warn":"down",n=r("p",{className:te[s]+(i.className?" "+i.className:""),role:"status"},[r("span",{className:V[s],"aria-hidden":"true"}),r("span",{className:"gb-engine-notice-text"},A(i.node)||i.text||"")]);if(i.onOpenSetup){var l=r("button",{type:"button",className:"gb-engine-notice-link",text:i.action||"Open setup"});l.addEventListener("click",i.onOpenSetup),n.appendChild(l)}return n}y.enginePicker=se,y.bridgeNotice=le})(typeof globalThis<"u"?globalThis:this);
|
package/src/escape.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// ESCAPE, CONSUMED (24/10/2026). A kit part that acts on Escape (a Dialog closing, a picker's box clearing its words, a Popover
|
|
2
|
+
// stepping back or closing) stops the keydown from going further out AND the keyup that follows it: a Polaris Modal it sits in
|
|
3
|
+
// closes on the Escape KEYUP (its keydown only marks it closing, Modal/Dialog.js), so stopping the keydown alone still closed the
|
|
4
|
+
// modal behind the picker (measured: a funnel step's page picker, a product picker over the new-funnel modal). The keyup is caught
|
|
5
|
+
// on the window in the capture phase, before any listener on the document, once, within a second.
|
|
6
|
+
let swallowing = false;
|
|
7
|
+
|
|
8
|
+
export function consumeEscape(e: { stopPropagation: () => void }): void {
|
|
9
|
+
e.stopPropagation();
|
|
10
|
+
if (typeof window === "undefined" || swallowing) return;
|
|
11
|
+
swallowing = true;
|
|
12
|
+
const done = () => { swallowing = false; window.removeEventListener("keyup", onUp, true); clearTimeout(timer); };
|
|
13
|
+
const onUp = (up: KeyboardEvent) => { if (up.key === "Escape") { up.stopPropagation(); done(); } };
|
|
14
|
+
const timer = setTimeout(done, 1000);
|
|
15
|
+
window.addEventListener("keyup", onUp, true);
|
|
16
|
+
}
|