@wordpress/block-library 9.30.1-next.836ecdcae.0 → 9.31.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.
- package/CHANGELOG.md +2 -0
- package/build/button/edit.js +6 -1
- package/build/button/edit.js.map +1 -1
- package/build/button/edit.native.js +1 -1
- package/build/button/edit.native.js.map +1 -1
- package/build/buttons/index.js +2 -1
- package/build/buttons/index.js.map +1 -1
- package/build/categories/edit.js +3 -1
- package/build/categories/edit.js.map +1 -1
- package/build/image/edit.native.js +1 -1
- package/build/image/edit.native.js.map +1 -1
- package/build/image/image.js +5 -8
- package/build/image/image.js.map +1 -1
- package/build/image/save.js +6 -2
- package/build/image/save.js.map +1 -1
- package/build/index.js +4 -0
- package/build/index.js.map +1 -1
- package/build/navigation/edit/index.js +0 -1
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation-link/block-inserter.js +69 -0
- package/build/navigation-link/block-inserter.js.map +1 -0
- package/build/navigation-link/dialog-wrapper.js +80 -0
- package/build/navigation-link/dialog-wrapper.js.map +1 -0
- package/build/navigation-link/link-ui.js +34 -82
- package/build/navigation-link/link-ui.js.map +1 -1
- package/build/navigation-link/page-creator.js +12 -18
- package/build/navigation-link/page-creator.js.map +1 -1
- package/build/post-date/edit.js +2 -1
- package/build/post-date/edit.js.map +1 -1
- package/build/post-featured-image/edit.js +7 -2
- package/build/post-featured-image/edit.js.map +1 -1
- package/build/post-title/edit.js +8 -2
- package/build/post-title/edit.js.map +1 -1
- package/build/query/edit/pattern-selection.js +9 -1
- package/build/query/edit/pattern-selection.js.map +1 -1
- package/build/query/index.js +2 -1
- package/build/query/index.js.map +1 -1
- package/build/rss/edit.js +6 -1
- package/build/rss/edit.js.map +1 -1
- package/build/site-tagline/index.js +1 -0
- package/build/site-tagline/index.js.map +1 -1
- package/build/social-link/edit.js +6 -1
- package/build/social-link/edit.js.map +1 -1
- package/build/social-links/index.js +2 -1
- package/build/social-links/index.js.map +1 -1
- package/build/spacer/edit.js +2 -1
- package/build/spacer/edit.js.map +1 -1
- package/build/table-of-contents/edit.js +33 -9
- package/build/table-of-contents/edit.js.map +1 -1
- package/build/table-of-contents/index.js +4 -0
- package/build/table-of-contents/index.js.map +1 -1
- package/build/table-of-contents/list.js +6 -3
- package/build/table-of-contents/list.js.map +1 -1
- package/build/table-of-contents/save.js +6 -3
- package/build/table-of-contents/save.js.map +1 -1
- package/build/term-template/edit.js +318 -0
- package/build/term-template/edit.js.map +1 -0
- package/build/term-template/index.js +109 -0
- package/build/term-template/index.js.map +1 -0
- package/build/term-template/save.js +16 -0
- package/build/term-template/save.js.map +1 -0
- package/build/term-template/variations.js +83 -0
- package/build/term-template/variations.js.map +1 -0
- package/build/terms-query/edit.js +20 -0
- package/build/terms-query/edit.js.map +1 -0
- package/build/terms-query/index.js +83 -0
- package/build/terms-query/index.js.map +1 -0
- package/build/terms-query/inspector-controls.js +231 -0
- package/build/terms-query/inspector-controls.js.map +1 -0
- package/build/terms-query/save.js +24 -0
- package/build/terms-query/save.js.map +1 -0
- package/build/terms-query/terms-query-content.js +71 -0
- package/build/terms-query/terms-query-content.js.map +1 -0
- package/build/utils/hooks.js +3 -0
- package/build/utils/hooks.js.map +1 -1
- package/build-module/button/edit.js +7 -2
- package/build-module/button/edit.js.map +1 -1
- package/build-module/button/edit.native.js +1 -1
- package/build-module/button/edit.native.js.map +1 -1
- package/build-module/buttons/index.js +2 -1
- package/build-module/buttons/index.js.map +1 -1
- package/build-module/categories/edit.js +3 -1
- package/build-module/categories/edit.js.map +1 -1
- package/build-module/image/edit.native.js +1 -1
- package/build-module/image/edit.native.js.map +1 -1
- package/build-module/image/image.js +5 -8
- package/build-module/image/image.js.map +1 -1
- package/build-module/image/save.js +6 -2
- package/build-module/image/save.js.map +1 -1
- package/build-module/index.js +4 -0
- package/build-module/index.js.map +1 -1
- package/build-module/navigation/edit/index.js +0 -1
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation-link/block-inserter.js +61 -0
- package/build-module/navigation-link/block-inserter.js.map +1 -0
- package/build-module/navigation-link/dialog-wrapper.js +75 -0
- package/build-module/navigation-link/dialog-wrapper.js.map +1 -0
- package/build-module/navigation-link/link-ui.js +37 -85
- package/build-module/navigation-link/link-ui.js.map +1 -1
- package/build-module/navigation-link/page-creator.js +12 -19
- package/build-module/navigation-link/page-creator.js.map +1 -1
- package/build-module/post-date/edit.js +3 -2
- package/build-module/post-date/edit.js.map +1 -1
- package/build-module/post-featured-image/edit.js +9 -4
- package/build-module/post-featured-image/edit.js.map +1 -1
- package/build-module/post-title/edit.js +9 -3
- package/build-module/post-title/edit.js.map +1 -1
- package/build-module/query/edit/pattern-selection.js +9 -1
- package/build-module/query/edit/pattern-selection.js.map +1 -1
- package/build-module/query/index.js +2 -1
- package/build-module/query/index.js.map +1 -1
- package/build-module/rss/edit.js +8 -3
- package/build-module/rss/edit.js.map +1 -1
- package/build-module/site-tagline/index.js +1 -0
- package/build-module/site-tagline/index.js.map +1 -1
- package/build-module/social-link/edit.js +8 -3
- package/build-module/social-link/edit.js.map +1 -1
- package/build-module/social-links/index.js +2 -1
- package/build-module/social-links/index.js.map +1 -1
- package/build-module/spacer/edit.js +3 -2
- package/build-module/spacer/edit.js.map +1 -1
- package/build-module/table-of-contents/edit.js +35 -11
- package/build-module/table-of-contents/edit.js.map +1 -1
- package/build-module/table-of-contents/index.js +4 -0
- package/build-module/table-of-contents/index.js.map +1 -1
- package/build-module/table-of-contents/list.js +6 -3
- package/build-module/table-of-contents/list.js.map +1 -1
- package/build-module/table-of-contents/save.js +6 -3
- package/build-module/table-of-contents/save.js.map +1 -1
- package/build-module/term-template/edit.js +310 -0
- package/build-module/term-template/edit.js.map +1 -0
- package/build-module/term-template/index.js +102 -0
- package/build-module/term-template/index.js.map +1 -0
- package/build-module/term-template/save.js +9 -0
- package/build-module/term-template/save.js.map +1 -0
- package/build-module/term-template/variations.js +76 -0
- package/build-module/term-template/variations.js.map +1 -0
- package/build-module/terms-query/edit.js +12 -0
- package/build-module/terms-query/edit.js.map +1 -0
- package/build-module/terms-query/index.js +76 -0
- package/build-module/terms-query/index.js.map +1 -0
- package/build-module/terms-query/inspector-controls.js +224 -0
- package/build-module/terms-query/inspector-controls.js.map +1 -0
- package/build-module/terms-query/save.js +17 -0
- package/build-module/terms-query/save.js.map +1 -0
- package/build-module/terms-query/terms-query-content.js +63 -0
- package/build-module/terms-query/terms-query-content.js.map +1 -0
- package/build-module/utils/hooks.js +3 -0
- package/build-module/utils/hooks.js.map +1 -1
- package/build-style/editor-rtl.css +24 -0
- package/build-style/editor.css +24 -0
- package/build-style/style-rtl.css +16 -0
- package/build-style/style.css +16 -0
- package/build-style/term-template/editor-rtl.css +160 -0
- package/build-style/term-template/editor.css +160 -0
- package/build-style/term-template/style-rtl.css +146 -0
- package/build-style/term-template/style.css +146 -0
- package/build-style/terms-query/style-rtl.css +140 -0
- package/build-style/terms-query/style.css +140 -0
- package/build-types/table-of-contents/list.d.ts +2 -1
- package/build-types/table-of-contents/list.d.ts.map +1 -1
- package/package.json +35 -35
- package/src/button/edit.js +12 -1
- package/src/button/edit.native.js +1 -1
- package/src/buttons/block.json +2 -1
- package/src/categories/edit.js +2 -1
- package/src/editor.scss +1 -0
- package/src/image/edit.native.js +1 -1
- package/src/image/image.js +5 -8
- package/src/image/save.js +7 -1
- package/src/index.js +4 -0
- package/src/navigation/edit/index.js +0 -1
- package/src/navigation-link/block-inserter.js +65 -0
- package/src/navigation-link/dialog-wrapper.js +74 -0
- package/src/navigation-link/link-ui.js +32 -95
- package/src/navigation-link/page-creator.js +13 -20
- package/src/post-date/edit.js +64 -53
- package/src/post-date/index.php +5 -13
- package/src/post-featured-image/edit.js +19 -3
- package/src/post-title/edit.js +14 -2
- package/src/query/block.json +2 -1
- package/src/query/edit/pattern-selection.js +10 -1
- package/src/rss/edit.js +13 -2
- package/src/site-tagline/block.json +1 -0
- package/src/social-link/edit.js +13 -2
- package/src/social-links/block.json +2 -1
- package/src/spacer/edit.js +5 -1
- package/src/style.scss +2 -0
- package/src/table-of-contents/block.json +4 -0
- package/src/table-of-contents/edit.js +58 -21
- package/src/table-of-contents/list.tsx +7 -2
- package/src/table-of-contents/save.js +7 -3
- package/src/term-template/block.json +73 -0
- package/src/term-template/edit.js +391 -0
- package/src/term-template/editor.scss +26 -0
- package/src/term-template/index.js +26 -0
- package/src/term-template/index.php +224 -0
- package/src/term-template/save.js +8 -0
- package/src/term-template/style.scss +12 -0
- package/src/term-template/variations.js +87 -0
- package/src/terms-query/block.json +49 -0
- package/src/terms-query/edit.js +10 -0
- package/src/terms-query/index.js +24 -0
- package/src/terms-query/index.php +44 -0
- package/src/terms-query/inspector-controls.js +239 -0
- package/src/terms-query/save.js +10 -0
- package/src/terms-query/style.scss +6 -0
- package/src/terms-query/terms-query-content.js +74 -0
- package/src/utils/hooks.js +4 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
@@ -11,11 +12,10 @@ var _i18n = require("@wordpress/i18n");
|
|
|
11
12
|
var _blockEditor = require("@wordpress/block-editor");
|
|
12
13
|
var _element = require("@wordpress/element");
|
|
13
14
|
var _coreData = require("@wordpress/core-data");
|
|
14
|
-
var _data = require("@wordpress/data");
|
|
15
15
|
var _icons = require("@wordpress/icons");
|
|
16
16
|
var _compose = require("@wordpress/compose");
|
|
17
|
-
var _lockUnlock = require("../lock-unlock");
|
|
18
17
|
var _pageCreator = require("./page-creator");
|
|
18
|
+
var _blockInserter = _interopRequireDefault(require("./block-inserter"));
|
|
19
19
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
20
20
|
/**
|
|
21
21
|
* WordPress dependencies
|
|
@@ -25,10 +25,6 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
25
25
|
* Internal dependencies
|
|
26
26
|
*/
|
|
27
27
|
|
|
28
|
-
const {
|
|
29
|
-
PrivateQuickInserter: QuickInserter
|
|
30
|
-
} = (0, _lockUnlock.unlock)(_blockEditor.privateApis);
|
|
31
|
-
|
|
32
28
|
/**
|
|
33
29
|
* Given the Link block's type attribute, return the query params to give to
|
|
34
30
|
* /wp/v2/search.
|
|
@@ -83,61 +79,6 @@ function getSuggestionsQuery(type, kind) {
|
|
|
83
79
|
};
|
|
84
80
|
}
|
|
85
81
|
}
|
|
86
|
-
function LinkUIBlockInserter({
|
|
87
|
-
clientId,
|
|
88
|
-
onBack,
|
|
89
|
-
onBlockInsert
|
|
90
|
-
}) {
|
|
91
|
-
const {
|
|
92
|
-
rootBlockClientId
|
|
93
|
-
} = (0, _data.useSelect)(select => {
|
|
94
|
-
const {
|
|
95
|
-
getBlockRootClientId
|
|
96
|
-
} = select(_blockEditor.store);
|
|
97
|
-
return {
|
|
98
|
-
rootBlockClientId: getBlockRootClientId(clientId)
|
|
99
|
-
};
|
|
100
|
-
}, [clientId]);
|
|
101
|
-
const focusOnMountRef = (0, _compose.useFocusOnMount)('firstElement');
|
|
102
|
-
const dialogTitleId = (0, _compose.useInstanceId)(_blockEditor.LinkControl, `link-ui-block-inserter__title`);
|
|
103
|
-
const dialogDescriptionId = (0, _compose.useInstanceId)(_blockEditor.LinkControl, `link-ui-block-inserter__description`);
|
|
104
|
-
if (!clientId) {
|
|
105
|
-
return null;
|
|
106
|
-
}
|
|
107
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
108
|
-
className: "link-ui-block-inserter",
|
|
109
|
-
role: "dialog",
|
|
110
|
-
"aria-labelledby": dialogTitleId,
|
|
111
|
-
"aria-describedby": dialogDescriptionId,
|
|
112
|
-
ref: focusOnMountRef,
|
|
113
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.VisuallyHidden, {
|
|
114
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("h2", {
|
|
115
|
-
id: dialogTitleId,
|
|
116
|
-
children: (0, _i18n.__)('Add block')
|
|
117
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
|
|
118
|
-
id: dialogDescriptionId,
|
|
119
|
-
children: (0, _i18n.__)('Choose a block to add to your Navigation.')
|
|
120
|
-
})]
|
|
121
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
|
|
122
|
-
className: "link-ui-block-inserter__back",
|
|
123
|
-
icon: (0, _i18n.isRTL)() ? _icons.chevronRightSmall : _icons.chevronLeftSmall,
|
|
124
|
-
onClick: e => {
|
|
125
|
-
e.preventDefault();
|
|
126
|
-
onBack();
|
|
127
|
-
},
|
|
128
|
-
size: "small",
|
|
129
|
-
children: (0, _i18n.__)('Back')
|
|
130
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(QuickInserter, {
|
|
131
|
-
rootClientId: rootBlockClientId,
|
|
132
|
-
clientId: clientId,
|
|
133
|
-
isAppender: false,
|
|
134
|
-
prioritizePatterns: false,
|
|
135
|
-
selectBlockOnInsert: !onBlockInsert,
|
|
136
|
-
onSelect: onBlockInsert ? onBlockInsert : undefined,
|
|
137
|
-
hasSearch: false
|
|
138
|
-
})]
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
82
|
function UnforwardedLinkUI(props, ref) {
|
|
142
83
|
const {
|
|
143
84
|
label,
|
|
@@ -169,8 +110,8 @@ function UnforwardedLinkUI(props, ref) {
|
|
|
169
110
|
// Return to main Link UI
|
|
170
111
|
setAddingPage(false);
|
|
171
112
|
};
|
|
172
|
-
const dialogTitleId = (0, _compose.useInstanceId)(LinkUI,
|
|
173
|
-
const dialogDescriptionId = (0, _compose.useInstanceId)(LinkUI,
|
|
113
|
+
const dialogTitleId = (0, _compose.useInstanceId)(LinkUI, 'link-ui-link-control__title');
|
|
114
|
+
const dialogDescriptionId = (0, _compose.useInstanceId)(LinkUI, 'link-ui-link-control__description');
|
|
174
115
|
const blockEditingMode = (0, _blockEditor.useBlockEditingMode)();
|
|
175
116
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.Popover, {
|
|
176
117
|
ref: ref,
|
|
@@ -202,22 +143,28 @@ function UnforwardedLinkUI(props, ref) {
|
|
|
202
143
|
onChange: props.onChange,
|
|
203
144
|
onRemove: props.onRemove,
|
|
204
145
|
onCancel: props.onCancel,
|
|
205
|
-
renderControlBottom: () =>
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
146
|
+
renderControlBottom: () => {
|
|
147
|
+
// Don't show the tools when there is submitted link (preview state).
|
|
148
|
+
if (link?.url?.length) {
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(LinkUITools, {
|
|
152
|
+
focusAddBlockButton: focusAddBlockButton,
|
|
153
|
+
focusAddPageButton: focusAddPageButton,
|
|
154
|
+
setAddingBlock: () => {
|
|
155
|
+
setAddingBlock(true);
|
|
156
|
+
setFocusAddBlockButton(false);
|
|
157
|
+
},
|
|
158
|
+
setAddingPage: () => {
|
|
159
|
+
setAddingPage(true);
|
|
160
|
+
setFocusAddPageButton(false);
|
|
161
|
+
},
|
|
162
|
+
canAddPage: permissions?.canCreate && type === 'page',
|
|
163
|
+
canAddBlock: blockEditingMode === 'default'
|
|
164
|
+
});
|
|
165
|
+
}
|
|
219
166
|
})]
|
|
220
|
-
}), addingBlock && /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
167
|
+
}), addingBlock && /*#__PURE__*/(0, _jsxRuntime.jsx)(_blockInserter.default, {
|
|
221
168
|
clientId: props.clientId,
|
|
222
169
|
onBack: () => {
|
|
223
170
|
setAddingBlock(false);
|
|
@@ -243,8 +190,8 @@ const LinkUITools = ({
|
|
|
243
190
|
setAddingPage,
|
|
244
191
|
focusAddBlockButton,
|
|
245
192
|
focusAddPageButton,
|
|
246
|
-
|
|
247
|
-
|
|
193
|
+
canAddPage,
|
|
194
|
+
canAddBlock
|
|
248
195
|
}) => {
|
|
249
196
|
const blockInserterAriaRole = 'listbox';
|
|
250
197
|
const addBlockButtonRef = (0, _element.useRef)();
|
|
@@ -263,10 +210,15 @@ const LinkUITools = ({
|
|
|
263
210
|
addPageButtonRef.current?.focus();
|
|
264
211
|
}
|
|
265
212
|
}, [focusAddPageButton]);
|
|
213
|
+
|
|
214
|
+
// Don't render anything if neither button should be shown
|
|
215
|
+
if (!canAddPage && !canAddBlock) {
|
|
216
|
+
return null;
|
|
217
|
+
}
|
|
266
218
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalVStack, {
|
|
267
219
|
spacing: 0,
|
|
268
220
|
className: "link-ui-tools",
|
|
269
|
-
children: [
|
|
221
|
+
children: [canAddPage && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
|
|
270
222
|
__next40pxDefaultSize: true,
|
|
271
223
|
ref: addPageButtonRef,
|
|
272
224
|
icon: _icons.plus,
|
|
@@ -276,7 +228,7 @@ const LinkUITools = ({
|
|
|
276
228
|
},
|
|
277
229
|
"aria-haspopup": blockInserterAriaRole,
|
|
278
230
|
children: (0, _i18n.__)('Create page')
|
|
279
|
-
}),
|
|
231
|
+
}), canAddBlock && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
|
|
280
232
|
__next40pxDefaultSize: true,
|
|
281
233
|
ref: addBlockButtonRef,
|
|
282
234
|
icon: _icons.plus,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_dom","require","_components","_i18n","_blockEditor","_element","_coreData","_data","_icons","_compose","_lockUnlock","_pageCreator","_jsxRuntime","PrivateQuickInserter","QuickInserter","unlock","blockEditorPrivateApis","getSuggestionsQuery","type","kind","subtype","initialSuggestionsSearchOptions","perPage","LinkUIBlockInserter","clientId","onBack","onBlockInsert","rootBlockClientId","useSelect","select","getBlockRootClientId","blockEditorStore","focusOnMountRef","useFocusOnMount","dialogTitleId","useInstanceId","LinkControl","dialogDescriptionId","jsxs","className","role","ref","children","VisuallyHidden","jsx","id","__","Button","icon","isRTL","chevronRightSmall","chevronLeftSmall","onClick","e","preventDefault","size","rootClientId","isAppender","prioritizePatterns","selectBlockOnInsert","onSelect","undefined","hasSearch","UnforwardedLinkUI","props","label","url","opensInNewTab","link","postType","addingBlock","setAddingBlock","useState","addingPage","setAddingPage","focusAddBlockButton","setFocusAddBlockButton","focusAddPageButton","setFocusAddPageButton","permissions","useResourcePermissions","name","useMemo","title","stripHTML","handlePageCreated","pageLink","onChange","LinkUI","blockEditingMode","useBlockEditingMode","Popover","placement","onClose","anchor","shift","hasTextControl","hasRichPreviews","value","showInitialSuggestions","withCreateSuggestion","noDirectEntry","noURLSuggestion","suggestionsQuery","onRemove","onCancel","renderControlBottom","length","LinkUITools","canCreatePage","canCreate","LinkUIPageCreator","onPageCreated","initialTitle","exports","forwardRef","blockInserterAriaRole","addBlockButtonRef","useRef","addPageButtonRef","useEffect","current","focus","__experimentalVStack","spacing","__next40pxDefaultSize","plus","_default","default"],"sources":["@wordpress/block-library/src/navigation-link/link-ui.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\nimport {\n\tPopover,\n\tButton,\n\tVisuallyHidden,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { __, isRTL } from '@wordpress/i18n';\nimport {\n\tLinkControl,\n\tstore as blockEditorStore,\n\tprivateApis as blockEditorPrivateApis,\n\tuseBlockEditingMode,\n} from '@wordpress/block-editor';\nimport {\n\tuseMemo,\n\tuseState,\n\tuseRef,\n\tuseEffect,\n\tforwardRef,\n} from '@wordpress/element';\nimport { useResourcePermissions } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\nimport { chevronLeftSmall, chevronRightSmall, plus } from '@wordpress/icons';\nimport { useInstanceId, useFocusOnMount } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../lock-unlock';\nimport { LinkUIPageCreator } from './page-creator';\n\nconst { PrivateQuickInserter: QuickInserter } = unlock(\n\tblockEditorPrivateApis\n);\n\n/**\n * Given the Link block's type attribute, return the query params to give to\n * /wp/v2/search.\n *\n * @param {string} type Link block's type attribute.\n * @param {string} kind Link block's entity of kind (post-type|taxonomy)\n * @return {{ type?: string, subtype?: string }} Search query params.\n */\nexport function getSuggestionsQuery( type, kind ) {\n\tswitch ( type ) {\n\t\tcase 'post':\n\t\tcase 'page':\n\t\t\treturn { type: 'post', subtype: type };\n\t\tcase 'category':\n\t\t\treturn { type: 'term', subtype: 'category' };\n\t\tcase 'tag':\n\t\t\treturn { type: 'term', subtype: 'post_tag' };\n\t\tcase 'post_format':\n\t\t\treturn { type: 'post-format' };\n\t\tdefault:\n\t\t\tif ( kind === 'taxonomy' ) {\n\t\t\t\treturn { type: 'term', subtype: type };\n\t\t\t}\n\t\t\tif ( kind === 'post-type' ) {\n\t\t\t\treturn { type: 'post', subtype: type };\n\t\t\t}\n\t\t\treturn {\n\t\t\t\t// for custom link which has no type\n\t\t\t\t// always show pages as initial suggestions\n\t\t\t\tinitialSuggestionsSearchOptions: {\n\t\t\t\t\ttype: 'post',\n\t\t\t\t\tsubtype: 'page',\n\t\t\t\t\tperPage: 20,\n\t\t\t\t},\n\t\t\t};\n\t}\n}\n\nfunction LinkUIBlockInserter( { clientId, onBack, onBlockInsert } ) {\n\tconst { rootBlockClientId } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockRootClientId } = select( blockEditorStore );\n\n\t\t\treturn {\n\t\t\t\trootBlockClientId: getBlockRootClientId( clientId ),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst focusOnMountRef = useFocusOnMount( 'firstElement' );\n\n\tconst dialogTitleId = useInstanceId(\n\t\tLinkControl,\n\t\t`link-ui-block-inserter__title`\n\t);\n\tconst dialogDescriptionId = useInstanceId(\n\t\tLinkControl,\n\t\t`link-ui-block-inserter__description`\n\t);\n\n\tif ( ! clientId ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<div\n\t\t\tclassName=\"link-ui-block-inserter\"\n\t\t\trole=\"dialog\"\n\t\t\taria-labelledby={ dialogTitleId }\n\t\t\taria-describedby={ dialogDescriptionId }\n\t\t\tref={ focusOnMountRef }\n\t\t>\n\t\t\t<VisuallyHidden>\n\t\t\t\t<h2 id={ dialogTitleId }>{ __( 'Add block' ) }</h2>\n\n\t\t\t\t<p id={ dialogDescriptionId }>\n\t\t\t\t\t{ __( 'Choose a block to add to your Navigation.' ) }\n\t\t\t\t</p>\n\t\t\t</VisuallyHidden>\n\n\t\t\t<Button\n\t\t\t\tclassName=\"link-ui-block-inserter__back\"\n\t\t\t\ticon={ isRTL() ? chevronRightSmall : chevronLeftSmall }\n\t\t\t\tonClick={ ( e ) => {\n\t\t\t\t\te.preventDefault();\n\t\t\t\t\tonBack();\n\t\t\t\t} }\n\t\t\t\tsize=\"small\"\n\t\t\t>\n\t\t\t\t{ __( 'Back' ) }\n\t\t\t</Button>\n\n\t\t\t<QuickInserter\n\t\t\t\trootClientId={ rootBlockClientId }\n\t\t\t\tclientId={ clientId }\n\t\t\t\tisAppender={ false }\n\t\t\t\tprioritizePatterns={ false }\n\t\t\t\tselectBlockOnInsert={ ! onBlockInsert }\n\t\t\t\tonSelect={ onBlockInsert ? onBlockInsert : undefined }\n\t\t\t\thasSearch={ false }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\nfunction UnforwardedLinkUI( props, ref ) {\n\tconst { label, url, opensInNewTab, type, kind } = props.link;\n\tconst postType = type || 'page';\n\n\tconst [ addingBlock, setAddingBlock ] = useState( false );\n\tconst [ addingPage, setAddingPage ] = useState( false );\n\tconst [ focusAddBlockButton, setFocusAddBlockButton ] = useState( false );\n\tconst [ focusAddPageButton, setFocusAddPageButton ] = useState( false );\n\tconst permissions = useResourcePermissions( {\n\t\tkind: 'postType',\n\t\tname: postType,\n\t} );\n\n\t// Memoize link value to avoid overriding the LinkControl's internal state.\n\t// This is a temporary fix. See https://github.com/WordPress/gutenberg/issues/50976#issuecomment-1568226407.\n\tconst link = useMemo(\n\t\t() => ( {\n\t\t\turl,\n\t\t\topensInNewTab,\n\t\t\ttitle: label && stripHTML( label ),\n\t\t} ),\n\t\t[ label, opensInNewTab, url ]\n\t);\n\n\tconst handlePageCreated = ( pageLink ) => {\n\t\t// Set the new page as the current link\n\t\tprops.onChange( pageLink );\n\t\t// Return to main Link UI\n\t\tsetAddingPage( false );\n\t};\n\n\tconst dialogTitleId = useInstanceId(\n\t\tLinkUI,\n\t\t`link-ui-link-control__title`\n\t);\n\tconst dialogDescriptionId = useInstanceId(\n\t\tLinkUI,\n\t\t`link-ui-link-control__description`\n\t);\n\n\tconst blockEditingMode = useBlockEditingMode();\n\n\treturn (\n\t\t<Popover\n\t\t\tref={ ref }\n\t\t\tplacement=\"bottom\"\n\t\t\tonClose={ props.onClose }\n\t\t\tanchor={ props.anchor }\n\t\t\tshift\n\t\t>\n\t\t\t{ ! addingBlock && ! addingPage && (\n\t\t\t\t<div\n\t\t\t\t\trole=\"dialog\"\n\t\t\t\t\taria-labelledby={ dialogTitleId }\n\t\t\t\t\taria-describedby={ dialogDescriptionId }\n\t\t\t\t>\n\t\t\t\t\t<VisuallyHidden>\n\t\t\t\t\t\t<h2 id={ dialogTitleId }>{ __( 'Add link' ) }</h2>\n\n\t\t\t\t\t\t<p id={ dialogDescriptionId }>\n\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t'Search for and add a link to your Navigation.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</p>\n\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t<LinkControl\n\t\t\t\t\t\thasTextControl\n\t\t\t\t\t\thasRichPreviews\n\t\t\t\t\t\tvalue={ link }\n\t\t\t\t\t\tshowInitialSuggestions\n\t\t\t\t\t\twithCreateSuggestion={ false }\n\t\t\t\t\t\tnoDirectEntry={ !! type }\n\t\t\t\t\t\tnoURLSuggestion={ !! type }\n\t\t\t\t\t\tsuggestionsQuery={ getSuggestionsQuery( type, kind ) }\n\t\t\t\t\t\tonChange={ props.onChange }\n\t\t\t\t\t\tonRemove={ props.onRemove }\n\t\t\t\t\t\tonCancel={ props.onCancel }\n\t\t\t\t\t\trenderControlBottom={ () =>\n\t\t\t\t\t\t\t! link?.url?.length && (\n\t\t\t\t\t\t\t\t<LinkUITools\n\t\t\t\t\t\t\t\t\tfocusAddBlockButton={ focusAddBlockButton }\n\t\t\t\t\t\t\t\t\tfocusAddPageButton={ focusAddPageButton }\n\t\t\t\t\t\t\t\t\tsetAddingBlock={ () => {\n\t\t\t\t\t\t\t\t\t\tsetAddingBlock( true );\n\t\t\t\t\t\t\t\t\t\tsetFocusAddBlockButton( false );\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\tsetAddingPage={ () => {\n\t\t\t\t\t\t\t\t\t\tsetAddingPage( true );\n\t\t\t\t\t\t\t\t\t\tsetFocusAddPageButton( false );\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\tcanCreatePage={ permissions.canCreate }\n\t\t\t\t\t\t\t\t\tblockEditingMode={ blockEditingMode }\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</div>\n\t\t\t) }\n\n\t\t\t{ addingBlock && (\n\t\t\t\t<LinkUIBlockInserter\n\t\t\t\t\tclientId={ props.clientId }\n\t\t\t\t\tonBack={ () => {\n\t\t\t\t\t\tsetAddingBlock( false );\n\t\t\t\t\t\tsetFocusAddBlockButton( true );\n\t\t\t\t\t\tsetFocusAddPageButton( false );\n\t\t\t\t\t} }\n\t\t\t\t\tonBlockInsert={ props?.onBlockInsert }\n\t\t\t\t/>\n\t\t\t) }\n\n\t\t\t{ addingPage && (\n\t\t\t\t<LinkUIPageCreator\n\t\t\t\t\tpostType={ postType }\n\t\t\t\t\tonBack={ () => {\n\t\t\t\t\t\tsetAddingPage( false );\n\t\t\t\t\t\tsetFocusAddPageButton( true );\n\t\t\t\t\t\tsetFocusAddBlockButton( false );\n\t\t\t\t\t} }\n\t\t\t\t\tonPageCreated={ handlePageCreated }\n\t\t\t\t\tinitialTitle={ link?.url || '' }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</Popover>\n\t);\n}\n\nexport const LinkUI = forwardRef( UnforwardedLinkUI );\n\nconst LinkUITools = ( {\n\tsetAddingBlock,\n\tsetAddingPage,\n\tfocusAddBlockButton,\n\tfocusAddPageButton,\n\tcanCreatePage,\n\tblockEditingMode,\n} ) => {\n\tconst blockInserterAriaRole = 'listbox';\n\tconst addBlockButtonRef = useRef();\n\tconst addPageButtonRef = useRef();\n\n\t// Focus the add block button when the popover is opened.\n\tuseEffect( () => {\n\t\tif ( focusAddBlockButton ) {\n\t\t\taddBlockButtonRef.current?.focus();\n\t\t}\n\t}, [ focusAddBlockButton ] );\n\n\t// Focus the add page button when the popover is opened.\n\tuseEffect( () => {\n\t\tif ( focusAddPageButton ) {\n\t\t\taddPageButtonRef.current?.focus();\n\t\t}\n\t}, [ focusAddPageButton ] );\n\n\treturn (\n\t\t<VStack spacing={ 0 } className=\"link-ui-tools\">\n\t\t\t{ canCreatePage && (\n\t\t\t\t<Button\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tref={ addPageButtonRef }\n\t\t\t\t\ticon={ plus }\n\t\t\t\t\tonClick={ ( e ) => {\n\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\tsetAddingPage( true );\n\t\t\t\t\t} }\n\t\t\t\t\taria-haspopup={ blockInserterAriaRole }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Create page' ) }\n\t\t\t\t</Button>\n\t\t\t) }\n\t\t\t{ blockEditingMode === 'default' && (\n\t\t\t\t<Button\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tref={ addBlockButtonRef }\n\t\t\t\t\ticon={ plus }\n\t\t\t\t\tonClick={ ( e ) => {\n\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\tsetAddingBlock( true );\n\t\t\t\t\t} }\n\t\t\t\t\taria-haspopup={ blockInserterAriaRole }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Add block' ) }\n\t\t\t\t</Button>\n\t\t\t) }\n\t\t</VStack>\n\t);\n};\n\nexport default LinkUITools;\n"],"mappings":";;;;;;;AAGA,IAAAA,IAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAMA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AAMA,IAAAI,QAAA,GAAAJ,OAAA;AAOA,IAAAK,SAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AACA,IAAAQ,QAAA,GAAAR,OAAA;AAKA,IAAAS,WAAA,GAAAT,OAAA;AACA,IAAAU,YAAA,GAAAV,OAAA;AAAmD,IAAAW,WAAA,GAAAX,OAAA;AAjCnD;AACA;AACA;;AA2BA;AACA;AACA;;AAIA,MAAM;EAAEY,oBAAoB,EAAEC;AAAc,CAAC,GAAG,IAAAC,kBAAM,EACrDC,wBACD,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,mBAAmBA,CAAEC,IAAI,EAAEC,IAAI,EAAG;EACjD,QAASD,IAAI;IACZ,KAAK,MAAM;IACX,KAAK,MAAM;MACV,OAAO;QAAEA,IAAI,EAAE,MAAM;QAAEE,OAAO,EAAEF;MAAK,CAAC;IACvC,KAAK,UAAU;MACd,OAAO;QAAEA,IAAI,EAAE,MAAM;QAAEE,OAAO,EAAE;MAAW,CAAC;IAC7C,KAAK,KAAK;MACT,OAAO;QAAEF,IAAI,EAAE,MAAM;QAAEE,OAAO,E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ErC,IAAAI,QAAE,EAAE,WAAY;IAAC,CACZ,CACR;EAAA,CACM,CAAC;AAEX,CAAC;AAAC,IAAAiF,QAAA,GAAAb,OAAA,CAAAc,OAAA,GAEapB,WAAW","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_dom","require","_components","_i18n","_blockEditor","_element","_coreData","_icons","_compose","_pageCreator","_blockInserter","_interopRequireDefault","_jsxRuntime","getSuggestionsQuery","type","kind","subtype","initialSuggestionsSearchOptions","perPage","UnforwardedLinkUI","props","ref","label","url","opensInNewTab","link","postType","addingBlock","setAddingBlock","useState","addingPage","setAddingPage","focusAddBlockButton","setFocusAddBlockButton","focusAddPageButton","setFocusAddPageButton","permissions","useResourcePermissions","name","useMemo","title","stripHTML","handlePageCreated","pageLink","onChange","dialogTitleId","useInstanceId","LinkUI","dialogDescriptionId","blockEditingMode","useBlockEditingMode","jsxs","Popover","placement","onClose","anchor","shift","children","role","VisuallyHidden","jsx","id","__","LinkControl","hasTextControl","hasRichPreviews","value","showInitialSuggestions","withCreateSuggestion","noDirectEntry","noURLSuggestion","suggestionsQuery","onRemove","onCancel","renderControlBottom","length","LinkUITools","canAddPage","canCreate","canAddBlock","default","clientId","onBack","onBlockInsert","LinkUIPageCreator","onPageCreated","initialTitle","exports","forwardRef","blockInserterAriaRole","addBlockButtonRef","useRef","addPageButtonRef","useEffect","current","focus","__experimentalVStack","spacing","className","Button","__next40pxDefaultSize","icon","plus","onClick","e","preventDefault","_default"],"sources":["@wordpress/block-library/src/navigation-link/link-ui.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\nimport {\n\tPopover,\n\tButton,\n\tVisuallyHidden,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { LinkControl, useBlockEditingMode } from '@wordpress/block-editor';\nimport {\n\tuseMemo,\n\tuseState,\n\tuseRef,\n\tuseEffect,\n\tforwardRef,\n} from '@wordpress/element';\nimport { useResourcePermissions } from '@wordpress/core-data';\nimport { plus } from '@wordpress/icons';\nimport { useInstanceId } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { LinkUIPageCreator } from './page-creator';\nimport LinkUIBlockInserter from './block-inserter';\n\n/**\n * Given the Link block's type attribute, return the query params to give to\n * /wp/v2/search.\n *\n * @param {string} type Link block's type attribute.\n * @param {string} kind Link block's entity of kind (post-type|taxonomy)\n * @return {{ type?: string, subtype?: string }} Search query params.\n */\nexport function getSuggestionsQuery( type, kind ) {\n\tswitch ( type ) {\n\t\tcase 'post':\n\t\tcase 'page':\n\t\t\treturn { type: 'post', subtype: type };\n\t\tcase 'category':\n\t\t\treturn { type: 'term', subtype: 'category' };\n\t\tcase 'tag':\n\t\t\treturn { type: 'term', subtype: 'post_tag' };\n\t\tcase 'post_format':\n\t\t\treturn { type: 'post-format' };\n\t\tdefault:\n\t\t\tif ( kind === 'taxonomy' ) {\n\t\t\t\treturn { type: 'term', subtype: type };\n\t\t\t}\n\t\t\tif ( kind === 'post-type' ) {\n\t\t\t\treturn { type: 'post', subtype: type };\n\t\t\t}\n\t\t\treturn {\n\t\t\t\t// for custom link which has no type\n\t\t\t\t// always show pages as initial suggestions\n\t\t\t\tinitialSuggestionsSearchOptions: {\n\t\t\t\t\ttype: 'post',\n\t\t\t\t\tsubtype: 'page',\n\t\t\t\t\tperPage: 20,\n\t\t\t\t},\n\t\t\t};\n\t}\n}\n\nfunction UnforwardedLinkUI( props, ref ) {\n\tconst { label, url, opensInNewTab, type, kind } = props.link;\n\tconst postType = type || 'page';\n\n\tconst [ addingBlock, setAddingBlock ] = useState( false );\n\tconst [ addingPage, setAddingPage ] = useState( false );\n\tconst [ focusAddBlockButton, setFocusAddBlockButton ] = useState( false );\n\tconst [ focusAddPageButton, setFocusAddPageButton ] = useState( false );\n\tconst permissions = useResourcePermissions( {\n\t\tkind: 'postType',\n\t\tname: postType,\n\t} );\n\n\t// Memoize link value to avoid overriding the LinkControl's internal state.\n\t// This is a temporary fix. See https://github.com/WordPress/gutenberg/issues/50976#issuecomment-1568226407.\n\tconst link = useMemo(\n\t\t() => ( {\n\t\t\turl,\n\t\t\topensInNewTab,\n\t\t\ttitle: label && stripHTML( label ),\n\t\t} ),\n\t\t[ label, opensInNewTab, url ]\n\t);\n\n\tconst handlePageCreated = ( pageLink ) => {\n\t\t// Set the new page as the current link\n\t\tprops.onChange( pageLink );\n\t\t// Return to main Link UI\n\t\tsetAddingPage( false );\n\t};\n\n\tconst dialogTitleId = useInstanceId(\n\t\tLinkUI,\n\t\t'link-ui-link-control__title'\n\t);\n\tconst dialogDescriptionId = useInstanceId(\n\t\tLinkUI,\n\t\t'link-ui-link-control__description'\n\t);\n\n\tconst blockEditingMode = useBlockEditingMode();\n\n\treturn (\n\t\t<Popover\n\t\t\tref={ ref }\n\t\t\tplacement=\"bottom\"\n\t\t\tonClose={ props.onClose }\n\t\t\tanchor={ props.anchor }\n\t\t\tshift\n\t\t>\n\t\t\t{ ! addingBlock && ! addingPage && (\n\t\t\t\t<div\n\t\t\t\t\trole=\"dialog\"\n\t\t\t\t\taria-labelledby={ dialogTitleId }\n\t\t\t\t\taria-describedby={ dialogDescriptionId }\n\t\t\t\t>\n\t\t\t\t\t<VisuallyHidden>\n\t\t\t\t\t\t<h2 id={ dialogTitleId }>{ __( 'Add link' ) }</h2>\n\n\t\t\t\t\t\t<p id={ dialogDescriptionId }>\n\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t'Search for and add a link to your Navigation.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</p>\n\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t<LinkControl\n\t\t\t\t\t\thasTextControl\n\t\t\t\t\t\thasRichPreviews\n\t\t\t\t\t\tvalue={ link }\n\t\t\t\t\t\tshowInitialSuggestions\n\t\t\t\t\t\twithCreateSuggestion={ false }\n\t\t\t\t\t\tnoDirectEntry={ !! type }\n\t\t\t\t\t\tnoURLSuggestion={ !! type }\n\t\t\t\t\t\tsuggestionsQuery={ getSuggestionsQuery( type, kind ) }\n\t\t\t\t\t\tonChange={ props.onChange }\n\t\t\t\t\t\tonRemove={ props.onRemove }\n\t\t\t\t\t\tonCancel={ props.onCancel }\n\t\t\t\t\t\trenderControlBottom={ () => {\n\t\t\t\t\t\t\t// Don't show the tools when there is submitted link (preview state).\n\t\t\t\t\t\t\tif ( link?.url?.length ) {\n\t\t\t\t\t\t\t\treturn null;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t<LinkUITools\n\t\t\t\t\t\t\t\t\tfocusAddBlockButton={ focusAddBlockButton }\n\t\t\t\t\t\t\t\t\tfocusAddPageButton={ focusAddPageButton }\n\t\t\t\t\t\t\t\t\tsetAddingBlock={ () => {\n\t\t\t\t\t\t\t\t\t\tsetAddingBlock( true );\n\t\t\t\t\t\t\t\t\t\tsetFocusAddBlockButton( false );\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\tsetAddingPage={ () => {\n\t\t\t\t\t\t\t\t\t\tsetAddingPage( true );\n\t\t\t\t\t\t\t\t\t\tsetFocusAddPageButton( false );\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\tcanAddPage={\n\t\t\t\t\t\t\t\t\t\tpermissions?.canCreate &&\n\t\t\t\t\t\t\t\t\t\ttype === 'page'\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tcanAddBlock={\n\t\t\t\t\t\t\t\t\t\tblockEditingMode === 'default'\n\t\t\t\t\t\t\t\t\t}\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</div>\n\t\t\t) }\n\n\t\t\t{ addingBlock && (\n\t\t\t\t<LinkUIBlockInserter\n\t\t\t\t\tclientId={ props.clientId }\n\t\t\t\t\tonBack={ () => {\n\t\t\t\t\t\tsetAddingBlock( false );\n\t\t\t\t\t\tsetFocusAddBlockButton( true );\n\t\t\t\t\t\tsetFocusAddPageButton( false );\n\t\t\t\t\t} }\n\t\t\t\t\tonBlockInsert={ props?.onBlockInsert }\n\t\t\t\t/>\n\t\t\t) }\n\n\t\t\t{ addingPage && (\n\t\t\t\t<LinkUIPageCreator\n\t\t\t\t\tpostType={ postType }\n\t\t\t\t\tonBack={ () => {\n\t\t\t\t\t\tsetAddingPage( false );\n\t\t\t\t\t\tsetFocusAddPageButton( true );\n\t\t\t\t\t\tsetFocusAddBlockButton( false );\n\t\t\t\t\t} }\n\t\t\t\t\tonPageCreated={ handlePageCreated }\n\t\t\t\t\tinitialTitle={ link?.url || '' }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</Popover>\n\t);\n}\n\nexport const LinkUI = forwardRef( UnforwardedLinkUI );\n\nconst LinkUITools = ( {\n\tsetAddingBlock,\n\tsetAddingPage,\n\tfocusAddBlockButton,\n\tfocusAddPageButton,\n\tcanAddPage,\n\tcanAddBlock,\n} ) => {\n\tconst blockInserterAriaRole = 'listbox';\n\tconst addBlockButtonRef = useRef();\n\tconst addPageButtonRef = useRef();\n\n\t// Focus the add block button when the popover is opened.\n\tuseEffect( () => {\n\t\tif ( focusAddBlockButton ) {\n\t\t\taddBlockButtonRef.current?.focus();\n\t\t}\n\t}, [ focusAddBlockButton ] );\n\n\t// Focus the add page button when the popover is opened.\n\tuseEffect( () => {\n\t\tif ( focusAddPageButton ) {\n\t\t\taddPageButtonRef.current?.focus();\n\t\t}\n\t}, [ focusAddPageButton ] );\n\n\t// Don't render anything if neither button should be shown\n\tif ( ! canAddPage && ! canAddBlock ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<VStack spacing={ 0 } className=\"link-ui-tools\">\n\t\t\t{ canAddPage && (\n\t\t\t\t<Button\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tref={ addPageButtonRef }\n\t\t\t\t\ticon={ plus }\n\t\t\t\t\tonClick={ ( e ) => {\n\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\tsetAddingPage( true );\n\t\t\t\t\t} }\n\t\t\t\t\taria-haspopup={ blockInserterAriaRole }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Create page' ) }\n\t\t\t\t</Button>\n\t\t\t) }\n\t\t\t{ canAddBlock && (\n\t\t\t\t<Button\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tref={ addBlockButtonRef }\n\t\t\t\t\ticon={ plus }\n\t\t\t\t\tonClick={ ( e ) => {\n\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\tsetAddingBlock( true );\n\t\t\t\t\t} }\n\t\t\t\t\taria-haspopup={ blockInserterAriaRole }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Add block' ) }\n\t\t\t\t</Button>\n\t\t\t) }\n\t\t</VStack>\n\t);\n};\n\nexport default LinkUITools;\n"],"mappings":";;;;;;;;AAGA,IAAAA,IAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAMA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AAOA,IAAAK,SAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,QAAA,GAAAP,OAAA;AAKA,IAAAQ,YAAA,GAAAR,OAAA;AACA,IAAAS,cAAA,GAAAC,sBAAA,CAAAV,OAAA;AAAmD,IAAAW,WAAA,GAAAX,OAAA;AA3BnD;AACA;AACA;;AAqBA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASY,mBAAmBA,CAAEC,IAAI,EAAEC,IAAI,EAAG;EACjD,QAASD,IAAI;IACZ,KAAK,MAAM;IACX,KAAK,MAAM;MACV,OAAO;QAAEA,IAAI,EAAE,MAAM;QAAEE,OAAO,EAAEF;MAAK,CAAC;IACvC,KAAK,UAAU;MACd,OAAO;QAAEA,IAAI,E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C;IAClC;EACD,CAAC,EAAE,CAAE7D,kBAAkB,CAAG,CAAC;;EAE3B;EACA,IAAK,CAAE2C,UAAU,IAAI,CAAEE,WAAW,EAAG;IACpC,OAAO,IAAI;EACZ;EAEA,oBACC,IAAAnE,WAAA,CAAAuC,IAAA,EAACjD,WAAA,CAAA8F,oBAAM;IAACC,OAAO,EAAG,CAAG;IAACC,SAAS,EAAC,eAAe;IAAAzC,QAAA,GAC5CoB,UAAU,iBACX,IAAAjE,WAAA,CAAAgD,GAAA,EAAC1D,WAAA,CAAAiG,MAAM;MACNC,qBAAqB;MACrB/E,GAAG,EAAGuE,gBAAkB;MACxBS,IAAI,EAAGC,WAAM;MACbC,OAAO,EAAKC,CAAC,IAAM;QAClBA,CAAC,CAACC,cAAc,CAAC,CAAC;QAClB1E,aAAa,CAAE,IAAK,CAAC;MACtB,CAAG;MACH,iBAAgB0D,qBAAuB;MAAAhC,QAAA,EAErC,IAAAK,QAAE,EAAE,aAAc;IAAC,CACd,CACR,EACCiB,WAAW,iBACZ,IAAAnE,WAAA,CAAAgD,GAAA,EAAC1D,WAAA,CAAAiG,MAAM;MACNC,qBAAqB;MACrB/E,GAAG,EAAGqE,iBAAmB;MACzBW,IAAI,EAAGC,WAAM;MACbC,OAAO,EAAKC,CAAC,IAAM;QAClBA,CAAC,CAACC,cAAc,CAAC,CAAC;QAClB7E,cAAc,CAAE,IAAK,CAAC;MACvB,CAAG;MACH,iBAAgB6D,qBAAuB;MAAAhC,QAAA,EAErC,IAAAK,QAAE,EAAE,WAAY;IAAC,CACZ,CACR;EAAA,CACM,CAAC;AAEX,CAAC;AAAC,IAAA4C,QAAA,GAAAnB,OAAA,CAAAP,OAAA,GAEaJ,WAAW","ignoreList":[]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
@@ -10,13 +11,16 @@ var _data = require("@wordpress/data");
|
|
|
10
11
|
var _coreData = require("@wordpress/core-data");
|
|
11
12
|
var _htmlEntities = require("@wordpress/html-entities");
|
|
12
13
|
var _element = require("@wordpress/element");
|
|
13
|
-
var
|
|
14
|
-
var _compose = require("@wordpress/compose");
|
|
14
|
+
var _dialogWrapper = _interopRequireDefault(require("./dialog-wrapper"));
|
|
15
15
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
16
16
|
/**
|
|
17
17
|
* WordPress dependencies
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Internal dependencies
|
|
22
|
+
*/
|
|
23
|
+
|
|
20
24
|
/**
|
|
21
25
|
* Component for creating new pages within the Navigation Link UI.
|
|
22
26
|
*
|
|
@@ -35,9 +39,6 @@ function LinkUIPageCreator({
|
|
|
35
39
|
const [title, setTitle] = (0, _element.useState)(initialTitle);
|
|
36
40
|
const [shouldPublish, setShouldPublish] = (0, _element.useState)(false);
|
|
37
41
|
|
|
38
|
-
// Focus the first element when the component mounts
|
|
39
|
-
const focusOnMountRef = (0, _compose.useFocusOnMount)('firstElement');
|
|
40
|
-
|
|
41
42
|
// Check if the title is valid for submission
|
|
42
43
|
const isTitleValid = title.trim().length > 0;
|
|
43
44
|
|
|
@@ -80,19 +81,12 @@ function LinkUIPageCreator({
|
|
|
80
81
|
}
|
|
81
82
|
}
|
|
82
83
|
const isSubmitDisabled = isSaving || !isTitleValid;
|
|
83
|
-
return /*#__PURE__*/(0, _jsxRuntime.
|
|
84
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_dialogWrapper.default, {
|
|
84
85
|
className: "link-ui-page-creator",
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
onClick: e => {
|
|
90
|
-
e.preventDefault();
|
|
91
|
-
onBack();
|
|
92
|
-
},
|
|
93
|
-
size: "small",
|
|
94
|
-
children: (0, _i18n.__)('Back')
|
|
95
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalVStack, {
|
|
86
|
+
title: (0, _i18n.__)('Create page'),
|
|
87
|
+
description: (0, _i18n.__)('Create a new page to add to your Navigation.'),
|
|
88
|
+
onBack: onBack,
|
|
89
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalVStack, {
|
|
96
90
|
className: "link-ui-page-creator__inner",
|
|
97
91
|
spacing: 4,
|
|
98
92
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("form", {
|
|
@@ -137,7 +131,7 @@ function LinkUIPageCreator({
|
|
|
137
131
|
})]
|
|
138
132
|
})
|
|
139
133
|
})
|
|
140
|
-
})
|
|
134
|
+
})
|
|
141
135
|
});
|
|
142
136
|
}
|
|
143
137
|
//# sourceMappingURL=page-creator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_components","require","_i18n","_data","_coreData","_htmlEntities","_element","
|
|
1
|
+
{"version":3,"names":["_components","require","_i18n","_data","_coreData","_htmlEntities","_element","_dialogWrapper","_interopRequireDefault","_jsxRuntime","LinkUIPageCreator","postType","onBack","onPageCreated","initialTitle","title","setTitle","useState","shouldPublish","setShouldPublish","isTitleValid","trim","length","lastError","isSaving","useSelect","select","coreStore","getLastEntitySaveError","isSavingEntityRecord","saveEntityRecord","useDispatch","createPage","event","preventDefault","savedRecord","status","throwOnError","pageLink","id","type","decodeEntities","rendered","url","link","kind","error","isSubmitDisabled","jsx","default","className","__","description","children","__experimentalVStack","spacing","onSubmit","jsxs","TextControl","__next40pxDefaultSize","__nextHasNoMarginBottom","label","onChange","placeholder","value","CheckboxControl","help","checked","Notice","isDismissible","message","__experimentalHStack","justify","Button","variant","onClick","disabled","accessibleWhenDisabled","isBusy"],"sources":["@wordpress/block-library/src/navigation-link/page-creator.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tTextControl,\n\tNotice,\n\tCheckboxControl,\n\t__experimentalVStack as VStack,\n\t__experimentalHStack as HStack,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport DialogWrapper from './dialog-wrapper';\n\n/**\n * Component for creating new pages within the Navigation Link UI.\n *\n * @param {Object} props Component props.\n * @param {string} props.postType The post type to create.\n * @param {Function} props.onBack Callback when user wants to go back.\n * @param {Function} props.onPageCreated Callback when page is successfully created.\n * @param {string} [props.initialTitle] Initial title to pre-fill the form.\n */\nexport function LinkUIPageCreator( {\n\tpostType,\n\tonBack,\n\tonPageCreated,\n\tinitialTitle = '',\n} ) {\n\tconst [ title, setTitle ] = useState( initialTitle );\n\tconst [ shouldPublish, setShouldPublish ] = useState( false );\n\n\t// Check if the title is valid for submission\n\tconst isTitleValid = title.trim().length > 0;\n\n\t// Get the last created entity record (without ID) to track creation state\n\tconst { lastError, isSaving } = useSelect(\n\t\t( select ) => ( {\n\t\t\tlastError: select( coreStore ).getLastEntitySaveError(\n\t\t\t\t'postType',\n\t\t\t\tpostType\n\t\t\t),\n\t\t\tisSaving: select( coreStore ).isSavingEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tpostType\n\t\t\t),\n\t\t} ),\n\t\t[ postType ]\n\t);\n\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\n\tasync function createPage( event ) {\n\t\tevent.preventDefault();\n\t\tif ( isSaving || ! isTitleValid ) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tconst savedRecord = await saveEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tpostType,\n\t\t\t\t{\n\t\t\t\t\ttitle,\n\t\t\t\t\tstatus: shouldPublish ? 'publish' : 'draft',\n\t\t\t\t},\n\t\t\t\t{ throwOnError: true }\n\t\t\t);\n\n\t\t\tif ( savedRecord ) {\n\t\t\t\t// Create the page link object from the saved record\n\t\t\t\tconst pageLink = {\n\t\t\t\t\tid: savedRecord.id,\n\t\t\t\t\ttype: postType,\n\t\t\t\t\ttitle: decodeEntities( savedRecord.title.rendered ),\n\t\t\t\t\turl: savedRecord.link,\n\t\t\t\t\tkind: 'post-type',\n\t\t\t\t};\n\n\t\t\t\tonPageCreated( pageLink );\n\t\t\t}\n\t\t} catch ( error ) {\n\t\t\t// Error handling is done via the data store selectors\n\t\t}\n\t}\n\n\tconst isSubmitDisabled = isSaving || ! isTitleValid;\n\n\treturn (\n\t\t<DialogWrapper\n\t\t\tclassName=\"link-ui-page-creator\"\n\t\t\ttitle={ __( 'Create page' ) }\n\t\t\tdescription={ __( 'Create a new page to add to your Navigation.' ) }\n\t\t\tonBack={ onBack }\n\t\t>\n\t\t\t<VStack className=\"link-ui-page-creator__inner\" spacing={ 4 }>\n\t\t\t\t<form onSubmit={ createPage }>\n\t\t\t\t\t<VStack spacing={ 4 }>\n\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\tlabel={ __( 'Title' ) }\n\t\t\t\t\t\t\tonChange={ setTitle }\n\t\t\t\t\t\t\tplaceholder={ __( 'No title' ) }\n\t\t\t\t\t\t\tvalue={ title }\n\t\t\t\t\t\t/>\n\n\t\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\tlabel={ __( 'Publish immediately' ) }\n\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t'If unchecked, the page will be created as a draft.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tchecked={ shouldPublish }\n\t\t\t\t\t\t\tonChange={ setShouldPublish }\n\t\t\t\t\t\t/>\n\n\t\t\t\t\t\t{ lastError && (\n\t\t\t\t\t\t\t<Notice status=\"error\" isDismissible={ false }>\n\t\t\t\t\t\t\t\t{ lastError.message }\n\t\t\t\t\t\t\t</Notice>\n\t\t\t\t\t\t) }\n\n\t\t\t\t\t\t<HStack spacing={ 2 } justify=\"flex-end\">\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\tvariant=\"tertiary\"\n\t\t\t\t\t\t\t\tonClick={ onBack }\n\t\t\t\t\t\t\t\tdisabled={ isSaving }\n\t\t\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t\t</Button>\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\tvariant=\"primary\"\n\t\t\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\t\t\tisBusy={ isSaving }\n\t\t\t\t\t\t\t\taria-disabled={ isSubmitDisabled }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Create page' ) }\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t</HStack>\n\t\t\t\t\t</VStack>\n\t\t\t\t</form>\n\t\t\t</VStack>\n\t\t</DialogWrapper>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AAQA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AAKA,IAAAM,cAAA,GAAAC,sBAAA,CAAAP,OAAA;AAA6C,IAAAQ,WAAA,GAAAR,OAAA;AApB7C;AACA;AACA;;AAeA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASS,iBAAiBA,CAAE;EAClCC,QAAQ;EACRC,MAAM;EACNC,aAAa;EACbC,YAAY,GAAG;AAChB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3C;UAAkB,CAC7B,CAAC,EAEAI,SAAS,iBACV,IAAAd,WAAA,CAAAuC,GAAA,EAAChD,WAAA,CAAAoE,MAAM;YAAChC,MAAM,EAAC,OAAO;YAACiC,aAAa,EAAG,KAAO;YAAAhB,QAAA,EAC3C9B,SAAS,CAAC+C;UAAO,CACZ,CACR,eAED,IAAA7D,WAAA,CAAAgD,IAAA,EAACzD,WAAA,CAAAuE,oBAAM;YAAChB,OAAO,EAAG,CAAG;YAACiB,OAAO,EAAC,UAAU;YAAAnB,QAAA,gBACvC,IAAA5C,WAAA,CAAAuC,GAAA,EAAChD,WAAA,CAAAyE,MAAM;cACNd,qBAAqB;cACrBe,OAAO,EAAC,UAAU;cAClBC,OAAO,EAAG/D,MAAQ;cAClBgE,QAAQ,EAAGpD,QAAU;cACrBqD,sBAAsB;cAAAxB,QAAA,EAEpB,IAAAF,QAAE,EAAE,QAAS;YAAC,CACT,CAAC,eACT,IAAA1C,WAAA,CAAAuC,GAAA,EAAChD,WAAA,CAAAyE,MAAM;cACNd,qBAAqB;cACrBe,OAAO,EAAC,SAAS;cACjBlC,IAAI,EAAC,QAAQ;cACbsC,MAAM,EAAGtD,QAAU;cACnB,iBAAgBuB,gBAAkB;cAAAM,QAAA,EAEhC,IAAAF,QAAE,EAAE,aAAc;YAAC,CACd,CAAC;UAAA,CACF,CAAC;QAAA,CACF;MAAC,CACJ;IAAC,CACA;EAAC,CACK,CAAC;AAElB","ignoreList":[]}
|
package/build/post-date/edit.js
CHANGED
|
@@ -79,6 +79,7 @@ function PostDateEdit({
|
|
|
79
79
|
const [siteFormat = dateSettings.formats.date] = (0, _coreData.useEntityProp)('root', 'site', 'date_format');
|
|
80
80
|
const [siteTimeFormat = dateSettings.formats.time] = (0, _coreData.useEntityProp)('root', 'site', 'time_format');
|
|
81
81
|
const postType = (0, _data.useSelect)(select => postTypeSlug ? select(_coreData.store).getPostType(postTypeSlug) : null, [postTypeSlug]);
|
|
82
|
+
const blockEditingMode = (0, _blockEditor.useBlockEditingMode)();
|
|
82
83
|
let postDate = /*#__PURE__*/(0, _jsxRuntime.jsx)("time", {
|
|
83
84
|
dateTime: (0, _date.dateI18n)('c', datetime),
|
|
84
85
|
ref: setPopoverAnchor,
|
|
@@ -92,7 +93,7 @@ function PostDateEdit({
|
|
|
92
93
|
});
|
|
93
94
|
}
|
|
94
95
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
95
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_blockEditor.BlockControls, {
|
|
96
|
+
children: [(blockEditingMode === 'default' || !isDescendentOfQueryLoop) && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_blockEditor.BlockControls, {
|
|
96
97
|
group: "block",
|
|
97
98
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_blockEditor.AlignmentControl, {
|
|
98
99
|
value: textAlign,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_clsx","_interopRequireDefault","require","_coreData","_element","_date","_blockEditor","_components","_i18n","_icons","_keycodes","_data","_hooks","_jsxRuntime","PostDateEdit","attributes","datetime","textAlign","format","isLink","metadata","context","postType","postTypeSlug","queryId","setAttributes","displayType","bindings","source","args","key","blockProps","useBlockProps","className","clsx","dropdownMenuProps","useToolsPanelDropdownMenuProps","popoverAnchor","setPopoverAnchor","useState","popoverProps","useMemo","anchor","__unstableMarkNextChangeAsNotPersistent","useDispatch","blockEditorStore","useEffect","undefined","Date","isDescendentOfQueryLoop","Number","isFinite","dateSettings","getDateSettings","siteFormat","formats","date","useEntityProp","siteTimeFormat","time","useSelect","select","coreStore","getPostType","postDate","jsx","dateTime","dateI18n","ref","children","humanTimeDiff","href","onClick","event","preventDefault","jsxs","Fragment","BlockControls","group","AlignmentControl","value","onChange","nextAlign","ToolbarGroup","Dropdown","renderContent","onClose","__experimentalPublishDateTimePicker","title","__","currentDate","newDatetime","is12Hour","is12HourFormat","dateOrder","_x","renderToggle","isOpen","onToggle","openOnArrowDown","keyCode","DOWN","ToolbarButton","icon","edit","onKeyDown","InspectorControls","__experimentalToolsPanel","label","resetAll","__experimentalToolsPanelItem","hasValue","onDeselect","isShownByDefault","__experimentalDateFormatPicker","defaultFormat","nextFormat","labels","singular_name","sprintf","toLowerCase","ToggleControl","__nextHasNoMarginBottom","checked","test"],"sources":["@wordpress/block-library/src/post-date/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useEntityProp, store as coreStore } from '@wordpress/core-data';\nimport { useEffect, useMemo, useState } from '@wordpress/element';\nimport {\n\tdateI18n,\n\thumanTimeDiff,\n\tgetSettings as getDateSettings,\n} from '@wordpress/date';\nimport {\n\tAlignmentControl,\n\tBlockControls,\n\tInspectorControls,\n\tstore as blockEditorStore,\n\tuseBlockProps,\n\t__experimentalDateFormatPicker as DateFormatPicker,\n\t__experimentalPublishDateTimePicker as PublishDateTimePicker,\n} from '@wordpress/block-editor';\nimport {\n\tDropdown,\n\tToolbarGroup,\n\tToolbarButton,\n\tToggleControl,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { edit } from '@wordpress/icons';\nimport { DOWN } from '@wordpress/keycodes';\nimport { useSelect, useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { useToolsPanelDropdownMenuProps } from '../utils/hooks';\n\nexport default function PostDateEdit( {\n\tattributes: { datetime, textAlign, format, isLink, metadata },\n\tcontext: { postType: postTypeSlug, queryId },\n\tsetAttributes,\n} ) {\n\tconst displayType =\n\t\tmetadata?.bindings?.datetime?.source === 'core/post-data' &&\n\t\tmetadata?.bindings?.datetime?.args?.key;\n\n\tconst blockProps = useBlockProps( {\n\t\tclassName: clsx( {\n\t\t\t[ `has-text-align-${ textAlign }` ]: textAlign,\n\t\t} ),\n\t} );\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\t// Memoize popoverProps to avoid returning a new object every time.\n\tconst popoverProps = useMemo(\n\t\t() => ( { anchor: popoverAnchor } ),\n\t\t[ popoverAnchor ]\n\t);\n\n\tconst { __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\n\t// We need to set the datetime to a default value upon first loading\n\t// to discern the block from its legacy version (which would default\n\t// to the containing post's publish date).\n\tuseEffect( () => {\n\t\tif ( datetime === undefined ) {\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tsetAttributes( { datetime: new Date() } );\n\t\t}\n\t}, [ datetime ] );\n\n\tconst isDescendentOfQueryLoop = Number.isFinite( queryId );\n\tconst dateSettings = getDateSettings();\n\tconst [ siteFormat = dateSettings.formats.date ] = useEntityProp(\n\t\t'root',\n\t\t'site',\n\t\t'date_format'\n\t);\n\tconst [ siteTimeFormat = dateSettings.formats.time ] = useEntityProp(\n\t\t'root',\n\t\t'site',\n\t\t'time_format'\n\t);\n\n\tconst postType = useSelect(\n\t\t( select ) =>\n\t\t\tpostTypeSlug\n\t\t\t\t? select( coreStore ).getPostType( postTypeSlug )\n\t\t\t\t: null,\n\t\t[ postTypeSlug ]\n\t);\n\n\tlet postDate = (\n\t\t<time dateTime={ dateI18n( 'c', datetime ) } ref={ setPopoverAnchor }>\n\t\t\t{ format === 'human-diff'\n\t\t\t\t? humanTimeDiff( datetime )\n\t\t\t\t: dateI18n( format || siteFormat, datetime ) }\n\t\t</time>\n\t);\n\n\tif ( isLink && datetime ) {\n\t\tpostDate = (\n\t\t\t<a\n\t\t\t\thref=\"#post-date-pseudo-link\"\n\t\t\t\tonClick={ ( event ) => event.preventDefault() }\n\t\t\t>\n\t\t\t\t{ postDate }\n\t\t\t</a>\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<BlockControls group=\"block\">\n\t\t\t\t<AlignmentControl\n\t\t\t\t\tvalue={ textAlign }\n\t\t\t\t\tonChange={ ( nextAlign ) => {\n\t\t\t\t\t\tsetAttributes( { textAlign: nextAlign } );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t\t{ displayType !== 'modified' && ! isDescendentOfQueryLoop && (\n\t\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t\t<Dropdown\n\t\t\t\t\t\t\tpopoverProps={ popoverProps }\n\t\t\t\t\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t\t\t\t\t<PublishDateTimePicker\n\t\t\t\t\t\t\t\t\ttitle={\n\t\t\t\t\t\t\t\t\t\tdisplayType === 'date'\n\t\t\t\t\t\t\t\t\t\t\t? __( 'Publish Date' )\n\t\t\t\t\t\t\t\t\t\t\t: __( 'Date' )\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tcurrentDate={ datetime }\n\t\t\t\t\t\t\t\t\tonChange={ ( newDatetime ) =>\n\t\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\t\tdatetime: newDatetime,\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\tis12Hour={ is12HourFormat(\n\t\t\t\t\t\t\t\t\t\tsiteTimeFormat\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\t\t\t\t\tdateOrder={\n\t\t\t\t\t\t\t\t\t\t/* translators: Order of day, month, and year. Available formats are 'dmy', 'mdy', and 'ymd'. */\n\t\t\t\t\t\t\t\t\t\t_x( 'dmy', 'date order' )\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\trenderToggle={ ( { isOpen, onToggle } ) => {\n\t\t\t\t\t\t\t\tconst openOnArrowDown = ( event ) => {\n\t\t\t\t\t\t\t\t\tif ( ! isOpen && event.keyCode === DOWN ) {\n\t\t\t\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\t\t\t\tonToggle();\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\t\t\t\t\t\ticon={ edit }\n\t\t\t\t\t\t\t\t\t\ttitle={ __( 'Change Date' ) }\n\t\t\t\t\t\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t\t\t\t\t\tonKeyDown={ openOnArrowDown }\n\t\t\t\t\t\t\t\t\t/>\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</ToolbarGroup>\n\t\t\t\t) }\n\t\t\t</BlockControls>\n\n\t\t\t<InspectorControls>\n\t\t\t\t<ToolsPanel\n\t\t\t\t\tlabel={ __( 'Settings' ) }\n\t\t\t\t\tresetAll={ () => {\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\tdatetime: undefined,\n\t\t\t\t\t\t\tformat: undefined,\n\t\t\t\t\t\t\tisLink: false,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t\t\t>\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\thasValue={ () => !! format }\n\t\t\t\t\t\tlabel={ __( 'Date Format' ) }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( { format: undefined } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t>\n\t\t\t\t\t\t<DateFormatPicker\n\t\t\t\t\t\t\tformat={ format }\n\t\t\t\t\t\t\tdefaultFormat={ siteFormat }\n\t\t\t\t\t\t\tonChange={ ( nextFormat ) =>\n\t\t\t\t\t\t\t\tsetAttributes( { format: nextFormat } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\thasValue={ () => isLink !== false }\n\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\tpostType?.labels.singular_name\n\t\t\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t\t\t// translators: %s: Name of the post type e.g: \"post\".\n\t\t\t\t\t\t\t\t\t\t__( 'Link to %s' ),\n\t\t\t\t\t\t\t\t\t\tpostType.labels.singular_name.toLowerCase()\n\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t: __( 'Link to post' )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonDeselect={ () => setAttributes( { isLink: false } ) }\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t>\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\tpostType?.labels.singular_name\n\t\t\t\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t\t\t\t// translators: %s: Name of the post type e.g: \"post\".\n\t\t\t\t\t\t\t\t\t\t\t__( 'Link to %s' ),\n\t\t\t\t\t\t\t\t\t\t\tpostType.labels.singular_name.toLowerCase()\n\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t: __( 'Link to post' )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\t\tsetAttributes( { isLink: ! isLink } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tchecked={ isLink }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t</ToolsPanel>\n\t\t\t</InspectorControls>\n\n\t\t\t<div { ...blockProps }>{ postDate }</div>\n\t\t</>\n\t);\n}\n\nexport function is12HourFormat( format ) {\n\t// To know if the time format is a 12 hour time, look for any of the 12 hour\n\t// format characters: 'a', 'A', 'g', and 'h'. The character must be\n\t// unescaped, i.e. not preceded by a '\\'. Coincidentally, 'aAgh' is how I\n\t// feel when working with regular expressions.\n\t// https://www.php.net/manual/en/datetime.format.php\n\treturn /(?:^|[^\\\\])[aAgh]/.test( format );\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AAKA,IAAAI,YAAA,GAAAJ,OAAA;AASA,IAAAK,WAAA,GAAAL,OAAA;AAQA,IAAAM,KAAA,GAAAN,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AACA,IAAAQ,SAAA,GAAAR,OAAA;AACA,IAAAS,KAAA,GAAAT,OAAA;AAKA,IAAAU,MAAA,GAAAV,OAAA;AAAgE,IAAAW,WAAA,GAAAX,OAAA;AAxChE;AACA;AACA;;AAGA;AACA;AACA;;AA8BA;AACA;AACA;;AAGe,SAASY,YAAYA,CAAE;EACrCC,UAAU,EAAE;IAAEC,QAAQ;IAAEC,SAAS;IAAEC,MAAM;IAAEC,MAAM;IAAEC;EAAS,CAAC;EAC7DC,OAAO,EAAE;IAAEC,QAAQ,EAAEC,YAAY;IAAEC;EAAQ,CAAC;EAC5CC;AACD,CAAC,EAAG;EACH,MAAMC,WAAW,GAChBN,QAAQ,EAAEO,QAAQ,EAAEX,QAAQ,EAAEY,MAAM,KAAK,gBAAgB,IACzDR,QAAQ,EAAEO,QAAQ,EAAEX,QAAQ,EAAEa,IAAI,EAAEC,GAAG;EAExC,MAAMC,UAAU,GAAG,IAAAC,0BAAa,EAAE;IACjCC,SAAS,EAAE,IAAAC,aAAI,EAAE;MAChB,CAAE,kBAAmBjB,SAAS,EAAG,GAAIA;IACtC,CAAE;EACH,CAAE,CAAC;EACH,MAA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E,EAAE,YAAa,CAAC,EAClBnE,QAAQ,CAAC+F,MAAM,CAACC,aAAa,CAACE,WAAW,CAAC,CAC1C,CAAC,GACD,IAAA/B,QAAE,EAAE,cAAe,CACtB;YACDR,QAAQ,EAAGA,CAAA,KACVxD,aAAa,CAAE;cAAEN,MAAM,EAAE,CAAEA;YAAO,CAAE,CACpC;YACDwG,OAAO,EAAGxG;UAAQ,CAClB;QAAC,CACa,CAAC;MAAA,CACN;IAAC,CACK,CAAC,eAEpB,IAAAN,WAAA,CAAAoD,GAAA;MAAA,GAAUlC,UAAU;MAAAsC,QAAA,EAAKL;IAAQ,CAAO,CAAC;EAAA,CACxC,CAAC;AAEL;AAEO,SAAS6B,cAAcA,CAAE3E,MAAM,EAAG;EACxC;EACA;EACA;EACA;EACA;EACA,OAAO,mBAAmB,CAAC0G,IAAI,CAAE1G,MAAO,CAAC;AAC1C","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_clsx","_interopRequireDefault","require","_coreData","_element","_date","_blockEditor","_components","_i18n","_icons","_keycodes","_data","_hooks","_jsxRuntime","PostDateEdit","attributes","datetime","textAlign","format","isLink","metadata","context","postType","postTypeSlug","queryId","setAttributes","displayType","bindings","source","args","key","blockProps","useBlockProps","className","clsx","dropdownMenuProps","useToolsPanelDropdownMenuProps","popoverAnchor","setPopoverAnchor","useState","popoverProps","useMemo","anchor","__unstableMarkNextChangeAsNotPersistent","useDispatch","blockEditorStore","useEffect","undefined","Date","isDescendentOfQueryLoop","Number","isFinite","dateSettings","getDateSettings","siteFormat","formats","date","useEntityProp","siteTimeFormat","time","useSelect","select","coreStore","getPostType","blockEditingMode","useBlockEditingMode","postDate","jsx","dateTime","dateI18n","ref","children","humanTimeDiff","href","onClick","event","preventDefault","jsxs","Fragment","BlockControls","group","AlignmentControl","value","onChange","nextAlign","ToolbarGroup","Dropdown","renderContent","onClose","__experimentalPublishDateTimePicker","title","__","currentDate","newDatetime","is12Hour","is12HourFormat","dateOrder","_x","renderToggle","isOpen","onToggle","openOnArrowDown","keyCode","DOWN","ToolbarButton","icon","edit","onKeyDown","InspectorControls","__experimentalToolsPanel","label","resetAll","__experimentalToolsPanelItem","hasValue","onDeselect","isShownByDefault","__experimentalDateFormatPicker","defaultFormat","nextFormat","labels","singular_name","sprintf","toLowerCase","ToggleControl","__nextHasNoMarginBottom","checked","test"],"sources":["@wordpress/block-library/src/post-date/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useEntityProp, store as coreStore } from '@wordpress/core-data';\nimport { useEffect, useMemo, useState } from '@wordpress/element';\nimport {\n\tdateI18n,\n\thumanTimeDiff,\n\tgetSettings as getDateSettings,\n} from '@wordpress/date';\nimport {\n\tAlignmentControl,\n\tBlockControls,\n\tInspectorControls,\n\tstore as blockEditorStore,\n\tuseBlockProps,\n\tuseBlockEditingMode,\n\t__experimentalDateFormatPicker as DateFormatPicker,\n\t__experimentalPublishDateTimePicker as PublishDateTimePicker,\n} from '@wordpress/block-editor';\nimport {\n\tDropdown,\n\tToolbarGroup,\n\tToolbarButton,\n\tToggleControl,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { edit } from '@wordpress/icons';\nimport { DOWN } from '@wordpress/keycodes';\nimport { useSelect, useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { useToolsPanelDropdownMenuProps } from '../utils/hooks';\n\nexport default function PostDateEdit( {\n\tattributes: { datetime, textAlign, format, isLink, metadata },\n\tcontext: { postType: postTypeSlug, queryId },\n\tsetAttributes,\n} ) {\n\tconst displayType =\n\t\tmetadata?.bindings?.datetime?.source === 'core/post-data' &&\n\t\tmetadata?.bindings?.datetime?.args?.key;\n\n\tconst blockProps = useBlockProps( {\n\t\tclassName: clsx( {\n\t\t\t[ `has-text-align-${ textAlign }` ]: textAlign,\n\t\t} ),\n\t} );\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\t// Memoize popoverProps to avoid returning a new object every time.\n\tconst popoverProps = useMemo(\n\t\t() => ( { anchor: popoverAnchor } ),\n\t\t[ popoverAnchor ]\n\t);\n\n\tconst { __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\n\t// We need to set the datetime to a default value upon first loading\n\t// to discern the block from its legacy version (which would default\n\t// to the containing post's publish date).\n\tuseEffect( () => {\n\t\tif ( datetime === undefined ) {\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tsetAttributes( { datetime: new Date() } );\n\t\t}\n\t}, [ datetime ] );\n\n\tconst isDescendentOfQueryLoop = Number.isFinite( queryId );\n\tconst dateSettings = getDateSettings();\n\tconst [ siteFormat = dateSettings.formats.date ] = useEntityProp(\n\t\t'root',\n\t\t'site',\n\t\t'date_format'\n\t);\n\tconst [ siteTimeFormat = dateSettings.formats.time ] = useEntityProp(\n\t\t'root',\n\t\t'site',\n\t\t'time_format'\n\t);\n\n\tconst postType = useSelect(\n\t\t( select ) =>\n\t\t\tpostTypeSlug\n\t\t\t\t? select( coreStore ).getPostType( postTypeSlug )\n\t\t\t\t: null,\n\t\t[ postTypeSlug ]\n\t);\n\n\tconst blockEditingMode = useBlockEditingMode();\n\n\tlet postDate = (\n\t\t<time dateTime={ dateI18n( 'c', datetime ) } ref={ setPopoverAnchor }>\n\t\t\t{ format === 'human-diff'\n\t\t\t\t? humanTimeDiff( datetime )\n\t\t\t\t: dateI18n( format || siteFormat, datetime ) }\n\t\t</time>\n\t);\n\n\tif ( isLink && datetime ) {\n\t\tpostDate = (\n\t\t\t<a\n\t\t\t\thref=\"#post-date-pseudo-link\"\n\t\t\t\tonClick={ ( event ) => event.preventDefault() }\n\t\t\t>\n\t\t\t\t{ postDate }\n\t\t\t</a>\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ ( blockEditingMode === 'default' ||\n\t\t\t\t! isDescendentOfQueryLoop ) && (\n\t\t\t\t<BlockControls group=\"block\">\n\t\t\t\t\t<AlignmentControl\n\t\t\t\t\t\tvalue={ textAlign }\n\t\t\t\t\t\tonChange={ ( nextAlign ) => {\n\t\t\t\t\t\t\tsetAttributes( { textAlign: nextAlign } );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\n\t\t\t\t\t{ displayType !== 'modified' &&\n\t\t\t\t\t\t! isDescendentOfQueryLoop && (\n\t\t\t\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t\t\t\t<Dropdown\n\t\t\t\t\t\t\t\t\tpopoverProps={ popoverProps }\n\t\t\t\t\t\t\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t\t\t\t\t\t\t<PublishDateTimePicker\n\t\t\t\t\t\t\t\t\t\t\ttitle={\n\t\t\t\t\t\t\t\t\t\t\t\tdisplayType === 'date'\n\t\t\t\t\t\t\t\t\t\t\t\t\t? __( 'Publish Date' )\n\t\t\t\t\t\t\t\t\t\t\t\t\t: __( 'Date' )\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\tcurrentDate={ datetime }\n\t\t\t\t\t\t\t\t\t\t\tonChange={ ( newDatetime ) =>\n\t\t\t\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\t\t\t\tdatetime: newDatetime,\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\tis12Hour={ is12HourFormat(\n\t\t\t\t\t\t\t\t\t\t\t\tsiteTimeFormat\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\t\t\t\t\t\t\tdateOrder={\n\t\t\t\t\t\t\t\t\t\t\t\t/* translators: Order of day, month, and year. Available formats are 'dmy', 'mdy', and 'ymd'. */\n\t\t\t\t\t\t\t\t\t\t\t\t_x( 'dmy', 'date order' )\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\trenderToggle={ ( { isOpen, onToggle } ) => {\n\t\t\t\t\t\t\t\t\t\tconst openOnArrowDown = ( event ) => {\n\t\t\t\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t\t\t\t! isOpen &&\n\t\t\t\t\t\t\t\t\t\t\t\tevent.keyCode === DOWN\n\t\t\t\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\t\t\t\t\t\tonToggle();\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\treturn (\n\t\t\t\t\t\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\t\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\t\t\t\t\t\t\t\ticon={ edit }\n\t\t\t\t\t\t\t\t\t\t\t\ttitle={ __( 'Change Date' ) }\n\t\t\t\t\t\t\t\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t\t\t\t\t\t\t\tonKeyDown={ openOnArrowDown }\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/>\n\t\t\t\t\t\t\t</ToolbarGroup>\n\t\t\t\t\t\t) }\n\t\t\t\t</BlockControls>\n\t\t\t) }\n\n\t\t\t<InspectorControls>\n\t\t\t\t<ToolsPanel\n\t\t\t\t\tlabel={ __( 'Settings' ) }\n\t\t\t\t\tresetAll={ () => {\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\tdatetime: undefined,\n\t\t\t\t\t\t\tformat: undefined,\n\t\t\t\t\t\t\tisLink: false,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t\t\t>\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\thasValue={ () => !! format }\n\t\t\t\t\t\tlabel={ __( 'Date Format' ) }\n\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\tsetAttributes( { format: undefined } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t>\n\t\t\t\t\t\t<DateFormatPicker\n\t\t\t\t\t\t\tformat={ format }\n\t\t\t\t\t\t\tdefaultFormat={ siteFormat }\n\t\t\t\t\t\t\tonChange={ ( nextFormat ) =>\n\t\t\t\t\t\t\t\tsetAttributes( { format: nextFormat } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\thasValue={ () => isLink !== false }\n\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\tpostType?.labels.singular_name\n\t\t\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t\t\t// translators: %s: Name of the post type e.g: \"post\".\n\t\t\t\t\t\t\t\t\t\t__( 'Link to %s' ),\n\t\t\t\t\t\t\t\t\t\tpostType.labels.singular_name.toLowerCase()\n\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t: __( 'Link to post' )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonDeselect={ () => setAttributes( { isLink: false } ) }\n\t\t\t\t\t\tisShownByDefault\n\t\t\t\t\t>\n\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\tpostType?.labels.singular_name\n\t\t\t\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t\t\t\t// translators: %s: Name of the post type e.g: \"post\".\n\t\t\t\t\t\t\t\t\t\t\t__( 'Link to %s' ),\n\t\t\t\t\t\t\t\t\t\t\tpostType.labels.singular_name.toLowerCase()\n\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t: __( 'Link to post' )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\t\tsetAttributes( { isLink: ! isLink } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tchecked={ isLink }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t</ToolsPanel>\n\t\t\t</InspectorControls>\n\n\t\t\t<div { ...blockProps }>{ postDate }</div>\n\t\t</>\n\t);\n}\n\nexport function is12HourFormat( format ) {\n\t// To know if the time format is a 12 hour time, look for any of the 12 hour\n\t// format characters: 'a', 'A', 'g', and 'h'. The character must be\n\t// unescaped, i.e. not preceded by a '\\'. Coincidentally, 'aAgh' is how I\n\t// feel when working with regular expressions.\n\t// https://www.php.net/manual/en/datetime.format.php\n\treturn /(?:^|[^\\\\])[aAgh]/.test( format );\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AAKA,IAAAI,YAAA,GAAAJ,OAAA;AAUA,IAAAK,WAAA,GAAAL,OAAA;AAQA,IAAAM,KAAA,GAAAN,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AACA,IAAAQ,SAAA,GAAAR,OAAA;AACA,IAAAS,KAAA,GAAAT,OAAA;AAKA,IAAAU,MAAA,GAAAV,OAAA;AAAgE,IAAAW,WAAA,GAAAX,OAAA;AAzChE;AACA;AACA;;AAGA;AACA;AACA;;AA+BA;AACA;AACA;;AAGe,SAASY,YAAYA,CAAE;EACrCC,UAAU,EAAE;IAAE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|
|
257
257
|
}), isLink && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalToolsPanelItem, {
|
|
258
|
-
label: (0, _i18n.__)('Link
|
|
258
|
+
label: (0, _i18n.__)('Link relation'),
|
|
259
259
|
isShownByDefault: true,
|
|
260
260
|
hasValue: () => !!rel,
|
|
261
261
|
onDeselect: () => setAttributes({
|
|
@@ -264,7 +264,12 @@ function PostFeaturedImageEdit({
|
|
|
264
264
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.TextControl, {
|
|
265
265
|
__next40pxDefaultSize: true,
|
|
266
266
|
__nextHasNoMarginBottom: true,
|
|
267
|
-
label: (0, _i18n.__)('Link
|
|
267
|
+
label: (0, _i18n.__)('Link relation'),
|
|
268
|
+
help: (0, _element.createInterpolateElement)((0, _i18n.__)('The <a>Link Relation</a> attribute defines the relationship between a linked resource and the current document.'), {
|
|
269
|
+
a: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.ExternalLink, {
|
|
270
|
+
href: "https://developer.mozilla.org/docs/Web/HTML/Attributes/rel"
|
|
271
|
+
})
|
|
272
|
+
}),
|
|
268
273
|
value: rel,
|
|
269
274
|
onChange: newRel => setAttributes({
|
|
270
275
|
rel: newRel
|