@bccampus/ui-components 0.5.8 → 0.5.9

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.
@@ -17,14 +17,11 @@ type CardTitleProps = React.ComponentProps<"div"> & {
17
17
  };
18
18
  declare function CardTitle({ size, className, ...props }: CardTitleProps): import("react").JSX.Element;
19
19
  declare function CardSubtitle({ size, className, ...props }: CardTitleProps): import("react").JSX.Element;
20
- export type CardChildProps = React.ComponentProps<"div"> & {
21
- asChild?: boolean;
22
- };
23
- declare function CardCaption({ asChild, ...props }: CardChildProps): import("react").JSX.Element;
24
- declare function CardSubcaption({ asChild, ...props }: CardChildProps): import("react").JSX.Element;
25
- declare function CardMeta({ asChild, ...props }: CardChildProps): import("react").JSX.Element;
26
- declare function CardContent({ asChild, ...props }: CardChildProps): import("react").JSX.Element;
27
- declare function CardToolbar({ className, asChild, ...props }: CardChildProps): import("react").JSX.Element;
28
- declare function CardMedia({ className, asChild, ...props }: CardChildProps): import("react").JSX.Element;
20
+ declare function CardCaption(props: React.ComponentProps<"div">): import("react").JSX.Element;
21
+ declare function CardSubcaption(props: React.ComponentProps<"div">): import("react").JSX.Element;
22
+ declare function CardMeta(props: React.ComponentProps<"div">): import("react").JSX.Element;
23
+ declare function CardContent(props: React.ComponentProps<"div">): import("react").JSX.Element;
24
+ declare function CardToolbar({ className, ...props }: React.ComponentProps<"div">): import("react").JSX.Element;
25
+ declare function CardMedia({ className, ...props }: React.ComponentProps<"div">): import("react").JSX.Element;
29
26
  declare function CardImage({ className, ...props }: React.ComponentProps<"img">): import("react").JSX.Element;
30
27
  export { Card, CardArea, CardItemGroup, CardToolbar, CardTitle, CardSubtitle, CardCaption, CardSubcaption, CardMeta, CardContent, CardMedia, CardImage, };
@@ -1,5 +1,4 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import { S as Slot } from "../../_chunks/index.js";
3
2
  import { c as cn } from "../../_chunks/utils.js";
4
3
  import { Caption } from "./typography/caption.js";
5
4
  import { c as cva } from "../../_chunks/index2.js";
@@ -73,29 +72,23 @@ function CardSubtitle({ size = "md", className, ...props }) {
73
72
  }
74
73
  );
75
74
  }
76
- function CardCaption({ asChild, ...props }) {
77
- const Comp = asChild ? Slot : Caption;
78
- return /* @__PURE__ */ jsx(Comp, { variant: "light", ...props });
75
+ function CardCaption(props) {
76
+ return /* @__PURE__ */ jsx(Caption, { ...props });
79
77
  }
80
- function CardSubcaption({ asChild, ...props }) {
81
- const Comp = asChild ? Slot : Caption;
82
- return /* @__PURE__ */ jsx(Comp, { variant: "light", ...props });
78
+ function CardSubcaption(props) {
79
+ return /* @__PURE__ */ jsx(Caption, { variant: "light", ...props });
83
80
  }
84
- function CardMeta({ asChild, ...props }) {
85
- const Comp = asChild ? Slot : Caption;
86
- return /* @__PURE__ */ jsx(Comp, { variant: "light", ...props });
81
+ function CardMeta(props) {
82
+ return /* @__PURE__ */ jsx(Caption, { variant: "light", ...props });
87
83
  }
88
- function CardContent({ asChild, ...props }) {
89
- const Comp = asChild ? Slot : "div";
90
- return /* @__PURE__ */ jsx(Comp, { ...props });
84
+ function CardContent(props) {
85
+ return /* @__PURE__ */ jsx("div", { ...props });
91
86
  }
92
- function CardToolbar({ className, asChild, ...props }) {
93
- const Comp = asChild ? Slot : "div";
94
- return /* @__PURE__ */ jsx(Comp, { className: cn("flex flex-wrap items-center gap-(--gap-card-item-group)", className), ...props });
87
+ function CardToolbar({ className, ...props }) {
88
+ return /* @__PURE__ */ jsx("div", { className: cn("flex flex-wrap items-center gap-(--gap-card-item-group)", className), ...props });
95
89
  }
96
- function CardMedia({ className, asChild, ...props }) {
97
- const Comp = asChild ? Slot : "div";
98
- return /* @__PURE__ */ jsx(Comp, { className: cn("relative w-full h-full", className), ...props });
90
+ function CardMedia({ className, ...props }) {
91
+ return /* @__PURE__ */ jsx("div", { className: cn("relative w-full h-full", className), ...props });
99
92
  }
100
93
  function CardImage({ className, ...props }) {
101
94
  return /* @__PURE__ */ jsx(CardMedia, { children: /* @__PURE__ */ jsx("img", { className: cn("w-full h-full rounded-lg aspect-9/5 object-cover object-top", className), ...props }) });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bccampus/ui-components",
3
- "version": "0.5.8",
3
+ "version": "0.5.9",
4
4
  "type": "module",
5
5
  "packageManager": "yarn@4.10.3",
6
6
  "exports": {
@@ -1,4 +1,3 @@
1
- import { Slot } from "@radix-ui/react-slot";
2
1
  import { cn } from "@/lib/utils";
3
2
  import { Caption } from "./typography/caption";
4
3
  import { cva, type VariantProps } from "class-variance-authority";
@@ -84,38 +83,28 @@ function CardSubtitle({ size = "md", className, ...props }: CardTitleProps) {
84
83
  );
85
84
  }
86
85
 
87
- export type CardChildProps = React.ComponentProps<"div"> & {
88
- asChild?: boolean;
89
- };
90
-
91
- function CardCaption({ asChild, ...props }: CardChildProps) {
92
- const Comp = asChild ? Slot : Caption;
93
- return <Comp variant="light" {...props} />;
86
+ function CardCaption(props: React.ComponentProps<"div">) {
87
+ return <Caption {...props} />;
94
88
  }
95
89
 
96
- function CardSubcaption({ asChild, ...props }: CardChildProps) {
97
- const Comp = asChild ? Slot : Caption;
98
- return <Comp variant="light" {...props} />;
90
+ function CardSubcaption(props: React.ComponentProps<"div">) {
91
+ return <Caption variant="light" {...props} />;
99
92
  }
100
93
 
101
- function CardMeta({ asChild, ...props }: CardChildProps) {
102
- const Comp = asChild ? Slot : Caption;
103
- return <Comp variant="light" {...props} />;
94
+ function CardMeta(props: React.ComponentProps<"div">) {
95
+ return <Caption variant="light" {...props} />;
104
96
  }
105
97
 
106
- function CardContent({ asChild, ...props }: CardChildProps) {
107
- const Comp = asChild ? Slot : "div";
108
- return <Comp {...props} />;
98
+ function CardContent(props: React.ComponentProps<"div">) {
99
+ return <div {...props} />;
109
100
  }
110
101
 
111
- function CardToolbar({ className, asChild, ...props }: CardChildProps) {
112
- const Comp = asChild ? Slot : "div";
113
- return <Comp className={cn("flex flex-wrap items-center gap-(--gap-card-item-group)", className)} {...props} />;
102
+ function CardToolbar({ className, ...props }: React.ComponentProps<"div">) {
103
+ return <div className={cn("flex flex-wrap items-center gap-(--gap-card-item-group)", className)} {...props} />;
114
104
  }
115
105
 
116
- function CardMedia({ className, asChild, ...props }: CardChildProps) {
117
- const Comp = asChild ? Slot : "div";
118
- return <Comp className={cn("relative w-full h-full", className)} {...props} />;
106
+ function CardMedia({ className, ...props }: React.ComponentProps<"div">) {
107
+ return <div className={cn("relative w-full h-full", className)} {...props} />;
119
108
  }
120
109
 
121
110
  function CardImage({ className, ...props }: React.ComponentProps<"img">) {
@@ -1,2 +0,0 @@
1
- import { BaseCompositeProps } from './types';
2
- export declare function LayoutGrid<T extends object>({ data, ...props }: BaseCompositeProps<T>): import("react").JSX.Element;
@@ -1,59 +0,0 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { CompositeComponent } from "./composite-component.js";
3
- import { useRef, useCallback } from "react";
4
- import "nanostores";
5
- import { useKeyboardEvent } from "../../../hooks/use-keyboard-event.js";
6
- function LayoutGrid({ data, ...props }) {
7
- const compositeRef = useRef(null);
8
- const focusElement = useCallback(() => {
9
- const itemKey = data.focusProvider.focusedItem.get()?.key;
10
- if (itemKey && compositeRef.current) {
11
- const focusedItemEl = compositeRef.current.querySelector(`[data-key="${itemKey}"]`);
12
- if (focusedItemEl) focusedItemEl.focus();
13
- }
14
- }, [data]);
15
- const handleKeyboardEvent = useKeyboardEvent({
16
- ArrowUp: () => {
17
- data.focusProvider.focusUp();
18
- focusElement();
19
- },
20
- ArrowDown: () => {
21
- data.focusProvider.focusDown();
22
- focusElement();
23
- },
24
- Home: () => {
25
- data.focusProvider.focusToFirst();
26
- focusElement();
27
- },
28
- End: () => {
29
- data.focusProvider.focusToLast();
30
- focusElement();
31
- },
32
- Space: () => {
33
- data.selectionProvider?.toggleSelect();
34
- focusElement();
35
- }
36
- });
37
- const handleItemMouseEvent = useCallback(
38
- (item) => {
39
- data.focusProvider.focus(item.key);
40
- data.selectionProvider?.toggleSelect(item);
41
- focusElement();
42
- },
43
- [data.focusProvider, data.selectionProvider, focusElement]
44
- );
45
- return /* @__PURE__ */ jsx(
46
- CompositeComponent,
47
- {
48
- ref: compositeRef,
49
- variant: "listbox",
50
- data,
51
- onKeyDown: handleKeyboardEvent,
52
- itemMouseEventHandler: handleItemMouseEvent,
53
- ...props
54
- }
55
- );
56
- }
57
- export {
58
- LayoutGrid
59
- };
@@ -1,61 +0,0 @@
1
- import { CompositeComponent } from "./composite-component";
2
- import { useCallback, useRef } from "react";
3
- import { CompositeDataItem } from "./CompositeDataItem";
4
- import type { BaseCompositeProps } from "./types";
5
- import { useKeyboardEvent } from "@/hooks/use-keyboard-event";
6
-
7
- export function LayoutGrid<T extends object>({ data, ...props }: BaseCompositeProps<T>) {
8
- const compositeRef = useRef<HTMLDivElement>(null);
9
-
10
- const focusElement = useCallback(() => {
11
- const itemKey = data.focusProvider.focusedItem.get()?.key;
12
-
13
- if (itemKey && compositeRef.current) {
14
- const focusedItemEl = compositeRef.current.querySelector<HTMLDivElement>(`[data-key="${itemKey}"]`);
15
- if (focusedItemEl) focusedItemEl.focus();
16
- }
17
- }, [data]);
18
-
19
- const handleKeyboardEvent = useKeyboardEvent({
20
- ArrowUp: () => {
21
- data.focusProvider.focusUp();
22
- focusElement();
23
- },
24
- ArrowDown: () => {
25
- data.focusProvider.focusDown();
26
- focusElement();
27
- },
28
- Home: () => {
29
- data.focusProvider.focusToFirst();
30
- focusElement();
31
- },
32
- End: () => {
33
- data.focusProvider.focusToLast();
34
- focusElement();
35
- },
36
- Space: () => {
37
- data.selectionProvider?.toggleSelect();
38
- focusElement();
39
- },
40
- });
41
-
42
- const handleItemMouseEvent = useCallback(
43
- (item: CompositeDataItem<T>) => {
44
- data.focusProvider.focus(item.key);
45
- data.selectionProvider?.toggleSelect(item);
46
- focusElement();
47
- },
48
- [data.focusProvider, data.selectionProvider, focusElement]
49
- );
50
-
51
- return (
52
- <CompositeComponent
53
- ref={compositeRef}
54
- variant="listbox"
55
- data={data}
56
- onKeyDown={handleKeyboardEvent}
57
- itemMouseEventHandler={handleItemMouseEvent}
58
- {...props}
59
- />
60
- );
61
- }