@table-js/ui 0.0.1

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 ADDED
@@ -0,0 +1,35 @@
1
+ # @tablejs/ui
2
+
3
+ UI components for Table.js Smart TV applications.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @tablejs/ui @tablejs/core
9
+ ```
10
+
11
+ ## Components
12
+
13
+ - **Button** - Focusable button with variants
14
+ - **Card** - Content card with image and text
15
+ - **Shelf** - Netflix-style horizontal scrolling shelf
16
+ - **Modal** - Overlay modal with focus trap
17
+
18
+ ## Usage
19
+
20
+ ```tsx
21
+ import { Button, Card, Shelf } from '@tablejs/ui'
22
+
23
+ function HomePage() {
24
+ return (
25
+ <Shelf title="Popular Movies">
26
+ <Card title="Inception" image="/inception.jpg" />
27
+ <Card title="Interstellar" image="/interstellar.jpg" />
28
+ </Shelf>
29
+ )
30
+ }
31
+ ```
32
+
33
+ ## License
34
+
35
+ MIT
@@ -0,0 +1,38 @@
1
+ import * as react from 'react';
2
+ import { UseFocusableOptions } from '@table/core';
3
+ import * as react_jsx_runtime from 'react/jsx-runtime';
4
+
5
+ interface ButtonProps extends UseFocusableOptions {
6
+ children: React.ReactNode;
7
+ variant?: 'primary' | 'secondary' | 'ghost';
8
+ size?: 'sm' | 'md' | 'lg';
9
+ className?: string;
10
+ }
11
+ declare const Button: react.ForwardRefExoticComponent<ButtonProps & react.RefAttributes<HTMLButtonElement>>;
12
+
13
+ interface CardProps extends UseFocusableOptions {
14
+ title?: string;
15
+ subtitle?: string;
16
+ image?: string;
17
+ children?: React.ReactNode;
18
+ className?: string;
19
+ }
20
+ declare const Card: react.ForwardRefExoticComponent<CardProps & react.RefAttributes<HTMLDivElement>>;
21
+
22
+ interface ShelfProps {
23
+ title?: string;
24
+ children: React.ReactNode;
25
+ className?: string;
26
+ }
27
+ declare function Shelf({ title, children, className }: ShelfProps): react_jsx_runtime.JSX.Element;
28
+
29
+ interface ModalProps {
30
+ open: boolean;
31
+ onClose: () => void;
32
+ title?: string;
33
+ children: React.ReactNode;
34
+ className?: string;
35
+ }
36
+ declare function Modal({ open, onClose, title, children, className }: ModalProps): react_jsx_runtime.JSX.Element | null;
37
+
38
+ export { Button, Card, Modal, Shelf };
@@ -0,0 +1,38 @@
1
+ import * as react from 'react';
2
+ import { UseFocusableOptions } from '@table/core';
3
+ import * as react_jsx_runtime from 'react/jsx-runtime';
4
+
5
+ interface ButtonProps extends UseFocusableOptions {
6
+ children: React.ReactNode;
7
+ variant?: 'primary' | 'secondary' | 'ghost';
8
+ size?: 'sm' | 'md' | 'lg';
9
+ className?: string;
10
+ }
11
+ declare const Button: react.ForwardRefExoticComponent<ButtonProps & react.RefAttributes<HTMLButtonElement>>;
12
+
13
+ interface CardProps extends UseFocusableOptions {
14
+ title?: string;
15
+ subtitle?: string;
16
+ image?: string;
17
+ children?: React.ReactNode;
18
+ className?: string;
19
+ }
20
+ declare const Card: react.ForwardRefExoticComponent<CardProps & react.RefAttributes<HTMLDivElement>>;
21
+
22
+ interface ShelfProps {
23
+ title?: string;
24
+ children: React.ReactNode;
25
+ className?: string;
26
+ }
27
+ declare function Shelf({ title, children, className }: ShelfProps): react_jsx_runtime.JSX.Element;
28
+
29
+ interface ModalProps {
30
+ open: boolean;
31
+ onClose: () => void;
32
+ title?: string;
33
+ children: React.ReactNode;
34
+ className?: string;
35
+ }
36
+ declare function Modal({ open, onClose, title, children, className }: ModalProps): react_jsx_runtime.JSX.Element | null;
37
+
38
+ export { Button, Card, Modal, Shelf };
package/dist/index.js ADDED
@@ -0,0 +1,162 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ Button: () => Button,
24
+ Card: () => Card,
25
+ Modal: () => Modal,
26
+ Shelf: () => Shelf
27
+ });
28
+ module.exports = __toCommonJS(index_exports);
29
+
30
+ // src/components/Button.tsx
31
+ var import_react = require("react");
32
+ var import_core = require("@table/core");
33
+ var import_jsx_runtime = require("react/jsx-runtime");
34
+ var Button = (0, import_react.forwardRef)(
35
+ ({ children, variant = "primary", size = "md", className = "", ...focus }, ref) => {
36
+ const base = "rounded-lg font-semibold transition-all duration-150";
37
+ const variants = {
38
+ primary: "bg-indigo-600 text-white",
39
+ secondary: "bg-zinc-700 text-white",
40
+ ghost: "bg-transparent text-white"
41
+ };
42
+ const sizes = {
43
+ sm: "px-4 py-2 text-sm",
44
+ md: "px-6 py-3 text-base",
45
+ lg: "px-8 py-4 text-lg"
46
+ };
47
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.Focusable, { ...focus, children: (focused) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
48
+ "button",
49
+ {
50
+ ref,
51
+ className: ` ${base} ${variants[variant]} ${sizes[size]} ${focused ? "scale-105 ring-4 ring-white" : ""} ${className} `,
52
+ children
53
+ }
54
+ ) });
55
+ }
56
+ );
57
+ Button.displayName = "Button";
58
+
59
+ // src/components/Card.tsx
60
+ var import_react2 = require("react");
61
+ var import_core2 = require("@table/core");
62
+ var import_jsx_runtime2 = require("react/jsx-runtime");
63
+ var Card = (0, import_react2.forwardRef)(
64
+ ({ title, subtitle, image, children, className = "", ...focus }, ref) => {
65
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core2.Focusable, { ...focus, children: (focused) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
66
+ "div",
67
+ {
68
+ ref,
69
+ className: `overflow-hidden rounded-xl bg-zinc-800 transition-transform duration-150 ${focused ? "scale-105 ring-4 ring-white" : ""} ${className} `,
70
+ children: [
71
+ image && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "aspect-video w-full overflow-hidden", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("img", { src: image, alt: title, className: "h-full w-full object-cover" }) }),
72
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "p-4", children: [
73
+ title && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h3", { className: "mb-1 text-lg font-bold", children: title }),
74
+ subtitle && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "text-sm text-zinc-400", children: subtitle }),
75
+ children
76
+ ] })
77
+ ]
78
+ }
79
+ ) });
80
+ }
81
+ );
82
+ Card.displayName = "Card";
83
+
84
+ // src/components/Shelf.tsx
85
+ var import_react3 = require("react");
86
+ var import_core3 = require("@table/core");
87
+ var import_jsx_runtime3 = require("react/jsx-runtime");
88
+ function Shelf({ title, children, className = "" }) {
89
+ const ref = (0, import_react3.useRef)(null);
90
+ const [offset, setOffset] = (0, import_react3.useState)(0);
91
+ const { manager } = (0, import_core3.useFocusContext)();
92
+ (0, import_react3.useEffect)(() => {
93
+ const container = ref.current;
94
+ if (!container) return;
95
+ const update = () => {
96
+ const focused = container.querySelector('[data-focused="true"]');
97
+ if (!focused) return;
98
+ const rect = focused.getBoundingClientRect();
99
+ const containerRect = container.getBoundingClientRect();
100
+ const itemWidth = rect.width + 24;
101
+ if (rect.left < containerRect.left) {
102
+ setOffset((prev) => prev + itemWidth);
103
+ } else if (rect.right > containerRect.right) {
104
+ setOffset((prev) => prev - itemWidth);
105
+ }
106
+ };
107
+ const id = manager.getFocusedId();
108
+ if (id) update();
109
+ const interval = setInterval(update, 100);
110
+ return () => clearInterval(interval);
111
+ }, [manager]);
112
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className, children: [
113
+ title && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h2", { className: "mb-4 px-16 text-2xl font-bold", children: title }),
114
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "overflow-hidden px-16", ref, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_core3.FocusGroup, { orientation: "horizontal", loop: false, rememberFocus: false, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
115
+ "div",
116
+ {
117
+ className: "flex gap-6 transition-transform duration-300",
118
+ style: { transform: `translateX(${offset}px)` },
119
+ children
120
+ }
121
+ ) }) })
122
+ ] });
123
+ }
124
+
125
+ // src/components/Modal.tsx
126
+ var import_react4 = require("react");
127
+ var import_core4 = require("@table/core");
128
+ var import_jsx_runtime4 = require("react/jsx-runtime");
129
+ function Modal({ open, onClose, title, children, className = "" }) {
130
+ const { keyHandler } = (0, import_core4.useFocusContext)();
131
+ (0, import_react4.useEffect)(() => {
132
+ if (!open) return;
133
+ const unsub = keyHandler.subscribe((action) => {
134
+ if (action.type === "back") {
135
+ onClose();
136
+ }
137
+ });
138
+ return unsub;
139
+ }, [open, onClose, keyHandler]);
140
+ if (!open) return null;
141
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "fixed inset-0 z-50 flex items-center justify-center", children: [
142
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "absolute inset-0 bg-black/80", onClick: onClose }),
143
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
144
+ "div",
145
+ {
146
+ className: `relative z-10 w-full max-w-2xl rounded-2xl border border-zinc-700 bg-zinc-900 p-8 shadow-2xl ${className} `,
147
+ children: [
148
+ title && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("h2", { className: "mb-6 text-3xl font-bold", children: title }),
149
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_core4.FocusGroup, { orientation: "vertical", loop: false, rememberFocus: false, children })
150
+ ]
151
+ }
152
+ )
153
+ ] });
154
+ }
155
+ // Annotate the CommonJS export names for ESM import in node:
156
+ 0 && (module.exports = {
157
+ Button,
158
+ Card,
159
+ Modal,
160
+ Shelf
161
+ });
162
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/components/Button.tsx","../src/components/Card.tsx","../src/components/Shelf.tsx","../src/components/Modal.tsx"],"sourcesContent":["export { Button } from './components/Button'\nexport { Card } from './components/Card'\nexport { Shelf } from './components/Shelf'\nexport { Modal } from './components/Modal'\n","import { forwardRef } from 'react'\nimport { Focusable } from '@table/core'\nimport type { UseFocusableOptions } from '@table/core'\n\ninterface ButtonProps extends UseFocusableOptions {\n children: React.ReactNode\n variant?: 'primary' | 'secondary' | 'ghost'\n size?: 'sm' | 'md' | 'lg'\n className?: string\n}\n\nexport const Button = forwardRef<HTMLButtonElement, ButtonProps>(\n ({ children, variant = 'primary', size = 'md', className = '', ...focus }, ref) => {\n const base = 'rounded-lg font-semibold transition-all duration-150'\n\n const variants = {\n primary: 'bg-indigo-600 text-white',\n secondary: 'bg-zinc-700 text-white',\n ghost: 'bg-transparent text-white',\n }\n\n const sizes = {\n sm: 'px-4 py-2 text-sm',\n md: 'px-6 py-3 text-base',\n lg: 'px-8 py-4 text-lg',\n }\n\n return (\n <Focusable {...focus}>\n {(focused) => (\n <button\n ref={ref as never}\n className={` ${base} ${variants[variant]} ${sizes[size]} ${focused ? 'scale-105 ring-4 ring-white' : ''} ${className} `}\n >\n {children}\n </button>\n )}\n </Focusable>\n )\n },\n)\n\nButton.displayName = 'Button'\n","import { forwardRef } from 'react'\nimport { Focusable } from '@table/core'\nimport type { UseFocusableOptions } from '@table/core'\n\ninterface CardProps extends UseFocusableOptions {\n title?: string\n subtitle?: string\n image?: string\n children?: React.ReactNode\n className?: string\n}\n\nexport const Card = forwardRef<HTMLDivElement, CardProps>(\n ({ title, subtitle, image, children, className = '', ...focus }, ref) => {\n return (\n <Focusable {...focus}>\n {(focused) => (\n <div\n ref={ref as never}\n className={`overflow-hidden rounded-xl bg-zinc-800 transition-transform duration-150 ${focused ? 'scale-105 ring-4 ring-white' : ''} ${className} `}\n >\n {image && (\n <div className=\"aspect-video w-full overflow-hidden\">\n <img src={image} alt={title} className=\"h-full w-full object-cover\" />\n </div>\n )}\n <div className=\"p-4\">\n {title && <h3 className=\"mb-1 text-lg font-bold\">{title}</h3>}\n {subtitle && <p className=\"text-sm text-zinc-400\">{subtitle}</p>}\n {children}\n </div>\n </div>\n )}\n </Focusable>\n )\n },\n)\n\nCard.displayName = 'Card'\n","import { useRef, useEffect, useState } from 'react'\nimport { FocusGroup, useFocusContext } from '@table/core'\n\ninterface ShelfProps {\n title?: string\n children: React.ReactNode\n className?: string\n}\n\nexport function Shelf({ title, children, className = '' }: ShelfProps) {\n const ref = useRef<HTMLDivElement>(null)\n const [offset, setOffset] = useState(0)\n const { manager } = useFocusContext()\n\n useEffect(() => {\n const container = ref.current\n if (!container) return\n\n const update = () => {\n const focused = container.querySelector('[data-focused=\"true\"]')\n if (!focused) return\n\n const rect = focused.getBoundingClientRect()\n const containerRect = container.getBoundingClientRect()\n const itemWidth = rect.width + 24\n\n if (rect.left < containerRect.left) {\n setOffset((prev) => prev + itemWidth)\n } else if (rect.right > containerRect.right) {\n setOffset((prev) => prev - itemWidth)\n }\n }\n\n const id = manager.getFocusedId()\n if (id) update()\n\n const interval = setInterval(update, 100)\n return () => clearInterval(interval)\n }, [manager])\n\n return (\n <div className={className}>\n {title && <h2 className=\"mb-4 px-16 text-2xl font-bold\">{title}</h2>}\n <div className=\"overflow-hidden px-16\" ref={ref}>\n <FocusGroup orientation=\"horizontal\" loop={false} rememberFocus={false}>\n <div\n className=\"flex gap-6 transition-transform duration-300\"\n style={{ transform: `translateX(${offset}px)` }}\n >\n {children}\n </div>\n </FocusGroup>\n </div>\n </div>\n )\n}\n","import { useEffect } from 'react'\nimport { FocusGroup, useFocusContext } from '@table/core'\n\ninterface ModalProps {\n open: boolean\n onClose: () => void\n title?: string\n children: React.ReactNode\n className?: string\n}\n\nexport function Modal({ open, onClose, title, children, className = '' }: ModalProps) {\n const { keyHandler } = useFocusContext()\n\n useEffect(() => {\n if (!open) return\n\n const unsub = keyHandler.subscribe((action) => {\n if (action.type === 'back') {\n onClose()\n }\n })\n\n return unsub\n }, [open, onClose, keyHandler])\n\n if (!open) return null\n\n return (\n <div className=\"fixed inset-0 z-50 flex items-center justify-center\">\n <div className=\"absolute inset-0 bg-black/80\" onClick={onClose} />\n <div\n className={`relative z-10 w-full max-w-2xl rounded-2xl border border-zinc-700 bg-zinc-900 p-8 shadow-2xl ${className} `}\n >\n {title && <h2 className=\"mb-6 text-3xl font-bold\">{title}</h2>}\n <FocusGroup orientation=\"vertical\" loop={false} rememberFocus={false}>\n {children}\n </FocusGroup>\n </div>\n </div>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAA2B;AAC3B,kBAA0B;AA6BhB;AAnBH,IAAM,aAAS;AAAA,EACpB,CAAC,EAAE,UAAU,UAAU,WAAW,OAAO,MAAM,YAAY,IAAI,GAAG,MAAM,GAAG,QAAQ;AACjF,UAAM,OAAO;AAEb,UAAM,WAAW;AAAA,MACf,SAAS;AAAA,MACT,WAAW;AAAA,MACX,OAAO;AAAA,IACT;AAEA,UAAM,QAAQ;AAAA,MACZ,IAAI;AAAA,MACJ,IAAI;AAAA,MACJ,IAAI;AAAA,IACN;AAEA,WACE,4CAAC,yBAAW,GAAG,OACZ,WAAC,YACA;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA,WAAW,IAAI,IAAI,IAAI,SAAS,OAAO,CAAC,IAAI,MAAM,IAAI,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AAA,QACC,WAAW,gGAAgG,SAAS;AAAA,QAEnH;AAAA,mBAAS,6CAAC,QAAG,WAAU,2BAA2B,iBAAM;AAAA,UACzD,6CAAC,2BAAW,aAAY,YAAW,MAAM,OAAO,eAAe,OAC5D,UACH;AAAA;AAAA;AAAA,IACF;AAAA,KACF;AAEJ;","names":["import_react","import_core","import_jsx_runtime","import_react","import_core","import_jsx_runtime","import_react","import_core","import_jsx_runtime"]}
package/dist/index.mjs ADDED
@@ -0,0 +1,132 @@
1
+ // src/components/Button.tsx
2
+ import { forwardRef } from "react";
3
+ import { Focusable } from "@table/core";
4
+ import { jsx } from "react/jsx-runtime";
5
+ var Button = forwardRef(
6
+ ({ children, variant = "primary", size = "md", className = "", ...focus }, ref) => {
7
+ const base = "rounded-lg font-semibold transition-all duration-150";
8
+ const variants = {
9
+ primary: "bg-indigo-600 text-white",
10
+ secondary: "bg-zinc-700 text-white",
11
+ ghost: "bg-transparent text-white"
12
+ };
13
+ const sizes = {
14
+ sm: "px-4 py-2 text-sm",
15
+ md: "px-6 py-3 text-base",
16
+ lg: "px-8 py-4 text-lg"
17
+ };
18
+ return /* @__PURE__ */ jsx(Focusable, { ...focus, children: (focused) => /* @__PURE__ */ jsx(
19
+ "button",
20
+ {
21
+ ref,
22
+ className: ` ${base} ${variants[variant]} ${sizes[size]} ${focused ? "scale-105 ring-4 ring-white" : ""} ${className} `,
23
+ children
24
+ }
25
+ ) });
26
+ }
27
+ );
28
+ Button.displayName = "Button";
29
+
30
+ // src/components/Card.tsx
31
+ import { forwardRef as forwardRef2 } from "react";
32
+ import { Focusable as Focusable2 } from "@table/core";
33
+ import { jsx as jsx2, jsxs } from "react/jsx-runtime";
34
+ var Card = forwardRef2(
35
+ ({ title, subtitle, image, children, className = "", ...focus }, ref) => {
36
+ return /* @__PURE__ */ jsx2(Focusable2, { ...focus, children: (focused) => /* @__PURE__ */ jsxs(
37
+ "div",
38
+ {
39
+ ref,
40
+ className: `overflow-hidden rounded-xl bg-zinc-800 transition-transform duration-150 ${focused ? "scale-105 ring-4 ring-white" : ""} ${className} `,
41
+ children: [
42
+ image && /* @__PURE__ */ jsx2("div", { className: "aspect-video w-full overflow-hidden", children: /* @__PURE__ */ jsx2("img", { src: image, alt: title, className: "h-full w-full object-cover" }) }),
43
+ /* @__PURE__ */ jsxs("div", { className: "p-4", children: [
44
+ title && /* @__PURE__ */ jsx2("h3", { className: "mb-1 text-lg font-bold", children: title }),
45
+ subtitle && /* @__PURE__ */ jsx2("p", { className: "text-sm text-zinc-400", children: subtitle }),
46
+ children
47
+ ] })
48
+ ]
49
+ }
50
+ ) });
51
+ }
52
+ );
53
+ Card.displayName = "Card";
54
+
55
+ // src/components/Shelf.tsx
56
+ import { useRef, useEffect, useState } from "react";
57
+ import { FocusGroup, useFocusContext } from "@table/core";
58
+ import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
59
+ function Shelf({ title, children, className = "" }) {
60
+ const ref = useRef(null);
61
+ const [offset, setOffset] = useState(0);
62
+ const { manager } = useFocusContext();
63
+ useEffect(() => {
64
+ const container = ref.current;
65
+ if (!container) return;
66
+ const update = () => {
67
+ const focused = container.querySelector('[data-focused="true"]');
68
+ if (!focused) return;
69
+ const rect = focused.getBoundingClientRect();
70
+ const containerRect = container.getBoundingClientRect();
71
+ const itemWidth = rect.width + 24;
72
+ if (rect.left < containerRect.left) {
73
+ setOffset((prev) => prev + itemWidth);
74
+ } else if (rect.right > containerRect.right) {
75
+ setOffset((prev) => prev - itemWidth);
76
+ }
77
+ };
78
+ const id = manager.getFocusedId();
79
+ if (id) update();
80
+ const interval = setInterval(update, 100);
81
+ return () => clearInterval(interval);
82
+ }, [manager]);
83
+ return /* @__PURE__ */ jsxs2("div", { className, children: [
84
+ title && /* @__PURE__ */ jsx3("h2", { className: "mb-4 px-16 text-2xl font-bold", children: title }),
85
+ /* @__PURE__ */ jsx3("div", { className: "overflow-hidden px-16", ref, children: /* @__PURE__ */ jsx3(FocusGroup, { orientation: "horizontal", loop: false, rememberFocus: false, children: /* @__PURE__ */ jsx3(
86
+ "div",
87
+ {
88
+ className: "flex gap-6 transition-transform duration-300",
89
+ style: { transform: `translateX(${offset}px)` },
90
+ children
91
+ }
92
+ ) }) })
93
+ ] });
94
+ }
95
+
96
+ // src/components/Modal.tsx
97
+ import { useEffect as useEffect2 } from "react";
98
+ import { FocusGroup as FocusGroup2, useFocusContext as useFocusContext2 } from "@table/core";
99
+ import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
100
+ function Modal({ open, onClose, title, children, className = "" }) {
101
+ const { keyHandler } = useFocusContext2();
102
+ useEffect2(() => {
103
+ if (!open) return;
104
+ const unsub = keyHandler.subscribe((action) => {
105
+ if (action.type === "back") {
106
+ onClose();
107
+ }
108
+ });
109
+ return unsub;
110
+ }, [open, onClose, keyHandler]);
111
+ if (!open) return null;
112
+ return /* @__PURE__ */ jsxs3("div", { className: "fixed inset-0 z-50 flex items-center justify-center", children: [
113
+ /* @__PURE__ */ jsx4("div", { className: "absolute inset-0 bg-black/80", onClick: onClose }),
114
+ /* @__PURE__ */ jsxs3(
115
+ "div",
116
+ {
117
+ className: `relative z-10 w-full max-w-2xl rounded-2xl border border-zinc-700 bg-zinc-900 p-8 shadow-2xl ${className} `,
118
+ children: [
119
+ title && /* @__PURE__ */ jsx4("h2", { className: "mb-6 text-3xl font-bold", children: title }),
120
+ /* @__PURE__ */ jsx4(FocusGroup2, { orientation: "vertical", loop: false, rememberFocus: false, children })
121
+ ]
122
+ }
123
+ )
124
+ ] });
125
+ }
126
+ export {
127
+ Button,
128
+ Card,
129
+ Modal,
130
+ Shelf
131
+ };
132
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/Button.tsx","../src/components/Card.tsx","../src/components/Shelf.tsx","../src/components/Modal.tsx"],"sourcesContent":["import { forwardRef } from 'react'\nimport { Focusable } from '@table/core'\nimport type { UseFocusableOptions } from '@table/core'\n\ninterface ButtonProps extends UseFocusableOptions {\n children: React.ReactNode\n variant?: 'primary' | 'secondary' | 'ghost'\n size?: 'sm' | 'md' | 'lg'\n className?: string\n}\n\nexport const Button = forwardRef<HTMLButtonElement, ButtonProps>(\n ({ children, variant = 'primary', size = 'md', className = '', ...focus }, ref) => {\n const base = 'rounded-lg font-semibold transition-all duration-150'\n\n const variants = {\n primary: 'bg-indigo-600 text-white',\n secondary: 'bg-zinc-700 text-white',\n ghost: 'bg-transparent text-white',\n }\n\n const sizes = {\n sm: 'px-4 py-2 text-sm',\n md: 'px-6 py-3 text-base',\n lg: 'px-8 py-4 text-lg',\n }\n\n return (\n <Focusable {...focus}>\n {(focused) => (\n <button\n ref={ref as never}\n className={` ${base} ${variants[variant]} ${sizes[size]} ${focused ? 'scale-105 ring-4 ring-white' : ''} ${className} `}\n >\n {children}\n </button>\n )}\n </Focusable>\n )\n },\n)\n\nButton.displayName = 'Button'\n","import { forwardRef } from 'react'\nimport { Focusable } from '@table/core'\nimport type { UseFocusableOptions } from '@table/core'\n\ninterface CardProps extends UseFocusableOptions {\n title?: string\n subtitle?: string\n image?: string\n children?: React.ReactNode\n className?: string\n}\n\nexport const Card = forwardRef<HTMLDivElement, CardProps>(\n ({ title, subtitle, image, children, className = '', ...focus }, ref) => {\n return (\n <Focusable {...focus}>\n {(focused) => (\n <div\n ref={ref as never}\n className={`overflow-hidden rounded-xl bg-zinc-800 transition-transform duration-150 ${focused ? 'scale-105 ring-4 ring-white' : ''} ${className} `}\n >\n {image && (\n <div className=\"aspect-video w-full overflow-hidden\">\n <img src={image} alt={title} className=\"h-full w-full object-cover\" />\n </div>\n )}\n <div className=\"p-4\">\n {title && <h3 className=\"mb-1 text-lg font-bold\">{title}</h3>}\n {subtitle && <p className=\"text-sm text-zinc-400\">{subtitle}</p>}\n {children}\n </div>\n </div>\n )}\n </Focusable>\n )\n },\n)\n\nCard.displayName = 'Card'\n","import { useRef, useEffect, useState } from 'react'\nimport { FocusGroup, useFocusContext } from '@table/core'\n\ninterface ShelfProps {\n title?: string\n children: React.ReactNode\n className?: string\n}\n\nexport function Shelf({ title, children, className = '' }: ShelfProps) {\n const ref = useRef<HTMLDivElement>(null)\n const [offset, setOffset] = useState(0)\n const { manager } = useFocusContext()\n\n useEffect(() => {\n const container = ref.current\n if (!container) return\n\n const update = () => {\n const focused = container.querySelector('[data-focused=\"true\"]')\n if (!focused) return\n\n const rect = focused.getBoundingClientRect()\n const containerRect = container.getBoundingClientRect()\n const itemWidth = rect.width + 24\n\n if (rect.left < containerRect.left) {\n setOffset((prev) => prev + itemWidth)\n } else if (rect.right > containerRect.right) {\n setOffset((prev) => prev - itemWidth)\n }\n }\n\n const id = manager.getFocusedId()\n if (id) update()\n\n const interval = setInterval(update, 100)\n return () => clearInterval(interval)\n }, [manager])\n\n return (\n <div className={className}>\n {title && <h2 className=\"mb-4 px-16 text-2xl font-bold\">{title}</h2>}\n <div className=\"overflow-hidden px-16\" ref={ref}>\n <FocusGroup orientation=\"horizontal\" loop={false} rememberFocus={false}>\n <div\n className=\"flex gap-6 transition-transform duration-300\"\n style={{ transform: `translateX(${offset}px)` }}\n >\n {children}\n </div>\n </FocusGroup>\n </div>\n </div>\n )\n}\n","import { useEffect } from 'react'\nimport { FocusGroup, useFocusContext } from '@table/core'\n\ninterface ModalProps {\n open: boolean\n onClose: () => void\n title?: string\n children: React.ReactNode\n className?: string\n}\n\nexport function Modal({ open, onClose, title, children, className = '' }: ModalProps) {\n const { keyHandler } = useFocusContext()\n\n useEffect(() => {\n if (!open) return\n\n const unsub = keyHandler.subscribe((action) => {\n if (action.type === 'back') {\n onClose()\n }\n })\n\n return unsub\n }, [open, onClose, keyHandler])\n\n if (!open) return null\n\n return (\n <div className=\"fixed inset-0 z-50 flex items-center justify-center\">\n <div className=\"absolute inset-0 bg-black/80\" onClick={onClose} />\n <div\n className={`relative z-10 w-full max-w-2xl rounded-2xl border border-zinc-700 bg-zinc-900 p-8 shadow-2xl ${className} `}\n >\n {title && <h2 className=\"mb-6 text-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cAAW,aAAY,cAAa,MAAM,OAAO,eAAe,OAC/D,0BAAAA;AAAA,MAAC;AAAA;AAAA,QACC,WAAU;AAAA,QACV,OAAO,EAAE,WAAW,cAAc,MAAM,MAAM;AAAA,QAE7C;AAAA;AAAA,IACH,GACF,GACF;AAAA,KACF;AAEJ;;;ACvDA,SAAS,aAAAE,kBAAiB;AAC1B,SAAS,cAAAC,aAAY,mBAAAC,wBAAuB;AA6BtC,gBAAAC,MACA,QAAAC,aADA;AAnBC,SAAS,MAAM,EAAE,MAAM,SAAS,OAAO,UAAU,YAAY,GAAG,GAAe;AACpF,QAAM,EAAE,WAAW,IAAIF,iBAAgB;AAEvC,EAAAF,WAAU,MAAM;AACd,QAAI,CAAC,KAAM;AAEX,UAAM,QAAQ,WAAW,UAAU,CAAC,WAAW;AAC7C,UAAI,OAAO,SAAS,QAAQ;AAC1B,gBAAQ;AAAA,MACV;AAAA,IACF,CAAC;AAED,WAAO;AAAA,EACT,GAAG,CAAC,MAAM,SAAS,UAAU,CAAC;AAE9B,MAAI,CAAC,KAAM,QAAO;AAElB,SACE,gBAAAI,MAAC,SAAI,WAAU,uDACb;AAAA,oBAAAD,KAAC,SAAI,WAAU,gCAA+B,SAAS,SAAS;AAAA,IAChE,gBAAAC;AAAA,MAAC;AAAA;AAAA,QACC,WAAW,gGAAgG,SAAS;AAAA,QAEnH;AAAA,mBAAS,gBAAAD,KAAC,QAAG,WAAU,2BAA2B,iBAAM;AAAA,UACzD,gBAAAA,KAACF,aAAA,EAAW,aAAY,YAAW,MAAM,OAAO,eAAe,OAC5D,UACH;AAAA;AAAA;AAAA,IACF;AAAA,KACF;AAEJ;","names":["forwardRef","Focusable","jsx","jsx","jsxs","useEffect","FocusGroup","useFocusContext","jsx","jsxs"]}
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@table-js/ui",
3
+ "version": "0.0.1",
4
+ "description": "Table.js UI components for Smart TV",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.mjs",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.mjs",
11
+ "require": "./dist/index.js",
12
+ "types": "./dist/index.d.ts"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "scripts": {
19
+ "build": "tsup",
20
+ "dev": "tsup --watch",
21
+ "typecheck": "tsc --noEmit",
22
+ "clean": "rm -rf dist"
23
+ },
24
+ "keywords": [
25
+ "smart-tv",
26
+ "ui",
27
+ "components",
28
+ "react",
29
+ "tizen",
30
+ "webos"
31
+ ],
32
+ "author": "Table.js Team",
33
+ "license": "MIT",
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "https://github.com/tablejs/tablejs"
37
+ },
38
+ "devDependencies": {
39
+ "@table/tsconfig": "workspace:*",
40
+ "@types/react": "^19.2.14",
41
+ "@types/react-dom": "^19.2.3",
42
+ "tsup": "^8.0.1",
43
+ "typescript": "^5.3.3"
44
+ },
45
+ "peerDependencies": {
46
+ "@table-js/core": "^0.0.1",
47
+ "react": "^18.0.0 || ^19.0.0",
48
+ "react-dom": "^18.0.0 || ^19.0.0"
49
+ }
50
+ }