@protonradio/proton-ui 0.7.21 → 0.8.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.
package/dist/index.d.ts CHANGED
@@ -211,7 +211,7 @@ declare const BRAND: {
211
211
  * A customizable button component that can render as either a button or anchor element
212
212
  * @interface ButtonProps
213
213
  */
214
- export declare function Button({ variant, href, onPress, type, isDisabled, "data-testid": testId, children, }: ButtonProps): JSX_2.Element;
214
+ export declare function Button({ variant, to, target, onPress, type, isDisabled, "data-testid": testId, children, }: ButtonProps): JSX_2.Element;
215
215
 
216
216
  export declare function ButtonGroup(props: ButtonGroupProps): JSX_2.Element;
217
217
 
@@ -260,10 +260,14 @@ declare interface ButtonProps {
260
260
  * @param {boolean} isDisabled
261
261
  */
262
262
  isDisabled?: boolean;
263
- /** The URL that the button should link to. Turns the element into an `a` tag
264
- * @param {string} href
263
+ /** The URL that the button should link to. Turns the element into an `a` tag. If the URL is external, you should pass the entire URL to the `to` prop (e.g. `https://example.com`).
264
+ * @param {string} to
265
265
  */
266
- href?: string;
266
+ to?: string;
267
+ /** The target attribute for the link. Defaults to `_blank` if the URL is external.
268
+ * @param {string} target
269
+ */
270
+ target?: "_blank" | "_self" | "_parent" | "_top";
267
271
  /** Called when the button is pressed (on release, not keydown)
268
272
  * @param {(e: PressEvent) => void} onPress
269
273
  */
package/dist/index.es.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import A, { useRef as M, useCallback as X, useState as z, useContext as Y, useEffect as L, createContext as Q, useMemo as V, useLayoutEffect as Kc, createElement as bi, isValidElement as Mc, forwardRef as dt, cloneElement as Ic } from "react";
2
2
  import Cn, { flushSync as Fc, createPortal as gi } from "react-dom";
3
- import { e as W, i as Nr, h as yi, a as _c, D as en, t as El } from "./utils-Bc2wVuvD.mjs";
3
+ import { e as W, i as Nr, h as yi, a as _c, D as en, t as El } from "./utils-CJd9wFM9.mjs";
4
4
  import { THEMES as Pt, BREAKPOINTS as $i } from "./constants.es.js";
5
5
  import { transparentize as Gn, parseToRgba as Rc } from "color2k";
6
6
  import { G as ge, S as tn, W as nn, D as rn } from "./colors-Dwh4VIMR.mjs";
@@ -9255,40 +9255,42 @@ const Jh = {
9255
9255
  };
9256
9256
  function Gs({
9257
9257
  variant: t = "primary",
9258
- href: e,
9259
- onPress: n,
9260
- type: r,
9261
- isDisabled: l,
9262
- "data-testid": i,
9263
- children: o
9258
+ to: e,
9259
+ target: n,
9260
+ onPress: r,
9261
+ type: l,
9262
+ isDisabled: i,
9263
+ "data-testid": o,
9264
+ children: a
9264
9265
  }) {
9265
- const a = e ? "a" : "button", u = a !== "a" ? {} : {
9266
- target: "_blank",
9267
- href: e
9268
- }, s = M(null), { buttonProps: c } = Fn(
9266
+ const u = e ? "a" : "button", s = e && Nr(e), c = u !== "a" ? {} : {
9267
+ target: n || (s ? "_blank" : void 0),
9268
+ href: e,
9269
+ rel: s || n === "_blank" ? "noopener noreferrer" : void 0
9270
+ }, d = M(null), { buttonProps: f } = Fn(
9269
9271
  {
9270
- onPress: n,
9271
- elementType: a,
9272
- type: r || "button",
9273
- isDisabled: l
9272
+ onPress: r,
9273
+ elementType: u,
9274
+ type: l || "button",
9275
+ isDisabled: i
9274
9276
  },
9275
- s
9277
+ d
9276
9278
  );
9277
9279
  return /* @__PURE__ */ b.jsxs(
9278
- a,
9280
+ u,
9279
9281
  {
9282
+ ...f,
9280
9283
  ...c,
9281
- ...u,
9282
9284
  className: W(
9283
9285
  "proton-Button",
9284
9286
  `proton-Button--${t}`,
9285
- l && "proton-Button--disabled"
9287
+ i && "proton-Button--disabled"
9286
9288
  ),
9287
- ref: s,
9288
- "data-testid": i,
9289
+ ref: d,
9290
+ "data-testid": o,
9289
9291
  children: [
9290
- o,
9291
- e && Nr(e) && /* @__PURE__ */ b.jsx("svg", { viewBox: "0 0 512 512", width: "0.8em", height: "0.8em", children: /* @__PURE__ */ b.jsx(
9292
+ a,
9293
+ e && s && /* @__PURE__ */ b.jsx("svg", { viewBox: "0 0 512 512", width: "0.8em", height: "0.8em", children: /* @__PURE__ */ b.jsx(
9292
9294
  "path",
9293
9295
  {
9294
9296
  d: "M384 224v184a40 40 0 01-40 40H104a40 40 0 01-40-40V168a40 40 0 0140-40h167.48M336 64h112v112M224 288L440 72",