x4js 2.0.18 → 2.0.21
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 +1 -0
- package/lib/cjs/x4.css +1 -1
- package/lib/cjs/x4.js +2 -2
- package/lib/esm/x4.css +1 -1
- package/lib/esm/x4.mjs +2 -2
- package/lib/styles/x4.css +1 -1
- package/lib/types/x4js.d.ts +92 -77
- package/package.json +1 -1
- package/src/components/boxes/boxes.ts +35 -3
- package/src/components/breadcrumb/breadcrumb.ts +4 -4
- package/src/components/btngroup/btngroup.ts +4 -4
- package/src/components/button/button.ts +2 -2
- package/src/components/calendar/calendar.ts +1 -1
- package/src/components/canvas/canvas.ts +2 -2
- package/src/components/checkbox/checkbox.ts +4 -4
- package/src/components/colorinput/colorinput.ts +3 -3
- package/src/components/combobox/combobox.module.scss +13 -0
- package/src/components/combobox/combobox.ts +10 -3
- package/src/components/dialog/dialog.ts +7 -7
- package/src/components/form/form.ts +5 -5
- package/src/components/gridview/gridview.ts +12 -9
- package/src/components/header/header.module.scss +2 -1
- package/src/components/header/header.ts +22 -10
- package/src/components/icon/icon.module.scss +1 -0
- package/src/components/icon/icon.ts +1 -1
- package/src/components/image/image.ts +3 -3
- package/src/components/input/input.ts +2 -2
- package/src/components/keyboard/keyboard.ts +5 -5
- package/src/components/label/label.module.scss +6 -1
- package/src/components/label/label.ts +1 -1
- package/src/components/listbox/listbox.module.scss +35 -31
- package/src/components/listbox/listbox.ts +53 -15
- package/src/components/messages/messages.ts +15 -1
- package/src/components/notification/notification.ts +8 -8
- package/src/components/popup/popup.ts +14 -3
- package/src/components/progress/progress.ts +1 -1
- package/src/components/propgrid/propgrid.ts +5 -3
- package/src/components/radio/radio.ts +2 -2
- package/src/components/rating/rating.ts +6 -6
- package/src/components/select/select.ts +1 -1
- package/src/components/sizers/sizer.ts +5 -5
- package/src/components/slider/slider.ts +3 -3
- package/src/components/switch/switch.ts +3 -3
- package/src/components/tabs/tabs.module.scss +2 -2
- package/src/components/tabs/tabs.ts +29 -5
- package/src/components/textarea/textarea.ts +1 -1
- package/src/components/textedit/textedit.ts +2 -2
- package/src/components/tickline/tickline.ts +1 -1
- package/src/components/tooltips/tooltips.ts +2 -2
- package/src/components/treeview/treeview.module.scss +9 -1
- package/src/components/treeview/treeview.ts +53 -14
- package/src/components/viewport/viewport.ts +1 -1
- package/src/core/component.ts +46 -9
- package/src/core/core_application.ts +3 -3
- package/src/core/core_data.ts +12 -12
- package/src/core/core_element.ts +1 -1
- package/src/core/core_react.ts +2 -2
- package/src/core/core_router.ts +2 -2
- package/src/core/core_state.ts +1 -1
- package/src/core/core_styles.ts +1 -1
- package/src/core/core_tools.ts +2 -0
- package/lib/src/components/base.scss +0 -25
- package/lib/src/components/boxes/boxes.module.scss +0 -54
- package/lib/src/components/boxes/boxes.ts +0 -370
- package/lib/src/components/breadcrumb/breadcrumb.scss +0 -56
- package/lib/src/components/breadcrumb/breadcrumb.ts +0 -93
- package/lib/src/components/breadcrumb/chevron-right.svg +0 -1
- package/lib/src/components/btngroup/btngroup.module.scss +0 -41
- package/lib/src/components/btngroup/btngroup.ts +0 -153
- package/lib/src/components/button/button.module.scss +0 -173
- package/lib/src/components/button/button.ts +0 -185
- package/lib/src/components/calendar/calendar-check-sharp-light.svg +0 -1
- package/lib/src/components/calendar/calendar.module.scss +0 -163
- package/lib/src/components/calendar/calendar.ts +0 -327
- package/lib/src/components/calendar/chevron-left-sharp-light.svg +0 -1
- package/lib/src/components/calendar/chevron-right-sharp-light.svg +0 -1
- package/lib/src/components/canvas/canvas.module.scss +0 -25
- package/lib/src/components/canvas/canvas.ts +0 -189
- package/lib/src/components/canvas/canvas_ex.ts +0 -276
- package/lib/src/components/checkbox/check.svg +0 -4
- package/lib/src/components/checkbox/checkbox.module.scss +0 -142
- package/lib/src/components/checkbox/checkbox.ts +0 -140
- package/lib/src/components/colorinput/colorinput.module.scss +0 -65
- package/lib/src/components/colorinput/colorinput.ts +0 -91
- package/lib/src/components/colorinput/crosshairs-simple-sharp-light.svg +0 -1
- package/lib/src/components/colorpicker/colorpicker.module.scss +0 -133
- package/lib/src/components/colorpicker/colorpicker.ts +0 -482
- package/lib/src/components/combobox/combobox.module.scss +0 -133
- package/lib/src/components/combobox/combobox.ts +0 -275
- package/lib/src/components/combobox/updown.svg +0 -4
- package/lib/src/components/components.ts +0 -42
- package/lib/src/components/dialog/dialog.module.scss +0 -104
- package/lib/src/components/dialog/dialog.ts +0 -229
- package/lib/src/components/dialog/xmark-sharp-light.svg +0 -1
- package/lib/src/components/filedrop/cloud-arrow-up.svg +0 -1
- package/lib/src/components/filedrop/filedrop.module.scss +0 -70
- package/lib/src/components/filedrop/filedrop.ts +0 -131
- package/lib/src/components/form/form.module.scss +0 -38
- package/lib/src/components/form/form.ts +0 -172
- package/lib/src/components/gridview/arrow-down-light.svg +0 -1
- package/lib/src/components/gridview/arrow-up-light.svg +0 -1
- package/lib/src/components/gridview/gridview.module.scss +0 -324
- package/lib/src/components/gridview/gridview.ts +0 -1175
- package/lib/src/components/header/header.module.scss +0 -40
- package/lib/src/components/header/header.ts +0 -130
- package/lib/src/components/icon/icon.module.scss +0 -31
- package/lib/src/components/icon/icon.ts +0 -137
- package/lib/src/components/image/image.module.scss +0 -28
- package/lib/src/components/image/image.ts +0 -168
- package/lib/src/components/input/input.module.scss +0 -74
- package/lib/src/components/input/input.ts +0 -422
- package/lib/src/components/keyboard/arrow-up.svg +0 -1
- package/lib/src/components/keyboard/delete-left.svg +0 -1
- package/lib/src/components/keyboard/eye-slash.svg +0 -1
- package/lib/src/components/keyboard/keyboard.module.scss +0 -134
- package/lib/src/components/keyboard/keyboard.ts +0 -526
- package/lib/src/components/label/label.module.scss +0 -76
- package/lib/src/components/label/label.ts +0 -97
- package/lib/src/components/link/link.ts +0 -81
- package/lib/src/components/listbox/listbox.module.scss +0 -161
- package/lib/src/components/listbox/listbox.ts +0 -539
- package/lib/src/components/menu/caret-right-solid.svg +0 -1
- package/lib/src/components/menu/menu.module.scss +0 -117
- package/lib/src/components/menu/menu.ts +0 -174
- package/lib/src/components/messages/circle-exclamation.svg +0 -1
- package/lib/src/components/messages/messages.module.scss +0 -92
- package/lib/src/components/messages/messages.ts +0 -215
- package/lib/src/components/messages/pen-field.svg +0 -1
- package/lib/src/components/normalize.scss +0 -391
- package/lib/src/components/notification/circle-check-solid.svg +0 -1
- package/lib/src/components/notification/circle-exclamation-solid.svg +0 -1
- package/lib/src/components/notification/circle-notch-light.svg +0 -1
- package/lib/src/components/notification/notification.module.scss +0 -84
- package/lib/src/components/notification/notification.ts +0 -107
- package/lib/src/components/notification/xmark-sharp-light.svg +0 -1
- package/lib/src/components/panel/panel.module.scss +0 -60
- package/lib/src/components/panel/panel.ts +0 -58
- package/lib/src/components/popup/popup.module.scss +0 -51
- package/lib/src/components/popup/popup.ts +0 -442
- package/lib/src/components/progress/progress.module.scss +0 -57
- package/lib/src/components/progress/progress.ts +0 -44
- package/lib/src/components/propgrid/folder-closed.svg +0 -1
- package/lib/src/components/propgrid/folder-open.svg +0 -1
- package/lib/src/components/propgrid/progrid.module.scss +0 -112
- package/lib/src/components/propgrid/propgrid.ts +0 -288
- package/lib/src/components/propgrid/updown.svg +0 -4
- package/lib/src/components/radio/radio.module.scss +0 -147
- package/lib/src/components/radio/radio.svg +0 -4
- package/lib/src/components/radio/radio.ts +0 -142
- package/lib/src/components/rating/rating.module.scss +0 -23
- package/lib/src/components/rating/rating.ts +0 -131
- package/lib/src/components/rating/star-sharp-light.svg +0 -1
- package/lib/src/components/rating/star-sharp-solid.svg +0 -1
- package/lib/src/components/select/select.module.scss +0 -9
- package/lib/src/components/select/select.ts +0 -134
- package/lib/src/components/shared.scss +0 -137
- package/lib/src/components/sizers/sizer.module.scss +0 -90
- package/lib/src/components/sizers/sizer.ts +0 -132
- package/lib/src/components/slider/slider.module.scss +0 -118
- package/lib/src/components/slider/slider.ts +0 -198
- package/lib/src/components/switch/switch.module.scss +0 -127
- package/lib/src/components/switch/switch.ts +0 -62
- package/lib/src/components/tabs/tabs.module.scss +0 -45
- package/lib/src/components/tabs/tabs.ts +0 -205
- package/lib/src/components/textarea/textarea.module.scss +0 -63
- package/lib/src/components/textarea/textarea.ts +0 -125
- package/lib/src/components/textedit/textedit.module.scss +0 -116
- package/lib/src/components/textedit/textedit.ts +0 -115
- package/lib/src/components/themes.scss +0 -88
- package/lib/src/components/tickline/tickline.module.scss +0 -26
- package/lib/src/components/tickline/tickline.ts +0 -82
- package/lib/src/components/tooltips/circle-info-sharp-light.svg +0 -1
- package/lib/src/components/tooltips/comments-question.svg +0 -1
- package/lib/src/components/tooltips/tooltips.scss +0 -72
- package/lib/src/components/tooltips/tooltips.ts +0 -109
- package/lib/src/components/treeview/chevron-down-light.svg +0 -1
- package/lib/src/components/treeview/treeview.module.scss +0 -185
- package/lib/src/components/treeview/treeview.ts +0 -445
- package/lib/src/components/viewport/viewport.module.scss +0 -32
- package/lib/src/components/viewport/viewport.ts +0 -41
- package/lib/src/core/component.ts +0 -1066
- package/lib/src/core/core_application.ts +0 -265
- package/lib/src/core/core_colors.ts +0 -250
- package/lib/src/core/core_data.ts +0 -1310
- package/lib/src/core/core_dom.ts +0 -471
- package/lib/src/core/core_dragdrop.ts +0 -201
- package/lib/src/core/core_element.ts +0 -115
- package/lib/src/core/core_events.ts +0 -177
- package/lib/src/core/core_i18n.ts +0 -393
- package/lib/src/core/core_react.ts +0 -79
- package/lib/src/core/core_router.ts +0 -237
- package/lib/src/core/core_state.ts +0 -62
- package/lib/src/core/core_styles.ts +0 -214
- package/lib/src/core/core_svg.ts +0 -712
- package/lib/src/core/core_tools.ts +0 -906
- package/lib/src/types/scss.d.ts +0 -4
- package/lib/src/types/svg.d.ts +0 -1
- package/lib/src/types/x4react.d.ts +0 -9
- package/lib/src/x4.scss +0 -19
- package/lib/src/x4.ts +0 -35
- package/lib/src/x4tsx.d.ts +0 -25
|
@@ -1,370 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ___ ___ __
|
|
3
|
-
* \ \/ / / _
|
|
4
|
-
* \ / /_| |_
|
|
5
|
-
* / \____ _|
|
|
6
|
-
* /__/\__\ |_|
|
|
7
|
-
*
|
|
8
|
-
* @file boxes.ts
|
|
9
|
-
* @author Etienne Cochard
|
|
10
|
-
*
|
|
11
|
-
* @copyright (c) 2024 R-libre ingenierie
|
|
12
|
-
*
|
|
13
|
-
* Use of this source code is governed by an MIT-style license
|
|
14
|
-
* that can be found in the LICENSE file or at https://opensource.org/licenses/MIT.
|
|
15
|
-
**/
|
|
16
|
-
|
|
17
|
-
import { asap, class_ns, isArray, isNumber, isString } from '@core/core_tools.js';
|
|
18
|
-
import { Component, ComponentContent, ComponentEvents, ComponentProps, EvSelectionChange } from "../../core/component"
|
|
19
|
-
|
|
20
|
-
import "./boxes.module.scss";
|
|
21
|
-
import { EventCallback } from '@core/core_events.js';
|
|
22
|
-
|
|
23
|
-
export interface BoxProps extends ComponentProps {
|
|
24
|
-
tag?: string;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
*
|
|
29
|
-
*/
|
|
30
|
-
|
|
31
|
-
@class_ns( "x4" )
|
|
32
|
-
export class Box<P extends BoxProps=BoxProps,E extends ComponentEvents=ComponentEvents> extends Component<P,E> {
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
*
|
|
38
|
-
*/
|
|
39
|
-
|
|
40
|
-
@class_ns( "x4" )
|
|
41
|
-
export class HBox<P extends BoxProps=BoxProps,E extends ComponentEvents=ComponentEvents> extends Box<P,E> {
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
*
|
|
46
|
-
*/
|
|
47
|
-
|
|
48
|
-
@class_ns( "x4" )
|
|
49
|
-
export class VBox<P extends BoxProps=BoxProps,E extends ComponentEvents=ComponentEvents> extends Box<P,E> {
|
|
50
|
-
constructor( p: P ) {
|
|
51
|
-
super( p );
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* stack of widgets where only one widget is visible at a time
|
|
58
|
-
*/
|
|
59
|
-
|
|
60
|
-
type ContentBuilder = ( ) => Component;
|
|
61
|
-
|
|
62
|
-
interface StackItem {
|
|
63
|
-
name: string;
|
|
64
|
-
content: Component | ContentBuilder;
|
|
65
|
-
title?: string;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
*
|
|
70
|
-
*/
|
|
71
|
-
|
|
72
|
-
interface StackeBoxEvents extends ComponentEvents {
|
|
73
|
-
pageChange?: EvSelectionChange;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export interface StackBoxProps extends Omit<ComponentProps,"content"> {
|
|
77
|
-
default: string;
|
|
78
|
-
items: StackItem[];
|
|
79
|
-
pageChange?: EventCallback<EvSelectionChange>;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
*
|
|
84
|
-
*/
|
|
85
|
-
|
|
86
|
-
interface StackItemEx extends StackItem {
|
|
87
|
-
page: Component;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
*
|
|
92
|
-
*/
|
|
93
|
-
|
|
94
|
-
@class_ns( "x4" )
|
|
95
|
-
export class StackBox<P extends StackBoxProps = StackBoxProps, E extends StackeBoxEvents = StackeBoxEvents> extends Box<StackBoxProps,StackeBoxEvents> {
|
|
96
|
-
|
|
97
|
-
protected _items: StackItemEx[];
|
|
98
|
-
protected _cur: number;
|
|
99
|
-
|
|
100
|
-
constructor( props: StackBoxProps ) {
|
|
101
|
-
super( props );
|
|
102
|
-
|
|
103
|
-
this.mapPropEvents( props, "pageChange" );
|
|
104
|
-
|
|
105
|
-
this._items = props.items?.map( itm => {
|
|
106
|
-
return { ...itm, page: null as any};
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
if( props.default ) {
|
|
110
|
-
this.select( props.default );
|
|
111
|
-
}
|
|
112
|
-
else if( this._items.length ) {
|
|
113
|
-
this.select( this._items[0].name );
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
addItem( item: StackItem ) {
|
|
118
|
-
this._items.push( {
|
|
119
|
-
name: item.name,
|
|
120
|
-
content: item.content,
|
|
121
|
-
page: null
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
select( name: string ) {
|
|
126
|
-
let sel = this.query( `:scope > .selected` );
|
|
127
|
-
if( sel ) {
|
|
128
|
-
sel.setClass( "selected", false );
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
this._cur = this._items.findIndex( x => x.name==name );
|
|
132
|
-
const pg = this._items[this._cur];
|
|
133
|
-
|
|
134
|
-
if( pg ) {
|
|
135
|
-
if( !pg.page ) {
|
|
136
|
-
pg.page = this._createPage( pg );
|
|
137
|
-
this.appendContent( pg.page );
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
sel = pg.page;
|
|
141
|
-
if( sel ) {
|
|
142
|
-
(sel as any).activate?.( );
|
|
143
|
-
sel.setClass( "selected", true );
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
asap( ( ) => this.fire( "pageChange", { selection: pg.name, empty: !sel } ) );
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
return pg?.page;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
*
|
|
154
|
-
*/
|
|
155
|
-
|
|
156
|
-
private _createPage( page: StackItemEx ) {
|
|
157
|
-
|
|
158
|
-
let content: Component;
|
|
159
|
-
if( page.content instanceof Function ) {
|
|
160
|
-
content = page.content( );
|
|
161
|
-
page.content = content; // keep it
|
|
162
|
-
}
|
|
163
|
-
else {
|
|
164
|
-
content = page.content;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
content?.setData( "stackname", page.name );
|
|
168
|
-
return content;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
*
|
|
173
|
-
*/
|
|
174
|
-
|
|
175
|
-
getPage( name: string ) {
|
|
176
|
-
const pg = this._items.find( x => x.name==name );
|
|
177
|
-
return pg ? pg.content : null;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
getItem( name: string ) {
|
|
181
|
-
const pg = this._items.find( x => x.name==name );
|
|
182
|
-
return pg;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
/**
|
|
186
|
-
*
|
|
187
|
-
*/
|
|
188
|
-
|
|
189
|
-
getCurPage( ) {
|
|
190
|
-
const c = this._items[this._cur];
|
|
191
|
-
return c?.name;
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
// :: ASSIST BOX ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
@class_ns( "x4" )
|
|
199
|
-
export class AssistBox extends StackBox {
|
|
200
|
-
selectNextPage( nxt = true ) {
|
|
201
|
-
let p;
|
|
202
|
-
if( nxt && this._cur<this._items.length-1 ) {
|
|
203
|
-
p = this._items[this._cur+1];
|
|
204
|
-
}
|
|
205
|
-
else if( !nxt && this._cur>0 ) {
|
|
206
|
-
p = this._items[this._cur-1];
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
if( p ) {
|
|
210
|
-
this.select( p.name );
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
isFirstPage( ) {
|
|
215
|
-
return this._cur==0;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
isLastPage( ) {
|
|
219
|
-
return this._cur==this._items.length-1;
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
// :: GRIDBOX ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
|
226
|
-
|
|
227
|
-
interface GridBoxItem {
|
|
228
|
-
row: number; // starts at 0
|
|
229
|
-
col: number; // starts at 0
|
|
230
|
-
item: Component;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
export interface GridBoxProps extends Omit<BoxProps,"content"> {
|
|
234
|
-
rows?: number | string | string[];
|
|
235
|
-
columns?: number | string | string[];
|
|
236
|
-
items?: GridBoxItem[];
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
@class_ns("x4")
|
|
240
|
-
export class GridBox<P extends GridBoxProps=GridBoxProps,E extends ComponentEvents=ComponentEvents> extends Box<P,E> {
|
|
241
|
-
|
|
242
|
-
constructor( props: P ) {
|
|
243
|
-
super( props );
|
|
244
|
-
|
|
245
|
-
if( props.rows!==undefined ) {
|
|
246
|
-
this.setRows( props.rows );
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
if( props.columns!==undefined ) {
|
|
250
|
-
this.setCols( props.columns );
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
if( props.items ) {
|
|
254
|
-
this.setItems( props.items );
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
setRows( r: number | string | string[] ) {
|
|
259
|
-
if( isArray(r) ) {
|
|
260
|
-
r = r.join( " " );
|
|
261
|
-
}
|
|
262
|
-
else if( isNumber(r) ) {
|
|
263
|
-
r = `repeat( ${r}, 1fr )`;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
this.setStyleValue( "gridTemplateRows", r );
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
setCols( r: number | string | string[] ) {
|
|
270
|
-
if( isArray(r) ) {
|
|
271
|
-
r = r.join( " " );
|
|
272
|
-
}
|
|
273
|
-
else if( isNumber(r) ) {
|
|
274
|
-
r = `repeat( ${r}, 1fr )`;
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
this.setStyleValue( "gridTemplateColumns", r );
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
setRowCount( n: number ) {
|
|
281
|
-
this.setStyleValue( "gridTemplateRows", `repeat(${n})` );
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
setColCount( n: number ) {
|
|
285
|
-
this.setStyleValue( "gridTemplateColumns", `repeat(${n})` );
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
/**
|
|
289
|
-
* @param t "a a a" "b c c" "b c c"
|
|
290
|
-
* user item.setAttribute( "grid-area", "a" );
|
|
291
|
-
*/
|
|
292
|
-
|
|
293
|
-
setTemplate( t: string[] ) {
|
|
294
|
-
this.setAttribute( "grid-template-area", t.map( x => '"' + x + '"' ).join(" ") );
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
setItems( items: GridBoxItem[] ) {
|
|
298
|
-
items.forEach( x => {
|
|
299
|
-
x.item.setStyle( {
|
|
300
|
-
gridColumn: (x.col+1)+"",
|
|
301
|
-
gridRow: (x.row+1)+"",
|
|
302
|
-
} );
|
|
303
|
-
});
|
|
304
|
-
|
|
305
|
-
this.setContent( items.map( x => x.item ) );
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
// :: MASONRY ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
|
311
|
-
|
|
312
|
-
// from a nice article of Andy Barefoot
|
|
313
|
-
// https://medium.com/@andybarefoot/a-masonry-style-layout-using-css-grid-8c663d355ebb
|
|
314
|
-
|
|
315
|
-
interface MasonryProps extends Omit<BoxProps,"content"> {
|
|
316
|
-
items: Component[];
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
@class_ns("x4")
|
|
320
|
-
export class MasonryBox extends Box<MasonryProps> {
|
|
321
|
-
|
|
322
|
-
constructor(props: MasonryProps ) {
|
|
323
|
-
super(props);
|
|
324
|
-
|
|
325
|
-
this.addDOMEvent( 'resized', () => {
|
|
326
|
-
this.resizeAllItems( );
|
|
327
|
-
});
|
|
328
|
-
|
|
329
|
-
if( props.items ) {
|
|
330
|
-
this.setItems( props.items );
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
resizeItem(item: Component) {
|
|
335
|
-
const style = this.getComputedStyle();
|
|
336
|
-
|
|
337
|
-
const rowHeight = parseInt(style['gridAutoRows']);
|
|
338
|
-
const rowGap = parseInt(style['rowGap']);
|
|
339
|
-
|
|
340
|
-
let content = item.query('.content');
|
|
341
|
-
if( !content ) {
|
|
342
|
-
content = item;
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
if (content && (rowHeight + rowGap)) {
|
|
346
|
-
const rc = content.getBoundingRect();
|
|
347
|
-
const rowSpan = Math.ceil( (rc.height + rowGap) / (rowHeight + rowGap) );
|
|
348
|
-
item.setStyleValue('gridRowEnd', "span " + rowSpan);
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
resizeAllItems( ) {
|
|
353
|
-
const els = this.queryAll( ".item" );
|
|
354
|
-
els.forEach( itm => {;
|
|
355
|
-
this.resizeItem( itm );
|
|
356
|
-
} );
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
setItems( items: Component[] ) {
|
|
360
|
-
const els = items.map( x => {
|
|
361
|
-
return new Box( {
|
|
362
|
-
cls: 'item',
|
|
363
|
-
content: x
|
|
364
|
-
} );
|
|
365
|
-
});
|
|
366
|
-
|
|
367
|
-
this.setContent( els );
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
:root {
|
|
3
|
-
--breadcrumbs-background: var( --background-primary );
|
|
4
|
-
--breadcrumbs-icon-color: var( --text-ternary );
|
|
5
|
-
--breadcrumbs-link-color: var( --text-ternary );
|
|
6
|
-
--breadcrumbs-active-color: var( --accent-background );
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
.x4breadcrumbs {
|
|
10
|
-
background-color: var( --breadcrumbs-background );
|
|
11
|
-
border-bottom: 1px solid var( --border );
|
|
12
|
-
padding: 8px 0;
|
|
13
|
-
margin-bottom: 2em;
|
|
14
|
-
|
|
15
|
-
&> .x4button {
|
|
16
|
-
border: none;
|
|
17
|
-
background-color: transparent;
|
|
18
|
-
color: var( --breadcrumbs-link-color );
|
|
19
|
-
padding: 6px 8px;
|
|
20
|
-
padding-right: 0;
|
|
21
|
-
min-width: 60px;
|
|
22
|
-
|
|
23
|
-
#icon {
|
|
24
|
-
fill: var( --breadcrumbs-icon-color );
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
&:not(:last-child):after {
|
|
28
|
-
content: ">"
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
&:hover:not(:last-child) {
|
|
32
|
-
background-color: transparent;
|
|
33
|
-
color: var( --accent-background );
|
|
34
|
-
fill: var( --accent-background );
|
|
35
|
-
border-bottom-color: var( --breadcrumbs-link-color );
|
|
36
|
-
#text {
|
|
37
|
-
text-decoration: underline;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
&:last-child {
|
|
42
|
-
font-weight: bold;
|
|
43
|
-
color: var( --breadcrumbs-active-color );
|
|
44
|
-
|
|
45
|
-
#icon {
|
|
46
|
-
fill: var( --breadcrumbs-active-color );
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
cursor: auto;
|
|
50
|
-
&:hover {
|
|
51
|
-
background-color: transparent;
|
|
52
|
-
color: var( --breadcrumbs-link-color );
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ___ ___ __
|
|
3
|
-
* \ \/ / / _
|
|
4
|
-
* \ / /_| |_
|
|
5
|
-
* / \____ _|
|
|
6
|
-
* /__/\__\ |_|
|
|
7
|
-
*
|
|
8
|
-
* @file breadcrumb.ts
|
|
9
|
-
* @author Etienne Cochard
|
|
10
|
-
*
|
|
11
|
-
* @copyright (c) 2024 R-libre ingenierie
|
|
12
|
-
*
|
|
13
|
-
* Use of this source code is governed by an MIT-style license
|
|
14
|
-
* that can be found in the LICENSE file or at https://opensource.org/licenses/MIT.
|
|
15
|
-
**/
|
|
16
|
-
|
|
17
|
-
import { class_ns } from '@core/core_tools.js';
|
|
18
|
-
import { parseRoute, Router } from '@core/core_router.js';
|
|
19
|
-
|
|
20
|
-
import { BoxProps, Button, HBox, Icon } from '../components';
|
|
21
|
-
import { Component, ComponentEvents, EvClick } from '@core/component.js';
|
|
22
|
-
import { EventCallback } from '@core/core_events.js';
|
|
23
|
-
|
|
24
|
-
import "./breadcrumb.scss"
|
|
25
|
-
|
|
26
|
-
import icon_sep from "./chevron-right.svg"
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Breadcrumb events
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
interface BreadcrumbEvents extends ComponentEvents {
|
|
33
|
-
click: EvClick; // context = item name
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
*
|
|
38
|
-
*/
|
|
39
|
-
|
|
40
|
-
interface BreadcrumbElement {
|
|
41
|
-
name?: string;
|
|
42
|
-
icon?: string;
|
|
43
|
-
label: string;
|
|
44
|
-
click?: ( name: string ) => void;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
*
|
|
49
|
-
*/
|
|
50
|
-
|
|
51
|
-
interface BreadcrumbsProps extends BoxProps{
|
|
52
|
-
items: BreadcrumbElement[];
|
|
53
|
-
click?: EventCallback<EvClick>;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
*
|
|
58
|
-
*/
|
|
59
|
-
|
|
60
|
-
@class_ns( "x4" )
|
|
61
|
-
export class Breadcrumbs extends HBox<BreadcrumbsProps,BreadcrumbEvents> {
|
|
62
|
-
|
|
63
|
-
constructor( props: BreadcrumbsProps ) {
|
|
64
|
-
super( props );
|
|
65
|
-
|
|
66
|
-
this.mapPropEvents( props, "click" );
|
|
67
|
-
|
|
68
|
-
if( props.items ) {
|
|
69
|
-
this.setItems( props.items );
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
setItems( elements: BreadcrumbElement[ ] ) {
|
|
74
|
-
|
|
75
|
-
const items = elements.map( itm => {
|
|
76
|
-
return new Button( {
|
|
77
|
-
label: itm.label,
|
|
78
|
-
icon: itm.icon,
|
|
79
|
-
click: ( ) => {
|
|
80
|
-
if( itm.click ) {
|
|
81
|
-
itm.click( itm.name );
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
this.fire( "click", { context: itm.name } );
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
})
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
this.setContent( items );
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512"><!--!Font Awesome Pro 6.6.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2024 Fonticons, Inc.--><path d="M299.3 244.7c6.2 6.2 6.2 16.4 0 22.6l-192 192c-6.2 6.2-16.4 6.2-22.6 0s-6.2-16.4 0-22.6L265.4 256 84.7 75.3c-6.2-6.2-6.2-16.4 0-22.6s16.4-6.2 22.6 0l192 192z"/></svg>
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ___ ___ __
|
|
3
|
-
* \ \/ / / _
|
|
4
|
-
* \ / /_| |_
|
|
5
|
-
* / \____ _|
|
|
6
|
-
* /__/\__\ |_|
|
|
7
|
-
*
|
|
8
|
-
* @file btngroup.model.scss
|
|
9
|
-
* @author Etienne Cochard
|
|
10
|
-
*
|
|
11
|
-
* @copyright (c) 2024 R-libre ingenierie
|
|
12
|
-
*
|
|
13
|
-
* Use of this source code is governed by an MIT-style license
|
|
14
|
-
* that can be found in the LICENSE file or at https://opensource.org/licenses/MIT.
|
|
15
|
-
**/
|
|
16
|
-
|
|
17
|
-
:root {
|
|
18
|
-
--btngroup-background: white;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
.x4btngroup {
|
|
22
|
-
align-content: start;
|
|
23
|
-
margin: 5px;
|
|
24
|
-
gap: 4px;
|
|
25
|
-
|
|
26
|
-
background: var( --btngroup-background );
|
|
27
|
-
|
|
28
|
-
&.align-right {
|
|
29
|
-
justify-content: end;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
&.align-center {
|
|
33
|
-
justify-content: center;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
.x4button:disabled {
|
|
37
|
-
.fa-primary {
|
|
38
|
-
fill: var( --border );
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ___ ___ __
|
|
3
|
-
* \ \/ / / _
|
|
4
|
-
* \ / /_| |_
|
|
5
|
-
* / \____ _|
|
|
6
|
-
* /__/\__\ |_|
|
|
7
|
-
*
|
|
8
|
-
* @file btngroup.ts
|
|
9
|
-
* @author Etienne Cochard
|
|
10
|
-
*
|
|
11
|
-
* @copyright (c) 2024 R-libre ingenierie
|
|
12
|
-
*
|
|
13
|
-
* Use of this source code is governed by an MIT-style license
|
|
14
|
-
* that can be found in the LICENSE file or at https://opensource.org/licenses/MIT.
|
|
15
|
-
**/
|
|
16
|
-
|
|
17
|
-
import { Component, ComponentEvents, ComponentProps, Flex, Space } from '../../core/component';
|
|
18
|
-
import { EventCallback } from '../../core/core_events';
|
|
19
|
-
import { class_ns, isString } from '../../core/core_tools';
|
|
20
|
-
import { _tr } from '../../core/core_i18n'
|
|
21
|
-
|
|
22
|
-
import { Button } from '../button/button';
|
|
23
|
-
import { Box } from '../boxes/boxes.js';
|
|
24
|
-
import { Label } from '../label/label.js';
|
|
25
|
-
import { EvBtnClick } from '../dialog/dialog.js';
|
|
26
|
-
|
|
27
|
-
import "./btngroup.module.scss"
|
|
28
|
-
import { Input } from '../components.js';
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* accept "ok" or "ok.<classname>"
|
|
32
|
-
*/
|
|
33
|
-
|
|
34
|
-
type predefined = `ok${ "" | `.${string}`}`
|
|
35
|
-
| `cancel${ "" | `.${string}`}`
|
|
36
|
-
| `yes${ "" | `.${string}`}`
|
|
37
|
-
| `no${ "" | `.${string}`}`
|
|
38
|
-
| `retry${ "" | `.${string}`}`
|
|
39
|
-
| `abort${ "" | `.${string}`}`
|
|
40
|
-
| "-" | ">>" // - = Flex
|
|
41
|
-
| "~"; // space
|
|
42
|
-
|
|
43
|
-
export type BtnGroupItem = predefined | Button | Label | Input;
|
|
44
|
-
|
|
45
|
-
interface BtnGroupEvents extends ComponentEvents {
|
|
46
|
-
btnclick: EvBtnClick;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
interface BtnGroupProps extends Omit<ComponentProps,"content"> {
|
|
50
|
-
align?: "left" | "center" | "right"; // left default
|
|
51
|
-
vertical?: boolean;
|
|
52
|
-
items: BtnGroupItem[];
|
|
53
|
-
reverse?: boolean,
|
|
54
|
-
btnclick?: EventCallback<EvBtnClick>;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
*
|
|
59
|
-
*/
|
|
60
|
-
|
|
61
|
-
@class_ns( "x4" )
|
|
62
|
-
export class BtnGroup extends Box<BtnGroupProps,BtnGroupEvents> {
|
|
63
|
-
|
|
64
|
-
constructor( props: BtnGroupProps ) {
|
|
65
|
-
super( props );
|
|
66
|
-
|
|
67
|
-
if( props.align ) {
|
|
68
|
-
this.addClass( "align-"+props.align );
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
this.addClass( props.vertical ? "x4vbox" : "x4hbox" );
|
|
72
|
-
|
|
73
|
-
if( props.items ) {
|
|
74
|
-
this.setButtons( props.items );
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
this.mapPropEvents( props, "btnclick" );
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
*
|
|
82
|
-
* @param btns
|
|
83
|
-
*/
|
|
84
|
-
|
|
85
|
-
setButtons( btns: BtnGroupItem[] ) {
|
|
86
|
-
|
|
87
|
-
this.clearContent( );
|
|
88
|
-
|
|
89
|
-
const childs: Component[] = [];
|
|
90
|
-
|
|
91
|
-
const hasOption = ( options: string[], value: string ) => {
|
|
92
|
-
const idx = options.indexOf( value );
|
|
93
|
-
if( idx>=0 ) {
|
|
94
|
-
options.splice( idx, 1 );
|
|
95
|
-
return true;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
btns?.forEach( (b: string | Component) => {
|
|
101
|
-
|
|
102
|
-
if( b==="-" || b===">>" ) {
|
|
103
|
-
b = new Flex( );
|
|
104
|
-
}
|
|
105
|
-
else if( b=='~' ) {
|
|
106
|
-
b = new Space( "1em" );
|
|
107
|
-
}
|
|
108
|
-
else if( isString(b) ) {
|
|
109
|
-
let title: string;
|
|
110
|
-
|
|
111
|
-
const nm = (b as predefined);
|
|
112
|
-
|
|
113
|
-
let [txt,...def] = nm.split( "." );
|
|
114
|
-
|
|
115
|
-
let cls = "";
|
|
116
|
-
switch( txt as predefined ) {
|
|
117
|
-
case "ok": title = _tr.global.ok; break;
|
|
118
|
-
case "cancel": title = _tr.global.cancel; break;
|
|
119
|
-
case "abort": title = _tr.global.abort; break;
|
|
120
|
-
case "no": title = _tr.global.no; break;
|
|
121
|
-
case "yes": title = _tr.global.yes; break;
|
|
122
|
-
case "retry": title = _tr.global.retry; break;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
b = new Button( { cls, id: txt, label: title, click: ( ) => {
|
|
126
|
-
this.fire( "btnclick", {button:txt as string} )
|
|
127
|
-
} } );
|
|
128
|
-
|
|
129
|
-
if( hasOption( def, "default" ) ) {
|
|
130
|
-
b.addClass( 'default' );
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
if( hasOption( def, "autofocus" ) ) {
|
|
134
|
-
b.setAttribute( 'autofocus', true );
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
if( hasOption( def, "disabled" ) ) {
|
|
138
|
-
b.enable( false );
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
b.addClass( def.join(" ") );
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
childs.push( b );
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
super.setContent( childs );
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
getButton( id: string ) {
|
|
151
|
-
return this.query<Button>( '#'+id );
|
|
152
|
-
}
|
|
153
|
-
}
|