@kne/react-modal 0.1.1 → 0.1.4

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-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"],
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,
@@ -341,47 +341,47 @@ const computedCommonProps = _ref => {
341
341
  styles: propsStyles,
342
342
  style: propsStyle
343
343
  } = _ref,
344
- props = _objectWithoutPropertiesLoose(_ref, _excluded$3);
344
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$6);
345
345
  const useMobileLayout = isMobile && mobileFullscreen !== false;
346
346
  const hasFooter = !(footer === null && footerButtons === undefined);
347
- const sizeVars = sizeStyleVars(size, hasFooter);
347
+ const sizeVars = sizeStyleVars$1(size, hasFooter);
348
348
  const {
349
349
  width
350
350
  } = sizeVars,
351
- cssVars = _objectWithoutPropertiesLoose(sizeVars, _excluded2);
351
+ cssVars = _objectWithoutPropertiesLoose(sizeVars, _excluded2$3);
352
352
  const runChildren = options => {
353
353
  const opts = Object.assign({}, options, {
354
354
  close: onClose
355
355
  });
356
356
  return /*#__PURE__*/jsx(ModalOuter, {
357
- title: renderWithOptions(title, opts),
357
+ title: renderWithOptions$1(title, opts),
358
358
  closable: closable,
359
359
  onClose: onClose,
360
360
  onConfirm: onConfirm,
361
361
  confirmText: confirmText,
362
362
  onCancel: onCancel,
363
363
  cancelText: cancelText,
364
- footerButtons: renderWithOptions(footerButtons, opts),
364
+ footerButtons: renderWithOptions$1(footerButtons, opts),
365
365
  noPadding: noPadding,
366
- footer: renderWithOptions(footer, opts),
366
+ footer: renderWithOptions$1(footer, opts),
367
367
  targetProps: opts,
368
368
  isMobile: useMobileLayout,
369
369
  bodyScroll: bodyScroll,
370
- children: renderWithOptions(children, opts)
370
+ children: renderWithOptions$1(children, opts)
371
371
  });
372
372
  };
373
373
  return _extends({}, props, {
374
374
  icon: null,
375
375
  centered: !useMobileLayout,
376
376
  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),
377
+ wrapClassName: classnames(wrapClassName, modalStyle['modal-wrap'], useMobileLayout ? modalStyle['modal-wrap-fullscreen'] : modalStyle['modal-wrap-centered'], useMobileLayout && fixedModeClass),
378
378
  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)
379
+ mask: classnames(propsClassNames == null ? void 0 : propsClassNames.mask, useMobileLayout && modalStyle['modal-mask-fullscreen'], useMobileLayout && fixedModeClass),
380
+ container: classnames(modalStyle['modal-container'], useMobileLayout && modalStyle['is-mobile'], propsClassNames == null ? void 0 : propsClassNames.container),
381
+ body: classnames(modalStyle['modal-antd-body'], useMobileLayout && modalStyle['is-mobile'], propsClassNames == null ? void 0 : propsClassNames.body),
382
+ footer: classnames(modalStyle['modal-antd-footer'], propsClassNames == null ? void 0 : propsClassNames.footer),
383
+ header: classnames(modalStyle['modal-antd-header'], propsClassNames == null ? void 0 : propsClassNames.header),
384
+ content: classnames(modalStyle['modal-container'], useMobileLayout && modalStyle['is-mobile'], propsClassNames == null ? void 0 : propsClassNames.content)
385
385
  }),
386
386
  title: null,
387
387
  maskClosable: Object.prototype.hasOwnProperty.call(props, 'maskClosable') ? props.maskClosable : false,
@@ -389,8 +389,8 @@ const computedCommonProps = _ref => {
389
389
  footer: null,
390
390
  closable: false,
391
391
  onCancel: onClose,
392
- className: classnames(className, style['modal'], style[size], {
393
- [style['is-mobile']]: useMobileLayout
392
+ className: classnames(className, modalStyle['modal'], modalStyle[size], {
393
+ [modalStyle['is-mobile']]: useMobileLayout
394
394
  }),
395
395
  style: Object.assign({}, cssVars, propsStyle, useMobileLayout ? {
396
396
  '--kne-modal-viewport-gutter': '0px',
@@ -435,18 +435,18 @@ const Modal = withLocale(_ref2 => {
435
435
  mobileFullscreen = true,
436
436
  bodyScroll = true
437
437
  } = _ref2,
438
- props = _objectWithoutPropertiesLoose(_ref2, _excluded3);
438
+ props = _objectWithoutPropertiesLoose(_ref2, _excluded3$1);
439
439
  const hostRef = useRef(null);
440
440
  const {
441
441
  isMobile,
442
442
  fixedModeClass,
443
443
  getPopupContainer,
444
444
  anchorRef
445
- } = useMobilePopupMount(_extends({}, viewportPopupMountOptions, {
446
- getPopupContainer: wrapCustomGetContainer(getContainer)
445
+ } = useMobilePopupMount(_extends({}, viewportPopupMountOptions$1, {
446
+ getPopupContainer: wrapCustomGetContainer$2(getContainer)
447
447
  }));
448
448
  const getScrollElement = useScrollElement();
449
- useLockParentScroll(!!open, getScrollElement);
449
+ useLockParentScroll$1(!!open, getScrollElement);
450
450
  const setAnchorRef = node => {
451
451
  hostRef.current = node;
452
452
  anchorRef(node);
@@ -459,7 +459,7 @@ const Modal = withLocale(_ref2 => {
459
459
  return /*#__PURE__*/jsxs(Fragment, {
460
460
  children: [/*#__PURE__*/jsx("span", {
461
461
  ref: setAnchorRef,
462
- className: style['modal-host'],
462
+ className: modalStyle['modal-host'],
463
463
  "aria-hidden": "true"
464
464
  }), /*#__PURE__*/jsx(Modal$1, _extends({}, computedCommonProps(Object.assign({}, props, {
465
465
  size,
@@ -481,7 +481,7 @@ const useModal = () => {
481
481
  const {
482
482
  resolveMount,
483
483
  getPopupContainer
484
- } = useMobilePopupMount(viewportPopupMountOptions);
484
+ } = useMobilePopupMount(viewportPopupMountOptions$1);
485
485
  const getScrollElement = useScrollElement();
486
486
  return props => {
487
487
  const anchor = typeof document !== 'undefined' ? document.activeElement : null;
@@ -489,7 +489,7 @@ const useModal = () => {
489
489
  isMobile,
490
490
  fixedModeClass
491
491
  } = resolveMount(anchor);
492
- const unlock = lockParentScroll(getScrollElement);
492
+ const unlock = lockParentScroll$1(getScrollElement);
493
493
  const api = {};
494
494
  const {
495
495
  afterClose: userAfterClose,
@@ -527,8 +527,793 @@ const useModal = () => {
527
527
  };
528
528
  };
529
529
 
530
+ 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"};
531
+
532
+ 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"],
533
+ _excluded2$2 = ["dimension"],
534
+ _excluded3 = ["size", "placement", "getContainer", "open", "bodyScroll"];
535
+ const DrawerLocaleRoot = withLocale(({
536
+ children
537
+ }) => children);
538
+ const VIEWPORT_EXAMPLE_SELECTORS$2 = ['.example-driver-device-scroll'];
539
+ const boundaryPopupMountOptions$1 = {
540
+ cover: 'boundary',
541
+ exampleSelectors: VIEWPORT_EXAMPLE_SELECTORS$2
542
+ };
543
+ const renderWithOptions = (value, options) => {
544
+ if (typeof value === 'function') {
545
+ return value(options);
546
+ }
547
+ return value;
548
+ };
549
+ const wrapCustomGetContainer$1 = customGetContainer => {
550
+ if (!customGetContainer) {
551
+ return undefined;
552
+ }
553
+ if (typeof customGetContainer === 'function') {
554
+ return triggerNode => customGetContainer(triggerNode) || null;
555
+ }
556
+ return () => customGetContainer;
557
+ };
558
+ const isVerticalPlacement = placement => placement === 'top' || placement === 'bottom';
559
+ const findParentDrawerMountHost = node => {
560
+ if (!node || typeof node.closest !== 'function') {
561
+ return null;
562
+ }
563
+ const parentRoot = node.closest('.ant-drawer-root');
564
+ if (!parentRoot) {
565
+ return null;
566
+ }
567
+ return parentRoot.parentElement || (typeof document !== 'undefined' ? document.body : null);
568
+ };
569
+ const resolveDrawerGetContainer = ({
570
+ customGetContainer,
571
+ getPopupContainer,
572
+ getHostNode
573
+ }) => {
574
+ const wrappedCustom = wrapCustomGetContainer$1(customGetContainer);
575
+ return triggerNode => {
576
+ if (wrappedCustom) {
577
+ const custom = wrappedCustom(triggerNode);
578
+ if (custom) {
579
+ return custom;
580
+ }
581
+ }
582
+ const from = triggerNode || (typeof getHostNode === 'function' ? getHostNode() : null);
583
+ const nestedHost = findParentDrawerMountHost(from);
584
+ if (nestedHost) {
585
+ return nestedHost;
586
+ }
587
+ return getPopupContainer(triggerNode);
588
+ };
589
+ };
590
+ let parentScrollLockCount = 0;
591
+ let parentScrollLocked = [];
592
+ const lockParentScroll = getScrollElement => {
593
+ parentScrollLockCount += 1;
594
+ if (parentScrollLockCount === 1) {
595
+ const targets = [document.body];
596
+ const scrollEl = typeof getScrollElement === 'function' ? getScrollElement() : null;
597
+ if (scrollEl && scrollEl !== document.body && !targets.includes(scrollEl)) {
598
+ targets.push(scrollEl);
599
+ }
600
+ parentScrollLocked = targets.map(el => {
601
+ const prev = {
602
+ overflow: el.style.overflow,
603
+ overscrollBehavior: el.style.overscrollBehavior
604
+ };
605
+ el.style.overflow = 'hidden';
606
+ el.style.overscrollBehavior = 'none';
607
+ return {
608
+ el,
609
+ prev
610
+ };
611
+ });
612
+ }
613
+ return () => {
614
+ parentScrollLockCount = Math.max(0, parentScrollLockCount - 1);
615
+ if (parentScrollLockCount === 0) {
616
+ parentScrollLocked.forEach(({
617
+ el,
618
+ prev
619
+ }) => {
620
+ el.style.overflow = prev.overflow;
621
+ el.style.overscrollBehavior = prev.overscrollBehavior;
622
+ });
623
+ parentScrollLocked = [];
624
+ }
625
+ };
626
+ };
627
+ const useLockParentScroll = (enabled, getScrollElement) => {
628
+ useEffect(() => {
629
+ if (!enabled) {
630
+ return undefined;
631
+ }
632
+ return lockParentScroll(getScrollElement);
633
+ }, [enabled, getScrollElement]);
634
+ };
635
+ const sizeStyleVars = (size, hasFooter) => {
636
+ const minBase = size === 'small' ? 300 : 500;
637
+ const chrome = 48 + (hasFooter ? 69 : 0);
638
+ const minHeight = `${Math.max(0, minBase - chrome)}px`;
639
+ const largeDim = typeof window !== 'undefined' ? `${Math.min(window.innerWidth - 64, 1500)}px` : '1500px';
640
+ if (size === 'large') {
641
+ return {
642
+ dimension: largeDim,
643
+ '--kne-drawer-body-min-height': minHeight
644
+ };
645
+ }
646
+ if (size === 'small') {
647
+ return {
648
+ dimension: '600px',
649
+ '--kne-drawer-body-min-height': minHeight
650
+ };
651
+ }
652
+ return {
653
+ dimension: '1000px',
654
+ '--kne-drawer-body-min-height': minHeight
655
+ };
656
+ };
657
+ const DrawerOuter = ({
658
+ title,
659
+ footer,
660
+ footerButtons,
661
+ noPadding,
662
+ onClose,
663
+ closable,
664
+ onConfirm,
665
+ onCancel,
666
+ children,
667
+ targetProps,
668
+ cancelText,
669
+ confirmText,
670
+ isMobile,
671
+ bodyScroll
672
+ }) => {
673
+ const effectiveNoPadding = noPadding != null ? noPadding : bodyScroll === false;
674
+ const bodyInner = /*#__PURE__*/jsx("div", {
675
+ className: classnames(style['drawer-body-inner'], 'drawer-body-inner', 'modal-body-inner', {
676
+ [style['no-padding']]: effectiveNoPadding
677
+ }),
678
+ children: children
679
+ });
680
+ const bodyClassName = classnames(style['drawer-body'], 'drawer-body', 'modal-body');
681
+ return /*#__PURE__*/jsxs("div", {
682
+ className: classnames(style['drawer-outer'], 'drawer-container', {
683
+ [style['is-mobile']]: isMobile,
684
+ [style['no-title']]: !title,
685
+ [style['no-footer']]: footer === null && footerButtons === undefined,
686
+ [style['no-padding']]: effectiveNoPadding
687
+ }),
688
+ "data-testid": "react-drawer",
689
+ children: [closable === false ? null : /*#__PURE__*/jsx(Button, {
690
+ "data-testid": "react-drawer-close-btn",
691
+ className: classnames(style['drawer-close'], 'drawer-close'),
692
+ type: "text",
693
+ icon: /*#__PURE__*/jsx(CloseOutlined, {}),
694
+ onClick: e => {
695
+ e.stopPropagation();
696
+ onClose && onClose();
697
+ }
698
+ }), title ? /*#__PURE__*/jsx("div", {
699
+ className: classnames(style['drawer-title'], 'drawer-title', 'modal-title'),
700
+ children: title
701
+ }) : null, bodyScroll !== false ? /*#__PURE__*/jsx(SimpleBar, {
702
+ className: bodyClassName,
703
+ style: {
704
+ height: 'var(--kne-drawer-body-height)'
705
+ },
706
+ children: bodyInner
707
+ }) : /*#__PURE__*/jsx("div", {
708
+ className: classnames(bodyClassName, style['body-scroll-off']),
709
+ children: bodyInner
710
+ }), footer === null && footerButtons === undefined ? null : /*#__PURE__*/jsx(Footer, {
711
+ footer: footer,
712
+ footerButtons: footerButtons,
713
+ onConfirm: onConfirm,
714
+ confirmText: confirmText,
715
+ onCancel: onCancel,
716
+ cancelText: cancelText,
717
+ onClose: onClose,
718
+ targetProps: targetProps,
719
+ isMobile: isMobile
720
+ })]
721
+ });
722
+ };
723
+ const computedDrawerProps = _ref => {
724
+ let {
725
+ children,
726
+ footer,
727
+ footerButtons,
728
+ className,
729
+ size = 'default',
730
+ placement = 'right',
731
+ title,
732
+ onClose,
733
+ onConfirm,
734
+ confirmText,
735
+ onCancel,
736
+ cancelText,
737
+ closable,
738
+ noPadding,
739
+ bodyScroll = true,
740
+ isMobile,
741
+ fixedModeClass,
742
+ rootClassName,
743
+ classNames: propsClassNames,
744
+ styles: propsStyles,
745
+ style: propsStyle,
746
+ width: propsWidth,
747
+ height: propsHeight,
748
+ modalRender,
749
+ drawerRender
750
+ } = _ref,
751
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$5);
752
+ const vertical = isVerticalPlacement(placement);
753
+ const hasFooter = !(footer === null && footerButtons === undefined);
754
+ const _sizeStyleVars = sizeStyleVars(size, hasFooter),
755
+ {
756
+ dimension
757
+ } = _sizeStyleVars,
758
+ cssVars = _objectWithoutPropertiesLoose(_sizeStyleVars, _excluded2$2);
759
+ const sizeProp = vertical ? {
760
+ height: propsHeight != null ? propsHeight : dimension
761
+ } : {
762
+ width: propsWidth != null ? propsWidth : dimension
763
+ };
764
+ const runChildren = options => {
765
+ const opts = Object.assign({}, options, {
766
+ close: onClose
767
+ });
768
+ const drawerPanel = /*#__PURE__*/jsx("div", {
769
+ className: classnames(style['drawer-panel-host'], 'drawer-panel-host'),
770
+ children: /*#__PURE__*/jsx("div", {
771
+ className: classnames(style['drawer-panel-body'], 'drawer-panel-body'),
772
+ children: /*#__PURE__*/jsx(DrawerOuter, {
773
+ title: renderWithOptions(title, opts),
774
+ closable: closable,
775
+ onClose: onClose,
776
+ onConfirm: onConfirm,
777
+ confirmText: confirmText,
778
+ onCancel: onCancel,
779
+ cancelText: cancelText,
780
+ footerButtons: renderWithOptions(footerButtons, opts),
781
+ noPadding: noPadding,
782
+ footer: renderWithOptions(footer, opts),
783
+ targetProps: opts,
784
+ isMobile: isMobile,
785
+ bodyScroll: bodyScroll,
786
+ children: renderWithOptions(children, opts)
787
+ })
788
+ })
789
+ });
790
+ return typeof modalRender === 'function' ? modalRender(drawerPanel) : drawerPanel;
791
+ };
792
+ const mobileWrapperClass = isMobile ? vertical ? style['drawer-wrapper-mobile-vertical'] : style['drawer-wrapper-mobile'] : null;
793
+ const panelLayoutStyles = {
794
+ height: '100%',
795
+ display: 'flex',
796
+ flexDirection: 'column',
797
+ padding: 0
798
+ };
799
+ return _extends({}, props, drawerRender ? {
800
+ drawerRender
801
+ } : null, {
802
+ placement
803
+ }, sizeProp, {
804
+ title: null,
805
+ maskClosable: Object.prototype.hasOwnProperty.call(props, 'maskClosable') ? props.maskClosable : false,
806
+ destroyOnHidden: true,
807
+ footer: null,
808
+ closable: false,
809
+ onClose,
810
+ rootClassName: classnames(rootClassName, isMobile && style['drawer-root-mobile'], isMobile && fixedModeClass, modalRender && style['drawer-form-host'], drawerRender && style['drawer-host-render']),
811
+ classNames: Object.assign({}, propsClassNames, {
812
+ header: classnames(style['drawer-antd-header'], propsClassNames == null ? void 0 : propsClassNames.header),
813
+ footer: classnames(style['drawer-antd-footer'], propsClassNames == null ? void 0 : propsClassNames.footer),
814
+ body: classnames(style['drawer-antd-body'], isMobile && style['is-mobile'], propsClassNames == null ? void 0 : propsClassNames.body),
815
+ wrapper: classnames(propsClassNames == null ? void 0 : propsClassNames.wrapper, mobileWrapperClass),
816
+ mask: classnames(propsClassNames == null ? void 0 : propsClassNames.mask, isMobile && fixedModeClass)
817
+ }),
818
+ className: classnames(className, style['drawer'], style[size], {
819
+ [style['is-mobile']]: isMobile
820
+ }),
821
+ style: Object.assign({}, cssVars, propsStyle, vertical ? {
822
+ '--kne-drawer-viewport-height': dimension
823
+ } : null),
824
+ styles: _extends({}, propsStyles, {
825
+ body: _extends({
826
+ padding: 0
827
+ }, propsStyles == null ? void 0 : propsStyles.body, {
828
+ flex: '1 1 auto',
829
+ minHeight: 0,
830
+ display: 'flex',
831
+ flexDirection: 'column',
832
+ overflow: 'hidden'
833
+ }, isMobile ? {
834
+ height: '100%',
835
+ maxHeight: '100%'
836
+ } : null),
837
+ section: _extends({}, panelLayoutStyles, propsStyles == null ? void 0 : propsStyles.section, propsStyles == null ? void 0 : propsStyles.content),
838
+ wrapper: _extends({}, propsStyles == null ? void 0 : propsStyles.wrapper, vertical ? {
839
+ height: 'var(--kne-drawer-viewport-height, 100vh)',
840
+ maxHeight: '100%'
841
+ } : {
842
+ height: '100%'
843
+ }, isMobile && !vertical ? {
844
+ width: 'var(--kne-viewport-width, 100vw)',
845
+ maxWidth: '100%'
846
+ } : null, isMobile && vertical ? {
847
+ height: 'var(--kne-viewport-height, 100vh)',
848
+ maxHeight: '100%'
849
+ } : null)
850
+ }),
851
+ children: /*#__PURE__*/jsx(DrawerLocaleRoot, {
852
+ children: runChildren({})
853
+ })
854
+ });
855
+ };
856
+ const Drawer = withLocale(_ref2 => {
857
+ let {
858
+ size = 'default',
859
+ placement = 'right',
860
+ getContainer,
861
+ open,
862
+ bodyScroll = true
863
+ } = _ref2,
864
+ props = _objectWithoutPropertiesLoose(_ref2, _excluded3);
865
+ const hostRef = useRef(null);
866
+ const {
867
+ isMobile,
868
+ fixedModeClass,
869
+ getPopupContainer,
870
+ anchorRef
871
+ } = useMobilePopupMount(_extends({}, boundaryPopupMountOptions$1, {
872
+ getPopupContainer: wrapCustomGetContainer$1(getContainer)
873
+ }));
874
+ const getScrollElement = useScrollElement();
875
+ useLockParentScroll(!!open, getScrollElement);
876
+ const setAnchorRef = node => {
877
+ hostRef.current = node;
878
+ anchorRef(node);
879
+ };
880
+ const getDrawerContainer = resolveDrawerGetContainer({
881
+ customGetContainer: getContainer,
882
+ getPopupContainer,
883
+ getHostNode: () => hostRef.current
884
+ });
885
+ return /*#__PURE__*/jsxs(Fragment, {
886
+ children: [/*#__PURE__*/jsx("span", {
887
+ ref: setAnchorRef,
888
+ className: style['drawer-host'],
889
+ "aria-hidden": "true"
890
+ }), /*#__PURE__*/jsx(Drawer$1, _extends({}, computedDrawerProps(Object.assign({}, props, {
891
+ size,
892
+ placement,
893
+ isMobile,
894
+ open,
895
+ fixedModeClass,
896
+ bodyScroll
897
+ })), {
898
+ open: open,
899
+ getContainer: getDrawerContainer
900
+ }))]
901
+ });
902
+ });
903
+
904
+ const usePatchElement = () => {
905
+ const [elements, setElements] = useState([]);
906
+ const patchElement = useCallback(element => {
907
+ setElements(originElements => [...originElements, element]);
908
+ return () => {
909
+ setElements(originElements => originElements.filter(ele => ele !== element));
910
+ };
911
+ }, []);
912
+ return [elements, patchElement];
913
+ };
914
+
915
+ const _excluded$4 = ["getContainer", "afterClose"],
916
+ _excluded2$1 = ["afterClose", "getContainer"];
917
+ const VIEWPORT_EXAMPLE_SELECTORS$1 = ['.example-driver-device-scroll'];
918
+ const boundaryPopupMountOptions = {
919
+ cover: 'boundary',
920
+ exampleSelectors: VIEWPORT_EXAMPLE_SELECTORS$1
921
+ };
922
+ const wrapCustomGetContainer = customGetContainer => {
923
+ if (!customGetContainer) {
924
+ return undefined;
925
+ }
926
+ if (typeof customGetContainer === 'function') {
927
+ return triggerNode => customGetContainer(triggerNode) || null;
928
+ }
929
+ return () => customGetContainer;
930
+ };
931
+ const drawerApiRef = {
932
+ current: null
933
+ };
934
+ let hookDrawerUuid = 0;
935
+ const HookDrawer = /*#__PURE__*/forwardRef(({
936
+ config,
937
+ afterClose: hookAfterClose
938
+ }, ref) => {
939
+ const [open, setOpen] = useState(true);
940
+ const [innerConfig, setInnerConfig] = useState(config);
941
+ const hostRef = useRef(null);
942
+ const {
943
+ getPopupContainer,
944
+ anchorRef
945
+ } = useMobilePopupMount(_extends({}, boundaryPopupMountOptions, {
946
+ getPopupContainer: wrapCustomGetContainer(innerConfig.getContainer)
947
+ }));
948
+ const close = () => {
949
+ setOpen(false);
950
+ };
951
+ useImperativeHandle(ref, () => ({
952
+ destroy: close,
953
+ update: newConfig => {
954
+ setInnerConfig(origin => Object.assign({}, origin, typeof newConfig === 'function' ? newConfig(origin) : newConfig));
955
+ }
956
+ }));
957
+ const {
958
+ getContainer,
959
+ afterClose: userAfterClose
960
+ } = innerConfig,
961
+ restConfig = _objectWithoutPropertiesLoose(innerConfig, _excluded$4);
962
+ const mergedAfterClose = (...args) => {
963
+ hookAfterClose && hookAfterClose(...args);
964
+ userAfterClose && userAfterClose(...args);
965
+ };
966
+ const drawerProps = computedDrawerProps(_extends({}, restConfig, {
967
+ onClose: close,
968
+ afterClose: mergedAfterClose
969
+ }));
970
+ const getDrawerContainer = resolveDrawerGetContainer({
971
+ customGetContainer: getContainer,
972
+ getPopupContainer,
973
+ getHostNode: () => hostRef.current
974
+ });
975
+ return /*#__PURE__*/jsxs(Fragment, {
976
+ children: [/*#__PURE__*/jsx("span", {
977
+ ref: node => {
978
+ hostRef.current = node;
979
+ anchorRef(node);
980
+ },
981
+ "aria-hidden": "true",
982
+ style: {
983
+ position: 'absolute',
984
+ width: 0,
985
+ height: 0,
986
+ overflow: 'hidden'
987
+ }
988
+ }), /*#__PURE__*/jsx(Drawer$1, _extends({}, drawerProps, {
989
+ open: open,
990
+ getContainer: getDrawerContainer
991
+ }))]
992
+ });
993
+ });
994
+ const ElementsHolder = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_props, ref) => {
995
+ const [elements, patchElement] = usePatchElement();
996
+ useImperativeHandle(ref, () => ({
997
+ patchElement
998
+ }), [patchElement]);
999
+ return /*#__PURE__*/jsx(Fragment, {
1000
+ children: elements
1001
+ });
1002
+ }));
1003
+ const useDrawerHolder = () => {
1004
+ const holderRef = useRef(null);
1005
+ const [actionQueue, setActionQueue] = useState([]);
1006
+ const {
1007
+ resolveMount,
1008
+ getPopupContainer
1009
+ } = useMobilePopupMount(boundaryPopupMountOptions);
1010
+ const getScrollElement = useScrollElement();
1011
+ useEffect(() => {
1012
+ if (actionQueue.length) {
1013
+ const cloneQueue = [...actionQueue];
1014
+ cloneQueue.forEach(action => action());
1015
+ setActionQueue([]);
1016
+ }
1017
+ }, [actionQueue]);
1018
+ const drawer = useCallback(props => {
1019
+ var _holderRef$current2;
1020
+ hookDrawerUuid += 1;
1021
+ const drawerRef = /*#__PURE__*/createRef();
1022
+ const api = {};
1023
+ let closeFunc;
1024
+ let unlock = () => {};
1025
+ const runOpen = () => {
1026
+ var _holderRef$current;
1027
+ const anchor = typeof document !== 'undefined' ? document.activeElement : null;
1028
+ const {
1029
+ isMobile,
1030
+ fixedModeClass
1031
+ } = resolveMount(anchor);
1032
+ unlock = lockParentScroll(getScrollElement);
1033
+ const {
1034
+ afterClose: userAfterClose,
1035
+ getContainer: customGetContainer
1036
+ } = props,
1037
+ restProps = _objectWithoutPropertiesLoose(props, _excluded2$1);
1038
+ const drawerEl = /*#__PURE__*/jsx(HookDrawer, {
1039
+ ref: drawerRef,
1040
+ config: _extends({}, restProps, {
1041
+ isMobile,
1042
+ fixedModeClass,
1043
+ getContainer: customGetContainer,
1044
+ onClose: () => api.close(),
1045
+ afterClose: (...args) => {
1046
+ unlock();
1047
+ userAfterClose && userAfterClose(...args);
1048
+ }
1049
+ }),
1050
+ afterClose: () => {
1051
+ closeFunc && closeFunc();
1052
+ }
1053
+ }, `react-drawer-${hookDrawerUuid}`);
1054
+ closeFunc = (_holderRef$current = holderRef.current) == null ? void 0 : _holderRef$current.patchElement(drawerEl);
1055
+ };
1056
+ if ((_holderRef$current2 = holderRef.current) != null && _holderRef$current2.patchElement) {
1057
+ runOpen();
1058
+ } else {
1059
+ setActionQueue(prev => [...prev, runOpen]);
1060
+ }
1061
+ api.close = () => {
1062
+ if (drawerRef.current) {
1063
+ drawerRef.current.destroy();
1064
+ } else {
1065
+ setActionQueue(prev => [...prev, () => {
1066
+ var _drawerRef$current;
1067
+ return (_drawerRef$current = drawerRef.current) == null ? void 0 : _drawerRef$current.destroy();
1068
+ }]);
1069
+ }
1070
+ };
1071
+ return api;
1072
+ }, [getScrollElement, resolveMount]);
1073
+ return [drawer, /*#__PURE__*/jsx(ElementsHolder, {
1074
+ ref: holderRef
1075
+ }, "drawer-elements-holder")];
1076
+ };
1077
+ const DrawerContextHolder = () => {
1078
+ const [drawer, contextHolder] = useDrawerHolder();
1079
+ drawerApiRef.current = drawer;
1080
+ return contextHolder;
1081
+ };
1082
+ const useDrawer = () => {
1083
+ if (!drawerApiRef.current) {
1084
+ throw new Error('useDrawer requires <DrawerContextHolder /> mounted inside <App> before calling useDrawer()');
1085
+ }
1086
+ return drawerApiRef.current;
1087
+ };
1088
+
1089
+ 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"};
1090
+
1091
+ const _excluded$3 = ["type", "icon", "title", "danger", "wrapClassName", "message", "confirmType", "getContainer", "onConfirm", "onCancel", "confirmText", "cancelText", "afterClose", "zIndex"],
1092
+ _excluded2 = ["afterClose"];
1093
+ const ConfirmLocaleRoot = withLocale(({
1094
+ children
1095
+ }) => children);
1096
+ const VIEWPORT_EXAMPLE_SELECTORS = ['.example-driver-device-scroll'];
1097
+ const viewportPopupMountOptions = {
1098
+ cover: 'viewport',
1099
+ exampleSelectors: VIEWPORT_EXAMPLE_SELECTORS
1100
+ };
1101
+ const ICON_BY_TYPE = {
1102
+ info: InfoCircleFilled,
1103
+ confirm: ExclamationCircleFilled,
1104
+ warning: ExclamationCircleFilled,
1105
+ error: CloseCircleFilled,
1106
+ success: CheckCircleFilled
1107
+ };
1108
+ const getIconKind = (type, confirmType) => type === 'confirm' ? confirmType : type;
1109
+ const shouldShowDefaultIcon = ({
1110
+ type,
1111
+ danger,
1112
+ icon
1113
+ }) => {
1114
+ if (icon === false || icon === null) {
1115
+ return false;
1116
+ }
1117
+ if (type === 'confirm') {
1118
+ return !!danger;
1119
+ }
1120
+ return ['info', 'success', 'warning', 'error'].includes(type);
1121
+ };
1122
+ const getConfirmIconNode = ({
1123
+ type,
1124
+ confirmType: _confirmType = 'info',
1125
+ danger,
1126
+ icon
1127
+ }) => {
1128
+ if (icon) {
1129
+ return icon;
1130
+ }
1131
+ if (!shouldShowDefaultIcon({
1132
+ type,
1133
+ danger,
1134
+ icon
1135
+ })) {
1136
+ return null;
1137
+ }
1138
+ const kind = getIconKind(type, _confirmType);
1139
+ const IconComponent = ICON_BY_TYPE[kind] || ICON_BY_TYPE.info;
1140
+ return /*#__PURE__*/jsx(IconComponent, {
1141
+ className: classnames(confirmStyle['title-icon'], confirmStyle[`title-icon-${kind}`])
1142
+ });
1143
+ };
1144
+ const buildConfirmContent = ({
1145
+ type,
1146
+ confirmType,
1147
+ title,
1148
+ message,
1149
+ danger,
1150
+ icon,
1151
+ isMobile
1152
+ }) => {
1153
+ const iconNode = getConfirmIconNode({
1154
+ type,
1155
+ confirmType,
1156
+ danger,
1157
+ icon
1158
+ });
1159
+ const mobileClass = isMobile ? confirmStyle['is-mobile-block'] : null;
1160
+ return {
1161
+ title: title ? /*#__PURE__*/jsxs("div", {
1162
+ className: classnames(confirmStyle.titleRow, mobileClass),
1163
+ onClick: e => {
1164
+ e.stopPropagation();
1165
+ },
1166
+ children: [iconNode ? /*#__PURE__*/jsx("span", {
1167
+ className: confirmStyle.titleIcon,
1168
+ children: iconNode
1169
+ }) : null, /*#__PURE__*/jsx("div", {
1170
+ className: confirmStyle.titleText,
1171
+ children: title
1172
+ })]
1173
+ }) : null,
1174
+ content: /*#__PURE__*/jsxs("div", {
1175
+ className: classnames(confirmStyle.contentRow, mobileClass, {
1176
+ [confirmStyle['has-title']]: title,
1177
+ [confirmStyle['has-icon']]: !!iconNode && title
1178
+ }),
1179
+ children: [!title && iconNode ? /*#__PURE__*/jsx("span", {
1180
+ className: confirmStyle.titleIcon,
1181
+ children: iconNode
1182
+ }) : null, /*#__PURE__*/jsx("div", {
1183
+ className: confirmStyle.contentText,
1184
+ children: message
1185
+ })]
1186
+ })
1187
+ };
1188
+ };
1189
+ const mapConfirmProps = (props, {
1190
+ isMobile,
1191
+ fixedModeClass,
1192
+ getPopupContainer,
1193
+ anchor,
1194
+ unlock,
1195
+ userAfterClose
1196
+ }) => {
1197
+ var _otherProps$className;
1198
+ const _maskClosable$props = _extends({
1199
+ maskClosable: false
1200
+ }, props),
1201
+ {
1202
+ type = 'confirm',
1203
+ icon,
1204
+ title,
1205
+ danger,
1206
+ wrapClassName,
1207
+ message,
1208
+ confirmType = 'info',
1209
+ getContainer: customGetContainer,
1210
+ onConfirm,
1211
+ onCancel,
1212
+ confirmText,
1213
+ cancelText,
1214
+ afterClose,
1215
+ zIndex
1216
+ } = _maskClosable$props,
1217
+ otherProps = _objectWithoutPropertiesLoose(_maskClosable$props, _excluded$3);
1218
+ const {
1219
+ title: confirmTitle,
1220
+ content
1221
+ } = buildConfirmContent({
1222
+ type,
1223
+ confirmType,
1224
+ title,
1225
+ message,
1226
+ danger,
1227
+ icon,
1228
+ isMobile
1229
+ });
1230
+ return {
1231
+ modalMethod: type,
1232
+ config: _extends({}, otherProps, {
1233
+ zIndex: zIndex != null ? zIndex : 1100,
1234
+ okText: confirmText != null ? confirmText : otherProps.okText,
1235
+ cancelText: cancelText != null ? cancelText : otherProps.cancelText,
1236
+ onOk: onConfirm != null ? onConfirm : otherProps.onOk,
1237
+ onCancel: onCancel != null ? onCancel : otherProps.onCancel,
1238
+ getContainer: resolveModalGetContainer({
1239
+ customGetContainer,
1240
+ getPopupContainer,
1241
+ getHostNode: () => anchor
1242
+ }),
1243
+ centered: true,
1244
+ afterClose: (...args) => {
1245
+ unlock();
1246
+ userAfterClose && userAfterClose(...args);
1247
+ afterClose && afterClose(...args);
1248
+ },
1249
+ icon: null,
1250
+ classNames: {
1251
+ mask: classnames(isMobile && modalStyle['modal-mask-fullscreen'], isMobile && fixedModeClass, (_otherProps$className = otherProps.classNames) == null ? void 0 : _otherProps$className.mask)
1252
+ },
1253
+ wrapClassName: classnames(modalStyle['modal-wrap'], confirmStyle['confirm-modal-wrap'], wrapClassName, {
1254
+ [confirmStyle['is-danger']]: danger,
1255
+ [confirmStyle['is-mobile']]: isMobile,
1256
+ [modalStyle['modal-wrap-centered']]: isMobile,
1257
+ [fixedModeClass]: isMobile
1258
+ }),
1259
+ title: confirmTitle ? /*#__PURE__*/jsx(ConfirmLocaleRoot, {
1260
+ children: confirmTitle
1261
+ }) : null,
1262
+ content: /*#__PURE__*/jsx(ConfirmLocaleRoot, {
1263
+ children: content
1264
+ })
1265
+ })
1266
+ };
1267
+ };
1268
+ const useConfirmModal = () => {
1269
+ const {
1270
+ modal
1271
+ } = App.useApp();
1272
+ const {
1273
+ resolveMount,
1274
+ getPopupContainer
1275
+ } = useMobilePopupMount(viewportPopupMountOptions);
1276
+ const getScrollElement = useScrollElement();
1277
+ return props => {
1278
+ const anchor = typeof document !== 'undefined' ? document.activeElement : null;
1279
+ const {
1280
+ isMobile,
1281
+ fixedModeClass
1282
+ } = resolveMount(anchor);
1283
+ const unlock = lockParentScroll$1(getScrollElement);
1284
+ const api = {};
1285
+ const {
1286
+ afterClose: userAfterClose
1287
+ } = props,
1288
+ restProps = _objectWithoutPropertiesLoose(props, _excluded2);
1289
+ const {
1290
+ modalMethod,
1291
+ config
1292
+ } = mapConfirmProps(_extends({}, restProps, {
1293
+ onClose: () => api.close()
1294
+ }), {
1295
+ isMobile,
1296
+ fixedModeClass,
1297
+ getPopupContainer,
1298
+ anchor,
1299
+ unlock,
1300
+ userAfterClose
1301
+ });
1302
+ if (typeof modal[modalMethod] === 'function') {
1303
+ const {
1304
+ destroy
1305
+ } = modal[modalMethod](config);
1306
+ api.close = destroy;
1307
+ } else {
1308
+ unlock();
1309
+ api.close = () => {};
1310
+ }
1311
+ return api;
1312
+ };
1313
+ };
1314
+
530
1315
  const _excluded$2 = ["className", "inset", "children"];
531
- const ModalScrollRegion = _ref => {
1316
+ const ScrollRegion = _ref => {
532
1317
  let {
533
1318
  className,
534
1319
  inset = false,
@@ -546,7 +1331,7 @@ const ModalScrollRegion = _ref => {
546
1331
  };
547
1332
 
548
1333
  const _excluded$1 = ["className", "destroyOnHidden"];
549
- const ModalTabsLayout = _ref => {
1334
+ const TabsLayout = _ref => {
550
1335
  let {
551
1336
  className,
552
1337
  destroyOnHidden = true
@@ -572,7 +1357,7 @@ const resolveColStyle = width => {
572
1357
  minWidth: 0
573
1358
  };
574
1359
  };
575
- const ModalColumnsLayout = _ref => {
1360
+ const ColumnsLayout = _ref => {
576
1361
  let {
577
1362
  widths,
578
1363
  className,
@@ -593,10 +1378,12 @@ const ModalColumnsLayout = _ref => {
593
1378
 
594
1379
  const createModalRender = modalDefaults => hostProps => /*#__PURE__*/jsx(Modal, _extends({}, modalDefaults, hostProps));
595
1380
 
1381
+ const createDrawerRender = drawerDefaults => hostProps => /*#__PURE__*/jsx(Drawer, _extends({}, drawerDefaults, hostProps));
1382
+
596
1383
  const modalClassNames = {
597
1384
  stepsForm: 'react-modal-steps-form',
598
1385
  splitter: 'react-modal-splitter'
599
1386
  };
600
1387
 
601
- export { ModalColumnsLayout, ModalScrollRegion, ModalTabsLayout, createModalRender, Modal as default, modalClassNames, useModal };
1388
+ export { ColumnsLayout, Drawer, DrawerContextHolder, ScrollRegion, TabsLayout, createDrawerRender, createModalRender, Modal as default, modalClassNames, useConfirmModal, useDrawer, useModal };
602
1389
  //# sourceMappingURL=index.modern.js.map