oneslash-design-system 2.14.1 → 2.14.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.
@@ -11,8 +11,8 @@ export type IconComponent = React.ComponentType<any>;
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
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
+ * whose classes set no size is sized like a named icon; one with a size class of its own
15
+ * (`w-*`, `h-*`, `size-*`) is rendered as given, so the caller's size wins.
16
16
  */
17
17
  export type IconSource = string | IconComponent | React.ReactElement;
18
18
  interface IconSlotProps {
@@ -12,6 +12,8 @@ var __assign = (this && this.__assign) || function () {
12
12
  };
13
13
  import React, { Suspense, lazy } from 'react';
14
14
  var NamedIcon = lazy(function () { return import('./namedIcon'); });
15
+ // A Tailwind class that sets a width or a height, with any variant or `!` in front
16
+ var SIZE_CLASS = /(^|[\s:!])(w|h|size)-/;
15
17
  export default function IconSlot(_a) {
16
18
  var _b;
17
19
  var icon = _a.icon, className = _a.className, _c = _a.strokeWidth, strokeWidth = _c === void 0 ? 2 : _c, size = _a.size, warnIfMissing = _a.warnIfMissing;
@@ -19,12 +21,19 @@ export default function IconSlot(_a) {
19
21
  return null;
20
22
  if (React.isValidElement(icon)) {
21
23
  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
+ // The caller's own size wins: two size classes on one element would leave the result to CSS order
25
+ if (own.className && SIZE_CLASS.test(own.className))
24
26
  return icon;
27
+ var merged = [own.className, className].filter(Boolean).join(' ') || undefined;
28
+ // A Lucide icon passed from a Server Component arrives already rendered, as an <svg> with
29
+ // Lucide's own classes and its default width and height. The size class overrides those
30
+ // attributes; a pixel size replaces them.
31
+ if (typeof icon.type === 'string') {
32
+ var box = size !== undefined && icon.type === 'svg' ? { width: size, height: size } : {};
33
+ return React.cloneElement(icon, __assign({ className: merged }, box));
34
+ }
25
35
  // `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));
36
+ return React.cloneElement(icon, __assign({ className: merged, strokeWidth: (_b = own.strokeWidth) !== null && _b !== void 0 ? _b : strokeWidth }, (size !== undefined && own.size === undefined ? { size: size } : {})));
28
37
  }
29
38
  if (typeof icon === 'string') {
30
39
  return (
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "oneslash-design-system",
3
3
  "description": "A design system for the Oneslash projects",
4
- "version": "2.14.1",
4
+ "version": "2.14.2",
5
5
  "license": "MIT",
6
6
  "private": false,
7
7
  "main": "./dist/index.js",