@vertigis/workflow 5.31.0 → 5.32.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/amd/Errors.js +1 -1
- package/amd/Validation.js +1 -1
- package/amd/activities/arcgis/AddFeatureLayer.js +1 -1
- package/amd/activities/arcgis/AddFeatures.js +1 -1
- package/amd/activities/arcgis/AddGraphics.js +1 -1
- package/amd/activities/arcgis/DeleteFeatures.js +1 -1
- package/amd/activities/arcgis/GetViewExtent.js +1 -1
- package/amd/activities/arcgis/MapProvider.js +1 -1
- package/amd/activities/arcgis/RemoveFeatureSetFields.js +1 -1
- package/amd/activities/arcgis/RemoveGraphics.js +1 -1
- package/amd/activities/arcgis/RunPrint.js +1 -1
- package/amd/activities/arcgis/RunReport.d.ts +1 -0
- package/amd/activities/arcgis/RunReport.js +1 -1
- package/amd/activities/arcgis/RunWorkflow.js +1 -1
- package/amd/activities/arcgis/SetLayerDefinitionExpression.js +1 -1
- package/amd/activities/arcgis/SetViewpoint.js +1 -1
- package/amd/activities/arcgis/ShowResults.js +1 -1
- package/amd/activities/arcgis/UpdateFeatures.js +1 -1
- package/amd/activities/arcgis/runUtils.js +1 -1
- package/amd/activities/arcgis/shared.js +1 -1
- package/amd/activities/core/ForEach.js +1 -1
- package/amd/activities/core/ParseUrl.js +1 -1
- package/amd/activities/forms/FormRenderer.d.ts +2 -3
- package/amd/activities/forms/FormRenderer.js +1 -1
- package/amd/activities/forms/GetFormElementItemsFromCollection.d.ts +6 -0
- package/amd/activities/forms/GetFormElementItemsFromCollection.js +1 -1
- package/amd/amdpile.js +1 -1
- package/amd/amdpile.js.LICENSE.txt +12 -20
- package/amd/app/AppActivity.d.ts +0 -2
- package/amd/app/AppActivity.js +1 -1
- package/amd/bundle.js +1 -1
- package/amd/deps/react/index.min.js +2 -0
- package/amd/deps/react/index.min.js.LICENSE.txt +14 -0
- package/amd/execution/ProgramRunner.js +1 -1
- package/amd/forms/FormComponent.d.ts +2 -2
- package/amd/forms/FormComponent.js +1 -1
- package/amd/forms/FormDefinition.d.ts +1 -1
- package/amd/forms/FormElementOuter.d.ts +4 -4
- package/amd/forms/FormElementOuter.js +1 -1
- package/amd/forms/FormHost.d.ts +5 -6
- package/amd/forms/FormHost.js +1 -1
- package/amd/forms/FormPresenterHost.d.ts +5 -8
- package/amd/forms/NumberParser.d.ts +25 -0
- package/amd/forms/NumberParser.js +1 -0
- package/amd/forms/assets/arrow.js +1 -1
- package/amd/forms/assets/chevron.js +1 -1
- package/amd/forms/assets/cross.js +1 -1
- package/amd/forms/assets/datetime.js +1 -1
- package/amd/forms/assets/remove.js +1 -1
- package/amd/forms/assets/scan.js +1 -1
- package/amd/forms/common.js +1 -1
- package/amd/forms/components/DatePicker.d.ts +1 -1
- package/amd/forms/components/DatePicker.js +1 -1
- package/amd/forms/components/DateRangePicker.d.ts +1 -1
- package/amd/forms/components/DateRangePicker.js +1 -1
- package/amd/forms/components/DateTimePicker.js +1 -1
- package/amd/forms/components/Navigator.js +1 -1
- package/amd/forms/components/NumberRangeSlider.d.ts +1 -1
- package/amd/forms/components/NumberRangeSlider.js +1 -1
- package/amd/forms/components/NumberSlider.d.ts +1 -1
- package/amd/forms/components/NumberSlider.js +1 -1
- package/amd/forms/components/SyntheticButton.js +1 -1
- package/amd/forms/components/TimePickerInput.d.ts +2 -2
- package/amd/forms/components/TimePickerInput.js +1 -1
- package/amd/forms/dateUtilities.js +1 -1
- package/amd/forms/datetime.js +1 -1
- package/amd/forms/files.js +1 -1
- package/amd/forms/geometry.js +1 -1
- package/amd/forms/number.d.ts +1 -1
- package/amd/forms/number.js +1 -1
- package/amd/forms/numberSliderUtilities.js +1 -1
- package/amd/forms/presenter.js +1 -1
- package/amd/forms/renderers.js +1 -1
- package/amd/forms/scanner.js +1 -1
- package/amd/forms/selectors.js +1 -1
- package/amd/forms/text.js +1 -1
- package/amd/forms/utils.js +1 -1
- package/amd/libs/version.d.ts +1 -1
- package/amd/libs/version.js +1 -1
- package/amd/licensing/LicenseChecker.js +1 -1
- package/amd/licensing/Watermark.js +1 -1
- package/esm/Errors.js +1 -1
- package/esm/Validation.js +1 -1
- package/esm/activities/arcgis/AddFeatureLayer.js +1 -1
- package/esm/activities/arcgis/AddFeatures.js +1 -1
- package/esm/activities/arcgis/AddGraphics.js +1 -1
- package/esm/activities/arcgis/CreateFeatureSet.js +1 -1
- package/esm/activities/arcgis/DeleteFeatures.js +1 -1
- package/esm/activities/arcgis/Geoprocessing.js +1 -1
- package/esm/activities/arcgis/GeoprocessingAsync.js +1 -1
- package/esm/activities/arcgis/GetCodedValueDomain.js +1 -1
- package/esm/activities/arcgis/GetViewExtent.js +1 -1
- package/esm/activities/arcgis/MapProvider.js +1 -1
- package/esm/activities/arcgis/RemoveFeatureSetFields.js +1 -1
- package/esm/activities/arcgis/RemoveGraphics.js +1 -1
- package/esm/activities/arcgis/RunPrint.js +1 -1
- package/esm/activities/arcgis/RunReport.d.ts +1 -0
- package/esm/activities/arcgis/RunReport.js +1 -1
- package/esm/activities/arcgis/RunWorkflow.js +1 -1
- package/esm/activities/arcgis/SetViewpoint.js +1 -1
- package/esm/activities/arcgis/ShowResults.js +1 -1
- package/esm/activities/arcgis/UpdateFeatures.js +1 -1
- package/esm/activities/arcgis/runUtils.js +1 -1
- package/esm/activities/arcgis/shared.js +1 -1
- package/esm/activities/core/ForEach.js +1 -1
- package/esm/activities/core/ParseUrl.js +1 -1
- package/esm/activities/core/Subworkflow.js +1 -1
- package/esm/activities/forms/FormRenderer.d.ts +2 -3
- package/esm/activities/forms/FormRenderer.js +1 -1
- package/esm/activities/forms/GetFormElementItemsFromCollection.d.ts +6 -0
- package/esm/activities/forms/GetFormElementItemsFromCollection.js +1 -1
- package/esm/app/ActivityPackUtils.js +1 -1
- package/esm/app/AppActivity.d.ts +0 -2
- package/esm/app/AppActivity.js +1 -1
- package/esm/deps/react/index.min.js +2 -0
- package/esm/deps/react/index.min.js.LICENSE.txt +14 -0
- package/esm/execution/ProgramRunner.js +1 -1
- package/esm/forms/FormComponent.d.ts +2 -2
- package/esm/forms/FormComponent.js +1 -1
- package/esm/forms/FormDefinition.d.ts +1 -1
- package/esm/forms/FormElementOuter.d.ts +4 -4
- package/esm/forms/FormElementOuter.js +1 -1
- package/esm/forms/FormHost.d.ts +5 -6
- package/esm/forms/FormHost.js +1 -1
- package/esm/forms/FormPresenterHost.d.ts +5 -8
- package/esm/forms/NumberParser.d.ts +25 -0
- package/esm/forms/NumberParser.js +1 -0
- package/esm/forms/assets/arrow.js +1 -1
- package/esm/forms/assets/chevron.js +1 -1
- package/esm/forms/assets/cross.js +1 -1
- package/esm/forms/assets/datetime.js +1 -1
- package/esm/forms/assets/remove.js +1 -1
- package/esm/forms/assets/scan.js +1 -1
- package/esm/forms/common.js +1 -1
- package/esm/forms/components/DatePicker.d.ts +1 -1
- package/esm/forms/components/DatePicker.js +1 -1
- package/esm/forms/components/DateRangePicker.d.ts +1 -1
- package/esm/forms/components/DateRangePicker.js +1 -1
- package/esm/forms/components/DateTimePicker.js +1 -1
- package/esm/forms/components/Navigator.js +1 -1
- package/esm/forms/components/NumberRangeSlider.d.ts +1 -1
- package/esm/forms/components/NumberRangeSlider.js +1 -1
- package/esm/forms/components/NumberSlider.d.ts +1 -1
- package/esm/forms/components/NumberSlider.js +1 -1
- package/esm/forms/components/SyntheticButton.js +1 -1
- package/esm/forms/components/TimePickerInput.d.ts +2 -2
- package/esm/forms/components/TimePickerInput.js +1 -1
- package/esm/forms/dateUtilities.js +1 -1
- package/esm/forms/datetime.js +1 -1
- package/esm/forms/files.js +1 -1
- package/esm/forms/geometry.js +1 -1
- package/esm/forms/number.d.ts +1 -1
- package/esm/forms/number.js +1 -1
- package/esm/forms/numberFormatter.js +1 -1
- package/esm/forms/numberSliderUtilities.js +1 -1
- package/esm/forms/presenter.js +1 -1
- package/esm/forms/renderers.js +1 -1
- package/esm/forms/scanner.js +1 -1
- package/esm/forms/selectors.js +1 -1
- package/esm/forms/text.js +1 -1
- package/esm/forms/utils.js +1 -1
- package/esm/libs/version.d.ts +1 -1
- package/esm/libs/version.js +1 -1
- package/esm/licensing/LicenseChecker.js +1 -1
- package/esm/licensing/Watermark.js +1 -1
- package/package.json +13 -9
- package/runtime/Errors.js +1 -1
- package/runtime/Validation.js +1 -1
- package/runtime/activities/arcgis/AddFeatureLayer.js +1 -1
- package/runtime/activities/arcgis/AddFeatures.js +1 -1
- package/runtime/activities/arcgis/AddGraphics.js +1 -1
- package/runtime/activities/arcgis/DeleteFeatures.js +1 -1
- package/runtime/activities/arcgis/GetViewExtent.js +1 -1
- package/runtime/activities/arcgis/MapProvider.js +1 -1
- package/runtime/activities/arcgis/RemoveFeatureSetFields.js +1 -1
- package/runtime/activities/arcgis/RemoveGraphics.js +1 -1
- package/runtime/activities/arcgis/RunPrint.js +1 -1
- package/runtime/activities/arcgis/RunReport.d.ts +1 -0
- package/runtime/activities/arcgis/RunReport.js +1 -1
- package/runtime/activities/arcgis/RunWorkflow.js +1 -1
- package/runtime/activities/arcgis/SetLayerDefinitionExpression.js +1 -1
- package/runtime/activities/arcgis/SetViewpoint.js +1 -1
- package/runtime/activities/arcgis/ShowResults.js +1 -1
- package/runtime/activities/arcgis/UpdateFeatures.js +1 -1
- package/runtime/activities/arcgis/runUtils.js +1 -1
- package/runtime/activities/arcgis/shared.js +1 -1
- package/runtime/activities/core/ForEach.js +1 -1
- package/runtime/activities/core/ParseUrl.js +1 -1
- package/runtime/activities/forms/FormRenderer.d.ts +2 -3
- package/runtime/activities/forms/FormRenderer.js +1 -1
- package/runtime/activities/forms/GetFormElementItemsFromCollection.d.ts +6 -0
- package/runtime/activities/forms/GetFormElementItemsFromCollection.js +1 -1
- package/runtime/amdpile.js +1 -1
- package/runtime/amdpile.js.LICENSE.txt +12 -20
- package/runtime/app/AppActivity.d.ts +0 -2
- package/runtime/app/AppActivity.js +1 -1
- package/runtime/bundle.js +1 -1
- package/runtime/deps/react/index.min.js +2 -0
- package/runtime/deps/react/index.min.js.LICENSE.txt +14 -0
- package/runtime/execution/ProgramRunner.js +1 -1
- package/runtime/forms/FormComponent.d.ts +2 -2
- package/runtime/forms/FormComponent.js +1 -1
- package/runtime/forms/FormDefinition.d.ts +1 -1
- package/runtime/forms/FormElementOuter.d.ts +4 -4
- package/runtime/forms/FormElementOuter.js +1 -1
- package/runtime/forms/FormHost.d.ts +5 -6
- package/runtime/forms/FormHost.js +1 -1
- package/runtime/forms/FormPresenterHost.d.ts +5 -8
- package/runtime/forms/NumberParser.d.ts +25 -0
- package/runtime/forms/NumberParser.js +1 -0
- package/runtime/forms/assets/arrow.js +1 -1
- package/runtime/forms/assets/chevron.js +1 -1
- package/runtime/forms/assets/cross.js +1 -1
- package/runtime/forms/assets/datetime.js +1 -1
- package/runtime/forms/assets/remove.js +1 -1
- package/runtime/forms/assets/scan.js +1 -1
- package/runtime/forms/common.js +1 -1
- package/runtime/forms/components/DatePicker.d.ts +1 -1
- package/runtime/forms/components/DatePicker.js +1 -1
- package/runtime/forms/components/DateRangePicker.d.ts +1 -1
- package/runtime/forms/components/DateRangePicker.js +1 -1
- package/runtime/forms/components/DateTimePicker.js +1 -1
- package/runtime/forms/components/Navigator.js +1 -1
- package/runtime/forms/components/NumberRangeSlider.d.ts +1 -1
- package/runtime/forms/components/NumberRangeSlider.js +1 -1
- package/runtime/forms/components/NumberSlider.d.ts +1 -1
- package/runtime/forms/components/NumberSlider.js +1 -1
- package/runtime/forms/components/SyntheticButton.js +1 -1
- package/runtime/forms/components/TimePickerInput.d.ts +2 -2
- package/runtime/forms/components/TimePickerInput.js +1 -1
- package/runtime/forms/dateUtilities.js +1 -1
- package/runtime/forms/datetime.js +1 -1
- package/runtime/forms/files.js +1 -1
- package/runtime/forms/geometry.js +1 -1
- package/runtime/forms/number.d.ts +1 -1
- package/runtime/forms/number.js +1 -1
- package/runtime/forms/numberSliderUtilities.js +1 -1
- package/runtime/forms/presenter.js +1 -1
- package/runtime/forms/renderers.js +1 -1
- package/runtime/forms/scanner.js +1 -1
- package/runtime/forms/selectors.js +1 -1
- package/runtime/forms/text.js +1 -1
- package/runtime/forms/utils.js +1 -1
- package/runtime/libs/version.d.ts +1 -1
- package/runtime/libs/version.js +1 -1
- package/runtime/licensing/LicenseChecker.js +1 -1
- package/runtime/licensing/Watermark.js +1 -1
- package/amd/forms/locales/stock.d.ts +0 -1
- package/amd/forms/locales/stock.js +0 -1
- package/esm/forms/locales/stock.d.ts +0 -1
- package/esm/forms/locales/stock.js +0 -1
- package/runtime/forms/locales/stock.d.ts +0 -1
- package/runtime/forms/locales/stock.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ActivityActivationError,ActivityBindingError,ActivityCancellationError,ActivityError,AggregateActivityError,EngineRuntimeError,ExpressionAccessorError,ExpressionEvaluationError,ExpressionSyntaxError,GenericActivityError,ProgramStartError}from"../Errors.js";import{query}from"../Hooks.js";import{Task}from"../Task.js";import Bluebird from"../deps/bluebird_fork.js";function isExpression(t){var e=t.type;return null==e&&"string"==typeof t.code}function createLinkedCancellationToken(t,e){const r=Task.race([new Task(e),t]),i=new AbortController;return r.signal=i.signal,r.finally(()=>i.abort()),r}function isInvalidHandler(t){return null==t||"function"!=typeof t.execute}function isLiteral(t){switch(typeof t){case"boolean":case"number":case"string":return!0}return!1}let evaluators={};function clearExpressionCache(){evaluators={}}const reservedIdentifiers=["resources","values","Date","Math","Object","parseInt","parseFloat","decodeURIComponent","encodeURIComponent"];function isAccessor(e){return!("string"!=typeof e||e.length<1)&&(!(0<=e.indexOf("."))&&!reservedIdentifiers.some(t=>t===e))}function compileExpression(t,e){var r=t.code;let i=evaluators[r];if(void 0===i){const s=[],o={};s.push('"use strict"; ');var n=t.accessors;if(Array.isArray(n))for(const a of n)isAccessor(a)&&!o[a]&&(s.push(`var ${a} = this.${a};`),o[a]=!0);s.push("return "),s.push(r),s.push(";"),i=evaluators[r]=new Function("resources","values",s.join(""))}return function(){return i.call(this,e,t.values)}}function echo(t){return t}const echoHandler={execute:echo};function combine(t,e){return{...t||{},...e||{}}}function isError(t){return void 0!==t}function filterErrors(t){return t.filter(isError)}function reduceErrors(t){return t.isPending()?t.then(filterErrors):t.isFulfilled()?Bluebird.resolve(filterErrors(t.value())):t}let nextSymbol,nextSymbolPrefix;function newSymbol(){return void 0!==nextSymbol&&1073741824<=nextSymbol&&(nextSymbol=void 0),void 0===nextSymbol&&(nextSymbol=0,nextSymbolPrefix=(new Date).valueOf()+":"),nextSymbolPrefix+nextSymbol++}const immediate=Bluebird.resolve(void 0);let guard=!0;class Proxy{constructor(t){Object.defineProperty(this,"target",{get(){if(!1===guard)return guard=!0,t}})}}class AmbientStateProxy extends Proxy{get outputs(){return guard=!1,this.target.outputs}set outputs(t){guard=!1,this.target.outputs=t}get error(){return guard=!1,this.target.error}set error(t){guard=!1,this.target.error=t}get completion(){return guard=!1,this.target.completion}complete(t){return guard=!1,this.target.complete(t)}reject(t){return guard=!1,this.target.reject(t)}get environment(){return guard=!1,this.target.environment}get inputs(){return guard=!1,this.target.inputs}get activityContexts(){return guard=!1,this.target.activityContexts}get locale(){return guard=!1,this.target.locale}get resources(){return guard=!1,this.target.resources}get trivia(){return guard=!1,this.target.trivia}}class ActivityContextProxy extends Proxy{get luid(){return guard=!1,this.target.luid}get ambient(){return guard=!1,this.target.ambient.proxy}get action(){return guard=!1,this.target.action}get branch(){return guard=!1,this.target.branch}get cancellationToken(){return guard=!1,this.target.cancellationToken}get passes(){return guard=!1,this.target.passes}get caught(){return guard=!1,this.target.caught}call(t){return guard=!1,this.target.call(t)}fork(t){return guard=!1,this.target.fork(t)}jump(t){return guard=!1,this.target.jump(t)}hasBranch(t){return guard=!1,this.target.hasBranch(t)}get state(){return guard=!1,this.target.state}registerForErrors(){return guard=!1,this.target.registerForErrors()}persist(t){return guard=!1,this.target.persist(t)}goto(){return guard=!1,this.target.goto()}}class AmbientState{constructor(){this.frame=new MonikerFrame,this.stack=[],this.handlers={}}get activityContexts(){const t={};for(const e of[...this.stack,this.frame])for(const r in e.state)"$$"===r.substring(0,2)&&(t[r]=e.state[r]);return t}break(){this.halted=!0}continue(){this.halted=!1,void 0!==this.scheduler&&!this.scheduler.isFulfilled()||(this.scheduler=immediate.then(t=>{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 r=this.frame.current.execute();if(r.isPending())break;r.isRejected()&&this.fail(r.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 i=e.cancellationResolve;void 0!==i&&i()}var r=this.frame=this.stack.pop();return void 0===r&&(void 0!==t?this.reject(t):this.complete()),r}call(){var t=this.frame;const e=this.push();e.cancellationToken=t.cancellationToken,e.state=t.state}fork(){const e=this.push();e.cancellationToken=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 r;void 0!==e&&(r=e.current,this.start(r.activity,r,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,r){const i=e.frame=this.frame;if((i.current=e).luid=this.id+":"+e.activity.id,e.action=e.activity.action,e.ambient=this,e.id=newSymbol(),e.caught=r,e.cancellationToken=createLinkedCancellationToken(i.cancellationToken,t=>e.cancellationResolve=t),e.proxy=new ActivityContextProxy(e),void 0!==t){const n=e.recent=t.recent||(t.recent={});t=n.context||t;(n.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,r){const i=new(t.async?AsyncContext:StepContext);i.activity=t,i.monikers.push("$"),this.prepare(i,e,r)}enqueue(t,e){const r=this.inspector;this.queue=r.relate(t,e).list(),this.next()}goto(t){for(var e=this.stack,r=t.index;e[r]===t;)this.pop();return t===this.frame}}class MonikerFrame{}class PromiseWrapper{}class ActivityContext{constructor(){this.inputs={},this.extras=[],this.monikers=[]}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 e=this.activity;const r=this.ambient.inspector;return r.isStep(e)&&void 0!==r.relate(e,t).peek()}emitExpressionEvaluationError(t,e){var r=this.activity.id,i=this.activity.inputs[t];return new ExpressionEvaluationError(r,t,i.source||i.code,e)}emitExpressionSyntaxError(t,e){var r=this.activity.id,i=this.activity.inputs[t];return new ExpressionSyntaxError(r,t,i.source||i.code,e)}emitExpressionAccessorError(t,e,r){return new ExpressionAccessorError(this.activity.id,t,e,r)}emitActivityBindingError(t){var e=this.activity;return new ActivityBindingError(e.id,e.action,t)}emitActivityActivationError(t,e){return new ActivityActivationError(this.activity.id,t,e)}emitActivityError(t){if(t instanceof ActivityError)return t;var e=this.activity;const r=new GenericActivityError(void 0,t&&t.message);return r.activityId=e.id,r.error=t,r}executeHandlerInline(e){if(0<e.length||this.cancellationToken.isFulfilled())return e;const r=this.extras;for(let t=0;t<r.length;t++)r[t]=Bluebird.resolve(r[t]).value();const i=this.inputs;for(const o in i){let t=Bluebird.resolve(i[o]).value();t instanceof PromiseWrapper&&(t=t.result),i[o]=t}const t=this.proxy,n=this.handler.value(),s=Bluebird.attempt(function(){return n.execute(i,t,...r)});return s.isPending()?s.then(t=>(this.outputs=t,e),t=>[this.emitActivityError(t)]):s.isRejected()?[this.emitActivityError(s.reason())]:(this.outputs=s.value(),e)}resolveExtrasInline(){for(const e of query(this.handler.value())){const t=this.ambient.engine.activator,r=t.activate(e);if(this.extras.push(r),r.isPending())return r.then(t=>{},t=>this.emitActivityActivationError(e.type,t));if(r.isRejected())return this.emitActivityActivationError(e.type,r.reason())}}resolveInputsInline(t){if(0<t.length||this.cancellationToken.isFulfilled())return t;const e=[];e.push(this.resolveExtrasInline());const r=this.evaluators;if(void 0!==r){const i=this.scope;for(const s in i)i[s]=Bluebird.resolve(i[s]).value();const n=this.inputs;this.ambient.resources;for(const o in r){const a=n[o]=Bluebird.attempt(function(){var t=r[o].call(i);if(t&&"function"==typeof t.then){const e=new PromiseWrapper;return e.result=t,e}return t});a.isPending()&&e.push(a.then(t=>{},t=>this.emitExpressionEvaluationError(o,t))),a.isRejected()&&e.push(this.emitExpressionEvaluationError(o,a.reason()))}}return reduceErrors(Bluebird.all(e))}resolveHandlerInline(){const e=this.activity.action;if("string"==typeof e){var r=this.ambient;const i=r.handlers;let t=this.handler=i[e];if(void 0===t){const n=r.engine,s=r.inspector;t=this.handler=i[e]=Bluebird.attempt(function(){return n.createHandler(e,s)})}return t.isPending()?t.then(t=>isInvalidHandler(t)?this.emitActivityBindingError():void 0,t=>this.emitActivityBindingError(t)):t.isRejected()?this.emitActivityBindingError(t.reason()):isInvalidHandler(t.value())?this.emitActivityBindingError():void 0}this.handler=Bluebird.resolve(echoHandler)}findContext(t){var e=this.ambient,r=e.stack;let i=e.frame;for(;void 0!==i;){var n=i.state[t];if(void 0!==n)return n;i=r[i.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,t=>{});if(t.isRejected())return immediate;var e=t.value();return void 0!==e&&0<e.length?Bluebird.reject(e):Bluebird.resolve(this.outputs)}resolveAccessorInline(e){const t=this.findContext(e);this.scope;if(void 0!==t){const r=this.scope[e]=t.resolveOutputsInline();return r.isPending()?r.then(t=>{},t=>this.emitExpressionAccessorError(e,void 0,t)):r.isRejected()?this.emitExpressionAccessorError(e,void 0,r.reason()):void 0}const r=this.scope[e]=Bluebird.resolve(this.ambient.environment[e]);return r.isPending()?r.then(t=>{},t=>this.emitExpressionAccessorError(e,t)):r.isRejected()?this.emitExpressionAccessorError(e,r.reason()):void 0}resolveAssetsInline(){const r=[];r.push(this.resolveHandlerInline());var i=this.activity.inputs;if(null!=i){let t,e;const s=this.ambient;this.inputs;for(const o in i){const a=i[o];if(void 0!==a&&null!==a)if(isLiteral(a))this.inputs[o]=Bluebird.resolve(a);else if(isExpression(a)){void 0===t&&(this.scope=t={}),void 0===e&&(this.evaluators=e={});var n=a.accessors;if(Array.isArray(n))for(const l of n)"string"==typeof l&&void 0===t[l]&&r.push(this.resolveAccessorInline(l));const c=Bluebird.attempt(function(){return compileExpression(a,s.resources)});c.isFulfilled()?e[o]=c.value():r.push(this.emitExpressionSyntaxError(o,c.reason()))}else r.push(this.emitExpressionSyntaxError(o))}}return reduceErrors(Bluebird.all(r))}concludeInline(t){return this.cancellationResolve(),t}generateMonikers(){const t=this.monikers;var e=this.activity;this.ambient.inspector;t.push("$"+e.id),"string"==typeof e.name&&t.push("$"+e.name);const r=e.action;"string"!=typeof r||1<(e=r.split(":")).length&&(0<(e=e[e.length-2]).length&&t.push("$$"+e))}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 e=this.ambient;if(void 0!==t)return e.debug(e),e.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=>e.fail(t)),t.then(t=>e.execute())),this.generateMonikers();const r=e.frame.state;for(const i of this.monikers)r[i]=this;return this.promise=t,immediate}}goto(){}}class StepContext extends ActivityContext{transferInline(){const t=this.promise;if(t.isFulfilled()){const r=this.ambient;var e=this.marshalError();void 0!==e?r.bubble(e):this.repeat?r.start(this.activity,this):(this.callBranch&&r.call(),this.forkBranch&&r.fork(),r.enqueue(this.activity,this.jumpBranch))}}goto(){const t=this.frame,e=this.ambient;if(e.goto(t)){var r=this.recent;const i=void 0!==r?r.context:this;t.current=i,i.repeat=!0,e.halted=!1,e.execute()}}}class TransitionContext extends ActivityContext{test(){let t=void 0,e=void 0;var r=this.outputs;for(const i in r){if(void 0!==t&&void 0!==e)return!1;if(e=r[i],!isLiteral(e))return!1;if(void 0===t)t=e,e=void 0;else if(t!==e)return!1}return void 0===t||(void 0!==e||("boolean"==typeof t?t:"number"==typeof t?0<t:"string"==typeof t&&0<t.length))}transferInline(){const t=this.promise;if(t.isFulfilled()){t.value();const r=this.ambient;var e=this.marshalError();void 0!==e?r.bubble(e):this.test()?r.start(this.activity.target):r.next()}}}class AsyncContext extends ActivityContext{transferInline(){this.ambient.enqueue(this.activity)}execute(){return super.execute(),immediate}}function run(n,s,o,a){const c=t=>{var e=s.findStep(t);if(!e)throw new GenericActivityError(`The workflow does not contain a step with the id ${t}.`);return e},l=(t,e,r,i)=>{t=c(t);const n=c(e);if(!n.transitions.some(t=>"content"===t.branch||"try"===t.branch))throw new GenericActivityError(`The ${e} step is not a Container, Subworkflow, or Try Catch activity.`);r=`${i}$${r}`;h(t,n,r)},u=t=>{var e=d.frame.current.activity,r=c(t);if("gcx:wf:core::Subworkflow"!==r.action)throw new GenericActivityError(`The target step ${t} is not a Subworkflow activity.`);h(e,r,"default")},h=(t,e,r)=>{var i=s.relate(t,r).peek();void 0!==i&&s.remove(i);const n=s.addTransition(t,e);n.branch=r},d=new AmbientState;return d.completion=new Bluebird((t,e)=>{d.resolveCompletion=t,d.rejectCompletion=e}),d.cancellationToken=new Task(t=>d.cancellationResolve=t),d.execute(function(){if(s.isStep(a)){o=o||{},d.engine=n,d.inspector=s,d.id=newSymbol(),d.debug=o.debug||(()=>{}),d.environment=combine(n.environment,o.environment),d.inputs=o.inputs||{},d.locale=o.locale,d.resources={forms:s.cacheForms()},d.outputs={},d.trivia=combine(n.trivia,o.trivia),d.trivia.setFormElementEvent=l,d.trivia.setSubworkflowTransition=u,d.proxy=new AmbientStateProxy(d);const e=d.trivia.isDescendantOf;e?d.trivia.isDescendantOf=t=>t===d.proxy||e(t):d.trivia.isDescendantOf=t=>t===d.proxy;const r=d.frame;r.index=0,r.cancellationToken=d.cancellationToken,r.state=o.state||{};var t=o.cancellationToken;if(null!=t){const i=Task.race([t,d.cancellationToken]);i.isPending()?(t=()=>d.cancel(),i.then(t,t)):d.cancel()}d.start(a)}else d.reject(new ProgramStartError)}),d.completion}export{clearExpressionCache,run};
|
|
1
|
+
import{ActivityActivationError,ActivityBindingError,ActivityCancellationError,ActivityError,AggregateActivityError,EngineRuntimeError,ExpressionAccessorError,ExpressionEvaluationError,ExpressionSyntaxError,GenericActivityError,ProgramStartError}from"../Errors.js";import{query}from"../Hooks.js";import{Task}from"../Task.js";import Bluebird from"../deps/bluebird_fork.js";function isExpression(t){var e=t.type;return null==e&&"string"==typeof t.code}function createLinkedCancellationToken(t,e){const r=Task.race([new Task(e),t]),i=new AbortController;return r.signal=i.signal,r.finally(()=>i.abort()),r}function isInvalidHandler(t){return null==t||"function"!=typeof t.execute}function isLiteral(t){switch(typeof t){case"boolean":case"number":case"string":return!0}return!1}let evaluators={};function clearExpressionCache(){evaluators={}}const reservedIdentifiers=["resources","values","Date","Math","Object","parseInt","parseFloat","decodeURIComponent","encodeURIComponent"];function isAccessor(e){return!("string"!=typeof e||e.length<1)&&(!(0<=e.indexOf("."))&&!reservedIdentifiers.some(t=>t===e))}function compileExpression(t,e){var r=t.code;let i=evaluators[r];if(void 0===i){const s=[],o={};s.push('"use strict"; ');var n=t.accessors;if(Array.isArray(n))for(const a of n)isAccessor(a)&&!o[a]&&(s.push(`var ${a} = this.${a};`),o[a]=!0);s.push("return "),s.push(r),s.push(";"),i=evaluators[r]=new Function("resources","values",s.join(""))}return function(){return i.call(this,e,t.values)}}function echo(t){return t}const echoHandler={execute:echo};function combine(t,e){return{...t||{},...e||{}}}function isError(t){return void 0!==t}function filterErrors(t){return t.filter(isError)}function reduceErrors(t){return t.isPending()?t.then(filterErrors):t.isFulfilled()?Bluebird.resolve(filterErrors(t.value())):t}let nextSymbol,nextSymbolPrefix;function newSymbol(){return void 0!==nextSymbol&&1073741824<=nextSymbol&&(nextSymbol=void 0),void 0===nextSymbol&&(nextSymbol=0,nextSymbolPrefix=(new Date).valueOf()+":"),nextSymbolPrefix+nextSymbol++}const immediate=Bluebird.resolve(void 0);let guard=!0;class Proxy{constructor(t){Object.defineProperty(this,"target",{get(){if(!1===guard)return guard=!0,t}})}}class AmbientStateProxy extends Proxy{get outputs(){return guard=!1,this.target.outputs}set outputs(t){guard=!1,this.target.outputs=t}get error(){return guard=!1,this.target.error}set error(t){guard=!1,this.target.error=t}get completion(){return guard=!1,this.target.completion}complete(t){return guard=!1,this.target.complete(t)}reject(t){return guard=!1,this.target.reject(t)}get environment(){return guard=!1,this.target.environment}get inputs(){return guard=!1,this.target.inputs}get activityContexts(){return guard=!1,this.target.activityContexts}get locale(){return guard=!1,this.target.locale}get resources(){return guard=!1,this.target.resources}get trivia(){return guard=!1,this.target.trivia}}class ActivityContextProxy extends Proxy{get luid(){return guard=!1,this.target.luid}get ambient(){return guard=!1,this.target.ambient.proxy}get action(){return guard=!1,this.target.action}get branch(){return guard=!1,this.target.branch}get cancellationToken(){return guard=!1,this.target.cancellationToken}get passes(){return guard=!1,this.target.passes}get caught(){return guard=!1,this.target.caught}call(t){return guard=!1,this.target.call(t)}fork(t){return guard=!1,this.target.fork(t)}jump(t){return guard=!1,this.target.jump(t)}hasBranch(t){return guard=!1,this.target.hasBranch(t)}get state(){return guard=!1,this.target.state}registerForErrors(){return guard=!1,this.target.registerForErrors()}persist(t){return guard=!1,this.target.persist(t)}goto(){return guard=!1,this.target.goto()}}class AmbientState{constructor(){this.frame=new MonikerFrame,this.stack=[],this.handlers={}}get activityContexts(){const t={};for(const e of[...this.stack,this.frame])for(const r in e.state)"$$"===r.substring(0,2)&&(t[r]=e.state[r]);return t}break(){this.halted=!0}continue(){this.halted=!1,void 0!==this.scheduler&&!this.scheduler.isFulfilled()||(this.scheduler=immediate.then(t=>{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 r=this.frame.current.execute();if(r.isPending())break;r.isRejected()&&this.fail(r.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 i=e.cancellationResolve;void 0!==i&&i()}var r=this.frame=this.stack.pop();return void 0===r&&(void 0!==t?this.reject(t):this.complete()),r}call(){var t=this.frame;const e=this.push();e.cancellationToken=t.cancellationToken,e.state=t.state}fork(){const e=this.push();e.cancellationToken=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 r;void 0!==e&&(r=e.current,this.start(r.activity,r,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,r){const i=e.frame=this.frame;if((i.current=e).luid=this.id+":"+e.activity.id,e.action=e.activity.action,e.ambient=this,e.id=newSymbol(),e.caught=r,e.cancellationToken=createLinkedCancellationToken(i.cancellationToken,t=>e.cancellationResolve=t),e.proxy=new ActivityContextProxy(e),void 0!==t){const n=e.recent=t.recent||(t.recent={});t=n.context||t;(n.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,r){const i=new(t.async?AsyncContext:StepContext);i.activity=t,i.monikers.push("$"),this.prepare(i,e,r)}enqueue(t,e){const r=this.inspector;this.queue=r.relate(t,e).list(),this.next()}goto(t){for(var e=this.stack,r=t.index;e[r]===t;)this.pop();return t===this.frame}}class MonikerFrame{}class PromiseWrapper{}class ActivityContext{constructor(){this.inputs={},this.extras=[],this.monikers=[]}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 e=this.activity;const r=this.ambient.inspector;return r.isStep(e)&&void 0!==r.relate(e,t).peek()}emitExpressionEvaluationError(t,e){var r=this.activity.id,i=this.activity.inputs[t];return new ExpressionEvaluationError(r,t,i.source||i.code,e)}emitExpressionSyntaxError(t,e){var r=this.activity.id,i=this.activity.inputs[t];return new ExpressionSyntaxError(r,t,i.source||i.code,e)}emitExpressionAccessorError(t,e,r){return new ExpressionAccessorError(this.activity.id,t,e,r)}emitActivityBindingError(t){var e=this.activity;return new ActivityBindingError(e.id,e.action,t)}emitActivityActivationError(t,e){return new ActivityActivationError(this.activity.id,t,e)}emitActivityError(t){if(t instanceof ActivityError)return t;var e=this.activity;const r=new GenericActivityError(void 0,t?.message);return r.activityId=e.id,r.error=t,r}executeHandlerInline(e){if(0<e.length||this.cancellationToken.isFulfilled())return e;const r=this.extras;for(let t=0;t<r.length;t++)r[t]=Bluebird.resolve(r[t]).value();const i=this.inputs;for(const o in i){let t=Bluebird.resolve(i[o]).value();t instanceof PromiseWrapper&&(t=t.result),i[o]=t}const t=this.proxy,n=this.handler.value(),s=Bluebird.attempt(function(){return n.execute(i,t,...r)});return s.isPending()?s.then(t=>(this.outputs=t,e),t=>[this.emitActivityError(t)]):s.isRejected()?[this.emitActivityError(s.reason())]:(this.outputs=s.value(),e)}resolveExtrasInline(){for(const e of query(this.handler.value())){const t=this.ambient.engine.activator,r=t.activate(e);if(this.extras.push(r),r.isPending())return r.then(t=>{},t=>this.emitActivityActivationError(e.type,t));if(r.isRejected())return this.emitActivityActivationError(e.type,r.reason())}}resolveInputsInline(t){if(0<t.length||this.cancellationToken.isFulfilled())return t;const e=[];e.push(this.resolveExtrasInline());const r=this.evaluators;if(void 0!==r){const i=this.scope;for(const s in i)i[s]=Bluebird.resolve(i[s]).value();const n=this.inputs;for(const o in r){const a=n[o]=Bluebird.attempt(function(){var t=r[o].call(i);if(t&&"function"==typeof t.then){const e=new PromiseWrapper;return e.result=t,e}return t});a.isPending()&&e.push(a.then(t=>{},t=>this.emitExpressionEvaluationError(o,t))),a.isRejected()&&e.push(this.emitExpressionEvaluationError(o,a.reason()))}}return reduceErrors(Bluebird.all(e))}resolveHandlerInline(){const e=this.activity.action;if("string"==typeof e){var r=this.ambient;const i=r.handlers;let t=this.handler=i[e];if(void 0===t){const n=r.engine,s=r.inspector;t=this.handler=i[e]=Bluebird.attempt(function(){return n.createHandler(e,s)})}return t.isPending()?t.then(t=>isInvalidHandler(t)?this.emitActivityBindingError():void 0,t=>this.emitActivityBindingError(t)):t.isRejected()?this.emitActivityBindingError(t.reason()):isInvalidHandler(t.value())?this.emitActivityBindingError():void 0}this.handler=Bluebird.resolve(echoHandler)}findContext(t){var e=this.ambient,r=e.stack;let i=e.frame;for(;void 0!==i;){var n=i.state[t];if(void 0!==n)return n;i=r[i.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,t=>{});if(t.isRejected())return immediate;var e=t.value();return void 0!==e&&0<e.length?Bluebird.reject(e):Bluebird.resolve(this.outputs)}resolveAccessorInline(e){const t=this.findContext(e);if(void 0!==t){const r=this.scope[e]=t.resolveOutputsInline();return r.isPending()?r.then(t=>{},t=>this.emitExpressionAccessorError(e,void 0,t)):r.isRejected()?this.emitExpressionAccessorError(e,void 0,r.reason()):void 0}const r=this.scope[e]=Bluebird.resolve(this.ambient.environment[e]);return r.isPending()?r.then(t=>{},t=>this.emitExpressionAccessorError(e,t)):r.isRejected()?this.emitExpressionAccessorError(e,r.reason()):void 0}resolveAssetsInline(){const r=[];r.push(this.resolveHandlerInline());var i=this.activity.inputs;if(null!=i){let t,e;const s=this.ambient;for(const o in i){const a=i[o];if(void 0!==a&&null!==a)if(isLiteral(a))this.inputs[o]=Bluebird.resolve(a);else if(isExpression(a)){void 0===t&&(this.scope=t={}),void 0===e&&(this.evaluators=e={});var n=a.accessors;if(Array.isArray(n))for(const l of n)"string"==typeof l&&void 0===t[l]&&r.push(this.resolveAccessorInline(l));const c=Bluebird.attempt(function(){return compileExpression(a,s.resources)});c.isFulfilled()?e[o]=c.value():r.push(this.emitExpressionSyntaxError(o,c.reason()))}else r.push(this.emitExpressionSyntaxError(o))}}return reduceErrors(Bluebird.all(r))}concludeInline(t){return this.cancellationResolve(),t}generateMonikers(){const t=this.monikers;var e=this.activity;t.push("$"+e.id),"string"==typeof e.name&&t.push("$"+e.name);const r=e.action;"string"!=typeof r||1<(e=r.split(":")).length&&(0<(e=e[e.length-2]).length&&t.push("$$"+e))}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 e=this.ambient;if(void 0!==t)return e.debug(e),e.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=>e.fail(t)),t.then(t=>e.execute())),this.generateMonikers();const r=e.frame.state;for(const i of this.monikers)r[i]=this;return this.promise=t,immediate}}goto(){}}class StepContext extends ActivityContext{transferInline(){const t=this.promise;if(t.isFulfilled()){const r=this.ambient;var e=this.marshalError();void 0!==e?r.bubble(e):this.repeat?r.start(this.activity,this):(this.callBranch&&r.call(),this.forkBranch&&r.fork(),r.enqueue(this.activity,this.jumpBranch))}}goto(){const t=this.frame,e=this.ambient;if(e.goto(t)){var r=this.recent;const i=void 0!==r?r.context:this;t.current=i,i.repeat=!0,e.halted=!1,e.execute()}}}class TransitionContext extends ActivityContext{test(){let t=void 0,e=void 0;var r=this.outputs;for(const i in r){if(void 0!==t&&void 0!==e)return!1;if(e=r[i],!isLiteral(e))return!1;if(void 0===t)t=e,e=void 0;else if(t!==e)return!1}return void 0===t||(void 0!==e||("boolean"==typeof t?t:"number"==typeof t?0<t:"string"==typeof t&&0<t.length))}transferInline(){const t=this.promise;if(t.isFulfilled()){const r=this.ambient;var e=this.marshalError();void 0!==e?r.bubble(e):this.test()?r.start(this.activity.target):r.next()}}}class AsyncContext extends ActivityContext{transferInline(){this.ambient.enqueue(this.activity)}execute(){return super.execute(),immediate}}function run(n,s,o,a){const c=t=>{var e=s.findStep(t);if(!e)throw new GenericActivityError(`The workflow does not contain a step with the id ${t}.`);return e},l=(t,e,r,i)=>{t=c(t);const n=c(e);if(!n.transitions.some(t=>"content"===t.branch||"try"===t.branch))throw new GenericActivityError(`The ${e} step is not a Container, Subworkflow, or Try Catch activity.`);r=`${i}$${r}`;h(t,n,r)},u=t=>{var e=d.frame.current.activity,r=c(t);if("gcx:wf:core::Subworkflow"!==r.action)throw new GenericActivityError(`The target step ${t} is not a Subworkflow activity.`);h(e,r,"default")},h=(t,e,r)=>{var i=s.relate(t,r).peek();void 0!==i&&s.remove(i);const n=s.addTransition(t,e);n.branch=r},d=new AmbientState;return d.completion=new Bluebird((t,e)=>{d.resolveCompletion=t,d.rejectCompletion=e}),d.cancellationToken=new Task(t=>d.cancellationResolve=t),d.execute(function(){if(s.isStep(a)){o=o||{},d.engine=n,d.inspector=s,d.id=newSymbol(),d.debug=o.debug||(()=>{}),d.environment=combine(n.environment,o.environment),d.inputs=o.inputs||{},d.locale=o.locale,d.resources={forms:s.cacheForms()},d.outputs={},d.trivia=combine(n.trivia,o.trivia),d.trivia.setFormElementEvent=l,d.trivia.setSubworkflowTransition=u,d.proxy=new AmbientStateProxy(d);const e=d.trivia.isDescendantOf;e?d.trivia.isDescendantOf=t=>t===d.proxy||e(t):d.trivia.isDescendantOf=t=>t===d.proxy;const r=d.frame;r.index=0,r.cancellationToken=d.cancellationToken,r.state=o.state||{};var t=o.cancellationToken;if(null!=t){const i=Task.race([t,d.cancellationToken]);i.isPending()?(t=()=>d.cancel(),i.then(t,t)):d.cancel()}d.start(a)}else d.reject(new ProgramStartError)}),d.completion}export{clearExpressionCache,run};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Component } from "react";
|
|
2
2
|
import * as defs from "./FormDefinition";
|
|
3
3
|
import { FormPresenterHost } from "./FormPresenterHost";
|
|
4
4
|
import type { FormElementProps, FormElementRegistration } from "..";
|
|
@@ -9,7 +9,7 @@ export interface FormComponentProps {
|
|
|
9
9
|
name?: string;
|
|
10
10
|
children?: JSX.Element[];
|
|
11
11
|
}
|
|
12
|
-
export declare class FormComponent extends
|
|
12
|
+
export declare class FormComponent extends Component<FormComponentProps, {}> {
|
|
13
13
|
id: string;
|
|
14
14
|
autoInput: boolean;
|
|
15
15
|
enabled: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import{Component}from"react";import{makeId}from"./utils.js";class FormComponent extends Component{constructor(){super(...arguments),this.raiseEvent=(e,t)=>this.props.host?.post(e,{name:this.props.name,value:t}),this.setProperty=(e,t)=>{const s=this.props.host;var n=this.props.name;s.assignElementProperty(n,e,t)},this.setValue=e=>this.setProperty("value",e)}get elementRegistration(){const e=this.props["host"];if(isFormRenderer(e))return e.getElementRegistration(this.element)}get element(){const{host:e,name:t}=this.props;if(t)return e.find(t)}prepare(){var e;void 0===this.id&&(this.id=makeId()),this.enabled=!0;const t=this.props.host;return!1===t.enabled&&(this.enabled=!1),void 0!==this.element&&(void 0!==(e=t.find(this.element.section))&&!1===e.enabled&&(this.enabled=!1),!1===this.element.enabled&&(this.enabled=!1)),this.element}render(){return this.props.host.renderVisual(this)}}class FormElement extends FormComponent{componentDidMount(){const e=this.props;e.host.refs[e.name]=this}componentDidUpdate(){const e=this.props;e.host.refs[e.name]=this}componentWillUnmount(){const e=this.props;e.host.refs[e.name]=void 0}}function isFormRenderer(e){return!!e&&"function"==typeof e.getElementRegistration}export{FormComponent,FormElement};
|
|
@@ -196,7 +196,7 @@ export interface Element {
|
|
|
196
196
|
fileTypes?: string;
|
|
197
197
|
/** Indicates the format of the value. */
|
|
198
198
|
format?: FormatRef;
|
|
199
|
-
/** Indicates
|
|
199
|
+
/** Indicates whether the element is hoisted or not. */
|
|
200
200
|
hoisted?: boolean;
|
|
201
201
|
/**
|
|
202
202
|
* The order of this element in a single-dimensional column.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
2
|
import { FormComponent } from "./FormComponent";
|
|
3
3
|
import { defs } from "./FormHost";
|
|
4
4
|
interface FormElementOuterProps {
|
|
@@ -31,7 +31,7 @@ interface FormElementOuterProps {
|
|
|
31
31
|
onMouseDown?: (event: React.MouseEvent<HTMLElement>) => void;
|
|
32
32
|
onTouchStart?: (event: React.TouchEvent<HTMLElement>) => void;
|
|
33
33
|
}
|
|
34
|
-
declare const _default:
|
|
35
|
-
children?:
|
|
36
|
-
} &
|
|
34
|
+
declare const _default: import("react").ForwardRefExoticComponent<FormElementOuterProps & {
|
|
35
|
+
children?: ReactNode;
|
|
36
|
+
} & import("react").RefAttributes<HTMLDivElement | HTMLLabelElement>>;
|
|
37
37
|
export default _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import{jsxs as _jsxs}from"react/jsx-runtime";import{forwardRef,createElement}from"react";import{renderTitle,renderDescription,renderError}from"./common.js";import{TitleLocation}from"./constants.js";import{makeSafeClassName,makeUniqueId}from"./utils.js";export default forwardRef((e,r)=>{const{children:t,className:s,component:o,element:a,errorClassName:i,htmlElementType:n,...m}=e;var l=o.props.host;const p=[];var c=makeUniqueId(o.props.name),d=renderTitle(a,l,c),u=renderDescription(a,l,c),f=renderError(a,l),e=d?.props?.id,l=u?.props?.id;const h=[];s&&h.push(...s.split(" ")),a.titleLocation===TitleLocation.BESIDE&&h.push("inline-title"),a.styleName&&h.push(makeSafeClassName(a.styleName)),f&&i&&h.push(i);r={"aria-labelledby":e,"aria-describedby":l,className:h.join(" "),id:c,ref:r,...m};return p.push(d),a.titleLocation===TitleLocation.BESIDE?p.push(_jsxs("div",{className:"form-element-content",children:[u,f,t]},void 0)):(p.push(u),p.push(f),p.push(t)),createElement(n||"div",r,...p)});
|
package/esm/forms/FormHost.d.ts
CHANGED
|
@@ -2,9 +2,9 @@ import { Lookup } from "../Collections";
|
|
|
2
2
|
import Bluebird from "../deps/bluebird_fork";
|
|
3
3
|
import { Calendar } from "./Calendar";
|
|
4
4
|
import * as defs from "./FormDefinition";
|
|
5
|
-
import { FormPresenterHost
|
|
5
|
+
import { FormPresenterHost } from "./FormPresenterHost";
|
|
6
6
|
import { FormatOptions } from "./numberFormatter";
|
|
7
|
-
export { defs
|
|
7
|
+
export { defs };
|
|
8
8
|
export interface FormEventSubscription {
|
|
9
9
|
(): boolean;
|
|
10
10
|
active: boolean;
|
|
@@ -16,6 +16,7 @@ export interface FormEventHandler {
|
|
|
16
16
|
export declare abstract class FormHost implements FormPresenterHost {
|
|
17
17
|
/** Indicates the overall state of the form. */
|
|
18
18
|
form: defs.Form;
|
|
19
|
+
deriveLocale(): string;
|
|
19
20
|
/** Indicates all errors to be assigned. */
|
|
20
21
|
errors: Lookup<defs.Text>;
|
|
21
22
|
/** Indicates any reference information relevant to components. */
|
|
@@ -178,7 +179,7 @@ export declare abstract class FormHost implements FormPresenterHost {
|
|
|
178
179
|
/** Coerces a number. */
|
|
179
180
|
coerceNumber(value: string): number;
|
|
180
181
|
/** Formats a number. */
|
|
181
|
-
formatNumber(value: number, options:
|
|
182
|
+
formatNumber(value: number, options: FormatOptions): string;
|
|
182
183
|
/** Renders a custom element. */
|
|
183
184
|
renderCustom(component: {}, element: defs.Element): JSX.Element;
|
|
184
185
|
/** Renders a component's state. */
|
|
@@ -188,9 +189,7 @@ export declare abstract class FormHost implements FormPresenterHost {
|
|
|
188
189
|
/** Derives the locale for the given facility. */
|
|
189
190
|
deriveCalendar(format: defs.DateTimeFormat): Calendar;
|
|
190
191
|
/** Derives the locale for the given facility. */
|
|
191
|
-
|
|
192
|
-
/** Derives the locale for the given facility. */
|
|
193
|
-
deriveTimeZone(facility: Facility): any;
|
|
192
|
+
deriveTimeZone(): any;
|
|
194
193
|
private getParentSection;
|
|
195
194
|
private isSectionCollapsed;
|
|
196
195
|
private isElementPositionBeforeLastFocused;
|
package/esm/forms/FormHost.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import Globalize from"globalize";import"globalize";import"globalize/number";import moment from"moment-timezone";import{Task}from"../Task.js";import{DEFAULT_LOCALE}from"../constants.js";import Bluebird from"../deps/bluebird_fork.js";import{Calendar}from"./Calendar.js";import{FormComponent}from"./FormComponent.js";import*as defs from"./FormDefinition.js";import{LOCALE}from"./locales/stock.js";import{format}from"./numberFormatter.js";import*as presenter from"./presenter.js";import*as renderers from"./renderers.js";import{CSS}from"./styles/stock.js";import{addStyleToDocument,sort,text}from"./utils.js";const guid="C0166F74-982A-464E-9FB6-9605CB7649C1:",eventName=guid+"FormEvent";function createEvent(e,t){return new CustomEvent(e,{bubbles:!1,cancelable:!1,detail:t})}function ensureTimeZone(){let e=moment.tz.names[0];return void 0===e&&moment.tz.setDefault(e=moment.tz.guess()),e}function ensureLocale(){let e=Globalize.locale();return void 0===e&&(Globalize.load(LOCALE),Globalize.locale(DEFAULT_LOCALE),e=Globalize.locale()),e.locale}function overlay(i,s){switch(typeof i){case"boolean":case"number":case"string":return i;case"object":break;default:return s}if(null===i)return s;if(i instanceof Array){let e=s;void 0!==e&&null!==e||(e=[]);let t=0;for(const n of i){var r=overlay(n,e[t]);void 0!==r&&(t<i.length?e[t]=r:e.push(r),++t)}return e}let e=s;void 0===e&&(e={});for(const t in i)e[t]=overlay(i[t],e[t]);return e}function createSubscription(e){function t(){return void 0!==e&&(t.active=!1,e(),!0)}return t.active=!0,t}let staticStyle=void 0;class FormHost{constructor(){this.form={defaults:{},elements:{}},this.errors={},this.refs={},this.enabled=!1,this.visible=!1,this.dismiss=!1,this.custom=!1,this.container=document.createElement("div"),this.eventIndex=0,this.eventQueue=[],this.mutuallyExclusiveSections={},this.nextFocus=!1,this.nextRefresh=!1,this.style=void 0}mount(){var e=this.container,t=e.parentNode;null==t&&document.body.appendChild(e),this.update()}unmount(){var e=this.container;const t=e.parentNode;void 0!==t&&null!==t&&t.removeChild(e)}observeFocus(e){this.enabled&&e instanceof HTMLElement&&(this.lastFocus&&this.lastFocus.target===e||this.setLastFocus(e))}focus(e){!0===(e=null==e?!1:e)&&(this.lastFocus=void 0),!1===e&&!1===(e=this.nextFocus)&&(e=!0),this.nextFocus=e,this.invalidate(!0!==e?e:void 0)}show(){const e=this.container;if(void 0===e)return!1;this.custom||void 0!==this.focusObserver||e.addEventListener("focus",this.focusObserver=e=>this.observeFocus(e.target),!0),this.enabled||(this.nextRefresh=!0,this.focus());const t=[];var i,s=this.errors;for(const r in s){const n=this.form.elements[r];void 0!==n&&null!==n&&(n.error=s[r],this.invalidate(r),!1!==n.visible&&(i=this.getParentSection(n),this.isSectionCollapsed(i)&&t.push(i)))}return 0<t.length&&(t.forEach(e=>{var t;this.isAccordionSection(e)?(t=this.findName(e))&&this.updateAccordionSections(t):e.collapsed=!1}),this.invalidate()),this.errors={},this.idle(),!1!==this.nextRefresh&&(this.enabled=!0,this.visible=!0,this.mount()),this.enabled}spin(){return void 0!==this.container&&(this.idle(),this.visible&&!this.enabled||(this.nextRefresh=!0,this.enabled=!1,this.visible=!0,this.mount()),this.visible)}hide(){return void 0!==this.container&&(this.idle(),this.visible&&(this.enabled=!1,this.visible=!1,this.unmount()),!0)}dispose(){if(this.dismiss)return!1;{this.dismiss=!0;const t=this.container;t.dispatchEvent(createEvent(eventName));var e=this.focusObserver;return void 0!==e&&t.removeEventListener("focus",e,!0),this.idle(),this.unmount(),this.refs={},presenter.releaseForm(this.container),this.container=void 0,this.lastFocus=void 0,!(this.eventTask=void 0)}}renderFocus(e,t){var i,s=this.nextFocus;if(this.enabled&&e instanceof HTMLElement)if(!1!==s)if(void 0!==t){if(t===s||!0===s&&void 0===this.lastFocus)return this.nextFocus=!1,this.setLastFocus(e,t),e.focus(),!0}else{const r=null===(i=this.lastFocus)||void 0===i?void 0:i.target;if(!0===s&&r instanceof HTMLElement&&e.contains(r))return this.nextFocus=!1,r.focus(),!0}else if(!1===s&&t&&t!==(null===(s=this.lastFocus)||void 0===s?void 0:s.name)&&this.isElementPositionBeforeLastFocused(t))return this.setLastFocus(e,t),e.focus(),!0;return!1}renderHtml(e,t){return"string"==typeof e?text.textToHtml(e):text.isMarkdown(e)?text.markdownToHtml(e.markdown,t):""}renderText(e){return"string"==typeof e?e:text.isMarkdown(e)?text.markdownToText(e.markdown):""}renderStyle(e){return"string"==typeof e?addStyleToDocument(e):staticStyle=staticStyle||addStyleToDocument(CSS)}renderVisual(e){return presenter.render(e)||presenter.renderNone(e)}qualifyDefault(e){var t=sort(this.form.elements);for(const n in t){var i=t[n];if(null!=i&&!1!==i.visible&&i.enabled){if(i.default)return e.value=i.value,n;var s=sort(i.items);if(null!=s)for(const o in s){var r=s[o];if(null!=r&&r.visible&&r.enabled&&r.default)return e.item=o,e.value=r.value,n}}}}qualify(e,t){var i;return null==t&&(t={}),"clicked"===e&&void 0===t.name&&(t.name=this.qualifyDefault(t)),t.type=e,void 0===t.routingKey&&(i=t.name,t.routingKey=void 0!==i?e+"$"+i:e),t}post(e,t){t=this.publish(e,t);const i=this.container;void 0!==i&&i.dispatchEvent(createEvent(eventName,t))}subscribe(i){const e=this.container;if(void 0===e)return createSubscription();const s=function(){i=void 0,e.removeEventListener(eventName,t)},t=function(e){const t=e.detail;void 0!==t?Bluebird.resolve().then(function(){"function"==typeof i&&i(t)}):s()};return e.addEventListener(eventName,t),createSubscription(s)}refresh(e){this.custom||("string"==typeof e?(e=this.refs[e],presenter.refresh(e)):(void 0===this.style&&(this.style=this.renderStyle()),this.refs={},presenter.refreshForm(this,this.container)))}invalidate(e){const t=this.nextRefresh;"string"==typeof e&&!0!==t&&(!1===t?this.nextRefresh={[e]:!0}:t[e]=!0),void 0!==e&&!0!==e||(this.nextRefresh=!0),!1===e&&!1===t&&(this.nextRefresh={})}update(){var e=this.nextRefresh;if(!0===e&&(this.nextRefresh=!1,this.refresh()),"object"==typeof e){this.nextRefresh=!1;for(const t in e)!0===e[t]&&this.refresh(t)}}idle(){const e=this.timerHandle;void 0!==e&&(this.timerHandle=void 0,e())}busy(){if(void 0===this.timerHandle&&void 0!==this.container){let e=setTimeout(()=>this.spin());this.timerHandle=function(){void 0!==e&&(clearTimeout(e),e=void 0)}}}publish(e,t){return this.enabled?(t=this.enqueue(e,t),0<this.eventQueue.length&&this.spin(),t):this.qualify(e,t)}enqueue(e,t){return t=this.qualify(e,t),void 0!==this.eventTask?(this.resolveEvent(t),this.eventTask=void 0):this.eventQueue.push(t),t}dequeue(){const e=this.eventQueue;if(0<e.length){var t=this.eventIndex,i=e[t++];return t>=e.length?e.length=this.eventIndex=0:this.eventIndex=t,i}}observe(){const t=this;return Bluebird.attempt(function(){if(void 0!==t.eventTask)return t.eventTask;var e=t.dequeue();return void 0!==e?e:t.show()?(t.eventTask=new Task(e=>{t.resolveEvent=e}),t.eventTask):void 0})}load(e,t){if(void 0===this.container)return!1;if(this.eventQueue.length=this.eventIndex=0,this.eventTask=void 0,this.errors={},this.lastFocus=void 0,this.nextFocus=!0,this.nextRefresh=!0,this.enqueue("load"),this.enqueue("prepare"),null!=e){e=overlay(e,e={defaults:{},elements:{}});this.form=overlay(t,e);for(const i in this.form.elements){let e=this.form.elements[i];if(e=overlay(e,{showFilter:!1,checked:!1,enabled:!0,hoisted:!1,visible:!0,overlay:!1,default:!1,validates:!1,readOnly:!1,require:!1,autoActivate:!1}),e.items)for(const s in e.items)e.items[s]=overlay(e.items[s],{enabled:!0,checked:!1,visible:!0,default:!1,validates:!1});this.form.elements[i]=e}}return!0}route(e){switch(e.type){case"changed":return this.cascade(e.name);case"prepare":return this.hydrate(e);case"suggest":return this.suggest(e);case"clicked":return this.click(e);case"validate":return this.verify(e);case"verify":return this.submit(e);case"checked":return this.changed(e)}return!1}changed(e){return this.enqueue("changed",{name:e.name,item:e.item,value:e.value}),!0}isElementValid(e,t=!0,i={status:void 0}){return null!=e&&(i.status=void 0,text.isStatus(e.error)&&"invalid"===e.error.status?!(i.status="invalid"):!0!==e.require||(this.isElementEffectivelyVisible(e)?!!this.isElementValueDefined(e)||!(i.status="missing"):t))}isElementEffectivelyVisible(e){if(null==e)return!1;var t=this.getParentSection(e);return(!t||!1!==t.visible)&&!1!==e.visible}isElementValueDefined(e){if(null==e)return!1;if("CheckBox"===e.type)return!0;var t=e.current;if(null!=t)return!0;t=e.value;if(null!=t&&""!==t)return!0;t=e.label;if(null!=t&&""!==t)return!0;var i=e.items;if(null!=i)for(const r in i){var s=i[r];if(null!=s&&!0===s.checked)return!0}return!1}trap(e){switch(e.type){case"populate":case"load":break;default:return!1}var t=e.name;const i=this.find(t);if(void 0===i||null===i)return!1;e=i.dependsOn;if("string"!=typeof e)return!1;e=this.find(e);return i.enabled=this.isElementEffectivelyVisible(e)&&this.isElementValueDefined(e),this.invalidate(t),!i.enabled}cascade(e){var t=this.find(e);if(null==t||!1===t.dependsOn)return!1;const i={[e]:!0};var s=sort(this.form.elements);for(const n in s){const o=s[n];var r=o.dependsOn;if("string"==typeof r){const a=this.find(r);void 0!==a&&"string"!=typeof a.dependsOn&&(a.dependsOn=!0),!0===i[r]&&(i[n]=!0,o.checked=!1,o.current=void 0,o.label=void 0,o.items=void 0,o.value=void 0,this.invalidate(n),this.enqueue("populate",{name:n}))}else o.dependsOn=!1}return!0}click(e){var t=this.form.elements[e.name];return null!=t&&"ButtonBar"==t.type&&this.validate(e)}hydrate(e){for(const t in sort(this.form.elements))this.enqueue("populate",{name:t}),this.enqueue("load",{name:t});return!0}shouldTriggerValidation(e){var t=this.find(e.name);if(null!=t&&"string"==typeof e.value){e=e.item;if("string"!=typeof e)return!0===t.validates;t=t.items;if(null!=t){e=t[e];if(null!=e)return!0===e.validates}}}validate(e){var t=this.shouldTriggerValidation(e);if(!0!==t)return!1===t&&(this.enqueue("end",{name:e.name,item:e.item,value:e.value,routingKey:"end"}),!0);{const r=this.errors={};var i=sort(this.form.elements);for(const n in i){var s=i[n];null!=s&&(r[n]=void 0,this.enqueue("validate",{name:n}))}return this.enqueue("verify",{name:e.name,item:e.item,value:e.value,routingKey:"verify"}),!0}}verify(e){var t=e.name,i=this.form.elements[t],e={status:void 0};return!this.isElementValid(i,!0,e)&&(e.status&&(this.errors[t]={status:e.status}),!1===this.nextFocus&&this.focus(t),!0)}suggest(e){const t=this.form.elements[e.name];return void 0!==t&&null!==t&&(t.items={message:{label:{status:"trivial"},enabled:!1}},this.invalidate(e.name),!0)}submit(e){return!this.hasErrors()&&(this.enqueue("submit",{name:e.name,item:e.item,value:e.value}),!0)}hasErrors(){var e=this.errors;for(const i in e){var t=e[i];if(null!=t)return!0}return!1}find(e){if(null!=e)return"string"==typeof(e="object"==typeof e?e.name:e)?this.form.elements[e]:void 0}findName(e){for(const t in this.form.elements)if(this.form.elements[t]===e)return t}coerceNumber(e){var t=this.deriveLocale("globalize");return Globalize(t).parseNumber(e)}formatNumber(e,t,i=!1){if(i)return format(t,e);i=this.deriveLocale("globalize");return Globalize(i).formatNumber(e,t)}renderCustom(e,t){if(e instanceof FormComponent)return renderers.element.renderCustom(e,t)}renderState(e,t,i){return!1}deriveCalendar(e){return Calendar.useNative()}deriveLocale(e){return ensureLocale()}deriveTimeZone(e){return ensureTimeZone()}getParentSection(e){e=e.section;if(e){e="string"==typeof e?e:e.name;return this.form.elements[e]}}isSectionCollapsed(e){return!(!e||"Section"!==e.type||"collapsible-section"!==e.format&&"accordion-section"!==e.format)&&!0===e.collapsed}isElementPositionBeforeLastFocused(e){var t,i=this.lastFocus;if(e&&i&&void 0!==i.rowNumber&&void 0!==i.rowIndex){e=null===(t=this.form.elements)||void 0===t?void 0:t[e];if(e)return void 0!==e.rowNumber&&void 0!==e.rowIndex?e.rowNumber<i.rowNumber||e.rowNumber===i.rowNumber&&e.rowIndex<i.rowIndex:e.index<i.rowNumber||e.index===i.rowNumber&&0<i.rowIndex}return!1}setLastFocus(e,t){this.lastFocus={target:e},t&&(this.lastFocus.name=t,(t=null===(e=this.form.elements)||void 0===e?void 0:e[t])&&(void 0!==t.rowNumber&&void 0!==t.rowIndex?(this.lastFocus.rowNumber=t.rowNumber,this.lastFocus.rowIndex=t.rowIndex):(this.lastFocus.rowNumber=t.index,this.lastFocus.rowIndex=0)))}isSection(e){return"Section"===(null==e?void 0:e.type)}isAccordionSection(e){return this.isSection(e)&&"accordion-section"===e.format}getAllSectionElements(){const e={};for(const i in this.form.elements){var t=this.form.elements[i];this.isSection(t)&&(e[i]=t)}return e}getMutuallyExclusiveSectionElements(t){let i=this.mutuallyExclusiveSections[t];if(!i){var e=this.find(t);if(!this.isAccordionSection(e))return{};i={[t]:e};e=this.getAllSectionElements();const n=Object.keys(sort(e,e=>e.rowNumber));t=n.indexOf(t);for(let e=t-1;0<=e;e--){const o=n[e];var s=this.find(o);if(!this.isAccordionSection(s))break;i[o]=s}for(let e=t+1;e<n.length;e++){const o=n[e];var r=this.find(o);if(!this.isAccordionSection(r))break;i[o]=r}Object.keys(i).forEach(e=>{this.mutuallyExclusiveSections[e]=i})}return i}updateAccordionSections(t){const i=this.getMutuallyExclusiveSectionElements(t);Object.keys(i).forEach(e=>{i[e].collapsed=e!==t}),presenter.refreshForm(this,this.container)}}export{defs,FormHost};
|
|
1
|
+
import moment from"moment-timezone";import{Task}from"../Task.js";import{DEFAULT_LOCALE}from"../constants.js";import Bluebird from"../deps/bluebird_fork.js";import{Calendar}from"./Calendar.js";import{FormComponent}from"./FormComponent.js";import*as defs from"./FormDefinition.js";import NumberParser from"./NumberParser.js";import{format}from"./numberFormatter.js";import*as presenter from"./presenter.js";import*as renderers from"./renderers.js";import{CSS}from"./styles/stock.js";import{addStyleToDocument,sort,text}from"./utils.js";const guid="C0166F74-982A-464E-9FB6-9605CB7649C1:",eventName=guid+"FormEvent";function createEvent(e,t){return new CustomEvent(e,{bubbles:!1,cancelable:!1,detail:t})}function ensureTimeZone(){let e=moment.tz.names[0];return void 0===e&&moment.tz.setDefault(e=moment.tz.guess()),e}function overlay(i,s){switch(typeof i){case"boolean":case"number":case"string":return i;case"object":break;default:return s}if(null===i)return s;if(i instanceof Array){let e=s;void 0!==e&&null!==e||(e=[]);let t=0;for(const n of i){var r=overlay(n,e[t]);void 0!==r&&(t<i.length?e[t]=r:e.push(r),++t)}return e}let e=s;void 0===e&&(e={});for(const t in i)e[t]=overlay(i[t],e[t]);return e}function createSubscription(e){function t(){return void 0!==e&&(t.active=!1,e(),!0)}return t.active=!0,t}let staticStyle=void 0;class FormHost{constructor(){this.form={defaults:{},elements:{}},this.errors={},this.refs={},this.enabled=!1,this.visible=!1,this.dismiss=!1,this.custom=!1,this.container=document.createElement("div"),this.eventIndex=0,this.eventQueue=[],this.mutuallyExclusiveSections={},this.nextFocus=!1,this.nextRefresh=!1,this.style=void 0}deriveLocale(){return DEFAULT_LOCALE}mount(){var e=this.container,t=e.parentNode;null==t&&document.body.appendChild(e),this.update()}unmount(){var e=this.container;const t=e.parentNode;void 0!==t&&null!==t&&t.removeChild(e)}observeFocus(e){this.enabled&&e instanceof HTMLElement&&(this.lastFocus&&this.lastFocus.target===e||this.setLastFocus(e))}focus(e){!0===(e=null==e?!1:e)&&(this.lastFocus=void 0),!1===e&&!1===(e=this.nextFocus)&&(e=!0),this.nextFocus=e,this.invalidate(!0!==e?e:void 0)}show(){const e=this.container;if(void 0===e)return!1;this.custom||void 0!==this.focusObserver||e.addEventListener("focus",this.focusObserver=e=>this.observeFocus(e.target),!0),this.enabled||(this.nextRefresh=!0,this.focus());const t=[];var i,s=this.errors;for(const r in s){const n=this.form.elements[r];void 0!==n&&null!==n&&(n.error=s[r],this.invalidate(r),!1!==n.visible&&(i=this.getParentSection(n),this.isSectionCollapsed(i)&&t.push(i)))}return 0<t.length&&(t.forEach(e=>{var t;this.isAccordionSection(e)?(t=this.findName(e))&&this.updateAccordionSections(t):e.collapsed=!1}),this.invalidate()),this.errors={},this.idle(),!1!==this.nextRefresh&&(this.enabled=!0,this.visible=!0,this.mount()),this.enabled}spin(){return void 0!==this.container&&(this.idle(),this.visible&&!this.enabled||(this.nextRefresh=!0,this.enabled=!1,this.visible=!0,this.mount()),this.visible)}hide(){return void 0!==this.container&&(this.idle(),this.visible&&(this.enabled=!1,this.visible=!1,this.unmount()),!0)}dispose(){if(this.dismiss)return!1;{this.dismiss=!0;const t=this.container;t.dispatchEvent(createEvent(eventName));var e=this.focusObserver;return void 0!==e&&t.removeEventListener("focus",e,!0),this.idle(),this.unmount(),this.refs={},presenter.releaseForm(this.container),this.container=void 0,this.lastFocus=void 0,!(this.eventTask=void 0)}}renderFocus(e,t){var i=this.nextFocus;if(this.enabled&&e instanceof HTMLElement)if(!1!==i)if(void 0!==t){if(t===i||!0===i&&void 0===this.lastFocus)return this.nextFocus=!1,this.setLastFocus(e,t),e.focus(),!0}else{const s=this.lastFocus?.target;if(!0===i&&s instanceof HTMLElement&&e.contains(s))return this.nextFocus=!1,s.focus(),!0}else if(!1===i&&t&&t!==this.lastFocus?.name&&this.isElementPositionBeforeLastFocused(t))return this.setLastFocus(e,t),e.focus(),!0;return!1}renderHtml(e,t){return"string"==typeof e?text.textToHtml(e):text.isMarkdown(e)?text.markdownToHtml(e.markdown,t):""}renderText(e){return"string"==typeof e?e:text.isMarkdown(e)?text.markdownToText(e.markdown):""}renderStyle(e){return"string"==typeof e?addStyleToDocument(e):staticStyle=staticStyle||addStyleToDocument(CSS)}renderVisual(e){return presenter.render(e)||presenter.renderNone(e)}qualifyDefault(e){var t=sort(this.form.elements);for(const n in t){var i=t[n];if(null!=i&&!1!==i.visible&&i.enabled){if(i.default)return e.value=i.value,n;var s=sort(i.items);if(null!=s)for(const o in s){var r=s[o];if(null!=r&&r.visible&&r.enabled&&r.default)return e.item=o,e.value=r.value,n}}}}qualify(e,t){var i;return null==t&&(t={}),"clicked"===e&&void 0===t.name&&(t.name=this.qualifyDefault(t)),t.type=e,void 0===t.routingKey&&(i=t.name,t.routingKey=void 0!==i?e+"$"+i:e),t}post(e,t){t=this.publish(e,t);const i=this.container;void 0!==i&&i.dispatchEvent(createEvent(eventName,t))}subscribe(i){const e=this.container;if(void 0===e)return createSubscription();const s=function(){i=void 0,e.removeEventListener(eventName,t)},t=function(e){const t=e.detail;void 0!==t?Bluebird.resolve().then(function(){"function"==typeof i&&i(t)}):s()};return e.addEventListener(eventName,t),createSubscription(s)}refresh(e){this.custom||("string"==typeof e?(e=this.refs[e],presenter.refresh(e)):(void 0===this.style&&(this.style=this.renderStyle()),this.refs={},presenter.refreshForm(this,this.container)))}invalidate(e){const t=this.nextRefresh;"string"==typeof e&&!0!==t&&(!1===t?this.nextRefresh={[e]:!0}:t[e]=!0),void 0!==e&&!0!==e||(this.nextRefresh=!0),!1===e&&!1===t&&(this.nextRefresh={})}update(){var e=this.nextRefresh;if(!0===e&&(this.nextRefresh=!1,this.refresh()),"object"==typeof e){this.nextRefresh=!1;for(const t in e)!0===e[t]&&this.refresh(t)}}idle(){const e=this.timerHandle;void 0!==e&&(this.timerHandle=void 0,e())}busy(){if(void 0===this.timerHandle&&void 0!==this.container){let e=setTimeout(()=>this.spin());this.timerHandle=function(){void 0!==e&&(clearTimeout(e),e=void 0)}}}publish(e,t){return this.enabled?(t=this.enqueue(e,t),0<this.eventQueue.length&&this.spin(),t):this.qualify(e,t)}enqueue(e,t){return t=this.qualify(e,t),void 0!==this.eventTask?(this.resolveEvent(t),this.eventTask=void 0):this.eventQueue.push(t),t}dequeue(){const e=this.eventQueue;if(0<e.length){var t=this.eventIndex,i=e[t++];return t>=e.length?e.length=this.eventIndex=0:this.eventIndex=t,i}}observe(){const t=this;return Bluebird.attempt(function(){if(void 0!==t.eventTask)return t.eventTask;var e=t.dequeue();return void 0!==e?e:t.show()?(t.eventTask=new Task(e=>{t.resolveEvent=e}),t.eventTask):void 0})}load(e,t){if(void 0===this.container)return!1;if(this.eventQueue.length=this.eventIndex=0,this.eventTask=void 0,this.errors={},this.lastFocus=void 0,this.nextFocus=!0,this.nextRefresh=!0,this.enqueue("load"),this.enqueue("prepare"),null!=e){e=overlay(e,e={defaults:{},elements:{}});this.form=overlay(t,e);for(const i in this.form.elements){let e=this.form.elements[i];if(e=overlay(e,{showFilter:!1,checked:!1,enabled:!0,hoisted:!1,visible:!0,overlay:!1,default:!1,validates:!1,readOnly:!1,require:!1,autoActivate:!1}),e.items)for(const s in e.items)e.items[s]=overlay(e.items[s],{enabled:!0,checked:!1,visible:!0,default:!1,validates:!1});this.form.elements[i]=e}}return!0}route(e){switch(e.type){case"changed":return this.cascade(e.name);case"prepare":return this.hydrate(e);case"suggest":return this.suggest(e);case"clicked":return this.click(e);case"validate":return this.verify(e);case"verify":return this.submit(e);case"checked":return this.changed(e)}return!1}changed(e){return this.enqueue("changed",{name:e.name,item:e.item,value:e.value}),!0}isElementValid(e,t=!0,i={status:void 0}){return null!=e&&(i.status=void 0,text.isStatus(e.error)&&"invalid"===e.error.status?!(i.status="invalid"):!0!==e.require||(this.isElementEffectivelyVisible(e)?!!this.isElementValueDefined(e)||!(i.status="missing"):t))}isElementEffectivelyVisible(e){return null!=e&&(!1!==this.getParentSection(e)?.visible&&!1!==e.visible)}isElementValueDefined(e){if(null==e)return!1;if("CheckBox"===e.type)return!0;var t=e.current;if(null!=t)return!0;t=e.value;if(null!=t&&""!==t)return!0;t=e.label;if(null!=t&&""!==t)return!0;var i=e.items;if(null!=i)for(const r in i){var s=i[r];if(null!=s&&!0===s.checked)return!0}return!1}trap(e){switch(e.type){case"populate":case"load":break;default:return!1}var t=e.name;const i=this.find(t);if(void 0===i||null===i)return!1;e=i.dependsOn;if("string"!=typeof e)return!1;e=this.find(e);return i.enabled=this.isElementEffectivelyVisible(e)&&this.isElementValueDefined(e),this.invalidate(t),!i.enabled}cascade(e){var t=this.find(e);if(null==t||!1===t.dependsOn)return!1;const i={[e]:!0};var s=sort(this.form.elements);for(const n in s){const o=s[n];var r=o.dependsOn;if("string"==typeof r){const a=this.find(r);void 0!==a&&"string"!=typeof a.dependsOn&&(a.dependsOn=!0),!0===i[r]&&(i[n]=!0,o.checked=!1,o.current=void 0,o.label=void 0,o.items=void 0,o.value=void 0,this.invalidate(n),this.enqueue("populate",{name:n}))}else o.dependsOn=!1}return!0}click(e){var t=this.form.elements[e.name];return null!=t&&"ButtonBar"==t.type&&this.validate(e)}hydrate(e){for(const t in sort(this.form.elements))this.enqueue("populate",{name:t}),this.enqueue("load",{name:t});return!0}shouldTriggerValidation(e){var t=this.find(e.name);if(null!=t&&"string"==typeof e.value){e=e.item;if("string"!=typeof e)return!0===t.validates;t=t.items;if(null!=t){e=t[e];if(null!=e)return!0===e.validates}}}validate(e){var t=this.shouldTriggerValidation(e);if(!0!==t)return!1===t&&(this.enqueue("end",{name:e.name,item:e.item,value:e.value,routingKey:"end"}),!0);{const r=this.errors={};var i=sort(this.form.elements);for(const n in i){var s=i[n];null!=s&&(r[n]=void 0,this.enqueue("validate",{name:n}))}return this.enqueue("verify",{name:e.name,item:e.item,value:e.value,routingKey:"verify"}),!0}}verify(e){var t=e.name,i=this.form.elements[t],e={status:void 0};return!this.isElementValid(i,!0,e)&&(e.status&&(this.errors[t]={status:e.status}),!1===this.nextFocus&&this.focus(t),!0)}suggest(e){const t=this.form.elements[e.name];return void 0!==t&&null!==t&&(t.items={message:{label:{status:"trivial"},enabled:!1}},this.invalidate(e.name),!0)}submit(e){return!this.hasErrors()&&(this.enqueue("submit",{name:e.name,item:e.item,value:e.value}),!0)}hasErrors(){var e=this.errors;for(const i in e){var t=e[i];if(null!=t)return!0}return!1}find(e){if(null!=e)return"string"==typeof(e="object"==typeof e?e.name:e)?this.form.elements[e]:void 0}findName(e){for(const t in this.form.elements)if(this.form.elements[t]===e)return t}coerceNumber(e){var t=this.deriveLocale();return new NumberParser(t).parse(e)}formatNumber(e,t){return t?.locale||((t=t||{}).locale=this.deriveLocale()),format(t,e)}renderCustom(e,t){if(e instanceof FormComponent)return renderers.element.renderCustom(e,t)}renderState(e,t,i){return!1}deriveCalendar(e){return Calendar.useNative()}deriveTimeZone(){return ensureTimeZone()}getParentSection(e){e=e.section;if(e){e="string"==typeof e?e:e.name;return this.form.elements[e]}}isSectionCollapsed(e){return!(!e||"Section"!==e.type||"collapsible-section"!==e.format&&"accordion-section"!==e.format)&&!0===e.collapsed}isElementPositionBeforeLastFocused(e){var t=this.lastFocus;if(e&&void 0!==t?.rowNumber&&void 0!==t.rowIndex){e=this.form.elements?.[e];if(e)return void 0!==e.rowNumber&&void 0!==e.rowIndex?e.rowNumber<t.rowNumber||e.rowNumber===t.rowNumber&&e.rowIndex<t.rowIndex:e.index<t.rowNumber||e.index===t.rowNumber&&0<t.rowIndex}return!1}setLastFocus(e,t){this.lastFocus={target:e},t&&(this.lastFocus.name=t,(t=this.form.elements?.[t])&&(void 0!==t.rowNumber&&void 0!==t.rowIndex?(this.lastFocus.rowNumber=t.rowNumber,this.lastFocus.rowIndex=t.rowIndex):(this.lastFocus.rowNumber=t.index,this.lastFocus.rowIndex=0)))}isSection(e){return"Section"===e?.type}isAccordionSection(e){return this.isSection(e)&&"accordion-section"===e.format}getAllSectionElements(){const e={};for(const i in this.form.elements){var t=this.form.elements[i];this.isSection(t)&&(e[i]=t)}return e}getMutuallyExclusiveSectionElements(t){let i=this.mutuallyExclusiveSections[t];if(!i){var e=this.find(t);if(!this.isAccordionSection(e))return{};i={[t]:e};e=this.getAllSectionElements();const n=Object.keys(sort(e,e=>e.rowNumber));t=n.indexOf(t);for(let e=t-1;0<=e;e--){const o=n[e];var s=this.find(o);if(!this.isAccordionSection(s))break;i[o]=s}for(let e=t+1;e<n.length;e++){const o=n[e];var r=this.find(o);if(!this.isAccordionSection(r))break;i[o]=r}Object.keys(i).forEach(e=>{this.mutuallyExclusiveSections[e]=i})}return i}updateAccordionSections(t){const i=this.getMutuallyExclusiveSectionElements(t);Object.keys(i).forEach(e=>{i[e].collapsed=e!==t}),presenter.refreshForm(this,this.container)}}export{defs,FormHost};
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { Calendar } from "./Calendar";
|
|
2
2
|
import * as defs from "./FormDefinition";
|
|
3
3
|
import { FormatOptions } from "./numberFormatter";
|
|
4
|
-
/** Concrete types of facilities which deviate in terms of functionality. */
|
|
5
|
-
export declare type Facility = "browser" | "globalize" | "moment";
|
|
6
4
|
/** Exposes various features to components that require features of the environment. */
|
|
7
5
|
export interface FormPresenterHost {
|
|
8
6
|
/** Indicates if the form is enabled or not. */
|
|
@@ -37,17 +35,16 @@ export interface FormPresenterHost {
|
|
|
37
35
|
}): defs.Element;
|
|
38
36
|
/** Coerces a number from a value. */
|
|
39
37
|
coerceNumber(value: string): number;
|
|
40
|
-
/** Formats a value into a string.
|
|
41
|
-
formatNumber(value: number, options:
|
|
38
|
+
/** Formats a value into a string. */
|
|
39
|
+
formatNumber(value: number, options: FormatOptions): string;
|
|
42
40
|
/** Formats a value into a string. */
|
|
43
41
|
deriveCalendar(format: defs.DateTimeFormat): Calendar;
|
|
44
42
|
/**
|
|
45
|
-
* Derives the current locale
|
|
46
|
-
* then the workflow locale set by the host application (or default if undefined) will be returned.
|
|
43
|
+
* Derives the current locale set by the host application (or default if undefined) will be returned.
|
|
47
44
|
*/
|
|
48
|
-
deriveLocale(
|
|
45
|
+
deriveLocale(): string;
|
|
49
46
|
/** Derives the current time zone. */
|
|
50
|
-
deriveTimeZone(
|
|
47
|
+
deriveTimeZone(): string;
|
|
51
48
|
/**
|
|
52
49
|
* Collapses all neighbouring accordion sections except the one specified.
|
|
53
50
|
* @param expandedAccordionSection The name of the accordion section to be expanded. All others in the group will be collapsed.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parses a number based on the specified locale.
|
|
3
|
+
*
|
|
4
|
+
* WARNING: This technique assumes a positional number system, which isn't always the case for every locale (e.g. Hebrew, Korean).
|
|
5
|
+
* It seems though that at the moment, in all major browsers, `Intl.NumberFormat` will format these non-positional number systems
|
|
6
|
+
* using Western Arabic numerals ("123..."), so this works for now. But if any browser ever implements proper
|
|
7
|
+
* number system support for these locales, then this algorithm will no longer parse those locales properly.
|
|
8
|
+
*/
|
|
9
|
+
export default class NumberParser {
|
|
10
|
+
private _group;
|
|
11
|
+
private _decimal;
|
|
12
|
+
private _numeral;
|
|
13
|
+
private _index;
|
|
14
|
+
/**
|
|
15
|
+
* Creates a new instance of the {@link NumberParser} class.
|
|
16
|
+
* @param locale The locale to use for parsing the text.
|
|
17
|
+
*/
|
|
18
|
+
constructor(locale: string);
|
|
19
|
+
/**
|
|
20
|
+
* Parses a localized string representation of a number and returns the numeric value.
|
|
21
|
+
* @param str A localized string representation of a number.
|
|
22
|
+
* @returns The numeric value of the string.
|
|
23
|
+
*/
|
|
24
|
+
parse(str: string): number;
|
|
25
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default class NumberParser{constructor(e){const r=new Intl.NumberFormat(e).formatToParts(12345.6),t=Array.from(new Intl.NumberFormat(e,{useGrouping:!1}).format(9876543210)).reverse(),a=new Map(t.map((e,r)=>[e,r.toString()]));this._group=new RegExp(`[${r.find(e=>"group"===e.type).value}]`,"g"),this._decimal=new RegExp(`[${r.find(e=>"decimal"===e.type).value}]`),this._numeral=new RegExp(`[${t.join("")}]`,"g"),this._index=e=>a.get(e)}parse(e){e=e.trim().replace(this._group,"").replace(this._decimal,".").replace(this._numeral,this._index);return e?+e:NaN}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";function renderArrowHead(){return _jsx("svg",{className:"arrowHead",viewBox:"0 0 200 200",preserveAspectRatio:"none",children:_jsx("path",{d:"M 0 0 V 200 L 200 100 Z"},void 0)},void 0)}function renderArrowRight(){return _jsx("svg",{className:"arrowRight",viewBox:"0 0 24 24",preserveAspectRatio:"none",children:_jsx("path",{d:"M20 12l-8-8-1.4 1.4 5.6 5.6H4v2h12.2l-5.6 5.6L12 20l8-8z"},void 0)},void 0)}function renderArrowRollup(){return _jsxs("svg",{className:"arrowRollup",viewBox:"0 0 200 200",preserveAspectRatio:"none",children:[_jsx("circle",{cx:"100",cy:"100",r:"100"},void 0),_jsx("polyline",{points:"50 100 100 50 150 100"},void 0),_jsx("polyline",{points:"50 150 100 100 150 150"},void 0)]},void 0)}export{renderArrowHead,renderArrowRight,renderArrowRollup};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";function renderChevronUp(){return _jsx("svg",{className:"chevronUp",viewBox:"0 0 24 24",children:_jsx("g",{children:_jsx("path",{d:"M20 15.3l-8-8-8 8 1.4 1.4 6.6-6.6 6.6 6.6 1.4-1.4z"},void 0)},void 0)},void 0)}function renderChevronDown(){return _jsx("svg",{className:"chevronDown",viewBox:"0 0 24 24",children:_jsx("g",{children:_jsx("path",{d:"M18.6 7.3L12 13.9 5.4 7.3 4 8.7l8 8 8-8-1.4-1.4z"},void 0)},void 0)},void 0)}export{renderChevronUp,renderChevronDown};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";function renderCrossAdd(){return _jsxs("svg",{className:"crossAdd",viewBox:"0 0 200 200",preserveAspectRatio:"none",children:[_jsx("polyline",{points:"0 100 200 100"},void 0),_jsx("polyline",{points:"100 0 100 200"},void 0)]},void 0)}function renderCrossDelete(){return _jsxs("svg",{className:"crossDelete",viewBox:"0 0 200 200",preserveAspectRatio:"none",children:[_jsx("circle",{cx:"100",cy:"100",r:"100"},void 0),_jsx("polyline",{points:"50 50 150 150"},void 0),_jsx("polyline",{points:"50 150 150 50"},void 0)]},void 0)}export{renderCrossAdd,renderCrossDelete};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";function renderCalendar(){return _jsxs("svg",{className:"calendar",viewBox:"0 0 24 24",children:[_jsx("path",{d:"M23 6v16c0 .6-.4 1-1 1H2c-.6 0-1-.4-1-1V6m21-6H2C.9 0 0 .9 0 2v20c0 1.1.9 2 2 2h20c1.1 0 2-.9 2-2V2c0-1.1-.9-2-2-2z"},void 0),_jsx("path",{d:"M13 13h3v3h-3v-3zm-2-2H8V8h3v3zm5-3h-3v3h3V8zm5 0h-3v3h3V8zM6 13H3v3h3v-3zm5 0H8v3h3v-3zm10 0h-3v3h3v-3zM6 18H3v3h3v-3zm5 0H8v3h3v-3zm5 0h-3v3h3v-3z"},void 0)]},void 0)}function renderClock(){return _jsx("svg",{className:"clock",viewBox:"0 0 24 24",children:_jsx("path",{d:"M12.9748 11.6775C13.8937 12.9336 16 16 16 16s-4.4547-3.0477-4.7742-3.3673c-.1703-.1703-.2432-.4286-.2222-.6921C11.043 11.1284 12 4 12 4s.8257 6.1508.9748 7.6775zM12 2c5.514 0 10 4.486 10 10s-4.486 10-10 10S2 17.514 2 12 6.486 2 12 2m0-2C5.3726 0 0 5.3726 0 12s5.3726 12 12 12 12-5.3726 12-12S18.6274 0 12 0z"},void 0)},void 0)}export{renderCalendar,renderClock};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";function renderRemove(){return _jsx("svg",{className:"remove",viewBox:"0 0 24 24",children:_jsx("path",{d:"M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z"},void 0)},void 0)}export{renderRemove};
|
package/esm/forms/assets/scan.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";function renderScanBarcode(){return _jsx("svg",{className:"barcode",viewBox:"0 0 24 24",children:_jsx("path",{d:"M1 8V4.6666C1 2.65 2.65 1 4.6667 1H8v2H4.6667C3.7477 3 3 3.7477 3 4.6666V8H1zm15-5h3.3333C20.2523 3 21 3.7477 21 4.6666V8h2V4.6666C23 2.65 21.35 1 19.3333 1H16v2zM8 21H4.6667C3.7477 21 3 20.2523 3 19.3333V16H1v3.3333C1 21.35 2.65 23 4.6667 23H8v-2zm13-5v3.3333C21 20.2523 20.2523 21 19.3333 21H16v2h3.3333C21.35 23 23 21.35 23 19.3333V16h-2zM6 5H5v14h1V5zm3 0H7v14h2V5zm5 0h-2v14h2V5zm-3 0h-1v14h1V5zm5 0h-1v14h1V5zm3 0h-2v14h2V5z"},void 0)},void 0)}function renderScanQrcode(){return _jsx("svg",{className:"qrCode",viewBox:"0 0 24 24",children:_jsx("path",{d:"M9 6v3H6V6h3m1-1H5v5h5V5zM8 7H7v1h1V7zm1 8v3H6v-3h3m1-1H5v5h5v-5zm-2 2H7v1h1v-1zM18 6v3h-3V6h3m1-1h-5v5h5V5zm-2 2h-1v1h1V7zm-5 1h1V7h-1v1zm0 1h-1v1h1V9zm2 5h-3v1h3v-1zm0 2h1v-1h-1v1zm-2 0h-1v1h1v-1zm0 2h1v-1h-1v1zm4-1h1v-1h-1v1zm-1 1v-1h-1v2h2v-1h-1zm2-4h-1v1h1v-1zm1 2h1v-2h-1v2zm0 3h1v-1h-1v1zm-6-1h-1v1h1v-1zm0-13h-1v2h1V5zm-6 6H5v1h1v-1zm12 0v1h-1v1h2v-2h-1zm-2 0h-1v1h1v-1zm-1 3h1v-1h-1v1zm-1-3h-2v2h1v-1h1v-1zm-4 1h1v-1h-1v1zm-2 0v-1H7v2h3v-1H8zM3 8V4.6666C3 3.7477 3.7477 3 4.6667 3H8V1H4.6667C2.65 1 1 2.65 1 4.6666V8h2zm13-5h3.3333C20.2523 3 21 3.7477 21 4.6666V8h2V4.6666C23 2.65 21.35 1 19.3333 1H16v2zM8 21H4.6667C3.7477 21 3 20.2523 3 19.3333V16H1v3.3333C1 21.35 2.65 23 4.6667 23H8v-2zm13-5v3.3333C21 20.2523 20.2523 21 19.3333 21H16v2h3.3333C21.35 23 23 21.35 23 19.3333V16h-2z"},void 0)},void 0)}function renderScanMulti(){return _jsx("svg",{className:"barcodeOrQrCode",viewBox:"0 0 24 24",children:_jsx("path",{d:"M16 7h1v1h-1V7zM6 19V5H5v14h1zm1 0h2V5H7v14zm3 0h1V5h-1v14zm11 .3333C21 20.2523 20.2523 21 19.3333 21H16v2h3.3333C21.35 23 23 21.35 23 19.3333V16h-2v3.3333zM16 11h-1v1h1v-1zM3 4.6666C3 3.7477 3.7477 3 4.6667 3H8V1H4.6667C2.65 1 1 2.65 1 4.6666V8h2V4.6666zM14 11h-1v1h1v-1zm0 3h-1v1h1v-1zm1 2v-1h-1v1h1zm4.3333-15H16v2h3.3333C20.2523 3 21 3.7477 21 4.6666V8h2V4.6666C23 2.65 21.35 1 19.3333 1zM14 18h1v1h1v-2h-2v1zM3 19.3333V16H1v3.3333C1 21.35 2.65 23 4.6667 23H8v-2H4.6667C3.7477 21 3 20.2523 3 19.3333zM19 14h-1v2h1v-2zm-5-9v5h5V5h-5zm4 4h-3V6h3v3zm0 10h1v-1h-1v1zm-3-6v1h1v-1h-1zm2 1h-1v1h1v-1zm-1 3h1v-1h-1v1zm3-6h-1v1h-1v1h2v-2zm-5 7h-1v1h1v-1z"},void 0)},void 0)}export{renderScanBarcode,renderScanQrcode,renderScanMulti};
|
package/esm/forms/common.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import{useCallback}from"react";const DESCRIPTION_SUFFIX="-description",TITLE_SUFFIX="-title";function textToHtml(e,t){return{__html:t.renderHtml(e)}}function getTitleId(e){return`${e}${TITLE_SUFFIX}`}function getDescriptionId(e){return`${e}${DESCRIPTION_SUFFIX}`}function renderTitle(e,t,r,n){t=textToHtml(e.title,t);return 0<t?.__html?.length?(n=n||"form-element-title",_jsx("span",{className:n,dangerouslySetInnerHTML:t,id:getTitleId(r)},void 0)):null}function renderDescription(e,t,r,n){t=textToHtml(e.description,t);return 0<t?.__html?.length?_jsx("aside",{className:n,dangerouslySetInnerHTML:t,id:getDescriptionId(r)},void 0):null}function renderError(e,t){t=textToHtml(e.error,t);return 0<t?.__html?.length?_jsx("div",{className:"notice",dangerouslySetInnerHTML:t,role:"alert"},void 0):null}function renderFocus(e,t,r){null===e||e.disabled||r.renderFocus(e,t)}function useFocusCallback(e){const{host:t,name:r}=e.props;return useCallback(e=>{null===(e=Array.isArray(e?.thumbRefs)&&0<e.thumbRefs.length?e.thumbRefs[0].current:e)||e.disabled||t.renderFocus(e,r)},[e.enabled,r,t])}export{getTitleId,getDescriptionId,renderTitle,renderDescription,renderError,renderFocus,useFocusCallback};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{parse}from"date-fns";import
|
|
1
|
+
import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{parse}from"date-fns";import{useEffect,useState,lazy,Suspense}from"react";import{DEFAULT_LOCALE}from"../../constants.js";import{renderCalendar}from"../assets/datetime.js";import{useFocusCallback}from"../common.js";import{CssClasses}from"../constants.js";import{getDateAsLocaleFormattedString,getDateFnsLocale,getLocaleDateFormat,isValidDate,tryParseDateText}from"../dateUtilities.js";import{CSS}from"../styles/daterange.js";import{addStyleToDocument}from"../utils.js";const Calendar=lazy(()=>import("./ReactDateRangeCalendar"));addStyleToDocument(CSS);const dateFormat=getLocaleDateFormat();let currentLocale;const DatePicker=e=>{const{component:t,element:a,isOpen:o,onChange:s,onPopupToggle:r}=e,n=t.props["host"],[i,l]=useState(),[d,c]=useState();var m=n.renderText(a.tooltip),u=!t.enabled,p=u?"inner disabled":"inner";useEffect(()=>{(async()=>{var e=n.deriveLocale();"inv"!==e&&"en"!==e&&e!==DEFAULT_LOCALE&&(currentLocale=await getDateFnsLocale(e))})()},[]),useEffect(()=>{l(e.value),c(getDateAsLocaleFormattedString(e.value))},[e.value]);var v=useFocusCallback(t);const f=e=>{var t="string"==typeof e?e:e.target.value,a=""!==t&&void 0!==t,e=a?tryParseDateText(t):void 0,t=a?e?parse(e,dateFormat,0):new Date(NaN):void 0;a?isValidDate(t)?(l(t),c(e),g(),D(t)):(g({status:"invalid"}),l(new Date(NaN)),D(void 0)):(g(),l(void 0),D(void 0))};const D=e=>{"function"==typeof s&&s(e)};const g=e=>{a.error=e,t.forceUpdate()};return _jsxs("div",{className:"SimpleDatePicker outer",title:m,children:[_jsx("div",{className:p,children:_jsx("input",{"aria-label":"Date Picker",ref:v,disabled:u,type:"text",onChange:e=>(e=>{c(e.target.value)})(e),onBlur:e=>f(e),onKeyDown:e=>(e=>{e.stopPropagation(),"Enter"===e.key?f(d):"Escape"===e.key&&f(getDateAsLocaleFormattedString(i))})(e),placeholder:dateFormat.toUpperCase(),value:d},void 0)},void 0),_jsxs("div",{className:"buttonContainer",children:[_jsx("button",{className:"calendarButton",disabled:u,onClick:()=>{"function"==typeof r&&r(!o)},children:renderCalendar()},void 0),o&&_jsx(Suspense,{fallback:null,children:_jsxs("div",{className:CssClasses.DROPDOWN,children:[_jsx(Calendar,{format:dateFormat,editableDateInputs:!1,date:i,onChange:e=>{l(e),c(getDateAsLocaleFormattedString(e)),g(),D(e)},locale:currentLocale},void 0),_jsx("button",{className:"done",onClick:()=>{"function"==typeof r&&r(!1)},children:n.renderText("@common-done")},void 0)]},void 0)},void 0)]},void 0)]},void 0)};export default DatePicker;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{parse,isAfter,isBefore,isEqual}from"date-fns";import
|
|
1
|
+
import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{parse,isAfter,isBefore,isEqual}from"date-fns";import{useEffect,useRef,useState,lazy,Suspense}from"react";import{DEFAULT_LOCALE}from"../../constants.js";import FormElementOuter from"../FormElementOuter.js";import{renderArrowRight}from"../assets/arrow.js";import{renderCalendar}from"../assets/datetime.js";import{useFocusCallback}from"../common.js";import{CssClasses}from"../constants.js";import{convertToDateRangeRef,getDateAsLocaleFormattedString,getDateFnsLocale,getLocaleDateFormat,isValidDate,tryParseDateText}from"../dateUtilities.js";import{CSS}from"../styles/daterange.js";import{addStyleToDocument,makeSafeClassName}from"../utils.js";const DateRange=lazy(()=>import("./DateRange"));var DateInputType;addStyleToDocument(CSS),function(e){e.Start="start",e.End="end"}(DateInputType=DateInputType||{});const dateFormat=getLocaleDateFormat();let currentLocale;const DateRangePicker=e=>{const t=e.component,r=e.element,s=useRef(),[a,o]=useState(!1),[i,l]=useState(),[n,d]=useState(),[c,u]=useState(),[m,p]=useState();var D=!t.enabled;const{host:v,name:g}=t.props;var f=v.renderText(r.tooltip),y=t.enabled?"inner":"inner disabled";const S=[r.type,makeSafeClassName(g)];useEffect(()=>{(async()=>{var e=v.deriveLocale();"inv"!==e&&"en"!==e&&e!==DEFAULT_LOCALE&&(currentLocale=await getDateFnsLocale(e))})()},[]),useEffect(()=>{var e;r.value!==s.current&&((e=convertToDateRangeRef(r.value))?(l(e.startDate),u(e.endDate),d(getDateAsLocaleFormattedString(e.startDate)),p(getDateAsLocaleFormattedString(e.endDate))):void 0===r.value&&(l(void 0),u(void 0),d(""),p("")),r.error&&L(),E(e?.startDate,e?.endDate,!1))},[r.value]);var j=useFocusCallback(t);const x=(e,t)=>{var a,r="string"==typeof e?e:e.target.value,s=""!==r&&void 0!==r,o=s?tryParseDateText(r):void 0,n=s?o?parse(o,dateFormat,0):new Date(NaN):void 0,e=t===DateInputType.Start,r=e?n:i,t=e?c:n;s?isValidDate(n)?e?(l(r),d(o),(a=!isValidDate(t)||isAfter(r,t))&&(u(r),p(o)),L(),a=a?r:t,C(r,a)):(u(t),p(o),(a=!isValidDate(r)||isBefore(t,r))&&(l(t),d(o)),L(),a=a?t:r,C(a,t)):(L({status:"invalid"}),C(),(e?l:u)(new Date(NaN))):((e?void 0===t||isValidDate(t):void 0===r||isValidDate(r))&&L(),C(),(e?l:u)(void 0))};const F=(e,t)=>{(t===DateInputType.Start?d:p)(e.target.value)},T=(e,t)=>{var a;e.stopPropagation(),"Enter"===e.key?(a=t===DateInputType.Start?n:m,x(a,t)):"Escape"===e.key&&(e=t===DateInputType.Start?getDateAsLocaleFormattedString(i):getDateAsLocaleFormattedString(c),x(e,t))},C=(e,t)=>{h(e,t)&&E(e,t)},h=(e,t)=>{var a=s.current;return!(e||t||!a)||(!(!e||!t||a)||!!(e&&t&&a)&&(!isEqual(e,a.startDate)||!isEqual(t,a.endDate)))},L=e=>{r.error=e,t.forceUpdate()},E=(e,t,a=!0)=>{t=e&&t?{refValueType:"daterange",startDate:e,endDate:t}:void 0;s.current=r.value=t,a&&v.post("changed",{name:g,value:r.value})};e={startDate:s.current?.startDate||new Date,endDate:s.current?.endDate||new Date,key:"selection",showDateDisplay:!1};return _jsx(FormElementOuter,{className:S.join(" "),component:t,element:r,children:_jsxs("div",{className:"outer",title:f,children:[_jsxs("div",{className:y,children:[_jsx("input",{ref:j,disabled:D,type:"text",onChange:e=>F(e,DateInputType.Start),onBlur:e=>x(e,DateInputType.Start),onKeyDown:e=>T(e,DateInputType.Start),placeholder:dateFormat.toUpperCase(),value:n},void 0),_jsx("span",{className:"arrow",children:renderArrowRight()},void 0),_jsx("input",{disabled:D,type:"text",onChange:e=>F(e,DateInputType.End),onBlur:e=>x(e,DateInputType.End),onKeyDown:e=>T(e,DateInputType.End),placeholder:dateFormat.toUpperCase(),value:m},void 0)]},void 0),_jsxs("div",{className:"buttonContainer",children:[_jsx("button",{className:"calendarButton",disabled:D,onClick:()=>{o(!a)},children:renderCalendar()},void 0),a&&_jsx(Suspense,{fallback:null,children:_jsxs("div",{className:CssClasses.DROPDOWN,children:[_jsx(DateRange,{dateDisplayFormat:dateFormat,editableDateInputs:!1,months:1,direction:"horizontal",ranges:[e],onChange:e=>{var t=e.selection.startDate,e=e.selection.endDate;l(t),d(getDateAsLocaleFormattedString(t)),u(e),p(getDateAsLocaleFormattedString(e)),L(),C(t,e)},locale:currentLocale},void 0),_jsx("button",{className:"done",onClick:()=>{o(!1)},children:v.renderText("@common-done")},void 0)]},void 0)},void 0)]},void 0)]},void 0)},void 0)};export default DateRangePicker;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{useState}from"react";import{Calendar}from"../Calendar.js";import FormElementOuter from"../FormElementOuter.js";import{renderClock}from"../assets/datetime.js";import{useFocusCallback}from"../common.js";import{makeSafeClassName}from"../utils.js";import DatePicker from"./DatePicker.js";import TimePickerInput from"./TimePickerInput.js";export default e=>{const[t,o]=useState(!1),[a,i]=useState(!1),{component:r,element:n}=e,{host:s,name:l}=r.props;var c=useFocusCallback(r);const u=[n.type,makeSafeClassName(l)];var d=s.renderText(n.tooltip);const m=((e,t)=>{if("object"==typeof e&&null!==e)switch(e.refValueType){case"date":case"time":case"datetime":t=e.format}if("object"!=typeof t)return"app"===t?t:"device";if(null===t)return"device";var o=t.locale,a=t.timezone;return"string"==typeof o&&"string"==typeof a?{locale:o,timezone:a}:"device"})(n.value,n.format),p=s.deriveCalendar(m),f=((e,t)=>{if("object"==typeof e){if(null===e)return;switch(e.refValueType){case"date":case"time":case"datetime":break;default:return}e=e.value}if("number"==typeof e||"string"==typeof e){const o=t.coerceIntoValue(e);if(void 0!==o&&null!==o&&isFinite(o.valueOf()))return o}})(n.value,p);let v="datetime",g=(e=>{if("object"==typeof e&&null!==e)switch(e.refValueType){case"date":case"time":case"datetime":return e.refValueType}})(n.value);"DatePicker"===n.type&&(v="date"),"TimePicker"===n.type&&(v="time");let j=f;"datetime"===v&&"date"===g?j=void 0:g=v;e={calendar:p,disabled:!r.enabled,doneText:s.renderText("@common-done"),placeholder:s.renderText(n.prompt),title:d};function k(e,t){return void 0===(e=null!=e&&!isFinite(e.valueOf())?void 0:e)?void 0!==f:void 0===f||(g!==t||("date"===t&&((e=new Date(e)).setHours(f.getHours()),e.setMinutes(f.getMinutes()),e.setSeconds(f.getSeconds()),e.setMilliseconds(f.getMilliseconds())),"time"===t&&((e=new Date(e)).setFullYear(f.getFullYear()),e.setMonth(f.getMonth()),e.setDate(f.getDate())),f.valueOf()!==e.valueOf()))}d=()=>{var e=!a;i(e),e&&o(!1)};const y=[];function h(e,t){void 0!==e&&isFinite(e.valueOf())?n.value={refValueType:t,format:m,display:p.format(e,Calendar.fullFormat),value:e.valueOf()}:n.value=void 0}return"DatePicker"!==n.type&&"DateTimePicker"!==n.type||y.push(_jsx(DatePicker,{component:r,element:n,isOpen:t,onChange:function(e){let t=v;if("datetime"===v&&void 0!==e&&("date"===g&&(t="date"),void 0!==f)){const o=p.coerceIntoLocal(f),a=p.coerceIntoLocal(e);a.setHours(o.getHours()),a.setMinutes(o.getMinutes()),a.setSeconds(o.getSeconds()),a.setMilliseconds(o.getMilliseconds()),e=p.coerceIntoValue(a)}k(e,t)&&(h(e,t),r.forceUpdate(),s.post("changed",{name:l,value:n.value}))},onPopupToggle:()=>{var e=!t;o(e),e&&i(!1)},value:f},void 0)),"TimePicker"!==n.type&&"DateTimePicker"!==n.type||y.push(_jsxs("div",{className:"outer",children:[_jsx("div",{className:"inner",children:_jsx(TimePickerInput,{...e,isOpen:a,onChange:function(e){let t=v;if("datetime"===v&&void 0!==f)if(void 0!==e){const o=p.coerceIntoLocal(f),a=p.coerceIntoLocal(e);a.setFullYear(o.getFullYear()),a.setMonth(o.getMonth()),a.setDate(o.getDate()),e=p.coerceIntoValue(a)}else e=f,t="date";k(e,t)&&(h(e,t),r.forceUpdate(),s.post("changed",{name:l,value:n.value}))},onPopupToggle:d,ref:c,value:j},void 0)},void 0),_jsx("button",{className:"clockButton",disabled:e.disabled,onClick:d,children:renderClock()},void 0)]},void 0)),h(f,g),_jsx(FormElementOuter,{className:u.join(" "),component:r,element:n,children:y},void 0)};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import{Component}from"react";const domReferenceKey="__navigator";class Navigator extends Component{static find(t){let e=t.target;for(;e!==t.currentTarget&&e instanceof HTMLElement;){var r=e[domReferenceKey];if(r instanceof Navigator)return r;e=e.parentNode}}init(t){const e=this.target;void 0!==e&&(this.target=void 0,e[domReferenceKey]=void 0),null!==t&&((this.target=t)[domReferenceKey]=this)}focus(){this.target.focus()}scrollTo(t){var e=this.props.children;if(Array.isArray(e)){const n=this.target;var r=n.scrollHeight/e.length,s=r/2,e=t%r,e=(n.scrollHeight-n.clientHeight)/2+(e+(e<-s?r:s<=e?-r:0));return n.scrollTop=e,Math.round(t/r)}return 0}hasStates(){var t=this.state;if(null==t)return!1;t=t.states;return null!=t}render(){var t=this.props,e=this.state||{},r=e.states;const s=[t.className];if(null!=r)for(const n in r)!0===r[n]&&s.push(n);return _jsx("div",{className:s.join(" "),tabIndex:e.tabIndex,ref:t=>this.init(t),children:this.props.children},void 0)}}export{Navigator};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{useEffect,useMemo,useRef,useState}from"react";import{Range,getTrackBackground}from"react-range";import FormElementOuter from"../FormElementOuter.js";import{useFocusCallback}from"../common.js";import{CssClasses}from"../constants.js";import{getProcessedNumberFormat,getNumberSliderValues}from"../numberSliderUtilities.js";import{makeSafeClassName,throttle}from"../utils.js";const MIN_DECIMALS=0,DEFAULT_DECIMALS=0,DEFAULT_STEP=0,NumberRangeSlider=e=>{const a=e.component,r=e.element,t=useMemo(()=>getProcessedNumberFormat(r.format,MIN_DECIMALS,DEFAULT_DECIMALS,DEFAULT_STEP),[]),o=useRef(null),s=e=>{r.value=o.current=e},[n,l]=useState(),[i,u]=useState();useEffect(()=>{var e;null!==o.current&&r.value===o.current||(e=getNumberSliderValues(r.value,t),s(e),F(e))},[r.value]);const{host:c,name:m}=a.props,d=!a.enabled;var p=useFocusCallback(a);const{lowerBound:x,upperBound:v,precision:f}=t,{showMinMaxLabels:g,manualEntry:h}=r;let b=t.step,y=r.showTickMarks;y=0<b&&y,0===b&&(b=1/Math.pow(10,f));const E={currency:t.currency,customDisplayFormat:t.customDisplayFormat,format:t.displayFormat,fractionalDigits:f,locale:c.deriveLocale()};e=c.renderText(r.tooltip);const N=[r.type,makeSafeClassName(m)],j=e=>{e=S(e),F(e),(Array.isArray(o.current)||e[0]===x&&e[1]===v)&&(!Array.isArray(o.current)||e[0]===o.current[0]&&e[1]===o.current[1])||(s(e),c.post("changed",{name:m,value:r.value}))};const A=e=>{a.autoInput=!0},C=e=>e.target.select(),S=e=>{let r=e[0]<x?x:e[0]>v?v:e[0],t=e[1]>v?v:e[1]<x?x:e[1];return[r,t].sort((e,r)=>e-r)},_=useMemo(()=>throttle(e=>{c.post("dragged",{name:m,value:e})}),[]),k=(e,r)=>{const t=n.slice();let a=""!==e?Number(e):NaN;isNaN(a)?F(t):(0===r?(a<x&&(a=x),a>t[1]&&(a=t[1])):(a>v&&(a=v),a<t[0]&&(a=t[0])),t[r]=a,j(t))},F=e=>{l(e),u(e)};const M=(e,r,t,a,o="#fff",s="#197dc8")=>_jsx("div",{style:{position:"absolute",top:r,color:o,fontWeight:"bold",fontSize:"14px",fontFamily:"Arial,Helvetica Neue,Helvetica,sans-serif",padding:"4px",borderRadius:"5px",backgroundColor:s,left:t,right:a,whiteSpace:"nowrap"},children:e},void 0);return n?_jsxs(FormElementOuter,{className:N.join(" "),component:a,element:r,errorClassName:CssClasses.ERROR,children:[_jsx("div",{className:"slider-container",title:e,children:_jsx(Range,{draggableTrack:!0,step:b,min:x,max:v,values:n,onChange:e=>{e=S(e),F(e),Array.isArray(r.value)&&e[0]===r.value[0]&&e[1]===r.value[1]||_(e)},onFinalChange:j,renderMark:e=>{var{props:r,index:t}=e,e=x+t*b,t=e>v,e=e>n[0]&&e<n[1]?"#197dc8":"#ccc";return y&&!t&&_jsx("div",{...r,style:{...r.style,height:"16px",width:"2px",backgroundColor:e}},void 0)},renderTrack:e=>{var{props:r,children:e}=e;return _jsxs("div",{...r,style:{...r.style,height:"6px",margin:"50px 0px 24px",width:"100%",background:getTrackBackground({values:n,colors:["#ccc","#197dc8","#ccc"],min:x,max:v,rtl:!1})},children:[!1!==g&&M(c.formatNumber(x,E),"20px","-12px",void 0,"#333","#fff"),!1!==g&&M(c.formatNumber(v,E),"20px",void 0,"-12px","#333","#fff"),e]},void 0)},renderThumb:e=>{var{props:r,value:t,index:a}=e,o=v-x,e=t-x,t=e<o/10?"0":"auto",e=9*o/10<e?"0":"auto";return _jsx("div",{...r,style:{...r.style,height:"24px",width:"24px",borderRadius:"12px",backgroundColor:"#197dc8",display:"flex",justifyContent:"center",alignItems:"center",boxShadow:"0px 2px 4px #AAA",outline:"none"},children:M(c.formatNumber(n[a],E),"-32px",t,e)},void 0)},disabled:d,ref:p},void 0)},void 0),h||!i?null:_jsx("div",{className:"inputs",children:i.map((e,r)=>_jsxs("span",{children:[0===r?c.renderText("@common-start"):c.renderText("@common-end"),_jsx("input",{type:"number",disabled:d,min:0===r?x:n[0],max:0===r?n[1]:v,step:b,title:e+"",value:e,onBlur:e=>((e,r)=>{k(e.target.value,r)})(e,r),onChange:e=>((e,r)=>{const t=i.slice();t[r]=e.target.value,u(t),a.autoInput&&k(e.target.value,r)})(e,r),onKeyDown:e=>((e,r)=>{e.stopPropagation(),a.autoInput=!1,"Enter"===e.key?k(i[r]+"",r):"Escape"===e.key&&F(n.slice())})(e,r),onMouseDown:A,onFocus:C},r)]},void 0))},void 0)]},void 0):null};export default NumberRangeSlider;export{MIN_DECIMALS,DEFAULT_DECIMALS,DEFAULT_STEP};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{useEffect,useMemo,useRef,useState}from"react";import{Range}from"react-range";import FormElementOuter from"../FormElementOuter.js";import{useFocusCallback}from"../common.js";import{CssClasses}from"../constants.js";import{getProcessedNumberFormat,getNumberSliderValues}from"../numberSliderUtilities.js";import{makeSafeClassName}from"../utils.js";const MIN_DECIMALS=-20,DEFAULT_DECIMALS=3,DEFAULT_STEP=1,NumberSlider=e=>{const r=e.component,{host:s,name:t}=r.props,o=e.element,a=!r.enabled,n=useMemo(()=>getProcessedNumberFormat(o.format,MIN_DECIMALS,DEFAULT_DECIMALS,DEFAULT_STEP),[]),i=useRef(null),{lowerBound:l,upperBound:u,precision:m}=n,{showMinMaxLabels:d,manualEntry:p}=o,c={format:n.displayFormat,fractionalDigits:m,locale:s.deriveLocale()},x=e=>{var r;o.value=(r=e,{refValueType:"number",format:n,display:s.formatNumber(r,c),numeric:r}),i.current=e},[f,v]=useState(),[b,h]=useState();useEffect(()=>{var e=o.value;null!==i.current&&e?.numeric===i.current||(e=getNumberSliderValues(e,n,!0),x(e[0]),k(e[0]))},[o.value]);var g=useFocusCallback(r);let N=n.step,E=o.showTickMarks;E=0<N&&E,0===N&&(N=1/Math.pow(10,m));e=s.renderText(o.tooltip);const j=[o.type,makeSafeClassName(t)],C=e=>{e=A(e),k(e),e!==i.current&&(x(e),s.post("changed",{name:t,value:o.value}))},S=e=>{h(e.target.value),r.autoInput&&D(e.target.value)},_=e=>{D(e.target.value)},y=e=>{e.stopPropagation(),r.autoInput=!1,"Enter"===e.key?D(b+""):"Escape"===e.key&&k(f)},F=e=>{r.autoInput=!0},M=e=>e.target.select(),A=e=>e<l?l:e>u?u:e,D=e=>{let r=""!==e?Number(e):NaN;isNaN(r)?k(r):(r<l&&(r=l),r>u&&(r=u),C(r))},k=e=>{v(e),h(e)};const L=(e,r,t,o,a="#fff",s="#197dc8")=>_jsx("div",{style:{position:"absolute",top:r,color:a,fontWeight:"bold",fontSize:"14px",fontFamily:"Arial,Helvetica Neue,Helvetica,sans-serif",padding:"4px",borderRadius:"5px",backgroundColor:s,left:t,right:o,whiteSpace:"nowrap"},children:e},void 0);return _jsxs(FormElementOuter,{className:j.join(" "),component:r,element:o,errorClassName:CssClasses.ERROR,children:[_jsx("div",{className:"slider-container",title:e,children:_jsx(Range,{step:N,min:l,max:u,values:[f],onChange:e=>(e=>{e=A(e),k(e)})(e[0]),onFinalChange:e=>C(e[0]),renderMark:e=>{var{props:r,index:e}=e,e=l+e*N>u;return E&&!e&&_jsx("div",{...r,style:{...r.style,height:"16px",width:"2px",backgroundColor:"#ccc"}},void 0)},renderTrack:e=>{var{props:r,children:e}=e;return _jsxs("div",{...r,style:{...r.style,height:"6px",margin:"50px 0px 24px",width:"100%",background:"#ccc"},children:[!1!==d&&L(s.formatNumber(l,c),"20px","-12px",void 0,"#333","#fff"),!1!==d&&L(s.formatNumber(u,c),"20px",void 0,"-12px","#333","#fff"),e]},void 0)},renderThumb:e=>{var{props:r,value:t}=e,o=u-l,a=t-l,e=a<o/10?"0":"auto",a=9*o/10<a?"0":"auto";return _jsx("div",{...r,style:{...r.style,height:"24px",width:"24px",borderRadius:"12px",backgroundColor:"#197dc8",display:"flex",justifyContent:"center",alignItems:"center",boxShadow:"0px 2px 4px #AAA",outline:"none"},children:L(s.formatNumber(t,c),"-32px",e,a)},void 0)},disabled:a,ref:g},void 0)},void 0),!1===p?null:_jsx("div",{className:"inputs",children:_jsx("span",{children:_jsx("input",{type:"number",disabled:a,min:l,max:u,step:N,title:b+"",value:b,onBlur:_,onChange:S,onKeyDown:y,onMouseDown:F,onFocus:M},void 0)},void 0)},void 0)]},void 0)};export default NumberSlider;export{MIN_DECIMALS,DEFAULT_DECIMALS,DEFAULT_STEP};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{Component}from"react";const domReferenceKey="__synthetic_button";class SyntheticButton extends Component{static find(t){let e=t.target;for(;e!==t.currentTarget&&e instanceof HTMLElement;){var n=e[domReferenceKey];if(n instanceof SyntheticButton)return n;e=e.parentNode}}static search(t){const e=t.querySelectorAll("div"),n=[];for(let t=0;t<e.length;t++){var s=e.item(t)[domReferenceKey];s instanceof SyntheticButton&&n.push(s)}return n}init(t){const e=this.target;void 0!==e&&(this.target=void 0,e[domReferenceKey]=void 0),null!==t&&((this.target=t)[domReferenceKey]=this)}render(){var t=this.props,e=this.state||{},n=e.states;const s=["button"];if(null!=n)for(const i in n)!0===n[i]&&s.push(i);var r=e.content,e=e.symbol;return _jsx("div",{className:this.props.className,ref:t=>this.init(t),children:_jsxs("div",{className:s.join(" "),"aria-label":t.ariaLabel,children:[_jsx("span",{className:"content",children:r},void 0),_jsx("span",{className:"symbol",children:e},void 0)]},void 0)},void 0)}}export{SyntheticButton};
|