@kne/react-modal 0.1.1 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
- import { useRef, useEffect, Children } from 'react';
2
- import { Modal as Modal$1, App, Button, Tabs } from 'antd';
3
- import { CloseOutlined } from '@ant-design/icons';
1
+ import { useRef, useEffect, useState, useCallback, memo, forwardRef, useImperativeHandle, createRef, Children } from 'react';
2
+ import { Modal as Modal$1, App, Button, Drawer as Drawer$1, Tabs } from 'antd';
3
+ import { CloseOutlined, InfoCircleFilled, ExclamationCircleFilled, CloseCircleFilled, CheckCircleFilled } from '@ant-design/icons';
4
4
  import classnames from 'classnames';
5
5
  import { useMobilePopupMount, useScrollElement } from '@kne/responsive-utils';
6
6
  import { createWithIntlProvider, useIntl } from '@kne/react-intl';
@@ -49,9 +49,9 @@ const withLocale = createWithIntlProvider({
49
49
  namespace: 'react-modal'
50
50
  });
51
51
 
52
- var style = {"kne-responsive-boundary":"kne-react-modal_gh14z","kne-responsive-scroll":"kne-react-modal_Kfn6L","modal":"kne-react-modal_Bk7-B","small":"kne-react-modal_DZGD6","large":"kne-react-modal_9sz-n","modal-body-inner":"kne-react-modal_fFnva","is-mobile":"kne-react-modal_LtgJz","modal-container":"kne-react-modal_aEoZq","modal-antd-header":"kne-react-modal_54n8W","modal-antd-footer":"kne-react-modal_AJ9pV","modal-antd-body":"kne-react-modal_u2IjN","modal-outer":"kne-react-modal_kkILR","no-title":"kne-react-modal_8Iysr","no-footer":"kne-react-modal_VMxik","no-padding":"kne-react-modal_Fof-N","modal-title":"kne-react-modal_tG9MF","modal-body":"kne-react-modal_W-QFz","modal-footer":"kne-react-modal_meVfy","body-scroll-off":"kne-react-modal_l627I","is-embedded-footer":"kne-react-modal_17Eih","modal-footer-extra":"kne-react-modal_Fx8Z-","modal-footer-actions":"kne-react-modal_V3ZrX","modal-close":"kne-react-modal_-EK8N","modal-host":"kne-react-modal_eNb-h","modal-wrap":"kne-react-modal_3Sju5","modal-wrap-centered":"kne-react-modal_-qCIk","modal-wrap-fullscreen":"kne-react-modal_8lS2G","modal-mask-fullscreen":"kne-react-modal_XfLOC"};
52
+ var modalStyle = {"kne-responsive-boundary":"kne-react-modal_gh14z","kne-responsive-scroll":"kne-react-modal_Kfn6L","modal":"kne-react-modal_Bk7-B","small":"kne-react-modal_DZGD6","large":"kne-react-modal_9sz-n","modal-body-inner":"kne-react-modal_fFnva","is-mobile":"kne-react-modal_LtgJz","modal-container":"kne-react-modal_aEoZq","modal-antd-header":"kne-react-modal_54n8W","modal-antd-footer":"kne-react-modal_AJ9pV","modal-antd-body":"kne-react-modal_u2IjN","modal-outer":"kne-react-modal_kkILR","no-title":"kne-react-modal_8Iysr","no-footer":"kne-react-modal_VMxik","no-padding":"kne-react-modal_Fof-N","modal-title":"kne-react-modal_tG9MF","modal-body":"kne-react-modal_W-QFz","modal-footer":"kne-react-modal_meVfy","body-scroll-off":"kne-react-modal_l627I","is-embedded-footer":"kne-react-modal_17Eih","modal-footer-extra":"kne-react-modal_Fx8Z-","modal-footer-actions":"kne-react-modal_V3ZrX","modal-close":"kne-react-modal_-EK8N","modal-host":"kne-react-modal_eNb-h","modal-form-host":"kne-react-modal_Js8cf","modal-wrap":"kne-react-modal_3Sju5","modal-wrap-centered":"kne-react-modal_-qCIk","modal-wrap-fullscreen":"kne-react-modal_8lS2G","modal-mask-fullscreen":"kne-react-modal_XfLOC"};
53
53
 
54
- const _excluded$4 = ["ButtonComponent", "onClick", "autoClose", "display"];
54
+ const _excluded$7 = ["ButtonComponent", "onClick", "autoClose", "display"];
55
55
  const Footer = ({
56
56
  footer,
57
57
  footerButtons,
@@ -90,7 +90,7 @@ const Footer = ({
90
90
  onClick,
91
91
  autoClose = true
92
92
  } = _ref,
93
- props = _objectWithoutPropertiesLoose(_ref, _excluded$4);
93
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$7);
94
94
  return _extends({}, props, {
95
95
  buttonComponent: ButtonComponent,
96
96
  onClick: async (...args) => {
@@ -107,15 +107,15 @@ const Footer = ({
107
107
  return null;
108
108
  }
109
109
  return /*#__PURE__*/jsxs("div", {
110
- className: classnames(style['modal-footer'], 'modal-footer', {
111
- [style['is-mobile']]: isMobile,
112
- [style['is-embedded-footer']]: embeddedFooterOnly
110
+ className: classnames(modalStyle['modal-footer'], 'modal-footer', {
111
+ [modalStyle['is-mobile']]: isMobile,
112
+ [modalStyle['is-embedded-footer']]: embeddedFooterOnly
113
113
  }),
114
114
  children: [showFooterSlot ? /*#__PURE__*/jsx("div", {
115
- className: style['modal-footer-extra'],
115
+ className: modalStyle['modal-footer-extra'],
116
116
  children: footer
117
117
  }) : null, showButtons ? /*#__PURE__*/jsx("div", {
118
- className: style['modal-footer-actions'],
118
+ className: modalStyle['modal-footer-actions'],
119
119
  children: /*#__PURE__*/jsx(ButtonGroup, {
120
120
  list: list,
121
121
  showLength: list.length,
@@ -125,21 +125,21 @@ const Footer = ({
125
125
  });
126
126
  };
127
127
 
128
- const _excluded$3 = ["children", "footer", "footerButtons", "className", "size", "title", "onClose", "onConfirm", "confirmText", "onCancel", "cancelText", "closable", "noPadding", "bodyScroll", "isMobile", "mobileFullscreen", "fixedModeClass", "wrapClassName", "classNames", "styles", "style"],
129
- _excluded2 = ["width"],
130
- _excluded3 = ["size", "getContainer", "open", "mobileFullscreen", "bodyScroll"],
128
+ const _excluded$6 = ["children", "footer", "footerButtons", "className", "size", "title", "onClose", "onConfirm", "confirmText", "onCancel", "cancelText", "closable", "noPadding", "bodyScroll", "isMobile", "mobileFullscreen", "fixedModeClass", "wrapClassName", "classNames", "styles", "style", "modalRender"],
129
+ _excluded2$3 = ["width"],
130
+ _excluded3$1 = ["size", "getContainer", "open", "mobileFullscreen", "bodyScroll"],
131
131
  _excluded4 = ["afterClose", "getContainer"],
132
132
  _excluded5 = ["children", "getContainer", "afterClose"];
133
133
  const ModalLocaleRoot = withLocale(({
134
134
  children
135
135
  }) => children);
136
- const renderWithOptions = (value, options) => {
136
+ const renderWithOptions$1 = (value, options) => {
137
137
  if (typeof value === 'function') {
138
138
  return value(options);
139
139
  }
140
140
  return value;
141
141
  };
142
- const wrapCustomGetContainer = customGetContainer => {
142
+ const wrapCustomGetContainer$2 = customGetContainer => {
143
143
  if (!customGetContainer) {
144
144
  return undefined;
145
145
  }
@@ -148,10 +148,10 @@ const wrapCustomGetContainer = customGetContainer => {
148
148
  }
149
149
  return () => customGetContainer;
150
150
  };
151
- const VIEWPORT_EXAMPLE_SELECTORS = ['.example-driver-device-scroll'];
152
- const viewportPopupMountOptions = {
151
+ const VIEWPORT_EXAMPLE_SELECTORS$3 = ['.example-driver-device-scroll'];
152
+ const viewportPopupMountOptions$1 = {
153
153
  cover: 'viewport',
154
- exampleSelectors: VIEWPORT_EXAMPLE_SELECTORS
154
+ exampleSelectors: VIEWPORT_EXAMPLE_SELECTORS$3
155
155
  };
156
156
  const findParentModalMountHost = node => {
157
157
  if (!node || typeof node.closest !== 'function') {
@@ -168,7 +168,7 @@ const resolveModalGetContainer = ({
168
168
  getPopupContainer,
169
169
  getHostNode
170
170
  }) => {
171
- const wrappedCustom = wrapCustomGetContainer(customGetContainer);
171
+ const wrappedCustom = wrapCustomGetContainer$2(customGetContainer);
172
172
  return triggerNode => {
173
173
  if (wrappedCustom) {
174
174
  const custom = wrappedCustom(triggerNode);
@@ -184,17 +184,17 @@ const resolveModalGetContainer = ({
184
184
  return getPopupContainer(triggerNode);
185
185
  };
186
186
  };
187
- let parentScrollLockCount = 0;
188
- let parentScrollLocked = [];
189
- const lockParentScroll = getScrollElement => {
190
- parentScrollLockCount += 1;
191
- if (parentScrollLockCount === 1) {
187
+ let parentScrollLockCount$1 = 0;
188
+ let parentScrollLocked$1 = [];
189
+ const lockParentScroll$1 = getScrollElement => {
190
+ parentScrollLockCount$1 += 1;
191
+ if (parentScrollLockCount$1 === 1) {
192
192
  const targets = [document.body];
193
193
  const scrollEl = typeof getScrollElement === 'function' ? getScrollElement() : null;
194
194
  if (scrollEl && scrollEl !== document.body && !targets.includes(scrollEl)) {
195
195
  targets.push(scrollEl);
196
196
  }
197
- parentScrollLocked = targets.map(el => {
197
+ parentScrollLocked$1 = targets.map(el => {
198
198
  const prev = {
199
199
  overflow: el.style.overflow,
200
200
  overscrollBehavior: el.style.overscrollBehavior
@@ -208,28 +208,28 @@ const lockParentScroll = getScrollElement => {
208
208
  });
209
209
  }
210
210
  return () => {
211
- parentScrollLockCount = Math.max(0, parentScrollLockCount - 1);
212
- if (parentScrollLockCount === 0) {
213
- parentScrollLocked.forEach(({
211
+ parentScrollLockCount$1 = Math.max(0, parentScrollLockCount$1 - 1);
212
+ if (parentScrollLockCount$1 === 0) {
213
+ parentScrollLocked$1.forEach(({
214
214
  el,
215
215
  prev
216
216
  }) => {
217
217
  el.style.overflow = prev.overflow;
218
218
  el.style.overscrollBehavior = prev.overscrollBehavior;
219
219
  });
220
- parentScrollLocked = [];
220
+ parentScrollLocked$1 = [];
221
221
  }
222
222
  };
223
223
  };
224
- const useLockParentScroll = (enabled, getScrollElement) => {
224
+ const useLockParentScroll$1 = (enabled, getScrollElement) => {
225
225
  useEffect(() => {
226
226
  if (!enabled) {
227
227
  return undefined;
228
228
  }
229
- return lockParentScroll(getScrollElement);
229
+ return lockParentScroll$1(getScrollElement);
230
230
  }, [enabled, getScrollElement]);
231
231
  };
232
- const sizeStyleVars = (size, hasFooter) => {
232
+ const sizeStyleVars$1 = (size, hasFooter) => {
233
233
  const minBase = size === 'small' ? 300 : 500;
234
234
  const chrome = 48 + (hasFooter ? 58 : 0);
235
235
  const minHeight = `${Math.max(0, minBase - chrome)}px`;
@@ -268,23 +268,23 @@ const ModalOuter = ({
268
268
  }) => {
269
269
  const effectiveNoPadding = noPadding != null ? noPadding : bodyScroll === false;
270
270
  const bodyInner = /*#__PURE__*/jsx("div", {
271
- className: classnames(style['modal-body-inner'], 'modal-body-inner', {
272
- [style['no-padding']]: effectiveNoPadding
271
+ className: classnames(modalStyle['modal-body-inner'], 'modal-body-inner', {
272
+ [modalStyle['no-padding']]: effectiveNoPadding
273
273
  }),
274
274
  children: children
275
275
  });
276
- const bodyClassName = classnames(style['modal-body'], 'modal-body');
276
+ const bodyClassName = classnames(modalStyle['modal-body'], 'modal-body');
277
277
  return /*#__PURE__*/jsxs("div", {
278
- className: classnames(style['modal-outer'], 'modal-container', {
279
- [style['is-mobile']]: isMobile,
280
- [style['no-title']]: !title,
281
- [style['no-footer']]: footer === null && footerButtons === undefined,
282
- [style['no-padding']]: effectiveNoPadding
278
+ className: classnames(modalStyle['modal-outer'], 'modal-container', {
279
+ [modalStyle['is-mobile']]: isMobile,
280
+ [modalStyle['no-title']]: !title,
281
+ [modalStyle['no-footer']]: footer === null && footerButtons === undefined,
282
+ [modalStyle['no-padding']]: effectiveNoPadding
283
283
  }),
284
284
  "data-testid": "react-modal",
285
285
  children: [closable === false ? null : /*#__PURE__*/jsx(Button, {
286
286
  "data-testid": "react-modal-close-btn",
287
- className: classnames(style['modal-close'], 'modal-close'),
287
+ className: classnames(modalStyle['modal-close'], 'modal-close'),
288
288
  type: "text",
289
289
  icon: /*#__PURE__*/jsx(CloseOutlined, {}),
290
290
  onClick: e => {
@@ -292,7 +292,7 @@ const ModalOuter = ({
292
292
  onClose && onClose();
293
293
  }
294
294
  }), title ? /*#__PURE__*/jsx("div", {
295
- className: classnames(style['modal-title'], 'modal-title'),
295
+ className: classnames(modalStyle['modal-title'], 'modal-title'),
296
296
  children: title
297
297
  }) : null, bodyScroll !== false ? /*#__PURE__*/jsx(SimpleBar, {
298
298
  className: bodyClassName,
@@ -301,7 +301,7 @@ const ModalOuter = ({
301
301
  },
302
302
  children: bodyInner
303
303
  }) : /*#__PURE__*/jsx("div", {
304
- className: classnames(bodyClassName, style['body-scroll-off']),
304
+ className: classnames(bodyClassName, modalStyle['body-scroll-off']),
305
305
  children: bodyInner
306
306
  }), footer === null && footerButtons === undefined ? null : /*#__PURE__*/jsx(Footer, {
307
307
  footer: footer,
@@ -339,49 +339,51 @@ const computedCommonProps = _ref => {
339
339
  wrapClassName,
340
340
  classNames: propsClassNames,
341
341
  styles: propsStyles,
342
- style: propsStyle
342
+ style: propsStyle,
343
+ modalRender
343
344
  } = _ref,
344
- props = _objectWithoutPropertiesLoose(_ref, _excluded$3);
345
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$6);
345
346
  const useMobileLayout = isMobile && mobileFullscreen !== false;
346
347
  const hasFooter = !(footer === null && footerButtons === undefined);
347
- const sizeVars = sizeStyleVars(size, hasFooter);
348
+ const sizeVars = sizeStyleVars$1(size, hasFooter);
348
349
  const {
349
350
  width
350
351
  } = sizeVars,
351
- cssVars = _objectWithoutPropertiesLoose(sizeVars, _excluded2);
352
+ cssVars = _objectWithoutPropertiesLoose(sizeVars, _excluded2$3);
352
353
  const runChildren = options => {
353
354
  const opts = Object.assign({}, options, {
354
355
  close: onClose
355
356
  });
356
- return /*#__PURE__*/jsx(ModalOuter, {
357
- title: renderWithOptions(title, opts),
357
+ const modalPanel = /*#__PURE__*/jsx(ModalOuter, {
358
+ title: renderWithOptions$1(title, opts),
358
359
  closable: closable,
359
360
  onClose: onClose,
360
361
  onConfirm: onConfirm,
361
362
  confirmText: confirmText,
362
363
  onCancel: onCancel,
363
364
  cancelText: cancelText,
364
- footerButtons: renderWithOptions(footerButtons, opts),
365
+ footerButtons: renderWithOptions$1(footerButtons, opts),
365
366
  noPadding: noPadding,
366
- footer: renderWithOptions(footer, opts),
367
+ footer: renderWithOptions$1(footer, opts),
367
368
  targetProps: opts,
368
369
  isMobile: useMobileLayout,
369
370
  bodyScroll: bodyScroll,
370
- children: renderWithOptions(children, opts)
371
+ children: renderWithOptions$1(children, opts)
371
372
  });
373
+ return typeof modalRender === 'function' ? modalRender(modalPanel) : modalPanel;
372
374
  };
373
375
  return _extends({}, props, {
374
376
  icon: null,
375
377
  centered: !useMobileLayout,
376
378
  width: (_props$width = props.width) != null ? _props$width : useMobileLayout ? 'var(--kne-modal-viewport-width, 100vw)' : width,
377
- wrapClassName: classnames(wrapClassName, style['modal-wrap'], useMobileLayout ? style['modal-wrap-fullscreen'] : style['modal-wrap-centered'], useMobileLayout && fixedModeClass),
379
+ wrapClassName: classnames(wrapClassName, modalStyle['modal-wrap'], useMobileLayout ? modalStyle['modal-wrap-fullscreen'] : modalStyle['modal-wrap-centered'], useMobileLayout && fixedModeClass, modalRender && modalStyle['modal-form-host']),
378
380
  classNames: Object.assign({}, propsClassNames, {
379
- mask: classnames(propsClassNames == null ? void 0 : propsClassNames.mask, useMobileLayout && style['modal-mask-fullscreen'], useMobileLayout && fixedModeClass),
380
- container: classnames(style['modal-container'], useMobileLayout && style['is-mobile'], propsClassNames == null ? void 0 : propsClassNames.container),
381
- body: classnames(style['modal-antd-body'], useMobileLayout && style['is-mobile'], propsClassNames == null ? void 0 : propsClassNames.body),
382
- footer: classnames(style['modal-antd-footer'], propsClassNames == null ? void 0 : propsClassNames.footer),
383
- header: classnames(style['modal-antd-header'], propsClassNames == null ? void 0 : propsClassNames.header),
384
- content: classnames(style['modal-container'], useMobileLayout && style['is-mobile'], propsClassNames == null ? void 0 : propsClassNames.content)
381
+ mask: classnames(propsClassNames == null ? void 0 : propsClassNames.mask, useMobileLayout && modalStyle['modal-mask-fullscreen'], useMobileLayout && fixedModeClass),
382
+ container: classnames(modalStyle['modal-container'], useMobileLayout && modalStyle['is-mobile'], propsClassNames == null ? void 0 : propsClassNames.container),
383
+ body: classnames(modalStyle['modal-antd-body'], useMobileLayout && modalStyle['is-mobile'], propsClassNames == null ? void 0 : propsClassNames.body),
384
+ footer: classnames(modalStyle['modal-antd-footer'], propsClassNames == null ? void 0 : propsClassNames.footer),
385
+ header: classnames(modalStyle['modal-antd-header'], propsClassNames == null ? void 0 : propsClassNames.header),
386
+ content: classnames(modalStyle['modal-container'], useMobileLayout && modalStyle['is-mobile'], propsClassNames == null ? void 0 : propsClassNames.content)
385
387
  }),
386
388
  title: null,
387
389
  maskClosable: Object.prototype.hasOwnProperty.call(props, 'maskClosable') ? props.maskClosable : false,
@@ -389,8 +391,8 @@ const computedCommonProps = _ref => {
389
391
  footer: null,
390
392
  closable: false,
391
393
  onCancel: onClose,
392
- className: classnames(className, style['modal'], style[size], {
393
- [style['is-mobile']]: useMobileLayout
394
+ className: classnames(className, modalStyle['modal'], modalStyle[size], {
395
+ [modalStyle['is-mobile']]: useMobileLayout
394
396
  }),
395
397
  style: Object.assign({}, cssVars, propsStyle, useMobileLayout ? {
396
398
  '--kne-modal-viewport-gutter': '0px',
@@ -435,18 +437,18 @@ const Modal = withLocale(_ref2 => {
435
437
  mobileFullscreen = true,
436
438
  bodyScroll = true
437
439
  } = _ref2,
438
- props = _objectWithoutPropertiesLoose(_ref2, _excluded3);
440
+ props = _objectWithoutPropertiesLoose(_ref2, _excluded3$1);
439
441
  const hostRef = useRef(null);
440
442
  const {
441
443
  isMobile,
442
444
  fixedModeClass,
443
445
  getPopupContainer,
444
446
  anchorRef
445
- } = useMobilePopupMount(_extends({}, viewportPopupMountOptions, {
446
- getPopupContainer: wrapCustomGetContainer(getContainer)
447
+ } = useMobilePopupMount(_extends({}, viewportPopupMountOptions$1, {
448
+ getPopupContainer: wrapCustomGetContainer$2(getContainer)
447
449
  }));
448
450
  const getScrollElement = useScrollElement();
449
- useLockParentScroll(!!open, getScrollElement);
451
+ useLockParentScroll$1(!!open, getScrollElement);
450
452
  const setAnchorRef = node => {
451
453
  hostRef.current = node;
452
454
  anchorRef(node);
@@ -459,7 +461,7 @@ const Modal = withLocale(_ref2 => {
459
461
  return /*#__PURE__*/jsxs(Fragment, {
460
462
  children: [/*#__PURE__*/jsx("span", {
461
463
  ref: setAnchorRef,
462
- className: style['modal-host'],
464
+ className: modalStyle['modal-host'],
463
465
  "aria-hidden": "true"
464
466
  }), /*#__PURE__*/jsx(Modal$1, _extends({}, computedCommonProps(Object.assign({}, props, {
465
467
  size,
@@ -481,7 +483,7 @@ const useModal = () => {
481
483
  const {
482
484
  resolveMount,
483
485
  getPopupContainer
484
- } = useMobilePopupMount(viewportPopupMountOptions);
486
+ } = useMobilePopupMount(viewportPopupMountOptions$1);
485
487
  const getScrollElement = useScrollElement();
486
488
  return props => {
487
489
  const anchor = typeof document !== 'undefined' ? document.activeElement : null;
@@ -489,7 +491,7 @@ const useModal = () => {
489
491
  isMobile,
490
492
  fixedModeClass
491
493
  } = resolveMount(anchor);
492
- const unlock = lockParentScroll(getScrollElement);
494
+ const unlock = lockParentScroll$1(getScrollElement);
493
495
  const api = {};
494
496
  const {
495
497
  afterClose: userAfterClose,
@@ -527,8 +529,793 @@ const useModal = () => {
527
529
  };
528
530
  };
529
531
 
532
+ var style = {"kne-responsive-boundary":"kne-react-modal_qwqLr","kne-responsive-scroll":"kne-react-modal_vmry7","drawer":"kne-react-modal_cDsbq","small":"kne-react-modal_3QgK-","is-mobile":"kne-react-modal_FFf73","large":"kne-react-modal_8lell","drawer-body-inner":"kne-react-modal_xgX4D","drawer-antd-header":"kne-react-modal_3EUxr","drawer-antd-footer":"kne-react-modal_2G81L","drawer-antd-body":"kne-react-modal_eKVMu","drawer-outer":"kne-react-modal_P3Cw8","no-title":"kne-react-modal_upRot","no-footer":"kne-react-modal_j4sGu","no-padding":"kne-react-modal_pg37M","drawer-title":"kne-react-modal_-hw5V","drawer-body":"kne-react-modal_nJj7Y","body-scroll-off":"kne-react-modal_2Wh1H","modal-footer-extra":"kne-react-modal_M4hy9","drawer-close":"kne-react-modal_dVh38","drawer-host":"kne-react-modal_Nsxi9","drawer-host-render":"kne-react-modal_iGDWP","drawer-panel-host":"kne-react-modal_A0h-2","drawer-panel-body":"kne-react-modal_E4tcc","drawer-form-host":"kne-react-modal_vKkQW","drawer-wrapper-mobile":"kne-react-modal_vsxOs","drawer-wrapper-mobile-vertical":"kne-react-modal_HG8Vz","drawer-root-mobile":"kne-react-modal_G-qXe"};
533
+
534
+ const _excluded$5 = ["children", "footer", "footerButtons", "className", "size", "placement", "title", "onClose", "onConfirm", "confirmText", "onCancel", "cancelText", "closable", "noPadding", "bodyScroll", "isMobile", "fixedModeClass", "rootClassName", "classNames", "styles", "style", "width", "height", "modalRender", "drawerRender"],
535
+ _excluded2$2 = ["dimension"],
536
+ _excluded3 = ["size", "placement", "getContainer", "open", "bodyScroll"];
537
+ const DrawerLocaleRoot = withLocale(({
538
+ children
539
+ }) => children);
540
+ const VIEWPORT_EXAMPLE_SELECTORS$2 = ['.example-driver-device-scroll'];
541
+ const boundaryPopupMountOptions$1 = {
542
+ cover: 'boundary',
543
+ exampleSelectors: VIEWPORT_EXAMPLE_SELECTORS$2
544
+ };
545
+ const renderWithOptions = (value, options) => {
546
+ if (typeof value === 'function') {
547
+ return value(options);
548
+ }
549
+ return value;
550
+ };
551
+ const wrapCustomGetContainer$1 = customGetContainer => {
552
+ if (!customGetContainer) {
553
+ return undefined;
554
+ }
555
+ if (typeof customGetContainer === 'function') {
556
+ return triggerNode => customGetContainer(triggerNode) || null;
557
+ }
558
+ return () => customGetContainer;
559
+ };
560
+ const isVerticalPlacement = placement => placement === 'top' || placement === 'bottom';
561
+ const findParentDrawerMountHost = node => {
562
+ if (!node || typeof node.closest !== 'function') {
563
+ return null;
564
+ }
565
+ const parentRoot = node.closest('.ant-drawer-root');
566
+ if (!parentRoot) {
567
+ return null;
568
+ }
569
+ return parentRoot.parentElement || (typeof document !== 'undefined' ? document.body : null);
570
+ };
571
+ const resolveDrawerGetContainer = ({
572
+ customGetContainer,
573
+ getPopupContainer,
574
+ getHostNode
575
+ }) => {
576
+ const wrappedCustom = wrapCustomGetContainer$1(customGetContainer);
577
+ return triggerNode => {
578
+ if (wrappedCustom) {
579
+ const custom = wrappedCustom(triggerNode);
580
+ if (custom) {
581
+ return custom;
582
+ }
583
+ }
584
+ const from = triggerNode || (typeof getHostNode === 'function' ? getHostNode() : null);
585
+ const nestedHost = findParentDrawerMountHost(from);
586
+ if (nestedHost) {
587
+ return nestedHost;
588
+ }
589
+ return getPopupContainer(triggerNode);
590
+ };
591
+ };
592
+ let parentScrollLockCount = 0;
593
+ let parentScrollLocked = [];
594
+ const lockParentScroll = getScrollElement => {
595
+ parentScrollLockCount += 1;
596
+ if (parentScrollLockCount === 1) {
597
+ const targets = [document.body];
598
+ const scrollEl = typeof getScrollElement === 'function' ? getScrollElement() : null;
599
+ if (scrollEl && scrollEl !== document.body && !targets.includes(scrollEl)) {
600
+ targets.push(scrollEl);
601
+ }
602
+ parentScrollLocked = targets.map(el => {
603
+ const prev = {
604
+ overflow: el.style.overflow,
605
+ overscrollBehavior: el.style.overscrollBehavior
606
+ };
607
+ el.style.overflow = 'hidden';
608
+ el.style.overscrollBehavior = 'none';
609
+ return {
610
+ el,
611
+ prev
612
+ };
613
+ });
614
+ }
615
+ return () => {
616
+ parentScrollLockCount = Math.max(0, parentScrollLockCount - 1);
617
+ if (parentScrollLockCount === 0) {
618
+ parentScrollLocked.forEach(({
619
+ el,
620
+ prev
621
+ }) => {
622
+ el.style.overflow = prev.overflow;
623
+ el.style.overscrollBehavior = prev.overscrollBehavior;
624
+ });
625
+ parentScrollLocked = [];
626
+ }
627
+ };
628
+ };
629
+ const useLockParentScroll = (enabled, getScrollElement) => {
630
+ useEffect(() => {
631
+ if (!enabled) {
632
+ return undefined;
633
+ }
634
+ return lockParentScroll(getScrollElement);
635
+ }, [enabled, getScrollElement]);
636
+ };
637
+ const sizeStyleVars = (size, hasFooter) => {
638
+ const minBase = size === 'small' ? 300 : 500;
639
+ const chrome = 48 + (hasFooter ? 69 : 0);
640
+ const minHeight = `${Math.max(0, minBase - chrome)}px`;
641
+ const largeDim = typeof window !== 'undefined' ? `${Math.min(window.innerWidth - 64, 1500)}px` : '1500px';
642
+ if (size === 'large') {
643
+ return {
644
+ dimension: largeDim,
645
+ '--kne-drawer-body-min-height': minHeight
646
+ };
647
+ }
648
+ if (size === 'small') {
649
+ return {
650
+ dimension: '600px',
651
+ '--kne-drawer-body-min-height': minHeight
652
+ };
653
+ }
654
+ return {
655
+ dimension: '1000px',
656
+ '--kne-drawer-body-min-height': minHeight
657
+ };
658
+ };
659
+ const DrawerOuter = ({
660
+ title,
661
+ footer,
662
+ footerButtons,
663
+ noPadding,
664
+ onClose,
665
+ closable,
666
+ onConfirm,
667
+ onCancel,
668
+ children,
669
+ targetProps,
670
+ cancelText,
671
+ confirmText,
672
+ isMobile,
673
+ bodyScroll
674
+ }) => {
675
+ const effectiveNoPadding = noPadding != null ? noPadding : bodyScroll === false;
676
+ const bodyInner = /*#__PURE__*/jsx("div", {
677
+ className: classnames(style['drawer-body-inner'], 'drawer-body-inner', 'modal-body-inner', {
678
+ [style['no-padding']]: effectiveNoPadding
679
+ }),
680
+ children: children
681
+ });
682
+ const bodyClassName = classnames(style['drawer-body'], 'drawer-body', 'modal-body');
683
+ return /*#__PURE__*/jsxs("div", {
684
+ className: classnames(style['drawer-outer'], 'drawer-container', {
685
+ [style['is-mobile']]: isMobile,
686
+ [style['no-title']]: !title,
687
+ [style['no-footer']]: footer === null && footerButtons === undefined,
688
+ [style['no-padding']]: effectiveNoPadding
689
+ }),
690
+ "data-testid": "react-drawer",
691
+ children: [closable === false ? null : /*#__PURE__*/jsx(Button, {
692
+ "data-testid": "react-drawer-close-btn",
693
+ className: classnames(style['drawer-close'], 'drawer-close'),
694
+ type: "text",
695
+ icon: /*#__PURE__*/jsx(CloseOutlined, {}),
696
+ onClick: e => {
697
+ e.stopPropagation();
698
+ onClose && onClose();
699
+ }
700
+ }), title ? /*#__PURE__*/jsx("div", {
701
+ className: classnames(style['drawer-title'], 'drawer-title', 'modal-title'),
702
+ children: title
703
+ }) : null, bodyScroll !== false ? /*#__PURE__*/jsx(SimpleBar, {
704
+ className: bodyClassName,
705
+ style: {
706
+ height: 'var(--kne-drawer-body-height)'
707
+ },
708
+ children: bodyInner
709
+ }) : /*#__PURE__*/jsx("div", {
710
+ className: classnames(bodyClassName, style['body-scroll-off']),
711
+ children: bodyInner
712
+ }), footer === null && footerButtons === undefined ? null : /*#__PURE__*/jsx(Footer, {
713
+ footer: footer,
714
+ footerButtons: footerButtons,
715
+ onConfirm: onConfirm,
716
+ confirmText: confirmText,
717
+ onCancel: onCancel,
718
+ cancelText: cancelText,
719
+ onClose: onClose,
720
+ targetProps: targetProps,
721
+ isMobile: isMobile
722
+ })]
723
+ });
724
+ };
725
+ const computedDrawerProps = _ref => {
726
+ let {
727
+ children,
728
+ footer,
729
+ footerButtons,
730
+ className,
731
+ size = 'default',
732
+ placement = 'right',
733
+ title,
734
+ onClose,
735
+ onConfirm,
736
+ confirmText,
737
+ onCancel,
738
+ cancelText,
739
+ closable,
740
+ noPadding,
741
+ bodyScroll = true,
742
+ isMobile,
743
+ fixedModeClass,
744
+ rootClassName,
745
+ classNames: propsClassNames,
746
+ styles: propsStyles,
747
+ style: propsStyle,
748
+ width: propsWidth,
749
+ height: propsHeight,
750
+ modalRender,
751
+ drawerRender
752
+ } = _ref,
753
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$5);
754
+ const vertical = isVerticalPlacement(placement);
755
+ const hasFooter = !(footer === null && footerButtons === undefined);
756
+ const _sizeStyleVars = sizeStyleVars(size, hasFooter),
757
+ {
758
+ dimension
759
+ } = _sizeStyleVars,
760
+ cssVars = _objectWithoutPropertiesLoose(_sizeStyleVars, _excluded2$2);
761
+ const sizeProp = vertical ? {
762
+ height: propsHeight != null ? propsHeight : dimension
763
+ } : {
764
+ width: propsWidth != null ? propsWidth : dimension
765
+ };
766
+ const runChildren = options => {
767
+ const opts = Object.assign({}, options, {
768
+ close: onClose
769
+ });
770
+ const drawerPanel = /*#__PURE__*/jsx("div", {
771
+ className: classnames(style['drawer-panel-host'], 'drawer-panel-host'),
772
+ children: /*#__PURE__*/jsx("div", {
773
+ className: classnames(style['drawer-panel-body'], 'drawer-panel-body'),
774
+ children: /*#__PURE__*/jsx(DrawerOuter, {
775
+ title: renderWithOptions(title, opts),
776
+ closable: closable,
777
+ onClose: onClose,
778
+ onConfirm: onConfirm,
779
+ confirmText: confirmText,
780
+ onCancel: onCancel,
781
+ cancelText: cancelText,
782
+ footerButtons: renderWithOptions(footerButtons, opts),
783
+ noPadding: noPadding,
784
+ footer: renderWithOptions(footer, opts),
785
+ targetProps: opts,
786
+ isMobile: isMobile,
787
+ bodyScroll: bodyScroll,
788
+ children: renderWithOptions(children, opts)
789
+ })
790
+ })
791
+ });
792
+ return typeof modalRender === 'function' ? modalRender(drawerPanel) : drawerPanel;
793
+ };
794
+ const mobileWrapperClass = isMobile ? vertical ? style['drawer-wrapper-mobile-vertical'] : style['drawer-wrapper-mobile'] : null;
795
+ const panelLayoutStyles = {
796
+ height: '100%',
797
+ display: 'flex',
798
+ flexDirection: 'column',
799
+ padding: 0
800
+ };
801
+ return _extends({}, props, drawerRender ? {
802
+ drawerRender
803
+ } : null, {
804
+ placement
805
+ }, sizeProp, {
806
+ title: null,
807
+ maskClosable: Object.prototype.hasOwnProperty.call(props, 'maskClosable') ? props.maskClosable : false,
808
+ destroyOnHidden: true,
809
+ footer: null,
810
+ closable: false,
811
+ onClose,
812
+ rootClassName: classnames(rootClassName, isMobile && style['drawer-root-mobile'], isMobile && fixedModeClass, modalRender && style['drawer-form-host'], drawerRender && style['drawer-host-render']),
813
+ classNames: Object.assign({}, propsClassNames, {
814
+ header: classnames(style['drawer-antd-header'], propsClassNames == null ? void 0 : propsClassNames.header),
815
+ footer: classnames(style['drawer-antd-footer'], propsClassNames == null ? void 0 : propsClassNames.footer),
816
+ body: classnames(style['drawer-antd-body'], isMobile && style['is-mobile'], propsClassNames == null ? void 0 : propsClassNames.body),
817
+ wrapper: classnames(propsClassNames == null ? void 0 : propsClassNames.wrapper, mobileWrapperClass),
818
+ mask: classnames(propsClassNames == null ? void 0 : propsClassNames.mask, isMobile && fixedModeClass)
819
+ }),
820
+ className: classnames(className, style['drawer'], style[size], {
821
+ [style['is-mobile']]: isMobile
822
+ }),
823
+ style: Object.assign({}, cssVars, propsStyle, vertical ? {
824
+ '--kne-drawer-viewport-height': dimension
825
+ } : null),
826
+ styles: _extends({}, propsStyles, {
827
+ body: _extends({
828
+ padding: 0
829
+ }, propsStyles == null ? void 0 : propsStyles.body, {
830
+ flex: '1 1 auto',
831
+ minHeight: 0,
832
+ display: 'flex',
833
+ flexDirection: 'column',
834
+ overflow: 'hidden'
835
+ }, isMobile ? {
836
+ height: '100%',
837
+ maxHeight: '100%'
838
+ } : null),
839
+ section: _extends({}, panelLayoutStyles, propsStyles == null ? void 0 : propsStyles.section, propsStyles == null ? void 0 : propsStyles.content),
840
+ wrapper: _extends({}, propsStyles == null ? void 0 : propsStyles.wrapper, vertical ? {
841
+ height: 'var(--kne-drawer-viewport-height, 100vh)',
842
+ maxHeight: '100%'
843
+ } : {
844
+ height: '100%'
845
+ }, isMobile && !vertical ? {
846
+ width: 'var(--kne-viewport-width, 100vw)',
847
+ maxWidth: '100%'
848
+ } : null, isMobile && vertical ? {
849
+ height: 'var(--kne-viewport-height, 100vh)',
850
+ maxHeight: '100%'
851
+ } : null)
852
+ }),
853
+ children: /*#__PURE__*/jsx(DrawerLocaleRoot, {
854
+ children: runChildren({})
855
+ })
856
+ });
857
+ };
858
+ const Drawer = withLocale(_ref2 => {
859
+ let {
860
+ size = 'default',
861
+ placement = 'right',
862
+ getContainer,
863
+ open,
864
+ bodyScroll = true
865
+ } = _ref2,
866
+ props = _objectWithoutPropertiesLoose(_ref2, _excluded3);
867
+ const hostRef = useRef(null);
868
+ const {
869
+ isMobile,
870
+ fixedModeClass,
871
+ getPopupContainer,
872
+ anchorRef
873
+ } = useMobilePopupMount(_extends({}, boundaryPopupMountOptions$1, {
874
+ getPopupContainer: wrapCustomGetContainer$1(getContainer)
875
+ }));
876
+ const getScrollElement = useScrollElement();
877
+ useLockParentScroll(!!open, getScrollElement);
878
+ const setAnchorRef = node => {
879
+ hostRef.current = node;
880
+ anchorRef(node);
881
+ };
882
+ const getDrawerContainer = resolveDrawerGetContainer({
883
+ customGetContainer: getContainer,
884
+ getPopupContainer,
885
+ getHostNode: () => hostRef.current
886
+ });
887
+ return /*#__PURE__*/jsxs(Fragment, {
888
+ children: [/*#__PURE__*/jsx("span", {
889
+ ref: setAnchorRef,
890
+ className: style['drawer-host'],
891
+ "aria-hidden": "true"
892
+ }), /*#__PURE__*/jsx(Drawer$1, _extends({}, computedDrawerProps(Object.assign({}, props, {
893
+ size,
894
+ placement,
895
+ isMobile,
896
+ open,
897
+ fixedModeClass,
898
+ bodyScroll
899
+ })), {
900
+ open: open,
901
+ getContainer: getDrawerContainer
902
+ }))]
903
+ });
904
+ });
905
+
906
+ const usePatchElement = () => {
907
+ const [elements, setElements] = useState([]);
908
+ const patchElement = useCallback(element => {
909
+ setElements(originElements => [...originElements, element]);
910
+ return () => {
911
+ setElements(originElements => originElements.filter(ele => ele !== element));
912
+ };
913
+ }, []);
914
+ return [elements, patchElement];
915
+ };
916
+
917
+ const _excluded$4 = ["getContainer", "afterClose"],
918
+ _excluded2$1 = ["afterClose", "getContainer"];
919
+ const VIEWPORT_EXAMPLE_SELECTORS$1 = ['.example-driver-device-scroll'];
920
+ const boundaryPopupMountOptions = {
921
+ cover: 'boundary',
922
+ exampleSelectors: VIEWPORT_EXAMPLE_SELECTORS$1
923
+ };
924
+ const wrapCustomGetContainer = customGetContainer => {
925
+ if (!customGetContainer) {
926
+ return undefined;
927
+ }
928
+ if (typeof customGetContainer === 'function') {
929
+ return triggerNode => customGetContainer(triggerNode) || null;
930
+ }
931
+ return () => customGetContainer;
932
+ };
933
+ const drawerApiRef = {
934
+ current: null
935
+ };
936
+ let hookDrawerUuid = 0;
937
+ const HookDrawer = /*#__PURE__*/forwardRef(({
938
+ config,
939
+ afterClose: hookAfterClose
940
+ }, ref) => {
941
+ const [open, setOpen] = useState(true);
942
+ const [innerConfig, setInnerConfig] = useState(config);
943
+ const hostRef = useRef(null);
944
+ const {
945
+ getPopupContainer,
946
+ anchorRef
947
+ } = useMobilePopupMount(_extends({}, boundaryPopupMountOptions, {
948
+ getPopupContainer: wrapCustomGetContainer(innerConfig.getContainer)
949
+ }));
950
+ const close = () => {
951
+ setOpen(false);
952
+ };
953
+ useImperativeHandle(ref, () => ({
954
+ destroy: close,
955
+ update: newConfig => {
956
+ setInnerConfig(origin => Object.assign({}, origin, typeof newConfig === 'function' ? newConfig(origin) : newConfig));
957
+ }
958
+ }));
959
+ const {
960
+ getContainer,
961
+ afterClose: userAfterClose
962
+ } = innerConfig,
963
+ restConfig = _objectWithoutPropertiesLoose(innerConfig, _excluded$4);
964
+ const mergedAfterClose = (...args) => {
965
+ hookAfterClose && hookAfterClose(...args);
966
+ userAfterClose && userAfterClose(...args);
967
+ };
968
+ const drawerProps = computedDrawerProps(_extends({}, restConfig, {
969
+ onClose: close,
970
+ afterClose: mergedAfterClose
971
+ }));
972
+ const getDrawerContainer = resolveDrawerGetContainer({
973
+ customGetContainer: getContainer,
974
+ getPopupContainer,
975
+ getHostNode: () => hostRef.current
976
+ });
977
+ return /*#__PURE__*/jsxs(Fragment, {
978
+ children: [/*#__PURE__*/jsx("span", {
979
+ ref: node => {
980
+ hostRef.current = node;
981
+ anchorRef(node);
982
+ },
983
+ "aria-hidden": "true",
984
+ style: {
985
+ position: 'absolute',
986
+ width: 0,
987
+ height: 0,
988
+ overflow: 'hidden'
989
+ }
990
+ }), /*#__PURE__*/jsx(Drawer$1, _extends({}, drawerProps, {
991
+ open: open,
992
+ getContainer: getDrawerContainer
993
+ }))]
994
+ });
995
+ });
996
+ const ElementsHolder = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_props, ref) => {
997
+ const [elements, patchElement] = usePatchElement();
998
+ useImperativeHandle(ref, () => ({
999
+ patchElement
1000
+ }), [patchElement]);
1001
+ return /*#__PURE__*/jsx(Fragment, {
1002
+ children: elements
1003
+ });
1004
+ }));
1005
+ const useDrawerHolder = () => {
1006
+ const holderRef = useRef(null);
1007
+ const [actionQueue, setActionQueue] = useState([]);
1008
+ const {
1009
+ resolveMount,
1010
+ getPopupContainer
1011
+ } = useMobilePopupMount(boundaryPopupMountOptions);
1012
+ const getScrollElement = useScrollElement();
1013
+ useEffect(() => {
1014
+ if (actionQueue.length) {
1015
+ const cloneQueue = [...actionQueue];
1016
+ cloneQueue.forEach(action => action());
1017
+ setActionQueue([]);
1018
+ }
1019
+ }, [actionQueue]);
1020
+ const drawer = useCallback(props => {
1021
+ var _holderRef$current2;
1022
+ hookDrawerUuid += 1;
1023
+ const drawerRef = /*#__PURE__*/createRef();
1024
+ const api = {};
1025
+ let closeFunc;
1026
+ let unlock = () => {};
1027
+ const runOpen = () => {
1028
+ var _holderRef$current;
1029
+ const anchor = typeof document !== 'undefined' ? document.activeElement : null;
1030
+ const {
1031
+ isMobile,
1032
+ fixedModeClass
1033
+ } = resolveMount(anchor);
1034
+ unlock = lockParentScroll(getScrollElement);
1035
+ const {
1036
+ afterClose: userAfterClose,
1037
+ getContainer: customGetContainer
1038
+ } = props,
1039
+ restProps = _objectWithoutPropertiesLoose(props, _excluded2$1);
1040
+ const drawerEl = /*#__PURE__*/jsx(HookDrawer, {
1041
+ ref: drawerRef,
1042
+ config: _extends({}, restProps, {
1043
+ isMobile,
1044
+ fixedModeClass,
1045
+ getContainer: customGetContainer,
1046
+ onClose: () => api.close(),
1047
+ afterClose: (...args) => {
1048
+ unlock();
1049
+ userAfterClose && userAfterClose(...args);
1050
+ }
1051
+ }),
1052
+ afterClose: () => {
1053
+ closeFunc && closeFunc();
1054
+ }
1055
+ }, `react-drawer-${hookDrawerUuid}`);
1056
+ closeFunc = (_holderRef$current = holderRef.current) == null ? void 0 : _holderRef$current.patchElement(drawerEl);
1057
+ };
1058
+ if ((_holderRef$current2 = holderRef.current) != null && _holderRef$current2.patchElement) {
1059
+ runOpen();
1060
+ } else {
1061
+ setActionQueue(prev => [...prev, runOpen]);
1062
+ }
1063
+ api.close = () => {
1064
+ if (drawerRef.current) {
1065
+ drawerRef.current.destroy();
1066
+ } else {
1067
+ setActionQueue(prev => [...prev, () => {
1068
+ var _drawerRef$current;
1069
+ return (_drawerRef$current = drawerRef.current) == null ? void 0 : _drawerRef$current.destroy();
1070
+ }]);
1071
+ }
1072
+ };
1073
+ return api;
1074
+ }, [getScrollElement, resolveMount]);
1075
+ return [drawer, /*#__PURE__*/jsx(ElementsHolder, {
1076
+ ref: holderRef
1077
+ }, "drawer-elements-holder")];
1078
+ };
1079
+ const DrawerContextHolder = () => {
1080
+ const [drawer, contextHolder] = useDrawerHolder();
1081
+ drawerApiRef.current = drawer;
1082
+ return contextHolder;
1083
+ };
1084
+ const useDrawer = () => {
1085
+ if (!drawerApiRef.current) {
1086
+ throw new Error('useDrawer requires <DrawerContextHolder /> mounted inside <App> before calling useDrawer()');
1087
+ }
1088
+ return drawerApiRef.current;
1089
+ };
1090
+
1091
+ var confirmStyle = {"kne-responsive-boundary":"kne-react-modal_6tGX5","kne-responsive-scroll":"kne-react-modal_DOfki","confirm-modal-wrap":"kne-react-modal_NZArM","is-mobile":"kne-react-modal_PJp65","is-danger":"kne-react-modal_LUqb9","title-icon":"kne-react-modal_WAuWk","titleRow":"kne-react-modal_oEIMf","contentRow":"kne-react-modal_VFlnj","titleIcon":"kne-react-modal_UDO1-","title-icon-confirm":"kne-react-modal_w4spp","title-icon-info":"kne-react-modal_9DX59","title-icon-success":"kne-react-modal_pFvwL","title-icon-warning":"kne-react-modal_Wv7-o","title-icon-error":"kne-react-modal_0cNi0","titleText":"kne-react-modal_vDt06","contentText":"kne-react-modal_i15SX","has-title":"kne-react-modal_reDXC","has-icon":"kne-react-modal_Mpjjc","is-mobile-block":"kne-react-modal_C7-hV"};
1092
+
1093
+ const _excluded$3 = ["type", "icon", "title", "danger", "wrapClassName", "message", "confirmType", "getContainer", "onConfirm", "onCancel", "confirmText", "cancelText", "afterClose", "zIndex"],
1094
+ _excluded2 = ["afterClose"];
1095
+ const ConfirmLocaleRoot = withLocale(({
1096
+ children
1097
+ }) => children);
1098
+ const VIEWPORT_EXAMPLE_SELECTORS = ['.example-driver-device-scroll'];
1099
+ const viewportPopupMountOptions = {
1100
+ cover: 'viewport',
1101
+ exampleSelectors: VIEWPORT_EXAMPLE_SELECTORS
1102
+ };
1103
+ const ICON_BY_TYPE = {
1104
+ info: InfoCircleFilled,
1105
+ confirm: ExclamationCircleFilled,
1106
+ warning: ExclamationCircleFilled,
1107
+ error: CloseCircleFilled,
1108
+ success: CheckCircleFilled
1109
+ };
1110
+ const getIconKind = (type, confirmType) => type === 'confirm' ? confirmType : type;
1111
+ const shouldShowDefaultIcon = ({
1112
+ type,
1113
+ danger,
1114
+ icon
1115
+ }) => {
1116
+ if (icon === false || icon === null) {
1117
+ return false;
1118
+ }
1119
+ if (type === 'confirm') {
1120
+ return !!danger;
1121
+ }
1122
+ return ['info', 'success', 'warning', 'error'].includes(type);
1123
+ };
1124
+ const getConfirmIconNode = ({
1125
+ type,
1126
+ confirmType: _confirmType = 'info',
1127
+ danger,
1128
+ icon
1129
+ }) => {
1130
+ if (icon) {
1131
+ return icon;
1132
+ }
1133
+ if (!shouldShowDefaultIcon({
1134
+ type,
1135
+ danger,
1136
+ icon
1137
+ })) {
1138
+ return null;
1139
+ }
1140
+ const kind = getIconKind(type, _confirmType);
1141
+ const IconComponent = ICON_BY_TYPE[kind] || ICON_BY_TYPE.info;
1142
+ return /*#__PURE__*/jsx(IconComponent, {
1143
+ className: classnames(confirmStyle['title-icon'], confirmStyle[`title-icon-${kind}`])
1144
+ });
1145
+ };
1146
+ const buildConfirmContent = ({
1147
+ type,
1148
+ confirmType,
1149
+ title,
1150
+ message,
1151
+ danger,
1152
+ icon,
1153
+ isMobile
1154
+ }) => {
1155
+ const iconNode = getConfirmIconNode({
1156
+ type,
1157
+ confirmType,
1158
+ danger,
1159
+ icon
1160
+ });
1161
+ const mobileClass = isMobile ? confirmStyle['is-mobile-block'] : null;
1162
+ return {
1163
+ title: title ? /*#__PURE__*/jsxs("div", {
1164
+ className: classnames(confirmStyle.titleRow, mobileClass),
1165
+ onClick: e => {
1166
+ e.stopPropagation();
1167
+ },
1168
+ children: [iconNode ? /*#__PURE__*/jsx("span", {
1169
+ className: confirmStyle.titleIcon,
1170
+ children: iconNode
1171
+ }) : null, /*#__PURE__*/jsx("div", {
1172
+ className: confirmStyle.titleText,
1173
+ children: title
1174
+ })]
1175
+ }) : null,
1176
+ content: /*#__PURE__*/jsxs("div", {
1177
+ className: classnames(confirmStyle.contentRow, mobileClass, {
1178
+ [confirmStyle['has-title']]: title,
1179
+ [confirmStyle['has-icon']]: !!iconNode && title
1180
+ }),
1181
+ children: [!title && iconNode ? /*#__PURE__*/jsx("span", {
1182
+ className: confirmStyle.titleIcon,
1183
+ children: iconNode
1184
+ }) : null, /*#__PURE__*/jsx("div", {
1185
+ className: confirmStyle.contentText,
1186
+ children: message
1187
+ })]
1188
+ })
1189
+ };
1190
+ };
1191
+ const mapConfirmProps = (props, {
1192
+ isMobile,
1193
+ fixedModeClass,
1194
+ getPopupContainer,
1195
+ anchor,
1196
+ unlock,
1197
+ userAfterClose
1198
+ }) => {
1199
+ var _otherProps$className;
1200
+ const _maskClosable$props = _extends({
1201
+ maskClosable: false
1202
+ }, props),
1203
+ {
1204
+ type = 'confirm',
1205
+ icon,
1206
+ title,
1207
+ danger,
1208
+ wrapClassName,
1209
+ message,
1210
+ confirmType = 'info',
1211
+ getContainer: customGetContainer,
1212
+ onConfirm,
1213
+ onCancel,
1214
+ confirmText,
1215
+ cancelText,
1216
+ afterClose,
1217
+ zIndex
1218
+ } = _maskClosable$props,
1219
+ otherProps = _objectWithoutPropertiesLoose(_maskClosable$props, _excluded$3);
1220
+ const {
1221
+ title: confirmTitle,
1222
+ content
1223
+ } = buildConfirmContent({
1224
+ type,
1225
+ confirmType,
1226
+ title,
1227
+ message,
1228
+ danger,
1229
+ icon,
1230
+ isMobile
1231
+ });
1232
+ return {
1233
+ modalMethod: type,
1234
+ config: _extends({}, otherProps, {
1235
+ zIndex: zIndex != null ? zIndex : 1100,
1236
+ okText: confirmText != null ? confirmText : otherProps.okText,
1237
+ cancelText: cancelText != null ? cancelText : otherProps.cancelText,
1238
+ onOk: onConfirm != null ? onConfirm : otherProps.onOk,
1239
+ onCancel: onCancel != null ? onCancel : otherProps.onCancel,
1240
+ getContainer: resolveModalGetContainer({
1241
+ customGetContainer,
1242
+ getPopupContainer,
1243
+ getHostNode: () => anchor
1244
+ }),
1245
+ centered: true,
1246
+ afterClose: (...args) => {
1247
+ unlock();
1248
+ userAfterClose && userAfterClose(...args);
1249
+ afterClose && afterClose(...args);
1250
+ },
1251
+ icon: null,
1252
+ classNames: {
1253
+ mask: classnames(isMobile && modalStyle['modal-mask-fullscreen'], isMobile && fixedModeClass, (_otherProps$className = otherProps.classNames) == null ? void 0 : _otherProps$className.mask)
1254
+ },
1255
+ wrapClassName: classnames(modalStyle['modal-wrap'], confirmStyle['confirm-modal-wrap'], wrapClassName, {
1256
+ [confirmStyle['is-danger']]: danger,
1257
+ [confirmStyle['is-mobile']]: isMobile,
1258
+ [modalStyle['modal-wrap-centered']]: isMobile,
1259
+ [fixedModeClass]: isMobile
1260
+ }),
1261
+ title: confirmTitle ? /*#__PURE__*/jsx(ConfirmLocaleRoot, {
1262
+ children: confirmTitle
1263
+ }) : null,
1264
+ content: /*#__PURE__*/jsx(ConfirmLocaleRoot, {
1265
+ children: content
1266
+ })
1267
+ })
1268
+ };
1269
+ };
1270
+ const useConfirmModal = () => {
1271
+ const {
1272
+ modal
1273
+ } = App.useApp();
1274
+ const {
1275
+ resolveMount,
1276
+ getPopupContainer
1277
+ } = useMobilePopupMount(viewportPopupMountOptions);
1278
+ const getScrollElement = useScrollElement();
1279
+ return props => {
1280
+ const anchor = typeof document !== 'undefined' ? document.activeElement : null;
1281
+ const {
1282
+ isMobile,
1283
+ fixedModeClass
1284
+ } = resolveMount(anchor);
1285
+ const unlock = lockParentScroll$1(getScrollElement);
1286
+ const api = {};
1287
+ const {
1288
+ afterClose: userAfterClose
1289
+ } = props,
1290
+ restProps = _objectWithoutPropertiesLoose(props, _excluded2);
1291
+ const {
1292
+ modalMethod,
1293
+ config
1294
+ } = mapConfirmProps(_extends({}, restProps, {
1295
+ onClose: () => api.close()
1296
+ }), {
1297
+ isMobile,
1298
+ fixedModeClass,
1299
+ getPopupContainer,
1300
+ anchor,
1301
+ unlock,
1302
+ userAfterClose
1303
+ });
1304
+ if (typeof modal[modalMethod] === 'function') {
1305
+ const {
1306
+ destroy
1307
+ } = modal[modalMethod](config);
1308
+ api.close = destroy;
1309
+ } else {
1310
+ unlock();
1311
+ api.close = () => {};
1312
+ }
1313
+ return api;
1314
+ };
1315
+ };
1316
+
530
1317
  const _excluded$2 = ["className", "inset", "children"];
531
- const ModalScrollRegion = _ref => {
1318
+ const ScrollRegion = _ref => {
532
1319
  let {
533
1320
  className,
534
1321
  inset = false,
@@ -546,7 +1333,7 @@ const ModalScrollRegion = _ref => {
546
1333
  };
547
1334
 
548
1335
  const _excluded$1 = ["className", "destroyOnHidden"];
549
- const ModalTabsLayout = _ref => {
1336
+ const TabsLayout = _ref => {
550
1337
  let {
551
1338
  className,
552
1339
  destroyOnHidden = true
@@ -572,7 +1359,7 @@ const resolveColStyle = width => {
572
1359
  minWidth: 0
573
1360
  };
574
1361
  };
575
- const ModalColumnsLayout = _ref => {
1362
+ const ColumnsLayout = _ref => {
576
1363
  let {
577
1364
  widths,
578
1365
  className,
@@ -593,10 +1380,12 @@ const ModalColumnsLayout = _ref => {
593
1380
 
594
1381
  const createModalRender = modalDefaults => hostProps => /*#__PURE__*/jsx(Modal, _extends({}, modalDefaults, hostProps));
595
1382
 
1383
+ const createDrawerRender = drawerDefaults => hostProps => /*#__PURE__*/jsx(Drawer, _extends({}, drawerDefaults, hostProps));
1384
+
596
1385
  const modalClassNames = {
597
1386
  stepsForm: 'react-modal-steps-form',
598
1387
  splitter: 'react-modal-splitter'
599
1388
  };
600
1389
 
601
- export { ModalColumnsLayout, ModalScrollRegion, ModalTabsLayout, createModalRender, Modal as default, modalClassNames, useModal };
1390
+ export { ColumnsLayout, Drawer, DrawerContextHolder, ScrollRegion, TabsLayout, createDrawerRender, createModalRender, Modal as default, modalClassNames, useConfirmModal, useDrawer, useModal };
602
1391
  //# sourceMappingURL=index.modern.js.map