@lobehub/ui 1.60.2 → 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 type EditableTextProps = ControlInputProps;
4
- declare const EditableText: import("react").NamedExoticComponent<ControlInputProps>;
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;
@@ -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, useState } from 'react';
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
- onChange = _ref.onChange;
12
- var _useState = useState(false),
13
- _useState2 = _slicedToArray(_useState, 2),
14
- edited = _useState2[0],
15
- setEdited = _useState2[1];
16
- return edited ? /*#__PURE__*/_jsx(ControlInput, {
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);
@@ -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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/ui",
3
- "version": "1.60.2",
3
+ "version": "1.61.0",
4
4
  "description": "Lobe UI is an open-source UI component library for building chatbot web apps",
5
5
  "keywords": [
6
6
  "lobehub",