@knocklabs/react 0.7.10 → 0.7.12

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.
Files changed (28) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/index.css +1 -1
  3. package/dist/cjs/modules/guide/components/Banner/Banner.js.map +1 -1
  4. package/dist/cjs/modules/guide/components/Card/Card.js +1 -1
  5. package/dist/cjs/modules/guide/components/Card/Card.js.map +1 -1
  6. package/dist/cjs/modules/guide/components/Modal/Modal.js +1 -1
  7. package/dist/cjs/modules/guide/components/Modal/Modal.js.map +1 -1
  8. package/dist/cjs/modules/guide/components/helpers.js +1 -1
  9. package/dist/cjs/modules/guide/components/helpers.js.map +1 -1
  10. package/dist/esm/modules/guide/components/Banner/Banner.mjs.map +1 -1
  11. package/dist/esm/modules/guide/components/Card/Card.mjs +115 -90
  12. package/dist/esm/modules/guide/components/Card/Card.mjs.map +1 -1
  13. package/dist/esm/modules/guide/components/Modal/Modal.mjs +131 -106
  14. package/dist/esm/modules/guide/components/Modal/Modal.mjs.map +1 -1
  15. package/dist/esm/modules/guide/components/helpers.mjs +1 -0
  16. package/dist/esm/modules/guide/components/helpers.mjs.map +1 -1
  17. package/dist/index.css +1 -1
  18. package/dist/types/modules/guide/components/Banner/Banner.d.ts +2 -2
  19. package/dist/types/modules/guide/components/Banner/Banner.d.ts.map +1 -1
  20. package/dist/types/modules/guide/components/Card/Card.d.ts +7 -2
  21. package/dist/types/modules/guide/components/Card/Card.d.ts.map +1 -1
  22. package/dist/types/modules/guide/components/Modal/Modal.d.ts +7 -2
  23. package/dist/types/modules/guide/components/Modal/Modal.d.ts.map +1 -1
  24. package/dist/types/modules/guide/components/helpers.d.ts +1 -0
  25. package/dist/types/modules/guide/components/helpers.d.ts.map +1 -1
  26. package/dist/types/modules/guide/components/types.d.ts +12 -1
  27. package/dist/types/modules/guide/components/types.d.ts.map +1 -1
  28. package/package.json +4 -6
@@ -1,147 +1,172 @@
1
- import { useGuide as M } from "@knocklabs/react-core";
2
- import * as i from "@radix-ui/react-dialog";
1
+ import { useGuide as V } from "@knocklabs/react-core";
2
+ import * as d from "@radix-ui/react-dialog";
3
3
  import n from "clsx";
4
- import t from "react";
5
- import { maybeNavigateToUrlWithDelay as b } from "../helpers.mjs";
4
+ import a from "react";
5
+ import { isValidHttpUrl as v, maybeNavigateToUrlWithDelay as h } from "../helpers.mjs";
6
6
  /* empty css */
7
- const V = "modal", s = ({
7
+ const x = "modal", u = ({
8
8
  children: e,
9
- onOpenChange: a,
10
- ...o
11
- }) => /* @__PURE__ */ t.createElement(i.Root, { defaultOpen: !0, onOpenChange: a, ...o }, /* @__PURE__ */ t.createElement(i.Portal, null, e));
12
- s.displayName = "ModalView.Root";
13
- const u = t.forwardRef(({
9
+ onOpenChange: t,
10
+ ...l
11
+ }) => /* @__PURE__ */ a.createElement(d.Root, { defaultOpen: !0, onOpenChange: t, ...l }, /* @__PURE__ */ a.createElement(d.Portal, null, e));
12
+ u.displayName = "ModalView.Root";
13
+ const y = a.forwardRef(({
14
14
  className: e,
15
- ...a
16
- }, o) => /* @__PURE__ */ t.createElement(i.Overlay, { className: n("knock-guide-modal__overlay", e), ref: o, ...a }));
17
- u.displayName = "ModalView.Overlay";
18
- const y = t.forwardRef(({
15
+ ...t
16
+ }, l) => /* @__PURE__ */ a.createElement(d.Overlay, { className: n("knock-guide-modal__overlay", e), ref: l, ...t }));
17
+ y.displayName = "ModalView.Overlay";
18
+ const _ = a.forwardRef(({
19
19
  children: e,
20
- className: a,
21
- ...o
22
- }, l) => /* @__PURE__ */ t.createElement(i.Content, { className: n("knock-guide-modal", a), ref: l, ...o }, e));
23
- y.displayName = "ModalView.Content";
24
- const w = ({
20
+ className: t,
21
+ ...l
22
+ }, r) => /* @__PURE__ */ a.createElement(d.Content, { className: n("knock-guide-modal", t), ref: r, ...l }, e));
23
+ _.displayName = "ModalView.Content";
24
+ const M = ({
25
25
  children: e,
26
- className: a,
27
- ...o
28
- }) => /* @__PURE__ */ t.createElement("div", { className: n("knock-guide-modal__header", a), ...o }, e);
29
- w.displayName = "ModalView.Header";
30
- const _ = ({
31
- title: e,
32
- className: a,
33
- ...o
34
- }) => /* @__PURE__ */ t.createElement(i.Title, { className: n("knock-guide-modal__title", a), ...o }, e);
35
- _.displayName = "ModalView.Title";
26
+ className: t,
27
+ ...l
28
+ }) => /* @__PURE__ */ a.createElement("div", { className: n("knock-guide-modal__header", t), ...l }, e);
29
+ M.displayName = "ModalView.Header";
36
30
  const p = ({
31
+ title: e,
32
+ className: t,
33
+ ...l
34
+ }) => /* @__PURE__ */ a.createElement(d.Title, { className: n("knock-guide-modal__title", t), ...l }, e);
35
+ p.displayName = "ModalView.Title";
36
+ const E = ({
37
37
  body: e,
38
- className: a,
39
- ...o
40
- }) => /* @__PURE__ */ t.createElement(i.Description, { className: n("knock-guide-modal__body", a), dangerouslySetInnerHTML: {
38
+ className: t,
39
+ ...l
40
+ }) => /* @__PURE__ */ a.createElement(d.Description, { className: n("knock-guide-modal__body", t), dangerouslySetInnerHTML: {
41
41
  __html: e
42
- }, ...o });
43
- p.displayName = "ModalView.Body";
44
- const E = ({
42
+ }, ...l });
43
+ E.displayName = "ModalView.Body";
44
+ const g = ({
45
45
  children: e,
46
- className: a,
47
- ...o
48
- }) => /* @__PURE__ */ t.createElement("div", { className: n("knock-guide-modal__actions", a), ...o }, e);
49
- E.displayName = "ModalView.Actions";
46
+ className: t,
47
+ alt: l,
48
+ ...r
49
+ }) => /* @__PURE__ */ a.createElement("img", { className: n("knock-guide-modal__img", t), alt: l || "", ...r }, e);
50
+ g.displayName = "ModalView.Img";
50
51
  const k = ({
51
- text: e,
52
- action: a,
53
- className: o,
52
+ children: e,
53
+ className: t,
54
54
  ...l
55
- }) => /* @__PURE__ */ t.createElement("button", { className: n("knock-guide-modal__action", o), ...l }, e);
56
- k.displayName = "ModalView.PrimaryButton";
55
+ }) => /* @__PURE__ */ a.createElement("div", { className: n("knock-guide-modal__actions", t), ...l }, e);
56
+ k.displayName = "ModalView.Actions";
57
57
  const f = ({
58
58
  text: e,
59
- action: a,
60
- className: o,
61
- ...l
62
- }) => /* @__PURE__ */ t.createElement("button", { className: n("knock-guide-modal__action knock-guide-modal__action--secondary", o), ...l }, e);
63
- f.displayName = "ModalView.SecondaryButton";
59
+ action: t,
60
+ className: l,
61
+ ...r
62
+ }) => /* @__PURE__ */ a.createElement("button", { className: n("knock-guide-modal__action", l), ...r }, e);
63
+ f.displayName = "ModalView.PrimaryButton";
64
64
  const N = ({
65
+ text: e,
66
+ action: t,
67
+ className: l,
68
+ ...r
69
+ }) => /* @__PURE__ */ a.createElement("button", { className: n("knock-guide-modal__action knock-guide-modal__action--secondary", l), ...r }, e);
70
+ N.displayName = "ModalView.SecondaryButton";
71
+ const w = ({
65
72
  className: e,
66
- ...a
67
- }) => /* @__PURE__ */ t.createElement(i.Close, { className: n("knock-guide-modal__close", e), ...a }, /* @__PURE__ */ t.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "18", height: "18", fill: "none" }, /* @__PURE__ */ t.createElement("g", { fill: "#60646C", fillRule: "evenodd", clipRule: "evenodd" }, /* @__PURE__ */ t.createElement("path", { d: "M14.03 3.97a.75.75 0 0 1 0 1.06l-9 9a.75.75 0 0 1-1.06-1.06l9-9a.75.75 0 0 1 1.06 0Z" }), /* @__PURE__ */ t.createElement("path", { d: "M3.97 3.97a.75.75 0 0 1 1.06 0l9 9a.75.75 0 1 1-1.06 1.06l-9-9a.75.75 0 0 1 0-1.06Z" }))));
68
- N.displayName = "ModalView.Close";
69
- const g = ({
73
+ ...t
74
+ }) => /* @__PURE__ */ a.createElement(d.Close, { className: n("knock-guide-modal__close", e), ...t }, /* @__PURE__ */ a.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "18", height: "18", fill: "none" }, /* @__PURE__ */ a.createElement("g", { fill: "#60646C", fillRule: "evenodd", clipRule: "evenodd" }, /* @__PURE__ */ a.createElement("path", { d: "M14.03 3.97a.75.75 0 0 1 0 1.06l-9 9a.75.75 0 0 1-1.06-1.06l9-9a.75.75 0 0 1 1.06 0Z" }), /* @__PURE__ */ a.createElement("path", { d: "M3.97 3.97a.75.75 0 0 1 1.06 0l9 9a.75.75 0 1 1-1.06 1.06l-9-9a.75.75 0 0 1 0-1.06Z" }))));
75
+ w.displayName = "ModalView.Close";
76
+ const b = ({
70
77
  content: e,
71
- colorMode: a = "light",
72
- onOpenChange: o,
73
- onDismiss: l,
74
- onButtonClick: c
75
- }) => /* @__PURE__ */ t.createElement(s, { onOpenChange: o }, /* @__PURE__ */ t.createElement(u, null), /* @__PURE__ */ t.createElement(y, { "data-knock-color-mode": a, onPointerDownOutside: l }, /* @__PURE__ */ t.createElement(w, null, /* @__PURE__ */ t.createElement(_, { title: e.title }), e.dismissible && /* @__PURE__ */ t.createElement(N, { onClick: l })), /* @__PURE__ */ t.createElement(p, { body: e.body }), /* @__PURE__ */ t.createElement(E, null, e.secondary_button && /* @__PURE__ */ t.createElement(f, { text: e.secondary_button.text, action: e.secondary_button.action, onClick: (d) => {
76
- if (c) {
78
+ colorMode: t = "light",
79
+ onOpenChange: l,
80
+ onDismiss: r,
81
+ onButtonClick: o,
82
+ onImageClick: s
83
+ }) => /* @__PURE__ */ a.createElement(u, { onOpenChange: l }, /* @__PURE__ */ a.createElement(y, null), /* @__PURE__ */ a.createElement(_, { "data-knock-color-mode": t, onPointerDownOutside: r }, /* @__PURE__ */ a.createElement(M, null, /* @__PURE__ */ a.createElement(p, { title: e.title }), e.dismissible && /* @__PURE__ */ a.createElement(w, { onClick: r })), /* @__PURE__ */ a.createElement(E, { body: e.body }), e.image && /* @__PURE__ */ a.createElement("a", { href: v(e.image.action) ? e.image.action : void 0, target: "_blank" }, /* @__PURE__ */ a.createElement(g, { src: e.image.url, alt: e.image.alt, onClick: (m) => {
84
+ s && s(m, e.image);
85
+ } })), (e.primary_button || e.secondary_button) && /* @__PURE__ */ a.createElement(k, null, e.secondary_button && /* @__PURE__ */ a.createElement(N, { text: e.secondary_button.text, action: e.secondary_button.action, onClick: (m) => {
86
+ if (o) {
77
87
  const {
78
- text: r,
79
- action: m
88
+ text: i,
89
+ action: c
80
90
  } = e.secondary_button;
81
- c(d, {
91
+ o(m, {
82
92
  name: "secondary_button",
83
- text: r,
84
- action: m
93
+ text: i,
94
+ action: c
85
95
  });
86
96
  }
87
- } }), e.primary_button && /* @__PURE__ */ t.createElement(k, { text: e.primary_button.text, action: e.primary_button.action, onClick: (d) => {
88
- if (c) {
97
+ } }), e.primary_button && /* @__PURE__ */ a.createElement(f, { text: e.primary_button.text, action: e.primary_button.action, onClick: (m) => {
98
+ if (o) {
89
99
  const {
90
- text: r,
91
- action: m
100
+ text: i,
101
+ action: c
92
102
  } = e.primary_button;
93
- c(d, {
103
+ o(m, {
94
104
  name: "primary_button",
95
- text: r,
96
- action: m
105
+ text: i,
106
+ action: c
97
107
  });
98
108
  }
99
109
  } }))));
100
- g.displayName = "ModalView.Default";
101
- const v = ({
110
+ b.displayName = "ModalView.Default";
111
+ const A = ({
102
112
  guideKey: e,
103
- onButtonClick: a
113
+ onButtonClick: t,
114
+ onImageClick: l
104
115
  }) => {
105
116
  const {
106
- guide: o,
107
- step: l,
108
- colorMode: c
109
- } = M({
117
+ guide: r,
118
+ step: o,
119
+ colorMode: s
120
+ } = V({
110
121
  key: e,
111
- type: V
122
+ type: x
112
123
  });
113
- return t.useEffect(() => {
114
- l && l.markAsSeen();
115
- }, [l]), !o || !l ? null : /* @__PURE__ */ t.createElement(g, { content: l.content, colorMode: c, onDismiss: () => l.markAsArchived(), onButtonClick: (d, r) => {
116
- const m = {
117
- ...r,
124
+ return a.useEffect(() => {
125
+ o && o.markAsSeen();
126
+ }, [o]), !r || !o ? null : /* @__PURE__ */ a.createElement(b, { content: o.content, colorMode: s, onDismiss: () => o.markAsArchived(), onButtonClick: (m, i) => {
127
+ const c = {
128
+ ...i,
118
129
  type: "button_click"
119
130
  };
120
- return l.markAsInteracted({
121
- metadata: m
122
- }), a ? a(d, {
123
- button: r,
124
- step: l,
125
- guide: o
126
- }) : b(r.action);
131
+ return o.markAsInteracted({
132
+ metadata: c
133
+ }), t ? t(m, {
134
+ button: i,
135
+ step: o,
136
+ guide: r
137
+ }) : h(i.action);
138
+ }, onImageClick: (m, i) => {
139
+ const c = {
140
+ ...i,
141
+ type: "image_click"
142
+ };
143
+ if (o.markAsInteracted({
144
+ metadata: c
145
+ }), l)
146
+ return l(m, {
147
+ image: i,
148
+ step: o,
149
+ guide: r
150
+ });
127
151
  } });
128
152
  };
129
- v.displayName = "Modal";
130
- const h = {};
131
- Object.assign(h, {
132
- Default: g,
133
- Root: s,
134
- Overlay: u,
135
- Content: y,
136
- Title: _,
137
- Body: p,
138
- Actions: E,
139
- PrimaryButton: k,
140
- SecondaryButton: f,
141
- Close: N
153
+ A.displayName = "Modal";
154
+ const R = {};
155
+ Object.assign(R, {
156
+ Default: b,
157
+ Root: u,
158
+ Overlay: y,
159
+ Content: _,
160
+ Title: p,
161
+ Body: E,
162
+ Img: g,
163
+ Actions: k,
164
+ PrimaryButton: f,
165
+ SecondaryButton: N,
166
+ Close: w
142
167
  });
143
168
  export {
144
- v as Modal,
145
- h as ModalView
169
+ A as Modal,
170
+ R as ModalView
146
171
  };
147
172
  //# sourceMappingURL=Modal.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Modal.mjs","sources":["../../../../../../src/modules/guide/components/Modal/Modal.tsx"],"sourcesContent":["import { ColorMode, useGuide } from \"@knocklabs/react-core\";\nimport * as Dialog from \"@radix-ui/react-dialog\";\nimport clsx from \"clsx\";\nimport React from \"react\";\n\nimport { maybeNavigateToUrlWithDelay } from \"../helpers\";\nimport {\n ButtonContent,\n TargetButton,\n TargetButtonWithGuideContext,\n} from \"../types\";\n\nimport \"./styles.css\";\n\nconst MESSAGE_TYPE = \"modal\";\n\ntype RootProps = Omit<\n React.ComponentPropsWithoutRef<typeof Dialog.Root>,\n \"modal\"\n> &\n React.PropsWithChildren<React.ComponentPropsWithRef<\"div\">>;\n\nconst Root = ({ children, onOpenChange, ...props }: RootProps) => {\n return (\n <Dialog.Root defaultOpen onOpenChange={onOpenChange} {...props}>\n <Dialog.Portal>{children}</Dialog.Portal>\n </Dialog.Root>\n );\n};\nRoot.displayName = \"ModalView.Root\";\n\ntype OverlayProps = React.ComponentPropsWithoutRef<typeof Dialog.Overlay> &\n React.ComponentPropsWithRef<\"div\">;\ntype OverlayRef = React.ElementRef<\"div\">;\n\nconst Overlay = React.forwardRef<OverlayRef, OverlayProps>(\n ({ className, ...props }, forwardedRef) => {\n return (\n <Dialog.Overlay\n className={clsx(\"knock-guide-modal__overlay\", className)}\n ref={forwardedRef}\n {...props}\n />\n );\n },\n);\nOverlay.displayName = \"ModalView.Overlay\";\n\ntype ContentProps = React.ComponentPropsWithoutRef<typeof Dialog.Content> &\n React.ComponentPropsWithRef<\"div\">;\ntype ContentRef = React.ElementRef<\"div\">;\n\nconst Content = React.forwardRef<ContentRef, ContentProps>(\n ({ children, className, ...props }, forwardedRef) => {\n return (\n <Dialog.Content\n className={clsx(\"knock-guide-modal\", className)}\n ref={forwardedRef}\n {...props}\n >\n {children}\n </Dialog.Content>\n );\n },\n);\nContent.displayName = \"ModalView.Content\";\n\nconst Header: React.FC<\n React.PropsWithChildren<React.ComponentPropsWithRef<\"div\">>\n> = ({ children, className, ...props }) => {\n return (\n <div className={clsx(\"knock-guide-modal__header\", className)} {...props}>\n {children}\n </div>\n );\n};\nHeader.displayName = \"ModalView.Header\";\n\ntype TitleProps = React.ComponentPropsWithoutRef<typeof Dialog.Title> &\n React.ComponentPropsWithRef<\"div\"> & {\n title: string;\n };\n\nconst Title = ({ title, className, ...props }: TitleProps) => {\n return (\n <Dialog.Title\n className={clsx(\"knock-guide-modal__title\", className)}\n {...props}\n >\n {title}\n </Dialog.Title>\n );\n};\nTitle.displayName = \"ModalView.Title\";\n\nconst Body: React.FC<{ body: string } & React.ComponentPropsWithRef<\"div\">> = ({\n body,\n className,\n ...props\n}) => {\n return (\n <Dialog.Description\n className={clsx(\"knock-guide-modal__body\", className)}\n dangerouslySetInnerHTML={{ __html: body }}\n {...props}\n />\n );\n};\nBody.displayName = \"ModalView.Body\";\n\nconst Actions: React.FC<\n React.PropsWithChildren<React.ComponentPropsWithRef<\"div\">>\n> = ({ children, className, ...props }) => {\n return (\n <div className={clsx(\"knock-guide-modal__actions\", className)} {...props}>\n {children}\n </div>\n );\n};\nActions.displayName = \"ModalView.Actions\";\n\nconst PrimaryButton: React.FC<\n ButtonContent & React.ComponentPropsWithRef<\"button\">\n> = ({ text, action, className, ...props }) => {\n return (\n <button className={clsx(\"knock-guide-modal__action\", className)} {...props}>\n {text}\n </button>\n );\n};\nPrimaryButton.displayName = \"ModalView.PrimaryButton\";\n\nconst SecondaryButton: React.FC<\n ButtonContent & React.ComponentPropsWithRef<\"button\">\n> = ({ text, action, className, ...props }) => {\n return (\n <button\n className={clsx(\n \"knock-guide-modal__action knock-guide-modal__action--secondary\",\n className,\n )}\n {...props}\n >\n {text}\n </button>\n );\n};\nSecondaryButton.displayName = \"ModalView.SecondaryButton\";\n\ntype CloseProps = React.ComponentPropsWithoutRef<typeof Dialog.Close> &\n React.ComponentPropsWithRef<\"button\">;\n\nconst Close = ({ className, ...props }: CloseProps) => {\n return (\n <Dialog.Close\n className={clsx(\"knock-guide-modal__close\", className)}\n {...props}\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"18\"\n height=\"18\"\n fill=\"none\"\n >\n <g fill=\"#60646C\" fillRule=\"evenodd\" clipRule=\"evenodd\">\n <path d=\"M14.03 3.97a.75.75 0 0 1 0 1.06l-9 9a.75.75 0 0 1-1.06-1.06l9-9a.75.75 0 0 1 1.06 0Z\" />\n <path d=\"M3.97 3.97a.75.75 0 0 1 1.06 0l9 9a.75.75 0 1 1-1.06 1.06l-9-9a.75.75 0 0 1 0-1.06Z\" />\n </g>\n </svg>\n </Dialog.Close>\n );\n};\nClose.displayName = \"ModalView.Close\";\n\ntype ModalContent = {\n title: string;\n body: string;\n primary_button?: ButtonContent;\n secondary_button?: ButtonContent;\n dismissible?: boolean;\n};\n\nconst DefaultView: React.FC<{\n content: ModalContent;\n colorMode?: ColorMode;\n onOpenChange?: (open: boolean) => void;\n onDismiss?: () => void;\n onButtonClick?: (e: React.MouseEvent, button: TargetButton) => void;\n}> = ({\n content,\n colorMode = \"light\",\n onOpenChange,\n onDismiss,\n onButtonClick,\n}) => {\n return (\n <Root onOpenChange={onOpenChange}>\n <Overlay />\n {/* Must pass color mode to content for css variables to be set properly */}\n <Content\n data-knock-color-mode={colorMode}\n onPointerDownOutside={onDismiss}\n >\n <Header>\n <Title title={content.title} />\n {content.dismissible && <Close onClick={onDismiss} />}\n </Header>\n\n <Body body={content.body} />\n\n <Actions>\n {content.secondary_button && (\n <SecondaryButton\n text={content.secondary_button.text}\n action={content.secondary_button.action}\n onClick={(e) => {\n if (onButtonClick) {\n const { text, action } = content.secondary_button!;\n onButtonClick(e, { name: \"secondary_button\", text, action });\n }\n }}\n />\n )}\n {content.primary_button && (\n <PrimaryButton\n text={content.primary_button.text}\n action={content.primary_button.action}\n onClick={(e) => {\n if (onButtonClick) {\n const { text, action } = content.primary_button!;\n onButtonClick(e, { name: \"primary_button\", text, action });\n }\n }}\n />\n )}\n </Actions>\n </Content>\n </Root>\n );\n};\nDefaultView.displayName = \"ModalView.Default\";\n\ntype ModalProps = {\n guideKey?: string;\n onButtonClick?: (\n e: React.MouseEvent,\n target: TargetButtonWithGuideContext,\n ) => void;\n};\n\nexport const Modal: React.FC<ModalProps> = ({ guideKey, onButtonClick }) => {\n const { guide, step, colorMode } = useGuide({\n key: guideKey,\n type: MESSAGE_TYPE,\n });\n\n React.useEffect(() => {\n if (step) step.markAsSeen();\n }, [step]);\n\n if (!guide || !step) return null;\n\n return (\n <DefaultView\n content={step.content as ModalContent}\n colorMode={colorMode}\n onDismiss={() => step.markAsArchived()}\n onButtonClick={(e, button) => {\n const metadata = { ...button, type: \"button_click\" };\n step.markAsInteracted({ metadata });\n\n return onButtonClick\n ? onButtonClick(e, { button, step, guide })\n : maybeNavigateToUrlWithDelay(button.action);\n }}\n />\n );\n};\nModal.displayName = \"Modal\";\n\nexport const ModalView = {} as {\n Default: typeof DefaultView;\n Root: typeof Root;\n Overlay: typeof Overlay;\n Content: typeof Content;\n Title: typeof Title;\n Body: typeof Body;\n Actions: typeof Actions;\n PrimaryButton: typeof PrimaryButton;\n SecondaryButton: typeof SecondaryButton;\n Close: typeof Close;\n};\n\nObject.assign(ModalView, {\n Default: DefaultView,\n Root,\n Overlay,\n Content,\n Title,\n Body,\n Actions,\n PrimaryButton,\n SecondaryButton,\n Close,\n});\n"],"names":["MESSAGE_TYPE","Root","children","onOpenChange","props","React","Dialog","displayName","Overlay","forwardRef","className","forwardedRef","clsx","Content","Header","Title","title","Body","body","__html","Actions","PrimaryButton","text","action","SecondaryButton","Close","DefaultView","content","colorMode","onDismiss","onButtonClick","dismissible","secondary_button","e","name","primary_button","Modal","guideKey","guide","step","useGuide","key","type","useEffect","markAsSeen","markAsArchived","button","metadata","markAsInteracted","maybeNavigateToUrlWithDelay","ModalView","Object","assign","Default"],"mappings":";;;;;;AAcA,MAAMA,IAAe,SAQfC,IAAOA,CAAC;AAAA,EAAEC,UAAAA;AAAAA,EAAUC,cAAAA;AAAAA,EAAc,GAAGC;AAAiB,MAEvDC,gBAAAA,EAAA,cAAAC,EAAO,MAAP,EAAY,aAAW,IAAC,cAAAH,GAA4B,GAAIC,EAAAA,GACtDC,gBAAAA,EAAA,cAAAC,EAAO,QAAP,MAAeJ,CAAS,CAC3B;AAGJD,EAAKM,cAAc;AAMnB,MAAMC,IAAUH,EAAMI,WACpB,CAAC;AAAA,EAAEC,WAAAA;AAAAA,EAAW,GAAGN;AAAM,GAAGO,MAErBN,gBAAAA,EAAA,cAAAC,EAAO,SAAP,EACC,WAAWM,EAAK,8BAA8BF,CAAS,GACvD,KAAKC,GACL,GAAIP,EACJ,CAAA,C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AM;AAChBJ,IAAAA,OAAWK,WAAW;AAAA,EAAA,GACzB,CAACL,CAAI,CAAC,GAEL,CAACD,KAAS,CAACC,IAAa,OAGzBlC,gBAAAA,EAAA,cAAAqB,GAAA,EACC,SAASa,EAAKZ,SACd,WAAAC,GACA,WAAW,MAAMW,EAAKM,eAAe,GACrC,eAAe,CAACZ,GAAGa,MAAW;AAC5B,UAAMC,IAAW;AAAA,MAAE,GAAGD;AAAAA,MAAQJ,MAAM;AAAA,IAAe;AACnDH,WAAAA,EAAKS,iBAAiB;AAAA,MAAED,UAAAA;AAAAA,IAAAA,CAAU,GAE3BjB,IACHA,EAAcG,GAAG;AAAA,MAAEa,QAAAA;AAAAA,MAAQP,MAAAA;AAAAA,MAAMD,OAAAA;AAAAA,IAAAA,CAAO,IACxCW,EAA4BH,EAAOvB,MAAM;AAAA,EAAA,GAE/C;AAEN;AACAa,EAAM7B,cAAc;AAEb,MAAM2C,IAAY,CAAA;AAazBC,OAAOC,OAAOF,GAAW;AAAA,EACvBG,SAAS3B;AAAAA,EACTzB,MAAAA;AAAAA,EACAO,SAAAA;AAAAA,EACAK,SAAAA;AAAAA,EACAE,OAAAA;AAAAA,EACAE,MAAAA;AAAAA,EACAG,SAAAA;AAAAA,EACAC,eAAAA;AAAAA,EACAG,iBAAAA;AAAAA,EACAC,OAAAA;AACF,CAAC;"}
1
+ {"version":3,"file":"Modal.mjs","sources":["../../../../../../src/modules/guide/components/Modal/Modal.tsx"],"sourcesContent":["import { ColorMode, useGuide } from \"@knocklabs/react-core\";\nimport * as Dialog from \"@radix-ui/react-dialog\";\nimport clsx from \"clsx\";\nimport React from \"react\";\n\nimport { isValidHttpUrl, maybeNavigateToUrlWithDelay } from \"../helpers\";\nimport {\n ButtonContent,\n ImageContent,\n TargetButton,\n TargetButtonWithGuide,\n TargetImage,\n TargetImageWithGuide,\n} from \"../types\";\n\nimport \"./styles.css\";\n\nconst MESSAGE_TYPE = \"modal\";\n\ntype RootProps = Omit<\n React.ComponentPropsWithoutRef<typeof Dialog.Root>,\n \"modal\"\n> &\n React.PropsWithChildren<React.ComponentPropsWithRef<\"div\">>;\n\nconst Root = ({ children, onOpenChange, ...props }: RootProps) => {\n return (\n <Dialog.Root defaultOpen onOpenChange={onOpenChange} {...props}>\n <Dialog.Portal>{children}</Dialog.Portal>\n </Dialog.Root>\n );\n};\nRoot.displayName = \"ModalView.Root\";\n\ntype OverlayProps = React.ComponentPropsWithoutRef<typeof Dialog.Overlay> &\n React.ComponentPropsWithRef<\"div\">;\ntype OverlayRef = React.ElementRef<\"div\">;\n\nconst Overlay = React.forwardRef<OverlayRef, OverlayProps>(\n ({ className, ...props }, forwardedRef) => {\n return (\n <Dialog.Overlay\n className={clsx(\"knock-guide-modal__overlay\", className)}\n ref={forwardedRef}\n {...props}\n />\n );\n },\n);\nOverlay.displayName = \"ModalView.Overlay\";\n\ntype ContentProps = React.ComponentPropsWithoutRef<typeof Dialog.Content> &\n React.ComponentPropsWithRef<\"div\">;\ntype ContentRef = React.ElementRef<\"div\">;\n\nconst Content = React.forwardRef<ContentRef, ContentProps>(\n ({ children, className, ...props }, forwardedRef) => {\n return (\n <Dialog.Content\n className={clsx(\"knock-guide-modal\", className)}\n ref={forwardedRef}\n {...props}\n >\n {children}\n </Dialog.Content>\n );\n },\n);\nContent.displayName = \"ModalView.Content\";\n\nconst Header: React.FC<\n React.PropsWithChildren<React.ComponentPropsWithRef<\"div\">>\n> = ({ children, className, ...props }) => {\n return (\n <div className={clsx(\"knock-guide-modal__header\", className)} {...props}>\n {children}\n </div>\n );\n};\nHeader.displayName = \"ModalView.Header\";\n\ntype TitleProps = React.ComponentPropsWithoutRef<typeof Dialog.Title> &\n React.ComponentPropsWithRef<\"div\"> & {\n title: string;\n };\n\nconst Title = ({ title, className, ...props }: TitleProps) => {\n return (\n <Dialog.Title\n className={clsx(\"knock-guide-modal__title\", className)}\n {...props}\n >\n {title}\n </Dialog.Title>\n );\n};\nTitle.displayName = \"ModalView.Title\";\n\nconst Body: React.FC<{ body: string } & React.ComponentPropsWithRef<\"div\">> = ({\n body,\n className,\n ...props\n}) => {\n return (\n <Dialog.Description\n className={clsx(\"knock-guide-modal__body\", className)}\n dangerouslySetInnerHTML={{ __html: body }}\n {...props}\n />\n );\n};\nBody.displayName = \"ModalView.Body\";\n\nconst Img: React.FC<\n React.PropsWithChildren<React.ComponentPropsWithRef<\"img\">>\n> = ({ children, className, alt, ...props }) => {\n return (\n <img\n className={clsx(\"knock-guide-modal__img\", className)}\n alt={alt || \"\"}\n {...props}\n >\n {children}\n </img>\n );\n};\nImg.displayName = \"ModalView.Img\";\n\nconst Actions: React.FC<\n React.PropsWithChildren<React.ComponentPropsWithRef<\"div\">>\n> = ({ children, className, ...props }) => {\n return (\n <div className={clsx(\"knock-guide-modal__actions\", className)} {...props}>\n {children}\n </div>\n );\n};\nActions.displayName = \"ModalView.Actions\";\n\nconst PrimaryButton: React.FC<\n ButtonContent & React.ComponentPropsWithRef<\"button\">\n> = ({ text, action, className, ...props }) => {\n return (\n <button className={clsx(\"knock-guide-modal__action\", className)} {...props}>\n {text}\n </button>\n );\n};\nPrimaryButton.displayName = \"ModalView.PrimaryButton\";\n\nconst SecondaryButton: React.FC<\n ButtonContent & React.ComponentPropsWithRef<\"button\">\n> = ({ text, action, className, ...props }) => {\n return (\n <button\n className={clsx(\n \"knock-guide-modal__action knock-guide-modal__action--secondary\",\n className,\n )}\n {...props}\n >\n {text}\n </button>\n );\n};\nSecondaryButton.displayName = \"ModalView.SecondaryButton\";\n\ntype CloseProps = React.ComponentPropsWithoutRef<typeof Dialog.Close> &\n React.ComponentPropsWithRef<\"button\">;\n\nconst Close = ({ className, ...props }: CloseProps) => {\n return (\n <Dialog.Close\n className={clsx(\"knock-guide-modal__close\", className)}\n {...props}\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"18\"\n height=\"18\"\n fill=\"none\"\n >\n <g fill=\"#60646C\" fillRule=\"evenodd\" clipRule=\"evenodd\">\n <path d=\"M14.03 3.97a.75.75 0 0 1 0 1.06l-9 9a.75.75 0 0 1-1.06-1.06l9-9a.75.75 0 0 1 1.06 0Z\" />\n <path d=\"M3.97 3.97a.75.75 0 0 1 1.06 0l9 9a.75.75 0 1 1-1.06 1.06l-9-9a.75.75 0 0 1 0-1.06Z\" />\n </g>\n </svg>\n </Dialog.Close>\n );\n};\nClose.displayName = \"ModalView.Close\";\n\ntype ModalContent = {\n title: string;\n body: string;\n image?: ImageContent;\n primary_button?: ButtonContent;\n secondary_button?: ButtonContent;\n dismissible?: boolean;\n};\n\nconst DefaultView: React.FC<{\n content: ModalContent;\n colorMode?: ColorMode;\n onOpenChange?: (open: boolean) => void;\n onDismiss?: () => void;\n onButtonClick?: (e: React.MouseEvent, button: TargetButton) => void;\n onImageClick?: (e: React.MouseEvent, image: TargetImage) => void;\n}> = ({\n content,\n colorMode = \"light\",\n onOpenChange,\n onDismiss,\n onButtonClick,\n onImageClick,\n}) => {\n return (\n <Root onOpenChange={onOpenChange}>\n <Overlay />\n {/* Must pass color mode to content for css variables to be set properly */}\n <Content\n data-knock-color-mode={colorMode}\n onPointerDownOutside={onDismiss}\n >\n <Header>\n <Title title={content.title} />\n {content.dismissible && <Close onClick={onDismiss} />}\n </Header>\n\n <Body body={content.body} />\n\n {content.image && (\n <a\n href={\n isValidHttpUrl(content.image.action)\n ? content.image.action\n : undefined\n }\n target=\"_blank\"\n >\n <Img\n src={content.image.url}\n alt={content.image.alt}\n onClick={(e) => {\n if (onImageClick) {\n onImageClick(e, content.image!);\n }\n }}\n />\n </a>\n )}\n\n {(content.primary_button || content.secondary_button) && (\n <Actions>\n {content.secondary_button && (\n <SecondaryButton\n text={content.secondary_button.text}\n action={content.secondary_button.action}\n onClick={(e) => {\n if (onButtonClick) {\n const { text, action } = content.secondary_button!;\n onButtonClick(e, {\n name: \"secondary_button\",\n text,\n action,\n });\n }\n }}\n />\n )}\n {content.primary_button && (\n <PrimaryButton\n text={content.primary_button.text}\n action={content.primary_button.action}\n onClick={(e) => {\n if (onButtonClick) {\n const { text, action } = content.primary_button!;\n onButtonClick(e, { name: \"primary_button\", text, action });\n }\n }}\n />\n )}\n </Actions>\n )}\n </Content>\n </Root>\n );\n};\nDefaultView.displayName = \"ModalView.Default\";\n\ntype ModalProps = {\n guideKey?: string;\n onButtonClick?: (e: React.MouseEvent, target: TargetButtonWithGuide) => void;\n onImageClick?: (e: React.MouseEvent, target: TargetImageWithGuide) => void;\n};\n\nexport const Modal: React.FC<ModalProps> = ({\n guideKey,\n onButtonClick,\n onImageClick,\n}) => {\n const { guide, step, colorMode } = useGuide({\n key: guideKey,\n type: MESSAGE_TYPE,\n });\n\n React.useEffect(() => {\n if (step) step.markAsSeen();\n }, [step]);\n\n if (!guide || !step) return null;\n\n return (\n <DefaultView\n content={step.content as ModalContent}\n colorMode={colorMode}\n onDismiss={() => step.markAsArchived()}\n onButtonClick={(e, button) => {\n const metadata = { ...button, type: \"button_click\" };\n step.markAsInteracted({ metadata });\n\n return onButtonClick\n ? onButtonClick(e, { button, step, guide })\n : maybeNavigateToUrlWithDelay(button.action);\n }}\n onImageClick={(e, image) => {\n const metadata = { ...image, type: \"image_click\" };\n step.markAsInteracted({ metadata });\n\n if (onImageClick) {\n return onImageClick(e, { image, step, guide });\n }\n }}\n />\n );\n};\nModal.displayName = \"Modal\";\n\nexport const ModalView = {} as {\n Default: typeof DefaultView;\n Root: typeof Root;\n Overlay: typeof Overlay;\n Content: typeof Content;\n Title: typeof Title;\n Body: typeof Body;\n Img: typeof Img;\n Actions: typeof Actions;\n PrimaryButton: typeof PrimaryButton;\n SecondaryButton: typeof SecondaryButton;\n Close: typeof Close;\n};\n\nObject.assign(ModalView, {\n Default: DefaultView,\n Root,\n Overlay,\n Content,\n Title,\n Body,\n Img,\n Actions,\n PrimaryButton,\n SecondaryButton,\n Close,\n});\n"],"names":["MESSAGE_TYPE","Root","children","onOpenChange","props","React","Dialog","displayName","Overlay","forwardRef","className","forwardedRef","clsx","Content","Header","Title","title","Body","body","__html","Img","alt","Actions","PrimaryButton","text","action","SecondaryButton","Close","DefaultView","content","colorMode","onDismiss","onButtonClick","onImageClick","dismissible","image","isValidHttpUrl","undefined","url","e","primary_button","secondary_button","name","Modal","guideKey","guide","step","useGuide","key","type","useEffect","markAsSeen","markAsArchived","button","metadata","markAsInteracted","maybeNavigateToUrlWithDelay","ModalView","Object","assign","Default"],"mappings":";;;;;;AAiBA,MAAMA,IAAe,SAQfC,IAAOA,CAAC;AAAA,EAAEC,UAAAA;AAAAA,EAAUC,cAAAA;AAAAA,EAAc,GAAGC;AAAiB,MAEvDC,gBAAAA,EAAA,cAAAC,EAAO,MAAP,EAAY,aAAW,IAAC,cAAAH,GAA4B,GAAIC,EAAAA,GACtDC,gBAAAA,EAAA,cAAAC,EAAO,QAAP,MAAeJ,CAAS,CAC3B;AAGJD,EAAKM,cAAc;AAMnB,MAAMC,IAAUH,EAAMI,WACpB,CAAC;AAAA,EAAEC,WAAAA;AAAAA,EAAW,GAAGN;AAAM,GAAGO,MAErBN,gBAAAA,EAAA,cAAAC,EAAO,SAAP,EACC,WAAWM,EAAK,8BAA8BF,CAAS,GACvD,KAAKC,GACL,GAAIP,EACJ,CAAA,CAGR;AACAI,EAAQD,cAAc;AAMtB,MAAMM,IAAUR,EAAMI,WACpB,CAAC;AAAA,EAAEP,UAAAA;AAAAA,EAAUQ,WAAAA;AAAAA,EAAW,GAAGN;AAAM,GAAGO,MAE/BN,gBAAAA,EAAA,cAAAC,EAAO,SAAP,EACC,WAAWM,EAAK,qBAAqBF,CAAS,GAC9C,KAAKC,GACDP,GAAAA,KAEHF,CACH,CAGN;AACAW,EAAQN,cAAc;AAEtB,MAAMO,IAEFA,CAAC;AAAA,EAAEZ,UAAAA;AAAAA,EAAUQ,WAAAA;AAAAA,EAAW,GAAGN;AAAM,MAEjCC,gBAAAA,EAAA,cAAC,SAAI,WAAWO,EAAK,6BAA6BF,CAAS,GAAG,GAAIN,EAAAA,GAC/DF,CACH;AAGJY,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ACAG,KAAAA;AAAAA,EACAE,SAAAA;AAAAA,EACAC,eAAAA;AAAAA,EACAG,iBAAAA;AAAAA,EACAC,OAAAA;AACF,CAAC;"}
@@ -10,6 +10,7 @@ const r = (o) => {
10
10
  window != null && window.location && r(o) && setTimeout(() => window.location.assign(o), t);
11
11
  };
12
12
  export {
13
+ r as isValidHttpUrl,
13
14
  i as maybeNavigateToUrlWithDelay
14
15
  };
15
16
  //# sourceMappingURL=helpers.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.mjs","sources":["../../../../../src/modules/guide/components/helpers.ts"],"sourcesContent":["const isValidHttpUrl = (input: string) => {\n let url;\n\n try {\n url = new URL(input);\n } catch (_) {\n return false;\n }\n\n return url.protocol === \"http:\" || url.protocol === \"https:\";\n};\n\nexport const maybeNavigateToUrlWithDelay = (\n url: string,\n delay: number = 200,\n) => {\n if (!window?.location) return;\n if (!isValidHttpUrl(url)) return;\n\n setTimeout(() => window.location.assign(url), delay);\n};\n"],"names":["isValidHttpUrl","input","url","URL","protocol","maybeNavigateToUrlWithDelay","delay","window","location","setTimeout","assign"],"mappings":"AAAA,MAAMA,IAAiBA,CAACC,MAAkB;AACpCC,MAAAA;AAEA,MAAA;AACI,IAAAA,IAAA,IAAIC,IAAIF,CAAK;AAAA,UACT;AACH,WAAA;AAAA,EAAA;AAGT,SAAOC,EAAIE,aAAa,WAAWF,EAAIE,aAAa;AACtD,GAEaC,IAA8BA,CACzCH,GACAI,IAAgB,QACb;AACC,EAACC,yBAAQC,YACRR,EAAeE,CAAG,KAEvBO,WAAW,MAAMF,OAAOC,SAASE,OAAOR,CAAG,GAAGI,CAAK;AACrD;"}
1
+ {"version":3,"file":"helpers.mjs","sources":["../../../../../src/modules/guide/components/helpers.ts"],"sourcesContent":["export const isValidHttpUrl = (input: string) => {\n let url;\n\n try {\n url = new URL(input);\n } catch (_) {\n return false;\n }\n\n return url.protocol === \"http:\" || url.protocol === \"https:\";\n};\n\nexport const maybeNavigateToUrlWithDelay = (\n url: string,\n delay: number = 200,\n) => {\n if (!window?.location) return;\n if (!isValidHttpUrl(url)) return;\n\n setTimeout(() => window.location.assign(url), delay);\n};\n"],"names":["isValidHttpUrl","input","url","URL","protocol","maybeNavigateToUrlWithDelay","delay","window","location","setTimeout","assign"],"mappings":"AAAaA,MAAAA,IAAiBA,CAACC,MAAkB;AAC3CC,MAAAA;AAEA,MAAA;AACI,IAAAA,IAAA,IAAIC,IAAIF,CAAK;AAAA,UACT;AACH,WAAA;AAAA,EAAA;AAGT,SAAOC,EAAIE,aAAa,WAAWF,EAAIE,aAAa;AACtD,GAEaC,IAA8BA,CACzCH,GACAI,IAAgB,QACb;AACC,EAACC,yBAAQC,YACRR,EAAeE,CAAG,KAEvBO,WAAW,MAAMF,OAAOC,SAASE,OAAOR,CAAG,GAAGI,CAAK;AACrD;"}