@blockle/blocks 0.1.0 → 0.2.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/LICENSE +1 -1
- package/README.md +43 -12
- package/dist/index.cjs +3136 -0
- package/dist/index.d.ts +1 -28
- package/dist/index.mjs +3136 -0
- package/dist/reset.css.cjs +5 -0
- package/dist/reset.css.d.ts +295 -0
- package/dist/reset.css.mjs +4 -0
- package/dist/side-effects/lib/css/atoms/atoms.cjs +2 -0
- package/dist/side-effects/lib/css/atoms/atoms.mjs +1 -0
- package/dist/side-effects/themes/momotaro/index.cjs +2 -0
- package/dist/side-effects/themes/momotaro/index.mjs +1 -0
- package/dist/styles/lib/css/atoms/atomicProperties.cjs +69 -0
- package/dist/styles/lib/css/atoms/atomicProperties.mjs +70 -0
- package/dist/styles/lib/css/atoms/breakpoints.cjs +11 -0
- package/dist/styles/lib/css/atoms/breakpoints.mjs +12 -0
- package/dist/styles/lib/css/atoms/sprinkles.css.cjs +45 -0
- package/dist/styles/lib/css/atoms/sprinkles.css.mjs +46 -0
- package/dist/styles/lib/css/reset/reset.css.cjs +36 -0
- package/dist/styles/lib/css/reset/reset.css.mjs +35 -0
- package/dist/styles/lib/css/theme/makeTheme.cjs +10 -0
- package/dist/styles/lib/css/theme/makeTheme.mjs +11 -0
- package/dist/styles/lib/css/theme/makeVanillaTheme.cjs +15 -0
- package/dist/styles/lib/css/theme/makeVanillaTheme.mjs +16 -0
- package/dist/styles/lib/css/theme/tokens.cjs +70 -0
- package/dist/styles/lib/css/theme/tokens.mjs +71 -0
- package/dist/styles/lib/css/theme/vars.css.cjs +9 -0
- package/dist/styles/lib/css/theme/vars.css.mjs +10 -0
- package/dist/styles/themes/momotaro/momotaroTheme.css.cjs +11 -0
- package/dist/styles/themes/momotaro/momotaroTheme.css.mjs +12 -0
- package/dist/styles/themes/momotaro/tokens.cjs +70 -0
- package/dist/styles/themes/momotaro/tokens.mjs +71 -0
- package/dist/themes/momotaro.cjs +4 -0
- package/dist/themes/momotaro.d.ts +1 -0
- package/dist/themes/momotaro.mjs +4 -0
- package/package.json +57 -79
- package/reset.css/index.d.ts +1 -0
- package/reset.css/package.json +5 -0
- package/themes/momotaro/index.d.ts +1 -0
- package/themes/momotaro/package.json +5 -0
- package/dist/Badge/Badge.d.ts +0 -7
- package/dist/Badge/Badge.spec.d.ts +0 -1
- package/dist/Badge/Badge.stories.d.ts +0 -1
- package/dist/Badge/index.d.ts +0 -1
- package/dist/Box/Box.d.ts +0 -10
- package/dist/Box/index.d.ts +0 -1
- package/dist/Button/Button.d.ts +0 -13
- package/dist/Button/Button.spec.d.ts +0 -1
- package/dist/Button/Button.stories.d.ts +0 -1
- package/dist/Button/index.d.ts +0 -1
- package/dist/Card/Card.d.ts +0 -11
- package/dist/Card/Card.spec.d.ts +0 -1
- package/dist/Card/Card.stories.d.ts +0 -1
- package/dist/Card/index.d.ts +0 -1
- package/dist/Dialog/Dialog.d.ts +0 -13
- package/dist/Dialog/index.d.ts +0 -1
- package/dist/Divider/Divider.d.ts +0 -4
- package/dist/Divider/index.d.ts +0 -1
- package/dist/Drawer/Drawer.d.ts +0 -10
- package/dist/Drawer/index.d.ts +0 -1
- package/dist/Dropdown/Dropdown.d.ts +0 -17
- package/dist/Dropdown/index.d.ts +0 -1
- package/dist/FlatButton/FlatButton.d.ts +0 -15
- package/dist/FlatButton/index.d.ts +0 -1
- package/dist/Grid/Grid.d.ts +0 -10
- package/dist/Grid/index.d.ts +0 -1
- package/dist/Icon/Icon.d.ts +0 -26
- package/dist/Icon/Icon.spec.d.ts +0 -1
- package/dist/Icon/index.d.ts +0 -1
- package/dist/IconButton/IconButton.d.ts +0 -12
- package/dist/IconButton/index.d.ts +0 -1
- package/dist/Inline/Inline.d.ts +0 -8
- package/dist/Inline/index.d.ts +0 -1
- package/dist/Link/Link.d.ts +0 -9
- package/dist/Link/index.d.ts +0 -1
- package/dist/Loader/Loader.d.ts +0 -4
- package/dist/Loader/index.d.ts +0 -1
- package/dist/OutlineButton/OutlineButton.d.ts +0 -12
- package/dist/OutlineButton/index.d.ts +0 -1
- package/dist/Panel/Panel.d.ts +0 -10
- package/dist/Panel/index.d.ts +0 -1
- package/dist/Paper/Paper.d.ts +0 -14
- package/dist/Paper/Paper.spec.d.ts +0 -1
- package/dist/Paper/index.d.ts +0 -1
- package/dist/RippleBox/RippleBox.d.ts +0 -8
- package/dist/RippleBox/createRipple.d.ts +0 -2
- package/dist/RippleBox/index.d.ts +0 -1
- package/dist/Stack/Stack.d.ts +0 -13
- package/dist/Stack/index.d.ts +0 -1
- package/dist/Tag/Tag.d.ts +0 -8
- package/dist/Tag/index.d.ts +0 -1
- package/dist/Text/Text.d.ts +0 -10
- package/dist/Text/Text.spec.d.ts +0 -1
- package/dist/Text/index.d.ts +0 -1
- package/dist/TextField/TextField.d.ts +0 -22
- package/dist/TextField/TextField.stories.d.ts +0 -1
- package/dist/TextField/index.d.ts +0 -1
- package/dist/blockle-blocks.esm.js +0 -823
- package/dist/blockle-blocks.js +0 -854
- package/dist/blocks.css +0 -2554
- package/dist/blocks.css.map +0 -1
- package/dist/cx.d.ts +0 -3
- package/dist/setupTests.d.ts +0 -1
- package/dist/useAnimationState/index.d.ts +0 -1
- package/dist/useAnimationState/useAnimationState.d.ts +0 -6
- package/dist/useFlip/animate.d.ts +0 -14
- package/dist/useFlip/index.d.ts +0 -1
- package/dist/useFlip/useFlip.d.ts +0 -8
- package/dist/useLayer/index.d.ts +0 -1
- package/dist/useLayer/useLayer.d.ts +0 -1
- package/dist/useStyles/blocks.d.ts +0 -34
- package/dist/useStyles/index.d.ts +0 -2
- package/dist/useStyles/useStyles.d.ts +0 -3
- package/dist/utils/animate/animateCss.d.ts +0 -11
- package/dist/utils/animate/index.d.ts +0 -1
- package/dist/utils/getEventPosition.d.ts +0 -6
- package/dist/utils/index.d.ts +0 -1
|
@@ -1,823 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @blockle/blocks v0.1.0
|
|
3
|
-
* (C) 2020-2021 Niek Saarberg
|
|
4
|
-
* Released under the MIT License.
|
|
5
|
-
*/
|
|
6
|
-
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
7
|
-
import { forwardRef, createElement, Children, useState, useRef, useEffect, useLayoutEffect, useCallback } from 'react';
|
|
8
|
-
import { createPortal } from 'react-dom';
|
|
9
|
-
import { useField } from '@blockle/form';
|
|
10
|
-
|
|
11
|
-
const Badge = ({ children }) => jsx("div", Object.assign({ className: "Badge" }, { children: children }), void 0);
|
|
12
|
-
|
|
13
|
-
/*! *****************************************************************************
|
|
14
|
-
Copyright (c) Microsoft Corporation.
|
|
15
|
-
|
|
16
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
17
|
-
purpose with or without fee is hereby granted.
|
|
18
|
-
|
|
19
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
20
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
21
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
22
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
23
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
24
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
25
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
26
|
-
***************************************************************************** */
|
|
27
|
-
|
|
28
|
-
function __rest(s, e) {
|
|
29
|
-
var t = {};
|
|
30
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
31
|
-
t[p] = s[p];
|
|
32
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
33
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
34
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
35
|
-
t[p[i]] = s[p[i]];
|
|
36
|
-
}
|
|
37
|
-
return t;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const cx = (...args) => args.filter((arg) => arg && typeof arg === 'string').join(' ');
|
|
41
|
-
|
|
42
|
-
// bb -> blockle blocks
|
|
43
|
-
// useStyles({ padding: 'small', background: 'card' }); -> 'bb-padding-small bb-background-card'
|
|
44
|
-
const useStyles = (styles) => {
|
|
45
|
-
const keys = Object.keys(styles);
|
|
46
|
-
const classList = [];
|
|
47
|
-
keys.forEach((key) => {
|
|
48
|
-
const value = styles[key];
|
|
49
|
-
if (value === undefined) {
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
if (Array.isArray(value)) {
|
|
53
|
-
for (let i = 0; i < value.length; i++) {
|
|
54
|
-
const val = value[i];
|
|
55
|
-
if (i === 0) {
|
|
56
|
-
classList.push(`bb-${key}-${val}`);
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
classList.push(`bb-${key}-${val}-bp${i}`);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
classList.push(`bb-${key}-${value}`);
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
return classList.join(' ');
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
const Box = forwardRef((_a, ref) => {
|
|
71
|
-
var { alignItems, backgroundColor, children, className, color, component = 'div', display, flexDirection, flexGrow, flexShrink, flexWrap, fontSize, fontStyle, fontWeight, height, justifyContent, negativeMarginLeft, negativeMarginTop, overflow, overflowX, overflowY, padding, paddingBottom, paddingLeft, paddingRight, paddingTop, paddingX, paddingY, position, textAlign, width } = _a, restProps = __rest(_a, ["alignItems", "backgroundColor", "children", "className", "color", "component", "display", "flexDirection", "flexGrow", "flexShrink", "flexWrap", "fontSize", "fontStyle", "fontWeight", "height", "justifyContent", "negativeMarginLeft", "negativeMarginTop", "overflow", "overflowX", "overflowY", "padding", "paddingBottom", "paddingLeft", "paddingRight", "paddingTop", "paddingX", "paddingY", "position", "textAlign", "width"]);
|
|
72
|
-
const boxStyles = useStyles({
|
|
73
|
-
alignItems,
|
|
74
|
-
backgroundColor,
|
|
75
|
-
color,
|
|
76
|
-
display,
|
|
77
|
-
flexDirection,
|
|
78
|
-
flexGrow,
|
|
79
|
-
flexShrink,
|
|
80
|
-
flexWrap,
|
|
81
|
-
fontSize,
|
|
82
|
-
fontStyle,
|
|
83
|
-
fontWeight,
|
|
84
|
-
height,
|
|
85
|
-
justifyContent,
|
|
86
|
-
negativeMarginLeft,
|
|
87
|
-
negativeMarginTop,
|
|
88
|
-
overflow,
|
|
89
|
-
overflowX,
|
|
90
|
-
overflowY,
|
|
91
|
-
padding,
|
|
92
|
-
paddingBottom,
|
|
93
|
-
paddingLeft,
|
|
94
|
-
paddingRight,
|
|
95
|
-
paddingTop,
|
|
96
|
-
paddingX,
|
|
97
|
-
paddingY,
|
|
98
|
-
position,
|
|
99
|
-
textAlign,
|
|
100
|
-
width,
|
|
101
|
-
});
|
|
102
|
-
return createElement(component, Object.assign({ ref, className: cx(className, boxStyles) }, restProps), children);
|
|
103
|
-
});
|
|
104
|
-
Box.displayName = 'Box';
|
|
105
|
-
|
|
106
|
-
/* eslint-disable @typescript-eslint/ban-ts-ignore */
|
|
107
|
-
const isTouch$1 = 'ontouchstart' in document;
|
|
108
|
-
const endType = isTouch$1 ? 'touchend' : 'mouseup';
|
|
109
|
-
function nextTick(cb) {
|
|
110
|
-
requestAnimationFrame(() => requestAnimationFrame(cb));
|
|
111
|
-
}
|
|
112
|
-
function getPosition$1(event) {
|
|
113
|
-
if ('touches' in event) {
|
|
114
|
-
return {
|
|
115
|
-
x: event.touches[0].pageX,
|
|
116
|
-
y: event.touches[0].pageY,
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
return { x: event.pageX, y: event.pageY };
|
|
120
|
-
}
|
|
121
|
-
function createRipple(event) {
|
|
122
|
-
// Remove event from pool so we can hijack and set `__rippled` property
|
|
123
|
-
event.persist();
|
|
124
|
-
// Prevent "other" ripples to be created higher up in the dom tree
|
|
125
|
-
// @ts-ignore
|
|
126
|
-
if (event.__rippled) {
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
// @ts-ignore
|
|
130
|
-
event.__rippled = true;
|
|
131
|
-
const createdAt = Date.now();
|
|
132
|
-
const { currentTarget } = event;
|
|
133
|
-
const { x, y } = getPosition$1(event);
|
|
134
|
-
const target = currentTarget;
|
|
135
|
-
const rect = target.getBoundingClientRect();
|
|
136
|
-
const size = Math.ceil(Math.max(rect.width, rect.height)) * 4;
|
|
137
|
-
const duration = size < 600 ? 400 : 700;
|
|
138
|
-
// Ripple element
|
|
139
|
-
const ripple = document.createElement('div');
|
|
140
|
-
ripple.style.position = 'absolute';
|
|
141
|
-
ripple.style.borderRadius = '50%';
|
|
142
|
-
ripple.style.pointerEvents = 'none';
|
|
143
|
-
ripple.style.backgroundColor = 'currentColor';
|
|
144
|
-
ripple.style.width = `${size}px`;
|
|
145
|
-
ripple.style.height = `${size}px`;
|
|
146
|
-
ripple.style.opacity = '0.2';
|
|
147
|
-
ripple.style.transform = 'scale(0.01)';
|
|
148
|
-
ripple.style.left = `${x - rect.left - size / 2}px`;
|
|
149
|
-
ripple.style.top = `${y - rect.top - size / 2}px`;
|
|
150
|
-
ripple.style.transitionProperty = 'transform, opacity';
|
|
151
|
-
ripple.style.transitionDuration = `${duration}ms`;
|
|
152
|
-
ripple.style.transitionTimingFunction = 'cubic-bezier(.51,.26,.84,.84)';
|
|
153
|
-
target.appendChild(ripple);
|
|
154
|
-
nextTick(() => {
|
|
155
|
-
ripple.style.opacity = '0.1';
|
|
156
|
-
ripple.style.transform = 'scale(1)';
|
|
157
|
-
});
|
|
158
|
-
const cleanup = () => {
|
|
159
|
-
const diff = Date.now() - createdAt;
|
|
160
|
-
document.removeEventListener(endType, cleanup);
|
|
161
|
-
document.removeEventListener('touchcancel', cleanup);
|
|
162
|
-
if (diff < duration) {
|
|
163
|
-
ripple.style.opacity = '0';
|
|
164
|
-
setTimeout(cleanup, duration - diff);
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
167
|
-
target.removeChild(ripple);
|
|
168
|
-
};
|
|
169
|
-
document.addEventListener(endType, cleanup);
|
|
170
|
-
document.addEventListener('touchcancel', cleanup);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
const isTouch = 'ontouchstart' in document;
|
|
174
|
-
const startType = isTouch ? 'onTouchStart' : 'onMouseDown';
|
|
175
|
-
const RippleBox = forwardRef((_a, ref) => {
|
|
176
|
-
var { children, component = 'div', color = 'primary' } = _a, props = __rest(_a, ["children", "component", "color"]);
|
|
177
|
-
props[startType] = createRipple;
|
|
178
|
-
return (jsx(Box, Object.assign({ ref: ref, component: component, overflow: "hidden", position: "relative", color: color }, props, { children: children }), void 0));
|
|
179
|
-
});
|
|
180
|
-
RippleBox.displayName = 'RippleBox';
|
|
181
|
-
|
|
182
|
-
const Button = ({ children, className, disabled, onClick, type = 'button', width, secondary, }) => {
|
|
183
|
-
return (jsx(RippleBox, Object.assign({ component: "button", alignItems: "center", backgroundColor: disabled ? 'lightGray' : secondary ? 'secondary' : 'primary', className: cx('Button', disabled && 'is-disabled', className), color: "white", disabled: disabled, display: "flex", fontSize: "small", justifyContent: "center", onClick: onClick, paddingX: "large", paddingY: "xsmall", type: type, width: width }, { children: children }), void 0));
|
|
184
|
-
};
|
|
185
|
-
|
|
186
|
-
const Card = (_a) => {
|
|
187
|
-
var { backgroundColor = 'card', children, className, onClick, shadow } = _a, boxProps = __rest(_a, ["backgroundColor", "children", "className", "onClick", "shadow"]);
|
|
188
|
-
const props = Object.assign(Object.assign({}, boxProps), { className: cx('Card', shadow && `shadow-${shadow}`, onClick && 'is-clickable', className) });
|
|
189
|
-
if (onClick) {
|
|
190
|
-
return (jsx(RippleBox, Object.assign({ backgroundColor: backgroundColor, tabIndex: 0, role: "button", onClick: onClick, color: "primary", onKeyPress: (event) => {
|
|
191
|
-
if (onClick && (event.key === 'Enter' || event.key === ' ')) {
|
|
192
|
-
onClick();
|
|
193
|
-
}
|
|
194
|
-
} }, props, { children: children }), void 0));
|
|
195
|
-
}
|
|
196
|
-
return (jsx(Box, Object.assign({ backgroundColor: backgroundColor }, props, { children: children }), void 0));
|
|
197
|
-
};
|
|
198
|
-
|
|
199
|
-
function _extends$b() { _extends$b = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$b.apply(this, arguments); }
|
|
200
|
-
|
|
201
|
-
var _ref$b = /*#__PURE__*/createElement("path", {
|
|
202
|
-
fillRule: "evenodd",
|
|
203
|
-
clipRule: "evenodd",
|
|
204
|
-
d: "M9.707 16.707a1 1 0 01-1.414 0l-6-6a1 1 0 010-1.414l6-6a1 1 0 011.414 1.414L5.414 9H17a1 1 0 110 2H5.414l4.293 4.293a1 1 0 010 1.414z",
|
|
205
|
-
fill: "#4A5568"
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
function SvgSmArrowLeft(props) {
|
|
209
|
-
return /*#__PURE__*/createElement("svg", _extends$b({
|
|
210
|
-
width: 20,
|
|
211
|
-
height: 20,
|
|
212
|
-
viewBox: "0 0 20 20",
|
|
213
|
-
fill: "none",
|
|
214
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
215
|
-
}, props), _ref$b);
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
function _extends$a() { _extends$a = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$a.apply(this, arguments); }
|
|
219
|
-
|
|
220
|
-
var _ref$a = /*#__PURE__*/createElement("path", {
|
|
221
|
-
fillRule: "evenodd",
|
|
222
|
-
clipRule: "evenodd",
|
|
223
|
-
d: "M10.293 3.293a1 1 0 011.414 0l6 6a1 1 0 010 1.414l-6 6a1 1 0 01-1.414-1.414L14.586 11H3a1 1 0 110-2h11.586l-4.293-4.293a1 1 0 010-1.414z",
|
|
224
|
-
fill: "#4A5568"
|
|
225
|
-
});
|
|
226
|
-
|
|
227
|
-
function SvgSmArrowRight(props) {
|
|
228
|
-
return /*#__PURE__*/createElement("svg", _extends$a({
|
|
229
|
-
width: 20,
|
|
230
|
-
height: 20,
|
|
231
|
-
viewBox: "0 0 20 20",
|
|
232
|
-
fill: "none",
|
|
233
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
234
|
-
}, props), _ref$a);
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
function _extends$9() { _extends$9 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$9.apply(this, arguments); }
|
|
238
|
-
|
|
239
|
-
var _ref$9 = /*#__PURE__*/createElement("path", {
|
|
240
|
-
fillRule: "evenodd",
|
|
241
|
-
clipRule: "evenodd",
|
|
242
|
-
d: "M6 6V5a3 3 0 013-3h2a3 3 0 013 3v1h2a2 2 0 012 2v3.57A22.952 22.952 0 0110 13a22.95 22.95 0 01-8-1.43V8a2 2 0 012-2h2zm2-1a1 1 0 011-1h2a1 1 0 011 1v1H8V5zm1 5a1 1 0 011-1h.01a1 1 0 110 2H10a1 1 0 01-1-1z",
|
|
243
|
-
fill: "#4A5568"
|
|
244
|
-
});
|
|
245
|
-
|
|
246
|
-
var _ref2$1 = /*#__PURE__*/createElement("path", {
|
|
247
|
-
d: "M2 13.692V16a2 2 0 002 2h12a2 2 0 002-2v-2.308A24.974 24.974 0 0110 15c-2.796 0-5.487-.46-8-1.308z",
|
|
248
|
-
fill: "#4A5568"
|
|
249
|
-
});
|
|
250
|
-
|
|
251
|
-
function SvgSmBriefcase(props) {
|
|
252
|
-
return /*#__PURE__*/createElement("svg", _extends$9({
|
|
253
|
-
width: 20,
|
|
254
|
-
height: 20,
|
|
255
|
-
viewBox: "0 0 20 20",
|
|
256
|
-
fill: "none",
|
|
257
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
258
|
-
}, props), _ref$9, _ref2$1);
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
function _extends$8() { _extends$8 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$8.apply(this, arguments); }
|
|
262
|
-
|
|
263
|
-
var _ref$8 = /*#__PURE__*/createElement("path", {
|
|
264
|
-
fillRule: "evenodd",
|
|
265
|
-
clipRule: "evenodd",
|
|
266
|
-
d: "M6 2a1 1 0 00-1 1v1H4a2 2 0 00-2 2v10a2 2 0 002 2h12a2 2 0 002-2V6a2 2 0 00-2-2h-1V3a1 1 0 10-2 0v1H7V3a1 1 0 00-1-1zm0 5a1 1 0 000 2h8a1 1 0 100-2H6z",
|
|
267
|
-
fill: "#4A5568"
|
|
268
|
-
});
|
|
269
|
-
|
|
270
|
-
function SvgSmCalendar(props) {
|
|
271
|
-
return /*#__PURE__*/createElement("svg", _extends$8({
|
|
272
|
-
width: 20,
|
|
273
|
-
height: 20,
|
|
274
|
-
viewBox: "0 0 20 20",
|
|
275
|
-
fill: "none",
|
|
276
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
277
|
-
}, props), _ref$8);
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
function _extends$7() { _extends$7 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$7.apply(this, arguments); }
|
|
281
|
-
|
|
282
|
-
var _ref$7 = /*#__PURE__*/createElement("path", {
|
|
283
|
-
fillRule: "evenodd",
|
|
284
|
-
clipRule: "evenodd",
|
|
285
|
-
d: "M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",
|
|
286
|
-
fill: "#4A5568"
|
|
287
|
-
});
|
|
288
|
-
|
|
289
|
-
function SvgSmCheck(props) {
|
|
290
|
-
return /*#__PURE__*/createElement("svg", _extends$7({
|
|
291
|
-
width: 20,
|
|
292
|
-
height: 20,
|
|
293
|
-
viewBox: "0 0 20 20",
|
|
294
|
-
fill: "none",
|
|
295
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
296
|
-
}, props), _ref$7);
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
function _extends$6() { _extends$6 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$6.apply(this, arguments); }
|
|
300
|
-
|
|
301
|
-
var _ref$6 = /*#__PURE__*/createElement("path", {
|
|
302
|
-
fillRule: "evenodd",
|
|
303
|
-
clipRule: "evenodd",
|
|
304
|
-
d: "M12.707 5.293a1 1 0 010 1.414L9.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z",
|
|
305
|
-
fill: "#4A5568"
|
|
306
|
-
});
|
|
307
|
-
|
|
308
|
-
function SvgSmCheveronLeft(props) {
|
|
309
|
-
return /*#__PURE__*/createElement("svg", _extends$6({
|
|
310
|
-
width: 20,
|
|
311
|
-
height: 20,
|
|
312
|
-
viewBox: "0 0 20 20",
|
|
313
|
-
fill: "none",
|
|
314
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
315
|
-
}, props), _ref$6);
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
function _extends$5() { _extends$5 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$5.apply(this, arguments); }
|
|
319
|
-
|
|
320
|
-
var _ref$5 = /*#__PURE__*/createElement("path", {
|
|
321
|
-
d: "M8 3a1 1 0 011-1h2a1 1 0 110 2H9a1 1 0 01-1-1z",
|
|
322
|
-
fill: "#4A5568"
|
|
323
|
-
});
|
|
324
|
-
|
|
325
|
-
var _ref2 = /*#__PURE__*/createElement("path", {
|
|
326
|
-
d: "M6 3a2 2 0 00-2 2v11a2 2 0 002 2h8a2 2 0 002-2V5a2 2 0 00-2-2 3 3 0 01-3 3H9a3 3 0 01-3-3z",
|
|
327
|
-
fill: "#4A5568"
|
|
328
|
-
});
|
|
329
|
-
|
|
330
|
-
function SvgSmClipboard(props) {
|
|
331
|
-
return /*#__PURE__*/createElement("svg", _extends$5({
|
|
332
|
-
width: 20,
|
|
333
|
-
height: 20,
|
|
334
|
-
viewBox: "0 0 20 20",
|
|
335
|
-
fill: "none",
|
|
336
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
337
|
-
}, props), _ref$5, _ref2);
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
function _extends$4() { _extends$4 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$4.apply(this, arguments); }
|
|
341
|
-
|
|
342
|
-
var _ref$4 = /*#__PURE__*/createElement("path", {
|
|
343
|
-
fillRule: "evenodd",
|
|
344
|
-
clipRule: "evenodd",
|
|
345
|
-
d: "M11.49 3.17c-.38-1.56-2.6-1.56-2.98 0a1.532 1.532 0 01-2.286.948c-1.372-.836-2.942.734-2.106 2.106.54.886.061 2.042-.947 2.287-1.561.379-1.561 2.6 0 2.978a1.532 1.532 0 01.947 2.287c-.836 1.372.734 2.942 2.106 2.106a1.532 1.532 0 012.287.947c.379 1.561 2.6 1.561 2.978 0a1.533 1.533 0 012.287-.947c1.372.836 2.942-.734 2.106-2.106a1.533 1.533 0 01.947-2.287c1.561-.379 1.561-2.6 0-2.978a1.532 1.532 0 01-.947-2.287c.836-1.372-.734-2.942-2.106-2.106a1.532 1.532 0 01-2.287-.947zM10 13a3 3 0 100-6 3 3 0 000 6z",
|
|
346
|
-
fill: "#4A5568"
|
|
347
|
-
});
|
|
348
|
-
|
|
349
|
-
function SvgSmCog(props) {
|
|
350
|
-
return /*#__PURE__*/createElement("svg", _extends$4({
|
|
351
|
-
width: 20,
|
|
352
|
-
height: 20,
|
|
353
|
-
viewBox: "0 0 20 20",
|
|
354
|
-
fill: "none",
|
|
355
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
356
|
-
}, props), _ref$4);
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
function _extends$3() { _extends$3 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$3.apply(this, arguments); }
|
|
360
|
-
|
|
361
|
-
var _ref$3 = /*#__PURE__*/createElement("path", {
|
|
362
|
-
fillRule: "evenodd",
|
|
363
|
-
clipRule: "evenodd",
|
|
364
|
-
d: "M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z",
|
|
365
|
-
fill: "#4A5568"
|
|
366
|
-
});
|
|
367
|
-
|
|
368
|
-
function SvgSmExclamation(props) {
|
|
369
|
-
return /*#__PURE__*/createElement("svg", _extends$3({
|
|
370
|
-
width: 20,
|
|
371
|
-
height: 20,
|
|
372
|
-
viewBox: "0 0 20 20",
|
|
373
|
-
fill: "none",
|
|
374
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
375
|
-
}, props), _ref$3);
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
function _extends$2() { _extends$2 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$2.apply(this, arguments); }
|
|
379
|
-
|
|
380
|
-
var _ref$2 = /*#__PURE__*/createElement("path", {
|
|
381
|
-
fillRule: "evenodd",
|
|
382
|
-
clipRule: "evenodd",
|
|
383
|
-
d: "M10 3a1 1 0 011 1v5h5a1 1 0 110 2h-5v5a1 1 0 11-2 0v-5H4a1 1 0 110-2h5V4a1 1 0 011-1z",
|
|
384
|
-
fill: "#4A5568"
|
|
385
|
-
});
|
|
386
|
-
|
|
387
|
-
function SvgSmPlus(props) {
|
|
388
|
-
return /*#__PURE__*/createElement("svg", _extends$2({
|
|
389
|
-
width: 20,
|
|
390
|
-
height: 20,
|
|
391
|
-
viewBox: "0 0 20 20",
|
|
392
|
-
fill: "none",
|
|
393
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
394
|
-
}, props), _ref$2);
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
function _extends$1() { _extends$1 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$1.apply(this, arguments); }
|
|
398
|
-
|
|
399
|
-
var _ref$1 = /*#__PURE__*/createElement("path", {
|
|
400
|
-
fillRule: "evenodd",
|
|
401
|
-
clipRule: "evenodd",
|
|
402
|
-
d: "M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z",
|
|
403
|
-
fill: "#4A5568"
|
|
404
|
-
});
|
|
405
|
-
|
|
406
|
-
function SvgSmSelector(props) {
|
|
407
|
-
return /*#__PURE__*/createElement("svg", _extends$1({
|
|
408
|
-
width: 20,
|
|
409
|
-
height: 20,
|
|
410
|
-
viewBox: "0 0 20 20",
|
|
411
|
-
fill: "none",
|
|
412
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
413
|
-
}, props), _ref$1);
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
417
|
-
|
|
418
|
-
var _ref = /*#__PURE__*/createElement("path", {
|
|
419
|
-
fillRule: "evenodd",
|
|
420
|
-
clipRule: "evenodd",
|
|
421
|
-
d: "M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",
|
|
422
|
-
fill: "#4A5568"
|
|
423
|
-
});
|
|
424
|
-
|
|
425
|
-
function SvgSmX(props) {
|
|
426
|
-
return /*#__PURE__*/createElement("svg", _extends({
|
|
427
|
-
width: 20,
|
|
428
|
-
height: 20,
|
|
429
|
-
viewBox: "0 0 20 20",
|
|
430
|
-
fill: "none",
|
|
431
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
432
|
-
}, props), _ref);
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
const ICON_MAP = {
|
|
436
|
-
arrowBack: SvgSmCheveronLeft,
|
|
437
|
-
arrowLeft: SvgSmArrowLeft,
|
|
438
|
-
arrowRight: SvgSmArrowRight,
|
|
439
|
-
briefcase: SvgSmBriefcase,
|
|
440
|
-
calendar: SvgSmCalendar,
|
|
441
|
-
check: SvgSmCheck,
|
|
442
|
-
clipboard: SvgSmClipboard,
|
|
443
|
-
cog: SvgSmCog,
|
|
444
|
-
cross: SvgSmX,
|
|
445
|
-
exclamation: SvgSmExclamation,
|
|
446
|
-
plus: SvgSmPlus,
|
|
447
|
-
selector: SvgSmSelector,
|
|
448
|
-
};
|
|
449
|
-
const Icon = ({ className, label, name, size = 'medium', color = 'white' }) => {
|
|
450
|
-
const iconStyles = useStyles({
|
|
451
|
-
color,
|
|
452
|
-
});
|
|
453
|
-
if (!ICON_MAP[name]) {
|
|
454
|
-
console.warn(`<Icon name="${name}" />`);
|
|
455
|
-
return null;
|
|
456
|
-
}
|
|
457
|
-
return (jsx("span", Object.assign({ className: cx('Icon', `size-${size}`, className, iconStyles), title: label }, { children: createElement(ICON_MAP[name], {
|
|
458
|
-
className: 'icon-svg',
|
|
459
|
-
'data-testid': 'icon-svg',
|
|
460
|
-
}) }), void 0));
|
|
461
|
-
};
|
|
462
|
-
|
|
463
|
-
const IconButton = ({ disabled, label, name, onClick, secondary }) => {
|
|
464
|
-
return (jsx(RippleBox, Object.assign({ disabled: disabled, onClick: onClick, className: cx('IconButton', secondary && 'is-secondary', disabled && 'is-disabled') }, { children: jsx(Icon, { name: name, label: label, size: "medium", color: disabled ? 'gray' : 'black' }, void 0) }), void 0));
|
|
465
|
-
};
|
|
466
|
-
|
|
467
|
-
const Stack = ({ align, children, component = 'div', spacing, horizontal = false, className, }) => {
|
|
468
|
-
const items = Children.toArray(children);
|
|
469
|
-
return (jsx(Box, Object.assign({ className: cx('Stack', className), component: component, display: "flex", flexDirection: horizontal ? 'row' : 'column', justifyContent: horizontal ? undefined : align, alignItems: align, negativeMarginTop: horizontal ? undefined : spacing, negativeMarginLeft: horizontal ? spacing : undefined }, { children: items.map((item, key) => (jsx(Box, Object.assign({ paddingTop: horizontal ? undefined : spacing, paddingLeft: horizontal ? spacing : undefined }, { children: item }), key))) }), void 0));
|
|
470
|
-
};
|
|
471
|
-
|
|
472
|
-
const useAnimationState = (nextOpenState) => {
|
|
473
|
-
const [state, setState] = useState({ open: nextOpenState, leave: false });
|
|
474
|
-
const close = () => setState({ open: false, leave: false });
|
|
475
|
-
let { open, leave } = state;
|
|
476
|
-
if (nextOpenState && !open) {
|
|
477
|
-
open = true;
|
|
478
|
-
leave = false;
|
|
479
|
-
setState({ open, leave });
|
|
480
|
-
}
|
|
481
|
-
if (!nextOpenState && open && !leave) {
|
|
482
|
-
open = true;
|
|
483
|
-
leave = true;
|
|
484
|
-
setState({ open, leave });
|
|
485
|
-
}
|
|
486
|
-
return [{ open, leave }, close];
|
|
487
|
-
};
|
|
488
|
-
|
|
489
|
-
const useLayer = () => {
|
|
490
|
-
const layerRef = useRef();
|
|
491
|
-
useEffect(() => () => {
|
|
492
|
-
if (layerRef.current) {
|
|
493
|
-
document.body.removeChild(layerRef.current);
|
|
494
|
-
}
|
|
495
|
-
}, []);
|
|
496
|
-
return () => {
|
|
497
|
-
if (!layerRef.current) {
|
|
498
|
-
layerRef.current = document.createElement('div');
|
|
499
|
-
document.body.appendChild(layerRef.current);
|
|
500
|
-
}
|
|
501
|
-
return layerRef.current;
|
|
502
|
-
};
|
|
503
|
-
};
|
|
504
|
-
|
|
505
|
-
const Dialog = ({ actions, full = false, onRequestClose, open = false, render, title = null, minHeight, }) => {
|
|
506
|
-
const [state, close] = useAnimationState(open);
|
|
507
|
-
const layer = useLayer();
|
|
508
|
-
useEffect(() => {
|
|
509
|
-
if (!state.open) {
|
|
510
|
-
return;
|
|
511
|
-
}
|
|
512
|
-
const onKeyPress = (event) => {
|
|
513
|
-
if (event.key === 'Escape') {
|
|
514
|
-
onRequestClose();
|
|
515
|
-
}
|
|
516
|
-
};
|
|
517
|
-
document.addEventListener('keydown', onKeyPress);
|
|
518
|
-
return () => {
|
|
519
|
-
document.removeEventListener('keydown', onKeyPress);
|
|
520
|
-
};
|
|
521
|
-
}, [state.open]);
|
|
522
|
-
if (!state.open) {
|
|
523
|
-
return null;
|
|
524
|
-
}
|
|
525
|
-
const onAnimationEnd = (event) => {
|
|
526
|
-
if (event.animationName === 'DialogBack-Leave') {
|
|
527
|
-
close();
|
|
528
|
-
}
|
|
529
|
-
};
|
|
530
|
-
const dialog = (jsxs("div", Object.assign({ className: "DialogContainer" }, { children: [jsx("div", { className: cx('DialogBack', state.leave && 'is-leave'), onClick: onRequestClose, onAnimationEnd: onAnimationEnd }, void 0),
|
|
531
|
-
jsx(Box, Object.assign({ className: cx('Dialog', state.leave && 'is-leave'), width: full ? 'full' : undefined, display: "flex", flexDirection: "column", position: "relative", paddingY: "small", style: {
|
|
532
|
-
minHeight: `min(96%, ${minHeight}px)`,
|
|
533
|
-
} }, { children: jsxs(Stack, Object.assign({ spacing: "medium" }, { children: [(title || full) && (jsxs(Box, Object.assign({ display: "flex", alignItems: "center", paddingLeft: "gutter" }, { children: [jsx(Box, Object.assign({ flexGrow: 1 }, { children: title }), void 0),
|
|
534
|
-
jsx(IconButton, { name: "cross", label: "Close", onClick: onRequestClose }, void 0)] }), void 0)),
|
|
535
|
-
jsx(Box, Object.assign({ flexGrow: 1, overflow: "auto", paddingX: "gutter" }, { children: render() }), void 0),
|
|
536
|
-
actions && (jsx(Box, Object.assign({ display: "flex", justifyContent: "flex-end", alignItems: "center", paddingX: "gutter" }, { children: actions }), void 0))] }), void 0) }), void 0)] }), void 0));
|
|
537
|
-
return createPortal(dialog, layer());
|
|
538
|
-
};
|
|
539
|
-
|
|
540
|
-
const Divider = () => jsx("hr", { className: "Divider" }, void 0);
|
|
541
|
-
|
|
542
|
-
const Drawer = ({ children, onRequestClose, open, position = 'left' }) => {
|
|
543
|
-
return (jsxs(Fragment, { children: [jsx("div", { className: cx('Drawer-Back', open && 'is-open'), onClick: onRequestClose }, void 0),
|
|
544
|
-
jsx("div", Object.assign({ className: cx('Drawer', `position-${position}`, open && 'is-open') }, { children: children }), void 0)] }, void 0));
|
|
545
|
-
};
|
|
546
|
-
|
|
547
|
-
const validate$1 = ({ required }) => (value) => {
|
|
548
|
-
if (required && !value) {
|
|
549
|
-
return 'required';
|
|
550
|
-
}
|
|
551
|
-
return null;
|
|
552
|
-
};
|
|
553
|
-
const Dropdown = ({ name, onChange, placeholder, required, value,
|
|
554
|
-
// errorMessages = {},
|
|
555
|
-
children, }) => {
|
|
556
|
-
const ref = useRef(null);
|
|
557
|
-
const [focus, setFocus] = useState(false);
|
|
558
|
-
const field = useField(name, {
|
|
559
|
-
value: value || '',
|
|
560
|
-
validate: validate$1({ required }),
|
|
561
|
-
onChange,
|
|
562
|
-
});
|
|
563
|
-
const invalid = field.invalid && (field.dirty || field.touched);
|
|
564
|
-
useEffect(() => {
|
|
565
|
-
if (ref.current) {
|
|
566
|
-
const { value } = ref.current;
|
|
567
|
-
if (value && value !== field.value) {
|
|
568
|
-
field.setValue(value);
|
|
569
|
-
}
|
|
570
|
-
}
|
|
571
|
-
}, [children]);
|
|
572
|
-
return (jsxs(Box, Object.assign({ position: "relative", display: "inline-block", color: invalid ? 'warning' : focus ? 'primary' : 'black' }, { children: [jsxs(Box, Object.assign({ ref: ref, component: "select", className: cx('Dropdown-select', invalid && 'is-invalid'), color: "black", fontSize: "medium", paddingY: "xsmall", paddingLeft: "small", paddingRight: "large", name: name, id: `Dropdown-${name}`, value: field.value, onBlur: () => {
|
|
573
|
-
setFocus(false);
|
|
574
|
-
field.setTouched();
|
|
575
|
-
}, onChange: (event) => {
|
|
576
|
-
field.setValue(event.currentTarget.value);
|
|
577
|
-
}, onFocus: () => {
|
|
578
|
-
setFocus(true);
|
|
579
|
-
} }, { children: [placeholder && (jsx("option", Object.assign({ value: "", disabled: true }, { children: placeholder }), void 0)), children] }), void 0),
|
|
580
|
-
jsx(Box, Object.assign({ className: "Dropdown-icon", paddingRight: "xsmall" }, { children: jsx(Icon, { name: "selector", label: "", color: "black", size: "xsmall" }, void 0) }), void 0)] }), void 0));
|
|
581
|
-
};
|
|
582
|
-
|
|
583
|
-
const FlatButton = (_a) => {
|
|
584
|
-
var { children, className, disabled, onClick, secondary, type = 'button', width } = _a, props = __rest(_a, ["children", "className", "disabled", "onClick", "secondary", "type", "width"]);
|
|
585
|
-
return (jsx(RippleBox, Object.assign({ component: "button", type: type, disabled: disabled, onClick: onClick, className: cx('FlatButton', disabled && 'is-disabled', className), width: width, paddingX: "large", paddingY: "small", fontSize: "small", color: disabled ? 'gray' : secondary ? 'secondary' : 'primary', display: "flex", justifyContent: "center", alignItems: "center", fontWeight: "bold" }, props, { children: children }), void 0));
|
|
586
|
-
};
|
|
587
|
-
|
|
588
|
-
const Grid = ({ children, className, spacing, columns }) => {
|
|
589
|
-
const gridStyles = useStyles({
|
|
590
|
-
display: 'grid',
|
|
591
|
-
gridGap: spacing,
|
|
592
|
-
});
|
|
593
|
-
return (jsx("div", Object.assign({ className: cx(className, gridStyles), style: {
|
|
594
|
-
gridTemplateColumns: `repeat(${columns}, 1fr)`,
|
|
595
|
-
} }, { children: children }), void 0));
|
|
596
|
-
};
|
|
597
|
-
|
|
598
|
-
const Inline = ({ children, spacing }) => {
|
|
599
|
-
const items = Children.toArray(children);
|
|
600
|
-
return (jsx(Box, Object.assign({ display: "flex", flexWrap: "wrap", negativeMarginTop: spacing, negativeMarginLeft: spacing }, { children: items.map((item, key) => {
|
|
601
|
-
return (jsx(Box, Object.assign({ display: "inline-block", paddingTop: spacing, paddingLeft: spacing }, { children: item }), key));
|
|
602
|
-
}) }), void 0));
|
|
603
|
-
};
|
|
604
|
-
|
|
605
|
-
const Link = ({ children, to, fontSize }) => {
|
|
606
|
-
const linkStyles = useStyles({
|
|
607
|
-
color: 'primary',
|
|
608
|
-
fontSize,
|
|
609
|
-
});
|
|
610
|
-
return (jsx("a", Object.assign({ href: `#${to}`, className: cx('Link', linkStyles) }, { children: children }), void 0));
|
|
611
|
-
};
|
|
612
|
-
|
|
613
|
-
const Loader = () => {
|
|
614
|
-
return (jsx("div", Object.assign({ className: "Loader" }, { children: jsx(Icon, { name: "briefcase", label: "Loading", color: "secondary" }, void 0) }), void 0));
|
|
615
|
-
};
|
|
616
|
-
|
|
617
|
-
const OutlineButton = ({ children, className, disabled, onClick, type = 'button', width, }) => {
|
|
618
|
-
return (jsx(RippleBox, Object.assign({ component: "button", type: type, disabled: disabled, onClick: onClick, className: cx('OutlineButton', disabled && 'is-disabled', className), fontWeight: "bold", width: width, paddingX: "large", paddingY: "small", fontSize: "small", color: disabled ? 'lightGray' : 'primary', display: "flex", justifyContent: "center", alignItems: "center" }, { children: children }), void 0));
|
|
619
|
-
};
|
|
620
|
-
|
|
621
|
-
const Panel = ({ className, onRequestClose, open = false, render }) => {
|
|
622
|
-
const [state, close] = useAnimationState(open);
|
|
623
|
-
const layer = useLayer();
|
|
624
|
-
if (!state.open) {
|
|
625
|
-
return null;
|
|
626
|
-
}
|
|
627
|
-
const onAnimationEnd = (event) => {
|
|
628
|
-
if (event.animationName === 'Panel-Back-Leave') {
|
|
629
|
-
close();
|
|
630
|
-
}
|
|
631
|
-
};
|
|
632
|
-
const panel = (jsxs("div", Object.assign({ className: "Panel-Container" }, { children: [jsx("div", { className: cx('Panel-Back', state.leave && 'is-leave'), onClick: onRequestClose, onAnimationEnd: onAnimationEnd }, void 0),
|
|
633
|
-
jsx("div", Object.assign({ className: cx('Panel', state.leave && 'is-leave', className) }, { children: render() }), void 0)] }), void 0));
|
|
634
|
-
return createPortal(panel, layer());
|
|
635
|
-
};
|
|
636
|
-
|
|
637
|
-
const animationLeaveExpression = /^Paper-.*?Leave$/;
|
|
638
|
-
const Paper = ({ open = false, effect = 'fade', className, transparent, shadow, render, fit, }) => {
|
|
639
|
-
const [state, close] = useAnimationState(open);
|
|
640
|
-
const onAnimationEnd = (event) => {
|
|
641
|
-
if (animationLeaveExpression.test(event.animationName)) {
|
|
642
|
-
close();
|
|
643
|
-
}
|
|
644
|
-
};
|
|
645
|
-
if (!state.open) {
|
|
646
|
-
return null;
|
|
647
|
-
}
|
|
648
|
-
return (jsx("div", Object.assign({ className: cx('Paper', state.leave && 'is-leave', className, `effect-${effect}`, fit && 'is-fit', transparent && 'is-transparent', shadow && 'is-shadow'), onAnimationEnd: onAnimationEnd }, { children: render() }), void 0));
|
|
649
|
-
};
|
|
650
|
-
|
|
651
|
-
const Text = ({ component = 'span', children, textAlign, fontSize = 'medium', fontWeight, color, fontStyle, className, }) => {
|
|
652
|
-
return (jsx(Box, Object.assign({ component: component, textAlign: textAlign, fontSize: fontSize, fontWeight: fontWeight, fontStyle: fontStyle, display: "block", className: cx('Text', className), color: color }, { children: children }), void 0));
|
|
653
|
-
};
|
|
654
|
-
|
|
655
|
-
const Tag = ({ children, onClick }) => {
|
|
656
|
-
return (jsx(RippleBox, Object.assign({ tabIndex: 0, className: "Tag", display: "flex", alignItems: "center", paddingX: "small", paddingY: "xsmall", onClick: onClick, onKeyPress: (event) => {
|
|
657
|
-
if (event.key === ' ' || event.key === 'Enter') {
|
|
658
|
-
onClick();
|
|
659
|
-
}
|
|
660
|
-
} }, { children: jsxs(Stack, Object.assign({ spacing: "xsmall", horizontal: true }, { children: [jsx(Text, Object.assign({ fontSize: "small", fontWeight: "bold" }, { children: children }), void 0),
|
|
661
|
-
jsx(Icon, { name: "cross", label: "remove", color: "black", size: "xsmall" }, void 0)] }), void 0) }), void 0));
|
|
662
|
-
};
|
|
663
|
-
|
|
664
|
-
const validate = ({ required, pattern, minLength, maxLength }) => (value) => {
|
|
665
|
-
if (required && !value) {
|
|
666
|
-
return 'required';
|
|
667
|
-
}
|
|
668
|
-
if (pattern && !pattern.test(value)) {
|
|
669
|
-
return 'pattern';
|
|
670
|
-
}
|
|
671
|
-
if (minLength && value.length < minLength) {
|
|
672
|
-
return 'minLength';
|
|
673
|
-
}
|
|
674
|
-
if (maxLength && value.length > maxLength) {
|
|
675
|
-
return 'maxLength';
|
|
676
|
-
}
|
|
677
|
-
return null;
|
|
678
|
-
};
|
|
679
|
-
const TextField = ({ label, name, onChange, pattern, placeholder, required, type = 'text', value = '', errorMessages = {}, minLength, maxLength, disabled, }) => {
|
|
680
|
-
const [focus, setFocus] = useState(false);
|
|
681
|
-
const field = useField(name, {
|
|
682
|
-
value,
|
|
683
|
-
validate: validate({ required, pattern, minLength, maxLength }),
|
|
684
|
-
onChange,
|
|
685
|
-
});
|
|
686
|
-
const invalid = field.invalid && field.touched;
|
|
687
|
-
return (jsxs(Box, Object.assign({ position: "relative", color: invalid ? 'warning' : focus ? 'primary' : 'white', paddingBottom: "large", className: cx('TextField', disabled && 'is-disabled') }, { children: [jsx("input", { autoComplete: "off", className: cx('TextField-Input', field.value && 'is-filled', invalid && 'is-invalid'), id: `Input-${name}`, name: name, onBlur: () => {
|
|
688
|
-
setFocus(false);
|
|
689
|
-
field.setTouched();
|
|
690
|
-
}, onChange: (event) => field.setValue(event.target.value), onFocus: () => {
|
|
691
|
-
setFocus(true);
|
|
692
|
-
}, placeholder: placeholder || label, type: type, value: field.value, disabled: disabled }, void 0),
|
|
693
|
-
jsx(Box, Object.assign({ component: "label", display: "block", htmlFor: `Input-${name}`, color: invalid ? 'warning' : 'gray', className: cx('TextField-Label', field.value && 'is-visible'), paddingX: "xsmall", fontSize: "xsmall", paddingTop: "xsmall", backgroundColor: "white" }, { children: label }), void 0),
|
|
694
|
-
invalid && (jsx(Box, Object.assign({ color: "warning", className: "TextField-Bottom", fontSize: "small" }, { children: (field.validationMessage && errorMessages[field.validationMessage]) ||
|
|
695
|
-
field.validationMessage }), void 0))] }), void 0));
|
|
696
|
-
};
|
|
697
|
-
|
|
698
|
-
const animate = ({ element, transforms, duration = 200, timingFunction = 'ease', done, }) => {
|
|
699
|
-
element.style.transition = '';
|
|
700
|
-
transforms.forEach(({ property, from = '' }) => {
|
|
701
|
-
element.style.setProperty(property, from);
|
|
702
|
-
});
|
|
703
|
-
const onTransitionEnd = () => {
|
|
704
|
-
if (!element) {
|
|
705
|
-
return;
|
|
706
|
-
}
|
|
707
|
-
element.removeEventListener('transitionend', onTransitionEnd);
|
|
708
|
-
element.removeEventListener('transitioncancel', onTransitionEnd);
|
|
709
|
-
element.style.transition = '';
|
|
710
|
-
if (done) {
|
|
711
|
-
done();
|
|
712
|
-
}
|
|
713
|
-
};
|
|
714
|
-
element.addEventListener('transitionend', onTransitionEnd);
|
|
715
|
-
element.addEventListener('transitioncancel', onTransitionEnd);
|
|
716
|
-
window.requestAnimationFrame(() => {
|
|
717
|
-
window.requestAnimationFrame(() => {
|
|
718
|
-
element.style.transition = `transform ${duration}ms ${timingFunction}, opacity ${duration}ms ${timingFunction}`;
|
|
719
|
-
transforms.forEach(({ property, to = '' }) => {
|
|
720
|
-
element.style.setProperty(property, to);
|
|
721
|
-
});
|
|
722
|
-
});
|
|
723
|
-
});
|
|
724
|
-
};
|
|
725
|
-
|
|
726
|
-
function getScrollPosition(element) {
|
|
727
|
-
let node = element;
|
|
728
|
-
let x = 0;
|
|
729
|
-
let y = 0;
|
|
730
|
-
while ((node = node.parentElement)) {
|
|
731
|
-
x += node.scrollLeft;
|
|
732
|
-
y += node.scrollTop;
|
|
733
|
-
}
|
|
734
|
-
return { x, y };
|
|
735
|
-
}
|
|
736
|
-
function getPosition(element) {
|
|
737
|
-
const rect = element.getBoundingClientRect();
|
|
738
|
-
const scroll = getScrollPosition(element);
|
|
739
|
-
return {
|
|
740
|
-
x: rect.x + scroll.x,
|
|
741
|
-
y: rect.y + scroll.y,
|
|
742
|
-
};
|
|
743
|
-
}
|
|
744
|
-
function getTransformValue(axis, x, y) {
|
|
745
|
-
switch (axis) {
|
|
746
|
-
case 'x':
|
|
747
|
-
return `translateX(${x}px)`;
|
|
748
|
-
case 'y':
|
|
749
|
-
return `translateY(${y}px)`;
|
|
750
|
-
case 'both':
|
|
751
|
-
return `translate(${x}px, ${y}px)`;
|
|
752
|
-
}
|
|
753
|
-
}
|
|
754
|
-
function useRefValue(initialValue) {
|
|
755
|
-
const ref = useRef(initialValue);
|
|
756
|
-
return ref.current;
|
|
757
|
-
}
|
|
758
|
-
const useFlip = ({ axis = 'both' } = {}) => {
|
|
759
|
-
const refs = useRefValue(new Map());
|
|
760
|
-
const positions = useRefValue(new Map());
|
|
761
|
-
useLayoutEffect(() => {
|
|
762
|
-
const animations = [];
|
|
763
|
-
Array.from(refs.entries()).forEach(([id, element]) => {
|
|
764
|
-
if (!element.isConnected) {
|
|
765
|
-
refs.delete(id);
|
|
766
|
-
positions.delete(id);
|
|
767
|
-
return;
|
|
768
|
-
}
|
|
769
|
-
const prevPosition = positions.get(id);
|
|
770
|
-
const position = getPosition(element);
|
|
771
|
-
// Enter animation
|
|
772
|
-
if (!prevPosition) {
|
|
773
|
-
animations.push({
|
|
774
|
-
element,
|
|
775
|
-
transforms: [
|
|
776
|
-
{ property: 'transform', from: 'scale(0.8)' },
|
|
777
|
-
{ property: 'opacity', from: '0' },
|
|
778
|
-
],
|
|
779
|
-
});
|
|
780
|
-
}
|
|
781
|
-
// Move animation
|
|
782
|
-
if (prevPosition && (prevPosition.x !== position.x || prevPosition.y !== position.y)) {
|
|
783
|
-
const x = prevPosition.x - position.x;
|
|
784
|
-
const y = prevPosition.y - position.y;
|
|
785
|
-
animations.push({
|
|
786
|
-
element,
|
|
787
|
-
transforms: [{ property: 'transform', from: getTransformValue(axis, x, y) }],
|
|
788
|
-
});
|
|
789
|
-
}
|
|
790
|
-
positions.set(id, position);
|
|
791
|
-
});
|
|
792
|
-
animations.forEach(animate);
|
|
793
|
-
});
|
|
794
|
-
const setRef = useCallback((id) => (ref) => {
|
|
795
|
-
if (ref) {
|
|
796
|
-
refs.set(id, ref);
|
|
797
|
-
}
|
|
798
|
-
}, []);
|
|
799
|
-
const remove = useCallback((id, callback) => {
|
|
800
|
-
const element = refs.get(id);
|
|
801
|
-
if (element) {
|
|
802
|
-
animate({
|
|
803
|
-
element,
|
|
804
|
-
done: callback,
|
|
805
|
-
duration: 100,
|
|
806
|
-
transforms: [
|
|
807
|
-
{
|
|
808
|
-
property: 'opacity',
|
|
809
|
-
from: '1',
|
|
810
|
-
to: '0',
|
|
811
|
-
},
|
|
812
|
-
{
|
|
813
|
-
property: 'transform',
|
|
814
|
-
to: 'scale(0.8)',
|
|
815
|
-
},
|
|
816
|
-
],
|
|
817
|
-
});
|
|
818
|
-
}
|
|
819
|
-
}, []);
|
|
820
|
-
return { setRef, remove };
|
|
821
|
-
};
|
|
822
|
-
|
|
823
|
-
export { Badge, Box, Button, Card, Dialog, Divider, Drawer, Dropdown, FlatButton, Grid, Icon, IconButton, Inline, Link, Loader, OutlineButton, Panel, Paper, RippleBox, Stack, Tag, Text, TextField, cx, useAnimationState, useFlip, useLayer, useStyles };
|