@propeller-commerce/propeller-v2-react-ui 0.15.4 → 0.15.6

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/dist/index.d.cts CHANGED
@@ -3536,6 +3536,8 @@ interface CategoryDescriptionProps {
3536
3536
  maxLength?: number;
3537
3537
  /** Extra CSS class applied to the root element. */
3538
3538
  className?: string;
3539
+ /** Translated labels: `readMore`, `readLess`. */
3540
+ labels?: Record<string, string>;
3539
3541
  }
3540
3542
  /**
3541
3543
  * Renders a category's localised HTML description, optionally truncated with a
@@ -6083,6 +6085,8 @@ interface ProductDescriptionProps {
6083
6085
  maxLength?: number;
6084
6086
  /** Extra CSS class applied to the root element. */
6085
6087
  className?: string;
6088
+ /** Translated labels: `readMore`, `readLess`. */
6089
+ labels?: Record<string, string>;
6086
6090
  }
6087
6091
  /**
6088
6092
  * Renders a product's localised HTML description, optionally collapsed to a
package/dist/index.d.ts CHANGED
@@ -3536,6 +3536,8 @@ interface CategoryDescriptionProps {
3536
3536
  maxLength?: number;
3537
3537
  /** Extra CSS class applied to the root element. */
3538
3538
  className?: string;
3539
+ /** Translated labels: `readMore`, `readLess`. */
3540
+ labels?: Record<string, string>;
3539
3541
  }
3540
3542
  /**
3541
3543
  * Renders a category's localised HTML description, optionally truncated with a
@@ -6083,6 +6085,8 @@ interface ProductDescriptionProps {
6083
6085
  maxLength?: number;
6084
6086
  /** Extra CSS class applied to the root element. */
6085
6087
  className?: string;
6088
+ /** Translated labels: `readMore`, `readLess`. */
6089
+ labels?: Record<string, string>;
6086
6090
  }
6087
6091
  /**
6088
6092
  * Renders a product's localised HTML description, optionally collapsed to a
package/dist/index.js CHANGED
@@ -1572,15 +1572,15 @@ function buildCategoriesQuery(depth) {
1572
1572
  categories {
1573
1573
  categoryId
1574
1574
  hidden
1575
- names(language: $language) { value language }
1576
- slugs(language: $language) { value }
1575
+ names { value language }
1576
+ slugs { value language }
1577
1577
  ${buildCategoriesQuery(depth - 1)}
1578
1578
  }
1579
1579
  `;
1580
1580
  }
1581
1581
  function mapCategory(raw, language) {
1582
1582
  const nameEntry = raw.names?.find((n) => n.language === language) ?? raw.names?.[0];
1583
- const slugEntry = raw.slugs?.[0];
1583
+ const slugEntry = raw.slugs?.find((s) => s.language === language) ?? raw.slugs?.[0];
1584
1584
  return {
1585
1585
  categoryId: raw.categoryId,
1586
1586
  name: nameEntry?.value ?? "",
@@ -1656,17 +1656,17 @@ function useMenu(options) {
1656
1656
  inflightFetches.set(key, promise);
1657
1657
  try {
1658
1658
  const gql = `
1659
- query Menu($categoryId: Float, $language: String) {
1659
+ query Menu($categoryId: Float) {
1660
1660
  category(categoryId: $categoryId) {
1661
1661
  categoryId
1662
1662
  hidden
1663
- names(language: $language) { value language }
1664
- slugs(language: $language) { value }
1663
+ names { value language }
1664
+ slugs { value language }
1665
1665
  ${buildCategoriesQuery(depth)}
1666
1666
  }
1667
1667
  }
1668
1668
  `;
1669
- const variables = { categoryId: rootCategoryId, language };
1669
+ const variables = { categoryId: rootCategoryId };
1670
1670
  const data = await graphqlClient.query(gql, variables);
1671
1671
  const root = data?.category ?? null;
1672
1672
  const items = root ? (root.categories ?? []).filter((cat) => !isHidden(cat)).map((cat) => mapCategory(cat, language)) : [];
@@ -4161,10 +4161,7 @@ function AccountIconAndMenu(rawProps) {
4161
4161
  )
4162
4162
  }
4163
4163
  ),
4164
- props.user ? /* @__PURE__ */ jsxs("span", { className: "propeller-account-menu__greeting hidden md:block font-normal", children: [
4165
- "Hi, ",
4166
- getUserName()
4167
- ] }) : null,
4164
+ props.user ? /* @__PURE__ */ jsx("span", { className: "propeller-account-menu__greeting hidden md:block font-normal", children: getLabel(props.labels, "greeting", "Hi, {name}").replace("{name}", getUserName()) }) : null,
4168
4165
  !props.user ? /* @__PURE__ */ jsx("span", { className: "propeller-account-menu__greeting hidden md:block font-normal", children: getLabel(props.labels, "accountLabel", "Account") }) : null
4169
4166
  ]
4170
4167
  }
@@ -7975,7 +7972,7 @@ function CategoryDescription(props) {
7975
7972
  type: "button",
7976
7973
  className: "propeller-category-description__toggle mt-2 text-sm font-medium text-primary hover:underline",
7977
7974
  onClick: () => setExpanded((v) => !v),
7978
- children: expanded ? "Read less" : "Read more"
7975
+ children: expanded ? getLabel(props.labels, "readLess", "Read less") : getLabel(props.labels, "readMore", "Read more")
7979
7976
  }
7980
7977
  ) : null
7981
7978
  ]
@@ -9892,7 +9889,7 @@ function GridToolbar(rawProps) {
9892
9889
  const [currentSortOrder, setCurrentSortOrder] = useState(SortOrder.DESC);
9893
9890
  const [currentOffset, setCurrentOffset] = useState(12);
9894
9891
  const [currentViewMode, setCurrentViewMode] = useState("grid");
9895
- function getLabel56(key) {
9892
+ function getLabel59(key) {
9896
9893
  const labels = props.labels || {};
9897
9894
  return labels[key] !== void 0 ? labels[key] : DEFAULT_LABELS[key] || key;
9898
9895
  }
@@ -9930,8 +9927,8 @@ function GridToolbar(rawProps) {
9930
9927
  }
9931
9928
  function getAvailabilityLabel() {
9932
9929
  const qty = props.minStock;
9933
- if (qty !== void 0 && qty > MIN_STOCK_THRESHOLD) return `${getLabel56("inStock")}: ${qty}+`;
9934
- return getLabel56("inStock");
9930
+ if (qty !== void 0 && qty > MIN_STOCK_THRESHOLD) return `${getLabel59("inStock")}: ${qty}+`;
9931
+ return getLabel59("inStock");
9935
9932
  }
9936
9933
  function handleSortFieldChange(field) {
9937
9934
  setCurrentSortField(field);
@@ -9977,7 +9974,7 @@ function GridToolbar(rawProps) {
9977
9974
  /* @__PURE__ */ jsx("div", { className: "propeller-grid-toolbar__count text-sm text-muted-foreground font-medium", children: props.itemsFound > 0 ? /* @__PURE__ */ jsxs("span", { children: [
9978
9975
  props.itemsFound,
9979
9976
  "\xA0",
9980
- props.itemsFound === 1 ? getLabel56("productSingular") : getLabel56("productPlural")
9977
+ props.itemsFound === 1 ? getLabel59("productSingular") : getLabel59("productPlural")
9981
9978
  ] }) : null }),
9982
9979
  /* @__PURE__ */ jsxs("div", { className: "propeller-grid-toolbar__controls flex flex-wrap items-center gap-3", children: [
9983
9980
  /* @__PURE__ */ jsx(
@@ -9988,7 +9985,7 @@ function GridToolbar(rawProps) {
9988
9985
  onChange: (e) => handleOffsetChange(parseInt(e.target.value)),
9989
9986
  children: getOffsetOptions()?.map((n) => /* @__PURE__ */ jsxs("option", { value: n, children: [
9990
9987
  n,
9991
- getLabel56("perPage")
9988
+ getLabel59("perPage")
9992
9989
  ] }, n))
9993
9990
  }
9994
9991
  ),
@@ -10004,7 +10001,7 @@ function GridToolbar(rawProps) {
10004
10001
  {
10005
10002
  value: field,
10006
10003
  disabled: field === "PRICE" && isPriceSortDisabled(),
10007
- children: getLabel56(field)
10004
+ children: getLabel59(field)
10008
10005
  },
10009
10006
  field
10010
10007
  ))
@@ -10017,8 +10014,8 @@ function GridToolbar(rawProps) {
10017
10014
  value: currentSortOrder,
10018
10015
  onChange: (e) => handleSortOrderChange(e.target.value),
10019
10016
  children: [
10020
- /* @__PURE__ */ jsx("option", { value: SortOrder.ASC, children: getLabel56("ASC") }),
10021
- /* @__PURE__ */ jsx("option", { value: SortOrder.DESC, children: getLabel56("DESC") })
10017
+ /* @__PURE__ */ jsx("option", { value: SortOrder.ASC, children: getLabel59("ASC") }),
10018
+ /* @__PURE__ */ jsx("option", { value: SortOrder.DESC, children: getLabel59("DESC") })
10022
10019
  ]
10023
10020
  }
10024
10021
  ),
@@ -10028,7 +10025,7 @@ function GridToolbar(rawProps) {
10028
10025
  type: "button",
10029
10026
  className: "propeller-grid-toolbar__view-toggle h-9 w-9 flex items-center justify-center rounded-control border border-input bg-transparent hover:bg-accent hover:text-accent-foreground transition-colors",
10030
10027
  onClick: (event) => handleViewChange(),
10031
- title: currentViewMode === "grid" ? getLabel56("switchToList") : getLabel56("switchToGrid"),
10028
+ title: currentViewMode === "grid" ? getLabel59("switchToList") : getLabel59("switchToGrid"),
10032
10029
  children: [
10033
10030
  currentViewMode === "grid" ? /* @__PURE__ */ jsxs(
10034
10031
  "svg",
@@ -10086,7 +10083,7 @@ function GridToolbar(rawProps) {
10086
10083
  onClick: (event) => {
10087
10084
  if (props.onClearFilters) props.onClearFilters();
10088
10085
  },
10089
- children: getLabel56("clearAll")
10086
+ children: getLabel59("clearAll")
10090
10087
  }
10091
10088
  ),
10092
10089
  props.priceFilterMin !== void 0 || props.priceFilterMax !== void 0 ? /* @__PURE__ */ jsxs(
@@ -10097,7 +10094,7 @@ function GridToolbar(rawProps) {
10097
10094
  if (props.onPriceFilterRemove) props.onPriceFilterRemove();
10098
10095
  },
10099
10096
  children: [
10100
- getLabel56("price"),
10097
+ getLabel59("price"),
10101
10098
  ": \u20AC",
10102
10099
  props.priceFilterMin ?? 0,
10103
10100
  " \u2013 \u20AC",
@@ -10147,7 +10144,7 @@ var DEFAULT_LABELS2 = {
10147
10144
  of: "of"
10148
10145
  };
10149
10146
  function GridPagination(props) {
10150
- function getLabel56(key) {
10147
+ function getLabel59(key) {
10151
10148
  const labels = props.labels || {};
10152
10149
  return labels[key] !== void 0 ? labels[key] : DEFAULT_LABELS2[key] || key;
10153
10150
  }
@@ -10220,15 +10217,15 @@ function GridPagination(props) {
10220
10217
  className: "propeller-grid-pagination__btn propeller-grid-pagination__btn--prev inline-flex items-center rounded-control border border-input bg-card px-4 py-2 text-sm font-medium text-foreground shadow-sm hover:bg-surface-hover disabled:opacity-40 disabled:cursor-not-allowed",
10221
10218
  disabled: currentPage === 1,
10222
10219
  onClick: () => handlePageChange(currentPage - 1),
10223
- children: getLabel56("previous")
10220
+ children: getLabel59("previous")
10224
10221
  }
10225
10222
  ),
10226
10223
  /* @__PURE__ */ jsxs("span", { className: "propeller-grid-pagination__info px-2 text-sm font-medium text-muted-foreground", children: [
10227
- getLabel56("page"),
10224
+ getLabel59("page"),
10228
10225
  "\xA0",
10229
10226
  currentPage,
10230
10227
  "\xA0",
10231
- getLabel56("of"),
10228
+ getLabel59("of"),
10232
10229
  "\xA0",
10233
10230
  totalPages
10234
10231
  ] }),
@@ -10239,7 +10236,7 @@ function GridPagination(props) {
10239
10236
  className: "propeller-grid-pagination__btn propeller-grid-pagination__btn--next inline-flex items-center rounded-control border border-input bg-card px-4 py-2 text-sm font-medium text-foreground shadow-sm hover:bg-surface-hover disabled:opacity-40 disabled:cursor-not-allowed",
10240
10237
  disabled: currentPage === totalPages,
10241
10238
  onClick: () => handlePageChange(currentPage + 1),
10242
- children: getLabel56("next")
10239
+ children: getLabel59("next")
10243
10240
  }
10244
10241
  )
10245
10242
  ] }) : null,
@@ -10251,7 +10248,7 @@ function GridPagination(props) {
10251
10248
  className: "propeller-grid-pagination__btn propeller-grid-pagination__btn--prev inline-flex items-center rounded-control border border-input bg-card px-3 py-2 text-sm font-medium text-foreground shadow-sm hover:bg-surface-hover disabled:opacity-40 disabled:cursor-not-allowed",
10252
10249
  disabled: currentPage === 1,
10253
10250
  onClick: () => handlePageChange(currentPage - 1),
10254
- children: getLabel56("previous")
10251
+ children: getLabel59("previous")
10255
10252
  }
10256
10253
  ),
10257
10254
  getFullPages().map((item, idx) => /* @__PURE__ */ jsx(
@@ -10278,7 +10275,7 @@ function GridPagination(props) {
10278
10275
  className: "propeller-grid-pagination__btn propeller-grid-pagination__btn--next inline-flex items-center rounded-control border border-input bg-card px-3 py-2 text-sm font-medium text-foreground shadow-sm hover:bg-surface-hover disabled:opacity-40 disabled:cursor-not-allowed",
10279
10276
  disabled: currentPage === totalPages,
10280
10277
  onClick: () => handlePageChange(currentPage + 1),
10281
- children: getLabel56("next")
10278
+ children: getLabel59("next")
10282
10279
  }
10283
10280
  )
10284
10281
  ] }) : null
@@ -10417,7 +10414,7 @@ function MachineGrid(rawProps) {
10417
10414
  const cards = rootMachines.map((m) => ({ machine: m, href: childSlugHref(m) })).filter((c) => c.href !== null);
10418
10415
  return /* @__PURE__ */ jsxs("div", { className: rawProps.className, children: [
10419
10416
  /* @__PURE__ */ jsx("h1", { className: "propeller-grid-title mb-6 text-2xl font-semibold", children: rawProps.rootTitle ?? "Machines" }),
10420
- rootLoading ? /* @__PURE__ */ jsx("p", { className: "py-12 text-center text-foreground-subtle", children: "Loading\u2026" }) : cards.length === 0 ? /* @__PURE__ */ jsx("p", { className: "py-12 text-center text-foreground-subtle", children: "No machines found." }) : /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4", children: cards.map(({ machine: m, href }) => /* @__PURE__ */ jsx(
10417
+ rootLoading ? /* @__PURE__ */ jsx("p", { className: "py-12 text-center text-foreground-subtle", children: getLabel(rawProps.machineCardLabels, "loading", "Loading\u2026") }) : cards.length === 0 ? /* @__PURE__ */ jsx("p", { className: "py-12 text-center text-foreground-subtle", children: getLabel(rawProps.machineCardLabels, "noMachines", "No machines found.") }) : /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4", children: cards.map(({ machine: m, href }) => /* @__PURE__ */ jsx(
10421
10418
  MachineCard,
10422
10419
  {
10423
10420
  machine: m,
@@ -15416,7 +15413,7 @@ function ProductDescription(props) {
15416
15413
  type: "button",
15417
15414
  className: "propeller-product-description__toggle mt-2 text-sm font-medium text-primary hover:underline",
15418
15415
  onClick: () => setExpanded((v) => !v),
15419
- children: expanded ? "Read less" : "Read more"
15416
+ children: expanded ? getLabel(props.labels, "readLess", "Read less") : getLabel(props.labels, "readMore", "Read more")
15420
15417
  }
15421
15418
  ) : null
15422
15419
  ]
@@ -16731,7 +16728,8 @@ function ProductTabs(rawProps) {
16731
16728
  product: props.product,
16732
16729
  language: props.language,
16733
16730
  collapsed: props.descriptionCollapsed,
16734
- maxLength: props.descriptionMaxLength
16731
+ maxLength: props.descriptionMaxLength,
16732
+ labels: props.labels
16735
16733
  }
16736
16734
  ) : null,
16737
16735
  specsVisited && isTabVisible("specifications") ? /* @__PURE__ */ jsx("div", { className: isActive("specifications") ? "" : "hidden", children: /* @__PURE__ */ jsx(
@@ -16801,7 +16799,8 @@ function ProductTabs(rawProps) {
16801
16799
  product: props.product,
16802
16800
  language: props.language,
16803
16801
  collapsed: props.descriptionCollapsed,
16804
- maxLength: props.descriptionMaxLength
16802
+ maxLength: props.descriptionMaxLength,
16803
+ labels: props.labels
16805
16804
  }
16806
16805
  ) }) : null
16807
16806
  ] }) : null,
@@ -17129,8 +17128,9 @@ function PurchaseAuthorizationConfigurator(rawProps) {
17129
17128
  {
17130
17129
  type: "button",
17131
17130
  className: "text-muted-foreground hover:text-foreground transition",
17131
+ "aria-label": getLabel(props.labels, "closeLabel", "Close"),
17132
17132
  onClick: () => closeAddContactModal(),
17133
- children: "\u2715"
17133
+ children: /* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: "\u2715" })
17134
17134
  }
17135
17135
  )
17136
17136
  ] }),
@@ -17228,7 +17228,7 @@ function PurchaseAuthorizationConfigurator(rawProps) {
17228
17228
  }
17229
17229
  )
17230
17230
  ] }),
17231
- addContactError ? /* @__PURE__ */ jsx("p", { className: "text-sm text-destructive", children: addContactError }) : null,
17231
+ addContactError ? /* @__PURE__ */ jsx("p", { className: "text-sm text-destructive", children: props.labels?.addContactFailed || addContactError }) : null,
17232
17232
  /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-3 pt-2", children: [
17233
17233
  /* @__PURE__ */ jsx(
17234
17234
  "button",
@@ -17381,8 +17381,9 @@ function PurchaseAuthorizationRequests(rawProps) {
17381
17381
  {
17382
17382
  type: "button",
17383
17383
  className: "propeller-purchase-authorization-requests__modal-close text-foreground-subtle hover:text-foreground focus:outline-none",
17384
+ "aria-label": getLabel(props.labels, "closeLabel", "Close"),
17384
17385
  onClick: () => closeModal(),
17385
- children: /* @__PURE__ */ jsx("svg", { fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", className: "h-5 w-5", strokeWidth: 2, children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" }) })
17386
+ children: /* @__PURE__ */ jsx("svg", { "aria-hidden": "true", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", className: "h-5 w-5", strokeWidth: 2, children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" }) })
17386
17387
  }
17387
17388
  )
17388
17389
  ] }),
@@ -17665,6 +17666,8 @@ function RegisterForm(rawProps) {
17665
17666
  const emailPlaceholder = props.labels?.emailPlaceholder || "name@example.com";
17666
17667
  const passwordPlaceholder = props.labels?.passwordPlaceholder || "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022";
17667
17668
  const passwordMismatchText = props.labels?.passwordMismatch || "Passwords do not match";
17669
+ const selectUserTypeText = props.labels?.selectUserType || "Please select an account type.";
17670
+ const registrationFailedText = props.labels?.registrationFailed;
17668
17671
  const loginText = props.labels?.loginText || "Already have an account?";
17669
17672
  const loginLinkText = props.labels?.loginLink || "Log in";
17670
17673
  function isFieldRequired(fieldName) {
@@ -17675,7 +17678,7 @@ function RegisterForm(rawProps) {
17675
17678
  async function handleSubmit(e) {
17676
17679
  e.preventDefault();
17677
17680
  if (!effectiveUserType) {
17678
- setError("Please select an account type.");
17681
+ setError(selectUserTypeText);
17679
17682
  return;
17680
17683
  }
17681
17684
  if (password !== confirmPassword) {
@@ -17751,7 +17754,7 @@ function RegisterForm(rawProps) {
17751
17754
  );
17752
17755
  }
17753
17756
  } else if (result.error) {
17754
- setError(result.error);
17757
+ setError(registrationFailedText || result.error);
17755
17758
  }
17756
17759
  }
17757
17760
  return /* @__PURE__ */ jsxs("div", { className: "propeller-register-form", "data-loading": loading ? "true" : "false", "data-user-type": selectedUserType, children: [