x4js 2.0.1 → 2.0.3
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/package.json +12 -9
- package/lib/README.txt +0 -15
- package/lib/src/assets/house-light.svg +0 -1
- package/lib/src/assets/radio.svg +0 -4
- package/lib/src/components/base.scss +0 -26
- package/lib/src/components/boxes/boxes.module.scss +0 -37
- package/lib/src/components/boxes/boxes.ts +0 -125
- package/lib/src/components/btngroup/btngroup.module.scss +0 -29
- package/lib/src/components/btngroup/btngroup.ts +0 -106
- package/lib/src/components/button/button.module.scss +0 -154
- package/lib/src/components/button/button.ts +0 -117
- 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 -326
- 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/checkbox/check.svg +0 -4
- package/lib/src/components/checkbox/checkbox.module.scss +0 -142
- package/lib/src/components/checkbox/checkbox.ts +0 -125
- package/lib/src/components/colorinput/colorinput.module.scss +0 -65
- package/lib/src/components/colorinput/colorinput.ts +0 -88
- 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 -477
- package/lib/src/components/combobox/combobox.module.scss +0 -121
- package/lib/src/components/combobox/combobox.ts +0 -190
- package/lib/src/components/combobox/updown.svg +0 -4
- package/lib/src/components/dialog/dialog.module.scss +0 -71
- package/lib/src/components/dialog/dialog.ts +0 -91
- package/lib/src/components/dialog/xmark-sharp-light.svg +0 -1
- package/lib/src/components/form/form.module.scss +0 -34
- package/lib/src/components/form/form.ts +0 -36
- package/lib/src/components/header/header.module.scss +0 -40
- package/lib/src/components/header/header.ts +0 -124
- package/lib/src/components/icon/icon.module.scss +0 -30
- package/lib/src/components/icon/icon.ts +0 -134
- package/lib/src/components/image/image.module.scss +0 -21
- package/lib/src/components/image/image.ts +0 -67
- package/lib/src/components/input/input.module.scss +0 -69
- package/lib/src/components/input/input.ts +0 -274
- package/lib/src/components/label/label.module.scss +0 -52
- package/lib/src/components/label/label.ts +0 -55
- package/lib/src/components/listbox/listbox.module.scss +0 -103
- package/lib/src/components/listbox/listbox.ts +0 -427
- package/lib/src/components/menu/caret-right-solid.svg +0 -1
- package/lib/src/components/menu/menu.module.scss +0 -108
- package/lib/src/components/menu/menu.ts +0 -168
- package/lib/src/components/messages/circle-exclamation.svg +0 -1
- package/lib/src/components/messages/messages.module.scss +0 -47
- package/lib/src/components/messages/messages.ts +0 -64
- package/lib/src/components/normalize.scss +0 -386
- 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 -82
- package/lib/src/components/notification/notification.ts +0 -108
- package/lib/src/components/notification/xmark-sharp-light.svg +0 -1
- package/lib/src/components/panel/panel.module.scss +0 -48
- package/lib/src/components/panel/panel.ts +0 -57
- package/lib/src/components/popup/popup.module.scss +0 -43
- package/lib/src/components/popup/popup.ts +0 -395
- package/lib/src/components/progress/progress.module.scss +0 -57
- package/lib/src/components/progress/progress.ts +0 -43
- package/lib/src/components/rating/rating.module.scss +0 -23
- package/lib/src/components/rating/rating.ts +0 -125
- 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/shared.scss +0 -76
- package/lib/src/components/sizers/sizer.module.scss +0 -90
- package/lib/src/components/sizers/sizer.ts +0 -120
- package/lib/src/components/slider/slider.module.scss +0 -71
- package/lib/src/components/slider/slider.ts +0 -143
- package/lib/src/components/switch/switch.module.scss +0 -127
- package/lib/src/components/switch/switch.ts +0 -56
- package/lib/src/components/tabs/tabs.module.scss +0 -46
- package/lib/src/components/tabs/tabs.ts +0 -157
- package/lib/src/components/textarea/textarea.module.scss +0 -59
- package/lib/src/components/textarea/textarea.ts +0 -54
- package/lib/src/components/textedit/textedit.module.scss +0 -114
- package/lib/src/components/textedit/textedit.ts +0 -82
- package/lib/src/components/themes.scss +0 -77
- package/lib/src/components/tooltips/circle-info-sharp-light.svg +0 -1
- package/lib/src/components/tooltips/tooltips.scss +0 -51
- package/lib/src/components/tooltips/tooltips.ts +0 -103
- package/lib/src/components/treeview/chevron-down-light.svg +0 -1
- package/lib/src/components/treeview/treeview.module.scss +0 -116
- package/lib/src/components/treeview/treeview.ts +0 -403
- package/lib/src/components/viewport/viewport.module.scss +0 -25
- package/lib/src/components/viewport/viewport.ts +0 -38
- package/lib/src/core/component.ts +0 -979
- package/lib/src/core/core_colors.ts +0 -250
- 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 -98
- package/lib/src/core/core_events.ts +0 -149
- package/lib/src/core/core_i18n.ts +0 -377
- package/lib/src/core/core_router.ts +0 -221
- package/lib/src/core/core_styles.ts +0 -215
- package/lib/src/core/core_svg.ts +0 -550
- package/lib/src/core/core_tools.ts +0 -673
- package/lib/src/main.scss +0 -21
- package/lib/src/main.tsx +0 -323
- package/lib/src/x4.scss +0 -19
- package/lib/types/x4.d.ts +0 -2624
- package/scripts/build.mjs +0 -351
- package/scripts/prepack.mjs +0 -15
- package/src/assets/house-light.svg +0 -1
- package/src/assets/radio.svg +0 -4
- package/src/components/base.scss +0 -26
- package/src/components/boxes/boxes.module.scss +0 -37
- package/src/components/boxes/boxes.ts +0 -125
- package/src/components/btngroup/btngroup.module.scss +0 -29
- package/src/components/btngroup/btngroup.ts +0 -106
- package/src/components/button/button.module.scss +0 -154
- package/src/components/button/button.ts +0 -117
- package/src/components/calendar/calendar-check-sharp-light.svg +0 -1
- package/src/components/calendar/calendar.module.scss +0 -163
- package/src/components/calendar/calendar.ts +0 -326
- package/src/components/calendar/chevron-left-sharp-light.svg +0 -1
- package/src/components/calendar/chevron-right-sharp-light.svg +0 -1
- package/src/components/checkbox/check.svg +0 -4
- package/src/components/checkbox/checkbox.module.scss +0 -142
- package/src/components/checkbox/checkbox.ts +0 -125
- package/src/components/colorinput/colorinput.module.scss +0 -65
- package/src/components/colorinput/colorinput.ts +0 -88
- package/src/components/colorinput/crosshairs-simple-sharp-light.svg +0 -1
- package/src/components/colorpicker/colorpicker.module.scss +0 -133
- package/src/components/colorpicker/colorpicker.ts +0 -477
- package/src/components/combobox/combobox.module.scss +0 -121
- package/src/components/combobox/combobox.ts +0 -190
- package/src/components/combobox/updown.svg +0 -4
- package/src/components/dialog/dialog.module.scss +0 -71
- package/src/components/dialog/dialog.ts +0 -91
- package/src/components/dialog/xmark-sharp-light.svg +0 -1
- package/src/components/form/form.module.scss +0 -34
- package/src/components/form/form.ts +0 -36
- package/src/components/header/header.module.scss +0 -40
- package/src/components/header/header.ts +0 -124
- package/src/components/icon/icon.module.scss +0 -30
- package/src/components/icon/icon.ts +0 -134
- package/src/components/image/image.module.scss +0 -21
- package/src/components/image/image.ts +0 -67
- package/src/components/input/input.module.scss +0 -69
- package/src/components/input/input.ts +0 -274
- package/src/components/label/label.module.scss +0 -52
- package/src/components/label/label.ts +0 -55
- package/src/components/listbox/listbox.module.scss +0 -103
- package/src/components/listbox/listbox.ts +0 -427
- package/src/components/menu/caret-right-solid.svg +0 -1
- package/src/components/menu/menu.module.scss +0 -108
- package/src/components/menu/menu.ts +0 -168
- package/src/components/messages/circle-exclamation.svg +0 -1
- package/src/components/messages/messages.module.scss +0 -47
- package/src/components/messages/messages.ts +0 -64
- package/src/components/normalize.scss +0 -386
- package/src/components/notification/circle-check-solid.svg +0 -1
- package/src/components/notification/circle-exclamation-solid.svg +0 -1
- package/src/components/notification/circle-notch-light.svg +0 -1
- package/src/components/notification/notification.module.scss +0 -82
- package/src/components/notification/notification.ts +0 -108
- package/src/components/notification/xmark-sharp-light.svg +0 -1
- package/src/components/panel/panel.module.scss +0 -48
- package/src/components/panel/panel.ts +0 -57
- package/src/components/popup/popup.module.scss +0 -43
- package/src/components/popup/popup.ts +0 -395
- package/src/components/progress/progress.module.scss +0 -57
- package/src/components/progress/progress.ts +0 -43
- package/src/components/rating/rating.module.scss +0 -23
- package/src/components/rating/rating.ts +0 -125
- package/src/components/rating/star-sharp-light.svg +0 -1
- package/src/components/rating/star-sharp-solid.svg +0 -1
- package/src/components/shared.scss +0 -76
- package/src/components/sizers/sizer.module.scss +0 -90
- package/src/components/sizers/sizer.ts +0 -120
- package/src/components/slider/slider.module.scss +0 -71
- package/src/components/slider/slider.ts +0 -143
- package/src/components/switch/switch.module.scss +0 -127
- package/src/components/switch/switch.ts +0 -56
- package/src/components/tabs/tabs.module.scss +0 -46
- package/src/components/tabs/tabs.ts +0 -157
- package/src/components/textarea/textarea.module.scss +0 -59
- package/src/components/textarea/textarea.ts +0 -54
- package/src/components/textedit/textedit.module.scss +0 -114
- package/src/components/textedit/textedit.ts +0 -82
- package/src/components/themes.scss +0 -77
- package/src/components/tooltips/circle-info-sharp-light.svg +0 -1
- package/src/components/tooltips/tooltips.scss +0 -51
- package/src/components/tooltips/tooltips.ts +0 -103
- package/src/components/treeview/chevron-down-light.svg +0 -1
- package/src/components/treeview/treeview.module.scss +0 -116
- package/src/components/treeview/treeview.ts +0 -403
- package/src/components/viewport/viewport.module.scss +0 -25
- package/src/components/viewport/viewport.ts +0 -38
- package/src/core/component.ts +0 -979
- package/src/core/core_colors.ts +0 -250
- package/src/core/core_dom.ts +0 -471
- package/src/core/core_dragdrop.ts +0 -201
- package/src/core/core_element.ts +0 -98
- package/src/core/core_events.ts +0 -149
- package/src/core/core_i18n.ts +0 -377
- package/src/core/core_router.ts +0 -221
- package/src/core/core_styles.ts +0 -215
- package/src/core/core_svg.ts +0 -550
- package/src/core/core_tools.ts +0 -673
- package/src/main.scss +0 -21
- package/src/main.tsx +0 -323
- package/src/x4.scss +0 -19
- package/tsconfig.json +0 -14
- package/types/scss.d.ts +0 -4
- package/types/svg.d.ts +0 -4
- package/types/x4react.d.ts +0 -9
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ___ ___ __
|
|
3
|
-
* \ \/ / / _
|
|
4
|
-
* \ / /_| |_
|
|
5
|
-
* / \____ _|
|
|
6
|
-
* /__/\__\ |_|
|
|
7
|
-
*
|
|
8
|
-
* @file treeview.module.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
|
-
--treeitem-backgound: var( );
|
|
19
|
-
--treeitem-color: var( );
|
|
20
|
-
|
|
21
|
-
--treeitem-backgound-hover: var( --background-secondary );
|
|
22
|
-
--treeitem-color-hover: var( );
|
|
23
|
-
|
|
24
|
-
--treeitem-background-sel: var( --accent-background );
|
|
25
|
-
--treeitem-color-sel: var( --accent-color );
|
|
26
|
-
|
|
27
|
-
--treeitem-backgound-active: var( --accent-background-active);
|
|
28
|
-
--treeitem-color-active: var( --accent-color-active );
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
.x4treeview {
|
|
32
|
-
overflow-y: auto;
|
|
33
|
-
height: 100%;
|
|
34
|
-
margin: 5px;
|
|
35
|
-
|
|
36
|
-
outline: none;
|
|
37
|
-
|
|
38
|
-
border: 1px solid var( --border );
|
|
39
|
-
|
|
40
|
-
&:focus {
|
|
41
|
-
border: 1px solid var( --border-focus );
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// child + subitems
|
|
45
|
-
.x4ctreeviewitem {
|
|
46
|
-
&>.label {
|
|
47
|
-
gap: 4px;
|
|
48
|
-
|
|
49
|
-
.x4label, .x4icon {
|
|
50
|
-
color: inherit;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
.x4icon {
|
|
54
|
-
width: 16px;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
padding: 4px;
|
|
58
|
-
|
|
59
|
-
&:hover {
|
|
60
|
-
background-color: var( --treeitem-backgound-hover );
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
&.selected {
|
|
64
|
-
background-color: var( --treeitem-background-sel );
|
|
65
|
-
color: var( --treeitem-color-sel );
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
&:active{
|
|
69
|
-
background-color: var( --accent-background-active );
|
|
70
|
-
color: var( --accent-color-active );
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
&>.body:not(:first-child) {
|
|
75
|
-
padding-left: 24px;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
&>.body {
|
|
79
|
-
transition: opacity 0.5s ease;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
&.folder {
|
|
83
|
-
&> .label {
|
|
84
|
-
display: flex;
|
|
85
|
-
flex-direction: row;
|
|
86
|
-
align-items: center;
|
|
87
|
-
|
|
88
|
-
&>.x-icon {
|
|
89
|
-
transform: rotate( 0deg );
|
|
90
|
-
transition: transform 0.2s ease;
|
|
91
|
-
|
|
92
|
-
width: 16px;
|
|
93
|
-
height: 16px;
|
|
94
|
-
|
|
95
|
-
cursor: pointer;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
&>.body {
|
|
100
|
-
overflow: hidden;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
&:not(.open) {
|
|
104
|
-
&>.body {
|
|
105
|
-
//display: none;
|
|
106
|
-
height: 0;
|
|
107
|
-
opacity: 0;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
&>.label>.x4icon {
|
|
111
|
-
transform: rotate( -90deg );
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}
|
|
@@ -1,403 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ___ ___ __
|
|
3
|
-
* \ \/ / / _
|
|
4
|
-
* \ / /_| |_
|
|
5
|
-
* / \____ _|
|
|
6
|
-
* /__/\__\ |_|
|
|
7
|
-
*
|
|
8
|
-
* @file treeview.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, ComponentEvent, ComponentEvents, ComponentProps, componentFromDOM } from '@core/component';
|
|
18
|
-
|
|
19
|
-
import { Label } from '../label/label';
|
|
20
|
-
import { ListboxID, ListItem, kbNav } from '../listbox/listbox';
|
|
21
|
-
import { Box, BoxProps, HBox, VBox } from '../boxes/boxes';
|
|
22
|
-
import { Icon } from '../icon/icon.js';
|
|
23
|
-
|
|
24
|
-
import "./treeview.module.scss";
|
|
25
|
-
import folder_icon from "./chevron-down-light.svg"
|
|
26
|
-
|
|
27
|
-
//import folder_closed from "./folder-minus-light.svg"
|
|
28
|
-
|
|
29
|
-
export enum kbTreeNav {
|
|
30
|
-
first,
|
|
31
|
-
prev,
|
|
32
|
-
next,
|
|
33
|
-
last,
|
|
34
|
-
|
|
35
|
-
parent,
|
|
36
|
-
child,
|
|
37
|
-
|
|
38
|
-
expand,
|
|
39
|
-
collapse,
|
|
40
|
-
toggle,
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
export interface TreeItem extends ListItem {
|
|
45
|
-
children?: TreeItem[];
|
|
46
|
-
open?: boolean;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
interface TreeviewProps extends Omit<ComponentProps,"content"> {
|
|
50
|
-
items: TreeItem[];
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
interface ChangeEvent extends ComponentEvent {
|
|
54
|
-
selection: TreeItem;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
interface TreeviewEvents extends ComponentEvents {
|
|
58
|
-
change: ChangeEvent;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
class CTreeViewItem extends Box {
|
|
62
|
-
|
|
63
|
-
private _item: TreeItem;
|
|
64
|
-
private _label: Component;
|
|
65
|
-
private _icon: Icon;
|
|
66
|
-
private _childs: Component;
|
|
67
|
-
|
|
68
|
-
constructor( props: BoxProps, item: TreeItem ) {
|
|
69
|
-
super( { ...props } );
|
|
70
|
-
|
|
71
|
-
this._item = item;
|
|
72
|
-
|
|
73
|
-
if( item ) {
|
|
74
|
-
this._label = new HBox( {cls:"label item", content: [
|
|
75
|
-
this._icon = new Icon( { iconId: item.children? folder_icon : item.iconId } ),
|
|
76
|
-
new Label( { tag: "span", cls: "", text: item.text } ),
|
|
77
|
-
]});
|
|
78
|
-
|
|
79
|
-
this._label.setData( "id", item.id+"" );
|
|
80
|
-
|
|
81
|
-
if( item.children ) {
|
|
82
|
-
this. _childs = new VBox( { cls: "body" } );
|
|
83
|
-
|
|
84
|
-
if( item.open===undefined ) {
|
|
85
|
-
item.open = false;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
this.addClass( "folder" )
|
|
89
|
-
this.setClass( "open", item.open );
|
|
90
|
-
this.setItems( item.children );
|
|
91
|
-
|
|
92
|
-
this._icon.addDOMEvent( "click", ( ev )=>this.toggle(ev) );
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
this. _childs = new VBox( { cls: "body" } );
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
this.setContent( [
|
|
100
|
-
this._label,
|
|
101
|
-
this._childs,
|
|
102
|
-
] );
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
toggle( ev?: UIEvent ) {
|
|
106
|
-
|
|
107
|
-
const isOpen = this.hasClass("open");
|
|
108
|
-
this.open( !isOpen );
|
|
109
|
-
|
|
110
|
-
if( ev ) {
|
|
111
|
-
ev.stopPropagation( );
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
open( open = true ) {
|
|
116
|
-
this.setClass( "open", open );
|
|
117
|
-
this._item.open = open;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
setItems( items: TreeItem[ ] ) {
|
|
121
|
-
if( items ) {
|
|
122
|
-
const childs = items.map( itm => {
|
|
123
|
-
return new CTreeViewItem( {}, itm );
|
|
124
|
-
})
|
|
125
|
-
this._childs.setContent( childs );
|
|
126
|
-
}
|
|
127
|
-
else {
|
|
128
|
-
this._childs.clearContent( );
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
*
|
|
135
|
-
*/
|
|
136
|
-
|
|
137
|
-
export class Treeview extends Component<TreeviewProps,TreeviewEvents> {
|
|
138
|
-
private _selection: ListboxID;
|
|
139
|
-
private _selitem: Component;
|
|
140
|
-
private _items: TreeItem[];
|
|
141
|
-
|
|
142
|
-
constructor( props: TreeviewProps ) {
|
|
143
|
-
super( props );
|
|
144
|
-
|
|
145
|
-
if( props.items ) {
|
|
146
|
-
this.setItems( props.items );
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
this.setAttribute( "tabindex", 0 );
|
|
150
|
-
this.setDOMEvents( {
|
|
151
|
-
click: ( ev ) => this._onclick( ev ),
|
|
152
|
-
keydown: ( ev ) => this._onkey( ev ),
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
*
|
|
158
|
-
*/
|
|
159
|
-
|
|
160
|
-
setItems( items: TreeItem[ ] ) {
|
|
161
|
-
this._items = items;
|
|
162
|
-
|
|
163
|
-
const root = new CTreeViewItem( { cls: "root"}, null );
|
|
164
|
-
root.setItems( items );
|
|
165
|
-
this.setContent( root );
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
private _onclick( ev: UIEvent ) {
|
|
169
|
-
let target = ev.target as HTMLElement;
|
|
170
|
-
while( target && target!=this.dom ) {
|
|
171
|
-
const c = componentFromDOM( target );
|
|
172
|
-
|
|
173
|
-
if( c && c.hasClass("item") ) {
|
|
174
|
-
const id = c.getData( "id" );
|
|
175
|
-
this._selectItem( id, c );
|
|
176
|
-
return;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
target = target.parentElement;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
this.clearSelection( );
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
private _onkey( ev: KeyboardEvent ) {
|
|
186
|
-
switch( ev.key ) {
|
|
187
|
-
case "ArrowDown": {
|
|
188
|
-
this.navigate( kbTreeNav.next );
|
|
189
|
-
break;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
case "ArrowUp": {
|
|
193
|
-
this.navigate( kbTreeNav.prev );
|
|
194
|
-
break;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
case "Home": {
|
|
198
|
-
this.navigate( kbTreeNav.first );
|
|
199
|
-
break;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
case "End": {
|
|
203
|
-
this.navigate( kbTreeNav.last );
|
|
204
|
-
break;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
case "ArrowRight":{
|
|
208
|
-
this.navigate( kbTreeNav.child );
|
|
209
|
-
break;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
case "+": {
|
|
213
|
-
this.navigate( kbTreeNav.expand );
|
|
214
|
-
break;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
case "ArrowLeft": {
|
|
218
|
-
this.navigate( kbTreeNav.parent );
|
|
219
|
-
break;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
case "-": {
|
|
223
|
-
this.navigate( kbTreeNav.collapse );
|
|
224
|
-
break;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
case ' ': {
|
|
229
|
-
this.navigate( kbTreeNav.toggle );
|
|
230
|
-
break;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
default:
|
|
234
|
-
console.log( ev.key );
|
|
235
|
-
return;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
ev.preventDefault( );
|
|
239
|
-
ev.stopPropagation( );
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
/**
|
|
243
|
-
*
|
|
244
|
-
*/
|
|
245
|
-
|
|
246
|
-
navigate( sens: kbTreeNav ) {
|
|
247
|
-
|
|
248
|
-
if( !this._items || this._items.length==0 ) {
|
|
249
|
-
return;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
if( !this._selitem ) {
|
|
253
|
-
if( sens==kbTreeNav.next || sens==kbTreeNav.parent ) sens = kbTreeNav.first;
|
|
254
|
-
else if( sens==kbTreeNav.prev ) sens = kbTreeNav.last;
|
|
255
|
-
else return;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
const p = this._selitem?.parentElement<CTreeViewItem>( );
|
|
259
|
-
const isFolder = p?.hasClass("folder");
|
|
260
|
-
|
|
261
|
-
if( p && sens==kbTreeNav.parent && isFolder && p.hasClass("open") ) {
|
|
262
|
-
sens = kbTreeNav.collapse;
|
|
263
|
-
}
|
|
264
|
-
else if( sens==kbTreeNav.child ) {
|
|
265
|
-
if( isFolder) {
|
|
266
|
-
if( !p.hasClass("open") ) {
|
|
267
|
-
sens = kbTreeNav.expand;
|
|
268
|
-
}
|
|
269
|
-
else {
|
|
270
|
-
sens = kbTreeNav.next;
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
else {
|
|
274
|
-
sens = kbTreeNav.next;
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
if( sens==kbTreeNav.expand || sens==kbTreeNav.collapse || sens==kbTreeNav.toggle ) {
|
|
279
|
-
if( isFolder ) {
|
|
280
|
-
if( sens==kbTreeNav.toggle ) {
|
|
281
|
-
p.toggle( );
|
|
282
|
-
return true;
|
|
283
|
-
}
|
|
284
|
-
else {
|
|
285
|
-
p.open( sens==kbTreeNav.expand );
|
|
286
|
-
return true;
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
else {
|
|
291
|
-
const all = this._flattenOpenItems( );
|
|
292
|
-
let cur = all.findIndex( x => this._selection==x.id );
|
|
293
|
-
|
|
294
|
-
let newSel: ListboxID;
|
|
295
|
-
|
|
296
|
-
if( sens==kbTreeNav.first ) {
|
|
297
|
-
newSel = all[0].id;
|
|
298
|
-
}
|
|
299
|
-
else if( sens==kbTreeNav.last ) {
|
|
300
|
-
newSel = all[all.length-1].id;
|
|
301
|
-
}
|
|
302
|
-
else if( cur>=0 ) {
|
|
303
|
-
if( sens==kbTreeNav.prev ) {
|
|
304
|
-
if( cur>0 ) {
|
|
305
|
-
newSel = all[cur-1].id;
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
else if( sens==kbTreeNav.next ) {
|
|
309
|
-
if( cur<all.length-1 ) {
|
|
310
|
-
newSel = all[cur+1].id;
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
else if( sens==kbTreeNav.parent ) {
|
|
314
|
-
|
|
315
|
-
const clevel = all[cur].level;
|
|
316
|
-
while( cur>0 ) {
|
|
317
|
-
cur--;
|
|
318
|
-
if( all[cur].level<clevel ) {
|
|
319
|
-
newSel = all[cur].id;
|
|
320
|
-
break;
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
if( newSel ) {
|
|
327
|
-
const nsel = this.query( `[data-id="${newSel}"]`)
|
|
328
|
-
this._selectItem( newSel, nsel );
|
|
329
|
-
return true;
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
return false;
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
private _flattenOpenItems( ) {
|
|
337
|
-
let all: { id: ListboxID, level: number }[] = [];
|
|
338
|
-
|
|
339
|
-
const build = ( x: TreeItem, level: number ) => {
|
|
340
|
-
all.push( {id: x.id+"", level } );
|
|
341
|
-
if( x.children && x.open ) {
|
|
342
|
-
x.children.forEach( y => build( y, level+1 ) );
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
this._items.forEach( y => build( y, 0 ) );
|
|
347
|
-
return all;
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
private _flattenItems( ) {
|
|
351
|
-
let all: TreeItem[] = [];
|
|
352
|
-
|
|
353
|
-
const build = ( x: TreeItem ) => {
|
|
354
|
-
all.push( x );
|
|
355
|
-
if( x.children ) {
|
|
356
|
-
x.children.forEach( y => build(y) );
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
this._items.forEach( y => build( y ) );
|
|
361
|
-
return all;
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
private _selectItem( id: ListboxID, item: Component ) {
|
|
365
|
-
if( this._selitem ) {
|
|
366
|
-
this._selitem.removeClass( "selected" );
|
|
367
|
-
this._selitem = undefined;
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
this._selitem = item;
|
|
371
|
-
this._selection = id;
|
|
372
|
-
|
|
373
|
-
if( item ) {
|
|
374
|
-
item.addClass( "selected" );
|
|
375
|
-
item.scrollIntoView( {
|
|
376
|
-
behavior: "smooth",
|
|
377
|
-
block: "nearest"
|
|
378
|
-
} );
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
const itm = this._findItem( id );
|
|
382
|
-
this.fire( "change", { selection: itm } );
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
private _findItem( id: ListboxID ) {
|
|
386
|
-
const all = this._flattenItems( );
|
|
387
|
-
return all.find( x => x.id==id );
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
/**
|
|
391
|
-
*
|
|
392
|
-
*/
|
|
393
|
-
|
|
394
|
-
clearSelection( ) {
|
|
395
|
-
if( this._selitem ) {
|
|
396
|
-
this._selitem.removeClass( "selected" );
|
|
397
|
-
this._selitem = undefined;
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
this._selection = undefined;
|
|
401
|
-
this.fire( "change", { selection: undefined } );
|
|
402
|
-
}
|
|
403
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ___ ___ __
|
|
3
|
-
* \ \/ / / _
|
|
4
|
-
* \ / /_| |_
|
|
5
|
-
* / \____ _|
|
|
6
|
-
* /__/\__\ |_|
|
|
7
|
-
*
|
|
8
|
-
* @file viewport.module.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
|
-
@use "../shared.scss";
|
|
18
|
-
|
|
19
|
-
.x4scrollview {
|
|
20
|
-
@extend .flex;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
.x4viewport {
|
|
24
|
-
width: 100%;
|
|
25
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ___ ___ __
|
|
3
|
-
* \ \/ / / _
|
|
4
|
-
* \ / /_| |_
|
|
5
|
-
* / \____ _|
|
|
6
|
-
* /__/\__\ |_|
|
|
7
|
-
*
|
|
8
|
-
* @file viewport.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, ComponentProps } from "@core/component"
|
|
18
|
-
|
|
19
|
-
import "./viewport.module.scss"
|
|
20
|
-
|
|
21
|
-
export class Viewport extends Component {
|
|
22
|
-
constructor( props: ComponentProps ) {
|
|
23
|
-
super( props );
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export class ScrollView extends Component {
|
|
28
|
-
constructor( props: ComponentProps ) {
|
|
29
|
-
super( props );
|
|
30
|
-
this.setContent( new Viewport( {} ) );
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
getViewport( ) {
|
|
34
|
-
return this.firstChild<Viewport>( );
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|