newspack-components 4.2.0 → 4.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/dist/cjs/action-card/index.js +21 -12
  2. package/dist/cjs/action-card/style.scss +25 -2
  3. package/dist/cjs/autocomplete-tokenfield/index.js +2 -2
  4. package/dist/cjs/autocomplete-with-latest-posts/index.js +289 -0
  5. package/dist/cjs/autocomplete-with-latest-posts/style.scss +150 -0
  6. package/dist/cjs/badge/index.js +32 -0
  7. package/dist/cjs/badge/style.scss +36 -0
  8. package/dist/cjs/button/index.js +2 -0
  9. package/dist/cjs/card/core-card.js +141 -0
  10. package/dist/cjs/card/index.js +33 -0
  11. package/dist/cjs/card/style-core.scss +227 -0
  12. package/dist/cjs/card/style.scss +2 -2
  13. package/dist/cjs/card-settings-group/index.js +49 -0
  14. package/dist/cjs/card-settings-group/style.scss +33 -0
  15. package/dist/cjs/card-sortable-list/index.js +390 -0
  16. package/dist/cjs/card-sortable-list/style.scss +48 -0
  17. package/dist/cjs/confirm-dialog/index.js +59 -0
  18. package/dist/cjs/divider/index.js +42 -0
  19. package/dist/cjs/divider/style.scss +51 -0
  20. package/dist/cjs/form-token-field/style.scss +0 -5
  21. package/dist/cjs/grid/index.js +2 -1
  22. package/dist/cjs/grid/style.scss +63 -9
  23. package/dist/cjs/index.js +42 -0
  24. package/dist/cjs/modal/index.js +11 -4
  25. package/dist/cjs/modal/style.scss +43 -13
  26. package/dist/cjs/newspack-icon/style.scss +5 -3
  27. package/dist/cjs/section-header/index.js +76 -17
  28. package/dist/cjs/section-header/style.scss +109 -4
  29. package/dist/cjs/style.scss +2 -0
  30. package/dist/cjs/waiting/index.js +3 -1
  31. package/dist/cjs/waiting/style.scss +4 -0
  32. package/dist/cjs/web-preview/index.js +98 -39
  33. package/dist/cjs/web-preview/style.scss +20 -53
  34. package/dist/cjs/with-wizard/index.js +1 -1
  35. package/dist/cjs/with-wizard/style.scss +24 -6
  36. package/dist/cjs/with-wizard-screen/style.scss +39 -10
  37. package/dist/cjs/wizard/components/WizardSnackbar.js +70 -0
  38. package/dist/cjs/wizard/components/style.scss +48 -0
  39. package/dist/cjs/wizard/index.js +97 -16
  40. package/dist/cjs/wizard/store/index.js +46 -0
  41. package/dist/esm/action-card/index.js +21 -12
  42. package/dist/esm/action-card/style.scss +25 -2
  43. package/dist/esm/autocomplete-tokenfield/index.js +2 -2
  44. package/dist/esm/autocomplete-with-latest-posts/index.js +281 -0
  45. package/dist/esm/autocomplete-with-latest-posts/style.scss +150 -0
  46. package/dist/esm/badge/index.js +24 -0
  47. package/dist/esm/badge/style.scss +36 -0
  48. package/dist/esm/button/index.js +2 -0
  49. package/dist/esm/card/core-card.js +133 -0
  50. package/dist/esm/card/index.js +33 -0
  51. package/dist/esm/card/style-core.scss +227 -0
  52. package/dist/esm/card/style.scss +2 -2
  53. package/dist/esm/card-settings-group/index.js +42 -0
  54. package/dist/esm/card-settings-group/style.scss +33 -0
  55. package/dist/esm/card-sortable-list/index.js +381 -0
  56. package/dist/esm/card-sortable-list/style.scss +48 -0
  57. package/dist/esm/confirm-dialog/index.js +49 -0
  58. package/dist/esm/divider/index.js +34 -0
  59. package/dist/esm/divider/style.scss +51 -0
  60. package/dist/esm/form-token-field/style.scss +0 -5
  61. package/dist/esm/grid/index.js +2 -1
  62. package/dist/esm/grid/style.scss +63 -9
  63. package/dist/esm/index.js +6 -0
  64. package/dist/esm/modal/index.js +11 -4
  65. package/dist/esm/modal/style.scss +43 -13
  66. package/dist/esm/newspack-icon/style.scss +5 -3
  67. package/dist/esm/section-header/index.js +75 -18
  68. package/dist/esm/section-header/style.scss +109 -4
  69. package/dist/esm/style.scss +2 -0
  70. package/dist/esm/waiting/index.js +3 -1
  71. package/dist/esm/waiting/style.scss +4 -0
  72. package/dist/esm/web-preview/index.js +101 -42
  73. package/dist/esm/web-preview/style.scss +20 -53
  74. package/dist/esm/with-wizard/index.js +1 -1
  75. package/dist/esm/with-wizard/style.scss +24 -6
  76. package/dist/esm/with-wizard-screen/style.scss +39 -10
  77. package/dist/esm/wizard/components/WizardSnackbar.js +64 -0
  78. package/dist/esm/wizard/components/style.scss +48 -0
  79. package/dist/esm/wizard/index.js +101 -20
  80. package/dist/esm/wizard/store/index.js +46 -0
  81. package/package.json +5 -6
  82. package/shared/author-context.js +26 -0
  83. package/shared/hooks/use-coauthors.js +220 -0
  84. package/shared/hooks/use-coauthors.test.js +624 -0
  85. package/shared/hooks/use-custom-byline.js +47 -0
  86. package/shared/hooks/use-custom-byline.test.js +133 -0
  87. package/shared/scss/_mixins.scss +46 -0
  88. package/src/action-card/action-card.d.ts +7 -3
  89. package/src/action-card/index.js +24 -11
  90. package/src/action-card/style.scss +25 -2
  91. package/src/autocomplete-tokenfield/index.js +2 -2
  92. package/src/autocomplete-with-latest-posts/index.js +290 -0
  93. package/src/autocomplete-with-latest-posts/style.scss +150 -0
  94. package/src/badge/index.tsx +24 -0
  95. package/src/badge/style.scss +36 -0
  96. package/src/button/index.tsx +3 -2
  97. package/src/card/core-card.js +147 -0
  98. package/src/card/index.js +39 -1
  99. package/src/card/style-core.scss +227 -0
  100. package/src/card/style.scss +2 -2
  101. package/src/card-settings-group/README.md +43 -0
  102. package/src/card-settings-group/index.tsx +53 -0
  103. package/src/card-settings-group/style.scss +33 -0
  104. package/src/card-sortable-list/README.md +51 -0
  105. package/src/card-sortable-list/index.tsx +412 -0
  106. package/src/card-sortable-list/style.scss +48 -0
  107. package/src/confirm-dialog/index.tsx +64 -0
  108. package/src/divider/README.md +25 -0
  109. package/src/divider/index.js +31 -0
  110. package/src/divider/style.scss +51 -0
  111. package/src/form-token-field/style.scss +0 -5
  112. package/src/grid/index.tsx +2 -1
  113. package/src/grid/style.scss +63 -9
  114. package/src/index.js +6 -0
  115. package/src/modal/index.js +12 -3
  116. package/src/modal/style.scss +43 -13
  117. package/src/newspack-icon/style.scss +5 -3
  118. package/src/section-header/index.js +72 -13
  119. package/src/section-header/style.scss +109 -4
  120. package/src/style.scss +2 -0
  121. package/src/waiting/index.js +2 -1
  122. package/src/waiting/style.scss +4 -0
  123. package/src/web-preview/index.js +90 -35
  124. package/src/web-preview/style.scss +20 -53
  125. package/src/with-wizard/index.js +1 -1
  126. package/src/with-wizard/style.scss +24 -6
  127. package/src/with-wizard-screen/style.scss +39 -10
  128. package/src/wizard/components/WizardSnackbar.js +58 -0
  129. package/src/wizard/components/style.scss +48 -0
  130. package/src/wizard/index.js +108 -14
  131. package/src/wizard/store/index.js +26 -0
@@ -0,0 +1,390 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _components = require("@wordpress/components");
9
+ var _element = require("@wordpress/element");
10
+ var _ = require("../");
11
+ require("./style.scss");
12
+ var _classnames = _interopRequireDefault(require("classnames"));
13
+ var _jsxRuntime = require("react/jsx-runtime");
14
+ /**
15
+ * Card - Sortable list component.
16
+ */
17
+
18
+ /**
19
+ * WordPress dependencies.
20
+ */
21
+ // eslint-disable-line @wordpress/no-unsafe-wp-apis
22
+
23
+ /**
24
+ * Internal dependencies
25
+ */
26
+
27
+ /**
28
+ * External dependencies
29
+ */
30
+
31
+ const DROP_ANIMATION_DURATION = 400; // ms — must match $drop-duration in style.scss
32
+ const BUTTON_MOVE_DURATION = 200; // ms — must match $shift-duration in style.scss
33
+
34
+ const CardSortableList = ({
35
+ disabled = false,
36
+ items = [],
37
+ onDragCallback = () => {}
38
+ }) => {
39
+ const [sortedItems, setSortedItems] = (0, _element.useState)(items);
40
+ const [draggingIndex, setDraggingIndex] = (0, _element.useState)(null);
41
+ const [hoverIndex, setHoverIndex] = (0, _element.useState)(null);
42
+ const [droppedIndex, setDroppedIndex] = (0, _element.useState)(null);
43
+ const [measurements, setMeasurements] = (0, _element.useState)(null);
44
+ const listRef = (0, _element.useRef)(null);
45
+ const itemRefs = (0, _element.useRef)([]);
46
+ const dropAnimationTimer = (0, _element.useRef)(null);
47
+ const buttonMoveTimer = (0, _element.useRef)(null);
48
+ const buttonFlipRef = (0, _element.useRef)(null);
49
+ const [buttonMoveId, setButtonMoveId] = (0, _element.useState)(0);
50
+ const documentDragOverRef = (0, _element.useRef)(null);
51
+
52
+ // Keep sortedItems in sync when the items prop changes externally (e.g. after a save).
53
+ (0, _element.useEffect)(() => {
54
+ setSortedItems(items);
55
+ }, [items]);
56
+
57
+ // Clean up any pending animation timer on unmount.
58
+ (0, _element.useEffect)(() => {
59
+ return () => {
60
+ if (dropAnimationTimer.current) {
61
+ clearTimeout(dropAnimationTimer.current);
62
+ }
63
+ if (buttonMoveTimer.current) {
64
+ clearTimeout(buttonMoveTimer.current);
65
+ }
66
+ if (documentDragOverRef.current) {
67
+ document.removeEventListener('dragover', documentDragOverRef.current);
68
+ }
69
+ };
70
+ }, []);
71
+
72
+ /**
73
+ * Handle a chevron-button move. Records item positions before the reorder so
74
+ * the FLIP animation can play after React commits the new DOM order.
75
+ */
76
+ const handleButtonMove = (fromIndex, toIndex) => {
77
+ if (toIndex < 0 || toIndex >= sortedItems.length) {
78
+ return;
79
+ }
80
+ const fromEl = itemRefs.current[fromIndex];
81
+ const toEl = itemRefs.current[toIndex];
82
+ if (!fromEl || !toEl) {
83
+ return;
84
+ }
85
+ const stride = Math.abs(toEl.getBoundingClientRect().top - fromEl.getBoundingClientRect().top);
86
+ const direction = toIndex > fromIndex ? 1 : -1;
87
+ buttonFlipRef.current = {
88
+ fromIndex,
89
+ toIndex,
90
+ stride,
91
+ direction
92
+ };
93
+ const reordered = [...sortedItems];
94
+ const [moved] = reordered.splice(fromIndex, 1);
95
+ reordered.splice(toIndex, 0, moved);
96
+ setSortedItems(reordered);
97
+ setButtonMoveId(id => id + 1);
98
+ };
99
+
100
+ /**
101
+ * FLIP Invert+Play step: runs synchronously after React commits the reordered
102
+ * DOM. Animate each swapped item from its previous position to its new one
103
+ * using inline CSS transitions (no CSS classes, to avoid creating a new
104
+ * containing block that would break position:fixed on the Draggable clone).
105
+ */
106
+ (0, _element.useLayoutEffect)(() => {
107
+ const flipData = buttonFlipRef.current;
108
+ if (!flipData) {
109
+ return;
110
+ }
111
+ buttonFlipRef.current = null;
112
+ const {
113
+ fromIndex,
114
+ toIndex,
115
+ stride,
116
+ direction
117
+ } = flipData;
118
+ const startAnimation = (el, startY) => {
119
+ if (!el) {
120
+ return;
121
+ }
122
+ // Snap to the starting position with no transition.
123
+ el.style.transition = 'none';
124
+ el.style.transform = `translateY(${startY}px)`;
125
+ // Force a reflow so the browser registers the starting position
126
+ // before we switch to the animated transition.
127
+ el.getBoundingClientRect();
128
+ // Animate from startY back to 0 (its new natural position).
129
+ el.style.transition = `transform ${BUTTON_MOVE_DURATION}ms ease-out`;
130
+ el.style.transform = '';
131
+ };
132
+
133
+ // Moved item is now at toIndex: animate it in from its old position.
134
+ startAnimation(itemRefs.current[toIndex], -direction * stride);
135
+ // Displaced item is now at fromIndex: animate it in from its old position.
136
+ startAnimation(itemRefs.current[fromIndex], direction * stride);
137
+ if (buttonMoveTimer.current) {
138
+ clearTimeout(buttonMoveTimer.current);
139
+ }
140
+ buttonMoveTimer.current = setTimeout(() => {
141
+ // Clear inline animation styles before calling the external callback so
142
+ // the subsequent React re-render doesn't fight a live animation.
143
+ [fromIndex, toIndex].forEach(i => {
144
+ const el = itemRefs.current[i];
145
+ if (el) {
146
+ el.style.transition = '';
147
+ el.style.transform = '';
148
+ }
149
+ });
150
+
151
+ // Move focus to the matching chevron button on the card at toIndex.
152
+ // Focus before onDragCallback so a parent rerender can't steal focus.
153
+ const targetEl = itemRefs.current[toIndex];
154
+ if (targetEl) {
155
+ const moveButtons = targetEl.querySelectorAll('.newspack-card--core__header__draggable-controls__move-buttons button');
156
+ // direction > 0 = moved down → prefer the down button (index 1).
157
+ // direction < 0 = moved up → prefer the up button (index 0).
158
+ const preferred = direction > 0 ? moveButtons[1] : moveButtons[0];
159
+ const fallback = direction > 0 ? moveButtons[0] : moveButtons[1];
160
+ if (preferred && !preferred.disabled) {
161
+ preferred.focus();
162
+ } else if (fallback && !fallback.disabled) {
163
+ fallback.focus();
164
+ }
165
+ }
166
+ onDragCallback(fromIndex, toIndex);
167
+ buttonMoveTimer.current = null;
168
+ }, BUTTON_MOVE_DURATION);
169
+ }, [buttonMoveId]); // eslint-disable-line react-hooks/exhaustive-deps
170
+
171
+ const handleDragStart = index => {
172
+ // Cancel any in-progress button-move animation so no item wrapper keeps
173
+ // an inline transform. A transformed ancestor breaks position:fixed on
174
+ // the Draggable clone (CSS spec: fixed positioning is relative to the
175
+ // nearest ancestor with a transform/filter/perspective).
176
+ if (buttonMoveTimer.current) {
177
+ clearTimeout(buttonMoveTimer.current);
178
+ buttonMoveTimer.current = null;
179
+ itemRefs.current.forEach(el => {
180
+ if (el) {
181
+ el.style.transition = '';
182
+ el.style.transform = '';
183
+ }
184
+ });
185
+ }
186
+ const listEl = listRef.current;
187
+ if (listEl) {
188
+ var _rects$index$height;
189
+ const itemEls = itemRefs.current;
190
+ const rects = itemEls.map(el => el?.getBoundingClientRect());
191
+
192
+ // Stride = item height + gap to next item (difference between consecutive tops).
193
+ const itemStrides = rects.map((rect, i) => {
194
+ if (!rect) {
195
+ return 0;
196
+ }
197
+ const nextRect = rects[i + 1];
198
+ return nextRect ? nextRect.top - rect.top : rect.height;
199
+ });
200
+ setMeasurements({
201
+ lockedHeight: listEl.getBoundingClientRect().height,
202
+ sourceHeight: (_rects$index$height = rects[index]?.height) !== null && _rects$index$height !== void 0 ? _rects$index$height : 0,
203
+ itemStrides,
204
+ itemTops: rects.map(rect => {
205
+ var _rect$top;
206
+ return (_rect$top = rect?.top) !== null && _rect$top !== void 0 ? _rect$top : 0;
207
+ })
208
+ });
209
+ }
210
+ // Make the entire document a valid drop target so the browser skips
211
+ // its snap-back animation when the cursor is released outside the list.
212
+ const preventSnapback = e => e.preventDefault();
213
+ document.addEventListener('dragover', preventSnapback);
214
+ documentDragOverRef.current = preventSnapback;
215
+ setDraggingIndex(index);
216
+ setDroppedIndex(null);
217
+ };
218
+ const clearDragState = () => {
219
+ if (documentDragOverRef.current) {
220
+ document.removeEventListener('dragover', documentDragOverRef.current);
221
+ documentDragOverRef.current = null;
222
+ }
223
+ setDraggingIndex(null);
224
+ setHoverIndex(null);
225
+ setMeasurements(null);
226
+ };
227
+
228
+ /**
229
+ * Determine the drop target index from cursor coordinates and the item
230
+ * top positions snapshotted at drag start. Mirrors the midpoint logic
231
+ * previously used in getDropIndex but works without a live event target.
232
+ */
233
+ const getDropIndexFromCursor = (clientY, m, sourceIndex) => {
234
+ const {
235
+ itemTops,
236
+ itemStrides,
237
+ sourceHeight
238
+ } = m;
239
+ for (let i = 0; i < itemTops.length; i++) {
240
+ const movingDown = sourceIndex > i;
241
+ const midpoint = itemTops[i] + (movingDown ? itemStrides[i] : itemStrides[i] - sourceHeight);
242
+ if (clientY < midpoint) {
243
+ return i;
244
+ }
245
+ }
246
+ return itemTops.length; // below all items
247
+ };
248
+ const handleDragEnd = event => {
249
+ // Take a local copy of measurements before clearDragState nulls it.
250
+ const m = measurements;
251
+ const sourceIndex = draggingIndex;
252
+ clearDragState();
253
+ if (m === null || sourceIndex === null) {
254
+ return;
255
+ }
256
+ const dropIndex = getDropIndexFromCursor(event.clientY, m, sourceIndex);
257
+
258
+ // Compute the destination index in the post-removal array.
259
+ // After splicing out the dragged item, indices above it shift down by one.
260
+ const insertIndex = dropIndex > sourceIndex ? dropIndex - 1 : dropIndex;
261
+ if (insertIndex === sourceIndex) {
262
+ return;
263
+ }
264
+ const reordered = [...sortedItems];
265
+ const [moved] = reordered.splice(sourceIndex, 1);
266
+ reordered.splice(insertIndex, 0, moved);
267
+
268
+ // First render: show items in their new order with no animation.
269
+ // The dragging CSS classes are already cleared by clearDragState() above,
270
+ // so no transitions will fire on this paint.
271
+ setSortedItems(reordered);
272
+
273
+ // Next frame: trigger the drop animation on the newly-positioned item,
274
+ // then call onDragCallback after the animation completes.
275
+ requestAnimationFrame(() => {
276
+ setDroppedIndex(insertIndex);
277
+ dropAnimationTimer.current = setTimeout(() => {
278
+ setDroppedIndex(null);
279
+ onDragCallback(sourceIndex, insertIndex);
280
+ }, DROP_ANIMATION_DURATION);
281
+ });
282
+ };
283
+ const handleDragOver = (event, index) => {
284
+ event.preventDefault();
285
+ if (!measurements) {
286
+ return;
287
+ }
288
+ const rect = event.currentTarget.getBoundingClientRect();
289
+ const midpoint = rect.top + rect.height / 2;
290
+ setHoverIndex(event.clientY < midpoint ? index : index + 1);
291
+ };
292
+
293
+ /**
294
+ * Compute the translateY for a non-source item at `index` given the current
295
+ * draggingIndex and hoverIndex, so that items visually shift to show the gap
296
+ * while the container's layout height stays fixed.
297
+ *
298
+ * The source item has been visually hidden but still occupies its layout slot.
299
+ * Items between the source and the hover position need to slide by the source
300
+ * item's stride (height + gap) to either fill the vacated source slot or make
301
+ * room for the incoming gap at the hover position.
302
+ */
303
+ const getTranslateY = index => {
304
+ var _itemStrides$dragging;
305
+ if (draggingIndex === null || hoverIndex === null || !measurements) {
306
+ return 0;
307
+ }
308
+ if (index === draggingIndex) {
309
+ return 0;
310
+ }
311
+ const {
312
+ itemStrides,
313
+ sourceHeight
314
+ } = measurements;
315
+ const sourceStride = (_itemStrides$dragging = itemStrides[draggingIndex]) !== null && _itemStrides$dragging !== void 0 ? _itemStrides$dragging : sourceHeight;
316
+ if (hoverIndex > draggingIndex) {
317
+ // Dragging downward: items strictly between source and hover position slide up.
318
+ if (index > draggingIndex && index < hoverIndex) {
319
+ return -sourceStride;
320
+ }
321
+ } else if (index >= hoverIndex && index < draggingIndex) {
322
+ // Dragging upward: items between hover position and source slide down.
323
+ return sourceStride;
324
+ }
325
+ return 0;
326
+ };
327
+ const isDragging = draggingIndex !== null;
328
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalVStack, {
329
+ ref: listRef,
330
+ className: (0, _classnames.default)('newspack-card--core--sortable-list', disabled && 'newspack-card--core--sortable-list__is-disabled', isDragging && 'newspack-card--core--sortable-list__is-dragging'),
331
+ style: measurements ? {
332
+ height: measurements.lockedHeight
333
+ } : undefined,
334
+ spacing: 4,
335
+ children: sortedItems.map((item, index) => {
336
+ const translateY = getTranslateY(index);
337
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Disabled, {
338
+ isDisabled: disabled,
339
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
340
+ ref: el => {
341
+ itemRefs.current[index] = el;
342
+ },
343
+ className: (0, _classnames.default)('newspack-card--core--sortable-list__item', {
344
+ 'is-source': draggingIndex === index,
345
+ 'is-dropped': droppedIndex === index
346
+ }),
347
+ style: translateY ? {
348
+ transform: `translateY(${translateY}px)`
349
+ } : {
350
+ transition: !isDragging ? 'none' : undefined
351
+ },
352
+ id: `draggable-card-${index}`,
353
+ onDragOver: e => handleDragOver(e, index),
354
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Draggable, {
355
+ transferData: {},
356
+ cloneClassname: "newspack-card--core--sortable-list__item__clone",
357
+ elementId: `draggable-card-${index}`,
358
+ onDragStart: () => handleDragStart(index),
359
+ onDragEnd: handleDragEnd,
360
+ appendToOwnerDocument: true,
361
+ children: ({
362
+ onDraggableStart,
363
+ onDraggableEnd
364
+ }) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_.Card, {
365
+ isSmall: true,
366
+ draggable: true,
367
+ onDragStart: onDraggableStart,
368
+ onDragEnd: onDraggableEnd,
369
+ __experimentalCoreCard: true,
370
+ __experimentalCoreProps: {
371
+ header: /*#__PURE__*/(0, _jsxRuntime.jsxs)("h3", {
372
+ children: [item.title, /*#__PURE__*/(0, _jsxRuntime.jsx)(_.Badge, {
373
+ level: item.badgeLevel,
374
+ text: item.badgeText
375
+ })]
376
+ }),
377
+ isDraggable: true,
378
+ isFirstTarget: index === 0,
379
+ isLastTarget: index === sortedItems.length - 1,
380
+ dragIndex: index,
381
+ onDragCallback: handleButtonMove
382
+ }
383
+ })
384
+ })
385
+ })
386
+ }, item.id);
387
+ })
388
+ });
389
+ };
390
+ var _default = exports.default = CardSortableList;
@@ -0,0 +1,48 @@
1
+ $collapse-duration: 200ms;
2
+ $shift-duration: 150ms;
3
+ $drop-duration: 400ms; /* must match DROP_ANIMATION_DURATION in index.tsx */
4
+
5
+ .newspack-card--core--sortable-list {
6
+ &__item {
7
+ cursor: grab;
8
+
9
+ /*
10
+ * Animate items sliding to fill/make space around the dragged item.
11
+ */
12
+ transition: transform $shift-duration ease;
13
+
14
+ /*
15
+ * Collapse the source item's content — the wrapper stays in layout as the
16
+ * anchor point, and the container height is locked via inline style in JS.
17
+ */
18
+ &.is-source {
19
+ cursor: grabbing;
20
+ opacity: 0;
21
+ transition: opacity $collapse-duration ease;
22
+ }
23
+
24
+ /*
25
+ * Drop landing animation: brief fade-in and scale on the newly placed item.
26
+ */
27
+ &.is-dropped {
28
+ animation: newspack-sortable-drop $drop-duration ease forwards;
29
+ opacity: 0;
30
+ }
31
+
32
+ }
33
+ }
34
+
35
+ @keyframes newspack-sortable-drop {
36
+ 0% {
37
+ opacity: 0;
38
+ transform: scale(0.98);
39
+ }
40
+ 60% {
41
+ opacity: 1;
42
+ transform: scale(1.01);
43
+ }
44
+ 100% {
45
+ opacity: 1;
46
+ transform: scale(1);
47
+ }
48
+ }
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _element = require("@wordpress/element");
9
+ var _components = require("@wordpress/components");
10
+ var _classnames = _interopRequireDefault(require("classnames"));
11
+ var _jsxRuntime = require("react/jsx-runtime");
12
+ /**
13
+ * Modal
14
+ */
15
+
16
+ /**
17
+ * WordPress dependencies.
18
+ */
19
+
20
+ // eslint-disable-line @wordpress/no-unsafe-wp-apis
21
+
22
+ /**
23
+ * External dependencies.
24
+ */
25
+
26
+ /*
27
+ * See both https://wordpress.github.io/gutenberg/?path=/docs/components-confirmdialog--docs and
28
+ * https://wordpress.github.io/gutenberg/?path=/docs/components-modal--docs for all supported props.
29
+ */
30
+
31
+ const sizeClassMap = {
32
+ small: 'newspack-modal--size-small',
33
+ medium: 'newspack-modal--size-medium',
34
+ large: 'newspack-modal--size-large',
35
+ 'x-large': 'newspack-modal--size-x-large',
36
+ full: 'newspack-modal--size-full'
37
+ };
38
+ function ConfirmDialog({
39
+ className,
40
+ size = 'small',
41
+ hideTitle,
42
+ isDestructive,
43
+ onConfirm,
44
+ onCancel,
45
+ ...otherProps
46
+ }, ref) {
47
+ const classes = (0, _classnames.default)('newspack-modal', sizeClassMap[size], hideTitle && 'newspack-modal--hide-title',
48
+ // Note: also hides the X close button.
49
+ isDestructive && 'newspack-modal--destructive', className);
50
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalConfirmDialog, {
51
+ className: classes,
52
+ ...otherProps,
53
+ ref: ref,
54
+ onConfirm: onConfirm,
55
+ onCancel: onCancel,
56
+ __experimentalHideHeader: false
57
+ });
58
+ }
59
+ var _default = exports.default = (0, _element.forwardRef)(ConfirmDialog);
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ require("./style.scss");
9
+ var _classnames = _interopRequireDefault(require("classnames"));
10
+ var _jsxRuntime = require("react/jsx-runtime");
11
+ /**
12
+ * Divider
13
+ */
14
+
15
+ /**
16
+ * Internal dependencies
17
+ */
18
+
19
+ /**
20
+ * External dependencies
21
+ */
22
+
23
+ const Divider = ({
24
+ alignment = 'none',
25
+ className = undefined,
26
+ marginBottom = 64,
27
+ marginTop = 64,
28
+ variant = 'default',
29
+ ...otherProps
30
+ }) => {
31
+ const classes = (0, _classnames.default)('newspack-divider', className, alignment && `newspack-divider--alignment-${alignment}`, variant && `newspack-divider--variant-${variant}`);
32
+ const style = {
33
+ '--divider-margin-bottom': typeof marginBottom === 'number' ? `${marginBottom}px` : marginBottom,
34
+ '--divider-margin-top': typeof marginTop === 'number' ? `${marginTop}px` : marginTop
35
+ };
36
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("hr", {
37
+ className: classes,
38
+ style: style,
39
+ ...otherProps
40
+ });
41
+ };
42
+ var _default = exports.default = Divider;
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Divider
3
+ */
4
+
5
+ @use "~@wordpress/base-styles/colors" as wp-colors;
6
+
7
+ .newspack-divider {
8
+ background: transparent;
9
+ border: 0;
10
+ display: block;
11
+ height: 1px;
12
+ margin-bottom: min(32px, var(--divider-margin-bottom, 64px));
13
+ margin-left: 0;
14
+ margin-right: 0;
15
+ margin-top: min(32px, var(--divider-margin-top, 64px));
16
+ padding: 0;
17
+
18
+ @media screen and (min-width: 783px) {
19
+ margin-bottom: var(--divider-margin-bottom, 64px);
20
+ margin-top: var(--divider-margin-top, 64px);
21
+ }
22
+
23
+ // Alignment
24
+
25
+ &--alignment-full-width {
26
+ margin-left: calc(-50vw + 50%);
27
+ width: 100vw;
28
+ }
29
+
30
+ &--alignment-none {
31
+ width: 100%;
32
+ }
33
+
34
+ // Variant
35
+
36
+ &--variant-default {
37
+ background-color: wp-colors.$gray-300;
38
+ }
39
+
40
+ &--variant-primary {
41
+ background-color: var(--wp-admin-theme-color);
42
+ }
43
+
44
+ &--variant-secondary {
45
+ background-color: wp-colors.$gray-900;
46
+ }
47
+
48
+ &--variant-tertiary {
49
+ background-color: wp-colors.$gray-100;
50
+ }
51
+ }
@@ -7,11 +7,6 @@
7
7
  .newspack-form-token-field {
8
8
  width: 100%;
9
9
 
10
- .components-form-token-field__input-container {
11
- padding-bottom: 1px;
12
- padding-top: 1px;
13
- }
14
-
15
10
  // Help
16
11
 
17
12
  &__help {
@@ -22,13 +22,14 @@ var _jsxRuntime = require("react/jsx-runtime");
22
22
 
23
23
  const Grid = ({
24
24
  className = '',
25
+ borders = false,
25
26
  columns = 2,
26
27
  gutter = 32,
27
28
  noMargin = false,
28
29
  rowGap = 0,
29
30
  ...otherProps
30
31
  }) => {
31
- const classes = (0, _classnames.default)('newspack-grid', noMargin && 'newspack-grid--no-margin', columns && 'newspack-grid__columns-' + columns, gutter && 'newspack-grid__gutter-' + gutter, rowGap && 'newspack-grid__row-gap-' + rowGap, className);
32
+ const classes = (0, _classnames.default)('newspack-grid', borders && 'newspack-grid__borders', noMargin && 'newspack-grid--no-margin', columns && 'newspack-grid__columns-' + columns, gutter && 'newspack-grid__gutter-' + gutter, rowGap && 'newspack-grid__row-gap-' + rowGap, className);
32
33
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
33
34
  className: classes,
34
35
  ...otherProps