@rugal.tu/vuemodel3 1.3.7 → 1.4.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/VueModel.esm.js +165 -132
- package/dist/VueModel.umd.js +165 -132
- package/package.json +1 -1
- package/src/VueModel.d.ts +55 -22
- package/src/VueModel.ts +226 -167
- package/src/esm/VueModel.js +165 -132
- package/src/esm/VueModel.js.map +1 -1
- package/src/umd/VueModel.js +165 -132
- package/src/umd/VueModel.js.map +1 -1
package/src/VueModel.ts
CHANGED
|
@@ -1199,7 +1199,7 @@ export class ApiStore extends FuncBase {
|
|
|
1199
1199
|
FindStore[Key] = [];
|
|
1200
1200
|
IsGoNext = true;
|
|
1201
1201
|
}
|
|
1202
|
-
else if (typeof Value == 'object') {
|
|
1202
|
+
else if (Value != null && typeof Value == 'object') {
|
|
1203
1203
|
if (FindStore[Key] == null || typeof FindStore[Key] != 'object')
|
|
1204
1204
|
FindStore[Key] = {};
|
|
1205
1205
|
IsGoNext = true;
|
|
@@ -1491,34 +1491,57 @@ type CommandOption = {
|
|
|
1491
1491
|
};
|
|
1492
1492
|
|
|
1493
1493
|
type TreeSetType = {
|
|
1494
|
-
'v-text'?: '' | PathType | Function | TreeSetOption,
|
|
1495
|
-
'v-model'?: '' | PathType,
|
|
1496
|
-
'v-for'?: '' | PathType | Function | TreeSetOption,
|
|
1497
|
-
'v-if'?: '' | PathType | Function | TreeSetOption,
|
|
1498
|
-
'v-else'?: '' | null,
|
|
1499
|
-
'v-else-if'?: '' | PathType | Function | TreeSetOption,
|
|
1500
|
-
'v-show'?: '' | PathType | Function | TreeSetOption,
|
|
1501
|
-
'v-bind'?: '' | PathType | Function | TreeSetOption,
|
|
1502
|
-
'v-on:change'?: '' | PathType | Function | TreeSetOption,
|
|
1503
|
-
'v-on:click'?: '' | PathType | Function | TreeSetOption,
|
|
1504
|
-
'v-on-mounted'?: '' | PathType | Function | TreeSetOption,
|
|
1505
|
-
'v-on-unmounted'?: '' | PathType | Function | TreeSetOption,
|
|
1506
|
-
|
|
1507
1494
|
'watch'?: '' | WatchCallback,
|
|
1508
1495
|
'using'?: '' | UsingFunctionType,
|
|
1509
|
-
|
|
1510
|
-
[VModelCmd: `v-model:${string}`]: '' | PathType | TreeSetOption,
|
|
1511
|
-
[VForCmd: `v-for(${string})`]: '' | PathType | Function | TreeSetOption,
|
|
1512
|
-
[VBindCmd: `v-bind:${string}`]: '' | PathType | Function | TreeSetOption,
|
|
1513
|
-
[VOnCmd: `v-on:${string}`]: '' | PathType | Function | TreeSetOption,
|
|
1514
|
-
[VOnParamCmd: `v-on:${string}(${string})`]: '' | PathType | Function | TreeSetOption,
|
|
1515
|
-
[VSlotCmd: `v-slot:${string}`]: '' | string,
|
|
1516
|
-
[VOnMountedCmd: `v-on-mounted(${string})`]: '' | PathType | Function | TreeSetOption,
|
|
1517
|
-
[VOnUnMountedCmd: `v-on-unmounted(${string})`]: '' | PathType | Function | TreeSetOption,
|
|
1518
1496
|
[FuncCmd: `func:${string}`]: '' | Function,
|
|
1519
1497
|
[DomName: `:${string}`]: '' | UsingFunctionType | TreeSetType,
|
|
1498
|
+
|
|
1499
|
+
'v-model'?: '' | PathType,
|
|
1500
|
+
[VModelCmd: `v-model:${string}`]: '' | PathType,
|
|
1501
|
+
|
|
1502
|
+
'v-slot'?: '' | PathType | Function | TreeSetFuncOption,
|
|
1503
|
+
[VSlotArgsCmd: `v-slot(${string})`]: Function | TreeSetFuncOption,
|
|
1504
|
+
[VSlotKeyCmd: `v-slot:${string}`]: '' | PathType | Function | TreeSetFuncOption,
|
|
1505
|
+
[VSlotKeyArgsCmd: `v-slot:${string}(${string})`]: Function | TreeSetFuncOption,
|
|
1506
|
+
|
|
1507
|
+
'v-text'?: '' | PathType | Function | TreeSetFuncOption,
|
|
1508
|
+
[VForTextCmd: `v-text(${string})`]: Function | TreeSetFuncOption,
|
|
1509
|
+
|
|
1510
|
+
'v-for'?: '' | PathType | Function | TreeSetFuncOption,
|
|
1511
|
+
[VForKeyCmd: `v-for<${string}>`]: PathType | Function | TreeSetFuncOption,
|
|
1512
|
+
[VForKeyArgsCmd: `v-for<${string}>(${string})`]: Function | TreeSetFuncOption,
|
|
1513
|
+
[VForArgsCmd: `v-for(${string})`]: Function | TreeSetFuncOption,
|
|
1514
|
+
[VForArgsKeyCmd: `v-for(${string})<${string}>`]: Function | TreeSetFuncOption,
|
|
1515
|
+
|
|
1516
|
+
'v-show'?: '' | PathType | Function | TreeSetFuncOption,
|
|
1517
|
+
[VShowArgsCmd: `v-show(${string})`]: Function | TreeSetFuncOption,
|
|
1518
|
+
|
|
1519
|
+
'v-if'?: '' | PathType | Function | TreeSetFuncOption,
|
|
1520
|
+
'v-else-if'?: '' | PathType | Function | TreeSetFuncOption,
|
|
1521
|
+
'v-else'?: '' | null,
|
|
1522
|
+
[VIfArgsCmd: `v-if(${string})`]: Function | TreeSetFuncOption,
|
|
1523
|
+
[VElseIfArgsCmd: `v-else-if(${string})`]: Function | TreeSetFuncOption,
|
|
1524
|
+
|
|
1525
|
+
'v-bind'?: '' | PathType | Function | TreeSetFuncOption,
|
|
1526
|
+
[VBindCmd: `v-bind:${string}`]: '' | PathType | Function | TreeSetFuncOption,
|
|
1527
|
+
[VBindArgsCmd: `v-bind:${string}(${string})`]: Function | TreeSetFuncOption,
|
|
1528
|
+
|
|
1529
|
+
'v-on:change'?: '' | PathType | Function | TreeSetFuncOption,
|
|
1530
|
+
'v-on:click'?: '' | PathType | Function | TreeSetFuncOption,
|
|
1531
|
+
[VOnCmd: `v-on:${string}`]: '' | PathType | Function | TreeSetFuncOption,
|
|
1532
|
+
[VOnArgsCmd: `v-on:${string}(${string})`]: Function | TreeSetFuncOption,
|
|
1533
|
+
|
|
1534
|
+
'v-on-mounted'?: '' | PathType | Function | TreeSetFuncOption,
|
|
1535
|
+
[VOnMountedArgsCmd: `v-on-mounted(${string})`]: Function | TreeSetFuncOption,
|
|
1536
|
+
|
|
1537
|
+
'v-on-unmounted'?: '' | PathType | Function | TreeSetFuncOption,
|
|
1538
|
+
[VOnUnMountedArgsCmd: `v-on-unmounted(${string})`]: Function | TreeSetFuncOption,
|
|
1539
|
+
|
|
1540
|
+
};
|
|
1541
|
+
type TreeSetFuncOption = {
|
|
1542
|
+
TargetFunc: PathType | Function,
|
|
1543
|
+
Args?: PathType,
|
|
1520
1544
|
};
|
|
1521
|
-
type TreeSetOption = CommandOption;
|
|
1522
1545
|
type AddCommandOption = PathType | Function | CommandOption;
|
|
1523
1546
|
|
|
1524
1547
|
type TreeSetInfo = {
|
|
@@ -1526,11 +1549,17 @@ type TreeSetInfo = {
|
|
|
1526
1549
|
TreePaths: string[],
|
|
1527
1550
|
DomPaths: string[],
|
|
1528
1551
|
DomName?: string,
|
|
1529
|
-
StoreValue: PathType | Function,
|
|
1552
|
+
StoreValue: PathType | Function | TreeSetFuncOption,
|
|
1530
1553
|
Command: string,
|
|
1531
1554
|
CommandKey?: string,
|
|
1532
|
-
|
|
1555
|
+
ForKey?: string,
|
|
1556
|
+
Args?: string,
|
|
1533
1557
|
}
|
|
1558
|
+
type TreeSetInfoOption = {
|
|
1559
|
+
TargetDom: PathType | QueryNode[],
|
|
1560
|
+
TargetValue: PathType | Function | CommandOption,
|
|
1561
|
+
TargetPath: PathType,
|
|
1562
|
+
};
|
|
1534
1563
|
type AddV_ModelOption = {
|
|
1535
1564
|
ModelValue?: string,
|
|
1536
1565
|
DefaultValue?: any,
|
|
@@ -1547,10 +1576,17 @@ type AddV_TreeOption = {
|
|
|
1547
1576
|
UseDomStore?: boolean,
|
|
1548
1577
|
};
|
|
1549
1578
|
//#endregion
|
|
1579
|
+
|
|
1550
1580
|
export class VueCommand extends VueStore {
|
|
1551
1581
|
protected $IsInited: boolean = false;
|
|
1582
|
+
protected $CommandMap: Record<string, (Info: TreeSetInfo, Option: TreeSetInfoOption) => void>;
|
|
1552
1583
|
$QueryDomName: string = null;
|
|
1553
1584
|
|
|
1585
|
+
constructor() {
|
|
1586
|
+
super();
|
|
1587
|
+
this.$SetupCommandMap();
|
|
1588
|
+
}
|
|
1589
|
+
|
|
1554
1590
|
//#region With Method
|
|
1555
1591
|
public WithQueryDomName(QueryDomName: string) {
|
|
1556
1592
|
this.$QueryDomName = QueryDomName;
|
|
@@ -1582,9 +1618,10 @@ export class VueCommand extends VueStore {
|
|
|
1582
1618
|
this.$AddCommand(DomName, 'v-model', SetOption);
|
|
1583
1619
|
return this;
|
|
1584
1620
|
}
|
|
1585
|
-
public AddV_Slot(DomName: PathType | QueryNode[], SlotKey: string,
|
|
1586
|
-
let SetOption = this.$ConvertCommandOption(
|
|
1587
|
-
|
|
1621
|
+
public AddV_Slot(DomName: PathType | QueryNode[], SlotKey: string, Option: AddCommandOption) {
|
|
1622
|
+
let SetOption = this.$ConvertCommandOption(DomName, Option);
|
|
1623
|
+
if (SlotKey != null)
|
|
1624
|
+
SetOption.CommandKey = SlotKey;
|
|
1588
1625
|
this.$AddCommand(DomName, `v-slot`, SetOption);
|
|
1589
1626
|
return this;
|
|
1590
1627
|
}
|
|
@@ -1741,83 +1778,8 @@ export class VueCommand extends VueStore {
|
|
|
1741
1778
|
RootNode = TreeRoot as QueryNode;
|
|
1742
1779
|
let RootPaths = UsingRootNode ? [] : this.Paths(TreeRoot)
|
|
1743
1780
|
this.$ParseTreeSet(RootPaths, TreeSet, AllSetInfo);
|
|
1744
|
-
|
|
1745
|
-
type TreeSetInfoOption = {
|
|
1746
|
-
TargetDom: PathType | QueryNode[],
|
|
1747
|
-
TargetValue: PathType | Function,
|
|
1748
|
-
TargetPath: PathType,
|
|
1749
|
-
};
|
|
1750
|
-
let CommandMap: Record<string, (Info: TreeSetInfo, Option: TreeSetInfoOption) => void> = {
|
|
1751
|
-
'v-text': (Info, Option) => {
|
|
1752
|
-
Model.AddV_Text(Option.TargetDom, Option.TargetValue);
|
|
1753
|
-
},
|
|
1754
|
-
'v-model': (Info, Option) => {
|
|
1755
|
-
if (typeof (Info.StoreValue) == 'function') {
|
|
1756
|
-
Model.$Error(`v-model command value must be a string or string[], path: ${this.ToJoin(Info.DomPaths)}`);
|
|
1757
|
-
return;
|
|
1758
|
-
}
|
|
1759
|
-
Model.AddV_Model(Option.TargetDom, Option.TargetPath, {
|
|
1760
|
-
ModelValue: Info.CommandKey,
|
|
1761
|
-
});
|
|
1762
|
-
},
|
|
1763
|
-
'v-for': (Info, Option) => {
|
|
1764
|
-
Model.AddV_For(Option.TargetDom, Option.TargetValue, Info.CommandKey);
|
|
1765
|
-
},
|
|
1766
|
-
'v-if': (Info, Option) => {
|
|
1767
|
-
Model.AddV_If(Option.TargetDom, Option.TargetValue);
|
|
1768
|
-
},
|
|
1769
|
-
'v-else-if': (Info, Option) => {
|
|
1770
|
-
Model.AddV_ElseIf(Option.TargetDom, Option.TargetValue);
|
|
1771
|
-
},
|
|
1772
|
-
'v-else': (Info, Option) => {
|
|
1773
|
-
Model.AddV_Else(Option.TargetDom);
|
|
1774
|
-
},
|
|
1775
|
-
'v-show': (Info, Option) => {
|
|
1776
|
-
Model.AddV_Show(Option.TargetDom, Option.TargetValue);
|
|
1777
|
-
},
|
|
1778
|
-
'v-bind': (Info, Option) => {
|
|
1779
|
-
if (!Option.TargetValue)
|
|
1780
|
-
return;
|
|
1781
|
-
Model.AddV_Bind(Option.TargetDom, Info.CommandKey, Option.TargetValue, Info.Params);
|
|
1782
|
-
},
|
|
1783
|
-
'v-on': (Info, Option) => {
|
|
1784
|
-
Model.AddV_On(Option.TargetDom, Info.CommandKey, Option.TargetValue, Info.Params);
|
|
1785
|
-
},
|
|
1786
|
-
'v-slot': (Info, Option) => {
|
|
1787
|
-
if (Array.isArray(Info.StoreValue) || typeof (Info.StoreValue) == 'function') {
|
|
1788
|
-
Model.$Error(`v-slot command value must be a string, path: ${this.ToJoin(Info.DomPaths)}`);
|
|
1789
|
-
return;
|
|
1790
|
-
}
|
|
1791
|
-
Model.AddV_Slot(Option.TargetDom, Info.CommandKey, Option.TargetPath);
|
|
1792
|
-
},
|
|
1793
|
-
'v-on-mounted': (Info, Option) => {
|
|
1794
|
-
Model.AddV_OnMounted(Option.TargetDom, Option.TargetValue, Info.CommandKey);
|
|
1795
|
-
},
|
|
1796
|
-
'v-on-unmounted': (Info, Option) => {
|
|
1797
|
-
Model.AddV_OnUnMounted(Option.TargetDom, Option.TargetValue, Info.CommandKey);
|
|
1798
|
-
},
|
|
1799
|
-
'watch': (Info, Option) => {
|
|
1800
|
-
if (typeof (Info.StoreValue) != 'function') {
|
|
1801
|
-
Model.$Error(`watch command value must be a function, path: ${this.ToJoin(Info.DomPaths)}`);
|
|
1802
|
-
return;
|
|
1803
|
-
}
|
|
1804
|
-
Model.AddV_Watch(Info.DomPaths, Info.StoreValue as any);
|
|
1805
|
-
},
|
|
1806
|
-
'func': (Info, Option) => {
|
|
1807
|
-
if (typeof (Info.StoreValue) != 'function') {
|
|
1808
|
-
Model.$Error(`func command value must be a function, path: ${this.ToJoin(Info.DomPaths)}`);
|
|
1809
|
-
return;
|
|
1810
|
-
}
|
|
1811
|
-
Model.AddV_Function(['event', ...Info.DomPaths, Info.CommandKey], Info.StoreValue);
|
|
1812
|
-
},
|
|
1813
|
-
'using': (Info, Option) => {
|
|
1814
|
-
if (typeof (Info.StoreValue) === 'function') {
|
|
1815
|
-
Info.StoreValue(Info.DomPaths, Info.Nodes);
|
|
1816
|
-
}
|
|
1817
|
-
}
|
|
1818
|
-
}
|
|
1819
1781
|
for (let Info of AllSetInfo) {
|
|
1820
|
-
let ActionSet = CommandMap[Info.Command];
|
|
1782
|
+
let ActionSet = this.$CommandMap[Info.Command];
|
|
1821
1783
|
if (ActionSet == null) {
|
|
1822
1784
|
Model.$Error(`${Info.Command} command is not allowed, path: ${this.ToJoin(Info.DomPaths)}`);
|
|
1823
1785
|
continue;
|
|
@@ -1842,18 +1804,41 @@ export class VueCommand extends VueStore {
|
|
|
1842
1804
|
|
|
1843
1805
|
let TargetDom: PathType | QueryNode[] = NeedQuery ? Info.Nodes : Info.DomPaths;
|
|
1844
1806
|
let TargetPath: PathType = [];
|
|
1845
|
-
let TargetValue: PathType | Function;
|
|
1807
|
+
let TargetValue: PathType | Function | CommandOption;
|
|
1846
1808
|
|
|
1847
|
-
if (typeof
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1809
|
+
if (typeof Info.StoreValue === 'function') {
|
|
1810
|
+
TargetValue = {
|
|
1811
|
+
Target: Info.StoreValue,
|
|
1812
|
+
FuncArgs: Info.Args,
|
|
1813
|
+
};
|
|
1814
|
+
}
|
|
1815
|
+
else {
|
|
1816
|
+
if (typeof Info.StoreValue === 'string' || Array.isArray(Info.StoreValue)) {
|
|
1817
|
+
Info.StoreValue = Model.ToJoin(Info.StoreValue);
|
|
1818
|
+
if (Option?.UseTreePath)
|
|
1819
|
+
TargetPath = [...Info.TreePaths];
|
|
1820
|
+
if (Option?.UseDomStore || Info.StoreValue == '.')
|
|
1821
|
+
TargetPath.push(Info.DomName);
|
|
1822
|
+
else if (Info.StoreValue != null && Info.StoreValue != '')
|
|
1823
|
+
TargetPath = this.Paths(TargetPath, Info.StoreValue);
|
|
1824
|
+
|
|
1825
|
+
TargetValue = TargetPath.length > 0 ? TargetPath : Info.StoreValue;
|
|
1826
|
+
}
|
|
1827
|
+
else {
|
|
1828
|
+
let NewStoreValue: CommandOption = {
|
|
1829
|
+
Target: Info.StoreValue.TargetFunc,
|
|
1830
|
+
FuncArgs: Info.StoreValue.Args,
|
|
1831
|
+
};
|
|
1832
|
+
TargetValue = NewStoreValue;
|
|
1833
|
+
if (Info.StoreValue.Args != null) {
|
|
1834
|
+
let Args = Model.ToJoin(Info.StoreValue.Args);
|
|
1835
|
+
if (Info.CommandKey == null || Info.CommandKey == '')
|
|
1836
|
+
Info.CommandKey = Args;
|
|
1837
|
+
else
|
|
1838
|
+
Info.CommandKey = Model.ToJoin([Info.CommandKey, Args], ', ');
|
|
1839
|
+
}
|
|
1840
|
+
}
|
|
1855
1841
|
}
|
|
1856
|
-
TargetValue = TargetPath.length > 0 ? TargetPath : Info.StoreValue;
|
|
1857
1842
|
|
|
1858
1843
|
if (TargetValue == '')
|
|
1859
1844
|
continue;
|
|
@@ -1867,8 +1852,8 @@ export class VueCommand extends VueStore {
|
|
|
1867
1852
|
return this;
|
|
1868
1853
|
}
|
|
1869
1854
|
private $ParseTreeSet(Paths: string[], TreeSet: TreeSetType, Result: TreeSetInfo[]) {
|
|
1855
|
+
const TreeNodeReges = /^:(?<next>.+)$/;
|
|
1870
1856
|
let AllKeys = Object.keys(TreeSet);
|
|
1871
|
-
let ParamRegex = /^(.+?)\(([^)]*)\)$/;
|
|
1872
1857
|
|
|
1873
1858
|
for (let i = 0; i < AllKeys.length; i++) {
|
|
1874
1859
|
let Command = AllKeys[i];
|
|
@@ -1877,70 +1862,148 @@ export class VueCommand extends VueStore {
|
|
|
1877
1862
|
let DomPaths = [...Paths];
|
|
1878
1863
|
let TreePaths = [...Paths];
|
|
1879
1864
|
let DomName = TreePaths.pop();
|
|
1880
|
-
if (!Command.includes(':')) {
|
|
1881
|
-
let HasParams = Command.match(ParamRegex);
|
|
1882
|
-
let CommandKey: string = null;
|
|
1883
|
-
if (HasParams && HasParams.length >= 3) {
|
|
1884
|
-
Command = HasParams[1];
|
|
1885
|
-
CommandKey = HasParams[2];
|
|
1886
|
-
}
|
|
1887
|
-
Result.push({
|
|
1888
|
-
Command: Command,
|
|
1889
|
-
StoreValue: SetPair,
|
|
1890
|
-
TreePaths: TreePaths,
|
|
1891
|
-
DomPaths: DomPaths,
|
|
1892
|
-
DomName: DomName,
|
|
1893
|
-
CommandKey: CommandKey,
|
|
1894
|
-
});
|
|
1895
|
-
continue;
|
|
1896
|
-
}
|
|
1897
1865
|
|
|
1898
|
-
let
|
|
1899
|
-
if (
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
}
|
|
1903
|
-
|
|
1904
|
-
Command = Commands.shift();
|
|
1905
|
-
let Params: string = null;
|
|
1906
|
-
if (Commands.length > 0) {
|
|
1907
|
-
let LastCommand = Commands.pop();
|
|
1908
|
-
let HasParams = LastCommand.match(ParamRegex);
|
|
1909
|
-
if (HasParams && HasParams.length >= 3) {
|
|
1910
|
-
Commands.push(HasParams[1]);
|
|
1911
|
-
Params = HasParams[2];
|
|
1912
|
-
}
|
|
1913
|
-
else
|
|
1914
|
-
Commands.push(LastCommand);
|
|
1915
|
-
}
|
|
1916
|
-
|
|
1917
|
-
let NextDomName = Model.ToJoin(Commands, ':');
|
|
1918
|
-
if (Command == '') {
|
|
1919
|
-
if (typeof SetPair != 'function')
|
|
1920
|
-
this.$ParseTreeSet([...Paths, NextDomName], SetPair as any, Result);
|
|
1921
|
-
else {
|
|
1866
|
+
let TreeNodeResult = Command.match(TreeNodeReges);
|
|
1867
|
+
if (TreeNodeResult) {
|
|
1868
|
+
let NextDomName = TreeNodeResult.groups.next;
|
|
1869
|
+
if (typeof SetPair === 'function') {
|
|
1922
1870
|
Result.push({
|
|
1923
1871
|
Command: 'using',
|
|
1924
|
-
CommandKey: null,
|
|
1925
1872
|
StoreValue: SetPair,
|
|
1926
1873
|
TreePaths: [...DomPaths],
|
|
1927
1874
|
DomPaths: [...DomPaths, NextDomName],
|
|
1928
1875
|
DomName: NextDomName,
|
|
1929
|
-
Params: Params,
|
|
1930
1876
|
});
|
|
1931
1877
|
}
|
|
1878
|
+
else {
|
|
1879
|
+
this.$ParseTreeSet([...Paths, NextDomName], SetPair as any, Result);
|
|
1880
|
+
}
|
|
1932
1881
|
continue;
|
|
1933
1882
|
}
|
|
1934
1883
|
|
|
1884
|
+
let GetCommandPart = (FindCommand: string, StartChar: string, EndChar: string) => {
|
|
1885
|
+
if (!FindCommand.includes(StartChar) || !FindCommand.includes(EndChar))
|
|
1886
|
+
return null;
|
|
1887
|
+
|
|
1888
|
+
let StartIndex = FindCommand.indexOf(StartChar);
|
|
1889
|
+
let EndIndex = FindCommand.lastIndexOf(EndChar);
|
|
1890
|
+
let Result = FindCommand.slice(StartIndex + 1, EndIndex).trim();
|
|
1891
|
+
return Result?.trim();
|
|
1892
|
+
};
|
|
1893
|
+
let GetCommandWithKey = (FindCommand: string) => {
|
|
1894
|
+
let ArgsStart = null;
|
|
1895
|
+
let ForKeyStart = null;
|
|
1896
|
+
if (FindCommand.includes('('))
|
|
1897
|
+
ArgsStart = FindCommand.indexOf('(');
|
|
1898
|
+
if (FindCommand.includes('<'))
|
|
1899
|
+
ForKeyStart = FindCommand.indexOf('<');
|
|
1900
|
+
|
|
1901
|
+
let CommandWithKey = null;
|
|
1902
|
+
if (ArgsStart == null && ForKeyStart == null) {
|
|
1903
|
+
CommandWithKey = FindCommand;
|
|
1904
|
+
}
|
|
1905
|
+
else if (ArgsStart == null || ForKeyStart == null) {
|
|
1906
|
+
let MinIndex = ArgsStart ?? ForKeyStart;
|
|
1907
|
+
CommandWithKey = FindCommand.slice(0, MinIndex);
|
|
1908
|
+
}
|
|
1909
|
+
else {
|
|
1910
|
+
let MinIndex = Math.min(ArgsStart, ForKeyStart);
|
|
1911
|
+
CommandWithKey = FindCommand.slice(0, MinIndex);
|
|
1912
|
+
}
|
|
1913
|
+
|
|
1914
|
+
let Command = CommandWithKey;
|
|
1915
|
+
let CommandKey = null;
|
|
1916
|
+
if (CommandWithKey.includes(':')) {
|
|
1917
|
+
let CommandKeyStart = Command.indexOf(':');
|
|
1918
|
+
Command = CommandWithKey.slice(0, CommandKeyStart);
|
|
1919
|
+
CommandKey = CommandWithKey.slice(CommandKeyStart + 1);
|
|
1920
|
+
}
|
|
1921
|
+
return {
|
|
1922
|
+
Command: Command?.trim(),
|
|
1923
|
+
CommandKey: CommandKey?.trim(),
|
|
1924
|
+
}
|
|
1925
|
+
};
|
|
1926
|
+
let Args = GetCommandPart(Command, '(', ')');
|
|
1927
|
+
let ForKey = GetCommandPart(Command, '<', '>');
|
|
1928
|
+
let CommandWithKey = GetCommandWithKey(Command);
|
|
1935
1929
|
Result.push({
|
|
1936
|
-
Command: Command,
|
|
1937
|
-
CommandKey:
|
|
1930
|
+
Command: CommandWithKey?.Command,
|
|
1931
|
+
CommandKey: CommandWithKey?.CommandKey,
|
|
1932
|
+
ForKey: ForKey,
|
|
1933
|
+
Args: Args,
|
|
1938
1934
|
StoreValue: SetPair,
|
|
1939
1935
|
TreePaths: TreePaths,
|
|
1940
1936
|
DomPaths: DomPaths,
|
|
1941
1937
|
DomName: DomName,
|
|
1942
|
-
Params: Params,
|
|
1943
1938
|
});
|
|
1939
|
+
continue;
|
|
1940
|
+
}
|
|
1941
|
+
}
|
|
1942
|
+
private $SetupCommandMap() {
|
|
1943
|
+
this.$CommandMap = {
|
|
1944
|
+
'v-text': (Info, Option) => {
|
|
1945
|
+
Model.AddV_Text(Option.TargetDom, Option.TargetValue);
|
|
1946
|
+
},
|
|
1947
|
+
'v-model': (Info, Option) => {
|
|
1948
|
+
if (typeof (Info.StoreValue) == 'function') {
|
|
1949
|
+
Model.$Error(`v-model command value must be a string or string[], path: ${this.ToJoin(Info.DomPaths)}`);
|
|
1950
|
+
return;
|
|
1951
|
+
}
|
|
1952
|
+
Model.AddV_Model(Option.TargetDom, Option.TargetPath, {
|
|
1953
|
+
ModelValue: Info.CommandKey,
|
|
1954
|
+
});
|
|
1955
|
+
},
|
|
1956
|
+
'v-for': (Info, Option) => {
|
|
1957
|
+
Model.AddV_For(Option.TargetDom, Option.TargetValue, Info.ForKey);
|
|
1958
|
+
},
|
|
1959
|
+
'v-if': (Info, Option) => {
|
|
1960
|
+
Model.AddV_If(Option.TargetDom, Option.TargetValue);
|
|
1961
|
+
},
|
|
1962
|
+
'v-else-if': (Info, Option) => {
|
|
1963
|
+
Model.AddV_ElseIf(Option.TargetDom, Option.TargetValue);
|
|
1964
|
+
},
|
|
1965
|
+
'v-else': (Info, Option) => {
|
|
1966
|
+
Model.AddV_Else(Option.TargetDom);
|
|
1967
|
+
},
|
|
1968
|
+
'v-show': (Info, Option) => {
|
|
1969
|
+
Model.AddV_Show(Option.TargetDom, Option.TargetValue);
|
|
1970
|
+
},
|
|
1971
|
+
'v-bind': (Info, Option) => {
|
|
1972
|
+
if (!Option.TargetValue)
|
|
1973
|
+
return;
|
|
1974
|
+
Model.AddV_Bind(Option.TargetDom, Info.CommandKey, Option.TargetValue, Info.Args);
|
|
1975
|
+
},
|
|
1976
|
+
'v-on': (Info, Option) => {
|
|
1977
|
+
Model.AddV_On(Option.TargetDom, Info.CommandKey, Option.TargetValue, Info.Args);
|
|
1978
|
+
},
|
|
1979
|
+
'v-slot': (Info, Option) => {
|
|
1980
|
+
Model.AddV_Slot(Option.TargetDom, Info.CommandKey, Option.TargetValue);
|
|
1981
|
+
},
|
|
1982
|
+
'v-on-mounted': (Info, Option) => {
|
|
1983
|
+
Model.AddV_OnMounted(Option.TargetDom, Option.TargetValue, Info.Args);
|
|
1984
|
+
},
|
|
1985
|
+
'v-on-unmounted': (Info, Option) => {
|
|
1986
|
+
Model.AddV_OnUnMounted(Option.TargetDom, Option.TargetValue, Info.Args);
|
|
1987
|
+
},
|
|
1988
|
+
'watch': (Info, Option) => {
|
|
1989
|
+
if (typeof (Info.StoreValue) != 'function') {
|
|
1990
|
+
Model.$Error(`watch command value must be a function, path: ${this.ToJoin(Info.DomPaths)}`);
|
|
1991
|
+
return;
|
|
1992
|
+
}
|
|
1993
|
+
Model.AddV_Watch(Info.DomPaths, Info.StoreValue as any);
|
|
1994
|
+
},
|
|
1995
|
+
'func': (Info, Option) => {
|
|
1996
|
+
if (typeof (Info.StoreValue) != 'function') {
|
|
1997
|
+
Model.$Error(`func command value must be a function, path: ${this.ToJoin(Info.DomPaths)}`);
|
|
1998
|
+
return;
|
|
1999
|
+
}
|
|
2000
|
+
Model.AddV_Function(['event', ...Info.DomPaths, Info.CommandKey], Info.StoreValue);
|
|
2001
|
+
},
|
|
2002
|
+
'using': (Info, Option) => {
|
|
2003
|
+
if (typeof (Info.StoreValue) === 'function') {
|
|
2004
|
+
Info.StoreValue(Info.DomPaths, Info.Nodes);
|
|
2005
|
+
}
|
|
2006
|
+
}
|
|
1944
2007
|
}
|
|
1945
2008
|
}
|
|
1946
2009
|
//#endregion
|
|
@@ -2069,11 +2132,7 @@ export class VueCommand extends VueStore {
|
|
|
2069
2132
|
|
|
2070
2133
|
if (Option.FuncArgs) {
|
|
2071
2134
|
let Args = this.ToJoin(Option.FuncArgs, ',');
|
|
2072
|
-
|
|
2073
|
-
Args = `(${Args}`;
|
|
2074
|
-
if (!/\)$/.test(Args))
|
|
2075
|
-
Args += ')';
|
|
2076
|
-
Target += Args;
|
|
2135
|
+
Target += `(${Args})`;
|
|
2077
2136
|
}
|
|
2078
2137
|
else if (Option.FuncAction) {
|
|
2079
2138
|
Target += `()`;
|