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 CHANGED
@@ -126,17 +126,20 @@ class Calendar extends layout_1.VLayout {
126
126
  if (dte.getMonth() != cmonth) {
127
127
  cls += ' out';
128
128
  }
129
- days.push(new layout_1.HLayout({
130
- cls,
131
- flex: 1,
132
- content: new component_1.Component({
133
- tag: 'span',
134
- content: (0, tools_1.formatIntlDate)(dte, 'd'),
135
- }),
136
- dom_events: {
137
- click: () => this.select(dte.clone())
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
  }
@@ -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): NodeListOf<Element>;
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
- const elements = this.m_dom.querySelectorAll(selector);
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
@@ -332,7 +332,7 @@ class Record {
332
332
  }
333
333
  let fld = fields[idx];
334
334
  if (fld.calc !== undefined) {
335
- return fld.calc.call(this);
335
+ return fld.calc(this);
336
336
  }
337
337
  return this[fld.name];
338
338
  }
package/lib/formatters.js CHANGED
@@ -86,3 +86,4 @@ function bool_formatter(input) {
86
86
  return input ? 'oui' : '-';
87
87
  }
88
88
  exports.bool_formatter = bool_formatter;
89
+ setCurrencySymbol(null);
package/lib/gridview.js CHANGED
@@ -60,7 +60,7 @@ class ColHeader extends component_1.Component {
60
60
  }),
61
61
  new icon_js_1.Icon({
62
62
  ref: 'sorter',
63
- cls: '@hidden',
63
+ cls: '@hidden sort',
64
64
  icon: 'var( --x4-icon-arrow-down )'
65
65
  })
66
66
  ]);
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, CProps, ContainerEventMap, EvDblClick } from './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 declare class ListViewItem {
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 CProps<E> {
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 = exports.ListViewItem = void 0;
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
@@ -51,7 +51,7 @@ export declare class Md5 {
51
51
  appendAsciiStr(str: string): this;
52
52
  appendByteArray(input: Uint8Array): this;
53
53
  getState(): {
54
- buffer: any;
54
+ buffer: string;
55
55
  buflen: number;
56
56
  length: number;
57
57
  state: number[];
package/lib/md5.js CHANGED
@@ -343,6 +343,7 @@ class Md5 {
343
343
  const self = this;
344
344
  const s = self._state;
345
345
  return {
346
+ //@ts-ignore
346
347
  buffer: String.fromCharCode.apply(null, self._buffer8),
347
348
  buflen: self._bufferLength,
348
349
  length: self._dataLength,
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.queryItem('[tabindex]');
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
- tab_indexes = tab_indexes.filter((el) => el.offsetParent !== null);
118
- if (tab_indexes.length) {
119
- tab_indexes[0].focus();
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 tabbable = root.querySelectorAll('[tabindex]');
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
@@ -78,7 +78,7 @@ function ajaxRequest(cfg) {
78
78
  }
79
79
  if (cfg.headers) {
80
80
  for (let h in cfg.headers) {
81
- this.xhr.setRequestHeader(h, cfg.headers[h]);
81
+ xhr.setRequestHeader(h, cfg.headers[h]);
82
82
  }
83
83
  }
84
84
  function progress(ev) {
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: 'cls(far fa-calendar-days)',
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 ?? '1970');
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: 'cls(far fa-circle-info)' }),
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
  }