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