@lego-box/ui-kit 0.1.0 → 0.1.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.
package/dist/index.mjs CHANGED
@@ -401,30 +401,27 @@ Badge.displayName = "Badge";
401
401
  // src/components/tabs.tsx
402
402
  import * as React10 from "react";
403
403
  import { jsx as jsx10, jsxs as jsxs5 } from "react/jsx-runtime";
404
+ var TabsContext = React10.createContext(null);
404
405
  var Tabs = React10.forwardRef(
405
- ({ value, onValueChange, children, className, ...props }, ref) => {
406
- return /* @__PURE__ */ jsx10(
407
- "div",
408
- {
409
- ref,
410
- className: cn("w-full", className),
411
- ...props,
412
- children: React10.Children.map(children, (child) => {
413
- if (React10.isValidElement(child)) {
414
- return React10.cloneElement(child, {
415
- selectedValue: value,
416
- onValueChange
417
- });
418
- }
419
- return child;
420
- })
421
- }
406
+ ({
407
+ value,
408
+ onValueChange,
409
+ children,
410
+ className,
411
+ // Explicitly omit component-specific props so they never reach the DOM (fixes React warnings)
412
+ selectedValue: _selectedValue,
413
+ ...props
414
+ }, ref) => {
415
+ const contextValue = React10.useMemo(
416
+ () => ({ value, onValueChange }),
417
+ [value, onValueChange]
422
418
  );
419
+ return /* @__PURE__ */ jsx10(TabsContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx10("div", { ref, className: cn("w-full", className), ...props, children }) });
423
420
  }
424
421
  );
425
422
  Tabs.displayName = "Tabs";
426
423
  var TabsList = React10.forwardRef(
427
- ({ children, className, selectedValue, onValueChange, ...props }, ref) => {
424
+ ({ children, className, ...props }, ref) => {
428
425
  return /* @__PURE__ */ jsx10(
429
426
  "div",
430
427
  {
@@ -434,28 +431,26 @@ var TabsList = React10.forwardRef(
434
431
  className
435
432
  ),
436
433
  ...props,
437
- children: React10.Children.map(children, (child) => {
438
- if (React10.isValidElement(child)) {
439
- return React10.cloneElement(child, {
440
- selectedValue,
441
- onValueChange
442
- });
443
- }
444
- return child;
445
- })
434
+ children
446
435
  }
447
436
  );
448
437
  }
449
438
  );
450
439
  TabsList.displayName = "TabsList";
451
440
  var TabsTrigger = React10.forwardRef(
452
- ({ value, children, className, selectedValue, onValueChange, badge, disabled, ...props }, ref) => {
453
- const isActive = selectedValue === value;
441
+ ({ value, children, className, badge, disabled, ...props }, ref) => {
442
+ const context = React10.useContext(TabsContext);
443
+ const isActive = context?.value === value;
444
+ const handleClick = () => {
445
+ if (!disabled && context?.onValueChange) {
446
+ context.onValueChange(value);
447
+ }
448
+ };
454
449
  return /* @__PURE__ */ jsxs5(
455
450
  "button",
456
451
  {
457
452
  ref,
458
- onClick: () => !disabled && onValueChange?.(value),
453
+ onClick: handleClick,
459
454
  disabled,
460
455
  className: cn(
461
456
  "inline-flex items-center justify-center gap-2 px-4 py-2.5 text-sm font-medium rounded-lg transition-all duration-200",