@wordpress/fields 0.3.0 → 0.4.1-next.082ed6819.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 (184) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +20 -0
  3. package/build/actions/utils.js +2 -2
  4. package/build/actions/utils.js.map +1 -1
  5. package/build/fields/author/author-view.js +72 -0
  6. package/build/fields/author/author-view.js.map +1 -0
  7. package/build/fields/author/index.js +35 -0
  8. package/build/fields/author/index.js.map +1 -0
  9. package/build/fields/comment-status/index.js +40 -0
  10. package/build/fields/comment-status/index.js.map +1 -0
  11. package/build/fields/date/date-view.js +69 -0
  12. package/build/fields/date/date-view.js.map +1 -0
  13. package/build/fields/date/index.js +29 -0
  14. package/build/fields/date/index.js.map +1 -0
  15. package/build/fields/featured-image/featured-image-edit.js.map +1 -1
  16. package/build/fields/featured-image/featured-image-view.js.map +1 -1
  17. package/build/fields/featured-image/index.js +0 -3
  18. package/build/fields/featured-image/index.js.map +1 -1
  19. package/build/fields/index.js +35 -0
  20. package/build/fields/index.js.map +1 -1
  21. package/build/fields/order/index.js +1 -1
  22. package/build/fields/order/index.js.map +1 -1
  23. package/build/fields/parent/index.js +0 -3
  24. package/build/fields/parent/index.js.map +1 -1
  25. package/build/fields/parent/parent-edit.js +6 -6
  26. package/build/fields/parent/parent-edit.js.map +1 -1
  27. package/build/fields/parent/parent-view.js +1 -1
  28. package/build/fields/parent/parent-view.js.map +1 -1
  29. package/build/fields/password/edit.js +65 -0
  30. package/build/fields/password/edit.js.map +1 -0
  31. package/build/fields/password/index.js +30 -0
  32. package/build/fields/password/index.js.map +1 -0
  33. package/build/fields/slug/index.js +0 -3
  34. package/build/fields/slug/index.js.map +1 -1
  35. package/build/fields/slug/slug-edit.js +23 -26
  36. package/build/fields/slug/slug-edit.js.map +1 -1
  37. package/build/fields/slug/slug-view.js +3 -2
  38. package/build/fields/slug/slug-view.js.map +1 -1
  39. package/build/fields/slug/utils.js +21 -0
  40. package/build/fields/slug/utils.js.map +1 -0
  41. package/build/fields/status/index.js +37 -0
  42. package/build/fields/status/index.js.map +1 -0
  43. package/build/fields/status/status-elements.js +46 -0
  44. package/build/fields/status/status-elements.js.map +1 -0
  45. package/build/fields/status/status-view.js +41 -0
  46. package/build/fields/status/status-view.js.map +1 -0
  47. package/build/fields/title/index.js +5 -1
  48. package/build/fields/title/index.js.map +1 -1
  49. package/build/fields/title/title-view.js +61 -0
  50. package/build/fields/title/title-view.js.map +1 -0
  51. package/build/index.js.map +1 -1
  52. package/build/types.js.map +1 -1
  53. package/build-module/actions/utils.js +2 -2
  54. package/build-module/actions/utils.js.map +1 -1
  55. package/build-module/fields/author/author-view.js +64 -0
  56. package/build-module/fields/author/author-view.js.map +1 -0
  57. package/build-module/fields/author/index.js +29 -0
  58. package/build-module/fields/author/index.js.map +1 -0
  59. package/build-module/fields/comment-status/index.js +35 -0
  60. package/build-module/fields/comment-status/index.js.map +1 -0
  61. package/build-module/fields/date/date-view.js +62 -0
  62. package/build-module/fields/date/date-view.js.map +1 -0
  63. package/build-module/fields/date/index.js +23 -0
  64. package/build-module/fields/date/index.js.map +1 -0
  65. package/build-module/fields/featured-image/featured-image-edit.js +1 -2
  66. package/build-module/fields/featured-image/featured-image-edit.js.map +1 -1
  67. package/build-module/fields/featured-image/featured-image-view.js.map +1 -1
  68. package/build-module/fields/featured-image/index.js +2 -4
  69. package/build-module/fields/featured-image/index.js.map +1 -1
  70. package/build-module/fields/index.js +5 -0
  71. package/build-module/fields/index.js.map +1 -1
  72. package/build-module/fields/order/index.js +2 -1
  73. package/build-module/fields/order/index.js.map +1 -1
  74. package/build-module/fields/parent/index.js +2 -4
  75. package/build-module/fields/parent/index.js.map +1 -1
  76. package/build-module/fields/parent/parent-edit.js +10 -8
  77. package/build-module/fields/parent/parent-edit.js.map +1 -1
  78. package/build-module/fields/parent/parent-view.js +1 -1
  79. package/build-module/fields/parent/parent-view.js.map +1 -1
  80. package/build-module/fields/password/edit.js +58 -0
  81. package/build-module/fields/password/edit.js.map +1 -0
  82. package/build-module/fields/password/index.js +23 -0
  83. package/build-module/fields/password/index.js.map +1 -0
  84. package/build-module/fields/slug/index.js +2 -4
  85. package/build-module/fields/slug/index.js.map +1 -1
  86. package/build-module/fields/slug/slug-edit.js +25 -27
  87. package/build-module/fields/slug/slug-edit.js.map +1 -1
  88. package/build-module/fields/slug/slug-view.js +3 -2
  89. package/build-module/fields/slug/slug-view.js.map +1 -1
  90. package/build-module/fields/slug/utils.js +13 -0
  91. package/build-module/fields/slug/utils.js.map +1 -0
  92. package/build-module/fields/status/index.js +31 -0
  93. package/build-module/fields/status/index.js.map +1 -0
  94. package/build-module/fields/status/status-elements.js +40 -0
  95. package/build-module/fields/status/status-elements.js.map +1 -0
  96. package/build-module/fields/status/status-view.js +34 -0
  97. package/build-module/fields/status/status-view.js.map +1 -0
  98. package/build-module/fields/title/index.js +4 -1
  99. package/build-module/fields/title/index.js.map +1 -1
  100. package/build-module/fields/title/title-view.js +55 -0
  101. package/build-module/fields/title/title-view.js.map +1 -0
  102. package/build-module/index.js.map +1 -1
  103. package/build-module/types.js.map +1 -1
  104. package/build-style/{styles-rtl.css → style-rtl.css} +77 -0
  105. package/build-style/{styles.css → style.css} +77 -0
  106. package/build-types/fields/author/author-view.d.ts +9 -0
  107. package/build-types/fields/author/author-view.d.ts.map +1 -0
  108. package/build-types/fields/author/index.d.ts +14 -0
  109. package/build-types/fields/author/index.d.ts.map +1 -0
  110. package/build-types/fields/comment-status/index.d.ts +14 -0
  111. package/build-types/fields/comment-status/index.d.ts.map +1 -0
  112. package/build-types/fields/date/date-view.d.ts +9 -0
  113. package/build-types/fields/date/date-view.d.ts.map +1 -0
  114. package/build-types/fields/date/index.d.ts +14 -0
  115. package/build-types/fields/date/index.d.ts.map +1 -0
  116. package/build-types/fields/featured-image/featured-image-edit.d.ts.map +1 -1
  117. package/build-types/fields/featured-image/featured-image-view.d.ts +1 -1
  118. package/build-types/fields/featured-image/featured-image-view.d.ts.map +1 -1
  119. package/build-types/fields/featured-image/index.d.ts.map +1 -1
  120. package/build-types/fields/index.d.ts +5 -0
  121. package/build-types/fields/index.d.ts.map +1 -1
  122. package/build-types/fields/order/index.d.ts.map +1 -1
  123. package/build-types/fields/parent/index.d.ts.map +1 -1
  124. package/build-types/fields/parent/parent-edit.d.ts +3 -0
  125. package/build-types/fields/parent/parent-edit.d.ts.map +1 -1
  126. package/build-types/fields/parent/parent-view.d.ts +1 -1
  127. package/build-types/fields/parent/parent-view.d.ts.map +1 -1
  128. package/build-types/fields/password/edit.d.ts +8 -0
  129. package/build-types/fields/password/edit.d.ts.map +1 -0
  130. package/build-types/fields/password/index.d.ts +14 -0
  131. package/build-types/fields/password/index.d.ts.map +1 -0
  132. package/build-types/fields/slug/index.d.ts.map +1 -1
  133. package/build-types/fields/slug/slug-edit.d.ts.map +1 -1
  134. package/build-types/fields/slug/slug-view.d.ts.map +1 -1
  135. package/build-types/fields/slug/utils.d.ts +6 -0
  136. package/build-types/fields/slug/utils.d.ts.map +1 -0
  137. package/build-types/fields/status/index.d.ts +14 -0
  138. package/build-types/fields/status/index.d.ts.map +1 -0
  139. package/build-types/fields/status/status-elements.d.ts +13 -0
  140. package/build-types/fields/status/status-elements.d.ts.map +1 -0
  141. package/build-types/fields/status/status-view.d.ts +9 -0
  142. package/build-types/fields/status/status-view.d.ts.map +1 -0
  143. package/build-types/fields/title/index.d.ts.map +1 -1
  144. package/build-types/fields/title/title-view.d.ts +9 -0
  145. package/build-types/fields/title/title-view.d.ts.map +1 -0
  146. package/build-types/index.d.ts +1 -0
  147. package/build-types/index.d.ts.map +1 -1
  148. package/build-types/lock-unlock.d.ts +1 -1
  149. package/build-types/lock-unlock.d.ts.map +1 -1
  150. package/build-types/types.d.ts +14 -1
  151. package/build-types/types.d.ts.map +1 -1
  152. package/package.json +23 -21
  153. package/src/actions/utils.ts +2 -2
  154. package/src/fields/author/author-view.tsx +63 -0
  155. package/src/fields/author/index.tsx +32 -0
  156. package/src/fields/comment-status/index.tsx +40 -0
  157. package/src/fields/date/date-view.tsx +92 -0
  158. package/src/fields/date/index.tsx +23 -0
  159. package/src/fields/featured-image/featured-image-edit.tsx +2 -1
  160. package/src/fields/featured-image/featured-image-view.tsx +1 -1
  161. package/src/fields/featured-image/index.ts +1 -2
  162. package/src/fields/featured-image/style.scss +2 -5
  163. package/src/fields/index.ts +5 -0
  164. package/src/fields/order/index.ts +2 -1
  165. package/src/fields/parent/index.ts +1 -2
  166. package/src/fields/parent/parent-edit.tsx +9 -9
  167. package/src/fields/parent/parent-view.tsx +2 -2
  168. package/src/fields/password/edit.tsx +68 -0
  169. package/src/fields/password/index.tsx +24 -0
  170. package/src/fields/slug/index.ts +1 -2
  171. package/src/fields/slug/slug-edit.tsx +21 -24
  172. package/src/fields/slug/slug-view.tsx +3 -2
  173. package/src/fields/slug/utils.ts +15 -0
  174. package/src/fields/status/index.tsx +32 -0
  175. package/src/fields/status/status-elements.tsx +50 -0
  176. package/src/fields/status/status-view.tsx +28 -0
  177. package/src/fields/title/index.ts +3 -0
  178. package/src/fields/title/title-view.tsx +62 -0
  179. package/src/index.ts +1 -0
  180. package/src/style.scss +2 -0
  181. package/src/types.ts +17 -1
  182. package/tsconfig.json +10 -9
  183. package/tsconfig.tsbuildinfo +1 -1
  184. package/src/styles.scss +0 -1
@@ -1,3 +1,8 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import removeAccents from 'remove-accents';
5
+
1
6
  /**
2
7
  * WordPress dependencies
3
8
  */
@@ -6,19 +11,16 @@ import { useSelect } from '@wordpress/data';
6
11
  import { createInterpolateElement, useCallback, useMemo, useState } from '@wordpress/element';
7
12
  // @ts-ignore
8
13
  import { store as coreStore } from '@wordpress/core-data';
9
- /**
10
- * External dependencies
11
- */
12
- import removeAccents from 'remove-accents';
14
+ import { debounce } from '@wordpress/compose';
15
+ import { decodeEntities } from '@wordpress/html-entities';
16
+ import { __, sprintf } from '@wordpress/i18n';
17
+ import { filterURLForDisplay } from '@wordpress/url';
13
18
 
14
19
  /**
15
20
  * Internal dependencies
16
21
  */
17
- import { debounce } from '@wordpress/compose';
18
- import { decodeEntities } from '@wordpress/html-entities';
19
- import { __, sprintf } from '@wordpress/i18n';
22
+
20
23
  import { getTitleWithFallbackName } from './utils';
21
- import { filterURLForDisplay } from '@wordpress/url';
22
24
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
23
25
  function buildTermsTree(flatTerms) {
24
26
  const flatTermsWithParentAndChildren = flatTerms.map(term => {
@@ -1 +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,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAE7C,SAASC,wBAAwB,QAAQ,SAAS;AAClD,SAASC,mBAAmB,QAAQ,gBAAgB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAkBrD,SAASC,cAAcA,CAAEC,SAAiB,EAAG;EAC5C,MAAMC,8BAA8B,GAAGD,SAAS,CAACE,GAAG,CAAIC,IAAI,IAAM;IACjE,OAAO;MACNC,QAAQ,EAAE,EAAE;MACZ,GAAGD;IACJ,CAAC;EACF,CAAE,CAAC;;EAEH;EACA,IACCF,8BAA8B,CAACI,IAAI,CAClC,CAAE;IAAEC;EAAO,CAAC,KAAMA,MAAM,KAAK,IAAI,IAAIA,MAAM,KAAKC,SACjD,CAAC,EACA;IACD,OAAON,8BAA8B;EACtC;EAEA,MAAMO,aAAa,GAClBP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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":[]}
1
+ {"version":3,"names":["removeAccents","ComboboxControl","ExternalLink","useSelect","createInterpolateElement","useCallback","useMemo","useState","store","coreStore","debounce","decodeEntities","__","sprintf","filterURLForDisplay","getTitleWithFallbackName","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 * External dependencies\n */\nimport removeAccents from 'remove-accents';\n\n/**\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';\nimport { debounce } from '@wordpress/compose';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { filterURLForDisplay } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\nimport { getTitleWithFallbackName } from './utils';\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,OAAOA,aAAa,MAAM,gBAAgB;;AAE1C;AACA;AACA;AACA,SAASC,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;AAEzD,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,mBAAmB,QAAQ,gBAAgB;;AAEpD;AACA;AACA;;AAEA,SAASC,wBAAwB,QAAQ,SAAS;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAkBnD,SAASC,cAAcA,CAAEC,SAAiB,EAAG;EAC5C,MAAMC,8BAA8B,GAAGD,SAAS,CAACE,GAAG,CAAIC,IAAI,IAAM;IACjE,OAAO;MACNC,QAAQ,EAAE,EAAE;MACZ,GAAGD;IACJ,CAAC;EACF,CAAE,CAAC;;EAEH;EACA,IACCF,8BAA8B,CAACI,IAAI,CAClC,CAAE;IAAEC;EAAO,CAAC,KAAMA,MAAM,KAAK,IAAI,IAAIA,MAAM,KAAKC,SACjD,CAAC,EACA;IACD,OAAON,8BAA8B;EACtC;EAEA,MAAMO,aAAa,GA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AAA;QAAAQ,QAAA,EACGrB,wBAAwB,CACzBQ,EAAE,CACD,mFACD,CAAC,EACD;UACC0E,CAAC,eACArE,IAAA,CAACf,YAAY;YACZsH,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":[]}
@@ -3,13 +3,13 @@
3
3
  */
4
4
  import { useSelect } from '@wordpress/data';
5
5
  import { store as coreStore } from '@wordpress/core-data';
6
+ import { __ } from '@wordpress/i18n';
6
7
 
7
8
  /**
8
9
  * Internal dependencies
9
10
  */
10
11
 
11
12
  import { getTitleWithFallbackName } from './utils';
12
- import { __ } from '@wordpress/i18n';
13
13
  import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
14
14
  export const ParentView = ({
15
15
  item
@@ -1 +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":[]}
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';\nimport type { DataViewRenderFieldProps } from '@wordpress/dataviews';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\nimport { getTitleWithFallbackName } from './utils';\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,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;;AAEA,SAASC,wBAAwB,QAAQ,SAAS;AAAC,SAAAC,QAAA,IAAAC,SAAA,EAAAC,GAAA,IAAAC,IAAA;AAEnD,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,EAAIX,wBAAwB,CAAEO,MAAO;IAAC,CAAI,CAAC;EACnD;EAEA,oBAAOH,IAAA,CAAAF,SAAA;IAAAS,QAAA,EAAIZ,EAAE,CAAE,MAAO;EAAC,CAAI,CAAC;AAC7B,CAAC","ignoreList":[]}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { CheckboxControl, __experimentalVStack as VStack, TextControl } from '@wordpress/components';
5
+ import { useState } from '@wordpress/element';
6
+ import { __ } from '@wordpress/i18n';
7
+
8
+ /**
9
+ * Internal dependencies
10
+ */
11
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
12
+ function PasswordEdit({
13
+ data,
14
+ onChange,
15
+ field
16
+ }) {
17
+ const [showPassword, setShowPassword] = useState(!!field.getValue({
18
+ item: data
19
+ }));
20
+ const handleTogglePassword = value => {
21
+ setShowPassword(value);
22
+ if (!value) {
23
+ onChange({
24
+ password: ''
25
+ });
26
+ }
27
+ };
28
+ return /*#__PURE__*/_jsxs(VStack, {
29
+ as: "fieldset",
30
+ spacing: 4,
31
+ className: "fields-controls__password",
32
+ children: [/*#__PURE__*/_jsx(CheckboxControl, {
33
+ __nextHasNoMarginBottom: true,
34
+ label: __('Password protected'),
35
+ help: __('Only visible to those who know the password'),
36
+ checked: showPassword,
37
+ onChange: handleTogglePassword
38
+ }), showPassword && /*#__PURE__*/_jsx("div", {
39
+ className: "fields-controls__password-input",
40
+ children: /*#__PURE__*/_jsx(TextControl, {
41
+ label: __('Password'),
42
+ onChange: value => onChange({
43
+ password: value
44
+ }),
45
+ value: field.getValue({
46
+ item: data
47
+ }) || '',
48
+ placeholder: __('Use a secure password'),
49
+ type: "text",
50
+ __next40pxDefaultSize: true,
51
+ __nextHasNoMarginBottom: true,
52
+ maxLength: 255
53
+ })
54
+ })]
55
+ });
56
+ }
57
+ export default PasswordEdit;
58
+ //# sourceMappingURL=edit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["CheckboxControl","__experimentalVStack","VStack","TextControl","useState","__","jsx","_jsx","jsxs","_jsxs","PasswordEdit","data","onChange","field","showPassword","setShowPassword","getValue","item","handleTogglePassword","value","password","as","spacing","className","children","__nextHasNoMarginBottom","label","help","checked","placeholder","type","__next40pxDefaultSize","maxLength"],"sources":["@wordpress/fields/src/fields/password/edit.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tCheckboxControl,\n\t__experimentalVStack as VStack,\n\tTextControl,\n} from '@wordpress/components';\nimport type { DataFormControlProps } from '@wordpress/dataviews';\nimport { useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\n\nfunction PasswordEdit( {\n\tdata,\n\tonChange,\n\tfield,\n}: DataFormControlProps< BasePost > ) {\n\tconst [ showPassword, setShowPassword ] = useState(\n\t\t!! field.getValue( { item: data } )\n\t);\n\n\tconst handleTogglePassword = ( value: boolean ) => {\n\t\tsetShowPassword( value );\n\t\tif ( ! value ) {\n\t\t\tonChange( { password: '' } );\n\t\t}\n\t};\n\n\treturn (\n\t\t<VStack\n\t\t\tas=\"fieldset\"\n\t\t\tspacing={ 4 }\n\t\t\tclassName=\"fields-controls__password\"\n\t\t>\n\t\t\t<CheckboxControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\tlabel={ __( 'Password protected' ) }\n\t\t\t\thelp={ __( 'Only visible to those who know the password' ) }\n\t\t\t\tchecked={ showPassword }\n\t\t\t\tonChange={ handleTogglePassword }\n\t\t\t/>\n\t\t\t{ showPassword && (\n\t\t\t\t<div className=\"fields-controls__password-input\">\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\tlabel={ __( 'Password' ) }\n\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\tonChange( {\n\t\t\t\t\t\t\t\tpassword: value,\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tvalue={ field.getValue( { item: data } ) || '' }\n\t\t\t\t\t\tplaceholder={ __( 'Use a secure password' ) }\n\t\t\t\t\t\ttype=\"text\"\n\t\t\t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CAACJ,WAAW;QACXuB,KAAK,EAAGrB,EAAE,CAAE,UAAW,CAAG;QAC1BO,QAAQ,EAAKO,KAAK,IACjBP,QAAQ,CAAE;UACTQ,QAAQ,EAAED;QACX,CAAE,CACF;QACDA,KAAK,EAAGN,KAAK,CAACG,QAAQ,CAAE;UAAEC,IAAI,EAAEN;QAAK,CAAE,CAAC,IAAI,EAAI;QAChDkB,WAAW,EAAGxB,EAAE,CAAE,uBAAwB,CAAG;QAC7CyB,IAAI,EAAC,MAAM;QACXC,qBAAqB;QACrBN,uBAAuB;QACvBO,SAAS,EAAG;MAAK,CACjB;IAAC,CACE,CACL;EAAA,CACM,CAAC;AAEX;AACA,eAAetB,YAAY","ignoreList":[]}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+
5
+ /**
6
+ * Internal dependencies
7
+ */
8
+
9
+ import PasswordEdit from './edit';
10
+ const passwordField = {
11
+ id: 'password',
12
+ type: 'text',
13
+ Edit: PasswordEdit,
14
+ enableSorting: false,
15
+ enableHiding: false,
16
+ isVisible: item => item.status !== 'private'
17
+ };
18
+
19
+ /**
20
+ * This field is used to display the post password.
21
+ */
22
+ export default passwordField;
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["PasswordEdit","passwordField","id","type","Edit","enableSorting","enableHiding","isVisible","item","status"],"sources":["@wordpress/fields/src/fields/password/index.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport type { Field } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\nimport PasswordEdit from './edit';\n\nconst passwordField: Field< BasePost > = {\n\tid: 'password',\n\ttype: 'text',\n\tEdit: PasswordEdit,\n\tenableSorting: false,\n\tenableHiding: false,\n\tisVisible: ( item ) => item.status !== 'private',\n};\n\n/**\n * This field is used to display the post password.\n */\nexport default passwordField;\n"],"mappings":"AAAA;AACA;AACA;;AAGA;AACA;AACA;;AAEA,OAAOA,YAAY,MAAM,QAAQ;AAEjC,MAAMC,aAAgC,GAAG;EACxCC,EAAE,EAAE,UAAU;EACdC,IAAI,EAAE,MAAM;EACZC,IAAI,EAAEJ,YAAY;EAClBK,aAAa,EAAE,KAAK;EACpBC,YAAY,EAAE,KAAK;EACnBC,SAAS,EAAIC,IAAI,IAAMA,IAAI,CAACC,MAAM,KAAK;AACxC,CAAC;;AAED;AACA;AACA;AACA,eAAeR,aAAa","ignoreList":[]}
@@ -2,20 +2,18 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
 
5
+ import { __ } from '@wordpress/i18n';
6
+
5
7
  /**
6
8
  * Internal dependencies
7
9
  */
8
10
 
9
- import { __ } from '@wordpress/i18n';
10
11
  import SlugEdit from './slug-edit';
11
12
  import SlugView from './slug-view';
12
13
  const slugField = {
13
14
  id: 'slug',
14
15
  type: 'text',
15
16
  label: __('Slug'),
16
- getValue: ({
17
- item
18
- }) => item.slug,
19
17
  Edit: SlugEdit,
20
18
  render: SlugView
21
19
  };
@@ -1 +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":[]}
1
+ {"version":3,"names":["__","SlugEdit","SlugView","slugField","id","type","label","Edit","render"],"sources":["@wordpress/fields/src/fields/slug/index.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport type { Field } from '@wordpress/dataviews';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\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\tEdit: SlugEdit,\n\trender: SlugView,\n};\n\nexport default slugField;\n"],"mappings":"AAAA;AACA;AACA;;AAEA,SAASA,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;;AAEA,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,IAAI,EAAEN,QAAQ;EACdO,MAAM,EAAEN;AACT,CAAC;AAED,eAAeC,SAAS","ignoreList":[]}
@@ -13,19 +13,20 @@ import { __ } from '@wordpress/i18n';
13
13
  /**
14
14
  * Internal dependencies
15
15
  */
16
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
16
+
17
+ import { getSlug } from './utils';
18
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
17
19
  const SlugEdit = ({
18
20
  field,
19
21
  onChange,
20
22
  data
21
23
  }) => {
22
- var _field$getValue;
23
24
  const {
24
25
  id
25
26
  } = field;
26
- const slug = (_field$getValue = field.getValue({
27
+ const slug = field.getValue({
27
28
  item: data
28
- })) !== null && _field$getValue !== void 0 ? _field$getValue : '';
29
+ }) || getSlug(data);
29
30
  const permalinkTemplate = data.permalink_template || '';
30
31
  const PERMALINK_POSTNAME_REGEX = /%(?:postname|pagename)%/;
31
32
  const [prefix, suffix] = permalinkTemplate.split(PERMALINK_POSTNAME_REGEX);
@@ -90,29 +91,26 @@ const SlugEdit = ({
90
91
  onChangeControl(originalSlugRef.current);
91
92
  }
92
93
  },
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
- })
94
+ "aria-describedby": postUrlSlugDescriptionId
95
+ }), /*#__PURE__*/_jsxs("div", {
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
+ })]
116
114
  })]
117
115
  }), !isEditable && /*#__PURE__*/_jsx(ExternalLink, {
118
116
  className: "fields-controls__slug-help",
@@ -1 +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,Y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]}
1
+ {"version":3,"names":["Button","ExternalLink","__experimentalInputControl","InputControl","__experimentalInputControlPrefixWrapper","InputControlPrefixWrapper","__experimentalVStack","VStack","copySmall","useCopyToClipboard","useInstanceId","useDispatch","useCallback","useEffect","useRef","store","noticesStore","safeDecodeURIComponent","__","getSlug","jsx","_jsx","jsxs","_jsxs","SlugEdit","field","onChange","data","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"],"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';\nimport { getSlug } from './utils';\n\nconst SlugEdit = ( {\n\tfield,\n\tonChange,\n\tdata,\n}: DataFormControlProps< BasePost > ) => {\n\tconst { id } = field;\n\n\tconst slug = field.getValue( { item: data } ) || getSlug( 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/>\n\t\t\t\t\t<div className=\"fields-controls__slug-help\">\n\t\t\t\t\t\t<span className=\"fields-controls__slug-help-visual-label\">\n\t\t\t\t\t\t\t{ __( 'Permalink:' ) }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\tclassName=\"fields-controls__slug-help-link\"\n\t\t\t\t\t\t\thref={ permalink }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<span className=\"fields-controls__slug-help-prefix\">\n\t\t\t\t\t\t\t\t{ permalinkPrefix }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t<span className=\"fields-controls__slug-help-slug\">\n\t\t\t\t\t\t\t\t{ slugToDisplay }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t<span className=\"fields-controls__slug-help-suffix\">\n\t\t\t\t\t\t\t\t{ permalinkSuffix }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t</div>\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;;AAEA,SAASC,OAAO,QAAQ,SAAS;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAElC,MAAMC,QAAQ,GAAGA,CAAE;EAClBC,KAAK;EACLC,QAAQ;EACRC;AACiC,CAAC,KAAM;EACxC,MAAM;IAAEC;EAAG,CAAC,GAAGH,KAAK;EAEpB,MAAMI,IAAI,GAAGJ,KAAK,CAACK,QAAQ,CAAE;IAAEC,IAAI,EAAEJ;EAAK,CAAE,CAAC,IAAI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AAAC,QAAA,gBAC1CnC,IAAA;UAAMkC,SAAS,EAAC,yCAAyC;UAAAC,QAAA,EACtDtC,EAAE,CAAE,YAAa;QAAC,CACf,CAAC,eACPK,KAAA,CAACtB,YAAY;UACZsD,SAAS,EAAC,iCAAiC;UAC3CG,IAAI,EAAGb,SAAW;UAAAW,QAAA,gBAElBnC,IAAA;YAAMkC,SAAS,EAAC,mCAAmC;YAAAC,QAAA,EAChDlB;UAAe,CACZ,CAAC,eACPjB,IAAA;YAAMkC,SAAS,EAAC,iCAAiC;YAAAC,QAAA,EAC9Cb;UAAa,CACV,CAAC,eACPtB,IAAA;YAAMkC,SAAS,EAAC,mCAAmC;YAAAC,QAAA,EAChDjB;UAAe,CACZ,CAAC;QAAA,CACM,CAAC;MAAA,CACX,CAAC;IAAA,CACC,CACR,EACC,CAAEC,UAAU,iBACbnB,IAAA,CAACpB,YAAY;MACZsD,SAAS,EAAC,4BAA4B;MACtCG,IAAI,EAAGb,SAAW;MAAAW,QAAA,EAEhBX;IAAS,CACE,CACd;EAAA,CACQ,CAAC;AAEb,CAAC;AAED,eAAerB,QAAQ","ignoreList":[]}
@@ -7,10 +7,11 @@ import { useEffect, useRef } from '@wordpress/element';
7
7
  * Internal dependencies
8
8
  */
9
9
 
10
+ import { getSlug } from './utils';
10
11
  const SlugView = ({
11
12
  item
12
13
  }) => {
13
- const slug = item.slug;
14
+ const slug = typeof item === 'object' ? getSlug(item) : '';
14
15
  const originalSlugRef = useRef(slug);
15
16
  useEffect(() => {
16
17
  if (slug && originalSlugRef.current === undefined) {
@@ -18,7 +19,7 @@ const SlugView = ({
18
19
  }
19
20
  }, [slug]);
20
21
  const slugToDisplay = slug || originalSlugRef.current;
21
- return `/${slugToDisplay !== null && slugToDisplay !== void 0 ? slugToDisplay : ''}`;
22
+ return `${slugToDisplay}`;
22
23
  };
23
24
  export default SlugView;
24
25
  //# sourceMappingURL=slug-view.js.map
@@ -1 +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
+ {"version":3,"names":["useEffect","useRef","getSlug","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';\nimport { getSlug } from './utils';\n\nconst SlugView = ( { item }: { item: BasePost } ) => {\n\tconst slug = typeof item === 'object' ? getSlug( item ) : '';\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;;AAEA,SAASC,OAAO,QAAQ,SAAS;AAEjC,MAAMC,QAAQ,GAAGA,CAAE;EAAEC;AAAyB,CAAC,KAAM;EACpD,MAAMC,IAAI,GAAG,OAAOD,IAAI,KAAK,QAAQ,GAAGF,OAAO,CAAEE,IAAK,CAAC,GAAG,EAAE;EAC5D,MAAME,eAAe,GAAGL,MAAM,CAAEI,IAAK,CAAC;EAEtCL,SAAS,CAAE,MAAM;IAChB,IAAKK,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,GAAIE,aAAa,EAAG;AAC5B,CAAC;AAED,eAAeN,QAAQ","ignoreList":[]}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { cleanForSlug } from '@wordpress/url';
5
+ /**
6
+ * Internal dependencies
7
+ */
8
+
9
+ import { getItemTitle } from '../../actions/utils';
10
+ export const getSlug = item => {
11
+ return item.slug || cleanForSlug(getItemTitle(item)) || item.id.toString();
12
+ };
13
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["cleanForSlug","getItemTitle","getSlug","item","slug","id","toString"],"sources":["@wordpress/fields/src/fields/slug/utils.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { cleanForSlug } from '@wordpress/url';\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\nimport { getItemTitle } from '../../actions/utils';\n\nexport const getSlug = ( item: BasePost ): string => {\n\treturn (\n\t\titem.slug || cleanForSlug( getItemTitle( item ) ) || item.id.toString()\n\t);\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,YAAY,QAAQ,gBAAgB;AAC7C;AACA;AACA;;AAEA,SAASC,YAAY,QAAQ,qBAAqB;AAElD,OAAO,MAAMC,OAAO,GAAKC,IAAc,IAAc;EACpD,OACCA,IAAI,CAACC,IAAI,IAAIJ,YAAY,CAAEC,YAAY,CAAEE,IAAK,CAAE,CAAC,IAAIA,IAAI,CAACE,EAAE,CAACC,QAAQ,CAAC,CAAC;AAEzE,CAAC","ignoreList":[]}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+
5
+ import { __ } from '@wordpress/i18n';
6
+
7
+ /**
8
+ * Internal dependencies
9
+ */
10
+
11
+ import StatusView from './status-view';
12
+ import STATUSES from './status-elements';
13
+ const OPERATOR_IS_ANY = 'isAny';
14
+ const statusField = {
15
+ label: __('Status'),
16
+ id: 'status',
17
+ type: 'text',
18
+ elements: STATUSES,
19
+ render: StatusView,
20
+ Edit: 'radio',
21
+ enableSorting: false,
22
+ filterBy: {
23
+ operators: [OPERATOR_IS_ANY]
24
+ }
25
+ };
26
+
27
+ /**
28
+ * Status field for BasePost.
29
+ */
30
+ export default statusField;
31
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["__","StatusView","STATUSES","OPERATOR_IS_ANY","statusField","label","id","type","elements","render","Edit","enableSorting","filterBy","operators"],"sources":["@wordpress/fields/src/fields/status/index.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport type { Field } from '@wordpress/dataviews';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\nimport StatusView from './status-view';\nimport STATUSES from './status-elements';\n\nconst OPERATOR_IS_ANY = 'isAny';\n\nconst statusField: Field< BasePost > = {\n\tlabel: __( 'Status' ),\n\tid: 'status',\n\ttype: 'text',\n\telements: STATUSES,\n\trender: StatusView,\n\tEdit: 'radio',\n\tenableSorting: false,\n\tfilterBy: {\n\t\toperators: [ OPERATOR_IS_ANY ],\n\t},\n};\n\n/**\n * Status field for BasePost.\n */\nexport default statusField;\n"],"mappings":"AAAA;AACA;AACA;;AAEA,SAASA,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;;AAEA,OAAOC,UAAU,MAAM,eAAe;AACtC,OAAOC,QAAQ,MAAM,mBAAmB;AAExC,MAAMC,eAAe,GAAG,OAAO;AAE/B,MAAMC,WAA8B,GAAG;EACtCC,KAAK,EAAEL,EAAE,CAAE,QAAS,CAAC;EACrBM,EAAE,EAAE,QAAQ;EACZC,IAAI,EAAE,MAAM;EACZC,QAAQ,EAAEN,QAAQ;EAClBO,MAAM,EAAER,UAAU;EAClBS,IAAI,EAAE,OAAO;EACbC,aAAa,EAAE,KAAK;EACpBC,QAAQ,EAAE;IACTC,SAAS,EAAE,CAAEV,eAAe;EAC7B;AACD,CAAC;;AAED;AACA;AACA;AACA,eAAeC,WAAW","ignoreList":[]}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { trash, drafts, published, scheduled, pending, notAllowed } from '@wordpress/icons';
5
+ import { __ } from '@wordpress/i18n';
6
+
7
+ // See https://github.com/WordPress/gutenberg/issues/55886
8
+ // We do not support custom statutes at the moment.
9
+ const STATUSES = [{
10
+ value: 'draft',
11
+ label: __('Draft'),
12
+ icon: drafts,
13
+ description: __('Not ready to publish.')
14
+ }, {
15
+ value: 'future',
16
+ label: __('Scheduled'),
17
+ icon: scheduled,
18
+ description: __('Publish automatically on a chosen date.')
19
+ }, {
20
+ value: 'pending',
21
+ label: __('Pending Review'),
22
+ icon: pending,
23
+ description: __('Waiting for review before publishing.')
24
+ }, {
25
+ value: 'private',
26
+ label: __('Private'),
27
+ icon: notAllowed,
28
+ description: __('Only visible to site admins and editors.')
29
+ }, {
30
+ value: 'publish',
31
+ label: __('Published'),
32
+ icon: published,
33
+ description: __('Visible to everyone.')
34
+ }, {
35
+ value: 'trash',
36
+ label: __('Trash'),
37
+ icon: trash
38
+ }];
39
+ export default STATUSES;
40
+ //# sourceMappingURL=status-elements.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["trash","drafts","published","scheduled","pending","notAllowed","__","STATUSES","value","label","icon","description"],"sources":["@wordpress/fields/src/fields/status/status-elements.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\ttrash,\n\tdrafts,\n\tpublished,\n\tscheduled,\n\tpending,\n\tnotAllowed,\n} from '@wordpress/icons';\nimport { __ } from '@wordpress/i18n';\n\n// See https://github.com/WordPress/gutenberg/issues/55886\n// We do not support custom statutes at the moment.\nconst STATUSES = [\n\t{\n\t\tvalue: 'draft',\n\t\tlabel: __( 'Draft' ),\n\t\ticon: drafts,\n\t\tdescription: __( 'Not ready to publish.' ),\n\t},\n\t{\n\t\tvalue: 'future',\n\t\tlabel: __( 'Scheduled' ),\n\t\ticon: scheduled,\n\t\tdescription: __( 'Publish automatically on a chosen date.' ),\n\t},\n\t{\n\t\tvalue: 'pending',\n\t\tlabel: __( 'Pending Review' ),\n\t\ticon: pending,\n\t\tdescription: __( 'Waiting for review before publishing.' ),\n\t},\n\t{\n\t\tvalue: 'private',\n\t\tlabel: __( 'Private' ),\n\t\ticon: notAllowed,\n\t\tdescription: __( 'Only visible to site admins and editors.' ),\n\t},\n\t{\n\t\tvalue: 'publish',\n\t\tlabel: __( 'Published' ),\n\t\ticon: published,\n\t\tdescription: __( 'Visible to everyone.' ),\n\t},\n\t{ value: 'trash', label: __( 'Trash' ), icon: trash },\n];\n\nexport default STATUSES;\n"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,KAAK,EACLC,MAAM,EACNC,SAAS,EACTC,SAAS,EACTC,OAAO,EACPC,UAAU,QACJ,kBAAkB;AACzB,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA,MAAMC,QAAQ,GAAG,CAChB;EACCC,KAAK,EAAE,OAAO;EACdC,KAAK,EAAEH,EAAE,CAAE,OAAQ,CAAC;EACpBI,IAAI,EAAET,MAAM;EACZU,WAAW,EAAEL,EAAE,CAAE,uBAAwB;AAC1C,CAAC,EACD;EACCE,KAAK,EAAE,QAAQ;EACfC,KAAK,EAAEH,EAAE,CAAE,WAAY,CAAC;EACxBI,IAAI,EAAEP,SAAS;EACfQ,WAAW,EAAEL,EAAE,CAAE,yCAA0C;AAC5D,CAAC,EACD;EACCE,KAAK,EAAE,SAAS;EAChBC,KAAK,EAAEH,EAAE,CAAE,gBAAiB,CAAC;EAC7BI,IAAI,EAAEN,OAAO;EACbO,WAAW,EAAEL,EAAE,CAAE,uCAAwC;AAC1D,CAAC,EACD;EACCE,KAAK,EAAE,SAAS;EAChBC,KAAK,EAAEH,EAAE,CAAE,SAAU,CAAC;EACtBI,IAAI,EAAEL,UAAU;EAChBM,WAAW,EAAEL,EAAE,CAAE,0CAA2C;AAC7D,CAAC,EACD;EACCE,KAAK,EAAE,SAAS;EAChBC,KAAK,EAAEH,EAAE,CAAE,WAAY,CAAC;EACxBI,IAAI,EAAER,SAAS;EACfS,WAAW,EAAEL,EAAE,CAAE,sBAAuB;AACzC,CAAC,EACD;EAAEE,KAAK,EAAE,OAAO;EAAEC,KAAK,EAAEH,EAAE,CAAE,OAAQ,CAAC;EAAEI,IAAI,EAAEV;AAAM,CAAC,CACrD;AAED,eAAeO,QAAQ","ignoreList":[]}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { __experimentalHStack as HStack, Icon } from '@wordpress/components';
5
+
6
+ /**
7
+ * Internal dependencies
8
+ */
9
+
10
+ import STATUSES from './status-elements';
11
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
12
+ function StatusView({
13
+ item
14
+ }) {
15
+ const status = STATUSES.find(({
16
+ value
17
+ }) => value === item.status);
18
+ const label = status?.label || item.status;
19
+ const icon = status?.icon;
20
+ return /*#__PURE__*/_jsxs(HStack, {
21
+ alignment: "left",
22
+ spacing: 0,
23
+ children: [icon && /*#__PURE__*/_jsx("div", {
24
+ className: "edit-site-post-list__status-icon",
25
+ children: /*#__PURE__*/_jsx(Icon, {
26
+ icon: icon
27
+ })
28
+ }), /*#__PURE__*/_jsx("span", {
29
+ children: label
30
+ })]
31
+ });
32
+ }
33
+ export default StatusView;
34
+ //# sourceMappingURL=status-view.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["__experimentalHStack","HStack","Icon","STATUSES","jsx","_jsx","jsxs","_jsxs","StatusView","item","status","find","value","label","icon","alignment","spacing","children","className"],"sources":["@wordpress/fields/src/fields/status/status-view.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __experimentalHStack as HStack, Icon } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\nimport STATUSES from './status-elements';\n\nfunction StatusView( { item }: { item: BasePost } ) {\n\tconst status = STATUSES.find( ( { value } ) => value === item.status );\n\tconst label = status?.label || item.status;\n\tconst icon = status?.icon;\n\treturn (\n\t\t<HStack alignment=\"left\" spacing={ 0 }>\n\t\t\t{ icon && (\n\t\t\t\t<div className=\"edit-site-post-list__status-icon\">\n\t\t\t\t\t<Icon icon={ icon } />\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<span>{ label }</span>\n\t\t</HStack>\n\t);\n}\n\nexport default StatusView;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,oBAAoB,IAAIC,MAAM,EAAEC,IAAI,QAAQ,uBAAuB;;AAE5E;AACA;AACA;;AAEA,OAAOC,QAAQ,MAAM,mBAAmB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAEzC,SAASC,UAAUA,CAAE;EAAEC;AAAyB,CAAC,EAAG;EACnD,MAAMC,MAAM,GAAGP,QAAQ,CAACQ,IAAI,CAAE,CAAE;IAAEC;EAAM,CAAC,KAAMA,KAAK,KAAKH,IAAI,CAACC,MAAO,CAAC;EACtE,MAAMG,KAAK,GAAGH,MAAM,EAAEG,KAAK,IAAIJ,IAAI,CAACC,MAAM;EAC1C,MAAMI,IAAI,GAAGJ,MAAM,EAAEI,IAAI;EACzB,oBACCP,KAAA,CAACN,MAAM;IAACc,SAAS,EAAC,MAAM;IAACC,OAAO,EAAG,CAAG;IAAAC,QAAA,GACnCH,IAAI,iBACLT,IAAA;MAAKa,SAAS,EAAC,kCAAkC;MAAAD,QAAA,eAChDZ,IAAA,CAACH,IAAI;QAACY,IAAI,EAAGA;MAAM,CAAE;IAAC,CAClB,CACL,eACDT,IAAA;MAAAY,QAAA,EAAQJ;IAAK,CAAQ,CAAC;EAAA,CACf,CAAC;AAEX;AAEA,eAAeL,UAAU","ignoreList":[]}
@@ -9,6 +9,7 @@ import { __ } from '@wordpress/i18n';
9
9
  */
10
10
 
11
11
  import { getItemTitle } from '../../actions/utils';
12
+ import TitleView from './title-view';
12
13
  const titleField = {
13
14
  type: 'text',
14
15
  id: 'title',
@@ -16,7 +17,9 @@ const titleField = {
16
17
  placeholder: __('No title'),
17
18
  getValue: ({
18
19
  item
19
- }) => getItemTitle(item)
20
+ }) => getItemTitle(item),
21
+ render: TitleView,
22
+ enableHiding: false
20
23
  };
21
24
  export default titleField;
22
25
  //# sourceMappingURL=index.js.map