@snapcall/design-system 1.0.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.
- package/README.md +38 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.js +614 -0
- package/dist/index.mjs +577 -0
- package/dist/style.css +1 -0
- package/dist/tailwind.config.js +366 -0
- package/dist/tailwind.css +3 -0
- package/package.json +66 -0
package/README.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Design System
|
|
2
|
+
|
|
3
|
+
This is SnapCall's design system, the goal is to use this library in all of our apps with the ability to re-use the same components everywhere.
|
|
4
|
+
|
|
5
|
+
Storybook preview link (based on `develop`): https://d3iwrju745oc71.cloudfront.net
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm i @snapcall/design-system
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
### Inside a Tailwind project
|
|
16
|
+
|
|
17
|
+
First, update your tailwind config:
|
|
18
|
+
|
|
19
|
+
```js
|
|
20
|
+
{
|
|
21
|
+
content: ['./node_modules/@snapcall/design-system/dist/*.{js,mjs}',],
|
|
22
|
+
presets: [require('@snapcall/design-system/dist/tailwind.config')],
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Then, include the base style at the root of your app:
|
|
27
|
+
|
|
28
|
+
```js
|
|
29
|
+
import '@snapcall/design-system/dist/style.css';
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Inside a non-Tailwind project
|
|
33
|
+
|
|
34
|
+
Include the full style at the root of your app:
|
|
35
|
+
|
|
36
|
+
```js
|
|
37
|
+
import '@snapcall/design-system/dist/tailwind.css';
|
|
38
|
+
```
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ReactElement } from 'react';
|
|
3
|
+
import { AriaButtonProps } from 'react-aria';
|
|
4
|
+
import { OverlayTriggerState, useOverlayTriggerState } from 'react-stately';
|
|
5
|
+
|
|
6
|
+
interface ButtonProps extends AriaButtonProps {
|
|
7
|
+
variant?: 'primary' | 'secondary' | 'tertiary' | 'dark' | 'gray' | 'red';
|
|
8
|
+
size?: 'large' | 'medium' | 'small' | 'extraSmall';
|
|
9
|
+
/** Only supported for secondary and red variants */
|
|
10
|
+
blank?: boolean;
|
|
11
|
+
fullWidth?: boolean;
|
|
12
|
+
form?: string;
|
|
13
|
+
}
|
|
14
|
+
declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
15
|
+
|
|
16
|
+
interface BadgeProps extends React.HTMLAttributes<HTMLSpanElement> {
|
|
17
|
+
children: React.ReactNode;
|
|
18
|
+
variant?: 'info' | 'success' | 'warning' | 'danger' | 'primary' | 'secondary' | 'basic';
|
|
19
|
+
capitalize?: boolean;
|
|
20
|
+
}
|
|
21
|
+
declare const Badge: React.FC<BadgeProps>;
|
|
22
|
+
|
|
23
|
+
interface DrawerProps {
|
|
24
|
+
state: OverlayTriggerState;
|
|
25
|
+
placement?: 'top' | 'right' | 'bottom' | 'left';
|
|
26
|
+
container?: Element;
|
|
27
|
+
children: ReactElement | ((close: () => void) => ReactElement);
|
|
28
|
+
}
|
|
29
|
+
declare const Drawer: ({ state, placement, container, children, ...props }: DrawerProps) => JSX.Element | null;
|
|
30
|
+
declare const useDrawerState: typeof useOverlayTriggerState;
|
|
31
|
+
|
|
32
|
+
export { Badge, BadgeProps, Button, ButtonProps, Drawer, DrawerProps, useDrawerState };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,614 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __defProps = Object.defineProperties;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
9
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
10
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
12
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
13
|
+
var __spreadValues = (a, b) => {
|
|
14
|
+
for (var prop in b || (b = {}))
|
|
15
|
+
if (__hasOwnProp.call(b, prop))
|
|
16
|
+
__defNormalProp(a, prop, b[prop]);
|
|
17
|
+
if (__getOwnPropSymbols)
|
|
18
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
19
|
+
if (__propIsEnum.call(b, prop))
|
|
20
|
+
__defNormalProp(a, prop, b[prop]);
|
|
21
|
+
}
|
|
22
|
+
return a;
|
|
23
|
+
};
|
|
24
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
25
|
+
var __objRest = (source, exclude) => {
|
|
26
|
+
var target = {};
|
|
27
|
+
for (var prop in source)
|
|
28
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
29
|
+
target[prop] = source[prop];
|
|
30
|
+
if (source != null && __getOwnPropSymbols)
|
|
31
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
32
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
33
|
+
target[prop] = source[prop];
|
|
34
|
+
}
|
|
35
|
+
return target;
|
|
36
|
+
};
|
|
37
|
+
var __export = (target, all) => {
|
|
38
|
+
for (var name in all)
|
|
39
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
40
|
+
};
|
|
41
|
+
var __copyProps = (to, from, except, desc) => {
|
|
42
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
43
|
+
for (let key of __getOwnPropNames(from))
|
|
44
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
45
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
46
|
+
}
|
|
47
|
+
return to;
|
|
48
|
+
};
|
|
49
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
50
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
51
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
52
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
53
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
54
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
55
|
+
mod
|
|
56
|
+
));
|
|
57
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
58
|
+
|
|
59
|
+
// src/index.tsx
|
|
60
|
+
var src_exports = {};
|
|
61
|
+
__export(src_exports, {
|
|
62
|
+
Badge: () => Badge,
|
|
63
|
+
Button: () => Button,
|
|
64
|
+
Drawer: () => Drawer,
|
|
65
|
+
useDrawerState: () => useDrawerState
|
|
66
|
+
});
|
|
67
|
+
module.exports = __toCommonJS(src_exports);
|
|
68
|
+
|
|
69
|
+
// src/components/Button/Button.tsx
|
|
70
|
+
var import_react_aria = require("react-aria");
|
|
71
|
+
|
|
72
|
+
// node_modules/@react-aria/utils/dist/import.mjs
|
|
73
|
+
var import_react = __toESM(require("react"), 1);
|
|
74
|
+
var $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c = typeof window !== "undefined" ? (0, import_react.default).useLayoutEffect : () => {
|
|
75
|
+
};
|
|
76
|
+
var $bbed8b41f857bcc0$var$transitionsByElement = /* @__PURE__ */ new Map();
|
|
77
|
+
var $bbed8b41f857bcc0$var$transitionCallbacks = /* @__PURE__ */ new Set();
|
|
78
|
+
function $bbed8b41f857bcc0$var$setupGlobalEvents() {
|
|
79
|
+
if (typeof window === "undefined")
|
|
80
|
+
return;
|
|
81
|
+
let onTransitionStart = (e) => {
|
|
82
|
+
let transitions = $bbed8b41f857bcc0$var$transitionsByElement.get(e.target);
|
|
83
|
+
if (!transitions) {
|
|
84
|
+
transitions = /* @__PURE__ */ new Set();
|
|
85
|
+
$bbed8b41f857bcc0$var$transitionsByElement.set(e.target, transitions);
|
|
86
|
+
e.target.addEventListener("transitioncancel", onTransitionEnd);
|
|
87
|
+
}
|
|
88
|
+
transitions.add(e.propertyName);
|
|
89
|
+
};
|
|
90
|
+
let onTransitionEnd = (e) => {
|
|
91
|
+
let properties = $bbed8b41f857bcc0$var$transitionsByElement.get(e.target);
|
|
92
|
+
if (!properties)
|
|
93
|
+
return;
|
|
94
|
+
properties.delete(e.propertyName);
|
|
95
|
+
if (properties.size === 0) {
|
|
96
|
+
e.target.removeEventListener("transitioncancel", onTransitionEnd);
|
|
97
|
+
$bbed8b41f857bcc0$var$transitionsByElement.delete(e.target);
|
|
98
|
+
}
|
|
99
|
+
if ($bbed8b41f857bcc0$var$transitionsByElement.size === 0) {
|
|
100
|
+
for (let cb of $bbed8b41f857bcc0$var$transitionCallbacks)
|
|
101
|
+
cb();
|
|
102
|
+
$bbed8b41f857bcc0$var$transitionCallbacks.clear();
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
document.body.addEventListener("transitionrun", onTransitionStart);
|
|
106
|
+
document.body.addEventListener("transitionend", onTransitionEnd);
|
|
107
|
+
}
|
|
108
|
+
if (typeof document !== "undefined") {
|
|
109
|
+
if (document.readyState !== "loading")
|
|
110
|
+
$bbed8b41f857bcc0$var$setupGlobalEvents();
|
|
111
|
+
else
|
|
112
|
+
document.addEventListener("DOMContentLoaded", $bbed8b41f857bcc0$var$setupGlobalEvents);
|
|
113
|
+
}
|
|
114
|
+
var $5df64b3807dc15ee$var$visualViewport = typeof window !== "undefined" && window.visualViewport;
|
|
115
|
+
function $c87311424ea30a05$var$testUserAgent(re) {
|
|
116
|
+
var _window_navigator_userAgentData;
|
|
117
|
+
if (typeof window === "undefined" || window.navigator == null)
|
|
118
|
+
return false;
|
|
119
|
+
return ((_window_navigator_userAgentData = window.navigator["userAgentData"]) === null || _window_navigator_userAgentData === void 0 ? void 0 : _window_navigator_userAgentData.brands.some((brand) => re.test(brand.brand))) || re.test(window.navigator.userAgent);
|
|
120
|
+
}
|
|
121
|
+
function $c87311424ea30a05$var$testPlatform(re) {
|
|
122
|
+
var _window_navigator_userAgentData;
|
|
123
|
+
return typeof window !== "undefined" && window.navigator != null ? re.test(((_window_navigator_userAgentData = window.navigator["userAgentData"]) === null || _window_navigator_userAgentData === void 0 ? void 0 : _window_navigator_userAgentData.platform) || window.navigator.platform) : false;
|
|
124
|
+
}
|
|
125
|
+
function $c87311424ea30a05$export$9ac100e40613ea10() {
|
|
126
|
+
return $c87311424ea30a05$var$testPlatform(/^Mac/i);
|
|
127
|
+
}
|
|
128
|
+
function $c87311424ea30a05$export$a11b0059900ceec8() {
|
|
129
|
+
return $c87311424ea30a05$var$testUserAgent(/Android/i);
|
|
130
|
+
}
|
|
131
|
+
function $6a7db85432448f7f$export$60278871457622de(event) {
|
|
132
|
+
if (event.mozInputSource === 0 && event.isTrusted)
|
|
133
|
+
return true;
|
|
134
|
+
if ((0, $c87311424ea30a05$export$a11b0059900ceec8)() && event.pointerType)
|
|
135
|
+
return event.type === "click" && event.buttons === 1;
|
|
136
|
+
return event.detail === 0 && !event.pointerType;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// node_modules/@react-aria/interactions/dist/import.mjs
|
|
140
|
+
var import_react2 = __toESM(require("react"), 1);
|
|
141
|
+
var $ae1eeba8b9eafd08$export$5165eccb35aaadb5 = (0, import_react2.default).createContext(null);
|
|
142
|
+
$ae1eeba8b9eafd08$export$5165eccb35aaadb5.displayName = "PressResponderContext";
|
|
143
|
+
var $507fabe10e71c6fb$var$currentModality = null;
|
|
144
|
+
var $507fabe10e71c6fb$var$changeHandlers = /* @__PURE__ */ new Set();
|
|
145
|
+
var $507fabe10e71c6fb$var$hasSetupGlobalListeners = false;
|
|
146
|
+
var $507fabe10e71c6fb$var$hasEventBeforeFocus = false;
|
|
147
|
+
var $507fabe10e71c6fb$var$hasBlurredWindowRecently = false;
|
|
148
|
+
function $507fabe10e71c6fb$var$triggerChangeHandlers(modality, e) {
|
|
149
|
+
for (let handler of $507fabe10e71c6fb$var$changeHandlers)
|
|
150
|
+
handler(modality, e);
|
|
151
|
+
}
|
|
152
|
+
function $507fabe10e71c6fb$var$isValidKey(e) {
|
|
153
|
+
return !(e.metaKey || !(0, $c87311424ea30a05$export$9ac100e40613ea10)() && e.altKey || e.ctrlKey || e.key === "Control" || e.key === "Shift" || e.key === "Meta");
|
|
154
|
+
}
|
|
155
|
+
function $507fabe10e71c6fb$var$handleKeyboardEvent(e) {
|
|
156
|
+
$507fabe10e71c6fb$var$hasEventBeforeFocus = true;
|
|
157
|
+
if ($507fabe10e71c6fb$var$isValidKey(e)) {
|
|
158
|
+
$507fabe10e71c6fb$var$currentModality = "keyboard";
|
|
159
|
+
$507fabe10e71c6fb$var$triggerChangeHandlers("keyboard", e);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
function $507fabe10e71c6fb$var$handlePointerEvent(e) {
|
|
163
|
+
$507fabe10e71c6fb$var$currentModality = "pointer";
|
|
164
|
+
if (e.type === "mousedown" || e.type === "pointerdown") {
|
|
165
|
+
$507fabe10e71c6fb$var$hasEventBeforeFocus = true;
|
|
166
|
+
$507fabe10e71c6fb$var$triggerChangeHandlers("pointer", e);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
function $507fabe10e71c6fb$var$handleClickEvent(e) {
|
|
170
|
+
if ((0, $6a7db85432448f7f$export$60278871457622de)(e)) {
|
|
171
|
+
$507fabe10e71c6fb$var$hasEventBeforeFocus = true;
|
|
172
|
+
$507fabe10e71c6fb$var$currentModality = "virtual";
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
function $507fabe10e71c6fb$var$handleFocusEvent(e) {
|
|
176
|
+
if (e.target === window || e.target === document)
|
|
177
|
+
return;
|
|
178
|
+
if (!$507fabe10e71c6fb$var$hasEventBeforeFocus && !$507fabe10e71c6fb$var$hasBlurredWindowRecently) {
|
|
179
|
+
$507fabe10e71c6fb$var$currentModality = "virtual";
|
|
180
|
+
$507fabe10e71c6fb$var$triggerChangeHandlers("virtual", e);
|
|
181
|
+
}
|
|
182
|
+
$507fabe10e71c6fb$var$hasEventBeforeFocus = false;
|
|
183
|
+
$507fabe10e71c6fb$var$hasBlurredWindowRecently = false;
|
|
184
|
+
}
|
|
185
|
+
function $507fabe10e71c6fb$var$handleWindowBlur() {
|
|
186
|
+
$507fabe10e71c6fb$var$hasEventBeforeFocus = false;
|
|
187
|
+
$507fabe10e71c6fb$var$hasBlurredWindowRecently = true;
|
|
188
|
+
}
|
|
189
|
+
function $507fabe10e71c6fb$var$setupGlobalFocusEvents() {
|
|
190
|
+
if (typeof window === "undefined" || $507fabe10e71c6fb$var$hasSetupGlobalListeners)
|
|
191
|
+
return;
|
|
192
|
+
let focus = HTMLElement.prototype.focus;
|
|
193
|
+
HTMLElement.prototype.focus = function() {
|
|
194
|
+
$507fabe10e71c6fb$var$hasEventBeforeFocus = true;
|
|
195
|
+
focus.apply(this, arguments);
|
|
196
|
+
};
|
|
197
|
+
document.addEventListener("keydown", $507fabe10e71c6fb$var$handleKeyboardEvent, true);
|
|
198
|
+
document.addEventListener("keyup", $507fabe10e71c6fb$var$handleKeyboardEvent, true);
|
|
199
|
+
document.addEventListener("click", $507fabe10e71c6fb$var$handleClickEvent, true);
|
|
200
|
+
window.addEventListener("focus", $507fabe10e71c6fb$var$handleFocusEvent, true);
|
|
201
|
+
window.addEventListener("blur", $507fabe10e71c6fb$var$handleWindowBlur, false);
|
|
202
|
+
if (typeof PointerEvent !== "undefined") {
|
|
203
|
+
document.addEventListener("pointerdown", $507fabe10e71c6fb$var$handlePointerEvent, true);
|
|
204
|
+
document.addEventListener("pointermove", $507fabe10e71c6fb$var$handlePointerEvent, true);
|
|
205
|
+
document.addEventListener("pointerup", $507fabe10e71c6fb$var$handlePointerEvent, true);
|
|
206
|
+
} else {
|
|
207
|
+
document.addEventListener("mousedown", $507fabe10e71c6fb$var$handlePointerEvent, true);
|
|
208
|
+
document.addEventListener("mousemove", $507fabe10e71c6fb$var$handlePointerEvent, true);
|
|
209
|
+
document.addEventListener("mouseup", $507fabe10e71c6fb$var$handlePointerEvent, true);
|
|
210
|
+
}
|
|
211
|
+
$507fabe10e71c6fb$var$hasSetupGlobalListeners = true;
|
|
212
|
+
}
|
|
213
|
+
if (typeof document !== "undefined") {
|
|
214
|
+
if (document.readyState !== "loading")
|
|
215
|
+
$507fabe10e71c6fb$var$setupGlobalFocusEvents();
|
|
216
|
+
else
|
|
217
|
+
document.addEventListener("DOMContentLoaded", $507fabe10e71c6fb$var$setupGlobalFocusEvents);
|
|
218
|
+
}
|
|
219
|
+
var $6179b936705e76d3$var$globalIgnoreEmulatedMouseEvents = false;
|
|
220
|
+
var $6179b936705e76d3$var$hoverCount = 0;
|
|
221
|
+
function $6179b936705e76d3$var$setGlobalIgnoreEmulatedMouseEvents() {
|
|
222
|
+
$6179b936705e76d3$var$globalIgnoreEmulatedMouseEvents = true;
|
|
223
|
+
setTimeout(() => {
|
|
224
|
+
$6179b936705e76d3$var$globalIgnoreEmulatedMouseEvents = false;
|
|
225
|
+
}, 50);
|
|
226
|
+
}
|
|
227
|
+
function $6179b936705e76d3$var$handleGlobalPointerEvent(e) {
|
|
228
|
+
if (e.pointerType === "touch")
|
|
229
|
+
$6179b936705e76d3$var$setGlobalIgnoreEmulatedMouseEvents();
|
|
230
|
+
}
|
|
231
|
+
function $6179b936705e76d3$var$setupGlobalTouchEvents() {
|
|
232
|
+
if (typeof document === "undefined")
|
|
233
|
+
return;
|
|
234
|
+
if (typeof PointerEvent !== "undefined")
|
|
235
|
+
document.addEventListener("pointerup", $6179b936705e76d3$var$handleGlobalPointerEvent);
|
|
236
|
+
else
|
|
237
|
+
document.addEventListener("touchend", $6179b936705e76d3$var$setGlobalIgnoreEmulatedMouseEvents);
|
|
238
|
+
$6179b936705e76d3$var$hoverCount++;
|
|
239
|
+
return () => {
|
|
240
|
+
$6179b936705e76d3$var$hoverCount--;
|
|
241
|
+
if ($6179b936705e76d3$var$hoverCount > 0)
|
|
242
|
+
return;
|
|
243
|
+
if (typeof PointerEvent !== "undefined")
|
|
244
|
+
document.removeEventListener("pointerup", $6179b936705e76d3$var$handleGlobalPointerEvent);
|
|
245
|
+
else
|
|
246
|
+
document.removeEventListener("touchend", $6179b936705e76d3$var$setGlobalIgnoreEmulatedMouseEvents);
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
function $6179b936705e76d3$export$ae780daf29e6d456(props) {
|
|
250
|
+
let { onHoverStart, onHoverChange, onHoverEnd, isDisabled } = props;
|
|
251
|
+
let [isHovered, setHovered] = (0, import_react2.useState)(false);
|
|
252
|
+
let state = (0, import_react2.useRef)({
|
|
253
|
+
isHovered: false,
|
|
254
|
+
ignoreEmulatedMouseEvents: false,
|
|
255
|
+
pointerType: "",
|
|
256
|
+
target: null
|
|
257
|
+
}).current;
|
|
258
|
+
(0, import_react2.useEffect)($6179b936705e76d3$var$setupGlobalTouchEvents, []);
|
|
259
|
+
let { hoverProps, triggerHoverEnd } = (0, import_react2.useMemo)(() => {
|
|
260
|
+
let triggerHoverStart = (event, pointerType) => {
|
|
261
|
+
state.pointerType = pointerType;
|
|
262
|
+
if (isDisabled || pointerType === "touch" || state.isHovered || !event.currentTarget.contains(event.target))
|
|
263
|
+
return;
|
|
264
|
+
state.isHovered = true;
|
|
265
|
+
let target = event.currentTarget;
|
|
266
|
+
state.target = target;
|
|
267
|
+
if (onHoverStart)
|
|
268
|
+
onHoverStart({
|
|
269
|
+
type: "hoverstart",
|
|
270
|
+
target,
|
|
271
|
+
pointerType
|
|
272
|
+
});
|
|
273
|
+
if (onHoverChange)
|
|
274
|
+
onHoverChange(true);
|
|
275
|
+
setHovered(true);
|
|
276
|
+
};
|
|
277
|
+
let triggerHoverEnd2 = (event, pointerType) => {
|
|
278
|
+
state.pointerType = "";
|
|
279
|
+
state.target = null;
|
|
280
|
+
if (pointerType === "touch" || !state.isHovered)
|
|
281
|
+
return;
|
|
282
|
+
state.isHovered = false;
|
|
283
|
+
let target = event.currentTarget;
|
|
284
|
+
if (onHoverEnd)
|
|
285
|
+
onHoverEnd({
|
|
286
|
+
type: "hoverend",
|
|
287
|
+
target,
|
|
288
|
+
pointerType
|
|
289
|
+
});
|
|
290
|
+
if (onHoverChange)
|
|
291
|
+
onHoverChange(false);
|
|
292
|
+
setHovered(false);
|
|
293
|
+
};
|
|
294
|
+
let hoverProps2 = {};
|
|
295
|
+
if (typeof PointerEvent !== "undefined") {
|
|
296
|
+
hoverProps2.onPointerEnter = (e) => {
|
|
297
|
+
if ($6179b936705e76d3$var$globalIgnoreEmulatedMouseEvents && e.pointerType === "mouse")
|
|
298
|
+
return;
|
|
299
|
+
triggerHoverStart(e, e.pointerType);
|
|
300
|
+
};
|
|
301
|
+
hoverProps2.onPointerLeave = (e) => {
|
|
302
|
+
if (!isDisabled && e.currentTarget.contains(e.target))
|
|
303
|
+
triggerHoverEnd2(e, e.pointerType);
|
|
304
|
+
};
|
|
305
|
+
} else {
|
|
306
|
+
hoverProps2.onTouchStart = () => {
|
|
307
|
+
state.ignoreEmulatedMouseEvents = true;
|
|
308
|
+
};
|
|
309
|
+
hoverProps2.onMouseEnter = (e) => {
|
|
310
|
+
if (!state.ignoreEmulatedMouseEvents && !$6179b936705e76d3$var$globalIgnoreEmulatedMouseEvents)
|
|
311
|
+
triggerHoverStart(e, "mouse");
|
|
312
|
+
state.ignoreEmulatedMouseEvents = false;
|
|
313
|
+
};
|
|
314
|
+
hoverProps2.onMouseLeave = (e) => {
|
|
315
|
+
if (!isDisabled && e.currentTarget.contains(e.target))
|
|
316
|
+
triggerHoverEnd2(e, "mouse");
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
return {
|
|
320
|
+
hoverProps: hoverProps2,
|
|
321
|
+
triggerHoverEnd: triggerHoverEnd2
|
|
322
|
+
};
|
|
323
|
+
}, [
|
|
324
|
+
onHoverStart,
|
|
325
|
+
onHoverChange,
|
|
326
|
+
onHoverEnd,
|
|
327
|
+
isDisabled,
|
|
328
|
+
state
|
|
329
|
+
]);
|
|
330
|
+
(0, import_react2.useEffect)(() => {
|
|
331
|
+
if (isDisabled)
|
|
332
|
+
triggerHoverEnd({
|
|
333
|
+
currentTarget: state.target
|
|
334
|
+
}, state.pointerType);
|
|
335
|
+
}, [
|
|
336
|
+
isDisabled
|
|
337
|
+
]);
|
|
338
|
+
return {
|
|
339
|
+
hoverProps,
|
|
340
|
+
isHovered
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
// src/components/Button/Button.tsx
|
|
345
|
+
var import_react4 = require("react");
|
|
346
|
+
var import_classnames = __toESM(require("classnames"));
|
|
347
|
+
|
|
348
|
+
// src/utils/useForwardedRef.ts
|
|
349
|
+
var import_react3 = require("react");
|
|
350
|
+
function useForwardedRef(ref) {
|
|
351
|
+
const innerRef = (0, import_react3.useRef)(null);
|
|
352
|
+
(0, import_react3.useEffect)(() => {
|
|
353
|
+
if (!ref)
|
|
354
|
+
return;
|
|
355
|
+
if (typeof ref === "function") {
|
|
356
|
+
ref(innerRef.current);
|
|
357
|
+
} else {
|
|
358
|
+
ref.current = innerRef.current;
|
|
359
|
+
}
|
|
360
|
+
});
|
|
361
|
+
return innerRef;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
// src/components/Button/Button.tsx
|
|
365
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
366
|
+
var Button = (0, import_react4.forwardRef)(
|
|
367
|
+
function Button2(_a, forwardedRef) {
|
|
368
|
+
var _b = _a, {
|
|
369
|
+
children,
|
|
370
|
+
variant = "primary",
|
|
371
|
+
size = "medium",
|
|
372
|
+
blank = false,
|
|
373
|
+
fullWidth = false,
|
|
374
|
+
form
|
|
375
|
+
} = _b, otherProps = __objRest(_b, [
|
|
376
|
+
"children",
|
|
377
|
+
"variant",
|
|
378
|
+
"size",
|
|
379
|
+
"blank",
|
|
380
|
+
"fullWidth",
|
|
381
|
+
"form"
|
|
382
|
+
]);
|
|
383
|
+
const ref = useForwardedRef(forwardedRef);
|
|
384
|
+
const { buttonProps, isPressed } = (0, import_react_aria.useButton)(otherProps, ref);
|
|
385
|
+
const { isFocused, isFocusVisible, focusProps } = (0, import_react_aria.useFocusRing)();
|
|
386
|
+
const { hoverProps, isHovered } = $6179b936705e76d3$export$ae780daf29e6d456({
|
|
387
|
+
isDisabled: buttonProps.disabled
|
|
388
|
+
});
|
|
389
|
+
const variantStyle = {
|
|
390
|
+
primary: (0, import_classnames.default)("text-white border-transparent", {
|
|
391
|
+
"bg-blue-700": !isHovered && !isPressed,
|
|
392
|
+
"bg-blue-800": isHovered && !isPressed,
|
|
393
|
+
"bg-blue-900": isPressed,
|
|
394
|
+
"outline-blue-1000": isFocusVisible
|
|
395
|
+
}),
|
|
396
|
+
secondary: (0, import_classnames.default)("text-blue-700 border-transparent", {
|
|
397
|
+
"bg-gray-50": !blank && !isHovered && !isPressed,
|
|
398
|
+
"bg-blue-100": isHovered && !isPressed,
|
|
399
|
+
"bg-blue-200": isPressed,
|
|
400
|
+
"outline-blue-700": isFocusVisible
|
|
401
|
+
}),
|
|
402
|
+
tertiary: (0, import_classnames.default)("text-gray-1000 border-gray-600", {
|
|
403
|
+
"bg-transparent": !isHovered && !isPressed,
|
|
404
|
+
"bg-gray-50": isHovered && !isPressed,
|
|
405
|
+
"bg-gray-200": isPressed,
|
|
406
|
+
"outline-gray-1000": isFocusVisible
|
|
407
|
+
}),
|
|
408
|
+
dark: (0, import_classnames.default)("text-white border-transparent", {
|
|
409
|
+
"bg-gray-1000": !isHovered && !isPressed,
|
|
410
|
+
"bg-gray-800": isHovered && !isPressed,
|
|
411
|
+
"bg-gray-900": isPressed,
|
|
412
|
+
"outline-gray-600": isFocusVisible
|
|
413
|
+
}),
|
|
414
|
+
gray: (0, import_classnames.default)("text-gray-1000 border-transparent", {
|
|
415
|
+
"bg-gray-50": !isHovered && !isPressed,
|
|
416
|
+
"bg-gray-300": isHovered && !isPressed,
|
|
417
|
+
"bg-gray-500": isPressed,
|
|
418
|
+
"outline-gray-1000": isFocusVisible
|
|
419
|
+
}),
|
|
420
|
+
red: (0, import_classnames.default)("text-red-700 border-transparent", {
|
|
421
|
+
"bg-gray-50": !blank && !isHovered && !isPressed,
|
|
422
|
+
"bg-red-100": isHovered && !isPressed,
|
|
423
|
+
"bg-red-200": isPressed,
|
|
424
|
+
"outline-red-700": isFocusVisible
|
|
425
|
+
})
|
|
426
|
+
};
|
|
427
|
+
const sizeStyle = {
|
|
428
|
+
large: "py-2.5 px-5 text-md rounded-lg gap-2",
|
|
429
|
+
medium: "py-1.5 px-3.5 text-md rounded-lg gap-2",
|
|
430
|
+
small: "py-[5px] px-3 text-sm rounded-md gap-2",
|
|
431
|
+
extraSmall: "py-1 px-2.5 text-sm rounded gap-[5px]"
|
|
432
|
+
};
|
|
433
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
434
|
+
"button",
|
|
435
|
+
__spreadProps(__spreadValues(__spreadValues(__spreadValues({
|
|
436
|
+
className: (0, import_classnames.default)(
|
|
437
|
+
sizeStyle[size],
|
|
438
|
+
variantStyle[variant],
|
|
439
|
+
"flex items-center justify-center font-medium border",
|
|
440
|
+
"transition-colors ease-in-out",
|
|
441
|
+
{
|
|
442
|
+
"outline-none": isFocused && !isFocusVisible,
|
|
443
|
+
"outline outline-2 outline-offset-0": isFocusVisible,
|
|
444
|
+
"cursor-not-allowed opacity-50": buttonProps.disabled,
|
|
445
|
+
"w-full": fullWidth
|
|
446
|
+
}
|
|
447
|
+
)
|
|
448
|
+
}, buttonProps), focusProps), hoverProps), {
|
|
449
|
+
form,
|
|
450
|
+
ref,
|
|
451
|
+
children
|
|
452
|
+
})
|
|
453
|
+
);
|
|
454
|
+
}
|
|
455
|
+
);
|
|
456
|
+
|
|
457
|
+
// src/components/Badge/Badge.tsx
|
|
458
|
+
var import_classnames2 = __toESM(require("classnames"));
|
|
459
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
460
|
+
var Badge = ({
|
|
461
|
+
children,
|
|
462
|
+
variant = "primary",
|
|
463
|
+
capitalize = true
|
|
464
|
+
}) => {
|
|
465
|
+
const colorStyle = {
|
|
466
|
+
info: "bg-[#F0F7FF] text-cta",
|
|
467
|
+
success: "bg-[#F1FFF1] text-[#53AB53]",
|
|
468
|
+
warning: "bg-[#FFF5DC] text-[#FFB800]",
|
|
469
|
+
danger: "bg-[#FFF3F1] text-[#E42525]",
|
|
470
|
+
primary: "bg-primary text-graySelected",
|
|
471
|
+
secondary: "bg-graySelected text-primaryLight",
|
|
472
|
+
basic: "bg-transparent text-primaryLight border border-primaryLight"
|
|
473
|
+
};
|
|
474
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
475
|
+
"span",
|
|
476
|
+
{
|
|
477
|
+
className: (0, import_classnames2.default)("px-2 py-[2px] text-xs rounded-md whitespace-nowrap", colorStyle[variant], {
|
|
478
|
+
capitalize
|
|
479
|
+
}),
|
|
480
|
+
children
|
|
481
|
+
}
|
|
482
|
+
);
|
|
483
|
+
};
|
|
484
|
+
|
|
485
|
+
// src/components/Drawer/Drawer.tsx
|
|
486
|
+
var import_react5 = require("react");
|
|
487
|
+
var import_react_aria2 = require("react-aria");
|
|
488
|
+
var import_react_stately = require("react-stately");
|
|
489
|
+
var import_react_transition_group = require("react-transition-group");
|
|
490
|
+
var import_classnames3 = __toESM(require("classnames"));
|
|
491
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
492
|
+
var placementsStyle = {
|
|
493
|
+
top: {
|
|
494
|
+
container: " items-start justify-center",
|
|
495
|
+
transition: {
|
|
496
|
+
appear: "-translate-y-full",
|
|
497
|
+
appearDone: "translate-y-0",
|
|
498
|
+
exit: "-translate-y-full"
|
|
499
|
+
}
|
|
500
|
+
},
|
|
501
|
+
right: {
|
|
502
|
+
container: "justify-end",
|
|
503
|
+
transition: {
|
|
504
|
+
appear: "translate-x-full",
|
|
505
|
+
appearDone: "translate-x-0",
|
|
506
|
+
exit: "translate-x-full"
|
|
507
|
+
}
|
|
508
|
+
},
|
|
509
|
+
bottom: {
|
|
510
|
+
container: " items-end justify-center",
|
|
511
|
+
transition: {
|
|
512
|
+
appear: "translate-y-full",
|
|
513
|
+
appearDone: "translate-y-0",
|
|
514
|
+
exit: "translate-y-full"
|
|
515
|
+
}
|
|
516
|
+
},
|
|
517
|
+
left: {
|
|
518
|
+
container: "justify-start",
|
|
519
|
+
transition: {
|
|
520
|
+
appear: "-translate-x-full",
|
|
521
|
+
appearDone: "translate-x-0",
|
|
522
|
+
exit: "-translate-x-full"
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
};
|
|
526
|
+
var Drawer = (_a) => {
|
|
527
|
+
var _b = _a, {
|
|
528
|
+
state,
|
|
529
|
+
placement = "left",
|
|
530
|
+
container,
|
|
531
|
+
children
|
|
532
|
+
} = _b, props = __objRest(_b, [
|
|
533
|
+
"state",
|
|
534
|
+
"placement",
|
|
535
|
+
"container",
|
|
536
|
+
"children"
|
|
537
|
+
]);
|
|
538
|
+
const ref = (0, import_react5.useRef)(null);
|
|
539
|
+
const [exited, setExited] = (0, import_react5.useState)(!state.isOpen);
|
|
540
|
+
const { modalProps, underlayProps } = (0, import_react_aria2.useModalOverlay)(
|
|
541
|
+
__spreadValues({
|
|
542
|
+
isDismissable: true
|
|
543
|
+
}, props),
|
|
544
|
+
state,
|
|
545
|
+
ref
|
|
546
|
+
);
|
|
547
|
+
if (!(state.isOpen || !exited)) {
|
|
548
|
+
return null;
|
|
549
|
+
}
|
|
550
|
+
const placementStyle = placementsStyle[placement];
|
|
551
|
+
const position = container ? "absolute" : "fixed";
|
|
552
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react_aria2.Overlay, { portalContainer: container, children: [
|
|
553
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
554
|
+
import_react_transition_group.CSSTransition,
|
|
555
|
+
{
|
|
556
|
+
in: state.isOpen,
|
|
557
|
+
appear: true,
|
|
558
|
+
onEntered: () => setExited(false),
|
|
559
|
+
onExited: () => setExited(true),
|
|
560
|
+
timeout: { enter: 0, exit: 300 },
|
|
561
|
+
classNames: {
|
|
562
|
+
appear: "opacity-0",
|
|
563
|
+
appearDone: "opacity-1",
|
|
564
|
+
exit: "opacity-0"
|
|
565
|
+
},
|
|
566
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
567
|
+
"div",
|
|
568
|
+
{
|
|
569
|
+
className: (0, import_classnames3.default)(
|
|
570
|
+
"z-50 inset-0 bg-black/50 transition-opacity duration-300",
|
|
571
|
+
position
|
|
572
|
+
)
|
|
573
|
+
}
|
|
574
|
+
)
|
|
575
|
+
}
|
|
576
|
+
),
|
|
577
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
578
|
+
"div",
|
|
579
|
+
__spreadProps(__spreadValues({
|
|
580
|
+
className: (0, import_classnames3.default)("z-50 inset-0 flex", position, placementStyle.container)
|
|
581
|
+
}, underlayProps), {
|
|
582
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
583
|
+
import_react_transition_group.CSSTransition,
|
|
584
|
+
{
|
|
585
|
+
in: state.isOpen,
|
|
586
|
+
appear: true,
|
|
587
|
+
nodeRef: ref,
|
|
588
|
+
timeout: { enter: 0, exit: 300 },
|
|
589
|
+
classNames: placementStyle.transition,
|
|
590
|
+
children: (0, import_react5.cloneElement)(
|
|
591
|
+
typeof children === "function" ? children(state.close) : children,
|
|
592
|
+
__spreadValues({
|
|
593
|
+
ref,
|
|
594
|
+
style: {
|
|
595
|
+
transitionProperty: "transform",
|
|
596
|
+
transitionTimingFunction: "cubic-bezier(0.4, 0, 0.2, 1)",
|
|
597
|
+
transitionDuration: "300ms"
|
|
598
|
+
}
|
|
599
|
+
}, modalProps)
|
|
600
|
+
)
|
|
601
|
+
}
|
|
602
|
+
)
|
|
603
|
+
})
|
|
604
|
+
)
|
|
605
|
+
] });
|
|
606
|
+
};
|
|
607
|
+
var useDrawerState = import_react_stately.useOverlayTriggerState;
|
|
608
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
609
|
+
0 && (module.exports = {
|
|
610
|
+
Badge,
|
|
611
|
+
Button,
|
|
612
|
+
Drawer,
|
|
613
|
+
useDrawerState
|
|
614
|
+
});
|