@gramlot/gramlot 0.3.41 → 0.5.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/assets/icons/align-center.svg +4 -0
- package/assets/icons/align-justify.svg +4 -0
- package/assets/icons/align-left.svg +4 -0
- package/assets/icons/align-right.svg +4 -0
- package/assets/icons/applications.svg +4 -0
- package/assets/icons/archive.svg +4 -0
- package/assets/icons/attachment.svg +4 -0
- package/assets/icons/bold.svg +4 -0
- package/assets/icons/book.svg +4 -0
- package/assets/icons/bookmark.svg +4 -0
- package/assets/icons/calendar.svg +4 -0
- package/assets/icons/cancel.svg +4 -0
- package/assets/icons/chart.svg +4 -1
- package/assets/icons/chat.svg +4 -0
- package/assets/icons/clock.svg +4 -0
- package/assets/icons/code.svg +4 -0
- package/assets/icons/collapse.svg +4 -0
- package/assets/icons/columns.svg +4 -0
- package/assets/icons/confirm.svg +4 -0
- package/assets/icons/copy.svg +4 -0
- package/assets/icons/cut.svg +4 -0
- package/assets/icons/database.svg +4 -0
- package/assets/icons/delete.svg +4 -0
- package/assets/icons/detach.svg +4 -0
- package/assets/icons/document.svg +4 -0
- package/assets/icons/download.svg +4 -0
- package/assets/icons/duplicate.svg +4 -0
- package/assets/icons/edit.svg +4 -0
- package/assets/icons/eraser.svg +4 -0
- package/assets/icons/expand.svg +4 -0
- package/assets/icons/export.svg +4 -0
- package/assets/icons/eye.svg +4 -0
- package/assets/icons/filter.svg +4 -0
- package/assets/icons/first.svg +4 -0
- package/assets/icons/folder.svg +4 -0
- package/assets/icons/group.svg +4 -0
- package/assets/icons/help.svg +4 -0
- package/assets/icons/home.svg +4 -0
- package/assets/icons/horizontal-rule.svg +4 -0
- package/assets/icons/image.svg +4 -0
- package/assets/icons/import.svg +4 -0
- package/assets/icons/indent.svg +4 -0
- package/assets/icons/info.svg +4 -0
- package/assets/icons/inspector.svg +4 -0
- package/assets/icons/italic.svg +4 -0
- package/assets/icons/last.svg +4 -0
- package/assets/icons/layers.svg +4 -0
- package/assets/icons/link.svg +4 -0
- package/assets/icons/list-bulleted.svg +4 -0
- package/assets/icons/list-numbered.svg +4 -0
- package/assets/icons/list.svg +4 -0
- package/assets/icons/lock.svg +4 -0
- package/assets/icons/logout.svg +4 -0
- package/assets/icons/navigation.svg +4 -0
- package/assets/icons/new.svg +4 -0
- package/assets/icons/next.svg +4 -0
- package/assets/icons/open.svg +4 -0
- package/assets/icons/outdent.svg +4 -0
- package/assets/icons/palette.svg +4 -0
- package/assets/icons/panel-bottom.svg +4 -0
- package/assets/icons/panel-left.svg +4 -0
- package/assets/icons/panel-right.svg +4 -0
- package/assets/icons/panel-top.svg +4 -0
- package/assets/icons/paragraph.svg +4 -0
- package/assets/icons/paste.svg +4 -0
- package/assets/icons/pause.svg +4 -0
- package/assets/icons/pin.svg +4 -0
- package/assets/icons/play.svg +4 -0
- package/assets/icons/previous.svg +4 -0
- package/assets/icons/print.svg +4 -0
- package/assets/icons/redo.svg +4 -0
- package/assets/icons/refresh.svg +4 -0
- package/assets/icons/save.svg +4 -0
- package/assets/icons/search.svg +4 -0
- package/assets/icons/select-all.svg +4 -0
- package/assets/icons/send.svg +4 -0
- package/assets/icons/settings.svg +4 -0
- package/assets/icons/sort-ascending.svg +4 -0
- package/assets/icons/sort-descending.svg +4 -0
- package/assets/icons/stop.svg +4 -0
- package/assets/icons/strikethrough.svg +4 -0
- package/assets/icons/table.svg +4 -0
- package/assets/icons/tree.svg +4 -0
- package/assets/icons/underline.svg +4 -0
- package/assets/icons/undo.svg +4 -0
- package/assets/icons/unlock.svg +4 -0
- package/assets/icons/upload.svg +4 -0
- package/assets/icons/user.svg +4 -0
- package/assets/icons/warning.svg +4 -0
- package/assets/icons/zoom-in.svg +4 -0
- package/assets/icons/zoom-out.svg +4 -0
- package/dist/components/charts/__init__.py +1 -1
- package/dist/components/charts/assets/index.js +1 -1
- package/dist/components/charts/assets/libraries/vega.js +11 -11
- package/dist/components/charts/grammar.json +2032 -72
- package/dist/components/editors/__init__.py +1 -1
- package/dist/components/editors/assets/collection.js +1 -1
- package/dist/components/editors/assets/index.js +1 -1
- package/dist/components/editors/assets/libraries/codemirror.js +30 -31
- package/dist/components/editors/assets/libraries/jodit.js +453 -447
- package/dist/components/editors/commands.json +113 -1
- package/dist/components/editors/grammar.json +12 -5
- package/dist/components/grid/__init__.py +1 -1
- package/dist/components/grid/assets/index.js +1 -1
- package/dist/components/grid/commands.json +4 -6
- package/dist/components/grid/grammar.json +112 -0
- package/dist/components/inputs/__init__.py +1 -1
- package/dist/components/inputs/assets/index.js +1 -1
- package/dist/components/inputs/grammar.json +5165 -359
- package/dist/components/layout/__init__.py +1 -1
- package/dist/components/layout/assets/collection.js +1 -0
- package/dist/components/layout/assets/index.js +1 -1
- package/dist/components/layout/grammar.json +433 -4
- package/dist/components/tree/__init__.py +1 -1
- package/dist/components/tree/assets/index.js +1 -1
- package/dist/components/tree/grammar.json +51 -0
- package/dist/components/typst/__init__.py +1 -1
- package/dist/components/typst/assets/collection.js +6 -6
- package/dist/components/typst/assets/index.js +1 -1
- package/dist/components/uploads/__init__.py +1 -1
- package/dist/components/uploads/assets/index.js +1 -1
- package/dist/components/uploads/grammar.json +66 -0
- package/dist/declared-collections.js +1 -1
- package/dist/gramlot.js +5486 -2029
- package/dist/gramlot.min.js +361 -138
- package/dist/libraries.json +6 -4
- package/dist/standard-collections.js +1 -1
- package/dist/standard-grammar.js +1 -1
- package/package.json +6 -2
- package/src/binding/ask-dialog.js +17 -3
- package/src/binding/providers.js +3 -2
- package/src/binding/remote.js +41 -6
- package/src/binding/runtime.js +30 -3
- package/src/builder/gramlot-builder.d.ts +3 -1
- package/src/builder/gramlot-builder.js +77 -26
- package/src/builder/source.js +78 -15
- package/src/builder/xml-recipe.js +144 -0
- package/src/chat-file-types.js +13 -0
- package/src/chat.d.ts +1 -0
- package/src/chat.js +35 -25
- package/src/commands.d.ts +1 -1
- package/src/commands.js +1 -1
- package/src/components/border-container.js +64 -6
- package/src/components/buttons.js +26 -31
- package/src/components/chart-bar3d-options.js +0 -1
- package/src/components/chart-boxplot-options.js +1 -1
- package/src/components/chart-candlestick-options.js +1 -1
- package/src/components/chart-engines/echarts-options.js +6 -5
- package/src/components/chart-engines/echarts.js +27 -10
- package/src/components/chart-engines/plotly-map.js +1 -1
- package/src/components/chart-engines/plotly.js +21 -14
- package/src/components/chart-engines/uplot.js +17 -11
- package/src/components/chart-engines/vega.js +17 -11
- package/src/components/chart-funnel-options.js +1 -1
- package/src/components/chart-geographic-options.js +2 -2
- package/src/components/chart-heatmap-options.js +1 -1
- package/src/components/chart-map-bar3d-options.js +2 -2
- package/src/components/chart-map-options.js +2 -2
- package/src/components/chart-pane.js +5 -5
- package/src/components/chart-parallel-options.js +1 -1
- package/src/components/chart-radar-options.js +1 -1
- package/src/components/chart-renderer.js +6 -1
- package/src/components/chart-sankey-options.js +1 -1
- package/src/components/chart-spatial-options.js +6 -2
- package/src/components/chart-sunburst-options.js +13 -1
- package/src/components/chart-theme.js +14 -0
- package/src/components/chart-treemap-options.js +1 -1
- package/src/components/chart-type-data.js +24 -4
- package/src/components/charts.js +7 -6
- package/src/components/check-box-text-editor.js +1 -0
- package/src/components/check-box-text.js +2 -0
- package/src/components/check-box-tree.js +1 -1
- package/src/components/choice-editor.js +5 -4
- package/src/components/choice-field-styles.js +9 -1
- package/src/components/code-mirror-engine.js +19 -5
- package/src/components/code-mirror-gramlot.js +85 -0
- package/src/components/code-mirror.js +3 -2
- package/src/components/drawing.js +43 -14
- package/src/components/editor-commands.js +69 -0
- package/src/components/editor-options.js +1 -1
- package/src/components/editors.js +5 -3
- package/src/components/form-tray-pane.js +18 -0
- package/src/components/graphical-ranges.js +190 -0
- package/src/components/grid-check-sets.js +39 -3
- package/src/components/grid-footer.js +6 -1
- package/src/components/grid-header-interaction.js +3 -3
- package/src/components/grid-styles.js +30 -5
- package/src/components/grid-tools.js +15 -7
- package/src/components/grid.js +109 -15
- package/src/components/html-editor-commands.js +61 -0
- package/src/components/html-editor.js +18 -3
- package/src/components/inputs.js +94 -23
- package/src/components/jodit-engine.js +110 -7
- package/src/components/layout.js +3 -2
- package/src/components/menus.js +89 -26
- package/src/components/numeric-range.js +39 -0
- package/src/components/selected-container.js +123 -64
- package/src/components/tab-bar.js +389 -0
- package/src/components/toolbar-icon-style.js +22 -0
- package/src/components/toolbar-overflow.js +74 -12
- package/src/components/tray-base.js +528 -0
- package/src/components/tray-pane.js +41 -518
- package/src/components/tree.js +56 -4
- package/src/components/typed-editor.js +5 -2
- package/src/components/typst-preview.js +3 -3
- package/src/components/upload-blocks.js +88 -0
- package/src/components/upload-engine.js +21 -31
- package/src/components/uploader.js +168 -47
- package/src/editing-session.js +2 -1
- package/src/gramlot.js +6 -3
- package/src/handlers/dom-handler.d.ts +2 -0
- package/src/handlers/dom-handler.js +9 -0
- package/src/handlers/rpc-handler.d.ts +1 -1
- package/src/handlers/rpc-handler.js +2 -0
- package/src/handlers/source-handler.d.ts +5 -3
- package/src/handlers/source-handler.js +31 -13
- package/src/icons.js +84 -0
- package/src/ide-runtime.js +3 -1
- package/src/index-page-runtime.js +20 -5
- package/src/index-page-styles.js +1 -1
- package/src/index-theme.js +210 -3
- package/src/index.d.ts +7 -2
- package/src/index.js +7 -2
- package/src/libraries.js +4 -4
- package/src/object-extract.d.ts +7 -0
- package/src/object-extract.js +31 -0
- package/src/renderer/attributes.js +1 -1
- package/src/renderer/gramlot-renderer.d.ts +2 -2
- package/src/renderer/gramlot-renderer.js +4 -1
- package/src/server/chat-attachments.js +139 -0
- package/src/server/chat.d.ts +33 -0
- package/src/server/chat.js +168 -0
- package/src/server/database-selectors.d.ts +6 -0
- package/src/server/database-selectors.js +13 -0
- package/src/server/gramlot-file-server.js +6 -1
- package/src/server/gramlot-server.d.ts +19 -3
- package/src/server/gramlot-server.js +149 -19
- package/src/server/index-page.d.ts +10 -0
- package/src/server/index-page.js +92 -8
- package/src/server/index.d.ts +1 -1
- package/src/server/index.js +1 -1
- package/src/server/page-base.js +4 -0
- package/src/server/page-store.d.ts +21 -0
- package/src/server/page-store.js +219 -0
- package/src/server/page.d.ts +6 -1
- package/src/server/page.js +5 -1
- package/src/server/store-recipe.js +102 -0
- package/src/server/toolbar-icon-name.d.ts +93 -0
- package/src/server/upload.d.ts +2 -0
- package/src/server/upload.js +36 -18
- package/src/server/visual-editor.js +4 -2
- package/src/tree-store.d.ts +5 -1
- package/src/tree-store.js +11 -2
- package/src/view/choice-focus.js +17 -0
- package/src/view/html.js +21 -1
- package/src/view/labelbox.js +6 -1
- package/src/view/menu.js +9 -3
- package/src/visual-editor.d.ts +1 -0
- package/src/visual-editor.js +10 -5
- package/themes/gramlot-base/theme.css +60 -28
- package/themes/gramlot-compact/theme.css +2 -0
- package/themes/gramlot-index/icons/align-center.svg +4 -0
- package/themes/gramlot-index/icons/align-justify.svg +4 -0
- package/themes/gramlot-index/icons/align-left.svg +4 -0
- package/themes/gramlot-index/icons/align-right.svg +4 -0
- package/themes/gramlot-index/icons/applications.svg +4 -0
- package/themes/gramlot-index/icons/archive.svg +4 -0
- package/themes/gramlot-index/icons/attachment.svg +4 -0
- package/themes/gramlot-index/icons/bold.svg +4 -0
- package/themes/gramlot-index/icons/book.svg +4 -0
- package/themes/gramlot-index/icons/bookmark.svg +4 -0
- package/themes/gramlot-index/icons/calendar.svg +4 -0
- package/themes/gramlot-index/icons/cancel.svg +4 -0
- package/themes/gramlot-index/icons/chart.svg +4 -0
- package/themes/gramlot-index/icons/chat.svg +4 -0
- package/themes/gramlot-index/icons/clock.svg +4 -0
- package/themes/gramlot-index/icons/code.svg +4 -0
- package/themes/gramlot-index/icons/collapse.svg +4 -0
- package/themes/gramlot-index/icons/columns.svg +4 -0
- package/themes/gramlot-index/icons/confirm.svg +4 -0
- package/themes/gramlot-index/icons/copy.svg +4 -0
- package/themes/gramlot-index/icons/cut.svg +4 -0
- package/themes/gramlot-index/icons/database.svg +4 -0
- package/themes/gramlot-index/icons/delete.svg +4 -0
- package/themes/gramlot-index/icons/detach.svg +4 -0
- package/themes/gramlot-index/icons/document.svg +4 -0
- package/themes/gramlot-index/icons/download.svg +4 -0
- package/themes/gramlot-index/icons/duplicate.svg +4 -0
- package/themes/gramlot-index/icons/edit.svg +4 -0
- package/themes/gramlot-index/icons/eraser.svg +4 -0
- package/themes/gramlot-index/icons/expand.svg +4 -0
- package/themes/gramlot-index/icons/export.svg +4 -0
- package/themes/gramlot-index/icons/eye.svg +4 -0
- package/themes/gramlot-index/icons/filter.svg +4 -0
- package/themes/gramlot-index/icons/first.svg +4 -0
- package/themes/gramlot-index/icons/folder.svg +4 -0
- package/themes/gramlot-index/icons/group.svg +4 -0
- package/themes/gramlot-index/icons/help.svg +4 -0
- package/themes/gramlot-index/icons/home.svg +4 -0
- package/themes/gramlot-index/icons/horizontal-rule.svg +4 -0
- package/themes/gramlot-index/icons/image.svg +4 -0
- package/themes/gramlot-index/icons/import.svg +4 -0
- package/themes/gramlot-index/icons/indent.svg +4 -0
- package/themes/gramlot-index/icons/info.svg +4 -0
- package/themes/gramlot-index/icons/inspector.svg +4 -0
- package/themes/gramlot-index/icons/italic.svg +4 -0
- package/themes/gramlot-index/icons/last.svg +4 -0
- package/themes/gramlot-index/icons/layers.svg +4 -0
- package/themes/gramlot-index/icons/link.svg +4 -0
- package/themes/gramlot-index/icons/list-bulleted.svg +4 -0
- package/themes/gramlot-index/icons/list-numbered.svg +4 -0
- package/themes/gramlot-index/icons/list.svg +4 -0
- package/themes/gramlot-index/icons/lock.svg +4 -0
- package/themes/gramlot-index/icons/logout.svg +4 -0
- package/themes/gramlot-index/icons/navigation.svg +4 -0
- package/themes/gramlot-index/icons/new.svg +4 -0
- package/themes/gramlot-index/icons/next.svg +4 -0
- package/themes/gramlot-index/icons/open.svg +4 -0
- package/themes/gramlot-index/icons/outdent.svg +4 -0
- package/themes/gramlot-index/icons/palette.svg +4 -0
- package/themes/gramlot-index/icons/panel-bottom.svg +4 -0
- package/themes/gramlot-index/icons/panel-left.svg +4 -0
- package/themes/gramlot-index/icons/panel-right.svg +4 -0
- package/themes/gramlot-index/icons/panel-top.svg +4 -0
- package/themes/gramlot-index/icons/paragraph.svg +4 -0
- package/themes/gramlot-index/icons/paste.svg +4 -0
- package/themes/gramlot-index/icons/pause.svg +4 -0
- package/themes/gramlot-index/icons/pin.svg +4 -0
- package/themes/gramlot-index/icons/play.svg +4 -0
- package/themes/gramlot-index/icons/previous.svg +4 -0
- package/themes/gramlot-index/icons/print.svg +4 -0
- package/themes/gramlot-index/icons/redo.svg +4 -0
- package/themes/gramlot-index/icons/refresh.svg +4 -0
- package/themes/gramlot-index/icons/save.svg +4 -0
- package/themes/gramlot-index/icons/search.svg +4 -0
- package/themes/gramlot-index/icons/select-all.svg +4 -0
- package/themes/gramlot-index/icons/send.svg +4 -0
- package/themes/gramlot-index/icons/settings.svg +4 -0
- package/themes/gramlot-index/icons/sort-ascending.svg +4 -0
- package/themes/gramlot-index/icons/sort-descending.svg +4 -0
- package/themes/gramlot-index/icons/stop.svg +4 -0
- package/themes/gramlot-index/icons/strikethrough.svg +4 -0
- package/themes/gramlot-index/icons/table.svg +4 -0
- package/themes/gramlot-index/icons/tree.svg +4 -0
- package/themes/gramlot-index/icons/underline.svg +4 -0
- package/themes/gramlot-index/icons/undo.svg +4 -0
- package/themes/gramlot-index/icons/unlock.svg +4 -0
- package/themes/gramlot-index/icons/upload.svg +4 -0
- package/themes/gramlot-index/icons/user.svg +4 -0
- package/themes/gramlot-index/icons/warning.svg +4 -0
- package/themes/gramlot-index/icons/zoom-in.svg +4 -0
- package/themes/gramlot-index/icons/zoom-out.svg +4 -0
- package/themes/gramlot-index/icons.json +93 -0
- package/themes/gramlot-index/theme.css +24 -0
- package/themes/joanna/theme.css +2 -0
- package/themes/mela/theme.css +2 -0
- package/themes/mimi/theme.css +2 -0
- package/tools/gramlot-tools-inspector.js +11 -3
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import {renderIcon, projectIconAttributes} from '../icons.js';
|
|
1
2
|
/** Shared selection keeps panel Source and light DOM mounted until explicit closing. */
|
|
2
3
|
import {defineComponent} from './registry.js';
|
|
3
4
|
import {Container} from './container.js';
|
|
5
|
+
import {createTabBar, outsideTabStrip, tabBarStyles} from './tab-bar.js';
|
|
4
6
|
import {WindowSurface} from './window-surface.js';
|
|
5
|
-
import {SVG_NS} from '../renderer/attributes.js';
|
|
6
7
|
|
|
7
8
|
function SelectedContainer(HTMLElement) {
|
|
8
9
|
// Named as its factory: inside the body `SelectedContainer` is this class, owner of the static state.
|
|
@@ -12,13 +13,15 @@ function SelectedContainer(HTMLElement) {
|
|
|
12
13
|
static #selectionPanels = new WeakMap();
|
|
13
14
|
static #panelSequence = 0;
|
|
14
15
|
static projectChild(element, attrs, actions) {
|
|
15
|
-
const {pageName = null, title = '', icon = '', badge = null, badge_color = '', closable = false, detachable = false, onClose, hidden = false, disabled = false, ...rest} = attrs;
|
|
16
|
+
const {pageName = null, title = '', icon = '', icon_size = null, icon_color = null, icon_opacity = null, badge = null, badge_color = '', caption_color = null, tab_align = 'start', closable = false, detachable = false, onClose, hidden = false, disabled = false, ...rest} = attrs;
|
|
16
17
|
if (pageName !== null && typeof pageName !== 'string') throw new TypeError('pageName must be a string');
|
|
17
18
|
if (typeof closable !== 'boolean') throw new TypeError('closable must be a boolean');
|
|
18
19
|
if (typeof detachable !== 'boolean') throw new TypeError('detachable must be a boolean');
|
|
20
|
+
if (caption_color != null && typeof caption_color !== 'string') throw new TypeError('caption_color must be text');
|
|
21
|
+
if (!['start','end'].includes(tab_align)) throw new TypeError('Invalid tab_align');
|
|
19
22
|
const panels = SelectedContainer.#selectionPanels;
|
|
20
23
|
const slot = panels.get(element)?.slot ?? `panel-${++SelectedContainer.#panelSequence}`;
|
|
21
|
-
panels.set(element, {pageName, title, icon, badge, badge_color, closable, detachable, hidden, disabled, slot,
|
|
24
|
+
panels.set(element, {pageName, title, icon, icon_size, icon_color, icon_opacity, badge, badge_color, caption_color, tab_align, closable, detachable, hidden, disabled, slot,
|
|
22
25
|
remove: actions.remove, allowClose: () => onClose == null ? true : actions.invoke('onClose', onClose, {})});
|
|
23
26
|
rest.slot = slot;
|
|
24
27
|
if (element.parentElement) element.parentElement.scheduleSelection();
|
|
@@ -204,6 +207,11 @@ const selectionChildParameters = {
|
|
|
204
207
|
title: {dtype:'T', default:''},
|
|
205
208
|
onClose: {inline: []},
|
|
206
209
|
};
|
|
210
|
+
// Tab presentation of a child pane: only a tabContainer draws a strip.
|
|
211
|
+
const tabChildParameters = {
|
|
212
|
+
caption_color: {dtype:'T', nullable:true, binding:'read'},
|
|
213
|
+
tab_align: {dtype:'T', default:'start', binding:'read', enum:['start','end']},
|
|
214
|
+
};
|
|
207
215
|
|
|
208
216
|
export const StackContainer = defineComponent({
|
|
209
217
|
name:'stackContainer', tag:'gramlot-stack-container', base:SelectedContainer, subTags:'*',
|
|
@@ -213,14 +221,15 @@ export const StackContainer = defineComponent({
|
|
|
213
221
|
|
|
214
222
|
export const TabContainer = defineComponent({
|
|
215
223
|
name:'tabContainer', tag:'gramlot-tab-container', base:SelectedContainer, subTags:'*',
|
|
216
|
-
sourceContext: true, childParameters: {...selectionChildParameters, title:{...selectionChildParameters.title, required:true}, detachable:{dtype:'B'}},
|
|
224
|
+
sourceContext: true, childParameters: {...selectionChildParameters, title:{...selectionChildParameters.title, required:true}, detachable:{dtype:'B'}, ...tabChildParameters},
|
|
217
225
|
parameters: {
|
|
218
|
-
tabMode: {dtype:'T', default:'tabs', binding:'read', enum:['tabs','underline']},
|
|
226
|
+
tabMode: {dtype:'T', default:'tabs', binding:'read', enum:['tabs','underline','tabBar']},
|
|
219
227
|
tabPosition: {dtype:'T', default:'top', binding:'read', enum:['top','bottom','left','right']},
|
|
220
228
|
tabAlign: {dtype:'T', default:'start', binding:'read', enum:['start','center','end']},
|
|
221
229
|
},
|
|
222
230
|
implementation: Base => class extends Base {
|
|
223
231
|
#tabs = new Map();
|
|
232
|
+
#tabBar;
|
|
224
233
|
constructor() {
|
|
225
234
|
super();
|
|
226
235
|
const doc = this.ownerDocument;
|
|
@@ -236,6 +245,9 @@ export const TabContainer = defineComponent({
|
|
|
236
245
|
border-bottom:1px solid var(--tab-border);background:var(--gramlot-tab-background,var(--gramlot-surface-subtle,#eef1f5))}
|
|
237
246
|
[data-align=center] .tabs{justify-content:safe center}
|
|
238
247
|
[data-align=end] .tabs{justify-content:safe flex-end}
|
|
248
|
+
.tab-entry[data-tab-align=end]{order:1}
|
|
249
|
+
.tab-entry:nth-child(1 of [data-tab-align=end]:not([hidden]):not([data-overflow])){margin-inline-start:auto}
|
|
250
|
+
:is([data-position=left],[data-position=right]) .tab-entry:nth-child(1 of [data-tab-align=end]:not([hidden]):not([data-overflow])){margin-inline-start:0;margin-block-start:auto}
|
|
239
251
|
.tab-entry{position:relative;display:flex;flex:none;align-items:stretch;border:1px solid transparent;border-bottom:0;
|
|
240
252
|
border-radius:var(--tab-radius) var(--tab-radius) 0 0;color:var(--gramlot-tab-color,var(--gramlot-text-secondary,#555))}
|
|
241
253
|
.tab-entry:has([aria-selected=true]){border-color:var(--tab-border);color:var(--gramlot-tab-selected-color,var(--gramlot-ink,#222));
|
|
@@ -251,17 +263,7 @@ export const TabContainer = defineComponent({
|
|
|
251
263
|
@media(hover:hover){.tabs button:not(:disabled):hover{background:var(--gramlot-tab-hover-background,var(--gramlot-selected,#e8f1fc))}}
|
|
252
264
|
.tabs button:disabled{opacity:.5;cursor:default}
|
|
253
265
|
.tabs button:focus-visible{outline:2px solid var(--gramlot-focus-ring,Highlight);outline-offset:-3px}
|
|
254
|
-
.
|
|
255
|
-
.panel:has(>.panel-tools:not([hidden]))>slot{display:block;flex:1;min-height:0;overflow:auto}
|
|
256
|
-
.panel-tools{display:flex;flex:none;justify-content:flex-end;padding:2px 4px;
|
|
257
|
-
background:var(--gramlot-surface-subtle,var(--gramlot-surface,#fff));border-bottom:1px solid var(--tab-border)}
|
|
258
|
-
.detach{display:flex;align-items:center;justify-content:center;touch-action:none;cursor:grab;
|
|
259
|
-
font:inherit;color:inherit;border:0;border-radius:var(--gramlot-radius-sm,4px);background:transparent;
|
|
260
|
-
padding:var(--gramlot-group-action-padding,.2em .4em);min-width:var(--gramlot-touch-target,var(--gramlot-group-action-size,24px));min-height:var(--gramlot-touch-target,var(--gramlot-group-action-size,24px))}
|
|
261
|
-
@media(hover:hover){.detach:hover{background:var(--gramlot-field-readonly-background,#ddd)}}
|
|
262
|
-
.detach:focus-visible{outline:2px solid var(--gramlot-focus-ring,Highlight);outline-offset:-2px}
|
|
263
|
-
.detach svg{width:1.25em;height:1.25em;flex:none;pointer-events:none}
|
|
264
|
-
.detach[data-dragging]{cursor:grabbing;background:var(--gramlot-selected,#e8f1fc)}
|
|
266
|
+
.tab-entry[data-detachable] [role=tab]{touch-action:none;user-select:none;cursor:grab}
|
|
265
267
|
.close{align-self:center;flex:none;min-height:var(--gramlot-touch-target,20px);min-width:var(--gramlot-touch-target,20px);
|
|
266
268
|
padding:0;margin-inline-end:3px;border-radius:var(--tab-radius);font-size:1.15em}
|
|
267
269
|
[hidden]{display:none!important}
|
|
@@ -285,23 +287,59 @@ export const TabContainer = defineComponent({
|
|
|
285
287
|
[data-mode=underline]:is([data-position=left],[data-position=right]) .tab-entry::after{height:auto;width:var(--gramlot-tab-indicator-size,2px);top:0;bottom:0}
|
|
286
288
|
[data-mode=underline][data-position=left] .tab-entry::after{left:auto;right:0}
|
|
287
289
|
[data-mode=underline][data-position=right] .tab-entry::after{left:0;right:auto}`;
|
|
290
|
+
style.textContent += tabBarStyles;
|
|
288
291
|
this.shadowRoot.append(style);
|
|
289
292
|
}
|
|
290
293
|
projectAttributes(attrs, adapt) {
|
|
291
294
|
const rest = super.projectAttributes(attrs, adapt);
|
|
292
295
|
const {tabMode, tabPosition, tabAlign} = this.parameters;
|
|
293
|
-
if (!['tabs','underline'].includes(tabMode)) throw new TypeError('Invalid tabMode');
|
|
296
|
+
if (!['tabs','underline','tabBar'].includes(tabMode)) throw new TypeError('Invalid tabMode');
|
|
294
297
|
if (!['top','bottom','left','right'].includes(tabPosition)) throw new TypeError('Invalid tabPosition');
|
|
295
298
|
if (!['start','center','end'].includes(tabAlign)) throw new TypeError('Invalid tabAlign');
|
|
296
299
|
this.control.dataset.mode = tabMode; this.control.dataset.position = tabPosition;
|
|
297
300
|
this.control.dataset.align = tabAlign;
|
|
298
|
-
|
|
301
|
+
if (tabMode === 'tabBar' && !this.#tabBar) {
|
|
302
|
+
this.#tabBar = createTabBar(this.ownerDocument);
|
|
303
|
+
this.#tabBar.detachTab = (root, position) => {
|
|
304
|
+
for (const [record, entry] of this.#tabs) {
|
|
305
|
+
if (entry.root === root) { this.detachPanel(record, position); break; }
|
|
306
|
+
}
|
|
307
|
+
};
|
|
308
|
+
this.tabStrip.replaceWith(this.#tabBar);
|
|
309
|
+
this.#tabBar.append(this.tabStrip);
|
|
310
|
+
} else if (tabMode !== 'tabBar' && this.#tabBar) {
|
|
311
|
+
for (const entry of this.tabStrip.querySelectorAll('[data-overflow]')) entry.removeAttribute('data-overflow');
|
|
312
|
+
this.#tabBar.replaceWith(this.tabStrip);
|
|
313
|
+
this.#tabBar = null;
|
|
314
|
+
}
|
|
315
|
+
const orientation = ['left','right'].includes(tabPosition) ? 'vertical' : 'horizontal';
|
|
316
|
+
this.tabStrip.setAttribute('aria-orientation', orientation);
|
|
317
|
+
if (this.#tabBar) this.#tabBar.dataset.position = orientation;
|
|
299
318
|
return rest;
|
|
300
319
|
}
|
|
320
|
+
#focusAfterClose() {
|
|
321
|
+
const active = this.tabStrip.querySelector('[aria-selected=true]');
|
|
322
|
+
if (!active) return;
|
|
323
|
+
if (this.#tabBar?.hasAttribute('inert')) {
|
|
324
|
+
const panel = this.shadowRoot.getElementById(active.getAttribute('aria-controls'));
|
|
325
|
+
panel.tabIndex = -1;
|
|
326
|
+
panel.focus();
|
|
327
|
+
} else active.focus();
|
|
328
|
+
}
|
|
301
329
|
renderTabs(records, selected) {
|
|
302
330
|
for (const [record, entry] of this.#tabs) {
|
|
303
|
-
if (
|
|
331
|
+
if (records.includes(record)) continue;
|
|
332
|
+
if (this.#tabBar && !entry.root.hidden && !entry.root.hasAttribute('data-overflow') && !this.#tabBar.hasAttribute('inert')) {
|
|
333
|
+
const spacer = this.ownerDocument.createElement('div');
|
|
334
|
+
spacer.className = 'tab-entry closing';
|
|
335
|
+
spacer.inert = true;
|
|
336
|
+
spacer.setAttribute('aria-hidden', 'true');
|
|
337
|
+
entry.root.replaceWith(spacer);
|
|
338
|
+
this.ownerDocument.defaultView.setTimeout(() => spacer.remove(), 200);
|
|
339
|
+
} else entry.root.remove();
|
|
340
|
+
this.#tabs.delete(record);
|
|
304
341
|
}
|
|
342
|
+
let visibleCount = 0;
|
|
305
343
|
for (const [index, record] of records.entries()) {
|
|
306
344
|
let entry = this.#tabs.get(record);
|
|
307
345
|
if (!entry) {
|
|
@@ -311,62 +349,86 @@ export const TabContainer = defineComponent({
|
|
|
311
349
|
record.viewport.setAttribute('role', 'tabpanel');
|
|
312
350
|
record.viewport.setAttribute('aria-labelledby', button.id);
|
|
313
351
|
const icon = doc.createElement('span'), caption = doc.createElement('span'), badge = doc.createElement('span');
|
|
314
|
-
icon.className = 'icon'; icon.setAttribute('aria-hidden', 'true'); caption.className = 'caption'; badge.className = 'badge';
|
|
352
|
+
icon.className = 'icon'; icon.setAttribute('iconslot', ''); icon.setAttribute('aria-hidden', 'true'); caption.className = 'caption'; badge.className = 'badge';
|
|
315
353
|
button.append(icon, caption, badge);
|
|
316
354
|
close.className = 'close'; close.textContent = '×';
|
|
317
|
-
|
|
355
|
+
let pointerId = null;
|
|
356
|
+
let suppressClick = false;
|
|
357
|
+
// tabBar owns its preview and reorder gesture. Plain strips only detach.
|
|
358
|
+
button.addEventListener('pointerdown', event => {
|
|
359
|
+
suppressClick = false;
|
|
360
|
+
if (this.#tabBar || !root.hasAttribute('data-detachable') || button.disabled ||
|
|
361
|
+
event.button !== 0 || !event.isPrimary) return;
|
|
362
|
+
pointerId = event.pointerId;
|
|
363
|
+
button.setPointerCapture(pointerId);
|
|
364
|
+
});
|
|
365
|
+
button.addEventListener('pointerup', event => {
|
|
366
|
+
if (event.pointerId !== pointerId) return;
|
|
367
|
+
pointerId = null;
|
|
368
|
+
const vertical = this.tabStrip.getAttribute('aria-orientation') === 'vertical';
|
|
369
|
+
if (!this.#tabBar && outsideTabStrip(this.tabStrip, vertical, event)) {
|
|
370
|
+
suppressClick = true;
|
|
371
|
+
this.detachPanel(record, {left:event.clientX-12, top:event.clientY-12});
|
|
372
|
+
}
|
|
373
|
+
});
|
|
374
|
+
for (const type of ['pointercancel','lostpointercapture']) {
|
|
375
|
+
button.addEventListener(type, event => {
|
|
376
|
+
if (event.pointerId === pointerId) pointerId = null;
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
button.addEventListener('click', event => {
|
|
380
|
+
if (!suppressClick || !event.detail) this.selectPanel(record);
|
|
381
|
+
suppressClick = false;
|
|
382
|
+
});
|
|
318
383
|
close.addEventListener('click', () => {
|
|
319
384
|
this.closePanel(record);
|
|
320
|
-
if (!close.isConnected) this
|
|
385
|
+
if (!close.isConnected) this.#focusAfterClose();
|
|
321
386
|
});
|
|
322
387
|
button.addEventListener('keydown', event => {
|
|
323
|
-
if (event.key === '
|
|
388
|
+
if (event.key === 'Escape' && pointerId !== null) {
|
|
389
|
+
button.releasePointerCapture(pointerId);
|
|
390
|
+
pointerId = null;
|
|
391
|
+
return;
|
|
392
|
+
}
|
|
393
|
+
if (event.key === 'Enter' && event.shiftKey && root.hasAttribute('data-detachable')) {
|
|
394
|
+
event.preventDefault();
|
|
395
|
+
this.detachPanel(record);
|
|
396
|
+
return;
|
|
397
|
+
}
|
|
398
|
+
if (event.key === 'Delete') { event.preventDefault(); this.closePanel(record); this.#focusAfterClose(); return; }
|
|
324
399
|
const vertical = ['left','right'].includes(this.parameters.tabPosition);
|
|
325
400
|
const previous = vertical ? 'ArrowUp' : 'ArrowLeft', nextKey = vertical ? 'ArrowDown' : 'ArrowRight';
|
|
326
401
|
if (![previous,nextKey,'Home','End'].includes(event.key)) return;
|
|
327
402
|
event.preventDefault();
|
|
328
|
-
const available = [...this
|
|
329
|
-
|
|
330
|
-
let index = available.findIndex(([r]) => r === record);
|
|
403
|
+
const available = [...this.tabStrip.querySelectorAll('.tab-entry:not([hidden]):not([data-overflow]) [role=tab]:not(:disabled)')];
|
|
404
|
+
let index = available.indexOf(button);
|
|
331
405
|
index = event.key === 'Home' ? 0 : event.key === 'End' ? available.length - 1
|
|
332
406
|
: (index + (event.key === nextKey ? 1 : -1) + available.length) % available.length;
|
|
333
|
-
const
|
|
334
|
-
|
|
407
|
+
const next = available[index];
|
|
408
|
+
if (!this.#tabBar) next.click();
|
|
409
|
+
next.focus();
|
|
410
|
+
next.scrollIntoView({block:'nearest',inline:'nearest'});
|
|
335
411
|
});
|
|
336
|
-
|
|
337
|
-
const symbol = doc.createElementNS(SVG_NS, 'svg'); symbol.setAttribute('viewBox','0 0 20 20'); symbol.setAttribute('aria-hidden','true');
|
|
338
|
-
const path = doc.createElementNS(SVG_NS, 'path'); path.setAttribute('d','M11 3h6v6M17 3l-8 8M8 4H4v12h12v-4');
|
|
339
|
-
path.setAttribute('fill','none'); path.setAttribute('stroke','currentColor'); path.setAttribute('stroke-width','1.8');
|
|
340
|
-
path.setAttribute('stroke-linecap','round'); path.setAttribute('stroke-linejoin','round'); symbol.append(path); detach.append(symbol);
|
|
341
|
-
let gesture = null, dragged = false;
|
|
342
|
-
detach.addEventListener('pointerdown', event => {
|
|
343
|
-
if (event.button !== 0) return;
|
|
344
|
-
gesture = {id:event.pointerId,x:event.clientX,y:event.clientY}; dragged = false;
|
|
345
|
-
detach.setPointerCapture(event.pointerId); detach.setAttribute('data-dragging','');
|
|
346
|
-
});
|
|
347
|
-
detach.addEventListener('pointerup', event => {
|
|
348
|
-
if (!gesture || gesture.id !== event.pointerId) return;
|
|
349
|
-
const start = gesture; gesture = null; detach.removeAttribute('data-dragging');
|
|
350
|
-
if (detach.hasPointerCapture(event.pointerId)) detach.releasePointerCapture(event.pointerId);
|
|
351
|
-
dragged = Math.hypot(event.clientX-start.x,event.clientY-start.y) >= 8;
|
|
352
|
-
if (dragged) this.detachPanel(record,{left:event.clientX-12,top:event.clientY-12});
|
|
353
|
-
});
|
|
354
|
-
for (const type of ['pointercancel','lostpointercapture']) detach.addEventListener(type, () => {
|
|
355
|
-
gesture = null; detach.removeAttribute('data-dragging');
|
|
356
|
-
});
|
|
357
|
-
detach.addEventListener('click', () => {
|
|
358
|
-
if (dragged) { dragged = false; return; }
|
|
359
|
-
this.detachPanel(record);
|
|
360
|
-
});
|
|
361
|
-
const tools = doc.createElement('div'); tools.className = 'panel-tools'; tools.append(detach);
|
|
362
|
-
record.viewport.prepend(tools);
|
|
363
|
-
root.append(button, close); this.tabStrip.append(root); entry = {root,button,close,icon,caption,badge,detach,tools}; this.#tabs.set(record, entry);
|
|
412
|
+
root.append(button, close); this.tabStrip.append(root); entry = {root,button,close,icon,caption,badge}; this.#tabs.set(record, entry);
|
|
364
413
|
}
|
|
365
|
-
if (this.tabStrip.children[index] !== entry.root) this.tabStrip.insertBefore(entry.root, this.tabStrip.children[index] ?? null);
|
|
366
|
-
entry.root.hidden = !!record.config.hidden;
|
|
414
|
+
if (!this.#tabBar && this.tabStrip.children[index] !== entry.root) this.tabStrip.insertBefore(entry.root, this.tabStrip.children[index] ?? null);
|
|
415
|
+
entry.root.hidden = !!record.config.hidden || !!(this.#tabBar && record.surface);
|
|
416
|
+
if (!entry.root.hidden) visibleCount++;
|
|
417
|
+
entry.root.toggleAttribute('data-detachable', record.config.detachable && !record.surface);
|
|
367
418
|
const caption = record.config.title || record.config.pageName || String(record.index + 1);
|
|
368
|
-
entry.caption.textContent = caption;
|
|
369
|
-
entry.
|
|
419
|
+
entry.caption.textContent = caption;
|
|
420
|
+
entry.caption.style.color = record.config.caption_color ?? '';
|
|
421
|
+
if (record.config.tab_align === 'end') entry.root.dataset.tabAlign = 'end';
|
|
422
|
+
else delete entry.root.dataset.tabAlign;
|
|
423
|
+
if (entry.root.hasAttribute('data-detachable')) {
|
|
424
|
+
entry.button.title = `${caption} · Drag out or press Shift+Enter to detach`;
|
|
425
|
+
entry.button.setAttribute('aria-keyshortcuts', 'Shift+Enter');
|
|
426
|
+
} else {
|
|
427
|
+
entry.button.title = caption;
|
|
428
|
+
entry.button.removeAttribute('aria-keyshortcuts');
|
|
429
|
+
}
|
|
430
|
+
renderIcon(this, entry.icon, record.config.icon);
|
|
431
|
+
entry.icon.style.cssText = projectIconAttributes(record.config, {style:entry.icon.style.cssText}, this.ownerDocument).style;
|
|
370
432
|
entry.badge.textContent = record.config.badge ?? '';
|
|
371
433
|
entry.badge.hidden = record.config.badge == null || record.config.badge === '';
|
|
372
434
|
entry.badge.style.backgroundColor = record.config.badge_color;
|
|
@@ -374,14 +436,11 @@ export const TabContainer = defineComponent({
|
|
|
374
436
|
entry.button.disabled = !!record.config.disabled;
|
|
375
437
|
entry.button.setAttribute('aria-selected', String(record === selected));
|
|
376
438
|
entry.button.tabIndex = record === selected ? 0 : -1;
|
|
377
|
-
entry.tools.hidden = !record.config.detachable || record !== selected || !!record.surface;
|
|
378
|
-
entry.detach.disabled = !!record.config.disabled;
|
|
379
|
-
entry.detach.setAttribute('aria-label', `Detach ${caption}`);
|
|
380
|
-
entry.detach.title = `Drag or click to detach ${caption}`;
|
|
381
439
|
entry.close.hidden = !record.config.closable;
|
|
382
440
|
entry.close.disabled = !!record.config.disabled;
|
|
383
441
|
entry.close.setAttribute('aria-label', `Close ${caption}`);
|
|
384
442
|
}
|
|
443
|
+
this.#tabBar?.update(visibleCount, this.#tabs.get(selected)?.root);
|
|
385
444
|
}
|
|
386
445
|
},
|
|
387
446
|
});
|