@activecollab/components 1.0.369 → 1.0.371
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/cjs/components/EditableHours/EditableHours.js +54 -19
- package/dist/cjs/components/EditableHours/EditableHours.js.map +1 -1
- package/dist/cjs/components/EditableText/EditableText.js +1 -1
- package/dist/cjs/components/EditableText/EditableText.js.map +1 -1
- package/dist/esm/components/EditableHours/EditableHours.d.ts +2 -0
- package/dist/esm/components/EditableHours/EditableHours.d.ts.map +1 -1
- package/dist/esm/components/EditableHours/EditableHours.js +53 -19
- package/dist/esm/components/EditableHours/EditableHours.js.map +1 -1
- package/dist/esm/components/EditableText/EditableText.d.ts.map +1 -1
- package/dist/esm/components/EditableText/EditableText.js +1 -1
- package/dist/esm/components/EditableText/EditableText.js.map +1 -1
- package/dist/index.js +55 -20
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -15808,7 +15808,7 @@
|
|
|
15808
15808
|
setCurrentValue(e.target.value);
|
|
15809
15809
|
typeof onSave === "function" && onSave(e);
|
|
15810
15810
|
} else {
|
|
15811
|
-
!allowEmptyString ? setCurrentValue(prevValue) : typeof onSave === "function" && onSave(e);
|
|
15811
|
+
!allowEmptyString ? setCurrentValue(prevValue) : typeof onSave === "function" && prevValue !== e.target.value && onSave(e);
|
|
15812
15812
|
}
|
|
15813
15813
|
}
|
|
15814
15814
|
}, [allowEmptyString, onSave, prevValue]);
|
|
@@ -15929,7 +15929,7 @@
|
|
|
15929
15929
|
return !Number.isInteger(num);
|
|
15930
15930
|
};
|
|
15931
15931
|
|
|
15932
|
-
var _excluded$c = ["value", "onCancel", "onSave", "inputProps", "allowEmptyValue", "withLeadingZero", "validation"];
|
|
15932
|
+
var _excluded$c = ["value", "onCancel", "onSave", "inputProps", "allowEmptyValue", "withLeadingZero", "validation", "incrementOnlySelected", "minuteIncrement"];
|
|
15933
15933
|
var EditableHours = /*#__PURE__*/React__default["default"].forwardRef(function (_ref, ref) {
|
|
15934
15934
|
var _ref$value = _ref.value,
|
|
15935
15935
|
value = _ref$value === void 0 ? 0 : _ref$value,
|
|
@@ -15943,6 +15943,10 @@
|
|
|
15943
15943
|
validation = _ref$validation === void 0 ? function () {
|
|
15944
15944
|
return true;
|
|
15945
15945
|
} : _ref$validation,
|
|
15946
|
+
_ref$incrementOnlySel = _ref.incrementOnlySelected,
|
|
15947
|
+
incrementOnlySelected = _ref$incrementOnlySel === void 0 ? false : _ref$incrementOnlySel,
|
|
15948
|
+
_ref$minuteIncrement = _ref.minuteIncrement,
|
|
15949
|
+
minuteIncrement = _ref$minuteIncrement === void 0 ? 1 : _ref$minuteIncrement,
|
|
15946
15950
|
rest = _objectWithoutProperties(_ref, _excluded$c);
|
|
15947
15951
|
var inputRef = React.useRef(null);
|
|
15948
15952
|
var handleRef = useForkRef(ref, inputRef);
|
|
@@ -15987,7 +15991,7 @@
|
|
|
15987
15991
|
setCurrentValue(_value);
|
|
15988
15992
|
typeof onSave === "function" && onSave(e);
|
|
15989
15993
|
} else {
|
|
15990
|
-
!allowEmptyValue ? setCurrentValue(prevValue) : typeof onSave === "function" && onSave(e);
|
|
15994
|
+
!allowEmptyValue ? setCurrentValue(prevValue) : typeof onSave === "function" && prevValue !== e.target.value && onSave(e);
|
|
15991
15995
|
}
|
|
15992
15996
|
}
|
|
15993
15997
|
}, [allowEmptyValue, onSave, prevValue, withLeadingZero]);
|
|
@@ -15996,28 +16000,46 @@
|
|
|
15996
16000
|
var selectionStart = inputRef.current.selectionStart;
|
|
15997
16001
|
if (selectionStart !== null) {
|
|
15998
16002
|
var dotsIndex = currentValue.indexOf(":");
|
|
15999
|
-
var
|
|
16003
|
+
var _currentValue$split$m = currentValue.split(":").map(Number),
|
|
16004
|
+
_currentValue$split$m2 = _slicedToArray(_currentValue$split$m, 2),
|
|
16005
|
+
hours = _currentValue$split$m2[0],
|
|
16006
|
+
minutes = _currentValue$split$m2[1];
|
|
16007
|
+
var newHours = hours;
|
|
16008
|
+
var newMinutes = minutes;
|
|
16000
16009
|
if (selectionStart < dotsIndex) {
|
|
16001
|
-
|
|
16002
|
-
|
|
16003
|
-
|
|
16004
|
-
|
|
16010
|
+
if (increment) {
|
|
16011
|
+
newHours += 1;
|
|
16012
|
+
} else {
|
|
16013
|
+
newHours -= 1;
|
|
16014
|
+
if (newHours < 0) newHours = 0;
|
|
16005
16015
|
}
|
|
16006
16016
|
} else if (selectionStart > dotsIndex) {
|
|
16007
|
-
|
|
16008
|
-
|
|
16009
|
-
|
|
16010
|
-
|
|
16017
|
+
if (increment) {
|
|
16018
|
+
newMinutes += minuteIncrement;
|
|
16019
|
+
if (newMinutes > 59) {
|
|
16020
|
+
newMinutes = 0;
|
|
16021
|
+
if (!incrementOnlySelected) newHours += 1;
|
|
16022
|
+
}
|
|
16023
|
+
} else {
|
|
16024
|
+
if (newMinutes >= minuteIncrement || newMinutes === 0) {
|
|
16025
|
+
newMinutes -= minuteIncrement;
|
|
16026
|
+
if (newMinutes < 0 && newHours > 0) {
|
|
16027
|
+
newMinutes = 60 - minuteIncrement;
|
|
16028
|
+
if (!incrementOnlySelected) newHours -= 1;
|
|
16029
|
+
}
|
|
16030
|
+
if (newHours < 0) {
|
|
16031
|
+
newHours = 0;
|
|
16032
|
+
}
|
|
16033
|
+
} else {
|
|
16034
|
+
newMinutes = 0;
|
|
16035
|
+
}
|
|
16011
16036
|
}
|
|
16012
16037
|
}
|
|
16013
|
-
|
|
16038
|
+
var newMinutesString = newMinutes < 10 ? "0".concat(newMinutes) : newMinutes;
|
|
16039
|
+
var newHoursString = withLeadingZero && newHours < 10 ? "0".concat(newHours) : newHours;
|
|
16040
|
+
var newValue = "".concat(newHoursString, ":").concat(newMinutesString);
|
|
16041
|
+
if (validation(newValue)) {
|
|
16014
16042
|
setCurrentValue(newValue);
|
|
16015
|
-
if (onSave) {
|
|
16016
|
-
onSave(new Event("input", {
|
|
16017
|
-
bubbles: true,
|
|
16018
|
-
cancelable: true
|
|
16019
|
-
}));
|
|
16020
|
-
}
|
|
16021
16043
|
requestAnimationFrame(function () {
|
|
16022
16044
|
var _inputRef$current;
|
|
16023
16045
|
var newDotsIndex = newValue.indexOf(":");
|
|
@@ -16029,11 +16051,17 @@
|
|
|
16029
16051
|
}
|
|
16030
16052
|
}
|
|
16031
16053
|
}
|
|
16032
|
-
}, [currentValue,
|
|
16054
|
+
}, [currentValue, incrementOnlySelected, minuteIncrement, validation, withLeadingZero]);
|
|
16033
16055
|
var handleKeyDown = React.useCallback(function (e) {
|
|
16034
16056
|
if (e.key === "Enter") {
|
|
16035
16057
|
e.target.blur();
|
|
16036
16058
|
}
|
|
16059
|
+
if (e.key === "ArrowLeft") {
|
|
16060
|
+
return;
|
|
16061
|
+
}
|
|
16062
|
+
if (e.key === "ArrowRight") {
|
|
16063
|
+
return;
|
|
16064
|
+
}
|
|
16037
16065
|
if (e.key === "Escape") {
|
|
16038
16066
|
escapeRef.current = true;
|
|
16039
16067
|
e.target.blur();
|
|
@@ -16107,6 +16135,12 @@
|
|
|
16107
16135
|
}
|
|
16108
16136
|
}
|
|
16109
16137
|
};
|
|
16138
|
+
var handleDoubleClick = function handleDoubleClick() {
|
|
16139
|
+
if (inputRef.current) {
|
|
16140
|
+
var _inputRef$current7;
|
|
16141
|
+
(_inputRef$current7 = inputRef.current) === null || _inputRef$current7 === void 0 ? void 0 : _inputRef$current7.setSelectionRange(0, currentValue.length);
|
|
16142
|
+
}
|
|
16143
|
+
};
|
|
16110
16144
|
return /*#__PURE__*/React__default["default"].createElement(EditableContent, _extends({
|
|
16111
16145
|
ref: handleRef,
|
|
16112
16146
|
inputProps: _objectSpread2(_objectSpread2({}, inputProps), {}, {
|
|
@@ -16116,6 +16150,7 @@
|
|
|
16116
16150
|
onChange: handleChange,
|
|
16117
16151
|
type: "text",
|
|
16118
16152
|
onClick: handleClick,
|
|
16153
|
+
onDoubleClick: handleDoubleClick,
|
|
16119
16154
|
className: classNames__default["default"]("c-input", inputProps === null || inputProps === void 0 ? void 0 : inputProps.className)
|
|
16120
16155
|
})
|
|
16121
16156
|
}, rest));
|