@wordpress/fields 0.5.1-next.a9f418477.0 → 0.6.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 (53) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/actions/delete-post.js +1 -0
  3. package/build/actions/delete-post.js.map +1 -1
  4. package/build/actions/duplicate-post.js +1 -0
  5. package/build/actions/duplicate-post.js.map +1 -1
  6. package/build/actions/export-pattern.js +1 -0
  7. package/build/actions/export-pattern.js.map +1 -1
  8. package/build/actions/permanently-delete-post.js +1 -0
  9. package/build/actions/permanently-delete-post.js.map +1 -1
  10. package/build/actions/restore-post.js +1 -0
  11. package/build/actions/restore-post.js.map +1 -1
  12. package/build/actions/trash-post.js +1 -0
  13. package/build/actions/trash-post.js.map +1 -1
  14. package/build/components/create-template-part-modal/index.js +32 -41
  15. package/build/components/create-template-part-modal/index.js.map +1 -1
  16. package/build/components/create-template-part-modal/utils.js +1 -0
  17. package/build/components/create-template-part-modal/utils.js.map +1 -1
  18. package/build/fields/parent/parent-edit.js +1 -0
  19. package/build/fields/parent/parent-edit.js.map +1 -1
  20. package/build/fields/status/status-view.js +1 -0
  21. package/build/fields/status/status-view.js.map +1 -1
  22. package/build/fields/template/template-edit.js +1 -0
  23. package/build/fields/template/template-edit.js.map +1 -1
  24. package/build/mutation/index.js +1 -0
  25. package/build/mutation/index.js.map +1 -1
  26. package/build-module/actions/delete-post.js +1 -0
  27. package/build-module/actions/delete-post.js.map +1 -1
  28. package/build-module/actions/duplicate-post.js +1 -0
  29. package/build-module/actions/duplicate-post.js.map +1 -1
  30. package/build-module/actions/export-pattern.js +1 -0
  31. package/build-module/actions/export-pattern.js.map +1 -1
  32. package/build-module/actions/permanently-delete-post.js +1 -0
  33. package/build-module/actions/permanently-delete-post.js.map +1 -1
  34. package/build-module/actions/restore-post.js +1 -0
  35. package/build-module/actions/restore-post.js.map +1 -1
  36. package/build-module/actions/trash-post.js +1 -0
  37. package/build-module/actions/trash-post.js.map +1 -1
  38. package/build-module/components/create-template-part-modal/index.js +32 -41
  39. package/build-module/components/create-template-part-modal/index.js.map +1 -1
  40. package/build-module/components/create-template-part-modal/utils.js +1 -0
  41. package/build-module/components/create-template-part-modal/utils.js.map +1 -1
  42. package/build-module/fields/parent/parent-edit.js +1 -0
  43. package/build-module/fields/parent/parent-edit.js.map +1 -1
  44. package/build-module/fields/status/status-view.js +1 -0
  45. package/build-module/fields/status/status-view.js.map +1 -1
  46. package/build-module/fields/template/template-edit.js +1 -0
  47. package/build-module/fields/template/template-edit.js.map +1 -1
  48. package/build-module/mutation/index.js +1 -0
  49. package/build-module/mutation/index.js.map +1 -1
  50. package/build-types/components/create-template-part-modal/index.d.ts.map +1 -1
  51. package/package.json +24 -24
  52. package/src/components/create-template-part-modal/index.tsx +25 -26
  53. package/tsconfig.tsbuildinfo +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/fields",
3
- "version": "0.5.1-next.a9f418477.0",
3
+ "version": "0.6.0",
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",
@@ -33,29 +33,29 @@
33
33
  ],
34
34
  "dependencies": {
35
35
  "@babel/runtime": "7.25.7",
36
- "@wordpress/api-fetch": "^7.13.1-next.a9f418477.0",
37
- "@wordpress/blob": "^4.13.1-next.a9f418477.0",
38
- "@wordpress/block-editor": "^14.8.1-next.a9f418477.0",
39
- "@wordpress/blocks": "^14.2.1-next.a9f418477.0",
36
+ "@wordpress/api-fetch": "*",
37
+ "@wordpress/blob": "*",
38
+ "@wordpress/block-editor": "*",
39
+ "@wordpress/blocks": "*",
40
40
  "@wordpress/components": "*",
41
- "@wordpress/compose": "^7.13.1-next.a9f418477.0",
42
- "@wordpress/core-data": "^7.13.1-next.a9f418477.0",
43
- "@wordpress/data": "^10.13.1-next.a9f418477.0",
44
- "@wordpress/dataviews": "^4.9.1-next.a9f418477.0",
45
- "@wordpress/date": "^5.13.1-next.a9f418477.0",
46
- "@wordpress/element": "^6.13.1-next.a9f418477.0",
47
- "@wordpress/hooks": "^4.13.1-next.a9f418477.0",
48
- "@wordpress/html-entities": "^4.13.1-next.a9f418477.0",
49
- "@wordpress/i18n": "^5.13.1-next.a9f418477.0",
50
- "@wordpress/icons": "^10.13.1-next.a9f418477.0",
51
- "@wordpress/media-utils": "^5.13.1-next.a9f418477.0",
52
- "@wordpress/notices": "^5.13.1-next.a9f418477.0",
53
- "@wordpress/patterns": "^2.13.1-next.a9f418477.0",
54
- "@wordpress/primitives": "^4.13.1-next.a9f418477.0",
55
- "@wordpress/private-apis": "^1.13.1-next.a9f418477.0",
56
- "@wordpress/router": "^1.13.1-next.a9f418477.0",
57
- "@wordpress/url": "^4.13.1-next.a9f418477.0",
58
- "@wordpress/warning": "^3.13.1-next.a9f418477.0",
41
+ "@wordpress/compose": "*",
42
+ "@wordpress/core-data": "*",
43
+ "@wordpress/data": "*",
44
+ "@wordpress/dataviews": "*",
45
+ "@wordpress/date": "*",
46
+ "@wordpress/element": "*",
47
+ "@wordpress/hooks": "*",
48
+ "@wordpress/html-entities": "*",
49
+ "@wordpress/i18n": "*",
50
+ "@wordpress/icons": "*",
51
+ "@wordpress/media-utils": "*",
52
+ "@wordpress/notices": "*",
53
+ "@wordpress/patterns": "*",
54
+ "@wordpress/primitives": "*",
55
+ "@wordpress/private-apis": "*",
56
+ "@wordpress/router": "*",
57
+ "@wordpress/url": "*",
58
+ "@wordpress/warning": "*",
59
59
  "change-case": "4.1.2",
60
60
  "client-zip": "^2.4.5",
61
61
  "clsx": "2.1.1",
@@ -67,5 +67,5 @@
67
67
  "publishConfig": {
68
68
  "access": "public"
69
69
  },
70
- "gitHead": "c1a8f3e9cada3b7d8342d1d2595c2dac0433111d"
70
+ "gitHead": "b432c18934c9db866b6dba7d37517a4e97d642e3"
71
71
  }
@@ -28,7 +28,7 @@ import {
28
28
  symbolFilled as symbolFilledIcon,
29
29
  } from '@wordpress/icons';
30
30
  import { store as noticesStore } from '@wordpress/notices';
31
- // @ts-ignore
31
+ // @ts-expect-error serialize is not typed
32
32
  import { serialize } from '@wordpress/blocks';
33
33
 
34
34
  /**
@@ -50,6 +50,13 @@ type CreateTemplatePartModalContentsProps = {
50
50
  defaultTitle?: string;
51
51
  };
52
52
 
53
+ type TemplatePartArea = {
54
+ area: string;
55
+ label: string;
56
+ icon: string;
57
+ description: string;
58
+ };
59
+
53
60
  /**
54
61
  * A React component that renders a modal for creating a template part. The modal displays a title and the contents for creating the template part.
55
62
  * This component should not live in this package, it should be moved to a dedicated package responsible for managing template.
@@ -64,7 +71,7 @@ export default function CreateTemplatePartModal( {
64
71
  } & CreateTemplatePartModalContentsProps ) {
65
72
  const defaultModalTitle = useSelect(
66
73
  ( select ) =>
67
- // @ts-ignore
74
+ // @ts-expect-error getPostType is not typed with 'wp_template_part' as argument.
68
75
  select( coreStore ).getPostType( 'wp_template_part' )?.labels
69
76
  ?.add_new_item,
70
77
  []
@@ -77,7 +84,6 @@ export default function CreateTemplatePartModal( {
77
84
  focusOnMount="firstContentElement"
78
85
  size="medium"
79
86
  >
80
- { /* @ts-ignore */ }
81
87
  <CreateTemplatePartModalContents { ...restProps } />
82
88
  </Modal>
83
89
  );
@@ -125,22 +131,14 @@ export function CreateTemplatePartModalContents( {
125
131
  const [ isSubmitting, setIsSubmitting ] = useState( false );
126
132
  const instanceId = useInstanceId( CreateTemplatePartModal );
127
133
 
128
- const defaultTemplatePartAreas = useSelect( ( select ) => {
129
- const areas =
134
+ const defaultTemplatePartAreas = useSelect(
135
+ ( select ) =>
130
136
  // @ts-expect-error getEntityRecord is not typed with unstableBase as argument.
131
137
  select( coreStore ).getEntityRecord< {
132
- default_template_part_areas: Array< {
133
- area: string;
134
- label: string;
135
- icon: string;
136
- description: string;
137
- } >;
138
- } >( 'root', '__unstableBase' )?.default_template_part_areas || [];
139
-
140
- return areas.map( ( item ) => {
141
- return { ...item, icon: getTemplatePartIcon( item.icon ) };
142
- } );
143
- }, [] );
138
+ default_template_part_areas: Array< TemplatePartArea >;
139
+ } >( 'root', '__unstableBase' )?.default_template_part_areas,
140
+ []
141
+ );
144
142
 
145
143
  async function createTemplatePart() {
146
144
  if ( ! title || isSubmitting ) {
@@ -220,12 +218,13 @@ export function CreateTemplatePartModalContents( {
220
218
  }
221
219
  checked={ area }
222
220
  >
223
- { defaultTemplatePartAreas.map(
224
- ( { icon, label, area: value, description } ) => (
221
+ { ( defaultTemplatePartAreas ?? [] ).map( ( item ) => {
222
+ const icon = getTemplatePartIcon( item.icon );
223
+ return (
225
224
  <Radio
226
225
  __next40pxDefaultSize
227
- key={ label }
228
- value={ value }
226
+ key={ item.label }
227
+ value={ item.area }
229
228
  className="fields-create-template-part-modal__area-radio"
230
229
  >
231
230
  <Flex align="start" justify="start">
@@ -233,19 +232,19 @@ export function CreateTemplatePartModalContents( {
233
232
  <Icon icon={ icon } />
234
233
  </FlexItem>
235
234
  <FlexBlock className="fields-create-template-part-modal__option-label">
236
- { label }
237
- <div>{ description }</div>
235
+ { item.label }
236
+ <div>{ item.description }</div>
238
237
  </FlexBlock>
239
238
 
240
239
  <FlexItem className="fields-create-template-part-modal__checkbox">
241
- { area === value && (
240
+ { area === item.area && (
242
241
  <Icon icon={ check } />
243
242
  ) }
244
243
  </FlexItem>
245
244
  </Flex>
246
245
  </Radio>
247
- )
248
- ) }
246
+ );
247
+ } ) }
249
248
  </RadioGroup>
250
249
  </BaseControl>
251
250
  <HStack justify="right">