@netless/fastboard-ui 0.3.2-canary.4 → 0.3.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netless/fastboard-ui",
3
- "version": "0.3.2-canary.4",
3
+ "version": "0.3.2",
4
4
  "description": "The front-end of @netless/fastboard-core.",
5
5
  "main": "dist/index.js",
6
6
  "svelte": "dist/index.svelte.mjs",
@@ -10,14 +10,14 @@
10
10
  ],
11
11
  "repository": "netless-io/fastboard",
12
12
  "peerDependencies": {
13
- "@netless/fastboard-core": "0.3.2-canary.4"
13
+ "@netless/fastboard-core": "0.3.2"
14
14
  },
15
15
  "dependencies": {
16
16
  "tippy.js": "^6.3.7"
17
17
  },
18
18
  "devDependencies": {
19
19
  "@netless/esbuild-plugin-inline-sass": "0.1.0",
20
- "@netless/fastboard-core": "0.3.2-canary.4"
20
+ "@netless/fastboard-core": "0.3.2"
21
21
  },
22
22
  "scripts": {
23
23
  "cleanup": "rimraf dist",
@@ -38,6 +38,10 @@ class AppsInToolbar {
38
38
  this._data = this._data.filter(item => !filter(item));
39
39
  this._listeners.forEach(fn => fn(this._data));
40
40
  }
41
+ clear() {
42
+ this._data.length = 0;
43
+ this._listeners.forEach(fn => fn(this._data));
44
+ }
41
45
  }
42
46
 
43
47
  export type { AppsInToolbar };
@@ -61,7 +61,7 @@
61
61
  <div class="{name}-view" bind:this={container} on:touchstart|capture={tippy_hide_all} />
62
62
  <div class="{name}-left" class:hidden={!(layout === "visible" || layout === "toolbar-only")}>
63
63
  {#if config.toolbar?.enable !== false}
64
- <Toolbar {app} {theme} {language} />
64
+ <Toolbar {app} {theme} {language} config={config.toolbar} />
65
65
  {/if}
66
66
  </div>
67
67
  <div class="{name}-bottom-left" class:hidden={layout !== "visible"}>
@@ -1,6 +1,6 @@
1
1
  <script lang="ts">
2
2
  import type { FastboardApp } from "@netless/fastboard-core";
3
- import type { Language, Theme } from "../../typings";
3
+ import type { Language, Theme, ToolbarConfig } from "../../typings";
4
4
  import { writable as svelte_writable } from "svelte/store";
5
5
  import { height } from "../../actions/height";
6
6
  import { clamp } from "../helpers";
@@ -9,6 +9,7 @@
9
9
  export let app: FastboardApp | null | undefined = null;
10
10
  export let theme: Theme = "light";
11
11
  export let language: Language = "en";
12
+ export let config: ToolbarConfig = {};
12
13
 
13
14
  const name = "fastboard-toolbar";
14
15
  const extra_height = (32 + 4 + 4) * 2;
@@ -22,11 +23,22 @@
22
23
 
23
24
  $: computed_height = clamp($container_height, extra_height, $scroll_height + extra_height);
24
25
  $: scrollable = $scroll_height + extra_height > $container_height;
26
+
27
+ $: hide_apps = config.apps?.enable === false;
25
28
  </script>
26
29
 
27
30
  <div class="{name} {theme}" class:collapsed use:height={container_height}>
28
31
  <div class="{name}-contents {theme}" style:height={scrollable ? computed_height + "px" : "auto"}>
29
- <Contents {app} {theme} {language} {disabled} {scroll_height} {computed_height} {scrollable} />
32
+ <Contents
33
+ {app}
34
+ {theme}
35
+ {language}
36
+ {disabled}
37
+ {scroll_height}
38
+ {computed_height}
39
+ {scrollable}
40
+ {hide_apps}
41
+ />
30
42
  </div>
31
43
  <label class="{name}-handler {theme}">
32
44
  <input type="checkbox" bind:checked={collapsed} />
@@ -1,11 +1,12 @@
1
1
  import type { FastboardApp } from "@netless/fastboard-core";
2
- import type { Theme, Language } from "../../typings";
2
+ import type { Theme, Language, ToolbarConfig } from "../../typings";
3
3
  import { SvelteComponentTyped } from "svelte";
4
4
 
5
5
  export declare interface ToolbarProps {
6
6
  app?: FastboardApp | null;
7
7
  theme?: Theme;
8
8
  language?: Language;
9
+ config?: ToolbarConfig;
9
10
  }
10
11
 
11
12
  declare class Toolbar extends SvelteComponentTyped<ToolbarProps> {}
@@ -26,6 +26,7 @@
26
26
  export let scroll_height: Writable<number>;
27
27
  export let computed_height = 0;
28
28
  export let scrollable = false;
29
+ export let hide_apps = false;
29
30
 
30
31
  const name = "fastboard-toolbar";
31
32
 
@@ -147,9 +148,11 @@
147
148
  <Button class="clear" {...btn_props} on:click={clear} content={t.clear}>
148
149
  <Icons.Clear {theme} />
149
150
  </Button>
150
- <Button class="apps" {...btn_props} content={t.apps} menu={apps_panel} menu_placement="right-end">
151
- <Icons.Apps {theme} />
152
- </Button>
151
+ {#if !hide_apps}
152
+ <Button class="apps" {...btn_props} content={t.apps} menu={apps_panel} menu_placement="right-end">
153
+ <Icons.Apps {theme} />
154
+ </Button>
155
+ {/if}
153
156
  </div>
154
157
  {#if scrollable}
155
158
  <Button class="scroll-down" {name} {theme} {disabled} on:click={scroll_down}>
package/src/typings.ts CHANGED
@@ -16,10 +16,16 @@ export type GenericIcon<K extends string, E extends string = IconType> = {
16
16
 
17
17
  export type I18nData<T extends string> = Record<Language, Record<T, string>>;
18
18
 
19
+ export interface ToolbarConfig {
20
+ apps?: {
21
+ enable?: boolean;
22
+ };
23
+ }
24
+
19
25
  export interface FastboardUIConfig {
20
26
  toolbar?: {
21
27
  enable?: boolean;
22
- };
28
+ } & ToolbarConfig;
23
29
  redo_undo?: {
24
30
  enable?: boolean;
25
31
  };