musae 0.3.3 → 0.3.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.
- package/dist/components/button/button.cjs +11 -10
- package/dist/components/button/button.mjs +7 -6
- package/dist/components/calendar/contribution.cjs +251 -0
- package/dist/components/calendar/contribution.d.ts +13 -0
- package/dist/components/calendar/contribution.mjs +249 -0
- package/dist/components/calendar/index.d.ts +2 -1
- package/dist/components/config/provider.cjs +2 -2
- package/dist/components/config/provider.mjs +2 -2
- package/dist/components/drawer/popup.cjs +51 -17
- package/dist/components/drawer/popup.d.ts +1 -1
- package/dist/components/drawer/popup.mjs +51 -17
- package/dist/components/fab/floatable.d.ts +1 -1
- package/dist/components/icon/icons/action/delete.cjs +20 -0
- package/dist/components/icon/icons/action/delete.d.ts +3 -0
- package/dist/components/icon/icons/action/delete.mjs +18 -0
- package/dist/components/icon/icons/action/index.cjs +7 -1
- package/dist/components/icon/icons/action/index.d.ts +5 -1
- package/dist/components/icon/icons/action/index.mjs +6 -2
- package/dist/components/icon/icons/action/three-d-rotation.cjs +28 -0
- package/dist/components/icon/icons/action/three-d-rotation.d.ts +3 -0
- package/dist/components/icon/icons/action/three-d-rotation.mjs +26 -0
- package/dist/components/icon/icons/editor/attch-file.cjs +20 -0
- package/dist/components/icon/icons/editor/attch-file.d.ts +3 -0
- package/dist/components/icon/icons/editor/attch-file.mjs +18 -0
- package/dist/components/icon/icons/editor/index.cjs +4 -1
- package/dist/components/icon/icons/editor/index.d.ts +3 -1
- package/dist/components/icon/icons/editor/index.mjs +4 -2
- package/dist/components/icon/icons/index.cjs +6 -0
- package/dist/components/icon/icons/index.mjs +3 -0
- package/dist/components/menu/hooks.d.ts +1 -2
- package/dist/components/menu/item.d.ts +2 -3
- package/dist/components/pagination/pagination.cjs +1 -1
- package/dist/components/pagination/pagination.mjs +2 -2
- package/dist/components/popover/popover.cjs +1 -1
- package/dist/components/popover/popover.mjs +1 -1
- package/dist/components/popper/dropdown.cjs +44 -19
- package/dist/components/popper/dropdown.mjs +46 -21
- package/dist/components/popper/hooks.cjs +88 -89
- package/dist/components/popper/hooks.d.ts +7 -13
- package/dist/components/popper/hooks.mjs +91 -91
- package/dist/components/rich-text-editor/plugins/controlled-state/index.cjs +1 -2
- package/dist/components/rich-text-editor/plugins/controlled-state/index.mjs +1 -2
- package/dist/components/rich-text-editor/plugins/markdown-shortcut/index.cjs +5 -4
- package/dist/components/rich-text-editor/plugins/markdown-shortcut/index.d.ts +3 -3
- package/dist/components/rich-text-editor/plugins/markdown-shortcut/index.mjs +3 -4
- package/dist/components/rich-text-editor/rich-text-editor.cjs +5 -5
- package/dist/components/rich-text-editor/rich-text-editor.mjs +3 -3
- package/dist/components/select/utils.cjs +1 -3
- package/dist/components/select/utils.d.ts +1 -1
- package/dist/components/select/utils.mjs +2 -4
- package/dist/components/skeleton/skeleton.cjs +5 -48
- package/dist/components/skeleton/skeleton.d.ts +1 -1
- package/dist/components/skeleton/skeleton.mjs +5 -48
- package/dist/components/steps/context.d.ts +1 -1
- package/dist/components/steps/item.d.ts +1 -1
- package/dist/components/steps/steps.d.ts +1 -1
- package/dist/components/switch/switch.cjs +7 -6
- package/dist/components/switch/switch.d.ts +1 -1
- package/dist/components/switch/switch.mjs +8 -7
- package/dist/components/table/body.cjs +3 -1
- package/dist/components/table/body.mjs +3 -1
- package/dist/components/tabs/context.d.ts +1 -1
- package/dist/components/tabs/hooks.d.ts +2 -2
- package/dist/components/tabs/navigation.d.ts +1 -1
- package/dist/components/tabs/panels.d.ts +1 -1
- package/dist/components/tabs/tab.d.ts +1 -1
- package/dist/components/tabs/tabs.d.ts +1 -1
- package/dist/components/tag/tag.d.ts +1 -1
- package/dist/components/theme/hooks.cjs +6 -6
- package/dist/components/theme/hooks.d.ts +1 -1
- package/dist/components/theme/hooks.mjs +6 -6
- package/dist/components/theme/theme-provider.cjs +12 -6
- package/dist/components/theme/theme-provider.d.ts +2 -2
- package/dist/components/theme/theme-provider.mjs +12 -6
- package/dist/components/time-picker/hooks.d.ts +1 -1
- package/dist/components/time-picker/panel.d.ts +1 -1
- package/dist/components/time-picker/time-picker.d.ts +1 -1
- package/dist/components/timeline/context.d.ts +1 -1
- package/dist/components/timeline/item.d.ts +1 -1
- package/dist/components/timeline/timeline.d.ts +1 -1
- package/dist/components/tooltip/tooltip.d.ts +1 -1
- package/dist/components/transfer/context.d.ts +1 -1
- package/dist/components/transfer/hooks.d.ts +1 -1
- package/dist/components/transfer/item.d.ts +1 -1
- package/dist/components/transfer/list.d.ts +1 -1
- package/dist/components/transfer/transfer.d.ts +1 -1
- package/dist/components/upload/upload.cjs +31 -6
- package/dist/components/upload/upload.d.ts +2 -2
- package/dist/components/upload/upload.mjs +31 -6
- package/dist/components/upload/uploadeds.cjs +119 -55
- package/dist/components/upload/uploadeds.d.ts +1 -1
- package/dist/components/upload/uploadeds.mjs +121 -57
- package/dist/components/upload/utils.cjs +9 -0
- package/dist/components/upload/utils.d.ts +6 -0
- package/dist/components/upload/utils.mjs +9 -0
- package/dist/components/visually-hidden/visually-hidden.d.ts +1 -1
- package/dist/components/waterfall/sequential.d.ts +1 -1
- package/dist/components/waterfall/waterfall.d.ts +1 -1
- package/dist/components/watermark/hooks.d.ts +1 -1
- package/dist/components/watermark/watermark.d.ts +1 -1
- package/dist/hooks/use-class-names.d.ts +1 -0
- package/dist/hooks/use-closable.cjs +0 -8
- package/dist/hooks/use-closable.mjs +0 -8
- package/dist/hooks/use-container.d.ts +1 -1
- package/dist/hooks/use-lazy-boolean.cjs +2 -2
- package/dist/hooks/use-lazy-boolean.mjs +2 -2
- package/dist/index.cjs +2 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +1 -0
- package/dist/locale/locales/en_US.cjs +5 -1
- package/dist/locale/locales/en_US.mjs +5 -1
- package/dist/locale/locales/zh_CN.cjs +5 -1
- package/dist/locale/locales/zh_CN.mjs +5 -1
- package/dist/styles.css +16 -7
- package/dist/types/drawer.d.ts +5 -0
- package/dist/types/element.d.ts +1 -56
- package/dist/types/form.d.ts +39 -1
- package/dist/types/locale.d.ts +6 -0
- package/dist/types/menu.d.ts +8 -3
- package/dist/types/popper.d.ts +1 -1
- package/dist/types/skeleton.d.ts +0 -7
- package/dist/{components/theme/types.d.ts → types/theme.d.ts} +1 -1
- package/dist/types/tree.d.ts +7 -2
- package/dist/{components/upload/types.d.ts → types/upload.d.ts} +59 -22
- package/dist/{components/waterfall/types.d.ts → types/waterfall.d.ts} +3 -3
- package/dist/utils/class-name.cjs +1 -1
- package/dist/utils/class-name.d.ts +3 -1
- package/dist/utils/class-name.mjs +1 -1
- package/dist/utils/colors.cjs +0 -10
- package/dist/utils/colors.d.ts +1 -4
- package/dist/utils/colors.mjs +1 -10
- package/dist/utils/component-token.cjs +1 -0
- package/dist/utils/component-token.d.ts +2 -1
- package/dist/utils/component-token.mjs +1 -0
- package/dist/utils/date.cjs +13 -0
- package/dist/utils/date.d.ts +6 -0
- package/dist/utils/date.mjs +13 -0
- package/package.json +25 -25
- package/dist/components/icon/icons/three-dimension-rotation.d.ts +0 -3
- /package/dist/{components/steps/types.d.ts → types/steps.d.ts} +0 -0
- /package/dist/{components/switch/types.d.ts → types/switch.d.ts} +0 -0
- /package/dist/{components/tabs/types.d.ts → types/tabs.d.ts} +0 -0
- /package/dist/{components/tag/types.d.ts → types/tag.d.ts} +0 -0
- /package/dist/{components/time-picker/types.d.ts → types/time-picker.d.ts} +0 -0
- /package/dist/{components/timeline/types.d.ts → types/timeline.d.ts} +0 -0
- /package/dist/{components/tooltip/types.d.ts → types/tooltip.d.ts} +0 -0
- /package/dist/{components/transfer/types.d.ts → types/transfer.d.ts} +0 -0
- /package/dist/{components/visually-hidden/types.d.ts → types/visually-hidden.d.ts} +0 -0
- /package/dist/{components/watermark/types.d.ts → types/watermark.d.ts} +0 -0
|
@@ -7,7 +7,7 @@ import { useClassNames } from '../../hooks/use-class-names.mjs';
|
|
|
7
7
|
import { PaginationClassToken } from '../../utils/class-name.mjs';
|
|
8
8
|
import { ComponentToken } from '../../utils/component-token.mjs';
|
|
9
9
|
import { useLocale } from '../../locale/use-locale.mjs';
|
|
10
|
-
import { toFunction, clsx } from '@aiszlab/relax';
|
|
10
|
+
import { unique, toFunction, clsx } from '@aiszlab/relax';
|
|
11
11
|
|
|
12
12
|
var Pagination = function Pagination(_ref) {
|
|
13
13
|
var _ref$total = _ref.total,
|
|
@@ -53,7 +53,7 @@ var Pagination = function Pagination(_ref) {
|
|
|
53
53
|
}
|
|
54
54
|
};
|
|
55
55
|
var sizeOptions = useMemo(function () {
|
|
56
|
-
return
|
|
56
|
+
return unique(pageSizes).map(function (size) {
|
|
57
57
|
return {
|
|
58
58
|
value: size,
|
|
59
59
|
label: toFunction(locale.size)(size)
|
|
@@ -96,7 +96,7 @@ var Popover = /*#__PURE__*/React.forwardRef(function (_ref2, ref) {
|
|
|
96
96
|
return relax.chain(_children.props.onFocus, turnOn)(event);
|
|
97
97
|
},
|
|
98
98
|
onBlur: function onBlur(event) {
|
|
99
|
-
return relax.chain(_children.props.onBlur)(event);
|
|
99
|
+
return relax.chain(_children.props.onBlur, disappear)(event);
|
|
100
100
|
}
|
|
101
101
|
}),
|
|
102
102
|
_useFocus2 = _slicedToArray(_useFocus, 2),
|
|
@@ -94,7 +94,7 @@ var Popover = /*#__PURE__*/forwardRef(function (_ref2, ref) {
|
|
|
94
94
|
return chain(_children.props.onFocus, turnOn)(event);
|
|
95
95
|
},
|
|
96
96
|
onBlur: function onBlur(event) {
|
|
97
|
-
return chain(_children.props.onBlur)(event);
|
|
97
|
+
return chain(_children.props.onBlur, disappear)(event);
|
|
98
98
|
}
|
|
99
99
|
}),
|
|
100
100
|
_useFocus2 = _slicedToArray(_useFocus, 2),
|
|
@@ -15,6 +15,25 @@ var dom = require('@aiszlab/relax/dom');
|
|
|
15
15
|
|
|
16
16
|
var _excluded = ["open", "children", "placement", "style", "className", "onExit", "onExited", "onEntered", "trigger", "offset", "overlay", "arrow", "disappearable"];
|
|
17
17
|
var styles = {
|
|
18
|
+
portal: {
|
|
19
|
+
"default": {
|
|
20
|
+
position: "musaex-ixxii4",
|
|
21
|
+
overflow: "musaex-b3r6kr",
|
|
22
|
+
overflowX: null,
|
|
23
|
+
overflowY: null,
|
|
24
|
+
pointerEvents: "musaex-47corl",
|
|
25
|
+
inset: "musaex-10a8y8t",
|
|
26
|
+
insetInline: null,
|
|
27
|
+
insetInlineStart: null,
|
|
28
|
+
insetInlineEnd: null,
|
|
29
|
+
left: null,
|
|
30
|
+
right: null,
|
|
31
|
+
insetBlock: null,
|
|
32
|
+
top: null,
|
|
33
|
+
bottom: null,
|
|
34
|
+
$$css: true
|
|
35
|
+
}
|
|
36
|
+
},
|
|
18
37
|
dropdown: {
|
|
19
38
|
"default": function _default(props) {
|
|
20
39
|
return [{
|
|
@@ -35,7 +54,12 @@ var styles = {
|
|
|
35
54
|
borderTopRightRadius: null,
|
|
36
55
|
borderBottomLeftRadius: null,
|
|
37
56
|
borderBottomRightRadius: null,
|
|
38
|
-
|
|
57
|
+
pointerEvents: "musaex-67bb7w",
|
|
58
|
+
willChange: "musaex-1enemt",
|
|
59
|
+
transitionProperty: "musaex-qzan4j",
|
|
60
|
+
transitionDuration: "musaex-1g2r6go",
|
|
61
|
+
display: "musaex-1s85apg",
|
|
62
|
+
opacity: "musaex-g01cxk",
|
|
39
63
|
$$css: true
|
|
40
64
|
}, {
|
|
41
65
|
"--backgroundColor": props.backgroundColor != null ? props.backgroundColor : "initial"
|
|
@@ -72,7 +96,7 @@ var Dropdown = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
72
96
|
onExited = _ref.onExited,
|
|
73
97
|
onEntered = _ref.onEntered,
|
|
74
98
|
trigger = _ref.trigger,
|
|
75
|
-
|
|
99
|
+
offset = _ref.offset,
|
|
76
100
|
_ref$overlay = _ref.overlay,
|
|
77
101
|
overlay = _ref$overlay === void 0 ? false : _ref$overlay,
|
|
78
102
|
_ref$arrow = _ref.arrow,
|
|
@@ -84,26 +108,23 @@ var Dropdown = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
84
108
|
var theme = hooks.useTheme();
|
|
85
109
|
var _useFloating = hooks$1.useFloating({
|
|
86
110
|
arrowable: arrowable,
|
|
87
|
-
offset:
|
|
111
|
+
offset: offset,
|
|
88
112
|
placement: placement,
|
|
89
113
|
open: open,
|
|
90
|
-
trigger: trigger
|
|
91
|
-
}),
|
|
92
|
-
floatableRef = _useFloating.floatableRef,
|
|
93
|
-
arrowRef = _useFloating.arrowRef;
|
|
94
|
-
var _useAnimation = hooks$1.useAnimation({
|
|
95
|
-
open: open,
|
|
96
|
-
disappearable: disappearable,
|
|
114
|
+
trigger: trigger,
|
|
97
115
|
onEntered: onEntered,
|
|
98
116
|
onExit: onExit,
|
|
99
|
-
onExited: onExited
|
|
117
|
+
onExited: onExited,
|
|
118
|
+
disappearable: disappearable
|
|
100
119
|
}),
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
120
|
+
floatableRef = _useFloating.floatableRef,
|
|
121
|
+
arrowRef = _useFloating.arrowRef,
|
|
122
|
+
_disappear = _useFloating.disappear;
|
|
104
123
|
React.useImperativeHandle(ref, function () {
|
|
105
124
|
return {
|
|
106
|
-
disappear: disappear
|
|
125
|
+
disappear: function disappear() {
|
|
126
|
+
return _disappear(true);
|
|
127
|
+
},
|
|
107
128
|
contains: function contains(node) {
|
|
108
129
|
return dom.contains(floatableRef.current, node);
|
|
109
130
|
}
|
|
@@ -115,10 +136,14 @@ var Dropdown = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
115
136
|
}), overlay && styles.dropdown.overlay),
|
|
116
137
|
arrow: stylex.default.props(styles.arrow["default"]({
|
|
117
138
|
backgroundColor: theme.colors[colors.ColorToken.SurfaceContainer]
|
|
118
|
-
}))
|
|
139
|
+
})),
|
|
140
|
+
portal: stylex.default.props(styles.portal["default"])
|
|
119
141
|
};
|
|
120
|
-
return /*#__PURE__*/React.createElement("div",
|
|
121
|
-
|
|
142
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
143
|
+
className: styled.portal.className,
|
|
144
|
+
style: styled.portal.style
|
|
145
|
+
}, /*#__PURE__*/React.createElement("div", _objectSpread(_objectSpread({
|
|
146
|
+
ref: floatableRef
|
|
122
147
|
}, props), {}, {
|
|
123
148
|
className: relax.clsx(classNames[className.PopperClassToken.Dropdown], className$1, styled.dropdown.className),
|
|
124
149
|
style: _objectSpread(_objectSpread({}, styled.dropdown.style), style)
|
|
@@ -126,7 +151,7 @@ var Dropdown = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
126
151
|
ref: arrowRef,
|
|
127
152
|
className: styled.arrow.className,
|
|
128
153
|
style: styled.arrow.style
|
|
129
|
-
})));
|
|
154
|
+
}))));
|
|
130
155
|
});
|
|
131
156
|
|
|
132
157
|
exports.default = Dropdown;
|
|
@@ -4,8 +4,8 @@ import React, { forwardRef, useImperativeHandle } from 'react';
|
|
|
4
4
|
import { PopperClassToken } from '../../utils/class-name.mjs';
|
|
5
5
|
import { useClassNames } from '../../hooks/use-class-names.mjs';
|
|
6
6
|
import _stylex from '../../node_modules/.pnpm/@stylexjs_stylex@0.7.5/node_modules/@stylexjs/stylex/lib/es/stylex.mjs';
|
|
7
|
-
import {
|
|
8
|
-
import { useFloating
|
|
7
|
+
import { clsx } from '@aiszlab/relax';
|
|
8
|
+
import { useFloating } from './hooks.mjs';
|
|
9
9
|
import { useTheme } from '../theme/hooks.mjs';
|
|
10
10
|
import { ColorToken } from '../../utils/colors.mjs';
|
|
11
11
|
import { ComponentToken } from '../../utils/component-token.mjs';
|
|
@@ -13,6 +13,25 @@ import { contains } from '@aiszlab/relax/dom';
|
|
|
13
13
|
|
|
14
14
|
var _excluded = ["open", "children", "placement", "style", "className", "onExit", "onExited", "onEntered", "trigger", "offset", "overlay", "arrow", "disappearable"];
|
|
15
15
|
var styles = {
|
|
16
|
+
portal: {
|
|
17
|
+
"default": {
|
|
18
|
+
position: "musaex-ixxii4",
|
|
19
|
+
overflow: "musaex-b3r6kr",
|
|
20
|
+
overflowX: null,
|
|
21
|
+
overflowY: null,
|
|
22
|
+
pointerEvents: "musaex-47corl",
|
|
23
|
+
inset: "musaex-10a8y8t",
|
|
24
|
+
insetInline: null,
|
|
25
|
+
insetInlineStart: null,
|
|
26
|
+
insetInlineEnd: null,
|
|
27
|
+
left: null,
|
|
28
|
+
right: null,
|
|
29
|
+
insetBlock: null,
|
|
30
|
+
top: null,
|
|
31
|
+
bottom: null,
|
|
32
|
+
$$css: true
|
|
33
|
+
}
|
|
34
|
+
},
|
|
16
35
|
dropdown: {
|
|
17
36
|
"default": function _default(props) {
|
|
18
37
|
return [{
|
|
@@ -33,7 +52,12 @@ var styles = {
|
|
|
33
52
|
borderTopRightRadius: null,
|
|
34
53
|
borderBottomLeftRadius: null,
|
|
35
54
|
borderBottomRightRadius: null,
|
|
36
|
-
|
|
55
|
+
pointerEvents: "musaex-67bb7w",
|
|
56
|
+
willChange: "musaex-1enemt",
|
|
57
|
+
transitionProperty: "musaex-qzan4j",
|
|
58
|
+
transitionDuration: "musaex-1g2r6go",
|
|
59
|
+
display: "musaex-1s85apg",
|
|
60
|
+
opacity: "musaex-g01cxk",
|
|
37
61
|
$$css: true
|
|
38
62
|
}, {
|
|
39
63
|
"--backgroundColor": props.backgroundColor != null ? props.backgroundColor : "initial"
|
|
@@ -70,7 +94,7 @@ var Dropdown = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
70
94
|
onExited = _ref.onExited,
|
|
71
95
|
onEntered = _ref.onEntered,
|
|
72
96
|
trigger = _ref.trigger,
|
|
73
|
-
|
|
97
|
+
offset = _ref.offset,
|
|
74
98
|
_ref$overlay = _ref.overlay,
|
|
75
99
|
overlay = _ref$overlay === void 0 ? false : _ref$overlay,
|
|
76
100
|
_ref$arrow = _ref.arrow,
|
|
@@ -82,26 +106,23 @@ var Dropdown = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
82
106
|
var theme = useTheme();
|
|
83
107
|
var _useFloating = useFloating({
|
|
84
108
|
arrowable: arrowable,
|
|
85
|
-
offset:
|
|
109
|
+
offset: offset,
|
|
86
110
|
placement: placement,
|
|
87
111
|
open: open,
|
|
88
|
-
trigger: trigger
|
|
89
|
-
}),
|
|
90
|
-
floatableRef = _useFloating.floatableRef,
|
|
91
|
-
arrowRef = _useFloating.arrowRef;
|
|
92
|
-
var _useAnimation = useAnimation({
|
|
93
|
-
open: open,
|
|
94
|
-
disappearable: disappearable,
|
|
112
|
+
trigger: trigger,
|
|
95
113
|
onEntered: onEntered,
|
|
96
114
|
onExit: onExit,
|
|
97
|
-
onExited: onExited
|
|
115
|
+
onExited: onExited,
|
|
116
|
+
disappearable: disappearable
|
|
98
117
|
}),
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
118
|
+
floatableRef = _useFloating.floatableRef,
|
|
119
|
+
arrowRef = _useFloating.arrowRef,
|
|
120
|
+
_disappear = _useFloating.disappear;
|
|
102
121
|
useImperativeHandle(ref, function () {
|
|
103
122
|
return {
|
|
104
|
-
disappear: disappear
|
|
123
|
+
disappear: function disappear() {
|
|
124
|
+
return _disappear(true);
|
|
125
|
+
},
|
|
105
126
|
contains: function contains$1(node) {
|
|
106
127
|
return contains(floatableRef.current, node);
|
|
107
128
|
}
|
|
@@ -113,10 +134,14 @@ var Dropdown = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
113
134
|
}), overlay && styles.dropdown.overlay),
|
|
114
135
|
arrow: _stylex.props(styles.arrow["default"]({
|
|
115
136
|
backgroundColor: theme.colors[ColorToken.SurfaceContainer]
|
|
116
|
-
}))
|
|
137
|
+
})),
|
|
138
|
+
portal: _stylex.props(styles.portal["default"])
|
|
117
139
|
};
|
|
118
|
-
return /*#__PURE__*/React.createElement("div",
|
|
119
|
-
|
|
140
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
141
|
+
className: styled.portal.className,
|
|
142
|
+
style: styled.portal.style
|
|
143
|
+
}, /*#__PURE__*/React.createElement("div", _objectSpread(_objectSpread({
|
|
144
|
+
ref: floatableRef
|
|
120
145
|
}, props), {}, {
|
|
121
146
|
className: clsx(classNames[PopperClassToken.Dropdown], className, styled.dropdown.className),
|
|
122
147
|
style: _objectSpread(_objectSpread({}, styled.dropdown.style), style)
|
|
@@ -124,7 +149,7 @@ var Dropdown = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
124
149
|
ref: arrowRef,
|
|
125
150
|
className: styled.arrow.className,
|
|
126
151
|
style: styled.arrow.style
|
|
127
|
-
})));
|
|
152
|
+
}))));
|
|
128
153
|
});
|
|
129
154
|
|
|
130
155
|
export { Dropdown as default };
|
|
@@ -28,132 +28,125 @@ var useOffsets = function useOffsets(_ref) {
|
|
|
28
28
|
};
|
|
29
29
|
/**
|
|
30
30
|
* @description
|
|
31
|
-
*
|
|
31
|
+
* floating position
|
|
32
32
|
*/
|
|
33
|
-
var
|
|
33
|
+
var useFloating = function useFloating(_ref2) {
|
|
34
34
|
var open = _ref2.open,
|
|
35
|
-
|
|
35
|
+
_trigger = _ref2.trigger,
|
|
36
|
+
placement = _ref2.placement,
|
|
37
|
+
arrowable = _ref2.arrowable,
|
|
38
|
+
_offset = _ref2.offset,
|
|
36
39
|
onEntered = _ref2.onEntered,
|
|
37
40
|
onExit = _ref2.onExit,
|
|
38
|
-
onExited = _ref2.onExited
|
|
41
|
+
onExited = _ref2.onExited,
|
|
42
|
+
disappearable = _ref2.disappearable;
|
|
39
43
|
var _useAnimate = framerMotion.useAnimate(),
|
|
40
44
|
_useAnimate2 = _slicedToArray(_useAnimate, 2),
|
|
41
|
-
|
|
45
|
+
floatableRef = _useAnimate2[0],
|
|
42
46
|
animate = _useAnimate2[1];
|
|
47
|
+
var arrowRef = React.useRef(null);
|
|
48
|
+
var _useContainer = useContainer.useContainer({
|
|
49
|
+
container: _trigger,
|
|
50
|
+
useBody: false
|
|
51
|
+
}, [open]),
|
|
52
|
+
trigger = _useContainer.container;
|
|
53
|
+
var _isOpen = React.useRef(false);
|
|
54
|
+
// appear animation
|
|
55
|
+
// prevent open again when opened
|
|
56
|
+
// first remove `display: none` style
|
|
57
|
+
// then animate
|
|
43
58
|
var appear = relax.useEvent(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
44
59
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
45
60
|
while (1) switch (_context.prev = _context.next) {
|
|
46
61
|
case 0:
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
62
|
+
if (!_isOpen.current) {
|
|
63
|
+
_context.next = 2;
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
return _context.abrupt("return");
|
|
67
|
+
case 2:
|
|
68
|
+
_isOpen.current = true;
|
|
69
|
+
floatableRef.current.style.display = "unset";
|
|
70
|
+
_context.next = 6;
|
|
71
|
+
return animate(floatableRef.current, {
|
|
72
|
+
opacity: 1
|
|
52
73
|
}, {
|
|
53
74
|
duration: 0.2
|
|
54
75
|
});
|
|
55
|
-
case
|
|
56
|
-
_context.next =
|
|
76
|
+
case 6:
|
|
77
|
+
_context.next = 8;
|
|
57
78
|
return onEntered === null || onEntered === void 0 ? void 0 : onEntered();
|
|
58
|
-
case
|
|
79
|
+
case 8:
|
|
59
80
|
case "end":
|
|
60
81
|
return _context.stop();
|
|
61
82
|
}
|
|
62
83
|
}, _callee);
|
|
63
84
|
})));
|
|
85
|
+
// disappear animation
|
|
86
|
+
// prevent disappear again when disappeared
|
|
87
|
+
// when using force disappear, it will be forced to disappear
|
|
64
88
|
var disappear = relax.useEvent(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
89
|
+
var force,
|
|
90
|
+
_args2 = arguments;
|
|
65
91
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
66
92
|
while (1) switch (_context2.prev = _context2.next) {
|
|
67
93
|
case 0:
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
94
|
+
force = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : false;
|
|
95
|
+
if (_isOpen.current) {
|
|
96
|
+
_context2.next = 3;
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
return _context2.abrupt("return");
|
|
100
|
+
case 3:
|
|
101
|
+
if (!(!force && !disappearable)) {
|
|
102
|
+
_context2.next = 5;
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
return _context2.abrupt("return");
|
|
106
|
+
case 5:
|
|
107
|
+
_isOpen.current = false;
|
|
108
|
+
_context2.next = 8;
|
|
109
|
+
return Promise.all([onExit === null || onExit === void 0 ? void 0 : onExit(), animate(floatableRef.current, {
|
|
110
|
+
opacity: 0
|
|
72
111
|
}, {
|
|
73
112
|
duration: 0.2
|
|
74
113
|
}).then(function () {
|
|
75
|
-
|
|
76
|
-
animatableRef.current.style.display = "none";
|
|
114
|
+
floatableRef.current.style.display = "none";
|
|
77
115
|
})]);
|
|
78
|
-
case
|
|
79
|
-
_context2.next =
|
|
116
|
+
case 8:
|
|
117
|
+
_context2.next = 10;
|
|
80
118
|
return onExited === null || onExited === void 0 ? void 0 : onExited();
|
|
81
|
-
case
|
|
119
|
+
case 10:
|
|
82
120
|
case "end":
|
|
83
121
|
return _context2.stop();
|
|
84
122
|
}
|
|
85
123
|
}, _callee2);
|
|
86
124
|
})));
|
|
87
|
-
var _disappear = React.useCallback(function () {
|
|
88
|
-
if (!disappearable) return;
|
|
89
|
-
disappear();
|
|
90
|
-
}, [disappear, disappearable]);
|
|
91
|
-
React.useLayoutEffect(function () {
|
|
92
|
-
if (open) {
|
|
93
|
-
appear();
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
_disappear();
|
|
97
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
98
|
-
}, [open]);
|
|
99
|
-
return {
|
|
100
|
-
animatableRef: animatableRef,
|
|
101
|
-
disappear: disappear
|
|
102
|
-
};
|
|
103
|
-
};
|
|
104
|
-
/**
|
|
105
|
-
* @description
|
|
106
|
-
* floating position
|
|
107
|
-
*/
|
|
108
|
-
var useFloating = function useFloating(_ref5) {
|
|
109
|
-
var open = _ref5.open,
|
|
110
|
-
_trigger = _ref5.trigger,
|
|
111
|
-
placement = _ref5.placement,
|
|
112
|
-
arrowable = _ref5.arrowable,
|
|
113
|
-
_offset = _ref5.offset;
|
|
114
|
-
var floatableRef = React.useRef(null);
|
|
115
|
-
var _useContainer = useContainer.useContainer({
|
|
116
|
-
container: _trigger,
|
|
117
|
-
useBody: false
|
|
118
|
-
}, [open]),
|
|
119
|
-
trigger = _useContainer.container;
|
|
120
|
-
var arrowRef = React.useRef(null);
|
|
121
125
|
// memorized offsets
|
|
122
126
|
var offsets = useOffsets({
|
|
123
127
|
offset: _offset,
|
|
124
128
|
arrowable: arrowable
|
|
125
129
|
});
|
|
126
|
-
//
|
|
127
|
-
|
|
128
|
-
React.useLayoutEffect(function () {
|
|
129
|
-
var floatable = floatableRef.current;
|
|
130
|
+
// position listener
|
|
131
|
+
var position = relax.useEvent(function () {
|
|
130
132
|
if (!trigger) return;
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
dom.computePosition(trigger, floatable, {
|
|
133
|
+
var cleanup = dom.autoUpdate(trigger, floatableRef.current, function () {
|
|
134
|
+
dom.computePosition(trigger, floatableRef.current, {
|
|
134
135
|
placement: placement,
|
|
135
|
-
middleware: [dom.flip(), dom.offset(offsets), arrowable && !!arrowRef.current && dom.arrow({
|
|
136
|
+
middleware: [dom.flip(), dom.shift(), dom.offset(offsets), arrowable && !!arrowRef.current && dom.arrow({
|
|
136
137
|
element: arrowRef.current,
|
|
137
138
|
padding: 16
|
|
138
|
-
}), dom.size({
|
|
139
|
-
apply: function apply(_ref6) {
|
|
140
|
-
var availableWidth = _ref6.availableWidth,
|
|
141
|
-
availableHeight = _ref6.availableHeight,
|
|
142
|
-
floating = _ref6.elements.floating;
|
|
143
|
-
floating.style.maxWidth = "".concat(availableWidth, "px");
|
|
144
|
-
floating.style.maxHeight = "".concat(availableHeight, "px");
|
|
145
|
-
}
|
|
146
139
|
})]
|
|
147
|
-
}).then(function (
|
|
148
|
-
var x =
|
|
149
|
-
y =
|
|
150
|
-
middlewareData =
|
|
151
|
-
_placement =
|
|
140
|
+
}).then(function (_ref5) {
|
|
141
|
+
var x = _ref5.x,
|
|
142
|
+
y = _ref5.y,
|
|
143
|
+
middlewareData = _ref5.middlewareData,
|
|
144
|
+
_placement = _ref5.placement;
|
|
152
145
|
var _placement$split = _placement.split("-"),
|
|
153
146
|
_placement$split2 = _slicedToArray(_placement$split, 1),
|
|
154
147
|
side = _placement$split2[0];
|
|
155
148
|
// set float element styles
|
|
156
|
-
|
|
149
|
+
floatableRef.current.style.translate = "".concat(x, "px ").concat(y, "px");
|
|
157
150
|
// set arrow styles
|
|
158
151
|
if (middlewareData.arrow && !!arrowRef.current) {
|
|
159
152
|
var _middlewareData$arrow, _middlewareData$arrow2;
|
|
@@ -163,25 +156,31 @@ var useFloating = function useFloating(_ref5) {
|
|
|
163
156
|
side === "top" && (arrowRef.current.style.insetBlockEnd = offsetY);
|
|
164
157
|
side === "bottom" && (arrowRef.current.style.insetBlockStart = offsetY);
|
|
165
158
|
}
|
|
159
|
+
// use appear animation
|
|
160
|
+
appear();
|
|
166
161
|
})["catch"](function () {
|
|
167
162
|
return null;
|
|
168
|
-
}).then(function () {
|
|
169
|
-
requestAnimationFrame(function () {
|
|
170
|
-
floatable.style.transitionProperty = "translate";
|
|
171
|
-
floatable.style.transitionDuration = "0.1s";
|
|
172
|
-
});
|
|
173
163
|
});
|
|
174
164
|
});
|
|
175
|
-
return
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
165
|
+
return cleanup;
|
|
166
|
+
});
|
|
167
|
+
// auto update: calc trigger dom to get position
|
|
168
|
+
// if trigger changed, re-relate
|
|
169
|
+
React.useEffect(function () {
|
|
170
|
+
if (open) {
|
|
171
|
+
var cleanup = position();
|
|
172
|
+
return function () {
|
|
173
|
+
cleanup === null || cleanup === void 0 || cleanup();
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
disappear();
|
|
177
|
+
}, [disappear, open, position]);
|
|
179
178
|
return {
|
|
180
179
|
floatableRef: floatableRef,
|
|
181
|
-
arrowRef: arrowRef
|
|
180
|
+
arrowRef: arrowRef,
|
|
181
|
+
disappear: disappear
|
|
182
182
|
};
|
|
183
183
|
};
|
|
184
184
|
|
|
185
|
-
exports.useAnimation = useAnimation;
|
|
186
185
|
exports.useFloating = useFloating;
|
|
187
186
|
exports.useOffsets = useOffsets;
|
|
@@ -11,28 +11,22 @@ export declare const useOffsets: ({ offset, arrowable, }: {
|
|
|
11
11
|
crossAxis?: number;
|
|
12
12
|
alignmentAxis?: number | null;
|
|
13
13
|
};
|
|
14
|
-
/**
|
|
15
|
-
* @description
|
|
16
|
-
* use animation
|
|
17
|
-
*/
|
|
18
|
-
export declare const useAnimation: ({ open, disappearable, onEntered, onExit, onExited, }: {
|
|
19
|
-
open: boolean;
|
|
20
|
-
disappearable: boolean;
|
|
21
|
-
} & Pick<PopperProps, "onEntered" | "onExit" | "onExited">) => {
|
|
22
|
-
animatableRef: import("framer-motion").AnimationScope<HTMLDivElement>;
|
|
23
|
-
disappear: () => Promise<void>;
|
|
24
|
-
};
|
|
25
14
|
/**
|
|
26
15
|
* @description
|
|
27
16
|
* floating position
|
|
28
17
|
*/
|
|
29
|
-
export declare const useFloating: ({ open, trigger: _trigger, placement, arrowable, offset: _offset, }: {
|
|
18
|
+
export declare const useFloating: ({ open, trigger: _trigger, placement, arrowable, offset: _offset, onEntered, onExit, onExited, disappearable, }: {
|
|
30
19
|
open: boolean;
|
|
31
20
|
trigger: DropdownProps["trigger"];
|
|
32
21
|
placement: DropdownProps["placement"];
|
|
33
22
|
arrowable: boolean;
|
|
34
23
|
offset: DropdownProps["offset"];
|
|
24
|
+
onEntered?: () => Promise<void> | void;
|
|
25
|
+
onExit?: () => Promise<void> | void;
|
|
26
|
+
onExited?: () => Promise<void> | void;
|
|
27
|
+
disappearable: boolean;
|
|
35
28
|
}) => {
|
|
36
|
-
floatableRef: import("
|
|
29
|
+
floatableRef: import("framer-motion").AnimationScope<HTMLDivElement>;
|
|
37
30
|
arrowRef: import("react").RefObject<HTMLDivElement>;
|
|
31
|
+
disappear: (force?: boolean) => Promise<void>;
|
|
38
32
|
};
|