@arcgis/coding-components 4.29.0-beta.47 → 4.29.0-beta.49
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/arcgis-coding-components/arcgis-coding-components.esm.js +1 -1
- package/dist/arcgis-coding-components/assets/code-editor/arcade.worker.js +13 -13
- package/dist/arcgis-coding-components/index.esm.js +1 -1
- package/dist/arcgis-coding-components/{p-10a322ec.js → p-0d616249.js} +9 -9
- package/dist/arcgis-coding-components/p-2c0d6f15.js +2 -0
- package/dist/arcgis-coding-components/{p-71faf9a4.js → p-5802524a.js} +1 -1
- package/dist/arcgis-coding-components/{p-9eabda86.js → p-5ddccf04.js} +1 -1
- package/dist/arcgis-coding-components/p-7475f3a6.js +1 -0
- package/dist/arcgis-coding-components/{p-e6ede32d.js → p-7d8caba9.js} +1 -1
- package/dist/arcgis-coding-components/{p-f7d7d78d.js → p-9f6db08a.js} +1 -1
- package/dist/arcgis-coding-components/{p-e475e6cd.js → p-aefe77ce.js} +1 -1
- package/dist/arcgis-coding-components/p-ce2be55e.entry.js +1 -0
- package/dist/arcgis-coding-components/{p-ce586a8c.js → p-d425a387.js} +1 -1
- package/dist/arcgis-coding-components/{p-c084ada8.js → p-ff21f230.js} +1 -1
- package/dist/cjs/{arcade-defaults-8445d852.js → arcade-defaults-2d513b59.js} +1534 -1534
- package/dist/cjs/arcade-mode-6219f1b8.js +599 -0
- package/dist/cjs/arcgis-arcade-api_6.cjs.entry.js +1404 -1408
- package/dist/cjs/arcgis-coding-components.cjs.js +2 -2
- package/dist/cjs/{cssMode-e63287bb.js → cssMode-1ec48254.js} +2 -2
- package/dist/cjs/{html-c0d4db3b.js → html-0e1741fe.js} +2 -2
- package/dist/cjs/{htmlMode-fdc44d57.js → htmlMode-279d3c29.js} +2 -2
- package/dist/cjs/{index-6a382a34.js → index-ac186201.js} +67 -24
- package/dist/cjs/index.cjs.js +2 -2
- package/dist/cjs/{javascript-a419d064.js → javascript-04f1bce0.js} +3 -3
- package/dist/cjs/{jsonMode-73aee5d2.js → jsonMode-59322f7a.js} +2 -2
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{tsMode-37d1b053.js → tsMode-17561f70.js} +2 -2
- package/dist/cjs/{typescript-53f9f36a.js → typescript-b7da8629.js} +2 -2
- package/dist/components/arcade-api.js +160 -160
- package/dist/components/arcade-contribution.js +60 -60
- package/dist/components/arcade-defaults.js +1240 -1240
- package/dist/components/arcade-mode.js +514 -513
- package/dist/components/arcade-results.js +426 -430
- package/dist/components/arcade-suggestions.js +130 -132
- package/dist/components/arcade-variables.js +157 -155
- package/dist/components/arcgis-arcade-api.d.ts +2 -2
- package/dist/components/arcgis-arcade-editor.d.ts +2 -2
- package/dist/components/arcgis-arcade-editor.js +391 -391
- package/dist/components/arcgis-arcade-results.d.ts +2 -2
- package/dist/components/arcgis-arcade-suggestions.d.ts +2 -2
- package/dist/components/arcgis-arcade-variables.d.ts +2 -2
- package/dist/components/arcgis-code-editor.d.ts +2 -2
- package/dist/components/code-editor.js +251 -251
- package/dist/components/fields.js +69 -69
- package/dist/components/functional-components.js +1 -1
- package/dist/components/index2.js +2 -2
- package/dist/components/markdown.js +28 -28
- package/dist/components/utilities.js +20 -20
- package/dist/esm/{arcade-defaults-d7893362.js → arcade-defaults-0bafa696.js} +1534 -1534
- package/dist/esm/arcade-mode-c17a1fa1.js +595 -0
- package/dist/esm/arcgis-arcade-api_6.entry.js +1404 -1408
- package/dist/esm/arcgis-coding-components.js +3 -3
- package/dist/esm/{cssMode-b1771f92.js → cssMode-3d18bd2b.js} +2 -2
- package/dist/esm/{html-af635d52.js → html-2bce5d77.js} +2 -2
- package/dist/esm/{htmlMode-3021c301.js → htmlMode-69d56956.js} +2 -2
- package/dist/esm/{index-fd6b2fd8.js → index-022fb97b.js} +67 -24
- package/dist/esm/index.js +2 -2
- package/dist/esm/{javascript-70589186.js → javascript-ded5c9d7.js} +3 -3
- package/dist/esm/{jsonMode-cb509b79.js → jsonMode-0bf84cb2.js} +2 -2
- package/dist/esm/loader.js +2 -2
- package/dist/esm/{tsMode-ed90c9aa.js → tsMode-15d4e936.js} +2 -2
- package/dist/esm/{typescript-db8a0b18.js → typescript-cc4d00f0.js} +2 -2
- package/dist/types/components/arcade-api/arcade-api.d.ts +40 -40
- package/dist/types/components/arcade-api/t9n-types.d.ts +6 -6
- package/dist/types/components/arcade-editor/arcade-editor.d.ts +127 -127
- package/dist/types/components/arcade-editor/t9n-types.d.ts +6 -6
- package/dist/types/components/arcade-results/arcade-results.d.ts +47 -47
- package/dist/types/components/arcade-results/t9n-types.d.ts +11 -11
- package/dist/types/components/arcade-suggestions/arcade-suggestions.d.ts +34 -34
- package/dist/types/components/arcade-suggestions/t9n-types.d.ts +4 -4
- package/dist/types/components/arcade-variables/arcade-variables.d.ts +41 -41
- package/dist/types/components/arcade-variables/t9n-types.d.ts +6 -6
- package/dist/types/components/code-editor/code-editor.d.ts +73 -73
- package/dist/types/stencil-public-runtime.d.ts +8 -0
- package/dist/types/utils/arcade-executor.d.ts +79 -79
- package/dist/types/utils/arcade-monaco/arcade-defaults.d.ts +66 -66
- package/dist/types/utils/arcade-monaco/arcade-language-features.d.ts +23 -23
- package/dist/types/utils/arcade-monaco/arcade-mode.d.ts +9 -9
- package/dist/types/utils/arcade-monaco/arcade-theme.d.ts +7 -7
- package/dist/types/utils/arcade-monaco/arcade-worker-manager.d.ts +9 -9
- package/dist/types/utils/arcade-monaco/arcade.worker.d.ts +12 -12
- package/dist/types/utils/arcade-monaco/types.d.ts +29 -29
- package/dist/types/utils/editor-suggestions.d.ts +24 -24
- package/dist/types/utils/functional-components.d.ts +1 -1
- package/dist/types/utils/markdown.d.ts +1 -1
- package/dist/types/utils/profile/editor-profile.d.ts +185 -185
- package/dist/types/utils/profile/types.d.ts +101 -101
- package/dist/types/utils/utilities.d.ts +1 -1
- package/package.json +7 -7
- package/dist/arcgis-coding-components/p-5d670bd2.js +0 -2
- package/dist/arcgis-coding-components/p-9e242e76.js +0 -1
- package/dist/arcgis-coding-components/p-ccdf0ac1.entry.js +0 -1
- package/dist/cjs/arcade-mode-b77afcc9.js +0 -598
- package/dist/esm/arcade-mode-70e22d22.js +0 -594
|
@@ -13,151 +13,149 @@ 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
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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
|
-
|
|
92
|
-
|
|
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
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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
|
-
|
|
109
|
-
|
|
110
|
-
|
|
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
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
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) => (h("calcite-list-item-group", { heading: suggestionGroup.label }, this.renderSuggestionListItems(suggestionGroup.suggestions))));
|
|
110
|
+
}
|
|
111
|
+
return this.renderSuggestionListItems(this.suggestions);
|
|
119
112
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
113
|
+
renderSuggestionListItems(suggestions) {
|
|
114
|
+
suggestions = filterCollection(suggestions, "label", this._filterValue);
|
|
115
|
+
if (!suggestions.length) {
|
|
116
|
+
return h("div", { class: "notice-container" }, this._t9nStrings?.noitems ?? "No item");
|
|
117
|
+
}
|
|
118
|
+
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
119
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
120
|
+
renderSuggestionFlowItem() {
|
|
121
|
+
const suggestion = this._selectedSuggestion;
|
|
122
|
+
if (!suggestion) {
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
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) })))));
|
|
126
|
+
}
|
|
127
|
+
render() {
|
|
128
|
+
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())));
|
|
129
|
+
}
|
|
130
|
+
static get assetsDirs() { return ["assets"]; }
|
|
131
|
+
get _hostElement() { return this; }
|
|
132
|
+
static get watchers() { return {
|
|
133
|
+
"suggestions": ["suggestionsPropChanged"]
|
|
134
|
+
}; }
|
|
135
|
+
static get style() { return arcadeSuggestionsCss; }
|
|
138
136
|
}, [1, "arcgis-arcade-suggestions", {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
137
|
+
"suggestions": [16],
|
|
138
|
+
"_lang": [32],
|
|
139
|
+
"_t9nLocale": [32],
|
|
140
|
+
"_t9nStrings": [32],
|
|
141
|
+
"_selectedSuggestion": [32],
|
|
142
|
+
"_filterValue": [32],
|
|
143
|
+
"_colorizeStyle": [32]
|
|
144
|
+
}, undefined, {
|
|
145
|
+
"suggestions": ["suggestionsPropChanged"]
|
|
146
|
+
}]);
|
|
149
147
|
function defineCustomElement() {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
148
|
+
if (typeof customElements === "undefined") {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
const components = ["arcgis-arcade-suggestions"];
|
|
152
|
+
components.forEach(tagName => { switch (tagName) {
|
|
153
|
+
case "arcgis-arcade-suggestions":
|
|
154
|
+
if (!customElements.get(tagName)) {
|
|
155
|
+
customElements.define(tagName, ArcgisArcadeSuggestions);
|
|
156
|
+
}
|
|
157
|
+
break;
|
|
158
|
+
} });
|
|
161
159
|
}
|
|
162
160
|
defineCustomElement();
|
|
163
161
|
|
|
@@ -14,168 +14,170 @@ 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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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
|
-
|
|
94
|
-
|
|
78
|
+
// #endregion
|
|
79
|
+
//#region Private Methods
|
|
80
|
+
addPanelRenderer(panelRenderer) {
|
|
81
|
+
this._flowItemRenderers = [...this._flowItemRenderers, panelRenderer];
|
|
95
82
|
}
|
|
96
|
-
|
|
97
|
-
|
|
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
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
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
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
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(() => {
|
|
119
|
+
this._mutationCounter += 1;
|
|
120
|
+
}));
|
|
121
|
+
loading = true;
|
|
122
|
+
}
|
|
123
|
+
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)))));
|
|
124
|
+
};
|
|
146
125
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
126
|
+
renderEditorVariables(collection) {
|
|
127
|
+
// Filter the variables. Skip group, we will filter the children later on.
|
|
128
|
+
const filterExpression = B(this._filterValue);
|
|
129
|
+
const filteredVariables = collection.variables.filter((variable) => variable.passFilter(filterExpression));
|
|
130
|
+
if (!filteredVariables.length) {
|
|
131
|
+
return h("div", { class: "notice-container" }, this._t9nStrings?.noitems ?? "No item");
|
|
132
|
+
}
|
|
133
|
+
return filteredVariables.map((variable) => this.renderEditorVariable(variable));
|
|
134
|
+
}
|
|
135
|
+
renderEditorVariable(variable) {
|
|
136
|
+
switch (variable.type) {
|
|
137
|
+
case "group":
|
|
138
|
+
// Group is a collection but we represent it differently
|
|
139
|
+
return (h("calcite-list-item-group", { heading: variable.getLabel() }, this.renderEditorVariables(variable)));
|
|
140
|
+
default:
|
|
141
|
+
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));
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
render() {
|
|
145
|
+
const profile = arcadeDefaults.getEditorProfileForModel(this.modelId ?? "");
|
|
146
|
+
if (!this.loading && !profile?.variables.length) {
|
|
147
|
+
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 ?? ""))));
|
|
148
|
+
}
|
|
149
|
+
return (h("calcite-flow", { ref: (ref) => this.flowFocusHandler(ref) }, this.collectionBasedVariableRenderer(profile, true)(), this._flowItemRenderers.map((renderer) => renderer())));
|
|
150
|
+
}
|
|
151
|
+
static get assetsDirs() { return ["assets"]; }
|
|
152
|
+
get _hostElement() { return this; }
|
|
153
|
+
static get watchers() { return {
|
|
154
|
+
"modelId": ["modelIdPropChanged"]
|
|
155
|
+
}; }
|
|
156
|
+
static get style() { return arcadeVariablesCss; }
|
|
155
157
|
}, [1, "arcgis-arcade-variables", {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
158
|
+
"loading": [4],
|
|
159
|
+
"modelId": [1, "model-id"],
|
|
160
|
+
"_lang": [32],
|
|
161
|
+
"_t9nLocale": [32],
|
|
162
|
+
"_t9nStrings": [32],
|
|
163
|
+
"_mutationCounter": [32],
|
|
164
|
+
"_flowItemRenderers": [32],
|
|
165
|
+
"_filterValue": [32]
|
|
166
|
+
}, undefined, {
|
|
167
|
+
"modelId": ["modelIdPropChanged"]
|
|
168
|
+
}]);
|
|
167
169
|
function defineCustomElement() {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
170
|
+
if (typeof customElements === "undefined") {
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
const components = ["arcgis-arcade-variables"];
|
|
174
|
+
components.forEach(tagName => { switch (tagName) {
|
|
175
|
+
case "arcgis-arcade-variables":
|
|
176
|
+
if (!customElements.get(tagName)) {
|
|
177
|
+
customElements.define(tagName, ArcgisArcadeVariables);
|
|
178
|
+
}
|
|
179
|
+
break;
|
|
180
|
+
} });
|
|
179
181
|
}
|
|
180
182
|
defineCustomElement();
|
|
181
183
|
|
|
@@ -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
|
-
|
|
6
|
-
|
|
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
|
-
|
|
6
|
-
|
|
5
|
+
prototype: ArcgisArcadeEditor;
|
|
6
|
+
new (): ArcgisArcadeEditor;
|
|
7
7
|
};
|
|
8
8
|
/**
|
|
9
9
|
* Used to define this component and all nested components recursively.
|