x4js 1.6.4 → 2.0.1
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 +3 -14
- package/lib/README.txt +3 -14
- package/lib/src/assets/house-light.svg +1 -0
- package/lib/src/assets/radio.svg +4 -0
- package/lib/src/components/base.scss +26 -0
- package/lib/src/components/boxes/boxes.module.scss +37 -0
- package/lib/src/components/boxes/boxes.ts +125 -0
- package/lib/src/components/btngroup/btngroup.module.scss +29 -0
- package/lib/src/components/btngroup/btngroup.ts +106 -0
- package/lib/src/components/button/button.module.scss +154 -0
- package/lib/src/components/button/button.ts +117 -0
- package/lib/src/components/calendar/calendar-check-sharp-light.svg +1 -0
- package/lib/src/components/calendar/calendar.module.scss +163 -0
- package/lib/src/{calendar.ts → components/calendar/calendar.ts} +81 -83
- package/lib/src/components/calendar/chevron-left-sharp-light.svg +1 -0
- package/lib/src/components/calendar/chevron-right-sharp-light.svg +1 -0
- package/lib/src/components/checkbox/check.svg +4 -0
- package/lib/src/components/checkbox/checkbox.module.scss +142 -0
- package/lib/src/components/checkbox/checkbox.ts +125 -0
- package/lib/src/components/colorinput/colorinput.module.scss +65 -0
- package/lib/src/components/colorinput/colorinput.ts +88 -0
- package/lib/src/components/colorinput/crosshairs-simple-sharp-light.svg +1 -0
- package/lib/src/components/colorpicker/colorpicker.module.scss +133 -0
- package/lib/src/components/colorpicker/colorpicker.ts +477 -0
- package/lib/src/components/combobox/combobox.module.scss +121 -0
- package/lib/src/components/combobox/combobox.ts +190 -0
- package/lib/src/components/combobox/updown.svg +4 -0
- package/lib/src/components/dialog/dialog.module.scss +71 -0
- package/lib/src/components/dialog/dialog.ts +91 -0
- package/lib/src/components/dialog/xmark-sharp-light.svg +1 -0
- package/lib/src/components/form/form.module.scss +34 -0
- package/lib/src/components/form/form.ts +36 -0
- package/lib/src/components/header/header.module.scss +40 -0
- package/lib/src/components/header/header.ts +124 -0
- package/lib/src/components/icon/icon.module.scss +30 -0
- package/lib/src/components/icon/icon.ts +134 -0
- package/lib/src/components/image/image.module.scss +21 -0
- package/lib/src/components/image/image.ts +67 -0
- package/lib/src/components/input/input.module.scss +69 -0
- package/lib/src/components/input/input.ts +274 -0
- package/lib/src/components/label/label.module.scss +52 -0
- package/lib/src/components/label/label.ts +55 -0
- package/lib/src/components/listbox/listbox.module.scss +103 -0
- package/lib/src/components/listbox/listbox.ts +427 -0
- package/lib/src/components/menu/caret-right-solid.svg +1 -0
- package/lib/src/components/menu/menu.module.scss +108 -0
- package/lib/src/components/menu/menu.ts +168 -0
- package/lib/src/components/messages/circle-exclamation.svg +1 -0
- package/lib/src/components/messages/messages.module.scss +47 -0
- package/lib/src/components/messages/messages.ts +64 -0
- package/lib/src/components/normalize.scss +386 -0
- package/lib/src/components/notification/circle-check-solid.svg +1 -0
- package/lib/src/components/notification/circle-exclamation-solid.svg +1 -0
- package/lib/src/components/notification/circle-notch-light.svg +1 -0
- package/lib/src/components/notification/notification.module.scss +82 -0
- package/lib/src/components/notification/notification.ts +108 -0
- package/lib/src/components/notification/xmark-sharp-light.svg +1 -0
- package/lib/src/components/panel/panel.module.scss +48 -0
- package/lib/src/components/panel/panel.ts +57 -0
- package/lib/src/components/popup/popup.module.scss +43 -0
- package/lib/src/components/popup/popup.ts +395 -0
- package/lib/src/components/progress/progress.module.scss +57 -0
- package/lib/src/components/progress/progress.ts +43 -0
- package/lib/src/components/rating/rating.module.scss +23 -0
- package/lib/src/components/rating/rating.ts +125 -0
- package/lib/src/components/rating/star-sharp-light.svg +1 -0
- package/lib/src/components/rating/star-sharp-solid.svg +1 -0
- package/lib/src/components/shared.scss +76 -0
- package/lib/src/components/sizers/sizer.module.scss +90 -0
- package/lib/src/components/sizers/sizer.ts +120 -0
- package/lib/src/components/slider/slider.module.scss +71 -0
- package/lib/src/components/slider/slider.ts +143 -0
- package/lib/src/components/switch/switch.module.scss +127 -0
- package/lib/src/components/switch/switch.ts +56 -0
- package/lib/src/components/tabs/tabs.module.scss +46 -0
- package/lib/src/components/tabs/tabs.ts +157 -0
- package/lib/src/components/textarea/textarea.module.scss +59 -0
- package/lib/src/components/textarea/textarea.ts +54 -0
- package/lib/src/components/textedit/textedit.module.scss +114 -0
- package/lib/src/components/textedit/textedit.ts +82 -0
- package/lib/src/components/themes.scss +77 -0
- package/lib/src/components/tooltips/circle-info-sharp-light.svg +1 -0
- package/lib/src/components/tooltips/tooltips.scss +51 -0
- package/lib/src/components/tooltips/tooltips.ts +103 -0
- package/lib/src/components/treeview/chevron-down-light.svg +1 -0
- package/lib/src/components/treeview/treeview.module.scss +116 -0
- package/lib/src/components/treeview/treeview.ts +403 -0
- package/lib/src/components/viewport/viewport.module.scss +25 -0
- package/lib/src/components/viewport/viewport.ts +38 -0
- package/lib/src/core/component.ts +979 -0
- package/lib/src/core/core_colors.ts +250 -0
- package/lib/src/{dom_events.ts → core/core_dom.ts} +195 -39
- package/lib/src/{drag_manager.ts → core/core_dragdrop.ts} +29 -44
- package/lib/src/core/core_element.ts +98 -0
- package/lib/src/core/core_events.ts +149 -0
- package/lib/src/{i18n.ts → core/core_i18n.ts} +43 -42
- package/lib/src/{router.ts → core/core_router.ts} +27 -40
- package/lib/src/core/core_styles.ts +215 -0
- package/lib/src/core/core_svg.ts +550 -0
- package/lib/src/core/core_tools.ts +673 -0
- package/lib/src/main.scss +21 -0
- package/lib/src/main.tsx +323 -0
- package/lib/src/x4.scss +19 -0
- package/lib/types/x4.d.ts +2624 -0
- package/package.json +67 -59
- package/scripts/build.mjs +351 -0
- package/scripts/prepack.mjs +15 -0
- package/src/assets/house-light.svg +1 -0
- package/src/assets/radio.svg +4 -0
- package/src/components/base.scss +26 -0
- package/src/components/boxes/boxes.module.scss +37 -0
- package/src/components/boxes/boxes.ts +125 -0
- package/src/components/btngroup/btngroup.module.scss +29 -0
- package/src/components/btngroup/btngroup.ts +106 -0
- package/src/components/button/button.module.scss +154 -0
- package/src/components/button/button.ts +117 -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 +326 -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/checkbox/check.svg +4 -0
- package/src/components/checkbox/checkbox.module.scss +142 -0
- package/src/components/checkbox/checkbox.ts +125 -0
- package/src/components/colorinput/colorinput.module.scss +65 -0
- package/src/components/colorinput/colorinput.ts +88 -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 +477 -0
- package/src/components/combobox/combobox.module.scss +121 -0
- package/src/components/combobox/combobox.ts +190 -0
- package/src/components/combobox/updown.svg +4 -0
- package/src/components/dialog/dialog.module.scss +71 -0
- package/src/components/dialog/dialog.ts +91 -0
- package/src/components/dialog/xmark-sharp-light.svg +1 -0
- package/src/components/form/form.module.scss +34 -0
- package/src/components/form/form.ts +36 -0
- package/src/components/header/header.module.scss +40 -0
- package/src/components/header/header.ts +124 -0
- package/src/components/icon/icon.module.scss +30 -0
- package/src/components/icon/icon.ts +134 -0
- package/src/components/image/image.module.scss +21 -0
- package/src/components/image/image.ts +67 -0
- package/src/components/input/input.module.scss +69 -0
- package/src/components/input/input.ts +274 -0
- package/src/components/label/label.module.scss +52 -0
- package/src/components/label/label.ts +55 -0
- package/src/components/listbox/listbox.module.scss +103 -0
- package/src/components/listbox/listbox.ts +427 -0
- package/src/components/menu/caret-right-solid.svg +1 -0
- package/src/components/menu/menu.module.scss +108 -0
- package/src/components/menu/menu.ts +168 -0
- package/src/components/messages/circle-exclamation.svg +1 -0
- package/src/components/messages/messages.module.scss +47 -0
- package/src/components/messages/messages.ts +64 -0
- package/src/components/normalize.scss +386 -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 +82 -0
- package/src/components/notification/notification.ts +108 -0
- package/src/components/notification/xmark-sharp-light.svg +1 -0
- package/src/components/panel/panel.module.scss +48 -0
- package/src/components/panel/panel.ts +57 -0
- package/src/components/popup/popup.module.scss +43 -0
- package/src/components/popup/popup.ts +395 -0
- package/src/components/progress/progress.module.scss +57 -0
- package/src/components/progress/progress.ts +43 -0
- package/src/components/rating/rating.module.scss +23 -0
- package/src/components/rating/rating.ts +125 -0
- package/src/components/rating/star-sharp-light.svg +1 -0
- package/src/components/rating/star-sharp-solid.svg +1 -0
- package/src/components/shared.scss +76 -0
- package/src/components/sizers/sizer.module.scss +90 -0
- package/src/components/sizers/sizer.ts +120 -0
- package/src/components/slider/slider.module.scss +71 -0
- package/src/components/slider/slider.ts +143 -0
- package/src/components/switch/switch.module.scss +127 -0
- package/src/components/switch/switch.ts +56 -0
- package/src/components/tabs/tabs.module.scss +46 -0
- package/src/components/tabs/tabs.ts +157 -0
- package/src/components/textarea/textarea.module.scss +59 -0
- package/src/components/textarea/textarea.ts +54 -0
- package/src/components/textedit/textedit.module.scss +114 -0
- package/src/components/textedit/textedit.ts +82 -0
- package/src/components/themes.scss +77 -0
- package/src/components/tooltips/circle-info-sharp-light.svg +1 -0
- package/src/components/tooltips/tooltips.scss +51 -0
- package/src/components/tooltips/tooltips.ts +103 -0
- package/src/components/treeview/chevron-down-light.svg +1 -0
- package/src/components/treeview/treeview.module.scss +116 -0
- package/src/components/treeview/treeview.ts +403 -0
- package/src/components/viewport/viewport.module.scss +25 -0
- package/src/components/viewport/viewport.ts +38 -0
- package/src/core/component.ts +979 -0
- package/src/core/core_colors.ts +250 -0
- package/src/core/core_dom.ts +471 -0
- package/src/core/core_dragdrop.ts +201 -0
- package/src/core/core_element.ts +98 -0
- package/src/core/core_events.ts +149 -0
- package/src/core/core_i18n.ts +377 -0
- package/src/core/core_router.ts +221 -0
- package/src/core/core_styles.ts +215 -0
- package/src/core/core_svg.ts +550 -0
- package/src/core/core_tools.ts +673 -0
- package/src/main.scss +21 -0
- package/src/main.tsx +323 -0
- package/src/x4.scss +19 -0
- package/tsconfig.json +14 -0
- package/types/scss.d.ts +4 -0
- package/types/svg.d.ts +4 -0
- package/types/x4react.d.ts +9 -0
- package/lib/changelog.txt +0 -23
- package/lib/cjs/x4js.js +0 -39
- package/lib/cjs/x4js.js.map +0 -7
- package/lib/esm/x4js.mjs +0 -15972
- package/lib/esm/x4js.mjs.map +0 -7
- package/lib/licence.md +0 -21
- package/lib/src/MIT-license.md +0 -14
- package/lib/src/action.ts +0 -88
- package/lib/src/alpha.jpg +0 -0
- package/lib/src/app_sockets.ts +0 -81
- package/lib/src/application.ts +0 -262
- package/lib/src/autocomplete.ts +0 -232
- package/lib/src/base64.ts +0 -166
- package/lib/src/base_component.ts +0 -152
- package/lib/src/button.ts +0 -355
- package/lib/src/canvas.ts +0 -510
- package/lib/src/cardview.ts +0 -228
- package/lib/src/checkbox.ts +0 -188
- package/lib/src/color.ts +0 -752
- package/lib/src/colorpicker.ts +0 -1649
- package/lib/src/combobox.ts +0 -512
- package/lib/src/component.ts +0 -2367
- package/lib/src/copyright.txt +0 -27
- package/lib/src/datastore.ts +0 -1302
- package/lib/src/dialog.ts +0 -656
- package/lib/src/drawtext.ts +0 -355
- package/lib/src/fileupload.ts +0 -213
- package/lib/src/form.ts +0 -413
- package/lib/src/formatters.ts +0 -105
- package/lib/src/gridview.ts +0 -1185
- package/lib/src/icon.ts +0 -362
- package/lib/src/image.ts +0 -225
- package/lib/src/index.ts +0 -89
- package/lib/src/input.ts +0 -297
- package/lib/src/label.ts +0 -153
- package/lib/src/layout.ts +0 -442
- package/lib/src/link.ts +0 -86
- package/lib/src/listview.ts +0 -765
- package/lib/src/md5.ts +0 -438
- package/lib/src/menu.ts +0 -425
- package/lib/src/messagebox.ts +0 -224
- package/lib/src/panel.ts +0 -86
- package/lib/src/popup.ts +0 -494
- package/lib/src/property_editor.ts +0 -337
- package/lib/src/radiobtn.ts +0 -197
- package/lib/src/rating.ts +0 -135
- package/lib/src/request.ts +0 -300
- package/lib/src/settings.ts +0 -77
- package/lib/src/sidebarview.ts +0 -108
- package/lib/src/spreadsheet.ts +0 -1449
- package/lib/src/styles.ts +0 -343
- package/lib/src/svgcomponent.ts +0 -592
- package/lib/src/tabbar.ts +0 -151
- package/lib/src/tabview.ts +0 -110
- package/lib/src/textarea.ts +0 -235
- package/lib/src/textedit.ts +0 -533
- package/lib/src/toaster.ts +0 -80
- package/lib/src/tools.ts +0 -1473
- package/lib/src/tooltips.ts +0 -191
- package/lib/src/treeview.ts +0 -716
- package/lib/src/version.ts +0 -30
- package/lib/src/x4.less +0 -2242
- package/lib/src/x4dom.ts +0 -57
- package/lib/src/x4events.ts +0 -585
- package/lib/src/x4js.ts +0 -89
- package/lib/src/x4react.ts +0 -90
- package/lib/styles/x4.css +0 -1785
- package/lib/styles/x4.less +0 -2242
- package/lib/types/x4js.d.ts +0 -6728
- package/license.md +0 -21
package/lib/src/combobox.ts
DELETED
|
@@ -1,512 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ___ ___ __
|
|
3
|
-
* \ \/ / / _
|
|
4
|
-
* \ / /_| |_
|
|
5
|
-
* / \____ _|
|
|
6
|
-
* /__/\__\ |_|
|
|
7
|
-
*
|
|
8
|
-
* @file combobox.ts
|
|
9
|
-
* @author Etienne Cochard
|
|
10
|
-
*
|
|
11
|
-
* Copyright (c) 2019-2023 R-libre ingenierie
|
|
12
|
-
*
|
|
13
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
14
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
15
|
-
* in the Software without restriction, including without limitation the rights
|
|
16
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
17
|
-
* of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
18
|
-
* subject to the following conditions:
|
|
19
|
-
* The above copyright notice and this permission notice shall be included in all copies
|
|
20
|
-
* or substantial portions of the Software.
|
|
21
|
-
*
|
|
22
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
23
|
-
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
|
24
|
-
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
25
|
-
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
26
|
-
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
27
|
-
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
28
|
-
**/
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* TODO: replace custom combo list by listview or gridview
|
|
32
|
-
*/
|
|
33
|
-
|
|
34
|
-
import { x4document } from './x4dom'
|
|
35
|
-
|
|
36
|
-
import { Component, CProps, ContainerEventMap } from './component'
|
|
37
|
-
import { EvChange, EvSelectionChange, EventCallback } from './x4events'
|
|
38
|
-
|
|
39
|
-
import { Input } from './input'
|
|
40
|
-
import { Label } from './label'
|
|
41
|
-
import { Button } from './button'
|
|
42
|
-
import { HLayout } from './layout'
|
|
43
|
-
import { PopupListView, ListViewItem, EvCancel, PopulateItems } from './listview';
|
|
44
|
-
import { DataStore, DataView, Record } from './datastore'
|
|
45
|
-
import { isFunction, HtmlString } from './tools'
|
|
46
|
-
import { Tooltip } from './tooltips'
|
|
47
|
-
import { _tr } from './i18n'
|
|
48
|
-
|
|
49
|
-
export interface ComboStoreProxyProps {
|
|
50
|
-
store: DataView | DataStore;
|
|
51
|
-
display: ( rec: Record ) => string | HtmlString;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// ============================================================================
|
|
55
|
-
// [COMBOBOX]
|
|
56
|
-
// ============================================================================
|
|
57
|
-
|
|
58
|
-
export interface ComboItemRender {
|
|
59
|
-
( itm: ListViewItem ) : Component;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
interface ComboBoxEventMap extends ContainerEventMap {
|
|
63
|
-
readonly change: EvChange; // value change (event.value = new value as id)
|
|
64
|
-
readonly selectionChange?: EvSelectionChange; // ( event.value = new value as ListItem)
|
|
65
|
-
readonly cancel?: EvCancel;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export interface ComboBoxProps extends CProps<ComboBoxEventMap> {
|
|
69
|
-
tabIndex?: number | boolean;
|
|
70
|
-
name?: string;
|
|
71
|
-
readOnly?: boolean;
|
|
72
|
-
required?: true;
|
|
73
|
-
|
|
74
|
-
label?: string;
|
|
75
|
-
labelWidth?: number; // < 0 for flex
|
|
76
|
-
// =0 to adjust label width
|
|
77
|
-
// > 0 to specify a width
|
|
78
|
-
|
|
79
|
-
labelAlign?: 'left' | 'right';
|
|
80
|
-
|
|
81
|
-
items?: ListViewItem[] | PopulateItems;
|
|
82
|
-
value?: any; // shown value at init
|
|
83
|
-
|
|
84
|
-
renderer?: ComboItemRender;
|
|
85
|
-
selectionChange?: EventCallback<EvSelectionChange>;// shortcut to events: { selectionChange: ... }
|
|
86
|
-
editable?: boolean;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
abstract class InputLike extends Component {
|
|
90
|
-
abstract setValue( text: string ): void;
|
|
91
|
-
abstract getValue( ): string;
|
|
92
|
-
abstract showError( text: string ): void;
|
|
93
|
-
abstract clearError( ): void;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* @review use textedit
|
|
99
|
-
*/
|
|
100
|
-
|
|
101
|
-
export class ComboBox extends HLayout<ComboBoxProps,ComboBoxEventMap> {
|
|
102
|
-
|
|
103
|
-
private m_ui_input: Input | InputLike;
|
|
104
|
-
private m_ui_button: Button;
|
|
105
|
-
private m_popup: PopupListView;
|
|
106
|
-
private m_lockpop: boolean;
|
|
107
|
-
private m_lockchg: boolean;
|
|
108
|
-
private m_popvis: boolean;
|
|
109
|
-
private m_selection: ListViewItem;
|
|
110
|
-
|
|
111
|
-
constructor(props: ComboBoxProps) {
|
|
112
|
-
super(props);
|
|
113
|
-
|
|
114
|
-
if( !props.editable ) {
|
|
115
|
-
this.setDomEvent( 'keypress', () => this.showPopup() );
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
this.setDomEvent( 'click', () => {
|
|
119
|
-
if( this.m_props.editable ) {
|
|
120
|
-
this.m_ui_input.focus( );
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
this.showPopup();
|
|
124
|
-
} );
|
|
125
|
-
|
|
126
|
-
this.setDomEvent("keydown", e => this._onKey(e));
|
|
127
|
-
this.mapPropEvents(props, 'selectionChange' );
|
|
128
|
-
|
|
129
|
-
this.m_popvis = false;
|
|
130
|
-
this.m_lockpop = false;
|
|
131
|
-
this.m_lockchg = false;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
_onKey(e: KeyboardEvent ) {
|
|
135
|
-
if (this.m_popvis) {
|
|
136
|
-
if (e.key == "ArrowUp" || e.key == "ArrowDown") {
|
|
137
|
-
this.m_lockpop = true;
|
|
138
|
-
this.m_popup.handleKey(e);
|
|
139
|
-
this.m_lockpop = false;
|
|
140
|
-
e.preventDefault();
|
|
141
|
-
e.stopPropagation();
|
|
142
|
-
}
|
|
143
|
-
else if (e.key == "Escape") {
|
|
144
|
-
this._hidePopup();
|
|
145
|
-
e.preventDefault();
|
|
146
|
-
e.stopPropagation();
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
set items( items: ListViewItem[] ) {
|
|
152
|
-
this.m_props.items = items;
|
|
153
|
-
if( this.m_popup ) {
|
|
154
|
-
this.m_popup.items = items;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
/** @ignore */
|
|
159
|
-
render( props: ComboBoxProps ) {
|
|
160
|
-
|
|
161
|
-
if( !props.renderer ) {
|
|
162
|
-
|
|
163
|
-
this.setClass('@required', props.required);
|
|
164
|
-
|
|
165
|
-
const input = new Input( {
|
|
166
|
-
flex : 1,
|
|
167
|
-
readOnly : this.m_props.editable ? false : true,
|
|
168
|
-
tabIndex : 0,
|
|
169
|
-
name: props.name,
|
|
170
|
-
value_hook: {
|
|
171
|
-
get: (): string => { return this.value; },
|
|
172
|
-
set: (v: string) => { this.value = v; }
|
|
173
|
-
},
|
|
174
|
-
dom_events: {
|
|
175
|
-
focus: () => {
|
|
176
|
-
this.clearError();
|
|
177
|
-
if( this.m_props.editable && input.value.length==0 ) {
|
|
178
|
-
this.showPopup( );
|
|
179
|
-
}
|
|
180
|
-
},
|
|
181
|
-
input: ( ) => {
|
|
182
|
-
if( this.m_lockchg ) {
|
|
183
|
-
return;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
const text = input.value;
|
|
187
|
-
this.m_selection = { id: undefined, text };
|
|
188
|
-
let items = this.showPopup( );
|
|
189
|
-
if( items && items.length && items[0].text==text ) {
|
|
190
|
-
this.m_selection = { id: items[0].id, text };
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
this.m_ui_input = input;
|
|
197
|
-
}
|
|
198
|
-
else {
|
|
199
|
-
this.m_ui_input = new Component( {
|
|
200
|
-
flex: 1,
|
|
201
|
-
cls: '@fake-input @hlayout',
|
|
202
|
-
tabIndex: 1
|
|
203
|
-
} ) as any;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
let width = undefined,
|
|
207
|
-
flex = undefined;
|
|
208
|
-
|
|
209
|
-
let labelWidth = props.labelWidth ?? 0;
|
|
210
|
-
|
|
211
|
-
if( labelWidth>0 ) {
|
|
212
|
-
width = labelWidth;
|
|
213
|
-
}
|
|
214
|
-
else if( labelWidth<0 ) {
|
|
215
|
-
flex = -labelWidth;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
this.setContent([
|
|
219
|
-
// todo: why 'label1' class name
|
|
220
|
-
new Label({
|
|
221
|
-
cls: 'label1' + (props.label ? '' : ' @hidden'),
|
|
222
|
-
text: props.label,
|
|
223
|
-
width,
|
|
224
|
-
flex,
|
|
225
|
-
align: props.labelAlign
|
|
226
|
-
}),
|
|
227
|
-
new HLayout({
|
|
228
|
-
flex: 1,
|
|
229
|
-
content: [
|
|
230
|
-
this.m_ui_input,
|
|
231
|
-
this.m_ui_button = new Button({
|
|
232
|
-
cls: 'gadget',
|
|
233
|
-
icon: 'var( --x4-icon-angle-down )',
|
|
234
|
-
tabIndex: false,
|
|
235
|
-
click: () => {
|
|
236
|
-
this.showPopup( false )
|
|
237
|
-
},
|
|
238
|
-
dom_events: {
|
|
239
|
-
focus: () => {
|
|
240
|
-
this.clearError();
|
|
241
|
-
this.dom.focus();
|
|
242
|
-
},
|
|
243
|
-
}
|
|
244
|
-
})
|
|
245
|
-
]
|
|
246
|
-
}),
|
|
247
|
-
]);
|
|
248
|
-
|
|
249
|
-
if (props.value !== undefined) {
|
|
250
|
-
this.value = props.value;
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
componentDisposed( ) {
|
|
255
|
-
if( this.m_popup ) {
|
|
256
|
-
this.m_popup.close( );
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
super.componentDisposed( );
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
/**
|
|
263
|
-
* display the popup
|
|
264
|
-
*/
|
|
265
|
-
|
|
266
|
-
showPopup( filter_items: boolean = true ) {
|
|
267
|
-
|
|
268
|
-
let props = this.m_props;
|
|
269
|
-
if (props.readOnly || this.hasClass("@disable") ) {
|
|
270
|
-
return null;
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
let items = props.items;
|
|
274
|
-
if( isFunction( items ) ) {
|
|
275
|
-
const filter = filter_items ? (this.m_ui_input as Input).value : null;
|
|
276
|
-
items = items( filter );
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
if( items.length==0 ) {
|
|
280
|
-
return null;
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
// need creation ?
|
|
284
|
-
|
|
285
|
-
if( !this.m_popup ) {
|
|
286
|
-
let cstyle = this.getComputedStyle( );
|
|
287
|
-
let fontFamily = cstyle.value( 'fontFamily' );
|
|
288
|
-
let fontSize = cstyle.value( 'fontSize' );
|
|
289
|
-
|
|
290
|
-
// prepare the combo listview
|
|
291
|
-
this.m_popup = new PopupListView({
|
|
292
|
-
cls: '@combo-popup',
|
|
293
|
-
populate: props.populate,
|
|
294
|
-
renderItem: this.m_props.renderer,
|
|
295
|
-
selectionChange: (e) => {
|
|
296
|
-
|
|
297
|
-
this._selectItem(e);
|
|
298
|
-
|
|
299
|
-
if (!this.m_lockpop) {
|
|
300
|
-
this._hidePopup();
|
|
301
|
-
this.focus();
|
|
302
|
-
}
|
|
303
|
-
},
|
|
304
|
-
cancel: ( e ) => this.signal( 'cancel', e ),
|
|
305
|
-
style: {
|
|
306
|
-
fontFamily,
|
|
307
|
-
fontSize
|
|
308
|
-
}
|
|
309
|
-
});
|
|
310
|
-
|
|
311
|
-
// lock focus trap
|
|
312
|
-
this.m_popup.setDomEvent( "mousedown", ( ev ) => {
|
|
313
|
-
ev.stopImmediatePropagation( );
|
|
314
|
-
ev.stopPropagation( );
|
|
315
|
-
ev.preventDefault( );
|
|
316
|
-
}, true );
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
this.m_popup.items = items;
|
|
320
|
-
|
|
321
|
-
let r1 = this.m_ui_button.getBoundingRect(),
|
|
322
|
-
r2 = this.m_ui_input.getBoundingRect();
|
|
323
|
-
|
|
324
|
-
this.m_popup.setStyle({
|
|
325
|
-
minWidth: r1.right - r2.left,
|
|
326
|
-
});
|
|
327
|
-
|
|
328
|
-
this.m_popup.displayAt(r2.left, r2.bottom);
|
|
329
|
-
this.m_popvis = true;
|
|
330
|
-
this.startTimer("focus-check", 100, true, () => this._checkFocus());
|
|
331
|
-
|
|
332
|
-
if( this.value!==undefined ) {
|
|
333
|
-
this.m_popup.selection = this.value;
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
return items;
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
/**
|
|
340
|
-
*
|
|
341
|
-
*/
|
|
342
|
-
|
|
343
|
-
validate( ) {
|
|
344
|
-
if( this.m_props.required && !this.m_selection ) {
|
|
345
|
-
this.showError(_tr.global.required_field);
|
|
346
|
-
return false;
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
return true;
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
public showError(text: string) {
|
|
353
|
-
this.m_ui_input.showError( text );
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
public clearError() {
|
|
357
|
-
this.m_ui_input.clearError( );
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
/** @ignore
|
|
361
|
-
*/
|
|
362
|
-
|
|
363
|
-
private _selectItem( ev: EvSelectionChange ) {
|
|
364
|
-
|
|
365
|
-
let item: ListViewItem = ev.selection as ListViewItem;
|
|
366
|
-
if( !item ) {
|
|
367
|
-
return;
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
this.m_lockchg = true;
|
|
371
|
-
this._setInput( item, true );
|
|
372
|
-
this.m_lockchg = false;
|
|
373
|
-
|
|
374
|
-
this.m_selection = {
|
|
375
|
-
id: item.id,
|
|
376
|
-
text: item.text
|
|
377
|
-
};
|
|
378
|
-
|
|
379
|
-
this.emit( 'selectionChange', EvSelectionChange( item ) );
|
|
380
|
-
this.emit( 'change', EvChange(item.id) );
|
|
381
|
-
//this.m_ui_input.focus( );
|
|
382
|
-
//this.m_popup.hide( );
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
/**
|
|
386
|
-
*
|
|
387
|
-
*/
|
|
388
|
-
|
|
389
|
-
private _setInput( item: ListViewItem, fireEv = false ) {
|
|
390
|
-
|
|
391
|
-
if( item ) {
|
|
392
|
-
if( this.m_ui_input ) {
|
|
393
|
-
if( this.m_ui_input instanceof Input ) {
|
|
394
|
-
this.m_ui_input.value = item.text as string;
|
|
395
|
-
// fires a change event
|
|
396
|
-
if( fireEv ) {
|
|
397
|
-
this.m_ui_input.dom.dispatchEvent( new Event('input') );
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
else {
|
|
401
|
-
this.m_ui_input.setContent( this.m_props.renderer( item ) );
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
else {
|
|
405
|
-
this.m_props.value = item.id;
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
else {
|
|
409
|
-
if( this.m_ui_input && this.m_ui_input instanceof Input ) {
|
|
410
|
-
this.m_ui_input.value = "";
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
/**
|
|
416
|
-
*
|
|
417
|
-
*/
|
|
418
|
-
|
|
419
|
-
public get value() {
|
|
420
|
-
return this.m_selection ? this.m_selection.id : undefined;
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
public get valueText( ) {
|
|
424
|
-
if( this.m_selection ) {
|
|
425
|
-
return this.m_selection.text;
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
if( this.m_props.editable ) {
|
|
429
|
-
return (this.m_ui_input as Input).value;
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
return '';
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
/**
|
|
436
|
-
*
|
|
437
|
-
*/
|
|
438
|
-
|
|
439
|
-
public set value(id) {
|
|
440
|
-
let items = this.m_props.items;
|
|
441
|
-
|
|
442
|
-
if( isFunction(items) ) {
|
|
443
|
-
items = items( null );
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
const found = items.some( (v) => {
|
|
447
|
-
if (v.id === id) {
|
|
448
|
-
this._setInput( v );
|
|
449
|
-
this.m_selection = v;
|
|
450
|
-
return true;
|
|
451
|
-
}
|
|
452
|
-
});
|
|
453
|
-
|
|
454
|
-
if( !found ) {
|
|
455
|
-
this._setInput( null );
|
|
456
|
-
this.m_selection = null;
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
get input( ) : Input {
|
|
461
|
-
return this.m_ui_input instanceof Input ? this.m_ui_input : null;
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
_checkFocus() {
|
|
465
|
-
const focus = document.activeElement;
|
|
466
|
-
if (this.dom && this.dom.contains(focus) || focus==document.body ) {
|
|
467
|
-
return;
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
if (this.m_popup && this.m_popup.dom && this.m_popup.dom.contains(focus)) {
|
|
471
|
-
return;
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
this._hidePopup();
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
_hidePopup() {
|
|
478
|
-
if (this.m_popvis) {
|
|
479
|
-
this.m_popup.close();
|
|
480
|
-
this.m_popvis = false;
|
|
481
|
-
this.stopTimer("focus-check");
|
|
482
|
-
}
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
static storeProxy( props: ComboStoreProxyProps ): PopulateItems {
|
|
486
|
-
|
|
487
|
-
let view: DataView = props.store instanceof DataStore ? props.store.createView() : props.store;
|
|
488
|
-
|
|
489
|
-
return ( ) => {
|
|
490
|
-
let result: ListViewItem[] = new Array( props.store.count );
|
|
491
|
-
|
|
492
|
-
props.store.forEach( ( rec, index ) => {
|
|
493
|
-
result[index] = {
|
|
494
|
-
id: rec.getID( ),
|
|
495
|
-
text: props.display( rec )
|
|
496
|
-
}
|
|
497
|
-
});
|
|
498
|
-
|
|
499
|
-
return result;
|
|
500
|
-
};
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
focus( ) {
|
|
504
|
-
if( this.m_props.editable ) {
|
|
505
|
-
this.m_ui_input.focus( );
|
|
506
|
-
}
|
|
507
|
-
else {
|
|
508
|
-
super.focus( );
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
}
|
|
512
|
-
|