@bearmenu/ui 0.7.1 → 0.8.2
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.
- package/dist/{chunk-4JOV7FXW.js → chunk-2DEIXTBN.js} +1 -1
- package/dist/{chunk-UUJVXN2O.js → chunk-66MAPLXS.js} +3 -1
- package/dist/{chunk-Y5D5LP4A.js → chunk-7BWTYWM3.js} +14 -3
- package/dist/{chunk-ZFNOCP6W.js → chunk-H3BV4VAG.js} +15 -1
- package/dist/{chunk-TL4YU2O5.js → chunk-UKBNQO6Q.js} +2 -2
- package/dist/{chunk-UX6SWAKH.js → chunk-UZ3PCIE5.js} +119 -28
- package/dist/{chunk-YLNYXPIH.js → chunk-VBA45GLP.js} +1 -1
- package/dist/{chunk-A5ONAJCE.js → chunk-VG3PND3D.js} +1 -1
- package/dist/{chunk-ZBBUKXM5.js → chunk-X3WMRKOW.js} +1 -1
- package/dist/{chunk-HCM6LKM5.js → chunk-XNA2INVQ.js} +2 -2
- package/dist/{chunk-AV777R4G.js → chunk-YYGB4G4Q.js} +1 -1
- package/dist/components/accordion.js +1 -1
- package/dist/components/alert-dialog.js +1 -1
- package/dist/components/alert.js +1 -1
- package/dist/components/avatar.d.ts +10 -1
- package/dist/components/avatar.js +41 -14
- package/dist/components/badge.d.ts +11 -2
- package/dist/components/badge.js +1 -1
- package/dist/components/breadcrumb.js +1 -1
- package/dist/components/button.d.ts +1 -1
- package/dist/components/button.js +1 -1
- package/dist/components/calendar.js +3 -3
- package/dist/components/card.js +1 -1
- package/dist/components/carousel.js +1 -1
- package/dist/components/circular-progress.js +1 -1
- package/dist/components/combobox.js +3 -3
- package/dist/components/command.js +1 -1
- package/dist/components/currency-input.js +2 -2
- package/dist/components/date-input.js +1 -1
- package/dist/components/description-list.js +1 -1
- package/dist/components/drawer.js +5 -1
- package/dist/components/dropdown-menu.js +1 -1
- package/dist/components/empty-state.js +2 -2
- package/dist/components/field.js +2 -2
- package/dist/components/filter-category-row.js +2 -2
- package/dist/components/form.js +1 -1
- package/dist/components/haptic-button.js +1 -1
- package/dist/components/input-group.js +1 -1
- package/dist/components/input.js +1 -1
- package/dist/components/item.js +1 -1
- package/dist/components/kbd.js +1 -1
- package/dist/components/label.js +1 -1
- package/dist/components/link-button.js +1 -1
- package/dist/components/multi-select-combobox.js +4 -4
- package/dist/components/pagination.js +1 -1
- package/dist/components/place-about-tab.d.ts +17 -1
- package/dist/components/place-about-tab.js +4 -4
- package/dist/components/place-card.js +2 -2
- package/dist/components/place-details-mobile.js +7 -7
- package/dist/components/place-schedule-week.js +2 -2
- package/dist/components/popover.js +1 -1
- package/dist/components/searchable-select.js +3 -3
- package/dist/components/select.js +2 -2
- package/dist/components/selection-bar.js +1 -1
- package/dist/components/sheet.d.ts +23 -0
- package/dist/components/sheet.js +51 -14
- package/dist/components/sliding-panels.js +5 -1
- package/dist/components/sonner.js +2 -2
- package/dist/components/stepper.js +4 -1
- package/dist/components/table.js +1 -1
- package/dist/components/tabs.js +1 -1
- package/dist/components/tag-group.js +1 -1
- package/dist/components/tag.js +1 -1
- package/dist/components/text.d.ts +18 -0
- package/dist/components/text.js +1 -1
- package/dist/components/toggle-group.js +1 -1
- package/dist/components/toggle.js +1 -1
- package/dist/lib/card-hover.d.ts +75 -0
- package/dist/lib/card-hover.js +18 -0
- package/package.json +1 -1
- package/src/components/accordion.tsx +1 -1
- package/src/components/avatar.stories.tsx +59 -26
- package/src/components/avatar.test.tsx +129 -0
- package/src/components/avatar.tsx +93 -37
- package/src/components/badge.tsx +15 -3
- package/src/components/breadcrumb.tsx +1 -1
- package/src/components/button.tsx +16 -1
- package/src/components/calendar.tsx +2 -2
- package/src/components/circular-progress.tsx +1 -1
- package/src/components/command.tsx +2 -2
- package/src/components/currency-input.tsx +1 -1
- package/src/components/description-list.tsx +1 -1
- package/src/components/drawer.tsx +5 -1
- package/src/components/dropdown-menu.tsx +1 -1
- package/src/components/field.tsx +1 -1
- package/src/components/input-group.tsx +1 -1
- package/src/components/input.tsx +1 -1
- package/src/components/item.tsx +1 -1
- package/src/components/kbd.tsx +1 -1
- package/src/components/label.tsx +1 -1
- package/src/components/place-about-tab.tsx +131 -18
- package/src/components/place-card.tsx +1 -1
- package/src/components/place-details-mobile.tsx +2 -2
- package/src/components/popover.tsx +9 -1
- package/src/components/select.tsx +2 -2
- package/src/components/selection-bar.tsx +1 -1
- package/src/components/sheet.tsx +72 -12
- package/src/components/sliding-panels.stories.tsx +70 -0
- package/src/components/sliding-panels.test.tsx +116 -0
- package/src/components/sliding-panels.tsx +14 -0
- package/src/components/sonner.tsx +2 -2
- package/src/components/stepper.tsx +4 -1
- package/src/components/table.tsx +1 -1
- package/src/components/tabs.tsx +1 -1
- package/src/components/tag-group.tsx +1 -1
- package/src/components/tag.tsx +1 -1
- package/src/components/text.test.tsx +37 -3
- package/src/components/text.tsx +32 -3
- package/src/components/toggle.tsx +1 -1
- package/src/globals.css +53 -11
- package/src/lib/card-hover.ts +87 -0
- package/dist/chunk-EBAMCZDW.js +0 -112
- package/dist/chunk-VQNDZVI7.js +0 -106
- package/dist/components/toast.d.ts +0 -18
- package/dist/components/toast.js +0 -3
- package/dist/components/toaster.d.ts +0 -5
- package/dist/components/toaster.js +0 -25
- package/dist/components/use-toast.d.ts +0 -42
- package/dist/components/use-toast.js +0 -2
- package/src/components/toast.stories.tsx +0 -63
- package/src/components/toast.tsx +0 -130
- package/src/components/toaster.tsx +0 -31
- package/src/components/use-toast.ts +0 -180
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
// Inspired by react-hot-toast library
|
|
4
|
-
import * as React from "react";
|
|
5
|
-
|
|
6
|
-
import type { ToastActionElement, ToastProps } from "./toast";
|
|
7
|
-
|
|
8
|
-
const TOAST_LIMIT = 1;
|
|
9
|
-
const TOAST_REMOVE_DELAY = 1000000;
|
|
10
|
-
|
|
11
|
-
type ToasterToast = ToastProps & {
|
|
12
|
-
id: string;
|
|
13
|
-
title?: React.ReactNode;
|
|
14
|
-
description?: React.ReactNode;
|
|
15
|
-
action?: ToastActionElement;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
let count = 0;
|
|
19
|
-
|
|
20
|
-
function genId() {
|
|
21
|
-
count = (count + 1) % Number.MAX_SAFE_INTEGER;
|
|
22
|
-
return count.toString();
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
type Action =
|
|
26
|
-
| {
|
|
27
|
-
type: "ADD_TOAST";
|
|
28
|
-
toast: ToasterToast;
|
|
29
|
-
}
|
|
30
|
-
| {
|
|
31
|
-
type: "UPDATE_TOAST";
|
|
32
|
-
toast: Partial<ToasterToast>;
|
|
33
|
-
}
|
|
34
|
-
| {
|
|
35
|
-
type: "DISMISS_TOAST";
|
|
36
|
-
toastId?: ToasterToast["id"];
|
|
37
|
-
}
|
|
38
|
-
| {
|
|
39
|
-
type: "REMOVE_TOAST";
|
|
40
|
-
toastId?: ToasterToast["id"];
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
interface State {
|
|
44
|
-
toasts: ToasterToast[];
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const toastTimeouts = new Map<string, ReturnType<typeof setTimeout>>();
|
|
48
|
-
|
|
49
|
-
const addToRemoveQueue = (toastId: string) => {
|
|
50
|
-
if (toastTimeouts.has(toastId)) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const timeout = setTimeout(() => {
|
|
55
|
-
toastTimeouts.delete(toastId);
|
|
56
|
-
dispatch({
|
|
57
|
-
type: "REMOVE_TOAST",
|
|
58
|
-
toastId: toastId,
|
|
59
|
-
});
|
|
60
|
-
}, TOAST_REMOVE_DELAY);
|
|
61
|
-
|
|
62
|
-
toastTimeouts.set(toastId, timeout);
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
export const reducer = (state: State, action: Action): State => {
|
|
66
|
-
switch (action.type) {
|
|
67
|
-
case "ADD_TOAST":
|
|
68
|
-
return {
|
|
69
|
-
...state,
|
|
70
|
-
toasts: [action.toast, ...state.toasts].slice(0, TOAST_LIMIT),
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
case "UPDATE_TOAST":
|
|
74
|
-
return {
|
|
75
|
-
...state,
|
|
76
|
-
toasts: state.toasts.map((t) => (t.id === action.toast.id ? { ...t, ...action.toast } : t)),
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
case "DISMISS_TOAST": {
|
|
80
|
-
const { toastId } = action;
|
|
81
|
-
|
|
82
|
-
// ! Side effects ! - This could be extracted into a dismissToast() action,
|
|
83
|
-
// but I'll keep it here for simplicity
|
|
84
|
-
if (toastId) {
|
|
85
|
-
addToRemoveQueue(toastId);
|
|
86
|
-
} else {
|
|
87
|
-
state.toasts.forEach((toast) => {
|
|
88
|
-
addToRemoveQueue(toast.id);
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
return {
|
|
93
|
-
...state,
|
|
94
|
-
toasts: state.toasts.map((t) =>
|
|
95
|
-
t.id === toastId || toastId === undefined
|
|
96
|
-
? {
|
|
97
|
-
...t,
|
|
98
|
-
open: false,
|
|
99
|
-
}
|
|
100
|
-
: t
|
|
101
|
-
),
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
case "REMOVE_TOAST":
|
|
105
|
-
if (action.toastId === undefined) {
|
|
106
|
-
return {
|
|
107
|
-
...state,
|
|
108
|
-
toasts: [],
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
return {
|
|
112
|
-
...state,
|
|
113
|
-
toasts: state.toasts.filter((t) => t.id !== action.toastId),
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
const listeners: Array<(state: State) => void> = [];
|
|
119
|
-
|
|
120
|
-
let memoryState: State = { toasts: [] };
|
|
121
|
-
|
|
122
|
-
function dispatch(action: Action) {
|
|
123
|
-
memoryState = reducer(memoryState, action);
|
|
124
|
-
listeners.forEach((listener) => {
|
|
125
|
-
listener(memoryState);
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
type Toast = Omit<ToasterToast, "id">;
|
|
130
|
-
|
|
131
|
-
function toast({ ...props }: Toast) {
|
|
132
|
-
const id = genId();
|
|
133
|
-
|
|
134
|
-
const update = (props: ToasterToast) =>
|
|
135
|
-
dispatch({
|
|
136
|
-
type: "UPDATE_TOAST",
|
|
137
|
-
toast: { ...props, id },
|
|
138
|
-
});
|
|
139
|
-
const dismiss = () => dispatch({ type: "DISMISS_TOAST", toastId: id });
|
|
140
|
-
|
|
141
|
-
dispatch({
|
|
142
|
-
type: "ADD_TOAST",
|
|
143
|
-
toast: {
|
|
144
|
-
...props,
|
|
145
|
-
id,
|
|
146
|
-
open: true,
|
|
147
|
-
onOpenChange: (open) => {
|
|
148
|
-
if (!open) dismiss();
|
|
149
|
-
},
|
|
150
|
-
},
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
return {
|
|
154
|
-
id: id,
|
|
155
|
-
dismiss,
|
|
156
|
-
update,
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
function useToast() {
|
|
161
|
-
const [state, setState] = React.useState<State>(memoryState);
|
|
162
|
-
|
|
163
|
-
React.useEffect(() => {
|
|
164
|
-
listeners.push(setState);
|
|
165
|
-
return () => {
|
|
166
|
-
const index = listeners.indexOf(setState);
|
|
167
|
-
if (index > -1) {
|
|
168
|
-
listeners.splice(index, 1);
|
|
169
|
-
}
|
|
170
|
-
};
|
|
171
|
-
}, [state]);
|
|
172
|
-
|
|
173
|
-
return {
|
|
174
|
-
...state,
|
|
175
|
-
toast,
|
|
176
|
-
dismiss: (toastId?: string) => dispatch({ type: "DISMISS_TOAST", toastId }),
|
|
177
|
-
};
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
export { useToast, toast };
|