@dust-tt/sparkle 0.2.125-rc → 0.2.125

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,6 @@
1
+ /// <reference types="node" />
1
2
  import React, { ReactNode } from "react";
3
+ import type { UrlObject } from "url";
2
4
  interface CardButtonProps {
3
5
  children: ReactNode;
4
6
  variant?: "primary" | "secondary" | "tertiary";
@@ -7,7 +9,7 @@ interface CardButtonProps {
7
9
  onClick?: () => void;
8
10
  onMouseEnter?: () => void;
9
11
  onMouseLeave?: () => void;
10
- href?: string;
12
+ href?: string | UrlObject;
11
13
  target?: string;
12
14
  rel?: string;
13
15
  replace?: boolean;
@@ -1,7 +1,9 @@
1
+ /// <reference types="node" />
1
2
  import React from "react";
3
+ import type { UrlObject } from "url";
2
4
  interface TemplateItemProps {
3
5
  description: string;
4
- href: string;
6
+ href: string | UrlObject;
5
7
  id: string;
6
8
  name: string;
7
9
  visual: {
@@ -1,6 +1,8 @@
1
+ /// <reference types="node" />
1
2
  import React, { ComponentType, MouseEvent, ReactNode } from "react";
3
+ import type { UrlObject } from "url";
2
4
  export type SparkleContextLinkType = ComponentType<{
3
- href: string;
5
+ href: string | UrlObject;
4
6
  className?: string;
5
7
  children: ReactNode;
6
8
  ariaLabel?: string;
@@ -8,6 +10,8 @@ export type SparkleContextLinkType = ComponentType<{
8
10
  onClick?: (event: MouseEvent<HTMLAnchorElement>) => void;
9
11
  replace?: boolean;
10
12
  shallow?: boolean;
13
+ target?: string;
14
+ rel?: string;
11
15
  }>;
12
16
  export type SparkleContextType = {
13
17
  components: {
package/dist/cjs/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var React = require('react');
4
+ var url = require('url');
4
5
 
5
6
  function _interopNamespaceDefault(e) {
6
7
  var n = Object.create(null);
@@ -52,8 +53,9 @@ var css_248z = ".s-form-checkbox,.s-form-radio {\n -webkit-appearance: none;\n
52
53
  styleInject(css_248z);
53
54
 
54
55
  var aLink = function (_a) {
55
- var href = _a.href, className = _a.className, ariaCurrent = _a.ariaCurrent, ariaLabel = _a.ariaLabel, onClick = _a.onClick, children = _a.children;
56
- return (React.createElement("a", { href: href, className: className, "aria-current": ariaCurrent, "aria-label": ariaLabel, onClick: onClick }, children));
56
+ var href = _a.href, className = _a.className, ariaCurrent = _a.ariaCurrent, ariaLabel = _a.ariaLabel, onClick = _a.onClick, children = _a.children, target = _a.target, rel = _a.rel;
57
+ var hrefAsString = typeof href !== "string" ? url.format(href) : href;
58
+ return (React.createElement("a", { href: hrefAsString, className: className, "aria-current": ariaCurrent, "aria-label": ariaLabel, onClick: onClick, target: target, rel: rel }, children));
57
59
  };
58
60
  var noHrefLink = function (_a) {
59
61
  var className = _a.className, ariaCurrent = _a.ariaCurrent, ariaLabel = _a.ariaLabel, onClick = _a.onClick, children = _a.children;
@@ -941,10 +943,7 @@ function CardButton(_a) {
941
943
  var Link = href ? components.link : noHrefLink;
942
944
  var commonClasses = classNames("s-flex s-cursor-pointer s-transition s-duration-200", variantClasses$1[variant], sizeClasses$4[size], className);
943
945
  if (href) {
944
- if (target) {
945
- return (React.createElement("a", { href: href, target: target, rel: rel, className: commonClasses }, children));
946
- }
947
- return (React.createElement(Link, { href: href, className: commonClasses, replace: replace, shallow: shallow }, children));
946
+ return (React.createElement(Link, { href: href, className: commonClasses, replace: replace, shallow: shallow, target: target, rel: rel }, children));
948
947
  }
949
948
  else {
950
949
  return (React.createElement("div", { className: commonClasses, onClick: onClick, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave }, children));