@constela/core 0.10.0 → 0.11.0
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/index.d.ts +243 -4
- package/dist/index.js +171 -7
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -16,6 +16,10 @@ declare const STORAGE_TYPES: readonly ["local", "session"];
|
|
|
16
16
|
type StorageType = (typeof STORAGE_TYPES)[number];
|
|
17
17
|
declare const CLIPBOARD_OPERATIONS: readonly ["write", "read"];
|
|
18
18
|
type ClipboardOperation = (typeof CLIPBOARD_OPERATIONS)[number];
|
|
19
|
+
declare const FOCUS_OPERATIONS: readonly ["focus", "blur", "select"];
|
|
20
|
+
type FocusOperation = (typeof FOCUS_OPERATIONS)[number];
|
|
21
|
+
declare const VALIDITY_PROPERTIES: readonly ["valid", "valueMissing", "typeMismatch", "patternMismatch", "tooLong", "tooShort", "rangeUnderflow", "rangeOverflow", "customError", "message"];
|
|
22
|
+
type ValidityProperty = (typeof VALIDITY_PROPERTIES)[number];
|
|
19
23
|
declare const NAVIGATE_TARGETS: readonly ["_self", "_blank"];
|
|
20
24
|
type NavigateTarget = (typeof NAVIGATE_TARGETS)[number];
|
|
21
25
|
declare const PARAM_TYPES: readonly ["string", "number", "boolean", "json"];
|
|
@@ -142,7 +146,15 @@ interface ConcatExpr {
|
|
|
142
146
|
expr: 'concat';
|
|
143
147
|
items: Expression[];
|
|
144
148
|
}
|
|
145
|
-
|
|
149
|
+
/**
|
|
150
|
+
* Validity expression - gets form element validation state
|
|
151
|
+
*/
|
|
152
|
+
interface ValidityExpr {
|
|
153
|
+
expr: 'validity';
|
|
154
|
+
ref: string;
|
|
155
|
+
property?: ValidityProperty;
|
|
156
|
+
}
|
|
157
|
+
type Expression = LitExpr | StateExpr | VarExpr | BinExpr | NotExpr | ParamExpr | CondExpr | GetExpr | RouteExpr | ImportExpr | DataExpr | RefExpr | IndexExpr | StyleExpr | ConcatExpr | ValidityExpr;
|
|
146
158
|
/**
|
|
147
159
|
* Number state field
|
|
148
160
|
*/
|
|
@@ -340,8 +352,51 @@ interface CloseStep {
|
|
|
340
352
|
do: 'close';
|
|
341
353
|
connection: string;
|
|
342
354
|
}
|
|
343
|
-
|
|
355
|
+
/**
|
|
356
|
+
* Delay step - executes steps after a delay (setTimeout equivalent)
|
|
357
|
+
*/
|
|
358
|
+
interface DelayStep {
|
|
359
|
+
do: 'delay';
|
|
360
|
+
ms: Expression;
|
|
361
|
+
then: ActionStep[];
|
|
362
|
+
result?: string;
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Interval step - executes an action repeatedly (setInterval equivalent)
|
|
366
|
+
*/
|
|
367
|
+
interface IntervalStep {
|
|
368
|
+
do: 'interval';
|
|
369
|
+
ms: Expression;
|
|
370
|
+
action: string;
|
|
371
|
+
result?: string;
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* ClearTimer step - clears a timer (clearTimeout/clearInterval equivalent)
|
|
375
|
+
*/
|
|
376
|
+
interface ClearTimerStep {
|
|
377
|
+
do: 'clearTimer';
|
|
378
|
+
target: Expression;
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* Focus step - manages form element focus
|
|
382
|
+
*/
|
|
383
|
+
interface FocusStep {
|
|
384
|
+
do: 'focus';
|
|
385
|
+
target: Expression;
|
|
386
|
+
operation: FocusOperation;
|
|
387
|
+
onSuccess?: ActionStep[];
|
|
388
|
+
onError?: ActionStep[];
|
|
389
|
+
}
|
|
390
|
+
type ActionStep = SetStep | UpdateStep | SetPathStep | FetchStep | StorageStep | ClipboardStep | NavigateStep | ImportStep | CallStep | SubscribeStep | DisposeStep | DomStep | SendStep | CloseStep | DelayStep | IntervalStep | ClearTimerStep | FocusStep;
|
|
344
391
|
type LocalActionStep = SetStep | UpdateStep | SetPathStep;
|
|
392
|
+
/**
|
|
393
|
+
* Event handler options for special events like intersect
|
|
394
|
+
*/
|
|
395
|
+
interface EventHandlerOptions {
|
|
396
|
+
threshold?: number;
|
|
397
|
+
rootMargin?: string;
|
|
398
|
+
once?: boolean;
|
|
399
|
+
}
|
|
345
400
|
/**
|
|
346
401
|
* Event handler - binds an event to an action
|
|
347
402
|
*/
|
|
@@ -349,6 +404,9 @@ interface EventHandler {
|
|
|
349
404
|
event: string;
|
|
350
405
|
action: string;
|
|
351
406
|
payload?: Expression;
|
|
407
|
+
debounce?: number;
|
|
408
|
+
throttle?: number;
|
|
409
|
+
options?: EventHandlerOptions;
|
|
352
410
|
}
|
|
353
411
|
/**
|
|
354
412
|
* Action definition - a named sequence of steps
|
|
@@ -434,7 +492,15 @@ interface CodeNode {
|
|
|
434
492
|
language: Expression;
|
|
435
493
|
content: Expression;
|
|
436
494
|
}
|
|
437
|
-
|
|
495
|
+
/**
|
|
496
|
+
* Portal node - renders children to a different DOM location
|
|
497
|
+
*/
|
|
498
|
+
interface PortalNode {
|
|
499
|
+
kind: 'portal';
|
|
500
|
+
target: 'body' | 'head' | string;
|
|
501
|
+
children: ViewNode[];
|
|
502
|
+
}
|
|
503
|
+
type ViewNode = ElementNode | TextNode | IfNode | EachNode | ComponentNode | SlotNode | MarkdownNode | CodeNode | PortalNode;
|
|
438
504
|
interface ComponentDef {
|
|
439
505
|
params?: Record<string, ParamDef>;
|
|
440
506
|
localState?: Record<string, StateField>;
|
|
@@ -633,6 +699,10 @@ declare function isStyleExpr(value: unknown): value is StyleExpr;
|
|
|
633
699
|
* Checks if value is a concat expression
|
|
634
700
|
*/
|
|
635
701
|
declare function isConcatExpr(value: unknown): value is ConcatExpr;
|
|
702
|
+
/**
|
|
703
|
+
* Checks if value is a validity expression
|
|
704
|
+
*/
|
|
705
|
+
declare function isValidityExpr(value: unknown): value is ValidityExpr;
|
|
636
706
|
/**
|
|
637
707
|
* Checks if value is a data source
|
|
638
708
|
*/
|
|
@@ -681,6 +751,10 @@ declare function isMarkdownNode(value: unknown): value is MarkdownNode;
|
|
|
681
751
|
* Checks if value is a code node
|
|
682
752
|
*/
|
|
683
753
|
declare function isCodeNode(value: unknown): value is CodeNode;
|
|
754
|
+
/**
|
|
755
|
+
* Checks if value is a portal node
|
|
756
|
+
*/
|
|
757
|
+
declare function isPortalNode(value: unknown): value is PortalNode;
|
|
684
758
|
/**
|
|
685
759
|
* Checks if value is any valid view node
|
|
686
760
|
*/
|
|
@@ -729,6 +803,10 @@ declare function isSubscribeStep(value: unknown): value is SubscribeStep;
|
|
|
729
803
|
* Checks if value is a dispose step
|
|
730
804
|
*/
|
|
731
805
|
declare function isDisposeStep(value: unknown): value is DisposeStep;
|
|
806
|
+
/**
|
|
807
|
+
* Checks if value is a focus step
|
|
808
|
+
*/
|
|
809
|
+
declare function isFocusStep(value: unknown): value is FocusStep;
|
|
732
810
|
/**
|
|
733
811
|
* Checks if value is any valid action step
|
|
734
812
|
*/
|
|
@@ -1109,6 +1187,8 @@ declare const astSchema: {
|
|
|
1109
1187
|
readonly $ref: "#/$defs/IndexExpr";
|
|
1110
1188
|
}, {
|
|
1111
1189
|
readonly $ref: "#/$defs/StyleExpr";
|
|
1190
|
+
}, {
|
|
1191
|
+
readonly $ref: "#/$defs/ValidityExpr";
|
|
1112
1192
|
}];
|
|
1113
1193
|
};
|
|
1114
1194
|
readonly LitExpr: {
|
|
@@ -1295,6 +1375,24 @@ declare const astSchema: {
|
|
|
1295
1375
|
};
|
|
1296
1376
|
};
|
|
1297
1377
|
};
|
|
1378
|
+
readonly ValidityExpr: {
|
|
1379
|
+
readonly type: "object";
|
|
1380
|
+
readonly required: readonly ["expr", "ref"];
|
|
1381
|
+
readonly additionalProperties: false;
|
|
1382
|
+
readonly properties: {
|
|
1383
|
+
readonly expr: {
|
|
1384
|
+
readonly type: "string";
|
|
1385
|
+
readonly const: "validity";
|
|
1386
|
+
};
|
|
1387
|
+
readonly ref: {
|
|
1388
|
+
readonly type: "string";
|
|
1389
|
+
};
|
|
1390
|
+
readonly property: {
|
|
1391
|
+
readonly type: "string";
|
|
1392
|
+
readonly enum: readonly ["valid", "valueMissing", "typeMismatch", "patternMismatch", "tooLong", "tooShort", "rangeUnderflow", "rangeOverflow", "customError", "message"];
|
|
1393
|
+
};
|
|
1394
|
+
};
|
|
1395
|
+
};
|
|
1298
1396
|
readonly StylePreset: {
|
|
1299
1397
|
readonly type: "object";
|
|
1300
1398
|
readonly required: readonly ["base"];
|
|
@@ -1428,6 +1526,14 @@ declare const astSchema: {
|
|
|
1428
1526
|
readonly $ref: "#/$defs/UpdateStep";
|
|
1429
1527
|
}, {
|
|
1430
1528
|
readonly $ref: "#/$defs/FetchStep";
|
|
1529
|
+
}, {
|
|
1530
|
+
readonly $ref: "#/$defs/DelayStep";
|
|
1531
|
+
}, {
|
|
1532
|
+
readonly $ref: "#/$defs/IntervalStep";
|
|
1533
|
+
}, {
|
|
1534
|
+
readonly $ref: "#/$defs/ClearTimerStep";
|
|
1535
|
+
}, {
|
|
1536
|
+
readonly $ref: "#/$defs/FocusStep";
|
|
1431
1537
|
}];
|
|
1432
1538
|
};
|
|
1433
1539
|
readonly SetStep: {
|
|
@@ -1510,6 +1616,93 @@ declare const astSchema: {
|
|
|
1510
1616
|
};
|
|
1511
1617
|
};
|
|
1512
1618
|
};
|
|
1619
|
+
readonly DelayStep: {
|
|
1620
|
+
readonly type: "object";
|
|
1621
|
+
readonly required: readonly ["do", "ms", "then"];
|
|
1622
|
+
readonly additionalProperties: false;
|
|
1623
|
+
readonly properties: {
|
|
1624
|
+
readonly do: {
|
|
1625
|
+
readonly type: "string";
|
|
1626
|
+
readonly const: "delay";
|
|
1627
|
+
};
|
|
1628
|
+
readonly ms: {
|
|
1629
|
+
readonly $ref: "#/$defs/Expression";
|
|
1630
|
+
};
|
|
1631
|
+
readonly then: {
|
|
1632
|
+
readonly type: "array";
|
|
1633
|
+
readonly items: {
|
|
1634
|
+
readonly $ref: "#/$defs/ActionStep";
|
|
1635
|
+
};
|
|
1636
|
+
};
|
|
1637
|
+
readonly result: {
|
|
1638
|
+
readonly type: "string";
|
|
1639
|
+
};
|
|
1640
|
+
};
|
|
1641
|
+
};
|
|
1642
|
+
readonly IntervalStep: {
|
|
1643
|
+
readonly type: "object";
|
|
1644
|
+
readonly required: readonly ["do", "ms", "action"];
|
|
1645
|
+
readonly additionalProperties: false;
|
|
1646
|
+
readonly properties: {
|
|
1647
|
+
readonly do: {
|
|
1648
|
+
readonly type: "string";
|
|
1649
|
+
readonly const: "interval";
|
|
1650
|
+
};
|
|
1651
|
+
readonly ms: {
|
|
1652
|
+
readonly $ref: "#/$defs/Expression";
|
|
1653
|
+
};
|
|
1654
|
+
readonly action: {
|
|
1655
|
+
readonly type: "string";
|
|
1656
|
+
};
|
|
1657
|
+
readonly result: {
|
|
1658
|
+
readonly type: "string";
|
|
1659
|
+
};
|
|
1660
|
+
};
|
|
1661
|
+
};
|
|
1662
|
+
readonly ClearTimerStep: {
|
|
1663
|
+
readonly type: "object";
|
|
1664
|
+
readonly required: readonly ["do", "target"];
|
|
1665
|
+
readonly additionalProperties: false;
|
|
1666
|
+
readonly properties: {
|
|
1667
|
+
readonly do: {
|
|
1668
|
+
readonly type: "string";
|
|
1669
|
+
readonly const: "clearTimer";
|
|
1670
|
+
};
|
|
1671
|
+
readonly target: {
|
|
1672
|
+
readonly $ref: "#/$defs/Expression";
|
|
1673
|
+
};
|
|
1674
|
+
};
|
|
1675
|
+
};
|
|
1676
|
+
readonly FocusStep: {
|
|
1677
|
+
readonly type: "object";
|
|
1678
|
+
readonly required: readonly ["do", "target", "operation"];
|
|
1679
|
+
readonly additionalProperties: false;
|
|
1680
|
+
readonly properties: {
|
|
1681
|
+
readonly do: {
|
|
1682
|
+
readonly type: "string";
|
|
1683
|
+
readonly const: "focus";
|
|
1684
|
+
};
|
|
1685
|
+
readonly target: {
|
|
1686
|
+
readonly $ref: "#/$defs/Expression";
|
|
1687
|
+
};
|
|
1688
|
+
readonly operation: {
|
|
1689
|
+
readonly type: "string";
|
|
1690
|
+
readonly enum: readonly ["focus", "blur", "select"];
|
|
1691
|
+
};
|
|
1692
|
+
readonly onSuccess: {
|
|
1693
|
+
readonly type: "array";
|
|
1694
|
+
readonly items: {
|
|
1695
|
+
readonly $ref: "#/$defs/ActionStep";
|
|
1696
|
+
};
|
|
1697
|
+
};
|
|
1698
|
+
readonly onError: {
|
|
1699
|
+
readonly type: "array";
|
|
1700
|
+
readonly items: {
|
|
1701
|
+
readonly $ref: "#/$defs/ActionStep";
|
|
1702
|
+
};
|
|
1703
|
+
};
|
|
1704
|
+
};
|
|
1705
|
+
};
|
|
1513
1706
|
readonly EventHandler: {
|
|
1514
1707
|
readonly type: "object";
|
|
1515
1708
|
readonly required: readonly ["event", "action"];
|
|
@@ -1524,6 +1717,30 @@ declare const astSchema: {
|
|
|
1524
1717
|
readonly payload: {
|
|
1525
1718
|
readonly $ref: "#/$defs/Expression";
|
|
1526
1719
|
};
|
|
1720
|
+
readonly debounce: {
|
|
1721
|
+
readonly type: "number";
|
|
1722
|
+
};
|
|
1723
|
+
readonly throttle: {
|
|
1724
|
+
readonly type: "number";
|
|
1725
|
+
};
|
|
1726
|
+
readonly options: {
|
|
1727
|
+
readonly $ref: "#/$defs/EventHandlerOptions";
|
|
1728
|
+
};
|
|
1729
|
+
};
|
|
1730
|
+
};
|
|
1731
|
+
readonly EventHandlerOptions: {
|
|
1732
|
+
readonly type: "object";
|
|
1733
|
+
readonly additionalProperties: false;
|
|
1734
|
+
readonly properties: {
|
|
1735
|
+
readonly threshold: {
|
|
1736
|
+
readonly type: "number";
|
|
1737
|
+
};
|
|
1738
|
+
readonly rootMargin: {
|
|
1739
|
+
readonly type: "string";
|
|
1740
|
+
};
|
|
1741
|
+
readonly once: {
|
|
1742
|
+
readonly type: "boolean";
|
|
1743
|
+
};
|
|
1527
1744
|
};
|
|
1528
1745
|
};
|
|
1529
1746
|
readonly ActionDefinition: {
|
|
@@ -1559,6 +1776,8 @@ declare const astSchema: {
|
|
|
1559
1776
|
readonly $ref: "#/$defs/MarkdownNode";
|
|
1560
1777
|
}, {
|
|
1561
1778
|
readonly $ref: "#/$defs/CodeNode";
|
|
1779
|
+
}, {
|
|
1780
|
+
readonly $ref: "#/$defs/PortalNode";
|
|
1562
1781
|
}];
|
|
1563
1782
|
};
|
|
1564
1783
|
readonly ElementNode: {
|
|
@@ -1719,6 +1938,26 @@ declare const astSchema: {
|
|
|
1719
1938
|
};
|
|
1720
1939
|
};
|
|
1721
1940
|
};
|
|
1941
|
+
readonly PortalNode: {
|
|
1942
|
+
readonly type: "object";
|
|
1943
|
+
readonly required: readonly ["kind", "target", "children"];
|
|
1944
|
+
readonly additionalProperties: false;
|
|
1945
|
+
readonly properties: {
|
|
1946
|
+
readonly kind: {
|
|
1947
|
+
readonly type: "string";
|
|
1948
|
+
readonly const: "portal";
|
|
1949
|
+
};
|
|
1950
|
+
readonly target: {
|
|
1951
|
+
readonly type: "string";
|
|
1952
|
+
};
|
|
1953
|
+
readonly children: {
|
|
1954
|
+
readonly type: "array";
|
|
1955
|
+
readonly items: {
|
|
1956
|
+
readonly $ref: "#/$defs/ViewNode";
|
|
1957
|
+
};
|
|
1958
|
+
};
|
|
1959
|
+
};
|
|
1960
|
+
};
|
|
1722
1961
|
readonly ParamDef: {
|
|
1723
1962
|
readonly type: "object";
|
|
1724
1963
|
readonly required: readonly ["type"];
|
|
@@ -1752,4 +1991,4 @@ declare const astSchema: {
|
|
|
1752
1991
|
};
|
|
1753
1992
|
};
|
|
1754
1993
|
|
|
1755
|
-
export { type ActionDefinition, type ActionStep, BINARY_OPERATORS, type BinExpr, type BinaryOperator, type BooleanField, CLIPBOARD_OPERATIONS, type CallStep, type ClipboardOperation, type ClipboardStep, type CloseStep, type CodeNode, type ComponentDef, type ComponentNode, type ComponentsRef, type CompoundVariant, type ConcatExpr, type CondExpr, type ConstelaAst, ConstelaError, type ConstelaProgram, DATA_SOURCE_TYPES, DATA_TRANSFORMS, type DataExpr, type DataSource, type DataSourceType, type DataTransform, type DisposeStep, type DomStep, type EachNode, type ElementNode, type ErrorCode, type ErrorOptions, type EventHandler, type Expression, type FetchStep, type GetExpr, HTTP_METHODS, type HttpMethod, type IfNode, type ImportExpr, type ImportStep, type LayoutProgram, type LifecycleHooks, type ListField, type LitExpr, type LocalActionDefinition, type LocalActionStep, type MarkdownNode, NAVIGATE_TARGETS, type NavigateStep, type NavigateTarget, type NotExpr, type NumberField, type ObjectField, PARAM_TYPES, type ParamDef, type ParamExpr, type ParamType, type Program, type RefExpr, type RouteDefinition, type RouteExpr, STORAGE_OPERATIONS, STORAGE_TYPES, type SendStep, type SetPathStep, type SetStep, type SlotNode, type StateExpr, type StateField, type StaticPathsDefinition, type StorageOperation, type StorageStep, type StorageType, type StringField, type StyleExpr, type StylePreset, type SubscribeStep, type TextNode, UPDATE_OPERATIONS, type UpdateOperation, type UpdateStep, type ValidationFailure, type ValidationResult, type ValidationSuccess, type VarExpr, type ViewNode, astSchema, createClipboardWriteMissingValueError, createComponentCycleError, createComponentNotFoundError, createComponentPropMissingError, createComponentPropTypeError, createCondElseRequiredError, createDataNotDefinedError, createDuplicateActionError, createDuplicateDefaultSlotError, createDuplicateSlotNameError, createImportsNotDefinedError, createInvalidClipboardOperationError, createInvalidDataSourceError, createInvalidNavigateTargetError, createInvalidSlotNameError, createInvalidStorageOperationError, createInvalidStorageTypeError, createLayoutMissingSlotError, createLayoutNotFoundError, createLocalActionInvalidStepError, createOperationInvalidForTypeError, createOperationMissingFieldError, createOperationUnknownError, createRouteNotDefinedError, createSchemaError, createSlotInLoopError, createStorageSetMissingValueError, createUndefinedActionError, createUndefinedDataError, createUndefinedDataSourceError, createUndefinedImportError, createUndefinedLocalStateError, createUndefinedParamError, createUndefinedRefError, createUndefinedRouteParamError, createUndefinedStateError, createUndefinedStyleError, createUndefinedVarError, createUndefinedVariantError, createUnsupportedVersionError, findSimilarNames, isActionStep, isBinExpr, isBooleanField, isCallStep, isClipboardStep, isCodeNode, isComponentNode, isConcatExpr, isCondExpr, isConstelaError, isDataExpr, isDataSource, isDisposeStep, isEachNode, isElementNode, isEventHandler, isExpression, isFetchStep, isGetExpr, isIfNode, isImportExpr, isImportStep, isLayoutProgram, isLifecycleHooks, isListField, isLitExpr, isLocalActionDefinition, isLocalActionStep, isMarkdownNode, isNamedSlotNode, isNavigateStep, isNotExpr, isNumberField, isObjectField, isParamExpr, isRefExpr, isRouteDefinition, isRouteExpr, isSetPathStep, isSetStep, isSlotNode, isStateExpr, isStateField, isStaticPathsDefinition, isStorageStep, isStringField, isStyleExpr, isSubscribeStep, isTextNode, isUpdateStep, isVarExpr, isViewNode, validateAst };
|
|
1994
|
+
export { type ActionDefinition, type ActionStep, BINARY_OPERATORS, type BinExpr, type BinaryOperator, type BooleanField, CLIPBOARD_OPERATIONS, type CallStep, type ClearTimerStep, type ClipboardOperation, type ClipboardStep, type CloseStep, type CodeNode, type ComponentDef, type ComponentNode, type ComponentsRef, type CompoundVariant, type ConcatExpr, type CondExpr, type ConstelaAst, ConstelaError, type ConstelaProgram, DATA_SOURCE_TYPES, DATA_TRANSFORMS, type DataExpr, type DataSource, type DataSourceType, type DataTransform, type DelayStep, type DisposeStep, type DomStep, type EachNode, type ElementNode, type ErrorCode, type ErrorOptions, type EventHandler, type EventHandlerOptions, type Expression, FOCUS_OPERATIONS, type FetchStep, type FocusOperation, type FocusStep, type GetExpr, HTTP_METHODS, type HttpMethod, type IfNode, type ImportExpr, type ImportStep, type IntervalStep, type LayoutProgram, type LifecycleHooks, type ListField, type LitExpr, type LocalActionDefinition, type LocalActionStep, type MarkdownNode, NAVIGATE_TARGETS, type NavigateStep, type NavigateTarget, type NotExpr, type NumberField, type ObjectField, PARAM_TYPES, type ParamDef, type ParamExpr, type ParamType, type PortalNode, type Program, type RefExpr, type RouteDefinition, type RouteExpr, STORAGE_OPERATIONS, STORAGE_TYPES, type SendStep, type SetPathStep, type SetStep, type SlotNode, type StateExpr, type StateField, type StaticPathsDefinition, type StorageOperation, type StorageStep, type StorageType, type StringField, type StyleExpr, type StylePreset, type SubscribeStep, type TextNode, UPDATE_OPERATIONS, type UpdateOperation, type UpdateStep, VALIDITY_PROPERTIES, type ValidationFailure, type ValidationResult, type ValidationSuccess, type ValidityExpr, type ValidityProperty, type VarExpr, type ViewNode, astSchema, createClipboardWriteMissingValueError, createComponentCycleError, createComponentNotFoundError, createComponentPropMissingError, createComponentPropTypeError, createCondElseRequiredError, createDataNotDefinedError, createDuplicateActionError, createDuplicateDefaultSlotError, createDuplicateSlotNameError, createImportsNotDefinedError, createInvalidClipboardOperationError, createInvalidDataSourceError, createInvalidNavigateTargetError, createInvalidSlotNameError, createInvalidStorageOperationError, createInvalidStorageTypeError, createLayoutMissingSlotError, createLayoutNotFoundError, createLocalActionInvalidStepError, createOperationInvalidForTypeError, createOperationMissingFieldError, createOperationUnknownError, createRouteNotDefinedError, createSchemaError, createSlotInLoopError, createStorageSetMissingValueError, createUndefinedActionError, createUndefinedDataError, createUndefinedDataSourceError, createUndefinedImportError, createUndefinedLocalStateError, createUndefinedParamError, createUndefinedRefError, createUndefinedRouteParamError, createUndefinedStateError, createUndefinedStyleError, createUndefinedVarError, createUndefinedVariantError, createUnsupportedVersionError, findSimilarNames, isActionStep, isBinExpr, isBooleanField, isCallStep, isClipboardStep, isCodeNode, isComponentNode, isConcatExpr, isCondExpr, isConstelaError, isDataExpr, isDataSource, isDisposeStep, isEachNode, isElementNode, isEventHandler, isExpression, isFetchStep, isFocusStep, isGetExpr, isIfNode, isImportExpr, isImportStep, isLayoutProgram, isLifecycleHooks, isListField, isLitExpr, isLocalActionDefinition, isLocalActionStep, isMarkdownNode, isNamedSlotNode, isNavigateStep, isNotExpr, isNumberField, isObjectField, isParamExpr, isPortalNode, isRefExpr, isRouteDefinition, isRouteExpr, isSetPathStep, isSetStep, isSlotNode, isStateExpr, isStateField, isStaticPathsDefinition, isStorageStep, isStringField, isStyleExpr, isSubscribeStep, isTextNode, isUpdateStep, isValidityExpr, isVarExpr, isViewNode, validateAst };
|
package/dist/index.js
CHANGED
|
@@ -29,6 +29,19 @@ var HTTP_METHODS = ["GET", "POST", "PUT", "DELETE"];
|
|
|
29
29
|
var STORAGE_OPERATIONS = ["get", "set", "remove"];
|
|
30
30
|
var STORAGE_TYPES = ["local", "session"];
|
|
31
31
|
var CLIPBOARD_OPERATIONS = ["write", "read"];
|
|
32
|
+
var FOCUS_OPERATIONS = ["focus", "blur", "select"];
|
|
33
|
+
var VALIDITY_PROPERTIES = [
|
|
34
|
+
"valid",
|
|
35
|
+
"valueMissing",
|
|
36
|
+
"typeMismatch",
|
|
37
|
+
"patternMismatch",
|
|
38
|
+
"tooLong",
|
|
39
|
+
"tooShort",
|
|
40
|
+
"rangeUnderflow",
|
|
41
|
+
"rangeOverflow",
|
|
42
|
+
"customError",
|
|
43
|
+
"message"
|
|
44
|
+
];
|
|
32
45
|
var NAVIGATE_TARGETS = ["_self", "_blank"];
|
|
33
46
|
var PARAM_TYPES = ["string", "number", "boolean", "json"];
|
|
34
47
|
var DATA_TRANSFORMS = ["mdx", "yaml", "csv"];
|
|
@@ -142,6 +155,17 @@ function isStyleExpr(value) {
|
|
|
142
155
|
function isConcatExpr(value) {
|
|
143
156
|
return typeof value === "object" && value !== null && value.expr === "concat" && Array.isArray(value.items);
|
|
144
157
|
}
|
|
158
|
+
function isValidityExpr(value) {
|
|
159
|
+
if (!isObject(value)) return false;
|
|
160
|
+
if (value["expr"] !== "validity") return false;
|
|
161
|
+
if (typeof value["ref"] !== "string") return false;
|
|
162
|
+
if ("property" in value && value["property"] !== void 0) {
|
|
163
|
+
if (!VALIDITY_PROPERTIES.includes(value["property"])) {
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
return true;
|
|
168
|
+
}
|
|
145
169
|
function isDataSource(value) {
|
|
146
170
|
if (!isObject(value)) return false;
|
|
147
171
|
const type = value["type"];
|
|
@@ -178,7 +202,7 @@ function isRouteDefinition(value) {
|
|
|
178
202
|
return true;
|
|
179
203
|
}
|
|
180
204
|
function isExpression(value) {
|
|
181
|
-
return isLitExpr(value) || isStateExpr(value) || isVarExpr(value) || isBinExpr(value) || isNotExpr(value) || isParamExpr(value) || isCondExpr(value) || isGetExpr(value) || isRouteExpr(value) || isImportExpr(value) || isDataExpr(value) || isRefExpr(value) || isIndexExpr(value) || isStyleExpr(value) || isConcatExpr(value);
|
|
205
|
+
return isLitExpr(value) || isStateExpr(value) || isVarExpr(value) || isBinExpr(value) || isNotExpr(value) || isParamExpr(value) || isCondExpr(value) || isGetExpr(value) || isRouteExpr(value) || isImportExpr(value) || isDataExpr(value) || isRefExpr(value) || isIndexExpr(value) || isStyleExpr(value) || isConcatExpr(value) || isValidityExpr(value);
|
|
182
206
|
}
|
|
183
207
|
function isElementNode(value) {
|
|
184
208
|
if (!isObject(value)) return false;
|
|
@@ -233,8 +257,15 @@ function isCodeNode(value) {
|
|
|
233
257
|
if (!("content" in value) || !isObject(value["content"])) return false;
|
|
234
258
|
return true;
|
|
235
259
|
}
|
|
260
|
+
function isPortalNode(value) {
|
|
261
|
+
if (!isObject(value)) return false;
|
|
262
|
+
if (value["kind"] !== "portal") return false;
|
|
263
|
+
if (typeof value["target"] !== "string") return false;
|
|
264
|
+
if (!Array.isArray(value["children"])) return false;
|
|
265
|
+
return true;
|
|
266
|
+
}
|
|
236
267
|
function isViewNode(value) {
|
|
237
|
-
return isElementNode(value) || isTextNode(value) || isIfNode(value) || isEachNode(value) || isComponentNode(value) || isSlotNode(value) || isMarkdownNode(value) || isCodeNode(value);
|
|
268
|
+
return isElementNode(value) || isTextNode(value) || isIfNode(value) || isEachNode(value) || isComponentNode(value) || isSlotNode(value) || isMarkdownNode(value) || isCodeNode(value) || isPortalNode(value);
|
|
238
269
|
}
|
|
239
270
|
function isSetStep(value) {
|
|
240
271
|
if (!isObject(value)) return false;
|
|
@@ -329,8 +360,37 @@ function isDisposeStep(value) {
|
|
|
329
360
|
if (!isObject(value["target"])) return false;
|
|
330
361
|
return true;
|
|
331
362
|
}
|
|
363
|
+
function isDelayStep(value) {
|
|
364
|
+
if (!isObject(value)) return false;
|
|
365
|
+
if (value["do"] !== "delay") return false;
|
|
366
|
+
if (!isObject(value["ms"])) return false;
|
|
367
|
+
if (!Array.isArray(value["then"])) return false;
|
|
368
|
+
return true;
|
|
369
|
+
}
|
|
370
|
+
function isIntervalStep(value) {
|
|
371
|
+
if (!isObject(value)) return false;
|
|
372
|
+
if (value["do"] !== "interval") return false;
|
|
373
|
+
if (!isObject(value["ms"])) return false;
|
|
374
|
+
if (typeof value["action"] !== "string") return false;
|
|
375
|
+
return true;
|
|
376
|
+
}
|
|
377
|
+
function isClearTimerStep(value) {
|
|
378
|
+
if (!isObject(value)) return false;
|
|
379
|
+
if (value["do"] !== "clearTimer") return false;
|
|
380
|
+
if (!isObject(value["target"])) return false;
|
|
381
|
+
return true;
|
|
382
|
+
}
|
|
383
|
+
function isFocusStep(value) {
|
|
384
|
+
if (!isObject(value)) return false;
|
|
385
|
+
if (value["do"] !== "focus") return false;
|
|
386
|
+
if (!isObject(value["target"])) return false;
|
|
387
|
+
if (!FOCUS_OPERATIONS.includes(value["operation"])) {
|
|
388
|
+
return false;
|
|
389
|
+
}
|
|
390
|
+
return true;
|
|
391
|
+
}
|
|
332
392
|
function isActionStep(value) {
|
|
333
|
-
return isSetStep(value) || isUpdateStep(value) || isSetPathStep(value) || isFetchStep(value) || isStorageStep(value) || isClipboardStep(value) || isNavigateStep(value) || isImportStep(value) || isCallStep(value) || isSubscribeStep(value) || isDisposeStep(value);
|
|
393
|
+
return isSetStep(value) || isUpdateStep(value) || isSetPathStep(value) || isFetchStep(value) || isStorageStep(value) || isClipboardStep(value) || isNavigateStep(value) || isImportStep(value) || isCallStep(value) || isSubscribeStep(value) || isDisposeStep(value) || isDelayStep(value) || isIntervalStep(value) || isClearTimerStep(value) || isFocusStep(value);
|
|
334
394
|
}
|
|
335
395
|
function isLocalActionStep(value) {
|
|
336
396
|
return isSetStep(value) || isUpdateStep(value) || isSetPathStep(value);
|
|
@@ -1459,7 +1519,8 @@ var astSchema = {
|
|
|
1459
1519
|
{ $ref: "#/$defs/CondExpr" },
|
|
1460
1520
|
{ $ref: "#/$defs/GetExpr" },
|
|
1461
1521
|
{ $ref: "#/$defs/IndexExpr" },
|
|
1462
|
-
{ $ref: "#/$defs/StyleExpr" }
|
|
1522
|
+
{ $ref: "#/$defs/StyleExpr" },
|
|
1523
|
+
{ $ref: "#/$defs/ValidityExpr" }
|
|
1463
1524
|
]
|
|
1464
1525
|
},
|
|
1465
1526
|
LitExpr: {
|
|
@@ -1576,6 +1637,19 @@ var astSchema = {
|
|
|
1576
1637
|
}
|
|
1577
1638
|
}
|
|
1578
1639
|
},
|
|
1640
|
+
ValidityExpr: {
|
|
1641
|
+
type: "object",
|
|
1642
|
+
required: ["expr", "ref"],
|
|
1643
|
+
additionalProperties: false,
|
|
1644
|
+
properties: {
|
|
1645
|
+
expr: { type: "string", const: "validity" },
|
|
1646
|
+
ref: { type: "string" },
|
|
1647
|
+
property: {
|
|
1648
|
+
type: "string",
|
|
1649
|
+
enum: ["valid", "valueMissing", "typeMismatch", "patternMismatch", "tooLong", "tooShort", "rangeUnderflow", "rangeOverflow", "customError", "message"]
|
|
1650
|
+
}
|
|
1651
|
+
}
|
|
1652
|
+
},
|
|
1579
1653
|
// ==================== Style Presets ====================
|
|
1580
1654
|
StylePreset: {
|
|
1581
1655
|
type: "object",
|
|
@@ -1668,7 +1742,11 @@ var astSchema = {
|
|
|
1668
1742
|
oneOf: [
|
|
1669
1743
|
{ $ref: "#/$defs/SetStep" },
|
|
1670
1744
|
{ $ref: "#/$defs/UpdateStep" },
|
|
1671
|
-
{ $ref: "#/$defs/FetchStep" }
|
|
1745
|
+
{ $ref: "#/$defs/FetchStep" },
|
|
1746
|
+
{ $ref: "#/$defs/DelayStep" },
|
|
1747
|
+
{ $ref: "#/$defs/IntervalStep" },
|
|
1748
|
+
{ $ref: "#/$defs/ClearTimerStep" },
|
|
1749
|
+
{ $ref: "#/$defs/FocusStep" }
|
|
1672
1750
|
]
|
|
1673
1751
|
},
|
|
1674
1752
|
SetStep: {
|
|
@@ -1720,6 +1798,61 @@ var astSchema = {
|
|
|
1720
1798
|
}
|
|
1721
1799
|
}
|
|
1722
1800
|
},
|
|
1801
|
+
DelayStep: {
|
|
1802
|
+
type: "object",
|
|
1803
|
+
required: ["do", "ms", "then"],
|
|
1804
|
+
additionalProperties: false,
|
|
1805
|
+
properties: {
|
|
1806
|
+
do: { type: "string", const: "delay" },
|
|
1807
|
+
ms: { $ref: "#/$defs/Expression" },
|
|
1808
|
+
then: {
|
|
1809
|
+
type: "array",
|
|
1810
|
+
items: { $ref: "#/$defs/ActionStep" }
|
|
1811
|
+
},
|
|
1812
|
+
result: { type: "string" }
|
|
1813
|
+
}
|
|
1814
|
+
},
|
|
1815
|
+
IntervalStep: {
|
|
1816
|
+
type: "object",
|
|
1817
|
+
required: ["do", "ms", "action"],
|
|
1818
|
+
additionalProperties: false,
|
|
1819
|
+
properties: {
|
|
1820
|
+
do: { type: "string", const: "interval" },
|
|
1821
|
+
ms: { $ref: "#/$defs/Expression" },
|
|
1822
|
+
action: { type: "string" },
|
|
1823
|
+
result: { type: "string" }
|
|
1824
|
+
}
|
|
1825
|
+
},
|
|
1826
|
+
ClearTimerStep: {
|
|
1827
|
+
type: "object",
|
|
1828
|
+
required: ["do", "target"],
|
|
1829
|
+
additionalProperties: false,
|
|
1830
|
+
properties: {
|
|
1831
|
+
do: { type: "string", const: "clearTimer" },
|
|
1832
|
+
target: { $ref: "#/$defs/Expression" }
|
|
1833
|
+
}
|
|
1834
|
+
},
|
|
1835
|
+
FocusStep: {
|
|
1836
|
+
type: "object",
|
|
1837
|
+
required: ["do", "target", "operation"],
|
|
1838
|
+
additionalProperties: false,
|
|
1839
|
+
properties: {
|
|
1840
|
+
do: { type: "string", const: "focus" },
|
|
1841
|
+
target: { $ref: "#/$defs/Expression" },
|
|
1842
|
+
operation: {
|
|
1843
|
+
type: "string",
|
|
1844
|
+
enum: ["focus", "blur", "select"]
|
|
1845
|
+
},
|
|
1846
|
+
onSuccess: {
|
|
1847
|
+
type: "array",
|
|
1848
|
+
items: { $ref: "#/$defs/ActionStep" }
|
|
1849
|
+
},
|
|
1850
|
+
onError: {
|
|
1851
|
+
type: "array",
|
|
1852
|
+
items: { $ref: "#/$defs/ActionStep" }
|
|
1853
|
+
}
|
|
1854
|
+
}
|
|
1855
|
+
},
|
|
1723
1856
|
// ==================== Event Handler ====================
|
|
1724
1857
|
EventHandler: {
|
|
1725
1858
|
type: "object",
|
|
@@ -1728,7 +1861,19 @@ var astSchema = {
|
|
|
1728
1861
|
properties: {
|
|
1729
1862
|
event: { type: "string" },
|
|
1730
1863
|
action: { type: "string" },
|
|
1731
|
-
payload: { $ref: "#/$defs/Expression" }
|
|
1864
|
+
payload: { $ref: "#/$defs/Expression" },
|
|
1865
|
+
debounce: { type: "number" },
|
|
1866
|
+
throttle: { type: "number" },
|
|
1867
|
+
options: { $ref: "#/$defs/EventHandlerOptions" }
|
|
1868
|
+
}
|
|
1869
|
+
},
|
|
1870
|
+
EventHandlerOptions: {
|
|
1871
|
+
type: "object",
|
|
1872
|
+
additionalProperties: false,
|
|
1873
|
+
properties: {
|
|
1874
|
+
threshold: { type: "number" },
|
|
1875
|
+
rootMargin: { type: "string" },
|
|
1876
|
+
once: { type: "boolean" }
|
|
1732
1877
|
}
|
|
1733
1878
|
},
|
|
1734
1879
|
// ==================== Action Definition ====================
|
|
@@ -1754,7 +1899,8 @@ var astSchema = {
|
|
|
1754
1899
|
{ $ref: "#/$defs/ComponentNode" },
|
|
1755
1900
|
{ $ref: "#/$defs/SlotNode" },
|
|
1756
1901
|
{ $ref: "#/$defs/MarkdownNode" },
|
|
1757
|
-
{ $ref: "#/$defs/CodeNode" }
|
|
1902
|
+
{ $ref: "#/$defs/CodeNode" },
|
|
1903
|
+
{ $ref: "#/$defs/PortalNode" }
|
|
1758
1904
|
]
|
|
1759
1905
|
},
|
|
1760
1906
|
ElementNode: {
|
|
@@ -1856,6 +2002,19 @@ var astSchema = {
|
|
|
1856
2002
|
content: { $ref: "#/$defs/Expression" }
|
|
1857
2003
|
}
|
|
1858
2004
|
},
|
|
2005
|
+
PortalNode: {
|
|
2006
|
+
type: "object",
|
|
2007
|
+
required: ["kind", "target", "children"],
|
|
2008
|
+
additionalProperties: false,
|
|
2009
|
+
properties: {
|
|
2010
|
+
kind: { type: "string", const: "portal" },
|
|
2011
|
+
target: { type: "string" },
|
|
2012
|
+
children: {
|
|
2013
|
+
type: "array",
|
|
2014
|
+
items: { $ref: "#/$defs/ViewNode" }
|
|
2015
|
+
}
|
|
2016
|
+
}
|
|
2017
|
+
},
|
|
1859
2018
|
// ==================== Component Definition ====================
|
|
1860
2019
|
ParamDef: {
|
|
1861
2020
|
type: "object",
|
|
@@ -1889,12 +2048,14 @@ export {
|
|
|
1889
2048
|
ConstelaError,
|
|
1890
2049
|
DATA_SOURCE_TYPES,
|
|
1891
2050
|
DATA_TRANSFORMS,
|
|
2051
|
+
FOCUS_OPERATIONS,
|
|
1892
2052
|
HTTP_METHODS,
|
|
1893
2053
|
NAVIGATE_TARGETS,
|
|
1894
2054
|
PARAM_TYPES,
|
|
1895
2055
|
STORAGE_OPERATIONS,
|
|
1896
2056
|
STORAGE_TYPES,
|
|
1897
2057
|
UPDATE_OPERATIONS,
|
|
2058
|
+
VALIDITY_PROPERTIES,
|
|
1898
2059
|
astSchema,
|
|
1899
2060
|
createClipboardWriteMissingValueError,
|
|
1900
2061
|
createComponentCycleError,
|
|
@@ -1955,6 +2116,7 @@ export {
|
|
|
1955
2116
|
isEventHandler,
|
|
1956
2117
|
isExpression,
|
|
1957
2118
|
isFetchStep,
|
|
2119
|
+
isFocusStep,
|
|
1958
2120
|
isGetExpr,
|
|
1959
2121
|
isIfNode,
|
|
1960
2122
|
isImportExpr,
|
|
@@ -1972,6 +2134,7 @@ export {
|
|
|
1972
2134
|
isNumberField,
|
|
1973
2135
|
isObjectField,
|
|
1974
2136
|
isParamExpr,
|
|
2137
|
+
isPortalNode,
|
|
1975
2138
|
isRefExpr,
|
|
1976
2139
|
isRouteDefinition,
|
|
1977
2140
|
isRouteExpr,
|
|
@@ -1987,6 +2150,7 @@ export {
|
|
|
1987
2150
|
isSubscribeStep,
|
|
1988
2151
|
isTextNode,
|
|
1989
2152
|
isUpdateStep,
|
|
2153
|
+
isValidityExpr,
|
|
1990
2154
|
isVarExpr,
|
|
1991
2155
|
isViewNode,
|
|
1992
2156
|
validateAst
|