@j2inn/resolvable-ui-elements 1.0.4-beta.0 → 1.0.5

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/README.md CHANGED
@@ -1,22 +1,36 @@
1
- # What is resolvable-ui-elements?
2
- The main goal of this library is to enhance the flexibility of the UI code written, by adding a layer that separates the queries and information used to interact with the backend from the UI code, moving it to a separated JSON file.
3
-
4
- The JSON file (typically called `elements.json`) can be generated from a spreadsheet used to simplify the data management for a project UI.
5
-
6
-
7
- ## How do I get set up? ###
8
- To install this package run `npm i @j2inn/resolvable-ui-elements`
9
-
10
- ## Where do I get more info? ###
11
- See: https://finproducts.atlassian.net/wiki/spaces/ECO/pages/32881311778/Element+Types
12
-
13
- ## Codebase Structure ##
14
-
15
- src
16
- ├── resolvableElements
17
- │ ├── elements # Element classes implementation
18
- │ ├── interfacesGeneration # Code for generating interfaces from an elements.json file
19
- │ ├── react # React hooks to use resolvable elements.
20
- │ └── ...
21
- └── ...
22
-
1
+ # What is resolvable-ui-elements?
2
+ The main goal of this library is to enhance the flexibility of the UI code written, by adding a layer that separates the queries and information used to interact with the backend from the UI code, moving it to a separated JSON file.
3
+
4
+ The JSON file (typically called `elements.json`) can be generated from a spreadsheet used to simplify the data management for a project UI.
5
+
6
+
7
+ ## How do I get set up? ###
8
+ To install this package run `npm i @j2inn/resolvable-ui-elements`
9
+
10
+ ## Where do I get more info? ###
11
+ See: https://finproducts.atlassian.net/wiki/spaces/ECO/pages/32881311778/Element+Types
12
+
13
+ ## Codebase Structure ##
14
+
15
+ src
16
+ ├── resolvableElements
17
+ │ ├── elements # Element classes implementation
18
+ │ ├── interfacesGeneration # Code for generating interfaces from an elements.json file
19
+ │ ├── react # React hooks to use resolvable elements.
20
+ │ └── ...
21
+ └── ...
22
+
23
+ ## BE libraries dependencies ##
24
+ If you decide to use the Resolver's `evalFuncName` feature, this library should be used in combination with [finOemAuthzExt](https://bitbucket.org/finproducts/finoemauthzext). The pod allows the usage of the wrapper function.
25
+ ```typescript
26
+ /**
27
+ * Function name to be used for expressions eval,
28
+ * used to enable custom backend permission check using elements path
29
+ * @example
30
+ * customEval(\`page/section/elementName\`, parametersDict)
31
+ */
32
+ evalFuncName?: string
33
+ ```
34
+
35
+ ### v1.0.4 ###
36
+ Version 1.0.4 of this library introduces the usage of optional parameters in function evaluation. To be able to use them, [finOemAuthzExt](https://bitbucket.org/finproducts/finoemauthzext) 1.0.2+ should be used for the BE.
@@ -8,6 +8,7 @@ const haystack_core_1 = require("haystack-core");
8
8
  const haystack_units_1 = require("haystack-units");
9
9
  const resolveTemplatedExpression_1 = require("../../resolveTemplatedExpression");
10
10
  const ResolvableValueElement_1 = require("../ResolvableValueElement");
11
+ const GRID_VAL_COLUMN_NAME = 'val';
11
12
  /**
12
13
  * Resolves to the result of an expression.
13
14
  */
@@ -27,10 +28,10 @@ class ResolvableExprElement extends ResolvableValueElement_1.ResolvableValueElem
27
28
  const grid = await this.resolver.evalExprElement(expr, parameters, path);
28
29
  // Identify when it's necessary to unpack the result `val` or not
29
30
  // since the eval wraps the result value in a grid's first dict `val` tag for non-collections.
30
- const val = grid[0]?.get('val');
31
- const shouldUnpackResult = !this.isExpectedResultACollection() && val;
31
+ const shouldUnpackResult = !this.isExpectedResultACollection() &&
32
+ grid.hasColumn(GRID_VAL_COLUMN_NAME);
32
33
  if (shouldUnpackResult) {
33
- this.value = val;
34
+ this.value = grid[0]?.get(GRID_VAL_COLUMN_NAME);
34
35
  }
35
36
  else {
36
37
  this.value = grid;
@@ -1 +1 @@
1
- {"version":3,"file":"ResolvableExprElement.js","sourceRoot":"","sources":["../../../../src/resolvableElements/elements/expr/ResolvableExprElement.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,iDAA2C;AAC3C,mDAAoD;AACpD,iFAA2E;AAE3E,sEAAkE;AAIlE;;GAEG;AACH,MAAa,qBAEX,SAAQ,+CAAyB;IAClC,MAAM,CAAC,eAAe,GAAG,IAAI,GAA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E,YAAY,EAAE,GAAG,IAAI,CAAC,KAAkC,CAAA;QAEhE,OAAO,CACN,qBAAqB,CAAC,eAAe,CAAC,GAAG,CAAC,YAAY,CAAC;YACvD,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,CAC3B,CAAA;IACF,CAAC,CAAA;IAES,OAAO,GAAG,KAAK,IAAmB,EAAE;QAC7C,IAAI,IAAI,CAAC,QAAQ,EAAE;YAClB,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;SAC3B;IACF,CAAC,CAAA;IAED,gBAAgB,GAAmB,GAAG,EAAE;QACvC,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,KAAkC,CAAA;QAExD,MAAM,UAAU,GAAa,EAAE,CAAA;QAE/B,IAAI,IAAI,EAAE;YACT,IAAA,qDAAwB,EAAC,IAAI,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE;gBAC3C,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;gBACtB,OAAO,EAAE,CAAA;YACV,CAAC,CAAC,CAAA;SACF;QAED,OAAO,UAAU,CAAA;IAClB,CAAC,CAAA;;AAxEF,sDAyEC"}
1
+ {"version":3,"file":"ResolvableExprElement.js","sourceRoot":"","sources":["../../../../src/resolvableElements/elements/expr/ResolvableExprElement.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,iDAA2C;AAC3C,mDAAoD;AACpD,iFAA2E;AAE3E,sEAAkE;AAIlE,MAAM,oBAAoB,GAAG,KAAK,CAAA;AAElC;;GAEG;AACH,MAAa,qBAEX,SAAQ,+CAAyB;IAClC,MAAM,CAAC,eAAe,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAA;IAEpD,YAAY,IAAiC;QAC5C,KAAK,CAAC,IAAI,CAAC,CAAA;IACZ,CAAC;IAED,SAAS,GAAG,CAAC,CAAA;IACb,QAAQ,CAAS;IAEP,YAAY,GAAG,KAAK,EAAE,UAAi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,KAAK,IAAmB,EAAE;QAC7C,IAAI,IAAI,CAAC,QAAQ,EAAE;YAClB,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;SAC3B;IACF,CAAC,CAAA;IAED,gBAAgB,GAAmB,GAAG,EAAE;QACvC,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,KAAkC,CAAA;QAExD,MAAM,UAAU,GAAa,EAAE,CAAA;QAE/B,IAAI,IAAI,EAAE;YACT,IAAA,qDAAwB,EAAC,IAAI,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE;gBAC3C,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;gBACtB,OAAO,EAAE,CAAA;YACV,CAAC,CAAC,CAAA;SACF;QAED,OAAO,UAAU,CAAA;IAClB,CAAC,CAAA;;AAzEF,sDA0EC"}
@@ -1,10 +1,13 @@
1
1
  import { HDict } from 'haystack-core';
2
2
  export declare const REG_EXPR_MATCHING_TEMPLATE: RegExp;
3
3
  /**
4
- * Replaces variables (defined as <$parameterName>) in an expression with the values given in the parameters dict.
5
- * The HVal.toAxon function is used for conversion to a string.
4
+ * Replaces variables (defined as {{parameterName}}) in an expression with the values given in the parameters dict.
5
+ * The HVal.toAxon function is used for conversion to a string. Optional parameters can be marked using a '?'
6
+ * after the parameter name. They can safely be omitted in the parameters Dict.
6
7
  * @example
7
- * resolveTemplatedExpression("func({{num}})", HDict.make({num: HNum.make("22")})) => "func(22)"
8
+ * resolveTemplatedExpression("func({{num}})", HDict.make({num: HNum.make(22)})) => "func(22)"
9
+ * @example
10
+ * resolveTemplatedExpression("func({{num}}, {{unit?}})", HDict.make({num: HNum.make(22)})) => "func(22, null)"
8
11
  * @param expr the axon expression
9
12
  * @param params the parameters expressed as dict
10
13
  * @returns the axon expression resolved with the specified params
@@ -7,10 +7,13 @@ exports.replaceTemplateVariables = exports.resolveTemplateExpression = exports.R
7
7
  const haystack_core_1 = require("haystack-core");
8
8
  exports.REG_EXPR_MATCHING_TEMPLATE = new RegExp(/{{([^{}?]*)(\??)}}/, 'g');
9
9
  /**
10
- * Replaces variables (defined as <$parameterName>) in an expression with the values given in the parameters dict.
11
- * The HVal.toAxon function is used for conversion to a string.
10
+ * Replaces variables (defined as {{parameterName}}) in an expression with the values given in the parameters dict.
11
+ * The HVal.toAxon function is used for conversion to a string. Optional parameters can be marked using a '?'
12
+ * after the parameter name. They can safely be omitted in the parameters Dict.
12
13
  * @example
13
- * resolveTemplatedExpression("func({{num}})", HDict.make({num: HNum.make("22")})) => "func(22)"
14
+ * resolveTemplatedExpression("func({{num}})", HDict.make({num: HNum.make(22)})) => "func(22)"
15
+ * @example
16
+ * resolveTemplatedExpression("func({{num}}, {{unit?}})", HDict.make({num: HNum.make(22)})) => "func(22, null)"
14
17
  * @param expr the axon expression
15
18
  * @param params the parameters expressed as dict
16
19
  * @returns the axon expression resolved with the specified params
@@ -1 +1 @@
1
- {"version":3,"file":"resolveTemplatedExpression.js","sourceRoot":"","sources":["../../src/resolvableElements/resolveTemplatedExpression.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,iDAAgD;AAEnC,QAAA,0BAA0B,GAAG,IAAI,MAAM,CAAC,oBAAoB,EAAE,GAAG,CAAC,CAAA;AAE/E;;;;;;;;GAQG;AACI,MAAM,yBAAyB,GAAG,CACxC,IAAY,EACZ,UAAkB,EACT,EAAE;IACX,MAAM,SAAS,GAAG,UAAU,CAAA;IAE5B,OAAO,IAAA,gCAAwB,EAC9B,IAAI,EACJ,CAAC,UAAkB,EAAE,KAAa,EAAE,QAAgB,EAAE,EAAE;QACvD,MAAM,UAAU,GAAG,QAAQ,KAAK,GAAG,CAAA;QACnC,MAAM,SAAS,GAAG,SAAS,EAAE,GAAG,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;QACjD,IAAI,SAAS,IAAI,IAAI,EAAE;YACtB,OAAO,SAAS,CAAA;SAChB;aAAM,IAAI,UAAU,EAAE;YACtB,OAAO,yBAAS,CAAA;SAChB;QACD,MAAM,IAAI,KAAK,CACd,6BAA6B,KAAK,OAAO,SAAS,EAAE,MAAM,EAAE,EAAE,CAC9D,CAAA;IACF,CAAC,CACD,CAAA;AACF,CAAC,CAAA;AArBY,QAAA,yBAAyB,6BAqBrC;AAED;;;;;GAKG;AACI,MAAM,wBAAwB,GAAG,CACvC,cAAsB,EACtB,QAAwE,EAC/D,EAAE,CAAC,cAAc,CAAC,OAAO,CAAC,kCAA0B,EAAE,QAAQ,CAAC,CAAA;AAH5D,QAAA,wBAAwB,4BAGoC"}
1
+ {"version":3,"file":"resolveTemplatedExpression.js","sourceRoot":"","sources":["../../src/resolvableElements/resolveTemplatedExpression.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,iDAAgD;AAEnC,QAAA,0BAA0B,GAAG,IAAI,MAAM,CAAC,oBAAoB,EAAE,GAAG,CAAC,CAAA;AAE/E;;;;;;;;;;;GAWG;AACI,MAAM,yBAAyB,GAAG,CACxC,IAAY,EACZ,UAAkB,EACT,EAAE;IACX,MAAM,SAAS,GAAG,UAAU,CAAA;IAE5B,OAAO,IAAA,gCAAwB,EAC9B,IAAI,EACJ,CAAC,UAAkB,EAAE,KAAa,EAAE,QAAgB,EAAE,EAAE;QACvD,MAAM,UAAU,GAAG,QAAQ,KAAK,GAAG,CAAA;QACnC,MAAM,SAAS,GAAG,SAAS,EAAE,GAAG,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;QACjD,IAAI,SAAS,IAAI,IAAI,EAAE;YACtB,OAAO,SAAS,CAAA;SAChB;aAAM,IAAI,UAAU,EAAE;YACtB,OAAO,yBAAS,CAAA;SAChB;QACD,MAAM,IAAI,KAAK,CACd,6BAA6B,KAAK,OAAO,SAAS,EAAE,MAAM,EAAE,EAAE,CAC9D,CAAA;IACF,CAAC,CACD,CAAA;AACF,CAAC,CAAA;AArBY,QAAA,yBAAyB,6BAqBrC;AAED;;;;;GAKG;AACI,MAAM,wBAAwB,GAAG,CACvC,cAAsB,EACtB,QAAwE,EAC/D,EAAE,CAAC,cAAc,CAAC,OAAO,CAAC,kCAA0B,EAAE,QAAQ,CAAC,CAAA;AAH5D,QAAA,wBAAwB,4BAGoC"}
@@ -5,6 +5,7 @@ import { HNum } from 'haystack-core';
5
5
  import { millisecond, second } from 'haystack-units';
6
6
  import { replaceTemplateVariables } from '../../resolveTemplatedExpression';
7
7
  import { ResolvableValueElement } from '../ResolvableValueElement';
8
+ const GRID_VAL_COLUMN_NAME = 'val';
8
9
  /**
9
10
  * Resolves to the result of an expression.
10
11
  */
@@ -24,10 +25,10 @@ export class ResolvableExprElement extends ResolvableValueElement {
24
25
  const grid = await this.resolver.evalExprElement(expr, parameters, path);
25
26
  // Identify when it's necessary to unpack the result `val` or not
26
27
  // since the eval wraps the result value in a grid's first dict `val` tag for non-collections.
27
- const val = grid[0]?.get('val');
28
- const shouldUnpackResult = !this.isExpectedResultACollection() && val;
28
+ const shouldUnpackResult = !this.isExpectedResultACollection() &&
29
+ grid.hasColumn(GRID_VAL_COLUMN_NAME);
29
30
  if (shouldUnpackResult) {
30
- this.value = val;
31
+ this.value = grid[0]?.get(GRID_VAL_COLUMN_NAME);
31
32
  }
32
33
  else {
33
34
  this.value = grid;
@@ -1 +1 @@
1
- {"version":3,"file":"ResolvableExprElement.js","sourceRoot":"","sources":["../../../../src/resolvableElements/elements/expr/ResolvableExprElement.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAS,IAAI,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAA;AAE3E,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAA;AAIlE;;GAEG;AACH,MAAM,OAAO,qBAEX,SAAQ,sBAAyB;IAClC,MAAM,CAAC,eAAe,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,OAAO,CA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,CAAA;QAEhE,OAAO,CACN,qBAAqB,CAAC,eAAe,CAAC,GAAG,CAAC,YAAY,CAAC;YACvD,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,CAC3B,CAAA;IACF,CAAC,CAAA;IAES,OAAO,GAAG,KAAK,IAAmB,EAAE;QAC7C,IAAI,IAAI,CAAC,QAAQ,EAAE;YAClB,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;SAC3B;IACF,CAAC,CAAA;IAED,gBAAgB,GAAmB,GAAG,EAAE;QACvC,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,KAAkC,CAAA;QAExD,MAAM,UAAU,GAAa,EAAE,CAAA;QAE/B,IAAI,IAAI,EAAE;YACT,wBAAwB,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE;gBAC3C,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;gBACtB,OAAO,EAAE,CAAA;YACV,CAAC,CAAC,CAAA;SACF;QAED,OAAO,UAAU,CAAA;IAClB,CAAC,CAAA"}
1
+ {"version":3,"file":"ResolvableExprElement.js","sourceRoot":"","sources":["../../../../src/resolvableElements/elements/expr/ResolvableExprElement.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAS,IAAI,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAA;AAE3E,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAA;AAIlE,MAAM,oBAAoB,GAAG,KAAK,CAAA;AAElC;;GAEG;AACH,MAAM,OAAO,qBAEX,SAAQ,sBAAyB;IAClC,MAAM,CAAC,eAAe,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAA;IAEpD,YAAY,IAAiC;QAC5C,KAAK,CAAC,IAAI,CAAC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Y,CAAC;YACvD,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,CAC3B,CAAA;IACF,CAAC,CAAA;IAES,OAAO,GAAG,KAAK,IAAmB,EAAE;QAC7C,IAAI,IAAI,CAAC,QAAQ,EAAE;YAClB,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;SAC3B;IACF,CAAC,CAAA;IAED,gBAAgB,GAAmB,GAAG,EAAE;QACvC,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,KAAkC,CAAA;QAExD,MAAM,UAAU,GAAa,EAAE,CAAA;QAE/B,IAAI,IAAI,EAAE;YACT,wBAAwB,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE;gBAC3C,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;gBACtB,OAAO,EAAE,CAAA;YACV,CAAC,CAAC,CAAA;SACF;QAED,OAAO,UAAU,CAAA;IAClB,CAAC,CAAA"}
@@ -1,10 +1,13 @@
1
1
  import { HDict } from 'haystack-core';
2
2
  export declare const REG_EXPR_MATCHING_TEMPLATE: RegExp;
3
3
  /**
4
- * Replaces variables (defined as <$parameterName>) in an expression with the values given in the parameters dict.
5
- * The HVal.toAxon function is used for conversion to a string.
4
+ * Replaces variables (defined as {{parameterName}}) in an expression with the values given in the parameters dict.
5
+ * The HVal.toAxon function is used for conversion to a string. Optional parameters can be marked using a '?'
6
+ * after the parameter name. They can safely be omitted in the parameters Dict.
6
7
  * @example
7
- * resolveTemplatedExpression("func({{num}})", HDict.make({num: HNum.make("22")})) => "func(22)"
8
+ * resolveTemplatedExpression("func({{num}})", HDict.make({num: HNum.make(22)})) => "func(22)"
9
+ * @example
10
+ * resolveTemplatedExpression("func({{num}}, {{unit?}})", HDict.make({num: HNum.make(22)})) => "func(22, null)"
8
11
  * @param expr the axon expression
9
12
  * @param params the parameters expressed as dict
10
13
  * @returns the axon expression resolved with the specified params
@@ -4,10 +4,13 @@
4
4
  import { AXON_NULL } from 'haystack-core';
5
5
  export const REG_EXPR_MATCHING_TEMPLATE = new RegExp(/{{([^{}?]*)(\??)}}/, 'g');
6
6
  /**
7
- * Replaces variables (defined as <$parameterName>) in an expression with the values given in the parameters dict.
8
- * The HVal.toAxon function is used for conversion to a string.
7
+ * Replaces variables (defined as {{parameterName}}) in an expression with the values given in the parameters dict.
8
+ * The HVal.toAxon function is used for conversion to a string. Optional parameters can be marked using a '?'
9
+ * after the parameter name. They can safely be omitted in the parameters Dict.
9
10
  * @example
10
- * resolveTemplatedExpression("func({{num}})", HDict.make({num: HNum.make("22")})) => "func(22)"
11
+ * resolveTemplatedExpression("func({{num}})", HDict.make({num: HNum.make(22)})) => "func(22)"
12
+ * @example
13
+ * resolveTemplatedExpression("func({{num}}, {{unit?}})", HDict.make({num: HNum.make(22)})) => "func(22, null)"
11
14
  * @param expr the axon expression
12
15
  * @param params the parameters expressed as dict
13
16
  * @returns the axon expression resolved with the specified params
@@ -1 +1 @@
1
- {"version":3,"file":"resolveTemplatedExpression.js","sourceRoot":"","sources":["../../src/resolvableElements/resolveTemplatedExpression.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAS,MAAM,eAAe,CAAA;AAEhD,MAAM,CAAC,MAAM,0BAA0B,GAAG,IAAI,MAAM,CAAC,oBAAoB,EAAE,GAAG,CAAC,CAAA;AAE/E;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CACxC,IAAY,EACZ,UAAkB,EACT,EAAE;IACX,MAAM,SAAS,GAAG,UAAU,CAAA;IAE5B,OAAO,wBAAwB,CAC9B,IAAI,EACJ,CAAC,UAAkB,EAAE,KAAa,EAAE,QAAgB,EAAE,EAAE;QACvD,MAAM,UAAU,GAAG,QAAQ,KAAK,GAAG,CAAA;QACnC,MAAM,SAAS,GAAG,SAAS,EAAE,GAAG,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;QACjD,IAAI,SAAS,IAAI,IAAI,EAAE;YACtB,OAAO,SAAS,CAAA;SAChB;aAAM,IAAI,UAAU,EAAE;YACtB,OAAO,SAAS,CAAA;SAChB;QACD,MAAM,IAAI,KAAK,CACd,6BAA6B,KAAK,OAAO,SAAS,EAAE,MAAM,EAAE,EAAE,CAC9D,CAAA;IACF,CAAC,CACD,CAAA;AACF,CAAC,CAAA;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CACvC,cAAsB,EACtB,QAAwE,EAC/D,EAAE,CAAC,cAAc,CAAC,OAAO,CAAC,0BAA0B,EAAE,QAAQ,CAAC,CAAA"}
1
+ {"version":3,"file":"resolveTemplatedExpression.js","sourceRoot":"","sources":["../../src/resolvableElements/resolveTemplatedExpression.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAS,MAAM,eAAe,CAAA;AAEhD,MAAM,CAAC,MAAM,0BAA0B,GAAG,IAAI,MAAM,CAAC,oBAAoB,EAAE,GAAG,CAAC,CAAA;AAE/E;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CACxC,IAAY,EACZ,UAAkB,EACT,EAAE;IACX,MAAM,SAAS,GAAG,UAAU,CAAA;IAE5B,OAAO,wBAAwB,CAC9B,IAAI,EACJ,CAAC,UAAkB,EAAE,KAAa,EAAE,QAAgB,EAAE,EAAE;QACvD,MAAM,UAAU,GAAG,QAAQ,KAAK,GAAG,CAAA;QACnC,MAAM,SAAS,GAAG,SAAS,EAAE,GAAG,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;QACjD,IAAI,SAAS,IAAI,IAAI,EAAE;YACtB,OAAO,SAAS,CAAA;SAChB;aAAM,IAAI,UAAU,EAAE;YACtB,OAAO,SAAS,CAAA;SAChB;QACD,MAAM,IAAI,KAAK,CACd,6BAA6B,KAAK,OAAO,SAAS,EAAE,MAAM,EAAE,EAAE,CAC9D,CAAA;IACF,CAAC,CACD,CAAA;AACF,CAAC,CAAA;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CACvC,cAAsB,EACtB,QAAwE,EAC/D,EAAE,CAAC,cAAc,CAAC,OAAO,CAAC,0BAA0B,EAAE,QAAQ,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@j2inn/resolvable-ui-elements",
3
- "version": "1.0.4-beta.0",
3
+ "version": "1.0.5",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -49,4 +49,4 @@
49
49
  "ts-jest": "^28.0.8",
50
50
  "typescript": "^4.8.2"
51
51
  }
52
- }
52
+ }