@purpurds/cta-link 5.4.3 → 5.6.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.
@@ -1,9 +1,79 @@
1
1
  import { ActionProps } from '@purpurds/action';
2
- import { default as React, AnchorHTMLAttributes } from 'react';
2
+ import { default as React, AnchorHTMLAttributes, ForwardedRef, HTMLAttributes } from 'react';
3
3
 
4
4
  export declare const ctaLinkIcons: readonly ["forward", "external", "back", "phone"];
5
5
  export type CtaLinkIcon = (typeof ctaLinkIcons)[number];
6
- export declare const CtaLink: ({ children, className, ["data-testid"]: dataTestid, fullWidth, iconOnly, negative, size, variant, icon, ...props }: ActionProps & React.AnchorHTMLAttributes<HTMLAnchorElement> & {
6
+ type DefaultProps = ActionProps & {
7
+ icon?: CtaLinkIcon;
8
+ };
9
+ type AnchorProps = DefaultProps & {
10
+ href: string;
11
+ ref?: ForwardedRef<HTMLAnchorElement>;
12
+ } & AnchorHTMLAttributes<HTMLAnchorElement>;
13
+ type SpanProps = DefaultProps & {
14
+ ref?: ForwardedRef<HTMLSpanElement>;
15
+ } & HTMLAttributes<HTMLSpanElement>;
16
+ export type CtaLinkProps = AnchorProps | SpanProps;
17
+ export declare const CtaLink: React.ForwardRefExoticComponent<(Omit<{
18
+ "data-testid"?: string | undefined;
19
+ children?: React.ReactNode;
20
+ className?: string | undefined;
21
+ fullWidth?: boolean | undefined;
22
+ negative?: boolean | undefined;
23
+ size?: import('@purpurds/action').Size | undefined;
24
+ variant: import('@purpurds/action').Variant;
25
+ } & {
26
+ iconOnly: boolean;
27
+ "aria-label": string;
28
+ } & Partial<Record<never, never>> & {
7
29
  icon?: "forward" | "external" | "back" | "phone" | undefined;
8
- }) => React.JSX.Element;
30
+ } & {
31
+ href: string;
32
+ ref?: React.ForwardedRef<HTMLAnchorElement> | undefined;
33
+ } & React.AnchorHTMLAttributes<HTMLAnchorElement>, "ref"> | Omit<{
34
+ "data-testid"?: string | undefined;
35
+ children?: React.ReactNode;
36
+ className?: string | undefined;
37
+ fullWidth?: boolean | undefined;
38
+ negative?: boolean | undefined;
39
+ size?: import('@purpurds/action').Size | undefined;
40
+ variant: import('@purpurds/action').Variant;
41
+ } & {
42
+ "aria-label"?: string | undefined;
43
+ } & Partial<Record<"iconOnly", never>> & {
44
+ icon?: "forward" | "external" | "back" | "phone" | undefined;
45
+ } & {
46
+ href: string;
47
+ ref?: React.ForwardedRef<HTMLAnchorElement> | undefined;
48
+ } & React.AnchorHTMLAttributes<HTMLAnchorElement>, "ref"> | Omit<{
49
+ "data-testid"?: string | undefined;
50
+ children?: React.ReactNode;
51
+ className?: string | undefined;
52
+ fullWidth?: boolean | undefined;
53
+ negative?: boolean | undefined;
54
+ size?: import('@purpurds/action').Size | undefined;
55
+ variant: import('@purpurds/action').Variant;
56
+ } & {
57
+ iconOnly: boolean;
58
+ "aria-label": string;
59
+ } & Partial<Record<never, never>> & {
60
+ icon?: "forward" | "external" | "back" | "phone" | undefined;
61
+ } & {
62
+ ref?: React.ForwardedRef<HTMLSpanElement> | undefined;
63
+ } & React.HTMLAttributes<HTMLSpanElement>, "ref"> | Omit<{
64
+ "data-testid"?: string | undefined;
65
+ children?: React.ReactNode;
66
+ className?: string | undefined;
67
+ fullWidth?: boolean | undefined;
68
+ negative?: boolean | undefined;
69
+ size?: import('@purpurds/action').Size | undefined;
70
+ variant: import('@purpurds/action').Variant;
71
+ } & {
72
+ "aria-label"?: string | undefined;
73
+ } & Partial<Record<"iconOnly", never>> & {
74
+ icon?: "forward" | "external" | "back" | "phone" | undefined;
75
+ } & {
76
+ ref?: React.ForwardedRef<HTMLSpanElement> | undefined;
77
+ } & React.HTMLAttributes<HTMLSpanElement>, "ref">) & React.RefAttributes<HTMLAnchorElement | HTMLSpanElement>>;
78
+ export {};
9
79
  //# sourceMappingURL=cta-link.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cta-link.d.ts","sourceRoot":"","sources":["../src/cta-link.tsx"],"names":[],"mappings":"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react/jsx-runtime";
2
- const c = {
1
+ import { jsx as o, jsxs as k, Fragment as b } from "react/jsx-runtime";
2
+ import { forwardRef as $ } from "react";
3
+ const d = {
3
4
  SM: "sm",
4
5
  MD: "md",
5
6
  LG: "lg"
6
7
  };
7
- function k(e) {
8
+ function M(e) {
8
9
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
9
10
  }
10
- var f = { exports: {} };
11
+ var w = { exports: {} };
11
12
  /*!
12
13
  Copyright (c) 2018 Jed Watson.
13
14
  Licensed under the MIT License (MIT), see
@@ -19,11 +20,11 @@ var f = { exports: {} };
19
20
  function a() {
20
21
  for (var r = "", t = 0; t < arguments.length; t++) {
21
22
  var n = arguments[t];
22
- n && (r = u(r, i.call(this, n)));
23
+ n && (r = i(r, u.call(this, n)));
23
24
  }
24
25
  return r;
25
26
  }
26
- function i(r) {
27
+ function u(r) {
27
28
  if (typeof r == "string" || typeof r == "number")
28
29
  return this && this[r] || r;
29
30
  if (typeof r != "object")
@@ -34,17 +35,17 @@ var f = { exports: {} };
34
35
  return r.toString();
35
36
  var t = "";
36
37
  for (var n in r)
37
- l.call(r, n) && r[n] && (t = u(t, this && this[n] || n));
38
+ l.call(r, n) && r[n] && (t = i(t, this && this[n] || n));
38
39
  return t;
39
40
  }
40
- function u(r, t) {
41
+ function i(r, t) {
41
42
  return t ? r ? r + " " + t : r + t : r;
42
43
  }
43
44
  e.exports ? (a.default = a, e.exports = a) : window.classNames = a;
44
45
  })();
45
- })(f);
46
- var b = f.exports;
47
- const $ = /* @__PURE__ */ k(b), M = {
46
+ })(w);
47
+ var S = w.exports;
48
+ const j = /* @__PURE__ */ M(S), L = {
48
49
  "purpur-icon": "_purpur-icon_8u1lq_1",
49
50
  "purpur-icon--xxs": "_purpur-icon--xxs_8u1lq_4",
50
51
  "purpur-icon--xs": "_purpur-icon--xs_8u1lq_8",
@@ -52,47 +53,47 @@ const $ = /* @__PURE__ */ k(b), M = {
52
53
  "purpur-icon--md": "_purpur-icon--md_8u1lq_16",
53
54
  "purpur-icon--lg": "_purpur-icon--lg_8u1lq_20",
54
55
  "purpur-icon--xl": "_purpur-icon--xl_8u1lq_24"
55
- }, S = {
56
+ }, O = {
56
57
  name: "arrow-left",
57
58
  svg: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path fill-rule="evenodd" d="M3.1 12a.9.9 0 0 1 .264-.636l5.5-5.5a.9.9 0 0 1 1.272 1.272L6.173 11.1H20a.9.9 0 0 1 0 1.8H6.173l3.963 3.964a.9.9 0 1 1-1.272 1.272l-5.5-5.5A.9.9 0 0 1 3.1 12Z" clip-rule="evenodd"/></svg>',
58
59
  keywords: ["arrow-left"],
59
60
  category: "utility"
60
- }, j = {
61
+ }, C = {
61
62
  name: "arrow-right",
62
63
  svg: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path fill-rule="evenodd" d="M20.9 12a.9.9 0 0 1-.264.636l-5.5 5.5a.9.9 0 0 1-1.272-1.272l3.963-3.964H4a.9.9 0 0 1 0-1.8h13.827l-3.963-3.964a.9.9 0 1 1 1.272-1.272l5.5 5.5A.9.9 0 0 1 20.9 12Z" clip-rule="evenodd"/></svg>',
63
64
  keywords: ["arrow-right"],
64
65
  category: "utility"
65
- }, L = {
66
+ }, q = {
66
67
  name: "external",
67
68
  svg: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path fill-rule="evenodd" d="M15 3.4a.9.9 0 1 1 0-1.8h6.5a.9.9 0 0 1 .9.9V9a.9.9 0 1 1-1.8 0V4.673l-7.964 7.963a.9.9 0 1 1-1.272-1.272L19.327 3.4H15ZM1.6 5c0-1.05.85-1.9 1.9-1.9h6a.9.9 0 0 1 0 1.8h-6a.1.1 0 0 0-.1.1v15.5a.1.1 0 0 0 .1.1h16a.1.1 0 0 0 .1-.1V14a.9.9 0 1 1 1.8 0v6.5a1.9 1.9 0 0 1-1.9 1.9h-16a1.9 1.9 0 0 1-1.9-1.9V5Z" clip-rule="evenodd"/></svg>',
68
69
  keywords: ["external"],
69
70
  category: "media"
70
- }, O = {
71
+ }, N = {
71
72
  name: "phone",
72
73
  svg: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path fill-rule="evenodd" d="M5.341 2.228c.75-.622 1.73-.43 2.305.145l2.783 2.783a1.9 1.9 0 0 1 0 2.687L8.843 9.43a.1.1 0 0 0 0 .142l5.586 5.585a.1.1 0 0 0 .142 0l1.585-1.585a1.9 1.9 0 0 1 2.687 0l3.5 3.5c.343.342.698 1.023.31 1.742-.346.645-1.173 1.615-3.154 2.936-1.75 1.167-3.667 1.269-5.297.903-1.61-.361-3.015-1.192-3.839-2.016a.9.9 0 0 1 1.273-1.272c.573.572 1.669 1.242 2.96 1.532 1.27.285 2.656.188 3.905-.645 1.483-.989 2.137-1.68 2.418-2.06l-3.348-3.347a.1.1 0 0 0-.142 0l-1.586 1.585a1.9 1.9 0 0 1-2.687 0l-5.585-5.585a1.9 1.9 0 0 1 0-2.688l1.585-1.585a.1.1 0 0 0 0-.142L6.41 3.682c-.447.383-1.183 1.102-2.206 2.38-.878 1.097-1.14 2.08-1.127 2.951.013.898.323 1.758.732 2.59.24.488.733 1.079 1.551 1.88.561.549 1.227 1.152 2.002 1.854.344.312.71.644 1.098 1a.9.9 0 0 1-1.215 1.327c-.367-.336-.722-.658-1.061-.965a77.443 77.443 0 0 1-2.082-1.93c-.831-.813-1.523-1.586-1.909-2.372-.456-.93-.896-2.07-.916-3.356-.02-1.314.399-2.7 1.521-4.103 1.148-1.435 1.995-2.254 2.544-2.71Z" clip-rule="evenodd"/></svg>',
73
74
  keywords: ["phone"],
74
75
  category: "device"
75
- }, C = $.bind(M), m = "purpur-icon", q = "md", N = (e) => e.filter((l) => Object.keys(l).length >= 1).map((l) => `${l.name}="${l.value}"`).join(" "), A = ({ content: e = "", title: l } = {}) => {
76
+ }, A = j.bind(L), h = "purpur-icon", I = "md", V = (e) => e.filter((l) => Object.keys(l).length >= 1).map((l) => `${l.name}="${l.value}"`).join(" "), B = ({ content: e = "", title: l } = {}) => {
76
77
  const a = [
77
78
  { name: "xmlns", value: "http://www.w3.org/2000/svg" },
78
79
  { name: "fill", value: "currentColor" },
79
80
  { name: "viewBox", value: "0 0 24 24" },
80
81
  l ? { name: "role", value: "img" } : { name: "aria-hidden", value: "true" }
81
- ], i = l ? `<title>${l}</title>` : "";
82
- return `<svg ${N(a)}>${i}${e}</svg>`;
83
- }, V = (e) => e.replace(/<(\/?)svg([^>]*)>/g, "").trim(), _ = ({
82
+ ], u = l ? `<title>${l}</title>` : "";
83
+ return `<svg ${V(a)}>${u}${e}</svg>`;
84
+ }, H = (e) => e.replace(/<(\/?)svg([^>]*)>/g, "").trim(), _ = ({
84
85
  ["data-testid"]: e,
85
86
  svg: l,
86
87
  allyTitle: a,
87
- className: i = "",
88
- size: u = q,
88
+ className: u = "",
89
+ size: i = I,
89
90
  ...r
90
91
  }) => {
91
- const t = A({
92
- content: V(l.svg),
92
+ const t = B({
93
+ content: H(l.svg),
93
94
  title: a
94
- }), n = C(i, m, `${m}--${u}`);
95
- return /* @__PURE__ */ d(
95
+ }), n = A(u, h, `${h}--${i}`);
96
+ return /* @__PURE__ */ o(
96
97
  "span",
97
98
  {
98
99
  "aria-label": a,
@@ -103,10 +104,10 @@ const $ = /* @__PURE__ */ k(b), M = {
103
104
  }
104
105
  );
105
106
  };
106
- function B(e) {
107
+ function P(e) {
107
108
  return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
108
109
  }
109
- var h = { exports: {} };
110
+ var x = { exports: {} };
110
111
  /*!
111
112
  Copyright (c) 2018 Jed Watson.
112
113
  Licensed under the MIT License (MIT), see
@@ -118,32 +119,32 @@ var h = { exports: {} };
118
119
  function a() {
119
120
  for (var r = "", t = 0; t < arguments.length; t++) {
120
121
  var n = arguments[t];
121
- n && (r = u(r, i(n)));
122
+ n && (r = i(r, u.call(this, n)));
122
123
  }
123
124
  return r;
124
125
  }
125
- function i(r) {
126
+ function u(r) {
126
127
  if (typeof r == "string" || typeof r == "number")
127
- return r;
128
+ return this && this[r] || r;
128
129
  if (typeof r != "object")
129
130
  return "";
130
131
  if (Array.isArray(r))
131
- return a.apply(null, r);
132
+ return a.apply(this, r);
132
133
  if (r.toString !== Object.prototype.toString && !r.toString.toString().includes("[native code]"))
133
134
  return r.toString();
134
135
  var t = "";
135
136
  for (var n in r)
136
- l.call(r, n) && r[n] && (t = u(t, n));
137
+ l.call(r, n) && r[n] && (t = i(t, this && this[n] || n));
137
138
  return t;
138
139
  }
139
- function u(r, t) {
140
+ function i(r, t) {
140
141
  return t ? r ? r + " " + t : r + t : r;
141
142
  }
142
143
  e.exports ? (a.default = a, e.exports = a) : window.classNames = a;
143
144
  })();
144
- })(h);
145
- var H = h.exports;
146
- const I = /* @__PURE__ */ B(H), s = {
145
+ })(x);
146
+ var Z = x.exports;
147
+ const D = /* @__PURE__ */ P(Z), E = {
147
148
  "purpur-cta-link": "_purpur-cta-link_1mhg7_1",
148
149
  "purpur-cta-link--sm": "_purpur-cta-link--sm_1mhg7_33",
149
150
  "purpur-cta-link--icon-only": "_purpur-cta-link--icon-only_1mhg7_36",
@@ -157,44 +158,50 @@ const I = /* @__PURE__ */ B(H), s = {
157
158
  "purpur-cta-link--secondary-negative": "_purpur-cta-link--secondary-negative_1mhg7_87",
158
159
  "purpur-cta-link--expressive": "_purpur-cta-link--expressive_1mhg7_98",
159
160
  "purpur-cta-link--expressive-negative": "_purpur-cta-link--expressive-negative_1mhg7_108"
160
- }, p = "purpur-cta-link", P = ["forward", "external", "back", "phone"], Z = {
161
- forward: j,
162
- external: L,
163
- back: S,
164
- phone: O
165
- }, E = ({
166
- children: e,
167
- className: l,
168
- ["data-testid"]: a,
169
- fullWidth: i = !1,
170
- iconOnly: u,
171
- negative: r = !1,
172
- size: t = c.MD,
173
- variant: n,
174
- icon: o = "forward",
175
- ...g
176
- }) => {
177
- const w = I(
178
- [
179
- l,
180
- s[p],
181
- s[`${p}--${r ? `${n}-negative` : n}`],
182
- s[`${p}--${t}`]
183
- ],
184
- {
185
- [s[`${p}--icon-only`]]: u,
186
- [s[`${p}--negative`]]: r,
187
- [s[`${p}--full-width`]]: i
188
- }
189
- ), y = g.href ? "a" : "span", v = Z[o];
190
- return /* @__PURE__ */ x(y, { className: w, "data-testid": a, ...g, children: [
191
- (o === "back" || o === "phone") && /* @__PURE__ */ d(_, { svg: v, size: t === c.LG ? "sm" : "xs" }),
192
- !u && e,
193
- (o === "forward" || o === "external") && /* @__PURE__ */ d(_, { svg: v, size: t === c.LG ? "sm" : "xs" })
194
- ] });
195
- };
161
+ }, G = D.bind(E), s = "purpur-cta-link", T = ["forward", "external", "back", "phone"], z = {
162
+ forward: C,
163
+ external: q,
164
+ back: O,
165
+ phone: N
166
+ }, K = $(
167
+ ({
168
+ children: e,
169
+ className: l,
170
+ ["data-testid"]: a,
171
+ fullWidth: u = !1,
172
+ iconOnly: i,
173
+ negative: r = !1,
174
+ size: t = d.MD,
175
+ variant: n,
176
+ icon: p = "forward",
177
+ ...c
178
+ }, g) => {
179
+ const y = G(
180
+ [
181
+ l,
182
+ s,
183
+ `${s}--${r ? `${n}-negative` : n}`,
184
+ `${s}--${t}`
185
+ ],
186
+ {
187
+ [`${s}--icon-only`]: i,
188
+ [`${s}--negative`]: r,
189
+ [`${s}--full-width`]: u
190
+ }
191
+ ), v = z[p], m = /* @__PURE__ */ k(b, { children: [
192
+ (p === "back" || p === "phone") && /* @__PURE__ */ o(_, { svg: v, size: t === d.LG ? "sm" : "xs" }),
193
+ !i && e,
194
+ (p === "forward" || p === "external") && /* @__PURE__ */ o(_, { svg: v, size: t === d.LG ? "sm" : "xs" })
195
+ ] }), f = {
196
+ ...c,
197
+ className: y,
198
+ "data-testid": a
199
+ };
200
+ return "href" in c && c.href ? /* @__PURE__ */ o("a", { ...f, ref: g, children: m }) : /* @__PURE__ */ o("span", { ...f, ref: g, children: m });
201
+ }
202
+ );
196
203
  export {
197
- E as CtaLink,
198
- P as ctaLinkIcons
204
+ K as CtaLink,
205
+ T as ctaLinkIcons
199
206
  };
200
207
  //# sourceMappingURL=cta-link.es.js.map