@asnewyla/tabs 0.2.0
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/LICENSE +21 -0
- package/README.md +67 -0
- package/dist/index.css +55 -0
- package/dist/index.css.map +1 -0
- package/dist/index.d.mts +26 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.js +60 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +55 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +63 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 XD
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# @asnewyla/tabs
|
|
2
|
+
|
|
3
|
+
Styled tabs built on `@asnewyla/unstyled-tabs`. Compound components, an
|
|
4
|
+
underline active-tab indicator, and full keyboard/focus accessibility.
|
|
5
|
+
|
|
6
|
+
## Install
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
npm install @asnewyla/tabs
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Import the stylesheet once, anywhere in your app:
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
import '@asnewyla/tabs/styles.css';
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
```tsx
|
|
21
|
+
import { Tab, TabList, TabPanel, Tabs } from '@asnewyla/tabs';
|
|
22
|
+
|
|
23
|
+
// Uncontrolled
|
|
24
|
+
<Tabs defaultValue="profile">
|
|
25
|
+
<TabList aria-label="Account settings">
|
|
26
|
+
<Tab value="profile">Profile</Tab>
|
|
27
|
+
<Tab value="settings">Settings</Tab>
|
|
28
|
+
<Tab value="billing" disabled>Billing</Tab>
|
|
29
|
+
</TabList>
|
|
30
|
+
<TabPanel value="profile">Profile content</TabPanel>
|
|
31
|
+
<TabPanel value="settings">Settings content</TabPanel>
|
|
32
|
+
<TabPanel value="billing">Billing content</TabPanel>
|
|
33
|
+
</Tabs>
|
|
34
|
+
|
|
35
|
+
// Controlled
|
|
36
|
+
<Tabs value={active} onValueChange={setActive}>
|
|
37
|
+
...
|
|
38
|
+
</Tabs>
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Props
|
|
42
|
+
|
|
43
|
+
Every prop is `@asnewyla/unstyled-tabs`'s own — `Tabs`/`TabList`/`Tab`/
|
|
44
|
+
`TabPanel` each add no props of their own; `className` merges with each
|
|
45
|
+
piece's base class (`xd-tabs`, `xd-tab-list`, `xd-tab`, `xd-tab-panel`,
|
|
46
|
+
base class first), the same convention every styled component in this
|
|
47
|
+
library follows. See `@asnewyla/unstyled-tabs`'s README for the full
|
|
48
|
+
component/keyboard/accessibility contract — sorting, disabled tabs,
|
|
49
|
+
`ArrowLeft`/`ArrowRight`/`Home`/`End` behavior, and the `aria-controls`/
|
|
50
|
+
`aria-labelledby` wiring are all unchanged here.
|
|
51
|
+
|
|
52
|
+
### Theming
|
|
53
|
+
|
|
54
|
+
Override the CSS custom properties — defaults adapt automatically to
|
|
55
|
+
`prefers-color-scheme` via `@asnewyla/tokens`:
|
|
56
|
+
|
|
57
|
+
```css
|
|
58
|
+
:root {
|
|
59
|
+
--xd-color-primary: #0d9488;
|
|
60
|
+
--xd-color-border: #cbd5e1;
|
|
61
|
+
--xd-color-text-muted: #475569;
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## License
|
|
66
|
+
|
|
67
|
+
MIT
|
package/dist/index.css
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/* src/components/Tabs.css */
|
|
2
|
+
.xd-tabs {
|
|
3
|
+
display: flex;
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
gap: var(--xd-space-md, 0.5rem);
|
|
6
|
+
}
|
|
7
|
+
.xd-tab-list {
|
|
8
|
+
display: flex;
|
|
9
|
+
gap: var(--xd-space-sm, 0.375rem);
|
|
10
|
+
border-bottom: var(--xd-border-width-thin, 1px) solid var(--xd-color-border, #cbd5e1);
|
|
11
|
+
}
|
|
12
|
+
.xd-tab {
|
|
13
|
+
position: relative;
|
|
14
|
+
margin-bottom: -1px;
|
|
15
|
+
padding: var(--xd-space-sm, 0.375rem) var(--xd-space-md, 0.5rem);
|
|
16
|
+
border: none;
|
|
17
|
+
border-bottom: var(--xd-border-width-thick, 2px) solid transparent;
|
|
18
|
+
background: transparent;
|
|
19
|
+
font-family: inherit;
|
|
20
|
+
font-size: var(--xd-font-size-md, 0.875rem);
|
|
21
|
+
font-weight: var(--xd-font-weight-medium, 500);
|
|
22
|
+
color: var(--xd-color-text-muted, #475569);
|
|
23
|
+
cursor: pointer;
|
|
24
|
+
transition: color var(--xd-motion-fast, 120ms ease-out), border-color var(--xd-motion-fast, 120ms ease-out);
|
|
25
|
+
}
|
|
26
|
+
.xd-tab:hover:not(:disabled) {
|
|
27
|
+
color: var(--xd-color-text, #0f172a);
|
|
28
|
+
}
|
|
29
|
+
.xd-tab[aria-selected=true] {
|
|
30
|
+
color: var(--xd-color-primary, #0d9488);
|
|
31
|
+
border-bottom-color: var(--xd-color-primary, #0d9488);
|
|
32
|
+
}
|
|
33
|
+
.xd-tab:focus-visible {
|
|
34
|
+
outline: var(--xd-focus-ring-width, 2px) solid var(--xd-color-focus, var(--xd-color-primary, #0d9488));
|
|
35
|
+
outline-offset: -2px;
|
|
36
|
+
}
|
|
37
|
+
.xd-tab:disabled {
|
|
38
|
+
opacity: var(--xd-opacity-disabled, 0.5);
|
|
39
|
+
cursor: not-allowed;
|
|
40
|
+
}
|
|
41
|
+
.xd-tab-panel {
|
|
42
|
+
font-size: var(--xd-font-size-md, 0.875rem);
|
|
43
|
+
line-height: var(--xd-line-height-normal, 1.25);
|
|
44
|
+
color: var(--xd-color-text, #0f172a);
|
|
45
|
+
}
|
|
46
|
+
.xd-tab-panel:focus-visible {
|
|
47
|
+
outline: var(--xd-focus-ring-width, 2px) solid var(--xd-color-focus, var(--xd-color-primary, #0d9488));
|
|
48
|
+
outline-offset: var(--xd-focus-ring-offset, 2px);
|
|
49
|
+
}
|
|
50
|
+
@media (prefers-reduced-motion: reduce) {
|
|
51
|
+
.xd-tab {
|
|
52
|
+
transition-duration: 1ms;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/*# sourceMappingURL=index.css.map */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/Tabs.css"],"sourcesContent":[".xd-tabs {\n display: flex;\n flex-direction: column;\n gap: var(--xd-space-md, 0.5rem);\n}\n\n.xd-tab-list {\n display: flex;\n gap: var(--xd-space-sm, 0.375rem);\n border-bottom: var(--xd-border-width-thin, 1px) solid\n var(--xd-color-border, #cbd5e1);\n}\n\n.xd-tab {\n position: relative;\n /* Sits flush against the tablist's own border, so the active tab's\n indicator below overlaps it exactly at the seam instead of leaving\n a visible gap or double line. */\n margin-bottom: -1px;\n padding: var(--xd-space-sm, 0.375rem) var(--xd-space-md, 0.5rem);\n border: none;\n border-bottom: var(--xd-border-width-thick, 2px) solid transparent;\n background: transparent;\n font-family: inherit;\n font-size: var(--xd-font-size-md, 0.875rem);\n font-weight: var(--xd-font-weight-medium, 500);\n color: var(--xd-color-text-muted, #475569);\n cursor: pointer;\n transition:\n color var(--xd-motion-fast, 120ms ease-out),\n border-color var(--xd-motion-fast, 120ms ease-out);\n}\n\n.xd-tab:hover:not(:disabled) {\n color: var(--xd-color-text, #0f172a);\n}\n\n.xd-tab[aria-selected=\"true\"] {\n color: var(--xd-color-primary, #0d9488);\n border-bottom-color: var(--xd-color-primary, #0d9488);\n}\n\n.xd-tab:focus-visible {\n outline: var(--xd-focus-ring-width, 2px) solid\n var(--xd-color-focus, var(--xd-color-primary, #0d9488));\n outline-offset: -2px;\n}\n\n.xd-tab:disabled {\n opacity: var(--xd-opacity-disabled, 0.5);\n cursor: not-allowed;\n}\n\n.xd-tab-panel {\n font-size: var(--xd-font-size-md, 0.875rem);\n line-height: var(--xd-line-height-normal, 1.25);\n color: var(--xd-color-text, #0f172a);\n}\n\n.xd-tab-panel:focus-visible {\n outline: var(--xd-focus-ring-width, 2px) solid\n var(--xd-color-focus, var(--xd-color-primary, #0d9488));\n outline-offset: var(--xd-focus-ring-offset, 2px);\n}\n\n/* --- Motion preference --- */\n\n@media (prefers-reduced-motion: reduce) {\n .xd-tab {\n transition-duration: 1ms;\n }\n}\n"],"mappings":";AAAA,CAAC;AACC,WAAS;AACT,kBAAgB;AAChB,OAAK,IAAI,aAAa,EAAE;AAC1B;AAEA,CAAC;AACC,WAAS;AACT,OAAK,IAAI,aAAa,EAAE;AACxB,iBAAe,IAAI,sBAAsB,EAAE,KAAK,MAC9C,IAAI,iBAAiB,EAAE;AAC3B;AAEA,CAAC;AACC,YAAU;AAIV,iBAAe;AACf,WAAS,IAAI,aAAa,EAAE,UAAU,IAAI,aAAa,EAAE;AACzD,UAAQ;AACR,iBAAe,IAAI,uBAAuB,EAAE,KAAK,MAAM;AACvD,cAAY;AACZ,eAAa;AACb,aAAW,IAAI,iBAAiB,EAAE;AAClC,eAAa,IAAI,uBAAuB,EAAE;AAC1C,SAAO,IAAI,qBAAqB,EAAE;AAClC,UAAQ;AACR,cACE,MAAM,IAAI,gBAAgB,EAAE,MAAM,SAAS,EAC3C,aAAa,IAAI,gBAAgB,EAAE,MAAM;AAC7C;AAEA,CApBC,MAoBM,MAAM,KAAK;AAChB,SAAO,IAAI,eAAe,EAAE;AAC9B;AAEA,CAxBC,MAwBM,CAAC;AACN,SAAO,IAAI,kBAAkB,EAAE;AAC/B,uBAAqB,IAAI,kBAAkB,EAAE;AAC/C;AAEA,CA7BC,MA6BM;AACL,WAAS,IAAI,qBAAqB,EAAE,KAAK,MACvC,IAAI,gBAAgB,EAAE,IAAI,kBAAkB,EAAE;AAChD,kBAAgB;AAClB;AAEA,CAnCC,MAmCM;AACL,WAAS,IAAI,qBAAqB,EAAE;AACpC,UAAQ;AACV;AAEA,CAAC;AACC,aAAW,IAAI,iBAAiB,EAAE;AAClC,eAAa,IAAI,uBAAuB,EAAE;AAC1C,SAAO,IAAI,eAAe,EAAE;AAC9B;AAEA,CANC,YAMY;AACX,WAAS,IAAI,qBAAqB,EAAE,KAAK,MACvC,IAAI,gBAAgB,EAAE,IAAI,kBAAkB,EAAE;AAChD,kBAAgB,IAAI,sBAAsB,EAAE;AAC9C;AAIA,QAAO,wBAAyB;AAC9B,GAvDD;AAwDG,yBAAqB;AACvB;AACF;","names":[]}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { TabProps as TabProps$1, TabListProps as TabListProps$1, TabPanelProps as TabPanelProps$1, TabsProps as TabsProps$1 } from '@asnewyla/unstyled-tabs';
|
|
3
|
+
|
|
4
|
+
type TabProps = TabProps$1;
|
|
5
|
+
declare const Tab: react.ForwardRefExoticComponent<{
|
|
6
|
+
value: string;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
} & Omit<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref">, "disabled" | "type" | "value" | "role"> & react.RefAttributes<HTMLButtonElement>>;
|
|
9
|
+
|
|
10
|
+
type TabListProps = TabListProps$1;
|
|
11
|
+
declare const TabList: react.ForwardRefExoticComponent<TabListProps$1 & react.RefAttributes<HTMLDivElement>>;
|
|
12
|
+
|
|
13
|
+
type TabPanelProps = TabPanelProps$1;
|
|
14
|
+
declare const TabPanel: react.ForwardRefExoticComponent<{
|
|
15
|
+
value: string;
|
|
16
|
+
} & Omit<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "role"> & react.RefAttributes<HTMLDivElement>>;
|
|
17
|
+
|
|
18
|
+
type TabsProps = TabsProps$1;
|
|
19
|
+
declare const Tabs: react.ForwardRefExoticComponent<{
|
|
20
|
+
value?: string;
|
|
21
|
+
defaultValue?: string;
|
|
22
|
+
onValueChange?: (value: string) => void;
|
|
23
|
+
children: react.ReactNode;
|
|
24
|
+
} & Omit<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "defaultValue" | "children" | "onChange"> & react.RefAttributes<HTMLDivElement>>;
|
|
25
|
+
|
|
26
|
+
export { Tab, TabList, type TabListProps, TabPanel, type TabPanelProps, type TabProps, Tabs, type TabsProps };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { TabProps as TabProps$1, TabListProps as TabListProps$1, TabPanelProps as TabPanelProps$1, TabsProps as TabsProps$1 } from '@asnewyla/unstyled-tabs';
|
|
3
|
+
|
|
4
|
+
type TabProps = TabProps$1;
|
|
5
|
+
declare const Tab: react.ForwardRefExoticComponent<{
|
|
6
|
+
value: string;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
} & Omit<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref">, "disabled" | "type" | "value" | "role"> & react.RefAttributes<HTMLButtonElement>>;
|
|
9
|
+
|
|
10
|
+
type TabListProps = TabListProps$1;
|
|
11
|
+
declare const TabList: react.ForwardRefExoticComponent<TabListProps$1 & react.RefAttributes<HTMLDivElement>>;
|
|
12
|
+
|
|
13
|
+
type TabPanelProps = TabPanelProps$1;
|
|
14
|
+
declare const TabPanel: react.ForwardRefExoticComponent<{
|
|
15
|
+
value: string;
|
|
16
|
+
} & Omit<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "role"> & react.RefAttributes<HTMLDivElement>>;
|
|
17
|
+
|
|
18
|
+
type TabsProps = TabsProps$1;
|
|
19
|
+
declare const Tabs: react.ForwardRefExoticComponent<{
|
|
20
|
+
value?: string;
|
|
21
|
+
defaultValue?: string;
|
|
22
|
+
onValueChange?: (value: string) => void;
|
|
23
|
+
children: react.ReactNode;
|
|
24
|
+
} & Omit<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "defaultValue" | "children" | "onChange"> & react.RefAttributes<HTMLDivElement>>;
|
|
25
|
+
|
|
26
|
+
export { Tab, TabList, type TabListProps, TabPanel, type TabPanelProps, type TabProps, Tabs, type TabsProps };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var unstyledTabs = require('@asnewyla/unstyled-tabs');
|
|
4
|
+
var react = require('react');
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
|
|
7
|
+
// src/components/Tab.tsx
|
|
8
|
+
function TabInner({ className, ...rest }, ref) {
|
|
9
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
10
|
+
unstyledTabs.Tab,
|
|
11
|
+
{
|
|
12
|
+
...rest,
|
|
13
|
+
className: className ? `xd-tab ${className}` : "xd-tab",
|
|
14
|
+
ref
|
|
15
|
+
}
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
var Tab = react.forwardRef(TabInner);
|
|
19
|
+
function TabListInner({ className, ...rest }, ref) {
|
|
20
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
21
|
+
unstyledTabs.TabList,
|
|
22
|
+
{
|
|
23
|
+
...rest,
|
|
24
|
+
className: className ? `xd-tab-list ${className}` : "xd-tab-list",
|
|
25
|
+
ref
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
var TabList = react.forwardRef(TabListInner);
|
|
30
|
+
function TabPanelInner({ className, ...rest }, ref) {
|
|
31
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
32
|
+
unstyledTabs.TabPanel,
|
|
33
|
+
{
|
|
34
|
+
...rest,
|
|
35
|
+
className: className ? `xd-tab-panel ${className}` : "xd-tab-panel",
|
|
36
|
+
ref
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
var TabPanel = react.forwardRef(
|
|
41
|
+
TabPanelInner
|
|
42
|
+
);
|
|
43
|
+
function TabsInner({ className, ...rest }, ref) {
|
|
44
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
45
|
+
unstyledTabs.Tabs,
|
|
46
|
+
{
|
|
47
|
+
...rest,
|
|
48
|
+
className: className ? `xd-tabs ${className}` : "xd-tabs",
|
|
49
|
+
ref
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
var Tabs = react.forwardRef(TabsInner);
|
|
54
|
+
|
|
55
|
+
exports.Tab = Tab;
|
|
56
|
+
exports.TabList = TabList;
|
|
57
|
+
exports.TabPanel = TabPanel;
|
|
58
|
+
exports.Tabs = Tabs;
|
|
59
|
+
//# sourceMappingURL=index.js.map
|
|
60
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/Tab.tsx","../src/components/TabList.tsx","../src/components/TabPanel.tsx","../src/components/Tabs.tsx"],"names":["jsx","UnstyledTab","forwardRef","UnstyledTabList","UnstyledTabPanel","UnstyledTabs"],"mappings":";;;;;;;AAQA,SAAS,SACP,EAAE,SAAA,EAAW,GAAG,IAAA,IAChB,GAAA,EACA;AACA,EAAA,uBACEA,cAAA;AAAA,IAACC,gBAAA;AAAA,IAAA;AAAA,MACE,GAAG,IAAA;AAAA,MACJ,SAAA,EAAW,SAAA,GAAY,CAAA,OAAA,EAAU,SAAS,CAAA,CAAA,GAAK,QAAA;AAAA,MAC/C;AAAA;AAAA,GACF;AAEJ;AAEO,IAAM,GAAA,GAAMC,iBAAwC,QAAQ;ACbnE,SAAS,aACP,EAAE,SAAA,EAAW,GAAG,IAAA,IAChB,GAAA,EACA;AACA,EAAA,uBACEF,cAAAA;AAAA,IAACG,oBAAA;AAAA,IAAA;AAAA,MACE,GAAG,IAAA;AAAA,MACJ,SAAA,EAAW,SAAA,GAAY,CAAA,YAAA,EAAe,SAAS,CAAA,CAAA,GAAK,aAAA;AAAA,MACpD;AAAA;AAAA,GACF;AAEJ;AAEO,IAAM,OAAA,GAAUD,iBAAyC,YAAY;ACb5E,SAAS,cACP,EAAE,SAAA,EAAW,GAAG,IAAA,IAChB,GAAA,EACA;AACA,EAAA,uBACEF,cAAAA;AAAA,IAACI,qBAAA;AAAA,IAAA;AAAA,MACE,GAAG,IAAA;AAAA,MACJ,SAAA,EAAW,SAAA,GAAY,CAAA,aAAA,EAAgB,SAAS,CAAA,CAAA,GAAK,cAAA;AAAA,MACrD;AAAA;AAAA,GACF;AAEJ;AAEO,IAAM,QAAA,GAAWF,gBAAAA;AAAA,EACtB;AACF;ACdA,SAAS,UACP,EAAE,SAAA,EAAW,GAAG,IAAA,IAChB,GAAA,EACA;AACA,EAAA,uBACEF,cAAAA;AAAA,IAACK,iBAAA;AAAA,IAAA;AAAA,MACE,GAAG,IAAA;AAAA,MACJ,SAAA,EAAW,SAAA,GAAY,CAAA,QAAA,EAAW,SAAS,CAAA,CAAA,GAAK,SAAA;AAAA,MAChD;AAAA;AAAA,GACF;AAEJ;AAEO,IAAM,IAAA,GAAOH,iBAAsC,SAAS","file":"index.js","sourcesContent":["import {\n Tab as UnstyledTab,\n type TabProps as UnstyledTabProps,\n} from '@asnewyla/unstyled-tabs';\nimport { type ForwardedRef, forwardRef } from 'react';\n\nexport type TabProps = UnstyledTabProps;\n\nfunction TabInner(\n { className, ...rest }: TabProps,\n ref: ForwardedRef<HTMLButtonElement>,\n) {\n return (\n <UnstyledTab\n {...rest}\n className={className ? `xd-tab ${className}` : 'xd-tab'}\n ref={ref}\n />\n );\n}\n\nexport const Tab = forwardRef<HTMLButtonElement, TabProps>(TabInner);\n","import {\n TabList as UnstyledTabList,\n type TabListProps as UnstyledTabListProps,\n} from '@asnewyla/unstyled-tabs';\nimport { type ForwardedRef, forwardRef } from 'react';\n\nexport type TabListProps = UnstyledTabListProps;\n\nfunction TabListInner(\n { className, ...rest }: TabListProps,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n return (\n <UnstyledTabList\n {...rest}\n className={className ? `xd-tab-list ${className}` : 'xd-tab-list'}\n ref={ref}\n />\n );\n}\n\nexport const TabList = forwardRef<HTMLDivElement, TabListProps>(TabListInner);\n","import {\n TabPanel as UnstyledTabPanel,\n type TabPanelProps as UnstyledTabPanelProps,\n} from '@asnewyla/unstyled-tabs';\nimport { type ForwardedRef, forwardRef } from 'react';\n\nexport type TabPanelProps = UnstyledTabPanelProps;\n\nfunction TabPanelInner(\n { className, ...rest }: TabPanelProps,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n return (\n <UnstyledTabPanel\n {...rest}\n className={className ? `xd-tab-panel ${className}` : 'xd-tab-panel'}\n ref={ref}\n />\n );\n}\n\nexport const TabPanel = forwardRef<HTMLDivElement, TabPanelProps>(\n TabPanelInner,\n);\n","import {\n Tabs as UnstyledTabs,\n type TabsProps as UnstyledTabsProps,\n} from '@asnewyla/unstyled-tabs';\nimport { type ForwardedRef, forwardRef } from 'react';\nimport './Tabs.css';\n\nexport type TabsProps = UnstyledTabsProps;\n\nfunction TabsInner(\n { className, ...rest }: TabsProps,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n return (\n <UnstyledTabs\n {...rest}\n className={className ? `xd-tabs ${className}` : 'xd-tabs'}\n ref={ref}\n />\n );\n}\n\nexport const Tabs = forwardRef<HTMLDivElement, TabsProps>(TabsInner);\n"]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Tab as Tab$1, TabList as TabList$1, TabPanel as TabPanel$1, Tabs as Tabs$1 } from '@asnewyla/unstyled-tabs';
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import { jsx } from 'react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
// src/components/Tab.tsx
|
|
6
|
+
function TabInner({ className, ...rest }, ref) {
|
|
7
|
+
return /* @__PURE__ */ jsx(
|
|
8
|
+
Tab$1,
|
|
9
|
+
{
|
|
10
|
+
...rest,
|
|
11
|
+
className: className ? `xd-tab ${className}` : "xd-tab",
|
|
12
|
+
ref
|
|
13
|
+
}
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
var Tab = forwardRef(TabInner);
|
|
17
|
+
function TabListInner({ className, ...rest }, ref) {
|
|
18
|
+
return /* @__PURE__ */ jsx(
|
|
19
|
+
TabList$1,
|
|
20
|
+
{
|
|
21
|
+
...rest,
|
|
22
|
+
className: className ? `xd-tab-list ${className}` : "xd-tab-list",
|
|
23
|
+
ref
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
var TabList = forwardRef(TabListInner);
|
|
28
|
+
function TabPanelInner({ className, ...rest }, ref) {
|
|
29
|
+
return /* @__PURE__ */ jsx(
|
|
30
|
+
TabPanel$1,
|
|
31
|
+
{
|
|
32
|
+
...rest,
|
|
33
|
+
className: className ? `xd-tab-panel ${className}` : "xd-tab-panel",
|
|
34
|
+
ref
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
var TabPanel = forwardRef(
|
|
39
|
+
TabPanelInner
|
|
40
|
+
);
|
|
41
|
+
function TabsInner({ className, ...rest }, ref) {
|
|
42
|
+
return /* @__PURE__ */ jsx(
|
|
43
|
+
Tabs$1,
|
|
44
|
+
{
|
|
45
|
+
...rest,
|
|
46
|
+
className: className ? `xd-tabs ${className}` : "xd-tabs",
|
|
47
|
+
ref
|
|
48
|
+
}
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
var Tabs = forwardRef(TabsInner);
|
|
52
|
+
|
|
53
|
+
export { Tab, TabList, TabPanel, Tabs };
|
|
54
|
+
//# sourceMappingURL=index.mjs.map
|
|
55
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/Tab.tsx","../src/components/TabList.tsx","../src/components/TabPanel.tsx","../src/components/Tabs.tsx"],"names":["UnstyledTab","jsx","UnstyledTabList","forwardRef","UnstyledTabPanel","UnstyledTabs"],"mappings":";;;;;AAQA,SAAS,SACP,EAAE,SAAA,EAAW,GAAG,IAAA,IAChB,GAAA,EACA;AACA,EAAA,uBACE,GAAA;AAAA,IAACA,KAAA;AAAA,IAAA;AAAA,MACE,GAAG,IAAA;AAAA,MACJ,SAAA,EAAW,SAAA,GAAY,CAAA,OAAA,EAAU,SAAS,CAAA,CAAA,GAAK,QAAA;AAAA,MAC/C;AAAA;AAAA,GACF;AAEJ;AAEO,IAAM,GAAA,GAAM,WAAwC,QAAQ;ACbnE,SAAS,aACP,EAAE,SAAA,EAAW,GAAG,IAAA,IAChB,GAAA,EACA;AACA,EAAA,uBACEC,GAAAA;AAAA,IAACC,SAAA;AAAA,IAAA;AAAA,MACE,GAAG,IAAA;AAAA,MACJ,SAAA,EAAW,SAAA,GAAY,CAAA,YAAA,EAAe,SAAS,CAAA,CAAA,GAAK,aAAA;AAAA,MACpD;AAAA;AAAA,GACF;AAEJ;AAEO,IAAM,OAAA,GAAUC,WAAyC,YAAY;ACb5E,SAAS,cACP,EAAE,SAAA,EAAW,GAAG,IAAA,IAChB,GAAA,EACA;AACA,EAAA,uBACEF,GAAAA;AAAA,IAACG,UAAA;AAAA,IAAA;AAAA,MACE,GAAG,IAAA;AAAA,MACJ,SAAA,EAAW,SAAA,GAAY,CAAA,aAAA,EAAgB,SAAS,CAAA,CAAA,GAAK,cAAA;AAAA,MACrD;AAAA;AAAA,GACF;AAEJ;AAEO,IAAM,QAAA,GAAWD,UAAAA;AAAA,EACtB;AACF;ACdA,SAAS,UACP,EAAE,SAAA,EAAW,GAAG,IAAA,IAChB,GAAA,EACA;AACA,EAAA,uBACEF,GAAAA;AAAA,IAACI,MAAA;AAAA,IAAA;AAAA,MACE,GAAG,IAAA;AAAA,MACJ,SAAA,EAAW,SAAA,GAAY,CAAA,QAAA,EAAW,SAAS,CAAA,CAAA,GAAK,SAAA;AAAA,MAChD;AAAA;AAAA,GACF;AAEJ;AAEO,IAAM,IAAA,GAAOF,WAAsC,SAAS","file":"index.mjs","sourcesContent":["import {\n Tab as UnstyledTab,\n type TabProps as UnstyledTabProps,\n} from '@asnewyla/unstyled-tabs';\nimport { type ForwardedRef, forwardRef } from 'react';\n\nexport type TabProps = UnstyledTabProps;\n\nfunction TabInner(\n { className, ...rest }: TabProps,\n ref: ForwardedRef<HTMLButtonElement>,\n) {\n return (\n <UnstyledTab\n {...rest}\n className={className ? `xd-tab ${className}` : 'xd-tab'}\n ref={ref}\n />\n );\n}\n\nexport const Tab = forwardRef<HTMLButtonElement, TabProps>(TabInner);\n","import {\n TabList as UnstyledTabList,\n type TabListProps as UnstyledTabListProps,\n} from '@asnewyla/unstyled-tabs';\nimport { type ForwardedRef, forwardRef } from 'react';\n\nexport type TabListProps = UnstyledTabListProps;\n\nfunction TabListInner(\n { className, ...rest }: TabListProps,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n return (\n <UnstyledTabList\n {...rest}\n className={className ? `xd-tab-list ${className}` : 'xd-tab-list'}\n ref={ref}\n />\n );\n}\n\nexport const TabList = forwardRef<HTMLDivElement, TabListProps>(TabListInner);\n","import {\n TabPanel as UnstyledTabPanel,\n type TabPanelProps as UnstyledTabPanelProps,\n} from '@asnewyla/unstyled-tabs';\nimport { type ForwardedRef, forwardRef } from 'react';\n\nexport type TabPanelProps = UnstyledTabPanelProps;\n\nfunction TabPanelInner(\n { className, ...rest }: TabPanelProps,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n return (\n <UnstyledTabPanel\n {...rest}\n className={className ? `xd-tab-panel ${className}` : 'xd-tab-panel'}\n ref={ref}\n />\n );\n}\n\nexport const TabPanel = forwardRef<HTMLDivElement, TabPanelProps>(\n TabPanelInner,\n);\n","import {\n Tabs as UnstyledTabs,\n type TabsProps as UnstyledTabsProps,\n} from '@asnewyla/unstyled-tabs';\nimport { type ForwardedRef, forwardRef } from 'react';\nimport './Tabs.css';\n\nexport type TabsProps = UnstyledTabsProps;\n\nfunction TabsInner(\n { className, ...rest }: TabsProps,\n ref: ForwardedRef<HTMLDivElement>,\n) {\n return (\n <UnstyledTabs\n {...rest}\n className={className ? `xd-tabs ${className}` : 'xd-tabs'}\n ref={ref}\n />\n );\n}\n\nexport const Tabs = forwardRef<HTMLDivElement, TabsProps>(TabsInner);\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@asnewyla/tabs",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Styled tabs with roving-focus keyboard navigation and accessibility",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/xavierDelaFuente/xd-components.git",
|
|
9
|
+
"directory": "packages/tabs"
|
|
10
|
+
},
|
|
11
|
+
"publishConfig": {
|
|
12
|
+
"access": "public"
|
|
13
|
+
},
|
|
14
|
+
"main": "dist/index.js",
|
|
15
|
+
"module": "dist/index.mjs",
|
|
16
|
+
"types": "dist/index.d.ts",
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"import": "./dist/index.mjs",
|
|
21
|
+
"require": "./dist/index.js"
|
|
22
|
+
},
|
|
23
|
+
"./styles.css": "./dist/index.css"
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist"
|
|
27
|
+
],
|
|
28
|
+
"sideEffects": [
|
|
29
|
+
"*.css"
|
|
30
|
+
],
|
|
31
|
+
"keywords": [
|
|
32
|
+
"react",
|
|
33
|
+
"tabs",
|
|
34
|
+
"styled",
|
|
35
|
+
"accessible"
|
|
36
|
+
],
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
39
|
+
"react-dom": "^18.0.0 || ^19.0.0"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@asnewyla/unstyled-tabs": "0.2.0"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@testing-library/jest-dom": "^6.4.0",
|
|
46
|
+
"@testing-library/react": "^16.0.0",
|
|
47
|
+
"@testing-library/user-event": "^14.5.0",
|
|
48
|
+
"@vitest/coverage-v8": "^2.0.0",
|
|
49
|
+
"jsdom": "^24.0.0",
|
|
50
|
+
"react": "^18.3.0",
|
|
51
|
+
"react-dom": "^18.3.0",
|
|
52
|
+
"tsup": "^8.1.0",
|
|
53
|
+
"typescript": "^5.5.0",
|
|
54
|
+
"vitest": "^2.0.0"
|
|
55
|
+
},
|
|
56
|
+
"scripts": {
|
|
57
|
+
"build": "tsup",
|
|
58
|
+
"test": "vitest run",
|
|
59
|
+
"test:watch": "vitest",
|
|
60
|
+
"test:coverage": "vitest run --coverage",
|
|
61
|
+
"type-check": "tsc --noEmit"
|
|
62
|
+
}
|
|
63
|
+
}
|