@bccampus/ui-components 0.5.8 → 0.6.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.
@@ -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 }) });
@@ -1,3 +1,7 @@
1
- export type InputProps = React.ComponentProps<"input">;
2
- declare function Input({ className, ...props }: InputProps): import("react").JSX.Element;
1
+ import { LucideProps } from 'lucide-react';
2
+ export interface InputProps extends React.ComponentProps<"input"> {
3
+ leftIcon?: React.JSXElementConstructor<LucideProps>;
4
+ rightIcon?: React.JSXElementConstructor<LucideProps>;
5
+ }
6
+ declare function Input({ className, leftIcon, rightIcon, ...props }: InputProps): import("react").JSX.Element;
3
7
  export { Input };
@@ -1,17 +1,23 @@
1
- import { jsx } from "react/jsx-runtime";
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
2
  import { c as cn } from "../../_chunks/utils.js";
3
- function Input({ className, ...props }) {
4
- return /* @__PURE__ */ jsx(
5
- "input",
6
- {
7
- className: cn(
8
- "w-full p-2 pr-8 text-brand-1 placeholder:text-brand-1 rounded-sm bg-complement-1-50 outline-none focus-visible:border-ring focus-visible:ring-ring focus-visible:ring-2",
9
- className
10
- ),
11
- name: "search",
12
- ...props
13
- }
14
- );
3
+ function Input({ className, leftIcon, rightIcon, ...props }) {
4
+ const LeftComp = leftIcon ? leftIcon : null;
5
+ const RightComp = rightIcon ? rightIcon : null;
6
+ return /* @__PURE__ */ jsxs("div", { className: cn("relative", className), children: [
7
+ LeftComp && /* @__PURE__ */ jsx(LeftComp, { className: "absolute size-4 top-1/2 left-2 -translate-y-1/2 pointer-events-none text-primary" }),
8
+ /* @__PURE__ */ jsx(
9
+ "input",
10
+ {
11
+ className: cn(
12
+ "w-full p-2 rounded-sm outline-none focus-visible:border-ring focus-visible:ring-ring focus-visible:ring-2",
13
+ "text-brand-1 placeholder:text-brand-1 bg-complement-1-50 dark:text-foreground dark:placeholder:text-white dark:bg-brand-1",
14
+ { "pl-8": LeftComp, "pr-8": RightComp }
15
+ ),
16
+ ...props
17
+ }
18
+ ),
19
+ RightComp && /* @__PURE__ */ jsx(RightComp, { className: "absolute size-4 top-1/2 right-3 -translate-y-1/2 pointer-events-none text-primary" })
20
+ ] });
15
21
  }
16
22
  export {
17
23
  Input
@@ -1,3 +1,3 @@
1
- export type SearchInputProps = React.ComponentProps<"input">;
2
- declare function SearchInput({ className, ...props }: SearchInputProps): import("react").JSX.Element;
1
+ import { InputProps } from './input';
2
+ declare function SearchInput({ ...props }: InputProps): import("react").JSX.Element;
3
3
  export { SearchInput };
@@ -1,5 +1,4 @@
1
- import { jsxs, jsx } from "react/jsx-runtime";
2
- import { c as cn } from "../../_chunks/utils.js";
1
+ import { jsx } from "react/jsx-runtime";
3
2
  import { Input } from "./input.js";
4
3
  import { c as createLucideIcon } from "../../_chunks/createLucideIcon.js";
5
4
  const __iconNode = [
@@ -7,11 +6,8 @@ const __iconNode = [
7
6
  ["circle", { cx: "11", cy: "11", r: "8", key: "4ej97u" }]
8
7
  ];
9
8
  const Search = createLucideIcon("search", __iconNode);
10
- function SearchInput({ className, ...props }) {
11
- return /* @__PURE__ */ jsxs("div", { className: cn("relative", className), children: [
12
- /* @__PURE__ */ jsx(Input, { ...props }),
13
- /* @__PURE__ */ jsx(Search, { className: "absolute size-4 top-1/2 right-3 -translate-y-1/2 pointer-events-none text-primary" })
14
- ] });
9
+ function SearchInput({ ...props }) {
10
+ return /* @__PURE__ */ jsx(Input, { rightIcon: Search, ...props });
15
11
  }
16
12
  export {
17
13
  SearchInput
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bccampus/ui-components",
3
- "version": "0.5.8",
3
+ "version": "0.6.0",
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,16 +1,33 @@
1
1
  import { cn } from "@/lib/utils";
2
- export type InputProps = React.ComponentProps<"input">;
2
+ import type { LucideProps } from "lucide-react";
3
3
 
4
- function Input({ className, ...props }: InputProps) {
4
+ export interface InputProps extends React.ComponentProps<"input"> {
5
+ leftIcon?: React.JSXElementConstructor<LucideProps>;
6
+ rightIcon?: React.JSXElementConstructor<LucideProps>;
7
+ }
8
+
9
+ function Input({ className, leftIcon, rightIcon, ...props }: InputProps) {
10
+ const LeftComp = leftIcon ? leftIcon : null;
11
+ const RightComp = rightIcon ? rightIcon : null;
5
12
  return (
6
- <input
7
- className={cn(
8
- "w-full p-2 pr-8 text-brand-1 placeholder:text-brand-1 rounded-sm bg-complement-1-50 outline-none focus-visible:border-ring focus-visible:ring-ring focus-visible:ring-2",
9
- className
13
+ <div className={cn("relative", className)}>
14
+ {LeftComp && (
15
+ <LeftComp className="absolute size-4 top-1/2 left-2 -translate-y-1/2 pointer-events-none text-primary" />
16
+ )}
17
+
18
+ <input
19
+ className={cn(
20
+ "w-full p-2 rounded-sm outline-none focus-visible:border-ring focus-visible:ring-ring focus-visible:ring-2",
21
+ "text-brand-1 placeholder:text-brand-1 bg-complement-1-50 dark:text-foreground dark:placeholder:text-white dark:bg-brand-1",
22
+ { "pl-8": LeftComp, "pr-8": RightComp },
23
+ )}
24
+ {...props}
25
+ />
26
+
27
+ {RightComp && (
28
+ <RightComp className="absolute size-4 top-1/2 right-3 -translate-y-1/2 pointer-events-none text-primary" />
10
29
  )}
11
- name="search"
12
- {...props}
13
- />
30
+ </div>
14
31
  );
15
32
  }
16
33
 
@@ -1,16 +1,8 @@
1
- import { cn } from "@/lib/utils";
2
1
  import { Search } from "lucide-react";
3
- import { Input } from "./input";
2
+ import { Input, type InputProps } from "./input";
4
3
 
5
- export type SearchInputProps = React.ComponentProps<"input">;
6
-
7
- function SearchInput({ className, ...props }: SearchInputProps) {
8
- return (
9
- <div className={cn("relative", className)}>
10
- <Input {...props} />
11
- <Search className="absolute size-4 top-1/2 right-3 -translate-y-1/2 pointer-events-none text-primary" />
12
- </div>
13
- );
4
+ function SearchInput({ ...props }: InputProps) {
5
+ return <Input rightIcon={Search} {...props} />;
14
6
  }
15
7
 
16
8
  export { SearchInput };
@@ -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
- }