@wordpress/dataviews 14.0.0 → 14.1.1-next.v.202604091042.0

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.
Files changed (138) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +16 -5
  3. package/build/components/dataform-controls/array.cjs +2 -0
  4. package/build/components/dataform-controls/array.cjs.map +2 -2
  5. package/build/components/dataform-controls/checkbox.cjs +3 -1
  6. package/build/components/dataform-controls/checkbox.cjs.map +2 -2
  7. package/build/components/dataform-controls/color.cjs +8 -2
  8. package/build/components/dataform-controls/color.cjs.map +2 -2
  9. package/build/components/dataform-controls/date.cjs +20 -9
  10. package/build/components/dataform-controls/date.cjs.map +2 -2
  11. package/build/components/dataform-controls/datetime.cjs +5 -2
  12. package/build/components/dataform-controls/datetime.cjs.map +2 -2
  13. package/build/components/dataform-controls/password.cjs +4 -1
  14. package/build/components/dataform-controls/password.cjs.map +2 -2
  15. package/build/components/dataform-controls/radio.cjs +3 -1
  16. package/build/components/dataform-controls/radio.cjs.map +2 -2
  17. package/build/components/dataform-controls/select.cjs +3 -1
  18. package/build/components/dataform-controls/select.cjs.map +2 -2
  19. package/build/components/dataform-controls/textarea.cjs +2 -0
  20. package/build/components/dataform-controls/textarea.cjs.map +2 -2
  21. package/build/components/dataform-controls/toggle-group.cjs +3 -1
  22. package/build/components/dataform-controls/toggle-group.cjs.map +2 -2
  23. package/build/components/dataform-controls/toggle.cjs +3 -1
  24. package/build/components/dataform-controls/toggle.cjs.map +2 -2
  25. package/build/components/dataform-controls/utils/relative-date-control.cjs +5 -2
  26. package/build/components/dataform-controls/utils/relative-date-control.cjs.map +2 -2
  27. package/build/components/dataform-controls/utils/validated-input.cjs +2 -0
  28. package/build/components/dataform-controls/utils/validated-input.cjs.map +2 -2
  29. package/build/components/dataform-controls/utils/validated-number.cjs +3 -1
  30. package/build/components/dataform-controls/utils/validated-number.cjs.map +2 -2
  31. package/build/components/dataviews-filters/input-widget.cjs +4 -0
  32. package/build/components/dataviews-filters/input-widget.cjs.map +2 -2
  33. package/build/components/dataviews-pagination/index.cjs +1 -0
  34. package/build/components/dataviews-pagination/index.cjs.map +2 -2
  35. package/build/field-types/index.cjs +1 -0
  36. package/build/field-types/index.cjs.map +2 -2
  37. package/build/types/field-api.cjs.map +1 -1
  38. package/build-module/components/dataform-controls/array.mjs +2 -0
  39. package/build-module/components/dataform-controls/array.mjs.map +2 -2
  40. package/build-module/components/dataform-controls/checkbox.mjs +3 -1
  41. package/build-module/components/dataform-controls/checkbox.mjs.map +2 -2
  42. package/build-module/components/dataform-controls/color.mjs +8 -2
  43. package/build-module/components/dataform-controls/color.mjs.map +2 -2
  44. package/build-module/components/dataform-controls/date.mjs +20 -9
  45. package/build-module/components/dataform-controls/date.mjs.map +2 -2
  46. package/build-module/components/dataform-controls/datetime.mjs +5 -2
  47. package/build-module/components/dataform-controls/datetime.mjs.map +2 -2
  48. package/build-module/components/dataform-controls/password.mjs +4 -1
  49. package/build-module/components/dataform-controls/password.mjs.map +2 -2
  50. package/build-module/components/dataform-controls/radio.mjs +3 -1
  51. package/build-module/components/dataform-controls/radio.mjs.map +2 -2
  52. package/build-module/components/dataform-controls/select.mjs +3 -1
  53. package/build-module/components/dataform-controls/select.mjs.map +2 -2
  54. package/build-module/components/dataform-controls/textarea.mjs +2 -0
  55. package/build-module/components/dataform-controls/textarea.mjs.map +2 -2
  56. package/build-module/components/dataform-controls/toggle-group.mjs +3 -1
  57. package/build-module/components/dataform-controls/toggle-group.mjs.map +2 -2
  58. package/build-module/components/dataform-controls/toggle.mjs +3 -1
  59. package/build-module/components/dataform-controls/toggle.mjs.map +2 -2
  60. package/build-module/components/dataform-controls/utils/relative-date-control.mjs +5 -2
  61. package/build-module/components/dataform-controls/utils/relative-date-control.mjs.map +2 -2
  62. package/build-module/components/dataform-controls/utils/validated-input.mjs +2 -0
  63. package/build-module/components/dataform-controls/utils/validated-input.mjs.map +2 -2
  64. package/build-module/components/dataform-controls/utils/validated-number.mjs +3 -1
  65. package/build-module/components/dataform-controls/utils/validated-number.mjs.map +2 -2
  66. package/build-module/components/dataviews-filters/input-widget.mjs +4 -0
  67. package/build-module/components/dataviews-filters/input-widget.mjs.map +2 -2
  68. package/build-module/components/dataviews-pagination/index.mjs +1 -0
  69. package/build-module/components/dataviews-pagination/index.mjs.map +2 -2
  70. package/build-module/field-types/index.mjs +1 -0
  71. package/build-module/field-types/index.mjs.map +2 -2
  72. package/build-style/style-rtl.css +2 -2
  73. package/build-style/style.css +2 -2
  74. package/build-types/components/dataform-controls/array.d.ts.map +1 -1
  75. package/build-types/components/dataform-controls/checkbox.d.ts.map +1 -1
  76. package/build-types/components/dataform-controls/color.d.ts.map +1 -1
  77. package/build-types/components/dataform-controls/date.d.ts.map +1 -1
  78. package/build-types/components/dataform-controls/datetime.d.ts.map +1 -1
  79. package/build-types/components/dataform-controls/password.d.ts.map +1 -1
  80. package/build-types/components/dataform-controls/radio.d.ts.map +1 -1
  81. package/build-types/components/dataform-controls/select.d.ts.map +1 -1
  82. package/build-types/components/dataform-controls/textarea.d.ts.map +1 -1
  83. package/build-types/components/dataform-controls/toggle-group.d.ts.map +1 -1
  84. package/build-types/components/dataform-controls/toggle.d.ts.map +1 -1
  85. package/build-types/components/dataform-controls/utils/relative-date-control.d.ts.map +1 -1
  86. package/build-types/components/dataform-controls/utils/validated-input.d.ts.map +1 -1
  87. package/build-types/components/dataform-controls/utils/validated-number.d.ts.map +1 -1
  88. package/build-types/components/dataviews-filters/input-widget.d.ts.map +1 -1
  89. package/build-types/components/dataviews-layouts/index.d.ts +6 -6
  90. package/build-types/components/dataviews-pagination/index.d.ts.map +1 -1
  91. package/build-types/components/dataviews-search/index.d.ts +1 -1
  92. package/build-types/components/dataviews-search/index.d.ts.map +1 -1
  93. package/build-types/constants.d.ts +2 -2
  94. package/build-types/dataform/stories/index.story.d.ts +11 -1
  95. package/build-types/dataform/stories/index.story.d.ts.map +1 -1
  96. package/build-types/dataform/stories/layout-regular.d.ts +2 -1
  97. package/build-types/dataform/stories/layout-regular.d.ts.map +1 -1
  98. package/build-types/field-types/array.d.ts +1 -1
  99. package/build-types/field-types/array.d.ts.map +1 -1
  100. package/build-types/field-types/boolean.d.ts +1 -1
  101. package/build-types/field-types/boolean.d.ts.map +1 -1
  102. package/build-types/field-types/color.d.ts +1 -1
  103. package/build-types/field-types/color.d.ts.map +1 -1
  104. package/build-types/field-types/email.d.ts +1 -1
  105. package/build-types/field-types/email.d.ts.map +1 -1
  106. package/build-types/field-types/index.d.ts.map +1 -1
  107. package/build-types/field-types/integer.d.ts +1 -1
  108. package/build-types/field-types/integer.d.ts.map +1 -1
  109. package/build-types/field-types/number.d.ts +1 -1
  110. package/build-types/field-types/number.d.ts.map +1 -1
  111. package/build-types/field-types/stories/index.story.d.ts +37 -15
  112. package/build-types/field-types/stories/index.story.d.ts.map +1 -1
  113. package/build-types/types/field-api.d.ts +13 -0
  114. package/build-types/types/field-api.d.ts.map +1 -1
  115. package/build-wp/index.js +124 -56
  116. package/package.json +16 -16
  117. package/src/components/dataform-controls/array.tsx +2 -0
  118. package/src/components/dataform-controls/checkbox.tsx +2 -0
  119. package/src/components/dataform-controls/color.tsx +7 -0
  120. package/src/components/dataform-controls/date.tsx +15 -4
  121. package/src/components/dataform-controls/datetime.tsx +3 -0
  122. package/src/components/dataform-controls/password.tsx +3 -0
  123. package/src/components/dataform-controls/radio.tsx +2 -0
  124. package/src/components/dataform-controls/select.tsx +2 -0
  125. package/src/components/dataform-controls/textarea.tsx +2 -0
  126. package/src/components/dataform-controls/toggle-group.tsx +2 -0
  127. package/src/components/dataform-controls/toggle.tsx +2 -0
  128. package/src/components/dataform-controls/utils/relative-date-control.tsx +3 -0
  129. package/src/components/dataform-controls/utils/validated-input.tsx +2 -0
  130. package/src/components/dataform-controls/utils/validated-number.tsx +2 -0
  131. package/src/components/dataviews-filters/input-widget.tsx +4 -0
  132. package/src/components/dataviews-layouts/activity/style.scss +2 -2
  133. package/src/components/dataviews-pagination/index.tsx +1 -0
  134. package/src/dataform/stories/index.story.tsx +7 -0
  135. package/src/dataform/stories/layout-regular.tsx +15 -1
  136. package/src/field-types/index.tsx +4 -0
  137. package/src/field-types/stories/index.story.tsx +66 -5
  138. package/src/types/field-api.ts +16 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/dataviews",
3
- "version": "14.0.0",
3
+ "version": "14.1.1-next.v.202604091042.0+668146787",
4
4
  "description": "DataViews is a component that provides an API to render datasets using different types of layouts (table, grid, list, etc.).",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -53,20 +53,20 @@
53
53
  "sideEffects": false,
54
54
  "dependencies": {
55
55
  "@ariakit/react": "^0.4.21",
56
- "@wordpress/base-styles": "^6.19.0",
57
- "@wordpress/components": "^32.5.0",
58
- "@wordpress/compose": "^7.43.0",
59
- "@wordpress/data": "^10.43.0",
60
- "@wordpress/date": "^5.43.0",
61
- "@wordpress/deprecated": "^4.43.0",
62
- "@wordpress/element": "^6.43.0",
63
- "@wordpress/i18n": "^6.16.0",
64
- "@wordpress/icons": "^12.1.0",
65
- "@wordpress/keycodes": "^4.43.0",
66
- "@wordpress/primitives": "^4.43.0",
67
- "@wordpress/private-apis": "^1.43.0",
68
- "@wordpress/ui": "^0.10.0",
69
- "@wordpress/warning": "^3.43.0",
56
+ "@wordpress/base-styles": "^6.19.1-next.v.202604091042.0+668146787",
57
+ "@wordpress/components": "^32.5.2-next.v.202604091042.0+668146787",
58
+ "@wordpress/compose": "^7.43.1-next.v.202604091042.0+668146787",
59
+ "@wordpress/data": "^10.43.1-next.v.202604091042.0+668146787",
60
+ "@wordpress/date": "^5.43.1-next.v.202604091042.0+668146787",
61
+ "@wordpress/deprecated": "^4.43.1-next.v.202604091042.0+668146787",
62
+ "@wordpress/element": "^6.44.1-next.v.202604091042.0+668146787",
63
+ "@wordpress/i18n": "^6.17.1-next.v.202604091042.0+668146787",
64
+ "@wordpress/icons": "^12.1.1-next.v.202604091042.0+668146787",
65
+ "@wordpress/keycodes": "^4.43.1-next.v.202604091042.0+668146787",
66
+ "@wordpress/primitives": "^4.43.1-next.v.202604091042.0+668146787",
67
+ "@wordpress/private-apis": "^1.43.1-next.v.202604091042.0+668146787",
68
+ "@wordpress/ui": "^0.11.1-next.v.202604091042.0+668146787",
69
+ "@wordpress/warning": "^3.43.1-next.v.202604091042.0+668146787",
70
70
  "clsx": "^2.1.1",
71
71
  "colord": "^2.7.0",
72
72
  "date-fns": "^4.1.0",
@@ -92,5 +92,5 @@
92
92
  "scripts": {
93
93
  "build:wp": "node build.cjs"
94
94
  },
95
- "gitHead": "2cea90674d11aa521ec3f71652fb3a6a4c383969"
95
+ "gitHead": "73606df74f1c38a084bfa5db97205259ef817593"
96
96
  }
@@ -24,6 +24,7 @@ export default function ArrayControl< Item >( {
24
24
  }: DataFormControlProps< Item > ) {
25
25
  const { label, placeholder, getValue, setValue, isValid } = field;
26
26
  const value = getValue( { item: data } );
27
+ const disabled = field.isDisabled( { item: data, field } );
27
28
 
28
29
  const { elements, isLoading } = useElements( {
29
30
  elements: field.elements,
@@ -73,6 +74,7 @@ export default function ArrayControl< Item >( {
73
74
  onChange={ onChangeControl }
74
75
  placeholder={ placeholder }
75
76
  suggestions={ elements?.map( ( element ) => element.value ) }
77
+ disabled={ disabled }
76
78
  __experimentalValidateInput={ ( token: string ) => {
77
79
  // If elements validation is required, check if token is valid
78
80
  if ( field.isValid?.elements && elements ) {
@@ -22,6 +22,7 @@ export default function Checkbox< Item >( {
22
22
  validity,
23
23
  }: DataFormControlProps< Item > ) {
24
24
  const { getValue, setValue, label, description, isValid } = field;
25
+ const disabled = field.isDisabled( { item: data, field } );
25
26
 
26
27
  const onChangeControl = useCallback( () => {
27
28
  onChange(
@@ -39,6 +40,7 @@ export default function Checkbox< Item >( {
39
40
  help={ description }
40
41
  checked={ getValue( { item: data } ) }
41
42
  onChange={ onChangeControl }
43
+ disabled={ disabled }
42
44
  />
43
45
  );
44
46
  }
@@ -30,9 +30,11 @@ const { ValidatedInputControl } = unlock( privateApis );
30
30
  const ColorPickerDropdown = ( {
31
31
  color,
32
32
  onColorChange,
33
+ disabled,
33
34
  }: {
34
35
  color: string;
35
36
  onColorChange: ( newColor: string ) => void;
37
+ disabled?: boolean;
36
38
  } ) => {
37
39
  const validColor = color && colord( color ).isValid() ? color : '#ffffff';
38
40
 
@@ -45,6 +47,8 @@ const ColorPickerDropdown = ( {
45
47
  onClick={ onToggle }
46
48
  aria-label={ __( 'Open color picker' ) }
47
49
  size="small"
50
+ disabled={ disabled }
51
+ accessibleWhenDisabled
48
52
  icon={ () => <ColorIndicator colorValue={ validColor } /> }
49
53
  />
50
54
  ) }
@@ -70,6 +74,7 @@ export default function Color< Item >( {
70
74
  validity,
71
75
  }: DataFormControlProps< Item > ) {
72
76
  const { label, placeholder, description, setValue, isValid } = field;
77
+ const disabled = field.isDisabled( { item: data, field } );
73
78
  const value = field.getValue( { item: data } ) || '';
74
79
 
75
80
  const handleColorChange = useCallback(
@@ -98,11 +103,13 @@ export default function Color< Item >( {
98
103
  onChange={ handleInputChange }
99
104
  hideLabelFromVision={ hideLabelFromVision }
100
105
  type="text"
106
+ disabled={ disabled }
101
107
  prefix={
102
108
  <InputControlPrefixWrapper variant="control">
103
109
  <ColorPickerDropdown
104
110
  color={ value }
105
111
  onColorChange={ handleColorChange }
112
+ disabled={ disabled }
106
113
  />
107
114
  </InputControlPrefixWrapper>
108
115
  }
@@ -299,6 +299,7 @@ function CalendarDateControl< Item >( {
299
299
  isValid,
300
300
  format: fieldFormat,
301
301
  } = field;
302
+ const disabled = field.isDisabled( { item: data, field } );
302
303
  const [ selectedPresetId, setSelectedPresetId ] = useState< string | null >(
303
304
  null
304
305
  );
@@ -406,6 +407,8 @@ function CalendarDateControl< Item >( {
406
407
  variant="tertiary"
407
408
  isPressed={ isSelected }
408
409
  size="small"
410
+ disabled={ disabled }
411
+ accessibleWhenDisabled
409
412
  onClick={ () =>
410
413
  handlePresetClick( preset )
411
414
  }
@@ -419,8 +422,8 @@ function CalendarDateControl< Item >( {
419
422
  variant="tertiary"
420
423
  isPressed={ ! selectedPresetId }
421
424
  size="small"
422
- disabled={ !! selectedPresetId }
423
- accessibleWhenDisabled={ false }
425
+ disabled={ !! selectedPresetId || disabled }
426
+ accessibleWhenDisabled
424
427
  >
425
428
  { __( 'Custom' ) }
426
429
  </Button>
@@ -436,6 +439,7 @@ function CalendarDateControl< Item >( {
436
439
  value={ value }
437
440
  onChange={ handleManualDateChange }
438
441
  required={ !! field.isValid?.required }
442
+ disabled={ disabled }
439
443
  />
440
444
 
441
445
  { /* Calendar widget */ }
@@ -449,6 +453,7 @@ function CalendarDateControl< Item >( {
449
453
  onMonthChange={ setCalendarMonth }
450
454
  timeZone={ timezoneString || undefined }
451
455
  weekStartsOn={ weekStartsOn }
456
+ disabled={ disabled }
452
457
  />
453
458
  </Stack>
454
459
  </BaseControl>
@@ -472,6 +477,7 @@ function CalendarDateRangeControl< Item >( {
472
477
  setValue,
473
478
  format: fieldFormat,
474
479
  } = field;
480
+ const disabled = field.isDisabled( { item: data, field } );
475
481
  let value: DateRange;
476
482
  const fieldValue = getValue( { item: data } );
477
483
  if (
@@ -626,6 +632,8 @@ function CalendarDateRangeControl< Item >( {
626
632
  variant="tertiary"
627
633
  isPressed={ isSelected }
628
634
  size="small"
635
+ disabled={ disabled }
636
+ accessibleWhenDisabled
629
637
  onClick={ () =>
630
638
  handlePresetClick( preset )
631
639
  }
@@ -639,8 +647,8 @@ function CalendarDateRangeControl< Item >( {
639
647
  variant="tertiary"
640
648
  isPressed={ ! selectedPresetId }
641
649
  size="small"
642
- accessibleWhenDisabled={ false }
643
- disabled={ !! selectedPresetId }
650
+ accessibleWhenDisabled
651
+ disabled={ !! selectedPresetId || disabled }
644
652
  >
645
653
  { __( 'Custom' ) }
646
654
  </Button>
@@ -664,6 +672,7 @@ function CalendarDateRangeControl< Item >( {
664
672
  handleManualDateChange( 'from', newValue )
665
673
  }
666
674
  required={ !! field.isValid?.required }
675
+ disabled={ disabled }
667
676
  />
668
677
  <InputControl
669
678
  __next40pxDefaultSize
@@ -676,6 +685,7 @@ function CalendarDateRangeControl< Item >( {
676
685
  handleManualDateChange( 'to', newValue )
677
686
  }
678
687
  required={ !! field.isValid?.required }
688
+ disabled={ disabled }
679
689
  />
680
690
  </Stack>
681
691
 
@@ -687,6 +697,7 @@ function CalendarDateRangeControl< Item >( {
687
697
  onMonthChange={ setCalendarMonth }
688
698
  timeZone={ timezone.string || undefined }
689
699
  weekStartsOn={ weekStartsOn }
700
+ disabled={ disabled }
690
701
  />
691
702
  </Stack>
692
703
  </BaseControl>
@@ -41,6 +41,7 @@ function CalendarDateTimeControl< Item >( {
41
41
  }: DataFormControlProps< Item > ) {
42
42
  const { compact } = config || {};
43
43
  const { id, label, description, setValue, getValue, isValid } = field;
44
+ const disabled = field.isDisabled( { item: data, field } );
44
45
  const fieldValue = getValue( { item: data } );
45
46
  const value = typeof fieldValue === 'string' ? fieldValue : undefined;
46
47
 
@@ -179,6 +180,7 @@ function CalendarDateTimeControl< Item >( {
179
180
  hideLabelFromVision
180
181
  value={ formatDateTime( value ) }
181
182
  onChange={ handleManualDateTimeChange }
183
+ disabled={ disabled }
182
184
  />
183
185
  { /* Calendar widget */ }
184
186
  { ! compact && (
@@ -194,6 +196,7 @@ function CalendarDateTimeControl< Item >( {
194
196
  onMonthChange={ setCalendarMonth }
195
197
  timeZone={ timezoneString || undefined }
196
198
  weekStartsOn={ weekStartsOn }
199
+ disabled={ disabled }
197
200
  />
198
201
  ) }
199
202
  </Stack>
@@ -23,6 +23,7 @@ export default function Password< Item >( {
23
23
  validity,
24
24
  }: DataFormControlProps< Item > ) {
25
25
  const [ isVisible, setIsVisible ] = useState( false );
26
+ const disabled = field.isDisabled( { item: data, field } );
26
27
 
27
28
  const toggleVisibility = useCallback( () => {
28
29
  setIsVisible( ( prev ) => ! prev );
@@ -49,6 +50,8 @@ export default function Password< Item >( {
49
50
  ? __( 'Hide password' )
50
51
  : __( 'Show password' )
51
52
  }
53
+ disabled={ disabled }
54
+ accessibleWhenDisabled
52
55
  />
53
56
  </InputControlSuffixWrapper>
54
57
  ),
@@ -23,6 +23,7 @@ export default function Radio< Item >( {
23
23
  validity,
24
24
  }: DataFormControlProps< Item > ) {
25
25
  const { label, description, getValue, setValue, isValid } = field;
26
+ const disabled = field.isDisabled( { item: data, field } );
26
27
  const { elements, isLoading } = useElements( {
27
28
  elements: field.elements,
28
29
  getElements: field.getElements,
@@ -50,6 +51,7 @@ export default function Radio< Item >( {
50
51
  options={ elements }
51
52
  selected={ value }
52
53
  hideLabelFromVision={ hideLabelFromVision }
54
+ disabled={ disabled }
53
55
  />
54
56
  );
55
57
  }
@@ -23,6 +23,7 @@ export default function Select< Item >( {
23
23
  validity,
24
24
  }: DataFormControlProps< Item > ) {
25
25
  const { type, label, description, getValue, setValue, isValid } = field;
26
+ const disabled = field.isDisabled( { item: data, field } );
26
27
 
27
28
  const isMultiple = type === 'array';
28
29
  const value = getValue( { item: data } ) ?? ( isMultiple ? [] : '' );
@@ -55,6 +56,7 @@ export default function Select< Item >( {
55
56
  __next40pxDefaultSize
56
57
  hideLabelFromVision={ hideLabelFromVision }
57
58
  multiple={ isMultiple }
59
+ disabled={ disabled }
58
60
  />
59
61
  );
60
62
  }
@@ -23,6 +23,7 @@ export default function Textarea< Item >( {
23
23
  validity,
24
24
  }: DataFormControlProps< Item > ) {
25
25
  const { rows = 4 } = config || {};
26
+ const disabled = field.isDisabled( { item: data, field } );
26
27
  const { label, placeholder, description, setValue, isValid } = field;
27
28
  const value = field.getValue( { item: data } );
28
29
 
@@ -43,6 +44,7 @@ export default function Textarea< Item >( {
43
44
  help={ description }
44
45
  onChange={ onChangeControl }
45
46
  rows={ rows }
47
+ disabled={ disabled }
46
48
  minLength={
47
49
  isValid.minLength ? isValid.minLength.constraint : undefined
48
50
  }
@@ -27,6 +27,7 @@ export default function ToggleGroup< Item >( {
27
27
  validity,
28
28
  }: DataFormControlProps< Item > ) {
29
29
  const { getValue, setValue, isValid } = field;
30
+ const disabled = field.isDisabled( { item: data, field } );
30
31
  const value = getValue( { item: data } );
31
32
 
32
33
  const onChangeControl = useCallback(
@@ -67,6 +68,7 @@ export default function ToggleGroup< Item >( {
67
68
  key={ el.value }
68
69
  label={ el.label }
69
70
  value={ el.value }
71
+ disabled={ disabled }
70
72
  />
71
73
  ) ) }
72
74
  </ValidatedToggleGroupControl>
@@ -22,6 +22,7 @@ export default function Toggle< Item >( {
22
22
  validity,
23
23
  }: DataFormControlProps< Item > ) {
24
24
  const { label, description, getValue, setValue, isValid } = field;
25
+ const disabled = field.isDisabled( { item: data, field } );
25
26
 
26
27
  const onChangeControl = useCallback( () => {
27
28
  onChange(
@@ -39,6 +40,7 @@ export default function Toggle< Item >( {
39
40
  help={ description }
40
41
  checked={ getValue( { item: data } ) }
41
42
  onChange={ onChangeControl }
43
+ disabled={ disabled }
42
44
  />
43
45
  );
44
46
  }
@@ -59,6 +59,7 @@ export default function RelativeDateControl< Item >( {
59
59
  ];
60
60
 
61
61
  const { id, label, description, getValue, setValue } = field;
62
+ const disabled = field.isDisabled( { item: data, field } );
62
63
  const fieldValue = getValue( { item: data } );
63
64
  const { value: relValue = '', unit = options[ 0 ].value } =
64
65
  fieldValue && typeof fieldValue === 'object' ? fieldValue : {};
@@ -102,6 +103,7 @@ export default function RelativeDateControl< Item >( {
102
103
  step={ 1 }
103
104
  value={ relValue }
104
105
  onChange={ onChangeValue }
106
+ disabled={ disabled }
105
107
  />
106
108
  <SelectControl
107
109
  className="dataviews-controls__relative-date-unit"
@@ -111,6 +113,7 @@ export default function RelativeDateControl< Item >( {
111
113
  options={ options }
112
114
  onChange={ onChangeUnit }
113
115
  hideLabelFromVision
116
+ disabled={ disabled }
114
117
  />
115
118
  </Stack>
116
119
  </BaseControl>
@@ -43,6 +43,7 @@ export default function ValidatedText< Item >( {
43
43
  const { label, placeholder, description, getValue, setValue, isValid } =
44
44
  field;
45
45
  const value = getValue( { item: data } );
46
+ const disabled = field.isDisabled( { item: data, field } );
46
47
 
47
48
  const onChangeControl = useCallback(
48
49
  ( newValue: string ) =>
@@ -69,6 +70,7 @@ export default function ValidatedText< Item >( {
69
70
  type={ type }
70
71
  prefix={ prefix }
71
72
  suffix={ suffix }
73
+ disabled={ disabled }
72
74
  pattern={ isValid.pattern ? isValid.pattern.constraint : undefined }
73
75
  minLength={
74
76
  isValid.minLength ? isValid.minLength.constraint : undefined
@@ -96,6 +96,7 @@ export default function ValidatedNumber< Item >( {
96
96
  const step = Math.pow( 10, Math.abs( decimals ) * -1 );
97
97
  const { label, description, getValue, setValue, isValid } = field;
98
98
  const value = getValue( { item: data } ) ?? '';
99
+ const disabled = field.isDisabled( { item: data, field } );
99
100
 
100
101
  const onChangeControl = useCallback(
101
102
  ( newValue: string | undefined ) => {
@@ -161,6 +162,7 @@ export default function ValidatedNumber< Item >( {
161
162
  step={ step }
162
163
  min={ isValid.min ? isValid.min.constraint : undefined }
163
164
  max={ isValid.max ? isValid.max.constraint : undefined }
165
+ disabled={ disabled }
164
166
  />
165
167
  );
166
168
  }
@@ -64,6 +64,10 @@ export default function InputWidget( {
64
64
  ...currentField,
65
65
  // Deactivate validation for filters.
66
66
  isValid: {} satisfies NormalizedRules< any >,
67
+ // Filter controls are always enabled.
68
+ isDisabled: () => false,
69
+ // Filter controls are always visible.
70
+ isVisible: () => true,
67
71
  // Configure getValue/setValue as if Item was a plain object.
68
72
  getValue: ( { item }: { item: any } ) =>
69
73
  item[ currentField.id ],
@@ -4,7 +4,7 @@
4
4
 
5
5
  .dataviews-view-activity {
6
6
  margin: 0 0 auto;
7
- padding: $grid-unit-10 $grid-unit-30;
7
+ padding: 0 $grid-unit-30;
8
8
 
9
9
  .dataviews-view-activity__group-header {
10
10
  font-size: $font-size-large;
@@ -104,7 +104,7 @@
104
104
  .dataviews-view-activity__item {
105
105
  &.is-compact {
106
106
  .dataviews-view-activity__item-type {
107
- width: $grid-unit-10;
107
+ width: $grid-unit-15;
108
108
 
109
109
  &::before {
110
110
  height: $grid-unit-15;
@@ -72,6 +72,7 @@ export function DataViewsPagination() {
72
72
  ),
73
73
  {
74
74
  div: <div aria-hidden />,
75
+ // @ts-expect-error — Tag injected via sprintf argument, not visible in format string.
75
76
  CurrentPage: (
76
77
  <SelectControl
77
78
  aria-label={ __( 'Current page' ) }
@@ -93,6 +93,13 @@ export const LayoutRegular = {
93
93
  description: 'Chooses the label position.',
94
94
  options: [ 'default', 'top', 'side', 'none' ],
95
95
  },
96
+ disabled: {
97
+ control: { type: 'boolean' },
98
+ description: 'Disable all fields in the form.',
99
+ },
100
+ },
101
+ args: {
102
+ disabled: false,
96
103
  },
97
104
  };
98
105
 
@@ -312,8 +312,10 @@ const getLayoutFromStoryArgs = ( {
312
312
 
313
313
  const LayoutRegularComponent = ( {
314
314
  labelPosition,
315
+ disabled = false,
315
316
  }: {
316
317
  labelPosition: 'default' | 'top' | 'side' | 'none';
318
+ disabled?: boolean;
317
319
  } ) => {
318
320
  const [ post, setPost ] = useState( {
319
321
  title: 'Hello, World!',
@@ -332,6 +334,18 @@ const LayoutRegularComponent = ( {
332
334
  description: 'This is a sample description.',
333
335
  } );
334
336
 
337
+ // Make fields disabled when control is set to disabled.
338
+ const _fields: Field< SamplePost >[] = useMemo( () => {
339
+ if ( ! disabled ) {
340
+ return fields;
341
+ }
342
+
343
+ return fields.map( ( field ) => ( {
344
+ ...field,
345
+ isDisabled: true,
346
+ } ) );
347
+ }, [ disabled ] );
348
+
335
349
  const form: Form = useMemo(
336
350
  () => ( {
337
351
  layout: getLayoutFromStoryArgs( {
@@ -363,7 +377,7 @@ const LayoutRegularComponent = ( {
363
377
  return (
364
378
  <DataForm< SamplePost >
365
379
  data={ post }
366
- fields={ fields }
380
+ fields={ _fields }
367
381
  form={ form }
368
382
  onChange={ ( edits ) =>
369
383
  setPost( ( prev ) => ( {
@@ -96,6 +96,10 @@ export default function normalizeFields< Item >(
96
96
  getElements: field.getElements,
97
97
  hasElements: hasElements( field ),
98
98
  isVisible: field.isVisible,
99
+ isDisabled:
100
+ typeof field.isDisabled === 'function'
101
+ ? field.isDisabled
102
+ : () => !! field.isDisabled,
99
103
  enableHiding: field.enableHiding ?? true,
100
104
  readOnly: field.readOnly ?? false,
101
105
  // The type provides defaults for the following props