@lobehub/ui 1.60.1 → 1.61.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.
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { ControlInputProps } from "../components/ControlInput";
|
|
3
|
-
export
|
|
4
|
-
|
|
3
|
+
export interface EditableTextProps extends ControlInputProps {
|
|
4
|
+
editing?: boolean;
|
|
5
|
+
onEditingChange?: (editing: boolean) => void;
|
|
6
|
+
showEditIcon?: boolean;
|
|
7
|
+
}
|
|
8
|
+
declare const EditableText: import("react").NamedExoticComponent<EditableTextProps>;
|
|
5
9
|
export default EditableText;
|
package/es/EditableText/index.js
CHANGED
|
@@ -1,28 +1,42 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
1
2
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
4
|
+
var _excluded = ["value", "showEditIcon", "onChange", "editing", "onEditingChange"];
|
|
5
|
+
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; }
|
|
6
|
+
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; }
|
|
2
7
|
import { Edit3 } from 'lucide-react';
|
|
3
|
-
import { memo
|
|
8
|
+
import { memo } from 'react';
|
|
4
9
|
import { Flexbox } from 'react-layout-kit';
|
|
10
|
+
import useControlledState from 'use-merge-value';
|
|
5
11
|
import ActionIcon from "../ActionIcon";
|
|
6
12
|
import { ControlInput } from "../components/ControlInput";
|
|
7
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
14
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
15
|
var EditableText = /*#__PURE__*/memo(function (_ref) {
|
|
10
16
|
var value = _ref.value,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
_ref$showEditIcon = _ref.showEditIcon,
|
|
18
|
+
showEditIcon = _ref$showEditIcon === void 0 ? true : _ref$showEditIcon,
|
|
19
|
+
onChange = _ref.onChange,
|
|
20
|
+
editing = _ref.editing,
|
|
21
|
+
onEditingChange = _ref.onEditingChange,
|
|
22
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
23
|
+
var _useControlledState = useControlledState(false, {
|
|
24
|
+
onChange: onEditingChange,
|
|
25
|
+
value: editing
|
|
26
|
+
}),
|
|
27
|
+
_useControlledState2 = _slicedToArray(_useControlledState, 2),
|
|
28
|
+
edited = _useControlledState2[0],
|
|
29
|
+
setEdited = _useControlledState2[1];
|
|
30
|
+
return edited ? /*#__PURE__*/_jsx(ControlInput, _objectSpread({
|
|
17
31
|
onChange: onChange,
|
|
18
32
|
onChangeEnd: function onChangeEnd() {
|
|
19
33
|
setEdited(false);
|
|
20
34
|
},
|
|
21
35
|
value: value
|
|
22
|
-
}) : /*#__PURE__*/_jsxs(Flexbox, {
|
|
36
|
+
}, props)) : /*#__PURE__*/_jsxs(Flexbox, {
|
|
23
37
|
gap: 8,
|
|
24
38
|
horizontal: true,
|
|
25
|
-
children: [value, /*#__PURE__*/_jsx(ActionIcon, {
|
|
39
|
+
children: [value, showEditIcon && /*#__PURE__*/_jsx(ActionIcon, {
|
|
26
40
|
icon: Edit3,
|
|
27
41
|
onClick: function onClick() {
|
|
28
42
|
setEdited(!edited);
|
package/es/Swatches/style.js
CHANGED
|
@@ -6,6 +6,6 @@ export var useStyles = createStyles(function (_ref, size) {
|
|
|
6
6
|
token = _ref.token;
|
|
7
7
|
return {
|
|
8
8
|
active: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n box-shadow: 0 0 0 2px ", ";\n "])), token.colorTextTertiary),
|
|
9
|
-
container: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n cursor: pointer;\n\n width: ", "px;\n height: ", "px;\n\n background: ", ";\n border-radius: 50%;\n box-shadow: 0 0 0
|
|
9
|
+
container: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n cursor: pointer;\n\n width: ", "px;\n height: ", "px;\n\n background: ", ";\n border-radius: 50%;\n box-shadow: inset 0 0 0 2px ", ";\n\n transition:\n scale 400ms ", ",\n box-shadow 100ms ", ";\n\n &:hover {\n box-shadow: 0 0 0 3px ", ";\n }\n\n &:active {\n scale: 0.8;\n }\n "])), size, size, token.colorBgContainer, token.colorSplit, token.motionEaseOut, token.motionEaseOut, token.colorText)
|
|
10
10
|
};
|
|
11
11
|
});
|
|
@@ -30,6 +30,7 @@ export var ControlInput = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
30
30
|
if (value !== undefined) setInput(value);
|
|
31
31
|
}, [value]);
|
|
32
32
|
return /*#__PURE__*/_jsx(Input, _objectSpread({
|
|
33
|
+
autoFocus: true,
|
|
33
34
|
onBlur: function onBlur() {
|
|
34
35
|
isFocusing.current = false;
|
|
35
36
|
onChangeEnd === null || onChangeEnd === void 0 ? void 0 : onChangeEnd(input);
|