@antscorp/antsomi-ui 1.3.7-beta.67 → 1.3.7-beta.68

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 (515) hide show
  1. package/es/assets/css/main.scss +3 -2
  2. package/es/components/atoms/Checkbox/Checkbox.d.ts +0 -1
  3. package/es/components/atoms/ContentEditable/styled.d.ts +1 -2
  4. package/es/components/atoms/Eyedropper/styled.d.ts +0 -1
  5. package/es/components/atoms/Grid/Grid.d.ts +0 -1
  6. package/es/components/atoms/Input/Input.d.ts +18 -4
  7. package/es/components/atoms/Input/Input.js +2 -4
  8. package/es/components/atoms/Input/index.d.ts +1 -1
  9. package/es/components/atoms/Input/styled.d.ts +8 -9
  10. package/es/components/atoms/Input/styled.js +8 -8
  11. package/es/components/atoms/InputDynamic/InputDynamic.js +3 -3
  12. package/es/components/atoms/InputDynamic/styled.d.ts +1 -1
  13. package/es/components/atoms/InputDynamic/utils.js +8 -8
  14. package/es/components/atoms/MobileBrandingBar/index.d.ts +0 -1
  15. package/es/components/atoms/MobileBrandingBar/styled.d.ts +0 -1
  16. package/es/components/atoms/NotificationStatus/NotificationStatus.d.ts +0 -1
  17. package/es/components/atoms/Pagination/Pagination.d.ts +0 -1
  18. package/es/components/atoms/Popover/Popover.d.ts +0 -1
  19. package/es/components/atoms/PreviewTabs/styled.d.ts +1 -2
  20. package/es/components/atoms/Progress/Progress.d.ts +0 -1
  21. package/es/components/atoms/Radio/index.d.ts +0 -1
  22. package/es/components/atoms/RateV2/RateV2.js +2 -2
  23. package/es/components/atoms/ReactIframe/types.d.ts +0 -1
  24. package/es/components/atoms/Segmented/Segmented.d.ts +0 -1
  25. package/es/components/atoms/SelectAssociatedTag/SelectAssociatedTag.js +1 -1
  26. package/es/components/atoms/SelectAssociatedTag/SelectTag.d.ts +0 -1
  27. package/es/components/atoms/SelectAssociatedTag/styled.d.ts +2 -3
  28. package/es/components/atoms/Skeleton/Skeleton.d.ts +0 -1
  29. package/es/components/atoms/SlideBar/SlideBar.js +3 -1
  30. package/es/components/atoms/SlideBar/styled.d.ts +9 -9
  31. package/es/components/atoms/SlideBar/utils.d.ts +2 -2
  32. package/es/components/atoms/Slider/index.js +3 -8
  33. package/es/components/atoms/Space/Space.d.ts +2 -3
  34. package/es/components/atoms/Steps/styled.d.ts +2 -3
  35. package/es/components/atoms/Switch/styled.d.ts +0 -1
  36. package/es/components/atoms/Tag/Tag.js +6 -3
  37. package/es/components/atoms/Text/styled.d.ts +0 -1
  38. package/es/components/atoms/Timeline/Timeline.d.ts +1 -2
  39. package/es/components/atoms/Typography/EllipsisMiddle.d.ts +0 -1
  40. package/es/components/atoms/Watermark/Watermark.d.ts +0 -1
  41. package/es/components/icons/AntsomiAIIcon.d.ts +2 -2
  42. package/es/components/icons/AntsomiAIIcon.js +1 -3
  43. package/es/components/icons/CircleInfoIcon.d.ts +0 -1
  44. package/es/components/icons/EmotionFeedbackIcon.d.ts +2 -2
  45. package/es/components/icons/LazyIcon/LazyIcon.d.ts +3 -4
  46. package/es/components/icons/LoadingIcon.d.ts +1 -1
  47. package/es/components/icons/document/IconGallery.d.ts +0 -11
  48. package/es/components/icons/document/IconGallery.js +40 -20
  49. package/es/components/icons/document/styled.js +4 -4
  50. package/es/components/icons/index.d.ts +1 -1
  51. package/es/components/icons/index.js +1 -1
  52. package/es/components/icons/types/index.d.ts +0 -1
  53. package/es/components/molecules/AccessDenied/styled.d.ts +1 -2
  54. package/es/components/molecules/AccountSelection/AccountListing.js +1 -1
  55. package/es/components/molecules/AccountSelection/index.d.ts +2 -1
  56. package/es/components/molecules/AddDynamicContent/AddDynamicContent.d.ts +32 -1
  57. package/es/components/molecules/AddDynamicContent/AddDynamicContent.js +2 -28
  58. package/es/components/molecules/AddDynamicContent/components/DisplayFormat/DisplayFormat.d.ts +2 -3
  59. package/es/components/molecules/AddDynamicContent/components/DisplayFormat/DisplayFormat.js +0 -1
  60. package/es/components/molecules/AddDynamicContent/components/FormatNumber/FormatNumber.d.ts +2 -2
  61. package/es/components/molecules/AddDynamicContent/constants.d.ts +18 -35
  62. package/es/components/molecules/AddDynamicContent/constants.js +0 -2
  63. package/es/components/molecules/AddDynamicContent/styled.d.ts +4 -5
  64. package/es/components/molecules/AddDynamicContent/types.d.ts +0 -32
  65. package/es/components/molecules/AddDynamicContent/utils.d.ts +1 -1
  66. package/es/components/molecules/AlignSetting/index.d.ts +1 -1
  67. package/es/components/molecules/AlignSetting/utils.d.ts +1 -1
  68. package/es/components/molecules/ApplyPopupContent/styled.d.ts +1 -2
  69. package/es/components/molecules/CalendarSelection/CalendarSelection.js +5 -4
  70. package/es/components/molecules/CalendarSelection/actions.d.ts +11 -1
  71. package/es/components/molecules/CalendarSelection/actions.js +10 -1
  72. package/es/components/molecules/CalendarSelection/components/TimeRangeDisplay/TimeRangeDisplay.d.ts +8 -1
  73. package/es/components/molecules/CalendarSelection/components/TimeRangeDisplay/TimeRangeDisplay.js +1 -1
  74. package/es/components/molecules/CalendarSelection/constants.d.ts +22 -10
  75. package/es/components/molecules/CalendarSelection/constants.js +5 -10
  76. package/es/components/molecules/CalendarSelection/context.d.ts +0 -1
  77. package/es/components/molecules/CalendarSelection/index.d.ts +2 -2
  78. package/es/components/molecules/CalendarSelection/reducer.js +2 -1
  79. package/es/components/molecules/CalendarSelection/styled.d.ts +1 -2
  80. package/es/components/molecules/CalendarSelection/types.d.ts +4 -43
  81. package/es/components/molecules/CalendarSelection/utils.d.ts +2 -23
  82. package/es/components/molecules/CalendarSelection/utils.js +0 -5
  83. package/es/components/molecules/CaptureScreen/components/Cursor/styled.d.ts +2 -2
  84. package/es/components/molecules/CaptureScreen/components/Cursor/styled.js +3 -1
  85. package/es/components/molecules/CaptureScreen/constants.d.ts +4 -26
  86. package/es/components/molecules/CaptureScreen/styled.d.ts +4 -5
  87. package/es/components/molecules/ChartTab/components/styled.d.ts +1 -1
  88. package/es/components/molecules/ChatBox/ChatBoxInsight/styled.d.ts +1 -2
  89. package/es/components/molecules/ChatBox/styled.d.ts +1 -1
  90. package/es/components/molecules/CodeStructure/styled.d.ts +1 -1
  91. package/es/components/molecules/CodeStructure/utils.d.ts +5 -5
  92. package/es/components/molecules/ColorPicker/ChromePicker/styled.js +2 -2
  93. package/es/components/molecules/ColorPicker/CustomPicker/index.js +2 -2
  94. package/es/components/molecules/ColorPicker/CustomPicker/styled.d.ts +1 -1
  95. package/es/components/molecules/ColorPicker/CustomPicker/styled.js +6 -6
  96. package/es/components/molecules/ColorPicker/SketchPicker/styled.js +2 -2
  97. package/es/components/molecules/ColorPicker/index.d.ts +0 -1
  98. package/es/components/molecules/ColorPicker/index.js +2 -3
  99. package/es/components/molecules/ColorSetting/styled.d.ts +0 -1
  100. package/es/components/molecules/DatePicker/components/AdvancedPicker/AdvancedPicker.js +3 -3
  101. package/es/components/molecules/DatePicker/components/AdvancedPicker/constants.d.ts +14 -93
  102. package/es/components/molecules/DatePicker/components/AdvancedPicker/constants.js +0 -2
  103. package/es/components/molecules/DatePicker/components/AdvancedPicker/styled.d.ts +1 -1
  104. package/es/components/molecules/DatePicker/components/AdvancedPicker/utils.d.ts +4 -4
  105. package/es/components/molecules/DisplayFormat/DisplayFormatSelect.js +2 -2
  106. package/es/components/molecules/DisplayFormat/DisplayFormatSettings.d.ts +1 -1
  107. package/es/components/molecules/DisplayFormat/components/FormatNumber.d.ts +1 -1
  108. package/es/components/molecules/DisplayFormat/constants.d.ts +27 -37
  109. package/es/components/molecules/DisplayFormat/index.d.ts +0 -1
  110. package/es/components/molecules/DisplayFormat/styled.d.ts +4 -5
  111. package/es/components/molecules/DisplayFormat/types.d.ts +0 -1
  112. package/es/components/molecules/DrawerDetail/DrawerDetail.js +2 -2
  113. package/es/components/molecules/DrawerDetail/styled.d.ts +2 -3
  114. package/es/components/molecules/Dropdown/styled.d.ts +1 -2
  115. package/es/components/molecules/Dropdown/types.d.ts +0 -1
  116. package/es/components/molecules/EditingList/components/List/List.d.ts +0 -1
  117. package/es/components/molecules/EditingList/components/Loadable.d.ts +5 -6
  118. package/es/components/molecules/EditingList/components/Popover/Popover.d.ts +0 -1
  119. package/es/components/molecules/EditingList/components/Search/Search.d.ts +0 -1
  120. package/es/components/molecules/EditingList/components/Title/Title.d.ts +0 -1
  121. package/es/components/molecules/EditingList/styled.d.ts +0 -1
  122. package/es/components/molecules/EditingList/types.d.ts +0 -1
  123. package/es/components/molecules/EditingListV2/components/List/List.js +0 -1
  124. package/es/components/molecules/EditingListV2/components/Loadable.d.ts +3 -4
  125. package/es/components/molecules/EditingListV2/components/Popover/Popover.d.ts +0 -1
  126. package/es/components/molecules/EditingListV2/types.d.ts +0 -1
  127. package/es/components/molecules/EditorScript/EditorScript.d.ts +0 -1
  128. package/es/components/molecules/EmojiCollections/styled.d.ts +3 -4
  129. package/es/components/molecules/EmojiPopover/styled.d.ts +3 -4
  130. package/es/components/molecules/EmptyData/constants.d.ts +8 -2
  131. package/es/components/molecules/EmptyData/styled.d.ts +2 -3
  132. package/es/components/molecules/FontSetting/index.js +2 -2
  133. package/es/components/molecules/FontSizeInput/FontSizeInput.d.ts +0 -1
  134. package/es/components/molecules/FontSizeInput/components/FontSizeControl.d.ts +0 -1
  135. package/es/components/molecules/FontSizeInput/styled.d.ts +0 -1
  136. package/es/components/molecules/FontSizeInput/types.d.ts +0 -1
  137. package/es/components/molecules/HeaderV2/HeaderV2.d.ts +1 -1
  138. package/es/components/molecules/HeaderV2/HeaderV2.js +2 -2
  139. package/es/components/molecules/IconSelection/components/Icon/index.d.ts +3 -2
  140. package/es/components/molecules/IconSelection/constants.d.ts +0 -1
  141. package/es/components/molecules/IconSelection/styled.d.ts +0 -1
  142. package/es/components/molecules/IconSelection/styled.js +6 -4
  143. package/es/components/molecules/ImageEditor/styled.d.ts +1 -2
  144. package/es/components/molecules/InputSelectAttribute/index.d.ts +0 -1
  145. package/es/components/molecules/InputSelectAttribute/styled.d.ts +1 -1
  146. package/es/components/molecules/ItemNotFound/styled.d.ts +0 -1
  147. package/es/components/molecules/MatchAnySelect/MatchesAnySelect.js +3 -1
  148. package/es/components/molecules/MatchAnySelect/styled.d.ts +8 -15
  149. package/es/components/molecules/MatchAnySelect/utils.d.ts +20 -20
  150. package/es/components/molecules/Modal/Modal.js +1 -1
  151. package/es/components/molecules/Modal/styled.d.ts +1 -2
  152. package/es/components/molecules/ModalSelect/styled.d.ts +1 -2
  153. package/es/components/molecules/ModalV2/styled.d.ts +1 -2
  154. package/es/components/molecules/Popconfirm/Popconfirm.d.ts +0 -1
  155. package/es/components/molecules/PopupDraggable/styled.d.ts +2 -2
  156. package/es/components/molecules/PreviewModal/styled.d.ts +1 -2
  157. package/es/components/molecules/ProcessLoading/styled.d.ts +1 -2
  158. package/es/components/molecules/QuillEditor/CustomToolbar.js +26 -17
  159. package/es/components/molecules/QuillEditor/EditorToolbar.js +1 -0
  160. package/es/components/molecules/QuillEditor/QuillEditor.js +1 -1
  161. package/es/components/molecules/RadioGroup/styled.d.ts +0 -1
  162. package/es/components/molecules/ResizeGrid/components/Cell/Cell.js +2 -1
  163. package/es/components/molecules/ResizeGrid/styled.d.ts +2 -2
  164. package/es/components/molecules/ResizeGrid/types.d.ts +0 -1
  165. package/es/components/molecules/RichMenu/RichMenuBlock/RichMenuCell/styled.d.ts +2 -2
  166. package/es/components/molecules/RichMenu/RichMenuBlock/constants.js +1 -1
  167. package/es/components/molecules/RichMenu/RichMenuChatBar/TypingChat/styled.d.ts +1 -2
  168. package/es/components/molecules/RichMenu/RichMenuChatBar/styled.d.ts +2 -3
  169. package/es/components/molecules/SearchPopover/SearchPopover.d.ts +0 -1
  170. package/es/components/molecules/SearchPopover/styled.d.ts +0 -1
  171. package/es/components/molecules/Select/Select.d.ts +2 -10
  172. package/es/components/molecules/Select/styled.d.ts +2 -3
  173. package/es/components/molecules/SelectAccount/styled.d.ts +2 -3
  174. package/es/components/molecules/SelectMulti/styled.d.ts +4 -5
  175. package/es/components/molecules/SelectMulti/styled.js +4 -4
  176. package/es/components/molecules/SelectV2/styled.d.ts +5 -6
  177. package/es/components/molecules/SelectV2/styled.js +6 -6
  178. package/es/components/molecules/SettingWrapper/styled.d.ts +1 -1
  179. package/es/components/molecules/ShareAccess/actions.d.ts +6 -2
  180. package/es/components/molecules/ShareAccess/actions.js +4 -1
  181. package/es/components/molecules/ShareAccess/components/ModalTransferOwnerShip/styled.d.ts +1 -2
  182. package/es/components/molecules/ShareAccess/constants.d.ts +2 -24
  183. package/es/components/molecules/ShareAccess/constants.js +0 -4
  184. package/es/components/molecules/ShareAccess/hooks/useShareAccess.d.ts +5 -6
  185. package/es/components/molecules/ShareAccess/reducer.d.ts +1 -1
  186. package/es/components/molecules/ShareAccess/reducer.js +1 -1
  187. package/es/components/molecules/ShareAccess/types.d.ts +3 -11
  188. package/es/components/molecules/ShareAccess/utils.d.ts +3 -3
  189. package/es/components/molecules/Tabs/Tabs.d.ts +1 -2
  190. package/es/components/molecules/TagifyInput/TagifyInput.js +27 -114
  191. package/es/components/molecules/TagifyInput/constants.d.ts +2 -11
  192. package/es/components/molecules/TagifyInput/constants.js +0 -1
  193. package/es/components/molecules/TagifyInput/errorWrapper.d.ts +1 -1
  194. package/es/components/molecules/TagifyInput/styled.d.ts +1 -1
  195. package/es/components/molecules/TagifyInput/types.d.ts +1 -27
  196. package/es/components/molecules/TagifyInput/utils.d.ts +1 -4
  197. package/es/components/molecules/TagifyInput/utils.js +0 -9
  198. package/es/components/molecules/TemplateSaveAs/components/ImageSlider/styled.d.ts +1 -2
  199. package/es/components/molecules/TemplateSaveAs/hooks/useTemplateSave.d.ts +3 -4
  200. package/es/components/molecules/TemplateSaveAs/styled.d.ts +2 -3
  201. package/es/components/molecules/TemplateSaveAs/styled.js +1 -1
  202. package/es/components/molecules/Tree/Tree.d.ts +1 -10
  203. package/es/components/molecules/Tree/styled.d.ts +5 -12
  204. package/es/components/molecules/TreeSelect/TreeSelect.d.ts +8 -9
  205. package/es/components/molecules/UnsubscribePreferences/styled.d.ts +0 -1
  206. package/es/components/molecules/UnsubscribePreview/components/styled.d.ts +0 -1
  207. package/es/components/molecules/UploadImage/styled.d.ts +1 -1
  208. package/es/components/molecules/UploadImage/styled.js +6 -4
  209. package/es/components/molecules/VirtualizedMenu/VirtualizedMenu.d.ts +3 -2
  210. package/es/components/molecules/VirtualizedMenu/components/MenuInline/MenuInline.d.ts +5 -6
  211. package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useFocusManagement.d.ts +0 -1
  212. package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useItemInteraction.d.ts +0 -1
  213. package/es/components/molecules/VirtualizedMenu/components/MenuInline/hooks/useKeyboardNavigation.d.ts +0 -1
  214. package/es/components/molecules/VirtualizedMenu/styled.d.ts +0 -1
  215. package/es/components/molecules/VirtualizedMenu/utils.d.ts +0 -1
  216. package/es/components/molecules/index.d.ts +2 -2
  217. package/es/components/molecules/index.js +2 -2
  218. package/es/components/organism/AccountProfile/components/AccountSetting/AccountSetting.js +1 -2
  219. package/es/components/organism/AccountProfile/components/AccountSetting/components/EditableInput/constant.js +3 -3
  220. package/es/components/organism/AccountProfile/components/AccountSetting/components/EditableInput/index.js +1 -1
  221. package/es/components/organism/AccountProfile/components/AccountSetting/components/LanguageSelector/styles.d.ts +5 -6
  222. package/es/components/organism/AccountProfile/components/AccountSetting/components/LanguageSelector/styles.js +1 -1
  223. package/es/components/organism/AccountProfile/components/AccountSetting/styled.d.ts +0 -1
  224. package/es/components/organism/AccountProfile/components/AccountSetting/types.d.ts +0 -1
  225. package/es/components/organism/AccountProfile/components/AccountSetting/types.js +0 -1
  226. package/es/components/organism/AccountProfile/components/AccountSetting/utils.js +7 -5
  227. package/es/components/organism/AccountSharing/AccountSharing.d.ts +0 -1
  228. package/es/components/organism/AccountSharing/AccountSharing.js +33 -17
  229. package/es/components/organism/AccountSharing/styled.js +3 -13
  230. package/es/components/organism/ActivityTimeline/components/ItemGroupEvent/ItemGroupEvent.d.ts +1 -1
  231. package/es/components/organism/ActivityTimeline/components/List/styled.d.ts +0 -1
  232. package/es/components/organism/ActivityTimeline/components/ListItem/styled.d.ts +1 -2
  233. package/es/components/organism/ActivityTimeline/components/ProductCard/styled.d.ts +0 -1
  234. package/es/components/organism/ActivityTimeline/components/Slide/styled.d.ts +87 -88
  235. package/es/components/organism/ActivityTimeline/components/TimeLineTitle/styled.d.ts +0 -1
  236. package/es/components/organism/ActivityTimeline/components/TimelineSection/styled.d.ts +1 -1
  237. package/es/components/organism/ActivityTimeline/index.d.ts +2 -16
  238. package/es/components/organism/ActivityTimeline/styled.d.ts +0 -1
  239. package/es/components/organism/ActivityTimeline/types.d.ts +0 -1
  240. package/es/components/organism/AlgorithmsSetting/styled.d.ts +2 -3
  241. package/es/components/organism/AllocateCoupon/AllocateCoupon.d.ts +31 -0
  242. package/es/components/organism/AllocateCoupon/AllocateCoupon.js +33 -0
  243. package/es/components/organism/AllocateCoupon/components/ConditionRow.d.ts +16 -0
  244. package/es/components/organism/AllocateCoupon/components/ConditionRow.js +67 -0
  245. package/es/components/organism/AllocateCoupon/components/ConditionsField.d.ts +12 -0
  246. package/es/components/organism/AllocateCoupon/components/ConditionsField.js +27 -0
  247. package/es/components/organism/AllocateCoupon/components/EventRefDisplay.d.ts +15 -0
  248. package/es/components/organism/AllocateCoupon/components/EventRefDisplay.js +28 -0
  249. package/es/components/organism/AllocateCoupon/components/FieldRow.d.ts +15 -0
  250. package/es/components/organism/AllocateCoupon/components/FieldRow.js +15 -0
  251. package/es/components/organism/AllocateCoupon/components/IdentifierField.d.ts +13 -0
  252. package/es/components/organism/AllocateCoupon/components/IdentifierField.js +24 -0
  253. package/es/components/organism/AllocateCoupon/components/PoolField.d.ts +8 -0
  254. package/es/components/organism/AllocateCoupon/components/PoolField.js +17 -0
  255. package/es/components/organism/AllocateCoupon/components/QuantityField.d.ts +20 -0
  256. package/es/components/organism/AllocateCoupon/components/QuantityField.js +58 -0
  257. package/es/components/organism/AllocateCoupon/components/RefreshButton.d.ts +14 -0
  258. package/es/components/organism/AllocateCoupon/components/RefreshButton.js +21 -0
  259. package/es/components/organism/AllocateCoupon/components/Root.d.ts +10 -0
  260. package/es/components/organism/AllocateCoupon/components/Root.js +20 -0
  261. package/es/components/organism/AllocateCoupon/components/SourceEventField.d.ts +15 -0
  262. package/es/components/organism/AllocateCoupon/components/SourceEventField.js +50 -0
  263. package/es/components/organism/AllocateCoupon/constants/index.d.ts +59 -0
  264. package/es/components/organism/AllocateCoupon/constants/index.js +70 -0
  265. package/es/components/organism/AllocateCoupon/contexts/AllocateCouponContext.d.ts +4 -0
  266. package/es/components/organism/AllocateCoupon/contexts/AllocateCouponContext.js +15 -0
  267. package/es/components/organism/AllocateCoupon/hooks/useAllocateCoupon.d.ts +2 -0
  268. package/es/components/organism/AllocateCoupon/hooks/useAllocateCoupon.js +231 -0
  269. package/es/components/organism/AllocateCoupon/hooks/useAllocateCouponAttributeOptions.d.ts +27 -0
  270. package/es/components/organism/AllocateCoupon/hooks/useAllocateCouponAttributeOptions.js +45 -0
  271. package/es/components/organism/AllocateCoupon/hooks/useAllocateCouponStore.d.ts +8 -0
  272. package/es/components/organism/AllocateCoupon/hooks/useAllocateCouponStore.js +23 -0
  273. package/es/components/organism/AllocateCoupon/hooks/useAllocateCouponSync.d.ts +8 -0
  274. package/es/components/organism/AllocateCoupon/hooks/useAllocateCouponSync.js +43 -0
  275. package/es/components/organism/AllocateCoupon/index.d.ts +15 -0
  276. package/es/components/organism/AllocateCoupon/index.js +5 -0
  277. package/es/components/organism/AllocateCoupon/providers/AllocateCouponProvider.d.ts +8 -0
  278. package/es/components/organism/AllocateCoupon/providers/AllocateCouponProvider.js +7 -0
  279. package/es/components/organism/AllocateCoupon/stores/index.d.ts +11 -0
  280. package/es/components/organism/AllocateCoupon/stores/index.js +59 -0
  281. package/es/components/organism/AllocateCoupon/styles.scss +141 -0
  282. package/es/components/organism/AllocateCoupon/types/index.d.ts +336 -0
  283. package/es/components/organism/AllocateCoupon/types/index.js +22 -0
  284. package/es/components/organism/AllocateCoupon/utils/index.d.ts +50 -0
  285. package/es/components/organism/AllocateCoupon/utils/index.js +215 -0
  286. package/es/components/organism/BasicLogin/components/ChooseMethod/Method.d.ts +0 -1
  287. package/es/components/organism/BasicLogin/components/ChooseMethod/styled.d.ts +1 -2
  288. package/es/components/organism/BasicLogin/components/WidgetLayout/styled.d.ts +0 -1
  289. package/es/components/organism/BasicLogin/styled.d.ts +12 -13
  290. package/es/components/organism/ContentSources/Settings.d.ts +0 -3
  291. package/es/components/organism/ContentSources/Settings.js +1 -1
  292. package/es/components/organism/ContentSources/index.d.ts +0 -3
  293. package/es/components/organism/ContentSources/index.js +3 -4
  294. package/es/components/organism/ContentSources/styled.d.ts +1 -2
  295. package/es/components/organism/DataTable/DataTable.js +1 -1
  296. package/es/components/organism/DataTable/components/ModifyColumn/styled.d.ts +2 -3
  297. package/es/components/organism/DataTable/components/Pagination/index.js +1 -1
  298. package/es/components/organism/DataTable/components/Pagination/styled.d.ts +2 -3
  299. package/es/components/organism/DataTable/components/Table/styled.d.ts +6 -6
  300. package/es/components/organism/DataTable/components/Toolbar/styled.d.ts +5 -6
  301. package/es/components/organism/DataTable/constants/toolbar.d.ts +2 -47
  302. package/es/components/organism/DataTable/contexts/DataTableContext.d.ts +0 -1
  303. package/es/components/organism/DataTable/hooks/index.d.ts +0 -1
  304. package/es/components/organism/DataTable/hooks/index.js +0 -1
  305. package/es/components/organism/DataTable/hooks/useDataTableListing/types.d.ts +1 -1
  306. package/es/components/organism/DataTable/index.d.ts +2 -2
  307. package/es/components/organism/DataTable/index.js +1 -1
  308. package/es/components/organism/DataTable/providers/AntdTableConfigProvider.d.ts +2 -1
  309. package/es/components/organism/DataTable/styled/index.d.ts +3 -4
  310. package/es/components/organism/DataTable/types/index.d.ts +2 -3
  311. package/es/components/organism/DataTable/types/toolbar.d.ts +1 -1
  312. package/es/components/organism/DataTable/utils/filter.d.ts +3 -3
  313. package/es/components/organism/Filter/components/FilterActionButton.js +1 -1
  314. package/es/components/organism/Filter/components/FilterCondition/styled.d.ts +1 -2
  315. package/es/components/organism/Filter/contexts/FilterContext.d.ts +0 -1
  316. package/es/components/organism/Filter/hooks/useAddFilterCondition.d.ts +7 -8
  317. package/es/components/organism/Filter/styled.d.ts +4 -5
  318. package/es/components/organism/Filter/types/index.d.ts +1 -2
  319. package/es/components/organism/Filter/utils/index.d.ts +4 -3
  320. package/es/components/organism/Filter/utils/index.js +1 -1
  321. package/es/components/organism/FilterSetting/components/common/InputOrSelect/index.d.ts +9 -9
  322. package/es/components/organism/FilterSetting/components/common/InputSelectMulti/ColumnSuggestion/index.d.ts +1 -1
  323. package/es/components/organism/FilterSetting/components/common/InputSelectMulti/Tree/index.d.ts +1 -1
  324. package/es/components/organism/FilterSetting/components/common/InputSelectMulti/index.d.ts +2 -1
  325. package/es/components/organism/FilterSetting/constants.d.ts +57 -1
  326. package/es/components/organism/FilterSetting/context.d.ts +0 -1
  327. package/es/components/organism/Help/Help.js +37 -35
  328. package/es/components/organism/Help/styled.d.ts +11 -16
  329. package/es/components/organism/Help/utils.js +1 -0
  330. package/es/components/organism/LeftMenu/LeftMenu.d.ts +1 -1
  331. package/es/components/organism/LeftMenu/LeftMenu.js +7 -7
  332. package/es/components/organism/LeftMenu/components/CustomMenu/index.js +1 -1
  333. package/es/components/organism/LeftMenu/components/HomeMenu/index.d.ts +3 -1
  334. package/es/components/organism/LeftMenu/components/HomeMenu/index.js +0 -36
  335. package/es/components/organism/LeftMenu/components/HomeMenu/styled.d.ts +1 -2
  336. package/es/components/organism/LeftMenu/components/HomeMenu/useHomeMenu.d.ts +1 -2
  337. package/es/components/organism/LeftMenu/components/HomeMenu/useHomeMenu.js +1 -1
  338. package/es/components/organism/LeftMenu/components/common/ChildMenu/components/MenuItemImage/styled.d.ts +1 -2
  339. package/es/components/organism/LeftMenu/components/common/ChildMenu/index.js +1 -1
  340. package/es/components/organism/LeftMenu/components/common/ChildMenu/styled.d.ts +2 -3
  341. package/es/components/organism/LeftMenu/contexts/index.d.ts +0 -1
  342. package/es/components/organism/LeftMenu/hooks/useLeftMenu.d.ts +1 -1
  343. package/es/components/organism/LeftMenu/index.d.ts +24 -2
  344. package/es/components/organism/LeftMenu/styled.d.ts +4 -5
  345. package/es/components/organism/LeftMenu/styled.js +0 -2
  346. package/es/components/organism/LeftMenu/types/index.d.ts +1 -30
  347. package/es/components/organism/LeftMenu/utils/index.d.ts +5 -5
  348. package/es/components/organism/LeftMenu/utils/index.js +5 -7
  349. package/es/components/organism/Login/Login.js +36 -19
  350. package/es/components/organism/Login/components/ChooseMethod/Method.d.ts +0 -1
  351. package/es/components/organism/Login/components/ChooseMethod/styled.d.ts +1 -2
  352. package/es/components/organism/Login/components/SignIn/SignIn.js +2 -2
  353. package/es/components/organism/Login/components/VerifyAccount/styled.d.ts +7 -8
  354. package/es/components/organism/Login/components/WidgetLayout/styled.d.ts +0 -1
  355. package/es/components/organism/Login/styled.d.ts +14 -15
  356. package/es/components/organism/Login/types/index.d.ts +0 -2
  357. package/es/components/organism/Menu/styled.d.ts +1 -1
  358. package/es/components/organism/ModifyColumnModal/styled.d.ts +3 -4
  359. package/es/components/organism/Notification/styled.d.ts +0 -1
  360. package/es/components/organism/PreviewCollections/WhatsappMessage/CarouselMessage/styled.d.ts +0 -1
  361. package/es/components/organism/PreviewCollections/WhatsappMessage/utils.d.ts +2 -2
  362. package/es/components/organism/PreviewCollections/styled.d.ts +4 -3
  363. package/es/components/organism/PreviewTemplateModal/components/Banner/styled.d.ts +1 -1
  364. package/es/components/organism/PreviewTemplateModal/components/Banner/styled.js +3 -1
  365. package/es/components/organism/PreviewTemplateModal/components/Information/styled.d.ts +2 -3
  366. package/es/components/organism/PreviewTemplateModal/components/SimilarTemplate/index.js +1 -1
  367. package/es/components/organism/PreviewTemplateModal/components/SimilarTemplate/styled.d.ts +1 -2
  368. package/es/components/organism/PreviewTemplateModal/components/ThumbnailSlider/index.js +1 -1
  369. package/es/components/organism/PreviewTemplateModal/stories/dataTypes/dataType.stories.js +2 -1
  370. package/es/components/organism/PreviewTemplateModal/styled.d.ts +0 -1
  371. package/es/components/organism/PreviewTemplateModal/styled.js +1 -1
  372. package/es/components/organism/PreviewTemplateModal/types.d.ts +2 -3
  373. package/es/components/organism/SQLGeneration/components/CheckboxShowDiff.d.ts +0 -1
  374. package/es/components/organism/SQLGeneration/components/SQLGenerationCodeBlock.d.ts +0 -1
  375. package/es/components/organism/SQLGeneration/components/SQLGenerationPagination.d.ts +0 -1
  376. package/es/components/organism/SQLGeneration/components/SQLGenerationQuerySummary.d.ts +0 -1
  377. package/es/components/organism/SQLGeneration/components/SQLGenerationResult.d.ts +0 -1
  378. package/es/components/organism/SQLGeneration/components/styled.d.ts +1 -2
  379. package/es/components/organism/SQLGeneration/index.d.ts +1 -1
  380. package/es/components/organism/SQLGeneration/store/store.d.ts +42 -83
  381. package/es/components/organism/Table/ExplorePivotTable/styled.d.ts +6 -6
  382. package/es/components/organism/TextEditor/TextEditor.d.ts +2 -2
  383. package/es/components/organism/TextEditor/index.d.ts +2 -3
  384. package/es/components/organism/TextEditor/provider.d.ts +0 -1
  385. package/es/components/organism/TextEditor/styled.d.ts +1 -2
  386. package/es/components/organism/TextEditor/types.d.ts +3 -68
  387. package/es/components/organism/TextEditor/ui/BubbleMenu/BubbleMenu.d.ts +0 -1
  388. package/es/components/organism/TextEditor/ui/Button/Button.d.ts +5 -6
  389. package/es/components/organism/TextEditor/ui/Button/types.d.ts +0 -1
  390. package/es/components/organism/TextEditor/ui/Emoji/EmojiList.d.ts +0 -1
  391. package/es/components/organism/TextEditor/ui/FontPopover/FontPopover.d.ts +0 -1
  392. package/es/components/organism/TextEditor/ui/Popover/Popover.d.ts +0 -1
  393. package/es/components/organism/TextEditor/ui/SplitButtonDropdown/styled.d.ts +0 -1
  394. package/es/components/organism/TextEditor/ui/SplitButtonDropdown/types.d.ts +0 -1
  395. package/es/components/organism/TextEditor/ui/TextAlignSelect/TextAlignSelect.d.ts +0 -1
  396. package/es/components/organism/TextEditor/ui/Toolbar/actions/BoldAction.d.ts +0 -1
  397. package/es/components/organism/TextEditor/ui/Toolbar/actions/FontSizeAction.d.ts +0 -1
  398. package/es/components/organism/TextEditor/ui/Toolbar/actions/SmartTagAction.d.ts +0 -1
  399. package/es/components/organism/TextEditor/ui/Toolbar/actions/TextColorAction.d.ts +0 -1
  400. package/es/components/organism/TextEditor/ui/Toolbar/actions/UnsetLink.d.ts +0 -1
  401. package/es/components/organism/TextEditor/utils/link.d.ts +6 -6
  402. package/es/components/organism/TicketEditor/Content.js +29 -47
  403. package/es/components/organism/TicketEditor/components/MessageComponent.js +3 -3
  404. package/es/components/organism/TicketEditor/components/icons/AddTicketIcon.d.ts +1 -1
  405. package/es/components/organism/TicketEditor/components/icons/AddTicketIcon.js +3 -1
  406. package/es/components/organism/TicketEditor/components/icons/TicketIcon.d.ts +1 -2
  407. package/es/components/organism/TicketEditor/components/icons/TicketIcon.js +3 -1
  408. package/es/components/organism/TicketEditor/styled.d.ts +5 -6
  409. package/es/components/organism/TicketEditor/styled.js +0 -10
  410. package/es/components/organism/TicketEditor/util.d.ts +1 -2
  411. package/es/components/organism/TicketEditor/util.js +2 -27
  412. package/es/components/organism/TicketEditorV2/Content.d.ts +0 -1
  413. package/es/components/organism/TicketEditorV2/Content.js +18 -29
  414. package/es/components/organism/TicketEditorV2/components/MessageComponent.js +1 -1
  415. package/es/components/organism/TicketEditorV2/queries/useGetDetailTicket.d.ts +1 -1
  416. package/es/components/organism/TicketEditorV2/queries/useGetListComments.d.ts +1 -1
  417. package/es/components/organism/TicketEditorV2/styled.d.ts +5 -6
  418. package/es/components/organism/index.d.ts +1 -1
  419. package/es/components/organism/index.js +1 -1
  420. package/es/components/template/Layout/Layout.js +1 -3
  421. package/es/components/template/Layout/components/RecommendationWorkspace/components/MenuMapping/styled.d.ts +1 -2
  422. package/es/components/template/Layout/stores/index.d.ts +2 -3
  423. package/es/components/template/Layout/styled.d.ts +4 -5
  424. package/es/components/template/Layout/types.d.ts +0 -1
  425. package/es/components/template/TemplateListing/Loadable.d.ts +0 -1
  426. package/es/components/template/TemplateListing/components/BlankTemplate/styled.d.ts +1 -2
  427. package/es/components/template/TemplateListing/components/CategoryListing/index.js +1 -1
  428. package/es/components/template/TemplateListing/components/CategoryListing/styled.d.ts +1 -2
  429. package/es/components/template/TemplateListing/components/CategoryListing/types.d.ts +0 -1
  430. package/es/components/template/TemplateListing/components/Empty/styled.d.ts +1 -2
  431. package/es/components/template/TemplateListing/constants/defaultProps.d.ts +1 -1
  432. package/es/components/template/TemplateListing/hooks/useTemplateListing.d.ts +2 -3
  433. package/es/components/template/TemplateListing/stories/dataTypes/dataType.stories.js +2 -1
  434. package/es/components/template/TemplateListing/styled/index.d.ts +1 -2
  435. package/es/components/template/TemplateListing/types/Empty.d.ts +0 -1
  436. package/es/components/template/TemplateListing/types/TemplateListing.d.ts +8 -2
  437. package/es/components/template/TemplateListing/types/index.d.ts +0 -1
  438. package/es/constants/api.d.ts +19 -9
  439. package/es/constants/api.js +0 -7
  440. package/es/constants/queries.d.ts +0 -1
  441. package/es/constants/queries.js +0 -1
  442. package/es/constants/theme.d.ts +1 -3
  443. package/es/constants/unsubscribe.d.ts +11 -1
  444. package/es/hooks/index.d.ts +0 -1
  445. package/es/hooks/useDebounce.d.ts +0 -1
  446. package/es/hooks/useDeepCompareMemo.d.ts +0 -1
  447. package/es/hooks/useDragEvent.d.ts +1 -1
  448. package/es/hooks/useEffectWithTarget.d.ts +1 -2
  449. package/es/hooks/useElementSize.d.ts +0 -1
  450. package/es/hooks/useFocusManagement.d.ts +0 -1
  451. package/es/hooks/useKeyEventCanvas.d.ts +1 -1
  452. package/es/hooks/useLatest.d.ts +0 -1
  453. package/es/hooks/useListingItemResize.d.ts +0 -1
  454. package/es/hooks/useOutsideClick.d.ts +0 -1
  455. package/es/locales/en/translation.json +75 -0
  456. package/es/locales/i18n.d.ts +150 -0
  457. package/es/locales/vi/translation.json +75 -0
  458. package/es/models/PromotionPool.d.ts +3 -0
  459. package/es/models/PromotionPool.js +4 -0
  460. package/es/providers/AppConfigProvider/contexts/index.d.ts +3 -4
  461. package/es/providers/AppConfigProvider/contexts/index.js +3 -5
  462. package/es/providers/ConfigProvider/ConfigProvider.d.ts +1 -1
  463. package/es/providers/ConfigProvider/ConfigProvider.js +1 -1
  464. package/es/providers/ConfigProvider/GlobalStyle.js +3 -2
  465. package/es/queries/Account/useGetAccountList.js +1 -1
  466. package/es/queries/BusinessObject/useGetListEventAttr.d.ts +1 -1
  467. package/es/queries/BusinessObject/useGetListPromotionCodeAttr.d.ts +1 -1
  468. package/es/queries/CustomFunction/useCustomFunction.d.ts +1 -1
  469. package/es/queries/DynamicContentAttribute/useGetDynamicContentAttr.d.ts +1 -1
  470. package/es/queries/PromotionPool/useGetListPromotionPool.d.ts +1 -1
  471. package/es/queries/TemplateListing/index.d.ts +1 -1
  472. package/es/queries/User/index.d.ts +1 -0
  473. package/es/queries/User/index.js +1 -0
  474. package/es/services/MediaTemplateDesign/BusinessObject/index.d.ts +3 -3
  475. package/es/services/index.js +5 -3
  476. package/es/styled/common.d.ts +1 -2
  477. package/es/test.d.ts +11 -0
  478. package/es/test.js +377 -138
  479. package/es/utils/color.d.ts +1 -0
  480. package/es/utils/common.js +1 -0
  481. package/es/utils/cookie.js +4 -5
  482. package/es/utils/web.d.ts +1 -2
  483. package/package.json +57 -80
  484. package/es/__tests__/fileMock.test.d.ts +0 -2
  485. package/es/__tests__/fileMock.test.js +0 -2
  486. package/es/__tests__/styleMock.test.d.ts +0 -1
  487. package/es/__tests__/styleMock.test.js +0 -2
  488. package/es/components/atoms/Input/types.d.ts +0 -17
  489. package/es/components/atoms/Input/types.js +0 -1
  490. package/es/components/atoms/Popover/styled.d.ts +0 -4
  491. package/es/components/atoms/Popover/styled.js +0 -5
  492. package/es/components/molecules/UploadImage/MediaThumb.d.ts +0 -8
  493. package/es/components/molecules/UploadImage/MediaThumb.js +0 -15
  494. package/es/components/molecules/UploadImage/VideoThumbnail.d.ts +0 -4
  495. package/es/components/molecules/UploadImage/VideoThumbnail.js +0 -40
  496. package/es/components/organism/DataTable/hooks/useCDPTable/useCDPTable.d.ts +0 -58
  497. package/es/components/organism/DataTable/hooks/useCDPTable/useCDPTable.js +0 -127
  498. package/es/components/organism/FilterSetting/components/common/InputSelectMulti/types.d.ts +0 -1
  499. package/es/components/organism/FilterSetting/components/common/InputSelectMulti/types.js +0 -1
  500. package/es/components/organism/GenerativeInsights/constants.d.ts +0 -1
  501. package/es/components/organism/GenerativeInsights/constants.js +0 -1
  502. package/es/components/organism/GenerativeInsights/index.d.ts +0 -11
  503. package/es/components/organism/GenerativeInsights/index.js +0 -54
  504. package/es/components/organism/GenerativeInsights/styled.d.ts +0 -12
  505. package/es/components/organism/GenerativeInsights/styled.js +0 -65
  506. package/es/components/organism/GenerativeInsights/utils.d.ts +0 -13
  507. package/es/components/organism/GenerativeInsights/utils.js +0 -49
  508. package/es/components/organism/LeftMenu/components/HomeMenu/types.d.ts +0 -3
  509. package/es/components/organism/LeftMenu/components/HomeMenu/types.js +0 -1
  510. package/es/components/organism/LeftMenu/hooks/types.d.ts +0 -24
  511. package/es/components/organism/LeftMenu/hooks/types.js +0 -1
  512. package/es/components/template/TemplateListing/types/TemplateItem.d.ts +0 -7
  513. package/es/components/template/TemplateListing/types/TemplateItem.js +0 -1
  514. package/es/utils/crossSubdomainCookieOptions.d.ts +0 -14
  515. package/es/utils/crossSubdomainCookieOptions.js +0 -12
@@ -0,0 +1,17 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import clsx from 'clsx';
3
+ // Components
4
+ import { FieldRow } from './FieldRow';
5
+ import { Select } from '../../../molecules/Select';
6
+ // Context
7
+ import { useAllocateCouponContext } from '../contexts/AllocateCouponContext';
8
+ // Locales
9
+ import i18nInstance from '@antscorp/antsomi-ui/es/locales/i18n';
10
+ import { translations } from '@antscorp/antsomi-ui/es/locales/translations';
11
+ const { t } = i18nInstance;
12
+ export const PoolField = props => {
13
+ const { pool: poolOverride, className, style, classNames, styles } = props;
14
+ const contextPool = useAllocateCouponContext(store => store.pool);
15
+ const pool = poolOverride ?? contextPool;
16
+ return (_jsx(FieldRow, { label: t(translations.allocateCoupon.poolField.label), required: true, helpText: pool.helpText, className: clsx('antsomi-allocate-coupon-pool-field-row', className), style: style, classNames: { label: classNames?.label, helpText: classNames?.helpText }, styles: { label: styles?.label, helpText: styles?.helpText }, children: _jsx(Select, { showSearch: true, loading: pool.isLoading, value: pool.selectedId ?? undefined, placeholder: t(translations.allocateCoupon.poolField.placeholder), className: clsx('antsomi-allocate-coupon-pool-select', classNames?.select), style: styles?.select, options: pool.options.map(option => ({ value: option.id, label: option.name })), onChange: pool.onSelect }) }));
17
+ };
@@ -0,0 +1,20 @@
1
+ import React, { ReactNode } from 'react';
2
+ import type { AllocateCouponConditionsState, AllocateCouponQuantityState, AllocateCouponSourceEventState, ConditionOperatorOptionsResolver, ConditionValueRenderer, SlotStyleProps, SourceEventGroupResolver } from '../types';
3
+ export type QuantityFieldSlot = 'label' | 'modeToggle' | 'fixedValue' | 'eventPanel' | 'sourceEvent' | 'calcMethod' | 'field' | 'conditions' | 'fallback';
4
+ export interface QuantityFieldProps extends SlotStyleProps<QuantityFieldSlot> {
5
+ quantity?: AllocateCouponQuantityState;
6
+ sourceEvent?: AllocateCouponSourceEventState;
7
+ conditions?: AllocateCouponConditionsState;
8
+ /** Forwarded to the internal `ConditionsField` when using the default (non-`children`)
9
+ * composition — see `ConditionValueRenderer`. */
10
+ renderValue?: ConditionValueRenderer;
11
+ /** Forwarded to the internal `ConditionsField` when using the default (non-`children`)
12
+ * composition — see `ConditionOperatorOptionsResolver`. */
13
+ getOperatorOptions?: ConditionOperatorOptionsResolver;
14
+ /** Forwarded to the internal `SourceEventField` when using the default (non-`children`)
15
+ * composition — see `SourceEventGroupResolver`. */
16
+ getSourceEventGroup?: SourceEventGroupResolver;
17
+ /** Custom internal composition — defaults to the spec order when omitted */
18
+ children?: ReactNode;
19
+ }
20
+ export declare const QuantityField: React.FC<QuantityFieldProps>;
@@ -0,0 +1,58 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import clsx from 'clsx';
3
+ // Components
4
+ import { InputNumber, Radio, RadioGroupSub, RequiredLabel, Text, } from '@antscorp/antsomi-ui/es/components/atoms';
5
+ import { SelectV2 as Select } from '@antscorp/antsomi-ui/es/components/molecules';
6
+ import { TreeSelect } from '../../../molecules/TreeSelect';
7
+ import { FieldRow } from './FieldRow';
8
+ import { SourceEventField } from './SourceEventField';
9
+ import { ConditionsField } from './ConditionsField';
10
+ // Context
11
+ import { useAllocateCouponContext } from '../contexts/AllocateCouponContext';
12
+ // Locales
13
+ import i18nInstance from '@antscorp/antsomi-ui/es/locales/i18n';
14
+ import { translations } from '@antscorp/antsomi-ui/es/locales/translations';
15
+ // Constants
16
+ import { CALC_METHOD_OPTIONS } from '../constants';
17
+ import { FALLBACK_MODE, QUANTITY_MODE } from '../types';
18
+ // Utils
19
+ import { toQuantityFieldOptions } from '../utils';
20
+ const { t } = i18nInstance;
21
+ export const QuantityField = props => {
22
+ const { quantity: quantityOverride, sourceEvent: sourceEventOverride, conditions: conditionsOverride, renderValue, getOperatorOptions, getSourceEventGroup, className, style, classNames, styles, children, } = props;
23
+ const contextPool = useAllocateCouponContext(store => store.pool);
24
+ const contextQuantity = useAllocateCouponContext(store => store.quantity);
25
+ const contextSourceEvent = useAllocateCouponContext(store => store.sourceEvent);
26
+ const quantity = quantityOverride ?? contextQuantity;
27
+ const sourceEvent = sourceEventOverride ?? contextSourceEvent;
28
+ const treeData = toQuantityFieldOptions(quantity.fieldOptions);
29
+ const selectedFieldValue = quantity.field
30
+ ? quantity.field.itemTypeId
31
+ ? `${quantity.field.itemTypeId}.${quantity.field.propertyName}`
32
+ : quantity.field.propertyName || undefined
33
+ : undefined;
34
+ const onChangeFieldValue = (value) => {
35
+ const [itemTypeIdPart, ...rest] = value.split('.');
36
+ const hasItemTypeId = rest.length > 0;
37
+ const flat = quantity.fieldOptions.flatMap(option => option.children?.length ? option.children : [option]);
38
+ const match = flat.find(option => hasItemTypeId
39
+ ? String(option.itemTypeId) === itemTypeIdPart && option.propertyName === rest.join('.')
40
+ : option.propertyName === value);
41
+ if (match) {
42
+ quantity.onChangeField?.({
43
+ itemTypeId: match.itemTypeId,
44
+ propertyName: match.propertyName,
45
+ propertyLabel: match.propertyLabel,
46
+ dataType: match.dataType,
47
+ });
48
+ }
49
+ };
50
+ const isCalculateFromEvent = quantity.mode === QUANTITY_MODE.CALCULATE_FROM_EVENT;
51
+ // Never hides an already-selected mode (e.g. if the upstream trigger is later removed).
52
+ const showCalculateFromEventOption = sourceEvent.list.length > 0 || isCalculateFromEvent;
53
+ if (!contextPool.selectedId) {
54
+ return null;
55
+ }
56
+ return (_jsx(FieldRow, { label: t(translations.allocateCoupon.quantityField.label), required: true, className: className, style: style, classNames: { label: classNames?.label }, styles: { label: styles?.label }, children: _jsxs("div", { className: clsx('antsomi-allocate-coupon-quantity-mode-stack', classNames?.modeToggle), style: styles?.modeToggle, children: [_jsxs(RadioGroupSub, { value: quantity.mode, onChange: event => quantity.onChangeMode?.(event.target.value), children: [_jsxs(Radio, { value: QUANTITY_MODE.FIXED, children: [t(translations.allocateCoupon.quantityField.allocatePrefix), ' ', _jsx(InputNumber, { size: "small", min: 1, disabled: quantity.mode !== QUANTITY_MODE.FIXED, value: quantity.fixedValue ?? undefined, placeholder: t(translations.allocateCoupon.quantityField.enterNumber), className: classNames?.fixedValue, style: styles?.fixedValue, onChange: value => quantity.onChangeFixedValue?.(value ?? null) }), ' ', t(translations.allocateCoupon.quantityField.codesPerTime)] }), showCalculateFromEventOption && (_jsx(Radio, { value: QUANTITY_MODE.CALCULATE_FROM_EVENT, children: t(translations.allocateCoupon.quantityField.calculateFromEvent) }))] }), isCalculateFromEvent &&
57
+ (children ?? (_jsxs("div", { className: clsx('antsomi-allocate-coupon-indented-panel', classNames?.eventPanel), style: styles?.eventPanel, children: [_jsxs("div", { className: "antsomi-allocate-coupon-three-column-row", children: [_jsxs("div", { children: [_jsx(RequiredLabel, { isReverseMask: true, type: "secondary", children: t(translations.allocateCoupon.quantityField.eventLabel) }), _jsx(SourceEventField, { sourceEvent: sourceEventOverride, getSourceEventGroup: getSourceEventGroup, className: classNames?.sourceEvent, style: styles?.sourceEvent })] }), _jsxs("div", { children: [_jsx(RequiredLabel, { isReverseMask: true, type: "secondary", children: t(translations.allocateCoupon.quantityField.calcMethodLabel) }), _jsx(Select, { className: classNames?.calcMethod, style: styles?.calcMethod, value: quantity.calcMethod, options: CALC_METHOD_OPTIONS, onChange: (value) => quantity.onChangeCalcMethod?.(value) })] }), _jsxs("div", { children: [_jsx(RequiredLabel, { isReverseMask: true, type: "secondary", children: t(translations.allocateCoupon.quantityField.attributeLabel) }), _jsx(TreeSelect, { showSearch: true, className: classNames?.field, style: styles?.field, value: selectedFieldValue, placeholder: t(translations.allocateCoupon.quantityField.selectAttribute), treeData: treeData, loading: quantity.isFieldOptionsLoading, onChange: onChangeFieldValue })] })] }), _jsx(Text, { type: "secondary", children: t(translations.allocateCoupon.quantityField.onlyIncludeDataMatching) }), _jsx("div", { className: classNames?.conditions, style: styles?.conditions, children: _jsx(ConditionsField, { conditions: conditionsOverride, renderValue: renderValue, getOperatorOptions: getOperatorOptions }) }), _jsx(FieldRow, { label: t(translations.allocateCoupon.quantityField.whenNoDataMatches), required: true, className: clsx(classNames?.fallback, 'antsomi-allocate-coupon-fallback'), style: styles?.fallback, children: _jsxs(RadioGroupSub, { value: quantity.fallback.mode, onChange: event => quantity.onChangeFallbackMode?.(event.target.value), children: [_jsx(Radio, { value: FALLBACK_MODE.END_JOURNEY, children: t(translations.allocateCoupon.quantityField.endJourney) }), _jsxs(Radio, { value: FALLBACK_MODE.ALLOCATE_FIXED, children: [t(translations.allocateCoupon.quantityField.allocateFixedFallback), _jsx(InputNumber, { size: "small", min: 1, disabled: quantity.fallback.mode !== FALLBACK_MODE.ALLOCATE_FIXED, value: quantity.fallback.fixedValue ?? undefined, placeholder: t(translations.allocateCoupon.quantityField.enterNumber), onChange: value => quantity.onChangeFallbackFixedValue?.(value ?? null) })] })] }) })] })))] }) }));
58
+ };
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ import type { AllocateCouponRefreshState, SlotStyleProps } from '../types';
3
+ export type RefreshButtonSlot = 'button';
4
+ export interface RefreshButtonProps extends SlotStyleProps<RefreshButtonSlot> {
5
+ /** Override the value read from context — mainly for Storybook/tests */
6
+ refresh?: AllocateCouponRefreshState;
7
+ }
8
+ /**
9
+ * Manual refresh for all 5 underlying queries at once (`refresh.onRefresh`, from the headless
10
+ * hook) — not tied to any single field, so it reads a dedicated `refresh` context slice rather
11
+ * than one of the field slices. Same override-prop pattern as every other field component, for
12
+ * standalone Storybook/test rendering without a `Root` ancestor.
13
+ */
14
+ export declare const RefreshButton: React.FC<RefreshButtonProps>;
@@ -0,0 +1,21 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ // Components
3
+ import { Button, Icon } from '@antscorp/antsomi-ui/es/components/atoms';
4
+ // Context
5
+ import { useAllocateCouponContext } from '../contexts/AllocateCouponContext';
6
+ // Locales
7
+ import i18nInstance from '@antscorp/antsomi-ui/es/locales/i18n';
8
+ import { translations } from '@antscorp/antsomi-ui/es/locales/translations';
9
+ const { t } = i18nInstance;
10
+ /**
11
+ * Manual refresh for all 5 underlying queries at once (`refresh.onRefresh`, from the headless
12
+ * hook) — not tied to any single field, so it reads a dedicated `refresh` context slice rather
13
+ * than one of the field slices. Same override-prop pattern as every other field component, for
14
+ * standalone Storybook/test rendering without a `Root` ancestor.
15
+ */
16
+ export const RefreshButton = props => {
17
+ const { refresh: refreshOverride, className, style } = props;
18
+ const contextRefresh = useAllocateCouponContext(store => store.refresh);
19
+ const refresh = refreshOverride ?? contextRefresh;
20
+ return (_jsx(Button, { type: "default", shape: "round", loading: refresh.isRefreshing, icon: refresh.isRefreshing ? undefined : _jsx(Icon, { type: "icon-ants-refresh-1", size: 12 }), className: className, style: { width: 'fit-content', ...style }, onClick: () => refresh.onRefresh?.(), children: t(translations.allocateCoupon.refreshButton.label) }));
21
+ };
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import type { AllocateCouponState } from '../types';
3
+ export interface AllocateCouponRootProps extends Partial<AllocateCouponState> {
4
+ children?: React.ReactNode;
5
+ }
6
+ /**
7
+ * Provider-only wrapper — no layout of its own. Every `AllocateCoupon.*` field component reads
8
+ * its slice of state via context, so it can be mounted anywhere under `Root`, in any order.
9
+ */
10
+ export declare const Root: React.FC<React.PropsWithChildren<AllocateCouponRootProps>>;
@@ -0,0 +1,20 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ // Hooks
3
+ import { useAllocateCouponStore } from '../hooks/useAllocateCouponStore';
4
+ import { useAllocateCouponSync } from '../hooks/useAllocateCouponSync';
5
+ // Providers
6
+ import { AllocateCouponProvider } from '../providers/AllocateCouponProvider';
7
+ const RootSync = props => {
8
+ const { children, ...rest } = props;
9
+ useAllocateCouponSync(rest);
10
+ return children;
11
+ };
12
+ /**
13
+ * Provider-only wrapper — no layout of its own. Every `AllocateCoupon.*` field component reads
14
+ * its slice of state via context, so it can be mounted anywhere under `Root`, in any order.
15
+ */
16
+ export const Root = props => {
17
+ const { children, ...rest } = props;
18
+ const store = useAllocateCouponStore(rest);
19
+ return (_jsx(AllocateCouponProvider, { store: store, children: _jsx(RootSync, { ...rest, children: children }) }));
20
+ };
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import type { AllocateCouponSourceEventState, SlotStyleProps, SourceEventGroupResolver } from '../types';
3
+ export type SourceEventFieldSlot = 'select' | 'item';
4
+ export interface SourceEventFieldProps extends SlotStyleProps<SourceEventFieldSlot> {
5
+ sourceEvent?: AllocateCouponSourceEventState;
6
+ getSourceEventGroup?: SourceEventGroupResolver;
7
+ }
8
+ /**
9
+ * The ancestor Trigger/Wait-for-Event node's event(s), rendered as a searchable dropdown
10
+ * grouped via the consumer-supplied `getSourceEventGroup` resolver (e.g. "Action based trigger"
11
+ * / "Wait for event" — per the design). The store already models this as selectable
12
+ * (`selectedKey`/`onSelect`) even though the resolution itself is derived, not freely authored —
13
+ * with a single upstream event the dropdown just has one (pre-selected) option.
14
+ */
15
+ export declare const SourceEventField: React.FC<SourceEventFieldProps>;
@@ -0,0 +1,50 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ // Libraries
3
+ import { useMemo } from 'react';
4
+ // Components
5
+ import { SelectV2 as Select } from '@antscorp/antsomi-ui/es/components/molecules';
6
+ import { EventRefDisplay } from './EventRefDisplay';
7
+ // Context
8
+ import { useAllocateCouponContext } from '../contexts/AllocateCouponContext';
9
+ // Locales
10
+ import i18nInstance from '@antscorp/antsomi-ui/es/locales/i18n';
11
+ import { translations } from '@antscorp/antsomi-ui/es/locales/translations';
12
+ // Utils
13
+ import { buildSourceEventKey } from '../utils';
14
+ const { t } = i18nInstance;
15
+ const UNGROUPED_KEY = 'UNGROUPED';
16
+ /**
17
+ * The ancestor Trigger/Wait-for-Event node's event(s), rendered as a searchable dropdown
18
+ * grouped via the consumer-supplied `getSourceEventGroup` resolver (e.g. "Action based trigger"
19
+ * / "Wait for event" — per the design). The store already models this as selectable
20
+ * (`selectedKey`/`onSelect`) even though the resolution itself is derived, not freely authored —
21
+ * with a single upstream event the dropdown just has one (pre-selected) option.
22
+ */
23
+ export const SourceEventField = props => {
24
+ const { sourceEvent: sourceEventOverride, getSourceEventGroup, className, style, classNames, styles, } = props;
25
+ const contextSourceEvent = useAllocateCouponContext(store => store.sourceEvent);
26
+ const sourceEvent = sourceEventOverride ?? contextSourceEvent;
27
+ const groupedOptions = useMemo(() => {
28
+ const groups = new Map();
29
+ sourceEvent.list.forEach(ref => {
30
+ const group = getSourceEventGroup?.(ref) ?? {
31
+ groupKey: UNGROUPED_KEY,
32
+ groupLabel: t(translations.allocateCoupon.sourceEventField.ungroupedLabel),
33
+ };
34
+ const option = {
35
+ value: buildSourceEventKey(ref),
36
+ label: (_jsx(EventRefDisplay, { eventRef: ref, hookError: sourceEvent.error, className: classNames?.item, style: styles?.item })),
37
+ };
38
+ const bucket = groups.get(group.groupKey) ?? { groupLabel: group.groupLabel, options: [] };
39
+ bucket.options.push(option);
40
+ groups.set(group.groupKey, bucket);
41
+ });
42
+ return Array.from(groups.values()).map(({ groupLabel, options }) => ({
43
+ label: groupLabel,
44
+ options,
45
+ }));
46
+ }, [sourceEvent.list, sourceEvent.error, getSourceEventGroup, classNames?.item, styles?.item]);
47
+ return (_jsx(Select, { showSearch: true, loading: sourceEvent.isLoading, disabled: !sourceEvent.list.length, value: sourceEvent.selectedKey ?? undefined, placeholder: t(translations.allocateCoupon.sourceEventField.noUpstreamNode), className: classNames?.select ?? className, style: { width: '100%', ...style, ...styles?.select }, options: groupedOptions, filterOption: (input, option) => typeof option?.label === 'string'
48
+ ? option.label.toLowerCase().includes(input.toLowerCase())
49
+ : true, onChange: value => sourceEvent.onSelect?.(value) }));
50
+ };
@@ -0,0 +1,59 @@
1
+ import { AllocateCouponState, CALC_METHOD, FALLBACK_MODE, GET_DATA_FROM, QUANTITY_MODE } from '../types';
2
+ export { QUANTITY_MODE, CALC_METHOD, FALLBACK_MODE, GET_DATA_FROM };
3
+ export declare const CALC_METHOD_OPTIONS: ({
4
+ label: string;
5
+ value: "SUM";
6
+ } | {
7
+ label: string;
8
+ value: "COUNT";
9
+ })[];
10
+ /** Generic operator set for condition rows, used until each field's real `dataType` is threaded
11
+ * through `useGetListEventAttr`/`useGetListAttributeBO` — see plan §9 follow-up note. Uses the
12
+ * "suggestion" set since it's the only one in `src/constants/condition.ts` that includes a
13
+ * "matches any of" option, needed for multi-value BO attribute conditions (e.g. "Product >>
14
+ * Category matches any of Drinks, Food" in the design). */
15
+ export declare const DEFAULT_CONDITION_OPERATOR_OPTIONS: ({
16
+ label: string;
17
+ value: "not_equals";
18
+ } | {
19
+ label: string;
20
+ value: "equals";
21
+ } | {
22
+ label: string;
23
+ value: "exists";
24
+ } | {
25
+ label: string;
26
+ value: "not_exists";
27
+ } | {
28
+ label: string;
29
+ value: "contains";
30
+ } | {
31
+ label: string;
32
+ value: "doesnt_contain";
33
+ } | {
34
+ label: string;
35
+ value: "start_with";
36
+ } | {
37
+ label: string;
38
+ value: "not_start_with";
39
+ } | {
40
+ label: string;
41
+ value: "end_with";
42
+ } | {
43
+ label: string;
44
+ value: "not_end_with";
45
+ } | {
46
+ label: string;
47
+ value: "matches";
48
+ } | {
49
+ label: string;
50
+ value: "not_matches";
51
+ })[];
52
+ /** Fixed, static option set for the Identifier field's dropdown — there's no backend precedent
53
+ * for identifier types yet (identifier ownership is an open product decision, see
54
+ * `AllocateCouponIdentifierState` in types), so this isn't fetched from any API. */
55
+ export declare const IDENTIFIER_OPTIONS: {
56
+ label: string;
57
+ value: string;
58
+ }[];
59
+ export declare const allocateCouponInitialState: AllocateCouponState;
@@ -0,0 +1,70 @@
1
+ // Locales
2
+ import i18nInstance from '@antscorp/antsomi-ui/es/locales/i18n';
3
+ import { translations } from '@antscorp/antsomi-ui/es/locales/translations';
4
+ // Constants
5
+ import { OPERATORS } from '@antscorp/antsomi-ui/es/constants/condition';
6
+ // Types
7
+ import { CALC_METHOD, FALLBACK_MODE, GET_DATA_FROM, QUANTITY_MODE, } from '../types';
8
+ export { QUANTITY_MODE, CALC_METHOD, FALLBACK_MODE, GET_DATA_FROM };
9
+ const { t } = i18nInstance;
10
+ export const CALC_METHOD_OPTIONS = [
11
+ { label: t(translations.allocateCoupon.calcMethod.sum), value: CALC_METHOD.SUM },
12
+ { label: t(translations.allocateCoupon.calcMethod.count), value: CALC_METHOD.COUNT },
13
+ ];
14
+ /** Generic operator set for condition rows, used until each field's real `dataType` is threaded
15
+ * through `useGetListEventAttr`/`useGetListAttributeBO` — see plan §9 follow-up note. Uses the
16
+ * "suggestion" set since it's the only one in `src/constants/condition.ts` that includes a
17
+ * "matches any of" option, needed for multi-value BO attribute conditions (e.g. "Product >>
18
+ * Category matches any of Drinks, Food" in the design). */
19
+ export const DEFAULT_CONDITION_OPERATOR_OPTIONS = OPERATORS.suggestion.list;
20
+ /** Fixed, static option set for the Identifier field's dropdown — there's no backend precedent
21
+ * for identifier types yet (identifier ownership is an open product decision, see
22
+ * `AllocateCouponIdentifierState` in types), so this isn't fetched from any API. */
23
+ export const IDENTIFIER_OPTIONS = [
24
+ { label: t(translations.allocateCoupon.identifierOptions.phone), value: 'phone' },
25
+ { label: t(translations.allocateCoupon.identifierOptions.email), value: 'email' },
26
+ { label: t(translations.allocateCoupon.identifierOptions.customerId), value: 'customer_id' },
27
+ { label: t(translations.allocateCoupon.identifierOptions.userId), value: 'user_id' },
28
+ ];
29
+ export const allocateCouponInitialState = {
30
+ pool: {
31
+ selectedId: null,
32
+ options: [],
33
+ isLoading: false,
34
+ error: null,
35
+ helpText: undefined,
36
+ },
37
+ quantity: {
38
+ mode: QUANTITY_MODE.FIXED,
39
+ fixedValue: null,
40
+ calcMethod: CALC_METHOD.SUM,
41
+ field: null,
42
+ fieldOptions: [],
43
+ isFieldOptionsLoading: false,
44
+ fieldOptionsError: null,
45
+ fallback: {
46
+ mode: FALLBACK_MODE.END_JOURNEY,
47
+ fixedValue: null,
48
+ },
49
+ },
50
+ sourceEvent: {
51
+ list: [],
52
+ selectedKey: null,
53
+ isLoading: false,
54
+ error: null,
55
+ },
56
+ conditions: {
57
+ items: [],
58
+ fieldOptions: [],
59
+ isFieldOptionsLoading: false,
60
+ fieldOptionsError: null,
61
+ },
62
+ identifier: {
63
+ value: null,
64
+ visible: false,
65
+ options: IDENTIFIER_OPTIONS,
66
+ },
67
+ refresh: {
68
+ isRefreshing: false,
69
+ },
70
+ };
@@ -0,0 +1,4 @@
1
+ import { StoreApi } from 'zustand';
2
+ import { AllocateCouponStore } from '../types';
3
+ export declare const AllocateCouponContext: import("react").Context<StoreApi<AllocateCouponStore> | null>;
4
+ export declare function useAllocateCouponContext<T>(selector: (allocateCouponStore: AllocateCouponStore) => T): T;
@@ -0,0 +1,15 @@
1
+ // Libraries
2
+ import { createContext, useContext } from 'react';
3
+ import isEqual from 'react-fast-compare';
4
+ import { useStore } from 'zustand';
5
+ // Hooks
6
+ import { useDeepCompareMemo } from '@antscorp/antsomi-ui/es/hooks';
7
+ export const AllocateCouponContext = createContext(null);
8
+ export function useAllocateCouponContext(selector) {
9
+ const store = useContext(AllocateCouponContext);
10
+ if (!store)
11
+ throw new Error('Missing AllocateCouponContext.Provider in the tree');
12
+ const selectedState = useStore(store, selector);
13
+ const memoizedState = useDeepCompareMemo(() => selectedState, [selectedState]);
14
+ return useDeepCompareMemo(() => (isEqual(selectedState, memoizedState) ? memoizedState : selectedState), [selectedState, memoizedState]);
15
+ }
@@ -0,0 +1,2 @@
1
+ import { UseAllocateCouponProps, UseAllocateCouponResult } from '../types';
2
+ export declare const useAllocateCoupon: (props: UseAllocateCouponProps) => UseAllocateCouponResult;
@@ -0,0 +1,231 @@
1
+ // Libraries
2
+ import { useCallback, useMemo } from 'react';
3
+ import { useStore } from 'zustand';
4
+ import { useQuery } from '@tanstack/react-query';
5
+ import uniqueId from 'lodash/uniqueId';
6
+ // Hooks
7
+ import { useDeepCompareEffect } from '@antscorp/antsomi-ui/es/hooks';
8
+ // Locales
9
+ import i18nInstance from '@antscorp/antsomi-ui/es/locales/i18n';
10
+ import { translations } from '@antscorp/antsomi-ui/es/locales/translations';
11
+ // Constants
12
+ import { CALC_METHOD, FALLBACK_MODE, GET_DATA_FROM, IDENTIFIER_OPTIONS, QUANTITY_MODE, } from '../constants';
13
+ // Utils
14
+ import { buildSourceEventKey, formatPoolIdentityList, fromAllocateCouponSettings, toAllocateCouponSettings, validateAllocateCouponSettings, } from '../utils';
15
+ // Hooks (private store plumbing — creates its own separate store instance, never shared with
16
+ // `Root`'s internal store; the two stay decoupled per the headless-component-pattern rule)
17
+ import { useAllocateCouponStore } from './useAllocateCouponStore';
18
+ // Hooks (private — resolves the merged event+BO attribute options shared by Quantity/Conditions)
19
+ import { useAllocateCouponAttributeOptions } from './useAllocateCouponAttributeOptions';
20
+ /**
21
+ * The headless business hook for the Allocate Coupon settings panel. Owns UI/selection state;
22
+ * all 5 data fetches (`getSourceEvents`, `getListPromotionPool`, `getPromotionPoolDetail`,
23
+ * `getListEventAttr`, `getListAttributeBO`) are required consumer-supplied query configs — this hook never knows
24
+ * about URLs, auth, or antsomi-ui's own services. It only merges in the internal `enabled`
25
+ * gating each fetch needs (e.g. don't fetch event attrs until a source event is selected) and
26
+ * hands the result to a generic `useQuery`. Never imports the presentational `AllocateCoupon`
27
+ * component — wiring happens at the consumer.
28
+ */
29
+ const { t } = i18nInstance;
30
+ export const useAllocateCoupon = (props) => {
31
+ const { getSourceEvents, getListPromotionPool, getPromotionPoolDetail, getListEventAttr, getListAttributeBO, initialData, onChange, showIdentifierField = false, getExtraValidationErrors, } = props;
32
+ // Hydrate once from `initialData` (edit mode) — not re-synced on later `initialData` changes.
33
+ // eslint-disable-next-line react-hooks/exhaustive-deps
34
+ const hydrated = useMemo(() => fromAllocateCouponSettings(initialData), []);
35
+ // Owns the user/selection-editable state (`pool.selectedId`, `quantity.*`, `conditions.items`,
36
+ // `identifier.value`, `sourceEvent.{list,selectedKey}`). `onChange` fires from inside the
37
+ // store's setter actions, action-attributably, only when the serialized settings actually
38
+ // change — see `stores/index.ts`'s `notifyIfChanged`.
39
+ const store = useAllocateCouponStore(hydrated, onChange);
40
+ const poolId = useStore(store, s => s.pool.selectedId);
41
+ const quantityMode = useStore(store, s => s.quantity.mode);
42
+ const fixedValue = useStore(store, s => s.quantity.fixedValue);
43
+ const calcMethod = useStore(store, s => s.quantity.calcMethod);
44
+ const quantityField = useStore(store, s => s.quantity.field);
45
+ const fallback = useStore(store, s => s.quantity.fallback);
46
+ const conditionItems = useStore(store, s => s.conditions.items);
47
+ const selectedSourceEventKey = useStore(store, s => s.sourceEvent.selectedKey);
48
+ const identifierValue = useStore(store, s => s.identifier.value);
49
+ const setPool = useStore(store, s => s.setPool);
50
+ const setQuantity = useStore(store, s => s.setQuantity);
51
+ const setSourceEvent = useStore(store, s => s.setSourceEvent);
52
+ const setConditions = useStore(store, s => s.setConditions);
53
+ const setIdentifier = useStore(store, s => s.setIdentifier);
54
+ /* Promotion Pool — the consumer's query already resolves to `AllocateCouponPoolOption[]`, so
55
+ no local re-shaping is needed. Fetched metadata (options/loading/error/helpText) is derived
56
+ locally, never pushed into the store — the store only holds the user-editable `selectedId`. */
57
+ const { data: poolOptions = [], isLoading: isPoolLoading, isFetching: isPoolFetching, error: poolError, refetch: refetchPool, } = useQuery(getListPromotionPool());
58
+ /* Selected pool's detail (in particular `restrictionType`) — kept as its own query, gated on
59
+ a pool actually being selected, so the consumer never has to resolve detail for every listed
60
+ pool up front just to show one help text. */
61
+ const poolDetailConfig = getPromotionPoolDetail({ poolId: poolId ?? undefined });
62
+ const isPoolDetailEnabled = !!poolId && (poolDetailConfig.enabled ?? true);
63
+ const { data: poolDetail, isFetching: isPoolDetailFetching, refetch: refetchPoolDetail, } = useQuery({
64
+ ...poolDetailConfig,
65
+ enabled: isPoolDetailEnabled,
66
+ });
67
+ // allocationTypeLabels is the pool's own restriction scope, not the journey Identifier field.
68
+ const poolHelpText = useMemo(() => {
69
+ if (!poolDetail?.restrictionType)
70
+ return undefined;
71
+ if (poolDetail.restrictionType !== 'unique') {
72
+ return t(translations.allocateCoupon.poolHelpText.multiple);
73
+ }
74
+ const identityList = formatPoolIdentityList(poolDetail.allocationTypeLabels, t(translations.allocateCoupon.poolHelpText.identityListJoiner));
75
+ return identityList
76
+ ? t(translations.allocateCoupon.poolHelpText.unique, { identityList })
77
+ : t(translations.allocateCoupon.poolHelpText.uniqueDefault);
78
+ }, [poolDetail]);
79
+ /* Source Event resolution — the one thing antsomi-ui cannot derive itself */
80
+ const { data: sourceEventList = [], isLoading: isSourceEventLoading, isFetching: isSourceEventFetching, error: sourceEventError, refetch: refetchSourceEvents, } = useQuery(getSourceEvents());
81
+ // `sourceEvent.list` is mirrored into the store (unlike other query metadata) because the
82
+ // store's own `toAllocateCouponSettings(get())` needs it to resolve `selectedKey` into
83
+ // `{eventActionId, eventCategoryId}`. The auto-select-first-event update rides along in the
84
+ // same call so the store's notify mechanism sees one consistent snapshot, not two partial ones.
85
+ useDeepCompareEffect(() => {
86
+ setSourceEvent({
87
+ list: sourceEventList,
88
+ ...(!selectedSourceEventKey && sourceEventList.length
89
+ ? { selectedKey: buildSourceEventKey(sourceEventList[0]) }
90
+ : null),
91
+ });
92
+ }, [sourceEventList, selectedSourceEventKey, setSourceEvent]);
93
+ const selectedSourceEvent = useMemo(() => sourceEventList.find(ref => buildSourceEventKey(ref) === selectedSourceEventKey), [sourceEventList, selectedSourceEventKey]);
94
+ /* Event attributes → Quantity-field / Condition options. Which source ids to scope this to
95
+ is entirely the consumer's concern now (typically resolved from
96
+ `selectedSourceEvent.additionalKey`) — antsomi-ui only forwards `selectedEvent`. See
97
+ `useAllocateCouponAttributeOptions` for how the 2 dependent queries (event attrs, then
98
+ Business Object attrs) resolve into one merged `fieldOptions` list. */
99
+ const { fieldOptions, isLoading: isFieldOptionsLoading, error: fieldOptionsError, isFetching: isFieldOptionsFetching, refetch: refetchFieldOptions, } = useAllocateCouponAttributeOptions({
100
+ selectedEvent: selectedSourceEvent,
101
+ getListEventAttr,
102
+ getListAttributeBO,
103
+ });
104
+ const onAddCondition = () => {
105
+ const newItem = {
106
+ id: uniqueId('allocate-coupon-condition_'),
107
+ field: null,
108
+ operator: null,
109
+ value: null,
110
+ getDataFrom: GET_DATA_FROM.EVENT,
111
+ };
112
+ setConditions({ items: [...conditionItems, newItem] });
113
+ };
114
+ const onChangeCondition = (id, patch) => {
115
+ setConditions({
116
+ items: conditionItems.map(item => (item.id === id ? { ...item, ...patch } : item)),
117
+ });
118
+ };
119
+ const onRemoveCondition = (id) => {
120
+ setConditions({ items: conditionItems.filter(item => item.id !== id) });
121
+ };
122
+ /* Manual refresh — re-runs every currently-relevant query at once. Pool/source-events have no
123
+ precondition, so they always refetch; pool detail is guarded by its own `enabled` gate
124
+ (TanStack Query v4's `refetch()` ignores `enabled` and would otherwise fire a request whose
125
+ precondition isn't actually met yet) — `refetchFieldOptions` applies the same gating
126
+ internally for its own 2 underlying queries. */
127
+ const onRefresh = useCallback(() => {
128
+ const tasks = [refetchPool(), refetchSourceEvents(), refetchFieldOptions()];
129
+ if (isPoolDetailEnabled)
130
+ tasks.push(refetchPoolDetail());
131
+ return Promise.all(tasks);
132
+ }, [
133
+ refetchPool,
134
+ refetchSourceEvents,
135
+ refetchPoolDetail,
136
+ refetchFieldOptions,
137
+ isPoolDetailEnabled,
138
+ ]);
139
+ const isRefreshing = isPoolFetching ||
140
+ isSourceEventFetching ||
141
+ (isPoolDetailEnabled && isPoolDetailFetching) ||
142
+ isFieldOptionsFetching;
143
+ const actions = useMemo(() => ({
144
+ reset: () => {
145
+ // One bulk `setState` call, not five separate setters — a setter-per-call reset would
146
+ // fire `onChange` up to 5x with intermediate half-reset snapshots instead of once with
147
+ // the final reset settings.
148
+ store.getState().setState({
149
+ pool: { selectedId: null },
150
+ quantity: {
151
+ mode: QUANTITY_MODE.FIXED,
152
+ fixedValue: null,
153
+ calcMethod: CALC_METHOD.SUM,
154
+ field: null,
155
+ fallback: { mode: FALLBACK_MODE.END_JOURNEY, fixedValue: null },
156
+ },
157
+ conditions: { items: [] },
158
+ sourceEvent: { selectedKey: null },
159
+ identifier: { value: null },
160
+ });
161
+ },
162
+ getSettings: () => toAllocateCouponSettings(store.getState()),
163
+ // Delegates the built-in rules to `validateAllocateCouponSettings` -- the same pure
164
+ // function a consumer can call directly against persisted data without this hook
165
+ // mounted (see that function's own doc comment). `getExtraValidationErrors` receives
166
+ // `defaultErrors` alongside `settings` so a consumer never has to re-import/re-call
167
+ // the base validator itself just to layer on an app-specific rule; the merge stays
168
+ // additive here (base spread first) so an extra validator can never accidentally wipe
169
+ // out a built-in error by returning `{}`.
170
+ validate: () => {
171
+ const settings = toAllocateCouponSettings(store.getState());
172
+ const { errors: defaultErrors } = validateAllocateCouponSettings(settings);
173
+ const extraErrors = getExtraValidationErrors?.({ settings, defaultErrors }) ?? {};
174
+ const errors = { ...defaultErrors, ...extraErrors };
175
+ return { valid: Object.keys(errors).length === 0, errors };
176
+ },
177
+ }), [store, getExtraValidationErrors]);
178
+ return {
179
+ pool: {
180
+ selectedId: poolId,
181
+ options: poolOptions,
182
+ isLoading: isPoolLoading,
183
+ error: poolError,
184
+ helpText: poolHelpText,
185
+ onSelect: id => setPool({ selectedId: id }),
186
+ },
187
+ quantity: {
188
+ mode: quantityMode,
189
+ fixedValue,
190
+ calcMethod,
191
+ field: quantityField,
192
+ fieldOptions,
193
+ isFieldOptionsLoading,
194
+ fieldOptionsError,
195
+ fallback,
196
+ onChangeMode: mode => setQuantity({ mode }),
197
+ onChangeFixedValue: value => setQuantity({ fixedValue: value }),
198
+ onChangeCalcMethod: method => setQuantity({ calcMethod: method }),
199
+ onChangeField: field => setQuantity({ field }),
200
+ onChangeFallbackMode: mode => setQuantity({ fallback: { ...fallback, mode } }),
201
+ onChangeFallbackFixedValue: value => setQuantity({ fallback: { ...fallback, fixedValue: value } }),
202
+ },
203
+ sourceEvent: {
204
+ list: sourceEventList,
205
+ selectedKey: selectedSourceEventKey,
206
+ isLoading: isSourceEventLoading,
207
+ error: sourceEventError,
208
+ onSelect: key => setSourceEvent({ selectedKey: key }),
209
+ },
210
+ conditions: {
211
+ items: conditionItems,
212
+ fieldOptions,
213
+ isFieldOptionsLoading,
214
+ fieldOptionsError,
215
+ onAddCondition,
216
+ onChangeCondition,
217
+ onRemoveCondition,
218
+ },
219
+ identifier: {
220
+ value: identifierValue,
221
+ visible: showIdentifierField,
222
+ options: IDENTIFIER_OPTIONS,
223
+ onChange: value => setIdentifier({ value }),
224
+ },
225
+ refresh: {
226
+ isRefreshing,
227
+ onRefresh,
228
+ },
229
+ actions,
230
+ };
231
+ };