xmlui 0.9.11 → 0.9.13

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.
Files changed (62) hide show
  1. package/dist/{apiInterceptorWorker-BZP06llg.mjs → apiInterceptorWorker-BUaYCWe6.mjs} +1 -1
  2. package/dist/core-XLM8cuFP.mjs +7491 -0
  3. package/dist/{index-CFJ5_K_a.mjs → index-DiCe0Ajo.mjs} +1848 -872
  4. package/dist/index.css +150 -130
  5. package/dist/language-server-web-worker.mjs +1 -1
  6. package/dist/language-server.mjs +1 -1
  7. package/dist/{lint-CiMcsEWf.mjs → lint-Cd70ckJ6.mjs} +84 -94
  8. package/dist/{parser-mzWvH7dz.mjs → parser-CBXS8ft2.mjs} +19 -17
  9. package/dist/scripts/bin/build-lib.js +42 -1
  10. package/dist/scripts/bin/vite-xmlui-plugin.js +2 -22
  11. package/dist/scripts/bin/viteConfig.js +3 -1
  12. package/dist/scripts/src/abstractions/ComponentDefs.js +2 -20
  13. package/dist/scripts/src/components/App/App.js +61 -21
  14. package/dist/scripts/src/components/Button/Button.js +5 -1
  15. package/dist/scripts/src/components/Button/ButtonNative.js +9 -2
  16. package/dist/scripts/src/components/Checkbox/Checkbox.js +2 -2
  17. package/dist/scripts/src/components/ComponentProvider.js +2 -0
  18. package/dist/scripts/src/components/Footer/Footer.js +1 -1
  19. package/dist/scripts/src/components/Form/FormContext.js +2 -0
  20. package/dist/scripts/src/components/Form/FormNative.js +8 -2
  21. package/dist/scripts/src/components/Form/formActions.js +5 -4
  22. package/dist/scripts/src/components/FormItem/FormItemNative.js +25 -12
  23. package/dist/scripts/src/components/Items/Items.js +2 -1
  24. package/dist/scripts/src/components/List/List.js +2 -1
  25. package/dist/scripts/src/components/Markdown/Markdown.js +3 -0
  26. package/dist/scripts/src/components/Markdown/MarkdownNative.js +13 -10
  27. package/dist/scripts/src/components/NavPanel/NavPanel.js +2 -2
  28. package/dist/scripts/src/components/NumberBox/NumberBox2.js +85 -0
  29. package/dist/scripts/src/components/NumberBox/NumberBox2Native.js +395 -0
  30. package/dist/scripts/src/components/NumberBox/numberbox-abstractions.js +35 -0
  31. package/dist/scripts/src/components/Option/Option.js +2 -1
  32. package/dist/scripts/src/components/Select/Select.js +8 -0
  33. package/dist/scripts/src/components/Select/SelectNative.js +24 -10
  34. package/dist/scripts/src/components/SelectionStore/SelectionStore.js +1 -1
  35. package/dist/scripts/src/components/SelectionStore/SelectionStoreNative.js +10 -7
  36. package/dist/scripts/src/components/Theme/ThemeNative.js +1 -0
  37. package/dist/scripts/src/components/VisuallyHidden.js +21 -0
  38. package/dist/scripts/src/components-core/loader/DataLoader.js +110 -3
  39. package/dist/scripts/src/components-core/loader/Loader.js +29 -7
  40. package/dist/scripts/src/components-core/rendering/ComponentAdapter.js +4 -1
  41. package/dist/scripts/src/components-core/rendering/ComponentWrapper.js +23 -5
  42. package/dist/scripts/src/components-core/rendering/Container.js +23 -26
  43. package/dist/scripts/src/components-core/rendering/StateContainer.js +2 -4
  44. package/dist/scripts/src/components-core/rendering/reducer.js +6 -5
  45. package/dist/scripts/src/components-core/script-runner/eval-tree-async.js +2 -2
  46. package/dist/scripts/src/components-core/script-runner/eval-tree-sync.js +10 -2
  47. package/dist/scripts/src/components-core/utils/extractParam.js +24 -7
  48. package/dist/scripts/src/components-core/xmlui-parser.js +1 -1
  49. package/dist/scripts/src/parsers/xmlui-parser/parser.js +1 -1
  50. package/dist/scripts/src/parsers/xmlui-parser/transform.js +0 -10
  51. package/dist/scripts/src/parsers/xmlui-parser/utils.js +6 -9
  52. package/dist/{server-common-DxRVCeIE.mjs → server-common-DW5h7Q34.mjs} +122 -64
  53. package/dist/style.css +150 -130
  54. package/dist/xmlui-metadata.mjs +901 -316
  55. package/dist/xmlui-metadata.umd.js +901 -318
  56. package/dist/xmlui-parser.d.ts +14 -9
  57. package/dist/xmlui-parser.mjs +34 -34
  58. package/dist/xmlui-standalone.umd.js +7473 -5421
  59. package/dist/xmlui.d.ts +15 -1
  60. package/dist/xmlui.mjs +2 -1
  61. package/package.json +5 -5
  62. package/dist/core-C-osEDc2.mjs +0 -2
@@ -200,7 +200,7 @@ function parseXmlUiMarkup(text) {
200
200
  }
201
201
  }
202
202
  if (eat(syntax_kind_1.SyntaxKind.Equal)) {
203
- if (!eat(syntax_kind_1.SyntaxKind.StringLiteral) && !eat(syntax_kind_1.SyntaxKind.Identifier)) {
203
+ if (!eat(syntax_kind_1.SyntaxKind.StringLiteral)) {
204
204
  const attrFollowWithoutIdent = [syntax_kind_1.SyntaxKind.NodeEnd, syntax_kind_1.SyntaxKind.NodeClose];
205
205
  errRecover(diagnostics_1.Diag_Attr_Value_Expected, attrFollowWithoutIdent);
206
206
  }
@@ -618,7 +618,6 @@ function nodeToComponentDef(node, originalGetText, fileId) {
618
618
  const shouldCollapseWhitespace = tagName !== "event" && tagName !== "method";
619
619
  const attrs = getAttributes(node);
620
620
  desugarKeyOnlyAttrs(attrs);
621
- desugarQuotelessAttrs(attrs, getText);
622
621
  parseEscapeCharactersInAttrValues(attrs);
623
622
  parseEscapeCharactersInContent(childNodes);
624
623
  mergeConsecutiveTexts(childNodes, shouldCollapseWhitespace);
@@ -1030,15 +1029,6 @@ function desugarKeyOnlyAttrs(attrs) {
1030
1029
  }
1031
1030
  }
1032
1031
  }
1033
- function desugarQuotelessAttrs(attrs, getText) {
1034
- var _a, _b, _c;
1035
- for (let attr of attrs) {
1036
- const attrValue = (_a = attr.children) === null || _a === void 0 ? void 0 : _a[2];
1037
- if (((_c = (_b = attr.children) === null || _b === void 0 ? void 0 : _b[2]) === null || _c === void 0 ? void 0 : _c.kind) === syntax_kind_1.SyntaxKind.Identifier) {
1038
- attrValue.text = '"' + getText(attrValue) + '"';
1039
- }
1040
- }
1041
- }
1042
1032
  function addToNamespaces(namespaceStack, comp, nsKey, value) {
1043
1033
  var _a;
1044
1034
  let nsCommaSeparated = value.split(":");
@@ -42,13 +42,11 @@ function findTokenAtPos(node, position) {
42
42
  if (node.start > position || position > node.end) {
43
43
  return undefined;
44
44
  }
45
- // if (position === node.end) {
46
- // return {
47
- // chainBeforePos: findLastToken(node),
48
- // sharedParents: 0,
49
- // };
50
- // }
51
- const res = { chainAtPos: chain };
45
+ const res = {
46
+ chainAtPos: chain,
47
+ chainBeforePos: undefined,
48
+ sharedParents: undefined
49
+ };
52
50
  while (node.children !== undefined && node.children.length > 0) {
53
51
  //todo: make it a binary search before finding a fork
54
52
  const nodeAtPosIdx = node.children.findIndex((n) => n.start <= position &&
@@ -57,9 +55,8 @@ function findTokenAtPos(node, position) {
57
55
  const nodeBeforePos = node.children[nodeAtPosIdx - 1];
58
56
  if (nodeBeforePos !== undefined && position <= nodeAtPos.pos) {
59
57
  sharedParents = chain.length;
60
- chainBeforePos = findLastToken(nodeBeforePos);
61
58
  return {
62
- chainBeforePos,
59
+ chainBeforePos: chain.concat(findLastToken(nodeBeforePos)),
63
60
  sharedParents,
64
61
  chainAtPos: chain.concat(findFirstToken(nodeAtPos)),
65
62
  };
@@ -1,6 +1,6 @@
1
1
  import { MarkupKind as MarkupKind$1, CompletionItemKind as CompletionItemKind$1, TextDocuments as TextDocuments$1, TextDocumentSyncKind, DidChangeConfigurationNotification } from "vscode-languageserver";
2
2
  import { TextDocument as TextDocument$1 } from "vscode-languageserver-textdocument";
3
- import { S as SyntaxKind, x as findTokenAtPos, o as createXmlUiParser } from "./parser-mzWvH7dz.mjs";
3
+ import { S as SyntaxKind, x as findTokenAtPos, c as createXmlUiParser } from "./parser-CBXS8ft2.mjs";
4
4
  var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
5
5
  function getAugmentedNamespace(n) {
6
6
  if (n.__esModule) return n;
@@ -18757,6 +18757,40 @@ function compNameForTagNameNode(tagNameNode, getText) {
18757
18757
  const nameNode = tagNameNode.children.findLast((c) => c.kind === SyntaxKind.Identifier);
18758
18758
  return getText(nameNode);
18759
18759
  }
18760
+ function insideClosingTag(pathToElementNode) {
18761
+ if (pathToElementNode === null) {
18762
+ return false;
18763
+ }
18764
+ const elementNode = pathToElementNode.at(-1);
18765
+ const nodeBeforeElementNode = pathToElementNode.at(-2);
18766
+ const inputWasOnlyAnElementNode = !nodeBeforeElementNode;
18767
+ if (inputWasOnlyAnElementNode) {
18768
+ return false;
18769
+ }
18770
+ const idxClosingStartToken = elementNode.children.findIndex((n) => n.kind === SyntaxKind.CloseNodeStart);
18771
+ if (idxClosingStartToken === -1) {
18772
+ return false;
18773
+ }
18774
+ const idxElementNodeChild = elementNode.children.findIndex((n) => n === nodeBeforeElementNode);
18775
+ if (idxClosingStartToken <= idxElementNodeChild) {
18776
+ return true;
18777
+ }
18778
+ return false;
18779
+ }
18780
+ function pathToNodeInAscendands(chain, predicate) {
18781
+ let currentIdx = -1;
18782
+ let current = chain.at(currentIdx);
18783
+ let path = [current];
18784
+ while (current) {
18785
+ if (predicate(current)) {
18786
+ return path;
18787
+ }
18788
+ currentIdx--;
18789
+ current = chain.at(currentIdx);
18790
+ path.push(current);
18791
+ }
18792
+ return null;
18793
+ }
18760
18794
  function handleCompletionResolve({
18761
18795
  item,
18762
18796
  metaByComp: metaByComp2
@@ -18764,7 +18798,6 @@ function handleCompletionResolve({
18764
18798
  var _a2;
18765
18799
  const metadataAccessInfo = (_a2 = item == null ? void 0 : item.data) == null ? void 0 : _a2.metadataAccessInfo;
18766
18800
  if (metadataAccessInfo) {
18767
- metaByComp2.Alert.props;
18768
18801
  const { componentName } = metadataAccessInfo;
18769
18802
  const componentMeta = metaByComp2[componentName];
18770
18803
  if ("prop" in metadataAccessInfo) {
@@ -18793,7 +18826,19 @@ function handleCompletion({ parseResult: { node }, getText, metaByComp: metaByCo
18793
18826
  case SyntaxKind.OpenNodeStart:
18794
18827
  return allComponentNames(metaByComp2);
18795
18828
  case SyntaxKind.CloseNodeStart:
18796
- return matchingTagName(findRes, metaByComp2, getText);
18829
+ const closestElementNodeSuspect = chainBeforePos.at(-2) ?? chainAtPos.at(sharedParents - 1);
18830
+ if (closestElementNodeSuspect && closestElementNodeSuspect.kind === SyntaxKind.ElementNode) {
18831
+ return matchingTagName(closestElementNodeSuspect, metaByComp2, getText);
18832
+ } else {
18833
+ return allComponentNames(metaByComp2);
18834
+ }
18835
+ case SyntaxKind.Identifier:
18836
+ const pathToElementNode = pathToNodeInAscendands(chainBeforePos, (n) => n.kind === SyntaxKind.ElementNode);
18837
+ if (pathToElementNode && insideClosingTag(pathToElementNode)) {
18838
+ const elementNode = pathToElementNode.at(-1);
18839
+ return matchingTagName(elementNode, metaByComp2, getText);
18840
+ }
18841
+ return allComponentNames(metaByComp2);
18797
18842
  }
18798
18843
  const completeForProp = chainBeforePos.some(
18799
18844
  (n) => n.kind === SyntaxKind.AttributeKeyNode || n.kind === SyntaxKind.TagNameNode || n.kind === SyntaxKind.AttributeNode
@@ -18801,47 +18846,36 @@ function handleCompletion({ parseResult: { node }, getText, metaByComp: metaByCo
18801
18846
  if (completeForProp) {
18802
18847
  const tagNameNode = findTagNameNodeInStack(chainAtPos);
18803
18848
  const compName = compNameForTagNameNode(tagNameNode, getText);
18804
- return completionForNewProps(compName, metaByComp2);
18849
+ return completionForNewProp(compName, metaByComp2);
18805
18850
  }
18806
18851
  return null;
18807
18852
  }
18808
18853
  function allComponentNames(md) {
18809
- return Object.keys(md).map(componentCompletionItem);
18854
+ return Object.keys(md).map((compName) => CompletionItemBuilder.withComponent(compName).componentResolveData().build());
18810
18855
  }
18811
- function matchingTagName({ chainAtPos, chainBeforePos, sharedParents }, metaByComp2, getText) {
18812
- let parentBefore;
18813
- if (chainBeforePos.length > 1) {
18814
- parentBefore = chainBeforePos[chainBeforePos.length - 2];
18815
- } else if (sharedParents > 0) {
18816
- parentBefore = chainAtPos[sharedParents - 1];
18817
- } else {
18856
+ function matchingTagName(elementNode, metaByComp2, getText) {
18857
+ const nameNode = elementNode.children.find((c) => c.kind === SyntaxKind.TagNameNode);
18858
+ if (nameNode === void 0) {
18818
18859
  return allComponentNames(metaByComp2);
18819
18860
  }
18820
- if (parentBefore.kind === SyntaxKind.ElementNode) {
18821
- const nameNode = parentBefore.children.find((c) => c.kind === SyntaxKind.TagNameNode);
18822
- if (nameNode === void 0) {
18823
- return allComponentNames(metaByComp2);
18824
- }
18825
- const colonIdx = nameNode.children.findIndex((c) => c.kind === SyntaxKind.Colon);
18826
- let nameSpace = void 0;
18827
- let nameIdentSearchSpace = nameNode.children;
18828
- let name = void 0;
18829
- if (colonIdx !== -1) {
18830
- nameIdentSearchSpace = nameNode.children.slice(colonIdx + 1);
18831
- const nameSpaceIdx = nameNode.children.findIndex((c) => c.kind === SyntaxKind.Identifier);
18832
- if (nameSpaceIdx < colonIdx) {
18833
- nameSpace = getText(nameNode.children[nameSpaceIdx]);
18834
- }
18835
- }
18836
- const nameIdent = nameIdentSearchSpace.find((c) => c.kind === SyntaxKind.Identifier);
18837
- if (nameIdent === void 0) {
18838
- return allComponentNames(metaByComp2);
18861
+ const colonIdx = nameNode.children.findIndex((c) => c.kind === SyntaxKind.Colon);
18862
+ let nameSpace = void 0;
18863
+ let nameIdentSearchSpace = nameNode.children;
18864
+ let name = void 0;
18865
+ if (colonIdx !== -1) {
18866
+ nameIdentSearchSpace = nameNode.children.slice(colonIdx + 1);
18867
+ const nameSpaceIdx = nameNode.children.findIndex((c) => c.kind === SyntaxKind.Identifier);
18868
+ if (nameSpaceIdx < colonIdx) {
18869
+ nameSpace = getText(nameNode.children[nameSpaceIdx]);
18839
18870
  }
18840
- name = getText(nameIdent);
18841
- const value = nameSpace !== void 0 ? nameSpace + ":" + name : name;
18842
- return [componentCompletionItem(value)];
18843
18871
  }
18844
- return null;
18872
+ const nameIdent = nameIdentSearchSpace.find((c) => c.kind === SyntaxKind.Identifier);
18873
+ if (nameIdent === void 0) {
18874
+ return allComponentNames(metaByComp2);
18875
+ }
18876
+ name = getText(nameIdent);
18877
+ const value = nameSpace !== void 0 ? nameSpace + ":" + name : name;
18878
+ return [CompletionItemBuilder.withComponent(value).build()];
18845
18879
  }
18846
18880
  function handleCompletionInsideToken(chainAtPos, position, metaByComp2, getText) {
18847
18881
  const parent = chainAtPos.at(-2);
@@ -18850,48 +18884,33 @@ function handleCompletionInsideToken(chainAtPos, position, metaByComp2, getText)
18850
18884
  }
18851
18885
  switch (parent.kind) {
18852
18886
  case SyntaxKind.TagNameNode: {
18887
+ const tagNameNodeParent = chainAtPos.at(-3);
18888
+ const tagNameNodeIdx = tagNameNodeParent.children.findIndex((c) => c === parent);
18889
+ if (tagNameNodeIdx <= 0) {
18890
+ return null;
18891
+ }
18892
+ const previousNode = tagNameNodeParent.children[tagNameNodeIdx - 1];
18893
+ if (previousNode.kind === SyntaxKind.CloseNodeStart && tagNameNodeParent.kind === SyntaxKind.ElementNode) {
18894
+ return matchingTagName(tagNameNodeParent, metaByComp2, getText);
18895
+ }
18853
18896
  return allComponentNames(metaByComp2);
18854
18897
  }
18855
18898
  case SyntaxKind.AttributeKeyNode: {
18856
18899
  const tagNameNode = findTagNameNodeInStack(chainAtPos);
18857
18900
  const compName = compNameForTagNameNode(tagNameNode, getText);
18858
- return completionForNewProps(compName, metaByComp2);
18901
+ return completionForNewProp(compName, metaByComp2);
18859
18902
  }
18860
18903
  }
18861
18904
  return null;
18862
18905
  }
18863
- function completionForNewProps(compName, metaByComp2) {
18906
+ function completionForNewProp(compName, metaByComp2) {
18864
18907
  const metadata = metaByComp2[compName];
18865
18908
  if (!metadata || !metadata.props) {
18866
18909
  return null;
18867
18910
  }
18868
- return Object.keys(metadata.props).map((propName) => propCompletionItem(compName, propName));
18869
- }
18870
- function componentCompletionItem(name) {
18871
- return {
18872
- label: name,
18873
- kind: CompletionItemKind$1.Constructor,
18874
- labelDetails: {
18875
- description: "Core component"
18876
- },
18877
- data: {
18878
- metadataAccessInfo: {
18879
- componentName: name
18880
- }
18881
- }
18882
- };
18883
- }
18884
- function propCompletionItem(componentName, name) {
18885
- return {
18886
- label: name,
18887
- kind: CompletionItemKind$1.Property,
18888
- data: {
18889
- metadataAccessInfo: {
18890
- prop: name,
18891
- componentName
18892
- }
18893
- }
18894
- };
18911
+ return Object.keys(metadata.props).map(
18912
+ (propName) => CompletionItemBuilder.withProp(propName).propResolveData(compName).build()
18913
+ );
18895
18914
  }
18896
18915
  function markupContent(content) {
18897
18916
  return {
@@ -18899,6 +18918,45 @@ function markupContent(content) {
18899
18918
  value: content
18900
18919
  };
18901
18920
  }
18921
+ class CompletionItemBuilder {
18922
+ static withComponent(name) {
18923
+ const item = {
18924
+ label: name,
18925
+ kind: CompletionItemKind$1.Constructor
18926
+ };
18927
+ return new CompletionItemBuilder(item);
18928
+ }
18929
+ static withProp(propName) {
18930
+ const item = {
18931
+ label: propName,
18932
+ kind: CompletionItemKind$1.Property
18933
+ };
18934
+ return new CompletionItemBuilder(item);
18935
+ }
18936
+ constructor(item) {
18937
+ this.item = item;
18938
+ }
18939
+ componentResolveData() {
18940
+ const data = {
18941
+ metadataAccessInfo: { componentName: this.item.label }
18942
+ };
18943
+ this.item.data = data;
18944
+ return this;
18945
+ }
18946
+ propResolveData(componentName) {
18947
+ const data = {
18948
+ metadataAccessInfo: {
18949
+ componentName,
18950
+ prop: this.item.label
18951
+ }
18952
+ };
18953
+ this.item.data = data;
18954
+ return this;
18955
+ }
18956
+ build() {
18957
+ return this.item;
18958
+ }
18959
+ }
18902
18960
  function handleHover({ parseResult: { node }, getText, metaByComp: metaByComp2 }, position) {
18903
18961
  const findRes = findTokenAtPos(node, position);
18904
18962
  console.log("findres: ", findRes);