@kaskad/component-tree 0.0.1 → 0.0.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/fesm2022/kaskad-component-tree.mjs +2380 -0
- package/fesm2022/kaskad-component-tree.mjs.map +1 -0
- package/package.json +10 -10
- package/types/kaskad-component-tree.d.ts +582 -0
- package/esm2022/index.js +0 -12
- package/esm2022/index.js.map +0 -1
- package/esm2022/kaskad-component-tree.js +0 -5
- package/esm2022/kaskad-component-tree.js.map +0 -1
- package/esm2022/lib/component-lookup/index.js +0 -68
- package/esm2022/lib/component-lookup/index.js.map +0 -1
- package/esm2022/lib/component-lookup/traverses/array-traverser.js +0 -18
- package/esm2022/lib/component-lookup/traverses/array-traverser.js.map +0 -1
- package/esm2022/lib/component-lookup/traverses/component-traverser.js +0 -120
- package/esm2022/lib/component-lookup/traverses/component-traverser.js.map +0 -1
- package/esm2022/lib/component-lookup/traverses/index.js +0 -29
- package/esm2022/lib/component-lookup/traverses/index.js.map +0 -1
- package/esm2022/lib/component-lookup/traverses/object-traverser.js +0 -22
- package/esm2022/lib/component-lookup/traverses/object-traverser.js.map +0 -1
- package/esm2022/lib/component-lookup/types.js +0 -1
- package/esm2022/lib/component-lookup/types.js.map +0 -1
- package/esm2022/lib/component-tree-api.js +0 -121
- package/esm2022/lib/component-tree-api.js.map +0 -1
- package/esm2022/lib/computation/computation-frame.js +0 -27
- package/esm2022/lib/computation/computation-frame.js.map +0 -1
- package/esm2022/lib/computation/computation-stack.js +0 -83
- package/esm2022/lib/computation/computation-stack.js.map +0 -1
- package/esm2022/lib/computation/index.js +0 -3
- package/esm2022/lib/computation/index.js.map +0 -1
- package/esm2022/lib/config.js +0 -6
- package/esm2022/lib/config.js.map +0 -1
- package/esm2022/lib/mobx/component.js +0 -110
- package/esm2022/lib/mobx/component.js.map +0 -1
- package/esm2022/lib/mobx/create-root-node.js +0 -21
- package/esm2022/lib/mobx/create-root-node.js.map +0 -1
- package/esm2022/lib/mobx/ref-space.js +0 -25
- package/esm2022/lib/mobx/ref-space.js.map +0 -1
- package/esm2022/lib/mobx/store.js +0 -827
- package/esm2022/lib/mobx/store.js.map +0 -1
- package/esm2022/lib/node/create-node-options.js +0 -16
- package/esm2022/lib/node/create-node-options.js.map +0 -1
- package/esm2022/lib/node/creators/array-creator.js +0 -9
- package/esm2022/lib/node/creators/array-creator.js.map +0 -1
- package/esm2022/lib/node/creators/command-creator.js +0 -16
- package/esm2022/lib/node/creators/command-creator.js.map +0 -1
- package/esm2022/lib/node/creators/component-creator.js +0 -58
- package/esm2022/lib/node/creators/component-creator.js.map +0 -1
- package/esm2022/lib/node/creators/leaf-creator.js +0 -5
- package/esm2022/lib/node/creators/leaf-creator.js.map +0 -1
- package/esm2022/lib/node/creators/map-creator.js +0 -14
- package/esm2022/lib/node/creators/map-creator.js.map +0 -1
- package/esm2022/lib/node/creators/object-creator.js +0 -17
- package/esm2022/lib/node/creators/object-creator.js.map +0 -1
- package/esm2022/lib/node/creators/set-creator.js +0 -13
- package/esm2022/lib/node/creators/set-creator.js.map +0 -1
- package/esm2022/lib/node/creators/shape-creator.js +0 -15
- package/esm2022/lib/node/creators/shape-creator.js.map +0 -1
- package/esm2022/lib/node/creators/variant-shape-creator.js +0 -23
- package/esm2022/lib/node/creators/variant-shape-creator.js.map +0 -1
- package/esm2022/lib/node/guards.js +0 -5
- package/esm2022/lib/node/guards.js.map +0 -1
- package/esm2022/lib/node/node-creation.js +0 -47
- package/esm2022/lib/node/node-creation.js.map +0 -1
- package/esm2022/lib/node/node-type.js +0 -1
- package/esm2022/lib/node/node-type.js.map +0 -1
- package/esm2022/lib/node/node.js +0 -305
- package/esm2022/lib/node/node.js.map +0 -1
- package/esm2022/lib/parsers/index.js +0 -3
- package/esm2022/lib/parsers/index.js.map +0 -1
- package/esm2022/lib/parsers/node-selector.types.js +0 -1
- package/esm2022/lib/parsers/node-selector.types.js.map +0 -1
- package/esm2022/lib/parsers/parse-component-selector.js +0 -43
- package/esm2022/lib/parsers/parse-component-selector.js.map +0 -1
- package/esm2022/lib/parsers/parse-node-selector.js +0 -263
- package/esm2022/lib/parsers/parse-node-selector.js.map +0 -1
- package/esm2022/lib/types/command.js +0 -1
- package/esm2022/lib/types/command.js.map +0 -1
- package/esm2022/lib/types/index.js +0 -5
- package/esm2022/lib/types/index.js.map +0 -1
- package/esm2022/lib/types/node.guards.js +0 -7
- package/esm2022/lib/types/node.guards.js.map +0 -1
- package/esm2022/lib/types/schema.js +0 -1
- package/esm2022/lib/types/schema.js.map +0 -1
- package/esm2022/lib/util/extract-node-value.js +0 -45
- package/esm2022/lib/util/extract-node-value.js.map +0 -1
- package/esm2022/lib/util/format-source.js +0 -7
- package/esm2022/lib/util/format-source.js.map +0 -1
- package/esm2022/lib/util/get-component.js +0 -8
- package/esm2022/lib/util/get-component.js.map +0 -1
- package/esm2022/lib/util/id-generator.js +0 -10
- package/esm2022/lib/util/id-generator.js.map +0 -1
- package/esm2022/lib/util/traverse-node.js +0 -50
- package/esm2022/lib/util/traverse-node.js.map +0 -1
- package/index.d.ts +0 -11
- package/kaskad-component-tree.d.ts +0 -5
- package/lib/component-lookup/index.d.ts +0 -8
- package/lib/component-lookup/traverses/array-traverser.d.ts +0 -3
- package/lib/component-lookup/traverses/component-traverser.d.ts +0 -3
- package/lib/component-lookup/traverses/index.d.ts +0 -9
- package/lib/component-lookup/traverses/object-traverser.d.ts +0 -3
- package/lib/component-lookup/types.d.ts +0 -13
- package/lib/component-tree-api.d.ts +0 -21
- package/lib/computation/computation-frame.d.ts +0 -14
- package/lib/computation/computation-stack.d.ts +0 -48
- package/lib/computation/index.d.ts +0 -2
- package/lib/config.d.ts +0 -4
- package/lib/mobx/component.d.ts +0 -45
- package/lib/mobx/create-root-node.d.ts +0 -3
- package/lib/mobx/ref-space.d.ts +0 -10
- package/lib/mobx/store.d.ts +0 -238
- package/lib/node/create-node-options.d.ts +0 -12
- package/lib/node/creators/array-creator.d.ts +0 -4
- package/lib/node/creators/command-creator.d.ts +0 -4
- package/lib/node/creators/component-creator.d.ts +0 -4
- package/lib/node/creators/leaf-creator.d.ts +0 -4
- package/lib/node/creators/map-creator.d.ts +0 -4
- package/lib/node/creators/object-creator.d.ts +0 -4
- package/lib/node/creators/set-creator.d.ts +0 -4
- package/lib/node/creators/shape-creator.d.ts +0 -4
- package/lib/node/creators/variant-shape-creator.d.ts +0 -4
- package/lib/node/guards.d.ts +0 -3
- package/lib/node/node-creation.d.ts +0 -4
- package/lib/node/node-type.d.ts +0 -49
- package/lib/node/node.d.ts +0 -107
- package/lib/parsers/index.d.ts +0 -5
- package/lib/parsers/node-selector.types.d.ts +0 -25
- package/lib/parsers/parse-component-selector.d.ts +0 -8
- package/lib/parsers/parse-node-selector.d.ts +0 -87
- package/lib/types/command.d.ts +0 -3
- package/lib/types/index.d.ts +0 -4
- package/lib/types/node.guards.d.ts +0 -4
- package/lib/types/schema.d.ts +0 -13
- package/lib/util/extract-node-value.d.ts +0 -3
- package/lib/util/format-source.d.ts +0 -1
- package/lib/util/get-component.d.ts +0 -4
- package/lib/util/id-generator.d.ts +0 -5
- package/lib/util/traverse-node.d.ts +0 -26
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { NodeSelector } from './node-selector.types';
|
|
2
|
-
export type PathPart = string | number;
|
|
3
|
-
export type PathArray = PathPart[];
|
|
4
|
-
/**
|
|
5
|
-
* Parse a path string into structured segments.
|
|
6
|
-
*
|
|
7
|
-
* ## Path Notation Rules
|
|
8
|
-
*
|
|
9
|
-
* **Dot notation (.)** - Access object properties
|
|
10
|
-
* - `user.profile.name` - Access nested object properties
|
|
11
|
-
* - `config.0` - Access object property named "0" (string key)
|
|
12
|
-
*
|
|
13
|
-
* **Bracket notation ([])** - Access array elements by numeric index
|
|
14
|
-
* - `items[0].name` - Access first array element, then its 'name' property
|
|
15
|
-
* - `matrix[0][1]` - Access multi-dimensional arrays
|
|
16
|
-
*
|
|
17
|
-
* **Optional chaining (?.)** - Safely access potentially missing properties
|
|
18
|
-
* - `user?.profile?.email` - Returns null if any segment is missing
|
|
19
|
-
*
|
|
20
|
-
* **Variable prefix ($)** - Access variables instead of properties
|
|
21
|
-
* - `$config.theme` - Access variable 'config', then its 'theme' property
|
|
22
|
-
* - `$items[0]` - Access variable 'items' array, then first element
|
|
23
|
-
*
|
|
24
|
-
* **Component selector (->)** - Access properties on other components
|
|
25
|
-
* - `&ref->prop.field` - Access 'prop.field' on component with ref
|
|
26
|
-
* - `:Button[disabled=true]->label` - Access 'label' on Button with condition
|
|
27
|
-
* - `^parent->config` - Access 'config' on parent component
|
|
28
|
-
*
|
|
29
|
-
* **Optional component selector (?->)** - Safely access components that might not exist
|
|
30
|
-
* - `&ref?->value` - Returns null if component with ref doesn't exist
|
|
31
|
-
* - `:OptionalType?->property` - Returns null if component type not found
|
|
32
|
-
* - `^Parent?->config` - Returns null if parent doesn't match
|
|
33
|
-
*
|
|
34
|
-
* ## Component Selector Syntax
|
|
35
|
-
*
|
|
36
|
-
* Component selectors support modifiers and conditions:
|
|
37
|
-
* - `&ref` - Select by ref
|
|
38
|
-
* - `:ComponentType` - Select by component type
|
|
39
|
-
* - `^parent` - Select parent component
|
|
40
|
-
* - `[prop=value]` - Filter by property value
|
|
41
|
-
* - Multiple conditions: `:Button[disabled=true][type=submit]`
|
|
42
|
-
*
|
|
43
|
-
* ## Notation Disambiguation
|
|
44
|
-
*
|
|
45
|
-
* The choice between dot and bracket notation determines the access type:
|
|
46
|
-
* ```typescript
|
|
47
|
-
* 'data.0' // Object property named "0" (string key)
|
|
48
|
-
* 'data[0]' // Array element at index 0 (numeric index)
|
|
49
|
-
* 'columns.1' // Object property named "1"
|
|
50
|
-
* 'columns[1]' // Array element at index 1
|
|
51
|
-
* ```
|
|
52
|
-
*
|
|
53
|
-
* @example
|
|
54
|
-
* parseNodeSelector('users[0].name')
|
|
55
|
-
* // => { kind: 'property', head: 'users', tail: [{ key: 0, optional: false }, { key: 'name', optional: false }] }
|
|
56
|
-
*
|
|
57
|
-
* @example
|
|
58
|
-
* parseNodeSelector('config.0')
|
|
59
|
-
* // => { kind: 'property', head: 'config', tail: [{ key: '0', optional: false }] }
|
|
60
|
-
*
|
|
61
|
-
* @example
|
|
62
|
-
* parseNodeSelector('prop?.nested?.field')
|
|
63
|
-
* // => { kind: 'property', head: 'prop', tail: [{ key: 'nested', optional: true }, { key: 'field', optional: true }] }
|
|
64
|
-
*
|
|
65
|
-
* @example
|
|
66
|
-
* parseNodeSelector('$varName.field')
|
|
67
|
-
* // => { kind: 'variable', head: 'varName', tail: [{ key: 'field', optional: false }] }
|
|
68
|
-
*
|
|
69
|
-
* @example
|
|
70
|
-
* parseNodeSelector('&ref->prop.field')
|
|
71
|
-
* // => {
|
|
72
|
-
* // componentSelector: [{ qualifier: 'ref', modifier: '&', conditions: [] }],
|
|
73
|
-
* // kind: 'property',
|
|
74
|
-
* // head: 'prop',
|
|
75
|
-
* // tail: [{ key: 'field', optional: false }]
|
|
76
|
-
* // }
|
|
77
|
-
*
|
|
78
|
-
* @example
|
|
79
|
-
* parseNodeSelector(':Button[disabled=true]->label.text')
|
|
80
|
-
* // => {
|
|
81
|
-
* // componentSelector: [{ qualifier: 'Button', modifier: ':', conditions: [['disabled', 'true']] }],
|
|
82
|
-
* // kind: 'property',
|
|
83
|
-
* // head: 'label',
|
|
84
|
-
* // tail: [{ key: 'text', optional: false }]
|
|
85
|
-
* // }
|
|
86
|
-
*/
|
|
87
|
-
export declare function parseNodeSelector(path: string): NodeSelector;
|
package/lib/types/command.d.ts
DELETED
package/lib/types/index.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { ValueType } from '@kaskad/types';
|
|
2
|
-
import { AbstractNode, ArrayNode, CommandNode } from '../node/node';
|
|
3
|
-
export declare function isArrayNode(node: AbstractNode<ValueType>): node is ArrayNode;
|
|
4
|
-
export declare function isCommandNode(node: AbstractNode<ValueType>): node is CommandNode;
|
package/lib/types/schema.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { ComponentId } from '@kaskad/types';
|
|
2
|
-
import { CommandNode } from '../node/node';
|
|
3
|
-
export interface CommandNodeStructure {
|
|
4
|
-
runnerType: string;
|
|
5
|
-
owner: ComponentId;
|
|
6
|
-
target: string;
|
|
7
|
-
init?: string;
|
|
8
|
-
finalize?: string;
|
|
9
|
-
}
|
|
10
|
-
export interface NodeChangeHandler {
|
|
11
|
-
readonly selector: string;
|
|
12
|
-
readonly command: CommandNode;
|
|
13
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function formatSource(sourceUrl: string | null | undefined, path?: (string | number)[]): string;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { ValueType } from '@kaskad/types';
|
|
2
|
-
import { AbstractNode } from '../node/node';
|
|
3
|
-
import { PathSegment } from '../parsers';
|
|
4
|
-
/**
|
|
5
|
-
* Traverse a node using parsed path segments, respecting optional chaining.
|
|
6
|
-
*
|
|
7
|
-
* @param node - The starting node
|
|
8
|
-
* @param segments - Array of path segments to traverse
|
|
9
|
-
* @returns The found node, or null if not found and optional chaining was used
|
|
10
|
-
* @throws Error if a required segment is not found
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* const userNode = component.getNode('user');
|
|
14
|
-
* const nameNode = traverseNode(userNode, [
|
|
15
|
-
* { key: 'profile', optional: false },
|
|
16
|
-
* { key: 'name', optional: false }
|
|
17
|
-
* ]);
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* // With optional chaining - returns null instead of throwing
|
|
21
|
-
* const emailNode = traverseNode(userNode, [
|
|
22
|
-
* { key: 'contact', optional: true },
|
|
23
|
-
* { key: 'email', optional: false }
|
|
24
|
-
* ]);
|
|
25
|
-
*/
|
|
26
|
-
export declare function traverseNode(node: AbstractNode<ValueType>, segments: PathSegment[]): AbstractNode<ValueType> | null;
|