@netless/fastboard-react 0.1.0 → 0.2.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.
Files changed (85) hide show
  1. package/dist/index.js +426 -487
  2. package/dist/index.js.map +1 -1
  3. package/dist/index.mjs +368 -425
  4. package/dist/index.mjs.map +1 -1
  5. package/package.json +18 -13
  6. package/src/components/Fastboard.tsx +27 -17
  7. package/src/components/PageControl/PageControl.tsx +2 -4
  8. package/src/components/PageControl/hooks.ts +18 -61
  9. package/src/components/Toolbar/Content.tsx +19 -4
  10. package/src/components/Toolbar/Toolbar.scss +13 -3
  11. package/src/components/Toolbar/Toolbar.tsx +15 -47
  12. package/src/components/hooks.ts +1 -1
  13. package/src/index.ts +1 -0
  14. package/src/vanilla/index.tsx +18 -0
  15. package/dist/behaviors/style.d.ts +0 -1
  16. package/dist/components/Fastboard.d.ts +0 -15
  17. package/dist/components/PageControl/PageControl.d.ts +0 -5
  18. package/dist/components/PageControl/hooks.d.ts +0 -9
  19. package/dist/components/PageControl/index.d.ts +0 -2
  20. package/dist/components/PlayerControl/PlayerControl.d.ts +0 -9
  21. package/dist/components/PlayerControl/hooks.d.ts +0 -11
  22. package/dist/components/PlayerControl/icons/Loading.d.ts +0 -3
  23. package/dist/components/PlayerControl/icons/Pause.d.ts +0 -3
  24. package/dist/components/PlayerControl/icons/Play.d.ts +0 -3
  25. package/dist/components/PlayerControl/icons/index.d.ts +0 -6
  26. package/dist/components/PlayerControl/index.d.ts +0 -2
  27. package/dist/components/RedoUndo/RedoUndo.d.ts +0 -5
  28. package/dist/components/RedoUndo/hooks.d.ts +0 -6
  29. package/dist/components/RedoUndo/index.d.ts +0 -2
  30. package/dist/components/Toolbar/Content.d.ts +0 -2
  31. package/dist/components/Toolbar/Toolbar.d.ts +0 -14
  32. package/dist/components/Toolbar/components/ApplianceButtons.d.ts +0 -7
  33. package/dist/components/Toolbar/components/AppsButton.d.ts +0 -6
  34. package/dist/components/Toolbar/components/ColorBox.d.ts +0 -2
  35. package/dist/components/Toolbar/components/CutLine.d.ts +0 -2
  36. package/dist/components/Toolbar/components/Mask.d.ts +0 -7
  37. package/dist/components/Toolbar/components/PencilButton.d.ts +0 -2
  38. package/dist/components/Toolbar/components/ShapesButton.d.ts +0 -3
  39. package/dist/components/Toolbar/components/Slider.d.ts +0 -2
  40. package/dist/components/Toolbar/components/TextButton.d.ts +0 -2
  41. package/dist/components/Toolbar/components/UpDownButtons.d.ts +0 -7
  42. package/dist/components/Toolbar/const.d.ts +0 -18
  43. package/dist/components/Toolbar/hooks.d.ts +0 -12
  44. package/dist/components/Toolbar/icons/Apps.d.ts +0 -3
  45. package/dist/components/Toolbar/icons/Arrow.d.ts +0 -3
  46. package/dist/components/Toolbar/icons/Circle.d.ts +0 -3
  47. package/dist/components/Toolbar/icons/Clean.d.ts +0 -3
  48. package/dist/components/Toolbar/icons/Clicker.d.ts +0 -3
  49. package/dist/components/Toolbar/icons/Collapse.d.ts +0 -3
  50. package/dist/components/Toolbar/icons/Diamond.d.ts +0 -3
  51. package/dist/components/Toolbar/icons/Down.d.ts +0 -3
  52. package/dist/components/Toolbar/icons/Eraser.d.ts +0 -3
  53. package/dist/components/Toolbar/icons/Expand.d.ts +0 -3
  54. package/dist/components/Toolbar/icons/Line.d.ts +0 -3
  55. package/dist/components/Toolbar/icons/Pencil.d.ts +0 -3
  56. package/dist/components/Toolbar/icons/Rectangle.d.ts +0 -3
  57. package/dist/components/Toolbar/icons/Selector.d.ts +0 -3
  58. package/dist/components/Toolbar/icons/SpeechBalloon.d.ts +0 -3
  59. package/dist/components/Toolbar/icons/Star.d.ts +0 -3
  60. package/dist/components/Toolbar/icons/Text.d.ts +0 -3
  61. package/dist/components/Toolbar/icons/Triangle.d.ts +0 -3
  62. package/dist/components/Toolbar/icons/Up.d.ts +0 -3
  63. package/dist/components/Toolbar/icons/index.d.ts +0 -22
  64. package/dist/components/Toolbar/index.d.ts +0 -2
  65. package/dist/components/ZoomControl/ZoomControl.d.ts +0 -5
  66. package/dist/components/ZoomControl/hooks.d.ts +0 -7
  67. package/dist/components/ZoomControl/index.d.ts +0 -2
  68. package/dist/components/hooks.d.ts +0 -13
  69. package/dist/i18n/index.d.ts +0 -12
  70. package/dist/icons/ChevronLeft.d.ts +0 -3
  71. package/dist/icons/ChevronRight.d.ts +0 -3
  72. package/dist/icons/FilePlus.d.ts +0 -3
  73. package/dist/icons/Minus.d.ts +0 -3
  74. package/dist/icons/Plus.d.ts +0 -3
  75. package/dist/icons/Redo.d.ts +0 -3
  76. package/dist/icons/Reset.d.ts +0 -3
  77. package/dist/icons/Undo.d.ts +0 -3
  78. package/dist/icons/index.d.ts +0 -7
  79. package/dist/index.d.ts +0 -9
  80. package/dist/internal/helpers.d.ts +0 -16
  81. package/dist/internal/hooks.d.ts +0 -3
  82. package/dist/internal/index.d.ts +0 -2
  83. package/dist/theme.d.ts +0 -16
  84. package/dist/typings.d.ts +0 -10
  85. package/src/components/Toolbar/components/Mask.tsx +0 -44
@@ -1,2 +0,0 @@
1
- /// <reference types="react" />
2
- export declare function Slider(): JSX.Element;
@@ -1,2 +0,0 @@
1
- /// <reference types="react" />
2
- export declare function TextButton(): JSX.Element;
@@ -1,7 +0,0 @@
1
- /// <reference types="react" />
2
- export interface UpButtonProps {
3
- disabled: boolean;
4
- scrollTo: (height: number) => void;
5
- }
6
- export declare function UpButton({ disabled, scrollTo }: UpButtonProps): JSX.Element;
7
- export declare function DownButton({ disabled, scrollTo }: UpButtonProps): JSX.Element;
@@ -1,18 +0,0 @@
1
- /// <reference types="react" />
2
- import { ApplianceNames, ShapeType } from "white-web-sdk";
3
- export declare const ShapesMap: {
4
- readonly rectangle: import("react").MemoExoticComponent<(props: import("../..").IconProps) => JSX.Element>;
5
- readonly ellipse: import("react").MemoExoticComponent<(props: import("../..").IconProps) => JSX.Element>;
6
- readonly straight: import("react").MemoExoticComponent<(props: import("../..").IconProps) => JSX.Element>;
7
- readonly arrow: import("react").MemoExoticComponent<(props: import("../..").IconProps) => JSX.Element>;
8
- readonly pentagram: import("react").MemoExoticComponent<(props: import("../..").IconProps) => JSX.Element>;
9
- readonly rhombus: import("react").MemoExoticComponent<(props: import("../..").IconProps) => JSX.Element>;
10
- readonly triangle: import("react").MemoExoticComponent<(props: import("../..").IconProps) => JSX.Element>;
11
- readonly speechBalloon: import("react").MemoExoticComponent<(props: import("../..").IconProps) => JSX.Element>;
12
- };
13
- export declare const ApplianceShapes: readonly [ApplianceNames.rectangle, ApplianceNames.ellipse, ApplianceNames.straight, ApplianceNames.arrow];
14
- export declare const Shapes: readonly [ShapeType.Pentagram, ShapeType.Rhombus, ShapeType.Triangle, ShapeType.SpeechBalloon];
15
- export declare const ItemHeight: number;
16
- export declare const ItemsCount = 8;
17
- export declare const MaxHeight: number;
18
- export declare const MinHeight: number;
@@ -1,12 +0,0 @@
1
- import type { ApplianceNames, Color, MemberState, ShapeType } from "white-web-sdk";
2
- export interface ToolbarHook {
3
- readonly writable: boolean;
4
- readonly memberState: MemberState | undefined;
5
- cleanCurrentScene(): void;
6
- setAppliance(appliance: ApplianceNames, shape?: ShapeType): void;
7
- setStrokeWidth(width: number): void;
8
- setStrokeColor(color: Color): void;
9
- }
10
- export declare function useRoomState(): any;
11
- export declare function useToolbar(): ToolbarHook;
12
- export declare const EmptyToolbarHook: ToolbarHook;
@@ -1,3 +0,0 @@
1
- /// <reference types="react" />
2
- import type { IconProps } from "../../../typings";
3
- export declare const Apps: (props: IconProps) => JSX.Element;
@@ -1,3 +0,0 @@
1
- /// <reference types="react" />
2
- import type { IconProps } from "../../../typings";
3
- export declare const Arrow: (props: IconProps) => JSX.Element;
@@ -1,3 +0,0 @@
1
- /// <reference types="react" />
2
- import type { IconProps } from "../../../typings";
3
- export declare const Circle: (props: IconProps) => JSX.Element;
@@ -1,3 +0,0 @@
1
- /// <reference types="react" />
2
- import type { IconProps } from "../../../typings";
3
- export declare const Clean: (props: IconProps) => JSX.Element;
@@ -1,3 +0,0 @@
1
- /// <reference types="react" />
2
- import type { IconProps } from "../../../typings";
3
- export declare const Clicker: (props: IconProps) => JSX.Element;
@@ -1,3 +0,0 @@
1
- /// <reference types="react" />
2
- import type { IconProps } from "../../../typings";
3
- export declare const Collapse: (props: IconProps) => JSX.Element;
@@ -1,3 +0,0 @@
1
- /// <reference types="react" />
2
- import type { IconProps } from "../../../typings";
3
- export declare const Diamond: (props: IconProps) => JSX.Element;
@@ -1,3 +0,0 @@
1
- /// <reference types="react" />
2
- import type { IconProps } from "../../../typings";
3
- export declare const Down: (props: IconProps) => JSX.Element;
@@ -1,3 +0,0 @@
1
- /// <reference types="react" />
2
- import type { IconProps } from "../../../typings";
3
- export declare const Eraser: (props: IconProps) => JSX.Element;
@@ -1,3 +0,0 @@
1
- /// <reference types="react" />
2
- import type { IconProps } from "../../../typings";
3
- export declare const Expand: (props: IconProps) => JSX.Element;
@@ -1,3 +0,0 @@
1
- /// <reference types="react" />
2
- import type { IconProps } from "../../../typings";
3
- export declare const Line: (props: IconProps) => JSX.Element;
@@ -1,3 +0,0 @@
1
- /// <reference types="react" />
2
- import type { IconProps } from "../../../typings";
3
- export declare const Pencil: (props: IconProps) => JSX.Element;
@@ -1,3 +0,0 @@
1
- /// <reference types="react" />
2
- import type { IconProps } from "../../../typings";
3
- export declare const Rectangle: (props: IconProps) => JSX.Element;
@@ -1,3 +0,0 @@
1
- /// <reference types="react" />
2
- import type { IconProps } from "../../../typings";
3
- export declare const Selector: (props: IconProps) => JSX.Element;
@@ -1,3 +0,0 @@
1
- /// <reference types="react" />
2
- import type { IconProps } from "../../../typings";
3
- export declare const SpeechBalloon: (props: IconProps) => JSX.Element;
@@ -1,3 +0,0 @@
1
- /// <reference types="react" />
2
- import type { IconProps } from "../../../typings";
3
- export declare const Star: (props: IconProps) => JSX.Element;
@@ -1,3 +0,0 @@
1
- /// <reference types="react" />
2
- import type { IconProps } from "../../../typings";
3
- export declare const Text: (props: IconProps) => JSX.Element;
@@ -1,3 +0,0 @@
1
- /// <reference types="react" />
2
- import type { IconProps } from "../../../typings";
3
- export declare const Triangle: (props: IconProps) => JSX.Element;
@@ -1,3 +0,0 @@
1
- /// <reference types="react" />
2
- import type { IconProps } from "../../../typings";
3
- export declare const Up: (props: IconProps) => JSX.Element;
@@ -1,22 +0,0 @@
1
- /// <reference types="react" />
2
- export declare const Icons: {
3
- Clicker: import("react").MemoExoticComponent<(props: import("../../..").IconProps) => JSX.Element>;
4
- Collapse: import("react").MemoExoticComponent<(props: import("../../..").IconProps) => JSX.Element>;
5
- Eraser: import("react").MemoExoticComponent<(props: import("../../..").IconProps) => JSX.Element>;
6
- Expand: import("react").MemoExoticComponent<(props: import("../../..").IconProps) => JSX.Element>;
7
- Pencil: import("react").MemoExoticComponent<(props: import("../../..").IconProps) => JSX.Element>;
8
- Selector: import("react").MemoExoticComponent<(props: import("../../..").IconProps) => JSX.Element>;
9
- Rectangle: import("react").MemoExoticComponent<(props: import("../../..").IconProps) => JSX.Element>;
10
- Text: import("react").MemoExoticComponent<(props: import("../../..").IconProps) => JSX.Element>;
11
- Apps: import("react").MemoExoticComponent<(props: import("../../..").IconProps) => JSX.Element>;
12
- Clean: import("react").MemoExoticComponent<(props: import("../../..").IconProps) => JSX.Element>;
13
- Circle: import("react").MemoExoticComponent<(props: import("../../..").IconProps) => JSX.Element>;
14
- Line: import("react").MemoExoticComponent<(props: import("../../..").IconProps) => JSX.Element>;
15
- Arrow: import("react").MemoExoticComponent<(props: import("../../..").IconProps) => JSX.Element>;
16
- Star: import("react").MemoExoticComponent<(props: import("../../..").IconProps) => JSX.Element>;
17
- Diamond: import("react").MemoExoticComponent<(props: import("../../..").IconProps) => JSX.Element>;
18
- SpeechBalloon: import("react").MemoExoticComponent<(props: import("../../..").IconProps) => JSX.Element>;
19
- Triangle: import("react").MemoExoticComponent<(props: import("../../..").IconProps) => JSX.Element>;
20
- Up: import("react").MemoExoticComponent<(props: import("../../..").IconProps) => JSX.Element>;
21
- Down: import("react").MemoExoticComponent<(props: import("../../..").IconProps) => JSX.Element>;
22
- };
@@ -1,2 +0,0 @@
1
- export * from "./hooks";
2
- export { Toolbar, type ToolbarProps } from "./Toolbar";
@@ -1,5 +0,0 @@
1
- /// <reference types="react" />
2
- import type { CommonProps, GenericIcon } from "../../typings";
3
- export declare const name = "fastboard-zoom-control";
4
- export declare type ZoomControlProps = CommonProps & GenericIcon<"reset" | "minus" | "plus">;
5
- export declare function ZoomControl({ theme, resetIcon, resetIconDisable, minusIcon, minusIconDisable, plusIcon, plusIconDisable, }: ZoomControlProps): JSX.Element;
@@ -1,7 +0,0 @@
1
- export declare const ScalePoints: readonly number[];
2
- export declare function useZoomControl(): {
3
- scale: any;
4
- resetCamera: () => void;
5
- zoomIn: () => void;
6
- zoomOut: () => void;
7
- };
@@ -1,2 +0,0 @@
1
- export * from "./hooks";
2
- export { ZoomControl, type ZoomControlProps } from "./ZoomControl";
@@ -1,13 +0,0 @@
1
- /// <reference types="react" />
2
- import type { FastboardReadable } from "@netless/fastboard";
3
- import type { Theme } from "../typings";
4
- export declare const FastboardAppContext: import("react").Context<any>;
5
- export declare const ThemeContext: import("react").Context<Theme>;
6
- export declare function useTheme(userTheme?: Theme | null): Theme;
7
- export declare function useFastboardApp(): any;
8
- export declare function useFastboardValue<T>(val: FastboardReadable<T>): any;
9
- export declare function useWritable(): any;
10
- export declare function useBoxState(): any;
11
- export declare function useFocusedApp(): any;
12
- export declare function useMaximized(): boolean;
13
- export declare function useHideControls(): boolean | "toolbar-only";
@@ -1,12 +0,0 @@
1
- /// <reference types="react" />
2
- import type { i18n } from "i18next";
3
- import type { Language } from "../typings";
4
- export interface CreateI18nParams {
5
- language?: Language;
6
- }
7
- export declare const createI18n: ({ language, }?: CreateI18nParams) => Promise<i18n>;
8
- export declare const I18nContext: import("react").Context<i18n | null>;
9
- export declare function useTranslation(): {
10
- t: import("i18next").TFunction | ((id: string) => string);
11
- i18n: i18n | null;
12
- };
@@ -1,3 +0,0 @@
1
- /// <reference types="react" />
2
- import type { IconProps } from "../typings";
3
- export declare function ChevronLeft({ theme, active }: IconProps): JSX.Element;
@@ -1,3 +0,0 @@
1
- /// <reference types="react" />
2
- import type { IconProps } from "../typings";
3
- export declare function ChevronRight({ theme, active }: IconProps): JSX.Element;
@@ -1,3 +0,0 @@
1
- /// <reference types="react" />
2
- import type { IconProps } from "../typings";
3
- export declare function FilePlus({ theme, active }: IconProps): JSX.Element;
@@ -1,3 +0,0 @@
1
- /// <reference types="react" />
2
- import type { IconProps } from "../typings";
3
- export declare function Minus({ theme, active }: IconProps): JSX.Element;
@@ -1,3 +0,0 @@
1
- /// <reference types="react" />
2
- import type { IconProps } from "../typings";
3
- export declare function Plus({ theme, active }: IconProps): JSX.Element;
@@ -1,3 +0,0 @@
1
- /// <reference types="react" />
2
- import type { IconProps } from "../typings";
3
- export declare function Redo({ theme, active }: IconProps): JSX.Element;
@@ -1,3 +0,0 @@
1
- /// <reference types="react" />
2
- import type { IconProps } from "../typings";
3
- export declare function Reset({ theme, active }: IconProps): JSX.Element;
@@ -1,3 +0,0 @@
1
- /// <reference types="react" />
2
- import type { IconProps } from "../typings";
3
- export declare function Undo({ theme, active }: IconProps): JSX.Element;
@@ -1,7 +0,0 @@
1
- import React from "react";
2
- export interface IconPropsWithFallback {
3
- fallback: React.ReactElement;
4
- src?: string;
5
- alt?: string;
6
- }
7
- export declare function Icon({ fallback, src, alt }: IconPropsWithFallback): JSX.Element;
package/dist/index.d.ts DELETED
@@ -1,9 +0,0 @@
1
- import "./behaviors/style";
2
- export * from "./typings";
3
- export * from "./components/hooks";
4
- export * from "./components/RedoUndo";
5
- export * from "./components/ZoomControl";
6
- export * from "./components/PageControl";
7
- export * from "./components/Toolbar";
8
- export * from "./components/PlayerControl";
9
- export * from "./components/Fastboard";
@@ -1,16 +0,0 @@
1
- export declare function noop(): void;
2
- export declare function applyStyles(css: string): HTMLStyleElement;
3
- export declare function clamp(value: number, min: number, max: number): number;
4
- export declare function isEqualArray<T>(a: T[], b: T[]): boolean;
5
- export declare const defaultHotKeys: {
6
- changeToSelector: string;
7
- changeToLaserPointer: string;
8
- changeToPencil: string;
9
- changeToRectangle: string;
10
- changeToEllipse: string;
11
- changeToEraser: string;
12
- changeToText: string;
13
- changeToStraight: string;
14
- changeToArrow: string;
15
- changeToHand: string;
16
- };
@@ -1,3 +0,0 @@
1
- export declare function useLastValue<T>(value: T): T;
2
- export declare function useAsyncValue<T>(fn: () => Promise<T>): T | null;
3
- export declare function useForceUpdate(): () => void;
@@ -1,2 +0,0 @@
1
- export * from "./helpers";
2
- export * from "./hooks";
package/dist/theme.d.ts DELETED
@@ -1,16 +0,0 @@
1
- import type { IconProps } from "./typings";
2
- export interface ThemeConfig {
3
- color: string;
4
- activeColor: string;
5
- backgroundColor: string;
6
- hoverBackgroundColor: string;
7
- }
8
- export declare const light: ThemeConfig;
9
- export declare const dark: ThemeConfig;
10
- export declare const themes: {
11
- light: ThemeConfig;
12
- dark: ThemeConfig;
13
- };
14
- export declare const getStroke: (props: IconProps) => string;
15
- export declare const TopOffset: [number, number];
16
- export declare const RightOffset: [number, number];
package/dist/typings.d.ts DELETED
@@ -1,10 +0,0 @@
1
- export declare type Theme = "light" | "dark";
2
- export declare type Language = "en" | "zh-CN";
3
- export interface IconProps {
4
- theme?: Theme;
5
- active?: boolean;
6
- }
7
- export interface CommonProps {
8
- theme?: Theme;
9
- }
10
- export declare type GenericIcon<K extends string, E extends string = "disable"> = Partial<Record<`${K}Icon${Capitalize<E | "">}`, string>>;
@@ -1,44 +0,0 @@
1
- import React, { useState, useEffect } from "react";
2
- import ReactDOM from "react-dom";
3
-
4
- interface MaskProps {
5
- toolbar: HTMLDivElement | null;
6
- children: React.ReactNode;
7
- }
8
-
9
- export const Mask = React.memo(({ toolbar, children }: MaskProps) => {
10
- const [rootElement] = useState<HTMLDivElement | null>(() => {
11
- const element = document.createElement("div");
12
- element.style.position = "absolute";
13
- return element;
14
- });
15
-
16
- useEffect(() => {
17
- if (toolbar && rootElement) {
18
- toolbar.appendChild(rootElement);
19
- }
20
- }, [rootElement, toolbar]);
21
-
22
- useEffect(() => {
23
- if (rootElement && toolbar) {
24
- toolbar.appendChild(rootElement);
25
-
26
- const toolbarRect = toolbar.getBoundingClientRect();
27
- const halfHeight = toolbarRect.height / 2 - 31;
28
- rootElement.style.top = halfHeight + "px";
29
- rootElement.style.left = "41px";
30
- rootElement.style.width = "17px";
31
- rootElement.style.height = "62px";
32
-
33
- return () => {
34
- toolbar.removeChild(rootElement);
35
- };
36
- }
37
- }, [rootElement, toolbar]);
38
-
39
- if (rootElement) {
40
- return ReactDOM.createPortal(children, rootElement);
41
- } else {
42
- return null;
43
- }
44
- });