linkmore-design 1.0.59 → 1.0.63

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.
Files changed (352) hide show
  1. package/dist/AutoComplete/demos/basic.d.ts +3 -0
  2. package/dist/AutoComplete/index.d.ts +30 -0
  3. package/dist/AutoComplete/style/index.d.ts +1 -0
  4. package/dist/Avatar/demos/basic.d.ts +2 -0
  5. package/dist/Avatar/index.d.ts +3 -0
  6. package/dist/Avatar/style/index.d.ts +1 -0
  7. package/dist/Breadcrumb/demos/basic.d.ts +2 -0
  8. package/dist/Breadcrumb/demos/basic1.d.ts +2 -0
  9. package/dist/Breadcrumb/index.d.ts +4 -0
  10. package/dist/Breadcrumb/style/index.d.ts +1 -0
  11. package/dist/CardTable/fns/index.d.ts +1 -0
  12. package/dist/CardTable/utils.d.ts +1 -1
  13. package/dist/Col/demos/basic.d.ts +2 -0
  14. package/dist/Col/index.d.ts +3 -0
  15. package/dist/Col/style/index.d.ts +1 -0
  16. package/dist/Form/demos/error-tip.d.ts +2 -0
  17. package/dist/Form/index.d.ts +7 -2
  18. package/dist/Grid/RowContext.d.ts +8 -0
  19. package/dist/Grid/col.d.ts +28 -0
  20. package/dist/Grid/demos/basic.d.ts +2 -0
  21. package/dist/Grid/hooks/useBreakpoint.d.ts +3 -0
  22. package/dist/Grid/index.d.ts +11 -0
  23. package/dist/Grid/row.d.ts +14 -0
  24. package/dist/Grid/style/index.d.ts +1 -0
  25. package/dist/Layout/demos/basic.d.ts +2 -0
  26. package/dist/Layout/index.d.ts +4 -0
  27. package/dist/Layout/style/index.d.ts +1 -0
  28. package/dist/LmEditTable/EditTable.d.ts +2 -0
  29. package/dist/LmEditTable/demos/colsort.d.ts +2 -0
  30. package/dist/LmEditTable/demos/sinleEdit.d.ts +2 -0
  31. package/dist/LmEditTable/demos/size.d.ts +2 -0
  32. package/dist/LmEditTable/sortableBoxCol.d.ts +5 -0
  33. package/dist/LmEditTable/sortableItemCol.d.ts +1 -0
  34. package/dist/LmFilter/components/CustomSelectFilter.d.ts +4 -0
  35. package/dist/LmFilter/filterFns/index.d.ts +27 -10
  36. package/dist/LmFilter/localization.d.ts +8 -2
  37. package/dist/LmFilter/utils.d.ts +2 -0
  38. package/dist/PageHeader/demos/basic.d.ts +2 -0
  39. package/dist/PageHeader/index.d.ts +24 -0
  40. package/dist/PageHeader/style/index.d.ts +1 -0
  41. package/dist/Popover/demos/basic.d.ts +2 -0
  42. package/dist/Popover/demos/basic1.d.ts +2 -0
  43. package/dist/Popover/index.d.ts +11 -0
  44. package/dist/Popover/style/index.d.ts +1 -0
  45. package/dist/Row/demos/basic.d.ts +2 -0
  46. package/dist/Row/index.d.ts +3 -0
  47. package/dist/Row/style/index.d.ts +1 -0
  48. package/dist/Tooltip/index.d.ts +43 -1
  49. package/dist/Typography/Base/Ellipsis.d.ts +14 -0
  50. package/dist/Typography/Base/EllipsisTooltip.d.ts +13 -0
  51. package/dist/Typography/Base/index.d.ts +54 -0
  52. package/dist/Typography/Editable.d.ts +20 -0
  53. package/dist/Typography/Link.d.ts +7 -0
  54. package/dist/Typography/Paragraph.d.ts +7 -0
  55. package/dist/Typography/Text.d.ts +8 -0
  56. package/dist/Typography/Title.d.ts +9 -0
  57. package/dist/Typography/Typography.d.ts +11 -0
  58. package/dist/Typography/demos/basic.d.ts +2 -0
  59. package/dist/Typography/hooks/useMergedConfig.d.ts +1 -0
  60. package/dist/Typography/hooks/useUpdatedEffect.d.ts +3 -0
  61. package/dist/Typography/index.d.ts +15 -0
  62. package/dist/Typography/style/index.d.ts +1 -0
  63. package/dist/_util/colors.d.ts +5 -0
  64. package/dist/_util/getRenderPropValue.d.ts +3 -0
  65. package/dist/_util/hooks/useFlexGapSupport.d.ts +2 -0
  66. package/dist/_util/hooks/useForceUpdate.d.ts +2 -0
  67. package/dist/_util/placements.d.ts +16 -0
  68. package/dist/_util/responsiveObserve.d.ts +21 -0
  69. package/dist/_util/styleChecker.d.ts +4 -0
  70. package/dist/_util/transButton.d.ts +9 -0
  71. package/dist/index.d.ts +14 -0
  72. package/dist/index.umd.js +17392 -8920
  73. package/dist/index.umd.min.js +6 -6
  74. package/es/AutoComplete/index.d.ts +30 -0
  75. package/es/AutoComplete/index.js +101 -0
  76. package/es/AutoComplete/style/index.css +505 -0
  77. package/es/AutoComplete/style/index.d.ts +1 -0
  78. package/es/AutoComplete/style/index.js +1 -0
  79. package/es/Avatar/index.d.ts +3 -0
  80. package/es/Avatar/index.js +3 -0
  81. package/es/Avatar/style/index.css +505 -0
  82. package/es/Avatar/style/index.d.ts +1 -0
  83. package/es/Avatar/style/index.js +1 -0
  84. package/es/Breadcrumb/index.d.ts +4 -0
  85. package/es/Breadcrumb/index.js +3 -0
  86. package/es/Breadcrumb/style/index.css +505 -0
  87. package/es/Breadcrumb/style/index.d.ts +1 -0
  88. package/es/Breadcrumb/style/index.js +1 -0
  89. package/es/CardTable/body/TableBodyCell.js +10 -5
  90. package/es/CardTable/fns/index.js +29 -2
  91. package/es/CardTable/table/TableRoot.js +46 -13
  92. package/es/Col/README.md.old +22 -0
  93. package/es/Col/index.d.ts +3 -0
  94. package/es/Col/index.js +2 -0
  95. package/es/Col/style/index.css +505 -0
  96. package/es/Col/style/index.d.ts +1 -0
  97. package/es/Col/style/index.js +1 -0
  98. package/es/Dropdown/index.js +2 -2
  99. package/es/Dropdown/style/index.css +19 -1
  100. package/es/Form/index.d.ts +7 -2
  101. package/es/Form/index.js +18 -2
  102. package/es/Form/style/index.css +86 -1
  103. package/es/Grid/RowContext.d.ts +8 -0
  104. package/es/Grid/RowContext.js +3 -0
  105. package/es/Grid/col.d.ts +28 -0
  106. package/es/Grid/col.js +112 -0
  107. package/es/Grid/hooks/useBreakpoint.d.ts +3 -0
  108. package/es/Grid/hooks/useBreakpoint.js +24 -0
  109. package/es/Grid/index.d.ts +11 -0
  110. package/es/Grid/index.js +14 -0
  111. package/es/Grid/row.d.ts +14 -0
  112. package/es/Grid/row.js +142 -0
  113. package/es/Grid/style/index.css +505 -0
  114. package/es/Grid/style/index.d.ts +1 -0
  115. package/es/Grid/style/index.js +1 -0
  116. package/es/IconFont/index.js +1 -1
  117. package/es/Layout/index.d.ts +4 -0
  118. package/es/Layout/index.js +3 -0
  119. package/es/Layout/style/index.css +505 -0
  120. package/es/Layout/style/index.d.ts +1 -0
  121. package/es/Layout/style/index.js +1 -0
  122. package/es/LmEditTable/EditTable.d.ts +2 -0
  123. package/es/LmEditTable/EditTable.js +206 -58
  124. package/es/LmEditTable/sortableBoxCol.d.ts +5 -0
  125. package/es/LmEditTable/sortableBoxCol.js +13 -0
  126. package/es/LmEditTable/sortableItemCol.d.ts +1 -0
  127. package/es/LmEditTable/sortableItemCol.js +48 -0
  128. package/es/LmFilter/LmFilter.js +22 -4
  129. package/es/LmFilter/{icon_placeholder.png → assets/empty.png} +0 -0
  130. package/es/LmFilter/baseFilter/fuzzySearch.js +6 -1
  131. package/es/LmFilter/baseFilter/index.js +1 -3
  132. package/es/LmFilter/clearFilter/index.js +3 -5
  133. package/es/LmFilter/complexFilter/drawer.js +32 -20
  134. package/es/LmFilter/components/CheckboxFilter.js +1 -1
  135. package/es/LmFilter/components/CustomSelectFilter.js +128 -0
  136. package/es/LmFilter/components/EmptyFilter.js +2 -2
  137. package/es/LmFilter/components/SelectFilter.js +1 -1
  138. package/es/LmFilter/components/index.js +1 -1
  139. package/es/LmFilter/customFilter/index.js +75 -2
  140. package/es/LmFilter/filterFns/index.js +290 -62
  141. package/es/LmFilter/localization.d.ts +8 -2
  142. package/es/LmFilter/localization.js +20 -2
  143. package/es/LmFilter/style/style.css +50 -8
  144. package/es/LmFilter/utils.js +34 -0
  145. package/es/LmFilter/wrapper/Filter.js +4 -0
  146. package/es/LmFilter/wrapper/FilterContainer.js +0 -4
  147. package/es/LmFilter/wrapper/FilterRoot.js +28 -63
  148. package/es/LmTable/Table.js +9 -3
  149. package/es/LmTable/style/index.css +5 -0
  150. package/es/PageHeader/index.d.ts +24 -0
  151. package/es/PageHeader/index.js +169 -0
  152. package/es/PageHeader/style/index.css +505 -0
  153. package/es/PageHeader/style/index.d.ts +1 -0
  154. package/es/PageHeader/style/index.js +1 -0
  155. package/es/Popover/index.d.ts +11 -0
  156. package/es/Popover/index.js +63 -0
  157. package/es/Popover/style/index.css +505 -0
  158. package/es/Popover/style/index.d.ts +1 -0
  159. package/es/Popover/style/index.js +1 -0
  160. package/es/Row/README.md.old +22 -0
  161. package/es/Row/index.d.ts +3 -0
  162. package/es/Row/index.js +2 -0
  163. package/es/Row/style/index.css +505 -0
  164. package/es/Row/style/index.d.ts +1 -0
  165. package/es/Row/style/index.js +1 -0
  166. package/es/Tooltip/index.d.ts +43 -1
  167. package/es/Tooltip/index.js +236 -1
  168. package/es/Typography/Base/Ellipsis.d.ts +14 -0
  169. package/es/Typography/Base/Ellipsis.js +197 -0
  170. package/es/Typography/Base/EllipsisTooltip.d.ts +13 -0
  171. package/es/Typography/Base/EllipsisTooltip.js +23 -0
  172. package/es/Typography/Base/index.d.ts +54 -0
  173. package/es/Typography/Base/index.js +509 -0
  174. package/es/Typography/Editable.d.ts +20 -0
  175. package/es/Typography/Editable.js +117 -0
  176. package/es/Typography/Link.d.ts +7 -0
  177. package/es/Typography/Link.js +43 -0
  178. package/es/Typography/Paragraph.d.ts +7 -0
  179. package/es/Typography/Paragraph.js +12 -0
  180. package/es/Typography/Text.d.ts +8 -0
  181. package/es/Typography/Text.js +41 -0
  182. package/es/Typography/Title.d.ts +9 -0
  183. package/es/Typography/Title.js +41 -0
  184. package/es/Typography/Typography.d.ts +11 -0
  185. package/es/Typography/Typography.js +61 -0
  186. package/es/Typography/hooks/useMergedConfig.d.ts +1 -0
  187. package/es/Typography/hooks/useMergedConfig.js +8 -0
  188. package/es/Typography/hooks/useUpdatedEffect.d.ts +3 -0
  189. package/es/Typography/hooks/useUpdatedEffect.js +13 -0
  190. package/es/Typography/index.d.ts +15 -0
  191. package/es/Typography/index.js +14 -0
  192. package/es/Typography/style/index.css +505 -0
  193. package/es/Typography/style/index.d.ts +1 -0
  194. package/es/Typography/style/index.js +1 -0
  195. package/es/_util/colors.d.ts +5 -0
  196. package/es/_util/colors.js +4 -0
  197. package/es/_util/getRenderPropValue.d.ts +3 -0
  198. package/es/_util/getRenderPropValue.js +13 -0
  199. package/es/_util/hooks/useFlexGapSupport.d.ts +2 -0
  200. package/es/_util/hooks/useFlexGapSupport.js +14 -0
  201. package/es/_util/hooks/useForceUpdate.d.ts +2 -0
  202. package/es/_util/hooks/useForceUpdate.js +11 -0
  203. package/es/_util/placements.d.ts +16 -0
  204. package/es/_util/placements.js +87 -0
  205. package/es/_util/responsiveObserve.d.ts +21 -0
  206. package/es/_util/responsiveObserve.js +66 -0
  207. package/es/_util/styleChecker.d.ts +4 -0
  208. package/es/_util/styleChecker.js +31 -0
  209. package/es/_util/transButton.d.ts +9 -0
  210. package/es/_util/transButton.js +73 -0
  211. package/es/index.d.ts +14 -0
  212. package/es/index.js +8 -1
  213. package/lib/AutoComplete/index.d.ts +30 -0
  214. package/lib/AutoComplete/index.js +125 -0
  215. package/lib/AutoComplete/style/index.css +505 -0
  216. package/lib/AutoComplete/style/index.d.ts +1 -0
  217. package/lib/AutoComplete/style/index.js +3 -0
  218. package/lib/Avatar/index.d.ts +3 -0
  219. package/lib/Avatar/index.js +15 -0
  220. package/lib/Avatar/style/index.css +505 -0
  221. package/lib/Avatar/style/index.d.ts +1 -0
  222. package/lib/Avatar/style/index.js +3 -0
  223. package/lib/Breadcrumb/index.d.ts +4 -0
  224. package/lib/Breadcrumb/index.js +15 -0
  225. package/lib/Breadcrumb/style/index.css +505 -0
  226. package/lib/Breadcrumb/style/index.d.ts +1 -0
  227. package/lib/Breadcrumb/style/index.js +3 -0
  228. package/lib/CardTable/body/TableBodyCell.js +10 -5
  229. package/lib/CardTable/fns/index.js +29 -2
  230. package/lib/CardTable/table/TableRoot.js +46 -13
  231. package/lib/Col/README.md.old +22 -0
  232. package/lib/Col/index.d.ts +3 -0
  233. package/lib/Col/index.js +11 -0
  234. package/lib/Col/style/index.css +505 -0
  235. package/lib/Col/style/index.d.ts +1 -0
  236. package/lib/Col/style/index.js +3 -0
  237. package/lib/Dropdown/index.js +2 -2
  238. package/lib/Dropdown/style/index.css +19 -1
  239. package/lib/Form/index.d.ts +7 -2
  240. package/lib/Form/index.js +16 -1
  241. package/lib/Form/style/index.css +86 -1
  242. package/lib/Grid/RowContext.d.ts +8 -0
  243. package/lib/Grid/RowContext.js +12 -0
  244. package/lib/Grid/col.d.ts +28 -0
  245. package/lib/Grid/col.js +128 -0
  246. package/lib/Grid/hooks/useBreakpoint.d.ts +3 -0
  247. package/lib/Grid/hooks/useBreakpoint.js +37 -0
  248. package/lib/Grid/index.d.ts +11 -0
  249. package/lib/Grid/index.js +45 -0
  250. package/lib/Grid/row.d.ts +14 -0
  251. package/lib/Grid/row.js +164 -0
  252. package/lib/Grid/style/index.css +505 -0
  253. package/lib/Grid/style/index.d.ts +1 -0
  254. package/lib/Grid/style/index.js +3 -0
  255. package/lib/IconFont/index.js +1 -1
  256. package/lib/Layout/index.d.ts +4 -0
  257. package/lib/Layout/index.js +15 -0
  258. package/lib/Layout/style/index.css +505 -0
  259. package/lib/Layout/style/index.d.ts +1 -0
  260. package/lib/Layout/style/index.js +3 -0
  261. package/lib/LmEditTable/EditTable.d.ts +2 -0
  262. package/lib/LmEditTable/EditTable.js +207 -59
  263. package/lib/LmEditTable/sortableBoxCol.d.ts +5 -0
  264. package/lib/LmEditTable/sortableBoxCol.js +24 -0
  265. package/lib/LmEditTable/sortableItemCol.d.ts +1 -0
  266. package/lib/LmEditTable/sortableItemCol.js +61 -0
  267. package/lib/LmFilter/LmFilter.js +22 -4
  268. package/lib/LmFilter/{icon_placeholder.png → assets/empty.png} +0 -0
  269. package/lib/LmFilter/baseFilter/fuzzySearch.js +6 -1
  270. package/lib/LmFilter/baseFilter/index.js +1 -3
  271. package/lib/LmFilter/clearFilter/index.js +3 -5
  272. package/lib/LmFilter/complexFilter/drawer.js +32 -20
  273. package/lib/LmFilter/components/CheckboxFilter.js +1 -1
  274. package/lib/LmFilter/components/CustomSelectFilter.js +128 -0
  275. package/lib/LmFilter/components/EmptyFilter.js +2 -2
  276. package/lib/LmFilter/components/SelectFilter.js +1 -1
  277. package/lib/LmFilter/components/index.js +1 -1
  278. package/lib/LmFilter/customFilter/index.js +75 -2
  279. package/lib/LmFilter/filterFns/index.js +290 -62
  280. package/lib/LmFilter/localization.d.ts +8 -2
  281. package/lib/LmFilter/localization.js +20 -2
  282. package/lib/LmFilter/style/style.css +50 -8
  283. package/lib/LmFilter/utils.js +34 -0
  284. package/lib/LmFilter/wrapper/Filter.js +4 -0
  285. package/lib/LmFilter/wrapper/FilterContainer.js +0 -4
  286. package/lib/LmFilter/wrapper/FilterRoot.js +28 -63
  287. package/lib/LmTable/Table.js +9 -3
  288. package/lib/LmTable/style/index.css +5 -0
  289. package/lib/PageHeader/index.d.ts +24 -0
  290. package/lib/PageHeader/index.js +194 -0
  291. package/lib/PageHeader/style/index.css +505 -0
  292. package/lib/PageHeader/style/index.d.ts +1 -0
  293. package/lib/PageHeader/style/index.js +3 -0
  294. package/lib/Popover/index.d.ts +11 -0
  295. package/lib/Popover/index.js +81 -0
  296. package/lib/Popover/style/index.css +505 -0
  297. package/lib/Popover/style/index.d.ts +1 -0
  298. package/lib/Popover/style/index.js +3 -0
  299. package/lib/Row/README.md.old +22 -0
  300. package/lib/Row/index.d.ts +3 -0
  301. package/lib/Row/index.js +11 -0
  302. package/lib/Row/style/index.css +505 -0
  303. package/lib/Row/style/index.d.ts +1 -0
  304. package/lib/Row/style/index.js +3 -0
  305. package/lib/Tooltip/index.d.ts +43 -1
  306. package/lib/Tooltip/index.js +247 -1
  307. package/lib/Typography/Base/Ellipsis.d.ts +14 -0
  308. package/lib/Typography/Base/Ellipsis.js +212 -0
  309. package/lib/Typography/Base/EllipsisTooltip.d.ts +13 -0
  310. package/lib/Typography/Base/EllipsisTooltip.js +36 -0
  311. package/lib/Typography/Base/index.d.ts +54 -0
  312. package/lib/Typography/Base/index.js +545 -0
  313. package/lib/Typography/Editable.d.ts +20 -0
  314. package/lib/Typography/Editable.js +137 -0
  315. package/lib/Typography/Link.d.ts +7 -0
  316. package/lib/Typography/Link.js +58 -0
  317. package/lib/Typography/Paragraph.d.ts +7 -0
  318. package/lib/Typography/Paragraph.js +26 -0
  319. package/lib/Typography/Text.d.ts +8 -0
  320. package/lib/Typography/Text.js +57 -0
  321. package/lib/Typography/Title.d.ts +9 -0
  322. package/lib/Typography/Title.js +58 -0
  323. package/lib/Typography/Typography.d.ts +11 -0
  324. package/lib/Typography/Typography.js +77 -0
  325. package/lib/Typography/hooks/useMergedConfig.d.ts +1 -0
  326. package/lib/Typography/hooks/useMergedConfig.js +21 -0
  327. package/lib/Typography/hooks/useUpdatedEffect.d.ts +3 -0
  328. package/lib/Typography/hooks/useUpdatedEffect.js +24 -0
  329. package/lib/Typography/index.d.ts +15 -0
  330. package/lib/Typography/index.js +31 -0
  331. package/lib/Typography/style/index.css +505 -0
  332. package/lib/Typography/style/index.d.ts +1 -0
  333. package/lib/Typography/style/index.js +3 -0
  334. package/lib/_util/colors.d.ts +5 -0
  335. package/lib/_util/colors.js +14 -0
  336. package/lib/_util/getRenderPropValue.d.ts +3 -0
  337. package/lib/_util/getRenderPropValue.js +22 -0
  338. package/lib/_util/hooks/useFlexGapSupport.d.ts +2 -0
  339. package/lib/_util/hooks/useFlexGapSupport.js +30 -0
  340. package/lib/_util/hooks/useForceUpdate.d.ts +2 -0
  341. package/lib/_util/hooks/useForceUpdate.js +24 -0
  342. package/lib/_util/placements.d.ts +16 -0
  343. package/lib/_util/placements.js +98 -0
  344. package/lib/_util/responsiveObserve.d.ts +21 -0
  345. package/lib/_util/responsiveObserve.js +79 -0
  346. package/lib/_util/styleChecker.d.ts +4 -0
  347. package/lib/_util/styleChecker.js +52 -0
  348. package/lib/_util/transButton.d.ts +9 -0
  349. package/lib/_util/transButton.js +87 -0
  350. package/lib/index.d.ts +14 -0
  351. package/lib/index.js +57 -1
  352. package/package.json +3 -3
@@ -0,0 +1,545 @@
1
+ "use strict";
2
+
3
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
+
5
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
6
+
7
+ Object.defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+ exports.default = void 0;
11
+
12
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
+
14
+ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
15
+
16
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
17
+
18
+ var _CheckOutlined = _interopRequireDefault(require("@ant-design/icons/CheckOutlined"));
19
+
20
+ var _CopyOutlined = _interopRequireDefault(require("@ant-design/icons/CopyOutlined"));
21
+
22
+ var _EditOutlined = _interopRequireDefault(require("@ant-design/icons/EditOutlined"));
23
+
24
+ var _classnames = _interopRequireDefault(require("classnames"));
25
+
26
+ var _copyToClipboard = _interopRequireDefault(require("copy-to-clipboard"));
27
+
28
+ var _rcResizeObserver = _interopRequireDefault(require("rc-resize-observer"));
29
+
30
+ var _toArray = _interopRequireDefault(require("rc-util/lib/Children/toArray"));
31
+
32
+ var _useLayoutEffect = _interopRequireDefault(require("rc-util/lib/hooks/useLayoutEffect"));
33
+
34
+ var _useMergedState3 = _interopRequireDefault(require("rc-util/lib/hooks/useMergedState"));
35
+
36
+ var _omit = _interopRequireDefault(require("rc-util/lib/omit"));
37
+
38
+ var _ref3 = require("rc-util/lib/ref");
39
+
40
+ var React = _interopRequireWildcard(require("react"));
41
+
42
+ var _configProvider = require("antd/es/config-provider");
43
+
44
+ var _LocaleReceiver = require("antd/es/locale-provider/LocaleReceiver");
45
+
46
+ var _transButton = _interopRequireDefault(require("../../_util/transButton"));
47
+
48
+ var _styleChecker = require("../../_util/styleChecker");
49
+
50
+ var _Tooltip = _interopRequireDefault(require("../../Tooltip"));
51
+
52
+ var _Editable = _interopRequireDefault(require("../Editable"));
53
+
54
+ var _useMergedConfig7 = _interopRequireDefault(require("../hooks/useMergedConfig"));
55
+
56
+ var _useUpdatedEffect = _interopRequireDefault(require("../hooks/useUpdatedEffect"));
57
+
58
+ var _Typography = _interopRequireDefault(require("../Typography"));
59
+
60
+ var _Ellipsis = _interopRequireDefault(require("./Ellipsis"));
61
+
62
+ var _EllipsisTooltip = _interopRequireDefault(require("./EllipsisTooltip"));
63
+
64
+ var __rest = void 0 && (void 0).__rest || function (s, e) {
65
+ var t = {};
66
+
67
+ for (var p in s) {
68
+ if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
69
+ }
70
+
71
+ if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
72
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
73
+ }
74
+ return t;
75
+ };
76
+
77
+ function wrapperDecorations(_ref, content) {
78
+ var mark = _ref.mark,
79
+ code = _ref.code,
80
+ underline = _ref.underline,
81
+ del = _ref.delete,
82
+ strong = _ref.strong,
83
+ keyboard = _ref.keyboard,
84
+ italic = _ref.italic;
85
+ var currentContent = content;
86
+
87
+ function wrap(needed, tag) {
88
+ if (!needed) return;
89
+ currentContent = /*#__PURE__*/React.createElement(tag, {}, currentContent);
90
+ }
91
+
92
+ wrap(strong, 'strong');
93
+ wrap(underline, 'u');
94
+ wrap(del, 'del');
95
+ wrap(code, 'code');
96
+ wrap(mark, 'mark');
97
+ wrap(keyboard, 'kbd');
98
+ wrap(italic, 'i');
99
+ return currentContent;
100
+ }
101
+
102
+ function getNode(dom, defaultNode, needDom) {
103
+ if (dom === true || dom === undefined) {
104
+ return defaultNode;
105
+ }
106
+
107
+ return dom || needDom && defaultNode;
108
+ }
109
+
110
+ function toList(val) {
111
+ return Array.isArray(val) ? val : [val];
112
+ }
113
+
114
+ var ELLIPSIS_STR = '...';
115
+ var Base = /*#__PURE__*/React.forwardRef(function (props, ref) {
116
+ var customizePrefixCls = props.prefixCls,
117
+ className = props.className,
118
+ style = props.style,
119
+ type = props.type,
120
+ disabled = props.disabled,
121
+ children = props.children,
122
+ ellipsis = props.ellipsis,
123
+ editable = props.editable,
124
+ copyable = props.copyable,
125
+ component = props.component,
126
+ title = props.title,
127
+ restProps = __rest(props, ["prefixCls", "className", "style", "type", "disabled", "children", "ellipsis", "editable", "copyable", "component", "title"]);
128
+
129
+ var _React$useContext = React.useContext(_configProvider.ConfigContext),
130
+ getPrefixCls = _React$useContext.getPrefixCls,
131
+ direction = _React$useContext.direction;
132
+
133
+ var textLocale = (0, _LocaleReceiver.useLocaleReceiver)('Text')[0]; // Force TS get this
134
+
135
+ var typographyRef = React.useRef(null);
136
+ var editIconRef = React.useRef(null); // ============================ MISC ============================
137
+
138
+ var prefixCls = getPrefixCls('typography', customizePrefixCls);
139
+ var textProps = (0, _omit.default)(restProps, ['mark', 'code', 'delete', 'underline', 'strong', 'keyboard', 'italic']); // ========================== Editable ==========================
140
+
141
+ var _useMergedConfig = (0, _useMergedConfig7.default)(editable),
142
+ _useMergedConfig2 = (0, _slicedToArray2.default)(_useMergedConfig, 2),
143
+ enableEdit = _useMergedConfig2[0],
144
+ editConfig = _useMergedConfig2[1];
145
+
146
+ var _useMergedState = (0, _useMergedState3.default)(false, {
147
+ value: editConfig.editing
148
+ }),
149
+ _useMergedState2 = (0, _slicedToArray2.default)(_useMergedState, 2),
150
+ editing = _useMergedState2[0],
151
+ setEditing = _useMergedState2[1];
152
+
153
+ var _editConfig$triggerTy = editConfig.triggerType,
154
+ triggerType = _editConfig$triggerTy === void 0 ? ['icon'] : _editConfig$triggerTy;
155
+
156
+ var triggerEdit = function triggerEdit(edit) {
157
+ var _a;
158
+
159
+ if (edit) {
160
+ (_a = editConfig.onStart) === null || _a === void 0 ? void 0 : _a.call(editConfig);
161
+ }
162
+
163
+ setEditing(edit);
164
+ }; // Focus edit icon when back
165
+
166
+
167
+ (0, _useUpdatedEffect.default)(function () {
168
+ var _a;
169
+
170
+ if (!editing) {
171
+ (_a = editIconRef.current) === null || _a === void 0 ? void 0 : _a.focus();
172
+ }
173
+ }, [editing]);
174
+
175
+ var onEditClick = function onEditClick(e) {
176
+ e === null || e === void 0 ? void 0 : e.preventDefault();
177
+ triggerEdit(true);
178
+ };
179
+
180
+ var onEditChange = function onEditChange(value) {
181
+ var _a;
182
+
183
+ (_a = editConfig.onChange) === null || _a === void 0 ? void 0 : _a.call(editConfig, value);
184
+ triggerEdit(false);
185
+ };
186
+
187
+ var onEditCancel = function onEditCancel() {
188
+ var _a;
189
+
190
+ (_a = editConfig.onCancel) === null || _a === void 0 ? void 0 : _a.call(editConfig);
191
+ triggerEdit(false);
192
+ }; // ========================== Copyable ==========================
193
+
194
+
195
+ var _useMergedConfig3 = (0, _useMergedConfig7.default)(copyable),
196
+ _useMergedConfig4 = (0, _slicedToArray2.default)(_useMergedConfig3, 2),
197
+ enableCopy = _useMergedConfig4[0],
198
+ copyConfig = _useMergedConfig4[1];
199
+
200
+ var _React$useState = React.useState(false),
201
+ _React$useState2 = (0, _slicedToArray2.default)(_React$useState, 2),
202
+ copied = _React$useState2[0],
203
+ setCopied = _React$useState2[1];
204
+
205
+ var copyIdRef = React.useRef();
206
+ var copyOptions = {};
207
+
208
+ if (copyConfig.format) {
209
+ copyOptions.format = copyConfig.format;
210
+ }
211
+
212
+ var cleanCopyId = function cleanCopyId() {
213
+ clearTimeout(copyIdRef.current);
214
+ };
215
+
216
+ var onCopyClick = function onCopyClick(e) {
217
+ var _a;
218
+
219
+ e === null || e === void 0 ? void 0 : e.preventDefault();
220
+ e === null || e === void 0 ? void 0 : e.stopPropagation();
221
+ (0, _copyToClipboard.default)(copyConfig.text || String(children) || '', copyOptions);
222
+ setCopied(true); // Trigger tips update
223
+
224
+ cleanCopyId();
225
+ copyIdRef.current = setTimeout(function () {
226
+ setCopied(false);
227
+ }, 3000);
228
+ (_a = copyConfig.onCopy) === null || _a === void 0 ? void 0 : _a.call(copyConfig, e);
229
+ };
230
+
231
+ React.useEffect(function () {
232
+ return cleanCopyId;
233
+ }, []); // ========================== Ellipsis ==========================
234
+
235
+ var _React$useState3 = React.useState(false),
236
+ _React$useState4 = (0, _slicedToArray2.default)(_React$useState3, 2),
237
+ isLineClampSupport = _React$useState4[0],
238
+ setIsLineClampSupport = _React$useState4[1];
239
+
240
+ var _React$useState5 = React.useState(false),
241
+ _React$useState6 = (0, _slicedToArray2.default)(_React$useState5, 2),
242
+ isTextOverflowSupport = _React$useState6[0],
243
+ setIsTextOverflowSupport = _React$useState6[1];
244
+
245
+ var _React$useState7 = React.useState(false),
246
+ _React$useState8 = (0, _slicedToArray2.default)(_React$useState7, 2),
247
+ expanded = _React$useState8[0],
248
+ setExpanded = _React$useState8[1];
249
+
250
+ var _React$useState9 = React.useState(false),
251
+ _React$useState10 = (0, _slicedToArray2.default)(_React$useState9, 2),
252
+ isJsEllipsis = _React$useState10[0],
253
+ setIsJsEllipsis = _React$useState10[1];
254
+
255
+ var _React$useState11 = React.useState(false),
256
+ _React$useState12 = (0, _slicedToArray2.default)(_React$useState11, 2),
257
+ isNativeEllipsis = _React$useState12[0],
258
+ setIsNativeEllipsis = _React$useState12[1];
259
+
260
+ var _React$useState13 = React.useState(true),
261
+ _React$useState14 = (0, _slicedToArray2.default)(_React$useState13, 2),
262
+ isNativeVisible = _React$useState14[0],
263
+ setIsNativeVisible = _React$useState14[1];
264
+
265
+ var _useMergedConfig5 = (0, _useMergedConfig7.default)(ellipsis, {
266
+ expandable: false
267
+ }),
268
+ _useMergedConfig6 = (0, _slicedToArray2.default)(_useMergedConfig5, 2),
269
+ enableEllipsis = _useMergedConfig6[0],
270
+ ellipsisConfig = _useMergedConfig6[1];
271
+
272
+ var mergedEnableEllipsis = enableEllipsis && !expanded; // Shared prop to reduce bundle size
273
+
274
+ var _ellipsisConfig$rows = ellipsisConfig.rows,
275
+ rows = _ellipsisConfig$rows === void 0 ? 1 : _ellipsisConfig$rows;
276
+ var needMeasureEllipsis = React.useMemo(function () {
277
+ return (// Disable ellipsis
278
+ !mergedEnableEllipsis || // Provide suffix
279
+ ellipsisConfig.suffix !== undefined || ellipsisConfig.onEllipsis || // Can't use css ellipsis since we need to provide the place for button
280
+ ellipsisConfig.expandable || enableEdit || enableCopy
281
+ );
282
+ }, [mergedEnableEllipsis, ellipsisConfig, enableEdit, enableCopy]);
283
+ (0, _useLayoutEffect.default)(function () {
284
+ if (enableEllipsis && !needMeasureEllipsis) {
285
+ setIsLineClampSupport((0, _styleChecker.isStyleSupport)('webkitLineClamp'));
286
+ setIsTextOverflowSupport((0, _styleChecker.isStyleSupport)('textOverflow'));
287
+ }
288
+ }, [needMeasureEllipsis, enableEllipsis]);
289
+ var cssEllipsis = React.useMemo(function () {
290
+ if (needMeasureEllipsis) {
291
+ return false;
292
+ }
293
+
294
+ if (rows === 1) {
295
+ return isTextOverflowSupport;
296
+ }
297
+
298
+ return isLineClampSupport;
299
+ }, [needMeasureEllipsis, isTextOverflowSupport, isLineClampSupport]);
300
+ var isMergedEllipsis = mergedEnableEllipsis && (cssEllipsis ? isNativeEllipsis : isJsEllipsis);
301
+ var cssTextOverflow = mergedEnableEllipsis && rows === 1 && cssEllipsis;
302
+ var cssLineClamp = mergedEnableEllipsis && rows > 1 && cssEllipsis; // >>>>> Expand
303
+
304
+ var onExpandClick = function onExpandClick(e) {
305
+ var _a;
306
+
307
+ setExpanded(true);
308
+ (_a = ellipsisConfig.onExpand) === null || _a === void 0 ? void 0 : _a.call(ellipsisConfig, e);
309
+ };
310
+
311
+ var _React$useState15 = React.useState(0),
312
+ _React$useState16 = (0, _slicedToArray2.default)(_React$useState15, 2),
313
+ ellipsisWidth = _React$useState16[0],
314
+ setEllipsisWidth = _React$useState16[1];
315
+
316
+ var onResize = function onResize(_ref2) {
317
+ var offsetWidth = _ref2.offsetWidth;
318
+ setEllipsisWidth(offsetWidth);
319
+ }; // >>>>> JS Ellipsis
320
+
321
+
322
+ var onJsEllipsis = function onJsEllipsis(jsEllipsis) {
323
+ var _a;
324
+
325
+ setIsJsEllipsis(jsEllipsis); // Trigger if changed
326
+
327
+ if (isJsEllipsis !== jsEllipsis) {
328
+ (_a = ellipsisConfig.onEllipsis) === null || _a === void 0 ? void 0 : _a.call(ellipsisConfig, jsEllipsis);
329
+ }
330
+ }; // >>>>> Native ellipsis
331
+
332
+
333
+ React.useEffect(function () {
334
+ var textEle = typographyRef.current;
335
+
336
+ if (enableEllipsis && cssEllipsis && textEle) {
337
+ var currentEllipsis = cssLineClamp ? textEle.offsetHeight < textEle.scrollHeight : textEle.offsetWidth < textEle.scrollWidth;
338
+
339
+ if (isNativeEllipsis !== currentEllipsis) {
340
+ setIsNativeEllipsis(currentEllipsis);
341
+ }
342
+ }
343
+ }, [enableEllipsis, cssEllipsis, children, cssLineClamp, isNativeVisible]); // https://github.com/ant-design/ant-design/issues/36786
344
+ // Use IntersectionObserver to check if element is invisible
345
+
346
+ React.useEffect(function () {
347
+ var textEle = typographyRef.current;
348
+
349
+ if (typeof IntersectionObserver === 'undefined' || !textEle || !cssEllipsis || !mergedEnableEllipsis) {
350
+ // @ts-ignore
351
+ return;
352
+ }
353
+ /* eslint-disable-next-line compat/compat */
354
+
355
+
356
+ var observer = new IntersectionObserver(function () {
357
+ setIsNativeVisible(!!textEle.offsetParent);
358
+ });
359
+ observer.observe(textEle);
360
+ return function () {
361
+ observer.disconnect();
362
+ };
363
+ }, [cssEllipsis, mergedEnableEllipsis]); // ========================== Tooltip ===========================
364
+
365
+ var tooltipProps = {};
366
+
367
+ if (ellipsisConfig.tooltip === true) {
368
+ tooltipProps = {
369
+ title: children
370
+ };
371
+ } else if ( /*#__PURE__*/React.isValidElement(ellipsisConfig.tooltip)) {
372
+ tooltipProps = {
373
+ title: ellipsisConfig.tooltip
374
+ };
375
+ } else if ((0, _typeof2.default)(ellipsisConfig.tooltip) === 'object') {
376
+ tooltipProps = Object.assign({
377
+ title: children
378
+ }, ellipsisConfig.tooltip);
379
+ } else {
380
+ tooltipProps = {
381
+ title: ellipsisConfig.tooltip
382
+ };
383
+ }
384
+
385
+ var topAriaLabel = React.useMemo(function () {
386
+ var isValid = function isValid(val) {
387
+ return ['string', 'number'].includes((0, _typeof2.default)(val));
388
+ };
389
+
390
+ if (!enableEllipsis || cssEllipsis) {
391
+ return undefined;
392
+ }
393
+
394
+ if (isValid(children)) {
395
+ return children;
396
+ }
397
+
398
+ if (isValid(title)) {
399
+ return title;
400
+ }
401
+
402
+ if (isValid(tooltipProps.title)) {
403
+ return tooltipProps.title;
404
+ }
405
+
406
+ return undefined;
407
+ }, [enableEllipsis, cssEllipsis, title, tooltipProps.title, isMergedEllipsis]); // =========================== Render ===========================
408
+ // >>>>>>>>>>> Editing input
409
+
410
+ if (editing) {
411
+ return /*#__PURE__*/React.createElement(_Editable.default, {
412
+ value: typeof children === 'string' ? children : '',
413
+ onSave: onEditChange,
414
+ onCancel: onEditCancel,
415
+ onEnd: editConfig.onEnd,
416
+ prefixCls: prefixCls,
417
+ className: className,
418
+ style: style,
419
+ direction: direction,
420
+ component: component,
421
+ maxLength: editConfig.maxLength,
422
+ autoSize: editConfig.autoSize,
423
+ enterIcon: editConfig.enterIcon
424
+ });
425
+ } // >>>>>>>>>>> Typography
426
+ // Expand
427
+
428
+
429
+ var renderExpand = function renderExpand() {
430
+ var expandable = ellipsisConfig.expandable,
431
+ symbol = ellipsisConfig.symbol;
432
+ if (!expandable) return null;
433
+ var expandContent;
434
+
435
+ if (symbol) {
436
+ expandContent = symbol;
437
+ } else {
438
+ expandContent = textLocale.expand;
439
+ }
440
+
441
+ return /*#__PURE__*/React.createElement("a", {
442
+ key: "expand",
443
+ className: "".concat(prefixCls, "-expand"),
444
+ onClick: onExpandClick,
445
+ "aria-label": textLocale.expand
446
+ }, expandContent);
447
+ }; // Edit
448
+
449
+
450
+ var renderEdit = function renderEdit() {
451
+ // @ts-ignore
452
+ if (!enableEdit) return;
453
+ var icon = editConfig.icon,
454
+ tooltip = editConfig.tooltip;
455
+ var editTitle = (0, _toArray.default)(tooltip)[0] || textLocale.edit;
456
+ var ariaLabel = typeof editTitle === 'string' ? editTitle : '';
457
+ return triggerType.includes('icon') ? /*#__PURE__*/React.createElement(_Tooltip.default, {
458
+ key: "edit",
459
+ title: tooltip === false ? '' : editTitle
460
+ }, /*#__PURE__*/React.createElement(_transButton.default, {
461
+ ref: editIconRef,
462
+ className: "".concat(prefixCls, "-edit"),
463
+ onClick: onEditClick,
464
+ "aria-label": ariaLabel
465
+ }, icon || /*#__PURE__*/React.createElement(_EditOutlined.default, {
466
+ role: "button"
467
+ }))) : null;
468
+ }; // Copy
469
+
470
+
471
+ var renderCopy = function renderCopy() {
472
+ // @ts-ignore
473
+ if (!enableCopy) return;
474
+ var tooltips = copyConfig.tooltips,
475
+ icon = copyConfig.icon;
476
+ var tooltipNodes = toList(tooltips);
477
+ var iconNodes = toList(icon);
478
+ var copyTitle = copied ? getNode(tooltipNodes[1], textLocale.copied) : getNode(tooltipNodes[0], textLocale.copy);
479
+ var systemStr = copied ? textLocale.copied : textLocale.copy;
480
+ var ariaLabel = typeof copyTitle === 'string' ? copyTitle : systemStr;
481
+ return /*#__PURE__*/React.createElement(_Tooltip.default, {
482
+ key: "copy",
483
+ title: copyTitle
484
+ }, /*#__PURE__*/React.createElement(_transButton.default, {
485
+ className: (0, _classnames.default)("".concat(prefixCls, "-copy"), copied && "".concat(prefixCls, "-copy-success")),
486
+ onClick: onCopyClick,
487
+ "aria-label": ariaLabel
488
+ }, copied ? getNode(iconNodes[1], /*#__PURE__*/React.createElement(_CheckOutlined.default, null), true) : getNode(iconNodes[0], /*#__PURE__*/React.createElement(_CopyOutlined.default, null), true)));
489
+ };
490
+
491
+ var renderOperations = function renderOperations(renderExpanded) {
492
+ return [renderExpanded && renderExpand(), renderEdit(), renderCopy()];
493
+ };
494
+
495
+ var renderEllipsis = function renderEllipsis(needEllipsis) {
496
+ return [needEllipsis && /*#__PURE__*/React.createElement("span", {
497
+ "aria-hidden": true,
498
+ key: "ellipsis"
499
+ }, ELLIPSIS_STR), ellipsisConfig.suffix, renderOperations(needEllipsis)];
500
+ };
501
+
502
+ return /*#__PURE__*/React.createElement(_rcResizeObserver.default, {
503
+ onResize: onResize,
504
+ disabled: !mergedEnableEllipsis || cssEllipsis
505
+ }, function (resizeRef) {
506
+ var _classNames;
507
+
508
+ return /*#__PURE__*/React.createElement(_EllipsisTooltip.default, {
509
+ tooltipProps: tooltipProps,
510
+ enabledEllipsis: mergedEnableEllipsis,
511
+ isEllipsis: isMergedEllipsis
512
+ }, /*#__PURE__*/React.createElement(_Typography.default, Object.assign({
513
+ className: (0, _classnames.default)((_classNames = {}, (0, _defineProperty2.default)(_classNames, "".concat(prefixCls, "-").concat(type), type), (0, _defineProperty2.default)(_classNames, "".concat(prefixCls, "-disabled"), disabled), (0, _defineProperty2.default)(_classNames, "".concat(prefixCls, "-ellipsis"), enableEllipsis), (0, _defineProperty2.default)(_classNames, "".concat(prefixCls, "-single-line"), mergedEnableEllipsis && rows === 1), (0, _defineProperty2.default)(_classNames, "".concat(prefixCls, "-ellipsis-single-line"), cssTextOverflow), (0, _defineProperty2.default)(_classNames, "".concat(prefixCls, "-ellipsis-multiple-line"), cssLineClamp), _classNames), className),
514
+ style: Object.assign(Object.assign({}, style), {
515
+ WebkitLineClamp: cssLineClamp ? rows : undefined
516
+ }),
517
+ component: component,
518
+ ref: (0, _ref3.composeRef)(resizeRef, typographyRef, ref),
519
+ direction: direction,
520
+ onClick: triggerType.includes('text') ? onEditClick : null,
521
+ "aria-label": topAriaLabel,
522
+ title: title
523
+ }, textProps), /*#__PURE__*/React.createElement(_Ellipsis.default, {
524
+ enabledMeasure: mergedEnableEllipsis && !cssEllipsis,
525
+ text: children,
526
+ rows: rows,
527
+ width: ellipsisWidth,
528
+ onEllipsis: onJsEllipsis
529
+ }, function (node, needEllipsis) {
530
+ var renderNode = node;
531
+
532
+ if (node.length && needEllipsis && topAriaLabel) {
533
+ renderNode = /*#__PURE__*/React.createElement("span", {
534
+ key: "show-content",
535
+ "aria-hidden": true
536
+ }, renderNode);
537
+ }
538
+
539
+ var wrappedContext = wrapperDecorations(props, /*#__PURE__*/React.createElement(React.Fragment, null, renderNode, renderEllipsis(needEllipsis)));
540
+ return wrappedContext;
541
+ })));
542
+ });
543
+ });
544
+ var _default = Base;
545
+ exports.default = _default;
@@ -0,0 +1,20 @@
1
+ import type { AutoSizeType } from 'rc-textarea/lib/ResizableTextArea';
2
+ import * as React from 'react';
3
+ import type { DirectionType } from 'antd/es/config-provider';
4
+ interface EditableProps {
5
+ prefixCls?: string;
6
+ value: string;
7
+ ['aria-label']?: string;
8
+ onSave: (value: string) => void;
9
+ onCancel: () => void;
10
+ onEnd?: () => void;
11
+ className?: string;
12
+ style?: React.CSSProperties;
13
+ direction?: DirectionType;
14
+ maxLength?: number;
15
+ autoSize?: boolean | AutoSizeType;
16
+ enterIcon?: React.ReactNode;
17
+ component?: string;
18
+ }
19
+ declare const Editable: React.FC<EditableProps>;
20
+ export default Editable;
@@ -0,0 +1,137 @@
1
+ "use strict";
2
+
3
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
+
5
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
6
+
7
+ Object.defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+ exports.default = void 0;
11
+
12
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
+
14
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
15
+
16
+ var _EnterOutlined = _interopRequireDefault(require("@ant-design/icons/EnterOutlined"));
17
+
18
+ var _classnames = _interopRequireDefault(require("classnames"));
19
+
20
+ var _KeyCode = _interopRequireDefault(require("rc-util/lib/KeyCode"));
21
+
22
+ var React = _interopRequireWildcard(require("react"));
23
+
24
+ var _linkmoreDesign = require("linkmore-design");
25
+
26
+ var _reactNode = require("../_util/reactNode");
27
+
28
+ var TextArea = _linkmoreDesign.Input.TextArea;
29
+
30
+ var Editable = function Editable(_ref) {
31
+ var prefixCls = _ref.prefixCls,
32
+ ariaLabel = _ref['aria-label'],
33
+ className = _ref.className,
34
+ style = _ref.style,
35
+ direction = _ref.direction,
36
+ maxLength = _ref.maxLength,
37
+ _ref$autoSize = _ref.autoSize,
38
+ autoSize = _ref$autoSize === void 0 ? true : _ref$autoSize,
39
+ value = _ref.value,
40
+ onSave = _ref.onSave,
41
+ onCancel = _ref.onCancel,
42
+ onEnd = _ref.onEnd,
43
+ component = _ref.component,
44
+ _ref$enterIcon = _ref.enterIcon,
45
+ enterIcon = _ref$enterIcon === void 0 ? /*#__PURE__*/React.createElement(_EnterOutlined.default, null) : _ref$enterIcon;
46
+ var ref = React.useRef();
47
+ var inComposition = React.useRef(false);
48
+ var lastKeyCode = React.useRef();
49
+
50
+ var _React$useState = React.useState(value),
51
+ _React$useState2 = (0, _slicedToArray2.default)(_React$useState, 2),
52
+ current = _React$useState2[0],
53
+ setCurrent = _React$useState2[1];
54
+
55
+ React.useEffect(function () {
56
+ setCurrent(value);
57
+ }, [value]);
58
+ React.useEffect(function () {
59
+ if (ref.current && ref.current.resizableTextArea) {
60
+ var textArea = ref.current.resizableTextArea.textArea;
61
+ textArea.focus();
62
+ var length = textArea.value.length;
63
+ textArea.setSelectionRange(length, length);
64
+ }
65
+ }, []);
66
+
67
+ var onChange = function onChange(_ref2) {
68
+ var target = _ref2.target;
69
+ setCurrent(target.value.replace(/[\n\r]/g, ''));
70
+ };
71
+
72
+ var onCompositionStart = function onCompositionStart() {
73
+ inComposition.current = true;
74
+ };
75
+
76
+ var onCompositionEnd = function onCompositionEnd() {
77
+ inComposition.current = false;
78
+ };
79
+
80
+ var onKeyDown = function onKeyDown(_ref3) {
81
+ var keyCode = _ref3.keyCode;
82
+ // We don't record keyCode when IME is using
83
+ if (inComposition.current) return;
84
+ lastKeyCode.current = keyCode;
85
+ };
86
+
87
+ var confirmChange = function confirmChange() {
88
+ onSave(current.trim());
89
+ };
90
+
91
+ var onKeyUp = function onKeyUp(_ref4) {
92
+ var keyCode = _ref4.keyCode,
93
+ ctrlKey = _ref4.ctrlKey,
94
+ altKey = _ref4.altKey,
95
+ metaKey = _ref4.metaKey,
96
+ shiftKey = _ref4.shiftKey;
97
+
98
+ // Check if it's a real key
99
+ if (lastKeyCode.current === keyCode && !inComposition.current && !ctrlKey && !altKey && !metaKey && !shiftKey) {
100
+ if (keyCode === _KeyCode.default.ENTER) {
101
+ confirmChange();
102
+ onEnd === null || onEnd === void 0 ? void 0 : onEnd();
103
+ } else if (keyCode === _KeyCode.default.ESC) {
104
+ onCancel();
105
+ }
106
+ }
107
+ };
108
+
109
+ var onBlur = function onBlur() {
110
+ confirmChange();
111
+ };
112
+
113
+ var textClassName = component ? "".concat(prefixCls, "-").concat(component) : '';
114
+ var textAreaClassName = (0, _classnames.default)(prefixCls, "".concat(prefixCls, "-edit-content"), (0, _defineProperty2.default)({}, "".concat(prefixCls, "-rtl"), direction === 'rtl'), className, textClassName);
115
+ return /*#__PURE__*/React.createElement("div", {
116
+ className: textAreaClassName,
117
+ style: style
118
+ }, /*#__PURE__*/React.createElement(TextArea, {
119
+ ref: ref,
120
+ maxLength: maxLength,
121
+ value: current,
122
+ onChange: onChange,
123
+ onKeyDown: onKeyDown,
124
+ onKeyUp: onKeyUp,
125
+ onCompositionStart: onCompositionStart,
126
+ onCompositionEnd: onCompositionEnd,
127
+ onBlur: onBlur,
128
+ "aria-label": ariaLabel,
129
+ rows: 1,
130
+ autoSize: autoSize
131
+ }), enterIcon !== null ? (0, _reactNode.cloneElement)(enterIcon, {
132
+ className: "".concat(prefixCls, "-edit-content-confirm")
133
+ }) : null);
134
+ };
135
+
136
+ var _default = Editable;
137
+ exports.default = _default;