x4js 1.4.15 → 1.4.16

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.
@@ -96,5 +96,6 @@ export declare class Application<P extends ApplicationProps = ApplicationProps,
96
96
  setTitle(title: string): void;
97
97
  disableZoomWheel(): void;
98
98
  enterModal(enter: boolean): void;
99
+ handleTouchEvents(): void;
99
100
  }
100
101
  export {};
@@ -30,6 +30,7 @@
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");
35
36
  /**
@@ -145,6 +146,33 @@ class Application extends base_component_1.BaseComponent {
145
146
  }
146
147
  enterModal(enter) {
147
148
  }
149
+ handleTouchEvents() {
150
+ document.addEventListener('touchstart', (ev) => {
151
+ let me = this;
152
+ let now = new Date().getTime();
153
+ if (!me.__last_touch || (me.__last_touch - now) > 700) {
154
+ me.__touch_cnt = 1;
155
+ }
156
+ else {
157
+ me.__touch_cnt++;
158
+ }
159
+ me.__last_touch = now;
160
+ if (me.__touch_cnt == 2) {
161
+ me.__touch_cnt = 0;
162
+ let fake = {
163
+ type: "dblclick",
164
+ };
165
+ const tch = ev.touches[0];
166
+ for (const n in tch) {
167
+ fake[n] = tch[n];
168
+ }
169
+ // ts-ignore -> private
170
+ component_1.Component._dispatchEvent(fake);
171
+ ev.preventDefault();
172
+ ev.stopPropagation();
173
+ }
174
+ });
175
+ }
148
176
  }
149
177
  exports.Application = Application;
150
178
  ;
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): void;
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 && this.m_curPage) {
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.dom && this.m_curPage) {
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "x4js",
3
- "version": "1.4.15",
3
+ "version": "1.4.16",
4
4
  "description": "X4js core files",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -194,6 +194,42 @@ export class Application<P extends ApplicationProps = ApplicationProps, E extend
194
194
 
195
195
  public enterModal( enter: boolean ) {
196
196
  }
197
+
198
+ public handleTouchEvents( ) {
199
+ document.addEventListener( 'touchstart', ( ev: TouchEvent ) => {
200
+
201
+ let me = this as any;
202
+ let now = new Date( ).getTime();
203
+
204
+ if( !me.__last_touch || (me.__last_touch-now) > 700 ) {
205
+ me.__touch_cnt = 1;
206
+ }
207
+ else {
208
+ me.__touch_cnt++;
209
+ }
210
+
211
+ me.__last_touch = now;
212
+
213
+ if( me.__touch_cnt==2 ) {
214
+ me.__touch_cnt = 0;
215
+
216
+ let fake = {
217
+ type: "dblclick",
218
+ };
219
+
220
+ const tch = ev.touches[0];
221
+ for( const n in tch ) {
222
+ fake[n] = tch[n];
223
+ }
224
+
225
+ // ts-ignore -> private
226
+ (Component as any)._dispatchEvent( fake );
227
+
228
+ ev.preventDefault( );
229
+ ev.stopPropagation( );
230
+ }
231
+ });
232
+ }
197
233
  };
198
234
 
199
235
 
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 && this.m_curPage ) {
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.dom && this.m_curPage ) {
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
  }