@dust-tt/sparkle 0.2.158 → 0.2.159

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,7 +1,7 @@
1
1
  import React from "react";
2
2
  export interface SpinnerProps {
3
3
  size?: "xs" | "sm" | "md" | "lg" | "xl" | "xxl";
4
- variant?: "color" | "light" | "dark";
4
+ variant?: "color" | "light" | "dark" | "pink900";
5
5
  }
6
6
  declare const Spinner: React.FC<SpinnerProps>;
7
7
  export default Spinner;
package/dist/esm/index.js CHANGED
@@ -40232,7 +40232,7 @@ var SvgXCircle$1 = function (props) { return (React.createElement("svg", __assig
40232
40232
  var SvgXMark$1 = function (props) { return (React.createElement("svg", __assign({ xmlns: "http://www.w3.org/2000/svg", width: "1em", height: "1em", fill: "none", viewBox: "0 0 24 24" }, props),
40233
40233
  React.createElement("path", { fill: "currentColor", d: "m12 10 5-5 2 2-5 5 5 5-2 2-5-5-5 5-2-2 5-5-5-5 2-2 5 5Z" }))); };
40234
40234
 
40235
- var colors = [
40235
+ var colors$1 = [
40236
40236
  "s-bg-red-300",
40237
40237
  "s-bg-orange-300",
40238
40238
  "s-bg-amber-300",
@@ -40313,7 +40313,7 @@ function Avatar(_a) {
40313
40313
  for (var i = 0; i < name.length; i++) {
40314
40314
  hash = name.charCodeAt(i) + ((hash << 5) - hash);
40315
40315
  }
40316
- return colors[Math.abs(hash) % colors.length];
40316
+ return colors$1[Math.abs(hash) % colors$1.length];
40317
40317
  };
40318
40318
  var getTextVariant = function (name) {
40319
40319
  if (/\+/.test(name)) {
@@ -97272,6 +97272,41 @@ var pxSizeClasses = {
97272
97272
  xl: "128",
97273
97273
  xxl: "192",
97274
97274
  };
97275
+ var colors = {
97276
+ emerald900: [0.0235, 0.3059, 0.2314, 1], // #064E3B
97277
+ amber900: [0.5725, 0.251, 0.0549, 1], // #92400E
97278
+ slate900: [0.0588, 0.0902, 0.1647, 1], // #0F172A
97279
+ purple900: [0.298, 0.1137, 0.5843, 1], // #4C1D95
97280
+ sky900: [0.0471, 0.2902, 0.4314, 1], // #0C4A6E
97281
+ pink900: [0.5137, 0.0941, 0.2627, 1], // #831843
97282
+ red900: [0.498, 0.1137, 0.1137, 1], // #7F1D1D
97283
+ warning900: [0.498, 0.1137, 0.1137, 1], // #7F1D1D
97284
+ action900: [0.1176, 0.2275, 0.5412, 1], // #1E3A8A
97285
+ };
97286
+ var isColorArray = function (arr) {
97287
+ return (Array.isArray(arr) &&
97288
+ arr.length === 4 &&
97289
+ arr.every(function (n) { return typeof n === "number"; }));
97290
+ };
97291
+ // Due to the dynamic nature of Lottie, we use 'any' for the input object.
97292
+ // This function recursively replaces color arrays within the Lottie animation object.
97293
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
97294
+ var replaceColors = function (obj, newColor) {
97295
+ if (Array.isArray(obj)) {
97296
+ return obj.map(function (item) { return replaceColors(item, newColor); });
97297
+ }
97298
+ else if (obj !== null && typeof obj === "object") {
97299
+ for (var key in obj) {
97300
+ if (isColorArray(obj[key])) {
97301
+ obj[key] = newColor;
97302
+ }
97303
+ else {
97304
+ obj[key] = replaceColors(obj[key], newColor);
97305
+ }
97306
+ }
97307
+ }
97308
+ return obj;
97309
+ };
97275
97310
  var Spinner = function (_a) {
97276
97311
  var _b = _a.size, size = _b === void 0 ? "md" : _b, _c = _a.variant, variant = _c === void 0 ? "color" : _c;
97277
97312
  var fullSize = parseInt(pxSizeClasses[size], 10);
@@ -97314,6 +97349,15 @@ var Spinner = function (_a) {
97314
97349
  anim = animation$9;
97315
97350
  }
97316
97351
  }
97352
+ if (variant && variant in colors) {
97353
+ // Clone the animation data to modify it
97354
+ var animationData = JSON.parse(JSON.stringify(anim));
97355
+ var newColor = colors[variant];
97356
+ if (newColor) {
97357
+ replaceColors(animationData, newColor);
97358
+ }
97359
+ return (React__default.createElement(Lottie, { animationData: animationData, style: { width: "".concat(fullSize, "px"), height: "".concat(fullSize, "px") }, loop: true, autoplay: true }));
97360
+ }
97317
97361
  return (React__default.createElement(Lottie, { animationData: anim, style: { width: "".concat(fullSize, "px"), height: "".concat(fullSize, "px") }, loop: true, autoplay: true }));
97318
97362
  };
97319
97363