@ws-ui/shared 0.0.1

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.
@@ -0,0 +1,3 @@
1
+ import Qodly from "./Qodly.svg?react";
2
+ export { Qodly };
3
+ export * from './4DIcons';
@@ -0,0 +1,21 @@
1
+ import { Placement, VirtualElement } from '@popperjs/core';
2
+ import React, { CSSProperties, FC } from 'react';
3
+ interface IOverlayProps {
4
+ onClick: (ev: React.MouseEvent) => void;
5
+ }
6
+ export declare const Overlay: FC<IOverlayProps>;
7
+ interface IDialogBodyProps {
8
+ style?: CSSProperties;
9
+ attributes?: {
10
+ [key: string]: string;
11
+ };
12
+ }
13
+ export declare const DialogBody: React.ForwardRefExoticComponent<Omit<React.HTMLProps<HTMLDivElement> & IDialogBodyProps, "ref"> & React.RefAttributes<any>>;
14
+ interface IDialogProps {
15
+ isOpen: boolean;
16
+ onClose?: () => void;
17
+ referenceElement: Element | VirtualElement | null | undefined;
18
+ placement?: Placement;
19
+ }
20
+ export declare const Dialog: FC<IDialogProps>;
21
+ export {};
@@ -0,0 +1,2 @@
1
+ import { FC } from 'react';
2
+ export declare const Portal: FC;
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ export type ToastKind = 'warning' | 'info' | 'danger' | 'message' | 'error' | 'multi';
3
+ interface IToastProps {
4
+ kind: ToastKind;
5
+ message: string | IMultilineMessage[];
6
+ id?: number | string;
7
+ onClose(): void;
8
+ }
9
+ export interface IMultilineMessage {
10
+ title: string;
11
+ messages: string[];
12
+ }
13
+ export declare const Toast: React.FC<IToastProps>;
14
+ export {};
@@ -0,0 +1,8 @@
1
+ import { FC } from 'react';
2
+ declare const IndentLines: FC<{
3
+ showLines?: boolean;
4
+ depth: number;
5
+ height?: number;
6
+ width?: number;
7
+ }>;
8
+ export default IndentLines;
@@ -0,0 +1,8 @@
1
+ import { FC, MouseEventHandler } from 'react';
2
+ declare const Switcher: FC<{
3
+ show: boolean;
4
+ expanded: boolean;
5
+ variant?: 'arrow' | 'caret';
6
+ onClick?: MouseEventHandler;
7
+ }>;
8
+ export default Switcher;
@@ -0,0 +1,4 @@
1
+ import { FC } from 'react';
2
+ import { ITreeProps } from '../interfaces';
3
+ declare const Tree: FC<ITreeProps>;
4
+ export default Tree;
@@ -0,0 +1,4 @@
1
+ import { FC } from 'react';
2
+ import { TreeNodeProps } from '../interfaces';
3
+ declare const TreeNode: FC<TreeNodeProps>;
4
+ export default TreeNode;
@@ -0,0 +1,7 @@
1
+ import Tree from './components/Tree';
2
+ import TreeNode from './components/TreeNode';
3
+ import IndentLines from './components/IndentLines';
4
+ import Switcher from './components/Switcher';
5
+ export { TreeNode, Tree, IndentLines, Switcher };
6
+ export * from './interfaces';
7
+ export * from './styled';
@@ -0,0 +1,87 @@
1
+ import { MouseEvent, ReactElement } from 'react';
2
+ export type RenderNodeHandler<T = any> = (node: ITreeNodeData<T>, depth: number, state: NodeState, actions: TreeActions, searchQuery: string) => JSX.Element;
3
+ export type NodeHandler = (node?: ITreeNodeData) => void;
4
+ export type NodeState = {
5
+ expanded: boolean;
6
+ selected: boolean;
7
+ };
8
+ export type TreeActions = {
9
+ expand: NodeHandler;
10
+ select: NodeHandler;
11
+ selectSingle: NodeHandler;
12
+ deselect: NodeHandler;
13
+ };
14
+ export type TreeState = {
15
+ expandedKeys: string[];
16
+ selectedKeys: string[];
17
+ };
18
+ export interface ITreeProps {
19
+ /**
20
+ * Nested Tree Data.
21
+ */
22
+ treeData: ITreeNodeData[];
23
+ /**
24
+ * A function to customize the structure of the node.
25
+ */
26
+ renderNode?: RenderNodeHandler;
27
+ /**
28
+ * an event listener when a node is expanded inside the tree
29
+ */
30
+ onExpandNode?: (expandedKeys: string[]) => void;
31
+ /**
32
+ * expanded keys of the tree.
33
+ */
34
+ expandedKeys?: string[];
35
+ /**
36
+ * node search query
37
+ */
38
+ searchQuery?: string;
39
+ /**
40
+ * expand condition
41
+ */
42
+ expandCondition?: 'always' | 'when-collapsed';
43
+ /**
44
+ * Hanlder for node click event.
45
+ */
46
+ onNodeClick?: NodeHandler;
47
+ /**
48
+ * Renders the encapsolated view
49
+ */
50
+ encapsulated?: boolean;
51
+ }
52
+ export interface ITreeNodeData<T = any> {
53
+ key: string;
54
+ title: string;
55
+ index?: number;
56
+ subtitle?: string;
57
+ options?: {
58
+ selectable?: boolean;
59
+ draggable?: boolean;
60
+ focusable?: boolean;
61
+ deletable?: boolean;
62
+ filterable?: boolean;
63
+ };
64
+ icon?: ReactElement | JSX.Element | string;
65
+ children?: ITreeNodeData[];
66
+ invalid?: boolean;
67
+ data?: T;
68
+ }
69
+ export interface TreeNodeProps {
70
+ node: ITreeNodeData;
71
+ expandedKeys: string[];
72
+ selectedKeys: string[];
73
+ actions: TreeActions;
74
+ depth: number;
75
+ searchQuery: string;
76
+ renderNode?: RenderNodeHandler;
77
+ onNodeClick?: NodeHandler;
78
+ }
79
+ export interface ITreeAction {
80
+ name: string;
81
+ icon: ReactElement;
82
+ }
83
+ export interface ITreeIcon {
84
+ size?: number;
85
+ className?: string;
86
+ onClick?: (ev: MouseEvent) => void;
87
+ }
@@ -0,0 +1,3 @@
1
+ import { FC } from 'react';
2
+ import { ITreeIcon } from './interfaces';
3
+ export declare const TreeIcon: FC<ITreeIcon>;
@@ -0,0 +1,4 @@
1
+ export * from './Dialog';
2
+ export * from './Portal';
3
+ export * from './Toast';
4
+ export * from './Tree';
@@ -0,0 +1,5 @@
1
+ export * from './use-didmounteffect';
2
+ export * from './use-hotkeys';
3
+ export * from './use-outside-click';
4
+ export * from './use-previous';
5
+ export * from './use-state-ref';
@@ -0,0 +1,2 @@
1
+ import { EffectCallback, DependencyList } from 'react';
2
+ export declare function useDidMountEffect(effect: EffectCallback, deps?: DependencyList): void;
@@ -0,0 +1,14 @@
1
+ import { DependencyList } from 'react';
2
+ import { KeyHandler } from 'hotkeys-js';
3
+ type Options = {
4
+ scope?: string;
5
+ element?: HTMLElement | null;
6
+ keyup?: boolean | null;
7
+ keydown?: boolean | null;
8
+ splitKey?: string;
9
+ preventDefault?: boolean;
10
+ };
11
+ export declare function useHotkeys(keys: string, callback: KeyHandler, options?: Options): void;
12
+ export declare function useHotkeys(keys: string, callback: KeyHandler, deps?: DependencyList): void;
13
+ export declare function useHotkeys(keys: string, callback: KeyHandler, options?: Options, deps?: DependencyList): void;
14
+ export {};
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare const useOutsideClick: <T extends HTMLElement, R = void>(callback: (event: MouseEvent) => R) => import("react").MutableRefObject<T | null>;
@@ -0,0 +1 @@
1
+ export declare function usePrevious<T = any>(value: T): T | undefined;
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare function useStateRef<T>(state: T): import("react").MutableRefObject<T>;