@page-speed/venn-diagram 0.0.6 → 0.0.8

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/README.md CHANGED
@@ -50,6 +50,11 @@ export function MyDashboard() {
50
50
  }
51
51
  ```
52
52
 
53
+ ## Styling
54
+
55
+ This component uses Tailwind utility classes for its default styling. Make sure
56
+ your Tailwind `content` config includes this package so the classes are
57
+ generated (for example, `./node_modules/@page-speed/venn-diagram/dist/**/*.{js,ts,jsx,tsx}`).
53
58
 
54
59
  ## API Overview
55
60
 
@@ -1 +1 @@
1
- {"version":3,"file":"VennDiagram.d.ts","sourceRoot":"","sources":["../../../src/components/VennDiagram.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoC,MAAM,OAAO,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAA0B,MAAM,qBAAqB,CAAC;AA6B/E,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CA8KlD,CAAC"}
1
+ {"version":3,"file":"VennDiagram.d.ts","sourceRoot":"","sources":["../../../src/components/VennDiagram.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoC,MAAM,OAAO,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAA0B,MAAM,qBAAqB,CAAC;AA4B/E,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CA4LlD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"VennDiagramSVG.d.ts","sourceRoot":"","sources":["../../../src/components/VennDiagramSVG.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkC,MAAM,OAAO,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAInD,UAAU,mBAAmB;IAC3B,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB,aAAa,EAAE,KAAK,CAAC;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC,CAAC;IACnE,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;CACxC;AAED,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CA0KxD,CAAC"}
1
+ {"version":3,"file":"VennDiagramSVG.d.ts","sourceRoot":"","sources":["../../../src/components/VennDiagramSVG.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkC,MAAM,OAAO,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGnD,UAAU,mBAAmB;IAC3B,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB,aAAa,EAAE,KAAK,CAAC;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC,CAAC;IACnE,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;CACxC;AAED,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CA+KxD,CAAC"}
package/dist/cjs/index.js CHANGED
@@ -3250,8 +3250,6 @@ const isAccessibleContrast = (foreground, background) => {
3250
3250
  return contrastRatio >= 4.5;
3251
3251
  };
3252
3252
 
3253
- var styles = {"vennContainer":"VennDiagram-module_vennContainer__zE5Q4","svg":"VennDiagram-module_svg__8SEMM","circleGroup":"VennDiagram-module_circleGroup__9MTB2","circle":"VennDiagram-module_circle__sXeUM","selected":"VennDiagram-module_selected__U2SLC","labelGroup":"VennDiagram-module_labelGroup__bbeK2","value":"VennDiagram-module_value__0wKIt","label":"VennDiagram-module_label__fsN9f","legend":"VennDiagram-module_legend__ZOQL5","legendItem":"VennDiagram-module_legendItem__G3upl","legendLabel":"VennDiagram-module_legendLabel__yK6aP","legendValue":"VennDiagram-module_legendValue__cuwMv","error":"VennDiagram-module_error__czgBP","loading":"VennDiagram-module_loading__8lTBq"};
3254
-
3255
3253
  const VennDiagramContext = /*#__PURE__*/require$$0.createContext(null);
3256
3254
  VennDiagramContext.displayName = "VennDiagramContext";
3257
3255
 
@@ -3297,7 +3295,7 @@ const VennDiagramSVG = ({
3297
3295
  viewBox: `0 0 ${width} ${height}`,
3298
3296
  width: width,
3299
3297
  height: height,
3300
- className: styles.svg,
3298
+ className: "block h-full w-full",
3301
3299
  role: "img",
3302
3300
  "aria-label": "Venn diagram",
3303
3301
  children: [layout.map((circle, idx) => {
@@ -3305,8 +3303,9 @@ const VennDiagramSVG = ({
3305
3303
  const color = colorScheme ? colorScheme[idx] : "#ccc";
3306
3304
  const isHovered = hoveredSets?.includes(set.name);
3307
3305
  const isSelected = selectedSets?.includes(set.name);
3306
+ const effectiveStrokeWidth = isHovered ? Math.max(strokeWidth || 0, 3) : strokeWidth;
3308
3307
  return jsxRuntimeExports.jsx("g", {
3309
- className: styles.circleGroup,
3308
+ className: "outline-none",
3310
3309
  children: jsxRuntimeExports.jsx("circle", {
3311
3310
  cx: circle.x,
3312
3311
  cy: circle.y,
@@ -3314,12 +3313,8 @@ const VennDiagramSVG = ({
3314
3313
  fill: color,
3315
3314
  fillOpacity: isHovered ? config.hoverOpacity : 0.4,
3316
3315
  stroke: color,
3317
- strokeWidth: strokeWidth,
3318
- className: `${styles.circle} ${isSelected ? styles.selected : ""}`,
3319
- style: {
3320
- transition: animated ? "all 300ms ease-in-out" : "none",
3321
- cursor: config.interactive ? "pointer" : "default"
3322
- },
3316
+ strokeWidth: effectiveStrokeWidth,
3317
+ className: ["outline-none focus:outline-none focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2", animated ? "transition-all duration-300 ease-in-out" : "", config.interactive ? "cursor-pointer" : "cursor-default", isSelected ? "drop-shadow-sm" : ""].filter(Boolean).join(" "),
3323
3318
  onMouseEnter: () => handleCircleHover(set.name, true),
3324
3319
  onMouseLeave: () => handleCircleHover(set.name, false),
3325
3320
  onClick: () => handleCircleClick(set.name),
@@ -3342,27 +3337,23 @@ const VennDiagramSVG = ({
3342
3337
  const rawLabel = singleSet?.label ?? setNames[0];
3343
3338
  const renderedLabel = typeof rawLabel === "string" ? config.formatLabel ? config.formatLabel(rawLabel) : rawLabel : rawLabel;
3344
3339
  return jsxRuntimeExports.jsxs("g", {
3345
- className: styles.labelGroup,
3340
+ className: ["pointer-events-none select-none", animated ? "transition-opacity duration-300 ease-in-out" : ""].filter(Boolean).join(" "),
3346
3341
  style: {
3347
- opacity: isHovered ? 1 : 0.7,
3348
- transition: animated ? "opacity 300ms ease-in-out" : "none"
3342
+ opacity: isHovered ? 1 : 0.7
3349
3343
  },
3350
3344
  children: [showValues && jsxRuntimeExports.jsx("text", {
3351
3345
  x: pos.x,
3352
3346
  y: pos.y - 8,
3353
3347
  textAnchor: "middle",
3354
- className: styles.value,
3348
+ className: "text-base font-semibold",
3355
3349
  fill: config.textFill,
3356
- fontSize: "16",
3357
- fontWeight: "600",
3358
3350
  children: config.formatValue ? config.formatValue(value) : value
3359
3351
  }), showLabels && setNames.length === 1 && jsxRuntimeExports.jsx("text", {
3360
3352
  x: pos.x,
3361
3353
  y: pos.y + 20,
3362
3354
  textAnchor: "middle",
3363
- className: styles.label,
3355
+ className: "text-sm font-medium",
3364
3356
  fill: config.textFill,
3365
- fontSize: "14",
3366
3357
  children: renderedLabel
3367
3358
  })]
3368
3359
  }, setNames.join(","));
@@ -3436,21 +3427,23 @@ const VennDiagram = ({
3436
3427
  selectedSets,
3437
3428
  setSelectedSets
3438
3429
  }), [data, finalWidth, finalHeight, showLabels, showValues, colorScheme, animated, hoverOpacity, interactive, padding, textFill, strokeWidth, formatValue, formatLabel, hoveredSets, selectedSets, onSetHover]);
3430
+ const rootClassName = ["relative w-full", className].filter(Boolean).join(" ");
3439
3431
  if (error) {
3440
3432
  return jsxRuntimeExports.jsxs("div", {
3441
- className: styles.error,
3433
+ className: "flex w-full flex-col items-center justify-center gap-2 rounded-lg border border-red-200/70 bg-red-50 px-4 py-6 text-sm text-red-600",
3442
3434
  role: "alert",
3443
3435
  "data-testid": testId ? `${testId}-error` : undefined,
3444
3436
  children: [jsxRuntimeExports.jsx("p", {
3445
3437
  children: "Error rendering Venn diagram:"
3446
3438
  }), jsxRuntimeExports.jsx("code", {
3439
+ className: "w-full rounded-md bg-black/5 px-2 py-1 font-mono text-xs text-red-700",
3447
3440
  children: error.message
3448
3441
  })]
3449
3442
  });
3450
3443
  }
3451
3444
  if (isLoading && layout.length === 0) {
3452
3445
  return jsxRuntimeExports.jsx("div", {
3453
- className: styles.loading,
3446
+ className: "flex w-full items-center justify-center text-sm text-slate-500",
3454
3447
  role: "status",
3455
3448
  "aria-busy": true,
3456
3449
  "data-testid": testId ? `${testId}-loading` : undefined,
@@ -3462,32 +3455,36 @@ const VennDiagram = ({
3462
3455
  return jsxRuntimeExports.jsx(VennDiagramContext.Provider, {
3463
3456
  value: contextValue,
3464
3457
  children: jsxRuntimeExports.jsxs("div", {
3465
- ref: containerRef,
3466
- className: `${styles.vennContainer} ${className || ""}`,
3467
- style: {
3468
- width: responsive ? "100%" : finalWidth,
3469
- height: responsive ? "100%" : finalHeight,
3470
- ...style
3471
- },
3458
+ className: rootClassName,
3459
+ style: style,
3472
3460
  "data-testid": testId,
3473
- children: [renderer === "svg" && jsxRuntimeExports.jsx(VennDiagramSVG, {
3474
- layout: layout,
3475
- textPositions: textPositions,
3476
- width: finalWidth,
3477
- height: finalHeight,
3478
- onClick: onClick
3461
+ children: [jsxRuntimeExports.jsx("div", {
3462
+ ref: containerRef,
3463
+ className: "relative h-full w-full min-h-[300px]",
3464
+ style: {
3465
+ width: responsive ? "100%" : finalWidth,
3466
+ height: responsive ? "100%" : finalHeight
3467
+ },
3468
+ "data-venn-container": true,
3469
+ children: renderer === "svg" && jsxRuntimeExports.jsx(VennDiagramSVG, {
3470
+ layout: layout,
3471
+ textPositions: textPositions,
3472
+ width: finalWidth,
3473
+ height: finalHeight,
3474
+ onClick: onClick
3475
+ })
3479
3476
  }), showLegend && jsxRuntimeExports.jsx("div", {
3480
- className: styles.legend,
3477
+ className: "mt-4 flex flex-col gap-2 venn-legend",
3481
3478
  children: data.sets.map((set, idx) => jsxRuntimeExports.jsxs("div", {
3482
- className: styles.legendItem,
3479
+ className: "flex items-center justify-between gap-3 rounded-md border border-l-4 border-slate-200/70 bg-white/80 px-3 py-2 text-sm",
3483
3480
  style: {
3484
3481
  borderLeftColor: colorScheme[idx]
3485
3482
  },
3486
3483
  children: [jsxRuntimeExports.jsx("span", {
3487
- className: styles.legendLabel,
3484
+ className: "text-sm font-medium text-slate-700",
3488
3485
  children: formatLabel && typeof (set.label || set.name) === "string" ? formatLabel(set.label || set.name) : set.label || set.name
3489
3486
  }), jsxRuntimeExports.jsx("span", {
3490
- className: styles.legendValue,
3487
+ className: "text-sm font-semibold text-slate-600",
3491
3488
  children: formatValue ? formatValue(set.size) : set.size
3492
3489
  })]
3493
3490
  }, set.name))