@pisell/materials 6.11.4 → 6.11.6

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 (292) hide show
  1. package/build/lowcode/assets-daily.json +11 -11
  2. package/build/lowcode/assets-dev.json +2 -2
  3. package/build/lowcode/assets-prod.json +11 -11
  4. package/build/lowcode/index.js +1 -1
  5. package/build/lowcode/meta.js +7 -7
  6. package/build/lowcode/preview.js +9 -9
  7. package/build/lowcode/render/default/view.css +1 -1
  8. package/build/lowcode/render/default/view.js +16 -16
  9. package/build/lowcode/view.css +1 -1
  10. package/build/lowcode/view.js +15 -15
  11. package/es/components/PisellSuperTabs/PisellSuperTabs.d.ts +1 -1
  12. package/es/components/PisellSuperTabs/PisellSuperTabs.js +7 -4
  13. package/es/components/PisellSuperTabs/hooks/useTabsState.js +3 -8
  14. package/es/components/PisellSuperTabs/types.d.ts +2 -0
  15. package/es/components/PisellTabbar/PisellTabbar.d.ts +1 -1
  16. package/es/components/PisellTabbar/PisellTabbar.js +411 -62
  17. package/es/components/PisellTabbar/constants.d.ts +2 -1
  18. package/es/components/PisellTabbar/constants.js +5 -4
  19. package/es/components/PisellTabbar/hooks/useActiveKey.d.ts +6 -0
  20. package/es/components/PisellTabbar/hooks/useActiveKey.js +21 -2
  21. package/es/components/PisellTabbar/hooks/useExpand.d.ts +1 -0
  22. package/es/components/PisellTabbar/hooks/useExpand.js +9 -1
  23. package/es/components/PisellTabbar/template/Template1/PisellTabbar.d.ts +3 -18
  24. package/es/components/PisellTabbar/template/Template1/PisellTabbar.js +124 -28
  25. package/es/components/PisellTabbar/template/Template1/constants.js +1 -1
  26. package/es/components/PisellTabbar/types.d.ts +5 -26
  27. package/es/components/PisellTabbar/utils/index.d.ts +2 -1
  28. package/es/components/PisellTabbar/utils/index.js +2 -1
  29. package/es/components/dataSourceComponents/dataSourceTable/hooks/useDataSourceKey.d.ts +2 -2
  30. package/es/components/dataSourceComponents/dataSourceTable/hooks/useTableProps.d.ts +2 -2
  31. package/es/components/page/index.js +6 -1
  32. package/es/components/pisellDataSourceContainer/hooks/useDataSourceKey.d.ts +2 -2
  33. package/es/components/pisellDateTimeDisplay/PisellDateTimeDisplay.js +47 -34
  34. package/es/components/pisellDateTimeDisplay/PisellDateTimeDisplay.stories.d.ts +19 -0
  35. package/es/components/pisellDateTimeDisplay/PisellDateTimeDisplay.stories.js +74 -0
  36. package/es/components/pisellDateTimeDisplay/components/DateDisplay.d.ts +6 -1
  37. package/es/components/pisellDateTimeDisplay/components/DateDisplay.js +10 -3
  38. package/es/components/pisellDateTimeDisplay/formats/dateTimeDisplayFormats.d.ts +7 -0
  39. package/es/components/pisellDateTimeDisplay/formats/dateTimeDisplayFormats.js +81 -0
  40. package/es/components/pisellDateTimeDisplay/formats/index.d.ts +1 -0
  41. package/es/components/pisellDateTimeDisplay/formats/index.js +1 -0
  42. package/es/components/pisellDateTimeDisplay/hooks/useCurrentTime.d.ts +2 -2
  43. package/es/components/pisellDateTimeDisplay/hooks/useCurrentTime.js +2 -2
  44. package/es/components/pisellDateTimeDisplay/index.d.ts +1 -0
  45. package/es/components/pisellDateTimeDisplay/index.js +2 -1
  46. package/es/components/pisellDateTimeDisplay/types.d.ts +48 -2
  47. package/es/components/pisellDateTimeDisplay/utils/formatDate.js +25 -6
  48. package/es/components/pisellDateTimeDisplay/utils/formatDateOrRelative.d.ts +17 -0
  49. package/es/components/pisellDateTimeDisplay/utils/formatDateOrRelative.js +38 -0
  50. package/es/components/pisellDateTimeDisplay/utils/formatWeekday.js +11 -12
  51. package/es/components/pisellDateTimeDisplay/utils/index.d.ts +3 -1
  52. package/es/components/pisellDateTimeDisplay/utils/index.js +3 -1
  53. package/es/components/pisellDateTimeDisplay/utils/localeUtils.d.ts +2 -7
  54. package/es/components/pisellDateTimeDisplay/utils/localeUtils.js +4 -17
  55. package/es/components/pisellDateTimeDisplay/utils/relativeDay.d.ts +23 -0
  56. package/es/components/pisellDateTimeDisplay/utils/relativeDay.js +45 -0
  57. package/es/components/pisellEmail/PisellEmail.less +2 -2
  58. package/es/components/pisellFind/PisellFind.stories.d.ts +45 -0
  59. package/es/components/pisellFind/PisellFind.stories.js +479 -0
  60. package/es/components/pisellFind/index.d.ts +40 -0
  61. package/es/components/pisellFind/index.js +72 -0
  62. package/es/components/pisellLongText/PisellLongText.less +2 -2
  63. package/es/components/pisellLookup/PisellLookup.d.ts +4 -0
  64. package/es/components/pisellLookup/PisellLookup.js +636 -0
  65. package/es/components/pisellLookup/PisellLookup.less +640 -0
  66. package/es/components/pisellLookup/PisellLookup.stories.d.ts +129 -0
  67. package/es/components/pisellLookup/PisellLookup.stories.js +1012 -0
  68. package/es/components/pisellLookup/components/HotWords.d.ts +7 -0
  69. package/es/components/pisellLookup/components/HotWords.js +49 -0
  70. package/es/components/pisellLookup/components/LookupAuxiliary.d.ts +7 -0
  71. package/es/components/pisellLookup/components/LookupAuxiliary.js +59 -0
  72. package/es/components/pisellLookup/components/LookupResultHost.d.ts +7 -0
  73. package/es/components/pisellLookup/components/LookupResultHost.js +185 -0
  74. package/es/components/pisellLookup/components/LookupTrigger.d.ts +3 -0
  75. package/es/components/pisellLookup/components/LookupTrigger.js +358 -0
  76. package/es/components/pisellLookup/components/SearchHistory.d.ts +7 -0
  77. package/es/components/pisellLookup/components/SearchHistory.js +68 -0
  78. package/es/components/pisellLookup/components/SuggestWords.d.ts +7 -0
  79. package/es/components/pisellLookup/components/SuggestWords.js +53 -0
  80. package/es/components/pisellLookup/components/index.d.ts +9 -0
  81. package/es/components/pisellLookup/components/index.js +10 -0
  82. package/es/components/pisellLookup/hooks/index.d.ts +6 -0
  83. package/es/components/pisellLookup/hooks/index.js +7 -0
  84. package/es/components/pisellLookup/hooks/useDebounceSearch.d.ts +40 -0
  85. package/es/components/pisellLookup/hooks/useDebounceSearch.js +78 -0
  86. package/es/components/pisellLookup/hooks/useSearchHistory.d.ts +48 -0
  87. package/es/components/pisellLookup/hooks/useSearchHistory.js +125 -0
  88. package/es/components/pisellLookup/hooks/useSearchState.d.ts +80 -0
  89. package/es/components/pisellLookup/hooks/useSearchState.js +113 -0
  90. package/es/components/pisellLookup/index.d.ts +6 -0
  91. package/es/components/pisellLookup/index.js +5 -0
  92. package/es/components/pisellLookup/types.d.ts +666 -0
  93. package/es/components/pisellLookup/types.js +1 -0
  94. package/es/components/pisellLookup/utils/index.d.ts +5 -0
  95. package/es/components/pisellLookup/utils/index.js +6 -0
  96. package/es/components/pisellLookup/utils/storage.d.ts +42 -0
  97. package/es/components/pisellLookup/utils/storage.js +118 -0
  98. package/es/components/pisellLookup/utils/trigger.d.ts +42 -0
  99. package/es/components/pisellLookup/utils/trigger.js +76 -0
  100. package/es/components/pisellMultipleSelect/PisellMultipleSelect.less +7 -7
  101. package/es/components/pisellSingleLineText/PisellSingleLineText.less +143 -4
  102. package/es/components/pisellSingleSelect/PisellSingleSelect.less +6 -6
  103. package/es/components/pisellTimeRangeDisplay/PisellTimeRangeDisplay.d.ts +32 -0
  104. package/es/components/pisellTimeRangeDisplay/PisellTimeRangeDisplay.js +197 -0
  105. package/es/components/pisellTimeRangeDisplay/PisellTimeRangeDisplay.less +49 -0
  106. package/es/components/pisellTimeRangeDisplay/PisellTimeRangeDisplay.stories.d.ts +61 -0
  107. package/es/components/pisellTimeRangeDisplay/PisellTimeRangeDisplay.stories.js +209 -0
  108. package/es/components/pisellTimeRangeDisplay/components/DateBlock.d.ts +20 -0
  109. package/es/components/pisellTimeRangeDisplay/components/DateBlock.js +30 -0
  110. package/es/components/pisellTimeRangeDisplay/components/DurationBlock.d.ts +19 -0
  111. package/es/components/pisellTimeRangeDisplay/components/DurationBlock.js +25 -0
  112. package/es/components/pisellTimeRangeDisplay/components/TimeRangeBlock.d.ts +30 -0
  113. package/es/components/pisellTimeRangeDisplay/components/TimeRangeBlock.js +86 -0
  114. package/es/components/pisellTimeRangeDisplay/components/WeekdayBlock.d.ts +18 -0
  115. package/es/components/pisellTimeRangeDisplay/components/WeekdayBlock.js +23 -0
  116. package/es/components/pisellTimeRangeDisplay/components/index.d.ts +8 -0
  117. package/es/components/pisellTimeRangeDisplay/components/index.js +4 -0
  118. package/es/components/pisellTimeRangeDisplay/index.d.ts +3 -0
  119. package/es/components/pisellTimeRangeDisplay/index.js +1 -0
  120. package/es/components/pisellTimeRangeDisplay/types.d.ts +137 -0
  121. package/es/components/pisellTimeRangeDisplay/types.js +1 -0
  122. package/es/components/pisellTimeRangeDisplay/utils/formatDuration.d.ts +14 -0
  123. package/es/components/pisellTimeRangeDisplay/utils/formatDuration.js +53 -0
  124. package/es/components/pisellTimeRangeDisplay/utils/index.d.ts +4 -0
  125. package/es/components/pisellTimeRangeDisplay/utils/index.js +5 -0
  126. package/es/components/pisellTimeRangeDisplay/utils/parseTimeRange.d.ts +23 -0
  127. package/es/components/pisellTimeRangeDisplay/utils/parseTimeRange.js +27 -0
  128. package/es/components/pisellUrl/PisellUrl.less +1 -1
  129. package/es/components/productCard/cartSkuCard/components/packages/utils.d.ts +1 -1
  130. package/es/components/productCard/components/Packages/utils.d.ts +1 -1
  131. package/es/components/table/Gallery/components/VirtualGrid/useGapSize.d.ts +2 -2
  132. package/es/components/table/Table/fields/select/filterUtil/index.d.ts +1 -1
  133. package/es/components/table/Table/fields/treeSelect/filterUtil/index.d.ts +1 -1
  134. package/es/index.d.ts +6 -0
  135. package/es/index.js +10 -1
  136. package/es/locales/en-US.d.ts +14 -0
  137. package/es/locales/en-US.js +16 -0
  138. package/es/locales/zh-CN.d.ts +14 -0
  139. package/es/locales/zh-CN.js +16 -0
  140. package/es/locales/zh-TW.d.ts +14 -0
  141. package/es/locales/zh-TW.js +16 -0
  142. package/es/theme/tokens.js +105 -125
  143. package/es/utils/index.d.ts +1 -1
  144. package/es/utils/platform.d.ts +1 -1
  145. package/lib/components/PisellSuperTabs/PisellSuperTabs.d.ts +1 -1
  146. package/lib/components/PisellSuperTabs/PisellSuperTabs.js +6 -4
  147. package/lib/components/PisellSuperTabs/hooks/useTabsState.js +1 -2
  148. package/lib/components/PisellSuperTabs/types.d.ts +2 -0
  149. package/lib/components/PisellTabbar/PisellTabbar.d.ts +1 -1
  150. package/lib/components/PisellTabbar/PisellTabbar.js +522 -139
  151. package/lib/components/PisellTabbar/constants.d.ts +2 -1
  152. package/lib/components/PisellTabbar/constants.js +5 -4
  153. package/lib/components/PisellTabbar/hooks/useActiveKey.d.ts +6 -0
  154. package/lib/components/PisellTabbar/hooks/useActiveKey.js +14 -1
  155. package/lib/components/PisellTabbar/hooks/useExpand.d.ts +1 -0
  156. package/lib/components/PisellTabbar/hooks/useExpand.js +9 -1
  157. package/lib/components/PisellTabbar/template/Template1/PisellTabbar.d.ts +3 -18
  158. package/lib/components/PisellTabbar/template/Template1/PisellTabbar.js +171 -55
  159. package/lib/components/PisellTabbar/template/Template1/constants.js +1 -1
  160. package/lib/components/PisellTabbar/types.d.ts +5 -26
  161. package/lib/components/PisellTabbar/utils/index.d.ts +2 -1
  162. package/lib/components/PisellTabbar/utils/index.js +2 -1
  163. package/lib/components/dataSourceComponents/dataSourceTable/hooks/useDataSourceKey.d.ts +2 -2
  164. package/lib/components/dataSourceComponents/dataSourceTable/hooks/useTableProps.d.ts +2 -2
  165. package/lib/components/page/index.js +3 -0
  166. package/lib/components/pisellDataSourceContainer/hooks/useDataSourceKey.d.ts +2 -2
  167. package/lib/components/pisellDateTimeDisplay/PisellDateTimeDisplay.js +27 -17
  168. package/lib/components/pisellDateTimeDisplay/PisellDateTimeDisplay.stories.d.ts +19 -0
  169. package/lib/components/pisellDateTimeDisplay/PisellDateTimeDisplay.stories.js +63 -0
  170. package/lib/components/pisellDateTimeDisplay/components/DateDisplay.d.ts +6 -1
  171. package/lib/components/pisellDateTimeDisplay/components/DateDisplay.js +5 -1
  172. package/lib/components/pisellDateTimeDisplay/formats/dateTimeDisplayFormats.d.ts +7 -0
  173. package/lib/components/pisellDateTimeDisplay/formats/dateTimeDisplayFormats.js +98 -0
  174. package/lib/components/pisellDateTimeDisplay/formats/index.d.ts +1 -0
  175. package/lib/components/pisellDateTimeDisplay/formats/index.js +29 -0
  176. package/lib/components/pisellDateTimeDisplay/hooks/useCurrentTime.d.ts +2 -2
  177. package/lib/components/pisellDateTimeDisplay/index.d.ts +1 -0
  178. package/lib/components/pisellDateTimeDisplay/index.js +3 -1
  179. package/lib/components/pisellDateTimeDisplay/types.d.ts +48 -2
  180. package/lib/components/pisellDateTimeDisplay/utils/formatDate.js +14 -1
  181. package/lib/components/pisellDateTimeDisplay/utils/formatDateOrRelative.d.ts +17 -0
  182. package/lib/components/pisellDateTimeDisplay/utils/formatDateOrRelative.js +54 -0
  183. package/lib/components/pisellDateTimeDisplay/utils/formatWeekday.js +6 -6
  184. package/lib/components/pisellDateTimeDisplay/utils/index.d.ts +3 -1
  185. package/lib/components/pisellDateTimeDisplay/utils/index.js +8 -2
  186. package/lib/components/pisellDateTimeDisplay/utils/localeUtils.d.ts +2 -7
  187. package/lib/components/pisellDateTimeDisplay/utils/localeUtils.js +2 -11
  188. package/lib/components/pisellDateTimeDisplay/utils/relativeDay.d.ts +23 -0
  189. package/lib/components/pisellDateTimeDisplay/utils/relativeDay.js +54 -0
  190. package/lib/components/pisellEmail/PisellEmail.less +2 -2
  191. package/lib/components/pisellFind/PisellFind.stories.d.ts +45 -0
  192. package/lib/components/pisellFind/PisellFind.stories.js +343 -0
  193. package/lib/components/pisellFind/index.d.ts +40 -0
  194. package/lib/components/pisellFind/index.js +68 -0
  195. package/lib/components/pisellLongText/PisellLongText.less +2 -2
  196. package/lib/components/pisellLookup/PisellLookup.d.ts +4 -0
  197. package/lib/components/pisellLookup/PisellLookup.js +434 -0
  198. package/lib/components/pisellLookup/PisellLookup.less +640 -0
  199. package/lib/components/pisellLookup/PisellLookup.stories.d.ts +129 -0
  200. package/lib/components/pisellLookup/PisellLookup.stories.js +631 -0
  201. package/lib/components/pisellLookup/components/HotWords.d.ts +7 -0
  202. package/lib/components/pisellLookup/components/HotWords.js +63 -0
  203. package/lib/components/pisellLookup/components/LookupAuxiliary.d.ts +7 -0
  204. package/lib/components/pisellLookup/components/LookupAuxiliary.js +93 -0
  205. package/lib/components/pisellLookup/components/LookupResultHost.d.ts +7 -0
  206. package/lib/components/pisellLookup/components/LookupResultHost.js +190 -0
  207. package/lib/components/pisellLookup/components/LookupTrigger.d.ts +3 -0
  208. package/lib/components/pisellLookup/components/LookupTrigger.js +293 -0
  209. package/lib/components/pisellLookup/components/SearchHistory.d.ts +7 -0
  210. package/lib/components/pisellLookup/components/SearchHistory.js +73 -0
  211. package/lib/components/pisellLookup/components/SuggestWords.d.ts +7 -0
  212. package/lib/components/pisellLookup/components/SuggestWords.js +71 -0
  213. package/lib/components/pisellLookup/components/index.d.ts +9 -0
  214. package/lib/components/pisellLookup/components/index.js +44 -0
  215. package/lib/components/pisellLookup/hooks/index.d.ts +6 -0
  216. package/lib/components/pisellLookup/hooks/index.js +27 -0
  217. package/lib/components/pisellLookup/hooks/useDebounceSearch.d.ts +40 -0
  218. package/lib/components/pisellLookup/hooks/useDebounceSearch.js +66 -0
  219. package/lib/components/pisellLookup/hooks/useSearchHistory.d.ts +48 -0
  220. package/lib/components/pisellLookup/hooks/useSearchHistory.js +107 -0
  221. package/lib/components/pisellLookup/hooks/useSearchState.d.ts +80 -0
  222. package/lib/components/pisellLookup/hooks/useSearchState.js +91 -0
  223. package/lib/components/pisellLookup/index.d.ts +6 -0
  224. package/lib/components/pisellLookup/index.js +29 -0
  225. package/lib/components/pisellLookup/types.d.ts +666 -0
  226. package/lib/components/pisellLookup/types.js +17 -0
  227. package/lib/components/pisellLookup/utils/index.d.ts +5 -0
  228. package/lib/components/pisellLookup/utils/index.js +25 -0
  229. package/lib/components/pisellLookup/utils/storage.d.ts +42 -0
  230. package/lib/components/pisellLookup/utils/storage.js +96 -0
  231. package/lib/components/pisellLookup/utils/trigger.d.ts +42 -0
  232. package/lib/components/pisellLookup/utils/trigger.js +66 -0
  233. package/lib/components/pisellMultipleSelect/PisellMultipleSelect.less +7 -7
  234. package/lib/components/pisellSingleLineText/PisellSingleLineText.less +143 -4
  235. package/lib/components/pisellSingleSelect/PisellSingleSelect.less +6 -6
  236. package/lib/components/pisellTimeRangeDisplay/PisellTimeRangeDisplay.d.ts +32 -0
  237. package/lib/components/pisellTimeRangeDisplay/PisellTimeRangeDisplay.js +193 -0
  238. package/lib/components/pisellTimeRangeDisplay/PisellTimeRangeDisplay.less +49 -0
  239. package/lib/components/pisellTimeRangeDisplay/PisellTimeRangeDisplay.stories.d.ts +61 -0
  240. package/lib/components/pisellTimeRangeDisplay/PisellTimeRangeDisplay.stories.js +187 -0
  241. package/lib/components/pisellTimeRangeDisplay/components/DateBlock.d.ts +20 -0
  242. package/lib/components/pisellTimeRangeDisplay/components/DateBlock.js +69 -0
  243. package/lib/components/pisellTimeRangeDisplay/components/DurationBlock.d.ts +19 -0
  244. package/lib/components/pisellTimeRangeDisplay/components/DurationBlock.js +65 -0
  245. package/lib/components/pisellTimeRangeDisplay/components/TimeRangeBlock.d.ts +30 -0
  246. package/lib/components/pisellTimeRangeDisplay/components/TimeRangeBlock.js +120 -0
  247. package/lib/components/pisellTimeRangeDisplay/components/WeekdayBlock.d.ts +18 -0
  248. package/lib/components/pisellTimeRangeDisplay/components/WeekdayBlock.js +64 -0
  249. package/lib/components/pisellTimeRangeDisplay/components/index.d.ts +8 -0
  250. package/lib/components/pisellTimeRangeDisplay/components/index.js +38 -0
  251. package/lib/components/pisellTimeRangeDisplay/index.d.ts +3 -0
  252. package/lib/components/{PisellTabbar/components → pisellTimeRangeDisplay}/index.js +8 -7
  253. package/lib/components/pisellTimeRangeDisplay/types.d.ts +137 -0
  254. package/lib/components/pisellTimeRangeDisplay/types.js +17 -0
  255. package/lib/components/pisellTimeRangeDisplay/utils/formatDuration.d.ts +14 -0
  256. package/lib/components/pisellTimeRangeDisplay/utils/formatDuration.js +52 -0
  257. package/lib/components/pisellTimeRangeDisplay/utils/index.d.ts +4 -0
  258. package/lib/components/pisellTimeRangeDisplay/utils/index.js +47 -0
  259. package/lib/components/pisellTimeRangeDisplay/utils/parseTimeRange.d.ts +23 -0
  260. package/lib/components/pisellTimeRangeDisplay/utils/parseTimeRange.js +49 -0
  261. package/lib/components/pisellUrl/PisellUrl.less +1 -1
  262. package/lib/components/productCard/cartSkuCard/components/packages/utils.d.ts +1 -1
  263. package/lib/components/productCard/components/Packages/utils.d.ts +1 -1
  264. package/lib/components/table/Gallery/components/VirtualGrid/useGapSize.d.ts +2 -2
  265. package/lib/components/table/Table/fields/select/filterUtil/index.d.ts +1 -1
  266. package/lib/components/table/Table/fields/treeSelect/filterUtil/index.d.ts +1 -1
  267. package/lib/index.d.ts +6 -0
  268. package/lib/index.js +9 -0
  269. package/lib/locales/en-US.d.ts +14 -0
  270. package/lib/locales/en-US.js +16 -0
  271. package/lib/locales/zh-CN.d.ts +14 -0
  272. package/lib/locales/zh-CN.js +16 -0
  273. package/lib/locales/zh-TW.d.ts +14 -0
  274. package/lib/locales/zh-TW.js +16 -0
  275. package/lib/theme/tokens.js +105 -114
  276. package/lib/utils/index.d.ts +1 -1
  277. package/lib/utils/platform.d.ts +1 -1
  278. package/lowcode/pisell-find/meta.ts +365 -0
  279. package/lowcode/pisell-find/snippets.ts +37 -0
  280. package/lowcode/pisell-lookup/meta.ts +845 -0
  281. package/lowcode/pisell-lookup/snippets.ts +93 -0
  282. package/lowcode/pisell-time-range-display/index.ts +3 -0
  283. package/lowcode/pisell-time-range-display/meta.ts +375 -0
  284. package/lowcode/pisell-time-range-display/snippets.ts +1 -0
  285. package/package.json +3 -3
  286. package/es/components/PisellTabbar/components/TabbarLevel.d.ts +0 -8
  287. package/es/components/PisellTabbar/components/TabbarLevel.js +0 -275
  288. package/es/components/PisellTabbar/components/index.d.ts +0 -1
  289. package/es/components/PisellTabbar/components/index.js +0 -2
  290. package/lib/components/PisellTabbar/components/TabbarLevel.d.ts +0 -8
  291. package/lib/components/PisellTabbar/components/TabbarLevel.js +0 -295
  292. package/lib/components/PisellTabbar/components/index.d.ts +0 -1
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import type { SearchHistoryProps } from '../types';
3
+ /**
4
+ * SearchHistory 组件
5
+ * 展示搜索历史记录
6
+ */
7
+ export declare const SearchHistory: React.FC<SearchHistoryProps>;
@@ -0,0 +1,68 @@
1
+ import React from 'react';
2
+ import { Tag } from 'antd';
3
+ import { CloseOutlined } from '@ant-design/icons';
4
+ /**
5
+ * SearchHistory 组件
6
+ * 展示搜索历史记录
7
+ */
8
+ export var SearchHistory = function SearchHistory(props) {
9
+ var history = props.history,
10
+ onSelect = props.onSelect,
11
+ onRemove = props.onRemove,
12
+ onClear = props.onClear,
13
+ render = props.render,
14
+ className = props.className,
15
+ style = props.style;
16
+
17
+ // 如果没有历史记录,不显示
18
+ if (!history || history.length === 0) {
19
+ return null;
20
+ }
21
+
22
+ // 使用自定义渲染
23
+ if (render) {
24
+ return /*#__PURE__*/React.createElement(React.Fragment, null, render(history, onSelect));
25
+ }
26
+
27
+ /**
28
+ * 处理点击历史记录
29
+ */
30
+ var handleClick = function handleClick(keyword) {
31
+ onSelect(keyword);
32
+ };
33
+
34
+ /**
35
+ * 处理删除历史记录
36
+ */
37
+ var handleRemove = function handleRemove(e, keyword) {
38
+ e.stopPropagation();
39
+ onRemove === null || onRemove === void 0 || onRemove(keyword);
40
+ };
41
+
42
+ /**
43
+ * 处理清除全部历史记录
44
+ */
45
+ var handleClearAll = function handleClearAll() {
46
+ onClear === null || onClear === void 0 || onClear();
47
+ };
48
+ return /*#__PURE__*/React.createElement("div", {
49
+ className: "pisell-lookup-history ".concat(className || ''),
50
+ style: style
51
+ }, /*#__PURE__*/React.createElement("div", {
52
+ className: "pisell-lookup-history-list"
53
+ }, history.map(function (item, index) {
54
+ return /*#__PURE__*/React.createElement(Tag, {
55
+ key: "".concat(item, "-").concat(index),
56
+ className: "pisell-lookup-history-item",
57
+ onClick: function onClick() {
58
+ return handleClick(item);
59
+ },
60
+ closable: !!onRemove,
61
+ onClose: function onClose(e) {
62
+ return handleRemove(e, item);
63
+ },
64
+ closeIcon: /*#__PURE__*/React.createElement(CloseOutlined, null)
65
+ }, item);
66
+ })));
67
+ };
68
+ SearchHistory.displayName = 'SearchHistory';
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import type { SuggestWordsProps } from '../types';
3
+ /**
4
+ * SuggestWords 组件
5
+ * 展示搜索联想词
6
+ */
7
+ export declare const SuggestWords: React.FC<SuggestWordsProps>;
@@ -0,0 +1,53 @@
1
+ import React from 'react';
2
+ import { List } from 'antd';
3
+ import { SearchOutlined } from '@ant-design/icons';
4
+ /**
5
+ * SuggestWords 组件
6
+ * 展示搜索联想词
7
+ */
8
+ export var SuggestWords = function SuggestWords(props) {
9
+ var suggestions = props.suggestions,
10
+ onSelect = props.onSelect,
11
+ render = props.render,
12
+ className = props.className,
13
+ style = props.style;
14
+
15
+ // 如果没有联想词,不显示
16
+ if (!suggestions || suggestions.length === 0) {
17
+ return null;
18
+ }
19
+
20
+ // 使用自定义渲染
21
+ if (render) {
22
+ return /*#__PURE__*/React.createElement(React.Fragment, null, render(suggestions, onSelect));
23
+ }
24
+
25
+ /**
26
+ * 处理点击联想词
27
+ */
28
+ var handleClick = function handleClick(keyword) {
29
+ onSelect(keyword);
30
+ };
31
+ return /*#__PURE__*/React.createElement("div", {
32
+ className: "pisell-lookup-suggestions ".concat(className || ''),
33
+ style: style
34
+ }, /*#__PURE__*/React.createElement(List, {
35
+ className: "pisell-lookup-suggestions-list",
36
+ size: "small",
37
+ dataSource: suggestions,
38
+ renderItem: function renderItem(item) {
39
+ return /*#__PURE__*/React.createElement(List.Item, {
40
+ className: "pisell-lookup-suggestions-item",
41
+ onClick: function onClick() {
42
+ return handleClick(item);
43
+ }
44
+ }, /*#__PURE__*/React.createElement(SearchOutlined, {
45
+ style: {
46
+ marginRight: 8,
47
+ color: '#667085'
48
+ }
49
+ }), item);
50
+ }
51
+ }));
52
+ };
53
+ SuggestWords.displayName = 'SuggestWords';
@@ -0,0 +1,9 @@
1
+ /**
2
+ * 子组件统一导出
3
+ */
4
+ export { SearchHistory } from './SearchHistory';
5
+ export { SuggestWords } from './SuggestWords';
6
+ export { HotWords } from './HotWords';
7
+ export { LookupAuxiliary } from './LookupAuxiliary';
8
+ export { LookupTrigger } from './LookupTrigger';
9
+ export { LookupResultHost } from './LookupResultHost';
@@ -0,0 +1,10 @@
1
+ /**
2
+ * 子组件统一导出
3
+ */
4
+
5
+ export { SearchHistory } from "./SearchHistory";
6
+ export { SuggestWords } from "./SuggestWords";
7
+ export { HotWords } from "./HotWords";
8
+ export { LookupAuxiliary } from "./LookupAuxiliary";
9
+ export { LookupTrigger } from "./LookupTrigger";
10
+ export { LookupResultHost } from "./LookupResultHost";
@@ -0,0 +1,6 @@
1
+ /**
2
+ * 自定义 Hooks 统一导出
3
+ */
4
+ export * from './useSearchState';
5
+ export * from './useSearchHistory';
6
+ export * from './useDebounceSearch';
@@ -0,0 +1,7 @@
1
+ /**
2
+ * 自定义 Hooks 统一导出
3
+ */
4
+
5
+ export * from "./useSearchState";
6
+ export * from "./useSearchHistory";
7
+ export * from "./useDebounceSearch";
@@ -0,0 +1,40 @@
1
+ /**
2
+ * 防抖搜索 Hook
3
+ */
4
+ export interface UseDebounceSearchOptions {
5
+ /**
6
+ * 关键词
7
+ */
8
+ keyword: string;
9
+ /**
10
+ * 防抖时间(毫秒)
11
+ */
12
+ debounceTime: number;
13
+ /**
14
+ * 搜索触发回调
15
+ */
16
+ onSearch?: (keyword: string) => void;
17
+ /**
18
+ * 是否启用防抖
19
+ */
20
+ enabled?: boolean;
21
+ /**
22
+ * 上次搜索的关键词(用于去重)
23
+ */
24
+ lastSearchKeyword?: string;
25
+ /**
26
+ * 是否跳过防抖触发(用于手动选择场景)
27
+ */
28
+ skipDebounce?: boolean;
29
+ }
30
+ export interface UseDebounceSearchResult {
31
+ /**
32
+ * 防抖后的关键词
33
+ */
34
+ debouncedKeyword: string;
35
+ }
36
+ /**
37
+ * 防抖搜索 Hook
38
+ * 用于实时搜索模式的防抖处理
39
+ */
40
+ export declare const useDebounceSearch: (options: UseDebounceSearchOptions) => UseDebounceSearchResult;
@@ -0,0 +1,78 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
5
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
6
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
+ import { useEffect, useRef, useState } from 'react';
8
+
9
+ /**
10
+ * 防抖搜索 Hook
11
+ */
12
+
13
+ /**
14
+ * 防抖搜索 Hook
15
+ * 用于实时搜索模式的防抖处理
16
+ */
17
+ export var useDebounceSearch = function useDebounceSearch(options) {
18
+ var keyword = options.keyword,
19
+ debounceTime = options.debounceTime,
20
+ onSearch = options.onSearch,
21
+ _options$enabled = options.enabled,
22
+ enabled = _options$enabled === void 0 ? true : _options$enabled,
23
+ lastSearchKeyword = options.lastSearchKeyword;
24
+ var _useState = useState(keyword),
25
+ _useState2 = _slicedToArray(_useState, 2),
26
+ debouncedKeyword = _useState2[0],
27
+ setDebouncedKeyword = _useState2[1];
28
+ var timerRef = useRef(null);
29
+
30
+ /**
31
+ * 防抖处理
32
+ */
33
+ useEffect(function () {
34
+ if (!enabled) {
35
+ // 不启用防抖时,直接更新
36
+ setDebouncedKeyword(keyword);
37
+ return;
38
+ }
39
+
40
+ // 清除之前的定时器
41
+ if (timerRef.current) {
42
+ clearTimeout(timerRef.current);
43
+ }
44
+
45
+ // 设置新的定时器
46
+ timerRef.current = setTimeout(function () {
47
+ setDebouncedKeyword(keyword);
48
+ }, debounceTime);
49
+
50
+ // 清理函数
51
+ return function () {
52
+ if (timerRef.current) {
53
+ clearTimeout(timerRef.current);
54
+ }
55
+ };
56
+ }, [keyword, debounceTime, enabled]);
57
+
58
+ /**
59
+ * 触发搜索回调
60
+ */
61
+ useEffect(function () {
62
+ // 只有在启用防抖时才触发搜索(包括空关键词,用于恢复数据)
63
+ if (enabled && onSearch && debouncedKeyword !== undefined) {
64
+ // 如果和上次搜索的关键词相同,跳过(避免重复触发)
65
+ if (lastSearchKeyword !== undefined && debouncedKeyword === lastSearchKeyword) {
66
+ return;
67
+ }
68
+ try {
69
+ onSearch(debouncedKeyword);
70
+ } catch (error) {
71
+ console.error('Failed to trigger search:', error);
72
+ }
73
+ }
74
+ }, [debouncedKeyword, onSearch, enabled, lastSearchKeyword]);
75
+ return {
76
+ debouncedKeyword: debouncedKeyword
77
+ };
78
+ };
@@ -0,0 +1,48 @@
1
+ /**
2
+ * 搜索历史管理 Hook
3
+ */
4
+ export interface UseSearchHistoryOptions {
5
+ /**
6
+ * 存储 key
7
+ */
8
+ historyKey: string;
9
+ /**
10
+ * 最大历史记录数量
11
+ */
12
+ maxHistoryCount: number;
13
+ /**
14
+ * 自定义加载历史记录函数
15
+ */
16
+ onLoadHistory?: () => string[];
17
+ /**
18
+ * 自定义保存历史记录函数
19
+ */
20
+ onSaveHistory?: (history: string[]) => void;
21
+ }
22
+ export interface UseSearchHistoryResult {
23
+ /**
24
+ * 历史记录数组
25
+ */
26
+ history: string[];
27
+ /**
28
+ * 添加历史记录
29
+ */
30
+ addHistory: (keyword: string) => void;
31
+ /**
32
+ * 删除历史记录
33
+ */
34
+ removeHistory: (keyword: string) => void;
35
+ /**
36
+ * 清除全部历史记录
37
+ */
38
+ clearAllHistory: () => void;
39
+ /**
40
+ * 重新加载历史记录
41
+ */
42
+ reloadHistory: () => void;
43
+ }
44
+ /**
45
+ * 搜索历史管理 Hook
46
+ * 支持自定义存储逻辑
47
+ */
48
+ export declare const useSearchHistory: (options: UseSearchHistoryOptions) => UseSearchHistoryResult;
@@ -0,0 +1,125 @@
1
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
2
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
4
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
5
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
6
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
7
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
8
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
9
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
10
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
11
+ import { useCallback, useEffect, useState } from 'react';
12
+ import { addHistoryItem, clearHistory, loadHistory, removeHistoryItem } from "../utils";
13
+
14
+ /**
15
+ * 搜索历史管理 Hook
16
+ */
17
+
18
+ /**
19
+ * 搜索历史管理 Hook
20
+ * 支持自定义存储逻辑
21
+ */
22
+ export var useSearchHistory = function useSearchHistory(options) {
23
+ var historyKey = options.historyKey,
24
+ maxHistoryCount = options.maxHistoryCount,
25
+ onLoadHistory = options.onLoadHistory,
26
+ onSaveHistory = options.onSaveHistory;
27
+ var _useState = useState([]),
28
+ _useState2 = _slicedToArray(_useState, 2),
29
+ history = _useState2[0],
30
+ setHistory = _useState2[1];
31
+
32
+ /**
33
+ * 加载历史记录
34
+ */
35
+ var reloadHistory = useCallback(function () {
36
+ try {
37
+ if (onLoadHistory) {
38
+ // 使用自定义加载函数
39
+ var loadedHistory = onLoadHistory();
40
+ setHistory(Array.isArray(loadedHistory) ? loadedHistory : []);
41
+ } else {
42
+ // 使用默认的 localStorage 加载
43
+ var _loadedHistory = loadHistory(historyKey);
44
+ setHistory(Array.isArray(_loadedHistory) ? _loadedHistory : []);
45
+ }
46
+ } catch (error) {
47
+ console.error('Failed to reload history:', error);
48
+ setHistory([]);
49
+ }
50
+ }, [historyKey, onLoadHistory]);
51
+
52
+ /**
53
+ * 初始化:加载历史记录
54
+ */
55
+ useEffect(function () {
56
+ reloadHistory();
57
+ }, [reloadHistory]);
58
+
59
+ /**
60
+ * 添加历史记录
61
+ */
62
+ var addHistory = useCallback(function (keyword) {
63
+ // 忽略空关键词
64
+ if (!keyword || !keyword.trim()) {
65
+ return;
66
+ }
67
+ var trimmedKeyword = keyword.trim();
68
+ if (onSaveHistory) {
69
+ // 使用自定义保存函数
70
+ // 去重并添加到开头
71
+ var safeHistory = Array.isArray(history) ? history : [];
72
+ var filteredHistory = safeHistory.filter(function (h) {
73
+ return h !== trimmedKeyword;
74
+ });
75
+ var newHistory = [trimmedKeyword].concat(_toConsumableArray(filteredHistory)).slice(0, maxHistoryCount);
76
+ setHistory(newHistory);
77
+ onSaveHistory(newHistory);
78
+ } else {
79
+ // 使用默认的 localStorage 保存
80
+ var _newHistory = addHistoryItem(historyKey, trimmedKeyword, maxHistoryCount);
81
+ setHistory(_newHistory);
82
+ }
83
+ }, [history, historyKey, maxHistoryCount, onSaveHistory]);
84
+
85
+ /**
86
+ * 删除历史记录
87
+ */
88
+ var removeHistory = useCallback(function (keyword) {
89
+ if (onSaveHistory) {
90
+ // 使用自定义保存函数
91
+ var safeHistory = Array.isArray(history) ? history : [];
92
+ var newHistory = safeHistory.filter(function (h) {
93
+ return h !== keyword;
94
+ });
95
+ setHistory(newHistory);
96
+ onSaveHistory(newHistory);
97
+ } else {
98
+ // 使用默认的 localStorage 删除
99
+ var _newHistory2 = removeHistoryItem(historyKey, keyword);
100
+ setHistory(_newHistory2);
101
+ }
102
+ }, [history, historyKey, onSaveHistory]);
103
+
104
+ /**
105
+ * 清除全部历史记录
106
+ */
107
+ var clearAllHistory = useCallback(function () {
108
+ if (onSaveHistory) {
109
+ // 使用自定义保存函数
110
+ setHistory([]);
111
+ onSaveHistory([]);
112
+ } else {
113
+ // 使用默认的 localStorage 清除
114
+ clearHistory(historyKey);
115
+ setHistory([]);
116
+ }
117
+ }, [historyKey, onSaveHistory]);
118
+ return {
119
+ history: history,
120
+ addHistory: addHistory,
121
+ removeHistory: removeHistory,
122
+ clearAllHistory: clearAllHistory,
123
+ reloadHistory: reloadHistory
124
+ };
125
+ };
@@ -0,0 +1,80 @@
1
+ /**
2
+ * 搜索状态管理 Hook
3
+ */
4
+ export interface UseSearchStateOptions {
5
+ /**
6
+ * 受控的关键词
7
+ */
8
+ value?: string;
9
+ /**
10
+ * 默认关键词
11
+ */
12
+ defaultValue?: string;
13
+ /**
14
+ * 受控的可见性
15
+ */
16
+ visible?: boolean;
17
+ /**
18
+ * 默认可见性
19
+ */
20
+ defaultVisible?: boolean;
21
+ /**
22
+ * 关键词变化回调
23
+ */
24
+ onChange?: (value: string) => void;
25
+ /**
26
+ * 可见性变化回调
27
+ */
28
+ onVisibleChange?: (visible: boolean) => void;
29
+ /**
30
+ * 打开回调
31
+ */
32
+ onOpen?: () => void;
33
+ /**
34
+ * 关闭回调
35
+ */
36
+ onClose?: () => void;
37
+ }
38
+ export interface UseSearchStateResult {
39
+ /**
40
+ * 当前关键词
41
+ */
42
+ keyword: string;
43
+ /**
44
+ * 设置关键词
45
+ */
46
+ setKeyword: (value: string) => void;
47
+ /**
48
+ * 是否可见
49
+ */
50
+ visible: boolean;
51
+ /**
52
+ * 设置可见性
53
+ */
54
+ setVisible: (visible: boolean) => void;
55
+ /**
56
+ * 打开
57
+ */
58
+ open: () => void;
59
+ /**
60
+ * 关闭
61
+ */
62
+ close: () => void;
63
+ /**
64
+ * 切换可见性
65
+ */
66
+ toggle: () => void;
67
+ /**
68
+ * 是否为受控的关键词
69
+ */
70
+ isControlledKeyword: boolean;
71
+ /**
72
+ * 是否为受控的可见性
73
+ */
74
+ isControlledVisible: boolean;
75
+ }
76
+ /**
77
+ * 搜索状态管理 Hook
78
+ * 支持受控和非受控模式
79
+ */
80
+ export declare const useSearchState: (options: UseSearchStateOptions) => UseSearchStateResult;
@@ -0,0 +1,113 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
5
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
6
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
+ import { useCallback, useState } from 'react';
8
+
9
+ /**
10
+ * 搜索状态管理 Hook
11
+ */
12
+
13
+ /**
14
+ * 搜索状态管理 Hook
15
+ * 支持受控和非受控模式
16
+ */
17
+ export var useSearchState = function useSearchState(options) {
18
+ var value = options.value,
19
+ _options$defaultValue = options.defaultValue,
20
+ defaultValue = _options$defaultValue === void 0 ? '' : _options$defaultValue,
21
+ visibleProp = options.visible,
22
+ _options$defaultVisib = options.defaultVisible,
23
+ defaultVisible = _options$defaultVisib === void 0 ? false : _options$defaultVisib,
24
+ onChange = options.onChange,
25
+ onVisibleChange = options.onVisibleChange,
26
+ onOpen = options.onOpen,
27
+ onClose = options.onClose;
28
+
29
+ // 判断是否为受控模式
30
+ var isControlledKeyword = value !== undefined;
31
+ var isControlledVisible = visibleProp !== undefined;
32
+
33
+ // 内部状态(非受控模式使用)
34
+ var _useState = useState(defaultValue),
35
+ _useState2 = _slicedToArray(_useState, 2),
36
+ internalKeyword = _useState2[0],
37
+ setInternalKeyword = _useState2[1];
38
+ var _useState3 = useState(defaultVisible),
39
+ _useState4 = _slicedToArray(_useState3, 2),
40
+ internalVisible = _useState4[0],
41
+ setInternalVisible = _useState4[1];
42
+
43
+ // 当前值(受控优先)
44
+ var keyword = isControlledKeyword ? value : internalKeyword;
45
+ var visible = isControlledVisible ? visibleProp : internalVisible;
46
+
47
+ /**
48
+ * 设置关键词
49
+ */
50
+ var setKeyword = useCallback(function (newValue) {
51
+ // 非受控模式下更新内部状态
52
+ if (!isControlledKeyword) {
53
+ setInternalKeyword(newValue);
54
+ }
55
+
56
+ // 触发回调
57
+ onChange === null || onChange === void 0 || onChange(newValue);
58
+ }, [isControlledKeyword, onChange]);
59
+
60
+ /**
61
+ * 设置可见性
62
+ */
63
+ var setVisible = useCallback(function (newVisible) {
64
+ var oldVisible = visible;
65
+
66
+ // 非受控模式下更新内部状态
67
+ if (!isControlledVisible) {
68
+ setInternalVisible(newVisible);
69
+ }
70
+
71
+ // 触发回调
72
+ onVisibleChange === null || onVisibleChange === void 0 || onVisibleChange(newVisible);
73
+
74
+ // 触发打开/关闭回调
75
+ if (newVisible && !oldVisible) {
76
+ onOpen === null || onOpen === void 0 || onOpen();
77
+ } else if (!newVisible && oldVisible) {
78
+ onClose === null || onClose === void 0 || onClose();
79
+ }
80
+ }, [isControlledVisible, visible, onVisibleChange, onOpen, onClose]);
81
+
82
+ /**
83
+ * 打开
84
+ */
85
+ var open = useCallback(function () {
86
+ setVisible(true);
87
+ }, [setVisible]);
88
+
89
+ /**
90
+ * 关闭
91
+ */
92
+ var close = useCallback(function () {
93
+ setVisible(false);
94
+ }, [setVisible]);
95
+
96
+ /**
97
+ * 切换可见性
98
+ */
99
+ var toggle = useCallback(function () {
100
+ setVisible(!visible);
101
+ }, [setVisible, visible]);
102
+ return {
103
+ keyword: keyword,
104
+ setKeyword: setKeyword,
105
+ visible: visible,
106
+ setVisible: setVisible,
107
+ open: open,
108
+ close: close,
109
+ toggle: toggle,
110
+ isControlledKeyword: isControlledKeyword,
111
+ isControlledVisible: isControlledVisible
112
+ };
113
+ };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * PisellLookup 组件导出
3
+ */
4
+ export { PisellLookup } from './PisellLookup';
5
+ export type { PisellLookupRef } from './types';
6
+ export type * from './types';
@@ -0,0 +1,5 @@
1
+ /**
2
+ * PisellLookup 组件导出
3
+ */
4
+
5
+ export { PisellLookup } from "./PisellLookup";