@askrjs/themes 0.0.16 → 0.0.17
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 +25 -0
- package/THEMING.md +6 -5
- package/dist/components/_internal/block-layout.d.ts +1 -0
- package/dist/components/_internal/block-layout.js +14 -11
- package/dist/components/_internal/block-layout.js.map +1 -1
- package/dist/components/_internal/classes.js +8 -1
- package/dist/components/_internal/classes.js.map +1 -1
- package/dist/components/_internal/jsx.js.map +1 -1
- package/dist/components/_internal/style.js +182 -28
- package/dist/components/_internal/style.js.map +1 -1
- package/dist/components/alert/alert.d.ts +1 -0
- package/dist/components/alert/alert.js.map +1 -1
- package/dist/components/alert/alert.types.d.ts +1 -0
- package/dist/components/aside/aside.d.ts +1 -0
- package/dist/components/aside/aside.js.map +1 -1
- package/dist/components/aspect-ratio/aspect-ratio.d.ts +1 -0
- package/dist/components/aspect-ratio/aspect-ratio.js.map +1 -1
- package/dist/components/aspect-ratio/aspect-ratio.types.d.ts +1 -0
- package/dist/components/badge/badge.d.ts +1 -0
- package/dist/components/badge/badge.js.map +1 -1
- package/dist/components/badge/badge.types.d.ts +1 -0
- package/dist/components/block/block.d.ts +1 -0
- package/dist/components/block/block.js +2 -2
- package/dist/components/block/block.js.map +1 -1
- package/dist/components/block/block.types.d.ts +1 -0
- package/dist/components/brand/brand.d.ts +1 -0
- package/dist/components/brand/brand.js +2 -2
- package/dist/components/brand/brand.js.map +1 -1
- package/dist/components/brand/brand.types.d.ts +1 -0
- package/dist/components/button-group/button-group.d.ts +1 -0
- package/dist/components/button-group/button-group.js.map +1 -1
- package/dist/components/button-group/button-group.types.d.ts +1 -0
- package/dist/components/card/card.d.ts +1 -0
- package/dist/components/card/card.js.map +1 -1
- package/dist/components/card/card.types.d.ts +1 -0
- package/dist/components/catalog.d.ts +1 -0
- package/dist/components/catalog.js +22 -13
- package/dist/components/catalog.js.map +1 -1
- package/dist/components/close/close.d.ts +1 -0
- package/dist/components/close/close.js.map +1 -1
- package/dist/components/container/container.d.ts +1 -0
- package/dist/components/container/container.js.map +1 -1
- package/dist/components/empty-state/empty-state.d.ts +1 -0
- package/dist/components/empty-state/empty-state.js.map +1 -1
- package/dist/components/field/field.d.ts +1 -0
- package/dist/components/field/field.js.map +1 -1
- package/dist/components/field/field.types.d.ts +1 -0
- package/dist/components/footer/footer.d.ts +1 -0
- package/dist/components/footer/footer.js.map +1 -1
- package/dist/components/footer/footer.types.d.ts +1 -0
- package/dist/components/grid/grid.d.ts +1 -0
- package/dist/components/grid/grid.js.map +1 -1
- package/dist/components/grid/grid.types.d.ts +1 -0
- package/dist/components/header/header.d.ts +1 -0
- package/dist/components/header/header.js.map +1 -1
- package/dist/components/input-group/input-group.d.ts +1 -0
- package/dist/components/input-group/input-group.js.map +1 -1
- package/dist/components/input-group/input-group.types.d.ts +1 -0
- package/dist/components/jsx-types.d.ts +12 -0
- package/dist/components/main/main.d.ts +1 -0
- package/dist/components/main/main.js.map +1 -1
- package/dist/components/nav/nav.d.ts +1 -0
- package/dist/components/nav/nav.js +6 -2
- package/dist/components/nav/nav.js.map +1 -1
- package/dist/components/nav/nav.types.d.ts +2 -0
- package/dist/components/navbar/navbar.d.ts +1 -0
- package/dist/components/navbar/navbar.js +15 -10
- package/dist/components/navbar/navbar.js.map +1 -1
- package/dist/components/overlays/dropdown-content.d.ts +1 -0
- package/dist/components/overlays/dropdown-content.js.map +1 -1
- package/dist/components/page/page.d.ts +1 -0
- package/dist/components/page/page.js.map +1 -1
- package/dist/components/page-header/page-header.d.ts +1 -0
- package/dist/components/page-header/page-header.js.map +1 -1
- package/dist/components/section/section.d.ts +1 -0
- package/dist/components/section/section.js.map +1 -1
- package/dist/components/separator/separator.d.ts +1 -0
- package/dist/components/separator/separator.js.map +1 -1
- package/dist/components/separator/separator.types.d.ts +1 -0
- package/dist/components/sidebar/index.d.ts +2 -2
- package/dist/components/sidebar/sidebar.d.ts +2 -1
- package/dist/components/sidebar/sidebar.js +39 -13
- package/dist/components/sidebar/sidebar.js.map +1 -1
- package/dist/components/sidebar/sidebar.types.d.ts +3 -1
- package/dist/components/skeleton/skeleton.d.ts +1 -0
- package/dist/components/skeleton/skeleton.js.map +1 -1
- package/dist/components/skeleton/skeleton.types.d.ts +1 -0
- package/dist/components/spinner/spinner.d.ts +1 -0
- package/dist/components/spinner/spinner.js.map +1 -1
- package/dist/components/stat/stat.d.ts +1 -0
- package/dist/components/stat/stat.js.map +1 -1
- package/dist/components/stat/stat.types.d.ts +1 -0
- package/dist/components/text/text.d.ts +1 -0
- package/dist/components/text/text.js.map +1 -1
- package/dist/components/text/text.types.d.ts +1 -0
- package/dist/components/theme/theme.d.ts +2 -0
- package/dist/components/theme/theme.js +32 -16
- package/dist/components/theme/theme.js.map +1 -1
- package/dist/components/toolbar/toolbar.d.ts +1 -0
- package/dist/components/toolbar/toolbar.js.map +1 -1
- package/dist/components.d.ts +6 -3
- package/dist/core.d.ts +2 -2
- package/dist/ssr.d.ts +18 -0
- package/dist/ssr.js +63 -0
- package/dist/ssr.js.map +1 -0
- package/dist/themes/default/index.css +36 -6
- package/package.json +7 -3
- package/src/components/_internal/block-layout.ts +27 -16
- package/src/components/_internal/classes.ts +15 -2
- package/src/components/_internal/jsx.ts +1 -1
- package/src/components/_internal/style.ts +241 -27
- package/src/components/alert/alert.tsx +1 -0
- package/src/components/alert/alert.types.ts +1 -0
- package/src/components/aside/aside.tsx +1 -0
- package/src/components/aspect-ratio/aspect-ratio.tsx +1 -0
- package/src/components/aspect-ratio/aspect-ratio.types.ts +1 -0
- package/src/components/badge/badge.tsx +1 -0
- package/src/components/badge/badge.types.ts +1 -0
- package/src/components/block/block.tsx +4 -1
- package/src/components/block/block.types.ts +1 -0
- package/src/components/brand/brand.tsx +6 -2
- package/src/components/brand/brand.types.ts +1 -0
- package/src/components/button-group/button-group.tsx +1 -0
- package/src/components/button-group/button-group.types.ts +1 -0
- package/src/components/card/card.tsx +1 -0
- package/src/components/card/card.types.ts +1 -0
- package/src/components/catalog.tsx +15 -4
- package/src/components/close/close.tsx +1 -0
- package/src/components/container/container.tsx +1 -0
- package/src/components/empty-state/empty-state.tsx +1 -0
- package/src/components/field/field.tsx +1 -0
- package/src/components/field/field.types.ts +1 -0
- package/src/components/footer/footer.tsx +1 -0
- package/src/components/footer/footer.types.ts +1 -0
- package/src/components/grid/grid.tsx +1 -0
- package/src/components/grid/grid.types.ts +1 -0
- package/src/components/header/header.tsx +1 -0
- package/src/components/input-group/input-group.tsx +1 -0
- package/src/components/input-group/input-group.types.ts +1 -0
- package/src/components/jsx-types.ts +16 -0
- package/src/components/main/main.tsx +1 -0
- package/src/components/nav/nav.tsx +16 -2
- package/src/components/nav/nav.types.ts +2 -0
- package/src/components/navbar/navbar.tsx +19 -8
- package/src/components/overlays/dropdown-content.tsx +1 -0
- package/src/components/page/page.tsx +1 -0
- package/src/components/page-header/page-header.tsx +1 -0
- package/src/components/section/section.tsx +1 -0
- package/src/components/separator/separator.tsx +1 -0
- package/src/components/separator/separator.types.ts +1 -0
- package/src/components/sidebar/index.ts +1 -0
- package/src/components/sidebar/sidebar.tsx +45 -20
- package/src/components/sidebar/sidebar.types.ts +3 -0
- package/src/components/skeleton/skeleton.tsx +1 -0
- package/src/components/skeleton/skeleton.types.ts +1 -0
- package/src/components/spinner/spinner.tsx +1 -0
- package/src/components/stat/stat.tsx +1 -0
- package/src/components/stat/stat.types.ts +1 -0
- package/src/components/text/text.tsx +1 -0
- package/src/components/text/text.types.ts +1 -0
- package/src/components/theme/theme.tsx +43 -12
- package/src/components/toolbar/toolbar.tsx +1 -0
- package/src/components.ts +9 -0
- package/src/ssr.ts +102 -0
- package/src/themes/default/styles/base/text.css +4 -4
- package/src/themes/default/styles/layout/layout.css +108 -0
- package/src/themes/default/styles/shell/navbar.css +4 -1
- package/src/themes/default/tokens.css +1 -1
- package/src/themes/presets/ginger.css +3 -3
- package/templates/theme/styles/base/text.css +4 -4
- package/templates/theme/styles/display/progress-circle.css +2 -0
- package/templates/theme/styles/forms/input-group.css +2 -1
- package/templates/theme/styles/layout/layout.css +108 -0
- package/templates/theme/styles/overlays/toast.css +11 -0
- package/templates/theme/styles/shell/navbar.css +4 -1
- package/templates/theme/styles/shell/sidebar.css +18 -1
- package/templates/theme/tokens.css +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { JSX } from "@askrjs/askr/jsx-runtime";
|
|
1
2
|
import { Slot } from "@askrjs/askr/foundations";
|
|
2
3
|
import { classes } from "../_internal/classes";
|
|
3
4
|
import {
|
|
@@ -15,8 +16,8 @@ const DEFAULT_ELEMENT = "div";
|
|
|
15
16
|
export function Block(props: BlockNativeProps): JSX.Element;
|
|
16
17
|
export function Block(props: BlockAsChildProps): JSX.Element;
|
|
17
18
|
export function Block(props: BlockNativeProps | BlockAsChildProps) {
|
|
18
|
-
const as = "as" in props ? props.as : DEFAULT_ELEMENT;
|
|
19
19
|
const {
|
|
20
|
+
as: asProp,
|
|
20
21
|
asChild,
|
|
21
22
|
children,
|
|
22
23
|
ref,
|
|
@@ -25,10 +26,12 @@ export function Block(props: BlockNativeProps | BlockAsChildProps) {
|
|
|
25
26
|
style: userStyle,
|
|
26
27
|
...rest
|
|
27
28
|
} = props as (BlockNativeProps | BlockAsChildProps) & {
|
|
29
|
+
as?: BlockNativeProps["as"];
|
|
28
30
|
class?: unknown;
|
|
29
31
|
className?: unknown;
|
|
30
32
|
style?: unknown;
|
|
31
33
|
};
|
|
34
|
+
const as = asProp ?? DEFAULT_ELEMENT;
|
|
32
35
|
|
|
33
36
|
const { blockProps, rest: passthroughProps } = splitBlockLayoutProps(rest);
|
|
34
37
|
const layoutStyle: Record<string, string | number> = {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { JSX } from "@askrjs/askr/jsx-runtime";
|
|
1
2
|
import { Slot } from "@askrjs/askr/foundations";
|
|
2
3
|
import { classes } from "../_internal/classes";
|
|
3
4
|
import { mergeProps } from "../_internal/merge-props";
|
|
@@ -16,14 +17,17 @@ export function Brand<TElement extends "div" | "a" | "span" = "div">(
|
|
|
16
17
|
props: BrandProps<TElement>,
|
|
17
18
|
): JSX.Element {
|
|
18
19
|
const {
|
|
20
|
+
as: asProp,
|
|
19
21
|
asChild,
|
|
20
22
|
children,
|
|
21
23
|
class: classProp,
|
|
22
24
|
className,
|
|
23
25
|
ref,
|
|
24
26
|
...rest
|
|
25
|
-
} = props as BrandNativeProps | BrandAsChildProps
|
|
26
|
-
|
|
27
|
+
} = props as (BrandNativeProps | BrandAsChildProps) & {
|
|
28
|
+
as?: "div" | "a" | "span";
|
|
29
|
+
};
|
|
30
|
+
const as = asProp;
|
|
27
31
|
|
|
28
32
|
const finalProps = mergeProps(rest, {
|
|
29
33
|
ref,
|
|
@@ -1,11 +1,16 @@
|
|
|
1
|
+
import type { JSX } from "@askrjs/askr/jsx-runtime";
|
|
1
2
|
import { Slot } from "@askrjs/askr/foundations";
|
|
2
3
|
import type { Ref } from "@askrjs/askr/foundations/utilities";
|
|
3
|
-
import { DialogContent } from "@askrjs/ui";
|
|
4
|
+
import { DialogContent, DialogDescription, DialogTitle } from "@askrjs/ui";
|
|
4
5
|
import { Block } from "./block";
|
|
5
6
|
import { classes } from "./_internal/classes";
|
|
6
7
|
import { mergeProps } from "./_internal/merge-props";
|
|
7
8
|
|
|
8
9
|
const CatalogDialogContent = DialogContent as (props: Record<string, unknown>) => JSX.Element;
|
|
10
|
+
const CatalogDialogTitle = DialogTitle as (props: Record<string, unknown>) => JSX.Element;
|
|
11
|
+
const CatalogDialogDescription = DialogDescription as (
|
|
12
|
+
props: Record<string, unknown>,
|
|
13
|
+
) => JSX.Element;
|
|
9
14
|
|
|
10
15
|
type CatalogElement = keyof JSX.IntrinsicElements;
|
|
11
16
|
|
|
@@ -42,13 +47,18 @@ function catalogPart(props: CatalogComponentProps, defaults: CatalogDefaults): J
|
|
|
42
47
|
}
|
|
43
48
|
|
|
44
49
|
function buttonPart(props: CatalogComponentProps, slot: string, className?: string): JSX.Element {
|
|
45
|
-
const { children, ref, class: classProp, type = "button", ...rest } = props;
|
|
50
|
+
const { as, asChild, children, ref, class: classProp, type = "button", ...rest } = props;
|
|
51
|
+
void as;
|
|
46
52
|
const finalProps = mergeProps(rest, {
|
|
47
53
|
ref,
|
|
48
54
|
class: classes(className, classProp),
|
|
49
55
|
"data-slot": slot,
|
|
50
56
|
});
|
|
51
57
|
|
|
58
|
+
if (asChild) {
|
|
59
|
+
return <Slot asChild {...finalProps} children={children as JSX.Element} />;
|
|
60
|
+
}
|
|
61
|
+
|
|
52
62
|
return (
|
|
53
63
|
<button type={type as "button" | "submit" | "reset"} {...finalProps}>
|
|
54
64
|
{children}
|
|
@@ -249,6 +259,7 @@ export function CalendarDay(
|
|
|
249
259
|
const { disabled, outside, rangeEnd, rangeMiddle, rangeStart, selected, today, ...rest } = props;
|
|
250
260
|
return buttonPart(
|
|
251
261
|
{
|
|
262
|
+
disabled,
|
|
252
263
|
"aria-disabled": disabled ? "true" : undefined,
|
|
253
264
|
"aria-selected": selected ? "true" : undefined,
|
|
254
265
|
"data-disabled": disabled ? "" : undefined,
|
|
@@ -661,11 +672,11 @@ export function SheetFooter(props: CatalogComponentProps): JSX.Element {
|
|
|
661
672
|
}
|
|
662
673
|
|
|
663
674
|
export function SheetTitle(props: CatalogComponentProps): JSX.Element {
|
|
664
|
-
return
|
|
675
|
+
return <CatalogDialogTitle {...props} data-slot="sheet-title" />;
|
|
665
676
|
}
|
|
666
677
|
|
|
667
678
|
export function SheetDescription(props: CatalogComponentProps): JSX.Element {
|
|
668
|
-
return
|
|
679
|
+
return <CatalogDialogDescription {...props} data-slot="sheet-description" />;
|
|
669
680
|
}
|
|
670
681
|
|
|
671
682
|
export function Toaster(props: CatalogComponentProps): JSX.Element {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { JSXElement } from "@askrjs/askr/foundations/structures";
|
|
2
|
+
|
|
3
|
+
declare global {
|
|
4
|
+
namespace JSX {
|
|
5
|
+
interface Element extends JSXElement {
|
|
6
|
+
readonly __askrThemesJsxElementBrand?: never;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
interface IntrinsicElements {
|
|
10
|
+
// @ts-ignore The Askr source types already provide a compatible fallback index.
|
|
11
|
+
[element: string]: Record<string, unknown>;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { JSX } from "@askrjs/askr/jsx-runtime";
|
|
1
2
|
import { Slot } from "@askrjs/askr/foundations";
|
|
2
3
|
import { currentRoute, Link, navigate } from "@askrjs/askr/router";
|
|
3
4
|
import { Block } from "../block";
|
|
@@ -103,13 +104,17 @@ function renderRoutedLink(
|
|
|
103
104
|
children,
|
|
104
105
|
href: suppliedHref,
|
|
105
106
|
to,
|
|
107
|
+
onPress,
|
|
106
108
|
onClick,
|
|
107
109
|
ref,
|
|
108
110
|
class: className,
|
|
109
111
|
match = "prefix",
|
|
110
112
|
target,
|
|
111
113
|
...rest
|
|
112
|
-
} = props as NavLinkProps & {
|
|
114
|
+
} = props as NavLinkProps & {
|
|
115
|
+
onPress?: (event: Event) => void;
|
|
116
|
+
onClick?: (event: MouseEvent) => void;
|
|
117
|
+
};
|
|
113
118
|
const href = to?.href ?? suppliedHref;
|
|
114
119
|
if (!href) {
|
|
115
120
|
throw new Error("Nav link requires href or to.");
|
|
@@ -124,6 +129,7 @@ function renderRoutedLink(
|
|
|
124
129
|
slot === "nav-item" && resolvedSlot !== "nav-item" ? "nav-item" : undefined;
|
|
125
130
|
const { "data-slot": _dataSlot, ...childRest } = rest as Record<string, unknown>;
|
|
126
131
|
void _dataSlot;
|
|
132
|
+
const hasDownload = (rest as Record<string, unknown>).download !== undefined;
|
|
127
133
|
const currentPathname = getReactiveCurrentPathname();
|
|
128
134
|
const targetPathname = resolvePathname(href);
|
|
129
135
|
const routeActive =
|
|
@@ -139,12 +145,20 @@ function renderRoutedLink(
|
|
|
139
145
|
: {
|
|
140
146
|
"data-active": undefined,
|
|
141
147
|
};
|
|
142
|
-
const rendersRouterLink =
|
|
148
|
+
const rendersRouterLink =
|
|
149
|
+
targetPathname !== null &&
|
|
150
|
+
!target &&
|
|
151
|
+
!hasDownload &&
|
|
152
|
+
typeof onClick !== "function" &&
|
|
153
|
+
typeof onPress !== "function";
|
|
143
154
|
const childProps: NavLinkProps = to
|
|
144
155
|
? ({ ...childRest, to, target } as NavLinkProps)
|
|
145
156
|
: ({ ...childRest, href, target } as NavLinkProps);
|
|
146
157
|
const handleClick = (event: MouseEvent) => {
|
|
158
|
+
onPress?.(event);
|
|
159
|
+
if (event.defaultPrevented) return;
|
|
147
160
|
onClick?.(event);
|
|
161
|
+
if (hasDownload) return;
|
|
148
162
|
|
|
149
163
|
if (!shouldHandleClientNavigation(event, target, targetPathname)) {
|
|
150
164
|
return;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { JSX } from "@askrjs/askr/jsx-runtime";
|
|
1
2
|
import type { JSXElement } from "@askrjs/askr/foundations";
|
|
2
3
|
import type { Ref } from "@askrjs/askr/foundations/utilities";
|
|
3
4
|
import type { LinkProps } from "@askrjs/askr/router";
|
|
@@ -58,6 +59,7 @@ export type NavItemAsChildProps = Omit<JSX.IntrinsicElements["a"], "children" |
|
|
|
58
59
|
|
|
59
60
|
export type NavLinkOwnProps = NavItemOwnProps & {
|
|
60
61
|
match?: NavLinkMatch;
|
|
62
|
+
onPress?: (event: Event) => void;
|
|
61
63
|
};
|
|
62
64
|
|
|
63
65
|
export type NavLinkProps = LinkProps & NavLinkOwnProps;
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { JSX } from "@askrjs/askr/jsx-runtime";
|
|
2
|
+
import {
|
|
3
|
+
Collapsible,
|
|
4
|
+
CollapsibleContent,
|
|
5
|
+
CollapsibleTrigger,
|
|
6
|
+
Dropdown,
|
|
7
|
+
DropdownTrigger,
|
|
8
|
+
} from "@askrjs/ui";
|
|
2
9
|
import { Block } from "../block";
|
|
3
10
|
import { classes } from "../_internal/classes";
|
|
4
11
|
import { isJsxElement, toChildArray } from "../_internal/jsx";
|
|
@@ -70,13 +77,17 @@ export function Navbar(props: NavbarProps): JSX.Element {
|
|
|
70
77
|
</LayoutBlock>
|
|
71
78
|
);
|
|
72
79
|
const collapse = hasNavContent ? (
|
|
73
|
-
<
|
|
74
|
-
<
|
|
75
|
-
{
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
+
<div data-slot="navbar-collapse">
|
|
81
|
+
<Collapsible>
|
|
82
|
+
<CollapsibleTrigger aria-label={collapseLabel} data-slot="navbar-toggle">
|
|
83
|
+
{collapseIcon}
|
|
84
|
+
<span data-slot="navbar-toggle-label">{collapseLabel}</span>
|
|
85
|
+
</CollapsibleTrigger>
|
|
86
|
+
<CollapsibleContent forceMount asChild data-slot="navbar-content">
|
|
87
|
+
{content}
|
|
88
|
+
</CollapsibleContent>
|
|
89
|
+
</Collapsible>
|
|
90
|
+
</div>
|
|
80
91
|
) : null;
|
|
81
92
|
|
|
82
93
|
return (
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { JSX } from "@askrjs/askr/jsx-runtime";
|
|
1
2
|
import { Slot } from "@askrjs/askr/foundations";
|
|
2
3
|
import { Block } from "../block";
|
|
3
4
|
import { classes } from "../_internal/classes";
|
|
@@ -143,16 +144,23 @@ export function SidebarMenuButton(props: SidebarButtonProps): JSX.Element {
|
|
|
143
144
|
}
|
|
144
145
|
|
|
145
146
|
export function SidebarMenuAction(props: SidebarButtonProps): JSX.Element {
|
|
146
|
-
const {
|
|
147
|
+
const {
|
|
148
|
+
asChild,
|
|
149
|
+
children,
|
|
150
|
+
class: className,
|
|
151
|
+
tooltip,
|
|
152
|
+
tooltipSide,
|
|
153
|
+
type = "button",
|
|
154
|
+
...rest
|
|
155
|
+
} = props;
|
|
156
|
+
const finalProps = mergeProps(rest, {
|
|
157
|
+
class: classes(className),
|
|
158
|
+
"data-slot": "sidebar-menu-action",
|
|
159
|
+
...sidebarTooltipProps(tooltip, tooltipSide),
|
|
160
|
+
});
|
|
161
|
+
if (asChild) return <Slot asChild {...finalProps} children={children as JSX.Element} />;
|
|
147
162
|
return (
|
|
148
|
-
<button
|
|
149
|
-
type={type as "button" | "submit" | "reset" | undefined}
|
|
150
|
-
{...mergeProps(rest, {
|
|
151
|
-
class: classes(className),
|
|
152
|
-
"data-slot": "sidebar-menu-action",
|
|
153
|
-
...sidebarTooltipProps(tooltip, tooltipSide),
|
|
154
|
-
})}
|
|
155
|
-
>
|
|
163
|
+
<button type={type as "button" | "submit" | "reset" | undefined} {...finalProps}>
|
|
156
164
|
{children}
|
|
157
165
|
</button>
|
|
158
166
|
);
|
|
@@ -162,21 +170,38 @@ export function SidebarMenuBadge(props: SidebarPartProps): JSX.Element {
|
|
|
162
170
|
return sidebarPart(props, "sidebar-menu-badge", "span");
|
|
163
171
|
}
|
|
164
172
|
|
|
165
|
-
export function SidebarRail(props:
|
|
166
|
-
|
|
173
|
+
export function SidebarRail(props: SidebarButtonProps): JSX.Element {
|
|
174
|
+
const { asChild, children, class: className, type = "button", ...rest } = props;
|
|
175
|
+
const finalProps = mergeProps(rest, {
|
|
176
|
+
class: classes(className),
|
|
177
|
+
"data-slot": "sidebar-rail",
|
|
178
|
+
});
|
|
179
|
+
if (asChild) return <Slot asChild {...finalProps} children={children as JSX.Element} />;
|
|
180
|
+
return (
|
|
181
|
+
<button type={type as "button" | "submit" | "reset" | undefined} {...finalProps}>
|
|
182
|
+
{children}
|
|
183
|
+
</button>
|
|
184
|
+
);
|
|
167
185
|
}
|
|
168
186
|
|
|
169
187
|
export function SidebarTrigger(props: SidebarButtonProps): JSX.Element {
|
|
170
|
-
const {
|
|
188
|
+
const {
|
|
189
|
+
asChild,
|
|
190
|
+
children,
|
|
191
|
+
class: className,
|
|
192
|
+
tooltip,
|
|
193
|
+
tooltipSide,
|
|
194
|
+
type = "button",
|
|
195
|
+
...rest
|
|
196
|
+
} = props;
|
|
197
|
+
const finalProps = mergeProps(rest, {
|
|
198
|
+
class: classes("btn btn-ghost btn-icon", className),
|
|
199
|
+
"data-slot": "sidebar-trigger",
|
|
200
|
+
...sidebarTooltipProps(tooltip, tooltipSide),
|
|
201
|
+
});
|
|
202
|
+
if (asChild) return <Slot asChild {...finalProps} children={children as JSX.Element} />;
|
|
171
203
|
return (
|
|
172
|
-
<button
|
|
173
|
-
type={type as "button" | "submit" | "reset" | undefined}
|
|
174
|
-
{...mergeProps(rest, {
|
|
175
|
-
class: classes("btn btn-ghost btn-icon", className),
|
|
176
|
-
"data-slot": "sidebar-trigger",
|
|
177
|
-
...sidebarTooltipProps(tooltip, tooltipSide),
|
|
178
|
-
})}
|
|
179
|
-
>
|
|
204
|
+
<button type={type as "button" | "submit" | "reset" | undefined} {...finalProps}>
|
|
180
205
|
{children}
|
|
181
206
|
</button>
|
|
182
207
|
);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { JSX } from "@askrjs/askr/jsx-runtime";
|
|
1
2
|
import type { BlockElementProps } from "../block";
|
|
2
3
|
|
|
3
4
|
export type SidebarCollapsible = "offcanvas" | "icon" | "none";
|
|
@@ -26,3 +27,5 @@ export type SidebarButtonProps = JSX.IntrinsicElements["button"] & {
|
|
|
26
27
|
tooltipSide?: SidebarTooltipSide;
|
|
27
28
|
variant?: "default" | "outline";
|
|
28
29
|
};
|
|
30
|
+
|
|
31
|
+
export type SidebarRailProps = SidebarButtonProps;
|