musae 0.3.7 → 0.3.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/components/avatar/group.cjs +4 -5
  2. package/dist/components/avatar/group.mjs +5 -6
  3. package/dist/components/countdown/countdown.cjs +25 -6
  4. package/dist/components/countdown/countdown.d.ts +1 -1
  5. package/dist/components/countdown/countdown.mjs +25 -6
  6. package/dist/components/form/field/field.cjs +8 -3
  7. package/dist/components/form/field/field.mjs +9 -4
  8. package/dist/components/form/item.cjs +16 -5
  9. package/dist/components/form/item.d.ts +2 -2
  10. package/dist/components/form/item.mjs +16 -5
  11. package/dist/components/otp-input/hooks.cjs +1 -4
  12. package/dist/components/otp-input/hooks.mjs +2 -5
  13. package/dist/components/otp-input/otp-input.cjs +5 -3
  14. package/dist/components/otp-input/otp-input.d.ts +1 -1
  15. package/dist/components/otp-input/otp-input.mjs +6 -4
  16. package/dist/components/popconfirm/popconfirm.cjs +26 -19
  17. package/dist/components/popconfirm/popconfirm.mjs +28 -21
  18. package/dist/components/popover/hooks.cjs +28 -0
  19. package/dist/components/popover/hooks.d.ts +11 -0
  20. package/dist/components/popover/hooks.mjs +30 -3
  21. package/dist/components/popover/popover.cjs +54 -26
  22. package/dist/components/popover/popover.d.ts +2 -2
  23. package/dist/components/popover/popover.mjs +57 -29
  24. package/dist/components/theme/hooks.cjs +8 -10
  25. package/dist/components/theme/hooks.d.ts +0 -3
  26. package/dist/components/theme/hooks.mjs +8 -10
  27. package/dist/locale/locales/en_US.cjs +8 -3
  28. package/dist/locale/locales/en_US.mjs +8 -3
  29. package/dist/locale/locales/zh_CN.cjs +8 -3
  30. package/dist/locale/locales/zh_CN.mjs +8 -3
  31. package/dist/types/countdown.d.ts +1 -1
  32. package/dist/types/locale.d.ts +3 -0
  33. package/dist/types/otp-input.d.ts +2 -1
  34. package/dist/types/popover.d.ts +2 -3
  35. package/package.json +8 -8
@@ -24,15 +24,14 @@ var _Group = function Group(_ref) {
24
24
  };
25
25
  var children = React.useMemo(function () {
26
26
  var _Children$toArray$red = React.Children.toArray(_children).reduce(function (prev, child, index) {
27
- // @ts-ignore
28
- var element = /*#__PURE__*/React.cloneElement(child, {
27
+ var _child = /*#__PURE__*/ /*#__PURE__*/React.isValidElement(child) ? /*#__PURE__*/React.cloneElement(child, {
29
28
  key: "avatars-".concat(index)
30
- });
29
+ }) : child;
31
30
  // great than max, hide current node
32
31
  if (index >= max) {
33
- prev[1].push(element);
32
+ prev[1].push(_child);
34
33
  } else {
35
- prev[0].push(element);
34
+ prev[0].push(_child);
36
35
  }
37
36
  return prev;
38
37
  }, [[], []]),
@@ -1,5 +1,5 @@
1
1
  import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
2
- import React, { useMemo, Children, cloneElement } from 'react';
2
+ import React, { useMemo, Children, isValidElement, cloneElement } from 'react';
3
3
  import { Context } from './context.mjs';
4
4
  import { useClassNames } from '../../hooks/use-class-names.mjs';
5
5
  import { AvatarClassToken } from '../../utils/class-name.mjs';
@@ -22,15 +22,14 @@ var _Group = function Group(_ref) {
22
22
  };
23
23
  var children = useMemo(function () {
24
24
  var _Children$toArray$red = Children.toArray(_children).reduce(function (prev, child, index) {
25
- // @ts-ignore
26
- var element = /*#__PURE__*/cloneElement(child, {
25
+ var _child = /*#__PURE__*/ /*#__PURE__*/isValidElement(child) ? /*#__PURE__*/cloneElement(child, {
27
26
  key: "avatars-".concat(index)
28
- });
27
+ }) : child;
29
28
  // great than max, hide current node
30
29
  if (index >= max) {
31
- prev[1].push(element);
30
+ prev[1].push(_child);
32
31
  } else {
33
- prev[0].push(element);
32
+ prev[0].push(_child);
34
33
  }
35
34
  return prev;
36
35
  }, [[], []]),
@@ -1,5 +1,7 @@
1
1
  Object.defineProperty(exports, '__esModule', { value: true });
2
2
 
3
+ var _regeneratorRuntime = require('@babel/runtime/helpers/regeneratorRuntime');
4
+ var _asyncToGenerator = require('@babel/runtime/helpers/asyncToGenerator');
3
5
  var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
4
6
  var React = require('react');
5
7
  var button = require('../button/button.cjs');
@@ -25,7 +27,8 @@ var Countdown = function Countdown(_ref) {
25
27
  _ref$ripple = _ref.ripple,
26
28
  ripple = _ref$ripple === void 0 ? true : _ref$ripple,
27
29
  className = _ref.className,
28
- style = _ref.style;
30
+ style = _ref.style,
31
+ onClick = _ref.onClick;
29
32
  var trigger = React.useRef(null);
30
33
  var counter = React.useRef(null);
31
34
  var stopper = React.useRef(null);
@@ -64,11 +67,27 @@ var Countdown = function Countdown(_ref) {
64
67
  }
65
68
  })) !== null && _counter$current$subs !== void 0 ? _counter$current$subs : null;
66
69
  });
67
- var start = relax.useEvent(function (e) {
68
- var _trigger$current2;
69
- countdown();
70
- (_trigger$current2 = trigger.current) === null || _trigger$current2 === void 0 || _trigger$current2.next(e);
71
- });
70
+ var start = relax.useEvent(/*#__PURE__*/function () {
71
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(e) {
72
+ var _trigger$current2;
73
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
74
+ while (1) switch (_context.prev = _context.next) {
75
+ case 0:
76
+ _context.next = 2;
77
+ return Promise.resolve(onClick === null || onClick === void 0 ? void 0 : onClick(e));
78
+ case 2:
79
+ countdown();
80
+ (_trigger$current2 = trigger.current) === null || _trigger$current2 === void 0 || _trigger$current2.next(e);
81
+ case 4:
82
+ case "end":
83
+ return _context.stop();
84
+ }
85
+ }, _callee);
86
+ }));
87
+ return function (_x) {
88
+ return _ref2.apply(this, arguments);
89
+ };
90
+ }());
72
91
  return /*#__PURE__*/React.createElement(button.Button, {
73
92
  onClick: start,
74
93
  disabled: disabled || isCounting,
@@ -1,4 +1,4 @@
1
1
  import React from "react";
2
2
  import type { CountdownProps } from "musae/types/countdown";
3
- declare const Countdown: ({ count, children, interval: _interval, disabled, variant, color, shape, size, ripple, className, style, }: CountdownProps) => React.JSX.Element;
3
+ declare const Countdown: ({ count, children, interval: _interval, disabled, variant, color, shape, size, ripple, className, style, onClick, }: CountdownProps) => React.JSX.Element;
4
4
  export default Countdown;
@@ -1,3 +1,5 @@
1
+ import _regeneratorRuntime from '@babel/runtime/helpers/regeneratorRuntime';
2
+ import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
1
3
  import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
2
4
  import React, { useRef, useState } from 'react';
3
5
  import { Button } from '../button/button.mjs';
@@ -23,7 +25,8 @@ var Countdown = function Countdown(_ref) {
23
25
  _ref$ripple = _ref.ripple,
24
26
  ripple = _ref$ripple === void 0 ? true : _ref$ripple,
25
27
  className = _ref.className,
26
- style = _ref.style;
28
+ style = _ref.style,
29
+ onClick = _ref.onClick;
27
30
  var trigger = useRef(null);
28
31
  var counter = useRef(null);
29
32
  var stopper = useRef(null);
@@ -62,11 +65,27 @@ var Countdown = function Countdown(_ref) {
62
65
  }
63
66
  })) !== null && _counter$current$subs !== void 0 ? _counter$current$subs : null;
64
67
  });
65
- var start = useEvent(function (e) {
66
- var _trigger$current2;
67
- countdown();
68
- (_trigger$current2 = trigger.current) === null || _trigger$current2 === void 0 || _trigger$current2.next(e);
69
- });
68
+ var start = useEvent(/*#__PURE__*/function () {
69
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(e) {
70
+ var _trigger$current2;
71
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
72
+ while (1) switch (_context.prev = _context.next) {
73
+ case 0:
74
+ _context.next = 2;
75
+ return Promise.resolve(onClick === null || onClick === void 0 ? void 0 : onClick(e));
76
+ case 2:
77
+ countdown();
78
+ (_trigger$current2 = trigger.current) === null || _trigger$current2 === void 0 || _trigger$current2.next(e);
79
+ case 4:
80
+ case "end":
81
+ return _context.stop();
82
+ }
83
+ }, _callee);
84
+ }));
85
+ return function (_x) {
86
+ return _ref2.apply(this, arguments);
87
+ };
88
+ }());
70
89
  return /*#__PURE__*/React.createElement(Button, {
71
90
  onClick: start,
72
91
  disabled: disabled || isCounting,
@@ -14,6 +14,7 @@ var framerMotion = require('framer-motion');
14
14
  var theme = require('../../theme/theme.cjs');
15
15
  var useClassNames = require('../../../hooks/use-class-names.cjs');
16
16
  var componentToken = require('../../../utils/component-token.cjs');
17
+ var useLocale = require('../../../locale/use-locale.cjs');
17
18
 
18
19
  var _excluded = ["required", "children", "className", "style"];
19
20
  var styles = {
@@ -29,18 +30,22 @@ var styles = {
29
30
  * if there is name prop, it will render
30
31
  */
31
32
  var Field = function Field(_ref) {
33
+ var _props$label;
32
34
  var required = _ref.required,
33
35
  _children = _ref.children,
34
36
  className$1 = _ref.className,
35
37
  style = _ref.style,
36
38
  props = _objectWithoutProperties(_ref, _excluded);
37
39
  var classNames = useClassNames.useClassNames(componentToken.ComponentToken.Form);
40
+ var _useLocale = useLocale.useLocale(componentToken.ComponentToken.Form),
41
+ _useLocale2 = _slicedToArray(_useLocale, 1),
42
+ locale = _useLocale2[0];
38
43
  var _useController = reactHookForm.useController({
39
44
  name: props.name,
40
45
  rules: {
41
46
  required: {
42
47
  value: required,
43
- message: "".concat(props.name, " is required")
48
+ message: relax.toFunction(locale.required)((_props$label = props.label) !== null && _props$label !== void 0 ? _props$label : props.name)
44
49
  }
45
50
  }
46
51
  }),
@@ -71,7 +76,7 @@ var Field = function Field(_ref) {
71
76
  }, relax.isRefable(_child) && {
72
77
  ref: ref
73
78
  }))), true];
74
- }, [[], false]);
79
+ }, [[], false]).at(0);
75
80
  }, [_children, name, value, invalid, ref, onChange, onBlur]);
76
81
  var styled = {
77
82
  supporting: stylex.default.props(styles.supporting, theme.typography.body.small)
@@ -81,7 +86,7 @@ var Field = function Field(_ref) {
81
86
  required: required,
82
87
  className: classNames[className.FormClassToken.Item]
83
88
  }, /*#__PURE__*/React.createElement("div", {
84
- className: className$1,
89
+ className: relax.clsx(classNames[className.FormClassToken.Field], className$1),
85
90
  style: style
86
91
  }, children), /*#__PURE__*/React.createElement("div", {
87
92
  className: relax.clsx(classNames[className.FormClassToken.FieldSupporting], styled.supporting.className),
@@ -3,7 +3,7 @@ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
3
3
  import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
4
4
  import React, { useMemo, Children, isValidElement, cloneElement } from 'react';
5
5
  import { useController } from 'react-hook-form';
6
- import { chain, isRefable, clsx } from '@aiszlab/relax';
6
+ import { toFunction, chain, isRefable, clsx } from '@aiszlab/relax';
7
7
  import { FormClassToken } from '../../../utils/class-name.mjs';
8
8
  import _stylex from '../../../node_modules/.pnpm/@stylexjs_stylex@0.7.5/node_modules/@stylexjs/stylex/lib/es/stylex.mjs';
9
9
  import Layout from './layout.mjs';
@@ -12,6 +12,7 @@ import { AnimatePresence } from 'framer-motion';
12
12
  import { typography } from '../../theme/theme.mjs';
13
13
  import { useClassNames } from '../../../hooks/use-class-names.mjs';
14
14
  import { ComponentToken } from '../../../utils/component-token.mjs';
15
+ import { useLocale } from '../../../locale/use-locale.mjs';
15
16
 
16
17
  var _excluded = ["required", "children", "className", "style"];
17
18
  var styles = {
@@ -27,18 +28,22 @@ var styles = {
27
28
  * if there is name prop, it will render
28
29
  */
29
30
  var Field = function Field(_ref) {
31
+ var _props$label;
30
32
  var required = _ref.required,
31
33
  _children = _ref.children,
32
34
  className = _ref.className,
33
35
  style = _ref.style,
34
36
  props = _objectWithoutProperties(_ref, _excluded);
35
37
  var classNames = useClassNames(ComponentToken.Form);
38
+ var _useLocale = useLocale(ComponentToken.Form),
39
+ _useLocale2 = _slicedToArray(_useLocale, 1),
40
+ locale = _useLocale2[0];
36
41
  var _useController = useController({
37
42
  name: props.name,
38
43
  rules: {
39
44
  required: {
40
45
  value: required,
41
- message: "".concat(props.name, " is required")
46
+ message: toFunction(locale.required)((_props$label = props.label) !== null && _props$label !== void 0 ? _props$label : props.name)
42
47
  }
43
48
  }
44
49
  }),
@@ -69,7 +74,7 @@ var Field = function Field(_ref) {
69
74
  }, isRefable(_child) && {
70
75
  ref: ref
71
76
  }))), true];
72
- }, [[], false]);
77
+ }, [[], false]).at(0);
73
78
  }, [_children, name, value, invalid, ref, onChange, onBlur]);
74
79
  var styled = {
75
80
  supporting: _stylex.props(styles.supporting, typography.body.small)
@@ -79,7 +84,7 @@ var Field = function Field(_ref) {
79
84
  required: required,
80
85
  className: classNames[FormClassToken.Item]
81
86
  }, /*#__PURE__*/React.createElement("div", {
82
- className: className,
87
+ className: clsx(classNames[FormClassToken.Field], className),
83
88
  style: style
84
89
  }, children), /*#__PURE__*/React.createElement("div", {
85
90
  className: clsx(classNames[FormClassToken.FieldSupporting], styled.supporting.className),
@@ -5,8 +5,12 @@ var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProp
5
5
  var React = require('react');
6
6
  var field = require('./field/field.cjs');
7
7
  var layout = require('./field/layout.cjs');
8
+ var useClassNames = require('../../hooks/use-class-names.cjs');
9
+ var componentToken = require('../../utils/component-token.cjs');
10
+ var relax = require('@aiszlab/relax');
11
+ var className = require('../../utils/class-name.cjs');
8
12
 
9
- var _excluded = ["required"];
13
+ var _excluded = ["required", "className", "style"];
10
14
  /**
11
15
  * @description
12
16
  * item render
@@ -14,9 +18,14 @@ var _excluded = ["required"];
14
18
  var Item = function Item(_ref) {
15
19
  var _ref$required = _ref.required,
16
20
  required = _ref$required === void 0 ? false : _ref$required,
21
+ className$1 = _ref.className,
22
+ style = _ref.style,
17
23
  props = _objectWithoutProperties(_ref, _excluded);
24
+ var classNames = useClassNames.useClassNames(componentToken.ComponentToken.Form);
18
25
  if (props.name) {
19
26
  return /*#__PURE__*/React.createElement(field.default, _objectSpread(_objectSpread({}, props), {}, {
27
+ className: className$1,
28
+ style: style,
20
29
  name: props.name,
21
30
  required: required
22
31
  }));
@@ -26,10 +35,12 @@ var Item = function Item(_ref) {
26
35
  labelCol: props.labelCol,
27
36
  wrapperCol: props.wrapperCol,
28
37
  required: required,
29
- className: props.className,
30
- style: props.style,
31
- space: true
32
- }, props.children);
38
+ space: true,
39
+ className: classNames[className.FormClassToken.Item]
40
+ }, /*#__PURE__*/React.createElement("div", {
41
+ className: relax.clsx(classNames[className.FormClassToken.Field], className$1),
42
+ style: style
43
+ }, props.children));
33
44
  };
34
45
 
35
46
  exports.default = Item;
@@ -1,9 +1,9 @@
1
- import { FormItemProps } from "musae/types/form";
1
+ import type { FormItemProps } from "musae/types/form";
2
2
  import React from "react";
3
3
  import type { FieldValues } from "react-hook-form";
4
4
  /**
5
5
  * @description
6
6
  * item render
7
7
  */
8
- declare const Item: <T extends FieldValues = FieldValues>({ required, ...props }: FormItemProps<T>) => React.JSX.Element;
8
+ declare const Item: <T extends FieldValues = FieldValues>({ required, className, style, ...props }: FormItemProps<T>) => React.JSX.Element;
9
9
  export default Item;
@@ -3,8 +3,12 @@ import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProper
3
3
  import React from 'react';
4
4
  import Field from './field/field.mjs';
5
5
  import Layout from './field/layout.mjs';
6
+ import { useClassNames } from '../../hooks/use-class-names.mjs';
7
+ import { ComponentToken } from '../../utils/component-token.mjs';
8
+ import { clsx } from '@aiszlab/relax';
9
+ import { FormClassToken } from '../../utils/class-name.mjs';
6
10
 
7
- var _excluded = ["required"];
11
+ var _excluded = ["required", "className", "style"];
8
12
  /**
9
13
  * @description
10
14
  * item render
@@ -12,9 +16,14 @@ var _excluded = ["required"];
12
16
  var Item = function Item(_ref) {
13
17
  var _ref$required = _ref.required,
14
18
  required = _ref$required === void 0 ? false : _ref$required,
19
+ className = _ref.className,
20
+ style = _ref.style,
15
21
  props = _objectWithoutProperties(_ref, _excluded);
22
+ var classNames = useClassNames(ComponentToken.Form);
16
23
  if (props.name) {
17
24
  return /*#__PURE__*/React.createElement(Field, _objectSpread(_objectSpread({}, props), {}, {
25
+ className: className,
26
+ style: style,
18
27
  name: props.name,
19
28
  required: required
20
29
  }));
@@ -24,10 +33,12 @@ var Item = function Item(_ref) {
24
33
  labelCol: props.labelCol,
25
34
  wrapperCol: props.wrapperCol,
26
35
  required: required,
27
- className: props.className,
28
- style: props.style,
29
- space: true
30
- }, props.children);
36
+ space: true,
37
+ className: classNames[FormClassToken.Item]
38
+ }, /*#__PURE__*/React.createElement("div", {
39
+ className: clsx(classNames[FormClassToken.Field], className),
40
+ style: style
41
+ }, props.children));
31
42
  };
32
43
 
33
44
  export { Item as default };
@@ -28,10 +28,7 @@ var useValue = function useValue(_ref) {
28
28
  var changed = Array.from(values);
29
29
  changed[index] = otp;
30
30
  var changedValue = changed.join("");
31
- if (relax.isUndefined(_value)) {
32
- setValue(changedValue);
33
- return;
34
- }
31
+ setValue(changedValue);
35
32
  onChange === null || onChange === void 0 || onChange(changedValue);
36
33
  });
37
34
  return {
@@ -1,5 +1,5 @@
1
1
  import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
2
- import { useControlledState, useEvent, isUndefined } from '@aiszlab/relax';
2
+ import { useControlledState, useEvent } from '@aiszlab/relax';
3
3
  import { useMemo } from 'react';
4
4
  import { Keyboard } from '../../utils/keyboard.mjs';
5
5
 
@@ -28,10 +28,7 @@ var useValue = function useValue(_ref) {
28
28
  var changed = Array.from(values);
29
29
  changed[index] = otp;
30
30
  var changedValue = changed.join("");
31
- if (isUndefined(_value)) {
32
- setValue(changedValue);
33
- return;
34
- }
31
+ setValue(changedValue);
35
32
  onChange === null || onChange === void 0 || onChange(changedValue);
36
33
  });
37
34
  return {
@@ -11,7 +11,9 @@ var OtpInput = function OtpInput(_ref) {
11
11
  var _ref$length = _ref.length,
12
12
  length = _ref$length === void 0 ? 6 : _ref$length,
13
13
  onChange = _ref.onChange,
14
- _value = _ref.value;
14
+ _value = _ref.value,
15
+ className = _ref.className,
16
+ style = _ref.style;
15
17
  var _useValue = hooks.useValue({
16
18
  length: length,
17
19
  onChange: onChange,
@@ -63,8 +65,8 @@ var OtpInput = function OtpInput(_ref) {
63
65
  }
64
66
  };
65
67
  return /*#__PURE__*/React.createElement("div", {
66
- className: styled.otp.className,
67
- style: styled.otp.style
68
+ className: relax.clsx(styled.otp.className, className),
69
+ style: _objectSpread(_objectSpread({}, styled.otp.style), style)
68
70
  }, value.map(function (item, index) {
69
71
  return /*#__PURE__*/React.createElement(input.default, {
70
72
  key: index,
@@ -1,4 +1,4 @@
1
1
  import React from "react";
2
2
  import type { OtpInputProps } from "musae/types/otp-input";
3
- declare const OtpInput: ({ length, onChange, value: _value }: OtpInputProps) => React.JSX.Element;
3
+ declare const OtpInput: ({ length, onChange, value: _value, className, style }: OtpInputProps) => React.JSX.Element;
4
4
  export default OtpInput;
@@ -3,13 +3,15 @@ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
3
3
  import React, { useRef, useState } from 'react';
4
4
  import { useValue, useInputEvents } from './hooks.mjs';
5
5
  import Input from '../input/input.mjs';
6
- import { useEvent, clamp } from '@aiszlab/relax';
6
+ import { useEvent, clamp, clsx } from '@aiszlab/relax';
7
7
 
8
8
  var OtpInput = function OtpInput(_ref) {
9
9
  var _ref$length = _ref.length,
10
10
  length = _ref$length === void 0 ? 6 : _ref$length,
11
11
  onChange = _ref.onChange,
12
- _value = _ref.value;
12
+ _value = _ref.value,
13
+ className = _ref.className,
14
+ style = _ref.style;
13
15
  var _useValue = useValue({
14
16
  length: length,
15
17
  onChange: onChange,
@@ -61,8 +63,8 @@ var OtpInput = function OtpInput(_ref) {
61
63
  }
62
64
  };
63
65
  return /*#__PURE__*/React.createElement("div", {
64
- className: styled.otp.className,
65
- style: styled.otp.style
66
+ className: clsx(styled.otp.className, className),
67
+ style: _objectSpread(_objectSpread({}, styled.otp.style), style)
66
68
  }, value.map(function (item, index) {
67
69
  return /*#__PURE__*/React.createElement(Input, {
68
70
  key: index,
@@ -56,17 +56,17 @@ var styles = {
56
56
  $$css: true
57
57
  }
58
58
  };
59
- var Popconfirm = function Popconfirm(_ref2) {
60
- var content = _ref2.content,
61
- title = _ref2.title,
62
- onConfirm = _ref2.onConfirm,
63
- onCancel = _ref2.onCancel,
64
- className$1 = _ref2.className,
65
- _ref2$placement = _ref2.placement,
66
- placement = _ref2$placement === void 0 ? "top" : _ref2$placement,
67
- _children = _ref2.children,
68
- style = _ref2.style;
69
- var _ref = React.useRef(null);
59
+ var Popconfirm = function Popconfirm(_ref) {
60
+ var content = _ref.content,
61
+ title = _ref.title,
62
+ onConfirm = _ref.onConfirm,
63
+ onCancel = _ref.onCancel,
64
+ className$1 = _ref.className,
65
+ _ref$placement = _ref.placement,
66
+ placement = _ref$placement === void 0 ? "top" : _ref$placement,
67
+ _children = _ref.children,
68
+ style = _ref.style;
69
+ var ref = React.useRef(null);
70
70
  var _useBoolean = relax.useBoolean(),
71
71
  _useBoolean2 = _slicedToArray(_useBoolean, 2),
72
72
  isOpen = _useBoolean2[0],
@@ -74,7 +74,6 @@ var Popconfirm = function Popconfirm(_ref2) {
74
74
  turnOff = _useBoolean2$.turnOff,
75
75
  toggle = _useBoolean2$.toggle;
76
76
  var classNames = useClassNames.useClassNames(componentToken.ComponentToken.Popconfirm);
77
- var childRef = relax.useRefs(_ref, _children.props.ref);
78
77
  var popperRef = React.useRef(null);
79
78
  var theme$1 = hooks.useTheme();
80
79
  var _useLocale = useLocale.useLocale(componentToken.ComponentToken.Popconfirm),
@@ -92,14 +91,22 @@ var Popconfirm = function Popconfirm(_ref2) {
92
91
  onCancel === null || onCancel === void 0 || onCancel();
93
92
  turnOff();
94
93
  });
95
- // @ts-ignore
96
- var children = /*#__PURE__*/React.cloneElement(_children, {
97
- ref: childRef,
98
- onClick: onClick
99
- });
94
+ var children = React.useMemo(function () {
95
+ var props = {
96
+ ref: ref,
97
+ onClick: onClick
98
+ };
99
+ if (/*#__PURE__*/React.isValidElement(_children)) {
100
+ return /*#__PURE__*/React.cloneElement(_children, props);
101
+ }
102
+ return /*#__PURE__*/React.createElement("div", {
103
+ ref: ref,
104
+ onClick: onClick
105
+ }, _children);
106
+ }, [ref, onClick, _children]);
100
107
  relax.useClickAway(function () {
101
108
  turnOff();
102
- }, [popperRef, _ref]);
109
+ }, [popperRef, ref]);
103
110
  var styled = {
104
111
  popconfirm: {
105
112
  className: "musaex-2wmp0v musaex-16xn7b0 musaex-rvj5dj musaex-183ukxf musaex-1lsrmdg"
@@ -114,7 +121,7 @@ var Popconfirm = function Popconfirm(_ref2) {
114
121
  }
115
122
  };
116
123
  return /*#__PURE__*/React.createElement(React.Fragment, null, children, /*#__PURE__*/React.createElement(popper.default, {
117
- trigger: _ref.current,
124
+ trigger: ref.current,
118
125
  open: isOpen,
119
126
  arrow: true,
120
127
  placement: placement,
@@ -1,12 +1,12 @@
1
1
  import _objectSpread from '@babel/runtime/helpers/objectSpread2';
2
2
  import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
3
- import React, { useRef, cloneElement } from 'react';
3
+ import React, { useRef, useMemo, isValidElement, cloneElement } from 'react';
4
4
  import _stylex from '../../node_modules/.pnpm/@stylexjs_stylex@0.7.5/node_modules/@stylexjs/stylex/lib/es/stylex.mjs';
5
5
  import { useClassNames } from '../../hooks/use-class-names.mjs';
6
6
  import { PopconfirmClassToken } from '../../utils/class-name.mjs';
7
7
  import Space from '../space/space.mjs';
8
8
  import { Button } from '../button/button.mjs';
9
- import { useBoolean, useRefs, useEvent, useClickAway, clsx } from '@aiszlab/relax';
9
+ import { useBoolean, useEvent, useClickAway, clsx } from '@aiszlab/relax';
10
10
  import Popper from '../popper/popper.mjs';
11
11
  import { typography } from '../theme/theme.mjs';
12
12
  import { useTheme } from '../theme/hooks.mjs';
@@ -54,17 +54,17 @@ var styles = {
54
54
  $$css: true
55
55
  }
56
56
  };
57
- var Popconfirm = function Popconfirm(_ref2) {
58
- var content = _ref2.content,
59
- title = _ref2.title,
60
- onConfirm = _ref2.onConfirm,
61
- onCancel = _ref2.onCancel,
62
- className = _ref2.className,
63
- _ref2$placement = _ref2.placement,
64
- placement = _ref2$placement === void 0 ? "top" : _ref2$placement,
65
- _children = _ref2.children,
66
- style = _ref2.style;
67
- var _ref = useRef(null);
57
+ var Popconfirm = function Popconfirm(_ref) {
58
+ var content = _ref.content,
59
+ title = _ref.title,
60
+ onConfirm = _ref.onConfirm,
61
+ onCancel = _ref.onCancel,
62
+ className = _ref.className,
63
+ _ref$placement = _ref.placement,
64
+ placement = _ref$placement === void 0 ? "top" : _ref$placement,
65
+ _children = _ref.children,
66
+ style = _ref.style;
67
+ var ref = useRef(null);
68
68
  var _useBoolean = useBoolean(),
69
69
  _useBoolean2 = _slicedToArray(_useBoolean, 2),
70
70
  isOpen = _useBoolean2[0],
@@ -72,7 +72,6 @@ var Popconfirm = function Popconfirm(_ref2) {
72
72
  turnOff = _useBoolean2$.turnOff,
73
73
  toggle = _useBoolean2$.toggle;
74
74
  var classNames = useClassNames(ComponentToken.Popconfirm);
75
- var childRef = useRefs(_ref, _children.props.ref);
76
75
  var popperRef = useRef(null);
77
76
  var theme = useTheme();
78
77
  var _useLocale = useLocale(ComponentToken.Popconfirm),
@@ -90,14 +89,22 @@ var Popconfirm = function Popconfirm(_ref2) {
90
89
  onCancel === null || onCancel === void 0 || onCancel();
91
90
  turnOff();
92
91
  });
93
- // @ts-ignore
94
- var children = /*#__PURE__*/cloneElement(_children, {
95
- ref: childRef,
96
- onClick: onClick
97
- });
92
+ var children = useMemo(function () {
93
+ var props = {
94
+ ref: ref,
95
+ onClick: onClick
96
+ };
97
+ if (/*#__PURE__*/isValidElement(_children)) {
98
+ return /*#__PURE__*/cloneElement(_children, props);
99
+ }
100
+ return /*#__PURE__*/React.createElement("div", {
101
+ ref: ref,
102
+ onClick: onClick
103
+ }, _children);
104
+ }, [ref, onClick, _children]);
98
105
  useClickAway(function () {
99
106
  turnOff();
100
- }, [popperRef, _ref]);
107
+ }, [popperRef, ref]);
101
108
  var styled = {
102
109
  popconfirm: {
103
110
  className: "musaex-2wmp0v musaex-16xn7b0 musaex-rvj5dj musaex-183ukxf musaex-1lsrmdg"
@@ -112,7 +119,7 @@ var Popconfirm = function Popconfirm(_ref2) {
112
119
  }
113
120
  };
114
121
  return /*#__PURE__*/React.createElement(React.Fragment, null, children, /*#__PURE__*/React.createElement(Popper, {
115
- trigger: _ref.current,
122
+ trigger: ref.current,
116
123
  open: isOpen,
117
124
  arrow: true,
118
125
  placement: placement,
@@ -60,5 +60,33 @@ var useIsOpen = function useIsOpen(popperRef) {
60
60
  disappear: disappear
61
61
  }];
62
62
  };
63
+ /**
64
+ * @description
65
+ * used triggers
66
+ */
67
+ var useTriggerBy = function useTriggerBy(triggerBy) {
68
+ var _triggerBy = React.useMemo(function () {
69
+ return new Set(relax.toArray(triggerBy));
70
+ }, [triggerBy]);
71
+ var isHoverable = React.useMemo(function () {
72
+ return _triggerBy.has("hover");
73
+ }, [_triggerBy]);
74
+ var isFocusable = React.useMemo(function () {
75
+ return _triggerBy.has("focus");
76
+ }, [_triggerBy]);
77
+ var isClickable = React.useMemo(function () {
78
+ return _triggerBy.has("click");
79
+ }, [_triggerBy]);
80
+ var isContextMenuable = React.useMemo(function () {
81
+ return _triggerBy.has("contextMenu");
82
+ }, [_triggerBy]);
83
+ return {
84
+ isHoverable: isHoverable,
85
+ isFocusable: isFocusable,
86
+ isClickable: isClickable,
87
+ isContextMenuable: isContextMenuable
88
+ };
89
+ };
63
90
 
64
91
  exports.useIsOpen = useIsOpen;
92
+ exports.useTriggerBy = useTriggerBy;