@bccampus/ui-components 0.4.3 → 0.5.1

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.
Files changed (170) hide show
  1. package/.yarn/install-state.gz +0 -0
  2. package/.yarn/releases/yarn-4.12.0.cjs +942 -0
  3. package/.yarnrc.yml +3 -0
  4. package/dist/_chunks/createLucideIcon.js +79 -0
  5. package/dist/_chunks/index.js +103 -0
  6. package/dist/_chunks/index2.js +44 -0
  7. package/dist/_chunks/index3.js +39 -0
  8. package/dist/_chunks/index4.js +615 -0
  9. package/dist/{utils-CRiPKpXj.js → _chunks/utils.js} +828 -544
  10. package/dist/components/index.d.ts +16 -0
  11. package/dist/components/index.js +84 -0
  12. package/dist/components/ui/banner.d.ts +10 -0
  13. package/dist/components/ui/banner.js +39 -0
  14. package/dist/components/ui/button.d.ts +11 -0
  15. package/dist/{button.js → components/ui/button.js} +11 -10
  16. package/dist/components/ui/card.d.ts +27 -0
  17. package/dist/components/ui/card.js +109 -0
  18. package/dist/components/ui/composite/CompositeData.d.ts +20 -0
  19. package/dist/components/ui/composite/CompositeData.js +89 -0
  20. package/dist/components/ui/composite/CompositeDataItem.d.ts +28 -0
  21. package/dist/components/ui/composite/CompositeDataItem.js +111 -0
  22. package/dist/components/ui/composite/FocusProvider/AbstractFocusProvider.d.ts +41 -0
  23. package/dist/components/ui/composite/FocusProvider/AbstractFocusProvider.js +36 -0
  24. package/dist/components/ui/composite/FocusProvider/ListboxFocusProvider.d.ts +16 -0
  25. package/dist/components/ui/composite/FocusProvider/ListboxFocusProvider.js +67 -0
  26. package/dist/components/ui/composite/FocusProvider/index.d.ts +2 -0
  27. package/dist/components/ui/composite/FocusProvider/index.js +6 -0
  28. package/dist/components/ui/composite/SelectionProvider/AbstractSelectionProvider.d.ts +23 -0
  29. package/dist/components/ui/composite/SelectionProvider/AbstractSelectionProvider.js +21 -0
  30. package/dist/components/ui/composite/SelectionProvider/MultipleSelectionProvider.d.ts +9 -0
  31. package/dist/components/ui/composite/SelectionProvider/MultipleSelectionProvider.js +20 -0
  32. package/dist/components/ui/composite/SelectionProvider/SingleSelectionProvider.d.ts +9 -0
  33. package/dist/components/ui/composite/SelectionProvider/SingleSelectionProvider.js +25 -0
  34. package/dist/components/ui/composite/SelectionProvider/index.d.ts +3 -0
  35. package/dist/components/ui/composite/SelectionProvider/index.js +8 -0
  36. package/dist/components/ui/composite/composite-component-item.d.ts +2 -0
  37. package/dist/components/ui/composite/composite-component-item.js +52 -0
  38. package/dist/components/ui/composite/composite-component.d.ts +2 -0
  39. package/dist/components/ui/composite/composite-component.js +66 -0
  40. package/dist/components/ui/composite/index.d.ts +8 -0
  41. package/dist/components/ui/composite/index.js +22 -0
  42. package/dist/components/ui/composite/listbox.d.ts +2 -0
  43. package/dist/components/ui/composite/listbox.js +59 -0
  44. package/dist/components/ui/composite/types.d.ts +82 -0
  45. package/dist/components/ui/composite/types.js +1 -0
  46. package/dist/components/ui/horizontal-list.d.ts +10 -0
  47. package/dist/components/ui/horizontal-list.js +70 -0
  48. package/dist/components/ui/icon-generator/generate-tiles.d.ts +4 -0
  49. package/dist/components/ui/icon-generator/generate-tiles.js +223 -0
  50. package/dist/components/ui/icon-generator/icon-generator.d.ts +3 -0
  51. package/dist/components/ui/icon-generator/icon-generator.js +82 -0
  52. package/dist/components/ui/icon-generator/index.d.ts +4 -0
  53. package/dist/components/ui/icon-generator/index.js +11 -0
  54. package/dist/components/ui/icon-generator/masked-image-generator.d.ts +3 -0
  55. package/dist/components/ui/icon-generator/masked-image-generator.js +31 -0
  56. package/dist/{masked-image-generator.d.ts → components/ui/icon-generator/types.d.ts} +48 -58
  57. package/dist/components/ui/icon-generator/types.js +30 -0
  58. package/dist/components/ui/input.d.ts +3 -0
  59. package/dist/{input.js → components/ui/input.js} +8 -8
  60. package/dist/components/ui/navigation-menu.d.ts +16 -0
  61. package/dist/components/ui/navigation-menu.js +1117 -0
  62. package/dist/components/ui/overlay.d.ts +7 -0
  63. package/dist/{overlay.js → components/ui/overlay.js} +7 -7
  64. package/dist/components/ui/page-header.d.ts +5 -0
  65. package/dist/{page-header.js → components/ui/page-header.js} +189 -181
  66. package/dist/components/ui/page-section.d.ts +8 -0
  67. package/dist/{page-section.js → components/ui/page-section.js} +7 -7
  68. package/dist/components/ui/page.d.ts +3 -0
  69. package/dist/components/ui/page.js +8 -0
  70. package/dist/components/ui/popover.d.ts +7 -0
  71. package/dist/components/ui/popover.js +3614 -0
  72. package/dist/components/ui/search-input.d.ts +3 -0
  73. package/dist/components/ui/search-input.js +18 -0
  74. package/dist/components/ui/tag.d.ts +10 -0
  75. package/dist/{tag.js → components/ui/tag.js} +10 -9
  76. package/dist/components/ui/typography/caption.d.ts +8 -0
  77. package/dist/components/ui/typography/caption.js +28 -0
  78. package/dist/components/ui/typography/index.d.ts +1 -0
  79. package/dist/components/ui/typography/index.js +5 -0
  80. package/dist/hooks/index.d.ts +3 -0
  81. package/dist/hooks/index.js +9 -0
  82. package/dist/hooks/use-effect-after-mount.d.ts +2 -0
  83. package/dist/hooks/use-effect-after-mount.js +24 -0
  84. package/dist/hooks/use-id.d.ts +1 -0
  85. package/dist/hooks/use-id.js +7 -0
  86. package/dist/hooks/use-keyboard-event.d.ts +59 -0
  87. package/dist/hooks/use-keyboard-event.js +52 -0
  88. package/dist/lib/index.d.ts +3 -0
  89. package/dist/lib/index.js +16 -0
  90. package/dist/lib/object.d.ts +5 -0
  91. package/dist/lib/object.js +38 -0
  92. package/dist/lib/set-operations.d.ts +5 -0
  93. package/dist/lib/set-operations.js +51 -0
  94. package/dist/{utils.d.ts → lib/utils.d.ts} +2 -5
  95. package/dist/lib/utils.js +4 -0
  96. package/package.json +76 -146
  97. package/src/App.tsx +44 -14
  98. package/src/components/index.ts +17 -0
  99. package/src/components/ui/composite/FocusProvider/index.ts +2 -0
  100. package/src/components/ui/composite/SelectionProvider/MultipleSelectionProvider.ts +1 -1
  101. package/src/components/ui/composite/SelectionProvider/index.ts +3 -0
  102. package/src/components/ui/composite/index.ts +6 -5
  103. package/src/components/ui/icon-generator/index.ts +2 -0
  104. package/src/components/ui/typography/index.ts +1 -0
  105. package/src/hooks/index.ts +3 -0
  106. package/src/index.ts +3 -0
  107. package/src/lib/index.ts +3 -0
  108. package/src/main.tsx +12 -12
  109. package/tsconfig.lib.json +44 -0
  110. package/vite.config.ts +34 -33
  111. package/dist/AbstractFocusProvider-CxvlcEki.js +0 -29
  112. package/dist/AbstractSelectionProvider-BtaROstC.js +0 -30
  113. package/dist/CompositeDataItem-DuHOHCWy.js +0 -158
  114. package/dist/ListboxFocusProvider.d.ts +0 -149
  115. package/dist/ListboxFocusProvider.js +0 -53
  116. package/dist/MultipleSelectionProvider.d.ts +0 -141
  117. package/dist/MultipleSelectionProvider.js +0 -19
  118. package/dist/SingleSelectionProvider.d.ts +0 -141
  119. package/dist/SingleSelectionProvider.js +0 -23
  120. package/dist/banner.d.ts +0 -16
  121. package/dist/banner.js +0 -42
  122. package/dist/button.d.ts +0 -17
  123. package/dist/caption.d.ts +0 -13
  124. package/dist/caption.js +0 -27
  125. package/dist/card.d.ts +0 -46
  126. package/dist/card.js +0 -108
  127. package/dist/composite-component-DSUbd1XS.js +0 -122
  128. package/dist/composite.d.ts +0 -208
  129. package/dist/composite.js +0 -82
  130. package/dist/createLucideIcon-CzehbSja.js +0 -94
  131. package/dist/generate-tiles-DuagGD1d.js +0 -244
  132. package/dist/generate-tiles.d.ts +0 -43
  133. package/dist/generate-tiles.js +0 -7
  134. package/dist/horizontal-list.d.ts +0 -16
  135. package/dist/horizontal-list.js +0 -77
  136. package/dist/icon-generator-tuhuqdpL.js +0 -76
  137. package/dist/icon-generator.d.ts +0 -58
  138. package/dist/icon-generator.js +0 -6
  139. package/dist/index-CQhYMnjT.js +0 -34
  140. package/dist/index-U7DVCmS_.js +0 -76
  141. package/dist/input.d.ts +0 -7
  142. package/dist/listbox.d.ts +0 -171
  143. package/dist/listbox.js +0 -76
  144. package/dist/masked-image-generator.js +0 -29
  145. package/dist/navigation-menu.d.ts +0 -27
  146. package/dist/navigation-menu.js +0 -1139
  147. package/dist/overlay.d.ts +0 -13
  148. package/dist/page-header.d.ts +0 -9
  149. package/dist/page-section.d.ts +0 -14
  150. package/dist/page.d.ts +0 -7
  151. package/dist/page.js +0 -8
  152. package/dist/search-input.d.ts +0 -7
  153. package/dist/search-input.js +0 -23
  154. package/dist/tag.d.ts +0 -16
  155. package/dist/ui-components.d.ts +0 -215
  156. package/dist/ui-components.js +0 -54
  157. package/dist/utils.js +0 -4
  158. package/src/assets/icons/icon_01.svg +0 -6
  159. package/src/assets/icons/icon_02.svg +0 -6
  160. package/src/assets/icons/icon_03.svg +0 -6
  161. package/src/assets/icons/icon_04.svg +0 -6
  162. package/src/assets/icons/icon_05.svg +0 -4
  163. package/src/assets/icons/icon_06.svg +0 -4
  164. package/src/assets/images/image_01.jpg +0 -0
  165. package/src/assets/images/image_02.jpg +0 -0
  166. package/src/assets/images/image_03.webp +0 -0
  167. package/src/assets/images/image_04.png +0 -0
  168. package/src/assets/images/image_05.jpg +0 -0
  169. package/src/assets/images/image_06.jpg +0 -0
  170. package/src/components/ui/index.ts +0 -15
@@ -0,0 +1,16 @@
1
+ export * from './ui/composite';
2
+ export * from './ui/icon-generator';
3
+ export * from './ui/typography';
4
+ export * from './ui/banner.tsx';
5
+ export * from './ui/button.tsx';
6
+ export * from './ui/card.tsx';
7
+ export * from './ui/horizontal-list.tsx';
8
+ export * from './ui/input.tsx';
9
+ export * from './ui/navigation-menu.tsx';
10
+ export * from './ui/overlay.tsx';
11
+ export * from './ui/page-header.tsx';
12
+ export * from './ui/page-section.tsx';
13
+ export * from './ui/page.tsx';
14
+ export * from './ui/popover.tsx';
15
+ export * from './ui/search-input.tsx';
16
+ export * from './ui/tag.tsx';
@@ -0,0 +1,84 @@
1
+ import { CompositeData } from "./ui/composite/CompositeData.js";
2
+ import { CompositeDataItem } from "./ui/composite/CompositeDataItem.js";
3
+ import { AbstractFocusProvider } from "./ui/composite/FocusProvider/AbstractFocusProvider.js";
4
+ import { ListboxFocusProvider } from "./ui/composite/FocusProvider/ListboxFocusProvider.js";
5
+ import { AbstractSelectionProvider } from "./ui/composite/SelectionProvider/AbstractSelectionProvider.js";
6
+ import { SingleSelectionProvider } from "./ui/composite/SelectionProvider/SingleSelectionProvider.js";
7
+ import { MultipleSelectionProvider } from "./ui/composite/SelectionProvider/MultipleSelectionProvider.js";
8
+ import { CompositeComponent } from "./ui/composite/composite-component.js";
9
+ import { CompositeComponentItem } from "./ui/composite/composite-component-item.js";
10
+ import { Listbox } from "./ui/composite/listbox.js";
11
+ import { IconGenerator } from "./ui/icon-generator/icon-generator.js";
12
+ import { generateIconPattern, generateTiles } from "./ui/icon-generator/generate-tiles.js";
13
+ import { MaskedImageGenerator } from "./ui/icon-generator/masked-image-generator.js";
14
+ import { TileShape } from "./ui/icon-generator/types.js";
15
+ import { Caption, captionVariants } from "./ui/typography/caption.js";
16
+ import { Banner } from "./ui/banner.js";
17
+ import { Button, buttonVariants } from "./ui/button.js";
18
+ import { Card, CardArea, CardCaption, CardContent, CardImage, CardItemGroup, CardMedia, CardMeta, CardSubcaption, CardSubtitle, CardTitle, CardToolbar } from "./ui/card.js";
19
+ import { HorizontalList } from "./ui/horizontal-list.js";
20
+ import { Input } from "./ui/input.js";
21
+ import { NavigationMenu, NavigationMenuContent, NavigationMenuIndicator, NavigationMenuItem, NavigationMenuLink, NavigationMenuList, NavigationMenuTrigger, NavigationMenuViewport, navigationMenuTriggerStyle } from "./ui/navigation-menu.js";
22
+ import { Overlay } from "./ui/overlay.js";
23
+ import { PageHeader } from "./ui/page-header.js";
24
+ import { PageSection } from "./ui/page-section.js";
25
+ import { Page } from "./ui/page.js";
26
+ import { Popover, PopoverAnchor, PopoverContent, PopoverTrigger } from "./ui/popover.js";
27
+ import { SearchInput } from "./ui/search-input.js";
28
+ import { Tag, tagVariants } from "./ui/tag.js";
29
+ export {
30
+ AbstractFocusProvider,
31
+ AbstractSelectionProvider,
32
+ Banner,
33
+ Button,
34
+ Caption,
35
+ Card,
36
+ CardArea,
37
+ CardCaption,
38
+ CardContent,
39
+ CardImage,
40
+ CardItemGroup,
41
+ CardMedia,
42
+ CardMeta,
43
+ CardSubcaption,
44
+ CardSubtitle,
45
+ CardTitle,
46
+ CardToolbar,
47
+ CompositeComponent,
48
+ CompositeComponentItem,
49
+ CompositeData,
50
+ CompositeDataItem,
51
+ HorizontalList,
52
+ IconGenerator,
53
+ Input,
54
+ Listbox,
55
+ ListboxFocusProvider,
56
+ MaskedImageGenerator,
57
+ MultipleSelectionProvider,
58
+ NavigationMenu,
59
+ NavigationMenuContent,
60
+ NavigationMenuIndicator,
61
+ NavigationMenuItem,
62
+ NavigationMenuLink,
63
+ NavigationMenuList,
64
+ NavigationMenuTrigger,
65
+ NavigationMenuViewport,
66
+ Overlay,
67
+ Page,
68
+ PageHeader,
69
+ PageSection,
70
+ Popover,
71
+ PopoverAnchor,
72
+ PopoverContent,
73
+ PopoverTrigger,
74
+ SearchInput,
75
+ SingleSelectionProvider,
76
+ Tag,
77
+ TileShape,
78
+ buttonVariants,
79
+ captionVariants,
80
+ generateIconPattern,
81
+ generateTiles,
82
+ navigationMenuTriggerStyle,
83
+ tagVariants
84
+ };
@@ -0,0 +1,10 @@
1
+ import { VariantProps } from 'class-variance-authority';
2
+ declare const bannerVariants: (props?: ({
3
+ variant?: "alert" | "default" | null | undefined;
4
+ size?: "default" | "sm" | "lg" | null | undefined;
5
+ } & import('class-variance-authority/dist/types').ClassProp) | undefined) => string;
6
+ export interface BannerProps extends VariantProps<typeof bannerVariants>, React.ComponentProps<"div"> {
7
+ dismissible?: boolean;
8
+ }
9
+ declare function Banner({ className, size, variant, dismissible, children, ...props }: BannerProps): import("react").JSX.Element | null;
10
+ export { Banner };
@@ -0,0 +1,39 @@
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { c as cva } from "../../_chunks/index2.js";
3
+ import { c as cn } from "../../_chunks/utils.js";
4
+ import { useState } from "react";
5
+ import { Button } from "./button.js";
6
+ import { c as createLucideIcon } from "../../_chunks/createLucideIcon.js";
7
+ const __iconNode = [
8
+ ["path", { d: "M18 6 6 18", key: "1bl5f8" }],
9
+ ["path", { d: "m6 6 12 12", key: "d8bk6v" }]
10
+ ];
11
+ const X = createLucideIcon("x", __iconNode);
12
+ const bannerVariants = cva("flex flex-row items-center justify-between px-(--spacing-section) text-sm", {
13
+ variants: {
14
+ variant: {
15
+ default: "bg-complement-3 text-white",
16
+ alert: "bg-complement-2-200 text-black"
17
+ },
18
+ size: {
19
+ default: "py-2",
20
+ sm: "py-1",
21
+ lg: "py-3 text-md font-semibold"
22
+ }
23
+ },
24
+ defaultVariants: {
25
+ variant: "default",
26
+ size: "default"
27
+ }
28
+ });
29
+ function Banner({ className, size, variant, dismissible, children, ...props }) {
30
+ const [dismissed, setDismissed] = useState(false);
31
+ if (dismissed) return null;
32
+ return /* @__PURE__ */ jsxs("div", { "data-slot": "banner", className: cn(bannerVariants({ variant, size }), className), ...props, children: [
33
+ /* @__PURE__ */ jsx("div", { className: "flex-auto text-center", children }),
34
+ dismissible && /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "size-6 text-white", onClick: () => setDismissed(true), children: /* @__PURE__ */ jsx(X, {}) }) })
35
+ ] });
36
+ }
37
+ export {
38
+ Banner
39
+ };
@@ -0,0 +1,11 @@
1
+ import { VariantProps } from 'class-variance-authority';
2
+ declare const buttonVariants: (props?: ({
3
+ variant?: "item" | "default" | "secondary" | "outline" | "ghost" | "destructive" | null | undefined;
4
+ block?: boolean | null | undefined;
5
+ size?: "text" | "default" | "sm" | "lg" | "icon" | null | undefined;
6
+ } & import('class-variance-authority/dist/types').ClassProp) | undefined) => string;
7
+ export type ButtonProps = React.ComponentProps<"button"> & VariantProps<typeof buttonVariants> & {
8
+ asChild?: boolean;
9
+ };
10
+ declare function Button({ className, variant, size, block, asChild, ...props }: ButtonProps): import("react").JSX.Element;
11
+ export { Button, buttonVariants };
@@ -1,8 +1,8 @@
1
- import { jsx as n } from "react/jsx-runtime";
2
- import { S as s } from "./index-U7DVCmS_.js";
3
- import { c as d } from "./index-CQhYMnjT.js";
4
- import { c } from "./utils-CRiPKpXj.js";
5
- const u = d(
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { S as Slot } from "../../_chunks/index.js";
3
+ import { c as cva } from "../../_chunks/index2.js";
4
+ import { c as cn } from "../../_chunks/utils.js";
5
+ const buttonVariants = cva(
6
6
  "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-sm text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 px-6 has-[>svg]:px-4 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring focus-visible:ring-2 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
7
7
  {
8
8
  variants: {
@@ -28,15 +28,16 @@ const u = d(
28
28
  },
29
29
  defaultVariants: {
30
30
  size: "default",
31
- block: !1,
31
+ block: false,
32
32
  variant: "default"
33
33
  }
34
34
  }
35
35
  );
36
- function p({ className: e, variant: r, size: t, block: o, asChild: a = !1, ...i }) {
37
- return /* @__PURE__ */ n(a ? s : "button", { "data-slot": "button", className: c(u({ size: t, block: o, variant: r }), e), ...i });
36
+ function Button({ className, variant, size, block, asChild = false, ...props }) {
37
+ const Comp = asChild ? Slot : "button";
38
+ return /* @__PURE__ */ jsx(Comp, { "data-slot": "button", className: cn(buttonVariants({ size, block, variant }), className), ...props });
38
39
  }
39
40
  export {
40
- p as Button,
41
- u as buttonVariants
41
+ Button,
42
+ buttonVariants
42
43
  };
@@ -0,0 +1,27 @@
1
+ import { VariantProps } from 'class-variance-authority';
2
+ declare const cardVariants: (props?: ({
3
+ bordered?: boolean | null | undefined;
4
+ rounded?: boolean | null | undefined;
5
+ } & import('class-variance-authority/dist/types').ClassProp) | undefined) => string;
6
+ export type CardProps<T extends boolean> = (T extends true ? React.ComponentProps<"a"> : React.ComponentProps<"div">) & VariantProps<typeof cardVariants> & {
7
+ asLink?: T;
8
+ };
9
+ declare function Card<T extends boolean = false>({ className, asLink, bordered, rounded, ...props }: CardProps<T>): import("react").JSX.Element;
10
+ type CardAreaProps = React.ComponentProps<"div"> & {
11
+ name: string;
12
+ };
13
+ declare function CardArea({ name, className, ...props }: CardAreaProps): import("react").JSX.Element;
14
+ declare function CardItemGroup({ className, ...props }: React.ComponentProps<"div">): import("react").JSX.Element;
15
+ type CardTitleProps = React.ComponentProps<"div"> & {
16
+ size?: "sm" | "md" | "lg";
17
+ };
18
+ declare function CardTitle({ size, className, ...props }: CardTitleProps): import("react").JSX.Element;
19
+ declare function CardSubtitle({ size, className, ...props }: CardTitleProps): 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;
26
+ declare function CardImage({ className, ...props }: React.ComponentProps<"img">): import("react").JSX.Element;
27
+ export { Card, CardArea, CardItemGroup, CardToolbar, CardTitle, CardSubtitle, CardCaption, CardSubcaption, CardMeta, CardContent, CardMedia, CardImage, };
@@ -0,0 +1,109 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { c as cn } from "../../_chunks/utils.js";
3
+ import { Caption } from "./typography/caption.js";
4
+ import { c as cva } from "../../_chunks/index2.js";
5
+ const cardVariants = cva("group @container/card w-full max-w-full bg-card text-card-foreground grid gap-(--gap-card)", {
6
+ variants: {
7
+ bordered: {
8
+ true: "p-(--spacing-card) border border-complement-1-100 dark:border-brand-1-900 ",
9
+ false: ""
10
+ },
11
+ rounded: {
12
+ true: "rounded-2xl",
13
+ false: ""
14
+ }
15
+ },
16
+ defaultVariants: {
17
+ bordered: false,
18
+ rounded: false
19
+ }
20
+ });
21
+ function Card({ className, asLink, bordered, rounded, ...props }) {
22
+ const Comp = asLink ? "a" : "div";
23
+ const linkClassName = asLink ? "transition-all hover:bg-complement-1-50 dark:hover:bg-gray-900" : "";
24
+ return (
25
+ //@ts-expect-error: props type will be correct
26
+ /* @__PURE__ */ jsx(Comp, { "data-slot": "card", className: cn(cardVariants({ bordered, rounded }), linkClassName, className), ...props })
27
+ );
28
+ }
29
+ function CardArea({ name, className, ...props }) {
30
+ return /* @__PURE__ */ jsx(
31
+ "div",
32
+ {
33
+ style: { gridArea: name },
34
+ className: cn("@container/card-area relative flex flex-col gap-(--gap-card-area)", className),
35
+ ...props
36
+ }
37
+ );
38
+ }
39
+ function CardItemGroup({ className, ...props }) {
40
+ return /* @__PURE__ */ jsx("div", { className: cn("flex flex-col gap-(--gap-card-item-group)", className), ...props });
41
+ }
42
+ function CardTitle({ size = "md", className, ...props }) {
43
+ return /* @__PURE__ */ jsx(
44
+ "div",
45
+ {
46
+ className: cn(
47
+ {
48
+ "heading-1": size === "lg",
49
+ "heading-2": size === "md",
50
+ "heading-3": size === "sm"
51
+ },
52
+ className
53
+ ),
54
+ ...props
55
+ }
56
+ );
57
+ }
58
+ function CardSubtitle({ size = "md", className, ...props }) {
59
+ return /* @__PURE__ */ jsx(
60
+ "div",
61
+ {
62
+ className: cn(
63
+ "text-secondary",
64
+ {
65
+ "heading-1": size === "lg",
66
+ "heading-2": size === "md",
67
+ "heading-3": size === "sm"
68
+ },
69
+ className
70
+ ),
71
+ ...props
72
+ }
73
+ );
74
+ }
75
+ function CardCaption(props) {
76
+ return /* @__PURE__ */ jsx(Caption, { ...props });
77
+ }
78
+ function CardSubcaption(props) {
79
+ return /* @__PURE__ */ jsx(Caption, { variant: "light", ...props });
80
+ }
81
+ function CardMeta(props) {
82
+ return /* @__PURE__ */ jsx(Caption, { variant: "light", ...props });
83
+ }
84
+ function CardContent(props) {
85
+ return /* @__PURE__ */ jsx("div", { ...props });
86
+ }
87
+ function CardToolbar({ className, ...props }) {
88
+ return /* @__PURE__ */ jsx("div", { className: cn("flex flex-wrap items-center gap-(--gap-card-item-group)", className), ...props });
89
+ }
90
+ function CardMedia({ className, ...props }) {
91
+ return /* @__PURE__ */ jsx("div", { className: cn("relative w-full h-full", className), ...props });
92
+ }
93
+ function CardImage({ className, ...props }) {
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 }) });
95
+ }
96
+ export {
97
+ Card,
98
+ CardArea,
99
+ CardCaption,
100
+ CardContent,
101
+ CardImage,
102
+ CardItemGroup,
103
+ CardMedia,
104
+ CardMeta,
105
+ CardSubcaption,
106
+ CardSubtitle,
107
+ CardTitle,
108
+ CardToolbar
109
+ };
@@ -0,0 +1,20 @@
1
+ import { CompositeItemKey, CompositeOptions, CompositeProviderOptions } from './types';
2
+ import { CompositeDataItem } from './CompositeDataItem';
3
+ import { AbstractFocusProvider } from './FocusProvider/AbstractFocusProvider';
4
+ import { AbstractSelectionProvider } from './SelectionProvider/AbstractSelectionProvider';
5
+ export declare class CompositeData<T extends object> implements Iterable<CompositeDataItem<T>> {
6
+ #private;
7
+ lookup: Map<CompositeItemKey, CompositeDataItem<T>>;
8
+ focusProvider: AbstractFocusProvider<T>;
9
+ selectionProvider?: AbstractSelectionProvider<T>;
10
+ disabledKeys: Set<CompositeItemKey>;
11
+ root: CompositeDataItem<T>;
12
+ constructor(items: T[], providerOptions: CompositeProviderOptions<T>, options?: CompositeOptions);
13
+ [Symbol.iterator](): Iterator<CompositeDataItem<T>>;
14
+ toJSON(): T[];
15
+ init(items: T[]): void;
16
+ item(key: CompositeItemKey): CompositeDataItem<T> | undefined;
17
+ descendants(itemKey: CompositeItemKey): CompositeDataItem<T>[] | undefined;
18
+ ancestors(itemKey: CompositeItemKey): CompositeDataItem<T>[] | undefined;
19
+ updateItem(key: CompositeItemKey, data: Partial<T> | ((item: T) => Partial<T>)): void;
20
+ }
@@ -0,0 +1,89 @@
1
+ import { CompositeDataItem } from "./CompositeDataItem.js";
2
+ import { union } from "../../../lib/set-operations.js";
3
+ class CompositeData {
4
+ #options;
5
+ lookup = /* @__PURE__ */ new Map();
6
+ focusProvider;
7
+ selectionProvider;
8
+ disabledKeys = /* @__PURE__ */ new Set();
9
+ root;
10
+ constructor(items, providerOptions, options) {
11
+ this.#options = {
12
+ itemKeyProp: "key",
13
+ itemChildrenProp: "children",
14
+ disabledKeys: [],
15
+ selectedKeys: [],
16
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
17
+ getItemKey: (item) => item[this.#options.itemKeyProp],
18
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
19
+ getItemChildren: (item) => item[this.#options.itemChildrenProp] ? item[this.#options.itemChildrenProp] : void 0,
20
+ ...options
21
+ };
22
+ this.focusProvider = providerOptions.focusProvider;
23
+ this.selectionProvider = providerOptions.selectionProvider;
24
+ this.init(items);
25
+ }
26
+ *[Symbol.iterator]() {
27
+ if (this.root.children) {
28
+ for (const node of this.root.children) {
29
+ yield node;
30
+ }
31
+ }
32
+ }
33
+ toJSON() {
34
+ const json = this.root.toJSON();
35
+ return json[this.#options.itemChildrenProp];
36
+ }
37
+ init(items) {
38
+ this.root = new CompositeDataItem(
39
+ { [this.#options.itemKeyProp]: "ALL", [this.#options.itemChildrenProp]: items },
40
+ this.#options,
41
+ null
42
+ );
43
+ this.lookup = new Map([...this.root].map((item) => [item.key, item]));
44
+ this.#options.disabledKeys.forEach((disabledKey) => this.#disable(disabledKey));
45
+ if (this.selectionProvider)
46
+ this.selectionProvider.init(this, this.#options);
47
+ this.focusProvider.init(this, this.#options);
48
+ }
49
+ item(key) {
50
+ return this.lookup.get(key);
51
+ }
52
+ descendants(itemKey) {
53
+ const item = this.lookup.get(itemKey);
54
+ if (!item) return void 0;
55
+ return item.descendants();
56
+ }
57
+ ancestors(itemKey) {
58
+ const item = this.lookup.get(itemKey);
59
+ if (!item) return void 0;
60
+ return item.ancestors();
61
+ }
62
+ #disable(item, recursive = false) {
63
+ const _item = item instanceof CompositeDataItem ? item : this.lookup.get(item);
64
+ if (!_item) return;
65
+ const disabledKeys = _item.disable(recursive);
66
+ this.disabledKeys = union(this.disabledKeys, disabledKeys);
67
+ }
68
+ updateItem(key, data) {
69
+ const item = this.lookup.get(key);
70
+ if (item) {
71
+ const newData = {
72
+ ...item.data.get(),
73
+ ...typeof data === "function" ? data(item.data.get()) : data
74
+ };
75
+ const newKey = this.#options.getItemKey(newData);
76
+ if (item.key !== newKey) throw "Item key cannot be updated!";
77
+ this.#updateIfSelectedItem(key);
78
+ item.data.set(newData);
79
+ }
80
+ }
81
+ #updateIfSelectedItem(key) {
82
+ if (this.selectionProvider && this.selectionProvider.selectedKeys.get().has(key)) {
83
+ this.selectionProvider.selectedKeys.set(/* @__PURE__ */ new Set([...this.selectionProvider.selectedKeys.get()]));
84
+ }
85
+ }
86
+ }
87
+ export {
88
+ CompositeData
89
+ };
@@ -0,0 +1,28 @@
1
+ import { PreinitializedMapStore } from 'nanostores';
2
+ import { CompositeDataItemState, CompositeItemKey, CompositeDataItemOptions } from './types';
3
+ export declare class CompositeDataItem<T extends object> implements Iterable<CompositeDataItem<T>> {
4
+ #private;
5
+ parent: CompositeDataItem<T> | null;
6
+ children?: CompositeDataItem<T>[];
7
+ level: number;
8
+ data: PreinitializedMapStore<T>;
9
+ state: PreinitializedMapStore<CompositeDataItemState>;
10
+ pointers: {
11
+ left?: CompositeItemKey;
12
+ right?: CompositeItemKey;
13
+ up?: CompositeItemKey;
14
+ down?: CompositeItemKey;
15
+ };
16
+ childrenProp: string;
17
+ constructor(item: T, options: CompositeDataItemOptions<T>, parent: CompositeDataItem<T> | null);
18
+ get key(): CompositeItemKey;
19
+ [Symbol.iterator](): Iterator<CompositeDataItem<T>>;
20
+ toJSON(): T;
21
+ descendants(): CompositeDataItem<T>[];
22
+ ancestors(): CompositeDataItem<T>[];
23
+ toggleSelect(recursive?: boolean): void;
24
+ select(recursive?: boolean): CompositeItemKey[];
25
+ deselect(recursive?: boolean): CompositeItemKey[];
26
+ disable(recursive?: boolean): CompositeItemKey[];
27
+ enable(recursive?: boolean): CompositeItemKey[];
28
+ }
@@ -0,0 +1,111 @@
1
+ import { omit } from "../../../lib/object.js";
2
+ import { map } from "nanostores";
3
+ class CompositeDataItem {
4
+ #key;
5
+ parent = null;
6
+ children;
7
+ level;
8
+ data;
9
+ state;
10
+ pointers;
11
+ childrenProp;
12
+ constructor(item, options, parent) {
13
+ this.#key = options.getItemKey(item);
14
+ this.data = map(omit(item, [options.itemChildrenProp]));
15
+ this.state = map({
16
+ focused: false,
17
+ selected: false,
18
+ disabled: false,
19
+ ...options.initialState
20
+ });
21
+ this.pointers = {};
22
+ this.parent = parent;
23
+ this.level = parent ? parent.level + 1 : 0;
24
+ this.childrenProp = options.itemChildrenProp;
25
+ const children = options.getItemChildren(item);
26
+ if (children) {
27
+ this.children = children.map((child) => {
28
+ const childItem = new CompositeDataItem(child, options, this);
29
+ return childItem;
30
+ });
31
+ }
32
+ }
33
+ get key() {
34
+ return this.#key;
35
+ }
36
+ *[Symbol.iterator]() {
37
+ if (this.key !== "ALL") yield this;
38
+ if (this.children)
39
+ for (const child of this.children)
40
+ for (const item of child) yield item;
41
+ }
42
+ toJSON() {
43
+ const json = { ...this.data.get() };
44
+ if (this.children) {
45
+ json[this.childrenProp] = [];
46
+ for (const child of this.children)
47
+ json[this.childrenProp].push(child.toJSON());
48
+ }
49
+ return json;
50
+ }
51
+ descendants() {
52
+ if (!this.children) return [];
53
+ const descendants = [];
54
+ this.children.forEach(
55
+ (child) => {
56
+ descendants.push(child);
57
+ const childDescendants = child.descendants();
58
+ if (childDescendants) descendants.push(...childDescendants);
59
+ }
60
+ );
61
+ return descendants;
62
+ }
63
+ ancestors() {
64
+ const ancestors = [];
65
+ let parent = this.parent;
66
+ while (parent) {
67
+ ancestors.push(parent);
68
+ parent = parent.parent;
69
+ }
70
+ return ancestors;
71
+ }
72
+ toggleSelect(recursive = false) {
73
+ if (this.state.get().selected) this.deselect(recursive);
74
+ else this.select(recursive);
75
+ }
76
+ select(recursive = false) {
77
+ this.state.setKey("selected", true);
78
+ if (recursive && this.children) {
79
+ const selectedChildKeys = this.children.map((child) => child.select(true)).flat();
80
+ return [this.key, ...selectedChildKeys];
81
+ }
82
+ return [this.key];
83
+ }
84
+ deselect(recursive = false) {
85
+ this.state.setKey("selected", false);
86
+ if (recursive && this.children) {
87
+ const deselectedChildKeys = this.children.map((child) => child.deselect(true)).flat();
88
+ return [this.key, ...deselectedChildKeys];
89
+ }
90
+ return [this.key];
91
+ }
92
+ disable(recursive = false) {
93
+ this.state.setKey("disabled", true);
94
+ if (recursive && this.children) {
95
+ const disabledChildKeys = this.children.map((child) => child.disable(true)).flat();
96
+ return [this.key, ...disabledChildKeys];
97
+ }
98
+ return [this.key];
99
+ }
100
+ enable(recursive = false) {
101
+ this.state.setKey("disabled", false);
102
+ if (recursive && this.children) {
103
+ const enabledChildKeys = this.children.map((child) => child.enable(true)).flat();
104
+ return [this.key, ...enabledChildKeys];
105
+ }
106
+ return [this.key];
107
+ }
108
+ }
109
+ export {
110
+ CompositeDataItem
111
+ };
@@ -0,0 +1,41 @@
1
+ import { PreinitializedWritableAtom } from 'nanostores';
2
+ import { CompositeData } from '../CompositeData';
3
+ import { CompositeDataItem } from '../CompositeDataItem';
4
+ import { CompositeDataOptions, CompositeItemKey } from '../types';
5
+ export interface FocusProvider {
6
+ focus(itemKey: CompositeItemKey): void;
7
+ focusUp(): void;
8
+ focusDown(): void;
9
+ focusLeft(): void;
10
+ focusRight(): void;
11
+ focusPageUp(): void;
12
+ focesPageDown(): void;
13
+ focusToFirst(): void;
14
+ focusToLast(): void;
15
+ focusToFirstInRow(): void;
16
+ focusToLastInRow(): void;
17
+ focusToTypeAheadMatch(): void;
18
+ }
19
+ export declare abstract class AbstractFocusProvider<T extends object> implements FocusProvider {
20
+ protected data: CompositeData<T>;
21
+ protected dataOptions: CompositeDataOptions<T>;
22
+ firstFocusableItem: CompositeDataItem<T> | null;
23
+ lastFocusableItem: CompositeDataItem<T> | null;
24
+ focusedItem: PreinitializedWritableAtom<CompositeDataItem<T> | null>;
25
+ init(data: CompositeData<T>, dataOptions: CompositeDataOptions<T>): void;
26
+ isFocusable(itemAtom: CompositeDataItem<T>): boolean;
27
+ focus(itemKey: CompositeItemKey): void;
28
+ focus(item: CompositeDataItem<T>): void;
29
+ abstract setFocusPointers(): readonly [first: CompositeDataItem<T> | null, last: CompositeDataItem<T> | null];
30
+ abstract focusUp(): void;
31
+ abstract focusDown(): void;
32
+ abstract focusLeft(): void;
33
+ abstract focusRight(): void;
34
+ abstract focusPageUp(): void;
35
+ abstract focesPageDown(): void;
36
+ abstract focusToFirst(): void;
37
+ abstract focusToLast(): void;
38
+ abstract focusToFirstInRow(): void;
39
+ abstract focusToLastInRow(): void;
40
+ abstract focusToTypeAheadMatch(): void;
41
+ }
@@ -0,0 +1,36 @@
1
+ import { atom } from "nanostores";
2
+ import { CompositeDataItem } from "../CompositeDataItem.js";
3
+ class AbstractFocusProvider {
4
+ data;
5
+ dataOptions;
6
+ firstFocusableItem;
7
+ lastFocusableItem;
8
+ focusedItem = atom(null);
9
+ init(data, dataOptions) {
10
+ this.data = data;
11
+ this.dataOptions = dataOptions;
12
+ const [first, last] = this.setFocusPointers();
13
+ this.firstFocusableItem = first;
14
+ if (this.firstFocusableItem) {
15
+ this.firstFocusableItem.state.setKey("focused", true);
16
+ this.focusedItem.set(this.firstFocusableItem);
17
+ }
18
+ this.lastFocusableItem = last;
19
+ }
20
+ isFocusable(itemAtom) {
21
+ return !itemAtom.state.get().disabled;
22
+ }
23
+ focus(item) {
24
+ const _item = item instanceof CompositeDataItem ? item : this.data.lookup.get(item);
25
+ if (!_item) return;
26
+ if (this.focusedItem.get()) {
27
+ if (_item.key === this.focusedItem.get()?.key) return;
28
+ this.focusedItem.get().state.setKey("focused", false);
29
+ }
30
+ _item.state.setKey("focused", true);
31
+ this.focusedItem.set(_item);
32
+ }
33
+ }
34
+ export {
35
+ AbstractFocusProvider
36
+ };