corvée(dépendances) ajoute Carbon Fields
This commit is contained in:
parent
135cc65eed
commit
62368587e5
459 changed files with 72750 additions and 26 deletions
29
web/vendor/htmlburger/carbon-fields/packages/blocks/store/actions.js
vendored
Normal file
29
web/vendor/htmlburger/carbon-fields/packages/blocks/store/actions.js
vendored
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/**
|
||||
* Returns an action object used to setup the definitions state when first opening an editor.
|
||||
*
|
||||
* @param {Object} definitions
|
||||
* @return {Object}
|
||||
*/
|
||||
export function setupContainerDefinitions( definitions ) {
|
||||
return {
|
||||
type: 'SETUP_CONTAINER_DEFINITIONS',
|
||||
payload: {
|
||||
definitions
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an action object used to setup the definitions state when first opening an editor.
|
||||
*
|
||||
* @param {Object} definitions
|
||||
* @return {Object}
|
||||
*/
|
||||
export function setupFieldDefinitions( definitions ) {
|
||||
return {
|
||||
type: 'SETUP_FIELD_DEFINITIONS',
|
||||
payload: {
|
||||
definitions
|
||||
}
|
||||
};
|
||||
}
|
||||
20
web/vendor/htmlburger/carbon-fields/packages/blocks/store/index.js
vendored
Normal file
20
web/vendor/htmlburger/carbon-fields/packages/blocks/store/index.js
vendored
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
/**
|
||||
* External dependencies.
|
||||
*/
|
||||
import { registerStore } from '@wordpress/data';
|
||||
|
||||
/**
|
||||
* Internal dependencies.
|
||||
*/
|
||||
import reducer from './reducer';
|
||||
import * as actions from './actions';
|
||||
import * as selectors from './selectors';
|
||||
|
||||
/**
|
||||
* Register the store.
|
||||
*/
|
||||
registerStore( 'carbon-fields/blocks', {
|
||||
reducer,
|
||||
actions,
|
||||
selectors
|
||||
} );
|
||||
43
web/vendor/htmlburger/carbon-fields/packages/blocks/store/reducer.js
vendored
Normal file
43
web/vendor/htmlburger/carbon-fields/packages/blocks/store/reducer.js
vendored
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
/**
|
||||
* External dependencies.
|
||||
*/
|
||||
import { combineReducers } from '@wordpress/data';
|
||||
|
||||
/**
|
||||
* The reducer that keeps track of container definitions keyed by block's name.
|
||||
*
|
||||
* @param {Object} state
|
||||
* @param {Object} action
|
||||
* @return {Object}
|
||||
*/
|
||||
export function containerDefinitionsByBlockName( state = {}, action ) {
|
||||
switch ( action.type ) {
|
||||
case 'SETUP_CONTAINER_DEFINITIONS':
|
||||
return action.payload.definitions;
|
||||
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The reducer that keeps track of field definitions keyed by block's name.
|
||||
*
|
||||
* @param {Object} state
|
||||
* @param {Object} action
|
||||
* @return {Object}
|
||||
*/
|
||||
export function fieldDefinitionsByBlockName( state = {}, action ) {
|
||||
switch ( action.type ) {
|
||||
case 'SETUP_FIELD_DEFINITIONS':
|
||||
return action.payload.definitions;
|
||||
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
export default combineReducers( {
|
||||
containerDefinitionsByBlockName,
|
||||
fieldDefinitionsByBlockName
|
||||
} );
|
||||
25
web/vendor/htmlburger/carbon-fields/packages/blocks/store/selectors.js
vendored
Normal file
25
web/vendor/htmlburger/carbon-fields/packages/blocks/store/selectors.js
vendored
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
/**
|
||||
* Get the container by a given block name.
|
||||
*
|
||||
* @param {Object} state
|
||||
* @param {string} blockName
|
||||
* @return {Object}
|
||||
*/
|
||||
export function getContainerDefinitionByBlockName( state, blockName ) {
|
||||
return state.containerDefinitionsByBlockName[
|
||||
blockName.replace( 'carbon-fields/', '' )
|
||||
] || {};
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the fields by a given block name.
|
||||
*
|
||||
* @param {Object} state
|
||||
* @param {string} blockName
|
||||
* @return {Object[]}
|
||||
*/
|
||||
export function getFieldDefinitionsByBlockName( state, blockName ) {
|
||||
return state.fieldDefinitionsByBlockName[
|
||||
blockName.replace( 'carbon-fields/', '' )
|
||||
] || [];
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue