@commercelayer/app-elements 7.16.0 → 7.17.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/dist/main.js CHANGED
@@ -1,5 +1,5 @@
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 d, au as i, av as l, aw as p, ax as g, ay as b, al as m, az as S, aA as k, aB as I, a1 as T, ae as R, a9 as D, aC as y, aD as C, aE as h, aF as A, aG as P, aH as f, aI as H, aJ as v, aK as F, aL as L, aM as B, aN as O, aO as E, aP as N, aQ as M, aR as G, 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 z, a$ as Y, 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 da, a7 as ia, bb as la, bc as pa, bd as ga, be as ba, bf as ma, bg as Sa, bh as ka, bi as Ia, bj as Ta, bk as Ra, bl as Da, bm as ya, bn as Ca, bo as ha, bp as Aa, bq as Pa, br as fa, bs as Ha, bt as va, bu as Fa, bv as La, bw as Ba, bx as Oa, by as Ea, bz as Na, bA as Ma, bB as Ga, 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 za, bL as Ya, bM as Ka, bN as Qa, bO as Xa, bP as Za, bQ as _a, bR as $a, bS as ae, ag 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 de, b$ as ie, c0 as le, c1 as pe, a8 as ge, c2 as be, c3 as me, c4 as Se, c5 as ke, c6 as Ie, c7 as Te, c8 as Re, c9 as De, ca as ye, cb as Ce, cc as he, cd as Ae, ce as Pe, cf as fe, cg as He, ch as ve, ci as Fe, cj as Le, ck as Be, cl as Oe, cm as Ee, cn as Ne, co as Me, cp as Ge, 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 ze, cz as Ye, 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 ds, cQ as is, cR as ls, cS as ps, cT as gs, cU as bs, cV as ms, cW as Ss, cX as ks, cY as Is, cZ as Ts, S as Rs, c_ as Ds, c$ as ys, d0 as Cs, ad as hs, aa as As, d1 as Ps, d2 as fs, d3 as Hs, d4 as vs, d5 as Fs, d6 as Ls, d7 as Bs, d8 as Os, d9 as Es, da as Ns, db as Ms, dc as Gs, dd as ws, de as Vs, df as xs, dg as Ws, dh as Js, di as Us, dj as js, a5 as qs, a4 as zs, dk as Ys, dl as Ks, dm as Qs, dn as Xs, dp as Zs, dq as _s, dr as $s, ds as at, dt as et, du as st, dv as tt, dw as ot, dx as rt, u as ct, dy as nt, ac as ut, dz as dt, dA as it, dB as lt } from "./main-CvmWwRKp.js";
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 d, au as i, av as l, aw as p, ax as g, ay as b, al as m, az as S, aA as k, aB as I, a1 as T, ae as R, a9 as D, aC as y, aD as C, aE as h, aF as A, aG as P, aH as f, aI as H, aJ as v, aK as F, aL as L, aM as B, aN as O, aO as E, aP as N, aQ as M, aR as G, 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 z, a$ as Y, 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 da, a7 as ia, bb as la, bc as pa, bd as ga, be as ba, bf as ma, bg as Sa, bh as ka, bi as Ia, bj as Ta, bk as Ra, bl as Da, bm as ya, bn as Ca, bo as ha, bp as Aa, bq as Pa, br as fa, bs as Ha, bt as va, bu as Fa, bv as La, bw as Ba, bx as Oa, by as Ea, bz as Na, bA as Ma, bB as Ga, 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 za, bL as Ya, bM as Ka, bN as Qa, bO as Xa, bP as Za, bQ as _a, bR as $a, bS as ae, ag 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 de, b$ as ie, c0 as le, c1 as pe, a8 as ge, c2 as be, c3 as me, c4 as Se, c5 as ke, c6 as Ie, c7 as Te, c8 as Re, c9 as De, ca as ye, cb as Ce, cc as he, cd as Ae, ce as Pe, cf as fe, cg as He, ch as ve, ci as Fe, cj as Le, ck as Be, cl as Oe, cm as Ee, cn as Ne, co as Me, cp as Ge, 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 ze, cz as Ye, 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 ds, cQ as is, cR as ls, cS as ps, cT as gs, cU as bs, cV as ms, cW as Ss, cX as ks, cY as Is, cZ as Ts, S as Rs, c_ as Ds, c$ as ys, d0 as Cs, ad as hs, aa as As, d1 as Ps, d2 as fs, d3 as Hs, d4 as vs, d5 as Fs, d6 as Ls, d7 as Bs, d8 as Os, d9 as Es, da as Ns, db as Ms, dc as Gs, dd as ws, de as Vs, df as xs, dg as Ws, dh as Js, di as Us, dj as js, a5 as qs, a4 as zs, dk as Ys, dl as Ks, dm as Qs, dn as Xs, dp as Zs, dq as _s, dr as $s, ds as at, dt as et, du as st, dv as tt, dw as ot, dx as rt, u as ct, dy as nt, ac as ut, dz as dt, dA as it, dB as lt } from "./main-BCESaaEa.js";
3
3
  export {
4
4
  s as A,
5
5
  t as ActionButtons,
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { t as D, c as T, m as p, a as N } from "./main-CvmWwRKp.js";
2
+ import { t as D, c as T, m as p, a as N } from "./main-BCESaaEa.js";
3
3
  function W(t, e) {
4
4
  const n = () => T(e?.in, NaN), a = I(t);
5
5
  let s;
@@ -72,6 +72,7 @@ export declare const iconMapping: {
72
72
  readonly globeHemisphereWest: phosphor.Icon;
73
73
  readonly googleLogo: phosphor.Icon;
74
74
  readonly hourglass: phosphor.Icon;
75
+ readonly hourglassHigh: phosphor.Icon;
75
76
  readonly houseSimple: phosphor.Icon;
76
77
  readonly info: phosphor.Icon;
77
78
  readonly key: phosphor.Icon;
@@ -0,0 +1,15 @@
1
+ import { GroupBase, SelectInstance, StylesConfig } from 'react-select';
2
+ import { InputSelectBaseProps, InputSelectValue, LoadAsyncValuesPaginated } from './InputSelect';
3
+ export interface AsyncPaginateSelectComponentProps extends Omit<InputSelectBaseProps, "label" | "hint" | "asTextSearch" | "isCreatable"> {
4
+ loadAsyncValues: LoadAsyncValuesPaginated;
5
+ styles: StylesConfig<InputSelectValue>;
6
+ }
7
+ /**
8
+ * The async select that loads the next page as its menu is scrolled, instead of
9
+ * leaving everything past the first page reachable only by typing.
10
+ *
11
+ * Options are always what the server returned — client-side filtering stays off,
12
+ * as filtering a list that is only partly loaded would quietly hide matches
13
+ * sitting on a page that has not been fetched yet.
14
+ */
15
+ export declare const AsyncPaginateSelectComponent: import('react').ForwardRefExoticComponent<AsyncPaginateSelectComponentProps & import('react').RefAttributes<SelectInstance<InputSelectValue, boolean, GroupBase<InputSelectValue>>>>;
@@ -1,6 +1,6 @@
1
1
  import { GroupBase, SelectInstance, StylesConfig } from 'react-select';
2
- import { InputSelectProps, InputSelectValue } from './InputSelect';
3
- export interface CreatableComponentProps extends Omit<InputSelectProps, "loadAsyncValues" | "label" | "hint"> {
2
+ import { InputSelectBaseProps, InputSelectValue } from './InputSelect';
3
+ export interface CreatableComponentProps extends Omit<InputSelectBaseProps, "label" | "hint"> {
4
4
  styles: StylesConfig<InputSelectValue>;
5
5
  }
6
6
  export declare const CreatableComponent: import('react').ForwardRefExoticComponent<CreatableComponentProps & import('react').RefAttributes<SelectInstance<InputSelectValue, boolean, GroupBase<InputSelectValue>>>>;
@@ -2,9 +2,9 @@ import { default as React } from 'react';
2
2
  import { GroupBase, SelectInstance, StylesConfig } from 'react-select';
3
3
  import { default as AsyncSelect } from 'react-select/async';
4
4
  import { default as AsyncCreatableSelect } from 'react-select/async-creatable';
5
- import { SetRequired } from 'type-fest';
6
- import { InputSelectProps, InputSelectValue } from './InputSelect';
7
- export interface GenericAsyncSelectComponentProps extends Omit<SetRequired<InputSelectProps, "loadAsyncValues">, "label" | "hint"> {
5
+ import { InputSelectBaseProps, InputSelectValue, LoadAsyncValues } from './InputSelect';
6
+ export interface GenericAsyncSelectComponentProps extends Omit<InputSelectBaseProps, "label" | "hint"> {
7
+ loadAsyncValues: LoadAsyncValues;
8
8
  styles: StylesConfig<InputSelectValue>;
9
9
  }
10
10
  export declare const GenericAsyncSelectComponent: React.ForwardRefExoticComponent<GenericAsyncSelectComponentProps & {
@@ -1,5 +1,5 @@
1
- import { InputSelectProps, PossibleSelectValue } from './InputSelect';
2
- export interface HookedInputSelectProps extends Omit<InputSelectProps, "onSelect" | "defaultValue"> {
1
+ import { InputSelectAsyncProps, InputSelectBaseProps, PossibleSelectValue } from './InputSelect';
2
+ interface HookedInputSelectOwnProps extends Omit<InputSelectBaseProps, "onSelect" | "defaultValue"> {
3
3
  /**
4
4
  * field name to match hook-form state
5
5
  */
@@ -27,9 +27,16 @@ export interface HookedInputSelectProps extends Omit<InputSelectProps, "onSelect
27
27
  */
28
28
  onSelect?: (value: PossibleSelectValue) => void;
29
29
  }
30
+ /**
31
+ * The async half is intersected in rather than derived with `Omit`/`Pick`, as
32
+ * both collapse a union — and with it the rule that `infiniteScroll` requires the
33
+ * paginated loader.
34
+ */
35
+ export type HookedInputSelectProps = HookedInputSelectOwnProps & InputSelectAsyncProps;
30
36
  /**
31
37
  * `InputSelect` component ready to be used with the `react-hook-form` context.
32
38
  * Value to be stored in the field can be controlled from the `pathToValue` prop.
33
39
  * @see InputSelect
34
40
  */
35
41
  export declare const HookedInputSelect: React.FC<HookedInputSelectProps>;
42
+ export {};
@@ -12,7 +12,7 @@ export interface InputSelectValue {
12
12
  isDisabled?: boolean;
13
13
  }
14
14
  export type PossibleSelectValue = MultiValue<InputSelectValue> | SingleValue<InputSelectValue>;
15
- export interface InputSelectProps extends InputWrapperBaseProps {
15
+ export interface InputSelectBaseProps extends InputWrapperBaseProps {
16
16
  /**
17
17
  * Initial values to populate the select options. It can be a flat array of values or a grouped array.
18
18
  */
@@ -94,10 +94,6 @@ export interface InputSelectProps extends InputWrapperBaseProps {
94
94
  * CSS class name
95
95
  */
96
96
  className?: string;
97
- /**
98
- * Function to load async values on search
99
- */
100
- loadAsyncValues?: (inputValue: string) => Promise<GroupedSelectValues | InputSelectValue[]>;
101
97
  /**
102
98
  * Optional text to display at the bottom of the dropdown menu
103
99
  */
@@ -132,6 +128,52 @@ export interface InputSelectProps extends InputWrapperBaseProps {
132
128
  */
133
129
  menuPortalTarget?: HTMLElement | null;
134
130
  }
131
+ /**
132
+ * Loads the options matching what has been typed, all in one go.
133
+ */
134
+ export type LoadAsyncValues = (inputValue: string) => Promise<GroupedSelectValues | InputSelectValue[]>;
135
+ /**
136
+ * Loads one page of the options matching what has been typed.
137
+ *
138
+ * `hasMore` is what stops the paging: while it is `true` the menu asks for the
139
+ * page after the current one as it is scrolled to the bottom.
140
+ */
141
+ export type LoadAsyncValuesPaginated = (inputValue: string, meta: {
142
+ page: number;
143
+ }) => Promise<{
144
+ options: InputSelectValue[];
145
+ hasMore: boolean;
146
+ }>;
147
+ /**
148
+ * How the options are loaded, which also decides which select is mounted.
149
+ *
150
+ * The two are kept apart rather than folded into one optional flag so that
151
+ * turning `infiniteScroll` on makes the paginated loader mandatory — a loader
152
+ * that ignores the page it is handed would silently return the first page
153
+ * forever.
154
+ */
155
+ export type InputSelectAsyncProps = {
156
+ /**
157
+ * Load the next page of options as the menu is scrolled, so that a list
158
+ * longer than one page can be browsed instead of only searched.
159
+ *
160
+ * Opt-in: without it the select keeps loading options the way it always
161
+ * has, one non-paginated request per search.
162
+ */
163
+ infiniteScroll?: false;
164
+ /**
165
+ * Function to load async values on search
166
+ */
167
+ loadAsyncValues?: LoadAsyncValues;
168
+ } | {
169
+ infiniteScroll: true;
170
+ /**
171
+ * Function to load one page of async values. Called again with the next
172
+ * page as the menu is scrolled to the bottom.
173
+ */
174
+ loadAsyncValues: LoadAsyncValuesPaginated;
175
+ };
176
+ export type InputSelectProps = InputSelectBaseProps & InputSelectAsyncProps;
135
177
  /**
136
178
  * Advanced select component with support for async options loading and multi-select.
137
179
  * It's a wrapper around `react-select` with a subset of props exposed.
@@ -1,6 +1,6 @@
1
1
  import { GroupBase, SelectInstance, StylesConfig } from 'react-select';
2
- import { InputSelectProps, InputSelectValue } from './InputSelect';
3
- export interface SelectComponentProps extends Omit<InputSelectProps, "loadAsyncValues" | "label" | "hint"> {
2
+ import { InputSelectBaseProps, InputSelectValue } from './InputSelect';
3
+ export interface SelectComponentProps extends Omit<InputSelectBaseProps, "label" | "hint"> {
4
4
  styles: StylesConfig<InputSelectValue>;
5
5
  }
6
6
  export declare const SelectComponent: import('react').ForwardRefExoticComponent<SelectComponentProps & import('react').RefAttributes<SelectInstance<InputSelectValue, boolean, GroupBase<InputSelectValue>>>>;
@@ -1,3 +1,3 @@
1
1
  export { HookedInputSelect, type HookedInputSelectProps, } from './HookedInputSelect';
2
- export { type GroupedSelectValues, InputSelect, type InputSelectProps, type InputSelectValue, type PossibleSelectValue, } from './InputSelect';
2
+ export { type GroupedSelectValues, InputSelect, type InputSelectAsyncProps, type InputSelectBaseProps, type InputSelectProps, type InputSelectValue, type LoadAsyncValues, type LoadAsyncValuesPaginated, type PossibleSelectValue, } from './InputSelect';
3
3
  export { flatSelectValues, getDefaultValueFromFlatten, isGroupedSelectValues, isMultiValueSelected, isSingleValueSelected, } from './utils';
@@ -18,8 +18,23 @@ export interface ResourceSelectOptions {
18
18
  recordCount?: number;
19
19
  /** Whether the labels of the current selection have been resolved. */
20
20
  hasResolvedSelection: boolean;
21
- /** Server-side search, when the instruction sets `searchBy`. */
22
- loadAsyncValues?: (hint: string) => Promise<InputSelectValue[]>;
21
+ /**
22
+ * Whether anything exists beyond `initialValues`. When it does not, the whole
23
+ * list is already in hand and the select needs no request of its own.
24
+ */
25
+ hasMorePages: boolean;
26
+ /** Whether typing narrows the list server-side, i.e. `searchBy` is set. */
27
+ isSearchable: boolean;
28
+ /**
29
+ * Loads one page of options, narrowed by what has been typed when the
30
+ * instruction sets `searchBy`. Feeds the select's infinite scroll.
31
+ */
32
+ loadAsyncValues: (hint: string, meta: {
33
+ page: number;
34
+ }) => Promise<{
35
+ options: InputSelectValue[];
36
+ hasMore: boolean;
37
+ }>;
23
38
  }
24
39
  /**
25
40
  * Loads the options of a resource-backed filter select.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commercelayer/app-elements",
3
- "version": "7.16.0",
3
+ "version": "7.17.1",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -59,6 +59,7 @@
59
59
  "react-hook-form": "7.62.0",
60
60
  "react-i18next": "^15.7.4",
61
61
  "react-select": "^5.10.2",
62
+ "react-select-async-paginate": "^0.7.11",
62
63
  "react-toastify": "^11.1.0",
63
64
  "react-tooltip": "^5.30.1",
64
65
  "stable-hash": "^0.0.6",