x4js 2.0.12 → 2.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -15
- package/lib/README.txt +15 -15
- package/lib/cjs/x4.css +1 -1
- package/lib/cjs/x4.js +1 -1
- package/lib/esm/x4.css +1 -1
- package/lib/esm/x4.mjs +1 -1
- package/lib/src/components/base.scss +25 -26
- package/lib/src/components/boxes/boxes.module.scss +37 -37
- package/lib/src/components/boxes/boxes.ts +129 -125
- package/lib/src/components/breadcrumb/breadcrumb.scss +28 -0
- package/lib/src/components/breadcrumb/breadcrumb.ts +84 -0
- package/lib/src/components/breadcrumb/chevron-right.svg +1 -0
- package/lib/src/components/btngroup/btngroup.module.scss +28 -28
- package/lib/src/components/btngroup/btngroup.ts +119 -101
- package/lib/src/components/button/button.module.scss +154 -153
- package/lib/src/components/button/button.ts +117 -117
- package/lib/src/components/calendar/calendar.module.scss +162 -162
- package/lib/src/components/calendar/calendar.ts +326 -325
- package/lib/src/components/checkbox/check.svg +3 -3
- package/lib/src/components/checkbox/checkbox.module.scss +141 -141
- package/lib/src/components/checkbox/checkbox.ts +125 -124
- package/lib/src/components/colorinput/colorinput.module.scss +64 -64
- package/lib/src/components/colorinput/colorinput.ts +90 -87
- package/lib/src/components/colorpicker/colorpicker.module.scss +132 -132
- package/lib/src/components/colorpicker/colorpicker.ts +481 -476
- package/lib/src/components/combobox/combobox.module.scss +123 -120
- package/lib/src/components/combobox/combobox.ts +192 -190
- package/lib/src/components/combobox/updown.svg +3 -3
- package/lib/src/components/components.ts +34 -0
- package/lib/src/components/dialog/dialog.module.scss +71 -71
- package/lib/src/components/dialog/dialog.ts +94 -92
- package/lib/src/components/form/form.module.scss +34 -34
- package/lib/src/components/form/form.ts +41 -36
- package/lib/src/components/grid/datastore.ts +1298 -0
- package/lib/src/components/grid/gridview.ts +1108 -0
- package/lib/src/components/grid/memdb.ts +325 -0
- package/lib/src/components/header/header.module.scss +39 -39
- package/lib/src/components/header/header.ts +129 -123
- package/lib/src/components/icon/icon.module.scss +29 -29
- package/lib/src/components/icon/icon.ts +136 -134
- package/lib/src/components/image/image.module.scss +20 -20
- package/lib/src/components/image/image.ts +68 -66
- package/lib/src/components/input/input.module.scss +69 -69
- package/lib/src/components/input/input.ts +275 -274
- package/lib/src/components/label/label.module.scss +58 -52
- package/lib/src/components/label/label.ts +64 -55
- package/lib/src/components/link/link.ts +78 -0
- package/lib/src/components/listbox/listbox.module.scss +103 -103
- package/lib/src/components/listbox/listbox.ts +431 -427
- package/lib/src/components/menu/menu.module.scss +107 -107
- package/lib/src/components/menu/menu.ts +171 -168
- package/lib/src/components/messages/messages.module.scss +48 -47
- package/lib/src/components/messages/messages.ts +68 -63
- package/lib/src/components/normalize.scss +386 -386
- package/lib/src/components/notification/notification.module.scss +81 -81
- package/lib/src/components/notification/notification.ts +109 -108
- package/lib/src/components/panel/panel.module.scss +47 -47
- package/lib/src/components/panel/panel.ts +57 -56
- package/lib/src/components/popup/popup.module.scss +43 -43
- package/lib/src/components/popup/popup.ts +396 -395
- package/lib/src/components/progress/progress.module.scss +56 -56
- package/lib/src/components/progress/progress.ts +43 -42
- package/lib/src/components/rating/rating.module.scss +22 -22
- package/lib/src/components/rating/rating.ts +131 -125
- package/lib/src/components/shared.scss +90 -76
- package/lib/src/components/sizers/sizer.module.scss +89 -89
- package/lib/src/components/sizers/sizer.ts +123 -119
- package/lib/src/components/slider/slider.module.scss +70 -70
- package/lib/src/components/slider/slider.ts +147 -142
- package/lib/src/components/switch/switch.module.scss +126 -126
- package/lib/src/components/switch/switch.ts +61 -55
- package/lib/src/components/tabs/tabs.module.scss +46 -46
- package/lib/src/components/tabs/tabs.ts +168 -157
- package/lib/src/components/textarea/textarea.module.scss +59 -59
- package/lib/src/components/textarea/textarea.ts +60 -54
- package/lib/src/components/textedit/textedit.module.scss +113 -113
- package/lib/src/components/textedit/textedit.ts +83 -82
- package/lib/src/components/themes.scss +81 -77
- package/lib/src/components/tooltips/tooltips.scss +50 -50
- package/lib/src/components/tooltips/tooltips.ts +103 -102
- package/lib/src/components/treeview/treeview.module.scss +115 -115
- package/lib/src/components/treeview/treeview.ts +410 -403
- package/lib/src/components/viewport/viewport.module.scss +24 -24
- package/lib/src/components/viewport/viewport.ts +41 -38
- package/lib/src/core/component.ts +1002 -979
- package/lib/src/core/core_application.ts +44 -0
- package/lib/src/core/core_colors.ts +249 -249
- package/lib/src/core/core_dom.ts +471 -471
- package/lib/src/core/core_dragdrop.ts +200 -200
- package/lib/src/core/core_element.ts +97 -97
- package/lib/src/core/core_events.ts +149 -149
- package/lib/src/core/core_i18n.ts +377 -377
- package/lib/src/core/core_router.ts +221 -221
- package/lib/src/core/core_styles.ts +214 -214
- package/lib/src/core/core_svg.ts +550 -550
- package/lib/src/core/core_tools.ts +688 -673
- package/lib/src/demo/assets/radio.svg +3 -3
- package/lib/src/demo/index.html +11 -11
- package/lib/src/demo/main.scss +21 -21
- package/lib/src/demo/main.tsx +323 -323
- package/lib/src/types/scss.d.ts +4 -4
- package/lib/src/types/x4react.d.ts +8 -8
- package/lib/src/x4.scss +18 -18
- package/lib/src/x4.ts +31 -62
- package/lib/styles/x4.css +1 -1
- package/lib/types/x4js.d.ts +100 -49
- package/package.json +2 -3
- package/src/x4.ts +31 -62
|
@@ -1,143 +1,148 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ___ ___ __
|
|
3
|
-
* \ \/ / / _
|
|
4
|
-
* \ / /_| |_
|
|
5
|
-
* / \____ _|
|
|
6
|
-
* /__/\__\ |_|
|
|
7
|
-
*
|
|
8
|
-
* @file slider.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, ComponentEvent } from '../../core/component';
|
|
18
|
-
import { Rect } from '../../core/core_tools.js';
|
|
19
|
-
|
|
20
|
-
import { HBox } from '../boxes/boxes';
|
|
21
|
-
import { Input } from '../input/input.js';
|
|
22
|
-
|
|
23
|
-
import './slider.module.scss';
|
|
24
|
-
|
|
25
|
-
interface ChangeEvent extends ComponentEvent {
|
|
26
|
-
value: number;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
interface SliderEvents extends ComponentEvents {
|
|
30
|
-
change: ChangeEvent;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
interface SliderProps extends ComponentProps {
|
|
34
|
-
value: number;
|
|
35
|
-
min: number;
|
|
36
|
-
max: number;
|
|
37
|
-
step?: number;
|
|
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
|
-
this.
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
this.
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
1
|
+
/**
|
|
2
|
+
* ___ ___ __
|
|
3
|
+
* \ \/ / / _
|
|
4
|
+
* \ / /_| |_
|
|
5
|
+
* / \____ _|
|
|
6
|
+
* /__/\__\ |_|
|
|
7
|
+
*
|
|
8
|
+
* @file slider.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, ComponentEvent } from '../../core/component';
|
|
18
|
+
import { class_ns, Rect } from '../../core/core_tools.js';
|
|
19
|
+
|
|
20
|
+
import { HBox } from '../boxes/boxes';
|
|
21
|
+
import { Input } from '../input/input.js';
|
|
22
|
+
|
|
23
|
+
import './slider.module.scss';
|
|
24
|
+
|
|
25
|
+
interface ChangeEvent extends ComponentEvent {
|
|
26
|
+
value: number;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface SliderEvents extends ComponentEvents {
|
|
30
|
+
change: ChangeEvent;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
interface SliderProps extends ComponentProps {
|
|
34
|
+
value: number;
|
|
35
|
+
min: number;
|
|
36
|
+
max: number;
|
|
37
|
+
step?: number;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
*
|
|
42
|
+
*/
|
|
43
|
+
|
|
44
|
+
@class_ns( "x4" )
|
|
45
|
+
export class Slider extends Component<SliderProps,SliderEvents> {
|
|
46
|
+
|
|
47
|
+
private _mdown = false;
|
|
48
|
+
private _irect: Rect = null;
|
|
49
|
+
private _thumb: Component = null;
|
|
50
|
+
private _bar: Component = null;
|
|
51
|
+
private _range: Input = null;
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
constructor( props: SliderProps ) {
|
|
55
|
+
super( props );
|
|
56
|
+
|
|
57
|
+
this.setContent( [
|
|
58
|
+
new HBox( { cls: "track", content: [
|
|
59
|
+
this._bar = new Component( { cls: "bar" } ),
|
|
60
|
+
this._thumb = new Component( { cls: "thumb" } ),
|
|
61
|
+
] }),
|
|
62
|
+
this._range = new Input( { type: "range", hidden: true, value: props.value, min: props.min, max: props.max, step: props.step } )
|
|
63
|
+
]);
|
|
64
|
+
|
|
65
|
+
this.setAttribute( "tabindex", 0 );
|
|
66
|
+
|
|
67
|
+
this.setDOMEvents( {
|
|
68
|
+
pointerdown: ( ev ) => this._on_mousedown( ev ),
|
|
69
|
+
pointermove: ( ev ) => this._on_mousemove( ev ),
|
|
70
|
+
pointerup: ( ev ) => this._on_mouseup( ev ),
|
|
71
|
+
keydown: ( ev ) => this._on_key( ev ),
|
|
72
|
+
} );
|
|
73
|
+
|
|
74
|
+
this._range.addDOMEvent( "change", ( ev: Event) => {
|
|
75
|
+
//console.log( ev );
|
|
76
|
+
})
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
private _on_mousedown( ev: PointerEvent ) {
|
|
80
|
+
ev.stopPropagation( );
|
|
81
|
+
ev.preventDefault( );
|
|
82
|
+
|
|
83
|
+
this.focus( );
|
|
84
|
+
|
|
85
|
+
this._mdown = true;
|
|
86
|
+
this._irect = this.getBoundingRect( );
|
|
87
|
+
|
|
88
|
+
this.setCapture( ev.pointerId );
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
private _on_mousemove( ev: PointerEvent ) {
|
|
92
|
+
if( this._mdown ) {
|
|
93
|
+
let pos = ev.pageX - this._irect.left;
|
|
94
|
+
if( pos<0 ) {
|
|
95
|
+
pos = 0;
|
|
96
|
+
}
|
|
97
|
+
else if( pos>this._irect.width ) {
|
|
98
|
+
pos = this._irect.width;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
let perc = pos / this._irect.width * 100;
|
|
102
|
+
this._range.setNumValue( perc );
|
|
103
|
+
|
|
104
|
+
this._update( );
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
private _update( ) {
|
|
109
|
+
const value = this._range.getNumValue( );
|
|
110
|
+
|
|
111
|
+
const perc = value / (this.props.max-this.props.min) * 100;
|
|
112
|
+
this._thumb.setStyleValue( "left", perc+"%" );
|
|
113
|
+
this._bar.setStyleValue( "width", perc+"%" );
|
|
114
|
+
//thumb.setAttribute( "tooltip", value );
|
|
115
|
+
|
|
116
|
+
this.fire( "change", { value } );
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
private _on_mouseup( ev: PointerEvent ) {
|
|
120
|
+
if( this._mdown ) {
|
|
121
|
+
this.releaseCapture( ev.pointerId );
|
|
122
|
+
this._mdown = false;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
private _on_key( ev: KeyboardEvent ) {
|
|
127
|
+
console.log( ev.key );
|
|
128
|
+
|
|
129
|
+
let stp = this.props.step ?? 1;
|
|
130
|
+
let inc = 0;
|
|
131
|
+
switch( ev.key ) {
|
|
132
|
+
case "ArrowRight":
|
|
133
|
+
case "ArrowUp": inc = stp; break;
|
|
134
|
+
|
|
135
|
+
case "ArrowLeft":
|
|
136
|
+
case "ArrowDown": inc = -stp; break;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if( inc ) {
|
|
140
|
+
if( ev.ctrlKey ) {
|
|
141
|
+
inc *= 10;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
this._range.setNumValue( this._range.getNumValue()+inc );
|
|
145
|
+
this._update( );
|
|
146
|
+
}
|
|
147
|
+
}
|
|
143
148
|
}
|
|
@@ -1,127 +1,127 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ___ ___ __
|
|
3
|
-
* \ \/ / / _
|
|
4
|
-
* \ / /_| |_
|
|
5
|
-
* / \____ _|
|
|
6
|
-
* /__/\__\ |_|
|
|
7
|
-
*
|
|
8
|
-
* @file switch.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
|
-
:root {
|
|
20
|
-
--switch-border: var( --border );
|
|
21
|
-
--switch-background: #eee;
|
|
22
|
-
--switch-background-disabled: var( --disabled-background );
|
|
23
|
-
--switch-checked: var( --accent-background );
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
.x4switch {
|
|
27
|
-
display: flex;
|
|
28
|
-
flex-direction: row;
|
|
29
|
-
align-items: center;
|
|
30
|
-
position: relative;
|
|
31
|
-
|
|
32
|
-
gap: 4px;
|
|
33
|
-
margin-left: 5px;
|
|
34
|
-
padding: 4px;
|
|
35
|
-
cursor: pointer;
|
|
36
|
-
|
|
37
|
-
label {
|
|
38
|
-
cursor: pointer;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
&:focus-within {
|
|
42
|
-
.x4label {
|
|
43
|
-
span {
|
|
44
|
-
text-decoration: underline;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
.switch {
|
|
50
|
-
width: 2.2rem;
|
|
51
|
-
height: 18px;
|
|
52
|
-
position: relative;
|
|
53
|
-
|
|
54
|
-
input {
|
|
55
|
-
position: absolute;
|
|
56
|
-
width: 100%;
|
|
57
|
-
height: 100%;
|
|
58
|
-
appearance: none;
|
|
59
|
-
padding: 0;
|
|
60
|
-
margin: 0;
|
|
61
|
-
left: 0;
|
|
62
|
-
top: 0;
|
|
63
|
-
cursor: pointer;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
.track {
|
|
67
|
-
position: absolute;
|
|
68
|
-
pointer-events: none;
|
|
69
|
-
left: 0;
|
|
70
|
-
top: 0;
|
|
71
|
-
width: 100%;
|
|
72
|
-
height: 100%;
|
|
73
|
-
border: 1px solid var( --switch-border );
|
|
74
|
-
|
|
75
|
-
background-color: var( --switch-background );
|
|
76
|
-
border-radius: 9px;
|
|
77
|
-
|
|
78
|
-
transition: background-color ease 0.2s;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
.thumb {
|
|
82
|
-
position: absolute;
|
|
83
|
-
pointer-events: none;
|
|
84
|
-
left: 0.05rem;
|
|
85
|
-
top: 1px;
|
|
86
|
-
|
|
87
|
-
width: 1rem;
|
|
88
|
-
height: 1rem;
|
|
89
|
-
|
|
90
|
-
border-radius: 8px;
|
|
91
|
-
background-color: white;
|
|
92
|
-
box-shadow: 0 0 2px rgba(0,0,0,0.5);
|
|
93
|
-
|
|
94
|
-
transition: left ease 0.2s;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
&:has(input:checked) {
|
|
99
|
-
.switch .thumb {
|
|
100
|
-
left: 1.15rem;
|
|
101
|
-
}
|
|
102
|
-
.switch .track {
|
|
103
|
-
background-color: var( --switch-checked );
|
|
104
|
-
//border-color: var( --color-70 );
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
&[disabled] {
|
|
109
|
-
&, * {
|
|
110
|
-
cursor: not-allowed;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
input {
|
|
114
|
-
pointer-events: none;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
label {
|
|
118
|
-
pointer-events: none;
|
|
119
|
-
color: var( --checkbox-color-disabled );
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
.switch .track,
|
|
123
|
-
&.x4switch:has(input:checked) .switch .track {
|
|
124
|
-
background-color: var( --switch-background-disabled );
|
|
125
|
-
}
|
|
126
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* ___ ___ __
|
|
3
|
+
* \ \/ / / _
|
|
4
|
+
* \ / /_| |_
|
|
5
|
+
* / \____ _|
|
|
6
|
+
* /__/\__\ |_|
|
|
7
|
+
*
|
|
8
|
+
* @file switch.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
|
+
:root {
|
|
20
|
+
--switch-border: var( --border );
|
|
21
|
+
--switch-background: #eee;
|
|
22
|
+
--switch-background-disabled: var( --disabled-background );
|
|
23
|
+
--switch-checked: var( --accent-background );
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.x4switch {
|
|
27
|
+
display: flex;
|
|
28
|
+
flex-direction: row;
|
|
29
|
+
align-items: center;
|
|
30
|
+
position: relative;
|
|
31
|
+
|
|
32
|
+
gap: 4px;
|
|
33
|
+
margin-left: 5px;
|
|
34
|
+
padding: 4px;
|
|
35
|
+
cursor: pointer;
|
|
36
|
+
|
|
37
|
+
label {
|
|
38
|
+
cursor: pointer;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
&:focus-within {
|
|
42
|
+
.x4label {
|
|
43
|
+
span {
|
|
44
|
+
text-decoration: underline;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.switch {
|
|
50
|
+
width: 2.2rem;
|
|
51
|
+
height: 18px;
|
|
52
|
+
position: relative;
|
|
53
|
+
|
|
54
|
+
input {
|
|
55
|
+
position: absolute;
|
|
56
|
+
width: 100%;
|
|
57
|
+
height: 100%;
|
|
58
|
+
appearance: none;
|
|
59
|
+
padding: 0;
|
|
60
|
+
margin: 0;
|
|
61
|
+
left: 0;
|
|
62
|
+
top: 0;
|
|
63
|
+
cursor: pointer;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.track {
|
|
67
|
+
position: absolute;
|
|
68
|
+
pointer-events: none;
|
|
69
|
+
left: 0;
|
|
70
|
+
top: 0;
|
|
71
|
+
width: 100%;
|
|
72
|
+
height: 100%;
|
|
73
|
+
border: 1px solid var( --switch-border );
|
|
74
|
+
|
|
75
|
+
background-color: var( --switch-background );
|
|
76
|
+
border-radius: 9px;
|
|
77
|
+
|
|
78
|
+
transition: background-color ease 0.2s;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.thumb {
|
|
82
|
+
position: absolute;
|
|
83
|
+
pointer-events: none;
|
|
84
|
+
left: 0.05rem;
|
|
85
|
+
top: 1px;
|
|
86
|
+
|
|
87
|
+
width: 1rem;
|
|
88
|
+
height: 1rem;
|
|
89
|
+
|
|
90
|
+
border-radius: 8px;
|
|
91
|
+
background-color: white;
|
|
92
|
+
box-shadow: 0 0 2px rgba(0,0,0,0.5);
|
|
93
|
+
|
|
94
|
+
transition: left ease 0.2s;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
&:has(input:checked) {
|
|
99
|
+
.switch .thumb {
|
|
100
|
+
left: 1.15rem;
|
|
101
|
+
}
|
|
102
|
+
.switch .track {
|
|
103
|
+
background-color: var( --switch-checked );
|
|
104
|
+
//border-color: var( --color-70 );
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
&[disabled] {
|
|
109
|
+
&, * {
|
|
110
|
+
cursor: not-allowed;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
input {
|
|
114
|
+
pointer-events: none;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
label {
|
|
118
|
+
pointer-events: none;
|
|
119
|
+
color: var( --checkbox-color-disabled );
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.switch .track,
|
|
123
|
+
&.x4switch:has(input:checked) .switch .track {
|
|
124
|
+
background-color: var( --switch-background-disabled );
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
127
|
}
|
|
@@ -1,56 +1,62 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ___ ___ __
|
|
3
|
-
* \ \/ / / _
|
|
4
|
-
* \ / /_| |_
|
|
5
|
-
* / \____ _|
|
|
6
|
-
* /__/\__\ |_|
|
|
7
|
-
*
|
|
8
|
-
* @file switch.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, makeUniqueComponentId } from '../../core/component';
|
|
18
|
-
|
|
19
|
-
//import { Checkbox } from '@controls/controls.js';
|
|
20
|
-
import { Input } from '../input/input';
|
|
21
|
-
import { Label } from '../label/label';
|
|
22
|
-
import { HBox } from '../boxes/boxes.js';
|
|
23
|
-
|
|
24
|
-
import "./switch.module.scss";
|
|
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
|
-
|
|
1
|
+
/**
|
|
2
|
+
* ___ ___ __
|
|
3
|
+
* \ \/ / / _
|
|
4
|
+
* \ / /_| |_
|
|
5
|
+
* / \____ _|
|
|
6
|
+
* /__/\__\ |_|
|
|
7
|
+
*
|
|
8
|
+
* @file switch.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, makeUniqueComponentId } from '../../core/component';
|
|
18
|
+
|
|
19
|
+
//import { Checkbox } from '@controls/controls.js';
|
|
20
|
+
import { Input } from '../input/input';
|
|
21
|
+
import { Label } from '../label/label';
|
|
22
|
+
import { HBox } from '../boxes/boxes.js';
|
|
23
|
+
|
|
24
|
+
import "./switch.module.scss";
|
|
25
|
+
import { class_ns } from '@core/core_tools.js';
|
|
26
|
+
|
|
27
|
+
interface SwitchProps extends ComponentProps {
|
|
28
|
+
label: string;
|
|
29
|
+
checked?: boolean;
|
|
30
|
+
value?: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
*
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
@class_ns( "x4" )
|
|
38
|
+
export class Switch extends HBox<SwitchProps> {
|
|
39
|
+
constructor(props: SwitchProps ) {
|
|
40
|
+
super( props );
|
|
41
|
+
|
|
42
|
+
const inputId = makeUniqueComponentId( );
|
|
43
|
+
|
|
44
|
+
this.setContent( [
|
|
45
|
+
new Component( {
|
|
46
|
+
cls: "switch",
|
|
47
|
+
content: [
|
|
48
|
+
new Input( { type: "checkbox", id: inputId, checked: props.checked } ),
|
|
49
|
+
new Component( { cls: "track" } ),
|
|
50
|
+
new Component( { cls: "thumb" } ),
|
|
51
|
+
]
|
|
52
|
+
} ),
|
|
53
|
+
new Label( {
|
|
54
|
+
tag: "label",
|
|
55
|
+
text: props.label,
|
|
56
|
+
labelFor: inputId,
|
|
57
|
+
}),
|
|
58
|
+
])
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
}
|
|
56
62
|
}
|