PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.1.6
JetFormBuilder — Dynamic Blocks Form Builder v3.1.6
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 / assets / src / editor / blocks / form-fields.js
jetformbuilder / assets / src / editor / blocks Last commit date
calculated-field 2 years ago checkbox-field 2 years ago color-picker-field 2 years ago conditional-block 2 years ago controls 2 years ago date-field 2 years ago datetime-field 2 years ago form-break-field 2 years ago form-break-start 2 years ago group-break-field 2 years ago heading-field 2 years ago hidden-field 2 years ago media-field 2 years ago number-field 2 years ago progress-bar 2 years ago radio-field 2 years ago range-field 2 years ago repeater-field 2 years ago select-field 2 years ago submit-field 2 years ago text-field 2 years ago textarea-field 2 years ago time-field 2 years ago wysiwyg-field 2 years ago base-block.json 2 years ago block-wrappers.js 2 years ago form-fields.js 2 years ago help-messages-config.js 2 years ago select-radio-chekc-options.js 2 years ago
form-fields.js
137 lines
1 import * as calculated from './calculated-field';
2 import * as checkbox from './checkbox-field';
3 import * as conditional from './conditional-block';
4 import * as date from './date-field';
5 import * as datetime from './datetime-field';
6 import * as formBreak from './form-break-field';
7 import * as groupBreak from './group-break-field';
8 import * as heading from './heading-field';
9 import * as hidden from './hidden-field';
10 import * as media from './media-field';
11 import * as number from './number-field';
12 import * as radio from './radio-field';
13 import * as range from './range-field';
14 import * as repeater from './repeater-field';
15 import * as select from './select-field';
16 import * as submit from './submit-field';
17 import * as text from './text-field';
18 import * as textarea from './textarea-field';
19 import * as time from './time-field';
20 import * as wysiwyg from './wysiwyg-field';
21 import * as colorPicker from './color-picker-field';
22 import * as progressBar from './progress-bar';
23 import * as formBreakStart from './form-break-start';
24 import * as wrappers from './block-wrappers';
25
26 const {
27 registerBlockType,
28 } = wp.blocks;
29
30 const {
31 applyFilters,
32 } = wp.hooks;
33
34 const fields = applyFilters( 'jet.fb.register.fields', [
35 calculated,
36 checkbox,
37 conditional,
38 datetime,
39 date,
40 formBreak,
41 groupBreak,
42 heading,
43 hidden,
44 media,
45 number,
46 radio,
47 range,
48 repeater,
49 select,
50 submit,
51 text,
52 textarea,
53 time,
54 wysiwyg,
55 colorPicker,
56 progressBar,
57 formBreakStart,
58 ] );
59
60 const registerFormField = block => {
61 if ( !block ) {
62 return;
63 }
64 const { metadata, settings, name } = block;
65
66 settings.edit = wrappers.withCustomProps( block );
67
68 /**
69 * @since 3.0.0
70 */
71 if ( !settings.hasOwnProperty( 'jfbGetFields' ) ) {
72 settings.jfbGetFields = function ( context = 'default' ) {
73 if ( !this.attributes?.name ) {
74 return [];
75 }
76
77 return [
78 {
79 name: this.attributes.name,
80 label: this.attributes.label || this.attributes.name,
81 value: this.attributes.name,
82 },
83 ];
84 };
85 }
86
87 if (
88 !settings.hasOwnProperty( '__experimentalLabel' ) &&
89 metadata.attributes.hasOwnProperty( 'name' )
90 ) {
91 /**
92 * @param attributes
93 * @param context {{|'accessibility'|'visual'|'list-view'}}
94 * @returns {*}
95 * @private
96 */
97 settings.__experimentalLabel = ( attributes, { context } ) => {
98 switch ( context ) {
99 case 'list-view':
100 return attributes.name || metadata.title;
101 case 'accessibility':
102 return !!attributes.name?.length
103 ? `${ metadata.title } (${ attributes.name })`
104 : metadata.title;
105 default:
106 return metadata.title;
107 }
108 };
109 }
110
111 registerBlockType( name, {
112 ...metadata,
113 ...settings,
114 } );
115 };
116
117 function sortBlocks( first, next ) {
118 let { metadata: { title: a } } = first;
119 let { metadata: { title: b } } = next;
120
121 a = a ? a : first.settings?.title;
122 b = b ? b : next.settings?.title;
123
124 try {
125 return a.localeCompare( b );
126 }
127 catch ( e ) {
128 return 0;
129 }
130 }
131
132 export default function RegisterFormFields( blocks = fields ) {
133 blocks.sort( sortBlocks );
134 blocks.forEach(
135 applyFilters( 'jet.fb.register.fields.handler', registerFormField ) );
136 }
137