@chocbite/ts-lib-ui 0.0.0-stage → 1.0.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/README.md +48 -2
- package/base/index.d.mts +3 -0
- package/base/index.mjs +521 -0
- package/base/index.mjs.map +1 -0
- package/canvas/index.d.mts +74 -0
- package/canvas/index.mjs +619 -0
- package/canvas/index.mjs.map +1 -0
- package/context-menu/index.d.mts +3 -0
- package/context-menu/index.mjs +2 -0
- package/context-menu-BbDVgMiZ.mjs +527 -0
- package/context-menu-BbDVgMiZ.mjs.map +1 -0
- package/document/index.d.mts +27 -0
- package/document/index.mjs +50 -0
- package/document/index.mjs.map +1 -0
- package/dom/index.d.mts +3 -0
- package/dom/index.mjs +8 -0
- package/dom/index.mjs.map +1 -0
- package/form/index.d.mts +747 -0
- package/form/index.mjs +2694 -0
- package/form/index.mjs.map +1 -0
- package/icons/index.d.mts +4109 -0
- package/icons/index.mjs +2 -0
- package/icons/mixins.scss +12 -0
- package/icons-CY4BLQ2F.mjs +4123 -0
- package/index-BvflC2sG.d.mts +212 -0
- package/index-CWQ5KhrP.d.mts +167 -0
- package/index-CdiJN7JF.d.mts +155 -0
- package/index-Cx6QmIC-.d.mts +120 -0
- package/keyboard/index.d.mts +85 -0
- package/keyboard/index.mjs +1499 -0
- package/keyboard/index.mjs.map +1 -0
- package/list/index.d.mts +3 -0
- package/list/index.mjs +2 -0
- package/list-CmrmWLBD.mjs +617 -0
- package/list-CmrmWLBD.mjs.map +1 -0
- package/package.json +95 -4
- package/selection/index.d.mts +16 -0
- package/selection/index.mjs +96 -0
- package/selection/index.mjs.map +1 -0
- package/settings/index.d.mts +43 -0
- package/settings/index.mjs +110 -0
- package/settings/index.mjs.map +1 -0
- package/spinner/index.d.mts +10 -0
- package/spinner/index.mjs +39 -0
- package/spinner/index.mjs.map +1 -0
- package/style.css +2994 -0
- package/svg/index.d.mts +3 -0
- package/svg/index.mjs +2 -0
- package/svg-golJPaR4.mjs +358 -0
- package/svg-golJPaR4.mjs.map +1 -0
- package/theme/index.d.mts +179 -0
- package/theme/index.mjs +2 -0
- package/theme/mixins.scss +39 -0
- package/theme-BtAXQpvm.mjs +338 -0
- package/theme-BtAXQpvm.mjs.map +1 -0
- package/viewport/index.d.mts +1 -0
- package/viewport/index.mjs +2 -0
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import './style.css';
|
|
2
|
+
import { t as SVGFunc } from "./index-CWQ5KhrP.mjs";
|
|
3
|
+
import { State, StateInferSub, StateREA, StateROA, StateSub } from "@chocbite/ts-lib/state";
|
|
4
|
+
import { Option } from "@chocbite/ts-lib/result";
|
|
5
|
+
/**Enum of possible access types for base element*/
|
|
6
|
+
declare const AccessTypes: {
|
|
7
|
+
readonly Write: "w";
|
|
8
|
+
readonly Read: "r";
|
|
9
|
+
readonly None: "n";
|
|
10
|
+
};
|
|
11
|
+
type AccessTypes = (typeof AccessTypes)[keyof typeof AccessTypes];
|
|
12
|
+
/**List for access type*/
|
|
13
|
+
declare const ACCESSTYPESINFO: {
|
|
14
|
+
w: {
|
|
15
|
+
name: string;
|
|
16
|
+
description?: string;
|
|
17
|
+
icon?: SVGFunc;
|
|
18
|
+
};
|
|
19
|
+
r: {
|
|
20
|
+
name: string;
|
|
21
|
+
description?: string;
|
|
22
|
+
icon?: SVGFunc;
|
|
23
|
+
};
|
|
24
|
+
n: {
|
|
25
|
+
name: string;
|
|
26
|
+
description?: string;
|
|
27
|
+
icon?: SVGFunc;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
type BaseIntersectObserverOptions = {
|
|
31
|
+
/**Deffers updating visible state for so many milliseconds
|
|
32
|
+
* this will also batch updates if they are constantly coming*/
|
|
33
|
+
deffered_visible?: number;
|
|
34
|
+
/**Deffers updating visible state for so many milliseconds
|
|
35
|
+
* this will also batch updates if they are constantly coming*/
|
|
36
|
+
deffered_hidden?: number;
|
|
37
|
+
} & IntersectionObserverInit;
|
|
38
|
+
declare class BaseIntersectObserver extends IntersectionObserver {
|
|
39
|
+
#private;
|
|
40
|
+
constructor(options: BaseIntersectObserverOptions);
|
|
41
|
+
}
|
|
42
|
+
type DataProps<T> = { [K in keyof T as T[K] extends Function ? never : K]: T[K]; };
|
|
43
|
+
type WithStateROA<T> = { [K in keyof T]?: T[K] | StateROA<T[K]>; };
|
|
44
|
+
/**Shared class for elements to extend
|
|
45
|
+
* All none abstract elements must use the define_element function to declare itself
|
|
46
|
+
*
|
|
47
|
+
* All none abstracts classes must override the static method element_name to return the name of the element
|
|
48
|
+
* Abstract classes should return @abstract@
|
|
49
|
+
*
|
|
50
|
+
* If another library defines an abstract base class, it is recommended to change the static element_name_space method to the name of the library
|
|
51
|
+
* example for this library '@chocolatelibui/core' becomes 'chocolatelibui-core'
|
|
52
|
+
* static element_name_space() { return 'chocolatelibui-core' }
|
|
53
|
+
* This resets the nametree to the library name and prevents too long element names
|
|
54
|
+
*
|
|
55
|
+
* Elements have an access propery, which builds on the html inert property
|
|
56
|
+
* Access has the following three states
|
|
57
|
+
* write = normal interaction and look
|
|
58
|
+
* read = inert attribute is added making the element uninteractable, and add opacity 0.5 to make the element look inaccessible
|
|
59
|
+
* none = adds display:none to element to make it */
|
|
60
|
+
declare abstract class Base extends HTMLElement {
|
|
61
|
+
#private;
|
|
62
|
+
/**Returns the name used to define the element, Abstract classes should return @abstract@ */
|
|
63
|
+
static element_name(): string;
|
|
64
|
+
/**Returns the namespace override for the element*/
|
|
65
|
+
static element_name_space(): string;
|
|
66
|
+
readonly is_connected: boolean;
|
|
67
|
+
/**Works when element is connected to observer, otherwise it is an alias for isConnected*/
|
|
68
|
+
readonly is_visible: boolean;
|
|
69
|
+
/**Runs when element is attached to document*/
|
|
70
|
+
protected connectedCallback(): void;
|
|
71
|
+
/**Runs when element is dettached from document*/
|
|
72
|
+
protected disconnectedCallback(): void;
|
|
73
|
+
/**Sets any attribute on the base element, to either a fixed value or a state value */
|
|
74
|
+
opts(opts: WithStateROA<DataProps<this>>): this;
|
|
75
|
+
/**Elements that can attach to a writable state can declare them in binds*/
|
|
76
|
+
bind(_opts: never): this;
|
|
77
|
+
/**Executes a function with the element as an argument and returns the element
|
|
78
|
+
* Useful when declaring multiple elements in a single statement, without easy access to a scope to execute code in*/
|
|
79
|
+
scope(fn: (elem: this) => void): this;
|
|
80
|
+
/**Returns an observer for the element */
|
|
81
|
+
intersect_observer(options?: BaseIntersectObserverOptions): BaseIntersectObserver;
|
|
82
|
+
/**Attaches the component to an observer, which is needed for the isVisible state and event to work and for the state system to work on visible*/
|
|
83
|
+
attach_to_intersect_observer(observer?: BaseIntersectObserver): this;
|
|
84
|
+
private internal_set_visible;
|
|
85
|
+
/**Overrideable function called when the element becomes visible or hidden
|
|
86
|
+
* If intersection observer is not attached it is based on connectedCallback, which is less accurate*/
|
|
87
|
+
protected on_visible(_is: boolean): void;
|
|
88
|
+
/**Returns actual size and position of the element
|
|
89
|
+
* if a resize observer is attached to the element, it will return the result of that, otherwise it will return the result of getBoundingClientRect()*/
|
|
90
|
+
get actual_size(): {
|
|
91
|
+
width: number;
|
|
92
|
+
height: number;
|
|
93
|
+
};
|
|
94
|
+
/**Attaches the component to the global resize observer */
|
|
95
|
+
attach_to_resize_observer(): this;
|
|
96
|
+
/**Dettaches the component from the global resize observer */
|
|
97
|
+
detach_from_resize_observer(): this;
|
|
98
|
+
private internal_set_size_pos;
|
|
99
|
+
/**Overrideable function called when the element is resized
|
|
100
|
+
* Only triggers when a resize observer is attached to the element, otherwise it will not trigger*/
|
|
101
|
+
protected on_resize(_rect: {
|
|
102
|
+
width: number;
|
|
103
|
+
height: number;
|
|
104
|
+
}): void;
|
|
105
|
+
/**Sets the access of the element, passing undefined is the same as passing write access*/
|
|
106
|
+
set access(access: AccessTypes);
|
|
107
|
+
/**Overrideable function called when access is changed */
|
|
108
|
+
protected on_access(_access: AccessTypes): void;
|
|
109
|
+
/**Returns the current access of the element */
|
|
110
|
+
get access(): AccessTypes;
|
|
111
|
+
/**Attaches a state to a function, so that the function is subscribed to the state when the component is connected
|
|
112
|
+
* @param visible when set true the function is only subscribed when the element is visible, this requires an observer to be attached to the element*/
|
|
113
|
+
attach_state<S extends State<any>>(state: S, func: StateInferSub<S>, visible?: boolean): typeof func;
|
|
114
|
+
/**Detaches the function from the state/component */
|
|
115
|
+
detach_state(func: StateSub<any>): typeof func;
|
|
116
|
+
/**Attaches a state to a function, so that the function is subscribed to the state when the component is connected
|
|
117
|
+
* @param visible when set true the function is only subscribed when the element is visible, this requires an observer to be attached to the element*/
|
|
118
|
+
attach_state_to_symbol<S extends State<any>>(symbol: symbol, state: S, func: StateInferSub<S>, visible?: boolean): this;
|
|
119
|
+
/**Detaches the function from the state/component */
|
|
120
|
+
detach_state_from_symbol(symbol: symbol): this;
|
|
121
|
+
/**Attaches a state to a property, so that the property is updated when the state changes
|
|
122
|
+
* @param prop the property to attach the state to
|
|
123
|
+
* @param state the state to attach to the property
|
|
124
|
+
* @param visible when set true the property is only updated when the element is visible, this requires an observer to be attached to the element*/
|
|
125
|
+
attach_state_ROA_to_prop<K extends keyof this>(prop: K, state: StateROA<this[K], any, any>, visible?: boolean): this;
|
|
126
|
+
/**Attaches a state to a property, so that the property is updated when the state changes
|
|
127
|
+
* @param prop the property to attach the state to
|
|
128
|
+
* @param state the state to attach to the property
|
|
129
|
+
* @param visible when set true the property is only updated when the element is visible, this requires an observer to be attached to the element
|
|
130
|
+
* @param fallback the fallback value for the property when the state is not ok, if undefined the property is not updated when the state is not ok*/
|
|
131
|
+
attach_state_ROA_to_prop_map<K extends keyof this, T = this[K]>(prop: K, state: StateROA<T, any, any>, map: (val: T) => Option<this[K]>, visible?: boolean): this;
|
|
132
|
+
/**Attaches a state to a property, so that the property is updated when the state changes
|
|
133
|
+
* @param prop the property to attach the state to
|
|
134
|
+
* @param state the state to attach to the property
|
|
135
|
+
* @param map_err function called when state gives a ResultErr,
|
|
136
|
+
* @param visible when set true the property is only updated when the element is visible, this requires an observer to be attached to the element*/
|
|
137
|
+
attach_state_to_prop<K extends keyof this>(prop: K, state: StateREA<this[K], any, any>, map_err: (error: string) => Option<this[K]>, visible?: boolean): this;
|
|
138
|
+
/**Attaches a state to a property, so that the property is updated when the state changes
|
|
139
|
+
* @param prop the property to attach the state to
|
|
140
|
+
* @param state the state to attach to the property
|
|
141
|
+
* @param map_err function called when state gives a ResultErr,
|
|
142
|
+
* @param map function called when state gives a ResultOk,
|
|
143
|
+
* @param visible when set true the property is only updated when the element is visible, this requires an observer to be attached to the element*/
|
|
144
|
+
attach_state_to_prop_map<K extends keyof this, T = this[K]>(prop: K, state: StateREA<T, any, any>, map_err: (error: string) => Option<this[K]>, map: (val: T) => Option<this[K]>, visible?: boolean): this;
|
|
145
|
+
/**Detaches the state from the property */
|
|
146
|
+
detach_state_from_prop<T extends keyof this>(prop: T): this;
|
|
147
|
+
/**Attaches a state to an element attribute, so that the attribute is updated when the state changes
|
|
148
|
+
* @param qualified_name the qualified name of the attribute to attach the state to
|
|
149
|
+
* @param state the state to attach to the attribute
|
|
150
|
+
* @param visible when set true the attribute is only updated when the element is visible, this requires an observer to be attached to the element*/
|
|
151
|
+
attach_state_ROA_to_attribute(qualified_name: string, state: StateROA<string, any, any>, visible?: boolean): this;
|
|
152
|
+
/**Attaches a state to an element attribute, so that the attribute is updated when the state changes
|
|
153
|
+
* @param qualified_name the qualified name of the attribute to attach the state to
|
|
154
|
+
* @param state the state to attach to the attribute
|
|
155
|
+
* @param visible when set true the attribute is only updated when the element is visible, this requires an observer to be attached to the element
|
|
156
|
+
* @param fallback the fallback value for the attribute when the state is not ok, if undefined the attribute is not updated when the state is not ok*/
|
|
157
|
+
attach_state_ROA_to_attribute_map<U>(qualified_name: string, state: StateROA<U, any, any>, map: (val: U) => Option<string>, visible?: boolean): this;
|
|
158
|
+
/**Attaches a state to an element attribute, so that the attribute is updated when the state changes
|
|
159
|
+
* @param qualified_name the qualified name of the attribute to attach the state to
|
|
160
|
+
* @param state the state to attach to the attribute
|
|
161
|
+
* @param map_err function called when state gives a ResultErr,
|
|
162
|
+
* @param visible when set true the attribute is only updated when the element is visible, this requires an observer to be attached to the element*/
|
|
163
|
+
attach_state_to_attribute(qualified_name: string, state: StateREA<string, any, any>, map_err: (error: string) => Option<string>, visible?: boolean): this;
|
|
164
|
+
/**Attaches a state to an element attribute, so that the attribute is updated when the state changes
|
|
165
|
+
* @param qualified_name the qualified name of the attribute to attach the state to
|
|
166
|
+
* @param state the state to attach to the attribute
|
|
167
|
+
* @param map_err function called when state gives a ResultErr,
|
|
168
|
+
* @param map function called when state gives a ResultOk,
|
|
169
|
+
* @param visible when set true the attribute is only updated when the element is visible, this requires an observer to be attached to the element*/
|
|
170
|
+
attach_state_to_attribute_map<U>(qualified_name: string, state: StateREA<U, any, any>, map_err: (error: string) => Option<string>, map: (val: U) => Option<string>, visible?: boolean): this;
|
|
171
|
+
/**Detaches the state from the property */
|
|
172
|
+
detach_state_from_attribute(qualified_name: string): this;
|
|
173
|
+
}
|
|
174
|
+
interface LoopOptions<T, N extends Node> {
|
|
175
|
+
change?: (element: N, new_value: T) => void;
|
|
176
|
+
destructor?: (element: N) => void;
|
|
177
|
+
}
|
|
178
|
+
declare class Loop<T, N extends Node> extends Base {
|
|
179
|
+
#private;
|
|
180
|
+
static element_name(): string;
|
|
181
|
+
static element_name_space(): string;
|
|
182
|
+
constructor(generator: (val: T) => N, options?: LoopOptions<T, N>);
|
|
183
|
+
set array(array: readonly T[]);
|
|
184
|
+
set error(err: Node);
|
|
185
|
+
}
|
|
186
|
+
declare function base_loop<T, N extends Node>(generator: (val: T) => N, options?: LoopOptions<T, N>): Loop<T, N>;
|
|
187
|
+
declare function base_loop_state(): void;
|
|
188
|
+
/**Shared svg class for elements to extend
|
|
189
|
+
* See Base for more information on how to define elements, and the element lifecycle */
|
|
190
|
+
declare abstract class BaseSVG extends Base {
|
|
191
|
+
/**Returns the name used to define the element, Abstract classes should return @abstract@ */
|
|
192
|
+
static element_name(): string;
|
|
193
|
+
/**Returns the namespace override for the element*/
|
|
194
|
+
static element_name_space(): string;
|
|
195
|
+
protected abstract default_canvas(): SVGSVGElement;
|
|
196
|
+
readonly canvas: SVGSVGElement;
|
|
197
|
+
constructor();
|
|
198
|
+
}
|
|
199
|
+
/**Gives more information about whats wrong with the given element name */
|
|
200
|
+
declare const validate_element_name: (name: string) => "Missing element name." | "Custom element names must not contain uppercase ASCII characters." | "Custom element names must contain a hyphen. Example: unicorn-cake" | "Custom element names must not start with a digit." | "Custom element names must not start with a hyphen." | "Invalid element name." | "The supplied element name is reserved and can't be used.\nSee: https://html.spec.whatwg.org/multipage/scripting.html#valid-custom-element-name" | "Unknown fault";
|
|
201
|
+
declare const set_base_element_global_namespace: (namespace: string) => void;
|
|
202
|
+
interface ElementConstructor {
|
|
203
|
+
element_name: () => string;
|
|
204
|
+
element_name_space: () => string;
|
|
205
|
+
}
|
|
206
|
+
/**Generates the base name for a custom element */
|
|
207
|
+
declare const base_element_name: (element: ElementConstructor) => string;
|
|
208
|
+
declare const ELEMENT_LIST: Set<string>;
|
|
209
|
+
/**Defines elements inheriting from the base*/
|
|
210
|
+
declare const define_element: (element: ElementConstructor) => void;
|
|
211
|
+
export { validate_element_name as a, base_loop as c, BaseIntersectObserver as d, BaseIntersectObserverOptions as f, set_base_element_global_namespace as i, base_loop_state as l, AccessTypes as m, base_element_name as n, BaseSVG as o, ACCESSTYPESINFO as p, define_element as r, Loop as s, ELEMENT_LIST as t, Base as u };
|
|
212
|
+
//# sourceMappingURL=index-BvflC2sG.d.mts.map
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import './style.css';
|
|
2
|
+
declare class SVGAttributes<T extends SVGElement> {
|
|
3
|
+
#private;
|
|
4
|
+
constructor(elem: T);
|
|
5
|
+
/**Returns the svg element */
|
|
6
|
+
get elem(): T;
|
|
7
|
+
/** Sets the stroke color of the SVG element */
|
|
8
|
+
stroke(stroke: string): this;
|
|
9
|
+
/** Sets the stroke color of the SVG element */
|
|
10
|
+
s(stroke: string): this;
|
|
11
|
+
/** Sets the fill color of the SVG element */
|
|
12
|
+
fill(fill: string): this;
|
|
13
|
+
/** Sets the fill color of the SVG element */
|
|
14
|
+
f(fill: string): this;
|
|
15
|
+
/** Sets the stroke width of the SVG element */
|
|
16
|
+
stroke_width(width: number): this;
|
|
17
|
+
/** Sets the stroke width of the SVG element */
|
|
18
|
+
sw(width: number): this;
|
|
19
|
+
/** Adds one or more class names to the SVG element */
|
|
20
|
+
class_list(...class_name: string[]): this;
|
|
21
|
+
/** Adds one or more class names to the SVG element */
|
|
22
|
+
cl(...class_name: string[]): this;
|
|
23
|
+
/** Sets an arbitrary attribute on the SVG element */
|
|
24
|
+
attribute(name: string, value: string): this;
|
|
25
|
+
/** Sets an arbitrary attribute on the SVG element */
|
|
26
|
+
a(name: string, value: string): this;
|
|
27
|
+
/** Applies a translation transform to the SVG element */
|
|
28
|
+
translate(x: number, y: number): this;
|
|
29
|
+
/** Applies a rotation transform to the SVG element */
|
|
30
|
+
rotate(angle: number, cx?: number, cy?: number): this;
|
|
31
|
+
/** Applies a scaling transform to the SVG element */
|
|
32
|
+
scale(sx: number, sy?: number): this;
|
|
33
|
+
/** Applies a skewX transform to the SVG element */
|
|
34
|
+
skewX(angle: number): this;
|
|
35
|
+
/** Applies a skewY transform to the SVG element */
|
|
36
|
+
skewY(angle: number): this;
|
|
37
|
+
/** Applies a custom transform to the SVG element */
|
|
38
|
+
transform(transform: string): this;
|
|
39
|
+
}
|
|
40
|
+
/**This creates a svg circle
|
|
41
|
+
* @param center_x x coordinate of center
|
|
42
|
+
* @param center_y y coordinate of center
|
|
43
|
+
* @param radius radius of circle*/
|
|
44
|
+
declare function circle(center_x: number, center_y: number, radius: number): SVGAttributes<SVGCircleElement>;
|
|
45
|
+
/**This draws parts of a circle/ellipse, the circle direction is reversed
|
|
46
|
+
* @param center_x the center point on the x axis
|
|
47
|
+
* @param center_y the center point on the y axis
|
|
48
|
+
* @param radius radius in x axis
|
|
49
|
+
* @param start_angle start angle in radians
|
|
50
|
+
* @param end_angle end anglein radians*/
|
|
51
|
+
declare function circle_arc(center_x: number, center_y: number, radius: number, start_angle: number, end_angle: number): SVGAttributes<SVGPathElement>;
|
|
52
|
+
/**This creates a svg ellipse
|
|
53
|
+
* @param center_x x coordinate of center
|
|
54
|
+
* @param center_y y coordinate of center
|
|
55
|
+
* @param radius_x x radius of circle
|
|
56
|
+
* @param radius_y y radius of circle*/
|
|
57
|
+
declare function ellipse(center_x: number, center_y: number, radius_x: number, radius_y: number): SVGAttributes<SVGEllipseElement>;
|
|
58
|
+
/**This draws parts of a circle/ellipse, the circle direction is reversed
|
|
59
|
+
* @param center_x the center point on the x axis
|
|
60
|
+
* @param center_y the center point on the y axis
|
|
61
|
+
* @param radius_x radius in x axis
|
|
62
|
+
* @param radius_y radius in y axis
|
|
63
|
+
* @param start_angle start angle in radians
|
|
64
|
+
* @param end_angle end anglein radians*/
|
|
65
|
+
declare function ellipse_arc(center_x: number, center_y: number, radius_x: number, radius_y: number, start_angle: number, end_angle: number): SVGAttributes<SVGPathElement>;
|
|
66
|
+
/**This draws a triangle*/
|
|
67
|
+
declare function group(): SVGAttributes<SVGGElement>;
|
|
68
|
+
/**This creates a line element
|
|
69
|
+
* @param start_x start point on x axis
|
|
70
|
+
* @param start_y start point on y axis
|
|
71
|
+
* @param end_x end point on x axis
|
|
72
|
+
* @param end_y end point on y axis*/
|
|
73
|
+
declare function line(start_x: number, start_y: number, end_x: number, end_y: number): SVGAttributes<SVGLineElement>;
|
|
74
|
+
/**This creates a path element*/
|
|
75
|
+
declare function path(path: string): SVGAttributes<SVGPathElement>;
|
|
76
|
+
/**This creates a rectangle with teh center as origin
|
|
77
|
+
* @param center_x x coordinate of center
|
|
78
|
+
* @param center_y y coordinate of center
|
|
79
|
+
* @param width width
|
|
80
|
+
* @param height height
|
|
81
|
+
* @param corner_radius radius of corner*/
|
|
82
|
+
declare function rectangle_from_center(center_x: number, center_y: number, width: number, height: number, corner_radius: number): SVGAttributes<SVGRectElement>;
|
|
83
|
+
/**This creates a rectangle with teh center as origin
|
|
84
|
+
* @param start_x x coordinate of center
|
|
85
|
+
* @param start_y y coordinate of center
|
|
86
|
+
* @param width width
|
|
87
|
+
* @param height height
|
|
88
|
+
* @param corner_radius radius of corner*/
|
|
89
|
+
declare function rectangle_from_corner(start_x: number, start_y: number, width: number, height: number, corner_radius: number): SVGAttributes<SVGRectElement>;
|
|
90
|
+
type SVGElements = {
|
|
91
|
+
ellipse: SVGEllipseElement;
|
|
92
|
+
circle: SVGCircleElement;
|
|
93
|
+
path: SVGPathElement;
|
|
94
|
+
line: SVGLineElement;
|
|
95
|
+
rect: SVGRectElement;
|
|
96
|
+
text: SVGTextElement;
|
|
97
|
+
g: SVGGElement;
|
|
98
|
+
svg: SVGSVGElement;
|
|
99
|
+
foreignObject: SVGForeignObjectElement;
|
|
100
|
+
};
|
|
101
|
+
declare function create_svg_element<K extends keyof SVGElements>(name: K): SVGAttributes<SVGElements[K]>;
|
|
102
|
+
/** This returns an empty svg element
|
|
103
|
+
* @param width width of svg
|
|
104
|
+
* @param height height of svg
|
|
105
|
+
* @param viewbox viewbox of svg*/
|
|
106
|
+
declare function svg$1(width: number, height: number, viewbox?: string): SVGAttributes<SVGSVGElement>;
|
|
107
|
+
declare const SVGAnchorPoint: {
|
|
108
|
+
readonly bottomLeft: 0;
|
|
109
|
+
readonly middleLeft: 1;
|
|
110
|
+
readonly topLeft: 2;
|
|
111
|
+
readonly topCenter: 3;
|
|
112
|
+
readonly topRight: 4;
|
|
113
|
+
readonly middleRight: 5;
|
|
114
|
+
readonly bottomRight: 6;
|
|
115
|
+
readonly bottomCenter: 7;
|
|
116
|
+
readonly middleCenter: 8;
|
|
117
|
+
};
|
|
118
|
+
type SVGAnchorPoint = (typeof SVGAnchorPoint)[keyof typeof SVGAnchorPoint];
|
|
119
|
+
/**Creates a text nodes for an svg
|
|
120
|
+
* @param x x coordinate of text
|
|
121
|
+
* @param y y coordinate of text
|
|
122
|
+
* @param text text
|
|
123
|
+
* @param size size of text in px
|
|
124
|
+
* @param anchor anchor point of text*/
|
|
125
|
+
declare function text(x: number, y: number, text: string, size: number, anchor: SVGAnchorPoint): SVGAttributes<SVGTextElement>;
|
|
126
|
+
/**Creates a text nodes for an svg
|
|
127
|
+
* @param x x coordinate of text
|
|
128
|
+
* @param y y coordinate of text
|
|
129
|
+
* @param width width of text
|
|
130
|
+
* @param height height of text
|
|
131
|
+
* @param text text
|
|
132
|
+
* @param size size of text in px
|
|
133
|
+
* @param anchor anchor point of */
|
|
134
|
+
declare function multi_line_text(x: number, y: number, width: number, height: number, text: string, size: number, anchor: SVGAnchorPoint): SVGAttributes<SVGForeignObjectElement>;
|
|
135
|
+
/**This draws a triangle
|
|
136
|
+
* @param center_x x coordinate of center
|
|
137
|
+
* @param center_y y coordinate of center
|
|
138
|
+
* @param width width
|
|
139
|
+
* @param height height*/
|
|
140
|
+
declare function isosceles_triangle(center_x: number, center_y: number, width: number, height: number): SVGAttributes<SVGPathElement>;
|
|
141
|
+
declare const svg: {
|
|
142
|
+
create: typeof create_svg_element;
|
|
143
|
+
attr: (elem: SVGElement) => SVGAttributes<SVGElement>;
|
|
144
|
+
circle: typeof circle;
|
|
145
|
+
circle_arc: typeof circle_arc;
|
|
146
|
+
ellipse: typeof ellipse;
|
|
147
|
+
ellipse_arc: typeof ellipse_arc;
|
|
148
|
+
group: typeof group;
|
|
149
|
+
line: typeof line;
|
|
150
|
+
path: typeof path;
|
|
151
|
+
rectangle_from_center: typeof rectangle_from_center;
|
|
152
|
+
rectangle_from_corner: typeof rectangle_from_corner;
|
|
153
|
+
svg: typeof svg$1;
|
|
154
|
+
text: typeof text;
|
|
155
|
+
multi_line_text: typeof multi_line_text;
|
|
156
|
+
isosceles_triangle: typeof isosceles_triangle;
|
|
157
|
+
angle_to_anchor_point: (angle: number) => 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7;
|
|
158
|
+
};
|
|
159
|
+
type SVGFunc = () => SVGSVGElement;
|
|
160
|
+
declare global {
|
|
161
|
+
/**Types enum icons in @chocbite/ts-lib state as SVGFunc*/
|
|
162
|
+
interface ChocbiteStateRegister {
|
|
163
|
+
icon: SVGFunc;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
export { svg as n, SVGAnchorPoint as r, SVGFunc as t };
|
|
167
|
+
//# sourceMappingURL=index-CWQ5KhrP.d.mts.map
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import './style.css';
|
|
2
|
+
import { d as BaseIntersectObserver, u as Base } from "./index-BvflC2sG.mjs";
|
|
3
|
+
import { t as SVGFunc } from "./index-CWQ5KhrP.mjs";
|
|
4
|
+
import { n as ContextMenu } from "./index-Cx6QmIC-.mjs";
|
|
5
|
+
import { State } from "@chocbite/ts-lib/state";
|
|
6
|
+
import { Option } from "@chocbite/ts-lib/result";
|
|
7
|
+
declare abstract class ListField extends Base {
|
|
8
|
+
static element_name(): string;
|
|
9
|
+
static element_name_space(): string;
|
|
10
|
+
constructor();
|
|
11
|
+
}
|
|
12
|
+
declare class ListTextField extends ListField {
|
|
13
|
+
static element_name(): string;
|
|
14
|
+
set text(value: string);
|
|
15
|
+
}
|
|
16
|
+
declare function text_field(): ListTextField;
|
|
17
|
+
declare class ListNumberField extends ListField {
|
|
18
|
+
static element_name(): string;
|
|
19
|
+
set number(value: number);
|
|
20
|
+
}
|
|
21
|
+
declare function number_field(): ListNumberField;
|
|
22
|
+
declare class ListNodeField<T extends Node> extends ListField {
|
|
23
|
+
static element_name(): string;
|
|
24
|
+
constructor(node: T);
|
|
25
|
+
set node(node: T);
|
|
26
|
+
get node(): T;
|
|
27
|
+
}
|
|
28
|
+
declare function node_field<T extends Node>(node: T): ListNodeField<T>;
|
|
29
|
+
interface ListKeyFieldOptions {
|
|
30
|
+
icon?: SVGFunc | State<SVGFunc>;
|
|
31
|
+
}
|
|
32
|
+
type ListSubRows<R> = () => R[] | State<R[]>;
|
|
33
|
+
interface ListRowOptions<R, T extends {}, S extends boolean> {
|
|
34
|
+
opened?: boolean;
|
|
35
|
+
openable?: boolean | State<boolean>;
|
|
36
|
+
key_field?: ListKeyFieldOptions;
|
|
37
|
+
sub_rows?: S extends true ? ListSubRows<R> : never;
|
|
38
|
+
add_row?: ListAddRowOptions;
|
|
39
|
+
context_menu?: ContextMenu | (() => Option<ContextMenu>);
|
|
40
|
+
values: T;
|
|
41
|
+
}
|
|
42
|
+
declare class ListRow<R, T extends {}, A extends ListType<R>, S extends boolean> extends Base implements ListRowParent<A> {
|
|
43
|
+
#private;
|
|
44
|
+
static element_name(): string;
|
|
45
|
+
static element_name_space(): string;
|
|
46
|
+
readonly depth: number;
|
|
47
|
+
state: A;
|
|
48
|
+
constructor(root: ListRoot<R, T, A, S>, parent: ListRowParent<A>, data: R);
|
|
49
|
+
select_adjacent(direction: "next" | "previous" | "p_next" | "p_previous" | "last", field: Option<number>): void;
|
|
50
|
+
set data(data: R);
|
|
51
|
+
set add_row(options: ListAddRowOptions | undefined);
|
|
52
|
+
set openable(value: boolean);
|
|
53
|
+
get openable(): boolean;
|
|
54
|
+
set open(open: boolean);
|
|
55
|
+
get open(): boolean;
|
|
56
|
+
get index(): number;
|
|
57
|
+
amount_rows(rec?: boolean): number;
|
|
58
|
+
set rows(rows: R[] | State<R[]>);
|
|
59
|
+
}
|
|
60
|
+
type ListType<R> = R[] | State<R[]>;
|
|
61
|
+
type ListTypeExtract<A extends ListType<any>> = A extends (infer U)[] ? U : A extends State<(infer U)[]> ? U : never;
|
|
62
|
+
declare const ListDataType: {
|
|
63
|
+
readonly number: "number";
|
|
64
|
+
readonly string: "string";
|
|
65
|
+
readonly bool: "bool";
|
|
66
|
+
};
|
|
67
|
+
type ListDataType = (typeof ListDataType)[keyof typeof ListDataType];
|
|
68
|
+
interface ListColumnOptions<V, C extends ListField> {
|
|
69
|
+
/**Initial width of the column in rem, auto when undefined*/
|
|
70
|
+
init_width?: number;
|
|
71
|
+
/**If the column has a fixed width in rem, overrides init_width and disables resizing*/
|
|
72
|
+
fixed_width?: number | "min" | "max";
|
|
73
|
+
/**Initial order of the column, lower numbers appear first, will order by column object if undefined*/
|
|
74
|
+
order?: number;
|
|
75
|
+
/**Whether the column is reorderable by the user*/
|
|
76
|
+
reorderable?: boolean;
|
|
77
|
+
/**Data type of the column, used for sorting, will attempt auto detect if undefined*/
|
|
78
|
+
type?: ListDataType;
|
|
79
|
+
/**Column title*/
|
|
80
|
+
title: string;
|
|
81
|
+
/**Generates the field element, only called during row or column creation */
|
|
82
|
+
field_gen(): C;
|
|
83
|
+
/**Applies the value to the field */
|
|
84
|
+
field_apply(field: C, value: V): void;
|
|
85
|
+
}
|
|
86
|
+
/**Helper to create a column object */
|
|
87
|
+
declare function column<V, C extends ListField>(options: ListColumnOptions<V, C>): ListColumnOptions<V, C>;
|
|
88
|
+
/**Special helper to create a string value column */
|
|
89
|
+
declare function column_string(
|
|
90
|
+
/**Column title*/
|
|
91
|
+
title: string): ListColumnOptions<string, ListTextField>;
|
|
92
|
+
type ListRowTransformer<R, T extends {}, A extends ListType<any>, S extends boolean> = (
|
|
93
|
+
/**Test */
|
|
94
|
+
data: R, row: ListRow<R, T, A, S>, state: A) => ListRowOptions<R, T, S>;
|
|
95
|
+
interface ListRoot<R, T extends {}, A extends ListType<any>, S extends boolean> {
|
|
96
|
+
/**Sub rows */
|
|
97
|
+
readonly sub_rows: S;
|
|
98
|
+
/**Columns options mapped by column key */
|
|
99
|
+
readonly columns: Map<keyof T, ListColumnOptions<T[keyof T], ListField>>;
|
|
100
|
+
/**Order of visible columns by column key */
|
|
101
|
+
columns_visible: (keyof T)[];
|
|
102
|
+
/**Function to transform a row data into row options */
|
|
103
|
+
transform: ListRowTransformer<R, T, A, S>;
|
|
104
|
+
/**Observer for the container if observer is active */
|
|
105
|
+
observer?: BaseIntersectObserver;
|
|
106
|
+
}
|
|
107
|
+
interface ListRowParent<A extends ListType<any>> {
|
|
108
|
+
/**Sub row depth */
|
|
109
|
+
readonly depth: number;
|
|
110
|
+
/**Whether the row is open to show sub rows */
|
|
111
|
+
open: boolean;
|
|
112
|
+
/**Selects the adjacent row in the given direction */
|
|
113
|
+
select_adjacent(direction: "next" | "previous" | "p_next" | "p_previous" | "last", field: Option<number>): void;
|
|
114
|
+
/**State associated with the row parent, if state is used */
|
|
115
|
+
state: A;
|
|
116
|
+
}
|
|
117
|
+
interface ListAddRowOptions {
|
|
118
|
+
text: string | State<string>;
|
|
119
|
+
disabled?: boolean | State<boolean>;
|
|
120
|
+
icon?: SVGFunc | State<SVGFunc>;
|
|
121
|
+
on_add: () => void;
|
|
122
|
+
}
|
|
123
|
+
interface ContainerOptions<S extends boolean = false> {
|
|
124
|
+
/**Should header row be omitted */
|
|
125
|
+
headless?: boolean;
|
|
126
|
+
/**Can rows have sub rows */
|
|
127
|
+
sub_rows?: S;
|
|
128
|
+
/**Options for an add row button */
|
|
129
|
+
add_row?: ListAddRowOptions;
|
|
130
|
+
/**If list should use a container to give fields the option of attach/detach to states when visible */
|
|
131
|
+
observer?: BaseIntersectObserver;
|
|
132
|
+
}
|
|
133
|
+
declare class Container<A extends ListType<any>, T extends {
|
|
134
|
+
[key: string]: ListColumnOptions<any, any>;
|
|
135
|
+
}, S extends boolean = false, R = ListTypeExtract<A>> extends Base {
|
|
136
|
+
#private;
|
|
137
|
+
static element_name(): string;
|
|
138
|
+
static element_name_space(): string;
|
|
139
|
+
constructor(columns: { [K in keyof T]: ListColumnOptions<T[K], any>; }, transform: ListRowTransformer<R, T, A, S>, rows: A, options?: ContainerOptions<S>);
|
|
140
|
+
set columns(columns: { [K in keyof T]: ListColumnOptions<T[K], any>; });
|
|
141
|
+
set add_row(options: ListAddRowOptions | undefined);
|
|
142
|
+
amount_rows(rec?: boolean): number;
|
|
143
|
+
set rows(rows: R[] | State<R[]>);
|
|
144
|
+
}
|
|
145
|
+
declare function container<A extends ListType<any>, T extends {}, S extends boolean = false, R = ListTypeExtract<A>>(columns: { [K in keyof T]: ListColumnOptions<T[K], any>; }, transform: ListRowTransformer<R, NoInfer<T>, A, S>, rows: A, options?: ContainerOptions<S>): Container<A, T, S, R>;
|
|
146
|
+
declare const list: {
|
|
147
|
+
column: typeof column;
|
|
148
|
+
column_string: typeof column_string;
|
|
149
|
+
container: typeof container;
|
|
150
|
+
text_field: typeof text_field;
|
|
151
|
+
number_field: typeof number_field;
|
|
152
|
+
node_field: typeof node_field;
|
|
153
|
+
};
|
|
154
|
+
export { ListField as n, list as t };
|
|
155
|
+
//# sourceMappingURL=index-CdiJN7JF.d.mts.map
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import './style.css';
|
|
2
|
+
import { u as Base } from "./index-BvflC2sG.mjs";
|
|
3
|
+
import { Option } from "@chocbite/ts-lib/result";
|
|
4
|
+
interface ContextMenuLine {}
|
|
5
|
+
declare abstract class MenuLine extends Base implements ContextMenuLine {
|
|
6
|
+
/**Returns the name used to define the element */
|
|
7
|
+
static element_name(): string;
|
|
8
|
+
/**Returns the namespace override for the element*/
|
|
9
|
+
static element_name_space(): string;
|
|
10
|
+
abstract do_focus(dir?: boolean): void;
|
|
11
|
+
/**Changes focus to the next line
|
|
12
|
+
* @param direction false is next sibling, true is previous */
|
|
13
|
+
focus_next(direction?: boolean): void;
|
|
14
|
+
}
|
|
15
|
+
interface ContextMenuDevider extends ContextMenuLine {}
|
|
16
|
+
declare function context_devider(): ContextMenuDevider;
|
|
17
|
+
interface ContextMenuSub extends ContextMenuLine {}
|
|
18
|
+
declare class MenuSub extends MenuLine implements ContextMenuSub {
|
|
19
|
+
#private;
|
|
20
|
+
/**Returns the name used to define the element */
|
|
21
|
+
static element_name(): string;
|
|
22
|
+
constructor(text: string, menu: ContextMenu, icon?: SVGSVGElement);
|
|
23
|
+
/**Opens the sub menu */
|
|
24
|
+
open(): void;
|
|
25
|
+
do_focus(): void;
|
|
26
|
+
/**Closes menu by calling parent*/
|
|
27
|
+
close(): void;
|
|
28
|
+
/**Closes the context menu down the tree*/
|
|
29
|
+
close_down(): void;
|
|
30
|
+
/**Closes the context menu up the tree to the root*/
|
|
31
|
+
close_up(): void;
|
|
32
|
+
}
|
|
33
|
+
declare function context_sub(text: string, menu: ContextMenu, icon?: SVGSVGElement): ContextMenuSub;
|
|
34
|
+
type ContextMenuLines = ContextMenuLine[];
|
|
35
|
+
declare class ContextMenu extends Base {
|
|
36
|
+
#private;
|
|
37
|
+
/**Returns the name used to define the element */
|
|
38
|
+
static element_name(): string;
|
|
39
|
+
/**Returns the namespace override for the element*/
|
|
40
|
+
static element_name_space(): string;
|
|
41
|
+
container: Container | undefined;
|
|
42
|
+
readonly submenu: MenuSub | undefined;
|
|
43
|
+
constructor(lines: ((ContextMenuLine | undefined)[] | Promise<(ContextMenuLine | undefined)[]>) | (() => (ContextMenuLine | undefined)[] | Promise<(ContextMenuLine | undefined)[]>));
|
|
44
|
+
protected connectedCallback(): void;
|
|
45
|
+
protected disconnectedCallback(): void;
|
|
46
|
+
/**Sets the lines of the context menu */
|
|
47
|
+
set lines(lines: (ContextMenuLine | undefined)[]);
|
|
48
|
+
/**Changes focus to the next line
|
|
49
|
+
* @param direction false is first child, true is last child */
|
|
50
|
+
focus_next(direction: boolean): void;
|
|
51
|
+
set closer(closer: boolean);
|
|
52
|
+
/**Sets the context menu to fullscreen mode in x directino */
|
|
53
|
+
set fullscreenx(full: boolean);
|
|
54
|
+
/**Sets the context menu to fullscreen mode in y direction */
|
|
55
|
+
set fullscreeny(full: boolean);
|
|
56
|
+
/**Closes the context menu down the tree*/
|
|
57
|
+
close_down(): void;
|
|
58
|
+
/**Closes the context menu up the tree to the root*/
|
|
59
|
+
close_up(): void;
|
|
60
|
+
/**Updates the position of the menu
|
|
61
|
+
* @param x x coordinate for menu, this will be ignored if needed for contextmenu to fit
|
|
62
|
+
* @param y y coordinate for menu, this will be ignored if needed for contextmenu to fit
|
|
63
|
+
* @param element element to use instead of coordinates, the contextemenu will avoid covering the element if possible*/
|
|
64
|
+
set_position(x?: number, y?: number, element?: Element): void;
|
|
65
|
+
}
|
|
66
|
+
declare function context_menu(lines: ((ContextMenuLine | undefined)[] | Promise<(ContextMenuLine | undefined)[]>) | (() => (ContextMenuLine | undefined)[]) | (() => Promise<(ContextMenuLine | undefined)[]>)): ContextMenu;
|
|
67
|
+
declare class Container extends Base {
|
|
68
|
+
#private;
|
|
69
|
+
/**Returns the name used to define the element */
|
|
70
|
+
static element_name(): string;
|
|
71
|
+
/**Returns the namespace override for the element*/
|
|
72
|
+
static element_name_space(): string;
|
|
73
|
+
constructor();
|
|
74
|
+
/**Attaches a menu to the container */
|
|
75
|
+
attach_menu(menu: ContextMenu): ContextMenu;
|
|
76
|
+
/**Closes open context menu */
|
|
77
|
+
close_up(): void;
|
|
78
|
+
}
|
|
79
|
+
declare const CONTEXT_MENY_SYMBOL: unique symbol;
|
|
80
|
+
declare global {
|
|
81
|
+
interface Document {
|
|
82
|
+
[CONTEXT_MENY_SYMBOL]: Container | undefined;
|
|
83
|
+
}
|
|
84
|
+
interface Element {
|
|
85
|
+
[CONTEXT_MENY_SYMBOL]: EventListenerOrEventListenerObject | undefined;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/**Attaches a context menu to the given element
|
|
89
|
+
* @param element the element to attach the context menu to
|
|
90
|
+
* @param lines the context menu to attach, if a function is given it will be called when the context menu is summoned
|
|
91
|
+
* @param block a function that returns true if the context menu should not be summoned, if undefined the context menu will always be summoned*/
|
|
92
|
+
declare function context_menu_attach(element: Element, lines: ContextMenu | (() => Option<ContextMenu>), block?: () => boolean): void;
|
|
93
|
+
/**Dettaches the context menu from the given element */
|
|
94
|
+
declare function context_menu_detach(element: Element): void;
|
|
95
|
+
/**Summons a context menu at a given location
|
|
96
|
+
* @param menu the context menu to summon
|
|
97
|
+
* @param element the element the context menu is referenced to, if undefined the context menu will appear in the main document
|
|
98
|
+
* @param x x position for context menu, if undefined, will use element middle, if element undefined, will put context menu in the top left corner of the screen
|
|
99
|
+
* @param y y position for context menu, if undefined, will use element middle, if element undefined, will put context menu in the top left corner of the screen
|
|
100
|
+
* @param dont_cover when set true */
|
|
101
|
+
declare function context_menu_summon(menu: ContextMenu, element?: Element, x?: number, y?: number, dont_cover?: boolean): void;
|
|
102
|
+
/**Sets the default context menu for the page, the one used if no other context menu has been attached to the element
|
|
103
|
+
* If set to a boolean the operating system context menu is disabled and nothing will appear
|
|
104
|
+
* If set undefined the operating systems context menu will be used*/
|
|
105
|
+
declare function context_menu_default(lines: (ContextMenu | (() => Option<ContextMenu>)) | false): void;
|
|
106
|
+
interface ContextMenuOption extends ContextMenuLine {}
|
|
107
|
+
declare function context_line(text: string, func: () => void, icon?: SVGSVGElement, shortcut?: string, checkmark?: boolean): ContextMenuOption;
|
|
108
|
+
declare const ctm: {
|
|
109
|
+
attach: typeof context_menu_attach;
|
|
110
|
+
default: typeof context_menu_default;
|
|
111
|
+
detach: typeof context_menu_detach;
|
|
112
|
+
summon: typeof context_menu_summon;
|
|
113
|
+
has(element: Element): boolean;
|
|
114
|
+
menu: typeof context_menu;
|
|
115
|
+
line: typeof context_line;
|
|
116
|
+
sub: typeof context_sub;
|
|
117
|
+
devider: typeof context_devider;
|
|
118
|
+
};
|
|
119
|
+
export { ContextMenu as n, ContextMenuLines as r, ctm as t };
|
|
120
|
+
//# sourceMappingURL=index-Cx6QmIC-.d.mts.map
|