@valu/block-components 0.4.0 → 0.5.1

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/README.md CHANGED
@@ -16,9 +16,23 @@ accessible by default.
16
16
  npm ci
17
17
  ```
18
18
 
19
- Peer dependencies: `react ^18.3`, `react-dom ^18.3`, and the
20
- `@wordpress/*` packages listed in `package.json` (available in any
21
- modern Gutenberg/WP 6.4+ environment).
19
+ ### Requirements
20
+
21
+ - **WordPress 7.0 or newer.** The components use the `@wordpress/*` packages
22
+ that WordPress ships at runtime.
23
+ - **A build that externalizes WordPress packages**, such as `@wordpress/scripts`
24
+ or `@wordpress/dependency-extraction-webpack-plugin`. The `@wordpress/*`
25
+ imports are left bare in `dist/` and must resolve to the `wp.*` globals, so
26
+ every plugin on the page shares the editor's copy.
27
+ - **Peer dependencies:** `react ^18.3` and `react-dom ^18.3`.
28
+
29
+ The `@wordpress/*` packages are intentionally not declared as peer
30
+ dependencies: npm would check them against your `node_modules`, while the
31
+ version that actually runs is the one WordPress provides. `@wordpress/icons`
32
+ is a regular dependency because WordPress doesn't provide it at runtime.
33
+
34
+ If you use TypeScript or run unit tests that import this package, install the
35
+ `@wordpress/*` packages you use as your own `devDependencies`.
22
36
 
23
37
  ## Quickstart
24
38
 
@@ -60,6 +60,7 @@ var tokens = {
60
60
  transitionFast: "120ms ease-out",
61
61
  fontSizeBody: "13px",
62
62
  fontSizeSmall: "11px",
63
+ fontWeightRegular: 400,
63
64
  fontWeightMedium: 500,
64
65
  fontWeightBold: 600
65
66
  };
@@ -78,6 +79,8 @@ react.css`
78
79
  white-space: nowrap;
79
80
  `;
80
81
  var Root = styled__default.default.div`
82
+ width: 100%;
83
+ min-width: 0;
81
84
  color: ${tokens.fg};
82
85
  font-size: ${tokens.fontSizeBody};
83
86
 
@@ -200,6 +203,11 @@ var PrimaryText = styled__default.default.span`
200
203
  line-height: 1.3;
201
204
  transition: color ${tokens.transitionFast};
202
205
  `;
206
+ var SelectedTitle = styled__default.default(PrimaryText)`
207
+ font-weight: ${tokens.fontWeightRegular};
208
+ white-space: normal;
209
+ overflow-wrap: anywhere;
210
+ `;
203
211
  var Option = styled__default.default.li`
204
212
  display: flex;
205
213
  align-items: center;
@@ -309,6 +317,10 @@ var ActionColumn = styled__default.default.div`
309
317
  gap: ${tokens.spaceXs};
310
318
  margin-left: auto;
311
319
  `;
320
+ var ReorderStack = styled__default.default.span`
321
+ display: flex;
322
+ flex-direction: column;
323
+ `;
312
324
  var SelectedListEl = styled__default.default.ul`
313
325
  list-style: none;
314
326
  margin: ${tokens.spaceSm} 0 0;
@@ -320,8 +332,8 @@ var SelectedListEl = styled__default.default.ul`
320
332
  var SelectedRow = styled__default.default.li`
321
333
  display: flex;
322
334
  align-items: center;
323
- gap: ${tokens.spaceSm};
324
- padding: 2px ${tokens.spaceSm};
335
+ gap: ${tokens.spaceXs};
336
+ padding: 6px ${tokens.spaceXs};
325
337
  background: ${({ missing }) => missing ? tokens.dangerSoft : tokens.bg};
326
338
  border: 1px solid ${({ missing }) => missing ? tokens.dangerLine : tokens.gray300};
327
339
  border-radius: ${tokens.radiusMd};
@@ -1679,11 +1691,11 @@ var SelectedItem = ({
1679
1691
  children: isMissing || isTrash ? /* @__PURE__ */ jsxRuntime.jsx(components.Icon, { icon: icons.caution, size: 22 }) : hasThumbImage ? /* @__PURE__ */ jsxRuntime.jsx("img", { src: item.thumbnailUrl, alt: "", loading: "lazy" }) : resolvedIcon ? /* @__PURE__ */ jsxRuntime.jsx(components.Icon, { icon: resolvedIcon, size: 22 }) : null
1680
1692
  }
1681
1693
  ) : null,
1682
- render ? render(item) : /* @__PURE__ */ jsxRuntime.jsx(ItemBody, { children: /* @__PURE__ */ jsxRuntime.jsx(PrimaryText, { muted: isMissing || isTrash, title: item.title, children: isMissing ? missingLabel : isTrash ? trashLabel : item.title }) }),
1694
+ render ? render(item) : /* @__PURE__ */ jsxRuntime.jsx(ItemBody, { children: /* @__PURE__ */ jsxRuntime.jsx(SelectedTitle, { muted: isMissing || isTrash, title: item.title, children: isMissing ? missingLabel : isTrash ? trashLabel : item.title }) }),
1683
1695
  !isMissing && showTypeBadge ? /* @__PURE__ */ jsxRuntime.jsx(TypeBadge, { type: item.type, kind: item.kind }) : null,
1684
1696
  !isMissing && hasAbnormalStatus ? /* @__PURE__ */ jsxRuntime.jsx(StatusBadge, { status: item.status }) : null,
1685
1697
  /* @__PURE__ */ jsxRuntime.jsxs(ActionColumn, { children: [
1686
- orderable ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1698
+ orderable ? /* @__PURE__ */ jsxRuntime.jsxs(ReorderStack, { children: [
1687
1699
  /* @__PURE__ */ jsxRuntime.jsx(
1688
1700
  components.Button,
1689
1701
  {
@@ -1760,10 +1772,7 @@ var useResolvedItems = (value) => {
1760
1772
  nameKey,
1761
1773
  item.id
1762
1774
  ]);
1763
- out[`${item.kind}:${item.type}:${item.id}`] = {
1764
- record: record ?? null,
1765
- resolved
1766
- };
1775
+ out[`${item.kind}:${item.type}:${item.id}`] = resolved ? record ?? null : void 0;
1767
1776
  }
1768
1777
  return out;
1769
1778
  },
@@ -1771,10 +1780,8 @@ var useResolvedItems = (value) => {
1771
1780
  );
1772
1781
  return react$1.useMemo(
1773
1782
  () => value.map((item) => {
1774
- const resolvedEntry = records[`${item.kind}:${item.type}:${item.id}`];
1775
- if (!resolvedEntry) return item;
1776
- const { record, resolved } = resolvedEntry;
1777
- if (!resolved) {
1783
+ const record = records[`${item.kind}:${item.type}:${item.id}`];
1784
+ if (record === void 0) {
1778
1785
  return item;
1779
1786
  }
1780
1787
  if (!record) {