@flatbiz/antd 4.5.41 → 4.5.43

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 (219) hide show
  1. package/esm/_rollupPluginBabelHelpers-c0dbec57.js +3 -0
  2. package/esm/_rollupPluginBabelHelpers-c0dbec57.js.map +1 -0
  3. package/esm/ace-editor-groovy/index.js +1 -1
  4. package/esm/ace-editor-groovy/index.js.map +1 -1
  5. package/esm/ace-editor-java/index.js +1 -1
  6. package/esm/ace-editor-java/index.js.map +1 -1
  7. package/esm/ace-editor-json/index.js +1 -1
  8. package/esm/ace-editor-json/index.js.map +1 -1
  9. package/esm/ace-editor-mysql/index.js +1 -1
  10. package/esm/ace-editor-mysql/index.js.map +1 -1
  11. package/esm/ace-editor-xml/index.js +1 -1
  12. package/esm/ace-editor-xml/index.js.map +1 -1
  13. package/esm/alert-wrapper/index.js +1 -1
  14. package/esm/amount-fen-input/index.js +1 -1
  15. package/esm/amount-fen-input/index.js.map +1 -1
  16. package/esm/amount-fen-input-form-item/index.js +1 -1
  17. package/esm/anchor-steps/index.js +1 -1
  18. package/esm/anchor-steps/index.js.map +1 -1
  19. package/esm/block-layout/index.js +1 -1
  20. package/esm/bootstrap/index.js +1 -1
  21. package/esm/box-grid/index.js +1 -1
  22. package/esm/box-grid/index.js.map +1 -1
  23. package/esm/button-operate/index.js +1 -1
  24. package/esm/button-operate/index.js.map +1 -1
  25. package/esm/button-wrapper/index.js +1 -1
  26. package/esm/card-layout/index.js +1 -1
  27. package/esm/card-wrapper/index.js +1 -1
  28. package/esm/cascader-wrapper/index.js +1 -1
  29. package/esm/cascader-wrapper/index.js.map +1 -1
  30. package/esm/check-list/index.js +1 -1
  31. package/esm/check-list/index.js.map +1 -1
  32. package/esm/checkbox-wrapper/index.js +1 -1
  33. package/esm/checkbox-wrapper/index.js.map +1 -1
  34. package/esm/color-picker-wrapper/index.js +1 -1
  35. package/esm/color-picker-wrapper/index.js.map +1 -1
  36. package/esm/config-provider-wrapper/index.js +1 -1
  37. package/esm/create-drawer-wrapper-model/index.js.map +1 -1
  38. package/esm/create-modal-wrapper-model/index.js.map +1 -1
  39. package/esm/css-node-hover/index.js +1 -1
  40. package/esm/date-picker-wrapper/index.js +1 -1
  41. package/esm/date-picker-wrapper/index.js.map +1 -1
  42. package/esm/date-range-picker-wrapper/index.js +1 -1
  43. package/esm/date-range-picker-wrapper/index.js.map +1 -1
  44. package/esm/date-range-picker-wrapper-form-item/index.js +1 -1
  45. package/esm/date-range-picker-wrapper-form-item/index.js.map +1 -1
  46. package/esm/delete-node/index.js +1 -1
  47. package/esm/dialog-alert/index.js +1 -1
  48. package/esm/dialog-alert/index.js.map +1 -1
  49. package/esm/dialog-confirm/index.js +1 -1
  50. package/esm/dialog-confirm/index.js.map +1 -1
  51. package/esm/dialog-drawer/index.js +1 -1
  52. package/esm/dialog-drawer/index.js.map +1 -1
  53. package/esm/dialog-drawer-content/index.js +1 -1
  54. package/esm/dialog-loading/index.js +1 -1
  55. package/esm/dialog-loading/index.js.map +1 -1
  56. package/esm/dialog-modal/index.js +1 -1
  57. package/esm/dialog-modal/index.js.map +1 -1
  58. package/esm/dialog-preview-image/index.js +1 -1
  59. package/esm/dialog-preview-image/index.js.map +1 -1
  60. package/esm/drag-collapse/index.js +1 -1
  61. package/esm/drag-collapse/index.js.map +1 -1
  62. package/esm/drag-collapse-form-list/index.js +1 -1
  63. package/esm/drag-collapse-form-list/index.js.map +1 -1
  64. package/esm/drag-editable-card/index.js +1 -1
  65. package/esm/drag-editable-card/index.js.map +1 -1
  66. package/esm/drag-editable-table/index.js +1 -1
  67. package/esm/drag-editable-table/index.js.map +1 -1
  68. package/esm/drag-editable-table-pro/index.js +1 -1
  69. package/esm/drag-editable-table-pro/index.js.map +1 -1
  70. package/esm/drag-form-list/index.js +1 -1
  71. package/esm/drag-form-list/index.js.map +1 -1
  72. package/esm/drag-table/index.js +1 -1
  73. package/esm/drag-table/index.js.map +1 -1
  74. package/esm/drawer-wrapper/index.js +1 -1
  75. package/esm/dropdown-menu-wrapper/index.js +1 -1
  76. package/esm/dynamic-node/index.js +1 -1
  77. package/esm/dynamic-node/index.js.map +1 -1
  78. package/esm/easy-form/index.js +1 -1
  79. package/esm/easy-table/index.css +1 -1
  80. package/esm/easy-table/index.js +1 -1
  81. package/esm/easy-table/index.js.map +1 -1
  82. package/esm/editable-card/index.js +1 -1
  83. package/esm/editable-card/index.js.map +1 -1
  84. package/esm/editable-field/index.js +1 -1
  85. package/esm/editable-field/index.js.map +1 -1
  86. package/esm/editable-table/index.js +1 -1
  87. package/esm/editable-table/index.js.map +1 -1
  88. package/esm/editable-table-pro/index.js +1 -1
  89. package/esm/editable-table-pro/index.js.map +1 -1
  90. package/esm/editor-wrapper/index.js +1 -1
  91. package/esm/editor-wrapper/index.js.map +1 -1
  92. package/esm/error-boundary-wrapper/index.js +1 -1
  93. package/esm/error-boundary-wrapper/index.js.map +1 -1
  94. package/esm/fba-app/index.js +1 -1
  95. package/esm/fba-app/index.js.map +1 -1
  96. package/esm/fba-hooks/index.js +1 -1
  97. package/esm/file-export/index.js +1 -1
  98. package/esm/file-export/index.js.map +1 -1
  99. package/esm/file-import/index.js +1 -1
  100. package/esm/file-select/index.js +1 -1
  101. package/esm/file-select/index.js.map +1 -1
  102. package/esm/flex-layout/index.js +1 -1
  103. package/esm/form-grid/index.js +1 -1
  104. package/esm/form-item-group/index.js +1 -1
  105. package/esm/form-item-span/index.js +1 -1
  106. package/esm/form-item-text/index.js +1 -1
  107. package/esm/form-item-text/index.js.map +1 -1
  108. package/esm/form-item-wrapper/index.js +1 -1
  109. package/esm/form-item-wrapper/index.js.map +1 -1
  110. package/esm/form-item-wrapper-dependencies/index.js +1 -1
  111. package/esm/form-list-wrapper/index.js +1 -1
  112. package/esm/form-list-wrapper/index.js.map +1 -1
  113. package/esm/form-wrapper/index.js +1 -1
  114. package/esm/gap/index.js +1 -1
  115. package/esm/icon-wrapper/index.css +1 -1
  116. package/esm/icon-wrapper/index.js +1 -1
  117. package/esm/icon-wrapper/index.js.map +1 -1
  118. package/esm/{index-7f4ad045.js → index-83bede1b.js} +2 -2
  119. package/esm/{index-7f4ad045.js.map → index-83bede1b.js.map} +1 -1
  120. package/esm/index.js +1 -1
  121. package/esm/input-search-wrapper/index.js +1 -1
  122. package/esm/input-search-wrapper/index.js.map +1 -1
  123. package/esm/input-text-area-wrapper/index.js +1 -1
  124. package/esm/input-text-area-wrapper/index.js.map +1 -1
  125. package/esm/input-wrapper/index.js +1 -1
  126. package/esm/input-wrapper/index.js.map +1 -1
  127. package/esm/json-editor/index.js +1 -1
  128. package/esm/json-editor/index.js.map +1 -1
  129. package/esm/label-value-layout/index.js +1 -1
  130. package/esm/label-value-render/index.js +1 -1
  131. package/esm/label-value-render/index.js.map +1 -1
  132. package/esm/local-loading/index.js +1 -1
  133. package/esm/local-loading/index.js.map +1 -1
  134. package/esm/mention-editor/index.js +1 -1
  135. package/esm/mention-editor/index.js.map +1 -1
  136. package/esm/mentions-wrapper/index.js +1 -1
  137. package/esm/mentions-wrapper/index.js.map +1 -1
  138. package/esm/modal-action/index.js +1 -1
  139. package/esm/modal-wrapper/index.js +1 -1
  140. package/esm/number-range-form-item/index.js +1 -1
  141. package/esm/number-range-form-item/index.js.map +1 -1
  142. package/esm/pagination-wrapper/index.js +1 -1
  143. package/esm/pdf/index.js +1 -1
  144. package/esm/pdf/index.js.map +1 -1
  145. package/esm/pdf-preview/index.js +1 -1
  146. package/esm/pdf-preview/index.js.map +1 -1
  147. package/esm/radio-group-wrapper/index.js +1 -1
  148. package/esm/radio-group-wrapper/index.js.map +1 -1
  149. package/esm/relation-tree/index.js +1 -1
  150. package/esm/relation-tree/index.js.map +1 -1
  151. package/esm/rich-text-editor/index.js +1 -1
  152. package/esm/rich-text-editor/index.js.map +1 -1
  153. package/esm/rich-text-viewer/index.js +1 -1
  154. package/esm/rich-text-viewer/index.js.map +1 -1
  155. package/esm/roll-location-center/index.js +1 -1
  156. package/esm/roll-location-center/index.js.map +1 -1
  157. package/esm/roll-location-in-view/index.js +1 -1
  158. package/esm/roll-location-in-view/index.js.map +1 -1
  159. package/esm/rule-describe/index.js +1 -1
  160. package/esm/search-form/index.js +1 -1
  161. package/esm/search-form/index.js.map +1 -1
  162. package/esm/search-menu/index.js +1 -1
  163. package/esm/search-menu/index.js.map +1 -1
  164. package/esm/selector-wrapper/index.js +1 -1
  165. package/esm/selector-wrapper/index.js.map +1 -1
  166. package/esm/selector-wrapper-search/index.js +1 -1
  167. package/esm/selector-wrapper-search/index.js.map +1 -1
  168. package/esm/selector-wrapper-simple/index.js +1 -1
  169. package/esm/selector-wrapper-simple/index.js.map +1 -1
  170. package/esm/simple-layout/index.js +1 -1
  171. package/esm/sms-count-down/index.js +1 -1
  172. package/esm/sms-count-down/index.js.map +1 -1
  173. package/esm/split-wrapper/index.js +1 -1
  174. package/esm/svg-http-view/index.js +1 -1
  175. package/esm/switch-confirm-wrapper/index.js +1 -1
  176. package/esm/switch-confirm-wrapper/index.js.map +1 -1
  177. package/esm/switch-wrapper/index.js +1 -1
  178. package/esm/switch-wrapper/index.js.map +1 -1
  179. package/esm/table-cell-render/index.js +1 -1
  180. package/esm/table-scrollbar/index.js +1 -1
  181. package/esm/table-scrollbar/index.js.map +1 -1
  182. package/esm/tabs-sticky/index.js +1 -1
  183. package/esm/tabs-sticky/index.js.map +1 -1
  184. package/esm/tabs-wrapper/index.js +1 -1
  185. package/esm/tabs-wrapper/index.js.map +1 -1
  186. package/esm/tag-group/index.js +1 -1
  187. package/esm/tag-list-render/index.js +1 -1
  188. package/esm/tag-list-render/index.js.map +1 -1
  189. package/esm/tag-wrapper/index.js +1 -1
  190. package/esm/text-css-ellipsis/index.js +1 -1
  191. package/esm/text-css-ellipsis/index.js.map +1 -1
  192. package/esm/text-overflow/index.js +1 -1
  193. package/esm/text-overflow-render/index.js +1 -1
  194. package/esm/text-symbol-wrapper/index.js +1 -1
  195. package/esm/time-picker-wrapper/index.js +1 -1
  196. package/esm/time-picker-wrapper/index.js.map +1 -1
  197. package/esm/time-range-picker-wrapper/index.js +1 -1
  198. package/esm/time-range-picker-wrapper/index.js.map +1 -1
  199. package/esm/time-range-picker-wrapper-form-item/index.js +1 -1
  200. package/esm/time-range-picker-wrapper-form-item/index.js.map +1 -1
  201. package/esm/tips-title/index.js +1 -1
  202. package/esm/tips-wrapper/index.js +1 -1
  203. package/esm/tree-modal/index.js +1 -1
  204. package/esm/tree-modal/index.js.map +1 -1
  205. package/esm/tree-modal-selector/index.js +1 -1
  206. package/esm/tree-modal-selector/index.js.map +1 -1
  207. package/esm/tree-selector-wrapper/index.js +1 -1
  208. package/esm/tree-selector-wrapper/index.js.map +1 -1
  209. package/esm/tree-wrapper/index.css +1 -1
  210. package/esm/tree-wrapper/index.js +1 -1
  211. package/esm/tree-wrapper/index.js.map +1 -1
  212. package/esm/upload-wrapper/index.js +1 -1
  213. package/esm/upload-wrapper/index.js.map +1 -1
  214. package/esm/x-mind-preview/index.js +1 -1
  215. package/esm/x-mind-preview/index.js.map +1 -1
  216. package/index.d.ts +74 -63
  217. package/package.json +1 -1
  218. package/esm/_rollupPluginBabelHelpers-a0769acd.js +0 -3
  219. package/esm/_rollupPluginBabelHelpers-a0769acd.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable */
2
2
  import './index.css';
3
3
  /*! @flatjs/forge MIT @flatbiz/antd */
4
- import{a as e,_ as r}from"../_rollupPluginBabelHelpers-a0769acd.js";import{hooks as i}from"@wove/react/cjs/hooks";import{flatbizDate as t}from"@flatbiz/utils";import{DatePicker as a}from"antd";import n from"dayjs";import{useMemo as o}from"react";import{D as u,g as s,a as f,b as l}from"../time-53b3f55f.js";import{jsx as d}from"react/jsx-runtime";var m=["value","onChange","style","format","outputNormalize","inputNormalize"];var v=function v(c){var b=c.value,D=c.onChange,p=c.style,h=c.format,M=c.outputNormalize,g=c.inputNormalize,w=e(c,m);var T=c.disabledDateConfig||{},C=T.minDate,H=T.maxDate,Y=T.disabledHourList,z=T.disabledMinuteList,L=T.disabledSecondList;var j=C?n(C):undefined;var N=H?n(H):undefined;var k=o((function(){if(h)return h;if(c.showTime)return u.YMDHms;return u.YMD}),[c.showTime,h]);var x=i.useCallbackRef((function(e,r){if(e){if(M){D==null?void 0:D(M(r))}else{D==null?void 0:D(r)}}else{D==null?void 0:D(undefined)}}));var y=i.useCallbackRef((function(e){var r=e.format(u.YMD);if(!c.disabledDateConfig){return false}if(j&&N){if(!t.in(r,j.format(u.YMD),N.format(u.YMD))){return true}}else if(j){if(!t.gte(r,j.format(u.YMD))){return true}}else if(N){if(!t.gte(N.format(u.YMD),r)){return true}}return false}));var R=o((function(){if(b){var e=g?g(b):b;if(e){return n(t.dateNormalize(e))}}return undefined}),[b]);var S=i.useCallbackRef((function(e){var r={minDateTime:j,maxDateTime:N,disabledHourList:Y,disabledMinuteList:z,disabledSecondList:L};e=e||R||n(new Date);return{disabledHours:function i(){return s(e,r)},disabledMinutes:function i(){return f(e,r)},disabledSeconds:function i(){return l(e,r)}}}));var _=o((function(){if(c.showTime)return c.showTime;if(k&&k.includes("HH")){return true}return false}),[c.showTime,k]);return d(a,r({disabledDate:y,disabledTime:S},w,{showTime:_,format:k,style:r({width:"100%"},p),value:R,onChange:x}))};export{v as DatePickerWrapper};
4
+ import{a as e,_ as r}from"../_rollupPluginBabelHelpers-c0dbec57.js";import{hooks as i}from"@wove/react/cjs/hooks";import{flatbizDate as t}from"@flatbiz/utils";import{DatePicker as a}from"antd";import n from"dayjs";import{useMemo as o}from"react";import{D as u,g as s,a as f,b as l}from"../time-53b3f55f.js";import{jsx as m}from"react/jsx-runtime";var d=["value","onChange","style","format","outputNormalize","inputNormalize"];var c=function c(b){var v=b.value,D=b.onChange,p=b.style,h=b.format,M=b.outputNormalize,g=b.inputNormalize,w=e(b,d);var T=b.disabledDateConfig||{},C=T.minDate,H=T.maxDate,Y=T.disabledHourList,z=T.disabledMinuteList,L=T.disabledSecondList;var j=C?n(C):undefined;var N=H?n(H):undefined;var k=o((function(){if(h)return h;if(b.showTime)return u.YMDHms;return u.YMD}),[b.showTime,h]);var x=i.useCallbackRef((function(e,r){if(e){if(M){D==null||D(M(r))}else{D==null||D(r)}}else{D==null||D(undefined)}}));var y=i.useCallbackRef((function(e){var r=e.format(u.YMD);if(!b.disabledDateConfig){return false}if(j&&N){if(!t.in(r,j.format(u.YMD),N.format(u.YMD))){return true}}else if(j){if(!t.gte(r,j.format(u.YMD))){return true}}else if(N){if(!t.gte(N.format(u.YMD),r)){return true}}return false}));var R=o((function(){if(v){var e=g?g(v):v;if(e){return n(t.dateNormalize(e))}}return undefined}),[v]);var S=i.useCallbackRef((function(e){var r={minDateTime:j,maxDateTime:N,disabledHourList:Y,disabledMinuteList:z,disabledSecondList:L};e=e||R||n(new Date);return{disabledHours:function i(){return s(e,r)},disabledMinutes:function i(){return f(e,r)},disabledSeconds:function i(){return l(e,r)}}}));var _=o((function(){if(b.showTime)return b.showTime;if(k&&k.includes("HH")){return true}return false}),[b.showTime,k]);return m(a,r({disabledDate:y,disabledTime:S},w,{showTime:_,format:k,style:r({width:"100%"},p),value:R,onChange:x}))};export{c as DatePickerWrapper};
5
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["@flatbiz/antd/src/date-picker-wrapper/date-picker-wrapper.tsx"],"sourcesContent":["import { flatbizDate, TAny } from '@flatbiz/utils';\nimport { hooks } from '@wove/react';\nimport { DatePicker } from 'antd';\nimport type { PickerDateProps } from 'antd/es/date-picker/generatePicker';\nimport dayjs from 'dayjs';\nimport { useMemo } from 'react';\nimport { DayjsDateTypeEnum, TDayjsDateType } from '../_utils/constants';\nimport { getDisabledHour, getDisabledMinute, getDisabledSecond } from '../_utils/time';\n\nexport type DatePickerWrapperProps = Omit<PickerDateProps<TAny>, 'value' | 'onChange' | 'format'> & {\n /** 默认格式为 'YYYY-MM-DD' */\n value?: string;\n onChange?: (value?: string) => void;\n disabledDateConfig?: {\n minDate?: TDayjsDateType;\n maxDate?: TDayjsDateType;\n /** 禁用 小时 刻度列表,与日期无关 */\n disabledHourList?: number[];\n /** 禁用 分钟 刻度列表,与日期无关 */\n disabledMinuteList?: number[];\n /** 禁用 秒钟 刻度列表,与日期无关 */\n disabledSecondList?: number[];\n };\n /** 可自定义格式 */\n format?: TDayjsDateType;\n /** value 输出适配 */\n outputNormalize?: (value?: TAny) => TAny;\n /** value 输入适配 */\n inputNormalize?: (value?: TAny) => string | undefined;\n};\n\n/**\n * DatePicker包装组件\n * ```\n * 1. value 默认格式为 'YYYY-MM-DD',可以通过 inputNormalize 来进行自定义转换\n * 2. onChange返回类型 string,可以通过 outputNormalize 来进行自定义转换\n * 3. 默认格式化类型 YYYY-MM-DD; 当showTime===true时,默认格式化类型 DayjsDateTypeEnum.YMDHms;其他格式化类型自定义format\n * 4. 设置 disabledDate 后,disabledDateConfig配置将失效\n * 5. 设置 disabledTime 后,内置的disabledTime逻辑将失效\n * ```\n */\nexport const DatePickerWrapper = (props: DatePickerWrapperProps) => {\n const { value, onChange, style, format, outputNormalize, inputNormalize, ...otherProps } = props;\n const { minDate, maxDate, disabledHourList, disabledMinuteList, disabledSecondList } =\n props.disabledDateConfig || {};\n const minDateTimeDayInst = minDate ? dayjs(minDate) : undefined;\n const maxDateTimeDayInst = maxDate ? dayjs(maxDate) : undefined;\n const customFormat = useMemo(() => {\n if (format) return format as string;\n if (props.showTime) return DayjsDateTypeEnum.YMDHms;\n return DayjsDateTypeEnum.YMD;\n }, [props.showTime, format]);\n\n const onChangeDate = hooks.useCallbackRef((date, dateString: string) => {\n if (date) {\n if (outputNormalize) {\n onChange?.(outputNormalize(dateString));\n } else {\n onChange?.(dateString);\n }\n } else {\n onChange?.(undefined);\n }\n });\n\n const getDisabledDate = hooks.useCallbackRef((current) => {\n const currentDate = current.format(DayjsDateTypeEnum.YMD);\n if (!props.disabledDateConfig) {\n return false;\n }\n if (minDateTimeDayInst && maxDateTimeDayInst) {\n if (\n !flatbizDate.in(\n currentDate,\n minDateTimeDayInst.format(DayjsDateTypeEnum.YMD),\n maxDateTimeDayInst.format(DayjsDateTypeEnum.YMD),\n )\n ) {\n return true;\n }\n } else if (minDateTimeDayInst) {\n if (!flatbizDate.gte(currentDate, minDateTimeDayInst.format(DayjsDateTypeEnum.YMD))) {\n return true;\n }\n } else if (maxDateTimeDayInst) {\n if (!flatbizDate.gte(maxDateTimeDayInst.format(DayjsDateTypeEnum.YMD), currentDate)) {\n return true;\n }\n }\n return false;\n });\n\n const datePickerValue = useMemo(() => {\n if (value) {\n const valueFt = inputNormalize ? inputNormalize(value) : value;\n if (valueFt) {\n return dayjs(flatbizDate.dateNormalize(valueFt));\n }\n }\n return undefined;\n }, [value]);\n\n const getDisabledTime = hooks.useCallbackRef((current) => {\n const options = {\n minDateTime: minDateTimeDayInst,\n maxDateTime: maxDateTimeDayInst,\n disabledHourList,\n disabledMinuteList,\n disabledSecondList,\n };\n current = current || datePickerValue || dayjs(new Date());\n return {\n disabledHours: () => {\n return getDisabledHour(current, options);\n },\n disabledMinutes: () => {\n return getDisabledMinute(current, options);\n },\n disabledSeconds: () => {\n return getDisabledSecond(current, options);\n },\n };\n });\n\n const showTime = useMemo(() => {\n if (props.showTime) return props.showTime;\n if (customFormat && customFormat.includes('HH')) {\n return true;\n }\n return false;\n }, [props.showTime, customFormat]);\n\n return (\n <DatePicker\n disabledDate={getDisabledDate}\n disabledTime={getDisabledTime}\n {...otherProps}\n showTime={showTime}\n format={customFormat}\n style={{ width: '100%', ...style }}\n value={datePickerValue}\n onChange={onChangeDate}\n />\n );\n};\n"],"names":["DatePickerWrapper","props","value","onChange","style","format","outputNormalize","inputNormalize","otherProps","_objectWithoutPropertiesLoose","_excluded","_ref","disabledDateConfig","minDate","maxDate","disabledHourList","disabledMinuteList","disabledSecondList","minDateTimeDayInst","dayjs","undefined","maxDateTimeDayInst","customFormat","useMemo","showTime","DayjsDateTypeEnum","YMDHms","YMD","onChangeDate","_hooks","useCallbackRef","date","dateString","getDisabledDate","current","currentDate","flatbizDate","in","gte","datePickerValue","valueFt","dateNormalize","getDisabledTime","options","minDateTime","maxDateTime","Date","disabledHours","getDisabledHour","disabledMinutes","getDisabledMinute","disabledSeconds","getDisabledSecond","includes","_jsx","DatePicker","_extends","disabledDate","disabledTime","width"],"mappings":";8aAyCaA,EAAoB,SAApBA,EAAqBC,GAChC,IAAQC,EAAmFD,EAAnFC,MAAOC,EAA4EF,EAA5EE,SAAUC,EAAkEH,EAAlEG,MAAOC,EAA2DJ,EAA3DI,OAAQC,EAAmDL,EAAnDK,gBAAiBC,EAAkCN,EAAlCM,eAAmBC,EAAUC,EAAKR,EAAKS,GAChG,IAAAC,EACEV,EAAMW,oBAAsB,CAAE,EADxBC,EAAOF,EAAPE,QAASC,EAAOH,EAAPG,QAASC,EAAgBJ,EAAhBI,iBAAkBC,EAAkBL,EAAlBK,mBAAoBC,EAAkBN,EAAlBM,mBAEhE,IAAMC,EAAqBL,EAAUM,EAAMN,GAAWO,UACtD,IAAMC,EAAqBP,EAAUK,EAAML,GAAWM,UACtD,IAAME,EAAeC,GAAQ,WAC3B,GAAIlB,EAAQ,OAAOA,EACnB,GAAIJ,EAAMuB,SAAU,OAAOC,EAAkBC,OAC7C,OAAOD,EAAkBE,GAC1B,GAAE,CAAC1B,EAAMuB,SAAUnB,IAEpB,IAAMuB,EAAeC,EAAMC,gBAAe,SAACC,EAAMC,GAC/C,GAAID,EAAM,CACR,GAAIzB,EAAiB,CACnBH,eAAAA,EAAWG,EAAgB0B,GAC7B,KAAO,CACL7B,GAAAA,UAAAA,EAAAA,EAAW6B,EACb,CACF,KAAO,CACL7B,GAAAA,UAAAA,EAAAA,EAAWiB,UACb,CACF,IAEA,IAAMa,EAAkBJ,EAAMC,gBAAe,SAACI,GAC5C,IAAMC,EAAcD,EAAQ7B,OAAOoB,EAAkBE,KACrD,IAAK1B,EAAMW,mBAAoB,CAC7B,OAAO,KACT,CACA,GAAIM,GAAsBG,EAAoB,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IG,MAAO,QAAWvD,GAC3BF,MAAOqC,EACPpC,SAAUyB,IAGhB"}
1
+ {"version":3,"file":"index.js","sources":["@flatbiz/antd/src/date-picker-wrapper/date-picker-wrapper.tsx"],"sourcesContent":["import { flatbizDate, TAny } from '@flatbiz/utils';\nimport { hooks } from '@wove/react';\nimport { DatePicker } from 'antd';\nimport type { PickerDateProps } from 'antd/es/date-picker/generatePicker';\nimport dayjs from 'dayjs';\nimport { useMemo } from 'react';\nimport { DayjsDateTypeEnum, TDayjsDateType } from '../_utils/constants';\nimport { getDisabledHour, getDisabledMinute, getDisabledSecond } from '../_utils/time';\n\nexport type DatePickerWrapperProps = Omit<PickerDateProps<TAny>, 'value' | 'onChange' | 'format'> & {\n /** 默认格式为 'YYYY-MM-DD' */\n value?: string;\n onChange?: (value?: string) => void;\n disabledDateConfig?: {\n minDate?: TDayjsDateType;\n maxDate?: TDayjsDateType;\n /** 禁用 小时 刻度列表,与日期无关 */\n disabledHourList?: number[];\n /** 禁用 分钟 刻度列表,与日期无关 */\n disabledMinuteList?: number[];\n /** 禁用 秒钟 刻度列表,与日期无关 */\n disabledSecondList?: number[];\n };\n /** 可自定义格式 */\n format?: TDayjsDateType;\n /** value 输出适配 */\n outputNormalize?: (value?: TAny) => TAny;\n /** value 输入适配 */\n inputNormalize?: (value?: TAny) => string | undefined;\n};\n\n/**\n * DatePicker包装组件\n * ```\n * 1. value 默认格式为 'YYYY-MM-DD',可以通过 inputNormalize 来进行自定义转换\n * 2. onChange返回类型 string,可以通过 outputNormalize 来进行自定义转换\n * 3. 默认格式化类型 YYYY-MM-DD; 当showTime===true时,默认格式化类型 DayjsDateTypeEnum.YMDHms;其他格式化类型自定义format\n * 4. 设置 disabledDate 后,disabledDateConfig配置将失效\n * 5. 设置 disabledTime 后,内置的disabledTime逻辑将失效\n * ```\n */\nexport const DatePickerWrapper = (props: DatePickerWrapperProps) => {\n const { value, onChange, style, format, outputNormalize, inputNormalize, ...otherProps } = props;\n const { minDate, maxDate, disabledHourList, disabledMinuteList, disabledSecondList } =\n props.disabledDateConfig || {};\n const minDateTimeDayInst = minDate ? dayjs(minDate) : undefined;\n const maxDateTimeDayInst = maxDate ? dayjs(maxDate) : undefined;\n const customFormat = useMemo(() => {\n if (format) return format as string;\n if (props.showTime) return DayjsDateTypeEnum.YMDHms;\n return DayjsDateTypeEnum.YMD;\n }, [props.showTime, format]);\n\n const onChangeDate = hooks.useCallbackRef((date, dateString: string) => {\n if (date) {\n if (outputNormalize) {\n onChange?.(outputNormalize(dateString));\n } else {\n onChange?.(dateString);\n }\n } else {\n onChange?.(undefined);\n }\n });\n\n const getDisabledDate = hooks.useCallbackRef((current) => {\n const currentDate = current.format(DayjsDateTypeEnum.YMD);\n if (!props.disabledDateConfig) {\n return false;\n }\n if (minDateTimeDayInst && maxDateTimeDayInst) {\n if (\n !flatbizDate.in(\n currentDate,\n minDateTimeDayInst.format(DayjsDateTypeEnum.YMD),\n maxDateTimeDayInst.format(DayjsDateTypeEnum.YMD),\n )\n ) {\n return true;\n }\n } else if (minDateTimeDayInst) {\n if (!flatbizDate.gte(currentDate, minDateTimeDayInst.format(DayjsDateTypeEnum.YMD))) {\n return true;\n }\n } else if (maxDateTimeDayInst) {\n if (!flatbizDate.gte(maxDateTimeDayInst.format(DayjsDateTypeEnum.YMD), currentDate)) {\n return true;\n }\n }\n return false;\n });\n\n const datePickerValue = useMemo(() => {\n if (value) {\n const valueFt = inputNormalize ? inputNormalize(value) : value;\n if (valueFt) {\n return dayjs(flatbizDate.dateNormalize(valueFt));\n }\n }\n return undefined;\n }, [value]);\n\n const getDisabledTime = hooks.useCallbackRef((current) => {\n const options = {\n minDateTime: minDateTimeDayInst,\n maxDateTime: maxDateTimeDayInst,\n disabledHourList,\n disabledMinuteList,\n disabledSecondList,\n };\n current = current || datePickerValue || dayjs(new Date());\n return {\n disabledHours: () => {\n return getDisabledHour(current, options);\n },\n disabledMinutes: () => {\n return getDisabledMinute(current, options);\n },\n disabledSeconds: () => {\n return getDisabledSecond(current, options);\n },\n };\n });\n\n const showTime = useMemo(() => {\n if (props.showTime) return props.showTime;\n if (customFormat && customFormat.includes('HH')) {\n return true;\n }\n return false;\n }, [props.showTime, customFormat]);\n\n return (\n <DatePicker\n disabledDate={getDisabledDate}\n disabledTime={getDisabledTime}\n {...otherProps}\n showTime={showTime}\n format={customFormat}\n style={{ width: '100%', ...style }}\n value={datePickerValue}\n onChange={onChangeDate}\n />\n );\n};\n"],"names":["DatePickerWrapper","props","value","onChange","style","format","outputNormalize","inputNormalize","otherProps","_objectWithoutPropertiesLoose","_excluded","_ref","disabledDateConfig","minDate","maxDate","disabledHourList","disabledMinuteList","disabledSecondList","minDateTimeDayInst","dayjs","undefined","maxDateTimeDayInst","customFormat","useMemo","showTime","DayjsDateTypeEnum","YMDHms","YMD","onChangeDate","_hooks","useCallbackRef","date","dateString","getDisabledDate","current","currentDate","flatbizDate","in","gte","datePickerValue","valueFt","dateNormalize","getDisabledTime","options","minDateTime","maxDateTime","Date","disabledHours","getDisabledHour","disabledMinutes","getDisabledMinute","disabledSeconds","getDisabledSecond","includes","_jsx","DatePicker","_extends","disabledDate","disabledTime","width"],"mappings":";8aAyCaA,EAAoB,SAApBA,EAAqBC,GAChC,IAAQC,EAAmFD,EAAnFC,MAAOC,EAA4EF,EAA5EE,SAAUC,EAAkEH,EAAlEG,MAAOC,EAA2DJ,EAA3DI,OAAQC,EAAmDL,EAAnDK,gBAAiBC,EAAkCN,EAAlCM,eAAmBC,EAAUC,EAAKR,EAAKS,GAChG,IAAAC,EACEV,EAAMW,oBAAsB,CAAE,EADxBC,EAAOF,EAAPE,QAASC,EAAOH,EAAPG,QAASC,EAAgBJ,EAAhBI,iBAAkBC,EAAkBL,EAAlBK,mBAAoBC,EAAkBN,EAAlBM,mBAEhE,IAAMC,EAAqBL,EAAUM,EAAMN,GAAWO,UACtD,IAAMC,EAAqBP,EAAUK,EAAML,GAAWM,UACtD,IAAME,EAAeC,GAAQ,WAC3B,GAAIlB,EA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AAM,IAAI2B,MAClD,MAAO,CACLC,cAAe,SAAfA,IACE,OAAOC,EAAgBd,EAASS,EACjC,EACDM,gBAAiB,SAAjBA,IACE,OAAOC,EAAkBhB,EAASS,EACnC,EACDQ,gBAAiB,SAAjBA,IACE,OAAOC,EAAkBlB,EAASS,EACpC,EAEJ,IAEA,IAAMnB,EAAWD,GAAQ,WACvB,GAAItB,EAAMuB,SAAU,OAAOvB,EAAMuB,SACjC,GAAIF,GAAgBA,EAAa+B,SAAS,MAAO,CAC/C,OAAO,IACT,CACA,OAAO,KACR,GAAE,CAACpD,EAAMuB,SAAUF,IAEpB,OACEgC,EAACC,EAAUC,EAAA,CACTC,aAAcxB,EACdyB,aAAchB,GACVlC,EAAU,CACdgB,SAAUA,EACVnB,OAAQiB,EACRlB,MAAKoD,EAAA,CAAIG,MAAO,QAAWvD,GAC3BF,MAAOqC,EACPpC,SAAUyB,IAGhB"}
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable */
2
2
  import './index.css';
3
3
  /*! @flatjs/forge MIT @flatbiz/antd */
4
- import{a as e,_ as r}from"../_rollupPluginBabelHelpers-a0769acd.js";import{hooks as n}from"@wove/react/cjs/hooks";import{flatbizDate as i}from"@flatbiz/utils";import{DatePicker as a}from"antd";import t from"dayjs";import{useState as u,useMemo as l}from"react";import{D as o,g as f,a as s,b as d}from"../time-53b3f55f.js";import{jsx as m}from"react/jsx-runtime";var v=["value","onChange","style","format","onOpenChange","outputNormalize","inputNormalize"];var c=function c(b){var p=b.value,D=b.onChange,h=b.style,g=b.format,C=b.onOpenChange,M=b.outputNormalize,w=b.inputNormalize,T=e(b,v);var y=b.disabledDateConfig||{},z=y.maxDays,H=y.minDate,Y=y.maxDate,L=y.disabledHourList,N=y.disabledMinuteList,j=y.disabledSecondList;var k=H?t(H):undefined;var x=Y?t(Y):undefined;var R=u(null),O=R[0],S=R[1];var P=u(null),_=P[0],B=P[1];var q=l((function(){if(w){return w(p)||[]}return p||[]}),[p]),A=q[0],E=q[1];var F=l((function(){if(A&&E){var e=i.dateNormalize(A);var r=i.dateNormalize(E);return[t(e),t(r)]}return undefined}),[A,E]);var G=l((function(){if(g)return g;if(b.showTime===true)return o.YMDHms;return o.YMD}),[b.showTime,g]);var I=l((function(){if(b.showTime)return b.showTime;if(G&&G.includes("HH")){return true}return false}),[b.showTime,G]);var J=n.useCallbackRef((function(e,r){if(e&&e[0]&&e[1]){if(M){D==null?void 0:D(M(r))}else{D==null?void 0:D(r)}}else{D==null?void 0:D(undefined)}}));var K=n.useCallbackRef((function(e){var r=e.format(o.YMD);if(!b.disabledDateConfig){return false}if(k&&x){if(!i.in(r,k.format(o.YMD),x.format(o.YMD))){return true}}else if(k){if(!i.gte(r,k.format(o.YMD))){return true}}else if(x){if(!i.gte(x.format(o.YMD),r)){return true}}if(!z||!(O!=null&&O[0])&&!(O!=null&&O[1])){return false}var n=(O==null?void 0:O[0])&&e.diff(O[0],"days")>z-1;var a=(O==null?void 0:O[1])&&O[1].diff(e,"days")>z-1;return!!a||!!n}));var Q=function e(r){if(z&&z>0){if(r){B([null,null]);S([null,null])}else{B(null)}}C==null?void 0:C(r)};var U=n.useCallbackRef((function(e){var r={minDateTime:k,maxDateTime:x,disabledHourList:L,disabledMinuteList:N,disabledSecondList:j};e=e||t(A||new Date);return{disabledHours:function n(){return f(e,r)},disabledMinutes:function n(){return s(e,r)},disabledSeconds:function n(){return d(e,r)}}}));return m(a.RangePicker,r({disabledDate:K,disabledTime:U},T,{showTime:I,format:G,style:r({width:"100%"},h),value:_||F,onChange:J,onOpenChange:Q,onCalendarChange:function e(r){return S(r)}}))};export{c as DateRangePickerWrapper};
4
+ import{a as e,_ as r}from"../_rollupPluginBabelHelpers-c0dbec57.js";import{hooks as n}from"@wove/react/cjs/hooks";import{flatbizDate as a}from"@flatbiz/utils";import{DatePicker as i}from"antd";import t from"dayjs";import{useState as u,useMemo as l}from"react";import{D as o,g as f,a as s,b as d}from"../time-53b3f55f.js";import{jsx as m}from"react/jsx-runtime";var v=["value","onChange","style","format","onOpenChange","outputNormalize","inputNormalize"];var c=function c(b){var p=b.value,D=b.onChange,h=b.style,g=b.format,C=b.onOpenChange,M=b.outputNormalize,w=b.inputNormalize,T=e(b,v);var y=b.disabledDateConfig||{},z=y.maxDays,H=y.minDate,Y=y.maxDate,L=y.disabledHourList,N=y.disabledMinuteList,j=y.disabledSecondList;var k=H?t(H):undefined;var x=Y?t(Y):undefined;var R=u(null),O=R[0],S=R[1];var P=u(null),_=P[0],B=P[1];var q=l((function(){if(w){return w(p)||[]}return p||[]}),[p]),A=q[0],E=q[1];var F=l((function(){if(A&&E){var e=a.dateNormalize(A);var r=a.dateNormalize(E);return[t(e),t(r)]}return undefined}),[A,E]);var G=l((function(){if(g)return g;if(b.showTime===true)return o.YMDHms;return o.YMD}),[b.showTime,g]);var I=l((function(){if(b.showTime)return b.showTime;if(G&&G.includes("HH")){return true}return false}),[b.showTime,G]);var J=n.useCallbackRef((function(e,r){if(e&&e[0]&&e[1]){if(M){D==null||D(M(r))}else{D==null||D(r)}}else{D==null||D(undefined)}}));var K=n.useCallbackRef((function(e){var r=e.format(o.YMD);if(!b.disabledDateConfig){return false}if(k&&x){if(!a.in(r,k.format(o.YMD),x.format(o.YMD))){return true}}else if(k){if(!a.gte(r,k.format(o.YMD))){return true}}else if(x){if(!a.gte(x.format(o.YMD),r)){return true}}if(!z||!(O!=null&&O[0])&&!(O!=null&&O[1])){return false}var n=(O==null?void 0:O[0])&&e.diff(O[0],"days")>z-1;var i=(O==null?void 0:O[1])&&O[1].diff(e,"days")>z-1;return!!i||!!n}));var Q=function e(r){if(z&&z>0){if(r){B([null,null]);S([null,null])}else{B(null)}}C==null||C(r)};var U=n.useCallbackRef((function(e){var r={minDateTime:k,maxDateTime:x,disabledHourList:L,disabledMinuteList:N,disabledSecondList:j};e=e||t(A||new Date);return{disabledHours:function n(){return f(e,r)},disabledMinutes:function n(){return s(e,r)},disabledSeconds:function n(){return d(e,r)}}}));return m(i.RangePicker,r({disabledDate:K,disabledTime:U},T,{showTime:I,format:G,style:r({width:"100%"},h),value:_||F,onChange:J,onOpenChange:Q,onCalendarChange:function e(r){return S(r)}}))};export{c as DateRangePickerWrapper};
5
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["@flatbiz/antd/src/date-range-picker-wrapper/date-range-picker-wrapper.tsx"],"sourcesContent":["import { flatbizDate, TAny } from '@flatbiz/utils';\nimport { hooks } from '@wove/react';\nimport { DatePicker } from 'antd';\nimport { RangePickerDateProps } from 'antd/es/date-picker/generatePicker';\nimport dayjs, { Dayjs } from 'dayjs';\nimport { useMemo, useState } from 'react';\nimport { DayjsDateTypeEnum, TDayjsDateType } from '../_utils/constants';\nimport { getDisabledHour, getDisabledMinute, getDisabledSecond } from '../_utils/time';\n\nexport type DateRangePickerWrapperProps = Omit<\n RangePickerDateProps<TAny>,\n 'value' | 'onChange' | 'onCalendarChange' | 'format'\n> & {\n value?: [string, string];\n onChange?: (value?: [string, string]) => void;\n /**\n * 1. minDate、maxDate 与 format格式相同;默认:YYYY-MM-DD\n * 2. maxDays 最大可选的天数\n */\n disabledDateConfig?: {\n minDate?: TDayjsDateType;\n maxDate?: TDayjsDateType;\n maxDays?: number;\n /** 禁用 小时 刻度列表,与日期无关 */\n disabledHourList?: number[];\n /** 禁用 分钟 刻度列表,与日期无关 */\n disabledMinuteList?: number[];\n /** 禁用 秒钟 刻度列表,与日期无关 */\n disabledSecondList?: number[];\n };\n format?: TDayjsDateType;\n /** value 输出适配 */\n outputNormalize?: (value: [string, string]) => TAny;\n /** value 输入适配 */\n inputNormalize?: (value?: TAny) => [string, string] | undefined;\n};\n\ntype RangeValue = [Dayjs | null, Dayjs | null] | null;\n\n/**\n * DatePicker.RangePicker包装组件\n * ```\n * 1. value类型为 [string, string],可以通过 inputNormalize来进行自定义转换\n * 2. onChange返回类型 [string, string],可以通过 outputNormalize来进行自定义转换\n * 3. 默认格式化类型 YYYY-MM-DD; 当showTime===true时,默认格式化类型YYYY-MM-DD HH:mm:ss;其他格式化类型自定义format\n * 4. 可设置disabledDateConfig,来控制日期项的disbaled状态\n * 5. 设置 disabledDate 后,disabledDateConfig配置将失效\n * 6. 设置 disabledTime 后,内置的disabledTime逻辑将失效\n *\n * TODO: 引用DatePicker.RangePicker TS有问题,待解决\n * TODO: 存在场景缺陷,当设置maxDays、showTime后,在选择单个日期不通过确认按钮直接切换输入框,无法获取回调,无法约束disabledDate\n * ```\n */\nexport const DateRangePickerWrapper = (props: DateRangePickerWrapperProps) => {\n const {\n value,\n onChange,\n style,\n format,\n onOpenChange: onAntdOpenChange,\n outputNormalize,\n inputNormalize,\n ...otherProps\n } = props;\n const { maxDays, minDate, maxDate, disabledHourList, disabledMinuteList, disabledSecondList } =\n props.disabledDateConfig || {};\n const minDateTimeDayInst = minDate ? dayjs(minDate) : undefined;\n const maxDateTimeDayInst = maxDate ? dayjs(maxDate) : undefined;\n\n const [dates, setDates] = useState<RangeValue>(null);\n const [hackValue, setHackValue] = useState<RangeValue>(null);\n\n const [date1, date2] = useMemo(() => {\n if (inputNormalize) {\n return inputNormalize(value) || [];\n }\n return value || [];\n }, [value]);\n const rangePickerValue = useMemo(() => {\n if (date1 && date2) {\n const newDate1 = flatbizDate.dateNormalize(date1);\n const newDate2 = flatbizDate.dateNormalize(date2);\n return [dayjs(newDate1), dayjs(newDate2)];\n }\n return undefined;\n }, [date1, date2]) as [Dayjs, Dayjs];\n\n const customFormat = useMemo(() => {\n if (format) return format as string;\n if (props.showTime === true) return DayjsDateTypeEnum.YMDHms;\n return DayjsDateTypeEnum.YMD;\n }, [props.showTime, format]);\n\n const showTime = useMemo(() => {\n if (props.showTime) return props.showTime;\n if (customFormat && customFormat.includes('HH')) {\n return true;\n }\n return false;\n }, [props.showTime, customFormat]);\n\n const onChangeDate = hooks.useCallbackRef((dates, dateStrings) => {\n if (dates && dates[0] && dates[1]) {\n if (outputNormalize) {\n onChange?.(outputNormalize(dateStrings) as [string, string]);\n } else {\n onChange?.(dateStrings);\n }\n } else {\n onChange?.(undefined);\n }\n });\n\n const getDisabledDate = hooks.useCallbackRef((current) => {\n const currentDate = current.format(DayjsDateTypeEnum.YMD);\n if (!props.disabledDateConfig) {\n return false;\n }\n if (minDateTimeDayInst && maxDateTimeDayInst) {\n if (\n !flatbizDate.in(\n currentDate,\n minDateTimeDayInst.format(DayjsDateTypeEnum.YMD),\n maxDateTimeDayInst.format(DayjsDateTypeEnum.YMD),\n )\n ) {\n return true;\n }\n } else if (minDateTimeDayInst) {\n if (!flatbizDate.gte(currentDate, minDateTimeDayInst.format(DayjsDateTypeEnum.YMD))) {\n return true;\n }\n } else if (maxDateTimeDayInst) {\n if (!flatbizDate.gte(maxDateTimeDayInst.format(DayjsDateTypeEnum.YMD), currentDate)) {\n return true;\n }\n }\n\n if (!maxDays || (!dates?.[0] && !dates?.[1])) {\n return false;\n }\n\n const tooLate = dates?.[0] && current.diff(dates[0], 'days') > maxDays - 1;\n const tooEarly = dates?.[1] && dates[1].diff(current, 'days') > maxDays - 1;\n return !!tooEarly || !!tooLate;\n });\n\n const onOpenChange = (open: boolean) => {\n if (maxDays && maxDays > 0) {\n if (open) {\n setHackValue([null, null]);\n setDates([null, null]);\n } else {\n setHackValue(null);\n }\n }\n onAntdOpenChange?.(open);\n };\n\n const getDisabledTime = hooks.useCallbackRef((current) => {\n const options = {\n minDateTime: minDateTimeDayInst,\n maxDateTime: maxDateTimeDayInst,\n disabledHourList,\n disabledMinuteList,\n disabledSecondList,\n };\n current = current || dayjs(date1 || new Date());\n return {\n disabledHours: () => {\n return getDisabledHour(current, options);\n },\n disabledMinutes: () => {\n return getDisabledMinute(current, options);\n },\n disabledSeconds: () => {\n return getDisabledSecond(current, options);\n },\n };\n });\n\n return (\n <DatePicker.RangePicker\n disabledDate={getDisabledDate}\n disabledTime={getDisabledTime}\n {...otherProps}\n showTime={showTime}\n format={customFormat}\n style={{ width: '100%', ...style }}\n value={hackValue || rangePickerValue}\n onChange={onChangeDate}\n onOpenChange={onOpenChange}\n onCalendarChange={(val) => setDates(val as RangeValue)}\n />\n );\n};\n"],"names":["DateRangePickerWrapper","props","value","onChange","style","format","onAntdOpenChange","onOpenChange","outputNormalize","inputNormalize","otherProps","_objectWithoutPropertiesLoose","_excluded","_ref","disabledDateConfig","maxDays","minDate","maxDate","disabledHourList","disabledMinuteList","disabledSecondList","minDateTimeDayInst","dayjs","undefined","maxDateTimeDayInst","_useState","useState","dates","setDates","_useState2","hackValue","setHackValue","_useMemo","useMemo","date1","date2","rangePickerValue","newDate1","flatbizDate","dateNormalize","newDate2","customFormat","showTime","DayjsDateTypeEnum","YMDHms","YMD","includes","onChangeDate","_hooks","useCallbackRef","dateStrings","getDisabledDate","current","currentDate","in","gte","tooLate","diff","tooEarly","open","getDisabledTime","options","minDateTime","maxDateTime","Date","disabledHours","getDisabledHour","disabledMinutes","getDisabledMinute","disabledSeconds","getDisabledSecond","_jsx","DatePicker","RangePicker","_extends","disabledDate","disabledTime","width","onCalendarChange","val"],"mappings":";2cAqDaA,EAAyB,SAAzBA,EAA0BC,GACrC,IACEC,EAQED,EARFC,MACAC,EAOEF,EAPFE,SACAC,EAMEH,EANFG,MACAC,EAKEJ,EALFI,OACcC,EAIZL,EAJFM,aACAC,EAGEP,EAHFO,gBACAC,EAEER,EAFFQ,eACGC,EAAUC,EACXV,EAAKW,GACT,IAAAC,EACEZ,EAAMa,oBAAsB,CAAE,EADxBC,EAAOF,EAAPE,QAASC,EAAOH,EAAPG,QAASC,EAAOJ,EAAPI,QAASC,EAAgBL,EAAhBK,iBAAkBC,EAAkBN,EAAlBM,mBAAoBC,EAAkBP,EAAlBO,mBAEzE,IAAMC,EAAqBL,EAAUM,EAAMN,GAAWO,UACtD,IAAMC,EAAqBP,EAAUK,EAAML,GAAWM,UAEtD,IAAAE,EAA0BC,EAAqB,MAAxCC,EAAKF,EAAA,GAAEG,EAAQH,EAAA,GACtB,IAAAI,EAAkCH,EAAqB,MAAhDI,EAASD,E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EAAA,CACrBC,aAAcxB,EACdyB,aAAchB,GACVlD,EAAU,CACdgC,SAAUA,EACVrC,OAAQoC,EACRrC,MAAKsE,EAAA,CAAIG,MAAO,QAAWzE,GAC3BF,MAAO4B,GAAaM,EACpBjC,SAAU4C,EACVxC,aAAcA,EACduE,iBAAkB,SAAAA,EAACC,GAAG,OAAKnD,EAASmD,EAAkB,IAG5D"}
1
+ {"version":3,"file":"index.js","sources":["@flatbiz/antd/src/date-range-picker-wrapper/date-range-picker-wrapper.tsx"],"sourcesContent":["import { flatbizDate, TAny } from '@flatbiz/utils';\nimport { hooks } from '@wove/react';\nimport { DatePicker } from 'antd';\nimport { RangePickerDateProps } from 'antd/es/date-picker/generatePicker';\nimport dayjs, { Dayjs } from 'dayjs';\nimport { useMemo, useState } from 'react';\nimport { DayjsDateTypeEnum, TDayjsDateType } from '../_utils/constants';\nimport { getDisabledHour, getDisabledMinute, getDisabledSecond } from '../_utils/time';\n\nexport type DateRangePickerWrapperProps = Omit<\n RangePickerDateProps<TAny>,\n 'value' | 'onChange' | 'onCalendarChange' | 'format'\n> & {\n value?: [string, string];\n onChange?: (value?: [string, string]) => void;\n /**\n * 1. minDate、maxDate 与 format格式相同;默认:YYYY-MM-DD\n * 2. maxDays 最大可选的天数\n */\n disabledDateConfig?: {\n minDate?: TDayjsDateType;\n maxDate?: TDayjsDateType;\n maxDays?: number;\n /** 禁用 小时 刻度列表,与日期无关 */\n disabledHourList?: number[];\n /** 禁用 分钟 刻度列表,与日期无关 */\n disabledMinuteList?: number[];\n /** 禁用 秒钟 刻度列表,与日期无关 */\n disabledSecondList?: number[];\n };\n format?: TDayjsDateType;\n /** value 输出适配 */\n outputNormalize?: (value: [string, string]) => TAny;\n /** value 输入适配 */\n inputNormalize?: (value?: TAny) => [string, string] | undefined;\n};\n\ntype RangeValue = [Dayjs | null, Dayjs | null] | null;\n\n/**\n * DatePicker.RangePicker包装组件\n * ```\n * 1. value类型为 [string, string],可以通过 inputNormalize来进行自定义转换\n * 2. onChange返回类型 [string, string],可以通过 outputNormalize来进行自定义转换\n * 3. 默认格式化类型 YYYY-MM-DD; 当showTime===true时,默认格式化类型YYYY-MM-DD HH:mm:ss;其他格式化类型自定义format\n * 4. 可设置disabledDateConfig,来控制日期项的disbaled状态\n * 5. 设置 disabledDate 后,disabledDateConfig配置将失效\n * 6. 设置 disabledTime 后,内置的disabledTime逻辑将失效\n *\n * TODO: 引用DatePicker.RangePicker TS有问题,待解决\n * TODO: 存在场景缺陷,当设置maxDays、showTime后,在选择单个日期不通过确认按钮直接切换输入框,无法获取回调,无法约束disabledDate\n * ```\n */\nexport const DateRangePickerWrapper = (props: DateRangePickerWrapperProps) => {\n const {\n value,\n onChange,\n style,\n format,\n onOpenChange: onAntdOpenChange,\n outputNormalize,\n inputNormalize,\n ...otherProps\n } = props;\n const { maxDays, minDate, maxDate, disabledHourList, disabledMinuteList, disabledSecondList } =\n props.disabledDateConfig || {};\n const minDateTimeDayInst = minDate ? dayjs(minDate) : undefined;\n const maxDateTimeDayInst = maxDate ? dayjs(maxDate) : undefined;\n\n const [dates, setDates] = useState<RangeValue>(null);\n const [hackValue, setHackValue] = useState<RangeValue>(null);\n\n const [date1, date2] = useMemo(() => {\n if (inputNormalize) {\n return inputNormalize(value) || [];\n }\n return value || [];\n }, [value]);\n const rangePickerValue = useMemo(() => {\n if (date1 && date2) {\n const newDate1 = flatbizDate.dateNormalize(date1);\n const newDate2 = flatbizDate.dateNormalize(date2);\n return [dayjs(newDate1), dayjs(newDate2)];\n }\n return undefined;\n }, [date1, date2]) as [Dayjs, Dayjs];\n\n const customFormat = useMemo(() => {\n if (format) return format as string;\n if (props.showTime === true) return DayjsDateTypeEnum.YMDHms;\n return DayjsDateTypeEnum.YMD;\n }, [props.showTime, format]);\n\n const showTime = useMemo(() => {\n if (props.showTime) return props.showTime;\n if (customFormat && customFormat.includes('HH')) {\n return true;\n }\n return false;\n }, [props.showTime, customFormat]);\n\n const onChangeDate = hooks.useCallbackRef((dates, dateStrings) => {\n if (dates && dates[0] && dates[1]) {\n if (outputNormalize) {\n onChange?.(outputNormalize(dateStrings) as [string, string]);\n } else {\n onChange?.(dateStrings);\n }\n } else {\n onChange?.(undefined);\n }\n });\n\n const getDisabledDate = hooks.useCallbackRef((current) => {\n const currentDate = current.format(DayjsDateTypeEnum.YMD);\n if (!props.disabledDateConfig) {\n return false;\n }\n if (minDateTimeDayInst && maxDateTimeDayInst) {\n if (\n !flatbizDate.in(\n currentDate,\n minDateTimeDayInst.format(DayjsDateTypeEnum.YMD),\n maxDateTimeDayInst.format(DayjsDateTypeEnum.YMD),\n )\n ) {\n return true;\n }\n } else if (minDateTimeDayInst) {\n if (!flatbizDate.gte(currentDate, minDateTimeDayInst.format(DayjsDateTypeEnum.YMD))) {\n return true;\n }\n } else if (maxDateTimeDayInst) {\n if (!flatbizDate.gte(maxDateTimeDayInst.format(DayjsDateTypeEnum.YMD), currentDate)) {\n return true;\n }\n }\n\n if (!maxDays || (!dates?.[0] && !dates?.[1])) {\n return false;\n }\n\n const tooLate = dates?.[0] && current.diff(dates[0], 'days') > maxDays - 1;\n const tooEarly = dates?.[1] && dates[1].diff(current, 'days') > maxDays - 1;\n return !!tooEarly || !!tooLate;\n });\n\n const onOpenChange = (open: boolean) => {\n if (maxDays && maxDays > 0) {\n if (open) {\n setHackValue([null, null]);\n setDates([null, null]);\n } else {\n setHackValue(null);\n }\n }\n onAntdOpenChange?.(open);\n };\n\n const getDisabledTime = hooks.useCallbackRef((current) => {\n const options = {\n minDateTime: minDateTimeDayInst,\n maxDateTime: maxDateTimeDayInst,\n disabledHourList,\n disabledMinuteList,\n disabledSecondList,\n };\n current = current || dayjs(date1 || new Date());\n return {\n disabledHours: () => {\n return getDisabledHour(current, options);\n },\n disabledMinutes: () => {\n return getDisabledMinute(current, options);\n },\n disabledSeconds: () => {\n return getDisabledSecond(current, options);\n },\n };\n });\n\n return (\n <DatePicker.RangePicker\n disabledDate={getDisabledDate}\n disabledTime={getDisabledTime}\n {...otherProps}\n showTime={showTime}\n format={customFormat}\n style={{ width: '100%', ...style }}\n value={hackValue || rangePickerValue}\n onChange={onChangeDate}\n onOpenChange={onOpenChange}\n onCalendarChange={(val) => setDates(val as RangeValue)}\n />\n );\n};\n"],"names":["DateRangePickerWrapper","props","value","onChange","style","format","onAntdOpenChange","onOpenChange","outputNormalize","inputNormalize","otherProps","_objectWithoutPropertiesLoose","_excluded","_ref","disabledDateConfig","maxDays","minDate","maxDate","disabledHourList","disabledMinuteList","disabledSecondList","minDateTimeDayInst","dayjs","undefined","maxDateTimeDayInst","_useState","useState","dates","setDates","_useState2","hackValue","setHackValue","_useMemo","useMemo","date1","date2","rangePickerValue","newDate1","flatbizDate","dateNormalize","newDate2","customFormat","showTime","DayjsDateTypeEnum","YMDHms","YMD","includes","onChangeDate","_hooks","useCallbackRef","dateStrings","getDisabledDate","current","currentDate","in","gte","tooLate","diff","tooEarly","open","getDisabledTime","options","minDateTime","maxDateTime","Date","disabledHours","getDisabledHour","disabledMinutes","getDisabledMinute","disabledSeconds","getDisabledSecond","_jsx","DatePicker","RangePicker","_extends","disabledDate","disabledTime","width","onCalendarChange","val"],"mappings":";2cAqDaA,EAAyB,SAAzBA,EAA0BC,GACrC,IACEC,EAQED,EARFC,MACAC,EAOEF,EAPFE,SACAC,EAMEH,EANFG,MACAC,EAKEJ,EALFI,OACcC,EAIZL,EAJFM,aACAC,EAGEP,EAHFO,gBACAC,EAEER,EAFFQ,eACGC,EAAUC,EACXV,EAAKW,GACT,IAAAC,EACEZ,EAAMa,oBAAsB,CAAE,EADxBC,EAAOF,EAAPE,QAASC,EAAOH,EAAPG,QAASC,EAAOJ,EAAPI,QAASC,EAAgBL,EAAhBK,iBAAkBC,EAAkBN,EAAlBM,mBAAoBC,EAAkBP,EAAlBO,mBAEzE,IAAMC,EAAqBL,EAAUM,EAAMN,GAAWO,UACtD,IAAMC,EAAqBP,EAAUK,EAAML,GAAWM,UAEtD,IAAAE,EAA0BC,EAAqB,MAAxC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EAAkBlB,EAASS,EACpC,EAEJ,IAEA,OACEU,EAACC,EAAWC,YAAWC,EAAA,CACrBC,aAAcxB,EACdyB,aAAchB,GACVlD,EAAU,CACdgC,SAAUA,EACVrC,OAAQoC,EACRrC,MAAKsE,EAAA,CAAIG,MAAO,QAAWzE,GAC3BF,MAAO4B,GAAaM,EACpBjC,SAAU4C,EACVxC,aAAcA,EACduE,iBAAkB,SAAlBA,EAAmBC,GAAG,OAAKnD,EAASmD,EAAkB,IAG5D"}
@@ -8,5 +8,5 @@ import './../pre-defined-class-name/index.css';
8
8
  import './../types/index.css';
9
9
  import './index.css';
10
10
  /*! @flatjs/forge MIT @flatbiz/antd */
11
- import{a as e,_ as r}from"../_rollupPluginBabelHelpers-a0769acd.js";import{hooks as a}from"@wove/react/cjs/hooks";import{isArray as n}from"@dimjs/lang/cjs/is-array";import{toArray as i}from"@flatbiz/utils";import{Form as o}from"antd";import{useMemo as t,useEffect as m,useRef as s}from"react";import{DateRangePickerWrapper as l}from"../date-range-picker-wrapper/index.js";import{fbaHooks as u}from"../fba-hooks/index.js";import{fbaUtils as v}from"../fba-utils/index.js";import{FormItemHidden as c}from"../form-item-hidden/index.js";import{FormItemWrapper as d}from"../form-item-wrapper/index.js";import{jsxs as f,Fragment as p,jsx as j}from"react/jsx-runtime";import"dayjs";import"../time-53b3f55f.js";import"../use-responsive-point-21b8c601.js";import"@dimjs/model";import"../pre-defined-class-name/index.js";import"@dimjs/utils/cjs/class-names";var h=["startName","endName","formListName","formListCompleteName","dateRangePickerWrapperProps"];var g=function s(u){var g;var C=u.startName,x=u.endName,N=u.formListName,k=u.formListCompleteName,P=u.dateRangePickerWrapperProps,b=e(u,h);var F=o.useFormInstance();var W=k||N;var L=t((function(){if(W&&n(C)&&n(x)){var e=C[0],r=C.slice(1);var a=x.slice(1);return[e].concat("__#invalid_date_"+r.join("-")+"_"+a.join("-"))}return"__#invalid_date_"+C+"_"+x}),[W,C,x]);var w=t((function(){return W?[].concat(i(W),L):L}),[L,W]);var R=t((function(){return W?[].concat(i(W),i(C)):C}),[C,W]);var y=t((function(){return W?[].concat(i(W),i(x)):x}),[x,W]);var z=o.useWatch(R,F);var A=o.useWatch(y,F);var B=o.useWatch(w,F);var E=a.useCallbackRef((function(e){var r=e==null?void 0:e[0];var a=e==null?void 0:e[1];v.setFormFieldsAndTriggerValuesChange(F,[{name:R,value:r},{name:y,value:a}]);P==null||P.onChange==null?void 0:P.onChange(e)}));m((function(){if(z&&A){F.setFields([{name:w,value:[z,A]}])}else{F.setFields([{name:w,value:undefined}])}}),[z,A,B,F,w]);return f(p,{children:[j(c,{name:C}),j(c,{name:x}),j(d,r({},b,{name:L,children:W&&(g=u.rules)!=null&&g.length?j(_,r({},P,{onChange:E})):j(l,r({},P,{onChange:E}))}))]})};var _=function e(a){var n,i;var o=s(0);var t=u.usePrevious(a.value);u.useEffectCustom((function(){var e,r;if(o.current===0&&!t&&(e=a.value)!=null&&e[0]&&(r=a.value)!=null&&r[1]){o.current=1;a.onChange==null?void 0:a.onChange(a.value)}}),[(n=a.value)==null?void 0:n[0],(i=a.value)==null?void 0:i[1]]);return j(l,r({},a))};export{g as DateRangePickerWrapperFormItem};
11
+ import{a as e,_ as r}from"../_rollupPluginBabelHelpers-c0dbec57.js";import{hooks as a}from"@wove/react/cjs/hooks";import{isArray as n}from"@dimjs/lang/cjs/is-array";import{toArray as i}from"@flatbiz/utils";import{Form as o}from"antd";import{useMemo as t,useEffect as m,useRef as s}from"react";import{DateRangePickerWrapper as l}from"../date-range-picker-wrapper/index.js";import{fbaHooks as u}from"../fba-hooks/index.js";import{fbaUtils as v}from"../fba-utils/index.js";import{FormItemHidden as c}from"../form-item-hidden/index.js";import{FormItemWrapper as f}from"../form-item-wrapper/index.js";import{jsxs as d,Fragment as p,jsx as j}from"react/jsx-runtime";import"dayjs";import"../time-53b3f55f.js";import"../use-responsive-point-21b8c601.js";import"@dimjs/model";import"../pre-defined-class-name/index.js";import"@dimjs/utils/cjs/class-names";var h=["startName","endName","formListName","formListCompleteName","dateRangePickerWrapperProps"];var g=function s(u){var g;var C=u.startName,x=u.endName,N=u.formListName,k=u.formListCompleteName,P=u.dateRangePickerWrapperProps,b=e(u,h);var F=o.useFormInstance();var W=k||N;var L=t((function(){if(W&&n(C)&&n(x)){var e=C[0],r=C.slice(1);var a=x.slice(1);return[e].concat("__#invalid_date_"+r.join("-")+"_"+a.join("-"))}return"__#invalid_date_"+C+"_"+x}),[W,C,x]);var w=t((function(){return W?[].concat(i(W),L):L}),[L,W]);var R=t((function(){return W?[].concat(i(W),i(C)):C}),[C,W]);var y=t((function(){return W?[].concat(i(W),i(x)):x}),[x,W]);var z=o.useWatch(R,F);var A=o.useWatch(y,F);var B=o.useWatch(w,F);var E=a.useCallbackRef((function(e){var r=e==null?void 0:e[0];var a=e==null?void 0:e[1];v.setFormFieldsAndTriggerValuesChange(F,[{name:R,value:r},{name:y,value:a}]);P==null||P.onChange==null||P.onChange(e)}));m((function(){if(z&&A){F.setFields([{name:w,value:[z,A]}])}else{F.setFields([{name:w,value:undefined}])}}),[z,A,B,F,w]);return d(p,{children:[j(c,{name:C}),j(c,{name:x}),j(f,r({},b,{name:L,children:W&&(g=u.rules)!=null&&g.length?j(_,r({},P,{onChange:E})):j(l,r({},P,{onChange:E}))}))]})};var _=function e(a){var n,i;var o=s(0);var t=u.usePrevious(a.value);u.useEffectCustom((function(){var e,r;if(o.current===0&&!t&&(e=a.value)!=null&&e[0]&&(r=a.value)!=null&&r[1]){o.current=1;a.onChange==null||a.onChange(a.value)}}),[(n=a.value)==null?void 0:n[0],(i=a.value)==null?void 0:i[1]]);return j(l,r({},a))};export{g as DateRangePickerWrapperFormItem};
12
12
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["@flatbiz/antd/src/date-range-picker-wrapper-form-item/date-range-picker-wrapper-form-item.tsx"],"sourcesContent":["import { isArray } from '@dimjs/lang';\n\nimport { toArray } from '@flatbiz/utils';\nimport { hooks } from '@wove/react';\nimport { Form } from 'antd';\nimport { useEffect, useMemo, useRef } from 'react';\nimport { DateRangePickerWrapper, DateRangePickerWrapperProps } from '../date-range-picker-wrapper';\nimport { fbaHooks } from '../fba-hooks';\nimport { fbaUtils } from '../fba-utils';\nimport { FormItemHidden } from '../form-item-hidden';\nimport { FormItemWrapper, FormItemWrapperProps } from '../form-item-wrapper';\nimport { FormItemNamePath } from '../types';\n\nexport type DateRangePickerWrapperFormItemProps = Omit<FormItemWrapperProps, 'name'> & {\n /**\n * 开始的时间name\n */\n startName: FormItemNamePath;\n /**\n * 结束的时间name\n */\n endName: FormItemNamePath;\n /**\n * 如果 DateRangePickerWrapperFormItem 在Form.List场景下 必传\n * @deprecated 使用 formListCompleteName 配置\n */\n formListName?: Array<string | number>;\n /**\n * 前端 formItem 前缀FormName,当 TimeRangePickerWrapperFormItem 处在Form.List场景下,必传\n * ```\n * 例如 处在formList内部时,则 formListCompleteName = ['xxxxList']\n * 例如 处在formList套formList内部时,则 formListCompleteName = ['xxxxList', 索引值, 'xxxxList2']\n * ```\n */\n formListCompleteName?: Array<string | number> | string;\n\n dateRangePickerWrapperProps?: DateRangePickerWrapperProps;\n};\n/**\n * 包含了Form.Item组件的时间区间选择组件,时间区间组件可以定义成两个字段操作,不用再通过数组处理\n * ```\n * 1. 会在form中产生一个 `__#invalid_date_xxxx_xxxx` 的无效字段,可以直接忽略\n * 2. 设置日期格式 dateRangePickerWrapperProps={{ format: 'YYYY-MM-DD HH:mm' }}\n * 使用场景:\n * 1. 基础使用场景\n * <DateRangePickerWrapperFormItem startName={'date1'} endName={'date2'} />\n * 2. Form.List 内部使用\n * <FormListWrapper name=\"dataList\" prevCompleteName={[]}>\n * {(data) => {\n * return <DateRangePickerWrapperFormItem formListCompleteName={data.prevCompleteName} startName={data.getInsideFormItemName('date1')} endName={data.getInsideFormItemName('date2')} />\n * }}\n * </FormListWrapper>\n * 3. Form.List 套 Form.List 内部使用\n * <FormListWrapper name=\"dataList\" prevCompleteName={[]}>\n * {(data) => {\n * return <FormListWrapper name={data.getInsideFormItemName('childrenList')} prevCompleteName={data.prevCompleteName}>\n * {(data2) => {\n * return <DateRangePickerWrapperFormItem formListCompleteName={data2.prevCompleteName} startName={data2.getInsideFormItemName('date1')} endName={data2.getInsideFormItemName('date2')} />\n * }}\n * </FormListWrapper>\n * }}\n * </FormListWrapper>\n * ```\n */\nexport const DateRangePickerWrapperFormItem = (props: DateRangePickerWrapperFormItemProps) => {\n const {\n startName,\n endName,\n formListName,\n formListCompleteName,\n dateRangePickerWrapperProps,\n ...otherProps\n } = props;\n const form = Form.useFormInstance();\n\n const prevName = formListCompleteName || formListName;\n\n const bodyName = useMemo(() => {\n if (prevName && isArray(startName) && isArray(endName)) {\n const [startName0, ...startNameOther] = startName;\n const [, ...endNameOther] = endName;\n return [startName0].concat(`__#invalid_date_${startNameOther.join('-')}_${endNameOther.join('-')}`);\n }\n return `__#invalid_date_${startName}_${endName}`;\n }, [prevName, startName, endName]);\n\n const bodyCompleteName = useMemo(\n () => (prevName ? [...toArray<string | number>(prevName), ...bodyName] : bodyName),\n [bodyName, prevName],\n );\n\n const startCompleteName = useMemo(() => {\n return prevName\n ? [...toArray<string | number>(prevName), ...toArray<string | number>(startName)]\n : startName;\n }, [startName, prevName]);\n\n const endCompleteName = useMemo(() => {\n return prevName ? [...toArray<string | number>(prevName), ...toArray<string | number>(endName)] : endName;\n }, [endName, prevName]);\n\n const startVal = Form.useWatch(startCompleteName, form);\n const endVal = Form.useWatch(endCompleteName, form);\n const bodyValue = Form.useWatch(bodyCompleteName, form);\n\n const onChange = hooks.useCallbackRef((data) => {\n const value1 = data?.[0];\n const value2 = data?.[1];\n fbaUtils.setFormFieldsAndTriggerValuesChange(form, [\n { name: startCompleteName, value: value1 },\n { name: endCompleteName, value: value2 },\n ]);\n dateRangePickerWrapperProps?.onChange?.(data);\n });\n\n useEffect(() => {\n if (startVal && endVal) {\n form.setFields([{ name: bodyCompleteName, value: [startVal, endVal] }]);\n } else {\n form.setFields([{ name: bodyCompleteName, value: undefined }]);\n }\n }, [startVal, endVal, bodyValue, form, bodyCompleteName]);\n\n return (\n <>\n <FormItemHidden name={startName} />\n <FormItemHidden name={endName} />\n <FormItemWrapper {...otherProps} name={bodyName}>\n {prevName && props.rules?.length ? (\n <Content {...dateRangePickerWrapperProps} onChange={onChange} />\n ) : (\n <DateRangePickerWrapper {...dateRangePickerWrapperProps} onChange={onChange} />\n )}\n </FormItemWrapper>\n </>\n );\n};\n\nconst Content = (props) => {\n const ref = useRef<number>(0);\n const preValue = fbaHooks.usePrevious(props.value);\n fbaHooks.useEffectCustom(() => {\n // 处在Form.List场景下,当第一次外部赋值时,会出现赋值成功,但显示异常效果\n if (ref.current === 0 && !preValue && props.value?.[0] && props.value?.[1]) {\n ref.current = 1;\n props.onChange?.(props.value);\n }\n }, [props.value?.[0], props.value?.[1]]);\n\n return <DateRangePickerWrapper {...props} />;\n};\n"],"names":["DateRangePickerWrapperFormItem","props","_props$rules","startName","endName","formListName","formListCompleteName","dateRangePickerWrapperProps","otherProps","_objectWithoutPropertiesLoose","_excluded","form","Form","useFormInstance","prevName","bodyName","useMemo","_isArray","startName0","startNameOther","slice","endNameOther","concat","join","bodyCompleteName","toArray","startCompleteName","endCompleteName","startVal","useWatch","endVal","bodyValue","onChange","_hooks","useCallbackRef","data","value1","value2","fbaUtils","setFormFieldsAndTriggerValuesChange","name","value","useEffect","setFields","undefined","_jsxs","_Fragment","children","_jsx","FormItemHidden","FormItemWrapper","_extends","rules","length","Content","DateRangePickerWrapper","_props$value3","_props$value4","ref","useRef","preValue","fbaHooks","usePrevious","useEffectCustom","_props$value","_props$value2","current"],"mappings":";q7BAgEaA,EAAiC,SAAjCA,EAAkCC,GAA+C,IAAAC,EAC5F,IACEC,EAMEF,EANFE,UACAC,EAKEH,EALFG,QACAC,EAIEJ,EAJFI,aACAC,EAGEL,EAHFK,qBACAC,EAEEN,EAFFM,4BACGC,EAAUC,EACXR,EAAKS,GACT,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AAMhB,EAAkBiB,MAAO,CAACb,EAAUE,KAC9D,KAAO,CACLnB,EAAKgC,UAAU,CAAC,CAAEH,KAAMhB,EAAkBiB,MAAOG,YACnD,CACF,GAAG,CAAChB,EAAUE,EAAQC,EAAWpB,EAAMa,IAEvC,OACEqB,EAAAC,EAAA,CAAAC,SAAA,CACEC,EAACC,EAAc,CAACT,KAAMrC,IACtB6C,EAACC,EAAc,CAACT,KAAMpC,IACtB4C,EAACE,EAAeC,KAAK3C,EAAU,CAAEgC,KAAMzB,EAASgC,SAC7CjC,IAAQZ,EAAID,EAAMmD,QAAK,MAAXlD,EAAamD,OACxBL,EAACM,EAAOH,KAAK5C,EAA2B,CAAEyB,SAAUA,KAEpDgB,EAACO,EAAsBJ,KAAK5C,EAA2B,CAAEyB,SAAUA,UAK7E,EAEA,IAAMsB,EAAU,SAAVA,EAAWrD,GAAU,IAAAuD,EAAAC,EACzB,IAAMC,EAAMC,EAAe,GAC3B,IAAMC,EAAWC,EAASC,YAAY7D,EAAMwC,OAC5CoB,EAASE,iBAAgB,WAAM,IAAAC,EAAAC,EAE7B,GAAIP,EAAIQ,UAAY,IAAMN,IAAQI,EAAI/D,EAAMwC,QAAK,MAAXuB,EAAc,KAAEC,EAAIhE,EAAMwC,QAANwB,MAAAA,EAAc,GAAI,CAC1EP,EAAIQ,QAAU,EACdjE,EAAM+B,UAAQ,UAAA,EAAd/B,EAAM+B,SAAW/B,EAAMwC,MACzB,IACC,EAAAe,EAACvD,EAAMwC,QAAK,UAAA,EAAXe,EAAc,IAAEC,EAAExD,EAAMwC,QAAK,UAAA,EAAXgB,EAAc,KAEpC,OAAOT,EAACO,EAAsBJ,EAAKlD,CAAAA,EAAAA,GACrC"}
1
+ {"version":3,"file":"index.js","sources":["@flatbiz/antd/src/date-range-picker-wrapper-form-item/date-range-picker-wrapper-form-item.tsx"],"sourcesContent":["import { isArray } from '@dimjs/lang';\n\nimport { toArray } from '@flatbiz/utils';\nimport { hooks } from '@wove/react';\nimport { Form } from 'antd';\nimport { useEffect, useMemo, useRef } from 'react';\nimport { DateRangePickerWrapper, DateRangePickerWrapperProps } from '../date-range-picker-wrapper';\nimport { fbaHooks } from '../fba-hooks';\nimport { fbaUtils } from '../fba-utils';\nimport { FormItemHidden } from '../form-item-hidden';\nimport { FormItemWrapper, FormItemWrapperProps } from '../form-item-wrapper';\nimport { FormItemNamePath } from '../types';\n\nexport type DateRangePickerWrapperFormItemProps = Omit<FormItemWrapperProps, 'name'> & {\n /**\n * 开始的时间name\n */\n startName: FormItemNamePath;\n /**\n * 结束的时间name\n */\n endName: FormItemNamePath;\n /**\n * 如果 DateRangePickerWrapperFormItem 在Form.List场景下 必传\n * @deprecated 使用 formListCompleteName 配置\n */\n formListName?: Array<string | number>;\n /**\n * 前端 formItem 前缀FormName,当 TimeRangePickerWrapperFormItem 处在Form.List场景下,必传\n * ```\n * 例如 处在formList内部时,则 formListCompleteName = ['xxxxList']\n * 例如 处在formList套formList内部时,则 formListCompleteName = ['xxxxList', 索引值, 'xxxxList2']\n * ```\n */\n formListCompleteName?: Array<string | number> | string;\n\n dateRangePickerWrapperProps?: DateRangePickerWrapperProps;\n};\n/**\n * 包含了Form.Item组件的时间区间选择组件,时间区间组件可以定义成两个字段操作,不用再通过数组处理\n * ```\n * 1. 会在form中产生一个 `__#invalid_date_xxxx_xxxx` 的无效字段,可以直接忽略\n * 2. 设置日期格式 dateRangePickerWrapperProps={{ format: 'YYYY-MM-DD HH:mm' }}\n * 使用场景:\n * 1. 基础使用场景\n * <DateRangePickerWrapperFormItem startName={'date1'} endName={'date2'} />\n * 2. Form.List 内部使用\n * <FormListWrapper name=\"dataList\" prevCompleteName={[]}>\n * {(data) => {\n * return <DateRangePickerWrapperFormItem formListCompleteName={data.prevCompleteName} startName={data.getInsideFormItemName('date1')} endName={data.getInsideFormItemName('date2')} />\n * }}\n * </FormListWrapper>\n * 3. Form.List 套 Form.List 内部使用\n * <FormListWrapper name=\"dataList\" prevCompleteName={[]}>\n * {(data) => {\n * return <FormListWrapper name={data.getInsideFormItemName('childrenList')} prevCompleteName={data.prevCompleteName}>\n * {(data2) => {\n * return <DateRangePickerWrapperFormItem formListCompleteName={data2.prevCompleteName} startName={data2.getInsideFormItemName('date1')} endName={data2.getInsideFormItemName('date2')} />\n * }}\n * </FormListWrapper>\n * }}\n * </FormListWrapper>\n * ```\n */\nexport const DateRangePickerWrapperFormItem = (props: DateRangePickerWrapperFormItemProps) => {\n const {\n startName,\n endName,\n formListName,\n formListCompleteName,\n dateRangePickerWrapperProps,\n ...otherProps\n } = props;\n const form = Form.useFormInstance();\n\n const prevName = formListCompleteName || formListName;\n\n const bodyName = useMemo(() => {\n if (prevName && isArray(startName) && isArray(endName)) {\n const [startName0, ...startNameOther] = startName;\n const [, ...endNameOther] = endName;\n return [startName0].concat(`__#invalid_date_${startNameOther.join('-')}_${endNameOther.join('-')}`);\n }\n return `__#invalid_date_${startName}_${endName}`;\n }, [prevName, startName, endName]);\n\n const bodyCompleteName = useMemo(\n () => (prevName ? [...toArray<string | number>(prevName), ...bodyName] : bodyName),\n [bodyName, prevName],\n );\n\n const startCompleteName = useMemo(() => {\n return prevName\n ? [...toArray<string | number>(prevName), ...toArray<string | number>(startName)]\n : startName;\n }, [startName, prevName]);\n\n const endCompleteName = useMemo(() => {\n return prevName ? [...toArray<string | number>(prevName), ...toArray<string | number>(endName)] : endName;\n }, [endName, prevName]);\n\n const startVal = Form.useWatch(startCompleteName, form);\n const endVal = Form.useWatch(endCompleteName, form);\n const bodyValue = Form.useWatch(bodyCompleteName, form);\n\n const onChange = hooks.useCallbackRef((data) => {\n const value1 = data?.[0];\n const value2 = data?.[1];\n fbaUtils.setFormFieldsAndTriggerValuesChange(form, [\n { name: startCompleteName, value: value1 },\n { name: endCompleteName, value: value2 },\n ]);\n dateRangePickerWrapperProps?.onChange?.(data);\n });\n\n useEffect(() => {\n if (startVal && endVal) {\n form.setFields([{ name: bodyCompleteName, value: [startVal, endVal] }]);\n } else {\n form.setFields([{ name: bodyCompleteName, value: undefined }]);\n }\n }, [startVal, endVal, bodyValue, form, bodyCompleteName]);\n\n return (\n <>\n <FormItemHidden name={startName} />\n <FormItemHidden name={endName} />\n <FormItemWrapper {...otherProps} name={bodyName}>\n {prevName && props.rules?.length ? (\n <Content {...dateRangePickerWrapperProps} onChange={onChange} />\n ) : (\n <DateRangePickerWrapper {...dateRangePickerWrapperProps} onChange={onChange} />\n )}\n </FormItemWrapper>\n </>\n );\n};\n\nconst Content = (props) => {\n const ref = useRef<number>(0);\n const preValue = fbaHooks.usePrevious(props.value);\n fbaHooks.useEffectCustom(() => {\n // 处在Form.List场景下,当第一次外部赋值时,会出现赋值成功,但显示异常效果\n if (ref.current === 0 && !preValue && props.value?.[0] && props.value?.[1]) {\n ref.current = 1;\n props.onChange?.(props.value);\n }\n }, [props.value?.[0], props.value?.[1]]);\n\n return <DateRangePickerWrapper {...props} />;\n};\n"],"names":["DateRangePickerWrapperFormItem","props","_props$rules","startName","endName","formListName","formListCompleteName","dateRangePickerWrapperProps","otherProps","_objectWithoutPropertiesLoose","_excluded","form","Form","useFormInstance","prevName","bodyName","useMemo","_isArray","startName0","startNameOther","slice","endNameOther","concat","join","bodyCompleteName","toArray","startCompleteName","endCompleteName","startVal","useWatch","endVal","bodyValue","onChange","_hooks","useCallbackRef","data","value1","value2","fbaUtils","setFormFieldsAndTriggerValuesChange","name","value","useEffect","setFields","undefined","_jsxs","_Fragment","children","_jsx","FormItemHidden","FormItemWrapper","_extends","rules","length","Content","DateRangePickerWrapper","_props$value3","_props$value4","ref","useRef","preValue","fbaHooks","usePrevious","useEffectCustom","_props$value","_props$value2","current"],"mappings":";q7BAgEaA,EAAiC,SAAjCA,EAAkCC,GAA+C,IAAAC,EAC5F,IACEC,EAMEF,EANFE,UACAC,EAKEH,EALFG,QACAC,EAIEJ,EAJFI,aACAC,EAGEL,EAHFK,qBACAC,EAEEN,EAFFM,4BACGC,EAAUC,EACXR,EAAKS,GACT,IAAMC,EAAOC,EAA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AACb,EAAUE,KAC9D,KAAO,CACLnB,EAAKgC,UAAU,CAAC,CAAEH,KAAMhB,EAAkBiB,MAAOG,YACnD,CACF,GAAG,CAAChB,EAAUE,EAAQC,EAAWpB,EAAMa,IAEvC,OACEqB,EAAAC,EAAA,CAAAC,SAAA,CACEC,EAACC,EAAc,CAACT,KAAMrC,IACtB6C,EAACC,EAAc,CAACT,KAAMpC,IACtB4C,EAACE,EAAeC,KAAK3C,EAAU,CAAEgC,KAAMzB,EAASgC,SAC7CjC,IAAQZ,EAAID,EAAMmD,QAAK,MAAXlD,EAAamD,OACxBL,EAACM,EAAOH,KAAK5C,EAA2B,CAAEyB,SAAUA,KAEpDgB,EAACO,EAAsBJ,KAAK5C,EAA2B,CAAEyB,SAAUA,UAK7E,EAEA,IAAMsB,EAAU,SAAVA,EAAWrD,GAAU,IAAAuD,EAAAC,EACzB,IAAMC,EAAMC,EAAe,GAC3B,IAAMC,EAAWC,EAASC,YAAY7D,EAAMwC,OAC5CoB,EAASE,iBAAgB,WAAM,IAAAC,EAAAC,EAE7B,GAAIP,EAAIQ,UAAY,IAAMN,IAAQI,EAAI/D,EAAMwC,QAAK,MAAXuB,EAAc,KAAEC,EAAIhE,EAAMwC,QAANwB,MAAAA,EAAc,GAAI,CAC1EP,EAAIQ,QAAU,EACdjE,EAAM+B,UAAQ,MAAd/B,EAAM+B,SAAW/B,EAAMwC,MACzB,IACC,EAAAe,EAACvD,EAAMwC,QAAK,UAAA,EAAXe,EAAc,IAAEC,EAAExD,EAAMwC,QAAK,UAAA,EAAXgB,EAAc,KAEpC,OAAOT,EAACO,EAAsBJ,EAAKlD,CAAAA,EAAAA,GACrC"}
@@ -2,5 +2,5 @@
2
2
  import './../icon-wrapper/index.css';
3
3
  import './index.css';
4
4
  /*! @flatjs/forge MIT @flatbiz/antd */
5
- import e from"@ant-design/icons/es/icons/CloseCircleFilled";import i from"@ant-design/icons/es/icons/DeleteOutlined";import{hooks as o}from"@wove/react/cjs/hooks";import{useState as r,useRef as n,Fragment as s}from"react";import{IconWrapper as t}from"../icon-wrapper/index.js";import{jsx as c}from"react/jsx-runtime";import"../_rollupPluginBabelHelpers-a0769acd.js";import"@dimjs/utils/cjs/class-names";import"@dimjs/lang/cjs/is-undefined";import"antd";var l=function l(m){var a=r(false),u=a[0],f=a[1];var p=n();var d=o.useDebounceClick((function(){if(!u){f(true);p.current=setTimeout((function(){f(false)}),3e3)}else{clearTimeout(p.current);f(false);m.onDelete()}}),300);if(m.hidden)return c(s,{});return c(t,{className:m.className,style:m.style,icon:!u?m.icon?m.icon:c(i,{}):m.confirmIcon?m.confirmIcon:c(e,{style:{color:"red"}}),onClick:d,size:"small"})};export{l as DeleteNode};
5
+ import e from"@ant-design/icons/es/icons/CloseCircleFilled";import i from"@ant-design/icons/es/icons/DeleteOutlined";import{hooks as o}from"@wove/react/cjs/hooks";import{useState as r,useRef as n,Fragment as s}from"react";import{IconWrapper as t}from"../icon-wrapper/index.js";import{jsx as c}from"react/jsx-runtime";import"../_rollupPluginBabelHelpers-c0dbec57.js";import"@dimjs/utils/cjs/class-names";import"@dimjs/lang/cjs/is-undefined";import"antd";var l=function l(m){var a=r(false),u=a[0],f=a[1];var p=n();var d=o.useDebounceClick((function(){if(!u){f(true);p.current=setTimeout((function(){f(false)}),3e3)}else{clearTimeout(p.current);f(false);m.onDelete()}}),300);if(m.hidden)return c(s,{});return c(t,{className:m.className,style:m.style,icon:!u?m.icon?m.icon:c(i,{}):m.confirmIcon?m.confirmIcon:c(e,{style:{color:"red"}}),onClick:d,size:"small"})};export{l as DeleteNode};
6
6
  //# sourceMappingURL=index.js.map
@@ -9,5 +9,5 @@ import './../fba-utils/index.css';
9
9
  import './../flex-layout/index.css';
10
10
  import './index.css';
11
11
  /*! @flatjs/forge MIT @flatbiz/antd */
12
- import{_ as i}from"../_rollupPluginBabelHelpers-a0769acd.js";import{dialogConfirm as o}from"../dialog-confirm/index.js";import"@dimjs/utils/cjs/class-names";import"../dialog-modal/index.js";import"@dimjs/lang/cjs/is-string";import"@dimjs/lang/cjs/is-promise";import"@wove/react/cjs/hooks";import"@flatbiz/utils";import"ahooks";import"antd";import"react";import"react-dom/client";import"../button-wrapper/index.js";import"@ant-design/icons/es/icons/LoadingOutlined";import"../index-7f4ad045.js";import"antd/es/locale/en_US";import"antd/es/locale/zh_CN";import"dayjs";import"dayjs/locale/en";import"dayjs/locale/zh-cn";import"dayjs/plugin/advancedFormat";import"dayjs/plugin/customParseFormat";import"dayjs/plugin/localeData";import"dayjs/plugin/utc";import"dayjs/plugin/weekday";import"dayjs/plugin/weekOfYear";import"dayjs/plugin/weekYear";import"../fba-hooks/index.js";import"@dimjs/lang/cjs/is-array";import"../use-responsive-point-21b8c601.js";import"@dimjs/utils/cjs/extend";import"react/jsx-runtime";import"../fba-utils/index.js";import"@dimjs/model";import"../flex-layout/index.js";import"@wove/react/cjs/create-ctx";var t={open:function t(r){return o.open(i({okText:"确定",cancelHidden:true,maskClosable:false},r,{onOk:r.onClick}))}};export{t as dialogAlert};
12
+ import{_ as i}from"../_rollupPluginBabelHelpers-c0dbec57.js";import{dialogConfirm as o}from"../dialog-confirm/index.js";import"@dimjs/utils/cjs/class-names";import"../dialog-modal/index.js";import"@dimjs/lang/cjs/is-string";import"@dimjs/lang/cjs/is-promise";import"@wove/react/cjs/hooks";import"@flatbiz/utils";import"ahooks";import"antd";import"react";import"react-dom/client";import"../button-wrapper/index.js";import"@ant-design/icons/es/icons/LoadingOutlined";import"../index-83bede1b.js";import"antd/es/locale/en_US";import"antd/es/locale/zh_CN";import"dayjs";import"dayjs/locale/en";import"dayjs/locale/zh-cn";import"dayjs/plugin/advancedFormat";import"dayjs/plugin/customParseFormat";import"dayjs/plugin/localeData";import"dayjs/plugin/utc";import"dayjs/plugin/weekday";import"dayjs/plugin/weekOfYear";import"dayjs/plugin/weekYear";import"../fba-hooks/index.js";import"@dimjs/lang/cjs/is-array";import"../use-responsive-point-21b8c601.js";import"@dimjs/utils/cjs/extend";import"react/jsx-runtime";import"../fba-utils/index.js";import"@dimjs/model";import"../flex-layout/index.js";import"@wove/react/cjs/create-ctx";var t={open:function t(r){return o.open(i({okText:"确定",cancelHidden:true,maskClosable:false},r,{onOk:r.onClick}))}};export{t as dialogAlert};
13
13
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["@flatbiz/antd/src/dialog-alert/dialog-alert.tsx"],"sourcesContent":["import { dialogConfirm } from '../dialog-confirm';\nimport { DialogModalProps } from '../dialog-modal';\n\nexport type DialogAlertProps = Omit<\n DialogModalProps,\n 'onOk' | 'cancelHidden' | 'cancelButtonProps' | 'onCancel' | 'onClick'\n> & {\n onClick?: (e: React.MouseEvent<HTMLElement>) => void | Promise<void>;\n};\n\n/**\n * 确认弹框\n * ```\n * 1. 可嵌套使用\n * 2. 为什么不推荐使用\n * dialogAlert.open 打开的内容无法适配兼容自定义主题、无法适配兼容旧版浏览器、无法兼容国际化\n * 适配兼容旧版浏览器(https://ant-design.antgroup.com/docs/react/compatible-style-cn)\n * 3. 需要修改默认主题风格的场景,请使用\n * const { appDialogAlert } = FbaApp.useDialogAlert();\n * appDialogAlert.open({})\n * ```\n */\nexport const dialogAlert = {\n open: (props: DialogAlertProps) => {\n return dialogConfirm.open({\n okText: '确定',\n cancelHidden: true,\n maskClosable: false,\n ...props,\n onOk: props.onClick,\n } as DialogModalProps);\n },\n};\n"],"names":["dialogAlert","open","props","dialogConfirm","_extends","okText","cancelHidden","maskClosable","onOk","onClick"],"mappings":";mmCAsBO,IAAMA,EAAc,CACzBC,KAAM,SAAAA,EAACC,GACL,OAAOC,EAAcF,KAAIG,EAAA,CACvBC,OAAQ,KACRC,aAAc,KACdC,aAAc,OACXL,EAAK,CACRM,KAAMN,EAAMO,UAEhB"}
1
+ {"version":3,"file":"index.js","sources":["@flatbiz/antd/src/dialog-alert/dialog-alert.tsx"],"sourcesContent":["import { dialogConfirm } from '../dialog-confirm';\nimport { DialogModalProps } from '../dialog-modal';\n\nexport type DialogAlertProps = Omit<\n DialogModalProps,\n 'onOk' | 'cancelHidden' | 'cancelButtonProps' | 'onCancel' | 'onClick'\n> & {\n onClick?: (e: React.MouseEvent<HTMLElement>) => void | Promise<void>;\n};\n\n/**\n * 确认弹框\n * ```\n * 1. 可嵌套使用\n * 2. 为什么不推荐使用\n * dialogAlert.open 打开的内容无法适配兼容自定义主题、无法适配兼容旧版浏览器、无法兼容国际化\n * 适配兼容旧版浏览器(https://ant-design.antgroup.com/docs/react/compatible-style-cn)\n * 3. 需要修改默认主题风格的场景,请使用\n * const { appDialogAlert } = FbaApp.useDialogAlert();\n * appDialogAlert.open({})\n * ```\n */\nexport const dialogAlert = {\n open: (props: DialogAlertProps) => {\n return dialogConfirm.open({\n okText: '确定',\n cancelHidden: true,\n maskClosable: false,\n ...props,\n onOk: props.onClick,\n } as DialogModalProps);\n },\n};\n"],"names":["dialogAlert","open","props","dialogConfirm","_extends","okText","cancelHidden","maskClosable","onOk","onClick"],"mappings":";mmCAsBO,IAAMA,EAAc,CACzBC,KAAM,SAANA,EAAOC,GACL,OAAOC,EAAcF,KAAIG,EAAA,CACvBC,OAAQ,KACRC,aAAc,KACdC,aAAc,OACXL,EAAK,CACRM,KAAMN,EAAMO,UAEhB"}
@@ -8,5 +8,5 @@ import './../fba-utils/index.css';
8
8
  import './../flex-layout/index.css';
9
9
  import './index.css';
10
10
  /*! @flatjs/forge MIT @flatbiz/antd */
11
- import{_ as i}from"../_rollupPluginBabelHelpers-a0769acd.js";import{classNames as o}from"@dimjs/utils/cjs/class-names";import{dialogModal as t}from"../dialog-modal/index.js";import"@dimjs/lang/cjs/is-string";import"@dimjs/lang/cjs/is-promise";import"@wove/react/cjs/hooks";import"@flatbiz/utils";import"ahooks";import"antd";import"react";import"react-dom/client";import"../button-wrapper/index.js";import"@ant-design/icons/es/icons/LoadingOutlined";import"../index-7f4ad045.js";import"antd/es/locale/en_US";import"antd/es/locale/zh_CN";import"dayjs";import"dayjs/locale/en";import"dayjs/locale/zh-cn";import"dayjs/plugin/advancedFormat";import"dayjs/plugin/customParseFormat";import"dayjs/plugin/localeData";import"dayjs/plugin/utc";import"dayjs/plugin/weekday";import"dayjs/plugin/weekOfYear";import"dayjs/plugin/weekYear";import"../fba-hooks/index.js";import"@dimjs/lang/cjs/is-array";import"../use-responsive-point-21b8c601.js";import"@dimjs/utils/cjs/extend";import"react/jsx-runtime";import"../fba-utils/index.js";import"@dimjs/model";import"../flex-layout/index.js";import"@wove/react/cjs/create-ctx";var s={open:function s(r){var e=o("v-dialog-confirm",r.className);return t.open(i({width:350,okText:"确定",cancelText:"取消",maskClosable:true,size:null},r,{className:e}))}};export{s as dialogConfirm};
11
+ import{_ as i}from"../_rollupPluginBabelHelpers-c0dbec57.js";import{classNames as o}from"@dimjs/utils/cjs/class-names";import{dialogModal as t}from"../dialog-modal/index.js";import"@dimjs/lang/cjs/is-string";import"@dimjs/lang/cjs/is-promise";import"@wove/react/cjs/hooks";import"@flatbiz/utils";import"ahooks";import"antd";import"react";import"react-dom/client";import"../button-wrapper/index.js";import"@ant-design/icons/es/icons/LoadingOutlined";import"../index-83bede1b.js";import"antd/es/locale/en_US";import"antd/es/locale/zh_CN";import"dayjs";import"dayjs/locale/en";import"dayjs/locale/zh-cn";import"dayjs/plugin/advancedFormat";import"dayjs/plugin/customParseFormat";import"dayjs/plugin/localeData";import"dayjs/plugin/utc";import"dayjs/plugin/weekday";import"dayjs/plugin/weekOfYear";import"dayjs/plugin/weekYear";import"../fba-hooks/index.js";import"@dimjs/lang/cjs/is-array";import"../use-responsive-point-21b8c601.js";import"@dimjs/utils/cjs/extend";import"react/jsx-runtime";import"../fba-utils/index.js";import"@dimjs/model";import"../flex-layout/index.js";import"@wove/react/cjs/create-ctx";var s={open:function s(r){var e=o("v-dialog-confirm",r.className);return t.open(i({width:350,okText:"确定",cancelText:"取消",maskClosable:true,size:null},r,{className:e}))}};export{s as dialogConfirm};
12
12
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["@flatbiz/antd/src/dialog-confirm/dialog-confirm.tsx"],"sourcesContent":["import { classNames } from '@dimjs/utils';\nimport { dialogModal, DialogModalProps } from '../dialog-modal';\nimport './style.less';\n\n/**\n * 确认弹框\n * ```\n * 1. 可嵌套使用\n * 2. 为什么不推荐使用\n * dialogConfirm.open 打开的内容无法适配兼容自定义主题、无法适配兼容旧版浏览器、无法兼容国际化\n * 适配兼容旧版浏览器(https://ant-design.antgroup.com/docs/react/compatible-style-cn)\n * 3. 需要修改默认主题风格的场景,请使用\n * const { appDialogConfirm } = FbaApp.useDialogConfirm();\n * appDialogConfirm.open({})\n * ```\n */\nexport const dialogConfirm = {\n open: (props: DialogModalProps) => {\n const className = classNames('v-dialog-confirm', props.className);\n return dialogModal.open({\n width: 350,\n okText: '确定',\n cancelText: '取消',\n maskClosable: true,\n size: null,\n ...props,\n className,\n });\n },\n};\n"],"names":["dialogConfirm","open","props","className","_classNames","dialogModal","_extends","width","okText","cancelText","maskClosable","size"],"mappings":";mlCAgBO,IAAMA,EAAgB,CAC3BC,KAAM,SAAAA,EAACC,GACL,IAAMC,EAAYC,EAAW,mBAAoBF,EAAMC,WACvD,OAAOE,EAAYJ,KAAIK,EAAA,CACrBC,MAAO,IACPC,OAAQ,KACRC,WAAY,KACZC,aAAc,KACdC,KAAM,MACHT,EAAK,CACRC,UAAAA,IAEJ"}
1
+ {"version":3,"file":"index.js","sources":["@flatbiz/antd/src/dialog-confirm/dialog-confirm.tsx"],"sourcesContent":["import { classNames } from '@dimjs/utils';\nimport { dialogModal, DialogModalProps } from '../dialog-modal';\nimport './style.less';\n\n/**\n * 确认弹框\n * ```\n * 1. 可嵌套使用\n * 2. 为什么不推荐使用\n * dialogConfirm.open 打开的内容无法适配兼容自定义主题、无法适配兼容旧版浏览器、无法兼容国际化\n * 适配兼容旧版浏览器(https://ant-design.antgroup.com/docs/react/compatible-style-cn)\n * 3. 需要修改默认主题风格的场景,请使用\n * const { appDialogConfirm } = FbaApp.useDialogConfirm();\n * appDialogConfirm.open({})\n * ```\n */\nexport const dialogConfirm = {\n open: (props: DialogModalProps) => {\n const className = classNames('v-dialog-confirm', props.className);\n return dialogModal.open({\n width: 350,\n okText: '确定',\n cancelText: '取消',\n maskClosable: true,\n size: null,\n ...props,\n className,\n });\n },\n};\n"],"names":["dialogConfirm","open","props","className","_classNames","dialogModal","_extends","width","okText","cancelText","maskClosable","size"],"mappings":";mlCAgBO,IAAMA,EAAgB,CAC3BC,KAAM,SAANA,EAAOC,GACL,IAAMC,EAAYC,EAAW,mBAAoBF,EAAMC,WACvD,OAAOE,EAAYJ,KAAIK,EAAA,CACrBC,MAAO,IACPC,OAAQ,KACRC,WAAY,KACZC,aAAc,KACdC,KAAM,MACHT,EAAK,CACRC,UAAAA,IAEJ"}
@@ -6,5 +6,5 @@ import './../types/index.css';
6
6
  import './../fba-utils/index.css';
7
7
  import './index.css';
8
8
  /*! @flatjs/forge MIT @flatbiz/antd */
9
- import{isString as e}from"@dimjs/lang/cjs/is-string";import{_ as r,a as t}from"../_rollupPluginBabelHelpers-a0769acd.js";import{isPromise as o}from"@dimjs/lang/cjs/is-promise";import{hooks as n}from"@wove/react/cjs/hooks";import{dom as i}from"@flatbiz/utils";import{Form as a,Space as l,Drawer as d}from"antd";import{useState as s,useMemo as c}from"react";import{createRoot as m}from"react-dom/client";import{ButtonWrapper as u}from"../button-wrapper/index.js";import{C as p}from"../index-7f4ad045.js";import{fbaHooks as f}from"../fba-hooks/index.js";import{u as v,C as j}from"../context-1f2093c6.js";import{jsx as h,jsxs as w}from"react/jsx-runtime";import"@ant-design/icons/es/icons/LoadingOutlined";import"@dimjs/utils/cjs/class-names";import"../fba-utils/index.js";import"@dimjs/lang/cjs/is-array";import"@dimjs/model";import"antd/es/locale/en_US";import"antd/es/locale/zh_CN";import"dayjs";import"dayjs/locale/en";import"dayjs/locale/zh-cn";import"dayjs/plugin/advancedFormat";import"dayjs/plugin/customParseFormat";import"dayjs/plugin/localeData";import"dayjs/plugin/utc";import"dayjs/plugin/weekday";import"dayjs/plugin/weekOfYear";import"dayjs/plugin/weekYear";import"@dimjs/utils/cjs/extend";import"../use-responsive-point-21b8c601.js";import"@wove/react/cjs/create-ctx";var x=["divElement","elementId","onOk","onCancel","content","configProviderProps","okText","cancelText","okButtonExtraProps","cancelButtonExtraProps","operatePosition","operateRender","width","okHidden","cancelHidden","extra"];var y=function e(i){var m;var v=i.divElement,y=i.elementId,g=i.onOk,k=i.onCancel,C=i.content,P=i.configProviderProps,b=i.okText,_=i.cancelText,E=i.okButtonExtraProps,B=i.cancelButtonExtraProps,F=i.operatePosition,I=F===void 0?"footer":F,R=i.operateRender,W=i.width,H=i.okHidden,O=i.cancelHidden,D=i.extra,T=t(i,x);var z=s(true),S=z[0],Y=z[1];var A=s(),L=A[0],M=A[1];var N=a.useForm(),U=N[0];var q=f.useResponsivePoint()||"";var G=s({}),J=G[0],K=G[1];var Q=n.useCallbackRef((function(){try{delete window[y]}catch(e){}Y(false)}));f.useEffectCustom((function(){window[y]=Q}),[Q]);var V=n.useCallbackRef((function(e){if(k){var r=k(U,e);if(r&&o(r)){return r.then(Q)}}return Q()}));var X=n.useCallbackRef((function(e){if(g){var r=g(U,e);if(r&&o(r)){return r.then(Q)}}return Q()}));var Z=f.useMemoCustom((function(){if(R){return R(U,J)}var e=H||(E==null?void 0:E.hidden);var t=H||(E==null?void 0:E.hidden);var o=w(l,{children:[t?null:h(u,r({},B,{onClick:V,children:_||"取消"})),e?null:h(u,r({type:"primary"},E,{onClick:X,children:b||"提交"}))]});if(!H||!O){return o}return null}),[J]);var $=typeof D==="function"?D(U):D;var ee=function e(r){M(r)};var re=c((function(){if(!q)return undefined;if(["xs","sm"].includes(q)){return{width:"90%",maxWidth:"90%"}}if(W){return{width:W,maxWidth:"calc(100% - 200px)"}}return{width:"40%",maxWidth:"calc(100% - 200px)"}}),[q,W]);var te=function e(r){K(r)};return h(j,{value:{onClose:Q,updateBodyStyle:ee,rerenderFooter:te},children:h(p,r({},P,{children:h(d,r({maskClosable:true,destroyOnClose:true,onClose:Q,contentWrapperStyle:{maxWidth:re==null?void 0:re.maxWidth},footer:I==="footer"?Z:null},T,{width:re==null?void 0:re.width,styles:r({},T.styles,{body:r({},L,(m=T.styles)==null?void 0:m.body)}),extra:I==="header"?Z:$,open:S,getContainer:v,children:typeof C==="function"?C(U,{onClose:Q}):C}))}))})};var g={open:function e(t){var o=i.bodyAppendDivElement(),n=o.divElement,a=o.elementId;window["__dialog_drawer_elementId"]=a;var l=m(n);l.render(h(y,r({},t,{divElement:n,elementId:a})));return{close:function e(){var r,t;(r=(t=window)[a])==null?void 0:r.call(t)}}},close:function r(){try{var t,o;var n=window["__dialog_drawer_elementId"];if(e(n))(t=(o=window)[n])==null?void 0:t.call(o)}catch(e){}},useDialogDrawer:function e(){var r=v();return{rerenderFooter:function e(t){r.rerenderFooter(t)}}}};export{g as dialogDrawer};
9
+ import{isString as e}from"@dimjs/lang/cjs/is-string";import{_ as r,a as t}from"../_rollupPluginBabelHelpers-c0dbec57.js";import{isPromise as o}from"@dimjs/lang/cjs/is-promise";import{hooks as n}from"@wove/react/cjs/hooks";import{dom as i}from"@flatbiz/utils";import{Form as a,Space as l,Drawer as d}from"antd";import{useState as s,useMemo as c}from"react";import{createRoot as m}from"react-dom/client";import{ButtonWrapper as u}from"../button-wrapper/index.js";import{C as p}from"../index-83bede1b.js";import{fbaHooks as f}from"../fba-hooks/index.js";import{u as v,C as j}from"../context-1f2093c6.js";import{jsx as h,jsxs as w}from"react/jsx-runtime";import"@ant-design/icons/es/icons/LoadingOutlined";import"@dimjs/utils/cjs/class-names";import"../fba-utils/index.js";import"@dimjs/lang/cjs/is-array";import"@dimjs/model";import"antd/es/locale/en_US";import"antd/es/locale/zh_CN";import"dayjs";import"dayjs/locale/en";import"dayjs/locale/zh-cn";import"dayjs/plugin/advancedFormat";import"dayjs/plugin/customParseFormat";import"dayjs/plugin/localeData";import"dayjs/plugin/utc";import"dayjs/plugin/weekday";import"dayjs/plugin/weekOfYear";import"dayjs/plugin/weekYear";import"@dimjs/utils/cjs/extend";import"../use-responsive-point-21b8c601.js";import"@wove/react/cjs/create-ctx";var x=["divElement","elementId","onOk","onCancel","content","configProviderProps","okText","cancelText","okButtonExtraProps","cancelButtonExtraProps","operatePosition","operateRender","width","okHidden","cancelHidden","extra"];var y=function e(i){var m;var v=i.divElement,y=i.elementId,g=i.onOk,k=i.onCancel,C=i.content,P=i.configProviderProps,b=i.okText,_=i.cancelText,E=i.okButtonExtraProps,B=i.cancelButtonExtraProps,F=i.operatePosition,I=F===void 0?"footer":F,R=i.operateRender,W=i.width,H=i.okHidden,O=i.cancelHidden,D=i.extra,T=t(i,x);var z=s(true),S=z[0],Y=z[1];var A=s(),L=A[0],M=A[1];var N=a.useForm(),U=N[0];var q=f.useResponsivePoint()||"";var G=s({}),J=G[0],K=G[1];var Q=n.useCallbackRef((function(){try{delete window[y]}catch(e){}Y(false)}));f.useEffectCustom((function(){window[y]=Q}),[Q]);var V=n.useCallbackRef((function(e){if(k){var r=k(U,e);if(r&&o(r)){return r.then(Q)}}return Q()}));var X=n.useCallbackRef((function(e){if(g){var r=g(U,e);if(r&&o(r)){return r.then(Q)}}return Q()}));var Z=f.useMemoCustom((function(){if(R){return R(U,J)}var e=H||(E==null?void 0:E.hidden);var t=H||(E==null?void 0:E.hidden);var o=w(l,{children:[t?null:h(u,r({},B,{onClick:V,children:_||"取消"})),e?null:h(u,r({type:"primary"},E,{onClick:X,children:b||"提交"}))]});if(!H||!O){return o}return null}),[J]);var $=typeof D==="function"?D(U):D;var ee=function e(r){M(r)};var re=c((function(){if(!q)return undefined;if(["xs","sm"].includes(q)){return{width:"90%",maxWidth:"90%"}}if(W){return{width:W,maxWidth:"calc(100% - 200px)"}}return{width:"40%",maxWidth:"calc(100% - 200px)"}}),[q,W]);var te=function e(r){K(r)};return h(j,{value:{onClose:Q,updateBodyStyle:ee,rerenderFooter:te},children:h(p,r({},P,{children:h(d,r({maskClosable:true,destroyOnClose:true,onClose:Q,contentWrapperStyle:{maxWidth:re==null?void 0:re.maxWidth},footer:I==="footer"?Z:null},T,{width:re==null?void 0:re.width,styles:r({},T.styles,{body:r({},L,(m=T.styles)==null?void 0:m.body)}),extra:I==="header"?Z:$,open:S,getContainer:v,children:typeof C==="function"?C(U,{onClose:Q}):C}))}))})};var g={open:function e(t){var o=i.bodyAppendDivElement(),n=o.divElement,a=o.elementId;window["__dialog_drawer_elementId"]=a;var l=m(n);l.render(h(y,r({},t,{divElement:n,elementId:a})));return{close:function e(){var r,t;(r=(t=window)[a])==null||r.call(t)}}},close:function r(){try{var t,o;var n=window["__dialog_drawer_elementId"];if(e(n))(t=(o=window)[n])==null||t.call(o)}catch(e){}},useDialogDrawer:function e(){var r=v();return{rerenderFooter:function e(t){r.rerenderFooter(t)}}}};export{g as dialogDrawer};
10
10
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["@flatbiz/antd/src/dialog-drawer/dialog-drawer.tsx"],"sourcesContent":["import { isPromise, isString } from '@dimjs/lang';\nimport { dom, TNoopDefine, TPlainObject } from '@flatbiz/utils';\nimport { hooks } from '@wove/react';\nimport { Drawer, DrawerProps, Form, FormInstance, Space } from 'antd';\nimport { CSSProperties, ReactElement, ReactNode, useMemo, useState } from 'react';\nimport { createRoot } from 'react-dom/client';\nimport { ButtonWrapper, ButtonWrapperProps } from '../button-wrapper';\nimport { ConfigProviderWrapper, ConfigProviderWrapperProps } from '../config-provider-wrapper';\nimport { fbaHooks } from '../fba-hooks';\nimport { BodyAppendDivElementProps } from '../_utils/dom';\nimport { CtxProvider, useDialogDrawerCtx } from './context';\n\nexport type DialogDrawerProps = Omit<\n DrawerProps,\n 'onOk' | 'onCancel' | 'getContainer' | 'open' | 'open' | 'footer' | 'extra'\n> & {\n okText?: string | ReactElement;\n cancelText?: string | ReactElement;\n onOk?: (form: FormInstance, e: React.MouseEvent<HTMLElement>) => void | Promise<void>;\n onCancel?: (form: FormInstance, e: React.MouseEvent<HTMLElement>) => void | Promise<void>;\n content: string | ReactElement | ((form: FormInstance, operate: { onClose: TNoopDefine }) => ReactElement);\n configProviderProps?: ConfigProviderWrapperProps;\n\n okButtonExtraProps?: Omit<ButtonWrapperProps, 'onClick' | 'children' | 'loading'>;\n cancelButtonExtraProps?: Omit<ButtonWrapperProps, 'onClick' | 'children'>;\n okHidden?: boolean;\n cancelHidden?: boolean;\n /** 设置操作区域位置 */\n operatePosition?: 'header' | 'footer';\n /** 右上角自定义内容,如果operatePosition=header,此设置无效 */\n extra?: ReactNode | ((form: FormInstance) => ReactElement);\n /**\n * ```\n * 1. 自定义弹框操作区域,通过 operatePosition 配置可以自定义位置\n * 2. extraData 为外部通过 useDialogModal.rerenderFooter 重新渲染footer携带的数据\n * ```\n */\n operateRender?: (form: FormInstance, extraData?: TPlainObject) => ReactElement;\n};\n\nconst ModalRender = (props: BodyAppendDivElementProps & DialogDrawerProps) => {\n const {\n divElement,\n elementId,\n onOk,\n onCancel,\n content,\n configProviderProps,\n okText,\n cancelText,\n okButtonExtraProps,\n cancelButtonExtraProps,\n operatePosition = 'footer',\n operateRender,\n width,\n okHidden,\n cancelHidden,\n extra,\n ...otherProps\n } = props;\n const [open, setOpen] = useState(true);\n const [innerBodyStyle, setInnerBodyStyle] = useState<CSSProperties>();\n const [form] = Form.useForm();\n const screenType = fbaHooks.useResponsivePoint() || '';\n const [footerExtraData, setFooterExtraData] = useState<TPlainObject>({});\n\n const onClose = hooks.useCallbackRef(() => {\n try {\n delete window[elementId];\n } catch (error) {\n //\n }\n setOpen(false);\n });\n\n fbaHooks.useEffectCustom(() => {\n window[elementId] = onClose;\n }, [onClose]);\n\n const onCancelHandle = hooks.useCallbackRef((e) => {\n if (onCancel) {\n const response = onCancel(form, e);\n if (response && isPromise(response)) {\n return response.then(onClose);\n }\n }\n return onClose();\n });\n\n const onOkHandle = hooks.useCallbackRef((e) => {\n if (onOk) {\n const response = onOk(form, e);\n if (response && isPromise(response)) {\n return response.then(onClose);\n }\n }\n return onClose();\n });\n\n const newOperateRender = fbaHooks.useMemoCustom(() => {\n if (operateRender) {\n return operateRender(form, footerExtraData);\n }\n\n const okHiddenNew = okHidden || okButtonExtraProps?.hidden;\n const cancelHiddenNew = okHidden || okButtonExtraProps?.hidden;\n\n const operateGroup = (\n <Space>\n {cancelHiddenNew ? null : (\n <ButtonWrapper {...cancelButtonExtraProps} onClick={onCancelHandle}>\n {cancelText || '取消'}\n </ButtonWrapper>\n )}\n {okHiddenNew ? null : (\n <ButtonWrapper type=\"primary\" {...okButtonExtraProps} onClick={onOkHandle}>\n {okText || '提交'}\n </ButtonWrapper>\n )}\n </Space>\n );\n if (!okHidden || !cancelHidden) {\n return operateGroup;\n }\n return null;\n }, [footerExtraData]);\n\n const extraRender = typeof extra === 'function' ? extra(form) : extra;\n\n const updateBodyStyle = (bodyStyle?: CSSProperties) => {\n setInnerBodyStyle(bodyStyle);\n };\n\n const customSize = useMemo(() => {\n if (!screenType) return undefined;\n if (['xs', 'sm'].includes(screenType)) {\n return {\n width: '90%',\n maxWidth: '90%',\n };\n }\n if (width) {\n return { width: width, maxWidth: 'calc(100% - 200px)' };\n }\n return { width: '40%', maxWidth: 'calc(100% - 200px)' };\n }, [screenType, width]);\n\n const rerenderFooter = (data) => {\n setFooterExtraData(data);\n };\n\n return (\n <CtxProvider value={{ onClose, updateBodyStyle, rerenderFooter }}>\n <ConfigProviderWrapper {...configProviderProps}>\n <Drawer\n maskClosable={true}\n destroyOnClose\n onClose={onClose}\n // 5.13.0 新增 styles.wrapper,并废弃 contentWrapperStyle drawerStyle maskStyle 属性\n contentWrapperStyle={{ maxWidth: customSize?.maxWidth }}\n footer={operatePosition === 'footer' ? newOperateRender : null}\n {...otherProps}\n width={customSize?.width}\n styles={{\n ...otherProps.styles,\n body: { ...innerBodyStyle, ...otherProps.styles?.body },\n // wrapper: {\n // maxWidth: customSize?.maxWidth,\n // ...otherProps.styles?.wrapper,\n // },\n }}\n extra={operatePosition === 'header' ? newOperateRender : extraRender}\n open={open}\n getContainer={divElement}\n >\n {typeof content === 'function' ? content(form, { onClose }) : content}\n </Drawer>\n </ConfigProviderWrapper>\n </CtxProvider>\n );\n};\n\n/**\n * 抽屉弹框\n * ```\n * 1. 可嵌套使用\n * 2. 为什么不推荐使用\n * dialogDrawer.open 打开的内容无法适配兼容自定义主题、无法适配兼容旧版浏览器、无法兼容国际化\n * 适配兼容旧版浏览器(https://ant-design.antgroup.com/docs/react/compatible-style-cn)\n * 3. 需要修改默认主题风格的场景,请使用\n * const { appDialogDrawer } = FbaApp.useDialogDrawer();\n * appDialogDrawer.open({})\n * ```\n */\nexport const dialogDrawer = {\n open: (props: DialogDrawerProps) => {\n const { divElement, elementId } = dom.bodyAppendDivElement();\n window['__dialog_drawer_elementId'] = elementId;\n const root = createRoot(divElement);\n root.render(<ModalRender {...props} divElement={divElement} elementId={elementId} />);\n return {\n close: () => {\n window[elementId]?.();\n },\n };\n },\n /**\n * ```\n * 1. 关闭最新弹框,如果有多个弹框只能关闭最后一个\n * 2. 多个弹框主动关闭,只能使用 dialogDrawer.open()返回值中的close\n * ```\n */\n close: () => {\n try {\n const elementId = window['__dialog_drawer_elementId'] as string;\n if (isString(elementId)) window[elementId]?.();\n } catch (error) {\n //\n }\n },\n /**\n * ```\n * 1. rerenderFooter 携带指定数据重新渲染 footer,可用于切换footer中的按钮状态\n * ```\n */\n useDialogDrawer: () => {\n const ctx = useDialogDrawerCtx();\n return {\n /** 重新渲染 footer, data为携带的数据,是footer的第二个参数 */\n rerenderFooter: (data?: TPlainObject) => {\n ctx.rerenderFooter(data);\n },\n };\n },\n};\n"],"names":["ModalRender","props","_otherProps$styles","divElement","elementId","onOk","onCancel","content","configProviderProps","okText","cancelText","okButtonExtraProps","cancelButtonExtraProps","_props$operatePositio","operatePosition","operateRender","width","okHidden","cancelHidden","extra","otherProps","_objectWithoutPropertiesLoose","_excluded","_useState","useState","open","setOpen","_useState2","innerBodyStyle","setInnerBodyStyle","_Form$useForm","Form","useForm","form","screenType","fbaHooks","useResponsivePoint","_useState3","footerExtraData","setFooterExtraData","onClose","_hooks","useCallbackRef","window","error","useEffectCustom","onCancelHandle","e","response","_isPromise","then","onOkHandle","newOperateRender","useMemoCustom","okHiddenNew","hidden","cancelHiddenNew","operateGroup","_jsxs","Space","children","_jsx","ButtonWrapper","_extends","onClick","type","extraRender","updateBodyStyle","bodyStyle","customSize","useMemo","undefined","includes","maxWidth","rerenderFooter","data","CtxProvider","value","ConfigProviderWrapper","Drawer","maskClosable","destroyOnClose","contentWrapperStyle","footer","styles","body","getContainer","dialogDrawer","_dom$bodyAppendDivEle","dom","bodyAppendDivElement","root","createRoot","render","close","_window$elementId","_window","call","_window$elementId2","_window2","_isString","useDialogDrawer","ctx","useDialogDrawerCtx"],"mappings":";m+CAwCA,IAAMA,EAAc,SAAdA,EAAeC,GAAyD,IAAAC,EAC5E,IACEC,EAiBEF,EAjBFE,WACAC,EAgBEH,EAhBFG,UACAC,EAeEJ,EAfFI,KACAC,EAcEL,EAdFK,SACAC,EAaEN,EAbFM,QACAC,EAYEP,EAZFO,oBACAC,EAWER,EAXFQ,OACAC,EAUET,EAVFS,WACAC,EASEV,EATFU,mBACAC,EAQEX,EARFW,uBAAsBC,EAQpBZ,EAPFa,gBAAAA,EAAeD,SAAG,EAAA,SAAQA,EAC1BE,EAMEd,EANFc,cACAC,EAKEf,EALFe,MACAC,EAIEhB,EAJFgB,SACAC,EAGEjB,EAHFiB,aACAC,EAEElB,EAFFkB,MACGC,EAAUC,EACXpB,EAAKqB,GACT,IAAAC,EAAwBC,EAAS,MAA1BC,EAAIF,EAAA,GAAEG,EAAOH,EAAA,GACpB,IAAAI,EAA4CH,IAArCI,EAAcD,EAAA,GAAEE,EAAiBF,EAAA,GACxC,IAAAG,EAAeC,EAAKC,UAAbC,EAAIH,EAAA,GACX,IAAMI,EAAaC,EAASC,sBAAwB,GACpD,IAAAC,EAA8Cb,EAAuB,IAA9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,EAAK,CAAEE,WAAYA,EAAYC,UAAWA,MACvE,MAAO,CACL0F,MAAO,SAAAA,IAAM,IAAAC,EAAAC,GACXD,GAAAC,EAAArD,QAAOvC,KAAU,UAAA,EAAjB2F,EAAAE,KAAAD,EACF,EAEH,EAODF,MAAO,SAAAA,IACL,IAAI,IAAAI,EAAAC,EACF,IAAM/F,EAAYuC,OAAO,6BACzB,GAAIyD,EAAShG,IAAY8F,GAAAC,EAAAxD,QAAOvC,KAAP8F,UAAAA,EAAAA,EAAAD,KAAAE,EAC1B,CAAC,MAAOvD,GACP,CAEH,EAMDyD,gBAAiB,SAAAA,IACf,IAAMC,EAAMC,IACZ,MAAO,CAEL7B,eAAgB,SAAAA,EAACC,GACf2B,EAAI5B,eAAeC,EACrB,EAEJ"}
1
+ {"version":3,"file":"index.js","sources":["@flatbiz/antd/src/dialog-drawer/dialog-drawer.tsx"],"sourcesContent":["import { isPromise, isString } from '@dimjs/lang';\nimport { dom, TNoopDefine, TPlainObject } from '@flatbiz/utils';\nimport { hooks } from '@wove/react';\nimport { Drawer, DrawerProps, Form, FormInstance, Space } from 'antd';\nimport { CSSProperties, ReactElement, ReactNode, useMemo, useState } from 'react';\nimport { createRoot } from 'react-dom/client';\nimport { ButtonWrapper, ButtonWrapperProps } from '../button-wrapper';\nimport { ConfigProviderWrapper, ConfigProviderWrapperProps } from '../config-provider-wrapper';\nimport { fbaHooks } from '../fba-hooks';\nimport { BodyAppendDivElementProps } from '../_utils/dom';\nimport { CtxProvider, useDialogDrawerCtx } from './context';\n\nexport type DialogDrawerProps = Omit<\n DrawerProps,\n 'onOk' | 'onCancel' | 'getContainer' | 'open' | 'open' | 'footer' | 'extra'\n> & {\n okText?: string | ReactElement;\n cancelText?: string | ReactElement;\n onOk?: (form: FormInstance, e: React.MouseEvent<HTMLElement>) => void | Promise<void>;\n onCancel?: (form: FormInstance, e: React.MouseEvent<HTMLElement>) => void | Promise<void>;\n content: string | ReactElement | ((form: FormInstance, operate: { onClose: TNoopDefine }) => ReactElement);\n configProviderProps?: ConfigProviderWrapperProps;\n\n okButtonExtraProps?: Omit<ButtonWrapperProps, 'onClick' | 'children' | 'loading'>;\n cancelButtonExtraProps?: Omit<ButtonWrapperProps, 'onClick' | 'children'>;\n okHidden?: boolean;\n cancelHidden?: boolean;\n /** 设置操作区域位置 */\n operatePosition?: 'header' | 'footer';\n /** 右上角自定义内容,如果operatePosition=header,此设置无效 */\n extra?: ReactNode | ((form: FormInstance) => ReactElement);\n /**\n * ```\n * 1. 自定义弹框操作区域,通过 operatePosition 配置可以自定义位置\n * 2. extraData 为外部通过 useDialogModal.rerenderFooter 重新渲染footer携带的数据\n * ```\n */\n operateRender?: (form: FormInstance, extraData?: TPlainObject) => ReactElement;\n};\n\nconst ModalRender = (props: BodyAppendDivElementProps & DialogDrawerProps) => {\n const {\n divElement,\n elementId,\n onOk,\n onCancel,\n content,\n configProviderProps,\n okText,\n cancelText,\n okButtonExtraProps,\n cancelButtonExtraProps,\n operatePosition = 'footer',\n operateRender,\n width,\n okHidden,\n cancelHidden,\n extra,\n ...otherProps\n } = props;\n const [open, setOpen] = useState(true);\n const [innerBodyStyle, setInnerBodyStyle] = useState<CSSProperties>();\n const [form] = Form.useForm();\n const screenType = fbaHooks.useResponsivePoint() || '';\n const [footerExtraData, setFooterExtraData] = useState<TPlainObject>({});\n\n const onClose = hooks.useCallbackRef(() => {\n try {\n delete window[elementId];\n } catch (error) {\n //\n }\n setOpen(false);\n });\n\n fbaHooks.useEffectCustom(() => {\n window[elementId] = onClose;\n }, [onClose]);\n\n const onCancelHandle = hooks.useCallbackRef((e) => {\n if (onCancel) {\n const response = onCancel(form, e);\n if (response && isPromise(response)) {\n return response.then(onClose);\n }\n }\n return onClose();\n });\n\n const onOkHandle = hooks.useCallbackRef((e) => {\n if (onOk) {\n const response = onOk(form, e);\n if (response && isPromise(response)) {\n return response.then(onClose);\n }\n }\n return onClose();\n });\n\n const newOperateRender = fbaHooks.useMemoCustom(() => {\n if (operateRender) {\n return operateRender(form, footerExtraData);\n }\n\n const okHiddenNew = okHidden || okButtonExtraProps?.hidden;\n const cancelHiddenNew = okHidden || okButtonExtraProps?.hidden;\n\n const operateGroup = (\n <Space>\n {cancelHiddenNew ? null : (\n <ButtonWrapper {...cancelButtonExtraProps} onClick={onCancelHandle}>\n {cancelText || '取消'}\n </ButtonWrapper>\n )}\n {okHiddenNew ? null : (\n <ButtonWrapper type=\"primary\" {...okButtonExtraProps} onClick={onOkHandle}>\n {okText || '提交'}\n </ButtonWrapper>\n )}\n </Space>\n );\n if (!okHidden || !cancelHidden) {\n return operateGroup;\n }\n return null;\n }, [footerExtraData]);\n\n const extraRender = typeof extra === 'function' ? extra(form) : extra;\n\n const updateBodyStyle = (bodyStyle?: CSSProperties) => {\n setInnerBodyStyle(bodyStyle);\n };\n\n const customSize = useMemo(() => {\n if (!screenType) return undefined;\n if (['xs', 'sm'].includes(screenType)) {\n return {\n width: '90%',\n maxWidth: '90%',\n };\n }\n if (width) {\n return { width: width, maxWidth: 'calc(100% - 200px)' };\n }\n return { width: '40%', maxWidth: 'calc(100% - 200px)' };\n }, [screenType, width]);\n\n const rerenderFooter = (data) => {\n setFooterExtraData(data);\n };\n\n return (\n <CtxProvider value={{ onClose, updateBodyStyle, rerenderFooter }}>\n <ConfigProviderWrapper {...configProviderProps}>\n <Drawer\n maskClosable={true}\n destroyOnClose\n onClose={onClose}\n // 5.13.0 新增 styles.wrapper,并废弃 contentWrapperStyle drawerStyle maskStyle 属性\n contentWrapperStyle={{ maxWidth: customSize?.maxWidth }}\n footer={operatePosition === 'footer' ? newOperateRender : null}\n {...otherProps}\n width={customSize?.width}\n styles={{\n ...otherProps.styles,\n body: { ...innerBodyStyle, ...otherProps.styles?.body },\n // wrapper: {\n // maxWidth: customSize?.maxWidth,\n // ...otherProps.styles?.wrapper,\n // },\n }}\n extra={operatePosition === 'header' ? newOperateRender : extraRender}\n open={open}\n getContainer={divElement}\n >\n {typeof content === 'function' ? content(form, { onClose }) : content}\n </Drawer>\n </ConfigProviderWrapper>\n </CtxProvider>\n );\n};\n\n/**\n * 抽屉弹框\n * ```\n * 1. 可嵌套使用\n * 2. 为什么不推荐使用\n * dialogDrawer.open 打开的内容无法适配兼容自定义主题、无法适配兼容旧版浏览器、无法兼容国际化\n * 适配兼容旧版浏览器(https://ant-design.antgroup.com/docs/react/compatible-style-cn)\n * 3. 需要修改默认主题风格的场景,请使用\n * const { appDialogDrawer } = FbaApp.useDialogDrawer();\n * appDialogDrawer.open({})\n * ```\n */\nexport const dialogDrawer = {\n open: (props: DialogDrawerProps) => {\n const { divElement, elementId } = dom.bodyAppendDivElement();\n window['__dialog_drawer_elementId'] = elementId;\n const root = createRoot(divElement);\n root.render(<ModalRender {...props} divElement={divElement} elementId={elementId} />);\n return {\n close: () => {\n window[elementId]?.();\n },\n };\n },\n /**\n * ```\n * 1. 关闭最新弹框,如果有多个弹框只能关闭最后一个\n * 2. 多个弹框主动关闭,只能使用 dialogDrawer.open()返回值中的close\n * ```\n */\n close: () => {\n try {\n const elementId = window['__dialog_drawer_elementId'] as string;\n if (isString(elementId)) window[elementId]?.();\n } catch (error) {\n //\n }\n },\n /**\n * ```\n * 1. rerenderFooter 携带指定数据重新渲染 footer,可用于切换footer中的按钮状态\n * ```\n */\n useDialogDrawer: () => {\n const ctx = useDialogDrawerCtx();\n return {\n /** 重新渲染 footer, data为携带的数据,是footer的第二个参数 */\n rerenderFooter: (data?: TPlainObject) => {\n ctx.rerenderFooter(data);\n },\n };\n },\n};\n"],"names":["ModalRender","props","_otherProps$styles","divElement","elementId","onOk","onCancel","content","configProviderProps","okText","cancelText","okButtonExtraProps","cancelButtonExtraProps","_props$operatePositio","operatePosition","operateRender","width","okHidden","cancelHidden","extra","otherProps","_objectWithoutPropertiesLoose","_excluded","_useState","useState","open","setOpen","_useState2","innerBodyStyle","setInnerBodyStyle","_Form$useForm","Form","useForm","form","screenType","fbaHooks","useResponsivePoint","_useState3","footerExtraData","setFooterExtraData","onClose","_hooks","useCallbackRef","window","error","useEffectCustom","onCancelHandle","e","response","_isPromise","then","onOkHandle","newOperateRender","useMemoCustom","okHiddenNew","hidden","cancelHiddenNew","operateGroup","_jsxs","Space","children","_jsx","ButtonWrapper","_extends","onClick","type","extraRender","updateBodyStyle","bodyStyle","customSize","useMemo","undefined","includes","maxWidth","rerenderFooter","data","CtxProvider","value","ConfigProviderWrapper","Drawer","maskClosable","destroyOnClose","contentWrapperStyle","footer","styles","body","getContainer","dialogDrawer","_dom$bodyAppendDivEle","dom","bodyAppendDivElement","root","createRoot","render","close","_window$elementId","_window","call","_window$elementId2","_window2","_isString","useDialogDrawer","ctx","useDialogDrawerCtx"],"mappings":";m+CAwCA,IAAMA,EAAc,SAAdA,EAAeC,GAAyD,IAAAC,EAC5E,IACEC,EAiBEF,EAjBFE,WACAC,EAgBEH,EAhBFG,UACAC,EAeEJ,EAfFI,KACAC,EAcEL,EAdFK,SACAC,EAaEN,EAbFM,QACAC,EAYEP,EAZFO,oBACAC,EAWER,EAXFQ,OACAC,EAUET,EAVFS,WACAC,EASEV,EATFU,mBACAC,EAQEX,EARFW,uBAAsBC,EAQpBZ,EAPFa,gBAAAA,EAAeD,SAAG,EAAA,SAAQA,EAC1BE,EAMEd,EANFc,cACAC,EAKEf,EALFe,MACAC,EAIEhB,EAJFgB,SACAC,EAGEjB,EAHFiB,aACAC,EAEElB,EAFFkB,MACGC,EAAUC,EACXpB,EAAKqB,GACT,IAAAC,EAAwBC,EAAS,MAA1BC,EAAIF,EAAA,GAAEG,EAAOH,EAAA,GACpB,IAAAI,EAA4CH,IAArCI,EAAcD,EAAA,GAAEE,EAAiBF,EAAA,GACxC,IAAAG,EAAeC,EAAKC,UAAbC,EAAIH,EAAA,GACX,IAAMI,EAAaC,EAASC,sBAAwB,GACpD,IAAAC,EAA8Cb,EAAuB,IAA9Dc,EAAeD,EAAA,GAAEE,EAAkBF,EAAA,GAE1C,IAAMG,EAAUC,EAAMC,gBAAe,WACnC,WACSC,OAAOv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,GAAAC,EAAArD,QAAOvC,KAAU,MAAjB2F,EAAAE,KAAAD,EACF,EAEH,EAODF,MAAO,SAAPA,IACE,IAAI,IAAAI,EAAAC,EACF,IAAM/F,EAAYuC,OAAO,6BACzB,GAAIyD,EAAShG,IAAY8F,GAAAC,EAAAxD,QAAOvC,KAAP8F,MAAAA,EAAAD,KAAAE,EAC1B,CAAC,MAAOvD,GACP,CAEH,EAMDyD,gBAAiB,SAAjBA,IACE,IAAMC,EAAMC,IACZ,MAAO,CAEL7B,eAAgB,SAAhBA,EAAiBC,GACf2B,EAAI5B,eAAeC,EACrB,EAEJ"}
@@ -6,5 +6,5 @@ import './../types/index.css';
6
6
  import './../fba-utils/index.css';
7
7
  import './index.css';
8
8
  /*! @flatjs/forge MIT @flatbiz/antd */
9
- import{_ as r}from"../_rollupPluginBabelHelpers-a0769acd.js";import{isPromise as e}from"@dimjs/lang/cjs/is-promise";import{hooks as o}from"@wove/react/cjs/hooks";import{Space as i}from"antd";import{ButtonWrapper as t}from"../button-wrapper/index.js";import{u as a}from"../context-1f2093c6.js";import{fbaHooks as n}from"../fba-hooks/index.js";import{jsxs as l,jsx as s}from"react/jsx-runtime";import"@ant-design/icons/es/icons/LoadingOutlined";import"@dimjs/utils/cjs/class-names";import"@flatbiz/utils";import"react";import"../index-7f4ad045.js";import"antd/es/locale/en_US";import"antd/es/locale/zh_CN";import"dayjs";import"dayjs/locale/en";import"dayjs/locale/zh-cn";import"dayjs/plugin/advancedFormat";import"dayjs/plugin/customParseFormat";import"dayjs/plugin/localeData";import"dayjs/plugin/utc";import"dayjs/plugin/weekday";import"dayjs/plugin/weekOfYear";import"dayjs/plugin/weekYear";import"@dimjs/utils/cjs/extend";import"../fba-utils/index.js";import"@dimjs/lang/cjs/is-array";import"@dimjs/model";import"../use-responsive-point-21b8c601.js";import"@wove/react/cjs/create-ctx";var d=function d(m){var p=a();var c=p.onClose;n.useEffectCustom((function(){p.updateBodyStyle({padding:0})}),[]);var u=m.okHidden,j=m.onCancel,f=m.onOk,y=m.cancelHidden,v=m.cancelText,g=m.okText,h=m.okButtonExtraProps,k=m.cancelButtonExtraProps,x=m.footer;var w=o.useCallbackRef((function(r){if(j){var o=j(r);if(o&&e(o)){return o.then(c)}}return c()}));var C=o.useCallbackRef((function(r){if(f){var o=f(r);if(o&&e(o)){return o.then(c)}}return c()}));var b=l(i,{children:[y||k!=null&&k.hidden?null:s(t,r({},k,{onClick:w,children:v||"取消"})),u||h!=null&&h.hidden?null:s(t,r({type:"primary"},h,{onClick:C,children:g||"提交"}))]});return l("div",{className:"dialog-drawer-content-wrapper",children:[s("div",{className:"dialog-drawer-content",children:m.children}),s("div",{className:"dialog-drawer-footer",style:m.footerStyle,children:(x==null?void 0:x({onClose:c}))||b})]})};export{d as DialogDrawerContent};
9
+ import{_ as r}from"../_rollupPluginBabelHelpers-c0dbec57.js";import{isPromise as e}from"@dimjs/lang/cjs/is-promise";import{hooks as o}from"@wove/react/cjs/hooks";import{Space as i}from"antd";import{ButtonWrapper as t}from"../button-wrapper/index.js";import{u as a}from"../context-1f2093c6.js";import{fbaHooks as n}from"../fba-hooks/index.js";import{jsxs as l,jsx as s}from"react/jsx-runtime";import"@ant-design/icons/es/icons/LoadingOutlined";import"@dimjs/utils/cjs/class-names";import"@flatbiz/utils";import"react";import"../index-83bede1b.js";import"antd/es/locale/en_US";import"antd/es/locale/zh_CN";import"dayjs";import"dayjs/locale/en";import"dayjs/locale/zh-cn";import"dayjs/plugin/advancedFormat";import"dayjs/plugin/customParseFormat";import"dayjs/plugin/localeData";import"dayjs/plugin/utc";import"dayjs/plugin/weekday";import"dayjs/plugin/weekOfYear";import"dayjs/plugin/weekYear";import"@dimjs/utils/cjs/extend";import"../fba-utils/index.js";import"@dimjs/lang/cjs/is-array";import"@dimjs/model";import"../use-responsive-point-21b8c601.js";import"@wove/react/cjs/create-ctx";var d=function d(m){var p=a();var c=p.onClose;n.useEffectCustom((function(){p.updateBodyStyle({padding:0})}),[]);var u=m.okHidden,j=m.onCancel,f=m.onOk,y=m.cancelHidden,v=m.cancelText,g=m.okText,h=m.okButtonExtraProps,k=m.cancelButtonExtraProps,x=m.footer;var w=o.useCallbackRef((function(r){if(j){var o=j(r);if(o&&e(o)){return o.then(c)}}return c()}));var C=o.useCallbackRef((function(r){if(f){var o=f(r);if(o&&e(o)){return o.then(c)}}return c()}));var b=l(i,{children:[y||k!=null&&k.hidden?null:s(t,r({},k,{onClick:w,children:v||"取消"})),u||h!=null&&h.hidden?null:s(t,r({type:"primary"},h,{onClick:C,children:g||"提交"}))]});return l("div",{className:"dialog-drawer-content-wrapper",children:[s("div",{className:"dialog-drawer-content",children:m.children}),s("div",{className:"dialog-drawer-footer",style:m.footerStyle,children:(x==null?void 0:x({onClose:c}))||b})]})};export{d as DialogDrawerContent};
10
10
  //# sourceMappingURL=index.js.map
@@ -2,5 +2,5 @@
2
2
  import './../fba-hooks/index.css';
3
3
  import './index.css';
4
4
  /*! @flatjs/forge MIT @flatbiz/antd */
5
- import{isString as e}from"@dimjs/lang/cjs/is-string";import{_ as o}from"../_rollupPluginBabelHelpers-a0769acd.js";import{classNames as r}from"@dimjs/utils/cjs/class-names";import{hooks as a}from"@wove/react/cjs/hooks";import{theme as l,Modal as i}from"antd";import{useState as n}from"react";import{createRoot as t}from"react-dom/client";import{fbaHooks as s}from"../fba-hooks/index.js";import{b as m,r as d}from"../dom-4d04aa64.js";import{jsx as c,jsxs as f}from"react/jsx-runtime";import"@dimjs/lang/cjs/is-array";import"@flatbiz/utils";import"../use-responsive-point-21b8c601.js";var v=function e(o){var t=o.elementId,m=o.className,v=o.divElement,u=o.message,p=o.mask;var g=l.useToken(),w=g.token;var j=w.colorPrimary;var k=n(true),_=k[0],b=k[1];var h=a.useCallbackRef((function(){try{delete window[t]}catch(e){}b(false)}));s.useEffectCustom((function(){window[t]=h}),[h]);var C=a.useCallbackRef((function(){d("#"+t)}));return c(i,{maskClosable:false,centered:true,destroyOnClose:true,className:r("v-dialog-loading",m),open:_,afterClose:C,getContainer:v,footer:null,closable:false,style:{"--v-loading-color":j},mask:p,children:c("div",{className:r("v-dialog-loading-content"),children:f("div",{className:"loader-wrapper",children:[c("div",{className:"loader-inner"}),c("div",{className:"loader-text",children:u||"处理中"})]})})})};var u={open:function e(r){var a=m(),l=a.divElement,i=a.elementId;window["__dialog_loading_elementId"]=i;var n=t(l);n.render(c(v,o({},r,{divElement:l,elementId:i,mask:r==null?void 0:r.mask})));return{close:function e(){var o,r;(o=(r=window)[i])==null?void 0:o.call(r)}}},close:function o(){try{var r,a;var l=window["__dialog_loading_elementId"];if(e(l))(r=(a=window)[l])==null?void 0:r.call(a)}catch(e){}}};export{u as dialogLoading};
5
+ import{isString as e}from"@dimjs/lang/cjs/is-string";import{_ as o}from"../_rollupPluginBabelHelpers-c0dbec57.js";import{classNames as r}from"@dimjs/utils/cjs/class-names";import{hooks as a}from"@wove/react/cjs/hooks";import{theme as l,Modal as n}from"antd";import{useState as i}from"react";import{createRoot as t}from"react-dom/client";import{fbaHooks as s}from"../fba-hooks/index.js";import{b as m,r as d}from"../dom-4d04aa64.js";import{jsx as c,jsxs as f}from"react/jsx-runtime";import"@dimjs/lang/cjs/is-array";import"@flatbiz/utils";import"../use-responsive-point-21b8c601.js";var u=function e(o){var t=o.elementId,m=o.className,u=o.divElement,v=o.message,p=o.mask;var g=l.useToken(),w=g.token;var j=w.colorPrimary;var k=i(true),_=k[0],b=k[1];var h=a.useCallbackRef((function(){try{delete window[t]}catch(e){}b(false)}));s.useEffectCustom((function(){window[t]=h}),[h]);var C=a.useCallbackRef((function(){d("#"+t)}));return c(n,{maskClosable:false,centered:true,destroyOnClose:true,className:r("v-dialog-loading",m),open:_,afterClose:C,getContainer:u,footer:null,closable:false,style:{"--v-loading-color":j},mask:p,children:c("div",{className:r("v-dialog-loading-content"),children:f("div",{className:"loader-wrapper",children:[c("div",{className:"loader-inner"}),c("div",{className:"loader-text",children:v||"处理中"})]})})})};var v={open:function e(r){var a=m(),l=a.divElement,n=a.elementId;window["__dialog_loading_elementId"]=n;var i=t(l);i.render(c(u,o({},r,{divElement:l,elementId:n,mask:r==null?void 0:r.mask})));return{close:function e(){var o,r;(o=(r=window)[n])==null||o.call(r)}}},close:function o(){try{var r,a;var l=window["__dialog_loading_elementId"];if(e(l))(r=(a=window)[l])==null||r.call(a)}catch(e){}}};export{v as dialogLoading};
6
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["@flatbiz/antd/src/dialog-loading/dialog-loading.tsx"],"sourcesContent":["import { isString } from '@dimjs/lang';\nimport { classNames } from '@dimjs/utils';\nimport { hooks } from '@wove/react';\nimport { Modal, theme } from 'antd';\nimport { CSSProperties, useState } from 'react';\nimport { createRoot } from 'react-dom/client';\nimport { fbaHooks } from '../fba-hooks';\nimport { bodyAppendDivElement, BodyAppendDivElementProps, removeBodyChild } from '../_utils/dom';\nimport './style.less';\n\nexport type DialogLoadingProps = {\n className?: string;\n message?: string;\n mask?: boolean;\n};\n\nconst ModalRender = (props: BodyAppendDivElementProps & DialogLoadingProps) => {\n const { elementId, className, divElement, message, mask } = props;\n const { token } = theme.useToken();\n const colorPrimary = token.colorPrimary;\n\n const [open, setOpen] = useState(true);\n\n const onClose = hooks.useCallbackRef(() => {\n try {\n delete window[elementId];\n } catch (error) {\n //\n }\n setOpen(false);\n });\n\n fbaHooks.useEffectCustom(() => {\n window[elementId] = onClose;\n }, [onClose]);\n\n const onAfterClose = hooks.useCallbackRef(() => {\n removeBodyChild(`#${elementId}`);\n });\n\n return (\n <Modal\n maskClosable={false}\n centered={true}\n destroyOnClose\n className={classNames('v-dialog-loading', className)}\n open={open}\n afterClose={onAfterClose}\n getContainer={divElement}\n footer={null}\n closable={false}\n style={{ '--v-loading-color': colorPrimary } as CSSProperties}\n mask={mask}\n >\n <div className={classNames('v-dialog-loading-content')}>\n <div className=\"loader-wrapper\">\n <div className=\"loader-inner\" />\n <div className=\"loader-text\">{message || '处理中'}</div>\n </div>\n </div>\n </Modal>\n );\n};\n\n/**\n * Loading弹框\n * ```\n * 1. 可嵌套使用\n * 2. 为什么不推荐使用\n * dialogLoading.open 打开的内容无法适配兼容自定义主题、无法适配兼容旧版浏览器、无法兼容国际化\n * 适配兼容旧版浏览器(https://ant-design.antgroup.com/docs/react/compatible-style-cn)\n * 3. 需要修改默认主题风格的场景,请使用\n * const { appDialogLoading } = FbaApp.useDialogLoading();\n * appDialogLoading.open({})\n * ```\n */\nexport const dialogLoading = {\n open: (props?: DialogLoadingProps) => {\n const { divElement, elementId } = bodyAppendDivElement();\n window['__dialog_loading_elementId'] = elementId;\n const root = createRoot(divElement);\n root.render(<ModalRender {...props} divElement={divElement} elementId={elementId} mask={props?.mask} />);\n return {\n close: () => {\n window[elementId]?.();\n },\n };\n },\n /**\n * ```\n * 1. 关闭最新弹框,如果有多个弹框只能关闭最后一个\n * 2. 多个弹框主动关闭,只能使用 dialogModal.open()返回值中的close\n * ```\n */\n close: () => {\n try {\n const elementId = window['__dialog_loading_elementId'] as string;\n if (isString(elementId)) window[elementId]?.();\n } catch (error) {\n //\n }\n },\n};\n"],"names":["ModalRender","props","elementId","className","divElement","message","mask","_theme$useToken","theme","useToken","token","colorPrimary","_useState","useState","open","setOpen","onClose","_hooks","useCallbackRef","window","error","fbaHooks","useEffectCustom","onAfterClose","removeBodyChild","_jsx","Modal","maskClosable","centered","destroyOnClose","_classNames","afterClose","getContainer","footer","closable","style","children","_jsxs","dialogLoading","_bodyAppendDivElement","bodyAppendDivElement","root","createRoot","render","_extends","close","_window$elementId","_window","call","_window$elementId2","_window2","_isString"],"mappings":";skBAgBA,IAAMA,EAAc,SAAdA,EAAeC,GACnB,IAAQC,EAAoDD,EAApDC,UAAWC,EAAyCF,EAAzCE,UAAWC,EAA8BH,EAA9BG,WAAYC,EAAkBJ,EAAlBI,QAASC,EAASL,EAATK,KACnD,IAAAC,EAAkBC,EAAMC,WAAhBC,EAAKH,EAALG,MACR,IAAMC,EAAeD,EAAMC,aAE3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IgC,EAASjD,IAAY+C,GAAAC,EAAA/B,QAAOjB,KAAP+C,UAAAA,EAAAA,EAAAD,KAAAE,EAC1B,CAAC,MAAO9B,GACP,CAEJ"}
1
+ {"version":3,"file":"index.js","sources":["@flatbiz/antd/src/dialog-loading/dialog-loading.tsx"],"sourcesContent":["import { isString } from '@dimjs/lang';\nimport { classNames } from '@dimjs/utils';\nimport { hooks } from '@wove/react';\nimport { Modal, theme } from 'antd';\nimport { CSSProperties, useState } from 'react';\nimport { createRoot } from 'react-dom/client';\nimport { fbaHooks } from '../fba-hooks';\nimport { bodyAppendDivElement, BodyAppendDivElementProps, removeBodyChild } from '../_utils/dom';\nimport './style.less';\n\nexport type DialogLoadingProps = {\n className?: string;\n message?: string;\n mask?: boolean;\n};\n\nconst ModalRender = (props: BodyAppendDivElementProps & DialogLoadingProps) => {\n const { elementId, className, divElement, message, mask } = props;\n const { token } = theme.useToken();\n const colorPrimary = token.colorPrimary;\n\n const [open, setOpen] = useState(true);\n\n const onClose = hooks.useCallbackRef(() => {\n try {\n delete window[elementId];\n } catch (error) {\n //\n }\n setOpen(false);\n });\n\n fbaHooks.useEffectCustom(() => {\n window[elementId] = onClose;\n }, [onClose]);\n\n const onAfterClose = hooks.useCallbackRef(() => {\n removeBodyChild(`#${elementId}`);\n });\n\n return (\n <Modal\n maskClosable={false}\n centered={true}\n destroyOnClose\n className={classNames('v-dialog-loading', className)}\n open={open}\n afterClose={onAfterClose}\n getContainer={divElement}\n footer={null}\n closable={false}\n style={{ '--v-loading-color': colorPrimary } as CSSProperties}\n mask={mask}\n >\n <div className={classNames('v-dialog-loading-content')}>\n <div className=\"loader-wrapper\">\n <div className=\"loader-inner\" />\n <div className=\"loader-text\">{message || '处理中'}</div>\n </div>\n </div>\n </Modal>\n );\n};\n\n/**\n * Loading弹框\n * ```\n * 1. 可嵌套使用\n * 2. 为什么不推荐使用\n * dialogLoading.open 打开的内容无法适配兼容自定义主题、无法适配兼容旧版浏览器、无法兼容国际化\n * 适配兼容旧版浏览器(https://ant-design.antgroup.com/docs/react/compatible-style-cn)\n * 3. 需要修改默认主题风格的场景,请使用\n * const { appDialogLoading } = FbaApp.useDialogLoading();\n * appDialogLoading.open({})\n * ```\n */\nexport const dialogLoading = {\n open: (props?: DialogLoadingProps) => {\n const { divElement, elementId } = bodyAppendDivElement();\n window['__dialog_loading_elementId'] = elementId;\n const root = createRoot(divElement);\n root.render(<ModalRender {...props} divElement={divElement} elementId={elementId} mask={props?.mask} />);\n return {\n close: () => {\n window[elementId]?.();\n },\n };\n },\n /**\n * ```\n * 1. 关闭最新弹框,如果有多个弹框只能关闭最后一个\n * 2. 多个弹框主动关闭,只能使用 dialogModal.open()返回值中的close\n * ```\n */\n close: () => {\n try {\n const elementId = window['__dialog_loading_elementId'] as string;\n if (isString(elementId)) window[elementId]?.();\n } catch (error) {\n //\n }\n },\n};\n"],"names":["ModalRender","props","elementId","className","divElement","message","mask","_theme$useToken","theme","useToken","token","colorPrimary","_useState","useState","open","setOpen","onClose","_hooks","useCallbackRef","window","error","fbaHooks","useEffectCustom","onAfterClose","removeBodyChild","_jsx","Modal","maskClosable","centered","destroyOnClose","_classNames","afterClose","getContainer","footer","closable","style","children","_jsxs","dialogLoading","_bodyAppendDivElement","bodyAppendDivElement","root","createRoot","render","_extends","close","_window$elementId","_window","call","_window$elementId2","_window2","_isString"],"mappings":";skBAgBA,IAAMA,EAAc,SAAdA,EAAeC,GACnB,IAAQC,EAAoDD,EAApDC,UAAWC,EAAyCF,EAAzCE,UAAWC,EAA8BH,EAA9BG,WAAYC,EAAkBJ,EAAlBI,QAASC,EAASL,EAATK,KACnD,IAAAC,EAAkBC,EAAMC,WAAhBC,EAAKH,EAALG,MACR,IAAMC,EAAeD,EAAMC,aAE3B,IAAAC,EAAwBC,EAAS,MAA1BC,EAAIF,EAAA,GAAEG,EAAOH,EAAA,GAEpB,IAAMI,EAAUC,EAAMC,gBAAe,WACnC,WACSC,OAAOjB,EACf,CAAC,MAAOkB,GACP,C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'./../flex-layout/index.css';
8
8
  import './index.css';
9
9
  /*! @flatjs/forge MIT @flatbiz/antd */
10
- import{isString as e}from"@dimjs/lang/cjs/is-string";import{classNames as t}from"@dimjs/utils/cjs/class-names";import{_ as o,a as r}from"../_rollupPluginBabelHelpers-a0769acd.js";import{isPromise as i}from"@dimjs/lang/cjs/is-promise";import{hooks as n}from"@wove/react/cjs/hooks";import{dom as l}from"@flatbiz/utils";import{useSize as a}from"ahooks";import{Form as d,Modal as s}from"antd";import{useState as m,useMemo as c}from"react";import{createRoot as u}from"react-dom/client";import{ButtonWrapper as f}from"../button-wrapper/index.js";import{C as p}from"../index-7f4ad045.js";import{fbaHooks as v}from"../fba-hooks/index.js";import{FlexLayout as h}from"../flex-layout/index.js";import{createCtx as g}from"@wove/react/cjs/create-ctx";import{jsx as y,jsxs as j}from"react/jsx-runtime";import"@ant-design/icons/es/icons/LoadingOutlined";import"../fba-utils/index.js";import"@dimjs/lang/cjs/is-array";import"@dimjs/model";import"antd/es/locale/en_US";import"antd/es/locale/zh_CN";import"dayjs";import"dayjs/locale/en";import"dayjs/locale/zh-cn";import"dayjs/plugin/advancedFormat";import"dayjs/plugin/customParseFormat";import"dayjs/plugin/localeData";import"dayjs/plugin/utc";import"dayjs/plugin/weekday";import"dayjs/plugin/weekOfYear";import"dayjs/plugin/weekYear";import"@dimjs/utils/cjs/extend";import"../use-responsive-point-21b8c601.js";var w=g(),k=w[0],x=w[1];var C=["title","titleExtra","divElement","elementId","onOk","onCancel","okButtonProps","cancelButtonProps","content","configProviderProps","className","okHidden","cancelHidden","footer","cancelText","okText","size","bodyHeight"];var b=function e(u){var g,w;var k=u.title,b=u.titleExtra,_=u.divElement,P=u.elementId,E=u.onOk,H=u.onCancel,B=u.okButtonProps,I=u.cancelButtonProps,z=u.content,F=u.configProviderProps,O=u.className,R=u.okHidden,N=u.cancelHidden,T=u.footer,D=u.cancelText,M=u.okText,S=u.size,Y=u.bodyHeight,q=r(u,C);var A=m(true),L=A[0],U=A[1];var G=d.useForm(),J=G[0];var K=a(document.querySelector("html"));var Q=v.useResponsivePoint()||"";var V=m({}),W=V[0],X=V[1];var Z=n.useCallbackRef((function(){try{delete window[P]}catch(e){}U(false)}));v.useEffectCustom((function(){window[P]=Z}),[Z]);var $=n.useCallbackRef((function(e){if(H){var t=H(J,e);if(t&&i(t)){return t.then(Z)}}return Z()}));var ee=n.useCallbackRef((function(e){if(E){var t=E(J,e);if(t&&i(t)){return t.then(Z)}}return Z()}));var te=n.useCallbackRef((function(){l.removeBodyChild("#"+P);u.afterClose==null?void 0:u.afterClose()}));var oe=v.useMemoCustom((function(){if(T){return typeof T==="function"?T(J,W):T}if(N&&R||T===null){return null}return[y(f,o({},I,{onClick:$,hidden:N,children:D||"取消"}),"0"),y(f,o({type:"primary"},B,{onClick:ee,hidden:R,children:M||"提交"}),"1")].filter(Boolean)}),[W]);var re=c((function(){if(!(K!=null&&K.height)||!Q)return undefined;var e=["xs","sm"].includes(Q);if(S=="large"){return{height:(K==null?void 0:K.height)*.7,width:e?"90%":K.width*.6}}if(S=="small"){var t=K.width*.3;return{height:(K==null?void 0:K.height)*.4,width:e?"90%":t<470?470:t}}if(S=="middle"){return{height:(K==null?void 0:K.height)*.4,width:e?"90%":K.width*.5}}return undefined}),[K==null?void 0:K.height,K==null?void 0:K.width,Q,S]);var ie=t("v-dialog-modal",{"v-dialog-modal-title-extra":!!b},O);var ne=function e(t){X(t)};var le=((g=q.styles)==null||(g=g.body)==null?void 0:g.height)||Y;return y(x,{value:{rerenderFooter:ne},children:y(p,o({},F,{children:y(s,o({title:b?j(h,{direction:"horizontal",fullIndex:0,children:[y("span",{children:k}),b]}):k,maskClosable:true,centered:true,onCancel:Z,destroyOnClose:true,width:re==null?void 0:re.width},q,{footer:oe,styles:o({},q.styles,{body:o({height:le||(re==null?void 0:re.height),maxHeight:"calc(100vh - 200px)"},(w=q.styles)==null?void 0:w.body)}),className:ie,open:L,afterClose:te,getContainer:_,children:typeof z==="function"?z(J,{onClose:Z}):z}))}))})};var _={open:function e(t){var r=l.bodyAppendDivElement(),i=r.divElement,n=r.elementId;window["__dialog_modal_elementId"]=n;var a=u(i);a.render(y(b,o({},t,{divElement:i,elementId:n})));return{close:function e(){var t,o;(t=(o=window)[n])==null?void 0:t.call(o)}}},close:function t(){try{var o,r;var i=window["__dialog_modal_elementId"];if(e(i))(o=(r=window)[i])==null?void 0:o.call(r)}catch(e){}},useDialogModal:function e(){var t=k();return{rerenderFooter:function e(o){t.rerenderFooter(o)}}}};export{_ as dialogModal};
10
+ import{isString as e}from"@dimjs/lang/cjs/is-string";import{classNames as t}from"@dimjs/utils/cjs/class-names";import{_ as o,a as r}from"../_rollupPluginBabelHelpers-c0dbec57.js";import{isPromise as i}from"@dimjs/lang/cjs/is-promise";import{hooks as n}from"@wove/react/cjs/hooks";import{dom as l}from"@flatbiz/utils";import{useSize as a}from"ahooks";import{Form as d,Modal as s}from"antd";import{useState as m,useMemo as c}from"react";import{createRoot as u}from"react-dom/client";import{ButtonWrapper as f}from"../button-wrapper/index.js";import{C as p}from"../index-83bede1b.js";import{fbaHooks as h}from"../fba-hooks/index.js";import{FlexLayout as v}from"../flex-layout/index.js";import{createCtx as g}from"@wove/react/cjs/create-ctx";import{jsx as y,jsxs as j}from"react/jsx-runtime";import"@ant-design/icons/es/icons/LoadingOutlined";import"../fba-utils/index.js";import"@dimjs/lang/cjs/is-array";import"@dimjs/model";import"antd/es/locale/en_US";import"antd/es/locale/zh_CN";import"dayjs";import"dayjs/locale/en";import"dayjs/locale/zh-cn";import"dayjs/plugin/advancedFormat";import"dayjs/plugin/customParseFormat";import"dayjs/plugin/localeData";import"dayjs/plugin/utc";import"dayjs/plugin/weekday";import"dayjs/plugin/weekOfYear";import"dayjs/plugin/weekYear";import"@dimjs/utils/cjs/extend";import"../use-responsive-point-21b8c601.js";var w=g(),k=w[0],x=w[1];var C=["title","titleExtra","divElement","elementId","onOk","onCancel","okButtonProps","cancelButtonProps","content","configProviderProps","className","okHidden","cancelHidden","footer","cancelText","okText","size","bodyHeight"];var b=function e(u){var g,w;var k=u.title,b=u.titleExtra,_=u.divElement,P=u.elementId,E=u.onOk,H=u.onCancel,B=u.okButtonProps,I=u.cancelButtonProps,z=u.content,F=u.configProviderProps,O=u.className,R=u.okHidden,N=u.cancelHidden,T=u.footer,D=u.cancelText,M=u.okText,S=u.size,Y=u.bodyHeight,q=r(u,C);var A=m(true),L=A[0],U=A[1];var G=d.useForm(),J=G[0];var K=a(document.querySelector("html"));var Q=h.useResponsivePoint()||"";var V=m({}),W=V[0],X=V[1];var Z=n.useCallbackRef((function(){try{delete window[P]}catch(e){}U(false)}));h.useEffectCustom((function(){window[P]=Z}),[Z]);var $=n.useCallbackRef((function(e){if(H){var t=H(J,e);if(t&&i(t)){return t.then(Z)}}return Z()}));var ee=n.useCallbackRef((function(e){if(E){var t=E(J,e);if(t&&i(t)){return t.then(Z)}}return Z()}));var te=n.useCallbackRef((function(){l.removeBodyChild("#"+P);u.afterClose==null||u.afterClose()}));var oe=h.useMemoCustom((function(){if(T){return typeof T==="function"?T(J,W):T}if(N&&R||T===null){return null}return[y(f,o({},I,{onClick:$,hidden:N,children:D||"取消"}),"0"),y(f,o({type:"primary"},B,{onClick:ee,hidden:R,children:M||"提交"}),"1")].filter(Boolean)}),[W]);var re=c((function(){if(!(K!=null&&K.height)||!Q)return undefined;var e=["xs","sm"].includes(Q);if(e){return{width:"90%"}}if(S=="large"){return{height:(K==null?void 0:K.height)*.7,width:e?"90%":K.width*.6}}if(S=="small"){var t=K.width*.3;return{height:(K==null?void 0:K.height)*.4,width:e?"90%":t<470?470:t}}if(S=="middle"){return{height:(K==null?void 0:K.height)*.4,width:e?"90%":K.width*.5}}return undefined}),[K==null?void 0:K.height,K==null?void 0:K.width,Q,S]);var ie=t("v-dialog-modal",{"v-dialog-modal-title-extra":!!b},O);var ne=function e(t){X(t)};var le=((g=q.styles)==null||(g=g.body)==null?void 0:g.height)||Y;return y(x,{value:{rerenderFooter:ne},children:y(p,o({},F,{children:y(s,o({title:b?j(v,{direction:"horizontal",fullIndex:0,children:[y("span",{children:k}),b]}):k,maskClosable:true,centered:true,onCancel:Z,destroyOnClose:true,width:re==null?void 0:re.width},q,{footer:oe,styles:o({},q.styles,{body:o({height:le||(re==null?void 0:re.height),maxHeight:"calc(100vh - 200px)"},(w=q.styles)==null?void 0:w.body)}),className:ie,open:L,afterClose:te,getContainer:_,children:typeof z==="function"?z(J,{onClose:Z}):z}))}))})};var _={open:function e(t){var r=l.bodyAppendDivElement(),i=r.divElement,n=r.elementId;window["__dialog_modal_elementId"]=n;var a=u(i);a.render(y(b,o({},t,{divElement:i,elementId:n})));return{close:function e(){var t,o;(t=(o=window)[n])==null||t.call(o)}}},close:function t(){try{var o,r;var i=window["__dialog_modal_elementId"];if(e(i))(o=(r=window)[i])==null||o.call(r)}catch(e){}},useDialogModal:function e(){var t=k();return{rerenderFooter:function e(o){t.rerenderFooter(o)}}}};export{_ as dialogModal};
11
11
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["@flatbiz/antd/src/dialog-modal/context.ts","@flatbiz/antd/src/dialog-modal/dialog-modal.tsx"],"sourcesContent":["import { TPlainObject } from '@flatbiz/utils';\nimport { createCtx } from '@wove/react';\n\nexport const [useDialogModalCtx, DialogModalCtxProvider] = createCtx<{\n /** 重新渲染footer */\n rerenderFooter: (data?: TPlainObject) => void;\n}>();\n","import { isPromise, isString } from '@dimjs/lang';\nimport { classNames } from '@dimjs/utils';\n\nimport { BodyAppendDivElementProps, dom, TNoopDefine, TPlainObject } from '@flatbiz/utils';\nimport { hooks } from '@wove/react';\nimport { useSize } from 'ahooks';\nimport { Form, FormInstance, Modal, ModalProps } from 'antd';\nimport { ReactElement, useMemo, useState } from 'react';\nimport { createRoot } from 'react-dom/client';\nimport { ButtonWrapper, ButtonWrapperProps } from '../button-wrapper';\nimport { ConfigProviderWrapper, ConfigProviderWrapperProps } from '../config-provider-wrapper';\nimport { fbaHooks } from '../fba-hooks';\nimport { FlexLayout } from '../flex-layout';\nimport { DialogModalCtxProvider, useDialogModalCtx } from './context';\nimport './style.less';\n\nexport type DialogModalProps = Omit<\n ModalProps,\n 'onOk' | 'onCancel' | 'getContainer' | 'open' | 'open' | 'okButtonProps' | 'cancelButtonProps' | 'footer'\n> & {\n /**\n * 内置尺寸,根据比例固定高度、宽度,默认:无\n * ```\n * 1. 如果自定义了width、bodyHeight属性,size中的height、width将对应失效\n * 2. 不传、传null值可取消内置尺寸\n * ```\n */\n size?: 'small' | 'middle' | 'large' | null;\n onOk?: (form: FormInstance, e: React.MouseEvent<HTMLElement>) => void | Promise<void>;\n onCancel?: (form: FormInstance, e: React.MouseEvent<HTMLElement>) => void | Promise<void>;\n content: string | ReactElement | ((form: FormInstance, operate: { onClose: TNoopDefine }) => ReactElement);\n configProviderProps?: ConfigProviderWrapperProps;\n okHidden?: boolean;\n cancelHidden?: boolean;\n okButtonProps?: Omit<ButtonWrapperProps, 'hidden' | 'children' | 'onClick'>;\n cancelButtonProps?: Omit<ButtonWrapperProps, 'hidden' | 'children' | 'onClick'>;\n /**\n * 设置modal body height 为当前窗口height的百分比,例如:30\n * @deprecated 已失效,可通过size属性设置\n * ```\n * 1. 最大值:80\n * 1. 设置bodyStyle.height 后,bodyHeightPercent失效\n * ```\n */\n bodyHeightPercent?: number;\n titleExtra?: ReactElement;\n /**\n * null则隐藏footer\n * ```\n * extraData 为外部通过 useDialogModal.rerenderFooter 重新渲染footer携带的数据\n * ```\n */\n footer?:\n | null\n | ReactElement\n | ReactElement[]\n | ((form: FormInstance, extraData?: TPlainObject) => ReactElement);\n /** 内容高度,为styles.body.height快捷配置,优先级低于styles.body.height */\n bodyHeight?: number;\n};\n\nconst ModalRender = (props: BodyAppendDivElementProps & DialogModalProps) => {\n const {\n title,\n titleExtra,\n divElement,\n elementId,\n onOk,\n onCancel,\n okButtonProps,\n cancelButtonProps,\n content,\n configProviderProps,\n className,\n okHidden,\n cancelHidden,\n footer,\n cancelText,\n okText,\n size,\n bodyHeight,\n ...otherProps\n } = props;\n\n const [open, setOpen] = useState(true);\n const [form] = Form.useForm();\n const htmlSize = useSize(document.querySelector('html'));\n const screenType = fbaHooks.useResponsivePoint() || '';\n const [footerExtraData, setFooterExtraData] = useState<TPlainObject>({});\n\n const onClose = hooks.useCallbackRef(() => {\n try {\n delete window[elementId];\n } catch (error) {\n //\n }\n setOpen(false);\n });\n\n fbaHooks.useEffectCustom(() => {\n window[elementId] = onClose;\n }, [onClose]);\n\n const onCancelHandle = hooks.useCallbackRef((e) => {\n if (onCancel) {\n const response = onCancel(form, e);\n if (response && isPromise(response)) {\n return response.then(onClose);\n }\n }\n return onClose();\n });\n\n const onOkHandle = hooks.useCallbackRef((e) => {\n if (onOk) {\n const response = onOk(form, e);\n if (response && isPromise(response)) {\n return response.then(onClose);\n }\n }\n return onClose();\n });\n\n const onAfterClose = hooks.useCallbackRef(() => {\n dom.removeBodyChild(`#${elementId}`);\n props.afterClose?.();\n });\n\n const footerNew = fbaHooks.useMemoCustom(() => {\n if (footer) {\n return typeof footer === 'function' ? footer(form, footerExtraData) : footer;\n }\n if ((cancelHidden && okHidden) || footer === null) {\n return null;\n }\n return [\n <ButtonWrapper key=\"0\" {...cancelButtonProps} onClick={onCancelHandle} hidden={cancelHidden}>\n {cancelText || '取消'}\n </ButtonWrapper>,\n <ButtonWrapper key=\"1\" type=\"primary\" {...okButtonProps} onClick={onOkHandle} hidden={okHidden}>\n {okText || '提交'}\n </ButtonWrapper>,\n ].filter(Boolean);\n }, [footerExtraData]);\n\n const customSize = useMemo(() => {\n if (!htmlSize?.height || !screenType) return undefined;\n const isXsSm = ['xs', 'sm'].includes(screenType);\n if (size == 'large') {\n return {\n height: htmlSize?.height * 0.7,\n width: isXsSm ? '90%' : htmlSize.width * 0.6,\n };\n }\n if (size == 'small') {\n const width = htmlSize.width * 0.3;\n return {\n height: htmlSize?.height * 0.4,\n width: isXsSm ? '90%' : width < 470 ? 470 : width,\n };\n }\n\n if (size == 'middle') {\n return {\n height: htmlSize?.height * 0.4,\n width: isXsSm ? '90%' : htmlSize.width * 0.5,\n };\n }\n\n return undefined;\n }, [htmlSize?.height, htmlSize?.width, screenType, size]);\n\n const classNameNew = classNames(\n 'v-dialog-modal',\n { 'v-dialog-modal-title-extra': !!titleExtra },\n className,\n );\n\n const rerenderFooter = (data) => {\n setFooterExtraData(data);\n };\n\n const bodyHeightNew = otherProps.styles?.body?.height || bodyHeight;\n\n return (\n <DialogModalCtxProvider value={{ rerenderFooter }}>\n <ConfigProviderWrapper {...configProviderProps}>\n <Modal\n title={\n titleExtra ? (\n <FlexLayout direction=\"horizontal\" fullIndex={0}>\n <span>{title}</span>\n {titleExtra}\n </FlexLayout>\n ) : (\n title\n )\n }\n maskClosable={true}\n centered={true}\n onCancel={onClose}\n destroyOnClose\n width={customSize?.width}\n {...otherProps}\n footer={footerNew}\n styles={{\n ...otherProps.styles,\n body: {\n height: bodyHeightNew || customSize?.height,\n maxHeight: 'calc(100vh - 200px)',\n ...otherProps.styles?.body,\n },\n }}\n className={classNameNew}\n open={open}\n afterClose={onAfterClose}\n getContainer={divElement}\n >\n {typeof content === 'function' ? content(form, { onClose }) : content}\n </Modal>\n </ConfigProviderWrapper>\n </DialogModalCtxProvider>\n );\n};\n\n/**\n * 居中弹框\n * ```\n * 1. 可嵌套使用\n * 2. 为什么不推荐使用\n * dialogModal.open 打开的内容无法适配兼容自定义主题、无法适配兼容旧版浏览器、无法兼容国际化\n * 适配兼容旧版浏览器(https://ant-design.antgroup.com/docs/react/compatible-style-cn)\n * 3. 需要修改默认主题风格的场景,请使用\n * const { appDialogModal } = FbaApp.useDialogModal();\n * appDialogModal.open({})\n * 4. size属性可使用预设的弹窗尺寸(默认值middle),如果不使用内置尺寸可设置 size = null\n * ```\n */\nexport const dialogModal = {\n open: (props: DialogModalProps) => {\n const { divElement, elementId } = dom.bodyAppendDivElement();\n window['__dialog_modal_elementId'] = elementId;\n const root = createRoot(divElement);\n root.render(<ModalRender {...props} divElement={divElement} elementId={elementId} />);\n return {\n close: () => {\n window[elementId]?.();\n },\n };\n },\n /**\n * ```\n * 1. 关闭最新弹框,如果有多个弹框只能关闭最后一个\n * 2. 多个弹框主动关闭,只能使用 dialogModal.open()返回值中的close\n * ```\n */\n close: () => {\n try {\n const elementId = window['__dialog_modal_elementId'] as string;\n if (isString(elementId)) window[elementId]?.();\n } catch (error) {\n //\n }\n },\n /**\n * ```\n * 1. rerenderFooter 携带指定数据重新渲染 footer,可用于切换footer中的按钮状态\n * ```\n */\n useDialogModal: () => {\n const ctx = useDialogModalCtx();\n return {\n /** 重新渲染 footer, data为携带的数据,是footer的第二个参数 */\n rerenderFooter: (data?: TPlainObject) => {\n ctx.rerenderFooter(data);\n },\n };\n },\n};\n"],"names":["_createCtx","_createCtx2","useDialogModalCtx","DialogModalCtxProvider","ModalRender","props","_otherProps$styles","_otherProps$styles2","title","titleExtra","divElement","elementId","onOk","onCancel","okButtonProps","cancelButtonProps","content","configProviderProps","className","okHidden","cancelHidden","footer","cancelText","okText","size","bodyHeight","otherProps","_objectWithoutPropertiesLoose","_excluded","_useState","useState","open","setOpen","_Form$useForm","Form","useForm","form","htmlSize","useSize","document","querySelector","screenType","fbaHooks","useResponsivePoint","_useState2","footerExtraData","setFooterExtraData","onClose","_hooks","useCallbackRef","window","error","useEffectCustom","onCancelHandle","e","response","_isPromise","then","onOkHandle","onAfterClose","dom","removeBodyChild","afterClose","footerNew","useMemoCustom","_jsx","ButtonWrapper","_extends","onClick","hidden","children","type","filter","Boolean","customSize","useMemo","height","undefined","isXsSm","includes","width","classNameNew","_classNames","rerenderFooter","data","bodyHeightNew","styles","body","value","ConfigProviderWrapper","Modal","_jsxs","FlexLayout","direction","fullIndex","maskClosable","centered","destroyOnClose","maxHeight","getContainer","dialogModal","_dom$bodyAppendDivEle","bodyAppendDivElement","root","createRoot","render","close","_window$elementId","_window","call","_window$elementId2","_window2","_isString","useDialogModal","ctx"],"mappings":";i0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AA8BvC,EACrC,IAAM4F,EAAOC,EAAW9F,GACxB6F,EAAKE,OAAOxC,EAAC7D,EAAW+D,EAAA,CAAA,EAAK9D,EAAK,CAAEK,WAAYA,EAAYC,UAAWA,MACvE,MAAO,CACL+F,MAAO,SAAAA,IAAM,IAAAC,EAAAC,GACXD,GAAAC,EAAA1D,QAAOvC,KAAU,UAAA,EAAjBgG,EAAAE,KAAAD,EACF,EAEH,EAODF,MAAO,SAAAA,IACL,IAAI,IAAAI,EAAAC,EACF,IAAMpG,EAAYuC,OAAO,4BACzB,GAAI8D,EAASrG,IAAYmG,GAAAC,EAAA7D,QAAOvC,KAAPmG,UAAAA,EAAAA,EAAAD,KAAAE,EAC1B,CAAC,MAAO5D,GACP,CAEH,EAMD8D,eAAgB,SAAAA,IACd,IAAMC,EAAMhH,IACZ,MAAO,CAELiF,eAAgB,SAAAA,EAACC,GACf8B,EAAI/B,eAAeC,EACrB,EAEJ"}
1
+ {"version":3,"file":"index.js","sources":["@flatbiz/antd/src/dialog-modal/context.ts","@flatbiz/antd/src/dialog-modal/dialog-modal.tsx"],"sourcesContent":["import { TPlainObject } from '@flatbiz/utils';\nimport { createCtx } from '@wove/react';\n\nexport const [useDialogModalCtx, DialogModalCtxProvider] = createCtx<{\n /** 重新渲染footer */\n rerenderFooter: (data?: TPlainObject) => void;\n}>();\n","import { isPromise, isString } from '@dimjs/lang';\nimport { classNames } from '@dimjs/utils';\n\nimport { BodyAppendDivElementProps, dom, TNoopDefine, TPlainObject } from '@flatbiz/utils';\nimport { hooks } from '@wove/react';\nimport { useSize } from 'ahooks';\nimport { Form, FormInstance, Modal, ModalProps } from 'antd';\nimport { ReactElement, useMemo, useState } from 'react';\nimport { createRoot } from 'react-dom/client';\nimport { ButtonWrapper, ButtonWrapperProps } from '../button-wrapper';\nimport { ConfigProviderWrapper, ConfigProviderWrapperProps } from '../config-provider-wrapper';\nimport { fbaHooks } from '../fba-hooks';\nimport { FlexLayout } from '../flex-layout';\nimport { DialogModalCtxProvider, useDialogModalCtx } from './context';\nimport './style.less';\n\nexport type DialogModalProps = Omit<\n ModalProps,\n 'onOk' | 'onCancel' | 'getContainer' | 'open' | 'open' | 'okButtonProps' | 'cancelButtonProps' | 'footer'\n> & {\n /**\n * 内置尺寸,根据比例固定高度、宽度,默认:无\n * ```\n * 1. 如果自定义了width、bodyHeight属性,size中的height、width将对应失效\n * 2. 不传、传null值可取消内置尺寸\n * ```\n */\n size?: 'small' | 'middle' | 'large' | null;\n onOk?: (form: FormInstance, e: React.MouseEvent<HTMLElement>) => void | Promise<void>;\n onCancel?: (form: FormInstance, e: React.MouseEvent<HTMLElement>) => void | Promise<void>;\n content: string | ReactElement | ((form: FormInstance, operate: { onClose: TNoopDefine }) => ReactElement);\n configProviderProps?: ConfigProviderWrapperProps;\n okHidden?: boolean;\n cancelHidden?: boolean;\n okButtonProps?: Omit<ButtonWrapperProps, 'hidden' | 'children' | 'onClick'>;\n cancelButtonProps?: Omit<ButtonWrapperProps, 'hidden' | 'children' | 'onClick'>;\n /**\n * 设置modal body height 为当前窗口height的百分比,例如:30\n * @deprecated 已失效,可通过size属性设置\n * ```\n * 1. 最大值:80\n * 1. 设置bodyStyle.height 后,bodyHeightPercent失效\n * ```\n */\n bodyHeightPercent?: number;\n titleExtra?: ReactElement;\n /**\n * null则隐藏footer\n * ```\n * extraData 为外部通过 useDialogModal.rerenderFooter 重新渲染footer携带的数据\n * ```\n */\n footer?:\n | null\n | ReactElement\n | ReactElement[]\n | ((form: FormInstance, extraData?: TPlainObject) => ReactElement);\n /** 内容高度,为styles.body.height快捷配置,优先级低于styles.body.height */\n bodyHeight?: number;\n};\n\nconst ModalRender = (props: BodyAppendDivElementProps & DialogModalProps) => {\n const {\n title,\n titleExtra,\n divElement,\n elementId,\n onOk,\n onCancel,\n okButtonProps,\n cancelButtonProps,\n content,\n configProviderProps,\n className,\n okHidden,\n cancelHidden,\n footer,\n cancelText,\n okText,\n size,\n bodyHeight,\n ...otherProps\n } = props;\n\n const [open, setOpen] = useState(true);\n const [form] = Form.useForm();\n const htmlSize = useSize(document.querySelector('html'));\n const screenType = fbaHooks.useResponsivePoint() || '';\n const [footerExtraData, setFooterExtraData] = useState<TPlainObject>({});\n\n const onClose = hooks.useCallbackRef(() => {\n try {\n delete window[elementId];\n } catch (error) {\n //\n }\n setOpen(false);\n });\n\n fbaHooks.useEffectCustom(() => {\n window[elementId] = onClose;\n }, [onClose]);\n\n const onCancelHandle = hooks.useCallbackRef((e) => {\n if (onCancel) {\n const response = onCancel(form, e);\n if (response && isPromise(response)) {\n return response.then(onClose);\n }\n }\n return onClose();\n });\n\n const onOkHandle = hooks.useCallbackRef((e) => {\n if (onOk) {\n const response = onOk(form, e);\n if (response && isPromise(response)) {\n return response.then(onClose);\n }\n }\n return onClose();\n });\n\n const onAfterClose = hooks.useCallbackRef(() => {\n dom.removeBodyChild(`#${elementId}`);\n props.afterClose?.();\n });\n\n const footerNew = fbaHooks.useMemoCustom(() => {\n if (footer) {\n return typeof footer === 'function' ? footer(form, footerExtraData) : footer;\n }\n if ((cancelHidden && okHidden) || footer === null) {\n return null;\n }\n return [\n <ButtonWrapper key=\"0\" {...cancelButtonProps} onClick={onCancelHandle} hidden={cancelHidden}>\n {cancelText || '取消'}\n </ButtonWrapper>,\n <ButtonWrapper key=\"1\" type=\"primary\" {...okButtonProps} onClick={onOkHandle} hidden={okHidden}>\n {okText || '提交'}\n </ButtonWrapper>,\n ].filter(Boolean);\n }, [footerExtraData]);\n\n const customSize = useMemo(() => {\n if (!htmlSize?.height || !screenType) return undefined;\n const isXsSm = ['xs', 'sm'].includes(screenType);\n\n if (isXsSm) {\n return { width: '90%' };\n }\n\n if (size == 'large') {\n return {\n height: htmlSize?.height * 0.7,\n width: isXsSm ? '90%' : htmlSize.width * 0.6,\n };\n }\n if (size == 'small') {\n const width = htmlSize.width * 0.3;\n return {\n height: htmlSize?.height * 0.4,\n width: isXsSm ? '90%' : width < 470 ? 470 : width,\n };\n }\n\n if (size == 'middle') {\n return {\n height: htmlSize?.height * 0.4,\n width: isXsSm ? '90%' : htmlSize.width * 0.5,\n };\n }\n return undefined;\n }, [htmlSize?.height, htmlSize?.width, screenType, size]);\n\n const classNameNew = classNames(\n 'v-dialog-modal',\n { 'v-dialog-modal-title-extra': !!titleExtra },\n className,\n );\n\n const rerenderFooter = (data) => {\n setFooterExtraData(data);\n };\n\n const bodyHeightNew = otherProps.styles?.body?.height || bodyHeight;\n\n return (\n <DialogModalCtxProvider value={{ rerenderFooter }}>\n <ConfigProviderWrapper {...configProviderProps}>\n <Modal\n title={\n titleExtra ? (\n <FlexLayout direction=\"horizontal\" fullIndex={0}>\n <span>{title}</span>\n {titleExtra}\n </FlexLayout>\n ) : (\n title\n )\n }\n maskClosable={true}\n centered={true}\n onCancel={onClose}\n destroyOnClose\n width={customSize?.width}\n {...otherProps}\n footer={footerNew}\n styles={{\n ...otherProps.styles,\n body: {\n height: bodyHeightNew || customSize?.height,\n maxHeight: 'calc(100vh - 200px)',\n ...otherProps.styles?.body,\n },\n }}\n className={classNameNew}\n open={open}\n afterClose={onAfterClose}\n getContainer={divElement}\n >\n {typeof content === 'function' ? content(form, { onClose }) : content}\n </Modal>\n </ConfigProviderWrapper>\n </DialogModalCtxProvider>\n );\n};\n\n/**\n * 居中弹框\n * ```\n * 1. 可嵌套使用\n * 2. 为什么不推荐使用\n * dialogModal.open 打开的内容无法适配兼容自定义主题、无法适配兼容旧版浏览器、无法兼容国际化\n * 适配兼容旧版浏览器(https://ant-design.antgroup.com/docs/react/compatible-style-cn)\n * 3. 需要修改默认主题风格的场景,请使用\n * const { appDialogModal } = FbaApp.useDialogModal();\n * appDialogModal.open({})\n * 4. size属性可使用预设的弹窗尺寸(默认值middle),如果不使用内置尺寸可设置 size = null\n * ```\n */\nexport const dialogModal = {\n open: (props: DialogModalProps) => {\n const { divElement, elementId } = dom.bodyAppendDivElement();\n window['__dialog_modal_elementId'] = elementId;\n const root = createRoot(divElement);\n root.render(<ModalRender {...props} divElement={divElement} elementId={elementId} />);\n return {\n close: () => {\n window[elementId]?.();\n },\n };\n },\n /**\n * ```\n * 1. 关闭最新弹框,如果有多个弹框只能关闭最后一个\n * 2. 多个弹框主动关闭,只能使用 dialogModal.open()返回值中的close\n * ```\n */\n close: () => {\n try {\n const elementId = window['__dialog_modal_elementId'] as string;\n if (isString(elementId)) window[elementId]?.();\n } catch (error) {\n //\n }\n },\n /**\n * ```\n * 1. rerenderFooter 携带指定数据重新渲染 footer,可用于切换footer中的按钮状态\n * ```\n */\n useDialogModal: () => {\n const ctx = useDialogModalCtx();\n return {\n /** 重新渲染 footer, data为携带的数据,是footer的第二个参数 */\n rerenderFooter: (data?: TPlainObject) => {\n ctx.rerenderFooter(data);\n },\n };\n },\n};\n"],"names":["_createCtx","_createCtx2","useDialogModalCtx","DialogModalCtxProvider","ModalRender","props","_otherProps$styles","_otherProps$styles2","title","titleExtra","divElement","elementId","onOk","onCancel","okButtonProps","cancelButtonProps","content","configProviderProps","className","okHidden","cancelHidden","footer","cancelText","okText","size","bodyHeight","otherProps","_objectWithoutPropertiesLoose","_excluded","_useState","useState","open","setOpen","_Form$useForm","Form","useForm","form","htmlSize","useSize","document","querySelector","screenType","fbaHooks","useResponsivePoint","_useState2","footerExtraData","setFooterExtraData","onClose","_hooks","useCallbackRef","window","error","useEffectCustom","onCancelHandle","e","response","_isPromise","then","onOkHandle","onAfterClose","dom","removeBodyChild","afterClose","footerNew","useMemoCustom","_jsx","ButtonWrapper","_extends","onClick","hidden","children","type","filter","Boolean","customSize","useMemo","height","undefined","isXsSm","includes","width","classNameNew","_classNames","rerenderFooter","data","bodyHeightNew","styles","body","value","ConfigProviderWrapper","Modal","_jsxs","FlexLayout","direction","fullIndex","maskClosable","centered","destroyOnClose","maxHeight","getContainer","dialogModal","_dom$bodyAppendDivEle","bodyAppendDivElement","root","createRoot","render","close","_window$elementId","_window","call","_window$elementId2","_window2","_isString","useDialogModal","ctx"],"mappings":";i0CAGO,IAAAA,EAAoDC,IAA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,UACpBuC,OAAO,4BAA8BvC,EACrC,IAAM4F,EAAOC,EAAW9F,GACxB6F,EAAKE,OAAOxC,EAAC7D,EAAW+D,EAAA,CAAA,EAAK9D,EAAK,CAAEK,WAAYA,EAAYC,UAAWA,MACvE,MAAO,CACL+F,MAAO,SAAPA,IAAa,IAAAC,EAAAC,GACXD,GAAAC,EAAA1D,QAAOvC,KAAU,MAAjBgG,EAAAE,KAAAD,EACF,EAEH,EAODF,MAAO,SAAPA,IACE,IAAI,IAAAI,EAAAC,EACF,IAAMpG,EAAYuC,OAAO,4BACzB,GAAI8D,EAASrG,IAAYmG,GAAAC,EAAA7D,QAAOvC,KAAPmG,MAAAA,EAAAD,KAAAE,EAC1B,CAAC,MAAO5D,GACP,CAEH,EAMD8D,eAAgB,SAAhBA,IACE,IAAMC,EAAMhH,IACZ,MAAO,CAELiF,eAAgB,SAAhBA,EAAiBC,GACf8B,EAAI/B,eAAeC,EACrB,EAEJ"}
@@ -2,5 +2,5 @@
2
2
  import './../fba-hooks/index.css';
3
3
  import './index.css';
4
4
  /*! @flatjs/forge MIT @flatbiz/antd */
5
- import{isString as e}from"@dimjs/lang/cjs/is-string";import{_ as r}from"../_rollupPluginBabelHelpers-a0769acd.js";import{hooks as i}from"@wove/react/cjs/hooks";import{dom as n}from"@flatbiz/utils";import{Image as o}from"antd";import{useState as t,Fragment as l}from"react";import{createRoot as a}from"react-dom/client";import{fbaHooks as m}from"../fba-hooks/index.js";import{jsx as s}from"react/jsx-runtime";import"@dimjs/lang/cjs/is-array";import"../use-responsive-point-21b8c601.js";var d=function e(r){var n=t(true),a=n[0],d=n[1];var c=r.elementId;var f=i.useCallbackRef((function(){try{delete window[c]}catch(e){}d(false)}));m.useEffectCustom((function(){window[c]=f}),[f]);return s(l,{children:s(o,{wrapperStyle:{display:"none"},preview:{visible:!!a,onVisibleChange:function e(){return d(false)},afterOpenChange:function e(r){return!r&&d(false)}},src:r.imageUrl})})};var c={show:function e(i){var o=n.bodyAppendDivElement(),t=o.divElement,l=o.elementId;window["__dialog_preview_elementId"]=l;var m=a(t);m.render(s(d,r({},i,{divElement:t,elementId:l})));return{close:function e(){var r,i;(r=(i=window)[l])==null?void 0:r.call(i)}}},hiden:function r(){try{var i,n;var o=window["__dialog_preview_elementId"];if(e(o))(i=(n=window)[o])==null?void 0:i.call(n)}catch(e){}}};export{c as dialogPreviewImage};
5
+ import{isString as e}from"@dimjs/lang/cjs/is-string";import{_ as r}from"../_rollupPluginBabelHelpers-c0dbec57.js";import{hooks as n}from"@wove/react/cjs/hooks";import{dom as i}from"@flatbiz/utils";import{Image as t}from"antd";import{useState as o,Fragment as l}from"react";import{createRoot as a}from"react-dom/client";import{fbaHooks as m}from"../fba-hooks/index.js";import{jsx as s}from"react/jsx-runtime";import"@dimjs/lang/cjs/is-array";import"../use-responsive-point-21b8c601.js";var c=function e(r){var i=o(true),a=i[0],c=i[1];var d=r.elementId;var f=n.useCallbackRef((function(){try{delete window[d]}catch(e){}c(false)}));m.useEffectCustom((function(){window[d]=f}),[f]);return s(l,{children:s(t,{wrapperStyle:{display:"none"},preview:{visible:!!a,onVisibleChange:function e(){return c(false)},afterOpenChange:function e(r){return!r&&c(false)}},src:r.imageUrl})})};var d={show:function e(n){var t=i.bodyAppendDivElement(),o=t.divElement,l=t.elementId;window["__dialog_preview_elementId"]=l;var m=a(o);m.render(s(c,r({},n,{divElement:o,elementId:l})));return{close:function e(){var r,n;(r=(n=window)[l])==null||r.call(n)}}},hiden:function r(){try{var n,i;var t=window["__dialog_preview_elementId"];if(e(t))(n=(i=window)[t])==null||n.call(i)}catch(e){}}};export{d as dialogPreviewImage};
6
6
  //# sourceMappingURL=index.js.map