@commercelayer/app-elements 7.4.2 → 7.5.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/main.d.ts CHANGED
@@ -122,7 +122,7 @@ export { ResourceLineItems, type ResourceLineItemsProps, } from './ui/resources/
122
122
  export { ResourceListItem, type ResourceListItemProps, } from './ui/resources/ResourceListItem';
123
123
  export { ResourceMetadata, type ResourceMetadataProps, } from './ui/resources/ResourceMetadata';
124
124
  export { ResourceOrderTimeline, type ResourceOrderTimelineProps, } from './ui/resources/ResourceOrderTimeline';
125
- export { getPaymentMethodLogoSrc, ResourcePaymentMethod, type ResourcePaymentMethodProps, } from './ui/resources/ResourcePaymentMethod';
125
+ export { getPaymentInstrumentDetails, getPaymentMethodLogoSrc, ResourcePaymentMethod, type ResourcePaymentMethodProps, } from './ui/resources/ResourcePaymentMethod';
126
126
  export { ResourceShipmentParcels, type ResourceShipmentParcelsProps, } from './ui/resources/ResourceShipmentParcels';
127
127
  export { ResourceTags, type ResourceTagsProps, } from './ui/resources/ResourceTags';
128
128
  export { type FiltersInstructions, type FormFullValues, type MetricsFilters, type UiFilterName, type UiFilterValue, useResourceFilters, } from './ui/resources/useResourceFilters';
package/dist/main.js CHANGED
@@ -1,12 +1,12 @@
1
1
  "use client";
2
- import { an as s, ao as t, ap as o, aq as r, ar as c, as as n, at as u, af as i, au as d, av as l, aw as p, ax as b, ay as g, al as m, az as S, aA as k, aB as I, a1 as T, ae as D, a9 as R, aC as y, aD as C, aE as h, aF as A, aG as P, aH as H, aI as f, aJ as F, aK as v, aL as O, aM as B, aN as E, aO as L, aP as N, aQ as G, aR as M, aS as w, aT as V, aU as x, aV as W, aW as J, aX as U, aY as j, aZ as Y, a_ as q, a$ as z, b0 as K, ah as Q, b1 as X, a0 as Z, ab as _, b2 as $, b3 as aa, b4 as ea, b5 as sa, aj as ta, ai as oa, b6 as ra, b7 as ca, b8 as na, b9 as ua, ba as ia, a7 as da, bb as la, bc as pa, bd as ba, be as ga, bf as ma, bg as Sa, bh as ka, bi as Ia, bj as Ta, bk as Da, bl as Ra, bm as ya, bn as Ca, bo as ha, bp as Aa, bq as Pa, br as Ha, bs as fa, bt as Fa, bu as va, bv as Oa, bw as Ba, bx as Ea, by as La, bz as Na, bA as Ga, bB as Ma, bC as wa, bD as Va, bE as xa, bF as Wa, bG as Ja, bH as Ua, bI as ja, bJ as Ya, bK as qa, bL as za, bM as Ka, bN as Qa, bO as Xa, bP as Za, bQ as _a, ag as $a, bR as ae, bS as ee, bT as se, bU as te, bV as oe, bW as re, bX as ce, bY as ne, bZ as ue, b_ as ie, a8 as de, b$ as le, c0 as pe, c1 as be, c2 as ge, c3 as me, c4 as Se, c5 as ke, c6 as Ie, c7 as Te, c8 as De, c9 as Re, ca as ye, cb as Ce, cc as he, cd as Ae, ce as Pe, cf as He, cg as fe, ch as Fe, ci as ve, cj as Oe, ck as Be, cl as Ee, cm as Le, cn as Ne, co as Ge, cp as Me, cq as we, cr as Ve, cs as xe, ct as We, cu as Je, cv as Ue, cw as je, cx as Ye, cy as qe, cz as ze, cA as Ke, cB as Qe, cC as Xe, cD as Ze, cE as _e, cF as $e, cG as as, cH as es, cI as ss, cJ as ts, cK as os, cL as rs, cM as cs, cN as ns, cO as us, cP as is, cQ as ds, cR as ls, cS as ps, cT as bs, S as gs, cU as ms, cV as Ss, cW as ks, ad as Is, aa as Ts, cX as Ds, cY as Rs, cZ as ys, c_ as Cs, c$ as hs, d0 as As, d1 as Ps, d2 as Hs, d3 as fs, d4 as Fs, d5 as vs, d6 as Os, d7 as Bs, d8 as Es, d9 as Ls, a5 as Ns, a4 as Gs, da as Ms, db as ws, dc as Vs, dd as xs, de as Ws, df as Js, dg as Us, dh as js, di as Ys, dj as qs, dk as zs, u as Ks, dl as Qs, ac as Xs, dm as Zs, dn as _s, dp as $s } from "./main-RB0PeDoP.js";
2
+ import { an as s, ao as t, ap as o, aq as r, ar as n, as as c, at as u, af as i, au as d, av as l, aw as p, ax as b, ay as g, al as m, az as S, aA as I, aB as k, a1 as T, ae as D, a9 as R, aC as y, aD as C, aE as h, aF as A, aG as P, aH as H, aI as f, aJ as F, aK as v, aL as O, aM as B, aN as E, aO as L, aP as N, aQ as G, aR as M, aS as w, aT as V, aU as x, aV as W, aW as J, aX as U, aY as j, aZ as q, a_ as Y, a$ as z, b0 as K, ah as Q, b1 as X, a0 as Z, ab as _, b2 as $, b3 as aa, b4 as ea, b5 as sa, aj as ta, ai as oa, b6 as ra, b7 as na, b8 as ca, b9 as ua, ba as ia, a7 as da, bb as la, bc as pa, bd as ba, be as ga, bf as ma, bg as Sa, bh as Ia, bi as ka, bj as Ta, bk as Da, bl as Ra, bm as ya, bn as Ca, bo as ha, bp as Aa, bq as Pa, br as Ha, bs as fa, bt as Fa, bu as va, bv as Oa, bw as Ba, bx as Ea, by as La, bz as Na, bA as Ga, bB as Ma, bC as wa, bD as Va, bE as xa, bF as Wa, bG as Ja, bH as Ua, bI as ja, bJ as qa, bK as Ya, bL as za, bM as Ka, bN as Qa, bO as Xa, bP as Za, bQ as _a, ag as $a, bR as ae, bS as ee, bT as se, bU as te, bV as oe, bW as re, bX as ne, bY as ce, bZ as ue, b_ as ie, a8 as de, b$ as le, c0 as pe, c1 as be, c2 as ge, c3 as me, c4 as Se, c5 as Ie, c6 as ke, c7 as Te, c8 as De, c9 as Re, ca as ye, cb as Ce, cc as he, cd as Ae, ce as Pe, cf as He, cg as fe, ch as Fe, ci as ve, cj as Oe, ck as Be, cl as Ee, cm as Le, cn as Ne, co as Ge, cp as Me, cq as we, cr as Ve, cs as xe, ct as We, cu as Je, cv as Ue, cw as je, cx as qe, cy as Ye, cz as ze, cA as Ke, cB as Qe, cC as Xe, cD as Ze, cE as _e, cF as $e, cG as as, cH as es, cI as ss, cJ as ts, cK as os, cL as rs, cM as ns, cN as cs, cO as us, cP as is, cQ as ds, cR as ls, cS as ps, cT as bs, cU as gs, S as ms, cV as Ss, cW as Is, cX as ks, ad as Ts, aa as Ds, cY as Rs, cZ as ys, c_ as Cs, c$ as hs, d0 as As, d1 as Ps, d2 as Hs, d3 as fs, d4 as Fs, d5 as vs, d6 as Os, d7 as Bs, d8 as Es, d9 as Ls, da as Ns, a5 as Gs, a4 as Ms, db as ws, dc as Vs, dd as xs, de as Ws, df as Js, dg as Us, dh as js, di as qs, dj as Ys, dk as zs, dl as Ks, u as Qs, dm as Xs, ac as Zs, dn as _s, dp as $s, dq as at } from "./main-YBGuu4K1.js";
3
3
  export {
4
4
  s as A,
5
5
  t as ActionButtons,
6
6
  o as Address,
7
7
  r as Alert,
8
- c as Avatar,
9
- n as AvatarLetter,
8
+ n as Avatar,
9
+ c as AvatarLetter,
10
10
  u as Badge,
11
11
  i as Button,
12
12
  d as ButtonFilter,
@@ -16,8 +16,8 @@ export {
16
16
  g as CodeBlock,
17
17
  m as CodeEditor,
18
18
  S as Container,
19
- k as CopyToClipboard,
20
- I as CoreSdkProvider,
19
+ I as CopyToClipboard,
20
+ k as CoreSdkProvider,
21
21
  T as Dropdown,
22
22
  D as DropdownDivider,
23
23
  R as DropdownItem,
@@ -44,8 +44,8 @@ export {
44
44
  J as HookedInputSpinner,
45
45
  U as HookedInputSwitch,
46
46
  j as HookedInputTextArea,
47
- Y as HookedInputToggleButton,
48
- q as HookedMarketWithCurrencySelector,
47
+ q as HookedInputToggleButton,
48
+ Y as HookedMarketWithCurrencySelector,
49
49
  z as HookedValidationApiError,
50
50
  K as HookedValidationError,
51
51
  Q as Hr,
@@ -59,8 +59,8 @@ export {
59
59
  ta as InputDate,
60
60
  oa as InputDateRange,
61
61
  ra as InputFeedback,
62
- ca as InputFile,
63
- na as InputJson,
62
+ na as InputFile,
63
+ ca as InputJson,
64
64
  ua as InputRadioGroup,
65
65
  ia as InputResourceGroup,
66
66
  da as InputSelect,
@@ -70,8 +70,8 @@ export {
70
70
  ga as InputTextArea,
71
71
  ma as InputToggleButton,
72
72
  Sa as Label,
73
- ka as Legend,
74
- Ia as List,
73
+ Ia as Legend,
74
+ ka as List,
75
75
  Ta as ListDetails,
76
76
  Da as ListDetailsItem,
77
77
  Ra as ListItem,
@@ -98,8 +98,8 @@ export {
98
98
  Ja as ResourcePaymentMethod,
99
99
  Ua as ResourceShipmentParcels,
100
100
  ja as ResourceTags,
101
- Ya as Routes,
102
- qa as RuleEngine,
101
+ qa as Routes,
102
+ Ya as RuleEngine,
103
103
  za as ScrollToTop,
104
104
  Ka as SearchBar,
105
105
  Qa as Section,
@@ -113,8 +113,8 @@ export {
113
113
  te as Steps,
114
114
  oe as Tab,
115
115
  re as Table,
116
- ce as TableData,
117
- ne as Tabs,
116
+ ne as TableData,
117
+ ce as Tabs,
118
118
  ue as Tag,
119
119
  ie as Td,
120
120
  de as Text,
@@ -124,8 +124,8 @@ export {
124
124
  ge as TokenProvider,
125
125
  me as Toolbar,
126
126
  Se as Tooltip,
127
- ke as Tr,
128
- Ie as Trans,
127
+ Ie as Tr,
128
+ ke as Trans,
129
129
  Te as computeFullname,
130
130
  De as createApp,
131
131
  Re as createRoute,
@@ -152,67 +152,68 @@ export {
152
152
  Je as getOrderFulfillmentStatusName,
153
153
  Ue as getOrderPaymentStatusName,
154
154
  je as getOrderStatusName,
155
- Ye as getOrderTransactionName,
156
- qe as getParcelTrackingDetail,
155
+ qe as getOrderTransactionName,
156
+ Ye as getParcelTrackingDetail,
157
157
  ze as getParcelTrackingDetails,
158
- Ke as getPaymentMethodLogoSrc,
159
- Qe as getPromotionDisplayStatus,
160
- Xe as getResourceAddressFormFieldsSchema,
161
- Ze as getResourceEndpoint,
162
- _e as getReturnDisplayStatus,
163
- $e as getReturnStatusName,
164
- as as getShipmentDisplayStatus,
165
- es as getShipmentRate,
166
- ss as getShipmentRates,
167
- ts as getShipmentStatusName,
168
- os as getStockTransferDisplayStatus,
169
- rs as getStockTransferStatusName,
158
+ Ke as getPaymentInstrumentDetails,
159
+ Qe as getPaymentMethodLogoSrc,
160
+ Xe as getPromotionDisplayStatus,
161
+ Ze as getResourceAddressFormFieldsSchema,
162
+ _e as getResourceEndpoint,
163
+ $e as getReturnDisplayStatus,
164
+ as as getReturnStatusName,
165
+ es as getShipmentDisplayStatus,
166
+ ss as getShipmentRate,
167
+ ts as getShipmentRates,
168
+ os as getShipmentStatusName,
169
+ rs as getStockTransferDisplayStatus,
170
+ ns as getStockTransferStatusName,
170
171
  cs as getUnitOfWeightName,
171
- ns as getUnitsOfWeightForSelect,
172
- us as goBack,
173
- is as hasBeenPurchased,
174
- ds as hasSingleTracking,
175
- ls as i18nLocales,
176
- ps as isAllStockTransfersCancelled,
177
- bs as isAttachmentValidNote,
178
- gs as isDateValid,
179
- ms as isGroupedSelectValues,
180
- Ss as isMock,
172
+ us as getUnitsOfWeightForSelect,
173
+ is as goBack,
174
+ ds as hasBeenPurchased,
175
+ ls as hasSingleTracking,
176
+ ps as i18nLocales,
177
+ bs as isAllStockTransfersCancelled,
178
+ gs as isAttachmentValidNote,
179
+ ms as isDateValid,
180
+ Ss as isGroupedSelectValues,
181
+ Is as isMock,
181
182
  ks as isMockedId,
182
- Is as isMultiValueSelected,
183
- Ts as isSingleValueSelected,
184
- Ds as makeDateYearsRange,
185
- Rs as maskGiftCardCode,
186
- ys as navigateTo,
187
- Cs as orderTransactionIsAnAsyncCapture,
188
- hs as parseApiError,
189
- As as referenceOrigins,
190
- Ps as removeMillisecondsFromIsoDate,
191
- Hs as setApiFormErrors,
192
- fs as sortAndGroupByDate,
193
- Fs as t,
194
- vs as timeSeparator,
195
- Os as toast,
196
- Bs as useAppLinking,
197
- Es as useClickAway,
198
- Ls as useConfirmDialog,
199
- Ns as useCoreApi,
200
- Gs as useCoreSdkProvider,
201
- Ms as useDelayShow,
202
- ws as useEditMetadataOverlay,
203
- Vs as useEditTagsOverlay,
204
- xs as useInputResourceGroupOverlay,
205
- Ws as useIsChanged,
206
- Js as useOnBlurFromContainer,
207
- Us as useOverlay,
208
- js as useResourceAddressOverlay,
183
+ Ts as isMultiValueSelected,
184
+ Ds as isSingleValueSelected,
185
+ Rs as makeDateYearsRange,
186
+ ys as maskGiftCardCode,
187
+ Cs as navigateTo,
188
+ hs as orderTransactionIsAnAsyncCapture,
189
+ As as parseApiError,
190
+ Ps as referenceOrigins,
191
+ Hs as removeMillisecondsFromIsoDate,
192
+ fs as setApiFormErrors,
193
+ Fs as sortAndGroupByDate,
194
+ vs as t,
195
+ Os as timeSeparator,
196
+ Bs as toast,
197
+ Es as useAppLinking,
198
+ Ls as useClickAway,
199
+ Ns as useConfirmDialog,
200
+ Gs as useCoreApi,
201
+ Ms as useCoreSdkProvider,
202
+ ws as useDelayShow,
203
+ Vs as useEditMetadataOverlay,
204
+ xs as useEditTagsOverlay,
205
+ Ws as useInputResourceGroupOverlay,
206
+ Js as useIsChanged,
207
+ Us as useOnBlurFromContainer,
208
+ js as useOverlay,
209
+ qs as useResourceAddressOverlay,
209
210
  Ys as useResourceFilters,
210
- qs as useResourceList,
211
- zs as useTagManager,
212
- Ks as useTokenProvider,
213
- Qs as useTrackingDetails,
214
- Xs as useTranslation,
215
- Zs as useValidationFeedback,
216
- _s as useViewJsonOverlay,
217
- $s as withSkeletonTemplate
211
+ zs as useResourceList,
212
+ Ks as useTagManager,
213
+ Qs as useTokenProvider,
214
+ Xs as useTrackingDetails,
215
+ Zs as useTranslation,
216
+ _s as useValidationFeedback,
217
+ $s as useViewJsonOverlay,
218
+ at as withSkeletonTemplate
218
219
  };
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { t as D, c as T, m as p, a as N } from "./main-RB0PeDoP.js";
2
+ import { t as D, c as T, m as p, a as N } from "./main-YBGuu4K1.js";
3
3
  function W(t, e) {
4
4
  const n = () => T(e?.in, NaN), a = I(t);
5
5
  let s;
@@ -1,12 +1,13 @@
1
1
  import { CustomerPaymentSource, Order, PaymentMethod } from '@commercelayer/sdk';
2
2
  import { FC, ReactNode } from 'react';
3
3
  import { SetNonNullable, SetRequired } from 'type-fest';
4
+ type PaymentMethodResource = SetRequired<SetNonNullable<Partial<Order>, "payment_method">, "payment_method"> | SetRequired<SetNonNullable<CustomerPaymentSource, "payment_source">, "payment_source">;
4
5
  export interface ResourcePaymentMethodProps {
5
6
  /**
6
7
  * Any resource that has `payment_source` or `payment_method` properties is actually eligible.
7
8
  * But we are only interested in `Order` and `CustomerPaymentSource` resources.
8
9
  */
9
- resource: SetRequired<SetNonNullable<Partial<Order>, "payment_method">, "payment_method"> | SetRequired<SetNonNullable<CustomerPaymentSource, "payment_source">, "payment_source">;
10
+ resource: PaymentMethodResource;
10
11
  /**
11
12
  * When true and if `payment_source.payment_response` is present, enables the expandable content to show more details on the transaction.
12
13
  */
@@ -28,3 +29,15 @@ export declare const ResourcePaymentMethod: FC<ResourcePaymentMethodProps>;
28
29
  * Retrieve the logo URL based on the payment source type.
29
30
  */
30
31
  export declare function getPaymentMethodLogoSrc(type?: PaymentMethod["payment_source_type"]): string;
32
+ /**
33
+ * Extracts payment instrument details from an Order or CustomerPaymentSource resource.
34
+ * Returns individual parts, all of which may be `undefined` if not available.
35
+ */
36
+ export declare function getPaymentInstrumentDetails(resource: PaymentMethodResource): {
37
+ paymentMethodName: string | undefined;
38
+ cardType: string | undefined;
39
+ issuerType: string | undefined;
40
+ cardLastDigits: string | undefined;
41
+ cardExpiry: string | undefined;
42
+ };
43
+ export {};
@@ -0,0 +1,10 @@
1
+ import { JSX } from 'react';
2
+ import { FilterItemGroupedPredicates } from './types';
3
+ interface FieldGroupedPredicatesProps {
4
+ item: FilterItemGroupedPredicates;
5
+ }
6
+ export declare function FieldGroupedPredicates({ item, }: FieldGroupedPredicatesProps): JSX.Element;
7
+ export declare namespace FieldGroupedPredicates {
8
+ var displayName: string;
9
+ }
10
+ export {};
@@ -51,6 +51,62 @@ export interface BaseFilterItem {
51
51
  parseFormValue?: (value: unknown) => ValueOf<QueryFilter> | undefined;
52
52
  };
53
53
  }
54
+ export interface FilterItemGroupedPredicates {
55
+ /**
56
+ * Label of the filter field in form component
57
+ */
58
+ label: string;
59
+ /**
60
+ * Flag to hide the filter field in form component
61
+ */
62
+ hidden?: boolean;
63
+ type: "groupedPredicates";
64
+ /**
65
+ * The URL query string key used to identify this filter in the URL and form state.
66
+ * Unlike other filter types, this is NOT an SDK predicate — it is a virtual key used
67
+ * only for URL serialization and react-hook-form state management.
68
+ * The actual SDK predicates are defined per-option inside `render.props.options`.
69
+ * @example
70
+ * ```ts
71
+ * urlParamKey: "availability" // → ?availability=in_stock
72
+ * ```
73
+ */
74
+ urlParamKey: string;
75
+ render: {
76
+ /**
77
+ * UI component to render
78
+ */
79
+ component: "inputToggleButton";
80
+ /**
81
+ * Props required for the UI component
82
+ */
83
+ props: {
84
+ mode: "single" | "multi";
85
+ /**
86
+ * Each option maps to a specific SDK predicate + value pair when selected.
87
+ * An option can be hidden from the UI but still be used in the query.
88
+ * @example
89
+ * ```ts
90
+ * [
91
+ * { label: 'Has items', value: 'has_items', sdk: { predicate: 'quantity_gteq', value: '1' } },
92
+ * { label: 'Empty', value: 'empty', sdk: { predicate: 'quantity_eq', value: '0' } },
93
+ * ]
94
+ * ```
95
+ */
96
+ options: Array<{
97
+ label: string;
98
+ /** The value stored in the URL query string and form state */
99
+ value: string;
100
+ isHidden?: boolean;
101
+ /** The actual SDK predicate + value this option maps to when selected */
102
+ sdk: {
103
+ predicate: string;
104
+ value: string;
105
+ };
106
+ }>;
107
+ };
108
+ };
109
+ }
54
110
  export type FilterItemOptions = BaseFilterItem & {
55
111
  type: "options";
56
112
  render: {
@@ -126,9 +182,21 @@ export interface FilterItemCurrencyRange extends Omit<BaseFilterItem, "sdk"> {
126
182
  props: Omit<InputCurrencyRangeProps, "onChange" | "fromCents" | "toCents" | "defaultCurrency" | "currencyList">;
127
183
  };
128
184
  }
129
- export type FiltersInstructionItem = FilterItemOptions | FilterItemTextSearch | FilterItemTime | FilterItemCurrencyRange;
185
+ export type FiltersInstructionItem = FilterItemOptions | FilterItemTextSearch | FilterItemTime | FilterItemCurrencyRange | FilterItemGroupedPredicates;
130
186
  export type FiltersInstructions = FiltersInstructionItem[];
131
187
  export declare function isItemOptions(item: FiltersInstructionItem): item is FilterItemOptions;
132
188
  export declare function isTextSearch(item: FiltersInstructionItem): item is FilterItemTextSearch;
133
189
  export declare function isCurrencyRange(item: FiltersInstructionItem): item is FilterItemCurrencyRange;
190
+ export declare function isGroupedPredicates(item: FiltersInstructionItem): item is FilterItemGroupedPredicates;
191
+ /**
192
+ * Returns the URL query string key / form field name for any instruction item.
193
+ *
194
+ * - For all standard types (`options`, `textSearch`, `timeRange`, `currencyRange`) this is `item.sdk.predicate`.
195
+ * - For `groupedPredicates` it is `item.urlParamKey`, because that type has no single SDK predicate
196
+ * (each option maps to its own predicate at the option level).
197
+ *
198
+ * Use this helper everywhere you need to resolve the URL/form key from an unnarrowed `FiltersInstructionItem`
199
+ * instead of accessing `item.sdk.predicate` directly.
200
+ */
201
+ export declare function getInstructionKey(item: FiltersInstructionItem): string;
134
202
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commercelayer/app-elements",
3
- "version": "7.4.2",
3
+ "version": "7.5.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "files": [