cx 23.4.1 → 23.4.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cx",
3
- "version": "23.4.1",
3
+ "version": "23.4.2",
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",
@@ -7,18 +7,8 @@ export class Binding {
7
7
  constructor(path) {
8
8
  this.path = path;
9
9
  this.parts = path.split(".");
10
- let body = "return (x";
11
- let selector = "x";
12
-
13
- for (let i = 0; i < this.parts.length; i++) {
14
- if (this.parts[i][0] >= "0" && this.parts[i][0] <= "9") selector += "[" + this.parts[i] + "]";
15
- else selector += "." + this.parts[i];
16
-
17
- if (i + 1 < this.parts.length) body += " && " + selector;
18
- else body += " ? " + selector + " : undefined";
19
- }
20
-
21
- body += ")";
10
+ let body = "return x";
11
+ for (let i = 0; i < this.parts.length; i++) body += '?.["' + this.parts[i] + '"]';
22
12
  this.value = new Function("x", body);
23
13
  }
24
14
 
@@ -1,49 +1,59 @@
1
- import {Binding} from './Binding';
2
- import assert from 'assert';
3
-
4
- describe('Binding', function() {
5
-
6
- describe('#get()', function () {
7
- it('should get value if value is defined', function () {
8
- var state = {person: {name: 'Joe'}};
9
- var b = Binding.get('person.name');
10
- assert.equal(b.value(state), 'Joe');
11
- });
12
- });
1
+ import { Binding } from "./Binding";
2
+ import assert from "assert";
3
+
4
+ describe("Binding", function () {
5
+ describe("#get()", function () {
6
+ it("should get value if value is defined", function () {
7
+ var state = { person: { name: "Joe" } };
8
+ var b = Binding.get("person.name");
9
+ assert.equal(b.value(state), "Joe");
10
+ });
13
11
 
14
- describe('#set()', function () {
12
+ it("allows non-standard property identifiers", function () {
13
+ var state = { person: { "@schema": "Person" } };
14
+ var b = Binding.get("person.@schema");
15
+ assert.equal(b.value(state), "Person");
16
+ });
17
+ });
15
18
 
16
- it('produces new objects along the binding path', function () {
17
- var state = {person: {name: 'Joe'}};
18
- var b = Binding.get('person.name');
19
- var ns = b.set(state, 'Jack');
20
- assert.equal(ns.person.name, 'Jack');
21
- assert.notEqual(state, ns);
22
- assert.notEqual(state.person, ns.person);
23
- assert.notEqual(state.person.name, ns.person.name);
24
- });
19
+ describe("#set()", function () {
20
+ it("produces new objects along the binding path", function () {
21
+ var state = { person: { name: "Joe" } };
22
+ var b = Binding.get("person.name");
23
+ var ns = b.set(state, "Jack");
24
+ assert.equal(ns.person.name, "Jack");
25
+ assert.notEqual(state, ns);
26
+ assert.notEqual(state.person, ns.person);
27
+ assert.notEqual(state.person.name, ns.person.name);
28
+ });
25
29
 
26
- it('returns same state object if value does not change', function () {
27
- var state = {person: {name: 'Joe'}};
28
- var b = Binding.get('person.name');
29
- var ns = b.set(state, 'Joe');
30
- assert.equal(state, ns);
31
- });
32
- });
30
+ it("returns same state object if value does not change", function () {
31
+ var state = { person: { name: "Joe" } };
32
+ var b = Binding.get("person.name");
33
+ var ns = b.set(state, "Joe");
34
+ assert.equal(state, ns);
35
+ });
33
36
 
34
- describe('.delete()', function () {
37
+ it("allows non-standard property identifiers", function () {
38
+ var state = { person: { "@schema": "Person" } };
39
+ var b = Binding.get("person.@schema");
40
+ var ns = b.set(state, "Test");
41
+ assert.equal(ns.person["@schema"], "Test");
42
+ });
43
+ });
35
44
 
36
- it('correctly removes pointed properties', function () {
37
- var state = {person: {name: 'Joe'}};
38
- var b = Binding.get('person.name');
45
+ describe(".delete()", function () {
46
+ it("correctly removes pointed properties", function () {
47
+ var state = { person: { name: "Joe" } };
48
+ var b = Binding.get("person.name");
39
49
  var ns = b.delete(state);
40
- assert('person' in ns);
41
- assert(!('name' in ns.person));
50
+ assert("person" in ns);
51
+ assert(!("name" in ns.person));
42
52
  });
43
53
 
44
- it('does not change state if property is non-existent', function () {
45
- var state = {person: {name: 'Joe'}};
46
- var b = Binding.get('person.name2');
54
+ it("does not change state if property is non-existent", function () {
55
+ var state = { person: { name: "Joe" } };
56
+ var b = Binding.get("person.name2");
47
57
  var ns = b.delete(state);
48
58
  assert(ns == state);
49
59
  });
@@ -7,6 +7,7 @@ interface Model {
7
7
  city: string;
8
8
  streetNumber: number;
9
9
  };
10
+ "@crazy": string;
10
11
  }
11
12
 
12
13
  describe("createAccessorModelProxy", () => {
@@ -35,4 +36,9 @@ describe("createAccessorModelProxy", () => {
35
36
  assert.strictEqual(streetNumber.nameOf(), "streetNumber");
36
37
  assert.strictEqual(city.nameOf(), "city");
37
38
  });
39
+
40
+ it("allows non-standard property identifiers ", () => {
41
+ let model = createAccessorModelProxy<Model>();
42
+ assert.strictEqual(model["@crazy"].nameOf(), "@crazy");
43
+ });
38
44
  });
@@ -1,6 +1,8 @@
1
- import * as Cx from '../../core';
2
- import { FieldProps } from './Field';
1
+ import * as Cx from "../../core";
2
+ import { FieldProps } from "./Field";
3
3
 
4
- interface ValidatorProps extends FieldProps {}
4
+ interface ValidatorProps extends FieldProps {
5
+ value: Cx.StructuredProp;
6
+ }
5
7
 
6
8
  export class Validator extends Cx.Widget<ValidatorProps> {}