@wordpress/fields 0.1.0 → 0.3.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 (135) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +12 -0
  3. package/build/actions/delete-post.js +9 -9
  4. package/build/actions/delete-post.js.map +1 -1
  5. package/build/actions/duplicate-post.js +3 -3
  6. package/build/actions/duplicate-post.js.map +1 -1
  7. package/build/actions/export-pattern.js.map +1 -1
  8. package/build/actions/permanently-delete-post.js +4 -3
  9. package/build/actions/permanently-delete-post.js.map +1 -1
  10. package/build/actions/reset-post.js +2 -2
  11. package/build/actions/reset-post.js.map +1 -1
  12. package/build/actions/restore-post.js +6 -5
  13. package/build/actions/restore-post.js.map +1 -1
  14. package/build/actions/trash-post.js +5 -4
  15. package/build/actions/trash-post.js.map +1 -1
  16. package/build/actions/view-post-revisions.js +1 -1
  17. package/build/actions/view-post-revisions.js.map +1 -1
  18. package/build/fields/featured-image/featured-image-edit.js +113 -0
  19. package/build/fields/featured-image/featured-image-edit.js.map +1 -0
  20. package/build/fields/featured-image/featured-image-view.js +41 -0
  21. package/build/fields/featured-image/featured-image-view.js.map +1 -0
  22. package/build/fields/featured-image/index.js +30 -0
  23. package/build/fields/featured-image/index.js.map +1 -0
  24. package/build/fields/index.js +21 -0
  25. package/build/fields/index.js.map +1 -1
  26. package/build/fields/parent/index.js +34 -0
  27. package/build/fields/parent/index.js.map +1 -0
  28. package/build/fields/parent/parent-edit.js +243 -0
  29. package/build/fields/parent/parent-edit.js.map +1 -0
  30. package/build/fields/parent/parent-view.js +39 -0
  31. package/build/fields/parent/parent-view.js.map +1 -0
  32. package/build/fields/parent/utils.js +20 -0
  33. package/build/fields/parent/utils.js.map +1 -0
  34. package/build/fields/slug/index.js +30 -0
  35. package/build/fields/slug/index.js.map +1 -0
  36. package/build/fields/slug/slug-edit.js +132 -0
  37. package/build/fields/slug/slug-edit.js.map +1 -0
  38. package/build/fields/slug/slug-view.js +30 -0
  39. package/build/fields/slug/slug-view.js.map +1 -0
  40. package/build/mutation/index.js +3 -2
  41. package/build/mutation/index.js.map +1 -1
  42. package/build/types.js.map +1 -1
  43. package/build-module/actions/delete-post.js +11 -12
  44. package/build-module/actions/delete-post.js.map +1 -1
  45. package/build-module/actions/duplicate-post.js +4 -5
  46. package/build-module/actions/duplicate-post.js.map +1 -1
  47. package/build-module/actions/export-pattern.js.map +1 -1
  48. package/build-module/actions/permanently-delete-post.js +4 -3
  49. package/build-module/actions/permanently-delete-post.js.map +1 -1
  50. package/build-module/actions/rename-post.js +1 -2
  51. package/build-module/actions/rename-post.js.map +1 -1
  52. package/build-module/actions/reorder-page.js +1 -2
  53. package/build-module/actions/reorder-page.js.map +1 -1
  54. package/build-module/actions/reset-post.js +3 -4
  55. package/build-module/actions/reset-post.js.map +1 -1
  56. package/build-module/actions/restore-post.js +6 -5
  57. package/build-module/actions/restore-post.js.map +1 -1
  58. package/build-module/actions/trash-post.js +6 -6
  59. package/build-module/actions/trash-post.js.map +1 -1
  60. package/build-module/actions/view-post-revisions.js +1 -1
  61. package/build-module/actions/view-post-revisions.js.map +1 -1
  62. package/build-module/fields/featured-image/featured-image-edit.js +105 -0
  63. package/build-module/fields/featured-image/featured-image-edit.js.map +1 -0
  64. package/build-module/fields/featured-image/featured-image-view.js +33 -0
  65. package/build-module/fields/featured-image/featured-image-view.js.map +1 -0
  66. package/build-module/fields/featured-image/index.js +24 -0
  67. package/build-module/fields/featured-image/index.js.map +1 -0
  68. package/build-module/fields/index.js +3 -0
  69. package/build-module/fields/index.js.map +1 -1
  70. package/build-module/fields/parent/index.js +28 -0
  71. package/build-module/fields/parent/index.js.map +1 -0
  72. package/build-module/fields/parent/parent-edit.js +230 -0
  73. package/build-module/fields/parent/parent-edit.js.map +1 -0
  74. package/build-module/fields/parent/parent-view.js +32 -0
  75. package/build-module/fields/parent/parent-view.js.map +1 -0
  76. package/build-module/fields/parent/utils.js +14 -0
  77. package/build-module/fields/parent/utils.js.map +1 -0
  78. package/build-module/fields/slug/index.js +23 -0
  79. package/build-module/fields/slug/index.js.map +1 -0
  80. package/build-module/fields/slug/slug-edit.js +125 -0
  81. package/build-module/fields/slug/slug-edit.js.map +1 -0
  82. package/build-module/fields/slug/slug-view.js +24 -0
  83. package/build-module/fields/slug/slug-view.js.map +1 -0
  84. package/build-module/mutation/index.js +3 -2
  85. package/build-module/mutation/index.js.map +1 -1
  86. package/build-module/types.js.map +1 -1
  87. package/build-style/styles-rtl.css +134 -0
  88. package/build-style/styles.css +134 -0
  89. package/build-types/actions/delete-post.d.ts.map +1 -1
  90. package/build-types/fields/featured-image/featured-image-edit.d.ts +7 -0
  91. package/build-types/fields/featured-image/featured-image-edit.d.ts.map +1 -0
  92. package/build-types/fields/featured-image/featured-image-view.d.ts +7 -0
  93. package/build-types/fields/featured-image/featured-image-view.d.ts.map +1 -0
  94. package/build-types/fields/featured-image/index.d.ts +11 -0
  95. package/build-types/fields/featured-image/index.d.ts.map +1 -0
  96. package/build-types/fields/index.d.ts +3 -0
  97. package/build-types/fields/index.d.ts.map +1 -1
  98. package/build-types/fields/parent/index.d.ts +14 -0
  99. package/build-types/fields/parent/index.d.ts.map +1 -0
  100. package/build-types/fields/parent/parent-edit.d.ts +9 -0
  101. package/build-types/fields/parent/parent-edit.d.ts.map +1 -0
  102. package/build-types/fields/parent/parent-view.d.ts +7 -0
  103. package/build-types/fields/parent/parent-view.d.ts.map +1 -0
  104. package/build-types/fields/parent/utils.d.ts +6 -0
  105. package/build-types/fields/parent/utils.d.ts.map +1 -0
  106. package/build-types/fields/slug/index.d.ts +11 -0
  107. package/build-types/fields/slug/index.d.ts.map +1 -0
  108. package/build-types/fields/slug/slug-edit.d.ts +8 -0
  109. package/build-types/fields/slug/slug-edit.d.ts.map +1 -0
  110. package/build-types/fields/slug/slug-view.d.ts +9 -0
  111. package/build-types/fields/slug/slug-view.d.ts.map +1 -0
  112. package/build-types/types.d.ts +2 -0
  113. package/build-types/types.d.ts.map +1 -1
  114. package/package.json +27 -23
  115. package/src/actions/delete-post.tsx +8 -5
  116. package/src/actions/duplicate-post.tsx +2 -2
  117. package/src/actions/view-post-revisions.tsx +1 -1
  118. package/src/fields/featured-image/featured-image-edit.tsx +122 -0
  119. package/src/fields/featured-image/featured-image-view.tsx +38 -0
  120. package/src/fields/featured-image/index.ts +24 -0
  121. package/src/fields/featured-image/style.scss +95 -0
  122. package/src/fields/index.ts +3 -0
  123. package/src/fields/parent/index.ts +27 -0
  124. package/src/fields/parent/parent-edit.tsx +348 -0
  125. package/src/fields/parent/parent-view.tsx +33 -0
  126. package/src/fields/parent/utils.ts +18 -0
  127. package/src/fields/slug/index.ts +23 -0
  128. package/src/fields/slug/slug-edit.tsx +156 -0
  129. package/src/fields/slug/slug-view.tsx +26 -0
  130. package/src/fields/slug/style.scss +22 -0
  131. package/src/mutation/index.ts +3 -3
  132. package/src/styles.scss +1 -0
  133. package/src/types.ts +2 -0
  134. package/tsconfig.json +3 -1
  135. package/tsconfig.tsbuildinfo +1 -1
@@ -0,0 +1,105 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { Button, __experimentalGrid as Grid } from '@wordpress/components';
5
+ import { useSelect } from '@wordpress/data';
6
+ import { useCallback, useRef } from '@wordpress/element';
7
+ // @ts-ignore
8
+ import { MediaUpload } from '@wordpress/media-utils';
9
+ import { lineSolid } from '@wordpress/icons';
10
+ import { store as coreStore } from '@wordpress/core-data';
11
+
12
+ /**
13
+ * Internal dependencies
14
+ */
15
+
16
+ import { __ } from '@wordpress/i18n';
17
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
18
+ export const FeaturedImageEdit = ({
19
+ data,
20
+ field,
21
+ onChange
22
+ }) => {
23
+ const {
24
+ id
25
+ } = field;
26
+ const value = field.getValue({
27
+ item: data
28
+ });
29
+ const media = useSelect(select => {
30
+ const {
31
+ getEntityRecord
32
+ } = select(coreStore);
33
+ return getEntityRecord('root', 'media', value);
34
+ }, [value]);
35
+ const onChangeControl = useCallback(newValue => onChange({
36
+ [id]: newValue
37
+ }), [id, onChange]);
38
+ const url = media?.source_url;
39
+ const title = media?.title?.rendered;
40
+ const ref = useRef(null);
41
+ return /*#__PURE__*/_jsx("fieldset", {
42
+ className: "fields-controls__featured-image",
43
+ children: /*#__PURE__*/_jsx("div", {
44
+ className: "fields-controls__featured-image-container",
45
+ children: /*#__PURE__*/_jsx(MediaUpload, {
46
+ onSelect: selectedMedia => {
47
+ onChangeControl(selectedMedia.id);
48
+ },
49
+ allowedTypes: ['image'],
50
+ render: ({
51
+ open
52
+ }) => {
53
+ return /*#__PURE__*/_jsx("div", {
54
+ ref: ref,
55
+ role: "button",
56
+ tabIndex: -1,
57
+ onClick: () => {
58
+ open();
59
+ },
60
+ onKeyDown: open,
61
+ children: /*#__PURE__*/_jsxs(Grid, {
62
+ rowGap: 0,
63
+ columnGap: 8,
64
+ templateColumns: "24px 1fr 24px",
65
+ children: [url && /*#__PURE__*/_jsxs(_Fragment, {
66
+ children: [/*#__PURE__*/_jsx("img", {
67
+ className: "fields-controls__featured-image-image",
68
+ alt: "",
69
+ width: 24,
70
+ height: 24,
71
+ src: url
72
+ }), /*#__PURE__*/_jsx("span", {
73
+ className: "fields-controls__featured-image-title",
74
+ children: title
75
+ })]
76
+ }), !url && /*#__PURE__*/_jsxs(_Fragment, {
77
+ children: [/*#__PURE__*/_jsx("span", {
78
+ className: "fields-controls__featured-image-placeholder",
79
+ style: {
80
+ width: '24px',
81
+ height: '24px'
82
+ }
83
+ }), /*#__PURE__*/_jsx("span", {
84
+ className: "fields-controls__featured-image-title",
85
+ children: __('Choose an image…')
86
+ })]
87
+ }), url && /*#__PURE__*/_jsx(_Fragment, {
88
+ children: /*#__PURE__*/_jsx(Button, {
89
+ size: "small",
90
+ className: "fields-controls__featured-image-remove-button",
91
+ icon: lineSolid,
92
+ onClick: event => {
93
+ event.stopPropagation();
94
+ onChangeControl(0);
95
+ }
96
+ })
97
+ })]
98
+ })
99
+ });
100
+ }
101
+ })
102
+ })
103
+ });
104
+ };
105
+ //# sourceMappingURL=featured-image-edit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Button","__experimentalGrid","Grid","useSelect","useCallback","useRef","MediaUpload","lineSolid","store","coreStore","__","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","FeaturedImageEdit","data","field","onChange","id","value","getValue","item","media","select","getEntityRecord","onChangeControl","newValue","url","source_url","title","rendered","ref","className","children","onSelect","selectedMedia","allowedTypes","render","open","role","tabIndex","onClick","onKeyDown","rowGap","columnGap","templateColumns","alt","width","height","src","style","size","icon","event","stopPropagation"],"sources":["@wordpress/fields/src/fields/featured-image/featured-image-edit.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Button, __experimentalGrid as Grid } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { useCallback, useRef } from '@wordpress/element';\n// @ts-ignore\nimport { MediaUpload } from '@wordpress/media-utils';\nimport { lineSolid } from '@wordpress/icons';\nimport { store as coreStore } from '@wordpress/core-data';\nimport type { DataFormControlProps } from '@wordpress/dataviews';\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\nimport { __ } from '@wordpress/i18n';\n\nexport const FeaturedImageEdit = ( {\n\tdata,\n\tfield,\n\tonChange,\n}: DataFormControlProps< BasePost > ) => {\n\tconst { id } = field;\n\n\tconst value = field.getValue( { item: data } );\n\n\tconst media = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecord } = select( coreStore );\n\t\t\treturn getEntityRecord( 'root', 'media', value );\n\t\t},\n\t\t[ value ]\n\t);\n\n\tconst onChangeControl = useCallback(\n\t\t( newValue: number ) =>\n\t\t\tonChange( {\n\t\t\t\t[ id ]: newValue,\n\t\t\t} ),\n\t\t[ id, onChange ]\n\t);\n\n\tconst url = media?.source_url;\n\tconst title = media?.title?.rendered;\n\tconst ref = useRef( null );\n\n\treturn (\n\t\t<fieldset className=\"fields-controls__featured-image\">\n\t\t\t<div className=\"fields-controls__featured-image-container\">\n\t\t\t\t<MediaUpload\n\t\t\t\t\tonSelect={ ( selectedMedia: { id: number } ) => {\n\t\t\t\t\t\tonChangeControl( selectedMedia.id );\n\t\t\t\t\t} }\n\t\t\t\t\tallowedTypes={ [ 'image' ] }\n\t\t\t\t\trender={ ( { open }: { open: () => void } ) => {\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\t\trole=\"button\"\n\t\t\t\t\t\t\t\ttabIndex={ -1 }\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\topen();\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tonKeyDown={ open }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<Grid\n\t\t\t\t\t\t\t\t\trowGap={ 0 }\n\t\t\t\t\t\t\t\t\tcolumnGap={ 8 }\n\t\t\t\t\t\t\t\t\ttemplateColumns=\"24px 1fr 24px\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ url && (\n\t\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t\t<img\n\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"fields-controls__featured-image-image\"\n\t\t\t\t\t\t\t\t\t\t\t\talt=\"\"\n\t\t\t\t\t\t\t\t\t\t\t\twidth={ 24 }\n\t\t\t\t\t\t\t\t\t\t\t\theight={ 24 }\n\t\t\t\t\t\t\t\t\t\t\t\tsrc={ url }\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t<span className=\"fields-controls__featured-image-title\">\n\t\t\t\t\t\t\t\t\t\t\t\t{ title }\n\t\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t{ ! url && (\n\t\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"fields-controls__featured-image-placeholder\"\n\t\t\t\t\t\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\t\t\t\t\t\twidth: '24px',\n\t\t\t\t\t\t\t\t\t\t\t\t\theight: '24px',\n\t\t\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t<span className=\"fields-controls__featured-image-title\">\n\t\t\t\t\t\t\t\t\t\t\t\t{ __( 'Choose an image…' ) }\n\t\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t{ url && (\n\t\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"fields-controls__featured-image-remove-button\"\n\t\t\t\t\t\t\t\t\t\t\t\ticon={ lineSolid }\n\t\t\t\t\t\t\t\t\t\t\t\tonClick={ (\n\t\t\t\t\t\t\t\t\t\t\t\t\tevent: React.MouseEvent< HTMLButtonElement >\n\t\t\t\t\t\t\t\t\t\t\t\t) => {\n\t\t\t\t\t\t\t\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\t\t\t\t\t\t\t\tonChangeControl( 0 );\n\t\t\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</Grid>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t);\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</fieldset>\n\t);\n};\n"],"mappings":"AAAA;AACA;A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oB,GAAG,iBACJlB,IAAA,CAAAE,SAAA;gBAAAsB,QAAA,eACCxB,IAAA,CAACZ,MAAM;kBACNsD,IAAI,EAAC,OAAO;kBACZnB,SAAS,EAAC,+CAA+C;kBACzDoB,IAAI,EAAGhD,SAAW;kBAClBqC,OAAO,EACNY,KAA4C,IACxC;oBACJA,KAAK,CAACC,eAAe,CAAC,CAAC;oBACvB7B,eAAe,CAAE,CAAE,CAAC;kBACrB;gBAAG,CACH;cAAC,CACD,CACF;YAAA,CACI;UAAC,CACH,CAAC;QAER;MAAG,CACH;IAAC,CACE;EAAC,CACG,CAAC;AAEb,CAAC","ignoreList":[]}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useSelect } from '@wordpress/data';
5
+ import { store as coreStore } from '@wordpress/core-data';
6
+
7
+ /**
8
+ * Internal dependencies
9
+ */
10
+ import { jsx as _jsx } from "react/jsx-runtime";
11
+ export const FeaturedImageView = ({
12
+ item
13
+ }) => {
14
+ const mediaId = item.featured_media;
15
+ const media = useSelect(select => {
16
+ const {
17
+ getEntityRecord
18
+ } = select(coreStore);
19
+ return mediaId ? getEntityRecord('root', 'media', mediaId) : null;
20
+ }, [mediaId]);
21
+ const url = media?.source_url;
22
+ if (url) {
23
+ return /*#__PURE__*/_jsx("img", {
24
+ className: "fields-controls__featured-image-image",
25
+ src: url,
26
+ alt: ""
27
+ });
28
+ }
29
+ return /*#__PURE__*/_jsx("span", {
30
+ className: "fields-controls__featured-image-placeholder"
31
+ });
32
+ };
33
+ //# sourceMappingURL=featured-image-view.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useSelect","store","coreStore","jsx","_jsx","FeaturedImageView","item","mediaId","featured_media","media","select","getEntityRecord","url","source_url","className","src","alt"],"sources":["@wordpress/fields/src/fields/featured-image/featured-image-view.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\nimport type { DataViewRenderFieldProps } from '@wordpress/dataviews';\n\nexport const FeaturedImageView = ( {\n\titem,\n}: DataViewRenderFieldProps< BasePost > ) => {\n\tconst mediaId = item.featured_media;\n\n\tconst media = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecord } = select( coreStore );\n\t\t\treturn mediaId ? getEntityRecord( 'root', 'media', mediaId ) : null;\n\t\t},\n\t\t[ mediaId ]\n\t);\n\tconst url = media?.source_url;\n\n\tif ( url ) {\n\t\treturn (\n\t\t\t<img\n\t\t\t\tclassName=\"fields-controls__featured-image-image\"\n\t\t\t\tsrc={ url }\n\t\t\t\talt=\"\"\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn <span className=\"fields-controls__featured-image-placeholder\" />;\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;;AAEzD;AACA;AACA;AAFA,SAAAC,GAAA,IAAAC,IAAA;AAMA,OAAO,MAAMC,iBAAiB,GAAGA,CAAE;EAClCC;AACqC,CAAC,KAAM;EAC5C,MAAMC,OAAO,GAAGD,IAAI,CAACE,cAAc;EAEnC,MAAMC,KAAK,GAAGT,SAAS,CACpBU,MAAM,IAAM;IACb,MAAM;MAAEC;IAAgB,CAAC,GAAGD,MAAM,CAAER,SAAU,CAAC;IAC/C,OAAOK,OAAO,GAAGI,eAAe,CAAE,MAAM,EAAE,OAAO,EAAEJ,OAAQ,CAAC,GAAG,IAAI;EACpE,CAAC,EACD,CAAEA,OAAO,CACV,CAAC;EACD,MAAMK,GAAG,GAAGH,KAAK,EAAEI,UAAU;EAE7B,IAAKD,GAAG,EAAG;IACV,oBACCR,IAAA;MACCU,SAAS,EAAC,uCAAuC;MACjDC,GAAG,EAAGH,GAAK;MACXI,GAAG,EAAC;IAAE,CACN,CAAC;EAEJ;EAEA,oBAAOZ,IAAA;IAAMU,SAAS,EAAC;EAA6C,CAAE,CAAC;AACxE,CAAC","ignoreList":[]}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+
5
+ /**
6
+ * Internal dependencies
7
+ */
8
+
9
+ import { __ } from '@wordpress/i18n';
10
+ import { FeaturedImageEdit } from './featured-image-edit';
11
+ import { FeaturedImageView } from './featured-image-view';
12
+ const featuredImageField = {
13
+ id: 'featured_media',
14
+ type: 'text',
15
+ label: __('Featured Image'),
16
+ getValue: ({
17
+ item
18
+ }) => item.featured_media,
19
+ Edit: FeaturedImageEdit,
20
+ render: FeaturedImageView,
21
+ enableSorting: false
22
+ };
23
+ export default featuredImageField;
24
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["__","FeaturedImageEdit","FeaturedImageView","featuredImageField","id","type","label","getValue","item","featured_media","Edit","render","enableSorting"],"sources":["@wordpress/fields/src/fields/featured-image/index.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport type { Field } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\nimport { __ } from '@wordpress/i18n';\nimport { FeaturedImageEdit } from './featured-image-edit';\nimport { FeaturedImageView } from './featured-image-view';\n\nconst featuredImageField: Field< BasePost > = {\n\tid: 'featured_media',\n\ttype: 'text',\n\tlabel: __( 'Featured Image' ),\n\tgetValue: ( { item } ) => item.featured_media,\n\tEdit: FeaturedImageEdit,\n\trender: FeaturedImageView,\n\tenableSorting: false,\n};\n\nexport default featuredImageField;\n"],"mappings":"AAAA;AACA;AACA;;AAGA;AACA;AACA;;AAEA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,iBAAiB,QAAQ,uBAAuB;AACzD,SAASC,iBAAiB,QAAQ,uBAAuB;AAEzD,MAAMC,kBAAqC,GAAG;EAC7CC,EAAE,EAAE,gBAAgB;EACpBC,IAAI,EAAE,MAAM;EACZC,KAAK,EAAEN,EAAE,CAAE,gBAAiB,CAAC;EAC7BO,QAAQ,EAAEA,CAAE;IAAEC;EAAK,CAAC,KAAMA,IAAI,CAACC,cAAc;EAC7CC,IAAI,EAAET,iBAAiB;EACvBU,MAAM,EAAET,iBAAiB;EACzBU,aAAa,EAAE;AAChB,CAAC;AAED,eAAeT,kBAAkB","ignoreList":[]}
@@ -1,3 +1,6 @@
1
+ export { default as slugField } from './slug';
1
2
  export { default as titleField } from './title';
2
3
  export { default as orderField } from './order';
4
+ export { default as featuredImageField } from './featured-image';
5
+ export { default as parentField } from './parent';
3
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["default","titleField","orderField"],"sources":["@wordpress/fields/src/fields/index.ts"],"sourcesContent":["export { default as titleField } from './title';\nexport { default as orderField } from './order';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,UAAU,QAAQ,SAAS;AAC/C,SAASD,OAAO,IAAIE,UAAU,QAAQ,SAAS","ignoreList":[]}
1
+ {"version":3,"names":["default","slugField","titleField","orderField","featuredImageField","parentField"],"sources":["@wordpress/fields/src/fields/index.ts"],"sourcesContent":["export { default as slugField } from './slug';\nexport { default as titleField } from './title';\nexport { default as orderField } from './order';\nexport { default as featuredImageField } from './featured-image';\nexport { default as parentField } from './parent';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,SAAS,QAAQ,QAAQ;AAC7C,SAASD,OAAO,IAAIE,UAAU,QAAQ,SAAS;AAC/C,SAASF,OAAO,IAAIG,UAAU,QAAQ,SAAS;AAC/C,SAASH,OAAO,IAAII,kBAAkB,QAAQ,kBAAkB;AAChE,SAASJ,OAAO,IAAIK,WAAW,QAAQ,UAAU","ignoreList":[]}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+
5
+ /**
6
+ * Internal dependencies
7
+ */
8
+
9
+ import { __ } from '@wordpress/i18n';
10
+ import { ParentEdit } from './parent-edit';
11
+ import { ParentView } from './parent-view';
12
+ const parentField = {
13
+ id: 'parent',
14
+ type: 'text',
15
+ label: __('Parent'),
16
+ getValue: ({
17
+ item
18
+ }) => item.parent,
19
+ Edit: ParentEdit,
20
+ render: ParentView,
21
+ enableSorting: true
22
+ };
23
+
24
+ /**
25
+ * This field is used to display the post parent.
26
+ */
27
+ export default parentField;
28
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["__","ParentEdit","ParentView","parentField","id","type","label","getValue","item","parent","Edit","render","enableSorting"],"sources":["@wordpress/fields/src/fields/parent/index.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport type { Field } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\nimport { __ } from '@wordpress/i18n';\nimport { ParentEdit } from './parent-edit';\nimport { ParentView } from './parent-view';\n\nconst parentField: Field< BasePost > = {\n\tid: 'parent',\n\ttype: 'text',\n\tlabel: __( 'Parent' ),\n\tgetValue: ( { item } ) => item.parent,\n\tEdit: ParentEdit,\n\trender: ParentView,\n\tenableSorting: true,\n};\n\n/**\n * This field is used to display the post parent.\n */\nexport default parentField;\n"],"mappings":"AAAA;AACA;AACA;;AAGA;AACA;AACA;;AAEA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,UAAU,QAAQ,eAAe;AAC1C,SAASC,UAAU,QAAQ,eAAe;AAE1C,MAAMC,WAA8B,GAAG;EACtCC,EAAE,EAAE,QAAQ;EACZC,IAAI,EAAE,MAAM;EACZC,KAAK,EAAEN,EAAE,CAAE,QAAS,CAAC;EACrBO,QAAQ,EAAEA,CAAE;IAAEC;EAAK,CAAC,KAAMA,IAAI,CAACC,MAAM;EACrCC,IAAI,EAAET,UAAU;EAChBU,MAAM,EAAET,UAAU;EAClBU,aAAa,EAAE;AAChB,CAAC;;AAED;AACA;AACA;AACA,eAAeT,WAAW","ignoreList":[]}
@@ -0,0 +1,230 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { ComboboxControl, ExternalLink } from '@wordpress/components';
5
+ import { useSelect } from '@wordpress/data';
6
+ import { createInterpolateElement, useCallback, useMemo, useState } from '@wordpress/element';
7
+ // @ts-ignore
8
+ import { store as coreStore } from '@wordpress/core-data';
9
+ /**
10
+ * External dependencies
11
+ */
12
+ import removeAccents from 'remove-accents';
13
+
14
+ /**
15
+ * Internal dependencies
16
+ */
17
+ import { debounce } from '@wordpress/compose';
18
+ import { decodeEntities } from '@wordpress/html-entities';
19
+ import { __, sprintf } from '@wordpress/i18n';
20
+ import { getTitleWithFallbackName } from './utils';
21
+ import { filterURLForDisplay } from '@wordpress/url';
22
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
23
+ function buildTermsTree(flatTerms) {
24
+ const flatTermsWithParentAndChildren = flatTerms.map(term => {
25
+ return {
26
+ children: [],
27
+ ...term
28
+ };
29
+ });
30
+
31
+ // All terms should have a `parent` because we're about to index them by it.
32
+ if (flatTermsWithParentAndChildren.some(({
33
+ parent
34
+ }) => parent === null || parent === undefined)) {
35
+ return flatTermsWithParentAndChildren;
36
+ }
37
+ const termsByParent = flatTermsWithParentAndChildren.reduce((acc, term) => {
38
+ const {
39
+ parent
40
+ } = term;
41
+ if (!acc[parent]) {
42
+ acc[parent] = [];
43
+ }
44
+ acc[parent].push(term);
45
+ return acc;
46
+ }, {});
47
+ const fillWithChildren = terms => {
48
+ return terms.map(term => {
49
+ const children = termsByParent[term.id];
50
+ return {
51
+ ...term,
52
+ children: children && children.length ? fillWithChildren(children) : []
53
+ };
54
+ });
55
+ };
56
+ return fillWithChildren(termsByParent['0'] || []);
57
+ }
58
+ export const getItemPriority = (name, searchValue) => {
59
+ const normalizedName = removeAccents(name || '').toLowerCase();
60
+ const normalizedSearch = removeAccents(searchValue || '').toLowerCase();
61
+ if (normalizedName === normalizedSearch) {
62
+ return 0;
63
+ }
64
+ if (normalizedName.startsWith(normalizedSearch)) {
65
+ return normalizedName.length;
66
+ }
67
+ return Infinity;
68
+ };
69
+ export function PageAttributesParent({
70
+ data,
71
+ onChangeControl
72
+ }) {
73
+ const [fieldValue, setFieldValue] = useState(null);
74
+ const pageId = data.parent;
75
+ const postId = data.id;
76
+ const postTypeSlug = data.type;
77
+ const {
78
+ parentPostTitle,
79
+ pageItems,
80
+ isHierarchical
81
+ } = useSelect(select => {
82
+ // @ts-expect-error getPostType is not typed
83
+ const {
84
+ getEntityRecord,
85
+ getEntityRecords,
86
+ getPostType
87
+ } = select(coreStore);
88
+ const postTypeInfo = getPostType(postTypeSlug);
89
+ const postIsHierarchical = postTypeInfo?.hierarchical && postTypeInfo.viewable;
90
+ const parentPost = pageId ? getEntityRecord('postType', postTypeSlug, pageId) : null;
91
+ const query = {
92
+ per_page: 100,
93
+ exclude: postId,
94
+ parent_exclude: postId,
95
+ orderby: 'menu_order',
96
+ order: 'asc',
97
+ _fields: 'id,title,parent',
98
+ ...(fieldValue !== null && {
99
+ search: fieldValue
100
+ })
101
+ };
102
+ return {
103
+ isHierarchical: postIsHierarchical,
104
+ parentPostTitle: parentPost ? getTitleWithFallbackName(parentPost) : '',
105
+ pageItems: postIsHierarchical ? getEntityRecords('postType', postTypeSlug, query) : null
106
+ };
107
+ }, [fieldValue, pageId, postId, postTypeSlug]);
108
+
109
+ /**
110
+ * This logic has been copied from https://github.com/WordPress/gutenberg/blob/0249771b519d5646171fb9fae422006c8ab773f2/packages/editor/src/components/page-attributes/parent.js#L106.
111
+ */
112
+ const parentOptions = useMemo(() => {
113
+ const getOptionsFromTree = (tree, level = 0) => {
114
+ const mappedNodes = tree.map(treeNode => [{
115
+ value: treeNode.id,
116
+ label: '— '.repeat(level) + decodeEntities(treeNode.name),
117
+ rawName: treeNode.name
118
+ }, ...getOptionsFromTree(treeNode.children || [], level + 1)]);
119
+ const sortedNodes = mappedNodes.sort(([a], [b]) => {
120
+ const priorityA = getItemPriority(a.rawName, fieldValue !== null && fieldValue !== void 0 ? fieldValue : '');
121
+ const priorityB = getItemPriority(b.rawName, fieldValue !== null && fieldValue !== void 0 ? fieldValue : '');
122
+ return priorityA >= priorityB ? 1 : -1;
123
+ });
124
+ return sortedNodes.flat();
125
+ };
126
+ if (!pageItems) {
127
+ return [];
128
+ }
129
+ let tree = pageItems.map(item => {
130
+ var _item$parent;
131
+ return {
132
+ id: item.id,
133
+ parent: (_item$parent = item.parent) !== null && _item$parent !== void 0 ? _item$parent : null,
134
+ name: getTitleWithFallbackName(item)
135
+ };
136
+ });
137
+
138
+ // Only build a hierarchical tree when not searching.
139
+ if (!fieldValue) {
140
+ tree = buildTermsTree(tree);
141
+ }
142
+ const opts = getOptionsFromTree(tree);
143
+
144
+ // Ensure the current parent is in the options list.
145
+ const optsHasParent = opts.find(item => item.value === pageId);
146
+ if (pageId && parentPostTitle && !optsHasParent) {
147
+ opts.unshift({
148
+ value: pageId,
149
+ label: parentPostTitle,
150
+ rawName: ''
151
+ });
152
+ }
153
+ return opts.map(option => ({
154
+ ...option,
155
+ value: option.value.toString()
156
+ }));
157
+ }, [pageItems, fieldValue, parentPostTitle, pageId]);
158
+ if (!isHierarchical) {
159
+ return null;
160
+ }
161
+
162
+ /**
163
+ * Handle user input.
164
+ *
165
+ * @param {string} inputValue The current value of the input field.
166
+ */
167
+ const handleKeydown = inputValue => {
168
+ setFieldValue(inputValue);
169
+ };
170
+
171
+ /**
172
+ * Handle author selection.
173
+ *
174
+ * @param {Object} selectedPostId The selected Author.
175
+ */
176
+ const handleChange = selectedPostId => {
177
+ if (selectedPostId) {
178
+ var _parseInt;
179
+ return onChangeControl((_parseInt = parseInt(selectedPostId, 10)) !== null && _parseInt !== void 0 ? _parseInt : 0);
180
+ }
181
+ onChangeControl(0);
182
+ };
183
+ return /*#__PURE__*/_jsx(ComboboxControl, {
184
+ __nextHasNoMarginBottom: true,
185
+ __next40pxDefaultSize: true,
186
+ label: __('Parent'),
187
+ help: __('Choose a parent page.'),
188
+ value: pageId?.toString(),
189
+ options: parentOptions,
190
+ onFilterValueChange: debounce(value => handleKeydown(value), 300),
191
+ onChange: handleChange,
192
+ hideLabelFromVision: true
193
+ });
194
+ }
195
+ export const ParentEdit = ({
196
+ data,
197
+ field,
198
+ onChange
199
+ }) => {
200
+ const {
201
+ id
202
+ } = field;
203
+ const homeUrl = useSelect(select => {
204
+ // @ts-expect-error getEntityRecord is not typed with unstableBase as argument.
205
+ return select(coreStore).getEntityRecord('root', '__unstableBase')?.home;
206
+ }, []);
207
+ const onChangeControl = useCallback(newValue => onChange({
208
+ [id]: newValue
209
+ }), [id, onChange]);
210
+ return /*#__PURE__*/_jsx("fieldset", {
211
+ className: "fields-controls__parent",
212
+ children: /*#__PURE__*/_jsxs("div", {
213
+ children: [createInterpolateElement(sprintf(/* translators: %1$s The home URL of the WordPress installation without the scheme. */
214
+ __('Child pages inherit characteristics from their parent, such as URL structure. For instance, if "Pricing" is a child of "Services", its URL would be %1$s<wbr />/services<wbr />/pricing.'), filterURLForDisplay(homeUrl).replace(/([/.])/g, '<wbr />$1')), {
215
+ wbr: /*#__PURE__*/_jsx("wbr", {})
216
+ }), /*#__PURE__*/_jsx("p", {
217
+ children: createInterpolateElement(__('They also show up as sub-items in the default navigation menu. <a>Learn more.</a>'), {
218
+ a: /*#__PURE__*/_jsx(ExternalLink, {
219
+ href: __('https://wordpress.org/documentation/article/page-post-settings-sidebar/#page-attributes'),
220
+ children: undefined
221
+ })
222
+ })
223
+ }), /*#__PURE__*/_jsx(PageAttributesParent, {
224
+ data: data,
225
+ onChangeControl: onChangeControl
226
+ })]
227
+ })
228
+ });
229
+ };
230
+ //# sourceMappingURL=parent-edit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ComboboxControl","ExternalLink","useSelect","createInterpolateElement","useCallback","useMemo","useState","store","coreStore","removeAccents","debounce","decodeEntities","__","sprintf","getTitleWithFallbackName","filterURLForDisplay","jsx","_jsx","jsxs","_jsxs","buildTermsTree","flatTerms","flatTermsWithParentAndChildren","map","term","children","some","parent","undefined","termsByParent","reduce","acc","push","fillWithChildren","terms","id","length","getItemPriority","name","searchValue","normalizedName","toLowerCase","normalizedSearch","startsWith","Infinity","PageAttributesParent","data","onChangeControl","fieldValue","setFieldValue","pageId","postId","postTypeSlug","type","parentPostTitle","pageItems","isHierarchical","select","getEntityRecord","getEntityRecords","getPostType","postTypeInfo","postIsHierarchical","hierarchical","viewable","parentPost","query","per_page","exclude","parent_exclude","orderby","order","_fields","search","parentOptions","getOptionsFromTree","tree","level","mappedNodes","treeNode","value","label","repeat","rawName","sortedNodes","sort","a","b","priorityA","priorityB","flat","item","_item$parent","opts","optsHasParent","find","unshift","option","toString","handleKeydown","inputValue","handleChange","selectedPostId","_parseInt","parseInt","__nextHasNoMarginBottom","__next40pxDefaultSize","help","options","onFilterValueChange","onChange","hideLabelFromVision","ParentEdit","field","homeUrl","home","newValue","className","replace","wbr","href"],"sources":["@wordpress/fields/src/fields/parent/parent-edit.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { ComboboxControl, ExternalLink } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tcreateInterpolateElement,\n\tuseCallback,\n\tuseMemo,\n\tuseState,\n} from '@wordpress/element';\n// @ts-ignore\nimport { store as coreStore } from '@wordpress/core-data';\nimport type { DataFormControlProps } from '@wordpress/dataviews';\n\n/**\n * External dependencies\n */\nimport removeAccents from 'remove-accents';\n\n/**\n * Internal dependencies\n */\nimport { debounce } from '@wordpress/compose';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { __, sprintf } from '@wordpress/i18n';\nimport type { BasePost } from '../../types';\nimport { getTitleWithFallbackName } from './utils';\nimport { filterURLForDisplay } from '@wordpress/url';\n\ntype TreeBase = {\n\tid: number;\n\tname: string;\n\t[ key: string ]: any;\n};\n\ntype TreeWithParent = TreeBase & {\n\tparent: number;\n};\n\ntype TreeWithoutParent = TreeBase & {\n\tparent: null;\n};\n\ntype Tree = TreeWithParent | TreeWithoutParent;\n\nfunction buildTermsTree( flatTerms: Tree[] ) {\n\tconst flatTermsWithParentAndChildren = flatTerms.map( ( term ) => {\n\t\treturn {\n\t\t\tchildren: [],\n\t\t\t...term,\n\t\t};\n\t} );\n\n\t// All terms should have a `parent` because we're about to index them by it.\n\tif (\n\t\tflatTermsWithParentAndChildren.some(\n\t\t\t( { parent } ) => parent === null || parent === undefined\n\t\t)\n\t) {\n\t\treturn flatTermsWithParentAndChildren as TreeWithParent[];\n\t}\n\n\tconst termsByParent = (\n\t\tflatTermsWithParentAndChildren as TreeWithParent[]\n\t ).reduce(\n\t\t( acc, term ) => {\n\t\t\tconst { parent } = term;\n\t\t\tif ( ! acc[ parent ] ) {\n\t\t\t\tacc[ parent ] = [];\n\t\t\t}\n\t\t\tacc[ parent ].push( term );\n\t\t\treturn acc;\n\t\t},\n\t\t{} as Record< string, Array< TreeWithParent > >\n\t);\n\n\tconst fillWithChildren = (\n\t\tterms: Array< TreeWithParent >\n\t): Array< TreeWithParent > => {\n\t\treturn terms.map( ( term ) => {\n\t\t\tconst children = termsByParent[ term.id ];\n\t\t\treturn {\n\t\t\t\t...term,\n\t\t\t\tchildren:\n\t\t\t\t\tchildren && children.length\n\t\t\t\t\t\t? fillWithChildren( children )\n\t\t\t\t\t\t: [],\n\t\t\t};\n\t\t} );\n\t};\n\n\treturn fillWithChildren( termsByParent[ '0' ] || [] );\n}\n\nexport const getItemPriority = ( name: string, searchValue: string ) => {\n\tconst normalizedName = removeAccents( name || '' ).toLowerCase();\n\tconst normalizedSearch = removeAccents( searchValue || '' ).toLowerCase();\n\tif ( normalizedName === normalizedSearch ) {\n\t\treturn 0;\n\t}\n\n\tif ( normalizedName.startsWith( normalizedSearch ) ) {\n\t\treturn normalizedName.length;\n\t}\n\n\treturn Infinity;\n};\n\nexport function PageAttributesParent( {\n\tdata,\n\tonChangeControl,\n}: {\n\tdata: BasePost;\n\tonChangeControl: ( newValue: number ) => void;\n} ) {\n\tconst [ fieldValue, setFieldValue ] = useState< null | string >( null );\n\n\tconst pageId = data.parent;\n\tconst postId = data.id;\n\tconst postTypeSlug = data.type;\n\n\tconst { parentPostTitle, pageItems, isHierarchical } = useSelect(\n\t\t( select ) => {\n\t\t\t// @ts-expect-error getPostType is not typed\n\t\t\tconst { getEntityRecord, getEntityRecords, getPostType } =\n\t\t\t\tselect( coreStore );\n\n\t\t\tconst postTypeInfo = getPostType( postTypeSlug );\n\n\t\t\tconst postIsHierarchical =\n\t\t\t\tpostTypeInfo?.hierarchical && postTypeInfo.viewable;\n\n\t\t\tconst parentPost = pageId\n\t\t\t\t? getEntityRecord< BasePost >(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\tpostTypeSlug,\n\t\t\t\t\t\tpageId\n\t\t\t\t )\n\t\t\t\t: null;\n\n\t\t\tconst query = {\n\t\t\t\tper_page: 100,\n\t\t\t\texclude: postId,\n\t\t\t\tparent_exclude: postId,\n\t\t\t\torderby: 'menu_order',\n\t\t\t\torder: 'asc',\n\t\t\t\t_fields: 'id,title,parent',\n\t\t\t\t...( fieldValue !== null && {\n\t\t\t\t\tsearch: fieldValue,\n\t\t\t\t} ),\n\t\t\t};\n\n\t\t\treturn {\n\t\t\t\tisHierarchical: postIsHierarchical,\n\t\t\t\tparentPostTitle: parentPost\n\t\t\t\t\t? getTitleWithFallbackName( parentPost )\n\t\t\t\t\t: '',\n\t\t\t\tpageItems: postIsHierarchical\n\t\t\t\t\t? getEntityRecords< BasePost >(\n\t\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t\tpostTypeSlug,\n\t\t\t\t\t\t\tquery\n\t\t\t\t\t )\n\t\t\t\t\t: null,\n\t\t\t};\n\t\t},\n\t\t[ fieldValue, pageId, postId, postTypeSlug ]\n\t);\n\n\t/**\n\t * This logic has been copied from https://github.com/WordPress/gutenberg/blob/0249771b519d5646171fb9fae422006c8ab773f2/packages/editor/src/components/page-attributes/parent.js#L106.\n\t */\n\tconst parentOptions = useMemo( () => {\n\t\tconst getOptionsFromTree = (\n\t\t\ttree: Array< Tree >,\n\t\t\tlevel = 0\n\t\t): Array< {\n\t\t\tvalue: number;\n\t\t\tlabel: string;\n\t\t\trawName: string;\n\t\t} > => {\n\t\t\tconst mappedNodes = tree.map( ( treeNode ) => [\n\t\t\t\t{\n\t\t\t\t\tvalue: treeNode.id,\n\t\t\t\t\tlabel:\n\t\t\t\t\t\t'— '.repeat( level ) + decodeEntities( treeNode.name ),\n\t\t\t\t\trawName: treeNode.name,\n\t\t\t\t},\n\t\t\t\t...getOptionsFromTree( treeNode.children || [], level + 1 ),\n\t\t\t] );\n\n\t\t\tconst sortedNodes = mappedNodes.sort( ( [ a ], [ b ] ) => {\n\t\t\t\tconst priorityA = getItemPriority(\n\t\t\t\t\ta.rawName,\n\t\t\t\t\tfieldValue ?? ''\n\t\t\t\t);\n\t\t\t\tconst priorityB = getItemPriority(\n\t\t\t\t\tb.rawName,\n\t\t\t\t\tfieldValue ?? ''\n\t\t\t\t);\n\t\t\t\treturn priorityA >= priorityB ? 1 : -1;\n\t\t\t} );\n\n\t\t\treturn sortedNodes.flat();\n\t\t};\n\n\t\tif ( ! pageItems ) {\n\t\t\treturn [];\n\t\t}\n\n\t\tlet tree = pageItems.map( ( item ) => ( {\n\t\t\tid: item.id as number,\n\t\t\tparent: item.parent ?? null,\n\t\t\tname: getTitleWithFallbackName( item ),\n\t\t} ) );\n\n\t\t// Only build a hierarchical tree when not searching.\n\t\tif ( ! fieldValue ) {\n\t\t\ttree = buildTermsTree( tree );\n\t\t}\n\n\t\tconst opts = getOptionsFromTree( tree );\n\n\t\t// Ensure the current parent is in the options list.\n\t\tconst optsHasParent = opts.find( ( item ) => item.value === pageId );\n\t\tif ( pageId && parentPostTitle && ! optsHasParent ) {\n\t\t\topts.unshift( {\n\t\t\t\tvalue: pageId,\n\t\t\t\tlabel: parentPostTitle,\n\t\t\t\trawName: '',\n\t\t\t} );\n\t\t}\n\t\treturn opts.map( ( option ) => ( {\n\t\t\t...option,\n\t\t\tvalue: option.value.toString(),\n\t\t} ) );\n\t}, [ pageItems, fieldValue, parentPostTitle, pageId ] );\n\n\tif ( ! isHierarchical ) {\n\t\treturn null;\n\t}\n\n\t/**\n\t * Handle user input.\n\t *\n\t * @param {string} inputValue The current value of the input field.\n\t */\n\tconst handleKeydown = ( inputValue: string ) => {\n\t\tsetFieldValue( inputValue );\n\t};\n\n\t/**\n\t * Handle author selection.\n\t *\n\t * @param {Object} selectedPostId The selected Author.\n\t */\n\tconst handleChange = ( selectedPostId: string | null | undefined ) => {\n\t\tif ( selectedPostId ) {\n\t\t\treturn onChangeControl( parseInt( selectedPostId, 10 ) ?? 0 );\n\t\t}\n\n\t\tonChangeControl( 0 );\n\t};\n\n\treturn (\n\t\t<ComboboxControl\n\t\t\t__nextHasNoMarginBottom\n\t\t\t__next40pxDefaultSize\n\t\t\tlabel={ __( 'Parent' ) }\n\t\t\thelp={ __( 'Choose a parent page.' ) }\n\t\t\tvalue={ pageId?.toString() }\n\t\t\toptions={ parentOptions }\n\t\t\tonFilterValueChange={ debounce(\n\t\t\t\t( value: unknown ) => handleKeydown( value as string ),\n\t\t\t\t300\n\t\t\t) }\n\t\t\tonChange={ handleChange }\n\t\t\thideLabelFromVision\n\t\t/>\n\t);\n}\n\nexport const ParentEdit = ( {\n\tdata,\n\tfield,\n\tonChange,\n}: DataFormControlProps< BasePost > ) => {\n\tconst { id } = field;\n\n\tconst homeUrl = useSelect( ( select ) => {\n\t\t// @ts-expect-error getEntityRecord is not typed with unstableBase as argument.\n\t\treturn select( coreStore ).getEntityRecord< {\n\t\t\thome: string;\n\t\t} >( 'root', '__unstableBase' )?.home as string;\n\t}, [] );\n\n\tconst onChangeControl = useCallback(\n\t\t( newValue?: number ) =>\n\t\t\tonChange( {\n\t\t\t\t[ id ]: newValue,\n\t\t\t} ),\n\t\t[ id, onChange ]\n\t);\n\n\treturn (\n\t\t<fieldset className=\"fields-controls__parent\">\n\t\t\t<div>\n\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\tsprintf(\n\t\t\t\t\t\t/* translators: %1$s The home URL of the WordPress installation without the scheme. */\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'Child pages inherit characteristics from their parent, such as URL structure. For instance, if \"Pricing\" is a child of \"Services\", its URL would be %1$s<wbr />/services<wbr />/pricing.'\n\t\t\t\t\t\t),\n\t\t\t\t\t\tfilterURLForDisplay( homeUrl ).replace(\n\t\t\t\t\t\t\t/([/.])/g,\n\t\t\t\t\t\t\t'<wbr />$1'\n\t\t\t\t\t\t)\n\t\t\t\t\t),\n\t\t\t\t\t{\n\t\t\t\t\t\twbr: <wbr />,\n\t\t\t\t\t}\n\t\t\t\t) }\n\t\t\t\t<p>\n\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'They also show up as sub-items in the default navigation menu. <a>Learn more.</a>'\n\t\t\t\t\t\t),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ta: (\n\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t\t\t'https://wordpress.org/documentation/article/page-post-settings-sidebar/#page-attributes'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\tchildren={ undefined }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t}\n\t\t\t\t\t) }\n\t\t\t\t</p>\n\t\t\t\t<PageAttributesParent\n\t\t\t\t\tdata={ data }\n\t\t\t\t\tonChangeControl={ onChangeControl }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</fieldset>\n\t);\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,eAAe,EAAEC,YAAY,QAAQ,uBAAuB;AACrE,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SACCC,wBAAwB,EACxBC,WAAW,EACXC,OAAO,EACPC,QAAQ,QACF,oBAAoB;AAC3B;AACA,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AAGzD;AACA;AACA;AACA,OAAOC,aAAa,MAAM,gBAAgB;;AAE1C;AACA;AACA;AACA,SA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,MAAM,IAAM;IACxC;IACA,OAAOA,MAAM,CAAEjD,SAAU,CAAC,CAACkD,eAAe,CAErC,MAAM,EAAE,gBAAiB,CAAC,EAAEyD,IAAI;EACtC,CAAC,EAAE,EAAG,CAAC;EAEP,MAAMpE,eAAe,GAAG3C,WAAW,CAChCgH,QAAiB,IAClBN,QAAQ,CAAE;IACT,CAAE3E,EAAE,GAAIiF;EACT,CAAE,CAAC,EACJ,CAAEjF,EAAE,EAAE2E,QAAQ,CACf,CAAC;EAED,oBACC7F,IAAA;IAAUoG,SAAS,EAAC,yBAAyB;IAAA5F,QAAA,eAC5CN,KAAA;MAAAM,QAAA,GACGtB,wBAAwB,CACzBU,OAAO,CACN;MACAD,EAAE,CACD,0LACD,CAAC,EACDG,mBAAmB,CAAEmG,OAAQ,CAAC,CAACI,OAAO,CACrC,SAAS,EACT,WACD,CACD,CAAC,EACD;QACCC,GAAG,eAAEtG,IAAA,UAAM;MACZ,CACD,CAAC,eACDA,IAAA;QAAAQ,QAAA,EACGtB,wBAAwB,CACzBS,EAAE,CACD,mFACD,CAAC,EACD;UACC0E,CAAC,eACArE,IAAA,CAAChB,YAAY;YACZuH,IAAI,EAAG5G,EAAE,CACR,yFACD,CAAG;YACHa,QAAQ,EAAGG;UAAW,CACtB;QAEH,CACD;MAAC,CACC,CAAC,eACJX,IAAA,CAAC4B,oBAAoB;QACpBC,IAAI,EAAGA,IAAM;QACbC,eAAe,EAAGA;MAAiB,CACnC,CAAC;IAAA,CACE;EAAC,CACG,CAAC;AAEb,CAAC","ignoreList":[]}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useSelect } from '@wordpress/data';
5
+ import { store as coreStore } from '@wordpress/core-data';
6
+
7
+ /**
8
+ * Internal dependencies
9
+ */
10
+
11
+ import { getTitleWithFallbackName } from './utils';
12
+ import { __ } from '@wordpress/i18n';
13
+ import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
14
+ export const ParentView = ({
15
+ item
16
+ }) => {
17
+ const parent = useSelect(select => {
18
+ const {
19
+ getEntityRecord
20
+ } = select(coreStore);
21
+ return item?.parent ? getEntityRecord('postType', item.type, item.parent) : null;
22
+ }, [item.parent, item.type]);
23
+ if (parent) {
24
+ return /*#__PURE__*/_jsx(_Fragment, {
25
+ children: getTitleWithFallbackName(parent)
26
+ });
27
+ }
28
+ return /*#__PURE__*/_jsx(_Fragment, {
29
+ children: __('None')
30
+ });
31
+ };
32
+ //# sourceMappingURL=parent-view.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useSelect","store","coreStore","getTitleWithFallbackName","__","Fragment","_Fragment","jsx","_jsx","ParentView","item","parent","select","getEntityRecord","type","children"],"sources":["@wordpress/fields/src/fields/parent/parent-view.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\nimport type { DataViewRenderFieldProps } from '@wordpress/dataviews';\nimport { getTitleWithFallbackName } from './utils';\nimport { __ } from '@wordpress/i18n';\n\nexport const ParentView = ( {\n\titem,\n}: DataViewRenderFieldProps< BasePost > ) => {\n\tconst parent = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecord } = select( coreStore );\n\t\t\treturn item?.parent\n\t\t\t\t? getEntityRecord( 'postType', item.type, item.parent )\n\t\t\t\t: null;\n\t\t},\n\t\t[ item.parent, item.type ]\n\t);\n\n\tif ( parent ) {\n\t\treturn <>{ getTitleWithFallbackName( parent ) }</>;\n\t}\n\n\treturn <>{ __( 'None' ) }</>;\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;;AAEzD;AACA;AACA;;AAGA,SAASC,wBAAwB,QAAQ,SAAS;AAClD,SAASC,EAAE,QAAQ,iBAAiB;AAAC,SAAAC,QAAA,IAAAC,SAAA,EAAAC,GAAA,IAAAC,IAAA;AAErC,OAAO,MAAMC,UAAU,GAAGA,CAAE;EAC3BC;AACqC,CAAC,KAAM;EAC5C,MAAMC,MAAM,GAAGX,SAAS,CACrBY,MAAM,IAAM;IACb,MAAM;MAAEC;IAAgB,CAAC,GAAGD,MAAM,CAAEV,SAAU,CAAC;IAC/C,OAAOQ,IAAI,EAAEC,MAAM,GAChBE,eAAe,CAAE,UAAU,EAAEH,IAAI,CAACI,IAAI,EAAEJ,IAAI,CAACC,MAAO,CAAC,GACrD,IAAI;EACR,CAAC,EACD,CAAED,IAAI,CAACC,MAAM,EAAED,IAAI,CAACI,IAAI,CACzB,CAAC;EAED,IAAKH,MAAM,EAAG;IACb,oBAAOH,IAAA,CAAAF,SAAA;MAAAS,QAAA,EAAIZ,wBAAwB,CAAEQ,MAAO;IAAC,CAAI,CAAC;EACnD;EAEA,oBAAOH,IAAA,CAAAF,SAAA;IAAAS,QAAA,EAAIX,EAAE,CAAE,MAAO;EAAC,CAAI,CAAC;AAC7B,CAAC","ignoreList":[]}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { decodeEntities } from '@wordpress/html-entities';
5
+ import { __ } from '@wordpress/i18n';
6
+
7
+ /**
8
+ * Internal dependencies
9
+ */
10
+
11
+ export function getTitleWithFallbackName(post) {
12
+ return typeof post.title === 'object' && 'rendered' in post.title && post.title.rendered ? decodeEntities(post.title.rendered) : `#${post?.id} (${__('no title')})`;
13
+ }
14
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["decodeEntities","__","getTitleWithFallbackName","post","title","rendered","id"],"sources":["@wordpress/fields/src/fields/parent/utils.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\n\nexport function getTitleWithFallbackName( post: BasePost ) {\n\treturn typeof post.title === 'object' &&\n\t\t'rendered' in post.title &&\n\t\tpost.title.rendered\n\t\t? decodeEntities( post.title.rendered )\n\t\t: `#${ post?.id } (${ __( 'no title' ) })`;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,cAAc,QAAQ,0BAA0B;AACzD,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;;AAGA,OAAO,SAASC,wBAAwBA,CAAEC,IAAc,EAAG;EAC1D,OAAO,OAAOA,IAAI,CAACC,KAAK,KAAK,QAAQ,IACpC,UAAU,IAAID,IAAI,CAACC,KAAK,IACxBD,IAAI,CAACC,KAAK,CAACC,QAAQ,GACjBL,cAAc,CAAEG,IAAI,CAACC,KAAK,CAACC,QAAS,CAAC,GACrC,IAAKF,IAAI,EAAEG,EAAE,KAAOL,EAAE,CAAE,UAAW,CAAC,GAAI;AAC5C","ignoreList":[]}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+
5
+ /**
6
+ * Internal dependencies
7
+ */
8
+
9
+ import { __ } from '@wordpress/i18n';
10
+ import SlugEdit from './slug-edit';
11
+ import SlugView from './slug-view';
12
+ const slugField = {
13
+ id: 'slug',
14
+ type: 'text',
15
+ label: __('Slug'),
16
+ getValue: ({
17
+ item
18
+ }) => item.slug,
19
+ Edit: SlugEdit,
20
+ render: SlugView
21
+ };
22
+ export default slugField;
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["__","SlugEdit","SlugView","slugField","id","type","label","getValue","item","slug","Edit","render"],"sources":["@wordpress/fields/src/fields/slug/index.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport type { Field } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\nimport { __ } from '@wordpress/i18n';\nimport SlugEdit from './slug-edit';\nimport SlugView from './slug-view';\n\nconst slugField: Field< BasePost > = {\n\tid: 'slug',\n\ttype: 'text',\n\tlabel: __( 'Slug' ),\n\tgetValue: ( { item } ) => item.slug,\n\tEdit: SlugEdit,\n\trender: SlugView,\n};\n\nexport default slugField;\n"],"mappings":"AAAA;AACA;AACA;;AAGA;AACA;AACA;;AAEA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,OAAOC,QAAQ,MAAM,aAAa;AAClC,OAAOC,QAAQ,MAAM,aAAa;AAElC,MAAMC,SAA4B,GAAG;EACpCC,EAAE,EAAE,MAAM;EACVC,IAAI,EAAE,MAAM;EACZC,KAAK,EAAEN,EAAE,CAAE,MAAO,CAAC;EACnBO,QAAQ,EAAEA,CAAE;IAAEC;EAAK,CAAC,KAAMA,IAAI,CAACC,IAAI;EACnCC,IAAI,EAAET,QAAQ;EACdU,MAAM,EAAET;AACT,CAAC;AAED,eAAeC,SAAS","ignoreList":[]}