@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/cjs/index.js CHANGED
@@ -40252,7 +40252,7 @@ var SvgXCircle$1 = function (props) { return (React__namespace.createElement("sv
40252
40252
  var SvgXMark$1 = function (props) { return (React__namespace.createElement("svg", __assign({ xmlns: "http://www.w3.org/2000/svg", width: "1em", height: "1em", fill: "none", viewBox: "0 0 24 24" }, props),
40253
40253
  React__namespace.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" }))); };
40254
40254
 
40255
- var colors = [
40255
+ var colors$1 = [
40256
40256
  "s-bg-red-300",
40257
40257
  "s-bg-orange-300",
40258
40258
  "s-bg-amber-300",
@@ -40333,7 +40333,7 @@ function Avatar(_a) {
40333
40333
  for (var i = 0; i < name.length; i++) {
40334
40334
  hash = name.charCodeAt(i) + ((hash << 5) - hash);
40335
40335
  }
40336
- return colors[Math.abs(hash) % colors.length];
40336
+ return colors$1[Math.abs(hash) % colors$1.length];
40337
40337
  };
40338
40338
  var getTextVariant = function (name) {
40339
40339
  if (/\+/.test(name)) {
@@ -97292,6 +97292,41 @@ var pxSizeClasses = {
97292
97292
  xl: "128",
97293
97293
  xxl: "192",
97294
97294
  };
97295
+ var colors = {
97296
+ emerald900: [0.0235, 0.3059, 0.2314, 1], // #064E3B
97297
+ amber900: [0.5725, 0.251, 0.0549, 1], // #92400E
97298
+ slate900: [0.0588, 0.0902, 0.1647, 1], // #0F172A
97299
+ purple900: [0.298, 0.1137, 0.5843, 1], // #4C1D95
97300
+ sky900: [0.0471, 0.2902, 0.4314, 1], // #0C4A6E
97301
+ pink900: [0.5137, 0.0941, 0.2627, 1], // #831843
97302
+ red900: [0.498, 0.1137, 0.1137, 1], // #7F1D1D
97303
+ warning900: [0.498, 0.1137, 0.1137, 1], // #7F1D1D
97304
+ action900: [0.1176, 0.2275, 0.5412, 1], // #1E3A8A
97305
+ };
97306
+ var isColorArray = function (arr) {
97307
+ return (Array.isArray(arr) &&
97308
+ arr.length === 4 &&
97309
+ arr.every(function (n) { return typeof n === "number"; }));
97310
+ };
97311
+ // Due to the dynamic nature of Lottie, we use 'any' for the input object.
97312
+ // This function recursively replaces color arrays within the Lottie animation object.
97313
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
97314
+ var replaceColors = function (obj, newColor) {
97315
+ if (Array.isArray(obj)) {
97316
+ return obj.map(function (item) { return replaceColors(item, newColor); });
97317
+ }
97318
+ else if (obj !== null && typeof obj === "object") {
97319
+ for (var key in obj) {
97320
+ if (isColorArray(obj[key])) {
97321
+ obj[key] = newColor;
97322
+ }
97323
+ else {
97324
+ obj[key] = replaceColors(obj[key], newColor);
97325
+ }
97326
+ }
97327
+ }
97328
+ return obj;
97329
+ };
97295
97330
  var Spinner = function (_a) {
97296
97331
  var _b = _a.size, size = _b === void 0 ? "md" : _b, _c = _a.variant, variant = _c === void 0 ? "color" : _c;
97297
97332
  var fullSize = parseInt(pxSizeClasses[size], 10);
@@ -97334,6 +97369,15 @@ var Spinner = function (_a) {
97334
97369
  anim = animation$9;
97335
97370
  }
97336
97371
  }
97372
+ if (variant && variant in colors) {
97373
+ // Clone the animation data to modify it
97374
+ var animationData = JSON.parse(JSON.stringify(anim));
97375
+ var newColor = colors[variant];
97376
+ if (newColor) {
97377
+ replaceColors(animationData, newColor);
97378
+ }
97379
+ return (React.createElement(Lottie, { animationData: animationData, style: { width: "".concat(fullSize, "px"), height: "".concat(fullSize, "px") }, loop: true, autoplay: true }));
97380
+ }
97337
97381
  return (React.createElement(Lottie, { animationData: anim, style: { width: "".concat(fullSize, "px"), height: "".concat(fullSize, "px") }, loop: true, autoplay: true }));
97338
97382
  };
97339
97383