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
46
web/vendor/htmlburger/carbon-fields/packages/metaboxes/utils/flatten-field.js
vendored
Normal file
46
web/vendor/htmlburger/carbon-fields/packages/metaboxes/utils/flatten-field.js
vendored
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
/**
|
||||
* External dependencies.
|
||||
*/
|
||||
import { pick, cloneDeep } from 'lodash';
|
||||
|
||||
/**
|
||||
* Carbon Fields dependencies.
|
||||
*/
|
||||
import { uniqueId } from '@carbon-fields/core';
|
||||
|
||||
/**
|
||||
* Flattens a field.
|
||||
*
|
||||
* @param {Object} field
|
||||
* @param {string} containerId
|
||||
* @param {Object[]} accumulator
|
||||
* @return {Object}
|
||||
*/
|
||||
export default function flattenField( field, containerId, accumulator ) {
|
||||
field = cloneDeep( field );
|
||||
|
||||
// Replace the id of the field.
|
||||
field.id = uniqueId();
|
||||
|
||||
// Keep reference to the container.
|
||||
field.container_id = containerId;
|
||||
|
||||
// The complex fields represent a nested structure of fields.
|
||||
// So we need to flat them as well.
|
||||
if ( field.type === 'complex' ) {
|
||||
field.value.forEach( ( group ) => {
|
||||
group.id = uniqueId();
|
||||
group.container_id = containerId;
|
||||
group.fields = group.fields.map( ( groupField ) => flattenField( groupField, containerId, accumulator ) );
|
||||
} );
|
||||
}
|
||||
|
||||
accumulator.push( field );
|
||||
|
||||
return pick( field, [
|
||||
'id',
|
||||
'type',
|
||||
'name',
|
||||
'base_name'
|
||||
] );
|
||||
}
|
||||
23
web/vendor/htmlburger/carbon-fields/packages/metaboxes/utils/from-event-pattern.js
vendored
Normal file
23
web/vendor/htmlburger/carbon-fields/packages/metaboxes/utils/from-event-pattern.js
vendored
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
/**
|
||||
* External dependencies.
|
||||
*/
|
||||
import create from 'callbag-create';
|
||||
|
||||
/**
|
||||
* Callbag source factory from `addHandler` and `removeHandler` pair.
|
||||
*
|
||||
* @see https://github.com/Andarist/callbag-from-event-pattern
|
||||
* @param {Function} addHandler
|
||||
* @param {Function} removeHandler
|
||||
* @param {Function} argsTransformer
|
||||
* @return {Function}
|
||||
*/
|
||||
export default function fromEventPattern( addHandler, removeHandler, argsTransformer = ( ...args ) => args ) {
|
||||
return create( ( sink ) => {
|
||||
const handler = ( ...args ) => sink( 1, argsTransformer( ...args ) );
|
||||
|
||||
addHandler( handler );
|
||||
|
||||
return () => removeHandler( handler );
|
||||
} );
|
||||
}
|
||||
13
web/vendor/htmlburger/carbon-fields/packages/metaboxes/utils/is-gutenberg.js
vendored
Normal file
13
web/vendor/htmlburger/carbon-fields/packages/metaboxes/utils/is-gutenberg.js
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/**
|
||||
* External dependencies.
|
||||
*/
|
||||
import { isUndefined } from 'lodash';
|
||||
|
||||
/**
|
||||
* Returns true if Gutenberg is presented.
|
||||
*
|
||||
* @return {boolean}
|
||||
*/
|
||||
export default function isGutenberg() {
|
||||
return ! isUndefined( window._wpLoadBlockEditor );
|
||||
}
|
||||
15
web/vendor/htmlburger/carbon-fields/packages/metaboxes/utils/strip-compact-input-prefix.js
vendored
Normal file
15
web/vendor/htmlburger/carbon-fields/packages/metaboxes/utils/strip-compact-input-prefix.js
vendored
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
/**
|
||||
* Removes the prefix used to compact the input of Carbon Fields.
|
||||
*
|
||||
* @param {string} str
|
||||
* @return {string}
|
||||
*/
|
||||
export default function stripCompactInputPrefix( str ) {
|
||||
const { compactInput, compactInputKey } = window.cf.config;
|
||||
|
||||
if ( ! compactInput || str.indexOf( compactInputKey ) !== 0 ) {
|
||||
return str;
|
||||
}
|
||||
|
||||
return str.replace( new RegExp( `^${ compactInputKey }\\[(.+?)\\]` ), '$1' );
|
||||
}
|
||||
16
web/vendor/htmlburger/carbon-fields/packages/metaboxes/utils/urldecode.js
vendored
Normal file
16
web/vendor/htmlburger/carbon-fields/packages/metaboxes/utils/urldecode.js
vendored
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
/**
|
||||
* Source: https://github.com/kvz/locutus/blob/master/src/php/url/urldecode.js
|
||||
*
|
||||
* @param {string} str
|
||||
* @return {string}
|
||||
*/
|
||||
export default function urldecode( str ) {
|
||||
return decodeURIComponent( ( str + '' )
|
||||
.replace( /%(?![\da-f]{2})/gi, function() {
|
||||
// PHP tolerates poorly formed escape sequences
|
||||
return '%25';
|
||||
} )
|
||||
|
||||
.replace( /\+/g, '%20' )
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue