@firecms/ui 3.0.0-canary.8 → 3.0.0-canary.80

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 (89) hide show
  1. package/README.md +1 -1
  2. package/dist/components/Avatar.d.ts +1 -0
  3. package/dist/components/BooleanSwitch.d.ts +1 -1
  4. package/dist/components/CenteredView.d.ts +4 -2
  5. package/dist/components/Checkbox.d.ts +4 -3
  6. package/dist/components/DateTimeField.d.ts +2 -2
  7. package/dist/components/InputLabel.d.ts +2 -2
  8. package/dist/components/Label.d.ts +4 -1
  9. package/dist/components/Markdown.d.ts +1 -0
  10. package/dist/components/Menu.d.ts +2 -1
  11. package/dist/components/Menubar.d.ts +69 -0
  12. package/dist/components/RadioGroup.d.ts +25 -3
  13. package/dist/components/Select.d.ts +1 -1
  14. package/dist/components/TextField.d.ts +1 -1
  15. package/dist/components/TextareaAutosize.d.ts +3 -34
  16. package/dist/components/index.d.ts +1 -1
  17. package/dist/hooks/index.d.ts +4 -0
  18. package/dist/hooks/useLocaleConfig.d.ts +1 -0
  19. package/dist/icons/Icon.d.ts +2 -2
  20. package/dist/index.d.ts +1 -0
  21. package/dist/index.es.js +8362 -8066
  22. package/dist/index.es.js.map +1 -1
  23. package/dist/index.umd.js +10 -10
  24. package/dist/index.umd.js.map +1 -1
  25. package/dist/styles.d.ts +6 -6
  26. package/dist/util/{cn.d.ts → cls.d.ts} +4 -0
  27. package/dist/util/index.d.ts +1 -3
  28. package/package.json +39 -49
  29. package/src/components/Alert.tsx +2 -2
  30. package/src/components/Autocomplete.tsx +4 -3
  31. package/src/components/Avatar.tsx +7 -4
  32. package/src/components/Badge.tsx +1 -1
  33. package/src/components/BooleanSwitch.tsx +9 -9
  34. package/src/components/BooleanSwitchWithLabel.tsx +5 -5
  35. package/src/components/Button.tsx +7 -7
  36. package/src/components/Card.tsx +2 -2
  37. package/src/components/CenteredView.tsx +25 -15
  38. package/src/components/Checkbox.tsx +31 -24
  39. package/src/components/Chip.tsx +2 -2
  40. package/src/components/CircularProgress.tsx +2 -2
  41. package/src/components/Collapse.tsx +3 -2
  42. package/src/components/Container.tsx +2 -2
  43. package/src/components/DateTimeField.tsx +10 -9
  44. package/src/components/Dialog.tsx +4 -4
  45. package/src/components/DialogActions.tsx +2 -2
  46. package/src/components/DialogContent.tsx +2 -2
  47. package/src/components/ExpandablePanel.tsx +8 -6
  48. package/src/components/FileUpload.tsx +5 -7
  49. package/src/components/IconButton.tsx +3 -3
  50. package/src/components/InfoLabel.tsx +2 -2
  51. package/src/components/InputLabel.tsx +10 -9
  52. package/src/components/Label.tsx +17 -4
  53. package/src/components/Markdown.tsx +14 -3
  54. package/src/components/Menu.tsx +13 -7
  55. package/src/components/Menubar.tsx +287 -0
  56. package/src/components/MultiSelect.tsx +7 -6
  57. package/src/components/Paper.tsx +2 -2
  58. package/src/components/Popover.tsx +3 -2
  59. package/src/components/RadioGroup.tsx +40 -9
  60. package/src/components/SearchBar.tsx +6 -6
  61. package/src/components/Select.tsx +24 -23
  62. package/src/components/Sheet.tsx +7 -7
  63. package/src/components/Skeleton.tsx +8 -5
  64. package/src/components/Table.tsx +6 -6
  65. package/src/components/Tabs.tsx +5 -5
  66. package/src/components/TextField.tsx +8 -7
  67. package/src/components/TextareaAutosize.tsx +3 -3
  68. package/src/components/Tooltip.tsx +4 -3
  69. package/src/components/Typography.tsx +20 -3
  70. package/src/components/common/SelectInputLabel.tsx +2 -2
  71. package/src/components/index.tsx +1 -1
  72. package/src/hooks/index.ts +4 -0
  73. package/src/hooks/useLocaleConfig.tsx +18 -0
  74. package/src/icons/Icon.tsx +44 -41
  75. package/src/index.ts +1 -0
  76. package/src/scripts/generateIconKeys.ts +0 -1
  77. package/src/styles.ts +6 -6
  78. package/src/util/cls.ts +14 -0
  79. package/src/util/index.ts +1 -3
  80. package/tailwind.config.js +70 -0
  81. package/dist/components/Spinner.d.ts +0 -1
  82. package/src/components/Spinner.tsx +0 -18
  83. package/src/util/cn.ts +0 -6
  84. /package/dist/{util → hooks}/useDebounceValue.d.ts +0 -0
  85. /package/dist/{util → hooks}/useInjectStyles.d.ts +0 -0
  86. /package/dist/{util → hooks}/useOutsideAlerter.d.ts +0 -0
  87. /package/src/{util → hooks}/useDebounceValue.tsx +0 -0
  88. /package/src/{util → hooks}/useInjectStyles.tsx +0 -0
  89. /package/src/{util → hooks}/useOutsideAlerter.tsx +0 -0
package/dist/styles.d.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  export declare const focusedMixin = "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-opacity-75 focus-visible:ring-offset-2 focus-visible:ring-offset-transparent";
2
2
  export declare const focusedInvisibleMixin = "focus:bg-opacity-70 focus:bg-slate-100 focus:dark:bg-gray-800 focus:dark:bg-opacity-60";
3
3
  export declare const focusedClasses = "z-30 outline-none ring-2 ring-primary ring-opacity-75 ring-offset-2 ring-offset-transparent ";
4
- export declare const fieldBackgroundMixin = "bg-opacity-50 bg-slate-200 dark:bg-gray-800 dark:bg-opacity-60 transition duration-150 ease-in-out";
5
- export declare const fieldBackgroundInvisibleMixin = "bg-opacity-0 bg-slate-100 dark:bg-gray-800 dark:bg-opacity-0 transition duration-150 ease-in-out";
6
- export declare const fieldBackgroundDisabledMixin = "bg-opacity-80 dark:bg-opacity-90";
7
- export declare const fieldBackgroundHoverMixin = "hover:bg-opacity-70 dark:hover:bg-opacity-90";
4
+ export declare const fieldBackgroundMixin = "bg-opacity-50 bg-slate-200 dark:bg-gray-800 dark:bg-opacity-60";
5
+ export declare const fieldBackgroundInvisibleMixin = "bg-opacity-0 bg-slate-100 dark:bg-gray-800 dark:bg-opacity-0";
6
+ export declare const fieldBackgroundDisabledMixin = "dark:bg-gray-800 bg-opacity-80 dark:bg-opacity-90";
7
+ export declare const fieldBackgroundHoverMixin = "hover:bg-opacity-70 dark:hover:bg-gray-700 dark:hover:bg-opacity-60";
8
8
  export declare const defaultBorderMixin = "border-gray-100 dark:border-gray-800 dark:border-opacity-80";
9
- export declare const paperMixin = "bg-white rounded-md dark:bg-gray-950 border dark:border-gray-800 dark:border-opacity-90 border-gray-100";
10
- export declare const cardMixin = "bg-white rounded-md dark:bg-gray-950 dark:border-gray-800 dark:border-opacity-50 transition duration-200 ease-in-out m-1 -p-1 border border-transparent";
9
+ export declare const paperMixin = "bg-white rounded-md dark:bg-gray-950 border dark:border-gray-800 dark:border-opacity-80 border-gray-100";
10
+ export declare const cardMixin = "bg-white border border-gray-100 dark:border-transparent rounded-md dark:bg-gray-950 dark:border-gray-800 dark:border-opacity-50 m-1 -p-1";
11
11
  export declare const cardClickableMixin = "hover:bg-primary-bg dark:hover:bg-primary-bg hover:bg-opacity-20 dark:hover:bg-opacity-20 hover:ring-2 hover:ring-primary cursor-pointer";
12
12
  export declare const cardSelectedMixin = "bg-primary-bg dark:bg-primary-bg bg-opacity-30 dark:bg-opacity-10 ring-1 ring-primary ring-opacity-75";
@@ -1,2 +1,6 @@
1
1
  import { type ClassValue } from "clsx";
2
+ export declare function cls(...classes: ClassValue[]): string;
3
+ /**
4
+ * @deprecated
5
+ */
2
6
  export declare function cn(...classes: ClassValue[]): string;
@@ -1,6 +1,4 @@
1
- export * from "./cn";
1
+ export * from "./cls";
2
2
  export * from "./debounce";
3
3
  export * from "./chip_colors";
4
4
  export * from "./key_to_icon_component";
5
- export * from "./useInjectStyles";
6
- export * from "./useOutsideAlerter";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@firecms/ui",
3
3
  "type": "module",
4
- "version": "3.0.0-canary.8",
4
+ "version": "3.0.0-canary.80",
5
5
  "description": "Awesome Firebase/Firestore-based headless open-source CMS",
6
6
  "funding": {
7
7
  "url": "https://github.com/sponsors/firecmsco"
@@ -31,9 +31,10 @@
31
31
  ".": {
32
32
  "import": "./dist/index.es.js",
33
33
  "require": "./dist/index.umd.js",
34
- "types": "./dist/src/index.d.ts"
34
+ "types": "./dist/index.d.ts"
35
35
  },
36
- "./package.json": "./package.json"
36
+ "./package.json": "./package.json",
37
+ "./tailwind.config.js": "./tailwind.config.js"
37
38
  },
38
39
  "scripts": {
39
40
  "watch": "vite build --watch",
@@ -47,72 +48,61 @@
47
48
  },
48
49
  "dependencies": {
49
50
  "@material-design-icons/font": "^0.14.13",
50
- "@radix-ui/react-checkbox": "^1.0.4",
51
- "@radix-ui/react-collapsible": "^1.0.3",
52
- "@radix-ui/react-dialog": "^1.0.5",
53
- "@radix-ui/react-dropdown-menu": "^2.0.6",
54
- "@radix-ui/react-label": "^2.0.2",
55
- "@radix-ui/react-popover": "^1.0.7",
56
- "@radix-ui/react-portal": "^1.0.4",
57
- "@radix-ui/react-radio-group": "^1.1.3",
58
- "@radix-ui/react-scroll-area": "^1.0.5",
59
- "@radix-ui/react-select": "^2.0.0",
60
- "@radix-ui/react-separator": "^1.0.3",
61
- "@radix-ui/react-switch": "^1.0.3",
62
- "@radix-ui/react-tabs": "^1.0.4",
63
- "@radix-ui/react-tooltip": "^1.0.7",
51
+ "@radix-ui/react-checkbox": "^1.1.1",
52
+ "@radix-ui/react-collapsible": "^1.1.0",
53
+ "@radix-ui/react-dialog": "^1.1.1",
54
+ "@radix-ui/react-dropdown-menu": "^2.1.1",
55
+ "@radix-ui/react-label": "^2.1.0",
56
+ "@radix-ui/react-menubar": "^1.1.1",
57
+ "@radix-ui/react-popover": "^1.1.1",
58
+ "@radix-ui/react-portal": "^1.1.1",
59
+ "@radix-ui/react-radio-group": "^1.2.0",
60
+ "@radix-ui/react-scroll-area": "^1.1.0",
61
+ "@radix-ui/react-select": "^2.1.1",
62
+ "@radix-ui/react-separator": "^1.1.0",
63
+ "@radix-ui/react-switch": "^1.1.0",
64
+ "@radix-ui/react-tabs": "^1.1.0",
65
+ "@radix-ui/react-tooltip": "^1.1.2",
66
+ "clsx": "^2.1.1",
64
67
  "cmdk": "^0.2.1",
65
- "react-datepicker": "^6.4.0",
68
+ "date-fns": "^3.6.0",
69
+ "react-datepicker": "^6.9.0",
66
70
  "react-dropzone": "^14.2.3",
67
71
  "react-fast-compare": "^3.2.2",
68
- "tailwind-merge": "^2.2.2"
72
+ "tailwind-merge": "^2.3.0"
69
73
  },
70
74
  "peerDependencies": {
71
- "react": "^18.2.0",
72
- "react-dom": "^18.2.0"
73
- },
74
- "eslintConfig": {
75
- "extends": [
76
- "react-app",
77
- "react-app/jest"
78
- ]
75
+ "react": "^18.3.1",
76
+ "react-dom": "^18.3.1"
79
77
  },
80
78
  "devDependencies": {
81
79
  "@jest/globals": "^29.7.0",
82
- "@testing-library/jest-dom": "^6.4.2",
83
- "@testing-library/react": "^14.2.1",
80
+ "@testing-library/jest-dom": "^6.4.6",
81
+ "@testing-library/react": "^15.0.7",
84
82
  "@testing-library/user-event": "^14.5.2",
85
83
  "@types/jest": "^29.5.12",
86
- "@types/node": "^20.11.30",
84
+ "@types/node": "^20.14.9",
87
85
  "@types/object-hash": "^3.0.6",
88
- "@types/react": "^18.2.67",
89
- "@types/react-dom": "^18.2.22",
86
+ "@types/react": "^18.3.3",
87
+ "@types/react-dom": "^18.3.0",
90
88
  "@types/react-measure": "^2.0.12",
91
- "@typescript-eslint/eslint-plugin": "^7.3.1",
92
- "@typescript-eslint/parser": "^7.3.1",
93
- "@vitejs/plugin-react": "^4.2.1",
89
+ "@vitejs/plugin-react": "^4.3.1",
94
90
  "cross-env": "^7.0.3",
95
- "eslint": "^8.57.0",
96
- "eslint-config-standard": "^17.1.0",
97
- "eslint-plugin-import": "^2.29.1",
98
- "eslint-plugin-n": "^16.6.2",
99
- "eslint-plugin-promise": "^6.1.1",
100
- "eslint-plugin-react": "^7.34.1",
101
- "eslint-plugin-react-hooks": "^4.6.0",
102
- "firebase": "^10.9.0",
91
+ "firebase": "^10.12.2",
103
92
  "jest": "^29.7.0",
104
93
  "npm-run-all": "^4.1.5",
105
- "ts-jest": "^29.1.2",
94
+ "ts-jest": "^29.1.5",
106
95
  "ts-node": "^10.9.2",
107
- "tsd": "^0.30.7",
108
- "typescript": "^5.4.2",
109
- "vite": "^5.1.6"
96
+ "tsd": "^0.31.1",
97
+ "typescript": "^5.5.3",
98
+ "vite": "^5.3.2"
110
99
  },
111
100
  "files": [
112
101
  "dist",
113
- "src"
102
+ "src",
103
+ "tailwind.config.js"
114
104
  ],
115
- "gitHead": "6d3cbe74b9d5ac0fbd7ee9110a92d0188a252f02",
105
+ "gitHead": "e41e7401fda1929c44300ada0b993e5b0703b7a1",
116
106
  "publishConfig": {
117
107
  "access": "public"
118
108
  }
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
- import { cn } from "../util";
2
+ import { cls } from "../util";
3
3
 
4
4
  export interface AlertProps {
5
5
  children: React.ReactNode;
@@ -52,7 +52,7 @@ export const Alert: React.FC<AlertProps> = ({
52
52
  return (
53
53
  <div
54
54
  style={style}
55
- className={cn(
55
+ className={cls(
56
56
  getSizeClasses(size),
57
57
  "w-full",
58
58
  "font-medium",
@@ -2,7 +2,8 @@ import React from "react";
2
2
 
3
3
  import { paperMixin } from "../styles";
4
4
  import { Collapse } from "./Collapse";
5
- import { cn, useOutsideAlerter } from "../util";
5
+ import { cls } from "../util";
6
+ import { useOutsideAlerter } from "../hooks";
6
7
 
7
8
  export type AutocompleteProps = {
8
9
  children: React.ReactNode;
@@ -49,14 +50,14 @@ export function Autocomplete({
49
50
  return <Collapse
50
51
  in={open}
51
52
  duration={50}
52
- className={cn(
53
+ className={cls(
53
54
  "absolute top-full left-0 right-0 overflow-visible",
54
55
  open ? "shadow" : "",
55
56
  "my-2",
56
57
  "z-20",
57
58
  "w-full")}>
58
59
  <div ref={autocompleteRef}
59
- className={cn(
60
+ className={cls(
60
61
  open ? paperMixin : "",
61
62
  "bg-slate-50 dark:bg-slate-900 py-2"
62
63
  )}>
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { cn } from "../util";
2
+ import { cls } from "../util";
3
3
  import { focusedMixin } from "../styles";
4
4
 
5
5
  export interface AvatarProps {
@@ -7,6 +7,7 @@ export interface AvatarProps {
7
7
  alt?: string;
8
8
  children?: React.ReactNode;
9
9
  className?: string;
10
+ outerClassName?: string;
10
11
  style?: React.CSSProperties;
11
12
  }
12
13
 
@@ -17,6 +18,7 @@ const AvatarInner: React.ForwardRefRenderFunction<HTMLButtonElement, AvatarProps
17
18
  children,
18
19
  className,
19
20
  style,
21
+ outerClassName,
20
22
  ...props
21
23
  }, ref) => {
22
24
 
@@ -25,13 +27,14 @@ const AvatarInner: React.ForwardRefRenderFunction<HTMLButtonElement, AvatarProps
25
27
  ref={ref}
26
28
  style={style}
27
29
  {...props}
28
- className={cn("rounded-full flex items-center justify-center overflow-hidden",
30
+ className={cls("rounded-full flex items-center justify-center overflow-hidden",
29
31
  focusedMixin,
30
32
  "p-1 hover:bg-slate-200 hover:dark:bg-slate-700 w-12 h-12",
33
+ outerClassName
31
34
  )}>
32
35
  {src
33
36
  ? (
34
- <img className={cn(
37
+ <img className={cls(
35
38
  "bg-slate-100 dark:bg-slate-800",
36
39
  "w-full h-full object-cover rounded-full",
37
40
  className)}
@@ -40,7 +43,7 @@ const AvatarInner: React.ForwardRefRenderFunction<HTMLButtonElement, AvatarProps
40
43
  )
41
44
  : (
42
45
  <span
43
- className={cn(
46
+ className={cls(
44
47
  "bg-slate-100 dark:bg-slate-800",
45
48
  "flex items-center justify-center",
46
49
  "w-full h-full py-1.5 text-lg font-medium text-slate-900 dark:text-white rounded-full",
@@ -27,7 +27,7 @@ export const Badge: React.FC<BadgeProps> = ({
27
27
  children
28
28
  }) => {
29
29
  return (
30
- <div className="relative inline-block">
30
+ <div className="relative inline-block w-fit">
31
31
  {children}
32
32
  <span
33
33
  className={`absolute top-0.5 right-0.5 transform translate-x-1/2 -translate-y-1/2 rounded-full
@@ -1,11 +1,11 @@
1
1
  import React from "react";
2
- import { cn } from "../util";
2
+ import { cls } from "../util";
3
3
 
4
4
  export type BooleanSwitchProps = {
5
5
  value: boolean | null;
6
6
  className?: string;
7
7
  disabled?: boolean;
8
- size?: "small" | "medium";
8
+ size?: "small" | "medium" | "large";
9
9
  } & ({
10
10
  allowIndeterminate: true;
11
11
  onValueChange?: (newValue: boolean | null) => void;
@@ -39,7 +39,7 @@ export const BooleanSwitch = React.forwardRef(function BooleanSwitch({
39
39
  onValueChange?.(!value);
40
40
  }
41
41
  }}
42
- className={cn(
42
+ className={cls(
43
43
  size === "small" ? "w-[38px] h-[22px] min-w-[38px] min-h-[22px]" : "w-[42px] h-[26px] min-w-[42px] min-h-[26px]",
44
44
  "outline-none rounded-full relative shadow-sm",
45
45
  value ? (disabled
@@ -51,13 +51,13 @@ export const BooleanSwitch = React.forwardRef(function BooleanSwitch({
51
51
  >
52
52
  {allowIndeterminate && (value === null || value === undefined) && <div
53
53
  key={"knob"}
54
- className={cn(
54
+ className={cls(
55
55
  "block rounded-full transition-transform duration-100 transform will-change-auto",
56
56
  disabled ? "bg-slate-400 dark:bg-slate-600" : "bg-slate-400 dark:bg-slate-600",
57
57
  {
58
- "w-[21px] h-[10px]": size === "medium",
58
+ "w-[21px] h-[10px]": size === "medium" || size === "large",
59
59
  "w-[19px] h-[8px]": size === "small",
60
- "translate-x-[10px]": size === "medium",
60
+ "translate-x-[10px]": size === "medium" || size === "large",
61
61
  "translate-x-[9px]": size === "small"
62
62
  }
63
63
  )}
@@ -65,13 +65,13 @@ export const BooleanSwitch = React.forwardRef(function BooleanSwitch({
65
65
 
66
66
  {!(allowIndeterminate && (value === null || value === undefined)) && <div
67
67
  key={"knob"}
68
- className={cn(
68
+ className={cls(
69
69
  "block rounded-full transition-transform duration-100 transform will-change-auto",
70
70
  disabled ? "bg-slate-300 dark:bg-slate-700" : (value ? "bg-white" : "bg-slate-600 dark:bg-slate-400"),
71
71
  {
72
- "w-[21px] h-[21px]": size === "medium",
72
+ "w-[21px] h-[21px]": size === "medium" || size === "large",
73
73
  "w-[19px] h-[19px]": size === "small",
74
- [value ? "translate-x-[19px]" : "translate-x-[3px]"]: size === "medium",
74
+ [value ? "translate-x-[19px]" : "translate-x-[3px]"]: size === "medium" || size === "large",
75
75
  [value ? "translate-x-[17px]" : "translate-x-[2px]"]: size === "small"
76
76
  }
77
77
  )}
@@ -6,7 +6,7 @@ import {
6
6
  focusedClasses
7
7
  } from "../styles";
8
8
  import { BooleanSwitch, BooleanSwitchProps } from "./BooleanSwitch";
9
- import { cn } from "../util";
9
+ import { cls } from "../util";
10
10
 
11
11
  export type BooleanSwitchWithLabelProps = BooleanSwitchProps & {
12
12
  position?: "start" | "end",
@@ -53,14 +53,14 @@ export const BooleanSwitchWithLabel = function BooleanSwitchWithLabel({
53
53
  onFocus={onFocus}
54
54
  onBlur={onBlur}
55
55
  tabIndex={-1}
56
- className={cn(
56
+ className={cls(
57
57
  !invisible && fieldBackgroundMixin,
58
58
  !invisible && (disabled ? fieldBackgroundDisabledMixin : fieldBackgroundHoverMixin),
59
59
  disabled ? "cursor-default" : "cursor-pointer",
60
- "rounded-md relative max-w-full justify-between w-full box-border relative inline-flex items-center",
60
+ "rounded-md max-w-full justify-between w-full box-border relative inline-flex items-center",
61
61
  !invisible && focus && !disabled ? focusedClasses : "",
62
62
  error ? "text-red-500 dark:text-red-600" : (focus && !disabled ? "text-primary" : (!disabled ? "text-text-primary dark:text-text-primary-dark" : "text-text-secondary dark:text-text-secondary-dark")),
63
- size === "small" ? "min-h-[40px]" : "min-h-[64px]",
63
+ size === "small" ? "min-h-[40px]" : (size === "medium" ? "min-h-[48px]" : "min-h-[64px]"),
64
64
  size === "small" ? "pl-2" : "pl-4",
65
65
  size === "small" ? "pr-4" : "pr-6",
66
66
  position === "end" ? "flex-row-reverse" : "flex-row"
@@ -86,7 +86,7 @@ export const BooleanSwitchWithLabel = function BooleanSwitchWithLabel({
86
86
  {...props}
87
87
  />
88
88
 
89
- <div className={cn(
89
+ <div className={cls(
90
90
  "flex-grow",
91
91
  position === "end" ? "mr-4" : "ml-4",
92
92
  size === "small" ? "text-sm" : "text-base"
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
2
 
3
3
  import { focusedMixin } from "../styles";
4
- import { cn } from "../util";
4
+ import { cls } from "../util";
5
5
 
6
6
  export type ButtonProps<P extends React.ElementType> =
7
7
  Omit<(P extends "button" ? React.ButtonHTMLAttributes<HTMLButtonElement> : React.ComponentProps<P>), "onClick">
@@ -32,9 +32,9 @@ const ButtonInner = React.forwardRef<
32
32
  }: ButtonProps<any>, ref) => {
33
33
 
34
34
  const baseClasses =
35
- "h-fit rounded-md uppercase inline-flex items-center justify-center p-2 px-4 text-sm font-medium focus:outline-none transition ease-in-out duration-150 gap-2";
35
+ "h-fit rounded-md uppercase whitespace-nowrap inline-flex items-center justify-center p-2 px-4 text-sm font-medium focus:outline-none transition ease-in-out duration-150 gap-2";
36
36
 
37
- const buttonClasses = cn({
37
+ const buttonClasses = cls({
38
38
  "w-full": fullWidth,
39
39
  "w-fit": !fullWidth,
40
40
  // Filled Variants
@@ -50,7 +50,7 @@ const ButtonInner = React.forwardRef<
50
50
  // Outlined Variants
51
51
  "border border-primary text-primary hover:bg-primary-bg": variant === "outlined" && color === "primary" && !disabled,
52
52
  "border border-secondary text-secondary hover:bg-secondary-bg": variant === "outlined" && color === "secondary" && !disabled,
53
- "border border-red-500 text-red-500 hover:bg-red-500": variant === "outlined" && color === "error" && !disabled,
53
+ "border border-red-500 text-red-500 hover:bg-red-500 hover:text-white": variant === "outlined" && color === "error" && !disabled,
54
54
  "border border-slate-400 text-text-primary dark:text-text-primary-dark hover:bg-slate-200": variant === "outlined" && color === "text" && !disabled,
55
55
  // Disabled states for all variants
56
56
  "border border-transparent opacity-50": variant === "text" && disabled,
@@ -58,7 +58,7 @@ const ButtonInner = React.forwardRef<
58
58
  "border border-gray-500 bg-gray-500 opacity-50": variant === "filled" && disabled,
59
59
  });
60
60
 
61
- const sizeClasses = cn(
61
+ const sizeClasses = cls(
62
62
  {
63
63
  "py-1 px-2": size === "small",
64
64
  "py-2 px-4": size === "medium",
@@ -73,7 +73,7 @@ const ButtonInner = React.forwardRef<
73
73
  <Component
74
74
  ref={ref}
75
75
  onClick={props.onClick}
76
- className={cn(focusedMixin, startIcon ? "pl-3" : "", baseClasses, buttonClasses, sizeClasses, className)}
76
+ className={cls(focusedMixin, startIcon ? "pl-3" : "", baseClasses, buttonClasses, sizeClasses, className)}
77
77
  {...(props as React.ComponentPropsWithRef<any>)}>
78
78
  {startIcon}
79
79
  {children}
@@ -85,7 +85,7 @@ const ButtonInner = React.forwardRef<
85
85
  <button ref={ref as any}
86
86
  type={props.type ?? "button"}
87
87
  onClick={props.onClick}
88
- className={cn(focusedMixin, startIcon ? "pl-3" : "", baseClasses, buttonClasses, sizeClasses, className)}
88
+ className={cls(focusedMixin, startIcon ? "pl-3" : "", baseClasses, buttonClasses, sizeClasses, className)}
89
89
  disabled={disabled}
90
90
  {...props as React.ButtonHTMLAttributes<HTMLButtonElement>}>
91
91
  {startIcon}
@@ -1,6 +1,6 @@
1
1
  import React, { useCallback } from "react";
2
2
  import { cardClickableMixin, cardMixin, focusedMixin } from "../styles";
3
- import { cn } from "../util";
3
+ import { cls } from "../util";
4
4
 
5
5
  type CardProps = {
6
6
  children: React.ReactNode;
@@ -29,7 +29,7 @@ const Card = React.forwardRef<HTMLDivElement, CardProps>(({
29
29
  role={onClick ? "button" : undefined}
30
30
  tabIndex={onClick ? 0 : undefined}
31
31
  onClick={onClick}
32
- className={cn(cardMixin, onClick && focusedMixin, onClick && cardClickableMixin, className)}
32
+ className={cls(cardMixin, onClick && focusedMixin, onClick && cardClickableMixin, className)}
33
33
  style={style}
34
34
  {...props}>
35
35
  {children}
@@ -1,24 +1,34 @@
1
1
  import React from "react";
2
2
  import { Container } from "./Container";
3
- import { cn } from "../util";
3
+ import { cls } from "../util";
4
4
 
5
- export function CenteredView({
6
- children,
7
- maxWidth,
8
- className,
9
- fullScreen
10
- }: {
5
+ export type CenteredViewProps = {
11
6
  children: React.ReactNode;
12
7
  maxWidth?: "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "3xl" | "4xl" | "5xl" | "6xl" | "7xl";
8
+ outerClassName?: string;
13
9
  className?: string;
14
10
  fullScreen?: boolean;
15
- }) {
11
+ };
16
12
 
17
- return <div className={cn("flex flex-col flex-grow", fullScreen ? "h-screen" : "h-full")}>
18
- <Container className={cn("m-auto", className)}
19
- maxWidth={maxWidth}>
20
- {children}
21
- </Container>
22
- </div>
13
+ export const CenteredView = React.forwardRef<HTMLDivElement, CenteredViewProps>(({
14
+ children,
15
+ maxWidth,
16
+ outerClassName,
17
+ className,
18
+ fullScreen,
19
+ ...rest
20
+ }, ref) => { // Notice how the ref is now received as the second argument
23
21
 
24
- }
22
+ return (
23
+ <div ref={ref}
24
+ className={cls("flex flex-col flex-grow", fullScreen ? "h-screen" : "h-full", outerClassName)}
25
+ {...rest}>
26
+ <Container className={cls("m-auto", className)} maxWidth={maxWidth}>
27
+ {children}
28
+ </Container>
29
+ </div>
30
+ );
31
+
32
+ });
33
+
34
+ CenteredView.displayName = "CenteredView";
@@ -2,13 +2,15 @@ import React from "react";
2
2
  import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
3
3
 
4
4
  import { Icon } from "../icons";
5
- import { cn } from "../util";
5
+ import { cls } from "../util";
6
6
 
7
- interface CheckboxProps {
7
+ export interface CheckboxProps {
8
8
  checked: boolean;
9
+ id?: string;
9
10
  disabled?: boolean;
10
11
  indeterminate?: boolean;
11
12
  onCheckedChange?: (checked: boolean) => void;
13
+ padding?: boolean;
12
14
  size?: "tiny" | "small" | "medium" | "large";
13
15
  color?: "primary" | "secondary";
14
16
  }
@@ -21,11 +23,17 @@ const sizeClasses = {
21
23
  };
22
24
 
23
25
  const outerSizeClasses = {
24
- medium: "w-10 h-10 p-2",
25
- small: "w-8 h-8 p-2",
26
- large: "w-12 h-12 p-2",
26
+ medium: "w-10 h-10",
27
+ small: "w-8 h-8",
28
+ large: "w-12 h-12 ",
27
29
  tiny: "w-6 h-6"
28
30
  }
31
+ const paddingClasses = {
32
+ medium: "p-2",
33
+ small: "p-2",
34
+ large: "p-2",
35
+ tiny: ""
36
+ }
29
37
 
30
38
  const colorClasses = {
31
39
  primary: "bg-primary",
@@ -33,8 +41,10 @@ const colorClasses = {
33
41
  }
34
42
 
35
43
  export const Checkbox = ({
44
+ id,
36
45
  checked,
37
46
  indeterminate = false,
47
+ padding = true,
38
48
  disabled,
39
49
  size = "medium",
40
50
  onCheckedChange,
@@ -51,19 +61,21 @@ export const Checkbox = ({
51
61
  ? 14
52
62
  : 24;
53
63
  return (
54
- <div className={cn(
55
- outerSizeClasses[size],
56
- "inline-flex items-center justify-center text-sm font-medium focus:outline-none transition-colors ease-in-out duration-150",
57
- onCheckedChange ? "rounded-full hover:bg-slate-200 hover:bg-opacity-75 dark:hover:bg-slate-700 dark:hover:bg-opacity-75" : "",
58
- onCheckedChange ? "cursor-pointer" : "cursor-default"
59
- )}>
60
- <CheckboxPrimitive.Root
61
- asChild
62
- checked={indeterminate || isChecked}
63
- disabled={disabled}
64
- onCheckedChange={disabled ? undefined : onCheckedChange}>
64
+ <CheckboxPrimitive.Root
65
+ id={id}
66
+ checked={indeterminate || isChecked}
67
+ disabled={disabled}
68
+ onCheckedChange={disabled ? undefined : onCheckedChange}>
69
+
70
+ <div className={cls(
71
+ padding ? paddingClasses[size] : "",
72
+ outerSizeClasses[size],
73
+ "inline-flex items-center justify-center text-sm font-medium focus:outline-none transition-colors ease-in-out duration-150",
74
+ onCheckedChange ? "rounded-full hover:bg-slate-200 hover:bg-opacity-75 dark:hover:bg-slate-700 dark:hover:bg-opacity-75" : "",
75
+ onCheckedChange ? "cursor-pointer" : "cursor-default"
76
+ )}>
65
77
  <div
66
- className={cn(
78
+ className={cls(
67
79
  "border-2 relative transition-colors ease-in-out duration-150",
68
80
  sizeClasses[size],
69
81
  disabled
@@ -84,12 +96,7 @@ export const Checkbox = ({
84
96
  )}
85
97
  </CheckboxPrimitive.Indicator>
86
98
  </div>
87
- </CheckboxPrimitive.Root>
88
- {/*{indeterminate && (*/}
89
- {/* <div >*/}
90
- {/* YO*/}
91
- {/* </div>*/}
92
- {/*)}*/}
93
- </div>
99
+ </div>
100
+ </CheckboxPrimitive.Root>
94
101
  );
95
102
  };
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { CHIP_COLORS, cn, getColorSchemeForKey } from "../util";
2
+ import { CHIP_COLORS, cls, getColorSchemeForKey } from "../util";
3
3
 
4
4
  export type ChipColorScheme = {
5
5
  color: string;
@@ -42,7 +42,7 @@ export function Chip({
42
42
  const usedColorScheme = typeof colorScheme === "string" ? getColorSchemeForKey(colorScheme) : colorScheme;
43
43
  return (
44
44
  <div
45
- className={cn("rounded-lg w-fit h-fit font-regular inline-flex gap-1",
45
+ className={cls("rounded-lg w-fit h-fit font-regular inline-flex gap-1",
46
46
  "text-ellipsis",
47
47
  onClick ? "cursor-pointer hover:bg-slate-300 hover:dark:bg-slate-700" : "",
48
48
  sizeClassNames[size],
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { cn } from "../util";
2
+ import { cls } from "../util";
3
3
 
4
4
  export type CircularProgressProps = {
5
5
  size?: "small" | "medium" | "large",
@@ -31,7 +31,7 @@ export function CircularProgress({
31
31
 
32
32
  return (
33
33
  <div
34
- className={cn(
34
+ className={cls(
35
35
  sizeClasses,
36
36
  borderClasses,
37
37
  "inline-block animate-spin rounded-full border-solid border-current border-r-transparent align-[-0.125em] motion-reduce:animate-[spin_1.5s_linear_infinite]",
@@ -1,7 +1,8 @@
1
1
  import React from "react";
2
2
  import * as Collapsible from "@radix-ui/react-collapsible";
3
3
 
4
- import { cn, useInjectStyles } from "../util";
4
+ import { cls } from "../util";
5
+ import { useInjectStyles } from "../hooks";
5
6
 
6
7
  interface CollapseProps {
7
8
  children?: React.ReactNode;
@@ -53,7 +54,7 @@ export function Collapse({
53
54
  className={className}>
54
55
 
55
56
  <Collapsible.Content
56
- className={cn(`CollapseContent-${duration}`)}
57
+ className={cls(`CollapseContent-${duration}`)}
57
58
  >
58
59
  {children}
59
60
  </Collapsible.Content>