@solibo/solibo-react 1.57.9 → 1.58.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.
Files changed (54) hide show
  1. package/dist/api/commands/board/useSetBoardMemberTerm.d.ts +5 -0
  2. package/dist/api/commands/board/useSetBoardMemberTerm.js +9 -0
  3. package/dist/api/commands/conversation/useConversationFolders.d.ts +1 -4
  4. package/dist/api/commands/conversation/useConversationHelpers.d.ts +16 -0
  5. package/dist/api/commands/conversation/useConversationHelpers.js +25 -0
  6. package/dist/api/commands/document/useIntegratedDocumentMutations.d.ts +18 -18
  7. package/dist/api/commands/document/useIntegratedRetry.d.ts +34 -0
  8. package/dist/api/commands/document/useIntegratedRetry.js +56 -0
  9. package/dist/api/commands/document/useOwnedDocumentMutations.d.ts +29 -0
  10. package/dist/api/commands/document/useOwnedDocumentMutations.js +128 -0
  11. package/dist/api/commands/economy/useCreateInvoiceComment.d.ts +5 -0
  12. package/dist/api/commands/economy/useCreateInvoiceComment.js +9 -0
  13. package/dist/api/commands/expense/useDeleteExpense.d.ts +1 -0
  14. package/dist/api/commands/homepage/useDeleteHomepageImage.d.ts +5 -0
  15. package/dist/api/commands/homepage/useDeleteHomepageImage.js +10 -0
  16. package/dist/api/commands/insurance/useDeleteInsurance.d.ts +1 -0
  17. package/dist/api/commands/invoicing/useDeleteAdHocLineGroup.d.ts +1 -0
  18. package/dist/api/commands/issue/useDeleteIssue.d.ts +1 -0
  19. package/dist/api/commands/loan/useUpdateLoan.d.ts +1 -0
  20. package/dist/api/commands/meeting/useDeleteMeeting.d.ts +1 -0
  21. package/dist/api/commands/resident/useUpdateResidentContact.d.ts +6 -0
  22. package/dist/api/commands/resident/useUpdateResidentContact.js +14 -0
  23. package/dist/api/commands/routines/useDeleteRoutine.d.ts +1 -0
  24. package/dist/api/commands/settlement/useDeleteSettlement.d.ts +1 -0
  25. package/dist/api/commands/settlement/useDeleteSettlementCustomCost.d.ts +1 -0
  26. package/dist/api/queries/company/useCompanyNames.d.ts +27 -0
  27. package/dist/api/queries/company/useCompanyNames.js +50 -0
  28. package/dist/api/queries/countries/useCountryLookup.d.ts +25 -0
  29. package/dist/api/queries/countries/useCountryLookup.js +36 -0
  30. package/dist/api/queries/document/useDocumentURL.d.ts +46 -0
  31. package/dist/api/queries/document/useDocumentURL.js +58 -0
  32. package/dist/api/queries/invoicing/usePlannedInvoicePreviews.d.ts +3 -0
  33. package/dist/api/queries/invoicing/usePlannedInvoicePreviews.js +7 -0
  34. package/dist/api/queries/user/useCompanyActions.d.ts +27 -0
  35. package/dist/api/queries/user/useCompanyActions.js +40 -0
  36. package/dist/api/queries/utilityUsage/useUtilityUsage.d.ts +4 -0
  37. package/dist/api/queries/utilityUsage/useUtilityUsage.js +11 -0
  38. package/dist/events/index.d.ts +2 -0
  39. package/dist/events/index.js +2 -0
  40. package/dist/events/useDomainEvents.d.ts +29 -0
  41. package/dist/events/useDomainEvents.js +52 -0
  42. package/dist/events/useLiveHomepage.d.ts +10 -0
  43. package/dist/events/useLiveHomepage.js +43 -0
  44. package/dist/index.d.ts +16 -0
  45. package/dist/index.js +15 -0
  46. package/dist/sharedText/index.d.ts +1 -0
  47. package/dist/sharedText/index.js +1 -0
  48. package/dist/sharedText/useSharedText.d.ts +48 -0
  49. package/dist/sharedText/useSharedText.js +55 -0
  50. package/dist/utils/pages.d.ts +42 -0
  51. package/dist/utils/pages.js +50 -0
  52. package/dist/utils/useByteArrayUrl.d.ts +7 -0
  53. package/dist/utils/useByteArrayUrl.js +18 -0
  54. package/package.json +40 -5
@@ -0,0 +1,50 @@
1
+ import { useEffect, useMemo } from 'react';
2
+ /** The page size a list asks for when it shows one page at a time. */
3
+ export const DEFAULT_PAGE_SIZE = 20;
4
+ /** The largest page the backend serves; ask for it when a list must load every item. */
5
+ export const MAX_PAGE_SIZE = 1000;
6
+ /** The items of every page loaded so far, in order. Stable while the pages are unchanged. */
7
+ export function usePagedItems(data) {
8
+ const pages = data?.pages;
9
+ return useMemo(() => (pages ?? []).flatMap((page) => [...(page?.items ?? [])]), [pages]);
10
+ }
11
+ /**
12
+ * Loads every page of a paged infinite query, one after the other, and returns their items. Use it
13
+ * where a screen needs the whole collection (a permission check, a select box); pass a large
14
+ * `count` (up to MAX_PAGE_SIZE) to the query to keep the number of requests down. Loading stops at
15
+ * the first error and goes on when the query is retried.
16
+ */
17
+ export function useAllPages(query, enabled = true) {
18
+ const { fetchNextPage, hasNextPage, isFetchingNextPage, isFetching, isError, } = query;
19
+ // The page count is a dependency too: a page that arrives at once can leave every flag as it
20
+ // was in the render before, and the next page must still be asked for.
21
+ const pageCount = query.data?.pages.length ?? 0;
22
+ useEffect(() => {
23
+ if (enabled &&
24
+ hasNextPage &&
25
+ !isFetchingNextPage &&
26
+ !isFetching &&
27
+ !isError) {
28
+ void fetchNextPage({ cancelRefetch: false });
29
+ }
30
+ }, [
31
+ enabled,
32
+ fetchNextPage,
33
+ hasNextPage,
34
+ isFetchingNextPage,
35
+ isFetching,
36
+ isError,
37
+ pageCount,
38
+ ]);
39
+ const items = usePagedItems(query.data);
40
+ const isComplete = !!query.isSuccess && !hasNextPage;
41
+ return {
42
+ items,
43
+ isComplete,
44
+ isPending: !isError &&
45
+ !isComplete &&
46
+ (query.isPending !== false || !!hasNextPage),
47
+ isError: !!isError,
48
+ error: query.error,
49
+ };
50
+ }
@@ -0,0 +1,7 @@
1
+ import { type SdkBytes } from '@solibo/solibo-query';
2
+ /**
3
+ * An object URL (`blob:`) for the bytes of a file the SDK returned, such as an invoice PDF, to show
4
+ * in a viewer or offer as a download. The URL belongs to these bytes: it is revoked when they
5
+ * change or the component unmounts. Undefined until there are bytes.
6
+ */
7
+ export declare function useByteArrayUrl(bytes: SdkBytes | null | undefined, contentType?: string): string | undefined;
@@ -0,0 +1,18 @@
1
+ import { useEffect, useState } from 'react';
2
+ import { byteArrayToBlob } from '@solibo/solibo-query';
3
+ /**
4
+ * An object URL (`blob:`) for the bytes of a file the SDK returned, such as an invoice PDF, to show
5
+ * in a viewer or offer as a download. The URL belongs to these bytes: it is revoked when they
6
+ * change or the component unmounts. Undefined until there are bytes.
7
+ */
8
+ export function useByteArrayUrl(bytes, contentType = 'application/octet-stream') {
9
+ const [url, setUrl] = useState();
10
+ useEffect(() => {
11
+ if (bytes == null)
12
+ return;
13
+ const objectUrl = URL.createObjectURL(byteArrayToBlob(bytes, contentType));
14
+ setUrl({ bytes, url: objectUrl });
15
+ return () => URL.revokeObjectURL(objectUrl);
16
+ }, [bytes, contentType]);
17
+ return url != null && url.bytes === bytes ? url.url : undefined;
18
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solibo/solibo-react",
3
- "version": "1.57.9",
3
+ "version": "1.58.0",
4
4
  "description": "React hooks for the Solibo Home SDK, built on @solibo/solibo-query. Solibo Home is the platform for owning and managing homes in Norway.",
5
5
  "homepage": "https://sdk.solibo.no",
6
6
  "repository": {
@@ -26,6 +26,34 @@
26
26
  "main": "dist/index.js",
27
27
  "module": "dist/index.js",
28
28
  "types": "dist/index.d.ts",
29
+ "exports": {
30
+ ".": {
31
+ "types": "./dist/index.d.ts",
32
+ "import": "./dist/index.js",
33
+ "default": "./dist/index.js"
34
+ },
35
+ "./shared-text": {
36
+ "types": "./dist/sharedText/index.d.ts",
37
+ "import": "./dist/sharedText/index.js",
38
+ "default": "./dist/sharedText/index.js"
39
+ },
40
+ "./events": {
41
+ "types": "./dist/events/index.d.ts",
42
+ "import": "./dist/events/index.js",
43
+ "default": "./dist/events/index.js"
44
+ },
45
+ "./package.json": "./package.json"
46
+ },
47
+ "typesVersions": {
48
+ "*": {
49
+ "shared-text": [
50
+ "dist/sharedText/index.d.ts"
51
+ ],
52
+ "events": [
53
+ "dist/events/index.d.ts"
54
+ ]
55
+ }
56
+ },
29
57
  "type": "module",
30
58
  "sideEffects": [
31
59
  "dist/utils/bigint-polyfill.js"
@@ -36,11 +64,12 @@
36
64
  ],
37
65
  "peerDependencies": {
38
66
  "@tanstack/react-query": "^5.0.0",
39
- "react": "^19.0.0"
67
+ "react": "^19.0.0",
68
+ "yjs": "^13.6.0"
40
69
  },
41
70
  "dependencies": {
42
- "@solibo/solibo-query": "1.57.9",
43
- "@solibo/solibo-sdk": "1.57.9"
71
+ "@solibo/solibo-query": "1.58.0",
72
+ "@solibo/solibo-sdk": "1.58.0"
44
73
  },
45
74
  "devDependencies": {
46
75
  "@eslint/js": "^10.0.1",
@@ -65,11 +94,17 @@
65
94
  "typescript-eslint": "^8.58.1",
66
95
  "vite": "^8.3.1",
67
96
  "vitest": "^4.1.11",
68
- "ws": "^8.21.3"
97
+ "ws": "^8.21.3",
98
+ "yjs": "^13.6.27"
69
99
  },
70
100
  "publishConfig": {
71
101
  "access": "public"
72
102
  },
103
+ "peerDependenciesMeta": {
104
+ "yjs": {
105
+ "optional": true
106
+ }
107
+ },
73
108
  "scripts": {
74
109
  "lint": "eslint .",
75
110
  "lint:fix": "eslint . --fix",