@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.
- package/dist/cjs/components/CardButton.d.ts +3 -1
- package/dist/cjs/components/TemplateItem.d.ts +3 -1
- package/dist/cjs/context.d.ts +5 -1
- package/dist/cjs/index.js +5 -6
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/components/CardButton.d.ts +3 -1
- package/dist/esm/components/TemplateItem.d.ts +3 -1
- package/dist/esm/context.d.ts +5 -1
- package/dist/esm/index.js +5 -6
- package/dist/esm/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -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;
|
package/dist/esm/context.d.ts
CHANGED
|
@@ -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/esm/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import React__default, { createContext, useRef, useState, useEffect, useContext, Children, cloneElement, useLayoutEffect, forwardRef, Fragment, isValidElement, createElement, useMemo, useReducer, createRef, useCallback } from 'react';
|
|
3
|
+
import url from 'url';
|
|
3
4
|
|
|
4
5
|
function styleInject(css, ref) {
|
|
5
6
|
if ( ref === void 0 ) ref = {};
|
|
@@ -32,8 +33,9 @@ var css_248z = ".s-form-checkbox,.s-form-radio {\n -webkit-appearance: none;\n
|
|
|
32
33
|
styleInject(css_248z);
|
|
33
34
|
|
|
34
35
|
var aLink = function (_a) {
|
|
35
|
-
var href = _a.href, className = _a.className, ariaCurrent = _a.ariaCurrent, ariaLabel = _a.ariaLabel, onClick = _a.onClick, children = _a.children;
|
|
36
|
-
|
|
36
|
+
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;
|
|
37
|
+
var hrefAsString = typeof href !== "string" ? url.format(href) : href;
|
|
38
|
+
return (React__default.createElement("a", { href: hrefAsString, className: className, "aria-current": ariaCurrent, "aria-label": ariaLabel, onClick: onClick, target: target, rel: rel }, children));
|
|
37
39
|
};
|
|
38
40
|
var noHrefLink = function (_a) {
|
|
39
41
|
var className = _a.className, ariaCurrent = _a.ariaCurrent, ariaLabel = _a.ariaLabel, onClick = _a.onClick, children = _a.children;
|
|
@@ -921,10 +923,7 @@ function CardButton(_a) {
|
|
|
921
923
|
var Link = href ? components.link : noHrefLink;
|
|
922
924
|
var commonClasses = classNames("s-flex s-cursor-pointer s-transition s-duration-200", variantClasses$1[variant], sizeClasses$4[size], className);
|
|
923
925
|
if (href) {
|
|
924
|
-
|
|
925
|
-
return (React__default.createElement("a", { href: href, target: target, rel: rel, className: commonClasses }, children));
|
|
926
|
-
}
|
|
927
|
-
return (React__default.createElement(Link, { href: href, className: commonClasses, replace: replace, shallow: shallow }, children));
|
|
926
|
+
return (React__default.createElement(Link, { href: href, className: commonClasses, replace: replace, shallow: shallow, target: target, rel: rel }, children));
|
|
928
927
|
}
|
|
929
928
|
else {
|
|
930
929
|
return (React__default.createElement("div", { className: commonClasses, onClick: onClick, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave }, children));
|