@dust-tt/sparkle 0.2.124 → 0.2.125-rc1

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,9 +9,11 @@ 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;
15
+ replace?: boolean;
16
+ shallow?: boolean;
13
17
  }
14
- export declare function CardButton({ children, variant, size, className, onClick, onMouseEnter, onMouseLeave, href, target, rel, }: CardButtonProps): React.JSX.Element;
18
+ export declare function CardButton({ children, variant, size, className, onClick, onMouseEnter, onMouseLeave, href, target, rel, replace, shallow, }: CardButtonProps): React.JSX.Element;
15
19
  export {};
@@ -1,13 +1,15 @@
1
+ /// <reference types="node" />
1
2
  import React from "react";
3
+ import type { UrlObject } from "url";
2
4
  interface TemplateItemProps {
3
5
  description: string;
6
+ href: string | UrlObject;
4
7
  id: string;
5
8
  name: string;
6
- onClick: (id: string) => void;
7
9
  visual: {
8
10
  backgroundColor: string;
9
11
  emoji: string;
10
12
  };
11
13
  }
12
- export declare function TemplateItem({ description, id, name, onClick, visual, }: TemplateItemProps): React.JSX.Element;
14
+ export declare function TemplateItem({ description, href, name, visual, }: TemplateItemProps): React.JSX.Element;
13
15
  export {};
@@ -1,11 +1,17 @@
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;
7
9
  ariaCurrent?: boolean | "time" | "false" | "true" | "page" | "step" | "location" | "date";
8
10
  onClick?: (event: MouseEvent<HTMLAnchorElement>) => void;
11
+ replace?: boolean;
12
+ shallow?: boolean;
13
+ target?: string;
14
+ rel?: string;
9
15
  }>;
10
16
  export type SparkleContextType = {
11
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;
@@ -936,15 +938,12 @@ var sizeClasses$4 = {
936
938
  lg: "s-p-5 s-rounded-3xl",
937
939
  };
938
940
  function CardButton(_a) {
939
- var children = _a.children, _b = _a.variant, variant = _b === void 0 ? "primary" : _b, _c = _a.size, size = _c === void 0 ? "md" : _c, _d = _a.className, className = _d === void 0 ? "" : _d, onClick = _a.onClick, onMouseEnter = _a.onMouseEnter, onMouseLeave = _a.onMouseLeave, href = _a.href, _e = _a.target, target = _e === void 0 ? "_blank" : _e, _f = _a.rel, rel = _f === void 0 ? "" : _f;
941
+ var children = _a.children, _b = _a.variant, variant = _b === void 0 ? "primary" : _b, _c = _a.size, size = _c === void 0 ? "md" : _c, _d = _a.className, className = _d === void 0 ? "" : _d, onClick = _a.onClick, onMouseEnter = _a.onMouseEnter, onMouseLeave = _a.onMouseLeave, href = _a.href, _e = _a.target, target = _e === void 0 ? "_blank" : _e, _f = _a.rel, rel = _f === void 0 ? "" : _f, replace = _a.replace, shallow = _a.shallow;
940
942
  var components = React.useContext(SparkleContext).components;
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 }, 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));
@@ -55242,9 +55241,9 @@ function Popup(_a) {
55242
55241
  }
55243
55242
 
55244
55243
  function TemplateItem(_a) {
55245
- var description = _a.description, id = _a.id, name = _a.name, onClick = _a.onClick, visual = _a.visual;
55244
+ var description = _a.description, href = _a.href, name = _a.name, visual = _a.visual;
55246
55245
  var backgroundColor = visual.backgroundColor, emoji = visual.emoji;
55247
- return (React.createElement(CardButton, { className: "s-flex s-max-h-32 s-max-w-lg s-flex-row s-gap-5 s-p-4", onClick: function () { return onClick(id); }, variant: "tertiary" },
55246
+ return (React.createElement(CardButton, { className: "s-flex s-max-h-32 s-max-w-lg s-flex-row s-gap-5 s-p-4", href: href, variant: "tertiary", replace: true, shallow: true },
55248
55247
  React.createElement(Avatar, { emoji: emoji, size: "lg", isRounded: true, backgroundColor: backgroundColor }),
55249
55248
  React.createElement("div", { className: "s-flex s-flex-col s-gap-2" },
55250
55249
  React.createElement("span", { className: "s-text-bold s-text-lg s-font-medium s-text-element-900" }, name),