@adhese/sdk-react 1.1.4 → 1.2.0-nightly-20240625081726
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/CHANGELOG.md +12 -0
- package/dist/AdheseSlot.js +42 -8
- package/dist/AdheseSlot.js.map +1 -1
- package/dist/cjs/AdheseSlot.cjs +42 -8
- package/dist/cjs/AdheseSlot.cjs.map +1 -1
- package/dist/sdkReact.d.ts +3 -3
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @adhese/sdk-react
|
|
2
2
|
|
|
3
|
+
## 1.2.0-nightly-20240625081726
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 407322d: Allow passing of all HTMLAttributes props to AdheseSlot to allow more customizing of the rendered element
|
|
8
|
+
- 1ea0633: Set width and height on passed element from the passed options to prevent content jumping in your page if the size of the slot is already known
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- Updated dependencies [1ea0633]
|
|
13
|
+
- @adhese/sdk@1.1.4-nightly-20240625081726
|
|
14
|
+
|
|
3
15
|
## 1.1.4
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/AdheseSlot.js
CHANGED
|
@@ -4,21 +4,55 @@ import { watch } from "@adhese/sdk-shared";
|
|
|
4
4
|
import { useAdheseSlot } from "./useAdheseSlot.js";
|
|
5
5
|
function AdheseSlot({
|
|
6
6
|
onChange,
|
|
7
|
-
|
|
7
|
+
width,
|
|
8
|
+
height,
|
|
9
|
+
lazyLoading,
|
|
10
|
+
lazyLoadingOptions,
|
|
11
|
+
slot,
|
|
12
|
+
pluginOptions,
|
|
13
|
+
renderMode,
|
|
14
|
+
type,
|
|
15
|
+
setup,
|
|
16
|
+
parameters,
|
|
17
|
+
format,
|
|
18
|
+
style,
|
|
19
|
+
id,
|
|
20
|
+
...props
|
|
8
21
|
}) {
|
|
9
22
|
const element = useRef(null);
|
|
10
|
-
const
|
|
11
|
-
|
|
23
|
+
const slotState = useAdheseSlot(element, {
|
|
24
|
+
width,
|
|
25
|
+
height,
|
|
26
|
+
lazyLoading,
|
|
27
|
+
lazyLoadingOptions,
|
|
28
|
+
slot,
|
|
29
|
+
pluginOptions,
|
|
30
|
+
renderMode,
|
|
31
|
+
type,
|
|
32
|
+
parameters,
|
|
33
|
+
format,
|
|
12
34
|
setup: useCallback((context, hooks) => {
|
|
13
|
-
|
|
14
|
-
(_a = options.setup) == null ? void 0 : _a.call(options, context, hooks);
|
|
35
|
+
setup == null ? void 0 : setup(context, hooks);
|
|
15
36
|
watch(context, (newSlot) => {
|
|
16
37
|
onChange == null ? void 0 : onChange(newSlot);
|
|
17
38
|
}, { immediate: true, deep: true });
|
|
18
|
-
}, [
|
|
39
|
+
}, [setup, onChange])
|
|
19
40
|
});
|
|
20
|
-
const
|
|
21
|
-
return /* @__PURE__ */ jsx(
|
|
41
|
+
const componentId = useId();
|
|
42
|
+
return /* @__PURE__ */ jsx(
|
|
43
|
+
"div",
|
|
44
|
+
{
|
|
45
|
+
ref: element,
|
|
46
|
+
id: id && `${componentId}${slotState == null ? void 0 : slotState.id}`,
|
|
47
|
+
"data-name": slotState == null ? void 0 : slotState.name,
|
|
48
|
+
style: {
|
|
49
|
+
width: slotState == null ? void 0 : slotState.options.width,
|
|
50
|
+
height: slotState == null ? void 0 : slotState.options.height,
|
|
51
|
+
...style
|
|
52
|
+
},
|
|
53
|
+
...props
|
|
54
|
+
}
|
|
55
|
+
);
|
|
22
56
|
}
|
|
23
57
|
export {
|
|
24
58
|
AdheseSlot
|
package/dist/AdheseSlot.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AdheseSlot.js","sources":["../src/AdheseSlot.tsx"],"sourcesContent":["'use client';\n\nimport { type ReactElement, useCallback, useId, useRef } from 'react';\nimport type { AdheseSlotOptions, AdheseSlot as Slot } from '@adhese/sdk';\nimport { watch } from '@adhese/sdk-shared';\nimport { useAdheseSlot } from './useAdheseSlot';\n\nexport type AdheseSlotProps = {\n /**\n * Callback to be called when the slot is created or disposed\n */\n onChange?(slot: Slot | null): void;\n} & Omit<AdheseSlotOptions, 'containingElement' | 'context'>;\n\n/**\n * Component to create an Adhese slot. The slot will be disposed when the component is unmounted. The slot will be\n * created when the containing element is available and the Adhese instance is available.\n *\n * @warning Make sure to wrap your `setup` function in a `useCallback` as it can trigger an infinite loop if it's not\n * memoized.\n */\n// eslint-disable-next-line ts/naming-convention\nexport function AdheseSlot({\n onChange,\n ...
|
|
1
|
+
{"version":3,"file":"AdheseSlot.js","sources":["../src/AdheseSlot.tsx"],"sourcesContent":["'use client';\n\nimport { type HTMLAttributes, type ReactElement, useCallback, useId, useRef } from 'react';\nimport type { AdheseSlotOptions, AdheseSlot as Slot } from '@adhese/sdk';\nimport { watch } from '@adhese/sdk-shared';\nimport { useAdheseSlot } from './useAdheseSlot';\n\nexport type AdheseSlotProps = {\n /**\n * Callback to be called when the slot is created or disposed\n */\n onChange?(slot: Slot | null): void;\n} & Omit<AdheseSlotOptions, 'containingElement' | 'context'> & HTMLAttributes<HTMLDivElement>;\n\n/**\n * Component to create an Adhese slot. The slot will be disposed when the component is unmounted. The slot will be\n * created when the containing element is available and the Adhese instance is available.\n *\n * @warning Make sure to wrap your `setup` function in a `useCallback` as it can trigger an infinite loop if it's not\n * memoized.\n */\n// eslint-disable-next-line ts/naming-convention\nexport function AdheseSlot({\n onChange,\n width,\n height,\n lazyLoading,\n lazyLoadingOptions,\n slot,\n pluginOptions,\n renderMode,\n type,\n setup,\n parameters,\n format,\n style,\n id,\n ...props\n}: AdheseSlotProps): ReactElement {\n const element = useRef<HTMLDivElement | null>(null);\n\n const slotState = useAdheseSlot(element, {\n width,\n height,\n lazyLoading,\n lazyLoadingOptions,\n slot,\n pluginOptions,\n renderMode,\n type,\n parameters,\n format,\n setup: useCallback(((context, hooks): void => {\n setup?.(context, hooks);\n\n watch(context, (newSlot) => {\n onChange?.(newSlot);\n }, { immediate: true, deep: true });\n }) satisfies AdheseSlotOptions['setup'], [setup, onChange]),\n });\n\n const componentId = useId();\n\n return (\n <div\n ref={element}\n id={id && `${componentId}${slotState?.id}`}\n data-name={slotState?.name}\n style={{\n width: slotState?.options.width,\n height: slotState?.options.height,\n ...style,\n }}\n {...props}\n />\n );\n}\n"],"names":[],"mappings":";;;;AAsBO,SAAS,WAAW;AAAA,EACzB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAkC;AAC1B,QAAA,UAAU,OAA8B,IAAI;AAE5C,QAAA,YAAY,cAAc,SAAS;AAAA,IACvC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO,YAAa,CAAC,SAAS,UAAgB;AAC5C,qCAAQ,SAAS;AAEX,YAAA,SAAS,CAAC,YAAY;AAC1B,6CAAW;AAAA,SACV,EAAE,WAAW,MAAM,MAAM,KAAM,CAAA;AAAA,IAAA,GACK,CAAC,OAAO,QAAQ,CAAC;AAAA,EAAA,CAC3D;AAED,QAAM,cAAc;AAGlB,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,KAAK;AAAA,MACL,IAAI,MAAM,GAAG,WAAW,GAAG,uCAAW,EAAE;AAAA,MACxC,aAAW,uCAAW;AAAA,MACtB,OAAO;AAAA,QACL,OAAO,uCAAW,QAAQ;AAAA,QAC1B,QAAQ,uCAAW,QAAQ;AAAA,QAC3B,GAAG;AAAA,MACL;AAAA,MACC,GAAG;AAAA,IAAA;AAAA,EAAA;AAGV;"}
|
package/dist/cjs/AdheseSlot.cjs
CHANGED
|
@@ -6,21 +6,55 @@ const sdkShared = require("@adhese/sdk-shared");
|
|
|
6
6
|
const useAdheseSlot = require("./useAdheseSlot.cjs");
|
|
7
7
|
function AdheseSlot({
|
|
8
8
|
onChange,
|
|
9
|
-
|
|
9
|
+
width,
|
|
10
|
+
height,
|
|
11
|
+
lazyLoading,
|
|
12
|
+
lazyLoadingOptions,
|
|
13
|
+
slot,
|
|
14
|
+
pluginOptions,
|
|
15
|
+
renderMode,
|
|
16
|
+
type,
|
|
17
|
+
setup,
|
|
18
|
+
parameters,
|
|
19
|
+
format,
|
|
20
|
+
style,
|
|
21
|
+
id,
|
|
22
|
+
...props
|
|
10
23
|
}) {
|
|
11
24
|
const element = react.useRef(null);
|
|
12
|
-
const
|
|
13
|
-
|
|
25
|
+
const slotState = useAdheseSlot.useAdheseSlot(element, {
|
|
26
|
+
width,
|
|
27
|
+
height,
|
|
28
|
+
lazyLoading,
|
|
29
|
+
lazyLoadingOptions,
|
|
30
|
+
slot,
|
|
31
|
+
pluginOptions,
|
|
32
|
+
renderMode,
|
|
33
|
+
type,
|
|
34
|
+
parameters,
|
|
35
|
+
format,
|
|
14
36
|
setup: react.useCallback((context, hooks) => {
|
|
15
|
-
|
|
16
|
-
(_a = options.setup) == null ? void 0 : _a.call(options, context, hooks);
|
|
37
|
+
setup == null ? void 0 : setup(context, hooks);
|
|
17
38
|
sdkShared.watch(context, (newSlot) => {
|
|
18
39
|
onChange == null ? void 0 : onChange(newSlot);
|
|
19
40
|
}, { immediate: true, deep: true });
|
|
20
|
-
}, [
|
|
41
|
+
}, [setup, onChange])
|
|
21
42
|
});
|
|
22
|
-
const
|
|
23
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
43
|
+
const componentId = react.useId();
|
|
44
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
45
|
+
"div",
|
|
46
|
+
{
|
|
47
|
+
ref: element,
|
|
48
|
+
id: id && `${componentId}${slotState == null ? void 0 : slotState.id}`,
|
|
49
|
+
"data-name": slotState == null ? void 0 : slotState.name,
|
|
50
|
+
style: {
|
|
51
|
+
width: slotState == null ? void 0 : slotState.options.width,
|
|
52
|
+
height: slotState == null ? void 0 : slotState.options.height,
|
|
53
|
+
...style
|
|
54
|
+
},
|
|
55
|
+
...props
|
|
56
|
+
}
|
|
57
|
+
);
|
|
24
58
|
}
|
|
25
59
|
exports.AdheseSlot = AdheseSlot;
|
|
26
60
|
//# sourceMappingURL=AdheseSlot.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AdheseSlot.cjs","sources":["../../src/AdheseSlot.tsx"],"sourcesContent":["'use client';\n\nimport { type ReactElement, useCallback, useId, useRef } from 'react';\nimport type { AdheseSlotOptions, AdheseSlot as Slot } from '@adhese/sdk';\nimport { watch } from '@adhese/sdk-shared';\nimport { useAdheseSlot } from './useAdheseSlot';\n\nexport type AdheseSlotProps = {\n /**\n * Callback to be called when the slot is created or disposed\n */\n onChange?(slot: Slot | null): void;\n} & Omit<AdheseSlotOptions, 'containingElement' | 'context'>;\n\n/**\n * Component to create an Adhese slot. The slot will be disposed when the component is unmounted. The slot will be\n * created when the containing element is available and the Adhese instance is available.\n *\n * @warning Make sure to wrap your `setup` function in a `useCallback` as it can trigger an infinite loop if it's not\n * memoized.\n */\n// eslint-disable-next-line ts/naming-convention\nexport function AdheseSlot({\n onChange,\n ...
|
|
1
|
+
{"version":3,"file":"AdheseSlot.cjs","sources":["../../src/AdheseSlot.tsx"],"sourcesContent":["'use client';\n\nimport { type HTMLAttributes, type ReactElement, useCallback, useId, useRef } from 'react';\nimport type { AdheseSlotOptions, AdheseSlot as Slot } from '@adhese/sdk';\nimport { watch } from '@adhese/sdk-shared';\nimport { useAdheseSlot } from './useAdheseSlot';\n\nexport type AdheseSlotProps = {\n /**\n * Callback to be called when the slot is created or disposed\n */\n onChange?(slot: Slot | null): void;\n} & Omit<AdheseSlotOptions, 'containingElement' | 'context'> & HTMLAttributes<HTMLDivElement>;\n\n/**\n * Component to create an Adhese slot. The slot will be disposed when the component is unmounted. The slot will be\n * created when the containing element is available and the Adhese instance is available.\n *\n * @warning Make sure to wrap your `setup` function in a `useCallback` as it can trigger an infinite loop if it's not\n * memoized.\n */\n// eslint-disable-next-line ts/naming-convention\nexport function AdheseSlot({\n onChange,\n width,\n height,\n lazyLoading,\n lazyLoadingOptions,\n slot,\n pluginOptions,\n renderMode,\n type,\n setup,\n parameters,\n format,\n style,\n id,\n ...props\n}: AdheseSlotProps): ReactElement {\n const element = useRef<HTMLDivElement | null>(null);\n\n const slotState = useAdheseSlot(element, {\n width,\n height,\n lazyLoading,\n lazyLoadingOptions,\n slot,\n pluginOptions,\n renderMode,\n type,\n parameters,\n format,\n setup: useCallback(((context, hooks): void => {\n setup?.(context, hooks);\n\n watch(context, (newSlot) => {\n onChange?.(newSlot);\n }, { immediate: true, deep: true });\n }) satisfies AdheseSlotOptions['setup'], [setup, onChange]),\n });\n\n const componentId = useId();\n\n return (\n <div\n ref={element}\n id={id && `${componentId}${slotState?.id}`}\n data-name={slotState?.name}\n style={{\n width: slotState?.options.width,\n height: slotState?.options.height,\n ...style,\n }}\n {...props}\n />\n );\n}\n"],"names":["useRef","useAdheseSlot","useCallback","watch","useId","jsx"],"mappings":";;;;;;AAsBO,SAAS,WAAW;AAAA,EACzB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAkC;AAC1B,QAAA,UAAUA,aAA8B,IAAI;AAE5C,QAAA,YAAYC,4BAAc,SAAS;AAAA,IACvC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAOC,MAAA,YAAa,CAAC,SAAS,UAAgB;AAC5C,qCAAQ,SAAS;AAEXC,sBAAA,SAAS,CAAC,YAAY;AAC1B,6CAAW;AAAA,SACV,EAAE,WAAW,MAAM,MAAM,KAAM,CAAA;AAAA,IAAA,GACK,CAAC,OAAO,QAAQ,CAAC;AAAA,EAAA,CAC3D;AAED,QAAM,cAAcC,MAAAA;AAGlB,SAAAC,2BAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,KAAK;AAAA,MACL,IAAI,MAAM,GAAG,WAAW,GAAG,uCAAW,EAAE;AAAA,MACxC,aAAW,uCAAW;AAAA,MACtB,OAAO;AAAA,QACL,OAAO,uCAAW,QAAQ;AAAA,QAC1B,QAAQ,uCAAW,QAAQ;AAAA,QAC3B,GAAG;AAAA,MACL;AAAA,MACC,GAAG;AAAA,IAAA;AAAA,EAAA;AAGV;;"}
|
package/dist/sdkReact.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PropsWithChildren, ReactElement, RefObject } from 'react';
|
|
1
|
+
import { PropsWithChildren, ReactElement, RefObject, HTMLAttributes } from 'react';
|
|
2
2
|
import { AdheseOptions, Adhese, AdheseSlotOptions, AdheseSlot as AdheseSlot$1 } from '@adhese/sdk';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -30,7 +30,7 @@ type AdheseSlotProps = {
|
|
|
30
30
|
* Callback to be called when the slot is created or disposed
|
|
31
31
|
*/
|
|
32
32
|
onChange?(slot: AdheseSlot$1 | null): void;
|
|
33
|
-
} & Omit<AdheseSlotOptions, 'containingElement' | 'context'>;
|
|
33
|
+
} & Omit<AdheseSlotOptions, 'containingElement' | 'context'> & HTMLAttributes<HTMLDivElement>;
|
|
34
34
|
/**
|
|
35
35
|
* Component to create an Adhese slot. The slot will be disposed when the component is unmounted. The slot will be
|
|
36
36
|
* created when the containing element is available and the Adhese instance is available.
|
|
@@ -38,6 +38,6 @@ type AdheseSlotProps = {
|
|
|
38
38
|
* @warning Make sure to wrap your `setup` function in a `useCallback` as it can trigger an infinite loop if it's not
|
|
39
39
|
* memoized.
|
|
40
40
|
*/
|
|
41
|
-
declare function AdheseSlot({ onChange, ...
|
|
41
|
+
declare function AdheseSlot({ onChange, width, height, lazyLoading, lazyLoadingOptions, slot, pluginOptions, renderMode, type, setup, parameters, format, style, id, ...props }: AdheseSlotProps): ReactElement;
|
|
42
42
|
|
|
43
43
|
export { AdheseProvider, AdheseSlot, useAdhese, useAdheseSlot };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adhese/sdk-react",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.2.0-nightly-20240625081726",
|
|
5
5
|
"description": "Adhese SDK",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"react-dom": ">=16.13"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@adhese/sdk": "
|
|
47
|
+
"@adhese/sdk": "1.1.4-nightly-20240625081726",
|
|
48
48
|
"@adhese/sdk-shared": "^1.1.0"
|
|
49
49
|
}
|
|
50
50
|
}
|