@stackframe/stack-ui 2.5.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.
Files changed (101) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/LICENSE +7 -0
  3. package/dist/components/ui/accordion.d.ts +7 -0
  4. package/dist/components/ui/accordion.js +14 -0
  5. package/dist/components/ui/alert.d.ts +8 -0
  6. package/dist/components/ui/alert.js +23 -0
  7. package/dist/components/ui/aspect-ratio.d.ts +4 -0
  8. package/dist/components/ui/aspect-ratio.js +4 -0
  9. package/dist/components/ui/avatar.d.ts +6 -0
  10. package/dist/components/ui/avatar.js +12 -0
  11. package/dist/components/ui/badge.d.ts +9 -0
  12. package/dist/components/ui/badge.js +22 -0
  13. package/dist/components/ui/breadcrumb.d.ts +19 -0
  14. package/dist/components/ui/breadcrumb.js +23 -0
  15. package/dist/components/ui/button.d.ts +15 -0
  16. package/dist/components/ui/button.js +44 -0
  17. package/dist/components/ui/calendar.d.ts +8 -0
  18. package/dist/components/ui/calendar.js +40 -0
  19. package/dist/components/ui/card.d.ts +9 -0
  20. package/dist/components/ui/card.js +18 -0
  21. package/dist/components/ui/checkbox.d.ts +4 -0
  22. package/dist/components/ui/checkbox.js +9 -0
  23. package/dist/components/ui/collapsible.d.ts +6 -0
  24. package/dist/components/ui/collapsible.js +6 -0
  25. package/dist/components/ui/command.d.ts +82 -0
  26. package/dist/components/ui/command.js +29 -0
  27. package/dist/components/ui/container.d.ts +6 -0
  28. package/dist/components/ui/container.js +19 -0
  29. package/dist/components/ui/context-menu.d.ts +27 -0
  30. package/dist/components/ui/context-menu.js +34 -0
  31. package/dist/components/ui/dialog.d.ts +20 -0
  32. package/dist/components/ui/dialog.js +24 -0
  33. package/dist/components/ui/dropdown-menu.d.ts +27 -0
  34. package/dist/components/ui/dropdown-menu.js +36 -0
  35. package/dist/components/ui/form.d.ts +23 -0
  36. package/dist/components/ui/form.js +63 -0
  37. package/dist/components/ui/hover-card.d.ts +6 -0
  38. package/dist/components/ui/hover-card.js +10 -0
  39. package/dist/components/ui/inline-code.d.ts +3 -0
  40. package/dist/components/ui/inline-code.js +29 -0
  41. package/dist/components/ui/input-otp.d.ts +32 -0
  42. package/dist/components/ui/input-otp.js +19 -0
  43. package/dist/components/ui/input.d.ts +9 -0
  44. package/dist/components/ui/input.js +23 -0
  45. package/dist/components/ui/label.d.ts +6 -0
  46. package/dist/components/ui/label.js +12 -0
  47. package/dist/components/ui/link.d.ts +12 -0
  48. package/dist/components/ui/link.js +11 -0
  49. package/dist/components/ui/menubar.d.ts +31 -0
  50. package/dist/components/ui/menubar.js +36 -0
  51. package/dist/components/ui/navigation-menu.d.ts +12 -0
  52. package/dist/components/ui/navigation-menu.js +24 -0
  53. package/dist/components/ui/password-input.d.ts +4 -0
  54. package/dist/components/ui/password-input.js +13 -0
  55. package/dist/components/ui/popover.d.ts +7 -0
  56. package/dist/components/ui/popover.js +11 -0
  57. package/dist/components/ui/progress.d.ts +4 -0
  58. package/dist/components/ui/progress.js +8 -0
  59. package/dist/components/ui/radio-group.d.ts +5 -0
  60. package/dist/components/ui/radio-group.js +15 -0
  61. package/dist/components/ui/scroll-area.d.ts +5 -0
  62. package/dist/components/ui/scroll-area.js +12 -0
  63. package/dist/components/ui/select.d.ts +13 -0
  64. package/dist/components/ui/select.js +27 -0
  65. package/dist/components/ui/separator.d.ts +4 -0
  66. package/dist/components/ui/separator.js +8 -0
  67. package/dist/components/ui/sheet.d.ts +26 -0
  68. package/dist/components/ui/sheet.js +37 -0
  69. package/dist/components/ui/skeleton.d.ts +5 -0
  70. package/dist/components/ui/skeleton.js +38 -0
  71. package/dist/components/ui/slider.d.ts +4 -0
  72. package/dist/components/ui/slider.js +8 -0
  73. package/dist/components/ui/spinner.d.ts +2 -0
  74. package/dist/components/ui/spinner.js +7 -0
  75. package/dist/components/ui/switch.d.ts +11 -0
  76. package/dist/components/ui/switch.js +25 -0
  77. package/dist/components/ui/table.d.ts +10 -0
  78. package/dist/components/ui/table.js +20 -0
  79. package/dist/components/ui/tabs.d.ts +7 -0
  80. package/dist/components/ui/tabs.js +13 -0
  81. package/dist/components/ui/textarea.d.ts +5 -0
  82. package/dist/components/ui/textarea.js +8 -0
  83. package/dist/components/ui/toast.d.ts +15 -0
  84. package/dist/components/ui/toast.js +34 -0
  85. package/dist/components/ui/toaster.d.ts +1 -0
  86. package/dist/components/ui/toaster.js +10 -0
  87. package/dist/components/ui/toggle-group.d.ts +12 -0
  88. package/dist/components/ui/toggle-group.js +21 -0
  89. package/dist/components/ui/toggle.d.ts +12 -0
  90. package/dist/components/ui/toggle.js +26 -0
  91. package/dist/components/ui/tooltip.d.ts +7 -0
  92. package/dist/components/ui/tooltip.js +12 -0
  93. package/dist/components/ui/typography.d.ts +10 -0
  94. package/dist/components/ui/typography.js +33 -0
  95. package/dist/components/ui/use-toast.d.ts +44 -0
  96. package/dist/components/ui/use-toast.js +131 -0
  97. package/dist/index.d.ts +47 -0
  98. package/dist/index.js +47 -0
  99. package/dist/lib/utils.d.ts +2 -0
  100. package/dist/lib/utils.js +5 -0
  101. package/package.json +83 -0
@@ -0,0 +1,44 @@
1
+ import * as React from "react";
2
+ import type { ToastActionElement, ToastProps } from "./toast";
3
+ type ToasterToast = ToastProps & {
4
+ id: string;
5
+ title?: React.ReactNode;
6
+ description?: React.ReactNode;
7
+ action?: ToastActionElement;
8
+ };
9
+ declare const actionTypes: {
10
+ readonly ADD_TOAST: "ADD_TOAST";
11
+ readonly UPDATE_TOAST: "UPDATE_TOAST";
12
+ readonly DISMISS_TOAST: "DISMISS_TOAST";
13
+ readonly REMOVE_TOAST: "REMOVE_TOAST";
14
+ };
15
+ type ActionType = typeof actionTypes;
16
+ type Action = {
17
+ type: ActionType["ADD_TOAST"];
18
+ toast: ToasterToast;
19
+ } | {
20
+ type: ActionType["UPDATE_TOAST"];
21
+ toast: Partial<ToasterToast>;
22
+ } | {
23
+ type: ActionType["DISMISS_TOAST"];
24
+ toastId?: ToasterToast["id"];
25
+ } | {
26
+ type: ActionType["REMOVE_TOAST"];
27
+ toastId?: ToasterToast["id"];
28
+ };
29
+ interface State {
30
+ toasts: ToasterToast[];
31
+ }
32
+ export declare const reducer: (state: State, action: Action) => State;
33
+ type Toast = Omit<ToasterToast, "id">;
34
+ declare function toast({ ...props }: Toast): {
35
+ id: string;
36
+ dismiss: () => void;
37
+ update: (props: ToasterToast) => void;
38
+ };
39
+ declare function useToast(): {
40
+ toast: typeof toast;
41
+ dismiss: (toastId?: string) => void;
42
+ toasts: ToasterToast[];
43
+ };
44
+ export { useToast, toast };
@@ -0,0 +1,131 @@
1
+ "use client";
2
+ // Inspired by react-hot-toast library
3
+ import * as React from "react";
4
+ const TOAST_LIMIT = 1;
5
+ const TOAST_REMOVE_DELAY = 1000000;
6
+ const actionTypes = {
7
+ ADD_TOAST: "ADD_TOAST",
8
+ UPDATE_TOAST: "UPDATE_TOAST",
9
+ DISMISS_TOAST: "DISMISS_TOAST",
10
+ REMOVE_TOAST: "REMOVE_TOAST",
11
+ };
12
+ let count = 0;
13
+ function genId() {
14
+ count = (count + 1) % Number.MAX_SAFE_INTEGER;
15
+ return count.toString();
16
+ }
17
+ const toastTimeouts = new Map();
18
+ const addToRemoveQueue = (toastId) => {
19
+ if (toastTimeouts.has(toastId)) {
20
+ return;
21
+ }
22
+ const timeout = setTimeout(() => {
23
+ toastTimeouts.delete(toastId);
24
+ dispatch({
25
+ type: "REMOVE_TOAST",
26
+ toastId: toastId,
27
+ });
28
+ }, TOAST_REMOVE_DELAY);
29
+ toastTimeouts.set(toastId, timeout);
30
+ };
31
+ export const reducer = (state, action) => {
32
+ switch (action.type) {
33
+ case "ADD_TOAST": {
34
+ return {
35
+ ...state,
36
+ toasts: [action.toast, ...state.toasts].slice(0, TOAST_LIMIT),
37
+ };
38
+ }
39
+ case "UPDATE_TOAST": {
40
+ return {
41
+ ...state,
42
+ toasts: state.toasts.map((t) => t.id === action.toast.id ? { ...t, ...action.toast } : t),
43
+ };
44
+ }
45
+ case "DISMISS_TOAST": {
46
+ const { toastId } = action;
47
+ // ! Side effects ! - This could be extracted into a dismissToast() action,
48
+ // but I'll keep it here for simplicity
49
+ if (toastId) {
50
+ addToRemoveQueue(toastId);
51
+ }
52
+ else {
53
+ state.toasts.forEach((toast) => {
54
+ addToRemoveQueue(toast.id);
55
+ });
56
+ }
57
+ return {
58
+ ...state,
59
+ toasts: state.toasts.map((t) => t.id === toastId || toastId === undefined
60
+ ? {
61
+ ...t,
62
+ open: false,
63
+ }
64
+ : t),
65
+ };
66
+ }
67
+ case "REMOVE_TOAST": {
68
+ if (action.toastId === undefined) {
69
+ return {
70
+ ...state,
71
+ toasts: [],
72
+ };
73
+ }
74
+ return {
75
+ ...state,
76
+ toasts: state.toasts.filter((t) => t.id !== action.toastId),
77
+ };
78
+ }
79
+ }
80
+ };
81
+ const listeners = [];
82
+ let memoryState = { toasts: [] };
83
+ function dispatch(action) {
84
+ memoryState = reducer(memoryState, action);
85
+ listeners.forEach((listener) => {
86
+ listener(memoryState);
87
+ });
88
+ }
89
+ function toast({ ...props }) {
90
+ const id = genId();
91
+ const update = (props) => dispatch({
92
+ type: "UPDATE_TOAST",
93
+ toast: { ...props, id },
94
+ });
95
+ const dismiss = () => dispatch({ type: "DISMISS_TOAST", toastId: id });
96
+ dispatch({
97
+ type: "ADD_TOAST",
98
+ toast: {
99
+ ...props,
100
+ id,
101
+ open: true,
102
+ onOpenChange: (open) => {
103
+ if (!open)
104
+ dismiss();
105
+ },
106
+ },
107
+ });
108
+ return {
109
+ id: id,
110
+ dismiss,
111
+ update,
112
+ };
113
+ }
114
+ function useToast() {
115
+ const [state, setState] = React.useState(memoryState);
116
+ React.useEffect(() => {
117
+ listeners.push(setState);
118
+ return () => {
119
+ const index = listeners.indexOf(setState);
120
+ if (index > -1) {
121
+ listeners.splice(index, 1);
122
+ }
123
+ };
124
+ }, [state]);
125
+ return {
126
+ ...state,
127
+ toast,
128
+ dismiss: (toastId) => dispatch({ type: "DISMISS_TOAST", toastId }),
129
+ };
130
+ }
131
+ export { useToast, toast };
@@ -0,0 +1,47 @@
1
+ export * from "./components/ui/accordion";
2
+ export * from "./components/ui/alert";
3
+ export * from "./components/ui/avatar";
4
+ export * from "./components/ui/aspect-ratio";
5
+ export * from "./components/ui/badge";
6
+ export * from "./components/ui/breadcrumb";
7
+ export * from "./components/ui/button";
8
+ export * from "./components/ui/calendar";
9
+ export * from "./components/ui/card";
10
+ export * from "./components/ui/checkbox";
11
+ export * from "./components/ui/collapsible";
12
+ export * from "./components/ui/command";
13
+ export * from "./components/ui/context-menu";
14
+ export * from "./components/ui/dropdown-menu";
15
+ export * from "./components/ui/form";
16
+ export * from "./components/ui/hover-card";
17
+ export * from "./components/ui/inline-code";
18
+ export * from "./components/ui/input-otp";
19
+ export * from "./components/ui/input";
20
+ export * from "./components/ui/label";
21
+ export * from "./components/ui/menubar";
22
+ export * from "./components/ui/navigation-menu";
23
+ export * from "./components/ui/popover";
24
+ export * from "./components/ui/progress";
25
+ export * from "./components/ui/progress";
26
+ export * from "./components/ui/radio-group";
27
+ export * from "./components/ui/scroll-area";
28
+ export * from "./components/ui/select";
29
+ export * from "./components/ui/separator";
30
+ export * from "./components/ui/sheet";
31
+ export * from "./components/ui/skeleton";
32
+ export * from "./components/ui/slider";
33
+ export * from "./components/ui/spinner";
34
+ export * from "./components/ui/switch";
35
+ export * from "./components/ui/table";
36
+ export * from "./components/ui/tabs";
37
+ export * from "./components/ui/textarea";
38
+ export * from "./components/ui/toast";
39
+ export * from "./components/ui/toaster";
40
+ export * from "./components/ui/toggle-group";
41
+ export * from "./components/ui/tooltip";
42
+ export * from "./components/ui/typography";
43
+ export * from "./components/ui/use-toast";
44
+ export * from "./components/ui/container";
45
+ export * from "./components/ui/password-input";
46
+ export * from "./components/ui/link";
47
+ export { cn } from "./lib/utils";
package/dist/index.js ADDED
@@ -0,0 +1,47 @@
1
+ export * from "./components/ui/accordion";
2
+ export * from "./components/ui/alert";
3
+ export * from "./components/ui/avatar";
4
+ export * from "./components/ui/aspect-ratio";
5
+ export * from "./components/ui/badge";
6
+ export * from "./components/ui/breadcrumb";
7
+ export * from "./components/ui/button";
8
+ export * from "./components/ui/calendar";
9
+ export * from "./components/ui/card";
10
+ export * from "./components/ui/checkbox";
11
+ export * from "./components/ui/collapsible";
12
+ export * from "./components/ui/command";
13
+ export * from "./components/ui/context-menu";
14
+ export * from "./components/ui/dropdown-menu";
15
+ export * from "./components/ui/form";
16
+ export * from "./components/ui/hover-card";
17
+ export * from "./components/ui/inline-code";
18
+ export * from "./components/ui/input-otp";
19
+ export * from "./components/ui/input";
20
+ export * from "./components/ui/label";
21
+ export * from "./components/ui/menubar";
22
+ export * from "./components/ui/navigation-menu";
23
+ export * from "./components/ui/popover";
24
+ export * from "./components/ui/progress";
25
+ export * from "./components/ui/progress";
26
+ export * from "./components/ui/radio-group";
27
+ export * from "./components/ui/scroll-area";
28
+ export * from "./components/ui/select";
29
+ export * from "./components/ui/separator";
30
+ export * from "./components/ui/sheet";
31
+ export * from "./components/ui/skeleton";
32
+ export * from "./components/ui/slider";
33
+ export * from "./components/ui/spinner";
34
+ export * from "./components/ui/switch";
35
+ export * from "./components/ui/table";
36
+ export * from "./components/ui/tabs";
37
+ export * from "./components/ui/textarea";
38
+ export * from "./components/ui/toast";
39
+ export * from "./components/ui/toaster";
40
+ export * from "./components/ui/toggle-group";
41
+ export * from "./components/ui/tooltip";
42
+ export * from "./components/ui/typography";
43
+ export * from "./components/ui/use-toast";
44
+ export * from "./components/ui/container";
45
+ export * from "./components/ui/password-input";
46
+ export * from "./components/ui/link";
47
+ export { cn } from "./lib/utils";
@@ -0,0 +1,2 @@
1
+ import { type ClassValue } from "clsx";
2
+ export declare function cn(...inputs: ClassValue[]): string;
@@ -0,0 +1,5 @@
1
+ import { clsx } from "clsx";
2
+ import { twMerge } from "tailwind-merge";
3
+ export function cn(...inputs) {
4
+ return twMerge(clsx(inputs));
5
+ }
package/package.json ADDED
@@ -0,0 +1,83 @@
1
+ {
2
+ "name": "@stackframe/stack-ui",
3
+ "version": "2.5.0",
4
+ "main": "./dist/index.js",
5
+ "types": "./dist/index.d.ts",
6
+ "files": [
7
+ "README.md",
8
+ "dist",
9
+ "CHANGELOG.md",
10
+ "LICENSE"
11
+ ],
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/index.d.ts",
15
+ "default": "./dist/index.js"
16
+ }
17
+ },
18
+ "peerDependencies": {
19
+ "react": ">=18.2",
20
+ "yup": "^1.4.0"
21
+ },
22
+ "peerDependenciesMeta": {
23
+ "react": {
24
+ "optional": true
25
+ },
26
+ "yup": {
27
+ "optional": true
28
+ }
29
+ },
30
+ "dependencies": {
31
+ "@radix-ui/react-accordion": "^1.1.2",
32
+ "@radix-ui/react-alert-dialog": "^1.0.5",
33
+ "@radix-ui/react-aspect-ratio": "^1.0.3",
34
+ "@radix-ui/react-avatar": "^1.0.4",
35
+ "@radix-ui/react-checkbox": "^1.0.4",
36
+ "@radix-ui/react-collapsible": "^1.0.3",
37
+ "@radix-ui/react-context-menu": "^2.1.5",
38
+ "@radix-ui/react-dialog": "^1.0.5",
39
+ "@radix-ui/react-dropdown-menu": "^2.0.6",
40
+ "@radix-ui/react-hover-card": "^1.0.7",
41
+ "@radix-ui/react-icons": "^1.3.0",
42
+ "@radix-ui/react-label": "^2.0.2",
43
+ "@radix-ui/react-menubar": "^1.0.4",
44
+ "@radix-ui/react-navigation-menu": "^1.1.4",
45
+ "@radix-ui/react-popover": "^1.0.7",
46
+ "@radix-ui/react-progress": "^1.0.3",
47
+ "@radix-ui/react-radio-group": "^1.1.3",
48
+ "@radix-ui/react-scroll-area": "^1.0.5",
49
+ "@radix-ui/react-select": "^2.0.0",
50
+ "@radix-ui/react-separator": "^1.0.3",
51
+ "@radix-ui/react-slider": "^1.1.2",
52
+ "@radix-ui/react-slot": "^1.0.2",
53
+ "@radix-ui/react-switch": "^1.0.3",
54
+ "@radix-ui/react-tabs": "^1.0.4",
55
+ "@radix-ui/react-toast": "^1.1.5",
56
+ "@radix-ui/react-toggle": "^1.0.3",
57
+ "@radix-ui/react-toggle-group": "^1.0.4",
58
+ "@radix-ui/react-tooltip": "^1.0.7",
59
+ "class-variance-authority": "^0.7.0",
60
+ "clsx": "^2.0.0",
61
+ "cmdk": "^1.0.0",
62
+ "input-otp": "^1.2.4",
63
+ "lucide-react": "^0.378.0",
64
+ "react-day-picker": "^8.10.1",
65
+ "react-hook-form": "^7.51.4",
66
+ "react-resizable-panels": "^2.0.19",
67
+ "tailwind-merge": "^2.3.0",
68
+ "@stackframe/stack-shared": "2.5.0"
69
+ },
70
+ "devDependencies": {
71
+ "@types/react": "^18.2.66",
72
+ "next": "^14.1.0",
73
+ "react": "^18.2.0",
74
+ "rimraf": "^5.0.5"
75
+ },
76
+ "scripts": {
77
+ "build": "tsc",
78
+ "typecheck": "tsc --noEmit",
79
+ "clean": "rimraf dist && rimraf node_modules",
80
+ "dev": "tsc -w --preserveWatchOutput --declarationMap",
81
+ "lint": "eslint --ext .tsx,.ts ."
82
+ }
83
+ }