@j2inn/resolvable-ui-elements 0.0.2-beta.5 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export { type FunctionResult } from './resolvableElements/elements/function/FunctionElement';
2
2
  export { isSectionData, type ParametersOfSection, type ResolvedSection, } from './resolvableElements/elements/section/SectionElementMeta';
3
3
  export { type UiElementData } from './resolvableElements/elements/UiElement';
4
+ export * from './resolvableElements/react/SectionChecker';
4
5
  export * from './resolvableElements/react/useResolverContext';
5
6
  export * from './resolvableElements/react/useResolveSection';
6
7
  export * from './useCurrentUser';
package/dist/index.js CHANGED
@@ -23,6 +23,7 @@ Object.defineProperty(exports, "isSectionData", { enumerable: true, get: functio
23
23
  //////////////////////////////////////////////////////////////////////////
24
24
  // React
25
25
  //////////////////////////////////////////////////////////////////////////
26
+ __exportStar(require("./resolvableElements/react/SectionChecker"), exports);
26
27
  __exportStar(require("./resolvableElements/react/useResolverContext"), exports);
27
28
  __exportStar(require("./resolvableElements/react/useResolveSection"), exports);
28
29
  //////////////////////////////////////////////////////////////////////////
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;AAMH,+FAIiE;AAHhE,mHAAA,aAAa,OAAA;AAKd,0EAA0E;AAC1E,QAAQ;AACR,0EAA0E;AAC1E,gFAA6D;AAC7D,+EAA4D;AAC5D,0EAA0E;AAC1E,QAAQ;AACR,0EAA0E;AAC1E,mDAAgC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;AAMH,+FAIiE;AAHhE,mHAAA,aAAa,OAAA;AAKd,0EAA0E;AAC1E,QAAQ;AACR,0EAA0E;AAC1E,4EAAyD;AACzD,gFAA6D;AAC7D,+EAA4D;AAC5D,0EAA0E;AAC1E,QAAQ;AACR,0EAA0E;AAC1E,mDAAgC"}
@@ -6,9 +6,15 @@ import { UiElementConstructorData, UiElementData } from '../UiElement';
6
6
  */
7
7
  export declare class ResolvableExprElement<T extends UiElementData> extends ResolvableValueElement<T> {
8
8
  #private;
9
+ static collectionTypes: Set<string>;
9
10
  constructor(data: UiElementConstructorData<T>);
10
11
  refreshes: number;
11
12
  protected doInitialize: (parameters: HDict) => Promise<void>;
13
+ /**
14
+ * Checks whether the declared resolvedType of this element is a collection.
15
+ * @returns true if the resolvedType is a collection.
16
+ */
17
+ isExpectedResultACollection: () => boolean;
12
18
  protected doClose: () => Promise<void>;
13
19
  getParameterList: () => string[];
14
20
  }
@@ -12,6 +12,7 @@ const ResolvableValueElement_1 = require("../ResolvableValueElement");
12
12
  * Resolves to the result of an expression.
13
13
  */
14
14
  class ResolvableExprElement extends ResolvableValueElement_1.ResolvableValueElement {
15
+ static collectionTypes = new Set(['HGrid', 'HList']);
15
16
  constructor(data) {
16
17
  super(data);
17
18
  }
@@ -29,7 +30,10 @@ class ResolvableExprElement extends ResolvableValueElement_1.ResolvableValueElem
29
30
  return;
30
31
  }
31
32
  const val = grid[0]?.get('val');
32
- if (val) {
33
+ // Identify when it's necessary to unpack the result `val` or not
34
+ // since the eval wraps the result value in a grid's first dict `val` tag for non-collections.
35
+ const shouldUnpackResult = !this.isExpectedResultACollection() && val;
36
+ if (shouldUnpackResult) {
33
37
  this.value = val;
34
38
  }
35
39
  else {
@@ -42,6 +46,15 @@ class ResolvableExprElement extends ResolvableValueElement_1.ResolvableValueElem
42
46
  }, haystack_core_1.HNum.make(refreshAfter, haystack_units_1.second).convertTo(haystack_units_1.millisecond).value);
43
47
  }
44
48
  };
49
+ /**
50
+ * Checks whether the declared resolvedType of this element is a collection.
51
+ * @returns true if the resolvedType is a collection.
52
+ */
53
+ isExpectedResultACollection = () => {
54
+ const { resolvedType } = this._meta;
55
+ return (ResolvableExprElement.collectionTypes.has(resolvedType) ||
56
+ resolvedType.endsWith('[]'));
57
+ };
45
58
  doClose = async () => {
46
59
  if (this.#timeout) {
47
60
  clearTimeout(this.#timeout);
@@ -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,iFAGyC;AAEzC,sEAAkE;AAIlE;;GAEG;AACH,MAAa,qBAEX,SAAQ,+CAAyB;IAClC,YAAY,IAAiC;QAC5C,KAAK,CAAC,IAAI,CAAC,CAAA;IACZ,CAAC;IAED,SAAS,GAAG,CAAC,CAAA;IACb,QAAQ,CAAS;IAEP,YAAY,GAAG,KAAK,EAAE,UAAiB,EAAiB,EAAE;QACnE,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,CAAA;IAC9B,CAAC,CAAA;IAED,YAAY,GAAG,KAAK,EAAE,UAAiB,EAAiB,EAAE;QACzD,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,GAAG,IAAI,CAAC,KAAkC,CAAA;QAEtE,MAAM,kBAAkB,GAAG,IAAA,sDAAyB,EAAC,IAAI,EAAE,UAAU,CAAC,CAAA;QAEtE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAA;QAEzD,IAAI,IAAI,CAAC,OAAO,EAAE,EAAE;YACnB,OAAO,CAAC,KAAK,CACZ,sCAAsC,EACtC,kBAAkB,EAClB,IAAI,CAAC,QAAQ,EAAE,CACf,CAAA;YACD,OAAM;SACN;QAED,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,KAAK,CAAC,CAAA;QAE/B,IAAI,GAAG,EAAE;YACR,IAAI,CAAC,KAAK,GAAG,GAAG,CAAA;SAChB;aAAM;YACN,IAAI,CAAC,KAAK,GAAG,IAAI,CAAA;SACjB;QAED,IAAI,YAAY,EAAE;YACjB,IAAI,CAAC,QAAQ,GAAG,UAAU,CAAC,GAAG,EAAE;gBAC/B,IAAI,CAAC,SAAS,EAAE,CAAA;gBAChB,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,CAAA;YAC9B,CAAC,EAAE,oBAAI,CAAC,IAAI,CAAC,YAAY,EAAE,uBAAM,CAAC,CAAC,SAAS,CAAC,4BAAW,CAAC,CAAC,KAAK,CAAsB,CAAA;SACrF;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;CACD;AAlED,sDAkEC"}
1
+ {"version":3,"file":"ResolvableExprElement.js","sourceRoot":"","sources":["../../../../src/resolvableElements/elements/expr/ResolvableExprElement.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,iDAA2C;AAC3C,mDAAoD;AACpD,iFAGyC;AAEzC,sEAAkE;AAIlE;;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,C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AsB,CAAA;SACrF;IACF,CAAC,CAAA;IAED;;;OAGG;IACH,2BAA2B,GAAG,GAAY,EAAE;QAC3C,MAAM,EAAE,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;;AAnFF,sDAoFC"}
@@ -0,0 +1,24 @@
1
+ import React from 'react';
2
+ import { UiElementData } from 'resolvableElements/elements/UiElement';
3
+ /**
4
+ * An utility type that allows a component to accept props with or without a 'section' property.
5
+ */
6
+ export declare type OptionalSection<P> = P | (Omit<P, 'section'> & {
7
+ section?: undefined;
8
+ });
9
+ /**
10
+ * Higher-Order Component that takes a section based component as an argument and returns a new component
11
+ * that checks if the 'section' prop is defined before rendering the SectionComponent.
12
+ * If the 'section' prop is undefined, it returns an empty element.
13
+ *
14
+ * @template P - Props of the original SectionComponent
15
+ * @param {React.FC<P>} SectionComponent - The original component that will be wrapped
16
+ * @returns {React.FC<P | (Omit<P, 'section'> & { section?: undefined })>} - The wrapped component
17
+ * @example
18
+ * const CheckedComponent = SectionChecker(({section, ...props}) => {
19
+ * return <div>{section.title}</div>
20
+ * })
21
+ */
22
+ export declare const SectionChecker: <P extends {
23
+ section: UiElementData;
24
+ }>(SectionComponent: React.FC<P>) => (props: OptionalSection<P>) => JSX.Element;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.SectionChecker = void 0;
7
+ const react_1 = __importDefault(require("react"));
8
+ /**
9
+ * Higher-Order Component that takes a section based component as an argument and returns a new component
10
+ * that checks if the 'section' prop is defined before rendering the SectionComponent.
11
+ * If the 'section' prop is undefined, it returns an empty element.
12
+ *
13
+ * @template P - Props of the original SectionComponent
14
+ * @param {React.FC<P>} SectionComponent - The original component that will be wrapped
15
+ * @returns {React.FC<P | (Omit<P, 'section'> & { section?: undefined })>} - The wrapped component
16
+ * @example
17
+ * const CheckedComponent = SectionChecker(({section, ...props}) => {
18
+ * return <div>{section.title}</div>
19
+ * })
20
+ */
21
+ const SectionChecker = (SectionComponent) => {
22
+ const CheckedSectionComponent = (props) => {
23
+ return !props.section ? <></> : <SectionComponent {...props}/>;
24
+ };
25
+ return CheckedSectionComponent;
26
+ };
27
+ exports.SectionChecker = SectionChecker;
28
+ //# sourceMappingURL=SectionChecker.jsx.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SectionChecker.jsx","sourceRoot":"","sources":["../../../src/resolvableElements/react/SectionChecker.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAAyB;AAUzB;;;;;;;;;;;;GAYG;AACI,MAAM,cAAc,GAAG,CAC7B,gBAA6B,EAC5B,EAAE;IACH,MAAM,uBAAuB,GAAG,CAAC,KAAyB,EAAE,EAAE;QAC7D,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,IAAI,KAAK,CAAC,EAAG,CAAA;IAChE,CAAC,CAAA;IAED,OAAO,uBAAuB,CAAA;AAC/B,CAAC,CAAA;AARY,QAAA,cAAc,kBAQ1B"}
@@ -1,6 +1,7 @@
1
1
  export { type FunctionResult } from './resolvableElements/elements/function/FunctionElement';
2
2
  export { isSectionData, type ParametersOfSection, type ResolvedSection, } from './resolvableElements/elements/section/SectionElementMeta';
3
3
  export { type UiElementData } from './resolvableElements/elements/UiElement';
4
+ export * from './resolvableElements/react/SectionChecker';
4
5
  export * from './resolvableElements/react/useResolverContext';
5
6
  export * from './resolvableElements/react/useResolveSection';
6
7
  export * from './useCurrentUser';
package/dist_es/index.js CHANGED
@@ -5,6 +5,7 @@ export { isSectionData, } from './resolvableElements/elements/section/SectionEle
5
5
  //////////////////////////////////////////////////////////////////////////
6
6
  // React
7
7
  //////////////////////////////////////////////////////////////////////////
8
+ export * from './resolvableElements/react/SectionChecker';
8
9
  export * from './resolvableElements/react/useResolverContext';
9
10
  export * from './resolvableElements/react/useResolveSection';
10
11
  //////////////////////////////////////////////////////////////////////////
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,OAAO,EACN,aAAa,GAGb,MAAM,0DAA0D,CAAA;AAEjE,0EAA0E;AAC1E,QAAQ;AACR,0EAA0E;AAC1E,cAAc,+CAA+C,CAAA;AAC7D,cAAc,8CAA8C,CAAA;AAC5D,0EAA0E;AAC1E,QAAQ;AACR,0EAA0E;AAC1E,cAAc,kBAAkB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,OAAO,EACN,aAAa,GAGb,MAAM,0DAA0D,CAAA;AAEjE,0EAA0E;AAC1E,QAAQ;AACR,0EAA0E;AAC1E,cAAc,2CAA2C,CAAA;AACzD,cAAc,+CAA+C,CAAA;AAC7D,cAAc,8CAA8C,CAAA;AAC5D,0EAA0E;AAC1E,QAAQ;AACR,0EAA0E;AAC1E,cAAc,kBAAkB,CAAA"}
@@ -6,9 +6,15 @@ import { UiElementConstructorData, UiElementData } from '../UiElement';
6
6
  */
7
7
  export declare class ResolvableExprElement<T extends UiElementData> extends ResolvableValueElement<T> {
8
8
  #private;
9
+ static collectionTypes: Set<string>;
9
10
  constructor(data: UiElementConstructorData<T>);
10
11
  refreshes: number;
11
12
  protected doInitialize: (parameters: HDict) => Promise<void>;
13
+ /**
14
+ * Checks whether the declared resolvedType of this element is a collection.
15
+ * @returns true if the resolvedType is a collection.
16
+ */
17
+ isExpectedResultACollection: () => boolean;
12
18
  protected doClose: () => Promise<void>;
13
19
  getParameterList: () => string[];
14
20
  }
@@ -9,6 +9,7 @@ import { ResolvableValueElement } from '../ResolvableValueElement';
9
9
  * Resolves to the result of an expression.
10
10
  */
11
11
  export class ResolvableExprElement extends ResolvableValueElement {
12
+ static collectionTypes = new Set(['HGrid', 'HList']);
12
13
  constructor(data) {
13
14
  super(data);
14
15
  }
@@ -26,7 +27,10 @@ export class ResolvableExprElement extends ResolvableValueElement {
26
27
  return;
27
28
  }
28
29
  const val = grid[0]?.get('val');
29
- if (val) {
30
+ // Identify when it's necessary to unpack the result `val` or not
31
+ // since the eval wraps the result value in a grid's first dict `val` tag for non-collections.
32
+ const shouldUnpackResult = !this.isExpectedResultACollection() && val;
33
+ if (shouldUnpackResult) {
30
34
  this.value = val;
31
35
  }
32
36
  else {
@@ -39,6 +43,15 @@ export class ResolvableExprElement extends ResolvableValueElement {
39
43
  }, HNum.make(refreshAfter, second).convertTo(millisecond).value);
40
44
  }
41
45
  };
46
+ /**
47
+ * Checks whether the declared resolvedType of this element is a collection.
48
+ * @returns true if the resolvedType is a collection.
49
+ */
50
+ isExpectedResultACollection = () => {
51
+ const { resolvedType } = this._meta;
52
+ return (ResolvableExprElement.collectionTypes.has(resolvedType) ||
53
+ resolvedType.endsWith('[]'));
54
+ };
42
55
  doClose = async () => {
43
56
  if (this.#timeout) {
44
57
  clearTimeout(this.#timeout);
@@ -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,EACN,wBAAwB,EACxB,yBAAyB,GACzB,MAAM,kCAAkC,CAAA;AAEzC,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAA;AAIlE;;GAEG;AACH,MAAM,OAAO,qBAEX,SAAQ,sBAAyB;IAClC,YAAY,IAAiC;QAC5C,KAAK,CAAC,IAAI,CAAC,CAAA;IACZ,CAAC;IAED,SAAS,GAAG,CAAC,CAAA;IACb,QAAQ,CAAS;IAEP,YAAY,GAAG,KAAK,EAAE,UAAiB,EAAiB,EAAE;QACnE,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,CAAA;IAC9B,CAAC,CAAA;IAED,YAAY,GAAG,KAAK,EAAE,UAAiB,EAAiB,EAAE;QACzD,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,GAAG,IAAI,CAAC,KAAkC,CAAA;QAEtE,MAAM,kBAAkB,GAAG,yBAAyB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAA;QAEtE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAA;QAEzD,IAAI,IAAI,CAAC,OAAO,EAAE,EAAE;YACnB,OAAO,CAAC,KAAK,CACZ,sCAAsC,EACtC,kBAAkB,EAClB,IAAI,CAAC,QAAQ,EAAE,CACf,CAAA;YACD,OAAM;SACN;QAED,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,KAAK,CAAC,CAAA;QAE/B,IAAI,GAAG,EAAE;YACR,IAAI,CAAC,KAAK,GAAG,GAAG,CAAA;SAChB;aAAM;YACN,IAAI,CAAC,KAAK,GAAG,IAAI,CAAA;SACjB;QAED,IAAI,YAAY,EAAE;YACjB,IAAI,CAAC,QAAQ,GAAG,UAAU,CAAC,GAAG,EAAE;gBAC/B,IAAI,CAAC,SAAS,EAAE,CAAA;gBAChB,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,CAAA;YAC9B,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,KAAK,CAAsB,CAAA;SACrF;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;CACD"}
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,EACN,wBAAwB,EAC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,IAAI,YAAY,EAAE;YACjB,IAAI,CAAC,QAAQ,GAAG,UAAU,CAAC,GAAG,EAAE;gBAC/B,IAAI,CAAC,SAAS,EAAE,CAAA;gBAChB,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,CAAA;YAC9B,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,KAAK,CAAsB,CAAA;SACrF;IACF,CAAC,CAAA;IAED;;;OAGG;IACH,2BAA2B,GAAG,GAAY,EAAE;QAC3C,MAAM,EAAE,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,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"}
@@ -0,0 +1,24 @@
1
+ import React from 'react';
2
+ import { UiElementData } from 'resolvableElements/elements/UiElement';
3
+ /**
4
+ * An utility type that allows a component to accept props with or without a 'section' property.
5
+ */
6
+ export declare type OptionalSection<P> = P | (Omit<P, 'section'> & {
7
+ section?: undefined;
8
+ });
9
+ /**
10
+ * Higher-Order Component that takes a section based component as an argument and returns a new component
11
+ * that checks if the 'section' prop is defined before rendering the SectionComponent.
12
+ * If the 'section' prop is undefined, it returns an empty element.
13
+ *
14
+ * @template P - Props of the original SectionComponent
15
+ * @param {React.FC<P>} SectionComponent - The original component that will be wrapped
16
+ * @returns {React.FC<P | (Omit<P, 'section'> & { section?: undefined })>} - The wrapped component
17
+ * @example
18
+ * const CheckedComponent = SectionChecker(({section, ...props}) => {
19
+ * return <div>{section.title}</div>
20
+ * })
21
+ */
22
+ export declare const SectionChecker: <P extends {
23
+ section: UiElementData;
24
+ }>(SectionComponent: React.FC<P>) => (props: OptionalSection<P>) => JSX.Element;
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+ /**
3
+ * Higher-Order Component that takes a section based component as an argument and returns a new component
4
+ * that checks if the 'section' prop is defined before rendering the SectionComponent.
5
+ * If the 'section' prop is undefined, it returns an empty element.
6
+ *
7
+ * @template P - Props of the original SectionComponent
8
+ * @param {React.FC<P>} SectionComponent - The original component that will be wrapped
9
+ * @returns {React.FC<P | (Omit<P, 'section'> & { section?: undefined })>} - The wrapped component
10
+ * @example
11
+ * const CheckedComponent = SectionChecker(({section, ...props}) => {
12
+ * return <div>{section.title}</div>
13
+ * })
14
+ */
15
+ export const SectionChecker = (SectionComponent) => {
16
+ const CheckedSectionComponent = (props) => {
17
+ return !props.section ? <></> : <SectionComponent {...props}/>;
18
+ };
19
+ return CheckedSectionComponent;
20
+ };
21
+ //# sourceMappingURL=SectionChecker.jsx.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SectionChecker.jsx","sourceRoot":"","sources":["../../../src/resolvableElements/react/SectionChecker.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAUzB;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAC7B,gBAA6B,EAC5B,EAAE;IACH,MAAM,uBAAuB,GAAG,CAAC,KAAyB,EAAE,EAAE;QAC7D,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,IAAI,KAAK,CAAC,EAAG,CAAA;IAChE,CAAC,CAAA;IAED,OAAO,uBAAuB,CAAA;AAC/B,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@j2inn/resolvable-ui-elements",
3
- "version": "0.0.2-beta.5",
3
+ "version": "0.0.3",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",