@adhese/sdk-react 0.6.4 → 0.7.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/index.cjs CHANGED
@@ -4,7 +4,7 @@ const jsxRuntime = require("react/jsx-runtime");
4
4
  const react = require("react");
5
5
  const sdk = require("@adhese/sdk");
6
6
  const useDeepCompareEffect = require("use-deep-compare-effect");
7
- const omit = require("lodash/omit");
7
+ const remeda = require("remeda");
8
8
  const adheseContext = react.createContext(void 0);
9
9
  function AdheseProvider({ children, options }) {
10
10
  const [adhese, setAdhese] = react.useState(void 0);
@@ -37,7 +37,7 @@ function useAdheseSlot(elementRef, options) {
37
37
  return () => {
38
38
  intermediate == null ? void 0 : intermediate.dispose();
39
39
  };
40
- }, [adhese, omit(options, Object.entries(options).filter(([, value]) => typeof value === "function").map(([key]) => key)), elementRef.current]);
40
+ }, [adhese, remeda.omit(options, Object.entries(options).filter(([, value]) => typeof value === "function").map(([key]) => key)), elementRef.current]);
41
41
  return slot;
42
42
  }
43
43
  exports.AdheseProvider = AdheseProvider;
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../src/adheseContext.tsx","../src/useAdheseSlot.ts"],"sourcesContent":["'use client';\n\nimport {\n type PropsWithChildren,\n type ReactElement,\n createContext,\n useContext,\n useEffect,\n useState,\n} from 'react';\nimport { type Adhese, type AdheseOptions, createAdhese } from '@adhese/sdk';\n\nconst adheseContext = createContext<Adhese | undefined>(undefined);\n\n/**\n * Provider to create an Adhese instance with the given options. Via the `useAdhese` hook, the Adhese instance can be\n * used in all child components.\n * @param children The children to render\n * @param options The options to create the Adhese instance with. When the options change, the Adhese instance will be recreated.\n * @constructor\n */\n// eslint-disable-next-line ts/naming-convention\nexport function AdheseProvider({ children, options }: PropsWithChildren<{ options: AdheseOptions }>): ReactElement {\n const [adhese, setAdhese] = useState<Adhese | undefined>(undefined);\n\n useEffect(() => {\n const instance = createAdhese(options);\n setAdhese(instance);\n\n return () => {\n instance.dispose();\n };\n }, [options]);\n\n return (\n <adheseContext.Provider value={adhese}>\n {children}\n </adheseContext.Provider>\n );\n}\n\n/**\n * Hook to get the Adhese instance from the nearest `AdheseProvider`. When the Adhese instance is not available yet, `null`\n */\nexport function useAdhese(): Adhese | undefined {\n return useContext(adheseContext);\n}\n","import { type RefObject, useState } from 'react';\nimport type { AdheseSlot, AdheseSlotOptions } from '@adhese/sdk';\nimport useDeepCompareEffect from 'use-deep-compare-effect';\nimport omit from 'lodash/omit';\nimport { useAdhese } from './adheseContext';\n\n/**\n * Hook to create an Adhese slot. The slot will be disposed when the component is unmounted. The slot will be created\n * when the containing element is available and the Adhese instance is available.\n * @param elementRef The ref to the containing element\n * @param options The options to create the slot\n */\nexport function useAdheseSlot(elementRef: RefObject<HTMLElement>, options: Omit<AdheseSlotOptions, 'containingElement' | 'context'>): AdheseSlot | null {\n const [slot, setSlot] = useState<AdheseSlot | null>(null);\n const adhese = useAdhese();\n\n useDeepCompareEffect(() => {\n let intermediate: AdheseSlot | undefined;\n\n if (adhese && elementRef.current) {\n intermediate = adhese.add(\n {\n ...options,\n containingElement: elementRef.current,\n },\n );\n\n setSlot(intermediate);\n }\n\n return () => {\n intermediate?.dispose();\n };\n }, [adhese, omit(options, Object.entries(options).filter(([, value]) => typeof value === 'function').map(([key]) => key)), elementRef.current]);\n\n return slot;\n}\n"],"names":["createContext","useState","useEffect","createAdhese","useContext"],"mappings":";;;;;;;AAYA,MAAM,gBAAgBA,MAAAA,cAAkC,MAAS;AAU1D,SAAS,eAAe,EAAE,UAAU,WAAwE;AACjH,QAAM,CAAC,QAAQ,SAAS,IAAIC,MAAAA,SAA6B,MAAS;AAElEC,QAAAA,UAAU,MAAM;AACR,UAAA,WAAWC,iBAAa,OAAO;AACrC,cAAU,QAAQ;AAElB,WAAO,MAAM;AACX,eAAS,QAAQ;AAAA,IAAA;AAAA,EACnB,GACC,CAAC,OAAO,CAAC;AAEZ,wCACG,cAAc,UAAd,EAAuB,OAAO,QAC5B,SACH,CAAA;AAEJ;AAKO,SAAS,YAAgC;AAC9C,SAAOC,MAAAA,WAAW,aAAa;AACjC;AClCgB,SAAA,cAAc,YAAoC,SAAsF;AACtJ,QAAM,CAAC,MAAM,OAAO,IAAIH,eAA4B,IAAI;AACxD,QAAM,SAAS;AAEf,uBAAqB,MAAM;AACrB,QAAA;AAEA,QAAA,UAAU,WAAW,SAAS;AAChC,qBAAe,OAAO;AAAA,QACpB;AAAA,UACE,GAAG;AAAA,UACH,mBAAmB,WAAW;AAAA,QAChC;AAAA,MAAA;AAGF,cAAQ,YAAY;AAAA,IACtB;AAEA,WAAO,MAAM;AACX,mDAAc;AAAA,IAAQ;AAAA,EAEvB,GAAA,CAAC,QAAQ,KAAK,SAAS,OAAO,QAAQ,OAAO,EAAE,OAAO,CAAC,CAAA,EAAG,KAAK,MAAM,OAAO,UAAU,UAAU,EAAE,IAAI,CAAC,CAAC,GAAG,MAAM,GAAG,CAAC,GAAG,WAAW,OAAO,CAAC;AAEvI,SAAA;AACT;;;;"}
1
+ {"version":3,"file":"index.cjs","sources":["../src/adheseContext.tsx","../src/useAdheseSlot.ts"],"sourcesContent":["'use client';\n\nimport {\n type PropsWithChildren,\n type ReactElement,\n createContext,\n useContext,\n useEffect,\n useState,\n} from 'react';\nimport { type Adhese, type AdheseOptions, createAdhese } from '@adhese/sdk';\n\nconst adheseContext = createContext<Adhese | undefined>(undefined);\n\n/**\n * Provider to create an Adhese instance with the given options. Via the `useAdhese` hook, the Adhese instance can be\n * used in all child components.\n * @param children The children to render\n * @param options The options to create the Adhese instance with. When the options change, the Adhese instance will be recreated.\n * @constructor\n */\n// eslint-disable-next-line ts/naming-convention\nexport function AdheseProvider({ children, options }: PropsWithChildren<{ options: AdheseOptions }>): ReactElement {\n const [adhese, setAdhese] = useState<Adhese | undefined>(undefined);\n\n useEffect(() => {\n const instance = createAdhese(options);\n setAdhese(instance);\n\n return () => {\n instance.dispose();\n };\n }, [options]);\n\n return (\n <adheseContext.Provider value={adhese}>\n {children}\n </adheseContext.Provider>\n );\n}\n\n/**\n * Hook to get the Adhese instance from the nearest `AdheseProvider`. When the Adhese instance is not available yet, `null`\n */\nexport function useAdhese(): Adhese | undefined {\n return useContext(adheseContext);\n}\n","import { type RefObject, useState } from 'react';\nimport type { AdheseSlot, AdheseSlotOptions } from '@adhese/sdk';\nimport useDeepCompareEffect from 'use-deep-compare-effect';\nimport { omit } from 'remeda';\nimport { useAdhese } from './adheseContext';\n\n/**\n * Hook to create an Adhese slot. The slot will be disposed when the component is unmounted. The slot will be created\n * when the containing element is available and the Adhese instance is available.\n * @param elementRef The ref to the containing element\n * @param options The options to create the slot\n */\nexport function useAdheseSlot(elementRef: RefObject<HTMLElement>, options: Omit<AdheseSlotOptions, 'containingElement' | 'context'>): AdheseSlot | null {\n const [slot, setSlot] = useState<AdheseSlot | null>(null);\n const adhese = useAdhese();\n\n useDeepCompareEffect(() => {\n let intermediate: AdheseSlot | undefined;\n\n if (adhese && elementRef.current) {\n intermediate = adhese.add(\n {\n ...options,\n containingElement: elementRef.current,\n },\n );\n\n setSlot(intermediate);\n }\n\n return () => {\n intermediate?.dispose();\n };\n }, [adhese, omit(options, Object.entries(options).filter(([, value]) => typeof value === 'function').map(([key]) => key as keyof typeof options)), elementRef.current]);\n\n return slot;\n}\n"],"names":["createContext","useState","useEffect","createAdhese","useContext","omit"],"mappings":";;;;;;;AAYA,MAAM,gBAAgBA,MAAAA,cAAkC,MAAS;AAU1D,SAAS,eAAe,EAAE,UAAU,WAAwE;AACjH,QAAM,CAAC,QAAQ,SAAS,IAAIC,MAAAA,SAA6B,MAAS;AAElEC,QAAAA,UAAU,MAAM;AACR,UAAA,WAAWC,iBAAa,OAAO;AACrC,cAAU,QAAQ;AAElB,WAAO,MAAM;AACX,eAAS,QAAQ;AAAA,IAAA;AAAA,EACnB,GACC,CAAC,OAAO,CAAC;AAEZ,wCACG,cAAc,UAAd,EAAuB,OAAO,QAC5B,SACH,CAAA;AAEJ;AAKO,SAAS,YAAgC;AAC9C,SAAOC,MAAAA,WAAW,aAAa;AACjC;AClCgB,SAAA,cAAc,YAAoC,SAAsF;AACtJ,QAAM,CAAC,MAAM,OAAO,IAAIH,eAA4B,IAAI;AACxD,QAAM,SAAS;AAEf,uBAAqB,MAAM;AACrB,QAAA;AAEA,QAAA,UAAU,WAAW,SAAS;AAChC,qBAAe,OAAO;AAAA,QACpB;AAAA,UACE,GAAG;AAAA,UACH,mBAAmB,WAAW;AAAA,QAChC;AAAA,MAAA;AAGF,cAAQ,YAAY;AAAA,IACtB;AAEA,WAAO,MAAM;AACX,mDAAc;AAAA,IAAQ;AAAA,EAEvB,GAAA,CAAC,QAAQI,YAAK,SAAS,OAAO,QAAQ,OAAO,EAAE,OAAO,CAAC,CAAA,EAAG,KAAK,MAAM,OAAO,UAAU,UAAU,EAAE,IAAI,CAAC,CAAC,GAAG,MAAM,GAA2B,CAAC,GAAG,WAAW,OAAO,CAAC;AAE/J,SAAA;AACT;;;;"}
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import { jsx } from "react/jsx-runtime";
2
2
  import { createContext, useState, useEffect, useContext } from "react";
3
3
  import { createAdhese } from "@adhese/sdk";
4
4
  import useDeepCompareEffect from "use-deep-compare-effect";
5
- import omit from "lodash/omit";
5
+ import { omit } from "remeda";
6
6
  const adheseContext = createContext(void 0);
7
7
  function AdheseProvider({ children, options }) {
8
8
  const [adhese, setAdhese] = useState(void 0);
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/adheseContext.tsx","../src/useAdheseSlot.ts"],"sourcesContent":["'use client';\n\nimport {\n type PropsWithChildren,\n type ReactElement,\n createContext,\n useContext,\n useEffect,\n useState,\n} from 'react';\nimport { type Adhese, type AdheseOptions, createAdhese } from '@adhese/sdk';\n\nconst adheseContext = createContext<Adhese | undefined>(undefined);\n\n/**\n * Provider to create an Adhese instance with the given options. Via the `useAdhese` hook, the Adhese instance can be\n * used in all child components.\n * @param children The children to render\n * @param options The options to create the Adhese instance with. When the options change, the Adhese instance will be recreated.\n * @constructor\n */\n// eslint-disable-next-line ts/naming-convention\nexport function AdheseProvider({ children, options }: PropsWithChildren<{ options: AdheseOptions }>): ReactElement {\n const [adhese, setAdhese] = useState<Adhese | undefined>(undefined);\n\n useEffect(() => {\n const instance = createAdhese(options);\n setAdhese(instance);\n\n return () => {\n instance.dispose();\n };\n }, [options]);\n\n return (\n <adheseContext.Provider value={adhese}>\n {children}\n </adheseContext.Provider>\n );\n}\n\n/**\n * Hook to get the Adhese instance from the nearest `AdheseProvider`. When the Adhese instance is not available yet, `null`\n */\nexport function useAdhese(): Adhese | undefined {\n return useContext(adheseContext);\n}\n","import { type RefObject, useState } from 'react';\nimport type { AdheseSlot, AdheseSlotOptions } from '@adhese/sdk';\nimport useDeepCompareEffect from 'use-deep-compare-effect';\nimport omit from 'lodash/omit';\nimport { useAdhese } from './adheseContext';\n\n/**\n * Hook to create an Adhese slot. The slot will be disposed when the component is unmounted. The slot will be created\n * when the containing element is available and the Adhese instance is available.\n * @param elementRef The ref to the containing element\n * @param options The options to create the slot\n */\nexport function useAdheseSlot(elementRef: RefObject<HTMLElement>, options: Omit<AdheseSlotOptions, 'containingElement' | 'context'>): AdheseSlot | null {\n const [slot, setSlot] = useState<AdheseSlot | null>(null);\n const adhese = useAdhese();\n\n useDeepCompareEffect(() => {\n let intermediate: AdheseSlot | undefined;\n\n if (adhese && elementRef.current) {\n intermediate = adhese.add(\n {\n ...options,\n containingElement: elementRef.current,\n },\n );\n\n setSlot(intermediate);\n }\n\n return () => {\n intermediate?.dispose();\n };\n }, [adhese, omit(options, Object.entries(options).filter(([, value]) => typeof value === 'function').map(([key]) => key)), elementRef.current]);\n\n return slot;\n}\n"],"names":[],"mappings":";;;;;AAYA,MAAM,gBAAgB,cAAkC,MAAS;AAU1D,SAAS,eAAe,EAAE,UAAU,WAAwE;AACjH,QAAM,CAAC,QAAQ,SAAS,IAAI,SAA6B,MAAS;AAElE,YAAU,MAAM;AACR,UAAA,WAAW,aAAa,OAAO;AACrC,cAAU,QAAQ;AAElB,WAAO,MAAM;AACX,eAAS,QAAQ;AAAA,IAAA;AAAA,EACnB,GACC,CAAC,OAAO,CAAC;AAEZ,6BACG,cAAc,UAAd,EAAuB,OAAO,QAC5B,SACH,CAAA;AAEJ;AAKO,SAAS,YAAgC;AAC9C,SAAO,WAAW,aAAa;AACjC;AClCgB,SAAA,cAAc,YAAoC,SAAsF;AACtJ,QAAM,CAAC,MAAM,OAAO,IAAI,SAA4B,IAAI;AACxD,QAAM,SAAS;AAEf,uBAAqB,MAAM;AACrB,QAAA;AAEA,QAAA,UAAU,WAAW,SAAS;AAChC,qBAAe,OAAO;AAAA,QACpB;AAAA,UACE,GAAG;AAAA,UACH,mBAAmB,WAAW;AAAA,QAChC;AAAA,MAAA;AAGF,cAAQ,YAAY;AAAA,IACtB;AAEA,WAAO,MAAM;AACX,mDAAc;AAAA,IAAQ;AAAA,EAEvB,GAAA,CAAC,QAAQ,KAAK,SAAS,OAAO,QAAQ,OAAO,EAAE,OAAO,CAAC,CAAA,EAAG,KAAK,MAAM,OAAO,UAAU,UAAU,EAAE,IAAI,CAAC,CAAC,GAAG,MAAM,GAAG,CAAC,GAAG,WAAW,OAAO,CAAC;AAEvI,SAAA;AACT;"}
1
+ {"version":3,"file":"index.js","sources":["../src/adheseContext.tsx","../src/useAdheseSlot.ts"],"sourcesContent":["'use client';\n\nimport {\n type PropsWithChildren,\n type ReactElement,\n createContext,\n useContext,\n useEffect,\n useState,\n} from 'react';\nimport { type Adhese, type AdheseOptions, createAdhese } from '@adhese/sdk';\n\nconst adheseContext = createContext<Adhese | undefined>(undefined);\n\n/**\n * Provider to create an Adhese instance with the given options. Via the `useAdhese` hook, the Adhese instance can be\n * used in all child components.\n * @param children The children to render\n * @param options The options to create the Adhese instance with. When the options change, the Adhese instance will be recreated.\n * @constructor\n */\n// eslint-disable-next-line ts/naming-convention\nexport function AdheseProvider({ children, options }: PropsWithChildren<{ options: AdheseOptions }>): ReactElement {\n const [adhese, setAdhese] = useState<Adhese | undefined>(undefined);\n\n useEffect(() => {\n const instance = createAdhese(options);\n setAdhese(instance);\n\n return () => {\n instance.dispose();\n };\n }, [options]);\n\n return (\n <adheseContext.Provider value={adhese}>\n {children}\n </adheseContext.Provider>\n );\n}\n\n/**\n * Hook to get the Adhese instance from the nearest `AdheseProvider`. When the Adhese instance is not available yet, `null`\n */\nexport function useAdhese(): Adhese | undefined {\n return useContext(adheseContext);\n}\n","import { type RefObject, useState } from 'react';\nimport type { AdheseSlot, AdheseSlotOptions } from '@adhese/sdk';\nimport useDeepCompareEffect from 'use-deep-compare-effect';\nimport { omit } from 'remeda';\nimport { useAdhese } from './adheseContext';\n\n/**\n * Hook to create an Adhese slot. The slot will be disposed when the component is unmounted. The slot will be created\n * when the containing element is available and the Adhese instance is available.\n * @param elementRef The ref to the containing element\n * @param options The options to create the slot\n */\nexport function useAdheseSlot(elementRef: RefObject<HTMLElement>, options: Omit<AdheseSlotOptions, 'containingElement' | 'context'>): AdheseSlot | null {\n const [slot, setSlot] = useState<AdheseSlot | null>(null);\n const adhese = useAdhese();\n\n useDeepCompareEffect(() => {\n let intermediate: AdheseSlot | undefined;\n\n if (adhese && elementRef.current) {\n intermediate = adhese.add(\n {\n ...options,\n containingElement: elementRef.current,\n },\n );\n\n setSlot(intermediate);\n }\n\n return () => {\n intermediate?.dispose();\n };\n }, [adhese, omit(options, Object.entries(options).filter(([, value]) => typeof value === 'function').map(([key]) => key as keyof typeof options)), elementRef.current]);\n\n return slot;\n}\n"],"names":[],"mappings":";;;;;AAYA,MAAM,gBAAgB,cAAkC,MAAS;AAU1D,SAAS,eAAe,EAAE,UAAU,WAAwE;AACjH,QAAM,CAAC,QAAQ,SAAS,IAAI,SAA6B,MAAS;AAElE,YAAU,MAAM;AACR,UAAA,WAAW,aAAa,OAAO;AACrC,cAAU,QAAQ;AAElB,WAAO,MAAM;AACX,eAAS,QAAQ;AAAA,IAAA;AAAA,EACnB,GACC,CAAC,OAAO,CAAC;AAEZ,6BACG,cAAc,UAAd,EAAuB,OAAO,QAC5B,SACH,CAAA;AAEJ;AAKO,SAAS,YAAgC;AAC9C,SAAO,WAAW,aAAa;AACjC;AClCgB,SAAA,cAAc,YAAoC,SAAsF;AACtJ,QAAM,CAAC,MAAM,OAAO,IAAI,SAA4B,IAAI;AACxD,QAAM,SAAS;AAEf,uBAAqB,MAAM;AACrB,QAAA;AAEA,QAAA,UAAU,WAAW,SAAS;AAChC,qBAAe,OAAO;AAAA,QACpB;AAAA,UACE,GAAG;AAAA,UACH,mBAAmB,WAAW;AAAA,QAChC;AAAA,MAAA;AAGF,cAAQ,YAAY;AAAA,IACtB;AAEA,WAAO,MAAM;AACX,mDAAc;AAAA,IAAQ;AAAA,EAEvB,GAAA,CAAC,QAAQ,KAAK,SAAS,OAAO,QAAQ,OAAO,EAAE,OAAO,CAAC,CAAA,EAAG,KAAK,MAAM,OAAO,UAAU,UAAU,EAAE,IAAI,CAAC,CAAC,GAAG,MAAM,GAA2B,CAAC,GAAG,WAAW,OAAO,CAAC;AAE/J,SAAA;AACT;"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@adhese/sdk-react",
3
3
  "type": "module",
4
- "version": "0.6.4",
4
+ "version": "0.7.0",
5
5
  "description": "Adhese SDK",
6
6
  "repository": {
7
7
  "type": "git",
@@ -28,8 +28,8 @@
28
28
  "react-dom": ">=16.13"
29
29
  },
30
30
  "dependencies": {
31
- "@adhese/sdk": "^0.6.4",
32
- "lodash": "^4.17.21",
31
+ "@adhese/sdk": "^0.7.0",
32
+ "remeda": "^1.59.0",
33
33
  "use-deep-compare-effect": "^1.8.1"
34
34
  },
35
35
  "devDependencies": {