@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,125 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { Button, ExternalLink, __experimentalInputControl as InputControl, __experimentalInputControlPrefixWrapper as InputControlPrefixWrapper, __experimentalVStack as VStack } from '@wordpress/components';
5
+ import { copySmall } from '@wordpress/icons';
6
+ import { useCopyToClipboard, useInstanceId } from '@wordpress/compose';
7
+ import { useDispatch } from '@wordpress/data';
8
+ import { useCallback, useEffect, useRef } from '@wordpress/element';
9
+ import { store as noticesStore } from '@wordpress/notices';
10
+ import { safeDecodeURIComponent } from '@wordpress/url';
11
+ import { __ } from '@wordpress/i18n';
12
+
13
+ /**
14
+ * Internal dependencies
15
+ */
16
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
17
+ const SlugEdit = ({
18
+ field,
19
+ onChange,
20
+ data
21
+ }) => {
22
+ var _field$getValue;
23
+ const {
24
+ id
25
+ } = field;
26
+ const slug = (_field$getValue = field.getValue({
27
+ item: data
28
+ })) !== null && _field$getValue !== void 0 ? _field$getValue : '';
29
+ const permalinkTemplate = data.permalink_template || '';
30
+ const PERMALINK_POSTNAME_REGEX = /%(?:postname|pagename)%/;
31
+ const [prefix, suffix] = permalinkTemplate.split(PERMALINK_POSTNAME_REGEX);
32
+ const permalinkPrefix = prefix;
33
+ const permalinkSuffix = suffix;
34
+ const isEditable = PERMALINK_POSTNAME_REGEX.test(permalinkTemplate);
35
+ const originalSlugRef = useRef(slug);
36
+ const slugToDisplay = slug || originalSlugRef.current;
37
+ const permalink = isEditable ? `${permalinkPrefix}${slugToDisplay}${permalinkSuffix}` : safeDecodeURIComponent(data.link || '');
38
+ useEffect(() => {
39
+ if (slug && originalSlugRef.current === undefined) {
40
+ originalSlugRef.current = slug;
41
+ }
42
+ }, [slug]);
43
+ const onChangeControl = useCallback(newValue => onChange({
44
+ [id]: newValue
45
+ }), [id, onChange]);
46
+ const {
47
+ createNotice
48
+ } = useDispatch(noticesStore);
49
+ const copyButtonRef = useCopyToClipboard(permalink, () => {
50
+ createNotice('info', __('Copied Permalink to clipboard.'), {
51
+ isDismissible: true,
52
+ type: 'snackbar'
53
+ });
54
+ });
55
+ const postUrlSlugDescriptionId = 'editor-post-url__slug-description-' + useInstanceId(SlugEdit);
56
+ return /*#__PURE__*/_jsxs("fieldset", {
57
+ className: "fields-controls__slug",
58
+ children: [isEditable && /*#__PURE__*/_jsxs(VStack, {
59
+ children: [/*#__PURE__*/_jsxs(VStack, {
60
+ spacing: "0px",
61
+ children: [/*#__PURE__*/_jsx("span", {
62
+ children: __('Customize the last part of the Permalink.')
63
+ }), /*#__PURE__*/_jsx(ExternalLink, {
64
+ href: "https://wordpress.org/documentation/article/page-post-settings-sidebar/#permalink",
65
+ children: __('Learn more')
66
+ })]
67
+ }), /*#__PURE__*/_jsx(InputControl, {
68
+ __next40pxDefaultSize: true,
69
+ prefix: /*#__PURE__*/_jsx(InputControlPrefixWrapper, {
70
+ children: "/"
71
+ }),
72
+ suffix: /*#__PURE__*/_jsx(Button, {
73
+ __next40pxDefaultSize: true,
74
+ icon: copySmall,
75
+ ref: copyButtonRef,
76
+ label: __('Copy')
77
+ }),
78
+ label: __('Link'),
79
+ hideLabelFromVision: true,
80
+ value: slug,
81
+ autoComplete: "off",
82
+ spellCheck: "false",
83
+ type: "text",
84
+ className: "fields-controls__slug-input",
85
+ onChange: newValue => {
86
+ onChangeControl(newValue);
87
+ },
88
+ onBlur: () => {
89
+ if (slug === '') {
90
+ onChangeControl(originalSlugRef.current);
91
+ }
92
+ },
93
+ "aria-describedby": postUrlSlugDescriptionId,
94
+ help: /*#__PURE__*/_jsx(_Fragment, {
95
+ children: /*#__PURE__*/_jsxs("p", {
96
+ className: "fields-controls__slug-help",
97
+ children: [/*#__PURE__*/_jsx("span", {
98
+ className: "fields-controls__slug-help-visual-label",
99
+ children: __('Permalink:')
100
+ }), /*#__PURE__*/_jsxs(ExternalLink, {
101
+ className: "fields-controls__slug-help-link",
102
+ href: permalink,
103
+ children: [/*#__PURE__*/_jsx("span", {
104
+ className: "fields-controls__slug-help-prefix",
105
+ children: permalinkPrefix
106
+ }), /*#__PURE__*/_jsx("span", {
107
+ className: "fields-controls__slug-help-slug",
108
+ children: slugToDisplay
109
+ }), /*#__PURE__*/_jsx("span", {
110
+ className: "fields-controls__slug-help-suffix",
111
+ children: permalinkSuffix
112
+ })]
113
+ })]
114
+ })
115
+ })
116
+ })]
117
+ }), !isEditable && /*#__PURE__*/_jsx(ExternalLink, {
118
+ className: "fields-controls__slug-help",
119
+ href: permalink,
120
+ children: permalink
121
+ })]
122
+ });
123
+ };
124
+ export default SlugEdit;
125
+ //# sourceMappingURL=slug-edit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Button","ExternalLink","__experimentalInputControl","InputControl","__experimentalInputControlPrefixWrapper","InputControlPrefixWrapper","__experimentalVStack","VStack","copySmall","useCopyToClipboard","useInstanceId","useDispatch","useCallback","useEffect","useRef","store","noticesStore","safeDecodeURIComponent","__","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","SlugEdit","field","onChange","data","_field$getValue","id","slug","getValue","item","permalinkTemplate","permalink_template","PERMALINK_POSTNAME_REGEX","prefix","suffix","split","permalinkPrefix","permalinkSuffix","isEditable","test","originalSlugRef","slugToDisplay","current","permalink","link","undefined","onChangeControl","newValue","createNotice","copyButtonRef","isDismissible","type","postUrlSlugDescriptionId","className","children","spacing","href","__next40pxDefaultSize","icon","ref","label","hideLabelFromVision","value","autoComplete","spellCheck","onBlur","help"],"sources":["@wordpress/fields/src/fields/slug/slug-edit.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tExternalLink,\n\t__experimentalInputControl as InputControl,\n\t__experimentalInputControlPrefixWrapper as InputControlPrefixWrapper,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { copySmall } from '@wordpress/icons';\nimport { useCopyToClipboard, useInstanceId } from '@wordpress/compose';\nimport { useDispatch } from '@wordpress/data';\nimport { useCallback, useEffect, useRef } from '@wordpress/element';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { safeDecodeURIComponent } from '@wordpress/url';\nimport type { DataFormControlProps } from '@wordpress/dataviews';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\n\nconst SlugEdit = ( {\n\tfield,\n\tonChange,\n\tdata,\n}: DataFormControlProps< BasePost > ) => {\n\tconst { id } = field;\n\n\tconst slug = field.getValue( { item: data } ) ?? '';\n\tconst permalinkTemplate = data.permalink_template || '';\n\tconst PERMALINK_POSTNAME_REGEX = /%(?:postname|pagename)%/;\n\tconst [ prefix, suffix ] = permalinkTemplate.split(\n\t\tPERMALINK_POSTNAME_REGEX\n\t);\n\tconst permalinkPrefix = prefix;\n\tconst permalinkSuffix = suffix;\n\tconst isEditable = PERMALINK_POSTNAME_REGEX.test( permalinkTemplate );\n\tconst originalSlugRef = useRef( slug );\n\tconst slugToDisplay = slug || originalSlugRef.current;\n\tconst permalink = isEditable\n\t\t? `${ permalinkPrefix }${ slugToDisplay }${ permalinkSuffix }`\n\t\t: safeDecodeURIComponent( data.link || '' );\n\n\tuseEffect( () => {\n\t\tif ( slug && originalSlugRef.current === undefined ) {\n\t\t\toriginalSlugRef.current = slug;\n\t\t}\n\t}, [ slug ] );\n\n\tconst onChangeControl = useCallback(\n\t\t( newValue?: string ) =>\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 { createNotice } = useDispatch( noticesStore );\n\n\tconst copyButtonRef = useCopyToClipboard( permalink, () => {\n\t\tcreateNotice( 'info', __( 'Copied Permalink to clipboard.' ), {\n\t\t\tisDismissible: true,\n\t\t\ttype: 'snackbar',\n\t\t} );\n\t} );\n\n\tconst postUrlSlugDescriptionId =\n\t\t'editor-post-url__slug-description-' + useInstanceId( SlugEdit );\n\n\treturn (\n\t\t<fieldset className=\"fields-controls__slug\">\n\t\t\t{ isEditable && (\n\t\t\t\t<VStack>\n\t\t\t\t\t<VStack spacing=\"0px\">\n\t\t\t\t\t\t<span>\n\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t'Customize the last part of the Permalink.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t<ExternalLink href=\"https://wordpress.org/documentation/article/page-post-settings-sidebar/#permalink\">\n\t\t\t\t\t\t\t{ __( 'Learn more' ) }\n\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t</VStack>\n\t\t\t\t\t<InputControl\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tprefix={\n\t\t\t\t\t\t\t<InputControlPrefixWrapper>\n\t\t\t\t\t\t\t\t/\n\t\t\t\t\t\t\t</InputControlPrefixWrapper>\n\t\t\t\t\t\t}\n\t\t\t\t\t\tsuffix={\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\ticon={ copySmall }\n\t\t\t\t\t\t\t\tref={ copyButtonRef }\n\t\t\t\t\t\t\t\tlabel={ __( 'Copy' ) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t}\n\t\t\t\t\t\tlabel={ __( 'Link' ) }\n\t\t\t\t\t\thideLabelFromVision\n\t\t\t\t\t\tvalue={ slug }\n\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t\tspellCheck=\"false\"\n\t\t\t\t\t\ttype=\"text\"\n\t\t\t\t\t\tclassName=\"fields-controls__slug-input\"\n\t\t\t\t\t\tonChange={ ( newValue?: string ) => {\n\t\t\t\t\t\t\tonChangeControl( newValue );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonBlur={ () => {\n\t\t\t\t\t\t\tif ( slug === '' ) {\n\t\t\t\t\t\t\t\tonChangeControl( originalSlugRef.current );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} }\n\t\t\t\t\t\taria-describedby={ postUrlSlugDescriptionId }\n\t\t\t\t\t\thelp={\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<p className=\"fields-controls__slug-help\">\n\t\t\t\t\t\t\t\t\t<span className=\"fields-controls__slug-help-visual-label\">\n\t\t\t\t\t\t\t\t\t\t{ __( 'Permalink:' ) }\n\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\t\tclassName=\"fields-controls__slug-help-link\"\n\t\t\t\t\t\t\t\t\t\thref={ permalink }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<span className=\"fields-controls__slug-help-prefix\">\n\t\t\t\t\t\t\t\t\t\t\t{ permalinkPrefix }\n\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t\t<span className=\"fields-controls__slug-help-slug\">\n\t\t\t\t\t\t\t\t\t\t\t{ slugToDisplay }\n\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t\t<span className=\"fields-controls__slug-help-suffix\">\n\t\t\t\t\t\t\t\t\t\t\t{ permalinkSuffix }\n\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t\t\t\t</p>\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</VStack>\n\t\t\t) }\n\t\t\t{ ! isEditable && (\n\t\t\t\t<ExternalLink\n\t\t\t\t\tclassName=\"fields-controls__slug-help\"\n\t\t\t\t\thref={ permalink }\n\t\t\t\t>\n\t\t\t\t\t{ permalink }\n\t\t\t\t</ExternalLink>\n\t\t\t) }\n\t\t</fieldset>\n\t);\n};\n\nexport default SlugEdit;\n"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,MAAM,EACNC,YAAY,EACZC,0BAA0B,IAAIC,YAAY,EAC1CC,uCAAuC,IAAIC,yBAAyB,EACpEC,oBAAoB,IAAIC,MAAM,QACxB,uBAAuB;AAC9B,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,kBAAkB,EAAEC,aAAa,QAAQ,oBAAoB;AACtE,SAASC,WAAW,QAAQ,iBAAiB;AAC7C,SAASC,WAAW,EAAEC,SAAS,EAAEC,MAAM,QAAQ,oBAAoB;AACnE,SAASC,KAAK,IAAIC,YAAY,QAAQ,oBAAoB;AAC1D,SAASC,sBAAsB,QAAQ,gBAAgB;AAEvD,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AAFA,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA,EAAAC,QAAA,IAAAC,SAAA;AAKA,MAAMC,QAAQ,GAAGA,CAAE;EAClBC,KAAK;EACLC,QAAQ;EACRC;AACiC,CAAC,KAAM;EAAA,IAAAC,eAAA;EACxC,MAAM;IAAEC;EAAG,CAAC,GAAGJ,KAAK;EAEpB,MAAMK,IAAI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UAC3C;QACD,CAAG;QACH,oBAAmBU,wBAA0B;QAC7Cc,IAAI,eACHlD,IAAA,CAAAI,SAAA;UAAAkC,QAAA,eACCpC,KAAA;YAAGmC,SAAS,EAAC,4BAA4B;YAAAC,QAAA,gBACxCtC,IAAA;cAAMqC,SAAS,EAAC,yCAAyC;cAAAC,QAAA,EACtDxC,EAAE,CAAE,YAAa;YAAC,CACf,CAAC,eACPI,KAAA,CAACrB,YAAY;cACZwD,SAAS,EAAC,iCAAiC;cAC3CG,IAAI,EAAGb,SAAW;cAAAW,QAAA,gBAElBtC,IAAA;gBAAMqC,SAAS,EAAC,mCAAmC;gBAAAC,QAAA,EAChDlB;cAAe,CACZ,CAAC,eACPpB,IAAA;gBAAMqC,SAAS,EAAC,iCAAiC;gBAAAC,QAAA,EAC9Cb;cAAa,CACV,CAAC,eACPzB,IAAA;gBAAMqC,SAAS,EAAC,mCAAmC;gBAAAC,QAAA,EAChDjB;cAAe,CACZ,CAAC;YAAA,CACM,CAAC;UAAA,CACb;QAAC,CACH;MACF,CACD,CAAC;IAAA,CACK,CACR,EACC,CAAEC,UAAU,iBACbtB,IAAA,CAACnB,YAAY;MACZwD,SAAS,EAAC,4BAA4B;MACtCG,IAAI,EAAGb,SAAW;MAAAW,QAAA,EAEhBX;IAAS,CACE,CACd;EAAA,CACQ,CAAC;AAEb,CAAC;AAED,eAAetB,QAAQ","ignoreList":[]}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useEffect, useRef } from '@wordpress/element';
5
+
6
+ /**
7
+ * Internal dependencies
8
+ */
9
+
10
+ const SlugView = ({
11
+ item
12
+ }) => {
13
+ const slug = item.slug;
14
+ const originalSlugRef = useRef(slug);
15
+ useEffect(() => {
16
+ if (slug && originalSlugRef.current === undefined) {
17
+ originalSlugRef.current = slug;
18
+ }
19
+ }, [slug]);
20
+ const slugToDisplay = slug || originalSlugRef.current;
21
+ return `/${slugToDisplay !== null && slugToDisplay !== void 0 ? slugToDisplay : ''}`;
22
+ };
23
+ export default SlugView;
24
+ //# sourceMappingURL=slug-view.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useEffect","useRef","SlugView","item","slug","originalSlugRef","current","undefined","slugToDisplay"],"sources":["@wordpress/fields/src/fields/slug/slug-view.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\n\nconst SlugView = ( { item }: { item: BasePost } ) => {\n\tconst slug = item.slug;\n\tconst originalSlugRef = useRef( slug );\n\n\tuseEffect( () => {\n\t\tif ( slug && originalSlugRef.current === undefined ) {\n\t\t\toriginalSlugRef.current = slug;\n\t\t}\n\t}, [ slug ] );\n\n\tconst slugToDisplay = slug || originalSlugRef.current;\n\n\treturn `/${ slugToDisplay ?? '' }`;\n};\n\nexport default SlugView;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,MAAM,QAAQ,oBAAoB;;AAEtD;AACA;AACA;;AAGA,MAAMC,QAAQ,GAAGA,CAAE;EAAEC;AAAyB,CAAC,KAAM;EACpD,MAAMC,IAAI,GAAGD,IAAI,CAACC,IAAI;EACtB,MAAMC,eAAe,GAAGJ,MAAM,CAAEG,IAAK,CAAC;EAEtCJ,SAAS,CAAE,MAAM;IAChB,IAAKI,IAAI,IAAIC,eAAe,CAACC,OAAO,KAAKC,SAAS,EAAG;MACpDF,eAAe,CAACC,OAAO,GAAGF,IAAI;IAC/B;EACD,CAAC,EAAE,CAAEA,IAAI,CAAG,CAAC;EAEb,MAAMI,aAAa,GAAGJ,IAAI,IAAIC,eAAe,CAACC,OAAO;EAErD,OAAO,IAAKE,aAAa,aAAbA,aAAa,cAAbA,aAAa,GAAI,EAAE,EAAG;AACnC,CAAC;AAED,eAAeN,QAAQ","ignoreList":[]}
@@ -1,3 +1,4 @@
1
+ /* wp:polyfill */
1
2
  /**
2
3
  * WordPress dependencies
3
4
  */
@@ -9,7 +10,7 @@ import { dispatch } from '@wordpress/data';
9
10
  * Internal dependencies
10
11
  */
11
12
 
12
- const getErrorMessagesFromPromises = allSettledResults => {
13
+ function getErrorMessagesFromPromises(allSettledResults) {
13
14
  const errorMessages = new Set();
14
15
  // If there was at lease one failure.
15
16
  if (allSettledResults.length === 1) {
@@ -29,7 +30,7 @@ const getErrorMessagesFromPromises = allSettledResults => {
29
30
  }
30
31
  }
31
32
  return errorMessages;
32
- };
33
+ }
33
34
  export const deletePostWithNotices = async (posts, notice, callbacks) => {
34
35
  const {
35
36
  createSuccessNotice,
@@ -1 +1 @@
1
- {"version":3,"names":["store","noticesStore","coreStore","dispatch","getErrorMessagesFromPromises","allSettledResults","errorMessages","Set","length","typedError","reason","message","add","failedPromises","filter","status","failedPromise","deletePostWithNotices","posts","notice","callbacks","createSuccessNotice","createErrorNotice","deleteEntityRecord","Promise","allSettled","map","post","type","id","force","throwOnError","every","_notice$success$type","successMessage","success","messages","getMessage","getBatchMessage","onActionPerformed","_notice$error$type","errorMessage","error","onActionError","editPostWithNotices","postsWithUpdates","editEntityRecord","saveEditedEntityRecord","originalPost","changes","_notice$success$type2","_notice$error$type2"],"sources":["@wordpress/fields/src/mutation/index.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { dispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport type { CoreDataError, Post } from '../types';\n\nconst getErrorMessagesFromPromises = < T >(\n\tallSettledResults: PromiseSettledResult< T >[]\n) => {\n\tconst errorMessages = new Set< string >();\n\t// If there was at lease one failure.\n\tif ( allSettledResults.length === 1 ) {\n\t\tconst typedError = allSettledResults[ 0 ] as {\n\t\t\treason?: CoreDataError;\n\t\t};\n\t\tif ( typedError.reason?.message ) {\n\t\t\terrorMessages.add( typedError.reason.message );\n\t\t}\n\t} else {\n\t\tconst failedPromises = allSettledResults.filter(\n\t\t\t( { status } ) => status === 'rejected'\n\t\t);\n\t\tfor ( const failedPromise of failedPromises ) {\n\t\t\tconst typedError = failedPromise as {\n\t\t\t\treason?: CoreDataError;\n\t\t\t};\n\t\t\tif ( typedError.reason?.message ) {\n\t\t\t\terrorMessages.add( typedError.reason.message );\n\t\t\t}\n\t\t}\n\t}\n\treturn errorMessages;\n};\n\nexport type NoticeSettings< T extends Post > = {\n\tsuccess: {\n\t\tid?: string;\n\t\ttype?: string;\n\t\tmessages: {\n\t\t\tgetMessage: ( posts: T ) => string;\n\t\t\tgetBatchMessage: ( posts: T[] ) => string;\n\t\t};\n\t};\n\terror: {\n\t\tid?: string;\n\t\ttype?: string;\n\t\tmessages: {\n\t\t\tgetMessage: ( errors: Set< string > ) => string;\n\t\t\tgetBatchMessage: ( errors: Set< string > ) => string;\n\t\t};\n\t};\n};\n\nexport const deletePostWithNotices = async < T extends Post >(\n\tposts: T[],\n\tnotice: NoticeSettings< T >,\n\tcallbacks: {\n\t\tonActionPerformed?: ( posts: T[] ) => void;\n\t\tonActionError?: () => void;\n\t}\n) => {\n\tconst { createSuccessNotice, createErrorNotice } = dispatch( noticesStore );\n\tconst { deleteEntityRecord } = dispatch( coreStore );\n\tconst allSettledResults = await Promise.allSettled(\n\t\tposts.map( ( post ) => {\n\t\t\treturn deleteEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tpost.type,\n\t\t\t\tpost.id,\n\t\t\t\t{ force: true },\n\t\t\t\t{ throwOnError: true }\n\t\t\t);\n\t\t} )\n\t);\n\t// If all the promises were fulfilled with success.\n\tif ( allSettledResults.every( ( { status } ) => status === 'fulfilled' ) ) {\n\t\tlet successMessage;\n\t\tif ( allSettledResults.length === 1 ) {\n\t\t\tsuccessMessage = notice.success.messages.getMessage( posts[ 0 ] );\n\t\t} else {\n\t\t\tsuccessMessage = notice.success.messages.getBatchMessage( posts );\n\t\t}\n\t\tcreateSuccessNotice( successMessage, {\n\t\t\ttype: notice.success.type ?? 'snackbar',\n\t\t\tid: notice.success.id,\n\t\t} );\n\t\tcallbacks.onActionPerformed?.( posts );\n\t} else {\n\t\tconst errorMessages = getErrorMessagesFromPromises( allSettledResults );\n\t\tlet errorMessage = '';\n\t\tif ( allSettledResults.length === 1 ) {\n\t\t\terrorMessage = notice.error.messages.getMessage( errorMessages );\n\t\t} else {\n\t\t\terrorMessage =\n\t\t\t\tnotice.error.messages.getBatchMessage( errorMessages );\n\t\t}\n\n\t\tcreateErrorNotice( errorMessage, {\n\t\t\ttype: notice.error.type ?? 'snackbar',\n\t\t\tid: notice.error.id,\n\t\t} );\n\t\tcallbacks.onActionError?.();\n\t}\n};\n\nexport const editPostWithNotices = async < T extends Post >(\n\tpostsWithUpdates: {\n\t\toriginalPost: T;\n\t\tchanges: Partial< T >;\n\t}[],\n\tnotice: NoticeSettings< T >,\n\tcallbacks: {\n\t\tonActionPerformed?: ( posts: T[] ) => void;\n\t\tonActionError?: () => void;\n\t}\n) => {\n\tconst { createSuccessNotice, createErrorNotice } = dispatch( noticesStore );\n\tconst { editEntityRecord, saveEditedEntityRecord } = dispatch( coreStore );\n\tawait Promise.allSettled(\n\t\tpostsWithUpdates.map( ( post ) => {\n\t\t\treturn editEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tpost.originalPost.type,\n\t\t\t\tpost.originalPost.id,\n\t\t\t\t{\n\t\t\t\t\t...post.changes,\n\t\t\t\t}\n\t\t\t);\n\t\t} )\n\t);\n\tconst allSettledResults = await Promise.allSettled(\n\t\tpostsWithUpdates.map( ( post ) => {\n\t\t\treturn saveEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tpost.originalPost.type,\n\t\t\t\tpost.originalPost.id,\n\t\t\t\t{\n\t\t\t\t\tthrowOnError: true,\n\t\t\t\t}\n\t\t\t);\n\t\t} )\n\t);\n\t// If all the promises were fulfilled with success.\n\tif ( allSettledResults.every( ( { status } ) => status === 'fulfilled' ) ) {\n\t\tlet successMessage;\n\t\tif ( allSettledResults.length === 1 ) {\n\t\t\tsuccessMessage = notice.success.messages.getMessage(\n\t\t\t\tpostsWithUpdates[ 0 ].originalPost\n\t\t\t);\n\t\t} else {\n\t\t\tsuccessMessage = notice.success.messages.getBatchMessage(\n\t\t\t\tpostsWithUpdates.map( ( post ) => post.originalPost )\n\t\t\t);\n\t\t}\n\t\tcreateSuccessNotice( successMessage, {\n\t\t\ttype: notice.success.type ?? 'snackbar',\n\t\t\tid: notice.success.id,\n\t\t} );\n\t\tcallbacks.onActionPerformed?.(\n\t\t\tpostsWithUpdates.map( ( post ) => post.originalPost )\n\t\t);\n\t} else {\n\t\tconst errorMessages = getErrorMessagesFromPromises( allSettledResults );\n\t\tlet errorMessage = '';\n\t\tif ( allSettledResults.length === 1 ) {\n\t\t\terrorMessage = notice.error.messages.getMessage( errorMessages );\n\t\t} else {\n\t\t\terrorMessage =\n\t\t\t\tnotice.error.messages.getBatchMessage( errorMessages );\n\t\t}\n\n\t\tcreateErrorNotice( errorMessage, {\n\t\t\ttype: notice.error.type ?? 'snackbar',\n\t\t\tid: notice.error.id,\n\t\t} );\n\t\tcallbacks.onActionError?.();\n\t}\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,YAAY,QAAQ,oBAAoB;AAC1D,SAASD,KAAK,IAAIE,SAAS,QAAQ,sBAAsB;AACzD,SAASC,QAAQ,QAAQ,iBAAiB;;AAE1C;AACA;AACA;;AAGA,MAAMC,4BAA4B,GACjCC,iBAA8C,IAC1C;EACJ,MAAMC,aAAa,GAAG,IAAIC,GAAG,CAAW,CAAC;EACzC;EACA,IAAKF,iBAAiB,CAACG,MAAM,KAAK,CAAC,EAAG;IACrC,MAAMC,UAAU,GAAGJ,iBAAiB,CAAE,CAAC,CAEtC;IACD,IAAKI,UAAU,CAACC,MAAM,EAAEC,OAAO,EAAG;MACjCL,aAAa,CAACM,GAAG,CAAEH,UAAU,CAACC,MAAM,CAACC,OAAQ,CAAC;IAC/C;EACD,CAAC,MAAM;IACN,MAAME,cAAc,GA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iBAAiB,GAC1BM,gBAAgB,CAACnB,GAAG,CAAIC,IAAI,IAAMA,IAAI,CAACqB,YAAa,CACrD,CAAC;EACF,CAAC,MAAM;IAAA,IAAAG,mBAAA;IACN,MAAM7C,aAAa,GAAGF,4BAA4B,CAAEC,iBAAkB,CAAC;IACvE,IAAIoC,YAAY,GAAG,EAAE;IACrB,IAAKpC,iBAAiB,CAACG,MAAM,KAAK,CAAC,EAAG;MACrCiC,YAAY,GAAGtB,MAAM,CAACuB,KAAK,CAACN,QAAQ,CAACC,UAAU,CAAE/B,aAAc,CAAC;IACjE,CAAC,MAAM;MACNmC,YAAY,GACXtB,MAAM,CAACuB,KAAK,CAACN,QAAQ,CAACE,eAAe,CAAEhC,aAAc,CAAC;IACxD;IAEAgB,iBAAiB,CAAEmB,YAAY,EAAE;MAChCb,IAAI,GAAAuB,mBAAA,GAAEhC,MAAM,CAACuB,KAAK,CAACd,IAAI,cAAAuB,mBAAA,cAAAA,mBAAA,GAAI,UAAU;MACrCtB,EAAE,EAAEV,MAAM,CAACuB,KAAK,CAACb;IAClB,CAAE,CAAC;IACHT,SAAS,CAACuB,aAAa,GAAG,CAAC;EAC5B;AACD,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["store","noticesStore","coreStore","dispatch","getErrorMessagesFromPromises","allSettledResults","errorMessages","Set","length","typedError","reason","message","add","failedPromises","filter","status","failedPromise","deletePostWithNotices","posts","notice","callbacks","createSuccessNotice","createErrorNotice","deleteEntityRecord","Promise","allSettled","map","post","type","id","force","throwOnError","every","_notice$success$type","successMessage","success","messages","getMessage","getBatchMessage","onActionPerformed","_notice$error$type","errorMessage","error","onActionError","editPostWithNotices","postsWithUpdates","editEntityRecord","saveEditedEntityRecord","originalPost","changes","_notice$success$type2","_notice$error$type2"],"sources":["@wordpress/fields/src/mutation/index.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { dispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport type { CoreDataError, Post } from '../types';\n\nfunction getErrorMessagesFromPromises< T >(\n\tallSettledResults: PromiseSettledResult< T >[]\n) {\n\tconst errorMessages = new Set< string >();\n\t// If there was at lease one failure.\n\tif ( allSettledResults.length === 1 ) {\n\t\tconst typedError = allSettledResults[ 0 ] as {\n\t\t\treason?: CoreDataError;\n\t\t};\n\t\tif ( typedError.reason?.message ) {\n\t\t\terrorMessages.add( typedError.reason.message );\n\t\t}\n\t} else {\n\t\tconst failedPromises = allSettledResults.filter(\n\t\t\t( { status } ) => status === 'rejected'\n\t\t);\n\t\tfor ( const failedPromise of failedPromises ) {\n\t\t\tconst typedError = failedPromise as {\n\t\t\t\treason?: CoreDataError;\n\t\t\t};\n\t\t\tif ( typedError.reason?.message ) {\n\t\t\t\terrorMessages.add( typedError.reason.message );\n\t\t\t}\n\t\t}\n\t}\n\treturn errorMessages;\n}\n\nexport type NoticeSettings< T extends Post > = {\n\tsuccess: {\n\t\tid?: string;\n\t\ttype?: string;\n\t\tmessages: {\n\t\t\tgetMessage: ( posts: T ) => string;\n\t\t\tgetBatchMessage: ( posts: T[] ) => string;\n\t\t};\n\t};\n\terror: {\n\t\tid?: string;\n\t\ttype?: string;\n\t\tmessages: {\n\t\t\tgetMessage: ( errors: Set< string > ) => string;\n\t\t\tgetBatchMessage: ( errors: Set< string > ) => string;\n\t\t};\n\t};\n};\n\nexport const deletePostWithNotices = async < T extends Post >(\n\tposts: T[],\n\tnotice: NoticeSettings< T >,\n\tcallbacks: {\n\t\tonActionPerformed?: ( posts: T[] ) => void;\n\t\tonActionError?: () => void;\n\t}\n) => {\n\tconst { createSuccessNotice, createErrorNotice } = dispatch( noticesStore );\n\tconst { deleteEntityRecord } = dispatch( coreStore );\n\tconst allSettledResults = await Promise.allSettled(\n\t\tposts.map( ( post ) => {\n\t\t\treturn deleteEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tpost.type,\n\t\t\t\tpost.id,\n\t\t\t\t{ force: true },\n\t\t\t\t{ throwOnError: true }\n\t\t\t);\n\t\t} )\n\t);\n\t// If all the promises were fulfilled with success.\n\tif ( allSettledResults.every( ( { status } ) => status === 'fulfilled' ) ) {\n\t\tlet successMessage;\n\t\tif ( allSettledResults.length === 1 ) {\n\t\t\tsuccessMessage = notice.success.messages.getMessage( posts[ 0 ] );\n\t\t} else {\n\t\t\tsuccessMessage = notice.success.messages.getBatchMessage( posts );\n\t\t}\n\t\tcreateSuccessNotice( successMessage, {\n\t\t\ttype: notice.success.type ?? 'snackbar',\n\t\t\tid: notice.success.id,\n\t\t} );\n\t\tcallbacks.onActionPerformed?.( posts );\n\t} else {\n\t\tconst errorMessages = getErrorMessagesFromPromises( allSettledResults );\n\t\tlet errorMessage = '';\n\t\tif ( allSettledResults.length === 1 ) {\n\t\t\terrorMessage = notice.error.messages.getMessage( errorMessages );\n\t\t} else {\n\t\t\terrorMessage =\n\t\t\t\tnotice.error.messages.getBatchMessage( errorMessages );\n\t\t}\n\n\t\tcreateErrorNotice( errorMessage, {\n\t\t\ttype: notice.error.type ?? 'snackbar',\n\t\t\tid: notice.error.id,\n\t\t} );\n\t\tcallbacks.onActionError?.();\n\t}\n};\n\nexport const editPostWithNotices = async < T extends Post >(\n\tpostsWithUpdates: {\n\t\toriginalPost: T;\n\t\tchanges: Partial< T >;\n\t}[],\n\tnotice: NoticeSettings< T >,\n\tcallbacks: {\n\t\tonActionPerformed?: ( posts: T[] ) => void;\n\t\tonActionError?: () => void;\n\t}\n) => {\n\tconst { createSuccessNotice, createErrorNotice } = dispatch( noticesStore );\n\tconst { editEntityRecord, saveEditedEntityRecord } = dispatch( coreStore );\n\tawait Promise.allSettled(\n\t\tpostsWithUpdates.map( ( post ) => {\n\t\t\treturn editEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tpost.originalPost.type,\n\t\t\t\tpost.originalPost.id,\n\t\t\t\t{\n\t\t\t\t\t...post.changes,\n\t\t\t\t}\n\t\t\t);\n\t\t} )\n\t);\n\tconst allSettledResults = await Promise.allSettled(\n\t\tpostsWithUpdates.map( ( post ) => {\n\t\t\treturn saveEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tpost.originalPost.type,\n\t\t\t\tpost.originalPost.id,\n\t\t\t\t{\n\t\t\t\t\tthrowOnError: true,\n\t\t\t\t}\n\t\t\t);\n\t\t} )\n\t);\n\t// If all the promises were fulfilled with success.\n\tif ( allSettledResults.every( ( { status } ) => status === 'fulfilled' ) ) {\n\t\tlet successMessage;\n\t\tif ( allSettledResults.length === 1 ) {\n\t\t\tsuccessMessage = notice.success.messages.getMessage(\n\t\t\t\tpostsWithUpdates[ 0 ].originalPost\n\t\t\t);\n\t\t} else {\n\t\t\tsuccessMessage = notice.success.messages.getBatchMessage(\n\t\t\t\tpostsWithUpdates.map( ( post ) => post.originalPost )\n\t\t\t);\n\t\t}\n\t\tcreateSuccessNotice( successMessage, {\n\t\t\ttype: notice.success.type ?? 'snackbar',\n\t\t\tid: notice.success.id,\n\t\t} );\n\t\tcallbacks.onActionPerformed?.(\n\t\t\tpostsWithUpdates.map( ( post ) => post.originalPost )\n\t\t);\n\t} else {\n\t\tconst errorMessages = getErrorMessagesFromPromises( allSettledResults );\n\t\tlet errorMessage = '';\n\t\tif ( allSettledResults.length === 1 ) {\n\t\t\terrorMessage = notice.error.messages.getMessage( errorMessages );\n\t\t} else {\n\t\t\terrorMessage =\n\t\t\t\tnotice.error.messages.getBatchMessage( errorMessages );\n\t\t}\n\n\t\tcreateErrorNotice( errorMessage, {\n\t\t\ttype: notice.error.type ?? 'snackbar',\n\t\t\tid: notice.error.id,\n\t\t} );\n\t\tcallbacks.onActionError?.();\n\t}\n};\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,YAAY,QAAQ,oBAAoB;AAC1D,SAASD,KAAK,IAAIE,SAAS,QAAQ,sBAAsB;AACzD,SAASC,QAAQ,QAAQ,iBAAiB;;AAE1C;AACA;AACA;;AAGA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AM,CAACgB,OAAO,CAACC,QAAQ,CAACE,eAAe,CACvDO,gBAAgB,CAACnB,GAAG,CAAIC,IAAI,IAAMA,IAAI,CAACqB,YAAa,CACrD,CAAC;IACF;IACA3B,mBAAmB,CAAEa,cAAc,EAAE;MACpCN,IAAI,GAAAsB,qBAAA,GAAE/B,MAAM,CAACgB,OAAO,CAACP,IAAI,cAAAsB,qBAAA,cAAAA,qBAAA,GAAI,UAAU;MACvCrB,EAAE,EAAEV,MAAM,CAACgB,OAAO,CAACN;IACpB,CAAE,CAAC;IACHT,SAAS,CAACmB,iBAAiB,GAC1BM,gBAAgB,CAACnB,GAAG,CAAIC,IAAI,IAAMA,IAAI,CAACqB,YAAa,CACrD,CAAC;EACF,CAAC,MAAM;IAAA,IAAAG,mBAAA;IACN,MAAM7C,aAAa,GAAGF,4BAA4B,CAAEC,iBAAkB,CAAC;IACvE,IAAIoC,YAAY,GAAG,EAAE;IACrB,IAAKpC,iBAAiB,CAACG,MAAM,KAAK,CAAC,EAAG;MACrCiC,YAAY,GAAGtB,MAAM,CAACuB,KAAK,CAACN,QAAQ,CAACC,UAAU,CAAE/B,aAAc,CAAC;IACjE,CAAC,MAAM;MACNmC,YAAY,GACXtB,MAAM,CAACuB,KAAK,CAACN,QAAQ,CAACE,eAAe,CAAEhC,aAAc,CAAC;IACxD;IAEAgB,iBAAiB,CAAEmB,YAAY,EAAE;MAChCb,IAAI,GAAAuB,mBAAA,GAAEhC,MAAM,CAACuB,KAAK,CAACd,IAAI,cAAAuB,mBAAA,cAAAA,mBAAA,GAAI,UAAU;MACrCtB,EAAE,EAAEV,MAAM,CAACuB,KAAK,CAACb;IAClB,CAAE,CAAC;IACHT,SAAS,CAACuB,aAAa,GAAG,CAAC;EAC5B;AACD,CAAC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["@wordpress/fields/src/types.ts"],"sourcesContent":["type PostStatus =\n\t| 'published'\n\t| 'draft'\n\t| 'pending'\n\t| 'private'\n\t| 'future'\n\t| 'auto-draft'\n\t| 'trash';\n\nexport interface CommonPost {\n\tstatus?: PostStatus;\n\ttitle: string | { rendered: string } | { raw: string };\n\tcontent: string | { raw: string; rendered: string };\n\ttype: string;\n\tid: string | number;\n\tblocks?: Object[];\n\t_links?: Links;\n}\n\ninterface Links {\n\t'predecessor-version'?: { href: string; id: number }[];\n\t'version-history'?: { href: string; count: number }[];\n\t[ key: string ]: { href: string }[] | undefined;\n}\n\nexport interface BasePost extends CommonPost {\n\tcomment_status?: 'open' | 'closed';\n\texcerpt?: string | { raw: string; rendered: string };\n\tmeta?: Record< string, any >;\n\tparent?: number;\n\tpassword?: string;\n\ttemplate?: string;\n\tformat?: string;\n\tfeatured_media?: number;\n\tmenu_order?: number;\n\tping_status?: 'open' | 'closed';\n\tlink?: string;\n}\n\nexport interface Template extends CommonPost {\n\ttype: 'wp_template';\n\tis_custom: boolean;\n\tsource: string;\n\torigin: string;\n\tplugin?: string;\n\thas_theme_file: boolean;\n\tid: string;\n}\n\nexport interface TemplatePart extends CommonPost {\n\ttype: 'wp_template_part';\n\tsource: string;\n\torigin: string;\n\thas_theme_file: boolean;\n\tid: string;\n\tarea: string;\n\tplugin?: string;\n}\n\nexport interface Pattern extends CommonPost {\n\tslug: string;\n\ttitle: { raw: string };\n\twp_pattern_sync_status: string;\n}\n\nexport type Post = Template | TemplatePart | Pattern | BasePost;\n\nexport type PostWithPermissions = Post & {\n\tpermissions: {\n\t\tdelete: boolean;\n\t\tupdate: boolean;\n\t};\n};\n\nexport interface PostType {\n\tslug: string;\n\tviewable: boolean;\n\tsupports?: {\n\t\t'page-attributes'?: boolean;\n\t\ttitle?: boolean;\n\t\trevisions?: boolean;\n\t};\n}\n\n// Will be unnecessary after typescript 5.0 upgrade.\nexport type CoreDataError = { message?: string; code?: string };\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["@wordpress/fields/src/types.ts"],"sourcesContent":["type PostStatus =\n\t| 'published'\n\t| 'draft'\n\t| 'pending'\n\t| 'private'\n\t| 'future'\n\t| 'auto-draft'\n\t| 'trash';\n\nexport interface CommonPost {\n\tstatus?: PostStatus;\n\ttitle: string | { rendered: string } | { raw: string };\n\tcontent: string | { raw: string; rendered: string };\n\ttype: string;\n\tid: string | number;\n\tblocks?: Object[];\n\t_links?: Links;\n}\n\ninterface Links {\n\t'predecessor-version'?: { href: string; id: number }[];\n\t'version-history'?: { href: string; count: number }[];\n\t[ key: string ]: { href: string }[] | undefined;\n}\n\nexport interface BasePost extends CommonPost {\n\tcomment_status?: 'open' | 'closed';\n\texcerpt?: string | { raw: string; rendered: string };\n\tmeta?: Record< string, any >;\n\tparent?: number;\n\tpassword?: string;\n\ttemplate?: string;\n\tformat?: string;\n\tfeatured_media?: number;\n\tmenu_order?: number;\n\tping_status?: 'open' | 'closed';\n\tlink?: string;\n\tslug?: string;\n\tpermalink_template?: string;\n}\n\nexport interface Template extends CommonPost {\n\ttype: 'wp_template';\n\tis_custom: boolean;\n\tsource: string;\n\torigin: string;\n\tplugin?: string;\n\thas_theme_file: boolean;\n\tid: string;\n}\n\nexport interface TemplatePart extends CommonPost {\n\ttype: 'wp_template_part';\n\tsource: string;\n\torigin: string;\n\thas_theme_file: boolean;\n\tid: string;\n\tarea: string;\n\tplugin?: string;\n}\n\nexport interface Pattern extends CommonPost {\n\tslug: string;\n\ttitle: { raw: string };\n\twp_pattern_sync_status: string;\n}\n\nexport type Post = Template | TemplatePart | Pattern | BasePost;\n\nexport type PostWithPermissions = Post & {\n\tpermissions: {\n\t\tdelete: boolean;\n\t\tupdate: boolean;\n\t};\n};\n\nexport interface PostType {\n\tslug: string;\n\tviewable: boolean;\n\tsupports?: {\n\t\t'page-attributes'?: boolean;\n\t\ttitle?: boolean;\n\t\trevisions?: boolean;\n\t};\n}\n\n// Will be unnecessary after typescript 5.0 upgrade.\nexport type CoreDataError = { message?: string; code?: string };\n"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,134 @@
1
+ /**
2
+ * Converts a hex value into the rgb equivalent.
3
+ *
4
+ * @param {string} hex - the hexadecimal value to convert
5
+ * @return {string} comma separated rgb values
6
+ */
7
+ /**
8
+ * Colors
9
+ */
10
+ /**
11
+ * Breakpoints & Media Queries
12
+ */
13
+ /**
14
+ * SCSS Variables.
15
+ *
16
+ * Please use variables from this sheet to ensure consistency across the UI.
17
+ * Don't add to this sheet unless you're pretty sure the value will be reused in many places.
18
+ * For example, don't add rules to this sheet that affect block visuals. It's purely for UI.
19
+ */
20
+ /**
21
+ * Converts a hex value into the rgb equivalent.
22
+ *
23
+ * @param {string} hex - the hexadecimal value to convert
24
+ * @return {string} comma separated rgb values
25
+ */
26
+ /**
27
+ * Colors
28
+ */
29
+ /**
30
+ * Fonts & basic variables.
31
+ */
32
+ /**
33
+ * Typography
34
+ */
35
+ /**
36
+ * Grid System.
37
+ * https://make.wordpress.org/design/2019/10/31/proposal-a-consistent-spacing-system-for-wordpress/
38
+ */
39
+ /**
40
+ * Radius scale.
41
+ */
42
+ /**
43
+ * Elevation scale.
44
+ */
45
+ /**
46
+ * Dimensions.
47
+ */
48
+ /**
49
+ * Mobile specific styles
50
+ */
51
+ /**
52
+ * Editor styles.
53
+ */
54
+ /**
55
+ * Block & Editor UI.
56
+ */
57
+ /**
58
+ * Block paddings.
59
+ */
60
+ /**
61
+ * React Native specific.
62
+ * These variables do not appear to be used anywhere else.
63
+ */
64
+ /**
65
+ * Converts a hex value into the rgb equivalent.
66
+ *
67
+ * @param {string} hex - the hexadecimal value to convert
68
+ * @return {string} comma separated rgb values
69
+ */
70
+ /**
71
+ * Long content fade mixin
72
+ *
73
+ * Creates a fading overlay to signify that the content is longer
74
+ * than the space allows.
75
+ */
76
+ /**
77
+ * Typography
78
+ */
79
+ /**
80
+ * Breakpoint mixins
81
+ */
82
+ /**
83
+ * Focus styles.
84
+ */
85
+ /**
86
+ * Applies editor left position to the selector passed as argument
87
+ */
88
+ /**
89
+ * Styles that are reused verbatim in a few places
90
+ */
91
+ /**
92
+ * Allows users to opt-out of animations via OS-level preferences.
93
+ */
94
+ /**
95
+ * Reset default styles for JavaScript UI based pages.
96
+ * This is a WP-admin agnostic reset
97
+ */
98
+ /**
99
+ * Reset the WP Admin page styles for Gutenberg-like pages.
100
+ */
101
+ :root {
102
+ --wp-admin-theme-color: #007cba;
103
+ --wp-admin-theme-color--rgb: 0, 124, 186;
104
+ --wp-admin-theme-color-darker-10: #006ba1;
105
+ --wp-admin-theme-color-darker-10--rgb: 0, 107, 161;
106
+ --wp-admin-theme-color-darker-20: #005a87;
107
+ --wp-admin-theme-color-darker-20--rgb: 0, 90, 135;
108
+ --wp-admin-border-width-focus: 2px;
109
+ --wp-block-synced-color: #7a00df;
110
+ --wp-block-synced-color--rgb: 122, 0, 223;
111
+ --wp-bound-block-color: var(--wp-block-synced-color);
112
+ }
113
+ @media (min-resolution: 192dpi) {
114
+ :root {
115
+ --wp-admin-border-width-focus: 1.5px;
116
+ }
117
+ }
118
+
119
+ .fields-controls__slug .fields-controls__slug-external-icon {
120
+ margin-right: 5ch;
121
+ }
122
+ .fields-controls__slug .fields-controls__slug-input input.components-input-control__input {
123
+ padding-inline-start: 0 !important;
124
+ }
125
+ .fields-controls__slug .fields-controls__slug-help-link {
126
+ word-break: break-word;
127
+ }
128
+ .fields-controls__slug .fields-controls__slug-help {
129
+ display: flex;
130
+ flex-direction: column;
131
+ }
132
+ .fields-controls__slug .fields-controls__slug-help .fields-controls__slug-help-slug {
133
+ font-weight: 600;
134
+ }
@@ -0,0 +1,134 @@
1
+ /**
2
+ * Converts a hex value into the rgb equivalent.
3
+ *
4
+ * @param {string} hex - the hexadecimal value to convert
5
+ * @return {string} comma separated rgb values
6
+ */
7
+ /**
8
+ * Colors
9
+ */
10
+ /**
11
+ * Breakpoints & Media Queries
12
+ */
13
+ /**
14
+ * SCSS Variables.
15
+ *
16
+ * Please use variables from this sheet to ensure consistency across the UI.
17
+ * Don't add to this sheet unless you're pretty sure the value will be reused in many places.
18
+ * For example, don't add rules to this sheet that affect block visuals. It's purely for UI.
19
+ */
20
+ /**
21
+ * Converts a hex value into the rgb equivalent.
22
+ *
23
+ * @param {string} hex - the hexadecimal value to convert
24
+ * @return {string} comma separated rgb values
25
+ */
26
+ /**
27
+ * Colors
28
+ */
29
+ /**
30
+ * Fonts & basic variables.
31
+ */
32
+ /**
33
+ * Typography
34
+ */
35
+ /**
36
+ * Grid System.
37
+ * https://make.wordpress.org/design/2019/10/31/proposal-a-consistent-spacing-system-for-wordpress/
38
+ */
39
+ /**
40
+ * Radius scale.
41
+ */
42
+ /**
43
+ * Elevation scale.
44
+ */
45
+ /**
46
+ * Dimensions.
47
+ */
48
+ /**
49
+ * Mobile specific styles
50
+ */
51
+ /**
52
+ * Editor styles.
53
+ */
54
+ /**
55
+ * Block & Editor UI.
56
+ */
57
+ /**
58
+ * Block paddings.
59
+ */
60
+ /**
61
+ * React Native specific.
62
+ * These variables do not appear to be used anywhere else.
63
+ */
64
+ /**
65
+ * Converts a hex value into the rgb equivalent.
66
+ *
67
+ * @param {string} hex - the hexadecimal value to convert
68
+ * @return {string} comma separated rgb values
69
+ */
70
+ /**
71
+ * Long content fade mixin
72
+ *
73
+ * Creates a fading overlay to signify that the content is longer
74
+ * than the space allows.
75
+ */
76
+ /**
77
+ * Typography
78
+ */
79
+ /**
80
+ * Breakpoint mixins
81
+ */
82
+ /**
83
+ * Focus styles.
84
+ */
85
+ /**
86
+ * Applies editor left position to the selector passed as argument
87
+ */
88
+ /**
89
+ * Styles that are reused verbatim in a few places
90
+ */
91
+ /**
92
+ * Allows users to opt-out of animations via OS-level preferences.
93
+ */
94
+ /**
95
+ * Reset default styles for JavaScript UI based pages.
96
+ * This is a WP-admin agnostic reset
97
+ */
98
+ /**
99
+ * Reset the WP Admin page styles for Gutenberg-like pages.
100
+ */
101
+ :root {
102
+ --wp-admin-theme-color: #007cba;
103
+ --wp-admin-theme-color--rgb: 0, 124, 186;
104
+ --wp-admin-theme-color-darker-10: #006ba1;
105
+ --wp-admin-theme-color-darker-10--rgb: 0, 107, 161;
106
+ --wp-admin-theme-color-darker-20: #005a87;
107
+ --wp-admin-theme-color-darker-20--rgb: 0, 90, 135;
108
+ --wp-admin-border-width-focus: 2px;
109
+ --wp-block-synced-color: #7a00df;
110
+ --wp-block-synced-color--rgb: 122, 0, 223;
111
+ --wp-bound-block-color: var(--wp-block-synced-color);
112
+ }
113
+ @media (min-resolution: 192dpi) {
114
+ :root {
115
+ --wp-admin-border-width-focus: 1.5px;
116
+ }
117
+ }
118
+
119
+ .fields-controls__slug .fields-controls__slug-external-icon {
120
+ margin-left: 5ch;
121
+ }
122
+ .fields-controls__slug .fields-controls__slug-input input.components-input-control__input {
123
+ padding-inline-start: 0 !important;
124
+ }
125
+ .fields-controls__slug .fields-controls__slug-help-link {
126
+ word-break: break-word;
127
+ }
128
+ .fields-controls__slug .fields-controls__slug-help {
129
+ display: flex;
130
+ flex-direction: column;
131
+ }
132
+ .fields-controls__slug .fields-controls__slug-help .fields-controls__slug-help-slug {
133
+ font-weight: 600;
134
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"delete-post.d.ts","sourceRoot":"","sources":["../../src/actions/delete-post.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAWnD,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAUhE,QAAA,MAAM,gBAAgB,EAAE,MAAM,CAAE,QAAQ,GAAG,YAAY,GAAG,OAAO,CAqKhE,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"delete-post.d.ts","sourceRoot":"","sources":["../../src/actions/delete-post.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAWnD,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAUhE,QAAA,MAAM,gBAAgB,EAAE,MAAM,CAAE,QAAQ,GAAG,YAAY,GAAG,OAAO,CAwKhE,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { DataFormControlProps } from '@wordpress/dataviews';
2
+ /**
3
+ * Internal dependencies
4
+ */
5
+ import type { BasePost } from '../../types';
6
+ export declare const FeaturedImageEdit: ({ data, field, onChange, }: DataFormControlProps<BasePost>) => import("react").JSX.Element;
7
+ //# sourceMappingURL=featured-image-edit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"featured-image-edit.d.ts","sourceRoot":"","sources":["../../../src/fields/featured-image/featured-image-edit.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACjE;;GAEG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAG5C,eAAO,MAAM,iBAAiB,+BAI3B,oBAAoB,CAAE,QAAQ,CAAE,gCAoGlC,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import type { BasePost } from '../../types';
5
+ import type { DataViewRenderFieldProps } from '@wordpress/dataviews';
6
+ export declare const FeaturedImageView: ({ item, }: DataViewRenderFieldProps<BasePost>) => import("react").JSX.Element;
7
+ //# sourceMappingURL=featured-image-view.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"featured-image-view.d.ts","sourceRoot":"","sources":["../../../src/fields/featured-image/featured-image-view.tsx"],"names":[],"mappings":"AAMA;;GAEG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAErE,eAAO,MAAM,iBAAiB,cAE3B,wBAAwB,CAAE,QAAQ,CAAE,gCAuBtC,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import type { Field } from '@wordpress/dataviews';
5
+ /**
6
+ * Internal dependencies
7
+ */
8
+ import type { BasePost } from '../../types';
9
+ declare const featuredImageField: Field<BasePost>;
10
+ export default featuredImageField;
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/featured-image/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAElD;;GAEG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAK5C,QAAA,MAAM,kBAAkB,EAAE,KAAK,CAAE,QAAQ,CAQxC,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
@@ -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.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/fields/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/fields/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,UAAU,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import type { Field } from '@wordpress/dataviews';
5
+ /**
6
+ * Internal dependencies
7
+ */
8
+ import type { BasePost } from '../../types';
9
+ declare const parentField: Field<BasePost>;
10
+ /**
11
+ * This field is used to display the post parent.
12
+ */
13
+ export default parentField;
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/parent/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAElD;;GAEG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAK5C,QAAA,MAAM,WAAW,EAAE,KAAK,CAAE,QAAQ,CAQjC,CAAC;AAEF;;GAEG;AACH,eAAe,WAAW,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { DataFormControlProps } from '@wordpress/dataviews';
2
+ import type { BasePost } from '../../types';
3
+ export declare const getItemPriority: (name: string, searchValue: string) => number;
4
+ export declare function PageAttributesParent({ data, onChangeControl, }: {
5
+ data: BasePost;
6
+ onChangeControl: (newValue: number) => void;
7
+ }): import("react").JSX.Element | null;
8
+ export declare const ParentEdit: ({ data, field, onChange, }: DataFormControlProps<BasePost>) => import("react").JSX.Element;
9
+ //# sourceMappingURL=parent-edit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parent-edit.d.ts","sourceRoot":"","sources":["../../../src/fields/parent/parent-edit.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAajE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAqE5C,eAAO,MAAM,eAAe,SAAW,MAAM,eAAe,MAAM,WAYjE,CAAC;AAEF,wBAAgB,oBAAoB,CAAE,EACrC,IAAI,EACJ,eAAe,GACf,EAAE;IACF,IAAI,EAAE,QAAQ,CAAC;IACf,eAAe,EAAE,CAAE,QAAQ,EAAE,MAAM,KAAM,IAAI,CAAC;CAC9C,sCAsKA;AAED,eAAO,MAAM,UAAU,+BAIpB,oBAAoB,CAAE,QAAQ,CAAE,gCA4DlC,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import type { BasePost } from '../../types';
5
+ import type { DataViewRenderFieldProps } from '@wordpress/dataviews';
6
+ export declare const ParentView: ({ item, }: DataViewRenderFieldProps<BasePost>) => import("react").JSX.Element;
7
+ //# sourceMappingURL=parent-view.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parent-view.d.ts","sourceRoot":"","sources":["../../../src/fields/parent/parent-view.tsx"],"names":[],"mappings":"AAMA;;GAEG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAIrE,eAAO,MAAM,UAAU,cAEpB,wBAAwB,CAAE,QAAQ,CAAE,gCAgBtC,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import type { BasePost } from '../../types';
5
+ export declare function getTitleWithFallbackName(post: BasePost): string;
6
+ //# sourceMappingURL=utils.d.ts.map