@blenx-dev/core 0.1.0 → 0.2.3

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 (58) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/iconify.config.ts +23 -0
  3. package/package.json +17 -7
  4. package/scripts/generate-icons.ts +82 -0
  5. package/src/components/Accordion/accordion.tsx +2 -2
  6. package/src/components/Autocomplete/autocomplete.tsx +2 -2
  7. package/src/components/Breadcrumbs/breadcrumbs.tsx +3 -3
  8. package/src/components/Checkbox/checkbox.tsx +2 -15
  9. package/src/components/CloseButton/close-button.tsx +2 -5
  10. package/src/components/Combobox/combobox.tsx +5 -5
  11. package/src/components/Command/command.tsx +2 -2
  12. package/src/components/CopyButton/copy-button.tsx +3 -11
  13. package/src/components/Drawer/drawer.tsx +3 -29
  14. package/src/components/Icon/icon.tsx +3 -3
  15. package/src/components/Popover/popover.tsx +24 -14
  16. package/src/components/Select/select.tsx +5 -5
  17. package/src/components/Spinner/spinner.tsx +3 -5
  18. package/src/components/Stack/stack.tsx +5 -15
  19. package/src/components/Text/text.tsx +1 -1
  20. package/src/components/index.ts +0 -3
  21. package/src/icons/ArrowRightIcon.tsx +20 -0
  22. package/src/icons/CalendarIcon.tsx +20 -0
  23. package/src/icons/CheckIcon.tsx +20 -0
  24. package/src/icons/ChevronDownIcon.tsx +20 -0
  25. package/src/icons/ChevronLeftIcon.tsx +20 -0
  26. package/src/icons/ChevronRightIcon.tsx +20 -0
  27. package/src/icons/ChevronUpIcon.tsx +20 -0
  28. package/src/icons/CircleAlertIcon.tsx +20 -0
  29. package/src/icons/CopyIcon.tsx +20 -0
  30. package/src/icons/EllipsisIcon.tsx +20 -0
  31. package/src/icons/FolderOpenIcon.tsx +20 -0
  32. package/src/icons/ListIcon.tsx +20 -0
  33. package/src/icons/LoaderCircleIcon.tsx +20 -0
  34. package/src/icons/SearchIcon.tsx +20 -0
  35. package/src/icons/SquareCheckIcon.tsx +20 -0
  36. package/src/icons/XIcon.tsx +20 -0
  37. package/src/icons/index.ts +17 -0
  38. package/src/utils/sprinkles.css.ts +18 -4
  39. package/src/DataTable/data-table-column-toggle.tsx +0 -73
  40. package/src/DataTable/data-table-empty.tsx +0 -27
  41. package/src/DataTable/data-table-error.tsx +0 -25
  42. package/src/DataTable/data-table-infinite-loader.tsx +0 -73
  43. package/src/DataTable/data-table-loading.tsx +0 -67
  44. package/src/DataTable/data-table-pagination.tsx +0 -80
  45. package/src/DataTable/data-table-toolbar.tsx +0 -62
  46. package/src/DataTable/data-table.css.ts +0 -420
  47. package/src/DataTable/data-table.tsx +0 -507
  48. package/src/DataTable/index.ts +0 -24
  49. package/src/DataTable/types.ts +0 -169
  50. package/src/DataTable/use-infinite-scroll.ts +0 -67
  51. package/src/components/Calendar/calendar.css.ts +0 -187
  52. package/src/components/Calendar/calendar.tsx +0 -143
  53. package/src/components/Calendar/index.ts +0 -1
  54. package/src/components/ColorPicker/color-picker.tsx +0 -123
  55. package/src/components/ColorPicker/index.ts +0 -1
  56. package/src/components/DatePicker/date-picker.tsx +0 -75
  57. package/src/components/DatePicker/index.ts +0 -1
  58. package/src/components/Stack/stack.css.ts +0 -42
@@ -1,22 +1,12 @@
1
- import clsx from "clsx";
2
1
  import type { BoxProps } from "../Box/box";
3
2
  import { Box } from "../Box/box";
4
- import { stackRecipe } from "./stack.css";
5
- import type { RecipeVariants } from "@vanilla-extract/recipes";
6
3
 
7
- type StackVariants = RecipeVariants<typeof stackRecipe>;
4
+ export type StackProps = Omit<BoxProps, "display"> & {
5
+ wrap?: boolean;
6
+ };
8
7
 
9
- export type StackProps = Omit<BoxProps, "display"> & StackVariants;
10
-
11
- export function Stack({ gap, align, justify, wrap, className, style, ...props }: StackProps) {
12
- return (
13
- <Box
14
- display="flex"
15
- className={clsx(stackRecipe({ gap, align, justify, wrap }), className)}
16
- style={style}
17
- {...props}
18
- />
19
- );
8
+ export function Stack({ wrap, ...props }: StackProps) {
9
+ return <Box display="flex" {...(wrap ? { flexWrap: "wrap" } : {})} gap="md" {...props} />;
20
10
  }
21
11
 
22
12
  type VStackProps = Omit<StackProps, "direction">;
@@ -26,7 +26,7 @@ const variantTag = {
26
26
  } as const satisfies Record<string, keyof React.JSX.IntrinsicElements>;
27
27
 
28
28
  export type TextProps = useRender.ComponentProps<"div"> &
29
- BaseSprinkles &
29
+ Omit<BaseSprinkles, "fontSize"> &
30
30
  RecipeVariants<typeof textVariants> & { span?: boolean } & {
31
31
  size?: BaseSprinkles["fontSize"];
32
32
  };
@@ -11,15 +11,12 @@ export * from "./Badge/badge";
11
11
  export * from "./Box/box";
12
12
  export * from "./Breadcrumbs/breadcrumbs";
13
13
  export * from "./Button/button";
14
- export * from "./Calendar/calendar";
15
14
  export * from "./Card/card";
16
15
  export * from "./Checkbox/checkbox";
17
16
  export * from "./Command/command";
18
- export * from "./ColorPicker/color-picker";
19
17
  export * from "./ColorSwatch/color-swatch";
20
18
  export * from "./Combobox/combobox";
21
19
  export * from "./Container/container";
22
- // Export * from "./DatePicker/date-picker";
23
20
  export * from "./Dialog/dialog";
24
21
  export * from "./Drawer/drawer";
25
22
  export * from "./Field/field";
@@ -0,0 +1,20 @@
1
+ import * as React from "react";
2
+
3
+ interface IconProps extends React.SVGProps<SVGSVGElement> {}
4
+
5
+ export const ArrowRightIcon = React.forwardRef<SVGSVGElement, IconProps>((props, ref) => (
6
+ <svg
7
+ ref={ref}
8
+ xmlns="http://www.w3.org/2000/svg"
9
+ viewBox="0 0 24 24"
10
+ fill="none"
11
+ stroke="currentColor"
12
+ dangerouslySetInnerHTML={{
13
+ __html:
14
+ '<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 12h14m-7-7l7 7l-7 7"/>',
15
+ }}
16
+ {...props}
17
+ />
18
+ ));
19
+
20
+ ArrowRightIcon.displayName = "ArrowRightIcon";
@@ -0,0 +1,20 @@
1
+ import * as React from "react";
2
+
3
+ interface IconProps extends React.SVGProps<SVGSVGElement> {}
4
+
5
+ export const CalendarIcon = React.forwardRef<SVGSVGElement, IconProps>((props, ref) => (
6
+ <svg
7
+ ref={ref}
8
+ xmlns="http://www.w3.org/2000/svg"
9
+ viewBox="0 0 24 24"
10
+ fill="none"
11
+ stroke="currentColor"
12
+ dangerouslySetInnerHTML={{
13
+ __html:
14
+ '<g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><path d="M8 2v4m8-4v4"/><rect width="18" height="18" x="3" y="4" rx="2"/><path d="M3 10h18"/></g>',
15
+ }}
16
+ {...props}
17
+ />
18
+ ));
19
+
20
+ CalendarIcon.displayName = "CalendarIcon";
@@ -0,0 +1,20 @@
1
+ import * as React from "react";
2
+
3
+ interface IconProps extends React.SVGProps<SVGSVGElement> {}
4
+
5
+ export const CheckIcon = React.forwardRef<SVGSVGElement, IconProps>((props, ref) => (
6
+ <svg
7
+ ref={ref}
8
+ xmlns="http://www.w3.org/2000/svg"
9
+ viewBox="0 0 24 24"
10
+ fill="none"
11
+ stroke="currentColor"
12
+ dangerouslySetInnerHTML={{
13
+ __html:
14
+ '<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20 6L9 17l-5-5"/>',
15
+ }}
16
+ {...props}
17
+ />
18
+ ));
19
+
20
+ CheckIcon.displayName = "CheckIcon";
@@ -0,0 +1,20 @@
1
+ import * as React from "react";
2
+
3
+ interface IconProps extends React.SVGProps<SVGSVGElement> {}
4
+
5
+ export const ChevronDownIcon = React.forwardRef<SVGSVGElement, IconProps>((props, ref) => (
6
+ <svg
7
+ ref={ref}
8
+ xmlns="http://www.w3.org/2000/svg"
9
+ viewBox="0 0 24 24"
10
+ fill="none"
11
+ stroke="currentColor"
12
+ dangerouslySetInnerHTML={{
13
+ __html:
14
+ '<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m6 9l6 6l6-6"/>',
15
+ }}
16
+ {...props}
17
+ />
18
+ ));
19
+
20
+ ChevronDownIcon.displayName = "ChevronDownIcon";
@@ -0,0 +1,20 @@
1
+ import * as React from "react";
2
+
3
+ interface IconProps extends React.SVGProps<SVGSVGElement> {}
4
+
5
+ export const ChevronLeftIcon = React.forwardRef<SVGSVGElement, IconProps>((props, ref) => (
6
+ <svg
7
+ ref={ref}
8
+ xmlns="http://www.w3.org/2000/svg"
9
+ viewBox="0 0 24 24"
10
+ fill="none"
11
+ stroke="currentColor"
12
+ dangerouslySetInnerHTML={{
13
+ __html:
14
+ '<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m15 18l-6-6l6-6"/>',
15
+ }}
16
+ {...props}
17
+ />
18
+ ));
19
+
20
+ ChevronLeftIcon.displayName = "ChevronLeftIcon";
@@ -0,0 +1,20 @@
1
+ import * as React from "react";
2
+
3
+ interface IconProps extends React.SVGProps<SVGSVGElement> {}
4
+
5
+ export const ChevronRightIcon = React.forwardRef<SVGSVGElement, IconProps>((props, ref) => (
6
+ <svg
7
+ ref={ref}
8
+ xmlns="http://www.w3.org/2000/svg"
9
+ viewBox="0 0 24 24"
10
+ fill="none"
11
+ stroke="currentColor"
12
+ dangerouslySetInnerHTML={{
13
+ __html:
14
+ '<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m9 18l6-6l-6-6"/>',
15
+ }}
16
+ {...props}
17
+ />
18
+ ));
19
+
20
+ ChevronRightIcon.displayName = "ChevronRightIcon";
@@ -0,0 +1,20 @@
1
+ import * as React from "react";
2
+
3
+ interface IconProps extends React.SVGProps<SVGSVGElement> {}
4
+
5
+ export const ChevronUpIcon = React.forwardRef<SVGSVGElement, IconProps>((props, ref) => (
6
+ <svg
7
+ ref={ref}
8
+ xmlns="http://www.w3.org/2000/svg"
9
+ viewBox="0 0 24 24"
10
+ fill="none"
11
+ stroke="currentColor"
12
+ dangerouslySetInnerHTML={{
13
+ __html:
14
+ '<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m18 15l-6-6l-6 6"/>',
15
+ }}
16
+ {...props}
17
+ />
18
+ ));
19
+
20
+ ChevronUpIcon.displayName = "ChevronUpIcon";
@@ -0,0 +1,20 @@
1
+ import * as React from "react";
2
+
3
+ interface IconProps extends React.SVGProps<SVGSVGElement> {}
4
+
5
+ export const CircleAlertIcon = React.forwardRef<SVGSVGElement, IconProps>((props, ref) => (
6
+ <svg
7
+ ref={ref}
8
+ xmlns="http://www.w3.org/2000/svg"
9
+ viewBox="0 0 24 24"
10
+ fill="none"
11
+ stroke="currentColor"
12
+ dangerouslySetInnerHTML={{
13
+ __html:
14
+ '<g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><circle cx="12" cy="12" r="10"/><path d="M12 8v4m0 4h.01"/></g>',
15
+ }}
16
+ {...props}
17
+ />
18
+ ));
19
+
20
+ CircleAlertIcon.displayName = "CircleAlertIcon";
@@ -0,0 +1,20 @@
1
+ import * as React from "react";
2
+
3
+ interface IconProps extends React.SVGProps<SVGSVGElement> {}
4
+
5
+ export const CopyIcon = React.forwardRef<SVGSVGElement, IconProps>((props, ref) => (
6
+ <svg
7
+ ref={ref}
8
+ xmlns="http://www.w3.org/2000/svg"
9
+ viewBox="0 0 24 24"
10
+ fill="none"
11
+ stroke="currentColor"
12
+ dangerouslySetInnerHTML={{
13
+ __html:
14
+ '<g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></g>',
15
+ }}
16
+ {...props}
17
+ />
18
+ ));
19
+
20
+ CopyIcon.displayName = "CopyIcon";
@@ -0,0 +1,20 @@
1
+ import * as React from "react";
2
+
3
+ interface IconProps extends React.SVGProps<SVGSVGElement> {}
4
+
5
+ export const EllipsisIcon = React.forwardRef<SVGSVGElement, IconProps>((props, ref) => (
6
+ <svg
7
+ ref={ref}
8
+ xmlns="http://www.w3.org/2000/svg"
9
+ viewBox="0 0 24 24"
10
+ fill="none"
11
+ stroke="currentColor"
12
+ dangerouslySetInnerHTML={{
13
+ __html:
14
+ '<g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><circle cx="12" cy="12" r="1"/><circle cx="19" cy="12" r="1"/><circle cx="5" cy="12" r="1"/></g>',
15
+ }}
16
+ {...props}
17
+ />
18
+ ));
19
+
20
+ EllipsisIcon.displayName = "EllipsisIcon";
@@ -0,0 +1,20 @@
1
+ import * as React from "react";
2
+
3
+ interface IconProps extends React.SVGProps<SVGSVGElement> {}
4
+
5
+ export const FolderOpenIcon = React.forwardRef<SVGSVGElement, IconProps>((props, ref) => (
6
+ <svg
7
+ ref={ref}
8
+ xmlns="http://www.w3.org/2000/svg"
9
+ viewBox="0 0 24 24"
10
+ fill="none"
11
+ stroke="currentColor"
12
+ dangerouslySetInnerHTML={{
13
+ __html:
14
+ '<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m6 14l1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2"/>',
15
+ }}
16
+ {...props}
17
+ />
18
+ ));
19
+
20
+ FolderOpenIcon.displayName = "FolderOpenIcon";
@@ -0,0 +1,20 @@
1
+ import * as React from "react";
2
+
3
+ interface IconProps extends React.SVGProps<SVGSVGElement> {}
4
+
5
+ export const ListIcon = React.forwardRef<SVGSVGElement, IconProps>((props, ref) => (
6
+ <svg
7
+ ref={ref}
8
+ xmlns="http://www.w3.org/2000/svg"
9
+ viewBox="0 0 24 24"
10
+ fill="none"
11
+ stroke="currentColor"
12
+ dangerouslySetInnerHTML={{
13
+ __html:
14
+ '<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 5h.01M3 12h.01M3 19h.01M8 5h13M8 12h13M8 19h13"/>',
15
+ }}
16
+ {...props}
17
+ />
18
+ ));
19
+
20
+ ListIcon.displayName = "ListIcon";
@@ -0,0 +1,20 @@
1
+ import * as React from "react";
2
+
3
+ interface IconProps extends React.SVGProps<SVGSVGElement> {}
4
+
5
+ export const LoaderCircleIcon = React.forwardRef<SVGSVGElement, IconProps>((props, ref) => (
6
+ <svg
7
+ ref={ref}
8
+ xmlns="http://www.w3.org/2000/svg"
9
+ viewBox="0 0 24 24"
10
+ fill="none"
11
+ stroke="currentColor"
12
+ dangerouslySetInnerHTML={{
13
+ __html:
14
+ '<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 12a9 9 0 1 1-6.219-8.56"/>',
15
+ }}
16
+ {...props}
17
+ />
18
+ ));
19
+
20
+ LoaderCircleIcon.displayName = "LoaderCircleIcon";
@@ -0,0 +1,20 @@
1
+ import * as React from "react";
2
+
3
+ interface IconProps extends React.SVGProps<SVGSVGElement> {}
4
+
5
+ export const SearchIcon = React.forwardRef<SVGSVGElement, IconProps>((props, ref) => (
6
+ <svg
7
+ ref={ref}
8
+ xmlns="http://www.w3.org/2000/svg"
9
+ viewBox="0 0 24 24"
10
+ fill="none"
11
+ stroke="currentColor"
12
+ dangerouslySetInnerHTML={{
13
+ __html:
14
+ '<g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><path d="m21 21l-4.34-4.34"/><circle cx="11" cy="11" r="8"/></g>',
15
+ }}
16
+ {...props}
17
+ />
18
+ ));
19
+
20
+ SearchIcon.displayName = "SearchIcon";
@@ -0,0 +1,20 @@
1
+ import * as React from "react";
2
+
3
+ interface IconProps extends React.SVGProps<SVGSVGElement> {}
4
+
5
+ export const SquareCheckIcon = React.forwardRef<SVGSVGElement, IconProps>((props, ref) => (
6
+ <svg
7
+ ref={ref}
8
+ xmlns="http://www.w3.org/2000/svg"
9
+ viewBox="0 0 24 24"
10
+ fill="none"
11
+ stroke="currentColor"
12
+ dangerouslySetInnerHTML={{
13
+ __html:
14
+ '<g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><rect width="18" height="18" x="3" y="3" rx="2"/><path d="m9 12l2 2l4-4"/></g>',
15
+ }}
16
+ {...props}
17
+ />
18
+ ));
19
+
20
+ SquareCheckIcon.displayName = "SquareCheckIcon";
@@ -0,0 +1,20 @@
1
+ import * as React from "react";
2
+
3
+ interface IconProps extends React.SVGProps<SVGSVGElement> {}
4
+
5
+ export const XIcon = React.forwardRef<SVGSVGElement, IconProps>((props, ref) => (
6
+ <svg
7
+ ref={ref}
8
+ xmlns="http://www.w3.org/2000/svg"
9
+ viewBox="0 0 24 24"
10
+ fill="none"
11
+ stroke="currentColor"
12
+ dangerouslySetInnerHTML={{
13
+ __html:
14
+ '<path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M18 6L6 18M6 6l12 12"/>',
15
+ }}
16
+ {...props}
17
+ />
18
+ ));
19
+
20
+ XIcon.displayName = "XIcon";
@@ -0,0 +1,17 @@
1
+ export interface IconProps extends React.SVGProps<SVGSVGElement> {}
2
+ export * from "./ChevronLeftIcon";
3
+ export * from "./ChevronRightIcon";
4
+ export * from "./ChevronUpIcon";
5
+ export * from "./ChevronDownIcon";
6
+ export * from "./CalendarIcon";
7
+ export * from "./SquareCheckIcon";
8
+ export * from "./SearchIcon";
9
+ export * from "./CheckIcon";
10
+ export * from "./XIcon";
11
+ export * from "./FolderOpenIcon";
12
+ export * from "./LoaderCircleIcon";
13
+ export * from "./CircleAlertIcon";
14
+ export * from "./CopyIcon";
15
+ export * from "./ListIcon";
16
+ export * from "./EllipsisIcon";
17
+ export * from "./ArrowRightIcon";
@@ -72,6 +72,7 @@ const flexProperties = defineProperties({
72
72
  flexGrow: { 0: 0, 1: 1 },
73
73
  flexShrink: { 0: 0, 1: 1 },
74
74
  display: ["block", "flex", "grid", "inline-flex", "none"],
75
+ flexWrap: ["wrap", "nowrap", "wrap-reverse"],
75
76
  flexDirection: ["row", "row-reverse", "column", "column-reverse"],
76
77
  gap: spacing,
77
78
  },
@@ -168,13 +169,26 @@ const alignmentProperties = defineProperties({
168
169
  conditions: responsiveConditions,
169
170
  defaultCondition: "base",
170
171
  properties: {
171
- alignItems: ["start", "center", "end", "stretch", "baseline"],
172
- justifyItems: ["start", "center", "end", "stretch"],
173
- justifyContent: ["center", "start", "end", "stretch", "between", "around", "evenly"],
172
+ alignItems: {
173
+ start: "flex-start",
174
+ center: "center",
175
+ end: "flex-end",
176
+ stretch: "stretch",
177
+ baseline: "baseline",
178
+ },
179
+ justifyContent: {
180
+ start: "flex-start",
181
+ center: "center",
182
+ end: "flex-end",
183
+ stretch: "stretch",
184
+ between: "space-between",
185
+ around: "space-around",
186
+ evenly: "space-evenly",
187
+ },
174
188
  },
175
189
  shorthands: {
176
190
  align: ["alignItems"],
177
- justify: ["justifyItems", "justifyContent"],
191
+ justify: ["justifyContent"],
178
192
  },
179
193
  });
180
194
  export const baseSprinkles = createSprinkles(
@@ -1,73 +0,0 @@
1
- import { semanticVars } from "@blenx-dev/theme/contract";
2
- import { ListIcon } from "@phosphor-icons/react";
3
- import type { Table } from "@tanstack/react-table";
4
- import * as styles from "./data-table.css";
5
- import { Button, Menu, MenuItem, MenuPopup, MenuSeparator, MenuTrigger } from "../components";
6
-
7
- interface DataTableColumnToggleProps<TData> {
8
- table: Table<TData>;
9
- }
10
-
11
- export function DataTableColumnToggle<TData>({ table }: DataTableColumnToggleProps<TData>) {
12
- const columns = table.getAllLeafColumns().filter((column) => column.getCanHide());
13
-
14
- if (columns.length === 0) return null;
15
-
16
- const allVisible = columns.every((column) => column.getIsVisible());
17
- const someVisible = columns.some((column) => column.getIsVisible());
18
-
19
- return (
20
- <Menu>
21
- <MenuTrigger render={<Button variant="outline" size="sm" />}>
22
- <ListIcon size={16} />
23
- <span>Columns</span>
24
- </MenuTrigger>
25
- <MenuPopup align="end">
26
- <MenuItem
27
- onClick={() => {
28
- for (const column of columns) {
29
- column.toggleVisibility(allVisible);
30
- }
31
- }}
32
- >
33
- <span className={styles.deselectLabel}>{allVisible ? "Deselect all" : "Select all"}</span>
34
- <span className={allVisible ? styles.checkboxChecked : styles.checkboxUnchecked}>
35
- {allVisible && <CheckMark />}
36
- {!allVisible && someVisible && <div className={styles.partial} />}
37
- </span>
38
- </MenuItem>
39
- <MenuSeparator />
40
- {columns.map((column) => {
41
- const label = column.columnDef.header?.toString() ?? column.id;
42
- const isVisible = column.getIsVisible();
43
- return (
44
- <MenuItem key={column.id} onClick={() => column.toggleVisibility(!isVisible)}>
45
- <span className={styles.itemLabel}>{label}</span>
46
- <span className={isVisible ? styles.checkboxChecked : styles.checkboxUnchecked}>
47
- {isVisible && <CheckMark />}
48
- </span>
49
- </MenuItem>
50
- );
51
- })}
52
- </MenuPopup>
53
- </Menu>
54
- );
55
- }
56
-
57
- function CheckMark() {
58
- return (
59
- <svg
60
- width="12"
61
- height="12"
62
- viewBox="0 0 24 24"
63
- fill="none"
64
- stroke={semanticVars.interactive.primaryFg}
65
- strokeWidth="3"
66
- strokeLinecap="round"
67
- strokeLinejoin="round"
68
- >
69
- <title>Visible</title>
70
- <polyline points="20 6 9 17 4 12" />
71
- </svg>
72
- );
73
- }
@@ -1,27 +0,0 @@
1
- import { FolderOpenIcon } from "@phosphor-icons/react";
2
- import * as styles from "./data-table.css";
3
-
4
- interface DataTableEmptyProps {
5
- message?: string;
6
- icon?: React.ReactNode;
7
- action?: React.ReactNode;
8
- }
9
-
10
- export function DataTableEmpty({
11
- message = "No results found",
12
- icon,
13
- action,
14
- }: DataTableEmptyProps) {
15
- return (
16
- <output aria-label={message} className={styles.emptyContainer}>
17
- {icon && <div className={styles.iconWrap}>{icon}</div>}
18
- {!icon && (
19
- <div className={styles.iconWrap}>
20
- <FolderOpenIcon size={48} />
21
- </div>
22
- )}
23
- <p className={styles.message}>{message}</p>
24
- {action && <div className={styles.actionWrap}>{action}</div>}
25
- </output>
26
- );
27
- }
@@ -1,25 +0,0 @@
1
- import { WarningCircleIcon } from "@phosphor-icons/react";
2
- import * as styles from "./data-table.css";
3
- import { Button } from "../components";
4
-
5
- interface DataTableErrorProps {
6
- message?: string;
7
- onRetry?: () => void;
8
- }
9
-
10
- export function DataTableError({
11
- message = "Something went wrong while loading data",
12
- onRetry,
13
- }: DataTableErrorProps) {
14
- return (
15
- <div role="alert" aria-label={message} className={styles.errorContainer}>
16
- <WarningCircleIcon size={48} />
17
- <p className={styles.errorMessage}>{message}</p>
18
- {onRetry && (
19
- <Button variant="outline" size="sm" onClick={onRetry}>
20
- Retry
21
- </Button>
22
- )}
23
- </div>
24
- );
25
- }
@@ -1,73 +0,0 @@
1
- import { Button, Spinner } from "../components";
2
- import type { InfiniteScrollConfig } from "./types";
3
- import { useInfiniteScroll } from "./use-infinite-scroll";
4
- import * as styles from "./data-table.css";
5
-
6
- interface DataTableInfiniteLoaderProps {
7
- fetchNextPage: () => void;
8
- hasNextPage: boolean;
9
- isFetchingNextPage: boolean;
10
- isFetching?: boolean;
11
- config?: InfiniteScrollConfig;
12
- }
13
-
14
- export function DataTableInfiniteLoader({
15
- fetchNextPage,
16
- hasNextPage,
17
- isFetchingNextPage,
18
- isFetching,
19
- config,
20
- }: DataTableInfiniteLoaderProps) {
21
- const isAuto = config?.mode === "auto";
22
- const loadingText = config?.loadingText ?? "Loading...";
23
- const noMoreText = config?.noMoreText ?? "No more results";
24
-
25
- const { sentinelRef } = useInfiniteScroll({
26
- hasNextPage,
27
- isFetchingNextPage: isFetchingNextPage || Boolean(isFetching),
28
- fetchNextPage,
29
- rootMargin: config?.rootMargin,
30
- threshold: config?.threshold,
31
- enabled: isAuto,
32
- });
33
-
34
- if (isAuto) {
35
- return (
36
- <div
37
- ref={sentinelRef}
38
- aria-label={isFetchingNextPage ? loadingText : noMoreText}
39
- className={styles.sentinel}
40
- >
41
- {isFetchingNextPage && (
42
- <div className={styles.loadingInline}>
43
- <Spinner />
44
- <span className={styles.loaderLoadingText}>{loadingText}</span>
45
- </div>
46
- )}
47
- {!hasNextPage && !isFetchingNextPage && <span className={styles.noMore}>{noMoreText}</span>}
48
- </div>
49
- );
50
- }
51
-
52
- if (!hasNextPage) {
53
- return (
54
- <div className={styles.center}>
55
- <span className={styles.noMore}>{noMoreText}</span>
56
- </div>
57
- );
58
- }
59
-
60
- return (
61
- <div className={styles.center}>
62
- <Button
63
- variant="outline"
64
- onClick={fetchNextPage}
65
- disabled={isFetchingNextPage}
66
- loading={isFetchingNextPage}
67
- aria-label={config?.loadMoreText ?? "Load more"}
68
- >
69
- {config?.loadMoreText ?? "Load more"}
70
- </Button>
71
- </div>
72
- );
73
- }