@lobehub/ui 1.60.2 → 1.62.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/TokenTag/index.d.ts
CHANGED
package/es/TokenTag/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["className", "maxValue", "value", "text"];
|
|
3
|
+
var _excluded = ["className", "displayMode", "maxValue", "value", "text"];
|
|
4
4
|
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; }
|
|
5
5
|
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; }
|
|
6
6
|
import { forwardRef } from 'react';
|
|
@@ -10,6 +10,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
10
10
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
11
|
var TokenTag = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
12
12
|
var className = _ref.className,
|
|
13
|
+
_ref$displayMode = _ref.displayMode,
|
|
14
|
+
displayMode = _ref$displayMode === void 0 ? 'left' : _ref$displayMode,
|
|
13
15
|
maxValue = _ref.maxValue,
|
|
14
16
|
value = _ref.value,
|
|
15
17
|
text = _ref.text,
|
|
@@ -38,7 +40,7 @@ var TokenTag = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
38
40
|
children: [/*#__PURE__*/_jsx(FluentEmoji, {
|
|
39
41
|
emoji: emoji,
|
|
40
42
|
size: ICON_SIZE
|
|
41
|
-
}), valueLeft > 0 ? (text === null || text === void 0 ? void 0 : text.tokens) || "Tokens ".concat(valueLeft) : (text === null || text === void 0 ? void 0 : text.overload) || 'Overload']
|
|
43
|
+
}), valueLeft > 0 ? (text === null || text === void 0 ? void 0 : text.tokens) || "Tokens ".concat(displayMode === 'left' ? valueLeft : value) : (text === null || text === void 0 ? void 0 : text.overload) || 'Overload']
|
|
42
44
|
}));
|
|
43
45
|
});
|
|
44
46
|
export default TokenTag;
|
|
@@ -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);
|