x4js 2.0.13 → 2.0.14
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 +162 -13
- 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 +269 -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 +37 -3
- package/lib/src/components/dialog/dialog.ts +149 -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 +1 -1
- package/lib/src/components/icon/icon.ts +4 -1
- 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 +137 -14
- 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 +525 -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 +4 -1
- 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 +4 -2
- package/lib/src/components/popup/popup.ts +136 -92
- 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 +108 -0
- package/lib/src/components/propgrid/propgrid.ts +271 -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 +9 -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 +43 -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 +31 -4
- 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 +102 -32
- package/lib/src/core/core_application.ts +222 -2
- package/lib/src/core/core_colors.ts +2 -2
- package/lib/src/{components/grid/datastore.ts → core/core_data.ts} +261 -250
- package/lib/src/core/core_dragdrop.ts +3 -3
- package/lib/src/core/core_element.ts +13 -1
- package/lib/src/core/core_events.ts +28 -0
- package/lib/src/core/core_i18n.ts +18 -2
- package/lib/src/core/core_react.ts +79 -0
- package/lib/src/core/core_router.ts +23 -7
- package/lib/src/core/core_styles.ts +5 -5
- package/lib/src/core/core_svg.ts +173 -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 +767 -92
- 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 +278 -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 +269 -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 +105 -0
- package/src/components/dialog/dialog.ts +212 -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 +30 -0
- package/src/components/icon/icon.ts +139 -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 +398 -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 +525 -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 +45 -0
- package/src/components/popup/popup.ts +440 -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 +108 -0
- package/src/components/propgrid/propgrid.ts +271 -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 +131 -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 +199 -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 +110 -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 +1072 -0
- package/src/core/core_application.ts +264 -0
- package/src/core/core_colors.ts +250 -0
- package/src/core/core_data.ts +1309 -0
- package/src/core/core_dom.ts +471 -0
- package/src/core/core_dragdrop.ts +201 -0
- package/src/core/core_element.ts +110 -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_styles.ts +214 -0
- package/src/core/core_svg.ts +711 -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,398 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ___ ___ __
|
|
3
|
+
* \ \/ / / _
|
|
4
|
+
* \ / /_| |_
|
|
5
|
+
* / \____ _|
|
|
6
|
+
* /__/\__\ |_|
|
|
7
|
+
*
|
|
8
|
+
* @file input.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 { EventCallback } from '@core/core_events.js';
|
|
18
|
+
import { Component, ComponentEvent, ComponentProps, EvChange, EvFocus } from '../../core/component';
|
|
19
|
+
import { class_ns, IComponentInterface, IFormElement, isString } from '../../core/core_tools.js';
|
|
20
|
+
|
|
21
|
+
import "./input.module.scss"
|
|
22
|
+
|
|
23
|
+
export interface BaseProps extends ComponentProps {
|
|
24
|
+
name?: string;
|
|
25
|
+
autofocus?: boolean;
|
|
26
|
+
|
|
27
|
+
focus?: EventCallback<EvFocus>;
|
|
28
|
+
change?: EventCallback<EvChange>;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
interface CheckboxProps extends BaseProps {
|
|
32
|
+
type: "checkbox";
|
|
33
|
+
value?: boolean | number | string;
|
|
34
|
+
checked?: boolean;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
interface RadioProps extends BaseProps {
|
|
38
|
+
type: "radio";
|
|
39
|
+
value: boolean | number | string;
|
|
40
|
+
checked?: boolean;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface RangeProps extends BaseProps {
|
|
44
|
+
type: "range";
|
|
45
|
+
value: number;
|
|
46
|
+
min: number;
|
|
47
|
+
max: number;
|
|
48
|
+
step?: number;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
interface DateProps extends BaseProps {
|
|
52
|
+
type: "date";
|
|
53
|
+
readonly?: boolean;
|
|
54
|
+
required?: boolean;
|
|
55
|
+
value: Date | string;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
interface NumberProps extends BaseProps {
|
|
59
|
+
type: "number";
|
|
60
|
+
readonly?: boolean;
|
|
61
|
+
required?: boolean;
|
|
62
|
+
value: number | string;
|
|
63
|
+
min?: number;
|
|
64
|
+
max?: number;
|
|
65
|
+
step?: number;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
interface FileProps extends BaseProps {
|
|
69
|
+
type: "file";
|
|
70
|
+
accept: string | string[];
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export interface TextInputProps extends BaseProps {
|
|
74
|
+
type: "text" | "email" | "password" | "date" | "number";
|
|
75
|
+
readonly?: boolean;
|
|
76
|
+
required?: boolean;
|
|
77
|
+
pattern?: string;
|
|
78
|
+
value?: string | number;
|
|
79
|
+
placeholder?: string;
|
|
80
|
+
spellcheck?: boolean;
|
|
81
|
+
minlength?: number;
|
|
82
|
+
maxlength?: number;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
export type InputProps = CheckboxProps | RadioProps | TextInputProps | RangeProps | DateProps | NumberProps | FileProps;
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
interface InputEvents extends ComponentEvent {
|
|
90
|
+
focus: EvFocus;
|
|
91
|
+
change: EvChange;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
*
|
|
97
|
+
*/
|
|
98
|
+
|
|
99
|
+
@class_ns( "x4" )
|
|
100
|
+
export class Input extends Component<InputProps,InputEvents> {
|
|
101
|
+
constructor( props: InputProps ) {
|
|
102
|
+
super( { tag: "input", ...props } );
|
|
103
|
+
|
|
104
|
+
this.mapPropEvents( props, "focus", "change" );
|
|
105
|
+
|
|
106
|
+
this.setAttribute( "type", props.type ?? "text" );
|
|
107
|
+
this.setAttribute( "name", props.name );
|
|
108
|
+
|
|
109
|
+
if( props.autofocus===true ) {
|
|
110
|
+
this.setAttribute( "autofocus", true );
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
switch( props.type ) {
|
|
114
|
+
case "checkbox":
|
|
115
|
+
case "radio": {
|
|
116
|
+
const ck = this.dom as HTMLInputElement;
|
|
117
|
+
ck.checked = props.checked;
|
|
118
|
+
ck.value = props.value === undefined ? "" : props.value+"";
|
|
119
|
+
//this.setAttribute( "checked", props.checked );
|
|
120
|
+
//this.setAttribute( "value", props.value );
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
case "range": {
|
|
125
|
+
this.setAttribute( "min", props.min );
|
|
126
|
+
this.setAttribute( "max", props.max );
|
|
127
|
+
this.setAttribute( "step", props.step );
|
|
128
|
+
this.setAttribute( "value", props.value );
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
case "number": {
|
|
133
|
+
const p = this.props as NumberProps;
|
|
134
|
+
|
|
135
|
+
this.setAttribute( "required", p.required );
|
|
136
|
+
this.setAttribute( "readonly", p.readonly );
|
|
137
|
+
this.setAttribute( "min", p.min );
|
|
138
|
+
this.setAttribute( "max", p.max );
|
|
139
|
+
this.setAttribute( "step", p.step );
|
|
140
|
+
//this.setAttribute( "value", p.value+'' );
|
|
141
|
+
this.setNumValue( isString(p.value) ? parseFloat(p.value) : p.value, -2 );
|
|
142
|
+
|
|
143
|
+
this.addDOMEvent( "wheel", ( e: WheelEvent ) => {
|
|
144
|
+
if( this.hasFocus() ) { // only if has focus
|
|
145
|
+
e.preventDefault( );
|
|
146
|
+
let v = this.getNumValue();
|
|
147
|
+
const delta = e.deltaY < 0 ? 1 : -1;
|
|
148
|
+
v += (p.step ? p.step : 1) * delta;
|
|
149
|
+
this.setNumValue( v, -2 );
|
|
150
|
+
|
|
151
|
+
this.dom.dispatchEvent(new Event('input'));
|
|
152
|
+
}
|
|
153
|
+
}, );
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
case "date": {
|
|
158
|
+
this.setAttribute( "required", props.required );
|
|
159
|
+
|
|
160
|
+
let v = props.value;
|
|
161
|
+
if( v instanceof Date ) {
|
|
162
|
+
//this.setAttribute( "value", formatDate( v, "Y-M-D" ) );
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
this.setAttribute( "value", v );
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
case "file": {
|
|
172
|
+
let v: string;
|
|
173
|
+
if( Array.isArray(props.accept) ) {
|
|
174
|
+
v = props.accept.join("," );
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
v = props.accept;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
this.setAttribute( "accept", v );
|
|
181
|
+
break;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
default: {
|
|
185
|
+
this.setAttribute( "required", props.required );
|
|
186
|
+
this.setAttribute( "readonly", props.readonly );
|
|
187
|
+
|
|
188
|
+
if( props.value!==null && props.value!==undefined ) {
|
|
189
|
+
this.setAttribute( "value", props.value );
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
if( props.pattern!==null && props.pattern!==undefined ) {
|
|
193
|
+
this.setAttribute( "pattern", props.pattern );
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
if( props.placeholder!==null && props.placeholder!==undefined ) {
|
|
197
|
+
this.setAttribute( "placeholder", props.placeholder );
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
if( props.spellcheck===false ) {
|
|
201
|
+
this.setAttribute( "spellcheck", false );
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
if( props.minlength!==undefined ) {
|
|
205
|
+
this.setAttribute( "minlength", props.minlength );
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
if( props.maxlength!==undefined ) {
|
|
209
|
+
this.setAttribute( "maxlength", props.maxlength );
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
break;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
this.addDOMEvent( "blur", ( e ) => { this.on_focus(e,true);} );
|
|
217
|
+
this.addDOMEvent( "focus", ( e ) => { this.on_focus(e,false);} );
|
|
218
|
+
this.addDOMEvent( "input", ( e ) => { this.on_change(e as InputEvent); });
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
*
|
|
223
|
+
*/
|
|
224
|
+
|
|
225
|
+
private on_focus( ev: FocusEvent, focus_out: boolean ) {
|
|
226
|
+
const event: EvFocus = { focus_out }
|
|
227
|
+
this.fire( "focus", event );
|
|
228
|
+
|
|
229
|
+
if( event.defaultPrevented ) {
|
|
230
|
+
ev.preventDefault( );
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
*
|
|
236
|
+
*/
|
|
237
|
+
|
|
238
|
+
private on_change( ev: InputEvent ) {
|
|
239
|
+
|
|
240
|
+
const event: EvChange = { value: this.getValue() };
|
|
241
|
+
this.fire( "change", event );
|
|
242
|
+
|
|
243
|
+
if( event.defaultPrevented ) {
|
|
244
|
+
ev.preventDefault( );
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* @returns
|
|
250
|
+
*/
|
|
251
|
+
|
|
252
|
+
public getValue( ) {
|
|
253
|
+
return (this.dom as HTMLInputElement).value;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
*
|
|
258
|
+
* @param value
|
|
259
|
+
*/
|
|
260
|
+
|
|
261
|
+
public setValue( value: string ) {
|
|
262
|
+
(this.dom as HTMLInputElement).value = value+"";
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
*
|
|
267
|
+
* @returns
|
|
268
|
+
*/
|
|
269
|
+
|
|
270
|
+
public getNumValue( ) {
|
|
271
|
+
return parseFloat( this.getValue() );
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
*
|
|
276
|
+
* @param value
|
|
277
|
+
* @param ndec number of decimals or -1 for auto, -2 as prop.step
|
|
278
|
+
*
|
|
279
|
+
*/
|
|
280
|
+
|
|
281
|
+
public setNumValue( value: number, ndec = -1 ) {
|
|
282
|
+
|
|
283
|
+
if( ndec==-2 && this.props.type=='number' ) {
|
|
284
|
+
const p = this.props as NumberProps;
|
|
285
|
+
|
|
286
|
+
if( p.step ) {
|
|
287
|
+
let ndec = -Math.floor(Math.log10(p.step ?? 1) );
|
|
288
|
+
return this.setValue( value.toFixed(ndec) );
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
else if( ndec>=0 ) {
|
|
292
|
+
return this.setValue( value.toFixed(ndec) );
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
this.setValue( value+"" );
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* @return the checked value
|
|
300
|
+
*/
|
|
301
|
+
|
|
302
|
+
public getCheck() {
|
|
303
|
+
const d = this.dom as HTMLInputElement;
|
|
304
|
+
return d.checked;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* change the checked value
|
|
309
|
+
* @param {boolean} ck new checked value
|
|
310
|
+
*/
|
|
311
|
+
|
|
312
|
+
public setCheck(ck: boolean) {
|
|
313
|
+
const d = this.dom as HTMLInputElement;
|
|
314
|
+
d.checked = ck;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
*
|
|
319
|
+
*/
|
|
320
|
+
|
|
321
|
+
public setReadOnly( ro: boolean ) {
|
|
322
|
+
const d = this.dom as HTMLInputElement;
|
|
323
|
+
d.readOnly = ro;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* select all the text
|
|
328
|
+
*/
|
|
329
|
+
|
|
330
|
+
public selectAll( ) {
|
|
331
|
+
const d = this.dom as HTMLInputElement;
|
|
332
|
+
d.select();
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* select a part of the text
|
|
337
|
+
* @param start
|
|
338
|
+
* @param length
|
|
339
|
+
*/
|
|
340
|
+
|
|
341
|
+
public select( start: number, length: number = 9999 ) : void {
|
|
342
|
+
const d = this.dom as HTMLInputElement;
|
|
343
|
+
d.setSelectionRange( start, start+length );
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* get the selection as { start, length }
|
|
348
|
+
*/
|
|
349
|
+
|
|
350
|
+
public getSelection( ) {
|
|
351
|
+
const d = this.dom as HTMLInputElement;
|
|
352
|
+
|
|
353
|
+
return {
|
|
354
|
+
start: d.selectionStart,
|
|
355
|
+
length: d.selectionEnd - d.selectionStart,
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
*
|
|
361
|
+
*/
|
|
362
|
+
|
|
363
|
+
public isValid( ) {
|
|
364
|
+
|
|
365
|
+
if( (this.props as any).required ) {
|
|
366
|
+
const v = this.getValue( );
|
|
367
|
+
if( v==="" ) {
|
|
368
|
+
return false;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
return true;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
*
|
|
377
|
+
*/
|
|
378
|
+
|
|
379
|
+
override queryInterface<T extends IComponentInterface>( name: string ): T {
|
|
380
|
+
if( name=="form-element" ) {
|
|
381
|
+
const i: IFormElement = {
|
|
382
|
+
getRawValue: ( ): any => { return this.getValue(); },
|
|
383
|
+
setRawValue: ( v: any ) => { this.setValue(v); },
|
|
384
|
+
isValid: ( ) => { return this.isValid(); }
|
|
385
|
+
};
|
|
386
|
+
|
|
387
|
+
//@ts-ignore
|
|
388
|
+
return i as T;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
return super.queryInterface( name );
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+
|
|
398
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512" fill="currentColor"><!--!Font Awesome Free 6.7.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M214.6 41.4c-12.5-12.5-32.8-12.5-45.3 0l-160 160c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L160 141.2 160 448c0 17.7 14.3 32 32 32s32-14.3 32-32l0-306.7L329.4 246.6c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3l-160-160z"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512" fill="currentColor"><!--!Font Awesome Free 6.7.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M576 128c0-35.3-28.7-64-64-64L205.3 64c-17 0-33.3 6.7-45.3 18.7L9.4 233.4c-6 6-9.4 14.1-9.4 22.6s3.4 16.6 9.4 22.6L160 429.3c12 12 28.3 18.7 45.3 18.7L512 448c35.3 0 64-28.7 64-64l0-256zM271 175c9.4-9.4 24.6-9.4 33.9 0l47 47 47-47c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9l-47 47 47 47c9.4 9.4 9.4 24.6 0 33.9s-24.6 9.4-33.9 0l-47-47-47 47c-9.4 9.4-24.6 9.4-33.9 0s-9.4-24.6 0-33.9l47-47-47-47c-9.4-9.4-9.4-24.6 0-33.9z"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512" fill="currentColor"><!--!Font Awesome Free 6.7.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.--><path d="M38.8 5.1C28.4-3.1 13.3-1.2 5.1 9.2S-1.2 34.7 9.2 42.9l592 464c10.4 8.2 25.5 6.3 33.7-4.1s6.3-25.5-4.1-33.7L525.6 386.7c39.6-40.6 66.4-86.1 79.9-118.4c3.3-7.9 3.3-16.7 0-24.6c-14.9-35.7-46.2-87.7-93-131.1C465.5 68.8 400.8 32 320 32c-68.2 0-125 26.3-169.3 60.8L38.8 5.1zm151 118.3C226 97.7 269.5 80 320 80c65.2 0 118.8 29.6 159.9 67.7C518.4 183.5 545 226 558.6 256c-12.6 28-36.6 66.8-70.9 100.9l-53.8-42.2c9.1-17.6 14.2-37.5 14.2-58.7c0-70.7-57.3-128-128-128c-32.2 0-61.7 11.9-84.2 31.5l-46.1-36.1zM394.9 284.2l-81.5-63.9c4.2-8.5 6.6-18.2 6.6-28.3c0-5.5-.7-10.9-2-16c.7 0 1.3 0 2 0c44.2 0 80 35.8 80 80c0 9.9-1.8 19.4-5.1 28.2zm9.4 130.3C378.8 425.4 350.7 432 320 432c-65.2 0-118.8-29.6-159.9-67.7C121.6 328.5 95 286 81.4 256c8.3-18.4 21.5-41.5 39.4-64.8L83.1 161.5C60.3 191.2 44 220.8 34.5 243.7c-3.3 7.9-3.3 16.7 0 24.6c14.9 35.7 46.2 87.7 93 131.1C174.5 443.2 239.2 480 320 480c47.8 0 89.9-12.9 126.2-32.5l-41.9-33zM192 256c0 70.7 57.3 128 128 128c13.3 0 26.1-2 38.2-5.8L302 334c-23.5-5.4-43.1-21.2-53.7-42.3l-56.1-44.2c-.2 2.8-.3 5.6-.3 8.5z"/></svg>
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ___ ___ __
|
|
3
|
+
* \ \/ / / _
|
|
4
|
+
* \ / /_| |_
|
|
5
|
+
* / \____ _|
|
|
6
|
+
* /__/\__\ |_|.2
|
|
7
|
+
*
|
|
8
|
+
* @file keyboard.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
|
+
--keyboard-key-background: #33302d;
|
|
19
|
+
--keyboard-hilite-color: #5ba921;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.x4keyboard {
|
|
23
|
+
z-index: 2000;
|
|
24
|
+
position: absolute !important;
|
|
25
|
+
width: 100vw;
|
|
26
|
+
height: 14rem;
|
|
27
|
+
bottom: 0;
|
|
28
|
+
|
|
29
|
+
background-color: rgba(0,0,0,0.9);
|
|
30
|
+
|
|
31
|
+
box-sizing: border-box;
|
|
32
|
+
padding: 4px;
|
|
33
|
+
|
|
34
|
+
#kb {
|
|
35
|
+
width: 100vw;
|
|
36
|
+
max-width: 800px;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.line {
|
|
40
|
+
flex-grow: 10;
|
|
41
|
+
position: relative;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.mi {
|
|
45
|
+
font-family: 'Material Icons';
|
|
46
|
+
font-size: 22px;
|
|
47
|
+
text-align: center;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.tch {
|
|
51
|
+
cursor: pointer;
|
|
52
|
+
|
|
53
|
+
flex-grow: 10;
|
|
54
|
+
flex-basis: 44px;
|
|
55
|
+
|
|
56
|
+
display: flex;
|
|
57
|
+
align-items: center;
|
|
58
|
+
|
|
59
|
+
div {
|
|
60
|
+
width: 100%;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
color: white;
|
|
64
|
+
text-align: center;
|
|
65
|
+
|
|
66
|
+
background-color: var( --keyboard-key-background);
|
|
67
|
+
border: 1px solid var( --keyboard-key-background);
|
|
68
|
+
|
|
69
|
+
border-radius: 4px;
|
|
70
|
+
margin: 2px 4px;
|
|
71
|
+
box-sizing: border-box;
|
|
72
|
+
|
|
73
|
+
&:hover {
|
|
74
|
+
border: 1px solid var( --keyboard-hilite-color);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
&:active {
|
|
78
|
+
background-color: var( --keyboard-hilite-color);
|
|
79
|
+
color: var( --keyboard-key-background);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
.cplace {
|
|
85
|
+
visibility: hidden;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.kbicon {
|
|
89
|
+
div {
|
|
90
|
+
width: 0;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.cret {
|
|
95
|
+
color: var( --keyboard-hilite-color);
|
|
96
|
+
font-weight: bold;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.cdel,
|
|
100
|
+
.cshift,
|
|
101
|
+
.chide {
|
|
102
|
+
.x4icon {
|
|
103
|
+
margin: auto;
|
|
104
|
+
color: var( --keyboard-hilite-color);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// color: rgba(255,255,255,0.3);
|
|
109
|
+
|
|
110
|
+
.lower,
|
|
111
|
+
.upper {
|
|
112
|
+
|
|
113
|
+
.cspace {
|
|
114
|
+
flex-basis: 689px;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.cret {
|
|
118
|
+
flex-basis: 84px;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.cshift {
|
|
122
|
+
flex-basis: 60px;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.chide {
|
|
126
|
+
flex-basis: 88px;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.cnum {
|
|
130
|
+
flex-basis: 88px;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|