@krrli/cm-designsystem 1.34.3 → 1.34.5

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.
@@ -604,6 +604,10 @@
604
604
  width: auto;
605
605
  }
606
606
 
607
+ .w-fit {
608
+ width: fit-content;
609
+ }
610
+
607
611
  .w-full {
608
612
  width: 100%;
609
613
  }
@@ -1,6 +1,5 @@
1
1
  import { default as React } from 'react';
2
2
  import { VariantProps } from 'tailwind-variants';
3
- import { TabItemProps } from './TabItem';
4
3
  declare const tabStyles: import('tailwind-variants').TVReturnType<{
5
4
  selected: {
6
5
  false: {
@@ -54,15 +53,11 @@ declare const tabStyles: import('tailwind-variants').TVReturnType<{
54
53
  trigger: string[];
55
54
  }, undefined, unknown, unknown, undefined>>;
56
55
  type TabVariants = VariantProps<typeof tabStyles>;
57
- export interface TabLabelProps {
58
- value: string;
59
- label: string;
60
- }
61
56
  export interface TabProps extends TabVariants {
62
57
  value: string;
63
58
  onChange?: (value: string) => void;
64
- children: React.ReactElement<TabItemProps>[];
59
+ children: React.ReactNode;
65
60
  }
66
- export declare const Tabs: (props: TabProps) => import("react/jsx-runtime").JSX.Element;
61
+ export declare const Tabs: ({ value, onChange, children, ...variants }: TabProps) => import("react/jsx-runtime").JSX.Element;
67
62
  export {};
68
63
  //# sourceMappingURL=Tabs.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Tabs.d.ts","sourceRoot":"","sources":["../../../src/components/tabs/Tabs.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAM,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAE1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAE9C,QAAA,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2CA2Cb,CAAC;AAEH,KAAK,WAAW,GAAG,YAAY,CAAC,OAAO,SAAS,CAAC,CAAC;AAElD,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,QAAS,SAAQ,WAAW;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,QAAQ,EAAE,KAAK,CAAC,YAAY,CAAC,YAAY,CAAC,EAAE,CAAC;CAC9C;AAED,eAAO,MAAM,IAAI,GAAI,OAAO,QAAQ,4CAsCnC,CAAC"}
1
+ {"version":3,"file":"Tabs.d.ts","sourceRoot":"","sources":["../../../src/components/tabs/Tabs.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAM,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAI1D,QAAA,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2CA6Cb,CAAC;AAEH,KAAK,WAAW,GAAG,YAAY,CAAC,OAAO,SAAS,CAAC,CAAC;AAElD,MAAM,WAAW,QAAS,SAAQ,WAAW;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,eAAO,MAAM,IAAI,GAAI,4CAA4C,QAAQ,4CA+BxE,CAAC"}
@@ -1,3 +1,4 @@
1
+ "use client";
1
2
  import { jsxs, jsx } from "react/jsx-runtime";
2
3
  import * as RadixTabs from "@radix-ui/react-tabs";
3
4
  import React from "react";
@@ -5,7 +6,15 @@ import { tv } from "tailwind-variants";
5
6
  import { Label } from "../typography/Label.js";
6
7
  const tabStyles = tv({
7
8
  slots: {
8
- list: ["bg-slate-200", "rounded-lg", "p-1", "flex", "gap-2", "group"],
9
+ list: [
10
+ "bg-slate-200",
11
+ "rounded-lg",
12
+ "p-1",
13
+ "flex",
14
+ "gap-2",
15
+ "group",
16
+ "w-fit"
17
+ ],
9
18
  trigger: ["pt-2", "pb-2", "pr-3", "pl-3", "rounded-md"]
10
19
  },
11
20
  variants: {
@@ -27,54 +36,40 @@ const tabStyles = tv({
27
36
  {
28
37
  selected: true,
29
38
  effect: "first",
30
- class: {
31
- trigger: ["group-hover:pr-6"]
32
- }
39
+ class: { trigger: ["group-hover:pr-6"] }
33
40
  },
34
41
  {
35
42
  selected: true,
36
43
  effect: "middle",
37
- class: {
38
- trigger: ["group-hover:pr-6", "group-hover:pl-6"]
39
- }
44
+ class: { trigger: ["group-hover:pr-6", "group-hover:pl-6"] }
40
45
  },
41
46
  {
42
47
  selected: true,
43
48
  effect: "last",
44
- class: {
45
- trigger: ["group-hover:pl-6"]
46
- }
49
+ class: { trigger: ["group-hover:pl-6"] }
47
50
  }
48
51
  ]
49
52
  });
50
- const Tabs = (props) => {
51
- const { list, trigger } = tabStyles(props);
52
- const [currentSelection, setSelection] = React.useState(props.value);
53
- const getEffectVariant = (index, max) => index === 0 ? "first" : max === index ? "last" : "middle";
54
- const onClick = (value) => {
55
- setSelection(value);
56
- props.onChange?.(value);
57
- };
58
- return /* @__PURE__ */ jsxs(RadixTabs.Root, { defaultValue: props.value, children: [
59
- /* @__PURE__ */ jsx(RadixTabs.List, { className: list(), children: props.children.map((child, index) => /* @__PURE__ */ jsx(
53
+ const Tabs = ({ value, onChange, children, ...variants }) => {
54
+ const { list, trigger } = tabStyles(variants);
55
+ const items = React.Children.toArray(children).filter(
56
+ (child) => React.isValidElement(child)
57
+ );
58
+ const getEffectVariant = (index, max) => index === 0 ? "first" : index === max ? "last" : "middle";
59
+ return /* @__PURE__ */ jsxs(RadixTabs.Root, { value, onValueChange: onChange, children: [
60
+ /* @__PURE__ */ jsx(RadixTabs.List, { className: list(), children: items.map((child, index) => /* @__PURE__ */ jsx(
60
61
  RadixTabs.Trigger,
61
62
  {
62
63
  value: child.props.value,
63
64
  className: trigger({
64
- selected: child.props.value === currentSelection,
65
- effect: getEffectVariant(index, props.children.length - 1)
65
+ selected: child.props.value === value,
66
+ effect: getEffectVariant(index, items.length - 1)
66
67
  }),
67
- onClick: () => onClick(child.props.value),
68
68
  children: /* @__PURE__ */ jsx(Label, { size: "lg", children: child.props.label })
69
69
  },
70
70
  child.props.value
71
71
  )) }),
72
- React.Children.map(props.children, (child, index) => {
73
- if (React.isValidElement(child)) {
74
- return React.cloneElement(child, { key: props.value || index });
75
- }
76
- return child;
77
- })
72
+ items
78
73
  ] });
79
74
  };
80
75
  export {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@krrli/cm-designsystem",
3
3
  "repository": "https://github.com/ost-cas-fea-25-26/cm-designsystem",
4
- "version": "1.34.3",
4
+ "version": "1.34.5",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",