x4js 1.4.9 → 1.4.12
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/calendar.js +14 -11
- package/lib/component.d.ts +1 -1
- package/lib/component.js +1 -1
- package/lib/datastore.js +1 -1
- package/lib/formatters.js +1 -0
- package/lib/gridview.js +1 -1
- package/lib/layout.d.ts +6 -0
- package/lib/layout.js +40 -1
- package/lib/listview.d.ts +3 -3
- package/lib/listview.js +1 -12
- package/lib/md5.d.ts +1 -1
- package/lib/md5.js +1 -0
- package/lib/popup.js +5 -7
- package/lib/request.js +1 -1
- package/lib/textedit.js +1 -1
- package/lib/tools.js +2 -1
- package/lib/tooltips.js +1 -1
- package/lib/x4.css +162 -41
- package/lib/x4_events.d.ts +2 -1
- package/lib/x4_events.js +9 -3
- package/package.json +1 -1
- package/src/calendar.ts +15 -11
- package/src/canvas.ts +7 -7
- package/src/component.ts +3 -2
- package/src/datastore.ts +1 -1
- package/src/formatters.ts +4 -1
- package/src/gridview.ts +1 -1
- package/src/layout.ts +54 -3
- package/src/listview.ts +3 -3
- package/src/md5.ts +1 -0
- package/src/popup.ts +5 -8
- package/src/request.ts +1 -1
- package/src/textedit.ts +2 -2
- package/src/tools.ts +3 -1
- package/src/tooltips.ts +1 -1
- package/src/x4.less +176 -44
- package/src/x4_events.ts +12 -5
- package/tsconfig.json +1 -1
- package/x4.css +0 -1572
package/lib/calendar.js
CHANGED
|
@@ -126,17 +126,20 @@ class Calendar extends layout_1.VLayout {
|
|
|
126
126
|
if (dte.getMonth() != cmonth) {
|
|
127
127
|
cls += ' out';
|
|
128
128
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
129
|
+
const mkItem = (dte) => {
|
|
130
|
+
return new layout_1.HLayout({
|
|
131
|
+
cls,
|
|
132
|
+
flex: 1,
|
|
133
|
+
content: new component_1.Component({
|
|
134
|
+
tag: 'span',
|
|
135
|
+
content: (0, tools_1.formatIntlDate)(dte, 'd'),
|
|
136
|
+
}),
|
|
137
|
+
dom_events: {
|
|
138
|
+
click: () => this.select(dte)
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
};
|
|
142
|
+
days.push(mkItem(dte.clone()));
|
|
140
143
|
dte.setDate(dte.getDate() + 1);
|
|
141
144
|
first = false;
|
|
142
145
|
}
|
package/lib/component.d.ts
CHANGED
|
@@ -398,7 +398,7 @@ export declare class Component<P extends CProps<BaseComponentEventMap> = CProps<
|
|
|
398
398
|
* @returns child or null
|
|
399
399
|
*/
|
|
400
400
|
queryItem<T extends Component>(selector: string): T;
|
|
401
|
-
queryAll(selector: string, cb?: (el: Component) => void):
|
|
401
|
+
queryAll(selector: string, cb?: (el: Component) => void): HTMLElement[];
|
|
402
402
|
/**
|
|
403
403
|
* find a child with the given ID
|
|
404
404
|
* @param id id (without '#')
|
package/lib/component.js
CHANGED
|
@@ -1177,7 +1177,7 @@ class Component extends base_component_1.BaseComponent {
|
|
|
1177
1177
|
return result ? Component.getElement(result) : null;
|
|
1178
1178
|
}
|
|
1179
1179
|
queryAll(selector, cb) {
|
|
1180
|
-
|
|
1180
|
+
let elements = Array.from(this.m_dom.querySelectorAll(selector));
|
|
1181
1181
|
if (cb) {
|
|
1182
1182
|
elements.forEach((el) => {
|
|
1183
1183
|
cb(flyWrap(el));
|
package/lib/datastore.js
CHANGED
package/lib/formatters.js
CHANGED
package/lib/gridview.js
CHANGED
package/lib/layout.d.ts
CHANGED
|
@@ -78,4 +78,10 @@ export declare class ScrollView extends Component<ScrollViewProps> {
|
|
|
78
78
|
constructor(props: ScrollViewProps);
|
|
79
79
|
setContent(content: ComponentContent): void;
|
|
80
80
|
}
|
|
81
|
+
export declare class Masonry extends Container {
|
|
82
|
+
constructor(props: any);
|
|
83
|
+
resizeItem(item: Component): void;
|
|
84
|
+
resizeAllItems(): void;
|
|
85
|
+
addItem(itm: Component): void;
|
|
86
|
+
}
|
|
81
87
|
export {};
|
package/lib/layout.js
CHANGED
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
29
29
|
*/
|
|
30
30
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
-
exports.ScrollView = exports.TableLayout = exports.GridLayout = exports.AutoLayout = exports.VLayout = exports.HLayout = exports.AbsLayout = void 0;
|
|
31
|
+
exports.Masonry = exports.ScrollView = exports.TableLayout = exports.GridLayout = exports.AutoLayout = exports.VLayout = exports.HLayout = exports.AbsLayout = void 0;
|
|
32
32
|
const component_1 = require("./component");
|
|
33
33
|
const tools_1 = require("./tools");
|
|
34
34
|
// ============================================================================
|
|
@@ -273,3 +273,42 @@ class ScrollView extends component_1.Component {
|
|
|
273
273
|
}
|
|
274
274
|
}
|
|
275
275
|
exports.ScrollView = ScrollView;
|
|
276
|
+
// :: MASONERY ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
|
277
|
+
// from a nice article of Andy Barefoot
|
|
278
|
+
// https://medium.com/@andybarefoot/a-masonry-style-layout-using-css-grid-8c663d355ebb
|
|
279
|
+
class Masonry extends component_1.Container {
|
|
280
|
+
constructor(props) {
|
|
281
|
+
super(props);
|
|
282
|
+
this.setDomEvent('sizechange', () => {
|
|
283
|
+
this.resizeAllItems();
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
resizeItem(item) {
|
|
287
|
+
const style = this.getComputedStyle();
|
|
288
|
+
const rowHeight = style.parse('grid-auto-rows');
|
|
289
|
+
const rowGap = style.parse('grid-row-gap');
|
|
290
|
+
let content = item.queryItem('.content');
|
|
291
|
+
if (!content) {
|
|
292
|
+
content = item;
|
|
293
|
+
}
|
|
294
|
+
if (content && (rowHeight + rowGap)) {
|
|
295
|
+
const rc = content.getBoundingRect();
|
|
296
|
+
const rowSpan = Math.ceil((rc.height + rowGap) / (rowHeight + rowGap));
|
|
297
|
+
item.setStyleValue('gridRowEnd', "span " + rowSpan);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
resizeAllItems() {
|
|
301
|
+
this.queryAll(".item", (itm) => {
|
|
302
|
+
;
|
|
303
|
+
this.resizeItem(itm);
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
addItem(itm) {
|
|
307
|
+
itm.addClass('content');
|
|
308
|
+
this.appendChild(new component_1.Container({
|
|
309
|
+
cls: 'item',
|
|
310
|
+
content: itm
|
|
311
|
+
}));
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
exports.Masonry = Masonry;
|
package/lib/listview.d.ts
CHANGED
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
27
27
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
28
28
|
**/
|
|
29
|
-
import { Container, Component,
|
|
29
|
+
import { Container, Component, ContainerProps, ContainerEventMap, EvDblClick } from './component';
|
|
30
30
|
import { IconID } from './icon';
|
|
31
31
|
import { VLayout } from './layout';
|
|
32
32
|
import { Popup, PopupEventMap, PopupProps } from './popup';
|
|
@@ -35,7 +35,7 @@ import { EvContextMenu, EvSelectionChange, EvClick, EventCallback, BasicEvent }
|
|
|
35
35
|
/**
|
|
36
36
|
* item definition
|
|
37
37
|
*/
|
|
38
|
-
export
|
|
38
|
+
export interface ListViewItem {
|
|
39
39
|
id: any;
|
|
40
40
|
text?: string | HtmlString;
|
|
41
41
|
html?: boolean;
|
|
@@ -67,7 +67,7 @@ export interface ListViewEventMap extends ContainerEventMap {
|
|
|
67
67
|
/**
|
|
68
68
|
* listview properties
|
|
69
69
|
*/
|
|
70
|
-
export interface ListViewProps<E extends ListViewEventMap = ListViewEventMap> extends
|
|
70
|
+
export interface ListViewProps<E extends ListViewEventMap = ListViewEventMap> extends ContainerProps<E> {
|
|
71
71
|
items?: ListViewItem[];
|
|
72
72
|
populate?: PopulateItems;
|
|
73
73
|
gadgets?: Component[];
|
package/lib/listview.js
CHANGED
|
@@ -28,24 +28,13 @@
|
|
|
28
28
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
29
29
|
**/
|
|
30
30
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
-
exports.PopupListView = exports.EvCancel = exports.ListView =
|
|
31
|
+
exports.PopupListView = exports.EvCancel = exports.ListView = void 0;
|
|
32
32
|
const component_1 = require("./component");
|
|
33
33
|
const layout_1 = require("./layout");
|
|
34
34
|
const popup_1 = require("./popup");
|
|
35
35
|
const tools_1 = require("./tools");
|
|
36
36
|
const menu_1 = require("./menu");
|
|
37
37
|
const x4_events_1 = require("./x4_events");
|
|
38
|
-
/**
|
|
39
|
-
* item definition
|
|
40
|
-
*/
|
|
41
|
-
class ListViewItem {
|
|
42
|
-
id;
|
|
43
|
-
text; // if you need pure text
|
|
44
|
-
html; // if text is html
|
|
45
|
-
icon;
|
|
46
|
-
data;
|
|
47
|
-
}
|
|
48
|
-
exports.ListViewItem = ListViewItem;
|
|
49
38
|
;
|
|
50
39
|
/**
|
|
51
40
|
* Standard listview class
|
package/lib/md5.d.ts
CHANGED
package/lib/md5.js
CHANGED
package/lib/popup.js
CHANGED
|
@@ -110,13 +110,12 @@ class Popup extends component_1.Container {
|
|
|
110
110
|
autofocus.focus();
|
|
111
111
|
}
|
|
112
112
|
else {
|
|
113
|
-
let tabbable = this.
|
|
113
|
+
let tabbable = this.queryAll('[tabindex]');
|
|
114
114
|
if (tabbable) {
|
|
115
|
-
let tab_indexes = [].map.call(tabbable, (e) => { return e; });
|
|
116
115
|
// remove hidden elements
|
|
117
|
-
|
|
118
|
-
if (
|
|
119
|
-
|
|
116
|
+
tabbable = tabbable.filter((el) => el.offsetParent !== null);
|
|
117
|
+
if (tabbable.length) {
|
|
118
|
+
tabbable[0].focus();
|
|
120
119
|
}
|
|
121
120
|
}
|
|
122
121
|
}
|
|
@@ -343,8 +342,7 @@ function _nextTab(root, el, prev) {
|
|
|
343
342
|
let comp = component_1.Component.getElement(el);
|
|
344
343
|
// get a list of elements with tab index, this way we should abble to
|
|
345
344
|
// cycle on them (not on browser address nor under dialog elements)
|
|
346
|
-
let
|
|
347
|
-
let tab_indexes = [].map.call(tabbable, (e) => { return e; });
|
|
345
|
+
let tab_indexes = Array.from(root.querySelectorAll('[tabindex]'));
|
|
348
346
|
// remove hidden elements
|
|
349
347
|
tab_indexes = tab_indexes.filter((el) => el.offsetParent !== null);
|
|
350
348
|
if (!tab_indexes.length) {
|
package/lib/request.js
CHANGED
package/lib/textedit.js
CHANGED
|
@@ -114,7 +114,7 @@ class TextEdit extends component_1.Component {
|
|
|
114
114
|
else if (props.type == 'date') {
|
|
115
115
|
button = new button_1.Button({
|
|
116
116
|
cls: 'gadget',
|
|
117
|
-
icon: '
|
|
117
|
+
icon: 'var( --x4-icon-calendar-days )',
|
|
118
118
|
tabIndex: false,
|
|
119
119
|
click: () => this._showDatePicker(button)
|
|
120
120
|
});
|
package/lib/tools.js
CHANGED
|
@@ -455,9 +455,10 @@ function parseIntlDate(value, fmts = i18n_1._tr.global.date_input_formats) {
|
|
|
455
455
|
let rematch = new RegExp('^' + smatch + '$', 'm');
|
|
456
456
|
let match = rematch.exec(value);
|
|
457
457
|
if (match) {
|
|
458
|
+
const now = new Date();
|
|
458
459
|
let d = parseInt(match.groups.day ?? '1');
|
|
459
460
|
let m = parseInt(match.groups.month ?? '1');
|
|
460
|
-
let y = parseInt(match.groups.year ?? '
|
|
461
|
+
let y = parseInt(match.groups.year ?? now.getFullYear() + '');
|
|
461
462
|
let h = parseInt(match.groups.hour ?? '0');
|
|
462
463
|
let i = parseInt(match.groups.min ?? '0');
|
|
463
464
|
let s = parseInt(match.groups.sec ?? '0');
|
package/lib/tooltips.js
CHANGED
|
@@ -47,7 +47,7 @@ class Tooltip extends component_1.Component {
|
|
|
47
47
|
render() {
|
|
48
48
|
this.setClass('@non-maskable', true);
|
|
49
49
|
this.setContent([
|
|
50
|
-
new icon_1.Icon({ icon: '
|
|
50
|
+
new icon_1.Icon({ icon: 'var( --x4-icon-tip )' }),
|
|
51
51
|
this.m_text = new label_1.Label({ text: 'help' })
|
|
52
52
|
]);
|
|
53
53
|
}
|