@0xsequence/marketplace-sdk 0.8.4 → 0.8.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.
Files changed (67) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/{chunk-VF3LWBQB.js → chunk-6SEJI7YS.js} +170 -9
  3. package/dist/chunk-6SEJI7YS.js.map +1 -0
  4. package/dist/{chunk-25CAMYCG.js → chunk-BB2PTJHI.js} +22 -20
  5. package/dist/chunk-BB2PTJHI.js.map +1 -0
  6. package/dist/{chunk-XUNDLCEH.js → chunk-LDZZUYG7.js} +2 -2
  7. package/dist/{chunk-44YGZVBS.js → chunk-QMWMJVTX.js} +2 -2
  8. package/dist/{chunk-HRL2TMXU.js → chunk-TGFX3TMV.js} +44 -34
  9. package/dist/{chunk-HRL2TMXU.js.map → chunk-TGFX3TMV.js.map} +1 -1
  10. package/dist/{chunk-VBRJ2OPM.js → chunk-V3NVAVHV.js} +2 -2
  11. package/dist/index.css +171 -36
  12. package/dist/index.css.map +1 -1
  13. package/dist/index.js +6 -6
  14. package/dist/react/_internal/databeat/index.js +5 -5
  15. package/dist/react/_internal/index.d.ts +1 -1
  16. package/dist/react/_internal/index.js +3 -1
  17. package/dist/react/_internal/wagmi/index.d.ts +3 -2
  18. package/dist/react/_internal/wagmi/index.js +3 -1
  19. package/dist/react/hooks/index.d.ts +246 -29
  20. package/dist/react/hooks/index.js +8 -4
  21. package/dist/react/hooks/options/index.js +2 -2
  22. package/dist/react/index.d.ts +2 -1
  23. package/dist/react/index.js +11 -7
  24. package/dist/react/queries/index.js +1 -1
  25. package/dist/react/ssr/index.js +1 -1
  26. package/dist/react/ui/components/collectible-card/index.d.ts +3 -2
  27. package/dist/react/ui/components/collectible-card/index.js +7 -7
  28. package/dist/react/ui/icons/index.js +2 -2
  29. package/dist/react/ui/index.js +7 -7
  30. package/dist/react/ui/modals/_internal/components/actionModal/index.js +5 -5
  31. package/dist/types/index.js +1 -1
  32. package/dist/utils/abi/index.js +5 -5
  33. package/dist/utils/index.js +6 -6
  34. package/package.json +20 -19
  35. package/src/react/_internal/wagmi/__tests__/create-config.test.ts +1 -11
  36. package/src/react/_internal/wagmi/get-connectors.ts +27 -24
  37. package/src/react/hooks/__tests__/useAutoSelectFeeOption.test.tsx +21 -75
  38. package/src/react/hooks/__tests__/useCurrencyBalance.test.tsx +4 -25
  39. package/src/react/hooks/index.ts +1 -0
  40. package/src/react/hooks/useFilterState.tsx +181 -0
  41. package/src/react/hooks/useFilters.tsx +24 -0
  42. package/src/react/ui/components/_internals/action-button/__tests__/ActionButtonBody.test.tsx +27 -94
  43. package/src/react/ui/components/_internals/action-button/__tests__/NonOwnerActions.test.tsx +59 -0
  44. package/src/react/ui/components/_internals/action-button/__tests__/OwnerActions.test.tsx +73 -0
  45. package/src/react/ui/components/_internals/action-button/__tests__/useActionButtonLogic.test.tsx +77 -0
  46. package/src/react/ui/components/_internals/action-button/components/ActionButtonBody.tsx +3 -2
  47. package/src/react/ui/components/_internals/action-button/hooks/useActionButtonLogic.ts +4 -3
  48. package/src/react/ui/components/collectible-card/CollectibleAsset.tsx +1 -0
  49. package/src/react/ui/components/collectible-card/CollectibleCard.tsx +18 -12
  50. package/src/react/ui/components/collectible-card/__tests__/CollectibleAsset.test.tsx +200 -0
  51. package/src/react/ui/components/collectible-card/__tests__/CollectibleCard.test.tsx +92 -123
  52. package/src/react/ui/components/collectible-card/__tests__/Footer.test.tsx +136 -0
  53. package/src/react/ui/modals/BuyModal/__tests__/Modal.test.tsx +2 -8
  54. package/src/react/ui/modals/SellModal/__tests__/Modal.test.tsx +72 -135
  55. package/src/react/ui/modals/_internal/components/selectWaasFeeOptions/__tests__/ActionButtons.test.tsx +72 -0
  56. package/src/react/ui/modals/_internal/components/selectWaasFeeOptions/__tests__/BalanceIndicator.test.tsx +50 -0
  57. package/src/react/ui/modals/_internal/components/selectWaasFeeOptions/__tests__/SelectWaasFeeOptions.test.tsx +193 -0
  58. package/src/react/ui/modals/_internal/components/switchChainModal/__tests__/SwitchChainModal.test.tsx +38 -58
  59. package/src/react/ui/modals/_internal/components/switchChainModal/index.tsx +3 -1
  60. package/test/test-utils.tsx +12 -22
  61. package/tsconfig.tsbuildinfo +1 -1
  62. package/dist/chunk-25CAMYCG.js.map +0 -1
  63. package/dist/chunk-VF3LWBQB.js.map +0 -1
  64. package/src/react/ui/components/_internals/action-button/__tests__/ActionButton.test.tsx +0 -107
  65. /package/dist/{chunk-XUNDLCEH.js.map → chunk-LDZZUYG7.js.map} +0 -0
  66. /package/dist/{chunk-44YGZVBS.js.map → chunk-QMWMJVTX.js.map} +0 -0
  67. /package/dist/{chunk-VBRJ2OPM.js.map → chunk-V3NVAVHV.js.map} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @0xsequence/marketplace-sdk
2
2
 
3
+ ## 0.8.6
4
+
5
+ ### Patch Changes
6
+
7
+ - - Added `useFilterState` to easily manage filter state with [nuqs](https://nuqs.47ng.com/)
8
+ - Added `useFiltersProgressive` hook for initializing filters with only keys, speeding up initial load
9
+ - Updated dependencies and improved tests
10
+
11
+ ## 0.8.5
12
+
13
+ ### Patch Changes
14
+
15
+ - Ignore embedded connectors if ecosystem connector is enabled
16
+ - CollectibleCard prop `lowestListing` renamed to `collectible` and `balanceIsLoading` is mandatory
17
+ - Improved test coverage and misc fixes
18
+
3
19
  ## 0.8.4
4
20
 
5
21
  ### Patch Changes
@@ -2,7 +2,7 @@
2
2
 
3
3
  import {
4
4
  collectionOptions
5
- } from "./chunk-XUNDLCEH.js";
5
+ } from "./chunk-LDZZUYG7.js";
6
6
  import {
7
7
  InfoIcon_default
8
8
  } from "./chunk-SJU6QZHM.js";
@@ -14,12 +14,12 @@ import {
14
14
  compareAddress,
15
15
  getPresentableChainName
16
16
  } from "./chunk-BGY4WXER.js";
17
- import {
18
- EIP2981_ABI
19
- } from "./chunk-XX4EVWBF.js";
20
17
  import {
21
18
  ERC1155_ABI
22
19
  } from "./chunk-FUM4OGOQ.js";
20
+ import {
21
+ EIP2981_ABI
22
+ } from "./chunk-XX4EVWBF.js";
23
23
  import {
24
24
  balanceOfCollectibleOptions,
25
25
  highestOfferOptions,
@@ -36,7 +36,7 @@ import {
36
36
  CollectableIdSchema,
37
37
  PROVIDER_ID,
38
38
  QueryArgSchema
39
- } from "./chunk-25CAMYCG.js";
39
+ } from "./chunk-BB2PTJHI.js";
40
40
  import {
41
41
  BaseError,
42
42
  ChainSwitchError,
@@ -1148,7 +1148,8 @@ var UseFiltersSchema = z9.object({
1148
1148
  chainId: z9.number(),
1149
1149
  collectionAddress: AddressSchema,
1150
1150
  showAllFilters: z9.boolean().default(false).optional(),
1151
- query: QueryArgSchema
1151
+ query: QueryArgSchema,
1152
+ excludePropertyValues: z9.boolean().default(false).optional()
1152
1153
  });
1153
1154
  var fetchFilters = async (args, config) => {
1154
1155
  const parsedArgs = UseFiltersSchema.parse(args);
@@ -1156,8 +1157,9 @@ var fetchFilters = async (args, config) => {
1156
1157
  const filters = await metadataClient.getTokenMetadataPropertyFilters({
1157
1158
  chainID: parsedArgs.chainId.toString(),
1158
1159
  contractAddress: parsedArgs.collectionAddress,
1159
- excludeProperties: []
1160
+ excludeProperties: [],
1160
1161
  // TODO: We can leverage this for some of the exclusion logic
1162
+ excludePropertyValues: parsedArgs.excludePropertyValues
1161
1163
  }).then((resp) => resp.filters);
1162
1164
  if (args.showAllFilters) return filters;
1163
1165
  const queryClient = getQueryClient();
@@ -1208,6 +1210,163 @@ var useFilters = (args) => {
1208
1210
  const config = useConfig();
1209
1211
  return useQuery11(filtersOptions(args, config));
1210
1212
  };
1213
+ var useFiltersProgressive = (args) => {
1214
+ const config = useConfig();
1215
+ const namesQuery = useQuery11(
1216
+ filtersOptions({ ...args, excludePropertyValues: true }, config)
1217
+ );
1218
+ const fullQuery = useQuery11({
1219
+ ...filtersOptions(args, config),
1220
+ placeholderData: namesQuery.data
1221
+ });
1222
+ const isLoadingNames = namesQuery.isLoading;
1223
+ const isFetchingValues = fullQuery.isPlaceholderData && fullQuery.isFetching;
1224
+ return {
1225
+ ...fullQuery,
1226
+ isFetchingValues,
1227
+ isLoadingNames
1228
+ };
1229
+ };
1230
+
1231
+ // src/react/hooks/useFilterState.tsx
1232
+ import { useMemo } from "react";
1233
+ import {
1234
+ createSerializer,
1235
+ parseAsBoolean,
1236
+ parseAsJson,
1237
+ parseAsString,
1238
+ useQueryState
1239
+ } from "nuqs";
1240
+ var validateFilters = (value) => {
1241
+ if (!Array.isArray(value)) return [];
1242
+ return value.filter(
1243
+ (f) => typeof f === "object" && typeof f.name === "string" && Object.values(PropertyType).includes(f.type)
1244
+ );
1245
+ };
1246
+ var filtersParser = parseAsJson(validateFilters).withDefault([]);
1247
+ var searchParser = parseAsString.withDefault("");
1248
+ var listedOnlyParser = parseAsBoolean.withDefault(false);
1249
+ var serialize = createSerializer(
1250
+ {
1251
+ filters: filtersParser,
1252
+ search: searchParser,
1253
+ listedOnly: listedOnlyParser
1254
+ },
1255
+ {
1256
+ urlKeys: {
1257
+ filters: "f",
1258
+ search: "q",
1259
+ listedOnly: "l"
1260
+ }
1261
+ }
1262
+ );
1263
+ function useFilterState() {
1264
+ const [filterOptions, setFilterOptions] = useQueryState(
1265
+ "filters",
1266
+ filtersParser
1267
+ );
1268
+ const [searchText, setSearchText] = useQueryState("search", searchParser);
1269
+ const [showListedOnly, setShowListedOnly] = useQueryState(
1270
+ "listedOnly",
1271
+ listedOnlyParser
1272
+ );
1273
+ const helpers = useMemo(
1274
+ () => ({
1275
+ getFilter: (name) => {
1276
+ return filterOptions?.find((f) => f.name === name);
1277
+ },
1278
+ getFilterValues: (name) => {
1279
+ const filter = filterOptions?.find((f) => f.name === name);
1280
+ if (!filter) return void 0;
1281
+ if (filter.type === "INT" /* INT */) {
1282
+ return {
1283
+ type: "INT" /* INT */,
1284
+ min: filter.min ?? 0,
1285
+ max: filter.max ?? 0
1286
+ };
1287
+ }
1288
+ return {
1289
+ type: "STRING" /* STRING */,
1290
+ values: filter.values ?? []
1291
+ };
1292
+ },
1293
+ isFilterActive: (name) => {
1294
+ return !!filterOptions?.find((f) => f.name === name);
1295
+ },
1296
+ isStringValueSelected: (name, value) => {
1297
+ const filter = filterOptions?.find((f) => f.name === name);
1298
+ if (!filter || filter.type !== "STRING" /* STRING */) return false;
1299
+ return filter.values?.includes(value) ?? false;
1300
+ },
1301
+ isIntFilterActive: (name) => {
1302
+ const filter = filterOptions?.find((f) => f.name === name);
1303
+ return !!filter && filter.type === "INT" /* INT */;
1304
+ },
1305
+ getIntFilterRange: (name) => {
1306
+ const filter = filterOptions?.find((f) => f.name === name);
1307
+ if (!filter || filter.type !== "INT" /* INT */) return void 0;
1308
+ return [filter.min ?? 0, filter.max ?? 0];
1309
+ },
1310
+ deleteFilter: (name) => {
1311
+ const otherFilters = filterOptions?.filter((f) => !(f.name === name)) ?? [];
1312
+ setFilterOptions(otherFilters);
1313
+ },
1314
+ toggleStringFilterValue: (name, value) => {
1315
+ const otherFilters = filterOptions?.filter((f) => !(f.name === name)) ?? [];
1316
+ const filter = filterOptions?.find((f) => f.name === name);
1317
+ const existingValues = filter?.type === "STRING" /* STRING */ ? filter.values ?? [] : [];
1318
+ if (existingValues.includes(value)) {
1319
+ const newValues = existingValues.filter((v) => v !== value);
1320
+ if (newValues.length === 0) {
1321
+ setFilterOptions(otherFilters);
1322
+ return;
1323
+ }
1324
+ setFilterOptions([
1325
+ ...otherFilters,
1326
+ { name, type: "STRING" /* STRING */, values: newValues }
1327
+ ]);
1328
+ } else {
1329
+ setFilterOptions([
1330
+ ...otherFilters,
1331
+ {
1332
+ name,
1333
+ type: "STRING" /* STRING */,
1334
+ values: [...existingValues, value]
1335
+ }
1336
+ ]);
1337
+ }
1338
+ },
1339
+ setIntFilterValue: (name, min, max) => {
1340
+ if (min === max && min === 0) {
1341
+ const otherFilters2 = filterOptions?.filter((f) => !(f.name === name)) ?? [];
1342
+ setFilterOptions(otherFilters2);
1343
+ return;
1344
+ }
1345
+ const otherFilters = filterOptions?.filter((f) => !(f.name === name)) ?? [];
1346
+ setFilterOptions([
1347
+ ...otherFilters,
1348
+ { name, type: "INT" /* INT */, min, max }
1349
+ ]);
1350
+ },
1351
+ clearAllFilters: () => {
1352
+ void setShowListedOnly(false);
1353
+ void setFilterOptions([]);
1354
+ void setSearchText("");
1355
+ }
1356
+ }),
1357
+ [filterOptions, setFilterOptions, setShowListedOnly, setSearchText]
1358
+ );
1359
+ return {
1360
+ filterOptions,
1361
+ searchText,
1362
+ showListedOnly,
1363
+ setFilterOptions,
1364
+ setSearchText,
1365
+ setShowListedOnly,
1366
+ ...helpers,
1367
+ serialize
1368
+ };
1369
+ }
1211
1370
 
1212
1371
  // src/react/hooks/useFloorOrder.tsx
1213
1372
  import { queryOptions as queryOptions9, useQuery as useQuery12 } from "@tanstack/react-query";
@@ -2218,7 +2377,7 @@ var SwitchChainModal = observer(() => {
2218
2377
  name: "switch-chain",
2219
2378
  id: "switch-chain-button",
2220
2379
  size: "sm",
2221
- label: isSwitching$.get() ? /* @__PURE__ */ jsx3(Spinner, { className: "spinner" }) : "Switch Network",
2380
+ label: isSwitching$.get() ? /* @__PURE__ */ jsx3("div", { "data-testid": "switch-chain-spinner", children: /* @__PURE__ */ jsx3(Spinner, { className: "spinner" }) }) : "Switch Network",
2222
2381
  variant: "primary",
2223
2382
  pending: isSwitching$.get(),
2224
2383
  shape: "square",
@@ -2649,6 +2808,8 @@ export {
2649
2808
  fetchFilters,
2650
2809
  filtersOptions,
2651
2810
  useFilters,
2811
+ useFiltersProgressive,
2812
+ useFilterState,
2652
2813
  floorOrderOptions,
2653
2814
  useFloorOrder,
2654
2815
  useHighestOffer,
@@ -2697,4 +2858,4 @@ export {
2697
2858
  collectionDetailsPollingOptions,
2698
2859
  useCollectionDetailsPolling
2699
2860
  };
2700
- //# sourceMappingURL=chunk-VF3LWBQB.js.map
2861
+ //# sourceMappingURL=chunk-6SEJI7YS.js.map