-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from pedro-lb/30-pass-label-from-schema-to-the…
…-custom-input-props 30 pass label from schema to the custom input props
- Loading branch information
Showing
12 changed files
with
184 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,10 @@ | ||
language: node_js | ||
|
||
node_js: | ||
- 9 | ||
- 8 | ||
- 12 | ||
|
||
before_install: | ||
- cd packages/core | ||
|
||
script: | ||
- yarn build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { FormupYupSchema } from '../interfaces'; | ||
import getSchemaField from './getSchemaField'; | ||
|
||
/** | ||
* If defined, extracts the field label from the schema. | ||
* @param name The field name | ||
* @param schema The schema | ||
*/ | ||
const getFieldLabel = ( | ||
name: string, | ||
schema: FormupYupSchema, | ||
) => { | ||
const schemaField = getSchemaField(name, schema); | ||
|
||
return schemaField?.['_label']; | ||
}; | ||
|
||
export default getFieldLabel; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import get from 'lodash.get'; | ||
|
||
import { FormupYupSchema } from '../interfaces'; | ||
|
||
/** | ||
* Recursively gets one schema field according to its name. | ||
* @param name The field name | ||
* @param schema The schema | ||
*/ | ||
const getSchemaField = ( | ||
name: string, | ||
schema: FormupYupSchema, | ||
) => { | ||
const fieldPath = String(name || '') | ||
.split('.') | ||
.reduce((prev, curr) => `${prev}.fields.${curr}`); | ||
|
||
const schemaField = get(schema?.fields || {}, fieldPath); | ||
|
||
return schemaField; | ||
}; | ||
|
||
export default getSchemaField; |
Oops, something went wrong.