@purpurds/cta-link 4.1.1 → 4.3.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,4 +1,8 @@
1
1
  import React, { AnchorHTMLAttributes } from "react";
2
2
  import { ActionProps } from "@purpurds/action";
3
- export declare const CtaLink: ({ children, className, ["data-testid"]: dataTestid, fullWidth, iconOnly, size, variant, ...props }: ActionProps & AnchorHTMLAttributes<HTMLAnchorElement>) => React.JSX.Element;
3
+ export declare const ctaLinkIcons: readonly ["forward", "external", "back", "phone"];
4
+ export type CtaLinkIcon = typeof ctaLinkIcons[number];
5
+ export declare const CtaLink: ({ children, className, ["data-testid"]: dataTestid, fullWidth, iconOnly, size, variant, icon, ...props }: ActionProps & React.AnchorHTMLAttributes<HTMLAnchorElement> & {
6
+ icon?: "forward" | "external" | "back" | "phone" | undefined;
7
+ }) => React.JSX.Element;
4
8
  //# sourceMappingURL=cta-link.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cta-link.d.ts","sourceRoot":"","sources":["../src/cta-link.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,EAAE,WAAW,EAAQ,MAAM,kBAAkB,CAAC;AAQrD,eAAO,MAAM,OAAO,uGASjB,WAAW,GAAG,qBAAqB,iBAAiB,CAAC,sBAuBvD,CAAC"}
1
+ {"version":3,"file":"cta-link.d.ts","sourceRoot":"","sources":["../src/cta-link.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,EAAE,WAAW,EAAQ,MAAM,kBAAkB,CAAC;AAQrD,eAAO,MAAM,YAAY,mDAAoD,CAAC;AAE9E,MAAM,MAAM,WAAW,GAAG,OAAO,YAAY,CAAC,MAAM,CAAC,CAAC;AAStD,eAAO,MAAM,OAAO;;uBAuCnB,CAAC"}
@@ -1,13 +1,13 @@
1
- import { jsx as _, jsxs as g } from "react/jsx-runtime";
2
- const c = {
1
+ import { jsx as c, jsxs as y } from "react/jsx-runtime";
2
+ const o = {
3
3
  SM: "sm",
4
4
  MD: "md",
5
5
  LG: "lg"
6
6
  };
7
- function y(t) {
7
+ function x(t) {
8
8
  return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
9
9
  }
10
- var f = { exports: {} };
10
+ var g = { exports: {} };
11
11
  /*!
12
12
  Copyright (c) 2018 Jed Watson.
13
13
  Licensed under the MIT License (MIT), see
@@ -15,36 +15,36 @@ var f = { exports: {} };
15
15
  */
16
16
  (function(t) {
17
17
  (function() {
18
- var a = {}.hasOwnProperty;
19
- function u() {
18
+ var l = {}.hasOwnProperty;
19
+ function a() {
20
20
  for (var r = "", e = 0; e < arguments.length; e++) {
21
21
  var n = arguments[e];
22
- n && (r = i(r, p.call(this, n)));
22
+ n && (r = u(r, i.call(this, n)));
23
23
  }
24
24
  return r;
25
25
  }
26
- function p(r) {
26
+ function i(r) {
27
27
  if (typeof r == "string" || typeof r == "number")
28
28
  return this && this[r] || r;
29
29
  if (typeof r != "object")
30
30
  return "";
31
31
  if (Array.isArray(r))
32
- return u.apply(this, r);
32
+ return a.apply(this, r);
33
33
  if (r.toString !== Object.prototype.toString && !r.toString.toString().includes("[native code]"))
34
34
  return r.toString();
35
35
  var e = "";
36
36
  for (var n in r)
37
- a.call(r, n) && r[n] && (e = i(e, this && this[n] || n));
37
+ l.call(r, n) && r[n] && (e = u(e, this && this[n] || n));
38
38
  return e;
39
39
  }
40
- function i(r, e) {
40
+ function u(r, e) {
41
41
  return e ? r ? r + " " + e : r + e : r;
42
42
  }
43
- t.exports ? (u.default = u, t.exports = u) : window.classNames = u;
43
+ t.exports ? (a.default = a, t.exports = a) : window.classNames = a;
44
44
  })();
45
- })(f);
46
- var k = f.exports;
47
- const h = /* @__PURE__ */ y(k), x = {
45
+ })(g);
46
+ var k = g.exports;
47
+ const b = /* @__PURE__ */ x(k), $ = {
48
48
  "purpur-icon": "_purpur-icon_8u1lq_1",
49
49
  "purpur-icon--xxs": "_purpur-icon--xxs_8u1lq_4",
50
50
  "purpur-icon--xs": "_purpur-icon--xs_8u1lq_8",
@@ -52,35 +52,50 @@ const h = /* @__PURE__ */ y(k), x = {
52
52
  "purpur-icon--md": "_purpur-icon--md_8u1lq_16",
53
53
  "purpur-icon--lg": "_purpur-icon--lg_8u1lq_20",
54
54
  "purpur-icon--xl": "_purpur-icon--xl_8u1lq_24"
55
- }, b = {
55
+ }, M = {
56
+ name: "arrow-left",
57
+ 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
+ keywords: ["arrow-left"],
59
+ category: "utility"
60
+ }, S = {
56
61
  name: "arrow-right",
57
62
  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>',
58
63
  keywords: ["arrow-right"],
59
64
  category: "utility"
60
- }, w = h.bind(x), o = "purpur-icon", $ = "md", S = (t) => t.filter((a) => Object.keys(a).length >= 1).map((a) => `${a.name}="${a.value}"`).join(" "), j = ({ content: t = "", title: a } = {}) => {
61
- const u = [
65
+ }, j = {
66
+ name: "external",
67
+ 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
+ keywords: ["external"],
69
+ category: "media"
70
+ }, L = {
71
+ name: "phone",
72
+ 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
+ keywords: ["phone"],
74
+ category: "device"
75
+ }, O = b.bind($), _ = "purpur-icon", C = "md", q = (t) => t.filter((l) => Object.keys(l).length >= 1).map((l) => `${l.name}="${l.value}"`).join(" "), N = ({ content: t = "", title: l } = {}) => {
76
+ const a = [
62
77
  { name: "xmlns", value: "http://www.w3.org/2000/svg" },
63
78
  { name: "fill", value: "currentColor" },
64
79
  { name: "viewBox", value: "0 0 24 24" },
65
- a ? { name: "role", value: "img" } : { name: "aria-hidden", value: "true" }
66
- ], p = a ? `<title>${a}</title>` : "";
67
- return `<svg ${S(u)}>${p}${t}</svg>`;
68
- }, O = (t) => t.replace(/<(\/?)svg([^>]*)>/g, "").trim(), M = ({
80
+ l ? { name: "role", value: "img" } : { name: "aria-hidden", value: "true" }
81
+ ], i = l ? `<title>${l}</title>` : "";
82
+ return `<svg ${q(a)}>${i}${t}</svg>`;
83
+ }, A = (t) => t.replace(/<(\/?)svg([^>]*)>/g, "").trim(), f = ({
69
84
  ["data-testid"]: t,
70
- svg: a,
71
- allyTitle: u,
72
- className: p = "",
73
- size: i = $,
85
+ svg: l,
86
+ allyTitle: a,
87
+ className: i = "",
88
+ size: u = C,
74
89
  ...r
75
90
  }) => {
76
- const e = j({
77
- content: O(a.svg),
78
- title: u
79
- }), n = w(p, o, `${o}--${i}`);
80
- return /* @__PURE__ */ _(
91
+ const e = N({
92
+ content: A(l.svg),
93
+ title: a
94
+ }), n = O(i, _, `${_}--${u}`);
95
+ return /* @__PURE__ */ c(
81
96
  "span",
82
97
  {
83
- "aria-label": u,
98
+ "aria-label": a,
84
99
  className: n,
85
100
  "data-testid": t,
86
101
  dangerouslySetInnerHTML: { __html: e },
@@ -88,10 +103,10 @@ const h = /* @__PURE__ */ y(k), x = {
88
103
  }
89
104
  );
90
105
  };
91
- function q(t) {
106
+ function H(t) {
92
107
  return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
93
108
  }
94
- var d = { exports: {} };
109
+ var m = { exports: {} };
95
110
  /*!
96
111
  Copyright (c) 2018 Jed Watson.
97
112
  Licensed under the MIT License (MIT), see
@@ -99,36 +114,36 @@ var d = { exports: {} };
99
114
  */
100
115
  (function(t) {
101
116
  (function() {
102
- var a = {}.hasOwnProperty;
103
- function u() {
117
+ var l = {}.hasOwnProperty;
118
+ function a() {
104
119
  for (var r = "", e = 0; e < arguments.length; e++) {
105
120
  var n = arguments[e];
106
- n && (r = i(r, p(n)));
121
+ n && (r = u(r, i(n)));
107
122
  }
108
123
  return r;
109
124
  }
110
- function p(r) {
125
+ function i(r) {
111
126
  if (typeof r == "string" || typeof r == "number")
112
127
  return r;
113
128
  if (typeof r != "object")
114
129
  return "";
115
130
  if (Array.isArray(r))
116
- return u.apply(null, r);
131
+ return a.apply(null, r);
117
132
  if (r.toString !== Object.prototype.toString && !r.toString.toString().includes("[native code]"))
118
133
  return r.toString();
119
134
  var e = "";
120
135
  for (var n in r)
121
- a.call(r, n) && r[n] && (e = i(e, n));
136
+ l.call(r, n) && r[n] && (e = u(e, n));
122
137
  return e;
123
138
  }
124
- function i(r, e) {
139
+ function u(r, e) {
125
140
  return e ? r ? r + " " + e : r + e : r;
126
141
  }
127
- t.exports ? (u.default = u, t.exports = u) : window.classNames = u;
142
+ t.exports ? (a.default = a, t.exports = a) : window.classNames = a;
128
143
  })();
129
- })(d);
130
- var N = d.exports;
131
- const A = /* @__PURE__ */ q(N), l = {
144
+ })(m);
145
+ var V = m.exports;
146
+ const B = /* @__PURE__ */ H(V), s = {
132
147
  "purpur-cta-link": "_purpur-cta-link_e7abc_1",
133
148
  "purpur-cta-link--sm": "_purpur-cta-link--sm_e7abc_33",
134
149
  "purpur-cta-link--icon-only": "_purpur-cta-link--icon-only_e7abc_36",
@@ -142,36 +157,43 @@ const A = /* @__PURE__ */ q(N), l = {
142
157
  "purpur-cta-link--secondary-negative": "_purpur-cta-link--secondary-negative_e7abc_87",
143
158
  "purpur-cta-link--expressive": "_purpur-cta-link--expressive_e7abc_98",
144
159
  "purpur-cta-link--expressive-negative": "_purpur-cta-link--expressive-negative_e7abc_108"
145
- }, s = "purpur-cta-link", C = ({
160
+ }, p = "purpur-cta-link", D = ["forward", "external", "back", "phone"], P = {
161
+ forward: S,
162
+ external: j,
163
+ back: M,
164
+ phone: L
165
+ }, I = ({
146
166
  children: t,
147
- className: a,
148
- ["data-testid"]: u,
149
- fullWidth: p = !1,
150
- iconOnly: i,
151
- size: r = c.MD,
167
+ className: l,
168
+ ["data-testid"]: a,
169
+ fullWidth: i = !1,
170
+ iconOnly: u,
171
+ size: r = o.MD,
152
172
  variant: e,
153
- ...n
173
+ icon: n = "forward",
174
+ ...d
154
175
  }) => {
155
- const v = A(
176
+ const w = B(
156
177
  [
157
- a,
158
- l[s],
159
- l[`${s}--${e}`],
160
- l[`${s}--${r}`]
178
+ l,
179
+ s[p],
180
+ s[`${p}--${e}`],
181
+ s[`${p}--${r}`]
161
182
  ],
162
183
  {
163
- [l[`${s}--icon-only`]]: i,
164
- [l[`${s}--negative`]]: e.endsWith("negative"),
165
- [l[`${s}--full-width`]]: p
184
+ [s[`${p}--icon-only`]]: u,
185
+ [s[`${p}--negative`]]: e.endsWith("negative"),
186
+ [s[`${p}--full-width`]]: i
166
187
  }
167
- ), m = n.href ? "a" : "span";
168
- return /* @__PURE__ */ g(m, { className: v, "data-testid": u, ...n, children: [
169
- t && !i && t,
170
- " ",
171
- /* @__PURE__ */ _(M, { svg: b, size: r === c.LG ? "sm" : "xs" })
188
+ ), h = d.href ? "a" : "span", v = P[n];
189
+ return /* @__PURE__ */ y(h, { className: w, "data-testid": a, ...d, children: [
190
+ (n === "back" || n === "phone") && /* @__PURE__ */ c(f, { svg: v, size: r === o.LG ? "sm" : "xs" }),
191
+ !u && t,
192
+ (n === "forward" || n === "external") && /* @__PURE__ */ c(f, { svg: v, size: r === o.LG ? "sm" : "xs" })
172
193
  ] });
173
194
  };
174
195
  export {
175
- C as CtaLink
196
+ I as CtaLink,
197
+ D as ctaLinkIcons
176
198
  };
177
199
  //# sourceMappingURL=cta-link.es.js.map