x4js 1.5.17 → 1.5.20
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/lib/{README.md → README.txt} +0 -0
- package/lib/cjs/index.js +39 -103
- package/lib/cjs/index.js.map +7 -0
- package/lib/esm/index.mjs +39 -87
- package/lib/esm/index.mjs.map +7 -0
- package/lib/{license.md → licence.md} +0 -0
- package/lib/src/MIT-license.md +14 -0
- package/lib/{types/action.d.ts → src/action.ts} +64 -33
- package/lib/src/alpha.jpg +0 -0
- package/lib/src/app_sockets.ts +81 -0
- package/lib/src/application.ts +251 -0
- package/lib/src/autocomplete.ts +197 -0
- package/lib/src/base64.ts +166 -0
- package/lib/src/base_component.ts +152 -0
- package/lib/src/button.ts +355 -0
- package/lib/src/calendar.ts +328 -0
- package/lib/src/canvas.ts +505 -0
- package/lib/src/cardview.ts +227 -0
- package/lib/src/checkbox.ts +188 -0
- package/lib/src/color.ts +752 -0
- package/lib/src/colorpicker.ts +1639 -0
- package/lib/src/combobox.ts +465 -0
- package/lib/src/component.ts +2329 -0
- package/lib/{esm/dom_events.js → src/copyright.txt} +27 -29
- package/lib/src/datastore.ts +1322 -0
- package/lib/src/dialog.ts +656 -0
- package/lib/src/dom_events.ts +315 -0
- package/lib/src/drag_manager.ts +199 -0
- package/lib/src/drawtext.ts +355 -0
- package/lib/src/fileupload.ts +213 -0
- package/lib/src/form.ts +375 -0
- package/lib/src/formatters.ts +105 -0
- package/lib/src/gridview.ts +1185 -0
- package/lib/src/i18n.ts +346 -0
- package/lib/src/icon.ts +335 -0
- package/lib/src/image.ts +204 -0
- package/lib/src/index.ts +89 -0
- package/lib/src/input.ts +249 -0
- package/lib/src/label.ts +128 -0
- package/lib/src/layout.ts +430 -0
- package/lib/src/link.ts +86 -0
- package/lib/src/listview.ts +765 -0
- package/lib/{esm/md5.js → src/md5.ts} +438 -403
- package/lib/src/menu.ts +425 -0
- package/lib/src/messagebox.ts +224 -0
- package/lib/src/panel.ts +86 -0
- package/lib/src/popup.ts +494 -0
- package/lib/src/property_editor.ts +337 -0
- package/lib/src/radiobtn.ts +197 -0
- package/lib/src/rating.ts +135 -0
- package/lib/src/request.ts +300 -0
- package/lib/src/router.ts +185 -0
- package/lib/src/settings.ts +77 -0
- package/lib/src/sidebarview.ts +103 -0
- package/lib/src/spreadsheet.ts +1449 -0
- package/lib/src/styles.ts +343 -0
- package/lib/src/svgcomponent.ts +577 -0
- package/lib/src/tabbar.ts +151 -0
- package/lib/src/tabview.ts +110 -0
- package/lib/src/textarea.ts +235 -0
- package/lib/src/textedit.ts +544 -0
- package/lib/src/toaster.ts +80 -0
- package/lib/src/tools.ts +1473 -0
- package/lib/src/tooltips.ts +191 -0
- package/lib/src/treeview.ts +716 -0
- package/lib/{esm/version.js → src/version.ts} +30 -29
- package/lib/{styles → src}/x4.less +0 -0
- package/lib/src/x4dom.ts +57 -0
- package/lib/src/x4events.ts +585 -0
- package/lib/src/x4react.ts +90 -0
- package/package.json +52 -49
- package/lib/cjs/action.js +0 -58
- package/lib/cjs/app_sockets.js +0 -74
- package/lib/cjs/application.js +0 -182
- package/lib/cjs/autocomplete.js +0 -155
- package/lib/cjs/base_component.js +0 -124
- package/lib/cjs/button.js +0 -263
- package/lib/cjs/calendar.js +0 -254
- package/lib/cjs/canvas.js +0 -361
- package/lib/cjs/cardview.js +0 -161
- package/lib/cjs/checkbox.js +0 -139
- package/lib/cjs/color.js +0 -591
- package/lib/cjs/colorpicker.js +0 -1468
- package/lib/cjs/combobox.js +0 -349
- package/lib/cjs/component.js +0 -1719
- package/lib/cjs/datastore.js +0 -985
- package/lib/cjs/dialog.js +0 -478
- package/lib/cjs/dom_events.js +0 -30
- package/lib/cjs/drag_manager.js +0 -145
- package/lib/cjs/drawtext.js +0 -276
- package/lib/cjs/fileupload.js +0 -167
- package/lib/cjs/form.js +0 -304
- package/lib/cjs/formatters.js +0 -90
- package/lib/cjs/gridview.js +0 -881
- package/lib/cjs/i18n.js +0 -266
- package/lib/cjs/icon.js +0 -272
- package/lib/cjs/image.js +0 -157
- package/lib/cjs/input.js +0 -174
- package/lib/cjs/label.js +0 -95
- package/lib/cjs/layout.js +0 -322
- package/lib/cjs/link.js +0 -64
- package/lib/cjs/listview.js +0 -546
- package/lib/cjs/md5.js +0 -403
- package/lib/cjs/menu.js +0 -301
- package/lib/cjs/messagebox.js +0 -177
- package/lib/cjs/panel.js +0 -68
- package/lib/cjs/popup.js +0 -383
- package/lib/cjs/property_editor.js +0 -252
- package/lib/cjs/radiobtn.js +0 -140
- package/lib/cjs/rating.js +0 -102
- package/lib/cjs/request.js +0 -246
- package/lib/cjs/router.js +0 -139
- package/lib/cjs/settings.js +0 -69
- package/lib/cjs/sidebarview.js +0 -82
- package/lib/cjs/spreadsheet.js +0 -1084
- package/lib/cjs/styles.js +0 -275
- package/lib/cjs/svgcomponent.js +0 -447
- package/lib/cjs/tabbar.js +0 -111
- package/lib/cjs/tabview.js +0 -85
- package/lib/cjs/textarea.js +0 -165
- package/lib/cjs/textedit.js +0 -415
- package/lib/cjs/toaster.js +0 -64
- package/lib/cjs/tools.js +0 -1197
- package/lib/cjs/tooltips.js +0 -157
- package/lib/cjs/treeview.js +0 -535
- package/lib/cjs/version.js +0 -32
- package/lib/cjs/x4dom.js +0 -32
- package/lib/cjs/x4events.js +0 -384
- package/lib/cjs/x4react.js +0 -72
- package/lib/esm/action.js +0 -53
- package/lib/esm/app_sockets.js +0 -70
- package/lib/esm/application.js +0 -184
- package/lib/esm/autocomplete.js +0 -155
- package/lib/esm/base_component.js +0 -107
- package/lib/esm/button.js +0 -257
- package/lib/esm/calendar.js +0 -249
- package/lib/esm/canvas.js +0 -358
- package/lib/esm/cardview.js +0 -159
- package/lib/esm/checkbox.js +0 -134
- package/lib/esm/color.js +0 -588
- package/lib/esm/colorpicker.js +0 -1475
- package/lib/esm/combobox.js +0 -351
- package/lib/esm/component.js +0 -1711
- package/lib/esm/datastore.js +0 -990
- package/lib/esm/dialog.js +0 -490
- package/lib/esm/drag_manager.js +0 -147
- package/lib/esm/drawtext.js +0 -271
- package/lib/esm/fileupload.js +0 -163
- package/lib/esm/form.js +0 -304
- package/lib/esm/formatters.js +0 -81
- package/lib/esm/gridview.js +0 -889
- package/lib/esm/i18n.js +0 -257
- package/lib/esm/icon.js +0 -261
- package/lib/esm/image.js +0 -154
- package/lib/esm/input.js +0 -182
- package/lib/esm/label.js +0 -90
- package/lib/esm/layout.js +0 -310
- package/lib/esm/link.js +0 -59
- package/lib/esm/listview.js +0 -534
- package/lib/esm/menu.js +0 -300
- package/lib/esm/messagebox.js +0 -161
- package/lib/esm/panel.js +0 -65
- package/lib/esm/popup.js +0 -379
- package/lib/esm/property_editor.js +0 -251
- package/lib/esm/radiobtn.js +0 -136
- package/lib/esm/rating.js +0 -97
- package/lib/esm/request.js +0 -224
- package/lib/esm/router.js +0 -136
- package/lib/esm/settings.js +0 -66
- package/lib/esm/sidebarview.js +0 -79
- package/lib/esm/spreadsheet.js +0 -1097
- package/lib/esm/styles.js +0 -270
- package/lib/esm/svgcomponent.js +0 -450
- package/lib/esm/tabbar.js +0 -107
- package/lib/esm/tabview.js +0 -83
- package/lib/esm/textarea.js +0 -160
- package/lib/esm/textedit.js +0 -412
- package/lib/esm/toaster.js +0 -62
- package/lib/esm/tools.js +0 -1158
- package/lib/esm/tooltips.js +0 -153
- package/lib/esm/treeview.js +0 -527
- package/lib/esm/x4dom.js +0 -29
- package/lib/esm/x4events.js +0 -376
- package/lib/esm/x4react.js +0 -71
- package/lib/types/app_sockets.d.ts +0 -29
- package/lib/types/application.d.ts +0 -104
- package/lib/types/autocomplete.d.ts +0 -58
- package/lib/types/base_component.d.ts +0 -88
- package/lib/types/button.d.ts +0 -151
- package/lib/types/calendar.d.ts +0 -82
- package/lib/types/canvas.d.ts +0 -92
- package/lib/types/cardview.d.ts +0 -87
- package/lib/types/checkbox.d.ts +0 -77
- package/lib/types/color.d.ts +0 -148
- package/lib/types/colorpicker.d.ts +0 -107
- package/lib/types/combobox.d.ts +0 -107
- package/lib/types/component.d.ts +0 -601
- package/lib/types/datastore.d.ts +0 -396
- package/lib/types/dialog.d.ts +0 -175
- package/lib/types/dom_events.d.ts +0 -302
- package/lib/types/drag_manager.d.ts +0 -54
- package/lib/types/drawtext.d.ts +0 -48
- package/lib/types/fileupload.d.ts +0 -64
- package/lib/types/form.d.ts +0 -133
- package/lib/types/formatters.d.ts +0 -35
- package/lib/types/gridview.d.ts +0 -175
- package/lib/types/i18n.d.ts +0 -73
- package/lib/types/icon.d.ts +0 -64
- package/lib/types/image.d.ts +0 -55
- package/lib/types/index.d.ts +0 -84
- package/lib/types/input.d.ts +0 -91
- package/lib/types/label.d.ts +0 -58
- package/lib/types/layout.d.ts +0 -87
- package/lib/types/link.d.ts +0 -50
- package/lib/types/listview.d.ts +0 -178
- package/lib/types/md5.d.ts +0 -61
- package/lib/types/menu.d.ts +0 -130
- package/lib/types/messagebox.d.ts +0 -69
- package/lib/types/panel.d.ts +0 -47
- package/lib/types/popup.d.ts +0 -75
- package/lib/types/property_editor.d.ts +0 -71
- package/lib/types/radiobtn.d.ts +0 -73
- package/lib/types/rating.d.ts +0 -53
- package/lib/types/request.d.ts +0 -52
- package/lib/types/router.d.ts +0 -42
- package/lib/types/settings.d.ts +0 -37
- package/lib/types/sidebarview.d.ts +0 -49
- package/lib/types/spreadsheet.d.ts +0 -222
- package/lib/types/styles.d.ts +0 -85
- package/lib/types/svgcomponent.d.ts +0 -215
- package/lib/types/tabbar.d.ts +0 -58
- package/lib/types/tabview.d.ts +0 -49
- package/lib/types/textarea.d.ts +0 -77
- package/lib/types/textedit.d.ts +0 -123
- package/lib/types/toaster.d.ts +0 -42
- package/lib/types/tools.d.ts +0 -394
- package/lib/types/tooltips.d.ts +0 -46
- package/lib/types/treeview.d.ts +0 -144
- package/lib/types/version.d.ts +0 -29
- package/lib/types/x4dom.d.ts +0 -49
- package/lib/types/x4events.d.ts +0 -269
- package/lib/types/x4react.d.ts +0 -41
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* ___ ___ __
|
|
4
|
-
* \ \_/ / / _
|
|
5
|
-
* \ / /_| |_
|
|
6
|
-
* / _ \____ _|
|
|
7
|
-
* /__/ \__\ |_|
|
|
8
|
-
*
|
|
9
|
-
* @file propertyeditor.ts
|
|
10
|
-
* @author Etienne Cochard
|
|
11
|
-
*
|
|
12
|
-
* Copyright (c) 2019-2022 R-libre ingenierie
|
|
13
|
-
*
|
|
14
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
15
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
16
|
-
* in the Software without restriction, including without limitation the rights
|
|
17
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
18
|
-
* of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
19
|
-
* subject to the following conditions:
|
|
20
|
-
* The above copyright notice and this permission notice shall be included in all copies
|
|
21
|
-
* or substantial portions of the Software.
|
|
22
|
-
*
|
|
23
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
24
|
-
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
|
25
|
-
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
26
|
-
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
27
|
-
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
28
|
-
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
29
|
-
**/
|
|
30
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
-
exports.PropertyEditor = void 0;
|
|
32
|
-
const component_1 = require("./component");
|
|
33
|
-
const x4events_1 = require("./x4events");
|
|
34
|
-
const input_1 = require("./input");
|
|
35
|
-
const textedit_1 = require("./textedit");
|
|
36
|
-
const checkbox_1 = require("./checkbox");
|
|
37
|
-
const spreadsheet_1 = require("./spreadsheet");
|
|
38
|
-
const i18n_1 = require("./i18n");
|
|
39
|
-
class PropertyEditor extends component_1.Component {
|
|
40
|
-
constructor(props) {
|
|
41
|
-
super(props);
|
|
42
|
-
this.mapPropEvents(props, 'change');
|
|
43
|
-
}
|
|
44
|
-
render(props) {
|
|
45
|
-
var _a;
|
|
46
|
-
this.m_record = props.record;
|
|
47
|
-
this.m_fields = (_a = props.fields) !== null && _a !== void 0 ? _a : [];
|
|
48
|
-
this.m_label_w = props.labelWidth;
|
|
49
|
-
this.m_sheet = new spreadsheet_1.Spreadsheet({
|
|
50
|
-
cls: '@fit',
|
|
51
|
-
columns: [
|
|
52
|
-
{
|
|
53
|
-
title: i18n_1._tr.global.property,
|
|
54
|
-
width: this.m_label_w > 0 ? this.m_label_w : -1,
|
|
55
|
-
cls: 'property'
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
title: i18n_1._tr.global.value,
|
|
59
|
-
width: -1,
|
|
60
|
-
createEditor: (...a) => this._editCell(...a),
|
|
61
|
-
renderer: (...a) => this._renderCell(...a)
|
|
62
|
-
},
|
|
63
|
-
],
|
|
64
|
-
autoedit: true,
|
|
65
|
-
change: (e) => this._cellChange(e)
|
|
66
|
-
});
|
|
67
|
-
this._updateProperties();
|
|
68
|
-
this.setContent(this.m_sheet);
|
|
69
|
-
}
|
|
70
|
-
setFields(fields) {
|
|
71
|
-
if (fields) {
|
|
72
|
-
this.m_fields = fields;
|
|
73
|
-
this._updateProperties();
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
this.m_sheet.clearData();
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
setRecord(record) {
|
|
80
|
-
this.m_record = record;
|
|
81
|
-
this._updateProperties();
|
|
82
|
-
}
|
|
83
|
-
_updateProperties() {
|
|
84
|
-
this.m_sheet.lockUpdate(true);
|
|
85
|
-
this.m_sheet.clearData();
|
|
86
|
-
this.m_fields.forEach((fld, lno) => {
|
|
87
|
-
this.m_sheet.setCellText(lno, 0, fld.title);
|
|
88
|
-
if (this.m_record) {
|
|
89
|
-
this.m_sheet.setCellText(lno, 1, this.m_record.getField(fld.id));
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
this.m_sheet.setCellText(lno, 1, fld.value);
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
this.m_sheet.lockUpdate(false);
|
|
96
|
-
}
|
|
97
|
-
_cellChange(ev) {
|
|
98
|
-
let ctx = ev.context;
|
|
99
|
-
let text = ev.value;
|
|
100
|
-
if (ctx.col != 1) {
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
let fld = this.m_fields[ctx.row];
|
|
104
|
-
switch (fld.type) {
|
|
105
|
-
default:
|
|
106
|
-
case 'string': {
|
|
107
|
-
break;
|
|
108
|
-
}
|
|
109
|
-
case 'number': {
|
|
110
|
-
break;
|
|
111
|
-
}
|
|
112
|
-
case 'password': {
|
|
113
|
-
break;
|
|
114
|
-
}
|
|
115
|
-
case 'boolean': {
|
|
116
|
-
break;
|
|
117
|
-
}
|
|
118
|
-
case 'choice': {
|
|
119
|
-
/*
|
|
120
|
-
let cprops = <ComboBoxProps>fprops;
|
|
121
|
-
if( cprops!==fld.props ) {
|
|
122
|
-
|
|
123
|
-
let choices;
|
|
124
|
-
if( isArray(fld.values) ) {
|
|
125
|
-
choices = this._choicesFromArray( fld.values );
|
|
126
|
-
}
|
|
127
|
-
else if( fld.values instanceof DataStore ) {
|
|
128
|
-
choices = this._choicesFromStore( fld.values, 'name' );
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
cprops.items = choices;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
editor = new ComboBox( cprops );
|
|
135
|
-
*/
|
|
136
|
-
break;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
if (this.m_record) {
|
|
140
|
-
this.m_record.setField(fld.id, text);
|
|
141
|
-
}
|
|
142
|
-
else {
|
|
143
|
-
fld.value = text;
|
|
144
|
-
}
|
|
145
|
-
this.emit('change', (0, x4events_1.EvChange)(text, fld));
|
|
146
|
-
}
|
|
147
|
-
_renderCell(text, rec) {
|
|
148
|
-
let fld = this.m_fields[rec.row];
|
|
149
|
-
switch (fld.type) {
|
|
150
|
-
default:
|
|
151
|
-
case 'string': {
|
|
152
|
-
break;
|
|
153
|
-
}
|
|
154
|
-
case 'number': {
|
|
155
|
-
break;
|
|
156
|
-
}
|
|
157
|
-
case 'password': {
|
|
158
|
-
text = '●●●●●●';
|
|
159
|
-
break;
|
|
160
|
-
}
|
|
161
|
-
case 'boolean': {
|
|
162
|
-
break;
|
|
163
|
-
}
|
|
164
|
-
case 'choice': {
|
|
165
|
-
/*
|
|
166
|
-
let cprops = <ComboBoxProps>fprops;
|
|
167
|
-
if( cprops!==fld.props ) {
|
|
168
|
-
|
|
169
|
-
let choices;
|
|
170
|
-
if( isArray(fld.values) ) {
|
|
171
|
-
choices = this._choicesFromArray( fld.values );
|
|
172
|
-
}
|
|
173
|
-
else if( fld.values instanceof DataStore ) {
|
|
174
|
-
choices = this._choicesFromStore( fld.values, 'name' );
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
cprops.items = choices;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
editor = new ComboBox( cprops );
|
|
181
|
-
*/
|
|
182
|
-
break;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
return text;
|
|
186
|
-
}
|
|
187
|
-
_editCell(props, row, col) {
|
|
188
|
-
let fld = this.m_fields[row];
|
|
189
|
-
let editor;
|
|
190
|
-
switch (fld.type) {
|
|
191
|
-
default:
|
|
192
|
-
case 'string': {
|
|
193
|
-
editor = new textedit_1.TextEdit(props);
|
|
194
|
-
break;
|
|
195
|
-
}
|
|
196
|
-
case 'number': {
|
|
197
|
-
editor = new textedit_1.TextEdit(props);
|
|
198
|
-
break;
|
|
199
|
-
}
|
|
200
|
-
case 'password': {
|
|
201
|
-
props.type = 'password';
|
|
202
|
-
props.value = this.m_record.getField(fld.id);
|
|
203
|
-
editor = new input_1.Input(props);
|
|
204
|
-
break;
|
|
205
|
-
}
|
|
206
|
-
case 'boolean': {
|
|
207
|
-
editor = new checkbox_1.CheckBox(props);
|
|
208
|
-
break;
|
|
209
|
-
}
|
|
210
|
-
case 'choice': {
|
|
211
|
-
/*let cprops = <ComboBoxProps>props;
|
|
212
|
-
if( cprops!==fld.props ) {
|
|
213
|
-
|
|
214
|
-
let choices;
|
|
215
|
-
if( isArray(fld.values) ) {
|
|
216
|
-
choices = this._choicesFromArray( fld.values );
|
|
217
|
-
}
|
|
218
|
-
else if( fld.values instanceof DataStore ) {
|
|
219
|
-
choices = this._choicesFromStore( fld.values, 'name' );
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
cprops.items = choices;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
editor = new ComboBox( cprops );
|
|
226
|
-
*/
|
|
227
|
-
break;
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
return editor;
|
|
231
|
-
}
|
|
232
|
-
_choicesFromArray(values) {
|
|
233
|
-
let choices = values.map((e) => {
|
|
234
|
-
if (typeof (e) == 'object') {
|
|
235
|
-
return { id: e.id, text: e.value };
|
|
236
|
-
}
|
|
237
|
-
else {
|
|
238
|
-
return { id: e, text: '' + e };
|
|
239
|
-
}
|
|
240
|
-
});
|
|
241
|
-
return choices;
|
|
242
|
-
}
|
|
243
|
-
_choicesFromStore(view, field) {
|
|
244
|
-
let choices = [];
|
|
245
|
-
for (let i = 0, n = view.count; i < n; i++) {
|
|
246
|
-
let rec = view.getByIndex(i);
|
|
247
|
-
choices.push({ id: rec.getID(), text: rec.getField(field) });
|
|
248
|
-
}
|
|
249
|
-
return choices;
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
exports.PropertyEditor = PropertyEditor;
|
package/lib/cjs/radiobtn.js
DELETED
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* ___ ___ __
|
|
4
|
-
* \ \_/ / / _
|
|
5
|
-
* \ / /_| |_
|
|
6
|
-
* / _ \____ _|
|
|
7
|
-
* /__/ \__\ |_|
|
|
8
|
-
*
|
|
9
|
-
* @file radiobtn.ts
|
|
10
|
-
* @author Etienne Cochard
|
|
11
|
-
*
|
|
12
|
-
* Copyright (c) 2019-2022 R-libre ingenierie
|
|
13
|
-
*
|
|
14
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
15
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
16
|
-
* in the Software without restriction, including without limitation the rights
|
|
17
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
18
|
-
* of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
19
|
-
* subject to the following conditions:
|
|
20
|
-
* The above copyright notice and this permission notice shall be included in all copies
|
|
21
|
-
* or substantial portions of the Software.
|
|
22
|
-
*
|
|
23
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
24
|
-
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
|
25
|
-
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
26
|
-
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
27
|
-
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
28
|
-
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
29
|
-
**/
|
|
30
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
-
exports.RadioBtn = void 0;
|
|
32
|
-
const x4dom_1 = require("./x4dom");
|
|
33
|
-
const component_1 = require("./component");
|
|
34
|
-
const x4events_1 = require("./x4events");
|
|
35
|
-
const input_1 = require("./input");
|
|
36
|
-
const label_1 = require("./label");
|
|
37
|
-
/**
|
|
38
|
-
* Standard RadioBtn
|
|
39
|
-
*/
|
|
40
|
-
class RadioBtn extends component_1.Component {
|
|
41
|
-
constructor(props) {
|
|
42
|
-
super(props);
|
|
43
|
-
this.mapPropEvents(props, 'change');
|
|
44
|
-
}
|
|
45
|
-
/** @ignore */
|
|
46
|
-
render(props) {
|
|
47
|
-
var _a, _b, _c, _d, _e;
|
|
48
|
-
let text = (_a = props.text) !== null && _a !== void 0 ? _a : '';
|
|
49
|
-
let name = (_b = props.name) !== null && _b !== void 0 ? _b : props.group;
|
|
50
|
-
let labelWidth = (_c = props.labelWidth) !== null && _c !== void 0 ? _c : -1;
|
|
51
|
-
let checked = (_d = props.checked) !== null && _d !== void 0 ? _d : false;
|
|
52
|
-
let align = (_e = props.align) !== null && _e !== void 0 ? _e : 'left';
|
|
53
|
-
let value = props.value;
|
|
54
|
-
let icon = props.icon;
|
|
55
|
-
this.setTag('label');
|
|
56
|
-
this.addClass('@hlayout');
|
|
57
|
-
this.addClass(align);
|
|
58
|
-
this._setTabIndex(props.tabIndex);
|
|
59
|
-
if (checked) {
|
|
60
|
-
this.addClass('checked');
|
|
61
|
-
}
|
|
62
|
-
this.setContent([
|
|
63
|
-
this.m_ui_input = new input_1.Input({
|
|
64
|
-
type: 'radio',
|
|
65
|
-
name: name,
|
|
66
|
-
tabIndex: props.tabIndex,
|
|
67
|
-
value: value,
|
|
68
|
-
attrs: {
|
|
69
|
-
checked: checked ? '' : undefined
|
|
70
|
-
},
|
|
71
|
-
dom_events: {
|
|
72
|
-
change: () => this._change(),
|
|
73
|
-
focus: () => this.m_ui_input.focus(),
|
|
74
|
-
}
|
|
75
|
-
}),
|
|
76
|
-
new label_1.Label({
|
|
77
|
-
ref: 'label',
|
|
78
|
-
icon: icon,
|
|
79
|
-
text: text,
|
|
80
|
-
width: labelWidth === 'flex' ? undefined : labelWidth,
|
|
81
|
-
flex: labelWidth === 'flex' ? 1 : undefined,
|
|
82
|
-
style: {
|
|
83
|
-
order: align == 'right' ? -1 : undefined,
|
|
84
|
-
},
|
|
85
|
-
})
|
|
86
|
-
]);
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* check state changed
|
|
90
|
-
*/
|
|
91
|
-
_change() {
|
|
92
|
-
let props = this.m_props;
|
|
93
|
-
let query = '.x-input[name=' + props.name + ']';
|
|
94
|
-
let nlist = x4dom_1.x4document.querySelectorAll(query); //todo: document ?
|
|
95
|
-
nlist.forEach((dom) => {
|
|
96
|
-
let radio = component_1.Component.getElement(dom, RadioBtn);
|
|
97
|
-
radio.removeClass('checked');
|
|
98
|
-
});
|
|
99
|
-
let dom = this.m_ui_input.dom;
|
|
100
|
-
this.setClass('checked', dom.checked);
|
|
101
|
-
this.emit('change', (0, x4events_1.EvChange)(true));
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* @return the checked value
|
|
105
|
-
*/
|
|
106
|
-
get check() {
|
|
107
|
-
if (this.m_ui_input) {
|
|
108
|
-
return this.m_ui_input.dom.checked;
|
|
109
|
-
}
|
|
110
|
-
return this.m_props.checked;
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* change the checked value
|
|
114
|
-
* @param {boolean} ck new checked value
|
|
115
|
-
*/
|
|
116
|
-
set check(ck) {
|
|
117
|
-
let dom = this.m_ui_input.dom;
|
|
118
|
-
if (ck) {
|
|
119
|
-
//this.addClass( 'checked' );
|
|
120
|
-
if (dom) {
|
|
121
|
-
dom.checked = true;
|
|
122
|
-
}
|
|
123
|
-
this.m_props.checked = true;
|
|
124
|
-
}
|
|
125
|
-
else {
|
|
126
|
-
//this.removeClass( 'checked' );
|
|
127
|
-
if (dom) {
|
|
128
|
-
dom.checked = false;
|
|
129
|
-
}
|
|
130
|
-
this.m_props.checked = false;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
get text() {
|
|
134
|
-
return this.itemWithRef('label').text;
|
|
135
|
-
}
|
|
136
|
-
set text(text) {
|
|
137
|
-
this.itemWithRef('label').text = text;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
exports.RadioBtn = RadioBtn;
|
package/lib/cjs/rating.js
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* ___ ___ __
|
|
4
|
-
* \ \_/ / / _
|
|
5
|
-
* \ / /_| |_
|
|
6
|
-
* / _ \____ _|
|
|
7
|
-
* /__/ \__\ |_|
|
|
8
|
-
*
|
|
9
|
-
* @file rating.ts
|
|
10
|
-
* @author Etienne Cochard
|
|
11
|
-
*
|
|
12
|
-
* Copyright (c) 2019-2022 R-libre ingenierie
|
|
13
|
-
*
|
|
14
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
15
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
16
|
-
* in the Software without restriction, including without limitation the rights
|
|
17
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
18
|
-
* of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
19
|
-
* subject to the following conditions:
|
|
20
|
-
* The above copyright notice and this permission notice shall be included in all copies
|
|
21
|
-
* or substantial portions of the Software.
|
|
22
|
-
*
|
|
23
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
24
|
-
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
|
25
|
-
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
26
|
-
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
27
|
-
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
28
|
-
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
29
|
-
**/
|
|
30
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
-
exports.Rating = void 0;
|
|
32
|
-
const component_1 = require("./component");
|
|
33
|
-
const layout_1 = require("./layout");
|
|
34
|
-
const input_1 = require("./input");
|
|
35
|
-
const x4events_1 = require("./x4events");
|
|
36
|
-
class Rating extends layout_1.HLayout {
|
|
37
|
-
constructor(props) {
|
|
38
|
-
var _a;
|
|
39
|
-
super(props);
|
|
40
|
-
props.steps = (_a = props.steps) !== null && _a !== void 0 ? _a : 5;
|
|
41
|
-
}
|
|
42
|
-
render(props) {
|
|
43
|
-
var _a, _b;
|
|
44
|
-
let shape = (_a = props.shape) !== null && _a !== void 0 ? _a : 'star';
|
|
45
|
-
let value = (_b = props.value) !== null && _b !== void 0 ? _b : 0;
|
|
46
|
-
this.m_input = new input_1.Input({
|
|
47
|
-
cls: '@hidden',
|
|
48
|
-
name: props.name,
|
|
49
|
-
value: '' + value
|
|
50
|
-
});
|
|
51
|
-
this.addClass(shape);
|
|
52
|
-
this.setDomEvent('click', (e) => this._onclick(e));
|
|
53
|
-
this.m_els = [];
|
|
54
|
-
for (let i = 0; i < props.steps; i++) {
|
|
55
|
-
let cls = 'item';
|
|
56
|
-
if (i + 1 <= value) {
|
|
57
|
-
cls += ' checked';
|
|
58
|
-
}
|
|
59
|
-
let c = new component_1.Component({
|
|
60
|
-
tag: 'option',
|
|
61
|
-
cls,
|
|
62
|
-
data: { value: i + 1 }
|
|
63
|
-
});
|
|
64
|
-
this.m_els.push(c);
|
|
65
|
-
}
|
|
66
|
-
this.m_els.push(this.m_input);
|
|
67
|
-
this.setContent(this.m_els);
|
|
68
|
-
}
|
|
69
|
-
getValue() {
|
|
70
|
-
var _a;
|
|
71
|
-
return (_a = this.m_props.value) !== null && _a !== void 0 ? _a : 0;
|
|
72
|
-
}
|
|
73
|
-
set value(v) {
|
|
74
|
-
this.m_props.value = v;
|
|
75
|
-
for (let c = 0; c < this.m_props.steps; c++) {
|
|
76
|
-
this.m_els[c].setClass('checked', this.m_els[c].getData('value') <= v);
|
|
77
|
-
}
|
|
78
|
-
this.m_input.value = '' + this.m_props.value;
|
|
79
|
-
}
|
|
80
|
-
set steps(n) {
|
|
81
|
-
this.m_props.steps = n;
|
|
82
|
-
this.update();
|
|
83
|
-
}
|
|
84
|
-
set shape(shape) {
|
|
85
|
-
this.removeClass(this.m_props.shape);
|
|
86
|
-
this.m_props.shape = shape;
|
|
87
|
-
this.addClass(this.m_props.shape);
|
|
88
|
-
}
|
|
89
|
-
_onclick(ev) {
|
|
90
|
-
let on = true;
|
|
91
|
-
for (let el = this.dom.firstChild; el; el = el.nextSibling) {
|
|
92
|
-
let comp = component_1.Component.getElement(el);
|
|
93
|
-
comp.setClass('checked', on);
|
|
94
|
-
if (el == ev.target) {
|
|
95
|
-
this.m_input.value = comp.getData('value');
|
|
96
|
-
on = false;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
this.emit('change', (0, x4events_1.EvChange)(this.m_props.value));
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
exports.Rating = Rating;
|