Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "types/jsonx/props"

Index

Type aliases

dynamicComponentProps

dynamicComponentProps: { cacheTimeout?: undefined | number; cacheTimeoutFunction?: functionParam; fetchFunction?: functionParam; fetchOptions?: any; fetchURL?: undefined | string; jsonx?: jsonx; loadingErrorJSONX?: jsonx; loadingJSONX?: jsonx; propName?: undefined | string; transformFunction?: functionParam; traverseObject?: any; useCache?: undefined | false | true }

Type declaration

  • Optional cacheTimeout?: undefined | number
  • Optional cacheTimeoutFunction?: functionParam
  • Optional fetchFunction?: functionParam
  • Optional fetchOptions?: any
  • Optional fetchURL?: undefined | string
  • Optional jsonx?: jsonx
  • Optional loadingErrorJSONX?: jsonx
  • Optional loadingJSONX?: jsonx
  • Optional propName?: undefined | string
  • Optional transformFunction?: functionParam
  • Optional traverseObject?: any
  • Optional useCache?: undefined | false | true

dynamicFunctionParams

dynamicFunctionParams: { jsonx?: jsonx; propName?: undefined | string; traverseObject?: any }

Type declaration

  • Optional jsonx?: jsonx
  • Optional propName?: undefined | string
  • Optional traverseObject?: any

formComponentProps

formComponentProps: { formComponent?: jsonx; formKey?: any; formWrapperComponent?: jsonx; hookFormOptions?: any; onSubmit?: functionParam }

Type declaration

  • Optional formComponent?: jsonx
  • Optional formKey?: any
  • Optional formWrapperComponent?: jsonx
  • Optional hookFormOptions?: any
  • Optional onSubmit?: functionParam

functionParam

functionParam: (...params: any[]) => any

Type declaration

    • (...params: any[]): any
    • Parameters

      • Rest ...params: any[]

      Returns any

Functions

getChildrenComponents

  • getChildrenComponents(options: any): void
  • returns children jsonx components defined on spreadComponent spread over an array on props.spread

    Parameters

    • options: any

    Returns void

getComponentProps

  • getComponentProps(options: { jsonx: any; resources?: any }): any
  • Resolves jsonx.__dangerouslyInsertComponents into an object that turns each value into a React components. This is typically used in a library like Recharts where you pass custom components for chart ticks or plot points.

    Parameters

    • options: { jsonx: any; resources?: any }
      • jsonx: any

        Valid JSONX JSON

      • Optional resources?: any

    Returns any

    resolved object of React Components

getComputedProps

  • getComputedProps(options: { componentLibraries?: any; debug?: undefined | false | true; ignoreReduxPropsInComponentLibraries?: undefined | false | true; jsonx: any; logError?: undefined | ((...params: any[]) => any); renderIndex: number; resources?: any; useReduxState?: undefined | false | true }): void
  • Returns computed properties for React Components and any property that's prefixed with __ is a computedProperty

    example

    const testJSONX = { component: 'div', props: { id: 'generatedJSONX', className: 'jsonx' }, children: [ [Object] ], asyncprops: { auth: [Array], username: [Array] }, __dangerouslyEvalProps: { getUsername: '(user={})=>user.name' }, __dangerouslyInsertComponents: { myComponent: [Object] } const resources = { user: { name: 'jsonx', description: 'react withouth javascript', }, stats: { logins: 102, comments: 3, }, authentication: 'OAuth2', }; const renderIndex = 1; getComputedProps.call({}, { jsonx: testJSONX, resources, renderIndex, }); computedProps = { key: 1, id: 'generatedJSONX', className: 'jsonx', auth: 'OAuth2', username: 'jsonx', getUsername: [Function], myComponent: { '$$typeof': Symbol(react.element), type: 'p', key: '8', ref: null, props: [Object], _owner: null, _store: {} } } }

    Parameters

    • options: { componentLibraries?: any; debug?: undefined | false | true; ignoreReduxPropsInComponentLibraries?: undefined | false | true; jsonx: any; logError?: undefined | ((...params: any[]) => any); renderIndex: number; resources?: any; useReduxState?: undefined | false | true }
      • Optional componentLibraries?: any
      • Optional debug?: undefined | false | true
      • Optional ignoreReduxPropsInComponentLibraries?: undefined | false | true
      • jsonx: any

        Valid JSONX JSON

      • Optional logError?: undefined | ((...params: any[]) => any)
      • renderIndex: number

        number used for React key prop

      • Optional resources?: any
      • Optional useReduxState?: undefined | false | true

    Returns void

getEvalProps

  • getEvalProps(options: { jsonx: any }): any
  • Used to evalute javascript and set those variables as props. getEvalProps evaluates __dangerouslyEvalProps and __dangerouslyBindEvalProps properties with eval, this is used when component properties are functions, __dangerouslyBindEvalProps is used when those functions require that this is bound to the function. For __dangerouslyBindEvalProps it must resolve an expression, so functions should be wrapped in (). I.e. (function f(x){ return this.minimum+x;})

    example

    const testVals = { auth: 'true', username: '(user={})=>user.name', }; const testJSONX = Object.assign({}, sampleJSONX, { __dangerouslyEvalProps: testVals, __dangerouslyBindEvalProps: { email: '(function getUser(user={}){ return this.testBound(); })', }, }); const JSONXP = getEvalProps.call({ testBound: () => 'bounded', }, { jsonx: testJSONX, }); const evalutedComputedFunc = JSONXP.username({ name: 'bob', }); const evalutedComputedBoundFunc = JSONXP.email({ email:'test@email.domain', }); // expect(JSONXP.auth).to.be.true; // expect(evalutedComputedFunc).to.eql('bob'); // expect(evalutedComputedBoundFunc).to.eql('bounded');

    Parameters

    • options: { jsonx: any }
      • jsonx: any

        Valid JSONX JSON

    Returns any

    returns resolved object with evaluated javascript

getFunctionFromProps

  • getFunctionFromProps(options: { allProps?: any; propFunc?: undefined | string }): (...params: any[]) => any
  • Takes a function string and returns a function on either this.props or window. The function can only be 2 levels deep

    example

    getFunctionFromProps({ propFunc='func:this.props.onClick', }) // => this.props.onClick

    Parameters

    • options: { allProps?: any; propFunc?: undefined | string }
      • Optional allProps?: any
      • Optional propFunc?: undefined | string

    Returns (...params: any[]) => any

    returns a function from this.props or window functions

      • (...params: any[]): any
      • Parameters

        • Rest ...params: any[]

        Returns any

getFunctionProps

  • getFunctionProps(options: { allProps?: any; jsonx: any }): any
  • Returns a resolved object from function strings that has functions pulled from jsonx.__functionProps

    Parameters

    • options: { allProps?: any; jsonx: any }
      • Optional allProps?: any
      • jsonx: any

        Valid JSONX JSON

    Returns any

    resolved object of functions from function strings

getReactComponentProps

  • getReactComponentProps(options: { jsonx: any }): any
  • Resolves jsonx.__dangerouslyInsertReactComponents into an object that turns each value into a React components. This is typically used in a library like Recharts where you pass custom components for chart ticks or plot points.

    Parameters

    • options: { jsonx: any }
      • jsonx: any

        Valid JSONX JSON // * @param {Object} [options.resources={}] - object to use for asyncprops, usually a result of an asynchronous call

    Returns any

    resolved object of React Components

getWindowComponents

  • getWindowComponents(options: { allProps?: any; jsonx: any }): any
  • Returns a resolved object that has React Components pulled from window.__jsonx_custom_elements

    Parameters

    • options: { allProps?: any; jsonx: any }
      • Optional allProps?: any
      • jsonx: any

        Valid JSONX JSON

    Returns any

    resolved object of with React Components from a window property window.__jsonx_custom_elements