@propeller-commerce/propeller-v2-react-ui 0.21.0 → 0.23.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/dist/index.d.cts CHANGED
@@ -40,6 +40,14 @@ interface PropellerDeps {
40
40
  interface PropellerScope {
41
41
  /** The authenticated user, or `null` when browsing anonymously. */
42
42
  user: Contact | Customer | null;
43
+ /**
44
+ * Whether a session exists, independent of whether `user` has loaded yet.
45
+ * Hosts paint from a cached hint before the profile arrives, so `user` is
46
+ * null for an authenticated visitor for the first frames; without this,
47
+ * semi-closed surfaces flash their logged-out state. Optional — omitting it
48
+ * keeps the previous behaviour.
49
+ */
50
+ isAuthenticated?: boolean;
43
51
  /** Active company ID for the current session; `undefined` for non-company users. */
44
52
  companyId: number | undefined;
45
53
  /** Active language code (e.g. `'NL'`). */
@@ -588,7 +596,11 @@ interface UseCartReturn {
588
596
  loading: boolean;
589
597
  /** Last error message, or `null`. */
590
598
  error: string | null;
591
- /** `false` when a B2B purchaser's authorization limit is exceeded by the cart total. */
599
+ /**
600
+ * `false` when a B2B purchaser's authorization limit is exceeded by the cart
601
+ * total, and while a seeded `cartId` is still being hydrated — it fails
602
+ * closed, so gating a checkout button on it holds rather than opens.
603
+ */
592
604
  checkoutAllowed: boolean;
593
605
  /** Resolves an existing cart or creates one via the shared `initCart` flow. */
594
606
  resolveCart: () => Promise<Cart>;
@@ -1669,6 +1681,15 @@ interface UseSparePartsOptions {
1669
1681
  * parts list need different languages. Set this when they diverge.
1670
1682
  */
1671
1683
  machineLanguage?: string;
1684
+ /**
1685
+ * Extra languages to try when the slug does not resolve in `machineLanguage`.
1686
+ *
1687
+ * A slug resolves only in the language it was authored in, so a tree that is
1688
+ * only half-translated has machines reachable by an NL slug but not an EN
1689
+ * one. `machineLanguage` and `language` are always tried first; list the
1690
+ * shop's other locales here to cover the rest. Order is the try order.
1691
+ */
1692
+ machineLanguages?: string[];
1672
1693
  /** Tax zone for price calculation. */
1673
1694
  taxZone?: string;
1674
1695
  /** Active user — drives `userId` scoping and contact/customer pricing. */
@@ -1737,6 +1758,14 @@ interface UseSparePartsReturn {
1737
1758
  fetchParts: () => Promise<void>;
1738
1759
  /** Navigate to a page. */
1739
1760
  goToPage: (page: number) => void;
1761
+ /**
1762
+ * The slug resolved in none of the candidate languages.
1763
+ *
1764
+ * Distinct from "resolved but has no parts": this node does not exist, and a
1765
+ * host that renders the usual empty listing for it shows a page built
1766
+ * entirely from the URL. Always `false` in controlled mode.
1767
+ */
1768
+ notFound: boolean;
1740
1769
  }
1741
1770
  /**
1742
1771
  * useSpareParts — fetch and paginate a machine node's spare-parts list.
@@ -2181,8 +2210,13 @@ interface ResolveSpecEntry {
2181
2210
  */
2182
2211
  transform?: (gridValue: NonNullable<ProductGridConfig[GridKey]>) => unknown;
2183
2212
  }
2184
- /** Per-prop resolution spec: maps each prop key to its {@link ResolveSpecEntry}. */
2185
- type ResolveSpec<P> = Partial<Record<keyof P, ResolveSpecEntry>>;
2213
+ /**
2214
+ * Per-prop resolution spec: maps each prop key to its {@link ResolveSpecEntry}.
2215
+ *
2216
+ * Infra keys are spec'able too, so a component can pull a provider value it
2217
+ * only reads internally without having to publish it as its own prop.
2218
+ */
2219
+ type ResolveSpec<P> = Partial<Record<keyof P | keyof PropellerInfra, ResolveSpecEntry>>;
2186
2220
  /**
2187
2221
  * useResolvedProps — resolves props through the two-tier precedence
2188
2222
  * `explicit prop > ProductGrid context > Propeller infra > default`.
@@ -2191,7 +2225,7 @@ type ResolveSpec<P> = Partial<Record<keyof P, ResolveSpecEntry>>;
2191
2225
  * @param spec - per-key resolution rules; keys absent from the spec pass through unchanged.
2192
2226
  * @returns the props with each spec'd key resolved to its highest-precedence value.
2193
2227
  */
2194
- declare function useResolvedProps<P extends object>(rawProps: P, spec: ResolveSpec<P>): P;
2228
+ declare function useResolvedProps<P extends object>(rawProps: P, spec: ResolveSpec<P>): P & Partial<PropellerInfra>;
2195
2229
 
2196
2230
  /**
2197
2231
  * Read the SDK services bundle from `<PropellerDepsProvider>`.
@@ -3496,13 +3530,17 @@ interface CartOverviewProps {
3496
3530
  code: string;
3497
3531
  name: string;
3498
3532
  }[];
3533
+ /** Logged-in user — used for the purchase-authorization check. Resolved from PropellerProvider when omitted. */
3534
+ user?: Contact | Customer | null;
3535
+ /** Active company ID — used for the purchase-authorization check. Resolved from PropellerProvider when omitted. */
3536
+ companyId?: number;
3499
3537
  }
3500
3538
  /**
3501
3539
  * Final cart review panel: shows invoice/delivery addresses, payment, carrier
3502
3540
  * and delivery date, with optional reference, notes, terms acceptance and a
3503
3541
  * place-order button.
3504
3542
  */
3505
- declare function CartOverview(props: CartOverviewProps): React$1.JSX.Element;
3543
+ declare function CartOverview(rawProps: CartOverviewProps): React$1.JSX.Element;
3506
3544
 
3507
3545
  /**
3508
3546
  * @rsc-blocked — Client-only component: interactive state (useState/useReducer).
@@ -4195,10 +4233,11 @@ declare function ProductCardPrice(props: {
4195
4233
  /** Renders the embedded `AddToCart` control with all pass-through props from
4196
4234
  * context, or the injected `addToCartComponent` when set.
4197
4235
  *
4198
- * Note: the default `AddToCartImpl` accepts a richer prop set (graphqlClient,
4199
- * configuration, etc.) than the public `AddToCartComponentProps` contract.
4200
- * Injected components only receive the contract surface; the extra infra
4201
- * props stay default-only. */
4236
+ * Note: the default `AddToCartImpl` accepts a richer prop set than the public
4237
+ * `AddToCartComponentProps` contract. Injected components receive the whole
4238
+ * contract surface; what stays default-only is infra (graphqlClient, user,
4239
+ * configuration, …), which an injected component resolves from
4240
+ * `<PropellerProvider>` itself. */
4202
4241
  declare function ProductCardAddToCart(props: {
4203
4242
  /** Override the AddToCart wrapper class. */
4204
4243
  className?: string;
@@ -4270,6 +4309,16 @@ interface MachineGridProps {
4270
4309
  rootTitle?: string;
4271
4310
  /** Language the machine tree is authored in (usually EN). Defaults to `'EN'`. */
4272
4311
  machineLanguage?: string;
4312
+ /**
4313
+ * Other languages the tree may be authored in, tried in order when a slug
4314
+ * does not resolve in `machineLanguage`.
4315
+ *
4316
+ * A slug resolves only in its own language, so a half-translated tree lists a
4317
+ * machine by its NL slug and then cannot open it with `language: 'EN'`. Pass
4318
+ * the shop's locales here; `machineLanguage` and the storefront `language`
4319
+ * are always tried first (PWP-993).
4320
+ */
4321
+ machineLanguages?: string[];
4273
4322
  listing: MachineListingState;
4274
4323
  onListingChange: (next: MachineListingState) => void;
4275
4324
  graphqlClient?: GraphQLClient;
@@ -4309,9 +4358,19 @@ interface MachineGridProps {
4309
4358
  filtersLabels?: Record<string, string>;
4310
4359
  toolbarLabels?: Record<string, string>;
4311
4360
  /**
4312
- * Labels for the machine side of the grid. Keys read here: `loading` and
4313
- * `noMachines`. The same object is passed to each `MachineCard` as its
4314
- * `labels`, which reads `viewMachine` — so all three keys belong in it.
4361
+ * Labels for the machine side of the grid.
4362
+ *
4363
+ * Keys read here: `loading`, `noMachines`, `machineNotFound`,
4364
+ * `quantityInMachine` and `searchParts`. The same object is passed to each
4365
+ * `MachineCard` as its `labels`, which reads `viewMachine` — so all six keys
4366
+ * belong in it.
4367
+ *
4368
+ * `quantityInMachine` and `searchParts` used to be read from `toolbarLabels`,
4369
+ * which is forwarded verbatim to `GridToolbar`: a shop that translated its
4370
+ * toolbar dictionary properly still got "Qty in machine" and "Search parts…"
4371
+ * in English, because those keys belong to no toolbar (PWP-995a). They are
4372
+ * still read from `toolbarLabels` as a fallback so existing hosts keep
4373
+ * working.
4315
4374
  */
4316
4375
  machineCardLabels?: Record<string, string>;
4317
4376
  /**
@@ -4549,6 +4608,8 @@ interface CompanySwitcherProps {
4549
4608
  /** Translated labels keyed by the slugs used inside the component (see
4550
4609
  * `getLabel` calls). Missing keys fall back to the English defaults. */
4551
4610
  labels?: Record<string, string>;
4611
+ /** Additional class name for the switcher's trigger button. */
4612
+ triggerClassName?: string;
4552
4613
  }
4553
4614
  /**
4554
4615
  * Dropdown for switching the active company of a multi-company contact.
@@ -6155,6 +6216,12 @@ interface ProductBulkPricesProps {
6155
6216
  * Defaults to 'open'.
6156
6217
  */
6157
6218
  portalMode?: string;
6219
+ /**
6220
+ * Whether a session exists, independent of whether `user` has loaded yet.
6221
+ * Passed down by the parent alongside `portalMode`; closes the hydration
6222
+ * window in which an authenticated visitor still has a null `user`.
6223
+ */
6224
+ isAuthenticated?: boolean;
6158
6225
  /** Authenticated user — used for semi-closed visibility. */
6159
6226
  user?: Contact | Customer | null;
6160
6227
  /** Tax zone code. Defaults to 'NL'. */
@@ -6694,6 +6761,15 @@ interface ProductInfoProps {
6694
6761
  * Example: ['brand', 'color']
6695
6762
  */
6696
6763
  textLabels?: string[];
6764
+ /** Cart to add into. Omit and pass `createCart` to start one on first add. */
6765
+ cartId?: string;
6766
+ /** If true a new cart is created when no `cartId` is available. */
6767
+ createCart?: boolean;
6768
+ /**
6769
+ * Called when a new cart is created, so the host can persist `cart.cartId`.
6770
+ * WARNING: without it a new cart is created on every add.
6771
+ */
6772
+ onCartCreated?: (cart: Cart) => void;
6697
6773
  showImage?: boolean;
6698
6774
  showBadges?: boolean;
6699
6775
  showFavorite?: boolean;
@@ -6837,6 +6913,12 @@ interface ProductPriceProps {
6837
6913
  * Defaults to 'open'.
6838
6914
  */
6839
6915
  portalMode?: string;
6916
+ /**
6917
+ * Whether a session exists, independent of whether `user` has loaded yet.
6918
+ * Passed down by the parent alongside `portalMode`; closes the hydration
6919
+ * window in which an authenticated visitor still has a null `user`.
6920
+ */
6921
+ isAuthenticated?: boolean;
6840
6922
  /** Authenticated user — used for semi-closed visibility. */
6841
6923
  user?: Contact | Customer | null;
6842
6924
  /**
package/dist/index.d.ts CHANGED
@@ -40,6 +40,14 @@ interface PropellerDeps {
40
40
  interface PropellerScope {
41
41
  /** The authenticated user, or `null` when browsing anonymously. */
42
42
  user: Contact | Customer | null;
43
+ /**
44
+ * Whether a session exists, independent of whether `user` has loaded yet.
45
+ * Hosts paint from a cached hint before the profile arrives, so `user` is
46
+ * null for an authenticated visitor for the first frames; without this,
47
+ * semi-closed surfaces flash their logged-out state. Optional — omitting it
48
+ * keeps the previous behaviour.
49
+ */
50
+ isAuthenticated?: boolean;
43
51
  /** Active company ID for the current session; `undefined` for non-company users. */
44
52
  companyId: number | undefined;
45
53
  /** Active language code (e.g. `'NL'`). */
@@ -588,7 +596,11 @@ interface UseCartReturn {
588
596
  loading: boolean;
589
597
  /** Last error message, or `null`. */
590
598
  error: string | null;
591
- /** `false` when a B2B purchaser's authorization limit is exceeded by the cart total. */
599
+ /**
600
+ * `false` when a B2B purchaser's authorization limit is exceeded by the cart
601
+ * total, and while a seeded `cartId` is still being hydrated — it fails
602
+ * closed, so gating a checkout button on it holds rather than opens.
603
+ */
592
604
  checkoutAllowed: boolean;
593
605
  /** Resolves an existing cart or creates one via the shared `initCart` flow. */
594
606
  resolveCart: () => Promise<Cart>;
@@ -1669,6 +1681,15 @@ interface UseSparePartsOptions {
1669
1681
  * parts list need different languages. Set this when they diverge.
1670
1682
  */
1671
1683
  machineLanguage?: string;
1684
+ /**
1685
+ * Extra languages to try when the slug does not resolve in `machineLanguage`.
1686
+ *
1687
+ * A slug resolves only in the language it was authored in, so a tree that is
1688
+ * only half-translated has machines reachable by an NL slug but not an EN
1689
+ * one. `machineLanguage` and `language` are always tried first; list the
1690
+ * shop's other locales here to cover the rest. Order is the try order.
1691
+ */
1692
+ machineLanguages?: string[];
1672
1693
  /** Tax zone for price calculation. */
1673
1694
  taxZone?: string;
1674
1695
  /** Active user — drives `userId` scoping and contact/customer pricing. */
@@ -1737,6 +1758,14 @@ interface UseSparePartsReturn {
1737
1758
  fetchParts: () => Promise<void>;
1738
1759
  /** Navigate to a page. */
1739
1760
  goToPage: (page: number) => void;
1761
+ /**
1762
+ * The slug resolved in none of the candidate languages.
1763
+ *
1764
+ * Distinct from "resolved but has no parts": this node does not exist, and a
1765
+ * host that renders the usual empty listing for it shows a page built
1766
+ * entirely from the URL. Always `false` in controlled mode.
1767
+ */
1768
+ notFound: boolean;
1740
1769
  }
1741
1770
  /**
1742
1771
  * useSpareParts — fetch and paginate a machine node's spare-parts list.
@@ -2181,8 +2210,13 @@ interface ResolveSpecEntry {
2181
2210
  */
2182
2211
  transform?: (gridValue: NonNullable<ProductGridConfig[GridKey]>) => unknown;
2183
2212
  }
2184
- /** Per-prop resolution spec: maps each prop key to its {@link ResolveSpecEntry}. */
2185
- type ResolveSpec<P> = Partial<Record<keyof P, ResolveSpecEntry>>;
2213
+ /**
2214
+ * Per-prop resolution spec: maps each prop key to its {@link ResolveSpecEntry}.
2215
+ *
2216
+ * Infra keys are spec'able too, so a component can pull a provider value it
2217
+ * only reads internally without having to publish it as its own prop.
2218
+ */
2219
+ type ResolveSpec<P> = Partial<Record<keyof P | keyof PropellerInfra, ResolveSpecEntry>>;
2186
2220
  /**
2187
2221
  * useResolvedProps — resolves props through the two-tier precedence
2188
2222
  * `explicit prop > ProductGrid context > Propeller infra > default`.
@@ -2191,7 +2225,7 @@ type ResolveSpec<P> = Partial<Record<keyof P, ResolveSpecEntry>>;
2191
2225
  * @param spec - per-key resolution rules; keys absent from the spec pass through unchanged.
2192
2226
  * @returns the props with each spec'd key resolved to its highest-precedence value.
2193
2227
  */
2194
- declare function useResolvedProps<P extends object>(rawProps: P, spec: ResolveSpec<P>): P;
2228
+ declare function useResolvedProps<P extends object>(rawProps: P, spec: ResolveSpec<P>): P & Partial<PropellerInfra>;
2195
2229
 
2196
2230
  /**
2197
2231
  * Read the SDK services bundle from `<PropellerDepsProvider>`.
@@ -3496,13 +3530,17 @@ interface CartOverviewProps {
3496
3530
  code: string;
3497
3531
  name: string;
3498
3532
  }[];
3533
+ /** Logged-in user — used for the purchase-authorization check. Resolved from PropellerProvider when omitted. */
3534
+ user?: Contact | Customer | null;
3535
+ /** Active company ID — used for the purchase-authorization check. Resolved from PropellerProvider when omitted. */
3536
+ companyId?: number;
3499
3537
  }
3500
3538
  /**
3501
3539
  * Final cart review panel: shows invoice/delivery addresses, payment, carrier
3502
3540
  * and delivery date, with optional reference, notes, terms acceptance and a
3503
3541
  * place-order button.
3504
3542
  */
3505
- declare function CartOverview(props: CartOverviewProps): React$1.JSX.Element;
3543
+ declare function CartOverview(rawProps: CartOverviewProps): React$1.JSX.Element;
3506
3544
 
3507
3545
  /**
3508
3546
  * @rsc-blocked — Client-only component: interactive state (useState/useReducer).
@@ -4195,10 +4233,11 @@ declare function ProductCardPrice(props: {
4195
4233
  /** Renders the embedded `AddToCart` control with all pass-through props from
4196
4234
  * context, or the injected `addToCartComponent` when set.
4197
4235
  *
4198
- * Note: the default `AddToCartImpl` accepts a richer prop set (graphqlClient,
4199
- * configuration, etc.) than the public `AddToCartComponentProps` contract.
4200
- * Injected components only receive the contract surface; the extra infra
4201
- * props stay default-only. */
4236
+ * Note: the default `AddToCartImpl` accepts a richer prop set than the public
4237
+ * `AddToCartComponentProps` contract. Injected components receive the whole
4238
+ * contract surface; what stays default-only is infra (graphqlClient, user,
4239
+ * configuration, …), which an injected component resolves from
4240
+ * `<PropellerProvider>` itself. */
4202
4241
  declare function ProductCardAddToCart(props: {
4203
4242
  /** Override the AddToCart wrapper class. */
4204
4243
  className?: string;
@@ -4270,6 +4309,16 @@ interface MachineGridProps {
4270
4309
  rootTitle?: string;
4271
4310
  /** Language the machine tree is authored in (usually EN). Defaults to `'EN'`. */
4272
4311
  machineLanguage?: string;
4312
+ /**
4313
+ * Other languages the tree may be authored in, tried in order when a slug
4314
+ * does not resolve in `machineLanguage`.
4315
+ *
4316
+ * A slug resolves only in its own language, so a half-translated tree lists a
4317
+ * machine by its NL slug and then cannot open it with `language: 'EN'`. Pass
4318
+ * the shop's locales here; `machineLanguage` and the storefront `language`
4319
+ * are always tried first (PWP-993).
4320
+ */
4321
+ machineLanguages?: string[];
4273
4322
  listing: MachineListingState;
4274
4323
  onListingChange: (next: MachineListingState) => void;
4275
4324
  graphqlClient?: GraphQLClient;
@@ -4309,9 +4358,19 @@ interface MachineGridProps {
4309
4358
  filtersLabels?: Record<string, string>;
4310
4359
  toolbarLabels?: Record<string, string>;
4311
4360
  /**
4312
- * Labels for the machine side of the grid. Keys read here: `loading` and
4313
- * `noMachines`. The same object is passed to each `MachineCard` as its
4314
- * `labels`, which reads `viewMachine` — so all three keys belong in it.
4361
+ * Labels for the machine side of the grid.
4362
+ *
4363
+ * Keys read here: `loading`, `noMachines`, `machineNotFound`,
4364
+ * `quantityInMachine` and `searchParts`. The same object is passed to each
4365
+ * `MachineCard` as its `labels`, which reads `viewMachine` — so all six keys
4366
+ * belong in it.
4367
+ *
4368
+ * `quantityInMachine` and `searchParts` used to be read from `toolbarLabels`,
4369
+ * which is forwarded verbatim to `GridToolbar`: a shop that translated its
4370
+ * toolbar dictionary properly still got "Qty in machine" and "Search parts…"
4371
+ * in English, because those keys belong to no toolbar (PWP-995a). They are
4372
+ * still read from `toolbarLabels` as a fallback so existing hosts keep
4373
+ * working.
4315
4374
  */
4316
4375
  machineCardLabels?: Record<string, string>;
4317
4376
  /**
@@ -4549,6 +4608,8 @@ interface CompanySwitcherProps {
4549
4608
  /** Translated labels keyed by the slugs used inside the component (see
4550
4609
  * `getLabel` calls). Missing keys fall back to the English defaults. */
4551
4610
  labels?: Record<string, string>;
4611
+ /** Additional class name for the switcher's trigger button. */
4612
+ triggerClassName?: string;
4552
4613
  }
4553
4614
  /**
4554
4615
  * Dropdown for switching the active company of a multi-company contact.
@@ -6155,6 +6216,12 @@ interface ProductBulkPricesProps {
6155
6216
  * Defaults to 'open'.
6156
6217
  */
6157
6218
  portalMode?: string;
6219
+ /**
6220
+ * Whether a session exists, independent of whether `user` has loaded yet.
6221
+ * Passed down by the parent alongside `portalMode`; closes the hydration
6222
+ * window in which an authenticated visitor still has a null `user`.
6223
+ */
6224
+ isAuthenticated?: boolean;
6158
6225
  /** Authenticated user — used for semi-closed visibility. */
6159
6226
  user?: Contact | Customer | null;
6160
6227
  /** Tax zone code. Defaults to 'NL'. */
@@ -6694,6 +6761,15 @@ interface ProductInfoProps {
6694
6761
  * Example: ['brand', 'color']
6695
6762
  */
6696
6763
  textLabels?: string[];
6764
+ /** Cart to add into. Omit and pass `createCart` to start one on first add. */
6765
+ cartId?: string;
6766
+ /** If true a new cart is created when no `cartId` is available. */
6767
+ createCart?: boolean;
6768
+ /**
6769
+ * Called when a new cart is created, so the host can persist `cart.cartId`.
6770
+ * WARNING: without it a new cart is created on every add.
6771
+ */
6772
+ onCartCreated?: (cart: Cart) => void;
6697
6773
  showImage?: boolean;
6698
6774
  showBadges?: boolean;
6699
6775
  showFavorite?: boolean;
@@ -6837,6 +6913,12 @@ interface ProductPriceProps {
6837
6913
  * Defaults to 'open'.
6838
6914
  */
6839
6915
  portalMode?: string;
6916
+ /**
6917
+ * Whether a session exists, independent of whether `user` has loaded yet.
6918
+ * Passed down by the parent alongside `portalMode`; closes the hydration
6919
+ * window in which an authenticated visitor still has a null `user`.
6920
+ */
6921
+ isAuthenticated?: boolean;
6840
6922
  /** Authenticated user — used for semi-closed visibility. */
6841
6923
  user?: Contact | Customer | null;
6842
6924
  /**