@bigbinary/neetoui 6.5.7 → 6.5.9-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/TreeSelect-af6d4145.js +6171 -0
- package/dist/TreeSelect-af6d4145.js.map +1 -0
- package/dist/Typography-3bf740f3.js +2932 -0
- package/dist/Typography-3bf740f3.js.map +1 -0
- package/dist/cjs/TreeSelect-244fb236.js +6210 -0
- package/dist/cjs/TreeSelect-244fb236.js.map +1 -0
- package/dist/cjs/Typography-72ac982c.js +2964 -0
- package/dist/cjs/Typography-72ac982c.js.map +1 -0
- package/dist/cjs/createClass-ca103cfb.js +57 -0
- package/dist/cjs/createClass-ca103cfb.js.map +1 -0
- package/dist/cjs/formik.js +630 -0
- package/dist/cjs/formik.js.map +1 -0
- package/dist/cjs/index-a5047060.js +98 -0
- package/dist/cjs/index-a5047060.js.map +1 -0
- package/dist/cjs/index.js +4470 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/layouts.js +377 -0
- package/dist/cjs/layouts.js.map +1 -0
- package/dist/cjs/managers.js +11 -0
- package/dist/cjs/managers.js.map +1 -0
- package/{managers.cjs.js → dist/cjs/overlayManager-a0827ae7.js} +4 -54
- package/dist/cjs/overlayManager-a0827ae7.js.map +1 -0
- package/dist/createClass-27bd48bc.js +52 -0
- package/dist/createClass-27bd48bc.js.map +1 -0
- package/dist/formik.js +610 -0
- package/dist/formik.js.map +1 -0
- package/dist/index-f5a4691b.js +91 -0
- package/dist/index-f5a4691b.js.map +1 -0
- package/dist/index.css +4 -0
- package/dist/index.js +4403 -0
- package/dist/index.js.map +1 -0
- package/dist/layouts.js +369 -0
- package/dist/layouts.js.map +1 -0
- package/dist/managers.js +3 -0
- package/dist/managers.js.map +1 -0
- package/{managers.js → dist/overlayManager-4d5be56b.js} +3 -51
- package/dist/overlayManager-4d5be56b.js.map +1 -0
- package/index.d.ts +2 -0
- package/package.json +25 -18
- package/formik.cjs.js +0 -27745
- package/formik.cjs.js.map +0 -1
- package/formik.js +0 -27703
- package/formik.js.map +0 -1
- package/index.cjs.js +0 -42484
- package/index.cjs.js.map +0 -1
- package/index.js +0 -42414
- package/index.js.map +0 -1
- package/layouts.cjs.js +0 -5294
- package/layouts.cjs.js.map +0 -1
- package/layouts.js +0 -5286
- package/layouts.js.map +0 -1
- package/managers.cjs.js.map +0 -1
- package/managers.js.map +0 -1
- /package/{index.css → dist/cjs/index.css} +0 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,4403 @@
|
|
|
1
|
+
import { _ as _objectWithoutProperties, a as _extends, c as classnames, b as _defineProperty, d as _slicedToArray, T as Tooltip, i as index$1, h as hyphenize, n as noop, l as lib, e as convertToDayjsObjects, A as ANT_DESIGN_GLOBAL_TOKEN_OVERRIDES, f as commonjsGlobal, g as dayjs, j as Typography, k as buildUrl, U as UniqueArray } from './Typography-3bf740f3.js';
|
|
2
|
+
export { T as Tooltip, j as Typography } from './Typography-3bf740f3.js';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import React__default, { useState, useEffect, forwardRef, useRef, useMemo, useCallback } from 'react';
|
|
5
|
+
import { isEmpty, isNil, mergeLeft, move, has, equals, props, all, includes, __, pluck, assoc } from 'ramda';
|
|
6
|
+
import { AnimatePresence, motion } from 'framer-motion';
|
|
7
|
+
import { Right, Down, Focus, Left, Calendar, Close, Clock, UpArrow, DownArrow, MenuHorizontal, Check, CheckCircle, Warning, CloseCircle, Info } from '@bigbinary/neeto-icons';
|
|
8
|
+
import { B as Button, _ as _asyncToGenerator, r as regenerator, u as useId, a as useSyncedRef, L as Label, b as _toConsumableArray, c as useOverlayManager, d as useOverlay, P as Portal, C as CSSTransition, e as Backdrop } from './TreeSelect-af6d4145.js';
|
|
9
|
+
export { A as Alert, B as Button, f as Checkbox, I as Input, L as Label, g as Modal, M as MultiEmailInput, R as Radio, S as Select, l as Slider, h as Spinner, i as Switch, T as Tag, j as Textarea, k as TreeSelect } from './TreeSelect-af6d4145.js';
|
|
10
|
+
import { isPresent, isNotPresent, noop as noop$1, snakeToCamelCase, camelToSnakeCase, isNotEmpty, modifyBy, dynamicArray } from '@bigbinary/neeto-cist';
|
|
11
|
+
import { Link, useLocation, useHistory, NavLink } from 'react-router-dom';
|
|
12
|
+
export { A as Avatar } from './index-f5a4691b.js';
|
|
13
|
+
import { HexColorInput, HexAlphaColorPicker, HexColorPicker } from 'react-colorful';
|
|
14
|
+
import _ConfigProvider from 'antd/lib/config-provider';
|
|
15
|
+
import _DatePicker from 'antd/lib/date-picker';
|
|
16
|
+
import './overlayManager-4d5be56b.js';
|
|
17
|
+
import TimeRangePicker from '@wojtekmaj/react-timerange-picker';
|
|
18
|
+
import TimePicker$1 from 'react-time-picker';
|
|
19
|
+
import _Table from 'antd/lib/table';
|
|
20
|
+
import ReactDragListView from 'react-drag-listview';
|
|
21
|
+
import { Resizable } from 'react-resizable';
|
|
22
|
+
import { _ as _typeof } from './createClass-27bd48bc.js';
|
|
23
|
+
import { t } from 'i18next';
|
|
24
|
+
import { Slide, toast } from 'react-toastify';
|
|
25
|
+
import { Options, options, tokenize } from 'linkifyjs';
|
|
26
|
+
import _Tree from 'antd/lib/tree';
|
|
27
|
+
import 'util';
|
|
28
|
+
import 'tippy.js';
|
|
29
|
+
import 'react-dom';
|
|
30
|
+
import 'react-select/creatable';
|
|
31
|
+
import 'react-select';
|
|
32
|
+
import 'react-select/async';
|
|
33
|
+
import 'react-select/async-creatable';
|
|
34
|
+
import 'antd/lib/slider';
|
|
35
|
+
import 'antd/lib/tree-select';
|
|
36
|
+
import 'boring-avatars';
|
|
37
|
+
|
|
38
|
+
var _excluded$l = ["open", "children", "className"];
|
|
39
|
+
var Collapse = function Collapse(_ref) {
|
|
40
|
+
var _ref$open = _ref.open,
|
|
41
|
+
open = _ref$open === void 0 ? false : _ref$open,
|
|
42
|
+
children = _ref.children,
|
|
43
|
+
_ref$className = _ref.className,
|
|
44
|
+
className = _ref$className === void 0 ? "" : _ref$className,
|
|
45
|
+
otherProps = _objectWithoutProperties(_ref, _excluded$l);
|
|
46
|
+
return /*#__PURE__*/React__default.createElement(AnimatePresence, null, open && /*#__PURE__*/React__default.createElement(motion.div, _extends({
|
|
47
|
+
animate: {
|
|
48
|
+
opacity: 1,
|
|
49
|
+
height: "auto"
|
|
50
|
+
},
|
|
51
|
+
exit: {
|
|
52
|
+
opacity: 0,
|
|
53
|
+
height: 0
|
|
54
|
+
},
|
|
55
|
+
initial: {
|
|
56
|
+
opacity: 0,
|
|
57
|
+
height: 0,
|
|
58
|
+
overflow: "hidden"
|
|
59
|
+
},
|
|
60
|
+
transition: {
|
|
61
|
+
duration: 0.3
|
|
62
|
+
}
|
|
63
|
+
}, otherProps), /*#__PURE__*/React__default.createElement("div", {
|
|
64
|
+
className: className
|
|
65
|
+
}, children)));
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
var Item$1 = function Item(_ref) {
|
|
69
|
+
var id = _ref.id,
|
|
70
|
+
_ref$title = _ref.title,
|
|
71
|
+
title = _ref$title === void 0 ? "" : _ref$title,
|
|
72
|
+
_ref$isOpen = _ref.isOpen,
|
|
73
|
+
isOpen = _ref$isOpen === void 0 ? false : _ref$isOpen,
|
|
74
|
+
_ref$onClick = _ref.onClick,
|
|
75
|
+
onClick = _ref$onClick === void 0 ? function () {} : _ref$onClick,
|
|
76
|
+
children = _ref.children,
|
|
77
|
+
_ref$className = _ref.className,
|
|
78
|
+
className = _ref$className === void 0 ? "" : _ref$className,
|
|
79
|
+
_ref$titleProps = _ref.titleProps,
|
|
80
|
+
titleProps = _ref$titleProps === void 0 ? {} : _ref$titleProps,
|
|
81
|
+
_ref$iconProps = _ref.iconProps,
|
|
82
|
+
iconProps = _ref$iconProps === void 0 ? {} : _ref$iconProps;
|
|
83
|
+
var onKeyDown = function onKeyDown(e) {
|
|
84
|
+
switch (e.key) {
|
|
85
|
+
case " ":
|
|
86
|
+
case "Enter":
|
|
87
|
+
onClick();
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
92
|
+
className: classnames("neeto-ui-accordion__wrapper", _defineProperty({}, className, className))
|
|
93
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
94
|
+
onClick: onClick,
|
|
95
|
+
onKeyDown: onKeyDown,
|
|
96
|
+
"aria-controls": "neeto-ui-accordion-section-".concat(id),
|
|
97
|
+
"aria-disabled": isOpen,
|
|
98
|
+
"aria-expanded": isOpen,
|
|
99
|
+
id: "neeto-ui-accordion-item-".concat(id),
|
|
100
|
+
role: "button",
|
|
101
|
+
tabIndex: 0,
|
|
102
|
+
className: classnames("neeto-ui-accordion__item neeto-ui-flex neeto-ui-justify-between neeto-ui-items-center", {
|
|
103
|
+
"neeto-ui-accordion__item--open": isOpen
|
|
104
|
+
})
|
|
105
|
+
}, /*#__PURE__*/React__default.createElement("div", _extends({}, titleProps, {
|
|
106
|
+
className: "neeto-ui-accordion__item-handle neeto-ui-flex neeto-ui-flex-grow neeto-ui-items-center neeto-ui-break-words"
|
|
107
|
+
}), title), /*#__PURE__*/React__default.createElement(motion.div, {
|
|
108
|
+
animate: isOpen ? "open" : "collapsed",
|
|
109
|
+
className: "neeto-ui-accordion__item-toggle-icon neeto-ui-flex-grow-0",
|
|
110
|
+
transition: {
|
|
111
|
+
duration: 0.3
|
|
112
|
+
},
|
|
113
|
+
variants: {
|
|
114
|
+
open: {
|
|
115
|
+
rotate: 90
|
|
116
|
+
},
|
|
117
|
+
collapsed: {
|
|
118
|
+
rotate: 0
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}, /*#__PURE__*/React__default.createElement(Right, _extends({
|
|
122
|
+
size: 16
|
|
123
|
+
}, iconProps)))), /*#__PURE__*/React__default.createElement(Collapse, {
|
|
124
|
+
"aria-labelledby": "neeto-ui-accordion-item-".concat(id),
|
|
125
|
+
className: "neeto-ui-accordion__drop",
|
|
126
|
+
id: "neeto-ui-accordion-section-".concat(id),
|
|
127
|
+
open: isOpen,
|
|
128
|
+
role: "region"
|
|
129
|
+
}, children));
|
|
130
|
+
};
|
|
131
|
+
Item$1.displayName = "Accordion.Item";
|
|
132
|
+
|
|
133
|
+
var ACCORDION_STYLES = {
|
|
134
|
+
primary: "primary",
|
|
135
|
+
secondary: "secondary"
|
|
136
|
+
};
|
|
137
|
+
var Accordion = function Accordion(_ref) {
|
|
138
|
+
var children = _ref.children,
|
|
139
|
+
_ref$defaultActiveKey = _ref.defaultActiveKey,
|
|
140
|
+
defaultActiveKey = _ref$defaultActiveKey === void 0 ? null : _ref$defaultActiveKey,
|
|
141
|
+
_ref$padded = _ref.padded,
|
|
142
|
+
padded = _ref$padded === void 0 ? false : _ref$padded,
|
|
143
|
+
_ref$style = _ref.style,
|
|
144
|
+
style = _ref$style === void 0 ? ACCORDION_STYLES.primary : _ref$style,
|
|
145
|
+
_ref$className = _ref.className,
|
|
146
|
+
className = _ref$className === void 0 ? "" : _ref$className;
|
|
147
|
+
var _useState = useState(defaultActiveKey),
|
|
148
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
149
|
+
openTab = _useState2[0],
|
|
150
|
+
setOpenTab = _useState2[1];
|
|
151
|
+
useEffect(function () {
|
|
152
|
+
setOpenTab(defaultActiveKey);
|
|
153
|
+
}, [defaultActiveKey]);
|
|
154
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
155
|
+
className: classnames("neeto-ui-accordions-outer-wrapper", _defineProperty({
|
|
156
|
+
"neeto-ui-accordions-outer-wrapper--padded": padded,
|
|
157
|
+
"neeto-ui-accordions-outer-wrapper--secondary": style === ACCORDION_STYLES.secondary
|
|
158
|
+
}, className, className))
|
|
159
|
+
}, React__default.Children.map(children, function (child, index) {
|
|
160
|
+
var isSingleOrLastChild = isEmpty(children) || index === children.length - 1;
|
|
161
|
+
return /*#__PURE__*/React__default.cloneElement(child, {
|
|
162
|
+
id: index,
|
|
163
|
+
key: index,
|
|
164
|
+
isOpen: openTab === index,
|
|
165
|
+
className: classnames(child.props.className, {
|
|
166
|
+
"neeto-ui-accordion__wrapper--last-item": isSingleOrLastChild
|
|
167
|
+
}),
|
|
168
|
+
onClick: function onClick() {
|
|
169
|
+
setOpenTab(openTab === index ? null : index);
|
|
170
|
+
child.props.onClick && child.props.onClick();
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
}));
|
|
174
|
+
};
|
|
175
|
+
Accordion.Item = Item$1;
|
|
176
|
+
|
|
177
|
+
var Divider = function Divider(props) {
|
|
178
|
+
return /*#__PURE__*/React__default.createElement("li", _extends({
|
|
179
|
+
className: "neeto-ui-dropdown__popup-divider"
|
|
180
|
+
}, props));
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
var _excluded$k = ["children", "className"];
|
|
184
|
+
var Menu$1 = function Menu(_ref) {
|
|
185
|
+
var children = _ref.children,
|
|
186
|
+
className = _ref.className,
|
|
187
|
+
otherProps = _objectWithoutProperties(_ref, _excluded$k);
|
|
188
|
+
return /*#__PURE__*/React__default.createElement("ul", _extends({
|
|
189
|
+
className: classnames("neeto-ui-dropdown__popup-menu", className)
|
|
190
|
+
}, otherProps), children);
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
var _excluded$j = ["children", "className", "tooltipProps"];
|
|
194
|
+
var MenuItem$1 = function MenuItem(_ref) {
|
|
195
|
+
var children = _ref.children,
|
|
196
|
+
className = _ref.className,
|
|
197
|
+
tooltipProps = _ref.tooltipProps,
|
|
198
|
+
otherProps = _objectWithoutProperties(_ref, _excluded$j);
|
|
199
|
+
var renderMenuItem = function renderMenuItem() {
|
|
200
|
+
return /*#__PURE__*/React__default.createElement("li", _extends({
|
|
201
|
+
className: classnames("neeto-ui-dropdown__popup-menu-item", className)
|
|
202
|
+
}, otherProps), children);
|
|
203
|
+
};
|
|
204
|
+
if (isPresent(tooltipProps)) {
|
|
205
|
+
return /*#__PURE__*/React__default.createElement(Tooltip, tooltipProps, renderMenuItem());
|
|
206
|
+
}
|
|
207
|
+
return renderMenuItem();
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
var _excluded$i = ["children", "className", "isActive", "isDisabled", "style", "prefix", "suffix", "type", "to", "href", "tooltipProps"];
|
|
211
|
+
function ownKeys$c(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
212
|
+
function _objectSpread$c(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$c(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$c(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
213
|
+
var ITEM_BTN_STYLES = {
|
|
214
|
+
"default": "default",
|
|
215
|
+
danger: "danger"
|
|
216
|
+
};
|
|
217
|
+
var BUTTON_TYPES = {
|
|
218
|
+
button: "button",
|
|
219
|
+
reset: "reset",
|
|
220
|
+
submit: "submit"
|
|
221
|
+
};
|
|
222
|
+
var MenuItemButton = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
223
|
+
var children = _ref.children,
|
|
224
|
+
className = _ref.className,
|
|
225
|
+
isActive = _ref.isActive,
|
|
226
|
+
isDisabled = _ref.isDisabled,
|
|
227
|
+
_ref$style = _ref.style,
|
|
228
|
+
style = _ref$style === void 0 ? ITEM_BTN_STYLES["default"] : _ref$style,
|
|
229
|
+
prefix = _ref.prefix,
|
|
230
|
+
suffix = _ref.suffix,
|
|
231
|
+
_ref$type = _ref.type,
|
|
232
|
+
type = _ref$type === void 0 ? BUTTON_TYPES.button : _ref$type,
|
|
233
|
+
_ref$to = _ref.to,
|
|
234
|
+
to = _ref$to === void 0 ? "" : _ref$to,
|
|
235
|
+
_ref$href = _ref.href,
|
|
236
|
+
href = _ref$href === void 0 ? "" : _ref$href,
|
|
237
|
+
tooltipProps = _ref.tooltipProps,
|
|
238
|
+
otherProps = _objectWithoutProperties(_ref, _excluded$i);
|
|
239
|
+
var Parent, elementSpecificProps;
|
|
240
|
+
if (to) {
|
|
241
|
+
Parent = Link;
|
|
242
|
+
elementSpecificProps = {
|
|
243
|
+
to: to
|
|
244
|
+
};
|
|
245
|
+
} else if (href) {
|
|
246
|
+
Parent = "a";
|
|
247
|
+
elementSpecificProps = {
|
|
248
|
+
href: href
|
|
249
|
+
};
|
|
250
|
+
} else {
|
|
251
|
+
Parent = "button";
|
|
252
|
+
elementSpecificProps = {
|
|
253
|
+
type: type
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
return /*#__PURE__*/React__default.createElement(MenuItem$1, {
|
|
257
|
+
tooltipProps: tooltipProps
|
|
258
|
+
}, /*#__PURE__*/React__default.createElement(Parent, _extends({
|
|
259
|
+
disabled: isDisabled,
|
|
260
|
+
className: classnames("neeto-ui-dropdown__popup-menu-item-btn", className, {
|
|
261
|
+
"neeto-ui-dropdown__popup-menu-item-btn--active": isActive,
|
|
262
|
+
"neeto-ui-dropdown__popup-menu-item-btn--disabled": isDisabled,
|
|
263
|
+
"neeto-ui-dropdown__popup-menu-item-btn--style-danger": style === ITEM_BTN_STYLES.danger
|
|
264
|
+
})
|
|
265
|
+
}, _objectSpread$c(_objectSpread$c({
|
|
266
|
+
ref: ref
|
|
267
|
+
}, otherProps), elementSpecificProps)), prefix && /*#__PURE__*/React__default.createElement("div", {
|
|
268
|
+
className: "neeto-ui-dropdown__popup-menu-item-btn__prefix"
|
|
269
|
+
}, prefix), children, suffix && /*#__PURE__*/React__default.createElement("div", {
|
|
270
|
+
className: "neeto-ui-dropdown__popup-menu-item-btn__suffix"
|
|
271
|
+
}, suffix)));
|
|
272
|
+
});
|
|
273
|
+
MenuItemButton.displayName = "MenuItemButton";
|
|
274
|
+
|
|
275
|
+
MenuItem$1.Button = MenuItemButton;
|
|
276
|
+
|
|
277
|
+
var _excluded$h = ["style", "size"],
|
|
278
|
+
_excluded2$1 = ["icon", "label", "isOpen", "onClose", "dropdownProps", "position", "children", "className", "buttonStyle", "buttonSize", "buttonProps", "customTarget", "disabled", "closeOnEsc", "closeOnSelect", "closeOnOutsideClick", "dropdownModifiers", "trigger", "strategy", "onClick"],
|
|
279
|
+
_excluded3 = ["classNames"];
|
|
280
|
+
function ownKeys$b(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
281
|
+
function _objectSpread$b(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$b(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$b(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
282
|
+
var BTN_STYLES$1 = {
|
|
283
|
+
primary: "primary",
|
|
284
|
+
secondary: "secondary",
|
|
285
|
+
tertiary: "tertiary",
|
|
286
|
+
danger: "danger",
|
|
287
|
+
danger_text: "danger-text",
|
|
288
|
+
text: "text",
|
|
289
|
+
link: "link"
|
|
290
|
+
};
|
|
291
|
+
var BTN_SIZES$1 = {
|
|
292
|
+
small: "small",
|
|
293
|
+
medium: "medium",
|
|
294
|
+
large: "large"
|
|
295
|
+
};
|
|
296
|
+
var STRATEGY = {
|
|
297
|
+
absolute: "absolute",
|
|
298
|
+
fixed: "fixed"
|
|
299
|
+
};
|
|
300
|
+
var PLACEMENT = {
|
|
301
|
+
auto: "auto",
|
|
302
|
+
autoStart: "auto-start",
|
|
303
|
+
autoEnd: "auto-end",
|
|
304
|
+
top: "top",
|
|
305
|
+
topStart: "top-start",
|
|
306
|
+
topEnd: "top-end",
|
|
307
|
+
bottom: "bottom",
|
|
308
|
+
bottomStart: "bottom-start",
|
|
309
|
+
bottomEnd: "bottom-end",
|
|
310
|
+
right: "right",
|
|
311
|
+
rightStart: "right-start",
|
|
312
|
+
rightEnd: "right-end",
|
|
313
|
+
left: "left",
|
|
314
|
+
leftStart: "left-start",
|
|
315
|
+
leftEnd: "left-end"
|
|
316
|
+
};
|
|
317
|
+
var TRIGGERS = {
|
|
318
|
+
click: "click",
|
|
319
|
+
hover: "mouseenter focus",
|
|
320
|
+
all: "mouseenter focus click",
|
|
321
|
+
manual: "manual"
|
|
322
|
+
};
|
|
323
|
+
var hideOnEsc = {
|
|
324
|
+
name: "hideOnEsc",
|
|
325
|
+
defaultValue: true,
|
|
326
|
+
fn: function fn(_ref) {
|
|
327
|
+
var hide = _ref.hide,
|
|
328
|
+
hideOnEsc = _ref.props.hideOnEsc;
|
|
329
|
+
function onKeyDown(event) {
|
|
330
|
+
var _event$key;
|
|
331
|
+
if (((_event$key = event.key) === null || _event$key === void 0 ? void 0 : _event$key.toLowerCase()) === "escape" && hideOnEsc) hide();
|
|
332
|
+
}
|
|
333
|
+
return {
|
|
334
|
+
onShow: function onShow() {
|
|
335
|
+
document.addEventListener("keydown", onKeyDown);
|
|
336
|
+
},
|
|
337
|
+
onHide: function onHide() {
|
|
338
|
+
document.removeEventListener("keydown", onKeyDown);
|
|
339
|
+
}
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
};
|
|
343
|
+
var plugins = [hideOnEsc];
|
|
344
|
+
var Dropdown = function Dropdown(_ref2) {
|
|
345
|
+
var icon = _ref2.icon,
|
|
346
|
+
label = _ref2.label,
|
|
347
|
+
isOpen = _ref2.isOpen,
|
|
348
|
+
_ref2$onClose = _ref2.onClose,
|
|
349
|
+
onClose = _ref2$onClose === void 0 ? noop : _ref2$onClose,
|
|
350
|
+
_ref2$dropdownProps = _ref2.dropdownProps,
|
|
351
|
+
dropdownProps = _ref2$dropdownProps === void 0 ? {} : _ref2$dropdownProps,
|
|
352
|
+
_ref2$position = _ref2.position,
|
|
353
|
+
position = _ref2$position === void 0 ? PLACEMENT.bottomEnd : _ref2$position,
|
|
354
|
+
children = _ref2.children,
|
|
355
|
+
className = _ref2.className,
|
|
356
|
+
_ref2$buttonStyle = _ref2.buttonStyle,
|
|
357
|
+
buttonStyle = _ref2$buttonStyle === void 0 ? BTN_STYLES$1.primary : _ref2$buttonStyle,
|
|
358
|
+
_ref2$buttonSize = _ref2.buttonSize,
|
|
359
|
+
buttonSize = _ref2$buttonSize === void 0 ? BTN_SIZES$1.medium : _ref2$buttonSize,
|
|
360
|
+
_ref2$buttonProps = _ref2.buttonProps,
|
|
361
|
+
_ref2$buttonProps2 = _ref2$buttonProps === void 0 ? {} : _ref2$buttonProps,
|
|
362
|
+
style = _ref2$buttonProps2.style,
|
|
363
|
+
size = _ref2$buttonProps2.size,
|
|
364
|
+
buttonProps = _objectWithoutProperties(_ref2$buttonProps2, _excluded$h),
|
|
365
|
+
customTarget = _ref2.customTarget,
|
|
366
|
+
_ref2$disabled = _ref2.disabled,
|
|
367
|
+
disabled = _ref2$disabled === void 0 ? false : _ref2$disabled,
|
|
368
|
+
_ref2$closeOnEsc = _ref2.closeOnEsc,
|
|
369
|
+
closeOnEsc = _ref2$closeOnEsc === void 0 ? true : _ref2$closeOnEsc,
|
|
370
|
+
_ref2$closeOnSelect = _ref2.closeOnSelect,
|
|
371
|
+
closeOnSelect = _ref2$closeOnSelect === void 0 ? true : _ref2$closeOnSelect,
|
|
372
|
+
_ref2$closeOnOutsideC = _ref2.closeOnOutsideClick,
|
|
373
|
+
closeOnOutsideClick = _ref2$closeOnOutsideC === void 0 ? true : _ref2$closeOnOutsideC,
|
|
374
|
+
_ref2$dropdownModifie = _ref2.dropdownModifiers,
|
|
375
|
+
dropdownModifiers = _ref2$dropdownModifie === void 0 ? [] : _ref2$dropdownModifie,
|
|
376
|
+
_ref2$trigger = _ref2.trigger,
|
|
377
|
+
trigger = _ref2$trigger === void 0 ? TRIGGERS.click : _ref2$trigger,
|
|
378
|
+
_ref2$strategy = _ref2.strategy,
|
|
379
|
+
strategy = _ref2$strategy === void 0 ? STRATEGY.absolute : _ref2$strategy,
|
|
380
|
+
onClick = _ref2.onClick,
|
|
381
|
+
otherProps = _objectWithoutProperties(_ref2, _excluded2$1);
|
|
382
|
+
var _useState = useState(null),
|
|
383
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
384
|
+
instance = _useState2[0],
|
|
385
|
+
setInstance = _useState2[1];
|
|
386
|
+
var _useState3 = useState(false),
|
|
387
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
388
|
+
mounted = _useState4[0],
|
|
389
|
+
setMounted = _useState4[1];
|
|
390
|
+
var isControlled = !isNil(isOpen);
|
|
391
|
+
var controlledProps = isControlled ? {
|
|
392
|
+
visible: isOpen
|
|
393
|
+
} : {
|
|
394
|
+
onClickOutside: function onClickOutside() {
|
|
395
|
+
return closeOnOutsideClick;
|
|
396
|
+
}
|
|
397
|
+
};
|
|
398
|
+
var dropdownClassname = dropdownProps.classNames,
|
|
399
|
+
otherDropdownProps = _objectWithoutProperties(dropdownProps, _excluded3);
|
|
400
|
+
var close = function close() {
|
|
401
|
+
return instance.hide();
|
|
402
|
+
};
|
|
403
|
+
return /*#__PURE__*/React__default.createElement(index$1, _extends({
|
|
404
|
+
interactive: true,
|
|
405
|
+
animation: false,
|
|
406
|
+
arrow: false,
|
|
407
|
+
duration: 0
|
|
408
|
+
// hideOnClick determines whether the dropdown should be hidden when the user clicks outside of the dropdown.
|
|
409
|
+
// https://atomiks.github.io/tippyjs/v6/all-props/#hideonclick
|
|
410
|
+
,
|
|
411
|
+
hideOnClick: isControlled ? undefined : closeOnOutsideClick || "toggle",
|
|
412
|
+
hideOnEsc: closeOnEsc,
|
|
413
|
+
maxWidth: "none",
|
|
414
|
+
offset: 0,
|
|
415
|
+
placement: position || PLACEMENT.bottomEnd,
|
|
416
|
+
popperOptions: {
|
|
417
|
+
strategy: strategy,
|
|
418
|
+
modifiers: dropdownModifiers
|
|
419
|
+
},
|
|
420
|
+
role: "dropdown",
|
|
421
|
+
theme: "light",
|
|
422
|
+
trigger: isControlled ? undefined : TRIGGERS[trigger],
|
|
423
|
+
className: classnames("neeto-ui-dropdown", _defineProperty({}, className, className)),
|
|
424
|
+
content: mounted ? /*#__PURE__*/React__default.createElement("div", _extends({
|
|
425
|
+
"data-cy": "".concat(hyphenize(label), "-dropdown-container"),
|
|
426
|
+
className: classnames("neeto-ui-dropdown__popup", _defineProperty({}, dropdownClassname, dropdownClassname)),
|
|
427
|
+
onClick: closeOnSelect ? close : noop
|
|
428
|
+
}, otherDropdownProps), children) : null,
|
|
429
|
+
onCreate: function onCreate(instance) {
|
|
430
|
+
return instance && setInstance(instance);
|
|
431
|
+
},
|
|
432
|
+
onMount: function onMount() {
|
|
433
|
+
return setMounted(true);
|
|
434
|
+
},
|
|
435
|
+
onHidden: function onHidden() {
|
|
436
|
+
onClose();
|
|
437
|
+
setMounted(false);
|
|
438
|
+
}
|
|
439
|
+
}, _objectSpread$b(_objectSpread$b({
|
|
440
|
+
plugins: plugins
|
|
441
|
+
}, otherProps), controlledProps)), customTarget ? /*#__PURE__*/React__default.createElement("span", {
|
|
442
|
+
onClick: onClick
|
|
443
|
+
}, typeof customTarget === "function" ? customTarget() : customTarget) : /*#__PURE__*/React__default.createElement(Button, _extends({
|
|
444
|
+
label: label,
|
|
445
|
+
onClick: onClick,
|
|
446
|
+
"data-cy": "".concat(hyphenize(label), "-dropdown-icon"),
|
|
447
|
+
disabled: disabled || (buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.disabled),
|
|
448
|
+
icon: icon || Down,
|
|
449
|
+
iconPosition: "right",
|
|
450
|
+
size: size !== null && size !== void 0 ? size : buttonSize,
|
|
451
|
+
style: style !== null && style !== void 0 ? style : buttonStyle
|
|
452
|
+
}, buttonProps)));
|
|
453
|
+
};
|
|
454
|
+
Dropdown.Menu = Menu$1;
|
|
455
|
+
Dropdown.MenuItem = MenuItem$1;
|
|
456
|
+
Dropdown.Divider = Divider;
|
|
457
|
+
|
|
458
|
+
var _excluded$g = ["style", "size"];
|
|
459
|
+
var BTN_STYLES = {
|
|
460
|
+
primary: "primary",
|
|
461
|
+
secondary: "secondary"
|
|
462
|
+
};
|
|
463
|
+
var BTN_SIZES = {
|
|
464
|
+
small: "small",
|
|
465
|
+
medium: "medium",
|
|
466
|
+
large: "large"
|
|
467
|
+
};
|
|
468
|
+
var ActionDropdown = function ActionDropdown(_ref) {
|
|
469
|
+
var _ref$label = _ref.label,
|
|
470
|
+
label = _ref$label === void 0 ? "" : _ref$label,
|
|
471
|
+
_ref$buttonStyle = _ref.buttonStyle,
|
|
472
|
+
buttonStyle = _ref$buttonStyle === void 0 ? BTN_STYLES.primary : _ref$buttonStyle,
|
|
473
|
+
_ref$buttonSize = _ref.buttonSize,
|
|
474
|
+
buttonSize = _ref$buttonSize === void 0 ? BTN_SIZES.medium : _ref$buttonSize,
|
|
475
|
+
_ref$disabled = _ref.disabled,
|
|
476
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
477
|
+
_ref$onClick = _ref.onClick,
|
|
478
|
+
onClick = _ref$onClick === void 0 ? noop : _ref$onClick,
|
|
479
|
+
_ref$buttonProps = _ref.buttonProps,
|
|
480
|
+
_ref$buttonProps2 = _ref$buttonProps === void 0 ? {} : _ref$buttonProps,
|
|
481
|
+
style = _ref$buttonProps2.style,
|
|
482
|
+
size = _ref$buttonProps2.size,
|
|
483
|
+
buttonProps = _objectWithoutProperties(_ref$buttonProps2, _excluded$g),
|
|
484
|
+
_ref$dropdownProps = _ref.dropdownProps,
|
|
485
|
+
dropdownProps = _ref$dropdownProps === void 0 ? {} : _ref$dropdownProps,
|
|
486
|
+
_ref$className = _ref.className,
|
|
487
|
+
className = _ref$className === void 0 ? "" : _ref$className,
|
|
488
|
+
children = _ref.children;
|
|
489
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
490
|
+
className: classnames(["neeto-ui-action-dropdown", className])
|
|
491
|
+
}, /*#__PURE__*/React__default.createElement(Button, _extends({
|
|
492
|
+
"data-testid": "action-dropdown-btn",
|
|
493
|
+
disabled: disabled,
|
|
494
|
+
label: label,
|
|
495
|
+
size: size !== null && size !== void 0 ? size : buttonSize,
|
|
496
|
+
style: style !== null && style !== void 0 ? style : buttonStyle,
|
|
497
|
+
onClick: onClick
|
|
498
|
+
}, buttonProps)), /*#__PURE__*/React__default.createElement(Dropdown, _extends({
|
|
499
|
+
buttonProps: {
|
|
500
|
+
size: size !== null && size !== void 0 ? size : buttonSize
|
|
501
|
+
},
|
|
502
|
+
buttonStyle: style !== null && style !== void 0 ? style : buttonStyle,
|
|
503
|
+
disabled: disabled
|
|
504
|
+
}, dropdownProps), children));
|
|
505
|
+
};
|
|
506
|
+
ActionDropdown.Menu = Dropdown.Menu;
|
|
507
|
+
ActionDropdown.MenuItem = Dropdown.MenuItem;
|
|
508
|
+
ActionDropdown.Divider = Dropdown.Divider;
|
|
509
|
+
|
|
510
|
+
function ownKeys$a(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
511
|
+
function _objectSpread$a(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$a(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$a(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
512
|
+
var useQueryParams = function useQueryParams() {
|
|
513
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
514
|
+
var location = useLocation();
|
|
515
|
+
return lib.parse(location.search, _objectSpread$a({
|
|
516
|
+
ignoreQueryPrefix: true
|
|
517
|
+
}, options));
|
|
518
|
+
};
|
|
519
|
+
|
|
520
|
+
var useTimeout = function useTimeout(callback, delay) {
|
|
521
|
+
var savedCallback = useRef(callback);
|
|
522
|
+
useEffect(function () {
|
|
523
|
+
savedCallback.current = callback;
|
|
524
|
+
}, [callback]);
|
|
525
|
+
useEffect(function () {
|
|
526
|
+
if (delay === null) {
|
|
527
|
+
return undefined;
|
|
528
|
+
}
|
|
529
|
+
var id = setTimeout(function () {
|
|
530
|
+
return savedCallback.current();
|
|
531
|
+
}, delay);
|
|
532
|
+
return function () {
|
|
533
|
+
return clearTimeout(id);
|
|
534
|
+
};
|
|
535
|
+
}, [delay]);
|
|
536
|
+
};
|
|
537
|
+
|
|
538
|
+
var _excluded$f = ["icon", "style", "className", "children"];
|
|
539
|
+
var STYLES = {
|
|
540
|
+
info: "info",
|
|
541
|
+
warning: "warning",
|
|
542
|
+
danger: "danger",
|
|
543
|
+
success: "success"
|
|
544
|
+
};
|
|
545
|
+
var Callout = function Callout(_ref) {
|
|
546
|
+
var _ref$icon = _ref.icon,
|
|
547
|
+
icon = _ref$icon === void 0 ? null : _ref$icon,
|
|
548
|
+
_ref$style = _ref.style,
|
|
549
|
+
style = _ref$style === void 0 ? STYLES.info : _ref$style,
|
|
550
|
+
_ref$className = _ref.className,
|
|
551
|
+
className = _ref$className === void 0 ? "" : _ref$className,
|
|
552
|
+
children = _ref.children,
|
|
553
|
+
otherProps = _objectWithoutProperties(_ref, _excluded$f);
|
|
554
|
+
var Icon = icon;
|
|
555
|
+
return /*#__PURE__*/React__default.createElement("div", _extends({
|
|
556
|
+
className: classnames("neeto-ui-callout", _defineProperty({
|
|
557
|
+
"neeto-ui-callout--info": style === STYLES.info,
|
|
558
|
+
"neeto-ui-callout--warning": style === STYLES.warning,
|
|
559
|
+
"neeto-ui-callout--danger": style === STYLES.danger,
|
|
560
|
+
"neeto-ui-callout--success": style === STYLES.success
|
|
561
|
+
}, className, className))
|
|
562
|
+
}, otherProps), icon && /*#__PURE__*/React__default.createElement("div", {
|
|
563
|
+
className: "neeto-ui-callout__icon",
|
|
564
|
+
"data-testid": "callout-icon"
|
|
565
|
+
}, /*#__PURE__*/React__default.createElement(Icon, null)), children);
|
|
566
|
+
};
|
|
567
|
+
|
|
568
|
+
var tinycolor$1 = {exports: {}};
|
|
569
|
+
|
|
570
|
+
(function (module) {
|
|
571
|
+
// TinyColor v1.4.2
|
|
572
|
+
// https://github.com/bgrins/TinyColor
|
|
573
|
+
// Brian Grinstead, MIT License
|
|
574
|
+
|
|
575
|
+
(function(Math) {
|
|
576
|
+
|
|
577
|
+
var trimLeft = /^\s+/,
|
|
578
|
+
trimRight = /\s+$/,
|
|
579
|
+
tinyCounter = 0,
|
|
580
|
+
mathRound = Math.round,
|
|
581
|
+
mathMin = Math.min,
|
|
582
|
+
mathMax = Math.max,
|
|
583
|
+
mathRandom = Math.random;
|
|
584
|
+
|
|
585
|
+
function tinycolor (color, opts) {
|
|
586
|
+
|
|
587
|
+
color = (color) ? color : '';
|
|
588
|
+
opts = opts || { };
|
|
589
|
+
|
|
590
|
+
// If input is already a tinycolor, return itself
|
|
591
|
+
if (color instanceof tinycolor) {
|
|
592
|
+
return color;
|
|
593
|
+
}
|
|
594
|
+
// If we are called as a function, call using new instead
|
|
595
|
+
if (!(this instanceof tinycolor)) {
|
|
596
|
+
return new tinycolor(color, opts);
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
var rgb = inputToRGB(color);
|
|
600
|
+
this._originalInput = color,
|
|
601
|
+
this._r = rgb.r,
|
|
602
|
+
this._g = rgb.g,
|
|
603
|
+
this._b = rgb.b,
|
|
604
|
+
this._a = rgb.a,
|
|
605
|
+
this._roundA = mathRound(100*this._a) / 100,
|
|
606
|
+
this._format = opts.format || rgb.format;
|
|
607
|
+
this._gradientType = opts.gradientType;
|
|
608
|
+
|
|
609
|
+
// Don't let the range of [0,255] come back in [0,1].
|
|
610
|
+
// Potentially lose a little bit of precision here, but will fix issues where
|
|
611
|
+
// .5 gets interpreted as half of the total, instead of half of 1
|
|
612
|
+
// If it was supposed to be 128, this was already taken care of by `inputToRgb`
|
|
613
|
+
if (this._r < 1) { this._r = mathRound(this._r); }
|
|
614
|
+
if (this._g < 1) { this._g = mathRound(this._g); }
|
|
615
|
+
if (this._b < 1) { this._b = mathRound(this._b); }
|
|
616
|
+
|
|
617
|
+
this._ok = rgb.ok;
|
|
618
|
+
this._tc_id = tinyCounter++;
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
tinycolor.prototype = {
|
|
622
|
+
isDark: function() {
|
|
623
|
+
return this.getBrightness() < 128;
|
|
624
|
+
},
|
|
625
|
+
isLight: function() {
|
|
626
|
+
return !this.isDark();
|
|
627
|
+
},
|
|
628
|
+
isValid: function() {
|
|
629
|
+
return this._ok;
|
|
630
|
+
},
|
|
631
|
+
getOriginalInput: function() {
|
|
632
|
+
return this._originalInput;
|
|
633
|
+
},
|
|
634
|
+
getFormat: function() {
|
|
635
|
+
return this._format;
|
|
636
|
+
},
|
|
637
|
+
getAlpha: function() {
|
|
638
|
+
return this._a;
|
|
639
|
+
},
|
|
640
|
+
getBrightness: function() {
|
|
641
|
+
//http://www.w3.org/TR/AERT#color-contrast
|
|
642
|
+
var rgb = this.toRgb();
|
|
643
|
+
return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000;
|
|
644
|
+
},
|
|
645
|
+
getLuminance: function() {
|
|
646
|
+
//http://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef
|
|
647
|
+
var rgb = this.toRgb();
|
|
648
|
+
var RsRGB, GsRGB, BsRGB, R, G, B;
|
|
649
|
+
RsRGB = rgb.r/255;
|
|
650
|
+
GsRGB = rgb.g/255;
|
|
651
|
+
BsRGB = rgb.b/255;
|
|
652
|
+
|
|
653
|
+
if (RsRGB <= 0.03928) {R = RsRGB / 12.92;} else {R = Math.pow(((RsRGB + 0.055) / 1.055), 2.4);}
|
|
654
|
+
if (GsRGB <= 0.03928) {G = GsRGB / 12.92;} else {G = Math.pow(((GsRGB + 0.055) / 1.055), 2.4);}
|
|
655
|
+
if (BsRGB <= 0.03928) {B = BsRGB / 12.92;} else {B = Math.pow(((BsRGB + 0.055) / 1.055), 2.4);}
|
|
656
|
+
return (0.2126 * R) + (0.7152 * G) + (0.0722 * B);
|
|
657
|
+
},
|
|
658
|
+
setAlpha: function(value) {
|
|
659
|
+
this._a = boundAlpha(value);
|
|
660
|
+
this._roundA = mathRound(100*this._a) / 100;
|
|
661
|
+
return this;
|
|
662
|
+
},
|
|
663
|
+
toHsv: function() {
|
|
664
|
+
var hsv = rgbToHsv(this._r, this._g, this._b);
|
|
665
|
+
return { h: hsv.h * 360, s: hsv.s, v: hsv.v, a: this._a };
|
|
666
|
+
},
|
|
667
|
+
toHsvString: function() {
|
|
668
|
+
var hsv = rgbToHsv(this._r, this._g, this._b);
|
|
669
|
+
var h = mathRound(hsv.h * 360), s = mathRound(hsv.s * 100), v = mathRound(hsv.v * 100);
|
|
670
|
+
return (this._a == 1) ?
|
|
671
|
+
"hsv(" + h + ", " + s + "%, " + v + "%)" :
|
|
672
|
+
"hsva(" + h + ", " + s + "%, " + v + "%, "+ this._roundA + ")";
|
|
673
|
+
},
|
|
674
|
+
toHsl: function() {
|
|
675
|
+
var hsl = rgbToHsl(this._r, this._g, this._b);
|
|
676
|
+
return { h: hsl.h * 360, s: hsl.s, l: hsl.l, a: this._a };
|
|
677
|
+
},
|
|
678
|
+
toHslString: function() {
|
|
679
|
+
var hsl = rgbToHsl(this._r, this._g, this._b);
|
|
680
|
+
var h = mathRound(hsl.h * 360), s = mathRound(hsl.s * 100), l = mathRound(hsl.l * 100);
|
|
681
|
+
return (this._a == 1) ?
|
|
682
|
+
"hsl(" + h + ", " + s + "%, " + l + "%)" :
|
|
683
|
+
"hsla(" + h + ", " + s + "%, " + l + "%, "+ this._roundA + ")";
|
|
684
|
+
},
|
|
685
|
+
toHex: function(allow3Char) {
|
|
686
|
+
return rgbToHex(this._r, this._g, this._b, allow3Char);
|
|
687
|
+
},
|
|
688
|
+
toHexString: function(allow3Char) {
|
|
689
|
+
return '#' + this.toHex(allow3Char);
|
|
690
|
+
},
|
|
691
|
+
toHex8: function(allow4Char) {
|
|
692
|
+
return rgbaToHex(this._r, this._g, this._b, this._a, allow4Char);
|
|
693
|
+
},
|
|
694
|
+
toHex8String: function(allow4Char) {
|
|
695
|
+
return '#' + this.toHex8(allow4Char);
|
|
696
|
+
},
|
|
697
|
+
toRgb: function() {
|
|
698
|
+
return { r: mathRound(this._r), g: mathRound(this._g), b: mathRound(this._b), a: this._a };
|
|
699
|
+
},
|
|
700
|
+
toRgbString: function() {
|
|
701
|
+
return (this._a == 1) ?
|
|
702
|
+
"rgb(" + mathRound(this._r) + ", " + mathRound(this._g) + ", " + mathRound(this._b) + ")" :
|
|
703
|
+
"rgba(" + mathRound(this._r) + ", " + mathRound(this._g) + ", " + mathRound(this._b) + ", " + this._roundA + ")";
|
|
704
|
+
},
|
|
705
|
+
toPercentageRgb: function() {
|
|
706
|
+
return { r: mathRound(bound01(this._r, 255) * 100) + "%", g: mathRound(bound01(this._g, 255) * 100) + "%", b: mathRound(bound01(this._b, 255) * 100) + "%", a: this._a };
|
|
707
|
+
},
|
|
708
|
+
toPercentageRgbString: function() {
|
|
709
|
+
return (this._a == 1) ?
|
|
710
|
+
"rgb(" + mathRound(bound01(this._r, 255) * 100) + "%, " + mathRound(bound01(this._g, 255) * 100) + "%, " + mathRound(bound01(this._b, 255) * 100) + "%)" :
|
|
711
|
+
"rgba(" + mathRound(bound01(this._r, 255) * 100) + "%, " + mathRound(bound01(this._g, 255) * 100) + "%, " + mathRound(bound01(this._b, 255) * 100) + "%, " + this._roundA + ")";
|
|
712
|
+
},
|
|
713
|
+
toName: function() {
|
|
714
|
+
if (this._a === 0) {
|
|
715
|
+
return "transparent";
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
if (this._a < 1) {
|
|
719
|
+
return false;
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
return hexNames[rgbToHex(this._r, this._g, this._b, true)] || false;
|
|
723
|
+
},
|
|
724
|
+
toFilter: function(secondColor) {
|
|
725
|
+
var hex8String = '#' + rgbaToArgbHex(this._r, this._g, this._b, this._a);
|
|
726
|
+
var secondHex8String = hex8String;
|
|
727
|
+
var gradientType = this._gradientType ? "GradientType = 1, " : "";
|
|
728
|
+
|
|
729
|
+
if (secondColor) {
|
|
730
|
+
var s = tinycolor(secondColor);
|
|
731
|
+
secondHex8String = '#' + rgbaToArgbHex(s._r, s._g, s._b, s._a);
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
return "progid:DXImageTransform.Microsoft.gradient("+gradientType+"startColorstr="+hex8String+",endColorstr="+secondHex8String+")";
|
|
735
|
+
},
|
|
736
|
+
toString: function(format) {
|
|
737
|
+
var formatSet = !!format;
|
|
738
|
+
format = format || this._format;
|
|
739
|
+
|
|
740
|
+
var formattedString = false;
|
|
741
|
+
var hasAlpha = this._a < 1 && this._a >= 0;
|
|
742
|
+
var needsAlphaFormat = !formatSet && hasAlpha && (format === "hex" || format === "hex6" || format === "hex3" || format === "hex4" || format === "hex8" || format === "name");
|
|
743
|
+
|
|
744
|
+
if (needsAlphaFormat) {
|
|
745
|
+
// Special case for "transparent", all other non-alpha formats
|
|
746
|
+
// will return rgba when there is transparency.
|
|
747
|
+
if (format === "name" && this._a === 0) {
|
|
748
|
+
return this.toName();
|
|
749
|
+
}
|
|
750
|
+
return this.toRgbString();
|
|
751
|
+
}
|
|
752
|
+
if (format === "rgb") {
|
|
753
|
+
formattedString = this.toRgbString();
|
|
754
|
+
}
|
|
755
|
+
if (format === "prgb") {
|
|
756
|
+
formattedString = this.toPercentageRgbString();
|
|
757
|
+
}
|
|
758
|
+
if (format === "hex" || format === "hex6") {
|
|
759
|
+
formattedString = this.toHexString();
|
|
760
|
+
}
|
|
761
|
+
if (format === "hex3") {
|
|
762
|
+
formattedString = this.toHexString(true);
|
|
763
|
+
}
|
|
764
|
+
if (format === "hex4") {
|
|
765
|
+
formattedString = this.toHex8String(true);
|
|
766
|
+
}
|
|
767
|
+
if (format === "hex8") {
|
|
768
|
+
formattedString = this.toHex8String();
|
|
769
|
+
}
|
|
770
|
+
if (format === "name") {
|
|
771
|
+
formattedString = this.toName();
|
|
772
|
+
}
|
|
773
|
+
if (format === "hsl") {
|
|
774
|
+
formattedString = this.toHslString();
|
|
775
|
+
}
|
|
776
|
+
if (format === "hsv") {
|
|
777
|
+
formattedString = this.toHsvString();
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
return formattedString || this.toHexString();
|
|
781
|
+
},
|
|
782
|
+
clone: function() {
|
|
783
|
+
return tinycolor(this.toString());
|
|
784
|
+
},
|
|
785
|
+
|
|
786
|
+
_applyModification: function(fn, args) {
|
|
787
|
+
var color = fn.apply(null, [this].concat([].slice.call(args)));
|
|
788
|
+
this._r = color._r;
|
|
789
|
+
this._g = color._g;
|
|
790
|
+
this._b = color._b;
|
|
791
|
+
this.setAlpha(color._a);
|
|
792
|
+
return this;
|
|
793
|
+
},
|
|
794
|
+
lighten: function() {
|
|
795
|
+
return this._applyModification(lighten, arguments);
|
|
796
|
+
},
|
|
797
|
+
brighten: function() {
|
|
798
|
+
return this._applyModification(brighten, arguments);
|
|
799
|
+
},
|
|
800
|
+
darken: function() {
|
|
801
|
+
return this._applyModification(darken, arguments);
|
|
802
|
+
},
|
|
803
|
+
desaturate: function() {
|
|
804
|
+
return this._applyModification(desaturate, arguments);
|
|
805
|
+
},
|
|
806
|
+
saturate: function() {
|
|
807
|
+
return this._applyModification(saturate, arguments);
|
|
808
|
+
},
|
|
809
|
+
greyscale: function() {
|
|
810
|
+
return this._applyModification(greyscale, arguments);
|
|
811
|
+
},
|
|
812
|
+
spin: function() {
|
|
813
|
+
return this._applyModification(spin, arguments);
|
|
814
|
+
},
|
|
815
|
+
|
|
816
|
+
_applyCombination: function(fn, args) {
|
|
817
|
+
return fn.apply(null, [this].concat([].slice.call(args)));
|
|
818
|
+
},
|
|
819
|
+
analogous: function() {
|
|
820
|
+
return this._applyCombination(analogous, arguments);
|
|
821
|
+
},
|
|
822
|
+
complement: function() {
|
|
823
|
+
return this._applyCombination(complement, arguments);
|
|
824
|
+
},
|
|
825
|
+
monochromatic: function() {
|
|
826
|
+
return this._applyCombination(monochromatic, arguments);
|
|
827
|
+
},
|
|
828
|
+
splitcomplement: function() {
|
|
829
|
+
return this._applyCombination(splitcomplement, arguments);
|
|
830
|
+
},
|
|
831
|
+
triad: function() {
|
|
832
|
+
return this._applyCombination(triad, arguments);
|
|
833
|
+
},
|
|
834
|
+
tetrad: function() {
|
|
835
|
+
return this._applyCombination(tetrad, arguments);
|
|
836
|
+
}
|
|
837
|
+
};
|
|
838
|
+
|
|
839
|
+
// If input is an object, force 1 into "1.0" to handle ratios properly
|
|
840
|
+
// String input requires "1.0" as input, so 1 will be treated as 1
|
|
841
|
+
tinycolor.fromRatio = function(color, opts) {
|
|
842
|
+
if (typeof color == "object") {
|
|
843
|
+
var newColor = {};
|
|
844
|
+
for (var i in color) {
|
|
845
|
+
if (color.hasOwnProperty(i)) {
|
|
846
|
+
if (i === "a") {
|
|
847
|
+
newColor[i] = color[i];
|
|
848
|
+
}
|
|
849
|
+
else {
|
|
850
|
+
newColor[i] = convertToPercentage(color[i]);
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
color = newColor;
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
return tinycolor(color, opts);
|
|
858
|
+
};
|
|
859
|
+
|
|
860
|
+
// Given a string or object, convert that input to RGB
|
|
861
|
+
// Possible string inputs:
|
|
862
|
+
//
|
|
863
|
+
// "red"
|
|
864
|
+
// "#f00" or "f00"
|
|
865
|
+
// "#ff0000" or "ff0000"
|
|
866
|
+
// "#ff000000" or "ff000000"
|
|
867
|
+
// "rgb 255 0 0" or "rgb (255, 0, 0)"
|
|
868
|
+
// "rgb 1.0 0 0" or "rgb (1, 0, 0)"
|
|
869
|
+
// "rgba (255, 0, 0, 1)" or "rgba 255, 0, 0, 1"
|
|
870
|
+
// "rgba (1.0, 0, 0, 1)" or "rgba 1.0, 0, 0, 1"
|
|
871
|
+
// "hsl(0, 100%, 50%)" or "hsl 0 100% 50%"
|
|
872
|
+
// "hsla(0, 100%, 50%, 1)" or "hsla 0 100% 50%, 1"
|
|
873
|
+
// "hsv(0, 100%, 100%)" or "hsv 0 100% 100%"
|
|
874
|
+
//
|
|
875
|
+
function inputToRGB(color) {
|
|
876
|
+
|
|
877
|
+
var rgb = { r: 0, g: 0, b: 0 };
|
|
878
|
+
var a = 1;
|
|
879
|
+
var s = null;
|
|
880
|
+
var v = null;
|
|
881
|
+
var l = null;
|
|
882
|
+
var ok = false;
|
|
883
|
+
var format = false;
|
|
884
|
+
|
|
885
|
+
if (typeof color == "string") {
|
|
886
|
+
color = stringInputToObject(color);
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
if (typeof color == "object") {
|
|
890
|
+
if (isValidCSSUnit(color.r) && isValidCSSUnit(color.g) && isValidCSSUnit(color.b)) {
|
|
891
|
+
rgb = rgbToRgb(color.r, color.g, color.b);
|
|
892
|
+
ok = true;
|
|
893
|
+
format = String(color.r).substr(-1) === "%" ? "prgb" : "rgb";
|
|
894
|
+
}
|
|
895
|
+
else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.v)) {
|
|
896
|
+
s = convertToPercentage(color.s);
|
|
897
|
+
v = convertToPercentage(color.v);
|
|
898
|
+
rgb = hsvToRgb(color.h, s, v);
|
|
899
|
+
ok = true;
|
|
900
|
+
format = "hsv";
|
|
901
|
+
}
|
|
902
|
+
else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.l)) {
|
|
903
|
+
s = convertToPercentage(color.s);
|
|
904
|
+
l = convertToPercentage(color.l);
|
|
905
|
+
rgb = hslToRgb(color.h, s, l);
|
|
906
|
+
ok = true;
|
|
907
|
+
format = "hsl";
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
if (color.hasOwnProperty("a")) {
|
|
911
|
+
a = color.a;
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
a = boundAlpha(a);
|
|
916
|
+
|
|
917
|
+
return {
|
|
918
|
+
ok: ok,
|
|
919
|
+
format: color.format || format,
|
|
920
|
+
r: mathMin(255, mathMax(rgb.r, 0)),
|
|
921
|
+
g: mathMin(255, mathMax(rgb.g, 0)),
|
|
922
|
+
b: mathMin(255, mathMax(rgb.b, 0)),
|
|
923
|
+
a: a
|
|
924
|
+
};
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
|
|
928
|
+
// Conversion Functions
|
|
929
|
+
// --------------------
|
|
930
|
+
|
|
931
|
+
// `rgbToHsl`, `rgbToHsv`, `hslToRgb`, `hsvToRgb` modified from:
|
|
932
|
+
// <http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript>
|
|
933
|
+
|
|
934
|
+
// `rgbToRgb`
|
|
935
|
+
// Handle bounds / percentage checking to conform to CSS color spec
|
|
936
|
+
// <http://www.w3.org/TR/css3-color/>
|
|
937
|
+
// *Assumes:* r, g, b in [0, 255] or [0, 1]
|
|
938
|
+
// *Returns:* { r, g, b } in [0, 255]
|
|
939
|
+
function rgbToRgb(r, g, b){
|
|
940
|
+
return {
|
|
941
|
+
r: bound01(r, 255) * 255,
|
|
942
|
+
g: bound01(g, 255) * 255,
|
|
943
|
+
b: bound01(b, 255) * 255
|
|
944
|
+
};
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
// `rgbToHsl`
|
|
948
|
+
// Converts an RGB color value to HSL.
|
|
949
|
+
// *Assumes:* r, g, and b are contained in [0, 255] or [0, 1]
|
|
950
|
+
// *Returns:* { h, s, l } in [0,1]
|
|
951
|
+
function rgbToHsl(r, g, b) {
|
|
952
|
+
|
|
953
|
+
r = bound01(r, 255);
|
|
954
|
+
g = bound01(g, 255);
|
|
955
|
+
b = bound01(b, 255);
|
|
956
|
+
|
|
957
|
+
var max = mathMax(r, g, b), min = mathMin(r, g, b);
|
|
958
|
+
var h, s, l = (max + min) / 2;
|
|
959
|
+
|
|
960
|
+
if(max == min) {
|
|
961
|
+
h = s = 0; // achromatic
|
|
962
|
+
}
|
|
963
|
+
else {
|
|
964
|
+
var d = max - min;
|
|
965
|
+
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
|
|
966
|
+
switch(max) {
|
|
967
|
+
case r: h = (g - b) / d + (g < b ? 6 : 0); break;
|
|
968
|
+
case g: h = (b - r) / d + 2; break;
|
|
969
|
+
case b: h = (r - g) / d + 4; break;
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
h /= 6;
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
return { h: h, s: s, l: l };
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
// `hslToRgb`
|
|
979
|
+
// Converts an HSL color value to RGB.
|
|
980
|
+
// *Assumes:* h is contained in [0, 1] or [0, 360] and s and l are contained [0, 1] or [0, 100]
|
|
981
|
+
// *Returns:* { r, g, b } in the set [0, 255]
|
|
982
|
+
function hslToRgb(h, s, l) {
|
|
983
|
+
var r, g, b;
|
|
984
|
+
|
|
985
|
+
h = bound01(h, 360);
|
|
986
|
+
s = bound01(s, 100);
|
|
987
|
+
l = bound01(l, 100);
|
|
988
|
+
|
|
989
|
+
function hue2rgb(p, q, t) {
|
|
990
|
+
if(t < 0) t += 1;
|
|
991
|
+
if(t > 1) t -= 1;
|
|
992
|
+
if(t < 1/6) return p + (q - p) * 6 * t;
|
|
993
|
+
if(t < 1/2) return q;
|
|
994
|
+
if(t < 2/3) return p + (q - p) * (2/3 - t) * 6;
|
|
995
|
+
return p;
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
if(s === 0) {
|
|
999
|
+
r = g = b = l; // achromatic
|
|
1000
|
+
}
|
|
1001
|
+
else {
|
|
1002
|
+
var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
|
|
1003
|
+
var p = 2 * l - q;
|
|
1004
|
+
r = hue2rgb(p, q, h + 1/3);
|
|
1005
|
+
g = hue2rgb(p, q, h);
|
|
1006
|
+
b = hue2rgb(p, q, h - 1/3);
|
|
1007
|
+
}
|
|
1008
|
+
|
|
1009
|
+
return { r: r * 255, g: g * 255, b: b * 255 };
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
// `rgbToHsv`
|
|
1013
|
+
// Converts an RGB color value to HSV
|
|
1014
|
+
// *Assumes:* r, g, and b are contained in the set [0, 255] or [0, 1]
|
|
1015
|
+
// *Returns:* { h, s, v } in [0,1]
|
|
1016
|
+
function rgbToHsv(r, g, b) {
|
|
1017
|
+
|
|
1018
|
+
r = bound01(r, 255);
|
|
1019
|
+
g = bound01(g, 255);
|
|
1020
|
+
b = bound01(b, 255);
|
|
1021
|
+
|
|
1022
|
+
var max = mathMax(r, g, b), min = mathMin(r, g, b);
|
|
1023
|
+
var h, s, v = max;
|
|
1024
|
+
|
|
1025
|
+
var d = max - min;
|
|
1026
|
+
s = max === 0 ? 0 : d / max;
|
|
1027
|
+
|
|
1028
|
+
if(max == min) {
|
|
1029
|
+
h = 0; // achromatic
|
|
1030
|
+
}
|
|
1031
|
+
else {
|
|
1032
|
+
switch(max) {
|
|
1033
|
+
case r: h = (g - b) / d + (g < b ? 6 : 0); break;
|
|
1034
|
+
case g: h = (b - r) / d + 2; break;
|
|
1035
|
+
case b: h = (r - g) / d + 4; break;
|
|
1036
|
+
}
|
|
1037
|
+
h /= 6;
|
|
1038
|
+
}
|
|
1039
|
+
return { h: h, s: s, v: v };
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
// `hsvToRgb`
|
|
1043
|
+
// Converts an HSV color value to RGB.
|
|
1044
|
+
// *Assumes:* h is contained in [0, 1] or [0, 360] and s and v are contained in [0, 1] or [0, 100]
|
|
1045
|
+
// *Returns:* { r, g, b } in the set [0, 255]
|
|
1046
|
+
function hsvToRgb(h, s, v) {
|
|
1047
|
+
|
|
1048
|
+
h = bound01(h, 360) * 6;
|
|
1049
|
+
s = bound01(s, 100);
|
|
1050
|
+
v = bound01(v, 100);
|
|
1051
|
+
|
|
1052
|
+
var i = Math.floor(h),
|
|
1053
|
+
f = h - i,
|
|
1054
|
+
p = v * (1 - s),
|
|
1055
|
+
q = v * (1 - f * s),
|
|
1056
|
+
t = v * (1 - (1 - f) * s),
|
|
1057
|
+
mod = i % 6,
|
|
1058
|
+
r = [v, q, p, p, t, v][mod],
|
|
1059
|
+
g = [t, v, v, q, p, p][mod],
|
|
1060
|
+
b = [p, p, t, v, v, q][mod];
|
|
1061
|
+
|
|
1062
|
+
return { r: r * 255, g: g * 255, b: b * 255 };
|
|
1063
|
+
}
|
|
1064
|
+
|
|
1065
|
+
// `rgbToHex`
|
|
1066
|
+
// Converts an RGB color to hex
|
|
1067
|
+
// Assumes r, g, and b are contained in the set [0, 255]
|
|
1068
|
+
// Returns a 3 or 6 character hex
|
|
1069
|
+
function rgbToHex(r, g, b, allow3Char) {
|
|
1070
|
+
|
|
1071
|
+
var hex = [
|
|
1072
|
+
pad2(mathRound(r).toString(16)),
|
|
1073
|
+
pad2(mathRound(g).toString(16)),
|
|
1074
|
+
pad2(mathRound(b).toString(16))
|
|
1075
|
+
];
|
|
1076
|
+
|
|
1077
|
+
// Return a 3 character hex if possible
|
|
1078
|
+
if (allow3Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1)) {
|
|
1079
|
+
return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0);
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
return hex.join("");
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
// `rgbaToHex`
|
|
1086
|
+
// Converts an RGBA color plus alpha transparency to hex
|
|
1087
|
+
// Assumes r, g, b are contained in the set [0, 255] and
|
|
1088
|
+
// a in [0, 1]. Returns a 4 or 8 character rgba hex
|
|
1089
|
+
function rgbaToHex(r, g, b, a, allow4Char) {
|
|
1090
|
+
|
|
1091
|
+
var hex = [
|
|
1092
|
+
pad2(mathRound(r).toString(16)),
|
|
1093
|
+
pad2(mathRound(g).toString(16)),
|
|
1094
|
+
pad2(mathRound(b).toString(16)),
|
|
1095
|
+
pad2(convertDecimalToHex(a))
|
|
1096
|
+
];
|
|
1097
|
+
|
|
1098
|
+
// Return a 4 character hex if possible
|
|
1099
|
+
if (allow4Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1) && hex[3].charAt(0) == hex[3].charAt(1)) {
|
|
1100
|
+
return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0) + hex[3].charAt(0);
|
|
1101
|
+
}
|
|
1102
|
+
|
|
1103
|
+
return hex.join("");
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
// `rgbaToArgbHex`
|
|
1107
|
+
// Converts an RGBA color to an ARGB Hex8 string
|
|
1108
|
+
// Rarely used, but required for "toFilter()"
|
|
1109
|
+
function rgbaToArgbHex(r, g, b, a) {
|
|
1110
|
+
|
|
1111
|
+
var hex = [
|
|
1112
|
+
pad2(convertDecimalToHex(a)),
|
|
1113
|
+
pad2(mathRound(r).toString(16)),
|
|
1114
|
+
pad2(mathRound(g).toString(16)),
|
|
1115
|
+
pad2(mathRound(b).toString(16))
|
|
1116
|
+
];
|
|
1117
|
+
|
|
1118
|
+
return hex.join("");
|
|
1119
|
+
}
|
|
1120
|
+
|
|
1121
|
+
// `equals`
|
|
1122
|
+
// Can be called with any tinycolor input
|
|
1123
|
+
tinycolor.equals = function (color1, color2) {
|
|
1124
|
+
if (!color1 || !color2) { return false; }
|
|
1125
|
+
return tinycolor(color1).toRgbString() == tinycolor(color2).toRgbString();
|
|
1126
|
+
};
|
|
1127
|
+
|
|
1128
|
+
tinycolor.random = function() {
|
|
1129
|
+
return tinycolor.fromRatio({
|
|
1130
|
+
r: mathRandom(),
|
|
1131
|
+
g: mathRandom(),
|
|
1132
|
+
b: mathRandom()
|
|
1133
|
+
});
|
|
1134
|
+
};
|
|
1135
|
+
|
|
1136
|
+
|
|
1137
|
+
// Modification Functions
|
|
1138
|
+
// ----------------------
|
|
1139
|
+
// Thanks to less.js for some of the basics here
|
|
1140
|
+
// <https://github.com/cloudhead/less.js/blob/master/lib/less/functions.js>
|
|
1141
|
+
|
|
1142
|
+
function desaturate(color, amount) {
|
|
1143
|
+
amount = (amount === 0) ? 0 : (amount || 10);
|
|
1144
|
+
var hsl = tinycolor(color).toHsl();
|
|
1145
|
+
hsl.s -= amount / 100;
|
|
1146
|
+
hsl.s = clamp01(hsl.s);
|
|
1147
|
+
return tinycolor(hsl);
|
|
1148
|
+
}
|
|
1149
|
+
|
|
1150
|
+
function saturate(color, amount) {
|
|
1151
|
+
amount = (amount === 0) ? 0 : (amount || 10);
|
|
1152
|
+
var hsl = tinycolor(color).toHsl();
|
|
1153
|
+
hsl.s += amount / 100;
|
|
1154
|
+
hsl.s = clamp01(hsl.s);
|
|
1155
|
+
return tinycolor(hsl);
|
|
1156
|
+
}
|
|
1157
|
+
|
|
1158
|
+
function greyscale(color) {
|
|
1159
|
+
return tinycolor(color).desaturate(100);
|
|
1160
|
+
}
|
|
1161
|
+
|
|
1162
|
+
function lighten (color, amount) {
|
|
1163
|
+
amount = (amount === 0) ? 0 : (amount || 10);
|
|
1164
|
+
var hsl = tinycolor(color).toHsl();
|
|
1165
|
+
hsl.l += amount / 100;
|
|
1166
|
+
hsl.l = clamp01(hsl.l);
|
|
1167
|
+
return tinycolor(hsl);
|
|
1168
|
+
}
|
|
1169
|
+
|
|
1170
|
+
function brighten(color, amount) {
|
|
1171
|
+
amount = (amount === 0) ? 0 : (amount || 10);
|
|
1172
|
+
var rgb = tinycolor(color).toRgb();
|
|
1173
|
+
rgb.r = mathMax(0, mathMin(255, rgb.r - mathRound(255 * - (amount / 100))));
|
|
1174
|
+
rgb.g = mathMax(0, mathMin(255, rgb.g - mathRound(255 * - (amount / 100))));
|
|
1175
|
+
rgb.b = mathMax(0, mathMin(255, rgb.b - mathRound(255 * - (amount / 100))));
|
|
1176
|
+
return tinycolor(rgb);
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1179
|
+
function darken (color, amount) {
|
|
1180
|
+
amount = (amount === 0) ? 0 : (amount || 10);
|
|
1181
|
+
var hsl = tinycolor(color).toHsl();
|
|
1182
|
+
hsl.l -= amount / 100;
|
|
1183
|
+
hsl.l = clamp01(hsl.l);
|
|
1184
|
+
return tinycolor(hsl);
|
|
1185
|
+
}
|
|
1186
|
+
|
|
1187
|
+
// Spin takes a positive or negative amount within [-360, 360] indicating the change of hue.
|
|
1188
|
+
// Values outside of this range will be wrapped into this range.
|
|
1189
|
+
function spin(color, amount) {
|
|
1190
|
+
var hsl = tinycolor(color).toHsl();
|
|
1191
|
+
var hue = (hsl.h + amount) % 360;
|
|
1192
|
+
hsl.h = hue < 0 ? 360 + hue : hue;
|
|
1193
|
+
return tinycolor(hsl);
|
|
1194
|
+
}
|
|
1195
|
+
|
|
1196
|
+
// Combination Functions
|
|
1197
|
+
// ---------------------
|
|
1198
|
+
// Thanks to jQuery xColor for some of the ideas behind these
|
|
1199
|
+
// <https://github.com/infusion/jQuery-xcolor/blob/master/jquery.xcolor.js>
|
|
1200
|
+
|
|
1201
|
+
function complement(color) {
|
|
1202
|
+
var hsl = tinycolor(color).toHsl();
|
|
1203
|
+
hsl.h = (hsl.h + 180) % 360;
|
|
1204
|
+
return tinycolor(hsl);
|
|
1205
|
+
}
|
|
1206
|
+
|
|
1207
|
+
function triad(color) {
|
|
1208
|
+
var hsl = tinycolor(color).toHsl();
|
|
1209
|
+
var h = hsl.h;
|
|
1210
|
+
return [
|
|
1211
|
+
tinycolor(color),
|
|
1212
|
+
tinycolor({ h: (h + 120) % 360, s: hsl.s, l: hsl.l }),
|
|
1213
|
+
tinycolor({ h: (h + 240) % 360, s: hsl.s, l: hsl.l })
|
|
1214
|
+
];
|
|
1215
|
+
}
|
|
1216
|
+
|
|
1217
|
+
function tetrad(color) {
|
|
1218
|
+
var hsl = tinycolor(color).toHsl();
|
|
1219
|
+
var h = hsl.h;
|
|
1220
|
+
return [
|
|
1221
|
+
tinycolor(color),
|
|
1222
|
+
tinycolor({ h: (h + 90) % 360, s: hsl.s, l: hsl.l }),
|
|
1223
|
+
tinycolor({ h: (h + 180) % 360, s: hsl.s, l: hsl.l }),
|
|
1224
|
+
tinycolor({ h: (h + 270) % 360, s: hsl.s, l: hsl.l })
|
|
1225
|
+
];
|
|
1226
|
+
}
|
|
1227
|
+
|
|
1228
|
+
function splitcomplement(color) {
|
|
1229
|
+
var hsl = tinycolor(color).toHsl();
|
|
1230
|
+
var h = hsl.h;
|
|
1231
|
+
return [
|
|
1232
|
+
tinycolor(color),
|
|
1233
|
+
tinycolor({ h: (h + 72) % 360, s: hsl.s, l: hsl.l}),
|
|
1234
|
+
tinycolor({ h: (h + 216) % 360, s: hsl.s, l: hsl.l})
|
|
1235
|
+
];
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1238
|
+
function analogous(color, results, slices) {
|
|
1239
|
+
results = results || 6;
|
|
1240
|
+
slices = slices || 30;
|
|
1241
|
+
|
|
1242
|
+
var hsl = tinycolor(color).toHsl();
|
|
1243
|
+
var part = 360 / slices;
|
|
1244
|
+
var ret = [tinycolor(color)];
|
|
1245
|
+
|
|
1246
|
+
for (hsl.h = ((hsl.h - (part * results >> 1)) + 720) % 360; --results; ) {
|
|
1247
|
+
hsl.h = (hsl.h + part) % 360;
|
|
1248
|
+
ret.push(tinycolor(hsl));
|
|
1249
|
+
}
|
|
1250
|
+
return ret;
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1253
|
+
function monochromatic(color, results) {
|
|
1254
|
+
results = results || 6;
|
|
1255
|
+
var hsv = tinycolor(color).toHsv();
|
|
1256
|
+
var h = hsv.h, s = hsv.s, v = hsv.v;
|
|
1257
|
+
var ret = [];
|
|
1258
|
+
var modification = 1 / results;
|
|
1259
|
+
|
|
1260
|
+
while (results--) {
|
|
1261
|
+
ret.push(tinycolor({ h: h, s: s, v: v}));
|
|
1262
|
+
v = (v + modification) % 1;
|
|
1263
|
+
}
|
|
1264
|
+
|
|
1265
|
+
return ret;
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1268
|
+
// Utility Functions
|
|
1269
|
+
// ---------------------
|
|
1270
|
+
|
|
1271
|
+
tinycolor.mix = function(color1, color2, amount) {
|
|
1272
|
+
amount = (amount === 0) ? 0 : (amount || 50);
|
|
1273
|
+
|
|
1274
|
+
var rgb1 = tinycolor(color1).toRgb();
|
|
1275
|
+
var rgb2 = tinycolor(color2).toRgb();
|
|
1276
|
+
|
|
1277
|
+
var p = amount / 100;
|
|
1278
|
+
|
|
1279
|
+
var rgba = {
|
|
1280
|
+
r: ((rgb2.r - rgb1.r) * p) + rgb1.r,
|
|
1281
|
+
g: ((rgb2.g - rgb1.g) * p) + rgb1.g,
|
|
1282
|
+
b: ((rgb2.b - rgb1.b) * p) + rgb1.b,
|
|
1283
|
+
a: ((rgb2.a - rgb1.a) * p) + rgb1.a
|
|
1284
|
+
};
|
|
1285
|
+
|
|
1286
|
+
return tinycolor(rgba);
|
|
1287
|
+
};
|
|
1288
|
+
|
|
1289
|
+
|
|
1290
|
+
// Readability Functions
|
|
1291
|
+
// ---------------------
|
|
1292
|
+
// <http://www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast-ratiodef (WCAG Version 2)
|
|
1293
|
+
|
|
1294
|
+
// `contrast`
|
|
1295
|
+
// Analyze the 2 colors and returns the color contrast defined by (WCAG Version 2)
|
|
1296
|
+
tinycolor.readability = function(color1, color2) {
|
|
1297
|
+
var c1 = tinycolor(color1);
|
|
1298
|
+
var c2 = tinycolor(color2);
|
|
1299
|
+
return (Math.max(c1.getLuminance(),c2.getLuminance())+0.05) / (Math.min(c1.getLuminance(),c2.getLuminance())+0.05);
|
|
1300
|
+
};
|
|
1301
|
+
|
|
1302
|
+
// `isReadable`
|
|
1303
|
+
// Ensure that foreground and background color combinations meet WCAG2 guidelines.
|
|
1304
|
+
// The third argument is an optional Object.
|
|
1305
|
+
// the 'level' property states 'AA' or 'AAA' - if missing or invalid, it defaults to 'AA';
|
|
1306
|
+
// the 'size' property states 'large' or 'small' - if missing or invalid, it defaults to 'small'.
|
|
1307
|
+
// If the entire object is absent, isReadable defaults to {level:"AA",size:"small"}.
|
|
1308
|
+
|
|
1309
|
+
// *Example*
|
|
1310
|
+
// tinycolor.isReadable("#000", "#111") => false
|
|
1311
|
+
// tinycolor.isReadable("#000", "#111",{level:"AA",size:"large"}) => false
|
|
1312
|
+
tinycolor.isReadable = function(color1, color2, wcag2) {
|
|
1313
|
+
var readability = tinycolor.readability(color1, color2);
|
|
1314
|
+
var wcag2Parms, out;
|
|
1315
|
+
|
|
1316
|
+
out = false;
|
|
1317
|
+
|
|
1318
|
+
wcag2Parms = validateWCAG2Parms(wcag2);
|
|
1319
|
+
switch (wcag2Parms.level + wcag2Parms.size) {
|
|
1320
|
+
case "AAsmall":
|
|
1321
|
+
case "AAAlarge":
|
|
1322
|
+
out = readability >= 4.5;
|
|
1323
|
+
break;
|
|
1324
|
+
case "AAlarge":
|
|
1325
|
+
out = readability >= 3;
|
|
1326
|
+
break;
|
|
1327
|
+
case "AAAsmall":
|
|
1328
|
+
out = readability >= 7;
|
|
1329
|
+
break;
|
|
1330
|
+
}
|
|
1331
|
+
return out;
|
|
1332
|
+
|
|
1333
|
+
};
|
|
1334
|
+
|
|
1335
|
+
// `mostReadable`
|
|
1336
|
+
// Given a base color and a list of possible foreground or background
|
|
1337
|
+
// colors for that base, returns the most readable color.
|
|
1338
|
+
// Optionally returns Black or White if the most readable color is unreadable.
|
|
1339
|
+
// *Example*
|
|
1340
|
+
// tinycolor.mostReadable(tinycolor.mostReadable("#123", ["#124", "#125"],{includeFallbackColors:false}).toHexString(); // "#112255"
|
|
1341
|
+
// tinycolor.mostReadable(tinycolor.mostReadable("#123", ["#124", "#125"],{includeFallbackColors:true}).toHexString(); // "#ffffff"
|
|
1342
|
+
// tinycolor.mostReadable("#a8015a", ["#faf3f3"],{includeFallbackColors:true,level:"AAA",size:"large"}).toHexString(); // "#faf3f3"
|
|
1343
|
+
// tinycolor.mostReadable("#a8015a", ["#faf3f3"],{includeFallbackColors:true,level:"AAA",size:"small"}).toHexString(); // "#ffffff"
|
|
1344
|
+
tinycolor.mostReadable = function(baseColor, colorList, args) {
|
|
1345
|
+
var bestColor = null;
|
|
1346
|
+
var bestScore = 0;
|
|
1347
|
+
var readability;
|
|
1348
|
+
var includeFallbackColors, level, size ;
|
|
1349
|
+
args = args || {};
|
|
1350
|
+
includeFallbackColors = args.includeFallbackColors ;
|
|
1351
|
+
level = args.level;
|
|
1352
|
+
size = args.size;
|
|
1353
|
+
|
|
1354
|
+
for (var i= 0; i < colorList.length ; i++) {
|
|
1355
|
+
readability = tinycolor.readability(baseColor, colorList[i]);
|
|
1356
|
+
if (readability > bestScore) {
|
|
1357
|
+
bestScore = readability;
|
|
1358
|
+
bestColor = tinycolor(colorList[i]);
|
|
1359
|
+
}
|
|
1360
|
+
}
|
|
1361
|
+
|
|
1362
|
+
if (tinycolor.isReadable(baseColor, bestColor, {"level":level,"size":size}) || !includeFallbackColors) {
|
|
1363
|
+
return bestColor;
|
|
1364
|
+
}
|
|
1365
|
+
else {
|
|
1366
|
+
args.includeFallbackColors=false;
|
|
1367
|
+
return tinycolor.mostReadable(baseColor,["#fff", "#000"],args);
|
|
1368
|
+
}
|
|
1369
|
+
};
|
|
1370
|
+
|
|
1371
|
+
|
|
1372
|
+
// Big List of Colors
|
|
1373
|
+
// ------------------
|
|
1374
|
+
// <http://www.w3.org/TR/css3-color/#svg-color>
|
|
1375
|
+
var names = tinycolor.names = {
|
|
1376
|
+
aliceblue: "f0f8ff",
|
|
1377
|
+
antiquewhite: "faebd7",
|
|
1378
|
+
aqua: "0ff",
|
|
1379
|
+
aquamarine: "7fffd4",
|
|
1380
|
+
azure: "f0ffff",
|
|
1381
|
+
beige: "f5f5dc",
|
|
1382
|
+
bisque: "ffe4c4",
|
|
1383
|
+
black: "000",
|
|
1384
|
+
blanchedalmond: "ffebcd",
|
|
1385
|
+
blue: "00f",
|
|
1386
|
+
blueviolet: "8a2be2",
|
|
1387
|
+
brown: "a52a2a",
|
|
1388
|
+
burlywood: "deb887",
|
|
1389
|
+
burntsienna: "ea7e5d",
|
|
1390
|
+
cadetblue: "5f9ea0",
|
|
1391
|
+
chartreuse: "7fff00",
|
|
1392
|
+
chocolate: "d2691e",
|
|
1393
|
+
coral: "ff7f50",
|
|
1394
|
+
cornflowerblue: "6495ed",
|
|
1395
|
+
cornsilk: "fff8dc",
|
|
1396
|
+
crimson: "dc143c",
|
|
1397
|
+
cyan: "0ff",
|
|
1398
|
+
darkblue: "00008b",
|
|
1399
|
+
darkcyan: "008b8b",
|
|
1400
|
+
darkgoldenrod: "b8860b",
|
|
1401
|
+
darkgray: "a9a9a9",
|
|
1402
|
+
darkgreen: "006400",
|
|
1403
|
+
darkgrey: "a9a9a9",
|
|
1404
|
+
darkkhaki: "bdb76b",
|
|
1405
|
+
darkmagenta: "8b008b",
|
|
1406
|
+
darkolivegreen: "556b2f",
|
|
1407
|
+
darkorange: "ff8c00",
|
|
1408
|
+
darkorchid: "9932cc",
|
|
1409
|
+
darkred: "8b0000",
|
|
1410
|
+
darksalmon: "e9967a",
|
|
1411
|
+
darkseagreen: "8fbc8f",
|
|
1412
|
+
darkslateblue: "483d8b",
|
|
1413
|
+
darkslategray: "2f4f4f",
|
|
1414
|
+
darkslategrey: "2f4f4f",
|
|
1415
|
+
darkturquoise: "00ced1",
|
|
1416
|
+
darkviolet: "9400d3",
|
|
1417
|
+
deeppink: "ff1493",
|
|
1418
|
+
deepskyblue: "00bfff",
|
|
1419
|
+
dimgray: "696969",
|
|
1420
|
+
dimgrey: "696969",
|
|
1421
|
+
dodgerblue: "1e90ff",
|
|
1422
|
+
firebrick: "b22222",
|
|
1423
|
+
floralwhite: "fffaf0",
|
|
1424
|
+
forestgreen: "228b22",
|
|
1425
|
+
fuchsia: "f0f",
|
|
1426
|
+
gainsboro: "dcdcdc",
|
|
1427
|
+
ghostwhite: "f8f8ff",
|
|
1428
|
+
gold: "ffd700",
|
|
1429
|
+
goldenrod: "daa520",
|
|
1430
|
+
gray: "808080",
|
|
1431
|
+
green: "008000",
|
|
1432
|
+
greenyellow: "adff2f",
|
|
1433
|
+
grey: "808080",
|
|
1434
|
+
honeydew: "f0fff0",
|
|
1435
|
+
hotpink: "ff69b4",
|
|
1436
|
+
indianred: "cd5c5c",
|
|
1437
|
+
indigo: "4b0082",
|
|
1438
|
+
ivory: "fffff0",
|
|
1439
|
+
khaki: "f0e68c",
|
|
1440
|
+
lavender: "e6e6fa",
|
|
1441
|
+
lavenderblush: "fff0f5",
|
|
1442
|
+
lawngreen: "7cfc00",
|
|
1443
|
+
lemonchiffon: "fffacd",
|
|
1444
|
+
lightblue: "add8e6",
|
|
1445
|
+
lightcoral: "f08080",
|
|
1446
|
+
lightcyan: "e0ffff",
|
|
1447
|
+
lightgoldenrodyellow: "fafad2",
|
|
1448
|
+
lightgray: "d3d3d3",
|
|
1449
|
+
lightgreen: "90ee90",
|
|
1450
|
+
lightgrey: "d3d3d3",
|
|
1451
|
+
lightpink: "ffb6c1",
|
|
1452
|
+
lightsalmon: "ffa07a",
|
|
1453
|
+
lightseagreen: "20b2aa",
|
|
1454
|
+
lightskyblue: "87cefa",
|
|
1455
|
+
lightslategray: "789",
|
|
1456
|
+
lightslategrey: "789",
|
|
1457
|
+
lightsteelblue: "b0c4de",
|
|
1458
|
+
lightyellow: "ffffe0",
|
|
1459
|
+
lime: "0f0",
|
|
1460
|
+
limegreen: "32cd32",
|
|
1461
|
+
linen: "faf0e6",
|
|
1462
|
+
magenta: "f0f",
|
|
1463
|
+
maroon: "800000",
|
|
1464
|
+
mediumaquamarine: "66cdaa",
|
|
1465
|
+
mediumblue: "0000cd",
|
|
1466
|
+
mediumorchid: "ba55d3",
|
|
1467
|
+
mediumpurple: "9370db",
|
|
1468
|
+
mediumseagreen: "3cb371",
|
|
1469
|
+
mediumslateblue: "7b68ee",
|
|
1470
|
+
mediumspringgreen: "00fa9a",
|
|
1471
|
+
mediumturquoise: "48d1cc",
|
|
1472
|
+
mediumvioletred: "c71585",
|
|
1473
|
+
midnightblue: "191970",
|
|
1474
|
+
mintcream: "f5fffa",
|
|
1475
|
+
mistyrose: "ffe4e1",
|
|
1476
|
+
moccasin: "ffe4b5",
|
|
1477
|
+
navajowhite: "ffdead",
|
|
1478
|
+
navy: "000080",
|
|
1479
|
+
oldlace: "fdf5e6",
|
|
1480
|
+
olive: "808000",
|
|
1481
|
+
olivedrab: "6b8e23",
|
|
1482
|
+
orange: "ffa500",
|
|
1483
|
+
orangered: "ff4500",
|
|
1484
|
+
orchid: "da70d6",
|
|
1485
|
+
palegoldenrod: "eee8aa",
|
|
1486
|
+
palegreen: "98fb98",
|
|
1487
|
+
paleturquoise: "afeeee",
|
|
1488
|
+
palevioletred: "db7093",
|
|
1489
|
+
papayawhip: "ffefd5",
|
|
1490
|
+
peachpuff: "ffdab9",
|
|
1491
|
+
peru: "cd853f",
|
|
1492
|
+
pink: "ffc0cb",
|
|
1493
|
+
plum: "dda0dd",
|
|
1494
|
+
powderblue: "b0e0e6",
|
|
1495
|
+
purple: "800080",
|
|
1496
|
+
rebeccapurple: "663399",
|
|
1497
|
+
red: "f00",
|
|
1498
|
+
rosybrown: "bc8f8f",
|
|
1499
|
+
royalblue: "4169e1",
|
|
1500
|
+
saddlebrown: "8b4513",
|
|
1501
|
+
salmon: "fa8072",
|
|
1502
|
+
sandybrown: "f4a460",
|
|
1503
|
+
seagreen: "2e8b57",
|
|
1504
|
+
seashell: "fff5ee",
|
|
1505
|
+
sienna: "a0522d",
|
|
1506
|
+
silver: "c0c0c0",
|
|
1507
|
+
skyblue: "87ceeb",
|
|
1508
|
+
slateblue: "6a5acd",
|
|
1509
|
+
slategray: "708090",
|
|
1510
|
+
slategrey: "708090",
|
|
1511
|
+
snow: "fffafa",
|
|
1512
|
+
springgreen: "00ff7f",
|
|
1513
|
+
steelblue: "4682b4",
|
|
1514
|
+
tan: "d2b48c",
|
|
1515
|
+
teal: "008080",
|
|
1516
|
+
thistle: "d8bfd8",
|
|
1517
|
+
tomato: "ff6347",
|
|
1518
|
+
turquoise: "40e0d0",
|
|
1519
|
+
violet: "ee82ee",
|
|
1520
|
+
wheat: "f5deb3",
|
|
1521
|
+
white: "fff",
|
|
1522
|
+
whitesmoke: "f5f5f5",
|
|
1523
|
+
yellow: "ff0",
|
|
1524
|
+
yellowgreen: "9acd32"
|
|
1525
|
+
};
|
|
1526
|
+
|
|
1527
|
+
// Make it easy to access colors via `hexNames[hex]`
|
|
1528
|
+
var hexNames = tinycolor.hexNames = flip(names);
|
|
1529
|
+
|
|
1530
|
+
|
|
1531
|
+
// Utilities
|
|
1532
|
+
// ---------
|
|
1533
|
+
|
|
1534
|
+
// `{ 'name1': 'val1' }` becomes `{ 'val1': 'name1' }`
|
|
1535
|
+
function flip(o) {
|
|
1536
|
+
var flipped = { };
|
|
1537
|
+
for (var i in o) {
|
|
1538
|
+
if (o.hasOwnProperty(i)) {
|
|
1539
|
+
flipped[o[i]] = i;
|
|
1540
|
+
}
|
|
1541
|
+
}
|
|
1542
|
+
return flipped;
|
|
1543
|
+
}
|
|
1544
|
+
|
|
1545
|
+
// Return a valid alpha value [0,1] with all invalid values being set to 1
|
|
1546
|
+
function boundAlpha(a) {
|
|
1547
|
+
a = parseFloat(a);
|
|
1548
|
+
|
|
1549
|
+
if (isNaN(a) || a < 0 || a > 1) {
|
|
1550
|
+
a = 1;
|
|
1551
|
+
}
|
|
1552
|
+
|
|
1553
|
+
return a;
|
|
1554
|
+
}
|
|
1555
|
+
|
|
1556
|
+
// Take input from [0, n] and return it as [0, 1]
|
|
1557
|
+
function bound01(n, max) {
|
|
1558
|
+
if (isOnePointZero(n)) { n = "100%"; }
|
|
1559
|
+
|
|
1560
|
+
var processPercent = isPercentage(n);
|
|
1561
|
+
n = mathMin(max, mathMax(0, parseFloat(n)));
|
|
1562
|
+
|
|
1563
|
+
// Automatically convert percentage into number
|
|
1564
|
+
if (processPercent) {
|
|
1565
|
+
n = parseInt(n * max, 10) / 100;
|
|
1566
|
+
}
|
|
1567
|
+
|
|
1568
|
+
// Handle floating point rounding errors
|
|
1569
|
+
if ((Math.abs(n - max) < 0.000001)) {
|
|
1570
|
+
return 1;
|
|
1571
|
+
}
|
|
1572
|
+
|
|
1573
|
+
// Convert into [0, 1] range if it isn't already
|
|
1574
|
+
return (n % max) / parseFloat(max);
|
|
1575
|
+
}
|
|
1576
|
+
|
|
1577
|
+
// Force a number between 0 and 1
|
|
1578
|
+
function clamp01(val) {
|
|
1579
|
+
return mathMin(1, mathMax(0, val));
|
|
1580
|
+
}
|
|
1581
|
+
|
|
1582
|
+
// Parse a base-16 hex value into a base-10 integer
|
|
1583
|
+
function parseIntFromHex(val) {
|
|
1584
|
+
return parseInt(val, 16);
|
|
1585
|
+
}
|
|
1586
|
+
|
|
1587
|
+
// Need to handle 1.0 as 100%, since once it is a number, there is no difference between it and 1
|
|
1588
|
+
// <http://stackoverflow.com/questions/7422072/javascript-how-to-detect-number-as-a-decimal-including-1-0>
|
|
1589
|
+
function isOnePointZero(n) {
|
|
1590
|
+
return typeof n == "string" && n.indexOf('.') != -1 && parseFloat(n) === 1;
|
|
1591
|
+
}
|
|
1592
|
+
|
|
1593
|
+
// Check to see if string passed in is a percentage
|
|
1594
|
+
function isPercentage(n) {
|
|
1595
|
+
return typeof n === "string" && n.indexOf('%') != -1;
|
|
1596
|
+
}
|
|
1597
|
+
|
|
1598
|
+
// Force a hex value to have 2 characters
|
|
1599
|
+
function pad2(c) {
|
|
1600
|
+
return c.length == 1 ? '0' + c : '' + c;
|
|
1601
|
+
}
|
|
1602
|
+
|
|
1603
|
+
// Replace a decimal with it's percentage value
|
|
1604
|
+
function convertToPercentage(n) {
|
|
1605
|
+
if (n <= 1) {
|
|
1606
|
+
n = (n * 100) + "%";
|
|
1607
|
+
}
|
|
1608
|
+
|
|
1609
|
+
return n;
|
|
1610
|
+
}
|
|
1611
|
+
|
|
1612
|
+
// Converts a decimal to a hex value
|
|
1613
|
+
function convertDecimalToHex(d) {
|
|
1614
|
+
return Math.round(parseFloat(d) * 255).toString(16);
|
|
1615
|
+
}
|
|
1616
|
+
// Converts a hex value to a decimal
|
|
1617
|
+
function convertHexToDecimal(h) {
|
|
1618
|
+
return (parseIntFromHex(h) / 255);
|
|
1619
|
+
}
|
|
1620
|
+
|
|
1621
|
+
var matchers = (function() {
|
|
1622
|
+
|
|
1623
|
+
// <http://www.w3.org/TR/css3-values/#integers>
|
|
1624
|
+
var CSS_INTEGER = "[-\\+]?\\d+%?";
|
|
1625
|
+
|
|
1626
|
+
// <http://www.w3.org/TR/css3-values/#number-value>
|
|
1627
|
+
var CSS_NUMBER = "[-\\+]?\\d*\\.\\d+%?";
|
|
1628
|
+
|
|
1629
|
+
// Allow positive/negative integer/number. Don't capture the either/or, just the entire outcome.
|
|
1630
|
+
var CSS_UNIT = "(?:" + CSS_NUMBER + ")|(?:" + CSS_INTEGER + ")";
|
|
1631
|
+
|
|
1632
|
+
// Actual matching.
|
|
1633
|
+
// Parentheses and commas are optional, but not required.
|
|
1634
|
+
// Whitespace can take the place of commas or opening paren
|
|
1635
|
+
var PERMISSIVE_MATCH3 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
|
|
1636
|
+
var PERMISSIVE_MATCH4 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
|
|
1637
|
+
|
|
1638
|
+
return {
|
|
1639
|
+
CSS_UNIT: new RegExp(CSS_UNIT),
|
|
1640
|
+
rgb: new RegExp("rgb" + PERMISSIVE_MATCH3),
|
|
1641
|
+
rgba: new RegExp("rgba" + PERMISSIVE_MATCH4),
|
|
1642
|
+
hsl: new RegExp("hsl" + PERMISSIVE_MATCH3),
|
|
1643
|
+
hsla: new RegExp("hsla" + PERMISSIVE_MATCH4),
|
|
1644
|
+
hsv: new RegExp("hsv" + PERMISSIVE_MATCH3),
|
|
1645
|
+
hsva: new RegExp("hsva" + PERMISSIVE_MATCH4),
|
|
1646
|
+
hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
|
|
1647
|
+
hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
|
|
1648
|
+
hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
|
|
1649
|
+
hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/
|
|
1650
|
+
};
|
|
1651
|
+
})();
|
|
1652
|
+
|
|
1653
|
+
// `isValidCSSUnit`
|
|
1654
|
+
// Take in a single string / number and check to see if it looks like a CSS unit
|
|
1655
|
+
// (see `matchers` above for definition).
|
|
1656
|
+
function isValidCSSUnit(color) {
|
|
1657
|
+
return !!matchers.CSS_UNIT.exec(color);
|
|
1658
|
+
}
|
|
1659
|
+
|
|
1660
|
+
// `stringInputToObject`
|
|
1661
|
+
// Permissive string parsing. Take in a number of formats, and output an object
|
|
1662
|
+
// based on detected format. Returns `{ r, g, b }` or `{ h, s, l }` or `{ h, s, v}`
|
|
1663
|
+
function stringInputToObject(color) {
|
|
1664
|
+
|
|
1665
|
+
color = color.replace(trimLeft,'').replace(trimRight, '').toLowerCase();
|
|
1666
|
+
var named = false;
|
|
1667
|
+
if (names[color]) {
|
|
1668
|
+
color = names[color];
|
|
1669
|
+
named = true;
|
|
1670
|
+
}
|
|
1671
|
+
else if (color == 'transparent') {
|
|
1672
|
+
return { r: 0, g: 0, b: 0, a: 0, format: "name" };
|
|
1673
|
+
}
|
|
1674
|
+
|
|
1675
|
+
// Try to match string input using regular expressions.
|
|
1676
|
+
// Keep most of the number bounding out of this function - don't worry about [0,1] or [0,100] or [0,360]
|
|
1677
|
+
// Just return an object and let the conversion functions handle that.
|
|
1678
|
+
// This way the result will be the same whether the tinycolor is initialized with string or object.
|
|
1679
|
+
var match;
|
|
1680
|
+
if ((match = matchers.rgb.exec(color))) {
|
|
1681
|
+
return { r: match[1], g: match[2], b: match[3] };
|
|
1682
|
+
}
|
|
1683
|
+
if ((match = matchers.rgba.exec(color))) {
|
|
1684
|
+
return { r: match[1], g: match[2], b: match[3], a: match[4] };
|
|
1685
|
+
}
|
|
1686
|
+
if ((match = matchers.hsl.exec(color))) {
|
|
1687
|
+
return { h: match[1], s: match[2], l: match[3] };
|
|
1688
|
+
}
|
|
1689
|
+
if ((match = matchers.hsla.exec(color))) {
|
|
1690
|
+
return { h: match[1], s: match[2], l: match[3], a: match[4] };
|
|
1691
|
+
}
|
|
1692
|
+
if ((match = matchers.hsv.exec(color))) {
|
|
1693
|
+
return { h: match[1], s: match[2], v: match[3] };
|
|
1694
|
+
}
|
|
1695
|
+
if ((match = matchers.hsva.exec(color))) {
|
|
1696
|
+
return { h: match[1], s: match[2], v: match[3], a: match[4] };
|
|
1697
|
+
}
|
|
1698
|
+
if ((match = matchers.hex8.exec(color))) {
|
|
1699
|
+
return {
|
|
1700
|
+
r: parseIntFromHex(match[1]),
|
|
1701
|
+
g: parseIntFromHex(match[2]),
|
|
1702
|
+
b: parseIntFromHex(match[3]),
|
|
1703
|
+
a: convertHexToDecimal(match[4]),
|
|
1704
|
+
format: named ? "name" : "hex8"
|
|
1705
|
+
};
|
|
1706
|
+
}
|
|
1707
|
+
if ((match = matchers.hex6.exec(color))) {
|
|
1708
|
+
return {
|
|
1709
|
+
r: parseIntFromHex(match[1]),
|
|
1710
|
+
g: parseIntFromHex(match[2]),
|
|
1711
|
+
b: parseIntFromHex(match[3]),
|
|
1712
|
+
format: named ? "name" : "hex"
|
|
1713
|
+
};
|
|
1714
|
+
}
|
|
1715
|
+
if ((match = matchers.hex4.exec(color))) {
|
|
1716
|
+
return {
|
|
1717
|
+
r: parseIntFromHex(match[1] + '' + match[1]),
|
|
1718
|
+
g: parseIntFromHex(match[2] + '' + match[2]),
|
|
1719
|
+
b: parseIntFromHex(match[3] + '' + match[3]),
|
|
1720
|
+
a: convertHexToDecimal(match[4] + '' + match[4]),
|
|
1721
|
+
format: named ? "name" : "hex8"
|
|
1722
|
+
};
|
|
1723
|
+
}
|
|
1724
|
+
if ((match = matchers.hex3.exec(color))) {
|
|
1725
|
+
return {
|
|
1726
|
+
r: parseIntFromHex(match[1] + '' + match[1]),
|
|
1727
|
+
g: parseIntFromHex(match[2] + '' + match[2]),
|
|
1728
|
+
b: parseIntFromHex(match[3] + '' + match[3]),
|
|
1729
|
+
format: named ? "name" : "hex"
|
|
1730
|
+
};
|
|
1731
|
+
}
|
|
1732
|
+
|
|
1733
|
+
return false;
|
|
1734
|
+
}
|
|
1735
|
+
|
|
1736
|
+
function validateWCAG2Parms(parms) {
|
|
1737
|
+
// return valid WCAG2 parms for isReadable.
|
|
1738
|
+
// If input parms are invalid, return {"level":"AA", "size":"small"}
|
|
1739
|
+
var level, size;
|
|
1740
|
+
parms = parms || {"level":"AA", "size":"small"};
|
|
1741
|
+
level = (parms.level || "AA").toUpperCase();
|
|
1742
|
+
size = (parms.size || "small").toLowerCase();
|
|
1743
|
+
if (level !== "AA" && level !== "AAA") {
|
|
1744
|
+
level = "AA";
|
|
1745
|
+
}
|
|
1746
|
+
if (size !== "small" && size !== "large") {
|
|
1747
|
+
size = "small";
|
|
1748
|
+
}
|
|
1749
|
+
return {"level":level, "size":size};
|
|
1750
|
+
}
|
|
1751
|
+
|
|
1752
|
+
// Node: Export function
|
|
1753
|
+
if (module.exports) {
|
|
1754
|
+
module.exports = tinycolor;
|
|
1755
|
+
}
|
|
1756
|
+
// AMD/requirejs: Define the module
|
|
1757
|
+
else {
|
|
1758
|
+
window.tinycolor = tinycolor;
|
|
1759
|
+
}
|
|
1760
|
+
|
|
1761
|
+
})(Math);
|
|
1762
|
+
} (tinycolor$1));
|
|
1763
|
+
|
|
1764
|
+
var tinycolor = tinycolor$1.exports;
|
|
1765
|
+
|
|
1766
|
+
const s=()=>"undefined"!=typeof window&&"EyeDropper"in window,i=()=>Promise.reject(new Error("Unsupported browser.")),c=()=>{const r=useRef(),[i,c]=useState(!1);useEffect(()=>(r.current=!0,c(s()),()=>{r.current=!1;}),[]);const u=useCallback(()=>i,[i]);return [r,u]},u=r=>{const o=(r=>s()&&new EyeDropper(r))(r);var n;return (n=o)?EyeDropper.prototype.open.bind(n):i},p=e=>{const s=useMemo(()=>u(e),[e]),[i,p]=c(),a=useRef(),f=useCallback(()=>{void 0!==a.current&&a.current.abort();},[a]),d=useCallback(function(r){void 0===r&&(r={});try{f();const{signal:o,...n}=r,t=new AbortController;a.current=t;const e=void 0!==o?(r=>{const o=new AbortController,n=()=>{o.abort();for(const o of r)o.removeEventListener("abort",n);};for(const o of r){if(o.aborted){n();break}o.addEventListener("abort",n);}return o.signal})([o,t.signal]):t.signal;return Promise.resolve(function(r,o){try{var t=Promise.resolve(s({...n,signal:e}));}catch(r){return o(r)}return t&&t.then?t.then(void 0,o):t}(0,function(r){throw i.current||(r.canceled=!0),r}))}catch(r){return Promise.reject(r)}},[a,i,f,s]);return useEffect(()=>f,[f]),{open:d,close:f,isSupported:p}};
|
|
1767
|
+
|
|
1768
|
+
var useEyeDropper = p
|
|
1769
|
+
|
|
1770
|
+
var Palette = function Palette(_ref) {
|
|
1771
|
+
var color = _ref.color,
|
|
1772
|
+
_ref$colorList = _ref.colorList,
|
|
1773
|
+
colorList = _ref$colorList === void 0 ? [] : _ref$colorList,
|
|
1774
|
+
onChange = _ref.onChange;
|
|
1775
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
1776
|
+
className: "neeto-ui-flex neeto-ui-flex-row neeto-ui-flex-wrap neeto-ui-items-start neeto-ui-justify-start neeto-ui-color-palette"
|
|
1777
|
+
}, colorList.map(function (item, index) {
|
|
1778
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
1779
|
+
"data-testid": "color-palette-item",
|
|
1780
|
+
key: index,
|
|
1781
|
+
className: classnames("neeto-ui-color-palette__item", {
|
|
1782
|
+
active: color && color.from === item.from && color.to === item.to
|
|
1783
|
+
}),
|
|
1784
|
+
onClick: function onClick() {
|
|
1785
|
+
return onChange(item.from, item.to);
|
|
1786
|
+
}
|
|
1787
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
1788
|
+
className: "bg-gradient-to-r from-".concat(item.from, " to-").concat(item.to)
|
|
1789
|
+
}));
|
|
1790
|
+
}));
|
|
1791
|
+
};
|
|
1792
|
+
|
|
1793
|
+
var TARGET_SIZES = {
|
|
1794
|
+
large: "large",
|
|
1795
|
+
medium: "medium",
|
|
1796
|
+
small: "small"
|
|
1797
|
+
};
|
|
1798
|
+
var ColorPicker = function ColorPicker(_ref) {
|
|
1799
|
+
var _ref2;
|
|
1800
|
+
var _ref$color = _ref.color,
|
|
1801
|
+
color = _ref$color === void 0 ? "" : _ref$color,
|
|
1802
|
+
_ref$size = _ref.size,
|
|
1803
|
+
size = _ref$size === void 0 ? TARGET_SIZES.large : _ref$size,
|
|
1804
|
+
_ref$onChange = _ref.onChange,
|
|
1805
|
+
onChange = _ref$onChange === void 0 ? noop : _ref$onChange,
|
|
1806
|
+
colorPaletteProps = _ref.colorPaletteProps,
|
|
1807
|
+
dropdownProps = _ref.dropdownProps,
|
|
1808
|
+
_ref$showEyeDropper = _ref.showEyeDropper,
|
|
1809
|
+
showEyeDropper = _ref$showEyeDropper === void 0 ? false : _ref$showEyeDropper,
|
|
1810
|
+
_ref$showHexValue = _ref.showHexValue,
|
|
1811
|
+
showHexValue = _ref$showHexValue === void 0 ? false : _ref$showHexValue,
|
|
1812
|
+
_ref$showTransparency = _ref.showTransparencyControl,
|
|
1813
|
+
showTransparencyControl = _ref$showTransparency === void 0 ? false : _ref$showTransparency,
|
|
1814
|
+
_ref$showPicker = _ref.showPicker,
|
|
1815
|
+
showPicker = _ref$showPicker === void 0 ? true : _ref$showPicker;
|
|
1816
|
+
var _useState = useState(color),
|
|
1817
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
1818
|
+
colorInternal = _useState2[0],
|
|
1819
|
+
setColorInternal = _useState2[1];
|
|
1820
|
+
var isInputChanged = useRef(false);
|
|
1821
|
+
var _useEyeDropper = useEyeDropper({
|
|
1822
|
+
pickRadius: 3
|
|
1823
|
+
}),
|
|
1824
|
+
open = _useEyeDropper.open,
|
|
1825
|
+
isSupported = _useEyeDropper.isSupported;
|
|
1826
|
+
var PickerComponent = showTransparencyControl ? HexAlphaColorPicker : HexColorPicker;
|
|
1827
|
+
var colorValue = (_ref2 = color !== null && color !== void 0 ? color : colorInternal) !== null && _ref2 !== void 0 ? _ref2 : "";
|
|
1828
|
+
var onChangeInternal = onChange || setColorInternal;
|
|
1829
|
+
var getColor = function getColor(colorValue) {
|
|
1830
|
+
var color = tinycolor(colorValue);
|
|
1831
|
+
return {
|
|
1832
|
+
hex: showTransparencyControl ? color.toHex8String() : color.toHexString(),
|
|
1833
|
+
rgb: color.toRgb()
|
|
1834
|
+
};
|
|
1835
|
+
};
|
|
1836
|
+
var onColorInputChange = function onColorInputChange(hex) {
|
|
1837
|
+
var color = tinycolor(hex);
|
|
1838
|
+
var rgb = color.toRgb();
|
|
1839
|
+
isInputChanged.current = true;
|
|
1840
|
+
onChangeInternal({
|
|
1841
|
+
hex: hex,
|
|
1842
|
+
rgb: rgb
|
|
1843
|
+
});
|
|
1844
|
+
};
|
|
1845
|
+
var onPickerChange = function onPickerChange(hex) {
|
|
1846
|
+
return onChangeInternal(getColor(hex));
|
|
1847
|
+
};
|
|
1848
|
+
var onBlur = function onBlur() {
|
|
1849
|
+
// If input is not changed, don't call onChange on blur
|
|
1850
|
+
if (!isInputChanged.current) return;
|
|
1851
|
+
isInputChanged.current = false;
|
|
1852
|
+
onChangeInternal(getColor(colorValue));
|
|
1853
|
+
};
|
|
1854
|
+
var pickColor = /*#__PURE__*/function () {
|
|
1855
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
|
|
1856
|
+
var colorResponse, colorHex;
|
|
1857
|
+
return regenerator.wrap(function _callee$(_context) {
|
|
1858
|
+
while (1) switch (_context.prev = _context.next) {
|
|
1859
|
+
case 0:
|
|
1860
|
+
_context.prev = 0;
|
|
1861
|
+
_context.next = 3;
|
|
1862
|
+
return open();
|
|
1863
|
+
case 3:
|
|
1864
|
+
colorResponse = _context.sent;
|
|
1865
|
+
colorHex = tinycolor(colorResponse.sRGBHex).toHexString();
|
|
1866
|
+
onPickerChange(colorHex);
|
|
1867
|
+
_context.next = 10;
|
|
1868
|
+
break;
|
|
1869
|
+
case 8:
|
|
1870
|
+
_context.prev = 8;
|
|
1871
|
+
_context.t0 = _context["catch"](0);
|
|
1872
|
+
case 10:
|
|
1873
|
+
case "end":
|
|
1874
|
+
return _context.stop();
|
|
1875
|
+
}
|
|
1876
|
+
}, _callee, null, [[0, 8]]);
|
|
1877
|
+
}));
|
|
1878
|
+
return function pickColor() {
|
|
1879
|
+
return _ref3.apply(this, arguments);
|
|
1880
|
+
};
|
|
1881
|
+
}();
|
|
1882
|
+
var Target = function Target(_ref4) {
|
|
1883
|
+
var size = _ref4.size;
|
|
1884
|
+
return /*#__PURE__*/React__default.createElement("button", {
|
|
1885
|
+
"data-cy": "color-picker-target",
|
|
1886
|
+
"data-testid": "neeto-color-picker",
|
|
1887
|
+
type: "button",
|
|
1888
|
+
className: classnames("neeto-ui-colorpicker__target", {
|
|
1889
|
+
"neeto-ui-colorpicker__target-size--large": size === TARGET_SIZES.large,
|
|
1890
|
+
"neeto-ui-colorpicker__target-size--medium": size === TARGET_SIZES.medium,
|
|
1891
|
+
"neeto-ui-colorpicker__target-size--small": size === TARGET_SIZES.small
|
|
1892
|
+
})
|
|
1893
|
+
}, showHexValue && /*#__PURE__*/React__default.createElement("span", {
|
|
1894
|
+
className: "neeto-ui-colorpicker-target__code"
|
|
1895
|
+
}, color), /*#__PURE__*/React__default.createElement("span", {
|
|
1896
|
+
className: "neeto-ui-colorpicker-target__color-wrapper"
|
|
1897
|
+
}, /*#__PURE__*/React__default.createElement("span", {
|
|
1898
|
+
className: "neeto-ui-colorpicker-target__color neeto-ui-border-gray-400 border",
|
|
1899
|
+
style: {
|
|
1900
|
+
backgroundColor: colorValue
|
|
1901
|
+
}
|
|
1902
|
+
}), /*#__PURE__*/React__default.createElement("span", {
|
|
1903
|
+
className: "neeto-ui-colorpicker-target__icon"
|
|
1904
|
+
}, /*#__PURE__*/React__default.createElement(Down, {
|
|
1905
|
+
size: 16
|
|
1906
|
+
}))));
|
|
1907
|
+
};
|
|
1908
|
+
return /*#__PURE__*/React__default.createElement(Dropdown, _extends({
|
|
1909
|
+
className: "neeto-ui-colorpicker__dropdown",
|
|
1910
|
+
closeOnSelect: false,
|
|
1911
|
+
customTarget: /*#__PURE__*/React__default.createElement(Target, {
|
|
1912
|
+
size: size
|
|
1913
|
+
}),
|
|
1914
|
+
label: colorValue,
|
|
1915
|
+
position: "bottom-start"
|
|
1916
|
+
}, dropdownProps), /*#__PURE__*/React__default.createElement("div", {
|
|
1917
|
+
className: "neeto-ui-colorpicker__popover"
|
|
1918
|
+
}, showPicker && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("div", {
|
|
1919
|
+
className: "neeto-ui-colorpicker__pointer",
|
|
1920
|
+
"data-testid": "neeto-color-picker-section"
|
|
1921
|
+
}, /*#__PURE__*/React__default.createElement(PickerComponent, {
|
|
1922
|
+
color: colorValue,
|
|
1923
|
+
onChange: onPickerChange
|
|
1924
|
+
})), /*#__PURE__*/React__default.createElement("div", {
|
|
1925
|
+
className: "neeto-ui-flex neeto-ui-items-center neeto-ui-justify-center neeto-ui-mt-2 neeto-ui-gap-2"
|
|
1926
|
+
}, showEyeDropper && isSupported() && /*#__PURE__*/React__default.createElement(Button, {
|
|
1927
|
+
className: "neeto-ui-colorpicker__eyedropper-btn",
|
|
1928
|
+
icon: Focus,
|
|
1929
|
+
size: "small",
|
|
1930
|
+
style: "text",
|
|
1931
|
+
type: "button",
|
|
1932
|
+
onClick: pickColor
|
|
1933
|
+
}), /*#__PURE__*/React__default.createElement("div", {
|
|
1934
|
+
className: "neeto-ui-input__wrapper"
|
|
1935
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
1936
|
+
className: "neeto-ui-colorpicker__input neeto-ui-input neeto-ui-input--small",
|
|
1937
|
+
"data-cy": "colorpicker-editable-input"
|
|
1938
|
+
}, /*#__PURE__*/React__default.createElement(HexColorInput, {
|
|
1939
|
+
onBlur: onBlur,
|
|
1940
|
+
alpha: !!showTransparencyControl,
|
|
1941
|
+
color: colorValue,
|
|
1942
|
+
onChange: onColorInputChange
|
|
1943
|
+
}))))), colorPaletteProps && /*#__PURE__*/React__default.createElement("div", {
|
|
1944
|
+
"data-testid": "color-palette",
|
|
1945
|
+
className: classnames("neeto-ui-colorpicker__palette-wrapper", {
|
|
1946
|
+
"neeto-ui-colorpicker__palette-wrapper--hidden-picker": !showPicker
|
|
1947
|
+
})
|
|
1948
|
+
}, /*#__PURE__*/React__default.createElement(Palette, colorPaletteProps))));
|
|
1949
|
+
};
|
|
1950
|
+
|
|
1951
|
+
var _excluded$e = ["className", "label", "size", "dropdownClassName", "popupClassName", "dateFormat", "timeFormat", "onChange", "onOk", "picker", "mode", "showTime", "type", "nakedInput", "error", "defaultValue", "value", "labelProps", "required", "allowClear"];
|
|
1952
|
+
function ownKeys$9(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
1953
|
+
function _objectSpread$9(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$9(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$9(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
1954
|
+
var INPUT_SIZES$2 = {
|
|
1955
|
+
small: "small",
|
|
1956
|
+
medium: "medium",
|
|
1957
|
+
large: "large"
|
|
1958
|
+
};
|
|
1959
|
+
var RangePicker$1 = _DatePicker.RangePicker;
|
|
1960
|
+
var datePickerTypes = {
|
|
1961
|
+
range: RangePicker$1,
|
|
1962
|
+
date: _DatePicker
|
|
1963
|
+
};
|
|
1964
|
+
var IconOverride = function IconOverride(_ref) {
|
|
1965
|
+
var Icon = _ref.icon;
|
|
1966
|
+
return /*#__PURE__*/React__default.createElement("span", {
|
|
1967
|
+
className: "neeto-ui-btn neeto-ui-btn--style-text neeto-ui-btn--size-medium neeto-ui-btn--icon-only"
|
|
1968
|
+
}, /*#__PURE__*/React__default.createElement(Icon, {
|
|
1969
|
+
className: "neeto-ui-btn__icon",
|
|
1970
|
+
size: 20
|
|
1971
|
+
}));
|
|
1972
|
+
};
|
|
1973
|
+
var Today = function Today(_ref2) {
|
|
1974
|
+
var onClick = _ref2.onClick;
|
|
1975
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
1976
|
+
className: "text-center"
|
|
1977
|
+
}, /*#__PURE__*/React__default.createElement("button", {
|
|
1978
|
+
onClick: onClick,
|
|
1979
|
+
className: "neeto-ui-rounded-md hover:neeto-ui-bg-gray-200 px-2 py-1 text-xs font-medium transition duration-300 ease-in-out",
|
|
1980
|
+
"data-cy": "year-month-mode-today"
|
|
1981
|
+
}, "Today"));
|
|
1982
|
+
};
|
|
1983
|
+
var DatePicker = /*#__PURE__*/forwardRef(function (_ref3, ref) {
|
|
1984
|
+
var _ref3$className = _ref3.className,
|
|
1985
|
+
className = _ref3$className === void 0 ? "" : _ref3$className,
|
|
1986
|
+
_ref3$label = _ref3.label,
|
|
1987
|
+
label = _ref3$label === void 0 ? "" : _ref3$label,
|
|
1988
|
+
_ref3$size = _ref3.size,
|
|
1989
|
+
size = _ref3$size === void 0 ? INPUT_SIZES$2.medium : _ref3$size,
|
|
1990
|
+
_ref3$dropdownClassNa = _ref3.dropdownClassName,
|
|
1991
|
+
dropdownClassName = _ref3$dropdownClassNa === void 0 ? "" : _ref3$dropdownClassNa,
|
|
1992
|
+
_ref3$popupClassName = _ref3.popupClassName,
|
|
1993
|
+
popupClassName = _ref3$popupClassName === void 0 ? "" : _ref3$popupClassName,
|
|
1994
|
+
_ref3$dateFormat = _ref3.dateFormat,
|
|
1995
|
+
dateFormat = _ref3$dateFormat === void 0 ? "DD/MM/YYYY" : _ref3$dateFormat,
|
|
1996
|
+
_ref3$timeFormat = _ref3.timeFormat,
|
|
1997
|
+
timeFormat = _ref3$timeFormat === void 0 ? "HH:mm:ss" : _ref3$timeFormat,
|
|
1998
|
+
_ref3$onChange = _ref3.onChange,
|
|
1999
|
+
onChange = _ref3$onChange === void 0 ? noop : _ref3$onChange,
|
|
2000
|
+
_ref3$onOk = _ref3.onOk,
|
|
2001
|
+
onOk = _ref3$onOk === void 0 ? noop : _ref3$onOk,
|
|
2002
|
+
_ref3$picker = _ref3.picker,
|
|
2003
|
+
picker = _ref3$picker === void 0 ? "date" : _ref3$picker,
|
|
2004
|
+
_ref3$mode = _ref3.mode,
|
|
2005
|
+
inputMode = _ref3$mode === void 0 ? "date" : _ref3$mode,
|
|
2006
|
+
_ref3$showTime = _ref3.showTime,
|
|
2007
|
+
showTime = _ref3$showTime === void 0 ? false : _ref3$showTime,
|
|
2008
|
+
_ref3$type = _ref3.type,
|
|
2009
|
+
type = _ref3$type === void 0 ? "date" : _ref3$type,
|
|
2010
|
+
_ref3$nakedInput = _ref3.nakedInput,
|
|
2011
|
+
nakedInput = _ref3$nakedInput === void 0 ? false : _ref3$nakedInput,
|
|
2012
|
+
_ref3$error = _ref3.error,
|
|
2013
|
+
error = _ref3$error === void 0 ? "" : _ref3$error,
|
|
2014
|
+
defaultValue = _ref3.defaultValue,
|
|
2015
|
+
value = _ref3.value,
|
|
2016
|
+
labelProps = _ref3.labelProps,
|
|
2017
|
+
_ref3$required = _ref3.required,
|
|
2018
|
+
required = _ref3$required === void 0 ? false : _ref3$required,
|
|
2019
|
+
_ref3$allowClear = _ref3.allowClear,
|
|
2020
|
+
allowClear = _ref3$allowClear === void 0 ? true : _ref3$allowClear,
|
|
2021
|
+
otherProps = _objectWithoutProperties(_ref3, _excluded$e);
|
|
2022
|
+
var _useState = useState(inputMode),
|
|
2023
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
2024
|
+
mode = _useState2[0],
|
|
2025
|
+
setMode = _useState2[1];
|
|
2026
|
+
var _useState3 = useState(),
|
|
2027
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
2028
|
+
pickerValue = _useState4[0],
|
|
2029
|
+
setPickerValue = _useState4[1];
|
|
2030
|
+
var id = useId(otherProps.id);
|
|
2031
|
+
var datePickerRef = useSyncedRef(ref);
|
|
2032
|
+
var Component = datePickerTypes[type === null || type === void 0 ? void 0 : type.toLowerCase()];
|
|
2033
|
+
var format = showTime ? "".concat(dateFormat, " ").concat(timeFormat) : dateFormat;
|
|
2034
|
+
var errorId = "error_".concat(id);
|
|
2035
|
+
var handleOnChange = function handleOnChange(date, dateString) {
|
|
2036
|
+
type === "range" && !date ? onChange([], dateString) : onChange(date, dateString);
|
|
2037
|
+
};
|
|
2038
|
+
var renderExtraFooter = function renderExtraFooter() {
|
|
2039
|
+
if (type === "range" || mode === "date") return null;
|
|
2040
|
+
return /*#__PURE__*/React__default.createElement(Today, {
|
|
2041
|
+
onClick: function onClick() {
|
|
2042
|
+
setMode("date");
|
|
2043
|
+
setTimeout(function () {
|
|
2044
|
+
document.querySelector(".ant-picker-now-btn").click();
|
|
2045
|
+
});
|
|
2046
|
+
}
|
|
2047
|
+
});
|
|
2048
|
+
};
|
|
2049
|
+
return /*#__PURE__*/React__default.createElement(_ConfigProvider, {
|
|
2050
|
+
theme: {
|
|
2051
|
+
token: _objectSpread$9({}, ANT_DESIGN_GLOBAL_TOKEN_OVERRIDES),
|
|
2052
|
+
components: {
|
|
2053
|
+
DatePicker: {
|
|
2054
|
+
activeBg: "rgb(var(--neeto-ui-white))",
|
|
2055
|
+
activeBorderColor: "rgb(var(--neeto-ui-primary-500))",
|
|
2056
|
+
addonBg: "rgb(var(--neeto-ui-gray-100))",
|
|
2057
|
+
cellActiveWithRangeBg: "rgb(var(--neeto-ui-primary-100))",
|
|
2058
|
+
cellBgDisabled: "rgb(var(--neeto-ui-gray-100))",
|
|
2059
|
+
cellHoverBg: "rgb(var(--neeto-ui-gray-200))",
|
|
2060
|
+
cellHoverWithRangeBg: "rgb(var(--neeto-ui-primary-100))",
|
|
2061
|
+
cellRangeBorderColor: "rgb(var(--neeto-ui-primary-100))",
|
|
2062
|
+
hoverBg: "rgb(var(--neeto-ui-white))",
|
|
2063
|
+
hoverBorderColor: "rgb(var(--neeto-ui-primary-500))",
|
|
2064
|
+
// Global overrides
|
|
2065
|
+
colorBgContainer: "rgb(var(--neeto-ui-white))",
|
|
2066
|
+
colorBgElevated: "rgb(var(--neeto-ui-white))",
|
|
2067
|
+
colorPrimary: "rgb(var(--neeto-ui-primary-500))",
|
|
2068
|
+
colorPrimaryBorder: "rgb(var(--neeto-ui-primary-100))",
|
|
2069
|
+
colorPrimaryHover: "rgb(var(--neeto-ui-primary-600))",
|
|
2070
|
+
colorBorder: "rgb(var(--neeto-ui-gray-300))",
|
|
2071
|
+
colorError: "rgb(var(--neeto-ui-error-500))",
|
|
2072
|
+
colorErrorHover: "rgb(var(--neeto-ui-error-600))",
|
|
2073
|
+
colorErrorOutline: "rgb(var(--neeto-ui-error-100))",
|
|
2074
|
+
colorFillAlter: "rgb(var(--neeto-ui-gray-100))",
|
|
2075
|
+
colorIcon: "rgb(var(--neeto-ui-gray-700))",
|
|
2076
|
+
colorIconHover: "rgb(var(--neeto-ui-gray-800))",
|
|
2077
|
+
colorLink: "rgb(var(--neeto-ui-primary-500))",
|
|
2078
|
+
colorLinkHover: "rgb(var(--neeto-ui-primary-600))",
|
|
2079
|
+
colorLinkActive: "rgb(var(--neeto-ui-primary-800))",
|
|
2080
|
+
colorSplit: "rgb(var(--neeto-ui-gray-200))",
|
|
2081
|
+
colorText: "rgb(var(--neeto-ui-gray-800))",
|
|
2082
|
+
colorTextDescription: "rgb(var(--neeto-ui-gray-700))",
|
|
2083
|
+
colorTextDisabled: "rgb(var(--neeto-ui-gray-500))",
|
|
2084
|
+
colorTextHeading: "rgb(var(--neeto-ui-black))",
|
|
2085
|
+
colorTextLightSolid: "rgb(var(--neeto-ui-white))",
|
|
2086
|
+
colorTextPlaceholder: "rgb(var(--neeto-ui-gray-400))",
|
|
2087
|
+
colorTextQuaternary: "rgb(var(--neeto-ui-gray-400))",
|
|
2088
|
+
colorWarning: "rgb(var(--neeto-ui-warning-500))",
|
|
2089
|
+
colorWarningHover: "rgb(var(--neeto-ui-warning-600))",
|
|
2090
|
+
colorWarningOutline: "rgb(var(--neeto-ui-warning-100))",
|
|
2091
|
+
controlItemBgActive: "rgb(var(--neeto-ui-pastel-purple))",
|
|
2092
|
+
controlItemBgHover: "rgb(var(--neeto-ui-gray-100))",
|
|
2093
|
+
controlOutline: "rgb(var(--neeto-ui-gray-300))",
|
|
2094
|
+
// Sizes
|
|
2095
|
+
cellHeight: 32,
|
|
2096
|
+
padding: 22
|
|
2097
|
+
}
|
|
2098
|
+
}
|
|
2099
|
+
}
|
|
2100
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
2101
|
+
className: "neeto-ui-input__wrapper"
|
|
2102
|
+
}, label && /*#__PURE__*/React__default.createElement(Label, _objectSpread$9({
|
|
2103
|
+
required: required
|
|
2104
|
+
}, labelProps), label), /*#__PURE__*/React__default.createElement(Component, _extends({
|
|
2105
|
+
"data-cy": label ? "".concat(hyphenize(label), "-input") : "picker-input",
|
|
2106
|
+
defaultValue: convertToDayjsObjects(defaultValue),
|
|
2107
|
+
ref: datePickerRef,
|
|
2108
|
+
showTime: showTime && {
|
|
2109
|
+
format: timeFormat
|
|
2110
|
+
},
|
|
2111
|
+
value: convertToDayjsObjects(value),
|
|
2112
|
+
className: classnames("neeto-ui-date-input", [className], {
|
|
2113
|
+
"neeto-ui-date-input--small": size === "small",
|
|
2114
|
+
"neeto-ui-date-input--medium": size === "medium",
|
|
2115
|
+
"neeto-ui-date-input--large": size === "large",
|
|
2116
|
+
"neeto-ui-date-input--disabled": otherProps.disabled,
|
|
2117
|
+
"neeto-ui-date-input--naked": nakedInput,
|
|
2118
|
+
"neeto-ui-date-input--error": !!error
|
|
2119
|
+
}),
|
|
2120
|
+
popupClassName: classnames("neeto-ui-date-time-dropdown", [dropdownClassName,
|
|
2121
|
+
// Will be removed in the next major version
|
|
2122
|
+
popupClassName]),
|
|
2123
|
+
onChange: handleOnChange
|
|
2124
|
+
}, _objectSpread$9(_objectSpread$9({
|
|
2125
|
+
format: format,
|
|
2126
|
+
onOk: onOk,
|
|
2127
|
+
picker: picker
|
|
2128
|
+
}, otherProps), type === "date" && {
|
|
2129
|
+
mode: mode,
|
|
2130
|
+
pickerValue: pickerValue,
|
|
2131
|
+
renderExtraFooter: renderExtraFooter,
|
|
2132
|
+
onPanelChange: function onPanelChange(pickerValue, mode) {
|
|
2133
|
+
setPickerValue(pickerValue);
|
|
2134
|
+
setMode(mode);
|
|
2135
|
+
}
|
|
2136
|
+
}), {
|
|
2137
|
+
nextIcon: /*#__PURE__*/React__default.createElement(IconOverride, {
|
|
2138
|
+
icon: Right
|
|
2139
|
+
}),
|
|
2140
|
+
prevIcon: /*#__PURE__*/React__default.createElement(IconOverride, {
|
|
2141
|
+
icon: Left
|
|
2142
|
+
}),
|
|
2143
|
+
suffixIcon: /*#__PURE__*/React__default.createElement(Calendar, {
|
|
2144
|
+
size: 16
|
|
2145
|
+
}),
|
|
2146
|
+
superNextIcon: /*#__PURE__*/React__default.createElement(IconOverride, {
|
|
2147
|
+
icon: Right
|
|
2148
|
+
}),
|
|
2149
|
+
superPrevIcon: /*#__PURE__*/React__default.createElement(IconOverride, {
|
|
2150
|
+
icon: Left
|
|
2151
|
+
}),
|
|
2152
|
+
allowClear: allowClear && {
|
|
2153
|
+
clearIcon: /*#__PURE__*/React__default.createElement(Close, {
|
|
2154
|
+
"data-cy": "date-time-clear-icon",
|
|
2155
|
+
size: 16
|
|
2156
|
+
})
|
|
2157
|
+
}
|
|
2158
|
+
})), !!error && typeof error === "string" && /*#__PURE__*/React__default.createElement("p", {
|
|
2159
|
+
className: "neeto-ui-input__error",
|
|
2160
|
+
"data-cy": "".concat(hyphenize(label), "-input-error"),
|
|
2161
|
+
id: errorId
|
|
2162
|
+
}, error)));
|
|
2163
|
+
});
|
|
2164
|
+
DatePicker.displayName = "DatePicker";
|
|
2165
|
+
|
|
2166
|
+
var customParseFormat$1 = {exports: {}};
|
|
2167
|
+
|
|
2168
|
+
(function (module, exports) {
|
|
2169
|
+
!function(e,t){module.exports=t();}(commonjsGlobal,(function(){var e={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"},t=/(\[[^[]*\])|([-_:/.,()\s]+)|(A|a|YYYY|YY?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g,n=/\d\d/,r=/\d\d?/,i=/\d*[^-_:/,()\s\d]+/,o={},s=function(e){return (e=+e)+(e>68?1900:2e3)};var a=function(e){return function(t){this[e]=+t;}},f=[/[+-]\d\d:?(\d\d)?|Z/,function(e){(this.zone||(this.zone={})).offset=function(e){if(!e)return 0;if("Z"===e)return 0;var t=e.match(/([+-]|\d\d)/g),n=60*t[1]+(+t[2]||0);return 0===n?0:"+"===t[0]?-n:n}(e);}],h=function(e){var t=o[e];return t&&(t.indexOf?t:t.s.concat(t.f))},u=function(e,t){var n,r=o.meridiem;if(r){for(var i=1;i<=24;i+=1)if(e.indexOf(r(i,0,t))>-1){n=i>12;break}}else n=e===(t?"pm":"PM");return n},d={A:[i,function(e){this.afternoon=u(e,!1);}],a:[i,function(e){this.afternoon=u(e,!0);}],S:[/\d/,function(e){this.milliseconds=100*+e;}],SS:[n,function(e){this.milliseconds=10*+e;}],SSS:[/\d{3}/,function(e){this.milliseconds=+e;}],s:[r,a("seconds")],ss:[r,a("seconds")],m:[r,a("minutes")],mm:[r,a("minutes")],H:[r,a("hours")],h:[r,a("hours")],HH:[r,a("hours")],hh:[r,a("hours")],D:[r,a("day")],DD:[n,a("day")],Do:[i,function(e){var t=o.ordinal,n=e.match(/\d+/);if(this.day=n[0],t)for(var r=1;r<=31;r+=1)t(r).replace(/\[|\]/g,"")===e&&(this.day=r);}],M:[r,a("month")],MM:[n,a("month")],MMM:[i,function(e){var t=h("months"),n=(h("monthsShort")||t.map((function(e){return e.slice(0,3)}))).indexOf(e)+1;if(n<1)throw new Error;this.month=n%12||n;}],MMMM:[i,function(e){var t=h("months").indexOf(e)+1;if(t<1)throw new Error;this.month=t%12||t;}],Y:[/[+-]?\d+/,a("year")],YY:[n,function(e){this.year=s(e);}],YYYY:[/\d{4}/,a("year")],Z:f,ZZ:f};function c(n){var r,i;r=n,i=o&&o.formats;for(var s=(n=r.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,(function(t,n,r){var o=r&&r.toUpperCase();return n||i[r]||e[r]||i[o].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,(function(e,t,n){return t||n.slice(1)}))}))).match(t),a=s.length,f=0;f<a;f+=1){var h=s[f],u=d[h],c=u&&u[0],l=u&&u[1];s[f]=l?{regex:c,parser:l}:h.replace(/^\[|\]$/g,"");}return function(e){for(var t={},n=0,r=0;n<a;n+=1){var i=s[n];if("string"==typeof i)r+=i.length;else {var o=i.regex,f=i.parser,h=e.slice(r),u=o.exec(h)[0];f.call(t,u),e=e.replace(u,"");}}return function(e){var t=e.afternoon;if(void 0!==t){var n=e.hours;t?n<12&&(e.hours+=12):12===n&&(e.hours=0),delete e.afternoon;}}(t),t}}return function(e,t,n){n.p.customParseFormat=!0,e&&e.parseTwoDigitYear&&(s=e.parseTwoDigitYear);var r=t.prototype,i=r.parse;r.parse=function(e){var t=e.date,r=e.utc,s=e.args;this.$u=r;var a=s[1];if("string"==typeof a){var f=!0===s[2],h=!0===s[3],u=f||h,d=s[2];h&&(d=s[2]),o=this.$locale(),!f&&d&&(o=n.Ls[d]),this.$d=function(e,t,n){try{if(["x","X"].indexOf(t)>-1)return new Date(("X"===t?1e3:1)*e);var r=c(t)(e),i=r.year,o=r.month,s=r.day,a=r.hours,f=r.minutes,h=r.seconds,u=r.milliseconds,d=r.zone,l=new Date,m=s||(i||o?1:l.getDate()),M=i||l.getFullYear(),Y=0;i&&!o||(Y=o>0?o-1:l.getMonth());var p=a||0,v=f||0,D=h||0,g=u||0;return d?new Date(Date.UTC(M,Y,m,p,v,D,g+60*d.offset*1e3)):n?new Date(Date.UTC(M,Y,m,p,v,D,g)):new Date(M,Y,m,p,v,D,g)}catch(e){return new Date("")}}(t,a,r),this.init(),d&&!0!==d&&(this.$L=this.locale(d).$L),u&&t!=this.format(a)&&(this.$d=new Date("")),o={};}else if(a instanceof Array)for(var l=a.length,m=1;m<=l;m+=1){s[1]=a[m-1];var M=n.apply(this,s);if(M.isValid()){this.$d=M.$d,this.$L=M.$L,this.init();break}m===l&&(this.$d=new Date(""));}else i.call(this,e);};}}));
|
|
2170
|
+
} (customParseFormat$1));
|
|
2171
|
+
|
|
2172
|
+
var customParseFormat = customParseFormat$1.exports;
|
|
2173
|
+
|
|
2174
|
+
var HoverIcon = function HoverIcon(_ref) {
|
|
2175
|
+
var _ref$time = _ref.time,
|
|
2176
|
+
time = _ref$time === void 0 ? false : _ref$time;
|
|
2177
|
+
var _useState = useState(false),
|
|
2178
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
2179
|
+
hovered = _useState2[0],
|
|
2180
|
+
setHovered = _useState2[1];
|
|
2181
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
2182
|
+
onMouseLeave: function onMouseLeave() {
|
|
2183
|
+
return setHovered(false);
|
|
2184
|
+
},
|
|
2185
|
+
onMouseOver: function onMouseOver() {
|
|
2186
|
+
return setHovered(true);
|
|
2187
|
+
}
|
|
2188
|
+
}, hovered && time ? /*#__PURE__*/React__default.createElement(Close, {
|
|
2189
|
+
size: 16
|
|
2190
|
+
}) : /*#__PURE__*/React__default.createElement(Clock, {
|
|
2191
|
+
size: 16
|
|
2192
|
+
}));
|
|
2193
|
+
};
|
|
2194
|
+
|
|
2195
|
+
// A wrapper hook around useState, that updates a ref as well, useful when dealing directly with dom event listeners.
|
|
2196
|
+
var useRefState = function useRefState(val) {
|
|
2197
|
+
// eslint-disable-next-line react/hook-use-state
|
|
2198
|
+
var _useState = useState(val),
|
|
2199
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
2200
|
+
value = _useState2[0],
|
|
2201
|
+
_setValue = _useState2[1];
|
|
2202
|
+
var valueRef = useRef(value);
|
|
2203
|
+
var setValue = function setValue(val) {
|
|
2204
|
+
valueRef.current = val;
|
|
2205
|
+
_setValue(val);
|
|
2206
|
+
};
|
|
2207
|
+
return [value, valueRef, setValue];
|
|
2208
|
+
};
|
|
2209
|
+
|
|
2210
|
+
var FORMAT = "HH:mm";
|
|
2211
|
+
var getFormattedTime = function getFormattedTime(value) {
|
|
2212
|
+
if (dayjs.isDayjs(value)) {
|
|
2213
|
+
return value.toDate();
|
|
2214
|
+
} else if (value instanceof Date || dayjs(value, FORMAT).isValid()) {
|
|
2215
|
+
return value;
|
|
2216
|
+
}
|
|
2217
|
+
return null;
|
|
2218
|
+
};
|
|
2219
|
+
var getFormattedRange = function getFormattedRange(value) {
|
|
2220
|
+
if (!Array.isArray(value)) return null;
|
|
2221
|
+
return value.map(function (item) {
|
|
2222
|
+
return getFormattedTime(item);
|
|
2223
|
+
});
|
|
2224
|
+
};
|
|
2225
|
+
var toDayJs = function toDayJs(value) {
|
|
2226
|
+
if (Array.isArray(value)) return value.map(function (item) {
|
|
2227
|
+
return dayjs(item, FORMAT);
|
|
2228
|
+
});
|
|
2229
|
+
return dayjs(value, FORMAT);
|
|
2230
|
+
};
|
|
2231
|
+
var isValidTime = function isValidTime(minTime, maxTime, value) {
|
|
2232
|
+
if (isPresent(minTime) && toDayJs(value).isBefore(toDayJs(minTime))) {
|
|
2233
|
+
return false;
|
|
2234
|
+
}
|
|
2235
|
+
return !(isPresent(maxTime) && toDayJs(value).isAfter(toDayJs(maxTime)));
|
|
2236
|
+
};
|
|
2237
|
+
var isValidRange = function isValidRange(minTime, maxTime, value) {
|
|
2238
|
+
return value.every(function (item) {
|
|
2239
|
+
return isValid(minTime, maxTime, item);
|
|
2240
|
+
});
|
|
2241
|
+
};
|
|
2242
|
+
var isValid = function isValid(minTime, maxTime, value) {
|
|
2243
|
+
return (Array.isArray(value) ? isValidRange : isValidTime)(minTime, maxTime, value);
|
|
2244
|
+
};
|
|
2245
|
+
var getValidTime = function getValidTime(minTime, maxTime, value) {
|
|
2246
|
+
if (isPresent(minTime) && toDayJs(value).isBefore(toDayJs(minTime))) {
|
|
2247
|
+
return minTime;
|
|
2248
|
+
}
|
|
2249
|
+
if (isPresent(maxTime) && toDayJs(value).isAfter(toDayJs(maxTime))) {
|
|
2250
|
+
return maxTime;
|
|
2251
|
+
}
|
|
2252
|
+
return value;
|
|
2253
|
+
};
|
|
2254
|
+
var getValidRange = function getValidRange(minTime, maxTime, value) {
|
|
2255
|
+
return value.map(function (item) {
|
|
2256
|
+
return getValidTime(minTime, maxTime, item);
|
|
2257
|
+
});
|
|
2258
|
+
};
|
|
2259
|
+
var getValid = function getValid(minTime, maxTime, value) {
|
|
2260
|
+
return (Array.isArray(value) ? getValidRange : getValidTime)(minTime, maxTime, value);
|
|
2261
|
+
};
|
|
2262
|
+
|
|
2263
|
+
var _excluded$d = ["type", "className", "label", "labelProps", "size", "nakedInput", "required", "value", "defaultValue", "onChange", "error", "onBlur", "minTime", "maxTime"];
|
|
2264
|
+
function ownKeys$8(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2265
|
+
function _objectSpread$8(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$8(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$8(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
2266
|
+
dayjs.extend(customParseFormat);
|
|
2267
|
+
var INPUT_SIZES$1 = {
|
|
2268
|
+
small: "small",
|
|
2269
|
+
medium: "medium",
|
|
2270
|
+
large: "large"
|
|
2271
|
+
};
|
|
2272
|
+
var timeComponents = {
|
|
2273
|
+
range: TimeRangePicker,
|
|
2274
|
+
time: TimePicker$1
|
|
2275
|
+
};
|
|
2276
|
+
var TimePickerInput = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
2277
|
+
var _ref$type = _ref.type,
|
|
2278
|
+
type = _ref$type === void 0 ? "time" : _ref$type,
|
|
2279
|
+
_ref$className = _ref.className,
|
|
2280
|
+
className = _ref$className === void 0 ? "" : _ref$className,
|
|
2281
|
+
label = _ref.label,
|
|
2282
|
+
labelProps = _ref.labelProps,
|
|
2283
|
+
_ref$size = _ref.size,
|
|
2284
|
+
size = _ref$size === void 0 ? INPUT_SIZES$1.medium : _ref$size,
|
|
2285
|
+
_ref$nakedInput = _ref.nakedInput,
|
|
2286
|
+
nakedInput = _ref$nakedInput === void 0 ? false : _ref$nakedInput,
|
|
2287
|
+
_ref$required = _ref.required,
|
|
2288
|
+
required = _ref$required === void 0 ? false : _ref$required,
|
|
2289
|
+
inputValue = _ref.value,
|
|
2290
|
+
defaultValue = _ref.defaultValue,
|
|
2291
|
+
_ref$onChange = _ref.onChange,
|
|
2292
|
+
onChange = _ref$onChange === void 0 ? noop : _ref$onChange,
|
|
2293
|
+
_ref$error = _ref.error,
|
|
2294
|
+
error = _ref$error === void 0 ? "" : _ref$error,
|
|
2295
|
+
_ref$onBlur = _ref.onBlur,
|
|
2296
|
+
onBlur = _ref$onBlur === void 0 ? noop : _ref$onBlur,
|
|
2297
|
+
minTime = _ref.minTime,
|
|
2298
|
+
maxTime = _ref.maxTime,
|
|
2299
|
+
otherProps = _objectWithoutProperties(_ref, _excluded$d);
|
|
2300
|
+
var _useRefState = useRefState(null),
|
|
2301
|
+
_useRefState2 = _slicedToArray(_useRefState, 3),
|
|
2302
|
+
value = _useRefState2[0],
|
|
2303
|
+
valueRef = _useRefState2[1],
|
|
2304
|
+
setValue = _useRefState2[2];
|
|
2305
|
+
var componentRef = useRef(null);
|
|
2306
|
+
var id = useId(otherProps.id);
|
|
2307
|
+
var errorId = "error_".concat(id);
|
|
2308
|
+
useEffect(function () {
|
|
2309
|
+
if (isNotPresent(inputValue) && isNotPresent(defaultValue)) return;
|
|
2310
|
+
setValue((type === "range" ? getFormattedRange : getFormattedTime)(inputValue || defaultValue));
|
|
2311
|
+
}, [type, inputValue]);
|
|
2312
|
+
var handleChange = function handleChange(newValue) {
|
|
2313
|
+
setValue(newValue);
|
|
2314
|
+
if (isValid(minTime, maxTime, newValue)) {
|
|
2315
|
+
onChange(toDayJs(newValue), newValue);
|
|
2316
|
+
}
|
|
2317
|
+
};
|
|
2318
|
+
var onBlurHandle = function onBlurHandle() {
|
|
2319
|
+
var value = valueRef.current;
|
|
2320
|
+
if (isValid(minTime, maxTime, value)) {
|
|
2321
|
+
onBlur(toDayJs(value), value);
|
|
2322
|
+
} else {
|
|
2323
|
+
var validValue = getValid(minTime, maxTime, value);
|
|
2324
|
+
setValue(validValue);
|
|
2325
|
+
onChange(toDayJs(validValue), validValue);
|
|
2326
|
+
onBlur(toDayJs(validValue), validValue);
|
|
2327
|
+
}
|
|
2328
|
+
return true;
|
|
2329
|
+
};
|
|
2330
|
+
|
|
2331
|
+
// If you just make amPm select change, onBlurHandle is not triggering. A work around
|
|
2332
|
+
useEffect(function () {
|
|
2333
|
+
var _document$getElementB;
|
|
2334
|
+
var amPmChange = function amPmChange() {
|
|
2335
|
+
return setTimeout(onBlurHandle);
|
|
2336
|
+
};
|
|
2337
|
+
var selectElements = (_document$getElementB = document.getElementById(id)) === null || _document$getElementB === void 0 ? void 0 : _document$getElementB.querySelectorAll("[name='amPm']");
|
|
2338
|
+
selectElements === null || selectElements === void 0 || selectElements.forEach(function (element) {
|
|
2339
|
+
return element.addEventListener("change", amPmChange);
|
|
2340
|
+
});
|
|
2341
|
+
return function () {
|
|
2342
|
+
selectElements === null || selectElements === void 0 || selectElements.forEach(function (element) {
|
|
2343
|
+
return element.removeEventListener("change", amPmChange);
|
|
2344
|
+
});
|
|
2345
|
+
};
|
|
2346
|
+
}, [value]);
|
|
2347
|
+
var handleKeyDown = function handleKeyDown(_ref2) {
|
|
2348
|
+
var code = _ref2.code;
|
|
2349
|
+
if (code !== "Enter") return;
|
|
2350
|
+
onBlurHandle();
|
|
2351
|
+
};
|
|
2352
|
+
var Component = timeComponents[type];
|
|
2353
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
2354
|
+
ref: ref,
|
|
2355
|
+
className: "neeto-ui-input__wrapper"
|
|
2356
|
+
}, label && /*#__PURE__*/React__default.createElement(Label, _objectSpread$8({
|
|
2357
|
+
required: required
|
|
2358
|
+
}, labelProps), label), /*#__PURE__*/React__default.createElement(Component, _extends({
|
|
2359
|
+
id: id,
|
|
2360
|
+
value: value,
|
|
2361
|
+
disableClock: true,
|
|
2362
|
+
clearIcon: /*#__PURE__*/React__default.createElement(HoverIcon, {
|
|
2363
|
+
time: !!value
|
|
2364
|
+
}),
|
|
2365
|
+
format: "hh:mm a",
|
|
2366
|
+
hourPlaceholder: "HH",
|
|
2367
|
+
minutePlaceholder: "mm",
|
|
2368
|
+
ref: componentRef,
|
|
2369
|
+
secondAriaLabel: "ss",
|
|
2370
|
+
shouldCloseClock: onBlurHandle,
|
|
2371
|
+
className: classnames("neeto-ui-time-picker", [className], {
|
|
2372
|
+
"neeto-ui-time-picker--small": size === "small",
|
|
2373
|
+
"neeto-ui-time-picker--medium": size === "medium",
|
|
2374
|
+
"neeto-ui-time-picker--large": size === "large",
|
|
2375
|
+
"neeto-ui-time-picker--disabled": otherProps.disabled,
|
|
2376
|
+
"neeto-ui-time-picker--naked": nakedInput,
|
|
2377
|
+
"neeto-ui-time-picker--error": !!error
|
|
2378
|
+
}),
|
|
2379
|
+
onChange: handleChange,
|
|
2380
|
+
onKeyDown: handleKeyDown
|
|
2381
|
+
}, otherProps)), !!error && typeof error === "string" && /*#__PURE__*/React__default.createElement("p", {
|
|
2382
|
+
className: "neeto-ui-input__error",
|
|
2383
|
+
"data-cy": "".concat(hyphenize(label), "-input-error"),
|
|
2384
|
+
id: errorId
|
|
2385
|
+
}, error));
|
|
2386
|
+
});
|
|
2387
|
+
TimePickerInput.displayName = "TimePicker";
|
|
2388
|
+
|
|
2389
|
+
var DATE_FORMAT = "YYYY-MM-DD";
|
|
2390
|
+
var TIME_FORMAT = "HH:mm";
|
|
2391
|
+
var getDateTime = function getDateTime(date, time) {
|
|
2392
|
+
if (isPresent(date) && isPresent(time)) {
|
|
2393
|
+
return dayjs("".concat(date.format(DATE_FORMAT), " ").concat(time.format(TIME_FORMAT)));
|
|
2394
|
+
}
|
|
2395
|
+
return null;
|
|
2396
|
+
};
|
|
2397
|
+
var getAllowedTime = function getAllowedTime(date, time, minDateTime, maxDateTime) {
|
|
2398
|
+
var newTime = getDateTime(date, time || dayjs());
|
|
2399
|
+
if (isPresent(minDateTime) && date !== null && date !== void 0 && date.isSame(minDateTime, "day") && newTime !== null && newTime !== void 0 && newTime.isBefore(minDateTime)) {
|
|
2400
|
+
return minDateTime;
|
|
2401
|
+
}
|
|
2402
|
+
if (isPresent(maxDateTime) && date !== null && date !== void 0 && date.isSame(maxDateTime, "day") && newTime !== null && newTime !== void 0 && newTime.isAfter(maxDateTime)) {
|
|
2403
|
+
return maxDateTime;
|
|
2404
|
+
}
|
|
2405
|
+
return newTime;
|
|
2406
|
+
};
|
|
2407
|
+
var getTime = function getTime(date) {
|
|
2408
|
+
return date === null || date === void 0 ? void 0 : date.format(TIME_FORMAT);
|
|
2409
|
+
};
|
|
2410
|
+
|
|
2411
|
+
function ownKeys$7(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2412
|
+
function _objectSpread$7(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$7(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$7(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
2413
|
+
dayjs.extend(customParseFormat);
|
|
2414
|
+
var DateTimePicker = function DateTimePicker(_ref) {
|
|
2415
|
+
var _ref$className = _ref.className,
|
|
2416
|
+
className = _ref$className === void 0 ? "" : _ref$className,
|
|
2417
|
+
_ref$label = _ref.label,
|
|
2418
|
+
label = _ref$label === void 0 ? "" : _ref$label,
|
|
2419
|
+
size = _ref.size,
|
|
2420
|
+
dropdownClassName = _ref.dropdownClassName,
|
|
2421
|
+
popupClassName = _ref.popupClassName,
|
|
2422
|
+
dateFormat = _ref.dateFormat,
|
|
2423
|
+
_ref$onChange = _ref.onChange,
|
|
2424
|
+
onChange = _ref$onChange === void 0 ? noop : _ref$onChange,
|
|
2425
|
+
_ref$nakedInput = _ref.nakedInput,
|
|
2426
|
+
nakedInput = _ref$nakedInput === void 0 ? false : _ref$nakedInput,
|
|
2427
|
+
_ref$error = _ref.error,
|
|
2428
|
+
error = _ref$error === void 0 ? "" : _ref$error,
|
|
2429
|
+
defaultValue = _ref.defaultValue,
|
|
2430
|
+
value = _ref.value,
|
|
2431
|
+
labelProps = _ref.labelProps,
|
|
2432
|
+
_ref$required = _ref.required,
|
|
2433
|
+
required = _ref$required === void 0 ? false : _ref$required,
|
|
2434
|
+
id = _ref.id,
|
|
2435
|
+
datePickerProps = _ref.datePickerProps,
|
|
2436
|
+
timePickerProps = _ref.timePickerProps,
|
|
2437
|
+
minDateTime = _ref.minDateTime,
|
|
2438
|
+
maxDateTime = _ref.maxDateTime,
|
|
2439
|
+
_ref$onTimeInputBlur = _ref.onTimeInputBlur,
|
|
2440
|
+
onTimeInputBlur = _ref$onTimeInputBlur === void 0 ? noop : _ref$onTimeInputBlur,
|
|
2441
|
+
_ref$onBlur = _ref.onBlur,
|
|
2442
|
+
onBlur = _ref$onBlur === void 0 ? noop : _ref$onBlur;
|
|
2443
|
+
var _useState = useState(),
|
|
2444
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
2445
|
+
date = _useState2[0],
|
|
2446
|
+
setDate = _useState2[1];
|
|
2447
|
+
var _useState3 = useState(),
|
|
2448
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
2449
|
+
time = _useState4[0],
|
|
2450
|
+
setTime = _useState4[1];
|
|
2451
|
+
var _useState5 = useState(),
|
|
2452
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
2453
|
+
changedField = _useState6[0],
|
|
2454
|
+
setChangedField = _useState6[1];
|
|
2455
|
+
var timeRef = React__default.useRef(null);
|
|
2456
|
+
var defaultId = useId(id);
|
|
2457
|
+
var errorId = "error_".concat(defaultId);
|
|
2458
|
+
useEffect(function () {
|
|
2459
|
+
var inputValue = value || defaultValue;
|
|
2460
|
+
if (isPresent(inputValue) && dayjs(inputValue).isValid()) {
|
|
2461
|
+
var dateTime = dayjs.isDayjs(inputValue) ? inputValue : dayjs(inputValue);
|
|
2462
|
+
setDate(dateTime);
|
|
2463
|
+
setTime(dateTime);
|
|
2464
|
+
}
|
|
2465
|
+
}, [value, defaultValue]);
|
|
2466
|
+
useEffect(function () {
|
|
2467
|
+
if (isNotPresent(changedField)) return;
|
|
2468
|
+
onChange(getDateTime(date, time), changedField);
|
|
2469
|
+
setChangedField(); // reset to avoid unnecessary trigger on rerender
|
|
2470
|
+
}, [date, time, changedField]);
|
|
2471
|
+
var handleDateChange = function handleDateChange(newDate) {
|
|
2472
|
+
var _timeRef$current;
|
|
2473
|
+
(_timeRef$current = timeRef.current) === null || _timeRef$current === void 0 || (_timeRef$current = _timeRef$current.querySelector(".react-time-picker__inputGroup__hour")) === null || _timeRef$current === void 0 || _timeRef$current.focus();
|
|
2474
|
+
setDate(newDate);
|
|
2475
|
+
setTime(getAllowedTime(newDate, time, minDateTime, maxDateTime));
|
|
2476
|
+
setChangedField("date");
|
|
2477
|
+
};
|
|
2478
|
+
var handleTimeChange = function handleTimeChange(newTime) {
|
|
2479
|
+
setTime(newTime.isValid() ? newTime : null);
|
|
2480
|
+
if (newTime.isValid() && !date) setDate(newTime);
|
|
2481
|
+
setChangedField("time");
|
|
2482
|
+
};
|
|
2483
|
+
var handleTimeBlur = function handleTimeBlur() {
|
|
2484
|
+
var dateTime = getDateTime(date, time);
|
|
2485
|
+
onTimeInputBlur(dateTime);
|
|
2486
|
+
onBlur(dateTime);
|
|
2487
|
+
};
|
|
2488
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
2489
|
+
className: "neeto-ui-input__wrapper"
|
|
2490
|
+
}, label && /*#__PURE__*/React__default.createElement(Label, _objectSpread$7({
|
|
2491
|
+
required: required
|
|
2492
|
+
}, labelProps), label), /*#__PURE__*/React__default.createElement("div", {
|
|
2493
|
+
className: classnames("neeto-ui-date-time-input", className)
|
|
2494
|
+
}, /*#__PURE__*/React__default.createElement(DatePicker, _extends({
|
|
2495
|
+
dateFormat: dateFormat,
|
|
2496
|
+
dropdownClassName: dropdownClassName,
|
|
2497
|
+
nakedInput: nakedInput,
|
|
2498
|
+
popupClassName: popupClassName,
|
|
2499
|
+
size: size,
|
|
2500
|
+
error: !!error,
|
|
2501
|
+
maxDate: maxDateTime,
|
|
2502
|
+
minDate: minDateTime,
|
|
2503
|
+
picker: "date",
|
|
2504
|
+
showTime: false,
|
|
2505
|
+
type: "date",
|
|
2506
|
+
value: date,
|
|
2507
|
+
onChange: handleDateChange
|
|
2508
|
+
}, datePickerProps)), /*#__PURE__*/React__default.createElement(TimePickerInput, _extends(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({
|
|
2509
|
+
error: error,
|
|
2510
|
+
nakedInput: nakedInput,
|
|
2511
|
+
size: size
|
|
2512
|
+
}, "error", !!error), "maxTime", (date === null || date === void 0 ? void 0 : date.isSame(maxDateTime, "day")) && getTime(maxDateTime)), "minTime", (date === null || date === void 0 ? void 0 : date.isSame(minDateTime, "day")) && getTime(minDateTime)), "ref", timeRef), "value", time), "onBlur", handleTimeBlur), "onChange", handleTimeChange), timePickerProps))), !!error && /*#__PURE__*/React__default.createElement("p", {
|
|
2513
|
+
className: "neeto-ui-input__error",
|
|
2514
|
+
"data-cy": "".concat(hyphenize(label), "-input-error"),
|
|
2515
|
+
id: errorId
|
|
2516
|
+
}, error));
|
|
2517
|
+
};
|
|
2518
|
+
DateTimePicker.displayName = "DateTimePicker";
|
|
2519
|
+
var index = /*#__PURE__*/React__default.memo(DateTimePicker);
|
|
2520
|
+
|
|
2521
|
+
var _excluded$c = ["keyName", "className", "tooltipProps"];
|
|
2522
|
+
var Kbd = function Kbd(_ref) {
|
|
2523
|
+
var keyName = _ref.keyName,
|
|
2524
|
+
className = _ref.className,
|
|
2525
|
+
tooltipProps = _ref.tooltipProps,
|
|
2526
|
+
otherProps = _objectWithoutProperties(_ref, _excluded$c);
|
|
2527
|
+
return /*#__PURE__*/React__default.createElement(Tooltip, _extends({
|
|
2528
|
+
disabled: !tooltipProps
|
|
2529
|
+
}, tooltipProps), /*#__PURE__*/React__default.createElement("span", _extends({
|
|
2530
|
+
className: classnames(["neeto-ui-kbd", className])
|
|
2531
|
+
}, otherProps), keyName));
|
|
2532
|
+
};
|
|
2533
|
+
|
|
2534
|
+
var renderImage = function renderImage(image) {
|
|
2535
|
+
return typeof image === "string" ? /*#__PURE__*/React__default.createElement("img", {
|
|
2536
|
+
"data-cy": "no-data-image",
|
|
2537
|
+
src: image
|
|
2538
|
+
}) : image;
|
|
2539
|
+
};
|
|
2540
|
+
|
|
2541
|
+
var _excluded$b = ["image", "title", "description", "helpText", "className", "primaryButtonProps", "secondaryButtonProps", "buttonSeparatorText"];
|
|
2542
|
+
var NoData = function NoData(_ref) {
|
|
2543
|
+
var _ref$image = _ref.image,
|
|
2544
|
+
image = _ref$image === void 0 ? null : _ref$image,
|
|
2545
|
+
_ref$title = _ref.title,
|
|
2546
|
+
title = _ref$title === void 0 ? "" : _ref$title,
|
|
2547
|
+
_ref$description = _ref.description,
|
|
2548
|
+
description = _ref$description === void 0 ? "" : _ref$description,
|
|
2549
|
+
_ref$helpText = _ref.helpText,
|
|
2550
|
+
helpText = _ref$helpText === void 0 ? null : _ref$helpText,
|
|
2551
|
+
_ref$className = _ref.className,
|
|
2552
|
+
className = _ref$className === void 0 ? "" : _ref$className,
|
|
2553
|
+
_ref$primaryButtonPro = _ref.primaryButtonProps,
|
|
2554
|
+
primaryButtonProps = _ref$primaryButtonPro === void 0 ? {} : _ref$primaryButtonPro,
|
|
2555
|
+
_ref$secondaryButtonP = _ref.secondaryButtonProps,
|
|
2556
|
+
secondaryButtonProps = _ref$secondaryButtonP === void 0 ? {} : _ref$secondaryButtonP,
|
|
2557
|
+
_ref$buttonSeparatorT = _ref.buttonSeparatorText,
|
|
2558
|
+
buttonSeparatorText = _ref$buttonSeparatorT === void 0 ? "" : _ref$buttonSeparatorT,
|
|
2559
|
+
otherProps = _objectWithoutProperties(_ref, _excluded$b);
|
|
2560
|
+
var hasPrimaryButtonProps = !isEmpty(primaryButtonProps);
|
|
2561
|
+
var hasSecondaryButtonProps = !isEmpty(secondaryButtonProps);
|
|
2562
|
+
var hasButtonSeparatorText = !isEmpty(buttonSeparatorText);
|
|
2563
|
+
var showButtonSeparator = hasButtonSeparatorText && hasPrimaryButtonProps && hasSecondaryButtonProps;
|
|
2564
|
+
return /*#__PURE__*/React__default.createElement("div", _extends({
|
|
2565
|
+
className: classnames("neeto-ui-no-data", [className]),
|
|
2566
|
+
"data-cy": "no-data-container"
|
|
2567
|
+
}, otherProps), image ? /*#__PURE__*/React__default.createElement("div", {
|
|
2568
|
+
className: "neeto-ui-no-data__image"
|
|
2569
|
+
}, renderImage(image)) : null, title && /*#__PURE__*/React__default.createElement(Typography, {
|
|
2570
|
+
className: "neeto-ui-text-center",
|
|
2571
|
+
"data-cy": "no-data-title",
|
|
2572
|
+
lineHeight: "none",
|
|
2573
|
+
style: "h3"
|
|
2574
|
+
}, title), description && /*#__PURE__*/React__default.createElement(Typography, {
|
|
2575
|
+
className: "neeto-ui-text-center neeto-ui-no-data__description",
|
|
2576
|
+
"data-cy": "no-data-description",
|
|
2577
|
+
lineHeight: "normal",
|
|
2578
|
+
style: "body2"
|
|
2579
|
+
}, description), helpText && /*#__PURE__*/React__default.createElement(Typography, {
|
|
2580
|
+
className: "neeto-ui-text-center neeto-ui-no-data__help-text",
|
|
2581
|
+
"data-cy": "no-data-help-text",
|
|
2582
|
+
lineHeight: "normal",
|
|
2583
|
+
style: "body2"
|
|
2584
|
+
}, helpText), (hasPrimaryButtonProps || hasSecondaryButtonProps) && /*#__PURE__*/React__default.createElement("div", {
|
|
2585
|
+
className: "neeto-ui-no-data__action-block"
|
|
2586
|
+
}, hasPrimaryButtonProps && /*#__PURE__*/React__default.createElement(Button, _extends({
|
|
2587
|
+
"data-cy": "no-data-primary-button"
|
|
2588
|
+
}, primaryButtonProps)), showButtonSeparator && /*#__PURE__*/React__default.createElement(Typography, {
|
|
2589
|
+
lineHeight: "normal",
|
|
2590
|
+
style: "body2"
|
|
2591
|
+
}, buttonSeparatorText), hasSecondaryButtonProps && /*#__PURE__*/React__default.createElement(Button, _extends({
|
|
2592
|
+
"data-cy": "no-data-secondary-button",
|
|
2593
|
+
style: "secondary"
|
|
2594
|
+
}, secondaryButtonProps))));
|
|
2595
|
+
};
|
|
2596
|
+
|
|
2597
|
+
var DOTS = "...";
|
|
2598
|
+
|
|
2599
|
+
var usePaginationQueryParams = function usePaginationQueryParams() {
|
|
2600
|
+
var queryParams = useQueryParams();
|
|
2601
|
+
var history = useHistory();
|
|
2602
|
+
var updatePageInQueryParam = function updatePageInQueryParam(page) {
|
|
2603
|
+
var params = {
|
|
2604
|
+
page: page
|
|
2605
|
+
};
|
|
2606
|
+
var pathname = window.location.pathname;
|
|
2607
|
+
history.push(buildUrl(pathname, mergeLeft(params, queryParams)));
|
|
2608
|
+
};
|
|
2609
|
+
return {
|
|
2610
|
+
updatePageInQueryParam: updatePageInQueryParam
|
|
2611
|
+
};
|
|
2612
|
+
};
|
|
2613
|
+
|
|
2614
|
+
var range = function range(start, end) {
|
|
2615
|
+
var length = end - start + 1;
|
|
2616
|
+
return Array.from({
|
|
2617
|
+
length: length
|
|
2618
|
+
}, function (_, index) {
|
|
2619
|
+
return index + start;
|
|
2620
|
+
});
|
|
2621
|
+
};
|
|
2622
|
+
var usePagination = function usePagination(_ref) {
|
|
2623
|
+
var count = _ref.count,
|
|
2624
|
+
pageSize = _ref.pageSize,
|
|
2625
|
+
_ref$siblingCount = _ref.siblingCount,
|
|
2626
|
+
siblingCount = _ref$siblingCount === void 0 ? 1 : _ref$siblingCount,
|
|
2627
|
+
pageNo = _ref.pageNo;
|
|
2628
|
+
var paginationRange = useMemo(function () {
|
|
2629
|
+
var totalPageCount = Math.ceil(count / pageSize);
|
|
2630
|
+
|
|
2631
|
+
// Pages count is determined as siblingCount + firstPage + lastPage + pageNo + 2*DOTS
|
|
2632
|
+
var totalPageNumbers = siblingCount + 5;
|
|
2633
|
+
|
|
2634
|
+
// If the number of pages is less than the page numbers we want to show in our
|
|
2635
|
+
// paginationComponent, we return the range [1..totalPageCount]
|
|
2636
|
+
if (totalPageNumbers >= totalPageCount) {
|
|
2637
|
+
return range(1, totalPageCount);
|
|
2638
|
+
}
|
|
2639
|
+
|
|
2640
|
+
// Calculate left and right sibling index and make sure they are within range 1 and totalPageCount
|
|
2641
|
+
var leftSiblingIndex = Math.max(pageNo - siblingCount, 1);
|
|
2642
|
+
var rightSiblingIndex = Math.min(pageNo + siblingCount, totalPageCount);
|
|
2643
|
+
|
|
2644
|
+
// We do not show dots just when there is just one page number to be inserted between the extremes of sibling and the page limits i.e 1 and totalPageCount. Hence we are using leftSiblingIndex > 2 and rightSiblingIndex < totalPageCount - 2
|
|
2645
|
+
var shouldShowLeftDots = leftSiblingIndex > 2;
|
|
2646
|
+
var shouldShowRightDots = rightSiblingIndex < totalPageCount - 2;
|
|
2647
|
+
var firstPageIndex = 1;
|
|
2648
|
+
var lastPageIndex = totalPageCount;
|
|
2649
|
+
|
|
2650
|
+
// Case 2: No left dots to show, but rights dots to be shown
|
|
2651
|
+
if (!shouldShowLeftDots && shouldShowRightDots) {
|
|
2652
|
+
var leftItemCount = 3 + 2 * siblingCount;
|
|
2653
|
+
var leftRange = range(1, leftItemCount);
|
|
2654
|
+
return [].concat(_toConsumableArray(leftRange), [DOTS, totalPageCount]);
|
|
2655
|
+
}
|
|
2656
|
+
|
|
2657
|
+
// Case 3: No right dots to show, but left dots to be shown
|
|
2658
|
+
if (shouldShowLeftDots && !shouldShowRightDots) {
|
|
2659
|
+
var rightItemCount = 3 + 2 * siblingCount;
|
|
2660
|
+
var rightRange = range(totalPageCount - rightItemCount + 1, totalPageCount);
|
|
2661
|
+
return [firstPageIndex, DOTS].concat(_toConsumableArray(rightRange));
|
|
2662
|
+
}
|
|
2663
|
+
|
|
2664
|
+
// Case 4: Both left and right dots to be shown
|
|
2665
|
+
if (shouldShowLeftDots && shouldShowRightDots) {
|
|
2666
|
+
var middleRange = range(leftSiblingIndex, rightSiblingIndex);
|
|
2667
|
+
return [firstPageIndex, DOTS].concat(_toConsumableArray(middleRange), [DOTS, lastPageIndex]);
|
|
2668
|
+
}
|
|
2669
|
+
return undefined;
|
|
2670
|
+
}, [count, pageSize, siblingCount, pageNo]);
|
|
2671
|
+
return paginationRange;
|
|
2672
|
+
};
|
|
2673
|
+
|
|
2674
|
+
var Pagination = function Pagination(_ref) {
|
|
2675
|
+
var _ref$count = _ref.count,
|
|
2676
|
+
count = _ref$count === void 0 ? 0 : _ref$count,
|
|
2677
|
+
pageNo = _ref.pageNo,
|
|
2678
|
+
navigate = _ref.navigate,
|
|
2679
|
+
pageSize = _ref.pageSize,
|
|
2680
|
+
_ref$siblingCount = _ref.siblingCount,
|
|
2681
|
+
siblingCount = _ref$siblingCount === void 0 ? 1 : _ref$siblingCount,
|
|
2682
|
+
_ref$className = _ref.className,
|
|
2683
|
+
className = _ref$className === void 0 ? "" : _ref$className;
|
|
2684
|
+
var paginationRange = usePagination({
|
|
2685
|
+
pageNo: pageNo,
|
|
2686
|
+
count: count,
|
|
2687
|
+
siblingCount: siblingCount,
|
|
2688
|
+
pageSize: pageSize
|
|
2689
|
+
});
|
|
2690
|
+
var _usePaginationQueryPa = usePaginationQueryParams(),
|
|
2691
|
+
updatePageInQueryParam = _usePaginationQueryPa.updatePageInQueryParam;
|
|
2692
|
+
if (!navigate) navigate = updatePageInQueryParam;
|
|
2693
|
+
if (pageNo === 0 || paginationRange.length < 2) {
|
|
2694
|
+
return null;
|
|
2695
|
+
}
|
|
2696
|
+
var onNext = function onNext() {
|
|
2697
|
+
if (!isLastPage) navigate(pageNo + 1);
|
|
2698
|
+
};
|
|
2699
|
+
var onPrevious = function onPrevious() {
|
|
2700
|
+
if (!isFirstPage) navigate(pageNo - 1);
|
|
2701
|
+
};
|
|
2702
|
+
var lastPage = paginationRange[paginationRange.length - 1];
|
|
2703
|
+
var isFirstPage = pageNo === 1;
|
|
2704
|
+
var isLastPage = pageNo === lastPage;
|
|
2705
|
+
return /*#__PURE__*/React__default.createElement("nav", {
|
|
2706
|
+
"aria-label": "Pagination Navigation",
|
|
2707
|
+
role: "navigation"
|
|
2708
|
+
}, /*#__PURE__*/React__default.createElement("ul", {
|
|
2709
|
+
className: classnames(["neeto-ui-pagination__wrapper", className])
|
|
2710
|
+
}, /*#__PURE__*/React__default.createElement("li", {
|
|
2711
|
+
"data-testid": "left-navigate-button",
|
|
2712
|
+
tabIndex: 0,
|
|
2713
|
+
className: classnames({
|
|
2714
|
+
"neeto-ui-pagination__item": true,
|
|
2715
|
+
"neeto-ui-pagination__item--navigate": true,
|
|
2716
|
+
disabled: isFirstPage
|
|
2717
|
+
}),
|
|
2718
|
+
onClick: onPrevious
|
|
2719
|
+
}, /*#__PURE__*/React__default.createElement("a", null, /*#__PURE__*/React__default.createElement(Left, {
|
|
2720
|
+
size: 20
|
|
2721
|
+
}))), paginationRange.map(function (pageNumber, index) {
|
|
2722
|
+
var isActive = pageNumber === pageNo;
|
|
2723
|
+
if (pageNumber === DOTS) {
|
|
2724
|
+
return /*#__PURE__*/React__default.createElement("li", {
|
|
2725
|
+
className: "neeto-ui-pagination__item neeto-ui-pagination__item--dots",
|
|
2726
|
+
"data-testid": "dots",
|
|
2727
|
+
key: index
|
|
2728
|
+
}, "\u2026");
|
|
2729
|
+
}
|
|
2730
|
+
return /*#__PURE__*/React__default.createElement("li", {
|
|
2731
|
+
"aria-current": isActive && true,
|
|
2732
|
+
key: index,
|
|
2733
|
+
tabIndex: 0,
|
|
2734
|
+
"aria-label": isActive ? "Current Page, Page ".concat(pageNumber) : "Goto Page ".concat(pageNumber),
|
|
2735
|
+
className: classnames("neeto-ui-pagination__item", {
|
|
2736
|
+
active: isActive
|
|
2737
|
+
}),
|
|
2738
|
+
onClick: function onClick() {
|
|
2739
|
+
return navigate(pageNumber);
|
|
2740
|
+
}
|
|
2741
|
+
}, /*#__PURE__*/React__default.createElement("a", null, pageNumber));
|
|
2742
|
+
}), /*#__PURE__*/React__default.createElement("li", {
|
|
2743
|
+
"data-testid": "right-navigate-button",
|
|
2744
|
+
tabIndex: 0,
|
|
2745
|
+
className: classnames({
|
|
2746
|
+
"neeto-ui-pagination__item": true,
|
|
2747
|
+
"neeto-ui-pagination__item--navigate": true,
|
|
2748
|
+
disabled: isLastPage
|
|
2749
|
+
}),
|
|
2750
|
+
onClick: onNext
|
|
2751
|
+
}, /*#__PURE__*/React__default.createElement("a", null, /*#__PURE__*/React__default.createElement(Right, {
|
|
2752
|
+
size: 20
|
|
2753
|
+
})))));
|
|
2754
|
+
};
|
|
2755
|
+
|
|
2756
|
+
var Body = function Body(_ref) {
|
|
2757
|
+
var children = _ref.children,
|
|
2758
|
+
className = _ref.className,
|
|
2759
|
+
_ref$hasFooter = _ref.hasFooter,
|
|
2760
|
+
hasFooter = _ref$hasFooter === void 0 ? true : _ref$hasFooter;
|
|
2761
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
2762
|
+
"data-cy": "pane-body",
|
|
2763
|
+
className: classnames("neeto-ui-pane__body neeto-ui-flex neeto-ui-flex-col neeto-ui-items-start neeto-ui-justify-start", _defineProperty({
|
|
2764
|
+
"neeto-ui-pane__body--has-footer": hasFooter
|
|
2765
|
+
}, className, className))
|
|
2766
|
+
}, children);
|
|
2767
|
+
};
|
|
2768
|
+
|
|
2769
|
+
var DEFAULT_PANE_HEADER_HEIGHT = 78;
|
|
2770
|
+
|
|
2771
|
+
var Footer = function Footer(_ref) {
|
|
2772
|
+
var children = _ref.children,
|
|
2773
|
+
className = _ref.className;
|
|
2774
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
2775
|
+
className: classnames("neeto-ui-pane__footer neeto-ui-flex neeto-ui-items-center", className)
|
|
2776
|
+
}, children);
|
|
2777
|
+
};
|
|
2778
|
+
|
|
2779
|
+
var Header = function Header(_ref) {
|
|
2780
|
+
var children = _ref.children,
|
|
2781
|
+
className = _ref.className;
|
|
2782
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
2783
|
+
className: classnames("neeto-ui-pane__header", className),
|
|
2784
|
+
"data-cy": "pane-header"
|
|
2785
|
+
}, children);
|
|
2786
|
+
};
|
|
2787
|
+
|
|
2788
|
+
var getHeaderHeight = function getHeaderHeight(paneWrapper) {
|
|
2789
|
+
var header = paneWrapper.current.querySelector(".neeto-ui-pane__header");
|
|
2790
|
+
return header ? header.offsetHeight : DEFAULT_PANE_HEADER_HEIGHT;
|
|
2791
|
+
};
|
|
2792
|
+
|
|
2793
|
+
var _excluded$a = ["size", "isOpen", "onClose", "children", "className", "closeOnEsc", "closeButton", "backdropClassName", "closeOnOutsideClick", "initialFocusRef", "finalFocusRef"];
|
|
2794
|
+
var SIZES$1 = {
|
|
2795
|
+
small: "small",
|
|
2796
|
+
large: "large"
|
|
2797
|
+
};
|
|
2798
|
+
var Pane = function Pane(_ref) {
|
|
2799
|
+
var _ref$size = _ref.size,
|
|
2800
|
+
size = _ref$size === void 0 ? SIZES$1.small : _ref$size,
|
|
2801
|
+
_ref$isOpen = _ref.isOpen,
|
|
2802
|
+
isOpen = _ref$isOpen === void 0 ? false : _ref$isOpen,
|
|
2803
|
+
_ref$onClose = _ref.onClose,
|
|
2804
|
+
onClose = _ref$onClose === void 0 ? function () {} : _ref$onClose,
|
|
2805
|
+
children = _ref.children,
|
|
2806
|
+
_ref$className = _ref.className,
|
|
2807
|
+
className = _ref$className === void 0 ? "" : _ref$className,
|
|
2808
|
+
_ref$closeOnEsc = _ref.closeOnEsc,
|
|
2809
|
+
closeOnEsc = _ref$closeOnEsc === void 0 ? true : _ref$closeOnEsc,
|
|
2810
|
+
_ref$closeButton = _ref.closeButton,
|
|
2811
|
+
closeButton = _ref$closeButton === void 0 ? true : _ref$closeButton,
|
|
2812
|
+
_ref$backdropClassNam = _ref.backdropClassName,
|
|
2813
|
+
backdropClassName = _ref$backdropClassNam === void 0 ? "" : _ref$backdropClassNam,
|
|
2814
|
+
_ref$closeOnOutsideCl = _ref.closeOnOutsideClick,
|
|
2815
|
+
closeOnOutsideClick = _ref$closeOnOutsideCl === void 0 ? true : _ref$closeOnOutsideCl,
|
|
2816
|
+
initialFocusRef = _ref.initialFocusRef,
|
|
2817
|
+
finalFocusRef = _ref.finalFocusRef,
|
|
2818
|
+
otherProps = _objectWithoutProperties(_ref, _excluded$a);
|
|
2819
|
+
var _useState = useState(false),
|
|
2820
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
2821
|
+
hasTransitionCompleted = _useState2[0],
|
|
2822
|
+
setHasTransitionCompleted = _useState2[1];
|
|
2823
|
+
var paneWrapper = useRef(null);
|
|
2824
|
+
var backdropRef = useRef(null);
|
|
2825
|
+
useOverlayManager(paneWrapper, isOpen);
|
|
2826
|
+
var _useOverlay = useOverlay({
|
|
2827
|
+
overlayWrapper: paneWrapper,
|
|
2828
|
+
backdropRef: backdropRef,
|
|
2829
|
+
closeOnOutsideClick: closeOnOutsideClick,
|
|
2830
|
+
closeOnEsc: closeOnEsc,
|
|
2831
|
+
onClose: onClose,
|
|
2832
|
+
isOpen: isOpen,
|
|
2833
|
+
initialFocusRef: initialFocusRef,
|
|
2834
|
+
finalFocusRef: finalFocusRef,
|
|
2835
|
+
hasTransitionCompleted: hasTransitionCompleted
|
|
2836
|
+
}),
|
|
2837
|
+
handleOverlayClose = _useOverlay.handleOverlayClose,
|
|
2838
|
+
setFocusField = _useOverlay.setFocusField;
|
|
2839
|
+
useEffect(function () {
|
|
2840
|
+
if (hasTransitionCompleted) {
|
|
2841
|
+
var headerHeight = getHeaderHeight(paneWrapper);
|
|
2842
|
+
if (headerHeight > DEFAULT_PANE_HEADER_HEIGHT) {
|
|
2843
|
+
paneWrapper.current.style.setProperty("--neeto-ui-pane-header-height", "".concat(headerHeight, "px"));
|
|
2844
|
+
}
|
|
2845
|
+
}
|
|
2846
|
+
}, [hasTransitionCompleted]);
|
|
2847
|
+
return /*#__PURE__*/React__default.createElement(Portal, {
|
|
2848
|
+
rootId: "neeto-ui-portal"
|
|
2849
|
+
}, /*#__PURE__*/React__default.createElement(CSSTransition, {
|
|
2850
|
+
unmountOnExit: true,
|
|
2851
|
+
appear: isOpen,
|
|
2852
|
+
classNames: "neeto-ui-pane",
|
|
2853
|
+
"in": isOpen,
|
|
2854
|
+
timeout: 230,
|
|
2855
|
+
onEntered: function onEntered() {
|
|
2856
|
+
return setHasTransitionCompleted(true);
|
|
2857
|
+
},
|
|
2858
|
+
onExited: function onExited() {
|
|
2859
|
+
return setHasTransitionCompleted(false);
|
|
2860
|
+
}
|
|
2861
|
+
}, /*#__PURE__*/React__default.createElement(Backdrop, {
|
|
2862
|
+
"data-testid": "backdrop",
|
|
2863
|
+
key: "pane-backdrop",
|
|
2864
|
+
ref: backdropRef,
|
|
2865
|
+
className: classnames("neeto-ui-pane__backdrop neeto-ui-flex neeto-ui-justify-end", backdropClassName)
|
|
2866
|
+
}, /*#__PURE__*/React__default.createElement("div", _extends({
|
|
2867
|
+
"data-cy": "pane-wrapper",
|
|
2868
|
+
key: "pane-wrapper",
|
|
2869
|
+
ref: paneWrapper,
|
|
2870
|
+
className: classnames("neeto-ui-pane__wrapper", _defineProperty({
|
|
2871
|
+
"neeto-ui-pane__wrapper--small": size === SIZES$1.small,
|
|
2872
|
+
"neeto-ui-pane__wrapper--large": size === SIZES$1.large
|
|
2873
|
+
}, className, className))
|
|
2874
|
+
}, otherProps), closeButton && /*#__PURE__*/React__default.createElement(Button, {
|
|
2875
|
+
"aria-label": "Close",
|
|
2876
|
+
className: "neeto-ui-pane__close",
|
|
2877
|
+
"data-cy": "pane-close-button",
|
|
2878
|
+
"data-testid": "close-button",
|
|
2879
|
+
icon: Close,
|
|
2880
|
+
size: "small",
|
|
2881
|
+
style: "text",
|
|
2882
|
+
onClick: handleOverlayClose
|
|
2883
|
+
}), hasTransitionCompleted && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, typeof children === "function" ? children({
|
|
2884
|
+
setFocusField: setFocusField
|
|
2885
|
+
}) : children)))));
|
|
2886
|
+
};
|
|
2887
|
+
Pane.Header = Header;
|
|
2888
|
+
Pane.Body = Body;
|
|
2889
|
+
Pane.Footer = Footer;
|
|
2890
|
+
|
|
2891
|
+
var Title = function Title(_ref) {
|
|
2892
|
+
var className = _ref.className,
|
|
2893
|
+
children = _ref.children;
|
|
2894
|
+
return /*#__PURE__*/React__default.createElement(Typography, {
|
|
2895
|
+
className: classnames("neeto-ui-mb-1", className),
|
|
2896
|
+
"data-testid": "popover-title",
|
|
2897
|
+
lineHeight: "snug",
|
|
2898
|
+
style: "h5",
|
|
2899
|
+
weight: "semibold"
|
|
2900
|
+
}, children);
|
|
2901
|
+
};
|
|
2902
|
+
|
|
2903
|
+
var _excluded$9 = ["children", "className", "theme"];
|
|
2904
|
+
var Popover = function Popover(_ref) {
|
|
2905
|
+
var children = _ref.children,
|
|
2906
|
+
_ref$className = _ref.className,
|
|
2907
|
+
className = _ref$className === void 0 ? "" : _ref$className,
|
|
2908
|
+
_ref$theme = _ref.theme,
|
|
2909
|
+
theme = _ref$theme === void 0 ? "light" : _ref$theme,
|
|
2910
|
+
otherProps = _objectWithoutProperties(_ref, _excluded$9);
|
|
2911
|
+
return /*#__PURE__*/React__default.createElement(Tooltip, _extends({
|
|
2912
|
+
theme: theme,
|
|
2913
|
+
arrow: true,
|
|
2914
|
+
interactive: true,
|
|
2915
|
+
className: classnames("neeto-ui-popover", className),
|
|
2916
|
+
content: children
|
|
2917
|
+
}, otherProps));
|
|
2918
|
+
};
|
|
2919
|
+
Popover.Title = Title;
|
|
2920
|
+
|
|
2921
|
+
var Stepper = function Stepper(_ref) {
|
|
2922
|
+
var steps = _ref.steps,
|
|
2923
|
+
activeIndex = _ref.activeIndex,
|
|
2924
|
+
setActiveIndex = _ref.setActiveIndex;
|
|
2925
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
2926
|
+
className: "neeto-ui-stepper__wrapper"
|
|
2927
|
+
}, steps.map(function (_ref2, index) {
|
|
2928
|
+
var id = _ref2.id,
|
|
2929
|
+
label = _ref2.label;
|
|
2930
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
2931
|
+
"data-testid": "stepper-item-".concat(id),
|
|
2932
|
+
key: id,
|
|
2933
|
+
className: classnames("neeto-ui-stepper-item__wrapper", {
|
|
2934
|
+
"neeto-ui-stepper-item__wrapper--active": index === activeIndex,
|
|
2935
|
+
"neeto-ui-stepper-item__wrapper--done": index < activeIndex
|
|
2936
|
+
})
|
|
2937
|
+
}, /*#__PURE__*/React__default.createElement("button", {
|
|
2938
|
+
className: "neeto-ui-stepper-item",
|
|
2939
|
+
onClick: function onClick() {
|
|
2940
|
+
return setActiveIndex(index);
|
|
2941
|
+
}
|
|
2942
|
+
}, /*#__PURE__*/React__default.createElement("span", {
|
|
2943
|
+
className: "neeto-ui-stepper-item__stage"
|
|
2944
|
+
}, /*#__PURE__*/React__default.createElement("span", null, id)), /*#__PURE__*/React__default.createElement("span", {
|
|
2945
|
+
className: "neeto-ui-stepper-item__label",
|
|
2946
|
+
"data-text": label
|
|
2947
|
+
}, label)));
|
|
2948
|
+
}));
|
|
2949
|
+
};
|
|
2950
|
+
|
|
2951
|
+
var _excluded$8 = ["active", "className", "children", "icon", "onClick", "activeClassName"];
|
|
2952
|
+
function ownKeys$6(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2953
|
+
function _objectSpread$6(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$6(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$6(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
2954
|
+
var Item = function Item(_ref) {
|
|
2955
|
+
var active = _ref.active,
|
|
2956
|
+
_ref$className = _ref.className,
|
|
2957
|
+
className = _ref$className === void 0 ? "" : _ref$className,
|
|
2958
|
+
children = _ref.children,
|
|
2959
|
+
_ref$icon = _ref.icon,
|
|
2960
|
+
icon = _ref$icon === void 0 ? null : _ref$icon,
|
|
2961
|
+
_ref$onClick = _ref.onClick,
|
|
2962
|
+
onClick = _ref$onClick === void 0 ? function () {} : _ref$onClick,
|
|
2963
|
+
_ref$activeClassName = _ref.activeClassName,
|
|
2964
|
+
activeClassName = _ref$activeClassName === void 0 ? "" : _ref$activeClassName,
|
|
2965
|
+
otherProps = _objectWithoutProperties(_ref, _excluded$8);
|
|
2966
|
+
var Icon = typeof icon === "string" ? function () {
|
|
2967
|
+
return /*#__PURE__*/React__default.createElement("i", {
|
|
2968
|
+
className: icon,
|
|
2969
|
+
"data-cy": "tab-item-icon",
|
|
2970
|
+
"data-testid": "tab-icon"
|
|
2971
|
+
});
|
|
2972
|
+
} : icon || React__default.Fragment;
|
|
2973
|
+
var Parent = activeClassName ? NavLink : "button";
|
|
2974
|
+
var buttonAttributes = activeClassName ? {} : {
|
|
2975
|
+
type: "button"
|
|
2976
|
+
};
|
|
2977
|
+
return /*#__PURE__*/React__default.createElement(Parent, _extends({
|
|
2978
|
+
"data-cy": "tab-item",
|
|
2979
|
+
className: classnames(["neeto-ui-tab neeto-ui-flex neeto-ui-items-center neeto-ui-justify-center neeto-ui-select-none", className], {
|
|
2980
|
+
active: active
|
|
2981
|
+
}),
|
|
2982
|
+
onClick: onClick
|
|
2983
|
+
}, _objectSpread$6(_objectSpread$6({}, otherProps), buttonAttributes)), icon && /*#__PURE__*/React__default.createElement(Icon, {
|
|
2984
|
+
className: "neeto-ui-tab__icon"
|
|
2985
|
+
}), children);
|
|
2986
|
+
};
|
|
2987
|
+
Item.displayName = "Tab.Item";
|
|
2988
|
+
|
|
2989
|
+
var _excluded$7 = ["size", "noUnderline", "children", "className"];
|
|
2990
|
+
var SIZES = {
|
|
2991
|
+
large: "large",
|
|
2992
|
+
small: "small"
|
|
2993
|
+
};
|
|
2994
|
+
var Tab = function Tab(_ref) {
|
|
2995
|
+
var _ref$size = _ref.size,
|
|
2996
|
+
size = _ref$size === void 0 ? SIZES.small : _ref$size,
|
|
2997
|
+
_ref$noUnderline = _ref.noUnderline,
|
|
2998
|
+
noUnderline = _ref$noUnderline === void 0 ? false : _ref$noUnderline,
|
|
2999
|
+
children = _ref.children,
|
|
3000
|
+
_ref$className = _ref.className,
|
|
3001
|
+
className = _ref$className === void 0 ? "" : _ref$className,
|
|
3002
|
+
otherProps = _objectWithoutProperties(_ref, _excluded$7);
|
|
3003
|
+
return /*#__PURE__*/React__default.createElement("div", _extends({
|
|
3004
|
+
"data-cy": "tab-container",
|
|
3005
|
+
className: classnames({
|
|
3006
|
+
"neeto-ui-tab__wrapper neeto-ui-flex": true,
|
|
3007
|
+
"neeto-ui-tab__wrapper--size-large": size === SIZES.large,
|
|
3008
|
+
"neeto-ui-tab__wrapper--size-small": size === SIZES.small,
|
|
3009
|
+
"neeto-ui-tab__wrapper--underline-none": noUnderline
|
|
3010
|
+
}, [className])
|
|
3011
|
+
}, otherProps), children);
|
|
3012
|
+
};
|
|
3013
|
+
Tab.Item = Item;
|
|
3014
|
+
|
|
3015
|
+
var SelectAllRowsCallout = function SelectAllRowsCallout(_ref) {
|
|
3016
|
+
var calloutProps = _ref.calloutProps,
|
|
3017
|
+
onBulkSelectAllRows = _ref.onBulkSelectAllRows,
|
|
3018
|
+
selectAllRowButtonLabel = _ref.selectAllRowButtonLabel,
|
|
3019
|
+
selectAllRowMessage = _ref.selectAllRowMessage;
|
|
3020
|
+
return /*#__PURE__*/React__default.createElement(Callout, _extends({
|
|
3021
|
+
className: "my-2"
|
|
3022
|
+
}, calloutProps, {
|
|
3023
|
+
"data-testid": "select-all-rows-callout"
|
|
3024
|
+
}), /*#__PURE__*/React__default.createElement("div", {
|
|
3025
|
+
className: "flex space-x-3"
|
|
3026
|
+
}, /*#__PURE__*/React__default.createElement(Typography, {
|
|
3027
|
+
style: "body2"
|
|
3028
|
+
}, selectAllRowMessage), /*#__PURE__*/React__default.createElement(Button, {
|
|
3029
|
+
"data-testid": "select-all-rows-button",
|
|
3030
|
+
label: selectAllRowButtonLabel,
|
|
3031
|
+
style: "link",
|
|
3032
|
+
onClick: onBulkSelectAllRows
|
|
3033
|
+
})));
|
|
3034
|
+
};
|
|
3035
|
+
|
|
3036
|
+
var URL_SORT_ORDERS = {
|
|
3037
|
+
ascend: "asc",
|
|
3038
|
+
descend: "desc"
|
|
3039
|
+
};
|
|
3040
|
+
var TABLE_SORT_ORDERS = {
|
|
3041
|
+
asc: "ascend",
|
|
3042
|
+
desc: "descend"
|
|
3043
|
+
};
|
|
3044
|
+
var COLUMN_ADD_DIRECTION = {
|
|
3045
|
+
left: 0,
|
|
3046
|
+
right: 1
|
|
3047
|
+
};
|
|
3048
|
+
|
|
3049
|
+
var useReorderColumns = function useReorderColumns(_ref) {
|
|
3050
|
+
var isEnabled = _ref.isEnabled,
|
|
3051
|
+
columns = _ref.columns,
|
|
3052
|
+
setColumns = _ref.setColumns,
|
|
3053
|
+
onColumnUpdate = _ref.onColumnUpdate,
|
|
3054
|
+
rowSelection = _ref.rowSelection;
|
|
3055
|
+
if (!isEnabled) return {
|
|
3056
|
+
dragProps: {},
|
|
3057
|
+
columns: columns
|
|
3058
|
+
};
|
|
3059
|
+
var isColumnFixed = function isColumnFixed(column) {
|
|
3060
|
+
return !!column.fixed;
|
|
3061
|
+
};
|
|
3062
|
+
var dragProps = {
|
|
3063
|
+
onDragEnd: function onDragEnd(fromIndex, toIndex) {
|
|
3064
|
+
var from = fromIndex;
|
|
3065
|
+
var to = toIndex;
|
|
3066
|
+
if (rowSelection) {
|
|
3067
|
+
from = fromIndex - 1;
|
|
3068
|
+
to = toIndex - 1;
|
|
3069
|
+
}
|
|
3070
|
+
if (isColumnFixed(columns[from]) || isColumnFixed(columns[to])) return;
|
|
3071
|
+
var newColumns = move(from, to, columns);
|
|
3072
|
+
setColumns(newColumns);
|
|
3073
|
+
onColumnUpdate(newColumns);
|
|
3074
|
+
},
|
|
3075
|
+
nodeSelector: "th",
|
|
3076
|
+
handleSelector: ".drag-handler",
|
|
3077
|
+
ignoreSelector: ".react-resizable-handle"
|
|
3078
|
+
};
|
|
3079
|
+
return {
|
|
3080
|
+
dragProps: dragProps,
|
|
3081
|
+
columns: columns
|
|
3082
|
+
};
|
|
3083
|
+
};
|
|
3084
|
+
|
|
3085
|
+
var SortIcon = function SortIcon(_ref) {
|
|
3086
|
+
var sortOrder = _ref.sortOrder;
|
|
3087
|
+
if (sortOrder === TABLE_SORT_ORDERS.asc || sortOrder === URL_SORT_ORDERS.ascend) {
|
|
3088
|
+
return /*#__PURE__*/React__default.createElement(UpArrow, {
|
|
3089
|
+
size: 14
|
|
3090
|
+
});
|
|
3091
|
+
}
|
|
3092
|
+
if (sortOrder === TABLE_SORT_ORDERS.desc || sortOrder === URL_SORT_ORDERS.descend) {
|
|
3093
|
+
return /*#__PURE__*/React__default.createElement(DownArrow, {
|
|
3094
|
+
size: 14
|
|
3095
|
+
});
|
|
3096
|
+
}
|
|
3097
|
+
return null;
|
|
3098
|
+
};
|
|
3099
|
+
|
|
3100
|
+
function ownKeys$5(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
3101
|
+
function _objectSpread$5(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$5(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$5(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
3102
|
+
var useResizableColumns = function useResizableColumns(_ref) {
|
|
3103
|
+
var columns = _ref.columns,
|
|
3104
|
+
setColumns = _ref.setColumns,
|
|
3105
|
+
isEnabled = _ref.isEnabled,
|
|
3106
|
+
isAddEnabled = _ref.isAddEnabled,
|
|
3107
|
+
onColumnAdd = _ref.onColumnAdd,
|
|
3108
|
+
onColumnUpdate = _ref.onColumnUpdate,
|
|
3109
|
+
onColumnDelete = _ref.onColumnDelete,
|
|
3110
|
+
handleSort = _ref.handleSort,
|
|
3111
|
+
sortedInfo = _ref.sortedInfo,
|
|
3112
|
+
onColumnHide = _ref.onColumnHide,
|
|
3113
|
+
onMoreActionClick = _ref.onMoreActionClick,
|
|
3114
|
+
tableOnChangeProps = _ref.tableOnChangeProps;
|
|
3115
|
+
var handleResize = function handleResize(index) {
|
|
3116
|
+
return function (_, _ref2) {
|
|
3117
|
+
var size = _ref2.size;
|
|
3118
|
+
var nextColumns = _toConsumableArray(columns);
|
|
3119
|
+
nextColumns[index] = _objectSpread$5(_objectSpread$5({}, nextColumns[index]), {}, {
|
|
3120
|
+
width: size.width
|
|
3121
|
+
});
|
|
3122
|
+
setColumns(nextColumns);
|
|
3123
|
+
};
|
|
3124
|
+
};
|
|
3125
|
+
var computedColumnsData = useMemo(function () {
|
|
3126
|
+
return columns.map(function (col, index) {
|
|
3127
|
+
var modifiedColumn = _objectSpread$5(_objectSpread$5({}, col), {}, {
|
|
3128
|
+
onHeaderCell: function onHeaderCell(column) {
|
|
3129
|
+
return {
|
|
3130
|
+
width: column.width,
|
|
3131
|
+
onResize: isEnabled ? handleResize(index) : noop$1,
|
|
3132
|
+
onResizeStop: function onResizeStop() {
|
|
3133
|
+
return isEnabled ? onColumnUpdate(columns) : noop$1;
|
|
3134
|
+
},
|
|
3135
|
+
isSortable: isPresent(col.sorter),
|
|
3136
|
+
onSort: handleSort,
|
|
3137
|
+
sortedInfo: sortedInfo,
|
|
3138
|
+
onColumnHide: onColumnHide,
|
|
3139
|
+
onMoreActionClick: onMoreActionClick,
|
|
3140
|
+
isAddEnabled: isAddEnabled && !col.fixed,
|
|
3141
|
+
onAddColumn: function onAddColumn(positionOffset) {
|
|
3142
|
+
return onColumnAdd(index + positionOffset);
|
|
3143
|
+
},
|
|
3144
|
+
onColumnDelete: onColumnDelete,
|
|
3145
|
+
isHidable: col.isHidable,
|
|
3146
|
+
isDeletable: col.isDeletable,
|
|
3147
|
+
moreActions: col.moreActions,
|
|
3148
|
+
column: col
|
|
3149
|
+
};
|
|
3150
|
+
},
|
|
3151
|
+
sortIcon: SortIcon,
|
|
3152
|
+
sortOrder: sortedInfo.field === col.dataIndex || sortedInfo.field === col.key ? sortedInfo.order : null
|
|
3153
|
+
});
|
|
3154
|
+
if (!has("ellipsis", col)) {
|
|
3155
|
+
modifiedColumn.ellipsis = true;
|
|
3156
|
+
}
|
|
3157
|
+
return modifiedColumn;
|
|
3158
|
+
});
|
|
3159
|
+
}, [columns, sortedInfo, tableOnChangeProps]);
|
|
3160
|
+
return {
|
|
3161
|
+
columns: computedColumnsData
|
|
3162
|
+
};
|
|
3163
|
+
};
|
|
3164
|
+
|
|
3165
|
+
function ownKeys$4(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
3166
|
+
function _objectSpread$4(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$4(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$4(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
3167
|
+
var useColumns = function useColumns(_ref) {
|
|
3168
|
+
var columns = _ref.columns,
|
|
3169
|
+
setColumns = _ref.setColumns,
|
|
3170
|
+
isResizeEnabled = _ref.isResizeEnabled,
|
|
3171
|
+
isReorderEnabled = _ref.isReorderEnabled,
|
|
3172
|
+
isAddEnabled = _ref.isAddEnabled,
|
|
3173
|
+
onColumnAdd = _ref.onColumnAdd,
|
|
3174
|
+
onColumnUpdate = _ref.onColumnUpdate,
|
|
3175
|
+
onColumnDelete = _ref.onColumnDelete,
|
|
3176
|
+
rowSelection = _ref.rowSelection,
|
|
3177
|
+
sortedInfo = _ref.sortedInfo,
|
|
3178
|
+
setSortedInfo = _ref.setSortedInfo,
|
|
3179
|
+
onColumnHide = _ref.onColumnHide,
|
|
3180
|
+
onMoreActionClick = _ref.onMoreActionClick,
|
|
3181
|
+
onTableChange = _ref.onTableChange,
|
|
3182
|
+
tableOnChangeProps = _ref.tableOnChangeProps,
|
|
3183
|
+
handleTableSortChange = _ref.handleTableSortChange,
|
|
3184
|
+
isDefaultPageChangeHandler = _ref.isDefaultPageChangeHandler;
|
|
3185
|
+
var _useReorderColumns = useReorderColumns({
|
|
3186
|
+
isEnabled: isReorderEnabled,
|
|
3187
|
+
columns: columns,
|
|
3188
|
+
setColumns: setColumns,
|
|
3189
|
+
onColumnUpdate: onColumnUpdate,
|
|
3190
|
+
rowSelection: rowSelection
|
|
3191
|
+
}),
|
|
3192
|
+
dragProps = _useReorderColumns.dragProps;
|
|
3193
|
+
var handleSort = function handleSort(sorter) {
|
|
3194
|
+
var _tableOnChangeProps$c, _tableOnChangeProps$c2, _tableOnChangeProps$c3;
|
|
3195
|
+
var newSortedInfo = _objectSpread$4({}, sorter);
|
|
3196
|
+
if (equals(props(["field", "order"], newSortedInfo), props(["field", "order"], sortedInfo))) {
|
|
3197
|
+
newSortedInfo = {
|
|
3198
|
+
field: null,
|
|
3199
|
+
order: null,
|
|
3200
|
+
column: null,
|
|
3201
|
+
columnKey: null
|
|
3202
|
+
};
|
|
3203
|
+
}
|
|
3204
|
+
setSortedInfo(newSortedInfo);
|
|
3205
|
+
onTableChange === null || onTableChange === void 0 || onTableChange(((_tableOnChangeProps$c = tableOnChangeProps.current) === null || _tableOnChangeProps$c === void 0 ? void 0 : _tableOnChangeProps$c.pagination) || {}, ((_tableOnChangeProps$c2 = tableOnChangeProps.current) === null || _tableOnChangeProps$c2 === void 0 ? void 0 : _tableOnChangeProps$c2.filters) || {}, _objectSpread$4({}, newSortedInfo));
|
|
3206
|
+
isDefaultPageChangeHandler && handleTableSortChange(((_tableOnChangeProps$c3 = tableOnChangeProps.current) === null || _tableOnChangeProps$c3 === void 0 ? void 0 : _tableOnChangeProps$c3.pagination) || {}, newSortedInfo);
|
|
3207
|
+
};
|
|
3208
|
+
var _useResizableColumns = useResizableColumns({
|
|
3209
|
+
columns: columns,
|
|
3210
|
+
setColumns: setColumns,
|
|
3211
|
+
isEnabled: isResizeEnabled,
|
|
3212
|
+
isAddEnabled: isAddEnabled,
|
|
3213
|
+
onColumnAdd: onColumnAdd,
|
|
3214
|
+
onColumnUpdate: onColumnUpdate,
|
|
3215
|
+
onColumnDelete: onColumnDelete,
|
|
3216
|
+
handleSort: handleSort,
|
|
3217
|
+
sortedInfo: sortedInfo,
|
|
3218
|
+
onColumnHide: onColumnHide,
|
|
3219
|
+
onMoreActionClick: onMoreActionClick,
|
|
3220
|
+
tableOnChangeProps: tableOnChangeProps
|
|
3221
|
+
}),
|
|
3222
|
+
computedColumnsData = _useResizableColumns.columns;
|
|
3223
|
+
return {
|
|
3224
|
+
dragProps: dragProps,
|
|
3225
|
+
columns: computedColumnsData
|
|
3226
|
+
};
|
|
3227
|
+
};
|
|
3228
|
+
|
|
3229
|
+
var getSortInfoFromQueryParams = function getSortInfoFromQueryParams(queryParams) {
|
|
3230
|
+
var sortedInfo = {};
|
|
3231
|
+
if (isPresent(queryParams.sort_by) && isPresent(queryParams.order_by) && isPresent(TABLE_SORT_ORDERS[queryParams.order_by])) {
|
|
3232
|
+
sortedInfo.field = snakeToCamelCase(queryParams.sort_by);
|
|
3233
|
+
sortedInfo.order = TABLE_SORT_ORDERS[queryParams.order_by];
|
|
3234
|
+
}
|
|
3235
|
+
return sortedInfo;
|
|
3236
|
+
};
|
|
3237
|
+
var useTableSort = function useTableSort() {
|
|
3238
|
+
var queryParams = useQueryParams();
|
|
3239
|
+
var _useState = useState(function () {
|
|
3240
|
+
return getSortInfoFromQueryParams(queryParams);
|
|
3241
|
+
}),
|
|
3242
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
3243
|
+
sortedInfo = _useState2[0],
|
|
3244
|
+
setSortedInfo = _useState2[1];
|
|
3245
|
+
useEffect(function () {
|
|
3246
|
+
setSortedInfo(getSortInfoFromQueryParams(queryParams));
|
|
3247
|
+
}, [queryParams === null || queryParams === void 0 ? void 0 : queryParams.sort_by, queryParams === null || queryParams === void 0 ? void 0 : queryParams.order_by]);
|
|
3248
|
+
var history = useHistory();
|
|
3249
|
+
var handleTableChange = function handleTableChange(pagination, sorter) {
|
|
3250
|
+
var params = {
|
|
3251
|
+
sort_by: sorter.order ? camelToSnakeCase(sorter.field) : undefined,
|
|
3252
|
+
order_by: URL_SORT_ORDERS[sorter.order],
|
|
3253
|
+
page: pagination.current
|
|
3254
|
+
};
|
|
3255
|
+
var pathname = window.location.pathname;
|
|
3256
|
+
history.push(buildUrl(pathname, mergeLeft(params, queryParams)));
|
|
3257
|
+
};
|
|
3258
|
+
return {
|
|
3259
|
+
handleTableChange: handleTableChange,
|
|
3260
|
+
sortedInfo: sortedInfo,
|
|
3261
|
+
setSortedInfo: setSortedInfo
|
|
3262
|
+
};
|
|
3263
|
+
};
|
|
3264
|
+
|
|
3265
|
+
var Menu = Dropdown.Menu,
|
|
3266
|
+
MenuItem = Dropdown.MenuItem;
|
|
3267
|
+
var HeaderCellMenu = function HeaderCellMenu(_ref) {
|
|
3268
|
+
var onSort = _ref.onSort,
|
|
3269
|
+
_ref$column = _ref.column,
|
|
3270
|
+
column = _ref$column === void 0 ? {} : _ref$column,
|
|
3271
|
+
sortedInfo = _ref.sortedInfo,
|
|
3272
|
+
isSortable = _ref.isSortable,
|
|
3273
|
+
isAddEnabled = _ref.isAddEnabled,
|
|
3274
|
+
isColumnDeletable = _ref.isColumnDeletable,
|
|
3275
|
+
isHidable = _ref.isHidable,
|
|
3276
|
+
onColumnHide = _ref.onColumnHide,
|
|
3277
|
+
onAddColumn = _ref.onAddColumn,
|
|
3278
|
+
onColumnDelete = _ref.onColumnDelete,
|
|
3279
|
+
hasMoreActions = _ref.hasMoreActions,
|
|
3280
|
+
onMoreActionClick = _ref.onMoreActionClick,
|
|
3281
|
+
_ref$columnTitle = _ref.columnTitle,
|
|
3282
|
+
columnTitle = _ref$columnTitle === void 0 ? null : _ref$columnTitle,
|
|
3283
|
+
_ref$moreActions = _ref.moreActions,
|
|
3284
|
+
moreActions = _ref$moreActions === void 0 ? [] : _ref$moreActions;
|
|
3285
|
+
var columnInfoButtonReference = useRef();
|
|
3286
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
3287
|
+
onClick: function onClick(event) {
|
|
3288
|
+
return event.stopPropagation();
|
|
3289
|
+
}
|
|
3290
|
+
}, /*#__PURE__*/React__default.createElement(Dropdown, {
|
|
3291
|
+
appendTo: function appendTo() {
|
|
3292
|
+
return document.body;
|
|
3293
|
+
},
|
|
3294
|
+
className: "flex",
|
|
3295
|
+
icon: MenuHorizontal,
|
|
3296
|
+
position: "auto",
|
|
3297
|
+
strategy: "fixed",
|
|
3298
|
+
buttonProps: {
|
|
3299
|
+
className: "min-h-0 flex-shrink-0",
|
|
3300
|
+
style: "text",
|
|
3301
|
+
size: "medium",
|
|
3302
|
+
"data-testid": "column-menu-button",
|
|
3303
|
+
"data-dropdown-button-style": "more-dropdown"
|
|
3304
|
+
}
|
|
3305
|
+
}, /*#__PURE__*/React__default.createElement(Menu, {
|
|
3306
|
+
className: "cursor-auto",
|
|
3307
|
+
onMouseDown: function onMouseDown(event) {
|
|
3308
|
+
return event.preventDefault();
|
|
3309
|
+
}
|
|
3310
|
+
}, isSortable && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(MenuItem.Button, {
|
|
3311
|
+
className: "flex items-center justify-between",
|
|
3312
|
+
onClick: function onClick() {
|
|
3313
|
+
return onSort({
|
|
3314
|
+
column: column,
|
|
3315
|
+
columnKey: column.key,
|
|
3316
|
+
field: column.dataIndex || column.key,
|
|
3317
|
+
order: TABLE_SORT_ORDERS.asc
|
|
3318
|
+
});
|
|
3319
|
+
}
|
|
3320
|
+
}, /*#__PURE__*/React__default.createElement("span", null, "Ascending"), sortedInfo.order === TABLE_SORT_ORDERS.asc && sortedInfo.field === column.dataIndex && /*#__PURE__*/React__default.createElement(Check, {
|
|
3321
|
+
className: "neeto-ui-text-success-500",
|
|
3322
|
+
size: 20
|
|
3323
|
+
})), /*#__PURE__*/React__default.createElement(MenuItem.Button, {
|
|
3324
|
+
className: "flex items-center justify-between",
|
|
3325
|
+
onClick: function onClick() {
|
|
3326
|
+
return onSort({
|
|
3327
|
+
column: column,
|
|
3328
|
+
columnKey: column.key,
|
|
3329
|
+
field: column.dataIndex,
|
|
3330
|
+
order: TABLE_SORT_ORDERS.desc
|
|
3331
|
+
});
|
|
3332
|
+
}
|
|
3333
|
+
}, /*#__PURE__*/React__default.createElement("span", null, "Descending"), sortedInfo.order === TABLE_SORT_ORDERS.desc && sortedInfo.field === column.dataIndex && /*#__PURE__*/React__default.createElement(Check, {
|
|
3334
|
+
className: "neeto-ui-text-success-500",
|
|
3335
|
+
size: 20
|
|
3336
|
+
}))), isAddEnabled && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(MenuItem.Button, {
|
|
3337
|
+
onClick: function onClick() {
|
|
3338
|
+
return onAddColumn(COLUMN_ADD_DIRECTION.right);
|
|
3339
|
+
}
|
|
3340
|
+
}, "Insert column right"), /*#__PURE__*/React__default.createElement(MenuItem.Button, {
|
|
3341
|
+
onClick: function onClick() {
|
|
3342
|
+
return onAddColumn(COLUMN_ADD_DIRECTION.left);
|
|
3343
|
+
}
|
|
3344
|
+
}, "Insert column left")), isPresent(column === null || column === void 0 ? void 0 : column.description) && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(MenuItem.Button, {
|
|
3345
|
+
ref: columnInfoButtonReference
|
|
3346
|
+
}, "Column info"), /*#__PURE__*/React__default.createElement(Popover, {
|
|
3347
|
+
className: "cursor-auto",
|
|
3348
|
+
hideOnClick: false,
|
|
3349
|
+
interactiveDebounce: 20,
|
|
3350
|
+
offset: [0, 15],
|
|
3351
|
+
position: "right",
|
|
3352
|
+
reference: columnInfoButtonReference,
|
|
3353
|
+
strategy: "fixed"
|
|
3354
|
+
}, columnTitle && /*#__PURE__*/React__default.createElement(Popover.Title, null, columnTitle), /*#__PURE__*/React__default.createElement(Typography, {
|
|
3355
|
+
className: "w-72 max-w-full whitespace-normal normal-case",
|
|
3356
|
+
lineHeight: "normal",
|
|
3357
|
+
style: "body2",
|
|
3358
|
+
weight: "normal"
|
|
3359
|
+
}, column === null || column === void 0 ? void 0 : column.description))), isHidable && /*#__PURE__*/React__default.createElement(MenuItem.Button, {
|
|
3360
|
+
onClick: function onClick() {
|
|
3361
|
+
return onColumnHide(column);
|
|
3362
|
+
}
|
|
3363
|
+
}, "Hide column"), isColumnDeletable && /*#__PURE__*/React__default.createElement(MenuItem.Button, {
|
|
3364
|
+
onClick: function onClick() {
|
|
3365
|
+
return onColumnDelete(column.id);
|
|
3366
|
+
}
|
|
3367
|
+
}, "Delete column"), hasMoreActions && moreActions.map(function (item, index) {
|
|
3368
|
+
return /*#__PURE__*/React__default.createElement(MenuItem.Button, {
|
|
3369
|
+
key: index,
|
|
3370
|
+
onClick: function onClick() {
|
|
3371
|
+
return onMoreActionClick(item.type, column);
|
|
3372
|
+
}
|
|
3373
|
+
}, item.label);
|
|
3374
|
+
}))));
|
|
3375
|
+
};
|
|
3376
|
+
|
|
3377
|
+
var _excluded$6 = ["children", "isSortable", "isAddEnabled", "sortedInfo", "onSort", "isHidable", "isDeletable", "onColumnHide", "onAddColumn", "onColumnDelete", "onMoreActionClick", "column", "moreActions"];
|
|
3378
|
+
var CellContent = function CellContent(_ref) {
|
|
3379
|
+
var children = _ref.children,
|
|
3380
|
+
isSortable = _ref.isSortable,
|
|
3381
|
+
isAddEnabled = _ref.isAddEnabled,
|
|
3382
|
+
sortedInfo = _ref.sortedInfo,
|
|
3383
|
+
onSort = _ref.onSort,
|
|
3384
|
+
_ref$isHidable = _ref.isHidable,
|
|
3385
|
+
isHidable = _ref$isHidable === void 0 ? true : _ref$isHidable,
|
|
3386
|
+
_ref$isDeletable = _ref.isDeletable,
|
|
3387
|
+
isDeletable = _ref$isDeletable === void 0 ? false : _ref$isDeletable,
|
|
3388
|
+
onColumnHide = _ref.onColumnHide,
|
|
3389
|
+
onAddColumn = _ref.onAddColumn,
|
|
3390
|
+
onColumnDelete = _ref.onColumnDelete,
|
|
3391
|
+
onMoreActionClick = _ref.onMoreActionClick,
|
|
3392
|
+
column = _ref.column,
|
|
3393
|
+
_ref$moreActions = _ref.moreActions,
|
|
3394
|
+
moreActions = _ref$moreActions === void 0 ? [] : _ref$moreActions,
|
|
3395
|
+
headerProps = _objectWithoutProperties(_ref, _excluded$6);
|
|
3396
|
+
var isColumnHidable = isHidable && isPresent(onColumnHide);
|
|
3397
|
+
var isColumnDeletable = isDeletable && isPresent(onColumnDelete);
|
|
3398
|
+
var hasMoreActions = !isEmpty(moreActions) && isPresent(onMoreActionClick);
|
|
3399
|
+
var hasMoreMenu = isSortable || isPresent(column === null || column === void 0 ? void 0 : column.description) || isColumnHidable || isAddEnabled || hasMoreActions;
|
|
3400
|
+
return /*#__PURE__*/React__default.createElement("th", _extends({}, headerProps, {
|
|
3401
|
+
title: "",
|
|
3402
|
+
onClick: isSortable ? noop$1 : headerProps.onClick
|
|
3403
|
+
}), /*#__PURE__*/React__default.createElement("div", {
|
|
3404
|
+
className: "flex items-center justify-between"
|
|
3405
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
3406
|
+
className: "min-w-0 flex-grow"
|
|
3407
|
+
}, children), hasMoreMenu && /*#__PURE__*/React__default.createElement(HeaderCellMenu, {
|
|
3408
|
+
column: column,
|
|
3409
|
+
hasMoreActions: hasMoreActions,
|
|
3410
|
+
isAddEnabled: isAddEnabled,
|
|
3411
|
+
isColumnDeletable: isColumnDeletable,
|
|
3412
|
+
isSortable: isSortable,
|
|
3413
|
+
moreActions: moreActions,
|
|
3414
|
+
onAddColumn: onAddColumn,
|
|
3415
|
+
onColumnDelete: onColumnDelete,
|
|
3416
|
+
onColumnHide: onColumnHide,
|
|
3417
|
+
onMoreActionClick: onMoreActionClick,
|
|
3418
|
+
onSort: onSort,
|
|
3419
|
+
sortedInfo: sortedInfo,
|
|
3420
|
+
columnTitle: headerProps.title,
|
|
3421
|
+
isHidable: isColumnHidable
|
|
3422
|
+
})));
|
|
3423
|
+
};
|
|
3424
|
+
|
|
3425
|
+
var _excluded$5 = ["onResize", "width", "onResizeStop", "className"];
|
|
3426
|
+
var HeaderCell = function HeaderCell(props) {
|
|
3427
|
+
var onResize = props.onResize,
|
|
3428
|
+
width = props.width,
|
|
3429
|
+
onResizeStop = props.onResizeStop,
|
|
3430
|
+
className = props.className,
|
|
3431
|
+
restProps = _objectWithoutProperties(props, _excluded$5);
|
|
3432
|
+
if (!width) {
|
|
3433
|
+
return /*#__PURE__*/React__default.createElement(CellContent, _extends({}, restProps, {
|
|
3434
|
+
className: classnames(className, "drag-handler")
|
|
3435
|
+
}));
|
|
3436
|
+
}
|
|
3437
|
+
return /*#__PURE__*/React__default.createElement(Resizable, {
|
|
3438
|
+
onResize: onResize,
|
|
3439
|
+
onResizeStop: onResizeStop,
|
|
3440
|
+
width: width,
|
|
3441
|
+
draggableOpts: {
|
|
3442
|
+
enableUserSelectHack: false
|
|
3443
|
+
},
|
|
3444
|
+
height: 0,
|
|
3445
|
+
handle: /*#__PURE__*/React__default.createElement("span", {
|
|
3446
|
+
className: "react-resizable-handle",
|
|
3447
|
+
onClick: function onClick(e) {
|
|
3448
|
+
return e.stopPropagation();
|
|
3449
|
+
}
|
|
3450
|
+
})
|
|
3451
|
+
}, /*#__PURE__*/React__default.createElement(CellContent, _extends({}, restProps, {
|
|
3452
|
+
className: classnames(className, "drag-handler")
|
|
3453
|
+
})));
|
|
3454
|
+
};
|
|
3455
|
+
|
|
3456
|
+
var _excluded$4 = ["onResize", "width", "onResizeStop"];
|
|
3457
|
+
var ResizableHeaderCell = function ResizableHeaderCell(props) {
|
|
3458
|
+
var onResize = props.onResize,
|
|
3459
|
+
width = props.width,
|
|
3460
|
+
onResizeStop = props.onResizeStop,
|
|
3461
|
+
restProps = _objectWithoutProperties(props, _excluded$4);
|
|
3462
|
+
if (!width) {
|
|
3463
|
+
return /*#__PURE__*/React__default.createElement(CellContent, restProps);
|
|
3464
|
+
}
|
|
3465
|
+
return /*#__PURE__*/React__default.createElement(Resizable, {
|
|
3466
|
+
onResize: onResize,
|
|
3467
|
+
onResizeStop: onResizeStop,
|
|
3468
|
+
width: width,
|
|
3469
|
+
draggableOpts: {
|
|
3470
|
+
enableUserSelectHack: false
|
|
3471
|
+
},
|
|
3472
|
+
height: 0,
|
|
3473
|
+
handle: /*#__PURE__*/React__default.createElement("span", {
|
|
3474
|
+
className: "react-resizable-handle",
|
|
3475
|
+
onClick: function onClick(e) {
|
|
3476
|
+
return e.stopPropagation();
|
|
3477
|
+
}
|
|
3478
|
+
})
|
|
3479
|
+
}, /*#__PURE__*/React__default.createElement(CellContent, restProps));
|
|
3480
|
+
};
|
|
3481
|
+
|
|
3482
|
+
var _excluded$3 = ["className"];
|
|
3483
|
+
var ReorderableHeaderCell = function ReorderableHeaderCell(_ref) {
|
|
3484
|
+
var className = _ref.className,
|
|
3485
|
+
props = _objectWithoutProperties(_ref, _excluded$3);
|
|
3486
|
+
return /*#__PURE__*/React__default.createElement(CellContent, _extends({}, props, {
|
|
3487
|
+
className: classnames(className, "drag-handler")
|
|
3488
|
+
}));
|
|
3489
|
+
};
|
|
3490
|
+
|
|
3491
|
+
var getHeaderCell = function getHeaderCell(_ref) {
|
|
3492
|
+
var enableColumnResize = _ref.enableColumnResize,
|
|
3493
|
+
enableColumnReorder = _ref.enableColumnReorder;
|
|
3494
|
+
if (enableColumnReorder && enableColumnResize) return {
|
|
3495
|
+
cell: HeaderCell
|
|
3496
|
+
};
|
|
3497
|
+
if (enableColumnResize) return {
|
|
3498
|
+
cell: ResizableHeaderCell
|
|
3499
|
+
};
|
|
3500
|
+
if (enableColumnReorder) return {
|
|
3501
|
+
cell: ReorderableHeaderCell
|
|
3502
|
+
};
|
|
3503
|
+
return {
|
|
3504
|
+
cell: CellContent
|
|
3505
|
+
};
|
|
3506
|
+
};
|
|
3507
|
+
var isIncludedIn = function isIncludedIn(array1, array2) {
|
|
3508
|
+
return all(includes(__, array1), array2);
|
|
3509
|
+
};
|
|
3510
|
+
|
|
3511
|
+
var _excluded$2 = ["allowRowClick", "enableColumnResize", "enableColumnReorder", "enableAddColumn", "className", "columnData", "currentPageNumber", "defaultPageSize", "handlePageChange", "loading", "onRowClick", "onRowSelect", "rowData", "totalCount", "selectedRowKeys", "fixedHeight", "paginationProps", "rowKey", "scroll", "rowSelection", "shouldDynamicallyRenderRowSize", "bordered", "onColumnUpdate", "components", "onColumnHide", "onColumnAdd", "onColumnDelete", "onChange", "onMoreActionClick", "bulkSelectAllRowsProps"];
|
|
3512
|
+
function ownKeys$3(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
3513
|
+
function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$3(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$3(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
3514
|
+
var TABLE_PAGINATION_HEIGHT = 64;
|
|
3515
|
+
var TABLE_DEFAULT_HEADER_HEIGHT = 40;
|
|
3516
|
+
var TABLE_ROW_HEIGHT = 52;
|
|
3517
|
+
var Table = function Table(_ref) {
|
|
3518
|
+
var _ref$allowRowClick = _ref.allowRowClick,
|
|
3519
|
+
allowRowClick = _ref$allowRowClick === void 0 ? true : _ref$allowRowClick,
|
|
3520
|
+
_ref$enableColumnResi = _ref.enableColumnResize,
|
|
3521
|
+
enableColumnResize = _ref$enableColumnResi === void 0 ? false : _ref$enableColumnResi,
|
|
3522
|
+
_ref$enableColumnReor = _ref.enableColumnReorder,
|
|
3523
|
+
enableColumnReorder = _ref$enableColumnReor === void 0 ? false : _ref$enableColumnReor,
|
|
3524
|
+
_ref$enableAddColumn = _ref.enableAddColumn,
|
|
3525
|
+
enableAddColumn = _ref$enableAddColumn === void 0 ? false : _ref$enableAddColumn,
|
|
3526
|
+
_ref$className = _ref.className,
|
|
3527
|
+
className = _ref$className === void 0 ? "" : _ref$className,
|
|
3528
|
+
_ref$columnData = _ref.columnData,
|
|
3529
|
+
columnData = _ref$columnData === void 0 ? [] : _ref$columnData,
|
|
3530
|
+
_ref$currentPageNumbe = _ref.currentPageNumber,
|
|
3531
|
+
currentPageNumber = _ref$currentPageNumbe === void 0 ? 1 : _ref$currentPageNumbe,
|
|
3532
|
+
_ref$defaultPageSize = _ref.defaultPageSize,
|
|
3533
|
+
defaultPageSize = _ref$defaultPageSize === void 0 ? 30 : _ref$defaultPageSize,
|
|
3534
|
+
_ref$handlePageChange = _ref.handlePageChange,
|
|
3535
|
+
handlePageChange = _ref$handlePageChange === void 0 ? noop : _ref$handlePageChange,
|
|
3536
|
+
_ref$loading = _ref.loading,
|
|
3537
|
+
loading = _ref$loading === void 0 ? false : _ref$loading,
|
|
3538
|
+
onRowClick = _ref.onRowClick,
|
|
3539
|
+
onRowSelect = _ref.onRowSelect,
|
|
3540
|
+
_ref$rowData = _ref.rowData,
|
|
3541
|
+
rowData = _ref$rowData === void 0 ? [] : _ref$rowData,
|
|
3542
|
+
_ref$totalCount = _ref.totalCount,
|
|
3543
|
+
totalCount = _ref$totalCount === void 0 ? 0 : _ref$totalCount,
|
|
3544
|
+
_ref$selectedRowKeys = _ref.selectedRowKeys,
|
|
3545
|
+
initialSelectedRowKeys = _ref$selectedRowKeys === void 0 ? [] : _ref$selectedRowKeys,
|
|
3546
|
+
_ref$fixedHeight = _ref.fixedHeight,
|
|
3547
|
+
fixedHeight = _ref$fixedHeight === void 0 ? false : _ref$fixedHeight,
|
|
3548
|
+
_ref$paginationProps = _ref.paginationProps,
|
|
3549
|
+
paginationProps = _ref$paginationProps === void 0 ? {} : _ref$paginationProps,
|
|
3550
|
+
_ref$rowKey = _ref.rowKey,
|
|
3551
|
+
rowKey = _ref$rowKey === void 0 ? "id" : _ref$rowKey,
|
|
3552
|
+
scroll = _ref.scroll,
|
|
3553
|
+
rowSelection = _ref.rowSelection,
|
|
3554
|
+
_ref$shouldDynamicall = _ref.shouldDynamicallyRenderRowSize,
|
|
3555
|
+
shouldDynamicallyRenderRowSize = _ref$shouldDynamicall === void 0 ? false : _ref$shouldDynamicall,
|
|
3556
|
+
_ref$bordered = _ref.bordered,
|
|
3557
|
+
bordered = _ref$bordered === void 0 ? true : _ref$bordered,
|
|
3558
|
+
_ref$onColumnUpdate = _ref.onColumnUpdate,
|
|
3559
|
+
onColumnUpdate = _ref$onColumnUpdate === void 0 ? noop : _ref$onColumnUpdate,
|
|
3560
|
+
_ref$components = _ref.components,
|
|
3561
|
+
components = _ref$components === void 0 ? {} : _ref$components,
|
|
3562
|
+
onColumnHide = _ref.onColumnHide,
|
|
3563
|
+
_ref$onColumnAdd = _ref.onColumnAdd,
|
|
3564
|
+
onColumnAdd = _ref$onColumnAdd === void 0 ? noop : _ref$onColumnAdd,
|
|
3565
|
+
onColumnDelete = _ref.onColumnDelete,
|
|
3566
|
+
onChange = _ref.onChange,
|
|
3567
|
+
onMoreActionClick = _ref.onMoreActionClick,
|
|
3568
|
+
bulkSelectAllRowsProps = _ref.bulkSelectAllRowsProps,
|
|
3569
|
+
otherProps = _objectWithoutProperties(_ref, _excluded$2);
|
|
3570
|
+
var _useState = useState(null),
|
|
3571
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
3572
|
+
containerHeight = _useState2[0],
|
|
3573
|
+
setContainerHeight = _useState2[1];
|
|
3574
|
+
var _useState3 = useState(TABLE_DEFAULT_HEADER_HEIGHT),
|
|
3575
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
3576
|
+
headerHeight = _useState4[0],
|
|
3577
|
+
setHeaderHeight = _useState4[1];
|
|
3578
|
+
var _useState5 = useState(columnData),
|
|
3579
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
3580
|
+
columns = _useState6[0],
|
|
3581
|
+
setColumns = _useState6[1];
|
|
3582
|
+
var _useState7 = useState(false),
|
|
3583
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
3584
|
+
bulkSelectedAllRows = _useState8[0],
|
|
3585
|
+
setBulkSelectedAllRows = _useState8[1];
|
|
3586
|
+
var _useTableSort = useTableSort(),
|
|
3587
|
+
handleTableSortChange = _useTableSort.handleTableChange,
|
|
3588
|
+
sortedInfo = _useTableSort.sortedInfo,
|
|
3589
|
+
setSortedInfo = _useTableSort.setSortedInfo;
|
|
3590
|
+
var _ref2 = bulkSelectAllRowsProps !== null && bulkSelectAllRowsProps !== void 0 ? bulkSelectAllRowsProps : {},
|
|
3591
|
+
handleSetBulkSelectedAllRows = _ref2.setBulkSelectedAllRows;
|
|
3592
|
+
var isDefaultPageChangeHandler = handlePageChange === noop;
|
|
3593
|
+
var history = useHistory();
|
|
3594
|
+
var headerRef = useRef();
|
|
3595
|
+
var tableOnChangeProps = useRef({});
|
|
3596
|
+
var resizeObserver = useRef(new ResizeObserver(function (_ref3) {
|
|
3597
|
+
var _ref4 = _slicedToArray(_ref3, 1),
|
|
3598
|
+
entry = _ref4[0];
|
|
3599
|
+
return setContainerHeight(entry.contentRect.height);
|
|
3600
|
+
}));
|
|
3601
|
+
var tableRef = useCallback(function (table) {
|
|
3602
|
+
if (!fixedHeight) return;
|
|
3603
|
+
var observer = resizeObserver.current;
|
|
3604
|
+
if (table !== null) {
|
|
3605
|
+
observer.observe(table === null || table === void 0 ? void 0 : table.parentNode);
|
|
3606
|
+
} else if (observer) {
|
|
3607
|
+
observer.disconnect();
|
|
3608
|
+
}
|
|
3609
|
+
}, [resizeObserver.current, fixedHeight]);
|
|
3610
|
+
useTimeout(function () {
|
|
3611
|
+
var headerHeight = headerRef.current ? headerRef.current.offsetHeight : TABLE_DEFAULT_HEADER_HEIGHT;
|
|
3612
|
+
setHeaderHeight(headerHeight);
|
|
3613
|
+
}, 10);
|
|
3614
|
+
var _useColumns = useColumns({
|
|
3615
|
+
isReorderEnabled: enableColumnReorder,
|
|
3616
|
+
isResizeEnabled: enableColumnResize,
|
|
3617
|
+
isAddEnabled: enableAddColumn,
|
|
3618
|
+
onTableChange: onChange,
|
|
3619
|
+
columns: columns,
|
|
3620
|
+
setColumns: setColumns,
|
|
3621
|
+
onColumnUpdate: onColumnUpdate,
|
|
3622
|
+
rowSelection: rowSelection,
|
|
3623
|
+
sortedInfo: sortedInfo,
|
|
3624
|
+
setSortedInfo: setSortedInfo,
|
|
3625
|
+
onColumnHide: onColumnHide,
|
|
3626
|
+
onMoreActionClick: onMoreActionClick,
|
|
3627
|
+
onColumnAdd: onColumnAdd,
|
|
3628
|
+
onColumnDelete: onColumnDelete,
|
|
3629
|
+
tableOnChangeProps: tableOnChangeProps,
|
|
3630
|
+
handleTableSortChange: handleTableSortChange,
|
|
3631
|
+
isDefaultPageChangeHandler: isDefaultPageChangeHandler
|
|
3632
|
+
}),
|
|
3633
|
+
dragProps = _useColumns.dragProps,
|
|
3634
|
+
curatedColumnsData = _useColumns.columns;
|
|
3635
|
+
var queryParams = useQueryParams();
|
|
3636
|
+
var setSortFromURL = function setSortFromURL(columnData) {
|
|
3637
|
+
var _queryParams$sort_by;
|
|
3638
|
+
return modifyBy({
|
|
3639
|
+
dataIndex: snakeToCamelCase((_queryParams$sort_by = queryParams.sort_by) !== null && _queryParams$sort_by !== void 0 ? _queryParams$sort_by : "")
|
|
3640
|
+
}, assoc("sortOrder", TABLE_SORT_ORDERS[queryParams.order_by]), columnData);
|
|
3641
|
+
};
|
|
3642
|
+
var sortedColumns = isDefaultPageChangeHandler ? setSortFromURL(curatedColumnsData) : curatedColumnsData;
|
|
3643
|
+
var locale = {
|
|
3644
|
+
emptyText: /*#__PURE__*/React__default.createElement(Typography, {
|
|
3645
|
+
style: "body2"
|
|
3646
|
+
}, "No Data")
|
|
3647
|
+
};
|
|
3648
|
+
var sortedColumnsWithAlignment = sortedColumns.map(function (sortedColumn) {
|
|
3649
|
+
return _objectSpread$3(_objectSpread$3({}, sortedColumn), {}, {
|
|
3650
|
+
onHeaderCell: function onHeaderCell(column) {
|
|
3651
|
+
var _sortedColumn$onHeade;
|
|
3652
|
+
return _objectSpread$3(_objectSpread$3({}, (_sortedColumn$onHeade = sortedColumn.onHeaderCell) === null || _sortedColumn$onHeade === void 0 ? void 0 : _sortedColumn$onHeade.call(sortedColumn, column)), {}, {
|
|
3653
|
+
"data-text-align": column.align
|
|
3654
|
+
});
|
|
3655
|
+
}
|
|
3656
|
+
});
|
|
3657
|
+
});
|
|
3658
|
+
var selectedRowKeys = bulkSelectedAllRows ? pluck(rowKey, rowData) : initialSelectedRowKeys;
|
|
3659
|
+
var showBulkSelectionCallout = useMemo(function () {
|
|
3660
|
+
return isIncludedIn(selectedRowKeys, pluck(rowKey, rowData)) && selectedRowKeys.length !== totalCount && !bulkSelectedAllRows;
|
|
3661
|
+
}, [selectedRowKeys, rowKey, rowData, totalCount, bulkSelectedAllRows]);
|
|
3662
|
+
var handleRowChange = function handleRowChange(selectedRowKeys, selectedRows) {
|
|
3663
|
+
if (selectedRowKeys.length !== defaultPageSize) {
|
|
3664
|
+
setBulkSelectedAllRows(false);
|
|
3665
|
+
handleSetBulkSelectedAllRows === null || handleSetBulkSelectedAllRows === void 0 || handleSetBulkSelectedAllRows(false);
|
|
3666
|
+
}
|
|
3667
|
+
onRowSelect === null || onRowSelect === void 0 || onRowSelect(selectedRowKeys, selectedRows);
|
|
3668
|
+
};
|
|
3669
|
+
var rowSelectionProps = rowSelection ? _objectSpread$3(_objectSpread$3({
|
|
3670
|
+
type: "checkbox",
|
|
3671
|
+
preserveSelectedRowKeys: true
|
|
3672
|
+
}, rowSelection), {}, {
|
|
3673
|
+
onChange: handleRowChange,
|
|
3674
|
+
selectedRowKeys: selectedRowKeys
|
|
3675
|
+
}) : false;
|
|
3676
|
+
|
|
3677
|
+
// eslint-disable-next-line @bigbinary/neeto/no-excess-function-arguments
|
|
3678
|
+
var handleTableChange = function handleTableChange(pagination, filters, sorter, extras) {
|
|
3679
|
+
setSortedInfo(sorter);
|
|
3680
|
+
isDefaultPageChangeHandler && handleTableSortChange(pagination, sorter);
|
|
3681
|
+
onChange === null || onChange === void 0 || onChange(pagination, filters, sorter, extras);
|
|
3682
|
+
tableOnChangeProps.current = {
|
|
3683
|
+
pagination: pagination,
|
|
3684
|
+
filters: filters
|
|
3685
|
+
};
|
|
3686
|
+
};
|
|
3687
|
+
var componentOverrides = _objectSpread$3(_objectSpread$3({}, components), {}, {
|
|
3688
|
+
header: getHeaderCell({
|
|
3689
|
+
enableColumnResize: enableColumnResize,
|
|
3690
|
+
enableColumnReorder: enableColumnReorder
|
|
3691
|
+
})
|
|
3692
|
+
});
|
|
3693
|
+
var calculateRowsPerPage = function calculateRowsPerPage() {
|
|
3694
|
+
var viewportHeight = window.innerHeight;
|
|
3695
|
+
var rowsPerPage = Math.floor((viewportHeight - TABLE_PAGINATION_HEIGHT) / TABLE_ROW_HEIGHT * 3);
|
|
3696
|
+
return Math.ceil(rowsPerPage / 10) * 10;
|
|
3697
|
+
};
|
|
3698
|
+
var pageSize = shouldDynamicallyRenderRowSize ? calculateRowsPerPage() : paginationProps.pageSize || defaultPageSize;
|
|
3699
|
+
var calculateTableContainerHeight = function calculateTableContainerHeight() {
|
|
3700
|
+
var isPaginationVisible = otherProps.pagination !== false && rowData.length > pageSize;
|
|
3701
|
+
return containerHeight - headerHeight - (isPaginationVisible ? TABLE_PAGINATION_HEIGHT : 0);
|
|
3702
|
+
};
|
|
3703
|
+
var calculatePageSizeOptions = function calculatePageSizeOptions() {
|
|
3704
|
+
return dynamicArray(5, function (index) {
|
|
3705
|
+
return (index + 1) * pageSize;
|
|
3706
|
+
});
|
|
3707
|
+
};
|
|
3708
|
+
var itemRender = function itemRender(_, type, originalElement) {
|
|
3709
|
+
var commonProps = {
|
|
3710
|
+
size: "small",
|
|
3711
|
+
style: "text"
|
|
3712
|
+
};
|
|
3713
|
+
if (type === "prev") return /*#__PURE__*/React__default.createElement(Button, _extends({
|
|
3714
|
+
icon: Left
|
|
3715
|
+
}, commonProps));
|
|
3716
|
+
if (type === "next") return /*#__PURE__*/React__default.createElement(Button, _extends({
|
|
3717
|
+
icon: Right
|
|
3718
|
+
}, commonProps));
|
|
3719
|
+
if (type === "jump-prev" || type === "jump-next") {
|
|
3720
|
+
return /*#__PURE__*/React__default.createElement(Button, _extends({
|
|
3721
|
+
icon: MenuHorizontal
|
|
3722
|
+
}, commonProps));
|
|
3723
|
+
}
|
|
3724
|
+
return originalElement;
|
|
3725
|
+
};
|
|
3726
|
+
useEffect(function () {
|
|
3727
|
+
if (isNotEmpty(initialSelectedRowKeys)) return;
|
|
3728
|
+
setBulkSelectedAllRows(false);
|
|
3729
|
+
handleSetBulkSelectedAllRows === null || handleSetBulkSelectedAllRows === void 0 || handleSetBulkSelectedAllRows(false);
|
|
3730
|
+
}, [handleSetBulkSelectedAllRows, initialSelectedRowKeys]);
|
|
3731
|
+
useEffect(function () {
|
|
3732
|
+
var shouldNavigateToLastPage = isEmpty(rowData) && !loading && currentPageNumber !== 1;
|
|
3733
|
+
if (!shouldNavigateToLastPage) return;
|
|
3734
|
+
var lastPage = Math.ceil(totalCount / pageSize);
|
|
3735
|
+
var page = Math.max(1, lastPage);
|
|
3736
|
+
var pathname = window.location.pathname;
|
|
3737
|
+
isDefaultPageChangeHandler ? history.push(buildUrl(pathname, mergeLeft({
|
|
3738
|
+
page: page
|
|
3739
|
+
}, queryParams))) : handlePageChange(page, pageSize);
|
|
3740
|
+
}, [rowData]);
|
|
3741
|
+
useEffect(function () {
|
|
3742
|
+
return setColumns(columnData);
|
|
3743
|
+
}, [columnData]);
|
|
3744
|
+
var neetoUIFontBold = parseInt(getComputedStyle(document.documentElement).getPropertyValue("--neeto-ui-font-bold"), 10);
|
|
3745
|
+
var renderTable = function renderTable() {
|
|
3746
|
+
return /*#__PURE__*/React__default.createElement(_ConfigProvider, {
|
|
3747
|
+
theme: {
|
|
3748
|
+
token: _objectSpread$3({}, ANT_DESIGN_GLOBAL_TOKEN_OVERRIDES),
|
|
3749
|
+
components: {
|
|
3750
|
+
Pagination: {
|
|
3751
|
+
itemActiveBg: "rgb(var(--neeto-ui-primary-500))",
|
|
3752
|
+
itemActiveBgDisabled: "rgb(var(--neeto-ui-gray-100))",
|
|
3753
|
+
itemActiveColorDisabled: "rgb(var(--neeto-ui-gray-300))",
|
|
3754
|
+
itemBg: "rgb(var(--neeto-ui-white))",
|
|
3755
|
+
itemInputBg: "rgb(var(--neeto-ui-white))",
|
|
3756
|
+
itemLinkBg: "rgb(var(--neeto-ui-white))",
|
|
3757
|
+
// Global overrides
|
|
3758
|
+
colorBgContainer: "rgb(var(--neeto-ui-primary-500))",
|
|
3759
|
+
colorPrimary: "rgb(var(--neeto-ui-white))",
|
|
3760
|
+
colorPrimaryHover: "rgb(var(--neeto-ui-white))",
|
|
3761
|
+
colorBgTextHover: "rgb(var(--neeto-ui-gray-200))",
|
|
3762
|
+
borderRadius: 6
|
|
3763
|
+
},
|
|
3764
|
+
Table: {
|
|
3765
|
+
headerBorderRadius: 0,
|
|
3766
|
+
bodySortBg: "rgb(var(--neeto-ui-gray-100))",
|
|
3767
|
+
borderColor: "rgb(var(--neeto-ui-gray-300))",
|
|
3768
|
+
expandIconBg: "rgb(var(--neeto-ui-white))",
|
|
3769
|
+
filterDropdownBg: "rgb(var(--neeto-ui-white))",
|
|
3770
|
+
filterDropdownMenuBg: "rgb(var(--neeto-ui-white))",
|
|
3771
|
+
fixedHeaderSortActiveBg: "rgb(var(--neeto-ui-gray-200))",
|
|
3772
|
+
footerBg: "rgb(var(--neeto-ui-gray-100))",
|
|
3773
|
+
footerColor: "rgb(var(--neeto-ui-gray-800))",
|
|
3774
|
+
headerBg: "rgb(var(--neeto-ui-gray-100))",
|
|
3775
|
+
headerColor: "rgb(var(--neeto-ui-gray-700))",
|
|
3776
|
+
headerFilterHoverBg: "rgb(var(--neeto-ui-gray-100))",
|
|
3777
|
+
headerSortActiveBg: "rgb(var(--neeto-ui-gray-200))",
|
|
3778
|
+
headerSortHoverBg: "rgb(var(--neeto-ui-gray-100))",
|
|
3779
|
+
headerSplitColor: "rgb(var(--neeto-ui-gray-200))",
|
|
3780
|
+
rowExpandedBg: "rgb(var(--neeto-ui-gray-200))",
|
|
3781
|
+
rowHoverBg: "rgb(var(--neeto-ui-gray-100))",
|
|
3782
|
+
rowSelectedBg: "rgb(var(--neeto-ui-primary-100))",
|
|
3783
|
+
rowSelectedHoverBg: "rgb(var(--neeto-ui-pastel-purple))",
|
|
3784
|
+
stickyScrollBarBg: "rgb(var(--neeto-ui-primary-100))",
|
|
3785
|
+
cellPaddingBlock: 10,
|
|
3786
|
+
// Global overrides
|
|
3787
|
+
colorPrimary: "rgb(var(--neeto-ui-primary-500))",
|
|
3788
|
+
fontSize: 14,
|
|
3789
|
+
fontWeightStrong: neetoUIFontBold,
|
|
3790
|
+
paddingContentVerticalLG: 10
|
|
3791
|
+
}
|
|
3792
|
+
}
|
|
3793
|
+
}
|
|
3794
|
+
}, bulkSelectAllRowsProps && showBulkSelectionCallout && /*#__PURE__*/React__default.createElement(SelectAllRowsCallout, _extends({}, bulkSelectAllRowsProps, {
|
|
3795
|
+
onBulkSelectAllRows: function onBulkSelectAllRows() {
|
|
3796
|
+
setBulkSelectedAllRows(true);
|
|
3797
|
+
handleSetBulkSelectedAllRows === null || handleSetBulkSelectedAllRows === void 0 || handleSetBulkSelectedAllRows(true);
|
|
3798
|
+
}
|
|
3799
|
+
})), /*#__PURE__*/React__default.createElement(_Table, _extends({
|
|
3800
|
+
bordered: bordered,
|
|
3801
|
+
loading: loading,
|
|
3802
|
+
locale: locale,
|
|
3803
|
+
rowKey: rowKey,
|
|
3804
|
+
columns: sortedColumnsWithAlignment,
|
|
3805
|
+
components: componentOverrides,
|
|
3806
|
+
dataSource: rowData,
|
|
3807
|
+
ref: tableRef,
|
|
3808
|
+
rowSelection: rowSelectionProps,
|
|
3809
|
+
showSorterTooltip: false,
|
|
3810
|
+
pagination: _objectSpread$3(_objectSpread$3({
|
|
3811
|
+
hideOnSinglePage: true
|
|
3812
|
+
}, paginationProps), {}, {
|
|
3813
|
+
showSizeChanger: false,
|
|
3814
|
+
total: totalCount !== null && totalCount !== void 0 ? totalCount : 0,
|
|
3815
|
+
current: currentPageNumber,
|
|
3816
|
+
defaultPageSize: pageSize,
|
|
3817
|
+
pageSizeOptions: calculatePageSizeOptions(),
|
|
3818
|
+
onChange: handlePageChange,
|
|
3819
|
+
itemRender: itemRender
|
|
3820
|
+
}),
|
|
3821
|
+
rowClassName: classnames("neeto-ui-table--row", {
|
|
3822
|
+
"neeto-ui-table--row_hover": allowRowClick
|
|
3823
|
+
}, [className]),
|
|
3824
|
+
scroll: _objectSpread$3({
|
|
3825
|
+
x: "max-content",
|
|
3826
|
+
y: calculateTableContainerHeight()
|
|
3827
|
+
}, scroll),
|
|
3828
|
+
onChange: handleTableChange,
|
|
3829
|
+
onHeaderRow: function onHeaderRow() {
|
|
3830
|
+
return {
|
|
3831
|
+
ref: headerRef,
|
|
3832
|
+
className: classnames("neeto-ui-table__header", {
|
|
3833
|
+
"neeto-ui-table-reorderable": enableColumnReorder
|
|
3834
|
+
}),
|
|
3835
|
+
id: "neeto-ui-table__header"
|
|
3836
|
+
};
|
|
3837
|
+
},
|
|
3838
|
+
onRow: function onRow(record, rowIndex) {
|
|
3839
|
+
return {
|
|
3840
|
+
onClick: function onClick(event) {
|
|
3841
|
+
return allowRowClick && onRowClick && onRowClick(event, record, rowIndex);
|
|
3842
|
+
}
|
|
3843
|
+
};
|
|
3844
|
+
}
|
|
3845
|
+
}, otherProps)));
|
|
3846
|
+
};
|
|
3847
|
+
return enableColumnReorder ? /*#__PURE__*/React__default.createElement(ReactDragListView.DragColumn, dragProps, renderTable()) : renderTable();
|
|
3848
|
+
};
|
|
3849
|
+
|
|
3850
|
+
var RangePicker = _DatePicker.RangePicker;
|
|
3851
|
+
var TIME_PICKER_TYPES = {
|
|
3852
|
+
range: RangePicker,
|
|
3853
|
+
time: _DatePicker
|
|
3854
|
+
};
|
|
3855
|
+
|
|
3856
|
+
var _excluded$1 = ["className", "label", "size", "dropdownClassName", "popupClassName", "format", "interval", "onChange", "type", "nakedInput", "disabled", "error", "defaultValue", "value", "labelProps", "required"];
|
|
3857
|
+
function ownKeys$2(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
3858
|
+
function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$2(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$2(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
3859
|
+
var INPUT_SIZES = {
|
|
3860
|
+
small: "small",
|
|
3861
|
+
medium: "medium",
|
|
3862
|
+
large: "large"
|
|
3863
|
+
};
|
|
3864
|
+
var TIME_PICKER_INTERVAL = {
|
|
3865
|
+
hourStep: 1,
|
|
3866
|
+
minuteStep: 1,
|
|
3867
|
+
secondStep: 1
|
|
3868
|
+
};
|
|
3869
|
+
var TimePicker = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
3870
|
+
var _ref$className = _ref.className,
|
|
3871
|
+
className = _ref$className === void 0 ? "" : _ref$className,
|
|
3872
|
+
_ref$label = _ref.label,
|
|
3873
|
+
label = _ref$label === void 0 ? "" : _ref$label,
|
|
3874
|
+
_ref$size = _ref.size,
|
|
3875
|
+
size = _ref$size === void 0 ? INPUT_SIZES.medium : _ref$size,
|
|
3876
|
+
_ref$dropdownClassNam = _ref.dropdownClassName,
|
|
3877
|
+
dropdownClassName = _ref$dropdownClassNam === void 0 ? "" : _ref$dropdownClassNam,
|
|
3878
|
+
_ref$popupClassName = _ref.popupClassName,
|
|
3879
|
+
popupClassName = _ref$popupClassName === void 0 ? "" : _ref$popupClassName,
|
|
3880
|
+
_ref$format = _ref.format,
|
|
3881
|
+
format = _ref$format === void 0 ? "HH:mm:ss" : _ref$format,
|
|
3882
|
+
_ref$interval = _ref.interval,
|
|
3883
|
+
interval = _ref$interval === void 0 ? TIME_PICKER_INTERVAL : _ref$interval,
|
|
3884
|
+
_ref$onChange = _ref.onChange,
|
|
3885
|
+
onChange = _ref$onChange === void 0 ? noop : _ref$onChange,
|
|
3886
|
+
_ref$type = _ref.type,
|
|
3887
|
+
type = _ref$type === void 0 ? "time" : _ref$type,
|
|
3888
|
+
_ref$nakedInput = _ref.nakedInput,
|
|
3889
|
+
nakedInput = _ref$nakedInput === void 0 ? false : _ref$nakedInput,
|
|
3890
|
+
_ref$disabled = _ref.disabled,
|
|
3891
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
3892
|
+
_ref$error = _ref.error,
|
|
3893
|
+
error = _ref$error === void 0 ? "" : _ref$error,
|
|
3894
|
+
defaultValue = _ref.defaultValue,
|
|
3895
|
+
value = _ref.value,
|
|
3896
|
+
labelProps = _ref.labelProps,
|
|
3897
|
+
_ref$required = _ref.required,
|
|
3898
|
+
required = _ref$required === void 0 ? false : _ref$required,
|
|
3899
|
+
otherProps = _objectWithoutProperties(_ref, _excluded$1);
|
|
3900
|
+
var id = useId(otherProps.id);
|
|
3901
|
+
var timePickerRef = useSyncedRef(ref);
|
|
3902
|
+
var Component = TIME_PICKER_TYPES[type.toLowerCase()];
|
|
3903
|
+
var errorId = "error_".concat(id);
|
|
3904
|
+
var showTimeLabels = {};
|
|
3905
|
+
if (format.includes("s")) {
|
|
3906
|
+
showTimeLabels.second = true;
|
|
3907
|
+
}
|
|
3908
|
+
if (format.includes("m")) {
|
|
3909
|
+
showTimeLabels.minute = true;
|
|
3910
|
+
}
|
|
3911
|
+
if (format.includes("H") || format.includes("h")) {
|
|
3912
|
+
showTimeLabels.hour = true;
|
|
3913
|
+
}
|
|
3914
|
+
var handleOnChange = function handleOnChange(time, timeString) {
|
|
3915
|
+
type === "range" && !time ? onChange([], timeString) : onChange(time, timeString);
|
|
3916
|
+
};
|
|
3917
|
+
var panelRender = function panelRender(originalPanel) {
|
|
3918
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
3919
|
+
className: "neeto-ui-date-input-custom-panel"
|
|
3920
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
3921
|
+
className: "neeto-ui-date-input-custom-panel__header"
|
|
3922
|
+
}, /*#__PURE__*/React__default.createElement("ul", {
|
|
3923
|
+
className: "neeto-ui-date-input-custom-panel__header-cols"
|
|
3924
|
+
}, showTimeLabels.hour && /*#__PURE__*/React__default.createElement("li", {
|
|
3925
|
+
className: "neeto-ui-date-input-custom-panel__header-col"
|
|
3926
|
+
}, "Hour"), showTimeLabels.minute && /*#__PURE__*/React__default.createElement("li", {
|
|
3927
|
+
className: "neeto-ui-date-input-custom-panel__header-col"
|
|
3928
|
+
}, "Minutes"), showTimeLabels.second && /*#__PURE__*/React__default.createElement("li", {
|
|
3929
|
+
className: "neeto-ui-date-input-custom-panel__header-col"
|
|
3930
|
+
}, "Seconds"))), /*#__PURE__*/React__default.createElement("div", {
|
|
3931
|
+
className: "neeto-ui-date-input-custom-panel__body"
|
|
3932
|
+
}, originalPanel));
|
|
3933
|
+
};
|
|
3934
|
+
return /*#__PURE__*/React__default.createElement(_ConfigProvider, {
|
|
3935
|
+
theme: {
|
|
3936
|
+
token: _objectSpread$2({}, ANT_DESIGN_GLOBAL_TOKEN_OVERRIDES),
|
|
3937
|
+
components: {
|
|
3938
|
+
DatePicker: {
|
|
3939
|
+
// Global overrides
|
|
3940
|
+
colorBgElevated: "rgb(var(--neeto-ui-white))",
|
|
3941
|
+
colorPrimary: "rgb(var(--neeto-ui-primary-500))",
|
|
3942
|
+
colorPrimaryHover: "rgb(var(--neeto-ui-primary-600))",
|
|
3943
|
+
colorBorder: "rgb(var(--neeto-ui-gray-300))",
|
|
3944
|
+
colorLink: "rgb(var(--neeto-ui-primary-500))",
|
|
3945
|
+
colorLinkHover: "rgb(var(--neeto-ui-primary-600))",
|
|
3946
|
+
colorText: "rgb(var(--neeto-ui-gray-800))",
|
|
3947
|
+
colorTextDisabled: "rgb(var(--neeto-ui-gray-500))",
|
|
3948
|
+
colorTextPlaceholder: "rgb(var(--neeto-ui-gray-400))",
|
|
3949
|
+
controlItemBgActive: "rgb(var(--neeto-ui-primary-800))",
|
|
3950
|
+
controlItemBgHover: "rgb(var(--neeto-ui-gray-100))",
|
|
3951
|
+
controlOutline: "rgb(var(--neeto-ui-gray-300))"
|
|
3952
|
+
}
|
|
3953
|
+
}
|
|
3954
|
+
}
|
|
3955
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
3956
|
+
className: "neeto-ui-input__wrapper"
|
|
3957
|
+
}, label && /*#__PURE__*/React__default.createElement(Label, _objectSpread$2({
|
|
3958
|
+
required: required
|
|
3959
|
+
}, labelProps), label), /*#__PURE__*/React__default.createElement(Component, _extends({
|
|
3960
|
+
hourStep: interval.hourStep,
|
|
3961
|
+
minuteStep: interval.minuteStep,
|
|
3962
|
+
ref: timePickerRef,
|
|
3963
|
+
secondStep: interval.secondStep,
|
|
3964
|
+
className: classnames("neeto-ui-time-input", [className], {
|
|
3965
|
+
"neeto-ui-time-input--small": size === "small",
|
|
3966
|
+
"neeto-ui-time-input--medium": size === "medium",
|
|
3967
|
+
"neeto-ui-time-input--large": size === "large",
|
|
3968
|
+
"neeto-ui-time-input--disabled": disabled,
|
|
3969
|
+
"neeto-ui-time-input--naked": nakedInput,
|
|
3970
|
+
"neeto-ui-time-input--error": error
|
|
3971
|
+
}),
|
|
3972
|
+
popupClassName: classnames("neeto-ui-date-time-dropdown", [dropdownClassName,
|
|
3973
|
+
// Will be removed in the next major version
|
|
3974
|
+
popupClassName]),
|
|
3975
|
+
onChange: handleOnChange
|
|
3976
|
+
}, _objectSpread$2(_objectSpread$2({
|
|
3977
|
+
disabled: disabled,
|
|
3978
|
+
format: format
|
|
3979
|
+
}, otherProps), {}, {
|
|
3980
|
+
panelRender: panelRender
|
|
3981
|
+
}), {
|
|
3982
|
+
defaultValue: convertToDayjsObjects(defaultValue),
|
|
3983
|
+
mode: undefined,
|
|
3984
|
+
picker: "time",
|
|
3985
|
+
suffixIcon: /*#__PURE__*/React__default.createElement(Clock, {
|
|
3986
|
+
size: 16
|
|
3987
|
+
}),
|
|
3988
|
+
value: convertToDayjsObjects(value)
|
|
3989
|
+
})), !!error && /*#__PURE__*/React__default.createElement("p", {
|
|
3990
|
+
className: "neeto-ui-input__error",
|
|
3991
|
+
"data-cy": "".concat(hyphenize(label), "-input-error"),
|
|
3992
|
+
id: errorId
|
|
3993
|
+
}, error)));
|
|
3994
|
+
});
|
|
3995
|
+
TimePicker.displayName = "TimePicker";
|
|
3996
|
+
|
|
3997
|
+
/**
|
|
3998
|
+
* Given a string, converts to an array of valid React components
|
|
3999
|
+
* (which may include strings)
|
|
4000
|
+
* @param {string} str
|
|
4001
|
+
* @param {Options} opts
|
|
4002
|
+
* @param {{ [elementId: string]: number }} meta
|
|
4003
|
+
* @returns {React.ReactNodeArray}
|
|
4004
|
+
*/
|
|
4005
|
+
function stringToElements(str, opts, meta) {
|
|
4006
|
+
const tokens = tokenize(str);
|
|
4007
|
+
const elements = [];
|
|
4008
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
4009
|
+
const token = tokens[i];
|
|
4010
|
+
if (token.t === 'nl' && opts.get('nl2br')) {
|
|
4011
|
+
const key = `__linkify-el-${meta.elementId++}`;
|
|
4012
|
+
elements.push(React.createElement('br', {
|
|
4013
|
+
key
|
|
4014
|
+
}));
|
|
4015
|
+
} else if (!token.isLink || !opts.check(token)) {
|
|
4016
|
+
// Regular text
|
|
4017
|
+
elements.push(token.toString());
|
|
4018
|
+
} else {
|
|
4019
|
+
let rendered = opts.render(token);
|
|
4020
|
+
if (!('key' in rendered.props)) {
|
|
4021
|
+
// Ensure generated element has unique key
|
|
4022
|
+
const key = `__linkify-el-${meta.elementId++}`;
|
|
4023
|
+
const props = options.assign({
|
|
4024
|
+
key
|
|
4025
|
+
}, rendered.props);
|
|
4026
|
+
rendered = React.cloneElement(rendered, props);
|
|
4027
|
+
}
|
|
4028
|
+
elements.push(rendered);
|
|
4029
|
+
}
|
|
4030
|
+
}
|
|
4031
|
+
return elements;
|
|
4032
|
+
}
|
|
4033
|
+
|
|
4034
|
+
// Recursively linkify the contents of the given React Element instance
|
|
4035
|
+
/**
|
|
4036
|
+
* @template P
|
|
4037
|
+
* @template {string | React.JSXElementConstructor<P>} T
|
|
4038
|
+
* @param {React.ReactElement<P, T>} element
|
|
4039
|
+
* @param {Options} opts
|
|
4040
|
+
* @param {{ [elementId: string]: number }} meta
|
|
4041
|
+
* @returns {React.ReactElement<P, T>}
|
|
4042
|
+
*/
|
|
4043
|
+
function linkifyReactElement(element, opts, meta) {
|
|
4044
|
+
if (React.Children.count(element.props.children) === 0) {
|
|
4045
|
+
// No need to clone if the element had no children
|
|
4046
|
+
return element;
|
|
4047
|
+
}
|
|
4048
|
+
const children = [];
|
|
4049
|
+
React.Children.forEach(element.props.children, child => {
|
|
4050
|
+
if (typeof child === 'string') {
|
|
4051
|
+
// ensure that we always generate unique element IDs for keys
|
|
4052
|
+
children.push.apply(children, stringToElements(child, opts, meta));
|
|
4053
|
+
} else if (React.isValidElement(child)) {
|
|
4054
|
+
if (typeof child.type === 'string' && opts.ignoreTags.indexOf(child.type.toUpperCase()) >= 0) {
|
|
4055
|
+
// Don't linkify this element
|
|
4056
|
+
children.push(child);
|
|
4057
|
+
} else {
|
|
4058
|
+
children.push(linkifyReactElement(child, opts, meta));
|
|
4059
|
+
}
|
|
4060
|
+
} else {
|
|
4061
|
+
// Unknown element type, just push
|
|
4062
|
+
children.push(child);
|
|
4063
|
+
}
|
|
4064
|
+
});
|
|
4065
|
+
|
|
4066
|
+
// Set a default unique key, copy over remaining props
|
|
4067
|
+
const key = `__linkify-el-${meta.elementId++}`;
|
|
4068
|
+
const newProps = options.assign({
|
|
4069
|
+
key
|
|
4070
|
+
}, element.props);
|
|
4071
|
+
return React.cloneElement(element, newProps, children);
|
|
4072
|
+
}
|
|
4073
|
+
|
|
4074
|
+
/**
|
|
4075
|
+
* @template P
|
|
4076
|
+
* @template {string | React.JSXElementConstructor<P>} T
|
|
4077
|
+
* @param {P & { as?: T, tagName?: T, options?: import('linkifyjs').Opts, children?: React.ReactNode}} props
|
|
4078
|
+
* @returns {React.ReactElement<P, T>}
|
|
4079
|
+
*/
|
|
4080
|
+
const Linkify = props => {
|
|
4081
|
+
// Copy over all non-linkify-specific props
|
|
4082
|
+
let linkId = 0;
|
|
4083
|
+
const defaultLinkRender = _ref => {
|
|
4084
|
+
let {
|
|
4085
|
+
tagName,
|
|
4086
|
+
attributes,
|
|
4087
|
+
content
|
|
4088
|
+
} = _ref;
|
|
4089
|
+
attributes.key = `__linkify-lnk-${linkId++}`;
|
|
4090
|
+
if (attributes.class) {
|
|
4091
|
+
attributes.className = attributes.class;
|
|
4092
|
+
delete attributes.class;
|
|
4093
|
+
}
|
|
4094
|
+
return React.createElement(tagName, attributes, content);
|
|
4095
|
+
};
|
|
4096
|
+
const newProps = {
|
|
4097
|
+
key: '__linkify-wrapper'
|
|
4098
|
+
};
|
|
4099
|
+
for (const prop in props) {
|
|
4100
|
+
if (prop !== 'options' && prop !== 'as' && prop !== 'tagName' && prop !== 'children') {
|
|
4101
|
+
newProps[prop] = props[prop];
|
|
4102
|
+
}
|
|
4103
|
+
}
|
|
4104
|
+
const opts = new Options(props.options, defaultLinkRender);
|
|
4105
|
+
const as = props.as || props.tagName || React.Fragment || 'span';
|
|
4106
|
+
const children = props.children;
|
|
4107
|
+
const element = React.createElement(as, newProps, children);
|
|
4108
|
+
return linkifyReactElement(element, opts, {
|
|
4109
|
+
elementId: 0
|
|
4110
|
+
});
|
|
4111
|
+
};
|
|
4112
|
+
|
|
4113
|
+
var Toast = function Toast(_ref) {
|
|
4114
|
+
var type = _ref.type,
|
|
4115
|
+
message = _ref.message,
|
|
4116
|
+
_ref$buttonLabel = _ref.buttonLabel,
|
|
4117
|
+
buttonLabel = _ref$buttonLabel === void 0 ? "" : _ref$buttonLabel,
|
|
4118
|
+
_ref$onClick = _ref.onClick,
|
|
4119
|
+
_onClick = _ref$onClick === void 0 ? noop : _ref$onClick;
|
|
4120
|
+
return /*#__PURE__*/React__default.createElement("div", {
|
|
4121
|
+
"data-cy": "toastr-message-container",
|
|
4122
|
+
"data-test": "toastr-".concat(type, "-container")
|
|
4123
|
+
}, /*#__PURE__*/React__default.createElement(Linkify, {
|
|
4124
|
+
options: {
|
|
4125
|
+
defaultProtocol: "https",
|
|
4126
|
+
rel: "noreferrer",
|
|
4127
|
+
target: "_blank"
|
|
4128
|
+
}
|
|
4129
|
+
}, /*#__PURE__*/React__default.createElement("p", null, message)), buttonLabel && /*#__PURE__*/React__default.createElement("div", {
|
|
4130
|
+
className: "toastr-message-container__btn-wrapper"
|
|
4131
|
+
}, /*#__PURE__*/React__default.createElement("button", {
|
|
4132
|
+
className: "neeto-ui-btn neeto-ui-btn--style-secondary",
|
|
4133
|
+
"data-cy": "toastr-".concat(type, "-button"),
|
|
4134
|
+
onClick: function onClick(e) {
|
|
4135
|
+
e.stopPropagation();
|
|
4136
|
+
_onClick();
|
|
4137
|
+
}
|
|
4138
|
+
}, buttonLabel)));
|
|
4139
|
+
};
|
|
4140
|
+
|
|
4141
|
+
var _excluded = ["closeToast"],
|
|
4142
|
+
_excluded2 = ["buttonLabel", "onClick"];
|
|
4143
|
+
function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4144
|
+
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$1(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4145
|
+
var TOAST_CONFIG = {
|
|
4146
|
+
autoClose: 3500,
|
|
4147
|
+
transition: Slide,
|
|
4148
|
+
position: toast.POSITION.BOTTOM_LEFT,
|
|
4149
|
+
hideProgressBar: true,
|
|
4150
|
+
closeButton: function closeButton(_ref) {
|
|
4151
|
+
var closeToast = _ref.closeToast,
|
|
4152
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
4153
|
+
return /*#__PURE__*/React__default.createElement(Close, _extends({
|
|
4154
|
+
className: "neeto-ui-toastr__close-button",
|
|
4155
|
+
color: "currentColor",
|
|
4156
|
+
"data-cy": "toastr-close-button",
|
|
4157
|
+
size: 16,
|
|
4158
|
+
onClick: closeToast
|
|
4159
|
+
}, props));
|
|
4160
|
+
},
|
|
4161
|
+
role: "log",
|
|
4162
|
+
className: "neeto-ui-toastr"
|
|
4163
|
+
};
|
|
4164
|
+
var TOAST_ICON = {
|
|
4165
|
+
success: /*#__PURE__*/React__default.createElement(CheckCircle, {
|
|
4166
|
+
className: "neeto-ui-text-white",
|
|
4167
|
+
"data-cy": "success-toast-icon"
|
|
4168
|
+
}),
|
|
4169
|
+
warning: /*#__PURE__*/React__default.createElement(Warning, {
|
|
4170
|
+
className: "neeto-ui-text-white",
|
|
4171
|
+
"data-cy": "warning-toast-icon"
|
|
4172
|
+
}),
|
|
4173
|
+
error: /*#__PURE__*/React__default.createElement(CloseCircle, {
|
|
4174
|
+
className: "neeto-ui-white",
|
|
4175
|
+
"data-cy": "error-toast-icon"
|
|
4176
|
+
}),
|
|
4177
|
+
info: /*#__PURE__*/React__default.createElement(Info, {
|
|
4178
|
+
className: "neeto-ui-text-white",
|
|
4179
|
+
"data-cy": "info-toast-icon"
|
|
4180
|
+
})
|
|
4181
|
+
};
|
|
4182
|
+
var toastrList = new UniqueArray();
|
|
4183
|
+
var parseToastrConfig = function parseToastrConfig(config) {
|
|
4184
|
+
if (_typeof(config[0]) === "object") {
|
|
4185
|
+
var _config$ = config[0],
|
|
4186
|
+
_buttonLabel = _config$.buttonLabel,
|
|
4187
|
+
_onClick = _config$.onClick,
|
|
4188
|
+
_customConfig = _objectWithoutProperties(_config$, _excluded2);
|
|
4189
|
+
return {
|
|
4190
|
+
buttonLabel: _buttonLabel,
|
|
4191
|
+
onClick: _onClick,
|
|
4192
|
+
customConfig: _customConfig
|
|
4193
|
+
};
|
|
4194
|
+
}
|
|
4195
|
+
var _config = _slicedToArray(config, 3),
|
|
4196
|
+
buttonLabel = _config[0],
|
|
4197
|
+
onClick = _config[1],
|
|
4198
|
+
customConfig = _config[2];
|
|
4199
|
+
return {
|
|
4200
|
+
buttonLabel: buttonLabel,
|
|
4201
|
+
onClick: onClick,
|
|
4202
|
+
customConfig: customConfig
|
|
4203
|
+
};
|
|
4204
|
+
};
|
|
4205
|
+
var getToastrMessage = function getToastrMessage(message) {
|
|
4206
|
+
if ((message === null || message === void 0 ? void 0 : message.noticeCode) === "custom_message" && "customMessage" in message) {
|
|
4207
|
+
return message.customMessage;
|
|
4208
|
+
} else if (_typeof(message) === "object" && message.noticeCode) {
|
|
4209
|
+
return t(message.noticeCode, message);
|
|
4210
|
+
} else if (_typeof(message) === "object" && message.notice) {
|
|
4211
|
+
return message.notice;
|
|
4212
|
+
}
|
|
4213
|
+
return message;
|
|
4214
|
+
};
|
|
4215
|
+
var withUniqueCheck = function withUniqueCheck(type, toastFunc) {
|
|
4216
|
+
return function (message) {
|
|
4217
|
+
message = getToastrMessage(message);
|
|
4218
|
+
for (var _len = arguments.length, toastrConfig = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
4219
|
+
toastrConfig[_key - 1] = arguments[_key];
|
|
4220
|
+
}
|
|
4221
|
+
var _parseToastrConfig = parseToastrConfig(toastrConfig),
|
|
4222
|
+
buttonLabel = _parseToastrConfig.buttonLabel,
|
|
4223
|
+
onClick = _parseToastrConfig.onClick,
|
|
4224
|
+
_parseToastrConfig$cu = _parseToastrConfig.customConfig,
|
|
4225
|
+
customConfig = _parseToastrConfig$cu === void 0 ? {} : _parseToastrConfig$cu;
|
|
4226
|
+
if (toastrList.add({
|
|
4227
|
+
type: type,
|
|
4228
|
+
message: message,
|
|
4229
|
+
buttonLabel: buttonLabel
|
|
4230
|
+
})) {
|
|
4231
|
+
var config = _objectSpread$1(_objectSpread$1({}, TOAST_CONFIG), {}, {
|
|
4232
|
+
icon: TOAST_ICON[type],
|
|
4233
|
+
onClose: function onClose() {
|
|
4234
|
+
return toastrList.remove({
|
|
4235
|
+
type: type,
|
|
4236
|
+
message: message,
|
|
4237
|
+
buttonLabel: buttonLabel
|
|
4238
|
+
});
|
|
4239
|
+
}
|
|
4240
|
+
}, customConfig);
|
|
4241
|
+
toastFunc({
|
|
4242
|
+
message: message,
|
|
4243
|
+
buttonLabel: buttonLabel,
|
|
4244
|
+
onClick: onClick,
|
|
4245
|
+
config: config
|
|
4246
|
+
});
|
|
4247
|
+
}
|
|
4248
|
+
};
|
|
4249
|
+
};
|
|
4250
|
+
var showSuccessToastr = withUniqueCheck("success", function (_ref2) {
|
|
4251
|
+
var message = _ref2.message,
|
|
4252
|
+
buttonLabel = _ref2.buttonLabel,
|
|
4253
|
+
onClick = _ref2.onClick,
|
|
4254
|
+
config = _ref2.config;
|
|
4255
|
+
return toast.success( /*#__PURE__*/React__default.createElement(Toast, {
|
|
4256
|
+
buttonLabel: buttonLabel,
|
|
4257
|
+
message: message,
|
|
4258
|
+
type: "success",
|
|
4259
|
+
onClick: onClick
|
|
4260
|
+
}), config);
|
|
4261
|
+
});
|
|
4262
|
+
var showInfoToastr = withUniqueCheck("info", function (_ref3) {
|
|
4263
|
+
var message = _ref3.message,
|
|
4264
|
+
buttonLabel = _ref3.buttonLabel,
|
|
4265
|
+
onClick = _ref3.onClick,
|
|
4266
|
+
config = _ref3.config;
|
|
4267
|
+
return toast.info( /*#__PURE__*/React__default.createElement(Toast, {
|
|
4268
|
+
buttonLabel: buttonLabel,
|
|
4269
|
+
message: message,
|
|
4270
|
+
type: "info",
|
|
4271
|
+
onClick: onClick
|
|
4272
|
+
}), config);
|
|
4273
|
+
});
|
|
4274
|
+
var showWarningToastr = withUniqueCheck("warning", function (_ref4) {
|
|
4275
|
+
var message = _ref4.message,
|
|
4276
|
+
buttonLabel = _ref4.buttonLabel,
|
|
4277
|
+
onClick = _ref4.onClick,
|
|
4278
|
+
config = _ref4.config;
|
|
4279
|
+
return toast.warning( /*#__PURE__*/React__default.createElement(Toast, {
|
|
4280
|
+
buttonLabel: buttonLabel,
|
|
4281
|
+
message: message,
|
|
4282
|
+
type: "warning",
|
|
4283
|
+
onClick: onClick
|
|
4284
|
+
}), config);
|
|
4285
|
+
});
|
|
4286
|
+
var isError = function isError(e) {
|
|
4287
|
+
return e && e.stack && e.message;
|
|
4288
|
+
};
|
|
4289
|
+
var isAxiosError = function isAxiosError(e) {
|
|
4290
|
+
return _typeof(e) === "object" && e.isAxiosError === true;
|
|
4291
|
+
};
|
|
4292
|
+
var isString = function isString(s) {
|
|
4293
|
+
return typeof s === "string" || s instanceof String;
|
|
4294
|
+
};
|
|
4295
|
+
var isErrorCodeObject = function isErrorCodeObject(e) {
|
|
4296
|
+
return _typeof(e) === "object" && "key" in e && "context" in e;
|
|
4297
|
+
};
|
|
4298
|
+
var errorCodeTranslation = function errorCodeTranslation(errorCode) {
|
|
4299
|
+
if (typeof errorCode === "string") {
|
|
4300
|
+
return t(errorCode);
|
|
4301
|
+
} else if (isErrorCodeObject(errorCode)) {
|
|
4302
|
+
return t(errorCode.key, errorCode.context);
|
|
4303
|
+
}
|
|
4304
|
+
return undefined;
|
|
4305
|
+
};
|
|
4306
|
+
var getErrorMessage = function getErrorMessage(response) {
|
|
4307
|
+
var _response$error = response.error,
|
|
4308
|
+
error = _response$error === void 0 ? "" : _response$error,
|
|
4309
|
+
_response$errors = response.errors,
|
|
4310
|
+
errors = _response$errors === void 0 ? [] : _response$errors,
|
|
4311
|
+
_response$errorCode = response.errorCode,
|
|
4312
|
+
errorCode = _response$errorCode === void 0 ? "" : _response$errorCode,
|
|
4313
|
+
_response$errorCodes = response.errorCodes,
|
|
4314
|
+
errorCodes = _response$errorCodes === void 0 ? [] : _response$errorCodes;
|
|
4315
|
+
var errorMessages = error || (errors === null || errors === void 0 ? void 0 : errors.join("\n"));
|
|
4316
|
+
var errorCodeTranslations = errorCode && t(errorCode, response) || (errorCodes === null || errorCodes === void 0 ? void 0 : errorCodes.map(errorCodeTranslation).join("\n"));
|
|
4317
|
+
if (errorMessages && errorCodeTranslations) {
|
|
4318
|
+
return [errorMessages, errorCodeTranslations].join("\n");
|
|
4319
|
+
}
|
|
4320
|
+
return errorMessages || errorCodeTranslations;
|
|
4321
|
+
};
|
|
4322
|
+
var withParsedErrorMsg = function withParsedErrorMsg(toastrFunc) {
|
|
4323
|
+
return function (errorObject) {
|
|
4324
|
+
var _errorObject;
|
|
4325
|
+
var errorMessage;
|
|
4326
|
+
errorObject = getToastrMessage(errorObject);
|
|
4327
|
+
var responseData = ((_errorObject = errorObject) === null || _errorObject === void 0 || (_errorObject = _errorObject.response) === null || _errorObject === void 0 ? void 0 : _errorObject.data) || {};
|
|
4328
|
+
if (responseData.noticeCode === "custom_message" && "customMessage" in responseData) {
|
|
4329
|
+
errorMessage = responseData.customMessage;
|
|
4330
|
+
} else if (responseData !== null && responseData !== void 0 && responseData.noticeCode) {
|
|
4331
|
+
var data = errorObject.response.data;
|
|
4332
|
+
errorMessage = t(data.noticeCode, data);
|
|
4333
|
+
} else if (isAxiosError(errorObject)) {
|
|
4334
|
+
errorMessage = getErrorMessage(responseData) || errorObject.message;
|
|
4335
|
+
} else if (isError(errorObject)) errorMessage = errorObject.message;else if (isString(errorObject)) errorMessage = errorObject;else errorMessage = "Something went wrong.";
|
|
4336
|
+
for (var _len2 = arguments.length, toastrConfig = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
4337
|
+
toastrConfig[_key2 - 1] = arguments[_key2];
|
|
4338
|
+
}
|
|
4339
|
+
var _parseToastrConfig2 = parseToastrConfig(toastrConfig),
|
|
4340
|
+
buttonLabel = _parseToastrConfig2.buttonLabel,
|
|
4341
|
+
onClick = _parseToastrConfig2.onClick,
|
|
4342
|
+
customConfig = _parseToastrConfig2.customConfig;
|
|
4343
|
+
toastrFunc(errorMessage, _objectSpread$1({
|
|
4344
|
+
buttonLabel: buttonLabel,
|
|
4345
|
+
onClick: onClick,
|
|
4346
|
+
role: "alert",
|
|
4347
|
+
autoClose: false
|
|
4348
|
+
}, customConfig));
|
|
4349
|
+
};
|
|
4350
|
+
};
|
|
4351
|
+
var showErrorToastr = withParsedErrorMsg(withUniqueCheck("error", function (_ref5) {
|
|
4352
|
+
var message = _ref5.message,
|
|
4353
|
+
buttonLabel = _ref5.buttonLabel,
|
|
4354
|
+
onClick = _ref5.onClick,
|
|
4355
|
+
config = _ref5.config;
|
|
4356
|
+
return toast.error( /*#__PURE__*/React__default.createElement(Toast, {
|
|
4357
|
+
buttonLabel: buttonLabel,
|
|
4358
|
+
message: message,
|
|
4359
|
+
type: "error",
|
|
4360
|
+
onClick: onClick
|
|
4361
|
+
}), config);
|
|
4362
|
+
}));
|
|
4363
|
+
var Toastr = {
|
|
4364
|
+
info: showInfoToastr,
|
|
4365
|
+
show: showInfoToastr,
|
|
4366
|
+
success: showSuccessToastr,
|
|
4367
|
+
error: showErrorToastr,
|
|
4368
|
+
warning: showWarningToastr
|
|
4369
|
+
};
|
|
4370
|
+
|
|
4371
|
+
var SwitcherIcon = function SwitcherIcon(_ref) {
|
|
4372
|
+
var expanded = _ref.expanded;
|
|
4373
|
+
return expanded ? /*#__PURE__*/React__default.createElement(Down, {
|
|
4374
|
+
size: 16
|
|
4375
|
+
}) : /*#__PURE__*/React__default.createElement(Right, {
|
|
4376
|
+
size: 16
|
|
4377
|
+
});
|
|
4378
|
+
};
|
|
4379
|
+
|
|
4380
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4381
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4382
|
+
var Tree = function Tree(props) {
|
|
4383
|
+
return /*#__PURE__*/React__default.createElement(_ConfigProvider, {
|
|
4384
|
+
theme: {
|
|
4385
|
+
token: _objectSpread({}, ANT_DESIGN_GLOBAL_TOKEN_OVERRIDES),
|
|
4386
|
+
components: {
|
|
4387
|
+
Tree: {
|
|
4388
|
+
directoryNodeSelectedBg: "rgb(var(--neeto-ui-primary-500))",
|
|
4389
|
+
directoryNodeSelectedColor: "rgb(var(--neeto-ui-white))",
|
|
4390
|
+
nodeHoverBg: "rgb(var(--neeto-ui-gray-100))",
|
|
4391
|
+
nodeSelectedBg: "rgb(var(--neeto-ui-primary-100))"
|
|
4392
|
+
}
|
|
4393
|
+
}
|
|
4394
|
+
}
|
|
4395
|
+
}, /*#__PURE__*/React__default.createElement(_Tree, _extends({
|
|
4396
|
+
switcherIcon: SwitcherIcon
|
|
4397
|
+
}, props, {
|
|
4398
|
+
className: classnames("neeto-ui-tree", props.className)
|
|
4399
|
+
})));
|
|
4400
|
+
};
|
|
4401
|
+
|
|
4402
|
+
export { Accordion, ActionDropdown, Callout, ColorPicker, DatePicker, index as DateTimePicker, Dropdown, Kbd, NoData, Pagination, Pane, Popover, Stepper, Tab, Table, TimePicker, TimePickerInput, Toastr, Tree };
|
|
4403
|
+
//# sourceMappingURL=index.js.map
|