@esportsplus/ui 0.59.1 → 0.61.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/.audit/audit.json +2810 -0
- package/.audit/check-scss.mjs +20 -0
- package/.audit/rules-audit.md +542 -0
- package/README.md +42 -31
- package/RULES.md +115 -0
- package/build/components/accordion/index.d.ts +12 -2175
- package/build/components/accordion/index.js +3 -4
- package/build/components/accordion/scss/index.scss +1 -1
- package/build/components/announcement/scss/index.scss +1 -1
- package/build/components/breadcrumb/index.js +47 -64
- package/build/components/breadcrumb/scss/index.scss +1 -1
- package/build/components/button/copy.d.ts +6 -4
- package/build/components/button/copy.js +24 -20
- package/build/components/button/faces.d.ts +0 -1
- package/build/components/button/faces.js +5 -6
- package/build/components/button/index.d.ts +3 -7
- package/build/components/button/index.js +3 -5
- package/build/components/button/kbd.d.ts +12 -8
- package/build/components/button/kbd.js +59 -74
- package/build/components/button/morph/index.d.ts +2169 -0
- package/build/components/button/morph/index.js +4 -0
- package/build/components/button/morph/save.d.ts +19 -0
- package/build/components/button/morph/save.js +57 -0
- package/build/components/button/morph/template.d.ts +22 -0
- package/build/components/button/morph/template.js +90 -0
- package/build/components/button/scss/index.scss +1 -1
- package/build/components/button/sidebar.js +2 -2
- package/build/components/button/split.d.ts +1 -1
- package/build/components/button/split.js +11 -15
- package/build/components/capslock/index.js +6 -5
- package/build/components/capslock/scss/index.scss +1 -1
- package/build/components/card/scss/index.scss +1 -1
- package/build/components/cc/index.js +103 -111
- package/build/components/cc/scss/index.scss +1 -1
- package/build/components/chat/index.d.ts +6 -0
- package/build/components/chat/index.js +3 -0
- package/build/components/chat/minimap/index.d.ts +52 -0
- package/build/components/chat/minimap/index.js +248 -0
- package/build/components/{chat-minimap/range.js → chat/minimap/model.js} +1 -1
- package/build/components/{chat-minimap → chat/minimap}/spy.d.ts +1 -1
- package/build/components/{chat-minimap → chat/minimap}/spy.js +1 -1
- package/build/components/checkbox/index.d.ts +1 -0
- package/build/components/checkbox/index.js +1 -0
- package/build/components/checkbox/options.d.ts +0 -1
- package/build/components/checkbox/options.js +0 -1
- package/build/components/checkbox/scss/index.scss +1 -1
- package/build/components/clipboard/index.d.ts +3 -2181
- package/build/components/clipboard/index.js +2 -3
- package/build/components/color-picker/index.d.ts +21 -0
- package/build/components/color-picker/index.js +153 -138
- package/build/components/color-picker/scss/index.scss +1 -1
- package/build/components/command/index.d.ts +6 -93
- package/build/components/command/index.js +4 -601
- package/build/components/command/palette.d.ts +103 -0
- package/build/components/command/palette.js +595 -0
- package/build/components/command/scss/index.scss +1 -1
- package/build/components/command/search.d.ts +37 -0
- package/build/components/command/search.js +67 -0
- package/build/components/counter/index.d.ts +15 -4
- package/build/components/counter/index.js +3 -2
- package/build/components/counter/scss/index.scss +1 -1
- package/build/components/datalist/scss/index.scss +1 -1
- package/build/components/dock/index.d.ts +24 -5
- package/build/components/dock/index.js +389 -51
- package/build/components/dock/scss/index.scss +1 -1
- package/build/components/editor/markdown/index.d.ts +3 -22
- package/build/components/editor/markdown/index.js +3 -30
- package/build/components/editor/markdown/render.js +3 -5
- package/build/components/editor/markdown/template.d.ts +22 -0
- package/build/components/editor/markdown/template.js +30 -0
- package/build/components/editor/tree/find.js +3 -3
- package/build/components/editor/tree/index.d.ts +3 -116
- package/build/components/editor/tree/index.js +3 -2225
- package/build/components/editor/tree/template.d.ts +116 -0
- package/build/components/editor/tree/template.js +2225 -0
- package/build/components/editor/viewer/index.d.ts +3 -26
- package/build/components/editor/viewer/index.js +3 -249
- package/build/components/editor/viewer/template.d.ts +26 -0
- package/build/components/editor/viewer/template.js +249 -0
- package/build/components/editor/workspace/index.d.ts +4 -65
- package/build/components/editor/workspace/index.js +4 -1228
- package/build/components/editor/workspace/model.d.ts +29 -37
- package/build/components/editor/workspace/model.js +186 -155
- package/build/components/editor/workspace/session.d.ts +3 -0
- package/build/components/editor/workspace/session.js +61 -34
- package/build/components/editor/workspace/shortcuts.d.ts +0 -2
- package/build/components/editor/workspace/shortcuts.js +0 -2
- package/build/components/editor/workspace/status.d.ts +4 -5
- package/build/components/editor/workspace/status.js +79 -61
- package/build/components/editor/workspace/statusbar.d.ts +5 -3
- package/build/components/editor/workspace/statusbar.js +66 -80
- package/build/components/editor/workspace/strip.d.ts +1 -2
- package/build/components/editor/workspace/strip.js +4 -3
- package/build/components/editor/workspace/tabs.d.ts +35 -3
- package/build/components/editor/workspace/tabs.js +75 -13
- package/build/components/editor/workspace/template.d.ts +65 -0
- package/build/components/editor/workspace/template.js +1145 -0
- package/build/components/error/scss/index.scss +1 -1
- package/build/components/filter/index.js +0 -3
- package/build/components/filter/scss/index.scss +1 -1
- package/build/components/form/index.d.ts +6 -32
- package/build/components/form/index.js +2 -1
- package/build/components/frame/scss/index.scss +1 -1
- package/build/components/grid/scss/index.scss +1 -1
- package/build/components/group/index.d.ts +12 -0
- package/build/components/group/index.js +15 -0
- package/build/components/group/scss/index.scss +2 -0
- package/build/components/heatmap/index.js +10 -32
- package/build/components/heatmap/scss/index.scss +1 -1
- package/build/components/highlight/index.d.ts +2 -3
- package/build/components/highlight/index.js +79 -78
- package/build/components/highlight/scss/index.scss +1 -1
- package/build/components/icon/index.d.ts +4 -3
- package/build/components/icon/index.js +2 -1
- package/build/components/icon/scss/index.scss +1 -1
- package/build/components/image/index.d.ts +3 -16
- package/build/components/image/index.js +2 -2
- package/build/components/image/scss/index.scss +1 -1
- package/build/components/index.d.ts +6 -4
- package/build/components/index.js +6 -4
- package/build/components/inline-edit/index.js +5 -4
- package/build/components/inline-edit/rich.js +79 -82
- package/build/components/inline-edit/scss/index.scss +1 -1
- package/build/components/inline-edit/status.js +4 -3
- package/build/components/input/scss/index.scss +1 -1
- package/build/components/input/tag.js +84 -67
- package/build/components/json/index.d.ts +4 -3
- package/build/components/json/index.js +2 -1
- package/build/components/link/scss/index.scss +1 -1
- package/build/components/loading/scss/index.scss +1 -1
- package/build/components/marquee/index.js +74 -71
- package/build/components/marquee/scss/index.scss +1 -1
- package/build/components/metric/flash.js +12 -11
- package/build/components/metric/scss/index.scss +1 -1
- package/build/components/nav/index.d.ts +1 -1
- package/build/components/nav/scss/index.scss +1 -1
- package/build/components/nav/toc.d.ts +8 -13
- package/build/components/nav/toc.js +9 -21
- package/build/components/nav/tree.d.ts +13 -14
- package/build/components/nav/tree.js +32 -19
- package/build/components/notification/index.d.ts +14 -3
- package/build/components/notification/index.js +4 -3
- package/build/components/notification/scss/index.scss +1 -1
- package/build/components/overlay/scss/index.scss +1 -1
- package/build/components/page/scss/index.scss +1 -1
- package/build/components/pagination/cards.d.ts +1 -0
- package/build/components/pagination/cards.js +4 -6
- package/build/components/pagination/scss/index.scss +1 -1
- package/build/components/panels/dnd.d.ts +47 -0
- package/build/components/panels/dnd.js +106 -0
- package/build/components/panels/group.d.ts +35 -0
- package/build/components/panels/group.js +319 -0
- package/build/components/panels/index.d.ts +25 -0
- package/build/components/panels/index.js +520 -0
- package/build/components/panels/model.d.ts +64 -0
- package/build/components/panels/model.js +446 -0
- package/build/components/panels/resize.d.ts +9 -0
- package/build/components/panels/resize.js +87 -0
- package/build/components/panels/scss/index.scss +2 -0
- package/build/components/panels/subtree.d.ts +3 -0
- package/build/components/panels/subtree.js +43 -0
- package/build/components/preview/buttons.d.ts +20 -0
- package/build/components/preview/buttons.js +26 -0
- package/build/components/{copy/index.d.ts → preview/code.d.ts} +3 -9
- package/build/components/preview/code.js +18 -0
- package/build/components/preview/header.d.ts +16 -0
- package/build/components/preview/header.js +18 -0
- package/build/components/preview/index.d.ts +8704 -0
- package/build/components/preview/index.js +123 -0
- package/build/components/preview/scss/index.scss +2 -0
- package/build/components/preview/source.d.ts +21 -0
- package/build/components/preview/source.js +76 -0
- package/build/components/preview/stage.d.ts +16 -0
- package/build/components/preview/stage.js +24 -0
- package/build/components/progress/scss/index.scss +1 -1
- package/build/components/progress/text.js +9 -11
- package/build/components/radio/index.d.ts +3 -2
- package/build/components/radio/index.js +2 -2
- package/build/components/range/filter.js +8 -9
- package/build/components/range/scss/index.scss +1 -1
- package/build/components/relative-time/index.js +4 -7
- package/build/components/relative-time/scss/index.scss +1 -1
- package/build/components/root/scss/index.scss +1 -1
- package/build/components/select/index.d.ts +1 -1
- package/build/components/select/index.js +72 -59
- package/build/components/select/scss/index.scss +1 -1
- package/build/components/shell/index.d.ts +22 -0
- package/build/components/shell/index.js +272 -0
- package/build/components/shell/scss/index.scss +2 -0
- package/build/components/shortcut-recorder/index.d.ts +2 -3
- package/build/components/shortcut-recorder/index.js +3 -1
- package/build/components/shortcut-recorder/scss/index.scss +1 -1
- package/build/components/sortable/scss/index.scss +1 -1
- package/build/components/sticky-header/scss/index.scss +1 -1
- package/build/components/story/index.d.ts +10 -6
- package/build/components/story/index.js +27 -47
- package/build/components/story/scss/index.scss +1 -1
- package/build/components/surface-field/index.js +13 -16
- package/build/components/surface-field/scss/index.scss +1 -1
- package/build/components/switch/index.d.ts +3 -2
- package/build/components/switch/index.js +2 -2
- package/build/components/tasklist/index.js +3 -1
- package/build/components/tasklist/scss/index.scss +1 -1
- package/build/components/textarea/scss/index.scss +1 -1
- package/build/components/theme/index.d.ts +6 -2
- package/build/components/theme/index.js +4 -3
- package/build/components/theme/scss/index.scss +1 -1
- package/build/components/theme-picker/cards.d.ts +13 -0
- package/build/components/theme-picker/cards.js +17 -0
- package/build/components/theme-picker/index.d.ts +9 -49
- package/build/components/theme-picker/index.js +5 -165
- package/build/components/theme-picker/scss/index.scss +1 -1
- package/build/components/theme-picker/shared.d.ts +26 -0
- package/build/components/theme-picker/shared.js +24 -0
- package/build/components/theme-picker/swatches.d.ts +13 -0
- package/build/components/theme-picker/swatches.js +17 -0
- package/build/components/theme-picker/toggle.d.ts +19 -0
- package/build/components/theme-picker/toggle.js +109 -0
- package/build/components/toast/index.js +10 -10
- package/build/components/toast/scss/index.scss +1 -1
- package/build/components/tooltip/menu.d.ts +2 -0
- package/build/components/tooltip/menu.js +88 -45
- package/build/components/tooltip/scss/index.scss +1 -1
- package/build/components/tooltip/shared.js +2 -2
- package/build/components/typewriter/rotate.js +7 -16
- package/build/components/typewriter/scss/index.scss +1 -1
- package/build/components/uptime/index.js +26 -33
- package/build/components/uptime/scss/index.scss +1 -1
- package/build/components/usage-meter/scss/index.scss +1 -1
- package/build/modifiers/background/scss/index.scss +2 -0
- package/build/modifiers/border/scss/index.scss +2 -0
- package/build/modifiers/box-shadow/scss/index.scss +2 -0
- package/build/modifiers/color/scss/index.scss +2 -0
- package/build/modifiers/scrollbar/scss/index.scss +1 -1
- package/build/shared/animation.js +1 -1
- package/build/shared/drag.d.ts +2 -1
- package/build/shared/drag.js +4 -3
- package/package.json +5 -5
- package/scripts/code-editor-services.test.mjs +1 -1
- package/scripts/code-editor-workspace.test.mjs +28 -18
- package/scripts/panels.test.mjs +262 -0
- package/scripts/workspace-keybindings.test.mjs +1 -1
- package/scripts/workspace-session.test.mjs +8 -6
- package/scripts/workspace-status.test.mjs +9 -1
- package/scripts/workspace-tabs.test.mjs +5 -5
- package/src/components/accordion/index.ts +11 -8
- package/src/components/accordion/scss/index.scss +15 -15
- package/src/components/accordion/scss/variables.scss +11 -7
- package/src/components/announcement/scss/index.scss +21 -24
- package/src/components/announcement/scss/variables.scss +13 -7
- package/src/components/breadcrumb/index.ts +8 -10
- package/src/components/breadcrumb/scss/index.scss +48 -122
- package/src/components/breadcrumb/scss/variables.scss +73 -55
- package/src/components/button/copy.ts +34 -27
- package/src/components/button/faces.ts +2 -4
- package/src/components/button/index.ts +3 -7
- package/src/components/button/kbd.ts +37 -95
- package/src/components/button/morph/index.ts +6 -0
- package/src/components/button/morph/save.ts +55 -0
- package/src/components/button/morph/template.ts +135 -0
- package/src/components/button/scss/index.scss +218 -99
- package/src/components/button/scss/variables.scss +160 -115
- package/src/components/button/sidebar.ts +6 -6
- package/src/components/button/split.ts +5 -6
- package/src/components/capslock/index.ts +9 -8
- package/src/components/capslock/scss/index.scss +21 -25
- package/src/components/capslock/scss/variables.scss +31 -12
- package/src/components/card/scss/index.scss +9 -24
- package/src/components/card/scss/variables.scss +29 -76
- package/src/components/cc/index.ts +15 -10
- package/src/components/cc/scss/index.scss +110 -153
- package/src/components/cc/scss/variables.scss +231 -44
- package/src/components/chat/index.ts +10 -0
- package/src/components/{chat-minimap → chat/minimap}/index.ts +66 -21
- package/src/components/{chat-minimap → chat/minimap}/scss/index.scss +26 -54
- package/src/components/chat/minimap/scss/variables.scss +178 -0
- package/src/components/{chat-minimap → chat/minimap}/spy.ts +1 -1
- package/src/components/checkbox/index.ts +1 -0
- package/src/components/checkbox/options.ts +0 -1
- package/src/components/checkbox/scss/index.scss +25 -31
- package/src/components/checkbox/scss/variables.scss +50 -19
- package/src/components/clipboard/index.ts +4 -3
- package/src/components/color-picker/index.ts +131 -67
- package/src/components/color-picker/scss/index.scss +138 -221
- package/src/components/color-picker/scss/variables.scss +228 -81
- package/src/components/command/index.ts +5 -860
- package/src/components/command/palette.ts +879 -0
- package/src/components/command/scss/index.scss +82 -99
- package/src/components/command/scss/variables.scss +129 -50
- package/src/components/command/search.ts +67 -0
- package/src/components/counter/index.ts +90 -85
- package/src/components/counter/scss/index.scss +32 -41
- package/src/components/counter/scss/variables.scss +44 -16
- package/src/components/datalist/scss/index.scss +25 -25
- package/src/components/datalist/scss/variables.scss +21 -11
- package/src/components/dock/index.ts +505 -42
- package/src/components/dock/scss/index.scss +318 -73
- package/src/components/dock/scss/variables.scss +310 -39
- package/src/components/editor/code/features.ts +0 -1
- package/src/components/editor/code/find.ts +0 -1
- package/src/components/editor/code/keymap.ts +0 -1
- package/src/components/editor/code/scss/_editor.scss +12 -31
- package/src/components/editor/code/scss/_features.scss +12 -45
- package/src/components/editor/code/scss/_services.scss +15 -23
- package/src/components/editor/code/scss/index.scss +1 -1
- package/src/components/editor/code/scss/variables.scss +195 -42
- package/src/components/editor/code/view.ts +0 -1
- package/src/components/editor/diffs/scss/_diffs.scss +24 -77
- package/src/components/editor/diffs/scss/_merge.scss +5 -16
- package/src/components/editor/diffs/scss/index.scss +1 -1
- package/src/components/editor/diffs/scss/variables.scss +148 -11
- package/src/components/editor/markdown/index.ts +3 -67
- package/src/components/editor/markdown/render.ts +3 -6
- package/src/components/editor/markdown/scss/index.scss +30 -48
- package/src/components/editor/markdown/scss/variables.scss +117 -32
- package/src/components/editor/markdown/template.ts +69 -0
- package/src/components/editor/tree/drag.ts +5 -2
- package/src/components/editor/tree/find.ts +5 -4
- package/src/components/editor/tree/index.ts +3 -3434
- package/src/components/editor/tree/scss/index.scss +204 -262
- package/src/components/editor/tree/scss/variables.scss +198 -31
- package/src/components/editor/tree/template.ts +3436 -0
- package/src/components/editor/viewer/index.ts +3 -318
- package/src/components/editor/viewer/scss/_viewer.scss +15 -31
- package/src/components/editor/viewer/scss/index.scss +1 -1
- package/src/components/editor/viewer/scss/variables.scss +56 -14
- package/src/components/editor/viewer/template.ts +321 -0
- package/src/components/editor/workspace/index.ts +4 -1480
- package/src/components/editor/workspace/model.ts +225 -185
- package/src/components/editor/workspace/scss/_keybindings.scss +163 -0
- package/src/components/editor/workspace/scss/{status.scss → _status.scss} +11 -44
- package/src/components/editor/workspace/scss/_tabs.scss +57 -0
- package/src/components/editor/workspace/scss/index.scss +82 -312
- package/src/components/editor/workspace/scss/variables.scss +427 -0
- package/src/components/editor/workspace/session.ts +80 -44
- package/src/components/editor/workspace/shortcuts.ts +0 -2
- package/src/components/editor/workspace/status.ts +110 -80
- package/src/components/editor/workspace/statusbar.ts +38 -35
- package/src/components/editor/workspace/strip.ts +6 -5
- package/src/components/editor/workspace/tabs.ts +115 -15
- package/src/components/editor/workspace/template.ts +1486 -0
- package/src/components/error/index.ts +3 -0
- package/src/components/error/scss/index.scss +34 -65
- package/src/components/error/scss/variables.scss +28 -9
- package/src/components/filter/index.ts +2 -6
- package/src/components/filter/scss/index.scss +9 -2
- package/src/components/filter/scss/variables.scss +6 -6
- package/src/components/form/index.ts +4 -1
- package/src/components/frame/scss/index.scss +31 -42
- package/src/components/frame/scss/variables.scss +25 -18
- package/src/components/grid/scss/index.scss +2 -1
- package/src/components/group/index.ts +24 -0
- package/src/components/group/scss/index.scss +6 -0
- package/src/components/group/scss/variables.scss +4 -0
- package/src/components/heatmap/index.ts +14 -44
- package/src/components/heatmap/scss/index.scss +38 -44
- package/src/components/heatmap/scss/variables.scss +100 -59
- package/src/components/highlight/index.ts +133 -119
- package/src/components/highlight/scss/index.scss +49 -43
- package/src/components/highlight/scss/variables.scss +71 -30
- package/src/components/icon/index.ts +7 -5
- package/src/components/icon/scss/index.scss +7 -2
- package/src/components/icon/scss/variables.scss +2 -0
- package/src/components/image/index.ts +4 -2
- package/src/components/image/scss/index.scss +14 -22
- package/src/components/image/scss/variables.scss +30 -15
- package/src/components/index.ts +6 -4
- package/src/components/inline-edit/index.ts +3 -2
- package/src/components/inline-edit/rich.ts +17 -15
- package/src/components/inline-edit/scss/index.scss +165 -254
- package/src/components/inline-edit/scss/variables.scss +311 -83
- package/src/components/inline-edit/status.ts +2 -1
- package/src/components/input/scrub.ts +1 -1
- package/src/components/input/scss/_field.scss +1 -1
- package/src/components/input/scss/_scrub.scss +14 -25
- package/src/components/input/scss/_tag.scss +26 -46
- package/src/components/input/scss/variables.scss +167 -77
- package/src/components/input/tag.ts +59 -49
- package/src/components/json/index.ts +4 -1
- package/src/components/link/scss/index.scss +1 -4
- package/src/components/link/scss/variables.scss +5 -1
- package/src/components/loading/scss/index.scss +3 -23
- package/src/components/loading/scss/variables.scss +3 -6
- package/src/components/marquee/index.ts +33 -28
- package/src/components/marquee/scss/index.scss +32 -26
- package/src/components/marquee/scss/variables.scss +35 -23
- package/src/components/metric/flash.ts +2 -1
- package/src/components/metric/scss/_flash.scss +125 -145
- package/src/components/metric/scss/index.scss +31 -43
- package/src/components/metric/scss/variables.scss +192 -98
- package/src/components/nav/index.ts +1 -1
- package/src/components/nav/scss/index.scss +46 -49
- package/src/components/nav/scss/variables.scss +61 -64
- package/src/components/nav/spy.ts +2 -0
- package/src/components/nav/toc.ts +11 -31
- package/src/components/nav/tree.ts +56 -24
- package/src/components/notification/index.ts +94 -89
- package/src/components/notification/scss/index.scss +77 -76
- package/src/components/notification/scss/variables.scss +55 -38
- package/src/components/overlay/index.ts +3 -1
- package/src/components/overlay/scss/index.scss +94 -114
- package/src/components/overlay/scss/variables.scss +46 -18
- package/src/components/page/scss/variables.scss +1 -1
- package/src/components/pagination/cards.ts +2 -1
- package/src/components/pagination/scss/index.scss +191 -7
- package/src/components/pagination/scss/variables.scss +112 -36
- package/src/components/panels/dnd.ts +184 -0
- package/src/components/panels/group.ts +437 -0
- package/src/components/panels/index.ts +678 -0
- package/src/components/panels/model.ts +675 -0
- package/src/components/panels/resize.ts +131 -0
- package/src/components/panels/scss/index.scss +394 -0
- package/src/components/panels/scss/variables.scss +197 -0
- package/src/components/panels/subtree.ts +65 -0
- package/src/components/preview/buttons.ts +48 -0
- package/src/components/preview/code.ts +28 -0
- package/src/components/preview/header.ts +23 -0
- package/src/components/preview/index.ts +144 -0
- package/src/components/preview/scss/index.scss +143 -0
- package/src/components/preview/scss/variables.scss +127 -0
- package/src/components/preview/source.ts +73 -0
- package/src/components/preview/stage.ts +33 -0
- package/src/components/progress/scss/index.scss +117 -15
- package/src/components/progress/scss/variables.scss +140 -40
- package/src/components/progress/text.ts +5 -4
- package/src/components/radio/index.ts +2 -4
- package/src/components/range/filter.ts +7 -11
- package/src/components/range/scss/_filter.scss +301 -327
- package/src/components/range/scss/_slider.scss +31 -110
- package/src/components/range/scss/_vertical.scss +8 -20
- package/src/components/range/scss/index.scss +1 -4
- package/src/components/range/scss/variables.scss +374 -70
- package/src/components/relative-time/index.ts +9 -14
- package/src/components/relative-time/scss/index.scss +13 -21
- package/src/components/relative-time/scss/variables.scss +46 -29
- package/src/components/root/scss/index.scss +11 -20
- package/src/components/root/scss/variables.scss +17 -15
- package/src/components/select/index.ts +37 -15
- package/src/components/select/scss/index.scss +24 -51
- package/src/components/select/scss/variables.scss +77 -19
- package/src/components/shell/index.ts +321 -0
- package/src/components/shell/scss/index.scss +214 -0
- package/src/components/shell/scss/variables.scss +89 -0
- package/src/components/shortcut-recorder/index.ts +6 -3
- package/src/components/shortcut-recorder/scss/index.scss +71 -56
- package/src/components/shortcut-recorder/scss/variables.scss +47 -21
- package/src/components/sortable/index.ts +1 -0
- package/src/components/sortable/scss/index.scss +37 -42
- package/src/components/sortable/scss/variables.scss +76 -52
- package/src/components/sticky-header/scss/index.scss +11 -10
- package/src/components/sticky-header/scss/variables.scss +36 -4
- package/src/components/story/index.ts +1 -36
- package/src/components/story/scss/index.scss +22 -98
- package/src/components/story/scss/variables.scss +57 -15
- package/src/components/surface-field/index.ts +18 -20
- package/src/components/surface-field/scss/index.scss +32 -46
- package/src/components/surface-field/scss/variables.scss +92 -23
- package/src/components/switch/index.ts +2 -4
- package/src/components/tasklist/index.ts +8 -2
- package/src/components/tasklist/scss/index.scss +7 -7
- package/src/components/tasklist/scss/variables.scss +18 -13
- package/src/components/textarea/index.ts +1 -0
- package/src/components/textarea/scss/index.scss +9 -7
- package/src/components/textarea/scss/variables.scss +2 -2
- package/src/components/theme/index.ts +12 -4
- package/src/components/theme/scss/index.scss +13 -0
- package/src/components/theme/scss/variables.scss +5 -16
- package/src/components/theme-picker/cards.ts +19 -0
- package/src/components/theme-picker/index.ts +6 -225
- package/src/components/theme-picker/scss/index.scss +77 -167
- package/src/components/theme-picker/scss/variables.scss +220 -0
- package/src/components/theme-picker/shared.ts +54 -0
- package/src/components/theme-picker/swatches.ts +15 -0
- package/src/components/theme-picker/toggle.ts +150 -0
- package/src/components/toast/index.ts +14 -14
- package/src/components/toast/scss/index.scss +130 -155
- package/src/components/toast/scss/variables.scss +89 -52
- package/src/components/tooltip/menu.ts +77 -10
- package/src/components/tooltip/scss/_menu.scss +96 -138
- package/src/components/tooltip/scss/_shared.scss +93 -90
- package/src/components/tooltip/scss/index.scss +52 -54
- package/src/components/tooltip/scss/variables.scss +187 -67
- package/src/components/tooltip/shared.ts +8 -6
- package/src/components/typewriter/rotate.ts +15 -24
- package/src/components/typewriter/scss/index.scss +131 -3
- package/src/components/typewriter/scss/variables.scss +56 -44
- package/src/components/uptime/index.ts +1 -13
- package/src/components/uptime/scss/index.scss +28 -66
- package/src/components/uptime/scss/variables.scss +63 -48
- package/src/components/usage-meter/scss/index.scss +19 -19
- package/src/components/usage-meter/scss/variables.scss +80 -35
- package/src/css-utilities/absolute.scss +54 -52
- package/src/css-utilities/background.scss +22 -24
- package/src/css-utilities/border.scss +21 -21
- package/src/css-utilities/box-shadow.scss +32 -21
- package/src/css-utilities/color.scss +23 -21
- package/src/css-utilities/flex.scss +55 -53
- package/src/css-utilities/group.scss +7 -0
- package/src/css-utilities/hidden.scss +22 -20
- package/src/css-utilities/icon.scss +32 -30
- package/src/css-utilities/layer.scss +10 -10
- package/src/css-utilities/reset.scss +27 -16
- package/src/css-utilities/surface.scss +206 -128
- package/src/css-utilities/text.scss +114 -114
- package/src/modifiers/background/scss/index.scss +1 -0
- package/src/modifiers/background/scss/variables.scss +24 -0
- package/src/modifiers/border/scss/index.scss +1 -0
- package/src/modifiers/border/scss/variables.scss +21 -0
- package/src/modifiers/box-shadow/scss/index.scss +1 -0
- package/src/modifiers/box-shadow/scss/variables.scss +12 -0
- package/src/modifiers/color/scss/index.scss +1 -0
- package/src/modifiers/color/scss/variables.scss +10 -0
- package/src/modifiers/scrollbar/scss/index.scss +3 -2
- package/src/modifiers/scrollbar/scss/variables.scss +4 -3
- package/src/shared/animation.ts +3 -3
- package/src/shared/drag.ts +8 -3
- package/src/tokens/scss/color.scss +53 -37
- package/src/tokens/scss/index.scss +0 -1
- package/src/tokens/scss/state.scss +16 -1
- package/storage/svg/code.svg +1 -1
- package/storage/svg/collapse.svg +1 -0
- package/storage/svg/grid.svg +1 -0
- package/storage/svg/stack.svg +1 -0
- package/build/components/banner/scss/index.scss +0 -2
- package/build/components/button/fan.d.ts +0 -24
- package/build/components/button/fan.js +0 -118
- package/build/components/button/hold.d.ts +0 -31
- package/build/components/button/hold.js +0 -115
- package/build/components/button/icons.d.ts +0 -6
- package/build/components/button/icons.js +0 -35
- package/build/components/button/loading.d.ts +0 -22
- package/build/components/button/loading.js +0 -60
- package/build/components/button/morph.d.ts +0 -22
- package/build/components/button/morph.js +0 -115
- package/build/components/card/expand.d.ts +0 -22
- package/build/components/card/expand.js +0 -118
- package/build/components/card/index.d.ts +0 -6
- package/build/components/card/index.js +0 -4
- package/build/components/chat-minimap/index.d.ts +0 -28
- package/build/components/chat-minimap/index.js +0 -223
- package/build/components/chat-minimap/scss/index.scss +0 -2
- package/build/components/clipboard/copy.d.ts +0 -27
- package/build/components/clipboard/copy.js +0 -48
- package/build/components/copy/index.js +0 -61
- package/build/components/copy/scss/index.scss +0 -2
- package/build/components/highlight/easing.d.ts +0 -2
- package/build/components/highlight/easing.js +0 -19
- package/build/components/pull-to-refresh/index.d.ts +0 -18
- package/build/components/pull-to-refresh/index.js +0 -222
- package/build/components/pull-to-refresh/scss/index.scss +0 -2
- package/src/components/banner/scss/index.scss +0 -37
- package/src/components/banner/scss/variables.scss +0 -16
- package/src/components/button/fan.ts +0 -170
- package/src/components/button/hold.ts +0 -154
- package/src/components/button/icons.ts +0 -21
- package/src/components/button/loading.ts +0 -77
- package/src/components/button/morph.ts +0 -153
- package/src/components/button/scss/_fan.scss +0 -121
- package/src/components/button/scss/_kbd.scss +0 -11
- package/src/components/button/scss/_morph.scss +0 -107
- package/src/components/button/scss/_sidebar.scss +0 -61
- package/src/components/button/scss/_split.scss +0 -53
- package/src/components/card/expand.ts +0 -141
- package/src/components/card/index.ts +0 -8
- package/src/components/card/scss/_expand.scss +0 -234
- package/src/components/chat-minimap/scss/variables.scss +0 -97
- package/src/components/clipboard/copy.ts +0 -49
- package/src/components/copy/index.ts +0 -69
- package/src/components/copy/scss/index.scss +0 -52
- package/src/components/copy/scss/variables.scss +0 -19
- package/src/components/editor/workspace/scss/keybindings.scss +0 -190
- package/src/components/editor/workspace/scss/tabs.scss +0 -56
- package/src/components/highlight/easing.ts +0 -33
- package/src/components/pagination/scss/_arrows.scss +0 -69
- package/src/components/pagination/scss/_cards.scss +0 -121
- package/src/components/pagination/scss/_dots.scss +0 -64
- package/src/components/progress/scss/_text.scss +0 -135
- package/src/components/pull-to-refresh/index.ts +0 -316
- package/src/components/pull-to-refresh/scss/index.scss +0 -128
- package/src/components/pull-to-refresh/scss/variables.scss +0 -38
- package/src/components/typewriter/scss/_caret.scss +0 -34
- package/src/components/typewriter/scss/_retype.scss +0 -68
- package/src/components/typewriter/scss/_rotate.scss +0 -29
- package/src/tokens/scss/transition.scss +0 -21
- /package/build/components/{chat-minimap/range.d.ts → chat/minimap/model.d.ts} +0 -0
- /package/src/components/{chat-minimap/range.ts → chat/minimap/model.ts} +0 -0
|
@@ -0,0 +1,1486 @@
|
|
|
1
|
+
import { effect, flush, onCleanup, reactive, read, root, signal, untrack, write, type Signal } from '@esportsplus/reactivity';
|
|
2
|
+
import { component, html, type Attributes, type Renderable } from '@esportsplus/template';
|
|
3
|
+
import breadcrumb, { type Crumb } from '~/components/breadcrumb';
|
|
4
|
+
import sidebar from '~/components/button/sidebar';
|
|
5
|
+
import command, { type Command, type ResultGroup, type Tab } from '~/components/command';
|
|
6
|
+
import fileTree, {
|
|
7
|
+
FileTreeDecorations,
|
|
8
|
+
FileTreeEditor,
|
|
9
|
+
FileTreeElements,
|
|
10
|
+
fileTreeIcon,
|
|
11
|
+
type FileTreeController,
|
|
12
|
+
type FileTreeElement
|
|
13
|
+
} from '../tree';
|
|
14
|
+
import highlight from '~/components/highlight';
|
|
15
|
+
import icon from '~/components/icon';
|
|
16
|
+
import input from '~/components/input';
|
|
17
|
+
import nav from '~/components/nav';
|
|
18
|
+
import overlay from '~/components/overlay';
|
|
19
|
+
import tooltip from '~/components/tooltip';
|
|
20
|
+
import type { Controller as MenuController, Item } from '~/components/tooltip/menu';
|
|
21
|
+
import scrollbar from '~/modifiers/scrollbar';
|
|
22
|
+
import fuzzy from '~/shared/fuzzy';
|
|
23
|
+
import { mac } from '~/shared/platform';
|
|
24
|
+
import { observe } from '~/shared/resize';
|
|
25
|
+
import codeEditor, { type CodeEditorAttributes } from '../code/editor';
|
|
26
|
+
import type { Controller as EditorController, Options as EditorOptions } from '../code/view';
|
|
27
|
+
import { label as chordLabel, declare, merge, sequence } from './keybindings';
|
|
28
|
+
import {
|
|
29
|
+
EditorWorkspaceModel,
|
|
30
|
+
type WorkspaceConfirmation,
|
|
31
|
+
type WorkspaceDecision,
|
|
32
|
+
type WorkspaceEntry,
|
|
33
|
+
type WorkspaceHost,
|
|
34
|
+
type WorkspaceTab,
|
|
35
|
+
type WorkspaceTarget
|
|
36
|
+
} from './model';
|
|
37
|
+
import navigate from './navigate';
|
|
38
|
+
import hosted from './session';
|
|
39
|
+
import shortcuts, { OPEN, PALETTE } from './shortcuts';
|
|
40
|
+
import statusbar from './statusbar';
|
|
41
|
+
import tabStrip from './strip';
|
|
42
|
+
import left from '@esportsplus/ui/svg/arrow-left.svg';
|
|
43
|
+
import right from '@esportsplus/ui/svg/arrow-right.svg';
|
|
44
|
+
import collapse from '@esportsplus/ui/svg/chevrons-up-down.svg';
|
|
45
|
+
import close from '@esportsplus/ui/svg/close.svg';
|
|
46
|
+
import cmd from '@esportsplus/ui/svg/command.svg';
|
|
47
|
+
import wrap from '@esportsplus/ui/svg/corner-down-right.svg';
|
|
48
|
+
import whitespace from '@esportsplus/ui/svg/eye.svg';
|
|
49
|
+
import save from '@esportsplus/ui/svg/save.svg';
|
|
50
|
+
import magnifier from '@esportsplus/ui/svg/search.svg';
|
|
51
|
+
import undo from '@esportsplus/ui/svg/undo.svg';
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
type CodeEditorWorkspaceAttributes = Attributes & {
|
|
55
|
+
// Called whenever the shown tab or its path changes; the previous cleanup runs first.
|
|
56
|
+
addons?: (context: WorkspaceEditorContext) => void | VoidFunction;
|
|
57
|
+
controller?: (controller: CodeEditorWorkspaceController) => void;
|
|
58
|
+
cwd?: string;
|
|
59
|
+
// The host's own marks, like git status and problems, which the explorer shows and next/previous step between.
|
|
60
|
+
decorations?: FileTreeDecorations | FileTreeDecorations[];
|
|
61
|
+
// The editor for a tab, such as 'editor.markdown', or undefined for the code editor. A mounted editor stays
|
|
62
|
+
// for the next tab that uses the same one, when its controller can 'setDocument'.
|
|
63
|
+
editor?: (tab: WorkspaceTab) => WorkspaceEditor | undefined;
|
|
64
|
+
editorOptions?: EditorOptions | ((tab: WorkspaceTab) => EditorOptions);
|
|
65
|
+
host?: WorkspaceHost;
|
|
66
|
+
model?: EditorWorkspaceModel;
|
|
67
|
+
openTarget?: WorkspaceTarget | (() => WorkspaceTarget | undefined);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
type CodeEditorWorkspaceController = {
|
|
71
|
+
close(path?: string): ReturnType<EditorWorkspaceModel['close']>;
|
|
72
|
+
collapseAll(): void;
|
|
73
|
+
delete(paths?: readonly string[]): ReturnType<EditorWorkspaceModel['delete']>;
|
|
74
|
+
dispose(): void;
|
|
75
|
+
readonly editor: WorkspaceEditorController | undefined;
|
|
76
|
+
focus(): void;
|
|
77
|
+
keybindings(): void;
|
|
78
|
+
readonly model: EditorWorkspaceModel;
|
|
79
|
+
// The next or previous change or problem, in the shown file and then the next file that has one.
|
|
80
|
+
navigate(kind: 'change' | 'problem', backward?: boolean): Promise<boolean>;
|
|
81
|
+
open(path: string, line?: number, column?: number): ReturnType<EditorWorkspaceModel['open']>;
|
|
82
|
+
quickOpen(query?: string): void;
|
|
83
|
+
refresh(): Promise<void>;
|
|
84
|
+
rename(source: string, destination: string): ReturnType<EditorWorkspaceModel['rename']>;
|
|
85
|
+
save(): ReturnType<EditorWorkspaceModel['save']>;
|
|
86
|
+
search(query: string): void;
|
|
87
|
+
toggleExplorer(): void;
|
|
88
|
+
toggleExplorerSide(): void;
|
|
89
|
+
toggleWhitespace(): void;
|
|
90
|
+
toggleWrap(): void;
|
|
91
|
+
undoFiles(): ReturnType<EditorWorkspaceModel['undoFiles']>;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
type Confirmation = {
|
|
95
|
+
request: WorkspaceConfirmation;
|
|
96
|
+
resolve: (decision: WorkspaceDecision) => void;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
type Control = {
|
|
100
|
+
active?: () => boolean;
|
|
101
|
+
disabled?: () => boolean;
|
|
102
|
+
label: string | (() => string);
|
|
103
|
+
onclick: VoidFunction;
|
|
104
|
+
sprite: string | (() => string);
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
// The editor shown for the active tab: it moves on to the next tab that uses the same editor, and is released when a
|
|
108
|
+
// different one takes its place or the workspace goes.
|
|
109
|
+
type Mount = {
|
|
110
|
+
addon?: void | VoidFunction;
|
|
111
|
+
controller?: WorkspaceEditorController;
|
|
112
|
+
editor: WorkspaceEditor;
|
|
113
|
+
// The shown tab's path; the options follow it through renames.
|
|
114
|
+
path: Signal<string>;
|
|
115
|
+
released: boolean;
|
|
116
|
+
tab: WorkspaceTab;
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
type Target = {
|
|
120
|
+
element: FileTreeElement;
|
|
121
|
+
paths: string[];
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
// Forward every attribute, so drafts, saving and reveal keep working.
|
|
125
|
+
type WorkspaceEditor = (attributes: WorkspaceEditorAttributes) => Renderable<unknown>;
|
|
126
|
+
|
|
127
|
+
type WorkspaceEditorAttributes = Omit<CodeEditorAttributes, 'controller' | 'document'> & {
|
|
128
|
+
controller?: (controller: WorkspaceEditorController) => void;
|
|
129
|
+
document: WorkspaceTab['document'];
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
type WorkspaceEditorContext = {
|
|
133
|
+
controller: WorkspaceEditorController;
|
|
134
|
+
host: HTMLElement;
|
|
135
|
+
tab: WorkspaceTab;
|
|
136
|
+
workspace: EditorWorkspaceModel;
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
// Shared by the code and markdown controllers; narrow with 'isWorkspaceCodeEditor' for code-only addons. Without
|
|
140
|
+
// 'setDocument', every tab switch mounts the editor again.
|
|
141
|
+
type WorkspaceEditorController = Pick<EditorController, 'dispose' | 'document' | 'focus' | 'host' | 'scroller' | 'select'> &
|
|
142
|
+
Partial<Pick<EditorController, 'setDocument'>>;
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
// At or below this width the explorer stacks under the editor instead of beside it.
|
|
146
|
+
const COMPACT_WIDTH = 520;
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
let uid = 0;
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
function control({ active, disabled, label, onclick, sprite }: Control) {
|
|
153
|
+
return html`
|
|
154
|
+
<button
|
|
155
|
+
class='button code-workspace-control'
|
|
156
|
+
type='button'
|
|
157
|
+
${{
|
|
158
|
+
'aria-label': label,
|
|
159
|
+
'aria-pressed': active && (() => (active() ? 'true' : 'false')),
|
|
160
|
+
class: active && (() => active() && '--active'),
|
|
161
|
+
disabled,
|
|
162
|
+
onclick,
|
|
163
|
+
title: label
|
|
164
|
+
}}
|
|
165
|
+
>
|
|
166
|
+
${() => icon({ 'aria-hidden': 'true', class: 'code-workspace-control-icon' }, typeof sprite === 'string' ? sprite : sprite())}
|
|
167
|
+
</button>
|
|
168
|
+
`;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// 'Mod' is ⌘ on Apple platforms and Ctrl elsewhere, as the command palette spells it. Text, for titles; keycaps swap
|
|
172
|
+
// the ⌘ for its icon, since most fonts lack the glyph.
|
|
173
|
+
function keys(names: string[]) {
|
|
174
|
+
let apple = mac();
|
|
175
|
+
|
|
176
|
+
return names.map((name) => (name === 'Mod' ? (apple ? '⌘' : 'Ctrl') : name));
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function label(text: string, names: string[]) {
|
|
180
|
+
return `${text} (${keys(names).join(mac() ? '' : '+')})`;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function name(path: string) {
|
|
184
|
+
return path.slice(path.lastIndexOf('/') + 1);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// Path-shaped entries reconcile through the existing store, so watcher ticks keep unchanged rows and expansion.
|
|
188
|
+
function reconcile(store: FileTreeElements, entries: readonly WorkspaceEntry[]) {
|
|
189
|
+
let nodes = new Map<string, { depth: number; element: FileTreeElement; parent: string | null }>();
|
|
190
|
+
|
|
191
|
+
for (let i = 0, n = entries.length; i < n; i++) {
|
|
192
|
+
let entry = entries[i],
|
|
193
|
+
id = '',
|
|
194
|
+
parts = entry.path.split('/');
|
|
195
|
+
|
|
196
|
+
for (let length = 1, m = parts.length; length <= m; length++) {
|
|
197
|
+
let folder = length < m || entry.kind === 'directory',
|
|
198
|
+
parent = length === 1 ? null : id;
|
|
199
|
+
|
|
200
|
+
id = parent === null ? parts[0] : `${parent}/${parts[length - 1]}`;
|
|
201
|
+
nodes.set(id, {
|
|
202
|
+
depth: length,
|
|
203
|
+
element: { id, name: parts[length - 1], type: folder ? 'folder' : 'file', ...(folder ? { children: [] } : {}) },
|
|
204
|
+
parent
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
for (let [id, { element }] of [...store.index]) {
|
|
210
|
+
if (nodes.get(id)?.element.type !== element.type) {
|
|
211
|
+
store.remove(id);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
let sorted = [...nodes].sort(([, a], [, b]) => a.depth - b.depth);
|
|
216
|
+
|
|
217
|
+
for (let i = 0, n = sorted.length; i < n; i++) {
|
|
218
|
+
let [id, node] = sorted[i];
|
|
219
|
+
|
|
220
|
+
if (!store.get(id)) {
|
|
221
|
+
store.add(node.element, node.parent);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
const isWorkspaceCodeEditor = (controller: WorkspaceEditorController): controller is EditorController =>
|
|
228
|
+
'goToLine' in controller && 'rectAt' in controller && 'refresh' in controller;
|
|
229
|
+
|
|
230
|
+
const workspace = ({
|
|
231
|
+
addons,
|
|
232
|
+
controller: receive,
|
|
233
|
+
cwd = '',
|
|
234
|
+
decorations: provided,
|
|
235
|
+
editor: editorFor,
|
|
236
|
+
editorOptions,
|
|
237
|
+
host,
|
|
238
|
+
model: supplied,
|
|
239
|
+
openTarget,
|
|
240
|
+
...attributes
|
|
241
|
+
}: CodeEditorWorkspaceAttributes) => {
|
|
242
|
+
if (!supplied && !host) {
|
|
243
|
+
throw new Error('Workspace: editor.workspace requires a WorkspaceHost or EditorWorkspaceModel');
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
let actions: MenuController | undefined,
|
|
247
|
+
// The tabs select by id, so switching tabs re-renders just the two whose state flips.
|
|
248
|
+
activeId = signal(0),
|
|
249
|
+
// The code editor keymap has no chord sequences, so the workspace runs Mod+K Mod+S itself.
|
|
250
|
+
chords = sequence({
|
|
251
|
+
// Focus inside only: the page's own Mod+K, like site search, still answers under a resting pointer.
|
|
252
|
+
accept: (event) => !confirmation && !!container?.contains(event.target as Node | null),
|
|
253
|
+
actions: { [OPEN[1]]: () => openKeybindings() },
|
|
254
|
+
apple: mac(),
|
|
255
|
+
onpending: (pending) => {
|
|
256
|
+
let text = `${chordLabel(OPEN[0], mac())} was pressed; waiting for the next key…`;
|
|
257
|
+
|
|
258
|
+
if (pending) {
|
|
259
|
+
model.status(text);
|
|
260
|
+
}
|
|
261
|
+
else if (model.state.status === text) {
|
|
262
|
+
model.status('');
|
|
263
|
+
}
|
|
264
|
+
},
|
|
265
|
+
prefix: OPEN[0]
|
|
266
|
+
}),
|
|
267
|
+
confirmation: Confirmation | undefined,
|
|
268
|
+
container: HTMLElement | undefined,
|
|
269
|
+
// Each open tab's path and dirty state as last written to the tree's decorations.
|
|
270
|
+
decorated = new Map<string, boolean>(),
|
|
271
|
+
decorations = new FileTreeDecorations(),
|
|
272
|
+
dialog = reactive({ active: false }),
|
|
273
|
+
elements = new WeakMap<WorkspaceTab, HTMLElement>(),
|
|
274
|
+
files = signal<readonly string[]>([]),
|
|
275
|
+
focusing = false,
|
|
276
|
+
hovered = false,
|
|
277
|
+
id = `code-workspace-${++uid}`,
|
|
278
|
+
keyboard = reactive({ active: false }),
|
|
279
|
+
model = supplied ?? new EditorWorkspaceModel(host!, cwd),
|
|
280
|
+
mount: Mount | undefined,
|
|
281
|
+
palette = reactive({ active: false, index: 0, query: '', tab: 'all' as Tab }),
|
|
282
|
+
release: VoidFunction | undefined,
|
|
283
|
+
request = signal<WorkspaceConfirmation | undefined>(undefined),
|
|
284
|
+
returnFocus: HTMLElement | undefined,
|
|
285
|
+
revealed = 0,
|
|
286
|
+
searchField: HTMLInputElement | undefined,
|
|
287
|
+
// Runs once the open modal has closed and returned focus, to move it where the user went next.
|
|
288
|
+
settle: VoidFunction | undefined,
|
|
289
|
+
shown = signal<Mount | undefined>(undefined),
|
|
290
|
+
statusBar = statusbar(model, () => navigation.go('problem')),
|
|
291
|
+
strip = tabStrip({
|
|
292
|
+
isFile: (path) => treeStore.get(path)?.type === 'file',
|
|
293
|
+
model,
|
|
294
|
+
remount,
|
|
295
|
+
reveal: (path) => {
|
|
296
|
+
peek(true, true);
|
|
297
|
+
treeState.selected = '';
|
|
298
|
+
flush();
|
|
299
|
+
treeState.selected = path;
|
|
300
|
+
}
|
|
301
|
+
}),
|
|
302
|
+
target = signal<Target | undefined>(undefined),
|
|
303
|
+
tree: FileTreeController | undefined,
|
|
304
|
+
treeEditor = new FileTreeEditor(),
|
|
305
|
+
treeState = reactive({ selected: '', selection: new Set<string>() }),
|
|
306
|
+
treeStore = new FileTreeElements([]),
|
|
307
|
+
ui = reactive({ compact: false, peek: false, position: '', ready: false, search: '' });
|
|
308
|
+
|
|
309
|
+
let hosting = hosted(model, () => (mount?.controller ? { controller: mount.controller, tab: mount.tab } : undefined)),
|
|
310
|
+
navigation = navigate({
|
|
311
|
+
bindings: () => (mount ? settings(mount.tab, mount.tab.path).keybindings : model.state.preferences.keybindings),
|
|
312
|
+
hosting,
|
|
313
|
+
model,
|
|
314
|
+
tree: () => tree
|
|
315
|
+
}),
|
|
316
|
+
// What the workspace shows of the model; each getter reads only the signals it needs.
|
|
317
|
+
view = {
|
|
318
|
+
get busy() {
|
|
319
|
+
return model.state.busy > 0;
|
|
320
|
+
},
|
|
321
|
+
get canUndo() {
|
|
322
|
+
return model.state.canUndoFiles;
|
|
323
|
+
},
|
|
324
|
+
get collapsed() {
|
|
325
|
+
return model.state.tabs.length > 0 && !model.state.preferences.explorerOpen;
|
|
326
|
+
},
|
|
327
|
+
get cwd() {
|
|
328
|
+
return model.state.cwd;
|
|
329
|
+
},
|
|
330
|
+
get error() {
|
|
331
|
+
return model.state.error;
|
|
332
|
+
},
|
|
333
|
+
get explorerOpen() {
|
|
334
|
+
return model.state.preferences.explorerOpen;
|
|
335
|
+
},
|
|
336
|
+
get left() {
|
|
337
|
+
return model.state.preferences.explorerSide === 'left';
|
|
338
|
+
},
|
|
339
|
+
get loaded() {
|
|
340
|
+
return model.state.loaded;
|
|
341
|
+
},
|
|
342
|
+
get path() {
|
|
343
|
+
let tab = model.state.active;
|
|
344
|
+
|
|
345
|
+
return tab && !tab.compare ? tab.path : '';
|
|
346
|
+
},
|
|
347
|
+
get project() {
|
|
348
|
+
return model.state.cwd.split(/[\\/]/).filter(Boolean).at(-1) ?? '';
|
|
349
|
+
},
|
|
350
|
+
get status() {
|
|
351
|
+
let state = model.state;
|
|
352
|
+
|
|
353
|
+
return state.status ||
|
|
354
|
+
(state.opening.length
|
|
355
|
+
? `Opening ${state.opening.at(-1)}…`
|
|
356
|
+
: state.busy
|
|
357
|
+
? 'Working…'
|
|
358
|
+
: state.loading
|
|
359
|
+
? 'Refreshing…'
|
|
360
|
+
: state.active?.missing
|
|
361
|
+
? 'File removed from disk; draft retained'
|
|
362
|
+
: '');
|
|
363
|
+
},
|
|
364
|
+
get statusError() {
|
|
365
|
+
return !!model.state.status && model.state.statusKind === 'error';
|
|
366
|
+
},
|
|
367
|
+
get tabs() {
|
|
368
|
+
return model.state.tabs.length > 0;
|
|
369
|
+
},
|
|
370
|
+
get whitespace() {
|
|
371
|
+
return model.state.preferences.showWhitespace;
|
|
372
|
+
},
|
|
373
|
+
get wrap() {
|
|
374
|
+
return model.state.preferences.wrapText;
|
|
375
|
+
}
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
function ask(next: WorkspaceConfirmation) {
|
|
379
|
+
confirmation?.resolve('cancel');
|
|
380
|
+
returnFocus = (container?.ownerDocument.activeElement as HTMLElement | null) ?? undefined;
|
|
381
|
+
|
|
382
|
+
return new Promise<WorkspaceDecision>((resolve) => {
|
|
383
|
+
let current: Confirmation = {
|
|
384
|
+
request: next,
|
|
385
|
+
resolve: (decision) => {
|
|
386
|
+
if (confirmation !== current) {
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
confirmation = undefined;
|
|
391
|
+
dialog.active = false;
|
|
392
|
+
settle = () => {
|
|
393
|
+
if (returnFocus?.isConnected) {
|
|
394
|
+
returnFocus.focus({ preventScroll: true });
|
|
395
|
+
}
|
|
396
|
+
else {
|
|
397
|
+
focusEditor();
|
|
398
|
+
}
|
|
399
|
+
};
|
|
400
|
+
resolve(decision);
|
|
401
|
+
}
|
|
402
|
+
};
|
|
403
|
+
|
|
404
|
+
confirmation = current;
|
|
405
|
+
write(request, next);
|
|
406
|
+
dialog.active = true;
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
function attach(current: Mount) {
|
|
411
|
+
let controller = current.controller;
|
|
412
|
+
|
|
413
|
+
detach(current);
|
|
414
|
+
statusBar.attach(controller);
|
|
415
|
+
write(current.path, current.tab.path);
|
|
416
|
+
|
|
417
|
+
if (!addons || !controller) {
|
|
418
|
+
return;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
try {
|
|
422
|
+
current.addon = addons({
|
|
423
|
+
controller,
|
|
424
|
+
host: controller.host,
|
|
425
|
+
tab: current.tab,
|
|
426
|
+
workspace: model
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
catch (error) {
|
|
430
|
+
model.status(`Editor addon failed: ${String(error)}`, true);
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
function choose(entry: Command) {
|
|
435
|
+
if (entry.group === PALETTE.group && entry.id === PALETTE.id) {
|
|
436
|
+
settle = openKeybindings;
|
|
437
|
+
return;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
let opened = model.open(entry.id);
|
|
441
|
+
|
|
442
|
+
settle = () => {
|
|
443
|
+
void opened.then(focusEditor);
|
|
444
|
+
};
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
function connect(element: HTMLElement) {
|
|
448
|
+
release?.();
|
|
449
|
+
container = element;
|
|
450
|
+
release = root((dispose) => {
|
|
451
|
+
let listening = new AbortController(),
|
|
452
|
+
unobserve = observe(element, ([entry]) => {
|
|
453
|
+
ui.compact = entry.contentRect.width <= COMPACT_WIDTH;
|
|
454
|
+
});
|
|
455
|
+
|
|
456
|
+
// Capture, so the second chord reaches neither the editor nor the workspace's own Mod+S; template's
|
|
457
|
+
// document events bubble.
|
|
458
|
+
element.ownerDocument.addEventListener('keydown', chords.keydown, { capture: true, signal: listening.signal });
|
|
459
|
+
// A closing modal hands focus back to whatever had it before, so ours moves only once it has closed;
|
|
460
|
+
// 'close' doesn't bubble, but capture still passes through the workspace.
|
|
461
|
+
element.addEventListener('close', () => {
|
|
462
|
+
let next = settle;
|
|
463
|
+
|
|
464
|
+
settle = undefined;
|
|
465
|
+
next?.();
|
|
466
|
+
}, { capture: true, signal: listening.signal });
|
|
467
|
+
model.setConfirmation(ask);
|
|
468
|
+
|
|
469
|
+
onCleanup(hosting.connect(element));
|
|
470
|
+
onCleanup(navigation.connect(element));
|
|
471
|
+
onCleanup(statusBar.connect());
|
|
472
|
+
onCleanup(() => {
|
|
473
|
+
listening.abort();
|
|
474
|
+
chords.cancel();
|
|
475
|
+
unobserve();
|
|
476
|
+
confirmation?.resolve('cancel');
|
|
477
|
+
model.setConfirmation(undefined);
|
|
478
|
+
model.stop();
|
|
479
|
+
|
|
480
|
+
if (mount) {
|
|
481
|
+
unmount(mount);
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
container = undefined;
|
|
485
|
+
release = undefined;
|
|
486
|
+
});
|
|
487
|
+
|
|
488
|
+
// Each effect follows one part of the model, so a change reaches only what shows it.
|
|
489
|
+
effect(() => {
|
|
490
|
+
let entries = model.state.entries;
|
|
491
|
+
|
|
492
|
+
untrack(() => {
|
|
493
|
+
let paths: string[] = [];
|
|
494
|
+
|
|
495
|
+
reconcile(treeStore, entries);
|
|
496
|
+
|
|
497
|
+
for (let i = 0, n = entries.length; i < n; i++) {
|
|
498
|
+
if (entries[i].kind === 'file') {
|
|
499
|
+
paths.push(entries[i].path);
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
write(files, paths);
|
|
504
|
+
});
|
|
505
|
+
});
|
|
506
|
+
|
|
507
|
+
effect(() => {
|
|
508
|
+
let tab = model.state.active;
|
|
509
|
+
|
|
510
|
+
write(activeId, tab?.id ?? 0);
|
|
511
|
+
untrack(() => show(tab));
|
|
512
|
+
});
|
|
513
|
+
|
|
514
|
+
effect(() => {
|
|
515
|
+
let path = view.path;
|
|
516
|
+
|
|
517
|
+
untrack(() => {
|
|
518
|
+
treeState.selected = path;
|
|
519
|
+
|
|
520
|
+
// A rename keeps the tab and its editor; addons restart for the new path.
|
|
521
|
+
if (mount && mount.tab === model.state.active && read(mount.path) !== path) {
|
|
522
|
+
attach(mount);
|
|
523
|
+
}
|
|
524
|
+
});
|
|
525
|
+
});
|
|
526
|
+
|
|
527
|
+
effect(() => {
|
|
528
|
+
if (!view.collapsed) {
|
|
529
|
+
ui.peek = false;
|
|
530
|
+
ui.ready = false;
|
|
531
|
+
}
|
|
532
|
+
});
|
|
533
|
+
|
|
534
|
+
effect(() => {
|
|
535
|
+
let tabs = model.state.tabs.map((tab) => [tab.path, tab.dirty] as const);
|
|
536
|
+
|
|
537
|
+
untrack(() => decorate(tabs));
|
|
538
|
+
});
|
|
539
|
+
|
|
540
|
+
effect(() => {
|
|
541
|
+
model.state.active;
|
|
542
|
+
model.state.reveal;
|
|
543
|
+
untrack(reveal);
|
|
544
|
+
});
|
|
545
|
+
|
|
546
|
+
// Line and column follow the active document alone, so typing in one tab never touches the others.
|
|
547
|
+
effect(() => {
|
|
548
|
+
let tab = model.state.active;
|
|
549
|
+
|
|
550
|
+
if (!tab || tab.compare) {
|
|
551
|
+
ui.position = '';
|
|
552
|
+
return;
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
let document = tab.document,
|
|
556
|
+
update = () => {
|
|
557
|
+
let position = document.position();
|
|
558
|
+
|
|
559
|
+
ui.position = `Ln ${position.line}, Col ${position.column}`;
|
|
560
|
+
};
|
|
561
|
+
|
|
562
|
+
update();
|
|
563
|
+
onCleanup(document.subscribe((_, change) => {
|
|
564
|
+
if (change.selectionChanged || change.textChanged) {
|
|
565
|
+
update();
|
|
566
|
+
}
|
|
567
|
+
}));
|
|
568
|
+
});
|
|
569
|
+
|
|
570
|
+
effect(() => {
|
|
571
|
+
let path = treeState.selected;
|
|
572
|
+
|
|
573
|
+
if (path && treeStore.get(path)?.type === 'file') {
|
|
574
|
+
untrack(() => {
|
|
575
|
+
if (path !== model.state.active?.path) {
|
|
576
|
+
void model.open(path, undefined, undefined, true);
|
|
577
|
+
}
|
|
578
|
+
});
|
|
579
|
+
}
|
|
580
|
+
});
|
|
581
|
+
|
|
582
|
+
effect(() => {
|
|
583
|
+
let next = typeof openTarget === 'function' ? openTarget() : openTarget;
|
|
584
|
+
|
|
585
|
+
if (next) {
|
|
586
|
+
untrack(() => {
|
|
587
|
+
void model.start().then(() => model.openTarget(next));
|
|
588
|
+
});
|
|
589
|
+
}
|
|
590
|
+
});
|
|
591
|
+
|
|
592
|
+
// A dialog closed by Escape, its backdrop or a drag leaves the drafts open.
|
|
593
|
+
effect(() => {
|
|
594
|
+
if (!dialog.active) {
|
|
595
|
+
untrack(() => confirmation?.resolve('cancel'));
|
|
596
|
+
}
|
|
597
|
+
});
|
|
598
|
+
|
|
599
|
+
void hosting.restore();
|
|
600
|
+
|
|
601
|
+
return dispose;
|
|
602
|
+
});
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
function crumbs() {
|
|
606
|
+
let path = view.path;
|
|
607
|
+
|
|
608
|
+
if (!path) {
|
|
609
|
+
return '';
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
let parts = path.split('/'),
|
|
613
|
+
project = view.project,
|
|
614
|
+
items: Crumb[] = [];
|
|
615
|
+
|
|
616
|
+
if (project) {
|
|
617
|
+
items.push({ href: '#', label: project });
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
for (let i = 0, n = parts.length; i < n; i++) {
|
|
621
|
+
items.push({ href: `#${parts.slice(0, i + 1).join('/')}`, label: parts[i] });
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
return breadcrumb({
|
|
625
|
+
class: 'code-workspace-breadcrumb',
|
|
626
|
+
items,
|
|
627
|
+
label: 'File path',
|
|
628
|
+
onnavigate: (item) => locate(item.href.slice(1)),
|
|
629
|
+
separator: 'chevron'
|
|
630
|
+
});
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
// The explorer marks open files and drafts; only a path that changed either is written.
|
|
634
|
+
function decorate(tabs: readonly (readonly [string, boolean])[]) {
|
|
635
|
+
let open = new Set<string>();
|
|
636
|
+
|
|
637
|
+
for (let i = 0, n = tabs.length; i < n; i++) {
|
|
638
|
+
let [path, unsaved] = tabs[i];
|
|
639
|
+
|
|
640
|
+
open.add(path);
|
|
641
|
+
|
|
642
|
+
if (decorated.get(path) !== unsaved) {
|
|
643
|
+
decorated.set(path, unsaved);
|
|
644
|
+
decorations.update([[path, { editor: { open: true, unsaved } }]]);
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
for (let path of [...decorated.keys()]) {
|
|
649
|
+
if (!open.has(path)) {
|
|
650
|
+
decorated.delete(path);
|
|
651
|
+
decorations.update([[path, null]]);
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
function detach(current: Mount) {
|
|
657
|
+
let stop = current.addon;
|
|
658
|
+
|
|
659
|
+
current.addon = undefined;
|
|
660
|
+
|
|
661
|
+
try {
|
|
662
|
+
stop?.();
|
|
663
|
+
}
|
|
664
|
+
catch (error) {
|
|
665
|
+
model.status(`Editor addon failed: ${String(error)}`, true);
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
// The active tab's editor may still be mounting; it takes focus as soon as its controller arrives.
|
|
670
|
+
function focusEditor() {
|
|
671
|
+
let tab = model.state.active;
|
|
672
|
+
|
|
673
|
+
focusing = false;
|
|
674
|
+
|
|
675
|
+
if (!tab) {
|
|
676
|
+
searchField?.focus();
|
|
677
|
+
return;
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
if (mount?.controller && mount.tab === tab) {
|
|
681
|
+
mount.controller.focus();
|
|
682
|
+
return;
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
focusing = true;
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
function keydown(event: KeyboardEvent) {
|
|
689
|
+
if (event.defaultPrevented || event.isComposing || !container || confirmation) {
|
|
690
|
+
return;
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
let inside = container.contains(event.target as Node | null),
|
|
694
|
+
key = event.key.toLowerCase(),
|
|
695
|
+
mod = (event.ctrlKey || event.metaKey) && !event.altKey;
|
|
696
|
+
|
|
697
|
+
// Quick open also answers while the pointer rests on the workspace, as an editor pane under the cursor would.
|
|
698
|
+
if (mod && !event.shiftKey && key === 'p' && (inside || hovered)) {
|
|
699
|
+
event.preventDefault();
|
|
700
|
+
quickOpen();
|
|
701
|
+
return;
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
if (!inside) {
|
|
705
|
+
return;
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
if (mod && key === 's') {
|
|
709
|
+
event.preventDefault();
|
|
710
|
+
void model.save();
|
|
711
|
+
}
|
|
712
|
+
else if (mod && key === 'w') {
|
|
713
|
+
event.preventDefault();
|
|
714
|
+
void model.close();
|
|
715
|
+
}
|
|
716
|
+
else if (mod && key === 'z' && !event.shiftKey && (event.target as Element).closest('.file-tree') && !(event.target as Element).closest('input, textarea, [contenteditable=true]')) {
|
|
717
|
+
event.preventDefault();
|
|
718
|
+
void model.undoFiles();
|
|
719
|
+
}
|
|
720
|
+
else if (key === 'escape' && ui.peek) {
|
|
721
|
+
event.preventDefault();
|
|
722
|
+
peek(false);
|
|
723
|
+
focusEditor();
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
// A breadcrumb leads back into the explorer: the project collapses the tree, a folder is revealed in it.
|
|
728
|
+
function locate(path: string) {
|
|
729
|
+
peek(true, true);
|
|
730
|
+
|
|
731
|
+
if (!path) {
|
|
732
|
+
tree?.collapseAll();
|
|
733
|
+
return;
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
if (path !== view.path) {
|
|
737
|
+
treeState.selected = path;
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
function openKeybindings() {
|
|
742
|
+
palette.active = false;
|
|
743
|
+
keyboard.active = true;
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
function pane() {
|
|
747
|
+
let next = read(shown);
|
|
748
|
+
|
|
749
|
+
if (!next) {
|
|
750
|
+
return html`
|
|
751
|
+
<div class='code-workspace-empty'>
|
|
752
|
+
Open a file from the explorer or press
|
|
753
|
+
<span class='code-workspace-keys'>
|
|
754
|
+
${keys(['Mod', 'P']).map((key) => html`
|
|
755
|
+
<kbd class='button button--kbd'>
|
|
756
|
+
${key === '⌘' ? icon({ 'aria-hidden': 'true', class: 'button-kbd-icon' }, cmd) : key}
|
|
757
|
+
</kbd>
|
|
758
|
+
`)}
|
|
759
|
+
</span>
|
|
760
|
+
</div>
|
|
761
|
+
`;
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
// A render that runs again has released the mount it made; the tab gets a fresh one.
|
|
765
|
+
let current: Mount = next.released ? { editor: next.editor, path: signal(next.tab.path), released: false, tab: next.tab } : next,
|
|
766
|
+
bound: WorkspaceEditorAttributes = {
|
|
767
|
+
class: 'code-workspace-document',
|
|
768
|
+
controller: (controller) => {
|
|
769
|
+
if (current.released) {
|
|
770
|
+
return;
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
current.controller = controller;
|
|
774
|
+
restore(current);
|
|
775
|
+
attach(current);
|
|
776
|
+
reveal();
|
|
777
|
+
|
|
778
|
+
if (focusing) {
|
|
779
|
+
focusing = false;
|
|
780
|
+
// The controller can arrive mid-render; focusing may flush, which would render the pane again.
|
|
781
|
+
queueMicrotask(() => {
|
|
782
|
+
if (!current.released) {
|
|
783
|
+
controller.focus();
|
|
784
|
+
}
|
|
785
|
+
});
|
|
786
|
+
}
|
|
787
|
+
},
|
|
788
|
+
document: current.tab.document,
|
|
789
|
+
onSave: () => {
|
|
790
|
+
void model.save(current.tab);
|
|
791
|
+
},
|
|
792
|
+
options: () => settings(current.tab, read(current.path))
|
|
793
|
+
};
|
|
794
|
+
|
|
795
|
+
mount = current;
|
|
796
|
+
onCleanup(() => unmount(current));
|
|
797
|
+
|
|
798
|
+
return untrack(() => current.editor(bound));
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
function peek(open: boolean, keyboard = false) {
|
|
802
|
+
if (!view.collapsed) {
|
|
803
|
+
return;
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
if (!open) {
|
|
807
|
+
ui.peek = false;
|
|
808
|
+
ui.ready = false;
|
|
809
|
+
return;
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
ui.peek = true;
|
|
813
|
+
|
|
814
|
+
// No transition will report the drawer settled when motion is off.
|
|
815
|
+
if (keyboard || container?.ownerDocument.defaultView?.matchMedia('(prefers-reduced-motion: reduce)').matches) {
|
|
816
|
+
ui.ready = true;
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
function quickOpen(query = '') {
|
|
821
|
+
if (palette.active) {
|
|
822
|
+
palette.active = false;
|
|
823
|
+
return;
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
palette.active = true;
|
|
827
|
+
|
|
828
|
+
// Opening clears the query; the requested one goes in after.
|
|
829
|
+
flush();
|
|
830
|
+
palette.query = query;
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
// The edge leaves once the drawer is open, so keyboard focus moves on into the explorer instead of being dropped.
|
|
834
|
+
function reach() {
|
|
835
|
+
peek(true, true);
|
|
836
|
+
flush();
|
|
837
|
+
searchField?.focus();
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
function results(groups: ResultGroup[]) {
|
|
841
|
+
return nav.tree({
|
|
842
|
+
current: 'command',
|
|
843
|
+
sections: groups.map((group) => ({
|
|
844
|
+
groups: [{
|
|
845
|
+
links: group.items.map((item) => ({
|
|
846
|
+
attributes: item.attributes,
|
|
847
|
+
content: html`
|
|
848
|
+
${item.command?.icon
|
|
849
|
+
? icon({ 'aria-hidden': 'true', class: 'code-workspace-command-icon' }, item.command.icon)
|
|
850
|
+
: fileTreeIcon({ name: name(item.id), type: 'file' }, false)}
|
|
851
|
+
${item.content}
|
|
852
|
+
`,
|
|
853
|
+
label: item.label
|
|
854
|
+
}))
|
|
855
|
+
}],
|
|
856
|
+
label: group.label
|
|
857
|
+
})),
|
|
858
|
+
[nav.tree.highlight]: {}
|
|
859
|
+
});
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
// Where the shown tab was left, for when it's shown again.
|
|
863
|
+
function remember(current: Mount) {
|
|
864
|
+
let element = current.controller!.scroller;
|
|
865
|
+
|
|
866
|
+
current.tab.scroll = { left: element.scrollLeft, top: element.scrollTop };
|
|
867
|
+
hosting.remember(current.tab, current.controller!);
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
// A merge starting or ending on the shown tab swaps what the pane shows for it.
|
|
871
|
+
function remount() {
|
|
872
|
+
if (mount) {
|
|
873
|
+
unmount(mount);
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
show(model.state.active);
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
function restore(current: Mount) {
|
|
880
|
+
hosting.shown(current.tab, current.controller!);
|
|
881
|
+
|
|
882
|
+
let element = current.controller!.scroller,
|
|
883
|
+
{ left, top } = current.tab.scroll,
|
|
884
|
+
tab = current.tab;
|
|
885
|
+
|
|
886
|
+
element.scrollLeft = left;
|
|
887
|
+
element.scrollTop = top;
|
|
888
|
+
|
|
889
|
+
// An editor that draws lazily, like markdown's, isn't tall enough before its first frame; it is after.
|
|
890
|
+
if (Math.abs(element.scrollLeft - left) > 1 || Math.abs(element.scrollTop - top) > 1) {
|
|
891
|
+
requestAnimationFrame(() => {
|
|
892
|
+
if (!current.released && current.tab === tab) {
|
|
893
|
+
element.scrollLeft = left;
|
|
894
|
+
element.scrollTop = top;
|
|
895
|
+
}
|
|
896
|
+
});
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
// Moves the mounted editor on to another tab's document, which costs far less than mounting it again.
|
|
901
|
+
function retarget(current: Mount, tab: WorkspaceTab) {
|
|
902
|
+
remember(current);
|
|
903
|
+
detach(current);
|
|
904
|
+
current.tab = tab;
|
|
905
|
+
current.controller!.setDocument!(tab.document, settings(tab, tab.path));
|
|
906
|
+
restore(current);
|
|
907
|
+
attach(current);
|
|
908
|
+
reveal();
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
function reveal() {
|
|
912
|
+
let controller = mount?.controller,
|
|
913
|
+
state = model.state,
|
|
914
|
+
next = state.reveal;
|
|
915
|
+
|
|
916
|
+
if (!controller || !next || !state.active || next.request === revealed || controller.document !== state.active.document || state.active.id !== next.tabId) {
|
|
917
|
+
return;
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
revealed = next.request;
|
|
921
|
+
|
|
922
|
+
if (isWorkspaceCodeEditor(controller)) {
|
|
923
|
+
controller.goToLine(next.line, next.column);
|
|
924
|
+
return;
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
let offset = controller.document.offset(next.line, next.column);
|
|
928
|
+
|
|
929
|
+
controller.select({ end: offset, start: offset });
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
function search(query: string) {
|
|
933
|
+
ui.search = query;
|
|
934
|
+
tree?.search(query);
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
function selected() {
|
|
938
|
+
return [...treeState.selection].filter((path) => treeStore.get(path));
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
function settings(tab: WorkspaceTab, path: string): EditorOptions {
|
|
942
|
+
let options = typeof editorOptions === 'function' ? editorOptions(tab) : editorOptions;
|
|
943
|
+
|
|
944
|
+
return {
|
|
945
|
+
fold: true,
|
|
946
|
+
minimap: true,
|
|
947
|
+
onMerge: () => {
|
|
948
|
+
void strip.merge(tab);
|
|
949
|
+
},
|
|
950
|
+
...options,
|
|
951
|
+
...statusBar.options(tab),
|
|
952
|
+
...(model.host.baseline ? { baseline: hosting.baseline(path) } : {}),
|
|
953
|
+
fileName: path,
|
|
954
|
+
keybindings: merge(options?.keybindings, model.state.preferences.keybindings),
|
|
955
|
+
label: path,
|
|
956
|
+
whitespace: view.whitespace,
|
|
957
|
+
wrap: view.wrap
|
|
958
|
+
};
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
// Puts the tab in the editor pane: the mounted editor moves on to it when it can, or one is mounted for it.
|
|
962
|
+
function show(tab: WorkspaceTab | undefined) {
|
|
963
|
+
if (mount?.tab === tab) {
|
|
964
|
+
return;
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
let editor = tab && (strip.editor(tab) ?? editorFor?.(tab) ?? codeEditor);
|
|
968
|
+
|
|
969
|
+
if (tab && mount?.controller?.setDocument && mount.editor === editor) {
|
|
970
|
+
retarget(mount, tab);
|
|
971
|
+
return;
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
if (mount) {
|
|
975
|
+
unmount(mount);
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
mount = tab && editor && { editor, path: signal(tab.path), released: false, tab };
|
|
979
|
+
write(shown, mount);
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
// A rename, pin or draft updates its own tab in place; only opening, closing or reordering tabs renders the strip.
|
|
983
|
+
function tab(entry: WorkspaceTab) {
|
|
984
|
+
let chosen = () => signal.selector(activeId, entry.id),
|
|
985
|
+
file = () => strip.label(entry);
|
|
986
|
+
|
|
987
|
+
return html`
|
|
988
|
+
<div
|
|
989
|
+
aria-controls='${id}-panel'
|
|
990
|
+
class='button code-workspace-tab'
|
|
991
|
+
id='${id}-tab-${entry.id}'
|
|
992
|
+
role='tab'
|
|
993
|
+
${{
|
|
994
|
+
'aria-selected': () => (chosen() ? 'true' : 'false'),
|
|
995
|
+
class: () => chosen() && '--active',
|
|
996
|
+
onauxclick: (event: MouseEvent) => {
|
|
997
|
+
if (event.button === 1) {
|
|
998
|
+
event.preventDefault();
|
|
999
|
+
void model.close(entry.path);
|
|
1000
|
+
}
|
|
1001
|
+
},
|
|
1002
|
+
onclick: () => {
|
|
1003
|
+
model.activate(entry);
|
|
1004
|
+
focusEditor();
|
|
1005
|
+
},
|
|
1006
|
+
onconnect: (element: HTMLElement) => {
|
|
1007
|
+
elements.set(entry, element);
|
|
1008
|
+
},
|
|
1009
|
+
onkeydown: (event: KeyboardEvent) => {
|
|
1010
|
+
let list = untrack(() => model.state.tabs),
|
|
1011
|
+
at = list.indexOf(entry),
|
|
1012
|
+
next: WorkspaceTab | undefined;
|
|
1013
|
+
|
|
1014
|
+
if (event.key === 'ArrowRight') {
|
|
1015
|
+
next = list[(at + 1) % list.length];
|
|
1016
|
+
}
|
|
1017
|
+
else if (event.key === 'ArrowLeft') {
|
|
1018
|
+
next = list[(at - 1 + list.length) % list.length];
|
|
1019
|
+
}
|
|
1020
|
+
else if (event.key === 'Home') {
|
|
1021
|
+
next = list[0];
|
|
1022
|
+
}
|
|
1023
|
+
else if (event.key === 'End') {
|
|
1024
|
+
next = list.at(-1);
|
|
1025
|
+
}
|
|
1026
|
+
else if (event.key === 'Enter' || event.key === ' ') {
|
|
1027
|
+
event.preventDefault();
|
|
1028
|
+
model.activate(entry);
|
|
1029
|
+
focusEditor();
|
|
1030
|
+
return;
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1033
|
+
if (next) {
|
|
1034
|
+
event.preventDefault();
|
|
1035
|
+
model.activate(next);
|
|
1036
|
+
elements.get(next)?.focus();
|
|
1037
|
+
}
|
|
1038
|
+
},
|
|
1039
|
+
tabindex: () => (chosen() ? 0 : -1),
|
|
1040
|
+
title: () => strip.title(entry)
|
|
1041
|
+
}}
|
|
1042
|
+
${strip.attributes(entry)}
|
|
1043
|
+
>
|
|
1044
|
+
${() => fileTreeIcon({ name: file(), type: 'file' }, false)}
|
|
1045
|
+
<span class='code-workspace-tab-name'>${file}</span>
|
|
1046
|
+
${() => strip.pin(entry)}
|
|
1047
|
+
${() => entry.dirty && html`<span aria-label='Unsaved changes' class='code-workspace-tab-dirty' role='img'></span>`}
|
|
1048
|
+
<button
|
|
1049
|
+
class='button code-workspace-tab-close'
|
|
1050
|
+
tabindex='-1'
|
|
1051
|
+
title='${label('Close', ['Mod', 'W'])}'
|
|
1052
|
+
type='button'
|
|
1053
|
+
${{
|
|
1054
|
+
'aria-label': () => `Close ${file()}`,
|
|
1055
|
+
onclick: (event: Event) => {
|
|
1056
|
+
event.stopPropagation();
|
|
1057
|
+
void model.close(entry.path);
|
|
1058
|
+
}
|
|
1059
|
+
}}
|
|
1060
|
+
>
|
|
1061
|
+
${icon({ 'aria-hidden': 'true', class: 'code-workspace-tab-close-icon' }, close)}
|
|
1062
|
+
</button>
|
|
1063
|
+
</div>
|
|
1064
|
+
`;
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
function toggle(key: 'explorerOpen' | 'showWhitespace' | 'wrapText') {
|
|
1068
|
+
model.setPreferences({ [key]: !model.state.preferences[key] });
|
|
1069
|
+
ui.peek = false;
|
|
1070
|
+
ui.ready = false;
|
|
1071
|
+
}
|
|
1072
|
+
|
|
1073
|
+
function unmount(current: Mount) {
|
|
1074
|
+
if (current.released) {
|
|
1075
|
+
return;
|
|
1076
|
+
}
|
|
1077
|
+
|
|
1078
|
+
let controller = current.controller;
|
|
1079
|
+
|
|
1080
|
+
current.released = true;
|
|
1081
|
+
|
|
1082
|
+
if (mount === current) {
|
|
1083
|
+
mount = undefined;
|
|
1084
|
+
statusBar.attach(undefined);
|
|
1085
|
+
}
|
|
1086
|
+
|
|
1087
|
+
if (controller?.host.isConnected) {
|
|
1088
|
+
remember(current);
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1091
|
+
detach(current);
|
|
1092
|
+
}
|
|
1093
|
+
|
|
1094
|
+
let api: CodeEditorWorkspaceController = {
|
|
1095
|
+
close: (path) => model.close(path),
|
|
1096
|
+
collapseAll: () => tree?.collapseAll(),
|
|
1097
|
+
delete: (paths = selected()) => model.delete(paths),
|
|
1098
|
+
dispose: () => {
|
|
1099
|
+
release?.();
|
|
1100
|
+
hosting.dispose();
|
|
1101
|
+
model.dispose();
|
|
1102
|
+
},
|
|
1103
|
+
get editor() {
|
|
1104
|
+
return mount?.controller;
|
|
1105
|
+
},
|
|
1106
|
+
focus: focusEditor,
|
|
1107
|
+
keybindings: openKeybindings,
|
|
1108
|
+
model,
|
|
1109
|
+
navigate: (kind, backward) => navigation.go(kind, backward),
|
|
1110
|
+
open: (path, line, column) => model.open(path, line, column),
|
|
1111
|
+
quickOpen,
|
|
1112
|
+
refresh: () => model.refresh(),
|
|
1113
|
+
rename: (source, destination) => model.rename(source, destination),
|
|
1114
|
+
save: () => model.save(),
|
|
1115
|
+
search,
|
|
1116
|
+
toggleExplorer: () => toggle('explorerOpen'),
|
|
1117
|
+
toggleExplorerSide: () => {
|
|
1118
|
+
model.setPreferences({ explorerSide: view.left ? 'right' : 'left' });
|
|
1119
|
+
ui.peek = false;
|
|
1120
|
+
ui.ready = false;
|
|
1121
|
+
},
|
|
1122
|
+
toggleWhitespace: () => toggle('showWhitespace'),
|
|
1123
|
+
toggleWrap: () => toggle('wrapText'),
|
|
1124
|
+
undoFiles: () => model.undoFiles()
|
|
1125
|
+
},
|
|
1126
|
+
items: Item[] = [
|
|
1127
|
+
{
|
|
1128
|
+
hidden: () => !single() || read(target)?.element.type !== 'file',
|
|
1129
|
+
label: 'Open',
|
|
1130
|
+
onselect: () => {
|
|
1131
|
+
void model.open(paths()[0]).then(focusEditor);
|
|
1132
|
+
}
|
|
1133
|
+
},
|
|
1134
|
+
{
|
|
1135
|
+
hidden: () => !single(),
|
|
1136
|
+
hint: 'F2',
|
|
1137
|
+
label: 'Rename',
|
|
1138
|
+
onselect: () => treeEditor.rename(paths()[0])
|
|
1139
|
+
},
|
|
1140
|
+
{
|
|
1141
|
+
hidden: () => !single(),
|
|
1142
|
+
label: 'Copy Path',
|
|
1143
|
+
onselect: () => {
|
|
1144
|
+
void model.copyPath(paths()[0]);
|
|
1145
|
+
}
|
|
1146
|
+
},
|
|
1147
|
+
...strip.items(() => paths()),
|
|
1148
|
+
...(model.host.actions ?? []).map((action): Item => ({
|
|
1149
|
+
danger: action.danger,
|
|
1150
|
+
hidden: () => !paths().length || (!!action.visible && !action.visible(paths())),
|
|
1151
|
+
icon: action.icon ? () => icon({ 'aria-hidden': 'true' }, action.icon!) : undefined,
|
|
1152
|
+
label: action.label,
|
|
1153
|
+
onselect: () => {
|
|
1154
|
+
void model.run(action, paths());
|
|
1155
|
+
}
|
|
1156
|
+
})),
|
|
1157
|
+
{
|
|
1158
|
+
danger: true,
|
|
1159
|
+
hint: mac() ? '⌘⌫' : 'Del',
|
|
1160
|
+
label: 'Delete',
|
|
1161
|
+
onselect: () => {
|
|
1162
|
+
void model.delete(paths());
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1165
|
+
],
|
|
1166
|
+
paths = () => read(target)?.paths ?? [],
|
|
1167
|
+
single = () => paths().length === 1;
|
|
1168
|
+
|
|
1169
|
+
receive?.(api);
|
|
1170
|
+
|
|
1171
|
+
return html`
|
|
1172
|
+
<section
|
|
1173
|
+
aria-label='Editor workspace'
|
|
1174
|
+
class='code-workspace'
|
|
1175
|
+
${attributes}
|
|
1176
|
+
${hosting.attributes}
|
|
1177
|
+
${statusBar.attributes}
|
|
1178
|
+
${{
|
|
1179
|
+
// A page-wide palette on Mod+K, like the site search, leaves the chord to a focused element that
|
|
1180
|
+
// declares it.
|
|
1181
|
+
'aria-keyshortcuts': declare(attributes['aria-keyshortcuts'] as string | undefined, OPEN[0]),
|
|
1182
|
+
class: [
|
|
1183
|
+
() => view.collapsed && 'code-workspace--collapsed',
|
|
1184
|
+
() => view.left && 'code-workspace--left',
|
|
1185
|
+
() => ui.peek && 'code-workspace--peek',
|
|
1186
|
+
// A narrow workspace stacks an open explorer under the editor; a hidden one still peeks from the edge.
|
|
1187
|
+
() => ui.compact && view.tabs && view.explorerOpen && 'code-workspace--stacked',
|
|
1188
|
+
() => view.tabs && 'code-workspace--tabs'
|
|
1189
|
+
],
|
|
1190
|
+
onconnect: connect,
|
|
1191
|
+
ondocumentkeydown: keydown,
|
|
1192
|
+
onpointerenter: () => {
|
|
1193
|
+
hovered = true;
|
|
1194
|
+
},
|
|
1195
|
+
onpointerleave: () => {
|
|
1196
|
+
hovered = false;
|
|
1197
|
+
}
|
|
1198
|
+
}}
|
|
1199
|
+
>
|
|
1200
|
+
<aside
|
|
1201
|
+
aria-label='File explorer'
|
|
1202
|
+
class='code-workspace-explorer'
|
|
1203
|
+
${{
|
|
1204
|
+
onfocusin: () => peek(true, true),
|
|
1205
|
+
// A drawer still sliding away can pass under a resting pointer; only a settled one peeks.
|
|
1206
|
+
onpointerenter: (event: PointerEvent) => {
|
|
1207
|
+
if (!(event.currentTarget as HTMLElement).getAnimations().length) {
|
|
1208
|
+
peek(true);
|
|
1209
|
+
}
|
|
1210
|
+
},
|
|
1211
|
+
ontransitionend: (event: TransitionEvent) => {
|
|
1212
|
+
if (event.target === event.currentTarget && event.propertyName === 'translate') {
|
|
1213
|
+
ui.ready = ui.peek;
|
|
1214
|
+
}
|
|
1215
|
+
}
|
|
1216
|
+
}}
|
|
1217
|
+
>
|
|
1218
|
+
<div class='code-workspace-explorer-content' ${{ inert: () => view.collapsed && !ui.ready }}>
|
|
1219
|
+
<div class='code-workspace-explorer-header'>
|
|
1220
|
+
${control({
|
|
1221
|
+
label: () => (view.left ? 'Move file explorer to right' : 'Move file explorer to left'),
|
|
1222
|
+
onclick: api.toggleExplorerSide,
|
|
1223
|
+
sprite: () => (view.left ? right : left)
|
|
1224
|
+
})}
|
|
1225
|
+
${control({ label: 'Collapse all folders', onclick: api.collapseAll, sprite: collapse })}
|
|
1226
|
+
${control({
|
|
1227
|
+
disabled: () => !view.canUndo || view.busy,
|
|
1228
|
+
label: 'Undo file operation',
|
|
1229
|
+
onclick: () => {
|
|
1230
|
+
void model.undoFiles();
|
|
1231
|
+
},
|
|
1232
|
+
sprite: undo
|
|
1233
|
+
})}
|
|
1234
|
+
${control({ label: label('Go to file', ['Mod', 'P']), onclick: () => quickOpen(), sprite: magnifier })}
|
|
1235
|
+
${input({
|
|
1236
|
+
'aria-label': 'Search files',
|
|
1237
|
+
autocomplete: 'off',
|
|
1238
|
+
class: 'code-workspace-search',
|
|
1239
|
+
onconnect: (element: HTMLInputElement) => {
|
|
1240
|
+
searchField = element;
|
|
1241
|
+
},
|
|
1242
|
+
oninput: (event: Event) => search((event.target as HTMLInputElement).value),
|
|
1243
|
+
placeholder: 'Search files',
|
|
1244
|
+
spellcheck: false,
|
|
1245
|
+
type: 'search',
|
|
1246
|
+
value: () => ui.search
|
|
1247
|
+
})}
|
|
1248
|
+
</div>
|
|
1249
|
+
<div class='code-workspace-tree'>
|
|
1250
|
+
${() => hosting.ready() && untrack(() => fileTree({
|
|
1251
|
+
class: 'code-workspace-files',
|
|
1252
|
+
compact: true,
|
|
1253
|
+
controller: (value) => {
|
|
1254
|
+
tree = value;
|
|
1255
|
+
value.search(ui.search);
|
|
1256
|
+
},
|
|
1257
|
+
decorations: [hosting.marks, ...[provided ?? []].flat(), decorations],
|
|
1258
|
+
editor: treeEditor,
|
|
1259
|
+
elements: treeStore,
|
|
1260
|
+
empty: () => html`<div class='code-workspace-notice'>No files in this workspace</div>`,
|
|
1261
|
+
export: hosting.export,
|
|
1262
|
+
find: 'filter',
|
|
1263
|
+
menu: (elements, position) => {
|
|
1264
|
+
if (!elements.length || !actions) {
|
|
1265
|
+
return;
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1268
|
+
write(target, { element: elements[0], paths: elements.map((element) => element.id) });
|
|
1269
|
+
// Items hide by the target; the menu focuses its first visible one as it opens.
|
|
1270
|
+
flush();
|
|
1271
|
+
// The tree claims the right click; the context menu opens at the point it reports.
|
|
1272
|
+
actions.open(position);
|
|
1273
|
+
},
|
|
1274
|
+
open: (element, open) => {
|
|
1275
|
+
void model.open(element.id, undefined, undefined, open.mode === 'preview');
|
|
1276
|
+
},
|
|
1277
|
+
operations: {
|
|
1278
|
+
delete: (elements) => {
|
|
1279
|
+
void model.delete(elements.map((element) => element.id));
|
|
1280
|
+
},
|
|
1281
|
+
import: hosting.import
|
|
1282
|
+
},
|
|
1283
|
+
preview: 'immediate',
|
|
1284
|
+
rename: async (element, value) => {
|
|
1285
|
+
let parent = element.id.includes('/') ? element.id.slice(0, element.id.lastIndexOf('/') + 1) : '';
|
|
1286
|
+
|
|
1287
|
+
if (!(await model.rename(element.id, parent + value))) {
|
|
1288
|
+
throw new Error(`Workspace: ${model.state.status}`);
|
|
1289
|
+
}
|
|
1290
|
+
},
|
|
1291
|
+
searched: (query) => {
|
|
1292
|
+
ui.search = query;
|
|
1293
|
+
},
|
|
1294
|
+
snapshot: hosting.explorer,
|
|
1295
|
+
state: treeState,
|
|
1296
|
+
typing: 'typeahead'
|
|
1297
|
+
}))}
|
|
1298
|
+
${() => {
|
|
1299
|
+
if (view.error) {
|
|
1300
|
+
return html`
|
|
1301
|
+
<div class='code-workspace-notice code-workspace-notice--cover' role='alert'>
|
|
1302
|
+
${view.error}
|
|
1303
|
+
<button
|
|
1304
|
+
class='button code-workspace-retry'
|
|
1305
|
+
type='button'
|
|
1306
|
+
onclick='${() => {
|
|
1307
|
+
void model.refresh();
|
|
1308
|
+
}}'
|
|
1309
|
+
>
|
|
1310
|
+
Retry
|
|
1311
|
+
</button>
|
|
1312
|
+
</div>
|
|
1313
|
+
`;
|
|
1314
|
+
}
|
|
1315
|
+
|
|
1316
|
+
return !view.loaded && html`<div class='code-workspace-notice code-workspace-notice--cover' role='status'>Loading…</div>`;
|
|
1317
|
+
}}
|
|
1318
|
+
</div>
|
|
1319
|
+
</div>
|
|
1320
|
+
${() => view.collapsed && !ui.ready && html`
|
|
1321
|
+
<button
|
|
1322
|
+
aria-label='Peek file explorer'
|
|
1323
|
+
class='code-workspace-edge'
|
|
1324
|
+
type='button'
|
|
1325
|
+
${{ onclick: reach, onfocus: reach }}
|
|
1326
|
+
></button>
|
|
1327
|
+
`}
|
|
1328
|
+
</aside>
|
|
1329
|
+
<main class='code-workspace-main' ${{ onpointerenter: () => peek(false) }}>
|
|
1330
|
+
<div aria-label='Open files' class='code-workspace-tabs' role='tablist' ${scrollbar()}>
|
|
1331
|
+
${highlight({ border: 'bottom', class: 'code-workspace-tabs-highlight' })}
|
|
1332
|
+
${() => model.state.tabs.map(tab)}
|
|
1333
|
+
</div>
|
|
1334
|
+
<div class='code-workspace-bar'>
|
|
1335
|
+
${crumbs}
|
|
1336
|
+
<div class='code-workspace-actions'>
|
|
1337
|
+
${statusBar.save(() => control({
|
|
1338
|
+
disabled: () => !view.tabs || view.busy,
|
|
1339
|
+
label: label('Save file', ['Mod', 'S']),
|
|
1340
|
+
onclick: () => {
|
|
1341
|
+
void model.save();
|
|
1342
|
+
},
|
|
1343
|
+
sprite: save
|
|
1344
|
+
}))}
|
|
1345
|
+
${control({
|
|
1346
|
+
active: () => view.wrap,
|
|
1347
|
+
label: () => (view.wrap ? 'Disable wrap' : 'Wrap long lines'),
|
|
1348
|
+
onclick: api.toggleWrap,
|
|
1349
|
+
sprite: wrap
|
|
1350
|
+
})}
|
|
1351
|
+
${control({
|
|
1352
|
+
active: () => view.whitespace,
|
|
1353
|
+
label: () => (view.whitespace ? 'Hide whitespace' : 'Show whitespace'),
|
|
1354
|
+
onclick: api.toggleWhitespace,
|
|
1355
|
+
sprite: whitespace
|
|
1356
|
+
})}
|
|
1357
|
+
${sidebar({
|
|
1358
|
+
'aria-label': () => (view.explorerOpen ? 'Hide file explorer' : 'Show file explorer'),
|
|
1359
|
+
class: 'code-workspace-control',
|
|
1360
|
+
onclick: api.toggleExplorer,
|
|
1361
|
+
open: () => view.explorerOpen,
|
|
1362
|
+
side: () => (view.left ? 'left' : 'right'),
|
|
1363
|
+
title: () => (view.explorerOpen ? 'Hide file explorer' : 'Show file explorer')
|
|
1364
|
+
})}
|
|
1365
|
+
</div>
|
|
1366
|
+
</div>
|
|
1367
|
+
<div
|
|
1368
|
+
class='code-workspace-editor'
|
|
1369
|
+
id='${id}-panel'
|
|
1370
|
+
role='tabpanel'
|
|
1371
|
+
${{ 'aria-labelledby': () => (read(activeId) ? `${id}-tab-${read(activeId)}` : undefined) }}
|
|
1372
|
+
>
|
|
1373
|
+
${pane}
|
|
1374
|
+
</div>
|
|
1375
|
+
</main>
|
|
1376
|
+
<footer class='code-workspace-status'>
|
|
1377
|
+
<span class='code-workspace-status-path'>${() => view.cwd}</span>
|
|
1378
|
+
<span class='code-workspace-status-position'>${() => ui.position}</span>
|
|
1379
|
+
${statusBar.items}
|
|
1380
|
+
<span
|
|
1381
|
+
aria-live='polite'
|
|
1382
|
+
class='code-workspace-status-message'
|
|
1383
|
+
role='status'
|
|
1384
|
+
${{ class: () => view.statusError && 'code-workspace-status-message--error' }}
|
|
1385
|
+
>
|
|
1386
|
+
${() => view.status}
|
|
1387
|
+
</span>
|
|
1388
|
+
</footer>
|
|
1389
|
+
<div
|
|
1390
|
+
class='code-workspace-layer'
|
|
1391
|
+
popover='manual'
|
|
1392
|
+
${{
|
|
1393
|
+
onconnect: (element: HTMLElement) => {
|
|
1394
|
+
element.showPopover();
|
|
1395
|
+
}
|
|
1396
|
+
}}
|
|
1397
|
+
>
|
|
1398
|
+
${tooltip.context(
|
|
1399
|
+
{
|
|
1400
|
+
class: 'code-workspace-menu',
|
|
1401
|
+
controller: (value: MenuController) => {
|
|
1402
|
+
actions = value;
|
|
1403
|
+
},
|
|
1404
|
+
items,
|
|
1405
|
+
[tooltip.context.panel]: { 'aria-label': 'File actions', class: 'code-workspace-menu-panel' }
|
|
1406
|
+
},
|
|
1407
|
+
''
|
|
1408
|
+
)}
|
|
1409
|
+
${statusBar.menu}
|
|
1410
|
+
${strip.menu()}
|
|
1411
|
+
</div>
|
|
1412
|
+
${command({
|
|
1413
|
+
commands: () => [PALETTE, ...read(files).map((path): Command => ({ group: 'Files', id: path, label: path }))],
|
|
1414
|
+
hotkey: [],
|
|
1415
|
+
label: 'Go to file',
|
|
1416
|
+
limit: 50,
|
|
1417
|
+
match: fuzzy,
|
|
1418
|
+
onrun: choose,
|
|
1419
|
+
placeholder: 'Go to file',
|
|
1420
|
+
render: results,
|
|
1421
|
+
state: palette,
|
|
1422
|
+
trigger: false,
|
|
1423
|
+
[command.dialog]: { 'aria-label': 'Go to file' }
|
|
1424
|
+
})}
|
|
1425
|
+
${shortcuts({
|
|
1426
|
+
apple: mac(),
|
|
1427
|
+
id,
|
|
1428
|
+
keybindings: () => model.state.preferences.keybindings,
|
|
1429
|
+
onchange: (next) => model.setPreferences({ keybindings: next }),
|
|
1430
|
+
state: keyboard
|
|
1431
|
+
})}
|
|
1432
|
+
${overlay(
|
|
1433
|
+
{
|
|
1434
|
+
'aria-labelledby': `${id}-confirm`,
|
|
1435
|
+
class: 'card overlay--alert code-workspace-confirm',
|
|
1436
|
+
state: dialog
|
|
1437
|
+
},
|
|
1438
|
+
html`
|
|
1439
|
+
<h2 class='code-workspace-confirm-title' id='${id}-confirm'>Save unsaved changes?</h2>
|
|
1440
|
+
<p class='code-workspace-confirm-files'>${() => read(request)?.dirty.join(', ')}</p>
|
|
1441
|
+
<p class='code-workspace-confirm-text'>
|
|
1442
|
+
${() => (read(request)?.kind === 'delete'
|
|
1443
|
+
? 'Save before deleting, discard the drafts, or cancel deletion.'
|
|
1444
|
+
: 'Save the drafts, discard them, or keep them open.')}
|
|
1445
|
+
</p>
|
|
1446
|
+
<div class='code-workspace-confirm-actions'>
|
|
1447
|
+
<button autofocus class='button code-workspace-confirm-button' type='button' onclick='${() => confirmation?.resolve('cancel')}'>
|
|
1448
|
+
Cancel
|
|
1449
|
+
</button>
|
|
1450
|
+
<button class='button code-workspace-confirm-button' type='button' onclick='${() => confirmation?.resolve('discard')}'>
|
|
1451
|
+
Discard
|
|
1452
|
+
</button>
|
|
1453
|
+
<button class='button code-workspace-confirm-button code-workspace-confirm-button--primary' type='button' onclick='${() => confirmation?.resolve('save')}'>
|
|
1454
|
+
Save
|
|
1455
|
+
</button>
|
|
1456
|
+
</div>
|
|
1457
|
+
`
|
|
1458
|
+
)}
|
|
1459
|
+
</section>
|
|
1460
|
+
`;
|
|
1461
|
+
};
|
|
1462
|
+
|
|
1463
|
+
|
|
1464
|
+
export default component(workspace);
|
|
1465
|
+
export { EditorWorkspaceModel, isWorkspaceCodeEditor };
|
|
1466
|
+
export type {
|
|
1467
|
+
CodeEditorWorkspaceAttributes,
|
|
1468
|
+
CodeEditorWorkspaceController,
|
|
1469
|
+
WorkspaceEditor,
|
|
1470
|
+
WorkspaceEditorAttributes,
|
|
1471
|
+
WorkspaceEditorContext,
|
|
1472
|
+
WorkspaceEditorController
|
|
1473
|
+
};
|
|
1474
|
+
export type {
|
|
1475
|
+
WorkspaceAction,
|
|
1476
|
+
WorkspaceCompare,
|
|
1477
|
+
WorkspaceConfirmation,
|
|
1478
|
+
WorkspaceDecision,
|
|
1479
|
+
WorkspaceEntry,
|
|
1480
|
+
WorkspaceHost,
|
|
1481
|
+
WorkspacePreferences,
|
|
1482
|
+
WorkspaceSession,
|
|
1483
|
+
WorkspaceSessionTab,
|
|
1484
|
+
WorkspaceTab,
|
|
1485
|
+
WorkspaceTarget
|
|
1486
|
+
} from './model';
|