pentatrion-design 0.0.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.
- package/.storybook/main.ts +33 -0
- package/.storybook/manager.ts +8 -0
- package/.storybook/preview-head.html +2 -0
- package/.storybook/preview.ts +26 -0
- package/.storybook/public/bg-map.jpg +0 -0
- package/.storybook/public/favicon-32x32.png +0 -0
- package/.storybook/public/favicon.svg +28 -0
- package/.storybook/public/movies.json +2153 -0
- package/.storybook/public/population.json +1178 -0
- package/.storybook/public/town-74.geojson +8995 -0
- package/.storybook/public/town-74.json +4062 -0
- package/.storybook/theme.ts +14 -0
- package/Makefile +14 -0
- package/README.md +40 -0
- package/TODO.md +5 -0
- package/dist/index.d.ts +1110 -0
- package/dist/index.js +3707 -0
- package/dist/redux/index.d.ts +43 -0
- package/dist/redux/index.js +583 -0
- package/dist/types.d-DlHa_IaW.d.ts +14 -0
- package/images/logo-shadow.svg +173 -0
- package/images/logo.svg +76 -0
- package/package.json +85 -0
- package/postcss.config.js +7 -0
- package/src/components/autocomplete/Autocomplete.stories.tsx +89 -0
- package/src/components/autocomplete/Autocomplete.tsx +316 -0
- package/src/components/autocomplete/AutocompleteOption.tsx +35 -0
- package/src/components/autocomplete/LazyAutocomplete.tsx +130 -0
- package/src/components/autocomplete/SimpleAutocomplete.tsx +74 -0
- package/src/components/autocomplete/index.ts +6 -0
- package/src/components/autocomplete/useAutocompleteContext.ts +20 -0
- package/src/components/autocomplete/util.ts +19 -0
- package/src/components/badge/Badge.stories.tsx +72 -0
- package/src/components/badge/Badge.tsx +70 -0
- package/src/components/button/Button.stories.tsx +189 -0
- package/src/components/button/Button.test.tsx +20 -0
- package/src/components/button/Button.tsx +200 -0
- package/src/components/button/ButtonGroup.stories.tsx +46 -0
- package/src/components/button/ButtonGroup.tsx +29 -0
- package/src/components/button/index.ts +2 -0
- package/src/components/card/Card.stories.tsx +21 -0
- package/src/components/card/config.ts +4 -0
- package/src/components/card/index.ts +1 -0
- package/src/components/code/Code.tsx +15 -0
- package/src/components/context-menu/ContextMenu.stories.tsx +22 -0
- package/src/components/context-menu/ContextMenu.tsx +175 -0
- package/src/components/context-menu/ContextMenuItem.tsx +34 -0
- package/src/components/context-menu/index.ts +2 -0
- package/src/components/dialog/Dialog.stories.tsx +270 -0
- package/src/components/dialog/Dialog.tsx +46 -0
- package/src/components/dialog/index.ts +1 -0
- package/src/components/dialog/util.ts +29 -0
- package/src/components/dropdown-menu/DropdownMenu.stories.tsx +19 -0
- package/src/components/dropdown-menu/DropdownMenu.tsx +12 -0
- package/src/components/dropdown-menu/DropdownMenuContent.tsx +46 -0
- package/src/components/dropdown-menu/DropdownMenuItem.tsx +33 -0
- package/src/components/dropdown-menu/DropdownMenuTrigger.tsx +42 -0
- package/src/components/dropdown-menu/index.ts +7 -0
- package/src/components/dropdown-menu/interface.d.ts +13 -0
- package/src/components/dropdown-menu/useDropdownMenu.tsx +115 -0
- package/src/components/dropdown-menu/useDropdownMenuContext.ts +16 -0
- package/src/components/dropdown-menu-nested/DropdownMenuNested.stories.tsx +33 -0
- package/src/components/dropdown-menu-nested/DropdownMenuNested.tsx +19 -0
- package/src/components/dropdown-menu-nested/MenuContext.ts +15 -0
- package/src/components/dropdown-menu-nested/MenuItem.tsx +43 -0
- package/src/components/dropdown-menu-nested/MenuItemWithChildren.tsx +204 -0
- package/src/components/dropdown-menu-nested/index.ts +3 -0
- package/src/components/flash/Flash.stories.tsx +34 -0
- package/src/components/flash/Flash.tsx +24 -0
- package/src/components/highlight/Highlight.stories.tsx +128 -0
- package/src/components/highlight/Highlight.tsx +29 -0
- package/src/components/href/Href.stories.tsx +55 -0
- package/src/components/href/Href.tsx +18 -0
- package/src/components/input/Checkbox.stories.tsx +52 -0
- package/src/components/input/Checkbox.tsx +41 -0
- package/src/components/input/Input.stories.tsx +103 -0
- package/src/components/input/Input.test.tsx +10 -0
- package/src/components/input/Input.tsx +60 -0
- package/src/components/input/RadioGroup.stories.tsx +76 -0
- package/src/components/input/RadioGroup.tsx +84 -0
- package/src/components/input/Toggle.stories.tsx +29 -0
- package/src/components/input/Toggle.tsx +35 -0
- package/src/components/input/index.ts +4 -0
- package/src/components/input-field/InputField.stories.tsx +227 -0
- package/src/components/input-field/InputField.tsx +62 -0
- package/src/components/loader/Loader.stories.tsx +37 -0
- package/src/components/loader/Loader.tsx +54 -0
- package/src/components/modal/Components.tsx +58 -0
- package/src/components/modal/Modal.stories.tsx +113 -0
- package/src/components/modal/Modal.tsx +13 -0
- package/src/components/modal/ModalContent.tsx +46 -0
- package/src/components/modal/ModalTrigger.tsx +41 -0
- package/src/components/modal/index.ts +7 -0
- package/src/components/modal/interface.d.ts +10 -0
- package/src/components/modal/useModal.ts +48 -0
- package/src/components/modal/useModalContext.ts +16 -0
- package/src/components/notification/Notification.stories.tsx +51 -0
- package/src/components/notification/NotificationsContext.ts +79 -0
- package/src/components/notification/NotificationsProvider.tsx +58 -0
- package/src/components/notification/index.ts +2 -0
- package/src/components/popover/Components.tsx +45 -0
- package/src/components/popover/Popover.stories.tsx +46 -0
- package/src/components/popover/Popover.test.tsx +21 -0
- package/src/components/popover/Popover.tsx +12 -0
- package/src/components/popover/PopoverContent.tsx +46 -0
- package/src/components/popover/PopoverTrigger.tsx +42 -0
- package/src/components/popover/index.ts +7 -0
- package/src/components/popover/interface.d.ts +13 -0
- package/src/components/popover/usePopover.tsx +80 -0
- package/src/components/popover/usePopoverContext.ts +16 -0
- package/src/components/portal/Portal.tsx +12 -0
- package/src/components/quick-settings/QuickSettings.stories.tsx +182 -0
- package/src/components/resize-area/ResizeArea.stories.css +40 -0
- package/src/components/resize-area/ResizeArea.stories.tsx +30 -0
- package/src/components/resize-area/ResizeArea.tsx +79 -0
- package/src/components/scroll/Scroll.stories.tsx +81 -0
- package/src/components/scroll/Scroll.tsx +111 -0
- package/src/components/select/Select.stories.tsx +248 -0
- package/src/components/select/Select.tsx +362 -0
- package/src/components/select/SelectOption.tsx +29 -0
- package/src/components/select/SelectSelection.tsx +13 -0
- package/src/components/select/index.ts +5 -0
- package/src/components/select/interface.d.ts +36 -0
- package/src/components/select/useSelectContext.ts +19 -0
- package/src/components/select/util.ts +12 -0
- package/src/components/snack/Snack.stories.tsx +33 -0
- package/src/components/snack/Snack.tsx +47 -0
- package/src/components/sortable/Sortable.stories.tsx +98 -0
- package/src/components/sortable/Sortable.tsx +37 -0
- package/src/components/sortable/index.ts +2 -0
- package/src/components/sortable/types.d.ts +12 -0
- package/src/components/steps/Step.tsx +41 -0
- package/src/components/steps/Steps.stories.tsx +141 -0
- package/src/components/steps/Steps.tsx +49 -0
- package/src/components/steps/index.ts +3 -0
- package/src/components/steps/util.ts +3 -0
- package/src/components/table/Table.stories.tsx +36 -0
- package/src/components/table/Table.tsx +13 -0
- package/src/components/table/TableBody.tsx +9 -0
- package/src/components/table/TableCell.tsx +16 -0
- package/src/components/table/TableFooter.tsx +9 -0
- package/src/components/table/TableHeader.tsx +14 -0
- package/src/components/table/TableHeaderCell.tsx +14 -0
- package/src/components/table/TableRow.tsx +14 -0
- package/src/components/table/index.ts +7 -0
- package/src/components/tabs/Tabs.stories.tsx +66 -0
- package/src/components/tabs/Tabs.tsx +80 -0
- package/src/components/tooltip/SimpleTooltip.tsx +17 -0
- package/src/components/tooltip/Tooltip.stories.tsx +129 -0
- package/src/components/tooltip/Tooltip.test.tsx +18 -0
- package/src/components/tooltip/Tooltip.tsx +13 -0
- package/src/components/tooltip/TooltipContent.tsx +41 -0
- package/src/components/tooltip/TooltipTrigger.tsx +36 -0
- package/src/components/tooltip/index.ts +6 -0
- package/src/components/tooltip/interface.d.ts +15 -0
- package/src/components/tooltip/useTooltip.ts +87 -0
- package/src/components/tooltip/useTooltipContext.ts +16 -0
- package/src/env.d.ts +27 -0
- package/src/hooks/index.ts +13 -0
- package/src/hooks/useCombinedRefs.test.tsx +42 -0
- package/src/hooks/useCombinedRefs.ts +21 -0
- package/src/hooks/useCopyToClipboard.ts +28 -0
- package/src/hooks/useDebounce.ts +59 -0
- package/src/hooks/useEventCallback.ts +13 -0
- package/src/hooks/useEventListener.ts +86 -0
- package/src/hooks/useFetch.tsx +21 -0
- package/src/hooks/useIsClosing.ts +25 -0
- package/src/hooks/useIsMounted.tsx +16 -0
- package/src/hooks/useIsomorphicLayoutEffect.ts +4 -0
- package/src/hooks/useNotifications.tsx +13 -0
- package/src/hooks/useOnClickOutside.ts +35 -0
- package/src/hooks/usePrevious.ts +9 -0
- package/src/hooks/useRipple.test.tsx +52 -0
- package/src/hooks/useRipple.tsx +79 -0
- package/src/index.css +14 -0
- package/src/index.ts +39 -0
- package/src/lib/arrUtil.ts +8 -0
- package/src/lib/error.ts +18 -0
- package/src/lib/fetch.test.ts +107 -0
- package/src/lib/fetch.ts +115 -0
- package/src/lib/index.ts +3 -0
- package/src/lib/tailwindVariants.ts +35 -0
- package/src/redux/index.ts +1 -0
- package/src/redux/notification/components/NotificationConsumer.tsx +52 -0
- package/src/redux/notification/errorCatcherMiddleware.ts +17 -0
- package/src/redux/notification/hooks/useNotification.ts +26 -0
- package/src/redux/notification/index.ts +5 -0
- package/src/redux/notification/notificationSlice.ts +68 -0
- package/src/styles/Animation.stories.tsx +43 -0
- package/src/styles/Shadow.stories.tsx +43 -0
- package/src/styles/Themes.stories.tsx +31 -0
- package/src/styles/Typography.stories.tsx +101 -0
- package/src/tailwind/base.css +188 -0
- package/src/tailwind/components-input-outline.css +62 -0
- package/src/tailwind/components-resize-area.css +112 -0
- package/src/tailwind/components-step.css +161 -0
- package/src/tailwind/components.css +51 -0
- package/src/tailwind/keyframes.ts +69 -0
- package/src/tailwind/pentatrionTw.ts +147 -0
- package/src/tailwind/utilities-dialog.css +103 -0
- package/src/tailwind/utilities.css +3 -0
- package/src/types.d.ts +12 -0
- package/tailwind.config.js +18 -0
- package/tests/README.md +32 -0
- package/tests/setup.ts +1 -0
- package/tsconfig.json +14 -0
- package/tsup.config.ts +23 -0
- package/vite.config.ts +24 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { M as Message, T as ThemeColor, a as MessageOptions } from '../types.d-DlHa_IaW.js';
|
|
2
|
+
import * as _reduxjs_toolkit from '@reduxjs/toolkit';
|
|
3
|
+
import { Middleware } from '@reduxjs/toolkit';
|
|
4
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
|
+
import { ReactNode } from 'react';
|
|
6
|
+
|
|
7
|
+
type NotificationState = {
|
|
8
|
+
messages: Message[];
|
|
9
|
+
};
|
|
10
|
+
declare const _default: _reduxjs_toolkit.Reducer<NotificationState>;
|
|
11
|
+
|
|
12
|
+
declare const messageAdded: _reduxjs_toolkit.ActionCreatorWithPreparedPayload<[content: string, options?: Partial<Omit<Message, "message" | "id">> | undefined], {
|
|
13
|
+
id: string;
|
|
14
|
+
content: string;
|
|
15
|
+
expiration: number;
|
|
16
|
+
color: ThemeColor;
|
|
17
|
+
canClose: boolean;
|
|
18
|
+
withLoader: boolean;
|
|
19
|
+
}, "notification/messageAdded", never, never>;
|
|
20
|
+
declare const messageRemoved: _reduxjs_toolkit.ActionCreatorWithPayload<string, "notification/messageRemoved">;
|
|
21
|
+
declare const errorAdded: _reduxjs_toolkit.ActionCreatorWithPreparedPayload<[err: any], {
|
|
22
|
+
id: string;
|
|
23
|
+
content: string;
|
|
24
|
+
expiration: number;
|
|
25
|
+
color: ThemeColor;
|
|
26
|
+
canClose: boolean;
|
|
27
|
+
withLoader: boolean;
|
|
28
|
+
}, "notification/errorAdded", never, never>;
|
|
29
|
+
declare const selectMessages: (state: any) => Message[];
|
|
30
|
+
|
|
31
|
+
declare const errorCatcherMiddleware: Middleware;
|
|
32
|
+
|
|
33
|
+
interface Props {
|
|
34
|
+
children: ReactNode;
|
|
35
|
+
}
|
|
36
|
+
declare function NotificationConsumer({ children }: Props): react_jsx_runtime.JSX.Element;
|
|
37
|
+
|
|
38
|
+
declare function useNotification(): {
|
|
39
|
+
notify: (content: string, options?: MessageOptions) => void;
|
|
40
|
+
notifyError: (err: unknown) => void;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export { NotificationConsumer, errorAdded, errorCatcherMiddleware, messageAdded, messageRemoved, _default as notificationSlice, selectMessages, useNotification };
|
|
@@ -0,0 +1,583 @@
|
|
|
1
|
+
// src/redux/notification/notificationSlice.ts
|
|
2
|
+
import { createSlice, nanoid } from "@reduxjs/toolkit";
|
|
3
|
+
|
|
4
|
+
// src/lib/error.ts
|
|
5
|
+
function isErrorLike(err) {
|
|
6
|
+
if (err instanceof Error) {
|
|
7
|
+
return true;
|
|
8
|
+
} else if (err.name !== void 0 && err.message !== void 0) {
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
function parseError(err) {
|
|
14
|
+
if (isErrorLike(err)) {
|
|
15
|
+
return [err.message || "An error occured", { color: "red" }];
|
|
16
|
+
}
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// src/redux/notification/notificationSlice.ts
|
|
21
|
+
var initialState = {
|
|
22
|
+
messages: []
|
|
23
|
+
};
|
|
24
|
+
var notificationSlice = createSlice({
|
|
25
|
+
name: "notification",
|
|
26
|
+
initialState,
|
|
27
|
+
reducers: {
|
|
28
|
+
errorAdded: {
|
|
29
|
+
reducer(state, action) {
|
|
30
|
+
state.messages.push(action.payload);
|
|
31
|
+
},
|
|
32
|
+
prepare(err) {
|
|
33
|
+
const errorMessage = parseError(err);
|
|
34
|
+
if (errorMessage) {
|
|
35
|
+
const [content, options] = errorMessage;
|
|
36
|
+
const {
|
|
37
|
+
expiration = 5e3,
|
|
38
|
+
color = "red",
|
|
39
|
+
canClose = true,
|
|
40
|
+
withLoader = false
|
|
41
|
+
} = options || {};
|
|
42
|
+
const id = nanoid();
|
|
43
|
+
return {
|
|
44
|
+
payload: { id, content, expiration, color, canClose, withLoader }
|
|
45
|
+
};
|
|
46
|
+
} else {
|
|
47
|
+
throw err;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
messageAdded: {
|
|
52
|
+
reducer(state, action) {
|
|
53
|
+
state.messages.push(action.payload);
|
|
54
|
+
},
|
|
55
|
+
prepare(content, options) {
|
|
56
|
+
const {
|
|
57
|
+
expiration = 5e3,
|
|
58
|
+
color = "yellow",
|
|
59
|
+
canClose = true,
|
|
60
|
+
withLoader = false
|
|
61
|
+
} = options || {};
|
|
62
|
+
const id = nanoid();
|
|
63
|
+
return {
|
|
64
|
+
payload: { id, content, expiration, color, canClose, withLoader }
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
messageRemoved(state, action) {
|
|
69
|
+
const messageId = action.payload;
|
|
70
|
+
state.messages = state.messages.filter((m) => m.id !== messageId);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
var notificationSlice_default = notificationSlice.reducer;
|
|
75
|
+
var { messageAdded, messageRemoved, errorAdded } = notificationSlice.actions;
|
|
76
|
+
var selectMessages = (state) => state.notification.messages;
|
|
77
|
+
|
|
78
|
+
// src/redux/notification/errorCatcherMiddleware.ts
|
|
79
|
+
var errorCatcherMiddleware = ({ dispatch }) => (next) => async (action) => {
|
|
80
|
+
if (typeof action !== "function" && action.type.endsWith("/rejected")) {
|
|
81
|
+
const errorMessage = parseError(action.error || {});
|
|
82
|
+
if (errorMessage) {
|
|
83
|
+
dispatch(messageAdded(...errorMessage));
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return next(action);
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
// src/redux/notification/components/NotificationConsumer.tsx
|
|
90
|
+
import { useEffect as useEffect9, useRef as useRef8 } from "react";
|
|
91
|
+
import { createPortal } from "react-dom";
|
|
92
|
+
import { useDispatch, useSelector } from "react-redux";
|
|
93
|
+
import { nanoid as nanoid2 } from "@reduxjs/toolkit";
|
|
94
|
+
|
|
95
|
+
// src/components/snack/Snack.tsx
|
|
96
|
+
import clsx5 from "clsx";
|
|
97
|
+
import { useEffect as useEffect8 } from "react";
|
|
98
|
+
|
|
99
|
+
// src/components/button/Button.tsx
|
|
100
|
+
import { forwardRef, useImperativeHandle, useRef as useRef7 } from "react";
|
|
101
|
+
import clsx2 from "clsx";
|
|
102
|
+
|
|
103
|
+
// src/components/loader/Loader.tsx
|
|
104
|
+
import { useId } from "react";
|
|
105
|
+
import clsx from "clsx";
|
|
106
|
+
|
|
107
|
+
// src/lib/tailwindVariants.ts
|
|
108
|
+
var colorVariants = {
|
|
109
|
+
yellow: {
|
|
110
|
+
border: "border-yellow-3",
|
|
111
|
+
text: "text-yellow-4"
|
|
112
|
+
},
|
|
113
|
+
gray: {
|
|
114
|
+
border: "border-gray-3",
|
|
115
|
+
text: "text-gray-4"
|
|
116
|
+
},
|
|
117
|
+
red: {
|
|
118
|
+
border: "border-red-3",
|
|
119
|
+
text: "text-red-4"
|
|
120
|
+
},
|
|
121
|
+
orange: {
|
|
122
|
+
border: "border-orange-3",
|
|
123
|
+
text: "text-orange-4"
|
|
124
|
+
},
|
|
125
|
+
green: {
|
|
126
|
+
border: "border-green-3",
|
|
127
|
+
text: "text-green-4"
|
|
128
|
+
},
|
|
129
|
+
blue: {
|
|
130
|
+
border: "border-blue-3",
|
|
131
|
+
text: "text-blue-4"
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
// src/components/loader/Loader.tsx
|
|
136
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
137
|
+
var sizeConfig = {
|
|
138
|
+
small: "w-6 h-6 text-base",
|
|
139
|
+
medium: "w-8 h-8 text-[2rem]",
|
|
140
|
+
large: "w-12 h-12 text-[3rem]"
|
|
141
|
+
};
|
|
142
|
+
var trackStyle = {
|
|
143
|
+
strokeLinecap: "round",
|
|
144
|
+
strokeWidth: 2
|
|
145
|
+
};
|
|
146
|
+
var circleStyle = {
|
|
147
|
+
strokeLinecap: "round",
|
|
148
|
+
strokeWidth: 2,
|
|
149
|
+
/**
|
|
150
|
+
* $total-length: 43.699; // total length of path, calculated by getTotalLength() in JS
|
|
151
|
+
* $looping-percent: 40;
|
|
152
|
+
* $looping-length: math.div($looping-percent * $total-length, 100) = 17.464;
|
|
153
|
+
* stroke-dasharray: #{$looping-length * 1px}, #{($total-length - $looping-length) * 1px};
|
|
154
|
+
*/
|
|
155
|
+
strokeDasharray: "17.45px, 26.21px"
|
|
156
|
+
};
|
|
157
|
+
function Loader({ size = "medium", color = "blue", className, ...rest }) {
|
|
158
|
+
const id = useId();
|
|
159
|
+
return /* @__PURE__ */ jsxs(
|
|
160
|
+
"svg",
|
|
161
|
+
{
|
|
162
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
163
|
+
className: clsx("inline-block", sizeConfig[size], colorVariants[color].text, className),
|
|
164
|
+
viewBox: "0 0 16 16",
|
|
165
|
+
...rest,
|
|
166
|
+
children: [
|
|
167
|
+
/* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsx("circle", { id, cx: "8", cy: "8", r: "7" }) }),
|
|
168
|
+
/* @__PURE__ */ jsx("use", { href: `#${id}`, className: "opacity-25 fill-none stroke-current", style: trackStyle }),
|
|
169
|
+
/* @__PURE__ */ jsx(
|
|
170
|
+
"use",
|
|
171
|
+
{
|
|
172
|
+
href: `#${id}`,
|
|
173
|
+
className: "fill-none stroke-current animate-loader-stroke",
|
|
174
|
+
style: circleStyle
|
|
175
|
+
}
|
|
176
|
+
)
|
|
177
|
+
]
|
|
178
|
+
}
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// src/hooks/useNotifications.tsx
|
|
183
|
+
import { useContext } from "react";
|
|
184
|
+
|
|
185
|
+
// src/components/notification/NotificationsContext.ts
|
|
186
|
+
import { createContext } from "react";
|
|
187
|
+
var NotificationsContext = createContext(
|
|
188
|
+
null
|
|
189
|
+
);
|
|
190
|
+
|
|
191
|
+
// src/hooks/useRipple.tsx
|
|
192
|
+
import { useEffect, useState } from "react";
|
|
193
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
194
|
+
var useRipple = (ref) => {
|
|
195
|
+
const [ripples, setRipples] = useState([]);
|
|
196
|
+
useEffect(() => {
|
|
197
|
+
const handlePointerDown = (e) => {
|
|
198
|
+
if (ref.current) {
|
|
199
|
+
const elem = ref.current;
|
|
200
|
+
const rect = elem.getBoundingClientRect();
|
|
201
|
+
const left = (e.clientX ?? 0) - rect.left;
|
|
202
|
+
const top = (e.clientY ?? 0) - rect.top;
|
|
203
|
+
const height = elem.clientHeight;
|
|
204
|
+
const width = elem.clientWidth;
|
|
205
|
+
const diameter = Math.max(width, height);
|
|
206
|
+
setRipples((r) => [
|
|
207
|
+
...r,
|
|
208
|
+
{
|
|
209
|
+
top: top - diameter / 2,
|
|
210
|
+
left: left - diameter / 2,
|
|
211
|
+
height: Math.max(width, height),
|
|
212
|
+
width: Math.max(width, height)
|
|
213
|
+
}
|
|
214
|
+
]);
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
if (ref.current) {
|
|
218
|
+
const elem = ref.current;
|
|
219
|
+
elem.addEventListener("pointerdown", handlePointerDown);
|
|
220
|
+
return () => {
|
|
221
|
+
elem.removeEventListener("pointerdown", handlePointerDown);
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
}, [ref]);
|
|
225
|
+
const [_debounced] = useDebounce(ripples, 1e3);
|
|
226
|
+
useEffect(() => {
|
|
227
|
+
if (_debounced.length) {
|
|
228
|
+
setRipples([]);
|
|
229
|
+
}
|
|
230
|
+
}, [_debounced]);
|
|
231
|
+
return ripples?.map((style, i) => {
|
|
232
|
+
return /* @__PURE__ */ jsx2(
|
|
233
|
+
"span",
|
|
234
|
+
{
|
|
235
|
+
"data-testid": "ripple",
|
|
236
|
+
className: "animate-ripple",
|
|
237
|
+
style: {
|
|
238
|
+
...style,
|
|
239
|
+
//should be absolutely positioned
|
|
240
|
+
position: "absolute",
|
|
241
|
+
backgroundColor: "#FFFFFF",
|
|
242
|
+
opacity: "25%",
|
|
243
|
+
transform: "scale(0)",
|
|
244
|
+
borderRadius: "50%"
|
|
245
|
+
}
|
|
246
|
+
},
|
|
247
|
+
i
|
|
248
|
+
);
|
|
249
|
+
});
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
// src/hooks/useIsMounted.tsx
|
|
253
|
+
import { useCallback, useEffect as useEffect2, useRef } from "react";
|
|
254
|
+
|
|
255
|
+
// src/hooks/useFetch.tsx
|
|
256
|
+
import { useCallback as useCallback2 } from "react";
|
|
257
|
+
|
|
258
|
+
// src/hooks/useCombinedRefs.ts
|
|
259
|
+
import { useCallback as useCallback3 } from "react";
|
|
260
|
+
|
|
261
|
+
// src/hooks/useIsClosing.ts
|
|
262
|
+
import { useCallback as useCallback4, useEffect as useEffect3, useRef as useRef2, useState as useState2 } from "react";
|
|
263
|
+
|
|
264
|
+
// src/hooks/usePrevious.ts
|
|
265
|
+
import { useEffect as useEffect4, useRef as useRef3 } from "react";
|
|
266
|
+
|
|
267
|
+
// src/hooks/useEventCallback.ts
|
|
268
|
+
import { useCallback as useCallback5, useRef as useRef4 } from "react";
|
|
269
|
+
function useEventCallback(callback) {
|
|
270
|
+
const ref = useRef4(() => {
|
|
271
|
+
throw new Error("Cannot call an event handler while rendering.");
|
|
272
|
+
});
|
|
273
|
+
ref.current = callback;
|
|
274
|
+
return useCallback5((...args) => ref.current?.(...args), [ref]);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// src/hooks/useDebounce.ts
|
|
278
|
+
import {
|
|
279
|
+
useCallback as useCallback6,
|
|
280
|
+
useEffect as useEffect5,
|
|
281
|
+
useRef as useRef5,
|
|
282
|
+
useState as useState3
|
|
283
|
+
} from "react";
|
|
284
|
+
function useDebounce(value, delay) {
|
|
285
|
+
const [debouncedValue, setImmediateValue] = useState3(value);
|
|
286
|
+
useEffect5(() => {
|
|
287
|
+
const timer = setTimeout(() => setImmediateValue(value), delay || 500);
|
|
288
|
+
return () => {
|
|
289
|
+
clearTimeout(timer);
|
|
290
|
+
};
|
|
291
|
+
}, [value, delay]);
|
|
292
|
+
return [debouncedValue, setImmediateValue];
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
// src/hooks/useCopyToClipboard.ts
|
|
296
|
+
import { useCallback as useCallback7, useState as useState4 } from "react";
|
|
297
|
+
|
|
298
|
+
// src/hooks/useEventListener.ts
|
|
299
|
+
import { useEffect as useEffect7, useRef as useRef6 } from "react";
|
|
300
|
+
|
|
301
|
+
// src/hooks/useIsomorphicLayoutEffect.ts
|
|
302
|
+
import { useEffect as useEffect6, useLayoutEffect } from "react";
|
|
303
|
+
|
|
304
|
+
// src/components/button/Button.tsx
|
|
305
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
306
|
+
var buttonVariants = {
|
|
307
|
+
size(icon, size) {
|
|
308
|
+
if (size === "custom") {
|
|
309
|
+
return false;
|
|
310
|
+
}
|
|
311
|
+
switch (size) {
|
|
312
|
+
case "small":
|
|
313
|
+
return clsx2(!icon && "px-2", "text-sm h-6");
|
|
314
|
+
case "medium":
|
|
315
|
+
return !icon && "px-4 h-8";
|
|
316
|
+
case "large":
|
|
317
|
+
return !icon && "px-8 h-12";
|
|
318
|
+
}
|
|
319
|
+
},
|
|
320
|
+
variant: {
|
|
321
|
+
contained(color) {
|
|
322
|
+
return clsx2(
|
|
323
|
+
"shadow hover:shadow-md focus:shadow-md active-full:shadow-lg outline-offset-0",
|
|
324
|
+
{
|
|
325
|
+
yellow: "text-yellow-text bg-yellow-3 hover:bg-yellow-4 active-full:bg-yellow-5 focus-visible:outline-yellow-5",
|
|
326
|
+
gray: "text-gray-text bg-gray-3 hover:bg-gray-4 active-full:bg-gray-5 focus-visible:outline-gray-5",
|
|
327
|
+
red: "text-red-text bg-red-3 hover:bg-red-4 active-full:bg-red-5 focus-visible:outline-red-5",
|
|
328
|
+
orange: "text-orange-text bg-orange-3 hover:bg-orange-4 active-full:bg-orange-5 focus-visible:outline-orange-5",
|
|
329
|
+
green: "text-green-text bg-green-3 hover:bg-green-4 active-full:bg-green-5 focus-visible:outline-green-5",
|
|
330
|
+
blue: "text-blue-text bg-blue-3 hover:bg-blue-4 active-full:bg-blue-5 focus-visible:outline-blue-5"
|
|
331
|
+
}[color]
|
|
332
|
+
);
|
|
333
|
+
},
|
|
334
|
+
light(color) {
|
|
335
|
+
return clsx2(
|
|
336
|
+
"shadow hover:shadow-md focus:shadow-md active-full:shadow-lg outline-offset-0 bg-gray-0",
|
|
337
|
+
{
|
|
338
|
+
yellow: "text-gray-text hover:text-yellow-text hover:bg-yellow-3 active-full:bg-yellow-4 dark:active-full:bg-yellow-4/50 focus-visible:outline-yellow-4",
|
|
339
|
+
gray: "text-gray-text hover:text-gray-text hover:bg-gray-3 active-full:bg-gray-4 dark:active-full:bg-gray-4/50 focus-visible:outline-gray-4",
|
|
340
|
+
red: "text-gray-text hover:text-red-text hover:bg-red-3 active-full:bg-red-4 dark:active-full:bg-red-4/50 focus-visible:outline-red-4",
|
|
341
|
+
orange: "text-gray-text hover:text-orange-text hover:bg-orange-3 active-full:bg-orange-4 dark:active-full:bg-orange-4/50 focus-visible:outline-orange-4",
|
|
342
|
+
green: "text-gray-text hover:text-green-text hover:bg-green-3 active-full:bg-green-4 dark:active-full:bg-green-4/50 focus-visible:outline-green-4",
|
|
343
|
+
blue: "text-gray-text hover:text-blue-text hover:bg-blue-3 active-full:bg-blue-4 dark:active-full:bg-blue-4/50 focus-visible:outline-blue-4"
|
|
344
|
+
}[color]
|
|
345
|
+
);
|
|
346
|
+
},
|
|
347
|
+
outlined(color) {
|
|
348
|
+
return clsx2(
|
|
349
|
+
"bg-gray-0 text-gray-7 outline outline-2 outline-offset-[-2px] focus-visible:ring-2 active-full:shadow-md",
|
|
350
|
+
{
|
|
351
|
+
yellow: "hover:bg-yellow-1/50 active-full:bg-yellow-2/50 outline-yellow-5 focus-visible:ring-yellow-4",
|
|
352
|
+
gray: "hover:bg-gray-1 active-full:bg-gray-2 outline-gray-5 focus-visible:ring-gray-4",
|
|
353
|
+
red: "hover:bg-red-1/50 active-full:bg-red-2/50 outline-red-5 focus-visible:ring-red-4",
|
|
354
|
+
orange: "hover:bg-orange-1/50 active-full:bg-orange-2/50 outline-orange-5 focus-visible:ring-orange-4",
|
|
355
|
+
green: "hover:bg-green-1/50 active-full:bg-green-2/50 outline-green-5 focus-visible:ring-green-4",
|
|
356
|
+
blue: "hover:bg-blue-1/50 active-full:bg-blue-2/50 outline-blue-5 focus-visible:ring-blue-4"
|
|
357
|
+
}[color]
|
|
358
|
+
);
|
|
359
|
+
},
|
|
360
|
+
text(color) {
|
|
361
|
+
return clsx2(
|
|
362
|
+
"bg-transparent active-full:shadow-sm outline-offset-0",
|
|
363
|
+
{
|
|
364
|
+
yellow: "hover:bg-yellow-1/50 active-full:bg-yellow-2/25 text-yellow-4 hover:text-yellow-5",
|
|
365
|
+
gray: "hover:bg-gray-1 active-full:bg-gray-2 text-gray-5 hover:text-gray-6 active-full:text-gray-7",
|
|
366
|
+
red: "hover:bg-red-1/50 active-full:bg-red-2/50 text-red-4 hover:text-red-5",
|
|
367
|
+
orange: "hover:bg-orange-1/50 active-full:bg-orange-2/50 text-orange-4 hover:text-orange-5",
|
|
368
|
+
green: "hover:bg-green-1/50 active-full:bg-green-2/50 text-green-4 hover:text-green-5",
|
|
369
|
+
blue: "hover:bg-blue-1/50 active-full:bg-blue-2/50 text-blue-4 hover:text-blue-5"
|
|
370
|
+
}[color]
|
|
371
|
+
);
|
|
372
|
+
},
|
|
373
|
+
ghost(color) {
|
|
374
|
+
return clsx2(
|
|
375
|
+
"bg-transparent outline-offset-0",
|
|
376
|
+
{
|
|
377
|
+
yellow: "text-yellow-4 hover:text-yellow-5",
|
|
378
|
+
gray: "text-gray-5 hover:text-gray-6 active-full:text-gray-7",
|
|
379
|
+
red: "text-red-4 hover:text-red-5",
|
|
380
|
+
orange: "text-orange-4 hover:text-orange-5",
|
|
381
|
+
green: "text-green-4 hover:text-green-5",
|
|
382
|
+
blue: "text-blue-4 hover:text-blue-5"
|
|
383
|
+
}[color]
|
|
384
|
+
);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
};
|
|
388
|
+
var Button = forwardRef(
|
|
389
|
+
({
|
|
390
|
+
withRipple = true,
|
|
391
|
+
variant = "contained",
|
|
392
|
+
loading,
|
|
393
|
+
color = "yellow",
|
|
394
|
+
size = "medium",
|
|
395
|
+
focusable = true,
|
|
396
|
+
fullWidth,
|
|
397
|
+
className,
|
|
398
|
+
disabled,
|
|
399
|
+
children,
|
|
400
|
+
selected = false,
|
|
401
|
+
icon = false,
|
|
402
|
+
...props
|
|
403
|
+
}, ref) => {
|
|
404
|
+
const inputRef = useRef7(null);
|
|
405
|
+
useImperativeHandle(
|
|
406
|
+
ref,
|
|
407
|
+
() => inputRef.current
|
|
408
|
+
);
|
|
409
|
+
const notClickable = loading || disabled;
|
|
410
|
+
const ripples = useRipple(inputRef);
|
|
411
|
+
return /* @__PURE__ */ jsxs2(
|
|
412
|
+
"button",
|
|
413
|
+
{
|
|
414
|
+
tabIndex: focusable ? 0 : -1,
|
|
415
|
+
role: "button",
|
|
416
|
+
ref: inputRef,
|
|
417
|
+
className: clsx2(
|
|
418
|
+
"rounded-2xl cursor-pointer relative overflow-clip focus-visible:outline focus-visible:outline-2 no-underline border-0 inline-flex items-center transition-color-shadow duration-300 leading-5",
|
|
419
|
+
className,
|
|
420
|
+
buttonVariants.size(icon, size),
|
|
421
|
+
buttonVariants.variant[variant](color),
|
|
422
|
+
icon && "justify-center min-w-8 h-8 [&_i]:w-8 [&_:last-child:not(i,img)]:pr-4",
|
|
423
|
+
fullWidth && "w-full",
|
|
424
|
+
selected && "active",
|
|
425
|
+
notClickable && "disabled"
|
|
426
|
+
),
|
|
427
|
+
"data-variant": variant,
|
|
428
|
+
disabled,
|
|
429
|
+
"aria-busy": loading,
|
|
430
|
+
...props,
|
|
431
|
+
children: [
|
|
432
|
+
!notClickable && withRipple && ripples,
|
|
433
|
+
children,
|
|
434
|
+
loading !== void 0 && /* @__PURE__ */ jsx3("span", { className: "", children: /* @__PURE__ */ jsx3(
|
|
435
|
+
Loader,
|
|
436
|
+
{
|
|
437
|
+
color,
|
|
438
|
+
size: "small",
|
|
439
|
+
className: clsx2("ml-2 -mr-2", !loading && "invisible")
|
|
440
|
+
}
|
|
441
|
+
) })
|
|
442
|
+
]
|
|
443
|
+
}
|
|
444
|
+
);
|
|
445
|
+
}
|
|
446
|
+
);
|
|
447
|
+
var Button_default = Button;
|
|
448
|
+
|
|
449
|
+
// src/components/button/ButtonGroup.tsx
|
|
450
|
+
import clsx3 from "clsx";
|
|
451
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
452
|
+
|
|
453
|
+
// src/components/dialog/Dialog.tsx
|
|
454
|
+
import clsx4 from "clsx";
|
|
455
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
456
|
+
var dialogVariants = {
|
|
457
|
+
color(color) {
|
|
458
|
+
if (!color) {
|
|
459
|
+
return "bg-gray-0";
|
|
460
|
+
}
|
|
461
|
+
return clsx4(
|
|
462
|
+
"border-t-4",
|
|
463
|
+
{
|
|
464
|
+
yellow: "border-t-yellow-3 bg-gray-0",
|
|
465
|
+
gray: "border-t-gray-3 bg-gray-0",
|
|
466
|
+
red: "border-t-red-3 bg-red-1",
|
|
467
|
+
blue: "border-t-blue-3 bg-blue-1",
|
|
468
|
+
green: "border-t-green-3 bg-green-1",
|
|
469
|
+
orange: "border-t-orange-3 bg-orange-1"
|
|
470
|
+
}[color]
|
|
471
|
+
);
|
|
472
|
+
}
|
|
473
|
+
};
|
|
474
|
+
function Dialog({ placement, color, children, className, ...rest }) {
|
|
475
|
+
return /* @__PURE__ */ jsx5(
|
|
476
|
+
"div",
|
|
477
|
+
{
|
|
478
|
+
className: clsx4(
|
|
479
|
+
"rounded-2xl relative shadow dark:shadow-dark",
|
|
480
|
+
dialogVariants.color(color),
|
|
481
|
+
className
|
|
482
|
+
),
|
|
483
|
+
"data-placement": placement,
|
|
484
|
+
"data-color": color,
|
|
485
|
+
...rest,
|
|
486
|
+
children
|
|
487
|
+
}
|
|
488
|
+
);
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
// src/components/snack/Snack.tsx
|
|
492
|
+
import { jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
493
|
+
function Snack({
|
|
494
|
+
expiration = 5e3,
|
|
495
|
+
content = "",
|
|
496
|
+
color = "yellow",
|
|
497
|
+
withLoader = false,
|
|
498
|
+
canClose = false,
|
|
499
|
+
onRemove = () => {
|
|
500
|
+
}
|
|
501
|
+
}) {
|
|
502
|
+
const onRemoveStable = useEventCallback(onRemove);
|
|
503
|
+
useEffect8(() => {
|
|
504
|
+
if (expiration === -1) {
|
|
505
|
+
return;
|
|
506
|
+
}
|
|
507
|
+
const timeoutId = setTimeout(() => onRemoveStable(), expiration);
|
|
508
|
+
return () => void clearTimeout(timeoutId);
|
|
509
|
+
}, [onRemoveStable, expiration]);
|
|
510
|
+
return /* @__PURE__ */ jsx6(Dialog, { className: clsx5("animate-fade-in", "ll-snack"), placement: "top", color, children: /* @__PURE__ */ jsxs3("div", { className: "w-fit min-w-60 px-2 py-1 flex items-center", children: [
|
|
511
|
+
/* @__PURE__ */ jsx6("span", { className: "pr-4 flex-1", children: content }),
|
|
512
|
+
withLoader && /* @__PURE__ */ jsx6(Loader, { size: "small", color: "gray" }),
|
|
513
|
+
canClose && /* @__PURE__ */ jsx6(Button_default, { icon: true, variant: "text", color: "gray", onClick: onRemove, children: /* @__PURE__ */ jsx6("i", { className: "fe-cancel" }) })
|
|
514
|
+
] }) });
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
// src/redux/notification/components/NotificationConsumer.tsx
|
|
518
|
+
import { Fragment, jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
519
|
+
function NotificationConsumer({ children }) {
|
|
520
|
+
const container = useRef8(null);
|
|
521
|
+
if (!container.current) {
|
|
522
|
+
container.current = document.createElement("div");
|
|
523
|
+
container.current.id = nanoid2();
|
|
524
|
+
container.current.classList.add("ll-snack-bar");
|
|
525
|
+
document.body.append(container.current);
|
|
526
|
+
}
|
|
527
|
+
if (!container.current.parentElement) {
|
|
528
|
+
console.log("NotificationConsumer n'a pas de parent !!", container);
|
|
529
|
+
document.body.append(container.current);
|
|
530
|
+
}
|
|
531
|
+
useEffect9(() => {
|
|
532
|
+
return () => {
|
|
533
|
+
container.current && container.current.remove();
|
|
534
|
+
};
|
|
535
|
+
}, []);
|
|
536
|
+
const messages = useSelector(selectMessages);
|
|
537
|
+
const dispatch = useDispatch();
|
|
538
|
+
return /* @__PURE__ */ jsxs4(Fragment, { children: [
|
|
539
|
+
children,
|
|
540
|
+
createPortal(
|
|
541
|
+
/* @__PURE__ */ jsx7("div", { className: "snack-bar-inner", children: messages.map((message) => /* @__PURE__ */ jsx7(
|
|
542
|
+
Snack,
|
|
543
|
+
{
|
|
544
|
+
...message,
|
|
545
|
+
onRemove: () => dispatch(messageRemoved(message.id))
|
|
546
|
+
},
|
|
547
|
+
message.id
|
|
548
|
+
)) }),
|
|
549
|
+
container.current
|
|
550
|
+
)
|
|
551
|
+
] });
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
// src/redux/notification/hooks/useNotification.ts
|
|
555
|
+
import { useDispatch as useDispatch2 } from "react-redux";
|
|
556
|
+
function useNotification() {
|
|
557
|
+
const dispatch = useDispatch2();
|
|
558
|
+
const notify = (content, options) => {
|
|
559
|
+
dispatch(messageAdded(content, options));
|
|
560
|
+
};
|
|
561
|
+
const notifyError = (err) => {
|
|
562
|
+
const errorMessage = parseError(err);
|
|
563
|
+
if (errorMessage) {
|
|
564
|
+
dispatch(messageAdded(...errorMessage));
|
|
565
|
+
} else {
|
|
566
|
+
throw err;
|
|
567
|
+
}
|
|
568
|
+
};
|
|
569
|
+
return {
|
|
570
|
+
notify,
|
|
571
|
+
notifyError
|
|
572
|
+
};
|
|
573
|
+
}
|
|
574
|
+
export {
|
|
575
|
+
NotificationConsumer,
|
|
576
|
+
errorAdded,
|
|
577
|
+
errorCatcherMiddleware,
|
|
578
|
+
messageAdded,
|
|
579
|
+
messageRemoved,
|
|
580
|
+
notificationSlice_default as notificationSlice,
|
|
581
|
+
selectMessages,
|
|
582
|
+
useNotification
|
|
583
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
type ThemeColor = "yellow" | "gray" | "red" | "orange" | "green" | "blue";
|
|
2
|
+
|
|
3
|
+
type MessageOptions = Partial<Omit<Message, "message" | "id">>;
|
|
4
|
+
|
|
5
|
+
interface Message {
|
|
6
|
+
id: string;
|
|
7
|
+
content: string;
|
|
8
|
+
expiration: number; // in ms. if -1 never expire
|
|
9
|
+
color: ThemeColor;
|
|
10
|
+
canClose: boolean;
|
|
11
|
+
withLoader: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type { Message as M, ThemeColor as T, MessageOptions as a };
|