@wordpress/dataviews 9.0.1-next.6f42e1382.0 → 9.0.1-next.a730c9c8c.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 (175) hide show
  1. package/CHANGELOG.md +7 -1
  2. package/README.md +106 -11
  3. package/build/components/dataviews-filters/input-widget.js +48 -4
  4. package/build/components/dataviews-filters/input-widget.js.map +1 -1
  5. package/build/dataform-controls/array.js +9 -7
  6. package/build/dataform-controls/array.js.map +1 -1
  7. package/build/dataform-controls/checkbox.js +31 -20
  8. package/build/dataform-controls/checkbox.js.map +1 -1
  9. package/build/dataform-controls/color.js +29 -24
  10. package/build/dataform-controls/color.js.map +1 -1
  11. package/build/dataform-controls/date.js +32 -24
  12. package/build/dataform-controls/date.js.map +1 -1
  13. package/build/dataform-controls/datetime.js +133 -19
  14. package/build/dataform-controls/datetime.js.map +1 -1
  15. package/build/dataform-controls/email.js +7 -1
  16. package/build/dataform-controls/email.js.map +1 -1
  17. package/build/dataform-controls/index.js +23 -0
  18. package/build/dataform-controls/index.js.map +1 -1
  19. package/build/dataform-controls/integer.js +47 -34
  20. package/build/dataform-controls/integer.js.map +1 -1
  21. package/build/dataform-controls/radio.js +42 -9
  22. package/build/dataform-controls/radio.js.map +1 -1
  23. package/build/dataform-controls/relative-date-control.js +6 -10
  24. package/build/dataform-controls/relative-date-control.js.map +1 -1
  25. package/build/dataform-controls/select.js +41 -10
  26. package/build/dataform-controls/select.js.map +1 -1
  27. package/build/dataform-controls/telephone.js +7 -1
  28. package/build/dataform-controls/telephone.js.map +1 -1
  29. package/build/dataform-controls/text.js +14 -2
  30. package/build/dataform-controls/text.js.map +1 -1
  31. package/build/dataform-controls/textarea.js +33 -20
  32. package/build/dataform-controls/textarea.js.map +1 -1
  33. package/build/dataform-controls/toggle-group.js +36 -6
  34. package/build/dataform-controls/toggle-group.js.map +1 -1
  35. package/build/dataform-controls/toggle.js +33 -22
  36. package/build/dataform-controls/toggle.js.map +1 -1
  37. package/build/dataform-controls/url.js +7 -1
  38. package/build/dataform-controls/url.js.map +1 -1
  39. package/build/dataform-controls/utils/validated-input.js +34 -32
  40. package/build/dataform-controls/utils/validated-input.js.map +1 -1
  41. package/build/dataforms-layouts/panel/dropdown.js +10 -14
  42. package/build/dataforms-layouts/panel/dropdown.js.map +1 -1
  43. package/build/dataforms-layouts/panel/index.js +24 -11
  44. package/build/dataforms-layouts/panel/index.js.map +1 -1
  45. package/build/dataforms-layouts/panel/modal.js +22 -27
  46. package/build/dataforms-layouts/panel/modal.js.map +1 -1
  47. package/build/dataforms-layouts/panel/summary-button.js +67 -0
  48. package/build/dataforms-layouts/panel/summary-button.js.map +1 -0
  49. package/build/normalize-fields.js +17 -0
  50. package/build/normalize-fields.js.map +1 -1
  51. package/build/types.js.map +1 -1
  52. package/build-module/components/dataviews-filters/input-widget.js +48 -4
  53. package/build-module/components/dataviews-filters/input-widget.js.map +1 -1
  54. package/build-module/dataform-controls/array.js +9 -7
  55. package/build-module/dataform-controls/array.js.map +1 -1
  56. package/build-module/dataform-controls/checkbox.js +31 -21
  57. package/build-module/dataform-controls/checkbox.js.map +1 -1
  58. package/build-module/dataform-controls/color.js +28 -24
  59. package/build-module/dataform-controls/color.js.map +1 -1
  60. package/build-module/dataform-controls/date.js +32 -24
  61. package/build-module/dataform-controls/date.js.map +1 -1
  62. package/build-module/dataform-controls/datetime.js +135 -21
  63. package/build-module/dataform-controls/datetime.js.map +1 -1
  64. package/build-module/dataform-controls/email.js +7 -1
  65. package/build-module/dataform-controls/email.js.map +1 -1
  66. package/build-module/dataform-controls/index.js +23 -0
  67. package/build-module/dataform-controls/index.js.map +1 -1
  68. package/build-module/dataform-controls/integer.js +46 -34
  69. package/build-module/dataform-controls/integer.js.map +1 -1
  70. package/build-module/dataform-controls/radio.js +44 -11
  71. package/build-module/dataform-controls/radio.js.map +1 -1
  72. package/build-module/dataform-controls/relative-date-control.js +6 -10
  73. package/build-module/dataform-controls/relative-date-control.js.map +1 -1
  74. package/build-module/dataform-controls/select.js +43 -12
  75. package/build-module/dataform-controls/select.js.map +1 -1
  76. package/build-module/dataform-controls/telephone.js +7 -1
  77. package/build-module/dataform-controls/telephone.js.map +1 -1
  78. package/build-module/dataform-controls/text.js +14 -2
  79. package/build-module/dataform-controls/text.js.map +1 -1
  80. package/build-module/dataform-controls/textarea.js +32 -20
  81. package/build-module/dataform-controls/textarea.js.map +1 -1
  82. package/build-module/dataform-controls/toggle-group.js +38 -8
  83. package/build-module/dataform-controls/toggle-group.js.map +1 -1
  84. package/build-module/dataform-controls/toggle.js +33 -23
  85. package/build-module/dataform-controls/toggle.js.map +1 -1
  86. package/build-module/dataform-controls/url.js +7 -1
  87. package/build-module/dataform-controls/url.js.map +1 -1
  88. package/build-module/dataform-controls/utils/validated-input.js +34 -33
  89. package/build-module/dataform-controls/utils/validated-input.js.map +1 -1
  90. package/build-module/dataforms-layouts/panel/dropdown.js +10 -15
  91. package/build-module/dataforms-layouts/panel/dropdown.js.map +1 -1
  92. package/build-module/dataforms-layouts/panel/index.js +24 -11
  93. package/build-module/dataforms-layouts/panel/index.js.map +1 -1
  94. package/build-module/dataforms-layouts/panel/modal.js +22 -28
  95. package/build-module/dataforms-layouts/panel/modal.js.map +1 -1
  96. package/build-module/dataforms-layouts/panel/summary-button.js +60 -0
  97. package/build-module/dataforms-layouts/panel/summary-button.js.map +1 -0
  98. package/build-module/normalize-fields.js +15 -0
  99. package/build-module/normalize-fields.js.map +1 -1
  100. package/build-module/types.js.map +1 -1
  101. package/build-types/components/dataform/stories/index.story.d.ts +3 -0
  102. package/build-types/components/dataform/stories/index.story.d.ts.map +1 -1
  103. package/build-types/components/dataviews/stories/fixtures.d.ts +4 -2
  104. package/build-types/components/dataviews/stories/fixtures.d.ts.map +1 -1
  105. package/build-types/components/dataviews-filters/input-widget.d.ts.map +1 -1
  106. package/build-types/dataform-controls/array.d.ts.map +1 -1
  107. package/build-types/dataform-controls/checkbox.d.ts.map +1 -1
  108. package/build-types/dataform-controls/color.d.ts.map +1 -1
  109. package/build-types/dataform-controls/date.d.ts.map +1 -1
  110. package/build-types/dataform-controls/datetime.d.ts.map +1 -1
  111. package/build-types/dataform-controls/email.d.ts.map +1 -1
  112. package/build-types/dataform-controls/index.d.ts +1 -1
  113. package/build-types/dataform-controls/index.d.ts.map +1 -1
  114. package/build-types/dataform-controls/integer.d.ts.map +1 -1
  115. package/build-types/dataform-controls/radio.d.ts.map +1 -1
  116. package/build-types/dataform-controls/relative-date-control.d.ts +6 -5
  117. package/build-types/dataform-controls/relative-date-control.d.ts.map +1 -1
  118. package/build-types/dataform-controls/select.d.ts.map +1 -1
  119. package/build-types/dataform-controls/telephone.d.ts.map +1 -1
  120. package/build-types/dataform-controls/text.d.ts +1 -1
  121. package/build-types/dataform-controls/text.d.ts.map +1 -1
  122. package/build-types/dataform-controls/textarea.d.ts +1 -1
  123. package/build-types/dataform-controls/textarea.d.ts.map +1 -1
  124. package/build-types/dataform-controls/toggle-group.d.ts.map +1 -1
  125. package/build-types/dataform-controls/toggle.d.ts.map +1 -1
  126. package/build-types/dataform-controls/url.d.ts.map +1 -1
  127. package/build-types/dataform-controls/utils/validated-input.d.ts +4 -4
  128. package/build-types/dataform-controls/utils/validated-input.d.ts.map +1 -1
  129. package/build-types/dataforms-layouts/panel/dropdown.d.ts +2 -1
  130. package/build-types/dataforms-layouts/panel/dropdown.d.ts.map +1 -1
  131. package/build-types/dataforms-layouts/panel/index.d.ts.map +1 -1
  132. package/build-types/dataforms-layouts/panel/modal.d.ts +2 -1
  133. package/build-types/dataforms-layouts/panel/modal.d.ts.map +1 -1
  134. package/build-types/dataforms-layouts/panel/summary-button.d.ts +15 -0
  135. package/build-types/dataforms-layouts/panel/summary-button.d.ts.map +1 -0
  136. package/build-types/field-types/stories/index.story.d.ts.map +1 -1
  137. package/build-types/normalize-fields.d.ts +3 -0
  138. package/build-types/normalize-fields.d.ts.map +1 -1
  139. package/build-types/types.d.ts +66 -3
  140. package/build-types/types.d.ts.map +1 -1
  141. package/build-wp/index.js +1468 -1422
  142. package/package.json +16 -15
  143. package/src/components/dataform/stories/index.story.tsx +436 -7
  144. package/src/components/dataviews/stories/fixtures.tsx +99 -41
  145. package/src/components/dataviews/stories/index.story.tsx +1 -1
  146. package/src/components/dataviews-filters/input-widget.tsx +44 -5
  147. package/src/components/dataviews-picker/stories/index.story.tsx +1 -1
  148. package/src/dataform-controls/array.tsx +4 -6
  149. package/src/dataform-controls/checkbox.tsx +41 -24
  150. package/src/dataform-controls/color.tsx +33 -24
  151. package/src/dataform-controls/date.tsx +47 -21
  152. package/src/dataform-controls/datetime.tsx +171 -23
  153. package/src/dataform-controls/email.tsx +9 -1
  154. package/src/dataform-controls/index.tsx +26 -0
  155. package/src/dataform-controls/integer.tsx +82 -49
  156. package/src/dataform-controls/radio.tsx +53 -11
  157. package/src/dataform-controls/relative-date-control.tsx +11 -10
  158. package/src/dataform-controls/select.tsx +53 -10
  159. package/src/dataform-controls/telephone.tsx +9 -1
  160. package/src/dataform-controls/text.tsx +18 -1
  161. package/src/dataform-controls/textarea.tsx +38 -24
  162. package/src/dataform-controls/toggle-group.tsx +50 -10
  163. package/src/dataform-controls/toggle.tsx +41 -24
  164. package/src/dataform-controls/url.tsx +9 -1
  165. package/src/dataform-controls/utils/validated-input.tsx +50 -50
  166. package/src/dataforms-layouts/panel/dropdown.tsx +12 -23
  167. package/src/dataforms-layouts/panel/index.tsx +39 -16
  168. package/src/dataforms-layouts/panel/modal.tsx +24 -30
  169. package/src/dataforms-layouts/panel/summary-button.tsx +92 -0
  170. package/src/field-types/stories/index.story.tsx +89 -1
  171. package/src/normalize-fields.ts +18 -0
  172. package/src/test/filter-and-sort-data-view.js +148 -138
  173. package/src/test/normalize-fields.ts +114 -0
  174. package/src/types.ts +73 -3
  175. package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
- ## 9.0.0-next.0 (2025-09-12)
5
+ ## 9.0.0-next.0 (2025-09-17)
6
6
 
7
7
  ### Breaking changes
8
8
 
@@ -11,6 +11,7 @@
11
11
 
12
12
  ### Features
13
13
 
14
+ - Field API: introduce `setValue` to fix DataViews filters and DataForm panel layout (modal) when working with nested data. [#71604](https://github.com/WordPress/gutenberg/pull/71604)
14
15
  - Introduce a new `DataViewsPicker` component. [#70971](https://github.com/WordPress/gutenberg/pull/70971)
15
16
  - Dataform: Add new `telephone` field type and field control. [#71498](https://github.com/WordPress/gutenberg/pull/71498)
16
17
  - DataForm: introduce a new `row` layout, check the README for details. [#71124](https://github.com/WordPress/gutenberg/pull/71124)
@@ -18,6 +19,11 @@
18
19
  - Dataform: Add new `password` field type and field control. [#71545](https://github.com/WordPress/gutenberg/pull/71545)
19
20
  - DataForm: Add a textarea control for use with the `text` field type ([#71495](https://github.com/WordPress/gutenberg/pull/71495))
20
21
  - DataViews: support groupBy in the list layout. [#71548](https://github.com/WordPress/gutenberg/pull/71548)
22
+ - DataForm: support validation in select control [#71665](https://github.com/WordPress/gutenberg/pull/71665)
23
+ - DataForm: support validation in toggleGroup control. ([#71666](https://github.com/WordPress/gutenberg/pull/71666))
24
+ - DataForm: Add object configuration support for Edit property with some options. ([#71582](https://github.com/WordPress/gutenberg/pull/71582))
25
+ - DataForm: Add summary field support for composed fields. ([#71614](https://github.com/WordPress/gutenberg/pull/71614))
26
+ - DataForm: update radio control to support `required` and `custom` validation. [#71664](https://github.com/WordPress/gutenberg/pull/71664)
21
27
 
22
28
  ### Bug Fixes
23
29
 
package/README.md CHANGED
@@ -989,24 +989,119 @@ Example:
989
989
  }
990
990
  ```
991
991
 
992
- ### `getValue`
992
+ ### `getValue` and `setValue`
993
993
 
994
- React component that returns the value of a field. This value is used to sort or filter the fields.
994
+ These functions control how field values are read from and written to your data structure.
995
995
 
996
- - Type: React component.
996
+ Both functions are optional and automatically generated from the field's `id` when not provided. The `id` is treated as a dot-notation path (e.g., `"user.profile.name"` accesses `item.user.profile.name`).
997
+
998
+ #### `getValue`
999
+
1000
+ Function that extracts the field value from an item. This value is used to sort, filter, and display the field.
1001
+
1002
+ - Type: `function`.
997
1003
  - Optional.
998
- - Defaults to `item[ id ]`.
999
- - Props:
1000
- - `item` value to be processed.
1001
- - Returns a value that represents the field.
1004
+ - Args:
1005
+ - `item`: the data item to be processed.
1006
+ - Returns the field's value.
1002
1007
 
1003
- Example:
1008
+ #### `setValue`
1009
+
1010
+ Function that creates a partial item object with updated field values. This is used by DataForm for editing operations and determines the structure of data passed to the `onChange` callback.
1011
+
1012
+ - Type: `function`.
1013
+ - Optional.
1014
+ - Args:
1015
+ - `item`: the current item being edited.
1016
+ - `value`: the new value to be set for the field.
1017
+ - Returns a partial item object with the changes to be applied.
1018
+
1019
+ #### Simple field access
1020
+
1021
+ For basic field access, you only need to specify the field `id`. Both `getValue` and `setValue` are automatically generated:
1004
1022
 
1005
1023
  ```js
1024
+ // Data structure
1025
+ const item = {
1026
+ title: 'Hello World',
1027
+ author: 'John Doe'
1028
+ };
1029
+
1030
+ // Field definition
1006
1031
  {
1007
- getValue: ( { item } ) => {
1008
- /* The field's value. */
1009
- };
1032
+ id: 'title',
1033
+ label: 'Title'
1034
+ // getValue: automatically becomes ( { item } ) => item.title
1035
+ // setValue: automatically becomes ( { value } ) => ( { title: value } )
1036
+ }
1037
+ ```
1038
+
1039
+ #### Nested data access
1040
+
1041
+ Use dot notation in the field `id` to access nested properties:
1042
+
1043
+ ```js
1044
+ // Data structure
1045
+ const item = {
1046
+ user: {
1047
+ profile: {
1048
+ name: 'John Doe',
1049
+ email: 'john@example.com'
1050
+ }
1051
+ }
1052
+ };
1053
+
1054
+ // Field definition - using dot notation (automatic)
1055
+ {
1056
+ id: 'user.profile.name',
1057
+ label: 'User Name'
1058
+ // getValue: automatically becomes ( { item } ) => item.user.profile.name
1059
+ // setValue: automatically becomes ( { value } ) => ( { user: { profile: { name: value } } } )
1060
+ }
1061
+
1062
+ // Alternative - using simple ID with custom functions
1063
+ {
1064
+ id: 'userName',
1065
+ label: 'User Name',
1066
+ getValue: ( { item } ) => item.user.profile.name,
1067
+ setValue: ( { value } ) => ( {
1068
+ user: {
1069
+ profile: { name: value }
1070
+ }
1071
+ } )
1072
+ }
1073
+ ```
1074
+
1075
+ #### Custom data transformation
1076
+
1077
+ Provide custom `getValue` and `setValue` functions when you need to transform data between the storage format and display format:
1078
+
1079
+ ```js
1080
+ // Data structure
1081
+ const item = {
1082
+ user: {
1083
+ preferences: {
1084
+ notifications: true
1085
+ }
1086
+ }
1087
+ };
1088
+
1089
+ // Field definition - transform boolean to string options
1090
+ {
1091
+ id: 'notifications',
1092
+ label: 'Notifications',
1093
+ Edit: 'radio',
1094
+ elements: [
1095
+ { label: 'Enabled', value: 'enabled' },
1096
+ { label: 'Disabled', value: 'disabled' }
1097
+ ],
1098
+ getValue: ( { item } ) =>
1099
+ item.user.preferences.notifications === true ? 'enabled' : 'disabled',
1100
+ setValue: ( { value } ) => ( {
1101
+ user: {
1102
+ preferences: { notifications: value === 'enabled' }
1103
+ }
1104
+ } )
1010
1105
  }
1011
1106
  ```
1012
1107
 
@@ -30,12 +30,54 @@ function InputWidget({
30
30
  fields
31
31
  }) {
32
32
  const currentFilter = view.filters?.find(f => f.field === filter.field);
33
- const field = fields.find(f => f.id === filter.field);
34
33
  const currentValue = (0, _utils.getCurrentValue)(filter, currentFilter);
34
+
35
+ /*
36
+ * We are reusing the field.Edit component for filters. By doing so,
37
+ * we get for free a filter control specific to the field type
38
+ * and other aspects of the field API (Edit control configuration, etc.).
39
+ *
40
+ * This approach comes with an issue: the field.Edit controls work with getValue
41
+ * and setValue methods, which take an item (Item) as parameter. But, at this point,
42
+ * we don't have an item and we don't know how to create one, either.
43
+ *
44
+ * So, what we do is to prepare the data and the relevant field configuration
45
+ * as if Item was a plain object whose keys are the field ids:
46
+ *
47
+ * {
48
+ * [ fieldOne.id ]: value,
49
+ * [ fieldTwo.id ]: value,
50
+ * }
51
+ *
52
+ */
53
+ const field = (0, _element.useMemo)(() => {
54
+ const currentField = fields.find(f => f.id === filter.field);
55
+ if (currentField) {
56
+ return {
57
+ ...currentField,
58
+ // Deactivate validation for filters.
59
+ isValid: {
60
+ required: false,
61
+ custom: () => null
62
+ },
63
+ // Configure getValue/setValue as if Item was a plain object.
64
+ getValue: ({
65
+ item
66
+ }) => item[currentField.id],
67
+ setValue: ({
68
+ value
69
+ }) => ({
70
+ [currentField.id]: value
71
+ })
72
+ };
73
+ }
74
+ return currentField;
75
+ }, [fields, filter.field]);
35
76
  const data = (0, _element.useMemo)(() => {
36
77
  var _view$filters;
37
- return ((_view$filters = view.filters) !== null && _view$filters !== void 0 ? _view$filters : []).reduce((acc, f) => {
38
- acc[f.field] = f.value;
78
+ return ((_view$filters = view.filters) !== null && _view$filters !== void 0 ? _view$filters : []).reduce((acc, activeFilter) => {
79
+ // We can now assume the field is stored as a Item prop.
80
+ acc[activeFilter.field] = activeFilter.value;
39
81
  return acc;
40
82
  }, {});
41
83
  }, [view.filters]);
@@ -44,7 +86,9 @@ function InputWidget({
44
86
  if (!field || !currentFilter) {
45
87
  return;
46
88
  }
47
- const nextValue = updatedData[field.id];
89
+ const nextValue = field.getValue({
90
+ item: updatedData
91
+ });
48
92
  if ((0, _es.default)(nextValue, currentValue)) {
49
93
  return;
50
94
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_es","_interopRequireDefault","require","_compose","_element","_components","_utils","_jsxRuntime","InputWidget","filter","view","onChangeView","fields","currentFilter","filters","find","f","field","id","currentValue","getCurrentValue","data","useMemo","_view$filters","reduce","acc","value","handleChange","useEvent","updatedData","_view$filters2","nextValue","fastDeepEqual","map","_filter","operator","operators","undefined","Edit","jsx","Flex","className","gap","direction","children","hideLabelFromVision","onChange"],"sources":["@wordpress/dataviews/src/components/dataviews-filters/input-widget.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport fastDeepEqual from 'fast-deep-equal/es6';\n\n/**\n * WordPress dependencies\n */\nimport { useEvent } from '@wordpress/compose';\nimport { useMemo } from '@wordpress/element';\nimport { Flex } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport type { View, NormalizedFilter, NormalizedField } from '../../types';\nimport { getCurrentValue } from './utils';\n\ninterface UserInputWidgetProps {\n\tview: View;\n\tfilter: NormalizedFilter;\n\tonChangeView: ( view: View ) => void;\n\tfields: NormalizedField< any >[];\n}\n\nexport default function InputWidget( {\n\tfilter,\n\tview,\n\tonChangeView,\n\tfields,\n}: UserInputWidgetProps ) {\n\tconst currentFilter = view.filters?.find(\n\t\t( f ) => f.field === filter.field\n\t);\n\n\tconst field = fields.find( ( f ) => f.id === filter.field );\n\tconst currentValue = getCurrentValue( filter, currentFilter );\n\tconst data = useMemo( () => {\n\t\treturn ( view.filters ?? [] ).reduce(\n\t\t\t( acc, f ) => {\n\t\t\t\tacc[ f.field ] = f.value;\n\t\t\t\treturn acc;\n\t\t\t},\n\t\t\t{} as Record< string, any >\n\t\t);\n\t}, [ view.filters ] );\n\n\tconst handleChange = useEvent( ( updatedData: Record< string, any > ) => {\n\t\tif ( ! field || ! currentFilter ) {\n\t\t\treturn;\n\t\t}\n\t\tconst nextValue = updatedData[ field.id ];\n\t\tif ( fastDeepEqual( nextValue, currentValue ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tonChangeView( {\n\t\t\t...view,\n\t\t\tfilters: ( view.filters ?? [] ).map( ( _filter ) =>\n\t\t\t\t_filter.field === filter.field\n\t\t\t\t\t? {\n\t\t\t\t\t\t\t..._filter,\n\t\t\t\t\t\t\toperator:\n\t\t\t\t\t\t\t\tcurrentFilter.operator || filter.operators[ 0 ],\n\t\t\t\t\t\t\t// Consider empty strings as undefined:\n\t\t\t\t\t\t\t//\n\t\t\t\t\t\t\t// - undefined as value means the filter is unset: the filter widget displays no value and the search returns all records\n\t\t\t\t\t\t\t// - empty string as value means \"search empty string\": returns only the records that have an empty string as value\n\t\t\t\t\t\t\t//\n\t\t\t\t\t\t\t// In practice, this means the filter will not be able to find an empty string as the value.\n\t\t\t\t\t\t\tvalue: nextValue === '' ? undefined : nextValue,\n\t\t\t\t\t }\n\t\t\t\t\t: _filter\n\t\t\t),\n\t\t} );\n\t} );\n\n\tif ( ! field || ! field.Edit || ! currentFilter ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Flex\n\t\t\tclassName=\"dataviews-filters__user-input-widget\"\n\t\t\tgap={ 2.5 }\n\t\t\tdirection=\"column\"\n\t\t>\n\t\t\t<field.Edit\n\t\t\t\thideLabelFromVision\n\t\t\t\tdata={ data }\n\t\t\t\tfield={ field }\n\t\t\t\toperator={ currentFilter.operator }\n\t\t\t\tonChange={ handleChange }\n\t\t\t/>\n\t\t</Flex>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,GAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AAMA,IAAAI,MAAA,GAAAJ,OAAA;AAA0C,IAAAK,WAAA,GAAAL,OAAA;AAhB1C;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;;AAWe,SAASM,WAAWA,CAAE;EACpCC,MAAM;EACNC,IAAI;EACJC,YAAY;EACZC;AACqB,CAAC,EAAG;EACzB,MAAMC,aAAa,GAAGH,IAAI,CAACI,OAAO,EAAEC,IAAI,CACrCC,CAAC,IAAMA,CAAC,CAACC,KAAK,KAAKR,MAAM,CAACQ,KAC7B,CAAC;EAED,MAAMA,KAAK,GAAGL,MAAM,CAACG,IAAI,CAAIC,CAAC,IAAMA,CAAC,CAACE,EAAE,KAAKT,MAAM,CAACQ,KAAM,CAAC;EAC3D,MAAME,YAAY,GAAG,IAAAC,sBAAe,EAAEX,MAAM,EAAEI,aAAc,CAAC;EAC7D,MAAMQ,IAAI,GAAG,IAAAC,gBAAO,EAAE,MAAM;IAAA,IAAAC,aAAA;IAC3B,OAAO,EAAAA,aAAA,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SAAS,EAAC,sCAAsC;IAChDC,GAAG,EAAG,GAAK;IACXC,SAAS,EAAC,QAAQ;IAAAC,QAAA,eAElB,IAAArC,WAAA,CAAAgC,GAAA,EAACtB,KAAK,CAACqB,IAAI;MACVO,mBAAmB;MACnBxB,IAAI,EAAGA,IAAM;MACbJ,KAAK,EAAGA,KAAO;MACfkB,QAAQ,EAAGtB,aAAa,CAACsB,QAAU;MACnCW,QAAQ,EAAGnB;IAAc,CACzB;EAAC,CACG,CAAC;AAET","ignoreList":[]}
1
+ {"version":3,"names":["_es","_interopRequireDefault","require","_compose","_element","_components","_utils","_jsxRuntime","InputWidget","filter","view","onChangeView","fields","currentFilter","filters","find","f","field","currentValue","getCurrentValue","useMemo","currentField","id","isValid","required","custom","getValue","item","setValue","value","data","_view$filters","reduce","acc","activeFilter","handleChange","useEvent","updatedData","_view$filters2","nextValue","fastDeepEqual","map","_filter","operator","operators","undefined","Edit","jsx","Flex","className","gap","direction","children","hideLabelFromVision","onChange"],"sources":["@wordpress/dataviews/src/components/dataviews-filters/input-widget.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport fastDeepEqual from 'fast-deep-equal/es6';\n\n/**\n * WordPress dependencies\n */\nimport { useEvent } from '@wordpress/compose';\nimport { useMemo } from '@wordpress/element';\nimport { Flex } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport type { View, NormalizedFilter, NormalizedField } from '../../types';\nimport { getCurrentValue } from './utils';\n\ninterface UserInputWidgetProps {\n\tview: View;\n\tfilter: NormalizedFilter;\n\tonChangeView: ( view: View ) => void;\n\tfields: NormalizedField< any >[];\n}\n\nexport default function InputWidget( {\n\tfilter,\n\tview,\n\tonChangeView,\n\tfields,\n}: UserInputWidgetProps ) {\n\tconst currentFilter = view.filters?.find(\n\t\t( f ) => f.field === filter.field\n\t);\n\tconst currentValue = getCurrentValue( filter, currentFilter );\n\n\t/*\n\t * We are reusing the field.Edit component for filters. By doing so,\n\t * we get for free a filter control specific to the field type\n\t * and other aspects of the field API (Edit control configuration, etc.).\n\t *\n\t * This approach comes with an issue: the field.Edit controls work with getValue\n\t * and setValue methods, which take an item (Item) as parameter. But, at this point,\n\t * we don't have an item and we don't know how to create one, either.\n\t *\n\t * So, what we do is to prepare the data and the relevant field configuration\n\t * as if Item was a plain object whose keys are the field ids:\n\t *\n\t * {\n\t * [ fieldOne.id ]: value,\n\t * [ fieldTwo.id ]: value,\n\t * }\n\t *\n\t */\n\tconst field = useMemo( () => {\n\t\tconst currentField = fields.find( ( f ) => f.id === filter.field );\n\t\tif ( currentField ) {\n\t\t\treturn {\n\t\t\t\t...currentField,\n\t\t\t\t// Deactivate validation for filters.\n\t\t\t\tisValid: {\n\t\t\t\t\trequired: false,\n\t\t\t\t\tcustom: () => null,\n\t\t\t\t},\n\t\t\t\t// Configure getValue/setValue as if Item was a plain object.\n\t\t\t\tgetValue: ( { item }: { item: any } ) =>\n\t\t\t\t\titem[ currentField.id ],\n\t\t\t\tsetValue: ( { value }: { value: any } ) => ( {\n\t\t\t\t\t[ currentField.id ]: value,\n\t\t\t\t} ),\n\t\t\t};\n\t\t}\n\t\treturn currentField;\n\t}, [ fields, filter.field ] );\n\n\tconst data = useMemo( () => {\n\t\treturn ( view.filters ?? [] ).reduce(\n\t\t\t( acc, activeFilter ) => {\n\t\t\t\t// We can now assume the field is stored as a Item prop.\n\t\t\t\tacc[ activeFilter.field ] = activeFilter.value;\n\t\t\t\treturn acc;\n\t\t\t},\n\t\t\t{} as Record< string, any >\n\t\t);\n\t}, [ view.filters ] );\n\n\tconst handleChange = useEvent( ( updatedData: Record< string, any > ) => {\n\t\tif ( ! field || ! currentFilter ) {\n\t\t\treturn;\n\t\t}\n\t\tconst nextValue = field.getValue( { item: updatedData } );\n\t\tif ( fastDeepEqual( nextValue, currentValue ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tonChangeView( {\n\t\t\t...view,\n\t\t\tfilters: ( view.filters ?? [] ).map( ( _filter ) =>\n\t\t\t\t_filter.field === filter.field\n\t\t\t\t\t? {\n\t\t\t\t\t\t\t..._filter,\n\t\t\t\t\t\t\toperator:\n\t\t\t\t\t\t\t\tcurrentFilter.operator || filter.operators[ 0 ],\n\t\t\t\t\t\t\t// Consider empty strings as undefined:\n\t\t\t\t\t\t\t//\n\t\t\t\t\t\t\t// - undefined as value means the filter is unset: the filter widget displays no value and the search returns all records\n\t\t\t\t\t\t\t// - empty string as value means \"search empty string\": returns only the records that have an empty string as value\n\t\t\t\t\t\t\t//\n\t\t\t\t\t\t\t// In practice, this means the filter will not be able to find an empty string as the value.\n\t\t\t\t\t\t\tvalue: nextValue === '' ? undefined : nextValue,\n\t\t\t\t\t }\n\t\t\t\t\t: _filter\n\t\t\t),\n\t\t} );\n\t} );\n\n\tif ( ! field || ! field.Edit || ! currentFilter ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Flex\n\t\t\tclassName=\"dataviews-filters__user-input-widget\"\n\t\t\tgap={ 2.5 }\n\t\t\tdirection=\"column\"\n\t\t>\n\t\t\t<field.Edit\n\t\t\t\thideLabelFromVision\n\t\t\t\tdata={ data }\n\t\t\t\tfield={ field }\n\t\t\t\toperator={ currentFilter.operator }\n\t\t\t\tonChange={ handleChange }\n\t\t\t/>\n\t\t</Flex>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,GAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AAMA,IAAAI,MAAA,GAAAJ,OAAA;AAA0C,IAAAK,WAAA,GAAAL,OAAA;AAhB1C;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;;AAWe,SAASM,WAAWA,CAAE;EACpCC,MAAM;EACNC,IAAI;EACJC,YAAY;EACZC;AACqB,CAAC,EAAG;EACzB,MAAMC,aAAa,GAAGH,IAAI,CAACI,OAAO,EAAEC,IAAI,CACrCC,CAAC,IAAMA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MACnCW,QAAQ,EAAGnB;IAAc,CACzB;EAAC,CACG,CAAC;AAET","ignoreList":[]}
@@ -23,12 +23,13 @@ function ArrayControl({
23
23
  }) {
24
24
  var _elements$map;
25
25
  const {
26
- id,
27
26
  label,
28
27
  placeholder,
29
- elements
28
+ elements,
29
+ getValue,
30
+ setValue
30
31
  } = field;
31
- const value = field.getValue({
32
+ const value = getValue({
32
33
  item: data
33
34
  });
34
35
  const findElementByValue = (0, _element.useCallback)(suggestionValue => {
@@ -52,10 +53,11 @@ function ArrayControl({
52
53
  const tokenByLabel = findElementByLabel(token);
53
54
  return tokenByLabel?.value || token;
54
55
  });
55
- onChange({
56
- [id]: stringTokens
57
- });
58
- }, [id, onChange, findElementByLabel]);
56
+ onChange(setValue({
57
+ item: data,
58
+ value: stringTokens
59
+ }));
60
+ }, [onChange, setValue, data, findElementByLabel]);
59
61
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.FormTokenField, {
60
62
  label: hideLabelFromVision ? undefined : label,
61
63
  value: arrayValue,
@@ -1 +1 @@
1
- {"version":3,"names":["_components","require","_element","_jsxRuntime","ArrayControl","data","field","onChange","hideLabelFromVision","_elements$map","id","label","placeholder","elements","value","getValue","item","findElementByValue","useCallback","suggestionValue","find","suggestion","findElementByLabel","suggestionLabel","arrayValue","useMemo","Array","isArray","map","token","tokenLabel","onChangeControl","tokens","stringTokens","tokenByLabel","jsx","FormTokenField","undefined","suggestions","__experimentalExpandOnFocus","length","__next40pxDefaultSize","__nextHasNoMarginBottom"],"sources":["@wordpress/dataviews/src/dataform-controls/array.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { FormTokenField } from '@wordpress/components';\nimport { useCallback, useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type { DataFormControlProps } from '../types';\n\nexport default function ArrayControl< Item >( {\n\tdata,\n\tfield,\n\tonChange,\n\thideLabelFromVision,\n}: DataFormControlProps< Item > ) {\n\tconst { id, label, placeholder, elements } = field;\n\tconst value = field.getValue( { item: data } );\n\n\tconst findElementByValue = useCallback(\n\t\t( suggestionValue: string ) => {\n\t\t\treturn elements?.find(\n\t\t\t\t( suggestion ) => suggestion.value === suggestionValue\n\t\t\t);\n\t\t},\n\t\t[ elements ]\n\t);\n\n\tconst findElementByLabel = useCallback(\n\t\t( suggestionLabel: string ) => {\n\t\t\treturn elements?.find(\n\t\t\t\t( suggestion ) => suggestion.label === suggestionLabel\n\t\t\t);\n\t\t},\n\t\t[ elements ]\n\t);\n\n\t// Ensure value is an array\n\tconst arrayValue = useMemo(\n\t\t() =>\n\t\t\tArray.isArray( value )\n\t\t\t\t? value.map( ( token ) => {\n\t\t\t\t\t\tconst tokenLabel = findElementByValue( token )?.label;\n\t\t\t\t\t\treturn tokenLabel || token;\n\t\t\t\t } )\n\t\t\t\t: [],\n\t\t[ value, findElementByValue ]\n\t);\n\n\tconst onChangeControl = useCallback(\n\t\t( tokens: ( string | { value: string } )[] ) => {\n\t\t\t// Convert TokenItem objects to strings\n\t\t\tconst stringTokens = tokens.map( ( token ) => {\n\t\t\t\tif ( typeof token !== 'string' ) {\n\t\t\t\t\treturn token.value;\n\t\t\t\t}\n\n\t\t\t\tconst tokenByLabel = findElementByLabel( token );\n\n\t\t\t\treturn tokenByLabel?.value || token;\n\t\t\t} );\n\n\t\t\tonChange( {\n\t\t\t\t[ id ]: stringTokens,\n\t\t\t} );\n\t\t},\n\t\t[ id, onChange, findElementByLabel ]\n\t);\n\n\treturn (\n\t\t<FormTokenField\n\t\t\tlabel={ hideLabelFromVision ? undefined : label }\n\t\t\tvalue={ arrayValue }\n\t\t\tonChange={ onChangeControl }\n\t\t\tplaceholder={ placeholder }\n\t\t\tsuggestions={\n\t\t\t\telements?.map( ( suggestion ) => suggestion.label ) ?? []\n\t\t\t}\n\t\t\t__experimentalExpandOnFocus={ elements && elements.length > 0 }\n\t\t\t__next40pxDefaultSize\n\t\t\t__nextHasNoMarginBottom\n\t\t/>\n\t);\n}\n"],"mappings":";;;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,GAAG,CAAIC,KAAK,IAAM;MAC7C,IAAK,OAAOA,KAAK,KAAK,QAAQ,EAAG;QAChC,OAAOA,KAAK,CAACf,KAAK;MACnB;MAEA,MAAMoB,YAAY,GAAGZ,kBAAkB,CAAEO,KAAM,CAAC;MAEhD,OAAOK,YAAY,EAAEpB,KAAK,IAAIe,KAAK;IACpC,CAAE,CAAC;IAEHtB,QAAQ,CAAE;MACT,CAAEG,EAAE,GAAIuB;IACT,CAAE,CAAC;EACJ,CAAC,EACD,CAAEvB,EAAE,EAAEH,QAAQ,EAAEe,kBAAkB,CACnC,CAAC;EAED,oBACC,IAAAnB,WAAA,CAAAgC,GAAA,EAACnC,WAAA,CAAAoC,cAAc;IACdzB,KAAK,EAAGH,mBAAmB,GAAG6B,SAAS,GAAG1B,KAAO;IACjDG,KAAK,EAAGU,UAAY;IACpBjB,QAAQ,EAAGwB,eAAiB;IAC5BnB,WAAW,EAAGA,WAAa;IAC3B0B,WAAW,GAAA7B,aAAA,GACVI,QAAQ,EAAEe,GAAG,CAAIP,UAAU,IAAMA,UAAU,CAACV,KAAM,CAAC,cAAAF,aAAA,cAAAA,aAAA,GAAI,EACvD;IACD8B,2BAA2B,EAAG1B,QAAQ,IAAIA,QAAQ,CAAC2B,MAAM,GAAG,CAAG;IAC/DC,qBAAqB;IACrBC,uBAAuB;EAAA,CACvB,CAAC;AAEJ","ignoreList":[]}
1
+ {"version":3,"names":["_components","require","_element","_jsxRuntime","ArrayControl","data","field","onChange","hideLabelFromVision","_elements$map","label","placeholder","elements","getValue","setValue","value","item","findElementByValue","useCallback","suggestionValue","find","suggestion","findElementByLabel","suggestionLabel","arrayValue","useMemo","Array","isArray","map","token","tokenLabel","onChangeControl","tokens","stringTokens","tokenByLabel","jsx","FormTokenField","undefined","suggestions","__experimentalExpandOnFocus","length","__next40pxDefaultSize","__nextHasNoMarginBottom"],"sources":["@wordpress/dataviews/src/dataform-controls/array.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { FormTokenField } from '@wordpress/components';\nimport { useCallback, useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type { DataFormControlProps } from '../types';\n\nexport default function ArrayControl< Item >( {\n\tdata,\n\tfield,\n\tonChange,\n\thideLabelFromVision,\n}: DataFormControlProps< Item > ) {\n\tconst { label, placeholder, elements, getValue, setValue } = field;\n\tconst value = getValue( { item: data } );\n\n\tconst findElementByValue = useCallback(\n\t\t( suggestionValue: string ) => {\n\t\t\treturn elements?.find(\n\t\t\t\t( suggestion ) => suggestion.value === suggestionValue\n\t\t\t);\n\t\t},\n\t\t[ elements ]\n\t);\n\n\tconst findElementByLabel = useCallback(\n\t\t( suggestionLabel: string ) => {\n\t\t\treturn elements?.find(\n\t\t\t\t( suggestion ) => suggestion.label === suggestionLabel\n\t\t\t);\n\t\t},\n\t\t[ elements ]\n\t);\n\n\t// Ensure value is an array\n\tconst arrayValue = useMemo(\n\t\t() =>\n\t\t\tArray.isArray( value )\n\t\t\t\t? value.map( ( token ) => {\n\t\t\t\t\t\tconst tokenLabel = findElementByValue( token )?.label;\n\t\t\t\t\t\treturn tokenLabel || token;\n\t\t\t\t } )\n\t\t\t\t: [],\n\t\t[ value, findElementByValue ]\n\t);\n\n\tconst onChangeControl = useCallback(\n\t\t( tokens: ( string | { value: string } )[] ) => {\n\t\t\t// Convert TokenItem objects to strings\n\t\t\tconst stringTokens = tokens.map( ( token ) => {\n\t\t\t\tif ( typeof token !== 'string' ) {\n\t\t\t\t\treturn token.value;\n\t\t\t\t}\n\n\t\t\t\tconst tokenByLabel = findElementByLabel( token );\n\n\t\t\t\treturn tokenByLabel?.value || token;\n\t\t\t} );\n\n\t\t\tonChange( setValue( { item: data, value: stringTokens } ) );\n\t\t},\n\t\t[ onChange, setValue, data, findElementByLabel ]\n\t);\n\n\treturn (\n\t\t<FormTokenField\n\t\t\tlabel={ hideLabelFromVision ? undefined : label }\n\t\t\tvalue={ arrayValue }\n\t\t\tonChange={ onChangeControl }\n\t\t\tplaceholder={ placeholder }\n\t\t\tsuggestions={\n\t\t\t\telements?.map( ( suggestion ) => suggestion.label ) ?? []\n\t\t\t}\n\t\t\t__experimentalExpandOnFocus={ elements && elements.length > 0 }\n\t\t\t__next40pxDefaultSize\n\t\t\t__nextHasNoMarginBottom\n\t\t/>\n\t);\n}\n"],"mappings":";;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAA0D,IAAAE,WAAA,GAAAF,OAAA;AAJ1D;AACA;AACA;;AAIA;AACA;AACA;;AAGe,SAASG,YAAYA,CAAU;EAC7CC,IAAI;EACJC,KAAK;EACLC,QAAQ;EACRC;AAC6B,CAAC,EAAG;EAAA,IAAAC,aAAA;EACjC,MAAM;IAAEC,KAAK;IAAEC,WAAW;IAAEC,QAAQ;IAAEC,QAAQ;IAAEC;EAAS,CAAC,GAAGR,KAAK;EAClE,MAAMS,KAAK,GAAGF,QAAQ,CAAE;IAAEG,IAAI,EAAEX;EAAK,CAAE,CAAC;EAExC,MAAMY,kBAAkB,GAAG,IAAAC,oBAAW,EACnCC,eAAuB,IAAM;IAC9B,OAAOP,QAAQ,EAAEQ,IAAI,CAClBC,UAAU,IAAMA,UAAU,CAACN,KAAK,KAAKI,eACxC,CAAC;EACF,CAAC,EACD,CAAEP,QAAQ,CACX,CAAC;EAED,MAAMU,kBAAkB,GAAG,IAAAJ,oBAAW,EACnCK,eAAuB,IAAM;IAC9B,OAAOX,QAAQ,EAAEQ,IAAI,CAClBC,UAAU,IAAMA,UAAU,CAACX,KAAK,KAAKa,eACxC,CAAC;EACF,CAAC,EACD,CAAEX,QAAQ,CACX,CAAC;;EAED;EACA,MAAMY,UAAU,GAAG,IAAAC,gBAAO,EACzB,MACCC,KAAK,CAACC,OAAO,CAAEZ,KAAM,CAAC,GACnBA,KAAK,CAACa,GAAG,CAAIC,KAAK,IAAM;IACxB,MAAMC,UAAU,GAAGb,kBAAkB,CAAEY,KAAM,CAAC,EAAEnB,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
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports.default = Checkbox;
8
+ var _deepmerge = _interopRequireDefault(require("deepmerge"));
7
9
  var _components = require("@wordpress/components");
8
10
  var _element = require("@wordpress/element");
9
11
  var _lockUnlock = require("../lock-unlock");
10
12
  var _jsxRuntime = require("react/jsx-runtime");
13
+ /**
14
+ * External dependencies
15
+ */
16
+
11
17
  /**
12
18
  * WordPress dependencies
13
19
  */
@@ -26,28 +32,37 @@ function Checkbox({
26
32
  hideLabelFromVision
27
33
  }) {
28
34
  const {
29
- id,
30
35
  getValue,
36
+ setValue,
31
37
  label,
32
38
  description
33
39
  } = field;
34
40
  const [customValidity, setCustomValidity] = (0, _element.useState)(undefined);
41
+ const onChangeControl = (0, _element.useCallback)(() => {
42
+ onChange(setValue({
43
+ item: data,
44
+ value: !getValue({
45
+ item: data
46
+ })
47
+ }));
48
+ }, [data, getValue, onChange, setValue]);
49
+ const onValidateControl = (0, _element.useCallback)(newValue => {
50
+ const message = field.isValid?.custom?.((0, _deepmerge.default)(data, setValue({
51
+ item: data,
52
+ value: newValue
53
+ })), field);
54
+ if (message) {
55
+ setCustomValidity({
56
+ type: 'invalid',
57
+ message
58
+ });
59
+ return;
60
+ }
61
+ setCustomValidity(undefined);
62
+ }, [data, field, setValue]);
35
63
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(ValidatedCheckboxControl, {
36
64
  required: !!field.isValid?.required,
37
- onValidate: newValue => {
38
- const message = field.isValid?.custom?.({
39
- ...data,
40
- [id]: newValue
41
- }, field);
42
- if (message) {
43
- setCustomValidity({
44
- type: 'invalid',
45
- message
46
- });
47
- return;
48
- }
49
- setCustomValidity(undefined);
50
- },
65
+ onValidate: onValidateControl,
51
66
  customValidity: customValidity,
52
67
  hidden: hideLabelFromVision,
53
68
  label: label,
@@ -55,11 +70,7 @@ function Checkbox({
55
70
  checked: getValue({
56
71
  item: data
57
72
  }),
58
- onChange: () => onChange({
59
- [id]: !getValue({
60
- item: data
61
- })
62
- })
73
+ onChange: onChangeControl
63
74
  });
64
75
  }
65
76
  //# sourceMappingURL=checkbox.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_components","require","_element","_lockUnlock","_jsxRuntime","ValidatedCheckboxControl","unlock","privateApis","Checkbox","field","onChange","data","hideLabelFromVision","id","getValue","label","description","customValidity","setCustomValidity","useState","undefined","jsx","required","isValid","onValidate","newValue","message","custom","type","hidden","help","checked","item"],"sources":["@wordpress/dataviews/src/dataform-controls/checkbox.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { privateApis } from '@wordpress/components';\nimport { useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type { DataFormControlProps } from '../types';\nimport { unlock } from '../lock-unlock';\n\nconst { ValidatedCheckboxControl } = unlock( privateApis );\n\nexport default function Checkbox< Item >( {\n\tfield,\n\tonChange,\n\tdata,\n\thideLabelFromVision,\n}: DataFormControlProps< Item > ) {\n\tconst { id, getValue, label, description } = field;\n\tconst [ customValidity, setCustomValidity ] =\n\t\tuseState<\n\t\t\tReact.ComponentProps<\n\t\t\t\ttypeof ValidatedCheckboxControl\n\t\t\t>[ 'customValidity' ]\n\t\t>( undefined );\n\n\treturn (\n\t\t<ValidatedCheckboxControl\n\t\t\trequired={ !! field.isValid?.required }\n\t\t\tonValidate={ ( newValue: any ) => {\n\t\t\t\tconst message = field.isValid?.custom?.(\n\t\t\t\t\t{\n\t\t\t\t\t\t...data,\n\t\t\t\t\t\t[ id ]: newValue,\n\t\t\t\t\t},\n\t\t\t\t\tfield\n\t\t\t\t);\n\n\t\t\t\tif ( message ) {\n\t\t\t\t\tsetCustomValidity( {\n\t\t\t\t\t\ttype: 'invalid',\n\t\t\t\t\t\tmessage,\n\t\t\t\t\t} );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tsetCustomValidity( undefined );\n\t\t\t} }\n\t\t\tcustomValidity={ customValidity }\n\t\t\thidden={ hideLabelFromVision }\n\t\t\tlabel={ label }\n\t\t\thelp={ description }\n\t\t\tchecked={ getValue( { item: data } ) }\n\t\t\tonChange={ () =>\n\t\t\t\tonChange( { [ id ]: ! getValue( { item: data } ) } )\n\t\t\t}\n\t\t/>\n\t);\n}\n"],"mappings":";;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAMA,IAAAE,WAAA,GAAAF,OAAA;AAAwC,IAAAG,WAAA,GAAAH,OAAA;AAVxC;AACA;AACA;;AAIA;AACA;AACA;;AAIA,MAAM;EAAEI;AAAyB,CAAC,GAAG,IAAAC,kBAAM,EAAEC,uBAAY,CAAC;AAE3C,SAASC,QAAQA,CAAU;EACzCC,KAAK;EACLC,QAAQ;EACRC,IAAI;EACJC;AAC6B,CAAC,EAAG;EACjC,MAAM;IAAEC,EAAE;IAAEC,QAAQ;IAAEC,KAAK;IAAEC;EAAY,CAAC,GAAGP,KAAK;EAClD,MAAM,CAAEQ,cAAc,EAAEC,iBAAiB,CAAE,GAC1C,IAAAC,iBAAQ,EAILC,SAAU,CAAC;EAEf,oBACC,IAAAhB,WAAA,CAAAiB,GAAA,EAAChB,wBAAwB;IACxBiB,QAAQ,EAAG,CAAC,CAAEb,KAAK,CAACc,OAAO,EAAED,QAAU;IACvCE,UAAU,EAAKC,QAAa,IAAM;MACjC,MAAMC,OAAO,GAAGjB,KAAK,CAACc,OAAO,EAAEI,MAAM,GACpC;QACC,GAAGhB,IAAI;QACP,CAAEE,EAAE,GAAIY;MACT,CAAC,EACDhB,KACD,CAAC;MAED,IAAKiB,OAAO,EAAG;QACdR,iBAAiB,CAAE;UAClBU,IAAI,EAAE,SAAS;UACfF;QACD,CAAE,CAAC;QACH;MACD;MAEAR,iBAAiB,CAAEE,SAAU,CAAC;IAC/B,CAAG;IACHH,cAAc,EAAGA,cAAgB;IACjCY,MAAM,EAAGjB,mBAAqB;IAC9BG,KAAK,EAAGA,KAAO;IACfe,IAAI,EAAGd,WAAa;IACpBe,OAAO,EAAGjB,QAAQ,CAAE;MAAEkB,IAAI,EAAErB;IAAK,CAAE,CAAG;IACtCD,QAAQ,EAAGA,CAAA,KACVA,QAAQ,CAAE;MAAE,CAAEG,EAAE,GAAI,CAAEC,QAAQ,CAAE;QAAEkB,IAAI,EAAErB;MAAK,CAAE;IAAE,CAAE;EACnD,CACD,CAAC;AAEJ","ignoreList":[]}
1
+ {"version":3,"names":["_deepmerge","_interopRequireDefault","require","_components","_element","_lockUnlock","_jsxRuntime","ValidatedCheckboxControl","unlock","privateApis","Checkbox","field","onChange","data","hideLabelFromVision","getValue","setValue","label","description","customValidity","setCustomValidity","useState","undefined","onChangeControl","useCallback","item","value","onValidateControl","newValue","message","isValid","custom","deepMerge","type","jsx","required","onValidate","hidden","help","checked"],"sources":["@wordpress/dataviews/src/dataform-controls/checkbox.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport deepMerge from 'deepmerge';\n\n/**\n * WordPress dependencies\n */\nimport { privateApis } from '@wordpress/components';\nimport { useState, useCallback } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type { DataFormControlProps } from '../types';\nimport { unlock } from '../lock-unlock';\n\nconst { ValidatedCheckboxControl } = unlock( privateApis );\n\nexport default function Checkbox< Item >( {\n\tfield,\n\tonChange,\n\tdata,\n\thideLabelFromVision,\n}: DataFormControlProps< Item > ) {\n\tconst { getValue, setValue, label, description } = field;\n\tconst [ customValidity, setCustomValidity ] =\n\t\tuseState<\n\t\t\tReact.ComponentProps<\n\t\t\t\ttypeof ValidatedCheckboxControl\n\t\t\t>[ 'customValidity' ]\n\t\t>( undefined );\n\n\tconst onChangeControl = useCallback( () => {\n\t\tonChange(\n\t\t\tsetValue( { item: data, value: ! getValue( { item: data } ) } )\n\t\t);\n\t}, [ data, getValue, onChange, setValue ] );\n\n\tconst onValidateControl = useCallback(\n\t\t( newValue: any ) => {\n\t\t\tconst message = field.isValid?.custom?.(\n\t\t\t\tdeepMerge(\n\t\t\t\t\tdata,\n\t\t\t\t\tsetValue( {\n\t\t\t\t\t\titem: data,\n\t\t\t\t\t\tvalue: newValue,\n\t\t\t\t\t} ) as Partial< Item >\n\t\t\t\t),\n\t\t\t\tfield\n\t\t\t);\n\n\t\t\tif ( message ) {\n\t\t\t\tsetCustomValidity( {\n\t\t\t\t\ttype: 'invalid',\n\t\t\t\t\tmessage,\n\t\t\t\t} );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tsetCustomValidity( undefined );\n\t\t},\n\t\t[ data, field, setValue ]\n\t);\n\n\treturn (\n\t\t<ValidatedCheckboxControl\n\t\t\trequired={ !! field.isValid?.required }\n\t\t\tonValidate={ onValidateControl }\n\t\t\tcustomValidity={ customValidity }\n\t\t\thidden={ hideLabelFromVision }\n\t\t\tlabel={ label }\n\t\t\thelp={ description }\n\t\t\tchecked={ getValue( { item: data } ) }\n\t\t\tonChange={ onChangeControl }\n\t\t/>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAMA,IAAAG,WAAA,GAAAH,OAAA;AAAwC,IAAAI,WAAA,GAAAJ,OAAA;AAfxC;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;;AAIA,MAAM;EAAEK;AAAyB,CAAC,GAAG,IAAAC,kBAAM,EAAEC,uBAAY,CAAC;AAE3C,SAASC,QAAQA,CAAU;EACzCC,KAAK;EACLC,QAAQ;EACRC,IAAI;EACJC;AAC6B,CAAC,EAAG;EACjC,MAAM;IAAEC,QAAQ;IAAEC,QAAQ;IAAEC,KAAK;IAAEC;EAAY,CAAC,GAAGP,KAAK;EACxD,MAAM,CAAEQ,cAAc,EAAEC,iBAAiB,CAAE,GAC1C,IAAAC,iBAAQ,EAILC,SAAU,CAAC;EAEf,MAAMC,eAAe,GAAG,IAAAC,oBAAW,EAAE,MAAM;IAC1CZ,QAAQ,CACPI,QAAQ,CAAE;MAAES,IAAI,EAAEZ,IAAI;MAAEa,KAAK,EAAE,CAAEX,QAAQ,CAAE;QAAEU,IAAI,EAAEZ;MAAK,CAAE;IAAE,CAAE,CAC/D,CAAC;EACF,CAAC,EAAE,CAAEA,IAAI,EAAEE,QAAQ,EAAEH,QAAQ,EAAEI,QAAQ,CAAG,CAAC;EAE3C,MAAMW,iBAAiB,GAAG,IAAAH,oBAAW,EAClCI,QAAa,IAAM;IACpB,MAAMC,OAAO,GAAGlB,KAAK,CAACmB,OAAO,EAAEC,MAAM,GACpC,IAAAC,kBAAS,EACRnB,IAAI,EACJG,QAAQ,CAAE;MACTS,IAAI,EAAEZ,IAAI;MACVa,KAAK,EAAEE;IACR,CAAE,CACH,CAAC,EACDjB,KACD,CAAC;IAED,IAAKkB,OAAO,EAAG;MACdT,iBAAiB,CAAE;QAClBa,IAAI,EAAE,SAAS;QACfJ;MACD,CAAE,CAAC;MACH;IACD;IAEAT,iBAAiB,CAAEE,SAAU,CAAC;EAC/B,CAAC,EACD,CAAET,IAAI,EAAEF,KAAK,EAAEK,QAAQ,CACxB,CAAC;EAED,oBACC,IAAAV,WAAA,CAAA4B,GAAA,EAAC3B,wBAAwB;IACxB4B,QAAQ,EAAG,CAAC,CAAExB,KAAK,CAACmB,OAAO,EAAEK,QAAU;IACvCC,UAAU,EAAGT,iBAAmB;IAChCR,cAAc,EAAGA,cAAgB;IACjCkB,MAAM,EAAGvB,mBAAqB;IAC9BG,KAAK,EAAGA,KAAO;IACfqB,IAAI,EAAGpB,WAAa;IACpBqB,OAAO,EAAGxB,QAAQ,CAAE;MAAEU,IAAI,EAAEZ;IAAK,CAAE,CAAG;IACtCD,QAAQ,EAAGW;EAAiB,CAC5B,CAAC;AAEJ","ignoreList":[]}
@@ -1,10 +1,12 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports.default = Color;
7
8
  var _colord = require("colord");
9
+ var _deepmerge = _interopRequireDefault(require("deepmerge"));
8
10
  var _components = require("@wordpress/components");
9
11
  var _element = require("@wordpress/element");
10
12
  var _lockUnlock = require("../lock-unlock");
@@ -76,41 +78,44 @@ function Color({
76
78
  hideLabelFromVision
77
79
  }) {
78
80
  const {
79
- id,
80
81
  label,
81
82
  placeholder,
82
- description
83
+ description,
84
+ setValue
83
85
  } = field;
84
86
  const value = field.getValue({
85
87
  item: data
86
88
  }) || '';
87
89
  const [customValidity, setCustomValidity] = (0, _element.useState)(undefined);
88
90
  const handleColorChange = (0, _element.useCallback)(colorObject => {
89
- onChange({
90
- [id]: colorObject.toHex()
91
- });
92
- }, [id, onChange]);
91
+ onChange(setValue({
92
+ item: data,
93
+ value: colorObject.toHex()
94
+ }));
95
+ }, [data, onChange, setValue]);
93
96
  const handleInputChange = (0, _element.useCallback)(newValue => {
94
- onChange({
95
- [id]: newValue || ''
96
- });
97
- }, [id, onChange]);
97
+ onChange(setValue({
98
+ item: data,
99
+ value: newValue || ''
100
+ }));
101
+ }, [data, onChange, setValue]);
102
+ const onValidateControl = (0, _element.useCallback)(newValue => {
103
+ const message = field.isValid?.custom?.((0, _deepmerge.default)(data, setValue({
104
+ item: data,
105
+ value: newValue
106
+ })), field);
107
+ if (message) {
108
+ setCustomValidity({
109
+ type: 'invalid',
110
+ message
111
+ });
112
+ return;
113
+ }
114
+ setCustomValidity(undefined);
115
+ }, [data, field, setValue]);
98
116
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(ValidatedInputControl, {
99
117
  required: !!field.isValid?.required,
100
- onValidate: newValue => {
101
- const message = field.isValid?.custom?.({
102
- ...data,
103
- [id]: newValue
104
- }, field);
105
- if (message) {
106
- setCustomValidity({
107
- type: 'invalid',
108
- message
109
- });
110
- return;
111
- }
112
- setCustomValidity(undefined);
113
- },
118
+ onValidate: onValidateControl,
114
119
  customValidity: customValidity,
115
120
  label: label,
116
121
  placeholder: placeholder,
@@ -1 +1 @@
1
- {"version":3,"names":["_colord","require","_components","_element","_lockUnlock","_jsxRuntime","ValidatedInputControl","Picker","unlock","privateApis","ColorPicker","color","onColorChange","validColor","colord","isValid","jsx","Dropdown","renderToggle","onToggle","isOpen","__experimentalInputControlPrefixWrapper","variant","children","type","onClick","style","width","height","borderRadius","backgroundColor","border","cursor","outline","outlineOffset","display","alignItems","justifyContent","padding","margin","renderContent","onChange","enableAlpha","Color","data","field","hideLabelFromVision","id","label","placeholder","description","value","getValue","item","customValidity","setCustomValidity","useState","undefined","handleColorChange","useCallback","colorObject","toHex","handleInputChange","newValue","required","onValidate","message","custom","help","prefix"],"sources":["@wordpress/dataviews/src/dataform-controls/color.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport { colord } from 'colord';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tDropdown,\n\tprivateApis,\n\t__experimentalInputControlPrefixWrapper as InputControlPrefixWrapper,\n} from '@wordpress/components';\nimport { useCallback, useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type { DataFormControlProps } from '../types';\nimport { unlock } from '../lock-unlock';\n\nconst { ValidatedInputControl, Picker } = unlock( privateApis );\n\nconst ColorPicker = ( {\n\tcolor,\n\tonColorChange,\n}: {\n\tcolor: string;\n\tonColorChange: ( colorObject: any ) => void;\n} ) => {\n\tconst validColor = color && colord( color ).isValid() ? color : '#ffffff';\n\n\treturn (\n\t\t<Dropdown\n\t\t\trenderToggle={ ( { onToggle, isOpen } ) => (\n\t\t\t\t<InputControlPrefixWrapper variant=\"icon\">\n\t\t\t\t\t<button\n\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\twidth: '24px',\n\t\t\t\t\t\t\theight: '24px',\n\t\t\t\t\t\t\tborderRadius: '50%',\n\t\t\t\t\t\t\tbackgroundColor: validColor,\n\t\t\t\t\t\t\tborder: '1px solid #ddd',\n\t\t\t\t\t\t\tcursor: 'pointer',\n\t\t\t\t\t\t\toutline: isOpen ? '2px solid #007cba' : 'none',\n\t\t\t\t\t\t\toutlineOffset: '2px',\n\t\t\t\t\t\t\tdisplay: 'flex',\n\t\t\t\t\t\t\talignItems: 'center',\n\t\t\t\t\t\t\tjustifyContent: 'center',\n\t\t\t\t\t\t\tpadding: 0,\n\t\t\t\t\t\t\tmargin: 0,\n\t\t\t\t\t\t} }\n\t\t\t\t\t\taria-label=\"Open color picker\"\n\t\t\t\t\t/>\n\t\t\t\t</InputControlPrefixWrapper>\n\t\t\t) }\n\t\t\trenderContent={ () => (\n\t\t\t\t<div style={ { padding: '16px' } }>\n\t\t\t\t\t<Picker\n\t\t\t\t\t\tcolor={ colord( validColor ) }\n\t\t\t\t\t\tonChange={ onColorChange }\n\t\t\t\t\t\tenableAlpha\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t/>\n\t);\n};\n\nexport default function Color< Item >( {\n\tdata,\n\tfield,\n\tonChange,\n\thideLabelFromVision,\n}: DataFormControlProps< Item > ) {\n\tconst { id, label, placeholder, description } = field;\n\tconst value = field.getValue( { item: data } ) || '';\n\tconst [ customValidity, setCustomValidity ] =\n\t\tuseState<\n\t\t\tReact.ComponentProps<\n\t\t\t\ttypeof ValidatedInputControl\n\t\t\t>[ 'customValidity' ]\n\t\t>( undefined );\n\n\tconst handleColorChange = useCallback(\n\t\t( colorObject: any ) => {\n\t\t\tonChange( { [ id ]: colorObject.toHex() } );\n\t\t},\n\t\t[ id, onChange ]\n\t);\n\n\tconst handleInputChange = useCallback(\n\t\t( newValue: string | undefined ) => {\n\t\t\tonChange( { [ id ]: newValue || '' } );\n\t\t},\n\t\t[ id, onChange ]\n\t);\n\n\treturn (\n\t\t<ValidatedInputControl\n\t\t\trequired={ !! field.isValid?.required }\n\t\t\tonValidate={ ( newValue: any ) => {\n\t\t\t\tconst message = field.isValid?.custom?.(\n\t\t\t\t\t{\n\t\t\t\t\t\t...data,\n\t\t\t\t\t\t[ id ]: newValue,\n\t\t\t\t\t},\n\t\t\t\t\tfield\n\t\t\t\t);\n\n\t\t\t\tif ( message ) {\n\t\t\t\t\tsetCustomValidity( {\n\t\t\t\t\t\ttype: 'invalid',\n\t\t\t\t\t\tmessage,\n\t\t\t\t\t} );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tsetCustomValidity( undefined );\n\t\t\t} }\n\t\t\tcustomValidity={ customValidity }\n\t\t\tlabel={ label }\n\t\t\tplaceholder={ placeholder }\n\t\t\tvalue={ value }\n\t\t\thelp={ description }\n\t\t\tonChange={ handleInputChange }\n\t\t\thideLabelFromVision={ hideLabelFromVision }\n\t\t\ttype=\"text\"\n\t\t\tprefix={\n\t\t\t\t<ColorPicker\n\t\t\t\t\tcolor={ value }\n\t\t\t\t\tonColorChange={ handleColorChange }\n\t\t\t\t/>\n\t\t\t}\n\t\t/>\n\t);\n}\n"],"mappings":";;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AAKA,IAAAC,WAAA,GAAAD,OAAA;AAKA,IAAAE,QAAA,GAAAF,OAAA;AAMA,IAAAG,WAAA,GAAAH,OAAA;AAAwC,IAAAI,WAAA,GAAAJ,OAAA;AAnBxC;AACA;AACA;;AAGA;AACA;AACA;;AAQA;AACA;AACA;;AAIA,MAAM;EAAEK,qBAAqB;EAAEC;AAAO,CAAC,GAAG,IAAAC,kBAAM,EAAEC,uBAAY,CAAC;AAE/D,MAAMC,WAAW,GAAGA,CAAE;EACrBC,KAAK;EACLC;AAID,CAAC,KAAM;EACN,MAAMC,UAAU,GAAGF,KAAK,IAAI,IAAAG,cAAM,EAAEH,KAAM,CAAC,CAACI,OAAO,CAAC,CAAC,GAAGJ,KAAK,GAAG,SAAS;EAEzE,oBACC,IAAAN,WAAA,CAAAW,GAAA,EAACd,WAAA,CAAAe,QAAQ;IACRC,YAAY,EAAGA,CAAE;MAAEC,QAAQ;MAAEC;IAAO,CAAC,kBACpC,IAAAf,W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AAG8C;IAAmB,CACnC;EACD,CACD,CAAC;AAEJ","ignoreList":[]}
1
+ {"version":3,"names":["_colord","require","_deepmerge","_interopRequireDefault","_components","_element","_lockUnlock","_jsxRuntime","ValidatedInputControl","Picker","unlock","privateApis","ColorPicker","color","onColorChange","validColor","colord","isValid","jsx","Dropdown","renderToggle","onToggle","isOpen","__experimentalInputControlPrefixWrapper","variant","children","type","onClick","style","width","height","borderRadius","backgroundColor","border","cursor","outline","outlineOffset","display","alignItems","justifyContent","padding","margin","renderContent","onChange","enableAlpha","Color","data","field","hideLabelFromVision","label","placeholder","description","setValue","value","getValue","item","customValidity","setCustomValidity","useState","undefined","handleColorChange","useCallback","colorObject","toHex","handleInputChange","newValue","onValidateControl","message","custom","deepMerge","required","onValidate","help","prefix"],"sources":["@wordpress/dataviews/src/dataform-controls/color.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport { colord } from 'colord';\nimport deepMerge from 'deepmerge';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tDropdown,\n\tprivateApis,\n\t__experimentalInputControlPrefixWrapper as InputControlPrefixWrapper,\n} from '@wordpress/components';\nimport { useCallback, useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type { DataFormControlProps } from '../types';\nimport { unlock } from '../lock-unlock';\n\nconst { ValidatedInputControl, Picker } = unlock( privateApis );\n\nconst ColorPicker = ( {\n\tcolor,\n\tonColorChange,\n}: {\n\tcolor: string;\n\tonColorChange: ( colorObject: any ) => void;\n} ) => {\n\tconst validColor = color && colord( color ).isValid() ? color : '#ffffff';\n\n\treturn (\n\t\t<Dropdown\n\t\t\trenderToggle={ ( { onToggle, isOpen } ) => (\n\t\t\t\t<InputControlPrefixWrapper variant=\"icon\">\n\t\t\t\t\t<button\n\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\twidth: '24px',\n\t\t\t\t\t\t\theight: '24px',\n\t\t\t\t\t\t\tborderRadius: '50%',\n\t\t\t\t\t\t\tbackgroundColor: validColor,\n\t\t\t\t\t\t\tborder: '1px solid #ddd',\n\t\t\t\t\t\t\tcursor: 'pointer',\n\t\t\t\t\t\t\toutline: isOpen ? '2px solid #007cba' : 'none',\n\t\t\t\t\t\t\toutlineOffset: '2px',\n\t\t\t\t\t\t\tdisplay: 'flex',\n\t\t\t\t\t\t\talignItems: 'center',\n\t\t\t\t\t\t\tjustifyContent: 'center',\n\t\t\t\t\t\t\tpadding: 0,\n\t\t\t\t\t\t\tmargin: 0,\n\t\t\t\t\t\t} }\n\t\t\t\t\t\taria-label=\"Open color picker\"\n\t\t\t\t\t/>\n\t\t\t\t</InputControlPrefixWrapper>\n\t\t\t) }\n\t\t\trenderContent={ () => (\n\t\t\t\t<div style={ { padding: '16px' } }>\n\t\t\t\t\t<Picker\n\t\t\t\t\t\tcolor={ colord( validColor ) }\n\t\t\t\t\t\tonChange={ onColorChange }\n\t\t\t\t\t\tenableAlpha\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t/>\n\t);\n};\n\nexport default function Color< Item >( {\n\tdata,\n\tfield,\n\tonChange,\n\thideLabelFromVision,\n}: DataFormControlProps< Item > ) {\n\tconst { label, placeholder, description, setValue } = field;\n\tconst value = field.getValue( { item: data } ) || '';\n\tconst [ customValidity, setCustomValidity ] =\n\t\tuseState<\n\t\t\tReact.ComponentProps<\n\t\t\t\ttypeof ValidatedInputControl\n\t\t\t>[ 'customValidity' ]\n\t\t>( undefined );\n\n\tconst handleColorChange = useCallback(\n\t\t( colorObject: any ) => {\n\t\t\tonChange( setValue( { item: data, value: colorObject.toHex() } ) );\n\t\t},\n\t\t[ data, onChange, setValue ]\n\t);\n\n\tconst handleInputChange = useCallback(\n\t\t( newValue: string | undefined ) => {\n\t\t\tonChange( setValue( { item: data, value: newValue || '' } ) );\n\t\t},\n\t\t[ data, onChange, setValue ]\n\t);\n\n\tconst onValidateControl = useCallback(\n\t\t( newValue: any ) => {\n\t\t\tconst message = field.isValid?.custom?.(\n\t\t\t\tdeepMerge(\n\t\t\t\t\tdata,\n\t\t\t\t\tsetValue( {\n\t\t\t\t\t\titem: data,\n\t\t\t\t\t\tvalue: newValue,\n\t\t\t\t\t} ) as Partial< Item >\n\t\t\t\t),\n\t\t\t\tfield\n\t\t\t);\n\n\t\t\tif ( message ) {\n\t\t\t\tsetCustomValidity( {\n\t\t\t\t\ttype: 'invalid',\n\t\t\t\t\tmessage,\n\t\t\t\t} );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tsetCustomValidity( undefined );\n\t\t},\n\t\t[ data, field, setValue ]\n\t);\n\n\treturn (\n\t\t<ValidatedInputControl\n\t\t\trequired={ !! field.isValid?.required }\n\t\t\tonValidate={ onValidateControl }\n\t\t\tcustomValidity={ customValidity }\n\t\t\tlabel={ label }\n\t\t\tplaceholder={ placeholder }\n\t\t\tvalue={ value }\n\t\t\thelp={ description }\n\t\t\tonChange={ handleInputChange }\n\t\t\thideLabelFromVision={ hideLabelFromVision }\n\t\t\ttype=\"text\"\n\t\t\tprefix={\n\t\t\t\t<ColorPicker\n\t\t\t\t\tcolor={ value }\n\t\t\t\t\tonColorChange={ handleColorChange }\n\t\t\t\t/>\n\t\t\t}\n\t\t/>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAC,sBAAA,CAAAF,OAAA;AAKA,IAAAG,WAAA,GAAAH,OAAA;AAKA,IAAAI,QAAA,GAAAJ,OAAA;AAMA,IAAAK,WAAA,GAAAL,OAAA;AAAwC,IAAAM,WAAA,GAAAN,OAAA;AApBxC;AACA;AACA;;AAIA;AACA;AACA;;AAQA;AACA;AACA;;AAIA,MAAM;EAAEO,qBAAqB;EAAEC;AAAO,CAAC,GAAG,IAAAC,kBAAM,EAAEC,uBAAY,CAAC;AAE/D,MAAMC,WAAW,GAAGA,CAAE;EACrBC,KAAK;EACLC;AAID,CAA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