x4js 1.4.15 → 1.4.18
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/application.d.ts +3 -0
- package/lib/application.js +30 -0
- package/lib/index.d.ts +0 -3
- package/lib/index.js +3 -3
- package/lib/router.js +1 -1
- package/lib/tabbar.d.ts +1 -1
- package/lib/tabbar.js +9 -2
- package/lib/x4.css +20 -0
- package/package.json +1 -1
- package/src/application.ts +38 -0
- package/src/index.ts +3 -3
- package/src/router.ts +1 -1
- package/src/tabbar.ts +11 -3
- package/src/x4.less +25 -0
- package/tsconfig.json +6 -0
package/lib/application.d.ts
CHANGED
|
@@ -75,6 +75,8 @@ export declare class Application<P extends ApplicationProps = ApplicationProps,
|
|
|
75
75
|
private m_app_uid;
|
|
76
76
|
private m_local_storage;
|
|
77
77
|
private m_user_data;
|
|
78
|
+
private m_touch_time;
|
|
79
|
+
private m_touch_count;
|
|
78
80
|
constructor(props: P);
|
|
79
81
|
ApplicationCreated(): void;
|
|
80
82
|
get app_name(): string;
|
|
@@ -96,5 +98,6 @@ export declare class Application<P extends ApplicationProps = ApplicationProps,
|
|
|
96
98
|
setTitle(title: string): void;
|
|
97
99
|
disableZoomWheel(): void;
|
|
98
100
|
enterModal(enter: boolean): void;
|
|
101
|
+
enableTouchDblClick(): void;
|
|
99
102
|
}
|
|
100
103
|
export {};
|
package/lib/application.js
CHANGED
|
@@ -30,8 +30,10 @@
|
|
|
30
30
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
31
|
exports.Application = void 0;
|
|
32
32
|
const base_component_1 = require("./base_component");
|
|
33
|
+
const component_1 = require("./component");
|
|
33
34
|
const settings_1 = require("./settings");
|
|
34
35
|
const tools_1 = require("./tools");
|
|
36
|
+
const _x4_touch_time = Symbol();
|
|
35
37
|
/**
|
|
36
38
|
* Represents an x4 application, which is typically a single page app.
|
|
37
39
|
* You should inherit Application to define yours.
|
|
@@ -65,6 +67,8 @@ class Application extends base_component_1.BaseComponent {
|
|
|
65
67
|
m_app_uid;
|
|
66
68
|
m_local_storage;
|
|
67
69
|
m_user_data;
|
|
70
|
+
m_touch_time;
|
|
71
|
+
m_touch_count;
|
|
68
72
|
constructor(props) {
|
|
69
73
|
console.assert(Application.self === null, 'application is a singleton');
|
|
70
74
|
super(props);
|
|
@@ -74,6 +78,8 @@ class Application extends base_component_1.BaseComponent {
|
|
|
74
78
|
let settings_name = `${this.m_app_name}.${this.m_app_version}.settings`;
|
|
75
79
|
this.m_local_storage = new settings_1.Settings(settings_name);
|
|
76
80
|
this.m_user_data = {};
|
|
81
|
+
this.m_touch_time = 0;
|
|
82
|
+
this.m_touch_count = 0;
|
|
77
83
|
Application.self = this;
|
|
78
84
|
if ('onload' in globalThis) {
|
|
79
85
|
globalThis.addEventListener('load', () => {
|
|
@@ -145,6 +151,30 @@ class Application extends base_component_1.BaseComponent {
|
|
|
145
151
|
}
|
|
146
152
|
enterModal(enter) {
|
|
147
153
|
}
|
|
154
|
+
enableTouchDblClick() {
|
|
155
|
+
document.addEventListener('touchstart', (ev) => {
|
|
156
|
+
let now = Date.now();
|
|
157
|
+
if ((now - this.m_touch_time) > 700) {
|
|
158
|
+
this.m_touch_count = 1;
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
this.m_touch_count++;
|
|
162
|
+
}
|
|
163
|
+
this.m_touch_time = now;
|
|
164
|
+
if (this.m_touch_count == 2) {
|
|
165
|
+
this.m_touch_count = 0;
|
|
166
|
+
// dirty fake dblclick event
|
|
167
|
+
const tch = ev.touches[0];
|
|
168
|
+
let fake = { type: "dblclick" };
|
|
169
|
+
for (const n in tch) {
|
|
170
|
+
fake[n] = tch[n];
|
|
171
|
+
}
|
|
172
|
+
// ignore -> private: dirty x2
|
|
173
|
+
component_1.Component._dispatchEvent(fake);
|
|
174
|
+
ev.stopPropagation();
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
}
|
|
148
178
|
}
|
|
149
179
|
exports.Application = Application;
|
|
150
180
|
;
|
package/lib/index.d.ts
CHANGED
|
@@ -28,7 +28,6 @@
|
|
|
28
28
|
**/
|
|
29
29
|
export * from "./application";
|
|
30
30
|
export * from "./base_component";
|
|
31
|
-
export * from "./base64";
|
|
32
31
|
export * from "./button";
|
|
33
32
|
export * from "./calendar";
|
|
34
33
|
export * from "./canvas";
|
|
@@ -67,7 +66,6 @@ export * from "./request";
|
|
|
67
66
|
export * from "./router";
|
|
68
67
|
export * from "./settings";
|
|
69
68
|
export * from "./sidebarview";
|
|
70
|
-
export * from "./smartedit";
|
|
71
69
|
export * from "./spreadsheet";
|
|
72
70
|
export * from "./styles";
|
|
73
71
|
export * from "./svgcomponent";
|
|
@@ -75,7 +73,6 @@ export * from "./tabbar";
|
|
|
75
73
|
export * from "./tabview";
|
|
76
74
|
export * from "./textarea";
|
|
77
75
|
export * from "./textedit";
|
|
78
|
-
export * from "./texthiliter";
|
|
79
76
|
export * from "./toaster";
|
|
80
77
|
export * from "./tools";
|
|
81
78
|
export * from "./tooltips";
|
package/lib/index.js
CHANGED
|
@@ -44,7 +44,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
44
44
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
45
|
__exportStar(require("./application"), exports);
|
|
46
46
|
__exportStar(require("./base_component"), exports);
|
|
47
|
-
|
|
47
|
+
//export * from "./base64"
|
|
48
48
|
__exportStar(require("./button"), exports);
|
|
49
49
|
__exportStar(require("./calendar"), exports);
|
|
50
50
|
__exportStar(require("./canvas"), exports);
|
|
@@ -83,7 +83,7 @@ __exportStar(require("./request"), exports);
|
|
|
83
83
|
__exportStar(require("./router"), exports);
|
|
84
84
|
__exportStar(require("./settings"), exports);
|
|
85
85
|
__exportStar(require("./sidebarview"), exports);
|
|
86
|
-
|
|
86
|
+
//export * from "./smartedit"
|
|
87
87
|
__exportStar(require("./spreadsheet"), exports);
|
|
88
88
|
__exportStar(require("./styles"), exports);
|
|
89
89
|
__exportStar(require("./svgcomponent"), exports);
|
|
@@ -91,7 +91,7 @@ __exportStar(require("./tabbar"), exports);
|
|
|
91
91
|
__exportStar(require("./tabview"), exports);
|
|
92
92
|
__exportStar(require("./textarea"), exports);
|
|
93
93
|
__exportStar(require("./textedit"), exports);
|
|
94
|
-
|
|
94
|
+
//export * from "./texthiliter"
|
|
95
95
|
__exportStar(require("./toaster"), exports);
|
|
96
96
|
__exportStar(require("./tools"), exports);
|
|
97
97
|
__exportStar(require("./tooltips"), exports);
|
package/lib/router.js
CHANGED
|
@@ -53,7 +53,7 @@ function parseRoute(str, loose = false) {
|
|
|
53
53
|
const o = tmp.indexOf('?', 1);
|
|
54
54
|
const ext = tmp.indexOf('.', 1);
|
|
55
55
|
keys.push(tmp.substring(1, o >= 0 ? o : ext >= 0 ? ext : tmp.length));
|
|
56
|
-
pattern += o
|
|
56
|
+
pattern += o >= 0 && ext < 0 ? '(?:/([^\/]+?))?' : '/([^\/]+?)';
|
|
57
57
|
if (ext >= 0) {
|
|
58
58
|
pattern += (o >= 0 ? '?' : '') + '\\' + tmp.substring(ext);
|
|
59
59
|
}
|
package/lib/tabbar.d.ts
CHANGED
|
@@ -51,7 +51,7 @@ export declare class TabBar extends Container<TabBarProps, TabBarEventMap> {
|
|
|
51
51
|
componentCreated(): void;
|
|
52
52
|
addPage(page: ITabPage): void;
|
|
53
53
|
render(): void;
|
|
54
|
-
select(id: string | null, notify?: boolean):
|
|
54
|
+
select(id: string | null, notify?: boolean): boolean;
|
|
55
55
|
private _select;
|
|
56
56
|
get selection(): Component<CProps<import("./base_component").BaseComponentEventMap>, import("./base_component").BaseComponentEventMap>;
|
|
57
57
|
}
|
package/lib/tabbar.js
CHANGED
|
@@ -68,19 +68,26 @@ class TabBar extends component_1.Container {
|
|
|
68
68
|
select(id, notify = false) {
|
|
69
69
|
if (!id) {
|
|
70
70
|
this._select(null, notify);
|
|
71
|
+
return true;
|
|
71
72
|
}
|
|
72
73
|
else {
|
|
73
74
|
let page = this.m_pages.find(x => x.id === id);
|
|
74
75
|
if (page) {
|
|
75
76
|
this._select(page, notify);
|
|
77
|
+
return true;
|
|
76
78
|
}
|
|
79
|
+
return false;
|
|
77
80
|
}
|
|
78
81
|
}
|
|
79
82
|
_select(p, notify) {
|
|
80
83
|
if (this.m_curPage == p) {
|
|
81
84
|
return;
|
|
82
85
|
}
|
|
83
|
-
if (this.dom
|
|
86
|
+
if (!this.dom) {
|
|
87
|
+
this.m_props.default = p.id;
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (this.m_curPage) {
|
|
84
91
|
this.m_curPage.btn.removeClass('selected');
|
|
85
92
|
if (this.m_curPage.page) {
|
|
86
93
|
this.m_curPage.page.hide();
|
|
@@ -90,7 +97,7 @@ class TabBar extends component_1.Container {
|
|
|
90
97
|
if (notify) {
|
|
91
98
|
this.signal('change', (0, x4_events_1.EvChange)(p ? p.id : null));
|
|
92
99
|
}
|
|
93
|
-
if (this.
|
|
100
|
+
if (this.m_curPage) {
|
|
94
101
|
this.m_curPage.btn.addClass('selected');
|
|
95
102
|
if (this.m_curPage.page) {
|
|
96
103
|
this.m_curPage.page.show();
|
package/lib/x4.css
CHANGED
|
@@ -306,6 +306,8 @@ textarea::selection {
|
|
|
306
306
|
align-items: center;
|
|
307
307
|
outline: none;
|
|
308
308
|
cursor: pointer;
|
|
309
|
+
font-family: var(--x4-font);
|
|
310
|
+
font-size: var(--x4-font-size);
|
|
309
311
|
height: 2rem;
|
|
310
312
|
padding: 8px;
|
|
311
313
|
overflow: hidden;
|
|
@@ -1691,3 +1693,21 @@ textarea::selection {
|
|
|
1691
1693
|
grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
|
|
1692
1694
|
grid-auto-rows: 10px;
|
|
1693
1695
|
}
|
|
1696
|
+
.x-tab-bar {
|
|
1697
|
+
border-bottom: 1px solid var(--gray-600);
|
|
1698
|
+
background-color: var(--gray-100);
|
|
1699
|
+
}
|
|
1700
|
+
.x-tab-bar > .x-button {
|
|
1701
|
+
border: none;
|
|
1702
|
+
color: var(--gray-600);
|
|
1703
|
+
}
|
|
1704
|
+
.x-tab-bar > .x-button.selected {
|
|
1705
|
+
font-weight: bold;
|
|
1706
|
+
border-bottom: none;
|
|
1707
|
+
color: var(--x4-selection-color);
|
|
1708
|
+
background-color: transparent;
|
|
1709
|
+
}
|
|
1710
|
+
.x-tab-bar > .x-button:focus:not(.selected) {
|
|
1711
|
+
text-decoration: underline;
|
|
1712
|
+
color: black;
|
|
1713
|
+
}
|
package/package.json
CHANGED
package/src/application.ts
CHANGED
|
@@ -34,6 +34,8 @@ import { Settings } from './settings'
|
|
|
34
34
|
import { deferCall } from './tools'
|
|
35
35
|
import { _tr } from './i18n'
|
|
36
36
|
|
|
37
|
+
const _x4_touch_time = Symbol( );
|
|
38
|
+
|
|
37
39
|
|
|
38
40
|
interface ApplicationEventMap extends BaseComponentEventMap {
|
|
39
41
|
message: EvMessage;
|
|
@@ -92,6 +94,9 @@ export class Application<P extends ApplicationProps = ApplicationProps, E extend
|
|
|
92
94
|
|
|
93
95
|
private m_local_storage: Settings;
|
|
94
96
|
private m_user_data: any;
|
|
97
|
+
|
|
98
|
+
private m_touch_time: number;
|
|
99
|
+
private m_touch_count: number;
|
|
95
100
|
|
|
96
101
|
constructor( props : P ) {
|
|
97
102
|
console.assert( Application.self===null, 'application is a singleton' );
|
|
@@ -104,6 +109,9 @@ export class Application<P extends ApplicationProps = ApplicationProps, E extend
|
|
|
104
109
|
let settings_name = `${this.m_app_name}.${this.m_app_version}.settings`;
|
|
105
110
|
this.m_local_storage = new Settings( settings_name );
|
|
106
111
|
this.m_user_data = {};
|
|
112
|
+
|
|
113
|
+
this.m_touch_time = 0;
|
|
114
|
+
this.m_touch_count = 0;
|
|
107
115
|
|
|
108
116
|
(Application.self as any) = this;
|
|
109
117
|
|
|
@@ -194,6 +202,36 @@ export class Application<P extends ApplicationProps = ApplicationProps, E extend
|
|
|
194
202
|
|
|
195
203
|
public enterModal( enter: boolean ) {
|
|
196
204
|
}
|
|
205
|
+
|
|
206
|
+
public enableTouchDblClick( ) {
|
|
207
|
+
document.addEventListener( 'touchstart', ( ev: TouchEvent ) => {
|
|
208
|
+
|
|
209
|
+
let now = Date.now( );
|
|
210
|
+
if( (now-this.m_touch_time) > 700 ) {
|
|
211
|
+
this.m_touch_count = 1;
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
this.m_touch_count++;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
this.m_touch_time = now;
|
|
218
|
+
|
|
219
|
+
if( this.m_touch_count==2 ) {
|
|
220
|
+
this.m_touch_count = 0;
|
|
221
|
+
|
|
222
|
+
// dirty fake dblclick event
|
|
223
|
+
const tch = ev.touches[0];
|
|
224
|
+
let fake: any = {type: "dblclick" };
|
|
225
|
+
for( const n in tch ) {
|
|
226
|
+
fake[n] = tch[n];
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// ignore -> private: dirty x2
|
|
230
|
+
(Component as any)._dispatchEvent( fake );
|
|
231
|
+
ev.stopPropagation( );
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
}
|
|
197
235
|
};
|
|
198
236
|
|
|
199
237
|
|
package/src/index.ts
CHANGED
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
|
|
30
30
|
export * from "./application"
|
|
31
31
|
export * from "./base_component"
|
|
32
|
-
export * from "./base64"
|
|
32
|
+
//export * from "./base64"
|
|
33
33
|
export * from "./button"
|
|
34
34
|
export * from "./calendar"
|
|
35
35
|
export * from "./canvas"
|
|
@@ -68,7 +68,7 @@ export * from "./request"
|
|
|
68
68
|
export * from "./router"
|
|
69
69
|
export * from "./settings"
|
|
70
70
|
export * from "./sidebarview"
|
|
71
|
-
export * from "./smartedit"
|
|
71
|
+
//export * from "./smartedit"
|
|
72
72
|
export * from "./spreadsheet"
|
|
73
73
|
export * from "./styles"
|
|
74
74
|
export * from "./svgcomponent"
|
|
@@ -76,7 +76,7 @@ export * from "./tabbar"
|
|
|
76
76
|
export * from "./tabview"
|
|
77
77
|
export * from "./textarea"
|
|
78
78
|
export * from "./textedit"
|
|
79
|
-
export * from "./texthiliter"
|
|
79
|
+
//export * from "./texthiliter"
|
|
80
80
|
export * from "./toaster"
|
|
81
81
|
export * from "./tools"
|
|
82
82
|
export * from "./tooltips"
|
package/src/router.ts
CHANGED
|
@@ -72,7 +72,7 @@ function parseRoute(str: string | RegExp, loose = false): Segment {
|
|
|
72
72
|
const ext = tmp.indexOf('.', 1);
|
|
73
73
|
|
|
74
74
|
keys.push(tmp.substring(1, o >= 0 ? o : ext >= 0 ? ext : tmp.length));
|
|
75
|
-
pattern += o
|
|
75
|
+
pattern += o >= 0 && ext < 0 ? '(?:/([^\/]+?))?' : '/([^\/]+?)';
|
|
76
76
|
if (ext >= 0) {
|
|
77
77
|
pattern += (o >= 0 ? '?' : '') + '\\' + tmp.substring(ext);
|
|
78
78
|
}
|
package/src/tabbar.ts
CHANGED
|
@@ -98,15 +98,18 @@ export class TabBar extends Container<TabBarProps,TabBarEventMap> {
|
|
|
98
98
|
this.setContent( buttons );
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
select( id: string | null, notify = false ) {
|
|
101
|
+
select( id: string | null, notify = false ): boolean {
|
|
102
102
|
if( !id ) {
|
|
103
103
|
this._select( null, notify );
|
|
104
|
+
return true;
|
|
104
105
|
}
|
|
105
106
|
else {
|
|
106
107
|
let page = this.m_pages.find( x => x.id===id );
|
|
107
108
|
if( page ) {
|
|
108
109
|
this._select( page, notify );
|
|
110
|
+
return true;
|
|
109
111
|
}
|
|
112
|
+
return false;
|
|
110
113
|
}
|
|
111
114
|
}
|
|
112
115
|
|
|
@@ -116,7 +119,12 @@ export class TabBar extends Container<TabBarProps,TabBarEventMap> {
|
|
|
116
119
|
return;
|
|
117
120
|
}
|
|
118
121
|
|
|
119
|
-
if( this.dom
|
|
122
|
+
if( !this.dom ) {
|
|
123
|
+
this.m_props.default = p.id;
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if( this.m_curPage ) {
|
|
120
128
|
this.m_curPage.btn.removeClass( 'selected' );
|
|
121
129
|
if( this.m_curPage.page ) {
|
|
122
130
|
this.m_curPage.page.hide( );
|
|
@@ -129,7 +137,7 @@ export class TabBar extends Container<TabBarProps,TabBarEventMap> {
|
|
|
129
137
|
this.signal( 'change', EvChange(p ? p.id : null) );
|
|
130
138
|
}
|
|
131
139
|
|
|
132
|
-
if( this.
|
|
140
|
+
if( this.m_curPage ) {
|
|
133
141
|
this.m_curPage.btn.addClass( 'selected' );
|
|
134
142
|
if( this.m_curPage.page ) {
|
|
135
143
|
this.m_curPage.page.show( );
|
package/src/x4.less
CHANGED
|
@@ -386,6 +386,8 @@ textarea {
|
|
|
386
386
|
align-items: center;
|
|
387
387
|
outline: none;
|
|
388
388
|
cursor: pointer;
|
|
389
|
+
font-family: var( --x4-font );
|
|
390
|
+
font-size: var( --x4-font-size );
|
|
389
391
|
|
|
390
392
|
height: 2rem;
|
|
391
393
|
padding: 8px;
|
|
@@ -2134,4 +2136,27 @@ textarea {
|
|
|
2134
2136
|
grid-gap: 10px;
|
|
2135
2137
|
grid-template-columns: repeat(auto-fill, minmax(250px,1fr));
|
|
2136
2138
|
grid-auto-rows: 10px;
|
|
2139
|
+
}
|
|
2140
|
+
|
|
2141
|
+
.x-tab-bar {
|
|
2142
|
+
border-bottom: 1px solid var(--gray-600);
|
|
2143
|
+
background-color: var(--gray-100);
|
|
2144
|
+
|
|
2145
|
+
&> .x-button {
|
|
2146
|
+
border: none;
|
|
2147
|
+
color: var( --gray-600 );
|
|
2148
|
+
|
|
2149
|
+
&.selected {
|
|
2150
|
+
font-weight: bold;
|
|
2151
|
+
//border: 1px solid var( --x4-selection-color );
|
|
2152
|
+
border-bottom: none;
|
|
2153
|
+
color: var( --x4-selection-color );
|
|
2154
|
+
background-color: transparent;
|
|
2155
|
+
}
|
|
2156
|
+
|
|
2157
|
+
&:focus:not(.selected) {
|
|
2158
|
+
text-decoration: underline;
|
|
2159
|
+
color: black;;
|
|
2160
|
+
}
|
|
2161
|
+
}
|
|
2137
2162
|
}
|