oneslash-design-system 2.14.0 → 2.14.1
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.
|
@@ -11,9 +11,9 @@ interface ButtonProps extends React.AriaAttributes {
|
|
|
11
11
|
state: 'enabled' | 'hovered' | 'focused' | 'disabled' | 'selected';
|
|
12
12
|
label: string;
|
|
13
13
|
secondLabel?: string;
|
|
14
|
-
/** A Lucide icon name, an icon component (only that icon is bundled) or an element */
|
|
14
|
+
/** A Lucide icon name, an icon component (only that icon is bundled) or an element (`<Plus />`, the form a Server Component can pass) */
|
|
15
15
|
decoIcon?: IconSource;
|
|
16
|
-
/** A Lucide icon name, an icon component (only that icon is bundled) or an element */
|
|
16
|
+
/** A Lucide icon name, an icon component (only that icon is bundled) or an element (`<Plus />`, the form a Server Component can pass) */
|
|
17
17
|
actionIcon?: IconSource;
|
|
18
18
|
onClickButton?: any;
|
|
19
19
|
onClickActionIcon?: () => void;
|
|
@@ -5,8 +5,8 @@ type IconName = keyof typeof icons;
|
|
|
5
5
|
interface IconProps {
|
|
6
6
|
/** A Lucide icon name. Give this or `icon`. */
|
|
7
7
|
name?: IconName;
|
|
8
|
-
/** An icon component, e.g. `Plus` from `lucide-react
|
|
9
|
-
icon?: IconComponent;
|
|
8
|
+
/** An icon component, e.g. `Plus` from `lucide-react`, or an element (`<Plus />`, the form a Server Component can pass): only that icon is bundled. Wins over `name`. */
|
|
9
|
+
icon?: IconComponent | React.ReactElement;
|
|
10
10
|
size?: 'tiny' | 'small' | 'medium' | 'large' | number;
|
|
11
11
|
color?: 'primary' | 'secondary' | 'disabled' | 'error' | 'warning' | 'success' | 'info' | 'accent' | 'inherit';
|
|
12
12
|
strokeWidth?: number;
|
|
@@ -10,7 +10,9 @@ export type IconComponent = React.ComponentType<any>;
|
|
|
10
10
|
* - a Lucide icon name (`"Plus"`). The icon set loads in its own chunk the first time a name is used.
|
|
11
11
|
* - an icon component (`Plus` from `lucide-react`). Sized and stroked like a named icon, and only
|
|
12
12
|
* that icon is bundled.
|
|
13
|
-
* - an element (`<Logo />`).
|
|
13
|
+
* - an element (`<Plus />`, `<Logo />`). The only form a Server Component can pass. An element
|
|
14
|
+
* without a `className` is sized and stroked like a named icon; one with a `className` is
|
|
15
|
+
* rendered as given, so the caller's own size wins.
|
|
14
16
|
*/
|
|
15
17
|
export type IconSource = string | IconComponent | React.ReactElement;
|
|
16
18
|
interface IconSlotProps {
|
|
@@ -1,12 +1,31 @@
|
|
|
1
1
|
'use client';
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
2
13
|
import React, { Suspense, lazy } from 'react';
|
|
3
14
|
var NamedIcon = lazy(function () { return import('./namedIcon'); });
|
|
4
15
|
export default function IconSlot(_a) {
|
|
5
|
-
var
|
|
16
|
+
var _b;
|
|
17
|
+
var icon = _a.icon, className = _a.className, _c = _a.strokeWidth, strokeWidth = _c === void 0 ? 2 : _c, size = _a.size, warnIfMissing = _a.warnIfMissing;
|
|
6
18
|
if (!icon)
|
|
7
19
|
return null;
|
|
8
|
-
if (React.isValidElement(icon))
|
|
9
|
-
|
|
20
|
+
if (React.isValidElement(icon)) {
|
|
21
|
+
var own = icon.props;
|
|
22
|
+
// The caller's own classes win: merging two size classes would leave the result to CSS order
|
|
23
|
+
if (own.className !== undefined)
|
|
24
|
+
return icon;
|
|
25
|
+
// `strokeWidth` and `size` are props of an icon component, not attributes of a plain tag
|
|
26
|
+
var iconProps = typeof icon.type === 'string' ? {} : __assign({ strokeWidth: (_b = own.strokeWidth) !== null && _b !== void 0 ? _b : strokeWidth }, (size !== undefined && own.size === undefined ? { size: size } : {}));
|
|
27
|
+
return React.cloneElement(icon, __assign({ className: className }, iconProps));
|
|
28
|
+
}
|
|
10
29
|
if (typeof icon === 'string') {
|
|
11
30
|
return (
|
|
12
31
|
// The empty box holds the icon's place until the icon set has loaded
|
|
@@ -163,12 +163,14 @@ export var AriaExpanded = {
|
|
|
163
163
|
},
|
|
164
164
|
};
|
|
165
165
|
// An icon can be a component or an element instead of a name. A component is sized like a
|
|
166
|
-
// named icon and only that icon is bundled
|
|
166
|
+
// named icon and only that icon is bundled. So is an element without a className (what a
|
|
167
|
+
// Server Component passes); an element with a className is rendered as given.
|
|
167
168
|
export var IconComponents = {
|
|
168
169
|
render: function () { return (<div style={{ display: "flex", gap: "16px", alignItems: "center" }}>
|
|
169
170
|
<Button size="medium" type="primary" state="enabled" label="Component" decoIcon={Star} actionIcon={ChevronRight}/>
|
|
170
171
|
<Button size="medium" type="secondary" state="enabled" label="By name" decoIcon="Star" actionIcon="ChevronRight"/>
|
|
171
172
|
<Button size="medium" type="tertiary" state="enabled" label="Element" decoIcon={<span className="w-5 h-5 rounded-full bg-accent-main flex-shrink-0"/>}/>
|
|
173
|
+
<Button size="medium" type="tertiary" state="enabled" label="Icon element" decoIcon={<Star />} actionIcon={<ChevronRight />}/>
|
|
172
174
|
</div>); },
|
|
173
175
|
};
|
|
174
176
|
// `href` renders a link with the button's look: next/link for a path, a plain <a> for another site
|