## Index

### Modules

- __global

### Variables

- ARGUMENT_NAMES
- STRIP_COMMENTS

### Functions

- boundArgsReducer
- getChildrenComponents
- getComponentProps
- getComputedProps
- getEvalProps
- getFunctionFromProps
- getFunctionProps
- getJSONXProps
- getParamNames
- getReactComponentProps
- getReactComponents
- getWindowComponents

## Variables

### Const ARGUMENT_NAMES

ARGUMENT_NAMES: RegExp = /([^\s,]+)/g

- Defined in props.ts:28

### Const STRIP_COMMENTS

STRIP_COMMENTS: RegExp = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/gm

- Defined in props.ts:27

## Functions

### boundArgsReducer

- boundArgsReducer(this: Context, jsonx?: jsonx): (Anonymous function)

- - Defined in props.ts:165

  #### Parameters

  - ##### this: Context

  - ##### Default value jsonx: jsonx = {}

  #### Returns (Anonymous function)

### getChildrenComponents

- getChildrenComponents(this: Context, options?: { allProps?: any; jsonx?: defs.jsonx }): { children: string } | { children: undefined } | { _children: any }

- - Defined in props.ts:136

  returns children jsonx components defined on spreadComponent spread over an array on props.spread

  #### Parameters

  - ##### this: Context

  - ##### Default value options: { allProps?: any; jsonx?: defs.jsonx } = {}

    - ##### Optional allProps?: any

    - ##### Optional jsonx?: defs.jsonx

  #### Returns { children: string } | { children: undefined } | { _children: any }

### getComponentProps

- getComponentProps(this: Context, options?: defs.Config): jsonxResourceProps

- - Defined in props.ts:300

  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

  - ##### this: Context

  - ##### Default value options: defs.Config = { jsonx: {} }

  #### Returns jsonxResourceProps

  resolved object of React Components

### getComputedProps

- getComputedProps(this: Context, options?: { componentLibraries?: defs.jsonxLibrary; debug?: undefined | false | true; disableRenderIndexKey?: undefined | false | true; ignoreReduxPropsInComponentLibraries?: undefined | false | true; jsonx?: defs.jsonx; logError?: any; renderIndex?: undefined | number; resources?: defs.jsonxResourceProps; useReduxState?: undefined | false | true }): any

- - Defined in props.ts:679

  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

  - ##### this: Context

  - ##### Default value options: { componentLibraries?: defs.jsonxLibrary; debug?: undefined | false | true; disableRenderIndexKey?: undefined | false | true; ignoreReduxPropsInComponentLibraries?: undefined | false | true; jsonx?: defs.jsonx; logError?: any; renderIndex?: undefined | number; resources?: defs.jsonxResourceProps; useReduxState?: undefined | false | true } = {}

    - ##### Optional componentLibraries?: defs.jsonxLibrary

    - ##### Optional debug?: undefined | false | true

    - ##### Optional disableRenderIndexKey?: undefined | false | true

    - ##### Optional ignoreReduxPropsInComponentLibraries?: undefined | false | true

    - ##### Optional jsonx?: defs.jsonx

      Valid JSONX JSON

    - ##### Optional logError?: any

    - ##### Optional renderIndex?: undefined | number

      number used for React key prop

    - ##### Optional resources?: defs.jsonxResourceProps

    - ##### Optional useReduxState?: undefined | false | true

  #### Returns any

### getEvalProps

- getEvalProps(this: Context, options?: { jsonx: jsonx }): {}

- - Defined in props.ts:201

  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

  - ##### this: Context

  - ##### Default value options: { jsonx: jsonx } = { jsonx: {} }

    - ##### jsonx: jsonx

      Valid JSONX JSON

  #### Returns {}

  returns resolved object with evaluated javascript

### getFunctionFromProps

- getFunctionFromProps(this: Context, options?: { functionProperty?: undefined | string; jsonx: jsonx; propBody: string; propFunc?: undefined | string }): any

- - Defined in props.ts:454

  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

  - ##### this: Context

  - ##### Default value options: { functionProperty?: undefined | string; jsonx: jsonx; propBody: string; propFunc?: undefined | string } = { jsonx: {}, propBody: "" }

    - ##### Optional functionProperty?: undefined | string

    - ##### jsonx: jsonx

    - ##### propBody: string

    - ##### Optional propFunc?: undefined | string

  #### Returns any

  returns a function from this.props or window functions

### getFunctionProps

- getFunctionProps(this: Context, options?: { allProps?: any; jsonx: jsonx }): any

- - Defined in props.ts:561

  Returns a resolved object from function strings that has functions pulled from jsonx.__functionProps

  #### Parameters

  - ##### this: Context

  - ##### Default value options: { allProps?: any; jsonx: jsonx } = { jsonx: {} }

    - ##### Optional allProps?: any

    - ##### jsonx: jsonx

      Valid JSONX JSON

  #### Returns any

  resolved object of functions from function strings

### getJSONXProps

- getJSONXProps(options?: defs.dynamicFunctionParams): jsonxResourceProps

- - Defined in props.ts:121

  It uses traverse on a traverseObject to returns a resolved object on propName. So if you're making an ajax call and want to pass properties into a component, you can assign them using asyncprops and reference object properties by an array of property paths

  example

    const traverseObject = { user: { name: 'jsonx', description: 'react withouth javascript', }, stats: { logins: 102, comments: 3, }, authentication: 'OAuth2', }; const testJSONX = { component: 'div', props: { id: 'generatedJSONX', className:'jsonx', }, asyncprops:{ auth: [ 'authentication', ], username: [ 'user', 'name', ], }, children: [ { component: 'p', props: { style: { color: 'red', fontWeight:'bold', }, }, children:'hello world', }, ], }; const JSONXP = getJSONXProps({ jsonx: testJSONX, traverseObject, }); // => { // auth: 'OAuth2', // username: 'jsonx' // }

    //finally resolves: const testJSONX = { component: 'div', props: { id: 'generatedJSONX', className:'jsonx', auth: 'OAuth2', username: 'jsonx', }, children: [ { component: 'p', props: { style: { color: 'red', fontWeight:'bold', }, }, children:'hello world', }, ], };

  #### Parameters

  - ##### Default value options: defs.dynamicFunctionParams = {}

  #### Returns jsonxResourceProps

  resolved object

### getParamNames

- getParamNames(func: defs.functionParam): RegExpMatchArray

- - Defined in props.ts:39

  returns the names of parameters from a function declaration

  example

    const arrowFunctionAdd = (a,b)=>a+b; function regularFunctionAdd(c,d){return c+d;} getParamNames(arrowFunctionAdd) // => ['a','b'] getParamNames(regularFunctionAdd) // => ['c','d']

  todo

    write tests

  #### Parameters

  - ##### func: defs.functionParam

  #### Returns RegExpMatchArray

### getReactComponentProps

- getReactComponentProps(this: Context, options?: { jsonx: jsonx }): jsonxResourceProps

- - Defined in props.ts:387

  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

  - ##### this: Context

  - ##### Default value options: { jsonx: jsonx } = { jsonx: {} }

    - ##### jsonx: jsonx

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

  #### Returns jsonxResourceProps

  resolved object of React Components

### getReactComponents

- getReactComponents(this: Context, options: defs.Config): jsonxResourceProps

- - Defined in props.ts:328

  #### Parameters

  - ##### this: Context

  - ##### options: defs.Config

  #### Returns jsonxResourceProps

### getWindowComponents

- getWindowComponents(this: Context, options?: { allProps?: any; jsonx: jsonx }): any

- - Defined in props.ts:594

  Returns a resolved object that has React Components pulled from window.__jsonx_custom_elements

  #### Parameters

  - ##### this: Context

  - ##### Default value options: { allProps?: any; jsonx: jsonx } = { jsonx: {} }

    - ##### Optional allProps?: any

    - ##### jsonx: jsonx

      Valid JSONX JSON

  #### Returns any

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