@synerise/ds-popconfirm 1.0.13 → 1.0.14

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.
package/README.md CHANGED
@@ -18,7 +18,11 @@ yarn add @synerise/ds-popconfirm
18
18
  ```javascript
19
19
  import Popconfirm from '@synerise/ds-popconfirm';
20
20
 
21
- <Popconfirm title="title" onConfirm={() => alert('confirm')} onCancel={() => alert('cancel')}>
21
+ <Popconfirm
22
+ title="title"
23
+ onConfirm={() => alert('confirm')}
24
+ onCancel={() => alert('cancel')}
25
+ >
22
26
  <button>text</button>
23
27
  </Popconfirm>;
24
28
  ```
@@ -48,6 +52,7 @@ import Popconfirm from '@synerise/ds-popconfirm';
48
52
  | hideButtons | prop to hide buttons | React.ReactNode | - |
49
53
  | titlePadding | prop to set padding | boolean | `false` |
50
54
  | buttonsAlign | Sets footer buttons align | 'right' / 'left' / undefined | `'right'` |
55
+ | staticVisible | stay open even after click outside | boolean | `false` |
51
56
 
52
57
  # Popcofirm.ConfirmMessage
53
58
 
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
- import { ConfirmMessageProps } from './ConfirmMessage.types';
2
+ import { type ConfirmMessageProps } from './ConfirmMessage.types';
3
3
  export declare const ConfirmMessage: ({ children, placement, title, onClick, displayDuration, icon, }: ConfirmMessageProps) => React.JSX.Element;
4
4
  export default ConfirmMessage;
@@ -1,5 +1,5 @@
1
- import React, { useCallback, useEffect, useMemo, useState } from 'react';
2
1
  import AntdTooltip from 'antd/lib/tooltip';
2
+ import React, { useCallback, useEffect, useMemo, useState } from 'react';
3
3
  import * as S from './ConfirmMessage.style';
4
4
  export var ConfirmMessage = function ConfirmMessage(_ref) {
5
5
  var children = _ref.children,
@@ -1,7 +1,5 @@
1
1
  import styled from 'styled-components';
2
2
  import { IconContainer } from '@synerise/ds-icon';
3
-
4
- // eslint-disable-next-line import/prefer-default-export
5
3
  export var Message = styled.div.withConfig({
6
4
  displayName: "ConfirmMessagestyle__Message",
7
5
  componentId: "sc-6dbwo9-0"
@@ -1,4 +1,4 @@
1
- import { ReactNode } from 'react';
1
+ import { type ReactNode } from 'react';
2
2
  export type ConfirmMessageProps = {
3
3
  displayDuration?: number;
4
4
  title: string;
@@ -1,5 +1,5 @@
1
1
  import '@synerise/ds-core/dist/js/style';
2
+ import { type PopconfirmType } from './Popconfirm.types';
2
3
  import './style/index.less';
3
- import { PopconfirmType } from './Popconfirm.types';
4
4
  declare const Popconfirm: PopconfirmType;
5
5
  export default Popconfirm;
@@ -1,14 +1,14 @@
1
- var _excluded = ["icon", "title", "description", "images", "imagesAutoplay", "imagesAutoplaySpeed", "withLink", "closeIcon", "titlePadding", "onCancel", "cancelButtonProps", "onConfirm", "okButtonProps", "okType", "hideButtons", "cancelText", "okText", "buttonsAlign", "disabled"];
1
+ var _excluded = ["icon", "title", "description", "images", "imagesAutoplay", "imagesAutoplaySpeed", "withLink", "closeIcon", "titlePadding", "onCancel", "cancelButtonProps", "onConfirm", "okButtonProps", "okType", "hideButtons", "cancelText", "okText", "buttonsAlign", "disabled", "staticVisible"];
2
2
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
3
  function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
4
- import React, { useEffect, useMemo, useRef, useState } from 'react';
5
- import '@synerise/ds-core/dist/js/style';
6
- import "./style/index.css";
7
4
  import { Carousel } from 'antd';
8
5
  import AntdPopconfirm from 'antd/lib/popconfirm';
6
+ import React, { useEffect, useMemo, useRef, useState } from 'react';
7
+ import '@synerise/ds-core/dist/js/style';
9
8
  import { useOnClickOutside } from '@synerise/ds-utils';
10
- import * as S from './Popconfirm.styles';
11
9
  import ConfirmMessage from './ConfirmMessage/ConfirmMessage';
10
+ import * as S from './Popconfirm.styles';
11
+ import "./style/index.css";
12
12
  var Popconfirm = function Popconfirm(_ref) {
13
13
  var icon = _ref.icon,
14
14
  title = _ref.title,
@@ -31,6 +31,7 @@ var Popconfirm = function Popconfirm(_ref) {
31
31
  okText = _ref.okText,
32
32
  buttonsAlign = _ref.buttonsAlign,
33
33
  disabled = _ref.disabled,
34
+ staticVisible = _ref.staticVisible,
34
35
  antdProps = _objectWithoutPropertiesLoose(_ref, _excluded);
35
36
  var renderImageCarousel = useMemo(function () {
36
37
  return (images == null ? void 0 : images.length) && /*#__PURE__*/React.createElement(Carousel, {
@@ -49,7 +50,13 @@ var Popconfirm = function Popconfirm(_ref) {
49
50
  visible = _useState[0],
50
51
  setVisible = _useState[1];
51
52
  useOnClickOutside(popupRef, function () {
52
- setVisible(false);
53
+ if (staticVisible && visible === undefined) {
54
+ return setVisible(true);
55
+ }
56
+ if (staticVisible && visible === true) {
57
+ return setVisible(true);
58
+ }
59
+ return setVisible(false);
53
60
  });
54
61
  useEffect(function () {
55
62
  if (!visible && antdProps.visible) {
@@ -60,9 +67,10 @@ var Popconfirm = function Popconfirm(_ref) {
60
67
  disabled: disabled,
61
68
  visible: visible,
62
69
  onVisibleChange: function onVisibleChange(isVisible) {
63
- if (antdProps.onVisibleChange) {
64
- antdProps.onVisibleChange(isVisible);
65
- } else if (isVisible !== visible) {
70
+ if (!staticVisible && isVisible !== visible) {
71
+ setVisible(isVisible);
72
+ }
73
+ if (staticVisible && visible === false) {
66
74
  setVisible(isVisible);
67
75
  }
68
76
  },
@@ -1,6 +1,6 @@
1
- import { ReactNode, MouseEvent as ReactMouseEvent } from 'react';
2
- import { PopconfirmProps as AntdPopconfirmProps } from 'antd/lib/popconfirm';
3
- import { ConfirmMessageProps } from './ConfirmMessage/ConfirmMessage.types';
1
+ import { type PopconfirmProps as AntdPopconfirmProps } from 'antd/lib/popconfirm';
2
+ import { type MouseEvent as ReactMouseEvent, type ReactNode } from 'react';
3
+ import { type ConfirmMessageProps } from './ConfirmMessage/ConfirmMessage.types';
4
4
  export type PopconfirmTexts = Pick<PopconfirmProps, 'okText' | 'description' | 'title' | 'cancelText'>;
5
5
  export type PopconfirmProps = Omit<AntdPopconfirmProps, 'okType'> & {
6
6
  description?: ReactNode;
@@ -15,6 +15,7 @@ export type PopconfirmProps = Omit<AntdPopconfirmProps, 'okType'> & {
15
15
  buttonsAlign?: 'left' | 'right';
16
16
  okType?: AntdPopconfirmProps['okType'] | string;
17
17
  children?: ReactNode;
18
+ staticVisible?: boolean;
18
19
  };
19
20
  export type PopconfirmType = {
20
21
  (props: PopconfirmProps): JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synerise/ds-popconfirm",
3
- "version": "1.0.13",
3
+ "version": "1.0.14",
4
4
  "description": "Popconfirm UI Component for the Synerise Design System",
5
5
  "license": "ISC",
6
6
  "repository": "Synerise/synerise-design",
@@ -34,9 +34,9 @@
34
34
  ],
35
35
  "types": "dist/index.d.ts",
36
36
  "dependencies": {
37
- "@synerise/ds-button": "^1.4.1",
38
- "@synerise/ds-icon": "^1.5.3",
39
- "@synerise/ds-utils": "^1.3.0"
37
+ "@synerise/ds-button": "^1.4.2",
38
+ "@synerise/ds-icon": "^1.5.4",
39
+ "@synerise/ds-utils": "^1.3.1"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "@synerise/ds-core": "*",
@@ -44,5 +44,5 @@
44
44
  "react": ">=16.9.0 <= 18.3.1",
45
45
  "styled-components": "^5.3.3"
46
46
  },
47
- "gitHead": "11fe1d29b2ac23e70c3d5e6ce8ae20201a619a34"
47
+ "gitHead": "4512641033ba3581a3df208143c547fcfed45895"
48
48
  }