@gravityforms/components 6.2.0 → 6.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,9 @@
1
1
  module.exports = [
2
+ {
3
+ "defaultExport": "Table",
4
+ "importPath": "html/admin/modules/",
5
+ "externalPath": "components.admin.html.modules"
6
+ },
2
7
  {
3
8
  "defaultExport": "Flyout",
4
9
  "namedExports": [
@@ -16,30 +21,25 @@ module.exports = [
16
21
  "externalPath": "components.admin.html.modules"
17
22
  },
18
23
  {
19
- "defaultExport": "Table",
20
- "importPath": "html/admin/modules/",
21
- "externalPath": "components.admin.html.modules"
22
- },
23
- {
24
- "defaultExport": "Textarea",
24
+ "defaultExport": "Toggle",
25
25
  "namedExports": [
26
- "textareaTemplate"
26
+ "toggleTemplate"
27
27
  ],
28
28
  "importPath": "html/admin/elements/",
29
29
  "externalPath": "components.admin.html.elements"
30
30
  },
31
31
  {
32
- "defaultExport": "Text",
32
+ "defaultExport": "Textarea",
33
33
  "namedExports": [
34
- "textTemplate"
34
+ "textareaTemplate"
35
35
  ],
36
36
  "importPath": "html/admin/elements/",
37
37
  "externalPath": "components.admin.html.elements"
38
38
  },
39
39
  {
40
- "defaultExport": "Toggle",
40
+ "defaultExport": "Text",
41
41
  "namedExports": [
42
- "toggleTemplate"
42
+ "textTemplate"
43
43
  ],
44
44
  "importPath": "html/admin/elements/",
45
45
  "externalPath": "components.admin.html.elements"
@@ -181,12 +181,12 @@ module.exports = [
181
181
  "externalPath": "components.admin.react.modules"
182
182
  },
183
183
  {
184
- "defaultExport": "Pagination",
184
+ "defaultExport": "Phone",
185
185
  "importPath": "react/admin/modules/",
186
186
  "externalPath": "components.admin.react.modules"
187
187
  },
188
188
  {
189
- "defaultExport": "Phone",
189
+ "defaultExport": "Pagination",
190
190
  "importPath": "react/admin/modules/",
191
191
  "externalPath": "components.admin.react.modules"
192
192
  },
@@ -255,6 +255,11 @@ module.exports = [
255
255
  "importPath": "react/admin/modules/",
256
256
  "externalPath": "components.admin.react.modules"
257
257
  },
258
+ {
259
+ "defaultExport": "DataGrid",
260
+ "importPath": "react/admin/modules/",
261
+ "externalPath": "components.admin.react.modules"
262
+ },
258
263
  {
259
264
  "defaultExport": "ColorPicker",
260
265
  "importPath": "react/admin/modules/",
@@ -295,11 +300,6 @@ module.exports = [
295
300
  "importPath": "react/admin/modules/",
296
301
  "externalPath": "components.admin.react.modules"
297
302
  },
298
- {
299
- "defaultExport": "DataGrid",
300
- "importPath": "react/admin/modules/",
301
- "externalPath": "components.admin.react.modules"
302
- },
303
303
  {
304
304
  "defaultExport": "Toggle",
305
305
  "importPath": "react/admin/elements/",
@@ -360,11 +360,6 @@ module.exports = [
360
360
  "importPath": "react/admin/elements/",
361
361
  "externalPath": "components.admin.react.elements"
362
362
  },
363
- {
364
- "defaultExport": "Input",
365
- "importPath": "react/admin/elements/",
366
- "externalPath": "components.admin.react.elements"
367
- },
368
363
  {
369
364
  "defaultExport": "Image",
370
365
  "importPath": "react/admin/elements/",
@@ -415,6 +410,11 @@ module.exports = [
415
410
  "importPath": "react/admin/elements/",
416
411
  "externalPath": "components.admin.react.elements"
417
412
  },
413
+ {
414
+ "defaultExport": "Input",
415
+ "importPath": "react/admin/elements/",
416
+ "externalPath": "components.admin.react.elements"
417
+ },
418
418
  {
419
419
  "defaultExport": "VidyardVideo",
420
420
  "importPath": "react/admin/modules/Videos/",
@@ -438,6 +438,16 @@ module.exports = [
438
438
  "importPath": "react/admin/modules/Loaders/",
439
439
  "externalPath": "components.admin.react.modules"
440
440
  },
441
+ {
442
+ "defaultExport": "RightSidebar",
443
+ "importPath": "react/admin/modules/Layouts/",
444
+ "externalPath": "components.admin.react.modules"
445
+ },
446
+ {
447
+ "defaultExport": "ModularSidebar",
448
+ "importPath": "react/admin/modules/Layouts/",
449
+ "externalPath": "components.admin.react.modules"
450
+ },
441
451
  {
442
452
  "defaultExport": "IconIndicator",
443
453
  "importPath": "react/admin/modules/Indicators/",
@@ -473,16 +483,6 @@ module.exports = [
473
483
  "importPath": "react/admin/modules/Cards/",
474
484
  "externalPath": "components.admin.react.modules"
475
485
  },
476
- {
477
- "defaultExport": "ModularSidebar",
478
- "importPath": "react/admin/modules/Layouts/",
479
- "externalPath": "components.admin.react.modules"
480
- },
481
- {
482
- "defaultExport": "RightSidebar",
483
- "importPath": "react/admin/modules/Layouts/",
484
- "externalPath": "components.admin.react.modules"
485
- },
486
486
  {
487
487
  "defaultExport": "ZohoLogo",
488
488
  "importPath": "react/admin/elements/Svgs/",
@@ -493,6 +493,11 @@ module.exports = [
493
493
  "importPath": "react/admin/elements/Svgs/",
494
494
  "externalPath": "components.admin.react.elements"
495
495
  },
496
+ {
497
+ "defaultExport": "WordPressLogo",
498
+ "importPath": "react/admin/elements/Svgs/",
499
+ "externalPath": "components.admin.react.elements"
500
+ },
496
501
  {
497
502
  "defaultExport": "WhatsAppLogo",
498
503
  "importPath": "react/admin/elements/Svgs/",
@@ -509,7 +514,7 @@ module.exports = [
509
514
  "externalPath": "components.admin.react.elements"
510
515
  },
511
516
  {
512
- "defaultExport": "WordPressLogo",
517
+ "defaultExport": "TelegramLogo",
513
518
  "importPath": "react/admin/elements/Svgs/",
514
519
  "externalPath": "components.admin.react.elements"
515
520
  },
@@ -634,22 +639,22 @@ module.exports = [
634
639
  "externalPath": "components.admin.react.elements"
635
640
  },
636
641
  {
637
- "defaultExport": "MailerSendFullLogo",
642
+ "defaultExport": "MailchimpLogo",
638
643
  "importPath": "react/admin/elements/Svgs/",
639
644
  "externalPath": "components.admin.react.elements"
640
645
  },
641
646
  {
642
- "defaultExport": "MailchimpLogo",
647
+ "defaultExport": "MailchimpFullLogo",
643
648
  "importPath": "react/admin/elements/Svgs/",
644
649
  "externalPath": "components.admin.react.elements"
645
650
  },
646
651
  {
647
- "defaultExport": "MailchimpFullLogo",
652
+ "defaultExport": "MailSuccessBg",
648
653
  "importPath": "react/admin/elements/Svgs/",
649
654
  "externalPath": "components.admin.react.elements"
650
655
  },
651
656
  {
652
- "defaultExport": "MailSuccessBg",
657
+ "defaultExport": "MailerSendFullLogo",
653
658
  "importPath": "react/admin/elements/Svgs/",
654
659
  "externalPath": "components.admin.react.elements"
655
660
  },
@@ -689,17 +694,17 @@ module.exports = [
689
694
  "externalPath": "components.admin.react.elements"
690
695
  },
691
696
  {
692
- "defaultExport": "GravityFormsLogo",
697
+ "defaultExport": "GravityCRMTextLogo",
693
698
  "importPath": "react/admin/elements/Svgs/",
694
699
  "externalPath": "components.admin.react.elements"
695
700
  },
696
701
  {
697
- "defaultExport": "GravityCRMTextLogo",
702
+ "defaultExport": "GravityCRMFullLogo",
698
703
  "importPath": "react/admin/elements/Svgs/",
699
704
  "externalPath": "components.admin.react.elements"
700
705
  },
701
706
  {
702
- "defaultExport": "GravityCRMFullLogo",
707
+ "defaultExport": "GravityFormsLogo",
703
708
  "importPath": "react/admin/elements/Svgs/",
704
709
  "externalPath": "components.admin.react.elements"
705
710
  },
@@ -778,11 +783,6 @@ module.exports = [
778
783
  "importPath": "react/admin/elements/Svgs/",
779
784
  "externalPath": "components.admin.react.elements"
780
785
  },
781
- {
782
- "defaultExport": "TelegramLogo",
783
- "importPath": "react/admin/elements/Svgs/",
784
- "externalPath": "components.admin.react.elements"
785
- },
786
786
  {
787
787
  "defaultExport": "BrandedLink",
788
788
  "importPath": "react/admin/elements/Link/",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravityforms/components",
3
- "version": "6.2.0",
3
+ "version": "6.2.1",
4
4
  "description": "UI components for use in Gravity Forms development. Both React and vanilla js flavors.",
5
5
  "author": "Rocketgenius",
6
6
  "license": "GPL-2.0-or-later",
@@ -30,7 +30,7 @@
30
30
  },
31
31
  "dependencies": {
32
32
  "@babel/runtime": "^7.26.0",
33
- "@gravityforms/components": "^6.2.0",
33
+ "@gravityforms/components": "^6.2.1",
34
34
  "@gravityforms/libraries": "^6.0.0",
35
35
  "@gravityforms/react-utils": "^5.1.7",
36
36
  "@gravityforms/request": "^6.1.0",
@@ -1,7 +1,6 @@
1
1
  import { React, ReactDND, PropTypes, classnames } from '@gravityforms/libraries';
2
- import { ConditionalWrapper } from '@gravityforms/react-utils';
3
2
  import { spacerClasses, sprintf } from '@gravityforms/utils';
4
- import { UP, DOWN, BLOCK, INLINE } from './constants';
3
+ import { UP, DOWN, INLINE } from './constants';
5
4
  import { ARROW_UP, ARROW_DOWN, ARROW_LEFT, ARROW_RIGHT, TAB } from '../../utils/keymap';
6
5
  import itemTypes from './item-types';
7
6
  import Button from '../../elements/Button';
@@ -58,6 +57,7 @@ const RepeaterItem = ( {
58
57
  speak = () => {},
59
58
  style = 'regular',
60
59
  type = INLINE,
60
+ useBlockLayoutOnMobile = true,
61
61
  upButtonAttributes = {},
62
62
  upButtonClasses = [],
63
63
  } ) => {
@@ -274,7 +274,7 @@ const RepeaterItem = ( {
274
274
  };
275
275
 
276
276
  const blockHeaderProps = {
277
- className: classnames( [
277
+ customClasses: classnames( [
278
278
  'gform-repeater-item__block-header',
279
279
  ], blockHeaderClasses ),
280
280
  size: 'text-sm',
@@ -290,14 +290,16 @@ const RepeaterItem = ( {
290
290
  buttonType = 'icon-white';
291
291
  }
292
292
 
293
- const renderActionButtons = () => {
293
+ const renderActionButtons = ( context = 'block' ) => {
294
+ const actionButtonType = context === 'block' ? 'white' : buttonType;
295
+ const size = context === 'block' ? 'size-height-m' : inlineButtonSize;
294
296
  return actionButtons.length ? actionButtons.map( ( button, idx ) => {
295
297
  const { icon, label, onClick, ...rest } = button;
296
298
  return (
297
299
  <Button
298
300
  key={ `action-button-${ idx }` }
299
- size={ inlineButtonSize }
300
- type={ buttonType }
301
+ size={ size }
302
+ type={ actionButtonType }
301
303
  icon={ icon }
302
304
  iconPosition="leading"
303
305
  iconPrefix="gravity-component-icon"
@@ -316,42 +318,52 @@ const RepeaterItem = ( {
316
318
  } ) : null;
317
319
  };
318
320
 
319
- const deleteButtonProps = {
320
- size: inlineButtonSize,
321
- type: buttonType,
322
- icon: 'trash',
323
- iconPosition: 'leading',
324
- iconPrefix: 'gravity-component-icon',
325
- label: i18n.deleteLabel,
326
- onClick: handleDelete,
327
- disabled: minItems > 0 && itemCount <= minItems,
328
- customAttributes: {
329
- type: 'button',
330
- },
331
- customClasses: classnames( [
332
- 'gform-repeater-item__delete',
333
- 'gform-repeater-item__action-control',
334
- ], deleteButtonClasses ),
335
- ...deleteButtonAttributes,
321
+ const renderDeleteButton = ( context = 'block' ) => {
322
+ const deleteButtonType = context === 'block' ? 'white' : buttonType;
323
+ const size = context === 'block' ? 'size-height-m' : inlineButtonSize;
324
+ const deleteButtonProps = {
325
+ size,
326
+ type: deleteButtonType,
327
+ icon: 'trash',
328
+ iconPosition: 'leading',
329
+ iconPrefix: 'gravity-component-icon',
330
+ label: i18n.deleteLabel,
331
+ onClick: handleDelete,
332
+ disabled: minItems > 0 && itemCount <= minItems,
333
+ customAttributes: {
334
+ type: 'button',
335
+ },
336
+ customClasses: classnames( [
337
+ 'gform-repeater-item__delete',
338
+ 'gform-repeater-item__action-control',
339
+ ], deleteButtonClasses ),
340
+ ...deleteButtonAttributes,
341
+ };
342
+ return <Button { ...deleteButtonProps } />;
336
343
  };
337
344
 
338
- const addButtonProps = {
339
- size: inlineButtonSize,
340
- type: buttonType,
341
- icon: 'plus-regular',
342
- iconAttributes: addButtonAttributes?.iconAttributes || {},
343
- iconPosition: 'leading',
344
- iconPrefix: 'gravity-component-icon',
345
- label: i18n.addLabel,
346
- onClick: addItem,
347
- disabled: !! ( maxItems && itemCount >= maxItems ) || addButtonAttributes?.disabled,
348
- customAttributes: {
349
- type: 'button',
350
- },
351
- customClasses: classnames( [
352
- 'gform-repeater-item__add',
353
- 'gform-repeater-item__action-control',
354
- ], addButtonClasses ),
345
+ const renderAddButton = ( context = 'block' ) => {
346
+ const addButtonType = context === 'block' ? 'white' : buttonType;
347
+ const size = context === 'block' ? 'size-height-m' : inlineButtonSize;
348
+ const addButtonProps = {
349
+ size,
350
+ type: addButtonType,
351
+ icon: 'plus-regular',
352
+ iconAttributes: addButtonAttributes?.iconAttributes || {},
353
+ iconPosition: 'leading',
354
+ iconPrefix: 'gravity-component-icon',
355
+ label: i18n.addLabel,
356
+ onClick: addItem,
357
+ disabled: !! ( maxItems && itemCount >= maxItems ) || addButtonAttributes?.disabled,
358
+ customAttributes: {
359
+ type: 'button',
360
+ },
361
+ customClasses: classnames( [
362
+ 'gform-repeater-item__add',
363
+ 'gform-repeater-item__action-control',
364
+ ], addButtonClasses ),
365
+ };
366
+ return <Button { ...addButtonProps } />;
355
367
  };
356
368
 
357
369
  const collapsibleButtonProps = {
@@ -374,7 +386,6 @@ const RepeaterItem = ( {
374
386
  };
375
387
 
376
388
  const blockContentProps = {
377
- 'aria-hidden': isCollapsed,
378
389
  'aria-labelledby': `${ id }-collapsible-button`,
379
390
  className: 'gform-repeater-item__block-content',
380
391
  id: `${ id }-block-content`,
@@ -386,16 +397,18 @@ const RepeaterItem = ( {
386
397
  'gform-repeater-item': true,
387
398
  [ `gform-repeater-item--style-${ style }` ]: true,
388
399
  [ `gform-repeater-item--type-${ type }` ]: type,
389
- 'gform-repeater-item--show-actions-on-hover': showActionsOnHover,
400
+ 'gform-repeater-item--show-actions-on-hover': type === INLINE && showActionsOnHover,
390
401
  'gform-repeater-item--has-arrows': showArrows && isSortable,
391
402
  'gform-repeater-item--has-drag-handle': showDragHandle && isDraggable && isSortable,
392
403
  'gform-repeater-item--is-draggable': isDraggable && isSortable,
393
404
  'gform-repeater-item--is-sortable': isSortable,
405
+ 'gform-repeater-item--is-collapsible': collapsible,
394
406
  'gform-repeater-item--is-collapsed': isCollapsed,
395
407
  'gform-repeater-item--is-dragging': isDragging,
396
408
  'gform-repeater-item--fill-content': fillContent,
397
409
  'gform-repeater-item--disable-item-drag': ! itemDraggable,
398
410
  'gform-repeater-item--is-keyboard-nav': keyboardDragActive,
411
+ 'gform-repeater-item--use-inline-layout-mobile': type === INLINE && ! useBlockLayoutOnMobile,
399
412
  ...spacerClasses( itemSpacing ),
400
413
  }, itemClasses ),
401
414
  'data-index': index,
@@ -404,32 +417,37 @@ const RepeaterItem = ( {
404
417
  ...itemAttributes,
405
418
  };
406
419
 
420
+ const useBlockLayout = type === 'block' || ( type === INLINE && useBlockLayoutOnMobile );
421
+ const noControls = ( ! showArrows && ( ! showDragHandle || ! isDraggable ) ) || ! isSortable;
422
+
407
423
  return (
408
424
  <div { ...componentProps } ref={ ref }>
409
- <div { ...itemWrapperProps }>
410
- { renderControls() }
411
- { type === BLOCK && blockContentTitle && (
412
- <Text { ...blockHeaderProps }>{ blockContentTitle }</Text>
413
- ) }
414
- { type === INLINE && children }
415
- <ConditionalWrapper
416
- condition={ ( showAdd || showActions || showDelete ) && type === INLINE && style === 'minimal' }
417
- wrapper={ ( ch ) => <div className="gform-repeater-item__minimal-actions">{ ch }</div> }
418
- >
419
- { showAdd && type === INLINE && <Button { ...addButtonProps } /> }
420
- { showActions && type === INLINE && renderActionButtons() }
421
- { showDelete && type === INLINE && <Button { ...deleteButtonProps } /> }
422
- </ConditionalWrapper>
423
- { collapsible && type === BLOCK && <Button { ...collapsibleButtonProps } /> }
424
- </div>
425
- { type === BLOCK && (
425
+ { ( ! noControls || useBlockLayout ) && (
426
+ <div { ...itemWrapperProps }>
427
+ { renderControls() }
428
+ { useBlockLayout && blockContentTitle && (
429
+ <Text { ...blockHeaderProps }>{ blockContentTitle }</Text>
430
+ ) }
431
+ { useBlockLayout && collapsible && <Button { ...collapsibleButtonProps } /> }
432
+ </div>
433
+ ) }
434
+ { (
426
435
  <div { ...blockContentProps }>
427
436
  { children }
428
- <div className="gform-repeater-item__block-content-footer">
429
- { showActions && renderActionButtons() }
430
- { showDelete && <Button { ...deleteButtonProps } /> }
431
- </div>
432
- { showAdd && ! inlineAdd && <Button { ...addButtonProps } /> }
437
+ { ( showAdd || showActions || showDelete ) && type === INLINE && (
438
+ <div className="gform-repeater-item__minimal-actions">
439
+ { showAdd && renderAddButton( 'inline' ) }
440
+ { showActions && renderActionButtons( 'inline' ) }
441
+ { showDelete && renderDeleteButton( 'inline' ) }
442
+ </div>
443
+ ) }
444
+ { useBlockLayout && (
445
+ <div className="gform-repeater-item__block-content-footer">
446
+ { showAdd && inlineAdd && renderAddButton( 'block' ) }
447
+ { showActions && renderActionButtons( 'block' ) }
448
+ { showDelete && renderDeleteButton( 'block' ) }
449
+ </div>
450
+ ) }
433
451
  </div>
434
452
  ) }
435
453
  </div>
@@ -60,6 +60,7 @@ const { useState } = React;
60
60
  * @param {string|number|Array|object} props.spacing The spacing for the component, as a string, number, array, or object.
61
61
  * @param {string} props.style The style of the repeater.
62
62
  * @param {string} props.type The type of the repeater.
63
+ * @param {boolean} props.useBlockOnSmallScreen If the block type styles should be used for inline type repeaters on small screens.
63
64
  * @param {object} props.upButtonAttributes Custom attributes for the up button.
64
65
  * @param {string|Array|object} props.upButtonClasses Custom classes for the up button.
65
66
  *
@@ -124,6 +125,7 @@ const Repeater = ( {
124
125
  spacing = '',
125
126
  style = 'regular',
126
127
  type = INLINE,
128
+ useBlockLayoutOnMobile = false,
127
129
  upButtonAttributes = {},
128
130
  upButtonClasses = [],
129
131
  } ) => {
@@ -300,6 +302,7 @@ const Repeater = ( {
300
302
  speak={ setScreenReaderText }
301
303
  style={ style }
302
304
  type={ type }
305
+ useBlockLayoutOnMobile={ useBlockLayoutOnMobile }
303
306
  upButtonAttributes={ upButtonAttributes }
304
307
  upButtonClasses={ upButtonClasses }
305
308
  >
@@ -406,6 +409,7 @@ Repeater.propTypes = {
406
409
  ] ),
407
410
  style: PropTypes.string,
408
411
  type: PropTypes.oneOf( [ BLOCK, INLINE ] ),
412
+ useBlockLayoutOnMobile: PropTypes.bool,
409
413
  upButtonAttributes: PropTypes.object,
410
414
  upButtonClasses: PropTypes.oneOfType( [
411
415
  PropTypes.element,
@@ -9,7 +9,7 @@ const resolvePath = ( path, base = window ) => {
9
9
  return path.split( '.' ).reduce( ( acc, part ) => acc && acc[ part ], base );
10
10
  };
11
11
 
12
- const useRepeaterState = ( initialStateOrPath, syncWithWindow = false, titleKey = '', repeaterType = 'inline', titlePrefix = '' ) => {
12
+ const useRepeaterState = ( initialStateOrPath, syncWithWindow = false, titleKey = '', titlePrefix = '' ) => {
13
13
  const isPath = typeof initialStateOrPath === 'string';
14
14
  const initialState = isPath ? deepClone( resolvePath( initialStateOrPath ) || [] ) : deepClone( initialStateOrPath );
15
15
  const [ items, setItems ] = useState( initialState );
@@ -37,14 +37,14 @@ const useRepeaterState = ( initialStateOrPath, syncWithWindow = false, titleKey
37
37
  [ key ]: value,
38
38
  };
39
39
 
40
- if ( titleKey && repeaterType === 'block' && key === titleKey ) {
40
+ if ( titleKey && key === titleKey ) {
41
41
  updatedItems[ index ].repeater_item_block_content_title = titlePrefix ? sprintf( titlePrefix, value ) : value;
42
42
  }
43
43
 
44
44
  updateExternalState( updatedItems );
45
45
  return updatedItems;
46
46
  } );
47
- }, [ repeaterType, titleKey, titlePrefix, syncWithWindow, initialStateOrPath ] );
47
+ }, [ titleKey, titlePrefix, syncWithWindow, initialStateOrPath ] );
48
48
 
49
49
  return { items, handleChange, onChange };
50
50
  };