@cerevialabs/ui 0.0.0-stage → 0.5.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/components/accordion/content/attrs.js +7 -0
- package/components/accordion/content/content.d.ts +2 -0
- package/components/accordion/content/content.js +18 -0
- package/components/accordion/content/index.d.ts +3 -0
- package/components/accordion/content/types.d.ts +3 -0
- package/components/accordion/context/context.d.ts +1 -0
- package/components/accordion/context/context.js +12 -0
- package/components/accordion/context/hooks.d.ts +3 -0
- package/components/accordion/context/hooks.js +49 -0
- package/components/accordion/context/index.d.ts +4 -0
- package/components/accordion/context/types.d.ts +14 -0
- package/components/accordion/context/utils.js +28 -0
- package/components/accordion/header/attrs.js +7 -0
- package/components/accordion/header/header.d.ts +2 -0
- package/components/accordion/header/header.js +17 -0
- package/components/accordion/header/index.d.ts +3 -0
- package/components/accordion/header/types.d.ts +3 -0
- package/components/accordion/index.d.ts +27 -0
- package/components/accordion/index.js +16 -0
- package/components/accordion/item/attrs.js +7 -0
- package/components/accordion/item/hooks.d.ts +3 -0
- package/components/accordion/item/hooks.js +22 -0
- package/components/accordion/item/index.d.ts +4 -0
- package/components/accordion/item/item.d.ts +2 -0
- package/components/accordion/item/item.js +23 -0
- package/components/accordion/item/types.d.ts +9 -0
- package/components/accordion/root/attrs.js +10 -0
- package/components/accordion/root/hooks.js +31 -0
- package/components/accordion/root/index.d.ts +3 -0
- package/components/accordion/root/root.d.ts +2 -0
- package/components/accordion/root/root.js +27 -0
- package/components/accordion/root/types.d.ts +19 -0
- package/components/accordion/trigger/attrs.js +7 -0
- package/components/accordion/trigger/index.d.ts +3 -0
- package/components/accordion/trigger/trigger.d.ts +2 -0
- package/components/accordion/trigger/trigger.js +10 -0
- package/components/accordion/trigger/types.d.ts +3 -0
- package/components/button/a11y.js +6 -0
- package/components/button/attrs.js +3 -0
- package/components/button/button.d.ts +2 -0
- package/components/button/button.js +25 -0
- package/components/button/index.d.ts +4 -0
- package/components/button/index.js +4 -0
- package/components/button/types.d.ts +5 -0
- package/components/collapsible/content/attrs.js +7 -0
- package/components/collapsible/content/content.d.ts +2 -0
- package/components/collapsible/content/content.js +18 -0
- package/components/collapsible/content/index.d.ts +3 -0
- package/components/collapsible/content/types.d.ts +3 -0
- package/components/collapsible/context/hooks.d.ts +2 -0
- package/components/collapsible/context/hooks.js +7 -0
- package/components/collapsible/context/index.d.ts +3 -0
- package/components/collapsible/context/types.d.ts +3 -0
- package/components/collapsible/index.d.ts +18 -0
- package/components/collapsible/index.js +11 -0
- package/components/collapsible/root/attrs.js +7 -0
- package/components/collapsible/root/index.d.ts +3 -0
- package/components/collapsible/root/root.d.ts +2 -0
- package/components/collapsible/root/root.js +10 -0
- package/components/collapsible/root/types.d.ts +3 -0
- package/components/collapsible/trigger/attrs.js +7 -0
- package/components/collapsible/trigger/index.d.ts +3 -0
- package/components/collapsible/trigger/trigger.d.ts +2 -0
- package/components/collapsible/trigger/trigger.js +10 -0
- package/components/collapsible/trigger/types.d.ts +3 -0
- package/components/index.d.ts +26 -0
- package/components/index.js +9 -0
- package/components/internal/disclosure/attrs.js +8 -0
- package/components/internal/disclosure/content/a11y.js +5 -0
- package/components/internal/disclosure/content/attrs.js +6 -0
- package/components/internal/disclosure/content/content.d.ts +1 -0
- package/components/internal/disclosure/content/content.js +30 -0
- package/components/internal/disclosure/content/hooks.js +81 -0
- package/components/internal/disclosure/content/index.d.ts +3 -0
- package/components/internal/disclosure/content/types.d.ts +11 -0
- package/components/internal/disclosure/content/utils.js +49 -0
- package/components/internal/disclosure/context/context.d.ts +1 -0
- package/components/internal/disclosure/context/context.js +12 -0
- package/components/internal/disclosure/context/hooks.d.ts +1 -0
- package/components/internal/disclosure/context/hooks.js +24 -0
- package/components/internal/disclosure/context/index.d.ts +4 -0
- package/components/internal/disclosure/context/types.d.ts +8 -0
- package/components/internal/disclosure/index.d.ts +9 -0
- package/components/internal/disclosure/index.js +11 -0
- package/components/internal/disclosure/root/hooks.js +23 -0
- package/components/internal/disclosure/root/index.d.ts +3 -0
- package/components/internal/disclosure/root/root.d.ts +1 -0
- package/components/internal/disclosure/root/root.js +27 -0
- package/components/internal/disclosure/root/types.d.ts +8 -0
- package/components/internal/disclosure/trigger/a11y.js +8 -0
- package/components/internal/disclosure/trigger/events.js +9 -0
- package/components/internal/disclosure/trigger/hooks.js +27 -0
- package/components/internal/disclosure/trigger/index.d.ts +3 -0
- package/components/internal/disclosure/trigger/trigger.d.ts +1 -0
- package/components/internal/disclosure/trigger/trigger.js +24 -0
- package/components/internal/disclosure/trigger/types.d.ts +3 -0
- package/components/scroll-area/content/attrs.js +21 -0
- package/components/scroll-area/content/content.d.ts +2 -0
- package/components/scroll-area/content/content.js +29 -0
- package/components/scroll-area/content/hooks.js +55 -0
- package/components/scroll-area/content/index.d.ts +3 -0
- package/components/scroll-area/content/types.d.ts +3 -0
- package/components/scroll-area/content/utils.js +34 -0
- package/components/scroll-area/context/context.d.ts +1 -0
- package/components/scroll-area/context/context.js +12 -0
- package/components/scroll-area/context/hooks.d.ts +3 -0
- package/components/scroll-area/context/hooks.js +170 -0
- package/components/scroll-area/context/index.d.ts +4 -0
- package/components/scroll-area/context/types.d.ts +47 -0
- package/components/scroll-area/context/utils.js +72 -0
- package/components/scroll-area/corner/attrs.js +10 -0
- package/components/scroll-area/corner/corner.d.ts +2 -0
- package/components/scroll-area/corner/corner.js +26 -0
- package/components/scroll-area/corner/hooks.js +12 -0
- package/components/scroll-area/corner/index.d.ts +3 -0
- package/components/scroll-area/corner/types.d.ts +3 -0
- package/components/scroll-area/index.d.ts +26 -0
- package/components/scroll-area/index.js +15 -0
- package/components/scroll-area/root/attrs.js +21 -0
- package/components/scroll-area/root/hooks.js +45 -0
- package/components/scroll-area/root/index.d.ts +3 -0
- package/components/scroll-area/root/root.d.ts +2 -0
- package/components/scroll-area/root/root.js +33 -0
- package/components/scroll-area/root/types.d.ts +8 -0
- package/components/scroll-area/scrollbar/a11y.js +12 -0
- package/components/scroll-area/scrollbar/attrs.js +12 -0
- package/components/scroll-area/scrollbar/context.d.ts +1 -0
- package/components/scroll-area/scrollbar/context.js +10 -0
- package/components/scroll-area/scrollbar/hooks.js +77 -0
- package/components/scroll-area/scrollbar/index.d.ts +4 -0
- package/components/scroll-area/scrollbar/scrollbar.d.ts +2 -0
- package/components/scroll-area/scrollbar/scrollbar.js +38 -0
- package/components/scroll-area/scrollbar/types.d.ts +8 -0
- package/components/scroll-area/thumb/attrs.js +7 -0
- package/components/scroll-area/thumb/hooks.js +75 -0
- package/components/scroll-area/thumb/index.d.ts +3 -0
- package/components/scroll-area/thumb/thumb.d.ts +2 -0
- package/components/scroll-area/thumb/thumb.js +26 -0
- package/components/scroll-area/thumb/types.d.ts +3 -0
- package/package.json +34 -4
- package/utils/apply-a11y.d.ts +5 -0
- package/utils/apply-a11y.js +11 -0
- package/utils/apply-attrs.d.ts +6 -0
- package/utils/apply-attrs.js +8 -0
- package/utils/data-attrs.d.ts +8 -0
- package/utils/data-attrs.js +21 -0
- package/utils/index.d.ts +11 -0
- package/utils/index.js +11 -0
- package/utils/merge-props.d.ts +4 -0
- package/utils/merge-props.js +68 -0
- package/utils/merge-refs.d.ts +2 -0
- package/utils/merge-refs.js +69 -0
- package/utils/prefers-reduced-motion.d.ts +1 -0
- package/utils/prefers-reduced-motion.js +19 -0
- package/utils/to-kebab-case.d.ts +1 -0
- package/utils/to-kebab-case.js +5 -0
- package/utils/use-controllable-state.d.ts +9 -0
- package/utils/use-controllable-state.js +38 -0
- package/utils/use-presence.d.ts +27 -0
- package/utils/use-presence.js +234 -0
- package/utils/use-render.d.ts +20 -0
- package/utils/use-render.js +74 -0
- package/README.md +0 -3
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { applyAttrs } from "../../../utils/apply-attrs.js";
|
|
2
|
+
// components/accordion/content/attrs.ts
|
|
3
|
+
const accordionContentAttrStates = [];
|
|
4
|
+
function accordionContentAttrs() {
|
|
5
|
+
return applyAttrs("accordion", accordionContentAttrStates, {}, { part: "content" });
|
|
6
|
+
}
|
|
7
|
+
export { accordionContentAttrs };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Disclosure } from "../../internal/disclosure/index.js";
|
|
3
|
+
import { accordionContentAttrs } from "./attrs.js";
|
|
4
|
+
import { mergeProps } from "../../../utils/merge-props.js";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
// components/accordion/content/content.tsx
|
|
7
|
+
const accordionContentSizeCssVars = {
|
|
8
|
+
width: "--accordion-content-width",
|
|
9
|
+
height: "--accordion-content-height"
|
|
10
|
+
};
|
|
11
|
+
function AccordionContent({ keepMounted, ...props }) {
|
|
12
|
+
return /* @__PURE__ */ jsx(Disclosure.Content, {
|
|
13
|
+
keepMounted,
|
|
14
|
+
sizeCssVars: accordionContentSizeCssVars,
|
|
15
|
+
...mergeProps(accordionContentAttrs(), props)
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
export { AccordionContent };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./types.js";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { createContext } from "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
// components/accordion/context/context.tsx
|
|
5
|
+
const AccordionContext = createContext(void 0);
|
|
6
|
+
function AccordionProvider({ contextValue, children }) {
|
|
7
|
+
return /* @__PURE__ */ jsx(AccordionContext.Provider, {
|
|
8
|
+
value: contextValue,
|
|
9
|
+
children
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
export { AccordionContext, AccordionProvider };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { use } from "react";
|
|
3
|
+
import { AccordionContext } from "./context.js";
|
|
4
|
+
import { nextOpenValues, toDefaultList, toOpenList, toPublicValue } from "./utils.js";
|
|
5
|
+
import { useControllableState } from "../../../utils/use-controllable-state.js";
|
|
6
|
+
// components/accordion/context/hooks.ts
|
|
7
|
+
function useAccordionProviderValue(props) {
|
|
8
|
+
const type = props.type === "multiple" ? "multiple" : "single";
|
|
9
|
+
const disabled = props.disabled ?? false;
|
|
10
|
+
const onValueChange = props.onValueChange;
|
|
11
|
+
const [openValues, setOpenValues] = useControllableState({
|
|
12
|
+
value: toOpenList(type, props.value),
|
|
13
|
+
defaultValue: toDefaultList(type, props.defaultValue),
|
|
14
|
+
onChange(next) {
|
|
15
|
+
if (type === "single") {
|
|
16
|
+
onValueChange?.(toPublicValue("single", next) ?? "");
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
onValueChange?.(toPublicValue("multiple", next));
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
const value = toPublicValue(type, openValues);
|
|
23
|
+
function toggle(itemValue, open) {
|
|
24
|
+
setOpenValues((current) => nextOpenValues(current, itemValue, open, type));
|
|
25
|
+
}
|
|
26
|
+
function isOpen(itemValue) {
|
|
27
|
+
return openValues.includes(itemValue);
|
|
28
|
+
}
|
|
29
|
+
if (type === "single") return {
|
|
30
|
+
type,
|
|
31
|
+
value,
|
|
32
|
+
disabled,
|
|
33
|
+
isOpen,
|
|
34
|
+
toggle
|
|
35
|
+
};
|
|
36
|
+
return {
|
|
37
|
+
type,
|
|
38
|
+
value,
|
|
39
|
+
disabled,
|
|
40
|
+
isOpen,
|
|
41
|
+
toggle
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function useAccordionContext() {
|
|
45
|
+
const context = use(AccordionContext);
|
|
46
|
+
if (!context) throw new Error("Accordion parts must be used within Accordion.Root");
|
|
47
|
+
return context;
|
|
48
|
+
}
|
|
49
|
+
export { useAccordionContext, useAccordionProviderValue };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import "react";
|
|
2
|
+
interface AccordionContextBase {
|
|
3
|
+
disabled: boolean;
|
|
4
|
+
isOpen: (itemValue: string) => boolean;
|
|
5
|
+
toggle: (itemValue: string, open: boolean) => void;
|
|
6
|
+
}
|
|
7
|
+
type AccordionContextValue = (AccordionContextBase & {
|
|
8
|
+
type: "single";
|
|
9
|
+
value: string;
|
|
10
|
+
}) | (AccordionContextBase & {
|
|
11
|
+
type: "multiple";
|
|
12
|
+
value: string[];
|
|
13
|
+
});
|
|
14
|
+
export type { AccordionContextValue };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// components/accordion/context/utils.ts
|
|
2
|
+
function toOpenList(type, value) {
|
|
3
|
+
if (value === void 0) return void 0;
|
|
4
|
+
if (type === "single") return value === "" ? [] : [value];
|
|
5
|
+
return value;
|
|
6
|
+
}
|
|
7
|
+
function toDefaultList(type, value) {
|
|
8
|
+
return toOpenList(type, value) ?? [];
|
|
9
|
+
}
|
|
10
|
+
function toPublicValue(type, openValues) {
|
|
11
|
+
if (type === "single") return openValues[0] ?? "";
|
|
12
|
+
return [...openValues];
|
|
13
|
+
}
|
|
14
|
+
function nextOpenValues(current, itemValue, open, type) {
|
|
15
|
+
if (itemValue === "") return [...current];
|
|
16
|
+
if (!open) {
|
|
17
|
+
if (type === "single") return current.length === 0 ? [...current] : [];
|
|
18
|
+
if (!current.includes(itemValue)) return [...current];
|
|
19
|
+
return current.filter((entry) => entry !== itemValue);
|
|
20
|
+
}
|
|
21
|
+
if (type === "single") {
|
|
22
|
+
if (current.length === 1 && current[0] === itemValue) return [...current];
|
|
23
|
+
return [itemValue];
|
|
24
|
+
}
|
|
25
|
+
if (current.includes(itemValue)) return [...current];
|
|
26
|
+
return [...current, itemValue];
|
|
27
|
+
}
|
|
28
|
+
export { nextOpenValues, toDefaultList, toOpenList, toPublicValue };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { applyAttrs } from "../../../utils/apply-attrs.js";
|
|
2
|
+
// components/accordion/header/attrs.ts
|
|
3
|
+
const accordionHeaderAttrStates = [];
|
|
4
|
+
function accordionHeaderAttrs() {
|
|
5
|
+
return applyAttrs("accordion", accordionHeaderAttrStates, {}, { part: "header" });
|
|
6
|
+
}
|
|
7
|
+
export { accordionHeaderAttrs };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { accordionHeaderAttrs } from "./attrs.js";
|
|
3
|
+
import { mergeProps } from "../../../utils/merge-props.js";
|
|
4
|
+
import { useRender } from "../../../utils/use-render.js";
|
|
5
|
+
// components/accordion/header/header.tsx
|
|
6
|
+
function AccordionHeader({ ref, render, className, children, ...props }) {
|
|
7
|
+
return useRender({
|
|
8
|
+
defaultTagName: "h3",
|
|
9
|
+
ref,
|
|
10
|
+
render,
|
|
11
|
+
props: mergeProps({
|
|
12
|
+
className,
|
|
13
|
+
children
|
|
14
|
+
}, accordionHeaderAttrs(), props)
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
export { AccordionHeader };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { AccordionContextValue } from "./context/types.js";
|
|
2
|
+
import { useAccordionContext } from "./context/hooks.js";
|
|
3
|
+
import "./context/index.js";
|
|
4
|
+
import { AccordionContentProps } from "./content/types.js";
|
|
5
|
+
import { AccordionContent } from "./content/content.js";
|
|
6
|
+
import "./content/index.js";
|
|
7
|
+
import { AccordionHeaderProps } from "./header/types.js";
|
|
8
|
+
import { AccordionHeader } from "./header/header.js";
|
|
9
|
+
import "./header/index.js";
|
|
10
|
+
import { AccordionItemContextValue, AccordionItemProps } from "./item/types.js";
|
|
11
|
+
import { AccordionItem } from "./item/item.js";
|
|
12
|
+
import { useAccordionItemContext } from "./item/hooks.js";
|
|
13
|
+
import "./item/index.js";
|
|
14
|
+
import { AccordionRootProps } from "./root/types.js";
|
|
15
|
+
import { AccordionRoot } from "./root/root.js";
|
|
16
|
+
import "./root/index.js";
|
|
17
|
+
import { AccordionTriggerProps } from "./trigger/types.js";
|
|
18
|
+
import { AccordionTrigger } from "./trigger/trigger.js";
|
|
19
|
+
import "./trigger/index.js";
|
|
20
|
+
export declare const Accordion: {
|
|
21
|
+
Root: typeof AccordionRoot;
|
|
22
|
+
Item: typeof AccordionItem;
|
|
23
|
+
Header: typeof AccordionHeader;
|
|
24
|
+
Trigger: typeof AccordionTrigger;
|
|
25
|
+
Content: typeof AccordionContent;
|
|
26
|
+
};
|
|
27
|
+
export { type AccordionContentProps, type AccordionContextValue, type AccordionHeaderProps, type AccordionItemContextValue, type AccordionItemProps, type AccordionRootProps, type AccordionTriggerProps, useAccordionContext, useAccordionItemContext };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useAccordionContext } from "./context/hooks.js";
|
|
2
|
+
import { AccordionContent } from "./content/content.js";
|
|
3
|
+
import { AccordionHeader } from "./header/header.js";
|
|
4
|
+
import { AccordionItem } from "./item/item.js";
|
|
5
|
+
import { useAccordionItemContext } from "./item/hooks.js";
|
|
6
|
+
import { AccordionRoot } from "./root/root.js";
|
|
7
|
+
import { AccordionTrigger } from "./trigger/trigger.js";
|
|
8
|
+
// components/accordion/index.ts
|
|
9
|
+
const Accordion = {
|
|
10
|
+
Root: AccordionRoot,
|
|
11
|
+
Item: AccordionItem,
|
|
12
|
+
Header: AccordionHeader,
|
|
13
|
+
Trigger: AccordionTrigger,
|
|
14
|
+
Content: AccordionContent
|
|
15
|
+
};
|
|
16
|
+
export { Accordion, useAccordionContext, useAccordionItemContext };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { applyAttrs } from "../../../utils/apply-attrs.js";
|
|
2
|
+
// components/accordion/item/attrs.ts
|
|
3
|
+
const accordionItemAttrStates = [];
|
|
4
|
+
function accordionItemAttrs() {
|
|
5
|
+
return applyAttrs("accordion", accordionItemAttrStates, {}, { part: "item" });
|
|
6
|
+
}
|
|
7
|
+
export { accordionItemAttrs };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useDisclosureContext } from "../../internal/disclosure/context/hooks.js";
|
|
3
|
+
import { useAccordionContext } from "../context/hooks.js";
|
|
4
|
+
import { accordionItemAttrs } from "./attrs.js";
|
|
5
|
+
// components/accordion/item/hooks.ts
|
|
6
|
+
function useAccordionItem({ value, disabled = false }) {
|
|
7
|
+
const group = useAccordionContext();
|
|
8
|
+
const itemDisabled = group.disabled || disabled;
|
|
9
|
+
return {
|
|
10
|
+
open: group.isOpen(value),
|
|
11
|
+
disabled: itemDisabled,
|
|
12
|
+
attrs: accordionItemAttrs(),
|
|
13
|
+
onOpenChange(open) {
|
|
14
|
+
if (itemDisabled) return;
|
|
15
|
+
group.toggle(value, open);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
function useAccordionItemContext() {
|
|
20
|
+
return useDisclosureContext();
|
|
21
|
+
}
|
|
22
|
+
export { useAccordionItem, useAccordionItemContext };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { AccordionItem } from "./item.js";
|
|
2
|
+
import { useAccordionItemContext } from "./hooks.js";
|
|
3
|
+
import { AccordionItemContextValue, AccordionItemProps } from "./types.js";
|
|
4
|
+
export { AccordionItem, type AccordionItemContextValue, type AccordionItemProps, useAccordionItemContext };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Disclosure } from "../../internal/disclosure/index.js";
|
|
3
|
+
import { useAccordionItem } from "./hooks.js";
|
|
4
|
+
import { mergeProps } from "../../../utils/merge-props.js";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
// components/accordion/item/item.tsx
|
|
7
|
+
function AccordionItem({ ref, render, value, disabled, className, children, ...props }) {
|
|
8
|
+
const item = useAccordionItem({
|
|
9
|
+
value,
|
|
10
|
+
disabled
|
|
11
|
+
});
|
|
12
|
+
return /* @__PURE__ */ jsx(Disclosure.Root, {
|
|
13
|
+
ref,
|
|
14
|
+
render,
|
|
15
|
+
open: item.open,
|
|
16
|
+
onOpenChange: item.onOpenChange,
|
|
17
|
+
disabled: item.disabled,
|
|
18
|
+
className,
|
|
19
|
+
...mergeProps(item.attrs, props),
|
|
20
|
+
children
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
export { AccordionItem };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DisclosureContextValue } from "../../internal/disclosure/context/types.js";
|
|
2
|
+
import { UseRenderComponentProps } from "../../../utils/use-render.js";
|
|
3
|
+
import "../../internal/disclosure/index.js";
|
|
4
|
+
import "../../../utils/index.js";
|
|
5
|
+
export type AccordionItemContextValue = DisclosureContextValue;
|
|
6
|
+
export interface AccordionItemProps extends UseRenderComponentProps<"div"> {
|
|
7
|
+
value: string;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { applyAttrs } from "../../../utils/apply-attrs.js";
|
|
2
|
+
// components/accordion/root/attrs.ts
|
|
3
|
+
const accordionRootAttrStates = ["disabled"];
|
|
4
|
+
function accordionRootAttrs({ type, disabled }) {
|
|
5
|
+
return {
|
|
6
|
+
...applyAttrs("accordion", accordionRootAttrStates, { disabled }, { part: "root" }),
|
|
7
|
+
"data-type": type
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export { accordionRootAttrs };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useAccordionContext, useAccordionProviderValue } from "../context/hooks.js";
|
|
3
|
+
import { accordionRootAttrs } from "./attrs.js";
|
|
4
|
+
// components/accordion/root/hooks.ts
|
|
5
|
+
function useAccordionRoot(props) {
|
|
6
|
+
const contextValue = useAccordionProviderValue({
|
|
7
|
+
type: props.type,
|
|
8
|
+
value: props.value,
|
|
9
|
+
defaultValue: props.defaultValue,
|
|
10
|
+
onValueChange: props.onValueChange,
|
|
11
|
+
disabled: props.disabled
|
|
12
|
+
});
|
|
13
|
+
const hostProps = { ...props };
|
|
14
|
+
delete hostProps.type;
|
|
15
|
+
delete hostProps.value;
|
|
16
|
+
delete hostProps.defaultValue;
|
|
17
|
+
delete hostProps.onValueChange;
|
|
18
|
+
delete hostProps.disabled;
|
|
19
|
+
return {
|
|
20
|
+
contextValue,
|
|
21
|
+
hostProps
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function useAccordionRootHost() {
|
|
25
|
+
const { type, disabled } = useAccordionContext();
|
|
26
|
+
return { attrs: accordionRootAttrs({
|
|
27
|
+
type,
|
|
28
|
+
disabled
|
|
29
|
+
}) };
|
|
30
|
+
}
|
|
31
|
+
export { useAccordionRoot, useAccordionRootHost };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { AccordionProvider } from "../context/context.js";
|
|
3
|
+
import { useAccordionRoot, useAccordionRootHost } from "./hooks.js";
|
|
4
|
+
import { mergeProps } from "../../../utils/merge-props.js";
|
|
5
|
+
import { useRender } from "../../../utils/use-render.js";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
// components/accordion/root/root.tsx
|
|
8
|
+
function AccordionRootHost({ ref, render, className, children, ...props }) {
|
|
9
|
+
const { attrs } = useAccordionRootHost();
|
|
10
|
+
return useRender({
|
|
11
|
+
defaultTagName: "div",
|
|
12
|
+
ref,
|
|
13
|
+
render,
|
|
14
|
+
props: mergeProps({
|
|
15
|
+
className,
|
|
16
|
+
children
|
|
17
|
+
}, attrs, props)
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
function AccordionRoot(props) {
|
|
21
|
+
const { contextValue, hostProps } = useAccordionRoot(props);
|
|
22
|
+
return /* @__PURE__ */ jsx(AccordionProvider, {
|
|
23
|
+
contextValue,
|
|
24
|
+
children: /* @__PURE__ */ jsx(AccordionRootHost, { ...hostProps })
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
export { AccordionRoot };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { UseRenderComponentProps } from "../../../utils/use-render.js";
|
|
2
|
+
import "../../../utils/index.js";
|
|
3
|
+
interface AccordionRootSharedProps extends UseRenderComponentProps<"div"> {
|
|
4
|
+
disabled?: boolean;
|
|
5
|
+
}
|
|
6
|
+
interface AccordionRootSingleProps extends AccordionRootSharedProps {
|
|
7
|
+
type?: "single";
|
|
8
|
+
value?: string;
|
|
9
|
+
defaultValue?: string;
|
|
10
|
+
onValueChange?: (value: string) => void;
|
|
11
|
+
}
|
|
12
|
+
interface AccordionRootMultipleProps extends AccordionRootSharedProps {
|
|
13
|
+
type: "multiple";
|
|
14
|
+
value?: string[];
|
|
15
|
+
defaultValue?: string[];
|
|
16
|
+
onValueChange?: (value: string[]) => void;
|
|
17
|
+
}
|
|
18
|
+
type AccordionRootProps = AccordionRootSingleProps | AccordionRootMultipleProps;
|
|
19
|
+
export type { AccordionRootMultipleProps, AccordionRootProps, AccordionRootSharedProps, AccordionRootSingleProps };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { applyAttrs } from "../../../utils/apply-attrs.js";
|
|
2
|
+
// components/accordion/trigger/attrs.ts
|
|
3
|
+
const accordionTriggerAttrStates = [];
|
|
4
|
+
function accordionTriggerAttrs() {
|
|
5
|
+
return applyAttrs("accordion", accordionTriggerAttrStates, {}, { part: "trigger" });
|
|
6
|
+
}
|
|
7
|
+
export { accordionTriggerAttrs };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Disclosure } from "../../internal/disclosure/index.js";
|
|
3
|
+
import { accordionTriggerAttrs } from "./attrs.js";
|
|
4
|
+
import { mergeProps } from "../../../utils/merge-props.js";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
// components/accordion/trigger/trigger.tsx
|
|
7
|
+
function AccordionTrigger(props) {
|
|
8
|
+
return /* @__PURE__ */ jsx(Disclosure.Trigger, { ...mergeProps(accordionTriggerAttrs(), props) });
|
|
9
|
+
}
|
|
10
|
+
export { AccordionTrigger };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { buttonA11ySpec } from "./a11y.js";
|
|
3
|
+
import { buttonAttrStates } from "./attrs.js";
|
|
4
|
+
import { applyA11y } from "../../utils/apply-a11y.js";
|
|
5
|
+
import { applyAttrs } from "../../utils/apply-attrs.js";
|
|
6
|
+
import { mergeProps } from "../../utils/merge-props.js";
|
|
7
|
+
import { useRender } from "../../utils/use-render.js";
|
|
8
|
+
// components/button/button.tsx
|
|
9
|
+
function ButtonComponent({ ref, render, loading = false, type = "button", disabled = false, className, children, ...props }) {
|
|
10
|
+
return useRender({
|
|
11
|
+
defaultTagName: "button",
|
|
12
|
+
ref,
|
|
13
|
+
render,
|
|
14
|
+
props: mergeProps({
|
|
15
|
+
type,
|
|
16
|
+
disabled,
|
|
17
|
+
className,
|
|
18
|
+
children
|
|
19
|
+
}, applyA11y(buttonA11ySpec, { loading }), applyAttrs("button", buttonAttrStates, {
|
|
20
|
+
loading,
|
|
21
|
+
disabled
|
|
22
|
+
}), props, { disabled })
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
export { ButtonComponent };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { applyAttrs } from "../../../utils/apply-attrs.js";
|
|
2
|
+
// components/collapsible/content/attrs.ts
|
|
3
|
+
const collapsibleContentAttrStates = [];
|
|
4
|
+
function collapsibleContentAttrs() {
|
|
5
|
+
return applyAttrs("collapsible", collapsibleContentAttrStates, {}, { part: "content" });
|
|
6
|
+
}
|
|
7
|
+
export { collapsibleContentAttrs };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Disclosure } from "../../internal/disclosure/index.js";
|
|
3
|
+
import { collapsibleContentAttrs } from "./attrs.js";
|
|
4
|
+
import { mergeProps } from "../../../utils/merge-props.js";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
// components/collapsible/content/content.tsx
|
|
7
|
+
const collapsibleContentSizeCssVars = {
|
|
8
|
+
width: "--collapsible-content-width",
|
|
9
|
+
height: "--collapsible-content-height"
|
|
10
|
+
};
|
|
11
|
+
function CollapsibleContent({ keepMounted, ...props }) {
|
|
12
|
+
return /* @__PURE__ */ jsx(Disclosure.Content, {
|
|
13
|
+
keepMounted,
|
|
14
|
+
sizeCssVars: collapsibleContentSizeCssVars,
|
|
15
|
+
...mergeProps(collapsibleContentAttrs(), props)
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
export { CollapsibleContent };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { CollapsibleContextValue } from "./context/types.js";
|
|
2
|
+
import { useCollapsibleContext } from "./context/hooks.js";
|
|
3
|
+
import "./context/index.js";
|
|
4
|
+
import { CollapsibleContentProps } from "./content/types.js";
|
|
5
|
+
import { CollapsibleContent } from "./content/content.js";
|
|
6
|
+
import "./content/index.js";
|
|
7
|
+
import { CollapsibleRootProps } from "./root/types.js";
|
|
8
|
+
import { CollapsibleRoot } from "./root/root.js";
|
|
9
|
+
import "./root/index.js";
|
|
10
|
+
import { CollapsibleTriggerProps } from "./trigger/types.js";
|
|
11
|
+
import { CollapsibleTrigger } from "./trigger/trigger.js";
|
|
12
|
+
import "./trigger/index.js";
|
|
13
|
+
export declare const Collapsible: {
|
|
14
|
+
Root: typeof CollapsibleRoot;
|
|
15
|
+
Trigger: typeof CollapsibleTrigger;
|
|
16
|
+
Content: typeof CollapsibleContent;
|
|
17
|
+
};
|
|
18
|
+
export { type CollapsibleContentProps, type CollapsibleContextValue, type CollapsibleRootProps, type CollapsibleTriggerProps, useCollapsibleContext };
|