cx 22.6.0 → 22.6.3

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/dist/ui.js CHANGED
@@ -5040,13 +5040,14 @@ var TreeAdapter = /*#__PURE__*/ (function(_ArrayAdapter) {
5040
5040
  _proto.processNode = function processNode(context, instance, level, result, record) {
5041
5041
  var _this2 = this;
5042
5042
 
5043
- result.push(record);
5043
+ var isHiddenRootNode = level == 0 && this.hideRootNodes;
5044
+ if (!isHiddenRootNode) result.push(record);
5044
5045
  var data = record.data,
5045
5046
  store = record.store;
5046
- data.$level = level;
5047
+ data.$level = this.hideRootNodes ? level - 1 : level;
5047
5048
 
5048
5049
  if (!data[this.leafField]) {
5049
- if (data[this.expandedField]) {
5050
+ if (data[this.expandedField] || isHiddenRootNode) {
5050
5051
  if (data[this.childrenField]) {
5051
5052
  var childNodes = _ArrayAdapter.prototype.mapRecords.call(
5052
5053
  this,
@@ -5099,6 +5100,7 @@ TreeAdapter.prototype.loadingField = "$loading";
5099
5100
  TreeAdapter.prototype.loadedField = "$loaded";
5100
5101
  TreeAdapter.prototype.foldersFirst = true;
5101
5102
  TreeAdapter.prototype.isTreeAdapter = true;
5103
+ TreeAdapter.prototype.hideRootNodes = false;
5102
5104
 
5103
5105
  function bind(path, defaultValue) {
5104
5106
  return {
package/dist/widgets.js CHANGED
@@ -1901,9 +1901,9 @@ var ListComponent = /*#__PURE__*/ (function(_VDOM$Component) {
1901
1901
  for (var i = 0; i < items.length; i++) {
1902
1902
  var item = items[i];
1903
1903
 
1904
- if (isItemSelectable(item)) {
1904
+ if (isDataItem(item)) {
1905
1905
  index++;
1906
- if (firstValid == -1) firstValid = index;
1906
+ if (!isItemDisabled(item) && firstValid == -1) firstValid = index;
1907
1907
 
1908
1908
  if (item.instance.selected) {
1909
1909
  firstSelected = index;
@@ -2045,7 +2045,15 @@ var ListItem = /*#__PURE__*/ (function(_Container) {
2045
2045
  })(Container);
2046
2046
 
2047
2047
  function isItemSelectable(item) {
2048
- return item && item.type == "data" && !item.instance.data.disabled;
2048
+ return isDataItem(item) && !isItemDisabled(item);
2049
+ }
2050
+
2051
+ function isDataItem(item) {
2052
+ return (item == null ? void 0 : item.type) == "data";
2053
+ }
2054
+
2055
+ function isItemDisabled(item) {
2056
+ return item == null ? void 0 : item.instance.data.disabled;
2049
2057
  }
2050
2058
 
2051
2059
  var Sandbox = /*#__PURE__*/ (function(_PureContainer) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cx",
3
- "version": "22.6.0",
3
+ "version": "22.6.3",
4
4
  "description": "Advanced JavaScript UI framework for admin and dashboard applications with ready to use grid, form and chart components.",
5
5
  "main": "index.js",
6
6
  "jsnext:main": "src/index.js",
@@ -13,7 +13,7 @@ interface PieChartProps extends BoundedObjectProps {
13
13
  clockwise?: Cx.BooleanProp;
14
14
  }
15
15
 
16
- export class PieChart extends Cx.Widget<PieChartProps> { }
16
+ export class PieChart extends Cx.Widget<PieChartProps> {}
17
17
 
18
18
  interface PieSliceProps extends Cx.StyledContainerProps {
19
19
  /** Used to indicate whether an item is active or not. Inactive items are shown only in the legend. */
@@ -43,7 +43,7 @@ interface PieSliceProps extends Cx.StyledContainerProps {
43
43
  /** Value in pixels to be used to explode the pie. */
44
44
  offset?: Cx.NumberProp;
45
45
 
46
- value?: Cx.StringProp;
46
+ value?: Cx.NumberProp;
47
47
  disabled?: Cx.BooleanProp;
48
48
  innerPointRadius?: Cx.NumberProp;
49
49
  outerPointRadius?: Cx.NumberProp;
@@ -68,7 +68,7 @@ interface PieSliceProps extends Cx.StyledContainerProps {
68
68
  tooltip?: Cx.StringProp | Cx.StructuredProp;
69
69
 
70
70
  /** Selection configuration. */
71
- selection?: { type: typeof PropertySelection | typeof KeySelection;[prop: string]: any };
71
+ selection?: { type: typeof PropertySelection | typeof KeySelection; [prop: string]: any };
72
72
 
73
73
  /** A value used to identify the group of components participating in hover effect synchronization. */
74
74
  hoverChannel?: string;
@@ -77,4 +77,4 @@ interface PieSliceProps extends Cx.StyledContainerProps {
77
77
  hoverId?: Cx.StringProp;
78
78
  }
79
79
 
80
- export class PieSlice extends Cx.Widget<PieSliceProps> { }
80
+ export class PieSlice extends Cx.Widget<PieSliceProps> {}
package/src/core.d.ts CHANGED
@@ -150,6 +150,14 @@ declare namespace Cx {
150
150
 
151
151
  /** Tooltip configuration. */
152
152
  tooltip?: StringProp | StructuredProp;
153
+
154
+ onMouseDown?: string | ((event: MouseEvent, instance: any) => void);
155
+ onMouseMove?: string | ((event: MouseEvent, instance: any) => void);
156
+ onMouseUp?: string | ((event: MouseEvent, instance: any) => void);
157
+ onTouchStart?: string | ((event: TouchEvent, instance: any) => void);
158
+ onTouchMove?: string | ((event: TouchEvent, instance: any) => void);
159
+ onTouchEnd?: string | ((event: TouchEvent, instance: any) => void);
160
+ onClick?: string | ((event: MouseEvent, instance: any) => void);
153
161
  }
154
162
 
155
163
  type SortDirection = "ASC" | "DESC";
@@ -0,0 +1,6 @@
1
+ export function findTreePath<T>(
2
+ array: T[],
3
+ criteria: (item: T) => boolean,
4
+ childrenField = "$children",
5
+ currentPath: T[] = []
6
+ ): T[] | false;
@@ -0,0 +1,16 @@
1
+ export function findTreePath(array, criteria, childrenField = "$children", currentPath = []) {
2
+ if (!Array.isArray(array)) return false;
3
+
4
+ for (let i = 0; i < array.length; i++) {
5
+ currentPath.push(array[i]);
6
+
7
+ if (criteria(array[i])) return currentPath;
8
+
9
+ let childPath = findTreePath(array[i][childrenField], criteria, childrenField, currentPath);
10
+ if (childPath) return childPath;
11
+
12
+ currentPath.pop();
13
+ }
14
+
15
+ return false;
16
+ }
@@ -1,10 +1,10 @@
1
- export * from './append';
2
- export * from './merge';
3
- export * from './filter';
4
- export * from './updateArray';
5
- export * from './updateTree';
6
- export * from './removeTreeNodes';
7
- export * from './findTreeNode';
8
- export * from './moveElement';
9
- export * from './insertElement';
10
-
1
+ export * from "./append";
2
+ export * from "./merge";
3
+ export * from "./filter";
4
+ export * from "./updateArray";
5
+ export * from "./updateTree";
6
+ export * from "./removeTreeNodes";
7
+ export * from "./findTreeNode";
8
+ export * from "./moveElement";
9
+ export * from "./insertElement";
10
+ export * from "./findTreePath";
@@ -7,4 +7,5 @@ export * from './removeTreeNodes';
7
7
  export * from './findTreeNode';
8
8
  export * from './moveElement';
9
9
  export * from './insertElement';
10
+ export * from './findTreePath';
10
11
 
@@ -22,12 +22,13 @@ export class TreeAdapter extends ArrayAdapter {
22
22
  });
23
23
  }
24
24
 
25
- processNode(context, instance, level, result, record) {
26
- result.push(record);
25
+ processNode(context, instance, level, result, record) {
26
+ let isHiddenRootNode = level == 0 && this.hideRootNodes;
27
+ if (!isHiddenRootNode) result.push(record);
27
28
  let { data, store } = record;
28
- data.$level = level;
29
+ data.$level = this.hideRootNodes ? level - 1 : level;
29
30
  if (!data[this.leafField]) {
30
- if (data[this.expandedField]) {
31
+ if (data[this.expandedField] || isHiddenRootNode) {
31
32
  if (data[this.childrenField]) {
32
33
  let childNodes = super.mapRecords(
33
34
  context,
@@ -71,3 +72,4 @@ TreeAdapter.prototype.loadingField = "$loading";
71
72
  TreeAdapter.prototype.loadedField = "$loaded";
72
73
  TreeAdapter.prototype.foldersFirst = true;
73
74
  TreeAdapter.prototype.isTreeAdapter = true;
75
+ TreeAdapter.prototype.hideRootNodes = false;
@@ -1,52 +1,58 @@
1
- import * as Cx from '../core';
2
- import * as React from 'react';
3
- import {Instance} from "../ui/Instance";
1
+ import * as Cx from "../core";
2
+ import * as React from "react";
3
+ import { Instance } from "../ui/Instance";
4
4
 
5
5
  export interface ButtonProps extends Cx.HtmlElementProps {
6
-
7
6
  /** Confirmation text or configuration object. See MsgBox.yesNo for more details. */
8
- confirm?: Cx.Prop<string | Cx.Config>,
7
+ confirm?: Cx.Prop<string | Cx.Config>;
9
8
 
10
9
  /** If true button appears in pressed state. Useful for implementing toggle buttons. */
11
- pressed?: Cx.BooleanProp,
10
+ pressed?: Cx.BooleanProp;
12
11
 
13
12
  /** Name of the icon to be put on the left side of the button. */
14
- icon?: Cx.StringProp,
15
-
13
+ icon?: Cx.StringProp;
14
+
16
15
  /** HTML tag to be used. Default is `button`. */
17
- tag?: string,
16
+ tag?: string;
18
17
 
19
18
  /** Base CSS class to be applied to the element. Default is 'button'. */
20
- baseClass?: string,
19
+ baseClass?: string;
21
20
 
22
- /**
23
- * Determines if button should receive focus on mousedown event.
24
- * Default is `false`, which means that focus can be set only using the keyboard `Tab` key.
21
+ /**
22
+ * Determines if button should receive focus on mousedown event.
23
+ * Default is `false`, which means that focus can be set only using the keyboard `Tab` key.
25
24
  */
26
- focusOnMouseDown?: boolean,
25
+ focusOnMouseDown?: boolean;
27
26
 
28
27
  /** Add type="submit" to the button. */
29
- submit?: boolean,
28
+ submit?: boolean;
30
29
 
31
30
  /** Set to `true` to disable the button. */
32
- disabled?: Cx.BooleanProp,
31
+ disabled?: Cx.BooleanProp;
33
32
 
34
33
  /** Set to `false` to disable the button. */
35
- enabled?: Cx.BooleanProp,
34
+ enabled?: Cx.BooleanProp;
36
35
 
37
- /**
36
+ /**
38
37
  * Click handler.
39
38
  *
40
39
  * @param e - Event.
41
- * @param instance - Cx widget instance that fired the event.
40
+ * @param instance - Cx widget instance that fired the event.
42
41
  */
43
- onClick?: string | ((e: React.SyntheticEvent<any>, instance: Instance) => void),
42
+ onClick?: string | ((e: React.SyntheticEvent<any>, instance: Instance) => void);
43
+
44
+ onMouseDown?: string | ((e: React.SyntheticEvent<any>, instance: Instance) => void);
44
45
 
45
46
  /** Button type. */
46
- type?: 'submit' | 'button',
47
+ type?: "submit" | "button";
47
48
 
48
49
  /** If set to `true`, the Button will cause its parent Overlay (if one exists) to close. This, however, can be prevented if `onClick` explicitly returns `false`. */
49
- dismiss?: boolean
50
+ dismiss?: boolean;
51
+
52
+ /** The form attribute specifies the form the button belongs to.
53
+ * The value of this attribute must be equal to the `id` attribute of a `<form>` element in the same document.
54
+ */
55
+ form?: Cx.StringProp;
50
56
  }
51
57
 
52
58
  export class Button extends Cx.Widget<ButtonProps> {}
@@ -462,9 +462,10 @@ class ListComponent extends VDOM.Component {
462
462
  firstValid = -1;
463
463
  for (let i = 0; i < items.length; i++) {
464
464
  let item = items[i];
465
- if (isItemSelectable(item)) {
465
+ if (isDataItem(item)) {
466
466
  index++;
467
- if (firstValid == -1) firstValid = index;
467
+
468
+ if (!isItemDisabled(item) && firstValid == -1) firstValid = index;
468
469
  if (item.instance.selected) {
469
470
  firstSelected = index;
470
471
  break;
@@ -576,5 +577,13 @@ class ListItem extends Container {
576
577
  }
577
578
 
578
579
  function isItemSelectable(item) {
579
- return item && item.type == "data" && !item.instance.data.disabled;
580
+ return isDataItem(item) && !isItemDisabled(item);
581
+ }
582
+
583
+ function isDataItem(item) {
584
+ return item?.type == "data";
585
+ }
586
+
587
+ function isItemDisabled(item) {
588
+ return item?.instance.data.disabled;
580
589
  }
@@ -17,11 +17,11 @@ export interface MenuItemProps extends Cx.HtmlElementProps {
17
17
  placementOrder?: string;
18
18
  autoClose?: boolean;
19
19
  icons?: boolean;
20
- icon: Cx.StringProp;
20
+ icon?: Cx.StringProp;
21
21
  keyboardShortcut?: KeyboardShortcut;
22
22
  tooltip?: string | Cx.Config;
23
23
  openOnFocus?: boolean;
24
- disabled: Cx.BooleanProp;
24
+ disabled?: Cx.BooleanProp;
25
25
 
26
26
  /**
27
27
  * Click handler.
@@ -1,38 +1,39 @@
1
- import * as Cx from '../../core';
2
- import { OverlayProps } from './Overlay';
1
+ import * as Cx from "../../core";
2
+ import { OverlayProps } from "./Overlay";
3
3
 
4
4
  interface WindowProps extends OverlayProps {
5
-
6
5
  /** Text to be displayed in the header. */
7
- title?: Cx.StringProp,
6
+ title?: Cx.StringProp;
8
7
 
9
8
  /** Controls the close button visibility. Defaults to `true`. */
10
- closable?: Cx.BooleanProp,
9
+ closable?: Cx.BooleanProp;
11
10
 
12
11
  /** A custom style which will be applied to the body. */
13
- bodyStyle?: Cx.StyleProp,
12
+ bodyStyle?: Cx.StyleProp;
14
13
 
15
14
  /** A custom style which will be applied to the header. */
16
- headerStyle?: Cx.StyleProp,
15
+ headerStyle?: Cx.StyleProp;
17
16
 
18
17
  /** A custom style which will be applied to the footer. */
19
- footerStyle?: Cx.StyleProp
18
+ footerStyle?: Cx.StyleProp;
20
19
 
21
20
  /** Base CSS class to be applied to the field. Defaults to `window`. */
22
- baseClass?: string,
21
+ baseClass?: string;
22
+
23
+ /** Additional CSS class to be applied to the section body. */
24
+ bodyClass?: Cx.ClassProp;
23
25
 
24
26
  /** Set to `true` to enable resizing. */
25
- resizable?: boolean,
27
+ resizable?: boolean;
26
28
 
27
29
  /** Set to `true` to automatically focus the field, after it renders for the first time. */
28
- autoFocus?: boolean,
30
+ autoFocus?: boolean;
29
31
 
30
32
  /** Set to `false` to prevent the window itself to be focusable. Default value is true.*/
31
- focusable?: boolean,
33
+ focusable?: boolean;
32
34
 
33
35
  /** Set to `true` to disable moving the window by dragging the header. */
34
- fixed?: boolean,
35
-
36
+ fixed?: boolean;
36
37
  }
37
38
 
38
39
  export class Window extends Cx.Widget<WindowProps> {}