@arcgis/coding-components 4.29.0-beta.46 → 4.29.0-beta.48

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 (90) hide show
  1. package/dist/arcgis-coding-components/arcgis-coding-components.esm.js +1 -1
  2. package/dist/arcgis-coding-components/index.esm.js +1 -1
  3. package/dist/arcgis-coding-components/{p-e475e6cd.js → p-0823fa31.js} +1 -1
  4. package/dist/arcgis-coding-components/p-2c0d6f15.js +2 -0
  5. package/dist/arcgis-coding-components/{p-e6ede32d.js → p-2e99b56e.js} +1 -1
  6. package/dist/arcgis-coding-components/{p-9eabda86.js → p-30618728.js} +1 -1
  7. package/dist/arcgis-coding-components/{p-9e242e76.js → p-3dd452e0.js} +1 -1
  8. package/dist/arcgis-coding-components/{p-ccdf0ac1.entry.js → p-8f729db2.entry.js} +1 -1
  9. package/dist/arcgis-coding-components/{p-f7d7d78d.js → p-a8d30530.js} +1 -1
  10. package/dist/arcgis-coding-components/{p-c084ada8.js → p-ae129dfa.js} +1 -1
  11. package/dist/arcgis-coding-components/{p-71faf9a4.js → p-af7d25aa.js} +1 -1
  12. package/dist/arcgis-coding-components/{p-10a322ec.js → p-b5479fc4.js} +8 -8
  13. package/dist/arcgis-coding-components/{p-ce586a8c.js → p-d78367ff.js} +1 -1
  14. package/dist/cjs/{arcade-defaults-8445d852.js → arcade-defaults-6fa4acb9.js} +1305 -1305
  15. package/dist/cjs/arcade-mode-15687545.js +598 -0
  16. package/dist/cjs/arcgis-arcade-api_6.cjs.entry.js +1408 -1408
  17. package/dist/cjs/arcgis-coding-components.cjs.js +2 -2
  18. package/dist/cjs/{cssMode-e63287bb.js → cssMode-644e4ecf.js} +2 -2
  19. package/dist/cjs/{html-c0d4db3b.js → html-567706f3.js} +2 -2
  20. package/dist/cjs/{htmlMode-fdc44d57.js → htmlMode-14c95ab8.js} +2 -2
  21. package/dist/cjs/{index-6a382a34.js → index-ac186201.js} +67 -24
  22. package/dist/cjs/index.cjs.js +2 -2
  23. package/dist/cjs/{javascript-a419d064.js → javascript-69c3523c.js} +3 -3
  24. package/dist/cjs/{jsonMode-73aee5d2.js → jsonMode-da8803e7.js} +2 -2
  25. package/dist/cjs/loader.cjs.js +1 -1
  26. package/dist/cjs/{tsMode-37d1b053.js → tsMode-eddf280e.js} +2 -2
  27. package/dist/cjs/{typescript-53f9f36a.js → typescript-114292ed.js} +2 -2
  28. package/dist/components/arcade-api.js +160 -160
  29. package/dist/components/arcade-contribution.js +60 -60
  30. package/dist/components/arcade-defaults.js +1239 -1239
  31. package/dist/components/arcade-mode.js +513 -513
  32. package/dist/components/arcade-results.js +430 -430
  33. package/dist/components/arcade-suggestions.js +132 -132
  34. package/dist/components/arcade-variables.js +155 -155
  35. package/dist/components/arcgis-arcade-api.d.ts +2 -2
  36. package/dist/components/arcgis-arcade-editor.d.ts +2 -2
  37. package/dist/components/arcgis-arcade-editor.js +390 -390
  38. package/dist/components/arcgis-arcade-results.d.ts +2 -2
  39. package/dist/components/arcgis-arcade-suggestions.d.ts +2 -2
  40. package/dist/components/arcgis-arcade-variables.d.ts +2 -2
  41. package/dist/components/arcgis-code-editor.d.ts +2 -2
  42. package/dist/components/code-editor.js +251 -251
  43. package/dist/components/fields.js +69 -69
  44. package/dist/components/functional-components.js +1 -1
  45. package/dist/components/markdown.js +28 -28
  46. package/dist/components/utilities.js +20 -20
  47. package/dist/esm/{arcade-defaults-d7893362.js → arcade-defaults-3a952c7e.js} +1305 -1305
  48. package/dist/esm/arcade-mode-619b0989.js +594 -0
  49. package/dist/esm/arcgis-arcade-api_6.entry.js +1408 -1408
  50. package/dist/esm/arcgis-coding-components.js +3 -3
  51. package/dist/esm/{cssMode-b1771f92.js → cssMode-4100a9c5.js} +2 -2
  52. package/dist/esm/{html-af635d52.js → html-fbb4fdec.js} +2 -2
  53. package/dist/esm/{htmlMode-3021c301.js → htmlMode-a896869e.js} +2 -2
  54. package/dist/esm/{index-fd6b2fd8.js → index-022fb97b.js} +67 -24
  55. package/dist/esm/index.js +2 -2
  56. package/dist/esm/{javascript-70589186.js → javascript-a0bd70ad.js} +3 -3
  57. package/dist/esm/{jsonMode-cb509b79.js → jsonMode-76fe6af1.js} +2 -2
  58. package/dist/esm/loader.js +2 -2
  59. package/dist/esm/{tsMode-ed90c9aa.js → tsMode-277700f6.js} +2 -2
  60. package/dist/esm/{typescript-db8a0b18.js → typescript-c9f880aa.js} +2 -2
  61. package/dist/types/components/arcade-api/arcade-api.d.ts +40 -40
  62. package/dist/types/components/arcade-api/t9n-types.d.ts +6 -6
  63. package/dist/types/components/arcade-editor/arcade-editor.d.ts +127 -127
  64. package/dist/types/components/arcade-editor/t9n-types.d.ts +6 -6
  65. package/dist/types/components/arcade-results/arcade-results.d.ts +47 -47
  66. package/dist/types/components/arcade-results/t9n-types.d.ts +11 -11
  67. package/dist/types/components/arcade-suggestions/arcade-suggestions.d.ts +34 -34
  68. package/dist/types/components/arcade-suggestions/t9n-types.d.ts +4 -4
  69. package/dist/types/components/arcade-variables/arcade-variables.d.ts +41 -41
  70. package/dist/types/components/arcade-variables/t9n-types.d.ts +6 -6
  71. package/dist/types/components/code-editor/code-editor.d.ts +73 -73
  72. package/dist/types/stencil-public-runtime.d.ts +8 -0
  73. package/dist/types/utils/arcade-executor.d.ts +79 -79
  74. package/dist/types/utils/arcade-monaco/arcade-defaults.d.ts +66 -66
  75. package/dist/types/utils/arcade-monaco/arcade-language-features.d.ts +23 -23
  76. package/dist/types/utils/arcade-monaco/arcade-mode.d.ts +9 -9
  77. package/dist/types/utils/arcade-monaco/arcade-theme.d.ts +7 -7
  78. package/dist/types/utils/arcade-monaco/arcade-worker-manager.d.ts +9 -9
  79. package/dist/types/utils/arcade-monaco/arcade.worker.d.ts +12 -12
  80. package/dist/types/utils/arcade-monaco/types.d.ts +29 -29
  81. package/dist/types/utils/editor-suggestions.d.ts +24 -24
  82. package/dist/types/utils/functional-components.d.ts +1 -1
  83. package/dist/types/utils/markdown.d.ts +1 -1
  84. package/dist/types/utils/profile/editor-profile.d.ts +185 -185
  85. package/dist/types/utils/profile/types.d.ts +101 -101
  86. package/dist/types/utils/utilities.d.ts +1 -1
  87. package/package.json +7 -7
  88. package/dist/arcgis-coding-components/p-5d670bd2.js +0 -2
  89. package/dist/cjs/arcade-mode-b77afcc9.js +0 -598
  90. package/dist/esm/arcade-mode-70e22d22.js +0 -594
@@ -13,151 +13,151 @@ import '@esri/calcite-components/dist/components/calcite-flow.js';
13
13
  import '@esri/calcite-components/dist/components/calcite-list.js';
14
14
 
15
15
  function isSuggestionGroups(item) {
16
- if (!Array.isArray(item)) {
17
- return false;
18
- }
19
- if (!item.length) {
20
- return false;
21
- }
22
- return Array.isArray(item[0]?.suggestions);
16
+ if (!Array.isArray(item)) {
17
+ return false;
18
+ }
19
+ if (!item.length) {
20
+ return false;
21
+ }
22
+ return Array.isArray(item[0]?.suggestions);
23
23
  }
24
24
 
25
25
  const arcadeSuggestionsCss = ":host{background-color:var(--calcite-ui-foreground-1)}:host .notice-container{margin:var(--calcite-spacing-quarter);padding:var(--calcite-spacing-half);background-color:var(--calcite-ui-foreground-1)}:host .sticky{position:sticky;top:0px;z-index:10}:host calcite-flow{height:100%}:host calcite-block p:first-of-type{margin-top:0}:host calcite-block code{font-family:var(--calcite-code-family)}:host calcite-block pre{direction:ltr;overflow-x:auto;background-color:var(--calcite-ui-foreground-2);padding:var(--calcite-spacing-half)}:host calcite-block pre code{font-size:var(--calcite-font-size--2)}";
26
26
 
27
27
  const ArcgisArcadeSuggestions = /*@__PURE__*/ proxyCustomElement(class ArcgisArcadeSuggestions extends HTMLElement {
28
- constructor() {
29
- super();
30
- this.__registerHost();
31
- this.__attachShadow();
32
- this.close = createEvent(this, "close", 3);
33
- this.itemSelected = createEvent(this, "itemSelected", 3);
34
- // @ts-expect-error
35
- this._updateFilterValue = (e) => (this._filterValue = e.target?.["value"] ?? "");
36
- this._emitItemSelected = (e) => {
37
- // @ts-expect-error
38
- const item = e.target?.["data-item"];
39
- if (!item) {
40
- return;
41
- }
42
- const keyEvent = e;
43
- if (!keyEvent.key || keyEvent.key === "Enter") {
44
- e.preventDefault();
45
- this.itemSelected.emit(item.code);
46
- }
47
- };
48
- this._showSuggestionDetail = (e) => {
49
- // @ts-expect-error
50
- const item = e.target?.["data-item"];
51
- if (!item) {
52
- return;
53
- }
54
- e.stopPropagation();
55
- this._selectedSuggestion = item;
56
- };
57
- this._emitClose = () => this.close.emit();
58
- this._beforeBack = async () => (this._selectedSuggestion = undefined);
59
- this._lang = "";
60
- this._t9nLocale = "";
61
- this._t9nStrings = undefined;
62
- this._selectedSuggestion = undefined;
63
- this._filterValue = "";
64
- this._colorizeStyle = "";
65
- this.suggestions = undefined;
66
- }
67
- suggestionsPropChanged() {
68
- this._selectedSuggestion = undefined;
69
- }
70
- //#endregion
71
- // #region Component lifecycle events
72
- async componentWillLoad() {
73
- this._colorizeStyle = generateColorizeStyles();
74
- this._themeChangedListner = onColorizeThemeChanged(() => (this._colorizeStyle = generateColorizeStyles()));
75
- await F(this, getAssetPath("./assets"));
76
- }
77
- disconnectedCallback() {
78
- this._flowObserver?.disconnect();
79
- this._themeChangedListner?.dispose();
80
- U(this);
81
- }
82
- // #endregion
83
- //#region Private Methods
84
- flowFocusHandler(ref) {
85
- // When a flow is removed from the document then a null ref will be passed in
86
- if (!ref) {
87
- this._flowObserver?.disconnect();
88
- this._flowObserver = undefined;
89
- return;
28
+ constructor() {
29
+ super();
30
+ this.__registerHost();
31
+ this.__attachShadow();
32
+ this.close = createEvent(this, "close", 3);
33
+ this.itemSelected = createEvent(this, "itemSelected", 3);
34
+ // @ts-expect-error
35
+ this._updateFilterValue = (e) => (this._filterValue = e.target?.["value"] ?? "");
36
+ this._emitItemSelected = (e) => {
37
+ // @ts-expect-error
38
+ const item = e.target?.["data-item"];
39
+ if (!item) {
40
+ return;
41
+ }
42
+ const keyEvent = e;
43
+ if (!keyEvent.key || keyEvent.key === "Enter") {
44
+ e.preventDefault();
45
+ this.itemSelected.emit(item.code);
46
+ }
47
+ };
48
+ this._showSuggestionDetail = (e) => {
49
+ // @ts-expect-error
50
+ const item = e.target?.["data-item"];
51
+ if (!item) {
52
+ return;
53
+ }
54
+ e.stopPropagation();
55
+ this._selectedSuggestion = item;
56
+ };
57
+ this._emitClose = () => this.close.emit();
58
+ this._beforeBack = async () => (this._selectedSuggestion = undefined);
59
+ this._lang = "";
60
+ this._t9nLocale = "";
61
+ this._t9nStrings = undefined;
62
+ this._selectedSuggestion = undefined;
63
+ this._filterValue = "";
64
+ this._colorizeStyle = "";
65
+ this.suggestions = undefined;
66
+ }
67
+ suggestionsPropChanged() {
68
+ this._selectedSuggestion = undefined;
90
69
  }
91
- if (this._flowObserver) {
92
- return;
70
+ //#endregion
71
+ // #region Component lifecycle events
72
+ async componentWillLoad() {
73
+ this._colorizeStyle = generateColorizeStyles();
74
+ this._themeChangedListner = onColorizeThemeChanged(() => (this._colorizeStyle = generateColorizeStyles()));
75
+ await F(this, getAssetPath("./assets"));
93
76
  }
94
- // Observer panel added/removed and also observe the flow id
95
- // When switching between flow the same reference is reused
96
- this._flowObserver = new MutationObserver(() => {
97
- // Get the last panel and try to set focus on the input element
98
- O(ref.querySelector("calcite-flow-item:last-child"), "calcite-input");
99
- });
100
- this._flowObserver.observe(ref, { attributes: true, attributeFilter: ["id"], childList: true });
101
- }
102
- //#endregion
103
- //#region Renderers
104
- renderSuggestionGroups() {
105
- if (this.suggestions === undefined) {
106
- return null;
77
+ disconnectedCallback() {
78
+ this._flowObserver?.disconnect();
79
+ this._themeChangedListner?.dispose();
80
+ U(this);
107
81
  }
108
- if (isSuggestionGroups(this.suggestions)) {
109
- return this.suggestions.map((suggestionGroup) => {
110
- return (h("calcite-list-item-group", { heading: suggestionGroup.label }, this.renderSuggestionListItems(suggestionGroup.suggestions)));
111
- });
82
+ // #endregion
83
+ //#region Private Methods
84
+ flowFocusHandler(ref) {
85
+ // When a flow is removed from the document then a null ref will be passed in
86
+ if (!ref) {
87
+ this._flowObserver?.disconnect();
88
+ this._flowObserver = undefined;
89
+ return;
90
+ }
91
+ if (this._flowObserver) {
92
+ return;
93
+ }
94
+ // Observer panel added/removed and also observe the flow id
95
+ // When switching between flow the same reference is reused
96
+ this._flowObserver = new MutationObserver(() => {
97
+ // Get the last panel and try to set focus on the input element
98
+ O(ref.querySelector("calcite-flow-item:last-child"), "calcite-input");
99
+ });
100
+ this._flowObserver.observe(ref, { attributes: true, attributeFilter: ["id"], childList: true });
112
101
  }
113
- return this.renderSuggestionListItems(this.suggestions);
114
- }
115
- renderSuggestionListItems(suggestions) {
116
- suggestions = filterCollection(suggestions, "label", this._filterValue);
117
- if (!suggestions.length) {
118
- return h("div", { class: "notice-container" }, this._t9nStrings?.noitems ?? "No item");
102
+ //#endregion
103
+ //#region Renderers
104
+ renderSuggestionGroups() {
105
+ if (this.suggestions === undefined) {
106
+ return null;
107
+ }
108
+ if (isSuggestionGroups(this.suggestions)) {
109
+ return this.suggestions.map((suggestionGroup) => {
110
+ return (h("calcite-list-item-group", { heading: suggestionGroup.label }, this.renderSuggestionListItems(suggestionGroup.suggestions)));
111
+ });
112
+ }
113
+ return this.renderSuggestionListItems(this.suggestions);
119
114
  }
120
- return suggestions.map((suggestion) => (h("calcite-list-item", { label: suggestion.label, description: suggestion.description, onCalciteListItemSelect: this._emitItemSelected, onKeyPress: this._emitItemSelected, "data-item": suggestion }, h("calcite-action", { slot: "actions-end", text: this._t9nStrings?.expand ?? "", scale: "s", icon: "chevron-right", iconFlipRtl: true, onClick: this._showSuggestionDetail, "data-item": suggestion }))));
121
- }
122
- renderSuggestionFlowItem() {
123
- const suggestion = this._selectedSuggestion;
124
- if (!suggestion) {
125
- return null;
115
+ renderSuggestionListItems(suggestions) {
116
+ suggestions = filterCollection(suggestions, "label", this._filterValue);
117
+ if (!suggestions.length) {
118
+ return h("div", { class: "notice-container" }, this._t9nStrings?.noitems ?? "No item");
119
+ }
120
+ return suggestions.map((suggestion) => (h("calcite-list-item", { label: suggestion.label, description: suggestion.description, onCalciteListItemSelect: this._emitItemSelected, onKeyPress: this._emitItemSelected, "data-item": suggestion }, h("calcite-action", { slot: "actions-end", text: this._t9nStrings?.expand ?? "", scale: "s", icon: "chevron-right", iconFlipRtl: true, onClick: this._showSuggestionDetail, "data-item": suggestion }))));
126
121
  }
127
- return (h("calcite-flow-item", { heading: this._t9nStrings?.suggestions, closable: true, onCalciteFlowItemClose: this._emitClose, beforeBack: this._beforeBack }, h("calcite-button", { width: "half", slot: "footer", appearance: "outline", kind: "brand", "icon-start": "code", scale: "s", onClick: this._emitItemSelected, ref: (e) => e?.setFocus(), "data-item": suggestion }, this._t9nStrings?.insert), h("calcite-block", { open: true, heading: suggestion.label, description: suggestion.description }, h("div", { innerHTML: convertMarkdownString(suggestion.documentation) }), h("pre", null, h("code", { ref: async (e) => await colorizeCodeElement(e, suggestion.code) })))));
128
- }
129
- render() {
130
- return (h(Host, null, h("style", null, this._colorizeStyle), h("calcite-flow", { ref: (ref) => this.flowFocusHandler(ref) }, h("calcite-flow-item", { heading: this._t9nStrings?.suggestions, closable: true, onCalciteFlowItemClose: this._emitClose }, h(StickyFilterInput, { filterValue: this._filterValue, onCalciteInputInput: this._updateFilterValue }), h("calcite-list", null, this.renderSuggestionGroups())), this.renderSuggestionFlowItem())));
131
- }
132
- static get assetsDirs() { return ["assets"]; }
133
- get _hostElement() { return this; }
134
- static get watchers() { return {
135
- "suggestions": ["suggestionsPropChanged"]
136
- }; }
137
- static get style() { return arcadeSuggestionsCss; }
122
+ renderSuggestionFlowItem() {
123
+ const suggestion = this._selectedSuggestion;
124
+ if (!suggestion) {
125
+ return null;
126
+ }
127
+ return (h("calcite-flow-item", { heading: this._t9nStrings?.suggestions, closable: true, onCalciteFlowItemClose: this._emitClose, beforeBack: this._beforeBack }, h("calcite-button", { width: "half", slot: "footer", appearance: "outline", kind: "brand", "icon-start": "code", scale: "s", onClick: this._emitItemSelected, ref: (e) => e?.setFocus(), "data-item": suggestion }, this._t9nStrings?.insert), h("calcite-block", { open: true, heading: suggestion.label, description: suggestion.description }, h("div", { innerHTML: convertMarkdownString(suggestion.documentation) }), h("pre", null, h("code", { ref: async (e) => await colorizeCodeElement(e, suggestion.code) })))));
128
+ }
129
+ render() {
130
+ return (h(Host, null, h("style", null, this._colorizeStyle), h("calcite-flow", { ref: (ref) => this.flowFocusHandler(ref) }, h("calcite-flow-item", { heading: this._t9nStrings?.suggestions, closable: true, onCalciteFlowItemClose: this._emitClose }, h(StickyFilterInput, { filterValue: this._filterValue, onCalciteInputInput: this._updateFilterValue }), h("calcite-list", null, this.renderSuggestionGroups())), this.renderSuggestionFlowItem())));
131
+ }
132
+ static get assetsDirs() { return ["assets"]; }
133
+ get _hostElement() { return this; }
134
+ static get watchers() { return {
135
+ "suggestions": ["suggestionsPropChanged"]
136
+ }; }
137
+ static get style() { return arcadeSuggestionsCss; }
138
138
  }, [1, "arcgis-arcade-suggestions", {
139
- "suggestions": [16],
140
- "_lang": [32],
141
- "_t9nLocale": [32],
142
- "_t9nStrings": [32],
143
- "_selectedSuggestion": [32],
144
- "_filterValue": [32],
145
- "_colorizeStyle": [32]
146
- }, undefined, {
147
- "suggestions": ["suggestionsPropChanged"]
148
- }]);
139
+ "suggestions": [16],
140
+ "_lang": [32],
141
+ "_t9nLocale": [32],
142
+ "_t9nStrings": [32],
143
+ "_selectedSuggestion": [32],
144
+ "_filterValue": [32],
145
+ "_colorizeStyle": [32]
146
+ }, undefined, {
147
+ "suggestions": ["suggestionsPropChanged"]
148
+ }]);
149
149
  function defineCustomElement() {
150
- if (typeof customElements === "undefined") {
151
- return;
152
- }
153
- const components = ["arcgis-arcade-suggestions"];
154
- components.forEach(tagName => { switch (tagName) {
155
- case "arcgis-arcade-suggestions":
156
- if (!customElements.get(tagName)) {
157
- customElements.define(tagName, ArcgisArcadeSuggestions);
158
- }
159
- break;
160
- } });
150
+ if (typeof customElements === "undefined") {
151
+ return;
152
+ }
153
+ const components = ["arcgis-arcade-suggestions"];
154
+ components.forEach(tagName => { switch (tagName) {
155
+ case "arcgis-arcade-suggestions":
156
+ if (!customElements.get(tagName)) {
157
+ customElements.define(tagName, ArcgisArcadeSuggestions);
158
+ }
159
+ break;
160
+ } });
161
161
  }
162
162
  defineCustomElement();
163
163
 
@@ -14,168 +14,168 @@ import '@esri/calcite-components/dist/components/calcite-flow.js';
14
14
  const arcadeVariablesCss = ":host{background-color:var(--calcite-ui-foreground-1)}:host .notice-container{margin:var(--calcite-spacing-quarter);padding:var(--calcite-spacing-half);background-color:var(--calcite-ui-foreground-1)}:host .sticky{position:sticky;top:0px;z-index:10}:host calcite-flow{height:100%}";
15
15
 
16
16
  const ArcgisArcadeVariables = /*@__PURE__*/ proxyCustomElement(class ArcgisArcadeVariables extends HTMLElement {
17
- constructor() {
18
- super();
19
- this.__registerHost();
20
- this.__attachShadow();
21
- this.close = createEvent(this, "close", 3);
22
- this.itemSelected = createEvent(this, "itemSelected", 3);
23
- // @ts-expect-error
24
- this._updateFilterValue = (e) => (this._filterValue = e.target?.["value"] ?? "");
25
- this._beforeBack = async () => {
26
- this.removeLastPanelRenderer();
27
- this._filterValue = "";
28
- };
29
- this._emitClose = () => this.close.emit();
30
- this._backToTop = () => (this._flowItemRenderers = []);
31
- this._emitItemSelected = (e) => {
32
- // @ts-expect-error
33
- const variable = e.target?.["data-item"];
34
- if (!variable || variable.nonInteractive) {
35
- return;
36
- }
37
- const keyEvent = e;
38
- if (!keyEvent.key || keyEvent.key === "Enter") {
39
- e.preventDefault();
40
- this.itemSelected.emit(variable.snippet);
41
- }
42
- };
43
- this._stopEnterPropagation = (e) => {
44
- if (e.key === "Enter") {
45
- e.stopPropagation();
46
- }
47
- };
48
- this._showCollectionPanel = (e) => {
49
- // @ts-expect-error
50
- const collectionVariable = e.target?.["data-item"];
51
- if (!collectionVariable) {
52
- return;
53
- }
54
- e.stopPropagation();
55
- this.addPanelRenderer(this.collectionBasedVariableRenderer(collectionVariable));
56
- };
57
- this._lang = "";
58
- this._t9nLocale = "";
59
- this._t9nStrings = undefined;
60
- this._mutationCounter = 1;
61
- this._flowItemRenderers = [];
62
- this._filterValue = "";
63
- this.loading = false;
64
- this.modelId = undefined;
65
- }
66
- modelIdPropChanged() {
67
- this._flowItemRenderers = [];
68
- }
69
- //#endregion
70
- // #region Component lifecycle events
71
- async componentWillLoad() {
72
- await F(this, getAssetPath("./assets"));
73
- }
74
- disconnectedCallback() {
75
- U(this);
76
- this._flowObserver?.disconnect();
77
- }
78
- // #endregion
79
- //#region Private Methods
80
- addPanelRenderer(panelRenderer) {
81
- this._flowItemRenderers = [...this._flowItemRenderers, panelRenderer];
82
- }
83
- removeLastPanelRenderer() {
84
- this._flowItemRenderers = this._flowItemRenderers.slice(0, -1);
85
- }
86
- flowFocusHandler(ref) {
87
- // When a flow is removed from the document then a null ref will be passed in
88
- if (!ref) {
89
- this._flowObserver?.disconnect();
90
- this._flowObserver = undefined;
91
- return;
17
+ constructor() {
18
+ super();
19
+ this.__registerHost();
20
+ this.__attachShadow();
21
+ this.close = createEvent(this, "close", 3);
22
+ this.itemSelected = createEvent(this, "itemSelected", 3);
23
+ // @ts-expect-error
24
+ this._updateFilterValue = (e) => (this._filterValue = e.target?.["value"] ?? "");
25
+ this._beforeBack = async () => {
26
+ this.removeLastPanelRenderer();
27
+ this._filterValue = "";
28
+ };
29
+ this._emitClose = () => this.close.emit();
30
+ this._backToTop = () => (this._flowItemRenderers = []);
31
+ this._emitItemSelected = (e) => {
32
+ // @ts-expect-error
33
+ const variable = e.target?.["data-item"];
34
+ if (!variable || variable.nonInteractive) {
35
+ return;
36
+ }
37
+ const keyEvent = e;
38
+ if (!keyEvent.key || keyEvent.key === "Enter") {
39
+ e.preventDefault();
40
+ this.itemSelected.emit(variable.snippet);
41
+ }
42
+ };
43
+ this._stopEnterPropagation = (e) => {
44
+ if (e.key === "Enter") {
45
+ e.stopPropagation();
46
+ }
47
+ };
48
+ this._showCollectionPanel = (e) => {
49
+ // @ts-expect-error
50
+ const collectionVariable = e.target?.["data-item"];
51
+ if (!collectionVariable) {
52
+ return;
53
+ }
54
+ e.stopPropagation();
55
+ this.addPanelRenderer(this.collectionBasedVariableRenderer(collectionVariable));
56
+ };
57
+ this._lang = "";
58
+ this._t9nLocale = "";
59
+ this._t9nStrings = undefined;
60
+ this._mutationCounter = 1;
61
+ this._flowItemRenderers = [];
62
+ this._filterValue = "";
63
+ this.loading = false;
64
+ this.modelId = undefined;
65
+ }
66
+ modelIdPropChanged() {
67
+ this._flowItemRenderers = [];
68
+ }
69
+ //#endregion
70
+ // #region Component lifecycle events
71
+ async componentWillLoad() {
72
+ await F(this, getAssetPath("./assets"));
73
+ }
74
+ disconnectedCallback() {
75
+ U(this);
76
+ this._flowObserver?.disconnect();
92
77
  }
93
- if (this._flowObserver) {
94
- return;
78
+ // #endregion
79
+ //#region Private Methods
80
+ addPanelRenderer(panelRenderer) {
81
+ this._flowItemRenderers = [...this._flowItemRenderers, panelRenderer];
95
82
  }
96
- // Observer panel added/removed and also observe the flow id
97
- // When switching between flow the same reference is reused
98
- this._flowObserver = new MutationObserver(() => {
99
- // Get the last panel and try to set focus on the input element
100
- O(ref.querySelector("calcite-flow-item:last-child"), "calcite-input");
101
- });
102
- this._flowObserver.observe(ref, { attributes: true, attributeFilter: ["id"], childList: true });
103
- }
104
- //#endregion
105
- //#region Renderers
106
- collectionBasedVariableRenderer(collection, topPanel = false) {
107
- // Returns a function to be added to the subpanel render collection
108
- return () => {
109
- if (!collection) {
110
- return null;
111
- }
112
- // If the collection actually exists then two options:
113
- // - the collection still need to be loaded
114
- // - the collection is ready
115
- let loading = this.loading;
116
- if (!loading && !collection.loaded) {
117
- // Request to load and update mutation counter when done
118
- collection.loadSource().then(() => setTimeout(() => this._mutationCounter++));
119
- loading = true;
120
- }
121
- return (h("calcite-flow-item", { heading: this._t9nStrings?.profilevariables, beforeBack: this._beforeBack, closable: true, onCalciteFlowItemClose: this._emitClose }, h("calcite-action", { slot: "header-actions-end", text: this._t9nStrings?.backtotop ?? "Back to top", scale: "m", hidden: topPanel, icon: "chevrons-left", iconFlipRtl: true, onClick: this._backToTop }), h(StickyFilterInput, { filterValue: this._filterValue, onCalciteInputInput: this._updateFilterValue }), loading ? (h("calcite-loader", { scale: "s", type: "indeterminate", label: this._t9nStrings?.loading ?? "Loading" })) : (h("calcite-list", null, this.renderEditorVariables(collection)))));
122
- };
123
- }
124
- renderEditorVariables(collection) {
125
- // Filter the variables. Skip group, we will filter the children later on.
126
- const filterExpression = B(this._filterValue);
127
- const filteredVariables = collection.variables.filter((variable) => variable.passFilter(filterExpression));
128
- if (!filteredVariables.length) {
129
- return h("div", { class: "notice-container" }, this._t9nStrings?.noitems ?? "No item");
83
+ removeLastPanelRenderer() {
84
+ this._flowItemRenderers = this._flowItemRenderers.slice(0, -1);
130
85
  }
131
- return filteredVariables.map((variable) => this.renderEditorVariable(variable));
132
- }
133
- renderEditorVariable(variable) {
134
- switch (variable.type) {
135
- case "group":
136
- // Group is a collection but we represent it differently
137
- return (h("calcite-list-item-group", { heading: variable.getLabel() }, this.renderEditorVariables(variable)));
138
- default:
139
- return (h("calcite-list-item", { label: variable.getLabel(), description: variable.getDescription(), onCalciteListItemSelect: this._emitItemSelected, onKeyPress: this._emitItemSelected, "data-item": variable }, variable.isCollection ? (h("calcite-action", { slot: "actions-end", text: this._t9nStrings?.expand ?? "", scale: "s", icon: "chevron-right", iconFlipRtl: true, onClick: this._showCollectionPanel, onKeyPress: this._stopEnterPropagation, "data-item": variable })) : null, variable.icon ? h("calcite-icon", { icon: variable.icon, scale: "s", slot: "content-start" }) : null));
86
+ flowFocusHandler(ref) {
87
+ // When a flow is removed from the document then a null ref will be passed in
88
+ if (!ref) {
89
+ this._flowObserver?.disconnect();
90
+ this._flowObserver = undefined;
91
+ return;
92
+ }
93
+ if (this._flowObserver) {
94
+ return;
95
+ }
96
+ // Observer panel added/removed and also observe the flow id
97
+ // When switching between flow the same reference is reused
98
+ this._flowObserver = new MutationObserver(() => {
99
+ // Get the last panel and try to set focus on the input element
100
+ O(ref.querySelector("calcite-flow-item:last-child"), "calcite-input");
101
+ });
102
+ this._flowObserver.observe(ref, { attributes: true, attributeFilter: ["id"], childList: true });
140
103
  }
141
- }
142
- render() {
143
- const profile = arcadeDefaults.getEditorProfileForModel(this.modelId ?? "");
144
- if (!this.loading && !profile?.variables.length) {
145
- return (h("calcite-flow", null, h("calcite-flow-item", { heading: this._t9nStrings?.profilevariables, closable: true, onCalciteFlowItemClose: this._emitClose }, h("div", { class: "notice-container" }, this._t9nStrings?.noprofilevariablesmessage ?? ""))));
104
+ //#endregion
105
+ //#region Renderers
106
+ collectionBasedVariableRenderer(collection, topPanel = false) {
107
+ // Returns a function to be added to the subpanel render collection
108
+ return () => {
109
+ if (!collection) {
110
+ return null;
111
+ }
112
+ // If the collection actually exists then two options:
113
+ // - the collection still need to be loaded
114
+ // - the collection is ready
115
+ let loading = this.loading;
116
+ if (!loading && !collection.loaded) {
117
+ // Request to load and update mutation counter when done
118
+ collection.loadSource().then(() => setTimeout(() => this._mutationCounter++));
119
+ loading = true;
120
+ }
121
+ return (h("calcite-flow-item", { heading: this._t9nStrings?.profilevariables, beforeBack: this._beforeBack, closable: true, onCalciteFlowItemClose: this._emitClose }, h("calcite-action", { slot: "header-actions-end", text: this._t9nStrings?.backtotop ?? "Back to top", scale: "m", hidden: topPanel, icon: "chevrons-left", iconFlipRtl: true, onClick: this._backToTop }), h(StickyFilterInput, { filterValue: this._filterValue, onCalciteInputInput: this._updateFilterValue }), loading ? (h("calcite-loader", { scale: "s", type: "indeterminate", label: this._t9nStrings?.loading ?? "Loading" })) : (h("calcite-list", null, this.renderEditorVariables(collection)))));
122
+ };
146
123
  }
147
- return (h("calcite-flow", { ref: (ref) => this.flowFocusHandler(ref) }, this.collectionBasedVariableRenderer(profile, true)(), this._flowItemRenderers.map((renderer) => renderer())));
148
- }
149
- static get assetsDirs() { return ["assets"]; }
150
- get _hostElement() { return this; }
151
- static get watchers() { return {
152
- "modelId": ["modelIdPropChanged"]
153
- }; }
154
- static get style() { return arcadeVariablesCss; }
124
+ renderEditorVariables(collection) {
125
+ // Filter the variables. Skip group, we will filter the children later on.
126
+ const filterExpression = B(this._filterValue);
127
+ const filteredVariables = collection.variables.filter((variable) => variable.passFilter(filterExpression));
128
+ if (!filteredVariables.length) {
129
+ return h("div", { class: "notice-container" }, this._t9nStrings?.noitems ?? "No item");
130
+ }
131
+ return filteredVariables.map((variable) => this.renderEditorVariable(variable));
132
+ }
133
+ renderEditorVariable(variable) {
134
+ switch (variable.type) {
135
+ case "group":
136
+ // Group is a collection but we represent it differently
137
+ return (h("calcite-list-item-group", { heading: variable.getLabel() }, this.renderEditorVariables(variable)));
138
+ default:
139
+ return (h("calcite-list-item", { label: variable.getLabel(), description: variable.getDescription(), onCalciteListItemSelect: this._emitItemSelected, onKeyPress: this._emitItemSelected, "data-item": variable }, variable.isCollection ? (h("calcite-action", { slot: "actions-end", text: this._t9nStrings?.expand ?? "", scale: "s", icon: "chevron-right", iconFlipRtl: true, onClick: this._showCollectionPanel, onKeyPress: this._stopEnterPropagation, "data-item": variable })) : null, variable.icon ? h("calcite-icon", { icon: variable.icon, scale: "s", slot: "content-start" }) : null));
140
+ }
141
+ }
142
+ render() {
143
+ const profile = arcadeDefaults.getEditorProfileForModel(this.modelId ?? "");
144
+ if (!this.loading && !profile?.variables.length) {
145
+ return (h("calcite-flow", null, h("calcite-flow-item", { heading: this._t9nStrings?.profilevariables, closable: true, onCalciteFlowItemClose: this._emitClose }, h("div", { class: "notice-container" }, this._t9nStrings?.noprofilevariablesmessage ?? ""))));
146
+ }
147
+ return (h("calcite-flow", { ref: (ref) => this.flowFocusHandler(ref) }, this.collectionBasedVariableRenderer(profile, true)(), this._flowItemRenderers.map((renderer) => renderer())));
148
+ }
149
+ static get assetsDirs() { return ["assets"]; }
150
+ get _hostElement() { return this; }
151
+ static get watchers() { return {
152
+ "modelId": ["modelIdPropChanged"]
153
+ }; }
154
+ static get style() { return arcadeVariablesCss; }
155
155
  }, [1, "arcgis-arcade-variables", {
156
- "loading": [4],
157
- "modelId": [1, "model-id"],
158
- "_lang": [32],
159
- "_t9nLocale": [32],
160
- "_t9nStrings": [32],
161
- "_mutationCounter": [32],
162
- "_flowItemRenderers": [32],
163
- "_filterValue": [32]
164
- }, undefined, {
165
- "modelId": ["modelIdPropChanged"]
166
- }]);
156
+ "loading": [4],
157
+ "modelId": [1, "model-id"],
158
+ "_lang": [32],
159
+ "_t9nLocale": [32],
160
+ "_t9nStrings": [32],
161
+ "_mutationCounter": [32],
162
+ "_flowItemRenderers": [32],
163
+ "_filterValue": [32]
164
+ }, undefined, {
165
+ "modelId": ["modelIdPropChanged"]
166
+ }]);
167
167
  function defineCustomElement() {
168
- if (typeof customElements === "undefined") {
169
- return;
170
- }
171
- const components = ["arcgis-arcade-variables"];
172
- components.forEach(tagName => { switch (tagName) {
173
- case "arcgis-arcade-variables":
174
- if (!customElements.get(tagName)) {
175
- customElements.define(tagName, ArcgisArcadeVariables);
176
- }
177
- break;
178
- } });
168
+ if (typeof customElements === "undefined") {
169
+ return;
170
+ }
171
+ const components = ["arcgis-arcade-variables"];
172
+ components.forEach(tagName => { switch (tagName) {
173
+ case "arcgis-arcade-variables":
174
+ if (!customElements.get(tagName)) {
175
+ customElements.define(tagName, ArcgisArcadeVariables);
176
+ }
177
+ break;
178
+ } });
179
179
  }
180
180
  defineCustomElement();
181
181
 
@@ -2,8 +2,8 @@ import type { Components, JSX } from "../types/components";
2
2
 
3
3
  interface ArcgisArcadeApi extends Components.ArcgisArcadeApi, HTMLElement {}
4
4
  export const ArcgisArcadeApi: {
5
- prototype: ArcgisArcadeApi;
6
- new (): ArcgisArcadeApi;
5
+ prototype: ArcgisArcadeApi;
6
+ new (): ArcgisArcadeApi;
7
7
  };
8
8
  /**
9
9
  * Used to define this component and all nested components recursively.
@@ -2,8 +2,8 @@ import type { Components, JSX } from "../types/components";
2
2
 
3
3
  interface ArcgisArcadeEditor extends Components.ArcgisArcadeEditor, HTMLElement {}
4
4
  export const ArcgisArcadeEditor: {
5
- prototype: ArcgisArcadeEditor;
6
- new (): ArcgisArcadeEditor;
5
+ prototype: ArcgisArcadeEditor;
6
+ new (): ArcgisArcadeEditor;
7
7
  };
8
8
  /**
9
9
  * Used to define this component and all nested components recursively.