@vertigis/workflow 5.44.0 → 5.45.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/Activator.d.ts +1 -1
- package/Hooks.d.ts +2 -2
- package/IActivityHandler.d.ts +2 -2
- package/ProgramInspectorFacility.d.ts +1 -1
- package/ProgramInspectorFacility.js +1 -1
- package/TemplateUtils.js +1 -1
- package/Validation.d.ts +31 -31
- package/Validation.js +1 -1
- package/activities/arcgis/AddFeatureLayer.d.ts +1 -1
- package/activities/arcgis/AddFeatureLayer.js +1 -1
- package/activities/arcgis/AddFeatures.d.ts +1 -1
- package/activities/arcgis/ConvertValueToArcGisFieldType.d.ts +2 -2
- package/activities/arcgis/CreateGraphic.d.ts +1 -1
- package/activities/arcgis/DeleteFeatures.d.ts +1 -1
- package/activities/arcgis/FeatureSetFromJson.d.ts +1 -1
- package/activities/arcgis/GeometryFromJson.d.ts +1 -1
- package/activities/arcgis/GeoprocessingAsync.js +1 -1
- package/activities/arcgis/GetCurrentPosition.js +1 -1
- package/activities/arcgis/GetFormElementItemsFromFeatures.js +1 -1
- package/activities/arcgis/MapProvider.d.ts +23 -2
- package/activities/arcgis/MapProvider.js +1 -1
- package/activities/arcgis/ProjectServiceTask.d.ts +1 -1
- package/activities/arcgis/QueryTask.js +1 -1
- package/activities/arcgis/RelationServiceTask.js +1 -1
- package/activities/arcgis/RendererFromJson.d.ts +1 -1
- package/activities/arcgis/ResetLayerDefinitionExpression.d.ts +24 -0
- package/activities/arcgis/ResetLayerDefinitionExpression.js +1 -0
- package/activities/arcgis/ReverseGeocode.d.ts +1 -1
- package/activities/arcgis/RunWorkflow.js +1 -1
- package/activities/arcgis/SetImageryLayerOptions.d.ts +2 -2
- package/activities/arcgis/SetMap.d.ts +1 -1
- package/activities/arcgis/SetMap.js +1 -1
- package/activities/arcgis/SymbolFromJson.d.ts +1 -1
- package/activities/arcgis/TypeChecking.d.ts +0 -7
- package/activities/arcgis/TypeChecking.js +1 -1
- package/activities/arcgis/UpdateFeatures.d.ts +1 -1
- package/activities/arcgis/libs/arcGisRestApi.d.ts +1 -1
- package/activities/arcgis/shared.d.ts +1 -1
- package/activities/arcgis/shared.js +1 -1
- package/activities/arcgis/tools.js +1 -1
- package/activities/constants.js +1 -1
- package/activities/core/ChannelProvider.d.ts +2 -2
- package/activities/core/ChannelProvider.js +1 -1
- package/activities/core/ConvertToJson.d.ts +1 -1
- package/activities/core/ExecuteFunction.js +1 -1
- package/activities/core/FormatDate.d.ts +39 -1
- package/activities/core/FormatDate.js +1 -1
- package/activities/core/GetWorkflowInputs.d.ts +1 -1
- package/activities/core/ParseUrl.js +1 -1
- package/activities/core/SetProperty.d.ts +1 -1
- package/activities/core/TextReplace.js +1 -1
- package/activities/core/converters.d.ts +1 -1
- package/activities/essentials/RunEssentialsWorkflow.js +1 -1
- package/activities/forms/FormRenderer.js +1 -1
- package/activities/forms/GetFormElementItemsFromCollection.js +1 -1
- package/activities/forms/SetCurrentFormElementItem.js +1 -1
- package/activities/forms/SetFormElementEvent.js +1 -1
- package/activities/index.js +1 -1
- package/definition/ActivityInput.d.ts +1 -1
- package/definition/Program.d.ts +11 -6
- package/definition/ProgramInspector.d.ts +9 -2
- package/definition/ProgramInspector.js +1 -1
- package/execution/ActivityContext.js +1 -1
- package/execution/AmbientState.d.ts +5 -5
- package/execution/AmbientState.js +1 -1
- package/execution/AmbientStateProxy.d.ts +4 -4
- package/execution/Engine.d.ts +4 -4
- package/execution/Engine.js +1 -1
- package/execution/ModuleLoader.d.ts +1 -1
- package/forms/FormComponent.d.ts +1 -1
- package/forms/FormDefinition.d.ts +4 -4
- package/forms/FormHost.d.ts +2 -2
- package/forms/FormPresenterHost.d.ts +2 -2
- package/forms/components/AutoComplete.js +1 -1
- package/forms/components/ButtonBar.js +1 -1
- package/forms/components/CheckBox.js +1 -1
- package/forms/components/CheckGroup.js +1 -1
- package/forms/components/DateRangePicker.js +1 -1
- package/forms/components/DateTimePicker.js +1 -1
- package/forms/components/DateTimeTextField.js +1 -1
- package/forms/components/FormElement.js +1 -1
- package/forms/components/GeometryPicker.js +1 -1
- package/forms/components/ItemPicker.js +1 -1
- package/forms/components/Number.js +1 -1
- package/forms/components/NumberRangeSlider.js +1 -1
- package/forms/components/NumberSlider.js +1 -1
- package/forms/components/RadioGroup.js +1 -1
- package/forms/components/Scanner.js +1 -1
- package/forms/components/Section.js +1 -1
- package/forms/components/TextBox.js +1 -1
- package/forms/components/TimePicker.js +1 -1
- package/forms/customNumberFormat.js +1 -1
- package/forms/index.d.ts +2 -4
- package/forms/numberFormatter.js +1 -1
- package/forms/numberUtilities.js +1 -1
- package/forms/presenter.d.ts +3 -3
- package/forms/textUtilities.js +1 -1
- package/forms/utils.js +1 -1
- package/libs/version.d.ts +1 -1
- package/libs/version.js +1 -1
- package/package.json +8 -7
|
@@ -28,4 +28,4 @@ export type ActivityInput = Expression | boolean | number | string;
|
|
|
28
28
|
/** Defines an annotation for an activity input. */
|
|
29
29
|
export type AnnotationKind = "idref";
|
|
30
30
|
export type ActivityInputExpression = Expression;
|
|
31
|
-
export declare function isActivityInputExpression(input: ActivityInput): input is ActivityInputExpression;
|
|
31
|
+
export declare function isActivityInputExpression(input: ActivityInput | undefined): input is ActivityInputExpression;
|
package/definition/Program.d.ts
CHANGED
|
@@ -12,18 +12,23 @@ import type { Transition } from "./Transition";
|
|
|
12
12
|
export interface Program extends Resource {
|
|
13
13
|
/** Indicates the components of the program. */
|
|
14
14
|
components?: Component[];
|
|
15
|
+
/** Indicates details related to where the program is intended to be deployed. */
|
|
16
|
+
deploymentConfig?: DeploymentConfig;
|
|
15
17
|
/** Indicates the forms in the program. */
|
|
16
18
|
forms?: Form[];
|
|
17
|
-
/**
|
|
18
|
-
|
|
19
|
+
/**
|
|
20
|
+
* The unique ids of validation issues that have been hidden by the author in the designer.
|
|
21
|
+
* This is persisted in the workflow to allow them to remain hidden when it is loaded again.
|
|
22
|
+
*/
|
|
23
|
+
hiddenValidationIssues?: string[];
|
|
19
24
|
/** Indicates the references for the program. */
|
|
20
25
|
references?: Reference[];
|
|
21
|
-
/** Indicates the transitions in the program. */
|
|
22
|
-
transitions?: Transition[];
|
|
23
26
|
/** Indicates the start of the program. */
|
|
24
27
|
start?: Step;
|
|
28
|
+
/** Indicates the steps in the program. */
|
|
29
|
+
steps?: Step[];
|
|
25
30
|
/** Indicates the language strings in the program. */
|
|
26
31
|
strings?: Record<string, Record<string, string>>;
|
|
27
|
-
/** Indicates
|
|
28
|
-
|
|
32
|
+
/** Indicates the transitions in the program. */
|
|
33
|
+
transitions?: Transition[];
|
|
29
34
|
}
|
|
@@ -33,6 +33,8 @@ export declare class ProgramInspector {
|
|
|
33
33
|
protected components: ComponentList;
|
|
34
34
|
/** Indicates the forms being built. */
|
|
35
35
|
protected forms: FormList;
|
|
36
|
+
/** Any validation issues that have been hidden by the author in the designer. */
|
|
37
|
+
protected hiddenValidationIssues: Set<string>;
|
|
36
38
|
/** Indicates the references being built. */
|
|
37
39
|
protected references: ReferenceList;
|
|
38
40
|
/** Indicates the steps being built. */
|
|
@@ -180,6 +182,11 @@ export declare class ProgramInspector {
|
|
|
180
182
|
* Retrieves the default locale for the workflow.
|
|
181
183
|
*/
|
|
182
184
|
getDefaultLocale(): string;
|
|
185
|
+
/**
|
|
186
|
+
* This method returns the ids of Validation Issues that have been hidden by the author in the designer.
|
|
187
|
+
* @returns The ids of Validation Issues that have been hidden by the author in the designer.
|
|
188
|
+
*/
|
|
189
|
+
getHiddenValidationIssues(): Set<string>;
|
|
183
190
|
/**
|
|
184
191
|
* Retrieves the string lookups for the given locale.
|
|
185
192
|
* @param locale The locale of the strings to retrieve. Defaults to the invariant strings.
|
|
@@ -248,7 +255,7 @@ declare class ComponentList extends ResourceList<Component, ComponentIncident> {
|
|
|
248
255
|
create(): Component;
|
|
249
256
|
qualify(name: string): string;
|
|
250
257
|
unlink(incident: ComponentIncident): number;
|
|
251
|
-
relate(incident: ComponentIncident
|
|
258
|
+
relate(incident: ComponentIncident): Iterable<Activity>;
|
|
252
259
|
}
|
|
253
260
|
declare class FormList extends ResourceList<Form, Incident<Form>> {
|
|
254
261
|
create(): Form;
|
|
@@ -282,7 +289,7 @@ declare class TransitionList extends ResourceList<Transition, TransitionIncident
|
|
|
282
289
|
qualify(name: string): string;
|
|
283
290
|
siblings(incident: ComponentIncident): Dictionary<StepIncident | TransitionIncident>;
|
|
284
291
|
unlink(incident: TransitionIncident): number;
|
|
285
|
-
relate(incident: TransitionIncident
|
|
292
|
+
relate(incident: TransitionIncident): Iterable<Step>;
|
|
286
293
|
}
|
|
287
294
|
export type LocaleParts = {
|
|
288
295
|
language: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Dictionary,Iterator,Stash}from"../Collections.js";class ProgramInspector{constructor(t){this.incidents=new IncidentList,this.components=new ComponentList(this.incidents),this.forms=new FormList(this.incidents),this.references=new ReferenceList(this.incidents),this.steps=new StepList(this.incidents),this.transitions=new TransitionList(this.incidents),this.program=makeBlankProgram(),this.editorId=t}newId(t){return"number"==typeof t&&(this.incidents.nextId=t),this.incidents.newId()}exists(t){return void 0!==this.incidents.findFor(t)}find(t){t=this.incidents.find(t);return void 0!==t?t.resource:void 0}findComponent(t){return this.components.findWith(t)}findForm(t){return this.forms.findWith(t)}findReference(t){return this.references.findWith(t)}findStep(t){return this.steps.findWith(t)}findTransition(t){return this.transitions.findWith(t)}all(){return iterate(this.incidents)}allComponents(){return this.components.all()}allForms(){return this.forms.all()}allReferences(){return this.references.all()}allSteps(){return this.steps.all()}allTransitions(){return this.transitions.all()}addComponent(){return this.components.add().resource}addForm(){return this.forms.add().resource}addReference(){return this.references.add().resource}addStep(){return this.steps.add().resource}addTransition(r,n){const i=this.steps.findFor(r),s=this.steps.findFor(n);if(void 0!==i&&void 0!==s){let t=i.transitions;void 0===t&&(t=i.transitions=new Dictionary);let e=s.transitions;void 0===e&&(e=s.transitions=new Dictionary);const o=this.transitions.add(),a=o.resource;return o.source=i,a.source=r,t.assign(o.token,o),o.target=s,a.target=n,e.assign(o.token,o),i.branches=void 0,a}}cacheComponents(){return this.components.cache()}cacheForms(){return this.forms.cache()}cacheReference(){return this.references.cache()}cacheSteps(){return this.steps.cache()}cacheTransitions(){return this.transitions.cache()}relate(t,e){const r=1<arguments.length?branchToToken(e):void 0;return Iterator.from(t).map(t=>this.incidents.relate(t,r))}remove(e,n){var r=t=>{let e=0;!1===n&&this.isComponent(t)&&(e+=this.remove(this.relate(t)));const r=this.incidents.findFor(t);return void 0!==r&&(e+=r.master.unlink(r),this.start===r.resource&&(this.start=void 0)),e};if(Array.isArray(e)||e instanceof Iterator){let t=0;const i=Iterator.from(e);for(;i.next();)t+=r(i.current);return t}return 0<r(e)}removeComponent(t){return this.components.removeFor(t)}removeForm(t){return this.forms.removeFor(t)}removeReference(t){return this.references.removeFor(t)}removeStep(t){return!!this.steps.removeFor(t)&&(this.start===t&&(this.start=void 0),!0)}removeTransition(t){return this.transitions.removeFor(t)}shift(t,e){const r=this.incidents.findFor(t);return void 0!==r&&r.master.shift(r,e)}shiftComponent(t,e){return this.components.shiftFor(t,e)}shiftForm(t,e){return this.forms.shiftFor(t,e)}shiftReference(t,e){return this.references.shiftFor(t,e)}shiftStep(t,e){return this.steps.shiftFor(t,e)}shiftTransition(t,e){return this.transitions.shiftFor(t,e)}rename(t,e){const r=this.incidents.findFor(t);return void 0!==r?r.master.rename(r,e):void 0}renameComponent(t,e){return this.components.renameFor(t,e)}renameForm(t,e){return this.forms.renameFor(t,e)}renameReference(t,e){return this.references.renameFor(t,e)}renameStep(t,e){return this.steps.renameFor(t,e)}renameTransition(t,e){return this.transitions.renameFor(t,e)}changeStart(t){return!!this.isStep(t)&&(this.start=t,!0)}changeBranch(t,e){const r=this.transitions.findFor(t);return void 0!==r&&(r.source.branches=void 0,t.branch="string"==typeof e?e:void 0,!0)}changeParent(t,e){let r=this.steps.findFor(t);if(void 0===r&&(r=this.transitions.findFor(t)),void 0===r)return!1;let n;return(null==e||(n=this.components.findFor(e),void 0!==n))&&(r.master.changeParent(r,n),!0)}changeSource(t,e){const r=this.transitions.findFor(t);if(void 0===r)return!1;const n=this.steps.findFor(e);if(void 0===n)return!1;r.source.branches=void 0,r.source!==r.target&&r.source.transitions.remove(r.token);let i=n.transitions;return void 0===i&&(i=n.transitions=new Dictionary),r.source=n,t.source=e,n.branches=void 0,i.assign(r.token,r),!0}changeTarget(t,e){const r=this.transitions.findFor(t);if(void 0===r)return!1;const n=this.steps.findFor(e);if(void 0===n)return!1;r.target!==r.source&&r.target.transitions.remove(r.token);let i=n.transitions;return void 0===i&&(i=n.transitions=new Dictionary),r.target=n,t.target=e,i.assign(r.token,r),!0}isComponent(t){return void 0!==this.components.findFor(t)}isParent(t,e){return this.isActivity(e)&&e.parent===t}isForm(t){return void 0!==this.forms.findFor(t)}isActivity(t){return this.isStep(t)||this.isTransition(t)}isReference(t){return void 0!==this.references.findFor(t)}isStep(t){return void 0!==this.steps.findFor(t)}isTransition(t){return void 0!==this.transitions.findFor(t)}isSource(t,e){return this.isTransition(t)&&t.source===e}isTarget(t,e){return this.isTransition(t)&&t.target===e}getDeploymentConfig(){return this.program.deploymentConfig||{supportedApps:{}}}getDefaultLocale(){return navigator.language||"inv"}getStrings(t){var e,r=this.program.strings||{};t=t||this.getDefaultLocale();let n={...r.inv||{}};return"inv"===t||(t=canonicalizeLocale(t))&&(t!==(e=parseLocale(t).language)&&e in r&&(n={...n,...r[e]}),t in r&&(n={...n,...r[t]})),n}realize(){this.program.components=this.allComponents().list(),this.program.forms=this.allForms().list(),this.program.references=this.allReferences().list(),this.program.steps=this.allSteps().list(),this.program.transitions=this.allTransitions().list(),this.program.start=this.start;const t=this.allComponents();for(;t.next();)t.current.steps=[],t.current.transitions=[];const e=this.allSteps();for(;e.next();){const n=e.current;n.transitions=[];const i=n.parent;void 0!==i&&i.steps.push(n)}const r=this.allTransitions();for(;r.next();){const s=r.current,o=s.parent;void 0!==o&&o.transitions.push(s),s.source.transitions.push(s),s.target!==s.source&&s.target.transitions.push(s)}}release(){this.program.components=[],this.program.forms=[],this.program.references=[],this.program.steps=[],this.program.transitions=[],this.program.start=void 0;const t=this.allComponents();for(;t.next();)t.current.steps=[],t.current.transitions=[];const e=this.allSteps();for(;e.next();)e.current.transitions=[]}resolveStart(t){if("number"==typeof t)return this.findStep(t);if("string"==typeof t)return this.findStep(t);if("object"!=typeof t||null===t)return this.start;var e=t.id;if("number"==typeof e)return this.findStep(e);t=t.name;return"string"==typeof t?this.findStep(t):void 0}import(t,n,s){if("object"!=typeof(t="string"==typeof t?JSON.parse(t):t)||null===t)return{};"function"!=typeof s&&(s=void 0),n=!1!==n;const i={},o={},a=new Stash,c=(t,e)=>{copyResource(t,e);let r=t.id,n=t.name;void 0!==s&&("number"==typeof(i=s(r,n))?(r=i,n=void 0):"string"==typeof i?(r=void 0,n=i):"object"==typeof i&&null!==i?(r=i.id,n=i.name):!0!==i&&(r=void 0,n=void 0)),"number"==typeof r&&(this.shift(e,r),o[r]=e),"string"==typeof n&&this.rename(e,n);var i="number"==typeof r?"id$"+r:"auto";return a.write(i,t,e),e};function u(t,e,r){var n=e.id;if("number"!=typeof n)return c(e,r());t+=n,n=i[t];return void 0===n?c(e,i[t]=r()):c(e,n)}const r=()=>this.addComponent();function h(t){const e=u("component$",t,r);return y(t.steps,t=>p(t,e)),y(t.transitions,t=>v(t,e)),e}const e=()=>this.addForm();const d=()=>this.addReference();const f=()=>this.addStep(),p=(t,e)=>{const r=u("step$",t,f);return this.changeParent(r,g(t.parent,h)||r.parent||e),y(t.transitions,t=>v(t,n?e:void 0,r)),r},m=this.addStep(),l=()=>this.addTransition(m,m),v=(t,e,r)=>{var n=u("transition$",t,()=>l());this.changeParent(n,g(t.parent,h)||n.parent||e);e=n.source!==m?n.source:void 0;this.changeSource(n,g(t.source,p)||e||r);e=n.target!==m?n.target:void 0;return this.changeTarget(n,g(t.target,p)||e||r),n};function g(t,e){if(isObject(t)){var r=t.id,r="number"==typeof r?"id$"+r:"auto";return a.read(r,t)||e(t)}}function y(t,e){if(Array.isArray(t))for(const r of t)g(r,e)}copyResource(t,this.program),y(t.components,h),y(t.forms,function(t){return u("form$",t,e)}),y(t.references,function(t){return u("reference$",t,d)}),y(t.steps,p),y(t.transitions,v),o.start=g(t.start,p),void 0===s&&(this.start=o.start);let F;var k=t=>(void 0===F&&(F=this.addStep(),this.changeParent(F,t)),F);const b=this.relate(m);for(;b.next();){F=void 0;var L=b.current;L.source===m&&this.changeSource(L,k(L.parent)),L.target===m&&this.changeTarget(L,k(L.parent))}return this.removeStep(m),this.realize(),o}export(){this.realize();const t=new ProgramInspector;t.import(this.program,!1);const e=t.program;e.steps=minifyArray(e.steps,function(e){return e.transitions=minifyArray(e.transitions,function(t){return t.source===e&&t.parent===e.parent&&(t.parent=void 0,t.source=void 0,t.target=t.target!==t.source?{id:t.target.id}:void 0,!0)}),void 0===e.parent}),e.transitions=minifyArray(e.transitions,function(t){return void 0===t.parent&&void 0!==t.source&&(t.source={id:t.source.id},t.target={id:t.target.id},!0)}),e.components=minifyArray(e.components,function(t){return t.steps=minifyArray(t.steps,function(t){return!(t.parent=void 0)}),t.transitions=minifyArray(t.transitions,function(t){return void 0!==t.parent&&(t.parent=void 0,t.source={id:t.source.id},t.target={id:t.target.id},!0)}),!0}),e.forms=minifyArray(e.forms),e.references=minifyArray(e.references);var r=t.start;return e.start=void 0!==r?{id:r.id}:void 0,e}reset(){this.incidents.clear(),this.components.clear(),this.forms.clear(),this.references.clear(),this.steps.clear(),this.transitions.clear(),this.incidents.nextId=1,this.program=makeBlankProgram(),this.start=void 0}toJSON(){return this.export()}}function iterate(t){return void 0===t?Iterator.empty:t.iterate().filter(function(t,e){return 0===String(e).lastIndexOf("token$",0)}).map(t=>t.resource,t=>t.id)}class IncidentList extends Dictionary{constructor(){super(...arguments),this.nextId=1}findFor(t){if(null!=t){var e=this.find(t.id);if(void 0!==e&&e.resource===t)return e}}newId(){let t=this.nextId;for(;this.exists(t);)t++;return this.nextId=t+1,t}relate(t,e){const r=this.findFor(t);return void 0!==r?r.master.relate(r,e):Iterator.empty}}class ResourceList extends Dictionary{constructor(t){super(),this.incidents=t}all(){return iterate(this)}cache(){let t=this.cacheLookup;if(void 0!==t)return t;t=this.cacheLookup={};const e=this.iterate();for(;e.next();){var r=e.current.resource,n=(t[r.id]=r).name;void 0!==n&&(t["$"+n]=r)}return t}findFor(t){t=this.incidents.findFor(t);return this.test(t)?t:void 0}test(t){return void 0!==t&&t.master===this}findWith(t){"string"==typeof t&&(t=this.qualify(t));t=this.incidents.find(t);return this.test(t)?t.resource:void 0}shift(t,e){this.incidents.remove(t.resource.id),"number"!=typeof e&&(e=this.incidents.newId());const r=this.incidents.assign(t.resource.id=e,t);void 0!==r&&this.incidents.assign(r.resource.id=this.incidents.newId(),r),this.cacheLookup=void 0}shiftFor(t,e){t=this.findFor(t);return void 0!==t&&(this.shift(t,e),!0)}rename(t,e){var r=t.resource.name;if(void 0!==r&&this.incidents.remove(this.qualify(r)),"string"==typeof e){e=this.qualify(t.resource.name=e);const n=this.incidents.assign(e,t);void 0!==n&&(n.resource.name=void 0)}else t.resource.name=void 0;return this.cacheLookup=void 0,r}renameFor(t,e){t=this.findFor(t);return void 0!==t&&(this.rename(t,e),!0)}add(){const t={},e=t.resource=this.create();return t.token=generateToken(),t.master=this,e.id=this.incidents.newId(),this.assign(t.token,t),this.incidents.assign(e.id,t),this.cacheLookup=void 0,t}removeFor(t){t=this.findFor(t);return void 0!==t&&(this.unlink(t),!0)}unlink(t){this.remove(t.token),this.cacheLookup=void 0;var e=t.resource.id;this.incidents.remove(e);t=t.resource.name;return void 0!==t&&this.incidents.remove(this.qualify(t)),1}relate(t,e){return Iterator.empty}changeParent(t,e){var r=t.parent;void 0!==r&&this.siblings(r).remove(t.token),void 0!==e?(t.parent=e,t.resource.parent=e.resource,this.siblings(e).assign(t.token,t)):(t.parent=void 0,t.resource.parent=void 0)}}class ComponentList extends ResourceList{create(){return{steps:[],transitions:[]}}qualify(t){return"component$"+t}unlink(t){super.unlink(t);const e=t.steps;if(void 0!==e){const n=e.iterate();for(;n.next();)n.current.resource.parent=void 0}const r=t.transitions;if(void 0!==r){const i=r.iterate();for(;i.next();)i.current.resource.parent=void 0}return 1}relate(t,e){const r=iterate(t.steps);t=iterate(t.transitions);return r.concat(t)}}class FormList extends ResourceList{create(){return{defaults:{},elements:{}}}qualify(t){return"form$"+t}}class ReferenceList extends ResourceList{create(){return{suite:"",path:""}}qualify(t){return"reference$"+t}}class StepList extends ResourceList{create(){return{inputs:{},transitions:[]}}qualify(t){return"activity$"+t}siblings(t){return t.steps||(t.steps=new Dictionary)}unlink(t){let e=super.unlink(t);void 0!==t.parent&&t.parent.steps.remove(t.token);const r=t.transitions;if(void 0!==r){const n=r.iterate();for(;n.next();)e+=n.current.master.unlink(n.current)}return e}relate(t,e){var r=t.transitions;if(void 0===r)return Iterator.empty;if(void 0===e)return iterate(r);let n=t.branches;if(void 0===n){n=t.branches={};for(const s of iterate(r).list().sort(compareTransitions))if(s.source===t.resource){var i=branchToToken(s.branch);const o=n[i];void 0===o?n[i]=s:Array.isArray(o)?o.push(s):n[i]=[o,s]}}return n[e]||Iterator.empty}}class TransitionList extends ResourceList{create(){return{inputs:{}}}qualify(t){return"activity$"+t}siblings(t){return t.transitions||(t.transitions=new Dictionary)}unlink(t){return super.unlink(t),t.source.branches=void 0,t.source.transitions.remove(t.token),t.target.transitions.remove(t.token),void 0!==t.parent&&t.parent.transitions.remove(t.token),1}relate(t,e){return t.source!==t.target?[t.source.resource,t.target.resource]:t.source.resource}}const safeProps={id:!1,name:!1,components:!1,elements:!0,forms:!1,references:!1,steps:!1,transitions:!1,start:!1,parent:!1,source:!1,target:!1,suite:!0,path:!0};function copyResource(t,e){for(const r in t)!1!==safeProps[r]&&(e[r]=deepClone(t[r]))}function deepClone(t){if(null!=t){if(Array.isArray(t))return t.map(deepClone);if("object"!=typeof t)return t;{const r={};for(const n in t){var e=t[n];null!=e&&(r[n]=e)}return r}}}function isObject(t){return!Array.isArray(t)&&("object"==typeof t&&null!==t)}function makeBlankProgram(){return{components:[],forms:[],references:[],steps:[],transitions:[]}}function minifyArray(e,r){let n=0;for(let t=0;t<e.length;t++){var i=e[t];void 0!==r&&!r(i)||(e[n++]=i)}return e.length=n,0<e.length?e:void 0}function branchToToken(t){return void 0!==t?"string$"+t:"blank"}function hasInputs(t){for(const e in t)return!0;return!1}function compareTransitions(t,e){return"number"==typeof t.rank?"number"!=typeof e.rank||t<e?-1:e<t?1:0:"number"==typeof e.rank?1:hasInputs(t)?hasInputs(e)?0:-1:hasInputs(e)?1:0}const generateToken=function(){let t,e;function r(){t=0,e="token$"+(new Date).valueOf()+"$"}r();return function(){return 1073741824<=t&&r(),e+t++}}();function parseLocale(t){if("string"==typeof t){const e=t.split("-");if(!(e.length<1||3<e.length||e.some(t=>0===t.length))){const r={language:e[0].toLowerCase()};return 2==e.length?2==e[1].length?r.territory=e[1].toUpperCase():r.script=e[1][0].toUpperCase()+e[1].slice(1).toLowerCase():3===e.length&&(r.script=e[1][0].toUpperCase()+e[1].slice(1).toLowerCase(),r.territory=e[2].toUpperCase()),r}}}function canonicalizeLocale(e){e=parseLocale(e);if(e){let t=e.language;return e.script&&(t+="-"+e.script),e.territory&&(t+="-"+e.territory),t}}export{ProgramInspector,parseLocale,canonicalizeLocale};
|
|
1
|
+
import{Dictionary,Iterator,Stash}from"../Collections.js";class ProgramInspector{constructor(t){this.incidents=new IncidentList,this.components=new ComponentList(this.incidents),this.forms=new FormList(this.incidents),this.hiddenValidationIssues=new Set,this.references=new ReferenceList(this.incidents),this.steps=new StepList(this.incidents),this.transitions=new TransitionList(this.incidents),this.program=makeBlankProgram(),this.editorId=t}newId(t){return"number"==typeof t&&(this.incidents.nextId=t),this.incidents.newId()}exists(t){return void 0!==this.incidents.findFor(t)}find(t){t=this.incidents.find(t);return void 0!==t?t.resource:void 0}findComponent(t){return this.components.findWith(t)}findForm(t){return this.forms.findWith(t)}findReference(t){return this.references.findWith(t)}findStep(t){return this.steps.findWith(t)}findTransition(t){return this.transitions.findWith(t)}all(){return iterate(this.incidents)}allComponents(){return this.components.all()}allForms(){return this.forms.all()}allReferences(){return this.references.all()}allSteps(){return this.steps.all()}allTransitions(){return this.transitions.all()}addComponent(){return this.components.add().resource}addForm(){return this.forms.add().resource}addReference(){return this.references.add().resource}addStep(){return this.steps.add().resource}addTransition(r,n){const i=this.steps.findFor(r),s=this.steps.findFor(n);if(void 0!==i&&void 0!==s){let t=i.transitions;void 0===t&&(t=i.transitions=new Dictionary);let e=s.transitions;void 0===e&&(e=s.transitions=new Dictionary);const o=this.transitions.add(),a=o.resource;return o.source=i,a.source=r,t.assign(o.token,o),o.target=s,a.target=n,e.assign(o.token,o),i.branches=void 0,a}}cacheComponents(){return this.components.cache()}cacheForms(){return this.forms.cache()}cacheReference(){return this.references.cache()}cacheSteps(){return this.steps.cache()}cacheTransitions(){return this.transitions.cache()}relate(t,e){const r=1<arguments.length?branchToToken(e):void 0;return Iterator.from(t).map(t=>this.incidents.relate(t,r))}remove(e,n){var r=t=>{let e=0;!1===n&&this.isComponent(t)&&(e+=this.remove(this.relate(t)));const r=this.incidents.findFor(t);return void 0!==r&&(e+=r.master.unlink(r),this.start===r.resource&&(this.start=void 0)),e};if(Array.isArray(e)||e instanceof Iterator){let t=0;const i=Iterator.from(e);for(;i.next();)t+=r(i.current);return t}return 0<r(e)}removeComponent(t){return this.components.removeFor(t)}removeForm(t){return this.forms.removeFor(t)}removeReference(t){return this.references.removeFor(t)}removeStep(t){return!!this.steps.removeFor(t)&&(this.start===t&&(this.start=void 0),!0)}removeTransition(t){return this.transitions.removeFor(t)}shift(t,e){const r=this.incidents.findFor(t);return void 0!==r&&r.master.shift(r,e)}shiftComponent(t,e){return this.components.shiftFor(t,e)}shiftForm(t,e){return this.forms.shiftFor(t,e)}shiftReference(t,e){return this.references.shiftFor(t,e)}shiftStep(t,e){return this.steps.shiftFor(t,e)}shiftTransition(t,e){return this.transitions.shiftFor(t,e)}rename(t,e){const r=this.incidents.findFor(t);return void 0!==r?r.master.rename(r,e):void 0}renameComponent(t,e){return this.components.renameFor(t,e)}renameForm(t,e){return this.forms.renameFor(t,e)}renameReference(t,e){return this.references.renameFor(t,e)}renameStep(t,e){return this.steps.renameFor(t,e)}renameTransition(t,e){return this.transitions.renameFor(t,e)}changeStart(t){return!!this.isStep(t)&&(this.start=t,!0)}changeBranch(t,e){const r=this.transitions.findFor(t);return void 0!==r&&(r.source.branches=void 0,t.branch="string"==typeof e?e:void 0,!0)}changeParent(t,e){let r=this.steps.findFor(t);if(void 0===r&&(r=this.transitions.findFor(t)),void 0===r)return!1;let n;return(null==e||(n=this.components.findFor(e),void 0!==n))&&(r.master.changeParent(r,n),!0)}changeSource(t,e){const r=this.transitions.findFor(t);if(void 0===r)return!1;const n=this.steps.findFor(e);if(void 0===n)return!1;r.source.branches=void 0,r.source!==r.target&&r.source.transitions.remove(r.token);let i=n.transitions;return void 0===i&&(i=n.transitions=new Dictionary),r.source=n,t.source=e,n.branches=void 0,i.assign(r.token,r),!0}changeTarget(t,e){const r=this.transitions.findFor(t);if(void 0===r)return!1;const n=this.steps.findFor(e);if(void 0===n)return!1;r.target!==r.source&&r.target.transitions.remove(r.token);let i=n.transitions;return void 0===i&&(i=n.transitions=new Dictionary),r.target=n,t.target=e,i.assign(r.token,r),!0}isComponent(t){return void 0!==this.components.findFor(t)}isParent(t,e){return this.isActivity(e)&&e.parent===t}isForm(t){return void 0!==this.forms.findFor(t)}isActivity(t){return this.isStep(t)||this.isTransition(t)}isReference(t){return void 0!==this.references.findFor(t)}isStep(t){return void 0!==this.steps.findFor(t)}isTransition(t){return void 0!==this.transitions.findFor(t)}isSource(t,e){return this.isTransition(t)&&t.source===e}isTarget(t,e){return this.isTransition(t)&&t.target===e}getDeploymentConfig(){return this.program.deploymentConfig||{supportedApps:{}}}getDefaultLocale(){return navigator.language||"inv"}getHiddenValidationIssues(){return this.hiddenValidationIssues}getStrings(t){var e,r=this.program.strings||{};t=t||this.getDefaultLocale();let n={...r.inv||{}};return"inv"===t||(t=canonicalizeLocale(t))&&(t!==(e=parseLocale(t).language)&&e in r&&(n={...n,...r[e]}),t in r&&(n={...n,...r[t]})),n}realize(){this.program.components=this.allComponents().list(),this.program.forms=this.allForms().list(),this.program.hiddenValidationIssues=[...this.hiddenValidationIssues],this.program.references=this.allReferences().list(),this.program.steps=this.allSteps().list(),this.program.transitions=this.allTransitions().list(),this.program.start=this.start;const t=this.allComponents();for(;t.next();)t.current.steps=[],t.current.transitions=[];const e=this.allSteps();for(;e.next();){const n=e.current;n.transitions=[];const i=n.parent;void 0!==i&&i.steps.push(n)}const r=this.allTransitions();for(;r.next();){const s=r.current,o=s.parent;void 0!==o&&o.transitions.push(s),s.source.transitions.push(s),s.target!==s.source&&s.target.transitions.push(s)}}release(){this.program.components=[],this.program.forms=[],this.program.hiddenValidationIssues=[],this.program.references=[],this.program.steps=[],this.program.transitions=[],this.program.start=void 0;const t=this.allComponents();for(;t.next();)t.current.steps=[],t.current.transitions=[];const e=this.allSteps();for(;e.next();)e.current.transitions=[]}resolveStart(t){if("number"==typeof t)return this.findStep(t);if("string"==typeof t)return this.findStep(t);if("object"!=typeof t||null===t)return this.start;var e=t.id;if("number"==typeof e)return this.findStep(e);t=t.name;return"string"==typeof t?this.findStep(t):void 0}import(t,n,s){if("object"!=typeof(t="string"==typeof t?JSON.parse(t):t)||null===t)return{};"function"!=typeof s&&(s=void 0),n=!1!==n;const i={},o={},a=new Stash,c=(t,e)=>{copyResource(t,e);let r=t.id,n=t.name;void 0!==s&&("number"==typeof(i=s(r,n))?(r=i,n=void 0):"string"==typeof i?(r=void 0,n=i):"object"==typeof i&&null!==i?(r=i.id,n=i.name):!0!==i&&(r=void 0,n=void 0)),"number"==typeof r&&(this.shift(e,r),o[r]=e),"string"==typeof n&&this.rename(e,n);var i="number"==typeof r?"id$"+r:"auto";return a.write(i,t,e),e};function u(t,e,r){var n=e.id;if("number"!=typeof n)return c(e,r());t+=n,n=i[t];return void 0===n?c(e,i[t]=r()):c(e,n)}const r=()=>this.addComponent();function d(t){const e=u("component$",t,r);return y(t.steps,t=>p(t,e)),y(t.transitions,t=>v(t,e)),e}const e=()=>this.addForm();const h=()=>this.addReference();const f=()=>this.addStep(),p=(t,e)=>{const r=u("step$",t,f);return this.changeParent(r,g(t.parent,d)||r.parent||e),y(t.transitions,t=>v(t,n?e:void 0,r)),r},m=this.addStep(),l=()=>this.addTransition(m,m),v=(t,e,r)=>{var n=u("transition$",t,()=>l());this.changeParent(n,g(t.parent,d)||n.parent||e);e=n.source!==m?n.source:void 0;this.changeSource(n,g(t.source,p)||e||r);e=n.target!==m?n.target:void 0;return this.changeTarget(n,g(t.target,p)||e||r),n};function g(t,e){if(isObject(t)){var r=t.id,r="number"==typeof r?"id$"+r:"auto";return a.read(r,t)||e(t)}}function y(t,e){if(Array.isArray(t))for(const r of t)g(r,e)}copyResource(t,this.program),y(t.components,d),y(t.forms,function(t){return u("form$",t,e)}),y(t.references,function(t){return u("reference$",t,h)}),y(t.steps,p),y(t.transitions,v),this.hiddenValidationIssues=new Set(t.hiddenValidationIssues??[]),o.start=g(t.start,p),void 0===s&&(this.start=o.start);let F;var k=t=>(void 0===F&&(F=this.addStep(),this.changeParent(F,t)),F);const I=this.relate(m);for(;I.next();){F=void 0;var S=I.current;S.source===m&&this.changeSource(S,k(S.parent)),S.target===m&&this.changeTarget(S,k(S.parent))}return this.removeStep(m),this.realize(),o}export(){this.realize();const t=new ProgramInspector;t.import(this.program,!1);const e=t.program;e.steps=minifyArray(e.steps,function(e){return e.transitions=minifyArray(e.transitions,function(t){return t.source===e&&t.parent===e.parent&&(t.parent=void 0,t.source=void 0,t.target=t.target!==t.source?{id:t.target.id}:void 0,!0)}),void 0===e.parent}),e.transitions=minifyArray(e.transitions,function(t){return void 0===t.parent&&void 0!==t.source&&(t.source={id:t.source.id},t.target={id:t.target.id},!0)}),e.components=minifyArray(e.components,function(t){return t.steps=minifyArray(t.steps,function(t){return!(t.parent=void 0)}),t.transitions=minifyArray(t.transitions,function(t){return void 0!==t.parent&&(t.parent=void 0,t.source={id:t.source.id},t.target={id:t.target.id},!0)}),!0}),e.forms=minifyArray(e.forms),e.hiddenValidationIssues=minifyArray(e.hiddenValidationIssues??[]),e.references=minifyArray(e.references);var r=t.start;return e.start=void 0!==r?{id:r.id}:void 0,e}reset(){this.incidents.clear(),this.components.clear(),this.forms.clear(),this.references.clear(),this.steps.clear(),this.transitions.clear(),this.incidents.nextId=1,this.program=makeBlankProgram(),this.start=void 0}toJSON(){return this.export()}}function iterate(t){return void 0===t?Iterator.empty:t.iterate().filter(function(t,e){return 0===String(e).lastIndexOf("token$",0)}).map(t=>t.resource,t=>t.id)}class IncidentList extends Dictionary{constructor(){super(...arguments),this.nextId=1}findFor(t){if(null!=t){var e=this.find(t.id);if(void 0!==e&&e.resource===t)return e}}newId(){let t=this.nextId;for(;this.exists(t);)t++;return this.nextId=t+1,t}relate(t,e){const r=this.findFor(t);return void 0!==r?r.master.relate(r,e):Iterator.empty}}class ResourceList extends Dictionary{constructor(t){super(),this.incidents=t}all(){return iterate(this)}cache(){let t=this.cacheLookup;if(void 0!==t)return t;t=this.cacheLookup={};const e=this.iterate();for(;e.next();){var r=e.current.resource,n=(t[r.id]=r).name;void 0!==n&&(t["$"+n]=r)}return t}findFor(t){t=this.incidents.findFor(t);return this.test(t)?t:void 0}test(t){return void 0!==t&&t.master===this}findWith(t){"string"==typeof t&&(t=this.qualify(t));t=this.incidents.find(t);return this.test(t)?t.resource:void 0}shift(t,e){this.incidents.remove(t.resource.id),"number"!=typeof e&&(e=this.incidents.newId());const r=this.incidents.assign(t.resource.id=e,t);void 0!==r&&this.incidents.assign(r.resource.id=this.incidents.newId(),r),this.cacheLookup=void 0}shiftFor(t,e){t=this.findFor(t);return void 0!==t&&(this.shift(t,e),!0)}rename(t,e){var r=t.resource.name;if(void 0!==r&&this.incidents.remove(this.qualify(r)),"string"==typeof e){e=this.qualify(t.resource.name=e);const n=this.incidents.assign(e,t);void 0!==n&&(n.resource.name=void 0)}else t.resource.name=void 0;return this.cacheLookup=void 0,r}renameFor(t,e){t=this.findFor(t);return void 0!==t&&(this.rename(t,e),!0)}add(){const t={},e=t.resource=this.create();return t.token=generateToken(),t.master=this,e.id=this.incidents.newId(),this.assign(t.token,t),this.incidents.assign(e.id,t),this.cacheLookup=void 0,t}removeFor(t){t=this.findFor(t);return void 0!==t&&(this.unlink(t),!0)}unlink(t){this.remove(t.token),this.cacheLookup=void 0;var e=t.resource.id;this.incidents.remove(e);t=t.resource.name;return void 0!==t&&this.incidents.remove(this.qualify(t)),1}relate(t,e){return Iterator.empty}changeParent(t,e){var r=t.parent;void 0!==r&&this.siblings(r).remove(t.token),void 0!==e?(t.parent=e,t.resource.parent=e.resource,this.siblings(e).assign(t.token,t)):(t.parent=void 0,t.resource.parent=void 0)}}class ComponentList extends ResourceList{create(){return{steps:[],transitions:[]}}qualify(t){return"component$"+t}unlink(t){super.unlink(t);const e=t.steps;if(void 0!==e){const n=e.iterate();for(;n.next();)n.current.resource.parent=void 0}const r=t.transitions;if(void 0!==r){const i=r.iterate();for(;i.next();)i.current.resource.parent=void 0}return 1}relate(t){const e=iterate(t.steps);t=iterate(t.transitions);return e.concat(t)}}class FormList extends ResourceList{create(){return{defaults:{},elements:{}}}qualify(t){return"form$"+t}}class ReferenceList extends ResourceList{create(){return{suite:"",path:""}}qualify(t){return"reference$"+t}}class StepList extends ResourceList{create(){return{inputs:{},transitions:[]}}qualify(t){return"activity$"+t}siblings(t){return t.steps||(t.steps=new Dictionary)}unlink(t){let e=super.unlink(t);void 0!==t.parent&&t.parent.steps.remove(t.token);const r=t.transitions;if(void 0!==r){const n=r.iterate();for(;n.next();)e+=n.current.master.unlink(n.current)}return e}relate(t,e){var r=t.transitions;if(void 0===r)return Iterator.empty;if(void 0===e)return iterate(r);let n=t.branches;if(void 0===n){n=t.branches={};for(const s of iterate(r).list().sort(compareTransitions))if(s.source===t.resource){var i=branchToToken(s.branch);const o=n[i];void 0===o?n[i]=s:Array.isArray(o)?o.push(s):n[i]=[o,s]}}return n[e]||Iterator.empty}}class TransitionList extends ResourceList{create(){return{inputs:{}}}qualify(t){return"activity$"+t}siblings(t){return t.transitions||(t.transitions=new Dictionary)}unlink(t){return super.unlink(t),t.source.branches=void 0,t.source.transitions.remove(t.token),t.target.transitions.remove(t.token),void 0!==t.parent&&t.parent.transitions.remove(t.token),1}relate(t){return t.source!==t.target?[t.source.resource,t.target.resource]:t.source.resource}}const safeProps={id:!1,name:!1,components:!1,elements:!0,forms:!1,hiddenValidationIssues:!1,references:!1,steps:!1,transitions:!1,start:!1,parent:!1,source:!1,target:!1,suite:!0,path:!0};function copyResource(t,e){for(const r in t)!1!==safeProps[r]&&(e[r]=deepClone(t[r]))}function deepClone(t){if(null!=t){if(Array.isArray(t))return t.map(deepClone);if("object"!=typeof t)return t;{const r={};for(const n in t){var e=t[n];null!=e&&(r[n]=e)}return r}}}function isObject(t){return!Array.isArray(t)&&("object"==typeof t&&null!==t)}function makeBlankProgram(){return{components:[],forms:[],hiddenValidationIssues:[],references:[],steps:[],transitions:[]}}function minifyArray(e,r){let n=0;for(let t=0;t<e.length;t++){var i=e[t];void 0!==r&&!r(i)||(e[n++]=i)}return e.length=n,0<e.length?e:void 0}function branchToToken(t){return void 0!==t?"string$"+t:"blank"}function hasInputs(t){for(const e in t)return!0;return!1}function compareTransitions(t,e){return"number"==typeof t.rank?"number"!=typeof e.rank||t<e?-1:e<t?1:0:"number"==typeof e.rank?1:hasInputs(t)?hasInputs(e)?0:-1:hasInputs(e)?1:0}const generateToken=function(){let t,e;function r(){t=0,e="token$"+(new Date).valueOf()+"$"}r();return function(){return 1073741824<=t&&r(),e+t++}}();function parseLocale(t){if("string"==typeof t){const e=t.split("-");if(!(e.length<1||3<e.length||e.some(t=>0===t.length))){const r={language:e[0].toLowerCase()};return 2==e.length?2==e[1].length?r.territory=e[1].toUpperCase():r.script=e[1][0].toUpperCase()+e[1].slice(1).toLowerCase():3===e.length&&(r.script=e[1][0].toUpperCase()+e[1].slice(1).toLowerCase(),r.territory=e[2].toUpperCase()),r}}}function canonicalizeLocale(e){e=parseLocale(e);if(e){let t=e.language;return e.script&&(t+="-"+e.script),e.territory&&(t+="-"+e.territory),t}}export{ProgramInspector,parseLocale,canonicalizeLocale};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import Bluebird from"bluebird";import{ExpressionEvaluationError,ExpressionSyntaxError,ExpressionAccessorError,ActivityBindingError,ActivityActivationError,ActivityError,GenericActivityError,AggregateActivityError}from"../Errors.js";import{query}from"../Hooks.js";import{isAccessor,isExpression,isLiteral}from"./util.js";const echoHandler={execute:t=>t}
|
|
1
|
+
import Bluebird from"bluebird";import{ExpressionEvaluationError,ExpressionSyntaxError,ExpressionAccessorError,ActivityBindingError,ActivityActivationError,ActivityError,GenericActivityError,AggregateActivityError}from"../Errors.js";import{query}from"../Hooks.js";import{isAccessor,isExpression,isLiteral}from"./util.js";const echoHandler={execute:t=>t},evaluators={};function compileExpression(t,i){var e=t.code;let r=evaluators[e];if(void 0===r){const n=[],o={};n.push('"use strict"; ');var s=t.accessors;if(Array.isArray(s))for(const c of s)isAccessor(c)&&!o[c]&&(n.push(`var ${c} = this.${c};`),o[c]=!0);n.push("return "),n.push(e),n.push(";"),r=evaluators[e]=new Function("resources","values",n.join(""))}return function(){return r.call(this,i,t.values)}}class PromiseWrapper{}class ActivityContext{constructor(){this.action="",this.activity={},this.ambient={},this.frame={},this.proxy={},this.passes=0,this.inputs={},this.outputs={},this.extras=[],this.monikers=[],this.evaluators={},this.scope={},this.cancellationToken={},this.cancellationResolve=()=>{}}static filterErrors(t){return t.filter(ActivityContext.isError)}static isError(t){return void 0!==t}static isInvalidHandler(t){return null==t||"function"!=typeof t.execute}static reduceErrors(t){return t.isPending()?t.then(ActivityContext.filterErrors):t.isFulfilled()?Bluebird.resolve(ActivityContext.filterErrors(t.value())):t}registerForErrors(){this.registeredForErrors=!0}persist(t){this.stateToPersist=t}call(t){this.callBranch=!0,this.forkBranch=!1,this.jumpBranch=t}fork(t){this.callBranch=!1,this.forkBranch=!0,this.jumpBranch=t}jump(t){this.callBranch=!1,this.forkBranch=!1,this.jumpBranch=t}hasBranch(t){var i=this.activity;const e=this.ambient.inspector;return e.isStep(i)&&void 0!==e.relate(i,t).peek()}emitExpressionEvaluationError(t,i){var e=this.activity.id,r=this.activity.inputs[t];return new ExpressionEvaluationError(e,t,r.source||r.code,i)}emitExpressionSyntaxError(t,i){var e=this.activity.id,r=this.activity.inputs[t];return new ExpressionSyntaxError(e,t,r.source||r.code,i)}emitExpressionAccessorError(t,i,e){return new ExpressionAccessorError(this.activity.id,t,i,e)}emitActivityBindingError(t){var i=this.activity;return new ActivityBindingError(i.id,i.action,t)}emitActivityActivationError(t,i){return new ActivityActivationError(this.activity.id,t,i)}emitActivityError(t){if(t instanceof ActivityError)return t;var i=this.activity;const e=new GenericActivityError(void 0,t?.message);return e.activityId=i.id,e.error=t,e}executeHandlerInline(i){if(0<i.length||this.cancellationToken.isFulfilled())return i;const e=this.extras;for(let t=0;t<e.length;t++)e[t]=Bluebird.resolve(e[t]).value();const r=this.inputs;for(const o in r){let t=Bluebird.resolve(r[o]).value();t instanceof PromiseWrapper&&(t=t.result),r[o]=t}const t=this.proxy,s=this.handler.value(),n=Bluebird.attempt(function(){return s.execute(r,t,...e)});return n.isPending()?n.then(t=>(this.outputs=t,i),t=>[this.emitActivityError(t)]):n.isRejected()?[this.emitActivityError(n.reason())]:(this.outputs=n.value(),i)}resolveExtrasInline(){for(const i of query(this.handler.value())){const t=this.ambient.engine.activator,e=t.activate(i);if(this.extras.push(e),e.isPending())return e.then(()=>{},t=>this.emitActivityActivationError(i.type,t));if(e.isRejected())return this.emitActivityActivationError(i.type,e.reason())}}resolveInputsInline(t){if(0<t.length||this.cancellationToken.isFulfilled())return t;const i=[];i.push(this.resolveExtrasInline());const e=this.evaluators;if(void 0!==e){const r=this.scope;for(const n in r)r[n]=Bluebird.resolve(r[n]).value();const s=this.inputs;for(const o in e){const c=s[o]=Bluebird.attempt(function(){var t=e[o].call(r,void 0,void 0);if(t&&"function"==typeof t.then){const i=new PromiseWrapper;return i.result=t,i}return t});c.isPending()&&i.push(c.then(()=>{},t=>this.emitExpressionEvaluationError(o,t))),c.isRejected()&&i.push(this.emitExpressionEvaluationError(o,c.reason()))}}return ActivityContext.reduceErrors(Bluebird.all(i))}resolveHandlerInline(){const i=this.activity.action;if("string"==typeof i){var e=this.ambient;const r=e.handlers;let t=this.handler=r[i];if(void 0===t){const s=e.engine,n=e.inspector;t=this.handler=r[i]=Bluebird.attempt(function(){return s.createHandler(i,n)})}return t.isPending()?t.then(t=>ActivityContext.isInvalidHandler(t)?this.emitActivityBindingError():void 0,t=>this.emitActivityBindingError(t)):t.isRejected()?this.emitActivityBindingError(t.reason()):ActivityContext.isInvalidHandler(t.value())?this.emitActivityBindingError():void 0}this.handler=Bluebird.resolve(echoHandler)}findContext(t){var i=this.ambient,e=i.stack;let r=i.frame;for(;void 0!==r;){var s=r.state[t];if(void 0!==s)return s;r=e[r.index-1]}}resolveOutputsInline(){const t=this.promise;if(t.isPending())return t.then(t=>void 0!==t&&0<t.length?Bluebird.reject(t):this.outputs,()=>{});if(t.isRejected())return Bluebird.resolve(void 0);var i=t.value();return void 0!==i&&0<i.length?Bluebird.reject(i):Bluebird.resolve(this.outputs)}resolveAccessorInline(i){const t=this.findContext(i);if(void 0!==t){const e=this.scope[i]=t.resolveOutputsInline();return e.isPending()?e.then(()=>{},t=>this.emitExpressionAccessorError(i,void 0,t)):e.isRejected()?this.emitExpressionAccessorError(i,void 0,e.reason()):void 0}const e=this.scope[i]=Bluebird.resolve(this.ambient.environment[i]);return e.isPending()?e.then(()=>{},t=>this.emitExpressionAccessorError(i,t)):e.isRejected()?this.emitExpressionAccessorError(i,e.reason()):void 0}resolveAssetsInline(){const e=[];e.push(this.resolveHandlerInline());var r=this.activity.inputs;if(null!=r){let t,i;const n=this.ambient;for(const o in r){const c=r[o];if(void 0!==c&&null!==c)if(isLiteral(c))this.inputs[o]=Bluebird.resolve(c);else if(isExpression(c)){void 0===t&&(this.scope=t={}),void 0===i&&(this.evaluators=i={});var s=c.accessors;if(Array.isArray(s))for(const l of s)"string"==typeof l&&void 0===t[l]&&e.push(this.resolveAccessorInline(l));const a=Bluebird.attempt(function(){return compileExpression(c,n.resources)});a.isFulfilled()?i[o]=a.value():e.push(this.emitExpressionSyntaxError(o,a.reason()))}else e.push(this.emitExpressionSyntaxError(o))}}return ActivityContext.reduceErrors(Bluebird.all(e))}concludeInline(t){return this.cancellationResolve(),t}generateMonikers(){const t=this.monikers;var i=this.activity;t.push("$"+i.id),"string"==typeof i.name&&t.push("$"+i.name);const e=i.action;"string"!=typeof e||1<(i=e.split(":")).length&&(0<(i=i[i.length-2]).length&&t.push("$$"+i))}marshalError(){var t=this.promise.value();return 1<t.length?new AggregateActivityError(this.activity.id,t):0<t.length?t[0]:void 0}execute(){let t=this.promise;const i=this.ambient;if(void 0!==t)return i.debug(i),i.halted||this.transferInline(),t;{if(t=this.resolveAssetsInline(),t.isRejected())return t;if(t=t.isPending()?t.then(t=>this.resolveInputsInline(t)):Bluebird.resolve(this.resolveInputsInline(t.value())),t.isRejected())return t;if(t=t.isPending()?t.then(t=>this.executeHandlerInline(t)):Bluebird.resolve(this.executeHandlerInline(t.value())),t.isRejected())return t;if(t=t.isPending()?t.then(t=>this.concludeInline(t)):Bluebird.resolve(this.concludeInline(t.value())),t.isRejected())return t;t.isPending()&&(t=t.catch(t=>i.fail(t)),t.then(()=>i.execute())),this.generateMonikers();const e=i.frame.state;for(const r of this.monikers)e[r]=this;return this.promise=t,Bluebird.resolve(void 0)}}goto(){}}export default ActivityContext;
|
|
@@ -32,8 +32,8 @@ declare class AmbientState implements IDebugSession, IAmbientState {
|
|
|
32
32
|
logLevel: LogLevel | undefined;
|
|
33
33
|
outputs: Record<string, any>;
|
|
34
34
|
printingServiceUrl: string | undefined;
|
|
35
|
-
removeExternalEventHandler: (
|
|
36
|
-
setExternalEventHandler: (
|
|
35
|
+
removeExternalEventHandler: (callback: ExternalEventCallback) => void;
|
|
36
|
+
setExternalEventHandler: (callback: ExternalEventCallback) => void;
|
|
37
37
|
trivia: Record<string, any> | undefined;
|
|
38
38
|
frame: MonikerFrame | undefined;
|
|
39
39
|
queue: Transition[];
|
|
@@ -42,8 +42,8 @@ declare class AmbientState implements IDebugSession, IAmbientState {
|
|
|
42
42
|
get activityContexts(): Record<string, ActivityContext>;
|
|
43
43
|
cancellationResolve: () => void;
|
|
44
44
|
cancellationToken: Task<void>;
|
|
45
|
-
completion: Bluebird<
|
|
46
|
-
resolveCompletion: (result:
|
|
45
|
+
completion: Bluebird<object>;
|
|
46
|
+
resolveCompletion: (result: object) => void;
|
|
47
47
|
rejectCompletion: (error: any) => void;
|
|
48
48
|
scheduler: Bluebird<void>;
|
|
49
49
|
proxy: AmbientStateProxy;
|
|
@@ -53,7 +53,7 @@ declare class AmbientState implements IDebugSession, IAmbientState {
|
|
|
53
53
|
break(): void;
|
|
54
54
|
continue(): void;
|
|
55
55
|
execute(action?: () => void): boolean;
|
|
56
|
-
complete(outputs?:
|
|
56
|
+
complete(outputs?: object): void;
|
|
57
57
|
reject(error?: any): void;
|
|
58
58
|
fail(thrown?: any): void;
|
|
59
59
|
cancel(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import Bluebird from"bluebird";import{ActivityCancellationError,EngineRuntimeError}from"../Errors.js";import{Task}from"../Task.js";import ActivityContextProxy from"./ActivityContextProxy.js";import AsyncContext from"./AsyncContext.js";import MonikerFrame from"./MonikerFrame.js";import StepContext from"./StepContext.js";import TransitionContext from"./TransitionContext.js";import{newSymbol}from"./util.js";class AmbientState{constructor(){this.debug=()=>{},this.engine={},this.inspector={},this.id="",this.environment={},this.inputs={},this.outputs={},this.removeExternalEventHandler=t=>{},this.setExternalEventHandler=t=>{},this.frame=new MonikerFrame,this.queue=[],this.stack=[],this.handlers={},this.cancellationResolve=()=>{},this.cancellationToken={},this.completion={},this.resolveCompletion=()=>{},this.rejectCompletion=()=>{},this.scheduler={},this.proxy={},this.inline=!1,this.halted=!1}get activityContexts(){const t={};for(const e of[...this.stack,this.frame])for(const i in e.state)"$$"===i.substring(0,2)&&(t[i]=e.state[i]);return t}static createLinkedCancellationToken(t,e){const i=Task.race([new Task(e),t]),n=new AbortController;return i.signal=n.signal,i.finally(()=>n.abort()),i}break(){this.halted=!0}continue(){this.halted=!1,void 0!==this.scheduler&&!this.scheduler.isFulfilled()||(this.scheduler=Bluebird.resolve(void 0).then(
|
|
1
|
+
import Bluebird from"bluebird";import{ActivityCancellationError,EngineRuntimeError}from"../Errors.js";import{Task}from"../Task.js";import ActivityContextProxy from"./ActivityContextProxy.js";import AsyncContext from"./AsyncContext.js";import MonikerFrame from"./MonikerFrame.js";import StepContext from"./StepContext.js";import TransitionContext from"./TransitionContext.js";import{newSymbol}from"./util.js";class AmbientState{constructor(){this.debug=()=>{},this.engine={},this.inspector={},this.id="",this.environment={},this.inputs={},this.outputs={},this.removeExternalEventHandler=t=>{},this.setExternalEventHandler=t=>{},this.frame=new MonikerFrame,this.queue=[],this.stack=[],this.handlers={},this.cancellationResolve=()=>{},this.cancellationToken={},this.completion={},this.resolveCompletion=()=>{},this.rejectCompletion=()=>{},this.scheduler={},this.proxy={},this.inline=!1,this.halted=!1}get activityContexts(){const t={};for(const e of[...this.stack,this.frame])for(const i in e.state)"$$"===i.substring(0,2)&&(t[i]=e.state[i]);return t}static createLinkedCancellationToken(t,e){const i=Task.race([new Task(e),t]),n=new AbortController;return i.signal=n.signal,i.finally(()=>n.abort()),i}break(){this.halted=!0}continue(){this.halted=!1,void 0!==this.scheduler&&!this.scheduler.isFulfilled()||(this.scheduler=Bluebird.resolve(void 0).then(()=>{this.execute()}))}execute(t){if(this.inline)return!1;this.inline=!0;try{void 0!==t&&t();const e=this.completion;for(;e.isPending();){if(this.halted)return!1;const i=this.frame.current.execute();if(i.isPending())break;i.isRejected()&&this.fail(i.reason())}}catch(t){this.fail(t)}finally{this.inline=!1}return!0}complete(t){this.completion.isPending()&&(this.cancellationResolve(),this.resolveCompletion(t||this.outputs))}reject(t){this.completion.isPending()&&(this.cancellationResolve(),this.rejectCompletion(t||this.error))}fail(t){this.completion.isPending()&&(this.cancellationResolve(),this.rejectCompletion(new EngineRuntimeError(t)))}cancel(){this.completion.isPending()&&(this.cancellationResolve(),this.rejectCompletion(new ActivityCancellationError))}push(){const t=this.stack;t.push(this.frame);const e=this.frame=new MonikerFrame;return e.index=t.length,e}pop(t){const e=this.frame;if(void 0!==e){e.current=void 0;const n=e.cancellationResolve;void 0!==n&&n()}var i=this.frame=this.stack.pop();return void 0===i&&(void 0!==t?this.reject(t):this.complete()),i}call(){var t=this.frame;const e=this.push();e.cancellationToken=t.cancellationToken,e.state=t.state}fork(){const e=this.push();e.cancellationToken=AmbientState.createLinkedCancellationToken(this.cancellationToken,t=>e.cancellationResolve=t),e.state={}}bubble(t){let e=this.pop(t);for(;void 0!==e&&!e.current.registeredForErrors;)e=this.pop(t);var i;void 0!==e&&(i=e.current,this.start(i.activity,i,t))}next(){var t=this.queue.pop();void 0!==t?this.attempt(t):void 0!==(t=this.pop())&&(t=t.current,this.start(t.activity,t))}prepare(e,t,i){const n=e.frame=this.frame;if((n.current=e).luid=this.id+":"+e.activity.id,e.action=e.activity.action,e.ambient=this,e.id=newSymbol(),e.caught=i,e.cancellationToken=AmbientState.createLinkedCancellationToken(n.cancellationToken,t=>e.cancellationResolve=t),e.proxy=new ActivityContextProxy(e),void 0!==t){const s=e.recent=t.recent||(t.recent={});t=s.context||t;(s.context=e).passes=t.passes+1,e.stateToPersist=e.state=t.stateToPersist}else e.passes=0}attempt(t){const e=new TransitionContext;e.activity=t,e.branch=t.branch,this.prepare(e)}start(t,e,i){const n=new(t.async?AsyncContext:StepContext);n.activity=t,n.monikers.push("$"),this.prepare(n,e,i)}enqueue(t,e){const i=this.inspector;this.queue=i.relate(t,e).list(),this.next()}goto(t){for(var e=this.stack,i=t.index;e[i]===t;)this.pop();return t===this.frame}}export default AmbientState;
|
|
@@ -7,12 +7,12 @@ import type { LogLevel } from "../diagnostics/logging";
|
|
|
7
7
|
* A proxy of the AmbientState so that callers cannot influence the guts of the engine.
|
|
8
8
|
*/
|
|
9
9
|
declare class AmbientStateProxy extends Proxy<AmbientState> implements IAmbientState {
|
|
10
|
-
get outputs():
|
|
11
|
-
set outputs(outputs:
|
|
10
|
+
get outputs(): object;
|
|
11
|
+
set outputs(outputs: object);
|
|
12
12
|
get error(): Error | undefined;
|
|
13
13
|
set error(error: Error | undefined);
|
|
14
|
-
get completion(): Bluebird<
|
|
15
|
-
complete(outputs?:
|
|
14
|
+
get completion(): Bluebird<object>;
|
|
15
|
+
complete(outputs?: object): void;
|
|
16
16
|
reject(error?: Error): void;
|
|
17
17
|
get environment(): Record<string, any>;
|
|
18
18
|
get inputs(): Record<string, any>;
|
package/execution/Engine.d.ts
CHANGED
|
@@ -18,13 +18,13 @@ export interface RunOptions {
|
|
|
18
18
|
/** Indicates a debugger callback. */
|
|
19
19
|
debug?: (session: IDebugSession) => void;
|
|
20
20
|
/** Indicates any environment that may be relevant to the program being run. */
|
|
21
|
-
environment?:
|
|
21
|
+
environment?: object;
|
|
22
22
|
/** Indicates the locale for the program being run. */
|
|
23
23
|
locale?: string;
|
|
24
24
|
/** Indicates the logging level for the program being run. */
|
|
25
25
|
logLevel?: LogLevel;
|
|
26
26
|
/** Indicates any inputs that may be relevant to the program being run. */
|
|
27
|
-
inputs?:
|
|
27
|
+
inputs?: object;
|
|
28
28
|
/** The printing engine URL used for sending print requests. */
|
|
29
29
|
printingServiceUrl?: string;
|
|
30
30
|
/** Indicates the start step to start at. */
|
|
@@ -91,8 +91,8 @@ export declare class Engine {
|
|
|
91
91
|
/** Creates a handler for the given action. */
|
|
92
92
|
createHandler(action: string, inspector?: ProgramInspector): PromiseLike<IActivityHandler | undefined> | IActivityHandler | undefined;
|
|
93
93
|
/** Runs a program and returns a promise for the outputs. */
|
|
94
|
-
run(document: Program, options?: RunOptions): Task<
|
|
95
|
-
run(inspector: ProgramInspector, options?: RunOptions): Task<
|
|
94
|
+
run(document: Program, options?: RunOptions): Task<object>;
|
|
95
|
+
run(inspector: ProgramInspector, options?: RunOptions): Task<object>;
|
|
96
96
|
/**
|
|
97
97
|
* Adds an event from an external source (the host application) to the current workflow.
|
|
98
98
|
* This will be ignored unless there is currently a callback function registered to process it.
|
package/execution/Engine.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import Bluebird from"bluebird";import{Activator}from"../Activator.js";import{getStringsForProgram}from"../LanguageStringUtils.js";import{Task}from"../Task.js";import{ProgramInspector,canonicalizeLocale}from"../definition/ProgramInspector.js";import{getCachedFormElements}from"../execution/ActivityLoader.js";import{BuiltInFormElements}from"../forms/manifest.js";import{check as checkLicense}from"../licensing/LicenseChecker.js";import{run}from"./ProgramRunner.js";class Engine{constructor(e){this._getFormElementRegistration=e=>this.formElements[e],this._registerFormElement=e=>{var t,r=e["id"];this.formElements[r]?(t={...this.formElements[r],...e},this.formElements[r]=t):this.formElements[r]=e},this.activator=new Activator,this.environment={},this.trivia={getFormElementRegistration:this._getFormElementRegistration,registerFormElement:this._registerFormElement},this.factories=[],this.implementations={},this.formElements={...getCachedFormElements(),...BuiltInFormElements},this.appSkuCode=e}setExternalEventHandler(e){this.externalEventCallback=e}removeExternalEventHandler(e){e===this.externalEventCallback&&(this.externalEventCallback=void 0)}static buildOptions(e,t){(t={...t||{}}).locale=canonicalizeLocale(t.locale),t.locale||(t.locale=e.getDefaultLocale()),t.logLevel=t.logLevel||"log";var r=new Proxy({},{get(e,t
|
|
1
|
+
import Bluebird from"bluebird";import{Activator}from"../Activator.js";import{getStringsForProgram}from"../LanguageStringUtils.js";import{Task}from"../Task.js";import{ProgramInspector,canonicalizeLocale}from"../definition/ProgramInspector.js";import{getCachedFormElements}from"../execution/ActivityLoader.js";import{BuiltInFormElements}from"../forms/manifest.js";import{check as checkLicense}from"../licensing/LicenseChecker.js";import{run}from"./ProgramRunner.js";class Engine{constructor(e){this._getFormElementRegistration=e=>this.formElements[e],this._registerFormElement=e=>{var t,r=e["id"];this.formElements[r]?(t={...this.formElements[r],...e},this.formElements[r]=t):this.formElements[r]=e},this.activator=new Activator,this.environment={},this.trivia={getFormElementRegistration:this._getFormElementRegistration,registerFormElement:this._registerFormElement},this.factories=[],this.implementations={},this.formElements={...getCachedFormElements(),...BuiltInFormElements},this.appSkuCode=e}setExternalEventHandler(e){this.externalEventCallback=e}removeExternalEventHandler(e){e===this.externalEventCallback&&(this.externalEventCallback=void 0)}static buildOptions(e,t){(t={...t||{}}).locale=canonicalizeLocale(t.locale),t.locale||(t.locale=e.getDefaultLocale()),t.logLevel=t.logLevel||"log";var r=new Proxy({},{get(e,t){return t}});const n=getStringsForProgram(e,t);return t.environment={activities:r,encodeHtml:function(e){return"string"==typeof e?e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"):""},getText:function(e){if("string"==typeof e&&"@"===e.charAt(0)){var t=e.slice(1);if(t in n)return n[t]}return e},strings:n,...t.environment||{}},t}createHandler(e,t){var r=this.implementations[e];if(void 0!==r){const i=Bluebird.resolve(r);return i.isFulfilled()?new(i.value()):i.then(function(e){return Bluebird.attempt(function(){return new e})})}for(const o of this.factories){var n=o.create(e,this._registerFormElement,t);if(void 0!==n)return n}}run(r,n){return Task.attempt(()=>{let e;r instanceof ProgramInspector?e=r:(e=new ProgramInspector,e.import(r)),checkLicense(e.program,this.appSkuCode),n=Engine.buildOptions(e,n);var t=e.resolveStart(n?n.start:void 0);return run(this,e,n,t)})}enqueueExternalEvent(e){this.externalEventCallback&&this.externalEventCallback(e)}}export{Engine};
|
|
@@ -11,4 +11,4 @@ export declare function registerModuleName(url: string): string;
|
|
|
11
11
|
* @param options The options to send.
|
|
12
12
|
* @param prefix The prefix as it is understood.
|
|
13
13
|
*/
|
|
14
|
-
export declare function importModule(path: string, options:
|
|
14
|
+
export declare function importModule(path: string, options: object, prefix?: string): Promise<object>;
|
package/forms/FormComponent.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ export interface FormComponentProps {
|
|
|
26
26
|
children: React.JSX.Element[];
|
|
27
27
|
}
|
|
28
28
|
/** @product This is intended for internal use only within VertiGIS Studio products. */
|
|
29
|
-
export declare class FormComponent extends Component<FormComponentProps,
|
|
29
|
+
export declare class FormComponent extends Component<FormComponentProps, object> {
|
|
30
30
|
id: string | undefined;
|
|
31
31
|
autoInput: boolean | undefined;
|
|
32
32
|
enabled: boolean;
|
|
@@ -95,7 +95,7 @@ export interface GeometryRef {
|
|
|
95
95
|
/** Indicates the format of the value. */
|
|
96
96
|
format: GeometryFormat;
|
|
97
97
|
/** Indicates the geometry. */
|
|
98
|
-
geometry:
|
|
98
|
+
geometry: object[];
|
|
99
99
|
}
|
|
100
100
|
/**
|
|
101
101
|
* References one or more items within the element.
|
|
@@ -342,7 +342,7 @@ export interface Element {
|
|
|
342
342
|
/**
|
|
343
343
|
* Indicates the current state.
|
|
344
344
|
*/
|
|
345
|
-
state?:
|
|
345
|
+
state?: object;
|
|
346
346
|
/** Indicates the style name to be used. */
|
|
347
347
|
styleName?: string;
|
|
348
348
|
/** Indicates the title for the element. */
|
|
@@ -417,9 +417,9 @@ export interface AutoCompleteState {
|
|
|
417
417
|
/** @product This is intended for internal use only within VertiGIS Studio products. */
|
|
418
418
|
export interface GeometryState {
|
|
419
419
|
/** Indicates the application specific context. */
|
|
420
|
-
context?:
|
|
420
|
+
context?: object;
|
|
421
421
|
/** Indicates the content. */
|
|
422
|
-
content?:
|
|
422
|
+
content?: object;
|
|
423
423
|
/** Indicates the checked state. */
|
|
424
424
|
checked?: boolean;
|
|
425
425
|
/** Indicates the focused state. */
|
package/forms/FormHost.d.ts
CHANGED
|
@@ -113,7 +113,7 @@ export declare abstract class FormHost implements FormPresenterHost {
|
|
|
113
113
|
*/
|
|
114
114
|
translateText(content: defs.Text | undefined): string | defs.MarkdownRef | undefined;
|
|
115
115
|
/** Renders the form component. */
|
|
116
|
-
renderVisual(component:
|
|
116
|
+
renderVisual(component: object): any;
|
|
117
117
|
/** Qualifies an event with defaults. */
|
|
118
118
|
protected qualifyDefault(event: defs.Event): string | undefined;
|
|
119
119
|
/** Qualifies an event. */
|
|
@@ -227,7 +227,7 @@ export declare abstract class FormHost implements FormPresenterHost {
|
|
|
227
227
|
/** Renders a component's state. */
|
|
228
228
|
renderState(name: string, type: "item-picker", state?: defs.ItemPickerState): boolean;
|
|
229
229
|
/** Renders a component's state. */
|
|
230
|
-
renderState(name: string, type: string, state?:
|
|
230
|
+
renderState(name: string, type: string, state?: object): boolean;
|
|
231
231
|
private getParentSection;
|
|
232
232
|
private isSectionCollapsed;
|
|
233
233
|
private isElementPositionBeforeLastFocused;
|
|
@@ -39,11 +39,11 @@ export interface FormPresenterHost {
|
|
|
39
39
|
/** Renders form text to display text. */
|
|
40
40
|
renderText(text: defs.Text | undefined): string;
|
|
41
41
|
/** Renders a component's visual. */
|
|
42
|
-
renderVisual(component:
|
|
42
|
+
renderVisual(component: object): any;
|
|
43
43
|
/** Renders a component's state. */
|
|
44
44
|
renderState(name: string, type: "geometry", state?: defs.GeometryState[]): boolean;
|
|
45
45
|
/** Renders a component's state. */
|
|
46
|
-
renderState(name: string, type: string, state?:
|
|
46
|
+
renderState(name: string, type: string, state?: object): boolean;
|
|
47
47
|
/** Find the element. */
|
|
48
48
|
find(name: string | {
|
|
49
49
|
name: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import BaseAutoComplete,{autocompleteClasses,HighlightOption}from"@vertigis/react-ui/Autocomplete";import FormLabelTextField from"@vertigis/react-ui/FormLabelTextField";import Popper from"@vertigis/react-ui/Popper";import Skeleton from"@vertigis/react-ui/Skeleton";import{styled}from"@vertigis/react-ui/styles";import clsx from"clsx";import{useContext,useEffect,useMemo,useRef,useState}from"react";import*as React from"react";import{ExclusiveTimer}from"../ExclusiveTimer.js";import{autoCompletePropertyConstraints}from"../elements/AutoComplete.js";import HostContext from"../hostContext.js";import{getKeyString}from"../keyboard.js";import{getItemId,inspectItems,makeSafeClassName}from"../utils.js";import FormElement from"./FormElement.js";import{useFocusCallback}from"./common.js";const StyledAutoComplete=styled(BaseAutoComplete)(()=>({[`.${autocompleteClasses.endAdornment}`]:{right:1}})),popperClasses={skeletonOption:"skeleton-option"},StyledPopper=styled(Popper)(()=>({[`.${autocompleteClasses.listbox}`]:{[`.${autocompleteClasses.option}`]:{display:"block",[`&.${popperClasses.skeletonOption}`]:{'&[data-option-index="0"]':{span:{width:"70%"}},'&[data-option-index="1"]':{span:{width:"85%"}},'&[data-option-index="2"]':{span:{width:"55%"}}}}}})),StyledSkeleton=styled(Skeleton)(()=>({fontSize:"1.25rem",lineHeight:"inherit"})),pendingOption={enabled:!1,label:""},pendingOptions=[pendingOption,pendingOption,pendingOption],AutoComplete=({className:e,component:t,current:u,delay:r,element:o,enabled:n,error:l,items:p,label:m,minLength:s,name:a,prompt:i,tooltip:c,raiseEvent:d,setProperty:f,setValue:g,value:C})=>{const v=useContext(HostContext),[y,x]=useState(),[b,h]=useState(""),[S,O]=useState([]),[E,k]=useState(null),P=useRef(!1),T=useRef(),I=useRef(!1),R=useRef(v.renderText({status:"trivial"})),N=v.renderText(i),F=v.renderText(c),A=useFocusCallback(n,a,v),L=useRef({}),j=useRef({}),w=useMemo(()=>{let e=r;return"number"==typeof e&&!isNaN(e)||(e=autoCompletePropertyConstraints.delay.default),Math.max(e,autoCompletePropertyConstraints.delay.minimum)},[r]),H=useMemo(()=>{let e=s;return"number"==typeof e&&!isNaN(e)||(e=autoCompletePropertyConstraints.minLength.default),Math.max(e,autoCompletePropertyConstraints.minLength.minimum)},[s]),M=t.timer||(t.timer=new ExclusiveTimer),B=()=>{d("suggest",C,b,void 0,M.cancellationToken),O(pendingOptions)},K=()=>{f("items",{}),f("label",void 0)};useEffect(()=>{"clear"===y?K():"input"===y&&(m&&f("label",void 0),P.current=!0,b.length>=H?(f("current",void 0),M.reset(),M.start(w,B)):0<Object.keys(p||{}).length&&K())},[y,b]),useEffect(()=>{var e,t,r=E?.value;C!==r&&(t=(e=getItemId(E,L.current))?j.current[e]:void 0,f("current",e),f("label",t),g(r,{argument:t}))},[E]),useEffect(()=>{const{current:e,items:t,label:r,value:o}=inspectItems(u,p,C);f("current",e),f("label",r||m),f("value",o,!1);const n={};let l=null;const s=[];for(const i in t){var a=t[i];s.push(a);const r=v.renderText(a.label).trim();n[i]=r,e&&i===e&&(l=a)}j.current=n,L.current=t,O(s),k(l)},[p]),useEffect(()=>{var e="string"==typeof u?u:void 0,t=e?L.current[e]:void 0,e=e?j.current[e]:void 0;t?(f("label",e),f("value",t.value),h(e||"")):(f("value",void 0),P.current||h("")),k(t||null)},[u]),useEffect(()=>{P.current||I.current||h(""),P.current=!1,I.current=!1},[m]);const $=v.renderText(m);return React.createElement(FormElement,{className:e,element:o,inputId:T.current,name:a},t=>React.createElement(StyledAutoComplete,{autoSelect:!0,clearOnEscape:!0,clearOnBlur:!1,disabled:!n,filterOptions:e=>e,getOptionDisabled:e=>!1===e.enabled,getOptionKey:e=>getItemId(e,L.current)||"",getOptionLabel:e=>{e=getItemId(e,L.current);return e?j.current[e]:""},inputValue:b,noOptionsText:R.current,onBlur:()=>{1===S.length&&b.toLowerCase()===j.current[0]?.toLowerCase()?(h(j.current[0]),k(S[0])):f("label",b)},onChange:(e,t
|
|
1
|
+
import BaseAutoComplete,{autocompleteClasses,HighlightOption}from"@vertigis/react-ui/Autocomplete";import FormLabelTextField from"@vertigis/react-ui/FormLabelTextField";import Popper from"@vertigis/react-ui/Popper";import Skeleton from"@vertigis/react-ui/Skeleton";import{styled}from"@vertigis/react-ui/styles";import clsx from"clsx";import{useContext,useEffect,useMemo,useRef,useState}from"react";import*as React from"react";import{ExclusiveTimer}from"../ExclusiveTimer.js";import{autoCompletePropertyConstraints}from"../elements/AutoComplete.js";import HostContext from"../hostContext.js";import{getKeyString}from"../keyboard.js";import{getItemId,inspectItems,makeSafeClassName}from"../utils.js";import FormElement from"./FormElement.js";import{useFocusCallback}from"./common.js";const StyledAutoComplete=styled(BaseAutoComplete)(()=>({[`.${autocompleteClasses.endAdornment}`]:{right:1}})),popperClasses={skeletonOption:"skeleton-option"},StyledPopper=styled(Popper)(()=>({[`.${autocompleteClasses.listbox}`]:{[`.${autocompleteClasses.option}`]:{display:"block",[`&.${popperClasses.skeletonOption}`]:{'&[data-option-index="0"]':{span:{width:"70%"}},'&[data-option-index="1"]':{span:{width:"85%"}},'&[data-option-index="2"]':{span:{width:"55%"}}}}}})),StyledSkeleton=styled(Skeleton)(()=>({fontSize:"1.25rem",lineHeight:"inherit"})),pendingOption={enabled:!1,label:""},pendingOptions=[pendingOption,pendingOption,pendingOption],AutoComplete=({className:e,component:t,current:u,delay:r,element:o,enabled:n,error:l,items:p,label:m,minLength:s,name:a,prompt:i,tooltip:c,raiseEvent:d,setProperty:f,setValue:g,value:C})=>{const v=useContext(HostContext),[y,x]=useState(),[b,h]=useState(""),[S,O]=useState([]),[E,k]=useState(null),P=useRef(!1),T=useRef(),I=useRef(!1),R=useRef(v.renderText({status:"trivial"})),N=v.renderText(i),F=v.renderText(c),A=useFocusCallback(n,a,v),L=useRef({}),j=useRef({}),w=useMemo(()=>{let e=r;return"number"==typeof e&&!isNaN(e)||(e=autoCompletePropertyConstraints.delay.default),Math.max(e,autoCompletePropertyConstraints.delay.minimum)},[r]),H=useMemo(()=>{let e=s;return"number"==typeof e&&!isNaN(e)||(e=autoCompletePropertyConstraints.minLength.default),Math.max(e,autoCompletePropertyConstraints.minLength.minimum)},[s]),M=t.timer||(t.timer=new ExclusiveTimer),B=()=>{d("suggest",C,b,void 0,M.cancellationToken),O(pendingOptions)},K=()=>{f("items",{}),f("label",void 0)};useEffect(()=>{"clear"===y?K():"input"===y&&(m&&f("label",void 0),P.current=!0,b.length>=H?(f("current",void 0),M.reset(),M.start(w,B)):0<Object.keys(p||{}).length&&K())},[y,b]),useEffect(()=>{var e,t,r=E?.value;C!==r&&(t=(e=getItemId(E,L.current))?j.current[e]:void 0,f("current",e),f("label",t),g(r,{argument:t}))},[E]),useEffect(()=>{const{current:e,items:t,label:r,value:o}=inspectItems(u,p,C);f("current",e),f("label",r||m),f("value",o,!1);const n={};let l=null;const s=[];for(const i in t){var a=t[i];s.push(a);const r=v.renderText(a.label).trim();n[i]=r,e&&i===e&&(l=a)}j.current=n,L.current=t,O(s),k(l)},[p]),useEffect(()=>{var e="string"==typeof u?u:void 0,t=e?L.current[e]:void 0,e=e?j.current[e]:void 0;t?(f("label",e),f("value",t.value),h(e||"")):(f("value",void 0),P.current||h("")),k(t||null)},[u]),useEffect(()=>{P.current||I.current||h(""),P.current=!1,I.current=!1},[m]);const $=v.renderText(m);return React.createElement(FormElement,{className:e,element:o,inputId:T.current,name:a},t=>React.createElement(StyledAutoComplete,{autoSelect:!0,clearOnEscape:!0,clearOnBlur:!1,disabled:!n,filterOptions:e=>e,getOptionDisabled:e=>!1===e.enabled,getOptionKey:e=>getItemId(e,L.current)||"",getOptionLabel:e=>{e=getItemId(e,L.current);return e?j.current[e]:""},inputValue:b,noOptionsText:R.current,onBlur:()=>{1===S.length&&b.toLowerCase()===j.current[0]?.toLowerCase()?(h(j.current[0]),k(S[0])):f("label",b)},onChange:(e,t)=>{I.current=!0,k(t)},onInputChange:(e,t,r)=>{h(t),x(r)},onKeyDown:e=>{"enter"===getKeyString(e)&&e.stopPropagation()},options:S,renderOption:(e,t,{inputValue:r})=>{if(t===pendingOption){var o=clsx(e.className,popperClasses.skeletonOption);return React.createElement("li",{...e,className:o,key:e.id},React.createElement(StyledSkeleton,null))}o=getItemId(t,L.current),o={...e,className:clsx(e.className,t.styleName?makeSafeClassName(t.styleName):void 0),title:t.tooltip?v.renderText(t.tooltip):void 0,inputText:r,optionText:o?j.current[o]:""};return React.createElement(HighlightOption,{...o})},renderInput:e=>(e.inputProps={...e.inputProps,...t,value:e.inputProps.value||$,placeholder:N,title:F},T.current=e.id,React.createElement(FormLabelTextField,{error:!!l,...e,fullWidth:!0,inputRef:A})),slotProps:{popper:{component:StyledPopper}},value:E}))};export default AutoComplete;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import Button from"@vertigis/react-ui/Button";import Stack,{stackClasses}from"@vertigis/react-ui/Stack";import{styled}from"@vertigis/react-ui/styles";import*as React from"react";import{useContext}from"react";import{Orientation}from"../constants.js";import HostContext from"../hostContext.js";import{makeSafeClassName,sortAndFilter}from"../utils.js";import FormElement from"./FormElement.js";import Markdown from"./Markdown.js";import{useFocusCallback}from"./common.js";const StyledFormElement=styled(FormElement)(({theme:{spacing:e}})=>({[`.${stackClasses.root}`]:{alignItems:"flex-start",flexWrap:"wrap",marginTop:e(1),marginBottom:e(1)}})),ButtonBar=({className:e,element:t,enabled:l,items:o,name:a,orientation:r,raiseEvent:c})=>{const d=useContext(HostContext),u=sortAndFilter(o),f=useFocusCallback(l,a,d);o=l?Object.entries(u).filter(e=>!1!==e[1].enabled&&!1!==e[1].visible)[0]:void 0;const p=o?o[0]:void 0;return React.createElement(StyledFormElement,{className:e,component:"fieldset",element:t,name:a},React.createElement(Stack,{direction:r===Orientation.VERTICAL?"column":"row",spacing:1},Object.keys(u).map(e=>{var t,o,a=u[e],r=a.styleName?makeSafeClassName(a.styleName):void 0,n=!1!==a.visible,i=l&&!1!==a.enabled&&n,s=d.renderText(a.tooltip),m=u[e]["value"];return n?React.createElement(Button,{className:r,color:a.default?"primary":"inherit",disabled:!i,key:e,onClick:(t=e,o=m,function(
|
|
1
|
+
import Button from"@vertigis/react-ui/Button";import Stack,{stackClasses}from"@vertigis/react-ui/Stack";import{styled}from"@vertigis/react-ui/styles";import*as React from"react";import{useContext}from"react";import{Orientation}from"../constants.js";import HostContext from"../hostContext.js";import{makeSafeClassName,sortAndFilter}from"../utils.js";import FormElement from"./FormElement.js";import Markdown from"./Markdown.js";import{useFocusCallback}from"./common.js";const StyledFormElement=styled(FormElement)(({theme:{spacing:e}})=>({[`.${stackClasses.root}`]:{alignItems:"flex-start",flexWrap:"wrap",marginTop:e(1),marginBottom:e(1)}})),ButtonBar=({className:e,element:t,enabled:l,items:o,name:a,orientation:r,raiseEvent:c})=>{const d=useContext(HostContext),u=sortAndFilter(o),f=useFocusCallback(l,a,d);o=l?Object.entries(u).filter(e=>!1!==e[1].enabled&&!1!==e[1].visible)[0]:void 0;const p=o?o[0]:void 0;return React.createElement(StyledFormElement,{className:e,component:"fieldset",element:t,name:a},React.createElement(Stack,{direction:r===Orientation.VERTICAL?"column":"row",spacing:1},Object.keys(u).map(e=>{var t,o,a=u[e],r=a.styleName?makeSafeClassName(a.styleName):void 0,n=!1!==a.visible,i=l&&!1!==a.enabled&&n,s=d.renderText(a.tooltip),m=u[e]["value"];return n?React.createElement(Button,{className:r,color:a.default?"primary":"inherit",disabled:!i,key:e,onClick:(t=e,o=m,function(){c("clicked",o,void 0,t)}),ref:p&&e===p?f:void 0,title:s,variant:a.default?"contained":"outlined"},React.createElement(Markdown,{inline:!0,text:a.label||""})):null})))};export default ButtonBar;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import Checkbox from"@vertigis/react-ui/Checkbox";import FormControlLabel from"@vertigis/react-ui/FormControlLabel";import*as React from"react";import{useContext}from"react";import HostContext from"../hostContext.js";import FormElement from"./FormElement.js";import Markdown from"./Markdown.js";import{useFocusCallback}from"./common.js";const CheckBox=({checked:t,className:e,element:o,enabled:r,label:a,name:c,raiseEvent:m,setProperty:n,tooltip:l,value:s})=>{const i=useContext(HostContext),C=i.renderText(l),d=useFocusCallback(r,c,i),k=e=>{e=e.target.checked;n("checked",e),m("changed",e?s:void 0,e)};return React.createElement(FormElement,{className:e,element:o,name:c},e=>React.createElement(FormControlLabel,{control:React.createElement(Checkbox,{checked:t,
|
|
1
|
+
import Checkbox from"@vertigis/react-ui/Checkbox";import FormControlLabel from"@vertigis/react-ui/FormControlLabel";import*as React from"react";import{useContext}from"react";import HostContext from"../hostContext.js";import FormElement from"./FormElement.js";import Markdown from"./Markdown.js";import{useFocusCallback}from"./common.js";const CheckBox=({checked:t,className:e,element:o,enabled:r,label:a,name:c,raiseEvent:m,setProperty:n,tooltip:l,value:s})=>{const i=useContext(HostContext),C=i.renderText(l),d=useFocusCallback(r,c,i),k=e=>{e=e.target.checked;n("checked",e),m("changed",e?s:void 0,e)};return React.createElement(FormElement,{className:e,element:o,name:c},e=>React.createElement(FormControlLabel,{control:React.createElement(Checkbox,{checked:t,onChange:k,slotProps:{input:{...e,ref:d}}}),disabled:!r,label:React.createElement(Markdown,{text:a}),title:C}))};export default CheckBox;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import Checkbox from"@vertigis/react-ui/Checkbox";import FormControlLabel from"@vertigis/react-ui/FormControlLabel";import FormGroup,{formGroupClasses}from"@vertigis/react-ui/FormGroup";import{styled}from"@vertigis/react-ui/styles";import*as React from"react";import{useContext,useEffect,useState}from"react";import{Orientation}from"../constants.js";import HostContext from"../hostContext.js";import{arrayEqual}from"../listUtilities.js";import{makeSafeClassName,inspectItems}from"../utils.js";import FormElement from"./FormElement.js";import Markdown from"./Markdown.js";import{useFocusCallback}from"./common.js";const StyledFormElement=styled(FormElement)(({theme:{spacing:e}})=>({[`.${formGroupClasses.root}`]:{paddingBottom:e(2)}})),CheckGroup=({className:e,current:m,element:t,enabled:o,items:n,name:r,orientation:a,raiseEvent:s,setProperty:i,setValue:c,value:l})=>{const u=useContext(HostContext),[p,f]=useState([]),[d,h]=useState();useEffect(()=>{var e=inspectItems(m,n,l)["items"];h(e);const t=[],o=[];for(const s in e){var r=e[s];r.checked&&(t.push(s),o.push(r))}arrayEqual(p,t)||f(t);var a=0===o.length?void 0:{refValueType:"items",items:o};c(a,!1)},[n]),useEffect(()=>{const e=[];if(l)for(const t in n)l.items.includes(n[t])&&e.push(t);arrayEqual(p,e)||f(e)},[l]);var v=useFocusCallback(o,r,u);var C=(o,r)=>function(e){const t=d?d[o]:void 0;t&&(e=t.checked=e.currentTarget.checked,function(){const e=[],t=[];for(const a in d){var o=d[a];o.checked&&(e.push(o),t.push(a))}var r=0===e.length?void 0:{refValueType:"items",items:e};c(r,!1),i("current",void 0),arrayEqual(t,p)||f(t)}(),s("changed",e?r:void 0,e,o))};const k=[];for(const g in d){var E=d[g],y=-1!==p.indexOf(g),b=o&&!1!==E.enabled,F=u.renderText(E.tooltip),x=E.styleName?makeSafeClassName(E.styleName):void 0;k.push(React.createElement(FormControlLabel,{className:x,control:React.createElement(Checkbox,{checked:y,
|
|
1
|
+
import Checkbox from"@vertigis/react-ui/Checkbox";import FormControlLabel from"@vertigis/react-ui/FormControlLabel";import FormGroup,{formGroupClasses}from"@vertigis/react-ui/FormGroup";import{styled}from"@vertigis/react-ui/styles";import*as React from"react";import{useContext,useEffect,useState}from"react";import{Orientation}from"../constants.js";import HostContext from"../hostContext.js";import{arrayEqual}from"../listUtilities.js";import{makeSafeClassName,inspectItems}from"../utils.js";import FormElement from"./FormElement.js";import Markdown from"./Markdown.js";import{useFocusCallback}from"./common.js";const StyledFormElement=styled(FormElement)(({theme:{spacing:e}})=>({[`.${formGroupClasses.root}`]:{paddingBottom:e(2)}})),CheckGroup=({className:e,current:m,element:t,enabled:o,items:n,name:r,orientation:a,raiseEvent:s,setProperty:i,setValue:c,value:l})=>{const u=useContext(HostContext),[p,f]=useState([]),[d,h]=useState();useEffect(()=>{var e=inspectItems(m,n,l)["items"];h(e);const t=[],o=[];for(const s in e){var r=e[s];r.checked&&(t.push(s),o.push(r))}arrayEqual(p,t)||f(t);var a=0===o.length?void 0:{refValueType:"items",items:o};c(a,!1)},[n]),useEffect(()=>{const e=[];if(l)for(const t in n)l.items.includes(n[t])&&e.push(t);arrayEqual(p,e)||f(e)},[l]);var v=useFocusCallback(o,r,u);var C=(o,r)=>function(e){const t=d?d[o]:void 0;t&&(e=t.checked=e.currentTarget.checked,function(){const e=[],t=[];for(const a in d){var o=d[a];o.checked&&(e.push(o),t.push(a))}var r=0===e.length?void 0:{refValueType:"items",items:e};c(r,!1),i("current",void 0),arrayEqual(t,p)||f(t)}(),s("changed",e?r:void 0,e,o))};const k=[];for(const g in d){var E=d[g],y=-1!==p.indexOf(g),b=o&&!1!==E.enabled,F=u.renderText(E.tooltip),x=E.styleName?makeSafeClassName(E.styleName):void 0;k.push(React.createElement(FormControlLabel,{className:x,control:React.createElement(Checkbox,{checked:y,onChange:C(g,E.value),slotProps:{input:{ref:v}}}),disabled:!b,key:g,label:React.createElement(Markdown,{text:E.label}),title:F}))}return React.createElement(StyledFormElement,{className:e,component:"fieldset",element:t,name:r},React.createElement(FormGroup,{row:a===Orientation.HORIZONTAL},k))};export default CheckGroup;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import BaseDateRangePicker from"@vertigis/react-ui/DateRangePicker";import FormHelperText from"@vertigis/react-ui/FormHelperText";import{styled}from"@vertigis/react-ui/styles";import clsx from"clsx";import{useContext,useEffect,useMemo,useRef,useState}from"react";import*as React from"react";import{areValuesEqual,convertToDateRangeRef,getDateBounds}from"../dateUtilities.js";import HostContext from"../hostContext.js";import{isInvalidError}from"../textUtilities.js";import{makeUniqueId}from"../utils.js";import DateTimeTextField from"./DateTimeTextField.js";import FormElement from"./FormElement.js";import{useFocusCallback}from"./common.js";const DateRangePickerField=e=>{const{inputProps:
|
|
1
|
+
import BaseDateRangePicker from"@vertigis/react-ui/DateRangePicker";import FormHelperText from"@vertigis/react-ui/FormHelperText";import{styled}from"@vertigis/react-ui/styles";import clsx from"clsx";import{useContext,useEffect,useMemo,useRef,useState}from"react";import*as React from"react";import{areValuesEqual,convertToDateRangeRef,getDateBounds}from"../dateUtilities.js";import HostContext from"../hostContext.js";import{isInvalidError}from"../textUtilities.js";import{makeUniqueId}from"../utils.js";import DateTimeTextField from"./DateTimeTextField.js";import FormElement from"./FormElement.js";import{useFocusCallback}from"./common.js";const DateRangePickerField=e=>{const{FormHelperTextProps:t,InputProps:r,InputLabelProps:a,inputProps:o,SelectProps:s,...n}=e,l=n.slotProps??{};return delete n.slotProps,l.formHelperText={...t,...l.formHelperText},l.input={...r,...l.input},l.inputLabel={...a,...l.inputLabel},l.htmlInput={...o,...l.htmlInput},l.select={...s,...l.select},n.error=n.error||l.htmlInput["data-elementError"],delete l.htmlInput["data-elementError"],React.createElement(DateTimeTextField,{...n,slotProps:l})},PREFIX="DateRangePicker",dateRangePickerClasses={root:`${PREFIX}-root`,toLabel:`${PREFIX}-toLabel`},StyledDateRangePicker=styled(BaseDateRangePicker)({alignItems:"center"}),StyledFormElement=styled(FormElement)(({theme:{spacing:e}})=>({[`.${dateRangePickerClasses.toLabel}`]:{paddingTop:e(3)}})),DateRangePicker=({className:e,element:t,enabled:r,error:a,format:o,name:s,setProperty:n,setValue:l,tooltip:i,value:m})=>{const u=useContext(HostContext),[c,d]=useState([null,null]),[p,f]=useState(-1),[R,g]=useState([!1,!1]),[x,P]=useState(!1),[E,D]=useState([null,null]),F=useRef(),k=useRef(!0),I=isInvalidError(a);useEffect(()=>{var e=convertToDateRangeRef(m),t=[e?.startDate||null,e?.endDate||null],e=C(t);areValuesEqual(m,e)||l(e,!1),D(t)},[m]),useEffect(()=>{var e=0===p?R[0]:!!c[0],t=1===p?R[1]:!!c[1];g([e,t]);t=e||t;if(t?I||n("error",{status:"invalid"}):I&&n("error",void 0),!x&&-1===p&&!t){if(k.current)return void(k.current=!1);t=C(E);areValuesEqual(m,t)||l(t)}k.current=!1},[c,p,x]);const T=u.renderText(i),v=useFocusCallback(r,s,u),C=e=>{if(e[0]&&e[1])return{refValueType:"daterange",startDate:e[0],endDate:e[1]}},b=useMemo(()=>`${makeUniqueId(s)}-input`,[s]);var S=R[0]||R[1],{min:i,max:o}=getDateBounds(o);return React.createElement(StyledFormElement,{className:clsx(e,dateRangePickerClasses.root),element:t,inputId:b,name:s},S&&React.createElement(FormHelperText,{component:"div",error:!0,role:"alert"},F.current),React.createElement(StyledDateRangePicker,{disabled:!r,maxDate:o,minDate:i,onChange:e=>D(e),onClose:()=>P(!1),onError:e=>d(e),onOpen:()=>P(!0),slots:{textField:DateRangePickerField},slotProps:{fieldSeparator:{children:u.renderText("@common-to"),className:dateRangePickerClasses.toLabel},textField:({position:e})=>({inputRef:e=>{"0"===e?.dataset.index&&(F.current=e.dataset.formatString,v(e))},onBlur:e=>{Number.parseInt(e.target.dataset.index)===p&&f(-1)},onFocus:e=>{e=Number.parseInt(e.target.dataset.index);f(e)},slotProps:{htmlInput:{id:"start"===e?b:void 0,"data-elementError":!!a,"data-index":"start"===e?0:1}},title:T})},value:E}))};export default DateRangePicker;export{dateRangePickerClasses};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{buttonBaseClasses}from"@vertigis/react-ui/ButtonBase";import BaseDateTimePicker from"@vertigis/react-ui/DateTimePicker";import FormHelperText from"@vertigis/react-ui/FormHelperText";import{clockClasses}from"@vertigis/react-ui/TimeClock";import{styled}from"@vertigis/react-ui/styles";import*as React from"react";import{useContext,useEffect,useMemo,useRef,useState}from"react";import{Calendar}from"../Calendar.js";import{areValuesEqual,getDateBounds,getNewElementValue,makeProperValue}from"../dateUtilities.js";import HostContext from"../hostContext.js";import{isInvalidError}from"../textUtilities.js";import{makeUniqueId,useLocale}from"../utils.js";import DateTimeTextField from"./DateTimeTextField.js";import FormElement from"./FormElement.js";import{useFocusCallback}from"./common.js";const StylableDateTimePicker=e=>{
|
|
1
|
+
import{buttonBaseClasses}from"@vertigis/react-ui/ButtonBase";import BaseDateTimePicker from"@vertigis/react-ui/DateTimePicker";import FormHelperText from"@vertigis/react-ui/FormHelperText";import{clockClasses}from"@vertigis/react-ui/TimeClock";import{styled}from"@vertigis/react-ui/styles";import*as React from"react";import{useContext,useEffect,useMemo,useRef,useState}from"react";import{Calendar}from"../Calendar.js";import{areValuesEqual,getDateBounds,getNewElementValue,makeProperValue}from"../dateUtilities.js";import HostContext from"../hostContext.js";import{isInvalidError}from"../textUtilities.js";import{makeUniqueId,useLocale}from"../utils.js";import DateTimeTextField from"./DateTimeTextField.js";import FormElement from"./FormElement.js";import{useFocusCallback}from"./common.js";const StylableDateTimePicker=e=>{const{className:t,slotProps:r,...a}=e;return React.createElement(BaseDateTimePicker,{slotProps:{...r,actionBar:{sx:{display:"none"}},popper:{...r?.popper,className:t}},...a})},StyledDateTimePicker=styled(StylableDateTimePicker)(({theme:{palette:e}})=>({[`& .${clockClasses.amButton}, .${clockClasses.pmButton}`]:{[`&.${buttonBaseClasses.focusVisible}`]:{color:e.action.active}}})),DateTimePicker=({className:e,element:t,enabled:r,error:a,format:o,name:s,prompt:i,setProperty:l,setValue:m,tooltip:n,value:u})=>{const c=useContext(HostContext),[p,d]=useState(!1),[f,T]=useState(!1),[k,x]=useState(!1),[E,v]=useState(null),C=useRef();const D={locale:useLocale(),timezone:(new Intl.DateTimeFormat).resolvedOptions().timeZone},F=useRef(!0),P=useFocusCallback(r,s,c),g=c.renderText(n),B=Calendar.useNative(),R="datetime",y=isInvalidError(a);useEffect(()=>{var e=makeProperValue(u,B),t=getNewElementValue(e,R,D,B);areValuesEqual(u,t)||m(t,!1),v(e||null)},[u]),useEffect(()=>{if(!k&&!f)if(p)y||l("error",{status:"invalid"});else{if(y&&l("error",void 0),F.current)return void(F.current=!1);var e=getNewElementValue(E,R,D,B);areValuesEqual(u,e)||m(e)}F.current=!1},[p,f,k]);const{min:S,max:V}=getDateBounds(o),b=useMemo(()=>`${makeUniqueId(s)}-input`,[s]),j=c.renderText(i);return React.createElement(FormElement,{className:e,element:t,inputId:b,name:s},e=>React.createElement(React.Fragment,null,y&&React.createElement(FormHelperText,{component:"div",error:!0,role:"alert"},C.current),React.createElement(StyledDateTimePicker,{disabled:!r,key:"date-picker",inputRef:e=>{e&&(C.current=e.dataset.formatString,P(e))},maxDateTime:V,minDateTime:S,onChange:e=>v(e),onClose:()=>x(!1),onError:e=>d(!!e),onOpen:()=>x(!0),slots:{textField:DateTimeTextField},slotProps:{textField:{error:!!a,id:b,inputProps:{...e,placeholder:j},onBlur:()=>T(!1),onFocus:()=>T(!0),title:g}},value:E})))};export default DateTimePicker;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import FormLabelTextField from"@vertigis/react-ui/FormLabelTextField";import*as React from"react";const DateTimeTextField=
|
|
1
|
+
import FormLabelTextField from"@vertigis/react-ui/FormLabelTextField";import*as React from"react";const DateTimeTextField=t=>{const{placeholder:e,inputProps:r,InputProps:l,...o}=t,a=o.slotProps??{};var{htmlInput:p,input:t}=a;return a.htmlInput={...r,...p,"data-format-string":e},a.htmlInput.placeholder||(a.htmlInput.placeholder=e),a.input={...l,...t},delete o.slotProps,React.createElement(FormLabelTextField,{...o,slotProps:a})};export default DateTimeTextField;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import FormControl from"@vertigis/react-ui/FormControl";import{styled}from"@vertigis/react-ui/styles";import clsx from"clsx";import{forwardRef,useContext}from"react";import*as React from"react";import{TitleLocation}from"../constants.js";import HostContext from"../hostContext.js";import{makeSafeClassName,makeUniqueId}from"../utils.js";import{formClasses}from"./Form.js";import{renderAccessibleDescription,renderDescription,renderError,renderTitle}from"./common.js";const StyledFormControl=styled(FormControl)(({theme:{palette:e,spacing:r}})=>({code:{backgroundColor:"rgba(0, 0, 0, .06)",fontFamily:'"Consolas", monospace'},table:{borderCollapse:"collapse","td, th":{border:`1px solid ${e.grey[400]}`,padding:r(.5)},th:{backgroundColor:e.grey[100]}}}));export default forwardRef((e,r)=>{var{children:o,className:t,component:s,element:i,inputId:a,name:n}=e,l=useContext(HostContext),m=makeUniqueId(n),c=renderTitle(m,i.require,i.title,a,"fieldset"===s?"legend":void 0),e=renderDescription(i.description,m,i.enabled),a=renderAccessibleDescription(i.accessibleDescription,i.description,m,l),l=renderError(i.error);const d={className:clsx(t,i.type,{[formClasses.formElementWithTitleBeside]:i.titleLocation===TitleLocation.BESIDE,[makeSafeClassName(n)]:!!n,[makeSafeClassName(i.styleName)]:!!i.styleName}),component:s,error:!!l,id:m,ref:r,required:i.require};m=c?.props?.id,r=a?.props?.id;const p=o instanceof Function?o:void 0;let f=o instanceof Function?void 0:o;p?f=p({"aria-labelledby":m,"aria-describedby":r}):(d["aria-labelledby"]=m,d["aria-describedby"]=r);
|
|
1
|
+
import FormControl from"@vertigis/react-ui/FormControl";import{styled}from"@vertigis/react-ui/styles";import clsx from"clsx";import{forwardRef,useContext}from"react";import*as React from"react";import{TitleLocation}from"../constants.js";import HostContext from"../hostContext.js";import{makeSafeClassName,makeUniqueId}from"../utils.js";import{formClasses}from"./Form.js";import{renderAccessibleDescription,renderDescription,renderError,renderTitle}from"./common.js";const StyledFormControl=styled(FormControl)(({theme:{palette:e,spacing:r}})=>({code:{backgroundColor:"rgba(0, 0, 0, .06)",fontFamily:'"Consolas", monospace'},table:{borderCollapse:"collapse","td, th":{border:`1px solid ${e.grey[400]}`,padding:r(.5)},th:{backgroundColor:e.grey[100]}}}));export default forwardRef((e,r)=>{var{children:o,className:t,component:s,element:i,inputId:a,name:n}=e,l=useContext(HostContext),m=makeUniqueId(n),c=renderTitle(m,i.require,i.title,a,"fieldset"===s?"legend":void 0),e=renderDescription(i.description,m,i.enabled),a=renderAccessibleDescription(i.accessibleDescription,i.description,m,l),l=renderError(i.error);const d={className:clsx(t,i.type,{[formClasses.formElementWithTitleBeside]:i.titleLocation===TitleLocation.BESIDE,[makeSafeClassName(n)]:!!n,[makeSafeClassName(i.styleName)]:!!i.styleName}),component:s,error:!!l,id:m,ref:r,required:i.require};m=c?.props?.id,r=a?.props?.id;const p=o instanceof Function?o:void 0;let f=o instanceof Function?void 0:o;p?f=p({"aria-labelledby":m,"aria-describedby":r}):(d["aria-labelledby"]=m,d["aria-describedby"]=r);const u=[c];return i.titleLocation===TitleLocation.BESIDE?u.push(React.createElement("div",{className:formClasses.formElementContent},e,a,l,f)):(u.push(e),u.push(a),u.push(l),u.push(f)),React.createElement(StyledFormControl,{fullWidth:!0,...d},...u)});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import Box from"@vertigis/react-ui/Box";import Button from"@vertigis/react-ui/Button";import IconButton from"@vertigis/react-ui/IconButton";import List from"@vertigis/react-ui/List";import ListItemButton from"@vertigis/react-ui/ListItemButton";import Plus from"@vertigis/react-ui/icons/Plus";import Trash from"@vertigis/react-ui/icons/Trash";import*as React from"react";import{useContext,useEffect,useRef,useState}from"react";import HostContext from"../hostContext.js";import{sanitizeGeometryRef,text}from"../utils.js";import FormElement from"./FormElement.js";import GeometryPickerListItem from"./GeometryPickerListItem.js";import Markdown from"./Markdown.js";import{useFocusCallback}from"./common.js";const GeometryPicker=({autoActivate:e,className:t,element:r,enabled:o,itemLabel:i,name:n,prompt:s,raiseEvent:a,setProperty:c,setValue:l,size:m,state:u,tooltip:d,value:f})=>{const p=useContext(HostContext),[g,v]=useState([]),[h,k]=useState(""),y=u,x=useRef(!1);let E=5;"number"==typeof m&&(E=1<m?Math.ceil(m):1),useEffect(()=>{var e=sanitizeGeometryRef(f);f!==e&&l(e,!1),void 0!==f&&(Array.isArray(i)?v(i):(v([]),text.isMarkdown(i)?i.markdown&&k(i):text.isStatus(i)?i.status&&k(i.status):i&&k(i))),void 0!==y&&null!==y||c("state",[])},[f]);const[R,b]=useState([]),B=useFocusCallback(o,n,p);const I=e=>{let t=y[e];return void 0!==t&&null!==t||(y.length<=e&&(y.length=e,y.push({})),t=y[e]),t},C=n=>()=>{let e;if(1<f.geometry.length){const r=[...f.geometry];if(r.splice(n,1),e={...f,geometry:r},y.splice(n,1),n<g.length){const o=[...g];o.splice(n,1),v(o)}}else y.length=0;
|
|
1
|
+
import Box from"@vertigis/react-ui/Box";import Button from"@vertigis/react-ui/Button";import IconButton from"@vertigis/react-ui/IconButton";import List from"@vertigis/react-ui/List";import ListItemButton from"@vertigis/react-ui/ListItemButton";import Plus from"@vertigis/react-ui/icons/Plus";import Trash from"@vertigis/react-ui/icons/Trash";import*as React from"react";import{useContext,useEffect,useRef,useState}from"react";import HostContext from"../hostContext.js";import{sanitizeGeometryRef,text}from"../utils.js";import FormElement from"./FormElement.js";import GeometryPickerListItem from"./GeometryPickerListItem.js";import Markdown from"./Markdown.js";import{useFocusCallback}from"./common.js";const GeometryPicker=({autoActivate:e,className:t,element:r,enabled:o,itemLabel:i,name:n,prompt:s,raiseEvent:a,setProperty:c,setValue:l,size:m,state:u,tooltip:d,value:f})=>{const p=useContext(HostContext),[g,v]=useState([]),[h,k]=useState(""),y=u,x=useRef(!1);let E=5;"number"==typeof m&&(E=1<m?Math.ceil(m):1),useEffect(()=>{var e=sanitizeGeometryRef(f);f!==e&&l(e,!1),void 0!==f&&(Array.isArray(i)?v(i):(v([]),text.isMarkdown(i)?i.markdown&&k(i):text.isStatus(i)?i.status&&k(i.status):i&&k(i))),void 0!==y&&null!==y||c("state",[])},[f]);const[R,b]=useState([]),B=useFocusCallback(o,n,p);const I=e=>{let t=y[e];return void 0!==t&&null!==t||(y.length<=e&&(y.length=e,y.push({})),t=y[e]),t},C=n=>()=>{let e;if(1<f.geometry.length){const r=[...f.geometry];if(r.splice(n,1),e={...f,geometry:r},y.splice(n,1),n<g.length){const o=[...g];o.splice(n,1),v(o)}}else y.length=0;const t=[];for(const i of R)i<n?t.push(i):i>n&&t.push(i-1);b(t),l(e,{argument:"remove"})};var L=e=>{o&&C(e)()},P=(e,t,r)=>{const o=I(e);o.focused=t,o.pending=r,p.renderState(n,"geometry",y)};let G=o;const S=[];if(void 0!==f&&void 0!==y){G=o&&f.geometry.length<E;var j=p.renderText("@geometry-picker-remove-item-label");for(const A of f.geometry){var w=S.length;I(w).content=A;var M=`checkbox-list-label-${w}`;S.push(React.createElement(GeometryPickerListItem,{deleteItem:L,disablePadding:!0,itemIndex:w,key:"$"+w,secondaryAction:React.createElement(IconButton,{"aria-label":j,className:"delete",disabled:!o,edge:"end",onClick:C(w),ref:B,title:j},React.createElement(Trash,null)),updateHighlight:P},React.createElement(ListItemButton,{onClick:(o=>()=>{var e=R.indexOf(o);const t=[...R],r=I(o);-1===e?(r.checked=!0,t.push(o)):(r.checked=!1,t.splice(e,1)),b(t)})(w),ref:(t=>e=>{B(e),null!==e&&(e.checked=!!I(t).checked)})(w),selected:-1!==R.indexOf(w)},React.createElement(Markdown,{id:M,inline:!0,text:g[w]||h}))))}}const T=()=>{a("clicked",f)};d=p.renderText(d);return o&&e&&!x.current&&(setTimeout(()=>{c("autoActivate",void 0),x.current=!1,G&&T()}),x.current=!0),React.createElement(FormElement,{className:t,component:"fieldset",element:r,name:n,ref:e=>{let t=y;null===e&&(r.visible||c("state",[]),t=void 0),p.renderState(n,"geometry",t)}},React.createElement(List,null,S),React.createElement(Box,null,React.createElement(Button,{disabled:!G,onClick:T,ref:B,startIcon:React.createElement(Plus,null),title:d,variant:"outlined"},React.createElement(Markdown,{inline:!0,text:s||""}))))};export default GeometryPicker;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import Checkbox from"@vertigis/react-ui/Checkbox";import FormControl from"@vertigis/react-ui/FormControl";import FormControlLabel from"@vertigis/react-ui/FormControlLabel";import FormLabel from"@vertigis/react-ui/FormLabel";import IconButton from"@vertigis/react-ui/IconButton";import Input from"@vertigis/react-ui/Input";import InputAdornment from"@vertigis/react-ui/InputAdornment";import List from"@vertigis/react-ui/List";import ListItem from"@vertigis/react-ui/ListItem";import ListItemButton from"@vertigis/react-ui/ListItemButton";import ListItemIcon from"@vertigis/react-ui/ListItemIcon";import ListItemText,{listItemTextClasses}from"@vertigis/react-ui/ListItemText";import Radio from"@vertigis/react-ui/Radio";import RadioGroup from"@vertigis/react-ui/RadioGroup";import Stack from"@vertigis/react-ui/Stack";import Typography from"@vertigis/react-ui/Typography";import Close from"@vertigis/react-ui/icons/Close";import{styled}from"@vertigis/react-ui/styles";import clsx from"clsx";import*as React from"react";import{useContext,useEffect,useMemo,useState}from"react";import{Orientation}from"../constants.js";import HostContext from"../hostContext.js";import{getKeyString}from"../keyboard.js";import{areValuesEqual}from"../listUtilities.js";import{debounce,isDataRef,isGeometryRef,makeSafeClassName,makeUniqueId}from"../utils.js";import FormElement from"./FormElement.js";import Markdown from"./Markdown.js";import{useFocusCallback}from"./common.js";const PREFIX="ItemPicker",itemPickerClasses={allNone:`${PREFIX}-all-none`,button:`${PREFIX}-list-item-button`,clearIcon:`${PREFIX}-clear-button`,horizontal:`${PREFIX}-horizontal`,item:`${PREFIX}-list-item`,items:`${PREFIX}-list-items`},StyledFormElement=styled(FormElement)(({theme:{typography:e,spacing:t}})=>({[`.${itemPickerClasses.allNone}`]:{marginLeft:t(2)},[`.${itemPickerClasses.clearIcon}`]:{height:e.pxToRem(20),width:e.pxToRem(20)},[`.${itemPickerClasses.items}`]:{[`&.${itemPickerClasses.horizontal}`]:{display:"flex",flexWrap:"wrap",[`.${itemPickerClasses.item}`]:{width:"auto"}},[`.${itemPickerClasses.item}`]:{[`.${itemPickerClasses.button}`]:{paddingBottom:0,paddingTop:0,[`.${listItemTextClasses.primary}`]:{fontWeight:e.fontWeightRegular}}}}})),ItemPicker=({className:e,component:o,element:t,enabled:
|
|
1
|
+
import Checkbox from"@vertigis/react-ui/Checkbox";import FormControl from"@vertigis/react-ui/FormControl";import FormControlLabel from"@vertigis/react-ui/FormControlLabel";import FormLabel from"@vertigis/react-ui/FormLabel";import IconButton from"@vertigis/react-ui/IconButton";import Input from"@vertigis/react-ui/Input";import InputAdornment from"@vertigis/react-ui/InputAdornment";import List from"@vertigis/react-ui/List";import ListItem from"@vertigis/react-ui/ListItem";import ListItemButton from"@vertigis/react-ui/ListItemButton";import ListItemIcon from"@vertigis/react-ui/ListItemIcon";import ListItemText,{listItemTextClasses}from"@vertigis/react-ui/ListItemText";import Radio from"@vertigis/react-ui/Radio";import RadioGroup from"@vertigis/react-ui/RadioGroup";import Stack from"@vertigis/react-ui/Stack";import Typography from"@vertigis/react-ui/Typography";import Close from"@vertigis/react-ui/icons/Close";import{styled}from"@vertigis/react-ui/styles";import clsx from"clsx";import*as React from"react";import{useContext,useEffect,useMemo,useState}from"react";import{Orientation}from"../constants.js";import HostContext from"../hostContext.js";import{getKeyString}from"../keyboard.js";import{areValuesEqual}from"../listUtilities.js";import{debounce,isDataRef,isGeometryRef,makeSafeClassName,makeUniqueId}from"../utils.js";import FormElement from"./FormElement.js";import Markdown from"./Markdown.js";import{useFocusCallback}from"./common.js";const PREFIX="ItemPicker",itemPickerClasses={allNone:`${PREFIX}-all-none`,button:`${PREFIX}-list-item-button`,clearIcon:`${PREFIX}-clear-button`,horizontal:`${PREFIX}-horizontal`,item:`${PREFIX}-list-item`,items:`${PREFIX}-list-items`},StyledFormElement=styled(FormElement)(({theme:{typography:e,spacing:t}})=>({[`.${itemPickerClasses.allNone}`]:{marginLeft:t(2)},[`.${itemPickerClasses.clearIcon}`]:{height:e.pxToRem(20),width:e.pxToRem(20)},[`.${itemPickerClasses.items}`]:{[`&.${itemPickerClasses.horizontal}`]:{display:"flex",flexWrap:"wrap",[`.${itemPickerClasses.item}`]:{width:"auto"}},[`.${itemPickerClasses.item}`]:{[`.${itemPickerClasses.button}`]:{paddingBottom:0,paddingTop:0,[`.${listItemTextClasses.primary}`]:{fontWeight:e.fontWeightRegular}}}}})),ItemPicker=({className:e,component:o,element:t,enabled:r,items:a,name:i,orientation:s,prompt:n,selectionMode:l,setProperty:c,setValue:m,showFilter:d,spacing:u,state:p,value:f})=>{const k=useContext(HostContext);void 0===u&&(u=1);const[g,I]=useState(""),h=a||{};let R=p;const v=useFocusCallback(r,i,k),b=e=>{const t=[];for(const o in h){var r=h[o];r.checked&&t.push(r)}let i;0<t.length&&(i={refValueType:"items",items:t}),areValuesEqual(f,i)||m(i,e)};useEffect(()=>{void 0!==R&&null!==R||(R={items:[],keyToIndex:{}});const e={};for(const r in a){var t=x(r,!1);t&&(e[r]=t)}R.items.length=0,R.keyToIndex={};for(const i in e)R.keyToIndex[i]=R.items.length,R.items.push(e[i]);p!==R&&c("state",R),b(!1)});const x=(e,t=!0)=>{let r=R.keyToIndex[e];if(null==r||null===r){if(!t)return;R.keyToIndex[e]=R.items.length,R.items.push({}),r=R.keyToIndex[e]}return R.items[r]},C=(e,t)=>{h[e].checked=t;const r=x(e);r&&(r.checked=t)};var E=t=>e=>{null!==e&&(v(e),e=!0===h[t].checked,x(t).checked=e)};const y=[];let T;switch(l){case"single":T="radio";break;case"multiple":T="checkbox"}const P={},L={};if(R)for(const K in h){var F,S,$,N,w=h[K];w.checked&&(P[K]=w),x(K).content=(e=>{if(e){if(isGeometryRef(e))return e.geometry;if(isDataRef(e)&&e.data)return e.data.geometry}})(w.value),!1!==w.visible&&(L[K]=w,S=(F=r&&!1!==w.enabled)&&!!T,$=k.renderText(w.tooltip),N=clsx(itemPickerClasses.item,w.styleName?makeSafeClassName(w.styleName):void 0),w=React.createElement(Markdown,{text:w.label}),y.push(React.createElement(ListItem,{className:N,disablePadding:!0,key:K},React.createElement(ListItemButton,{className:itemPickerClasses.button,disabled:!F,onClick:S?(r=>()=>{var e=h[r].checked;if("single"===l){if(!e)for(const t in h)C(t,t===r)}else C(r,!e);b(!0),k.renderState(i,"item-picker",R)})(K):void 0,tabIndex:F?void 0:-1,title:$,"data-id":K,onBlur:F?e=>{delete x(e.currentTarget.dataset.id).focused,k.renderState(i,"item-picker",R)}:void 0,onFocus:F?e=>{x(e.currentTarget.dataset.id).focused=!0,k.renderState(i,"item-picker",R)}:void 0,onMouseOver:F?e=>{x(e.currentTarget.dataset.id).pending=!0,k.renderState(i,"item-picker",R)}:void 0,onMouseOut:F?e=>{delete x(e.currentTarget.dataset.id).pending,k.renderState(i,"item-picker",R)}:void 0},"checkbox"===T&&React.createElement(ListItemIcon,null,React.createElement(Checkbox,{edge:"start",checked:!0===h[K]?.checked,disabled:!F,disableRipple:!0,slotProps:{input:{ref:E(K)}},tabIndex:-1,value:K})),"radio"===T&&React.createElement(ListItemIcon,null,React.createElement(Radio,{edge:"start",checked:!0===h[K]?.checked,disabled:!F,disableRipple:!0,name:i,slotProps:{input:{ref:E(K)}},tabIndex:-1,value:K})),React.createElement(ListItemText,null,w)))))}var M=k.renderText(n);const j=useMemo(()=>e=>{for(const t in h){const r=h[t];if(e){const i=k.renderText(r.label).toLowerCase();r.visible=0<=i.indexOf(e)}else r.visible=!0}o.forceUpdate()},[h]),B=useMemo(()=>debounce(j),[h]);const O=()=>{I(""),j("")};var X="multiple"===l&&0<y.length,z=clsx(itemPickerClasses.items,{[itemPickerClasses.horizontal]:s===Orientation.HORIZONTAL});let A,G=0,q=0,U=0,V=0;for(const Z in h){var W=L[Z];W?(U++,W.checked&&G++):(V++,h[Z].checked&&q++)}0===G?A="none":G===U&&(A="all");n=g?React.createElement(InputAdornment,{position:"end"},React.createElement(IconButton,{disabled:!r,onClick:O,title:k.renderText("@common-clear")},React.createElement(Close,{className:itemPickerClasses.clearIcon}))):null,s=d?`${makeUniqueId(i)}-filter`:void 0;let D,H=k.renderText("@item-picker-select");return X&&0<V&&(H=k.renderText("@item-picker-select-visible"),0<q&&(D=1===q?k.renderText("@item-picker-hidden-selected-item"):`${q} ${k.renderText("@item-picker-hidden-selected-items")}`)),React.createElement(StyledFormElement,{className:e,component:"fieldset",element:t,inputId:s,name:i,ref:e=>{null===e?k.renderState(i,"item-picker"):k.renderState(i,"item-picker",R)}},React.createElement(Stack,{spacing:u},d&&React.createElement(Input,{disabled:!r,endAdornment:n,error:!1,fullWidth:!0,id:s,inputRef:v,onChange:e=>{const t=e.target.value;I(t),B(t.toLowerCase())},onKeyDown:e=>{"escape"===getKeyString(e)&&O()},placeholder:M,type:"text",value:g}),X&&React.createElement(FormControl,{className:itemPickerClasses.allNone},React.createElement(FormLabel,null,H),React.createElement(RadioGroup,{color:"primary",row:!0},React.createElement(FormControlLabel,{value:"all",checked:"all"===A,control:React.createElement(Radio,{size:"small"}),disabled:!r,inputRef:v,onClick:()=>{for(const e in L)C(e,!0);b(!0)},label:k.renderText("@common-all")}),React.createElement(FormControlLabel,{value:"none",checked:"none"===A,control:React.createElement(Radio,{size:"small"}),disabled:!r,onClick:()=>{for(const e in L)C(e,!1);b(!0)},label:k.renderText("@common-none")})),D&&React.createElement(Typography,{variant:"subtitle2"},D)),React.createElement(List,{className:z,dense:!0},y)))};export default ItemPicker;export{itemPickerClasses};
|