@chocbite/ts-lib-ui 1.0.6 → 1.1.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/AGENTS.md +164 -3
- package/SOURCE.md +2000 -268
- package/base/index.d.mts +1 -1
- package/base/index.mjs +7 -7
- package/base/index.mjs.map +1 -1
- package/canvas/index.d.mts +1 -1
- package/canvas/index.mjs +8 -8
- package/canvas/index.mjs.map +1 -1
- package/context-menu/index.d.mts +2 -2
- package/context-menu/index.mjs +1 -1
- package/{context-menu-Bo8R6DmK.mjs → context-menu-DE3EUtY8.mjs} +149 -111
- package/context-menu-DE3EUtY8.mjs.map +1 -0
- package/document/index.mjs +1 -1
- package/document/index.mjs.map +1 -1
- package/dom/index.mjs +1 -1
- package/dom/index.mjs.map +1 -1
- package/form/index.d.mts +6 -5
- package/form/index.mjs +30 -29
- 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 → icons-B88i-7MC.mjs} +2 -2
- package/{index-ClIBfrHy.d.mts → index-BDWg5GX2.d.mts} +2 -2
- package/{index-ClfL2SQR.d.mts → index-CvzH3M_5.d.mts} +2 -2
- package/index-Cw4AcuUl.d.mts +371 -0
- package/{index-Pr2sLv9e.d.mts → index-YNZjMIO7.d.mts} +33 -17
- package/keyboard/index.d.mts +1 -1
- package/keyboard/index.mjs +12 -12
- package/keyboard/index.mjs.map +1 -1
- package/list/index.d.mts +2 -2
- package/list/index.mjs +1 -1
- package/list-D08epOjk.mjs +1566 -0
- package/list-D08epOjk.mjs.map +1 -0
- package/package.json +5 -80
- package/selection/index.mjs +1 -1
- package/selection/index.mjs.map +1 -1
- package/settings/index.mjs +1 -1
- package/settings/index.mjs.map +1 -1
- package/spinner/index.d.mts +1 -1
- package/spinner/index.mjs +3 -3
- package/spinner/index.mjs.map +1 -1
- package/state_ui/index.mjs +1 -1
- package/{state_ui-Bm3TeKNL.mjs → state_ui-Dtm2y5RU.mjs} +3 -3
- package/state_ui-Dtm2y5RU.mjs.map +1 -0
- package/style.css +307 -63
- package/svg/index.d.mts +1 -1
- package/svg/index.mjs +1 -1
- package/{svg-1bp-yIPC.mjs → svg-Yz7elqnU.mjs} +16 -16
- package/svg-Yz7elqnU.mjs.map +1 -0
- package/test/index.d.mts +1 -1
- package/test/index.mjs +1 -1
- package/test/index.mjs.map +1 -1
- package/theme/index.d.mts +1 -1
- package/theme/index.mjs +1 -1
- package/{theme-DgVtLDzP.mjs → theme-BJS5z1iW.mjs} +9 -9
- package/theme-BJS5z1iW.mjs.map +1 -0
- package/context-menu-Bo8R6DmK.mjs.map +0 -1
- package/index-BTUFkF9s.d.mts +0 -173
- package/list-DOXIQOEY.mjs +0 -715
- package/list-DOXIQOEY.mjs.map +0 -1
- package/state_ui-Bm3TeKNL.mjs.map +0 -1
- package/svg-1bp-yIPC.mjs.map +0 -1
- package/theme-DgVtLDzP.mjs.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "./style.css";
|
|
2
2
|
import { node_clone } from "./dom/index.mjs";
|
|
3
|
-
//
|
|
3
|
+
// icons/shared.ts
|
|
4
4
|
/*#__NO_SIDE_EFFECTS__*/
|
|
5
5
|
function generate_function(name, icon) {
|
|
6
6
|
let svg;
|
|
@@ -13,7 +13,7 @@ function generate_function(name, icon) {
|
|
|
13
13
|
}
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
|
-
//
|
|
16
|
+
// icons/material/material-symbols-rounded.ts
|
|
17
17
|
const material_10k_rounded = /* @__PURE__ */ generate_function("material_10k_rounded", "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24\" viewBox=\"0 -960 960 960\" width=\"24\"><path d=\"M240-540v150q0 13 8.5 21.5T270-360q13 0 21.5-8.5T300-390v-180q0-13-8.5-21.5T270-600h-40q-13 0-21.5 8.5T200-570q0 13 8.5 21.5T230-540h10Zm140 180h100q17 0 28.5-11.5T520-400v-160q0-17-11.5-28.5T480-600H380q-17 0-28.5 11.5T340-560v160q0 17 11.5 28.5T380-360Zm20-60v-120h60v120h-60Zm217-30 61 79q2 3 23 11 18 0 26-16.5t-3-30.5l-57-73 57-74q11-14 3-30t-26-16q-7 0-13 3t-10 8l-61 79v-60q0-13-8.5-21.5T587-600q-13 0-21.5 8.5T557-570v180q0 13 8.5 21.5T587-360q13 0 21.5-8.5T617-390v-60ZM200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560H200v560Zm0-560v560-560Z\"/></svg>");
|
|
18
18
|
const material_10mp_rounded = /* @__PURE__ */ generate_function("material_10mp_rounded", "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24\" viewBox=\"0 -960 960 960\" width=\"24\"><path d=\"M340-680v150q0 13 8.5 21.5T370-500q13 0 21.5-8.5T400-530v-180q0-13-8.5-21.5T370-740h-60q-13 0-21.5 8.5T280-710q0 13 8.5 21.5T310-680h30Zm180 180h100q17 0 28.5-11.5T660-540v-160q0-17-11.5-28.5T620-740H520q-17 0-28.5 11.5T480-700v160q0 17 11.5 28.5T520-500Zm20-60v-120h60v120h-60ZM200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560H200v560Zm0-560v560-560Zm100 360h40v90q0 13 8.5 21.5T370-280q13 0 21.5-8.5T400-310v-90h40v150q0 13 8.5 21.5T470-220q13 0 21.5-8.5T500-250v-170q0-17-11.5-28.5T460-460H280q-17 0-28.5 11.5T240-420v170q0 13 8.5 21.5T270-220q13 0 21.5-8.5T300-250v-150Zm300 120h80q17 0 28.5-11.5T720-320v-100q0-17-11.5-28.5T680-460H570q-13 0-21.5 8.5T540-430v180q0 13 8.5 21.5T570-220q13 0 21.5-8.5T600-250v-30Zm0-60v-60h60v60h-60Z\"/></svg>");
|
|
19
19
|
const material_11mp_rounded = /* @__PURE__ */ generate_function("material_11mp_rounded", "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24\" viewBox=\"0 -960 960 960\" width=\"24\"><path d=\"M380-680v150q0 13 8.5 21.5T410-500q13 0 21.5-8.5T440-530v-180q0-13-8.5-21.5T410-740h-60q-13 0-21.5 8.5T320-710q0 13 8.5 21.5T350-680h30Zm200 0v150q0 13 8.5 21.5T610-500q13 0 21.5-8.5T640-530v-180q0-13-8.5-21.5T610-740h-60q-13 0-21.5 8.5T520-710q0 13 8.5 21.5T550-680h30ZM200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560H200v560Zm0-560v560-560Zm100 360h40v90q0 13 8.5 21.5T370-280q13 0 21.5-8.5T400-310v-90h40v150q0 13 8.5 21.5T470-220q13 0 21.5-8.5T500-250v-170q0-17-11.5-28.5T460-460H280q-17 0-28.5 11.5T240-420v170q0 13 8.5 21.5T270-220q13 0 21.5-8.5T300-250v-150Zm300 120h80q17 0 28.5-11.5T720-320v-100q0-17-11.5-28.5T680-460H570q-13 0-21.5 8.5T540-430v180q0 13 8.5 21.5T570-220q13 0 21.5-8.5T600-250v-30Zm0-60v-60h60v60h-60Z\"/></svg>");
|
|
@@ -143,7 +143,7 @@ declare const svg: {
|
|
|
143
143
|
text: typeof text;
|
|
144
144
|
multi_line_text: typeof multi_line_text;
|
|
145
145
|
isosceles_triangle: typeof isosceles_triangle;
|
|
146
|
-
angle_to_anchor_point: (angle: number) => 0 |
|
|
146
|
+
angle_to_anchor_point: (angle: number) => 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7;
|
|
147
147
|
};
|
|
148
148
|
type SVGFunc = () => SVGSVGElement;
|
|
149
149
|
declare global {
|
|
@@ -153,4 +153,4 @@ declare global {
|
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
155
|
export { svg as n, SVGAnchorPoint as r, SVGFunc as t };
|
|
156
|
-
//# sourceMappingURL=index-
|
|
156
|
+
//# sourceMappingURL=index-BDWg5GX2.d.mts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import './style.css';
|
|
2
|
-
import { t as SVGFunc } from "./index-
|
|
2
|
+
import { t as SVGFunc } from "./index-BDWg5GX2.mjs";
|
|
3
3
|
import { State, StateInferSub, StateREA, StateROA, StateSub } from "@chocbite/ts-lib/state";
|
|
4
4
|
import { Option } from "@chocbite/ts-lib/result";
|
|
5
5
|
/**Enum of possible access types for base element*/
|
|
@@ -216,4 +216,4 @@ declare const ELEMENT_LIST: Set<string>;
|
|
|
216
216
|
/**Defines elements inheriting from the base*/
|
|
217
217
|
declare const define_element: (element: ElementConstructor) => void;
|
|
218
218
|
export { validate_element_name as a, base_loop as c, BaseIntersectObserverOptions as d, ACCESSTYPESINFO as f, set_base_element_global_namespace as i, Base as l, base_element_name as n, BaseSVG as o, AccessTypes as p, define_element as r, Loop as s, ELEMENT_LIST as t, BaseIntersectObserver as u };
|
|
219
|
-
//# sourceMappingURL=index-
|
|
219
|
+
//# sourceMappingURL=index-CvzH3M_5.d.mts.map
|
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
import './style.css';
|
|
2
|
+
import { l as Base, u as BaseIntersectObserver } from "./index-CvzH3M_5.mjs";
|
|
3
|
+
import { t as SVGFunc } from "./index-BDWg5GX2.mjs";
|
|
4
|
+
import { r as ContextMenu } from "./index-YNZjMIO7.mjs";
|
|
5
|
+
import { State, StateREAW } from "@chocbite/ts-lib/state";
|
|
6
|
+
import { Option, Result } 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
|
+
/**Shows why a write of the list failed as the validation message of the browser, at the row it is about, like the form elements do
|
|
30
|
+
* One hidden input in the container is placed over the row before the message is shown, it clears after 5 seconds */
|
|
31
|
+
declare class ListWarn {
|
|
32
|
+
#private;
|
|
33
|
+
constructor(container: HTMLElement);
|
|
34
|
+
/**Shows the message at the element, or at the top of the list without element
|
|
35
|
+
* @param at element to point at, rows are display contents, so give one of their cells */
|
|
36
|
+
show(at: Element | undefined, message: string): void;
|
|
37
|
+
}
|
|
38
|
+
/**What moving needs from a row */
|
|
39
|
+
interface ListMovableRow extends HTMLElement {
|
|
40
|
+
readonly data: unknown;
|
|
41
|
+
/**Moving of the list the row is in */
|
|
42
|
+
readonly reorder: object | undefined;
|
|
43
|
+
readonly parent_rows: unknown;
|
|
44
|
+
readonly parent_row: ListMovableRow | undefined;
|
|
45
|
+
readonly next_row: ListMovableRow | undefined;
|
|
46
|
+
readonly first_sub_row: ListMovableRow | undefined;
|
|
47
|
+
readonly movable: boolean;
|
|
48
|
+
readonly droppable: boolean;
|
|
49
|
+
readonly selected: boolean;
|
|
50
|
+
readonly multi_selected: boolean;
|
|
51
|
+
readonly label: string;
|
|
52
|
+
readonly anchor: Element | undefined;
|
|
53
|
+
readonly index: number;
|
|
54
|
+
readonly openable: boolean;
|
|
55
|
+
open: boolean;
|
|
56
|
+
drop_rows(): unknown;
|
|
57
|
+
focus_cell(): void;
|
|
58
|
+
}
|
|
59
|
+
type AnyRow = ListMovableRow;
|
|
60
|
+
/**Lists that rows can be dragged between, rows are given from one list to another of the same group
|
|
61
|
+
* The type is checked both ways, so only lists with exactly the same row type can join */
|
|
62
|
+
declare class ListDragGroup<R> {
|
|
63
|
+
readonly type: (value: R) => R;
|
|
64
|
+
}
|
|
65
|
+
/**Where rows are dropped, given to can_drop */
|
|
66
|
+
interface ListDropTarget<R> {
|
|
67
|
+
/**Row the rows become sub rows of, undefined for the top level */
|
|
68
|
+
parent: R | undefined;
|
|
69
|
+
/**List the rows are dropped in */
|
|
70
|
+
list: HTMLElement;
|
|
71
|
+
}
|
|
72
|
+
interface ListReorderOptions<R> {
|
|
73
|
+
/**Lists of the same group can give rows to each other, without a group rows only move inside the list */
|
|
74
|
+
group?: ListDragGroup<R>;
|
|
75
|
+
/**Whether the row data can be dropped at the target, all dropped rows must be allowed for a drop */
|
|
76
|
+
can_drop?(data: R, target: ListDropTarget<R>): boolean;
|
|
77
|
+
/**Rows moved to another parent or list are only inserted there, not removed from where they came from
|
|
78
|
+
* For apps that remove the rows themselves when they are added, set on the list the rows are dragged from
|
|
79
|
+
* Moves inside one parent are still one move write */
|
|
80
|
+
no_remove?: boolean;
|
|
81
|
+
}
|
|
82
|
+
/**Drag handle cell in front of a row, empty in the header */
|
|
83
|
+
declare class ListDragField extends Base {
|
|
84
|
+
static element_name(): string;
|
|
85
|
+
static element_name_space(): string;
|
|
86
|
+
}
|
|
87
|
+
/**Place rows are dropped at, before or after a row, or into it as its last sub rows */
|
|
88
|
+
interface ListDropPlace {
|
|
89
|
+
row: AnyRow;
|
|
90
|
+
mode: "before" | "after" | "into";
|
|
91
|
+
}
|
|
92
|
+
/**Moving rows of a list by dragging their handle or with alt and the arrow keys
|
|
93
|
+
* Like the selection, moves are only written to the rows states, the rows move when the states give the change back */
|
|
94
|
+
declare class ListReorder<R> {
|
|
95
|
+
#private;
|
|
96
|
+
readonly group: ListDragGroup<R>;
|
|
97
|
+
readonly container: HTMLElement;
|
|
98
|
+
constructor(container: HTMLElement, options: ListReorderOptions<R>, warn: ListWarn);
|
|
99
|
+
/**Makes the handle cell of a row */
|
|
100
|
+
handle(row: AnyRow): ListDragField;
|
|
101
|
+
/**Shows where rows are dropped in this list, undefined hides it */
|
|
102
|
+
indicate(place: ListDropPlace | undefined): void;
|
|
103
|
+
/**Shows why a move failed at the row, in the list of the row */
|
|
104
|
+
warn(row: AnyRow, message: string): void;
|
|
105
|
+
/**Moves the row one place up or down in its parent, from the keyboard, the row keeps the focus */
|
|
106
|
+
key_move(row: AnyRow, direction: -1 | 1): Promise<void>;
|
|
107
|
+
}
|
|
108
|
+
interface ListKeyFieldOptions {
|
|
109
|
+
/**Icon shown after the sub row opener */
|
|
110
|
+
icon?: SVGFunc | State<SVGFunc>;
|
|
111
|
+
/**Text shown after the icon, an error of a state is shown as the text */
|
|
112
|
+
text?: string | State<string>;
|
|
113
|
+
}
|
|
114
|
+
type ListSubRows<R> = () => R[] | State<R[]>;
|
|
115
|
+
interface ListRowOptions<R, T extends {}, S extends boolean> {
|
|
116
|
+
opened?: boolean;
|
|
117
|
+
openable?: boolean | State<boolean>;
|
|
118
|
+
key_field?: ListKeyFieldOptions;
|
|
119
|
+
sub_rows?: S extends true ? ListSubRows<R> : never;
|
|
120
|
+
add_row?: ListAddRowOptions;
|
|
121
|
+
context_menu?: ContextMenu | (() => Option<ContextMenu>);
|
|
122
|
+
/**Whether the row can be selected when the list has selection, true when undefined */
|
|
123
|
+
selectable?: boolean;
|
|
124
|
+
values: T;
|
|
125
|
+
}
|
|
126
|
+
declare class ListRow<R, T extends {}, A extends ListType<R>, S extends boolean> extends Base implements ListRowParent<A> {
|
|
127
|
+
#private;
|
|
128
|
+
static element_name(): string;
|
|
129
|
+
static element_name_space(): string;
|
|
130
|
+
readonly depth: number;
|
|
131
|
+
/**Key of the row in the selection, undefined when the row can not be selected */
|
|
132
|
+
selection_key?: unknown;
|
|
133
|
+
state: ListParentRows<A>;
|
|
134
|
+
constructor(root: ListRoot<R, T, A, S>, parent: ListRowParent<A>, data: R);
|
|
135
|
+
/**Regenerates the fields of the row and its sub rows after the columns changed */
|
|
136
|
+
columns_changed(): void;
|
|
137
|
+
select_adjacent(direction: "next" | "previous" | "p_next" | "p_previous" | "last", field: Option<number>): void;
|
|
138
|
+
/**Focuses the cell used for keyboard navigation */
|
|
139
|
+
focus_cell(): void;
|
|
140
|
+
key_down(e: KeyboardEvent): boolean;
|
|
141
|
+
set data(data: R);
|
|
142
|
+
set add_row(options: ListAddRowOptions | undefined);
|
|
143
|
+
set openable(value: boolean);
|
|
144
|
+
get openable(): boolean;
|
|
145
|
+
set open(open: boolean);
|
|
146
|
+
get open(): boolean;
|
|
147
|
+
get index(): number;
|
|
148
|
+
amount_rows(rec?: boolean): number;
|
|
149
|
+
set rows(rows: R[] | State<R[]>);
|
|
150
|
+
get data(): R;
|
|
151
|
+
/**Moving of the list the row is in, undefined when its rows can not be moved */
|
|
152
|
+
get reorder(): ListReorder<R> | undefined;
|
|
153
|
+
/**Rows of the parent the row is in */
|
|
154
|
+
get parent_rows(): ListParentRows<A>;
|
|
155
|
+
/**Row the row is a sub row of, undefined for top level rows */
|
|
156
|
+
get parent_row(): ListRow<R, T, A, S> | undefined;
|
|
157
|
+
get next_row(): ListRow<R, T, A, S> | undefined;
|
|
158
|
+
get first_sub_row(): ListRow<R, T, A, S> | undefined;
|
|
159
|
+
/**Whether the row has a handle and its parent rows can be written */
|
|
160
|
+
get movable(): boolean;
|
|
161
|
+
/**Whether rows can be dropped into the row, it must be openable with sub rows in a writable state */
|
|
162
|
+
get droppable(): boolean;
|
|
163
|
+
/**The sub rows rows are dropped into, also of a closed row */
|
|
164
|
+
drop_rows(): R[] | State<R[]> | undefined;
|
|
165
|
+
/**Whether the row is selected in a list with multi selection, a drag of it moves all selected rows */
|
|
166
|
+
get multi_selected(): boolean;
|
|
167
|
+
/**Text naming the row while it is dragged, the key field text or the text of the first cell */
|
|
168
|
+
get label(): string;
|
|
169
|
+
/**First visible cell of the row, the row itself is display contents and has no box */
|
|
170
|
+
get anchor(): Element | undefined;
|
|
171
|
+
set selected(value: boolean);
|
|
172
|
+
get selected(): boolean;
|
|
173
|
+
/**Removes the row and its sub rows from the selection, when the row is removed */
|
|
174
|
+
selection_leave(): void;
|
|
175
|
+
}
|
|
176
|
+
interface ListSelectionOptions<R, K = R> {
|
|
177
|
+
/**Single allows one selected row and shows radio buttons in front of the rows,
|
|
178
|
+
* multi allows any amount and shows checkboxes, which toggle a row without modifier keys */
|
|
179
|
+
mode: "single" | "multi";
|
|
180
|
+
/**Identity of the data of a row, the selection is a list of these
|
|
181
|
+
* Defaults to the data itself, give a key when rows can have equal data, like primitives
|
|
182
|
+
* Keys must be unique among the rows of the list, sub rows included */
|
|
183
|
+
key?: (data: R) => K;
|
|
184
|
+
}
|
|
185
|
+
/**What the selection needs from a row */
|
|
186
|
+
interface ListSelectionRow {
|
|
187
|
+
/**Shows the row as selected */
|
|
188
|
+
selected: boolean;
|
|
189
|
+
/**Cell to point at with a message about the row */
|
|
190
|
+
readonly anchor: Element | undefined;
|
|
191
|
+
}
|
|
192
|
+
/**Selection of the rows of a list, kept in an array state of keys owned by the app
|
|
193
|
+
* The list shows the keys of the state that have a visible row, and writes the state only on user actions,
|
|
194
|
+
* keys of rows it does not show are left alone, except by select all and deselect all which replace the selection */
|
|
195
|
+
declare class ListSelection<K> {
|
|
196
|
+
#private;
|
|
197
|
+
readonly multi: boolean;
|
|
198
|
+
readonly key: (data: any) => K;
|
|
199
|
+
/**Called after a change of the shown selection or of the selectable rows */
|
|
200
|
+
on_change?: () => void;
|
|
201
|
+
/**Called when the state rejects a write, with the row the user acted on */
|
|
202
|
+
on_error?: (row: ListSelectionRow | undefined, message: string) => void;
|
|
203
|
+
/**State user actions are written to */
|
|
204
|
+
target?: StateREAW<K[], any, K[]>;
|
|
205
|
+
constructor(options: ListSelectionOptions<any, K>, box: Element);
|
|
206
|
+
/**Runs the function with the change notification delayed until all nested batches are done */
|
|
207
|
+
batch<T>(func: () => T): T;
|
|
208
|
+
/**Applies a value of the state, only the changed keys are touched when the value carries its changes */
|
|
209
|
+
apply(value: Result<readonly K[], string>): void;
|
|
210
|
+
/**Adds a visible row that can be selected, it shows whether its key is in the state */
|
|
211
|
+
register(key: K, row: ListSelectionRow & Element): void;
|
|
212
|
+
/**Removes a row that is no longer visible or selectable, the state keeps its key */
|
|
213
|
+
unregister(key: K, row: ListSelectionRow & Element): void;
|
|
214
|
+
/**Amount of visible rows that can be selected */
|
|
215
|
+
get amount_selectable(): number;
|
|
216
|
+
/**Amount of visible rows that are selected */
|
|
217
|
+
get amount_selected(): number;
|
|
218
|
+
is_selected(key: K): boolean;
|
|
219
|
+
/**Replaces the selection with only the row */
|
|
220
|
+
select_only(key: K): void;
|
|
221
|
+
/**Adds the row to the selection, in single mode it replaces the selection */
|
|
222
|
+
select(key: K): void;
|
|
223
|
+
/**Removes the row from the selection */
|
|
224
|
+
deselect(key: K): void;
|
|
225
|
+
/**Toggles the row, in single mode selecting replaces the selection */
|
|
226
|
+
toggle(key: K): void;
|
|
227
|
+
/**Replaces the selection with all visible selectable rows, multi mode only */
|
|
228
|
+
select_all(): void;
|
|
229
|
+
/**Clears the selection, also of keys without a visible row */
|
|
230
|
+
clear(): void;
|
|
231
|
+
/**Click on the checkbox or radio button of a row */
|
|
232
|
+
check_click(key: K): void;
|
|
233
|
+
/**Click on a row outside its checkbox or radio button */
|
|
234
|
+
click(key: K, e: MouseEvent): void;
|
|
235
|
+
/**Focus moved to a row with the arrow keys, only shift in multi mode extends the range, otherwise the focus moves alone and space selects */
|
|
236
|
+
focus_moved(key: K, e: KeyboardEvent): void;
|
|
237
|
+
/**Handles selection keys pressed on a row, returns true when the key was used */
|
|
238
|
+
key_down(key: K | undefined, e: KeyboardEvent): boolean;
|
|
239
|
+
}
|
|
240
|
+
type ListType<R> = R[] | State<R[]>;
|
|
241
|
+
type ListTypeExtract<A extends ListType<any>> = A extends (infer U)[] ? U : A extends State<(infer U)[]> ? U : never;
|
|
242
|
+
/**Rows of a row parent, the top level rows or sub rows, which can be an array or a state regardless of the top level rows */
|
|
243
|
+
type ListParentRows<A extends ListType<any>> = A | ListType<ListTypeExtract<A>>;
|
|
244
|
+
declare const ListDataType: {
|
|
245
|
+
readonly number: "number";
|
|
246
|
+
readonly string: "string";
|
|
247
|
+
readonly bool: "bool";
|
|
248
|
+
};
|
|
249
|
+
type ListDataType = (typeof ListDataType)[keyof typeof ListDataType];
|
|
250
|
+
type ListColumnAlign = "left" | "center" | "right";
|
|
251
|
+
interface ListColumnOptions<V, C extends ListField> {
|
|
252
|
+
/**Initial width of the column in rem, auto when undefined*/
|
|
253
|
+
init_width?: number;
|
|
254
|
+
/**If the column has a fixed width in rem, overrides init_width and disables resizing*/
|
|
255
|
+
fixed_width?: number | "min" | "max";
|
|
256
|
+
/**Initial order of the column, lower numbers appear first, will order by column object if undefined
|
|
257
|
+
* A column without order uses its position in the column object as order*/
|
|
258
|
+
order?: number;
|
|
259
|
+
/**Whether the column is reorderable by the user*/
|
|
260
|
+
reorderable?: boolean;
|
|
261
|
+
/**Data type of the column, used for sorting, will attempt auto detect if undefined*/
|
|
262
|
+
type?: ListDataType;
|
|
263
|
+
/**Horizontal alignment of the title and the fields, center when undefined
|
|
264
|
+
* Text, number and node fields follow it, more complex fields like form fields do not */
|
|
265
|
+
align?: ListColumnAlign;
|
|
266
|
+
/**Column title*/
|
|
267
|
+
title: string;
|
|
268
|
+
/**Generates the field element, only called during row or column creation */
|
|
269
|
+
field_gen(): C;
|
|
270
|
+
/**Applies the value to the field */
|
|
271
|
+
field_apply(field: C, value: V): void;
|
|
272
|
+
}
|
|
273
|
+
/**Helper to create a column object */
|
|
274
|
+
declare function column<V, C extends ListField>(options: ListColumnOptions<V, C>): ListColumnOptions<V, C>;
|
|
275
|
+
/**Special helper to create a string value column */
|
|
276
|
+
declare function column_string(
|
|
277
|
+
/**Column title*/
|
|
278
|
+
title: string, options?: {
|
|
279
|
+
align?: ListColumnAlign;
|
|
280
|
+
}): ListColumnOptions<string, ListTextField>;
|
|
281
|
+
/**Transforms the data of a row into row options
|
|
282
|
+
* Returning an error makes the row invalid, the error text then replaces the fields of the row
|
|
283
|
+
* An invalid row is for failures with no other options, so it has no sub rows, add row or context menu */
|
|
284
|
+
type ListRowTransformer<R, T extends {}, A extends ListType<any>, S extends boolean> = (
|
|
285
|
+
/**Data of the row */
|
|
286
|
+
data: R,
|
|
287
|
+
/**The row the options are for */
|
|
288
|
+
row: ListRow<R, T, A, S>,
|
|
289
|
+
/**Rows the data is from, sub rows can come from an array or a state regardless of the top level rows */
|
|
290
|
+
state: S extends true ? A | ListType<R> : A) => Result<ListRowOptions<R, T, S>, string>;
|
|
291
|
+
interface ListRoot<R, T extends {}, A extends ListType<any>, S extends boolean> {
|
|
292
|
+
/**Sub rows */
|
|
293
|
+
readonly sub_rows: S;
|
|
294
|
+
/**Columns options mapped by column key */
|
|
295
|
+
readonly columns: Map<keyof T, ListColumnOptions<T[keyof T], ListField>>;
|
|
296
|
+
/**Order of visible columns by column key */
|
|
297
|
+
columns_visible: (keyof T)[];
|
|
298
|
+
/**Function to transform a row data into row options */
|
|
299
|
+
transform: ListRowTransformer<R, T, A, S>;
|
|
300
|
+
/**Observer for the container if observer is active */
|
|
301
|
+
observer?: BaseIntersectObserver;
|
|
302
|
+
/**Selection of rows, when enabled */
|
|
303
|
+
selection?: ListSelection<any>;
|
|
304
|
+
/**Moving of rows, when enabled */
|
|
305
|
+
reorder?: ListReorder<R>;
|
|
306
|
+
}
|
|
307
|
+
interface ListRowParent<A extends ListType<any>> {
|
|
308
|
+
/**Sub row depth */
|
|
309
|
+
readonly depth: number;
|
|
310
|
+
/**Whether the row is open to show sub rows */
|
|
311
|
+
open: boolean;
|
|
312
|
+
/**Selects the adjacent row in the given direction */
|
|
313
|
+
select_adjacent(direction: "next" | "previous" | "p_next" | "p_previous" | "last", field: Option<number>): void;
|
|
314
|
+
/**Rows of the parent, the rows of the container or the sub rows of a row */
|
|
315
|
+
state: ListParentRows<A>;
|
|
316
|
+
/**Handles a key pressed in the key field before the key field does, returns true when the key was used */
|
|
317
|
+
key_down?(e: KeyboardEvent): boolean;
|
|
318
|
+
}
|
|
319
|
+
interface ListAddRowOptions {
|
|
320
|
+
text: string | State<string>;
|
|
321
|
+
disabled?: boolean | State<boolean>;
|
|
322
|
+
icon?: SVGFunc | State<SVGFunc>;
|
|
323
|
+
on_add: () => void;
|
|
324
|
+
}
|
|
325
|
+
interface ContainerOptions<S extends boolean = false, R = unknown, K = R> {
|
|
326
|
+
/**Should header row be omitted */
|
|
327
|
+
headless?: boolean;
|
|
328
|
+
/**Can rows have sub rows */
|
|
329
|
+
sub_rows?: S;
|
|
330
|
+
/**Options for an add row button */
|
|
331
|
+
add_row?: ListAddRowOptions;
|
|
332
|
+
/**If list should use a container to give fields the option of attach/detach to states when visible */
|
|
333
|
+
observer?: BaseIntersectObserver;
|
|
334
|
+
/**Lets the user select rows, only rows that are visible can be selected */
|
|
335
|
+
selection?: ListSelectionOptions<R, K>;
|
|
336
|
+
/**Lets the user move rows with a drag handle in front of the rows, rows in a writable array state can be moved */
|
|
337
|
+
reorder?: ListReorderOptions<R>;
|
|
338
|
+
}
|
|
339
|
+
declare class Container<A extends ListType<any>, T extends {
|
|
340
|
+
[key: string]: ListColumnOptions<any, any>;
|
|
341
|
+
}, S extends boolean = false, R = ListTypeExtract<A>, K = R> extends Base {
|
|
342
|
+
#private;
|
|
343
|
+
static element_name(): string;
|
|
344
|
+
static element_name_space(): string;
|
|
345
|
+
constructor(columns: { [C in keyof T]: ListColumnOptions<T[C], any>; }, transform: ListRowTransformer<R, T, A, S>, rows: A, options?: ContainerOptions<S, R, K>);
|
|
346
|
+
set columns(columns: { [C in keyof T]: ListColumnOptions<T[C], any>; });
|
|
347
|
+
set add_row(options: ListAddRowOptions | undefined);
|
|
348
|
+
amount_rows(rec?: boolean): number;
|
|
349
|
+
set rows(rows: R[] | State<R[]>);
|
|
350
|
+
/**Binds the selection to an array state of keys, which can be shared with other lists and elements
|
|
351
|
+
* The list shows the keys that have a visible row, and only writes the state on user actions,
|
|
352
|
+
* with array write instructions, so it must be a state that applies them, like a local writable state
|
|
353
|
+
* Without a state the selection is kept in a state of the list that nobody else can reach
|
|
354
|
+
* Needs the selection option */
|
|
355
|
+
bind(opts: {
|
|
356
|
+
selection?: StateREAW<K[], any, K[]>;
|
|
357
|
+
}): this;
|
|
358
|
+
}
|
|
359
|
+
declare function container<A extends ListType<any>, T extends {}, S extends boolean = false, R = ListTypeExtract<A>, K = R>(columns: { [C in keyof T]: ListColumnOptions<T[C], any>; }, transform: ListRowTransformer<R, NoInfer<T>, A, S>, rows: A, options?: ContainerOptions<S, R, K>): Container<A, T, S, R, K>;
|
|
360
|
+
declare const list: {
|
|
361
|
+
column: typeof column;
|
|
362
|
+
column_string: typeof column_string;
|
|
363
|
+
container: typeof container;
|
|
364
|
+
text_field: typeof text_field;
|
|
365
|
+
number_field: typeof number_field;
|
|
366
|
+
node_field: typeof node_field;
|
|
367
|
+
/**Group of lists that can give rows to each other by dragging, all lists of a group must have the same row type */
|
|
368
|
+
drag_group<R>(): ListDragGroup<R>;
|
|
369
|
+
};
|
|
370
|
+
export { ListField as a, ListReorderOptions as i, ListDragGroup as n, ListDropTarget as r, list as t };
|
|
371
|
+
//# sourceMappingURL=index-Cw4AcuUl.d.mts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import './style.css';
|
|
2
|
-
import { l as Base } from "./index-
|
|
2
|
+
import { l as Base } from "./index-CvzH3M_5.mjs";
|
|
3
3
|
import { Option } from "@chocbite/ts-lib/result";
|
|
4
4
|
interface ContextMenuLine {}
|
|
5
5
|
declare abstract class MenuLine extends Base implements ContextMenuLine {
|
|
@@ -14,8 +14,18 @@ declare abstract class MenuLine extends Base implements ContextMenuLine {
|
|
|
14
14
|
* @param direction false is next sibling, true is previous */
|
|
15
15
|
focus_next(direction?: boolean): void;
|
|
16
16
|
}
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
declare class Container extends Base {
|
|
18
|
+
#private;
|
|
19
|
+
/**Returns the name used to define the element */
|
|
20
|
+
static element_name(): string;
|
|
21
|
+
/**Returns the namespace override for the element*/
|
|
22
|
+
static element_name_space(): string;
|
|
23
|
+
constructor();
|
|
24
|
+
/**Attaches a menu to the container */
|
|
25
|
+
attach_menu(menu: ContextMenu): ContextMenu;
|
|
26
|
+
/**Closes open context menu */
|
|
27
|
+
close_up(): void;
|
|
28
|
+
}
|
|
19
29
|
interface ContextMenuSub extends ContextMenuLine {}
|
|
20
30
|
declare class MenuSub extends MenuLine implements ContextMenuSub {
|
|
21
31
|
#private;
|
|
@@ -45,6 +55,9 @@ declare class ContextMenu extends Base {
|
|
|
45
55
|
constructor(lines: ((ContextMenuLine | undefined)[] | Promise<(ContextMenuLine | undefined)[]>) | (() => (ContextMenuLine | undefined)[] | Promise<(ContextMenuLine | undefined)[]>));
|
|
46
56
|
protected connectedCallback(): void;
|
|
47
57
|
protected disconnectedCallback(): void;
|
|
58
|
+
/**Gives the lines the menu shows when it opens, a lines function is called
|
|
59
|
+
* The lines are elements in one menu at a time, ctm.combine moves them into its menu, this menu takes them back when it opens */
|
|
60
|
+
read_lines(): (ContextMenuLine | undefined)[] | Promise<(ContextMenuLine | undefined)[]>;
|
|
48
61
|
/**Sets the lines of the context menu */
|
|
49
62
|
set lines(lines: (ContextMenuLine | undefined)[]);
|
|
50
63
|
/**Changes focus to the next line
|
|
@@ -66,18 +79,20 @@ declare class ContextMenu extends Base {
|
|
|
66
79
|
set_position(x?: number, y?: number, element?: Element): void;
|
|
67
80
|
}
|
|
68
81
|
declare function context_menu(lines: ((ContextMenuLine | undefined)[] | Promise<(ContextMenuLine | undefined)[]>) | (() => (ContextMenuLine | undefined)[]) | (() => Promise<(ContextMenuLine | undefined)[]>)): ContextMenu;
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
82
|
+
type Lines = (ContextMenuLine | undefined)[];
|
|
83
|
+
/**A group for ctm.combine, undefined for no group
|
|
84
|
+
* - lines, undefined lines are skipped like in ctm.menu
|
|
85
|
+
* - a menu, its lines are taken when the combined menu opens
|
|
86
|
+
* - a function called every time the combined menu opens, giving lines, a menu, or an option of a menu like ctm.attach takes*/
|
|
87
|
+
type ContextMenuGroup = Lines | ContextMenu | (() => Lines | ContextMenu | Option<ContextMenu>) | undefined;
|
|
88
|
+
/**Combines groups of lines and menus into one menu with a devider between groups, built every time the menu opens
|
|
89
|
+
* Empty groups are left out with their devider, and when all groups are empty there is no menu
|
|
90
|
+
* A group with promised lines makes the combined menu wait for all groups, showing a spinner, it then always opens
|
|
91
|
+
* Give the result to ctm.attach, or anything else taking a menu factory
|
|
92
|
+
* @param groups groups in menu order, see ContextMenuGroup*/
|
|
93
|
+
declare function context_combine(...groups: ContextMenuGroup[]): () => Option<ContextMenu>;
|
|
94
|
+
interface ContextMenuDevider extends ContextMenuLine {}
|
|
95
|
+
declare function context_devider(): ContextMenuDevider;
|
|
81
96
|
declare const CONTEXT_MENY_SYMBOL: unique symbol;
|
|
82
97
|
declare global {
|
|
83
98
|
interface Document {
|
|
@@ -117,6 +132,7 @@ declare const ctm: {
|
|
|
117
132
|
line: typeof context_line;
|
|
118
133
|
sub: typeof context_sub;
|
|
119
134
|
devider: typeof context_devider;
|
|
135
|
+
combine: typeof context_combine;
|
|
120
136
|
};
|
|
121
|
-
export {
|
|
122
|
-
//# sourceMappingURL=index-
|
|
137
|
+
export { ContextMenuLines as i, ContextMenuGroup as n, ContextMenu as r, ctm as t };
|
|
138
|
+
//# sourceMappingURL=index-YNZjMIO7.d.mts.map
|
package/keyboard/index.d.mts
CHANGED
package/keyboard/index.mjs
CHANGED
|
@@ -2,12 +2,12 @@ import "../style.css";
|
|
|
2
2
|
import { DOCUMENT_HANDLER } from "../document/index.mjs";
|
|
3
3
|
import { Base, define_element } from "../base/index.mjs";
|
|
4
4
|
import { get_cursor_position, set_cursor_position } from "../selection/index.mjs";
|
|
5
|
-
import { _ as version, i as theme_init_variable_root } from "../theme-
|
|
5
|
+
import { _ as version, i as theme_init_variable_root } from "../theme-BJS5z1iW.mjs";
|
|
6
6
|
import { settings_init } from "../settings/index.mjs";
|
|
7
7
|
import state, { state as state$1 } from "@chocbite/ts-lib/state";
|
|
8
8
|
import { some } from "@chocbite/ts-lib/result";
|
|
9
9
|
import { GREY } from "@chocbite/ts-lib/colors";
|
|
10
|
-
//
|
|
10
|
+
// keyboard/base.ts
|
|
11
11
|
var KeyboardBase = class KeyboardBase extends Base {
|
|
12
12
|
static element_name() {
|
|
13
13
|
return "@abstract@";
|
|
@@ -77,7 +77,7 @@ var KeyboardBase = class KeyboardBase extends Base {
|
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
};
|
|
80
|
-
//
|
|
80
|
+
// keyboard/types.ts
|
|
81
81
|
const KeyboardSpecialKeys = {
|
|
82
82
|
Close: "close",
|
|
83
83
|
Enter: "enter",
|
|
@@ -116,7 +116,7 @@ const KeyboardType = {
|
|
|
116
116
|
/**Phone number input type, eg. +1 234 567 890 */
|
|
117
117
|
Phone: "phone"
|
|
118
118
|
};
|
|
119
|
-
//
|
|
119
|
+
// keyboard/helpers.ts
|
|
120
120
|
function input_keyboard_type(input) {
|
|
121
121
|
if (input.type === "tel") return KeyboardType.Phone;
|
|
122
122
|
if (input.type === "email") return KeyboardType.Email;
|
|
@@ -149,7 +149,7 @@ function keyboard_type(element) {
|
|
|
149
149
|
}
|
|
150
150
|
return element.isContentEditable ? KeyboardType.Text : void 0;
|
|
151
151
|
}
|
|
152
|
-
//
|
|
152
|
+
// keyboard/keyboard_color.ts
|
|
153
153
|
function hex_to_rgb(hex) {
|
|
154
154
|
const value = Number.parseInt(hex.slice(1), 16);
|
|
155
155
|
return {
|
|
@@ -361,7 +361,7 @@ var Keyboard_Color = class extends KeyboardBase {
|
|
|
361
361
|
}
|
|
362
362
|
};
|
|
363
363
|
define_element(Keyboard_Color);
|
|
364
|
-
//
|
|
364
|
+
// keyboard/keyboard_datetime.ts
|
|
365
365
|
const MONTHS = [
|
|
366
366
|
"January",
|
|
367
367
|
"February",
|
|
@@ -672,14 +672,14 @@ var Keyboard_DateTime = class extends KeyboardBase {
|
|
|
672
672
|
};
|
|
673
673
|
define_element(Keyboard_DateTime);
|
|
674
674
|
const DATETIME_KEYBOARD = new Keyboard_DateTime();
|
|
675
|
-
//
|
|
675
|
+
// keyboard/shared.ts
|
|
676
676
|
const colors = theme_init_variable_root("keyboard", "Virtual Keyboard", "Theme variables for the virtual keyboard").make_sub_group("colors", "Colors", "Colors used in the virtual keyboard");
|
|
677
677
|
colors.make_variable("background", "Background Color", "", GREY["50"], GREY["900"], "Color", void 0);
|
|
678
678
|
colors.make_variable("keytext", "Key Text Color", "", GREY["800"], GREY["200"], "Color", void 0);
|
|
679
679
|
colors.make_variable("border", "Border Color", "", GREY["900"], GREY["50"], "Color", void 0);
|
|
680
680
|
colors.make_variable("shadow", "Shadow Color", "", GREY["900"] + "88", GREY["50"] + "FF", "Color", void 0);
|
|
681
681
|
colors.make_variable("active", "Pressed Color", "Color of the key when pressed", GREY["400"], GREY["700"], "Color", void 0);
|
|
682
|
-
//
|
|
682
|
+
// keyboard/keyboard_keys.ts
|
|
683
683
|
var KeyboardKey = class extends Base {
|
|
684
684
|
static element_name() {
|
|
685
685
|
return "key";
|
|
@@ -943,7 +943,7 @@ var Keyboard_Keys = class extends KeyboardBase {
|
|
|
943
943
|
}
|
|
944
944
|
};
|
|
945
945
|
define_element(Keyboard_Keys);
|
|
946
|
-
//
|
|
946
|
+
// keyboard/number.ts
|
|
947
947
|
const NUMBER_RATIONAL_KEYBOARD = new Keyboard_Keys({ default: {
|
|
948
948
|
max_width: 24,
|
|
949
949
|
keys: [
|
|
@@ -1173,13 +1173,13 @@ const PHONE_KEYBOARD = new Keyboard_Keys({ default: {
|
|
|
1173
1173
|
]
|
|
1174
1174
|
]
|
|
1175
1175
|
} });
|
|
1176
|
-
//
|
|
1176
|
+
// keyboard/settings.ts
|
|
1177
1177
|
const SETTINGS = settings_init("@chocbite/ts-lib-keyboard", version, "Keyboard", "Settings for virtual keyboard");
|
|
1178
1178
|
const THEME_ID = "virtual_keyboard";
|
|
1179
1179
|
const PRIVATE_VIRTUAL_KEYBOARD = state$1.rosw(SETTINGS.get(THEME_ID, false), true);
|
|
1180
1180
|
SETTINGS.register(THEME_ID, "Virtual Keyboard", "Enable or disable the virtual keyboard", PRIVATE_VIRTUAL_KEYBOARD);
|
|
1181
1181
|
const VIRTUAL_KEYBOARD = PRIVATE_VIRTUAL_KEYBOARD.read_write;
|
|
1182
|
-
//
|
|
1182
|
+
// keyboard/text.ts
|
|
1183
1183
|
const TEXT_KEYBOARD = new Keyboard_Keys({
|
|
1184
1184
|
default: {
|
|
1185
1185
|
max_width: 60,
|
|
@@ -1519,7 +1519,7 @@ const EMAIL_KEYBOARD = new Keyboard_Keys({
|
|
|
1519
1519
|
}
|
|
1520
1520
|
}
|
|
1521
1521
|
});
|
|
1522
|
-
//
|
|
1522
|
+
// keyboard/index.ts
|
|
1523
1523
|
const KEYBOARDS = {
|
|
1524
1524
|
[KeyboardType.Text]: TEXT_KEYBOARD,
|
|
1525
1525
|
[KeyboardType.Email]: EMAIL_KEYBOARD,
|