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