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
|
@@ -18,6 +18,9 @@
|
|
|
18
18
|
|
|
19
19
|
.x4hbox {
|
|
20
20
|
@extend .hbox;
|
|
21
|
+
&.align-start {
|
|
22
|
+
align-items: start;
|
|
23
|
+
}
|
|
21
24
|
}
|
|
22
25
|
|
|
23
26
|
.x4vbox {
|
|
@@ -25,6 +28,8 @@
|
|
|
25
28
|
}
|
|
26
29
|
|
|
27
30
|
.x4stackbox {
|
|
31
|
+
display: flex;
|
|
32
|
+
|
|
28
33
|
&>* {
|
|
29
34
|
@extend .fit;
|
|
30
35
|
position: relative !important;
|
|
@@ -35,3 +40,15 @@
|
|
|
35
40
|
}
|
|
36
41
|
}
|
|
37
42
|
|
|
43
|
+
.x4gridbox {
|
|
44
|
+
display: grid;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.x4masonrybox {
|
|
48
|
+
display: grid;
|
|
49
|
+
grid-gap: 10px;
|
|
50
|
+
grid-template-columns: repeat(auto-fill, minmax(250px,1fr));
|
|
51
|
+
grid-auto-rows: 10px;
|
|
52
|
+
|
|
53
|
+
overflow: hidden;
|
|
54
|
+
}
|
|
@@ -14,12 +14,14 @@
|
|
|
14
14
|
* that can be found in the LICENSE file or at https://opensource.org/licenses/MIT.
|
|
15
15
|
**/
|
|
16
16
|
|
|
17
|
-
import { class_ns } from '@core/core_tools.js';
|
|
18
|
-
import { Component, ComponentEvents, ComponentProps } from "../../core/component"
|
|
17
|
+
import { asap, class_ns, isArray, isNumber, isString } from '@core/core_tools.js';
|
|
18
|
+
import { Component, ComponentContent, ComponentEvents, ComponentProps, EvSelectionChange } from "../../core/component"
|
|
19
19
|
|
|
20
20
|
import "./boxes.module.scss";
|
|
21
|
+
import { EventCallback } from '@core/core_events.js';
|
|
21
22
|
|
|
22
23
|
export interface BoxProps extends ComponentProps {
|
|
24
|
+
tag?: string;
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
/**
|
|
@@ -55,29 +57,53 @@ export class VBox<P extends BoxProps=BoxProps,E extends ComponentEvents=Componen
|
|
|
55
57
|
* stack of widgets where only one widget is visible at a time
|
|
56
58
|
*/
|
|
57
59
|
|
|
60
|
+
type ContentBuilder = ( ) => Component;
|
|
61
|
+
|
|
58
62
|
interface StackItem {
|
|
59
63
|
name: string;
|
|
60
|
-
content: Component;
|
|
64
|
+
content: Component | ContentBuilder;
|
|
65
|
+
title?: string;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
*
|
|
70
|
+
*/
|
|
71
|
+
|
|
72
|
+
interface StackeBoxEvents extends ComponentEvents {
|
|
73
|
+
pageChange?: EvSelectionChange;
|
|
61
74
|
}
|
|
62
75
|
|
|
63
|
-
interface
|
|
76
|
+
export interface StackBoxProps extends Omit<ComponentProps,"content"> {
|
|
64
77
|
default: string;
|
|
65
78
|
items: StackItem[];
|
|
79
|
+
pageChange?: EventCallback<EvSelectionChange>;
|
|
66
80
|
}
|
|
67
81
|
|
|
68
|
-
|
|
82
|
+
/**
|
|
83
|
+
*
|
|
84
|
+
*/
|
|
85
|
+
|
|
86
|
+
interface StackItemEx extends StackItem {
|
|
69
87
|
page: Component;
|
|
70
88
|
}
|
|
71
89
|
|
|
90
|
+
/**
|
|
91
|
+
*
|
|
92
|
+
*/
|
|
93
|
+
|
|
72
94
|
@class_ns( "x4" )
|
|
73
|
-
export class StackBox extends Box<
|
|
74
|
-
|
|
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;
|
|
75
99
|
|
|
76
|
-
constructor( props:
|
|
100
|
+
constructor( props: StackBoxProps ) {
|
|
77
101
|
super( props );
|
|
78
102
|
|
|
103
|
+
this.mapPropEvents( props, "pageChange" );
|
|
104
|
+
|
|
79
105
|
this._items = props.items?.map( itm => {
|
|
80
|
-
return { ...itm, page: null };
|
|
106
|
+
return { ...itm, page: null as any};
|
|
81
107
|
});
|
|
82
108
|
|
|
83
109
|
if( props.default ) {
|
|
@@ -88,13 +114,23 @@ export class StackBox extends Box<StackedLayoutProps> {
|
|
|
88
114
|
}
|
|
89
115
|
}
|
|
90
116
|
|
|
117
|
+
addItem( item: StackItem ) {
|
|
118
|
+
this._items.push( {
|
|
119
|
+
name: item.name,
|
|
120
|
+
content: item.content,
|
|
121
|
+
page: null
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
|
|
91
125
|
select( name: string ) {
|
|
92
|
-
let sel = this.query(
|
|
126
|
+
let sel = this.query( `:scope > .selected` );
|
|
93
127
|
if( sel ) {
|
|
94
128
|
sel.setClass( "selected", false );
|
|
95
129
|
}
|
|
96
130
|
|
|
97
|
-
|
|
131
|
+
this._cur = this._items.findIndex( x => x.name==name );
|
|
132
|
+
const pg = this._items[this._cur];
|
|
133
|
+
|
|
98
134
|
if( pg ) {
|
|
99
135
|
if( !pg.page ) {
|
|
100
136
|
pg.page = this._createPage( pg );
|
|
@@ -103,27 +139,232 @@ export class StackBox extends Box<StackedLayoutProps> {
|
|
|
103
139
|
|
|
104
140
|
sel = pg.page;
|
|
105
141
|
if( sel ) {
|
|
142
|
+
(sel as any).activate?.( );
|
|
106
143
|
sel.setClass( "selected", true );
|
|
107
144
|
}
|
|
145
|
+
|
|
146
|
+
asap( ( ) => this.fire( "pageChange", { selection: pg.name, empty: !sel } ) );
|
|
108
147
|
}
|
|
148
|
+
|
|
149
|
+
return pg?.page;
|
|
109
150
|
}
|
|
110
151
|
|
|
111
152
|
/**
|
|
112
153
|
*
|
|
113
154
|
*/
|
|
114
155
|
|
|
115
|
-
private _createPage( page:
|
|
156
|
+
private _createPage( page: StackItemEx ) {
|
|
116
157
|
|
|
117
158
|
let content: Component;
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
159
|
+
if( page.content instanceof Function ) {
|
|
160
|
+
content = page.content( );
|
|
161
|
+
page.content = content; // keep it
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
122
164
|
content = page.content;
|
|
123
|
-
|
|
165
|
+
}
|
|
124
166
|
|
|
125
167
|
content?.setData( "stackname", page.name );
|
|
126
168
|
return content;
|
|
127
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
|
+
}
|
|
128
369
|
}
|
|
129
370
|
|
|
@@ -1,28 +1,56 @@
|
|
|
1
|
-
|
|
2
|
-
:root {
|
|
3
|
-
--
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
border
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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,84 +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 {
|
|
19
|
-
|
|
20
|
-
import {
|
|
21
|
-
|
|
22
|
-
import
|
|
23
|
-
|
|
24
|
-
import
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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
|
+
|
|
@@ -14,11 +14,17 @@
|
|
|
14
14
|
* that can be found in the LICENSE file or at https://opensource.org/licenses/MIT.
|
|
15
15
|
**/
|
|
16
16
|
|
|
17
|
+
:root {
|
|
18
|
+
--btngroup-background: white;
|
|
19
|
+
}
|
|
20
|
+
|
|
17
21
|
.x4btngroup {
|
|
18
22
|
align-content: start;
|
|
19
23
|
margin: 5px;
|
|
20
24
|
gap: 4px;
|
|
21
25
|
|
|
26
|
+
background: var( --btngroup-background );
|
|
27
|
+
|
|
22
28
|
&.align-right {
|
|
23
29
|
justify-content: end;
|
|
24
30
|
}
|
|
@@ -26,4 +32,10 @@
|
|
|
26
32
|
&.align-center {
|
|
27
33
|
justify-content: center;
|
|
28
34
|
}
|
|
35
|
+
|
|
36
|
+
.x4button:disabled {
|
|
37
|
+
.fa-primary {
|
|
38
|
+
fill: var( --border );
|
|
39
|
+
}
|
|
40
|
+
}
|
|
29
41
|
}
|