@scaleflex/widget-common 4.4.0 → 4.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/style.css +1126 -0
- package/dist/style.min.css +1 -0
- package/lib/ApprovalStatus/ApprovalStatus.styled.js +21 -0
- package/lib/ApprovalStatus/index.js +104 -0
- package/lib/AssetPreview.js +53 -0
- package/lib/AutoSuggest.js +166 -0
- package/lib/Avatar/Avatar.styled.js +25 -0
- package/lib/Avatar/index.js +83 -0
- package/lib/AvatarWithStatus/AvatarWithStatus.styled.js +12 -0
- package/lib/AvatarWithStatus/index.js +30 -0
- package/lib/BackButton.js +46 -0
- package/lib/BackdropOverlay.js +77 -0
- package/lib/BadgeButton.js +35 -0
- package/lib/BaseButton.js +36 -0
- package/lib/Button.js +29 -0
- package/lib/Carousel/Carousel.styled.js +19 -0
- package/lib/Carousel/index.js +136 -0
- package/lib/Checkbox.js +55 -0
- package/lib/CloseButton.js +46 -0
- package/lib/ColorPicker/ColorPicker.styled.js +29 -0
- package/lib/ColorPicker/index.js +117 -0
- package/lib/ColorPickerModal/ColorPickerModal.styled.js +17 -0
- package/lib/ColorPickerModal/index.js +103 -0
- package/lib/DatePicker/MyDatePicker.js +350 -0
- package/lib/DatePicker/index.js +1 -0
- package/lib/DropFilesWindow.js +45 -0
- package/lib/FilterItem/FilterItem.styled.js +42 -0
- package/lib/FilterItem/index.js +48 -0
- package/lib/FilterPopup/FilterPopup.styled.js +16 -0
- package/lib/FilterPopup/index.js +85 -0
- package/lib/FormControl.js +25 -0
- package/lib/FormGroup.js +18 -0
- package/lib/FormHelperText.js +29 -0
- package/lib/IconLabeledButton.js +32 -0
- package/lib/Image/Image.styled.js +16 -0
- package/lib/Image/index.js +95 -0
- package/lib/ImagePreview/ImagePreview.styled.js +19 -0
- package/lib/ImagePreview/index.js +198 -0
- package/lib/InputAndLabel.js +77 -0
- package/lib/InputGroupTime.js +6 -0
- package/lib/InputLabel.js +18 -0
- package/lib/ItemButtonOverlay/ItemButtonOverlay.styled.js +33 -0
- package/lib/ItemButtonOverlay/index.js +23 -0
- package/lib/ItemHoverTopOptions.js +58 -0
- package/lib/LoaderView/LoaderView.styled.js +37 -0
- package/lib/LoaderView/index.js +32 -0
- package/lib/MetaData/FilterMetadataFields.js +115 -0
- package/lib/MetaData/FilterMetadataFields.styled.js +16 -0
- package/lib/MetaData/MetaDataField.js +246 -0
- package/lib/MetaData/MetaDataFieldTypes/MetaDataFieldBooleanType.js +36 -0
- package/lib/MetaData/MetaDataFieldTypes/MetaDataFieldDateType.js +53 -0
- package/lib/MetaData/MetaDataFieldTypes/MetaDataFieldMultiSelectType.js +71 -0
- package/lib/MetaData/MetaDataFieldTypes/MetaDataFieldNumericType.js +45 -0
- package/lib/MetaData/MetaDataFieldTypes/MetaDataFieldSelectType.js +69 -0
- package/lib/MetaData/MetaDataFieldTypes/MetaDataFieldTagsType.js +143 -0
- package/lib/MetaData/MetaDataFieldTypes/MetaDataFieldTextType.js +42 -0
- package/lib/MetaData/MetaDataFieldTypes/MetaDataFieldTextareaType.js +72 -0
- package/lib/MetaData/MetaDataFieldTypes/MetaDataFieldTypes.styled.js +57 -0
- package/lib/MetaData/MetaDataFieldTypes/MetadataAttachmentsFieldType/AttachmentsAssetsMetadataAccordion.styled.js +95 -0
- package/lib/MetaData/MetaDataFieldTypes/MetadataAttachmentsFieldType/MetadataAttachmentsAction.js +188 -0
- package/lib/MetaData/MetaDataFieldTypes/MetadataAttachmentsFieldType/MetadataAttachmentsFieldType.constants.js +48 -0
- package/lib/MetaData/MetaDataFieldTypes/MetadataAttachmentsFieldType/MetadataAttachmentsInfo.js +93 -0
- package/lib/MetaData/MetaDataFieldTypes/MetadataAttachmentsFieldType/index.js +114 -0
- package/lib/MetaData/MetaDataFieldTypes/MetadataFieldUriType.js +71 -0
- package/lib/MetaData/MetaDataFieldTypes/MetadataGeoPointField/MetadataGeoPointField.styled.js +8 -0
- package/lib/MetaData/MetaDataFieldTypes/MetadataGeoPointField/constants.js +10 -0
- package/lib/MetaData/MetaDataFieldTypes/MetadataGeoPointField/index.js +135 -0
- package/lib/MetaData/MetaDataFieldTypes/index.js +9 -0
- package/lib/MetaData/MetaDataFieldTypes.hooks.js +53 -0
- package/lib/OverlayCard/OverlayCard.styled.js +8 -0
- package/lib/OverlayCard/index.js +28 -0
- package/lib/PoweredBy.js +12 -0
- package/lib/Radiobox.js +63 -0
- package/lib/RegionalVariantsFilters/RegionalVariantFilters.styled.js +17 -0
- package/lib/RegionalVariantsFilters/index.js +160 -0
- package/lib/SVGUrlToElement.js +73 -0
- package/lib/SearchGroup/SearchGroup.styled.js +93 -0
- package/lib/SearchGroup/index.js +293 -0
- package/lib/Spinner.js +40 -0
- package/lib/SuggestedSelectInput/SuggestedSelectInput.styled.js +57 -0
- package/lib/SuggestedSelectInput/index.js +238 -0
- package/lib/SuggestedTagsInput/SuggestedTagsInput.js +295 -0
- package/lib/SuggestedTagsInput/SuggestedTagsInput.styled.js +83 -0
- package/lib/SuggestedTagsInput/SuggestedTagsInput.utils.js +15 -0
- package/lib/SuggestedTagsInput/SuggestedTagsInputSkeleton.js +14 -0
- package/lib/Tabs.js +62 -0
- package/lib/ToggleButton/ToggleButton.styled.js +16 -0
- package/lib/ToggleButton/index.js +16 -0
- package/lib/Transitions/SlideTransition.js +24 -0
- package/lib/Transitions/TransitionWrapper.js +83 -0
- package/lib/Transitions/Transitions.styled.js +8 -0
- package/lib/Transitions/index.js +2 -0
- package/lib/Typography/Typography.js +47 -0
- package/lib/Typography/Typography.mixin.js +46 -0
- package/lib/Typography/Typography.styled.js +18 -0
- package/lib/Typography/index.js +3 -0
- package/lib/Typography/types/index.js +1 -0
- package/lib/Typography/types/variant.js +9 -0
- package/lib/UploadFileFloatyLabel/UploadFileFloatyLabel.mixin.js +23 -0
- package/lib/UploadFileFloatyLabel/UploadFileFloatyLabel.styled.js +24 -0
- package/lib/UploadFileFloatyLabel/index.js +12 -0
- package/lib/UsersAutocomplete/Tag.js +25 -0
- package/lib/UsersAutocomplete/Tag.styled.js +35 -0
- package/lib/UsersAutocomplete/UsersAutocomplete.styled.js +94 -0
- package/lib/UsersAutocomplete/index.js +303 -0
- package/lib/VirtualGrid/VirtualGrid.styled.js +33 -0
- package/lib/VirtualGrid/VirtualGrid.utils.js +38 -0
- package/lib/VirtualGrid/VirtualGridItem.js +15 -0
- package/lib/VirtualGrid/index.js +252 -0
- package/lib/VirtualList/VirtualListItem.js +14 -0
- package/lib/VirtualList/index.js +105 -0
- package/lib/hooks/index.js +4 -0
- package/lib/hooks/useDebounce.js +24 -0
- package/lib/hooks/useInputWithLocaleNumber.js +115 -0
- package/lib/hooks/useIsUnMountedRef.js +12 -0
- package/lib/hooks/useKeyboardNavigation.js +60 -0
- package/lib/hooks/useUpdateEffect.js +19 -0
- package/lib/index.js +36 -0
- package/package.json +4 -4
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
2
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
4
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
5
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
7
|
+
import { useState, useRef } from 'react';
|
|
8
|
+
import { ColorPicker, Modal, ModalContent, ModalTitle } from '@scaleflex/ui/core';
|
|
9
|
+
import ColorPickerIcon from '@scaleflex/icons/color-picker';
|
|
10
|
+
import Styled from './ColorPickerModal.styled';
|
|
11
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
|
+
function ColorPickerModal(_ref) {
|
|
13
|
+
var _ref$defaultColor = _ref.defaultColor,
|
|
14
|
+
defaultColor = _ref$defaultColor === void 0 ? '' : _ref$defaultColor,
|
|
15
|
+
_ref$colors = _ref.colors,
|
|
16
|
+
colors = _ref$colors === void 0 ? [] : _ref$colors,
|
|
17
|
+
onChange = _ref.onChange,
|
|
18
|
+
onTmpChooseColor = _ref.onTmpChooseColor,
|
|
19
|
+
open = _ref.open,
|
|
20
|
+
onClose = _ref.onClose,
|
|
21
|
+
_ref$i18n = _ref.i18n,
|
|
22
|
+
i18n = _ref$i18n === void 0 ? function () {} : _ref$i18n,
|
|
23
|
+
_ref$modalTitleLabel = _ref.modalTitleLabel,
|
|
24
|
+
modalTitleLabel = _ref$modalTitleLabel === void 0 ? i18n('colorPickerModalTitle') : _ref$modalTitleLabel,
|
|
25
|
+
_ref$cancelButtonLabe = _ref.cancelButtonLabel,
|
|
26
|
+
cancelButtonLabel = _ref$cancelButtonLabe === void 0 ? i18n('mutualizedCancelButtonLabel') : _ref$cancelButtonLabe,
|
|
27
|
+
_ref$saveButtonLabel = _ref.saveButtonLabel,
|
|
28
|
+
saveButtonLabel = _ref$saveButtonLabel === void 0 ? i18n('mutualizedApplyButtonLabel') : _ref$saveButtonLabel,
|
|
29
|
+
showTransparentColor = _ref.showTransparentColor,
|
|
30
|
+
hidePinIcon = _ref.hidePinIcon;
|
|
31
|
+
var initialColor = useRef(defaultColor);
|
|
32
|
+
var _useState = useState(defaultColor),
|
|
33
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
34
|
+
value = _useState2[0],
|
|
35
|
+
setValue = _useState2[1];
|
|
36
|
+
var _useState3 = useState(colors),
|
|
37
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
38
|
+
pinnedColors = _useState4[0],
|
|
39
|
+
setPinnedColors = _useState4[1];
|
|
40
|
+
if (!open) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
var handleSave = function handleSave() {
|
|
44
|
+
onChange(value);
|
|
45
|
+
if (typeof onClose === 'function') {
|
|
46
|
+
onClose();
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var handleClose = function handleClose(event) {
|
|
50
|
+
var shouldResetColor = initialColor.current !== value && typeof onTmpChooseColor === 'function';
|
|
51
|
+
if (shouldResetColor) {
|
|
52
|
+
onChange(initialColor.current);
|
|
53
|
+
}
|
|
54
|
+
if (typeof onClose === 'function') {
|
|
55
|
+
onClose(event);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
var onColorChange = function onColorChange(hexColor, rgbColor, colorPickerPinnedColors) {
|
|
59
|
+
if (typeof onTmpChooseColor === 'function') {
|
|
60
|
+
onTmpChooseColor(hexColor);
|
|
61
|
+
}
|
|
62
|
+
setValue(hexColor);
|
|
63
|
+
setPinnedColors(colorPickerPinnedColors);
|
|
64
|
+
};
|
|
65
|
+
return /*#__PURE__*/_jsxs(Modal, {
|
|
66
|
+
onClose: handleClose,
|
|
67
|
+
open: open,
|
|
68
|
+
fullWidth: true,
|
|
69
|
+
style: {
|
|
70
|
+
maxWidth: 350
|
|
71
|
+
},
|
|
72
|
+
children: [/*#__PURE__*/_jsx(ModalTitle, {
|
|
73
|
+
onClose: handleClose,
|
|
74
|
+
primary: modalTitleLabel,
|
|
75
|
+
icon: /*#__PURE__*/_jsx(ColorPickerIcon, {
|
|
76
|
+
size: 29
|
|
77
|
+
}),
|
|
78
|
+
iconShadow: true,
|
|
79
|
+
variant: "with-icon"
|
|
80
|
+
}), /*#__PURE__*/_jsx(ModalContent, {
|
|
81
|
+
children: /*#__PURE__*/_jsx(Styled.ColorPickerWrap, {
|
|
82
|
+
children: /*#__PURE__*/_jsx(ColorPicker, {
|
|
83
|
+
defaultColor: defaultColor,
|
|
84
|
+
pinnedColors: pinnedColors,
|
|
85
|
+
onChange: onColorChange,
|
|
86
|
+
showTransparentColor: showTransparentColor,
|
|
87
|
+
hidePinIcon: hidePinIcon
|
|
88
|
+
})
|
|
89
|
+
})
|
|
90
|
+
}), /*#__PURE__*/_jsxs(Styled.ModalActions, {
|
|
91
|
+
children: [/*#__PURE__*/_jsx(Styled.ModalButton, {
|
|
92
|
+
color: "basic",
|
|
93
|
+
onClick: handleClose,
|
|
94
|
+
children: cancelButtonLabel
|
|
95
|
+
}), /*#__PURE__*/_jsx(Styled.ModalButton, {
|
|
96
|
+
color: "primary",
|
|
97
|
+
onClick: handleSave,
|
|
98
|
+
children: saveButtonLabel
|
|
99
|
+
})]
|
|
100
|
+
})]
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
export default ColorPickerModal;
|
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
2
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
4
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
5
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
7
|
+
import { useState, useEffect, useRef } from 'react';
|
|
8
|
+
import { InputAndLabel } from '@scaleflex/widget-common';
|
|
9
|
+
import getDateString from '@scaleflex/widget-utils/lib/getDateString';
|
|
10
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
11
|
+
var oneDay = 60 * 60 * 24 * 1000;
|
|
12
|
+
var todayTimestamp = Date.now() - Date.now() % oneDay + new Date().getTimezoneOffset() * 1000 * 60;
|
|
13
|
+
var MyDatePicker = function MyDatePicker(props) {
|
|
14
|
+
var _useState = useState(function () {
|
|
15
|
+
return new Date().getFullYear();
|
|
16
|
+
}),
|
|
17
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
18
|
+
year = _useState2[0],
|
|
19
|
+
setYear = _useState2[1];
|
|
20
|
+
var _useState3 = useState(function () {
|
|
21
|
+
return new Date().getMonth();
|
|
22
|
+
}),
|
|
23
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
24
|
+
month = _useState4[0],
|
|
25
|
+
setMonth = _useState4[1];
|
|
26
|
+
var _useState5 = useState(function () {
|
|
27
|
+
return todayTimestamp;
|
|
28
|
+
}),
|
|
29
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
30
|
+
selectedDay = _useState6[0],
|
|
31
|
+
setSelectedDay = _useState6[1];
|
|
32
|
+
var _useState7 = useState(false),
|
|
33
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
34
|
+
showDatePicker = _useState8[0],
|
|
35
|
+
setShowDatePicker = _useState8[1];
|
|
36
|
+
var _useState9 = useState(0),
|
|
37
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
38
|
+
menuHeight = _useState10[0],
|
|
39
|
+
setMenuHeight = _useState10[1];
|
|
40
|
+
var wrapper = useRef();
|
|
41
|
+
var inputRef = useRef();
|
|
42
|
+
var iconRef = useRef();
|
|
43
|
+
var datePickerRef = useRef();
|
|
44
|
+
var getDayDetails = function getDayDetails(args) {
|
|
45
|
+
var daysMap = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
|
|
46
|
+
var date = args.index - args.firstDay;
|
|
47
|
+
var day = args.index % 7;
|
|
48
|
+
var prevMonth = args.month - 1;
|
|
49
|
+
var prevYear = args.year;
|
|
50
|
+
if (prevMonth < 0) {
|
|
51
|
+
prevMonth = 11;
|
|
52
|
+
prevYear--;
|
|
53
|
+
}
|
|
54
|
+
var prevMonthNumberOfDays = getNumberOfDays(prevYear, prevMonth);
|
|
55
|
+
var _date = (date < 0 ? prevMonthNumberOfDays + date : date % args.numberOfDays) + 1;
|
|
56
|
+
var month = date < 0 ? -1 : date >= args.numberOfDays ? 1 : 0;
|
|
57
|
+
var timestamp = new Date(args.year, args.month, _date).getTime();
|
|
58
|
+
return {
|
|
59
|
+
date: _date,
|
|
60
|
+
day: day,
|
|
61
|
+
month: month,
|
|
62
|
+
timestamp: timestamp,
|
|
63
|
+
dayString: daysMap[day]
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
var getNumberOfDays = function getNumberOfDays(year, month) {
|
|
67
|
+
return 40 - new Date(year, month, 40).getDate();
|
|
68
|
+
};
|
|
69
|
+
var getMonthDetails = function getMonthDetails(year, month) {
|
|
70
|
+
var firstDay = new Date(year, month).getDay();
|
|
71
|
+
var numberOfDays = getNumberOfDays(year, month);
|
|
72
|
+
var monthArray = [];
|
|
73
|
+
var rows = 6;
|
|
74
|
+
var currentDay = null;
|
|
75
|
+
var index = 0;
|
|
76
|
+
var cols = 7;
|
|
77
|
+
for (var row = 0; row < rows; row++) {
|
|
78
|
+
for (var col = 0; col < cols; col++) {
|
|
79
|
+
currentDay = getDayDetails({
|
|
80
|
+
index: index,
|
|
81
|
+
numberOfDays: numberOfDays,
|
|
82
|
+
firstDay: firstDay,
|
|
83
|
+
year: year,
|
|
84
|
+
month: month
|
|
85
|
+
});
|
|
86
|
+
monthArray.push(currentDay);
|
|
87
|
+
index++;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return monthArray;
|
|
91
|
+
};
|
|
92
|
+
var _useState11 = useState(function () {
|
|
93
|
+
return getMonthDetails(year, month);
|
|
94
|
+
}),
|
|
95
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
96
|
+
monthDetails = _useState12[0],
|
|
97
|
+
setMonthDetails = _useState12[1];
|
|
98
|
+
useEffect(function () {
|
|
99
|
+
setDateToInput(selectedDay);
|
|
100
|
+
}, []);
|
|
101
|
+
useEffect(function () {
|
|
102
|
+
getMenuHeight();
|
|
103
|
+
}, [showDatePicker]);
|
|
104
|
+
useEffect(function () {
|
|
105
|
+
setDateToInput(selectedDay.timestamp);
|
|
106
|
+
}, [selectedDay]);
|
|
107
|
+
useEffect(function () {
|
|
108
|
+
var closeDatePicker = function closeDatePicker(e) {
|
|
109
|
+
var _iconRef$current, _datePickerRef$curren;
|
|
110
|
+
if (!((_iconRef$current = iconRef.current) !== null && _iconRef$current !== void 0 && _iconRef$current.contains(e.target)) && !((_datePickerRef$curren = datePickerRef.current) !== null && _datePickerRef$curren !== void 0 && _datePickerRef$curren.contains(e.target))) {
|
|
111
|
+
e.preventDefault();
|
|
112
|
+
e.stopPropagation();
|
|
113
|
+
setShowDatePicker(false);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
document.addEventListener('click', closeDatePicker);
|
|
117
|
+
return function () {
|
|
118
|
+
document.removeEventListener('click', closeDatePicker);
|
|
119
|
+
};
|
|
120
|
+
}, []);
|
|
121
|
+
var getMenuHeight = function getMenuHeight() {
|
|
122
|
+
var _document$querySelect, _document$querySelect2;
|
|
123
|
+
var height = (_document$querySelect = document.querySelector('.filerobot-common-datePicker-container')) === null || _document$querySelect === void 0 ? void 0 : (_document$querySelect2 = _document$querySelect.getBoundingClientRect()) === null || _document$querySelect2 === void 0 ? void 0 : _document$querySelect2.height;
|
|
124
|
+
setMenuHeight(height);
|
|
125
|
+
};
|
|
126
|
+
var getMenuPosition = function getMenuPosition() {
|
|
127
|
+
return menuHeight + props.top >= props.containerHeight ? {
|
|
128
|
+
bottom: 45
|
|
129
|
+
} : {
|
|
130
|
+
top: 45
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
var showADatePicker = function showADatePicker(e) {
|
|
134
|
+
props.getParentPosition(e);
|
|
135
|
+
e.preventDefault();
|
|
136
|
+
e.stopPropagation();
|
|
137
|
+
setShowDatePicker(!showDatePicker);
|
|
138
|
+
};
|
|
139
|
+
var isCurrentDay = function isCurrentDay(day) {
|
|
140
|
+
return day.timestamp === todayTimestamp;
|
|
141
|
+
};
|
|
142
|
+
var isSelectedDay = function isSelectedDay(day) {
|
|
143
|
+
return day.timestamp === selectedDay;
|
|
144
|
+
};
|
|
145
|
+
var getDateFromDateString = function getDateFromDateString(dateValue) {
|
|
146
|
+
var _ref;
|
|
147
|
+
console.log('hey', dateValue);
|
|
148
|
+
var dateData = (_ref = typeof dateValue === 'string' ? dateValue === null || dateValue === void 0 ? void 0 : dateValue.split('-') : dateValue) === null || _ref === void 0 ? void 0 : _ref.map(function (d) {
|
|
149
|
+
return parseInt(d, 10);
|
|
150
|
+
});
|
|
151
|
+
if (!dateData || dateData.length < 3) {
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
var year = dateData[0];
|
|
155
|
+
var month = dateData[1];
|
|
156
|
+
var date = dateData[2];
|
|
157
|
+
return {
|
|
158
|
+
year: year,
|
|
159
|
+
month: month,
|
|
160
|
+
date: date
|
|
161
|
+
};
|
|
162
|
+
};
|
|
163
|
+
var getMonthStr = function getMonthStr(month) {
|
|
164
|
+
var monthMap = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
|
|
165
|
+
return monthMap[Math.max(Math.min(11, month), 0)] || 'Month';
|
|
166
|
+
};
|
|
167
|
+
var getDateStringFromTimestamp = function getDateStringFromTimestamp(timestamp) {
|
|
168
|
+
var dateObject = new Date(timestamp);
|
|
169
|
+
var month = dateObject.getMonth() + 1;
|
|
170
|
+
var date = dateObject.getDate();
|
|
171
|
+
return dateObject.getFullYear() + '-' + (month < 10 ? '0' + month : month) + '-' + (date < 10 ? '0' + date : date);
|
|
172
|
+
};
|
|
173
|
+
var setDate = function setDate(dateData) {
|
|
174
|
+
var selectedDay = new Date(dateData.year, dateData.month - 1, dateData.date).getTime();
|
|
175
|
+
setSelectedDay(selectedDay);
|
|
176
|
+
if (props.onChange) {
|
|
177
|
+
props.onChange({}, getDateString('ymd', '-', selectedDay));
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
var updateDateFromInput = function updateDateFromInput(e) {
|
|
181
|
+
if (!inputRef.current.value) {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
var dateData = getDateFromDateString(inputRef.current.value);
|
|
185
|
+
if (dateData !== null) {
|
|
186
|
+
setDate(dateData);
|
|
187
|
+
setYear(dateData.year);
|
|
188
|
+
setMonth(dateData.month - 1);
|
|
189
|
+
setMonthDetails(getMonthDetails(dateData.year, dateData.month - 1));
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
var setDateToInput = function setDateToInput(timestamp) {
|
|
193
|
+
var dateString = getDateStringFromTimestamp(timestamp);
|
|
194
|
+
|
|
195
|
+
// if no update from external value update internally
|
|
196
|
+
if (inputRef && !props.onChange) {
|
|
197
|
+
inputRef.current.value = dateString;
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
var onDateClick = function onDateClick(day) {
|
|
201
|
+
setSelectedDay(day.timestamp);
|
|
202
|
+
if (props.onChange) {
|
|
203
|
+
props.onChange({}, getDateStringFromTimestamp(day.timestamp));
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
var setNewYear = function setNewYear(offset) {
|
|
207
|
+
var newYear = year + offset;
|
|
208
|
+
setYear(newYear);
|
|
209
|
+
setMonthDetails(getMonthDetails(newYear, month));
|
|
210
|
+
};
|
|
211
|
+
var setNewMonth = function setNewMonth(offset) {
|
|
212
|
+
var newYear = year;
|
|
213
|
+
var newMonth = month + offset;
|
|
214
|
+
if (month === -1) {
|
|
215
|
+
newMonth = 11;
|
|
216
|
+
newYear--;
|
|
217
|
+
} else if (month === 12) {
|
|
218
|
+
newMonth = 0;
|
|
219
|
+
newYear++;
|
|
220
|
+
}
|
|
221
|
+
setYear(newYear);
|
|
222
|
+
setMonth(newMonth);
|
|
223
|
+
setMonthDetails(getMonthDetails(newYear, newMonth));
|
|
224
|
+
};
|
|
225
|
+
var renderCalendar = function renderCalendar() {
|
|
226
|
+
var days = monthDetails.map(function (day, index) {
|
|
227
|
+
return /*#__PURE__*/_jsx("div", {
|
|
228
|
+
className: "filerobot-common-datePicker-calendar-day".concat(day.month !== 0 ? ' disabled' : '') + (isCurrentDay(day) ? ' highlight' : '') + (isSelectedDay(day) ? ' highlight-green' : ''),
|
|
229
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
230
|
+
className: "filerobot-common-datePicker-calendar-day-container",
|
|
231
|
+
children: /*#__PURE__*/_jsx("span", {
|
|
232
|
+
onClick: function onClick() {
|
|
233
|
+
return onDateClick(day);
|
|
234
|
+
},
|
|
235
|
+
children: day.date
|
|
236
|
+
})
|
|
237
|
+
})
|
|
238
|
+
}, index);
|
|
239
|
+
});
|
|
240
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
241
|
+
className: "filerobot-common-datePicker-calendar",
|
|
242
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
243
|
+
className: "filerobot-common-datePicker-calendar-head",
|
|
244
|
+
children: ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT'].map(function (d, i) {
|
|
245
|
+
return /*#__PURE__*/_jsx("div", {
|
|
246
|
+
className: "filerobot-common-datePicker-calendar-head-name",
|
|
247
|
+
children: d
|
|
248
|
+
}, i);
|
|
249
|
+
})
|
|
250
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
251
|
+
className: "filerobot-common-datePicker-calendar-body",
|
|
252
|
+
children: days
|
|
253
|
+
})]
|
|
254
|
+
});
|
|
255
|
+
};
|
|
256
|
+
var showLabel = typeof props.showLabel === 'boolean' ? props.showLabel : true;
|
|
257
|
+
return /*#__PURE__*/_jsx(_Fragment, {
|
|
258
|
+
children: /*#__PURE__*/_jsxs("div", {
|
|
259
|
+
className: "filerobot-common-datePicker ".concat(props.classes ? "".concat(props.classes) : ''),
|
|
260
|
+
style: props.isFilterOptions ? {
|
|
261
|
+
position: 'unset'
|
|
262
|
+
} : {},
|
|
263
|
+
ref: wrapper,
|
|
264
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
265
|
+
className: "filerobot-common-datePicker-input",
|
|
266
|
+
children: /*#__PURE__*/_jsx(InputAndLabel, {
|
|
267
|
+
item: "date",
|
|
268
|
+
type: "date",
|
|
269
|
+
value: props.value,
|
|
270
|
+
onChange: updateDateFromInput,
|
|
271
|
+
onClick: showADatePicker,
|
|
272
|
+
ref: inputRef,
|
|
273
|
+
innerRef: iconRef,
|
|
274
|
+
icon: props.icon,
|
|
275
|
+
i18n: props.i18n,
|
|
276
|
+
isFilterOptions: props.isFilterOptions,
|
|
277
|
+
showLabel: showLabel
|
|
278
|
+
})
|
|
279
|
+
}), showDatePicker ? /*#__PURE__*/_jsxs("div", {
|
|
280
|
+
className: "filerobot-common-datePicker-container",
|
|
281
|
+
style: props.isFilterOptions ? {
|
|
282
|
+
bottom: 99,
|
|
283
|
+
left: 10
|
|
284
|
+
} : getMenuPosition(),
|
|
285
|
+
ref: datePickerRef,
|
|
286
|
+
children: [/*#__PURE__*/_jsxs("div", {
|
|
287
|
+
className: "filerobot-common-datePicker-container-head",
|
|
288
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
289
|
+
className: "filerobot-common-datePicker-container-head-button",
|
|
290
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
291
|
+
className: "filerobot-common-datePicker-container-head-button-inner",
|
|
292
|
+
onClick: function onClick() {
|
|
293
|
+
return setNewYear(-1);
|
|
294
|
+
},
|
|
295
|
+
children: /*#__PURE__*/_jsx("span", {
|
|
296
|
+
className: "mdpchbi-left-arrows"
|
|
297
|
+
})
|
|
298
|
+
})
|
|
299
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
300
|
+
className: "filerobot-common-datePicker-container-head-button",
|
|
301
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
302
|
+
className: "filerobot-common-datePicker-container-head-button-inner",
|
|
303
|
+
onClick: function onClick() {
|
|
304
|
+
return setNewMonth(-1);
|
|
305
|
+
},
|
|
306
|
+
children: /*#__PURE__*/_jsx("span", {
|
|
307
|
+
className: "mdpchbi-left-arrow"
|
|
308
|
+
})
|
|
309
|
+
})
|
|
310
|
+
}), /*#__PURE__*/_jsxs("div", {
|
|
311
|
+
className: "filerobot-common-datePicker-container-head-body",
|
|
312
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
313
|
+
className: "filerobot-common-datePicker-container-head-body-year",
|
|
314
|
+
children: year
|
|
315
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
316
|
+
className: "filerobot-common-datePicker-container-head-body-month",
|
|
317
|
+
children: getMonthStr(month)
|
|
318
|
+
})]
|
|
319
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
320
|
+
className: "filerobot-common-datePicker-container-head-button",
|
|
321
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
322
|
+
className: "filerobot-common-datePicker-container-head-button-inner",
|
|
323
|
+
onClick: function onClick() {
|
|
324
|
+
return setNewMonth(1);
|
|
325
|
+
},
|
|
326
|
+
children: /*#__PURE__*/_jsx("span", {
|
|
327
|
+
className: "mdpchbi-right-arrow"
|
|
328
|
+
})
|
|
329
|
+
})
|
|
330
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
331
|
+
className: "filerobot-common-datePicker-container-head-button",
|
|
332
|
+
onClick: function onClick() {
|
|
333
|
+
return setNewYear(1);
|
|
334
|
+
},
|
|
335
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
336
|
+
className: "filerobot-common-datePicker-container-head-button-inner",
|
|
337
|
+
children: /*#__PURE__*/_jsx("span", {
|
|
338
|
+
className: "mdpchbi-right-arrows"
|
|
339
|
+
})
|
|
340
|
+
})
|
|
341
|
+
})]
|
|
342
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
343
|
+
className: "filerobot-common-datePicker-container-body",
|
|
344
|
+
children: renderCalendar()
|
|
345
|
+
})]
|
|
346
|
+
}) : '']
|
|
347
|
+
})
|
|
348
|
+
});
|
|
349
|
+
};
|
|
350
|
+
export default MyDatePicker;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as DatePicker } from './MyDatePicker';
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
var _excluded = ["color", "i18n", "classes", "dropFileHint", "onMount", "visible"];
|
|
3
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
6
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
7
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
8
|
+
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
9
|
+
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
10
|
+
import { useEffect } from 'react';
|
|
11
|
+
import { Upload } from '@scaleflex/icons';
|
|
12
|
+
import { useTheme } from '@scaleflex/ui/theme/hooks';
|
|
13
|
+
import { PC } from './';
|
|
14
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
|
+
var DropFilesWindow = function DropFilesWindow(_ref) {
|
|
16
|
+
var _theme$palette;
|
|
17
|
+
var color = _ref.color,
|
|
18
|
+
i18n = _ref.i18n,
|
|
19
|
+
classes = _ref.classes,
|
|
20
|
+
dropFileHint = _ref.dropFileHint,
|
|
21
|
+
onMount = _ref.onMount,
|
|
22
|
+
_ref$visible = _ref.visible,
|
|
23
|
+
visible = _ref$visible === void 0 ? false : _ref$visible,
|
|
24
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
25
|
+
var theme = useTheme();
|
|
26
|
+
var iconProps = {
|
|
27
|
+
color: color || (theme === null || theme === void 0 ? void 0 : (_theme$palette = theme.palette) === null || _theme$palette === void 0 ? void 0 : _theme$palette[PC.AccentPrimary])
|
|
28
|
+
};
|
|
29
|
+
useEffect(function () {
|
|
30
|
+
if (typeof onMount === 'function') {
|
|
31
|
+
onMount();
|
|
32
|
+
}
|
|
33
|
+
}, []);
|
|
34
|
+
return /*#__PURE__*/_jsx("div", _objectSpread(_objectSpread({
|
|
35
|
+
className: "filerobot-common-DropFilesHereHint".concat(visible ? ' filerobot-common-DropFilesHereHint-visible' : '').concat(classes ? " ".concat(classes) : '')
|
|
36
|
+
}, props), {}, {
|
|
37
|
+
children: /*#__PURE__*/_jsxs("div", {
|
|
38
|
+
className: "filerobot-common-DropFilesHereHint-inner",
|
|
39
|
+
children: [/*#__PURE__*/_jsx(Upload, _objectSpread(_objectSpread({}, iconProps), {}, {
|
|
40
|
+
size: 50
|
|
41
|
+
})), dropFileHint]
|
|
42
|
+
})
|
|
43
|
+
}));
|
|
44
|
+
};
|
|
45
|
+
export default DropFilesWindow;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
var _templateObject, _templateObject2;
|
|
2
|
+
function _taggedTemplateLiteral(e, t) { return t || (t = e.slice(0)), Object.freeze(Object.defineProperties(e, { raw: { value: Object.freeze(t) } })); }
|
|
3
|
+
import { PC } from '@scaleflex/widget-common';
|
|
4
|
+
import styled from 'styled-components';
|
|
5
|
+
import { Button as SfxButton } from '@scaleflex/ui/core';
|
|
6
|
+
var Button = styled(SfxButton)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n color: ", ";\n border: 1px solid ", ";\n transition: all 100ms ease-out;\n background: ", ";\n max-width: 300px;\n\n .SfxButton-Label {\n font-weight: 400;\n }\n\n .SfxButton-EndIcon {\n margin: auto 0;\n margin-left: 8px;\n transition: all 100ms ease-out;\n\n ", "\n\n ", "\n }\n\n ", "\n\n &:hover:not(:disabled) {\n color: ", ";\n border-color: ", ";\n background-color: transparent;\n }\n\n &:disabled {\n cursor: not-allowed;\n user-select: none;\n }\n"])), function (_ref) {
|
|
7
|
+
var palette = _ref.theme.palette;
|
|
8
|
+
return palette[PC.TextPrimary];
|
|
9
|
+
}, function (_ref2) {
|
|
10
|
+
var palette = _ref2.theme.palette;
|
|
11
|
+
return palette[PC.BorderPrimaryStateless];
|
|
12
|
+
}, function (_ref3) {
|
|
13
|
+
var open = _ref3.open,
|
|
14
|
+
palette = _ref3.theme.palette;
|
|
15
|
+
return open ? palette[PC.Accent_0_5_Opacity] : 'transparent';
|
|
16
|
+
}, function (_ref4) {
|
|
17
|
+
var open = _ref4.open,
|
|
18
|
+
palette = _ref4.theme.palette;
|
|
19
|
+
return open && "\n transform: rotate(180deg);\n color: ".concat(palette[PC.IconsPrimary], "\n ");
|
|
20
|
+
}, function (_ref5) {
|
|
21
|
+
var active = _ref5.active,
|
|
22
|
+
open = _ref5.open,
|
|
23
|
+
palette = _ref5.theme.palette;
|
|
24
|
+
return open && active && "\n transform: rotate(180deg);\n color: ".concat(palette[PC.AccentStateless], "\n ");
|
|
25
|
+
}, function (_ref6) {
|
|
26
|
+
var active = _ref6.active,
|
|
27
|
+
open = _ref6.open,
|
|
28
|
+
palette = _ref6.theme.palette;
|
|
29
|
+
return active && "\n color: ".concat(palette[PC.AccentStateless], ";\n border-color: ").concat(!open ? palette[PC.AccentStateless] : palette[PC.BorderPrimaryStateless], ";\n ");
|
|
30
|
+
}, function (_ref7) {
|
|
31
|
+
var palette = _ref7.theme.palette;
|
|
32
|
+
return palette[PC.AccentStateless];
|
|
33
|
+
}, function (_ref8) {
|
|
34
|
+
var palette = _ref8.theme.palette;
|
|
35
|
+
return palette[PC.AccentStateless];
|
|
36
|
+
});
|
|
37
|
+
var Count = styled.span(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n"])));
|
|
38
|
+
var Styled = {
|
|
39
|
+
Button: Button,
|
|
40
|
+
Count: Count
|
|
41
|
+
};
|
|
42
|
+
export default Styled;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
var _excluded = ["label", "onClick", "open", "name", "active", "count", "style"];
|
|
3
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
6
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
7
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
8
|
+
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
9
|
+
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
10
|
+
import { ArrowBottom } from '@scaleflex/icons';
|
|
11
|
+
import { EllipsedText } from '@scaleflex/ui/core';
|
|
12
|
+
import Styled from './FilterItem.styled';
|
|
13
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
var FilterItem = function FilterItem(_ref) {
|
|
15
|
+
var _ref$label = _ref.label,
|
|
16
|
+
label = _ref$label === void 0 ? '' : _ref$label,
|
|
17
|
+
onClick = _ref.onClick,
|
|
18
|
+
open = _ref.open,
|
|
19
|
+
name = _ref.name,
|
|
20
|
+
_ref$active = _ref.active,
|
|
21
|
+
active = _ref$active === void 0 ? false : _ref$active,
|
|
22
|
+
_ref$count = _ref.count,
|
|
23
|
+
count = _ref$count === void 0 ? 0 : _ref$count,
|
|
24
|
+
_ref$style = _ref.style,
|
|
25
|
+
style = _ref$style === void 0 ? {} : _ref$style,
|
|
26
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
27
|
+
return /*#__PURE__*/_jsx(Styled.Button, _objectSpread(_objectSpread({
|
|
28
|
+
className: "filerobot-Common-Filters-FilterItem",
|
|
29
|
+
active: active,
|
|
30
|
+
open: open,
|
|
31
|
+
color: "secondary",
|
|
32
|
+
size: "sm",
|
|
33
|
+
onClick: onClick,
|
|
34
|
+
name: name,
|
|
35
|
+
endIcon: /*#__PURE__*/_jsx(ArrowBottom, {
|
|
36
|
+
size: 11
|
|
37
|
+
}),
|
|
38
|
+
style: style
|
|
39
|
+
}, rest), {}, {
|
|
40
|
+
children: /*#__PURE__*/_jsxs(EllipsedText, {
|
|
41
|
+
maxLinesCount: 1,
|
|
42
|
+
children: [label, Boolean(count) && /*#__PURE__*/_jsxs(Styled.Count, {
|
|
43
|
+
children: [" (", count, ")"]
|
|
44
|
+
})]
|
|
45
|
+
})
|
|
46
|
+
}));
|
|
47
|
+
};
|
|
48
|
+
export default FilterItem;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
var _templateObject, _templateObject2;
|
|
2
|
+
function _taggedTemplateLiteral(e, t) { return t || (t = e.slice(0)), Object.freeze(Object.defineProperties(e, { raw: { value: Object.freeze(t) } })); }
|
|
3
|
+
import styled, { keyframes } from 'styled-components';
|
|
4
|
+
import { PC } from '@scaleflex/widget-common';
|
|
5
|
+
var fadeInOutAnimation = keyframes(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n 0% { opacity: 0; transform: scale(0.9); }\n 50% { opacity: 1; transform: scale(1.05); }\n 100% { opacity: 1; transform: scale(1); }\n"])));
|
|
6
|
+
var PopupWrapper = styled.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n background-color: ", ";\n box-shadow: 0px 2px 6px ", ";\n border-radius: 4px;\n overflow: hidden;\n transform-origin: top left;\n opacity: 0;\n margin-top: 4px;\n margin-left: -5px;\n transform: scale(0.9);\n animation: ", " 250ms cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;\n"])), function (_ref) {
|
|
7
|
+
var palette = _ref.theme.palette;
|
|
8
|
+
return palette[PC.BackgroundStateless];
|
|
9
|
+
}, function (_ref2) {
|
|
10
|
+
var palette = _ref2.theme.palette;
|
|
11
|
+
return palette[PC.LargeShadow];
|
|
12
|
+
}, fadeInOutAnimation);
|
|
13
|
+
var Styled = {
|
|
14
|
+
PopupWrapper: PopupWrapper
|
|
15
|
+
};
|
|
16
|
+
export default Styled;
|