@bonprix-ds/react-feature-hint 1.0.1 → 1.0.2
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.
|
@@ -1,19 +1,23 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import "react";
|
|
2
|
+
import { useRef as e } from "react";
|
|
3
|
+
import { useEventListener as t } from "@bonprix-ds/utils";
|
|
3
4
|
import "#styles";
|
|
4
|
-
import { jsx as
|
|
5
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
5
6
|
//#region src/FeatureHintRoot.tsx
|
|
6
7
|
typeof window < "u" && import("@bonprix-ds/bpds-feature-hint").then(({ FeatureHint: e }) => {
|
|
7
8
|
customElements.get("bpds-feature-hint") || customElements.define("bpds-feature-hint", e);
|
|
8
9
|
});
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
var r = ({ children: r, verticalPosition: i, horizontalPosition: a, onClose: o }) => {
|
|
11
|
+
let s = e(null);
|
|
12
|
+
return t(s, "bpds-feature-hint-close", o), /* @__PURE__ */ n("bpds-feature-hint", {
|
|
13
|
+
ref: s,
|
|
14
|
+
"horizontal-position": a,
|
|
15
|
+
"vertical-position": i,
|
|
16
|
+
className: "preflight",
|
|
17
|
+
children: r
|
|
18
|
+
});
|
|
19
|
+
};
|
|
16
20
|
//#endregion
|
|
17
|
-
export {
|
|
21
|
+
export { r as default };
|
|
18
22
|
|
|
19
23
|
//# sourceMappingURL=FeatureHintRoot.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FeatureHintRoot.js","names":["FeatureHintElement","FeatureHintRoot","
|
|
1
|
+
{"version":3,"file":"FeatureHintRoot.js","names":["FeatureHintElement","FeatureHintRoot","ref","useRef","useEventListener","onClose","horizontalPosition","verticalPosition"],"sources":["../../src/FeatureHintRoot.tsx"],"sourcesContent":["\"use client\";\n\nimport React, { useRef, type ReactNode } from \"react\";\n\nimport type { FeatureHintProps } from \"@bonprix-ds/bpds-feature-hint\";\nimport { useEventListener } from \"@bonprix-ds/utils\";\nimport \"@bonprix-ds/bpds-feature-hint/feature-hint.css\";\n\n// The element class is loaded lazily and only in the browser: `class X extends HTMLElement` is\n// evaluated at module scope, and `HTMLElement` does not exist in Node, so a static import would\n// throw while the server renders this component. It also keeps `lit` and `@floating-ui/dom` out of\n// the server bundle, and defers the popup markup the element injects until after hydration, which\n// is what keeps that injection from becoming a hydration mismatch.\n// The registry check has to sit inside the callback, not beside the window guard: the tag can be\n// registered during the await - `defineCustomElements` from the umbrella does exactly that - and\n// `define` throws `NotSupportedError` on a name that is already taken.\nif (typeof window !== \"undefined\") {\n void import(\"@bonprix-ds/bpds-feature-hint\").then(({ FeatureHint: FeatureHintElement }) => {\n if (!customElements.get(\"bpds-feature-hint\")) customElements.define(\"bpds-feature-hint\", FeatureHintElement);\n });\n}\n\nexport interface Props {\n /** Preferred horizontal position of the popup. */\n horizontalPosition?: FeatureHintProps[\"horizontal-position\"];\n /** Preferred vertical position of the popup. */\n verticalPosition?: FeatureHintProps[\"vertical-position\"];\n /** Needs to include FeatureHint.Trigger, FeatureHint.Headline and FeatureHint.Subline. */\n children: ReactNode;\n /** Callback that gets called right before the popup is closed. */\n onClose?: () => void;\n}\n\nconst FeatureHintRoot = ({ children, verticalPosition, horizontalPosition, onClose }: Props) => {\n const ref = useRef<HTMLElement>(null);\n\n useEventListener(ref, \"bpds-feature-hint-close\", onClose);\n\n return (\n <bpds-feature-hint ref={ref} horizontal-position={horizontalPosition} vertical-position={verticalPosition} className=\"preflight\">\n {children}\n </bpds-feature-hint>\n );\n};\n\nexport default FeatureHintRoot;\n"],"mappings":";;;;;;AAgBI,OAAO,SAAW,OACpB,OAAY,gCAAgC,CAAC,MAAM,EAAE,aAAaA,QAAyB;CACzF,AAAK,eAAe,IAAI,mBAAmB,KAAG,eAAe,OAAO,qBAAqBA,CAAkB;AAC7G,CAAC;AAcH,IAAMC,KAAmB,EAAE,aAAU,qBAAkB,uBAAoB,iBAAqB;CAC9F,IAAMC,IAAMC,EAAoB,IAAI;CAIpC,OAFAC,EAAiBF,GAAK,2BAA2BG,CAAO,GAGtD,kBAAC,qBAAD;EAAwB;EAAK,uBAAqBC;EAAoB,qBAAmBC;EAAkB,WAAU;EAClH;CACgB,CAAA;AAEvB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bonprix-ds/react-feature-hint",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "FeatureHint component, implemented in React, for the Bonprix Design System.",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -41,11 +41,15 @@
|
|
|
41
41
|
"provenance": true
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@bonprix-ds/bpds-feature-hint": "1.0.1"
|
|
44
|
+
"@bonprix-ds/bpds-feature-hint": "1.0.1",
|
|
45
|
+
"@bonprix-ds/utils": "0.5.0"
|
|
45
46
|
},
|
|
46
47
|
"devDependencies": {
|
|
48
|
+
"@testing-library/dom": "10.4.2",
|
|
49
|
+
"@testing-library/react": "16.3.3",
|
|
47
50
|
"@types/react": "19.3.0",
|
|
48
51
|
"vite": "8.3.2",
|
|
52
|
+
"vitest": "5.0.5",
|
|
49
53
|
"@bonprix-ds/vite-config": "0.0.0"
|
|
50
54
|
},
|
|
51
55
|
"peerDependencies": {
|