@wordpress/fields 0.3.0 → 0.4.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 (164) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +16 -0
  3. package/build/actions/utils.js +2 -2
  4. package/build/actions/utils.js.map +1 -1
  5. package/build/fields/comment-status/index.js +40 -0
  6. package/build/fields/comment-status/index.js.map +1 -0
  7. package/build/fields/date/date-view.js +69 -0
  8. package/build/fields/date/date-view.js.map +1 -0
  9. package/build/fields/date/index.js +29 -0
  10. package/build/fields/date/index.js.map +1 -0
  11. package/build/fields/featured-image/featured-image-edit.js.map +1 -1
  12. package/build/fields/featured-image/featured-image-view.js.map +1 -1
  13. package/build/fields/featured-image/index.js +0 -3
  14. package/build/fields/featured-image/index.js.map +1 -1
  15. package/build/fields/index.js +28 -0
  16. package/build/fields/index.js.map +1 -1
  17. package/build/fields/order/index.js +1 -1
  18. package/build/fields/order/index.js.map +1 -1
  19. package/build/fields/parent/index.js +0 -3
  20. package/build/fields/parent/index.js.map +1 -1
  21. package/build/fields/parent/parent-edit.js +6 -6
  22. package/build/fields/parent/parent-edit.js.map +1 -1
  23. package/build/fields/parent/parent-view.js +1 -1
  24. package/build/fields/parent/parent-view.js.map +1 -1
  25. package/build/fields/password/edit.js +65 -0
  26. package/build/fields/password/edit.js.map +1 -0
  27. package/build/fields/password/index.js +30 -0
  28. package/build/fields/password/index.js.map +1 -0
  29. package/build/fields/slug/index.js +0 -3
  30. package/build/fields/slug/index.js.map +1 -1
  31. package/build/fields/slug/slug-edit.js +23 -26
  32. package/build/fields/slug/slug-edit.js.map +1 -1
  33. package/build/fields/slug/slug-view.js +3 -2
  34. package/build/fields/slug/slug-view.js.map +1 -1
  35. package/build/fields/slug/utils.js +21 -0
  36. package/build/fields/slug/utils.js.map +1 -0
  37. package/build/fields/status/index.js +37 -0
  38. package/build/fields/status/index.js.map +1 -0
  39. package/build/fields/status/status-elements.js +46 -0
  40. package/build/fields/status/status-elements.js.map +1 -0
  41. package/build/fields/status/status-view.js +41 -0
  42. package/build/fields/status/status-view.js.map +1 -0
  43. package/build/fields/title/index.js +5 -1
  44. package/build/fields/title/index.js.map +1 -1
  45. package/build/fields/title/title-view.js +61 -0
  46. package/build/fields/title/title-view.js.map +1 -0
  47. package/build/types.js.map +1 -1
  48. package/build-module/actions/utils.js +2 -2
  49. package/build-module/actions/utils.js.map +1 -1
  50. package/build-module/fields/comment-status/index.js +35 -0
  51. package/build-module/fields/comment-status/index.js.map +1 -0
  52. package/build-module/fields/date/date-view.js +62 -0
  53. package/build-module/fields/date/date-view.js.map +1 -0
  54. package/build-module/fields/date/index.js +23 -0
  55. package/build-module/fields/date/index.js.map +1 -0
  56. package/build-module/fields/featured-image/featured-image-edit.js +1 -2
  57. package/build-module/fields/featured-image/featured-image-edit.js.map +1 -1
  58. package/build-module/fields/featured-image/featured-image-view.js.map +1 -1
  59. package/build-module/fields/featured-image/index.js +2 -4
  60. package/build-module/fields/featured-image/index.js.map +1 -1
  61. package/build-module/fields/index.js +4 -0
  62. package/build-module/fields/index.js.map +1 -1
  63. package/build-module/fields/order/index.js +2 -1
  64. package/build-module/fields/order/index.js.map +1 -1
  65. package/build-module/fields/parent/index.js +2 -4
  66. package/build-module/fields/parent/index.js.map +1 -1
  67. package/build-module/fields/parent/parent-edit.js +10 -8
  68. package/build-module/fields/parent/parent-edit.js.map +1 -1
  69. package/build-module/fields/parent/parent-view.js +1 -1
  70. package/build-module/fields/parent/parent-view.js.map +1 -1
  71. package/build-module/fields/password/edit.js +58 -0
  72. package/build-module/fields/password/edit.js.map +1 -0
  73. package/build-module/fields/password/index.js +23 -0
  74. package/build-module/fields/password/index.js.map +1 -0
  75. package/build-module/fields/slug/index.js +2 -4
  76. package/build-module/fields/slug/index.js.map +1 -1
  77. package/build-module/fields/slug/slug-edit.js +25 -27
  78. package/build-module/fields/slug/slug-edit.js.map +1 -1
  79. package/build-module/fields/slug/slug-view.js +3 -2
  80. package/build-module/fields/slug/slug-view.js.map +1 -1
  81. package/build-module/fields/slug/utils.js +13 -0
  82. package/build-module/fields/slug/utils.js.map +1 -0
  83. package/build-module/fields/status/index.js +31 -0
  84. package/build-module/fields/status/index.js.map +1 -0
  85. package/build-module/fields/status/status-elements.js +40 -0
  86. package/build-module/fields/status/status-elements.js.map +1 -0
  87. package/build-module/fields/status/status-view.js +34 -0
  88. package/build-module/fields/status/status-view.js.map +1 -0
  89. package/build-module/fields/title/index.js +4 -1
  90. package/build-module/fields/title/index.js.map +1 -1
  91. package/build-module/fields/title/title-view.js +55 -0
  92. package/build-module/fields/title/title-view.js.map +1 -0
  93. package/build-module/types.js.map +1 -1
  94. package/build-style/{styles-rtl.css → style-rtl.css} +79 -0
  95. package/build-style/{styles.css → style.css} +79 -0
  96. package/build-types/fields/comment-status/index.d.ts +14 -0
  97. package/build-types/fields/comment-status/index.d.ts.map +1 -0
  98. package/build-types/fields/date/date-view.d.ts +9 -0
  99. package/build-types/fields/date/date-view.d.ts.map +1 -0
  100. package/build-types/fields/date/index.d.ts +14 -0
  101. package/build-types/fields/date/index.d.ts.map +1 -0
  102. package/build-types/fields/featured-image/featured-image-edit.d.ts.map +1 -1
  103. package/build-types/fields/featured-image/featured-image-view.d.ts +1 -1
  104. package/build-types/fields/featured-image/featured-image-view.d.ts.map +1 -1
  105. package/build-types/fields/featured-image/index.d.ts.map +1 -1
  106. package/build-types/fields/index.d.ts +4 -0
  107. package/build-types/fields/index.d.ts.map +1 -1
  108. package/build-types/fields/order/index.d.ts.map +1 -1
  109. package/build-types/fields/parent/index.d.ts.map +1 -1
  110. package/build-types/fields/parent/parent-edit.d.ts +3 -0
  111. package/build-types/fields/parent/parent-edit.d.ts.map +1 -1
  112. package/build-types/fields/parent/parent-view.d.ts +1 -1
  113. package/build-types/fields/parent/parent-view.d.ts.map +1 -1
  114. package/build-types/fields/password/edit.d.ts +8 -0
  115. package/build-types/fields/password/edit.d.ts.map +1 -0
  116. package/build-types/fields/password/index.d.ts +14 -0
  117. package/build-types/fields/password/index.d.ts.map +1 -0
  118. package/build-types/fields/slug/index.d.ts.map +1 -1
  119. package/build-types/fields/slug/slug-edit.d.ts.map +1 -1
  120. package/build-types/fields/slug/slug-view.d.ts.map +1 -1
  121. package/build-types/fields/slug/utils.d.ts +6 -0
  122. package/build-types/fields/slug/utils.d.ts.map +1 -0
  123. package/build-types/fields/status/index.d.ts +14 -0
  124. package/build-types/fields/status/index.d.ts.map +1 -0
  125. package/build-types/fields/status/status-elements.d.ts +13 -0
  126. package/build-types/fields/status/status-elements.d.ts.map +1 -0
  127. package/build-types/fields/status/status-view.d.ts +9 -0
  128. package/build-types/fields/status/status-view.d.ts.map +1 -0
  129. package/build-types/fields/title/index.d.ts.map +1 -1
  130. package/build-types/fields/title/title-view.d.ts +9 -0
  131. package/build-types/fields/title/title-view.d.ts.map +1 -0
  132. package/build-types/lock-unlock.d.ts +1 -1
  133. package/build-types/lock-unlock.d.ts.map +1 -1
  134. package/build-types/types.d.ts +3 -1
  135. package/build-types/types.d.ts.map +1 -1
  136. package/package.json +4 -3
  137. package/src/actions/utils.ts +2 -2
  138. package/src/fields/comment-status/index.tsx +40 -0
  139. package/src/fields/date/date-view.tsx +92 -0
  140. package/src/fields/date/index.tsx +23 -0
  141. package/src/fields/featured-image/featured-image-edit.tsx +2 -1
  142. package/src/fields/featured-image/featured-image-view.tsx +1 -1
  143. package/src/fields/featured-image/index.ts +1 -2
  144. package/src/fields/index.ts +4 -0
  145. package/src/fields/order/index.ts +2 -1
  146. package/src/fields/parent/index.ts +1 -2
  147. package/src/fields/parent/parent-edit.tsx +9 -9
  148. package/src/fields/parent/parent-view.tsx +2 -2
  149. package/src/fields/password/edit.tsx +68 -0
  150. package/src/fields/password/index.tsx +24 -0
  151. package/src/fields/slug/index.ts +1 -2
  152. package/src/fields/slug/slug-edit.tsx +21 -24
  153. package/src/fields/slug/slug-view.tsx +3 -2
  154. package/src/fields/slug/utils.ts +15 -0
  155. package/src/fields/status/index.tsx +32 -0
  156. package/src/fields/status/status-elements.tsx +50 -0
  157. package/src/fields/status/status-view.tsx +28 -0
  158. package/src/fields/title/index.ts +3 -0
  159. package/src/fields/title/title-view.tsx +62 -0
  160. package/src/style.scss +2 -0
  161. package/src/types.ts +3 -1
  162. package/tsconfig.json +10 -9
  163. package/tsconfig.tsbuildinfo +1 -1
  164. package/src/styles.scss +0 -1
@@ -1 +1 @@
1
- {"version":3,"names":["decodeEntities","TEMPLATE_POST_TYPE","TEMPLATE_PART_POST_TYPE","TEMPLATE_ORIGINS","custom","theme","plugin","isTemplate","post","type","isTemplatePart","isTemplateOrTemplatePart","p","getItemTitle","item","title","rendered","raw","isTemplateRemovable","template","source","includes","Boolean","has_theme_file"],"sources":["@wordpress/fields/src/actions/utils.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport type { Post, TemplatePart, Template } from '../types';\n\nexport const TEMPLATE_POST_TYPE = 'wp_template';\nexport const TEMPLATE_PART_POST_TYPE = 'wp_template_part';\nexport const TEMPLATE_ORIGINS = {\n\tcustom: 'custom',\n\ttheme: 'theme',\n\tplugin: 'plugin',\n};\n\nexport function isTemplate( post: Post ): post is Template {\n\treturn post.type === TEMPLATE_POST_TYPE;\n}\n\nexport function isTemplatePart( post: Post ): post is TemplatePart {\n\treturn post.type === TEMPLATE_PART_POST_TYPE;\n}\n\nexport function isTemplateOrTemplatePart(\n\tp: Post\n): p is Template | TemplatePart {\n\treturn p.type === TEMPLATE_POST_TYPE || p.type === TEMPLATE_PART_POST_TYPE;\n}\n\nexport function getItemTitle( item: Post ) {\n\tif ( typeof item.title === 'string' ) {\n\t\treturn decodeEntities( item.title );\n\t}\n\tif ( 'rendered' in item.title ) {\n\t\treturn decodeEntities( item.title.rendered );\n\t}\n\tif ( 'raw' in item.title ) {\n\t\treturn decodeEntities( item.title.raw );\n\t}\n\treturn '';\n}\n\n/**\n * Check if a template is removable.\n *\n * @param template The template entity to check.\n * @return Whether the template is removable.\n */\nexport function isTemplateRemovable( template: Template | TemplatePart ) {\n\tif ( ! template ) {\n\t\treturn false;\n\t}\n\t// In patterns list page we map the templates parts to a different object\n\t// than the one returned from the endpoint. This is why we need to check for\n\t// two props whether is custom or has a theme file.\n\treturn (\n\t\t[ template.source, template.source ].includes(\n\t\t\tTEMPLATE_ORIGINS.custom\n\t\t) &&\n\t\t! Boolean( template.type === 'wp_template' && template?.plugin ) &&\n\t\t! template.has_theme_file\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,cAAc,QAAQ,0BAA0B;;AAEzD;AACA;AACA;;AAGA,OAAO,MAAMC,kBAAkB,GAAG,aAAa;AAC/C,OAAO,MAAMC,uBAAuB,GAAG,kBAAkB;AACzD,OAAO,MAAMC,gBAAgB,GAAG;EAC/BC,MAAM,EAAE,QAAQ;EAChBC,KAAK,EAAE,OAAO;EACdC,MAAM,EAAE;AACT,CAAC;AAED,OAAO,SAASC,UAAUA,CAAEC,IAAU,EAAqB;EAC1D,OAAOA,IAAI,CAACC,IAAI,KAAKR,kBAAkB;AACxC;AAEA,OAAO,SAASS,cAAcA,CAAEF,IAAU,EAAyB;EAClE,OAAOA,IAAI,CAACC,IAAI,KAAKP,uBAAuB;AAC7C;AAEA,OAAO,SAASS,wBAAwBA,CACvCC,CAAO,EACwB;EAC/B,OAAOA,CAAC,CAACH,IAAI,KAAKR,kBAAkB,IAAIW,CAAC,CAACH,IAAI,KAAKP,uBAAuB;AAC3E;AAEA,OAAO,SAASW,YAAYA,CAAEC,IAAU,EAAG;EAC1C,IAAK,OAAOA,IAAI,CAACC,KAAK,KAAK,QAAQ,EAAG;IACrC,OAAOf,cAAc,CAAEc,IAAI,CAACC,KAAM,CAAC;EACpC;EACA,IAAK,UAAU,IAAID,IAAI,CAACC,KAAK,EAAG;IAC/B,OAAOf,cAAc,CAAEc,IAAI,CAACC,KAAK,CAACC,QAAS,CAAC;EAC7C;EACA,IAAK,KAAK,IAAIF,IAAI,CAACC,KAAK,EAAG;IAC1B,OAAOf,cAAc,CAAEc,IAAI,CAACC,KAAK,CAACE,GAAI,CAAC;EACxC;EACA,OAAO,EAAE;AACV;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,mBAAmBA,CAAEC,QAAiC,EAAG;EACxE,IAAK,CAAEA,QAAQ,EAAG;IACjB,OAAO,KAAK;EACb;EACA;EACA;EACA;EACA,OACC,CAAEA,QAAQ,CAACC,MAAM,EAAED,QAAQ,CAACC,MAAM,CAAE,CAACC,QAAQ,CAC5ClB,gBAAgB,CAACC,MAClB,CAAC,IACD,CAAEkB,OAAO,CAAEH,QAAQ,CAACV,IAAI,KAAK,aAAa,IAAIU,QAAQ,EAAEb,MAAO,CAAC,IAChE,CAAEa,QAAQ,CAACI,cAAc;AAE3B","ignoreList":[]}
1
+ {"version":3,"names":["decodeEntities","TEMPLATE_POST_TYPE","TEMPLATE_PART_POST_TYPE","TEMPLATE_ORIGINS","custom","theme","plugin","isTemplate","post","type","isTemplatePart","isTemplateOrTemplatePart","p","getItemTitle","item","title","rendered","raw","isTemplateRemovable","template","source","includes","Boolean","has_theme_file"],"sources":["@wordpress/fields/src/actions/utils.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport type { Post, TemplatePart, Template } from '../types';\n\nexport const TEMPLATE_POST_TYPE = 'wp_template';\nexport const TEMPLATE_PART_POST_TYPE = 'wp_template_part';\nexport const TEMPLATE_ORIGINS = {\n\tcustom: 'custom',\n\ttheme: 'theme',\n\tplugin: 'plugin',\n};\n\nexport function isTemplate( post: Post ): post is Template {\n\treturn post.type === TEMPLATE_POST_TYPE;\n}\n\nexport function isTemplatePart( post: Post ): post is TemplatePart {\n\treturn post.type === TEMPLATE_PART_POST_TYPE;\n}\n\nexport function isTemplateOrTemplatePart(\n\tp: Post\n): p is Template | TemplatePart {\n\treturn p.type === TEMPLATE_POST_TYPE || p.type === TEMPLATE_PART_POST_TYPE;\n}\n\nexport function getItemTitle( item: Post ) {\n\tif ( typeof item.title === 'string' ) {\n\t\treturn decodeEntities( item.title );\n\t}\n\tif ( item.title && 'rendered' in item.title ) {\n\t\treturn decodeEntities( item.title.rendered );\n\t}\n\tif ( item.title && 'raw' in item.title ) {\n\t\treturn decodeEntities( item.title.raw );\n\t}\n\treturn '';\n}\n\n/**\n * Check if a template is removable.\n *\n * @param template The template entity to check.\n * @return Whether the template is removable.\n */\nexport function isTemplateRemovable( template: Template | TemplatePart ) {\n\tif ( ! template ) {\n\t\treturn false;\n\t}\n\t// In patterns list page we map the templates parts to a different object\n\t// than the one returned from the endpoint. This is why we need to check for\n\t// two props whether is custom or has a theme file.\n\treturn (\n\t\t[ template.source, template.source ].includes(\n\t\t\tTEMPLATE_ORIGINS.custom\n\t\t) &&\n\t\t! Boolean( template.type === 'wp_template' && template?.plugin ) &&\n\t\t! template.has_theme_file\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,cAAc,QAAQ,0BAA0B;;AAEzD;AACA;AACA;;AAGA,OAAO,MAAMC,kBAAkB,GAAG,aAAa;AAC/C,OAAO,MAAMC,uBAAuB,GAAG,kBAAkB;AACzD,OAAO,MAAMC,gBAAgB,GAAG;EAC/BC,MAAM,EAAE,QAAQ;EAChBC,KAAK,EAAE,OAAO;EACdC,MAAM,EAAE;AACT,CAAC;AAED,OAAO,SAASC,UAAUA,CAAEC,IAAU,EAAqB;EAC1D,OAAOA,IAAI,CAACC,IAAI,KAAKR,kBAAkB;AACxC;AAEA,OAAO,SAASS,cAAcA,CAAEF,IAAU,EAAyB;EAClE,OAAOA,IAAI,CAACC,IAAI,KAAKP,uBAAuB;AAC7C;AAEA,OAAO,SAASS,wBAAwBA,CACvCC,CAAO,EACwB;EAC/B,OAAOA,CAAC,CAACH,IAAI,KAAKR,kBAAkB,IAAIW,CAAC,CAACH,IAAI,KAAKP,uBAAuB;AAC3E;AAEA,OAAO,SAASW,YAAYA,CAAEC,IAAU,EAAG;EAC1C,IAAK,OAAOA,IAAI,CAACC,KAAK,KAAK,QAAQ,EAAG;IACrC,OAAOf,cAAc,CAAEc,IAAI,CAACC,KAAM,CAAC;EACpC;EACA,IAAKD,IAAI,CAACC,KAAK,IAAI,UAAU,IAAID,IAAI,CAACC,KAAK,EAAG;IAC7C,OAAOf,cAAc,CAAEc,IAAI,CAACC,KAAK,CAACC,QAAS,CAAC;EAC7C;EACA,IAAKF,IAAI,CAACC,KAAK,IAAI,KAAK,IAAID,IAAI,CAACC,KAAK,EAAG;IACxC,OAAOf,cAAc,CAAEc,IAAI,CAACC,KAAK,CAACE,GAAI,CAAC;EACxC;EACA,OAAO,EAAE;AACV;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,mBAAmBA,CAAEC,QAAiC,EAAG;EACxE,IAAK,CAAEA,QAAQ,EAAG;IACjB,OAAO,KAAK;EACb;EACA;EACA;EACA;EACA,OACC,CAAEA,QAAQ,CAACC,MAAM,EAAED,QAAQ,CAACC,MAAM,CAAE,CAACC,QAAQ,CAC5ClB,gBAAgB,CAACC,MAClB,CAAC,IACD,CAAEkB,OAAO,CAAEH,QAAQ,CAACV,IAAI,KAAK,aAAa,IAAIU,QAAQ,EAAEb,MAAO,CAAC,IAChE,CAAEa,QAAQ,CAACI,cAAc;AAE3B","ignoreList":[]}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+
5
+ import { __ } from '@wordpress/i18n';
6
+
7
+ /**
8
+ * Internal dependencies
9
+ */
10
+
11
+ const commentStatusField = {
12
+ id: 'comment_status',
13
+ label: __('Discussion'),
14
+ type: 'text',
15
+ Edit: 'radio',
16
+ enableSorting: false,
17
+ filterBy: {
18
+ operators: []
19
+ },
20
+ elements: [{
21
+ value: 'open',
22
+ label: __('Open'),
23
+ description: __('Visitors can add new comments and replies.')
24
+ }, {
25
+ value: 'closed',
26
+ label: __('Closed'),
27
+ description: __('Visitors cannot add new comments or replies. Existing comments remain visible.')
28
+ }]
29
+ };
30
+
31
+ /**
32
+ * Comment status field for BasePost.
33
+ */
34
+ export default commentStatusField;
35
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["__","commentStatusField","id","label","type","Edit","enableSorting","filterBy","operators","elements","value","description"],"sources":["@wordpress/fields/src/fields/comment-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';\n\nconst commentStatusField: Field< BasePost > = {\n\tid: 'comment_status',\n\tlabel: __( 'Discussion' ),\n\ttype: 'text',\n\tEdit: 'radio',\n\tenableSorting: false,\n\tfilterBy: {\n\t\toperators: [],\n\t},\n\telements: [\n\t\t{\n\t\t\tvalue: 'open',\n\t\t\tlabel: __( 'Open' ),\n\t\t\tdescription: __( 'Visitors can add new comments and replies.' ),\n\t\t},\n\t\t{\n\t\t\tvalue: 'closed',\n\t\t\tlabel: __( 'Closed' ),\n\t\t\tdescription: __(\n\t\t\t\t'Visitors cannot add new comments or replies. Existing comments remain visible.'\n\t\t\t),\n\t\t},\n\t],\n};\n\n/**\n * Comment status field for BasePost.\n */\nexport default commentStatusField;\n"],"mappings":"AAAA;AACA;AACA;;AAEA,SAASA,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;;AAGA,MAAMC,kBAAqC,GAAG;EAC7CC,EAAE,EAAE,gBAAgB;EACpBC,KAAK,EAAEH,EAAE,CAAE,YAAa,CAAC;EACzBI,IAAI,EAAE,MAAM;EACZC,IAAI,EAAE,OAAO;EACbC,aAAa,EAAE,KAAK;EACpBC,QAAQ,EAAE;IACTC,SAAS,EAAE;EACZ,CAAC;EACDC,QAAQ,EAAE,CACT;IACCC,KAAK,EAAE,MAAM;IACbP,KAAK,EAAEH,EAAE,CAAE,MAAO,CAAC;IACnBW,WAAW,EAAEX,EAAE,CAAE,4CAA6C;EAC/D,CAAC,EACD;IACCU,KAAK,EAAE,QAAQ;IACfP,KAAK,EAAEH,EAAE,CAAE,QAAS,CAAC;IACrBW,WAAW,EAAEX,EAAE,CACd,gFACD;EACD,CAAC;AAEH,CAAC;;AAED;AACA;AACA;AACA,eAAeC,kBAAkB","ignoreList":[]}
@@ -0,0 +1,62 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { __, sprintf } from '@wordpress/i18n';
5
+ import { createInterpolateElement } from '@wordpress/element';
6
+ import { dateI18n, getDate, getSettings } from '@wordpress/date';
7
+
8
+ /**
9
+ * Internal dependencies
10
+ */
11
+ import { jsx as _jsx } from "react/jsx-runtime";
12
+ const getFormattedDate = dateToDisplay => dateI18n(getSettings().formats.datetimeAbbreviated, getDate(dateToDisplay));
13
+ const DateView = ({
14
+ item
15
+ }) => {
16
+ var _item$status, _item$modified, _item$date4, _item$date5;
17
+ const isDraftOrPrivate = ['draft', 'private'].includes((_item$status = item.status) !== null && _item$status !== void 0 ? _item$status : '');
18
+ if (isDraftOrPrivate) {
19
+ var _item$date;
20
+ return createInterpolateElement(sprintf(/* translators: %s: page creation or modification date. */
21
+ __('<span>Modified: <time>%s</time></span>'), getFormattedDate((_item$date = item.date) !== null && _item$date !== void 0 ? _item$date : null)), {
22
+ span: /*#__PURE__*/_jsx("span", {}),
23
+ time: /*#__PURE__*/_jsx("time", {})
24
+ });
25
+ }
26
+ const isScheduled = item.status === 'future';
27
+ if (isScheduled) {
28
+ var _item$date2;
29
+ return createInterpolateElement(sprintf(/* translators: %s: page creation date */
30
+ __('<span>Scheduled: <time>%s</time></span>'), getFormattedDate((_item$date2 = item.date) !== null && _item$date2 !== void 0 ? _item$date2 : null)), {
31
+ span: /*#__PURE__*/_jsx("span", {}),
32
+ time: /*#__PURE__*/_jsx("time", {})
33
+ });
34
+ }
35
+ const isPublished = item.status === 'publish';
36
+ if (isPublished) {
37
+ var _item$date3;
38
+ return createInterpolateElement(sprintf(/* translators: %s: page creation time */
39
+ __('<span>Published: <time>%s</time></span>'), getFormattedDate((_item$date3 = item.date) !== null && _item$date3 !== void 0 ? _item$date3 : null)), {
40
+ span: /*#__PURE__*/_jsx("span", {}),
41
+ time: /*#__PURE__*/_jsx("time", {})
42
+ });
43
+ }
44
+
45
+ // Pending posts show the modified date if it's newer.
46
+ const dateToDisplay = getDate((_item$modified = item.modified) !== null && _item$modified !== void 0 ? _item$modified : null) > getDate((_item$date4 = item.date) !== null && _item$date4 !== void 0 ? _item$date4 : null) ? item.modified : item.date;
47
+ const isPending = item.status === 'pending';
48
+ if (isPending) {
49
+ return createInterpolateElement(sprintf(/* translators: %s: page creation or modification date. */
50
+ __('<span>Modified: <time>%s</time></span>'), getFormattedDate(dateToDisplay !== null && dateToDisplay !== void 0 ? dateToDisplay : null)), {
51
+ span: /*#__PURE__*/_jsx("span", {}),
52
+ time: /*#__PURE__*/_jsx("time", {})
53
+ });
54
+ }
55
+
56
+ // Unknow status.
57
+ return /*#__PURE__*/_jsx("time", {
58
+ children: getFormattedDate((_item$date5 = item.date) !== null && _item$date5 !== void 0 ? _item$date5 : null)
59
+ });
60
+ };
61
+ export default DateView;
62
+ //# sourceMappingURL=date-view.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["__","sprintf","createInterpolateElement","dateI18n","getDate","getSettings","jsx","_jsx","getFormattedDate","dateToDisplay","formats","datetimeAbbreviated","DateView","item","_item$status","_item$modified","_item$date4","_item$date5","isDraftOrPrivate","includes","status","_item$date","date","span","time","isScheduled","_item$date2","isPublished","_item$date3","modified","isPending","children"],"sources":["@wordpress/fields/src/fields/date/date-view.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { createInterpolateElement } from '@wordpress/element';\nimport { dateI18n, getDate, getSettings } from '@wordpress/date';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\n\nconst getFormattedDate = ( dateToDisplay: string | null ) =>\n\tdateI18n(\n\t\tgetSettings().formats.datetimeAbbreviated,\n\t\tgetDate( dateToDisplay )\n\t);\n\nconst DateView = ( { item }: { item: BasePost } ) => {\n\tconst isDraftOrPrivate = [ 'draft', 'private' ].includes(\n\t\titem.status ?? ''\n\t);\n\tif ( isDraftOrPrivate ) {\n\t\treturn createInterpolateElement(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %s: page creation or modification date. */\n\t\t\t\t__( '<span>Modified: <time>%s</time></span>' ),\n\t\t\t\tgetFormattedDate( item.date ?? null )\n\t\t\t),\n\t\t\t{\n\t\t\t\tspan: <span />,\n\t\t\t\ttime: <time />,\n\t\t\t}\n\t\t);\n\t}\n\n\tconst isScheduled = item.status === 'future';\n\tif ( isScheduled ) {\n\t\treturn createInterpolateElement(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %s: page creation date */\n\t\t\t\t__( '<span>Scheduled: <time>%s</time></span>' ),\n\t\t\t\tgetFormattedDate( item.date ?? null )\n\t\t\t),\n\t\t\t{\n\t\t\t\tspan: <span />,\n\t\t\t\ttime: <time />,\n\t\t\t}\n\t\t);\n\t}\n\n\tconst isPublished = item.status === 'publish';\n\tif ( isPublished ) {\n\t\treturn createInterpolateElement(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %s: page creation time */\n\t\t\t\t__( '<span>Published: <time>%s</time></span>' ),\n\t\t\t\tgetFormattedDate( item.date ?? null )\n\t\t\t),\n\t\t\t{\n\t\t\t\tspan: <span />,\n\t\t\t\ttime: <time />,\n\t\t\t}\n\t\t);\n\t}\n\n\t// Pending posts show the modified date if it's newer.\n\tconst dateToDisplay =\n\t\tgetDate( item.modified ?? null ) > getDate( item.date ?? null )\n\t\t\t? item.modified\n\t\t\t: item.date;\n\n\tconst isPending = item.status === 'pending';\n\tif ( isPending ) {\n\t\treturn createInterpolateElement(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %s: page creation or modification date. */\n\t\t\t\t__( '<span>Modified: <time>%s</time></span>' ),\n\t\t\t\tgetFormattedDate( dateToDisplay ?? null )\n\t\t\t),\n\t\t\t{\n\t\t\t\tspan: <span />,\n\t\t\t\ttime: <time />,\n\t\t\t}\n\t\t);\n\t}\n\n\t// Unknow status.\n\treturn <time>{ getFormattedDate( item.date ?? null ) }</time>;\n};\n\nexport default DateView;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,wBAAwB,QAAQ,oBAAoB;AAC7D,SAASC,QAAQ,EAAEC,OAAO,EAAEC,WAAW,QAAQ,iBAAiB;;AAEhE;AACA;AACA;AAFA,SAAAC,GAAA,IAAAC,IAAA;AAKA,MAAMC,gBAAgB,GAAKC,aAA4B,IACtDN,QAAQ,CACPE,WAAW,CAAC,CAAC,CAACK,OAAO,CAACC,mBAAmB,EACzCP,OAAO,CAAEK,aAAc,CACxB,CAAC;AAEF,MAAMG,QAAQ,GAAGA,CAAE;EAAEC;AAAyB,CAAC,KAAM;EAAA,IAAAC,YAAA,EAAAC,cAAA,EAAAC,WAAA,EAAAC,WAAA;EACpD,MAAMC,gBAAgB,GAAG,CAAE,OAAO,EAAE,SAAS,CAAE,CAACC,QAAQ,EAAAL,YAAA,GACvDD,IAAI,CAACO,MAAM,cAAAN,YAAA,cAAAA,YAAA,GAAI,EAChB,CAAC;EACD,IAAKI,gBAAgB,EAAG;IAAA,IAAAG,UAAA;IACvB,OAAOnB,wBAAwB,CAC9BD,OAAO,CACN;IACAD,EAAE,CAAE,wCAAyC,CAAC,EAC9CQ,gBAAgB,EAAAa,UAAA,GAAER,IAAI,CAACS,IAAI,cAAAD,UAAA,cAAAA,UAAA,GAAI,IAAK,CACrC,CAAC,EACD;MACCE,IAAI,eAAEhB,IAAA,WAAO,CAAC;MACdiB,IAAI,eAAEjB,IAAA,WAAO;IACd,CACD,CAAC;EACF;EAEA,MAAMkB,WAAW,GAAGZ,IAAI,CAACO,MAAM,KAAK,QAA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;MACCc,IAAI,eAAEhB,IAAA,WAAO,CAAC;MACdiB,IAAI,eAAEjB,IAAA,WAAO;IACd,CACD,CAAC;EACF;;EAEA;EACA,oBAAOA,IAAA;IAAAwB,QAAA,EAAQvB,gBAAgB,EAAAS,WAAA,GAAEJ,IAAI,CAACS,IAAI,cAAAL,WAAA,cAAAA,WAAA,GAAI,IAAK;EAAC,CAAQ,CAAC;AAC9D,CAAC;AAED,eAAeL,QAAQ","ignoreList":[]}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+
5
+ import { __ } from '@wordpress/i18n';
6
+
7
+ /**
8
+ * Internal dependencies
9
+ */
10
+
11
+ import DateView from './date-view';
12
+ const dateField = {
13
+ id: 'date',
14
+ type: 'datetime',
15
+ label: __('Date'),
16
+ render: DateView
17
+ };
18
+
19
+ /**
20
+ * Date field for BasePost.
21
+ */
22
+ export default dateField;
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["__","DateView","dateField","id","type","label","render"],"sources":["@wordpress/fields/src/fields/date/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 DateView from './date-view';\n\nconst dateField: Field< BasePost > = {\n\tid: 'date',\n\ttype: 'datetime',\n\tlabel: __( 'Date' ),\n\trender: DateView,\n};\n\n/**\n * Date field for BasePost.\n */\nexport default dateField;\n"],"mappings":"AAAA;AACA;AACA;;AAEA,SAASA,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;;AAEA,OAAOC,QAAQ,MAAM,aAAa;AAElC,MAAMC,SAA4B,GAAG;EACpCC,EAAE,EAAE,MAAM;EACVC,IAAI,EAAE,UAAU;EAChBC,KAAK,EAAEL,EAAE,CAAE,MAAO,CAAC;EACnBM,MAAM,EAAEL;AACT,CAAC;;AAED;AACA;AACA;AACA,eAAeC,SAAS","ignoreList":[]}
@@ -8,12 +8,11 @@ import { useCallback, useRef } from '@wordpress/element';
8
8
  import { MediaUpload } from '@wordpress/media-utils';
9
9
  import { lineSolid } from '@wordpress/icons';
10
10
  import { store as coreStore } from '@wordpress/core-data';
11
+ import { __ } from '@wordpress/i18n';
11
12
 
12
13
  /**
13
14
  * Internal dependencies
14
15
  */
15
-
16
- import { __ } from '@wordpress/i18n';
17
16
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
18
17
  export const FeaturedImageEdit = ({
19
18
  data,
@@ -1 +1 @@
1
- {"version":3,"names":["Button","__experimentalGrid","Grid","useSelect","useCallback","useRef","MediaUpload","lineSolid","store","coreStore","__","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","FeaturedImageEdit","data","field","onChange","id","value","getValue","item","media","select","getEntityRecord","onChangeControl","newValue","url","source_url","title","rendered","ref","className","children","onSelect","selectedMedia","allowedTypes","render","open","role","tabIndex","onClick","onKeyDown","rowGap","columnGap","templateColumns","alt","width","height","src","style","size","icon","event","stopPropagation"],"sources":["@wordpress/fields/src/fields/featured-image/featured-image-edit.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Button, __experimentalGrid as Grid } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { useCallback, useRef } from '@wordpress/element';\n// @ts-ignore\nimport { MediaUpload } from '@wordpress/media-utils';\nimport { lineSolid } from '@wordpress/icons';\nimport { store as coreStore } from '@wordpress/core-data';\nimport type { DataFormControlProps } from '@wordpress/dataviews';\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\nimport { __ } from '@wordpress/i18n';\n\nexport const FeaturedImageEdit = ( {\n\tdata,\n\tfield,\n\tonChange,\n}: DataFormControlProps< BasePost > ) => {\n\tconst { id } = field;\n\n\tconst value = field.getValue( { item: data } );\n\n\tconst media = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecord } = select( coreStore );\n\t\t\treturn getEntityRecord( 'root', 'media', value );\n\t\t},\n\t\t[ value ]\n\t);\n\n\tconst onChangeControl = useCallback(\n\t\t( newValue: number ) =>\n\t\t\tonChange( {\n\t\t\t\t[ id ]: newValue,\n\t\t\t} ),\n\t\t[ id, onChange ]\n\t);\n\n\tconst url = media?.source_url;\n\tconst title = media?.title?.rendered;\n\tconst ref = useRef( null );\n\n\treturn (\n\t\t<fieldset className=\"fields-controls__featured-image\">\n\t\t\t<div className=\"fields-controls__featured-image-container\">\n\t\t\t\t<MediaUpload\n\t\t\t\t\tonSelect={ ( selectedMedia: { id: number } ) => {\n\t\t\t\t\t\tonChangeControl( selectedMedia.id );\n\t\t\t\t\t} }\n\t\t\t\t\tallowedTypes={ [ 'image' ] }\n\t\t\t\t\trender={ ( { open }: { open: () => void } ) => {\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\t\trole=\"button\"\n\t\t\t\t\t\t\t\ttabIndex={ -1 }\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\topen();\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tonKeyDown={ open }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<Grid\n\t\t\t\t\t\t\t\t\trowGap={ 0 }\n\t\t\t\t\t\t\t\t\tcolumnGap={ 8 }\n\t\t\t\t\t\t\t\t\ttemplateColumns=\"24px 1fr 24px\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ url && (\n\t\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t\t<img\n\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"fields-controls__featured-image-image\"\n\t\t\t\t\t\t\t\t\t\t\t\talt=\"\"\n\t\t\t\t\t\t\t\t\t\t\t\twidth={ 24 }\n\t\t\t\t\t\t\t\t\t\t\t\theight={ 24 }\n\t\t\t\t\t\t\t\t\t\t\t\tsrc={ url }\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t<span className=\"fields-controls__featured-image-title\">\n\t\t\t\t\t\t\t\t\t\t\t\t{ title }\n\t\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t{ ! url && (\n\t\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"fields-controls__featured-image-placeholder\"\n\t\t\t\t\t\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\t\t\t\t\t\twidth: '24px',\n\t\t\t\t\t\t\t\t\t\t\t\t\theight: '24px',\n\t\t\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t<span className=\"fields-controls__featured-image-title\">\n\t\t\t\t\t\t\t\t\t\t\t\t{ __( 'Choose an image…' ) }\n\t\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t{ url && (\n\t\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"fields-controls__featured-image-remove-button\"\n\t\t\t\t\t\t\t\t\t\t\t\ticon={ lineSolid }\n\t\t\t\t\t\t\t\t\t\t\t\tonClick={ (\n\t\t\t\t\t\t\t\t\t\t\t\t\tevent: React.MouseEvent< HTMLButtonElement >\n\t\t\t\t\t\t\t\t\t\t\t\t) => {\n\t\t\t\t\t\t\t\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\t\t\t\t\t\t\t\tonChangeControl( 0 );\n\t\t\t\t\t\t\t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AA,gBACCxB,IAAA;kBACCuB,SAAS,EAAC,6CAA6C;kBACvDkB,KAAK,EAAG;oBACPH,KAAK,EAAE,MAAM;oBACbC,MAAM,EAAE;kBACT;gBAAG,CACH,CAAC,eACFvC,IAAA;kBAAMuB,SAAS,EAAC,uCAAuC;kBAAAC,QAAA,EACpD1B,EAAE,CAAE,kBAAmB;gBAAC,CACrB,CAAC;cAAA,CACN,CACF,EACCoB,GAAG,iBACJlB,IAAA,CAAAE,SAAA;gBAAAsB,QAAA,eACCxB,IAAA,CAACZ,MAAM;kBACNsD,IAAI,EAAC,OAAO;kBACZnB,SAAS,EAAC,+CAA+C;kBACzDoB,IAAI,EAAGhD,SAAW;kBAClBqC,OAAO,EACNY,KAA4C,IACxC;oBACJA,KAAK,CAACC,eAAe,CAAC,CAAC;oBACvB7B,eAAe,CAAE,CAAE,CAAC;kBACrB;gBAAG,CACH;cAAC,CACD,CACF;YAAA,CACI;UAAC,CACH,CAAC;QAER;MAAG,CACH;IAAC,CACE;EAAC,CACG,CAAC;AAEb,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["Button","__experimentalGrid","Grid","useSelect","useCallback","useRef","MediaUpload","lineSolid","store","coreStore","__","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","FeaturedImageEdit","data","field","onChange","id","value","getValue","item","media","select","getEntityRecord","onChangeControl","newValue","url","source_url","title","rendered","ref","className","children","onSelect","selectedMedia","allowedTypes","render","open","role","tabIndex","onClick","onKeyDown","rowGap","columnGap","templateColumns","alt","width","height","src","style","size","icon","event","stopPropagation"],"sources":["@wordpress/fields/src/fields/featured-image/featured-image-edit.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Button, __experimentalGrid as Grid } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { useCallback, useRef } from '@wordpress/element';\n// @ts-ignore\nimport { MediaUpload } from '@wordpress/media-utils';\nimport { lineSolid } from '@wordpress/icons';\nimport { store as coreStore } from '@wordpress/core-data';\nimport type { DataFormControlProps } from '@wordpress/dataviews';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\n\nexport const FeaturedImageEdit = ( {\n\tdata,\n\tfield,\n\tonChange,\n}: DataFormControlProps< BasePost > ) => {\n\tconst { id } = field;\n\n\tconst value = field.getValue( { item: data } );\n\n\tconst media = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecord } = select( coreStore );\n\t\t\treturn getEntityRecord( 'root', 'media', value );\n\t\t},\n\t\t[ value ]\n\t);\n\n\tconst onChangeControl = useCallback(\n\t\t( newValue: number ) =>\n\t\t\tonChange( {\n\t\t\t\t[ id ]: newValue,\n\t\t\t} ),\n\t\t[ id, onChange ]\n\t);\n\n\tconst url = media?.source_url;\n\tconst title = media?.title?.rendered;\n\tconst ref = useRef( null );\n\n\treturn (\n\t\t<fieldset className=\"fields-controls__featured-image\">\n\t\t\t<div className=\"fields-controls__featured-image-container\">\n\t\t\t\t<MediaUpload\n\t\t\t\t\tonSelect={ ( selectedMedia: { id: number } ) => {\n\t\t\t\t\t\tonChangeControl( selectedMedia.id );\n\t\t\t\t\t} }\n\t\t\t\t\tallowedTypes={ [ 'image' ] }\n\t\t\t\t\trender={ ( { open }: { open: () => void } ) => {\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\t\trole=\"button\"\n\t\t\t\t\t\t\t\ttabIndex={ -1 }\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\topen();\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tonKeyDown={ open }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<Grid\n\t\t\t\t\t\t\t\t\trowGap={ 0 }\n\t\t\t\t\t\t\t\t\tcolumnGap={ 8 }\n\t\t\t\t\t\t\t\t\ttemplateColumns=\"24px 1fr 24px\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ url && (\n\t\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t\t<img\n\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"fields-controls__featured-image-image\"\n\t\t\t\t\t\t\t\t\t\t\t\talt=\"\"\n\t\t\t\t\t\t\t\t\t\t\t\twidth={ 24 }\n\t\t\t\t\t\t\t\t\t\t\t\theight={ 24 }\n\t\t\t\t\t\t\t\t\t\t\t\tsrc={ url }\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t<span className=\"fields-controls__featured-image-title\">\n\t\t\t\t\t\t\t\t\t\t\t\t{ title }\n\t\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t{ ! url && (\n\t\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"fields-controls__featured-image-placeholder\"\n\t\t\t\t\t\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\t\t\t\t\t\twidth: '24px',\n\t\t\t\t\t\t\t\t\t\t\t\t\theight: '24px',\n\t\t\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t\t<span className=\"fields-controls__featured-image-title\">\n\t\t\t\t\t\t\t\t\t\t\t\t{ __( 'Choose an image…' ) }\n\t\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t{ url && (\n\t\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"fields-controls__featured-image-remove-button\"\n\t\t\t\t\t\t\t\t\t\t\t\ticon={ lineSolid }\n\t\t\t\t\t\t\t\t\t\t\t\tonClick={ (\n\t\t\t\t\t\t\t\t\t\t\t\t\tevent: React.MouseEvent< HTMLButtonElement >\n\t\t\t\t\t\t\t\t\t\t\t\t) => {\n\t\t\t\t\t\t\t\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\t\t\t\t\t\t\t\tonChangeControl( 0 );\n\t\t\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</Grid>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t);\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</fieldset>\n\t);\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,MAAM,EAAEC,kBAAkB,IAAIC,IAAI,QAAQ,uBAAuB;AAC1E,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,WAAW,EAAEC,MAAM,QAAQ,oBAAoB;AACxD;AACA,SAASC,WAAW,QAAQ,wBAAwB;AACpD,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AAEzD,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AAFA,SAAAC,GAAA,IAAAC,IAAA,EAAAC,QAAA,IAAAC,SAAA,EAAAC,IAAA,IAAAC,KAAA;AAKA,OAAO,MAAMC,iBAAiB,GAAGA,CAAE;EAClCC,IAAI;EACJC,KAAK;EACLC;AACiC,CAAC,KAAM;EACxC,MAAM;IAAEC;EAAG,CAAC,GAAGF,KAAK;EAEpB,MAAMG,KAAK,GAAGH,KAAK,CAACI,QAAQ,CAAE;IAAEC,IAAI,EAAEN;EAAK,CAAE,CAAC;EAE9C,MAAMO,KAAK,GAAGtB,SAAS,CACpBuB,M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AAS,EAAC,uCAAuC;kBACjDc,GAAG,EAAC,EAAE;kBACNC,KAAK,EAAG,EAAI;kBACZC,MAAM,EAAG,EAAI;kBACbC,GAAG,EAAGtB;gBAAK,CACX,CAAC,eACFlB,IAAA;kBAAMuB,SAAS,EAAC,uCAAuC;kBAAAC,QAAA,EACpDJ;gBAAK,CACF,CAAC;cAAA,CACN,CACF,EACC,CAAEF,GAAG,iBACNd,KAAA,CAAAF,SAAA;gBAAAsB,QAAA,gBACCxB,IAAA;kBACCuB,SAAS,EAAC,6CAA6C;kBACvDkB,KAAK,EAAG;oBACPH,KAAK,EAAE,MAAM;oBACbC,MAAM,EAAE;kBACT;gBAAG,CACH,CAAC,eACFvC,IAAA;kBAAMuB,SAAS,EAAC,uCAAuC;kBAAAC,QAAA,EACpD1B,EAAE,CAAE,kBAAmB;gBAAC,CACrB,CAAC;cAAA,CACN,CACF,EACCoB,GAAG,iBACJlB,IAAA,CAAAE,SAAA;gBAAAsB,QAAA,eACCxB,IAAA,CAACZ,MAAM;kBACNsD,IAAI,EAAC,OAAO;kBACZnB,SAAS,EAAC,+CAA+C;kBACzDoB,IAAI,EAAGhD,SAAW;kBAClBqC,OAAO,EACNY,KAA4C,IACxC;oBACJA,KAAK,CAACC,eAAe,CAAC,CAAC;oBACvB7B,eAAe,CAAE,CAAE,CAAC;kBACrB;gBAAG,CACH;cAAC,CACD,CACF;YAAA,CACI;UAAC,CACH,CAAC;QAER;MAAG,CACH;IAAC,CACE;EAAC,CACG,CAAC;AAEb,CAAC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["useSelect","store","coreStore","jsx","_jsx","FeaturedImageView","item","mediaId","featured_media","media","select","getEntityRecord","url","source_url","className","src","alt"],"sources":["@wordpress/fields/src/fields/featured-image/featured-image-view.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\nimport type { DataViewRenderFieldProps } from '@wordpress/dataviews';\n\nexport const FeaturedImageView = ( {\n\titem,\n}: DataViewRenderFieldProps< BasePost > ) => {\n\tconst mediaId = item.featured_media;\n\n\tconst media = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecord } = select( coreStore );\n\t\t\treturn mediaId ? getEntityRecord( 'root', 'media', mediaId ) : null;\n\t\t},\n\t\t[ mediaId ]\n\t);\n\tconst url = media?.source_url;\n\n\tif ( url ) {\n\t\treturn (\n\t\t\t<img\n\t\t\t\tclassName=\"fields-controls__featured-image-image\"\n\t\t\t\tsrc={ url }\n\t\t\t\talt=\"\"\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn <span className=\"fields-controls__featured-image-placeholder\" />;\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;;AAEzD;AACA;AACA;AAFA,SAAAC,GAAA,IAAAC,IAAA;AAMA,OAAO,MAAMC,iBAAiB,GAAGA,CAAE;EAClCC;AACqC,CAAC,KAAM;EAC5C,MAAMC,OAAO,GAAGD,IAAI,CAACE,cAAc;EAEnC,MAAMC,KAAK,GAAGT,SAAS,CACpBU,MAAM,IAAM;IACb,MAAM;MAAEC;IAAgB,CAAC,GAAGD,MAAM,CAAER,SAAU,CAAC;IAC/C,OAAOK,OAAO,GAAGI,eAAe,CAAE,MAAM,EAAE,OAAO,EAAEJ,OAAQ,CAAC,GAAG,IAAI;EACpE,CAAC,EACD,CAAEA,OAAO,CACV,CAAC;EACD,MAAMK,GAAG,GAAGH,KAAK,EAAEI,UAAU;EAE7B,IAAKD,GAAG,EAAG;IACV,oBACCR,IAAA;MACCU,SAAS,EAAC,uCAAuC;MACjDC,GAAG,EAAGH,GAAK;MACXI,GAAG,EAAC;IAAE,CACN,CAAC;EAEJ;EAEA,oBAAOZ,IAAA;IAAMU,SAAS,EAAC;EAA6C,CAAE,CAAC;AACxE,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["useSelect","store","coreStore","jsx","_jsx","FeaturedImageView","item","mediaId","featured_media","media","select","getEntityRecord","url","source_url","className","src","alt"],"sources":["@wordpress/fields/src/fields/featured-image/featured-image-view.tsx"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport type { DataViewRenderFieldProps } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\n\nexport const FeaturedImageView = ( {\n\titem,\n}: DataViewRenderFieldProps< BasePost > ) => {\n\tconst mediaId = item.featured_media;\n\n\tconst media = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecord } = select( coreStore );\n\t\t\treturn mediaId ? getEntityRecord( 'root', 'media', mediaId ) : null;\n\t\t},\n\t\t[ mediaId ]\n\t);\n\tconst url = media?.source_url;\n\n\tif ( url ) {\n\t\treturn (\n\t\t\t<img\n\t\t\t\tclassName=\"fields-controls__featured-image-image\"\n\t\t\t\tsrc={ url }\n\t\t\t\talt=\"\"\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn <span className=\"fields-controls__featured-image-placeholder\" />;\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;;AAGzD;AACA;AACA;AAFA,SAAAC,GAAA,IAAAC,IAAA;AAKA,OAAO,MAAMC,iBAAiB,GAAGA,CAAE;EAClCC;AACqC,CAAC,KAAM;EAC5C,MAAMC,OAAO,GAAGD,IAAI,CAACE,cAAc;EAEnC,MAAMC,KAAK,GAAGT,SAAS,CACpBU,MAAM,IAAM;IACb,MAAM;MAAEC;IAAgB,CAAC,GAAGD,MAAM,CAAER,SAAU,CAAC;IAC/C,OAAOK,OAAO,GAAGI,eAAe,CAAE,MAAM,EAAE,OAAO,EAAEJ,OAAQ,CAAC,GAAG,IAAI;EACpE,CAAC,EACD,CAAEA,OAAO,CACV,CAAC;EACD,MAAMK,GAAG,GAAGH,KAAK,EAAEI,UAAU;EAE7B,IAAKD,GAAG,EAAG;IACV,oBACCR,IAAA;MACCU,SAAS,EAAC,uCAAuC;MACjDC,GAAG,EAAGH,GAAK;MACXI,GAAG,EAAC;IAAE,CACN,CAAC;EAEJ;EAEA,oBAAOZ,IAAA;IAAMU,SAAS,EAAC;EAA6C,CAAE,CAAC;AACxE,CAAC","ignoreList":[]}
@@ -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 { FeaturedImageEdit } from './featured-image-edit';
11
12
  import { FeaturedImageView } from './featured-image-view';
12
13
  const featuredImageField = {
13
14
  id: 'featured_media',
14
15
  type: 'text',
15
16
  label: __('Featured Image'),
16
- getValue: ({
17
- item
18
- }) => item.featured_media,
19
17
  Edit: FeaturedImageEdit,
20
18
  render: FeaturedImageView,
21
19
  enableSorting: false
@@ -1 +1 @@
1
- {"version":3,"names":["__","FeaturedImageEdit","FeaturedImageView","featuredImageField","id","type","label","getValue","item","featured_media","Edit","render","enableSorting"],"sources":["@wordpress/fields/src/fields/featured-image/index.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport type { Field } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\nimport { __ } from '@wordpress/i18n';\nimport { FeaturedImageEdit } from './featured-image-edit';\nimport { FeaturedImageView } from './featured-image-view';\n\nconst featuredImageField: Field< BasePost > = {\n\tid: 'featured_media',\n\ttype: 'text',\n\tlabel: __( 'Featured Image' ),\n\tgetValue: ( { item } ) => item.featured_media,\n\tEdit: FeaturedImageEdit,\n\trender: FeaturedImageView,\n\tenableSorting: false,\n};\n\nexport default featuredImageField;\n"],"mappings":"AAAA;AACA;AACA;;AAGA;AACA;AACA;;AAEA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,iBAAiB,QAAQ,uBAAuB;AACzD,SAASC,iBAAiB,QAAQ,uBAAuB;AAEzD,MAAMC,kBAAqC,GAAG;EAC7CC,EAAE,EAAE,gBAAgB;EACpBC,IAAI,EAAE,MAAM;EACZC,KAAK,EAAEN,EAAE,CAAE,gBAAiB,CAAC;EAC7BO,QAAQ,EAAEA,CAAE;IAAEC;EAAK,CAAC,KAAMA,IAAI,CAACC,cAAc;EAC7CC,IAAI,EAAET,iBAAiB;EACvBU,MAAM,EAAET,iBAAiB;EACzBU,aAAa,EAAE;AAChB,CAAC;AAED,eAAeT,kBAAkB","ignoreList":[]}
1
+ {"version":3,"names":["__","FeaturedImageEdit","FeaturedImageView","featuredImageField","id","type","label","Edit","render","enableSorting"],"sources":["@wordpress/fields/src/fields/featured-image/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 { FeaturedImageEdit } from './featured-image-edit';\nimport { FeaturedImageView } from './featured-image-view';\n\nconst featuredImageField: Field< BasePost > = {\n\tid: 'featured_media',\n\ttype: 'text',\n\tlabel: __( 'Featured Image' ),\n\tEdit: FeaturedImageEdit,\n\trender: FeaturedImageView,\n\tenableSorting: false,\n};\n\nexport default featuredImageField;\n"],"mappings":"AAAA;AACA;AACA;;AAEA,SAASA,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;;AAEA,SAASC,iBAAiB,QAAQ,uBAAuB;AACzD,SAASC,iBAAiB,QAAQ,uBAAuB;AAEzD,MAAMC,kBAAqC,GAAG;EAC7CC,EAAE,EAAE,gBAAgB;EACpBC,IAAI,EAAE,MAAM;EACZC,KAAK,EAAEN,EAAE,CAAE,gBAAiB,CAAC;EAC7BO,IAAI,EAAEN,iBAAiB;EACvBO,MAAM,EAAEN,iBAAiB;EACzBO,aAAa,EAAE;AAChB,CAAC;AAED,eAAeN,kBAAkB","ignoreList":[]}
@@ -3,4 +3,8 @@ export { default as titleField } from './title';
3
3
  export { default as orderField } from './order';
4
4
  export { default as featuredImageField } from './featured-image';
5
5
  export { default as parentField } from './parent';
6
+ export { default as passwordField } from './password';
7
+ export { default as statusField } from './status';
8
+ export { default as commentStatusField } from './comment-status';
9
+ export { default as dateField } from './date';
6
10
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["default","slugField","titleField","orderField","featuredImageField","parentField"],"sources":["@wordpress/fields/src/fields/index.ts"],"sourcesContent":["export { default as slugField } from './slug';\nexport { default as titleField } from './title';\nexport { default as orderField } from './order';\nexport { default as featuredImageField } from './featured-image';\nexport { default as parentField } from './parent';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,SAAS,QAAQ,QAAQ;AAC7C,SAASD,OAAO,IAAIE,UAAU,QAAQ,SAAS;AAC/C,SAASF,OAAO,IAAIG,UAAU,QAAQ,SAAS;AAC/C,SAASH,OAAO,IAAII,kBAAkB,QAAQ,kBAAkB;AAChE,SAASJ,OAAO,IAAIK,WAAW,QAAQ,UAAU","ignoreList":[]}
1
+ {"version":3,"names":["default","slugField","titleField","orderField","featuredImageField","parentField","passwordField","statusField","commentStatusField","dateField"],"sources":["@wordpress/fields/src/fields/index.ts"],"sourcesContent":["export { default as slugField } from './slug';\nexport { default as titleField } from './title';\nexport { default as orderField } from './order';\nexport { default as featuredImageField } from './featured-image';\nexport { default as parentField } from './parent';\nexport { default as passwordField } from './password';\nexport { default as statusField } from './status';\nexport { default as commentStatusField } from './comment-status';\nexport { default as dateField } from './date';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,SAAS,QAAQ,QAAQ;AAC7C,SAASD,OAAO,IAAIE,UAAU,QAAQ,SAAS;AAC/C,SAASF,OAAO,IAAIG,UAAU,QAAQ,SAAS;AAC/C,SAASH,OAAO,IAAII,kBAAkB,QAAQ,kBAAkB;AAChE,SAASJ,OAAO,IAAIK,WAAW,QAAQ,UAAU;AACjD,SAASL,OAAO,IAAIM,aAAa,QAAQ,YAAY;AACrD,SAASN,OAAO,IAAIO,WAAW,QAAQ,UAAU;AACjD,SAASP,OAAO,IAAIQ,kBAAkB,QAAQ,kBAAkB;AAChE,SAASR,OAAO,IAAIS,SAAS,QAAQ,QAAQ","ignoreList":[]}
@@ -3,13 +3,14 @@
3
3
  */
4
4
 
5
5
  import { __ } from '@wordpress/i18n';
6
+
6
7
  /**
7
8
  * Internal dependencies
8
9
  */
9
10
 
10
11
  const orderField = {
11
- type: 'integer',
12
12
  id: 'menu_order',
13
+ type: 'integer',
13
14
  label: __('Order'),
14
15
  description: __('Determines the order of pages.')
15
16
  };
@@ -1 +1 @@
1
- {"version":3,"names":["__","orderField","type","id","label","description"],"sources":["@wordpress/fields/src/fields/order/index.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport type { Field } from '@wordpress/dataviews';\nimport { __ } from '@wordpress/i18n';\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\n\nconst orderField: Field< BasePost > = {\n\ttype: 'integer',\n\tid: 'menu_order',\n\tlabel: __( 'Order' ),\n\tdescription: __( 'Determines the order of pages.' ),\n};\n\nexport default orderField;\n"],"mappings":"AAAA;AACA;AACA;;AAEA,SAASA,EAAE,QAAQ,iBAAiB;AACpC;AACA;AACA;;AAGA,MAAMC,UAA6B,GAAG;EACrCC,IAAI,EAAE,SAAS;EACfC,EAAE,EAAE,YAAY;EAChBC,KAAK,EAAEJ,EAAE,CAAE,OAAQ,CAAC;EACpBK,WAAW,EAAEL,EAAE,CAAE,gCAAiC;AACnD,CAAC;AAED,eAAeC,UAAU","ignoreList":[]}
1
+ {"version":3,"names":["__","orderField","id","type","label","description"],"sources":["@wordpress/fields/src/fields/order/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';\n\nconst orderField: Field< BasePost > = {\n\tid: 'menu_order',\n\ttype: 'integer',\n\tlabel: __( 'Order' ),\n\tdescription: __( 'Determines the order of pages.' ),\n};\n\nexport default orderField;\n"],"mappings":"AAAA;AACA;AACA;;AAEA,SAASA,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;;AAGA,MAAMC,UAA6B,GAAG;EACrCC,EAAE,EAAE,YAAY;EAChBC,IAAI,EAAE,SAAS;EACfC,KAAK,EAAEJ,EAAE,CAAE,OAAQ,CAAC;EACpBK,WAAW,EAAEL,EAAE,CAAE,gCAAiC;AACnD,CAAC;AAED,eAAeC,UAAU","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 { ParentEdit } from './parent-edit';
11
12
  import { ParentView } from './parent-view';
12
13
  const parentField = {
13
14
  id: 'parent',
14
15
  type: 'text',
15
16
  label: __('Parent'),
16
- getValue: ({
17
- item
18
- }) => item.parent,
19
17
  Edit: ParentEdit,
20
18
  render: ParentView,
21
19
  enableSorting: true
@@ -1 +1 @@
1
- {"version":3,"names":["__","ParentEdit","ParentView","parentField","id","type","label","getValue","item","parent","Edit","render","enableSorting"],"sources":["@wordpress/fields/src/fields/parent/index.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport type { Field } from '@wordpress/dataviews';\n\n/**\n * Internal dependencies\n */\nimport type { BasePost } from '../../types';\nimport { __ } from '@wordpress/i18n';\nimport { ParentEdit } from './parent-edit';\nimport { ParentView } from './parent-view';\n\nconst parentField: Field< BasePost > = {\n\tid: 'parent',\n\ttype: 'text',\n\tlabel: __( 'Parent' ),\n\tgetValue: ( { item } ) => item.parent,\n\tEdit: ParentEdit,\n\trender: ParentView,\n\tenableSorting: true,\n};\n\n/**\n * This field is used to display the post parent.\n */\nexport default parentField;\n"],"mappings":"AAAA;AACA;AACA;;AAGA;AACA;AACA;;AAEA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,UAAU,QAAQ,eAAe;AAC1C,SAASC,UAAU,QAAQ,eAAe;AAE1C,MAAMC,WAA8B,GAAG;EACtCC,EAAE,EAAE,QAAQ;EACZC,IAAI,EAAE,MAAM;EACZC,KAAK,EAAEN,EAAE,CAAE,QAAS,CAAC;EACrBO,QAAQ,EAAEA,CAAE;IAAEC;EAAK,CAAC,KAAMA,IAAI,CAACC,MAAM;EACrCC,IAAI,EAAET,UAAU;EAChBU,MAAM,EAAET,UAAU;EAClBU,aAAa,EAAE;AAChB,CAAC;;AAED;AACA;AACA;AACA,eAAeT,WAAW","ignoreList":[]}
1
+ {"version":3,"names":["__","ParentEdit","ParentView","parentField","id","type","label","Edit","render","enableSorting"],"sources":["@wordpress/fields/src/fields/parent/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 { ParentEdit } from './parent-edit';\nimport { ParentView } from './parent-view';\n\nconst parentField: Field< BasePost > = {\n\tid: 'parent',\n\ttype: 'text',\n\tlabel: __( 'Parent' ),\n\tEdit: ParentEdit,\n\trender: ParentView,\n\tenableSorting: true,\n};\n\n/**\n * This field is used to display the post parent.\n */\nexport default parentField;\n"],"mappings":"AAAA;AACA;AACA;;AAEA,SAASA,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;;AAEA,SAASC,UAAU,QAAQ,eAAe;AAC1C,SAASC,UAAU,QAAQ,eAAe;AAE1C,MAAMC,WAA8B,GAAG;EACtCC,EAAE,EAAE,QAAQ;EACZC,IAAI,EAAE,MAAM;EACZC,KAAK,EAAEN,EAAE,CAAE,QAAS,CAAC;EACrBO,IAAI,EAAEN,UAAU;EAChBO,MAAM,EAAEN,UAAU;EAClBO,aAAa,EAAE;AAChB,CAAC;;AAED;AACA;AACA;AACA,eAAeN,WAAW","ignoreList":[]}
@@ -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,wBA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AAC,EAAE,EAAG,CAAC;EAEP,MAAMpE,eAAe,GAAG3C,WAAW,CAChCgH,QAAiB,IAClBN,QAAQ,CAAE;IACT,CAAE3E,EAAE,GAAIiF;EACT,CAAE,CAAC,EACJ,CAAEjF,EAAE,EAAE2E,QAAQ,CACf,CAAC;EAED,oBACC7F,IAAA;IAAUoG,SAAS,EAAC,yBAAyB;IAAA5F,QAAA,eAC5CN,KAAA;MAAAM,QAAA,GACGtB,wBAAwB,CACzBU,OAAO,CACN;MACAD,EAAE,CACD,0LACD,CAAC,EACDG,mBAAmB,CAAEmG,OAAQ,CAAC,CAACI,OAAO,CACrC,SAAS,EACT,WACD,CACD,CAAC,EACD;QACCC,GAAG,eAAEtG,IAAA,UAAM;MACZ,CACD,CAAC,eACDA,IAAA;QAAAQ,QAAA,EACGtB,wBAAwB,CACzBS,EAAE,CACD,mFACD,CAAC,EACD;UACC0E,CAAC,eACArE,IAAA,CAAChB,YAAY;YACZuH,IAAI,EAAG5G,EAAE,CACR,yFACD,CAAG;YACHa,QAAQ,EAAGG;UAAW,CACtB;QAEH,CACD;MAAC,CACC,CAAC,eACJX,IAAA,CAAC4B,oBAAoB;QACpBC,IAAI,EAAGA,IAAM;QACbC,eAAe,EAAGA;MAAiB,CACnC,CAAC;IAAA,CACE;EAAC,CACG,CAAC;AAEb,CAAC","ignoreList":[]}
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,gBA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tC,CAAC,EAAE,EAAG,CAAC;EAEP,MAAMpE,eAAe,GAAG1C,WAAW,CAChC+G,QAAiB,IAClBN,QAAQ,CAAE;IACT,CAAE3E,EAAE,GAAIiF;EACT,CAAE,CAAC,EACJ,CAAEjF,EAAE,EAAE2E,QAAQ,CACf,CAAC;EAED,oBACC7F,IAAA;IAAUoG,SAAS,EAAC,yBAAyB;IAAA5F,QAAA,eAC5CN,KAAA;MAAAM,QAAA,GACGrB,wBAAwB,CACzBS,OAAO,CACN;MACAD,EAAE,CACD,0LACD,CAAC,EACDE,mBAAmB,CAAEoG,OAAQ,CAAC,CAACI,OAAO,CACrC,SAAS,EACT,WACD,CACD,CAAC,EACD;QACCC,GAAG,eAAEtG,IAAA,UAAM;MACZ,CACD,CAAC,eACDA,IAAA;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\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tmaxLength={ 255 }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</VStack>\n\t);\n}\nexport default PasswordEdit;\n"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,eAAe,EACfC,oBAAoB,IAAIC,MAAM,EAC9BC,WAAW,QACL,uBAAuB;AAE9B,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AAFA,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAKA,SAASC,YAAYA,CAAE;EACtBC,IAAI;EACJC,QAAQ;EACRC;AACiC,CAAC,EAAG;EACrC,MAAM,CAAEC,YAAY,EAAEC,eAAe,CAAE,GAAGX,QAAQ,CACjD,CAAC,CAAES,KAAK,CAACG,QAAQ,CAAE;IAAEC,IAAI,EAAEN;EAAK,CAAE,CACnC,CAAC;EAED,MAAMO,oBAAoB,GAAKC,KAAc,IAAM;IAClDJ,eAAe,CAAEI,KAAM,CAAC;IACxB,IAAK,CAAEA,KAAK,EAAG;MACdP,QAAQ,CAAE;QAAEQ,QAAQ,EAAE;MAAG,CAAE,CAAC;IAC7B;EACD,CAAC;EAED,oBACCX,KAAA,CAACP,MAAM;IACNmB,EAAE,EAAC,UAAU;IACbC,OAAO,EAAG,CAAG;IACbC,SAAS,EAAC,2BAA2B;IAAAC,QAAA,gBAErCjB,IAAA,CAACP,eAAe;MACfyB,uBAAuB;MACvBC,KAAK,EAAGrB,EAAE,CAAE,oBAAqB,CAAG;MACpCsB,IAAI,EAAGtB,EAAE,CAAE,6CAA8C,CAAG;MAC5DuB,OAAO,EAAGd,YAAc;MACxBF,QAAQ,EAAGM;IAAsB,CACjC,CAAC,EACAJ,YAAY,iBACbP,IAAA;MAAKgB,SAAS,EAAC,iCAAiC;MAAAC,QAAA,eAC/CjB,IAAA,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":[]}