@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/README.md CHANGED
@@ -1,47 +1,47 @@
1
- # @lego-box/ui-kit
2
-
3
- Reusable UI component library for Lego Box applications. Built with React, TypeScript, and Tailwind CSS.
4
-
5
- ## Installation
6
-
7
- ```bash
8
- pnpm add @lego-box/ui-kit
9
- # or
10
- npm install @lego-box/ui-kit
11
- ```
12
-
13
- ## Usage
14
-
15
- Import components directly:
16
-
17
- ```tsx
18
- import { Button, Card, Input } from '@lego-box/ui-kit';
19
-
20
- function MyComponent() {
21
- return (
22
- <Card>
23
- <Input placeholder="Enter text" />
24
- <Button>Submit</Button>
25
- </Card>
26
- );
27
- }
28
- ```
29
-
30
- CSS is automatically injected - no need to import stylesheets manually.
31
-
32
- ## Components
33
-
34
- - **Form Components:** Button, Input, Checkbox, Label, Select, PasswordInput
35
- - **Layout Components:** Card, Dialog, Tabs, AdminShell, TopBar, SideNav
36
- - **Data Display:** DataTable, GroupedTable, Badge, StatusBadge, Pagination
37
- - **User Management:** UserFormDialog, RoleFormDialog, PermissionFormDialog
38
- - **Feedback:** Loading, NotFound, AccessDenied, Tooltip
39
- - **And many more...**
40
-
41
- ## Theming
42
-
43
- The library uses CSS variables for theming. Supports light and dark modes out of the box.
44
-
45
- ## License
46
-
47
- MIT
1
+ # @lego-box/ui-kit
2
+
3
+ Reusable UI component library for Lego Box applications. Built with React, TypeScript, and Tailwind CSS.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pnpm add @lego-box/ui-kit
9
+ # or
10
+ npm install @lego-box/ui-kit
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ Import components directly:
16
+
17
+ ```tsx
18
+ import { Button, Card, Input } from '@lego-box/ui-kit';
19
+
20
+ function MyComponent() {
21
+ return (
22
+ <Card>
23
+ <Input placeholder="Enter text" />
24
+ <Button>Submit</Button>
25
+ </Card>
26
+ );
27
+ }
28
+ ```
29
+
30
+ CSS is automatically injected - no need to import stylesheets manually.
31
+
32
+ ## Components
33
+
34
+ - **Form Components:** Button, Input, Checkbox, Label, Select, PasswordInput
35
+ - **Layout Components:** Card, Dialog, Tabs, AdminShell, TopBar, SideNav
36
+ - **Data Display:** DataTable, GroupedTable, Badge, StatusBadge, Pagination
37
+ - **User Management:** UserFormDialog, RoleFormDialog, PermissionFormDialog
38
+ - **Feedback:** Loading, NotFound, AccessDenied, Tooltip
39
+ - **And many more...**
40
+
41
+ ## Theming
42
+
43
+ The library uses CSS variables for theming. Supports light and dark modes out of the box.
44
+
45
+ ## License
46
+
47
+ MIT
package/dist/index.d.mts CHANGED
@@ -92,6 +92,8 @@ interface TabsProps extends React.HTMLAttributes<HTMLDivElement> {
92
92
  value: string;
93
93
  onValueChange: (value: string) => void;
94
94
  children: React.ReactNode;
95
+ /** @internal Filtered out - do not pass to DOM (Radix compatibility) */
96
+ selectedValue?: string;
95
97
  }
96
98
  interface TabsListProps extends React.HTMLAttributes<HTMLDivElement> {
97
99
  children: React.ReactNode;
@@ -114,14 +116,8 @@ interface TabsTriggerProps extends React.HTMLAttributes<HTMLButtonElement> {
114
116
  * - Gap between tabs
115
117
  */
116
118
  declare const Tabs: React.ForwardRefExoticComponent<TabsProps & React.RefAttributes<HTMLDivElement>>;
117
- declare const TabsList: React.ForwardRefExoticComponent<TabsListProps & {
118
- selectedValue?: string;
119
- onValueChange?: (value: string) => void;
120
- } & React.RefAttributes<HTMLDivElement>>;
121
- declare const TabsTrigger: React.ForwardRefExoticComponent<TabsTriggerProps & {
122
- selectedValue?: string;
123
- onValueChange?: (value: string) => void;
124
- } & React.RefAttributes<HTMLButtonElement>>;
119
+ declare const TabsList: React.ForwardRefExoticComponent<TabsListProps & React.RefAttributes<HTMLDivElement>>;
120
+ declare const TabsTrigger: React.ForwardRefExoticComponent<TabsTriggerProps & React.RefAttributes<HTMLButtonElement>>;
125
121
 
126
122
  interface DataTableColumn<T> {
127
123
  key: string;
@@ -476,7 +472,7 @@ declare function CanGuard({ allowed, children, fallback }: CanGuardProps): react
476
472
  /**
477
473
  * CanDisable - Disables children when not allowed and shows tooltip on hover.
478
474
  * Use for tabs, buttons, and actions that should be disabled (not hidden) when lacking permission.
479
- * Forwards all additional props (e.g. selectedValue, onValueChange from TabsList) to the child.
475
+ * Forwards all additional props to the child.
480
476
  */
481
477
  interface CanDisableProps {
482
478
  /** Whether the action is allowed */
package/dist/index.d.ts CHANGED
@@ -92,6 +92,8 @@ interface TabsProps extends React.HTMLAttributes<HTMLDivElement> {
92
92
  value: string;
93
93
  onValueChange: (value: string) => void;
94
94
  children: React.ReactNode;
95
+ /** @internal Filtered out - do not pass to DOM (Radix compatibility) */
96
+ selectedValue?: string;
95
97
  }
96
98
  interface TabsListProps extends React.HTMLAttributes<HTMLDivElement> {
97
99
  children: React.ReactNode;
@@ -114,14 +116,8 @@ interface TabsTriggerProps extends React.HTMLAttributes<HTMLButtonElement> {
114
116
  * - Gap between tabs
115
117
  */
116
118
  declare const Tabs: React.ForwardRefExoticComponent<TabsProps & React.RefAttributes<HTMLDivElement>>;
117
- declare const TabsList: React.ForwardRefExoticComponent<TabsListProps & {
118
- selectedValue?: string;
119
- onValueChange?: (value: string) => void;
120
- } & React.RefAttributes<HTMLDivElement>>;
121
- declare const TabsTrigger: React.ForwardRefExoticComponent<TabsTriggerProps & {
122
- selectedValue?: string;
123
- onValueChange?: (value: string) => void;
124
- } & React.RefAttributes<HTMLButtonElement>>;
119
+ declare const TabsList: React.ForwardRefExoticComponent<TabsListProps & React.RefAttributes<HTMLDivElement>>;
120
+ declare const TabsTrigger: React.ForwardRefExoticComponent<TabsTriggerProps & React.RefAttributes<HTMLButtonElement>>;
125
121
 
126
122
  interface DataTableColumn<T> {
127
123
  key: string;
@@ -476,7 +472,7 @@ declare function CanGuard({ allowed, children, fallback }: CanGuardProps): react
476
472
  /**
477
473
  * CanDisable - Disables children when not allowed and shows tooltip on hover.
478
474
  * Use for tabs, buttons, and actions that should be disabled (not hidden) when lacking permission.
479
- * Forwards all additional props (e.g. selectedValue, onValueChange from TabsList) to the child.
475
+ * Forwards all additional props to the child.
480
476
  */
481
477
  interface CanDisableProps {
482
478
  /** Whether the action is allowed */
package/dist/index.js CHANGED
@@ -497,30 +497,27 @@ Badge.displayName = "Badge";
497
497
  // src/components/tabs.tsx
498
498
  var React10 = __toESM(require("react"));
499
499
  var import_jsx_runtime10 = require("react/jsx-runtime");
500
+ var TabsContext = React10.createContext(null);
500
501
  var Tabs = React10.forwardRef(
501
- ({ value, onValueChange, children, className, ...props }, ref) => {
502
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
503
- "div",
504
- {
505
- ref,
506
- className: cn("w-full", className),
507
- ...props,
508
- children: React10.Children.map(children, (child) => {
509
- if (React10.isValidElement(child)) {
510
- return React10.cloneElement(child, {
511
- selectedValue: value,
512
- onValueChange
513
- });
514
- }
515
- return child;
516
- })
517
- }
502
+ ({
503
+ value,
504
+ onValueChange,
505
+ children,
506
+ className,
507
+ // Explicitly omit component-specific props so they never reach the DOM (fixes React warnings)
508
+ selectedValue: _selectedValue,
509
+ ...props
510
+ }, ref) => {
511
+ const contextValue = React10.useMemo(
512
+ () => ({ value, onValueChange }),
513
+ [value, onValueChange]
518
514
  );
515
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(TabsContext.Provider, { value: contextValue, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { ref, className: cn("w-full", className), ...props, children }) });
519
516
  }
520
517
  );
521
518
  Tabs.displayName = "Tabs";
522
519
  var TabsList = React10.forwardRef(
523
- ({ children, className, selectedValue, onValueChange, ...props }, ref) => {
520
+ ({ children, className, ...props }, ref) => {
524
521
  return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
525
522
  "div",
526
523
  {
@@ -530,28 +527,26 @@ var TabsList = React10.forwardRef(
530
527
  className
531
528
  ),
532
529
  ...props,
533
- children: React10.Children.map(children, (child) => {
534
- if (React10.isValidElement(child)) {
535
- return React10.cloneElement(child, {
536
- selectedValue,
537
- onValueChange
538
- });
539
- }
540
- return child;
541
- })
530
+ children
542
531
  }
543
532
  );
544
533
  }
545
534
  );
546
535
  TabsList.displayName = "TabsList";
547
536
  var TabsTrigger = React10.forwardRef(
548
- ({ value, children, className, selectedValue, onValueChange, badge, disabled, ...props }, ref) => {
549
- const isActive = selectedValue === value;
537
+ ({ value, children, className, badge, disabled, ...props }, ref) => {
538
+ const context = React10.useContext(TabsContext);
539
+ const isActive = context?.value === value;
540
+ const handleClick = () => {
541
+ if (!disabled && context?.onValueChange) {
542
+ context.onValueChange(value);
543
+ }
544
+ };
550
545
  return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
551
546
  "button",
552
547
  {
553
548
  ref,
554
- onClick: () => !disabled && onValueChange?.(value),
549
+ onClick: handleClick,
555
550
  disabled,
556
551
  className: cn(
557
552
  "inline-flex items-center justify-center gap-2 px-4 py-2.5 text-sm font-medium rounded-lg transition-all duration-200",