cx 25.2.1 → 25.3.1

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/widgets.js CHANGED
@@ -5193,7 +5193,7 @@ var LinkButton = /*#__PURE__*/ (function (_Button) {
5193
5193
  var _proto = LinkButton.prototype;
5194
5194
  _proto.init = function init() {
5195
5195
  this.activeStyle = parseStyle(this.activeStyle);
5196
- this.inacativeStyle = parseStyle(this.inactiveStyle);
5196
+ this.inactiveStyle = parseStyle(this.inactiveStyle);
5197
5197
  _Button.prototype.init.call(this);
5198
5198
  };
5199
5199
  _proto.declareData = function declareData() {
@@ -11568,7 +11568,12 @@ var ColorPickerComponent = /*#__PURE__*/ (function (_VDOM$Component) {
11568
11568
  var _proto2 = ColorPickerComponent.prototype;
11569
11569
  _proto2.UNSAFE_componentWillReceiveProps = function UNSAFE_componentWillReceiveProps(props) {
11570
11570
  var data = props.instance.data;
11571
- var color = this.parse(data.value);
11571
+ var color;
11572
+ try {
11573
+ color = this.parse(data.value);
11574
+ } catch (_unused) {
11575
+ color = this.parse(null);
11576
+ }
11572
11577
  if (color.r != this.state.r || color.g != this.state.g || color.b != this.state.b || color.a != this.state.a)
11573
11578
  this.setState(color);
11574
11579
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cx",
3
- "version": "25.2.1",
3
+ "version": "25.3.1",
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",
package/src/core.d.ts CHANGED
@@ -160,7 +160,7 @@ declare namespace Cx {
160
160
 
161
161
  interface HtmlElementProps extends StyledContainerProps {
162
162
  /** Id of the element */
163
- id?: string | number | Binding | Selector<string | number>;
163
+ id?: Cx.StringProp | Cx.NumberProp;
164
164
 
165
165
  /** Inner text contents. */
166
166
  text?: Cx.StringProp | Cx.NumberProp;
@@ -251,6 +251,39 @@ declare global {
251
251
  tooltip?: Cx.StringProp | Cx.StructuredProp;
252
252
  }
253
253
  }
254
+
255
+ interface JSON {
256
+ /* JSON doesn't support symbol keys, and number keys
257
+ * are coerced to strings, even in arrays */
258
+
259
+ /**
260
+ * Converts a JavaScript Object Notation (JSON) string into an object.
261
+ * @param text A valid JSON string.
262
+ * @param reviver A function that transforms the results. This function is called for each member of the object.
263
+ * If a member contains nested objects, the nested objects are transformed before the parent object is.
264
+ */
265
+ parse(text: string, reviver?: (this: unknown, key: string, value: unknown) => unknown): unknown;
266
+
267
+ /**
268
+ * Converts a JavaScript value to a JavaScript Object Notation (JSON) string.
269
+ * @param value A JavaScript value, usually an object or array, to be converted.
270
+ * @param replacer A function that transforms the results.
271
+ * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.
272
+ */
273
+ stringify(
274
+ text: unknown,
275
+ replacer?: (this: unknown, key: string, value: unknown) => unknown,
276
+ space?: string | number,
277
+ ): string;
278
+ }
279
+
280
+ interface ArrayConstructor {
281
+ isArray(a: unknown): a is unknown[];
282
+ }
283
+
284
+ interface Body {
285
+ json(): Promise<unknown>;
286
+ }
254
287
  }
255
288
 
256
289
  declare module "react" {
@@ -263,6 +296,12 @@ declare module "react" {
263
296
  innerHtml?: Cx.StringProp;
264
297
  tooltip?: Cx.StringProp | Cx.StructuredProp;
265
298
  }
299
+ namespace React {
300
+ interface ImgHTMLAttributes<T> extends HTMLAttributes<T> {
301
+ alt?: Cx.StringProp | undefined;
302
+ src?: Cx.StringProp | undefined;
303
+ }
304
+ }
266
305
 
267
306
  //this doesn't work, however, it would be nice if it does
268
307
  // interface EventHandler<E extends React.SyntheticEvent<any>> {
@@ -1,4 +1,4 @@
1
- import { Record, AccessorChain } from "../core";
1
+ import { AccessorChain } from "../core";
2
2
  import { Binding } from "./Binding";
3
3
  import { Ref } from "./Ref";
4
4
 
@@ -14,20 +14,22 @@ export interface ViewConfig {
14
14
  sealed?: boolean;
15
15
  }
16
16
 
17
- export interface ViewMethods<D = Record> {
17
+ export interface ViewMethods<D = Record<string, any>> {
18
18
  getData(): D;
19
19
 
20
20
  init(path: Path, value: any): boolean;
21
- init<V>(path: AccessorChain<V>, value: V | any): boolean;
21
+ init<V>(path: AccessorChain<V>, value: V): boolean;
22
22
 
23
23
  set(path: Path, value: any): boolean;
24
- set(changes: Record): boolean;
25
- set<V>(path: AccessorChain<V>, value: V | any): boolean;
24
+ set<T extends Record<string, any>>(changes: T): boolean;
25
+ set<V>(path: AccessorChain<V>, value: V): boolean;
26
26
 
27
27
  get(path: Path): any;
28
28
  get(paths: Path[]): any[];
29
29
  get(...paths: Path[]): any[];
30
30
  get<V>(path: AccessorChain<V>): V;
31
+ get<T extends any[]>(...paths: { [K in keyof T]: AccessorChain<T[K]> }): T;
32
+ get<T extends any[]>(paths: { [K in keyof T]: AccessorChain<T[K]> }): T;
31
33
 
32
34
  /**
33
35
  * Removes data from the Store.
@@ -38,19 +40,29 @@ export interface ViewMethods<D = Record> {
38
40
  delete(paths: Path[]): boolean;
39
41
  delete(...paths: Path[]): boolean;
40
42
  delete<V>(path: AccessorChain<V>): boolean;
43
+ delete<T extends any[]>(...paths: { [K in keyof T]: AccessorChain<T[K]> }): boolean;
44
+ delete<T extends any[]>(paths: { [K in keyof T]: AccessorChain<T[K]> }): boolean;
41
45
 
42
46
  toggle(path: Path): boolean;
43
47
 
44
48
  update(updateFn: (currentValue: D, ...args) => D, ...args): boolean;
45
49
  update(path: Path, updateFn: (currentValue: any, ...args) => any, ...args): boolean;
46
- update<V>(path: AccessorChain<V>, updateFn: (currentValue: V, ...args) => V, ...args): boolean;
50
+ update<V, A extends any[]>(
51
+ path: AccessorChain<V>,
52
+ updateFn: (currentValue: V, ...args: A) => V,
53
+ ...args: A
54
+ ): boolean;
47
55
 
48
56
  /**
49
57
  * Mutates the content of the store using Immer
50
58
  */
51
59
  mutate(updateFn: (currentValue: D, ...args) => D, ...args): boolean;
52
60
  mutate(path: Path, updateFn: (currentValue: any, ...args) => any, ...args): boolean;
53
- mutate<V>(path: AccessorChain<V>, updateFn: (currentValue: V, ...args) => V, ...args): boolean;
61
+ mutate<V, A extends any[]>(
62
+ path: AccessorChain<V>,
63
+ updateFn: (currentValue: V, ...args: A) => void,
64
+ ...args: A
65
+ ): boolean;
54
66
 
55
67
  ref<T = any>(path: string | AccessorChain<T>, defaultValue?: T): Ref<T>;
56
68
  }
@@ -64,8 +76,8 @@ export class View<D = any> implements ViewMethods<D> {
64
76
  init<V>(path: AccessorChain<V>, value: V): boolean;
65
77
 
66
78
  set(path: Path, value: any): boolean;
67
- set(changes: Record): boolean;
68
- set<V>(path: AccessorChain<V>, value: V | any): boolean;
79
+ set<T extends Record<string, any>>(changes: T): boolean;
80
+ set<V>(path: AccessorChain<V>, value: V): boolean;
69
81
 
70
82
  /**
71
83
  * Copies the value stored under the `from` path and saves it under the `to` path.
@@ -87,6 +99,8 @@ export class View<D = any> implements ViewMethods<D> {
87
99
  delete(paths: Path[]): boolean;
88
100
  delete(...paths: Path[]): boolean;
89
101
  delete<V>(path: AccessorChain<V>): boolean;
102
+ delete<T extends any[]>(...paths: { [K in keyof T]: AccessorChain<T[K]> }): boolean;
103
+ delete<T extends any[]>(paths: { [K in keyof T]: AccessorChain<T[K]> }): boolean;
90
104
 
91
105
  clear(): void;
92
106
 
@@ -94,17 +108,27 @@ export class View<D = any> implements ViewMethods<D> {
94
108
  get(paths: Path[]): any;
95
109
  get(...paths: Path[]): any;
96
110
  get<V>(path: AccessorChain<V>): V;
111
+ get<T extends any[]>(...paths: { [K in keyof T]: AccessorChain<T[K]> }): T;
112
+ get<T extends any[]>(paths: { [K in keyof T]: AccessorChain<T[K]> }): T;
97
113
 
98
114
  toggle(path: Path): boolean;
99
115
  toggle(path: AccessorChain<boolean>): boolean;
100
116
 
101
117
  update(updateFn: (currentValue: D, ...args) => any, ...args): boolean;
102
118
  update(path: Path, updateFn: (currentValue: any, ...args) => any, ...args): boolean;
103
- update<V>(path: AccessorChain<V>, updateFn: (currentValue: V, ...args) => V, ...args): boolean;
119
+ update<V, A extends any[]>(
120
+ path: AccessorChain<V>,
121
+ updateFn: (currentValue: V, ...args: A) => V,
122
+ ...args: A
123
+ ): boolean;
104
124
 
105
125
  mutate(updateFn: (currentValue: D, ...args) => void, ...args): boolean;
106
126
  mutate(path: Path, updateFn: (currentValue: any, ...args) => void, ...args): boolean;
107
- mutate<V>(path: AccessorChain<V>, updateFn: (currentValue: V, ...args) => void, ...args): boolean;
127
+ mutate<V, A extends any[]>(
128
+ path: AccessorChain<V>,
129
+ updateFn: (currentValue: V, ...args: A) => void,
130
+ ...args: A
131
+ ): boolean;
108
132
 
109
133
  /**
110
134
  * `batch` method can be used to perform multiple Store operations silently
@@ -121,7 +145,7 @@ export class View<D = any> implements ViewMethods<D> {
121
145
 
122
146
  subscribe(callback: (changes?) => void): () => void;
123
147
 
124
- load(data: Record): boolean;
148
+ load(data: Record<string, any>): boolean;
125
149
 
126
150
  dispatch(action): void;
127
151
 
@@ -1,9 +1,10 @@
1
- import * as Cx from '../core';
2
-
3
1
  export class ResizeManager {
4
2
  static subscribe(callback: () => void): () => void;
5
3
 
6
4
  static notify(): void;
7
5
 
8
- static trackElement(el: Element, callback: () => void): () => void;
6
+ static trackElement(
7
+ el: Element,
8
+ callback: (entries: ResizeObserverEntry[], observer: ResizeObserver) => void,
9
+ ): () => void;
9
10
  }