@plitzi/sdk-elements 0.32.25 → 0.33.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.
Files changed (59) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/dist/Element/ElementContext.d.ts +7 -0
  3. package/dist/Element/helpers/isVisible.d.ts +1 -0
  4. package/dist/Element/helpers/isVisible.mjs +4 -0
  5. package/dist/Element/hocs/withElement.mjs +86 -78
  6. package/dist/Element/hooks/useInternalClassName.mjs +21 -20
  7. package/dist/Element/hooks/useInternalItems.mjs +1 -1
  8. package/dist/Element/hooks/useRscData.d.ts +4 -3
  9. package/dist/Element/hooks/useRscData.mjs +15 -10
  10. package/dist/dataSource/GlobalSources.d.ts +1 -2
  11. package/dist/dataSource/GlobalSources.mjs +46 -62
  12. package/dist/elements/advanced/BlockJsx/BlockJsx.mjs +1 -1
  13. package/dist/elements/basic/Link/Link.mjs +47 -41
  14. package/dist/elements/basic/RichText/RichText.d.ts +20 -0
  15. package/dist/elements/basic/RichText/RichText.mjs +30 -0
  16. package/dist/elements/basic/RichText/Settings.d.ts +7 -0
  17. package/dist/elements/basic/RichText/Settings.mjs +51 -0
  18. package/dist/elements/{provider/CollectionContainer → basic/RichText}/index.d.ts +6 -7
  19. package/dist/elements/{provider/CollectionContainer → basic/RichText}/index.mjs +12 -13
  20. package/dist/elements/basic/RichText/sanitizeHtml.d.ts +21 -0
  21. package/dist/elements/basic/RichText/sanitizeHtml.mjs +8 -0
  22. package/dist/elements/form/FormControl/index.mjs +1 -1
  23. package/dist/elements/index.d.ts +5 -3
  24. package/dist/elements/index.mjs +30 -28
  25. package/dist/elements/internal/Page/Page.mjs +28 -26
  26. package/dist/elements/provider/ApiContainer/ApiContainer.d.ts +28 -1
  27. package/dist/elements/provider/ApiContainer/ApiContainer.mjs +201 -86
  28. package/dist/elements/provider/ApiContainer/Settings.d.ts +15 -3
  29. package/dist/elements/provider/ApiContainer/Settings.mjs +209 -92
  30. package/dist/elements/provider/ApiContainer/components/FiltersInput/FiltersInput.d.ts +22 -0
  31. package/dist/elements/provider/ApiContainer/components/FiltersInput/FiltersInput.mjs +75 -0
  32. package/dist/elements/provider/ApiContainer/components/FiltersInput/index.d.ts +3 -0
  33. package/dist/elements/provider/ApiContainer/components/FiltersInput/index.mjs +5 -0
  34. package/dist/elements/provider/ApiContainer/hooks/useProviderPagination.d.ts +31 -0
  35. package/dist/elements/provider/ApiContainer/hooks/useProviderPagination.mjs +51 -0
  36. package/dist/elements/provider/ApiContainer/hooks/useProviderWrite.d.ts +26 -0
  37. package/dist/elements/provider/ApiContainer/hooks/useProviderWrite.mjs +27 -0
  38. package/dist/elements/provider/ApiContainer/index.d.ts +8 -0
  39. package/dist/elements/provider/ApiContainer/index.mjs +9 -1
  40. package/dist/elements/settings.mjs +32 -30
  41. package/dist/elements/structure/Pagination/Pagination.d.ts +41 -0
  42. package/dist/elements/structure/Pagination/Pagination.mjs +83 -0
  43. package/dist/elements/structure/Pagination/Settings.d.ts +12 -0
  44. package/dist/elements/structure/Pagination/Settings.mjs +85 -0
  45. package/dist/elements/structure/Pagination/buildPageWindow.d.ts +9 -0
  46. package/dist/elements/structure/Pagination/buildPageWindow.mjs +8 -0
  47. package/dist/elements/structure/Pagination/index.d.ts +67 -0
  48. package/dist/elements/structure/Pagination/index.mjs +59 -0
  49. package/dist/index.d.ts +130 -57
  50. package/dist/index.mjs +32 -30
  51. package/package.json +76 -32
  52. package/dist/elements/internal/Page/helpers/UserHelper.d.ts +0 -4
  53. package/dist/elements/provider/CollectionContainer/CollectionContainer.d.ts +0 -18
  54. package/dist/elements/provider/CollectionContainer/CollectionContainer.mjs +0 -69
  55. package/dist/elements/provider/CollectionContainer/CollectionContainer.stories-pending.d.ts +0 -1
  56. package/dist/elements/provider/CollectionContainer/Settings.d.ts +0 -10
  57. package/dist/elements/provider/CollectionContainer/Settings.mjs +0 -74
  58. package/dist/elements/provider/CollectionContainer/hooks/useCollectionContext.d.ts +0 -19
  59. package/dist/elements/provider/CollectionContainer/hooks/useCollectionContext.mjs +0 -71
package/dist/index.mjs CHANGED
@@ -11,55 +11,57 @@ import l from "./elements/basic/Heading/index.mjs";
11
11
  import u from "./elements/basic/Link/index.mjs";
12
12
  import d from "./elements/basic/Markdown/index.mjs";
13
13
  import f from "./elements/basic/Paragraph/index.mjs";
14
- import p from "./elements/basic/Text/index.mjs";
15
- import m from "./elements/form/Form/index.mjs";
16
- import h from "./elements/form/FormControl/index.mjs";
17
- import g from "./elements/internal/LayoutContainer/index.mjs";
18
- import _ from "./elements/internal/Loading/index.mjs";
19
- import { NotFound as v } from "./elements/internal/NotFound/index.mjs";
20
- import y from "./elements/internal/Page/index.mjs";
21
- import b from "./elements/media/FontAwesome/index.mjs";
22
- import x from "./elements/media/Image/index.mjs";
23
- import S from "./elements/media/Video/index.mjs";
24
- import C from "./elements/provider/ApiContainer/index.mjs";
25
- import w from "./elements/provider/CollectionContainer/index.mjs";
14
+ import p from "./elements/basic/RichText/index.mjs";
15
+ import m from "./elements/basic/Text/index.mjs";
16
+ import h from "./elements/form/Form/index.mjs";
17
+ import g from "./elements/form/FormControl/index.mjs";
18
+ import _ from "./elements/internal/LayoutContainer/index.mjs";
19
+ import v from "./elements/internal/Loading/index.mjs";
20
+ import { NotFound as y } from "./elements/internal/NotFound/index.mjs";
21
+ import b from "./elements/internal/Page/index.mjs";
22
+ import x from "./elements/media/FontAwesome/index.mjs";
23
+ import S from "./elements/media/Image/index.mjs";
24
+ import C from "./elements/media/Video/index.mjs";
25
+ import w from "./elements/provider/ApiContainer/index.mjs";
26
26
  import T from "./elements/structure/Container/index.mjs";
27
27
  import E from "./elements/structure/DialogContainer/index.mjs";
28
28
  import D from "./elements/structure/List/index.mjs";
29
29
  import O from "./elements/structure/ModalContainer/index.mjs";
30
- import k from "./elements/structure/TabContainer/index.mjs";
31
- import { elements_exports as A } from "./elements/index.mjs";
32
- import { defaultElementsSettings as j, settings_exports as M } from "./elements/settings.mjs";
30
+ import k from "./elements/structure/Pagination/index.mjs";
31
+ import A from "./elements/structure/TabContainer/index.mjs";
32
+ import { elements_exports as j } from "./elements/index.mjs";
33
+ import { defaultElementsSettings as M, settings_exports as N } from "./elements/settings.mjs";
33
34
  //#region src/index.ts
34
- var N = {
35
+ var P = {
35
36
  dropdown: c,
36
- notFound: v,
37
- loading: _,
37
+ notFound: y,
38
+ loading: v,
38
39
  custom: i,
39
40
  reference: o,
40
41
  blockHtml: n,
41
42
  nodeHtml: a,
42
43
  blockJsx: r,
43
- page: y,
44
+ page: b,
44
45
  container: T,
45
- layoutContainer: g,
46
+ layoutContainer: _,
46
47
  dialogContainer: E,
47
48
  modalContainer: O,
48
- tabContainer: k,
49
+ tabContainer: A,
49
50
  heading: l,
50
- image: x,
51
- video: S,
52
- fontAwesome: b,
51
+ image: S,
52
+ video: C,
53
+ fontAwesome: x,
53
54
  button: s,
54
55
  paragraph: f,
55
- text: p,
56
+ text: m,
56
57
  list: D,
57
58
  link: u,
58
59
  markdown: d,
59
- form: m,
60
- formControl: h,
61
- apiContainer: C,
62
- collectionContainer: w
60
+ richText: p,
61
+ pagination: k,
62
+ form: h,
63
+ formControl: g,
64
+ apiContainer: w
63
65
  };
64
66
  //#endregion
65
- export { C as ApiContainer, n as BlockHtml, r as BlockJsx, s as Button, w as CollectionContainer, T as Container, i as Custom, E as DialogContainer, c as Dropdown, b as FontAwesome, m as Form, h as FormControl, l as Heading, x as Image, t as JsxManager, g as LayoutContainer, u as Link, D as List, _ as Loading, d as Markdown, O as ModalContainer, a as NodeHtml, v as NotFound, y as Page, f as Paragraph, o as Reference, k as TabContainer, p as Text, S as Video, N as defaultElements, j as defaultElementsSettings, M as elementSettings, A as elements, e as useRscData };
67
+ export { w as ApiContainer, n as BlockHtml, r as BlockJsx, s as Button, T as Container, i as Custom, E as DialogContainer, c as Dropdown, x as FontAwesome, h as Form, g as FormControl, l as Heading, S as Image, t as JsxManager, _ as LayoutContainer, u as Link, D as List, v as Loading, d as Markdown, O as ModalContainer, a as NodeHtml, y as NotFound, b as Page, k as Pagination, f as Paragraph, o as Reference, p as RichText, A as TabContainer, m as Text, C as Video, P as defaultElements, M as defaultElementsSettings, N as elementSettings, j as elements, e as useRscData };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plitzi/sdk-elements",
3
- "version": "0.32.25",
3
+ "version": "0.33.1",
4
4
  "license": "AGPL-3.0",
5
5
  "files": [
6
6
  "dist"
@@ -66,6 +66,10 @@
66
66
  "types": "./dist/Element/helpers/getInteractions.d.ts",
67
67
  "import": "./dist/Element/helpers/getInteractions.mjs"
68
68
  },
69
+ "./Element/helpers/isVisible": {
70
+ "types": "./dist/Element/helpers/isVisible.d.ts",
71
+ "import": "./dist/Element/helpers/isVisible.mjs"
72
+ },
69
73
  "./Element/helpers/loadComponent": {
70
74
  "types": "./dist/Element/helpers/loadComponent.d.ts",
71
75
  "import": "./dist/Element/helpers/loadComponent.mjs"
@@ -354,6 +358,26 @@
354
358
  "types": "./dist/elements/basic/Paragraph/index.d.ts",
355
359
  "import": "./dist/elements/basic/Paragraph/index.mjs"
356
360
  },
361
+ "./elements/basic/RichText": {
362
+ "types": "./dist/elements/basic/RichText/index.d.ts",
363
+ "import": "./dist/elements/basic/RichText/index.mjs"
364
+ },
365
+ "./elements/basic/RichText/RichText": {
366
+ "types": "./dist/elements/basic/RichText/RichText.d.ts",
367
+ "import": "./dist/elements/basic/RichText/RichText.mjs"
368
+ },
369
+ "./elements/basic/RichText/Settings": {
370
+ "types": "./dist/elements/basic/RichText/Settings.d.ts",
371
+ "import": "./dist/elements/basic/RichText/Settings.mjs"
372
+ },
373
+ "./elements/basic/RichText/index": {
374
+ "types": "./dist/elements/basic/RichText/index.d.ts",
375
+ "import": "./dist/elements/basic/RichText/index.mjs"
376
+ },
377
+ "./elements/basic/RichText/sanitizeHtml": {
378
+ "types": "./dist/elements/basic/RichText/sanitizeHtml.d.ts",
379
+ "import": "./dist/elements/basic/RichText/sanitizeHtml.mjs"
380
+ },
357
381
  "./elements/basic/Text": {
358
382
  "types": "./dist/elements/basic/Text/index.d.ts",
359
383
  "import": "./dist/elements/basic/Text/index.mjs"
@@ -554,34 +578,34 @@
554
578
  "types": "./dist/elements/provider/ApiContainer/Settings.d.ts",
555
579
  "import": "./dist/elements/provider/ApiContainer/Settings.mjs"
556
580
  },
581
+ "./elements/provider/ApiContainer/components/FiltersInput": {
582
+ "types": "./dist/elements/provider/ApiContainer/components/FiltersInput/index.d.ts",
583
+ "import": "./dist/elements/provider/ApiContainer/components/FiltersInput/index.mjs"
584
+ },
585
+ "./elements/provider/ApiContainer/components/FiltersInput/FiltersInput": {
586
+ "types": "./dist/elements/provider/ApiContainer/components/FiltersInput/FiltersInput.d.ts",
587
+ "import": "./dist/elements/provider/ApiContainer/components/FiltersInput/FiltersInput.mjs"
588
+ },
589
+ "./elements/provider/ApiContainer/components/FiltersInput/index": {
590
+ "types": "./dist/elements/provider/ApiContainer/components/FiltersInput/index.d.ts",
591
+ "import": "./dist/elements/provider/ApiContainer/components/FiltersInput/index.mjs"
592
+ },
557
593
  "./elements/provider/ApiContainer/hooks/useApi": {
558
594
  "types": "./dist/elements/provider/ApiContainer/hooks/useApi.d.ts",
559
595
  "import": "./dist/elements/provider/ApiContainer/hooks/useApi.mjs"
560
596
  },
597
+ "./elements/provider/ApiContainer/hooks/useProviderPagination": {
598
+ "types": "./dist/elements/provider/ApiContainer/hooks/useProviderPagination.d.ts",
599
+ "import": "./dist/elements/provider/ApiContainer/hooks/useProviderPagination.mjs"
600
+ },
601
+ "./elements/provider/ApiContainer/hooks/useProviderWrite": {
602
+ "types": "./dist/elements/provider/ApiContainer/hooks/useProviderWrite.d.ts",
603
+ "import": "./dist/elements/provider/ApiContainer/hooks/useProviderWrite.mjs"
604
+ },
561
605
  "./elements/provider/ApiContainer/index": {
562
606
  "types": "./dist/elements/provider/ApiContainer/index.d.ts",
563
607
  "import": "./dist/elements/provider/ApiContainer/index.mjs"
564
608
  },
565
- "./elements/provider/CollectionContainer": {
566
- "types": "./dist/elements/provider/CollectionContainer/index.d.ts",
567
- "import": "./dist/elements/provider/CollectionContainer/index.mjs"
568
- },
569
- "./elements/provider/CollectionContainer/CollectionContainer": {
570
- "types": "./dist/elements/provider/CollectionContainer/CollectionContainer.d.ts",
571
- "import": "./dist/elements/provider/CollectionContainer/CollectionContainer.mjs"
572
- },
573
- "./elements/provider/CollectionContainer/Settings": {
574
- "types": "./dist/elements/provider/CollectionContainer/Settings.d.ts",
575
- "import": "./dist/elements/provider/CollectionContainer/Settings.mjs"
576
- },
577
- "./elements/provider/CollectionContainer/hooks/useCollectionContext": {
578
- "types": "./dist/elements/provider/CollectionContainer/hooks/useCollectionContext.d.ts",
579
- "import": "./dist/elements/provider/CollectionContainer/hooks/useCollectionContext.mjs"
580
- },
581
- "./elements/provider/CollectionContainer/index": {
582
- "types": "./dist/elements/provider/CollectionContainer/index.d.ts",
583
- "import": "./dist/elements/provider/CollectionContainer/index.mjs"
584
- },
585
609
  "./elements/settings": {
586
610
  "types": "./dist/elements/settings.d.ts",
587
611
  "import": "./dist/elements/settings.mjs"
@@ -686,6 +710,26 @@
686
710
  "types": "./dist/elements/structure/ModalContainer/index.d.ts",
687
711
  "import": "./dist/elements/structure/ModalContainer/index.mjs"
688
712
  },
713
+ "./elements/structure/Pagination": {
714
+ "types": "./dist/elements/structure/Pagination/index.d.ts",
715
+ "import": "./dist/elements/structure/Pagination/index.mjs"
716
+ },
717
+ "./elements/structure/Pagination/Pagination": {
718
+ "types": "./dist/elements/structure/Pagination/Pagination.d.ts",
719
+ "import": "./dist/elements/structure/Pagination/Pagination.mjs"
720
+ },
721
+ "./elements/structure/Pagination/Settings": {
722
+ "types": "./dist/elements/structure/Pagination/Settings.d.ts",
723
+ "import": "./dist/elements/structure/Pagination/Settings.mjs"
724
+ },
725
+ "./elements/structure/Pagination/buildPageWindow": {
726
+ "types": "./dist/elements/structure/Pagination/buildPageWindow.d.ts",
727
+ "import": "./dist/elements/structure/Pagination/buildPageWindow.mjs"
728
+ },
729
+ "./elements/structure/Pagination/index": {
730
+ "types": "./dist/elements/structure/Pagination/index.d.ts",
731
+ "import": "./dist/elements/structure/Pagination/index.mjs"
732
+ },
689
733
  "./elements/structure/TabContainer": {
690
734
  "types": "./dist/elements/structure/TabContainer/index.d.ts",
691
735
  "import": "./dist/elements/structure/TabContainer/index.mjs"
@@ -772,17 +816,17 @@
772
816
  "type": "module",
773
817
  "sideEffects": false,
774
818
  "dependencies": {
775
- "@plitzi/nexus": "^1.0.0",
776
- "@plitzi/plitzi-ui": "^1.6.18",
777
- "@plitzi/sdk-auth": "0.32.25",
778
- "@plitzi/sdk-dev-tools": "0.32.25",
779
- "@plitzi/sdk-event-bridge": "0.32.25",
780
- "@plitzi/sdk-interactions": "0.32.25",
781
- "@plitzi/sdk-navigation": "0.32.25",
782
- "@plitzi/sdk-schema": "0.32.25",
783
- "@plitzi/sdk-shared": "0.32.25",
819
+ "@plitzi/nexus": "^1.1.0",
820
+ "@plitzi/plitzi-ui": "^1.6.19",
821
+ "@plitzi/sdk-auth": "0.33.1",
822
+ "@plitzi/sdk-dev-tools": "0.33.1",
823
+ "@plitzi/sdk-event-bridge": "0.33.1",
824
+ "@plitzi/sdk-interactions": "0.33.1",
825
+ "@plitzi/sdk-navigation": "0.33.1",
826
+ "@plitzi/sdk-schema": "0.33.1",
827
+ "@plitzi/sdk-shared": "0.33.1",
784
828
  "clsx": "^2.1.1",
785
- "immer": "^11.1.15"
829
+ "immer": "^11.1.16"
786
830
  },
787
831
  "peerDependencies": {
788
832
  "react": "^19",
@@ -792,7 +836,7 @@
792
836
  "eslint": "^9.39.5",
793
837
  "react": "^19.2.8",
794
838
  "typescript": "^6.0.3",
795
- "vite": "^8.2.0",
839
+ "vite": "^8.2.1",
796
840
  "vitest": "^4.1.10"
797
841
  }
798
842
  }
@@ -1,4 +0,0 @@
1
- declare const isAuthenticated: (authData: {
2
- isAuthenticated: boolean;
3
- }, userProvider?: string, previewMode?: boolean) => boolean;
4
- export { isAuthenticated };
@@ -1,18 +0,0 @@
1
- import { RuleGroup } from '@plitzi/plitzi-ui/QueryBuilder';
2
- import { ReactNode, RefObject } from 'react';
3
- export type CollectionContainerProps = {
4
- ref?: RefObject<HTMLElement>;
5
- className?: string;
6
- source?: string;
7
- children?: ReactNode;
8
- limit?: string;
9
- query?: RuleGroup;
10
- singleRecord?: boolean;
11
- };
12
- declare const CollectionContainer: ({ ref, className, source, children, limit, query, singleRecord }: CollectionContainerProps) => import("react").JSX.Element | undefined;
13
- declare const _default: {
14
- (props: import('../../../Element/hocs/withElement').WithElementProps<CollectionContainerProps>): import("react").JSX.Element;
15
- displayName: string;
16
- };
17
- export default _default;
18
- export { CollectionContainer };
@@ -1,69 +0,0 @@
1
- import e from "../../../Element/hooks/useElement.mjs";
2
- import { RootElement as t } from "../../../Element/RootElement.mjs";
3
- import n from "./hooks/useCollectionContext.mjs";
4
- import r from "../../../Element/hocs/withElement.mjs";
5
- import { useCallback as i, useMemo as a } from "react";
6
- import o from "@plitzi/sdk-shared/hooks/usePlitziServiceContext";
7
- import { StoreProvider as s } from "@plitzi/nexus/react";
8
- import { emptyObject as c } from "@plitzi/sdk-shared/helpers/utils";
9
- import { jsx as l, jsxs as u } from "react/jsx-runtime";
10
- import d from "clsx";
11
- import f from "@plitzi/sdk-shared/dataSource/helpers/getSourceName";
12
- import p from "@plitzi/sdk-shared/dataSource/hooks/useRegisterSource";
13
- //#region src/elements/provider/CollectionContainer/CollectionContainer.tsx
14
- var m = ({ ref: r, className: m = "", source: h = "", children: g, limit: _ = "10", query: v, singleRecord: y = !1 }) => {
15
- let { id: b, idRef: x, definition: { label: S = "Collection Container" } } = e(), C = f("collectionContainer", { idRef: x }), { settings: { previewMode: w } } = o(), { loading: T, collection: E, fetch: D } = n({
16
- source: h,
17
- limit: _,
18
- query: v,
19
- singleRecord: y,
20
- previewMode: w
21
- }), O = i(() => {
22
- let e = [];
23
- return E ? (y || e.push({
24
- path: "records",
25
- name: "Records"
26
- }), e.push({
27
- path: "record.id",
28
- name: "Record ID"
29
- }), e.push({
30
- path: "record.status",
31
- name: "Record Status"
32
- }), Object.values(E.fields).forEach((t) => {
33
- e.push({
34
- path: `record.values.${t.machineName}`,
35
- name: `Record Field - ${t.name}`
36
- });
37
- }), e) : [];
38
- }, [E, y]);
39
- p({
40
- id: b,
41
- source: C,
42
- name: S || `Collection - ${E?.name || b}`,
43
- fields: O
44
- });
45
- let k = a(() => ({ performQuery: {
46
- action: "performQuery",
47
- title: `Refresh ${S}`,
48
- type: "callback",
49
- callback: D,
50
- preview: {},
51
- params: {}
52
- } }), [D, S]), A = a(() => C ? { runtime: { sources: { [C]: E } } } : c, [E, C]);
53
- if (!(!E && w)) return /* @__PURE__ */ u(t, {
54
- ref: r,
55
- interactionCallbacks: k,
56
- className: d("plitzi-component__collection-container", m, { "collection-container--context-empty": !E }),
57
- children: [!E && /* @__PURE__ */ l("div", {
58
- className: "collection-container__message",
59
- children: "Source Not Selected"
60
- }), E && !T && /* @__PURE__ */ l(s, {
61
- inherit: "live",
62
- name: `Collection:${b}`,
63
- value: A,
64
- children: g
65
- })]
66
- });
67
- }, h = r(m);
68
- //#endregion
69
- export { m as CollectionContainer, h as default };
@@ -1,10 +0,0 @@
1
- import { RuleGroup } from '@plitzi/plitzi-ui/QueryBuilder';
2
- type SettingsProps = {
3
- source?: string;
4
- query?: RuleGroup;
5
- limit?: string;
6
- singleRecord?: boolean;
7
- onUpdate?: (key: string, value: string | boolean | number | RuleGroup) => void;
8
- };
9
- declare const Settings: ({ source, query, limit, singleRecord, onUpdate }: SettingsProps) => import("react").JSX.Element;
10
- export default Settings;
@@ -1,74 +0,0 @@
1
- import { use as e, useCallback as t, useMemo as n } from "react";
2
- import r from "@plitzi/sdk-shared/hooks/usePlitziServiceContext";
3
- import { get as i } from "@plitzi/plitzi-ui/helpers";
4
- import { getPathsFromObeject as a } from "@plitzi/sdk-shared/helpers/utils";
5
- import { Fragment as o, jsx as s, jsxs as c } from "react/jsx-runtime";
6
- import l from "@plitzi/plitzi-ui/QueryBuilder";
7
- import u from "@plitzi/plitzi-ui/Checkbox";
8
- import d from "@plitzi/plitzi-ui/Input";
9
- import f from "@plitzi/plitzi-ui/Select";
10
- //#region src/elements/provider/CollectionContainer/Settings.tsx
11
- var p = ({ source: p = "", query: m, limit: h = "10", singleRecord: g = !1, onUpdate: _ }) => {
12
- let { contexts: { CollectionContext: v, NavigationContext: y } } = r(), { collections: b } = e(v), { routeParams: x, queryParams: S } = e(y), C = t((e) => (t) => _?.(e, t), [_]), w = t((e) => (t) => _?.(e, t.target.checked), [_]), T = t((e) => _?.("when", e), [_]), E = n(() => {
13
- if (!p || !b[p]) return {};
14
- let e = i(b, `${p}.records.0`, void 0);
15
- return e ? a({
16
- values: e.values,
17
- routeParams: x,
18
- queryParams: S,
19
- _id: e.id
20
- }).reduce((e, t) => ({
21
- ...e,
22
- [t]: {
23
- name: t,
24
- label: t,
25
- placeholder: `Enter ${t}`
26
- }
27
- }), {}) : {};
28
- }, [
29
- b,
30
- p,
31
- x,
32
- S
33
- ]);
34
- return /* @__PURE__ */ c("div", {
35
- className: "flex flex-col gap-4 py-2",
36
- children: [
37
- /* @__PURE__ */ c(f, {
38
- label: "Source",
39
- value: p,
40
- onChange: C("source"),
41
- children: [/* @__PURE__ */ s("option", {
42
- value: "",
43
- children: "Select a Source"
44
- }), Object.values(b).map((e, t) => /* @__PURE__ */ s("option", {
45
- value: e.id,
46
- children: e.name
47
- }, t))]
48
- }),
49
- p && /* @__PURE__ */ c(o, { children: [/* @__PURE__ */ c("div", {
50
- className: "flex flex-col",
51
- children: [/* @__PURE__ */ s("label", { children: "Query" }), /* @__PURE__ */ s(l, {
52
- direction: "vertical",
53
- className: "w-full",
54
- query: m,
55
- fields: E,
56
- onChange: T,
57
- showBranches: !0,
58
- allowSubGroups: !1
59
- })]
60
- }), /* @__PURE__ */ s(u, {
61
- label: "Single Record",
62
- checked: g,
63
- onChange: w("singleRecord")
64
- })] }),
65
- !g && /* @__PURE__ */ s(d, {
66
- value: h,
67
- label: "Limit",
68
- onChange: C("limit")
69
- })
70
- ]
71
- });
72
- };
73
- //#endregion
74
- export { p as default };
@@ -1,19 +0,0 @@
1
- import { RuleGroup } from '@plitzi/plitzi-ui/QueryBuilder';
2
- import { Collection } from '@plitzi/sdk-shared';
3
- export type UseCollectionContextProps = {
4
- source: string;
5
- query?: RuleGroup;
6
- limit: string;
7
- appendResults?: boolean;
8
- singleRecord: boolean;
9
- previewMode?: boolean;
10
- };
11
- export type UseCollectionContextResult = {
12
- loading: boolean;
13
- collection?: Collection;
14
- hasNextPage: boolean;
15
- handleNextPage: () => void;
16
- fetch: () => void;
17
- };
18
- declare const useCollectionContext: ({ source, query, limit, appendResults, singleRecord, previewMode }?: UseCollectionContextProps) => UseCollectionContextResult;
19
- export default useCollectionContext;
@@ -1,71 +0,0 @@
1
- import { use as e, useCallback as t, useEffect as n, useMemo as r, useState as i } from "react";
2
- import a from "@plitzi/sdk-shared/hooks/usePlitziServiceContext";
3
- import { isEmpty as o } from "@plitzi/plitzi-ui/helpers";
4
- import { QueryBuilderFormatter as s } from "@plitzi/plitzi-ui/QueryBuilder";
5
- //#region src/elements/provider/CollectionContainer/hooks/useCollectionContext.ts
6
- var c = ({ source: c, query: l, limit: u = "1", appendResults: d = !1, singleRecord: f = !1, previewMode: p = !0 } = {}) => {
7
- let { contexts: { CollectionContext: m, NavigationContext: h } } = a(), [g, _] = i(void 0), [v, y] = i(!0), [b, x] = i(void 0), [S, C] = i(!1), { routeParams: w, queryParams: T } = e(h), { fetchRecords: E, fetchCollection: D } = e(m), O = r(() => {
8
- if (!p || !l) return "";
9
- try {
10
- return s(l, "mongodb", !1, {
11
- queryParams: T,
12
- routeParams: w
13
- });
14
- } catch {}
15
- return "";
16
- }, [
17
- p,
18
- l,
19
- T,
20
- w
21
- ]), k = t((e, t) => {
22
- let { pageInfo: n, edges: r } = t;
23
- x(n.nextCursor), C(n.hasNextPage), _({
24
- ...e,
25
- records: f ? [] : r,
26
- record: f && r.length > 0 ? r[0] : void 0
27
- });
28
- }, [f]), A = t(async () => {
29
- y(!0);
30
- let e = await D(c, O);
31
- y(!1), e?.records && e.records.edges.length > 0 && k(e, e.records);
32
- }, [
33
- D,
34
- k,
35
- O,
36
- c
37
- ]), j = t(async () => {
38
- if (!g || !c) return;
39
- y(!0);
40
- let e = await E(c, O, !d && b ? void 0 : b, parseInt(u, 10));
41
- y(!1), e && k(g, e);
42
- }, [
43
- g,
44
- c,
45
- E,
46
- O,
47
- d,
48
- b,
49
- u,
50
- k
51
- ]), M = t(async () => {
52
- S && await j();
53
- }, [S, j]);
54
- return n(() => {
55
- o(c) ? (x(void 0), C(!1), _(void 0), y(!1)) : A();
56
- }, [c, A]), r(() => ({
57
- loading: v,
58
- collection: g,
59
- hasNextPage: S,
60
- handleNextPage: M,
61
- fetch: A
62
- }), [
63
- v,
64
- g,
65
- S,
66
- M,
67
- A
68
- ]);
69
- };
70
- //#endregion
71
- export { c as default };