@chocbite/ts-lib-ui 1.0.2 → 1.0.4
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/README.md +16 -1
- package/base/index.d.mts +2 -2
- package/base/index.mjs +69 -77
- package/base/index.mjs.map +1 -1
- package/canvas/index.d.mts +117 -60
- package/canvas/index.mjs +652 -584
- package/canvas/index.mjs.map +1 -1
- package/context-menu/index.d.mts +1 -1
- package/context-menu/index.mjs +1 -1
- package/{context-menu-CiNcuP-a.mjs → context-menu-Cz9rqUaM.mjs} +71 -37
- package/context-menu-Cz9rqUaM.mjs.map +1 -0
- package/document/index.mjs +3 -1
- package/document/index.mjs.map +1 -1
- package/form/index.d.mts +16 -5
- package/form/index.mjs +412 -153
- package/form/index.mjs.map +1 -1
- package/icons/index.d.mts +1 -1
- package/icons/index.mjs +1 -1
- package/icons-e2J_Ojic.mjs +4124 -0
- package/{index-BcidwqIy.d.mts → index-BDWg5GX2.d.mts} +7 -18
- package/{index-BND79jZp.d.mts → index-CvzH3M_5.d.mts} +16 -9
- package/{index-CugtUzv_.d.mts → index-DCn7acFY.d.mts} +30 -12
- package/{index-CB3-qP6l.d.mts → index-DhRb2iA8.d.mts} +7 -5
- package/keyboard/index.d.mts +1 -1
- package/keyboard/index.mjs +121 -50
- package/keyboard/index.mjs.map +1 -1
- package/list/index.d.mts +1 -1
- package/list/index.mjs +1 -1
- package/{list-CQDnxsLV.mjs → list-DXkEJKjx.mjs} +218 -117
- package/list-DXkEJKjx.mjs.map +1 -0
- package/package.json +7 -7
- package/selection/index.mjs +9 -11
- package/selection/index.mjs.map +1 -1
- package/settings/index.d.mts +23 -5
- package/settings/index.mjs +17 -10
- package/settings/index.mjs.map +1 -1
- package/spinner/index.d.mts +1 -1
- package/spinner/index.mjs +2 -2
- package/state/index.d.mts +36 -0
- package/state/index.mjs +2 -0
- package/state-OCzEmq3j.mjs +87 -0
- package/state-OCzEmq3j.mjs.map +1 -0
- package/style.css +423 -142
- package/svg/index.d.mts +1 -1
- package/svg/index.mjs +1 -1
- package/{svg-golJPaR4.mjs → svg-1bp-yIPC.mjs} +20 -17
- package/svg-1bp-yIPC.mjs.map +1 -0
- package/theme/index.d.mts +21 -2
- package/theme/index.mjs +1 -1
- package/{theme-9ib89_3b.mjs → theme-CFeGnUuF.mjs} +125 -44
- package/theme-CFeGnUuF.mjs.map +1 -0
- package/context-menu-CiNcuP-a.mjs.map +0 -1
- package/icons-CY4BLQ2F.mjs +0 -4123
- package/list-CQDnxsLV.mjs.map +0 -1
- package/svg-golJPaR4.mjs.map +0 -1
- package/theme-9ib89_3b.mjs.map +0 -1
- package/viewport/index.d.mts +0 -1
- package/viewport/index.mjs +0 -2
package/canvas/index.d.mts
CHANGED
|
@@ -1,74 +1,131 @@
|
|
|
1
1
|
import '../style.css';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import { l as Base } from "../index-CvzH3M_5.mjs";
|
|
3
|
+
/**Event dispatched on a widget when its position, size or rotation changes */
|
|
4
|
+
export declare const WIDGET_TRANSFORM_EVENT = "widget_transform";
|
|
5
|
+
/**Shared class for widgets placed at a fixed position in a viewport
|
|
6
|
+
* Position and size are in viewport units (px before any viewport scaling)
|
|
7
|
+
* Rotation is in degrees clockwise around the center of the widget
|
|
8
|
+
*
|
|
9
|
+
* Width and height must always be set, they default to 0
|
|
10
|
+
*
|
|
11
|
+
* Widgets declare their original size, which is the size their content is laid out at
|
|
12
|
+
* The content is then scaled from the original size to the width and height of the widget
|
|
13
|
+
* Widgets that should not stretch, like text, return width and height as their original size
|
|
14
|
+
*
|
|
15
|
+
* WIDGET_TRANSFORM_EVENT is dispatched whenever position, size or rotation changes*/
|
|
16
|
+
export declare abstract class WidgetBase extends Base {
|
|
6
17
|
#private;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
|
|
11
|
-
/**Default height of element when created */
|
|
12
|
-
abstract default_height(): number;
|
|
13
|
-
/**Element optimal ratio, returns the ratio where the element has no distortion.
|
|
14
|
-
* If the element can dynamically change based on ratio, return none. */
|
|
15
|
-
optimal_ratio(): Option<number>;
|
|
16
|
-
/**Called when the element has no optimal ratio and its dimensions change.
|
|
17
|
-
* Descendants can override this to re-layout their content in the new
|
|
18
|
-
* coordinate space defined by the updated viewBox. */
|
|
19
|
-
protected on_resize(_width: number, _height: number): void;
|
|
20
|
-
readonly canvas: SVGSVGElement;
|
|
18
|
+
/**Returns the name used to define the element, Abstract classes should return @abstract@ */
|
|
19
|
+
static element_name(): string;
|
|
20
|
+
/**Returns the namespace override for the element*/
|
|
21
|
+
static element_name_space(): string;
|
|
21
22
|
constructor();
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
protected connectedCallback(): void;
|
|
24
|
+
/**Returns the width the content of the widget is laid out at, return this.width to not stretch */
|
|
25
|
+
abstract get original_width(): number;
|
|
26
|
+
/**Returns the height the content of the widget is laid out at, return this.height to not stretch */
|
|
27
|
+
abstract get original_height(): number;
|
|
28
|
+
/**Sets the x position of the left edge of the widget */
|
|
29
|
+
set x(x: number);
|
|
30
|
+
/**Returns the x position of the left edge of the widget */
|
|
31
|
+
get x(): number;
|
|
32
|
+
/**Sets the y position of the top edge of the widget */
|
|
33
|
+
set y(y: number);
|
|
34
|
+
/**Returns the y position of the top edge of the widget */
|
|
35
|
+
get y(): number;
|
|
36
|
+
/**Sets the width of the widget */
|
|
37
|
+
set width(width: number);
|
|
38
|
+
/**Returns the width of the widget */
|
|
39
|
+
get width(): number;
|
|
40
|
+
/**Sets the height of the widget */
|
|
41
|
+
set height(height: number);
|
|
42
|
+
/**Returns the height of the widget */
|
|
43
|
+
get height(): number;
|
|
44
|
+
/**Sets the rotation of the widget in degrees, rotating clockwise around the center of the widget */
|
|
45
|
+
set rotation(rotation: number);
|
|
46
|
+
/**Returns the rotation of the widget in degrees */
|
|
27
47
|
get rotation(): number;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
set width(value: number);
|
|
48
|
+
}
|
|
49
|
+
/**Page of widgets with a fixed size
|
|
50
|
+
* Width and height are the size of the page in page units (px before any viewport scaling)*/
|
|
51
|
+
declare class Page extends Base {
|
|
52
|
+
#private;
|
|
53
|
+
/**Returns the name used to define the element */
|
|
54
|
+
static element_name(): string;
|
|
55
|
+
/**Returns the namespace override for the element*/
|
|
56
|
+
static element_name_space(): string;
|
|
57
|
+
constructor();
|
|
58
|
+
/**Sets the width of the page */
|
|
59
|
+
set width(width: number);
|
|
60
|
+
/**Returns the width of the page */
|
|
42
61
|
get width(): number;
|
|
43
|
-
/**
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
* - If the element has no optimal_ratio, the viewBox is updated to match
|
|
47
|
-
* the new dimensions and on_resize is called. */
|
|
48
|
-
set height(value: number);
|
|
62
|
+
/**Sets the height of the page */
|
|
63
|
+
set height(height: number);
|
|
64
|
+
/**Returns the height of the page */
|
|
49
65
|
get height(): number;
|
|
66
|
+
/**Sets the widgets on the page, the array order is the drawing order with the last widget on top
|
|
67
|
+
* Widgets already on the page are kept in place, so they are only reconnected if their order changes */
|
|
68
|
+
set widgets(widgets: readonly WidgetBase[]);
|
|
69
|
+
/**Returns the widgets on the page */
|
|
70
|
+
get widgets(): readonly WidgetBase[];
|
|
50
71
|
}
|
|
72
|
+
interface CanvasPageOptions {
|
|
73
|
+
/**Width of the page in page units, defaults to 1920 */
|
|
74
|
+
width?: number;
|
|
75
|
+
/**Height of the page in page units, defaults to 1080 */
|
|
76
|
+
height?: number;
|
|
77
|
+
/**Widgets on the page, the last widget is drawn on top */
|
|
78
|
+
widgets?: readonly WidgetBase[];
|
|
79
|
+
}
|
|
80
|
+
/**Viewport showing a page of widgets
|
|
81
|
+
* The page is scaled to fit inside the viewport element while keeping its aspect ratio, and centered
|
|
82
|
+
*
|
|
83
|
+
* When edit is true the page can be zoomed and panned, and a checkerboard is shown behind it
|
|
84
|
+
* Wheel and touchpad two finger swipe pans, ctrl + wheel or swipe zooms toward the cursor
|
|
85
|
+
* Shift + vertical wheel pans horizontally
|
|
86
|
+
* Touchpad pinch zooms toward the cursor
|
|
87
|
+
* Holding alt makes wheel zoom and pan 10 times slower
|
|
88
|
+
* Two finger touch pinch zooms and pans, middle or right mouse drag pans
|
|
89
|
+
*
|
|
90
|
+
* Pressing a widget in edit mode selects it and attaches a transformer to move, resize and rotate it
|
|
91
|
+
* Pressing outside any widget clears the selection*/
|
|
51
92
|
declare class Viewport extends Base {
|
|
52
93
|
#private;
|
|
94
|
+
/**Returns the name used to define the element */
|
|
53
95
|
static element_name(): string;
|
|
96
|
+
/**Returns the namespace override for the element*/
|
|
54
97
|
static element_name_space(): string;
|
|
55
|
-
constructor(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
get
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
set
|
|
67
|
-
|
|
98
|
+
constructor();
|
|
99
|
+
/**Sets the page shown in the viewport */
|
|
100
|
+
set page(page: Page | undefined);
|
|
101
|
+
/**Returns the page shown in the viewport */
|
|
102
|
+
get page(): Page | undefined;
|
|
103
|
+
/**Sets edit mode, which enables zooming and panning and shows a checkerboard background
|
|
104
|
+
* Leaving edit mode resets the view to fit the page */
|
|
105
|
+
set edit(edit: boolean);
|
|
106
|
+
/**Returns whether edit mode is enabled */
|
|
107
|
+
get edit(): boolean;
|
|
108
|
+
/**Sets the selected widget, which the transformer is attached to, selection is cleared when leaving edit mode */
|
|
109
|
+
set selected(widget: WidgetBase | undefined);
|
|
110
|
+
/**Returns the selected widget */
|
|
111
|
+
get selected(): WidgetBase | undefined;
|
|
112
|
+
/**Returns the current scale from page units to screen pixels */
|
|
113
|
+
get scale(): number;
|
|
114
|
+
protected on_resize(): void;
|
|
115
|
+
protected connectedCallback(): void;
|
|
116
|
+
protected disconnectedCallback(): void;
|
|
117
|
+
}
|
|
118
|
+
interface CanvasViewportOptions {
|
|
119
|
+
/**Page shown in the viewport */
|
|
120
|
+
page?: Page;
|
|
121
|
+
/**Enables zooming, panning and selecting widgets */
|
|
122
|
+
edit?: boolean;
|
|
68
123
|
}
|
|
69
|
-
|
|
70
|
-
export declare const
|
|
71
|
-
|
|
124
|
+
/**Displaying and editing graphics with a fixed position and size */
|
|
125
|
+
export declare const canvas: {
|
|
126
|
+
page: (options?: CanvasPageOptions) => Page;
|
|
127
|
+
viewport: (options?: CanvasViewportOptions) => Viewport;
|
|
128
|
+
WIDGET_TRANSFORM_EVENT: string;
|
|
72
129
|
};
|
|
73
|
-
export {};
|
|
130
|
+
export { type CanvasPageOptions, type CanvasViewportOptions, type Page, type Viewport, canvas as default };
|
|
74
131
|
//# sourceMappingURL=index.d.mts.map
|