x4js 2.0.13 → 2.0.15
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/.vscode/launch.json +14 -0
- package/README.md +5 -0
- package/{lib/src/demo → demo}/main.scss +3 -1
- package/{lib/src/demo/main.tsx → demo/main.ts} +37 -36
- package/demo/package.json +26 -0
- package/demo/scss.d.ts +4 -0
- package/demo/svg.d.ts +1 -0
- package/demo/tsconfig.json +14 -0
- package/lib/README.txt +5 -0
- package/lib/cjs/x4.css +1 -1
- package/lib/cjs/x4.js +2 -1
- package/lib/esm/x4.css +1 -1
- package/lib/esm/x4.mjs +2 -1
- package/lib/src/components/boxes/boxes.module.scss +17 -0
- package/lib/src/components/boxes/boxes.ts +258 -17
- package/lib/src/components/breadcrumb/breadcrumb.scss +56 -28
- package/lib/src/components/breadcrumb/breadcrumb.ts +93 -84
- package/lib/src/components/btngroup/btngroup.module.scss +12 -0
- package/lib/src/components/btngroup/btngroup.ts +41 -8
- package/lib/src/components/button/button.module.scss +23 -5
- package/lib/src/components/button/button.ts +72 -4
- package/lib/src/components/canvas/canvas.module.scss +25 -0
- package/lib/src/components/canvas/canvas.ts +189 -0
- package/lib/src/components/canvas/canvas_ex.ts +276 -0
- package/lib/src/components/checkbox/checkbox.ts +18 -4
- package/lib/src/components/combobox/combobox.module.scss +24 -15
- package/lib/src/components/combobox/combobox.ts +107 -24
- package/lib/src/components/components.ts +7 -0
- package/lib/src/components/dialog/dialog.module.scss +40 -7
- package/lib/src/components/dialog/dialog.ts +166 -31
- package/lib/src/components/filedrop/cloud-arrow-up.svg +1 -0
- package/lib/src/components/filedrop/filedrop.module.scss +70 -0
- package/lib/src/components/filedrop/filedrop.ts +131 -0
- package/lib/src/components/form/form.module.scss +4 -0
- package/lib/src/components/form/form.ts +137 -6
- package/lib/src/components/gridview/arrow-down-light.svg +1 -0
- package/lib/src/components/gridview/arrow-up-light.svg +1 -0
- package/lib/src/components/gridview/gridview.module.scss +324 -0
- package/lib/src/components/gridview/gridview.ts +1175 -0
- package/lib/src/components/icon/icon.module.scss +2 -1
- package/lib/src/components/icon/icon.ts +4 -3
- package/lib/src/components/image/image.module.scss +8 -1
- package/lib/src/components/image/image.ts +105 -6
- package/lib/src/components/input/input.module.scss +8 -3
- package/lib/src/components/input/input.ts +178 -31
- package/lib/src/components/keyboard/arrow-up.svg +1 -0
- package/lib/src/components/keyboard/delete-left.svg +1 -0
- package/lib/src/components/keyboard/eye-slash.svg +1 -0
- package/lib/src/components/keyboard/keyboard.module.scss +134 -0
- package/lib/src/components/keyboard/keyboard.ts +526 -0
- package/lib/src/components/label/label.module.scss +22 -4
- package/lib/src/components/label/label.ts +33 -0
- package/lib/src/components/link/link.ts +81 -78
- package/lib/src/components/listbox/listbox.module.scss +61 -3
- package/lib/src/components/listbox/listbox.ts +164 -56
- package/lib/src/components/menu/menu.module.scss +10 -1
- package/lib/src/components/menu/menu.ts +6 -3
- package/lib/src/components/messages/messages.module.scss +44 -0
- package/lib/src/components/messages/messages.ts +164 -18
- package/lib/src/components/messages/pen-field.svg +1 -0
- package/lib/src/components/normalize.scss +5 -0
- package/lib/src/components/notification/notification.module.scss +4 -2
- package/lib/src/components/notification/notification.ts +2 -4
- package/lib/src/components/panel/panel.module.scss +12 -0
- package/lib/src/components/popup/popup.module.scss +10 -2
- package/lib/src/components/popup/popup.ts +141 -95
- package/lib/src/components/propgrid/folder-closed.svg +1 -0
- package/lib/src/components/propgrid/folder-open.svg +1 -0
- package/lib/src/components/propgrid/progrid.module.scss +112 -0
- package/lib/src/components/propgrid/propgrid.ts +288 -0
- package/lib/src/components/propgrid/updown.svg +4 -0
- package/lib/src/components/radio/radio.module.scss +147 -0
- package/lib/src/components/radio/radio.svg +4 -0
- package/lib/src/components/radio/radio.ts +142 -0
- package/lib/src/components/select/select.module.scss +9 -0
- package/lib/src/components/select/select.ts +134 -0
- package/lib/src/components/shared.scss +47 -0
- package/lib/src/components/sizers/sizer.ts +10 -2
- package/lib/src/components/slider/slider.module.scss +77 -30
- package/lib/src/components/slider/slider.ts +72 -22
- package/lib/src/components/tabs/tabs.module.scss +1 -2
- package/lib/src/components/tabs/tabs.ts +49 -12
- package/lib/src/components/textarea/textarea.module.scss +6 -2
- package/lib/src/components/textarea/textarea.ts +73 -8
- package/lib/src/components/textedit/textedit.module.scss +3 -1
- package/lib/src/components/textedit/textedit.ts +47 -15
- package/lib/src/components/themes.scss +7 -0
- package/lib/src/components/tickline/tickline.module.scss +26 -0
- package/lib/src/components/tickline/tickline.ts +82 -0
- package/lib/src/components/tooltips/comments-question.svg +1 -0
- package/lib/src/components/tooltips/tooltips.scss +30 -9
- package/lib/src/components/tooltips/tooltips.ts +10 -5
- package/lib/src/components/treeview/treeview.module.scss +129 -60
- package/lib/src/components/treeview/treeview.ts +47 -12
- package/lib/src/components/viewport/viewport.module.scss +7 -0
- package/lib/src/core/component.ts +113 -40
- package/lib/src/core/core_application.ts +223 -2
- package/lib/src/core/core_colors.ts +2 -2
- package/lib/src/{components/grid/datastore.ts → core/core_data.ts} +264 -252
- package/lib/src/core/core_dragdrop.ts +3 -3
- package/lib/src/core/core_element.ts +18 -1
- package/lib/src/core/core_events.ts +28 -0
- package/lib/src/core/core_i18n.ts +19 -3
- package/lib/src/core/core_react.ts +79 -0
- package/lib/src/core/core_router.ts +25 -9
- package/lib/src/core/core_state.ts +62 -0
- package/lib/src/core/core_styles.ts +5 -5
- package/lib/src/core/core_svg.ts +174 -12
- package/lib/src/core/core_tools.ts +305 -87
- package/lib/src/x4tsx.d.ts +25 -0
- package/lib/styles/x4.css +1 -1
- package/lib/types/x4js.d.ts +828 -119
- package/package.json +4 -4
- package/scripts/build.mjs +378 -0
- package/scripts/prepack.mjs +346 -0
- package/src/components/base.scss +25 -0
- package/src/components/boxes/boxes.module.scss +54 -0
- package/src/components/boxes/boxes.ts +370 -0
- package/src/components/breadcrumb/breadcrumb.scss +56 -0
- package/src/components/breadcrumb/breadcrumb.ts +93 -0
- package/src/components/breadcrumb/chevron-right.svg +1 -0
- package/src/components/btngroup/btngroup.module.scss +41 -0
- package/src/components/btngroup/btngroup.ts +153 -0
- package/src/components/button/button.module.scss +173 -0
- package/src/components/button/button.ts +185 -0
- package/src/components/calendar/calendar-check-sharp-light.svg +1 -0
- package/src/components/calendar/calendar.module.scss +163 -0
- package/src/components/calendar/calendar.ts +327 -0
- package/src/components/calendar/chevron-left-sharp-light.svg +1 -0
- package/src/components/calendar/chevron-right-sharp-light.svg +1 -0
- package/src/components/canvas/canvas.module.scss +25 -0
- package/src/components/canvas/canvas.ts +189 -0
- package/src/components/canvas/canvas_ex.ts +276 -0
- package/src/components/checkbox/check.svg +4 -0
- package/src/components/checkbox/checkbox.module.scss +142 -0
- package/src/components/checkbox/checkbox.ts +140 -0
- package/src/components/colorinput/colorinput.module.scss +65 -0
- package/src/components/colorinput/colorinput.ts +91 -0
- package/src/components/colorinput/crosshairs-simple-sharp-light.svg +1 -0
- package/src/components/colorpicker/colorpicker.module.scss +133 -0
- package/src/components/colorpicker/colorpicker.ts +482 -0
- package/src/components/combobox/combobox.module.scss +133 -0
- package/src/components/combobox/combobox.ts +275 -0
- package/src/components/combobox/updown.svg +4 -0
- package/src/components/components.ts +41 -0
- package/src/components/dialog/dialog.module.scss +104 -0
- package/src/components/dialog/dialog.ts +229 -0
- package/src/components/dialog/xmark-sharp-light.svg +1 -0
- package/src/components/filedrop/cloud-arrow-up.svg +1 -0
- package/src/components/filedrop/filedrop.module.scss +70 -0
- package/src/components/filedrop/filedrop.ts +131 -0
- package/src/components/form/form.module.scss +38 -0
- package/src/components/form/form.ts +172 -0
- package/src/components/gridview/arrow-down-light.svg +1 -0
- package/src/components/gridview/arrow-up-light.svg +1 -0
- package/src/components/gridview/gridview.module.scss +324 -0
- package/src/components/gridview/gridview.ts +1175 -0
- package/src/components/header/header.module.scss +40 -0
- package/src/components/header/header.ts +130 -0
- package/src/components/icon/icon.module.scss +31 -0
- package/src/components/icon/icon.ts +137 -0
- package/src/components/image/image.module.scss +28 -0
- package/src/components/image/image.ts +168 -0
- package/src/components/input/input.module.scss +74 -0
- package/src/components/input/input.ts +422 -0
- package/src/components/keyboard/arrow-up.svg +1 -0
- package/src/components/keyboard/delete-left.svg +1 -0
- package/src/components/keyboard/eye-slash.svg +1 -0
- package/src/components/keyboard/keyboard.module.scss +134 -0
- package/src/components/keyboard/keyboard.ts +526 -0
- package/src/components/label/label.module.scss +76 -0
- package/src/components/label/label.ts +97 -0
- package/src/components/link/link.ts +81 -0
- package/src/components/listbox/listbox.module.scss +161 -0
- package/src/components/listbox/listbox.ts +539 -0
- package/src/components/menu/caret-right-solid.svg +1 -0
- package/src/components/menu/menu.module.scss +117 -0
- package/src/components/menu/menu.ts +174 -0
- package/src/components/messages/circle-exclamation.svg +1 -0
- package/src/components/messages/messages.module.scss +92 -0
- package/src/components/messages/messages.ts +215 -0
- package/src/components/messages/pen-field.svg +1 -0
- package/src/components/normalize.scss +391 -0
- package/src/components/notification/circle-check-solid.svg +1 -0
- package/src/components/notification/circle-exclamation-solid.svg +1 -0
- package/src/components/notification/circle-notch-light.svg +1 -0
- package/src/components/notification/notification.module.scss +84 -0
- package/src/components/notification/notification.ts +107 -0
- package/src/components/notification/xmark-sharp-light.svg +1 -0
- package/src/components/panel/panel.module.scss +60 -0
- package/src/components/panel/panel.ts +58 -0
- package/src/components/popup/popup.module.scss +51 -0
- package/src/components/popup/popup.ts +442 -0
- package/src/components/progress/progress.module.scss +57 -0
- package/src/components/progress/progress.ts +44 -0
- package/src/components/propgrid/folder-closed.svg +1 -0
- package/src/components/propgrid/folder-open.svg +1 -0
- package/src/components/propgrid/progrid.module.scss +112 -0
- package/src/components/propgrid/propgrid.ts +288 -0
- package/src/components/propgrid/updown.svg +4 -0
- package/src/components/radio/radio.module.scss +147 -0
- package/src/components/radio/radio.svg +4 -0
- package/src/components/radio/radio.ts +142 -0
- package/src/components/rating/rating.module.scss +23 -0
- package/src/components/rating/rating.ts +131 -0
- package/src/components/rating/star-sharp-light.svg +1 -0
- package/src/components/rating/star-sharp-solid.svg +1 -0
- package/src/components/select/select.module.scss +9 -0
- package/src/components/select/select.ts +134 -0
- package/src/components/shared.scss +137 -0
- package/src/components/sizers/sizer.module.scss +90 -0
- package/src/components/sizers/sizer.ts +132 -0
- package/src/components/slider/slider.module.scss +118 -0
- package/src/components/slider/slider.ts +198 -0
- package/src/components/switch/switch.module.scss +127 -0
- package/src/components/switch/switch.ts +62 -0
- package/src/components/tabs/tabs.module.scss +45 -0
- package/src/components/tabs/tabs.ts +205 -0
- package/src/components/textarea/textarea.module.scss +63 -0
- package/src/components/textarea/textarea.ts +125 -0
- package/src/components/textedit/textedit.module.scss +116 -0
- package/src/components/textedit/textedit.ts +115 -0
- package/src/components/themes.scss +88 -0
- package/src/components/tickline/tickline.module.scss +26 -0
- package/src/components/tickline/tickline.ts +82 -0
- package/src/components/tooltips/circle-info-sharp-light.svg +1 -0
- package/src/components/tooltips/comments-question.svg +1 -0
- package/src/components/tooltips/tooltips.scss +72 -0
- package/src/components/tooltips/tooltips.ts +109 -0
- package/src/components/treeview/chevron-down-light.svg +1 -0
- package/src/components/treeview/treeview.module.scss +185 -0
- package/src/components/treeview/treeview.ts +445 -0
- package/src/components/viewport/viewport.module.scss +32 -0
- package/src/components/viewport/viewport.ts +41 -0
- package/src/core/component.ts +1075 -0
- package/src/core/core_application.ts +265 -0
- package/src/core/core_colors.ts +250 -0
- package/src/core/core_data.ts +1310 -0
- package/src/core/core_dom.ts +471 -0
- package/src/core/core_dragdrop.ts +201 -0
- package/src/core/core_element.ts +115 -0
- package/src/core/core_events.ts +177 -0
- package/src/core/core_i18n.ts +393 -0
- package/src/core/core_react.ts +79 -0
- package/src/core/core_router.ts +237 -0
- package/src/core/core_state.ts +62 -0
- package/src/core/core_styles.ts +214 -0
- package/src/core/core_svg.ts +712 -0
- package/src/core/core_tools.ts +906 -0
- package/src/types/scss.d.ts +4 -0
- package/src/types/svg.d.ts +1 -0
- package/src/types/x4react.d.ts +9 -0
- package/src/x4.scss +19 -0
- package/src/x4tsx.d.ts +25 -0
- package/tsconfig.json +14 -0
- package/lib/src/components/grid/gridview.ts +0 -1108
- package/lib/src/components/grid/memdb.ts +0 -325
- /package/{lib/src/demo → demo}/assets/house-light.svg +0 -0
- /package/{lib/src/demo → demo}/assets/radio.svg +0 -0
- /package/{lib/src/demo → demo}/index.html +0 -0
|
@@ -0,0 +1,370 @@
|
|
|
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
|
+
|
|
@@ -0,0 +1,56 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
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
|
+
|
|
@@ -0,0 +1 @@
|
|
|
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>
|
|
@@ -0,0 +1,41 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,153 @@
|
|
|
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
|
+
}
|