@adhese/sdk-react 1.1.4 → 1.2.0-nightly-20240625075942

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 CHANGED
@@ -1,5 +1,16 @@
1
1
  # @adhese/sdk-react
2
2
 
3
+ ## 1.2.0-nightly-20240625075942
4
+
5
+ ### Minor Changes
6
+
7
+ - 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
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [1ea0633]
12
+ - @adhese/sdk@1.1.4-nightly-20240625075942
13
+
3
14
  ## 1.1.4
4
15
 
5
16
  ### Patch Changes
@@ -18,7 +18,18 @@ function AdheseSlot({
18
18
  }, [options.setup, onChange])
19
19
  });
20
20
  const id = useId();
21
- return /* @__PURE__ */ jsx("div", { ref: element, id: `${id}${slot == null ? void 0 : slot.id}`, "data-name": slot == null ? void 0 : slot.name });
21
+ return /* @__PURE__ */ jsx(
22
+ "div",
23
+ {
24
+ ref: element,
25
+ id: `${id}${slot == null ? void 0 : slot.id}`,
26
+ "data-name": slot == null ? void 0 : slot.name,
27
+ style: (slot == null ? void 0 : slot.options) ? {
28
+ width: slot == null ? void 0 : slot.options.width,
29
+ height: slot == null ? void 0 : slot.options.height
30
+ } : void 0
31
+ }
32
+ );
22
33
  }
23
34
  export {
24
35
  AdheseSlot
@@ -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 ...options\n}: AdheseSlotProps): ReactElement {\n const element = useRef<HTMLDivElement | null>(null);\n\n const slot = useAdheseSlot(element, {\n ...options,\n setup: useCallback(((context, hooks): void => {\n options.setup?.(context, hooks);\n\n watch(context, (newSlot) => {\n onChange?.(newSlot);\n }, { immediate: true, deep: true });\n }) satisfies AdheseSlotOptions['setup'], [options.setup, onChange]),\n });\n\n const id = useId();\n\n return (\n <div ref={element} id={`${id}${slot?.id}`} data-name={slot?.name} />\n );\n}\n"],"names":[],"mappings":";;;;AAsBO,SAAS,WAAW;AAAA,EACzB;AAAA,EACA,GAAG;AACL,GAAkC;AAC1B,QAAA,UAAU,OAA8B,IAAI;AAE5C,QAAA,OAAO,cAAc,SAAS;AAAA,IAClC,GAAG;AAAA,IACH,OAAO,YAAa,CAAC,SAAS,UAAgB;;AACpC,oBAAA,UAAA,iCAAQ,SAAS;AAEnB,YAAA,SAAS,CAAC,YAAY;AAC1B,6CAAW;AAAA,SACV,EAAE,WAAW,MAAM,MAAM,KAAM,CAAA;AAAA,IACK,GAAA,CAAC,QAAQ,OAAO,QAAQ,CAAC;AAAA,EAAA,CACnE;AAED,QAAM,KAAK;AAEX,SACG,oBAAA,OAAA,EAAI,KAAK,SAAS,IAAI,GAAG,EAAE,GAAG,6BAAM,EAAE,IAAI,aAAW,6BAAM,KAAM,CAAA;AAEtE;"}
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 ...options\n}: AdheseSlotProps): ReactElement {\n const element = useRef<HTMLDivElement | null>(null);\n\n const slot = useAdheseSlot(element, {\n ...options,\n setup: useCallback(((context, hooks): void => {\n options.setup?.(context, hooks);\n\n watch(context, (newSlot) => {\n onChange?.(newSlot);\n }, { immediate: true, deep: true });\n }) satisfies AdheseSlotOptions['setup'], [options.setup, onChange]),\n });\n\n const id = useId();\n\n return (\n <div\n ref={element}\n id={`${id}${slot?.id}`}\n data-name={slot?.name}\n style={slot?.options\n ? {\n width: slot?.options.width,\n height: slot?.options.height,\n }\n : undefined}\n />\n );\n}\n"],"names":[],"mappings":";;;;AAsBO,SAAS,WAAW;AAAA,EACzB;AAAA,EACA,GAAG;AACL,GAAkC;AAC1B,QAAA,UAAU,OAA8B,IAAI;AAE5C,QAAA,OAAO,cAAc,SAAS;AAAA,IAClC,GAAG;AAAA,IACH,OAAO,YAAa,CAAC,SAAS,UAAgB;;AACpC,oBAAA,UAAA,iCAAQ,SAAS;AAEnB,YAAA,SAAS,CAAC,YAAY;AAC1B,6CAAW;AAAA,SACV,EAAE,WAAW,MAAM,MAAM,KAAM,CAAA;AAAA,IACK,GAAA,CAAC,QAAQ,OAAO,QAAQ,CAAC;AAAA,EAAA,CACnE;AAED,QAAM,KAAK;AAGT,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,KAAK;AAAA,MACL,IAAI,GAAG,EAAE,GAAG,6BAAM,EAAE;AAAA,MACpB,aAAW,6BAAM;AAAA,MACjB,QAAO,6BAAM,WACT;AAAA,QACE,OAAO,6BAAM,QAAQ;AAAA,QACrB,QAAQ,6BAAM,QAAQ;AAAA,MAExB,IAAA;AAAA,IAAA;AAAA,EAAA;AAGV;"}
@@ -20,7 +20,18 @@ function AdheseSlot({
20
20
  }, [options.setup, onChange])
21
21
  });
22
22
  const id = react.useId();
23
- return /* @__PURE__ */ jsxRuntime.jsx("div", { ref: element, id: `${id}${slot == null ? void 0 : slot.id}`, "data-name": slot == null ? void 0 : slot.name });
23
+ return /* @__PURE__ */ jsxRuntime.jsx(
24
+ "div",
25
+ {
26
+ ref: element,
27
+ id: `${id}${slot == null ? void 0 : slot.id}`,
28
+ "data-name": slot == null ? void 0 : slot.name,
29
+ style: (slot == null ? void 0 : slot.options) ? {
30
+ width: slot == null ? void 0 : slot.options.width,
31
+ height: slot == null ? void 0 : slot.options.height
32
+ } : void 0
33
+ }
34
+ );
24
35
  }
25
36
  exports.AdheseSlot = AdheseSlot;
26
37
  //# 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 ...options\n}: AdheseSlotProps): ReactElement {\n const element = useRef<HTMLDivElement | null>(null);\n\n const slot = useAdheseSlot(element, {\n ...options,\n setup: useCallback(((context, hooks): void => {\n options.setup?.(context, hooks);\n\n watch(context, (newSlot) => {\n onChange?.(newSlot);\n }, { immediate: true, deep: true });\n }) satisfies AdheseSlotOptions['setup'], [options.setup, onChange]),\n });\n\n const id = useId();\n\n return (\n <div ref={element} id={`${id}${slot?.id}`} data-name={slot?.name} />\n );\n}\n"],"names":["useRef","useAdheseSlot","useCallback","watch","useId","jsx"],"mappings":";;;;;;AAsBO,SAAS,WAAW;AAAA,EACzB;AAAA,EACA,GAAG;AACL,GAAkC;AAC1B,QAAA,UAAUA,aAA8B,IAAI;AAE5C,QAAA,OAAOC,4BAAc,SAAS;AAAA,IAClC,GAAG;AAAA,IACH,OAAOC,MAAA,YAAa,CAAC,SAAS,UAAgB;;AACpC,oBAAA,UAAA,iCAAQ,SAAS;AAEnBC,sBAAA,SAAS,CAAC,YAAY;AAC1B,6CAAW;AAAA,SACV,EAAE,WAAW,MAAM,MAAM,KAAM,CAAA;AAAA,IACK,GAAA,CAAC,QAAQ,OAAO,QAAQ,CAAC;AAAA,EAAA,CACnE;AAED,QAAM,KAAKC,MAAAA;AAEX,SACGC,2BAAAA,IAAA,OAAA,EAAI,KAAK,SAAS,IAAI,GAAG,EAAE,GAAG,6BAAM,EAAE,IAAI,aAAW,6BAAM,KAAM,CAAA;AAEtE;;"}
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 ...options\n}: AdheseSlotProps): ReactElement {\n const element = useRef<HTMLDivElement | null>(null);\n\n const slot = useAdheseSlot(element, {\n ...options,\n setup: useCallback(((context, hooks): void => {\n options.setup?.(context, hooks);\n\n watch(context, (newSlot) => {\n onChange?.(newSlot);\n }, { immediate: true, deep: true });\n }) satisfies AdheseSlotOptions['setup'], [options.setup, onChange]),\n });\n\n const id = useId();\n\n return (\n <div\n ref={element}\n id={`${id}${slot?.id}`}\n data-name={slot?.name}\n style={slot?.options\n ? {\n width: slot?.options.width,\n height: slot?.options.height,\n }\n : undefined}\n />\n );\n}\n"],"names":["useRef","useAdheseSlot","useCallback","watch","useId","jsx"],"mappings":";;;;;;AAsBO,SAAS,WAAW;AAAA,EACzB;AAAA,EACA,GAAG;AACL,GAAkC;AAC1B,QAAA,UAAUA,aAA8B,IAAI;AAE5C,QAAA,OAAOC,4BAAc,SAAS;AAAA,IAClC,GAAG;AAAA,IACH,OAAOC,MAAA,YAAa,CAAC,SAAS,UAAgB;;AACpC,oBAAA,UAAA,iCAAQ,SAAS;AAEnBC,sBAAA,SAAS,CAAC,YAAY;AAC1B,6CAAW;AAAA,SACV,EAAE,WAAW,MAAM,MAAM,KAAM,CAAA;AAAA,IACK,GAAA,CAAC,QAAQ,OAAO,QAAQ,CAAC;AAAA,EAAA,CACnE;AAED,QAAM,KAAKC,MAAAA;AAGT,SAAAC,2BAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,KAAK;AAAA,MACL,IAAI,GAAG,EAAE,GAAG,6BAAM,EAAE;AAAA,MACpB,aAAW,6BAAM;AAAA,MACjB,QAAO,6BAAM,WACT;AAAA,QACE,OAAO,6BAAM,QAAQ;AAAA,QACrB,QAAQ,6BAAM,QAAQ;AAAA,MAExB,IAAA;AAAA,IAAA;AAAA,EAAA;AAGV;;"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@adhese/sdk-react",
3
3
  "type": "module",
4
- "version": "1.1.4",
4
+ "version": "1.2.0-nightly-20240625075942",
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": "^1.1.3",
47
+ "@adhese/sdk": "1.1.4-nightly-20240625075942",
48
48
  "@adhese/sdk-shared": "^1.1.0"
49
49
  }
50
50
  }