monochrome 0.2.0 → 0.3.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/README.md +19 -99
- package/dist/index.d.ts +16 -0
- package/dist/react/accordion.d.ts +22 -0
- package/dist/react/collapsible.d.ts +13 -0
- package/dist/react/index.d.ts +4 -0
- package/dist/react/index.js +1 -1
- package/dist/react/menu.d.ts +34 -0
- package/dist/react/shared.d.ts +6 -0
- package/dist/react/tabs.d.ts +24 -0
- package/dist/vue/accordion.d.ts +62 -0
- package/dist/vue/collapsible.d.ts +23 -0
- package/dist/vue/index.d.ts +4 -0
- package/dist/vue/index.js +1 -0
- package/dist/vue/menu.d.ts +73 -0
- package/dist/vue/shared.d.ts +35 -0
- package/dist/vue/tabs.d.ts +87 -0
- package/package.json +25 -23
- package/src/index.ts +0 -561
- package/src/react/accordion.tsx +0 -85
- package/src/react/collapsible.tsx +0 -60
- package/src/react/index.ts +0 -4
- package/src/react/menu.tsx +0 -230
- package/src/react/shared.tsx +0 -16
- package/src/react/tabs.tsx +0 -116
package/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Monochrome
|
|
2
2
|
|
|
3
|
-
Accessible UI component library. Best-in-class performance. HTML-first, React supported.
|
|
3
|
+
Accessible UI component library. Best-in-class performance. HTML-first, React and Vue supported.
|
|
4
4
|
|
|
5
5
|
<!-- badges -->
|
|
6
|
-
    
|
|
7
7
|
<!-- /badges -->
|
|
8
8
|
|
|
9
9
|
## Install
|
|
@@ -12,16 +12,14 @@ Accessible UI component library. Best-in-class performance. HTML-first, React su
|
|
|
12
12
|
npm install monochrome
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
```ts
|
|
16
|
+
import "monochrome" // Core (auto-activates)
|
|
17
|
+
import { Accordion } from "monochrome/react" // React
|
|
18
|
+
import { Accordion } from "monochrome/vue" // Vue
|
|
19
|
+
```
|
|
20
20
|
|
|
21
21
|
## Usage
|
|
22
22
|
|
|
23
|
-
### React
|
|
24
|
-
|
|
25
23
|
```tsx
|
|
26
24
|
import "monochrome"
|
|
27
25
|
import { Accordion } from "monochrome/react"
|
|
@@ -42,79 +40,9 @@ export function FAQ() {
|
|
|
42
40
|
}
|
|
43
41
|
```
|
|
44
42
|
|
|
45
|
-
Import `"monochrome"` once at your app's entry point. The
|
|
46
|
-
|
|
47
|
-
### HTML
|
|
48
|
-
|
|
49
|
-
monochrome works with any framework or no framework at all. Write semantic HTML with the ID convention and everything just works:
|
|
50
|
-
|
|
51
|
-
```html
|
|
52
|
-
<script src="https://unpkg.com/monochrome"></script>
|
|
53
|
-
|
|
54
|
-
<button
|
|
55
|
-
id="mct:collapsible:demo"
|
|
56
|
-
aria-expanded="false"
|
|
57
|
-
aria-controls="mcc:collapsible:demo"
|
|
58
|
-
>
|
|
59
|
-
Toggle
|
|
60
|
-
</button>
|
|
61
|
-
<div id="mcc:collapsible:demo" aria-hidden="true" hidden="until-found">
|
|
62
|
-
Content appears here.
|
|
63
|
-
</div>
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
### React Components
|
|
68
|
-
|
|
69
|
-
<details>
|
|
70
|
-
<summary>Collapsible</summary>
|
|
71
|
-
|
|
72
|
-
```tsx
|
|
73
|
-
import { Collapsible } from "monochrome/react"
|
|
74
|
-
|
|
75
|
-
<Collapsible.Root open>
|
|
76
|
-
<Collapsible.Trigger>Toggle</Collapsible.Trigger>
|
|
77
|
-
<Collapsible.Panel>Content here</Collapsible.Panel>
|
|
78
|
-
</Collapsible.Root>
|
|
79
|
-
```
|
|
80
|
-
</details>
|
|
81
|
-
|
|
82
|
-
<details>
|
|
83
|
-
<summary>Tabs</summary>
|
|
84
|
-
|
|
85
|
-
```tsx
|
|
86
|
-
import { Tabs } from "monochrome/react"
|
|
87
|
-
|
|
88
|
-
<Tabs.Root defaultValue="tab1" orientation="horizontal">
|
|
89
|
-
<Tabs.List>
|
|
90
|
-
<Tabs.Tab value="tab1">Tab 1</Tabs.Tab>
|
|
91
|
-
<Tabs.Tab value="tab2">Tab 2</Tabs.Tab>
|
|
92
|
-
</Tabs.List>
|
|
93
|
-
<Tabs.Panel value="tab1">Content 1</Tabs.Panel>
|
|
94
|
-
<Tabs.Panel value="tab2">Content 2</Tabs.Panel>
|
|
95
|
-
</Tabs.Root>
|
|
96
|
-
```
|
|
97
|
-
</details>
|
|
43
|
+
Import `"monochrome"` once at your app's entry point. The wrappers generate the correct HTML structure and ARIA attributes. All interactivity comes from the Monochrome runtime - no framework JavaScript needed on the client.
|
|
98
44
|
|
|
99
|
-
|
|
100
|
-
<summary>Menu</summary>
|
|
101
|
-
|
|
102
|
-
```tsx
|
|
103
|
-
import { Menu } from "monochrome/react"
|
|
104
|
-
|
|
105
|
-
<Menu.Root>
|
|
106
|
-
<Menu.Trigger>Open Menu</Menu.Trigger>
|
|
107
|
-
<Menu.Popover>
|
|
108
|
-
<Menu.Item>Action 1</Menu.Item>
|
|
109
|
-
<Menu.Item disabled>Disabled</Menu.Item>
|
|
110
|
-
<Menu.Separator />
|
|
111
|
-
<Menu.CheckboxItem checked={false}>Bold</Menu.CheckboxItem>
|
|
112
|
-
<Menu.RadioItem checked>Small</Menu.RadioItem>
|
|
113
|
-
<Menu.RadioItem checked={false}>Large</Menu.RadioItem>
|
|
114
|
-
</Menu.Popover>
|
|
115
|
-
</Menu.Root>
|
|
116
|
-
```
|
|
117
|
-
</details>
|
|
45
|
+
The Vue API is identical: `import { Accordion } from "monochrome/vue"`. Monochrome also works with plain HTML or any framework that outputs HTML. See [AGENTS.md](./AGENTS.md) for full documentation.
|
|
118
46
|
|
|
119
47
|
## Components
|
|
120
48
|
|
|
@@ -122,10 +50,14 @@ Four interactive UI patterns in <!-- size -->2.2kB<!-- /size -->:
|
|
|
122
50
|
|
|
123
51
|
| Component | Description | Tests |
|
|
124
52
|
| --- | --- | ---: |
|
|
125
|
-
| **Accordion** | Grouped collapsible content sections | <!-- tests:accordion -->
|
|
126
|
-
| **Collapsible** | Show and hide content with a button | <!-- tests:collapsible -->
|
|
127
|
-
| **Menu** | Dropdown menus, menubars, and submenus | <!-- tests:menu -->
|
|
128
|
-
| **Tabs** | Switch between multiple content panels | <!-- tests:tabs -->
|
|
53
|
+
| **Accordion** | Grouped collapsible content sections | <!-- tests:accordion -->66<!-- /tests:accordion --> |
|
|
54
|
+
| **Collapsible** | Show and hide content with a button | <!-- tests:collapsible -->42<!-- /tests:collapsible --> |
|
|
55
|
+
| **Menu** | Dropdown menus, menubars, and submenus | <!-- tests:menu -->176<!-- /tests:menu --> |
|
|
56
|
+
| **Tabs** | Switch between multiple content panels | <!-- tests:tabs -->70<!-- /tests:tabs --> |
|
|
57
|
+
|
|
58
|
+
## How it works
|
|
59
|
+
|
|
60
|
+
Monochrome uses the DOM as its source of truth. Instead of managing state in JavaScript, it reads ARIA attributes, responds to user interactions, and updates them directly. Minimal global event listeners handle every component on the page through event delegation. No initialization, no configuration, no framework required.
|
|
129
61
|
|
|
130
62
|
## Accessibility
|
|
131
63
|
|
|
@@ -137,33 +69,21 @@ Every component follows [WAI-ARIA Authoring Practices](https://www.w3.org/WAI/AR
|
|
|
137
69
|
- Preserves browser find-in-page (cmd+f)
|
|
138
70
|
- Screen reader support out of the box
|
|
139
71
|
|
|
140
|
-
## Performance
|
|
141
|
-
|
|
142
|
-
- Event delegation: minimal global listeners shared across all components
|
|
143
|
-
- No per-component instances, state objects, or memory allocations
|
|
144
|
-
- Zero DOM queries, navigates through direct element pointers
|
|
145
|
-
- Adding more components to the page costs nothing at runtime
|
|
146
|
-
|
|
147
|
-
> Performance isn't a feature, it's a consequence of the architecture. When you don't have per-component state, per-component listeners, or a rendering framework, there's nothing left to be slow.
|
|
148
|
-
|
|
149
72
|
## Styling
|
|
150
73
|
|
|
151
|
-
|
|
74
|
+
Monochrome is headless - no CSS is shipped. You provide all styles. Key requirements for menus:
|
|
152
75
|
|
|
153
76
|
```css
|
|
154
|
-
/* Menu popover visibility */
|
|
155
77
|
[popover]:popover-open {
|
|
156
78
|
display: flex;
|
|
157
79
|
}
|
|
158
80
|
|
|
159
|
-
/* Menu positioning (core sets --top, --right, --bottom, --left from getBoundingClientRect) */
|
|
160
81
|
[role="menu"] {
|
|
161
82
|
position: fixed;
|
|
162
83
|
top: var(--bottom);
|
|
163
84
|
left: var(--left);
|
|
164
85
|
}
|
|
165
86
|
|
|
166
|
-
/* Submenu positioning */
|
|
167
87
|
[role="menu"] [role="menu"] {
|
|
168
88
|
top: var(--top);
|
|
169
89
|
left: var(--right);
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
declare enum Focus {
|
|
2
|
+
Trigger = 0,
|
|
3
|
+
First = 1,
|
|
4
|
+
Last = 2,
|
|
5
|
+
None = 3
|
|
6
|
+
}
|
|
7
|
+
declare enum Prefix {
|
|
8
|
+
Trigger = "mct:",
|
|
9
|
+
TriggerAccordion = "mct:a",
|
|
10
|
+
TriggerCollapsible = "mct:c",
|
|
11
|
+
TriggerMenu = "mct:m",
|
|
12
|
+
TriggerTabs = "mct:t",
|
|
13
|
+
Content = "mcc:",
|
|
14
|
+
ContentMenu = "mcc:m",
|
|
15
|
+
RootAccordion = "mcr:a"
|
|
16
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type ReactElement } from "react";
|
|
2
|
+
import { type BaseProps } from "./shared.js";
|
|
3
|
+
declare function Root({ children, type, ...props }: BaseProps & {
|
|
4
|
+
type?: "single" | "multiple";
|
|
5
|
+
}): ReactElement;
|
|
6
|
+
declare function Item({ children, open, disabled, ...props }: BaseProps & {
|
|
7
|
+
open?: boolean;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
}): ReactElement;
|
|
10
|
+
declare function Header({ children, as, ...props }: BaseProps & {
|
|
11
|
+
as?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6";
|
|
12
|
+
}): ReactElement;
|
|
13
|
+
declare function Trigger({ children, ...props }: BaseProps): ReactElement;
|
|
14
|
+
declare function Panel({ children, ...props }: BaseProps): ReactElement;
|
|
15
|
+
export declare const Accordion: {
|
|
16
|
+
Root: typeof Root;
|
|
17
|
+
Item: typeof Item;
|
|
18
|
+
Header: typeof Header;
|
|
19
|
+
Trigger: typeof Trigger;
|
|
20
|
+
Panel: typeof Panel;
|
|
21
|
+
};
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type ReactElement } from "react";
|
|
2
|
+
import { type BaseProps } from "./shared.js";
|
|
3
|
+
declare function Root({ children, open, ...props }: BaseProps & {
|
|
4
|
+
open?: boolean;
|
|
5
|
+
}): ReactElement;
|
|
6
|
+
declare function Trigger({ children, ...props }: BaseProps): ReactElement;
|
|
7
|
+
declare function Panel({ children, ...props }: BaseProps): ReactElement;
|
|
8
|
+
export declare const Collapsible: {
|
|
9
|
+
Root: typeof Root;
|
|
10
|
+
Trigger: typeof Trigger;
|
|
11
|
+
Panel: typeof Panel;
|
|
12
|
+
};
|
|
13
|
+
export {};
|
package/dist/react/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{createContext as
|
|
2
|
+
import{createContext as w,createElement as c,useContext as M,useId as C}from"react";import{createElement as g}from"react";var m=(e,n)=>n?`${e}:${n}`:e,u=()=>g("script",{dangerouslySetInnerHTML:{__html:"document.currentScript.parentNode.setAttribute('hidden','until-found')"}});var P=w(null);function I(){let e=M(P);if(!e)throw Error("Accordion components must be used within Accordion.Item");return e}function T({children:e,type:n,...t}){let o=C();return c("div",{...t,"data-mode":n??"single",id:`mcr:accordion:${o}`},e)}function V({children:e,open:n,disabled:t,...o}){let a=C();return c(P.Provider,{value:{baseId:a,open:n??!1,disabled:t??!1}},c("div",o,e))}function A({children:e,as:n,...t}){return c(n??"h3",t,e)}function F({children:e,...n}){let t=I(),o=t.baseId,a=t.open;return c("button",{...n,type:"button",id:`mct:accordion:${o}`,"aria-expanded":a,"aria-controls":`mcc:accordion:${o}`,"aria-disabled":t.disabled||void 0},e)}function k({children:e,...n}){let t=I(),o=t.baseId,a=t.open;return c("div",{...n,id:`mcc:accordion:${o}`,role:"region","aria-labelledby":`mct:accordion:${o}`,"aria-hidden":!a,hidden:a?void 0:!0},!a&&c(u,null),e)}var O={Root:T,Item:V,Header:A,Trigger:F,Panel:k};import{createContext as z,createElement as b,useContext as H,useId as U}from"react";var R=z(null);function h(){let e=H(R);if(!e)throw Error("Collapsible components must be used within Collapsible.Root");return e}function L({children:e,open:n,...t}){let o=U();return b(R.Provider,{value:{baseId:o,open:n??!1}},b("div",t,e))}function S({children:e,...n}){let t=h(),o=t.baseId,a=t.open;return b("button",{...n,type:"button",id:`mct:collapsible:${o}`,"aria-expanded":a,"aria-controls":`mcc:collapsible:${o}`},e)}function j({children:e,...n}){let t=h(),o=t.baseId,a=t.open;return b("div",{...n,id:`mcc:collapsible:${o}`,"aria-labelledby":`mct:collapsible:${o}`,"aria-hidden":!a,hidden:a?void 0:!0},!a&&b(u,null),e)}var G={Root:L,Trigger:S,Panel:j};import{createContext as E,createElement as r,useContext as v,useId as B,useRef as q}from"react";var p=E(null),y=E(null);function f(){let e=v(p);if(!e)throw Error("Menu components must be used within Menu.Root");return e}function J(){let e=v(y);if(!e)throw Error("Menu components must be used within Menu.Popover");return e}function K({children:e,menubar:n,...t}){let o=B();return r(p.Provider,{value:{id:o,root:!0,menubar:n}},r("div",{...t,id:`mcr:menu:${o}`},e))}function N({children:e,...n}){let t=f();return r("button",{...n,type:"button",id:`mct:menu:${t.id}`,"aria-controls":`mcc:menu:${t.id}`,"aria-expanded":"false","aria-haspopup":"menu",tabIndex:t.root||t.first?0:-1,role:t.submenu?"menuitem":"button"},e)}function Q({children:e,...n}){let t=f(),o=q(!1);o.current=!1;let a=r(y.Provider,{value:{claimFirst:()=>{if(!o.current)return o.current=!0,!0;return!1}}},e);return t.menubar?r("ul",{...n,role:"menubar"},a):r("ul",{...n,role:"menu",id:`mcc:menu:${t.id}`,"aria-labelledby":`mct:menu:${t.id}`,"aria-hidden":"true",popover:"manual"},a)}function W({children:e,disabled:n,href:t,...o}){let a=n?r("span",{...o,role:"menuitem","aria-disabled":"true",tabIndex:-1},e):t?r("a",{...o,role:"menuitem",href:t,tabIndex:-1},e):r("button",{...o,type:"button",role:"menuitem",tabIndex:-1},e);return r("li",{role:"none"},a)}function X({children:e,checked:n,disabled:t,...o}){let a=t?r("span",{...o,role:"menuitemcheckbox","aria-checked":n??!1,"aria-disabled":"true",tabIndex:-1},e):r("button",{...o,type:"button",role:"menuitemcheckbox","aria-checked":n??!1,tabIndex:-1},e);return r("li",{role:"none"},a)}function Y({children:e,checked:n,disabled:t,...o}){let a=t?r("span",{...o,role:"menuitemradio","aria-checked":n??!1,"aria-disabled":"true",tabIndex:-1},e):r("button",{...o,type:"button",role:"menuitemradio","aria-checked":n??!1,tabIndex:-1},e);return r("li",{role:"none"},a)}function Z({children:e,...n}){return r("li",{...n,role:"presentation"},e)}function _(e){return r("li",{...e,role:"separator"})}function D({children:e,...n}){let t=f(),a=J().claimFirst(),i=B(),l=a&&t.menubar&&!t.submenu;return r(p.Provider,{value:{id:i,submenu:!0,first:l}},r("li",{...n,role:"none"},e))}var ee={Root:K,Trigger:N,Popover:Q,Item:W,CheckboxItem:X,RadioItem:Y,Label:Z,Separator:_,Group:D};import{createContext as te,createElement as d,useContext as ne,useId as oe}from"react";var $=te(null);function x(){let e=ne($);if(!e)throw Error("Tabs components must be used within Tabs.Root");return e}function ae({children:e,defaultValue:n,orientation:t,...o}){let a=oe(),i=t??"horizontal";return d($.Provider,{value:{baseId:a,selected:n,orientation:i}},d("div",{...o,"data-orientation":i,id:`mcr:tabs:${a}`},e))}function re({children:e,...n}){let t=x();return d("div",{...n,role:"tablist","aria-orientation":t.orientation},e)}function ie({children:e,value:n,selected:t,disabled:o,...a}){let i=x(),l=m(i.baseId,n),s=t??n===i.selected;return d("button",{...a,type:"button",role:"tab",id:`mct:tabs:${l}`,"aria-selected":s,"aria-controls":`mcc:tabs:${l}`,tabIndex:s?0:-1,"aria-disabled":o||void 0},e)}function le({children:e,value:n,selected:t,focusable:o=!0,...a}){let i=x(),l=m(i.baseId,n),s=t??n===i.selected;return d("div",{...a,role:"tabpanel",id:`mcc:tabs:${l}`,"aria-labelledby":`mct:tabs:${l}`,"aria-hidden":!s,hidden:s?void 0:!0,tabIndex:o?s?0:-1:void 0,"data-orientation":i.orientation},!s&&d(u,null),e)}var se={Root:ae,List:re,Tab:ie,Panel:le};export{se as Tabs,ee as Menu,G as Collapsible,O as Accordion};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type ReactElement } from "react";
|
|
2
|
+
import type { BaseProps } from "./shared.js";
|
|
3
|
+
declare function Root({ children, menubar, ...props }: BaseProps & {
|
|
4
|
+
menubar?: boolean;
|
|
5
|
+
}): ReactElement;
|
|
6
|
+
declare function Trigger({ children, ...props }: BaseProps): ReactElement;
|
|
7
|
+
declare function Popover({ children, ...props }: BaseProps): ReactElement;
|
|
8
|
+
declare function Item({ children, disabled, href, ...props }: BaseProps & {
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
href?: string;
|
|
11
|
+
}): ReactElement;
|
|
12
|
+
declare function CheckboxItem({ children, checked, disabled, ...props }: BaseProps & {
|
|
13
|
+
checked?: boolean;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
}): ReactElement;
|
|
16
|
+
declare function RadioItem({ children, checked, disabled, ...props }: BaseProps & {
|
|
17
|
+
checked?: boolean;
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
}): ReactElement;
|
|
20
|
+
declare function Label({ children, ...props }: BaseProps): ReactElement;
|
|
21
|
+
declare function Separator(props: Omit<BaseProps, "children">): ReactElement;
|
|
22
|
+
declare function Group({ children, ...props }: BaseProps): ReactElement;
|
|
23
|
+
export declare const Menu: {
|
|
24
|
+
Root: typeof Root;
|
|
25
|
+
Trigger: typeof Trigger;
|
|
26
|
+
Popover: typeof Popover;
|
|
27
|
+
Item: typeof Item;
|
|
28
|
+
CheckboxItem: typeof CheckboxItem;
|
|
29
|
+
RadioItem: typeof RadioItem;
|
|
30
|
+
Label: typeof Label;
|
|
31
|
+
Separator: typeof Separator;
|
|
32
|
+
Group: typeof Group;
|
|
33
|
+
};
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type HTMLAttributes, type ReactElement, type ReactNode } from "react";
|
|
2
|
+
export type BaseProps = HTMLAttributes<HTMLElement> & {
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
};
|
|
5
|
+
export declare const buildId: (base: string, id?: string) => string;
|
|
6
|
+
export declare const HiddenUntilFound: () => ReactElement;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type ReactElement } from "react";
|
|
2
|
+
import { type BaseProps } from "./shared.js";
|
|
3
|
+
declare function Root({ children, defaultValue, orientation, ...props }: BaseProps & {
|
|
4
|
+
defaultValue: string;
|
|
5
|
+
orientation?: "horizontal" | "vertical";
|
|
6
|
+
}): ReactElement;
|
|
7
|
+
declare function List({ children, ...props }: BaseProps): ReactElement;
|
|
8
|
+
declare function Tab({ children, value, selected, disabled, ...props }: BaseProps & {
|
|
9
|
+
value: string;
|
|
10
|
+
selected?: boolean;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
}): ReactElement;
|
|
13
|
+
declare function Panel({ children, value, selected, focusable, ...props }: BaseProps & {
|
|
14
|
+
value: string;
|
|
15
|
+
selected?: boolean;
|
|
16
|
+
focusable?: boolean;
|
|
17
|
+
}): ReactElement;
|
|
18
|
+
export declare const Tabs: {
|
|
19
|
+
Root: typeof Root;
|
|
20
|
+
List: typeof List;
|
|
21
|
+
Tab: typeof Tab;
|
|
22
|
+
Panel: typeof Panel;
|
|
23
|
+
};
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export declare const Accordion: {
|
|
2
|
+
Root: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
3
|
+
type: {
|
|
4
|
+
type: StringConstructor;
|
|
5
|
+
default: string;
|
|
6
|
+
};
|
|
7
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
8
|
+
[key: string]: any;
|
|
9
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
10
|
+
type: {
|
|
11
|
+
type: StringConstructor;
|
|
12
|
+
default: string;
|
|
13
|
+
};
|
|
14
|
+
}>> & Readonly<{}>, {
|
|
15
|
+
type: string;
|
|
16
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
17
|
+
Item: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
18
|
+
open: {
|
|
19
|
+
type: BooleanConstructor;
|
|
20
|
+
default: boolean;
|
|
21
|
+
};
|
|
22
|
+
disabled: {
|
|
23
|
+
type: BooleanConstructor;
|
|
24
|
+
default: boolean;
|
|
25
|
+
};
|
|
26
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
27
|
+
[key: string]: any;
|
|
28
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
29
|
+
open: {
|
|
30
|
+
type: BooleanConstructor;
|
|
31
|
+
default: boolean;
|
|
32
|
+
};
|
|
33
|
+
disabled: {
|
|
34
|
+
type: BooleanConstructor;
|
|
35
|
+
default: boolean;
|
|
36
|
+
};
|
|
37
|
+
}>> & Readonly<{}>, {
|
|
38
|
+
open: boolean;
|
|
39
|
+
disabled: boolean;
|
|
40
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
41
|
+
Header: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
42
|
+
as: {
|
|
43
|
+
type: StringConstructor;
|
|
44
|
+
default: string;
|
|
45
|
+
};
|
|
46
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
47
|
+
[key: string]: any;
|
|
48
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
49
|
+
as: {
|
|
50
|
+
type: StringConstructor;
|
|
51
|
+
default: string;
|
|
52
|
+
};
|
|
53
|
+
}>> & Readonly<{}>, {
|
|
54
|
+
as: string;
|
|
55
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
56
|
+
Trigger: import("vue").DefineComponent<{}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
57
|
+
[key: string]: any;
|
|
58
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
59
|
+
Panel: import("vue").DefineComponent<{}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
60
|
+
[key: string]: any;
|
|
61
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
62
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export declare const Collapsible: {
|
|
2
|
+
Root: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
3
|
+
open: {
|
|
4
|
+
type: BooleanConstructor;
|
|
5
|
+
default: boolean;
|
|
6
|
+
};
|
|
7
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
8
|
+
[key: string]: any;
|
|
9
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
10
|
+
open: {
|
|
11
|
+
type: BooleanConstructor;
|
|
12
|
+
default: boolean;
|
|
13
|
+
};
|
|
14
|
+
}>> & Readonly<{}>, {
|
|
15
|
+
open: boolean;
|
|
16
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
17
|
+
Trigger: import("vue").DefineComponent<{}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
18
|
+
[key: string]: any;
|
|
19
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
20
|
+
Panel: import("vue").DefineComponent<{}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
21
|
+
[key: string]: any;
|
|
22
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
23
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{defineComponent as W,h as O,provide as L,reactive as j,toRef as P,useId as F}from"vue";import{h as k,inject as K}from"vue";function z(y,w){let b=K(y);if(!b)throw Error(`${w} must be used within its parent provider`);return b}var B=(y,w)=>w?`${y}:${w}`:y,D=()=>k("script",{innerHTML:"document.currentScript.parentNode.setAttribute('hidden','until-found')"}),Y=Symbol("CollapsibleContext"),Z=Symbol("AccordionContext"),Q=Symbol("TabsContext"),J=Symbol("MenuContext"),G=Symbol("MenuPopupContext");var H=W({props:{type:{type:String,default:"single"}},setup(y,{slots:w}){let b=F();return()=>O("div",{"data-mode":y.type,id:`mcr:accordion:${b}`},w.default?.())}}),C=W({props:{open:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1}},setup(y,{slots:w}){let b=F();return L(Z,j({baseId:b,open:P(y,"open"),disabled:P(y,"disabled")})),()=>O("div",null,w.default?.())}}),q=W({props:{as:{type:String,default:"h3"}},setup(y,{slots:w}){return()=>O(y.as,null,w.default?.())}}),R=W({setup(y,{slots:w}){let b=z(Z,"Accordion.Trigger/Panel");return()=>O("button",{type:"button",id:`mct:accordion:${b.baseId}`,"aria-expanded":b.open,"aria-controls":`mcc:accordion:${b.baseId}`,"aria-disabled":b.disabled||void 0},w.default?.())}}),v=W({setup(y,{slots:w}){let b=z(Z,"Accordion.Trigger/Panel");return()=>O("div",{id:`mcc:accordion:${b.baseId}`,role:"region","aria-labelledby":`mct:accordion:${b.baseId}`,"aria-hidden":!b.open,hidden:b.open?void 0:!0},[!b.open&&O(D),w.default?.()])}}),m={Root:H,Item:C,Header:q,Trigger:R,Panel:v};import{defineComponent as S,h as _,provide as f,reactive as I,toRef as a,useId as u}from"vue";var n=S({props:{open:{type:Boolean,default:!1}},setup(y,{slots:w}){let b=u();return f(Y,I({baseId:b,open:a(y,"open")})),()=>_("div",null,w.default?.())}}),h=S({setup(y,{slots:w}){let b=z(Y,"Collapsible.Trigger/Panel");return()=>_("button",{type:"button",id:`mct:collapsible:${b.baseId}`,"aria-expanded":b.open,"aria-controls":`mcc:collapsible:${b.baseId}`},w.default?.())}}),i=S({setup(y,{slots:w}){let b=z(Y,"Collapsible.Trigger/Panel");return()=>_("div",{id:`mcc:collapsible:${b.baseId}`,"aria-labelledby":`mct:collapsible:${b.baseId}`,"aria-hidden":!b.open,hidden:b.open?void 0:!0},[!b.open&&_(D),w.default?.()])}}),c={Root:n,Trigger:h,Panel:i};import{defineComponent as N,h as $,onBeforeUpdate as l,provide as g,reactive as d,ref as r,toRef as t,useId as T}from"vue";var o=N({props:{menubar:Boolean},setup(y,{slots:w}){let b=T();return g(J,d({id:b,root:!0,menubar:t(y,"menubar")})),()=>$("div",{id:`mcr:menu:${b}`},w.default?.())}}),p=N({setup(y,{slots:w}){let b=z(J,"Menu.Trigger");return()=>$("button",{type:"button",id:`mct:menu:${b.id}`,"aria-controls":`mcc:menu:${b.id}`,"aria-expanded":"false","aria-haspopup":"menu",tabindex:b.root||b.first?0:-1,role:b.submenu?"menuitem":"button"},w.default?.())}}),e=N({setup(y,{slots:w}){let b=z(J,"Menu.Popover"),M=r(!1);return l(()=>{M.value=!1}),g(G,{claimFirst:()=>{if(!M.value)return M.value=!0,!0;return!1}}),()=>b.menubar?$("ul",{role:"menubar"},w.default?.()):$("ul",{role:"menu",id:`mcc:menu:${b.id}`,"aria-labelledby":`mct:menu:${b.id}`,"aria-hidden":"true",popover:"manual"},w.default?.())}}),s=N({inheritAttrs:!1,props:{disabled:Boolean,href:String},setup(y,{slots:w,attrs:b}){return()=>{let M=y.disabled?$("span",{...b,role:"menuitem","aria-disabled":"true",tabindex:-1},w.default?.()):y.href?$("a",{...b,role:"menuitem",href:y.href,tabindex:-1},w.default?.()):$("button",{...b,type:"button",role:"menuitem",tabindex:-1},w.default?.());return $("li",{role:"none"},[M])}}}),bb=N({inheritAttrs:!1,props:{checked:{type:Boolean,default:!1},disabled:Boolean},setup(y,{slots:w,attrs:b}){return()=>{let M=y.disabled?$("span",{...b,role:"menuitemcheckbox","aria-checked":y.checked,"aria-disabled":"true",tabindex:-1},w.default?.()):$("button",{...b,type:"button",role:"menuitemcheckbox","aria-checked":y.checked,tabindex:-1},w.default?.());return $("li",{role:"none"},[M])}}}),yb=N({inheritAttrs:!1,props:{checked:{type:Boolean,default:!1},disabled:Boolean},setup(y,{slots:w,attrs:b}){return()=>{let M=y.disabled?$("span",{...b,role:"menuitemradio","aria-checked":y.checked,"aria-disabled":"true",tabindex:-1},w.default?.()):$("button",{...b,type:"button",role:"menuitemradio","aria-checked":y.checked,tabindex:-1},w.default?.());return $("li",{role:"none"},[M])}}}),wb=N({setup(y,{slots:w}){return()=>$("li",{role:"presentation"},w.default?.())}}),$b=N({setup(){return()=>$("li",{role:"separator"})}}),Mb=N({setup(y,{slots:w}){let b=z(J,"Menu.Group"),E=z(G,"Menu.Group").claimFirst(),U=T(),V=E&&b.menubar&&!b.submenu;return g(J,{id:U,submenu:!0,first:V}),()=>$("li",{role:"none"},w.default?.())}}),zb={Root:o,Trigger:p,Popover:e,Item:s,CheckboxItem:bb,RadioItem:yb,Label:wb,Separator:$b,Group:Mb};import{computed as x,defineComponent as A,h as X,provide as Eb,reactive as Nb,toRef as Db,useId as Jb}from"vue";var Ob=A({props:{defaultValue:{type:String,required:!0},orientation:{type:String,default:"horizontal"}},setup(y,{slots:w}){let b=Jb();return Eb(Q,Nb({baseId:b,selected:y.defaultValue,orientation:Db(y,"orientation")})),()=>X("div",{"data-orientation":y.orientation,id:`mcr:tabs:${b}`},w.default?.())}}),Qb=A({setup(y,{slots:w}){let b=z(Q,"Tabs.List/Tab/Panel");return()=>X("div",{role:"tablist","aria-orientation":b.orientation},w.default?.())}}),Wb=A({props:{value:{type:String,required:!0},selected:{type:[Boolean,null],default:null},disabled:Boolean},setup(y,{slots:w}){let b=z(Q,"Tabs.List/Tab/Panel"),M=x(()=>B(b.baseId,y.value)),E=x(()=>y.selected!==null?y.selected:y.value===b.selected);return()=>X("button",{type:"button",role:"tab",id:`mct:tabs:${M.value}`,"aria-selected":E.value,"aria-controls":`mcc:tabs:${M.value}`,tabindex:E.value?0:-1,"aria-disabled":y.disabled||void 0},w.default?.())}}),Xb=A({props:{value:{type:String,required:!0},selected:{type:[Boolean,null],default:null},focusable:{type:Boolean,default:!0}},setup(y,{slots:w}){let b=z(Q,"Tabs.List/Tab/Panel"),M=x(()=>B(b.baseId,y.value)),E=x(()=>y.selected!==null?y.selected:y.value===b.selected);return()=>X("div",{role:"tabpanel",id:`mcc:tabs:${M.value}`,"aria-labelledby":`mct:tabs:${M.value}`,"aria-hidden":!E.value,hidden:E.value?void 0:!0,tabindex:y.focusable?E.value?0:-1:void 0,"data-orientation":b.orientation},[!E.value&&X(D),w.default?.()])}}),Yb={Root:Ob,List:Qb,Tab:Wb,Panel:Xb};export{Yb as Tabs,zb as Menu,c as Collapsible,m as Accordion};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
export declare const Menu: {
|
|
2
|
+
Root: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
3
|
+
menubar: BooleanConstructor;
|
|
4
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
5
|
+
[key: string]: any;
|
|
6
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
7
|
+
menubar: BooleanConstructor;
|
|
8
|
+
}>> & Readonly<{}>, {
|
|
9
|
+
menubar: boolean;
|
|
10
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
11
|
+
Trigger: import("vue").DefineComponent<{}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
12
|
+
[key: string]: any;
|
|
13
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
14
|
+
Popover: import("vue").DefineComponent<{}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
15
|
+
[key: string]: any;
|
|
16
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
17
|
+
Item: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
18
|
+
disabled: BooleanConstructor;
|
|
19
|
+
href: StringConstructor;
|
|
20
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
21
|
+
[key: string]: any;
|
|
22
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
23
|
+
disabled: BooleanConstructor;
|
|
24
|
+
href: StringConstructor;
|
|
25
|
+
}>> & Readonly<{}>, {
|
|
26
|
+
disabled: boolean;
|
|
27
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
28
|
+
CheckboxItem: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
29
|
+
checked: {
|
|
30
|
+
type: BooleanConstructor;
|
|
31
|
+
default: boolean;
|
|
32
|
+
};
|
|
33
|
+
disabled: BooleanConstructor;
|
|
34
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
35
|
+
[key: string]: any;
|
|
36
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
37
|
+
checked: {
|
|
38
|
+
type: BooleanConstructor;
|
|
39
|
+
default: boolean;
|
|
40
|
+
};
|
|
41
|
+
disabled: BooleanConstructor;
|
|
42
|
+
}>> & Readonly<{}>, {
|
|
43
|
+
disabled: boolean;
|
|
44
|
+
checked: boolean;
|
|
45
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
46
|
+
RadioItem: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
47
|
+
checked: {
|
|
48
|
+
type: BooleanConstructor;
|
|
49
|
+
default: boolean;
|
|
50
|
+
};
|
|
51
|
+
disabled: BooleanConstructor;
|
|
52
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
53
|
+
[key: string]: any;
|
|
54
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
55
|
+
checked: {
|
|
56
|
+
type: BooleanConstructor;
|
|
57
|
+
default: boolean;
|
|
58
|
+
};
|
|
59
|
+
disabled: BooleanConstructor;
|
|
60
|
+
}>> & Readonly<{}>, {
|
|
61
|
+
disabled: boolean;
|
|
62
|
+
checked: boolean;
|
|
63
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
64
|
+
Label: import("vue").DefineComponent<{}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
65
|
+
[key: string]: any;
|
|
66
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
67
|
+
Separator: import("vue").DefineComponent<{}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
68
|
+
[key: string]: any;
|
|
69
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
70
|
+
Group: import("vue").DefineComponent<{}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
71
|
+
[key: string]: any;
|
|
72
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
73
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { InjectionKey } from "vue";
|
|
2
|
+
export declare function requireInject<T>(key: InjectionKey<T>, component: string): T;
|
|
3
|
+
export declare const buildId: (base: string, id?: string) => string;
|
|
4
|
+
export declare const HiddenUntilFound: () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
5
|
+
[key: string]: any;
|
|
6
|
+
}>;
|
|
7
|
+
export type CollapsibleContext = {
|
|
8
|
+
baseId: string;
|
|
9
|
+
open: boolean;
|
|
10
|
+
};
|
|
11
|
+
export declare const CollapsibleKey: InjectionKey<CollapsibleContext>;
|
|
12
|
+
export type AccordionContext = {
|
|
13
|
+
baseId: string;
|
|
14
|
+
open: boolean;
|
|
15
|
+
disabled: boolean;
|
|
16
|
+
};
|
|
17
|
+
export declare const AccordionKey: InjectionKey<AccordionContext>;
|
|
18
|
+
export type TabsContext = {
|
|
19
|
+
baseId: string;
|
|
20
|
+
selected: string;
|
|
21
|
+
orientation: "horizontal" | "vertical";
|
|
22
|
+
};
|
|
23
|
+
export declare const TabsKey: InjectionKey<TabsContext>;
|
|
24
|
+
export type MenuContext = {
|
|
25
|
+
id: string;
|
|
26
|
+
root?: boolean;
|
|
27
|
+
menubar?: boolean;
|
|
28
|
+
submenu?: boolean;
|
|
29
|
+
first?: boolean;
|
|
30
|
+
};
|
|
31
|
+
export declare const MenuKey: InjectionKey<MenuContext>;
|
|
32
|
+
export type MenuPopupContext = {
|
|
33
|
+
claimFirst: () => boolean;
|
|
34
|
+
};
|
|
35
|
+
export declare const MenuPopupKey: InjectionKey<MenuPopupContext>;
|