@bonprix-ds/react-feature-hint 1.0.1 → 1.1.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.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  import "./src/jsx";
2
2
  export { default } from "./src/FeatureHint";
3
- export type { Props as FeatureHintProps, TriggerProps, HeadlineProps, SublineProps } from "./src/FeatureHint";
3
+ export type { Props as FeatureHintProps, TriggerProps, ContentProps, HeadlineProps, SublineProps } from "./src/FeatureHint";
@@ -5,6 +5,10 @@ export interface TriggerProps {
5
5
  /** The element the popup is anchored to. */
6
6
  children: ReactNode;
7
7
  }
8
+ export interface ContentProps {
9
+ /** FeatureHint.Headline and FeatureHint.Subline. */
10
+ children: ReactNode;
11
+ }
8
12
  export interface HeadlineProps {
9
13
  /** The headline to display in the popup. */
10
14
  children: ReactNode;
@@ -20,6 +24,10 @@ declare const FeatureHint: {
20
24
  ({ children }: TriggerProps): React.JSX.Element;
21
25
  displayName: string;
22
26
  };
27
+ Content: {
28
+ ({ children }: ContentProps): React.JSX.Element;
29
+ displayName: string;
30
+ };
23
31
  Headline: {
24
32
  ({ children }: HeadlineProps): React.JSX.Element;
25
33
  displayName: string;
@@ -1,20 +1,36 @@
1
1
  import e from "./FeatureHintRoot.js";
2
2
  import "react";
3
- import { jsx as t } from "react/jsx-runtime";
3
+ import { CloserIcon as t } from "@bonprix-ds/react-icon/icons";
4
+ import { jsx as n, jsxs as r } from "react/jsx-runtime";
4
5
  //#region src/FeatureHint.tsx
5
- var n = ({ children: e }) => /* @__PURE__ */ t("div", {
6
+ var i = ({ children: e }) => /* @__PURE__ */ n("div", {
6
7
  className: "w-fit",
7
8
  "data-bpds-feature-hint-trigger": !0,
8
9
  children: e
9
- }), r = ({ children: e }) => /* @__PURE__ */ t("div", {
10
+ }), a = ({ children: e }) => /* @__PURE__ */ r("div", {
11
+ "data-bpds-feature-hint-popup": !0,
12
+ children: [
13
+ /* @__PURE__ */ n("div", {
14
+ "data-bpds-feature-hint-content": !0,
15
+ children: e
16
+ }),
17
+ /* @__PURE__ */ n("button", {
18
+ type: "button",
19
+ "data-bpds-feature-hint-close-button": !0,
20
+ "aria-label": "Schließen",
21
+ children: /* @__PURE__ */ n(t, { className: "h-4 w-4 fill-current" })
22
+ }),
23
+ /* @__PURE__ */ n("div", { "data-bpds-feature-hint-arrow": !0 })
24
+ ]
25
+ }), o = ({ children: e }) => /* @__PURE__ */ n("div", {
10
26
  "data-bpds-feature-hint-headline": !0,
11
27
  children: e
12
- }), i = ({ children: e }) => /* @__PURE__ */ t("div", {
28
+ }), s = ({ children: e }) => /* @__PURE__ */ n("div", {
13
29
  "data-bpds-feature-hint-subline": !0,
14
30
  children: e
15
- }), a = (n) => /* @__PURE__ */ t(e, { ...n });
16
- a.displayName = "FeatureHint", a.Trigger = n, n.displayName = "FeatureHint.Trigger", a.Headline = r, r.displayName = "FeatureHint.Headline", a.Subline = i, i.displayName = "FeatureHint.Subline";
31
+ }), c = (t) => /* @__PURE__ */ n(e, { ...t });
32
+ c.displayName = "FeatureHint", c.Trigger = i, i.displayName = "FeatureHint.Trigger", c.Content = a, a.displayName = "FeatureHint.Content", c.Headline = o, o.displayName = "FeatureHint.Headline", c.Subline = s, s.displayName = "FeatureHint.Subline";
17
33
  //#endregion
18
- export { a as default };
34
+ export { c as default };
19
35
 
20
36
  //# sourceMappingURL=FeatureHint.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"FeatureHint.js","names":["FeatureHintRoot","Trigger","Headline","Subline","FeatureHint","props"],"sources":["../../src/FeatureHint.tsx"],"sourcesContent":["import React, { type ReactNode } from \"react\";\n\nimport FeatureHintRoot, { type Props } from \"./FeatureHintRoot\";\n\nexport type { Props };\n\nexport interface TriggerProps {\n /** The element the popup is anchored to. */\n children: ReactNode;\n}\n\nexport interface HeadlineProps {\n /** The headline to display in the popup. */\n children: ReactNode;\n}\n\nexport interface SublineProps {\n /** The text to display below the headline of the popup. */\n children: ReactNode;\n}\n\nconst Trigger = ({ children }: TriggerProps) => (\n <div className=\"w-fit\" data-bpds-feature-hint-trigger>\n {children}\n </div>\n);\n\nconst Headline = ({ children }: HeadlineProps) => <div data-bpds-feature-hint-headline>{children}</div>;\n\nconst Subline = ({ children }: SublineProps) => <div data-bpds-feature-hint-subline>{children}</div>;\n\n// No \"use client\" here on purpose: a Server Component cannot read `FeatureHint.Trigger` off a client\n// module, so the properties have to be attached in a module the server itself evaluates.\nconst FeatureHint = (props: Props) => <FeatureHintRoot {...props} />;\n\nFeatureHint.displayName = \"FeatureHint\";\n\nFeatureHint.Trigger = Trigger;\nTrigger.displayName = \"FeatureHint.Trigger\";\n\nFeatureHint.Headline = Headline;\nHeadline.displayName = \"FeatureHint.Headline\";\n\nFeatureHint.Subline = Subline;\nSubline.displayName = \"FeatureHint.Subline\";\n\nexport default FeatureHint;\n"],"mappings":";;;;AAqBA,IAAMC,KAAW,EAAE,kBACjB,kBAAC,OAAD;CAAK,WAAU;CAAQ,kCAAA;CACpB;AACE,CAAA,GAGDC,KAAY,EAAE,kBAA8B,kBAAC,OAAD;CAAK,mCAAA;CAAiC;AAAc,CAAA,GAEhGC,KAAW,EAAE,kBAA6B,kBAAC,OAAD;CAAK,kCAAA;CAAgC;AAAc,CAAA,GAI7FC,KAAe,MAAiB,kBAACJ,GAAD,EAAiB,GAAIK,EAAQ,CAAA;AAEnE,EAAY,cAAc,eAE1B,EAAY,UAAUJ,GACtB,EAAQ,cAAc,uBAEtB,EAAY,WAAWC,GACvB,EAAS,cAAc,wBAEvB,EAAY,UAAUC,GACtB,EAAQ,cAAc"}
1
+ {"version":3,"file":"FeatureHint.js","names":["FeatureHintRoot","Trigger","Content","CloserIcon","Headline","Subline","FeatureHint","props"],"sources":["../../src/FeatureHint.tsx"],"sourcesContent":["import React, { type ReactNode } from \"react\";\n\nimport { CloserIcon } from \"@bonprix-ds/react-icon/icons\";\n\nimport FeatureHintRoot, { type Props } from \"./FeatureHintRoot\";\n\nexport type { Props };\n\nexport interface TriggerProps {\n /** The element the popup is anchored to. */\n children: ReactNode;\n}\n\nexport interface ContentProps {\n /** FeatureHint.Headline and FeatureHint.Subline. */\n children: ReactNode;\n}\n\nexport interface HeadlineProps {\n /** The headline to display in the popup. */\n children: ReactNode;\n}\n\nexport interface SublineProps {\n /** The text to display below the headline of the popup. */\n children: ReactNode;\n}\n\nconst Trigger = ({ children }: TriggerProps) => (\n <div className=\"w-fit\" data-bpds-feature-hint-trigger>\n {children}\n </div>\n);\n\nconst Content = ({ children }: ContentProps) => (\n <div data-bpds-feature-hint-popup>\n <div data-bpds-feature-hint-content>{children}</div>\n <button type=\"button\" data-bpds-feature-hint-close-button aria-label=\"Schließen\">\n <CloserIcon className=\"h-4 w-4 fill-current\" />\n </button>\n <div data-bpds-feature-hint-arrow />\n </div>\n);\n\nconst Headline = ({ children }: HeadlineProps) => <div data-bpds-feature-hint-headline>{children}</div>;\n\nconst Subline = ({ children }: SublineProps) => <div data-bpds-feature-hint-subline>{children}</div>;\n\n// No \"use client\" here on purpose: a Server Component cannot read `FeatureHint.Trigger` off a client\n// module, so the properties have to be attached in a module the server itself evaluates.\nconst FeatureHint = (props: Props) => <FeatureHintRoot {...props} />;\n\nFeatureHint.displayName = \"FeatureHint\";\n\nFeatureHint.Trigger = Trigger;\nTrigger.displayName = \"FeatureHint.Trigger\";\n\nFeatureHint.Content = Content;\nContent.displayName = \"FeatureHint.Content\";\n\nFeatureHint.Headline = Headline;\nHeadline.displayName = \"FeatureHint.Headline\";\n\nFeatureHint.Subline = Subline;\nSubline.displayName = \"FeatureHint.Subline\";\n\nexport default FeatureHint;\n"],"mappings":";;;;;AA4BA,IAAMC,KAAW,EAAE,kBACjB,kBAAC,OAAD;CAAK,WAAU;CAAQ,kCAAA;CACpB;AACE,CAAA,GAGDC,KAAW,EAAE,kBACjB,kBAAC,OAAD;CAAK,gCAAA;CAAL,UAAA;EACE,kBAAC,OAAD;GAAK,kCAAA;GAAgC;EAAc,CAAA;EACnD,kBAAC,UAAD;GAAQ,MAAK;GAAS,uCAAA;GAAoC,cAAW;GACnE,UAAA,kBAACC,GAAD,EAAY,WAAU,uBAAwB,CAAA;EACxC,CAAA;EACR,kBAAC,OAAD,EAAK,gCAAA,GAA8B,CAAA;CAChC;IAGDC,KAAY,EAAE,kBAA8B,kBAAC,OAAD;CAAK,mCAAA;CAAiC;AAAc,CAAA,GAEhGC,KAAW,EAAE,kBAA6B,kBAAC,OAAD;CAAK,kCAAA;CAAgC;AAAc,CAAA,GAI7FC,KAAe,MAAiB,kBAACN,GAAD,EAAiB,GAAIO,EAAQ,CAAA;AAEnE,EAAY,cAAc,eAE1B,EAAY,UAAUN,GACtB,EAAQ,cAAc,uBAEtB,EAAY,UAAUC,GACtB,EAAQ,cAAc,uBAEtB,EAAY,WAAWE,GACvB,EAAS,cAAc,wBAEvB,EAAY,UAAUC,GACtB,EAAQ,cAAc"}
@@ -6,7 +6,7 @@ export interface Props {
6
6
  horizontalPosition?: FeatureHintProps["horizontal-position"];
7
7
  /** Preferred vertical position of the popup. */
8
8
  verticalPosition?: FeatureHintProps["vertical-position"];
9
- /** Needs to include FeatureHint.Trigger, FeatureHint.Headline and FeatureHint.Subline. */
9
+ /** FeatureHint.Trigger and FeatureHint.Content, which holds FeatureHint.Headline and FeatureHint.Subline. */
10
10
  children: ReactNode;
11
11
  /** Callback that gets called right before the popup is closed. */
12
12
  onClose?: () => void;
@@ -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 e } from "react/jsx-runtime";
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 t = ({ children: t, verticalPosition: n, horizontalPosition: r, onClose: i }) => /* @__PURE__ */ e("bpds-feature-hint", {
10
- "horizontal-position": r,
11
- "vertical-position": n,
12
- "onbpds-feature-hint-close": i,
13
- className: "preflight",
14
- children: t
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 { t as default };
21
+ export { r as default };
18
22
 
19
23
  //# sourceMappingURL=FeatureHintRoot.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"FeatureHintRoot.js","names":["FeatureHintElement","FeatureHintRoot","horizontalPosition","verticalPosition","onClose"],"sources":["../../src/FeatureHintRoot.tsx"],"sourcesContent":["\"use client\";\n\nimport React, { type ReactNode } from \"react\";\n\nimport type { FeatureHintProps } from \"@bonprix-ds/bpds-feature-hint\";\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 return (\n <bpds-feature-hint\n horizontal-position={horizontalPosition}\n vertical-position={verticalPosition}\n onbpds-feature-hint-close={onClose}\n className=\"preflight\"\n >\n {children}\n </bpds-feature-hint>\n );\n};\n\nexport default FeatureHintRoot;\n"],"mappings":";;;;;AAeI,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,iBAEvE,kBAAC,qBAAD;CACE,uBAAqBC;CACrB,qBAAmBC;CACnB,6BAA2BC;CAC3B,WAAU;CAET;AACgB,CAAA"}
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 `@floating-ui/dom` out of the server\n// bundle. FeatureHint.Content renders the whole popup, so the upgrade only positions it and wires up\n// the close button.\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 /** FeatureHint.Trigger and FeatureHint.Content, which holds 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.1",
3
+ "version": "1.1.0",
4
4
  "description": "FeatureHint component, implemented in React, for the Bonprix Design System.",
5
5
  "keywords": [],
6
6
  "license": "UNLICENSED",
@@ -41,11 +41,16 @@
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.1.0",
45
+ "@bonprix-ds/react-icon": "1.3.2",
46
+ "@bonprix-ds/utils": "0.5.0"
45
47
  },
46
48
  "devDependencies": {
49
+ "@testing-library/dom": "10.4.2",
50
+ "@testing-library/react": "16.3.3",
47
51
  "@types/react": "19.3.0",
48
- "vite": "8.3.2",
52
+ "vite": "8.3.3",
53
+ "vitest": "5.0.5",
49
54
  "@bonprix-ds/vite-config": "0.0.0"
50
55
  },
51
56
  "peerDependencies": {