PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.6.4.1
JetFormBuilder — Dynamic Blocks Form Builder v3.6.4.1
3.6.4.1 3.6.4 3.6.3.1 3.6.3 3.6.2.2 3.6.2.1 3.6.2 3.6.1.1 3.6.1 3.6.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.1.0 2.1.1 2.1.10 2.1.11 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 3.0.0 3.0.0.1 3.0.0.2 3.0.0.3 3.0.1 3.0.1.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.0.1 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.3.2 3.3.3 3.3.3.1 3.3.4 3.3.4.1 3.3.4.2 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.5.1 3.4.5.2 3.4.6 3.4.7 3.4.7.1 3.5.0 3.5.1 3.5.1.1 3.5.1.2 3.5.2 3.5.2.1 3.5.3 3.5.4 3.5.5 3.5.6 3.5.6.1 3.5.6.2 3.5.6.3 3.6.0
jetformbuilder / modules / framework / blocks-style-manager / assets / src / helpers / utils.js
jetformbuilder / modules / framework / blocks-style-manager / assets / src / helpers Last commit date
breakpoints.js 2 months ago color-palette.js 2 months ago conditions-checker.js 2 months ago utils.js 2 months ago
utils.js
82 lines
1 /**
2 * Get all block controls for given block
3 *
4 * @param {string} blockName
5 * @returns {object} blockControls
6 */
7 export const getBlockControls = ( blockName ) => {
8
9 const blockControls = window.crocoBlockStyleEditor.getBlockControls( blockName );
10
11 if ( ! blockControls ) {
12 return {};
13 }
14
15 return blockControls;
16 }
17
18 /**
19 * Check if given stack has children
20 *
21 * @param {object} stack
22 * @returns {boolean}
23 */
24 export const hasChildren = ( stack ) => {
25 if ( ! stack.children ) {
26 return false;
27 }
28
29 if ( Array.isArray( stack.children ) && stack.children.length > 0 ) {
30 return true;
31 }
32
33 // Otherwise, return false
34 return false;
35 }
36
37 /**
38 * Check if given variable is an object
39 *
40 * @param {any} variable
41 * @returns {boolean}
42 */
43 export const isObject = ( variable ) => {
44 return typeof variable === 'object' && variable !== null && !Array.isArray(variable);
45 }
46
47 export const isEmpty = ( variable ) => {
48
49 if ( variable === null || variable === undefined ) {
50 return true;
51 }
52
53 if ( typeof variable === 'string' && variable.trim() === '' ) {
54 return true;
55 }
56
57 if ( Array.isArray( variable ) && variable.length === 0 ) {
58 return true;
59 }
60
61 if ( isObject( variable ) && Object.keys( variable ).length === 0 ) {
62 return true;
63 }
64
65 return false;
66 }
67
68 export const valueIsEmpty = ( value ) => {
69
70 if ( isEmpty( value ) ) {
71 return true;
72 }
73
74 if ( isObject( value ) && Object.keys( value ).length > 0 ) {
75 if ( Object.values( value ).every( ( v ) => isEmpty( v ) ) ) {
76 return true;
77 }
78 }
79
80 return false;
81 }
82